@preventive/triage 1.0.0-alpha.16 → 1.0.0-alpha.18

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,50 +1,66 @@
1
- var U=["admin","manage","triage","view","none"];function fr(r){return typeof r=="string"&&U.includes(r)}function gr(r,e){let t=U.indexOf(r);return t!==-1&&t<=U.indexOf(e)}var br=["dependencies","security"],it={dependencies:"Dependencies",security:"Security"};var vr=Object.freeze([{id:"openai/gpt-6-astra-pro",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-6-astra",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-sol",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-terra",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-luna",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.5",efforts:["low","medium","high","xhigh"]},{id:"anthropic/claude-fable-5.1",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-opus-5",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-sonnet-5",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-sonnet-4.6",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-haiku-4.5",efforts:[]},{id:"moonshotai/kimi-k3",efforts:["low","high","max"]},{id:"google/gemini-3.8-flash",efforts:["low","medium","high","max"]},{id:"google/gemma-4-31b-it",efforts:["low","medium","high","max"]},{id:"qwen/qwen3.6-27b",efforts:["low","medium","high","max"]},{id:"nvidia/nemotron-3-super-120b-a12b",efforts:["low","medium","high","max"]},{id:"deepseek/deepseek-v4",efforts:["low","medium","high","max"]}]),_r="anthropic/claude-opus-5";var O=null,st=0;function ot(){return O?.user.role??null}function Yi(r){if(r!==null&&!fr(r))throw new TypeError(`Unknown managed preview role: ${r}. Expected ${U.join(", ")}.`);st++,O=r===null?null:{user:{id:`preview:${r}`,login:r,name:r[0].toUpperCase()+r.slice(1),role:r,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function Ji(r,e){let t=new URL(r,"http://managed-preview.invalid").pathname,i=(e?.method??"GET").toUpperCase();if(i==="POST"&&t==="/api/auth/logout")return Response.json({ok:!0});if(i!=="GET")throw new Error("Changes are not saved in the managed UI preview");if(t==="/api/auth/session")return Response.json(O);if(t==="/api/teams")return Response.json({teams:[]});if(t.startsWith("/api/admin/")&&!gr(O.user.role,"manage"))return Response.json({error:"forbidden"},{status:403});if(["/api/admin/users","/api/admin/teams","/api/admin/repositories"].includes(t)&&O.user.role!=="admin")return Response.json({error:"forbidden"},{status:403});let s={"/api/admin/users":{users:[O.user]},"/api/admin/teams":{teams:[],users:[O.user],repos:[],permissions:br},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/reports":{reports:[],repos:[],maxBytes:10485760},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:104857600},"/api/admin/history":{history:[]},"/api/admin/models":{models:vr,defaultModel:_r},"/api/admin/scan-results":{bundles:[],results:[]}};return Object.hasOwn(s,t)?Response.json(s[t]):Response.json({error:"not-found"},{status:404})}async function y(r,e){if(e?.signal?.throwIfAborted(),O)return Ji(r,e);let t=st,i=await fetch(r,e);if(t!==st)throw new DOMException("Managed session changed","AbortError");return i}var ze=globalThis,Te=ze.ShadowRoot&&(ze.ShadyCSS===void 0||ze.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,nt=Symbol(),yr=new WeakMap,pe=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==nt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Te&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=yr.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&yr.set(t,e))}return e}toString(){return this.cssText}},wr=r=>new pe(typeof r=="string"?r:r+"",void 0,nt),x=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((i,s,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[o+1],r[0]);return new pe(t,r,nt)},xr=(r,e)=>{if(Te)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=ze.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},at=Te?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return wr(t)})(r):r;var{is:Xi,defineProperty:Qi,getOwnPropertyDescriptor:es,getOwnPropertyNames:ts,getOwnPropertySymbols:rs,getPrototypeOf:is}=Object,Ne=globalThis,$r=Ne.trustedTypes,ss=$r?$r.emptyScript:"",os=Ne.reactiveElementPolyfillSupport,ue=(r,e)=>r,lt={toAttribute(r,e){switch(e){case Boolean:r=r?ss:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Sr=(r,e)=>!Xi(r,e),kr={attribute:!0,type:String,converter:lt,reflect:!1,useDefault:!1,hasChanged:Sr};Symbol.metadata??=Symbol("metadata"),Ne.litPropertyMetadata??=new WeakMap;var R=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,t=kr){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Qi(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:o}=es(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get:s,set(n){let a=s?.call(this);o?.call(this,n),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??kr}static _$Ei(){if(this.hasOwnProperty(ue("elementProperties")))return;let e=is(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ue("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ue("properties"))){let t=this.properties,i=[...ts(t),...rs(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(at(s))}else e!==void 0&&t.push(at(e));return t}static _$Eu(e,t){let i=t.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,t=this.constructor.elementProperties;for(let i of t.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 xr(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,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:lt).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let o=i.getPropertyOptions(s),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:lt;this._$Em=s;let a=n.fromAttribute(t,o.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,t,i,s=!1,o){if(e!==void 0){let n=this.constructor;if(s===!1&&(o=this[e]),i??=n.getPropertyOptions(e),!((i.hasChanged??Sr)(o,t)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(n._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:o},n){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),o!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}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[s,o]of this._$Ep)this[s]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[s,o]of i){let{wrapped:n}=o,a=this[s];n!==!0||this._$AL.has(s)||a===void 0||this.C(s,void 0,o,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.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(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[ue("elementProperties")]=new Map,R[ue("finalized")]=new Map,os?.({ReactiveElement:R}),(Ne.reactiveElementVersions??=[]).push("2.1.2");var dt=globalThis,Er=r=>r,Oe=dt.trustedTypes,Ar=Oe?Oe.createPolicy("lit-html",{createHTML:r=>r}):void 0,pt="$lit$",M=`lit$${Math.random().toFixed(9).slice(2)}$`,ut="?"+M,ns=`<${ut}>`,V=document,me=()=>V.createComment(""),fe=r=>r===null||typeof r!="object"&&typeof r!="function",ht=Array.isArray,zr=r=>ht(r)||typeof r?.[Symbol.iterator]=="function",ct=`[
2
- \f\r]`,he=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Cr=/-->/g,Rr=/>/g,j=RegExp(`>|${ct}(?:([^\\s"'>=/]+)(${ct}*=${ct}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Mr=/'/g,Lr=/"/g,Tr=/^(?:script|style|textarea|title)$/i,mt=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),l=mt(1),In=mt(2),zn=mt(3),k=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Ir=new WeakMap,F=V.createTreeWalker(V,129);function Nr(r,e){if(!ht(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ar!==void 0?Ar.createHTML(e):e}var Or=(r,e)=>{let t=r.length-1,i=[],s,o=e===2?"<svg>":e===3?"<math>":"",n=he;for(let a=0;a<t;a++){let c=r[a],d,f,p=-1,b=0;for(;b<c.length&&(n.lastIndex=b,f=n.exec(c),f!==null);)b=n.lastIndex,n===he?f[1]==="!--"?n=Cr:f[1]!==void 0?n=Rr:f[2]!==void 0?(Tr.test(f[2])&&(s=RegExp("</"+f[2],"g")),n=j):f[3]!==void 0&&(n=j):n===j?f[0]===">"?(n=s??he,p=-1):f[1]===void 0?p=-2:(p=n.lastIndex-f[2].length,d=f[1],n=f[3]===void 0?j:f[3]==='"'?Lr:Mr):n===Lr||n===Mr?n=j:n===Cr||n===Rr?n=he:(n=j,s=void 0);let h=n===j&&r[a+1].startsWith("/>")?" ":"";o+=n===he?c+ns:p>=0?(i.push(d),c.slice(0,p)+pt+c.slice(p)+M+h):c+M+(p===-2?a:h)}return[Nr(r,o+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},ge=class r{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0,a=e.length-1,c=this.parts,[d,f]=Or(e,t);if(this.el=r.createElement(d,i),F.currentNode=this.el.content,t===2||t===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=F.nextNode())!==null&&c.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let p of s.getAttributeNames())if(p.endsWith(pt)){let b=f[n++],h=s.getAttribute(p).split(M),g=/([.?@])?(.*)/.exec(b);c.push({type:1,index:o,name:g[2],strings:h,ctor:g[1]==="."?Pe:g[1]==="?"?De:g[1]==="@"?He:G}),s.removeAttribute(p)}else p.startsWith(M)&&(c.push({type:6,index:o}),s.removeAttribute(p));if(Tr.test(s.tagName)){let p=s.textContent.split(M),b=p.length-1;if(b>0){s.textContent=Oe?Oe.emptyScript:"";for(let h=0;h<b;h++)s.append(p[h],me()),F.nextNode(),c.push({type:2,index:++o});s.append(p[b],me())}}}else if(s.nodeType===8)if(s.data===ut)c.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(M,p+1))!==-1;)c.push({type:7,index:o}),p+=M.length-1}o++}}static createElement(e,t){let i=V.createElement("template");return i.innerHTML=e,i}};function q(r,e,t=r,i){if(e===k)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,o=fe(e)?void 0:e._$litDirective$;return s?.constructor!==o&&(s?._$AO?.(!1),o===void 0?s=void 0:(s=new o(r),s._$AT(r,t,i)),i!==void 0?(t._$Co??=[])[i]=s:t._$Cl=s),s!==void 0&&(e=q(r,s._$AS(r,e.values),s,i)),e}var Be=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??V).importNode(t,!0);F.currentNode=s;let o=F.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let d;c.type===2?d=new ie(o,o.nextSibling,this,e):c.type===1?d=new c.ctor(o,c.name,c.strings,this,e):c.type===6&&(d=new Ue(o,this,e)),this._$AV.push(d),c=i[++a]}n!==c?.index&&(o=F.nextNode(),n++)}return F.currentNode=V,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},ie=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=q(this,e,t),fe(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==k&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zr(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!==u&&fe(this._$AH)?this._$AA.nextSibling.data=e:this.T(V.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ge.createElement(Nr(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{let o=new Be(s,this),n=o.u(this.options);o.p(t),this.T(n),this._$AH=o}}_$AC(e){let t=Ir.get(e.strings);return t===void 0&&Ir.set(e.strings,t=new ge(e)),t}k(e){ht(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let o of e)s===t.length?t.push(i=new r(this.O(me()),this.O(me()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let i=Er(e).nextSibling;Er(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},G=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,s){let o=this.strings,n=!1;if(o===void 0)e=q(this,e,t,0),n=!fe(e)||e!==this._$AH&&e!==k,n&&(this._$AH=e);else{let a=e,c,d;for(e=o[0],c=0;c<o.length-1;c++)d=q(this,a[i+c],t,c),d===k&&(d=this._$AH[c]),n||=!fe(d)||d!==this._$AH[c],d===u?e=u:e!==u&&(e+=(d??"")+o[c+1]),this._$AH[c]=d}n&&!s&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Pe=class extends G{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}},De=class extends G{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}},He=class extends G{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=q(this,e,t,0)??u)===k)return;let i=this._$AH,s=e===u&&i!==u||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==u&&(i===u||s);s&&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)}},Ue=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){q(this,e)}},Br={M:pt,P:M,A:ut,C:1,L:Or,R:Be,D:zr,V:q,I:ie,H:G,N:De,U:He,B:Pe,F:Ue},as=dt.litHtmlPolyfillSupport;as?.(ge,ie),(dt.litHtmlVersions??=[]).push("3.3.3");var Pr=(r,e,t)=>{let i=t?.renderBefore??e,s=i._$litPart$;if(s===void 0){let o=t?.renderBefore??null;i._$litPart$=s=new ie(e.insertBefore(me(),o),o,void 0,t??{})}return s._$AI(r),s};var ft=globalThis,w=class extends R{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 t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Pr(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return k}};w._$litElement$=!0,w.finalized=!0,ft.litElementHydrateSupport?.({LitElement:w});var ls=ft.litElementPolyfillSupport;ls?.({LitElement:w});(ft.litElementVersions??=[]).push("4.2.2");var S={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},se=r=>(...e)=>({_$litDirective$:r,values:e}),B=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var be=class extends B{constructor(e){if(super(e),this.it=u,e.type!==S.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===u||e==null)return this._t=void 0,this.it=e;if(e===k)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};be.directiveName="unsafeHTML",be.resultType=1;var L=se(be);var Dr="m5.875 10.154 1.376-.772.023-.067-.023-.037h-.067l-.23-.015-.787-.02-.681-.03-.661-.035-.166-.035-.156-.205.016-.103.14-.094.2.018.442.03.665.046.481.028.714.075h.113l.016-.047-.039-.028-.03-.028-.687-.466-.744-.492-.39-.284-.21-.143-.106-.135-.046-.294.19-.21.258.017.065.018.26.2.557.43.726.535.106.089.042-.03.006-.022-.048-.08-.395-.713-.422-.726-.187-.301-.05-.18a1 1 0 0 1-.03-.213l.218-.296.12-.039.29.039.123.106.18.413.293.65.453.884.133.262.07.242.027.075h.046v-.043l.038-.497.069-.611.067-.787.023-.221.11-.266.218-.143.17.081.14.2-.02.13-.083.54-.163.846-.106.567h.062l.07-.07.287-.382.482-.602.213-.239.248-.264.159-.125h.301l.221.329-.099.34-.31.393-.256.333-.369.496-.23.397.021.032.055-.006.832-.177.45-.081.537-.092.243.113.026.115-.096.236-.573.141-.673.135-1.003.237-.012.01.014.017.452.042.193.01h.473l.88.066.23.153.138.186-.023.141-.354.181-.478-.113-1.116-.266-.383-.096h-.053v.032l.32.312.584.528.731.68.037.168-.094.133-.099-.014-.643-.484-.248-.218-.561-.472H9.08v.05l.129.189.684 1.027.035.315-.05.103-.177.062-.194-.036-.4-.561-.413-.632-.333-.567-.041.023-.197 2.116-.092.108-.212.082-.177-.135-.094-.218.094-.43.113-.561.092-.447.083-.554.05-.184-.004-.013-.04.006-.418.574-.636.858-.503.539-.12.048-.21-.108.02-.193.117-.172.696-.886.42-.549.27-.317-.001-.046h-.016l-1.85 1.201-.328.042-.142-.132.018-.218.067-.071.556-.383Z",oe='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2 2 5v6l6 3 6-3V5L8 2Z"/><path d="M2 5l6 3 6-3"/><path d="M8 8v6"/></svg>';var Hr={default:{className:"brand-deepview",mark:'<path class="fg" d="M7.843 6.719c-1.605 0-2.926 1.292-3.477 1.947.466.58 1.872 2.024 3.496 2.024s2.907-1.292 3.486-2.005c-.627-.703-1.88-1.966-3.505-1.966m.019 3.857c-1.51 0-2.802-1.263-3.353-1.9.55-.617 1.814-1.852 3.334-1.852 1.51 0 2.698 1.12 3.335 1.852-.533.618-1.787 1.9-3.316 1.9m-.019-3.42c-.826 0-1.577.694-1.577 1.596 0 .789.599 1.577 1.577 1.577.893 0 1.587-.684 1.587-1.577-.01-.779-.627-1.596-1.587-1.596m0 3.069a1.476 1.476 0 0 1-1.482-1.473c0-.722.599-1.491 1.482-1.491.846 0 1.482.693 1.492 1.491 0 .808-.618 1.473-1.492 1.473m.01-2.727c-.637 0-1.264.532-1.264 1.244 0 .627.475 1.235 1.245 1.245.684 0 1.254-.522 1.254-1.244 0-.58-.475-1.236-1.235-1.245m-.02 2.403a1.167 1.167 0 0 1-1.149-1.159c0-.532.456-1.14 1.169-1.149.56 0 1.149.427 1.159 1.15 0 .636-.485 1.158-1.179 1.158m-.769-1.833c-.19.238-.275.494-.237.864l.74.057zm1.026-.294c-.295-.057-.665 0-.912.228l.323.607zm.133.047-.38.56.988.114c-.057-.275-.323-.579-.608-.674m-.124.741.456.912c.21-.209.352-.484.314-.836zm-1.225.504a.97.97 0 0 0 .57.617l.399-.551zm.713.664c.313.076.636.01.845-.161l-.295-.618zm-.637 1.55c0 .028-.028.066-.066.066h-.59c-.028 0-.066-.028-.066-.066s.029-.066.067-.066h.579c.048 0 .076.028.076.066m.712 0c0 .028-.028.066-.066.066h-.437c-.028 0-.066-.028-.066-.066s.028-.066.066-.066h.437c.038 0 .066.028.066.066m.666 0c0 .028-.029.066-.067.066h-.37c-.029 0-.067-.028-.067-.066s.029-.066.067-.066h.37c.038 0 .067.028.067.066m-1.672.351c0 .029-.029.067-.067.067h-.295c-.028 0-.066-.028-.066-.066 0-.029.029-.067.067-.067h.294c.038 0 .066.028.066.066m.694 0c0 .029-.028.067-.066.067h-.409c-.028 0-.066-.028-.066-.066 0-.029.028-.067.066-.067h.399c.038 0 .076.028.076.066m.732 0c0 .029-.029.067-.067.067h-.465c-.029 0-.067-.028-.067-.066 0-.029.029-.067.067-.067h.465c.038 0 .067.028.067.066m-1.093.371a.065.065 0 0 1-.067.066h-.627c-.028 0-.075-.028-.066-.066 0-.028.029-.066.067-.066h.627c.038 0 .066.028.066.066m.684 0a.065.065 0 0 1-.066.066h-.39c-.028 0-.076-.028-.066-.066 0-.028.028-.066.066-.066h.39c.038 0 .066.028.066.066M5.088 6.263c-.019-.105-.114-.19-.237-.19s-.257.104-.257.237.105.238.247.238c.105 0 .218-.076.238-.18h.864v.826l.095-.048V6.31c0-.028-.019-.057-.048-.057h-.902zm-.237.19c-.076 0-.143-.066-.143-.143s.066-.142.143-.142.142.066.142.143c.01.076-.066.142-.143.142m2.89-.323H6.38l.418-.475v-.332a.255.255 0 0 0 .218-.248c0-.123-.114-.256-.256-.256s-.266.114-.266.257c0 .123.095.228.209.247v.284l-.456.523v.893l.095-.047v-.742h1.396c.029 0 .067-.009.067-.057 0-.028-.019-.047-.067-.047m-1.13-1.054c0-.076.066-.152.152-.152s.152.066.152.151c0 .076-.066.152-.152.152s-.152-.066-.152-.152m-.836 5.264h-.874c-.019-.105-.114-.219-.247-.219s-.256.105-.256.257c0 .132.114.275.266.275.104 0 .218-.076.237-.19h.827v.608l-.257.285a.3.3 0 0 0-.095-.019c-.133 0-.256.105-.256.228 0 .133.104.238.237.238.124 0 .247-.105.247-.238a.23.23 0 0 0-.057-.152l.285-.304v-.712c0-.029-.019-.058-.057-.058m-1.121.219a.16.16 0 0 1-.152-.161c0-.077.066-.162.152-.162s.152.066.152.152-.066.171-.152.171m.713 1.14c-.076 0-.143-.066-.143-.143s.066-.133.143-.133.142.067.142.143c0 .066-.066.133-.143.133m5.472-1.377a.24.24 0 0 0-.237.208h-1.13c-.029 0-.038.02-.038.048v.712l-.323.39h-.029a.245.245 0 0 0-.247.247c0 .133.114.256.247.256s.247-.113.247-.256a.26.26 0 0 0-.123-.219l.313-.38v-.674h1.083c.019.105.114.2.238.2.133 0 .266-.105.266-.257 0-.133-.105-.276-.266-.276m-1.758 1.767a.15.15 0 0 1-.143-.152c0-.075.067-.142.143-.142s.152.066.152.143a.15.15 0 0 1-.152.151m1.758-1.33a.15.15 0 0 1-.143-.152.147.147 0 0 1 .294.001.15.15 0 0 1-.152.151M8.917 5.55h-.399a.075.075 0 0 1-.076-.076c0-.028.029-.066.067-.066h.418c.028 0 .066.028.066.066s-.038.076-.076.076m.742 0H9.22c-.038 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.437c.038 0 .066.028.066.066s-.028.076-.066.076m.883 0h-.598c-.029 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.598c.028 0 .066.028.066.066s-.028.076-.066.076m-1.282.4h-.741c-.038 0-.076-.029-.076-.067s.028-.076.066-.076h.75c.039 0 .067.038.067.076 0 .029-.028.067-.066.067m.797 0h-.503c-.038 0-.076-.029-.076-.067s.028-.066.066-.066h.513c.038 0 .067.028.067.066 0 .029-.029.067-.067.067m.476 0h-.19c-.039 0-.067-.029-.067-.067s.028-.066.066-.066h.2c.028 0 .066.028.066.066 0 .029-.028.067-.075.067m-1.682.398h-.332c-.039 0-.077-.028-.077-.066s.029-.066.067-.066h.342c.038 0 .076.028.076.066s-.028.066-.076.066m.789 0h-.494c-.038 0-.067-.028-.067-.066s.029-.066.067-.066h.494c.038 0 .066.028.066.066s-.028.066-.066.066m.893 0h-.599c-.038 0-.076-.028-.076-.066s.028-.066.066-.066h.618c.028 0 .066.028.066.066s-.028.066-.076.066m.418.305a.69.69 0 0 0-.674.712c0 .086.019.18.048.257l.085.066c-.028-.085-.057-.171-.057-.304 0-.285.228-.646.598-.646.295 0 .599.228.599.636a.58.58 0 0 1-.599.59.8.8 0 0 1-.237-.048l.123.114a.4.4 0 0 0 .114.01c.39 0 .684-.276.684-.666 0-.313-.266-.712-.684-.722m.353.552-.019-.01-.161.19-.143-.01-.057-.047-.019-.133.19-.2a.28.28 0 0 0-.361.077c-.076.095-.076.209-.038.351l-.247.304.171.152.266-.266c.142.038.285.019.38-.095a.31.31 0 0 0 .038-.313"/>'},"claude-security":{className:"brand-claude",mark:`<path class="fg" d="${Dr}"/>`},"codex-security":{className:"brand-codex",mark:'<path class="fg" d="M11.04 8.364a1.72 1.72 0 0 0-.152-1.432 1.8 1.8 0 0 0-1.925-.846 1.8 1.8 0 0 0-.778-.498 1.8 1.8 0 0 0-.927-.05 1.8 1.8 0 0 0-.827.414 1.77 1.77 0 0 0-.507.767 1.8 1.8 0 0 0-.683.297 1.75 1.75 0 0 0-.499.549 1.75 1.75 0 0 0 .22 2.07 1.72 1.72 0 0 0 .151 1.432 1.8 1.8 0 0 0 1.926.846 1.77 1.77 0 0 0 1.333.587c.78 0 1.47-.496 1.707-1.227a1.8 1.8 0 0 0 .684-.298 1.75 1.75 0 0 0 .499-.548 1.75 1.75 0 0 0-.222-2.063m-2.667 3.678a1.33 1.33 0 0 1-.851-.304l.042-.024 1.413-.804a.23.23 0 0 0 .116-.199V8.747l.597.34q.01.005.011.015v1.629a1.323 1.323 0 0 1-1.328 1.31m-2.857-1.203a1.3 1.3 0 0 1-.158-.879l.042.025 1.414.805a.23.23 0 0 0 .23 0l1.729-.982v.68a.02.02 0 0 1-.01.018l-1.431.814a1.34 1.34 0 0 1-1.816-.48m-.372-3.037a1.32 1.32 0 0 1 .7-.574v1.656a.22.22 0 0 0 .114.197l1.72.979-.598.34a.02.02 0 0 1-.021 0L5.63 9.587a1.304 1.304 0 0 1-.487-1.791zm4.907 1.125L8.327 7.94l.596-.34a.02.02 0 0 1 .02 0l1.43.814a1.3 1.3 0 0 1 .512.528 1.3 1.3 0 0 1-.118 1.4 1.33 1.33 0 0 1-.595.436V9.122a.23.23 0 0 0-.12-.195m.594-.881-.042-.025-1.411-.812a.23.23 0 0 0-.232 0l-1.727.983v-.68a.02.02 0 0 1 .008-.018l1.429-.813a1.34 1.34 0 0 1 1.425.061 1.3 1.3 0 0 1 .55 1.298zM6.908 9.252l-.597-.34a.02.02 0 0 1-.012-.016V7.271c0-.249.073-.493.209-.703s.329-.378.557-.483a1.35 1.35 0 0 1 1.415.18l-.042.023-1.413.804a.23.23 0 0 0-.116.2zm.324-.69.77-.438.77.438v.875l-.768.437-.77-.437z"/>'},deepsec:{className:"brand-vercel",mark:'<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/>'},piolium:{className:"brand-piolium",mark:'<path class="fg" d="M8 6.4 5.6 7.2v2.3c0 1.6 1 2.7 2.4 3.3 1.4-.6 2.4-1.7 2.4-3.3V7.2Z"/>'}},cs={default:["#2563eb","#fff"],"claude-security":["#d97757","#fff"],"codex-security":["#fff","#000"],deepsec:["#000","#fff"],piolium:["#fbb829","#1c1b19"]},gt=Object.fromEntries(Object.entries(Hr).map(([r,{className:e,mark:t}])=>{let[i,s]=cs[r],o=r==="codex-security"||r==="deepsec"?` stroke="${s}" stroke-width=".5"`:"";return[r,`<svg class="file-icon ${e}" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path class="bg" fill="${i}"${o} d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/><g fill="${s}">${t}</g></svg>`]})),bt=Object.fromEntries(Object.entries(Hr).map(([r,{className:e,mark:t}])=>[r,`<span class="report-logo ${e}" aria-hidden="true"><svg viewBox="${r==="default"?"3.5 4 9 9":"4 5 8 8"}" width="14" height="14">${t}</svg></span>`]));var{I:ds}=Br,Ur=r=>r;var Fr=r=>r.strings===void 0,jr=()=>document.createComment(""),ne=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let o=i.insertBefore(jr(),s),n=i.insertBefore(jr(),s);t=new ds(o,n,r,r.options)}else{let o=t._$AB.nextSibling,n=t._$AM,a=n!==r;if(a){let c;t._$AQ?.(r),t._$AM=r,t._$AP!==void 0&&(c=r._$AU)!==n._$AU&&t._$AP(c)}if(o!==s||a){let c=t._$AA;for(;c!==o;){let d=Ur(c).nextSibling;Ur(i).insertBefore(c,s),c=d}}}return t},P=(r,e,t=r)=>(r._$AI(e,t),r),ps={},je=(r,e=ps)=>r._$AH=e,Vr=r=>r._$AH,Fe=r=>{r._$AR(),r._$AA.remove()};var I=se(class extends B{constructor(r){if(super(r),r.type!==S.PROPERTY&&r.type!==S.ATTRIBUTE&&r.type!==S.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Fr(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===k||e===u)return e;let t=r.element,i=r.name;if(r.type===S.PROPERTY){if(e===t[i])return k}else if(r.type===S.BOOLEAN_ATTRIBUTE){if(!!e===t.hasAttribute(i))return k}else if(r.type===S.ATTRIBUTE&&t.getAttribute(i)===e+"")return k;return je(r),e}});var qr=(r,e,t)=>{let i=new Map;for(let s=e;s<=t;s++)i.set(r[s],s);return i},Ve=se(class extends B{constructor(r){if(super(r),r.type!==S.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);let s=[],o=[],n=0;for(let a of r)s[n]=i?i(a,n):n,o[n]=t(a,n),n++;return{values:o,keys:s}}render(r,e,t){return this.dt(r,e,t).values}update(r,[e,t,i]){let s=Vr(r),{values:o,keys:n}=this.dt(e,t,i);if(!Array.isArray(s))return this.ut=n,o;let a=this.ut??=[],c=[],d,f,p=0,b=s.length-1,h=0,g=o.length-1;for(;p<=b&&h<=g;)if(s[p]===null)p++;else if(s[b]===null)b--;else if(a[p]===n[h])c[h]=P(s[p],o[h]),p++,h++;else if(a[b]===n[g])c[g]=P(s[b],o[g]),b--,g--;else if(a[p]===n[g])c[g]=P(s[p],o[g]),ne(r,c[g+1],s[p]),p++,g--;else if(a[b]===n[h])c[h]=P(s[b],o[h]),ne(r,s[p],s[b]),b--,h++;else if(d===void 0&&(d=qr(n,h,g),f=qr(a,p,b)),d.has(a[p]))if(d.has(a[b])){let m=f.get(n[h]),v=m!==void 0?s[m]:null;if(v===null){let $=ne(r,s[p]);P($,o[h]),c[h]=$}else c[h]=P(v,o[h]),ne(r,s[p],v),s[m]=null;h++}else Fe(s[b]),b--;else Fe(s[p]),p++;for(;h<=g;){let m=ne(r,c[g+1]);P(m,o[h]),c[h++]=m}for(;p<=b;){let m=s[p++];m!==null&&Fe(m)}return this.ut=n,je(r,c),k}});var us=new Map([["openai/gpt-6-astra","GPT-6 Astra"],["openai/gpt-6-astra-pro","GPT-6 Astra Pro"],["openai/gpt-5.6-sol","GPT-5.6 Sol"],["openai/gpt-5.6-terra","GPT-5.6 Terra"],["openai/gpt-5.6-luna","GPT-5.6 Luna"],["anthropic/claude-fable-5.1","Claude Fable 5.1"],["anthropic/claude-opus-5","Claude Opus 5"],["anthropic/claude-sonnet-5","Claude Sonnet 5"],["moonshotai/kimi-k3","Kimi K3"],["z-ai/glm-5.3","GLM 5.3"],["qwen/qwen3.8-max","Qwen3.8 Max"],["deepseek/deepseek-v4.1-flash","DeepSeek V4.1 Flash"],["deepseek/deepseek-v4-pro","DeepSeek V4 Pro"]]),hs=new Map([["openai","OpenAI"],["anthropic","Anthropic"],["moonshotai","Moonshot AI"],["google","Google"],["nvidia","NVIDIA"],["qwen","Qwen"],["deepseek","DeepSeek"],["x-ai","xAI"],["z-ai","Z.ai"]]),ms=new Map([["gpt","GPT"],["gptoss","GPT OSS"],["oss","OSS"],["o","O"],["ai","AI"],["api","API"],["4o","4o"],["k3","K3"],["k4","K4"],["qwen","Qwen"],["kimi","Kimi"],["gemini","Gemini"],["claude","Claude"],["fable","Fable"],["opus","Opus"],["sonnet","Sonnet"],["astra","Astra"],["terra","Terra"],["luna","Luna"],["codex","Codex"],["deepseek","DeepSeek"],["nemotron","Nemotron"],["gemma","Gemma"]]);function Gr(r){let e=r.replace(/:free$/u,"").replaceAll("_","-").split("-").filter(Boolean),t=[];for(let s=0;s<e.length;s++){let o=e[s],n=e[s+1];if(/^\d+$/u.test(o)&&/^\d+$/u.test(n??"")){t.push(`${o}.${n}`),s++;continue}let a=ms.get(o.toLowerCase());t.push(a??(/^(?:[a-z]+\d+|\d+[a-z]+)$/iu.test(o)?o.toUpperCase():o[0]?.toUpperCase()+o.slice(1)))}return t.join(" ").replace(/^GPT (\d)/u,"GPT-$1")}function ve(r){return us.get(r)??Gr(r.includes("/")?r.slice(r.indexOf("/")+1):r)}function _e(r){let e=r.includes("/")?r.split("/")[0]:"other";return{key:e,name:hs.get(e)??(e==="other"?"Other":Gr(e))}}function ye(r){return r==="xhigh"?"Extra high":r?r[0].toUpperCase()+r.slice(1):"Unavailable"}function we(r){return r.efforts.includes("max")?"max":r.efforts.at(-1)??null}async function ae(r,e=fetch){let t=await e("/api/admin/models",{credentials:"same-origin",headers:{accept:"application/json"},signal:r});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();return fs(i)}function fs(r){if(!Array.isArray(r?.models))throw new Error("No model catalogue returned");let e=r.models.filter(t=>typeof t?.id=="string"&&t.id.length>0).map(t=>({id:t.id,efforts:Array.isArray(t.efforts)?[...new Set(t.efforts.filter(i=>typeof i=="string"&&i.length>0))]:[]}));if(e.length===0)throw new Error("No models available");return{models:e,defaultModel:e.find(t=>t.id===r.defaultModel)?.id??e[0].id}}function vt(r){let e=new Map(r.map(i=>[i.id,i])),t=new Set;return r.flatMap(i=>{if(t.has(i.id))return[];let s=i.id.endsWith("-pro")?i.id.slice(0,-4):i.id,o=e.get(s),n=e.get(`${s}-pro`);return!/(?:^|\/)gpt-.+$/u.test(s)||s.endsWith("-pro")||!o||!n?[i]:(t.add(o.id),t.add(n.id),[{...o,pro:n}])})}function _t(r){return[...Map.groupBy(vt(r),t=>_e(t.id).key)].map(([t,i])=>({key:t,models:i}))}function Wr(r,e){if(r.length===0)return[];let t=Math.min(r.length,Math.max(1,e)),i=r.map(d=>d.models.length*2+3),s=i.reduce((d,f)=>d+f,0),o=Math.max(...i);for(;o<s;){let d=Math.floor((o+s)/2),f=0,p=1;for(let b of i)f+b>d&&(p++,f=0),f+=b;p>t?o=d+1:s=d}let n=[],a=[],c=0;for(let[d,f]of r.entries())a.length>0&&(c+i[d]>o||r.length-d===t-n.length-1)&&(n.push(a),a=[],c=0),a.push(f),c+=i[d];return n.push(a),n}var gs=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>`;function Kr(r){if(r==="google")return l`<svg class="google-mark" viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M21.35 12.27c0-.79-.07-1.55-.2-2.27H12v4.3h5.24a4.48 4.48 0 0 1-1.94 2.94v2.45h3.15c1.85-1.7 2.9-4.2 2.9-7.42Z"/><path fill="#34A853" d="M12 21.8c2.64 0 4.86-.87 6.48-2.35l-3.15-2.45c-.87.58-1.98.92-3.33.92-2.56 0-4.73-1.73-5.51-4.06H3.24v2.52A9.8 9.8 0 0 0 12 21.8Z"/><path fill="#FBBC05" d="M6.49 13.86a5.9 5.9 0 0 1 0-3.72V7.62H3.24a9.8 9.8 0 0 0 0 8.76l3.25-2.52Z"/><path fill="#EA4335" d="M12 6.08c1.43 0 2.72.49 3.74 1.45l2.8-2.8C16.85 3.14 14.63 2.2 12 2.2a9.8 9.8 0 0 0-8.76 5.42l3.25 2.52C7.27 7.81 9.44 6.08 12 6.08Z"/></svg>`;let e={openai:"openai",anthropic:"claude",moonshotai:"moonshot",nvidia:"nvidia",qwen:"qwen",deepseek:"deepseek","x-ai":"grok","z-ai":"zai"};return e[r]?l`<span class="provider-mark" style="${`--provider-icon: url('/provider-icons/${e[r]}.svg')`}" aria-hidden="true"></span>`:l`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="4" y="4" width="12" height="12" rx="3"/><path d="M8 1v3m4-3v3M8 16v3m4-3v3M1 8h3m-3 4h3m12-4h3m-3 4h3"/></svg>`}var yt=class extends w{static properties={loadModels:{attribute:!1},value:{attribute:!1},effort:{attribute:!1},hasExtra:{type:Boolean,attribute:"has-extra"},_models:{state:!0},_error:{state:!0},_menuColumns:{state:!0}};static styles=x`:host{display:block;min-width:0;container:scan-controls/inline-size}*{box-sizing:border-box}.layout{display:grid;grid-template-columns:minmax(13rem,1fr) minmax(14rem,1fr);gap:1.25rem;align-items:start}.layout.with-extra{grid-template-columns:minmax(13rem,.9fr) minmax(14rem,1.2fr) minmax(14rem,auto)}.field{min-width:0}.label{display:flex;justify-content:space-between;align-items:center;margin-bottom:.4rem;color:var(--muted);font-size:.72rem}output{color:var(--text);font-size:.72rem;font-weight:500}details{position:relative}.model-control{position:relative}summary{display:flex;align-items:center;gap:.55rem;padding:.5rem .6rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);list-style:none;transition:border-color .12s,background .12s}details[open] summary,summary:hover{border-color:var(--muted);background:var(--surface-active)}summary::-webkit-details-marker{display:none}.menu,summary{user-select:none}summary>svg{width:.9rem;height:.9rem;margin-left:auto;color:var(--muted)}.selected-copy{display:grid;gap:.1rem;flex:1;min-width:0}.selected-copy strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8rem;font-weight:500}.selected-copy small{color:var(--muted);font-size:.63rem}.pro-space{width:3.65rem;flex:0 0 3.65rem}.pro-toggle{position:absolute;right:2.05rem;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;justify-content:center;gap:.3rem;width:3.65rem;height:1.65rem;padding:.2rem .3rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--muted);font:inherit;font-size:.65rem;font-weight:600;cursor:default;user-select:none}.pro-toggle:hover{border-color:var(--muted);color:var(--text)}.pro-track{position:relative;flex:0 0 1.3rem;height:.8rem;border-radius:999px;background:var(--border)}.pro-track::after{content:'';position:absolute;top:.15rem;left:.15rem;width:.5rem;height:.5rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.pro-toggle[aria-checked=true]{color:var(--accent);border-color:rgb(from var(--accent) r g b / .45);background:rgb(from var(--accent) r g b / .08)}.pro-toggle[aria-checked=true] .pro-track{background:rgb(from var(--accent) r g b / .25)}.pro-toggle[aria-checked=true] .pro-track::after{transform:translateX(.5rem);background:var(--accent)}.icon{display:inline-grid;place-items:center;width:1.7rem;height:1.5rem;flex:0 0 1.7rem;color:var(--text)}.icon svg{display:block;width:1.1rem;height:1.1rem}.provider-mark{display:block;width:1.12rem;height:1.12rem;background:currentColor;-webkit-mask:var(--provider-icon) center/contain no-repeat;mask:var(--provider-icon) center/contain no-repeat}.icon.openai{color:#10a37f}.icon.anthropic{color:#d97757}.icon.moonshotai{color:#8068d9}.icon.google{color:#4285f4}.icon.nvidia{color:#76b900}.icon.qwen{color:#f97316}.icon.deepseek{color:#4d8dff}.icon.moonshotai .provider-mark{transform:scale(.78)}.icon.qwen .provider-mark{transform:scale(.82)}.icon.nvidia .provider-mark{transform:scale(.86)}.icon.deepseek .provider-mark{transform:scale(.9)}.extra{display:flex;min-width:0;min-height:4.9rem;align-items:flex-end;align-self:end;padding-bottom:.05rem}.menu{visibility:hidden;position:fixed;z-index:1000;width:min(46rem,calc(100vw - 1rem));max-height:calc(100dvh - 1rem);overflow:auto;overscroll-behavior:contain;padding:.65rem;border:1px solid var(--border);border-radius:9px;background:var(--surface-active);color:var(--text);box-shadow:0 .65rem 1.8rem rgb(0 0 0 / .55)}details[open] .menu[data-positioned]{visibility:visible}.groups{display:grid;grid-template-columns:repeat(var(--model-columns,1),minmax(0,1fr));gap:1rem;align-items:start}.provider-column{min-width:0}fieldset{min-width:0;margin:0 0 .6rem;padding:0;border:0}fieldset:last-child{margin-bottom:0}legend{display:flex;align-items:center;gap:.45rem;width:100%;min-height:1.9rem;padding:.35rem .5rem .25rem;border-bottom:1px solid rgb(from var(--border) r g b / .7);color:var(--muted);font-size:.64rem;font-weight:700;letter-spacing:.055em;text-transform:uppercase}legend .icon{width:.88rem;height:1.25rem;flex-basis:.88rem}legend .icon svg{width:.88rem;height:.88rem}legend .provider-mark{width:.88rem;height:.88rem}.choice{display:flex;align-items:center;gap:.5rem;padding:.35rem .5rem;border-radius:4px;font-size:.76rem}.choice:hover{background:rgb(from var(--text) r g b / .05)}.choice:has(:checked){color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.choice input{margin:0;accent-color:var(--accent)}.choice span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.slider{--thumb-size:1rem;padding:.15rem .6rem 0}input[type=range]{appearance:none;display:block;width:100%;height:var(--thumb-size);margin:.4rem 0 .5rem;padding:0;border:0;background:0 0}input[type=range]::-webkit-slider-runnable-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-moz-range-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-webkit-slider-thumb{appearance:none;width:var(--thumb-size);height:var(--thumb-size);margin-top:calc((.3rem - var(--thumb-size))/ 2);border:0;border-radius:50%;background:var(--accent)}input[type=range]::-moz-range-thumb{width:var(--thumb-size);height:var(--thumb-size);border:0;border-radius:50%;background:var(--accent)}input[type=range]:disabled{opacity:.5}.steps{position:relative;height:1.3rem;margin:0 calc(var(--thumb-size)/ 2)}.step{position:absolute;top:0;left:var(--step-position);transform:translateX(-50%);padding:.35rem 0 0;border:0;background:0 0;color:var(--muted);font:inherit;font-size:.62rem;white-space:nowrap;cursor:default}.step::before{content:'';position:absolute;top:0;left:50%;transform:translateX(-50%);width:1px;height:.2rem;background:var(--muted)}.step.active{color:var(--accent)}:is(summary,input,button):focus-visible{outline:2px solid var(--accent);outline-offset:2px}.message{margin:0;color:var(--muted);font-size:.75rem}.error{color:var(--critical,#e5534b)}.retry{margin-left:.5rem;padding:.2rem .4rem;border:1px solid var(--border);border-radius:4px;background:var(--bg);color:var(--text);font:inherit}.layout.with-extra .extra{grid-column:1/-1;align-self:start;min-height:0}.layout.with-extra .extra{grid-column:auto}`;constructor(){super(),this.loadModels=ae,this.value=null,this.effort=null,this.hasExtra=!1,this._models=[],this._error=null,this._menuColumns=1,this._positionRequest=0,this._onOutside=e=>{e.composedPath().includes(this)||this._close()},this._onViewportChange=()=>this._positionMenu()}connectedCallback(){super.connectedCallback(),document.addEventListener("pointerdown",this._onOutside),window.addEventListener("resize",this._onViewportChange),window.addEventListener("scroll",this._onViewportChange,!0),this.hasUpdated&&this._load()}updated(e){e.has("loadModels")&&this.isConnected&&this._load(),e.has("_models")&&this.renderRoot.querySelector("details")?.open&&(this._resetMenuPosition(),this._positionMenu())}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort(),document.removeEventListener("pointerdown",this._onOutside),window.removeEventListener("resize",this._onViewportChange),window.removeEventListener("scroll",this._onViewportChange,!0)}async _load(){this._controller?.abort();let e=new AbortController;this._controller=e,this._error=null;try{let t=await this.loadModels(e.signal);if(e.signal.aborted)return;this._models=t.models;let i=t.models.find(s=>s.id===this.value);i?i.efforts.includes(this.effort)||this._setEffort(we(i)):this._select(t.defaultModel)}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}}_close(){this._resetMenuPosition();let e=this.renderRoot.querySelector("details");e&&(e.open=!1)}_resetMenuPosition(){this._positionRequest++;let e=this.renderRoot.querySelector(".menu");e&&delete e.dataset.positioned}_toggleMenu(e){this._resetMenuPosition(),e.currentTarget.open&&this._positionMenu()}get _selectedRow(){return vt(this._models).find(e=>e.id===this.value||e.pro?.id===this.value)}async _positionMenu(){let e=++this._positionRequest,t=this.renderRoot.querySelector("details"),i=this.renderRoot.querySelector("summary"),s=this.renderRoot.querySelector(".menu");if(!t?.open||!i||!s)return;let o=i.getBoundingClientRect(),n=6,a=8,c=_t(this._models),d=c.reduce((N,Ie)=>N+Ie.models.length,0),f=Math.min(3,c.length,Math.ceil((d+c.length*1.5)/9)),p=parseFloat(getComputedStyle(s).fontSize),b=0;for(let N of s.querySelectorAll(".choice span, legend")){let Ie=document.createRange();Ie.selectNodeContents(N),b=Math.max(b,Ie.getBoundingClientRect().width)}let h=Math.max(11*p,Math.min(18*p,b+2.5*p)),g=1.3*p+2,m=Math.max(1,Math.min(f,Math.floor((window.innerWidth-a*2-g+p)/(h+p)))),v=Math.min(m*h+(m-1)*p+g,window.innerWidth-a*2),$=Math.max(a,Math.min(o.left,window.innerWidth-v-a));if(this._menuColumns=m,await this.updateComplete,e!==this._positionRequest||!this.isConnected||!t.open)return;s.style.left=`${$}px`,s.style.width=`${v}px`,s.style.setProperty("--model-columns",m),s.style.maxHeight=`${Math.max(0,window.innerHeight-a*2)}px`;let _=s.getBoundingClientRect().height,A=window.innerHeight-o.bottom-n-a,Me=o.top-n-a,Le=A<_&&Me>A?o.top-n-_:o.bottom+n;s.style.bottom="auto",s.style.top=`${Math.max(a,Math.min(Le,window.innerHeight-_-a))}px`,s.dataset.positioned=""}_select(e,{preserveEffort:t=!1,close:i=!0}={}){let s=this._models.find(o=>o.id===e);s&&(this.value=e,this._setEffort(t&&s.efforts.includes(this.effort)?this.effort:we(s)),i&&this._close())}_selectRow(e){let t=this._selectedRow?.pro?.id===this.value;this._select(t&&e.pro?e.pro.id:e.id)}_togglePro(){let e=this._selectedRow;e?.pro&&this._select(this.value===e.pro.id?e.id:e.pro.id,{preserveEffort:!0,close:!1})}_setEffort(e){this.effort=e,this.dispatchEvent(new CustomEvent("model-change",{detail:{model:this.value,effort:e},bubbles:!0,composed:!0}))}render(){if(this._error)return l`<p class="message error" role="alert">Couldn’t load models: ${this._error}<button class="retry" @click="${()=>{this._load()}}">Retry</button></p>`;let e=this._models.find(o=>o.id===this.value);if(!e)return l`<p class="message" role="status">Loading models…</p>`;let t=this._selectedRow,i=_e(e.id),s=Wr(_t(this._models),this._menuColumns);return l`<div class="${`layout ${this.hasExtra?"with-extra":""}`}"><div class="field"><span class="label" id="model-label">Model</span><div class="model-control"><details @toggle="${this._toggleMenu}" @keydown="${o=>{o.key==="Escape"&&(this._close(),this.renderRoot.querySelector("summary")?.focus())}}"><summary aria-labelledby="model-label selected-model" @click="${this._resetMenuPosition}"><span class="${`icon ${i.key}`}">${Kr(i.key)}</span><span class="selected-copy"><strong id="selected-model">${ve(t.id)}</strong><small>${i.name}</small></span>${t.pro?l`<span class="pro-space" aria-hidden="true"></span>`:u}${gs}</summary><div class="menu"><div class="groups">${s.map(o=>l`<div class="provider-column">${o.map(n=>this._modelSection(n))}</div>`)}</div></div></details>${t.pro?l`<button type="button" class="pro-toggle" role="switch" aria-label="Pro model" aria-checked="${e.id===t.pro.id}" @click="${this._togglePro}"><span>Pro</span><span class="pro-track" aria-hidden="true"></span></button>`:u}</div></div>${e.efforts.length>0?this._effortSlider(e.efforts):u} ${this.hasExtra?l`<div class="extra"><slot name="effort-extra"></slot></div>`:u}</div>`}_modelSection({key:e,models:t}){return l`<fieldset><legend><span class="${`icon ${e}`}">${Kr(e)}</span>${_e(t[0].id).name}</legend>${t.map(i=>l`<label class="choice"><input type="radio" name="scan-model" value="${i.id}" .checked="${i.id===this.value||i.pro?.id===this.value}" @change="${()=>{this._selectRow(i),this.renderRoot.querySelector("summary")?.focus()}}"><span>${ve(i.id)}</span></label>`)}</fieldset>`}_effortSlider(e){let t=Math.max(0,e.indexOf(this.effort)),i=Math.max(1,e.length-1);return l`<div class="field"><div class="label"><label for="effort">Effort</label><output for="effort">${ye(e[t])}</output></div><div class="slider" style="${`--effort-fill: calc(var(--thumb-size) / 2 + (100% - var(--thumb-size)) * ${t/i})`}"><input id="effort" type="range" min="0" max="${i}" step="1" .value="${String(t)}" ?disabled="${e.length===1}" aria-valuetext="${ye(e[t])}" @input="${s=>this._setEffort(e[Number(s.target.value)])}"><div class="steps">${e.map((s,o)=>l`<button type="button" class="${`step ${s===this.effort?"active":""}`}" style="${`--step-position: ${o/i*100}%`}" aria-label="${`Set effort to ${ye(s)}`}" aria-pressed="${s===this.effort}" @click="${()=>this._setEffort(s)}">${ye(s)}</button>`)}</div></div></div>`}};customElements.get("scan-model-picker")||customElements.define("scan-model-picker",yt);var E=class extends w{static properties={options:{attribute:!1},value:{attribute:!1},label:{type:String},placeholder:{type:String},disabled:{type:Boolean},_query:{state:!0},_facet:{state:!0},_open:{state:!0}};static styles=x`:host{display:block;min-width:0}*{box-sizing:border-box}button,input{font:inherit;color:var(--text)}button{cursor:default;user-select:none}.trigger{display:flex;align-items:center;gap:.6rem;width:100%;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);text-align:left;font-size:.76rem}.trigger:hover:not(:disabled){border-color:var(--muted)}.trigger:disabled{opacity:.5}:host([variant=filter]){display:inline-block;max-width:min(20rem,100%)}:host([variant=filter]) .trigger{height:30px;min-width:8.5rem;background:0 0;font-size:.8rem;font-weight:500;border-radius:4px}.name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.option-copy{flex:1;min-width:0;display:grid;gap:.08rem}.secondary{color:var(--muted);font-size:.64rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.avatar{display:grid;place-items:center;flex:0 0 1.5rem;width:1.5rem;height:1.5rem;border-radius:50%;color:var(--accent);background:rgb(from var(--accent) r g b / .13);font-family:sans-serif;font-size:.62rem;font-weight:600}.count,.detail{flex:0 0 auto;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums;white-space:nowrap}svg{flex:0 0 auto;width:.9rem;height:.9rem;color:var(--muted)}.menu{visibility:hidden;position:fixed;inset:auto;margin:0;padding:0;overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--text);box-shadow:0 .6rem 1.6rem rgb(0 0 0 / .4);user-select:none}.menu:popover-open{display:flex;flex-direction:column}.menu[data-positioned]{visibility:visible}.search{display:flex;align-items:center;gap:.5rem;flex:0 0 auto;padding:.55rem .65rem;border-bottom:1px solid var(--border)}input{flex:1;min-width:0;width:0;padding:.15rem 0;border:0;background:0 0;font-size:.78rem;outline:0}input::placeholder{color:var(--muted)}.search:focus-within{box-shadow:inset 0 -2px var(--accent)}.body{display:flex;min-height:0;flex:1}.facets{width:10.5rem;flex:0 0 auto;padding:.35rem;overflow:auto;overscroll-behavior:none;border-right:1px solid var(--border);background:rgb(from var(--bg) r g b / .25)}.org{display:flex;align-items:center;gap:.4rem;width:100%;padding:.4rem .45rem;border:0;border-radius:4px;background:0 0;text-align:left;font-size:.7rem}.org[aria-pressed=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.results{flex:1;min-width:0;overflow:auto;overscroll-behavior:none;padding:.3rem}.group+.group{margin-top:.35rem;padding-top:.35rem;border-top:1px solid var(--border)}.heading{position:sticky;top:-.3rem;z-index:1;display:flex;align-items:center;gap:.4rem;margin:0;padding:.4rem .5rem;color:var(--muted);background:var(--bg);font-size:.68rem;font-weight:600}.heading svg{width:.8rem;height:.8rem}.option{display:flex;align-items:center;gap:.65rem;width:100%;padding:.35rem .5rem;border:0;border-radius:4px;background:0 0;text-align:left;font-size:.76rem}.option svg{width:.8rem;height:.8rem;opacity:0;color:var(--accent)}.option[aria-selected=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.option[aria-selected=true] svg{opacity:1}.option:disabled{opacity:.45}.option:hover:not(:disabled),.org:hover{background:rgb(from var(--text) r g b / .05)}.pinned{padding-bottom:.25rem;margin-bottom:.25rem;border-bottom:1px solid var(--border)}.empty{margin:0;padding:1.3rem .7rem;color:var(--muted);font-size:.76rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}@media (max-width:40rem){.facets{width:8.5rem}}@media (max-width:28rem){.facets{width:7rem}.option{gap:.35rem}}`;constructor(){super(),this.options=[],this.value=null,this.label="Choose",this.placeholder="Choose",this.disabled=!1,this._query="",this._facet=null,this._open=!1,this._menuHeight=null,this._onViewport=()=>this._position()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onViewport),window.addEventListener("scroll",this._onViewport,!0)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onViewport),window.removeEventListener("scroll",this._onViewport,!0)}render(){let e=this.options.find(n=>n.value===this.value),t=this.choices(),s=[...t.pinned,...t.sections.flatMap(n=>n.options)].filter(n=>!n.disabled),o=s.find(n=>n.value===this.value)?.value??s[0]?.value;return l`<button type="button" class="trigger" popovertarget="selector-menu" aria-label="${this.label}" aria-haspopup="dialog" aria-expanded="${this._open}" ?disabled="${this.disabled}">${e?this.optionIcon(e):u}<span class="name">${e?.label??this.placeholder}</span>${e?.detail?l`<span class="detail">${e.detail}</span>`:u} <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg></button><div class="menu" id="selector-menu" popover="auto" role="dialog" aria-label="${this.label}" @beforetoggle="${this._beforeToggle}" @toggle="${this._toggle}" @keydown="${this._keyDown}"><div class="search"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${`${this.searchLabel}\u2026`}" aria-label="${this.searchLabel}" aria-controls="selector-options" .value="${I(this._query)}" @input="${n=>{this._query=n.target.value}}"> <span class="count" role="status">${t.count}${t.count===t.total?"":` / ${t.total}`}</span></div><div class="body">${t.showFacets?l`<div class="facets" role="group" aria-label="${this.facetLabel}"><button type="button" class="org" aria-pressed="${t.activeFacet==null}" @click="${()=>this._filterFacet(null)}"><span class="name">${this.allFacetsLabel}</span><span class="count">${t.total}</span></button> ${t.facets.map(n=>l`<button type="button" class="org" title="${n.name}" aria-pressed="${t.activeFacet===n.value}" @click="${()=>this._filterFacet(n.value)}"><span class="name">${n.name}</span><span class="count">${n.count}</span></button>`)}</div>`:u}<div class="results" id="selector-options" role="listbox" aria-label="${this.optionsLabel}">${t.pinned.length>0?l`<div class="pinned">${t.pinned.map(n=>this._option(n,!1,o))}</div>`:u} ${t.sections.map((n,a)=>l`<div class="group" role="group" aria-labelledby="${n.label?`selector-group-${a}`:u}">${n.label?l`<h3 class="heading" id="${`selector-group-${a}`}">${n.organization?l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" aria-hidden="true"><path d="M3 14V3h6v11M9 7h4v7M1 14h14M5 6h2M5 9h2M5 12h2"/></svg>`:u}${n.label}</h3>`:u} ${n.options.map(c=>this._option(c,n.organization,o))}</div>`)} ${t.count?u:l`<p class="empty">${this.options.length>0?this.noMatchesLabel:this.emptyLabel}</p>`}</div></div></div>`}optionIcon(e){return u}optionTitle(e){return e.label}_option(e,t,i){return l`<button type="button" class="option" role="option" ?data-reset="${e.reset}" ?disabled="${e.disabled}" aria-label="${e.label}" title="${this.optionTitle(e)}" aria-selected="${e.value===this.value}" tabindex="${e.value===i?0:-1}" @click="${()=>this._pick(e.value)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>${this.optionIcon(e)}${e.initials?l`<span class="avatar" aria-hidden="true">${e.initials}</span>`:u}<span class="option-copy"><span class="name">${e.displayLabel??(t?e.name:e.label)}</span>${e.secondary?l`<span class="secondary">${e.secondary}</span>`:u}</span>${e.detail?l`<span class="detail">${e.detail}</span>`:u}</button>`}updated(e){this.disabled&&this._open&&this._close(!1),e.has("options")&&(this._menuHeight=null),this._position(),(e.has("_query")||e.has("_facet"))&&(this.renderRoot.querySelector(".results").scrollTop=0)}_beforeToggle(e){this._open=e.newState==="open",delete e.target.dataset.positioned,this._open&&(this._query="",this._facet=null,this._menuHeight=null)}async _toggle(e){e.newState==="open"&&(await this.updateComplete,!(!this._open||!this.isConnected)&&(this._position(),this.renderRoot.querySelector("input").focus({preventScroll:!0})))}_position(){let e=this.renderRoot.querySelector(".menu");if(!e?.matches(":popover-open"))return;let t=this.renderRoot.querySelector(".trigger").getBoundingClientRect(),i=8,s=e.querySelector(".facets")!=null,o=Math.min(Math.max(t.width,s?560:360),window.innerWidth-i*2),n=window.innerHeight-t.bottom-i-4,a=t.top-i-4;e.style.width=`${o}px`,this._menuHeight??=Math.min(480,e.querySelector(".search").offsetHeight+Math.max(e.querySelector(".results").scrollHeight,e.querySelector(".facets")?.scrollHeight??0)+2);let c=this._menuHeight,d=n<c&&a>n;e.style.maxHeight=`${Math.max(0,Math.min(c,d?a:n))}px`,e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-o-i))}px`,e.style.top=`${Math.max(i,d?t.top-e.offsetHeight-4:t.bottom+4)}px`,e.dataset.positioned=""}_filterFacet(e){this._facet=e,this.renderRoot.querySelector("input").focus({preventScroll:!0})}_keyDown(e){if(e.stopPropagation(),e.key==="Escape"){e.preventDefault(),this._close();return}let t=this.renderRoot.querySelector("input"),i=this.renderRoot.activeElement,s=[...this.renderRoot.querySelectorAll(".option:not(:disabled)")],o=s.indexOf(i);if(i!==t&&o<0)return;if(e.key==="Enter"&&i===t){e.preventDefault(),(this.renderRoot.querySelector(".option:not([data-reset]):not(:disabled)")??s[0])?.click();return}let n;if(e.key==="ArrowDown")n=Math.min(o+1,s.length-1);else if(e.key==="ArrowUp")n=o-1;else if(i!==t&&e.key==="Home")n=0;else if(i!==t&&e.key==="End")n=s.length-1;else if(i!==t&&e.key.length===1&&e.key!==" "&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault(),this._query+=e.key,t.focus();return}else return;e.preventDefault();for(let[a,c]of s.entries())c.tabIndex=a===n?0:-1;n<0?t.focus():s[n]?.focus()}_pick(e){this.disabled||!this.options.some(t=>t.value===e&&!t.disabled)||(this._close(),this.dispatchEvent(new CustomEvent(this.changeEvent,{detail:{value:e},bubbles:!0,composed:!0})))}_close(e=!0){this.renderRoot.querySelector(".menu").hidePopover(),this._open=!1,e&&this.renderRoot.querySelector(".trigger").focus({preventScroll:!0})}};function bs(r){if(/^https?:\/\//iu.test(r)){try{let t=new URL(r),i=t.pathname.split("/").filter(Boolean);if(i.length>=2)return{owner:`${t.host}/${i[0]}`,name:i.slice(1).join("/")}}catch{}return{owner:null,name:r}}let e=/^([^\s/:]+)\/(.+)$/u.exec(r);return e?{owner:e[1],name:e[2]}:{owner:null,name:r}}var Zr=r=>r.normalize("NFKC").toLocaleLowerCase(),wt=(r,e)=>r.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"}),xt=Symbol("other repositories");function Yr(r,e="",t=null){let i=r.map(m=>({...m,...m.special?{owner:null,name:m.label}:bs(m.label)})),s=new Map;for(let m of i)m.owner!=null&&s.set(m.owner,(s.get(m.owner)??0)+1);let o=[...s].filter(([,m])=>m>1).toSorted(([m],[v])=>wt(m,v)).map(([m,v])=>({value:m,name:m,count:v})),n=m=>(s.get(m.owner)??0)<=1,a=i.filter(m=>!m.special&&!m.reset&&n(m)).length;a>0&&o.push({value:xt,name:"Other",count:a});let c=o.some(m=>m.value===t)?t:null,d=Zr(e.trim()).split(/\s+/u).filter(Boolean),f=m=>d.every(v=>Zr(m.label).includes(v)),p=i.filter(m=>m.reset||m.special&&f(m)),b=i.filter(m=>!m.reset&&!m.special&&f(m)&&(c==null||(c===xt?n(m):m.owner===c))),h=new Map;for(let m of b){let v=(s.get(m.owner)??0)>1?m.owner:null;h.has(v)||h.set(v,[]),h.get(v).push(m)}let g=[...h].toSorted(([m],[v])=>m==null?1:v==null?-1:wt(m,v)).map(([m,v])=>({label:m??(o.some($=>$.value!==xt)?"Other":null),organization:m!=null,options:v.toSorted(($,_)=>wt($.label,_.label))}));return{facets:o,activeFacet:c,pinned:p,sections:g,count:b.length+p.filter(m=>!m.reset).length,total:i.filter(m=>!m.reset).length,showFacets:o.length>1}}var $t=class extends E{constructor(){super(),this.label="Choose repository",this.placeholder="Choose repository"}get searchLabel(){return"Search repositories"}get optionsLabel(){return"Repositories"}get facetLabel(){return"Filter by organization"}get allFacetsLabel(){return"All organizations"}get noMatchesLabel(){return"No matching repositories"}get emptyLabel(){return"No repositories available"}get changeEvent(){return"repository-change"}choices(){return Yr(this.options,this._query,this._facet)}};customElements.get("repository-selector")||customElements.define("repository-selector",$t);function W(r){return!Number.isFinite(r)||r<0?"\u2014":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KiB`:r<1073741824?`${(r/1048576).toFixed(1)} MiB`:`${(r/1073741824).toFixed(1)} GiB`}function xe(r){return Array.isArray(r)?r.reduce((e,t)=>({bytes:e.bytes!=null&&Number.isFinite(t.bytes)?e.bytes+t.bytes:null,lines:e.lines!=null&&Number.isFinite(t.lines)?e.lines+t.lines:null}),{bytes:0,lines:0}):{bytes:null,lines:null}}function kt(r){return(r??[]).filter(e=>!["resource:base64","directory"].includes(e.format))}function vs(r){return r.map(e=>{let t=["sourcemap","sourcemaps"].includes(e.kind)||e.filename.toLowerCase().endsWith(".map")?"sourcemap":"stasis",i=t==="sourcemap"?"Sourcemap":"Stasis",s=[];if(typeof e.size=="string"&&!["","\u2014"].includes(e.size)&&s.push(e.size),e.files){s.push(`${e.files.length.toLocaleString()} files`);let{lines:o}=xe(e.files);o!=null&&s.push(`${o.toLocaleString()} LoC`)}return{value:e.id,label:e.filename,detail:i,format:t,secondary:s.join(" \xB7 ")}})}var St=class extends E{static properties={bundles:{attribute:!1}};static styles=[E.styles,x`.bundle-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 1.05rem;width:1.05rem;height:1.05rem;color:var(--muted)}.bundle-icon img,.bundle-icon svg{display:block;width:100%;height:100%;opacity:1}.option{gap:.5rem;padding-block:.25rem}.option-copy{gap:0}.option .name{line-height:1.3}.option .bundle-icon{flex-basis:1.35rem;width:1.35rem;height:1.35rem;margin-right:.15rem}.secondary{line-height:1.25;font-variant-numeric:tabular-nums}`];constructor(){super(),this.bundles=[],this.label="Choose bundle",this.placeholder="Choose bundle"}get searchLabel(){return"Search bundles"}get optionsLabel(){return"Bundles"}get noMatchesLabel(){return"No matching bundles"}get emptyLabel(){return"No stored bundles"}get changeEvent(){return"bundle-change"}willUpdate(e){e.has("bundles")&&(this.options=vs(this.bundles))}optionIcon(e){return l`<span class="bundle-icon" aria-hidden="true">${e.format==="sourcemap"?L(oe):l`<img src="./stasis.svg" alt="">`}</span>`}optionTitle(e){return u}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>`${i.label} ${i.detail}`.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("bundle-selector")||customElements.define("bundle-selector",St);var Et=class extends E{constructor(){super(),this.label="Choose workspace",this.placeholder="Choose workspace"}get searchLabel(){return"Search workspaces"}get optionsLabel(){return"Workspaces"}get noMatchesLabel(){return"No matching workspaces"}get emptyLabel(){return"No workspaces available"}get changeEvent(){return"workspace-change"}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>i.label.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("workspace-selector")||customElements.define("workspace-selector",Et);var $e=r=>({kind:r,sourceId:null,ids:new Set}),At=class extends w{static properties={mode:{type:String},loadSources:{attribute:!1},restore:{attribute:!1},_sources:{state:!0},_loading:{state:!0},_error:{state:!0},_merge:{state:!0},_link:{state:!0}};constructor(){super(),this.mode="link",this._sources=null,this._loading=!1,this._error=null,this._merge=$e("bundle"),this._link=$e("repository")}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadSources")){this._load();return}e.has("mode")&&this._selectOnlySource(),e.has("restore")&&this._restore(),["_sources","_merge","_link","mode","restore"].some(t=>e.has(t))&&this._notify()}get _current(){return this.mode==="merge"?this._merge:this._link}get _parents(){if(this.mode==="merge")return this._sources?.merge?.bundles??[];let e=this._sources?.link?.reports??[];return this._current.kind==="workspace"?(this._sources?.link?.workspaces??[]).filter(t=>e.some(i=>t.reports.includes(i.id))):(this._sources?.link?.repositories??[]).filter(t=>e.some(i=>i.repoIds.includes(t.id)))}get _parent(){return this._parents.find(e=>e.id===this._current.sourceId)}get _scopeOptions(){let e=this._sources?.link?.reports??[];return this._parents.map(t=>{let i=e.filter(s=>this._current.kind==="workspace"?t.reports.includes(s.id):s.repoIds.includes(t.id)).length;return{value:t.id,label:t.label,detail:`${i} ${i===1?"report":"reports"}`}})}get _inputs(){return this._parent?this.mode==="merge"?(this._sources?.merge?.results??[]).filter(e=>e.bundleId===this._parent.id):(this._sources?.link?.reports??[]).filter(e=>this._current.kind==="workspace"?this._parent.reports.includes(e.id):e.repoIds.includes(this._parent.id)):[]}get selection(){let e=this._parent;return{mode:this.mode,source:e?{kind:this._current.kind,id:e.id,label:e.label??e.filename}:null,inputs:this._loading||this._error?[]:this._inputs.filter(t=>this._current.ids.has(t.id))}}_notify(){this.dispatchEvent(new CustomEvent("report-inputs-change",{detail:this.selection,bubbles:!0,composed:!0}))}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();try{let t=this.loadSources?await this.loadSources(e.signal):{merge:{bundles:[],results:[]},link:{repositories:[],reports:[]}};if(e.signal.aborted)return;this._sources=t,this._merge=$e("bundle"),this._link=$e(Array.isArray(t.link?.workspaces)?"workspace":"repository"),this._selectOnlySource(),this._restore()}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_setCurrent(e){this.mode==="merge"?this._merge=e:this._link=e}_selectSource(e){e===this._current.sourceId||!this._parents.some(t=>t.id===e)||(this._setCurrent({...this._current,sourceId:e,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.map(t=>t.id))}),this._notify())}_changeKind(e){["workspace","repository"].includes(e)&&(e==="workspace"&&!Array.isArray(this._sources?.link?.workspaces)||(e!==this._link.kind&&(this._link=$e(e)),this._selectOnlySource(),this._notify()))}_selectOnlySource(){this.mode==="link"&&this._current.sourceId==null&&this._parents.length===1&&this._selectSource(this._parents[0].id)}_toggle(e,t){if(!this._inputs.some(s=>s.id===e))return;let i=new Set(this._current.ids);t?i.add(e):i.delete(e),this._setCurrent({...this._current,ids:i}),this._notify()}_selectAll(e){this._setCurrent({...this._current,ids:new Set(e?this._inputs.map(t=>t.id):[])}),this._notify()}_restore(){let e=this.restore;if(!this._sources||e?.mode!==this.mode||!e.source)return;let t=this.mode==="merge"?"bundle":e.source.kind;this.mode==="link"&&(t==="workspace"?!Array.isArray(this._sources.link?.workspaces):t!=="repository")||(this._setCurrent({kind:t,sourceId:e.source.id,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(i=>e.inputIds.includes(i.id)).map(i=>i.id))}))}render(){let e=this.mode==="merge",t=this._inputs,i=this.selection.inputs.length,s=Array.isArray(this._sources?.link?.workspaces),o=this._parent?e?"No scan results for this bundle.":`No saved reports in this ${this._current.kind}.`:e?"Choose a bundle to see its scan results.":this._parents.length===0?"No saved reports with app findings.":`Choose a ${this._current.kind} to see its saved reports.`;return l`<section class="panel" aria-label="${e?"Merge scan results":"Link saved reports"}" aria-busy="${this._loading}"><div class="source">${!e&&s?l`<div class="kinds" role="radiogroup" aria-label="Report source">${[["workspace","Workspace"],["repository","Repository"]].map(([n,a])=>l`<button type="button" role="radio" aria-checked="${n===this._link.kind}" @click="${()=>this._changeKind(n)}">${a}</button>`)}</div>`:u}<div class="field">${e?l`<span>Bundle with scan results</span>`:u} ${e?l`<bundle-selector .bundles="${this._parents}" .value="${this._current.sourceId}" ?disabled="${this._loading||this._parents.length===0}" @bundle-change="${n=>this._selectSource(n.detail.value)}"></bundle-selector>`:this._current.kind==="workspace"?l`<workspace-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @workspace-change="${n=>this._selectSource(n.detail.value)}"></workspace-selector>`:l`<repository-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @repository-change="${n=>this._selectSource(n.detail.value)}"></repository-selector>`}</div></div>${this._error?l`<p class="empty" role="alert">Couldn’t load report inputs: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:this._loading?l`<p class="empty" role="status">Loading report inputs…</p>`:t.length>0?l`<div class="list-head"><label><input type="checkbox" aria-label="Select all" .checked="${i===t.length}" .indeterminate="${i>0&&i<t.length}" @change="${n=>this._selectAll(n.target.checked)}"><strong>All</strong></label><span>${i} of ${t.length} selected</span></div><div class="list">${t.map(n=>this._row(n))}</div>`:l`<p class="empty">${e&&this._parents.length===0?"No scan results available.":o}</p>`}</section>`}_row(e){let t=this.mode==="link"?e.appFindings:e.findings,i=[e.model?ve(e.model):null,t==null?null:`${t} ${this.mode==="link"?"app ":""}${t===1?"finding":"findings"}`,e.createdAt,e.repo?`${e.repo}${e.directory?`/${e.directory}`:""}`:null].filter(Boolean);return l`<label class="option"><input type="checkbox" .checked="${this._current.ids.has(e.id)}" @change="${s=>this._toggle(e.id,s.target.checked)}">${L(gt[e.analyzer]??gt.default)}<span class="copy"><strong>${e.title??e.filename}</strong><span>${i.join(" \xB7 ")}</span></span></label>`}static styles=x`:host{display:block;min-width:0}*{box-sizing:border-box}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.source{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding:.85rem .9rem;border-bottom:1px solid var(--border)}.field{display:grid;flex:1 1 14rem;gap:.3rem;max-width:32rem;min-width:0}.field>span{color:var(--muted);font-size:.72rem}button{padding:.3rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}.kinds{display:flex;width:fit-content;border:1px solid var(--border);border-radius:5px;overflow:hidden}.kinds button{padding-block:.5rem;border:0;border-radius:0;color:var(--muted)}.kinds button+button{border-left:1px solid var(--border)}.kinds button[aria-checked=true]{color:var(--text);background:var(--surface-active)}.list-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.55rem .9rem;border-bottom:1px solid var(--border)}.list-head label{display:flex;align-items:center;gap:.55rem;user-select:none}.list-head strong{color:var(--text);font-size:.74rem;font-weight:600}.list-head>span{color:var(--muted);font-size:.68rem}.list{max-height:24rem;overflow:auto;overscroll-behavior:none}.option{display:flex;align-items:center;gap:.55rem;min-width:0;padding:.35rem .9rem;user-select:none}.option+.option{border-top:1px solid var(--border)}.option:hover{background:var(--surface-active)}input{width:.85rem;height:.85rem;margin:0;flex:0 0 auto;accent-color:var(--accent)}.file-icon{width:1.4rem;height:1.4rem;flex:0 0 auto}.copy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex:1;min-width:0}.copy span,.copy strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy strong{flex:1;color:var(--text);font-size:.74rem;font-weight:500}.copy span{max-width:55%;color:var(--muted);font-size:.66rem}.empty{margin:0;padding:1rem .9rem;color:var(--muted);font-size:.76rem}button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}`};customElements.get("scan-report-inputs")||customElements.define("scan-report-inputs",At);var _s=l`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h7M6 8h7M6 12h7M3 4h.01M3 8h.01M3 12h.01"/></svg>`,ys=l`<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3M7 5v4M5 7h4"/></svg>`,Ct=class extends w{static properties={isolate:{type:Boolean},vertical:{type:Boolean,reflect:!0}};constructor(){super(),this.isolate=!1,this.vertical=!1}_select(e){this.isolate!==e&&(this.isolate=e,this.dispatchEvent(new CustomEvent("depth-change",{detail:{isolate:e},bubbles:!0,composed:!0})))}render(){return l`<div class="scan-depth"><div class="depth-options" role="radiogroup" aria-label="Scan depth" aria-orientation="${this.vertical?"vertical":"horizontal"}" aria-describedby="${this.vertical?u:"scan-depth-description"}">${[[!1,"List",_s],[!0,"Isolate",ys]].map(([e,t,i])=>l`<label class="depth-choice"><input type="radio" name="scan-depth" value="${e?"isolate":"list"}" .checked="${this.isolate===e}" @change="${()=>this._select(e)}"><span>${i}${t}</span></label>`)}</div>${this.vertical?u:l`<div class="depth-description" id="scan-depth-description" aria-live="polite"><span class="${this.isolate?"inactive":""}" aria-hidden="${this.isolate}">Regular scan depth</span><span class="${this.isolate?"":"inactive"}" aria-hidden="${!this.isolate}">Deeper search at ~10x the tokens spent</span></div>`}</div>`}static styles=x`:host{display:block;width:19rem;max-width:100%;min-width:0}*{box-sizing:border-box}.scan-depth{display:grid;gap:.4rem;width:100%;min-width:0;user-select:none}.depth-options{display:flex;position:relative;padding:.2rem;border:1px solid var(--border);border-radius:8px;background:var(--bg)}.depth-options::before{content:'';position:absolute;inset:.2rem auto .2rem .2rem;width:calc((100% - .4rem)/ 2);border-radius:5px;background:var(--surface-active);box-shadow:0 1px 3px rgb(0 0 0 / .12),inset 0 0 0 1px rgb(from var(--accent) r g b / .18);transition:transform .16s ease-out}.depth-options:has(input[value=isolate]:checked)::before{transform:translateX(100%)}.depth-choice{position:relative;flex:1;min-width:0}.depth-choice input{position:absolute;width:1px;height:1px;opacity:0}.depth-choice span{display:flex;align-items:center;justify-content:center;gap:.4rem;height:1.9rem;padding:.3rem .65rem;border-radius:5px;color:var(--muted);font-size:.76rem;font-weight:500;transition:color .12s}.depth-choice svg{width:.95rem;height:.95rem;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.depth-choice:hover span{color:var(--text)}.depth-choice input:checked+span{color:var(--accent)}.depth-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.depth-description{display:grid;color:var(--muted);font-size:.68rem;line-height:1.4}.depth-description span{grid-area:1/1}.depth-description .inactive{visibility:hidden}@media (prefers-reduced-motion:reduce){.depth-choice span,.depth-options::before{transition:none}}:host([vertical]){width:5.8rem}:host([vertical]) .depth-options{flex-direction:column}:host([vertical]) .depth-options::before{inset:.2rem .2rem auto;width:auto;height:calc((100% - .4rem)/ 2)}:host([vertical]) .depth-options:has(input[value=isolate]:checked)::before{transform:translateY(100%)}:host([vertical]) .depth-choice span{justify-content:flex-start;height:1.7rem;padding:.25rem .5rem;font-size:.72rem}`};customElements.get("scan-depth-toggle")||customElements.define("scan-depth-toggle",Ct);var Rt=["security","generic","correctness"],ws=r=>JSON.stringify([r.mode,r.model,r.effort,r.isolate]);function Mt(r,e){let t=e.models.find(i=>i.id===e.defaultModel)??e.models[0];return t?(r.length>0?r:[{mode:"generic",isolate:!1}]).map(i=>{let s=e.models.find(o=>o.id===i.model)??t;return{...i,mode:Rt.includes(i.mode)?i.mode:"generic",model:s.id,effort:s.efforts.includes(i.effort)?i.effort:we(s),isolate:!!i.isolate}}):[]}function Lt(r){let e=new Set;return r.map(t=>{let i=ws(t),s=e.has(i);return e.add(i),s})}var It=class extends w{static properties={value:{attribute:!1},loadModels:{attribute:!1},_rows:{state:!0},_loading:{state:!0},_error:{state:!0}};constructor(){super(),this.value=[],this._rows=[],this._catalogue={models:[]},this._nextId=0,this._loading=!0,this._error=null}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadModels")){this._load();return}e.has("value")&&this.value!==this._lastEmitted&&!this._loading&&(this._setRows(this.value),this._notify())}_setRows(e){this._rows=Mt(e,this._catalogue).map(t=>({...t,id:t.id??++this._nextId}))}_notify(){let e=this._loading&&this._rows.length===0?this.value:this._rows.map(({id:i,...s})=>s),t=!this._loading&&!this._error&&e.length>0&&!Lt(e).includes(!0);this._lastEmitted=e,this.dispatchEvent(new CustomEvent("regimes-change",{detail:{value:e,ready:t},bubbles:!0,composed:!0}))}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();try{let t=await this.loadModels(e.signal);if(e.signal.aborted)return;this._catalogue=t,this._sharedModels=()=>Promise.resolve(t),this._setRows(this._rows.length>0?this._rows:this.value)}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_change(e,t){let i=this._rows.find(o=>o.id===e);if(!i)return;let s=Mt([{...i,...t}],this._catalogue)[0];s&&(this._rows=this._rows.map(o=>o.id===e?s:o),this._notify())}_add(){let e=this._rows.at(-1);e&&(this._rows=[...this._rows,{...e,id:++this._nextId}],this._notify())}_remove(e){this._rows.length<=1||(this._rows=this._rows.filter(t=>t.id!==e),this._notify())}render(){let e=Lt(this._rows);return l`<section aria-label="Scan regimes" aria-busy="${this._loading}"><div class="heading"><h2>Scan regimes</h2><span>${this._rows.length} ${this._rows.length===1?"regime":"regimes"}</span></div>${this._error?l`<p class="message" role="alert">Couldn’t load models: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:this._loading&&this._rows.length===0?l`<p class="message" role="status">Loading models…</p>`:l`${Ve(this._rows,t=>t.id,(t,i)=>this._row(t,i,e[i]))}<div class="footer"><button type="button" class="add" ?disabled="${this._rows.length===0}" @click="${this._add}"><span aria-hidden="true">+</span> Add regime</button><span class="message" role="status">${e.includes(!0)?"Change or remove duplicate regimes to run the scan":"Results from these regimes will be merged"}</span></div>`}</section>`}_row(e,t,i){return l`<div class="${`row${i?" duplicate":""}`}" role="group" aria-label="${`Regime ${t+1}`}" aria-describedby="${i?`duplicate-${e.id}`:u}"><div class="mode" role="radiogroup" aria-label="Scan mode">${Rt.map(s=>l`<label class="mode-choice"><input type="radio" name="${`regime-mode-${e.id}`}" .checked="${e.mode===s}" @change="${()=>this._change(e.id,{mode:s})}"><span>${s[0].toUpperCase()+s.slice(1)}</span></label>`)}</div><scan-model-picker .loadModels="${this._sharedModels}" .value="${I(e.model)}" .effort="${I(e.effort)}" @model-change="${s=>{s.stopPropagation(),this._change(e.id,s.detail)}}"></scan-model-picker><div class="row-actions"><scan-depth-toggle vertical .isolate="${e.isolate}" @depth-change="${s=>{s.stopPropagation(),this._change(e.id,{isolate:s.detail.isolate})}}"></scan-depth-toggle>${i?l`<span class="duplicate-label" id="${`duplicate-${e.id}`}">Duplicate regime</span>`:u}</div><button type="button" class="remove" aria-label="${`Remove regime ${t+1}`}" ?disabled="${this._rows.length===1}" @click="${()=>this._remove(e.id)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button></div>`}static styles=x`:host{display:block;min-width:0;container:regime-editor/inline-size}*{box-sizing:border-box}.heading{display:flex;align-items:baseline;gap:.65rem;margin-bottom:.75rem}h2{margin:0;color:var(--text);font-size:.85rem;font-weight:600}.heading>span{color:var(--muted);font-size:.7rem}.row{position:relative;display:grid;grid-template-columns:7.75rem minmax(0,1fr) 5.8rem;align-items:start;gap:1rem;padding:.85rem 0;border-top:1px solid var(--border)}.mode{display:grid;min-width:0;border:1px solid var(--border);border-radius:6px;overflow:hidden;background:var(--bg)}.mode-choice{position:relative;user-select:none}.mode-choice+.mode-choice{border-top:1px solid var(--border)}.mode-choice input{position:absolute;width:1px;height:1px;opacity:0}.mode-choice span{display:block;padding:.2rem .6rem;color:var(--muted);font-size:.72rem;line-height:1.15rem}.mode-choice:hover span{background:var(--surface-active)}.mode-choice input:checked+span{color:var(--accent);background:rgb(from var(--accent) r g b / .1);box-shadow:inset 2px 0 var(--accent);font-weight:600}.mode-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}button{border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}button{padding:.4rem .55rem;user-select:none}button:hover:not(:disabled){background:var(--surface-active)}button:disabled{opacity:.35}.row-actions{position:relative;display:flex;align-items:center;align-self:stretch;min-height:4.65rem;padding:.8rem 0 .25rem}.remove{position:absolute;top:.15rem;right:0;display:grid;place-items:center;width:1.5rem;height:1.5rem;padding:.25rem;border:0;background:0 0;color:var(--muted)}.duplicate-label{position:absolute;right:.15rem;bottom:-.05rem;transform:rotate(-7deg);padding:.1rem .3rem;border:1px solid rgb(from var(--critical,#e5534b) r g b / .45);border-radius:3px;color:var(--critical,#e5534b);background:var(--surface);font-size:.6rem;line-height:1rem;white-space:nowrap;pointer-events:none;user-select:none}svg{width:1rem;height:1rem}.footer{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding-top:.6rem;border-top:1px solid var(--border)}.add{display:flex;align-items:center;gap:.3rem}.message{margin:0;color:var(--muted);font-size:.7rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}scan-model-picker{grid-row:2;grid-column:1/-1}.mode{grid-column:1;max-width:9rem}.row-actions{grid-column:2}`};customElements.get("scan-regime-editor")||customElements.define("scan-regime-editor",It);var Jr=x`:host{display:block;box-sizing:border-box;color:var(--text)}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto;container:scan-page/inline-size}.head{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;min-height:2.1rem;margin-bottom:.45rem}.head-title{display:flex;align-items:center;gap:.65rem}h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.head-tabs{display:inline-flex;margin-left:.7rem;border:1px solid var(--border);border-radius:6px;overflow:hidden}.head-tabs button{border:0;border-right:1px solid var(--border);padding:.25rem .6rem;color:var(--muted);background:0 0;font:inherit;font-size:.75rem}.head-tabs button:last-child{border-right:0}.head-tabs button.active{color:var(--text);background:var(--surface-active)}.head-tabs button:hover{color:var(--text)}.source-choice.single-repository{grid-template-columns:1fr}.head-actions{margin-left:auto;display:flex;gap:.45rem}button,input,select{font:inherit}button{cursor:default}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.intro{margin:0 0 1.15rem;max-width:52rem;color:var(--muted);font-size:.82rem;line-height:1.5}.intro span{display:block}.notice{margin:0 0 1rem;padding:.55rem .7rem;border:1px solid rgb(from var(--accent) r g b / .35);border-radius:7px;color:var(--text);background:rgb(from var(--accent) r g b / .08);font-size:.78rem}.setup{display:grid;gap:.85rem}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.panel-head{display:flex;align-items:baseline;justify-content:space-between;gap:.7rem;padding:.72rem .9rem;border-bottom:1px solid var(--border)}.panel-head h2{margin:0;font-size:.86rem;font-weight:600}.panel-head p{margin:0;color:var(--muted);font-size:.72rem}.bundle-choice{display:grid;grid-template-columns:minmax(16rem,1.2fr) minmax(0,1fr);gap:1rem;align-items:end;padding:.85rem .9rem}.field{display:grid;gap:.3rem;min-width:0}.field label,.scope-field>span{color:var(--muted);font-size:.68rem}select{min-width:0;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.76rem}.bundle-stats{display:grid;grid-template-columns:repeat(4,max-content);align-items:center;gap:.45rem 1.1rem;min-width:0}.metric{display:inline-flex;align-items:center;gap:.3rem;min-width:0;white-space:nowrap}.metric svg{flex:0 0 auto;width:.85rem;height:.85rem;margin-right:.1rem;color:var(--muted)}.metric strong{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:.72rem;font-weight:600;font-variant-numeric:tabular-nums}.metric span{color:var(--muted);font-size:.7rem}.mode-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.45rem;padding:.7rem .9rem .85rem}.mode-option{display:grid;gap:.25rem;min-width:0;padding:.55rem .6rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--bg);text-align:left}.mode-title{display:flex;align-items:center;gap:.35rem;min-width:0}.mode-title svg{width:.95rem;height:.95rem;flex:0 0 auto;color:var(--muted)}.mode-option strong{color:var(--text);font-size:.75rem;font-weight:600}.mode-option span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.63rem}.mode-option.active{border-color:rgb(from var(--accent) r g b / .55);background:rgb(from var(--accent) r g b / .1)}.mode-option.active .mode-title svg,.mode-option.active strong{color:var(--accent)}.subtype-wrap{border-top:1px solid var(--border);background:rgb(from var(--accent) r g b / .025)}.subtype-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.45rem;padding:.7rem .9rem .45rem}.report-subtypes{grid-template-columns:repeat(2,minmax(0,1fr));padding-bottom:.7rem}.subtype-option{display:grid;gap:.12rem;padding:.42rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--muted);background:var(--bg);text-align:left}.subtype-option strong{color:var(--text);font-size:.72rem;font-weight:500}.subtype-option span{font-size:.62rem}.subtype-option.active{border-color:rgb(from var(--accent) r g b / .55);background:rgb(from var(--accent) r g b / .1)}.subtype-option.active strong{color:var(--accent)}.subtype-help{margin:0;padding:.15rem .9rem .72rem;color:var(--muted);font-size:.68rem;line-height:1.4}.source-choice{display:grid;grid-template-columns:minmax(12rem,.8fr) minmax(16rem,1.2fr);gap:.7rem;align-items:end;padding:.85rem .9rem}.source-footer{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:.7rem 1rem;grid-column:1/-1;min-width:0}.scope-slot{justify-self:end;width:min(34rem,100%);min-height:2rem}.source-footer .bundle-stats{min-height:2rem}.scope-toggle{display:flex;align-items:center;justify-content:end;gap:.7rem;min-width:0;min-height:2rem}.scope-options{display:flex;flex-shrink:0;min-width:0;border:1px solid var(--border);border-radius:5px;overflow:hidden;background:var(--bg)}.scope-option{position:relative;flex:1 0 auto;user-select:none}.scope-option+.scope-option{border-left:1px solid var(--border)}.scope-option input{position:absolute;width:1px;height:1px;opacity:0}.scope-option span{display:grid;place-items:center;height:calc(2rem - 2px);padding:.3rem .55rem;color:var(--muted);font-size:.74rem;white-space:nowrap}.scope-option:hover span{color:var(--text);background:var(--surface-active)}.scope-option input:checked+span{color:var(--text);background:var(--surface-active);font-weight:500}.scope-option input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.scope-description{order:-1;min-width:0;color:var(--muted);font-size:.66rem;line-height:1rem;text-align:right}.scope-field{display:flex;align-items:center;justify-content:end;gap:.5rem;min-width:0;max-width:100%;margin-left:auto}.scope-field select{width:13rem;max-width:100%;flex:1 1 auto}.choice-empty{display:flex;align-items:center;height:2rem;padding:.28rem .5rem;border:1px dashed var(--border);border-radius:5px;color:var(--muted);background:var(--bg);font-size:.72rem}.scope-head{display:flex;align-items:center;gap:.55rem;padding:.72rem .9rem;list-style:none;cursor:default;user-select:none}.scope-head::-webkit-details-marker{display:none}.scope-head:hover{background:var(--surface-active)}.scope-head:focus-visible{outline:2px solid var(--accent);outline-offset:-3px;border-radius:8px}.scope-chevron{width:.85rem;height:.85rem;flex:0 0 auto;transition:transform .15s}.scope-panel[open] .scope-chevron{transform:rotate(90deg)}.scope-panel[open] .scope-head{border-bottom:1px solid var(--border)}.scope-head h2{margin:0;font-size:.86rem;font-weight:600}.scope-head p{display:flex;flex-wrap:wrap;justify-content:end;gap:.15rem .65rem;margin:0 0 0 auto;color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums;text-align:right}.scope-head p span{white-space:nowrap}.scope-head p span+span{padding-left:.65rem;border-left:1px solid var(--border)}.scope-grid{display:grid;grid-template-columns:minmax(13rem,.75fr) minmax(0,1.25fr);min-height:0}.scope-pane{min-width:0}.scope-pane+.scope-pane{border-left:1px solid var(--border)}.pane-head{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem;padding:.55rem .75rem;border-bottom:1px solid var(--border)}.pane-head strong{font-size:.72rem;font-weight:600}.pane-head span{color:var(--muted);font-size:.65rem;font-variant-numeric:tabular-nums}.package-list{max-height:22rem;overflow:auto;overscroll-behavior:none}.package-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.45rem;width:100%;padding:.42rem .7rem;border:0;border-bottom:1px solid var(--border);color:var(--text);background:0 0;text-align:left}.package-row:hover{background:var(--surface-active)}.file input,.package-row input{width:.85rem;height:.85rem;accent-color:var(--accent)}.package-name,.package-size{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.package-name{font-size:.7rem}.package-size{color:var(--muted);font-size:.64rem;font-variant-numeric:tabular-nums}.package-row.excluded .package-name{color:var(--muted);text-decoration:line-through}.file-panel{min-width:0}.file-list{display:grid;grid-template-columns:minmax(0,1fr);max-height:22rem;overflow:auto;overscroll-behavior:none}.file{display:flex;align-items:center;gap:.45rem;min-width:0;padding:.35rem .75rem;border-bottom:1px solid var(--border)}.file input{flex:0 0 auto}.file-copy{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem}.file-meta{flex:0 1 auto;min-width:0;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums}.excluded .file-path{color:var(--muted);text-decoration:line-through}.file-foot{display:flex;justify-content:space-between;gap:.6rem;padding:.6rem .8rem;color:var(--muted);font-size:.7rem}.options{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:1rem;position:relative;z-index:2;overflow:visible;padding:.85rem .9rem 1rem}.options-grid{display:grid;grid-column:1/-1;gap:.7rem;min-width:0}.checks{position:relative;display:grid;grid-column:2;grid-row:3;align-content:center;justify-items:end;margin-top:1rem}.offline-help{position:absolute;top:calc(50% + .75rem);right:0;color:var(--muted);font-size:.66rem;line-height:1.4;white-space:nowrap}.check{display:inline-flex;align-items:center;gap:.4rem;color:var(--text);font-size:.75rem}.check input{width:.85rem;height:.85rem;accent-color:var(--accent)}.switch{display:inline-flex;align-items:center;gap:.45rem;color:var(--text);font-size:.74rem;cursor:default}.switch input{position:absolute;width:1px;height:1px;opacity:0}.switch-track{position:relative;width:2rem;height:1.1rem;border-radius:999px;background:var(--surface-active);transition:background .12s}.switch-track::after{content:'';position:absolute;top:.15rem;left:.15rem;width:.8rem;height:.8rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.switch input:checked+.switch-track{background:rgb(from var(--accent) r g b / .4)}.switch input:checked+.switch-track::after{transform:translateX(.9rem);background:var(--accent)}.checks .switch input:checked+.switch-track{background:rgb(from var(--critical,#e5534b) r g b / .3)}.checks .switch input:checked+.switch-track::after{background:var(--critical,#e5534b)}.switch input:focus-visible+.switch-track{outline:2px solid var(--accent);outline-offset:2px}.options-footer{display:flex;flex-wrap:wrap;grid-column:1;grid-row:3;align-items:end;gap:.7rem;min-width:0;margin-top:1rem}.options-footer slot[name=before-run]{display:contents}.agentic-fields{display:grid;gap:.65rem;padding:.85rem .9rem 1rem}.agentic-panel .panel-head{align-items:center}.prompt-row{display:flex;align-items:start;gap:.4rem;min-width:0}.prompt-row textarea{flex:1;width:0}.prompt-action{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;padding:.25rem;border:0;border-radius:4px;color:var(--muted);background:0 0}.prompt-action:hover{color:var(--text);background:var(--surface-active)}.prompt-action svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.4}textarea{min-width:0;resize:vertical;padding:.4rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.76rem}.run{padding:.48rem .8rem;border:0;border-radius:6px;color:var(--bg);background:var(--accent);font-size:.8rem;font-weight:600}.run:disabled{opacity:.45}.summary{align-self:end;padding-block:.48rem;color:var(--muted);font-size:.74rem}.history{display:grid;gap:.6rem}.scan-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:1rem;padding:.85rem .9rem}.scan-row+.scan-row{border-top:1px solid var(--border)}.scan-main{min-width:0}.scan-title{display:flex;align-items:center;gap:.45rem;min-width:0}.scan-title strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem}.scan-meta{display:block;margin-top:.25rem;color:var(--muted);font-size:.7rem}.status{display:inline-flex;align-items:center;gap:.3rem;padding:.15rem .4rem;border-radius:999px;font-size:.66rem;font-weight:600;text-transform:capitalize}.status::before{content:'';width:.4rem;height:.4rem;border-radius:50%;background:currentColor}.status.running{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.status.completed{color:#48b878;background:rgb(72 184 120 / .1)}.status.stopped{color:var(--muted);background:var(--surface-active)}.scan-actions{display:flex;align-items:center;gap:.45rem}.action{padding:.35rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.72rem;white-space:nowrap}.action:hover{border-color:var(--muted);background:var(--surface-active)}.empty{margin:0;padding:1.2rem;color:var(--muted);font-size:.8rem}@container scan-page (max-width: 48rem){gap:.7rem}.scope-grid{grid-template-columns:1fr}.scope-pane+.scope-pane{border-top:1px solid var(--border);border-left:0}.checks{margin-top:.8rem}.offline-help{max-width:100%;white-space:normal}.options-footer{margin-top:.8rem}.bundle-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:.45rem .65rem}.scope-head{flex-wrap:wrap}.scope-head p{flex-basis:100%;justify-content:start;margin-left:1.4rem;text-align:left}.scope-head p span{white-space:normal}.scope-head p span+span{padding-left:0;border-left:0}.scan-row{grid-template-columns:1fr;gap:.55rem}.scan-actions{justify-content:flex-start}.head-tabs{margin-left:0}`;var Xr=[{key:"metro",label:"metro",subtitle:"Metro bundle contents"},{key:"run",label:"run",subtitle:"Node.js CLI"},{key:"add",label:"add",subtitle:"Manually added files"}];function Qr(r){let e=r.filter(i=>i.id!=="all");if(e.length===0)return null;let t=new Map(e.map(i=>[String(i.id).replace(/^reason:/u,""),i]));return t.size!==e.length||[...t.keys()].some(i=>!Xr.some(s=>s.key===i))?null:[{id:"",label:"All files",subtitle:"Everything"},...Xr.filter(i=>t.has(i.key)).map(({key:i,...s})=>({...s,id:t.get(i).id,subtitle:i==="run"&&t.has("metro")?"Bundler and Node.js CLI":s.subtitle}))]}var zt={dependencies:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="4" cy="8" r="2"/><circle cx="12" cy="4" r="2"/><circle cx="12" cy="12" r="2"/><path d="M6 8h2M10.2 5.3 6 7.3M10.2 10.7 6 8.7"/></svg>`,code:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5.5 3-3 5 3 5M10.5 3l3 5-3 5M9 2.5 7 13.5"/></svg>`,agentic:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m8 1.8.8 4.4L12.5 8l-3.7 1.8L8 14.2l-.8-4.4L3.5 8l3.7-1.8Z"/><path d="m13 2 .25 1.25L14.5 3.5 13.25 3.25 13 2ZM3 11.5l.2 1 .95.2-.95.2-.2 1-.2-1-.95-.2.95-.2Z"/></svg>`,report:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 1.8h5l3 3V14H4zM9 1.8V5h3M6 8h4M6 10.5h4"/></svg>`},Tt=class extends w{static properties={source:{attribute:!1},loadBundle:{attribute:!1},loadModels:{attribute:!1},loadReportSources:{attribute:!1},canRun:{attribute:!1},_loadingBundle:{state:!0},_bundleError:{state:!0},_tab:{state:!0},_mode:{state:!0},_bundles:{state:!0},_repositories:{state:!0},_reportMode:{state:!0},_reportInput:{state:!0},_reportRestore:{state:!0},_scans:{state:!0},_selectedRepoId:{state:!0},_selectedBundleId:{state:!0},_reason:{state:!0},_excluded:{state:!0},_excludedModules:{state:!0},_prompts:{state:!0},_options:{state:!0},_regimes:{state:!0},_regimesReady:{state:!0},_notice:{state:!0}};static styles=Jr;constructor(){super(),this.loadModels=ae,this.canRun=!0,this._tab="new",this._mode="code",this.source=null,this.loadBundle=null,this._loadingBundle=!1,this._bundleError=null,this._bundles=[],this._repositories=[],this._reportMode="link",this._reportInput=null,this._reportRestore=null,this._scans=[],this._selectedRepoId=this._bundles[0]?.repoId??"unattached",this._selectedBundleId=this._bundles[0]?.id??null,this._reason=this._bundles[0]?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._nextPromptId=1,this._prompts=[{id:1,text:""}],this._options={analyzer:"generic",model:null,effort:null,cached:!1,isolate:!1},this._regimes=[],this._regimesReady=!1,this._notice=null,this._timers=new Set}willUpdate(e){if(e.has("source")){this._bundles=this.source?.bundles??[],this._repositories=this.source?.repositories??[],this._scans=this.source?.scans??[],this._excluded=new Set,this._excludedModules=new Set;let t=this._bundles.find(i=>i.id===this._selectedBundleId)??this._bundles[0];this._selectedRepoId=t?.repoId??"unattached",this._selectedBundleId=t?.id??null,this._reason=t?.reasons?.[0]?.id??""}}updated(e){(e.has("source")||e.has("loadBundle"))&&this._loadSelectedBundle()}async _loadSelectedBundle(){this._bundleController?.abort(),this._loadingBundle=!1,this._bundleError=null;let e=this._bundle;if(!this.loadBundle||!e||Array.isArray(e.files))return;let t=this._bundleController=new AbortController;this._loadingBundle=!0;try{let i=await this.loadBundle(e,t.signal);if(t.signal.aborted)return;this._bundles=this._bundles.map(s=>s.id===e.id?i:s),this._reason=i.reasons?.[0]?.id??""}catch(i){t.signal.aborted||(this._bundleError=String(i?.message??i))}finally{t.signal.aborted||(this._loadingBundle=!1)}}disconnectedCallback(){super.disconnectedCallback(),this._bundleController?.abort();for(let e of this._timers)clearTimeout(e);this._timers.clear()}get _repoBundles(){return this._bundles.filter(e=>e.repoId===this._selectedRepoId)}get _bundle(){return this._repoBundles.find(e=>e.id===this._selectedBundleId)}get _reasonData(){return this._bundle?.reasons.find(e=>e.id===this._reason)??this._bundle?.reasons[0]}_packageLabel(e){return e==="__own__"?"Own code":e}get _files(){let e=this._reasonData,t=e?.fileModules,i=e?.filePaths?new Set(e.filePaths):null;return kt(this._bundle?.files).filter(s=>(t==null||t.includes(s.module))&&(i==null||i.has(s.path))).toSorted((s,o)=>o.bytes-s.bytes)}render(){return l`<div class="wrap"><div class="head"><div class="head-title"><slot name="navigation"></slot><h1>Scans</h1></div><div class="head-tabs" role="tablist" aria-label="Scan views"><button class="${this._tab==="new"?"active":""}" role="tab" aria-selected="${this._tab==="new"}" @click="${()=>{this._tab="new"}}">New scan</button> <button class="${this._tab==="history"?"active":""}" role="tab" aria-selected="${this._tab==="history"}" @click="${()=>{this._tab="history"}}">Scan history</button></div></div><p class="intro">${this._mode==="report"?"Choose inputs and start a scan. Save the report when it finishes.":"Choose a bundle and start a scan. Save the report when it finishes."}</p>${this._notice?l`<p class="notice" role="status">${this._notice}</p>`:u} ${this._bundleError?l`<p class="notice" role="alert">Couldn’t load bundle: ${this._bundleError}<button @click="${()=>{this._loadSelectedBundle()}}">Retry</button></p>`:u} ${this._tab==="new"?this._newScan():this._history()}</div>`}_newScan(){let e=this._mode,t=this._bundle,i=e==="code"?this._files:t?.files??[],s=this._excluded,o=this._excludedModules,n=i.filter(h=>!s.has(h.path)&&!o.has(h.module)),a=xe(t?.files?n:null),c=new Map;for(let h of i){let g=c.get(h.module)??{bytes:0,count:0,included:0};g.bytes+=h.bytes,g.count++,s.has(h.path)||g.included++,c.set(h.module,g)}let d=[...c.keys()].toSorted((h,g)=>c.get(g).bytes-c.get(h).bytes||this._packageLabel(h).localeCompare(this._packageLabel(g))),f=i.slice(0,80),p=d.filter(h=>!o.has(h)).length,b=this._reportInput?.mode===this._reportMode?this._reportInput.inputs:[];return l`<div class="setup"><section class="panel mode-panel" aria-labelledby="scan-mode-heading"><div class="panel-head"><h2 id="scan-mode-heading">Scan mode</h2><p>Choose what the server should analyze</p></div><div class="mode-grid" role="tablist" aria-label="Scan mode">${[["dependencies","Dependency alerts","Revalidate incoming alerts against actual code"],["code","Code","Run a full scan of the codebase"],["agentic","Agentic","Free-form analysis with your instructions"],["report","Reports","Link saved reports or merge scan results"]].map(([h,g,m])=>l`<button type="button" role="tab" aria-selected="${e===h}" class="${`mode-option ${e===h?"active":""}`}" @click="${()=>this._changeMode(h)}"><span class="mode-title">${zt[h]}<strong>${g}</strong></span><span>${m}</span></button>`)}</div>${e==="code"?l`<div class="subtype-wrap"><div class="subtype-options" role="radiogroup" aria-label="Code subtype">${[["security","Security","Security findings only"],["generic","Generic","Free-form code scan: wide-scoped, most results"],["correctness","Correctness","Guided correctness scan"],["advanced","Advanced","Merge multiple regimes"]].map(([h,g,m])=>l`<button type="button" role="radio" aria-checked="${this._options.analyzer===h}" class="${`subtype-option ${this._options.analyzer===h?"active":""}`}" @click="${()=>this._setOption("analyzer",h)}"><strong>${g}</strong><span>${m}</span></button>`)}</div><p class="subtype-help">Focusing controls how effort is spent: while Generic can also find security issues, a focused Security scan is likely to find more.</p></div>`:u} ${e==="report"?l`<div class="subtype-wrap"><div class="subtype-options report-subtypes" role="radiogroup" aria-label="Reports submode">${[["link","Link","Link findings across saved reports"],["merge","Merge","Combine scan results for one bundle"]].map(([h,g,m])=>l`<button type="button" role="radio" aria-checked="${this._reportMode===h}" class="${`subtype-option ${this._reportMode===h?"active":""}`}" @click="${()=>{this._reportMode=h,this._reportRestore=null}}"><strong>${g}</strong><span>${m}</span></button>`)}</div></div>`:u}</section>${e==="report"?l`<scan-report-inputs .mode="${this._reportMode}" .loadSources="${this.loadReportSources}" .restore="${this._reportRestore}" @report-inputs-change="${h=>{this._reportInput=h.detail}}"></scan-report-inputs>`:this._sourcePanel(t,i)} ${e==="code"?l`<details class="panel scope-panel"><summary class="scope-head"><svg class="scope-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg><h2>Source filter</h2><p><span>${n.length} of ${i.length} files · ${p} of ${d.length} packages</span> <span>${W(a.bytes)} · ${a.lines==null?"\u2014":a.lines.toLocaleString()} LoC</span></p></summary><div class="scope-grid"><section class="scope-pane package-pane" aria-label="Packages in bundle"><div class="pane-head"><strong>Packages</strong><span>${d.length} total · sorted by size</span></div><div class="package-list">${d.map(h=>{let{bytes:g,count:m,included:v}=c.get(h),$=!o.has(h);return l`<label class="${`package-row ${$?"":"excluded"}`}"><input type="checkbox" .checked="${$}" @change="${_=>this._toggleModule(h)}"><span class="package-name">${this._packageLabel(h)}</span><span class="package-size">${W(g)} · ${v}/${m}</span></label>`})}</div></section><section class="scope-pane file-panel" aria-label="Largest files in bundle"><div class="pane-head"><strong>Largest files</strong><span>showing ${f.length} of ${i.length}</span></div>${i.length===0?l`<p class="empty">No files in this selection.</p>`:l`<div class="file-list">${f.map(h=>{let g=!s.has(h.path)&&!o.has(h.module);return l`<label class="${`file ${g?"":"excluded"}`}"><input type="checkbox" .checked="${g}" @change="${m=>this._toggleFile(h,m.target.checked)}"><span class="file-copy"><span class="file-path" title="${h.path}">${h.path}</span><span class="file-meta">${h.size} · ${this._packageLabel(h.module)}</span></span></label>`})}</div>`}</section></div></details>`:u} ${e==="agentic"?this._agenticPanel():u}<slot name="access"></slot>${this._optionsPanel(e,t,e==="report"?b.length:n.length)}</div>`}_sourcePanel(e,t){let i=this._mode==="code"?this._repoBundles.map(d=>d.files?{...d,files:kt(d.files)}:d):this._repoBundles,{lines:s}=xe(e?.files?t:null),o=new Map;for(let d of this._bundles)o.set(d.repoId,(o.get(d.repoId)??0)+1);let n=o.size>1,a=["code","agentic"].includes(this._mode)&&e!=null&&(!e.filename.toLowerCase().endsWith(".map")||e.reasons?.some(d=>d.id!=="all")),c=this._repositories.map(d=>{let f=o.get(d.id)??0;return{value:d.id,label:d.label,detail:`${f} ${f===1?"bundle":"bundles"}`,special:d.id==="unattached"}});return l`<section class="panel source-panel" aria-busy="${this._loadingBundle}"><div class="panel-head"><h2>Source</h2></div><div class="${`source-choice ${n?"":"single-repository"}`}">${n?l`<div class="field"><span>Repository</span><repository-selector .options="${c}" .value="${this._selectedRepoId}" @repository-change="${d=>this._selectRepoById(d.detail.value)}"></repository-selector></div>`:u}<div class="field">${n?l`<span>Bundle</span>`:u}${i.length>0?l`<bundle-selector .bundles="${i}" .value="${e?.id??null}" @bundle-change="${d=>this._selectBundleById(d.detail.value)}"></bundle-selector>`:l`<div class="choice-empty">${this._bundles.length===0?"No stored bundles.":"No stored bundles for this repository."}</div>`}</div><div class="source-footer"><div class="bundle-stats" aria-label="Bundle statistics"><div class="metric"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><ellipse cx="8" cy="4" rx="5" ry="2"/><path d="M3 4v8c0 1.1 2.2 2 5 2s5-.9 5-2V4M3 8c0 1.1 2.2 2 5 2s5-.9 5-2"/></svg><strong>${e?.size??"\u2014"}</strong><span>bundle size</span></div><div class="metric">${zt.report}<strong>${t.length}</strong><span>files</span></div><div class="metric">${zt.code}<strong>${s==null?"\u2014":s.toLocaleString()}</strong><span>LoC</span></div><div class="metric">${L(oe)}<strong>${new Set(t.map(d=>d.module)).size}</strong><span>packages</span></div></div>${a?l`<div class="scope-slot">${this._scopeField(e)}</div>`:u}</div></div></section>`}_scopeField(e){if(!["code","agentic"].includes(this._mode))return u;let t=(e?.reasons??[]).filter(o=>o.id!=="all");if(t.length===0)return u;let i=this._mode==="agentic",s=Qr(t);if(s){let o=s.find(n=>n.id===this._reason)??s[0];return l`<div class="scope-toggle"><div class="scope-options" role="radiogroup" aria-label="${i?"Choose agentic scope":"Choose scan scope"}" aria-describedby="scan-scope-description">${s.map(n=>l`<label class="scope-option"><input type="radio" name="scan-scope" value="${n.id}" .checked="${o.id===n.id}" @change="${()=>this._changeReason(n.id)}"><span>${n.label}</span></label>`)}</div><span class="scope-description" id="scan-scope-description">${o.subtitle}</span></div>`}return l`<label class="scope-field"><span>Scope</span><select id="${i?"scan-agentic-scope":"scan-reason"}" aria-label="${i?"Choose agentic scope":"Choose scan scope"}" @change="${o=>this._changeReason(o.target.value)}"><option value="" .selected="${I(!this._reason||this._reason==="all")}">All files</option>${t.map(o=>l`<option value="${o.id}" .selected="${I(o.id===this._reason)}">${o.label??o.id}</option>`)}</select></label>`}_optionsPanel(e,t,i){let s=e==="report"?`${i} ${this._reportMode==="merge"?"scan results":"reports"} selected`:`${t?.filename??"No bundle selected"} \xB7 ${i} files will be analyzed`,o=e==="code"&&this._options.analyzer==="advanced",n=!this.canRun||(e==="report"?i===0:t==null||i===0||o&&(!this._regimesReady||this._regimes.length===0));return l`<section class="panel options"><div class="options-grid">${o?l`<scan-regime-editor .loadModels="${this.loadModels}" .value="${this._regimes}" @regimes-change="${a=>{this._regimesReady=a.detail.ready,this._regimes=a.detail.value}}"></scan-regime-editor>`:l`<scan-model-picker .loadModels="${this.loadModels}" ?has-extra="${e==="code"}" .value="${this._options.model}" .effort="${this._options.effort}" @model-change="${a=>{this._options={...this._options,model:a.detail.model,effort:a.detail.effort}}}">${e==="code"?l`<scan-depth-toggle slot="effort-extra" .isolate="${this._options.isolate}" @depth-change="${a=>this._setOption("isolate",a.detail.isolate)}"></scan-depth-toggle>`:u}</scan-model-picker>`}</div><div class="options-footer"><slot name="before-run"></slot><button type="button" class="run" ?disabled="${n}" @click="${()=>this._runScan()}">${e==="report"?this._reportMode==="merge"?"Merge results":"Link reports":"Run scan"}</button><span class="summary">${s}</span></div><div class="checks"><label class="switch"><input type="checkbox" aria-describedby="${this._options.cached?"offline-help":u}" .checked="${this._options.cached}" @change="${a=>this._setOption("cached",a.target.checked)}"><span class="switch-track" aria-hidden="true"></span><span>Offline</span></label>${this._options.cached?l`<small class="offline-help" id="offline-help">Cache only, no new model requests</small>`:u}</div></section>`}_history(){return l`<section class="panel history"><div class="panel-head"><h2>Scan history</h2><p>${this._scans.length} scans</p></div>${this._scans.length===0?l`<p class="empty">No scans yet.</p>`:this._scans.map(e=>this._scanRow(e))}</section>`}_scanRow(e){let t=e.status==="completed"?e.reportSaved?l`<button type="button" class="action" @click="${()=>this._deleteSavedReport(e)}">Delete saved report</button>`:l`<button type="button" class="action" @click="${()=>this._saveReport(e)}">Save report</button>`:u;return l`<div class="scan-row"><div class="scan-main"><div class="scan-title"><strong>${e.bundleName}</strong><span class="${`status ${e.status}`}">${e.status}</span></div><span class="scan-meta">${e.reason} · ${e.files} ${e.mode==="report"?e.reportMode==="merge"?"results":"reports":"files"} · ${e.createdAt}${e.duration?` \xB7 ${e.duration}`:""}${e.reportSaved?" \xB7 Report saved":e.status==="completed"?" \xB7 Report available":""}</span></div><span class="scan-actions">${t}${e.status==="running"?l`<button type="button" class="action" @click="${()=>this._stopScan(e)}">Stop</button>`:u}${e.status==="stopped"?l`<button type="button" class="action" @click="${()=>this._restartScan(e)}">Restart as new scan</button>`:u}</span><span aria-hidden="true"></span></div>`}_selectBundle(e){this._selectedRepoId=e.repoId,this._selectedBundleId=e.id,this._reason=e.reasons?.[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_selectBundleById(e){let t=this._repoBundles.find(i=>i.id===e);t!=null&&this._selectBundle(t)}_selectRepoById(e){if(e===this._selectedRepoId||!this._repositories.some(i=>i.id===e))return;this._selectedRepoId=e;let t=this._bundles.find(i=>i.repoId===e);this._selectedBundleId=t?.id??null,this._reason=t?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_changeMode(e){!["dependencies","code","agentic","report"].includes(e)||e===this._mode||(this._mode=e,this._reportInput=null,this._reportRestore=null,this._excluded=new Set,this._excludedModules=new Set,this._notice=null)}_changeReason(e){this._reason=e,this._excluded=new Set,this._excludedModules=new Set}_toggleFile(e,t){let i=new Set(this._excluded);t?i.delete(e.path):i.add(e.path),this._excluded=i}_toggleModule(e){let t=new Set(this._excludedModules);t.has(e)?t.delete(e):t.add(e),this._excludedModules=t}_setOption(e,t){this._options[e]!==t&&(e==="analyzer"&&t==="advanced"&&(this._regimesReady=!1,this._regimes.length===0&&(this._regimes=[{mode:this._options.analyzer,model:this._options.model,effort:this._options.effort,isolate:this._options.isolate}])),this._options={...this._options,[e]:t})}_agenticPanel(){return l`<section class="panel agentic-panel"><div class="panel-head"><h2>Agentic instructions</h2><button type="button" class="prompt-action" aria-label="Add prompt" @click="${()=>this._addPrompt()}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg></button></div><div class="agentic-fields">${Ve(this._prompts,e=>e.id,(e,t)=>l`<div class="prompt-row"><textarea aria-label="${`Prompt ${t+1}`}" rows="3" placeholder="${this._promptPlaceholder(t)}" .value="${I(e.text)}" @input="${i=>{this._prompts=this._prompts.map(s=>s.id===e.id?{...s,text:i.target.value}:s)}}"></textarea>${this._prompts.length>1?l`<button type="button" class="prompt-action" aria-label="${`Remove prompt ${t+1}`}" @click="${()=>this._removePrompt(e.id)}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button>`:u}</div>`)}</div></section>`}_promptPlaceholder(e){let t=["","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth"][e];return t!=null?`What should the ${t?`${t} `:""}agent focus on?`:`What should agent ${e+1} focus on?`}async _addPrompt(){this._prompts=[...this._prompts,{id:++this._nextPromptId,text:""}],await this.updateComplete,this.renderRoot?.querySelector(".prompt-row:last-child textarea")?.focus()}_removePrompt(e){this._prompts.length>1&&(this._prompts=this._prompts.filter(t=>t.id!==e))}_runScan(){if(!this.canRun)return;let e=this._mode,t=e==="code"&&this._options.analyzer==="advanced";if(t&&(!this._regimesReady||this._regimes.length===0))return;let i=this._bundle,s=this._reportInput?.mode===this._reportMode?this._reportInput:null,o=s?.inputs??[],n=e==="code"?this._files.filter(d=>!this._excluded.has(d.path)&&!this._excludedModules.has(d.module)):i?.files??[];if(e==="report"&&(!s?.source||o.length===0)||e!=="report"&&(!i||n.length===0))return;let a={id:`scan-${Date.now()}`,mode:e,bundleId:e==="report"?this._reportMode==="merge"?s.source.id:null:i?.id??null,bundleName:e==="report"?s.source.label:i.filename,reason:e==="agentic"?this._reasonData?.label??"All files":e==="report"?this._reportMode==="merge"?"Merge scan results":"Link saved reports":e==="code"?this._reasonData?.label??"All files":"Dependencies",status:"running",createdAt:"Just now",duration:"",files:e==="report"?o.length:n.length,reportSaved:!1,cached:this._options.cached,isolate:e==="code"&&this._options.isolate,model:this._options.model,effort:this._options.effort};e==="code"&&(a.analyzer=this._options.analyzer),t&&(a.regimes=this._regimes.map(d=>({...d})),a.reason=`Advanced \xB7 ${a.regimes.length} regimes \xB7 ${a.reason}`,a.scopeId=this._reason,a.model=null,a.effort=null,a.isolate=!1),e==="agentic"&&(a.prompts=this._prompts.map(d=>d.text)),e==="report"&&(a.reportMode=this._reportMode,a.reportSource={...s.source},a.inputIds=o.map(d=>d.id)),this._scans=[a,...this._scans],this._tab="history",this._notice="Scan started. The server will update its status as work progresses.";let c=setTimeout(()=>{this._timers.delete(c),a.status==="running"&&(a.status="completed",a.duration="2m 14s",this._notice="Scan completed. Its report is ready to save.",this.requestUpdate())},2200);this._timers.add(c)}_stopScan(e){e.status==="running"&&(e.status="stopped",e.duration=e.duration||"stopped by user",this._notice="Scan stopped. It cannot continue, but you can restart it as a new scan.",this.requestUpdate())}_restartScan(e){if(this._options={...this._options,model:e.model??this._options.model,effort:e.effort??this._options.effort,cached:e.cached??!1,isolate:e.isolate??!1,analyzer:e.analyzer??"generic"},e.mode==="report"){this._mode="report",this._reportMode=e.reportMode==="link"?"link":"merge",this._reportInput=null,this._reportRestore={mode:this._reportMode,source:e.reportSource,inputIds:e.inputIds??[]},this._tab="new",this._notice="New report scan settings restored from the stopped run.";return}let t=this._bundles.find(i=>i.id===e.bundleId);t&&(this._selectBundle(t),this._mode=e.mode??"dependencies",e.mode==="agentic"&&(this._prompts=(e.prompts?.length>0?e.prompts:[""]).map(i=>({id:++this._nextPromptId,text:i}))),e.regimes?.length>0&&(this._options={...this._options,analyzer:"advanced"},this._regimes=e.regimes.map(i=>({...i})),this._regimesReady=!1),this._reason=t.reasons.find(i=>i.label===e.reason)?.id??t.reasons[0]?.id??"",e.regimes?.length>0&&(this._reason=e.scopeId??this._reason),this._tab="new",this._notice="New scan settings restored from the stopped run.")}_saveReport(e){e.reportSaved=!0,this._notice="Report saved. You can delete it from Reports and save this completed scan again.",this.requestUpdate()}_deleteSavedReport(e){e.reportSaved=!1,this._notice="Saved report deleted. The completed scan can be saved again.",this.requestUpdate()}};customElements.get("deepview-scan-page")||customElements.define("deepview-scan-page",Tt);var Nt=["@acme/auth","@acme/billing","@acme/catalog","@acme/checkout","@acme/config","@acme/crypto","@acme/data","@acme/identity","@acme/notifications","@acme/payments","@acme/search","@acme/storage","@acme/telemetry","@acme/ui","@acme/users","@acme/webhooks"],xs=Array.from({length:128},(r,e)=>{let t=Nt[e%Nt.length],i=9e3+e*7300%48e3;return{path:`packages/${t.slice(6)}/src/file-${String(e+1).padStart(3,"0")}.ts`,bytes:i,lines:180+e*137%960,module:t}}),ei=[{id:"repo-checkout",label:"acme/checkout"},{id:"repo-worker",label:"acme/worker-service"},{id:"unattached",label:"Unattached"}],$s=[{id:"bundle-checkout",filename:"checkout.stasis",repoId:"repo-checkout",repo:"acme/checkout",size:"48.2 MiB",files:[{path:"src/auth/session.ts",bytes:82e3,lines:1640,module:"@acme/auth"},{path:"src/payments/checkout.ts",bytes:74e3,lines:1480,module:"@acme/payments"},{path:"src/api/routes.ts",bytes:61e3,lines:1220,module:"@acme/api"},{path:"src/users/permissions.ts",bytes:42e3,lines:840,module:"@acme/users"},{path:"src/crypto/tokens.ts",bytes:36e3,lines:720,module:"@acme/crypto"},{path:"src/db/queries.ts",bytes:29e3,lines:580,module:"@acme/database"},{path:"src/webhooks/stripe.ts",bytes:22e3,lines:440,module:"@acme/payments"},{path:"src/config/env.ts",bytes:13e3,lines:260,module:"@acme/config"},...xs],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:null},{id:"app",label:"app",fileModules:["@acme/auth","@acme/payments","@acme/api","@acme/users","@acme/crypto","@acme/config",...Nt]}]},{id:"bundle-worker",filename:"worker.stasis",repoId:"repo-worker",repo:"acme/worker-service",size:"16.7 MiB",files:[{path:"worker/queue.ts",bytes:54e3,lines:1080,module:"queue"},{path:"worker/handlers/process.ts",bytes:48e3,lines:960,module:"handlers"},{path:"worker/handlers/retry.ts",bytes:31e3,lines:620,module:"handlers"},{path:"worker/secrets.ts",bytes:19e3,lines:380,module:"secrets"},{path:"worker/metrics.ts",bytes:12e3,lines:240,module:"metrics"}],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:["queue","handlers","secrets","metrics"]},{id:"app",label:"app",fileModules:["queue","handlers","metrics"]}]},{id:"bundle-unattached",filename:"detached-preview.stasis",repoId:"unattached",repo:"Unattached",size:"6.4 MiB",files:[{path:"src/index.ts",bytes:31e3,lines:620,module:"preview"},{path:"src/loader.ts",bytes:24e3,lines:480,module:"preview"},{path:"src/manifest.ts",bytes:18e3,lines:360,module:"preview"},{path:"src/worker.ts",bytes:15e3,lines:300,module:"worker"}],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:["preview","worker"]}]}],ti=[{id:"scan-104",bundleId:"bundle-checkout",bundleName:"checkout.stasis",reason:"app",status:"completed",createdAt:"Today, 09:42",duration:"4m 18s",files:5,reportSaved:!0},{id:"scan-103",bundleId:"bundle-worker",bundleName:"worker.stasis",reason:"All",status:"running",createdAt:"Today, 09:51",duration:"1m 06s",files:5,reportSaved:!1},{id:"scan-102",bundleId:"bundle-checkout",bundleName:"checkout.stasis",reason:"run",status:"stopped",createdAt:"Yesterday, 17:20",duration:"38s",files:4,reportSaved:!1}];function ri(){return $s.map(r=>({...r,files:r.files.map(e=>({...e,size:W(e.bytes)})),reasons:r.reasons.map(e=>({...e,fileModules:e.fileModules?[...e.fileModules]:null}))}))}var ks=/^( *)(```|~~~)/u,le=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u;function K(r){let e=[],t=-1,i="",s=0,o=0,n=0;for(let a of r.split(`
4
- `)){let c=n;n+=a.length+1;let d=ks.exec(a);if(t!==-1){d&&d[2]===i&&d[1].length<=s+3&&(e.push([t,c+a.length]),t=-1);continue}if(d&&d[1].length<=o+3){t=c,i=d[2],s=d[1].length;continue}if(!a.trim())continue;let f=le.exec(a),p=/^ */u.exec(a)[0].length;f&&f[1].length<=o+3?o=f[0].length:p<o&&(o=0)}return t!==-1&&e.push([t,r.length]),e}function Z(r,e){return r.some(([t,i])=>e>=t&&e<i)}function z(r){return String(r??"").replaceAll(/\r\n?/gu,`
5
- `)}var ke=/^## +(.*)$/gmu,Se=/^### +(.*)$/gmu,Y=/^#### +(.*)$/gmu,Ot=/^(.+):(\d+(?:-\d+)?)$/u;function qe(r){return/^[0-9a-f]{7,64}$/iu.test(r)}function T(r,e){let t=K(r),i=[...r.matchAll(e)].filter(s=>!Z(t,s.index));return i.map((s,o)=>({heading:s[1],body:r.slice(s.index+s[0].length+1,i[o+1]?.index)}))}function J(r,e){let t=K(r),i=[...r.matchAll(e)].find(s=>!Z(t,s.index));return i?{head:r.slice(0,i.index),subs:T(r,e)}:{head:r,subs:[]}}function Ee(r){let e=r.indexOf(`
6
- `);return e===-1?{title:r.trim(),body:""}:{title:r.slice(0,e).trim(),body:r.slice(e+1)}}function Ss(r){let e=[];for(let t of r.split(`
7
- `)){let i=t.trim();if(!i.startsWith("|")||/^[\s:|-]+$/u.test(i)&&i.includes("-"))continue;let s=i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(o=>o.trim());e.push(s)}return e}function Ae(r){let e=Ss(r);if(e.length<2)return[];let t=e[0].map(s=>s.toLowerCase()),i=[];for(let s of e.slice(1)){if(s.length===t.length&&s.every((n,a)=>n.toLowerCase()===t[a]))continue;let o={};t.forEach((n,a)=>{n&&(o[n]=s[a]??"")}),i.push(o)}return i}function ii(r){let e=Object.create(null),t=Object.create(null),i=[],s=null,o="",n=[],a="",c=(p,b,h)=>{!p||p in e||(e[p]=h.trim(),t[p]=b)},d=()=>{s&&c(s,o,n.join(`
8
- `)),s=null,o="",n=[]},f=p=>{(s?n:i).push(p)};for(let p of r.split(`
9
- `)){let b=/^ {0,3}(```|~~~)/u.exec(p),h=b!==null&&(!a||b[1]===a);if(h&&(a=a?"":b[1]),h||a){f(p);continue}if(!p.trim()){s?d():i.push(p);continue}let g=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(g){d();let m=g[1].trim(),v=g[2],$;for(;($=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(v))!==null;)c(m.toLowerCase(),m,v.slice(0,$.index)),m=$[1].trim(),v=v.slice($.index+$[0].length);s=m.toLowerCase(),o=m,n=[v];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){d();continue}f(p)}return d(),{fields:e,labels:t,prose:i.join(`
10
- `).trim()}}function Ge(r){let e=(r||"").trim(),t="",i=ce(e);i&&(e=i.label.trim(),t=i.url.trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=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)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);d&&(c=d[1],s||(s=d[2]));let f=Ot.exec(c);return f?(s||(s=f[2]),{file:f[1],line:s,locationLink:t}):{file:c,line:s||"?",locationLink:t}}function Bt(r){return r.replaceAll("**","")}function ce(r){let e=String(r??""),t=Es(e,As(e)),i=Cs(e),s=e.indexOf("]");for(let o=e.indexOf("[");o!==-1;o=e.indexOf("[",o+1)){for(;s!==-1&&s<=o;)s=e.indexOf("]",s+1);for(let n of[s,t.get(o)??-1]){if(n===-1||n===o+1||e[n+1]!=="(")continue;let a=Rs(e,n+1,i);if(a!==null)return{label:e.slice(o+1,n),url:a,index:o}}}return null}function Es(r,e){let t=new Map,i=[];for(let s=0;s<r.length;s++){let o=r[s];si(r,s)?s++:o==="`"?s=e.get(s)??s:o==="["?i.push(s):o==="]"&&i.length>0&&t.set(i.pop(),s)}return t}function As(r){let e=[];for(let s=r.indexOf("`");s!==-1;s=r.indexOf("`",s)){let o=1;for(;r[s+o]==="`";)o++;e.push([s,o]),s+=o}let t=new Map,i=new Map;for(let s=e.length-1;s>=0;s--){let[o,n]=e[s],a=i.get(n);a!==void 0&&t.set(o,a+n-1),i.set(n,o)}return t}function Cs(r){let e=r.length,t=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1),s=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1);for(let c=e-1;c>=0;c--)t[c]=r[c]===")"?c:t[c+1],i[c]=/\s/u.test(r[c])?c:i[c+1],s[c]=r[c]===">"?c:s[c+1],o[c]=r[c]===`
11
- `?c:o[c+1];let n=new Map,a=[];for(let c=0;c<e;c++){let d=r[c];si(r,c)?c++:i[c]===c?a.length=0:d==="("?a.push(c):d===")"&&a.length>0&&n.set(a.pop(),c)}return{balanced:n,nextClose:t,nextSpace:i,nextAngle:s,nextLine:o}}function Rs(r,e,t){let i=Ms(r,e,t);if(i)return i;let s=t.balanced.get(e);if(s!==void 0)return s>e+1?r.slice(e+1,s):null;let o=t.nextClose[e+1],n=t.nextSpace[e+1];return o===-1||o===e+1||n!==-1&&n<o?null:r.slice(e+1,o)}function Ms(r,e,t){if(r[e+1]!=="<")return"";let i=t.nextAngle[e+2],s=t.nextLine[e+2];return i===-1||s!==-1&&s<i||r[i+1]!==")"?"":r.slice(e+2,i)}var Ls=/\\([!-/:-@[-`{-~])/gu,Is=/[!-/:-@[-`{-~]/u;function si(r,e){return r[e]==="\\"&&Is.test(r[e+1]??"")}function oi(r){return typeof r=="string"?r.replace(Ls,"$1"):r}function ni(r){let e=/^\[(.+)\]$/u.exec(r.trim());return e?e[1].trim():r.trim()}function X(r){let e=(r||"").trim();return/^[-–—]+$/u.test(e)?"":e}var zs=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu;function Ts(r){switch(r.toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"HIGH_BUG":return"high_bug";case"BUG":return"bug";case"INFO":case"INFORMATIONAL":return"informational";default:return"medium"}}var li=r=>String(r??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),ai=new Map([["high",8],["medium",6],["low",4]]);function Ns(r){if(r!==void 0)return ai.get(li(r))??ai.get("medium")}var Os=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function ci(r){let t=z(r).trim().split(zs);if(t.length===1)return null;let i=[];for(let s=1;s<t.length;s+=2){let o=Ts(t[s]);for(let n of t[s+1].split(/^### /mu).slice(1)){let a=Bs(n,o);a&&i.push(a)}}return i.length===0?null:{type:"security",source:"deepsec",findings:i}}function Bs(r,e){let{title:t,body:i}=Ee(r);if(!t)return null;let s=i.replace(/\n---\s*$/u,"").trim(),o={};for(let v of s.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu))o[v[1].trim().toLowerCase()]=v[2].trim();let n=/^\*\*Recommendation:\*\*\s*/mu.exec(s),a=s,c="";n&&(a=s.slice(0,n.index),c=s.slice(n.index+n[0].length).trim());let d=a.split(`
12
- `).filter(v=>!/^\s*- \*\*/u.test(v)).join(`
13
- `).replaceAll("**","").trim(),f=[t,d].filter(Boolean).join(`
1
+ var Y=["admin","manage","triage","view","none"];function Kr(r){return typeof r=="string"&&Y.includes(r)}function Jr(r,e){let t=Y.indexOf(r);return t!==-1&&t<=Y.indexOf(e)}var Zr=["dependencies","security"],$t={dependencies:"Dependencies",security:"Security"};function Yr(r=null){let e=["anthropic/claude-opus-5.5","anthropic/claude-fable-5.1","anthropic/claude-sonnet-5","anthropic/claude-haiku-4.5","openai/gpt-6-astra","openai/gpt-6-astra-pro","openai/gpt-6-sol","openai/gpt-6-sol-pro","openai/gpt-6-luna","openai/gpt-6-luna-pro","moonshotai/kimi-k3","google/gemini-3.8-flash","google/gemma-4-31b-it","x-ai/grok-4.7","z-ai/glm-5.3","qwen/qwen3.8-max","deepseek/deepseek-v4.1-flash","deepseek/deepseek-v4-pro"],t=r==="moonshot"?"moonshotai":r,i=e.filter(s=>!["anthropic","openai","moonshot"].includes(r??"")||s.startsWith(`${t}/`)).map(s=>({id:s,efforts:["low","medium","high","xhigh","max"]}));return{models:i,defaultModel:i[0].id}}var Xr=Yr(),Qr=Object.freeze(Xr.models),ei=Xr.defaultModel;var q=null,kt=0;function St(){return q?.user.role??null}function Mo(r){if(r!==null&&!Kr(r))throw new TypeError(`Unknown managed preview role: ${r}. Expected ${Y.join(", ")}.`);kt++,q=r===null?null:{user:{id:`preview:${r}`,login:r,name:r[0].toUpperCase()+r.slice(1),role:r,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function Ro(r,e){let t=new URL(r,"http://managed-preview.invalid").pathname,i=(e?.method??"GET").toUpperCase();if(i==="POST"&&t==="/api/auth/logout")return Response.json({ok:!0});if(i!=="GET")throw new Error("Changes are not saved in the managed UI preview");if(t==="/api/auth/session")return Response.json(q);if(t==="/api/teams")return Response.json({teams:[]});if(t.startsWith("/api/admin/")&&!Jr(q.user.role,"manage"))return Response.json({error:"forbidden"},{status:403});if(["/api/admin/users","/api/admin/teams","/api/admin/repositories"].includes(t)&&q.user.role!=="admin")return Response.json({error:"forbidden"},{status:403});let s={"/api/admin/users":{users:[q.user]},"/api/admin/teams":{teams:[],users:[q.user],repos:[],permissions:Zr},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/reports":{reports:[],repos:[],maxBytes:10485760},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:104857600},"/api/admin/history":{history:[],total:0,page:1,limit:100},"/api/admin/models":{models:Qr,defaultModel:ei},"/api/admin/scan-results":{bundles:[],results:[]}};return Object.hasOwn(s,t)?Response.json(s[t]):Response.json({error:"not-found"},{status:404})}async function w(r,e){if(e?.signal?.throwIfAborted(),q)return Ro(r,e);let t=kt,i=await fetch(r,{...e,cache:"no-store"});if(t!==kt)throw new DOMException("Managed session changed","AbortError");return i}var Je=globalThis,Ze=Je.ShadowRoot&&(Je.ShadyCSS===void 0||Je.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Et=Symbol(),ti=new WeakMap,Ae=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Et)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Ze&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=ti.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&ti.set(t,e))}return e}toString(){return this.cssText}},k=r=>new Ae(typeof r=="string"?r:r+"",void 0,Et),S=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((i,s,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[o+1],r[0]);return new Ae(t,r,Et)},ri=(r,e)=>{if(Ze)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=Je.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},At=Ze?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return k(t)})(r):r;var{is:Lo,defineProperty:zo,getOwnPropertyDescriptor:Io,getOwnPropertyNames:Oo,getOwnPropertySymbols:To,getPrototypeOf:No}=Object,Ye=globalThis,ii=Ye.trustedTypes,Bo=ii?ii.emptyScript:"",Po=Ye.reactiveElementPolyfillSupport,Ce=(r,e)=>r,Ct={toAttribute(r,e){switch(e){case Boolean:r=r?Bo:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},oi=(r,e)=>!Lo(r,e),si={attribute:!0,type:String,converter:Ct,reflect:!1,useDefault:!1,hasChanged:oi};Symbol.metadata??=Symbol("metadata"),Ye.litPropertyMetadata??=new WeakMap;var j=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,t=si){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&zo(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:o}=Io(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get:s,set(n){let a=s?.call(this);o?.call(this,n),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??si}static _$Ei(){if(this.hasOwnProperty(Ce("elementProperties")))return;let e=No(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ce("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ce("properties"))){let t=this.properties,i=[...Oo(t),...To(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(At(s))}else e!==void 0&&t.push(At(e));return t}static _$Eu(e,t){let i=t.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,t=this.constructor.elementProperties;for(let i of t.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 ri(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,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:Ct).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let o=i.getPropertyOptions(s),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Ct;this._$Em=s;let a=n.fromAttribute(t,o.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,t,i,s=!1,o){if(e!==void 0){let n=this.constructor;if(s===!1&&(o=this[e]),i??=n.getPropertyOptions(e),!((i.hasChanged??oi)(o,t)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(n._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:o},n){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),o!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}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[s,o]of this._$Ep)this[s]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[s,o]of i){let{wrapped:n}=o,a=this[s];n!==!0||this._$AL.has(s)||a===void 0||this.C(s,void 0,o,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.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(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};j.elementStyles=[],j.shadowRootOptions={mode:"open"},j[Ce("elementProperties")]=new Map,j[Ce("finalized")]=new Map,Po?.({ReactiveElement:j}),(Ye.reactiveElementVersions??=[]).push("2.1.2");var Rt=globalThis,ni=r=>r,Xe=Rt.trustedTypes,ai=Xe?Xe.createPolicy("lit-html",{createHTML:r=>r}):void 0,Lt="$lit$",D=`lit$${Math.random().toFixed(9).slice(2)}$`,zt="?"+D,jo=`<${zt}>`,ee=document,Re=()=>ee.createComment(""),Le=r=>r===null||typeof r!="object"&&typeof r!="function",It=Array.isArray,hi=r=>It(r)||typeof r?.[Symbol.iterator]=="function",Mt=`[
2
+ \f\r]`,Me=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,li=/-->/g,ci=/>/g,X=RegExp(`>|${Mt}(?:([^\\s"'>=/]+)(${Mt}*=${Mt}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),di=/'/g,pi=/"/g,mi=/^(?:script|style|textarea|title)$/i,Ot=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),c=Ot(1),Ul=Ot(2),Hl=Ot(3),E=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),ui=new WeakMap,Q=ee.createTreeWalker(ee,129);function fi(r,e){if(!It(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return ai!==void 0?ai.createHTML(e):e}var gi=(r,e)=>{let t=r.length-1,i=[],s,o=e===2?"<svg>":e===3?"<math>":"",n=Me;for(let a=0;a<t;a++){let l=r[a],d,u,p=-1,g=0;for(;g<l.length&&(n.lastIndex=g,u=n.exec(l),u!==null);)g=n.lastIndex,n===Me?u[1]==="!--"?n=li:u[1]!==void 0?n=ci:u[2]!==void 0?(mi.test(u[2])&&(s=RegExp("</"+u[2],"g")),n=X):u[3]!==void 0&&(n=X):n===X?u[0]===">"?(n=s??Me,p=-1):u[1]===void 0?p=-2:(p=n.lastIndex-u[2].length,d=u[1],n=u[3]===void 0?X:u[3]==='"'?pi:di):n===pi||n===di?n=X:n===li||n===ci?n=Me:(n=X,s=void 0);let m=n===X&&r[a+1].startsWith("/>")?" ":"";o+=n===Me?l+jo:p>=0?(i.push(d),l.slice(0,p)+Lt+l.slice(p)+D+m):l+D+(p===-2?a:m)}return[fi(r,o+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},ze=class r{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0,a=e.length-1,l=this.parts,[d,u]=gi(e,t);if(this.el=r.createElement(d,i),Q.currentNode=this.el.content,t===2||t===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=Q.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let p of s.getAttributeNames())if(p.endsWith(Lt)){let g=u[n++],m=s.getAttribute(p).split(D),b=/([.?@])?(.*)/.exec(g);l.push({type:1,index:o,name:b[2],strings:m,ctor:b[1]==="."?et:b[1]==="?"?tt:b[1]==="@"?rt:re}),s.removeAttribute(p)}else p.startsWith(D)&&(l.push({type:6,index:o}),s.removeAttribute(p));if(mi.test(s.tagName)){let p=s.textContent.split(D),g=p.length-1;if(g>0){s.textContent=Xe?Xe.emptyScript:"";for(let m=0;m<g;m++)s.append(p[m],Re()),Q.nextNode(),l.push({type:2,index:++o});s.append(p[g],Re())}}}else if(s.nodeType===8)if(s.data===zt)l.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(D,p+1))!==-1;)l.push({type:7,index:o}),p+=D.length-1}o++}}static createElement(e,t){let i=ee.createElement("template");return i.innerHTML=e,i}};function te(r,e,t=r,i){if(e===E)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,o=Le(e)?void 0:e._$litDirective$;return s?.constructor!==o&&(s?._$AO?.(!1),o===void 0?s=void 0:(s=new o(r),s._$AT(r,t,i)),i!==void 0?(t._$Co??=[])[i]=s:t._$Cl=s),s!==void 0&&(e=te(r,s._$AS(r,e.values),s,i)),e}var Qe=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??ee).importNode(t,!0);Q.currentNode=s;let o=Q.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new he(o,o.nextSibling,this,e):l.type===1?d=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(d=new it(o,this,e)),this._$AV.push(d),l=i[++a]}n!==l?.index&&(o=Q.nextNode(),n++)}return Q.currentNode=ee,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},he=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=h,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=te(this,e,t),Le(e)?e===h||e==null||e===""?(this._$AH!==h&&this._$AR(),this._$AH=h):e!==this._$AH&&e!==E&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):hi(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!==h&&Le(this._$AH)?this._$AA.nextSibling.data=e:this.T(ee.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ze.createElement(fi(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{let o=new Qe(s,this),n=o.u(this.options);o.p(t),this.T(n),this._$AH=o}}_$AC(e){let t=ui.get(e.strings);return t===void 0&&ui.set(e.strings,t=new ze(e)),t}k(e){It(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let o of e)s===t.length?t.push(i=new r(this.O(Re()),this.O(Re()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let i=ni(e).nextSibling;ni(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},re=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=h,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=h}_$AI(e,t=this,i,s){let o=this.strings,n=!1;if(o===void 0)e=te(this,e,t,0),n=!Le(e)||e!==this._$AH&&e!==E,n&&(this._$AH=e);else{let a=e,l,d;for(e=o[0],l=0;l<o.length-1;l++)d=te(this,a[i+l],t,l),d===E&&(d=this._$AH[l]),n||=!Le(d)||d!==this._$AH[l],d===h?e=h:e!==h&&(e+=(d??"")+o[l+1]),this._$AH[l]=d}n&&!s&&this.j(e)}j(e){e===h?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},et=class extends re{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===h?void 0:e}},tt=class extends re{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==h)}},rt=class extends re{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=te(this,e,t,0)??h)===E)return;let i=this._$AH,s=e===h&&i!==h||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==h&&(i===h||s);s&&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)}},it=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){te(this,e)}},bi={M:Lt,P:D,A:zt,C:1,L:gi,R:Qe,D:hi,V:te,I:he,H:re,N:tt,U:rt,B:et,F:it},Do=Rt.litHtmlPolyfillSupport;Do?.(ze,he),(Rt.litHtmlVersions??=[]).push("3.3.3");var vi=(r,e,t)=>{let i=t?.renderBefore??e,s=i._$litPart$;if(s===void 0){let o=t?.renderBefore??null;i._$litPart$=s=new he(e.insertBefore(Re(),o),o,void 0,t??{})}return s._$AI(r),s};var Tt=globalThis,x=class extends j{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 t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=vi(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return E}};x._$litElement$=!0,x.finalized=!0,Tt.litElementHydrateSupport?.({LitElement:x});var Uo=Tt.litElementPolyfillSupport;Uo?.({LitElement:x});(Tt.litElementVersions??=[]).push("4.2.2");var Nt=class{constructor(e=()=>{}){this.resources=new Map,this.session=null,this.generation=0,this.sessionController=new AbortController,this.notify=e}setSession(e){(this.session?.id!==e?.id||this.session?.role!==e?.role)&&this.reset(),this.session=e}reset(){this.generation++,this.sessionController.abort(),this.sessionController=new AbortController,this.invalidate(),this.session=null}read(e){return this.resources.get(e)?.data}invalidate(e){for(let[t,i]of this.resources)e&&!e.some(s=>t===s||t.startsWith(`${s}:`))||(i.controller?.abort(),this.resources.delete(t))}async mutate(e,t){let i=this.generation,s;try{s=await e()}catch(o){throw i===this.generation&&o?.name!=="AbortError"&&this.notify(`Couldn't save changes: ${o?.message??o}`),o}if(i!==this.generation)throw new DOMException("Managed session changed","AbortError");return this.invalidate(t),s}async load(e,t,i,{signal:s,apply:o=()=>{}}={}){s?.throwIfAborted();let n=this.resources.get(e);if(n||(n={},this.resources.set(e,n)),n.data!==void 0&&o(n.data),!n.pending){let l=n.controller=new AbortController;n.pending=(async()=>{try{let d=await i(l.signal);return l.signal.throwIfAborted(),n.data=d,d}catch(d){throw!l.signal.aborted&&d?.name!=="AbortError"&&this.notify(`Couldn't refresh ${t}: ${d?.message??d}`),d}})().finally(()=>{n.pending=null})}let a=await n.pending;if(s?.throwIfAborted(),this.resources.get(e)!==n)throw new DOMException("Managed data changed","AbortError");return o(a),a}},z=new Nt(r=>{document.dispatchEvent(new CustomEvent("managed-notice",{detail:{message:r}}))});function Ho(r){z.setSession(r)}function Fo(){z.reset()}var I=class extends x{static properties={session:{attribute:!1},_loading:{state:!0}};constructor(){super(),this.session=null,this.appState=z,this._loading=!1,this._loadRequest=null}get _role(){return this.session?.role??null}get _csrf(){return this.session?.csrfToken??null}get _me(){return this.session?.id??null}disconnectedCallback(){this._loadRequest?.abort(),super.disconnectedCallback()}async _loadCollection(e,t,i,s){this._loadRequest?.abort();let o=new AbortController;this._loadRequest=o,this._loading=!0;try{await this.appState.load(e,t,i,{signal:o.signal,apply:s})}catch(n){!o.signal.aborted&&n?.name!=="AbortError"&&this.appState.read(e)===void 0&&(this._error=String(n?.message??n))}finally{this._loadRequest===o&&(this._loading=!1)}}};function ie(r){return c`<div class="loading-rows" role="status"><span class="sr-only">${r}</span><div aria-hidden="true">${[0,1,2,3].map(()=>c`<div class="loading-row"><span></span><span></span></div>`)}</div></div>`}var O={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},me=r=>(...e)=>({_$litDirective$:r,values:e}),G=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var Ie=class extends G{constructor(e){if(super(e),this.it=h,e.type!==O.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===h||e==null)return this._t=void 0,this.it=e;if(e===E)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};Ie.directiveName="unsafeHTML",Ie.resultType=1;var A=me(Ie);var yi="m5.875 10.154 1.376-.772.023-.067-.023-.037h-.067l-.23-.015-.787-.02-.681-.03-.661-.035-.166-.035-.156-.205.016-.103.14-.094.2.018.442.03.665.046.481.028.714.075h.113l.016-.047-.039-.028-.03-.028-.687-.466-.744-.492-.39-.284-.21-.143-.106-.135-.046-.294.19-.21.258.017.065.018.26.2.557.43.726.535.106.089.042-.03.006-.022-.048-.08-.395-.713-.422-.726-.187-.301-.05-.18a1 1 0 0 1-.03-.213l.218-.296.12-.039.29.039.123.106.18.413.293.65.453.884.133.262.07.242.027.075h.046v-.043l.038-.497.069-.611.067-.787.023-.221.11-.266.218-.143.17.081.14.2-.02.13-.083.54-.163.846-.106.567h.062l.07-.07.287-.382.482-.602.213-.239.248-.264.159-.125h.301l.221.329-.099.34-.31.393-.256.333-.369.496-.23.397.021.032.055-.006.832-.177.45-.081.537-.092.243.113.026.115-.096.236-.573.141-.673.135-1.003.237-.012.01.014.017.452.042.193.01h.473l.88.066.23.153.138.186-.023.141-.354.181-.478-.113-1.116-.266-.383-.096h-.053v.032l.32.312.584.528.731.68.037.168-.094.133-.099-.014-.643-.484-.248-.218-.561-.472H9.08v.05l.129.189.684 1.027.035.315-.05.103-.177.062-.194-.036-.4-.561-.413-.632-.333-.567-.041.023-.197 2.116-.092.108-.212.082-.177-.135-.094-.218.094-.43.113-.561.092-.447.083-.554.05-.184-.004-.013-.04.006-.418.574-.636.858-.503.539-.12.048-.21-.108.02-.193.117-.172.696-.886.42-.549.27-.317-.001-.046h-.016l-1.85 1.201-.328.042-.142-.132.018-.218.067-.071.556-.383Z",fe='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2 2 5v6l6 3 6-3V5L8 2Z"/><path d="M2 5l6 3 6-3"/><path d="M8 8v6"/></svg>';var _i='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="8" cy="2.5" r="1.5" fill="currentColor"/><circle cx="3" cy="13" r="1.5" fill="currentColor"/><circle cx="8" cy="13" r="1.5" fill="currentColor"/><circle cx="13" cy="13" r="1.5" fill="currentColor"/><path d="M8 4v3M8 7H3m5 0h5M3 7v4M8 7v4M13 7v4"/></svg>';var wi='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 1.5H2.5a1 1 0 0 0-1 1V5m9.5-3.5h2.5a1 1 0 0 1 1 1V5M1.5 11v2.5a1 1 0 0 0 1 1H5m6 0h2.5a1 1 0 0 0 1-1V11"/><circle cx="7.25" cy="7.25" r="2.75"/><path d="m9.25 9.25 2.25 2.25"/></svg>',ge='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5H4a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V5.5L9 1.5ZM9 1.5v4h4M5.5 8h5m-5 3h3.5"/></svg>',st='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4.5 4.5-3 3.5 3 3.5m7-7 3 3.5-3 3.5M9.5 2l-3 12"/></svg>',xi='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6.5 3.5 1.6 3.9L12 9l-3.9 1.6-1.6 3.9-1.6-3.9L1 9l3.9-1.6 1.6-3.9ZM12 1.5v4m-2-2h4"/></svg>';var $i={default:{className:"brand-deepview",mark:'<path class="fg" d="M7.843 6.719c-1.605 0-2.926 1.292-3.477 1.947.466.58 1.872 2.024 3.496 2.024s2.907-1.292 3.486-2.005c-.627-.703-1.88-1.966-3.505-1.966m.019 3.857c-1.51 0-2.802-1.263-3.353-1.9.55-.617 1.814-1.852 3.334-1.852 1.51 0 2.698 1.12 3.335 1.852-.533.618-1.787 1.9-3.316 1.9m-.019-3.42c-.826 0-1.577.694-1.577 1.596 0 .789.599 1.577 1.577 1.577.893 0 1.587-.684 1.587-1.577-.01-.779-.627-1.596-1.587-1.596m0 3.069a1.476 1.476 0 0 1-1.482-1.473c0-.722.599-1.491 1.482-1.491.846 0 1.482.693 1.492 1.491 0 .808-.618 1.473-1.492 1.473m.01-2.727c-.637 0-1.264.532-1.264 1.244 0 .627.475 1.235 1.245 1.245.684 0 1.254-.522 1.254-1.244 0-.58-.475-1.236-1.235-1.245m-.02 2.403a1.167 1.167 0 0 1-1.149-1.159c0-.532.456-1.14 1.169-1.149.56 0 1.149.427 1.159 1.15 0 .636-.485 1.158-1.179 1.158m-.769-1.833c-.19.238-.275.494-.237.864l.74.057zm1.026-.294c-.295-.057-.665 0-.912.228l.323.607zm.133.047-.38.56.988.114c-.057-.275-.323-.579-.608-.674m-.124.741.456.912c.21-.209.352-.484.314-.836zm-1.225.504a.97.97 0 0 0 .57.617l.399-.551zm.713.664c.313.076.636.01.845-.161l-.295-.618zm-.637 1.55c0 .028-.028.066-.066.066h-.59c-.028 0-.066-.028-.066-.066s.029-.066.067-.066h.579c.048 0 .076.028.076.066m.712 0c0 .028-.028.066-.066.066h-.437c-.028 0-.066-.028-.066-.066s.028-.066.066-.066h.437c.038 0 .066.028.066.066m.666 0c0 .028-.029.066-.067.066h-.37c-.029 0-.067-.028-.067-.066s.029-.066.067-.066h.37c.038 0 .067.028.067.066m-1.672.351c0 .029-.029.067-.067.067h-.295c-.028 0-.066-.028-.066-.066 0-.029.029-.067.067-.067h.294c.038 0 .066.028.066.066m.694 0c0 .029-.028.067-.066.067h-.409c-.028 0-.066-.028-.066-.066 0-.029.028-.067.066-.067h.399c.038 0 .076.028.076.066m.732 0c0 .029-.029.067-.067.067h-.465c-.029 0-.067-.028-.067-.066 0-.029.029-.067.067-.067h.465c.038 0 .067.028.067.066m-1.093.371a.065.065 0 0 1-.067.066h-.627c-.028 0-.075-.028-.066-.066 0-.028.029-.066.067-.066h.627c.038 0 .066.028.066.066m.684 0a.065.065 0 0 1-.066.066h-.39c-.028 0-.076-.028-.066-.066 0-.028.028-.066.066-.066h.39c.038 0 .066.028.066.066M5.088 6.263c-.019-.105-.114-.19-.237-.19s-.257.104-.257.237.105.238.247.238c.105 0 .218-.076.238-.18h.864v.826l.095-.048V6.31c0-.028-.019-.057-.048-.057h-.902zm-.237.19c-.076 0-.143-.066-.143-.143s.066-.142.143-.142.142.066.142.143c.01.076-.066.142-.143.142m2.89-.323H6.38l.418-.475v-.332a.255.255 0 0 0 .218-.248c0-.123-.114-.256-.256-.256s-.266.114-.266.257c0 .123.095.228.209.247v.284l-.456.523v.893l.095-.047v-.742h1.396c.029 0 .067-.009.067-.057 0-.028-.019-.047-.067-.047m-1.13-1.054c0-.076.066-.152.152-.152s.152.066.152.151c0 .076-.066.152-.152.152s-.152-.066-.152-.152m-.836 5.264h-.874c-.019-.105-.114-.219-.247-.219s-.256.105-.256.257c0 .132.114.275.266.275.104 0 .218-.076.237-.19h.827v.608l-.257.285a.3.3 0 0 0-.095-.019c-.133 0-.256.105-.256.228 0 .133.104.238.237.238.124 0 .247-.105.247-.238a.23.23 0 0 0-.057-.152l.285-.304v-.712c0-.029-.019-.058-.057-.058m-1.121.219a.16.16 0 0 1-.152-.161c0-.077.066-.162.152-.162s.152.066.152.152-.066.171-.152.171m.713 1.14c-.076 0-.143-.066-.143-.143s.066-.133.143-.133.142.067.142.143c0 .066-.066.133-.143.133m5.472-1.377a.24.24 0 0 0-.237.208h-1.13c-.029 0-.038.02-.038.048v.712l-.323.39h-.029a.245.245 0 0 0-.247.247c0 .133.114.256.247.256s.247-.113.247-.256a.26.26 0 0 0-.123-.219l.313-.38v-.674h1.083c.019.105.114.2.238.2.133 0 .266-.105.266-.257 0-.133-.105-.276-.266-.276m-1.758 1.767a.15.15 0 0 1-.143-.152c0-.075.067-.142.143-.142s.152.066.152.143a.15.15 0 0 1-.152.151m1.758-1.33a.15.15 0 0 1-.143-.152.147.147 0 0 1 .294.001.15.15 0 0 1-.152.151M8.917 5.55h-.399a.075.075 0 0 1-.076-.076c0-.028.029-.066.067-.066h.418c.028 0 .066.028.066.066s-.038.076-.076.076m.742 0H9.22c-.038 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.437c.038 0 .066.028.066.066s-.028.076-.066.076m.883 0h-.598c-.029 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.598c.028 0 .066.028.066.066s-.028.076-.066.076m-1.282.4h-.741c-.038 0-.076-.029-.076-.067s.028-.076.066-.076h.75c.039 0 .067.038.067.076 0 .029-.028.067-.066.067m.797 0h-.503c-.038 0-.076-.029-.076-.067s.028-.066.066-.066h.513c.038 0 .067.028.067.066 0 .029-.029.067-.067.067m.476 0h-.19c-.039 0-.067-.029-.067-.067s.028-.066.066-.066h.2c.028 0 .066.028.066.066 0 .029-.028.067-.075.067m-1.682.398h-.332c-.039 0-.077-.028-.077-.066s.029-.066.067-.066h.342c.038 0 .076.028.076.066s-.028.066-.076.066m.789 0h-.494c-.038 0-.067-.028-.067-.066s.029-.066.067-.066h.494c.038 0 .066.028.066.066s-.028.066-.066.066m.893 0h-.599c-.038 0-.076-.028-.076-.066s.028-.066.066-.066h.618c.028 0 .066.028.066.066s-.028.066-.076.066m.418.305a.69.69 0 0 0-.674.712c0 .086.019.18.048.257l.085.066c-.028-.085-.057-.171-.057-.304 0-.285.228-.646.598-.646.295 0 .599.228.599.636a.58.58 0 0 1-.599.59.8.8 0 0 1-.237-.048l.123.114a.4.4 0 0 0 .114.01c.39 0 .684-.276.684-.666 0-.313-.266-.712-.684-.722m.353.552-.019-.01-.161.19-.143-.01-.057-.047-.019-.133.19-.2a.28.28 0 0 0-.361.077c-.076.095-.076.209-.038.351l-.247.304.171.152.266-.266c.142.038.285.019.38-.095a.31.31 0 0 0 .038-.313"/>'},"claude-security":{className:"brand-claude",mark:`<path class="fg" d="${yi}"/>`},"codex-security":{className:"brand-codex",mark:'<path class="fg" d="M11.04 8.364a1.72 1.72 0 0 0-.152-1.432 1.8 1.8 0 0 0-1.925-.846 1.8 1.8 0 0 0-.778-.498 1.8 1.8 0 0 0-.927-.05 1.8 1.8 0 0 0-.827.414 1.77 1.77 0 0 0-.507.767 1.8 1.8 0 0 0-.683.297 1.75 1.75 0 0 0-.499.549 1.75 1.75 0 0 0 .22 2.07 1.72 1.72 0 0 0 .151 1.432 1.8 1.8 0 0 0 1.926.846 1.77 1.77 0 0 0 1.333.587c.78 0 1.47-.496 1.707-1.227a1.8 1.8 0 0 0 .684-.298 1.75 1.75 0 0 0 .499-.548 1.75 1.75 0 0 0-.222-2.063m-2.667 3.678a1.33 1.33 0 0 1-.851-.304l.042-.024 1.413-.804a.23.23 0 0 0 .116-.199V8.747l.597.34q.01.005.011.015v1.629a1.323 1.323 0 0 1-1.328 1.31m-2.857-1.203a1.3 1.3 0 0 1-.158-.879l.042.025 1.414.805a.23.23 0 0 0 .23 0l1.729-.982v.68a.02.02 0 0 1-.01.018l-1.431.814a1.34 1.34 0 0 1-1.816-.48m-.372-3.037a1.32 1.32 0 0 1 .7-.574v1.656a.22.22 0 0 0 .114.197l1.72.979-.598.34a.02.02 0 0 1-.021 0L5.63 9.587a1.304 1.304 0 0 1-.487-1.791zm4.907 1.125L8.327 7.94l.596-.34a.02.02 0 0 1 .02 0l1.43.814a1.3 1.3 0 0 1 .512.528 1.3 1.3 0 0 1-.118 1.4 1.33 1.33 0 0 1-.595.436V9.122a.23.23 0 0 0-.12-.195m.594-.881-.042-.025-1.411-.812a.23.23 0 0 0-.232 0l-1.727.983v-.68a.02.02 0 0 1 .008-.018l1.429-.813a1.34 1.34 0 0 1 1.425.061 1.3 1.3 0 0 1 .55 1.298zM6.908 9.252l-.597-.34a.02.02 0 0 1-.012-.016V7.271c0-.249.073-.493.209-.703s.329-.378.557-.483a1.35 1.35 0 0 1 1.415.18l-.042.023-1.413.804a.23.23 0 0 0-.116.2zm.324-.69.77-.438.77.438v.875l-.768.437-.77-.437z"/>'},deepsec:{className:"brand-vercel",mark:'<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/>'},piolium:{className:"brand-piolium",mark:'<path class="fg" d="M8 6.4 5.6 7.2v2.3c0 1.6 1 2.7 2.4 3.3 1.4-.6 2.4-1.7 2.4-3.3V7.2Z"/>'}},Vo={default:["#2563eb","#fff"],"claude-security":["#d97757","#fff"],"codex-security":["#fff","#000"],deepsec:["#000","#fff"],piolium:["#fbb829","#1c1b19"]},Bt=Object.fromEntries(Object.entries($i).map(([r,{className:e,mark:t}])=>{let[i,s]=Vo[r],o=r==="codex-security"||r==="deepsec"?` stroke="${s}" stroke-width=".5"`:"";return[r,`<svg class="file-icon ${e}" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path class="bg" fill="${i}"${o} d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/><g fill="${s}">${t}</g></svg>`]})),Pt=Object.fromEntries(Object.entries($i).map(([r,{className:e,mark:t}])=>[r,`<span class="report-logo ${e}" aria-hidden="true"><svg viewBox="${r==="default"?"3.5 4 9 9":"4 5 8 8"}" width="14" height="14">${t}</svg></span>`]));var qo=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-history","History"]];function N(r,e){return c`<nav class="manage-nav" aria-label="Management pages">${qo.filter(([,,t])=>t==null||t===e).map(([t,i])=>c`<button type="button" aria-current="${r===t?"page":h}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:t},bubbles:!0,composed:!0}))}}">${i}</button>`)}</nav>`}function M(r){if(r==="bundle")return A(fe);if(r==="report"||r==="preview")return A(ge);if(r==="scan")return A(wi);let e={users:"M10.75 4.75a2.75 2.75 0 1 1-5.5 0 2.75 2.75 0 0 1 5.5 0ZM3 14v-1.5A3.5 3.5 0 0 1 6.5 9h3a3.5 3.5 0 0 1 3.5 3.5V14",team:"M8.5 5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0ZM1.5 14v-1.5A3.5 3.5 0 0 1 5 9h2a3.5 3.5 0 0 1 3.5 3.5V14M11 2.75a2.5 2.5 0 0 1 0 4.5m1 2a3 3 0 0 1 2.5 3V14",repo:"M3 12.5V3a1.5 1.5 0 0 1 1.5-1.5H13v13H4.5a1.5 1.5 0 0 1 0-3H13M7 1.5v6l2-1.5 2 1.5v-6",history:"M2 5a6.25 6.25 0 1 1-.25 5M1.5 1.5V5H5M8 4.5V8l3 1.5",arrow:"M3 8h10M9 4l4 4-4 4",show:"M1 8s2.5-4.5 7-4.5S15 8 15 8s-2.5 4.5-7 4.5S1 8 1 8Zm9 0a2 2 0 1 0-4 0 2 2 0 0 0 4 0",hide:"m2 2 12 12M6 3.75A8 8 0 0 1 8 3.5c4.5 0 7 4.5 7 4.5a12 12 0 0 1-2 2.5M3.5 5A13 13 0 0 0 1 8s2.5 4.5 7 4.5a8 8 0 0 0 3-.6",download:"M8 2v8M5 7l3 3 3-3M2 11v3h12v-3",upload:"M8 11V2m-3 3 3-3 3 3M2 10v4h12v-4"};return c`<svg class="${r==="repo"?"repo-icon":h}" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e[r]??e.repo}"></path></svg>`}var{I:Go}=bi,ki=r=>r;var Ei=r=>r.strings===void 0,Si=()=>document.createComment(""),be=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let o=i.insertBefore(Si(),s),n=i.insertBefore(Si(),s);t=new Go(o,n,r,r.options)}else{let o=t._$AB.nextSibling,n=t._$AM,a=n!==r;if(a){let l;t._$AQ?.(r),t._$AM=r,t._$AP!==void 0&&(l=r._$AU)!==n._$AU&&t._$AP(l)}if(o!==s||a){let l=t._$AA;for(;l!==o;){let d=ki(l).nextSibling;ki(i).insertBefore(l,s),l=d}}}return t},W=(r,e,t=r)=>(r._$AI(e,t),r),Wo={},ot=(r,e=Wo)=>r._$AH=e,Ai=r=>r._$AH,nt=r=>{r._$AR(),r._$AA.remove()};var R=me(class extends G{constructor(r){if(super(r),r.type!==O.PROPERTY&&r.type!==O.ATTRIBUTE&&r.type!==O.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Ei(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===E||e===h)return e;let t=r.element,i=r.name;if(r.type===O.PROPERTY){if(e===t[i])return E}else if(r.type===O.BOOLEAN_ATTRIBUTE){if(!!e===t.hasAttribute(i))return E}else if(r.type===O.ATTRIBUTE&&t.getAttribute(i)===e+"")return E;return ot(r),e}});var C=class extends x{static properties={options:{attribute:!1},value:{attribute:!1},label:{type:String},placeholder:{type:String},disabled:{type:Boolean},_query:{state:!0},_facet:{state:!0},_open:{state:!0}};static styles=S`:host{display:block;min-width:0}*{box-sizing:border-box}button,input{font:inherit;color:var(--text)}button{cursor:default;user-select:none}.trigger{display:flex;align-items:center;gap:.6rem;width:100%;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);text-align:left;font-size:.76rem}.trigger:hover:not(:disabled){border-color:var(--muted)}.trigger:disabled{opacity:.5}:host([variant=filter]){display:inline-block;max-width:min(20rem,100%)}:host([variant=filter]) .trigger{height:30px;min-width:8.5rem;background:transparent;font-size:.8rem;font-weight:500;border-radius:4px}.name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.option-copy{flex:1;min-width:0;display:grid;gap:.08rem}.secondary{color:var(--muted);font-size:.64rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.avatar{display:grid;place-items:center;flex:0 0 1.5rem;width:1.5rem;height:1.5rem;border-radius:50%;color:var(--accent);background:rgb(from var(--accent) r g b / .13);font-family:sans-serif;font-size:.62rem;font-weight:600}.detail,.count{flex:0 0 auto;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums;white-space:nowrap}svg{flex:0 0 auto;width:.9rem;height:.9rem;color:var(--muted)}.menu{visibility:hidden;position:fixed;inset:auto;margin:0;padding:0;overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--text);box-shadow:0 .6rem 1.6rem #0006;user-select:none}.menu:popover-open{display:flex;flex-direction:column}.menu[data-positioned]{visibility:visible}.search{display:flex;align-items:center;gap:.5rem;flex:0 0 auto;padding:.55rem .65rem;border-bottom:1px solid var(--border)}input{flex:1;min-width:0;width:0;padding:.15rem 0;border:0;background:transparent;font-size:.78rem;outline:none}input::placeholder{color:var(--muted)}.search:focus-within{box-shadow:inset 0 -2px var(--accent)}.body{display:flex;min-height:0;flex:1}.facets{width:10.5rem;flex:0 0 auto;padding:.35rem;overflow:auto;overscroll-behavior:none;border-right:1px solid var(--border);background:rgb(from var(--bg) r g b / .25)}.org{display:flex;align-items:center;gap:.4rem;width:100%;padding:.4rem .45rem;border:0;border-radius:4px;background:transparent;text-align:left;font-size:.7rem}.org[aria-pressed=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.results{flex:1;min-width:0;overflow:auto;overscroll-behavior:none;padding:.3rem}.group+.group{margin-top:.35rem;padding-top:.35rem;border-top:1px solid var(--border)}.heading{position:sticky;top:-.3rem;z-index:1;display:flex;align-items:center;gap:.4rem;margin:0;padding:.4rem .5rem;color:var(--muted);background:var(--bg);font-size:.68rem;font-weight:600}.heading svg{width:.8rem;height:.8rem}.option{display:flex;align-items:center;gap:.65rem;width:100%;padding:.35rem .5rem;border:0;border-radius:4px;background:transparent;text-align:left;font-size:.76rem}.option svg{width:.8rem;height:.8rem;opacity:0;color:var(--accent)}.option[aria-selected=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.option[aria-selected=true] svg{opacity:1}.option:disabled{opacity:.45}.option:hover:not(:disabled),.org:hover{background:rgb(from var(--text) r g b / .05)}.pinned{padding-bottom:.25rem;margin-bottom:.25rem;border-bottom:1px solid var(--border)}.empty{margin:0;padding:1.3rem .7rem;color:var(--muted);font-size:.76rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}@media(max-width:40rem){.facets{width:8.5rem}}@media(max-width:28rem){.facets{width:7rem}.option{gap:.35rem}}`;constructor(){super(),this.options=[],this.value=null,this.label="Choose",this.placeholder="Choose",this.disabled=!1,this._query="",this._facet=null,this._open=!1,this._menuHeight=null,this._onViewport=()=>this._position()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onViewport),window.addEventListener("scroll",this._onViewport,!0)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onViewport),window.removeEventListener("scroll",this._onViewport,!0)}render(){let e=this.options.find(n=>n.value===this.value),t=this.choices(),s=[...t.pinned,...t.sections.flatMap(n=>n.options)].filter(n=>!n.disabled),o=s.find(n=>n.value===this.value)?.value??s[0]?.value;return c`<button type="button" class="trigger" popovertarget="selector-menu" aria-label="${this.label}" aria-haspopup="dialog" aria-expanded="${this._open}" ?disabled="${this.disabled}">${e?this.optionIcon(e):h}<span class="name">${e?.label??this.placeholder}</span>${e?.detail?c`<span class="detail">${e.detail}</span>`:h} <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg></button><div class="menu" id="selector-menu" popover="auto" role="dialog" aria-label="${this.label}" @beforetoggle="${this._beforeToggle}" @toggle="${this._toggle}" @keydown="${this._keyDown}"><div class="search"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${`${this.searchLabel}\u2026`}" aria-label="${this.searchLabel}" aria-controls="selector-options" .value="${R(this._query)}" @input="${n=>{this._query=n.target.value}}"> <span class="count" role="status">${t.count}${t.count===t.total?"":` / ${t.total}`}</span></div><div class="body">${t.showFacets?c`<div class="facets" role="group" aria-label="${this.facetLabel}"><button type="button" class="org" aria-pressed="${t.activeFacet==null}" @click="${()=>this._filterFacet(null)}"><span class="name">${this.allFacetsLabel}</span><span class="count">${t.total}</span></button> ${t.facets.map(n=>c`<button type="button" class="org" title="${n.name}" aria-pressed="${t.activeFacet===n.value}" @click="${()=>this._filterFacet(n.value)}"><span class="name">${n.name}</span><span class="count">${n.count}</span></button>`)}</div>`:h}<div class="results" id="selector-options" role="listbox" aria-label="${this.optionsLabel}">${t.pinned.length>0?c`<div class="pinned">${t.pinned.map(n=>this._option(n,!1,o))}</div>`:h} ${t.sections.map((n,a)=>c`<div class="group" role="group" aria-labelledby="${n.label?`selector-group-${a}`:h}">${n.label?c`<h3 class="heading" id="${`selector-group-${a}`}">${n.organization?c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" aria-hidden="true"><path d="M3 14V3h6v11M9 7h4v7M1 14h14M5 6h2M5 9h2M5 12h2"/></svg>`:h}${n.label}</h3>`:h} ${n.options.map(l=>this._option(l,n.organization,o))}</div>`)} ${t.count?h:c`<p class="empty">${this.options.length>0?this.noMatchesLabel:this.emptyLabel}</p>`}</div></div></div>`}optionIcon(e){return h}optionTitle(e){return e.label}_option(e,t,i){return c`<button type="button" class="option" role="option" ?data-reset="${e.reset}" ?disabled="${e.disabled}" aria-label="${e.label}" title="${this.optionTitle(e)}" aria-selected="${e.value===this.value}" tabindex="${e.value===i?0:-1}" @click="${()=>this._pick(e.value)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>${this.optionIcon(e)}${e.initials?c`<span class="avatar" aria-hidden="true">${e.initials}</span>`:h}<span class="option-copy"><span class="name">${e.displayLabel??(t?e.name:e.label)}</span>${e.secondary?c`<span class="secondary">${e.secondary}</span>`:h}</span>${e.detail?c`<span class="detail">${e.detail}</span>`:h}</button>`}updated(e){this.disabled&&this._open&&this._close(!1),e.has("options")&&(this._menuHeight=null),this._position(),(e.has("_query")||e.has("_facet"))&&(this.renderRoot.querySelector(".results").scrollTop=0)}_beforeToggle(e){this._open=e.newState==="open",delete e.target.dataset.positioned,this._open&&(this._query="",this._facet=null,this._menuHeight=null)}async _toggle(e){e.newState==="open"&&(await this.updateComplete,!(!this._open||!this.isConnected)&&(this._position(),this.renderRoot.querySelector("input").focus({preventScroll:!0})))}_position(){let e=this.renderRoot.querySelector(".menu");if(!e?.matches(":popover-open"))return;let t=this.renderRoot.querySelector(".trigger").getBoundingClientRect(),i=8,s=e.querySelector(".facets")!=null,o=Math.min(Math.max(t.width,s?560:360),window.innerWidth-i*2),n=window.innerHeight-t.bottom-i-4,a=t.top-i-4;e.style.width=`${o}px`,this._menuHeight??=Math.min(480,e.querySelector(".search").offsetHeight+Math.max(e.querySelector(".results").scrollHeight,e.querySelector(".facets")?.scrollHeight??0)+2);let l=this._menuHeight,d=n<l&&a>n;e.style.maxHeight=`${Math.max(0,Math.min(l,d?a:n))}px`,e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-o-i))}px`,e.style.top=`${Math.max(i,d?t.top-e.offsetHeight-4:t.bottom+4)}px`,e.dataset.positioned=""}_filterFacet(e){this._facet=e,this.renderRoot.querySelector("input").focus({preventScroll:!0})}_keyDown(e){if(e.stopPropagation(),e.key==="Escape"){e.preventDefault(),this._close();return}let t=this.renderRoot.querySelector("input"),i=this.renderRoot.activeElement,s=[...this.renderRoot.querySelectorAll(".option:not(:disabled)")],o=s.indexOf(i);if(i!==t&&o<0)return;if(e.key==="Enter"&&i===t){e.preventDefault(),(this.renderRoot.querySelector(".option:not([data-reset]):not(:disabled)")??s[0])?.click();return}let n;if(e.key==="ArrowDown")n=Math.min(o+1,s.length-1);else if(e.key==="ArrowUp")n=o-1;else if(i!==t&&e.key==="Home")n=0;else if(i!==t&&e.key==="End")n=s.length-1;else if(i!==t&&e.key.length===1&&e.key!==" "&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault(),this._query+=e.key,t.focus();return}else return;e.preventDefault();for(let[a,l]of s.entries())l.tabIndex=a===n?0:-1;n<0?t.focus():s[n]?.focus()}_pick(e){this.disabled||!this.options.some(t=>t.value===e&&!t.disabled)||(this._close(),this.dispatchEvent(new CustomEvent(this.changeEvent,{detail:{value:e},bubbles:!0,composed:!0})))}_close(e=!0){this.renderRoot.querySelector(".menu").hidePopover(),this._open=!1,e&&this.renderRoot.querySelector(".trigger").focus({preventScroll:!0})}};var jt=class extends C{get changeEvent(){return"local-item-change"}get searchLabel(){return"Search local files"}get optionsLabel(){return"Local files"}get noMatchesLabel(){return"No matching files."}get emptyLabel(){return"No local files available."}optionTitle(){return h}choices(){let e=this._query.trim().toLocaleLowerCase(),t=this.options.filter(i=>`${i.label} ${i.secondary??""}`.toLocaleLowerCase().includes(e));return{pinned:[],sections:[{options:t}],count:t.length,total:this.options.length,showFacets:!1}}};customElements.define("managed-local-item-selector",jt);var Oe=class{constructor(e,t,i){this.host=e,this.kind=t,this.upload=i,this.source=null,this.hasData=!1,this.open=!1,this.options=[],this.value=null,this.busy=!1,this.loading=!1,this.error="",this.success="",this.generation=0,this.readAbort=null,this.onChange=s=>{if(s?.kind){if(s.kind!==this.kind)return;if(s.value!==this.value){this.refresh();return}}this.readAbort&&!this.readAbort.signal.aborted&&(this.readAbort.abort(),this.error=`The local ${this.kind} changed or the list was refreshed. Select it again before importing.`),this.options=[],this.value=null,this.success="",this.refresh()},this.onBlur=()=>{this.readAbort&&!this.readAbort.signal.aborted&&this.onChange()},this.onVisibilityChange=()=>{globalThis.document?.visibilityState==="hidden"&&this.onBlur()},e.addController(this)}hostConnected(){globalThis.addEventListener("focus",this.onChange),globalThis.addEventListener("blur",this.onBlur),globalThis.addEventListener("storage",this.onChange),globalThis.document?.addEventListener("visibilitychange",this.onVisibilityChange),this.connectSource()}hostUpdated(){this.connectSource()}connectSource(){this.source!==this.host.localImportSource&&(this.unsubscribe?.(),this.abort?.abort(),this.source=this.host.localImportSource,this.unsubscribe=this.source?.subscribe(this.onChange),this.onChange())}hostDisconnected(){++this.generation,this.abort?.abort(),this.unsubscribe?.(),this.source=null,globalThis.removeEventListener("focus",this.onChange),globalThis.removeEventListener("blur",this.onBlur),globalThis.removeEventListener("storage",this.onChange),globalThis.document?.removeEventListener("visibilitychange",this.onVisibilityChange)}async refresh(){let e=++this.generation,t=this.source;this.loading=!0,this.host.requestUpdate();try{let i=t?await t.hasData(this.kind):!1;if(e!==this.generation)return;this.hasData=i;let s=this.open&&!t?.locked?await t?.list(this.kind)??[]:[];if(e!==this.generation)return;this.options=s,s.some(o=>o.value===this.value)||(this.value=null)}catch(i){e===this.generation&&(this.error=String(i?.message??i))}finally{e===this.generation&&(this.loading=!1,this.host.requestUpdate())}}toggle(){this.busy||(this.open=!this.open,this.error="",this.success="",this.options=[],this.value=null,this.refresh())}async unlock(){if(this.busy)return;this.busy=!0,this.error="";let e=this.abort=new AbortController;this.host.requestUpdate();try{await this.source.unlock({signal:e.signal})&&!e.signal.aborted&&await this.refresh()}catch(t){e.signal.aborted||(this.error=String(t?.message??t))}finally{this.busy=!1,this.host.requestUpdate()}}async importSelected(){if(this.busy||this.loading||!this.value||this.source?.locked)return;this.busy=!0,this.error="",this.success="";let e=this.options.find(i=>i.value===this.value)?.label,t=this.abort=new AbortController;this.readAbort=t,this.host.requestUpdate();try{await this.source.importItem(this.kind,this.value,i=>(this.readAbort=null,this.upload(i)),{signal:t.signal}),!t.signal.aborted&&!this.source?.locked&&(this.success=`Imported ${e}.`,this.value=null)}catch(i){t.signal.aborted||(this.error=String(i?.message??i))}finally{this.readAbort===t&&(this.readAbort=null),this.busy=!1,this.host.requestUpdate()}}renderAction(){return this.hasData||this.open?c`<button type="button" class="local-import-toggle" aria-expanded="${this.open}" aria-controls="local-import-panel" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Import</button>`:h}renderPanel(e){if(!this.open)return h;let t=this.source?.locked;return c`<section class="local-import-panel" id="local-import-panel" aria-label="${`Import local ${this.kind}`}"><div class="local-import-copy"><strong>Import local ${this.kind}</strong><p>${t?"Unlock local data with your passkey to choose a file.":"Copy a file from this browser to the managed workspace. The local copy stays on this device."}</p></div><div class="local-import-controls">${t?c`<button type="button" class="local-import-submit" ?disabled="${this.busy}" @click="${()=>this.unlock()}">${this.busy?"Waiting for passkey\u2026":"Unlock with passkey"}</button>`:c`<managed-local-item-selector label="${`Choose local ${this.kind}`}" placeholder="${this.loading?"Loading local files\u2026":`Choose local ${this.kind}\u2026`}" .options="${this.options}" .value="${this.value}" ?disabled="${this.busy||this.loading}" @local-item-change="${i=>{this.value=i.detail.value,this.success="",this.host.requestUpdate()}}"></managed-local-item-selector><button type="button" class="local-import-submit" ?disabled="${e||this.busy||this.loading||!this.value}" @click="${()=>this.importSelected()}">${this.busy?"Importing\u2026":`Import ${this.kind}`}</button>`} <button type="button" class="local-import-close" ?disabled="${this.busy}" @click="${()=>this.toggle()}">Close</button></div>${!t&&!this.loading&&this.options.length===0?c`<p class="local-import-message">No local ${this.kind}s available.</p>`:h} ${this.error?c`<p class="local-import-message error" role="alert">${this.error} <button type="button" ?disabled="${this.busy}" @click="${()=>{this.error="",this.refresh()}}">Retry</button></p>`:h} ${this.success?c`<p class="local-import-message" role="status">${this.success}</p>`:h}</section>`}};var Dt=`.local-import-toggle{flex-shrink:0;margin-block:calc(-.25rem - 1px);margin-left:auto;padding:.25rem .6rem;border:1px solid var(--border);border-radius:6px;background:transparent;color:var(--muted);font:inherit;font-size:.75rem;line-height:1.5}.local-import-toggle:hover,.local-import-toggle[aria-expanded=true]{color:var(--text);background:rgb(from var(--text) r g b / .06)}.local-import-panel{display:grid;gap:.8rem;padding:1rem;margin-bottom:1.25rem;border:1px solid var(--border);border-radius:8px;background:rgb(from var(--accent) r g b / .025)}.local-import-copy strong{font-size:.82rem;font-weight:600}.local-import-copy p,.local-import-message{margin:.3rem 0 0;color:var(--muted);font-size:.75rem;line-height:1.5}.local-import-controls{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem}managed-local-item-selector{flex:1 1 16rem;min-width:0}.local-import-controls button,.local-import-message button{padding:.35rem .7rem;border:1px solid var(--border);border-radius:5px;background:transparent;color:var(--text);font:inherit;font-size:.75rem;line-height:1.5}.local-import-controls .local-import-submit{border-color:rgb(from var(--accent) r g b / .4);background:rgb(from var(--accent) r g b / .1);color:var(--accent)}.local-import-controls .local-import-close{color:var(--muted)}.local-import-panel button:disabled,.local-import-toggle:disabled{opacity:.5}.local-import-panel button:focus-visible,.local-import-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.local-import-message.error{color:var(--critical)}
4
+ `;var U=`: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}.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: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: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: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: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: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){.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{min-width:8rem;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: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-browse{min-width:7rem}
5
+ `;var Ci=`.home-section{margin-top:1.1rem;margin-bottom:2rem}.section-heading{display:flex;align-items:baseline;gap:1rem;margin-bottom:.85rem}.section-heading h2{margin:0;font-size:.86rem;font-weight:600}.section-heading>span{color:var(--muted);font-size:.75rem}.pages{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.9rem}.page{display:flex;flex-direction:column;gap:.85rem;padding:1.35rem;border:1px solid var(--border);border-radius:12px;color:var(--text);background:var(--panel);text-align:left;font:inherit}.page:hover{background:var(--panel-hover);border-color:color-mix(in srgb,var(--muted) 60%,var(--border))}.page-top{display:flex;align-items:center;gap:.75rem;width:100%}.page-icon{display:grid;place-items:center;flex-shrink:0;width:2.5rem;height:2.5rem;border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border));border-radius:9px;background:color-mix(in srgb,var(--accent) 7%,var(--panel));color:var(--accent)}.page-bundle .page-icon{color:var(--green);border-color:color-mix(in srgb,var(--green) 18%,var(--border));background:color-mix(in srgb,var(--green) 6%,var(--panel))}.page-scan .page-icon{color:var(--yellow);border-color:color-mix(in srgb,var(--yellow) 18%,var(--border));background:color-mix(in srgb,var(--yellow) 6%,var(--panel))}.page-icon svg{width:1.2rem;height:1.2rem}.arrow{display:flex;margin-left:auto;flex-shrink:0;color:var(--muted)}.arrow svg{width:1rem;height:1rem}.page:hover .arrow{color:var(--text)}.page-copy{display:grid;gap:.45rem}.page>.page-copy{margin-inline-start:3.25rem}.page-copy strong,.page-title{font-size:1rem;font-weight:600;letter-spacing:-.015em}.page-copy>span{color:var(--muted);font-size:.8rem;line-height:1.65}.workspace-pages .page{gap:.85rem;padding:1.2rem 1.35rem}.workspace-pages .page-icon{width:2rem;height:2rem;color:var(--muted);background:transparent;border-color:var(--border)}.workspace-pages .page-title{font-size:.9rem}.workspace-pages .page-copy{margin-inline-start:2.75rem}.history-link{display:flex;align-items:center;gap:1rem;width:100%;padding:1.25rem 0;border:0;border-top:1px solid var(--border);text-align:left;color:var(--text);background:transparent}.history-link>.page-icon{color:var(--muted);background:transparent;border-color:var(--border)}.history-link .page-copy strong{font-size:.85rem}.history-cta{display:flex;align-items:center;gap:.6rem;flex-shrink:0;margin-left:auto;color:var(--muted);font-size:.78rem}.history-cta svg{width:1rem;height:1rem}.history-link:hover .history-cta{color:var(--accent)}@container (max-width: 48rem){.pages{grid-template-columns:1fr;gap:.65rem}.page,.workspace-pages .page{gap:.65rem;padding:1.15rem}.page-top .arrow{display:none}.workspace-pages .page-icon{width:2.5rem;height:2.5rem}.workspace-pages .page-copy{margin-inline-start:3.25rem}.page-copy{gap:.2rem}.page-copy strong,.page-title{font-size:.95rem}.section-heading>span{display:none}.history-cta{font-size:0}}
6
+ `;var Mi=`.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-bottom:.9rem}.toolbar input{flex:1}.toolbar select{min-width:10rem}.history{overflow-x:auto;border:1px solid var(--border);border-radius:9px;background:var(--panel)}.row,.history-head{display:grid;grid-template-columns:4.7rem minmax(16rem,1fr) minmax(12rem,1fr) 7.5rem;align-items:center;gap:.85rem;min-width:47rem;padding:.45rem .85rem}.history-head{background:rgb(from var(--text) r g b / .025);color:var(--muted);font-size:.7rem}.row{border-top:1px solid var(--border);min-height:2.35rem}.row:hover{background:var(--panel-hover)}.kind{display:inline-flex;align-items:center;justify-content:center;width:fit-content;padding:.05rem .35rem;border:1px solid var(--border);border-radius:4px;color:var(--muted);font-size:.65rem;text-transform:capitalize}.kind.triage{color:var(--accent);border-color:rgb(from var(--accent) r g b / .25);background:rgb(from var(--accent) r g b / .06)}.kind.upload{color:var(--green);border-color:rgb(from var(--green) r g b / .25);background:rgb(from var(--green) r g b / .06)}.kind.visibility{color:var(--yellow);border-color:rgb(from var(--yellow) r g b / .25);background:rgb(from var(--yellow) r g b / .06)}.activity-description,.detail{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.75rem}.actor{color:var(--text);font-weight:500}.action,.detail{color:var(--muted)}.history-time{display:flex;flex-direction:column;color:var(--muted);font-size:.7rem;white-space:nowrap;font-variant-numeric:tabular-nums}.history .empty{border:0;margin:0}.pagination{display:flex;align-items:center;flex-wrap:wrap;gap:.65rem;margin-top:1rem;color:var(--muted);font-size:.75rem}.pagination>span:first-child{margin-right:auto}
7
+ `;var Ri=`.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:5px;color:var(--muted);background:transparent}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical, #e5534b);background:rgb(from var(--critical, #e5534b) r g b / .1)}.icon-btn svg,.btn svg{width:.9rem;height:.9rem}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.list-head{color:var(--muted);font-size:.72rem;font-weight:500;padding-top:.75rem;padding-bottom:.75rem;border-bottom:1px solid var(--border);background:rgb(from var(--text) r g b / .025)}.users{list-style:none;margin:0;padding:0}.users li+li{border-top:1px solid var(--border)}.who{display:grid;gap:.15rem;min-width:0}.name-text,.login{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.login{color:var(--muted);font-size:.75rem}.last-seen time,.last-activity time{color:var(--text)}.activity-link{display:block;min-width:0;padding:.15rem .2rem;border:0;border-radius:4px;color:inherit;background:transparent;text-align:left}.activity-link:hover{color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.you{padding:.05rem .35rem;border-radius:4px;color:var(--accent);background:rgb(from var(--accent) r g b / .1);font-size:.75rem;font-weight:500}.permission-granted{color:var(--accent)}.permission-denied{color:var(--muted)}.no-team{color:var(--muted);font-size:.75rem}.access{display:flex;align-items:center;min-width:0}.role{width:100%;height:auto;font-size:.78rem}.self-note{display:flex;align-items:center;gap:.5rem;margin:1rem 0;color:var(--muted);font-size:.75rem}.users li:hover{background:var(--panel-hover)}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:1.85rem;height:1.85rem;border-radius:50%;overflow:hidden;font-size:.85rem;font-weight:600}.directory{border:1px solid var(--border);border-radius:11px;overflow:hidden;background:var(--panel);overflow-x:auto}.list-head,.users{min-width:49rem}.list-head,.users li{display:grid;grid-template-columns:minmax(11rem,1fr) minmax(14rem,1.2fr) 6.2rem 6.2rem 6.5rem;gap:.7rem;align-items:center;padding:1rem .85rem}.users li{padding-top:.6rem;padding-bottom:.6rem;min-height:3.5rem}.person{display:flex;align-items:center;gap:.65rem;min-width:0}.name{display:flex;align-items:center;gap:.4rem;font-size:.8rem;font-weight:500}.last-seen,.last-activity{display:grid;gap:.08rem;color:var(--muted);font-size:.68rem;font-variant-numeric:tabular-nums}.memberships{display:grid;gap:.1rem;min-width:0}.team-access{display:flex;gap:.2rem .5rem;min-width:0;font-size:.7rem;line-height:1.4;align-items:center;flex-wrap:nowrap}.team-access strong{display:inline-flex;align-items:center;gap:.25rem;color:var(--text);font-weight:500;min-width:0;max-width:8rem}.team-access strong svg{width:.8rem;height:.8rem;flex-shrink:0;color:var(--muted)}.team-access strong span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.team-perms{display:inline-flex;flex-wrap:nowrap;gap:.45rem;font-size:inherit;flex-shrink:0}
8
+ `;var Li=`.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:5px;color:var(--muted);background:transparent}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical, #e5534b);background:rgb(from var(--critical, #e5534b) r g b / .1)}.icon-btn svg,.btn svg{width:.9rem;height:.9rem}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:2rem;height:2rem;border-radius:50%;overflow:hidden;background:var(--surface-active);color:var(--muted);font-family:system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:.8rem;font-weight:600;user-select:none}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin:1.5rem 0 1.65rem}.search{flex:1 1 14rem;max-width:25rem;margin-right:auto}.search input{width:100%}.owners{display:grid;gap:1.6rem}.owner-head{display:flex;align-items:center;gap:.6rem;margin:0 0 .7rem;color:var(--muted);font-size:.8rem;font-weight:500}.owner-icon{display:grid;place-items:center;width:1.6rem;height:1.6rem;border:1px solid var(--border);border-radius:5px;background:var(--surface);text-transform:uppercase;font-size:.75rem}.repos{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--panel)}.repos li+li{border-top:1px solid var(--border)}button.repo-row{border:0;background:transparent;color:var(--text);cursor:default}button.repo-row:hover{background:var(--surface-active)}button.repo-row:focus-visible{outline-offset:-2px}.repo-icon{width:1.15rem;height:1.15rem;flex-shrink:0;color:var(--muted)}.repo-meta:before{content:none}.arrow{width:1rem;height:1rem;flex:0 0 auto;color:var(--muted)}.connected{display:inline-flex;align-items:center;gap:.25rem;flex:0 0 auto;color:var(--muted);font-size:.75rem;white-space:nowrap}.connected svg{width:.85rem;height:.85rem}.access-note{display:flex;align-items:center;gap:.85rem;padding:.85rem 1rem;background:var(--surface);border:1px solid var(--border);border-radius:8px}.access-note p{flex:1;margin:0;color:var(--muted);font-size:.78rem;line-height:1.5}a.btn{color:var(--text);text-decoration:none;cursor:default}.empty{padding:2.5rem 1rem;border:1px solid var(--border);border-radius:8px;text-align:center}.empty strong{display:block;margin-bottom:.4rem;font-size:.9rem;font-weight:500}.empty p{margin:0;color:var(--muted);font-size:.8rem}.loading{min-height:8rem;display:grid;place-items:center;color:var(--muted);font-size:.8rem}.pagination{display:flex;align-items:center;gap:.5rem;margin-top:.85rem}.pagination span{margin-right:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}.section{margin-top:1.75rem;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--panel)}.section h2{margin:0;padding:1rem 1.25rem;border-bottom:1px solid var(--border);background:rgb(from var(--text) r g b / .025);font-size:.85rem;font-weight:600}.settings-row{display:flex;align-items:center;gap:1rem;padding:1.25rem}.settings-copy{flex:1;min-width:0}.settings-copy strong{font-size:.83rem;font-weight:500}.settings-copy p{margin:.25rem 0 0;color:var(--muted);font-size:.76rem;line-height:1.5}.settings-row+.settings-row{border-top:1px solid var(--border)}.btn.danger,.error{color:var(--critical, #e5534b)}.status-line{display:inline-flex;align-items:center;gap:.35rem;color:var(--muted);font-size:.75rem}.status-line.inactive{color:var(--warning, #d19a24)}.data-section{margin-top:1.5rem}.data-section h2{margin:0 0 .5rem;font-size:.85rem;font-weight:500}.data-list{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:8px;overflow:hidden}.data-list li{display:flex;align-items:baseline;gap:.75rem;padding:.85rem 1rem;font-size:.8rem}.data-list li+li{border-top:1px solid var(--border)}.data-list strong{min-width:0;overflow-wrap:anywhere;font-weight:500}.data-list span{margin-left:auto;color:var(--muted);font-size:.75rem;white-space:nowrap}.data-empty{margin:0;color:var(--muted);font-size:.75rem}.dialog-backdrop{position:fixed;inset:0;z-index:20;display:grid;place-items:center;padding:1rem;background:#000000a6}.dialog{width:min(40rem,100%);max-height:calc(100vh - 3rem);overflow:auto;padding:1.5rem;border:1px solid var(--border);border-radius:12px;background:var(--bg);box-shadow:0 1rem 3rem #00000059}.dialog.small{width:min(28rem,100%)}.dialog h2{margin:0;font-size:1.05rem;font-weight:600}.dialog-copy{margin:.55rem 0 1rem;color:var(--muted);font-size:.78rem;line-height:1.5}.dialog-data{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:0 0 1rem}.dialog-data section{min-width:0;padding:.65rem;border:1px solid var(--border);border-radius:7px}.dialog-data h3{margin:0 0 .4rem;font-size:.75rem;font-weight:600}.dialog-data ul{max-height:9rem;overflow:auto;margin:0;padding-left:1rem;color:var(--muted);font-size:.75rem}.dialog-data li{margin:.2rem 0;overflow-wrap:anywhere}.confirm-line{display:flex;align-items:flex-start;gap:.5rem;margin:.7rem 0;color:var(--text);font-size:.76rem;line-height:1.4}.confirm-line input{flex:0 0 auto;margin-top:.15rem;accent-color:var(--accent)}.confirm-name{width:100%;margin-top:.15rem;padding:.45rem .55rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--text);font:inherit;font-size:.78rem}.dialog-actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1rem}.dialog-actions .danger{color:var(--critical, #e5534b);border-color:rgb(from var(--critical, #e5534b) r g b / .4)}@container (max-width: 35rem){.intro{margin-left:0}.search{flex-basis:100%;max-width:none}.access-note,.settings-row{flex-wrap:wrap}.access-note p,.settings-copy{flex-basis:100%}.head h1{font-size:1.35rem}.repo-copy{gap:.35rem}.repo-meta{max-width:100%}.dialog-data{grid-template-columns:1fr}}.repo-name{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.83rem;font-weight:500}.repo-row{display:flex;align-items:center;gap:.75rem;width:100%;min-height:2.8rem;padding:.55rem .85rem;text-align:left}.repo-copy{display:flex;flex-direction:row;align-items:center;gap:.85rem;flex:1;min-width:0}.repo-meta{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.72rem;margin-left:auto}@container (max-width: 35rem){.repo-copy{flex-direction:column;align-items:flex-start;gap:.1rem}.repo-meta{margin-left:0}}.data-section .dialog-data section{height:12rem;display:flex;flex-direction:column;align-items:flex-start}.data-section .dialog-data ul{width:100%;min-height:0;max-height:none}.access-action{flex-shrink:0}
9
+ `;var zi=`.report-logo.brand-deepview{--brand-bg:#2563eb;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-claude{--brand-bg:#d97757;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-codex{--brand-bg:#fff;--brand-fg:#000;background:var(--brand-bg)}.report-logo.brand-vercel{--brand-bg:#000;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-piolium{--brand-bg:#fbb829;--brand-fg:#1c1b19;background:var(--brand-bg)}.report-logo .fg{fill:var(--brand-fg)}.report-logo .bg{fill:var(--brand-bg)}.report-logo.brand-codex .bg,.report-logo.brand-vercel .bg{stroke:var(--brand-fg);stroke-width:.5}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-weight:600;pointer-events:none}.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: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{margin-left:auto;flex-shrink:0}.report-list{overflow-x:auto;border:1px solid var(--border);border-radius:9px;background:var(--panel)}.reports{min-width:47rem;margin:0;padding:0;list-style:none}.report-list-head,.report-main{display:grid;grid-template-columns:1.5rem minmax(12rem,1fr) minmax(7rem,.6fr) 4.1rem 9rem;align-items:center;gap:.7rem;padding:.5rem .85rem}.report-list-head{min-width:47rem;min-height:2.25rem;color:var(--muted);background:rgb(from var(--text) r g b / .025);border-bottom:1px solid var(--border);font-size:.7rem}.report-heading{grid-column:1 / 3}.actions-heading{text-align:right;padding-right:.25rem}.report+.report{border-top:1px solid var(--border)}.report-main{min-height:3.4rem}.report-main:hover{background:var(--panel-hover)}.report-logo{display:grid;place-items:center;width:1.5rem;height:1.5rem;border-radius:5px;overflow:hidden}.report-logo svg{width:1.1rem;height:1.1rem}.report-copy,.report-meta{display:grid;min-width:0;gap:.15rem}.report-name{color:var(--text);font-size:.8rem;font-weight:500}.report-name,.report-location,.report-meta>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.report-location{color:var(--muted);font-size:.7rem}.report-meta{color:var(--muted);font-size:.68rem;font-variant-numeric:tabular-nums}.report-meta>span:first-child{color:var(--text);opacity:.8;font-size:.72rem}.status{display:inline-flex;align-items:center;gap:.3rem;width:fit-content;padding:.1rem .4rem;border:1px solid var(--border);border-radius:5px;color:var(--muted);font-size:.65rem}.status:before{content:"";width:.25rem;height:.25rem;border-radius:50%;background:currentcolor}.status.visible{color:var(--green);border-color:rgb(from var(--green) r g b / .2);background:rgb(from var(--green) r g b / .06)}.report-actions{display:flex;justify-content:flex-end;align-items:center;gap:.1rem}.report-actions .action,.action-spacer{display:grid;place-items:center;flex-shrink:0;width:1.7rem;height:1.8rem;padding:.3rem;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--muted)}.action svg{width:.95rem;height:.95rem}.report-actions .action:hover:not(:disabled),.report-actions .action[aria-expanded=true]{color:var(--text);background:var(--surface-active);border-color:var(--border)}.report-actions .action.danger:hover{color:var(--critical);background:rgb(from var(--critical) r g b / .08)}.preview{height:20rem;border-top:1px solid var(--border);padding:.85rem}.preview pre{height:100%;overflow:auto;margin:0;padding:.85rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);font:.75rem/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.preview-loading{color:var(--muted);font-size:.8rem}.location-editor{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,.7fr) auto;align-items:end;gap:.75rem;padding:.85rem;border-top:1px solid var(--border);background:rgb(from var(--bg) r g b / .35)}.location-field{display:grid;gap:.35rem;min-width:0}.location-field>span,.location-field label{color:var(--muted);font-size:.75rem}.location-field input{width:100%}.location-actions{display:flex;gap:.4rem}.location-actions .action{padding:.4rem .65rem;min-height:2.25rem;border:1px solid var(--border);border-radius:6px;color:var(--text);background:var(--bg);font-size:.78rem}@container (max-width: 35rem){.drop-copy>span{display:none}}
10
+ `;var Ii=`button,select{font:inherit;cursor:default}button:focus-visible,a:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.upload-copy{display:flex;align-items:center;gap:1rem}.upload-copy>span{color:var(--muted);font-size:.75rem}.upload-controls{display:flex;align-items:end;gap:.65rem}.repo-picker{width:14rem;display:grid;gap:.3rem;min-width:0}.repo-picker-label{color:var(--muted);font-size:.75rem}.repo-select,.repo-attach{min-width:0;width:100%}.repo-select{max-width:18rem}.drop-browse{height:2rem;flex-shrink:0;padding:.3rem .75rem;border:1px solid var(--accent);border-radius:5px;color:var(--bg);background:var(--accent);font-size:.75rem;font-weight:600}.drop-browse:hover:not(:disabled){filter:brightness(1.08)}.drop-browse:disabled{opacity:.5}.section-head{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:.75rem;margin-bottom:.9rem}.section-head h2{margin:0;font-size:.85rem;font-weight:600}.summary{min-height:1.5em;display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}.unassigned{color:var(--high, #d97732)}.bundles{margin:0;padding:0;list-style:none}.bundle-group-head strong{min-width:0;overflow-wrap:anywhere;font-size:.8rem;font-weight:500}.bundle-group-head span{color:var(--muted);font-size:.75rem}.bundle-row+.bundle-row{border-top:1px solid var(--border)}.bundle-icon svg{width:1rem;height:1rem}.kind{color:var(--muted);padding:.05rem .35rem;border:1px solid var(--border);border-radius:4px;font-size:.65rem}.bundle-location-label{color:var(--muted);font-size:.75rem}.action{display:grid;place-items:center;width:2rem;height:2rem;padding:.45rem;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--muted);text-decoration:none}.action svg{width:1rem;height:1rem}.action:hover{color:var(--text);border-color:var(--border);background:var(--surface)}.action.danger:hover{color:var(--critical, #e5534b)}.msg{padding:1rem 0;margin:0;color:var(--muted);font-size:.8rem}.msg.error{color:var(--critical, #e5534b)}.drop-icon svg{width:1rem;height:1rem}.bundle-group{overflow:hidden;border:1px solid var(--border);border-radius:10px;background:var(--panel);overflow-x:auto}.bundle-group-head,.bundles{min-width:43rem}.bundle-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,15rem) auto;align-items:center;gap:.85rem;padding:.55rem .85rem}.bundle-location{display:grid;gap:.18rem;min-width:0;grid-column:auto;padding-left:0}.actions{display:flex;gap:.2rem;grid-column:auto;grid-row:auto}.bundle-group-head{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.5rem .85rem;border-bottom:1px solid var(--border);background:rgb(from var(--text) r g b / .025)}.bundle-groups{display:grid;gap:.85rem}.identity{display:flex;align-items:center;min-width:0;gap:.65rem}.bundle-icon{display:grid;place-items:center;width:1.6rem;height:1.6rem;flex-shrink:0;border:0;border-radius:7px;background:transparent;color:var(--muted)}.who{display:grid;min-width:0;gap:.15rem}.filename{font-size:.8rem;font-weight:500;overflow-wrap:anywhere;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.meta{display:flex;flex-wrap:nowrap;align-items:center;gap:.3rem .6rem;color:var(--muted);font-size:.65rem;line-height:1.5;overflow:hidden;white-space:nowrap}.meta>span:last-child{overflow:hidden;text-overflow:ellipsis}.upload-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.65rem;padding:.7rem .85rem;margin-bottom:1rem;border:1px dashed color-mix(in srgb,var(--muted) 45%,var(--border));border-radius:11px;background:var(--panel)}.upload-copy strong{display:block;font-size:.8rem;font-weight:500}.upload-description{display:block;margin-top:.3rem;color:var(--muted);font-size:.75rem}.drop-icon{display:grid;place-items:center;width:1.8rem;height:1.8rem;flex-shrink:0;border:0;border-radius:8px;color:var(--muted);background:transparent}.summary>span{min-width:5.5rem}@container (max-width: 55rem){.upload-panel{grid-template-columns:1fr}.upload-controls{justify-content:space-between;padding-left:2.8rem}.repo-picker{flex:1}.repo-select{max-width:none}}@container (max-width: 30rem){.upload-controls{padding-left:0;flex-wrap:wrap}.repo-picker{flex-basis:100%}.section-head{align-items:flex-start;flex-direction:column}}.bundle-open{padding:0;border:0;background:none;color:inherit;font:inherit;text-align:left}.bundle-open:hover{color:var(--accent);text-decoration:underline}
11
+ `;var Oi=`.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:5px;color:var(--muted);background:transparent}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical, #e5534b);background:rgb(from var(--critical, #e5534b) r g b / .1)}.icon-btn svg,.btn svg{width:.9rem;height:.9rem}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:2rem;height:2rem;border-radius:50%;overflow:hidden;background:var(--surface-active);color:var(--muted);font-family:system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:.8rem;font-weight:600;user-select:none}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.create-team{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-bottom:1.75rem;padding:1.25rem;border:1px solid var(--border);border-radius:10px;background:var(--panel)}.create-team label{color:var(--muted);font-size:.78rem;margin-right:.25rem}.new-name{width:15rem}.team{border:1px solid var(--border);border-radius:11px;margin-bottom:1.5rem;background:var(--panel);overflow:hidden}.team-head{display:flex;align-items:center;gap:.85rem;min-height:4.5rem;padding:1rem 1.35rem;border-bottom:1px solid var(--border);background:rgb(from var(--text) r g b / .025)}.team-icon{display:grid;place-items:center;flex:0 0 auto;width:2.25rem;height:2.25rem;border:1px solid rgb(from var(--accent) r g b / .2);border-radius:7px;background:rgb(from var(--accent) r g b / .07);color:var(--accent)}.team-icon svg{width:1.05rem;height:1.05rem}.team-name{margin:0;min-width:0;font-size:1rem;font-weight:600;letter-spacing:-.015em;overflow-wrap:anywhere}.team-actions{display:flex;gap:.25rem;margin-left:auto}.rename-input{flex:1;max-width:22rem;width:0}.team-body{display:grid;grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr)}.sub{min-width:0;padding:1.35rem}.sub+.sub{border-left:1px solid var(--border)}.sub-title{display:flex;align-items:center;gap:.5rem;margin:0;font-size:.85rem;font-weight:600}.sub-title .count{height:1.1rem;min-width:1.1rem;font-size:.75rem;padding:0 .3rem}.sub-description{display:flex;flex-direction:column;gap:.2rem;margin:.5rem 0 1rem;color:var(--muted);font-size:.75rem;line-height:1.6}.links{list-style:none;margin:0 0 .5rem;padding:0}.links li{display:flex;align-items:center;gap:.7rem;min-height:3.5rem;padding:.75rem 0}.links li+li{border-top:1px solid var(--border)}.repo-icon{flex:0 0 auto;color:var(--muted);width:.95rem;height:.95rem}.repo-copy{display:flex;min-width:0;flex-direction:column;gap:.2rem}.ln{min-width:0;font-size:.8rem;font-weight:500;overflow-wrap:anywhere}.path{color:var(--muted);font-family:var(--mono);font-size:.75rem;overflow-wrap:anywhere}.repo-row .icon-btn{margin-left:auto}.links .member-row{display:grid;grid-template-columns:minmax(0,1fr) auto 1.8rem;gap:.45rem}.member{display:flex;align-items:center;gap:.45rem;min-width:0}.member .avatar{width:1.6rem;height:1.6rem;font-size:.75rem}.perms{display:flex;flex-wrap:wrap;gap:.3rem}.perm{display:inline-flex;align-items:center;gap:.4rem;padding:.4rem .5rem;border:1px solid var(--border);border-radius:6px;font-size:.7rem;color:var(--muted);user-select:none}.perm:has(:checked){color:var(--text);background:rgb(from var(--accent) r g b / .07);border-color:rgb(from var(--accent) r g b / .2)}.perm:has(:disabled){opacity:.5}.add-row{display:flex;align-items:center;gap:.5rem;padding-top:.85rem}.add-row select,.add-row repository-selector,.add-row user-selector{flex:1;width:0}.add-repo-path{flex:.75;width:0}.add-row .btn{flex:0 0 auto}.muted{color:var(--muted);font-size:.78rem;margin:.75rem 0}@container (max-width: 57rem){.team-body{grid-template-columns:1fr}.sub+.sub{border-left:0;border-top:1px solid var(--border)}.add-row{max-width:36rem}}@container (max-width: 32rem){.create-team{flex-wrap:wrap}.create-team label{flex-basis:100%}.new-name{flex:1;width:0}.team-head,.sub{padding-left:.75rem;padding-right:.75rem}.links .member-row{grid-template-columns:minmax(0,1fr) 1.8rem}.perms{grid-row:2;padding-left:2.05rem}.member-row>.icon-btn{grid-column:2;grid-row:1}.add-row{flex-wrap:wrap}.add-repo-sel{flex-basis:calc(100% - 4rem)!important}.add-repo-path{order:1;flex-basis:100%}}.create-copy{display:grid;gap:.2rem;margin-right:auto}.create-copy strong{font-size:.85rem;font-weight:500}.create-copy>span{color:var(--muted);font-size:.75rem}@container (max-width: 52rem){.create-copy{flex-basis:100%;margin-bottom:.35rem}.new-name{flex:1;min-width:6rem}}
12
+ `;var Ti=(r,e,t)=>{let i=new Map;for(let s=e;s<=t;s++)i.set(r[s],s);return i},at=me(class extends G{constructor(r){if(super(r),r.type!==O.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);let s=[],o=[],n=0;for(let a of r)s[n]=i?i(a,n):n,o[n]=t(a,n),n++;return{values:o,keys:s}}render(r,e,t){return this.dt(r,e,t).values}update(r,[e,t,i]){let s=Ai(r),{values:o,keys:n}=this.dt(e,t,i);if(!Array.isArray(s))return this.ut=n,o;let a=this.ut??=[],l=[],d,u,p=0,g=s.length-1,m=0,b=o.length-1;for(;p<=g&&m<=b;)if(s[p]===null)p++;else if(s[g]===null)g--;else if(a[p]===n[m])l[m]=W(s[p],o[m]),p++,m++;else if(a[g]===n[b])l[b]=W(s[g],o[b]),g--,b--;else if(a[p]===n[b])l[b]=W(s[p],o[b]),be(r,l[b+1],s[p]),p++,b--;else if(a[g]===n[m])l[m]=W(s[g],o[m]),be(r,s[p],s[g]),g--,m++;else if(d===void 0&&(d=Ti(n,m,b),u=Ti(a,p,g)),d.has(a[p]))if(d.has(a[g])){let f=u.get(n[m]),y=f!==void 0?s[f]:null;if(y===null){let $=be(r,s[p]);W($,o[m]),l[m]=$}else l[m]=W(y,o[m]),be(r,s[p],y),s[f]=null;m++}else nt(s[g]),g--;else nt(s[p]),p++;for(;m<=b;){let f=be(r,l[b+1]);W(f,o[m]),l[m++]=f}for(;p<=g;){let f=s[p++];f!==null&&nt(f)}return this.ut=n,ot(r,l),E}});var sn=new Map([["openai/gpt-6-astra","GPT-6 Astra"],["openai/gpt-6-astra-pro","GPT-6 Astra Pro"],["openai/gpt-5.6-sol","GPT-5.6 Sol"],["openai/gpt-5.6-terra","GPT-5.6 Terra"],["openai/gpt-5.6-luna","GPT-5.6 Luna"],["anthropic/claude-fable-5.1","Claude Fable 5.1"],["anthropic/claude-opus-5","Claude Opus 5"],["anthropic/claude-sonnet-5","Claude Sonnet 5"],["moonshotai/kimi-k3","Kimi K3"],["z-ai/glm-5.3","GLM 5.3"],["qwen/qwen3.8-max","Qwen3.8 Max"],["deepseek/deepseek-v4.1-flash","DeepSeek V4.1 Flash"],["deepseek/deepseek-v4-pro","DeepSeek V4 Pro"]]),on=new Map([["openai","OpenAI"],["anthropic","Anthropic"],["moonshotai","Moonshot AI"],["google","Google"],["nvidia","NVIDIA"],["qwen","Qwen"],["deepseek","DeepSeek"],["x-ai","xAI"],["z-ai","Z.ai"]]),nn=new Map([["gpt","GPT"],["gptoss","GPT OSS"],["oss","OSS"],["o","O"],["ai","AI"],["api","API"],["4o","4o"],["k3","K3"],["k4","K4"],["qwen","Qwen"],["kimi","Kimi"],["gemini","Gemini"],["claude","Claude"],["fable","Fable"],["opus","Opus"],["sonnet","Sonnet"],["astra","Astra"],["terra","Terra"],["luna","Luna"],["codex","Codex"],["deepseek","DeepSeek"],["nemotron","Nemotron"],["gemma","Gemma"]]);function Ni(r){let e=r.replace(/:free$/u,"").replaceAll("_","-").split("-").filter(Boolean),t=[];for(let s=0;s<e.length;s++){let o=e[s],n=e[s+1];if(/^\d+$/u.test(o)&&/^\d+$/u.test(n??"")){t.push(`${o}.${n}`),s++;continue}let a=nn.get(o.toLowerCase());t.push(a??(/^(?:[a-z]+\d+|\d+[a-z]+)$/iu.test(o)?o.toUpperCase():o[0]?.toUpperCase()+o.slice(1)))}return t.join(" ").replace(/^GPT (\d)/u,"GPT-$1")}function se(r){return sn.get(r)??Ni(r.includes("/")?r.slice(r.indexOf("/")+1):r)}function Te(r){let e=r.includes("/")?r.split("/")[0]:"other";return{key:e,name:on.get(e)??(e==="other"?"Other":Ni(e))}}function oe(r){return r==="xhigh"?"Extra high":r?r[0].toUpperCase()+r.slice(1):"Unavailable"}function ve(r){return r.efforts.includes("max")?"max":r.efforts.at(-1)??null}async function ye(r,e=fetch){let t=await e("/api/admin/models",{credentials:"same-origin",headers:{accept:"application/json"},signal:r});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();return an(i)}function an(r){if(!Array.isArray(r?.models))throw new Error("No model catalogue returned");let e=r.models.filter(t=>typeof t?.id=="string"&&t.id.length>0).map(t=>({id:t.id,efforts:Array.isArray(t.efforts)?[...new Set(t.efforts.filter(i=>typeof i=="string"&&i.length>0))]:[]}));if(e.length===0)throw new Error("No models available");return{models:e,defaultModel:e.find(t=>t.id===r.defaultModel)?.id??e[0].id}}function Ut(r){let e=new Map(r.map(i=>[i.id,i])),t=new Set;return r.flatMap(i=>{if(t.has(i.id))return[];let s=i.id.endsWith("-pro")?i.id.slice(0,-4):i.id,o=e.get(s),n=e.get(`${s}-pro`);return!/(?:^|\/)gpt-.+$/u.test(s)||s.endsWith("-pro")||!o||!n?[i]:(t.add(o.id),t.add(n.id),[{...o,pro:n}])})}function Ht(r){return[...Map.groupBy(Ut(r),t=>Te(t.id).key)].map(([t,i])=>({key:t,models:i}))}function Bi(r,e){if(r.length===0)return[];let t=Math.min(r.length,Math.max(1,e)),i=r.map(d=>d.models.length*2+3),s=i.reduce((d,u)=>d+u,0),o=Math.max(...i);for(;o<s;){let d=Math.floor((o+s)/2),u=0,p=1;for(let g of i)u+g>d&&(p++,u=0),u+=g;p>t?o=d+1:s=d}let n=[],a=[],l=0;for(let[d,u]of r.entries())a.length>0&&(l+i[d]>o||r.length-d===t-n.length-1)&&(n.push(a),a=[],l=0),a.push(u),l+=i[d];return n.push(a),n}var Pi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"></path></svg>`;var ji=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"></path></svg>`;var Di=c`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
13
+ <path fill="#4285F4" d="M21.35 12.27c0-.79-.07-1.55-.2-2.27H12v4.3h5.24a4.48 4.48 0 0 1-1.94 2.94v2.45h3.15c1.85-1.7 2.9-4.2 2.9-7.42Z"/>
14
+ <path fill="#34A853" d="M12 21.8c2.64 0 4.86-.87 6.48-2.35l-3.15-2.45c-.87.58-1.98.92-3.33.92-2.56 0-4.73-1.73-5.51-4.06H3.24v2.52A9.8 9.8 0 0 0 12 21.8Z"/>
15
+ <path fill="#FBBC05" d="M6.49 13.86a5.9 5.9 0 0 1 0-3.72V7.62H3.24a9.8 9.8 0 0 0 0 8.76l3.25-2.52Z"/>
16
+ <path fill="#EA4335" d="M12 6.08c1.43 0 2.72.49 3.74 1.45l2.8-2.8C16.85 3.14 14.63 2.2 12 2.2a9.8 9.8 0 0 0-8.76 5.42l3.25 2.52C7.27 7.81 9.44 6.08 12 6.08Z"/>
17
+ </svg>
18
+ `;var Ui=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815"></path></svg>`;var Ft=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"></path></svg>`;var Hi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M10.212 8.976V7.62c.127-.01.256-.017.388-.021 3.596-.117 5.957 3.184 5.957 3.184s-2.548 3.647-5.282 3.647a3.227 3.227 0 01-1.063-.175v-4.109c1.4.174 1.681.812 2.523 2.258l1.873-1.627a4.905 4.905 0 00-3.67-1.846 6.594 6.594 0 00-.729.044m0-4.476v2.025c.13-.01.259-.019.388-.024 5.002-.174 8.261 4.226 8.261 4.226s-3.743 4.69-7.643 4.69c-.338 0-.675-.031-1.007-.092v1.25c.278.038.558.057.838.057 3.629 0 6.253-1.91 8.794-4.169.421.347 2.146 1.193 2.501 1.564-2.416 2.083-8.048 3.763-11.24 3.763-.308 0-.603-.02-.894-.048V19.5H24v-15H10.21zm0 9.756v1.068c-3.356-.616-4.287-4.21-4.287-4.21a7.173 7.173 0 014.287-2.138v1.172h-.005a3.182 3.182 0 00-2.502 1.178s.615 2.276 2.507 2.931m-5.961-3.3c1.436-1.935 3.604-3.148 5.961-3.336V6.523C5.81 6.887 2 10.723 2 10.723s2.158 6.427 8.21 7.015v-1.166C5.77 16 4.25 10.958 4.25 10.958h-.002z"></path></svg>`;var Fi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"></path></svg>`;var Vi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.654 3.87a5.087 5.087 0 110 10.174L23.7 19.09c.64.641.187 1.737-.72 1.737H8.48a8.479 8.479 0 010-16.958h10.175zM8.479 7.26a5.087 5.087 0 100 10.176 5.087 5.087 0 000-10.175z"></path></svg>`;var qi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z"></path></svg>`;var Gi=c`<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.105 2L9.927 4.953H.653L2.83 2h9.276zM23.254 19.048L21.078 22h-9.242l2.174-2.952h9.244zM24 2L9.264 22H0L14.736 2H24z"></path></svg>`;var Wi={anthropic:Pi,deepseek:ji,google:Di,moonshot:Ft,moonshotai:Ft,nvidia:Hi,openai:Fi,openrouter:Vi,qwen:qi,"x-ai":Ui,"z-ai":Gi},ln=c`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="4" y="4" width="12" height="12" rx="3"/><path d="M8 1v3m4-3v3M8 16v3m4-3v3M1 8h3m-3 4h3m12-4h3m-3 4h3"/></svg>`;function Vt(r){return Object.hasOwn(Wi,r)?Wi[r]:ln}var cn=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>`,qt=class extends x{static properties={loadModels:{attribute:!1},pending:{type:Boolean},value:{attribute:!1},effort:{attribute:!1},hasExtra:{type:Boolean,attribute:"has-extra"},_models:{state:!0},_error:{state:!0},_menuColumns:{state:!0}};static styles=S`:host{display:block;min-width:0;container:scan-controls / inline-size}*{box-sizing:border-box}.layout{display:grid;grid-template-columns:minmax(13rem,1fr) minmax(14rem,1fr);gap:1.25rem;align-items:start}.layout.with-extra{grid-template-columns:minmax(13rem,.9fr) minmax(14rem,1.2fr) minmax(14rem,auto)}.field{min-width:0;min-height:4.9rem}.model-placeholder{height:3.25rem;display:flex;align-items:center;padding:.5rem .6rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--bg);font-size:.75rem}.effort-placeholder{height:.3rem;margin:1rem .6rem;border-radius:999px;background:var(--surface-active)}.label{display:flex;justify-content:space-between;align-items:center;margin-bottom:.4rem;color:var(--muted);font-size:.72rem}output{color:var(--text);font-size:.72rem;font-weight:500}details{position:relative}.model-control{position:relative}summary{display:flex;align-items:center;gap:.55rem;padding:.5rem .6rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);list-style:none;transition:border-color .12s,background .12s}summary:hover,details[open] summary{border-color:var(--muted);background:var(--surface-active)}summary::-webkit-details-marker{display:none}summary,.menu{user-select:none}summary>svg{width:.9rem;height:.9rem;margin-left:auto;color:var(--muted)}.selected-copy{display:grid;gap:.1rem;flex:1;min-width:0}.selected-copy strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8rem;font-weight:500}.selected-copy small{color:var(--muted);font-size:.63rem}.pro-space{width:3.65rem;flex:0 0 3.65rem}.pro-toggle{position:absolute;right:2.05rem;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;justify-content:center;gap:.3rem;width:3.65rem;height:1.65rem;padding:.2rem .3rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--muted);font:inherit;font-size:.65rem;font-weight:600;cursor:default;user-select:none}.pro-toggle:hover{border-color:var(--muted);color:var(--text)}.pro-track{position:relative;flex:0 0 1.3rem;height:.8rem;border-radius:999px;background:var(--border)}.pro-track:after{content:"";position:absolute;top:.15rem;left:.15rem;width:.5rem;height:.5rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.pro-toggle[aria-checked=true]{color:var(--accent);border-color:rgb(from var(--accent) r g b / .45);background:rgb(from var(--accent) r g b / .08)}.pro-toggle[aria-checked=true] .pro-track{background:rgb(from var(--accent) r g b / .25)}.pro-toggle[aria-checked=true] .pro-track:after{transform:translate(.5rem);background:var(--accent)}.icon{display:inline-grid;place-items:center;width:1.7rem;height:1.5rem;flex:0 0 1.7rem;color:var(--text)}.icon svg{display:block;width:1.12rem;height:1.12rem}.icon.openai{color:#10a37f}.icon.anthropic{color:#d97757}.icon.moonshotai{color:#8068d9}.icon.google{color:#4285f4}.icon.nvidia{color:#76b900}.icon.qwen{color:#f97316}.icon.deepseek{color:#4d8dff}.icon.moonshotai svg{transform:scale(.78)}.icon.qwen svg{transform:scale(.82)}.icon.nvidia svg{transform:scale(.86)}.icon.deepseek svg{transform:scale(.9)}.extra{display:flex;min-width:0;min-height:4.9rem;align-items:flex-end;align-self:end;padding-bottom:.05rem}.menu{visibility:hidden;position:fixed;z-index:1000;width:min(46rem,calc(100vw - 1rem));max-height:calc(100dvh - 1rem);overflow:auto;overscroll-behavior:contain;padding:.65rem;border:1px solid var(--border);border-radius:9px;background:var(--surface-active);color:var(--text);box-shadow:0 .65rem 1.8rem #0000008c}details[open] .menu[data-positioned]{visibility:visible}.groups{display:grid;grid-template-columns:repeat(var(--model-columns, 1),minmax(0,1fr));gap:1rem;align-items:start}.provider-column{min-width:0}fieldset{min-width:0;margin:0 0 .6rem;padding:0;border:0}fieldset:last-child{margin-bottom:0}legend{display:flex;align-items:center;gap:.45rem;width:100%;min-height:1.9rem;padding:.35rem .5rem .25rem;border-bottom:1px solid rgb(from var(--border) r g b / .7);color:var(--muted);font-size:.64rem;font-weight:700;letter-spacing:.055em;text-transform:uppercase}legend .icon{width:.88rem;height:1.25rem;flex-basis:.88rem}legend .icon svg{width:.88rem;height:.88rem}.choice{display:flex;align-items:center;gap:.5rem;padding:.35rem .5rem;border-radius:4px;font-size:.76rem}.choice:hover{background:rgb(from var(--text) r g b / .05)}.choice:has(:checked){color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.choice input{margin:0;accent-color:var(--accent)}.choice span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.slider{--thumb-size: 1rem;padding:.15rem .6rem 0}input[type=range]{appearance:none;display:block;width:100%;height:var(--thumb-size);margin:.4rem 0 .5rem;padding:0;border:0;background:transparent}input[type=range]::-webkit-slider-runnable-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-moz-range-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-webkit-slider-thumb{appearance:none;width:var(--thumb-size);height:var(--thumb-size);margin-top:calc((.3rem - var(--thumb-size)) / 2);border:0;border-radius:50%;background:var(--accent)}input[type=range]::-moz-range-thumb{width:var(--thumb-size);height:var(--thumb-size);border:0;border-radius:50%;background:var(--accent)}input[type=range]:disabled{opacity:.5}.steps{position:relative;height:1.3rem;margin:0 calc(var(--thumb-size) / 2)}.step{position:absolute;top:0;left:var(--step-position);transform:translate(-50%);padding:.35rem 0 0;border:0;background:transparent;color:var(--muted);font:inherit;font-size:.62rem;white-space:nowrap;cursor:default}.step:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);width:1px;height:.2rem;background:var(--muted)}.step.active{color:var(--accent)}:is(summary,input,button):focus-visible{outline:2px solid var(--accent);outline-offset:2px}.message{margin:0;color:var(--muted);font-size:.75rem}.error{color:var(--critical, #e5534b)}.retry{margin-left:.5rem;padding:.2rem .4rem;border:1px solid var(--border);border-radius:4px;background:var(--bg);color:var(--text);font:inherit}@container scan-controls (max-width: 50rem){.layout.with-extra{grid-template-columns:minmax(13rem,1fr) minmax(14rem,1fr)}.layout.with-extra .extra{grid-column:1 / -1;align-self:start;min-height:0}}@container scan-controls (max-width: 30rem){.layout,.layout.with-extra{grid-template-columns:minmax(0,1fr);gap:1rem}.layout.with-extra .extra{grid-column:auto}}`;constructor(){super(),this.loadModels=ye,this.pending=!1,this.value=null,this.effort=null,this.hasExtra=!1,this._models=[],this._error=null,this._menuColumns=1,this._positionRequest=0,this._onOutside=e=>{e.composedPath().includes(this)||this._close()},this._onViewportChange=()=>this._positionMenu()}connectedCallback(){super.connectedCallback(),document.addEventListener("pointerdown",this._onOutside),window.addEventListener("resize",this._onViewportChange),window.addEventListener("scroll",this._onViewportChange,!0),this.hasUpdated&&this._load()}updated(e){(e.has("loadModels")||e.has("pending"))&&this.isConnected&&this._load(),e.has("_models")&&this.renderRoot.querySelector("details")?.open&&(this._resetMenuPosition(),this._positionMenu())}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort(),document.removeEventListener("pointerdown",this._onOutside),window.removeEventListener("resize",this._onViewportChange),window.removeEventListener("scroll",this._onViewportChange,!0)}async _load(){if(this._controller?.abort(),this.pending)return;let e=new AbortController;this._controller=e,this._error=null;let t=!1,i=s=>{if(e.signal.aborted)return;t=!0,this._models=s.models;let o=s.models.find(n=>n.id===this.value);o?o.efforts.includes(this.effort)||this._setEffort(ve(o)):this._select(s.defaultModel)};try{i(await this.loadModels(e.signal,i))}catch(s){!e.signal.aborted&&!t&&(this._error=String(s?.message??s))}}_close(){this._resetMenuPosition();let e=this.renderRoot.querySelector("details");e&&(e.open=!1)}_resetMenuPosition(){this._positionRequest++;let e=this.renderRoot.querySelector(".menu");e&&delete e.dataset.positioned}_toggleMenu(e){this._resetMenuPosition(),e.currentTarget.open&&this._positionMenu()}get _selectedRow(){return Ut(this._models).find(e=>e.id===this.value||e.pro?.id===this.value)}async _positionMenu(){let e=++this._positionRequest,t=this.renderRoot.querySelector("details"),i=this.renderRoot.querySelector("summary"),s=this.renderRoot.querySelector(".menu");if(!t?.open||!i||!s)return;let o=i.getBoundingClientRect(),n=6,a=8,l=Ht(this._models),d=l.reduce((V,Ke)=>V+Ke.models.length,0),u=Math.min(3,l.length,Math.ceil((d+l.length*1.5)/9)),p=parseFloat(getComputedStyle(s).fontSize),g=0;for(let V of s.querySelectorAll(".choice span, legend")){let Ke=document.createRange();Ke.selectNodeContents(V),g=Math.max(g,Ke.getBoundingClientRect().width)}let m=Math.max(11*p,Math.min(18*p,g+2.5*p)),b=1.3*p+2,f=Math.max(1,Math.min(u,Math.floor((window.innerWidth-a*2-b+p)/(m+p)))),y=Math.min(f*m+(f-1)*p+b,window.innerWidth-a*2),$=Math.max(a,Math.min(o.left,window.innerWidth-y-a));if(this._menuColumns=f,await this.updateComplete,e!==this._positionRequest||!this.isConnected||!t.open)return;s.style.left=`${$}px`,s.style.width=`${y}px`,s.style.setProperty("--model-columns",f),s.style.maxHeight=`${Math.max(0,window.innerHeight-a*2)}px`;let _=s.getBoundingClientRect().height,T=window.innerHeight-o.bottom-n-a,Ge=o.top-n-a,We=T<_&&Ge>T?o.top-n-_:o.bottom+n;s.style.bottom="auto",s.style.top=`${Math.max(a,Math.min(We,window.innerHeight-_-a))}px`,s.dataset.positioned=""}_select(e,{preserveEffort:t=!1,close:i=!0}={}){let s=this._models.find(o=>o.id===e);s&&(this.value=e,this._setEffort(t&&s.efforts.includes(this.effort)?this.effort:ve(s)),i&&this._close())}_selectRow(e){let t=this._selectedRow?.pro?.id===this.value;this._select(t&&e.pro?e.pro.id:e.id)}_togglePro(){let e=this._selectedRow;e?.pro&&this._select(this.value===e.pro.id?e.id:e.pro.id,{preserveEffort:!0,close:!1})}_setEffort(e){this.effort=e,this.dispatchEvent(new CustomEvent("model-change",{detail:{model:this.value,effort:e},bubbles:!0,composed:!0}))}render(){let e=this._models.find(o=>o.id===this.value);if(this.pending||!e)return c`<div class="${`layout ${this.hasExtra?"with-extra":""}`}" aria-busy="true"><div class="field"><span class="label">Model</span><div class="model-placeholder" role="${this._error?"alert":"status"}">${this._error?c`Couldn’t load models. <button type="button" class="retry" @click="${()=>{this._load()}}">Retry</button>`:"Loading models\u2026"}</div></div><div class="field" aria-hidden="true"><span class="label">Effort</span><div class="effort-placeholder"></div></div>${this.hasExtra?c`<div class="extra"><slot name="effort-extra"></slot></div>`:h}</div>`;let t=this._selectedRow,i=Te(e.id),s=Bi(Ht(this._models),this._menuColumns);return c`${this._error?c`<p class="message error" role="alert">Couldn’t refresh models: ${this._error}<button class="retry" @click="${()=>{this._load()}}">Retry</button></p>`:h}<div class="${`layout ${this.hasExtra?"with-extra":""}`}"><div class="field"><span class="label" id="model-label">Model</span><div class="model-control"><details @toggle="${this._toggleMenu}" @keydown="${o=>{o.key==="Escape"&&(this._close(),this.renderRoot.querySelector("summary")?.focus())}}"><summary aria-labelledby="model-label selected-model" @click="${this._resetMenuPosition}"><span class="${`icon ${i.key}`}" aria-hidden="true">${Vt(i.key)}</span><span class="selected-copy"><strong id="selected-model">${se(t.id)}</strong><small>${i.name}</small></span>${t.pro?c`<span class="pro-space" aria-hidden="true"></span>`:h}${cn}</summary><div class="menu"><div class="groups">${s.map(o=>c`<div class="provider-column">${o.map(n=>this._modelSection(n))}</div>`)}</div></div></details>${t.pro?c`<button type="button" class="pro-toggle" role="switch" aria-label="Pro model" aria-checked="${e.id===t.pro.id}" @click="${this._togglePro}"><span>Pro</span><span class="pro-track" aria-hidden="true"></span></button>`:h}</div></div>${e.efforts.length>0?this._effortSlider(e.efforts):c`<div class="field" aria-hidden="true"></div>`} ${this.hasExtra?c`<div class="extra"><slot name="effort-extra"></slot></div>`:h}</div>`}_modelSection({key:e,models:t}){return c`<fieldset><legend><span class="${`icon ${e}`}" aria-hidden="true">${Vt(e)}</span>${Te(t[0].id).name}</legend>${t.map(i=>c`<label class="choice"><input type="radio" name="scan-model" value="${i.id}" .checked="${i.id===this.value||i.pro?.id===this.value}" @change="${()=>{this._selectRow(i),this.renderRoot.querySelector("summary")?.focus()}}"><span>${se(i.id)}</span></label>`)}</fieldset>`}_effortSlider(e){let t=Math.max(0,e.indexOf(this.effort)),i=Math.max(1,e.length-1);return c`<div class="field"><div class="label"><label for="effort">Effort</label><output for="effort">${oe(e[t])}</output></div><div class="slider" style="${`--effort-fill: calc(var(--thumb-size) / 2 + (100% - var(--thumb-size)) * ${t/i})`}"><input id="effort" type="range" min="0" max="${i}" step="1" .value="${String(t)}" ?disabled="${e.length===1}" aria-valuetext="${oe(e[t])}" @input="${s=>this._setEffort(e[Number(s.target.value)])}"><div class="steps">${e.map((s,o)=>c`<button type="button" class="${`step ${s===this.effort?"active":""}`}" style="${`--step-position: ${o/i*100}%`}" aria-label="${`Set effort to ${oe(s)}`}" aria-pressed="${s===this.effort}" @click="${()=>this._setEffort(s)}">${oe(s)}</button>`)}</div></div></div>`}};customElements.get("scan-model-picker")||customElements.define("scan-model-picker",qt);function dn(r){if(/^https?:\/\//iu.test(r)){try{let t=new URL(r),i=t.pathname.split("/").filter(Boolean);if(i.length>=2)return{owner:`${t.host}/${i[0]}`,name:i.slice(1).join("/")}}catch{}return{owner:null,name:r}}let e=/^([^\s/:]+)\/(.+)$/u.exec(r);return e?{owner:e[1],name:e[2]}:{owner:null,name:r}}var Ki=r=>r.normalize("NFKC").toLocaleLowerCase(),Gt=(r,e)=>r.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"}),Wt=Symbol("other repositories");function Ji(r,e="",t=null){let i=r.map(f=>({...f,...f.special?{owner:null,name:f.label}:dn(f.label)})),s=new Map;for(let f of i)f.owner!=null&&s.set(f.owner,(s.get(f.owner)??0)+1);let o=[...s].filter(([,f])=>f>1).toSorted(([f],[y])=>Gt(f,y)).map(([f,y])=>({value:f,name:f,count:y})),n=f=>(s.get(f.owner)??0)<=1,a=i.filter(f=>!f.special&&!f.reset&&n(f)).length;a>0&&o.push({value:Wt,name:"Other",count:a});let l=o.some(f=>f.value===t)?t:null,d=Ki(e.trim()).split(/\s+/u).filter(Boolean),u=f=>d.every(y=>Ki(f.label).includes(y)),p=i.filter(f=>f.reset||f.special&&u(f)),g=i.filter(f=>!f.reset&&!f.special&&u(f)&&(l==null||(l===Wt?n(f):f.owner===l))),m=new Map;for(let f of g){let y=(s.get(f.owner)??0)>1?f.owner:null;m.has(y)||m.set(y,[]),m.get(y).push(f)}let b=[...m].toSorted(([f],[y])=>f==null?1:y==null?-1:Gt(f,y)).map(([f,y])=>({label:f??(o.some($=>$.value!==Wt)?"Other":null),organization:f!=null,options:y.toSorted(($,_)=>Gt($.label,_.label))}));return{facets:o,activeFacet:l,pinned:p,sections:b,count:g.length+p.filter(f=>!f.reset).length,total:i.filter(f=>!f.reset).length,showFacets:o.length>1}}var Kt=class extends C{constructor(){super(),this.label="Choose repository",this.placeholder="Choose repository"}get searchLabel(){return"Search repositories"}get optionsLabel(){return"Repositories"}get facetLabel(){return"Filter by organization"}get allFacetsLabel(){return"All organizations"}get noMatchesLabel(){return"No matching repositories"}get emptyLabel(){return"No repositories available"}get changeEvent(){return"repository-change"}choices(){return Ji(this.options,this._query,this._facet)}};customElements.get("repository-selector")||customElements.define("repository-selector",Kt);function B(r){return!Number.isFinite(r)||r<0?"\u2014":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KiB`:r<1073741824?`${(r/1048576).toFixed(1)} MiB`:`${(r/1073741824).toFixed(1)} GiB`}function Ne(r){return Array.isArray(r)?r.reduce((e,t)=>({bytes:e.bytes!=null&&Number.isFinite(t.bytes)?e.bytes+t.bytes:null,lines:e.lines!=null&&Number.isFinite(t.lines)?e.lines+t.lines:null}),{bytes:0,lines:0}):{bytes:null,lines:null}}function Jt(r){return(r??[]).filter(e=>!["resource:base64","directory"].includes(e.format))}function pn(r){return r.map(e=>{let t=["sourcemap","sourcemaps"].includes(e.kind)||e.filename.toLowerCase().endsWith(".map")?"sourcemap":"stasis",i=t==="sourcemap"?"Sourcemap":"Stasis",s=[];if(typeof e.size=="string"&&!["","\u2014"].includes(e.size)&&s.push(e.size),e.files){s.push(`${e.files.length.toLocaleString()} files`);let{lines:o}=Ne(e.files);o!=null&&s.push(`${o.toLocaleString()} LoC`)}return{value:e.id,label:e.filename,detail:i,format:t,secondary:s.join(" \xB7 ")}})}var Zt=class extends C{static properties={bundles:{attribute:!1}};static styles=[C.styles,S`.bundle-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 1.05rem;width:1.05rem;height:1.05rem;color:var(--muted)}.bundle-icon img,.bundle-icon svg{display:block;width:100%;height:100%;opacity:1}.option{gap:.5rem;padding-block:.25rem}.option-copy{gap:0}.option .name{line-height:1.3}.option .bundle-icon{flex-basis:1.35rem;width:1.35rem;height:1.35rem;margin-right:.15rem}.secondary{line-height:1.25;font-variant-numeric:tabular-nums}`];constructor(){super(),this.bundles=[],this.label="Choose bundle",this.placeholder="Choose bundle"}get searchLabel(){return"Search bundles"}get optionsLabel(){return"Bundles"}get noMatchesLabel(){return"No matching bundles"}get emptyLabel(){return"No stored bundles"}get changeEvent(){return"bundle-change"}willUpdate(e){e.has("bundles")&&(this.options=pn(this.bundles))}optionIcon(e){return c`<span class="bundle-icon" aria-hidden="true">${e.format==="sourcemap"?A(fe):c`<img src="./stasis.svg" alt="">`}</span>`}optionTitle(e){return h}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>`${i.label} ${i.detail}`.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("bundle-selector")||customElements.define("bundle-selector",Zt);var Yt=class extends C{constructor(){super(),this.label="Choose workspace",this.placeholder="Choose workspace"}get searchLabel(){return"Search workspaces"}get optionsLabel(){return"Workspaces"}get noMatchesLabel(){return"No matching workspaces"}get emptyLabel(){return"No workspaces available"}get changeEvent(){return"workspace-change"}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>i.label.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("workspace-selector")||customElements.define("workspace-selector",Yt);var Be=r=>({kind:r,sourceId:null,ids:new Set}),Xt=class extends x{static properties={mode:{type:String},loadSources:{attribute:!1},restore:{attribute:!1},_sources:{state:!0},_loading:{state:!0},_error:{state:!0},_merge:{state:!0},_link:{state:!0}};constructor(){super(),this.mode="link",this._sources=null,this._loading=!1,this._error=null,this._merge=Be("bundle"),this._link=Be("repository")}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadSources")){this._load();return}e.has("mode")&&this._selectOnlySource(),e.has("restore")&&this._restore(),["_sources","_merge","_link","mode","restore"].some(t=>e.has(t))&&this._notify()}get _current(){return this.mode==="merge"?this._merge:this._link}get _parents(){if(this.mode==="merge")return this._sources?.merge?.bundles??[];let e=this._sources?.link?.reports??[];return this._current.kind==="workspace"?(this._sources?.link?.workspaces??[]).filter(t=>e.some(i=>t.reports.includes(i.id))):(this._sources?.link?.repositories??[]).filter(t=>e.some(i=>i.repoIds.includes(t.id)))}get _parent(){return this._parents.find(e=>e.id===this._current.sourceId)}get _scopeOptions(){let e=this._sources?.link?.reports??[];return this._parents.map(t=>{let i=e.filter(s=>this._current.kind==="workspace"?t.reports.includes(s.id):s.repoIds.includes(t.id)).length;return{value:t.id,label:t.label,detail:`${i} ${i===1?"report":"reports"}`}})}get _inputs(){return this._parent?this.mode==="merge"?(this._sources?.merge?.results??[]).filter(e=>e.bundleId===this._parent.id):(this._sources?.link?.reports??[]).filter(e=>this._current.kind==="workspace"?this._parent.reports.includes(e.id):e.repoIds.includes(this._parent.id)):[]}get selection(){let e=this._parent;return{mode:this.mode,source:e?{kind:this._current.kind,id:e.id,label:e.label??e.filename}:null,inputs:this._loading||this._error?[]:this._inputs.filter(t=>this._current.ids.has(t.id))}}_notify(){this.dispatchEvent(new CustomEvent("report-inputs-change",{detail:this.selection,bubbles:!0,composed:!0}))}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();let t=!1,i=s=>{if(e.signal.aborted)return;let o=!t;t=!0,this._sources=s,o&&(this._merge=Be("bundle"),this._link=Be(Array.isArray(s.link?.workspaces)?"workspace":"repository")),this._selectOnlySource(),o&&this._restore(),this._loading=!1,this._notify()};try{i(this.loadSources?await this.loadSources(e.signal,i):{merge:{bundles:[],results:[]},link:{repositories:[],reports:[]}})}catch(s){!e.signal.aborted&&!t&&(this._error=String(s?.message??s))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_setCurrent(e){this.mode==="merge"?this._merge=e:this._link=e}_selectSource(e){e===this._current.sourceId||!this._parents.some(t=>t.id===e)||(this._setCurrent({...this._current,sourceId:e,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.map(t=>t.id))}),this._notify())}_changeKind(e){["workspace","repository"].includes(e)&&(e==="workspace"&&!Array.isArray(this._sources?.link?.workspaces)||(e!==this._link.kind&&(this._link=Be(e)),this._selectOnlySource(),this._notify()))}_selectOnlySource(){this.mode==="link"&&this._current.sourceId==null&&this._parents.length===1&&this._selectSource(this._parents[0].id)}_toggle(e,t){if(!this._inputs.some(s=>s.id===e))return;let i=new Set(this._current.ids);t?i.add(e):i.delete(e),this._setCurrent({...this._current,ids:i}),this._notify()}_selectAll(e){this._setCurrent({...this._current,ids:new Set(e?this._inputs.map(t=>t.id):[])}),this._notify()}_restore(){let e=this.restore;if(!this._sources||e?.mode!==this.mode||!e.source)return;let t=this.mode==="merge"?"bundle":e.source.kind;this.mode==="link"&&(t==="workspace"?!Array.isArray(this._sources.link?.workspaces):t!=="repository")||(this._setCurrent({kind:t,sourceId:e.source.id,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(i=>e.inputIds.includes(i.id)).map(i=>i.id))}))}render(){let e=this.mode==="merge",t=this._inputs,i=t.filter(n=>this._current.ids.has(n.id)).length,s=Array.isArray(this._sources?.link?.workspaces),o=this._parent?e?"No scan results for this bundle.":`No saved reports in this ${this._current.kind}.`:e?"Choose a bundle to see its scan results.":this._parents.length===0?"No saved reports with app findings.":`Choose a ${this._current.kind} to see its saved reports.`;return c`<section class="panel" aria-label="${e?"Merge scan results":"Link saved reports"}" aria-busy="${this._loading}"><div class="source">${!e&&s?c`<div class="kinds" role="radiogroup" aria-label="Report source">${[["workspace","Workspace"],["repository","Repository"]].map(([n,a])=>c`<button type="button" role="radio" aria-checked="${n===this._link.kind}" @click="${()=>this._changeKind(n)}">${a}</button>`)}</div>`:h}<div class="field">${e?c`<span>Bundle with scan results</span>`:h} ${e?c`<bundle-selector .bundles="${this._parents}" .value="${this._current.sourceId}" ?disabled="${this._loading||this._parents.length===0}" @bundle-change="${n=>this._selectSource(n.detail.value)}"></bundle-selector>`:this._current.kind==="workspace"?c`<workspace-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @workspace-change="${n=>this._selectSource(n.detail.value)}"></workspace-selector>`:c`<repository-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @repository-change="${n=>this._selectSource(n.detail.value)}"></repository-selector>`}</div></div><div class="input-results">${this._error?c`<p class="empty" role="alert">Couldn’t load report inputs: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:this._loading&&this._sources==null?c`<p class="empty" role="status">Loading report inputs…</p>`:t.length>0?c`<div class="list-head"><label><input type="checkbox" aria-label="Select all" ?disabled="${this._loading}" .checked="${i===t.length}" .indeterminate="${i>0&&i<t.length}" @change="${n=>this._selectAll(n.target.checked)}"><strong>All</strong></label><span>${i} of ${t.length} selected</span></div><div class="list">${t.map(n=>this._row(n))}</div>`:c`<p class="empty">${e&&this._parents.length===0?"No scan results available.":o}</p>`}</div></section>`}_row(e){let t=this.mode==="link"?e.appFindings:e.findings,i=[e.model?se(e.model):null,t==null?null:`${t} ${this.mode==="link"?"app ":""}${t===1?"finding":"findings"}`,e.createdAt,e.repo?`${e.repo}${e.directory?`/${e.directory}`:""}`:null].filter(Boolean);return c`<label class="option"><input type="checkbox" ?disabled="${this._loading}" .checked="${this._current.ids.has(e.id)}" @change="${s=>this._toggle(e.id,s.target.checked)}">${A(Bt[e.analyzer]??Bt.default)}<span class="copy"><strong>${e.title??e.filename}</strong><span>${i.join(" \xB7 ")}</span></span></label>`}static styles=S`:host{display:block;min-width:0}*{box-sizing:border-box}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.source{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding:.85rem .9rem;border-bottom:1px solid var(--border)}.field{display:grid;flex:1 1 14rem;gap:.3rem;max-width:32rem;min-width:0}.field>span{color:var(--muted);font-size:.72rem}button{padding:.3rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}.kinds{display:flex;width:fit-content;border:1px solid var(--border);border-radius:5px;overflow:hidden}.kinds button{padding-block:.5rem;border:0;border-radius:0;color:var(--muted)}.kinds button+button{border-left:1px solid var(--border)}.kinds button[aria-checked=true]{color:var(--text);background:var(--surface-active)}.list-head{flex-shrink:0;display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.55rem .9rem;border-bottom:1px solid var(--border)}.list-head label{display:flex;align-items:center;gap:.55rem;user-select:none}.list-head strong{color:var(--text);font-size:.74rem;font-weight:600}.list-head>span{color:var(--muted);font-size:.68rem}.input-results{height:16rem;display:flex;flex-direction:column;overflow:auto}.list{min-height:0;overflow:auto;overscroll-behavior:none}.option{display:flex;align-items:center;gap:.55rem;min-width:0;padding:.35rem .9rem;user-select:none}.option+.option{border-top:1px solid var(--border)}.option:hover{background:var(--surface-active)}input{width:.85rem;height:.85rem;margin:0;flex:0 0 auto;accent-color:var(--accent)}.file-icon{width:1.4rem;height:1.4rem;flex:0 0 auto}.copy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex:1;min-width:0}.copy strong,.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy strong{flex:1;color:var(--text);font-size:.74rem;font-weight:500}.copy span{max-width:55%;color:var(--muted);font-size:.66rem}.empty{margin:0;padding:1rem .9rem;color:var(--muted);font-size:.76rem}button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}`};customElements.get("scan-report-inputs")||customElements.define("scan-report-inputs",Xt);var un=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h7M6 8h7M6 12h7M3 4h.01M3 8h.01M3 12h.01"/></svg>`,hn=c`<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3M7 5v4M5 7h4"/></svg>`,Qt=class extends x{static properties={isolate:{type:Boolean},vertical:{type:Boolean,reflect:!0}};constructor(){super(),this.isolate=!1,this.vertical=!1}_select(e){this.isolate!==e&&(this.isolate=e,this.dispatchEvent(new CustomEvent("depth-change",{detail:{isolate:e},bubbles:!0,composed:!0})))}render(){return c`<div class="scan-depth"><div class="depth-options" role="radiogroup" aria-label="Scan depth" aria-orientation="${this.vertical?"vertical":"horizontal"}" aria-describedby="${this.vertical?h:"scan-depth-description"}">${[[!1,"List",un],[!0,"Isolate",hn]].map(([e,t,i])=>c`<label class="depth-choice"><input type="radio" name="scan-depth" value="${e?"isolate":"list"}" .checked="${this.isolate===e}" @change="${()=>this._select(e)}"><span>${i}${t}</span></label>`)}</div>${this.vertical?h:c`<div class="depth-description" id="scan-depth-description" aria-live="polite"><span class="${this.isolate?"inactive":""}" aria-hidden="${this.isolate}">Regular scan depth</span><span class="${this.isolate?"":"inactive"}" aria-hidden="${!this.isolate}">Deeper search at ~10x the tokens spent</span></div>`}</div>`}static styles=S`:host{display:block;width:19rem;max-width:100%;min-width:0}*{box-sizing:border-box}.scan-depth{display:grid;gap:.4rem;width:100%;min-width:0;user-select:none}.depth-options{display:flex;position:relative;padding:.2rem;border:1px solid var(--border);border-radius:8px;background:var(--bg)}.depth-options:before{content:"";position:absolute;inset:.2rem auto .2rem .2rem;width:calc((100% - .4rem)/2);border-radius:5px;background:var(--surface-active);box-shadow:0 1px 3px #0000001f,inset 0 0 0 1px rgb(from var(--accent) r g b / .18);transition:transform .16s ease-out}.depth-options:has(input[value=isolate]:checked):before{transform:translate(100%)}.depth-choice{position:relative;flex:1;min-width:0}.depth-choice input{position:absolute;width:1px;height:1px;opacity:0}.depth-choice span{display:flex;align-items:center;justify-content:center;gap:.4rem;height:1.9rem;padding:.3rem .65rem;border-radius:5px;color:var(--muted);font-size:.76rem;font-weight:500;transition:color .12s}.depth-choice svg{width:.95rem;height:.95rem;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.depth-choice:hover span{color:var(--text)}.depth-choice input:checked+span{color:var(--accent)}.depth-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.depth-description{display:grid;color:var(--muted);font-size:.68rem;line-height:1.4}.depth-description span{grid-area:1 / 1}.depth-description .inactive{visibility:hidden}@media(prefers-reduced-motion:reduce){.depth-options:before,.depth-choice span{transition:none}}:host([vertical]){width:5.8rem}:host([vertical]) .depth-options{flex-direction:column}:host([vertical]) .depth-options:before{inset:.2rem .2rem auto;width:auto;height:calc((100% - .4rem)/2)}:host([vertical]) .depth-options:has(input[value=isolate]:checked):before{transform:translateY(100%)}:host([vertical]) .depth-choice span{justify-content:flex-start;height:1.7rem;padding:.25rem .5rem;font-size:.72rem}`};customElements.get("scan-depth-toggle")||customElements.define("scan-depth-toggle",Qt);var er=["security","generic","correctness"],mn=r=>JSON.stringify([r.mode,r.model,r.effort,r.isolate]);function Zi(r){let e=r[0];return e?.model&&r.every(t=>t.model===e.model&&t.effort===e.effort)?{model:e.model,effort:e.effort}:null}function Yi(r,e){let t=e.models.find(i=>i.id===r?.model)??e.models.find(i=>i.id===e.defaultModel)??e.models[0];return t?{model:t.id,effort:t.efforts.includes(r?.effort)?r.effort:ve(t)}:null}function tr(r,e){let t=e.models.find(i=>i.id===e.defaultModel)??e.models[0];return t?(r.length>0?r:[{mode:"generic",isolate:!1}]).map(i=>{let s=e.models.find(o=>o.id===i.model)??t;return{...i,mode:er.includes(i.mode)?i.mode:"generic",model:s.id,effort:s.efforts.includes(i.effort)?i.effort:ve(s),isolate:!!i.isolate}}):[]}function rr(r){let e=new Set;return r.map(t=>{let i=mn(t),s=e.has(i);return e.add(i),s})}var ir=class extends x{static properties={value:{attribute:!1},loadModels:{attribute:!1},appModel:{attribute:!1},appModelAutomatic:{attribute:!1},_rows:{state:!0},_loading:{state:!0},_error:{state:!0},_resolvedAppModel:{state:!0},_appModelOpen:{state:!0}};constructor(){super(),this.value=[],this.appModel=null,this.appModelAutomatic=!0,this._resolvedAppModel=null,this._appModelOpen=!1,this._appModelsAgree=!0,this._rows=[],this._catalogue={models:[]},this._nextId=0,this._loading=!0,this._error=null}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadModels")){this._load();return}e.has("value")&&this.value!==this._lastEmitted&&!this._loading?(this._setRows(this.value),this._notify()):(e.has("appModel")||e.has("appModelAutomatic"))&&!this._loading&&this._notify()}_setRows(e){this._rows=tr(e,this._catalogue).map(t=>({...t,id:t.id??++this._nextId}))}_notify(){let e=this._loading&&this._rows.length===0?this.value:this._rows.map(({id:i,...s})=>s);this._loading||this._syncAppModel();let t=!this._loading&&!this._error&&this._resolvedAppModel!=null&&e.length>0&&!rr(e).includes(!0);this._lastEmitted=e,this.dispatchEvent(new CustomEvent("regimes-change",{detail:{value:e,ready:t,appModel:this._resolvedAppModel??this.appModel,appModelAutomatic:this.appModelAutomatic},bubbles:!0,composed:!0}))}_syncAppModel(){let e=Zi(this._rows),t=Yi((this.appModelAutomatic?e:null)??this.appModel??this._rows[0],this._catalogue);(this.appModel?.model!==t?.model||this.appModel?.effort!==t?.effort)&&(this.appModel=t),this._resolvedAppModel=this.appModel;let i=!!e&&e.model===t?.model&&e.effort===t?.effort;i!==this._appModelsAgree&&(this._appModelOpen=!i),this._appModelsAgree=i}_changeAppModel(e){e.model===this._resolvedAppModel?.model&&e.effort===this._resolvedAppModel?.effort||(this.appModelAutomatic=!1,this.appModel={model:e.model,effort:e.effort},this._notify())}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();let t=!1,i=s=>{e.signal.aborted||(t=!0,this._catalogue=s,this._sharedModels=()=>Promise.resolve(s),this._setRows(this._rows.length>0?this._rows:this.value),this._loading=!1,this._notify())};try{i(await this.loadModels(e.signal,i))}catch(s){!e.signal.aborted&&!t&&(this._error=String(s?.message??s))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_change(e,t){let i=this._rows.find(o=>o.id===e);if(!i)return;let s=tr([{...i,...t}],this._catalogue)[0];s&&(this._rows=this._rows.map(o=>o.id===e?s:o),this._notify())}_add(){let e=this._rows.at(-1);e&&(this._rows=[...this._rows,{...e,id:++this._nextId}],this._notify())}_remove(e){this._rows.length<=1||(this._rows=this._rows.filter(t=>t.id!==e),this._notify())}render(){let e=this._loading&&this._rows.length===0,t=e?(this.value.length>0?this.value:[{mode:"generic",isolate:!1}]).map((s,o)=>({...s,id:`pending-${o}`})):this._rows,i=rr(this._rows);return c`<section aria-label="Scan regimes" aria-busy="${this._loading}"><div class="heading"><h2>Scan regimes</h2><span>${t.length} ${t.length===1?"regime":"regimes"}</span></div>${this._error?c`<p class="message" role="alert">Couldn’t load models: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:h} ${at(t,s=>s.id,(s,o)=>this._row(s,o,i[o],e))}<div class="footer"><button type="button" class="add" ?disabled="${this._loading||this._rows.length===0}" @click="${this._add}"><span aria-hidden="true">+</span> Add regime</button><span class="message" role="status">${i.includes(!0)?"Change or remove duplicate regimes to run the scan":"Results from these regimes will be merged"}</span></div>${e?c`<div class="app-model"><div class="app-model-placeholder">App model: Loading…</div></div>`:this._appModelRow()}</section>`}_appModelRow(){let e=this._resolvedAppModel;return e?c`<details class="app-model" .open="${R(this._appModelOpen)}" @toggle="${t=>{this._appModelOpen=t.currentTarget.open}}"><summary><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg><span class="app-model-name">App model: <strong>${se(e.model)}</strong></span><span class="app-model-effort">Effort: <strong>${oe(e.effort)}</strong></span></summary><div class="app-model-controls"><scan-model-picker .loadModels="${this._sharedModels}" .value="${R(e.model)}" .effort="${R(e.effort)}" @model-change="${t=>{t.stopPropagation(),this._changeAppModel(t.detail)}}"></scan-model-picker></div></details>`:h}_row(e,t,i,s=!1){return c`<div class="${`row${i?" duplicate":""}`}" ?inert="${s}" role="group" aria-label="${`Regime ${t+1}`}" aria-describedby="${i?`duplicate-${e.id}`:h}"><div class="mode" role="radiogroup" aria-label="Scan mode">${er.map(o=>c`<label class="mode-choice"><input type="radio" name="${`regime-mode-${e.id}`}" .checked="${e.mode===o}" @change="${()=>this._change(e.id,{mode:o})}"><span>${o[0].toUpperCase()+o.slice(1)}</span></label>`)}</div><scan-model-picker .pending="${s}" .loadModels="${this._sharedModels}" .value="${R(e.model)}" .effort="${R(e.effort)}" @model-change="${o=>{o.stopPropagation(),this._change(e.id,o.detail)}}"></scan-model-picker><div class="row-actions"><scan-depth-toggle vertical .isolate="${e.isolate}" @depth-change="${o=>{o.stopPropagation(),this._change(e.id,{isolate:o.detail.isolate})}}"></scan-depth-toggle>${i?c`<span class="duplicate-label" id="${`duplicate-${e.id}`}">Duplicate regime</span>`:h}</div><button type="button" class="remove" aria-label="${`Remove regime ${t+1}`}" ?disabled="${this._rows.length===1}" @click="${()=>this._remove(e.id)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button></div>`}static styles=S`:host{display:block;min-width:0;container:regime-editor / inline-size}*{box-sizing:border-box}.heading{display:flex;align-items:baseline;gap:.65rem;margin-bottom:.75rem}h2{margin:0;color:var(--text);font-size:.85rem;font-weight:600}.heading>span{color:var(--muted);font-size:.7rem}.row{position:relative;display:grid;grid-template-columns:7.75rem minmax(0,1fr) 5.8rem;align-items:start;gap:1rem;padding:.85rem 0;border-top:1px solid var(--border)}.mode{display:grid;min-width:0;border:1px solid var(--border);border-radius:6px;overflow:hidden;background:var(--bg)}.mode-choice{position:relative;user-select:none}.mode-choice+.mode-choice{border-top:1px solid var(--border)}.mode-choice input{position:absolute;width:1px;height:1px;opacity:0}.mode-choice span{display:block;padding:.2rem .6rem;color:var(--muted);font-size:.72rem;line-height:1.15rem}.mode-choice:hover span{background:var(--surface-active)}.mode-choice input:checked+span{color:var(--accent);background:rgb(from var(--accent) r g b / .1);box-shadow:inset 2px 0 var(--accent);font-weight:600}.mode-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}button{border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}button{padding:.4rem .55rem;user-select:none}button:hover:not(:disabled){background:var(--surface-active)}button:disabled{opacity:.35}.row-actions{position:relative;display:flex;align-items:center;align-self:stretch;min-height:4.65rem;padding:.8rem 0 .25rem}.remove{position:absolute;top:.15rem;right:0;display:grid;place-items:center;width:1.5rem;height:1.5rem;padding:.25rem;border:0;background:transparent;color:var(--muted)}.duplicate-label{position:absolute;right:.15rem;bottom:-.05rem;transform:rotate(-7deg);padding:.1rem .3rem;border:1px solid rgb(from var(--critical, #e5534b) r g b / .45);border-radius:3px;color:var(--critical, #e5534b);background:var(--surface);font-size:.6rem;line-height:1rem;white-space:nowrap;pointer-events:none;user-select:none}svg{width:1rem;height:1rem}.footer{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding-top:.6rem;border-top:1px solid var(--border)}.add{display:flex;align-items:center;gap:.3rem}.app-model{margin-top:.7rem;border-top:1px solid var(--border)}.app-model-placeholder{padding:.65rem 0 .1rem;color:var(--muted);font-size:.74rem}.app-model>summary{display:flex;flex-wrap:wrap;align-items:center;gap:.35rem .8rem;padding:.65rem 0 .1rem;color:var(--muted);font-size:.74rem;list-style:none;cursor:default;user-select:none}.app-model>summary::-webkit-details-marker{display:none}.app-model>summary:hover{color:var(--text)}.app-model>summary:focus-visible{outline:2px solid var(--accent);outline-offset:3px;border-radius:3px}.app-model>summary svg{width:.8rem;height:.8rem;flex:0 0 .8rem}.app-model[open]>summary svg{transform:rotate(90deg)}.app-model strong{color:var(--text);font-weight:500}.app-model-name{min-width:0;overflow-wrap:anywhere}.app-model-effort{white-space:nowrap}.app-model-controls{padding:.85rem 0 .15rem}.message{margin:0;color:var(--muted);font-size:.7rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@container regime-editor (max-width: 54rem){.row{grid-template-columns:minmax(0,1fr) 5.8rem}scan-model-picker{grid-row:2;grid-column:1 / -1}.mode{grid-column:1;max-width:9rem}.row-actions{grid-column:2}}`};customElements.get("scan-regime-editor")||customElements.define("scan-regime-editor",ir);var Xi=`:host{display:block;min-width:0;color:var(--text);container:mode-selector / inline-size}*{box-sizing:border-box}section{overflow:hidden;border:1px solid var(--border);border-radius:9px;background:var(--surface)}header{display:flex;align-items:baseline;gap:.8rem;padding:.85rem 1rem .7rem}h2{margin:0;font-size:.86rem;font-weight:600}header>span{color:var(--muted);font-size:.73rem}fieldset{min-width:0;margin:0;padding:0;border:0}.modes{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.5rem;padding:0 1rem .9rem}.mode{position:relative;display:flex;align-items:flex-start;gap:.55rem;padding:.7rem .65rem;border:1px solid var(--border);border-radius:7px;background:var(--bg);cursor:default;text-align:left}.mode:hover{background:var(--surface-active)}.mode:has(:checked){border-color:rgb(from var(--accent) r g b / .6);background:rgb(from var(--accent) r g b / .07)}input{position:absolute;width:1px;height:1px;opacity:0;margin:0}.mode:has(:focus-visible),.subtype-option:has(:focus-visible){outline:2px solid var(--accent);outline-offset:3px}.mode-icon{display:flex;flex-shrink:0;color:var(--muted);padding-top:.1rem}.mode-icon svg{width:1rem;height:1rem}.mode-copy{display:grid;min-width:0;gap:.35rem;padding-right:.55rem}.mode-copy strong{font-size:.78rem;font-weight:500;line-height:1.3}.mode-copy>span{color:var(--muted);font-size:.69rem;line-height:1.4}.mode:has(:checked) .mode-copy strong,.mode:has(:checked) .mode-icon{color:var(--accent)}.indicator{position:absolute;right:.55rem;top:.75rem;width:.55rem;height:.55rem;border:1px solid var(--muted);border-radius:50%;opacity:.5}.mode:has(:checked) .indicator{border-color:var(--accent);background:var(--accent);box-shadow:inset 0 0 0 2px var(--bg);opacity:1}.subtype-wrap{border-top:1px solid var(--border);background:rgb(from var(--accent) r g b / .025)}.subtype-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.45rem;padding:.7rem .9rem .45rem}.report-subtypes{grid-template-columns:repeat(2,minmax(0,1fr));padding-bottom:.7rem}.subtype-option{position:relative;display:grid;gap:.12rem;padding:.42rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--muted);background:var(--bg);text-align:left}.subtype-option strong{color:var(--text);font-size:.72rem;font-weight:500}.subtype-option span{font-size:.62rem}.subtype-option:has(:checked){border-color:rgb(from var(--accent) r g b / .55);background:rgb(from var(--accent) r g b / .1)}.subtype-option:has(:checked) strong{color:var(--accent)}.subtype-help{margin:0;padding:.15rem .9rem .72rem;color:var(--muted);font-size:.68rem;line-height:1.4}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container mode-selector (max-width: 48rem){.modes,.subtype-options{grid-template-columns:repeat(2,minmax(0,1fr))}}@container mode-selector (max-width: 30rem){.mode-icon{display:none}header>span{display:none}}
19
+ `;var gn=[{id:"code",label:"Code",detail:"Run a full scan of the codebase",icon:st},{id:"dependencies",label:"Dependency alerts",detail:"Validate incoming alerts against actual code",icon:_i},{id:"agentic",label:"Agentic",detail:"Free-form analysis with your instructions",icon:xi},{id:"report",label:"Reports",detail:"Link saved reports or merge scan results",icon:ge}],bn=[{id:"generic",label:"Generic",detail:"Free-form code scan: wide-scoped, most results"},{id:"security",label:"Security",detail:"Security findings only"},{id:"correctness",label:"Correctness",detail:"Guided correctness scan"},{id:"advanced",label:"Advanced",detail:"Merge multiple regimes"}],vn=[{id:"link",label:"Link",detail:"Link findings across saved reports"},{id:"merge",label:"Merge",detail:"Combine scan results for one bundle"}],sr=class extends x{static properties={mode:{},analyzer:{},reportMode:{}};static styles=k(Xi);constructor(){super(),this.mode="code",this.analyzer="generic",this.reportMode="link"}_choose(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}render(){let e=this.mode==="code",t=this.mode==="report",i=e?bn:vn,s=e?this.analyzer:this.reportMode;return c`<section aria-labelledby="mode-heading"><header><h2 id="mode-heading">Scan mode</h2><span>Choose what the server should analyze</span></header><fieldset class="modes"><legend class="sr-only">Scan mode</legend>${gn.map(o=>c`<label class="mode"><input type="radio" name="scan-mode" .checked="${this.mode===o.id}" aria-label="${o.label}" @change="${()=>this._choose("scan-mode-change",{mode:o.id})}"> <span class="mode-icon" aria-hidden="true">${A(o.icon)}</span> <span class="mode-copy"><strong>${o.label}</strong><span>${o.detail}</span></span> <span class="indicator" aria-hidden="true"></span></label>`)}</fieldset>${e||t?c`<div class="subtype-wrap"><fieldset class="${`subtype-options ${t?"report-subtypes":""}`}"><legend class="sr-only">${e?"Code subtype":"Reports submode"}</legend>${i.map(o=>c`<label class="subtype-option"><input type="radio" name="scan-focus" .checked="${s===o.id}" aria-label="${o.label}" @change="${()=>e?this._choose("scan-analyzer-change",{analyzer:o.id}):this._choose("scan-report-mode-change",{mode:o.id})}"> <strong>${o.label}</strong><span>${o.detail}</span></label>`)}</fieldset>${e?c`<p class="subtype-help">Focusing controls how effort is spent: while Generic can also find security issues, a focused Security scan is likely to find more.</p>`:h}</div>`:h}</section>`}};customElements.get("scan-mode-selector")||customElements.define("scan-mode-selector",sr);var Qi=S`:host{display:block;box-sizing:border-box;color:var(--text)}*{box-sizing:border-box}.wrap{max-width:76rem;margin:0 auto;container:scan-page / inline-size}.head{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;min-height:2.1rem;margin-bottom:.45rem}.head-title{display:flex;align-items:center;gap:.65rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.head-tabs{display:inline-flex;flex-shrink:0;margin-left:auto;margin-block:calc(-.25rem - 1px);border:1px solid var(--border);border-radius:6px;overflow:hidden}.head-tabs button{border:0;border-right:1px solid var(--border);padding:.25rem .6rem;color:var(--muted);background:transparent;font:inherit;font-size:.75rem;line-height:1.5}.head-tabs button:last-child{border-right:0}.head-tabs button.active{color:var(--text);background:var(--surface-active)}.head-tabs button:hover{color:var(--text)}.source-choice.single-repository{grid-template-columns:1fr}.head-actions{margin-left:auto;display:flex;gap:.45rem}button,select,input{font:inherit}button{cursor:default}button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.intro-row{display:flex;align-items:center;flex-wrap:wrap;gap:.65rem 1rem;margin-bottom:1.15rem}.intro{margin:0;max-width:52rem;color:var(--muted);font-size:.82rem;line-height:1.5}.intro span{display:block}.notice{margin:0 0 1rem;padding:.55rem .7rem;border:1px solid rgb(from var(--accent) r g b / .35);border-radius:7px;color:var(--text);background:rgb(from var(--accent) r g b / .08);font-size:.78rem}.setup{display:grid;gap:.85rem}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.panel-head{display:flex;align-items:baseline;justify-content:space-between;gap:.7rem;padding:.72rem .9rem;border-bottom:1px solid var(--border)}.panel-head h2{margin:0;font-size:.86rem;font-weight:600}.panel-head p{margin:0;color:var(--muted);font-size:.72rem}.bundle-choice{display:grid;grid-template-columns:minmax(16rem,1.2fr) minmax(0,1fr);gap:1rem;align-items:end;padding:.85rem .9rem}.field{display:grid;gap:.3rem;min-width:0}.field label,.scope-field>span{color:var(--muted);font-size:.68rem}select{min-width:0;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.76rem}.bundle-stats{display:grid;grid-template-columns:repeat(4,max-content);align-items:center;gap:.45rem 1.1rem;min-width:0}.metric{display:inline-flex;align-items:center;gap:.3rem;min-width:0;white-space:nowrap}.metric svg{flex:0 0 auto;width:.85rem;height:.85rem;margin-right:.1rem;color:var(--muted)}.metric strong{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:.72rem;font-weight:600;font-variant-numeric:tabular-nums}.metric span{color:var(--muted);font-size:.7rem}.source-choice{display:grid;grid-template-columns:minmax(12rem,.8fr) minmax(16rem,1.2fr);gap:.7rem;align-items:end;padding:.85rem .9rem}.source-footer{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:.7rem 1rem;grid-column:1 / -1;min-width:0}.scope-slot{justify-self:end;width:min(34rem,100%);min-height:2rem}.source-footer .bundle-stats{min-height:2rem}.choice-empty{display:flex;align-items:center;height:2rem;padding:.28rem .5rem;border:1px dashed var(--border);border-radius:5px;color:var(--muted);background:var(--bg);font-size:.72rem}.scope-head{display:flex;align-items:center;gap:.55rem;padding:.72rem .9rem;list-style:none;cursor:default;user-select:none}.scope-head::-webkit-details-marker{display:none}.scope-head:hover{background:var(--surface-active)}.scope-head:focus-visible{outline:2px solid var(--accent);outline-offset:-3px;border-radius:8px}.scope-chevron{width:.85rem;height:.85rem;flex:0 0 auto;transition:transform .15s}.scope-panel[open] .scope-chevron{transform:rotate(90deg)}.scope-panel[open] .scope-head{border-bottom:1px solid var(--border)}.scope-head h2{margin:0;font-size:.86rem;font-weight:600}.scope-head p{display:flex;flex-wrap:wrap;justify-content:end;gap:.15rem .65rem;margin:0 0 0 auto;color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums;text-align:right}.scope-head p span{white-space:nowrap}.scope-head p span+span{padding-left:.65rem;border-left:1px solid var(--border)}.scope-grid{display:grid;grid-template-columns:minmax(13rem,.75fr) minmax(0,1.25fr);min-height:0}.scope-pane{min-width:0}.scope-pane+.scope-pane{border-left:1px solid var(--border)}.pane-head{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem;padding:.55rem .75rem;border-bottom:1px solid var(--border)}.pane-head strong{font-size:.72rem;font-weight:600}.pane-head span{color:var(--muted);font-size:.65rem;font-variant-numeric:tabular-nums}.package-list{max-height:22rem;overflow:auto;overscroll-behavior:none}.package-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.45rem;width:100%;padding:.42rem .7rem;border:0;border-bottom:1px solid var(--border);color:var(--text);background:transparent;text-align:left}.package-row:hover{background:var(--surface-active)}.package-row input,.file input{width:.85rem;height:.85rem;accent-color:var(--accent)}.package-name,.package-size{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.package-name{font-size:.7rem}.package-size{color:var(--muted);font-size:.64rem;font-variant-numeric:tabular-nums}.package-row.excluded .package-name{color:var(--muted);text-decoration:line-through}.file-panel{min-width:0}.file-list{display:grid;grid-template-columns:minmax(0,1fr);max-height:22rem;overflow:auto;overscroll-behavior:none}.file{display:flex;align-items:center;gap:.45rem;min-width:0;padding:.35rem .75rem;border-bottom:1px solid var(--border)}.file input{flex:0 0 auto}.file-copy{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem}.file-meta{flex:0 1 auto;min-width:0;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums}.excluded .file-path{color:var(--muted);text-decoration:line-through}.file-foot{display:flex;justify-content:space-between;gap:.6rem;padding:.6rem .8rem;color:var(--muted);font-size:.7rem}.options{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:1rem;position:relative;z-index:2;overflow:visible;padding:.85rem .9rem 1rem}.options-grid{display:grid;grid-column:1 / -1;gap:.7rem;min-width:0}.checks{position:relative;display:grid;grid-column:2;grid-row:3;align-content:center;justify-items:end;margin-top:1rem}.offline-help{position:absolute;top:calc(50% + .75rem);right:0;color:var(--muted);font-size:.66rem;line-height:1.4;white-space:nowrap}.check{display:inline-flex;align-items:center;gap:.4rem;color:var(--text);font-size:.75rem}.check input{width:.85rem;height:.85rem;accent-color:var(--accent)}.switch{display:inline-flex;align-items:center;gap:.45rem;color:var(--text);font-size:.74rem;cursor:default}.switch input{position:absolute;width:1px;height:1px;opacity:0}.switch-track{position:relative;width:2rem;height:1.1rem;border-radius:999px;background:var(--surface-active);transition:background .12s}.switch-track:after{content:"";position:absolute;top:.15rem;left:.15rem;width:.8rem;height:.8rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.switch input:checked+.switch-track{background:rgb(from var(--accent) r g b / .4)}.switch input:checked+.switch-track:after{transform:translate(.9rem);background:var(--accent)}.checks .switch input:checked+.switch-track{background:rgb(from var(--critical, #e5534b) r g b / .3)}.checks .switch input:checked+.switch-track:after{background:var(--critical, #e5534b)}.switch input:focus-visible+.switch-track{outline:2px solid var(--accent);outline-offset:2px}.options-footer{display:flex;flex-wrap:wrap;grid-column:1;grid-row:3;align-items:end;gap:.7rem;min-width:0;margin-top:1rem}.options-footer slot[name=before-run]{display:contents}.agentic-fields{display:grid;gap:.65rem;padding:.85rem .9rem 1rem}.agentic-panel .panel-head{align-items:center}.prompt-row{display:flex;align-items:start;gap:.4rem;min-width:0}.prompt-row textarea{flex:1;width:0}.prompt-action{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;padding:.25rem;border:0;border-radius:4px;color:var(--muted);background:transparent}.prompt-action:hover{color:var(--text);background:var(--surface-active)}.prompt-action svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.4}textarea{min-width:0;resize:vertical;padding:.4rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.76rem}.run{padding:.48rem .8rem;border:0;border-radius:6px;color:var(--bg);background:var(--accent);font-size:.8rem;font-weight:600}.run:disabled{opacity:.45}.summary{align-self:end;padding-block:.48rem;color:var(--muted);font-size:.74rem}.history{display:grid;gap:.6rem}.scan-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:1rem;padding:.85rem .9rem}.scan-row+.scan-row{border-top:1px solid var(--border)}.scan-main{min-width:0}.scan-title{display:flex;align-items:center;gap:.45rem;min-width:0}.scan-title strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem}.scan-meta{display:block;margin-top:.25rem;color:var(--muted);font-size:.7rem}.status{display:inline-flex;align-items:center;gap:.3rem;padding:.15rem .4rem;border-radius:999px;font-size:.66rem;font-weight:600;text-transform:capitalize}.status:before{content:"";width:.4rem;height:.4rem;border-radius:50%;background:currentColor}.status.running{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.status.completed{color:#48b878;background:#48b8781a}.status.stopped{color:var(--muted);background:var(--surface-active)}.scan-actions{display:flex;align-items:center;gap:.45rem}.action{padding:.35rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.72rem;white-space:nowrap}.action:hover{border-color:var(--muted);background:var(--surface-active)}.empty{margin:0;padding:1.2rem;color:var(--muted);font-size:.8rem}@container scan-page (max-width: 48rem){.bundle-choice,.source-choice,.source-footer{grid-template-columns:1fr;gap:.7rem}.scope-grid{grid-template-columns:1fr}.scope-pane+.scope-pane{border-top:1px solid var(--border);border-left:0}}@container scan-page (max-width: 42rem){.options{display:block;padding-bottom:3rem}.checks{margin-top:.8rem}.offline-help{max-width:100%;white-space:normal}.options-footer{margin-top:.8rem}}@container scan-page (max-width: 34rem){.bundle-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:.45rem .65rem}.scope-head{flex-wrap:wrap}.scope-head p{flex-basis:100%;justify-content:start;margin-left:1.4rem;text-align:left}.scope-head p span{white-space:normal}.scope-head p span+span{padding-left:0;border-left:0}.scan-row{grid-template-columns:1fr;gap:.55rem}.scan-actions{justify-content:flex-start}.head-tabs{margin-left:0}}`;var es=[{key:"metro",label:"metro",subtitle:"Metro bundle contents"},{key:"run",label:"run",subtitle:"Node.js CLI"},{key:"add",label:"add",subtitle:"Manually added files"}];function ts(r){let e=r.filter(i=>i.id!=="all");if(e.length===0)return null;let t=new Map(e.map(i=>[String(i.id).replace(/^reason:/u,""),i]));return t.size!==e.length||[...t.keys()].some(i=>!es.some(s=>s.key===i))?null:[{id:"",label:"All files",subtitle:"Everything"},...es.filter(i=>t.has(i.key)).map(({key:i,...s})=>({...s,id:t.get(i).id,subtitle:i==="run"&&t.has("metro")?"Bundler and Node.js CLI":s.subtitle}))]}var or=class extends x{static properties={reasons:{attribute:!1},value:{attribute:!1},label:{type:String}};constructor(){super(),this.reasons=[],this.value="",this.label="Choose scope"}_select(e){this.dispatchEvent(new CustomEvent("scope-change",{detail:{value:e},bubbles:!0,composed:!0}))}render(){let e=this.reasons.filter(s=>s.id!=="all");if(e.length===0)return h;let t=ts(e);if(!t)return c`<label class="scope-field"><span>Scope</span><select aria-label="${this.label}" .value="${R(this.value==="all"?"":this.value)}" @change="${s=>this._select(s.target.value)}"><option value="">All files</option>${e.map(s=>c`<option value="${s.id}">${s.label??s.id}</option>`)}</select></label>`;let i=t.find(s=>s.id===this.value)??t[0];return c`<div class="scope-toggle"><div class="scope-options" role="radiogroup" aria-label="${this.label}" aria-describedby="scope-description">${t.map(s=>c`<label class="scope-option"><input type="radio" name="scope" value="${s.id}" .checked="${i.id===s.id}" @change="${()=>this._select(s.id)}"><span>${s.label}</span></label>`)}</div><span class="scope-description" id="scope-description">${i.subtitle}</span></div>`}static styles=S`:host{display:block;min-width:0}*{box-sizing:border-box}.scope-toggle{display:flex;align-items:center;justify-content:end;flex-wrap:wrap;gap:.4rem .7rem;min-width:0;min-height:2rem}.scope-options{display:flex;flex-shrink:0;min-width:0;border:1px solid var(--border);border-radius:5px;overflow:hidden;background:var(--bg)}.scope-option{position:relative;flex:1 0 auto;user-select:none}.scope-option+.scope-option{border-left:1px solid var(--border)}.scope-option input{position:absolute;width:1px;height:1px;opacity:0}.scope-option span{display:grid;place-items:center;height:calc(2rem - 2px);padding:.3rem .55rem;color:var(--muted);font-size:.74rem;white-space:nowrap}.scope-option:hover span{color:var(--text);background:var(--surface-active)}.scope-option input:checked+span{color:var(--text);background:var(--surface-active);font-weight:500}.scope-option input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.scope-description{order:-1;min-width:0;color:var(--muted);font-size:.66rem;line-height:1rem;text-align:right}.scope-field{display:flex;align-items:center;justify-content:end;gap:.5rem;min-width:0;max-width:100%;margin-left:auto;color:var(--muted);font-size:.7rem}select{width:13rem;min-width:0;max-width:100%;padding:.35rem .5rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--text);font:inherit;font-size:.76rem}`};customElements.get("bundle-scope-selector")||customElements.define("bundle-scope-selector",or);var rs={code:A(st),report:A(ge)},nr=class extends x{static properties={hideHeading:{type:Boolean,attribute:"hide-heading"},sourceLoading:{type:Boolean,attribute:!1},source:{attribute:!1},loadBundle:{attribute:!1},loadModels:{attribute:!1},loadReportSources:{attribute:!1},canRun:{attribute:!1},_loadingBundle:{state:!0},_bundleError:{state:!0},_tab:{state:!0},_mode:{state:!0},_bundles:{state:!0},_repositories:{state:!0},_reportMode:{state:!0},_reportInput:{state:!0},_reportRestore:{state:!0},_scans:{state:!0},_selectedRepoId:{state:!0},_selectedBundleId:{state:!0},_reason:{state:!0},_excluded:{state:!0},_excludedModules:{state:!0},_prompts:{state:!0},_options:{state:!0},_regimes:{state:!0},_regimesReady:{state:!0},_appModel:{state:!0},_appModelAutomatic:{state:!0},_notice:{state:!0}};static styles=Qi;constructor(){super(),this.loadModels=ye,this.canRun=!0,this.hideHeading=!1,this._tab="new",this._mode="code",this.source=null,this.sourceLoading=!1,this.loadBundle=null,this._loadingBundle=!1,this._bundleError=null,this._bundles=[],this._repositories=[],this._reportMode="link",this._reportInput=null,this._reportRestore=null,this._scans=[],this._selectedRepoId=null,this._selectedBundleId=this._bundles[0]?.id??null,this._reason=this._bundles[0]?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._nextPromptId=1,this._prompts=[{id:1,text:""}],this._options={analyzer:"generic",model:null,effort:null,cached:!1,isolate:!1},this._regimes=[],this._appModel=null,this._appModelAutomatic=!0,this._regimesReady=!1,this._notice=null,this._timers=new Set}willUpdate(e){if(e.has("source")){this._bundles=this.source?.bundles??[],this._repositories=this.source?.repositories??[],this._scans=this.source?.scans??[],this._excluded=new Set,this._excludedModules=new Set;let t=this._repositories.find(s=>s.id===this._selectedRepoId),i=this._bundles.find(s=>s.id===this._selectedBundleId)??(t?this._bundles.find(s=>s.repoId===t.id):this._bundles[0]);this._selectedRepoId=i?.repoId??t?.id??this._repositories[0]?.id??"unattached",this._selectedBundleId=i?.id??null,this._reason=i?.reasons?.[0]?.id??""}}updated(e){(e.has("source")||e.has("loadBundle"))&&this._loadSelectedBundle()}async _loadSelectedBundle(){this._bundleController?.abort(),this._loadingBundle=!1,this._bundleError=null;let e=this._bundle;if(!this.loadBundle||!e||Array.isArray(e.files))return;let t=this._bundleController=new AbortController;this._loadingBundle=!0;try{let i=await this.loadBundle(e,t.signal);if(t.signal.aborted)return;this._bundles=this._bundles.map(s=>s.id===e.id?i:s),this._reason=i.reasons?.[0]?.id??""}catch(i){t.signal.aborted||(this._bundleError=String(i?.message??i))}finally{t.signal.aborted||(this._loadingBundle=!1)}}disconnectedCallback(){super.disconnectedCallback(),this._bundleController?.abort();for(let e of this._timers)clearTimeout(e);this._timers.clear()}get _repoBundles(){return this._bundles.filter(e=>e.repoId===this._selectedRepoId)}get _bundle(){return this._repoBundles.find(e=>e.id===this._selectedBundleId)}get _reasonData(){return this._bundle?.reasons.find(e=>e.id===this._reason)??this._bundle?.reasons[0]}_packageLabel(e){return e==="__own__"?"Own code":e}get _files(){let e=this._reasonData,t=e?.fileModules,i=e?.filePaths?new Set(e.filePaths):null;return Jt(this._bundle?.files).filter(s=>(t==null||t.includes(s.module))&&(i==null||i.has(s.path))).toSorted((s,o)=>o.bytes-s.bytes)}render(){return c`<div class="wrap">${this.hideHeading?c`<h1 class="sr-only">Scans</h1>`:c`<div class="head"><div class="head-title"><slot name="navigation"></slot><h1>Scans</h1></div></div>`}<div class="intro-row"><p class="intro">${this._tab==="history"?"Review past scans and save completed results as reports.":this._mode==="report"?"Choose inputs and start a scan. Save the report when it finishes.":"Choose a bundle and start a scan. Save the report when it finishes."}</p><div class="head-tabs" role="tablist" aria-label="Scan views"><button class="${this._tab==="new"?"active":""}" role="tab" aria-selected="${this._tab==="new"}" @click="${()=>{this._tab="new"}}">New scan</button> <button class="${this._tab==="history"?"active":""}" role="tab" aria-selected="${this._tab==="history"}" @click="${()=>{this._tab="history"}}">Scan history</button></div></div>${this._notice?c`<p class="notice" role="status">${this._notice}</p>`:h} ${this._bundleError?c`<p class="notice" role="alert">Couldn’t load bundle: ${this._bundleError}<button @click="${()=>{this._loadSelectedBundle()}}">Retry</button></p>`:h} ${this._tab==="new"?this._newScan():this._history()}</div>`}_newScan(){let e=this._mode,t=this._bundle,i=e==="code"?this._files:t?.files??[],s=this._excluded,o=this._excludedModules,n=i.filter(m=>!s.has(m.path)&&!o.has(m.module)),a=Ne(t?.files?n:null),l=new Map;for(let m of i){let b=l.get(m.module)??{bytes:0,count:0,included:0};b.bytes+=m.bytes,b.count++,s.has(m.path)||b.included++,l.set(m.module,b)}let d=[...l.keys()].toSorted((m,b)=>l.get(b).bytes-l.get(m).bytes||this._packageLabel(m).localeCompare(this._packageLabel(b))),u=i.slice(0,80),p=d.filter(m=>!o.has(m)).length,g=this._reportInput?.mode===this._reportMode?this._reportInput.inputs:[];return c`<div class="setup"><scan-mode-selector .mode="${e}" .analyzer="${this._options.analyzer}" .reportMode="${this._reportMode}" @scan-mode-change="${m=>this._changeMode(m.detail.mode)}" @scan-analyzer-change="${m=>this._setOption("analyzer",m.detail.analyzer)}" @scan-report-mode-change="${m=>{this._reportMode=m.detail.mode,this._reportRestore=null}}"></scan-mode-selector>${e==="report"?c`<scan-report-inputs .mode="${this._reportMode}" .loadSources="${this.loadReportSources}" .restore="${this._reportRestore}" @report-inputs-change="${m=>{this._reportInput=m.detail}}"></scan-report-inputs>`:this._sourcePanel(t,i)} ${e==="code"?c`<details class="panel scope-panel"><summary class="scope-head"><svg class="scope-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg><h2>Source filter</h2><p><span>${n.length} of ${i.length} files · ${p} of ${d.length} packages</span> <span>${B(a.bytes)} · ${a.lines==null?"\u2014":a.lines.toLocaleString()} LoC</span></p></summary><div class="scope-grid"><section class="scope-pane package-pane" aria-label="Packages in bundle"><div class="pane-head"><strong>Packages</strong><span>${d.length} total · sorted by size</span></div><div class="package-list">${d.map(m=>{let{bytes:b,count:f,included:y}=l.get(m),$=!o.has(m);return c`<label class="${`package-row ${$?"":"excluded"}`}"><input type="checkbox" .checked="${$}" @change="${_=>this._toggleModule(m)}"><span class="package-name">${this._packageLabel(m)}</span><span class="package-size">${B(b)} · ${y}/${f}</span></label>`})}</div></section><section class="scope-pane file-panel" aria-label="Largest files in bundle"><div class="pane-head"><strong>Largest files</strong><span>showing ${u.length} of ${i.length}</span></div>${i.length===0?c`<p class="empty">No files in this selection.</p>`:c`<div class="file-list">${u.map(m=>{let b=!s.has(m.path)&&!o.has(m.module);return c`<label class="${`file ${b?"":"excluded"}`}"><input type="checkbox" .checked="${b}" @change="${f=>this._toggleFile(m,f.target.checked)}"><span class="file-copy"><span class="file-path" data-tooltip-truncated data-tooltip="${m.path}">${m.path}</span><span class="file-meta">${m.size} · ${this._packageLabel(m.module)}</span></span></label>`})}</div>`}</section></div></details>`:h} ${e==="agentic"?this._agenticPanel():h}<slot name="access"></slot>${this._optionsPanel(e,t,e==="report"?g.length:n.length)}</div>`}_sourcePanel(e,t){if(this.sourceLoading)return c`<section class="panel source-panel" aria-busy="true"><div class="panel-head"><h2>Source</h2></div><p class="empty" role="status">Loading scan sources…</p></section>`;let i=this._mode==="code"?this._repoBundles.map(d=>d.files?{...d,files:Jt(d.files)}:d):this._repoBundles,{lines:s}=Ne(e?.files?t:null),o=new Map;for(let d of this._bundles)o.set(d.repoId,(o.get(d.repoId)??0)+1);let n=this._repositories.length>1,a=["code","agentic"].includes(this._mode)&&e!=null&&(!e.filename.toLowerCase().endsWith(".map")||e.reasons?.some(d=>d.id!=="all")),l=this._repositories.map(d=>{let u=o.get(d.id)??0;return{value:d.id,label:d.label,detail:`${u} ${u===1?"bundle":"bundles"}`,special:d.id==="unattached"}});return c`<section class="panel source-panel" aria-busy="${this._loadingBundle}"><div class="panel-head"><h2>Source</h2></div><div class="${`source-choice ${n?"":"single-repository"}`}">${n?c`<div class="field"><span>Repository</span><repository-selector .options="${l}" .value="${this._selectedRepoId}" @repository-change="${d=>this._selectRepoById(d.detail.value)}"></repository-selector></div>`:h}<div class="field">${n?c`<span>Bundle</span>`:h}${i.length>0?c`<bundle-selector .bundles="${i}" .value="${e?.id??null}" @bundle-change="${d=>this._selectBundleById(d.detail.value)}"></bundle-selector>`:c`<div class="choice-empty">${this._bundles.length===0?"No stored bundles.":"No stored bundles for this repository."}</div>`}</div><div class="source-footer"><div class="bundle-stats" aria-label="Bundle statistics"><div class="metric"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><ellipse cx="8" cy="4" rx="5" ry="2"/><path d="M3 4v8c0 1.1 2.2 2 5 2s5-.9 5-2V4M3 8c0 1.1 2.2 2 5 2s5-.9 5-2"/></svg><strong>${e?.size??"\u2014"}</strong><span>bundle size</span></div><div class="metric">${rs.report}<strong>${t.length}</strong><span>files</span></div><div class="metric">${rs.code}<strong>${s==null?"\u2014":s.toLocaleString()}</strong><span>LoC</span></div><div class="metric">${A(fe)}<strong>${new Set(t.map(d=>d.module)).size}</strong><span>packages</span></div></div>${a?c`<div class="scope-slot">${this._scopeField(e)}</div>`:h}</div></div></section>`}_scopeField(e){if(!["code","agentic"].includes(this._mode))return h;let t=(e?.reasons??[]).filter(i=>i.id!=="all");return t.length===0?h:c`<bundle-scope-selector .reasons="${t}" .value="${this._reason}" label="${this._mode==="agentic"?"Choose agentic scope":"Choose scan scope"}" @scope-change="${i=>this._changeReason(i.detail.value)}"></bundle-scope-selector>`}_optionsPanel(e,t,i){let s=e==="report"?`${i} ${this._reportMode==="merge"?"scan results":"reports"} selected`:`${t?.filename??"No bundle selected"} \xB7 ${i} files will be analyzed`,o=e==="code"&&this._options.analyzer==="advanced",n=!this.canRun||(e==="report"?i===0:t==null||i===0||o&&(!this._regimesReady||this._regimes.length===0));return c`<section class="panel options"><div class="options-grid">${o?c`<scan-regime-editor .loadModels="${this.loadModels}" .value="${this._regimes}" .appModel="${this._appModel}" .appModelAutomatic="${this._appModelAutomatic}" @regimes-change="${a=>{this._regimesReady=a.detail.ready,this._regimes=a.detail.value,this._appModel=a.detail.appModel,this._appModelAutomatic=a.detail.appModelAutomatic}}"></scan-regime-editor>`:c`<scan-model-picker .loadModels="${this.loadModels}" ?has-extra="${e==="code"}" .value="${this._options.model}" .effort="${this._options.effort}" @model-change="${a=>{this._options={...this._options,model:a.detail.model,effort:a.detail.effort}}}">${e==="code"?c`<scan-depth-toggle slot="effort-extra" .isolate="${this._options.isolate}" @depth-change="${a=>this._setOption("isolate",a.detail.isolate)}"></scan-depth-toggle>`:h}</scan-model-picker>`}</div><div class="options-footer"><slot name="before-run"></slot><button type="button" class="run" ?disabled="${n}" @click="${()=>this._runScan()}">${e==="report"?this._reportMode==="merge"?"Merge results":"Link reports":"Run scan"}</button><span class="summary">${s}</span></div><div class="checks"><label class="switch"><input type="checkbox" aria-describedby="${this._options.cached?"offline-help":h}" .checked="${this._options.cached}" @change="${a=>this._setOption("cached",a.target.checked)}"><span class="switch-track" aria-hidden="true"></span><span>Offline</span></label>${this._options.cached?c`<small class="offline-help" id="offline-help">Cache only, no new model requests</small>`:h}</div></section>`}_history(){return c`<section class="panel history"><div class="panel-head"><h2>Scan history</h2><p>${this._scans.length} scans</p></div>${this._scans.length===0?c`<p class="empty">No scans yet.</p>`:this._scans.map(e=>this._scanRow(e))}</section>`}_scanRow(e){let t=e.status==="completed"?e.reportSaved?c`<button type="button" class="action" @click="${()=>this._deleteSavedReport(e)}">Delete saved report</button>`:c`<button type="button" class="action" @click="${()=>this._saveReport(e)}">Save report</button>`:h;return c`<div class="scan-row"><div class="scan-main"><div class="scan-title"><strong>${e.bundleName}</strong><span class="${`status ${e.status}`}">${e.status}</span></div><span class="scan-meta">${e.reason} · ${e.files} ${e.mode==="report"?e.reportMode==="merge"?"results":"reports":"files"} · ${e.createdAt}${e.duration?` \xB7 ${e.duration}`:""}${e.reportSaved?" \xB7 Report saved":e.status==="completed"?" \xB7 Report available":""}</span></div><span class="scan-actions">${t}${e.status==="running"?c`<button type="button" class="action" @click="${()=>this._stopScan(e)}">Stop</button>`:h}${e.status==="stopped"?c`<button type="button" class="action" @click="${()=>this._restartScan(e)}">Restart as new scan</button>`:h}</span><span aria-hidden="true"></span></div>`}_selectBundle(e){this._selectedRepoId=e.repoId,this._selectedBundleId=e.id,this._reason=e.reasons?.[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_selectBundleById(e){let t=this._repoBundles.find(i=>i.id===e);t!=null&&this._selectBundle(t)}_selectRepoById(e){if(e===this._selectedRepoId||!this._repositories.some(i=>i.id===e))return;this._selectedRepoId=e;let t=this._bundles.find(i=>i.repoId===e);this._selectedBundleId=t?.id??null,this._reason=t?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_changeMode(e){!["dependencies","code","agentic","report"].includes(e)||e===this._mode||(this._mode=e,this._reportInput=null,this._reportRestore=null,this._excluded=new Set,this._excludedModules=new Set,this._notice=null)}_changeReason(e){this._reason=e,this._excluded=new Set,this._excludedModules=new Set}_toggleFile(e,t){let i=new Set(this._excluded);t?i.delete(e.path):i.add(e.path),this._excluded=i}_toggleModule(e){let t=new Set(this._excludedModules);t.has(e)?t.delete(e):t.add(e),this._excludedModules=t}_setOption(e,t){this._options[e]!==t&&(e==="analyzer"&&t==="advanced"&&(this._regimesReady=!1,this._regimes.length===0&&(this._regimes=[{mode:this._options.analyzer,model:this._options.model,effort:this._options.effort,isolate:this._options.isolate}])),this._options={...this._options,[e]:t})}_agenticPanel(){return c`<section class="panel agentic-panel"><div class="panel-head"><h2>Agentic instructions</h2><button type="button" class="prompt-action" aria-label="Add prompt" @click="${()=>this._addPrompt()}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg></button></div><div class="agentic-fields">${at(this._prompts,e=>e.id,(e,t)=>c`<div class="prompt-row"><textarea aria-label="${`Prompt ${t+1}`}" rows="3" placeholder="${this._promptPlaceholder(t)}" .value="${R(e.text)}" @input="${i=>{this._prompts=this._prompts.map(s=>s.id===e.id?{...s,text:i.target.value}:s)}}"></textarea>${this._prompts.length>1?c`<button type="button" class="prompt-action" aria-label="${`Remove prompt ${t+1}`}" @click="${()=>this._removePrompt(e.id)}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button>`:h}</div>`)}</div></section>`}_promptPlaceholder(e){let t=["","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth"][e];return t!=null?`What should the ${t?`${t} `:""}agent focus on?`:`What should agent ${e+1} focus on?`}async _addPrompt(){this._prompts=[...this._prompts,{id:++this._nextPromptId,text:""}],await this.updateComplete,this.renderRoot?.querySelector(".prompt-row:last-child textarea")?.focus()}_removePrompt(e){this._prompts.length>1&&(this._prompts=this._prompts.filter(t=>t.id!==e))}_runScan(){if(!this.canRun)return;let e=this._mode,t=e==="code"&&this._options.analyzer==="advanced";if(t&&(!this._regimesReady||this._regimes.length===0))return;let i=this._bundle,s=this._reportInput?.mode===this._reportMode?this._reportInput:null,o=s?.inputs??[],n=e==="code"?this._files.filter(d=>!this._excluded.has(d.path)&&!this._excludedModules.has(d.module)):i?.files??[];if(e==="report"&&(!s?.source||o.length===0)||e!=="report"&&(!i||n.length===0))return;let a={id:`scan-${Date.now()}`,mode:e,bundleId:e==="report"?this._reportMode==="merge"?s.source.id:null:i?.id??null,bundleName:e==="report"?s.source.label:i.filename,reason:e==="agentic"?this._reasonData?.label??"All files":e==="report"?this._reportMode==="merge"?"Merge scan results":"Link saved reports":e==="code"?this._reasonData?.label??"All files":"Dependencies",status:"running",createdAt:"Just now",duration:"",files:e==="report"?o.length:n.length,reportSaved:!1,cached:this._options.cached,isolate:e==="code"&&this._options.isolate,model:this._options.model,effort:this._options.effort};e==="code"&&(a.analyzer=this._options.analyzer),t&&(a.regimes=this._regimes.map(d=>({...d})),a.appModel=this._appModel?{...this._appModel}:null,a.appModelAutomatic=this._appModelAutomatic,a.reason=`Advanced \xB7 ${a.regimes.length} regimes \xB7 ${a.reason}`,a.scopeId=this._reason,a.model=null,a.effort=null,a.isolate=!1),e==="agentic"&&(a.prompts=this._prompts.map(d=>d.text)),e==="report"&&(a.reportMode=this._reportMode,a.reportSource={...s.source},a.inputIds=o.map(d=>d.id)),this._scans=[a,...this._scans],this._tab="history",this._notice="Scan started. The server will update its status as work progresses.";let l=setTimeout(()=>{this._timers.delete(l),a.status==="running"&&(a.status="completed",a.duration="2m 14s",this._notice="Scan completed. Its report is ready to save.",this.requestUpdate())},2200);this._timers.add(l)}_stopScan(e){e.status==="running"&&(e.status="stopped",e.duration=e.duration||"stopped by user",this._notice="Scan stopped. It cannot continue, but you can restart it as a new scan.",this.requestUpdate())}_restartScan(e){if(this._options={...this._options,model:e.model??this._options.model,effort:e.effort??this._options.effort,cached:e.cached??!1,isolate:e.isolate??!1,analyzer:e.analyzer??"generic"},e.mode==="report"){this._mode="report",this._reportMode=e.reportMode==="link"?"link":"merge",this._reportInput=null,this._reportRestore={mode:this._reportMode,source:e.reportSource,inputIds:e.inputIds??[]},this._tab="new",this._notice="New report scan settings restored from the stopped run.";return}let t=this._bundles.find(i=>i.id===e.bundleId);t&&(this._selectBundle(t),this._mode=e.mode??"dependencies",e.mode==="agentic"&&(this._prompts=(e.prompts?.length>0?e.prompts:[""]).map(i=>({id:++this._nextPromptId,text:i}))),e.regimes?.length>0&&(this._options={...this._options,analyzer:"advanced"},this._regimes=e.regimes.map(i=>({...i})),this._appModel=e.appModel?{...e.appModel}:null,this._appModelAutomatic=e.appModelAutomatic!==!1,this._regimesReady=!1),this._reason=t.reasons.find(i=>i.label===e.reason)?.id??t.reasons[0]?.id??"",e.regimes?.length>0&&(this._reason=e.scopeId??this._reason),this._tab="new",this._notice="New scan settings restored from the stopped run.")}_saveReport(e){e.reportSaved=!0,this._notice="Report saved. You can delete it from Reports and save this completed scan again.",this.requestUpdate()}_deleteSavedReport(e){e.reportSaved=!1,this._notice="Saved report deleted. The completed scan can be saved again.",this.requestUpdate()}};customElements.get("deepview-scan-page")||customElements.define("deepview-scan-page",nr);var yn={js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",json:"json",css:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",md:"markdown",markdown:"markdown",sol:"solidity",php:"php",phtml:"php",rs:"rust",rb:"ruby",java:"java",cpp:"cpp",cc:"cpp",cxx:"cpp","c++":"cpp",hpp:"cpp",hh:"cpp",hxx:"cpp","h++":"cpp",h:"cpp",c:"c",m:"objectivec",mm:"objectivec"};function is(r){if(typeof r!="string")return null;let e=r.slice(r.lastIndexOf("/")+1),t=e.lastIndexOf(".");return t<=0?null:yn[e.slice(t+1).toLowerCase()]??null}var _n=Object.freeze({javascript:"JavaScript",jsx:"JSX",typescript:"TypeScript",tsx:"TSX",json:"JSON",css:"CSS",markup:"HTML",yaml:"YAML",bash:"Shell",markdown:"Markdown",solidity:"Solidity",php:"PHP",rust:"Rust",ruby:"Ruby",java:"Java",cpp:"C++",c:"C",objectivec:"Objective-C",python:"Python",go:"Go",kotlin:"Kotlin",swift:"Swift",dart:"Dart",sql:"SQL",lua:"Lua",csharp:"C#",scala:"Scala",vue:"Vue",svelte:"Svelte"}),wn=Object.freeze({py:"python",pyw:"python",go:"go",kt:"kotlin",kts:"kotlin",swift:"swift",dart:"dart",sql:"sql",lua:"lua",cs:"csharp",scala:"scala",sc:"scala",vue:"vue",svelte:"svelte"});function xn(r){let e=typeof r=="string"?r.slice(r.lastIndexOf("/")+1):"",t=e.lastIndexOf("."),i=t>0?e.slice(t+1).trim().toLowerCase():"",s=is(r)??wn[i];return s?{key:s,label:_n[s]??s}:i?{key:`extension:${i}`,label:`.${i}`}:{key:"other",label:"Other"}}function ss(r,e){let t=new Map,i=0,s=0;for(let[o,n]of r){let a=xn(o),l=t.get(a.key)??{...a,files:0,lines:0,bytes:0};l.files++,l.lines+=n,l.bytes+=e.get(o)??0,t.set(a.key,l),s+=n,i+=e.get(o)??0}return{files:r.size,lines:s,bytes:i,languages:[...t.values()].toSorted((o,n)=>n.lines-o.lines||o.label.localeCompare(n.label))}}var $n=new Set(["module","commonjs","json","module-typescript","commonjs-typescript"]),kn=new Set(["solidity","php","shell","rust"]),Sn=new Set(["java","kotlin","gradle","objc","objcpp","swift","c","cpp","c-header","cpp-header","ruby","cmake","podspec","podfile","podfile-lock","template","xml","env","fastlane","pbxproj"]),En=new Set(["resource","resource:base64"]),as=new Set(["stat:file","stat:directory"]),ls=new Set([...$n,...kn,...Sn,...En,"patch","directory",...as]),ar=r=>as.has(r),os=r=>r==="directory"||r==="stat:directory"?"directory":"file";function An(r,e,t){if(r===e)return r;let i=ar(r),s=ar(e);if(i!==s&&os(r)===os(e))return i?e:r;throw new Error(`format conflict for '${t}' ('${e}' vs '${r}')`)}function _e(r,e){return e===""?r:r==="."?e:`${r}/${e}`}function cs(r,{scope:e="full"}={}){let t=new Set;for(let[i,{files:s}]of r)if(!(e!=="full"&&!$e(i)))for(let o of Object.keys(s))t.add(_e(i,o));return t}function Cn(r,{what:e,files:t,formats:i,scope:s}){if(L(r))return"escapes the root";if(s!=="full"&&!$e(r))return`is outside node_modules, which a '${s}'-scope ${e} does not record`;if(!t.has(r))return`names no file the ${e} records`;let o=i.get(r);return o==="directory"?"is a directory capture, not a file":ar(o)?`is a payload-free '${o}' record, not a file`:null}function ds(r,{what:e,files:t,formats:i,scope:s}){for(let o of r){let n=Cn(o,{what:e,files:t,formats:i,scope:s});v(n===null,`${e}: executable entry '${o}' ${n}`)}}function ps(r,{what:e,files:t,formats:i,scope:s="full"}){if(r===void 0)return new Set;let o=`${e}: executable`;v(Array.isArray(r),`${o} must be an array of file paths`);let n=new Set;for(let a of r)v(typeof a=="string"&&a!=="",`${o} entry must be a non-empty string`),v(!n.has(a),`${o} entry '${a}' is listed twice`),n.add(a);return ds(n,{what:e,files:t,formats:i,scope:s}),n}function us(r,{what:e,modules:t,formats:i,scope:s}){if(r.size!==0)return ds(r,{what:e,files:cs(t,{scope:s}),formats:i,scope:s}),lt(r)}function v(r,e){if(!r)throw new Error(e)}function we(r,e){let[t,i]=[r.split("/"),e.split("/")];for(;t.length>0&&t[0]===i[0];)t.shift(),i.shift();if(t.length===0&&i.length===0)return 0;if(t.length<2)return i.length<2&&t>i?1:-1;if(i.length<2)return 1;if(t[0]==="*")return-1;if(i[0]==="*"||t[0]==="node_modules")return 1;if(i[0]==="node_modules")return-1;let[s,o]=[t,i].map(n=>n.join(String.fromCodePoint(0)));if(s<o)return-1;if(s>o)return 1;throw new Error("Unreachable")}var je=r=>r&&[null,Object.prototype].includes(Object.getPrototypeOf(r)),xe=r=>Object.setPrototypeOf(Object.fromEntries(r),null),lt=r=>[...r].toSorted((e,t)=>we(e,t)),Pe=(r,{sorted:e=!0}={})=>{if(!e){let t=Object.create(null);for(let[i,s]of r)t[i]=s instanceof Map?Pe(s,{sorted:e}):s;return t}return xe([...r].toSorted((t,i)=>we(t[0],i[0])).map(([t,i])=>[t,i instanceof Map?Pe(i,{sorted:e}):i]))},lr=r=>new Map(Object.entries(r).map(([e,t])=>[e,je(t)?lr(t):t]));function L(r){if(r.startsWith("/"))return!0;let e=0;for(let t of r.split("/"))if(!(t==="."||t==="")){if(t!=="..")e++;else if(--e<0)return!0}return!1}function Mn(r,e){let t=r instanceof Map;if(t!==e instanceof Map)return!1;if(!t)return r===e;if(r.size!==e.size)return!1;for(let[i,s]of r)if(e.get(i)!==s)return!1;return!0}var ns=r=>r instanceof Map?`{${[...r].map(([e,t])=>`${e}: ${t}`).join(", ")}}`:r;function hs(r,e,t){let i=new Map,s=o=>{for(let[n,a]of o){let l=i.get(n);l===void 0&&i.set(n,l=new Map);for(let[d,u]of a){let p=l.get(d);p===void 0&&l.set(d,p=new Map);for(let[g,m]of u)p.has(g)?v(Mn(p.get(g),m),`${t}: import '${g}' from '${d}' resolves differently ('${ns(p.get(g))}' vs '${ns(m)}')`):p.set(g,m instanceof Map?new Map(m):m)}}};return s(r),s(e),i}function ms(r,e,t){let i=new Map,s=o=>{for(let[n,a]of o){let l=i.get(n);if(l===void 0){i.set(n,a);continue}try{i.set(n,An(a,l,n))}catch(d){throw new Error(`${t}: ${d.message}`,{cause:d})}}};return s(r),s(e),i}function fs(r,e,t,i){if(r.size===0)return new Set(e);let s=cs(t,{scope:i}),o=new Set(e);for(let n of r)s.has(n)||o.add(n);return o}function gs(r,e,t){let i=new Map,s=o=>{for(let[n,a]of o){let l=i.get(n);if(l===void 0){i.set(n,{name:a.name,version:a.version,...a.ecosystem===void 0?{}:{ecosystem:a.ecosystem},files:Object.assign(Object.create(null),a.files)});continue}v(l.name===a.name,`${t}: module '${n}' name mismatch ('${l.name}' vs '${a.name}')`),v(l.version===a.version,`${t}: module '${n}' version mismatch ('${l.version}' vs '${a.version}')`),v(l.ecosystem===a.ecosystem,`${t}: module '${n}' ecosystem mismatch ('${l.ecosystem??"(none)"}' vs '${a.ecosystem??"(none)"}')`);for(let[d,u]of Object.entries(a.files))Object.hasOwn(l.files,d)?v(l.files[d]===u,`${t}: content mismatch for '${_e(n,d)}'`):l.files[d]=u}};return s(r),s(e),i}function $e(r){return r.split("/").includes("node_modules")}function Rn(r){let e="node_modules/",t=r.length;for(;(t=r.lastIndexOf(e,t-1))!==-1;)if(t===0||r[t-1]==="/")return t;return-1}function bs(r){let e="node_modules/",t=Rn(r);if(t===-1)return null;let i=t+e.length,s=r.slice(i).split("/"),o=s[0].startsWith("@")?2:1;if(s.length<=o||s.slice(0,o).some(a=>!a))return null;let n=s.slice(0,o).join("/");return{dir:r.slice(0,i)+n,rel:s.slice(o).join("/"),name:n}}var K=1,vs=0,ys=({name:r,version:e,ecosystem:t,files:i})=>(v(t===void 0||typeof t=="string"),{name:r,version:e,...t===void 0?{}:{ecosystem:t},files:xe(Object.entries(i))}),Ln=r=>bs(r)??{dir:".",rel:r,name:null},_s=(r,e)=>{if(r===void 0)return e;if(e===void 0)return r;let t={};for(let i of[r,e])for(let[s,o]of Object.entries(i))t[s]=lt(new Set([...t[s]??[],...o]));return t},ne=class r{static VERSION=K;version=K;config;entries;modules;formats;imports;executable;reason;constructor({config:e={scope:"full"},entries:t,modules:i,formats:s,imports:o,executable:n,reason:a,version:l=K}={}){v([vs,K].includes(l)),v(["node_modules","full"].includes(e.scope)),this.version=l,this.config=e,this.entries=t??new Set,this.modules=i??new Map,this.formats=s??new Map,this.imports=o??new Map,this.executable=n??new Set,this.reason=a}get sources(){let e=new Map;for(let[t,{files:i}]of this.modules)for(let[s,o]of Object.entries(i))e.set(_e(t,s),o);return e}static isResourceFormat(e){return e==="resource"||e==="resource:base64"||e==="directory"}get hasCode(){for(let[e,{files:t}]of this.modules)for(let i of Object.keys(t))if(!r.isResourceFormat(this.formats.get(_e(e,i))))return!0;return!1}static parse(e){let t=JSON.parse(e);v(t.version===K||t.version===vs),v(["node_modules","full"].includes(t.config?.scope)),v(je(t.formats)),v(je(t.imports));let i=new Map;for(let[d,u]of Object.entries(t.formats)){v(!L(d)),v(ls.has(u),`unknown format '${u}' for ${d}`);let p=d===""?".":d;v(!i.has(p),`duplicate format key '${p}'`),i.set(p,u)}let s=new Map,o=new Set;if(t.version===K){let d=t.config.scope==="full";if(t.modules!==void 0){v(typeof t.modules=="object"&&t.modules!==null);for(let[u,p]of Object.entries(t.modules))v($e(u)),v(!L(u)),v(p?.name&&p.version&&p.files),s.set(u,ys(p))}if(d){v(t.sources&&typeof t.sources=="object");for(let[u,p]of Object.entries(t.sources))v(!$e(u)),v(!L(u)),v(p?.name&&p.version&&p.files),s.set(u,ys(p));v(t.entries===void 0||Array.isArray(t.entries)),o=new Set(t.entries)}else v(t.entries===void 0),v(t.sources===void 0);for(let[,{files:u}]of s)for(let p of Object.keys(u))v(!L(p))}else{v(t.sources);for(let[d,u]of Object.entries(t.sources)){v(!L(d));let{dir:p,rel:g,name:m}=Ln(d);v(!L(p)&&!L(g)),s.has(p)||s.set(p,{name:m,version:null,files:Object.create(null)}),s.get(p).files[g]=u}}let n=new Set;for(let[d,{files:u}]of s)for(let p of Object.keys(u)){let g=_e(d,p);v(!n.has(g),`duplicate file key '${g}' across bundle buckets`),n.add(g)}let a=lr(t.imports),l=d=>{if(typeof d=="string"){v(!L(d));return}v(d instanceof Map&&d.size>0,"import target must be a file or a non-empty {platform: file} map");for(let[u,p]of d)v(typeof u=="string"&&u.length>0&&!u.includes("/"),`invalid platform key '${u}'`),v(typeof p=="string"),v(!L(p))};for(let[,d]of a){v(d instanceof Map);for(let[u,p]of d){v(!L(u)),v(p instanceof Map);for(let[,g]of p)l(g)}}return new r({version:t.version,config:t.config,entries:o,modules:s,formats:i,imports:a,executable:t.version===K?ps(t.executable,{what:"bundle",files:n,formats:i,scope:t.config.scope}):new Set,reason:je(t.reason)?t.reason:void 0})}#e(){let e=[],t=[];for(let[i,{name:s,version:o,ecosystem:n,files:a}]of this.modules){if(Object.keys(a).length===0)continue;let l=$e(i);l&&v(s&&o&&a);let d=xe(Object.entries(a).toSorted((p,g)=>we(p[0],g[0])));(l?e:t).push([i,{name:s,version:o,...n===void 0?{}:{ecosystem:n},files:d}])}return e.sort((i,s)=>we(i[0],s[0])),t.sort((i,s)=>we(i[0],s[0])),{modules:xe(e),sources:xe(t)}}serialize(){let e=lt(this.entries),{modules:t,sources:i}=this.#e(),s=Pe(this.formats),o=Pe(this.imports),n={version:K,config:this.config};this.config.scope==="full"&&Object.assign(n,{entries:e,sources:i}),Object.assign(n,{modules:t,formats:s,imports:o});let a=us(this.executable,{what:"bundle",modules:this.modules,formats:this.formats,scope:this.config.scope});return a!==void 0&&(n.executable=a),this.reason!==void 0&&(n.reason=this.reason),JSON.stringify(n,void 0,2)}withReason(e){let t=[...this.sources.keys()];return new r({version:this.version,config:this.config,entries:this.entries,modules:this.modules,formats:this.formats,imports:this.imports,executable:this.executable,reason:_s(this.reason,{[e]:t})})}merge(e){return v(this.config.scope===e.config.scope,`bundle merge: scope mismatch ('${this.config.scope}' vs '${e.config.scope}')`),new r({config:{scope:this.config.scope},entries:new Set([...this.entries,...e.entries]),modules:gs(this.modules,e.modules,"bundle merge"),formats:ms(this.formats,e.formats,"bundle merge"),imports:hs(this.imports,e.imports,"bundle merge"),executable:fs(this.executable,e.executable,e.modules,this.config.scope),reason:_s(this.reason,e.reason)})}};var zn=/^( *)(```|~~~)/u,ke=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u;function ae(r){let e=[],t=-1,i="",s=0,o=0,n=0;for(let a of r.split(`
20
+ `)){let l=n;n+=a.length+1;let d=zn.exec(a);if(t!==-1){d&&d[2]===i&&d[1].length<=s+3&&(e.push([t,l+a.length]),t=-1);continue}if(d&&d[1].length<=o+3){t=l,i=d[2],s=d[1].length;continue}if(!a.trim())continue;let u=ke.exec(a),p=/^ */u.exec(a)[0].length;u&&u[1].length<=o+3?o=u[0].length:p<o&&(o=0)}return t!==-1&&e.push([t,r.length]),e}function le(r,e){return r.some(([t,i])=>e>=t&&e<i)}function H(r){return String(r??"").replaceAll(/\r\n?/gu,`
21
+ `)}var De=/^## +(.*)$/gmu,Ue=/^### +(.*)$/gmu,ce=/^#### +(.*)$/gmu,cr=/^(.+):(\d+(?:-\d+)?)$/u;function ct(r){return/^[0-9a-f]{7,64}$/iu.test(r)}function F(r,e){let t=ae(r),i=[...r.matchAll(e)].filter(s=>!le(t,s.index));return i.map((s,o)=>({heading:s[1],body:r.slice(s.index+s[0].length+1,i[o+1]?.index)}))}function de(r,e){let t=ae(r),i=[...r.matchAll(e)].find(s=>!le(t,s.index));return i?{head:r.slice(0,i.index),subs:F(r,e)}:{head:r,subs:[]}}function He(r){let e=r.indexOf(`
22
+ `);return e===-1?{title:r.trim(),body:""}:{title:r.slice(0,e).trim(),body:r.slice(e+1)}}function In(r){let e=[];for(let t of r.split(`
23
+ `)){let i=t.trim();if(!i.startsWith("|")||/^[\s:|-]+$/u.test(i)&&i.includes("-"))continue;let s=i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(o=>o.trim());e.push(s)}return e}function Fe(r){let e=In(r);if(e.length<2)return[];let t=e[0].map(s=>s.toLowerCase()),i=[];for(let s of e.slice(1)){if(s.length===t.length&&s.every((n,a)=>n.toLowerCase()===t[a]))continue;let o={};t.forEach((n,a)=>{n&&(o[n]=s[a]??"")}),i.push(o)}return i}function ws(r){let e=Object.create(null),t=Object.create(null),i=[],s=null,o="",n=[],a="",l=(p,g,m)=>{!p||p in e||(e[p]=m.trim(),t[p]=g)},d=()=>{s&&l(s,o,n.join(`
24
+ `)),s=null,o="",n=[]},u=p=>{(s?n:i).push(p)};for(let p of r.split(`
25
+ `)){let g=/^ {0,3}(```|~~~)/u.exec(p),m=g!==null&&(!a||g[1]===a);if(m&&(a=a?"":g[1]),m||a){u(p);continue}if(!p.trim()){s?d():i.push(p);continue}let b=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(b){d();let f=b[1].trim(),y=b[2],$;for(;($=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(y))!==null;)l(f.toLowerCase(),f,y.slice(0,$.index)),f=$[1].trim(),y=y.slice($.index+$[0].length);s=f.toLowerCase(),o=f,n=[y];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){d();continue}u(p)}return d(),{fields:e,labels:t,prose:i.join(`
26
+ `).trim()}}function dt(r){let e=(r||"").trim(),t="",i=Se(e);i&&(e=i.label.trim(),t=i.url.trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=o[1]);let l=[...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)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(l);d&&(l=d[1],s||(s=d[2]));let u=cr.exec(l);return u?(s||(s=u[2]),{file:u[1],line:s,locationLink:t}):{file:l,line:s||"?",locationLink:t}}function dr(r){return r.replaceAll("**","")}function Se(r){let e=String(r??""),t=On(e,Tn(e)),i=Nn(e),s=e.indexOf("]");for(let o=e.indexOf("[");o!==-1;o=e.indexOf("[",o+1)){for(;s!==-1&&s<=o;)s=e.indexOf("]",s+1);for(let n of[s,t.get(o)??-1]){if(n===-1||n===o+1||e[n+1]!=="(")continue;let a=Bn(e,n+1,i);if(a!==null)return{label:e.slice(o+1,n),url:a,index:o}}}return null}function On(r,e){let t=new Map,i=[];for(let s=0;s<r.length;s++){let o=r[s];xs(r,s)?s++:o==="`"?s=e.get(s)??s:o==="["?i.push(s):o==="]"&&i.length>0&&t.set(i.pop(),s)}return t}function Tn(r){let e=[];for(let s=r.indexOf("`");s!==-1;s=r.indexOf("`",s)){let o=1;for(;r[s+o]==="`";)o++;e.push([s,o]),s+=o}let t=new Map,i=new Map;for(let s=e.length-1;s>=0;s--){let[o,n]=e[s],a=i.get(n);a!==void 0&&t.set(o,a+n-1),i.set(n,o)}return t}function Nn(r){let e=r.length,t=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1),s=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1);for(let l=e-1;l>=0;l--)t[l]=r[l]===")"?l:t[l+1],i[l]=/\s/u.test(r[l])?l:i[l+1],s[l]=r[l]===">"?l:s[l+1],o[l]=r[l]===`
27
+ `?l:o[l+1];let n=new Map,a=[];for(let l=0;l<e;l++){let d=r[l];xs(r,l)?l++:i[l]===l?a.length=0:d==="("?a.push(l):d===")"&&a.length>0&&n.set(a.pop(),l)}return{balanced:n,nextClose:t,nextSpace:i,nextAngle:s,nextLine:o}}function Bn(r,e,t){let i=Pn(r,e,t);if(i)return i;let s=t.balanced.get(e);if(s!==void 0)return s>e+1?r.slice(e+1,s):null;let o=t.nextClose[e+1],n=t.nextSpace[e+1];return o===-1||o===e+1||n!==-1&&n<o?null:r.slice(e+1,o)}function Pn(r,e,t){if(r[e+1]!=="<")return"";let i=t.nextAngle[e+2],s=t.nextLine[e+2];return i===-1||s!==-1&&s<i||r[i+1]!==")"?"":r.slice(e+2,i)}var jn=/\\([!-/:-@[-`{-~])/gu,Dn=/[!-/:-@[-`{-~]/u;function xs(r,e){return r[e]==="\\"&&Dn.test(r[e+1]??"")}function $s(r){return typeof r=="string"?r.replace(jn,"$1"):r}function ks(r){let e=/^\[(.+)\]$/u.exec(r.trim());return e?e[1].trim():r.trim()}function pe(r){let e=(r||"").trim();return/^[-–—]+$/u.test(e)?"":e}var Un=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu;function Hn(r){switch(r.toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"HIGH_BUG":return"high_bug";case"BUG":return"bug";case"INFO":case"INFORMATIONAL":return"informational";default:return"medium"}}var Es=r=>String(r??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),Ss=new Map([["high",8],["medium",6],["low",4]]);function Fn(r){if(r!==void 0)return Ss.get(Es(r))??Ss.get("medium")}var Vn=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function As(r){let t=H(r).trim().split(Un);if(t.length===1)return null;let i=[];for(let s=1;s<t.length;s+=2){let o=Hn(t[s]);for(let n of t[s+1].split(/^### /mu).slice(1)){let a=qn(n,o);a&&i.push(a)}}return i.length===0?null:{type:"security",source:"deepsec",findings:i}}function qn(r,e){let{title:t,body:i}=He(r);if(!t)return null;let s=i.replace(/\n---\s*$/u,"").trim(),o={};for(let y of s.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu))o[y[1].trim().toLowerCase()]=y[2].trim();let n=/^\*\*Recommendation:\*\*\s*/mu.exec(s),a=s,l="";n&&(a=s.slice(0,n.index),l=s.slice(n.index+n[0].length).trim());let d=a.split(`
28
+ `).filter(y=>!/^\s*- \*\*/u.test(y)).join(`
29
+ `).replaceAll("**","").trim(),u=[t,d].filter(Boolean).join(`
14
30
 
15
- `),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),b=(o.lines||"").split(",").map(v=>v.trim()).find(Boolean)||"?",h={file:p,line:b,severity:e,description:f};c&&(h.recommendation=c.replaceAll("**",""));let g=Ns(o.confidence);g!==void 0&&(h.confidence=g);let m=Os.get(li(o.revalidation));return m&&(h.revalidate=m,h.revalidateSource="deepsec",o.reasoning&&(h.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(h.slug=o.slug),h}var di={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var We={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium"};var Ke=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Ps=new Set(Ke);function pi(r){return Ps.has(r?.revalidate)?r.revalidate:""}function Pt(r,e=r?.source){return Object.hasOwn(We,e)||pi(r)==="revalidation"}function Dt(r){if(!r)return"";for(let e of r.split(`
16
- `))if(e.trim())return e.trim();return""}function Ht(r){return Number.isFinite(parseInt(r?.line,10))?`${r.file}:${r.line}`:r?.file??""}function Ut(r){if(typeof r!="string"||r.length===0)return!1;try{let e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function Ds(r,e){let t=K(r),i=0;return r.split(`
17
- `).map(s=>{let o=i;return i+=s.length+1,Z(t,o)?s:e(s)}).join(`
18
- `)}function ui(r){return Ds(String(r??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var Hs=new Map(Object.entries(di).map(([r,e])=>[e.toLowerCase(),r])),mi=new Map(Object.entries(We).map(([r,e])=>[e.toLowerCase(),r])),Us=new Set(Ke);function C(r){let e=/(`+)(.+?)\1(?!`)/u.exec(String(r??""));if(!e)return null;let t=e[2];if(t.length>2&&t.startsWith(" ")&&t.endsWith(" ")){let i=t.slice(1,-1);if(i.startsWith("`")||i.endsWith("`"))return i}return t}function Ze(r){let e=ce(String(r??""));return e?.index===0?{label:e.label,url:e.url}:null}function fi(r){let e=/^<(https?:[^>\s]*)>$/u.exec(r.trim());return e?e[1]:null}function gi(r){let e=Ot.exec(r);return e?{file:e[1],line:e[2]}:{file:r,line:"?"}}function js(r){let e=r.indexOf(".");return e>0?{exportName:r.slice(0,e),methodName:r.slice(e+1)}:{exportName:r}}function Q(r){let e=String(r??"").trim();return Hs.get(e.toLowerCase())??e}function Fs(r){let e={},t=r.trim(),i=/ · (`+)(.+?)\1$/u.exec(t);i&&(Object.assign(e,js(C(i[0]))),t=t.slice(0,i.index));let s=Ze(t),o=C(s?s.label:t);return o!==null&&Object.assign(e,gi(o)),s&&Ut(s.url)&&(e.location=s.url),e}var hi=" \xB7 flagged critical by the analyzer",Vs=" (varies across reports \u2014 ";function qs(r){let e={},t=r.trim();t.endsWith(hi)&&(e.critical=!0,t=t.slice(0,-hi.length));let i=t.indexOf(Vs);i!==-1&&(t=t.slice(0,i));let s=/^(.*?) — corrected (from|to) (.*)$/u.exec(t);return s?s[2]==="from"?(e.severity=Q(s[3]),e.correctedSeverity=Q(s[1])):(e.severity=Q(s[1]),e.correctedSeverity=Q(s[3])):e.severity=Q(t),e}var Gs=new Set(["max","xhigh","high","medium","low","minimal"]),Ws=new Set(["list","isolate"]);function Ks(r){return/\d/u.test(r)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(r)}function Ye(r){let e=r.trim(),t=mi.get(e.toLowerCase());if(t)return{source:t};let i={},s=[];for(let o of e.split(" \xB7 ").map(n=>n.trim()).filter(Boolean))o==="revalidate"&&!i.revalidate?i.revalidate="revalidation":Ws.has(o)&&!i.exportsMode?i.exportsMode=o:Gs.has(o)&&!i.effort?i.effort=o:s.push(o);return s.length>1?[i.type,i.model]=s:s.length===1&&(i[Ks(s[0])?"model":"type"]=s[0]),{run:i}}function jt(r){let e=r.trim(),t=Ze(e);return t?t.label.trim():fi(e)??e}function Zs(r){let e=Ze(r.trim());if(e){let t=e.url.split("/").at(-1)??"";return qe(t)?t:C(e.label)??t}return C(r)??r.trim()}function Ys(r){let e=C(r)??r.trim(),t=e.lastIndexOf("@");return{npm:t>0?{name:e.slice(0,t),version:e.slice(t+1)}:{name:e}}}function Js(r){let e=r.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":Us.has(e)?e:void 0}var Xs=new Map([["location",(r,e)=>Object.assign(r,Fs(e))],["severity",(r,e)=>Object.assign(r,qs(e))],["confidence",(r,e)=>{let t=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);t&&(r.confidence=Number(t[1]))}],["revalidation",(r,e)=>{let t=Js(e);t&&(r.revalidate=t)}],["revalidated by",(r,e)=>{let t=e.trim();t&&(r.revalidateSource=mi.get(t.toLowerCase())??t)}],["repository",(r,e)=>{r.repo={github:jt(e)}}],["introduced in",(r,e)=>{r.commitHash=Zs(e)}],["package",(r,e)=>{r.package=Ys(e)}],["priority",(r,e)=>{r.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}],["found while analyzing",(r,e)=>{r.discoveredIn=C(e)??e}],["detailed report",(r,e)=>{r.reportPath=C(e)??e}],["commit audited",(r,e)=>{r.auditedCommit=C(e)??e}],["id",(r,e)=>{r.id=C(e)??e}],...[["category","category"],["status","status"],["branch","branch"],["date created","dateCreated"],["detected at","detectedAt"],["committed at","committedAt"],["poc status","pocStatus"],["variant of","parent"],["slug","slug"]].map(([r,e])=>[r,(t,i)=>{t[e]=i}])]);function bi(r,e,t){let i=Xs.get(e.trim().toLowerCase());i&&i(r,t.trim())}var Qs=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function vi(r){let e=r.split(`
19
- `),t=0,i=()=>{for(;t<e.length&&!e[t].trim();)t++},s=()=>{let a=[];for(;t<e.length;){let c=Qs.exec(e[t]);if(!c)break;a.push([c[1].trim(),c[2].trim()]),t++}return a};i();let o=s();if(o.length>0)return{title:"",facts:o,rest:e.slice(t).join(`
20
- `)};let n=[];for(;t<e.length&&e[t].trim();)n.push(e[t++]);return i(),o=s(),o.length===0?{title:"",facts:o,rest:r}:{title:de(n.join(`
31
+ `),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),g=(o.lines||"").split(",").map(y=>y.trim()).find(Boolean)||"?",m={file:p,line:g,severity:e,description:u};l&&(m.recommendation=l.replaceAll("**",""));let b=Fn(o.confidence);b!==void 0&&(m.confidence=b);let f=Vn.get(Es(o.revalidation));return f&&(m.revalidate=f,m.revalidateSource="deepsec",o.reasoning&&(m.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(m.slug=o.slug),m}var Cs={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var pt={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium"};var ut=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Gn=new Set(ut);function Ms(r){return Gn.has(r?.revalidate)?r.revalidate:""}function pr(r,e=r?.source){return Object.hasOwn(pt,e)||Ms(r)==="revalidation"}function ur(r){if(!r)return"";for(let e of r.split(`
32
+ `))if(e.trim())return e.trim();return""}function hr(r){return Number.isFinite(parseInt(r?.line,10))?`${r.file}:${r.line}`:r?.file??""}function mr(r){if(typeof r!="string"||r.length===0)return!1;try{let e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function Wn(r,e){let t=ae(r),i=0;return r.split(`
33
+ `).map(s=>{let o=i;return i+=s.length+1,le(t,o)?s:e(s)}).join(`
34
+ `)}function Rs(r){return Wn(String(r??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var Kn=new Map(Object.entries(Cs).map(([r,e])=>[e.toLowerCase(),r])),zs=new Map(Object.entries(pt).map(([r,e])=>[e.toLowerCase(),r])),Jn=new Set(ut);function P(r){let e=/(`+)(.+?)\1(?!`)/u.exec(String(r??""));if(!e)return null;let t=e[2];if(t.length>2&&t.startsWith(" ")&&t.endsWith(" ")){let i=t.slice(1,-1);if(i.startsWith("`")||i.endsWith("`"))return i}return t}function ht(r){let e=Se(String(r??""));return e?.index===0?{label:e.label,url:e.url}:null}function Is(r){let e=/^<(https?:[^>\s]*)>$/u.exec(r.trim());return e?e[1]:null}function Os(r){let e=cr.exec(r);return e?{file:e[1],line:e[2]}:{file:r,line:"?"}}function Zn(r){let e=r.indexOf(".");return e>0?{exportName:r.slice(0,e),methodName:r.slice(e+1)}:{exportName:r}}function ue(r){let e=String(r??"").trim();return Kn.get(e.toLowerCase())??e}function Yn(r){let e={},t=r.trim(),i=/ · (`+)(.+?)\1$/u.exec(t);i&&(Object.assign(e,Zn(P(i[0]))),t=t.slice(0,i.index));let s=ht(t),o=P(s?s.label:t);return o!==null&&Object.assign(e,Os(o)),s&&mr(s.url)&&(e.location=s.url),e}var Ls=" \xB7 flagged critical by the analyzer",Xn=" (varies across reports \u2014 ";function Qn(r){let e={},t=r.trim();t.endsWith(Ls)&&(e.critical=!0,t=t.slice(0,-Ls.length));let i=t.indexOf(Xn);i!==-1&&(t=t.slice(0,i));let s=/^(.*?) — corrected (from|to) (.*)$/u.exec(t);return s?s[2]==="from"?(e.severity=ue(s[3]),e.correctedSeverity=ue(s[1])):(e.severity=ue(s[1]),e.correctedSeverity=ue(s[3])):e.severity=ue(t),e}var ea=new Set(["max","xhigh","high","medium","low","minimal"]),ta=new Set(["list","isolate"]);function ra(r){return/\d/u.test(r)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(r)}function mt(r){let e=r.trim(),t=zs.get(e.toLowerCase());if(t)return{source:t};let i={},s=[];for(let o of e.split(" \xB7 ").map(n=>n.trim()).filter(Boolean))o==="revalidate"&&!i.revalidate?i.revalidate="revalidation":ta.has(o)&&!i.exportsMode?i.exportsMode=o:ea.has(o)&&!i.effort?i.effort=o:s.push(o);return s.length>1?[i.type,i.model]=s:s.length===1&&(i[ra(s[0])?"model":"type"]=s[0]),{run:i}}function fr(r){let e=r.trim(),t=ht(e);return t?t.label.trim():Is(e)??e}function ia(r){let e=ht(r.trim());if(e){let t=e.url.split("/").at(-1)??"";return ct(t)?t:P(e.label)??t}return P(r)??r.trim()}function sa(r){let e=P(r)??r.trim(),t=e.lastIndexOf("@");return{npm:t>0?{name:e.slice(0,t),version:e.slice(t+1)}:{name:e}}}function oa(r){let e=r.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":Jn.has(e)?e:void 0}var na=new Map([["location",(r,e)=>Object.assign(r,Yn(e))],["severity",(r,e)=>Object.assign(r,Qn(e))],["confidence",(r,e)=>{let t=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);t&&(r.confidence=Number(t[1]))}],["revalidation",(r,e)=>{let t=oa(e);t&&(r.revalidate=t)}],["revalidated by",(r,e)=>{let t=e.trim();t&&(r.revalidateSource=zs.get(t.toLowerCase())??t)}],["repository",(r,e)=>{r.repo={github:fr(e)}}],["introduced in",(r,e)=>{r.commitHash=ia(e)}],["package",(r,e)=>{r.package=sa(e)}],["priority",(r,e)=>{r.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}],["found while analyzing",(r,e)=>{r.discoveredIn=P(e)??e}],["detailed report",(r,e)=>{r.reportPath=P(e)??e}],["commit audited",(r,e)=>{r.auditedCommit=P(e)??e}],["id",(r,e)=>{r.id=P(e)??e}],...[["category","category"],["status","status"],["branch","branch"],["date created","dateCreated"],["detected at","detectedAt"],["committed at","committedAt"],["poc status","pocStatus"],["variant of","parent"],["slug","slug"]].map(([r,e])=>[r,(t,i)=>{t[e]=i}])]);function Ts(r,e,t){let i=na.get(e.trim().toLowerCase());i&&i(r,t.trim())}var aa=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function Ns(r){let e=r.split(`
35
+ `),t=0,i=()=>{for(;t<e.length&&!e[t].trim();)t++},s=()=>{let a=[];for(;t<e.length;){let l=aa.exec(e[t]);if(!l)break;a.push([l[1].trim(),l[2].trim()]),t++}return a};i();let o=s();if(o.length>0)return{title:"",facts:o,rest:e.slice(t).join(`
36
+ `)};let n=[];for(;t<e.length&&e[t].trim();)n.push(e[t++]);return i(),o=s(),o.length===0?{title:"",facts:o,rest:r}:{title:Ee(n.join(`
21
37
  `).trim()),facts:o,rest:e.slice(t).join(`
22
- `)}}function de(r){return ui(r)}function _i(r,e){let t=new RegExp(`^#{${e}} +(.*)$`,"gmu"),i=K(r),s=[...r.matchAll(t)].filter(a=>!Z(i,a.index)),o=r.slice(0,s[0]?.index??r.length).trim(),n=s.map((a,c)=>({label:a[1].trim(),body:r.slice(a.index+a[0].length,s[c+1]?.index).trim()}));return{lead:o,sections:n}}var eo=/^(\d+)\. (.*)$/u;function yi(r){let e=[],t=K(r),i=0;for(let s of r.split(`
23
- `)){let o=Z(t,i)?null:eo.exec(s);i+=s.length+1,o?e.push({ref:o[2].trim(),indent:o[1].length+2,note:[]}):e.length>0&&e.at(-1).note.push(s)}return e.map(s=>to(s))}function to({ref:r,indent:e,note:t}){let i={},s=Ze(r),o=fi(r),n=o===null?C(s?s.label:r):null;n!==null&&Object.assign(i,gi(n));let a=s?s.url:o;Ut(a)&&(i.url=a);let c=de(t.map(d=>d.slice(Math.min(e,/^ */u.exec(d)[0].length))).join(`
24
- `).trim());return c&&(i.text=c),i}var wi=new Map([["impact","impact"],["reproduction","reproduction"],["recommendation","recommendation"],["confidence reasoning","confidenceReason"],["revalidation verdict","revalidateVerdict"],["revalidation recommendation","revalidateRecommendation"]]),ro=[...wi.keys()];function xi(r){let e=r.length,t=1/0;for(let i=r.length-1;i>=0;i--){let s=ro.indexOf(r[i].label.toLowerCase());if(s===-1||s>=t)break;t=s,e=i}return{paragraphs:r.slice(0,e),fields:r.slice(e).map(i=>[wi.get(i.label.toLowerCase()),i.body])}}function $i(r,e,t){let i=[],s=Dt(e),o=r.endsWith("\u2026")?r.slice(0,-1).trimEnd():"";!r||s===r||o&&s.startsWith(o)?i.push(e):i.push(r,e);for(let{label:n,body:a}of t)i.push(a?`**${n}:** ${a}`:`**${n}:**`);return i.filter(Boolean).join(`
38
+ `)}}function Ee(r){return Rs(r)}function Bs(r,e){let t=new RegExp(`^#{${e}} +(.*)$`,"gmu"),i=ae(r),s=[...r.matchAll(t)].filter(a=>!le(i,a.index)),o=r.slice(0,s[0]?.index??r.length).trim(),n=s.map((a,l)=>({label:a[1].trim(),body:r.slice(a.index+a[0].length,s[l+1]?.index).trim()}));return{lead:o,sections:n}}var la=/^(\d+)\. (.*)$/u;function Ps(r){let e=[],t=ae(r),i=0;for(let s of r.split(`
39
+ `)){let o=le(t,i)?null:la.exec(s);i+=s.length+1,o?e.push({ref:o[2].trim(),indent:o[1].length+2,note:[]}):e.length>0&&e.at(-1).note.push(s)}return e.map(s=>ca(s))}function ca({ref:r,indent:e,note:t}){let i={},s=ht(r),o=Is(r),n=o===null?P(s?s.label:r):null;n!==null&&Object.assign(i,Os(n));let a=s?s.url:o;mr(a)&&(i.url=a);let l=Ee(t.map(d=>d.slice(Math.min(e,/^ */u.exec(d)[0].length))).join(`
40
+ `).trim());return l&&(i.text=l),i}var js=new Map([["impact","impact"],["reproduction","reproduction"],["recommendation","recommendation"],["confidence reasoning","confidenceReason"],["revalidation verdict","revalidateVerdict"],["revalidation recommendation","revalidateRecommendation"]]),da=[...js.keys()];function Ds(r){let e=r.length,t=1/0;for(let i=r.length-1;i>=0;i--){let s=da.indexOf(r[i].label.toLowerCase());if(s===-1||s>=t)break;t=s,e=i}return{paragraphs:r.slice(0,e),fields:r.slice(e).map(i=>[js.get(i.label.toLowerCase()),i.body])}}function Us(r,e,t){let i=[],s=ur(e),o=r.endsWith("\u2026")?r.slice(0,-1).trimEnd():"";!r||s===r||o&&s.startsWith(o)?i.push(e):i.push(r,e);for(let{label:n,body:a}of t)i.push(a?`**${n}:** ${a}`:`**${n}:**`);return i.filter(Boolean).join(`
25
41
 
26
- `)}var io=/^<!--\s*DeepView findings export\b[^>]*-->/u,so=/^Case \d+ of \d+(?:\s|$)/u,oo=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,no=new Set(["evidence","severity correction","comment"]);function Si(r){let e=z(r).trim();if(!io.test(e))return null;let{head:t,subs:i}=J(e,ke),s=[];for(let{heading:o,body:n}of i){if(o.trim().toLowerCase()==="summary")continue;let a=ao(o);for(let c of T(n,Se))s.push(co(c,a))}return uo(lo(t),s)}function ao(r){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(r.trim());return Q(e?e[1]:r)}function lo(r){let e=new Map;for(let t of r.matchAll(oo)){let i=t[1].trim().toLowerCase();e.has(i)||e.set(i,t[2].trim())}return{sources:(e.get("source")??"").split(",").map(t=>Ye(t).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(t=>t.trim()).filter(Boolean),repo:e.has("repository")?jt(e.get("repository")):""}}function co({heading:r,body:e},t){let i=r.trim().replace(/^\d+\.\s+/u,""),s=J(e,Y).subs.filter(o=>so.test(o.heading.trim()));return s.length===0?[ki(e,4,i,t)]:s.map(o=>ki(o.body,5,i,t))}function ki(r,e,t,i){let{title:s,facts:o,rest:n}=vi(r),{lead:a,sections:c}=_i(n,e),d={file:"unknown",line:"?"},f=null;for(let[_,A]of o)_.trim().toLowerCase()==="analyzer"?f=Ye(A):bi(d,_,A);d.severity||(d.severity=i||"medium");let p=s||t,b=p!=="Untitled finding"&&p!==Ht(d),h=c.filter(_=>!no.has(_.label.toLowerCase())).map(_=>({label:_.label,body:de(_.body)})),{paragraphs:g,fields:m}=xi(h);d.description=$i(b?p:"",de(a),g);let v=c.filter(_=>_.label.toLowerCase()==="evidence").flatMap(_=>yi(_.body));v.length>0&&(d.evidence=v);for(let[_,A]of m)d[_]=A;let $=c.find(_=>_.label.toLowerCase()==="severity correction");return $?.body&&(d.correctedSeverityReason=de($.body)),{finding:d,analyzer:f}}function po(r,e){let t={source:null,run:{}};if(e.some(s=>s.analyzer!==null)){let s=new Set(e.map(o=>o.analyzer?.source??null));s.size===1&&!s.has(null)&&([t.source]=s);for(let o of e)o.analyzer?.run?Object.assign(o.finding,o.analyzer.run):o.analyzer?.source&&!t.source&&(o.finding.source=o.analyzer.source);return t}let i=r.analyzers.length===1?Ye(r.analyzers[0]):null;return i?.source?t.source=i.source:i?.run?t.run=i.run:r.analyzers.length===0&&r.sources.length===1&&([t.source]=r.sources),t}function uo(r,e){let t=e.flat(),{source:i,run:s}=po(r,t),o={},n=new Set(t.map(d=>d.finding.type).filter(Boolean)),a=s.type??(n.size===1?[...n][0]:null)??(i?"security":null);a&&(o.type=a),i&&(o.source=i);for(let d of["model","effort","exportsMode"])s[d]&&(o[d]=s[d]);r.repo&&(o.repo={github:r.repo});let c=e.map(d=>d.map(f=>f.finding));return c.every(d=>d.length===1)?o.findings=c.flat():o.groups=c,o}var ho=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Ei(r){let e=mo(r);if(!e)return null;let{severity:t,description:i,location:s,file:o,line:n}=e;return s?{severity:t,description:i,location:s}:{severity:t,description:i,file:o,line:n}}function mo(r){let e=r.indexOf(`
27
- `),t=(e===-1?r:r.slice(0,e)).trim();if(!t)return null;let i=e===-1?"":r.slice(e+1),{sectionsText:s,metaText:o}=fo(i),n=go(s),a=bo(o),{file:c,line:d,locationLink:f}=vo(n.location||""),p=(a.severity||"").toLowerCase();return{severity:ho.has(p)?p:"medium",description:_o(t,n),location:f,file:c||"unknown",line:d}}function fo(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function go(r){let e={},t=r.split(/^## /mu);for(let i=1;i<t.length;i++){let s=t[i],o=s.indexOf(`
28
- `),n=(o===-1?s:s.slice(0,o)).trim().toLowerCase(),a=(o===-1?"":s.slice(o+1)).trim();n&&(e[n]=a)}return e}function bo(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function vo(r){let e="",t="?",i="",s=r.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(s){e=s[1].trim(),i=s[2];let n=s[2].match(/#L(\d+)/u);n&&(t=n[1])}else e=r.trim(),i=r.trim();let o=e.match(/^(.+):(\d+)$/u);return o&&(e=o[1],t==="?"&&(t=o[2])),{file:e,line:t,locationLink:i}}function _o(r,e){let t=[r];return e.details&&t.push(e.details),e.impact&&t.push(`Impact: ${e.impact}`),e["reproduction steps"]&&t.push(`Reproduction: ${e["reproduction steps"]}`),yo(t.join(`
42
+ `)}var pa=/^<!--\s*DeepView findings export\b[^>]*-->/u,ua=/^Case \d+ of \d+(?:\s|$)/u,ha=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,ma=new Set(["evidence","severity correction","comment"]);function Fs(r){let e=H(r).trim();if(!pa.test(e))return null;let{head:t,subs:i}=de(e,De),s=[];for(let{heading:o,body:n}of i){if(o.trim().toLowerCase()==="summary")continue;let a=fa(o);for(let l of F(n,Ue))s.push(ba(l,a))}return ya(ga(t),s)}function fa(r){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(r.trim());return ue(e?e[1]:r)}function ga(r){let e=new Map;for(let t of r.matchAll(ha)){let i=t[1].trim().toLowerCase();e.has(i)||e.set(i,t[2].trim())}return{sources:(e.get("source")??"").split(",").map(t=>mt(t).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(t=>t.trim()).filter(Boolean),repo:e.has("repository")?fr(e.get("repository")):""}}function ba({heading:r,body:e},t){let i=r.trim().replace(/^\d+\.\s+/u,""),s=de(e,ce).subs.filter(o=>ua.test(o.heading.trim()));return s.length===0?[Hs(e,4,i,t)]:s.map(o=>Hs(o.body,5,i,t))}function Hs(r,e,t,i){let{title:s,facts:o,rest:n}=Ns(r),{lead:a,sections:l}=Bs(n,e),d={file:"unknown",line:"?"},u=null;for(let[_,T]of o)_.trim().toLowerCase()==="analyzer"?u=mt(T):Ts(d,_,T);d.severity||(d.severity=i||"medium");let p=s||t,g=p!=="Untitled finding"&&p!==hr(d),m=l.filter(_=>!ma.has(_.label.toLowerCase())).map(_=>({label:_.label,body:Ee(_.body)})),{paragraphs:b,fields:f}=Ds(m);d.description=Us(g?p:"",Ee(a),b);let y=l.filter(_=>_.label.toLowerCase()==="evidence").flatMap(_=>Ps(_.body));y.length>0&&(d.evidence=y);for(let[_,T]of f)d[_]=T;let $=l.find(_=>_.label.toLowerCase()==="severity correction");return $?.body&&(d.correctedSeverityReason=Ee($.body)),{finding:d,analyzer:u}}function va(r,e){let t={source:null,run:{}};if(e.some(s=>s.analyzer!==null)){let s=new Set(e.map(o=>o.analyzer?.source??null));s.size===1&&!s.has(null)&&([t.source]=s);for(let o of e)o.analyzer?.run?Object.assign(o.finding,o.analyzer.run):o.analyzer?.source&&!t.source&&(o.finding.source=o.analyzer.source);return t}let i=r.analyzers.length===1?mt(r.analyzers[0]):null;return i?.source?t.source=i.source:i?.run?t.run=i.run:r.analyzers.length===0&&r.sources.length===1&&([t.source]=r.sources),t}function ya(r,e){let t=e.flat(),{source:i,run:s}=va(r,t),o={},n=new Set(t.map(d=>d.finding.type).filter(Boolean)),a=s.type??(n.size===1?[...n][0]:null)??(i?"security":null);a&&(o.type=a),i&&(o.source=i);for(let d of["model","effort","exportsMode"])s[d]&&(o[d]=s[d]);r.repo&&(o.repo={github:r.repo});let l=e.map(d=>d.map(u=>u.finding));return l.every(d=>d.length===1)?o.findings=l.flat():o.groups=l,o}var _a=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Vs(r){let e=wa(r);if(!e)return null;let{severity:t,description:i,location:s,file:o,line:n}=e;return s?{severity:t,description:i,location:s}:{severity:t,description:i,file:o,line:n}}function wa(r){let e=r.indexOf(`
43
+ `),t=(e===-1?r:r.slice(0,e)).trim();if(!t)return null;let i=e===-1?"":r.slice(e+1),{sectionsText:s,metaText:o}=xa(i),n=$a(s),a=ka(o),{file:l,line:d,locationLink:u}=Sa(n.location||""),p=(a.severity||"").toLowerCase();return{severity:_a.has(p)?p:"medium",description:Ea(t,n),location:u,file:l||"unknown",line:d}}function xa(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function $a(r){let e={},t=r.split(/^## /mu);for(let i=1;i<t.length;i++){let s=t[i],o=s.indexOf(`
44
+ `),n=(o===-1?s:s.slice(0,o)).trim().toLowerCase(),a=(o===-1?"":s.slice(o+1)).trim();n&&(e[n]=a)}return e}function ka(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function Sa(r){let e="",t="?",i="",s=r.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(s){e=s[1].trim(),i=s[2];let n=s[2].match(/#L(\d+)/u);n&&(t=n[1])}else e=r.trim(),i=r.trim();let o=e.match(/^(.+):(\d+)$/u);return o&&(e=o[1],t==="?"&&(t=o[2])),{file:e,line:t,locationLink:i}}function Ea(r,e){let t=[r];return e.details&&t.push(e.details),e.impact&&t.push(`Impact: ${e.impact}`),e["reproduction steps"]&&t.push(`Reproduction: ${e["reproduction steps"]}`),Aa(t.join(`
29
45
 
30
- `))}function yo(r){return r.replaceAll("**","")}var wo=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Ri(r){let e=z(r).trim();if(!e.startsWith("# "))return null;let t=e.split(/^# /mu).filter(s=>s.trim().length>0),i=[];for(let s of t){let o=xo(s);o&&i.push(o)}return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function xo(r){let{title:e,body:t}=Ee(r);if(!e)return null;let{sectionsText:i,metaText:s}=$o(t),o=ko(i),n=So(s),a=Ro(o.evidence||""),{file:c,line:d,locationLink:f}=Mi(o.location||a[0]?.ref||""),p=(n.severity||"").toLowerCase(),b=wo.has(p)?p:"medium",h=Lo(e,o,a.length>0),g={file:c||"unknown",line:d,severity:b,description:h};f&&(g.location=f),a.length>0&&(g.evidence=a.map(Mo)),o["reproduction steps"]&&(g.reproduction=Eo(o["reproduction steps"])),o["recommended fix"]&&(g.recommendation=o["recommended fix"]),n.repository&&(g.repo={github:n.repository}),n.branch&&(g.branch=n.branch),n["date created"]&&(g.dateCreated=n["date created"]),n.status&&(g.status=n.status),n.category&&(g.category=n.category);let m=Ei(r);return m&&(g._idBasis=m),g}function $o(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function ko(r){let e={};for(let t of r.split(/^## /mu).slice(1)){let{title:i,body:s}=Ee(t),o=i.toLowerCase();o&&(e[o]=s.trim())}return e}function So(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function Mi(r){let e="",t="?",i="",s=ce(r);if(s){e=s.label.trim(),i=s.url.trim();let n=i.match(/#L(\d+)(?:-L?(\d+))?/u);n&&(t=n[2]?`${n[1]}-${n[2]}`:n[1])}else e=r.trim(),i=r.trim();e=oi(e.replaceAll("`","")).trim();let o=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return o&&(e=o[1],t==="?"&&(t=o[3]?`${o[2]}-${o[3]}`:o[2])),{file:e,line:t,locationLink:i,linked:s!==null}}function Eo(r){let e=r.split(`
31
- `),t=e.findIndex(a=>a.trim());if(t===-1||!le.test(e[t])||e.some((a,c)=>c!==t&&le.test(a)))return r;let i=e[t].replace(/^ */u,""),s=i.replace(le,"");if(!s.trim())return r;let o=Ai(s)??Ai(i);if(o===null&&(le.test(s)||Co.test(i)))return r;let n=o===null?[s]:o.length===1?[o[0].step]:o.map(({number:a,step:c})=>`${a}. ${c}`);return e.splice(t,1,...n),e.join(`
32
- `)}var Ao=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,Co=/^\d{1,9}\)(?=[ \t]|$)/u;function Ai(r){let e=[...r.matchAll(Ao)];if(e.length===0||e[0].index!==0)return null;let t=[];for(let[i,s]of e.entries()){let o=Number(s[1]);if(i>0&&o<=t[i-1].number)return null;let n=r.slice(s.index+s[0].length,e[i+1]?.index).trim();if(!n)return null;t.push({number:o,step:n})}return t}var Ci=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function Ro(r){let e=[];for(let t of r.split(`
33
- `))Ci.test(t)?e.push({ref:t.replace(Ci,"").trim(),note:[]}):e.length>0&&t.trim()&&e.at(-1).note.push(t.trim());if(e.length===0){let t=r.split(`
34
- `).map(o=>o.trim()).filter(Boolean),i=t.findIndex(o=>ce(o)!==null);if(i===-1&&t.length!==1)return[];let s=i===-1?0:i;e.push({ref:t[s],note:t.filter((o,n)=>n!==s)})}return e.filter(t=>t.ref)}function Mo({ref:r,note:e}){let{file:t,line:i,locationLink:s,linked:o}=Mi(r),n={file:t||"unknown",line:i};s&&o&&(n.url=s);let a=e.join(`
35
- `);return a&&(n.text=a),n}function Lo(r,e,t){let i=[r];return e.details&&i.push(e.details),e.evidence&&!t&&i.push(`**Evidence:**
46
+ `))}function Aa(r){return r.replaceAll("**","")}var Ca=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Ws(r){let e=H(r).trim();if(!e.startsWith("# "))return null;let t=e.split(/^# /mu).filter(s=>s.trim().length>0),i=[];for(let s of t){let o=Ma(s);o&&i.push(o)}return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function Ma(r){let{title:e,body:t}=He(r);if(!e)return null;let{sectionsText:i,metaText:s}=Ra(t),o=La(i),n=za(s),a=Na(o.evidence||""),{file:l,line:d,locationLink:u}=Ks(o.location||a[0]?.ref||""),p=(n.severity||"").toLowerCase(),g=Ca.has(p)?p:"medium",m=Pa(e,o,a.length>0),b={file:l||"unknown",line:d,severity:g,description:m};u&&(b.location=u),a.length>0&&(b.evidence=a.map(Ba)),o["reproduction steps"]&&(b.reproduction=Ia(o["reproduction steps"])),o["recommended fix"]&&(b.recommendation=o["recommended fix"]),n.repository&&(b.repo={github:n.repository}),n.branch&&(b.branch=n.branch),n["date created"]&&(b.dateCreated=n["date created"]),n.status&&(b.status=n.status),n.category&&(b.category=n.category);let f=Vs(r);return f&&(b._idBasis=f),b}function Ra(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function La(r){let e={};for(let t of r.split(/^## /mu).slice(1)){let{title:i,body:s}=He(t),o=i.toLowerCase();o&&(e[o]=s.trim())}return e}function za(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function Ks(r){let e="",t="?",i="",s=Se(r);if(s){e=s.label.trim(),i=s.url.trim();let n=i.match(/#L(\d+)(?:-L?(\d+))?/u);n&&(t=n[2]?`${n[1]}-${n[2]}`:n[1])}else e=r.trim(),i=r.trim();e=$s(e.replaceAll("`","")).trim();let o=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return o&&(e=o[1],t==="?"&&(t=o[3]?`${o[2]}-${o[3]}`:o[2])),{file:e,line:t,locationLink:i,linked:s!==null}}function Ia(r){let e=r.split(`
47
+ `),t=e.findIndex(a=>a.trim());if(t===-1||!ke.test(e[t])||e.some((a,l)=>l!==t&&ke.test(a)))return r;let i=e[t].replace(/^ */u,""),s=i.replace(ke,"");if(!s.trim())return r;let o=qs(s)??qs(i);if(o===null&&(ke.test(s)||Ta.test(i)))return r;let n=o===null?[s]:o.length===1?[o[0].step]:o.map(({number:a,step:l})=>`${a}. ${l}`);return e.splice(t,1,...n),e.join(`
48
+ `)}var Oa=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,Ta=/^\d{1,9}\)(?=[ \t]|$)/u;function qs(r){let e=[...r.matchAll(Oa)];if(e.length===0||e[0].index!==0)return null;let t=[];for(let[i,s]of e.entries()){let o=Number(s[1]);if(i>0&&o<=t[i-1].number)return null;let n=r.slice(s.index+s[0].length,e[i+1]?.index).trim();if(!n)return null;t.push({number:o,step:n})}return t}var Gs=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function Na(r){let e=[];for(let t of r.split(`
49
+ `))Gs.test(t)?e.push({ref:t.replace(Gs,"").trim(),note:[]}):e.length>0&&t.trim()&&e.at(-1).note.push(t.trim());if(e.length===0){let t=r.split(`
50
+ `).map(o=>o.trim()).filter(Boolean),i=t.findIndex(o=>Se(o)!==null);if(i===-1&&t.length!==1)return[];let s=i===-1?0:i;e.push({ref:t[s],note:t.filter((o,n)=>n!==s)})}return e.filter(t=>t.ref)}function Ba({ref:r,note:e}){let{file:t,line:i,locationLink:s,linked:o}=Ks(r),n={file:t||"unknown",line:i};s&&o&&(n.url=s);let a=e.join(`
51
+ `);return a&&(n.text=a),n}function Pa(r,e,t){let i=[r];return e.details&&i.push(e.details),e.evidence&&!t&&i.push(`**Evidence:**
36
52
  ${e.evidence}`),e.impact&&i.push(`**Impact:** ${e.impact}`),i.join(`
37
53
 
38
- `)}function Io(r){let e=(r||"").trim(),t="",i=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);i&&(e=i[1].trim(),t=i[2].trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=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)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);d&&(c=d[1],s||(s=d[2]));let f=/^(.+):(\d+(?:-\d+)?)$/u.exec(c);return f?(s||(s=f[2]),{file:f[1],line:s,locationLink:t}):{file:c,line:s||"?",locationLink:t}}function Je({severity:r,description:e,ref:t,lineBullet:i="",id:s=""}){let o=Io(t),n=o.file||"unknown",a=o.line==="?"&&i?i:o.line,c=o.locationLink||(n==="unknown"&&s?`piolium:${s}`:"");return c?{severity:r,description:e,location:c}:{severity:r,description:e,file:n,line:a}}var zo=/^[\w.-]+\/[\w.-]+$/u;function Li(r){return zo.test(r)}function D(r){switch(((r||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"").toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"INFO":case"INFORMATIONAL":return"informational";default:return""}}function Ce(r){let e=/^([CHML])-?\d+$/iu.exec((r||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function Ft(r){let e=/^(critical|high|medium|low|informational|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((r||"").trim());return e?D(e[1]):""}function Ii(r){let e=/^(critical|high|medium|low|informational|info)\b/iu.exec((r||"").trim());return e?D(e[1]):""}function Qe(r){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((r||"").trim())}function et(r){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(r||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function Xe(r){return(r||"").replaceAll("-"," ")}function Re(r){let e=(r||"").trim(),t=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return ni(t?t[1]:e).toUpperCase()}function Vt(r){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(r);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function qt(r){let e=r.search(/\s/u),t=(e===-1?r:r.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=et(t);if(!i)return null;let s=(e===-1?"":r.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:i.id,slug:i.slug,rest:s}}function Gt(r){let{text:e,link:t}=Vt(r)??{text:r,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=et(i[1].trim());return o?{id:o.id,title:i[2].trim()||Xe(o.slug)||o.id,link:t}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:t}}let s=qt(e);return s?{id:s.id,title:s.rest||Xe(s.slug)||s.id,link:t}:{id:"",title:e.trim(),link:t}}function zi(r){let e={},t=o=>(/`([^`]+)`/u.exec(o)?.[1]??o.split(/\s+/u)[0]??"").trim(),i=/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu.exec(r||"");if(i){let o=t(i[1]);Li(o)&&(e.repo=o)}let s=/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu.exec(r||"");if(s){let o=t(s[1]);qe(o)&&(e.commitHash=o)}return e}var Wt=["key code reference","key code","code reference","location","affected file","file","path"];function Kt(r){for(let e of Wt)if(r[e])return r[e];return""}function tt(r){return{id:Re(r.id||""),title:X(r.title),severity:X(r.severity),pocStatus:X(r["poc status"]||r.poc),status:X(r.status),parent:Re(X(r.parent||"")),location:X(r.location)}}function rt(r,e=""){let t=D(r.severity)||e||Ce(r.id)||"medium",{file:i,line:s,locationLink:o}=Ge(r.location||""),n={file:i||"unknown",line:s,severity:t,description:Bt(r.title||r.id)};return o?n.location=o:n.file==="unknown"&&r.id&&(n.location=`piolium:${r.id}`),n._idBasis=Je({severity:t,description:n.description,ref:r.location||"",id:r.id}),r.pocStatus&&(n.pocStatus=r.pocStatus),r.status&&(n.status=r.status),r.parent&&(n.parent=r.parent),n}function Zt(r,e,t){let i=[];for(let s of r.split(`
39
- `)){let o=/^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.+)$/u.exec(s);if(!o)continue;let n=o[1].trim();if(/^\*\*[^:*]+:\*\*/u.test(n))continue;let a=Vt(n),c=a?.link??"";if(a)n=a.text;else{let m=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(n);m&&(n=m[2]?`${m[1].trim()} ${m[2].trim()}`:m[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(n))continue;let d=qt(n),f=d?.id??"",p=n;if(d){let m=Xe(d.slug);p=m&&d.rest?`${m}
54
+ `)}function ja(r){let e=(r||"").trim(),t="",i=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);i&&(e=i[1].trim(),t=i[2].trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=o[1]);let l=[...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)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(l);d&&(l=d[1],s||(s=d[2]));let u=/^(.+):(\d+(?:-\d+)?)$/u.exec(l);return u?(s||(s=u[2]),{file:u[1],line:s,locationLink:t}):{file:l,line:s||"?",locationLink:t}}function ft({severity:r,description:e,ref:t,lineBullet:i="",id:s=""}){let o=ja(t),n=o.file||"unknown",a=o.line==="?"&&i?i:o.line,l=o.locationLink||(n==="unknown"&&s?`piolium:${s}`:"");return l?{severity:r,description:e,location:l}:{severity:r,description:e,file:n,line:a}}var Da=/^[\w.-]+\/[\w.-]+$/u;function Js(r){return Da.test(r)}function J(r){switch(((r||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"").toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"INFO":case"INFORMATIONAL":return"informational";default:return""}}function Ve(r){let e=/^([CHML])-?\d+$/iu.exec((r||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function gr(r){let e=/^(critical|high|medium|low|informational|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((r||"").trim());return e?J(e[1]):""}function Zs(r){let e=/^(critical|high|medium|low|informational|info)\b/iu.exec((r||"").trim());return e?J(e[1]):""}function bt(r){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((r||"").trim())}function vt(r){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(r||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function gt(r){return(r||"").replaceAll("-"," ")}function qe(r){let e=(r||"").trim(),t=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return ks(t?t[1]:e).toUpperCase()}function br(r){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(r);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function vr(r){let e=r.search(/\s/u),t=(e===-1?r:r.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=vt(t);if(!i)return null;let s=(e===-1?"":r.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:i.id,slug:i.slug,rest:s}}function yr(r){let{text:e,link:t}=br(r)??{text:r,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=vt(i[1].trim());return o?{id:o.id,title:i[2].trim()||gt(o.slug)||o.id,link:t}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:t}}let s=vr(e);return s?{id:s.id,title:s.rest||gt(s.slug)||s.id,link:t}:{id:"",title:e.trim(),link:t}}function Ys(r){let e={},t=o=>(/`([^`]+)`/u.exec(o)?.[1]??o.split(/\s+/u)[0]??"").trim(),i=/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu.exec(r||"");if(i){let o=t(i[1]);Js(o)&&(e.repo=o)}let s=/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu.exec(r||"");if(s){let o=t(s[1]);ct(o)&&(e.commitHash=o)}return e}var _r=["key code reference","key code","code reference","location","affected file","file","path"];function wr(r){for(let e of _r)if(r[e])return r[e];return""}function yt(r){return{id:qe(r.id||""),title:pe(r.title),severity:pe(r.severity),pocStatus:pe(r["poc status"]||r.poc),status:pe(r.status),parent:qe(pe(r.parent||"")),location:pe(r.location)}}function _t(r,e=""){let t=J(r.severity)||e||Ve(r.id)||"medium",{file:i,line:s,locationLink:o}=dt(r.location||""),n={file:i||"unknown",line:s,severity:t,description:dr(r.title||r.id)};return o?n.location=o:n.file==="unknown"&&r.id&&(n.location=`piolium:${r.id}`),n._idBasis=ft({severity:t,description:n.description,ref:r.location||"",id:r.id}),r.pocStatus&&(n.pocStatus=r.pocStatus),r.status&&(n.status=r.status),r.parent&&(n.parent=r.parent),n}function xr(r,e,t){let i=[];for(let s of r.split(`
55
+ `)){let o=/^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.+)$/u.exec(s);if(!o)continue;let n=o[1].trim();if(/^\*\*[^:*]+:\*\*/u.test(n))continue;let a=br(n),l=a?.link??"";if(a)n=a.text;else{let f=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(n);f&&(n=f[2]?`${f[1].trim()} ${f[2].trim()}`:f[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(n))continue;let d=vr(n),u=d?.id??"",p=n;if(d){let f=gt(d.slug);p=f&&d.rest?`${f}
40
56
 
41
- ${d.rest}`:d.rest||m||d.id}let b=t.get(f),g={file:"unknown",line:"?",severity:D(b?.severity)||e||Ce(f)||"medium",description:Bt(p)};f?g.location=`piolium:${f}`:c&&(g.location=c),c.endsWith("report.md")&&(g.reportPath=c),b?.pocStatus&&(g.pocStatus=b.pocStatus),b?.status&&(g.status=b.status),b?.parent&&(g.parent=b.parent),i.push({id:f,finding:g})}return i}function Yt(r,e,t,i=""){let s=[];for(let n of Ae(r)){let a=tt(n);!a.id&&!a.title||(!a.parent&&t&&(a.parent=t),a.id&&!e.has(a.id)&&e.set(a.id,a),s.push({id:a.id,finding:rt(a,i)}))}if(s.length>0)return s;let o=Zt(r,i,e);for(let n of o)t&&!n.finding.parent&&(n.finding.parent=t);return o}var To=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]);function No(r){return To.has(r)||r.startsWith("findings by severity")}var Oo=/^(?:summary of findings|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope|table of contents|contents|appendix|recommendation|remediation)/u;function Bo(r){return Oo.test(r)}function Ti(r){let{id:e}=Gt(r);return!!(e&&et(e))}function Po(r){let e=T(r,Se);return(e.length>0?e:T(r,Y)).some(({heading:i})=>Ti(i))}function Ni(r){let e=z(r).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 t=jo(e),i=Fo(t["summary of findings"]||""),s=zi(J(e,ke).head),o=[],n=new Set,a=[],c=({id:f,finding:p})=>{o.push(p),f&&n.add(f)},d=f=>{for(let p of f)c(p)};for(let[f,p]of Object.entries(t)){let b=Ft(f);b||No(f)?d(Jt(p,b,i,a)):!Bo(f)&&Po(p)&&d(Jt(p,Ii(f),i,a))}for(let f of a)(!f.id||!n.has(f.id))&&c(f);for(let f of i.values())n.has(f.id)||c({id:f.id,finding:rt(f)});if(o.length===0)return null;for(let f of o)s.repo&&(f.repo={github:s.repo}),s.commitHash&&!f.auditedCommit&&(f.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:o}}function Do(r,e,t,i){let s=[],o="";for(let{heading:n,body:a}of r){let c=Ft(n);if(c)s.push(...Jt(a,c,e,t)),o="";else if(Qe(n))s.push(...Uo(a,e,o,t,i));else{let d=Ho(n,a,e,t,i);s.push(...d),o=d[0]?.id||o}}return s}function Ho(r,e,t,i,s){let{head:o,subs:n}=J(e,Y),a=Oi(r,o,t,s),c=a!==null&&!a.id&&n.some(f=>!Qe(f.heading)&&Ti(f.heading)),d=a&&!c?[a]:[];return d.push(...Xt(n,t,i,s,a?.id||"")),d}function Uo(r,e,t,i,s){let{head:o,subs:n}=J(r,Y);return i.push(...Yt(o,e,t,s)),Xt(n,e,i,s,"")}function Xt(r,e,t,i,s){let o=[],n="";for(let{heading:a,body:c}of r){if(Qe(a)){t.push(...Yt(c,e,s??n,i));continue}let d=Oi(a,c,e,i);d&&(o.push(d),n=d.id||n)}return o}function Jt(r,e,t,i){let s=T(r,Se);if(s.length>0)return Do(s,t,i,e);let o=Xt(T(r,Y),t,i,e,null);if(o.length>0)return o;let n=Ae(r).map(tt).filter(a=>a.id||a.title);if(n.length>0){for(let a of n)!a.severity&&e&&(a.severity=e),a.id&&!t.has(a.id)?t.set(a.id,a):a.id||i.push({id:"",finding:rt(a,e)});return[]}return i.push(...Zt(r,e,t)),[]}function Oi(r,e,t,i=""){let s=r.trim();if(!s)return null;let{id:o,title:n,link:a}=Gt(s),c=t.get(o);!o&&n&&(c=[...t.values()].find(N=>N.title.toLowerCase()===n.toLowerCase()),o=c?.id??"");let{fields:d,labels:f,prose:p}=ii(e),b=D(d.severity)||D(c?.severity)||i||Ce(o)||"medium",h=Ge(Kt(d)),g=/\d+/u.exec(d.line||d.lines||"")?.[0]??"",m=h.line==="?"&&g?g:h.line,v=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),$=p.split(`
42
- `).filter(N=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test(N)&&!/\*\*Variant of:?\*\*/iu.test(N)).join(`
43
- `).trim(),_={file:h.file||"unknown",line:m,severity:b,description:qo(n||o,d,f,$)};h.locationLink?_.location=h.locationLink:_.file==="unknown"&&o&&(_.location=`piolium:${o}`),_._idBasis=Je({severity:b,description:_.description,ref:Kt(d),lineBullet:g,id:o});let A=d["poc status"]||d.poc||c?.pocStatus;A&&(_.pocStatus=A);let Me=d["detailed report"]||(a.endsWith("report.md")?a:"");Me&&(_.reportPath=Me),c?.status&&(_.status=c.status);let Le=c?.parent||(v?Re(v[1]):"");return Le&&(_.parent=Le),{id:o,finding:_}}function jo(r){let e=Object.create(null);for(let{heading:t,body:i}of T(r,ke)){let s=t.trim().toLowerCase();s&&(e[s]=s in e?`${e[s]}
44
- ${i}`:i)}return e}function Fo(r){let e=new Map;for(let t of Ae(r)){let i=tt(t);i.id&&e.set(i.id,i)}return e}var Vo=new Set([...Wt,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function qo(r,e,t,i){let s=[r];e.summary&&s.push(e.summary),i&&s.push(i);for(let[o,n]of Object.entries(e))!n||Vo.has(o)||s.push(`**${t[o]||o}:** ${n}`);return s.filter(Boolean).join(`
57
+ ${d.rest}`:d.rest||f||d.id}let g=t.get(u),b={file:"unknown",line:"?",severity:J(g?.severity)||e||Ve(u)||"medium",description:dr(p)};u?b.location=`piolium:${u}`:l&&(b.location=l),l.endsWith("report.md")&&(b.reportPath=l),g?.pocStatus&&(b.pocStatus=g.pocStatus),g?.status&&(b.status=g.status),g?.parent&&(b.parent=g.parent),i.push({id:u,finding:b})}return i}function $r(r,e,t,i=""){let s=[];for(let n of Fe(r)){let a=yt(n);!a.id&&!a.title||(!a.parent&&t&&(a.parent=t),a.id&&!e.has(a.id)&&e.set(a.id,a),s.push({id:a.id,finding:_t(a,i)}))}if(s.length>0)return s;let o=xr(r,i,e);for(let n of o)t&&!n.finding.parent&&(n.finding.parent=t);return o}var Ua=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]);function Ha(r){return Ua.has(r)||r.startsWith("findings by severity")}var Fa=/^(?:summary of findings|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope|table of contents|contents|appendix|recommendation|remediation)/u;function Va(r){return Fa.test(r)}function Xs(r){let{id:e}=yr(r);return!!(e&&vt(e))}function qa(r){let e=F(r,Ue);return(e.length>0?e:F(r,ce)).some(({heading:i})=>Xs(i))}function Qs(r){let e=H(r).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 t=Ja(e),i=Za(t["summary of findings"]||""),s=Ys(de(e,De).head),o=[],n=new Set,a=[],l=({id:u,finding:p})=>{o.push(p),u&&n.add(u)},d=u=>{for(let p of u)l(p)};for(let[u,p]of Object.entries(t)){let g=gr(u);g||Ha(u)?d(kr(p,g,i,a)):!Va(u)&&qa(p)&&d(kr(p,Zs(u),i,a))}for(let u of a)(!u.id||!n.has(u.id))&&l(u);for(let u of i.values())n.has(u.id)||l({id:u.id,finding:_t(u)});if(o.length===0)return null;for(let u of o)s.repo&&(u.repo={github:s.repo}),s.commitHash&&!u.auditedCommit&&(u.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:o}}function Ga(r,e,t,i){let s=[],o="";for(let{heading:n,body:a}of r){let l=gr(n);if(l)s.push(...kr(a,l,e,t)),o="";else if(bt(n))s.push(...Ka(a,e,o,t,i));else{let d=Wa(n,a,e,t,i);s.push(...d),o=d[0]?.id||o}}return s}function Wa(r,e,t,i,s){let{head:o,subs:n}=de(e,ce),a=eo(r,o,t,s),l=a!==null&&!a.id&&n.some(u=>!bt(u.heading)&&Xs(u.heading)),d=a&&!l?[a]:[];return d.push(...Sr(n,t,i,s,a?.id||"")),d}function Ka(r,e,t,i,s){let{head:o,subs:n}=de(r,ce);return i.push(...$r(o,e,t,s)),Sr(n,e,i,s,"")}function Sr(r,e,t,i,s){let o=[],n="";for(let{heading:a,body:l}of r){if(bt(a)){t.push(...$r(l,e,s??n,i));continue}let d=eo(a,l,e,i);d&&(o.push(d),n=d.id||n)}return o}function kr(r,e,t,i){let s=F(r,Ue);if(s.length>0)return Ga(s,t,i,e);let o=Sr(F(r,ce),t,i,e,null);if(o.length>0)return o;let n=Fe(r).map(yt).filter(a=>a.id||a.title);if(n.length>0){for(let a of n)!a.severity&&e&&(a.severity=e),a.id&&!t.has(a.id)?t.set(a.id,a):a.id||i.push({id:"",finding:_t(a,e)});return[]}return i.push(...xr(r,e,t)),[]}function eo(r,e,t,i=""){let s=r.trim();if(!s)return null;let{id:o,title:n,link:a}=yr(s),l=t.get(o);!o&&n&&(l=[...t.values()].find(V=>V.title.toLowerCase()===n.toLowerCase()),o=l?.id??"");let{fields:d,labels:u,prose:p}=ws(e),g=J(d.severity)||J(l?.severity)||i||Ve(o)||"medium",m=dt(wr(d)),b=/\d+/u.exec(d.line||d.lines||"")?.[0]??"",f=m.line==="?"&&b?b:m.line,y=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),$=p.split(`
58
+ `).filter(V=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test(V)&&!/\*\*Variant of:?\*\*/iu.test(V)).join(`
59
+ `).trim(),_={file:m.file||"unknown",line:f,severity:g,description:Xa(n||o,d,u,$)};m.locationLink?_.location=m.locationLink:_.file==="unknown"&&o&&(_.location=`piolium:${o}`),_._idBasis=ft({severity:g,description:_.description,ref:wr(d),lineBullet:b,id:o});let T=d["poc status"]||d.poc||l?.pocStatus;T&&(_.pocStatus=T);let Ge=d["detailed report"]||(a.endsWith("report.md")?a:"");Ge&&(_.reportPath=Ge),l?.status&&(_.status=l.status);let We=l?.parent||(y?qe(y[1]):"");return We&&(_.parent=We),{id:o,finding:_}}function Ja(r){let e=Object.create(null);for(let{heading:t,body:i}of F(r,De)){let s=t.trim().toLowerCase();s&&(e[s]=s in e?`${e[s]}
60
+ ${i}`:i)}return e}function Za(r){let e=new Map;for(let t of Fe(r)){let i=yt(t);i.id&&e.set(i.id,i)}return e}var Ya=new Set([..._r,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function Xa(r,e,t,i){let s=[r];e.summary&&s.push(e.summary),i&&s.push(i);for(let[o,n]of Object.entries(e))!n||Ya.has(o)||s.push(`**${t[o]||o}:** ${n}`);return s.filter(Boolean).join(`
45
61
 
46
- `)}var Go=[["deepview-md",Si],["deepsec",ci],["piolium",Ni],["claude-security",Ri]];function Qt(r){return Array.isArray(r?.findings)?r.findings:Array.isArray(r?.groups)?r.groups:null}function Bi(r){let e;try{let t=JSON.parse(r);return Qt(t)?{data:t,format:"json",reason:null}:{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(t){e=t}for(let[t,i]of Go){let s=i(r);if(s)return{data:s,format:t,reason:null}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function Wo(r){let{data:e}=Bi(r);return e&&Pi(e)>0?e:null}function Pi(r){return(Qt(r)??[]).filter(e=>(Array.isArray(e)?e:[e]).some(t=>t&&typeof t=="object"&&Pt(t,t.source??r.source))).length}function Di(r,e){let t=(r.reports??[]).filter(n=>n.visible&&n.repoId!=null).flatMap(n=>{let a=Wo(n.content??"");return a?[{id:n.id,filename:n.filename,repoIds:[n.repoId],repo:n.repoFullName,directory:n.repoDirectory,analyzer:n.analyzer,appFindings:Pi(a)}]:[]}),i=new Map((r.repos??[]).map(n=>[n.repoId,{id:n.repoId,label:n.fullName}]));for(let n of t)i.has(n.repoIds[0])||i.set(n.repoIds[0],{id:n.repoIds[0],label:n.repo??String(n.repoIds[0])});let s=e.results??[],o=new Set(s.map(n=>n.bundleId));return{merge:{bundles:(e.bundles??[]).filter(n=>o.has(n.id)).map(n=>({...n,size:W(n.byteSize)})),results:s},link:{repositories:[...i.values()].filter(n=>t.some(a=>a.repoIds.includes(n.id))),reports:t}}}function Hi(r){return r.map(e=>{let t=e.login||String(e.id),i=e.name?.trim()||`@${t}`,s=i===`@${t}`?"":`@${t}`,o=i.replace(/^@/u,"").split(/\s+/u).filter(Boolean).slice(0,2).map(n=>n[0]).join("").toUpperCase();return{value:e.id,label:s?`${i} ${s}`:i,displayLabel:i,secondary:s,initials:o,disabled:e.disabled,detail:e.detail}})}function Ui(r,e){let t=e.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),i=r.filter(s=>t.every(o=>s.label.normalize("NFKC").toLocaleLowerCase().includes(o))).toSorted((s,o)=>s.label.localeCompare(o.label,void 0,{sensitivity:"base",numeric:!0}));return{pinned:[],sections:[{label:null,options:i}],facets:[],showFacets:!1,count:i.length,total:r.length}}var er=class extends E{static properties={users:{attribute:!1}};constructor(){super(),this.users=[],this.label="Choose user",this.placeholder="Choose user"}get searchLabel(){return"Search users"}get optionsLabel(){return"Users"}get noMatchesLabel(){return"No matching users"}get emptyLabel(){return"No users available"}get changeEvent(){return"user-change"}willUpdate(e){e.has("users")&&(this.options=Hi(this.users))}choices(){return Ui(this.options,this._query)}};customElements.get("user-selector")||customElements.define("user-selector",er);async function ee(){let r=await y("/api/auth/session",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)return null;let e=await r.json();return{id:e?.user?.id??null,role:typeof e?.user?.role=="string"?e.user.role:"none",csrfToken:typeof e?.csrfToken=="string"?e.csrfToken:null}}var te=x`.head{display:flex;align-items:center;gap:.6rem;min-height:2.1rem;margin-bottom:.55rem}.breadcrumb{display:inline-flex;align-items:center;gap:.35rem;flex:0 0 auto}.breadcrumb-manage{padding:.22rem .35rem;border:1px solid transparent;border-radius:5px;color:var(--muted);background:0 0;font:inherit;font-size:.82rem;cursor:pointer}.breadcrumb-manage:hover{color:var(--text);background:var(--surface-active);border-color:var(--border)}.breadcrumb-manage:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.breadcrumb-separator{color:var(--muted);font-size:1rem}.head h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}`;function re(){return l`<span class="breadcrumb"><button type="button" class="breadcrumb-manage" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage"},bubbles:!0,composed:!0}))}}">Manage</button><span class="breadcrumb-separator" aria-hidden="true">›</span></span>`}function Ko(r){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:r},bubbles:!0,composed:!0}))}var ur=x`:host{display:block;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.head{gap:.65rem;margin-bottom:.45rem}h1{font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.intro{margin:0 0 1.6rem;color:var(--muted);font-size:.85rem;line-height:1.5}.count{display:inline-grid;place-items:center;min-width:1.45rem;height:1.45rem;padding:0 .4rem;border-radius:5px;background:var(--surface-active);color:var(--muted);font-size:.72rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,input[type=checkbox],select{cursor:default}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}input:not([type=checkbox]),select{min-width:0;height:2rem;padding:.3rem .55rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{margin:0;width:.85rem;height:.85rem;accent-color:var(--accent)}.btn{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;height:2rem;padding:0 .7rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);font-size:.78rem;font-weight:500;white-space:nowrap}.btn:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary{background:var(--accent);color:var(--bg);border-color:var(--accent)}.btn.primary:hover:not(:disabled){filter:brightness(1.1)}button:disabled,select:disabled{opacity:.5}.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:5px;color:var(--muted);background:0 0}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical,#e5534b);background:rgb(from var(--critical,#e5534b) r g b / .1)}.btn svg,.icon-btn svg{width:.9rem;height:.9rem}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:2rem;height:2rem;border-radius:50%;overflow:hidden;background:var(--surface-active);color:var(--muted);font-family:system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:.8rem;font-weight:600;user-select:none}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.msg{margin:1rem 0;color:var(--muted);font-size:.85rem;line-height:1.5}.msg.error{color:var(--critical,#e5534b)}`;function qi(r,e){return l`<span class="avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${ot()?u:l`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" @error="${t=>t.currentTarget.classList.add("broken")}">`}</span>`}var Zo=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 4-8 8H2v-4l8-8Zm-1 1 4 4"/></svg>`,Yo=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h12M6 4V2h4v2M4 4l.6 10h6.8L12 4M6.5 7v4m3-4v4"/></svg>`,rr=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="m4 4 8 8m0-8-8 8"/></svg>`,tr=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>`,Jo={admin:"Admin",manage:"Manager",triage:"Triage",view:"Viewer",none:"No access"},Xo={admin:"Manage workspace access and teams",manage:"Manage content and scans",triage:"Review and triage findings",view:"Read-only access",none:"No workspace access"},ir=class extends w{static properties={_role:{state:!0}};static styles=x`:host{display:block;padding:clamp(1.5rem,5vw,3rem) clamp(1rem,4vw,2.5rem);color:var(--text)}.wrap{max-width:68rem;margin:0 auto}h1{margin:0;font-size:clamp(1.7rem,4vw,2.35rem);font-weight:600;letter-spacing:-.04em}.intro{max-width:38rem;margin:.55rem 0 1.7rem;color:var(--muted);line-height:1.5}.pages{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem;margin:0;padding:0;list-style:none}.pages li:last-child{grid-column:1/-1}.page{display:flex;align-items:center;gap:.8rem;width:100%;padding:.85rem 1rem;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:9px;text-align:left;font:inherit;cursor:default;transition:background .12s,border-color .12s}.page:hover{background:var(--surface-active);border-color:var(--muted)}.page:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.page-icon{display:grid;place-items:center;width:2rem;height:2rem;flex:0 0 auto;color:var(--accent);background:rgb(from var(--accent) r g b / .1);border-radius:6px}.page-icon svg{width:1.05rem;height:1.05rem}.page-icon .file-icon{width:1.15rem;height:1.15rem}.page-icon .brand-deepview{--brand-bg:#2563eb;--brand-fg:#fff}.page-icon .brand-claude{--brand-bg:#d97757;--brand-fg:#fff}.page-icon .brand-codex{--brand-bg:#fff;--brand-fg:#000}.page-icon .brand-vercel{--brand-bg:#000;--brand-fg:#fff}.page-icon .brand-piolium{--brand-bg:#fbb829;--brand-fg:#1c1b19}.page-icon .file-icon .bg{fill:var(--brand-bg)}.page-icon .file-icon .fg{fill:var(--brand-fg)}.page-icon .file-icon:is(.brand-codex,.brand-vercel) .bg{stroke:var(--brand-fg);stroke-width:.5}.page-copy{display:flex;min-width:0;flex-direction:column;gap:.15rem}.page-copy strong{font-size:.9rem;font-weight:600}.page-copy span{color:var(--muted);font-size:.76rem}.arrow{width:1rem;height:1rem;margin-left:auto;color:var(--muted);flex:0 0 auto}@media (max-width:42rem){.pages{grid-template-columns:1fr}.pages li:last-child{grid-column:auto}}`;constructor(){super(),this._role=null}connectedCallback(){super.connectedCallback(),ee().then(e=>(this._role=e?.role??"none",e))}render(){let e=(s,o,n,a)=>({view:s,title:o,text:n,icon:a}),t=[[this._role==="admin"?e("admin-users","Users","Review accounts and assign roles.","users"):null,this._role==="admin"?e("manage-teams","Teams","Organize repositories, members, and access.","team"):null],[this._role==="admin"?e("manage-repos","Repositories","Connect and select source repositories.","repo"):null,e("manage-bundles","Bundles","Manage source bundles and sourcemaps.","bundle")],[["admin","manage"].includes(this._role)?e("manage-scans","Scans","Run and monitor scans from stored bundles.","scan"):null,e("manage-reports","Reports","Review reports stored for your teams.","report")],[e("manage-history","History","Review workspace activity and triage changes.","history")]];return l`<div class="wrap"><h1>Manage</h1><p class="intro">${"Choose a page."}</p><nav aria-label="Management pages"><ul class="pages">${t.flat().filter(Boolean).map(s=>l`<li><button type="button" class="page" @click="${()=>Ko(s.view)}"><span class="page-icon" aria-hidden="true">${this._icon(s.icon)}</span> <span class="page-copy"><strong>${s.title}</strong><span>${s.text}</span></span> <svg class="arrow" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg></button></li>`)}</ul></nav></div>`}_icon(e){if(e==="bundle")return L(oe);let t={users:"M3.25 7.25a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Zm9.5 0a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5ZM1 13.25c0-1.8 1.1-3 2.75-3s2.75 1.2 2.75 3M9.5 13.25c0-1.8 1.1-3 2.75-3S15 11.45 15 13.25M8 8.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-3 5c0-2 1.2-3.5 3-3.5s3 1.5 3 3.5",repo:"M2 3.5A1.5 1.5 0 0 1 3.5 2h9A1.5 1.5 0 0 1 14 3.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 12.5v-9Zm3 2h6m-6 3h6m-6 3h3",report:"M4 1.5h5l3 3v10H4v-13Zm5 0v3h3m-6 3h4m-4 2h4m-4 2h3",bundle:"m8 1 5 2.8v8.4L8 15l-5-2.8V3.8L8 1Zm-5 2.8 5 2.8 5-2.8M8 6.6V15",history:"M8 2a6 6 0 1 0 6 6M8 4.5V8l2.25 1.5M10.5 2H14v3.5",team:"M8 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-4 5c0-2 1.7-3 4-3s4 1 4 3M2 7h2m8 0h2M8 1v2m0 9v2",scan:"M3 3.5h10v9H3zM5.5 6h5M5.5 8h5M5.5 10h3"};return l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"><path d="${t[e]??t.report}/"></path></svg>`}};customElements.define("managed-admin-home",ir);async function Qo(){let r=await y("/api/admin/history",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);let e=await r.json();if(!Array.isArray(e?.history))throw new Error("No history returned");return e.history}async function en(){try{let r=await y("/api/teams",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)return new Set;let e=await r.json();return new Set((Array.isArray(e?.teams)?e.teams:[]).flatMap(t=>Array.isArray(t.reports)?t.reports.map(i=>i.id):[]))}catch{return new Set}}var sr=class extends w{static properties={_history:{state:!0},_role:{state:!0},_allowedReports:{state:!0},_error:{state:!0},_filter:{state:!0},_query:{state:!0}};static styles=[te,x`:host{display:block;min-height:100%;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text)}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.intro{margin:0 0 1rem;color:var(--muted);font-size:.82rem;line-height:1.5}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.55rem;margin:0 0 .8rem}.toolbar input,.toolbar select{height:2rem;padding:.28rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem}.toolbar input{flex:1 1 20rem;min-width:12rem}.toolbar select{flex:0 1 10rem;min-width:9rem}.history{overflow:hidden;border:1px solid var(--border);border-radius:9px;background:var(--surface)}.row{display:grid;grid-template-columns:4.75rem minmax(8rem,10rem) minmax(0,1fr) auto;align-items:center;gap:.7rem;padding:.52rem .8rem;min-height:2.45rem}.row+.row{border-top:1px solid var(--border)}.kind{width:fit-content;padding:.14rem .38rem;border:1px solid var(--border);border-radius:999px;color:var(--muted);font-size:.62rem;font-weight:600;text-transform:capitalize}.kind.triage{color:var(--accent);border-color:rgb(from var(--accent) r g b / .35);background:rgb(from var(--accent) r g b / .08)}.actor{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.72rem}.copy{display:grid;grid-template-columns:minmax(9rem,auto) minmax(0,1fr);min-width:0;align-items:baseline;gap:.45rem}.action{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.76rem}.detail{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.67rem}time{color:var(--muted);font-size:.68rem;white-space:nowrap}.empty,.msg{margin:0;padding:1.2rem;color:var(--muted);font-size:.8rem;line-height:1.5}.msg.error{color:var(--critical,#c00)}@media (max-width:46rem){.row{grid-template-columns:4.5rem 8rem minmax(0,1fr) auto}.copy{grid-template-columns:minmax(8rem,auto) minmax(0,1fr)}}@media (max-width:38rem){.row{grid-template-columns:auto minmax(0,1fr) auto}.row .actor{grid-column:2;grid-row:2}.row .copy{grid-column:2;grid-row:1}time{grid-column:3;grid-row:1/3}}`];constructor(){super(),this._history=null,this._role=null,this._allowedReports=null,this._error=null,this._filter="all",this._query="",this._onActorFilter=e=>{let t=e.detail?.actor;typeof t!="string"||t.length===0||(this._query=t,this._filter="all")}}connectedCallback(){super.connectedCallback(),document.addEventListener("managed-history-filter",this._onActorFilter),this._load()}disconnectedCallback(){document.removeEventListener("managed-history-filter",this._onActorFilter),super.disconnectedCallback()}async _load(){try{let e=await ee();this._role=e?.role??"none",this._history=await Qo(),this._allowedReports=this._role==="manage"?await en():null}catch(e){this._error=String(e?.message??e)}}render(){let e=Array.isArray(this._history)?this._history:[],t=this._role==="manage"?e.filter(n=>n.kind==="triage"&&(this._allowedReports==null||this._allowedReports.has(n.reportId))):e,i=this._query.trim().toLocaleLowerCase(),s=i.length===0?t:t.filter(n=>tn(n).includes(i)),o=this._filter==="all"?s:s.filter(n=>n.kind===this._filter);return l`<div class="wrap"><div class="head">${re()}<h1>History</h1>${this._history?l`<span class="count">${o.length}</span>`:u}</div><p class="intro">${this._role==="admin"?"All workspace actions, including uploads, access changes, scans, and triage.":"Triage history for reports you can access."}</p>${this._history==null?u:l`<div class="toolbar" role="search"><input type="search" aria-label="Search history" placeholder="Search actions, users, repositories, reports…" .value="${this._query}" @input="${n=>{this._query=n.target.value}}"><select aria-label="Filter history by type" .value="${this._filter}" @change="${n=>{this._filter=n.target.value}}"><option value="all">All activity</option><option value="triage">Triage</option><option value="visibility">Visibility</option><option value="upload">Uploads</option><option value="scan">Scans</option></select></div>`} ${this._error?l`<p class="msg error">Couldn’t load history: ${this._error}</p>`:this._history==null?l`<p class="msg">Loading…</p>`:o.length===0?l`<div class="history"><p class="empty">No history available yet.</p></div>`:l`<div class="history" aria-label="Workspace history">${o.map(n=>this._row(n))}</div>`}</div>`}_row(e){let t=[e.repo??e.repository,e.report,e.finding].filter(Boolean).join(" \xB7 ");return l`<div class="row"><span class="${`kind ${e.kind??""}`}">${e.kind??"activity"}</span><span class="actor">${e.actor??e.user??"Unknown user"}</span><span class="copy"><span class="action">${e.action??"updated workspace data"}</span>${t?l`<span class="detail">${t}</span>`:u}</span><time>${e.when??""}</time></div>`}};customElements.define("managed-admin-history",sr);function tn(r){return Object.entries(r??{}).flatMap(([e,t])=>t==null?[]:typeof t=="object"?[e,JSON.stringify(t)]:[e,String(t)]).join(" ").toLocaleLowerCase()}async function rn(){let r=await y("/api/admin/users",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);let e=await r.json();return Array.isArray(e?.users)?e.users:[]}function ji(r){if(r==null||r==="")return l`<span>Unknown</span>`;let e=typeof r=="number"?r:Number(r);if(!Number.isFinite(e))return l`<span>Unknown</span>`;let t=new Date(e);return Number.isNaN(t.getTime())?l`<span>Unknown</span>`:l`<time datetime="${t.toISOString()}">${t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}</time><span>${t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}</span>`}function Fi(r){if(r==null||r==="")return"Unknown";let e=typeof r=="number"?r:Number(r);return Number.isFinite(e)&&!Number.isNaN(new Date(e).getTime())?`Last seen ${new Date(e).toLocaleString()}`:"Unknown"}function Vi(r){return r?.lastActivityAt??r?.lastActivity??r?.lastWriteAt??r?.lastActiveAt}async function sn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/set-role",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({userId:r,role:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var or=class extends w{static properties={_users:{state:!0},_teams:{state:!0},_error:{state:!0}};static styles=[te,ur,x`.wrap{max-width:68rem;margin:0 auto}.intro{margin-bottom:1rem;font-size:.78rem}.directory{border:1px solid var(--border);border-radius:9px;overflow:hidden;background:var(--surface)}.list-head,.users li{display:grid;grid-template-columns:minmax(12rem,1fr) minmax(15rem,1.15fr) 6.4rem 6.8rem 7rem;gap:.75rem;padding:.45rem .7rem;align-items:center}.list-head{color:var(--muted);font-size:.62rem;font-weight:500;border-bottom:1px solid var(--border)}.users{list-style:none;margin:0;padding:0}.users li+li{border-top:1px solid var(--border)}.person{display:flex;align-items:center;gap:.5rem;min-width:0}.avatar{width:1.65rem;height:1.65rem;font-size:.65rem}.who{display:grid;gap:.05rem;min-width:0}.name{display:flex;align-items:center;gap:.35rem;font-size:.78rem;font-weight:500}.login,.name-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.login{color:var(--muted);font-size:.65rem}.last-activity,.last-seen{display:grid;gap:.08rem;color:var(--muted);font-size:.61rem;font-variant-numeric:tabular-nums}.last-activity time,.last-seen time{color:var(--text)}.activity-link{display:block;min-width:0;padding:.15rem .2rem;border:0;border-radius:4px;color:inherit;background:0 0;text-align:left}.activity-link:hover{color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.you{padding:.05rem .35rem;border-radius:4px;color:var(--accent);background:rgb(from var(--accent) r g b / .1);font-size:.65rem;font-weight:500}.memberships{display:grid;gap:.18rem;min-width:0}.team-access{display:flex;align-items:center;justify-content:flex-start;gap:.5rem;min-width:0;color:var(--muted);font-size:.64rem;line-height:1.35}.team-access strong{color:var(--text);font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.team-perms{display:inline-flex;gap:.3rem;white-space:nowrap}.permission-granted{color:var(--accent)}.permission-denied{color:var(--critical,#e5534b)}.no-team{color:var(--muted);font-size:.67rem}.access{display:flex;align-items:center;min-width:0}.role{width:100%;height:1.7rem;font-size:.72rem}.self-note{margin:.7rem 0;color:var(--muted);font-size:.73rem}@container (max-width: 46rem){gap:.45rem;padding-left:.55rem;padding-right:.55rem}.last-activity,.last-seen{font-size:.57rem}.users li{grid-template-columns:minmax(0,1fr) 6.2rem;gap:.3rem .6rem}.memberships{grid-column:1/-1;grid-row:3;padding-left:2.15rem}.last-seen{grid-column:1;grid-row:2;padding-left:2.15rem;display:flex;flex-wrap:wrap;gap:.3rem}.last-activity{grid-column:1;grid-row:4;padding-left:2.15rem;display:flex;flex-wrap:wrap;gap:.3rem}.activity-link{grid-column:1;grid-row:4;padding-left:2rem}.access{grid-column:2;grid-row:1/3}`];constructor(){super(),this._users=null,this._teams=null,this._error=null,this._me=null,this._csrf=null}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null,this._users=null;try{let[e,t,i]=await Promise.all([ee(),rn(),Zi()]);this._me=e?.id??null,this._csrf=e?.csrfToken??null,this._users=t,this._teams=Array.isArray(i?.teams)?i.teams:[]}catch(e){this._error=String(e?.message??e)}}render(){return l`<div class="wrap"><div class="head">${re()}<h1>Users</h1>${this._users?l`<span class="count">${this._users.length}</span>`:u}</div><p class="intro">Manage workspace access and roles.</p>${this._error==null?this._users==null?l`<p class="msg">Loading…</p>`:this._list():l`<p class="msg error">Couldn't load users: ${this._error}</p>`}</div>`}_list(){return this._users.length===0?l`<p class="msg">No users yet.</p>`:l`<div class="directory"><div class="list-head" aria-hidden="true"><span>Account</span><span>Team access</span><span>Last seen</span><span>Last activity</span><span>Role</span></div><ul class="users">${this._users.map(e=>this._row(e))}</ul></div>${this._users.some(e=>e.id===this._me)?l`<p class="self-note">Your own role can only be changed by another admin.</p>`:u}`}_row(e){let t=e.id===this._me,i=(this._teams??[]).flatMap(s=>{let o=s.members?.find(n=>n.userId===e.id);return o==null?[]:[{team:s,member:o}]});return l`<li><span class="person">${qi(e.id,e.login)} <span class="who"><span class="name"><span class="name-text">${e.name||e.login}</span>${t?l`<span class="you">You</span>`:u}</span> <span class="login">@${e.login}</span> </span></span><span class="memberships">${i.length===0?l`<span class="no-team">No team access</span>`:i.map(({team:s,member:o})=>l`<span class="team-access"><strong>${s.name}</strong><span class="team-perms">${["dependencies","security"].map(n=>l`<span class="${o[n]===!0?"permission-granted":"permission-denied"}">${o[n]===!0?"+":"\u2212"} ${n==="dependencies"?"Deps":"Security"}</span>`)}</span></span>`)} </span><span class="last-seen" aria-label="${Fi(e.lastSeenAt)}">${ji(e.lastSeenAt)}</span> <button type="button" class="activity-link" aria-label="${`Show activity by ${e.login}`}" @click="${()=>this._showActivity(e.login)}"><span class="last-activity" aria-label="${`Last activity ${Fi(Vi(e)).replace(/^Last seen /u,"")}`}">${ji(Vi(e))}</span></button> <span class="access"><select class="role" ?disabled="${t}" aria-label="${`Change ${e.login}\u2019s role`}" aria-description="${Xo[e.role]??""}" @change="${s=>this._changeRole(e,s.target.value,s.target)}">${U.map(s=>l`<option value="${s}" ?selected="${s===e.role}">${Jo[s]}</option>`)}</select></span></li>`}async _changeRole(e,t,i){let s=e.role;if(t!==s){try{await sn(e.id,t,this._csrf),e.role=t}catch(o){console.warn("admin: set role failed:",o),i.value=s}this.requestUpdate()}}_showActivity(e){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-history",actor:e},bubbles:!0,composed:!0}))}};customElements.define("managed-admin-users",or);async function on(r,e,t,i){let s=new URLSearchParams({scope:r,q:e,page:String(t),limit:"20"}),o=await y(`/api/admin/repositories?${s}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:i});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async function nn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/repositories/select",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({repoId:r,selected:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function an(r,e){let t=await y(`/api/admin/repositories/impact?repoId=${encodeURIComponent(r)}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:e});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();if(i?.repoId!==r||!Array.isArray(i.reports)||!Array.isArray(i.bundles)||!Number.isSafeInteger(i.triageCount)||i.triageCount<0)throw new Error("Invalid repository data");return i}async function ln(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await y("/api/admin/repositories/remove",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({repoId:r,fullName:e,acknowledge:!0,deleteTriage:t})});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}var Gi=l`<svg class="repo-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M2 2.75A2.75 2.75 0 0 1 4.75 0h7.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.5a1 1 0 0 0 0 2h8a.75.75 0 0 1 0 1.5h-8A2.5 2.5 0 0 1 2 13V2.75Zm2.75-.25a1.25 1.25 0 0 0-1.25 1.25v7.32c.317-.114.66-.07 1 .18V2.5h-.5a.25.25 0 0 0 .75 0Zm6.75 0H5.5v8.5h6V2.5Z"/></svg>`,nr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_actionError:{state:!0},_scope:{state:!0},_query:{state:!0},_page:{state:!0},_loading:{state:!0},_busy:{state:!0},_detail:{state:!0},_impact:{state:!0},_impactLoading:{state:!0},_removeOpen:{state:!0},_acknowledge:{state:!0},_deleteTriage:{state:!0},_confirmName:{state:!0}};static styles=[te,ur,x`.wrap{max-width:68rem;margin:0 auto}.head{flex-wrap:wrap}.head h1{overflow-wrap:anywhere}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin:1.25rem 0 .85rem}.search{flex:1 1 14rem;max-width:25rem;margin-right:auto}.search input{width:100%}.owners{display:grid;gap:1rem}.owner-head{display:flex;align-items:center;gap:.5rem;margin:0 0 .35rem;padding-left:.7rem;color:var(--muted);font-size:.72rem;font-weight:500}.owner-icon{display:grid;place-items:center;width:1.3rem;height:1.3rem;border-radius:4px;background:var(--surface-active);text-transform:uppercase;font-size:.65rem}.repos{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface)}.repos li+li{border-top:1px solid var(--border)}.repo-row{display:flex;align-items:center;gap:.65rem;width:100%;min-height:2.65rem;padding:.38rem .7rem;text-align:left}button.repo-row{border:0;background:0 0;color:var(--text);cursor:default}button.repo-row:hover{background:var(--surface-active)}button.repo-row:focus-visible{outline-offset:-2px}.repo-icon{width:1rem;height:1rem;flex:0 0 auto;color:var(--muted)}.repo-copy{display:flex;align-items:baseline;gap:.55rem;flex:1;min-width:0}.repo-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8rem;font-weight:500}.repo-meta{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.68rem}.repo-meta::before{content:'·';margin-right:.55rem;color:var(--border-strong,var(--muted))}.arrow{width:1rem;height:1rem;flex:0 0 auto;color:var(--muted)}.connected{display:inline-flex;align-items:center;gap:.25rem;flex:0 0 auto;color:var(--muted);font-size:.68rem;white-space:nowrap}.connected svg{width:.85rem;height:.85rem}.access-note{display:flex;align-items:center;gap:.85rem;padding:.85rem 1rem;background:var(--surface);border:1px solid var(--border);border-radius:8px}.access-note p{flex:1;margin:0;color:var(--muted);font-size:.78rem;line-height:1.5}a.btn{color:var(--text);text-decoration:none;cursor:default}.empty{padding:2.5rem 1rem;border:1px solid var(--border);border-radius:8px;text-align:center}.empty strong{display:block;margin-bottom:.4rem;font-size:.9rem;font-weight:500}.empty p{margin:0;color:var(--muted);font-size:.8rem}.loading{min-height:8rem;display:grid;place-items:center;color:var(--muted);font-size:.8rem}.pagination{display:flex;align-items:center;gap:.5rem;margin-top:.85rem}.pagination span{margin-right:auto;color:var(--muted);font-size:.72rem;font-variant-numeric:tabular-nums}.section{margin-top:1.5rem;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface)}.section h2{margin:0;padding:.8rem 1rem;border-bottom:1px solid var(--border);font-size:.85rem;font-weight:500}.settings-row{display:flex;align-items:center;gap:1rem;padding:1rem}.settings-copy{flex:1;min-width:0}.settings-copy strong{font-size:.83rem;font-weight:500}.settings-copy p{margin:.25rem 0 0;color:var(--muted);font-size:.76rem;line-height:1.5}.settings-row+.settings-row{border-top:1px solid var(--border)}.btn.danger{color:var(--critical,#e5534b)}.error{color:var(--critical,#e5534b)}.status-line{display:inline-flex;align-items:center;gap:.35rem;color:var(--muted);font-size:.72rem}.status-line.inactive{color:var(--warning,#d19a24)}.data-section{margin-top:1.5rem}.data-section h2{margin:0 0 .5rem;font-size:.85rem;font-weight:500}.data-list{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:8px;overflow:hidden}.data-list li{display:flex;align-items:baseline;gap:.5rem;padding:.5rem .75rem;font-size:.75rem}.data-list li+li{border-top:1px solid var(--border)}.data-list strong{min-width:0;overflow-wrap:anywhere;font-weight:500}.data-list span{margin-left:auto;color:var(--muted);font-size:.68rem;white-space:nowrap}.data-empty{margin:0;color:var(--muted);font-size:.75rem}.dialog-backdrop{position:fixed;inset:0;z-index:20;display:grid;place-items:center;padding:1rem;background:rgb(0 0 0 / .65)}.dialog{width:min(40rem,100%);max-height:min(42rem,calc(100vh - 2rem));overflow:auto;padding:1.25rem;border:1px solid var(--border);border-radius:10px;background:var(--surface);box-shadow:0 1rem 3rem rgb(0 0 0 / .35)}.dialog.small{width:min(28rem,100%)}.dialog h2{margin:0;font-size:1.05rem;font-weight:600}.dialog-copy{margin:.55rem 0 1rem;color:var(--muted);font-size:.78rem;line-height:1.5}.dialog-data{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:0 0 1rem}.dialog-data section{min-width:0;padding:.65rem;border:1px solid var(--border);border-radius:7px}.dialog-data h3{margin:0 0 .4rem;font-size:.72rem;font-weight:600}.dialog-data ul{max-height:9rem;overflow:auto;margin:0;padding-left:1rem;color:var(--muted);font-size:.7rem}.dialog-data li{margin:.2rem 0;overflow-wrap:anywhere}.confirm-line{display:flex;align-items:flex-start;gap:.5rem;margin:.7rem 0;color:var(--text);font-size:.76rem;line-height:1.4}.confirm-line input{flex:0 0 auto;margin-top:.15rem;accent-color:var(--accent)}.confirm-name{width:100%;margin-top:.15rem;padding:.45rem .55rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--text);font:inherit;font-size:.78rem}.dialog-actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1rem}.dialog-actions .danger{color:var(--critical,#e5534b);border-color:rgb(from var(--critical,#e5534b) r g b / .4)}.search{flex-basis:100%;max-width:none}.access-note,.settings-row{flex-wrap:wrap}.access-note p,.settings-copy{flex-basis:100%}.head h1{font-size:1.35rem}.repo-copy{gap:.35rem}.repo-meta{max-width:45%}.dialog-data{grid-template-columns:1fr}`];constructor(){super(),this._data=null,this._error=null,this._actionError=null,this._csrf=null,this._scope="connected",this._query="",this._page=1,this._loading=!0,this._busy=null,this._detail=null,this._impact=null,this._impactLoading=!1,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._request=null,this._impactRequest=null,this._searchTimer=null}connectedCallback(){super.connectedCallback(),this._load()}disconnectedCallback(){super.disconnectedCallback(),this._request?.abort(),this._impactRequest?.abort(),clearTimeout(this._searchTimer)}async _load(){this._request?.abort();let e=new AbortController;this._request=e,this._loading=!0,this._error=null;try{let[t,i]=await Promise.all([this._csrf?null:ee(),on(this._scope,this._query,this._page,e.signal)]);if(e.signal.aborted)return;t&&(this._csrf=t.csrfToken),this._data=i;let s=Math.max(1,Math.ceil(i.total/20));this._page>s&&(this._page=s,this._load())}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{this._request===e&&(this._loading=!1)}}_open(e){clearTimeout(this._searchTimer),this._scope=e,this._query="",this._page=1,this._detail=null,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._data=null,this._actionError=null,this._load()}_search(e){this._query=e,this._page=1,this._request?.abort(),clearTimeout(this._searchTimer),this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},200)}_back(){return l`<span class="breadcrumb"><button type="button" class="breadcrumb-manage" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage"},bubbles:!0,composed:!0}))}}">Manage</button> <span class="breadcrumb-separator" aria-hidden="true">›</span> <button type="button" class="breadcrumb-manage" aria-label="Back to repositories" @click="${()=>{this._detail?(this._detail=null,this._actionError=null):this._open("connected")}}">Repositories</button> <span class="breadcrumb-separator" aria-hidden="true">›</span></span>`}_openDetail(e){this._detail=e,this._actionError=null,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._impactLoading=!0,this._impactRequest?.abort();let t=new AbortController;this._impactRequest=t,an(e.id,t.signal).then(i=>(!t.signal.aborted&&this._impactRequest===t&&(this._impact=i),i)).catch(i=>{t.signal.aborted||(this._actionError=`Couldn't load repository data: ${i?.message??i}`)}).finally(()=>{this._impactRequest===t&&(this._impactLoading=!1)})}render(){if(this._detail)return this._detailPage(this._detail);let e=this._scope==="connected",t=e?"Repositories":`Add ${this._scope} repository`;return l`<div class="wrap"><div class="head">${e?re():this._back()}<h1>${t}</h1>${e&&this._data?l`<span class="count">${this._data.connectedCount} connected</span>`:u}</div><p class="intro">${e?"Manage connected repositories and their settings.":this._scope==="installed"?"Choose a repository the GitHub App can read. Installed repositories can be public or private.":"Choose a public repository your GitHub account is involved with. Random public repositories are not listed."}</p>${!e&&this._scope==="installed"?l`<div class="access-note"><p>Installed repositories are readable through the GitHub App. Install it on a repository or organization to make it available here.</p>${this._data?.installUrl?l`<a class="btn" href="${this._data.installUrl}" target="_blank" rel="noopener noreferrer">Configure GitHub access</a>`:u}</div>`:u}<div class="toolbar"><label class="search"><input type="search" aria-label="${e?"Search connected repositories":`Search ${this._scope} repositories`}" placeholder="Search by repository or owner…" .value="${this._query}" @input="${i=>this._search(i.target.value)}"></label> ${e?l`<button type="button" class="btn" @click="${()=>this._open("installed")}">${this._accessIcon("private")} Add installed repository</button> <button type="button" class="btn" @click="${()=>this._open("public")}">${this._accessIcon("public")} Add your public repository</button>`:l`<button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>{this._load()}}">Refresh</button>`}</div>${this._actionError?l`<p class="msg error" role="alert">${this._actionError}</p>`:u}<div aria-busy="${this._loading}">${this._body()}</div></div>`}_body(){if(this._error)return l`<p class="msg error" role="alert">Couldn't load repositories: ${this._error}</p><button type="button" class="btn" @click="${()=>{this._load()}}">Try again</button>`;if(this._loading||!this._data)return l`<div class="loading" role="status">Loading repositories…</div>`;let e=this._data.repositories??[];return l`${this._data.tokenMissing&&this._scope==="public"?l`<p class="msg">Log out and back in to refresh your GitHub membership access.</p>`:u} ${e.length>0?l`<div class="owners">${this._groupRepos(e).map(([t,i])=>l`<section aria-label="${t}"><h2 class="owner-head"><span class="owner-icon" aria-hidden="true">${t[0]??"?"}</span>${t}</h2><ul class="repos">${i.map(s=>this._row(s))}</ul></section>`)}</div>`:l`<div class="empty"><strong>${this._query?"No matching repositories":this._scope==="connected"?"No connected repositories yet":`No ${this._scope} repositories available`}</strong><p>${this._query?"Try a different repository or owner name.":this._scope==="connected"?"Add an installed or public repository to get started.":this._scope==="installed"?"Install the GitHub App, then refresh this list.":"Public repositories associated with your GitHub account will appear here."}</p></div>`} ${this._data.total>20?l`<nav class="pagination" aria-label="Repository pages"><span>${(this._page-1)*20+1}–${Math.min(this._page*20,this._data.total)} of ${this._data.total}</span> <button type="button" class="btn" ?disabled="${this._page===1}" @click="${()=>{this._page--,this._load()}}">Previous</button> <button type="button" class="btn" ?disabled="${this._page*20>=this._data.total}" @click="${()=>{this._page++,this._load()}}">Next</button></nav>`:u}`}_groupRepos(e){let t=new Map;for(let i of e){let s=i.fullName.split("/")[0];t.has(s)||t.set(s,[]),t.get(s).push(i)}return[...t]}_row(e){let t=e.fullName.slice(e.fullName.indexOf("/")+1),i=`${this._accessLabel(e)}${this._scope==="connected"&&e.active===!1?" \xB7 Deactivated":""}`,s=l`${Gi}<span class="repo-copy"><span class="repo-name">${t}</span><span class="repo-meta">${i}</span></span>`;return this._scope==="connected"?l`<li><button type="button" class="repo-row" aria-label="${`Manage ${e.fullName}`}" @click="${()=>this._openDetail(e)}">${s}<svg class="arrow" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg></button></li>`:l`<li class="repo-row">${s} ${e.selected?l`<span class="connected"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>Connected</span>`:e.private&&!e.installed?l`<span class="repo-meta">Needs App access</span>`:l`<button type="button" class="btn" aria-label="${`Add ${e.fullName}`}" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!0)}}">${this._busy===e.id?"Adding\u2026":"Add"}</button>`}</li>`}_accessLabel(e){return e.installed?e.private?"Private \xB7 GitHub App":"Public \xB7 GitHub App":"Public \xB7 GitHub membership"}_detailPage(e){let t=e.active!==!1,i=this._impact?.reports??[],s=this._impact?.bundles??[];return l`<div class="wrap"><div class="head">${this._back()}<h1>${e.fullName}</h1></div><p class="intro">Repository settings and stored data.</p>${this._actionError?l`<p class="msg error" role="alert">${this._actionError}</p>`:u}<section class="section" aria-label="Repository connection"><h2>Connection</h2><div class="settings-row"><div class="settings-copy"><strong>${this._accessLabel(e)}</strong><p>${t?"Active for new scans and uploads.":"Deactivated. Stored reports and bundles are retained."}</p></div><span class="${`status-line ${t?"":"inactive"}`}">${t?"Active":"Deactivated"}</span> ${e.htmlUrl?l`<a class="btn" href="${e.htmlUrl}" target="_blank" rel="noopener noreferrer">View on GitHub</a>`:u}</div><div class="settings-row"><div class="settings-copy"><strong>${t?"Deactivate repository":"Reactivate repository"}</strong><p>${t?"Pause new scans while preserving all stored data and attachments.":"Make this repository available for new scans and bundle attachments again."}</p></div><button type="button" class="btn" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!t)}}">${this._busy===e.id?t?"Deactivating\u2026":"Reactivating\u2026":t?"Deactivate":"Reactivate"}</button></div></section><section class="data-section" aria-label="Stored repository data"><h2>Stored data</h2>${this._impactLoading?l`<p class="data-empty">Loading attached reports and bundles…</p>`:this._impact==null?l`<p class="data-empty">Attached data could not be loaded.</p><button type="button" class="btn" @click="${()=>this._openDetail(e)}">Try again</button>`:l`<div class="dialog-data"><section><h3>Reports (${i.length})</h3>${i.length>0?l`<ul>${i.map(o=>l`<li>${o.filename}${o.repoDirectory?` \xB7 ${o.repoDirectory}`:u}</li>`)}</ul>`:l`<p class="data-empty">No reports attached.</p>`}</section><section><h3>Bundles (${s.length})</h3>${s.length>0?l`<ul>${s.map(o=>l`<li>${o.filename}</li>`)}</ul>`:l`<p class="data-empty">No bundles attached.</p>`}</section></div>`}</section><section class="section" aria-label="Permanent repository removal"><h2>Permanent removal</h2><div class="settings-row"><div class="settings-copy"><strong>Delete repository and stored data</strong><p>Deactivation is reversible. Permanent removal deletes this repository’s attached reports and bundles; it cannot be undone.</p></div><button type="button" class="btn danger" ?disabled="${this._busy!=null||this._impactLoading||this._impact==null}" @click="${()=>{this._removeOpen=!0,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName=""}}">Remove permanently</button></div></section>${this._removeOpen&&this._impact!=null&&!this._impactLoading?this._removeDialog(e,i,s):u}</div>`}_removeDialog(e,t,i){let s=t.length>0||i.length>0,o=this._canRemove(e);return l`<div class="dialog-backdrop" role="presentation" @click="${n=>{n.target===n.currentTarget&&(this._removeOpen=!1)}}"><section class="${`dialog ${s?"":"small"}`}" role="dialog" aria-modal="true" aria-labelledby="remove-repo-title"><h2 id="remove-repo-title">Remove ${e.fullName} permanently?</h2><p class="dialog-copy">${s?"This destructive action will remove the repository and the stored data listed below. Deactivation keeps all of it.":"This repository has no attached reports or bundles. Permanent removal deletes its connection record."}</p>${s?l`<div class="dialog-data"><section><h3>Reports to delete (${t.length})</h3><ul>${t.map(n=>l`<li>${n.filename}${n.repoDirectory?` \xB7 ${n.repoDirectory}`:u}</li>`)}</ul></section><section><h3>Bundles to delete (${i.length})</h3><ul>${i.map(n=>l`<li>${n.filename}</li>`)}</ul></section></div>`:u} <label class="confirm-line"><input type="checkbox" .checked="${this._acknowledge}" @change="${n=>{this._acknowledge=n.target.checked}}">I understand this permanently deletes the repository connection${s?", reports, and bundles":""}.</label> ${(this._impact?.triageCount??0)>0?l`<label class="confirm-line"><input type="checkbox" .checked="${this._deleteTriage}" @change="${n=>{this._deleteTriage=n.target.checked}}">Also delete ${this._impact.triageCount} triage entr${this._impact.triageCount===1?"y":"ies"} belonging only to this repository.</label>`:u} ${s?l`<label class="confirm-line">Type <strong>${e.fullName}</strong> to confirm.<input class="confirm-name" type="text" autocomplete="off" .value="${this._confirmName}" @input="${n=>{this._confirmName=n.target.value}}"></label>`:u}<div class="dialog-actions"><button type="button" class="btn" @click="${()=>{this._removeOpen=!1}}">Cancel</button><button type="button" class="btn danger" ?disabled="${!o}" @click="${()=>{this._remove(e)}}">${this._busy===e.id?"Removing\u2026":"Remove permanently"}</button></div></section></div>`}_accessIcon(e){return e==="private"?l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="7" width="10" height="7" rx="1"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg>`:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path d="M2.5 8h11M8 2c1.5 1.7 2.2 3.7 2.2 6S9.5 12.3 8 14c-1.5-1.7-2.2-3.7-2.2-6S6.5 3.7 8 2Z"/></svg>`}async _setActive(e,t){if(this._busy==null){this._busy=e.id,this._actionError=null;try{if(await nn(e.id,t,this._csrf),!this.isConnected)return;this._detail?.id===e.id&&(this._detail={...this._detail,active:t}),this._data&&(this._data={...this._data,repositories:this._data.repositories.map(i=>i.id===e.id?{...i,active:t}:i)}),this._scope!=="connected"&&await this._load()}catch(i){let s=t?e.active===!1?"reactivate":"add":"deactivate";this._actionError=`Couldn't ${s} ${e.fullName}: ${i?.message??i}`}finally{this._busy=null}}}_canRemove(e){return this._busy!=null||this._impactLoading||this._impact?.repoId!==e.id||!this._acknowledge?!1:!(this._impact.reports.length>0||this._impact.bundles.length>0)||this._confirmName===e.fullName}async _remove(e){if(this._canRemove(e)){this._busy=e.id,this._actionError=null;try{await ln(e.id,e.fullName,this._deleteTriage,this._csrf),this._removeOpen=!1,this._detail=null,this._impact=null,await this._load()}catch(t){this._actionError=`Couldn't remove ${e.fullName}: ${t?.message??t}`}finally{this._busy=null}}}};customElements.define("managed-admin-repos",nr);async function cn(){let r=await y("/api/admin/reports",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function dn(r,e,t=null,i=""){let s={"content-type":r.type||"application/json","x-report-filename":encodeURIComponent(r.name)};e&&(s["x-csrf-token"]=e),t!=null&&(s["x-repo-id"]=String(t)),i!==""&&(s["x-repo-directory"]=encodeURIComponent(i));let o=await y("/api/admin/reports",{method:"POST",credentials:"same-origin",headers:s,body:r});if(!o.ok){if(o.status===413)throw new Error("too large");let n="";try{let a=await o.json();a?.error==="repo-not-connected"&&typeof a.repo=="string"&&(n=`: ${a.repo} is not connected`)}catch{}throw new Error(`HTTP ${o.status}${n}`)}return o.json()}async function pn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/reports/set-visible",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({reportId:r,visible:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function un(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await y("/api/admin/reports/set-repo",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({reportId:r,repoId:e,directory:t})});if(!o.ok)throw o.status===409?new Error("this report already defines its repository"):new Error(o.status===400?"invalid repository or directory":`HTTP ${o.status}`);return o.json()}async function hn(r,e){let t=e?{"x-csrf-token":e}:{},i=await y(`/api/admin/reports/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}function ar(r){return typeof r!="number"||!Number.isFinite(r)?"":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`}function hr(r){return[{value:null,label:"No repository",special:!0},...r.map(e=>({value:e.repoId,label:e.fullName}))]}function mn(r,e,t,i="Repository for new bundles"){return!Array.isArray(r)||r.length===0?u:l`<div class="repo-picker"><span class="repo-picker-label">${i}</span><repository-selector class="repo-select" .options="${hr(r)}" .value="${e}" label="${i}" @repository-change="${s=>t(s.detail.value)}"></repository-selector></div>`}function fn(r,e,t){return!Array.isArray(r)||r.length===0?u:l`<repository-selector class="repo-attach" label="Attach to a repository" .options="${hr(r)}" .value="${e??null}" @repository-change="${i=>t(i.detail.value)}"></repository-selector>`}function Wi(r,e=!0){let t=document.createElement("input");t.type="file",t.multiple=e,t.addEventListener("change",()=>{r([...t.files])},{once:!0}),t.click()}function Ki(r,e,t){let i=0,s=d=>Array.from(d.dataTransfer?.types??[]).includes("Files"),o=d=>{s(d)&&(d.preventDefault(),i+=1,t(!0))},n=d=>{s(d)&&d.preventDefault()},a=d=>{s(d)&&(i=Math.max(0,i-1),i===0&&t(!1))},c=d=>{s(d)&&(d.preventDefault(),d.stopPropagation(),i=0,t(!1),e([...d.dataTransfer.files]))};return r.addEventListener("dragenter",o),r.addEventListener("dragover",n),r.addEventListener("dragleave",a),r.addEventListener("drop",c),()=>{r.removeEventListener("dragenter",o),r.removeEventListener("dragover",n),r.removeEventListener("dragleave",a),r.removeEventListener("drop",c)}}var lr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0},_preview:{state:!0},_previewLoading:{state:!0},_locationReport:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0},_repoId:{state:!0},_repoDirectory:{state:!0}};static styles=[te,x`:host{display:block;position:relative;flex:1 1 auto;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .9);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.drop-card{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 1.2rem;padding:.7rem .8rem;border:1px dashed var(--border);border-radius:8px;background:rgb(from var(--surface) r g b / .55)}.drop-card strong{display:block;font-size:.78rem;font-weight:600}.drop-card .drop-copy>span{display:block;margin-top:.12rem;color:var(--muted);font-size:.7rem}.drop-icon{display:grid;place-items:center;width:1.8rem;height:1.8rem;flex:0 0 auto;border-radius:5px;color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.drop-icon svg{width:1rem;height:1rem}.drop-copy{min-width:0}.drop-browse{margin-left:auto;flex:0 0 auto;padding:.3rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.72rem}.head{display:flex;align-items:center;gap:.65rem;margin:0 0 .45rem}h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.head-actions{display:flex;align-items:center;gap:.5rem;margin-left:auto}.action,.upload{display:inline-flex;align-items:center;justify-content:center;min-height:2rem;padding:.3rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);font:inherit;font-size:.78rem;font-weight:500;white-space:nowrap;cursor:default}.upload{border-color:var(--accent);background:var(--accent);color:var(--bg);font-weight:600}.action:disabled,.upload:disabled{opacity:.5}.action:hover:not(:disabled),.upload:hover:not(:disabled){background:var(--surface-active)}.upload:hover:not(:disabled){filter:brightness(1.08)}.intro{max-width:44rem;margin:0 0 1.4rem;color:var(--muted);font-size:.85rem;line-height:1.5}.hint{margin:0 0 .7rem;color:var(--muted);font-size:.75rem}.reports{display:grid;gap:.5rem;margin:0;padding:0;list-style:none}.report{overflow:hidden;border:1px solid var(--border);border-radius:9px;background:var(--surface)}.report-main{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.55rem;padding:.42rem .6rem}.report-logo{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;border-radius:5px;overflow:hidden}.report-logo svg{width:1.2rem;height:1.2rem}.report-logo.brand-deepview{--brand-bg:#2563eb;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-claude{--brand-bg:#d97757;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-codex{--brand-bg:#fff;--brand-fg:#000;background:var(--brand-bg)}.report-logo.brand-vercel{--brand-bg:#000;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-piolium{--brand-bg:#fbb829;--brand-fg:#1c1b19;background:var(--brand-bg)}.report-logo.generic{color:var(--muted);background:var(--surface-active);border:1px solid var(--border)}.report-logo .fg{fill:var(--brand-fg)}.report-logo .bg{fill:var(--brand-bg)}.report-logo.brand-codex .bg,.report-logo.brand-vercel .bg{stroke:var(--brand-fg);stroke-width:.5}.report-copy{display:grid;flex:1;min-width:0;gap:.08rem}.report-name{font-size:.78rem;font-weight:600;overflow-wrap:anywhere}.report-location{color:var(--muted);font-size:.66rem;overflow-wrap:anywhere}.report-meta{display:flex;flex-wrap:nowrap;align-items:center;gap:.22rem .4rem;min-width:0;overflow:hidden;color:var(--muted);font-size:.62rem;line-height:1.25}.report-meta>span{min-width:0}.report-meta>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.report-meta .report-location{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.status{display:inline-flex;align-items:center;width:fit-content;padding:.1rem .35rem;border:1px solid var(--border);border-radius:4px;font-size:.65rem;font-weight:500}.status.hidden{color:var(--muted)}.status.visible{color:var(--accent);border-color:rgb(from var(--accent) r g b / .35);background:rgb(from var(--accent) r g b / .08)}.report-actions{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:.25rem;margin-left:auto}.report-actions .action{min-height:1.7rem;padding:.2rem .44rem;font-size:.68rem}.report-actions a{color:var(--accent);text-decoration:none}.report-actions a:hover{text-decoration:underline}.preview{border-top:1px solid var(--border);padding:.7rem .85rem .8rem 3.35rem}.preview pre{max-height:16rem;overflow:auto;margin:0;padding:.65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--muted);font:.7rem/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.preview-loading{color:var(--muted);font-size:.75rem}.location-editor{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,.7fr) auto;align-items:end;gap:.5rem;padding:.7rem .85rem .8rem 3.35rem;border-top:1px solid var(--border);background:rgb(from var(--bg) r g b / .35)}.location-field{display:grid;gap:.25rem;min-width:0}.location-field label{color:var(--muted);font-size:.68rem}.location-field input,.location-field select{width:100%;min-width:0;height:2rem;padding:.3rem .45rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem}.location-actions{display:flex;gap:.35rem}.empty{padding:2.5rem 1rem;border:1px solid var(--border);border-radius:8px;text-align:center}.empty strong{display:block;margin-bottom:.4rem;font-size:.9rem;font-weight:500}.empty p,.msg{margin:0;color:var(--muted);font-size:.8rem;line-height:1.5}.msg.error{color:var(--critical,#c00)}.head-actions{width:100%;margin-left:0}.report-main{grid-template-columns:auto minmax(0,1fr)}.report-actions{grid-column:2;width:auto;margin-left:0;justify-content:flex-start}.report-meta{flex-wrap:wrap}.location-editor,.preview{padding-left:.85rem}.location-editor{grid-template-columns:1fr;align-items:stretch}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._dragOver=!1,this._preview=null,this._previewLoading=null,this._previewRequest=null,this._locationReport=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._repoId=null,this._repoDirectory="",this._teardownDrop=null,this._queue=[]}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ki(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._cancelPreview()}async _load(){this._cancelPreview(),this._error=null,this._data=null;try{let[e,t]=await Promise.all([ee(),cn()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}render(){return l`${this._dragOver?l`<div class="dropzone">Drop reports to upload</div>`:u}<div class="wrap"><div class="head">${re()}<h1>Reports</h1></div><p class="intro">Upload reports. New reports stay hidden until you make them visible.</p><div class="drop-card"><span class="drop-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 10V2m0 0L5 5m3-3 3 3M3 9v3.5A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5V9"/></svg></span><span class="drop-copy"><strong>Drop reports here</strong><span>Reports can be dropped anywhere on this page, or selected from your computer.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>Wi(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div>${this._body()}</div>`}_body(){if(this._error!=null)return l`<p class="msg error">Couldn't load reports: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.reports)?this._data.reports:[];return e.length===0?l`<div class="empty"><strong>No reports uploaded yet</strong><p>Drop a report here or browse files above.</p></div>`:l`<p class="hint">${e.length} stored ${e.length===1?"report":"reports"}</p><ul class="reports">${e.map(t=>this._row(t))}</ul>`}_row(e){let t=e.analyzer??e.source??e.producer??"default",i=bt[t]??bt.default,s=e.repoEmbedded!==!0,o=e.repoEmbedded===!0||e.repoId!=null,n=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",a=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleString():"",c=[e.uploadedByLogin?`by ${e.uploadedByLogin}`:"uploader removed",a,ar(e.byteSize)].filter(Boolean).join(" \xB7 ");return l`<li class="report"><div class="report-main">${L(i)} <span class="report-copy"><span class="report-name">${e.filename}</span><span class="report-meta"><span class="${`status ${e.visible?"visible":"hidden"}`}">${e.visible?"Visible":"Hidden"}</span><span class="report-location">${n}</span><span>${c}</span></span></span> <span class="report-actions">${s?l`<button type="button" class="action" @click="${()=>this._openLocation(e)}">${e.repoId==null?"Set location":"Change location"}</button>`:u}<button type="button" class="action" @click="${()=>{this._togglePreview(e)}}">${this._preview===e.id?"Hide preview":"Preview"}</button>${e.visible?l`<button type="button" class="action" @click="${()=>{this._setVisible(e,!1)}}">Hide</button>`:l`<button type="button" class="action" ?disabled="${!o}" @click="${()=>{this._setVisible(e,!0)}}">Make visible</button>`}<a class="action" href="${`/api/admin/reports/${encodeURIComponent(e.id)}`}">Download</a><button type="button" class="action" @click="${()=>this._delete(e)}">Delete</button></span></div>${this._preview===e.id?l`<div class="preview">${this._previewLoading===e.id?l`<span class="preview-loading">Loading preview…</span>`:l`<pre>${this._previewText??""}</pre>`}</div>`:u} ${this._locationReport===e.id?this._locationEditor(e):u}</li>`}_openLocation(e){this._locationReport=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[];return l`<div class="location-editor"><div class="location-field"><span>Repository</span><repository-selector label="Repository for report" .options="${hr(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${i=>{this._locationRepo=i.detail.value}}"></repository-selector></div><div class="location-field"><label for="${`report-dir-${e.id}`}">Directory (optional)</label><input id="${`report-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" @input="${i=>{this._locationDirectory=i.target.value}}"></div><div class="location-actions"><button type="button" class="action" @click="${()=>{this._locationReport=null}}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy||this._locationRepo==null}" @click="${()=>{this._saveLocation(e)}}">Save</button></div></div>`}async _saveLocation(e){if(!(this._locationRepo==null||this._locationBusy)){this._locationBusy=!0;try{await un(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),this._locationReport=null,await this._load()}catch(t){this._error=`Couldn't set report location: ${String(t?.message??t)}`}finally{this._locationBusy=!1}}}_cancelPreview(){this._previewRequest?.abort(),this._previewRequest=null,this._preview=null,this._previewLoading=null,this._previewText=""}async _togglePreview(e){let t=this._preview===e.id;if(this._cancelPreview(),t)return;let i=new AbortController;this._previewRequest=i;let s=()=>this._previewRequest===i&&!i.signal.aborted;this._preview=e.id,this._previewLoading=e.id;try{let o=await y(`/api/admin/reports/${encodeURIComponent(e.id)}`,{credentials:"same-origin",signal:i.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);let n=await o.text();s()&&(this._previewText=n.slice(0,4e3)+(n.length>4e3?`
47
- \u2026`:""))}catch(o){s()&&(this._previewText=`Preview unavailable: ${o?.message??o}`)}finally{s()&&(this._previewLoading=null)}}async _setVisible(e,t){try{await pn(e.id,t,this._csrf),e.visible=t,this.requestUpdate()}catch(i){this._error=`Couldn't change report visibility: ${String(i?.message??i)}`}}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;)await dn(this._queue.shift(),this._csrf,this._repoId,this._repoDirectory.trim())}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load()}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? This can't be undone.`)){try{await hn(e.id,this._csrf)}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load()}}};customElements.define("managed-admin-reports",lr);async function gn(){let r=await y("/api/admin/bundles",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function bn(r,e,t){let i={"content-type":"application/octet-stream","x-bundle-filename":encodeURIComponent(r.name)};e&&(i["x-csrf-token"]=e),t!=null&&(i["x-repo-id"]=String(t));let s=await y("/api/admin/bundles",{method:"POST",credentials:"same-origin",headers:i,body:r});if(!s.ok)throw new Error(s.status===413?"too large":`HTTP ${s.status}`);return s.json()}async function vn(r,e){let t=e?{"x-csrf-token":e}:{},i=await y(`/api/admin/bundles/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function _n(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/bundles/set-repo",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({bundleId:r,repoId:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var yn=l`<svg class="report-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M8.878.392a1.75 1.75 0 0 0-1.756 0l-5.25 3.045A1.75 1.75 0 0 0 1 4.951v6.098c0 .624.332 1.2.872 1.514l5.25 3.045a1.75 1.75 0 0 0 1.756 0l5.25-3.045c.54-.313.872-.89.872-1.514V4.951c0-.624-.332-1.2-.872-1.514ZM7.875 1.69a.25.25 0 0 1 .25 0l4.63 2.685L8 7.133 3.245 4.375Zm-5.125 4.4 4.5 2.61v5.317l-4.375-2.537a.25.25 0 0 1-.125-.216Zm6 7.927V8.7l4.5-2.61v3.96a.25.25 0 0 1-.125.216Z"/></svg>`,cr=class extends w{static properties={_data:{state:!0},_repoId:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[te,x`:host{display:block;position:relative;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.head{margin-bottom:.4rem}h1{font-size:1.65rem;letter-spacing:-.035em}button,select{font:inherit;cursor:default}a:focus-visible,button:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.intro{margin:0 0 1rem;color:var(--muted);font-size:.8rem;line-height:1.45}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.upload-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.55rem 1rem;padding:.7rem .8rem;margin-bottom:1rem;border:1px dashed color-mix(in srgb,var(--border) 70%,var(--muted));border-radius:8px;background:var(--surface)}.upload-copy{display:grid;gap:.25rem}.upload-copy strong{font-size:.87rem;font-weight:600}.upload-copy>span{color:var(--muted);font-size:.72rem}.upload-controls{display:flex;align-items:end;gap:.65rem}.repo-picker{display:grid;gap:.3rem;min-width:0}.repo-picker-label{color:var(--muted);font-size:.67rem}.repo-attach,.repo-select{min-width:0;width:100%}.repo-select{max-width:18rem}.drop-browse{height:2rem;flex-shrink:0;padding:.3rem .75rem;border:1px solid var(--accent);border-radius:5px;color:var(--bg);background:var(--accent);font-size:.74rem;font-weight:600}.drop-browse:hover:not(:disabled){filter:brightness(1.08)}.drop-browse:disabled{opacity:.5}.section-head{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:.5rem;margin-bottom:.6rem}.section-head h2{margin:0;font-size:.85rem;font-weight:600}.summary{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums}.unassigned{color:var(--high,#d97732)}.bundles{margin:0;padding:0;list-style:none}.bundle-groups{display:grid;gap:.65rem}.bundle-group{overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--surface)}.bundle-group-head{display:flex;align-items:center;justify-content:space-between;gap:.6rem;padding:.45rem .7rem;border-bottom:1px solid var(--border)}.bundle-group-head strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.74rem;font-weight:600}.bundle-group-head span{color:var(--muted);font-size:.67rem}.bundle-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,15rem) auto;align-items:center;gap:.75rem;padding:.42rem .65rem}.bundle-row+.bundle-row{border-top:1px solid var(--border)}.identity{display:flex;align-items:flex-start;min-width:0;gap:.5rem}.bundle-icon{display:grid;place-items:center;width:1.45rem;height:1.45rem;flex-shrink:0;color:var(--muted)}.bundle-icon svg{width:1rem;height:1rem}.who{display:grid;min-width:0;gap:.12rem}.filename{font-size:.82rem;font-weight:600;overflow-wrap:anywhere}.meta{display:flex;flex-wrap:wrap;gap:.2rem .5rem;color:var(--muted);font-size:.62rem;line-height:1.35}.kind{color:var(--text)}.bundle-location{display:grid;gap:.18rem;min-width:0}.bundle-location-label{color:var(--muted);font-size:.6rem}.actions{display:flex;gap:.2rem}.action{display:grid;place-items:center;width:1.65rem;height:1.65rem;padding:.35rem;border:1px solid transparent;border-radius:5px;background:0 0;color:var(--muted);text-decoration:none}.action svg{width:1rem;height:1rem}.action:hover{color:var(--text);border-color:var(--border);background:var(--surface)}.action.danger:hover{color:var(--critical,#e5534b)}.msg{padding:1rem 0;margin:0;color:var(--muted);font-size:.8rem}.msg.error{color:var(--critical,#e5534b)}.upload-controls{justify-content:space-between}.repo-picker{flex:1}.repo-select{max-width:none}.bundle-row{grid-template-columns:minmax(0,1fr) auto;gap:.5rem}.bundle-location{grid-column:1;padding-left:2.4rem}.actions{grid-column:2;grid-row:1/3}.repo-picker{flex-basis:100%}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._repoId=null,this._dragOver=!1,this._teardownDrop=null,this._queue=[]}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ki(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.()}async _load(){this._error=null,this._data=null;try{let[e,t]=await Promise.all([ee(),gn()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}render(){return l`${this._dragOver?l`<div class="dropzone">Drop bundles to upload</div>`:u}<div class="wrap"><div class="head">${re()}<h1>Bundles</h1></div><p class="intro">Source bundles and sourcemaps for your repositories.</p><section class="upload-panel" aria-label="Upload bundles"><div class="upload-copy"><strong>Drop bundles here</strong><span>Choose a repository for your uploads.</span></div><div class="upload-controls">${mn(this._data?.repos,this._repoId,e=>{this._repoId=e},"Repository")}<button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>Wi(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div></section>${this._body()}</div>`}_body(){if(this._error!=null)return l`<p class="msg error">Couldn't load bundles: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.bundles)?this._data.bundles:[],t=e.filter(o=>o.repoId==null).length,i=e.reduce((o,n)=>o+(Number.isFinite(n.byteSize)?n.byteSize:0),0),s=Map.groupBy(e,o=>o.repoFullName||"Unattached");return l`<div class="section-head"><h2>Stored bundles</h2><span class="summary"><span>${e.length} ${e.length===1?"bundle":"bundles"}</span><span>${ar(i)}</span>${t?l`<span class="unassigned">${t} unattached</span>`:u}</span></div>${e.length>0?l`<div class="bundle-groups">${[...s].toSorted(([o],[n])=>o==="Unattached"?1:n==="Unattached"?-1:o.localeCompare(n)).map(([o,n])=>l`<section class="bundle-group"><div class="bundle-group-head"><strong>${o}</strong><span>${n.length} ${n.length===1?"bundle":"bundles"}</span></div><ul class="bundles">${n.map(a=>this._row(a))}</ul></section>`)}</div>`:l`<p class="msg">No bundles uploaded yet.</p>`}`}_row(e){let t=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return l`<li class="bundle-row"><span class="identity"><span class="bundle-icon" aria-hidden="true">${yn}</span><span class="who"> <span class="filename">${e.filename}</span> <span class="meta"><span class="kind">${e.kind==="stasis"?"Stasis":"Sourcemaps"}</span><span>${ar(e.byteSize)}</span><span>${t}</span>${e.uploadedByLogin?l`<span>@${e.uploadedByLogin}</span>`:u}</span> </span></span><span class="bundle-location">${fn(this._data?.repos,e.repoId,i=>this._setRepo(e,i))}</span> <span class="actions"><a class="action" aria-label="${`Download ${e.filename}`}" href="${`/api/admin/bundles/${encodeURIComponent(e.id)}`}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v8m-3-3 3 3 3-3M3 11v3h10v-3"/></svg></a><button type="button" class="action danger" aria-label="${`Delete ${e.filename}`}" @click="${()=>this._delete(e)}">${rr}</button></span></li>`}async _setRepo(e,t){try{await _n(e.id,t,this._csrf)}catch(i){this._error=`Couldn't change repo: ${String(i?.message??i)}`}await this._load()}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;){let t=this._queue.shift();await bn(t,this._csrf,this._repoId)}}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load()}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? Linked reports will keep their pending link.`)){try{await vn(e.id,this._csrf)}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load()}}};customElements.define("managed-admin-bundles",cr);var dr=class extends w{static styles=[te,x`:host{display:block}`];constructor(){super(),this._loadModels=e=>ae(e,y),this._source={bundles:ri(),repositories:ei,scans:ti.map(e=>({...e}))},this._loadReportSources=async e=>{let[t,i]=await Promise.all([y("/api/admin/reports",{signal:e,credentials:"same-origin"}),y("/api/admin/scan-results",{signal:e,credentials:"same-origin"})]);if(!t.ok)throw new Error(`Reports: HTTP ${t.status}`);if(!i.ok&&i.status!==404)throw new Error(`Scan results: HTTP ${i.status}`);let s=await t.json();return s.reports=await Promise.all((s.reports??[]).filter(o=>o.visible&&o.repoId!=null).map(async o=>{let n=await y(`/api/admin/reports/${encodeURIComponent(o.id)}`,{signal:e,credentials:"same-origin"});if(!n.ok)throw new Error(`Report ${o.filename}: HTTP ${n.status}`);return{...o,content:await n.text()}})),Di(s,i.ok?await i.json():{bundles:[],results:[]})}}render(){return l`<deepview-scan-page .source="${this._source}" .loadModels="${this._loadModels}" .loadReportSources="${this._loadReportSources}"><span slot="navigation">${re()}</span></deepview-scan-page>`}};customElements.define("managed-admin-scans",dr);async function Zi(){let r=await y("/api/admin/teams",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function H(r,e,t){let i={"content-type":"application/json"};e&&(i["x-csrf-token"]=e);let s=await y(r,{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify(t)});if(!s.ok)throw new Error(s.status===409?"name already taken":`HTTP ${s.status}`)}var pr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_renamingId:{state:!0},_repoChoices:{state:!0},_memberChoices:{state:!0}};static styles=[te,ur,x`.create-team{display:flex;align-items:center;gap:.5rem;margin-bottom:1.2rem}.create-team label{color:var(--muted);font-size:.78rem;margin-right:.25rem}.new-name{width:15rem}.team{border:1px solid var(--border);border-radius:9px;margin-bottom:1rem;background:var(--surface);overflow:hidden}.team-head{display:flex;align-items:center;gap:.65rem;min-height:3.6rem;padding:.8rem 1rem;border-bottom:1px solid var(--border)}.team-icon{display:grid;place-items:center;flex:0 0 auto;width:1.9rem;height:1.9rem;border-radius:6px;background:rgb(from var(--accent) r g b / .1);color:var(--accent)}.team-icon svg{width:1.05rem;height:1.05rem}.team-name{margin:0;min-width:0;font-size:1rem;font-weight:600;letter-spacing:-.015em;overflow-wrap:anywhere}.team-actions{display:flex;gap:.25rem;margin-left:auto}.rename-input{flex:1;max-width:22rem;width:0}.team-body{display:grid;grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr)}.sub{min-width:0;padding:1rem}.sub+.sub{border-left:1px solid var(--border)}.sub-title{display:flex;align-items:center;gap:.45rem;margin:0;font-size:.82rem;font-weight:600}.sub-title .count{height:1.1rem;min-width:1.1rem;font-size:.65rem;padding:0 .3rem}.sub-description{display:flex;flex-direction:column;gap:.12rem;margin:.35rem 0 .65rem;color:var(--muted);font-size:.72rem;line-height:1.4}.links{list-style:none;margin:0 0 .5rem;padding:0}.links li{display:flex;align-items:center;gap:.5rem;min-height:2.9rem;padding:.5rem 0}.links li+li{border-top:1px solid var(--border)}.repo-icon{flex:0 0 auto;color:var(--muted);width:.95rem;height:.95rem}.repo-copy{display:flex;min-width:0;flex-direction:column;gap:.2rem}.ln{min-width:0;font-size:.8rem;font-weight:500;overflow-wrap:anywhere}.path{color:var(--muted);font-family:var(--mono);font-size:.7rem;overflow-wrap:anywhere}.repo-row .icon-btn{margin-left:auto}.links .member-row{display:grid;grid-template-columns:minmax(0,1fr) auto 1.8rem;gap:.45rem}.member{display:flex;align-items:center;gap:.45rem;min-width:0}.member .avatar{width:1.6rem;height:1.6rem;font-size:.65rem}.perms{display:flex;flex-wrap:wrap;gap:.3rem}.perm{display:inline-flex;align-items:center;gap:.3rem;padding:.3rem .4rem;border:1px solid var(--border);border-radius:5px;font-size:.67rem;color:var(--muted);user-select:none}.perm:has(:checked){color:var(--text);background:rgb(from var(--accent) r g b / .07);border-color:rgb(from var(--accent) r g b / .2)}.perm:has(:disabled){opacity:.5}.add-row{display:flex;align-items:center;gap:.4rem;padding-top:.55rem}.add-row repository-selector,.add-row select,.add-row user-selector{flex:1;width:0}.add-repo-path{flex:.75;width:0}.add-row .btn{flex:0 0 auto}.muted{color:var(--muted);font-size:.78rem;margin:.75rem 0}.sub+.sub{border-left:0;border-top:1px solid var(--border)}.add-row{max-width:36rem}.create-team label{flex-basis:100%}.new-name{flex:1;width:0}.sub,.team-head{padding-left:.75rem;padding-right:.75rem}.links .member-row{grid-template-columns:minmax(0,1fr) 1.8rem}.perms{grid-row:2;padding-left:2.05rem}.member-row>.icon-btn{grid-column:2;grid-row:1}.add-row{flex-wrap:wrap}.add-repo-sel{flex-basis:calc(100% - 4rem)!important}.add-repo-path{order:1;flex-basis:100%}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._renamingId=null,this._repoChoices=new Map,this._memberChoices=new Map}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null;try{let[e,t]=await Promise.all([ee(),Zi()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}async _do(e){if(!this._busy){this._busy=!0,this._error=null;try{await e()}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load()}}}render(){return l`<div class="wrap"><div class="head">${re()}<h1>Teams</h1>${this._data?.teams?l`<span class="count">${this._data.teams.length}</span>`:u}</div><p class="intro">Group repositories and give members access to the findings they need.</p><div class="create-team"><label for="new-team-name">New team</label> <input id="new-team-name" class="new-name" type="text" placeholder="Team name" maxlength="100" ?disabled="${this._busy}" @keydown="${e=>{e.key==="Enter"&&this._create()}}"> <button class="btn primary" ?disabled="${this._busy}" @click="${()=>this._create()}">${tr} Create team</button></div>${this._body()}</div>`}_body(){if(this._error!=null&&this._data==null)return l`<p class="msg error">Couldn't load teams: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.teams)?this._data.teams:[];return l`${this._error==null?u:l`<p class="msg error">${this._error}</p>`} ${e.length===0?l`<p class="msg">No teams yet. Create one above.</p>`:e.map(t=>this._team(t))}`}_team(e){return l`<section class="team" aria-label="${e.name}"><div class="team-head"><span class="team-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2.5"/><path d="M1.5 13v-1c0-2 1.8-3.5 4.5-3.5s4.5 1.5 4.5 3.5v1M11 2.5a2.5 2.5 0 0 1 0 5M12 9c1.7.5 2.5 1.5 2.5 3v1"/></svg></span>${this._renamingId===e.id?l`<input class="rename-input" type="text" .value="${e.name}" maxlength="100" aria-label="Team name" @keydown="${t=>this._renameKey(t,e)}"> <button class="btn" ?disabled="${this._busy}" @click="${t=>this._saveRename(e,t)}">Save</button> <button class="btn" @click="${()=>{this._renamingId=null}}">Cancel</button>`:l`<h2 class="team-name">${e.name}</h2><span class="team-actions"><button class="icon-btn" aria-label="${`Rename ${e.name}`}" ?disabled="${this._busy}" @click="${()=>{this._renamingId=e.id}}">${Zo}</button> <button class="icon-btn danger" aria-label="${`Delete ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._deleteTeam(e)}">${Yo}</button></span>`}</div><div class="team-body"><div class="sub"><h3 class="sub-title">Repositories <span class="count">${e.repos.length}</span></h3><p class="sub-description">Source repositories included in this team.</p>${e.repos.length===0?l`<p class="muted">No repositories linked.</p>`:l`<ul class="links">${e.repos.map(t=>this._repoRow(e,t))}</ul>`} ${this._addRepoRow(e)}</div><div class="sub"><h3 class="sub-title">Members <span class="count">${e.members.length}</span></h3><p class="sub-description"><span>Membership includes the scan’s standard non-security findings.</span><span>Add underlying dependency or security findings per member.</span></p>${e.members.length===0?l`<p class="muted">No members.</p>`:l`<ul class="links">${e.members.map(t=>this._memberRow(e,t))}</ul>`} ${this._addMemberRow(e)}</div></div></section>`}_repoRow(e,t){return l`<li class="repo-row">${Gi} <span class="repo-copy"><span class="ln">${t.fullName}</span>${t.path?l`<span class="path">/${t.path.replace(/^\/+/u,"")}</span>`:u}</span> <button class="icon-btn danger" aria-label="${`Remove ${t.fullName}${t.path?`/${t.path}`:""} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>H("/api/admin/teams/remove-repo",this._csrf,{teamId:e.id,repoId:t.repoId,path:t.path??null}))}">${rr}</button></li>`}_addRepoRow(e){let t=Array.isArray(this._data.repos)?this._data.repos:[];return t.length===0?l`<p class="muted">No selected repositories to link — pick some on “Manage repositories”.</p>`:l`<div class="add-row"><repository-selector class="add-repo-sel" label="${`Repository to add to ${e.name}`}" placeholder="Add repository…" ?disabled="${this._busy}" .options="${t.map(i=>({value:i.repoId,label:i.fullName}))}" .value="${this._repoChoices.get(e.id)??null}" @repository-change="${i=>{this._repoChoices=new Map(this._repoChoices).set(e.id,i.detail.value)}}"></repository-selector><input class="add-repo-path" type="text" placeholder="Path (optional)" aria-label="${`Repository path in ${e.name} (optional)`}" maxlength="500" ?disabled="${this._busy}"> <button class="btn" aria-label="${`Add repository to ${e.name}`}" ?disabled="${this._busy||!this._repoChoices.has(e.id)}" @click="${i=>this._addRepo(e,i)}">${tr} Add</button></div>`}_memberRow(e,t){let i=Array.isArray(this._data.permissions)?this._data.permissions:[];return l`<li class="member-row"><span class="member">${qi(t.userId,t.login)}<span class="ln">${t.login}</span></span> <span class="perms">${i.map(s=>l`<label class="perm"><input type="checkbox" .checked="${t[s]===!0}" ?disabled="${this._busy}" aria-label="${`${it[s]??s} access for ${t.login} in ${e.name}`}" @change="${o=>this._togglePerm(e,t,s,o.target.checked)}"> ${it[s]??s}</label>`)} </span><button class="icon-btn danger" aria-label="${`Remove ${t.login} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>H("/api/admin/teams/remove-member",this._csrf,{teamId:e.id,userId:t.userId}))}">${rr}</button></li>`}_addMemberRow(e){let t=Array.isArray(this._data.users)?this._data.users:[],i=new Set(e.members.map(s=>s.userId));return l`<div class="add-row"><user-selector class="add-member-sel" label="${`Member to add to ${e.name}`}" placeholder="Add member…" ?disabled="${this._busy}" .users="${t.map(s=>({...s,disabled:i.has(s.id),detail:i.has(s.id)?"Member":""}))}" .value="${this._memberChoices.get(e.id)??null}" @user-change="${s=>{this._memberChoices=new Map(this._memberChoices).set(e.id,s.detail.value)}}"></user-selector><button class="btn" aria-label="${`Add member to ${e.name}`}" ?disabled="${this._busy||!this._memberChoices.has(e.id)||i.has(this._memberChoices.get(e.id))}" @click="${()=>this._addMember(e)}">${tr} Add</button></div>`}_create(){let e=this.renderRoot.querySelector(".new-name"),t=e?.value.trim();t&&this._do(async()=>{await H("/api/admin/teams",this._csrf,{name:t}),e&&(e.value="")})}_deleteTeam(e){globalThis.confirm?.(`Delete team \u201C${e.name}\u201D? Its repo + member links are removed.`)&&this._do(()=>H("/api/admin/teams/delete",this._csrf,{teamId:e.id}))}_renameKey(e,t){e.key==="Enter"?this._saveRename(t,e):e.key==="Escape"&&(this._renamingId=null)}_saveRename(e,t){if(this._busy)return;let i=t.target.closest(".team-head")?.querySelector(".rename-input")?.value.trim()??"";this._renamingId=null,!(i===""||i===e.name)&&this._do(()=>H("/api/admin/teams/rename",this._csrf,{teamId:e.id,name:i}))}_addRepo(e,t){let i=t.target.closest(".add-row"),s=this._repoChoices.get(e.id);if(!Number.isSafeInteger(s)||s<=0)return;let o=i?.querySelector(".add-repo-path")?.value??"";this._do(async()=>{await H("/api/admin/teams/set-repo",this._csrf,{teamId:e.id,repoId:s,path:o});let n=new Map(this._repoChoices);n.delete(e.id),this._repoChoices=n;let a=i?.querySelector(".add-repo-path");a&&(a.value="")})}_addMember(e){let t=this._memberChoices.get(e.id);!t||e.members.some(i=>i.userId===t)||this._do(async()=>{await H("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t});let i=new Map(this._memberChoices);i.delete(e.id),this._memberChoices=i})}_togglePerm(e,t,i,s){let o={};for(let n of this._data.permissions??[])o[n]=t[n]===!0;o[i]=s,this._do(()=>H("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t.userId,...o}))}};customElements.define("managed-admin-teams",pr);async function mr(r){let e;try{e=await y(r,{credentials:"same-origin",headers:{accept:"application/json"}})}catch{return null}if(!e.ok)return null;try{return await e.json()}catch{return null}}async function Wc(){let r=await mr("/api/auth/session"),e=r?.user;return e==null||typeof e.login!="string"?null:{id:e.id,login:e.login,name:typeof e.name=="string"?e.name:null,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:null,role:typeof e.role=="string"?e.role:"none",csrfToken:typeof r.csrfToken=="string"?r.csrfToken:null}}async function Kc(){let e=(await mr("/api/teams"))?.teams;return Array.isArray(e)?e.filter(t=>t!=null&&typeof t.id=="string"&&typeof t.name=="string").map(t=>({id:t.id,name:t.name,reports:Array.isArray(t.reports)?t.reports.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.filename=="string").map(i=>({id:i.id,filename:i.filename})):[],bundles:Array.isArray(t.bundles)?t.bundles.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.filename=="string").map(i=>({id:i.id,filename:i.filename,repoFullName:typeof i.repoFullName=="string"?i.repoFullName:""})):[]})):[]}async function Zc(r){let e;try{e=await y(`/api/reports/${encodeURIComponent(r)}`,{credentials:"same-origin"})}catch{return null}if(!e.ok)return null;try{return await e.text()}catch{return null}}async function Yc(r){let t=(await mr(`/api/reports/${encodeURIComponent(r)}/triage`))?.entries;return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:null}async function Jc(r,e,t){try{return(await y(`/api/reports/${encodeURIComponent(r)}/triage`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",...t?{"x-csrf-token":t}:{}},body:JSON.stringify({entries:e})})).status}catch{return 0}}function Xc(r){r&&(location.href=r)}async function Qc(r){try{await y("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:r?{"x-csrf-token":r}:{}})}catch{}location.reload()}export{Zc as fetchReport,Yc as fetchReportTriage,ot as getPreviewRole,Xc as login,Qc as logout,Wc as probeSession,Kc as probeTeams,Jc as pushReportTriage,Yi as setPreviewRole};
62
+ `)}var Qa=[["deepview-md",Fs],["deepsec",As],["piolium",Qs],["claude-security",Ws]];function Er(r){return Array.isArray(r?.findings)?r.findings:Array.isArray(r?.groups)?r.groups:null}function to(r){let e;try{let t=JSON.parse(r);return Er(t)?{data:t,format:"json",reason:null}:{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(t){e=t}for(let[t,i]of Qa){let s=i(r);if(s)return{data:s,format:t,reason:null}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}var el=new TextEncoder,Ju=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});var tl=2;function Ar(r){if(typeof r!="string")throw new TypeError(`utf8ByteLength expects a string, got ${typeof r}`);if(/[\u0100-\uFFFF]/.test(r))return el.encode(r).byteLength;let e=/[\u0080-\u00FF]/gu,t=r.length;for(;e.test(r);){let i=e.lastIndex-1;for(let s=0;i<r.length&&s<tl;i++)r.codePointAt(i)>127?(t++,s=0):s++;e.lastIndex=i}return t}var Cr=new WeakMap,Mr=new WeakMap,Rr=new WeakMap;function wt(r){if(r?.metadataOnly)return new Map;let e=r?.bundle??r?.json;if(e&&Cr.has(e))return Cr.get(e);let t=new Map;if(!r)return t;if(r.kind==="stasis"){if(!r.bundle)return t;let i=r.bundle.formats;for(let[s,o]of r.bundle.sources)typeof o=="string"&&(ne.isResourceFormat(i?.get(s))||t.set(s,o))}else if(r.kind==="sourcemap"){if(!r.json)return t;let i=r.json.sources??[],s=r.json.sourcesContent??[];for(let o=0;o<i.length;o++)typeof s[o]=="string"&&t.set(i[o],s[o])}return e&&Cr.set(e,t),t}function rl(r){let e=r?.bundle??r?.json;if(e&&Mr.has(e))return Mr.get(e);let t=new Map(wt(r));if(r?.kind==="stasis"&&r.bundle){let i=r.bundle.formats;for(let[s,o]of r.bundle.sources){if(typeof o!="string")continue;let n=i?.get(s);n==="resource"?t.set(s,o):n==="resource:base64"&&t.set(s,{format:"base64",data:o})}}return e&&Mr.set(e,t),t}var il="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function sl(r){let e=r.endsWith("=");if(e?r.length%4!==0||r.at(-3)==="=":r.length%4===1)return null;let t=e?r.slice(0,r.endsWith("==")?-2:-1):r;if(/[^A-Za-z0-9+/]/u.test(t))return null;let i=t.length%4;return i>1&&il.indexOf(t.at(-1))&(i===2?15:3)?null:Math.floor(t.length*3/4)}function ol(r){return typeof r=="string"?Ar(r):r?.format==="base64"?sl(r.data):null}function Lr(r){if(r?.fileSizes)return r.fileSizes;let e=r?.bundle??r?.json;if(e&&Rr.has(e))return Rr.get(e);let t=new Map,i=rl(r),s=r?.kind==="stasis"?r.bundle?.sources.keys():r?.json?.sources;for(let o of s??[])t.set(o,ol(i.get(o)));return e&&Rr.set(e,t),t}function ro(r){if(r?.kind!=="stasis"||!r.bundle?.modules)return null;let e=new Map;for(let[t,i]of r.bundle.modules)for(let s of Object.keys(i.files))e.set(t==="."?s:`${t}/${s}`,t);return e}var nl=2,io=nl;function so(r){return typeof r!="string"||r.length===0?0:(r.match(/\r\n|\r|\n/gu)?.length??0)+(/[\r\n]$/u.test(r)?0:1)}function oo(r,e){if(r?.version!==1&&r?.version!==io||r.integrity!==e||!["stasis","sourcemap"].includes(r.kind)||!Number.isSafeInteger(r.size)||r.size<0||!Array.isArray(r.files))throw new Error("Invalid bundle metadata");let t=r.version!==io,i=new Map,s=new Map,o=new Map;for(let l of r.files){if(!Array.isArray(l)||l.length!==4&&!(t&&l.length===3))throw new Error("Invalid bundle metadata file");let[d,u,p,g]=l;if(typeof d!="string"||s.has(d)||u!==null&&(!Number.isSafeInteger(u)||u<0)||p!==null&&(typeof p!="string"||!/^sha512-[A-Za-z0-9+/]{86}==$/u.test(p))||u===null&&p!==null||t&&u!==null&&p===null||g!=null&&(!Number.isSafeInteger(g)||g<0))throw new Error("Invalid bundle metadata file");s.set(d,u),p!==null&&i.set(d,p),g!=null&&o.set(d,g)}let n=new Set(r.unsized??[]);if(r.unsized!==void 0&&(t||!Array.isArray(r.unsized)||n.size!==r.unsized.length)||[...n].some(l=>typeof l!="string"||!s.has(l)||s.get(l)!==null))throw new Error("Invalid bundle metadata");let a={integrity:e,kind:r.kind,size:r.size,metadataOnly:!0,fileSizes:s,fileHashes:i,lineCounts:o,unsizedFiles:n,stale:t};if(r.kind==="stasis"){a.bundle=ne.parse(JSON.stringify(r.bundle));let l=a.bundle.sources;if(l.size!==s.size||[...l.keys()].some(u=>!s.has(u)))throw new Error("Invalid bundle metadata inventory");let d=a.bundle.formats;if(!t&&[...s].some(([u,p])=>i.has(u)!==(p!==null&&!ne.isResourceFormat(d.get(u)))))throw new Error("Invalid bundle metadata inventory");if([...n].some(u=>d.get(u)!=="resource:base64"))throw new Error("Invalid bundle metadata inventory")}else{if(!r.json||typeof r.json!="object"||![null,void 0].includes(r.namesCount)&&(!Number.isSafeInteger(r.namesCount)||r.namesCount<0))throw new Error("Invalid sourcemap metadata");if(!Array.isArray(r.json.sources)||r.json.sources.some(l=>!s.has(l))||!Array.isArray(r.sourceSizes)||r.sourceSizes.length!==r.json.sources.length||r.sourceSizes.some(l=>l!==null&&(!Number.isSafeInteger(l)||l<0))||[...s].some(([l,d])=>i.has(l)!==(d!==null))||n.size>0)throw new Error("Invalid sourcemap inventory");a.json=r.json,a.sourceSizes=r.sourceSizes,a.namesCount=r.namesCount}if(r.codeStats===void 0)a.codeStats=ss(o,s);else{let l=r.codeStats,d=u=>Number.isSafeInteger(u)&&u>=0;if(!l||![l.files,l.lines,l.bytes].every(d)||!Array.isArray(l.languages)||l.languages.some(u=>!u||typeof u.key!="string"||typeof u.label!="string"||![u.files,u.lines,u.bytes].every(d)))throw new Error("Invalid bundle code stats");a.codeStats=l}return a}async function no(r,e,t){let i=z.generation,s=await w(`/api/bundles/${encodeURIComponent(r)}/${e}`,{credentials:"same-origin",signal:t});if(!s.ok)throw new Error(`Bundle ${e} request failed (${s.status})`);let o=e==="metadata"?await s.json():await s.text();if(t?.throwIfAborted(),i!==z.generation)throw new DOMException("Managed session changed","AbortError");return o}function zr(r,{signal:e}={}){return z.load(`bundle-metadata:${r}`,"bundle metadata",t=>no(r,"metadata",t),{signal:e})}async function al(r,{signal:e}={}){e=e?AbortSignal.any([e,z.sessionController.signal]):z.sessionController.signal;try{return await no(r,"contents",e)}catch(t){throw t.name!=="AbortError"&&z.notify(`Couldn't load bundle contents: ${t.message}`),t}}function Ir(r,{splitOwnDirs:e=!0,packageDir:t=null}={}){if(t){if(t!=="."){let i=t.match(/(?:^|\/)node_modules\/(@[^/]+\/[^/]+|[^/]+)$/u);return i&&i[1]!==".pnpm"?i[1]:t}}else{let i=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,s;for(;(s=i.exec(r))!==null;)if(s[1]!==".pnpm")return s[1]}if(e){let i=r.indexOf("/");if(i>0)return r.slice(0,i)}return"__own__"}function ao(r,e){let t=new Map,i=r?.kind==="stasis"?r.bundle?.reason:null;if(!i||typeof i!="object"||Array.isArray(i))return t;let s=new Set(e);for(let[o,n]of Object.entries(i).toSorted(([a],[l])=>a.localeCompare(l))){if(!o||!Array.isArray(n))continue;let a=new Set(n.filter(l=>typeof l=="string"&&s.has(l)));a.size>0&&t.set(o,a)}return[...t.values()].some(o=>o.size<s.size)||t.clear(),t}function lo(r,e){if(e.error)throw new Error(e.error);let t=ro(e),i=e.kind==="stasis"?e.bundle?.formats:null,s=e.lineCounts??new Map([...wt(e)].map(([a,l])=>[a,so(l)])),o=[...Lr(e)].filter(([,a])=>a!=null).map(([a,l])=>({path:a,format:i?.get(a)??null,bytes:l,lines:s.get(a)??0,size:B(l),module:Ir(a,{splitOwnDirs:!1,packageDir:t?.get(a)})})),n=[{id:"all",label:"All",filePaths:null},...[...ao(e,o.map(a=>a.path))].map(([a,l])=>({id:`reason:${a}`,label:a,filePaths:[...l]}))];return{...r,files:o,reasons:n,size:B(e.size)}}function co(r){let e=new Map((r.repos??[]).map(i=>[i.repoId,{id:i.repoId,label:i.fullName}])),t=(r.bundles??[]).map(i=>{let s=i.repoId??"unattached";return e.has(s)||e.set(s,{id:s,label:s==="unattached"?"Unattached":i.repoFullName??String(s)}),{...i,repoId:s,repo:e.get(s).label,size:B(i.byteSize),files:null,reasons:[]}});return{repositories:[...e.values()],bundles:t,scans:[]}}async function po(r,e){let t=await zr(r.id,{signal:e});e?.throwIfAborted();let i=oo(t,r.integrity);return lo(r,i)}function ll(r){let{data:e}=to(r);return e&&uo(e)>0?e:null}function uo(r){return(Er(r)??[]).filter(e=>(Array.isArray(e)?e:[e]).some(t=>t&&typeof t=="object"&&pr(t,t.source??r.source))).length}function ho(r,e){let t=(r.reports??[]).filter(n=>n.visible&&n.repoId!=null).flatMap(n=>{let a=ll(n.content??"");return a?[{id:n.id,filename:n.filename,repoIds:[n.repoId],repo:n.repoFullName,directory:n.repoDirectory,analyzer:n.analyzer,appFindings:uo(a)}]:[]}),i=new Map((r.repos??[]).map(n=>[n.repoId,{id:n.repoId,label:n.fullName}]));for(let n of t)i.has(n.repoIds[0])||i.set(n.repoIds[0],{id:n.repoIds[0],label:n.repo??String(n.repoIds[0])});let s=e.results??[],o=new Set(s.map(n=>n.bundleId));return{merge:{bundles:(e.bundles??[]).filter(n=>o.has(n.id)).map(n=>({...n,size:B(n.byteSize)})),results:s},link:{repositories:[...i.values()].filter(n=>t.some(a=>a.repoIds.includes(n.id))),reports:t}}}function mo(r){return r.map(e=>{let t=e.login||String(e.id),i=e.name?.trim()||`@${t}`,s=i===`@${t}`?"":`@${t}`,o=i.replace(/^@/u,"").split(/\s+/u).filter(Boolean).slice(0,2).map(n=>n[0]).join("").toUpperCase();return{value:e.id,label:s?`${i} ${s}`:i,displayLabel:i,secondary:s,initials:o,disabled:e.disabled,detail:e.detail}})}function fo(r,e){let t=e.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),i=r.filter(s=>t.every(o=>s.label.normalize("NFKC").toLocaleLowerCase().includes(o))).toSorted((s,o)=>s.label.localeCompare(o.label,void 0,{sensitivity:"base",numeric:!0}));return{pinned:[],sections:[{label:null,options:i}],facets:[],showFacets:!1,count:i.length,total:r.length}}var Or=class extends C{static properties={users:{attribute:!1}};constructor(){super(),this.users=[],this.label="Choose user",this.placeholder="Choose user"}get searchLabel(){return"Search users"}get optionsLabel(){return"Users"}get noMatchesLabel(){return"No matching users"}get emptyLabel(){return"No users available"}get changeEvent(){return"user-change"}willUpdate(e){e.has("users")&&(this.options=mo(this.users))}choices(){return fo(this.options,this._query)}};customElements.get("user-selector")||customElements.define("user-selector",Or);function go(r){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:r},bubbles:!0,composed:!0}))}function xo(r,e){return c`<span class="avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${St()?h:c`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" @error="${t=>t.currentTarget.classList.add("broken")}">`}</span>`}var cl=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 4-8 8H2v-4l8-8Zm-1 1 4 4"/></svg>`,Gr=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h12M6 4V2h4v2M4 4l.6 10h6.8L12 4M6.5 7v4m3-4v4"/></svg>`,bo=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="m4 4 8 8m0-8-8 8"/></svg>`,Tr=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>`,dl={admin:"Admin",manage:"Manager",triage:"Triage",view:"Viewer",none:"No access"},pl={admin:"Manage workspace access and teams",manage:"Manage content and triage within team access",triage:"Review and triage findings",view:"Read-only access",none:"No workspace access"},Nr=class extends I{static styles=[k(Ci),k(U)];render(){let e=[["manage-bundles","Bundles","Keep source archives ready for review.","bundle"],["manage-scans","Scans","Run and monitor scans from stored bundles.","scan"],["manage-reports","Reports","Review, publish, and organize findings.","report"]],t=[["manage-repos","Repositories","Connect sources and manage repository settings.","repo"],["admin-users","Users","Manage accounts, roles, and workspace access.","users"],["manage-teams","Teams","Bring people and repositories together.","team"]];return c`<div class="wrap">${N("manage",this._role)}<h1 class="sr-only">Manage</h1>${this._role==null?c`<p class="msg" role="status">Loading management pages…</p>`:c`<section class="home-section" aria-labelledby="content-heading"><div class="section-heading"><h2 id="content-heading">Content & activity</h2><span>From source to findings</span></div><div class="pages">${e.filter(([i])=>i!=="manage-scans"||["admin","manage"].includes(this._role)).map(i=>this._page(i))}</div></section>${this._role==="admin"?c`<section class="home-section" aria-labelledby="workspace-heading"><div class="section-heading"><h2 id="workspace-heading">Workspace & access</h2><span>Sources, people, and permissions</span></div><div class="pages workspace-pages">${t.map(i=>this._page(i))}</div></section>`:h} <button type="button" class="history-link" @click="${()=>go("manage-history")}"><span class="page-icon" aria-hidden="true">${M("history")}</span> <span class="page-copy"><strong>Workspace history</strong><span>Follow activity and triage changes across your workspace.</span></span> <span class="history-cta">View history ${M("arrow")}</span></button>`}</div>`}_page([e,t,i,s]){return c`<button type="button" class="${`page page-${s}`}" @click="${()=>go(e)}"><span class="page-top"><span class="page-icon" aria-hidden="true">${M(s)}</span><strong class="page-title">${t}</strong><span class="arrow" aria-hidden="true">${M("arrow")}</span></span> <span class="page-copy"><span>${i}</span></span></button>`}};customElements.define("managed-admin-home",Nr);async function ul(r,e,t,i){let s=new URLSearchParams({page:String(e),limit:"100",kind:t,q:i.trim()}),o=await w(`/api/admin/history?${s}`,{signal:r,credentials:"same-origin",headers:{accept:"application/json"}});if(!o.ok)throw new Error(`HTTP ${o.status}`);let n=await o.json();if(!Array.isArray(n?.history)||!Number.isSafeInteger(n.total)||n.total<0||!Number.isSafeInteger(n.page)||n.page<1)throw new Error("No history returned");return n}var Br=class extends I{static properties={_page:{state:!0},_history:{state:!0},_total:{state:!0},_error:{state:!0},_filter:{state:!0},_query:{state:!0}};static styles=[k(Mi),k(U)];constructor(){super(),this._history=null,this._total=0,this._searchTimer=null,this._error=null,this._page=1,this._filter="all",this._query="",this._onActorFilter=e=>{let t=e.detail?.actor;typeof t=="string"&&(this._query=t,this._filter="all",this._load())}}connectedCallback(){super.connectedCallback(),document.addEventListener("managed-history-filter",this._onActorFilter),this._load()}disconnectedCallback(){clearTimeout(this._searchTimer),document.removeEventListener("managed-history-filter",this._onActorFilter),super.disconnectedCallback()}async _load(e=1){clearTimeout(this._searchTimer),this._error=null;let t=this._filter,i=this._query.trim(),s=`history:${JSON.stringify([e,t,i])}`;await this._loadCollection(s,"history",o=>ul(o,e,t,i),o=>{this._history=o.history,this._total=o.total,this._page=o.page})}_search(e){this._query=e,clearTimeout(this._searchTimer),this._loadRequest?.abort(),this._loadRequest=null,this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},250)}render(){let e=this._history??[],t=this._page,i=(t-1)*100;return c`<div class="wrap">${N("manage-history",this._role)}<h1 class="sr-only">History</h1><div class="page-intro"><p class="intro">${this._role==="admin"?"Uploads, access changes, repository changes, deletions, and triage.":"Bundle, report, and triage history within your team access."}</p><span class="result-count">${this._history?this._total:"\u2026"} entries</span></div><div class="toolbar" role="search"><input type="search" maxlength="500" aria-label="Search history" placeholder="Search actions, users, repositories, reports…" .value="${this._query}" @input="${s=>this._search(s.target.value)}"><select aria-label="Filter history by type" .value="${this._filter}" @change="${s=>{this._filter=s.target.value,this._load()}}"><option value="all">All activity</option><option value="triage">Triage</option><option value="visibility">Visibility</option><option value="upload">Uploads</option><option value="repository">${this._role==="admin"?"Repositories":"Assignments"}</option>${this._role==="admin"?c`<option value="access">Access</option>`:h}<option value="delete">Deletions</option></select><button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>this._load(t)}">Refresh</button></div>${this._error?c`<p class="msg error" role="alert">Couldn’t load history: ${this._error} <button type="button" class="btn" @click="${()=>this._load()}">Retry</button></p>`:h}<div aria-busy="${this._loading}">${this._history==null?this._error?h:ie("Loading history\u2026"):e.length===0?c`<div class="history"><p class="empty">${this._query.trim()||this._filter!=="all"?"No activity matches your filters.":"No history available yet."}</p></div>`:c`<div class="history" aria-label="Workspace history"><div class="history-head" aria-hidden="true"><span>Type</span><span>Activity</span><span>Repository / report / finding</span><span>Time</span></div>${e.map(s=>this._row(s))}</div>`}</div>${this._total>100?c`<nav class="pagination" aria-label="History pages"><span role="status">${i+1}–${Math.min(i+100,this._total)} of ${this._total} entries</span><button type="button" class="btn" ?disabled="${this._loading||t===1}" @click="${()=>this._changePage(t-1)}">Previous</button><span>Page ${t} of ${Math.ceil(this._total/100)}</span><button type="button" class="btn" ?disabled="${this._loading||i+100>=this._total}" @click="${()=>this._changePage(t+1)}">Next</button></nav>`:h}</div>`}async _changePage(e){await this._load(e),await this.updateComplete,this.renderRoot.querySelector(".history")?.scrollIntoView({block:"start"})}_row(e){let t=[e.repo??e.repository,e.report,e.finding].filter(Boolean).join(" \xB7 "),i=e.actor??e.user??"Unknown user",s=e.action??"updated workspace data";return c`<div class="row"><span class="${`kind ${e.kind??""}`}">${e.kind??"activity"}</span><span class="activity-description" data-tooltip-truncated data-tooltip="${`${i} ${s}`}"><strong class="actor">${i}</strong> <span class="action">${s}</span></span><span class="detail" data-tooltip-truncated data-tooltip="${t}">${t||"\u2014"}</span><span class="history-time">${Pr(e.at)}</span></div>`}};customElements.define("managed-admin-history",Br);async function hl(r){let e=await w("/api/admin/users",{signal:r,credentials:"same-origin",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();return Array.isArray(t?.users)?t.users:[]}function Pr(r){if(r==null||r==="")return c`<span>Unknown</span>`;let e=typeof r=="number"?r:Number(r);if(!Number.isFinite(e))return c`<span>Unknown</span>`;let t=new Date(e);return Number.isNaN(t.getTime())?c`<span>Unknown</span>`:c`<time datetime="${t.toISOString()}">${t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}</time><span>${t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}</span>`}function vo(r){if(r==null||r==="")return"Unknown";let e=typeof r=="number"?r:Number(r);return Number.isFinite(e)&&!Number.isNaN(new Date(e).getTime())?`Last seen ${new Date(e).toLocaleString()}`:"Unknown"}function yo(r){return r?.lastActivityAt??r?.lastActivity??r?.lastWriteAt??r?.lastActiveAt}async function ml(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await w("/api/admin/set-role",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({userId:r,role:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var jr=class extends I{static properties={_query:{state:!0},_users:{state:!0},_teams:{state:!0},_error:{state:!0}};static styles=[k(Ri),k(U)];constructor(){super(),this._users=null,this._query="",this._teams=null,this._error=null}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null,await this._loadCollection("users","users",e=>Promise.all([hl(e),Co(e)]),([e,t])=>{this._users=e,this._teams=Array.isArray(t?.teams)?t.teams:[]})}render(){return c`<div class="wrap">${N("admin-users",this._role)}<h1 class="sr-only">Users</h1><div class="page-intro"><p class="intro">Manage workspace access and roles.</p><span class="result-count">${this._users?.length??"\u2026"} users</span></div><div class="collection-toolbar" role="search"><input type="search" aria-label="Search users" placeholder="Search by name, username, or team…" .value="${this._query}" @input="${e=>{this._query=e.target.value}}"></div>${this._error?c`<p class="msg error" role="alert">Couldn't load users: ${this._error}</p>`:h}<div aria-busy="${this._loading}">${this._users==null?this._error?h:ie("Loading users\u2026"):this._list()}</div></div>`}_list(){if(this._users.length===0)return c`<p class="msg">No users yet.</p>`;let e=this._query.trim().toLocaleLowerCase(),t=this._users.filter(i=>[i.name,i.login,i.role,...(this._teams??[]).filter(s=>s.members?.some(o=>o.userId===i.id)).map(s=>s.name)].filter(Boolean).join(" ").toLocaleLowerCase().includes(e));return t.length===0?c`<div class="empty"><strong>No matching users</strong><p>Try another name, username, or team.</p></div>`:c`<div class="directory"><div class="list-head" aria-hidden="true"><span>Account</span><span>Team access</span><span>Last seen</span><span>Last activity</span><span>Role</span></div><ul class="users">${t.map(i=>this._row(i))}</ul></div>${this._users.some(i=>i.id===this._me)?c`<p class="self-note">Your own role can only be changed by another admin.</p>`:h}`}_row(e){let t=e.id===this._me,i=(this._teams??[]).flatMap(s=>{let o=s.members?.find(n=>n.userId===e.id);return o==null?[]:[{team:s,member:o}]});return c`<li><span class="person">${xo(e.id,e.login)} <span class="who"><span class="name"><span class="name-text">${e.name||e.login}</span>${t?c`<span class="you">You</span>`:h}</span> <span class="login">@${e.login}</span> </span></span><span class="memberships">${i.length===0?c`<span class="no-team">No team access</span>`:i.map(({team:s,member:o})=>c`<span class="team-access"><strong>${M("team")}<span>${s.name}</span></strong><span class="team-perms">${["dependencies","security"].map(n=>c`<span class="${o[n]===!0?"permission-granted":"permission-denied"}">${o[n]===!0?"+":"\u2212"} ${n==="dependencies"?"Deps":"Security"}</span>`)}</span></span>`)} </span><span class="last-seen" aria-label="${vo(e.lastSeenAt)}">${Pr(e.lastSeenAt)}</span> <button type="button" class="activity-link" aria-label="${`Show activity by ${e.login}`}" @click="${()=>this._showActivity(e.login)}"><span class="last-activity" aria-label="${`Last activity ${vo(yo(e)).replace(/^Last seen /u,"")}`}">${Pr(yo(e))}</span></button> <span class="access"><select class="role" ?disabled="${t}" aria-label="${`Change ${e.login}\u2019s role`}" aria-description="${pl[e.role]??""}" @change="${s=>this._changeRole(e,s.target.value,s.target)}">${Y.map(s=>c`<option value="${s}" ?selected="${s===e.role}">${dl[s]}</option>`)}</select></span></li>`}async _changeRole(e,t,i){let s=e.role;if(t!==s){try{await this.appState.mutate(()=>ml(e.id,t,this._csrf),["users","teams","history"]),e.role=t,await this._load()}catch(o){console.warn("admin: set role failed:",o),i.value=s}this.requestUpdate()}}_showActivity(e){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-history",actor:e},bubbles:!0,composed:!0}))}};customElements.define("managed-admin-users",jr);async function fl(r,e,t,i){let s=new URLSearchParams({scope:r,q:e,page:String(t),limit:"20"}),o=await w(`/api/admin/repositories?${s}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:i});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async function gl(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await w("/api/admin/repositories/select",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({repoId:r,selected:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function bl(r,e){let t=await w(`/api/admin/repositories/impact?repoId=${encodeURIComponent(r)}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:e});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();if(i?.repoId!==r||!Array.isArray(i.reports)||!Array.isArray(i.bundles)||!Number.isSafeInteger(i.triageCount)||i.triageCount<0)throw new Error("Invalid repository data");return i}async function vl(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await w("/api/admin/repositories/remove",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({repoId:r,fullName:e,acknowledge:!0,deleteTriage:t})});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}var $o=M("repo"),Dr=class extends I{static properties={_data:{state:!0},_error:{state:!0},_actionError:{state:!0},_scope:{state:!0},_query:{state:!0},_page:{state:!0},_loading:{state:!0},_busy:{state:!0},_detail:{state:!0},_impact:{state:!0},_impactLoading:{state:!0},_removeOpen:{state:!0},_acknowledge:{state:!0},_deleteTriage:{state:!0},_confirmName:{state:!0}};static styles=[k(Li),k(U)];constructor(){super(),this._data=null,this._error=null,this._actionError=null,this._scope="connected",this._query="",this._page=1,this._loading=!0,this._busy=null,this._detail=null,this._impact=null,this._impactLoading=!1,this._impactFresh=!1,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._impactRequest=null,this._searchTimer=null}connectedCallback(){super.connectedCallback(),this._load()}disconnectedCallback(){super.disconnectedCallback(),this._impactRequest?.abort(),clearTimeout(this._searchTimer)}_repositoryKey(){return`repos:${JSON.stringify([this._scope,this._query,this._page])}`}async _load(){this._error=null;let{_scope:e,_query:t,_page:i}=this;await this._loadCollection(this._repositoryKey(),"repositories",o=>fl(e,t,i,o),o=>{this._data=o});let s=Math.max(1,Math.ceil(this._data?.total/20));this._scope===e&&this._query===t&&this._page===i&&this._page>s&&(this._page=s,this._load())}_open(e){this._impactRequest?.abort(),clearTimeout(this._searchTimer),this._scope=e,this._query="",this._page=1,this._detail=null,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._data=null,this._actionError=null,this._load()}_search(e){this._query=e,this._page=1,this._loadRequest?.abort(),clearTimeout(this._searchTimer),this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},200)}_back(){return c`<span class="breadcrumb"><button type="button" class="breadcrumb-manage" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage"},bubbles:!0,composed:!0}))}}">Manage</button> <span class="breadcrumb-separator" aria-hidden="true">›</span> <button type="button" class="breadcrumb-manage" aria-label="Back to repositories" @click="${()=>{this._detail?(this._impactRequest?.abort(),this._detail=null,this._actionError=null):this._open("connected")}}">Repositories</button> <span class="breadcrumb-separator" aria-hidden="true">›</span></span>`}_openDetail(e){this._detail=e,this._actionError=null,this._impact=this.appState.read(`repo-impact:${e.id}`)??null,this._impactFresh=!1,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._impactLoading=!0,this._impactRequest?.abort();let t=new AbortController;this._impactRequest=t,this.appState.load(`repo-impact:${e.id}`,"repository data",i=>bl(e.id,i),{signal:t.signal,apply:i=>{this._impact=i}}).then(i=>(t.signal.aborted||(this._impactFresh=!0),i)).catch(i=>{!t.signal.aborted&&i?.name!=="AbortError"&&!this._impact&&(this._actionError=`Couldn't load repository data: ${i?.message??i}`)}).finally(()=>{this._impactRequest===t&&(this._impactLoading=!1)})}render(){if(this._detail)return this._detailPage(this._detail);let e=this._scope==="connected",t=e?"Repositories":`Add ${this._scope} repository`;return c`<div class="wrap">${N("manage-repos",this._role)} ${e?c`<h1 class="sr-only">${t}</h1>`:c`<div class="head">${this._back()}<h1>${t}</h1></div>`}<div class="page-intro"><p class="intro">${e?"Manage connected repositories and their settings.":this._scope==="installed"?"Choose a repository the GitHub App can read. Installed repositories can be public or private.":"Choose a public repository your GitHub account is involved with. Random public repositories are not listed."}</p>${e?c`<span class="result-count">${this._data?.connectedCount??"\u2026"} connected</span>`:h}</div>${!e&&this._scope==="installed"?c`<div class="access-note"><p>Installed repositories are readable through the GitHub App. Install it on a repository or organization to make it available here.</p><span class="access-action">${this._data?.installUrl?c`<a class="btn" href="${this._data.installUrl}" target="_blank" rel="noopener noreferrer">Configure GitHub access</a>`:c`<button type="button" class="btn" disabled="disabled">Configure GitHub access</button>`}</span></div>`:h}<div class="toolbar"><label class="search"><input type="search" aria-label="${e?"Search connected repositories":`Search ${this._scope} repositories`}" placeholder="Search by repository or owner…" .value="${this._query}" @input="${i=>this._search(i.target.value)}"></label> ${e?c`<button type="button" class="btn" @click="${()=>this._open("installed")}">${this._accessIcon("private")} Add installed repository</button> <button type="button" class="btn" @click="${()=>this._open("public")}">${this._accessIcon("public")} Add your public repository</button>`:c`<button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>{this._load()}}">Refresh</button>`}</div>${this._actionError?c`<p class="msg error" role="alert">${this._actionError}</p>`:h} ${this._error?c`<p class="msg error" role="alert">Couldn't load repositories: ${this._error}</p><button type="button" class="btn" @click="${()=>{this._load()}}">Try again</button>`:h}<div aria-busy="${this._loading}">${this._body()}</div></div>`}_body(){if(!this._data)return this._error?h:ie("Loading repositories\u2026");let e=this._data.repositories??[],t=this._data.page??this._page;return c`${this._data.tokenMissing&&this._scope==="public"?c`<p class="msg">Log out and back in to refresh your GitHub membership access.</p>`:h} ${e.length>0?c`<div class="owners">${this._groupRepos(e).map(([i,s])=>c`<section aria-label="${i}"><h2 class="owner-head"><span class="owner-icon" aria-hidden="true">${i[0]??"?"}</span>${i}</h2><ul class="repos">${s.map(o=>this._row(o))}</ul></section>`)}</div>`:c`<div class="empty"><strong>${this._query?"No matching repositories":this._scope==="connected"?"No connected repositories yet":`No ${this._scope} repositories available`}</strong><p>${this._query?"Try a different repository or owner name.":this._scope==="connected"?"Add an installed or public repository to get started.":this._scope==="installed"?"Install the GitHub App, then refresh this list.":"Public repositories associated with your GitHub account will appear here."}</p></div>`} ${this._data.total>20?c`<nav class="pagination" aria-label="Repository pages"><span>${(t-1)*20+1}–${Math.min(t*20,this._data.total)} of ${this._data.total}</span> <button type="button" class="btn" ?disabled="${this._loading||this._page===1}" @click="${()=>{this._page--,this._load()}}">Previous</button> <button type="button" class="btn" ?disabled="${this._loading||this._page*20>=this._data.total}" @click="${()=>{this._page++,this._load()}}">Next</button></nav>`:h}`}_groupRepos(e){let t=new Map;for(let i of e){let s=i.fullName.split("/")[0];t.has(s)||t.set(s,[]),t.get(s).push(i)}return[...t]}_row(e){let t=e.fullName.slice(e.fullName.indexOf("/")+1),i=`${this._accessLabel(e)}${this._scope==="connected"&&e.active===!1?" \xB7 Deactivated":""}`,s=c`${$o}<span class="repo-copy"><span class="repo-name">${t}</span><span class="repo-meta">${i}</span></span>`;return this._scope==="connected"?c`<li><button type="button" class="repo-row" aria-label="${`Manage ${e.fullName}`}" @click="${()=>this._openDetail(e)}">${s}<svg class="arrow" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg></button></li>`:c`<li class="repo-row">${s} ${e.selected?c`<span class="connected"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>Connected</span>`:e.private&&!e.installed?c`<span class="repo-meta">Needs App access</span>`:c`<button type="button" class="btn" aria-label="${`Add ${e.fullName}`}" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!0)}}">${this._busy===e.id?"Adding\u2026":"Add"}</button>`}</li>`}_accessLabel(e){return e.installed?e.private?"Private \xB7 GitHub App":"Public \xB7 GitHub App":"Public \xB7 GitHub membership"}_detailPage(e){let t=e.active!==!1,i=this._impact?.reports??[],s=this._impact?.bundles??[];return c`<div class="wrap">${N("manage-repos",this._role)}<div class="head">${this._back()}<h1>${e.fullName}</h1></div><p class="intro">Repository settings and stored data.</p>${this._actionError?c`<p class="msg error" role="alert">${this._actionError}</p>`:h}<section class="section" aria-label="Repository connection"><h2>Connection</h2><div class="settings-row"><div class="settings-copy"><strong>${this._accessLabel(e)}</strong><p>${t?"Active for new scans and uploads.":"Deactivated. Stored reports and bundles are retained."}</p></div><span class="${`status-line ${t?"":"inactive"}`}">${t?"Active":"Deactivated"}</span> ${e.htmlUrl?c`<a class="btn" href="${e.htmlUrl}" target="_blank" rel="noopener noreferrer">View on GitHub</a>`:h}</div><div class="settings-row"><div class="settings-copy"><strong>${t?"Deactivate repository":"Reactivate repository"}</strong><p>${t?"Pause new scans while preserving all stored data and attachments.":"Make this repository available for new scans and bundle attachments again."}</p></div><button type="button" class="btn" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!t)}}">${this._busy===e.id?t?"Deactivating\u2026":"Reactivating\u2026":t?"Deactivate":"Reactivate"}</button></div></section><section class="data-section" aria-label="Stored repository data"><h2>Stored data</h2><div class="dialog-data" aria-busy="${this._impactLoading}">${[["Reports",i],["Bundles",s]].map(([o,n])=>c`<section><h3>${o} (${this._impact==null?"\u2026":n.length})</h3>${this._impactLoading&&this._impact==null?c`<p class="data-empty" role="status">Loading ${o.toLowerCase()}…</p>`:this._impact==null?c`<p class="data-empty">Attached data could not be loaded.</p><button type="button" class="btn" @click="${()=>this._openDetail(e)}">Try again</button>`:n.length>0?c`<ul>${n.map(a=>c`<li>${a.filename}${a.repoDirectory?` \xB7 ${a.repoDirectory}`:h}</li>`)}</ul>`:c`<p class="data-empty">No ${o.toLowerCase()} attached.</p>`}</section>`)}</div></section><section class="section" aria-label="Permanent repository removal"><h2>Permanent removal</h2><div class="settings-row"><div class="settings-copy"><strong>Delete repository and stored data</strong><p>Deactivation is reversible. Permanent removal deletes this repository’s attached reports and bundles; it cannot be undone.</p></div><button type="button" class="btn danger" ?disabled="${this._busy!=null||this._impactLoading||!this._impactFresh||this._impact==null}" @click="${()=>{this._removeOpen=!0,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName=""}}">Remove permanently</button></div></section>${this._removeOpen&&this._impact!=null&&!this._impactLoading?this._removeDialog(e,i,s):h}</div>`}_removeDialog(e,t,i){let s=t.length>0||i.length>0,o=this._canRemove(e);return c`<div class="dialog-backdrop" role="presentation" @click="${n=>{n.target===n.currentTarget&&(this._removeOpen=!1)}}"><section class="${`dialog ${s?"":"small"}`}" role="dialog" aria-modal="true" aria-labelledby="remove-repo-title"><h2 id="remove-repo-title">Remove ${e.fullName} permanently?</h2><p class="dialog-copy">${s?"This destructive action will remove the repository and the stored data listed below. Deactivation keeps all of it.":"This repository has no attached reports or bundles. Permanent removal deletes its connection record."}</p>${s?c`<div class="dialog-data"><section><h3>Reports to delete (${t.length})</h3><ul>${t.map(n=>c`<li>${n.filename}${n.repoDirectory?` \xB7 ${n.repoDirectory}`:h}</li>`)}</ul></section><section><h3>Bundles to delete (${i.length})</h3><ul>${i.map(n=>c`<li>${n.filename}</li>`)}</ul></section></div>`:h} <label class="confirm-line"><input type="checkbox" .checked="${this._acknowledge}" @change="${n=>{this._acknowledge=n.target.checked}}">I understand this permanently deletes the repository connection${s?", reports, and bundles":""}.</label> ${(this._impact?.triageCount??0)>0?c`<label class="confirm-line"><input type="checkbox" .checked="${this._deleteTriage}" @change="${n=>{this._deleteTriage=n.target.checked}}">Also delete ${this._impact.triageCount} triage entr${this._impact.triageCount===1?"y":"ies"} belonging only to this repository.</label>`:h} ${s?c`<label class="confirm-line">Type <strong>${e.fullName}</strong> to confirm.<input class="confirm-name" type="text" autocomplete="off" .value="${this._confirmName}" @input="${n=>{this._confirmName=n.target.value}}"></label>`:h}<div class="dialog-actions"><button type="button" class="btn" @click="${()=>{this._removeOpen=!1}}">Cancel</button><button type="button" class="btn danger" ?disabled="${!o}" @click="${()=>{this._remove(e)}}">${this._busy===e.id?"Removing\u2026":"Remove permanently"}</button></div></section></div>`}_accessIcon(e){return e==="private"?c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="7" width="10" height="7" rx="1"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg>`:c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path d="M2.5 8h11M8 2c1.5 1.7 2.2 3.7 2.2 6S9.5 12.3 8 14c-1.5-1.7-2.2-3.7-2.2-6S6.5 3.7 8 2Z"/></svg>`}async _setActive(e,t){if(this._busy==null){this._busy=e.id,this._actionError=null;try{if(await this.appState.mutate(()=>gl(e.id,t,this._csrf),["repos","reports","bundles","teams","users","history"]),!this.isConnected)return;this._detail?.id===e.id&&(this._detail={...this._detail,active:t}),this._data&&(this._data={...this._data,repositories:this._data.repositories.map(i=>i.id===e.id?{...i,active:t}:i)}),await this._load()}catch(i){let s=t?e.active===!1?"reactivate":"add":"deactivate";this._actionError=`Couldn't ${s} ${e.fullName}: ${i?.message??i}`}finally{this._busy=null}}}_canRemove(e){return this._busy!=null||this._impactLoading||!this._impactFresh||this._impact?.repoId!==e.id||!this._acknowledge?!1:!(this._impact.reports.length>0||this._impact.bundles.length>0)||this._confirmName===e.fullName}async _remove(e){if(this._canRemove(e)){this._busy=e.id,this._actionError=null;try{await this.appState.mutate(()=>vl(e.id,e.fullName,this._deleteTriage,this._csrf),["repos","repo-impact","reports","report-preview","bundles","teams","users","history","scan-sources"]),this._removeOpen=!1,this._detail=null,this._impact=null,await this._load()}catch(t){this._actionError=`Couldn't remove ${e.fullName}: ${t?.message??t}`}finally{this._busy=null}}}};customElements.define("managed-admin-repos",Dr);async function yl(r){let e=await w("/api/admin/reports",{signal:r,credentials:"same-origin",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function _o(r,e,t=null,i=""){let s={"content-type":r.type||"application/json","x-report-filename":encodeURIComponent(r.name)};e&&(s["x-csrf-token"]=e),t!=null&&(s["x-repo-id"]=String(t)),i!==""&&(s["x-repo-directory"]=encodeURIComponent(i));let o=await w("/api/admin/reports",{method:"POST",credentials:"same-origin",headers:s,body:r});if(!o.ok){if(o.status===413)throw new Error("too large");if(o.status===403)throw new Error("choose a repository and directory within your team access");let n="";try{let a=await o.json();a?.error==="repo-not-connected"&&typeof a.repo=="string"&&(n=`: ${a.repo} is not connected`)}catch{}throw new Error(`HTTP ${o.status}${n}`)}return o.json()}async function _l(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await w("/api/admin/reports/set-visible",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({reportId:r,visible:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function wl(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await w("/api/admin/reports/set-repo",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({reportId:r,repoId:e,directory:t})});if(!o.ok)throw o.status===409?new Error("this report already defines its repository"):o.status===403?new Error("choose a repository and directory within your team access"):new Error(o.status===400?"invalid repository or directory":`HTTP ${o.status}`);return o.json()}async function xl(r,e){let t=e?{"x-csrf-token":e}:{},i=await w(`/api/admin/reports/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}function Ur(r){return typeof r!="number"||!Number.isFinite(r)?"":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`}function xt(r,e=!0){return[...e?[{value:null,label:"No repository",special:!0}]:[],...r.map(t=>({value:t.repoId,label:t.fullName}))]}function $l(r,e,t,i="Repository for new bundles",s=!0){let o=!Array.isArray(r);return c`<div class="repo-picker"><span class="repo-picker-label">${i}</span><repository-selector class="repo-select" .options="${o?[{value:null,label:"Loading repositories\u2026"}]:xt(r,s)}" .value="${e}" label="${i}" ?disabled="${o||r.length===0}" @repository-change="${n=>t(n.detail.value)}"></repository-selector></div>`}function kl(r,e,t,i=!0){return!Array.isArray(r)||r.length===0?h:c`<repository-selector class="repo-attach" label="Attach to a repository" .options="${xt(r,i)}" .value="${e??null}" @repository-change="${s=>t(s.detail.value)}"></repository-selector>`}function ko(r,e=!0){let t=document.createElement("input");t.type="file",t.multiple=e,t.addEventListener("change",()=>{r([...t.files])},{once:!0}),t.click()}function So(r,e,t){let i=0,s=d=>Array.from(d.dataTransfer?.types??[]).includes("Files"),o=d=>{s(d)&&(d.preventDefault(),i+=1,t(!0))},n=d=>{s(d)&&d.preventDefault()},a=d=>{s(d)&&(i=Math.max(0,i-1),i===0&&t(!1))},l=d=>{s(d)&&(d.preventDefault(),d.stopPropagation(),i=0,t(!1),e([...d.dataTransfer.files]))};return r.addEventListener("dragenter",o),r.addEventListener("dragover",n),r.addEventListener("dragleave",a),r.addEventListener("drop",l),()=>{r.removeEventListener("dragenter",o),r.removeEventListener("dragover",n),r.removeEventListener("dragleave",a),r.removeEventListener("drop",l)}}async function Eo(r,e,t,i){if(r._busy||!r._csrf)throw new Error("Wait for the current operation to finish, then try again.");r._busy=!0;try{await r.appState.mutate(()=>t(e),i)}finally{await r._load(),r._busy=!1;let s=r._queue.splice(0);s.length>0&&r._upload(s)}}var Hr=class extends I{static properties={localImportSource:{attribute:!1},_query:{state:!0},_visibility:{state:!0},_data:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0},_preview:{state:!0},_previewLoading:{state:!0},_locationReport:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0},_repoId:{state:!0},_repoDirectory:{state:!0}};static styles=[k(zi),k(U),k(Dt)];constructor(){super(),this._query="",this._visibility="all",this._data=null,this._error=null,this._busy=!1,this._dragOver=!1,this._preview=null,this._previewLoading=null,this._previewRequest=null,this._locationReport=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._repoId=null,this._repoDirectory="",this._teardownDrop=null,this._queue=[],this._localImport=new Oe(this,"report",e=>Eo(this,e,t=>_o(t,this._csrf,this._repoId,this._repoDirectory.trim()),["reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=So(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._cancelPreview()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("reports","reports",yl,t=>{this._data=t,this._preview&&!t.reports?.some(i=>i.id===this._preview)&&this._cancelPreview()})}render(){return c`${this._dragOver?c`<div class="dropzone">Drop reports to upload</div>`:h}<div class="wrap">${N("manage-reports",this._role)}<h1 class="sr-only">Reports</h1><div class="page-intro"><p class="intro">Upload reports. New reports stay hidden until you make them visible.</p>${this._localImport.renderAction()}</div>${this._localImport.renderPanel(this._busy||!this._csrf)}<div class="drop-card"><span class="drop-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 10V2m0 0L5 5m3-3 3 3M3 9v3.5A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5V9"/></svg></span><span class="drop-copy"><strong>Upload reports</strong><span>Drop files anywhere on this page, or browse your computer.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>ko(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div><div class="location-editor" aria-label="Location for reports without repository metadata"><div class="location-field"><span>Repository (when absent from report)</span><repository-selector label="Repository for new reports" .options="${xt(this._data?.repos??[])}" .value="${this._repoId}" ?disabled="${!this._data?.repos?.length}" @repository-change="${e=>{this._repoId=e.detail.value}}"></repository-selector></div><div class="location-field"><label for="report-upload-directory">Directory</label><input id="report-upload-directory" placeholder="Repository root" .value="${this._repoDirectory}" @input="${e=>{this._repoDirectory=e.target.value}}"></div></div>${this._data?.repoScopes?.length?c`<p class="intro">Team paths: ${this._data.repoScopes.map(e=>`${this._data.repos.find(t=>t.repoId===e.repoId)?.fullName??e.repoId}/${e.path??""}`).join(", ")}</p>`:h} ${this._body()}</div>`}_body(){let e=Array.isArray(this._data?.reports)?this._data.reports:[],t=this._query.trim().toLocaleLowerCase(),i=e.filter(s=>[s.filename,s.repoFullName,s.repoDirectory,s.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(t)&&(this._visibility==="all"||!!s.visible==(this._visibility==="visible")));return c`<div class="collection-toolbar" role="search"><input type="search" aria-label="Search reports" placeholder="Search reports or repositories…" .value="${this._query}" @input="${s=>{this._query=s.target.value}}"><select aria-label="Report visibility" .value="${this._visibility}" @change="${s=>{this._visibility=s.target.value}}"><option value="all">All reports</option><option value="visible">Visible to teams</option><option value="hidden">Hidden reports</option></select><span class="result-count" role="status">${this._data==null?"\u2026 reports":`${i.length} of ${e.length} reports`}</span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div aria-busy="${this._loading}">${this._data==null?this._error?h:ie("Loading reports\u2026"):i.length>0?c`<div class="report-list"><div class="report-list-head" aria-hidden="true"><span class="report-heading">Report / repository</span><span>Uploaded by</span><span>Visibility</span><span class="actions-heading">Actions</span></div><ul class="reports">${i.map(s=>this._row(s))}</ul></div>`:c`<div class="empty"><strong>${e.length===0?"No reports uploaded yet":"No matching reports"}</strong><p>${e.length===0?"Drop a report here or browse files above.":"Try a different search or visibility filter."}</p></div>`}</div>`}_row(e){let t=e.analyzer??e.source??e.producer??"default",i=Pt[t]??Pt.default,s=e.repoEmbedded!==!0&&e.canChangeRepo!==!1,o=e.repoEmbedded===!0||e.repoId!=null,n=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",a=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="report"><div class="report-main"><span class="report-mark" aria-hidden="true">${A(i)}</span> <span class="report-copy"><span class="report-name" data-tooltip-truncated data-tooltip="${e.filename}">${e.filename}</span><span class="report-location" data-tooltip-truncated data-tooltip="${n}">${n}</span></span> <span class="report-meta"><span data-tooltip-truncated data-tooltip="${e.uploadedByLogin??""}">${e.uploadedByLogin??"Uploader removed"}</span><span>${a} · ${Ur(e.byteSize)}</span></span> <span class="${`status ${e.visible?"visible":"hidden"}`}">${e.visible?"Visible":"Hidden"}</span> <span class="report-actions">${s?c`<button type="button" class="action" data-tooltip="Set repository location" aria-label="${`Set location for ${e.filename}`}" @click="${()=>this._openLocation(e)}">${M("repo")}</button>`:c`<span class="action-spacer"></span>`} <button type="button" class="action" data-tooltip="${this._preview===e.id?"Close preview":"Preview report"}" aria-label="${`Preview ${e.filename}`}" aria-expanded="${this._preview===e.id}" @click="${()=>{this._togglePreview(e)}}">${M("preview")}</button> <button type="button" class="action" data-tooltip="${e.visible?"Hide from teams":o?"Make visible to teams":"Assign a repository before publishing"}" aria-label="${`${e.visible?"Hide":"Make visible"} ${e.filename}`}" ?disabled="${e.canChangeRepo===!1||!o&&!e.visible}" @click="${()=>{this._setVisible(e,!e.visible)}}">${M(e.visible?"hide":"show")}</button> <a class="action" aria-label="${`Download ${e.filename}`}" href="${`/api/admin/reports/${encodeURIComponent(e.id)}`}">${M("download")}</a> <button type="button" class="action danger" aria-label="${`Delete ${e.filename}`}" ?disabled="${e.canChangeRepo===!1}" @click="${()=>this._delete(e)}">${Gr}</button></span></div>${this._preview===e.id?c`<div class="preview">${this._previewLoading===e.id?c`<span class="preview-loading">Loading preview…</span>`:c`<pre>${this._previewText??""}</pre>`}</div>`:h} ${this._locationReport===e.id?this._locationEditor(e):h}</li>`}_openLocation(e){e.canChangeRepo!==!1&&(this._locationReport=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null)}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[];return c`<div class="location-editor"><div class="location-field"><span>Repository</span><repository-selector label="Repository for report" .options="${xt(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${i=>{this._locationRepo=i.detail.value}}"></repository-selector></div><div class="location-field"><label for="${`report-dir-${e.id}`}">Directory (optional)</label><input id="${`report-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" @input="${i=>{this._locationDirectory=i.target.value}}"></div><div class="location-actions"><button type="button" class="action" @click="${()=>{this._locationReport=null}}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>{this._saveLocation(e)}}">Save</button></div></div>`}async _saveLocation(e){if(!this._locationBusy){this._locationBusy=!0,this._error=null;try{await this.appState.mutate(()=>wl(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),["reports","repo-impact","history","scan-sources"]),this._locationReport=null,await this._load({preserveError:!0})}catch(t){this._error=`Couldn't set report location: ${String(t?.message??t)}`}finally{this._locationBusy=!1}}}_cancelPreview(){this._previewRequest?.abort(),this._previewRequest=null,this._preview=null,this._previewLoading=null,this._previewText=""}async _togglePreview(e){let t=this._preview===e.id;if(this._cancelPreview(),t)return;let i=new AbortController;this._previewRequest=i;let s=()=>this._previewRequest===i&&!i.signal.aborted;this._preview=e.id,this._previewText=this.appState.read(`report-preview:${e.id}`)??"",this._previewLoading=this.appState.read(`report-preview:${e.id}`)===void 0?e.id:null;try{await this.appState.load(`report-preview:${e.id}`,"report preview",async o=>{let n=await w(`/api/admin/reports/${encodeURIComponent(e.id)}`,{credentials:"same-origin",signal:o});if(!n.ok)throw new Error(`HTTP ${n.status}`);let a=await n.text();return a.slice(0,4e3)+(a.length>4e3?`
63
+ \u2026`:"")},{signal:i.signal,apply:o=>{this._previewText=o}})}catch(o){s()&&o?.name!=="AbortError"&&!this._previewText&&(this._previewText=`Preview unavailable: ${o?.message??o}`)}finally{s()&&(this._previewLoading=null)}}async _setVisible(e,t){this._error=null;try{await this.appState.mutate(()=>_l(e.id,t,this._csrf),["reports","history","scan-sources"]),e.visible=t,this.requestUpdate(),await this._load()}catch(i){this._error=`Couldn't change report visibility: ${String(i?.message??i)}`}}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;)await this.appState.mutate(()=>_o(this._queue.shift(),this._csrf,this._repoId,this._repoDirectory.trim()),["reports","repo-impact","history","scan-sources"])}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load({preserveError:!0})}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? This can't be undone.`)){this._error=null;try{await this.appState.mutate(()=>xl(e.id,this._csrf),["reports",`report-preview:${e.id}`,"repo-impact","history","scan-sources"])}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load({preserveError:!0})}}};customElements.define("managed-admin-reports",Hr);async function Ao(r){let e=await w("/api/admin/bundles",{signal:r,credentials:"same-origin",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function wo(r,e,t){let i={"content-type":"application/octet-stream","x-bundle-filename":encodeURIComponent(r.name)};e&&(i["x-csrf-token"]=e),t!=null&&(i["x-repo-id"]=String(t));let s=await w("/api/admin/bundles",{method:"POST",credentials:"same-origin",headers:i,body:r});if(!s.ok)throw new Error(s.status===413?"too large":s.status===403?"choose a repository within your team access":`HTTP ${s.status}`);return s.json()}async function Sl(r,e){let t=e?{"x-csrf-token":e}:{},i=await w(`/api/admin/bundles/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function El(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await w("/api/admin/bundles/set-repo",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({bundleId:r,repoId:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var Al=c`<svg class="report-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M8.878.392a1.75 1.75 0 0 0-1.756 0l-5.25 3.045A1.75 1.75 0 0 0 1 4.951v6.098c0 .624.332 1.2.872 1.514l5.25 3.045a1.75 1.75 0 0 0 1.756 0l5.25-3.045c.54-.313.872-.89.872-1.514V4.951c0-.624-.332-1.2-.872-1.514ZM7.875 1.69a.25.25 0 0 1 .25 0l4.63 2.685L8 7.133 3.245 4.375Zm-5.125 4.4 4.5 2.61v5.317l-4.375-2.537a.25.25 0 0 1-.125-.216Zm6 7.927V8.7l4.5-2.61v3.96a.25.25 0 0 1-.125.216Z"/></svg>`,Fr=class extends I{static properties={localImportSource:{attribute:!1},_query:{state:!0},_data:{state:!0},_repoId:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[k(Ii),k(U),k(Dt)];constructor(){super(),this._query="",this._data=null,this._error=null,this._busy=!1,this._repoId=null,this._dragOver=!1,this._teardownDrop=null,this._queue=[],this._localImport=new Oe(this,"bundle",e=>Eo(this,e,t=>wo(t,this._csrf,this._repoId),["bundles","reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=So(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("bundles","bundles",Ao,t=>{this._data=t})}render(){return c`${this._dragOver?c`<div class="dropzone">Drop bundles to upload</div>`:h}<div class="wrap">${N("manage-bundles",this._role)}<h1 class="sr-only">Bundles</h1><div class="page-intro"><p class="intro">Source bundles for your repositories.</p>${this._localImport.renderAction()}</div>${this._localImport.renderPanel(this._busy||!this._csrf)}<section class="upload-panel" aria-label="Upload bundles"><div class="upload-copy"><span class="drop-icon" aria-hidden="true">${M("upload")}</span><span><strong>Upload source bundles</strong><span class="upload-description">Drop source archives anywhere on this page.</span></span></div><div class="upload-controls">${$l(this._data?.repos,this._repoId,e=>{this._repoId=e},"Repository")}<button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>ko(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div></section>${this._body()}</div>`}_body(){let e=Array.isArray(this._data?.bundles)?this._data.bundles:[],t=e.filter(a=>a.repoId==null).length,i=e.reduce((a,l)=>a+(Number.isFinite(l.byteSize)?l.byteSize:0),0),s=this._query.trim().toLocaleLowerCase(),o=e.filter(a=>[a.filename,a.repoFullName,a.kind,a.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(s)),n=Map.groupBy(o,a=>a.repoFullName||"Unattached");return c`<div class="collection-toolbar" role="search"><input type="search" aria-label="Search bundles" placeholder="Search bundles or repositories…" .value="${this._query}" @input="${a=>{this._query=a.target.value}}"></div><div class="section-head"><h2>Stored bundles</h2><span class="summary"><span>${this._data==null?"\u2026 bundles":`${e.length} ${e.length===1?"bundle":"bundles"}`}</span><span>${this._data==null?"\u2026":Ur(i)}</span><span class="unassigned">${this._data==null?"\u2026 unattached":t?`${t} unattached`:""}</span></span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div aria-busy="${this._loading}">${this._data==null?this._error?h:ie("Loading bundles\u2026"):o.length>0?c`<div class="bundle-groups">${[...n].toSorted(([a],[l])=>a==="Unattached"?-1:l==="Unattached"?1:a.localeCompare(l)).map(([a,l])=>c`<section class="bundle-group"><div class="bundle-group-head"><strong>${a}</strong><span>${l.length} ${l.length===1?"bundle":"bundles"}</span></div><ul class="bundles">${l.map(d=>this._row(d))}</ul></section>`)}</div>`:c`<div class="empty"><strong>${s?"No matching bundles":"No bundles uploaded yet"}</strong><p>${s?"Try another filename or repository.":"Drop source archives here or browse files above."}</p></div>`}</div>`}_row(e){let t=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="bundle-row"><span class="identity"><span class="bundle-icon" aria-hidden="true">${Al}</span><span class="who"> <button type="button" class="filename bundle-open" @click="${()=>this.dispatchEvent(new CustomEvent("managed-bundle-open",{detail:{id:e.id},bubbles:!0,composed:!0}))}">${e.filename}</button> <span class="meta"><span class="kind">${e.kind==="stasis"?"Stasis":"Sourcemaps"}</span><span>${Ur(e.byteSize)}</span><span>${t}</span>${e.uploadedByLogin?c`<span>@${e.uploadedByLogin}</span>`:h}</span> </span></span><span class="bundle-location">${e.canChangeRepo===!1?c`<span data-tooltip="Your teams do not grant access to change this repository link">${e.repoFullName??"Attached repository"}</span>`:kl(this._data?.repos,e.repoId,i=>this._setRepo(e,i))}</span> <span class="actions"><a class="action" aria-label="${`Download ${e.filename}`}" href="${`/api/admin/bundles/${encodeURIComponent(e.id)}`}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v8m-3-3 3 3 3-3M3 11v3h10v-3"/></svg></a><button type="button" class="action danger" aria-label="${`Delete ${e.filename}`}" ?disabled="${e.canChangeRepo===!1}" data-tooltip="${e.canChangeRepo===!1?"Repository access is required to detach or delete this bundle":"Delete bundle"}" @click="${()=>this._delete(e)}">${Gr}</button></span></li>`}async _setRepo(e,t){this._error=null;try{await this.appState.mutate(()=>El(e.id,t,this._csrf),["bundles","repo-impact","history","scan-sources"])}catch(i){this._error=`Couldn't change repo: ${String(i?.message??i)}`}await this._load({preserveError:!0})}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;){let t=this._queue.shift();await this.appState.mutate(()=>wo(t,this._csrf,this._repoId),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"])}}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load({preserveError:!0})}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? Linked reports will keep their pending link.`)){this._error=null;try{await this.appState.mutate(()=>Sl(e.id,this._csrf),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"])}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load({preserveError:!0})}}};customElements.define("managed-admin-bundles",Fr);var Vr=class extends I{static properties={_source:{state:!0},_error:{state:!0}};static styles=k(U);constructor(){super(),this._loadModels=(e,t)=>this.appState.load("models","scan models",i=>ye(i,w),{signal:e,apply:t}),this._source=null,this._error=null,this._loadReportSources=(e,t)=>this.appState.load("scan-sources","scan report inputs",async i=>{let[s,o]=await Promise.all([w("/api/admin/reports",{signal:i,credentials:"same-origin"}),w("/api/admin/scan-results",{signal:i,credentials:"same-origin"})]);if(!s.ok)throw new Error(`Reports: HTTP ${s.status}`);if(!o.ok&&o.status!==404)throw new Error(`Scan results: HTTP ${o.status}`);let n=await s.json();return n.reports=await Promise.all((n.reports??[]).filter(a=>a.visible&&a.repoId!=null).map(async a=>{let l=await w(`/api/admin/reports/${encodeURIComponent(a.id)}`,{signal:i,credentials:"same-origin"});if(!l.ok)throw new Error(`Report ${a.filename}: HTTP ${l.status}`);return{...a,content:await l.text()}})),ho(n,o.ok?await o.json():{bundles:[],results:[]})},{signal:e,apply:t})}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null,await this._loadCollection("bundles","bundles",Ao,e=>{this._source=co(e)})}render(){return c`<div class="wrap">${N("manage-scans",this._role)} ${this._error?c`<p class="msg error" role="alert">Couldn’t load scan sources: ${this._error} <button type="button" class="btn" @click="${()=>{this._load()}}">Retry</button></p>`:h}<deepview-scan-page hide-heading .source="${this._source}" .sourceLoading="${this._loading&&this._source==null}" .loadBundle="${po}" .loadModels="${this._loadModels}" .loadReportSources="${this._loadReportSources}"></deepview-scan-page></div>`}};customElements.define("managed-admin-scans",Vr);async function Co(r){let e=await w("/api/admin/teams",{signal:r,credentials:"same-origin",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function Z(r,e,t){let i={"content-type":"application/json"};e&&(i["x-csrf-token"]=e);let s=await w(r,{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify(t)});if(!s.ok)throw new Error(s.status===409?"name already taken":`HTTP ${s.status}`)}var qr=class extends I{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_renamingId:{state:!0},_repoChoices:{state:!0},_memberChoices:{state:!0}};static styles=[k(Oi),k(U)];constructor(){super(),this._data=null,this._error=null,this._busy=!1,this._renamingId=null,this._repoChoices=new Map,this._memberChoices=new Map}connectedCallback(){super.connectedCallback(),this._load()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("teams","teams",Co,t=>{this._data=t})}async _do(e){if(!this._busy){this._busy=!0,this._error=null;try{await this.appState.mutate(e,["teams","users","history"])}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load({preserveError:!0})}}}render(){return c`<div class="wrap">${N("manage-teams",this._role)}<h1 class="sr-only">Teams</h1><div class="page-intro"><p class="intro">Group repositories and give members access to the findings they need.</p><span class="result-count">${this._data?.teams?.length??"\u2026"} teams</span></div><div class="create-team"><div class="create-copy"><strong>Create a team</strong><span>Share the right findings with the right people.</span></div><label class="sr-only" for="new-team-name">New team</label> <input id="new-team-name" class="new-name" type="text" placeholder="Team name" maxlength="100" ?disabled="${this._busy}" @keydown="${e=>{e.key==="Enter"&&this._create()}}"> <button class="btn primary" ?disabled="${this._busy}" @click="${()=>this._create()}">${Tr} Create team</button></div><div aria-busy="${this._loading}">${this._body()}</div></div>`}_body(){if(this._error!=null&&this._data==null)return c`<p class="msg error">Couldn't load teams: ${this._error}</p>`;if(this._data==null)return ie("Loading teams\u2026");let e=Array.isArray(this._data.teams)?this._data.teams:[];return c`${this._error==null?h:c`<p class="msg error">${this._error}</p>`} ${e.length===0?c`<p class="msg">No teams yet. Create one above.</p>`:e.map(t=>this._team(t))}`}_team(e){return c`<section class="team" aria-label="${e.name}"><div class="team-head"><span class="team-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2.5"/><path d="M1.5 13v-1c0-2 1.8-3.5 4.5-3.5s4.5 1.5 4.5 3.5v1M11 2.5a2.5 2.5 0 0 1 0 5M12 9c1.7.5 2.5 1.5 2.5 3v1"/></svg></span>${this._renamingId===e.id?c`<input class="rename-input" type="text" .value="${e.name}" maxlength="100" aria-label="Team name" @keydown="${t=>this._renameKey(t,e)}"> <button class="btn" ?disabled="${this._busy}" @click="${t=>this._saveRename(e,t)}">Save</button> <button class="btn" @click="${()=>{this._renamingId=null}}">Cancel</button>`:c`<h2 class="team-name">${e.name}</h2><span class="team-actions"><button class="icon-btn" aria-label="${`Rename ${e.name}`}" ?disabled="${this._busy}" @click="${()=>{this._renamingId=e.id}}">${cl}</button> <button class="icon-btn danger" aria-label="${`Delete ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._deleteTeam(e)}">${Gr}</button></span>`}</div><div class="team-body"><div class="sub"><h3 class="sub-title">Repositories <span class="count">${e.repos.length}</span></h3><p class="sub-description">Source repositories included in this team.</p>${e.repos.length===0?c`<p class="muted">No repositories linked.</p>`:c`<ul class="links">${e.repos.map(t=>this._repoRow(e,t))}</ul>`} ${this._addRepoRow(e)}</div><div class="sub"><h3 class="sub-title">Members <span class="count">${e.members.length}</span></h3><p class="sub-description"><span>All members can view standard findings.</span><span>Choose who can also view dependencies and security findings.</span></p>${e.members.length===0?c`<p class="muted">No members.</p>`:c`<ul class="links">${e.members.map(t=>this._memberRow(e,t))}</ul>`} ${this._addMemberRow(e)}</div></div></section>`}_repoRow(e,t){return c`<li class="repo-row">${$o} <span class="repo-copy"><span class="ln">${t.fullName}</span>${t.path?c`<span class="path">/${t.path.replace(/^\/+/u,"")}</span>`:h}</span> <button class="icon-btn danger" aria-label="${`Remove ${t.fullName}${t.path?`/${t.path}`:""} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>Z("/api/admin/teams/remove-repo",this._csrf,{teamId:e.id,repoId:t.repoId,path:t.path??null}))}">${bo}</button></li>`}_addRepoRow(e){let t=Array.isArray(this._data.repos)?this._data.repos:[];return t.length===0?c`<p class="muted">No selected repositories to link — pick some on “Manage repositories”.</p>`:c`<div class="add-row"><repository-selector class="add-repo-sel" label="${`Repository to add to ${e.name}`}" placeholder="Add repository…" ?disabled="${this._busy}" .options="${t.map(i=>({value:i.repoId,label:i.fullName}))}" .value="${this._repoChoices.get(e.id)??null}" @repository-change="${i=>{this._repoChoices=new Map(this._repoChoices).set(e.id,i.detail.value)}}"></repository-selector><input class="add-repo-path" type="text" placeholder="Path (optional)" aria-label="${`Repository path in ${e.name} (optional)`}" maxlength="500" ?disabled="${this._busy}"> <button class="btn" aria-label="${`Add repository to ${e.name}`}" ?disabled="${this._busy||!this._repoChoices.has(e.id)}" @click="${i=>this._addRepo(e,i)}">${Tr} Add</button></div>`}_memberRow(e,t){let i=Array.isArray(this._data.permissions)?this._data.permissions:[];return c`<li class="member-row"><span class="member">${xo(t.userId,t.login)}<span class="ln">${t.login}</span></span> <span class="perms">${i.map(s=>c`<label class="perm"><input type="checkbox" .checked="${t[s]===!0}" ?disabled="${this._busy}" aria-label="${`${$t[s]??s} access for ${t.login} in ${e.name}`}" @change="${o=>this._togglePerm(e,t,s,o.target.checked)}"> ${$t[s]??s}</label>`)} </span><button class="icon-btn danger" aria-label="${`Remove ${t.login} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>Z("/api/admin/teams/remove-member",this._csrf,{teamId:e.id,userId:t.userId}))}">${bo}</button></li>`}_addMemberRow(e){let t=Array.isArray(this._data.users)?this._data.users:[],i=new Set(e.members.map(s=>s.userId));return c`<div class="add-row"><user-selector class="add-member-sel" label="${`Member to add to ${e.name}`}" placeholder="Add member…" ?disabled="${this._busy}" .users="${t.map(s=>({...s,disabled:i.has(s.id),detail:i.has(s.id)?"Member":""}))}" .value="${this._memberChoices.get(e.id)??null}" @user-change="${s=>{this._memberChoices=new Map(this._memberChoices).set(e.id,s.detail.value)}}"></user-selector><button class="btn" aria-label="${`Add member to ${e.name}`}" ?disabled="${this._busy||!this._memberChoices.has(e.id)||i.has(this._memberChoices.get(e.id))}" @click="${()=>this._addMember(e)}">${Tr} Add</button></div>`}_create(){let e=this.renderRoot.querySelector(".new-name"),t=e?.value.trim();t&&this._do(async()=>{await Z("/api/admin/teams",this._csrf,{name:t}),e&&(e.value="")})}_deleteTeam(e){globalThis.confirm?.(`Delete team \u201C${e.name}\u201D? Its repo + member links are removed.`)&&this._do(()=>Z("/api/admin/teams/delete",this._csrf,{teamId:e.id}))}_renameKey(e,t){e.key==="Enter"?this._saveRename(t,e):e.key==="Escape"&&(this._renamingId=null)}_saveRename(e,t){if(this._busy)return;let i=t.target.closest(".team-head")?.querySelector(".rename-input")?.value.trim()??"";this._renamingId=null,!(i===""||i===e.name)&&this._do(()=>Z("/api/admin/teams/rename",this._csrf,{teamId:e.id,name:i}))}_addRepo(e,t){let i=t.target.closest(".add-row"),s=this._repoChoices.get(e.id);if(!Number.isSafeInteger(s)||s<=0)return;let o=i?.querySelector(".add-repo-path")?.value??"";this._do(async()=>{await Z("/api/admin/teams/set-repo",this._csrf,{teamId:e.id,repoId:s,path:o});let n=new Map(this._repoChoices);n.delete(e.id),this._repoChoices=n;let a=i?.querySelector(".add-repo-path");a&&(a.value="")})}_addMember(e){let t=this._memberChoices.get(e.id);!t||e.members.some(i=>i.userId===t)||this._do(async()=>{await Z("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t});let i=new Map(this._memberChoices);i.delete(e.id),this._memberChoices=i})}_togglePerm(e,t,i,s){let o={};for(let n of this._data.permissions??[])o[n]=t[n]===!0;o[i]=s,this._do(()=>Z("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t.userId,...o}))}};customElements.define("managed-admin-teams",qr);async function Wr(r,e=null){let t;try{t=await w(r,{credentials:"same-origin",headers:{accept:"application/json"}})}catch{return e}if(t.status===401||t.status===403)return null;if(!t.ok)return e;try{return await t.json()}catch{return e}}async function nm({fallback:r=null}={}){let e;try{let i=await w("/api/auth/session",{credentials:"same-origin",headers:{accept:"application/json"}});if(i.status===401||i.status===403)return null;if(!i.ok)return r;e=await i.json()}catch{return r}let t=e?.user;return t===null?null:t===void 0||typeof t.login!="string"?r:{id:t.id,login:t.login,name:typeof t.name=="string"?t.name:null,avatarUrl:typeof t.avatarUrl=="string"?t.avatarUrl:null,role:typeof t.role=="string"?t.role:"none",csrfToken:typeof e.csrfToken=="string"?e.csrfToken:null}}async function am({fallback:r=[]}={}){let e=await Wr("/api/teams",{teams:r}),t=e?.teams;return Array.isArray(t)?t.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.name=="string").map(i=>({id:i.id,slug:i.slug,name:i.name,reports:Array.isArray(i.reports)?i.reports.filter(s=>s!=null&&typeof s.id=="string"&&typeof s.filename=="string").map(s=>({id:s.id,slug:s.slug,filename:s.filename})):[],bundles:Array.isArray(i.bundles)?i.bundles.filter(s=>s!=null&&typeof s.id=="string"&&typeof s.filename=="string").map(s=>({id:s.id,filename:s.filename,repoFullName:typeof s.repoFullName=="string"?s.repoFullName:""})):[]})):e==null?[]:r}async function lm(r){let e=await Wr(`/api/reports/${encodeURIComponent(r)}`);return typeof e?.content!="string"||typeof e.repo?.directory!="string"||e.repo.github!==null&&typeof e.repo.github!="string"?null:{content:e.content,repo:e.repo}}async function cm(r){let t=(await Wr(`/api/reports/${encodeURIComponent(r)}/triage`))?.entries;return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:null}async function dm(r,e,t){try{let i=await w("/api/github/pull-requests",{method:"POST",credentials:"same-origin",signal:t,headers:{"content-type":"application/json",...e?{"x-csrf-token":e}:{}},body:JSON.stringify({urls:r})});if(!i.ok)return null;let s=await i.json();return Array.isArray(s?.pullRequests)?s.pullRequests:null}catch{return null}}async function pm(r,e,t){try{return(await w(`/api/reports/${encodeURIComponent(r)}/triage`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",...t?{"x-csrf-token":t}:{}},body:JSON.stringify({entries:e})})).status}catch{return 0}}function um(r){r&&(location.href=r)}async function hm(r){try{await w("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:r?{"x-csrf-token":r}:{}})}catch{}location.reload()}export{al as fetchBundleContents,zr as fetchBundleMetadata,dm as fetchPullRequests,lm as fetchReport,cm as fetchReportTriage,St as getPreviewRole,um as login,hm as logout,nm as probeSession,am as probeTeams,pm as pushReportTriage,Fo as resetManagedAppState,Ho as setManagedAppSession,Mo as setPreviewRole};
48
64
  /*! Bundled license information:
49
65
 
50
66
  @lit/reactive-element/css-tag.js: