@preventive/triage 1.0.0-alpha.35 → 1.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dependency-paths.d.ts +2 -0
- package/client/dependency-paths.js +24 -0
- package/common/managed/report-content.ts +31 -1
- package/out/client-managed-import.js +41 -41
- package/out/client-managed.js +67 -67
- package/out/view.js +164 -164
- package/package.json +3 -1
- package/server-managed/bundle-build-worker.js +27 -6
- package/server-managed/bundle-build.ts +4 -2
- package/server-managed/http.ts +57 -2
package/out/client-managed.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
var Zc=Object.defineProperty;var w=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(i){throw t=[i],i}};var Nr=(r,e)=>{for(var t in e)Zc(r,t,{get:e[t],enumerable:!0})};function so(r){return typeof r=="string"&&Re.includes(r)}function Ge(r,e){let t=Re.indexOf(r);return t!==-1&&t<=Re.indexOf(e)}var Re,Pr=w(()=>{"use strict";Re=["admin","manage","triage","view","none"]});var oo,Br,Dr=w(()=>{"use strict";oo=["dependencies","security"],Br={dependencies:"Dependencies",security:"Security"}});function no(r=null){let e=["anthropic/claude-opus-5.5","anthropic/claude-fable-5.1","anthropic/claude-sonnet-5.5","anthropic/claude-haiku-4.5","openai/gpt-6-astra","openai/gpt-6-astra-pro","openai/gpt-6.1-sol","openai/gpt-6.1-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 ao=w(()=>{"use strict"});var lo,co,po,uo=w(()=>{"use strict";ao();lo=no(),co=Object.freeze(lo.models),po=lo.defaultModel});function Jc(r){if(!r?.startsWith("#public="))return null;let e=/^#public=([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/u.exec(r);return e?{id:e[1],token:e[2]}:{id:"",token:""}}function ee(){return mo}function jr(r=mo){return`/api/shares/${encodeURIComponent(r.id)}/workspace`}var ho,mo,Ot=w(()=>{"use strict";ho=globalThis.location?.hash,mo=Jc(ho);globalThis.addEventListener?.("hashchange",()=>{let r=globalThis.location?.hash;r?.startsWith("#public=")&&r!==ho&&globalThis.location.reload()})});function Ee(){return de?.user.role??null}function Yc(r){if(r!==null&&!so(r))throw new TypeError(`Unknown managed preview role: ${r}. Expected ${Re.join(", ")}.`);Tt++,de=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 Xc(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(de);if(t==="/api/teams")return Response.json({teams:[]});if(t.startsWith("/api/admin/")&&!Ge(de.user.role,"manage"))return Response.json({error:"forbidden"},{status:403});if(["/api/admin/users","/api/admin/teams","/api/admin/repositories","/api/admin/repositories/aliases"].includes(t)&&de.user.role!=="admin")return Response.json({error:"forbidden"},{status:403});let s={"/api/admin/users":{users:[de.user]},"/api/admin/teams":{teams:[],users:[de.user],repos:[],permissions:oo},"/api/admin/links":{shares:[]},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/repositories/aliases":{aliases:[],repos:[]},"/api/admin/repositories/resolve":{location:null},"/api/admin/reports":{reports:[],repos:[],maxBytes:26214400},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:209715200},"/api/admin/history":{history:[],total:0,page:1,limit:100,filters:{repos:[],users:[]}},"/api/admin/scan/models":{models:co,defaultModel:po},"/api/admin/scan-results":{bundles:[],results:[]}};return Object.hasOwn(s,t)?Response.json(s[t]):Response.json({error:"not-found"},{status:404})}async function Qc(r,e,t){let i=await t("/api/config",{credentials:"same-origin",signal:e.signal});if(!i.ok)return i;let s=(await i.json()).managed,o=s?.uploadChunkBytes;if(!Number.isSafeInteger(o)||o<=0||o>3*1024*1024)return t(r,e);let n=e.body,a=crypto.randomUUID(),l=r.endsWith("/reports")?"reports":"bundles",d=s?.uploadMaxBytes?.[l];if(Number.isSafeInteger(d)&&d>0&&n.size>d)return Response.json({error:"too-large"},{status:413});let u=Math.ceil(n.size/o),p=new Headers(e.headers);p.set("content-type","application/octet-stream");let h=0,f=!1;try{for(let y=0;y<u;y++){h=y+1;let g=await t(`/api/admin/uploads/${l}/${a}/${y}`,{...e,headers:p,body:n.slice(y*o,(y+1)*o)});if(!g.ok)return g}let b=new Headers(e.headers);b.set("x-upload-id",a),b.set("x-upload-parts",String(u)),b.set("x-upload-size",String(n.size));let v=await t(r,{...e,headers:b,body:""});return f=v.ok,v}finally{if(!f&&h>0){let b=new Headers(e.headers);b.set("x-upload-parts",String(h)),await t(`/api/admin/uploads/${l}/${a}`,{...e,method:"DELETE",headers:b,body:void 0,signal:AbortSignal.timeout(1e4)}).catch(()=>{})}}}async function $(r,e){if(e?.signal?.throwIfAborted(),de)return Xc(r,e);let t=Tt;async function i(s,o){if(t!==Tt)throw new DOMException("Managed session changed","AbortError");let n=ee();if(n){if(new URL(s,globalThis.location.origin).origin!==globalThis.location.origin)throw new Error("Public workspace requests must be same-origin");let d=new Headers(o?.headers);d.set("x-deepview-share",n.token),o={...o,headers:d,credentials:"omit",redirect:"error"}}let a=await fetch(s,{...o,cache:"no-store"});if(t!==Tt)throw new DOMException("Managed session changed","AbortError");return a}return e?.method==="POST"&&["/api/admin/reports","/api/admin/bundles"].includes(r)&&e.body instanceof Blob&&e.body.size>3*1024*1024?Qc(r,e,i):await i(r,e)}var de,Tt,B=w(()=>{"use strict";Pr();Dr();uo();Ot();de=null,Tt=0});var Nt,Pt,Ur,fo,ct,x,z,go,Fr,Hr=w(()=>{Nt=globalThis,Pt=Nt.ShadowRoot&&(Nt.ShadyCSS===void 0||Nt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ur=Symbol(),fo=new WeakMap,ct=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Ur)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(Pt&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=fo.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&fo.set(t,e))}return e}toString(){return this.cssText}},x=r=>new ct(typeof r=="string"?r:r+"",void 0,Ur),z=(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 ct(t,r,Ur)},go=(r,e)=>{if(Pt)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=Nt.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},Fr=Pt?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return x(t)})(r):r});var ed,td,rd,id,sd,od,Bt,bo,nd,ad,dt,qr,yo,vo,oe,Dt=w(()=>{Hr();Hr();({is:ed,defineProperty:td,getOwnPropertyDescriptor:rd,getOwnPropertyNames:id,getOwnPropertySymbols:sd,getPrototypeOf:od}=Object),Bt=globalThis,bo=Bt.trustedTypes,nd=bo?bo.emptyScript:"",ad=Bt.reactiveElementPolyfillSupport,dt=(r,e)=>r,qr={toAttribute(r,e){switch(e){case Boolean:r=r?nd: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}},yo=(r,e)=>!ed(r,e),vo={attribute:!0,type:String,converter:qr,reflect:!1,useDefault:!1,hasChanged:yo};Symbol.metadata??=Symbol("metadata"),Bt.litPropertyMetadata??=new WeakMap;oe=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=vo){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&&td(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:o}=rd(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)??vo}static _$Ei(){if(this.hasOwnProperty(dt("elementProperties")))return;let e=od(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(dt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dt("properties"))){let t=this.properties,i=[...id(t),...sd(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(Fr(s))}else e!==void 0&&t.push(Fr(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 go(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:qr).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:qr;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??yo)(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){}};oe.elementStyles=[],oe.shadowRootOptions={mode:"open"},oe[dt("elementProperties")]=new Map,oe[dt("finalized")]=new Map,ad?.({ReactiveElement:oe}),(Bt.reactiveElementVersions??=[]).push("2.1.2")});function Ao(r,e){if(!Zr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return _o!==void 0?_o.createHTML(e):e}function Le(r,e,t=r,i){if(e===j)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,o=ht(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=Le(r,s._$AS(r,e.values),s,i)),e}var Gr,wo,jt,_o,Wr,ne,Kr,ld,Ie,ut,ht,Zr,Ro,Vr,pt,xo,$o,Ae,ko,So,Eo,Jr,c,V,um,j,m,Co,Me,Mo,mt,Ut,We,ze,Ft,Ht,qt,Vt,Io,cd,Yr,te=w(()=>{Gr=globalThis,wo=r=>r,jt=Gr.trustedTypes,_o=jt?jt.createPolicy("lit-html",{createHTML:r=>r}):void 0,Wr="$lit$",ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Kr="?"+ne,ld=`<${Kr}>`,Ie=document,ut=()=>Ie.createComment(""),ht=r=>r===null||typeof r!="object"&&typeof r!="function",Zr=Array.isArray,Ro=r=>Zr(r)||typeof r?.[Symbol.iterator]=="function",Vr=`[
|
|
1
|
+
var Yc=Object.defineProperty;var _=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(i){throw t=[i],i}};var Nr=(r,e)=>{for(var t in e)Yc(r,t,{get:e[t],enumerable:!0})};function so(r){return typeof r=="string"&&Re.includes(r)}function Ge(r,e){let t=Re.indexOf(r);return t!==-1&&t<=Re.indexOf(e)}var Re,Pr=_(()=>{"use strict";Re=["admin","manage","triage","view","none"]});var oo,Br,Dr=_(()=>{"use strict";oo=["dependencies","security"],Br={dependencies:"Dependencies",security:"Security"}});function no(r=null){let e=["anthropic/claude-opus-5.5","anthropic/claude-fable-5.1","anthropic/claude-sonnet-5.5","anthropic/claude-haiku-4.5","openai/gpt-6-astra","openai/gpt-6-astra-pro","openai/gpt-6.1-sol","openai/gpt-6.1-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 ao=_(()=>{"use strict"});var lo,co,po,uo=_(()=>{"use strict";ao();lo=no(),co=Object.freeze(lo.models),po=lo.defaultModel});function Xc(r){if(!r?.startsWith("#public="))return null;let e=/^#public=([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/u.exec(r);return e?{id:e[1],token:e[2]}:{id:"",token:""}}function ee(){return mo}function jr(r=mo){return`/api/shares/${encodeURIComponent(r.id)}/workspace`}var ho,mo,Ot=_(()=>{"use strict";ho=globalThis.location?.hash,mo=Xc(ho);globalThis.addEventListener?.("hashchange",()=>{let r=globalThis.location?.hash;r?.startsWith("#public=")&&r!==ho&&globalThis.location.reload()})});function Ee(){return de?.user.role??null}function Qc(r){if(r!==null&&!so(r))throw new TypeError(`Unknown managed preview role: ${r}. Expected ${Re.join(", ")}.`);Tt++,de=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 ed(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(de);if(t==="/api/teams")return Response.json({teams:[]});if(t.startsWith("/api/admin/")&&!Ge(de.user.role,"manage"))return Response.json({error:"forbidden"},{status:403});if(["/api/admin/users","/api/admin/teams","/api/admin/repositories","/api/admin/repositories/aliases"].includes(t)&&de.user.role!=="admin")return Response.json({error:"forbidden"},{status:403});let s={"/api/admin/users":{users:[de.user]},"/api/admin/teams":{teams:[],users:[de.user],repos:[],permissions:oo},"/api/admin/links":{shares:[]},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/repositories/aliases":{aliases:[],repos:[]},"/api/admin/repositories/resolve":{location:null},"/api/admin/reports":{reports:[],repos:[],maxBytes:26214400},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:209715200},"/api/admin/history":{history:[],total:0,page:1,limit:100,filters:{repos:[],users:[]}},"/api/admin/scan/models":{models:co,defaultModel:po},"/api/admin/scan-results":{bundles:[],results:[]}};return Object.hasOwn(s,t)?Response.json(s[t]):Response.json({error:"not-found"},{status:404})}async function td(r,e,t){let i=await t("/api/config",{credentials:"same-origin",signal:e.signal});if(!i.ok)return i;let s=(await i.json()).managed,o=s?.uploadChunkBytes;if(!Number.isSafeInteger(o)||o<=0||o>3*1024*1024)return t(r,e);let n=e.body,a=crypto.randomUUID(),l=r.endsWith("/reports")?"reports":"bundles",d=s?.uploadMaxBytes?.[l];if(Number.isSafeInteger(d)&&d>0&&n.size>d)return Response.json({error:"too-large"},{status:413});let m=Math.ceil(n.size/o),p=new Headers(e.headers);p.set("content-type","application/octet-stream");let u=0,f=!1;try{for(let y=0;y<m;y++){u=y+1;let g=await t(`/api/admin/uploads/${l}/${a}/${y}`,{...e,headers:p,body:n.slice(y*o,(y+1)*o)});if(!g.ok)return g}let b=new Headers(e.headers);b.set("x-upload-id",a),b.set("x-upload-parts",String(m)),b.set("x-upload-size",String(n.size));let v=await t(r,{...e,headers:b,body:""});return f=v.ok,v}finally{if(!f&&u>0){let b=new Headers(e.headers);b.set("x-upload-parts",String(u)),await t(`/api/admin/uploads/${l}/${a}`,{...e,method:"DELETE",headers:b,body:void 0,signal:AbortSignal.timeout(1e4)}).catch(()=>{})}}}async function x(r,e){if(e?.signal?.throwIfAborted(),de)return ed(r,e);let t=Tt;async function i(s,o){if(t!==Tt)throw new DOMException("Managed session changed","AbortError");let n=ee();if(n){if(new URL(s,globalThis.location.origin).origin!==globalThis.location.origin)throw new Error("Public workspace requests must be same-origin");let d=new Headers(o?.headers);d.set("x-deepview-share",n.token),o={...o,headers:d,credentials:"omit",redirect:"error"}}let a=await fetch(s,{...o,cache:"no-store"});if(t!==Tt)throw new DOMException("Managed session changed","AbortError");return a}return e?.method==="POST"&&["/api/admin/reports","/api/admin/bundles"].includes(r)&&e.body instanceof Blob&&e.body.size>3*1024*1024?td(r,e,i):await i(r,e)}var de,Tt,B=_(()=>{"use strict";Pr();Dr();uo();Ot();de=null,Tt=0});var Nt,Pt,Ur,fo,ct,$,z,go,Fr,Hr=_(()=>{Nt=globalThis,Pt=Nt.ShadowRoot&&(Nt.ShadyCSS===void 0||Nt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ur=Symbol(),fo=new WeakMap,ct=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Ur)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(Pt&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=fo.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&fo.set(t,e))}return e}toString(){return this.cssText}},$=r=>new ct(typeof r=="string"?r:r+"",void 0,Ur),z=(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 ct(t,r,Ur)},go=(r,e)=>{if(Pt)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=Nt.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},Fr=Pt?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return $(t)})(r):r});var rd,id,sd,od,nd,ad,Bt,bo,ld,cd,dt,qr,yo,vo,oe,Dt=_(()=>{Hr();Hr();({is:rd,defineProperty:id,getOwnPropertyDescriptor:sd,getOwnPropertyNames:od,getOwnPropertySymbols:nd,getPrototypeOf:ad}=Object),Bt=globalThis,bo=Bt.trustedTypes,ld=bo?bo.emptyScript:"",cd=Bt.reactiveElementPolyfillSupport,dt=(r,e)=>r,qr={toAttribute(r,e){switch(e){case Boolean:r=r?ld: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}},yo=(r,e)=>!rd(r,e),vo={attribute:!0,type:String,converter:qr,reflect:!1,useDefault:!1,hasChanged:yo};Symbol.metadata??=Symbol("metadata"),Bt.litPropertyMetadata??=new WeakMap;oe=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=vo){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&&id(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:o}=sd(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)??vo}static _$Ei(){if(this.hasOwnProperty(dt("elementProperties")))return;let e=ad(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(dt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dt("properties"))){let t=this.properties,i=[...od(t),...nd(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(Fr(s))}else e!==void 0&&t.push(Fr(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 go(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:qr).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:qr;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??yo)(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){}};oe.elementStyles=[],oe.shadowRootOptions={mode:"open"},oe[dt("elementProperties")]=new Map,oe[dt("finalized")]=new Map,cd?.({ReactiveElement:oe}),(Bt.reactiveElementVersions??=[]).push("2.1.2")});function Ao(r,e){if(!Zr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return wo!==void 0?wo.createHTML(e):e}function Le(r,e,t=r,i){if(e===j)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,o=ht(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=Le(r,s._$AS(r,e.values),s,i)),e}var Gr,_o,jt,wo,Wr,ne,Kr,dd,Me,ut,ht,Zr,Ro,Vr,pt,xo,$o,Ae,ko,So,Eo,Jr,c,V,mm,j,h,Co,Ie,Io,mt,Ut,We,ze,Ft,Ht,qt,Vt,Mo,pd,Yr,te=_(()=>{Gr=globalThis,_o=r=>r,jt=Gr.trustedTypes,wo=jt?jt.createPolicy("lit-html",{createHTML:r=>r}):void 0,Wr="$lit$",ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Kr="?"+ne,dd=`<${Kr}>`,Me=document,ut=()=>Me.createComment(""),ht=r=>r===null||typeof r!="object"&&typeof r!="function",Zr=Array.isArray,Ro=r=>Zr(r)||typeof r?.[Symbol.iterator]=="function",Vr=`[
|
|
2
2
|
\f\r]`,pt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xo=/-->/g,$o=/>/g,Ae=RegExp(`>|${Vr}(?:([^\\s"'>=/]+)(${Vr}*=${Vr}*(?:[^
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),ko=/'/g,So=/"/g,Eo=/^(?:script|style|textarea|title)$/i,Jr=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),c=Jr(1),V=Jr(2),
|
|
4
|
-
`)){let f=
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ko=/'/g,So=/"/g,Eo=/^(?:script|style|textarea|title)$/i,Jr=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),c=Jr(1),V=Jr(2),mm=Jr(3),j=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),Co=new WeakMap,Ie=Me.createTreeWalker(Me,129);Io=(r,e)=>{let t=r.length-1,i=[],s,o=e===2?"<svg>":e===3?"<math>":"",n=pt;for(let a=0;a<t;a++){let l=r[a],d,m,p=-1,u=0;for(;u<l.length&&(n.lastIndex=u,m=n.exec(l),m!==null);)u=n.lastIndex,n===pt?m[1]==="!--"?n=xo:m[1]!==void 0?n=$o:m[2]!==void 0?(Eo.test(m[2])&&(s=RegExp("</"+m[2],"g")),n=Ae):m[3]!==void 0&&(n=Ae):n===Ae?m[0]===">"?(n=s??pt,p=-1):m[1]===void 0?p=-2:(p=n.lastIndex-m[2].length,d=m[1],n=m[3]===void 0?Ae:m[3]==='"'?So:ko):n===So||n===ko?n=Ae:n===xo||n===$o?n=pt:(n=Ae,s=void 0);let f=n===Ae&&r[a+1].startsWith("/>")?" ":"";o+=n===pt?l+dd:p>=0?(i.push(d),l.slice(0,p)+Wr+l.slice(p)+ne+f):l+ne+(p===-2?a:f)}return[Ao(r,o+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},mt=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,m]=Io(e,t);if(this.el=r.createElement(d,i),Ie.currentNode=this.el.content,t===2||t===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=Ie.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let p of s.getAttributeNames())if(p.endsWith(Wr)){let u=m[n++],f=s.getAttribute(p).split(ne),b=/([.?@])?(.*)/.exec(u);l.push({type:1,index:o,name:b[2],strings:f,ctor:b[1]==="."?Ft:b[1]==="?"?Ht:b[1]==="@"?qt:ze}),s.removeAttribute(p)}else p.startsWith(ne)&&(l.push({type:6,index:o}),s.removeAttribute(p));if(Eo.test(s.tagName)){let p=s.textContent.split(ne),u=p.length-1;if(u>0){s.textContent=jt?jt.emptyScript:"";for(let f=0;f<u;f++)s.append(p[f],ut()),Ie.nextNode(),l.push({type:2,index:++o});s.append(p[u],ut())}}}else if(s.nodeType===8)if(s.data===Kr)l.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(ne,p+1))!==-1;)l.push({type:7,index:o}),p+=ne.length-1}o++}}static createElement(e,t){let i=Me.createElement("template");return i.innerHTML=e,i}};Ut=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??Me).importNode(t,!0);Ie.currentNode=s;let o=Ie.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new We(o,o.nextSibling,this,e):l.type===1?d=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(d=new Vt(o,this,e)),this._$AV.push(d),l=i[++a]}n!==l?.index&&(o=Ie.nextNode(),n++)}return Ie.currentNode=Me,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++}},We=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=Le(this,e,t),ht(e)?e===h||e==null||e===""?(this._$AH!==h&&this._$AR(),this._$AH=h):e!==this._$AH&&e!==j&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ro(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&&ht(this._$AH)?this._$AA.nextSibling.data=e:this.T(Me.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=mt.createElement(Ao(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{let o=new Ut(s,this),n=o.u(this.options);o.p(t),this.T(n),this._$AH=o}}_$AC(e){let t=Co.get(e.strings);return t===void 0&&Co.set(e.strings,t=new mt(e)),t}k(e){Zr(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(ut()),this.O(ut()),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=_o(e).nextSibling;_o(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ze=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=Le(this,e,t,0),n=!ht(e)||e!==this._$AH&&e!==j,n&&(this._$AH=e);else{let a=e,l,d;for(e=o[0],l=0;l<o.length-1;l++)d=Le(this,a[i+l],t,l),d===j&&(d=this._$AH[l]),n||=!ht(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??"")}},Ft=class extends ze{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===h?void 0:e}},Ht=class extends ze{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==h)}},qt=class extends ze{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=Le(this,e,t,0)??h)===j)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)}},Vt=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){Le(this,e)}},Mo={M:Wr,P:ne,A:Kr,C:1,L:Io,R:Ut,D:Ro,V:Le,I:We,H:ze,N:Ht,U:qt,B:Ft,F:Vt},pd=Gr.litHtmlPolyfillSupport;pd?.(mt,We),(Gr.litHtmlVersions??=[]).push("3.3.3");Yr=(r,e,t)=>{let i=t?.renderBefore??e,s=i._$litPart$;if(s===void 0){let o=t?.renderBefore??null;i._$litPart$=s=new We(e.insertBefore(ut(),o),o,void 0,t??{})}return s._$AI(r),s}});var Xr,A,ud,Lo=_(()=>{Dt();Dt();te();te();Xr=globalThis,A=class extends oe{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=Yr(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return j}};A._$litElement$=!0,A.finalized=!0,Xr.litElementHydrateSupport?.({LitElement:A});ud=Xr.litElementPolyfillSupport;ud?.({LitElement:A});(Xr.litElementVersions??=[]).push("4.2.2")});var zo=_(()=>{});var S=_(()=>{Dt();te();Lo();zo()});function Gt(r){if(r._idBasis)return r._idBasis;let{severity:e,description:t}=r;return r.fileHash?{severity:e,description:t,fileHash:r.fileHash}:r.location?{severity:e,description:t,location:r.location}:{severity:e,description:t,file:r.file,line:r.line}}var Qr=_(()=>{});function Wt(r,e,t=e){let i=/^ */u.exec(r)[0].length;if(i>3)return null;if(e&&t&&md.test(r))return!0;let s=To.exec(r);if(s&&!(s[2][0]==="`"&&s[3].includes("`")))return{fence:s[2]};let o=r.slice(i);for(let[l,d,m]of gd){let p=l.exec(o);if(p)return{html:d,close:typeof m=="function"?m(p):m}}if(!e&&bd.test(o))return{html:No,close:null};let n=Oo.test(r)?null:Oe.exec(r);if(n&&!(e&&t&&/^ *(?:\d*[02-9]|\d+\d)[.)]/u.test(n[0]))){let l=/ +$/u.exec(n[0])[0].length;return{item:l>4?n[0].length-l+1:n[0].length}}let a=Oo.test(r)||e&&t?null:fd.exec(r);return a?{item:a[0].trimEnd().length+1}:hd.test(r)||null}function pe(r){return ei(r).ranges}function vd(r,e){let t=r.replace(/^(?: {0,3}> ?)+/u,""),i=Wt(t,e);for(;i?.item;)t=t.slice(i.item),i=Wt(t,!1);return t.trim()!==""&&!i&&/^ */u.exec(t)[0].length<4}function ei(r){let e=[],t=-1,i="",s=null,o=0,n=[],a=!1,l=!1,d=!1,m=0;for(let u of r.split(`
|
|
4
|
+
`)){let f=m;m+=u.length+1;let b=/^ */u.exec(u)[0].length;if(t!==-1||s){let L=o>0&&u.trim()!==""&&b<o,I=!L&&(s?s.ends.test(u):b<=o+3&&Po(i,u));if((L||I)&&(t!==-1&&e.push([t,L?f-1:f+u.length]),t=-1,s=null),!L)continue}if(!u.trim()){d&&n.pop(),d=!1,a=!1;continue}let v=n.length;for(;v>0&&b<n[v-1];)v--;let y=v>0?n[v-1]:0,g=u.slice(y),k=Wt(g,a,v===n.length&&!l);if(a&&!k)continue;for(n.length=v;k?.item;)y+=k.item,g=g.slice(k.item),n.push(y),k=Wt(g,!1);d=g.trim()==="",k?.fence?[t,i,o]=[f,k.fence,y]:k?.html&&([s,o]=[k.html.test(g)?null:{ends:k.html,close:k.close},y]);let C=a&&l;l=/^ {0,3}>/u.test(g),a=l?vd(g,C):!k&&!d&&/^ */u.exec(g)[0].length<4}t!==-1&&e.push([t,r.length]);let p=t===-1?s?.close:i;return{ranges:e,closer:p?" ".repeat(o)+p:null}}function Po(r,e){let t=To.exec(e);return t!==null&&t[2][0]===r[0]&&t[2].length>=r.length&&!t[3].trim()}function Te(r,e){let t=0,i=r.length;for(;t<i;){let s=t+i>>>1;r[s][1]<=e?t=s+1:i=s}return t<r.length&&e>=r[t][0]}var To,hd,Oo,md,Oe,fd,No,gd,bd,ti=_(()=>{To=/^( *)(`{3,}|~{3,})(.*)$/u,hd=/^ {0,3}(?:#{1,6}(?:[ \t]|$)|>|([-*_])(?:[ \t]*\1){2,}[ \t]*$)/u,Oo=/^ {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*$/u,md=/^ {0,3}(?:=+|-+)[ \t]*$/u,Oe=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u,fd=/^ *(?:[-*+]|\d{1,9}[.)])[ \t]*$/u,No=/^\s*$/u,gd=[[/^<(script|pre|textarea|style)(?:\s|>|$)/iu,/<\/(?:script|pre|textarea|style)>/iu,r=>`</${r[1].toLowerCase()}>`],[/^<!--/u,/-->/u,"-->"],[/^<\?/u,/\?>/u,"?>"],[/^<![A-Za-z]/u,/>/u,"<!-- -->"],[/^<!\[CDATA\[/u,/\]\]>/u,"]]>"],[/^<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|search|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/iu,No,null]],bd=/^(?:<[A-Za-z][\dA-Za-z-]*(?:\s+[:A-Z_a-z][\w.:-]*(?:\s*=\s*(?:[^\s"'<=>`]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][\dA-Za-z-]*\s*>)\s*$/u});function Z(r){return String(r??"").replaceAll(/\r\n?/gu,`
|
|
5
5
|
`)}function Ke(r){return/^[0-9a-f]{7,64}$/iu.test(r)}function Do(r,e){let t=pe(r);return[...r.matchAll(e)].filter(i=>!Te(t,i.index))}function Ze(r,e){let t=Do(r,e);return[r.slice(0,t[0]?.index),...t.map((i,s)=>r.slice(i.index+i[0].length,t[s+1]?.index))]}function he(r,e){let t=Do(r,e);return{head:r.slice(0,t[0]?.index),subs:t.map((i,s)=>({heading:i[1],body:r.slice(i.index+i[0].length+1,t[s+1]?.index)}))}}function me(r,e){return he(r,e).subs}function Je(r){let e=r.indexOf(`
|
|
6
6
|
`);return e===-1?{title:r.trim(),body:""}:{title:r.slice(0,e).trim(),body:r.slice(e+1)}}function gt(r){let e=r.split(`
|
|
7
|
-
`).map(i=>i.trim()).filter(i=>i.startsWith("|")&&!(/^[\s:|-]+$/u.test(i)&&i.includes("-"))).map(i=>i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(s=>s.trim()));if(e.length<2)return[];let t=e[0].map(i=>i.toLowerCase());return e.slice(1).filter(i=>i.length!==t.length||i.some((s,o)=>s.toLowerCase()!==t[o])).map(i=>Object.fromEntries(t.flatMap((s,o)=>s?[[s,i[o]??""]]:[])))}function jo(r){let e=Object.create(null),t=Object.create(null),i=[],s=null,o="",n=[],a="",l=(p,
|
|
8
|
-
`)),s=null,o="",n=[]},
|
|
9
|
-
`)){let
|
|
10
|
-
`).trim()}}function Uo(r){let e=(r||"").trim(),t="",i=Ye(e);i&&(e=i.label.trim(),t=i.url.trim());let s=/#L(\d+)/u.exec(t)?.[1]??"",a=[...e.matchAll(/`([^`]+)`/gu)].map(
|
|
11
|
-
`?l:o[l+1];let n=new Map,a=[];for(let l=0;l<e;l++){let d=r[l];Fo(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
|
|
7
|
+
`).map(i=>i.trim()).filter(i=>i.startsWith("|")&&!(/^[\s:|-]+$/u.test(i)&&i.includes("-"))).map(i=>i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(s=>s.trim()));if(e.length<2)return[];let t=e[0].map(i=>i.toLowerCase());return e.slice(1).filter(i=>i.length!==t.length||i.some((s,o)=>s.toLowerCase()!==t[o])).map(i=>Object.fromEntries(t.flatMap((s,o)=>s?[[s,i[o]??""]]:[])))}function jo(r){let e=Object.create(null),t=Object.create(null),i=[],s=null,o="",n=[],a="",l=(p,u,f)=>{!p||p in e||(e[p]=f.trim(),t[p]=u)},d=()=>{s&&l(s,o,n.join(`
|
|
8
|
+
`)),s=null,o="",n=[]},m=p=>{(s?n:i).push(p)};for(let p of r.split(`
|
|
9
|
+
`)){let u=/^ {0,3}(```|~~~)/u.exec(p),f=u!==null&&(!a||u[1]===a);if(f&&(a=a?"":u[1]),f||a){m(p);continue}if(!p.trim()){s?d():i.push(p);continue}let b=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(b){d();let v=b[1].trim(),y=b[2],g;for(;(g=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(y))!==null;)l(v.toLowerCase(),v,y.slice(0,g.index)),v=g[1].trim(),y=y.slice(g.index+g[0].length);s=v.toLowerCase(),o=v,n=[y];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){d();continue}m(p)}return d(),{fields:e,labels:t,prose:i.join(`
|
|
10
|
+
`).trim()}}function Uo(r){let e=(r||"").trim(),t="",i=Ye(e);i&&(e=i.label.trim(),t=i.url.trim());let s=/#L(\d+)/u.exec(t)?.[1]??"",a=[...e.matchAll(/`([^`]+)`/gu)].map(m=>m[1].trim()).find(m=>!m.includes("(")&&(m.includes("/")||/\.\w/u.test(m)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),l=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(a);l&&(a=l[1],s||(s=l[2]));let d=ri.exec(a);return d?(s||(s=d[2]),{file:d[1],line:s,locationLink:t}):{file:a,line:s||"?",locationLink:t}}function ii(r){return r.replaceAll("**","")}function Ye(r){let e=String(r??""),t=yd(e,_d(e)),i=wd(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=xd(e,n+1,i);if(a!==null)return{label:e.slice(o+1,n),url:a,index:o}}}return null}function yd(r,e){let t=new Map,i=[];for(let s=0;s<r.length;s++){let o=r[s];Fo(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 _d(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 wd(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]===`
|
|
11
|
+
`?l:o[l+1];let n=new Map,a=[];for(let l=0;l<e;l++){let d=r[l];Fo(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 xd(r,e,t){let i=$d(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 $d(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)}function Fo(r,e){return r[e]==="\\"&&Sd.test(r[e+1]??"")}function Ho(r){return typeof r=="string"?r.replace(kd,"$1"):r}function qo(r){let e=/^\[(.+)\]$/u.exec(r.trim());return e?e[1].trim():r.trim()}function Ne(r){let e=(r||"").trim();return/^[-–—]+$/u.test(e)?"":e}var Kt,ft,ue,Bo,ri,kd,Sd,J=_(()=>{ti();ti();Kt=/^## +(.*)$/gmu,ft=/^### +(.*)$/gmu,ue=/^#### +(.*)$/gmu,Bo=/^##### +(.*)$/gmu,ri=/^(.+):(\d+(?:-\d+)?)$/u;kd=/\\([!-/:-@[-`{-~])/gu,Sd=/[!-/:-@[-`{-~]/u});function Vo(r){return typeof r=="string"&&r.trim().toLowerCase()==="informative"?"informational":r}function H(r,e=r.severity){let t=Vo(r.severity);return t!==r.severity&&(!r.id&&!r._idBasis&&(r._idBasis=Gt({...r,severity:e})),r.severity=t),r.correctedSeverity!==void 0&&(r.correctedSeverity=Vo(r.correctedSeverity)),r}var Zt,fe=_(()=>{Qr();Zt=new Map([["CRITICAL","critical"],["HIGH","high"],["MEDIUM","medium"],["LOW","low"],["INFO","informational"],["INFORMATIONAL","informational"],["INFORMATIVE","informative"]])});function Ed(r){if(r!==void 0)return Go.get(Ko(r))??Go.get("medium")}function Zo(r){let t=Z(r).trim().split(Cd);if(t.length===1)return null;let i=[];for(let s=1;s<t.length;s+=2){let o=Rd.get(t[s].toUpperCase())??"medium";for(let n of Ze(t[s+1],/^### /gmu).slice(1)){let a=Wo(n,o);if(!a)continue;let l=n.indexOf(`
|
|
12
12
|
### `);l!==-1&&(a._idBasis=Gt(Wo(n.slice(0,l+1),o))),i.push(a)}}return i.length===0?null:{type:"security",source:"deepsec",findings:i}}function Wo(r,e){let{title:t,body:i}=Je(r);if(!t)return null;let s=i.replace(/\n---\s*$/u,"").trim(),o=Object.fromEntries([...s.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu)].map(y=>[y[1].trim().toLowerCase(),y[2].trim()])),n=/^\*\*Recommendation:\*\*\s*/mu.exec(s),a=n?s.slice(0,n.index):s,l=n?s.slice(n.index+n[0].length).trim():"",d=a.split(`
|
|
13
13
|
`).filter(y=>!/^\s*- \*\*/u.test(y)).join(`
|
|
14
|
-
`).replaceAll("**","").trim(),
|
|
14
|
+
`).replaceAll("**","").trim(),m=[t,d].filter(Boolean).join(`
|
|
15
15
|
|
|
16
|
-
`),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),
|
|
17
|
-
`).find(e=>e.trim())?.trim()??"":""}function li(r){let e=[];for(let t of Ze(r||"",/\n{2,}/gu)){if(!t.trim())continue;let i=
|
|
16
|
+
`),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),u=(o.lines||"").split(",").map(y=>y.trim()).find(Boolean)||"?",f={file:p,line:u,severity:e,description:m};l&&(f.recommendation=l.replaceAll("**",""));let b=Ed(o.confidence);b!==void 0&&(f.confidence=b);let v=Ad.get(Ko(o.revalidation));return v&&(f.revalidate=v,f.revalidateSource="deepsec",o.reasoning&&(f.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(f.slug=o.slug),H(f,e==="informative"?"medium":e)}var Cd,Rd,Ko,Go,Ad,Jo=_(()=>{Qr();J();fe();Cd=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu,Rd=new Map([...Zt,["HIGH_BUG","high_bug"],["BUG","bug"]]),Ko=r=>String(r??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),Go=new Map([["high",8],["medium",6],["low",4]]);Ad=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]])});var Yo,Jt,si=_(()=>{Yo={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"},Jt={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium","markdown-generic":"Markdown (generic)"}});function Xo(r){return Id.has(r?.revalidate)?r.revalidate:""}function ni(r,e=r?.source){return Object.hasOwn(Jt,e)||Xo(r)==="revalidation"}function Xt(r,e){if(!r)return r;let t=r;e?.exportsMode==="isolate"&&(t=t.replace(/^\((?:[^()]|\([^()]*\))*\): \[export:\s*\w+\] /u,""),t=t.replace(/^\[export:\s*\w+\] /u,""));let i=[e?.exportName,e?.methodName].filter(Boolean).map(s=>s.replaceAll(/[.*+?^${}()|[\]\\]/gu,"\\$&"));for(let s of i)t=t.replaceAll(new RegExp(`\\[export:\\s*${s}\\]\\s*`,"gu"),"");for(let s of i)t=t.replace(new RegExp(`^\\(\`?${s}\`?\\): `,"u"),"");return t}function ai(r){return r?r.split(`
|
|
17
|
+
`).find(e=>e.trim())?.trim()??"":""}function li(r){let e=[];for(let t of Ze(r||"",/\n{2,}/gu)){if(!t.trim())continue;let i=Md.exec(t);if(i){e.push({label:i[1].trim(),body:t.slice(i[0].length).trim()});continue}let s=e.at(-1);s&&s.label===null?s.body+=`
|
|
18
18
|
|
|
19
|
-
${t}`:e.push({label:null,body:t})}return e}function bt(r){return Number.isFinite(parseInt(r?.line,10))?`${r.file}:${r.line}`:r?.file??""}var oi,Yt,
|
|
19
|
+
${t}`:e.push({label:null,body:t})}return e}function bt(r){return Number.isFinite(parseInt(r?.line,10))?`${r.file}:${r.line}`:r?.file??""}var oi,Yt,Id,Md,vt=_(()=>{J();si();oi=["critical","high","medium","low","high_bug","bug","informational"],Yt=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Id=new Set(Yt);Md=/^\*\*([^*\n]+):\*\*[ \t]*/u});function ci(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 Ld(r,e){let t=pe(r),i=0;return r.split(`
|
|
20
20
|
`).map(s=>{let o=i;return i+=s.length+1,Te(t,o)?s:e(s)}).join(`
|
|
21
|
-
`)}function Pe(r){return
|
|
22
|
-
`),t=0,i=()=>{for(;t<e.length&&!e[t].trim();)t++},s=()=>{let a=[];for(let l;(l=
|
|
21
|
+
`)}function Pe(r){return Ld(String(r??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var di=_(()=>{J()});function pi(r){return Od.test(r)}function Xe(r){let e=r?.repo?.github;if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/u,"");if(!t)return null;let i=zd.exec(t),s=(i?`${i[1]}/${i[2]}`:t).replace(/\.git$/u,"");return pi(s)?s:null}var zd,Od,ui=_(()=>{zd=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/iu,Od=/^[\w.-]+\/[\w.-]+$/u});var Qo,en,tn,rn=_(()=>{Qo=[["Impact","impact",!1],["Reproduction","reproduction",!1],["Recommendation","recommendation",!1],["Confidence reasoning","confidenceReason",!1],["Revalidation verdict","revalidateVerdict",!0],["Revalidation recommendation","revalidateRecommendation",!0]],en=[["Status","status"],["Branch","branch"],["Date created","dateCreated"],["Detected at","detectedAt"],["Committed at","committedAt"],["PoC status","pocStatus"],["Variant of","parent"],["Slug","slug"],["Priority","priority"]],tn=[["Detailed report","reportPath"],["Commit audited","auditedCommit"],["ID","id"]]});function Be(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 er(r){let e=Ye(String(r??""));return e?.index===0?{label:e.label,url:e.url}:null}function nn(r){let e=/^<(https?:[^>\s]*)>$/u.exec(r.trim());return e?e[1]:null}function an(r){let e=ri.exec(r);return e?{file:e[1],line:e[2]}:{file:r,line:"?"}}function Nd(r){let e=r.indexOf(".");return e>0?{exportName:r.slice(0,e),methodName:r.slice(e+1)}:{exportName:r}}function Qt(r){let e=String(r??"").trim();return Td.get(e.toLowerCase())??e}function Pd(r){let e={},t=r.trim(),i=/ · (`+)(.+?)\1$/u.exec(t);i&&(Object.assign(e,Nd(Be(i[0]))),t=t.slice(0,i.index));let s=er(t),o=Be(s?s.label:t);return o!==null&&Object.assign(e,an(o)),s&&ci(s.url)&&(e.location=s.url),e}function Dd(r){let e={},t=r.trim();t.endsWith(sn)&&(e.critical=!0,t=t.slice(0,-sn.length));let i=t.indexOf(Bd);i!==-1&&(t=t.slice(0,i));let s=/^(.*?) — corrected (from|to) (.*)$/u.exec(t);return s?[e.severity,e.correctedSeverity]=(s[2]==="from"?[s[3],s[1]]:[s[1],s[3]]).map(Qt):e.severity=Qt(t),e}function Fd(r){return/\d/u.test(r)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(r)}function tr(r){let e=r.trim(),t=on.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":Ud.has(o)&&!i.exportsMode?i.exportsMode=o:jd.has(o)&&!i.effort?i.effort=o:s.push(o);return s.length>1?[i.type,i.model]=s:s.length===1&&(i[Fd(s[0])?"model":"type"]=s[0]),{run:i}}function hi(r){let e=r.trim(),t=er(e);return t?t.label.trim():nn(e)??e}function Hd(r){let e=er(r.trim());if(e){let t=e.url.split("/").at(-1)??"";return Ke(t)?t:Be(e.label)??t}return Be(r)??r.trim()}function qd(r){let e=Be(r)??r.trim(),t=e.lastIndexOf("@");return{npm:t>0?{name:e.slice(0,t),version:e.slice(t+1)}:{name:e}}}function Vd(r){let e=r.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":Yt.includes(e)?e:void 0}function ln(r,e,t){let i=Gd.get(e.trim().toLowerCase());i&&i(r,t.trim())}function cn(r){let e=r.split(`
|
|
22
|
+
`),t=0,i=()=>{for(;t<e.length&&!e[t].trim();)t++},s=()=>{let a=[];for(let l;(l=Wd.exec(e[t]??""))!==null;t++)a.push([l[1].trim(),l[2].trim()]);return a};i();let o=s();if(o.length>0)return{title:"",facts:o,rest:e.slice(t).join(`
|
|
23
23
|
`)};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:Pe(n.join(`
|
|
24
24
|
`).trim()),facts:o,rest:e.slice(t).join(`
|
|
25
25
|
`)}}function dn(r){let e=[],t=pe(r),i=0;for(let s of r.split(`
|
|
26
|
-
`)){let o=Te(t,i)?null:
|
|
27
|
-
`).trim());return l&&(i.text=l),i}function un(r){let e=r.length,t=1/0;for(let i=r.length-1;i>=0;i--){let s=
|
|
26
|
+
`)){let o=Te(t,i)?null:Kd.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=>Zd(s))}function Zd({ref:r,indent:e,note:t}){let i={},s=er(r),o=nn(r),n=o===null?Be(s?s.label:r):null;n!==null&&Object.assign(i,an(n));let a=s?s.url:o;ci(a)&&(i.url=a);let l=Pe(t.map(d=>d.slice(Math.min(e,/^ */u.exec(d)[0].length))).join(`
|
|
27
|
+
`).trim());return l&&(i.text=l),i}function un(r){let e=r.length,t=1/0;for(let i=r.length-1;i>=0;i--){let s=Jd.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=>[pn.get(i.label.toLowerCase()),i.body])}}function hn(r,e,t){let i=[],s=ai(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(`
|
|
28
28
|
|
|
29
|
-
`)}var
|
|
30
|
-
`).map(e=>e.trim()).filter(Boolean))].map(e=>{O(/^https?:\/\/[^\s()[\]{}"'<>`\\]+$/iu.test(e)&&!/[.,;!?]$/u.test(e),"link syntax; use bare URLs on separate lines");let t;try{t=new URL(e)}catch{O(!1,"URL")}let[i,s,o,n,...a]=t.pathname.slice(1).split("/");O(["github.com","www.github.com"].includes(t.hostname)&&!t.username&&!t.password&&!t.port&&[i,s].every(p=>p&&/^[\w-][\w.-]*$/u.test(p)),"repository URL"),O(a.every(Boolean),"repository path; empty components");let l=`${i}/${s.replace(/\.git$/iu,"")}`.toLowerCase(),d=/^#L(\d+)(?:-L?(\d+))?$/u.exec(t.hash),
|
|
31
|
-
`),n=new Set(Qe(o[0]).map(
|
|
29
|
+
`)}var Td,on,sn,Bd,jd,Ud,Gd,Wd,Kd,pn,Jd,mn=_(()=>{vt();si();J();di();rn();Td=new Map(Object.entries(Yo).map(([r,e])=>[e.toLowerCase(),r])),on=new Map(Object.entries(Jt).map(([r,e])=>[e.toLowerCase(),r]));sn=" \xB7 flagged critical by the analyzer",Bd=" (varies across reports \u2014 ";jd=new Set(["max","xhigh","high","medium","low","minimal"]),Ud=new Set(["list","isolate"]);Gd=new Map([...[["Category","category"],...en].map(([r,e])=>[r.toLowerCase(),(t,i)=>{t[e]=i}]),...[...tn,["Found while analyzing","discoveredIn"]].map(([r,e])=>[r.toLowerCase(),(t,i)=>{t[e]=Be(i)??i}]),["location",(r,e)=>Object.assign(r,Pd(e))],["severity",(r,e)=>Object.assign(r,Dd(e))],["confidence",(r,e)=>{let t=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);t&&(r.confidence=Number(t[1]))}],["revalidation",(r,e)=>{let t=Vd(e);t&&(r.revalidate=t)}],["revalidated by",(r,e)=>{let t=e.trim();t&&(r.revalidateSource=on.get(t.toLowerCase())??t)}],["repository",(r,e)=>{r.repo={github:hi(e)}}],["introduced in",(r,e)=>{r.commitHash=Hd(e)}],["package",(r,e)=>{r.package=qd(e)}],["priority",(r,e)=>{r.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}]]);Wd=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;Kd=/^(\d+)\. (.*)$/u;pn=new Map(Qo.map(([r,e])=>[r.toLowerCase(),e])),Jd=[...pn.keys()]});function gn(r){let e=Z(r).trim();if(!Yd.test(e))return null;let{head:t,subs:i}=he(e,Kt),s=[];for(let{heading:o,body:n}of i){if(o.trim().toLowerCase()==="summary")continue;let a=tp(o);for(let l of me(n,ft))s.push(ip(l,a))}return op(rp(t),s)}function tp(r){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(r.trim());return Qt(e?e[1]:r)}function rp(r){let e=new Map;for(let t of r.matchAll(Qd)){let i=t[1].trim().toLowerCase();e.has(i)||e.set(i,t[2].trim())}return{sources:(e.get("source")??"").split(",").map(t=>tr(t).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(t=>t.trim()).filter(Boolean),repo:e.has("repository")?hi(e.get("repository")):""}}function ip({heading:r,body:e},t){let i=r.trim().replace(/^\d+\.\s+/u,""),s=me(e,ue).filter(o=>Xd.test(o.heading.trim()));return s.length===0?[fn(e,ue,i,t)]:s.map(o=>fn(o.body,Bo,i,t))}function fn(r,e,t,i){let{title:s,facts:o,rest:n}=cn(r),{head:a,subs:l}=he(n,e),d=l.map(C=>({label:C.heading.trim(),body:C.body.trim()})),m={file:"unknown",line:"?"},p=null;for(let[C,L]of o)C.trim().toLowerCase()==="analyzer"?p=tr(L):ln(m,C,L);m.severity||(m.severity=i||"medium");let u=s||t,f=u!=="Untitled finding"&&u!==bt(m),b=d.filter(C=>!ep.has(C.label.toLowerCase())).map(C=>({label:C.label,body:Pe(C.body)})),{paragraphs:v,fields:y}=un(b);m.description=hn(f?u:"",Pe(a.trim()),v);let g=d.filter(C=>C.label.toLowerCase()==="evidence").flatMap(C=>dn(C.body));g.length>0&&(m.evidence=g);for(let[C,L]of y)m[C]=L;let k=d.find(C=>C.label.toLowerCase()==="severity correction");return k?.body&&(m.correctedSeverityReason=Pe(k.body)),{finding:H(m),analyzer:p}}function sp(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?tr(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 op(r,e){let t=e.flat(),{source:i,run:s}=sp(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(m=>m.finding));return l.every(d=>d.length===1)?o.findings=l.flat():o.groups=l,o}var Yd,Xd,Qd,ep,bn=_(()=>{vt();J();mn();di();fe();Yd=/^<!--\s*DeepView findings export\b[^>]*-->/u,Xd=/^Case \d+ of \d+(?:\s|$)/u,Qd=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,ep=new Set(["evidence","severity correction","comment"])});function O(r,e){if(!r)throw new Error(`Markdown (generic): unsupported ${e}`)}function cp(r){return[...new Set(r.split(`
|
|
30
|
+
`).map(e=>e.trim()).filter(Boolean))].map(e=>{O(/^https?:\/\/[^\s()[\]{}"'<>`\\]+$/iu.test(e)&&!/[.,;!?]$/u.test(e),"link syntax; use bare URLs on separate lines");let t;try{t=new URL(e)}catch{O(!1,"URL")}let[i,s,o,n,...a]=t.pathname.slice(1).split("/");O(["github.com","www.github.com"].includes(t.hostname)&&!t.username&&!t.password&&!t.port&&[i,s].every(p=>p&&/^[\w-][\w.-]*$/u.test(p)),"repository URL"),O(a.every(Boolean),"repository path; empty components");let l=`${i}/${s.replace(/\.git$/iu,"")}`.toLowerCase(),d=/^#L(\d+)(?:-L?(\d+))?$/u.exec(t.hash),m=o==="blob"?a.slice(0,-1):o==="tree"?a:[];try{m=m.map(decodeURIComponent)}catch{O(!1,"repository directory encoding")}return O(m.every(p=>p===p.trim()&&!/[\\/:?#\p{Cc}]/u.test(p)),"repository directory"),{repo:l,ref:n,directory:m,...o==="blob"&&a.length&&{evidence:{file:a.join("/"),line:d?d.slice(1).filter(Boolean).join("-"):"?",url:e}}}})}function dp(r,e,t,i){let s=cp(t),o=s[0]?.repo;O(o&&s.every(l=>l.repo===o),`repository set for finding ${r.id}; expected exactly one repository`),O(!r.group.github||r.group.github===o,`repository set for product ${r.product}; expected exactly one repository`);let n=i.get(o);O(n===void 0||n===r.prefix,`repository ID prefixes for ${o}; expected ${n}, got ${r.prefix} (${r.id})`),i.set(o,r.prefix),r.group.github=o,r.group.directories.push(...s.map(l=>l.directory));let a=s.flatMap(l=>l.evidence??[]);if(a.length){Object.assign(e,{file:a[0].file,line:a[0].line,location:a[0].url,evidence:a});let l=s.find(d=>d.evidence).ref;Ke(l)&&(e.commitHash=l)}}function pp(r){let e=r[0];for(let t of r.slice(1)){let i=0;for(;i<e.length&&e[i]===t[i];)i++;e=e.slice(0,i)}return e.join("/")}function rr(r){let e=Z(r).trim(),t=[...e.matchAll(/^## +(.*)$/gmu)];if(!t.some(m=>/^\d+\.\s+\S+/u.test(m[1]))&&(t.length||e.startsWith("# ")))return null;let i=[...e.matchAll(/^\|[^\n]*\|$/gmu)].find(([m])=>Qe(m).map(p=>p.toLowerCase()).join()===np.join());if(!i)return null;let s=e.slice(0,i.index).trim();O(!s||/^# [^\n]+$/u.test(s),"summary preamble"),O(i.index<(t[0]?.index??e.length),"summary position");let o=e.slice(i.index,t[0]?.index).trim().split(`
|
|
31
|
+
`),n=new Set(Qe(o[0]).map(m=>m.toLowerCase()));O(o[1]&&Qe(o[1]).length===5&&Qe(o[1]).every(m=>/^:?-{3,}:?$/u.test(m)),"summary separator");let a=new Map,l=new Map,d=new Map;for(let m of o.slice(2).filter(p=>p.trim())){O(/^\|.*\|$/u.test(m)&&Qe(m).length===5,"summary row");let[p,u,f,b]=Qe(m),v=/^(.+-)\d+$/u.exec(u)?.[1];O(/^\d+$/u.test(p)&&v&&f&&Object.hasOwn(vn,b)&&!d.has(u),`summary values for ${u}`);let y=a.get(f)??{directories:[],rows:[]},g={raw:m,id:u,prefix:v,product:f,priority:b,group:y};d.set(u,g),y.rows.push(g),a.set(f,y)}O(d.size,"empty summary");for(let[m,p]of t.entries()){let u=/^\d+\.\s+(\S+)\s*$/u.exec(p[1])?.[1],f=d.get(u);O(f&&!f.finding,`finding section ${p[1]}`);let b=e.slice(p.index,t[m+1]?.index),v=b.slice(p[0].length+1),y=new Map,g=[...v.matchAll(lp)];for(let[I,R]of g.entries()){let M=R[1],K=M.toLowerCase().replace(/^steps to reproduce\b.*$/u,"steps to reproduce");O(!y.has(K),`duplicate section ${M}`),y.set(K,{heading:M,body:v.slice(R.index+R[0].length,g[I+1]?.index).trim()})}O(ap.every(I=>y.has(I)),`missing required headers for ${u}`),O(!v.slice(0,g[0].index).trim(),`text before field headers for ${u}`);let k=y.get("title")?.body;O(k,`missing Title for ${u}`);let C={sourceId:u,_idBasis:{source:mi,row:f.raw.trim(),section:b.trim()},product:f.product,priority:f.priority,severity:vn[f.priority],file:"unknown",line:"?"};n.has("vulnerability")&&(C.security=!0);let L=[k];for(let[I,R]of y)I==="title"||I==="code references"||(I==="steps to reproduce"?C.reproduction=R.body:I==="patch"?C.recommendation=R.body:L.push(I==="description"?R.body:`**${R.heading}:**
|
|
32
32
|
${R.body}`));C.description=L.join(`
|
|
33
33
|
|
|
34
|
-
`),
|
|
35
|
-
`),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}=
|
|
36
|
-
`),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
|
|
34
|
+
`),dp(f,C,y.get("code references").body,l),f.finding=C}return O([...d.values()].every(m=>m.finding),"missing finding sections"),[...a].map(([m,p])=>{let u={github:p.github,directory:pp(p.directories)},f=p.rows.map(({finding:b})=>({...b,repo:{github:p.github}}));return{displayName:m,data:{type:"security",source:mi,product:m,repo:u,findings:f}}})}function yn(r){let e=rr(r);return e===null?null:e.length===1?e[0].data:{type:"security",source:mi,findings:e.flatMap(({data:t})=>t.findings)}}var mi,np,ap,lp,vn,Qe,fi=_(()=>{J();mi="markdown-generic",np=["#","id","product","priority","vulnerability"],ap=["title","description","root cause","code references","attack scenario","steps to reproduce","impact","patch"],lp=/^(?:#{3,6}[ \t]+)?(?:\*\*)?(Title|Description|Root Cause|Code references|Attack Scenario|Steps to Reproduce(?:[ \t]+.*?)?|Impact|Patch):?(?:\*\*)?(?:[ \t]+#+)?[ \t]*$/gimu,vn={P0:"critical",P1:"high",P2:"medium",P3:"low",P4:"informational"},Qe=r=>r.trim().slice(1,-1).split("|").map(e=>e.trim())});function _n(r){let e=hp(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 hp(r){let e=r.indexOf(`
|
|
35
|
+
`),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}=mp(i),n=fp(s),a=gp(o),{file:l,line:d,locationLink:m}=bp(n.location||""),p=(a.severity||"").toLowerCase();return{severity:up.has(p)?p:"medium",description:vp(t,n),location:m,file:l||"unknown",line:d}}function mp(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 fp(r){let e={},t=r.split(/^## /mu);for(let i=1;i<t.length;i++){let s=t[i],o=s.indexOf(`
|
|
36
|
+
`),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 gp(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function bp(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 vp(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"]}`),yp(t.join(`
|
|
37
37
|
|
|
38
|
-
`))}function
|
|
39
|
-
# `),y=
|
|
40
|
-
`),t=e.findIndex(a=>a.trim());if(t===-1||!Oe.test(e[t])||e.some((a,l)=>l!==t&&Oe.test(a)))return r;let i=e[t].replace(/^ */u,""),s=i.replace(Oe,"");if(!s.trim())return r;let o=xn(s)??xn(i);if(o===null&&(Oe.test(s)||
|
|
41
|
-
`)}function xn(r){let e=[...r.matchAll(
|
|
38
|
+
`))}function yp(r){return r.replaceAll("**","")}var up,wn=_(()=>{up=new Set(["critical","high","medium","low","high_bug","bug","informational"])});function kn(r){let e=Z(r).trim();if(!e.startsWith("# "))return null;let i=Ze(e,/^# /gmu).slice(1).filter(s=>s.trim().length>0).map(s=>wp(s)).filter(Boolean);return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function wp(r){let{title:e,body:t}=Je(r);if(!e)return null;let{sectionsText:i,metaText:s}=xp(t),o=$p(i),n=Object.fromEntries([...s.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu)].map(g=>[g[1].trim().toLowerCase(),g[2].trim()])),a=Rp(o.evidence||""),{file:l,line:d,locationLink:m}=Sn(o.location||a[0]?.ref||""),p=(n.severity||"").toLowerCase(),u=_p.has(p)?p:"medium",f=Ap(e,o,a.length>0),b={file:l||"unknown",line:d,severity:u,description:f};m&&(b.location=m),a.length>0&&(b.evidence=a.map(Ep)),o["reproduction steps"]&&(b.reproduction=kp(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 v=r.indexOf(`
|
|
39
|
+
# `),y=_n(v===-1?r:r.slice(0,v+1));return y&&(b._idBasis=y),H(b)}function xp(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 $p(r){let e=r.split(/^## /mu).slice(1).map(t=>Je(t));return Object.fromEntries(e.filter(t=>t.title).map(t=>[t.title.toLowerCase(),t.body.trim()]))}function Sn(r){let e="",t="?",i="",s=Ye(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=Ho(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 kp(r){let e=r.split(`
|
|
40
|
+
`),t=e.findIndex(a=>a.trim());if(t===-1||!Oe.test(e[t])||e.some((a,l)=>l!==t&&Oe.test(a)))return r;let i=e[t].replace(/^ */u,""),s=i.replace(Oe,"");if(!s.trim())return r;let o=xn(s)??xn(i);if(o===null&&(Oe.test(s)||Cp.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(`
|
|
41
|
+
`)}function xn(r){let e=[...r.matchAll(Sp)];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}function Rp(r){let e=[];for(let t of r.split(`
|
|
42
42
|
`))$n.test(t)?e.push({ref:t.replace($n,"").trim(),note:[]}):e.length>0&&t.trim()&&e.at(-1).note.push(t.trim());if(e.length===0){let t=r.split(`
|
|
43
|
-
`).map(o=>o.trim()).filter(Boolean),i=t.findIndex(o=>Ye(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
|
|
44
|
-
`);return a&&(n.text=a),n}function
|
|
43
|
+
`).map(o=>o.trim()).filter(Boolean),i=t.findIndex(o=>Ye(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 Ep({ref:r,note:e}){let{file:t,line:i,locationLink:s,linked:o}=Sn(r),n={file:t||"unknown",line:i};s&&o&&(n.url=s);let a=e.join(`
|
|
44
|
+
`);return a&&(n.text=a),n}function Ap(r,e,t){let i=[r];return e.details&&i.push(e.details),e.evidence&&!t&&i.push(`**Evidence:**
|
|
45
45
|
${e.evidence}`),e.impact&&i.push(`**Impact:** ${e.impact}`),i.join(`
|
|
46
46
|
|
|
47
|
-
`)}var
|
|
48
|
-
`)){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=bi(n),l=a?.link??"";if(a)n=a.text;else{let y=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(n);y&&(n=y[2]?`${y[1].trim()} ${y[2].trim()}`:y[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(n))continue;let d=vi(n),
|
|
47
|
+
`)}var _p,Sp,Cp,$n,Cn=_(()=>{wn();fe();vt();J();_p=new Set([...oi,"informative"]);Sp=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,Cp=/^\d{1,9}\)(?=[ \t]|$)/u;$n=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u});function Ip(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 m=/^(.+):(\d+(?:-\d+)?)$/u.exec(l);return m?(s||(s=m[2]),{file:m[1],line:s,locationLink:t}):{file:l,line:s||"?",locationLink:t}}function Rn({severity:r,description:e,ref:t,lineBullet:i="",id:s=""}){let o=Ip(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 En=_(()=>{});function ge(r){let e=((r||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"");return Zt.get(e.toUpperCase())??""}function yt(...r){return{severity:r.find(Boolean)||"medium",identitySeverity:r.find(e=>e&&e!=="informative")||"medium"}}function _t(r){let e=/^([CHML])-?\d+$/iu.exec((r||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function gi(r){return ge(/^(critical|high|medium|low|informational|informative|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((r||"").trim())?.[1])}function An(r){return ge(/^(critical|high|medium|low|informational|informative|info)\b/iu.exec((r||"").trim())?.[1])}function sr(r){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((r||"").trim())}function or(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 ir(r){return(r||"").replaceAll("-"," ")}function wt(r){let e=(r||"").trim(),t=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return qo(t?t[1]:e).toUpperCase()}function bi(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 vi(r){let e=r.search(/\s/u),t=(e===-1?r:r.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=or(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 yi(r){let{text:e,link:t}=bi(r)??{text:r,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=or(i[1].trim());return o?{id:o.id,title:i[2].trim()||ir(o.slug)||o.id,link:t}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:t}}let s=vi(e);return s?{id:s.id,title:s.rest||ir(s.slug)||s.id,link:t}:{id:"",title:e.trim(),link:t}}function In(r){let e={},t=o=>{let n=o.exec(r||"")?.[1];return n===void 0?"":(/`([^`]+)`/u.exec(n)?.[1]??n.split(/\s+/u)[0]??"").trim()},i=t(/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu);pi(i)&&(e.repo=i);let s=t(/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu);return Ke(s)&&(e.commitHash=s),e}var _i,wi=_(()=>{J();ui();fe();_i=["key code reference","key code","code reference","location","affected file","file","path"]});function nr(r){return{id:wt(r.id||""),title:Ne(r.title),severity:Ne(r.severity),pocStatus:Ne(r["poc status"]||r.poc),status:Ne(r.status),parent:wt(Ne(r.parent||"")),location:Ne(r.location)}}function ar(r,e=""){let{severity:t,identitySeverity:i}=yt(ge(r.severity),e,_t(r.id)),s=xi({ref:r.location||"",id:r.id,severity:t,identitySeverity:i,description:ii(r.title||r.id)});for(let o of["pocStatus","status","parent"])r[o]&&(s[o]=r[o]);return H(s)}function xi({ref:r,lineBullet:e="",id:t,severity:i,identitySeverity:s,description:o}){let{file:n,line:a,locationLink:l}=Uo(r),d={file:n||"unknown",line:a==="?"&&e?e:a,severity:i,description:o};return l?d.location=l:d.file==="unknown"&&t&&(d.location=`piolium:${t}`),d._idBasis=Rn({severity:s,description:o,ref:r,lineBullet:e,id:t}),d}function $i(r,e,t){let i=[];for(let s of r.split(`
|
|
48
|
+
`)){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=bi(n),l=a?.link??"";if(a)n=a.text;else{let y=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(n);y&&(n=y[2]?`${y[1].trim()} ${y[2].trim()}`:y[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(n))continue;let d=vi(n),m=d?.id??"",p=n;if(d){let y=ir(d.slug);p=y&&d.rest?`${y}
|
|
49
49
|
|
|
50
|
-
${d.rest}`:d.rest||y||d.id}let
|
|
51
|
-
`).filter(
|
|
52
|
-
`).trim(),g=xi({ref:
|
|
53
|
-
${i}`:i)}return e}function
|
|
50
|
+
${d.rest}`:d.rest||y||d.id}let u=t.get(m),{severity:f,identitySeverity:b}=yt(ge(u?.severity),e,_t(m)),v={file:"unknown",line:"?",severity:f,description:ii(p)};m?v.location=`piolium:${m}`:l&&(v.location=l),l.endsWith("report.md")&&(v.reportPath=l);for(let y of["pocStatus","status","parent"])u?.[y]&&(v[y]=u[y]);i.push({id:m,finding:H(v,b)})}return i}function ki(r,e,t,i=""){let s=[];for(let n of gt(r)){let a=nr(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:ar(a,i)}))}if(s.length>0)return s;let o=$i(r,i,e);for(let n of o)t&&!n.finding.parent&&(n.finding.parent=t);return o}var Mn=_(()=>{J();En();fe();wi()});function Ln(r){let{id:e}=yi(r);return!!(e&&or(e))}function zp(r){let e=me(r,ft);return(e.length>0?e:me(r,ue)).some(({heading:i})=>Ln(i))}function zn(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{head:t,subs:i}=he(e,Kt),s=Pp(i),o=new Map(gt(s["summary of findings"]||"").map(nr).filter(u=>u.id).map(u=>[u.id,u])),n=In(t),a=[],l=new Set,d=[],m=({id:u,finding:f})=>{a.push(f),u&&l.add(u)},p=u=>{for(let f of u)m(f)};for(let[u,f]of Object.entries(s)){let b=gi(u);b||Mp.has(u)||u.startsWith("findings by severity")?p(Si(f,b,o,d)):!Lp.test(u)&&zp(f)&&p(Si(f,An(u),o,d))}for(let u of d)(!u.id||!l.has(u.id))&&m(u);for(let u of o.values())l.has(u.id)||m({id:u.id,finding:ar(u)});if(a.length===0)return null;for(let u of a)n.repo&&(u.repo={github:n.repo}),n.commitHash&&!u.auditedCommit&&(u.auditedCommit=n.commitHash);return{type:"security",source:"piolium",findings:a}}function Op(r,e,t,i){let s=[],o="";for(let{heading:n,body:a}of r){let l=gi(n);if(l)s.push(...Si(a,l,e,t)),o="";else if(sr(n))s.push(...Np(a,e,o,t,i));else{let d=Tp(n,a,e,t,i);s.push(...d),o=d[0]?.id||o}}return s}function Tp(r,e,t,i,s){let{head:o,subs:n}=he(e,ue),a=On(r,o,t,s),l=a!==null&&!a.id&&n.some(m=>!sr(m.heading)&&Ln(m.heading)),d=a&&!l?[a]:[];return d.push(...Ci(n,t,i,s,a?.id||"")),d}function Np(r,e,t,i,s){let{head:o,subs:n}=he(r,ue);return i.push(...ki(o,e,t,s)),Ci(n,e,i,s,"")}function Ci(r,e,t,i,s){let o=[],n="";for(let{heading:a,body:l}of r){if(sr(a)){t.push(...ki(l,e,s??n,i));continue}let d=On(a,l,e,i);d&&(o.push(d),n=d.id||n)}return o}function Si(r,e,t,i){let s=me(r,ft);if(s.length>0)return Op(s,t,i,e);let o=Ci(me(r,ue),t,i,e,null);if(o.length>0)return o;let n=gt(r).map(nr).filter(a=>a.id||a.title);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:ar(a,e)});return n.length===0&&i.push(...$i(r,e,t)),[]}function On(r,e,t,i=""){let s=r.trim();if(!s)return null;let{id:o,title:n,link:a}=yi(s),l=t.get(o);if(!o&&n){let I=n.toLowerCase();l=[...t.values()].find(R=>R.title.toLowerCase()===I),o=l?.id??""}let{fields:d,labels:m,prose:p}=jo(e),{severity:u,identitySeverity:f}=yt(ge(d.severity),ge(l?.severity),i,_t(o)),b=/\d+/u.exec(d.line||d.lines||"")?.[0]??"",v=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),y=p.split(`
|
|
51
|
+
`).filter(I=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test(I)&&!/\*\*Variant of:?\*\*/iu.test(I)).join(`
|
|
52
|
+
`).trim(),g=xi({ref:_i.map(I=>d[I]).find(Boolean)??"",lineBullet:b,id:o,severity:u,identitySeverity:f,description:Dp(n||o,d,m,y)}),k=d["poc status"]||d.poc||l?.pocStatus;k&&(g.pocStatus=k);let C=d["detailed report"]||(a.endsWith("report.md")?a:"");C&&(g.reportPath=C),l?.status&&(g.status=l.status);let L=l?.parent||(v?wt(v[1]):"");return L&&(g.parent=L),{id:o,finding:H(g)}}function Pp(r){let e=Object.create(null);for(let{heading:t,body:i}of r){let s=t.trim().toLowerCase();s&&(e[s]=s in e?`${e[s]}
|
|
53
|
+
${i}`:i)}return e}function Dp(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||Bp.has(o)||s.push(`**${t[o]||o}:** ${n}`);return s.filter(Boolean).join(`
|
|
54
54
|
|
|
55
|
-
`)}var Ap,Mp,Np,Tn=w(()=>{J();fe();In();_i();Ap=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]),Mp=/^(?:summary of findings\b|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope\b|table of contents|contents\b|appendix|recommendation|remediation)/u;Np=new Set([...wi,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"])});function be(r){return Array.isArray(r?.findings)?r.findings:Array.isArray(r?.groups)?r.groups:null}function Nn(r){let e;try{let t=JSON.parse(r);if(be(t)){for(let i of Dp(be(t)))H(i);return{data:t,format:"json",reason:null}}return{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(t){e=t}for(let[t,i]of Bp)try{let s=i(r);if(s)return{data:s,format:t,reason:null}}catch(s){if(t!=="markdown-generic")throw s;return{data:null,format:t,reason:s.message}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function Dp(r){return r.flat().filter(e=>e&&typeof e=="object")}var Bp,ve=w(()=>{Jo();bn();fi();Cn();Tn();fe();fi();ui();vt();Bp=[["deepview-md",gn],["markdown-generic",yn],["deepsec",Zo],["piolium",zn],["claude-security",kn]]});function jp(r){E.setSession(r)}function Up(r){return E.setReportCatalog(r)}function Fp(){E.reset()}var Ri,E,ae=w(()=>{"use strict";Ri=class{constructor(e=()=>{}){this.resources=new Map,this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=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,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null}setReportCatalog(e){let t=new Set,i=new Map(e.map(p=>[p.id,JSON.stringify([p.cacheKey??null,p.reports.map(h=>[h.id,h.cacheKey??null,h.visible!==!1]).toSorted(),(p.bundles??[]).map(h=>[h.id,h.filename,h.repoFullName,h.repoDirectory??""]).toSorted()])]));for(let p of new Set([...this.teamCatalog?.keys()??[],...i.keys()]))this.teamCatalog?.get(p)!==i.get(p)&&t.add(`team:${p}`);for(let p of this.resources.keys()){let h="reports:content:team:";if(p.startsWith(h)){let[f]=p.slice(h.length).split(":");(!i.has(f)||this.teamCatalog?.get(f)!==i.get(f))&&this.invalidate([p])}}this.teamCatalog=i;let s=new Map;for(let p of e)for(let h of p.reports){let f=s.get(h.id)??[];f.push(JSON.stringify([p.id,h.cacheKey??null])),s.set(h.id,f)}let o=new Map([...s].map(([p,h])=>[p,JSON.stringify(h.toSorted())])),n=this.reportCatalog;this.reportCatalog=o;let a=new Set(t);for(let p of new Set([...n?.keys()??[],...o.keys()]))n?.get(p)!==o.get(p)&&a.add(p);for(let p of this.resources.keys()){if(!p.startsWith("reports:content:")||p.startsWith("reports:content:team:"))continue;let h=p.slice(16);(!o.has(h)||a.has(h))&&(this.invalidate([p]),a.add(h))}let l=new Map;for(let p of e)for(let h of p.bundles??[]){let f=l.get(h.id)??[];f.push(JSON.stringify([p.id,p.cacheKey??null,h.filename,h.repoFullName,h.repoDirectory??""])),l.set(h.id,f)}let d=!1,u=new Map([...l].map(([p,h])=>[p,JSON.stringify(h.toSorted())]));for(let p of new Set([...this.bundleCatalog?.keys()??[],...u.keys()]))this.bundleCatalog?.get(p)!==u.get(p)&&(d=!0,a.add(`bundle:${p}`),this.invalidate([`bundle-metadata:${p}`]));this.bundleCatalog=u;for(let p of this.resources.keys()){if(!p.startsWith("report-sources:")&&!p.startsWith("finding-history:"))continue;let[,h,f]=p.split(":");(h?t.has(`team:${h}`):d||a.has(f))&&this.invalidate([p])}return a}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=()=>{},retryInvalidated:n=!1}={}){let a=this.generation;for(;;){s?.throwIfAborted();let l=this.resources.get(e);if(l||(l={},this.resources.set(e,l)),l.data!==void 0&&o(l.data),!l.pending){let d=l.controller=new AbortController;l.pending=(async()=>{try{let u=await i(d.signal);return d.signal.throwIfAborted(),l.data=u,u}catch(u){throw!d.signal.aborted&&u?.name!=="AbortError"&&this.notify(`Couldn't refresh ${t}: ${u?.message??u}`),u}})().finally(()=>{l.pending=null})}try{let d=await l.pending;if(s?.throwIfAborted(),this.resources.get(e)!==l)throw new DOMException("Managed data changed","AbortError");return o(d),d}catch(d){if(!n||d?.name!=="AbortError"||s?.aborted||a!==this.generation||this.resources.get(e)===l)throw d}}}},E=new Ri(r=>{document.dispatchEvent(new CustomEvent("managed-notice",{detail:{message:r}}))})});var Y,ye,re,xt=w(()=>{Y={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ye=r=>(...e)=>({_$litDirective$:r,values:e}),re=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 Pn,we,Bn,Dn,et,lr,jn,Un,Fn,Hn,qn,_e=w(()=>{"use strict";Pn="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",we='<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>',Bn='<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>',Dn='<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>',et='<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>',lr='<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>',jn='<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>',Un='<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>',Fn='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" aria-hidden="true"><path d="M1 8h3.5m7 0H15"/><circle cx="8" cy="8" r="3.5"/></svg>',Hn='<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>',qn='<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>'});var Vp,Gn,Kn,Wn,rt,xe,Gp,it,Zn,cr,dr=w(()=>{te();({I:Vp}=Io),Gn=r=>r,Kn=r=>r.strings===void 0,Wn=()=>document.createComment(""),rt=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let o=i.insertBefore(Wn(),s),n=i.insertBefore(Wn(),s);t=new Vp(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=Gn(l).nextSibling;Gn(i).insertBefore(l,s),l=d}}}return t},xe=(r,e,t=r)=>(r._$AI(e,t),r),Gp={},it=(r,e=Gp)=>r._$AH=e,Zn=r=>r._$AH,cr=r=>{r._$AR(),r._$AA.remove()}});function us(r){return typeof r=="string"&&/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(r)?r:null}var hs=w(()=>{"use strict"});var Rr,Jl=w(()=>{te();xt();dr();Rr=ye(class extends re{constructor(){super(...arguments),this.key=m}render(r,e){return this.key=r,e}update(r,[e,t]){return e!==this.key&&(it(r),this.key=e),t}})});var Cs=w(()=>{Jl()});var Oy,Ty,Ny,lc=w(()=>{"use strict";S();Oy=document.querySelector("#drop-zone"),Ty=document.querySelector("#report"),Ny=document.querySelector("app-sidebar")});function Us(r=document){if(r.querySelector(":modal"))return!0;for(let e of r.querySelectorAll("*"))if(e.shadowRoot&&Us(e.shadowRoot))return!0;return!1}var cc=w(()=>{"use strict"});function yh(){return W||(W=document.createElement("div"),W.id="styled-tooltip",W.setAttribute("popover","manual"),document.body.append(W),W)}function wh(r){typeof r.showPopover=="function"&&(r.matches(":popover-open")&&r.hidePopover(),r.showPopover())}function kh(r,{placement:e="cursor"}={}){e=r.dataset.tooltipPlacement??e;let t=yh(),i=r.dataset.tooltip??"",s=r.dataset.tooltipRepo??"",o=us(r.dataset.tooltipCommit),n=["stasis","sourcemap"].includes(r.dataset.tooltipBundle)?r.dataset.tooltipBundle:"",a=r.dataset.tooltipStats??"",l=r.dataset.tooltipBuilt==="true",d=r.dataset.tooltipPackage??"",u=r.dataset.tooltipEcosystem??"",p=r.dataset.tooltipVersion??"",h=r.dataset.tooltipFiles??"",f=JSON.stringify([i,s,o,n,a,l,d,u,p,h]);if(!i||Mr===r&&dc===f)return;if(t.textContent=i,d){let R=document.createElement("div");R.className="tooltip-package";let I=(r.querySelector("[data-tooltip-package-icon] svg")??r.querySelector("svg"))?.cloneNode(!0);I&&R.append(I);let K=document.createElement("span");K.className="tooltip-package-details";for(let lt of[d,p,/^\d+$/u.test(h)?`${h} ${h==="1"?"file":"files"}`:""].filter(Boolean)){let io=document.createElement("span");io.textContent=lt,K.append(io)}R.append(K),t.append(R)}if(s||o){let R=document.createElement("div");if(R.className="tooltip-repo",s){R.innerHTML=Un;let I=document.createElement("span");I.textContent=s,R.append(I)}if(o){let I=document.createElement("span");I.className="tooltip-commit",I.innerHTML=Fn;let K=document.createElement("span");K.textContent=o.slice(0,7),I.append(K),R.append(I)}t.append(R)}if(n||a||l){let R=document.createElement("div");if(R.className="tooltip-bundle",n==="stasis"){let lt=document.createElement("img");lt.src="./stasis.svg",lt.alt="",R.append(lt)}else R.innerHTML=we;let I=document.createElement("span"),K=n==="stasis"?"Stasis":n==="sourcemap"?"Sourcemap":"";I.textContent=[K,l?"Built on server":"",a].filter(Boolean).join(" \xB7 "),R.append(I),t.append(R)}wh(t),t.style.left="0px",t.style.top="0px",t.style.transform="none",t.classList.add("visible");let b=mc,v=fc+xh;if(e==="right"||e==="right-start"){let R=r.getBoundingClientRect();b=R.right+$h,v=R.top+(e==="right"?R.height/2:0)}let y=window.innerWidth-t.offsetWidth-Ar,g=Math.max(Ar,Math.min(b,y));t.style.left=`${Math.round(g)}px`;let k=t.offsetHeight,C=e==="right"?v-k/2:v,L=window.innerHeight-k-Ar,M=Math.max(Ar,Math.min(C,L));t.style.top=`${Math.round(M)}px`,Mr=r,dc=f}function pc(){clearTimeout(Ir),Ir=null,W&&(W.classList.remove("visible"),typeof W.hidePopover=="function"&&W.matches(":popover-open")&&W.hidePopover()),Mr=null}function Sh(r,{gate:e,placement:t}={}){Object.hasOwn(r.dataset,"tooltipTruncated")&&r.scrollWidth<=r.clientWidth&&r.scrollHeight<=r.clientHeight||e&&!e(r)||(clearTimeout(Ir),Ir=setTimeout(()=>{kh(r,{placement:t})},_h))}function hc(r,e){for(let t of r.composedPath()){if(t===e)break;if(t.nodeType===1&&Object.hasOwn(t.dataset,"tooltip"))return t}return null}function gc(r,e){!r||uc.has(r)||(uc.add(r),r.addEventListener("mouseover",t=>{let i=hc(t,r);if(!i){pc();return}i!==Mr&&Sh(i,e)}),r.addEventListener("mouseout",t=>{let i=hc(t,r),s=t.relatedTarget?.closest?.("[data-tooltip]")??null;i&&i===s||pc()}))}var W,Mr,dc,Ir,mc,fc,_h,xh,$h,Ar,uc,bc=w(()=>{"use strict";_e();hs();Mr=null,dc="",Ir=null,mc=0,fc=0;document.addEventListener("mousemove",r=>{mc=r.clientX,fc=r.clientY},{passive:!0});_h=100,xh=14,$h=8,Ar=8;uc=new WeakSet});var yc,vc=w(()=>{yc=`a{cursor:default}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}button,summary,select,label,legend,header h3,.section-title,.ui-hint,.hint,.note,.lwd-note,.lwd-empty,.empty:not(.error,[role=alert]),.empty-discussion,.history-state[role=status],.history-summary{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}dialog{margin-top:5rem;margin-inline:auto;border:1px solid var(--border);border-radius:var(--ui-radius, 10px);background:var(--surface);color:var(--text);padding:1.1rem 1.25rem 1rem;max-width:480px;width:min(94vw,480px);box-shadow:0 20px 60px #00000059;&::backdrop{background:rgb(from var(--theme-bar) r g b / .55);backdrop-filter:blur(2px)}}header h3{margin:0 0 .6rem;font-size:1rem;font-weight:600}.nwd-input{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}.nwd-note{margin:.55rem 0 0;color:var(--muted);font-size:.74rem;line-height:1.45}.nwd-intro{margin:0 0 .8rem;color:var(--muted);font-size:.82rem;line-height:1.5}.nwd-actions{display:flex;align-items:center;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.nwd-spacer{flex:1}.nwd-actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:var(--ui-radius, 5px);padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);&:hover:not(:disabled){color:var(--surface);filter:brightness(1.08)}}&.quiet{border-color:transparent;color:var(--muted);&:hover:not(:disabled){border-color:transparent}}&.danger{color:var(--critical, #f87171);border-color:var(--border);&:hover:not(:disabled){border-color:var(--critical, #f87171);color:var(--critical, #f87171)}}&:disabled{opacity:.5}}@media(display-mode:window-controls-overlay){dialog{-webkit-app-region:no-drag;app-region:no-drag}}
|
|
56
|
-
`});function nt(r,e={}){return new Promise(t=>{let i=document.createElement(r);Object.assign(i,e),i.addEventListener("resolve",s=>{i.remove(),t(s.detail)}),document.body.append(i)})}var Q,Lr=
|
|
57
|
-
`});var Vs={};Nr(Vs,{openManagedShareDialog:()=>
|
|
55
|
+
`)}var Mp,Lp,Bp,Tn=_(()=>{J();fe();Mn();wi();Mp=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]),Lp=/^(?:summary of findings\b|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope\b|table of contents|contents\b|appendix|recommendation|remediation)/u;Bp=new Set([..._i,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"])});function be(r){return Array.isArray(r?.findings)?r.findings:Array.isArray(r?.groups)?r.groups:null}function Nn(r){let e;try{let t=JSON.parse(r);if(be(t)){for(let i of Up(be(t)))H(i);return{data:t,format:"json",reason:null}}return{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(t){e=t}for(let[t,i]of jp)try{let s=i(r);if(s)return{data:s,format:t,reason:null}}catch(s){if(t!=="markdown-generic")throw s;return{data:null,format:t,reason:s.message}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function Up(r){return r.flat().filter(e=>e&&typeof e=="object")}var jp,ve=_(()=>{Jo();bn();fi();Cn();Tn();fe();fi();ui();vt();jp=[["deepview-md",gn],["markdown-generic",yn],["deepsec",Zo],["piolium",zn],["claude-security",kn]]});function Fp(r){E.setSession(r)}function Hp(r){return E.setReportCatalog(r)}function qp(){E.reset()}var Ri,E,ae=_(()=>{"use strict";Ri=class{constructor(e=()=>{}){this.resources=new Map,this.session=null,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=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,this.teamCatalog=null,this.reportCatalog=null,this.bundleCatalog=null}setReportCatalog(e){let t=new Set,i=new Map(e.map(p=>[p.id,JSON.stringify([p.cacheKey??null,p.reports.map(u=>[u.id,u.cacheKey??null,u.visible!==!1]).toSorted(),(p.bundles??[]).map(u=>[u.id,u.filename,u.repoFullName,u.repoDirectory??""]).toSorted()])]));for(let p of new Set([...this.teamCatalog?.keys()??[],...i.keys()]))this.teamCatalog?.get(p)!==i.get(p)&&t.add(`team:${p}`);for(let p of this.resources.keys()){let u="reports:content:team:";if(p.startsWith(u)){let[f]=p.slice(u.length).split(":");(!i.has(f)||this.teamCatalog?.get(f)!==i.get(f))&&this.invalidate([p])}}this.teamCatalog=i;let s=new Map;for(let p of e)for(let u of p.reports){let f=s.get(u.id)??[];f.push(JSON.stringify([p.id,u.cacheKey??null])),s.set(u.id,f)}let o=new Map([...s].map(([p,u])=>[p,JSON.stringify(u.toSorted())])),n=this.reportCatalog;this.reportCatalog=o;let a=new Set(t);for(let p of new Set([...n?.keys()??[],...o.keys()]))n?.get(p)!==o.get(p)&&a.add(p);for(let p of this.resources.keys()){if(!p.startsWith("reports:content:")||p.startsWith("reports:content:team:"))continue;let u=p.slice(16);(!o.has(u)||a.has(u))&&(this.invalidate([p]),a.add(u))}let l=new Map;for(let p of e)for(let u of p.bundles??[]){let f=l.get(u.id)??[];f.push(JSON.stringify([p.id,p.cacheKey??null,u.filename,u.repoFullName,u.repoDirectory??""])),l.set(u.id,f)}let d=!1,m=new Map([...l].map(([p,u])=>[p,JSON.stringify(u.toSorted())]));for(let p of new Set([...this.bundleCatalog?.keys()??[],...m.keys()]))this.bundleCatalog?.get(p)!==m.get(p)&&(d=!0,a.add(`bundle:${p}`),this.invalidate([`bundle-metadata:${p}`]));this.bundleCatalog=m;for(let p of this.resources.keys()){if(!p.startsWith("report-sources:")&&!p.startsWith("finding-history:"))continue;let[,u,f]=p.split(":");(u?t.has(`team:${u}`):d||a.has(f))&&this.invalidate([p])}return a}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=()=>{},retryInvalidated:n=!1}={}){let a=this.generation;for(;;){s?.throwIfAborted();let l=this.resources.get(e);if(l||(l={},this.resources.set(e,l)),l.data!==void 0&&o(l.data),!l.pending){let d=l.controller=new AbortController;l.pending=(async()=>{try{let m=await i(d.signal);return d.signal.throwIfAborted(),l.data=m,m}catch(m){throw!d.signal.aborted&&m?.name!=="AbortError"&&this.notify(`Couldn't refresh ${t}: ${m?.message??m}`),m}})().finally(()=>{l.pending=null})}try{let d=await l.pending;if(s?.throwIfAborted(),this.resources.get(e)!==l)throw new DOMException("Managed data changed","AbortError");return o(d),d}catch(d){if(!n||d?.name!=="AbortError"||s?.aborted||a!==this.generation||this.resources.get(e)===l)throw d}}}},E=new Ri(r=>{document.dispatchEvent(new CustomEvent("managed-notice",{detail:{message:r}}))})});var Y,ye,re,xt=_(()=>{Y={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ye=r=>(...e)=>({_$litDirective$:r,values:e}),re=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 Pn,_e,Bn,Dn,et,lr,jn,Un,Fn,Hn,qn,we=_(()=>{"use strict";Pn="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",_e='<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>',Bn='<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>',Dn='<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>',et='<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>',lr='<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>',jn='<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>',Un='<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg>',Fn='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" aria-hidden="true"><path d="M1 8h3.5m7 0H15"/><circle cx="8" cy="8" r="3.5"/></svg>',Hn='<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>',qn='<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>'});var Wp,Gn,Kn,Wn,rt,xe,Kp,it,Zn,cr,dr=_(()=>{te();({I:Wp}=Mo),Gn=r=>r,Kn=r=>r.strings===void 0,Wn=()=>document.createComment(""),rt=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let o=i.insertBefore(Wn(),s),n=i.insertBefore(Wn(),s);t=new Wp(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=Gn(l).nextSibling;Gn(i).insertBefore(l,s),l=d}}}return t},xe=(r,e,t=r)=>(r._$AI(e,t),r),Kp={},it=(r,e=Kp)=>r._$AH=e,Zn=r=>r._$AH,cr=r=>{r._$AR(),r._$AA.remove()}});function us(r){return typeof r=="string"&&/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(r)?r:null}var hs=_(()=>{"use strict"});var Rr,Yl=_(()=>{te();xt();dr();Rr=ye(class extends re{constructor(){super(...arguments),this.key=h}render(r,e){return this.key=r,e}update(r,[e,t]){return e!==this.key&&(it(r),this.key=e),t}})});var Cs=_(()=>{Yl()});var Ny,Py,By,dc=_(()=>{"use strict";S();Ny=document.querySelector("#drop-zone"),Py=document.querySelector("#report"),By=document.querySelector("app-sidebar")});function Us(r=document){if(r.querySelector(":modal"))return!0;for(let e of r.querySelectorAll("*"))if(e.shadowRoot&&Us(e.shadowRoot))return!0;return!1}var pc=_(()=>{"use strict"});function wh(){return W||(W=document.createElement("div"),W.id="styled-tooltip",W.setAttribute("popover","manual"),document.body.append(W),W)}function xh(r){typeof r.showPopover=="function"&&(r.matches(":popover-open")&&r.hidePopover(),r.showPopover())}function Ch(r,{placement:e="cursor"}={}){e=r.dataset.tooltipPlacement??e;let t=wh(),i=r.dataset.tooltip??"",s=r.dataset.tooltipRepo??"",o=us(r.dataset.tooltipCommit),n=["stasis","sourcemap"].includes(r.dataset.tooltipBundle)?r.dataset.tooltipBundle:"",a=r.dataset.tooltipStats??"",l=r.dataset.tooltipBuilt==="true",d=r.dataset.tooltipPackage??"",m=r.dataset.tooltipEcosystem??"",p=r.dataset.tooltipVersion??"",u=r.dataset.tooltipFiles??"",f=JSON.stringify([i,s,o,n,a,l,d,m,p,u]);if(!i||Ir===r&&uc===f)return;if(t.textContent=i,d){let R=document.createElement("div");R.className="tooltip-package";let M=(r.querySelector("[data-tooltip-package-icon] svg")??r.querySelector("svg"))?.cloneNode(!0);M&&R.append(M);let K=document.createElement("span");K.className="tooltip-package-details";for(let lt of[d,p,/^\d+$/u.test(u)?`${u} ${u==="1"?"file":"files"}`:""].filter(Boolean)){let io=document.createElement("span");io.textContent=lt,K.append(io)}R.append(K),t.append(R)}if(s||o){let R=document.createElement("div");if(R.className="tooltip-repo",s){R.innerHTML=Un;let M=document.createElement("span");M.textContent=s,R.append(M)}if(o){let M=document.createElement("span");M.className="tooltip-commit",M.innerHTML=Fn;let K=document.createElement("span");K.textContent=o.slice(0,7),M.append(K),R.append(M)}t.append(R)}if(n||a||l){let R=document.createElement("div");if(R.className="tooltip-bundle",n==="stasis"){let lt=document.createElement("img");lt.src="./stasis.svg",lt.alt="",R.append(lt)}else R.innerHTML=_e;let M=document.createElement("span"),K=n==="stasis"?"Stasis":n==="sourcemap"?"Sourcemap":"";M.textContent=[K,l?"Built on server":"",a].filter(Boolean).join(" \xB7 "),R.append(M),t.append(R)}xh(t),t.style.left="0px",t.style.top="0px",t.style.transform="none",t.classList.add("visible");let b=gc,v=bc+kh;if(e==="right"||e==="right-start"){let R=r.getBoundingClientRect();b=R.right+Sh,v=R.top+(e==="right"?R.height/2:0)}let y=window.innerWidth-t.offsetWidth-Ar,g=Math.max(Ar,Math.min(b,y));t.style.left=`${Math.round(g)}px`;let k=t.offsetHeight,C=e==="right"?v-k/2:v,L=window.innerHeight-k-Ar,I=Math.max(Ar,Math.min(C,L));t.style.top=`${Math.round(I)}px`,Ir=r,uc=f}function hc(){clearTimeout(Mr),Mr=null,W&&(W.classList.remove("visible"),typeof W.hidePopover=="function"&&W.matches(":popover-open")&&W.hidePopover()),Ir=null}function Rh(r,{gate:e,placement:t}={}){Object.hasOwn(r.dataset,"tooltipTruncated")&&r.scrollWidth<=r.clientWidth&&r.scrollHeight<=r.clientHeight||e&&!e(r)||(clearTimeout(Mr),Mr=setTimeout(()=>{Ch(r,{placement:t})},$h))}function fc(r,e){for(let t of r.composedPath()){if(t===e)break;if(t.nodeType===1&&Object.hasOwn(t.dataset,"tooltip"))return t}return null}function vc(r,e){!r||mc.has(r)||(mc.add(r),r.addEventListener("mouseover",t=>{let i=fc(t,r);if(!i){hc();return}i!==Ir&&Rh(i,e)}),r.addEventListener("mouseout",t=>{let i=fc(t,r),s=t.relatedTarget?.closest?.("[data-tooltip]")??null;i&&i===s||hc()}))}var W,Ir,uc,Mr,gc,bc,$h,kh,Sh,Ar,mc,yc=_(()=>{"use strict";we();hs();Ir=null,uc="",Mr=null,gc=0,bc=0;document.addEventListener("mousemove",r=>{gc=r.clientX,bc=r.clientY},{passive:!0});$h=100,kh=14,Sh=8,Ar=8;mc=new WeakSet});var wc,_c=_(()=>{wc=`a{cursor:default}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}button,summary,select,label,legend,header h3,.section-title,.ui-hint,.hint,.note,.lwd-note,.lwd-empty,.empty:not(.error,[role=alert]),.empty-discussion,.history-state[role=status],.history-summary{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}dialog{margin-top:5rem;margin-inline:auto;border:1px solid var(--border);border-radius:var(--ui-radius, 10px);background:var(--surface);color:var(--text);padding:1.1rem 1.25rem 1rem;max-width:480px;width:min(94vw,480px);box-shadow:0 20px 60px #00000059;&::backdrop{background:rgb(from var(--theme-bar) r g b / .55);backdrop-filter:blur(2px)}}header h3{margin:0 0 .6rem;font-size:1rem;font-weight:600}.nwd-input{display:block;width:100%;box-sizing:border-box;padding:.5rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);background:var(--bg, var(--surface));color:var(--text);font:inherit;font-size:.88rem;&:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgb(from var(--accent) r g b / .18)}&::placeholder{color:var(--muted)}}.nwd-note{margin:.55rem 0 0;color:var(--muted);font-size:.74rem;line-height:1.45}.nwd-intro{margin:0 0 .8rem;color:var(--muted);font-size:.82rem;line-height:1.5}.nwd-actions{display:flex;align-items:center;gap:.4rem;margin-top:.8rem;padding-top:.7rem;border-top:1px solid var(--border)}.nwd-spacer{flex:1}.nwd-actions button{background:transparent;border:1px solid var(--border);color:var(--text);border-radius:var(--ui-radius, 5px);padding:.35rem .9rem;font:inherit;font-size:.8rem;&:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}&.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);&:hover:not(:disabled){color:var(--surface);filter:brightness(1.08)}}&.quiet{border-color:transparent;color:var(--muted);&:hover:not(:disabled){border-color:transparent}}&.danger{color:var(--critical, #f87171);border-color:var(--border);&:hover:not(:disabled){border-color:var(--critical, #f87171);color:var(--critical, #f87171)}}&:disabled{opacity:.5}}@media(display-mode:window-controls-overlay){dialog{-webkit-app-region:no-drag;app-region:no-drag}}
|
|
56
|
+
`});function nt(r,e={}){return new Promise(t=>{let i=document.createElement(r);Object.assign(i,e),i.addEventListener("resolve",s=>{i.remove(),t(s.detail)}),document.body.append(i)})}var Q,Lr=_(()=>{"use strict";S();dc();pc();yc();_c();Q=class extends A{static styles=[$(wc)];exclusive=!1;firstUpdated(){vc(this.renderRoot),this.beforeOpen();let e=this.renderRoot.querySelector("dialog");if(e){if(this.exclusive&&Us()){this._conflict(new DOMException("Another modal dialog is already open","InvalidStateError"));return}try{e.showModal()}catch(t){this._conflict(t);return}this.focusInitial()}}_conflict(e){this._settled=!0,this.dispatchEvent(new CustomEvent("modal-conflict",{detail:{cause:e}}))}beforeOpen(){}focusInitial(){(this.renderRoot.querySelector("input, textarea")??this.renderRoot.querySelector("button.primary")??this.renderRoot.querySelector("button"))?.focus()}_finish(e){this._settled||(this._settled=!0,this.renderRoot.querySelector("dialog")?.close(),this.dispatchEvent(new CustomEvent("resolve",{detail:e})))}_onClose=()=>this._finish(null);_onBackdrop=e=>{if(e.target!==e.currentTarget)return;let{left:t,right:i,top:s,bottom:o}=e.currentTarget.getBoundingClientRect();(e.clientX<t||e.clientX>i||e.clientY<s||e.clientY>o)&&this._onClose()}}});async function ce(r,e=null,t={}){let i;try{i=await x(r,{credentials:"same-origin",headers:{accept:"application/json"},...t})}catch{return e}if(i.status===401||i.status===403)return null;if(!i.ok)return e;try{return await i.json()}catch{return e}}async function t_({fallback:r=null}={}){let e;try{let i=ee(),s=await x(i?jr(i):"/api/auth/session",{credentials:"same-origin",headers:{accept:"application/json"}});if(s.status===401||s.status===403)return null;if(!s.ok)return r;e=await s.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,...ee()?{publicShare:!0}:{}}}async function r_({fallback:r=[],signal:e,onRevision:t}={}){let i=ee(),s=i?await ce(jr(i),null,{signal:e}):null,o=i?{teams:s?.team?[s.team]:[]}:await ce("/api/teams",{teams:r},{signal:e}),n=o?.teams;return Array.isArray(n)?(t?.(typeof o.revision=="string"?o.revision:null),n.filter(a=>a!=null&&typeof a.id=="string"&&typeof a.name=="string").map(a=>({id:a.id,slug:a.slug,name:a.name,...a.permissions?{permissions:{dependencies:a.permissions.dependencies===!0,security:a.permissions.security===!0}}:{},...typeof a.cacheKey=="string"?{cacheKey:a.cacheKey}:{},reports:Array.isArray(a.reports)?a.reports.filter(l=>l!=null&&typeof l.id=="string"&&typeof l.filename=="string").map(l=>({id:l.id,slug:l.slug,filename:l.filename,visible:l.visible!==!1,...l.analyzer===null||typeof l.analyzer=="string"?{analyzer:l.analyzer}:{},repoFullName:typeof l.repoFullName=="string"?l.repoFullName:"",repoDirectory:typeof l.repoDirectory=="string"?l.repoDirectory:"",...typeof l.cacheKey=="string"?{cacheKey:l.cacheKey}:{}})):[],bundles:Array.isArray(a.bundles)?a.bundles.filter(l=>l!=null&&typeof l.id=="string"&&typeof l.filename=="string").map(l=>({id:l.id,slug:l.slug,integrity:l.integrity,byteSize:l.byteSize,repoId:l.repoId,filename:l.filename,kind:l.kind,visible:l.visible!==!1,summary:l.summary??null,summaryRetryAt:Number.isSafeInteger(l.summaryRetryAt)&&l.summaryRetryAt>0?l.summaryRetryAt:null,repoDirectory:typeof l.repoDirectory=="string"?l.repoDirectory:"",repoFullName:typeof l.repoFullName=="string"?l.repoFullName:""})):[]}))):o==null?[]:r}function Fs(r){return r?.links===void 0?[]:Array.isArray(r.links)&&r.links.every(e=>Array.isArray(e)&&e.length>=2&&e.every(t=>typeof t=="string"))?r.links:null}function Hs(r){return be(r?.data)===null||typeof r.repo?.directory!="string"||r.repo.github!==null&&typeof r.repo.github!="string"||Fs(r)===null?null:{data:r.data,repo:r.repo,...r.links?{links:r.links}:{}}}async function zr(r,{signal:e}={}){return Hs(await ce(`/api/reports/${encodeURIComponent(r)}`,null,{signal:e}))}async function xc(r,{signal:e}={}){let t=[...new Set(r)];if(t.length===0)return[];let i=await ce("/api/reports/query",null,{method:"POST",signal:e,headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({ids:t})});if(!Array.isArray(i?.reports)||i.reports.length!==t.length)return null;let s=new Map;for(let n of i.reports){let a=Hs(n);if(!a||!t.includes(n.id)||s.has(n.id))return null;s.set(n.id,a)}let o=Fs(i);return o===null?null:r.map(n=>({...s.get(n),...o.length>0?{links:o}:{}}))}async function $c(r,{signal:e,reportId:t=null}={}){let i=t===null?"":`?reportId=${encodeURIComponent(t)}`,s=await ce(`/api/teams/${encodeURIComponent(r)}/reports${i}`,null,{signal:e});if(!Array.isArray(s?.reports))return null;let o=[],n=new Set;for(let l of s.reports){let d=Hs(l);if(!d||typeof l.id!="string"||typeof l.filename!="string"||n.has(l.id))return null;n.add(l.id),o.push({id:l.id,filename:l.filename,...d})}let a=Fs(s);return a===null?null:(Object.defineProperty(o,"links",{value:a}),o)}function Ve(r){return r?`?team=${encodeURIComponent(r)}`:""}async function i_(r,{reportId:e,...t}={}){let i=e==null?"":`?reportId=${encodeURIComponent(e)}`,s=await ce(`/api/teams/${encodeURIComponent(r)}/annotations${i}`,null,t),{reports:o,entries:n,comments:a,issues:l={}}=s??{};if(!o||typeof o!="object"||Array.isArray(o)||!n||typeof n!="object"||Array.isArray(n)||!Array.isArray(a)||!l||typeof l!="object"||Array.isArray(l)||Object.values(o).some(u=>!Array.isArray(u)||u.some(f=>typeof f!="string"))||a.some(u=>!u||typeof u.findingId!="string"))return null;let d=new Map;for(let[u,f]of a.entries()){let b=f.findingId,v=d.get(b)??[];v.push(u),d.set(b,v)}let m=new Map,p=new Map;return u=>{if(!Object.hasOwn(o,u))return null;if(p.has(u))return p.get(u);let f=JSON.stringify(o[u]),b=m.get(f);if(!b){let v=[...new Set(o[u])],y=v.flatMap(g=>d.get(g)??[]);b={entries:Object.fromEntries(v.filter(g=>Object.hasOwn(n,g)).map(g=>[g,n[g]])),comments:y.toSorted((g,k)=>g-k).map(g=>a[g]),issues:Object.fromEntries(v.filter(g=>Object.hasOwn(l,g)).map(g=>[g,l[g]]))},m.set(f,b)}return p.set(u,b),b}}async function s_(r,e,t){let s=(await ce(`/api/reports/${encodeURIComponent(r)}/triage${Ve(e)}`,null,t))?.entries;return s!=null&&typeof s=="object"&&!Array.isArray(s)?s:null}async function o_(r,e,t=null){if(ee())return[];let i=t===null?"":`?reportId=${encodeURIComponent(t)}`,s=await ce(`/api/teams/${encodeURIComponent(r)}/fixes${i}`,null,{signal:e});return Array.isArray(s?.fixes)?s.fixes:null}async function n_(r,e,t){let i=await ce(`/api/reports/${encodeURIComponent(r)}/comments${Ve(e)}`,null,t);return Array.isArray(i?.comments)?i.comments:null}async function a_(r,{findingId:e,body:t,commentId:i=null,version:s},o,n){let a=i==null?"":`/${encodeURIComponent(i)}`;try{let l=await x(`/api/reports/${encodeURIComponent(r)}/comments${a}${Ve(n)}`,{method:i==null?"POST":"PATCH",credentials:"same-origin",headers:{"content-type":"application/json",...o?{"x-csrf-token":o}:{}},body:JSON.stringify(i==null?{findingId:e,body:t}:{body:t,version:s})});return{status:l.status,comment:l.ok?(await l.json()).comment:null}}catch{return{status:0,comment:null}}}async function l_(r,e,t,i,s){try{return(await x(`/api/reports/${encodeURIComponent(r)}/comments/${encodeURIComponent(e)}${Ve(s)}`,{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json",...i?{"x-csrf-token":i}:{}},body:JSON.stringify({version:t})})).status}catch{return 0}}async function c_(r,e,t,i){try{return(await x(`/api/reports/${encodeURIComponent(r)}/triage${Ve(i)}`,{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 d_(r){r&&(location.href=r)}async function p_(r){if(ee()){location.href="/";return}try{await x("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:r?{"x-csrf-token":r}:{}})}catch{}location.reload()}async function kc(r){let e=await x(`/api/teams/${encodeURIComponent(r)}/share`,{credentials:"same-origin"});if(!e.ok)throw new Error(`Could not load public links (${e.status})`);return(await e.json()).shares}async function Sc(r,e,{id:t,revoke:i=!1,dependencies:s=!1,security:o=!1}={}){let n=t?`/${encodeURIComponent(t)}`:"",a=await x(`/api/teams/${encodeURIComponent(r)}/share${n}`,{method:i?"DELETE":t?"PATCH":"POST",credentials:"same-origin",headers:{"x-csrf-token":e,"content-type":"application/json"},...i?{}:{body:JSON.stringify({dependencies:s,security:o})}});if(!a.ok)throw new Error(`Could not ${i?"revoke":t?"update":"create"} public link (${a.status})`);return a.json()}async function u_(r,e){let t=await x(`/api/bundles/${encodeURIComponent(r)}/download`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Could not download bundle (${t.status})`);let i=URL.createObjectURL(await t.blob()),s=document.createElement("a");s.href=i,s.download=e,s.click(),setTimeout(()=>URL.revokeObjectURL(i),6e4)}var at=_(()=>{"use strict";B();Ot();ve()});var Rc,Cc=_(()=>{Rc=`.share-field{display:grid;gap:.35rem;margin-top:.8rem;font-size:.82rem}fieldset{display:grid;gap:.55rem;border:0;margin-top:1rem;font-size:.82rem}legend{margin-bottom:.55rem;font-weight:600}fieldset label{display:flex;align-items:center;gap:.5rem}input[type=checkbox]{accent-color:var(--accent)}.nwd-actions{flex-wrap:wrap}.revoke-all{margin-top:.75rem;border:0;background:none;color:var(--muted);font:inherit;font-size:.74rem}.revoke-all:hover:not(:disabled){color:var(--critical)}
|
|
57
|
+
`});var Vs={};Nr(Vs,{openManagedShareDialog:()=>Ih});function Ih(r,e="",t=null){return nt("managed-share-dialog",{team:r,initialId:e,session:t})}var qs,Gs=_(()=>{"use strict";S();Lr();at();ae();Cc();qs=class extends Q{static styles=[...Q.styles,$(Rc)];static properties={team:{attribute:!1},session:{attribute:!1},initialId:{attribute:!1},selectedId:{state:!0},links:{state:!0},dependencies:{state:!0},security:{state:!0},busy:{state:!0},message:{state:!0}};constructor(){super(),this.team=null,this.initialId="",this.selectedId="",this.links=[],this.dependencies=!1,this.security=!1,this.busy=!0,this.message="",this.urls=new Map}beforeOpen(){this.load(this.initialId)}select(e){let t=this.links.find(i=>i.id===e);this.selectedId=t?.id??"",this.dependencies=t?.permissions.dependencies===!0,this.security=t?.permissions.security===!0,this.message=""}async load(e=this.selectedId){this.busy=!0;try{let t=await kc(this.team.id);return this._settled?void 0:(this.links=t,this.select(e),!0)}catch(t){return this.message=t.message,!1}finally{this.busy=!1}}async change(e=!1,t=!1){if(!this.busy){this.busy=!0,this.message="";try{let i=await Sc(this.team.id,this.session?.csrfToken,{id:t?void 0:this.selectedId||void 0,revoke:e,dependencies:this.dependencies,security:this.security});if(E.invalidate(["links","history"]),this._settled)return;i.path&&(this.urls.set(i.id,new URL(i.path,location.origin).href),this.links=[{id:i.id,createdAt:Date.now(),createdBy:this.session?.login??"",permissions:{dependencies:this.dependencies,security:this.security}},...this.links],this.selectedId=i.id),e&&(t?this.urls.clear():this.urls.delete(this.selectedId)),await this.load(e?"":i.id??this.selectedId)&&(this.message=e?t?"All public links revoked.":"Link revoked.":i.path?"Link created.":"Permissions saved. The link URL is unchanged.")}catch(i){this.message=i.message}finally{this.busy=!1}}}async copy(){try{await navigator.clipboard.writeText(this.urls.get(this.selectedId)),this.message="Link copied."}catch{this.message="Select the link and copy it."}}render(){let e=this.urls.get(this.selectedId);return c`<dialog @close="${this._onClose}"><header><h3>Share ${this.team?.name}</h3></header><p class="nwd-intro ui-hint">Anyone with this link can read this workspace’s published reports, comments, triage, and available source files without signing in.<br>New published reports will also be included.</p><label class="share-field">Public links <select class="nwd-input" ?disabled="${this.busy}" @change="${t=>this.select(t.target.value)}"><option value="" ?selected="${!this.selectedId}">Create a new link</option>${this.links.map(t=>c`<option value="${t.id}" ?selected="${this.selectedId===t.id}">${new Date(t.createdAt).toLocaleString()} · ${t.createdBy} · ${t.id.slice(0,8)}</option>`)}</select></label><fieldset ?disabled="${this.busy}"><legend>Include in this link</legend><label><input type="checkbox" .checked="${this.security}" @change="${t=>{this.security=t.target.checked}}"> Security findings and advisories</label> <label><input type="checkbox" .checked="${this.dependencies}" @change="${t=>{this.dependencies=t.target.checked}}"> Findings in dependencies</label></fieldset><p class="nwd-note ui-hint">Both options are off for new links.<br>Existing links keep their URL when permissions change.</p>${e?c`<label class="share-field">Public link<input class="nwd-input" readonly="readonly" .value="${e}" @focus="${t=>t.target.select()}"></label>`:h} ${this.message?c`<p class="nwd-note" role="status">${this.message}</p>`:h}<footer class="nwd-actions">${this.selectedId?c`<button class="danger" ?disabled="${this.busy}" @click="${()=>this.change(!0)}">Revoke link</button>`:h} <span class="nwd-spacer"></span> ${e?c`<button @click="${()=>this.copy()}">Copy link</button>`:h} <button class="primary" ?disabled="${this.busy}" @click="${()=>this.change()}">${this.selectedId?"Save changes":"Create public link"}</button> <button @click="${()=>this._finish(null)}">Close</button></footer>${this.links.length>0?c`<button class="revoke-all" ?disabled="${this.busy}" @click="${()=>this.change(!0,!0)}">Revoke all links for this workspace</button>`:h}</dialog>`}};customElements.define("managed-share-dialog",qs)});async function Xs(r,e,t,i=null){let s=`/api/teams/${encodeURIComponent(r)}/issues`,o,n;try{o=await x(i?s:`${s}?${new URLSearchParams(e)}`,{method:i?"POST":"GET",credentials:"same-origin",headers:{accept:"application/json",...i?{"content-type":"application/json","x-csrf-token":t}:{}},...i?{body:JSON.stringify({...e,...i})}:{}}),n=await o.json()}catch{throw new Error(i?"github-create-uncertain":"github-unavailable")}if(!o.ok){let a=typeof n?.error=="string"&&n.error?n.error:null;throw new Error(i&&o.status>=500&&!Fh.has(a)?"github-create-uncertain":a??(i?"github-create-uncertain":"github-unavailable"))}return n}var Fh,Ac=_(()=>{"use strict";B();Fh=new Set(["github-unavailable","unavailable","shutting-down","github-create-failed"])});function Mc(r,{sourceUrl:e,evidence:t="",showRevalidation:i=!0}={}){let s=[],o=new Map,n=(p,u,f)=>{if(!f?.trim())return;let b=o.get(p)??{id:p,label:u,parts:[]};b.parts.includes(f.trim())||b.parts.push(f.trim()),o.set(p,b)},a=bt(r);r.file&&s.push(`File: ${e?`[${a}](${e})`:a}`);let l=null;for(let p of li(Xt(r.description,r))){if(p.label!==null){let u=Ic(p.label);l=["description","details","summary"].includes(u)?null:{id:Hh.get(u)??u,label:p.label}}l?n(l.id,l.label,p.body):s.push(p.label?`**${p.label}:** ${p.body}`:p.body)}r.confidence!=null&&s.push(`Confidence: ${r.confidence}/10`);for(let[p,u]of Tr){if(p.startsWith("revalidate")&&!i){o.delete(p);continue}let f=p==="evidence"?t.replace(/^\*\*Evidence:\*\*\n/u,""):Xt(r[p],r);n(p,u,f)}let d=[...Tr.map(([p])=>o.get(p)).filter(Boolean),...[...o.values()].filter(p=>!Tr.some(([u])=>u===p.id))],m={body:s.join(`
|
|
58
58
|
|
|
59
|
-
`),sections:d.map(({id:p,label:
|
|
59
|
+
`),sections:d.map(({id:p,label:u,parts:f})=>({id:p,label:u,text:`**${u}:**
|
|
60
60
|
${f.join(`
|
|
61
61
|
|
|
62
|
-
`)}`,selected:!1,start:0,end:0}))};return o.has("impact")&&(
|
|
62
|
+
`)}`,selected:!1,start:0,end:0}))};return o.has("impact")&&(m=Qs(m,"impact",!0)),m}function Lc(r,e){let t=r.body;if(e===t)return r;let i=t.length,s=e.length,o=0;for(;o<i&&o<s&&t[o]===e[o];)o++;for(;i>o&&s>o&&t[i-1]===e[s-1];)i--,s--;let n=e.length-t.length,a=r.sections.map(l=>l.selected?o>=l.start&&i<=l.end?{...l,end:l.end+n}:i<=l.start?{...l,start:l.start+n,end:l.end+n}:o>=l.end?l:{...l,text:t.slice(l.start,l.end),selected:!1,start:0,end:0}:l);return{body:e,sections:a}}function Qs(r,e,t){let i=r.sections.find(p=>p.id===e);if(!i||i.selected===t)return r;if(t){let p=!r.body||r.body.endsWith(`
|
|
63
63
|
|
|
64
64
|
`)?"":r.body.endsWith(`
|
|
65
65
|
`)?`
|
|
66
66
|
`:`
|
|
67
67
|
|
|
68
|
-
`,
|
|
69
|
-
`});var Oc={};Nr(Oc,{openManagedIssueDialog:()=>Hh});function Hh(r){return nt("managed-issue-dialog",r)}var eo,to,Tc=w(()=>{"use strict";S();Rc();Lr();Ic();Lc();eo={"github-unavailable":"GitHub could not be reached. Try checking again.","github-issue-forbidden":"GitHub did not permit issue creation. Check your repository access and authorization.","github-create-uncertain":"GitHub may have created this issue. Check the repository before trying again.","github-create-failed":"GitHub could not create the issue. Check the title and description before trying again.",unauthenticated:"Your session expired. Sign in again before creating an issue.","workspace-changed":"Your workspace access changed. Reopen the finding before creating an issue.","bad-issue-repository":"The finding\u2019s repository changed. Reopen the finding before creating an issue.","no-finding":"This finding is no longer available in this workspace."},to=class extends Q{static styles=[...Q.styles,x(zc)];static properties={teamId:{attribute:!1},context:{attribute:!1},session:{attribute:!1},formUrl:{attribute:!1},title:{state:!0},body:{state:!0},prepared:{state:!0},busy:{state:!0},creating:{state:!0},message:{state:!0},uncertain:{state:!0},createdUrl:{state:!0},createdIssue:{state:!0},detailsUnavailable:{state:!0},sections:{state:!0}};constructor(){super(),this.title="",this.body="",this.prepared=null,this.busy=!1,this.creating=!1,this.message="",this.uncertain=!1,this.createdUrl="",this.createdIssue=null,this.detailsUnavailable=!1,this.sections=[]}beforeOpen(){this.finding&&Object.assign(this,Ac(this.finding,this.draftOptions)),this.check(!0)}editBody(e){Object.assign(this,Mc(this,e))}toggleSection(e,t){Object.assign(this,Qs(this,e,t))}current(){return!this._settled&&this.isCurrent()}fallbackUrl(){let e=new URL(this.formUrl);return e.searchParams.set("title",this.title),e.searchParams.set("body",this.body),this.prepared?.labels&&e.searchParams.set("labels",this.prepared.labels.join(",")),e.href}async check(e=!1){if(!(this.busy||!this.current())){this.busy=!0,this.message="";try{let t=await Xs(this.teamId,this.context,this.session.csrfToken);if(!this.current())return;this.prepared=t,this.uncertain=!1,t.mode==="existing"&&(this.onCreated?.(t.url),window.location.assign(t.url)),e&&t.mode==="form"&&window.location.assign(this.fallbackUrl())}catch(t){!this.uncertain&&!["pending","created-unavailable"].includes(this.prepared?.mode)&&(this.prepared=null),this.message=eo[t.message]??"Unable to check this issue. Please retry."}finally{this.busy=!1}}}async create(){if(!(this.busy||this.uncertain||this.createdUrl||this.prepared?.mode!=="api")){if(!this.current()){this.message=eo["workspace-changed"],this.prepared=null;return}this.busy=!0,this.creating=!0,this.message="";try{let e=await Xs(this.teamId,this.context,this.session.csrfToken,{title:this.title,body:this.body});if(!this.current())return;e.mode==="existing"?(this.onCreated?.(e.url),window.location.assign(e.url)):e.url?(this.createdUrl=e.url,this.createdIssue=e.issue,this.detailsUnavailable=e.detailsUnavailable===!0,this.onCreated?.(e.url)):this.prepared=e}catch(e){e.message==="github-authorization-required"?this.prepared={mode:"authorize",authorizationPath:"/api/oauth/github/issues/login"}:(this.uncertain=e.message==="github-create-uncertain",["workspace-changed","bad-issue-repository","no-team","no-report","no-finding","unauthenticated","forbidden"].includes(e.message)&&(this.prepared=null),this.message=eo[e.message]??"Could not create this issue. Check the title, description, and repository access.")}finally{this.busy=!1,this.creating=!1}}}render(){let e=this.createdIssue,t=this.prepared,i=t?.mode==="created-unavailable",s=this.createdUrl||i,o=this.uncertain||t?.mode==="pending",n=this.creating||o,a=!this.busy&&!o&&t?.mode==="form";return c`<dialog aria-labelledby="issue-dialog-title" @close="${this._onClose}" @cancel="${l=>{this.creating&&l.preventDefault()}}"><header><h3 id="issue-dialog-title">${s?"Issue created":"Create a GitHub issue"}</h3></header><div class="dialog-content"><p class="nwd-intro">${s?"Created":"Create"} in <strong>${this.context?.repository}</strong> as <strong>@${this.session?.login}</strong>.</p>${this.createdUrl?c`<section class="created-issue" aria-label="Created GitHub issue"><div class="issue-heading"><span class="${`issue-status ${e?.status??"open"} ${e?.stateReason??""}`}">${e?.status==="closed"?e.stateReason==="not_planned"?"Not planned":e.stateReason==="duplicate"?"Duplicate":e.stateReason==="completed"?"Completed":"Closed":"Open"}</span> <span class="issue-number">${e?.number?`#${e.number}`:""}</span></div><h4><a href="${this.createdUrl}" target="_blank" rel="noopener">${e?.title??this.title}</a></h4><p class="nwd-note">Opened by @${e?.author??this.session?.login}</p>${e?.labels?.length?c`<div class="issue-labels">${e.labels.map(l=>c`<span>${l}</span>`)}</div>`:m}<div class="issue-description">${this.renderBody?this.renderBody(e?.description??this.body):e?.description??this.body}</div><p class="nwd-note ui-hint">Linked permanently to this finding. The Issue button will open this issue next time.</p>${this.detailsUnavailable?c`<p class="nwd-note">GitHub’s latest details could not be loaded. The issue was created and its link is saved.</p>`:m}</section>`:i?c`<p role="status">The issue was created and linked permanently to this finding. Its details cannot be shown because workspace access could not be confirmed. Check its status again once workspace access is available.</p>`:c`<label>Title<input class="nwd-input" maxlength="256" .value="${this.title}" ?disabled="${n}" @input="${l=>{this.title=l.target.value}}"></label><div class="description-heading"><label for="issue-description">Description</label> ${this.sections.length>0?c`<div class="description-sections" role="group" aria-label="Include in description">${this.sections.map(l=>c`<label><input type="checkbox" .checked="${l.selected}" ?disabled="${n}" @change="${d=>this.toggleSection(l.id,d.target.checked)}">${l.label}</label>`)}</div>`:m}</div><p id="description-help" class="nwd-note description-help ui-hint">${this.sections.length>0?"Add or remove sections above. Your edits are kept when toggling them.":"Edit the description before creating the issue."}</p><textarea id="issue-description" class="nwd-input" maxlength="65536" .value="${this.body}" aria-describedby="description-help" ?disabled="${n}" @input="${l=>this.editBody(l.target.value)}"></textarea> ${t?.labels?.length?c`<p class="nwd-note">Labels: ${t.labels.join(", ")}</p>`:m} ${t?.mode==="permissions"?c`<p>Ask a repository owner to approve the app’s Issues read and write permission. ${t.authorizationPath?c`<a href="${t.authorizationPath}" target="_blank" rel="noopener">Review repository permissions</a>`:m}</p>`:m} ${t?.mode==="authorize"?c`<p><a href="${t.authorizationPath}" target="_blank" rel="noopener">Authorize GitHub</a>, then check authorization here.</p>`:m} ${t?.mode==="pending"?c`<p role="status">An issue is being created, or its creation could not be confirmed. Check its status before continuing; another issue will not be created.</p>`:m} ${t?.mode==="unavailable"?c`<p role="status">This finding already has a managed issue in a repository outside this workspace.</p>`:m}`} ${!this.createdUrl&&this.message?c`<p class="nwd-note" role="status">${this.message}</p>`:m} ${!this.createdUrl&&this.busy?c`<p role="status">${this.creating?"Creating issue\u2026":"Checking repository access\u2026"}</p>`:m}</div><footer class="nwd-actions">${this.createdUrl?c`<a href="${this.createdUrl}" target="_blank" rel="noopener">Open issue on GitHub</a>`:!this.busy&&o?c`<a href="${t?.repositoryUrl??`https://github.com/${this.context?.repository}/issues`}" target="_blank" rel="noopener">Check repository issues</a>`:a?c`<a href="${this.fallbackUrl()}" target="_blank" rel="noopener">Use GitHub form</a>`:m} <span class="nwd-spacer"></span> ${!this.createdUrl&&t?.mode!=="unavailable"?t?.mode==="api"&&!this.uncertain?c`<button class="primary" ?disabled="${this.busy||!this.title.trim()}" @click="${this.create}">Create issue</button>`:c`<button ?disabled="${this.busy}" @click="${()=>this.check()}">${o||i?"Check issue status":"Check authorization"}</button>`:m} <button ?disabled="${this.creating}" @click="${()=>this._finish(null)}">${s?"Close":"Cancel"}</button></footer></dialog>`}};customElements.define("managed-issue-dialog",to)});function Nc(r,e){return e==="triage"?Vh[r?.triage]??"Untriaged":e==="flagged"?r?.flagged?"Yes":"No":r?.[e]||"None"}function Pc(r,e){return Object.entries(qh).flatMap(([t,i])=>{let s=Nc(r,t);if(e===void 0)return r?.[t]===void 0?[]:[{label:i,after:s}];let o=Nc(e,t);return o===s?[]:[{label:i,before:o,after:s}]})}var qh,Vh,Bc=w(()=>{"use strict";qh={triage:"Status",color:"Label",flagged:"Flagged",fix:"Fix",comment:"Comment"},Vh={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Deleted",ignored:"Ignored"}});function Dc(r,e){return r?Rr(r,c`<span class="managed-comment-avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${ee()?m:c`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" loading="lazy" @error="${t=>{t.currentTarget.hidden=!0}}">`}</span>`):m}var jc=w(()=>{"use strict";Ot();S();Cs()});var Fc,Uc=w(()=>{Fc=`.managed-comment{container:managed-comment / inline-size;white-space:normal}.managed-comment-row{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr) auto;align-items:start;gap:.35rem .65rem;line-height:1.5}.managed-comment-author{grid-column:1;grid-row:1;display:flex;align-items:center;gap:.45rem;min-width:0;max-width:14rem;& strong{overflow:hidden;text-overflow:ellipsis;font-weight:600}}.managed-comment-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.3rem;height:1.3rem;overflow:hidden;border-radius:50%;background:rgb(from var(--muted) r g b / .15);color:var(--muted);font-size:.65rem;font-weight:600;& img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}& img[hidden]{display:none}}.managed-comment-body{grid-column:2;grid-row:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}& a.comment-self-ref{text-decoration:underline dotted;text-underline-offset:2px}& a.comment-self-ref:hover{text-decoration:underline solid}}.managed-comment-time{color:var(--muted);font-size:.7rem;font-weight:400;white-space:nowrap;text-align:right}.managed-comment-meta{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:.5rem;min-height:1.3rem}.managed-comment-actions{display:flex;align-items:center;gap:.15rem}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr) auto;.managed-comment-body{grid-column:1}.managed-comment-meta{grid-column:2}}@container managed-comment (max-width: 28rem){.managed-comment-row:has(.managed-comment-meta){grid-template-columns:minmax(0,max-content) minmax(0,1fr);.managed-comment-meta{grid-column:1 / -1;grid-row:1}.managed-comment-author,.managed-comment-body{grid-row:2}}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr)}.managed-comment-author{max-width:9rem}}
|
|
70
|
-
`});var
|
|
71
|
-
`});var
|
|
72
|
-
`});var Wc={};Nr(Wc,{openFindingHistoryDialog:()=>Zh});function Zh(r){return r.isCurrent()?nt("finding-history-dialog",r):Promise.resolve(null)}var ro,Kc=w(()=>{"use strict";S();B();ae();Lr();Bc();jc();Uc();Hc();Vc();ro=class extends Q{static styles=[...Q.styles,x(qc),x(Fc),x(Gc)];static properties={finding:{attribute:!1},teamId:{attribute:!1},_events:{state:!0},_loading:{state:!0},_error:{state:!0}};constructor(){super(),this._events=[],this._loading=!0,this._error=!1}beforeOpen(){this._load()}async _load(){if(!this.isCurrent()){this._finish(null);return}this._loading=!0,this._error=!1;let{_managedReportId:e,id:t}=this.finding;this._key=`finding-history:${this.teamId??""}:${e}:${t}`,E.invalidate([this._key]);let i=E.load(this._key,"issue history",async s=>{let o=new URLSearchParams({finding:t});this.teamId&&o.set("team",this.teamId);let n=await $(`/api/reports/${encodeURIComponent(e)}/triage/history?${o}`,{credentials:"same-origin",signal:s});if(!n.ok)throw new Error(`History request failed (${n.status})`);let a=await n.json();if(a.finding!==t||!Array.isArray(a.events))throw new Error("Invalid history response");return a.events});this._owner=E.resources.get(this._key),this._signal=this._owner.controller.signal,this._signal.addEventListener("abort",this._onClose,{once:!0});try{let s=await i;if(this._settled||!this.isConnected)return;if(!this.isCurrent()){this._finish(null);return}this._events=s}catch(s){if(this._settled||!this.isConnected)return;s.name==="AbortError"||!this.isCurrent()?this._finish(null):this._error=!0}finally{this._loading=!1}}disconnectedCallback(){this._signal?.removeEventListener("abort",this._onClose),this._owner&&E.resources.get(this._key)===this._owner&&E.invalidate([this._key]),this._events=[],super.disconnectedCallback()}_onKeydown=e=>{e.key==="Escape"&&e.stopPropagation()};_renderEvent(e,t){let i=this._events[t+1],s=Pc(e.entry,i?.entry),o=new Date(e.at),n=e.actorLogin?`@${e.actorLogin}`:"";return c`<li class="event">${e.actorId?Dc(e.actorId,e.actorName||e.actorLogin):c`<span class="managed-comment-avatar" aria-hidden="true">${(e.actorLogin?.[0]||"?").toUpperCase()}</span>`}<div class="event-content"><div class="event-meta"><div class="event-user"><strong>${e.actorName||n||"Unknown user"}</strong> ${e.actorName&&n?c`<span class="username">${n}</span>`:m}</div><time datetime="${o.toISOString()}" data-tooltip="${o.toLocaleString()}">${o.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}</time></div><p class="event-action">${e.entry===null?"Cleared triage":i?"Updated triage":"Recorded triage state"}</p>${s.length>0?c`<dl class="changes">${s.map(a=>c`<div class="change"><dt>${a.label}</dt><dd class="${a.before===void 0?"snapshot":""}">${a.before===void 0?m:c`<span class="before"><span class="sr-only">Previously: </span>${a.before}</span> <span class="change-arrow" aria-hidden="true">→</span>`} <span class="after"><span class="sr-only">${a.before===void 0?"Recorded: ":"Changed to: "}</span>${a.after}</span></dd></div>`)}</dl>`:m}</div></li>`}render(){let e=this.finding??{};return c`<dialog aria-labelledby="history-title" @close="${this._onClose}" @keydown="${this._onKeydown}"><header><div class="history-heading"><h3 id="history-title"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 11a9 9 0 1 1 2.5 7M3 5v6h6M12 7v5l3 2"/></svg>Issue history</h3><p class="location">${e.file}${e.line?`:${e.line}`:""}</p></div><button type="button" class="detail-action" aria-label="Close issue history" @click="${this._onClose}">×</button></header>${!this._loading&&!this._error&&this._events.length>0?c`<div class="history-summary"><span>${this._events.length} ${this._events.length===1?"record":"records"}</span><span>Newest first</span></div>`:m}<div class="history-body" aria-busy="${String(this._loading)}">${this._loading?c`<p class="history-state" role="status">Loading history…</p>`:this._error?c`<div class="history-state" role="alert"><strong>Couldn’t load issue history</strong><p>Close and reopen to try again.</p></div>`:this._events.length===0?c`<div class="history-state" role="status"><strong>No triage changes yet</strong><p>Changes to status, labels, flags, and fixes will appear here.</p></div>`:c`<ol class="timeline">${this._events.map((t,i)=>this._renderEvent(t,i))}</ol>`}</div></dialog>`}};customElements.define("finding-history-dialog",ro)});B();S();ve();S();ae();var T=class extends A{static properties={session:{attribute:!1},allowShare:{attribute:!1},_loading:{state:!0}};constructor(){super(),this.session=null,this.allowShare=!1,this.appState=E,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 q(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>`}te();xt();var $t=class extends re{constructor(e){if(super(e),this.it=m,e.type!==Y.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===m||e==null)return this._t=void 0,this.it=e;if(e===j)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:[]}}};$t.directiveName="unsafeHTML",$t.resultType=1;var P=ye($t);Pr();Dr();_e();var Vn={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="${Pn}"/>`},"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"/>'},"markdown-generic":{className:"brand-markdown",mark:'<path class="fg" d="M4 7h1.2l1.2 1.5L7.6 7h1.2v4H7.6V8.8L6.4 10 5.2 8.8V11H4zm5.6 0h1.2v2.3H12l-1.8 1.8-1.8-1.8h1.2Z"/>'},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"/>'}},Hp={default:["#2563eb","#fff"],"claude-security":["#d97757","#fff"],"codex-security":["#fff","#000"],deepsec:["#000","#fff"],piolium:["#fbb829","#1c1b19"],"markdown-generic":["#374151","#fff"]},Ei=Object.fromEntries(Object.entries(Vn).map(([r,{className:e,mark:t}])=>{let[i,s]=Hp[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>`]})),Ai=Object.fromEntries(Object.entries(Vn).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>`]));function tt(r){let e=r.toLowerCase();if(e.endsWith(".generic-md")){let t=r.slice(0,-11);try{return decodeURIComponent(t)}catch{return t}}return e.endsWith(".codex")?r.slice(0,-6).replaceAll("__","/"):r}_e();S();_e();var qp=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-deduplication","Deduplication","admin"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function U(r,e,t=!1){return c`<header class="manage-header"><nav class="manage-nav" aria-label="Management pages">${qp.filter(([i,,s])=>(s==null||s===e)&&(i!=="manage-links"||t)).map(([i,s])=>c`<button type="button" aria-current="${r===i?"page":m}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:i},bubbles:!0,composed:!0}))}}">${s}</button>`)}</nav></header>`}function D(r){if(r==="bundle")return P(we);if(r==="report"||r==="preview")return P(et);if(r==="scan")return P(Dn);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":m}" 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>`}S();S();te();xt();dr();var G=ye(class extends re{constructor(r){if(super(r),r.type!==Y.PROPERTY&&r.type!==Y.ATTRIBUTE&&r.type!==Y.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Kn(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===j||e===m)return e;let t=r.element,i=r.name;if(r.type===Y.PROPERTY){if(e===t[i])return j}else if(r.type===Y.BOOLEAN_ATTRIBUTE){if(!!e===t.hasAttribute(i))return j}else if(r.type===Y.ATTRIBUTE&&t.getAttribute(i)===e+"")return j;return it(r),e}});var F=class extends A{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=z`:host{display:block;min-width:0}:host,.menu{-webkit-app-region:no-drag;app-region:no-drag}*{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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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(),this.dispatchEvent(new CustomEvent("tooltip-root-connected",{bubbles:!0,composed:!0})),window.addEventListener("resize",this._onViewport),window.addEventListener("scroll",this._onViewport,!0),this._scrollRoots=[];for(let e=this.getRootNode();e.host;e=e.host.getRootNode())e.addEventListener("scroll",this._onViewport,!0),this._scrollRoots.push(e)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onViewport),window.removeEventListener("scroll",this._onViewport,!0);for(let e of this._scrollRoots??[])e.removeEventListener("scroll",this._onViewport,!0);this._scrollRoots=[]}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):m}<span class="name" data-tooltip-truncated data-tooltip="${e?.label??m}">${e?.label??this.placeholder}</span>${e?.detail?c`<span class="detail">${e.detail}</span>`:m} <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="${G(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" aria-pressed="${t.activeFacet===n.value}" @click="${()=>this._filterFacet(n.value)}"><span class="name" data-tooltip-truncated data-tooltip="${n.name}">${n.name}</span><span class="count">${n.count}</span></button>`)}</div>`:m}<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>`:m} ${t.sections.map((n,a)=>c`<div class="group" role="group" aria-labelledby="${n.label?`selector-group-${a}`:m}">${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>`:m}${n.label}</h3>`:m} ${n.options.map(l=>this._option(l,n.organization,o))}</div>`)} ${t.count?m:c`<p class="empty">${this.options.length>0?this.noMatchesLabel:this.emptyLabel}</p>`}</div></div></div>`}optionIcon(e){return e.initials?c`<span class="avatar" aria-hidden="true">${e.initials}</span>`:m}optionTooltip(e){return e.label}_option(e,t,i){let s=e.displayLabel??(t?e.name:e.label),o=this.optionTooltip(e);return c`<button type="button" class="option" role="option" ?data-reset="${e.reset}" ?disabled="${e.disabled}" aria-label="${e.label}" 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)}<span class="option-copy"><span class="name" ?data-tooltip-truncated="${s===o}" data-tooltip="${o}">${s}</span>${e.secondary?c`<span class="secondary" data-tooltip-truncated data-tooltip="${e.secondary}">${e.secondary}</span>`:m}</span>${e.detail?c`<span class="detail">${e.detail}</span>`:m}</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 Mi=class extends F{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."}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",Mi);var kt=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>`:m}renderPanel(e){if(!this.open)return m;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>`:m} ${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>`:m} ${this.success?c`<p class="local-import-message" role="status">${this.success}</p>`:m}</section>`}};B();ae();ve();function Jn(r){let e;for(let t of r){let i=t.split("/");if(i.some(s=>!s||s==="."||s==="..")||t.includes("\\"))return"";if(i.pop(),e===void 0)e=i;else{let s=0;for(;s<e.length&&s<i.length&&e[s]===i[s];)s++;e.length=s}if(e.length===0)return""}return e?.join("/")??""}async function Wp({signal:r}={}){r=r?AbortSignal.any([r,E.sessionController.signal]):E.sessionController.signal,r.throwIfAborted();let e=await $("/api/admin/bundles",{credentials:"same-origin",signal:r});if(r.throwIfAborted(),!e.ok)throw Object.assign(new Error(`Bundle catalogue request failed (${e.status})`),{status:e.status});let t=await e.json();return r.throwIfAborted(),t.bundles??[]}async function pr(r,e,t){let i=E.generation,s=await $(`/api/bundles/${encodeURIComponent(r)}/${e}`,{credentials:"same-origin",signal:t});if(t?.throwIfAborted(),!s.ok)throw Object.assign(new Error(`Bundle ${e} request failed (${s.status})`),{status:s.status});let o=e==="contents"?await s.text():await s.json();if(t?.throwIfAborted(),i!==E.generation)throw new DOMException("Managed session changed","AbortError");return o}function Ii(r,{signal:e}={}){return E.load(`bundle-metadata:${r}`,"bundle metadata",t=>pr(r,"metadata",t),{signal:e,retryInvalidated:!0})}async function Yn(r,{signal:e}={}){e=e?AbortSignal.any([e,E.sessionController.signal]):E.sessionController.signal;let t=await pr(r,"metadata",e),i=t?.bundle?.repo??null,s=Xe({repo:i});if(!s)return i;let o=new URLSearchParams({repo:s,directory:i.directory??""}),n=new Set(t.unsized??[]),a=Jn((t.files??[]).filter(([u,p])=>p!=null||n.has(u)).map(([u])=>u));a&&o.set("filePrefix",a);let l=await $(`/api/admin/repositories/resolve?${o}`,{credentials:"same-origin",cache:"no-store",signal:e});if(e.throwIfAborted(),!l.ok)throw new Error(`Repository suggestion request failed (${l.status})`);let{location:d}=await l.json();return e.throwIfAborted(),d?{...i,github:d.github,...d.mapped?{directory:d.directory}:{},repoId:d.repoId}:i}async function Kp(r,{signal:e}={}){e=e?AbortSignal.any([e,E.sessionController.signal]):E.sessionController.signal;try{return await pr(r,"contents",e)}catch(t){throw t.name!=="AbortError"&&E.notify(`Couldn't load bundle contents: ${t.message}`),t}}function Zp(r,e,t="",i=!1,s=!1){let o=[e?`team=${encodeURIComponent(e)}`:"",t?`reason=${encodeURIComponent(t)}`:"",i?"repoAdvisories=true":"",s?"details=true":""].filter(Boolean).join("&"),n=`advisories${o?`?${o}`:""}`;return pr(r,n,E.sessionController.signal)}ve();function Xn(r,e){let t=rr(r);if(t===null)return null;let i=e.replace(/\.(?:md|markdown)$/iu,""),s=new Set;return t.map(({displayName:o,data:n})=>{let a=`${i}: ${o}`.replaceAll("%","%25").replaceAll(/[\\/\p{Cc}]/gu,"_")+".generic-md";if(s.has(a))throw new Error(`Markdown (generic): products produce the same report name: ${a}`);return s.add(a),{name:a,content:JSON.stringify(n)}})}B();async function $e(r,e){let t=await $(r,{signal:e,credentials:"same-origin",headers:{accept:"application/json"}});if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}function ke(r,e,t){let i={"content-type":"application/json"};return e&&(i["x-csrf-token"]=e),$(r,{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify(t)})}async function Qn(r,e,t){let i=t?{"x-csrf-token":t}:{},s=await $(`/api/admin/${r}/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin",headers:i});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function ea(r,e,t,i,s,o){let n=new URLSearchParams({page:String(e),limit:"100",kind:t,q:i.trim()});s&&n.set("repo",s),o&&n.set("actor",o);let a=await $e(`/api/admin/history?${n}`,r);if(!Array.isArray(a?.history)||!Number.isSafeInteger(a.total)||a.total<0||!Number.isSafeInteger(a.page)||a.page<1)throw new Error("No history returned");return a}async function ta(r){let e=await $e("/api/admin/users",r);return Array.isArray(e?.users)?e.users:[]}async function ra(r,e,t){let i=await ke("/api/admin/set-role",t,{userId:r,role:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ia(r,e,t,i){let s=new URLSearchParams({scope:r});return r==="installed"&&s.set("showAll",String(e)),t&&s.set("refresh","true"),await $e(`/api/admin/repositories?${s}`,i)}async function sa(r,e,t){let i=await ke("/api/admin/repositories/select",t,{repoId:r,selected:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function oa(r,e){let t=await $("/api/admin/repositories/add-public",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify({repository:r})});if(!t.ok){let i={400:"Enter a repository as owner/repo or a GitHub repository URL.",403:"You do not have permission to add arbitrary public repositories.",404:"No public repository was found at that address.",409:"Choose a public, non-archived repository."};throw new Error(i[t.status]??`GitHub lookup failed (HTTP ${t.status}). Try again.`)}}async function na(r,e){let t=await $e(`/api/admin/repositories/impact?repoId=${encodeURIComponent(r)}`,e);if(t?.repoId!==r||!Array.isArray(t.reports)||!Array.isArray(t.bundles)||!Number.isSafeInteger(t.triageCount)||t.triageCount<0)throw new Error("Invalid repository data");return t}async function aa(r,e){let t=await $("/api/admin/repositories/connect-app",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify({repoId:r})}),i=await t.json();if(!t.ok){let s={"github-app-not-configured":"The GitHub App is not configured on this server.","repo-identity-changed":"The repository has changed on GitHub. Refresh and check its connection.","repo-connection-changed":"The connection or your permissions changed. Refresh and try again.","repo-not-connected":"This repository is no longer connected.",forbidden:"Administrator access is required to connect the GitHub App."};throw new Error(s[i.error]??`Could not connect the GitHub App (HTTP ${t.status}). Try again.`)}if(i.connected===!0)return i;if(i.connected!==!1||typeof i.installUrl!="string"||!/^https:\/\/github\.com\/apps\/[^/?#]+\/installations\/new$/u.test(i.installUrl))throw new Error("Invalid GitHub installation response.");return i}async function la(r,e,t,i){let s=await ke("/api/admin/repositories/remove",i,{repoId:r,fullName:e,acknowledge:!0,deleteTriage:t});if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async function ca(r){return await $e("/api/admin/reports",r)}async function da(r,e,t){let i=await $("/api/admin/bundles/create",{method:"POST",credentials:"same-origin",signal:t,headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify(r)}),s=await i.json();if(!i.ok){let o={"unsupported-entries":"Select JavaScript/TypeScript files (including JSX/TSX) or Solidity files. Stasis cannot mix languages or use JSON or Rust as remote entry points.","bad-conditions":"Check the export conditions and selected platforms.","metro-conditions":"Stasis\u2019s Metro preset requires the react-native condition without manual changes.","build-lockfile":"Stasis needs a supported lockfile: pnpm-lock.yaml, yarn.lock (Yarn 1), package-lock.json, or soldeer.lock.","build-scope":"Your team needs access to the bundle\u2019s project root, including its lockfile and dependencies.","build-busy":"A bundle is already being built, or the server is busy. Try again shortly.","build-timeout":"The bundle build timed out. Try a smaller selection or retry.","too-large":"This bundle exceeds the server\u2019s size limit.","github-rate-limited":"GitHub\u2019s API rate limit has been reached. Retry after the limit resets.","github-build-failed":"Could not fetch the repository from GitHub. Check access and retry.","repository-changed":"The repository connection changed during the build. Reload and try again.","bundle-conflict":"This bundle already exists but is outside your current access.","build-failed":"Stasis could not build this selection. Check that its lockfile is supported and all entry points and imports exist at this commit."};throw new Error(o[s.error]??(i.status===401?"Sign in again to create a bundle.":i.status===403||i.status===404?"Repository access is required to create this bundle.":"Could not create the bundle. Try again."))}return s}async function zi(r,e,t=null,i=""){let s=(await $e("/api/config")).managed?.uploadMaxBytes?.reports;if(Number.isSafeInteger(s)&&s>0){if(r.size>s)throw new Error("too large")}else if(r.size>3*1024*1024)return Li(r,e,t,i);let o=Xn(await r.text(),r.name);if(!o)return Li(r,e,t,i);let n=[];for(let{name:a,content:l}of o)n.push(await Li(new File([l],a,{type:"application/json"}),e,t,i));return n.at(-1)}async function Li(r,e,t,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 $("/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=await o.json().catch(()=>null);if(n?.error==="storage-encryption-required")throw new Error("Link reports require managed storage encryption. Configure MANAGED_STORAGE_ENCRYPTION_KEY.");if(n?.error==="invalid-report")throw new Error(typeof n.reason=="string"&&n.reason?`This file is not a report: ${n.reason}`:"This file is not a recognized report.");let a=n?.error==="repo-not-connected"&&typeof n.repo=="string"?`: ${n.repo} is not connected`:"";throw new Error(`HTTP ${o.status}${a}`)}return o.json()}async function pa(r,e,t){let i=await ke("/api/admin/reports/set-visible",t,{reportId:r,visible:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ua(r,e,t,i){let s=await ke("/api/admin/reports/set-repo",i,{reportId:r,repoId:e,directory:t});if(!s.ok)throw s.status===409?new Error("this report already defines its repository"):s.status===403?new Error("choose a repository and directory within your team access"):new Error(s.status===400?"invalid repository or directory":`HTTP ${s.status}`);return s.json()}async function ha(r,e){await Qn("reports",r,e)}async function Oi(r){return await $e("/api/admin/bundles",r)}async function Ti(r,e,t,i=""){let s={"content-type":"application/octet-stream","x-bundle-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 $("/api/admin/bundles",{method:"POST",credentials:"same-origin",headers:s,body:r});if(!o.ok)throw new Error(o.status===413?"too large":o.status===403?"choose a repository and directory within your team access":`HTTP ${o.status}`);return o.json()}async function ma(r,e){await Qn("bundles",r,e)}async function fa(r,e,t){let i=await ke("/api/admin/bundles/set-visible",t,{bundleId:r,visible:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ga(r,e,t,i){let s=await ke("/api/admin/bundles/set-repo",i,{bundleId:r,repoId:e,directory:t});if(!s.ok)throw new Error(s.status===403?"choose a repository and directory within your team access":s.status===400?"invalid repository or directory":`HTTP ${s.status}`)}async function Ni(r){return await $e("/api/admin/teams",r)}async function ie(r,e,t){let i=await ke(r,e,t);if(!i.ok)throw new Error(i.status===409?"name already taken":`HTTP ${i.status}`)}function St(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 Ct(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 Pi(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)}}async function Rt(r,e,t,i){if(e.length!==0&&(r._queue.push(...e),!r._busy)){r._busy=!0,r._error=null;try{for(;r._queue.length>0;){let s=r._queue.shift();await r.appState.mutate(()=>t(s),i)}}catch(s){r._queue=[],r._error=`Upload failed: ${String(s?.message??s)}`}finally{r._busy=!1,await r._load({preserveError:!0})}}}var Bi=`.local-import-toggle{flex-shrink:0;margin-block:calc(-.25rem - 1px);margin-left:auto;padding:.25rem .6rem;border:1px solid var(--border);border-radius:var(--ui-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:var(--ui-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:var(--ui-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)}
|
|
73
|
-
`;var N=`:host{display:flex;flex-direction:column;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:
|
|
74
|
-
`;var
|
|
75
|
-
`;var
|
|
76
|
-
`;var
|
|
77
|
-
`;var wa=`.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:var(--ui-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}.repository-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-left:auto;margin-block:calc(-.45rem - 1px)}.breadcrumb{flex-wrap:wrap}.breadcrumb .breadcrumb-current{margin:0;color:var(--text);font-size:.85rem;font-weight:500}.public-repository-form{padding:1rem;margin:-1rem 0 1.5rem;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--panel)}.public-repository-form .confirm-field{margin:0}.search{flex:1 1 14rem;max-width:25rem;margin-right:auto}.search input{width:100%}.show-all,.show-all-paper{align-items:center;gap:.5rem;white-space:nowrap;font-size:.78rem}.show-all{display:var(--switch-button-display, inline-flex)}.show-all-paper{display:var(--switch-checkbox-display, none);& input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent)}}.show-all input{appearance:none;width:2rem;height:1.15rem;margin:0;padding:2px;border:1px solid var(--border);border-radius:var(--ui-radius, 1rem);background:var(--surface-active)}.show-all input:before{content:"";display:block;width:.775rem;height:.775rem;border-radius:50%;background:var(--muted)}.show-all input:checked{border-color:var(--accent);background:var(--accent)}.show-all input:checked:before{transform:translate(.85rem);background:var(--bg)}.show-all input:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.repository-count{margin:-.8rem 0 .6rem;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}.repository-browser{display:flex;overflow:hidden;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--panel)}.organization-list{flex:0 0 12rem;padding:.4rem;border-right:1px solid var(--border);background:rgb(from var(--bg) r g b / .25)}.organization{display:flex;align-items:center;gap:.5rem;width:100%;padding:.5rem;border:0;border-radius:var(--ui-radius, 4px);color:var(--text);background:transparent;text-align:left;font-size:.76rem;cursor:default}.organization:hover{background:rgb(from var(--text) r g b / .05)}.organization[aria-pressed=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.organization-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.organization-count{color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums}.repo-results{flex:1;min-width:0}.organization-list,.repo-results{max-height:min(65vh,40rem);overflow:auto;overscroll-behavior:contain}.repo-group+.repo-group{border-top:1px solid var(--border)}.owner-head{position:sticky;top:0;z-index:1;display:flex;align-items:center;gap:.6rem;margin:0;padding:.55rem .85rem;color:var(--muted);background:var(--panel);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:var(--ui-radius, 5px);background:var(--surface);text-transform:uppercase;font-size:.75rem}.repos{margin:0;padding:0;list-style:none}.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}.btn.connect-app{min-height:1.9rem;padding:.3rem .6rem;font-size:.72rem}.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:var(--ui-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;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}.section{margin-top:1.75rem;border:1px solid var(--border);border-radius:var(--ui-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:var(--ui-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:var(--ui-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;overflow-wrap:anywhere}.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:var(--ui-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-line span{min-width:0}.confirm-field{display:grid;gap:.5rem;margin-top:1.1rem;color:var(--text);font-size:.78rem;line-height:1.5;overflow-wrap:anywhere}.confirm-name{width:100%;min-width:0;padding:.45rem .55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font:inherit;font-size:.78rem}.dialog-actions{display:flex;flex-wrap:wrap;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){.organization-list{flex-basis:9rem}.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}@container (max-width: 28rem){.repository-browser{flex-direction:column}.organization-list{display:flex;flex:0 0 auto;gap:.25rem;border-right:0;border-bottom:1px solid var(--border)}.organization{flex:0 0 auto;width:auto;max-width:12rem}}
|
|
68
|
+
`,u=r.body+p+i.text,f=r.body.length+p.length;return{body:u,sections:r.sections.map(b=>b===i?{...b,selected:t,separator:p,start:f,end:u.length}:b)}}let s=r.body.slice(i.start,i.end),o=i.separator??"",n=i.start-o.length,l=r.body.slice(n,i.start)===o&&!r.sections.some(p=>p!==i&&p.selected&&p.start<i.start&&p.end>n)?n:i.start,d=r.body.slice(0,l)+r.body.slice(i.end),m=l-i.end;return{body:d,sections:r.sections.map(p=>p===i?{...p,text:s,selected:t,start:0,end:0}:p.selected&&p.start>=i.end?{...p,start:p.start+m,end:p.end+m}:p)}}var Tr,Ic,Hh,zc=_(()=>{"use strict";ve();Tr=[["impact","Impact"],["evidence","Evidence"],["reproduction","Reproduction"],["recommendation","Recommendation"],["confidenceReason","Confidence reason"],["revalidateVerdict","Revalidation verdict"],["revalidateRecommendation","Revalidation recommendation"]],Ic=r=>r.toLowerCase().replaceAll(/[^\p{L}\p{N}]/gu,""),Hh=new Map([...Tr.map(([r,e])=>[Ic(e),r]),["reproductionsteps","reproduction"],["recommendedfix","recommendation"]])});var Tc,Oc=_(()=>{Tc=`dialog{max-width:1040px;width:min(1040px,calc(100vw - 32px));margin-top:2rem;max-height:calc(100dvh - 4rem);overflow:hidden}dialog[open]{display:flex;flex-direction:column}header,.nwd-actions{flex-shrink:0}.dialog-content{min-height:0;overflow:auto;scrollbar-gutter:stable;padding:3px}.nwd-intro{overflow-wrap:anywhere}label{display:flex;flex-direction:column;gap:6px;margin:12px 0}textarea{min-height:clamp(240px,45dvh,540px);resize:vertical;line-height:1.55}.description-heading{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;margin:16px 0 6px}.description-heading label{margin:0}.description-sections{display:flex;flex:1;flex-wrap:wrap;justify-content:flex-end;gap:6px}.description-sections label{flex-direction:row;align-items:center;font-size:.8rem;line-height:1.3;cursor:default;padding:5px 8px;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);color:var(--muted);background:var(--surface)}.description-sections label:has(input:checked){color:var(--text);border-color:color-mix(in srgb,var(--accent) 65%,var(--border));background:color-mix(in srgb,var(--accent) 10%,var(--surface))}.description-sections label:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:2px}.description-sections label:has(input:disabled){opacity:.55}.description-sections input{accent-color:var(--accent);flex-shrink:0}.description-help{margin:0 0 8px}.nwd-actions{flex-wrap:wrap}.nwd-actions a{font-size:.8rem}@media(width<=600px){dialog{margin-top:1rem;max-height:calc(100dvh - 2rem)}.description-sections{flex-basis:100%;justify-content:flex-start}}a{color:var(--accent)}.created-issue{padding:16px;border:1px solid var(--border);border-radius:var(--ui-radius, 8px)}.issue-heading{display:flex;align-items:center;gap:8px;margin-bottom:12px}.issue-status{padding:3px 10px;border-radius:20px;background:#238636;color:#fff;font-size:.8rem}.issue-status.closed{background:#8250df}.issue-status.not_planned,.issue-status.duplicate,.issue-status.unknown{background:#656d76}.issue-number{color:var(--muted)}h4{font-size:1.15rem;line-height:1.4;overflow-wrap:anywhere}.issue-description{margin-top:16px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:40vh;overflow:auto;line-height:1.5;font-size:.9rem}.issue-labels{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.issue-labels span{border:1px solid var(--border);border-radius:12px;padding:2px 8px;font-size:.75rem}.para+.para,.md-list{margin-top:.75em}.md-list{padding-left:1.5em}.inline-code,.code-block{font-family:monospace;background:var(--bg, var(--surface));border-radius:4px}.inline-code{padding:1px 4px}.code-block{white-space:pre;overflow:auto;padding:10px;margin:10px 0}
|
|
69
|
+
`});var Nc={};Nr(Nc,{openManagedIssueDialog:()=>Vh});function Vh(r){return nt("managed-issue-dialog",r)}var eo,to,Pc=_(()=>{"use strict";S();Ac();Lr();zc();Oc();eo={"github-unavailable":"GitHub could not be reached. Try checking again.","github-issue-forbidden":"GitHub did not permit issue creation. Check your repository access and authorization.","github-create-uncertain":"GitHub may have created this issue. Check the repository before trying again.","github-create-failed":"GitHub could not create the issue. Check the title and description before trying again.",unauthenticated:"Your session expired. Sign in again before creating an issue.","workspace-changed":"Your workspace access changed. Reopen the finding before creating an issue.","bad-issue-repository":"The finding\u2019s repository changed. Reopen the finding before creating an issue.","no-finding":"This finding is no longer available in this workspace."},to=class extends Q{static styles=[...Q.styles,$(Tc)];static properties={teamId:{attribute:!1},context:{attribute:!1},session:{attribute:!1},formUrl:{attribute:!1},title:{state:!0},body:{state:!0},prepared:{state:!0},busy:{state:!0},creating:{state:!0},message:{state:!0},uncertain:{state:!0},createdUrl:{state:!0},createdIssue:{state:!0},detailsUnavailable:{state:!0},sections:{state:!0}};constructor(){super(),this.title="",this.body="",this.prepared=null,this.busy=!1,this.creating=!1,this.message="",this.uncertain=!1,this.createdUrl="",this.createdIssue=null,this.detailsUnavailable=!1,this.sections=[]}beforeOpen(){this.finding&&Object.assign(this,Mc(this.finding,this.draftOptions)),this.check(!0)}editBody(e){Object.assign(this,Lc(this,e))}toggleSection(e,t){Object.assign(this,Qs(this,e,t))}current(){return!this._settled&&this.isCurrent()}fallbackUrl(){let e=new URL(this.formUrl);return e.searchParams.set("title",this.title),e.searchParams.set("body",this.body),this.prepared?.labels&&e.searchParams.set("labels",this.prepared.labels.join(",")),e.href}async check(e=!1){if(!(this.busy||!this.current())){this.busy=!0,this.message="";try{let t=await Xs(this.teamId,this.context,this.session.csrfToken);if(!this.current())return;this.prepared=t,this.uncertain=!1,t.mode==="existing"&&(this.onCreated?.(t.url),window.location.assign(t.url)),e&&t.mode==="form"&&window.location.assign(this.fallbackUrl())}catch(t){!this.uncertain&&!["pending","created-unavailable"].includes(this.prepared?.mode)&&(this.prepared=null),this.message=eo[t.message]??"Unable to check this issue. Please retry."}finally{this.busy=!1}}}async create(){if(!(this.busy||this.uncertain||this.createdUrl||this.prepared?.mode!=="api")){if(!this.current()){this.message=eo["workspace-changed"],this.prepared=null;return}this.busy=!0,this.creating=!0,this.message="";try{let e=await Xs(this.teamId,this.context,this.session.csrfToken,{title:this.title,body:this.body});if(!this.current())return;e.mode==="existing"?(this.onCreated?.(e.url),window.location.assign(e.url)):e.url?(this.createdUrl=e.url,this.createdIssue=e.issue,this.detailsUnavailable=e.detailsUnavailable===!0,this.onCreated?.(e.url)):this.prepared=e}catch(e){e.message==="github-authorization-required"?this.prepared={mode:"authorize",authorizationPath:"/api/oauth/github/issues/login"}:(this.uncertain=e.message==="github-create-uncertain",["workspace-changed","bad-issue-repository","no-team","no-report","no-finding","unauthenticated","forbidden"].includes(e.message)&&(this.prepared=null),this.message=eo[e.message]??"Could not create this issue. Check the title, description, and repository access.")}finally{this.busy=!1,this.creating=!1}}}render(){let e=this.createdIssue,t=this.prepared,i=t?.mode==="created-unavailable",s=this.createdUrl||i,o=this.uncertain||t?.mode==="pending",n=this.creating||o,a=!this.busy&&!o&&t?.mode==="form";return c`<dialog aria-labelledby="issue-dialog-title" @close="${this._onClose}" @cancel="${l=>{this.creating&&l.preventDefault()}}"><header><h3 id="issue-dialog-title">${s?"Issue created":"Create a GitHub issue"}</h3></header><div class="dialog-content"><p class="nwd-intro">${s?"Created":"Create"} in <strong>${this.context?.repository}</strong> as <strong>@${this.session?.login}</strong>.</p>${this.createdUrl?c`<section class="created-issue" aria-label="Created GitHub issue"><div class="issue-heading"><span class="${`issue-status ${e?.status??"open"} ${e?.stateReason??""}`}">${e?.status==="closed"?e.stateReason==="not_planned"?"Not planned":e.stateReason==="duplicate"?"Duplicate":e.stateReason==="completed"?"Completed":"Closed":"Open"}</span> <span class="issue-number">${e?.number?`#${e.number}`:""}</span></div><h4><a href="${this.createdUrl}" target="_blank" rel="noopener">${e?.title??this.title}</a></h4><p class="nwd-note">Opened by @${e?.author??this.session?.login}</p>${e?.labels?.length?c`<div class="issue-labels">${e.labels.map(l=>c`<span>${l}</span>`)}</div>`:h}<div class="issue-description">${this.renderBody?this.renderBody(e?.description??this.body):e?.description??this.body}</div><p class="nwd-note ui-hint">Linked permanently to this finding. The Issue button will open this issue next time.</p>${this.detailsUnavailable?c`<p class="nwd-note">GitHub’s latest details could not be loaded. The issue was created and its link is saved.</p>`:h}</section>`:i?c`<p role="status">The issue was created and linked permanently to this finding. Its details cannot be shown because workspace access could not be confirmed. Check its status again once workspace access is available.</p>`:c`<label>Title<input class="nwd-input" maxlength="256" .value="${this.title}" ?disabled="${n}" @input="${l=>{this.title=l.target.value}}"></label><div class="description-heading"><label for="issue-description">Description</label> ${this.sections.length>0?c`<div class="description-sections" role="group" aria-label="Include in description">${this.sections.map(l=>c`<label><input type="checkbox" .checked="${l.selected}" ?disabled="${n}" @change="${d=>this.toggleSection(l.id,d.target.checked)}">${l.label}</label>`)}</div>`:h}</div><p id="description-help" class="nwd-note description-help ui-hint">${this.sections.length>0?"Add or remove sections above. Your edits are kept when toggling them.":"Edit the description before creating the issue."}</p><textarea id="issue-description" class="nwd-input" maxlength="65536" .value="${this.body}" aria-describedby="description-help" ?disabled="${n}" @input="${l=>this.editBody(l.target.value)}"></textarea> ${t?.labels?.length?c`<p class="nwd-note">Labels: ${t.labels.join(", ")}</p>`:h} ${t?.mode==="permissions"?c`<p>Ask a repository owner to approve the app’s Issues read and write permission. ${t.authorizationPath?c`<a href="${t.authorizationPath}" target="_blank" rel="noopener">Review repository permissions</a>`:h}</p>`:h} ${t?.mode==="authorize"?c`<p><a href="${t.authorizationPath}" target="_blank" rel="noopener">Authorize GitHub</a>, then check authorization here.</p>`:h} ${t?.mode==="pending"?c`<p role="status">An issue is being created, or its creation could not be confirmed. Check its status before continuing; another issue will not be created.</p>`:h} ${t?.mode==="unavailable"?c`<p role="status">This finding already has a managed issue in a repository outside this workspace.</p>`:h}`} ${!this.createdUrl&&this.message?c`<p class="nwd-note" role="status">${this.message}</p>`:h} ${!this.createdUrl&&this.busy?c`<p role="status">${this.creating?"Creating issue\u2026":"Checking repository access\u2026"}</p>`:h}</div><footer class="nwd-actions">${this.createdUrl?c`<a href="${this.createdUrl}" target="_blank" rel="noopener">Open issue on GitHub</a>`:!this.busy&&o?c`<a href="${t?.repositoryUrl??`https://github.com/${this.context?.repository}/issues`}" target="_blank" rel="noopener">Check repository issues</a>`:a?c`<a href="${this.fallbackUrl()}" target="_blank" rel="noopener">Use GitHub form</a>`:h} <span class="nwd-spacer"></span> ${!this.createdUrl&&t?.mode!=="unavailable"?t?.mode==="api"&&!this.uncertain?c`<button class="primary" ?disabled="${this.busy||!this.title.trim()}" @click="${this.create}">Create issue</button>`:c`<button ?disabled="${this.busy}" @click="${()=>this.check()}">${o||i?"Check issue status":"Check authorization"}</button>`:h} <button ?disabled="${this.creating}" @click="${()=>this._finish(null)}">${s?"Close":"Cancel"}</button></footer></dialog>`}};customElements.define("managed-issue-dialog",to)});function Bc(r,e){return e==="triage"?Wh[r?.triage]??"Untriaged":e==="flagged"?r?.flagged?"Yes":"No":r?.[e]||"None"}function Dc(r,e){return Object.entries(Gh).flatMap(([t,i])=>{let s=Bc(r,t);if(e===void 0)return r?.[t]===void 0?[]:[{label:i,after:s}];let o=Bc(e,t);return o===s?[]:[{label:i,before:o,after:s}]})}var Gh,Wh,jc=_(()=>{"use strict";Gh={triage:"Status",color:"Label",flagged:"Flagged",fix:"Fix",comment:"Comment"},Wh={inprogress:"In progress",fixed:"Fixed",invalid:"Invalid",deleted:"Deleted",ignored:"Ignored"}});function Uc(r,e){return r?Rr(r,c`<span class="managed-comment-avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${ee()?h:c`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" loading="lazy" @error="${t=>{t.currentTarget.hidden=!0}}">`}</span>`):h}var Fc=_(()=>{"use strict";Ot();S();Cs()});var qc,Hc=_(()=>{qc=`.managed-comment{container:managed-comment / inline-size;white-space:normal}.managed-comment-row{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr) auto;align-items:start;gap:.35rem .65rem;line-height:1.5}.managed-comment-author{grid-column:1;grid-row:1;display:flex;align-items:center;gap:.45rem;min-width:0;max-width:14rem;& strong{overflow:hidden;text-overflow:ellipsis;font-weight:600}}.managed-comment-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.3rem;height:1.3rem;overflow:hidden;border-radius:50%;background:rgb(from var(--muted) r g b / .15);color:var(--muted);font-size:.65rem;font-weight:600;& img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}& img[hidden]{display:none}}.managed-comment-body{grid-column:2;grid-row:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;& a{color:var(--accent);text-decoration:none}& a:hover{text-decoration:underline}& a.comment-self-ref{text-decoration:underline dotted;text-underline-offset:2px}& a.comment-self-ref:hover{text-decoration:underline solid}}.managed-comment-time{color:var(--muted);font-size:.7rem;font-weight:400;white-space:nowrap;text-align:right}.managed-comment-meta{grid-column:3;grid-row:1;justify-self:end;display:flex;align-items:center;gap:.5rem;min-height:1.3rem}.managed-comment-actions{display:flex;align-items:center;gap:.15rem}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr) auto;.managed-comment-body{grid-column:1}.managed-comment-meta{grid-column:2}}@container managed-comment (max-width: 28rem){.managed-comment-row:has(.managed-comment-meta){grid-template-columns:minmax(0,max-content) minmax(0,1fr);.managed-comment-meta{grid-column:1 / -1;grid-row:1}.managed-comment-author,.managed-comment-body{grid-row:2}}.managed-comment-row:not(:has(.managed-comment-author)){grid-template-columns:minmax(0,1fr)}.managed-comment-author{max-width:9rem}}
|
|
70
|
+
`});var Gc,Vc=_(()=>{Gc=`.detail-action{width:22px;height:22px;display:grid;place-items:center;padding:0;background:transparent;border:0;border-radius:var(--ui-radius, 4px);color:var(--muted);font:500 16px/1 ui-monospace,monospace;cursor:default;&:hover{color:var(--accent);background:var(--surface-active)}&:focus-visible{outline:2px solid var(--accent);outline-offset:1px}}
|
|
71
|
+
`});var Kc,Wc=_(()=>{Kc=`dialog{width:min(94vw,720px);max-width:720px;max-height:calc(100dvh - 4rem);margin-block:2rem;padding:0;overflow:hidden;background:rgb(from var(--surface) r g b / 1)}dialog[open]{display:flex;flex-direction:column}header{display:flex;align-items:start;justify-content:space-between;gap:1rem;padding:.75rem 1rem;border-bottom:1px solid var(--border);flex:none}.history-heading{min-width:0}header h3{display:flex;align-items:center;gap:.55rem;margin:0;line-height:1.5}header svg{flex:none;color:var(--muted)}header .detail-action{flex:none;width:1.75rem;height:1.75rem}.location{margin-top:.4rem;color:var(--muted);font:.76rem/1.5 ui-monospace,monospace;overflow-wrap:anywhere}.history-summary{display:flex;justify-content:space-between;gap:.5rem;flex:none;padding:.5rem 1rem .25rem;color:var(--muted);font-size:.72rem}.history-body{min-height:0;overflow:auto;overscroll-behavior:contain;padding:.75rem 1rem 1rem;font-size:.82rem;line-height:1.5}.timeline{list-style:none}.event{position:relative;display:grid;grid-template-columns:2rem minmax(0,1fr);gap:.75rem;padding-bottom:1rem}.event:last-child{padding-bottom:0}.event:not(:last-child):before{content:"";position:absolute;top:2.4rem;bottom:.4rem;left:calc(1rem - .5px);width:1px;background:var(--border)}.managed-comment-avatar{width:2rem;height:2rem;font-size:.8rem;background:var(--surface-active)}.event-content{min-width:0}.event-meta{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:.15rem .75rem}.event-user{display:flex;flex-wrap:wrap;align-items:baseline;gap:.1rem .45rem;min-width:0;overflow-wrap:anywhere}.event-user strong{font-weight:600}.username{color:var(--muted);font-size:.75rem}time{color:var(--muted);font-size:.7rem;white-space:nowrap}.event-action{margin-top:.1rem;color:var(--muted);font-size:.75rem}.changes{margin-top:.65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);overflow:hidden}.change{display:grid;grid-template-columns:4.5rem minmax(0,1fr);align-items:baseline;gap:.65rem;padding:.4rem .6rem}.change+.change{border-top:1px solid var(--border)}dt{color:var(--muted);font-size:.75rem}dd{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:baseline;gap:.65rem}dd.snapshot{grid-template-columns:minmax(0,1fr)}.before,.after{white-space:pre-wrap;overflow-wrap:anywhere}.before,.change-arrow{color:var(--muted)}.after{font-weight:500}.history-state{padding:1.5rem .5rem;text-align:center;color:var(--muted)}.history-state strong{display:block;margin-bottom:.35rem;color:var(--text);font-weight:500}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media(width<=540px){dialog{margin-block:1rem;max-height:calc(100dvh - 2rem)}header{padding:.65rem}.history-summary{padding-inline:.65rem}.history-body{padding:.65rem}.event{gap:.6rem}.event-meta{flex-direction:column}.change{grid-template-columns:minmax(0,1fr);gap:.3rem;padding:.35rem .5rem}dd{gap:.45rem}}
|
|
72
|
+
`});var Zc={};Nr(Zc,{openFindingHistoryDialog:()=>Yh});function Yh(r){return r.isCurrent()?nt("finding-history-dialog",r):Promise.resolve(null)}var ro,Jc=_(()=>{"use strict";S();B();ae();Lr();jc();Fc();Hc();Vc();Wc();ro=class extends Q{static styles=[...Q.styles,$(Gc),$(qc),$(Kc)];static properties={finding:{attribute:!1},teamId:{attribute:!1},_events:{state:!0},_loading:{state:!0},_error:{state:!0}};constructor(){super(),this._events=[],this._loading=!0,this._error=!1}beforeOpen(){this._load()}async _load(){if(!this.isCurrent()){this._finish(null);return}this._loading=!0,this._error=!1;let{_managedReportId:e,id:t}=this.finding;this._key=`finding-history:${this.teamId??""}:${e}:${t}`,E.invalidate([this._key]);let i=E.load(this._key,"issue history",async s=>{let o=new URLSearchParams({finding:t});this.teamId&&o.set("team",this.teamId);let n=await x(`/api/reports/${encodeURIComponent(e)}/triage/history?${o}`,{credentials:"same-origin",signal:s});if(!n.ok)throw new Error(`History request failed (${n.status})`);let a=await n.json();if(a.finding!==t||!Array.isArray(a.events))throw new Error("Invalid history response");return a.events});this._owner=E.resources.get(this._key),this._signal=this._owner.controller.signal,this._signal.addEventListener("abort",this._onClose,{once:!0});try{let s=await i;if(this._settled||!this.isConnected)return;if(!this.isCurrent()){this._finish(null);return}this._events=s}catch(s){if(this._settled||!this.isConnected)return;s.name==="AbortError"||!this.isCurrent()?this._finish(null):this._error=!0}finally{this._loading=!1}}disconnectedCallback(){this._signal?.removeEventListener("abort",this._onClose),this._owner&&E.resources.get(this._key)===this._owner&&E.invalidate([this._key]),this._events=[],super.disconnectedCallback()}_onKeydown=e=>{e.key==="Escape"&&e.stopPropagation()};_renderEvent(e,t){let i=this._events[t+1],s=Dc(e.entry,i?.entry),o=new Date(e.at),n=e.actorLogin?`@${e.actorLogin}`:"";return c`<li class="event">${e.actorId?Uc(e.actorId,e.actorName||e.actorLogin):c`<span class="managed-comment-avatar" aria-hidden="true">${(e.actorLogin?.[0]||"?").toUpperCase()}</span>`}<div class="event-content"><div class="event-meta"><div class="event-user"><strong>${e.actorName||n||"Unknown user"}</strong> ${e.actorName&&n?c`<span class="username">${n}</span>`:h}</div><time datetime="${o.toISOString()}" data-tooltip="${o.toLocaleString()}">${o.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}</time></div><p class="event-action">${e.entry===null?"Cleared triage":i?"Updated triage":"Recorded triage state"}</p>${s.length>0?c`<dl class="changes">${s.map(a=>c`<div class="change"><dt>${a.label}</dt><dd class="${a.before===void 0?"snapshot":""}">${a.before===void 0?h:c`<span class="before"><span class="sr-only">Previously: </span>${a.before}</span> <span class="change-arrow" aria-hidden="true">→</span>`} <span class="after"><span class="sr-only">${a.before===void 0?"Recorded: ":"Changed to: "}</span>${a.after}</span></dd></div>`)}</dl>`:h}</div></li>`}render(){let e=this.finding??{};return c`<dialog aria-labelledby="history-title" @close="${this._onClose}" @keydown="${this._onKeydown}"><header><div class="history-heading"><h3 id="history-title"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 11a9 9 0 1 1 2.5 7M3 5v6h6M12 7v5l3 2"/></svg>Issue history</h3><p class="location">${e.file}${e.line?`:${e.line}`:""}</p></div><button type="button" class="detail-action" aria-label="Close issue history" @click="${this._onClose}">×</button></header>${!this._loading&&!this._error&&this._events.length>0?c`<div class="history-summary"><span>${this._events.length} ${this._events.length===1?"record":"records"}</span><span>Newest first</span></div>`:h}<div class="history-body" aria-busy="${String(this._loading)}">${this._loading?c`<p class="history-state" role="status">Loading history…</p>`:this._error?c`<div class="history-state" role="alert"><strong>Couldn’t load issue history</strong><p>Close and reopen to try again.</p></div>`:this._events.length===0?c`<div class="history-state" role="status"><strong>No triage changes yet</strong><p>Changes to status, labels, flags, and fixes will appear here.</p></div>`:c`<ol class="timeline">${this._events.map((t,i)=>this._renderEvent(t,i))}</ol>`}</div></dialog>`}};customElements.define("finding-history-dialog",ro)});B();S();ve();S();ae();var T=class extends A{static properties={session:{attribute:!1},allowShare:{attribute:!1},_loading:{state:!0}};constructor(){super(),this.session=null,this.allowShare=!1,this.appState=E,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 q(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>`}te();xt();var $t=class extends re{constructor(e){if(super(e),this.it=h,e.type!==Y.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===j)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:[]}}};$t.directiveName="unsafeHTML",$t.resultType=1;var P=ye($t);Pr();Dr();we();var Vn={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="${Pn}"/>`},"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"/>'},"markdown-generic":{className:"brand-markdown",mark:'<path class="fg" d="M4 7h1.2l1.2 1.5L7.6 7h1.2v4H7.6V8.8L6.4 10 5.2 8.8V11H4zm5.6 0h1.2v2.3H12l-1.8 1.8-1.8-1.8h1.2Z"/>'},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"/>'}},Vp={default:["#2563eb","#fff"],"claude-security":["#d97757","#fff"],"codex-security":["#fff","#000"],deepsec:["#000","#fff"],piolium:["#fbb829","#1c1b19"],"markdown-generic":["#374151","#fff"]},Ei=Object.fromEntries(Object.entries(Vn).map(([r,{className:e,mark:t}])=>{let[i,s]=Vp[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>`]})),Ai=Object.fromEntries(Object.entries(Vn).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>`]));function tt(r){let e=r.toLowerCase();if(e.endsWith(".generic-md")){let t=r.slice(0,-11);try{return decodeURIComponent(t)}catch{return t}}return e.endsWith(".codex")?r.slice(0,-6).replaceAll("__","/"):r}we();S();we();var Gp=[["manage","Overview"],["manage-bundles","Bundles"],["manage-scans","Scans"],["manage-reports","Reports"],["manage-deduplication","Deduplication","admin"],["manage-repos","Repositories","admin"],["admin-users","Users","admin"],["manage-teams","Teams","admin"],["manage-import","Import","admin"],["manage-links","Links"],["manage-history","History"]];function U(r,e,t=!1){return c`<header class="manage-header"><nav class="manage-nav" aria-label="Management pages">${Gp.filter(([i,,s])=>(s==null||s===e)&&(i!=="manage-links"||t)).map(([i,s])=>c`<button type="button" aria-current="${r===i?"page":h}" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:i},bubbles:!0,composed:!0}))}}">${s}</button>`)}</nav></header>`}function D(r){if(r==="bundle")return P(_e);if(r==="report"||r==="preview")return P(et);if(r==="scan")return P(Dn);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>`}S();S();te();xt();dr();var G=ye(class extends re{constructor(r){if(super(r),r.type!==Y.PROPERTY&&r.type!==Y.ATTRIBUTE&&r.type!==Y.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Kn(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===j||e===h)return e;let t=r.element,i=r.name;if(r.type===Y.PROPERTY){if(e===t[i])return j}else if(r.type===Y.BOOLEAN_ATTRIBUTE){if(!!e===t.hasAttribute(i))return j}else if(r.type===Y.ATTRIBUTE&&t.getAttribute(i)===e+"")return j;return it(r),e}});var F=class extends A{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=z`:host{display:block;min-width:0}:host,.menu{-webkit-app-region:no-drag;app-region:no-drag}*{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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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(),this.dispatchEvent(new CustomEvent("tooltip-root-connected",{bubbles:!0,composed:!0})),window.addEventListener("resize",this._onViewport),window.addEventListener("scroll",this._onViewport,!0),this._scrollRoots=[];for(let e=this.getRootNode();e.host;e=e.host.getRootNode())e.addEventListener("scroll",this._onViewport,!0),this._scrollRoots.push(e)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onViewport),window.removeEventListener("scroll",this._onViewport,!0);for(let e of this._scrollRoots??[])e.removeEventListener("scroll",this._onViewport,!0);this._scrollRoots=[]}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" data-tooltip-truncated data-tooltip="${e?.label??h}">${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="${G(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" aria-pressed="${t.activeFacet===n.value}" @click="${()=>this._filterFacet(n.value)}"><span class="name" data-tooltip-truncated data-tooltip="${n.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 e.initials?c`<span class="avatar" aria-hidden="true">${e.initials}</span>`:h}optionTooltip(e){return e.label}_option(e,t,i){let s=e.displayLabel??(t?e.name:e.label),o=this.optionTooltip(e);return c`<button type="button" class="option" role="option" ?data-reset="${e.reset}" ?disabled="${e.disabled}" aria-label="${e.label}" 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)}<span class="option-copy"><span class="name" ?data-tooltip-truncated="${s===o}" data-tooltip="${o}">${s}</span>${e.secondary?c`<span class="secondary" data-tooltip-truncated data-tooltip="${e.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 Ii=class extends F{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."}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",Ii);var kt=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>`}};B();ae();ve();function Jn(r){let e;for(let t of r){let i=t.split("/");if(i.some(s=>!s||s==="."||s==="..")||t.includes("\\"))return"";if(i.pop(),e===void 0)e=i;else{let s=0;for(;s<e.length&&s<i.length&&e[s]===i[s];)s++;e.length=s}if(e.length===0)return""}return e?.join("/")??""}async function Zp({signal:r}={}){r=r?AbortSignal.any([r,E.sessionController.signal]):E.sessionController.signal,r.throwIfAborted();let e=await x("/api/admin/bundles",{credentials:"same-origin",signal:r});if(r.throwIfAborted(),!e.ok)throw Object.assign(new Error(`Bundle catalogue request failed (${e.status})`),{status:e.status});let t=await e.json();return r.throwIfAborted(),t.bundles??[]}async function pr(r,e,t){let i=E.generation,s=await x(`/api/bundles/${encodeURIComponent(r)}/${e}`,{credentials:"same-origin",signal:t});if(t?.throwIfAborted(),!s.ok)throw Object.assign(new Error(`Bundle ${e} request failed (${s.status})`),{status:s.status});let o=e==="contents"?await s.text():await s.json();if(t?.throwIfAborted(),i!==E.generation)throw new DOMException("Managed session changed","AbortError");return o}function Mi(r,{signal:e}={}){return E.load(`bundle-metadata:${r}`,"bundle metadata",t=>pr(r,"metadata",t),{signal:e,retryInvalidated:!0})}async function Yn(r,{signal:e}={}){e=e?AbortSignal.any([e,E.sessionController.signal]):E.sessionController.signal;let t=await pr(r,"metadata",e),i=t?.bundle?.repo??null,s=Xe({repo:i});if(!s)return i;let o=new URLSearchParams({repo:s,directory:i.directory??""}),n=new Set(t.unsized??[]),a=Jn((t.files??[]).filter(([m,p])=>p!=null||n.has(m)).map(([m])=>m));a&&o.set("filePrefix",a);let l=await x(`/api/admin/repositories/resolve?${o}`,{credentials:"same-origin",cache:"no-store",signal:e});if(e.throwIfAborted(),!l.ok)throw new Error(`Repository suggestion request failed (${l.status})`);let{location:d}=await l.json();return e.throwIfAborted(),d?{...i,github:d.github,...d.mapped?{directory:d.directory}:{},repoId:d.repoId}:i}async function Jp(r,{signal:e}={}){e=e?AbortSignal.any([e,E.sessionController.signal]):E.sessionController.signal;try{return await pr(r,"contents",e)}catch(t){throw t.name!=="AbortError"&&E.notify(`Couldn't load bundle contents: ${t.message}`),t}}function Yp(r,e,t="",i=!1,s=!1){let o=[e?`team=${encodeURIComponent(e)}`:"",t?`reason=${encodeURIComponent(t)}`:"",i?"repoAdvisories=true":"",s?"details=true":""].filter(Boolean).join("&"),n=`advisories${o?`?${o}`:""}`;return pr(r,n,E.sessionController.signal)}ve();function Xn(r,e){let t=rr(r);if(t===null)return null;let i=e.replace(/\.(?:md|markdown)$/iu,""),s=new Set;return t.map(({displayName:o,data:n})=>{let a=`${i}: ${o}`.replaceAll("%","%25").replaceAll(/[\\/\p{Cc}]/gu,"_")+".generic-md";if(s.has(a))throw new Error(`Markdown (generic): products produce the same report name: ${a}`);return s.add(a),{name:a,content:JSON.stringify(n)}})}B();async function $e(r,e){let t=await x(r,{signal:e,credentials:"same-origin",headers:{accept:"application/json"}});if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}function ke(r,e,t){let i={"content-type":"application/json"};return e&&(i["x-csrf-token"]=e),x(r,{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify(t)})}async function Qn(r,e,t){let i=t?{"x-csrf-token":t}:{},s=await x(`/api/admin/${r}/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin",headers:i});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function ea(r,e,t,i,s,o){let n=new URLSearchParams({page:String(e),limit:"100",kind:t,q:i.trim()});s&&n.set("repo",s),o&&n.set("actor",o);let a=await $e(`/api/admin/history?${n}`,r);if(!Array.isArray(a?.history)||!Number.isSafeInteger(a.total)||a.total<0||!Number.isSafeInteger(a.page)||a.page<1)throw new Error("No history returned");return a}async function ta(r){let e=await $e("/api/admin/users",r);return Array.isArray(e?.users)?e.users:[]}async function ra(r,e,t){let i=await ke("/api/admin/set-role",t,{userId:r,role:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ia(r,e,t,i){let s=new URLSearchParams({scope:r});return r==="installed"&&s.set("showAll",String(e)),t&&s.set("refresh","true"),await $e(`/api/admin/repositories?${s}`,i)}async function sa(r,e,t){let i=await ke("/api/admin/repositories/select",t,{repoId:r,selected:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function oa(r,e){let t=await x("/api/admin/repositories/add-public",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify({repository:r})});if(!t.ok){let i={400:"Enter a repository as owner/repo or a GitHub repository URL.",403:"You do not have permission to add arbitrary public repositories.",404:"No public repository was found at that address.",409:"Choose a public, non-archived repository."};throw new Error(i[t.status]??`GitHub lookup failed (HTTP ${t.status}). Try again.`)}}async function na(r,e){let t=await $e(`/api/admin/repositories/impact?repoId=${encodeURIComponent(r)}`,e);if(t?.repoId!==r||!Array.isArray(t.reports)||!Array.isArray(t.bundles)||!Number.isSafeInteger(t.triageCount)||t.triageCount<0)throw new Error("Invalid repository data");return t}async function aa(r,e){let t=await x("/api/admin/repositories/connect-app",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify({repoId:r})}),i=await t.json();if(!t.ok){let s={"github-app-not-configured":"The GitHub App is not configured on this server.","repo-identity-changed":"The repository has changed on GitHub. Refresh and check its connection.","repo-connection-changed":"The connection or your permissions changed. Refresh and try again.","repo-not-connected":"This repository is no longer connected.",forbidden:"Administrator access is required to connect the GitHub App."};throw new Error(s[i.error]??`Could not connect the GitHub App (HTTP ${t.status}). Try again.`)}if(i.connected===!0)return i;if(i.connected!==!1||typeof i.installUrl!="string"||!/^https:\/\/github\.com\/apps\/[^/?#]+\/installations\/new$/u.test(i.installUrl))throw new Error("Invalid GitHub installation response.");return i}async function la(r,e,t,i){let s=await ke("/api/admin/repositories/remove",i,{repoId:r,fullName:e,acknowledge:!0,deleteTriage:t});if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.json()}async function ca(r){return await $e("/api/admin/reports",r)}async function da(r,e,t){let i=await x("/api/admin/bundles/create",{method:"POST",credentials:"same-origin",signal:t,headers:{"content-type":"application/json","x-csrf-token":e},body:JSON.stringify(r)}),s=await i.json();if(!i.ok){let o={"unsupported-entries":"Select JavaScript/TypeScript files (including JSX/TSX) or Solidity files. Stasis cannot mix languages or use JSON or Rust as remote entry points.","bad-conditions":"Check the export conditions and selected platforms.","metro-conditions":"Stasis\u2019s Metro preset requires the react-native condition without manual changes.","build-lockfile":"Stasis needs a supported lockfile: pnpm-lock.yaml, yarn.lock (Yarn 1), package-lock.json, or soldeer.lock.","build-scope":"Your team needs access to the bundle\u2019s project root, including its lockfile and dependencies.","build-busy":"A bundle is already being built, or the server is busy. Try again shortly.","build-timeout":"The bundle build timed out. Try a smaller selection or retry.","too-large":"This bundle exceeds the server\u2019s size limit.","github-rate-limited":"GitHub\u2019s API rate limit has been reached. Retry after the limit resets.","github-build-failed":"Could not fetch the repository from GitHub. Check access and retry.","repository-changed":"The repository connection changed during the build. Reload and try again.","bundle-conflict":"This bundle already exists but is outside your current access.","build-failed":"Stasis could not build this selection. Check that its lockfile is supported and all entry points and imports exist at this commit."};throw new Error(o[s.error]??(i.status===401?"Sign in again to create a bundle.":i.status===403||i.status===404?"Repository access is required to create this bundle.":"Could not create the bundle. Try again."))}return s}async function zi(r,e,t=null,i=""){let s=(await $e("/api/config")).managed?.uploadMaxBytes?.reports;if(Number.isSafeInteger(s)&&s>0){if(r.size>s)throw new Error("too large")}else if(r.size>3*1024*1024)return Li(r,e,t,i);let o=Xn(await r.text(),r.name);if(!o)return Li(r,e,t,i);let n=[];for(let{name:a,content:l}of o)n.push(await Li(new File([l],a,{type:"application/json"}),e,t,i));return n.at(-1)}async function Li(r,e,t,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 x("/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=await o.json().catch(()=>null);if(n?.error==="storage-encryption-required")throw new Error("Link reports require managed storage encryption. Configure MANAGED_STORAGE_ENCRYPTION_KEY.");if(n?.error==="invalid-report")throw new Error(typeof n.reason=="string"&&n.reason?`This file is not a report: ${n.reason}`:"This file is not a recognized report.");let a=n?.error==="repo-not-connected"&&typeof n.repo=="string"?`: ${n.repo} is not connected`:"";throw new Error(`HTTP ${o.status}${a}`)}return o.json()}async function pa(r,e,t){let i=await ke("/api/admin/reports/set-visible",t,{reportId:r,visible:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ua(r,e,t,i){let s=await ke("/api/admin/reports/set-repo",i,{reportId:r,repoId:e,directory:t});if(!s.ok)throw s.status===409?new Error("this report already defines its repository"):s.status===403?new Error("choose a repository and directory within your team access"):new Error(s.status===400?"invalid repository or directory":`HTTP ${s.status}`);return s.json()}async function ha(r,e){let t=await x(`/api/admin/reports/${encodeURIComponent(r)}/location`,{signal:e,credentials:"same-origin"});if(!t.ok)throw new Error(`Report location suggestion request failed (${t.status})`);return(await t.json())?.location??null}async function ma(r,e){await Qn("reports",r,e)}async function Oi(r){return await $e("/api/admin/bundles",r)}async function Ti(r,e,t,i=""){let s={"content-type":"application/octet-stream","x-bundle-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 x("/api/admin/bundles",{method:"POST",credentials:"same-origin",headers:s,body:r});if(!o.ok)throw new Error(o.status===413?"too large":o.status===403?"choose a repository and directory within your team access":`HTTP ${o.status}`);return o.json()}async function fa(r,e){await Qn("bundles",r,e)}async function ga(r,e,t){let i=await ke("/api/admin/bundles/set-visible",t,{bundleId:r,visible:e});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function ba(r,e,t,i){let s=await ke("/api/admin/bundles/set-repo",i,{bundleId:r,repoId:e,directory:t});if(!s.ok)throw new Error(s.status===403?"choose a repository and directory within your team access":s.status===400?"invalid repository or directory":`HTTP ${s.status}`)}async function Ni(r){return await $e("/api/admin/teams",r)}async function ie(r,e,t){let i=await ke(r,e,t);if(!i.ok)throw new Error(i.status===409?"name already taken":`HTTP ${i.status}`)}function St(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 Ct(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 Pi(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)}}async function Rt(r,e,t,i){if(e.length!==0&&(r._queue.push(...e),!r._busy)){r._busy=!0,r._error=null;try{for(;r._queue.length>0;){let s=r._queue.shift();await r.appState.mutate(()=>t(s),i)}}catch(s){r._queue=[],r._error=`Upload failed: ${String(s?.message??s)}`}finally{r._busy=!1,await r._load({preserveError:!0})}}}var Bi=`.local-import-toggle{flex-shrink:0;margin-block:calc(-.25rem - 1px);margin-left:auto;padding:.25rem .6rem;border:1px solid var(--border);border-radius:var(--ui-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:var(--ui-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:var(--ui-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)}
|
|
73
|
+
`;var N=`:host{display:flex;flex-direction:column;position:relative;padding:0 clamp(1rem,3vw,3rem) 3rem;color:var(--text);container-type:inline-size;font-family:var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);font-size:.875rem;line-height:1.5;--panel:color-mix(in srgb, var(--bg) 50%, var(--surface));--panel-hover:color-mix(in srgb, var(--text) 3%, var(--panel))}*,*:before,*:after{box-sizing:border-box}button,summary,select,label,legend,h1,h2,h3,.section-heading,.ui-hint,.page-intro>.intro,.count,.result-count,.repository-count,.breadcrumb-separator,.list-head,.report-list-head,.history-head,.drop-copy,.local-import-copy,.location-field>span,.empty:not(.error,[role=alert]),.msg:not(.error,[role=alert]),.local-import-message:not(.error,[role=status]),.data-empty,.revision-empty{cursor:default;user-select:none;-webkit-user-select:none}input:not([type=checkbox],[type=radio]),textarea,[contenteditable],pre,code,.mono{cursor:text;user-select:text;-webkit-user-select:text}.wrap{width:100%;max-width:76rem;margin:0 auto;flex:1;min-height:0;overflow-y:auto;overscroll-behavior:none;scrollbar-gutter:stable}.manage-header{position:sticky;top:0;z-index:2}.wrap:has(>.manage-list){display:flex;flex-direction:column;overflow:hidden;scrollbar-gutter:auto}.wrap:has(>.manage-list)>:not(.manage-list){flex:none}.manage-list{position:relative;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}.manage-nav button{flex:0 0 auto;position:relative;min-height:3.7rem;padding:.9rem 0;border:0;border-radius:0;color:var(--muted);background:none;font-size:.8rem;font-weight:500;white-space:nowrap}.manage-nav button:hover,.manage-nav button[aria-current=page]{color:var(--text)}.manage-nav button[aria-current=page]:after{content:"";position:absolute;bottom:.6rem;inset-inline:0;height:2px;background:var(--accent);border-radius:var(--ui-radius, 2px)}.manage-nav button:focus-visible{outline-offset:-3px}.head{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem}h1,.head h1{margin:0;font-size:1.9rem;font-weight:600;letter-spacing:-.045em;line-height:1.2}.count{display:inline-flex;align-items:center;justify-content:center;min-width:1.6rem;padding:.12rem .5rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--surface);font-size:.73rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,select,input[type=checkbox]{cursor:default}button,a,input,select{-webkit-app-region:no-drag}button,a{transition:background .15s,color .15s,border-color .15s}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}button:disabled,select:disabled{opacity:.45}input:not([type=checkbox]),select{min-width:0;min-height:2.25rem;padding:.45rem .65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{accent-color:var(--accent)}.btn,.drop-browse{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;min-height:2.25rem;height:auto;padding:.45rem .8rem;border:1px solid var(--border);border-radius:var(--ui-radius, 7px);background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;text-decoration:none;white-space:nowrap}.btn:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary,.drop-browse{color:var(--bg);background:var(--accent);border-color:var(--accent)}.btn.primary:hover:not(:disabled),.drop-browse:hover:not(:disabled){background:var(--accent);filter:brightness(1.08)}.btn svg,.icon-btn svg{width:1rem;height:1rem}.icon-btn{width:2rem;height:2rem}.avatar{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 16%,var(--border))}.breadcrumb{display:flex;align-items:center;flex-basis:100%;gap:.4rem;margin-bottom:.8rem}.breadcrumb-manage{padding:.1rem 0;border:0;background:transparent;color:var(--muted);font-size:.78rem}.breadcrumb-manage:hover{color:var(--text)}.breadcrumb-separator{color:var(--muted)}.msg{margin:1rem 0;padding:1.1rem 1.25rem;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);color:var(--muted);font-size:.85rem}.msg.error{color:var(--critical);border-color:color-mix(in srgb,var(--critical) 35%,var(--border))}.empty{padding:3.5rem 1.5rem;border:1px dashed var(--border);border-radius:var(--ui-radius, 10px);color:var(--muted);text-align:center}.empty strong{display:block;margin-bottom:.4rem;color:var(--text);font-size:.95rem;font-weight:500}.empty p{margin:0;font-size:.85rem}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@container (max-width: 35rem){.drop-copy>span{display:none}.manage-nav{gap:1.2rem;margin-bottom:1.75rem}.manage-nav button{min-height:3.25rem}h1,.head h1{font-size:1.65rem}.intro{margin-bottom:1.5rem}}@media(prefers-reduced-motion:reduce){button,a{transition:none}}.collection-toolbar input{flex:1;max-width:26rem;min-width:10rem}.collection-toolbar select{min-width:10rem}.result-count{text-align:right;white-space:nowrap;margin-left:auto;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}@container (max-width: 35rem){.collection-toolbar input{flex-basis:100%;max-width:none}}.manage-nav{display:flex;gap:1.35rem;align-items:stretch;overflow-x:auto;scrollbar-width:thin;border-bottom:1px solid var(--border);margin-bottom:1.5rem;padding:0 .1rem}.wrap>:not(.manage-header),.manage-nav{-webkit-app-region:no-drag;app-region:no-drag}@media(display-mode:window-controls-overlay){.manage-header{display:flow-root}.manage-header:before{content:"";float:right;width:var(--wco-right-toolbar, 0px);height:var(--wco-titlebar-height)}.manage-nav{width:max-content;max-width:100%;border-bottom:0}.manage-nav button{min-height:var(--wco-titlebar-height);padding-block:.35rem}.manage-nav button[aria-current=page]:after{bottom:0}}.intro{margin:0 0 1.25rem;max-width:46rem;color:var(--muted);font-size:.875rem;line-height:1.65}.collection-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;margin-bottom:.85rem}.page-intro{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.5rem 1rem;margin-bottom:1.25rem}.page-intro .intro{margin:0}a{cursor:default}.loading-rows{border:1px solid var(--border);border-radius:var(--ui-radius, 10px);overflow:hidden}.loading-row{display:grid;align-content:center;gap:.6rem;min-height:4.25rem;padding:.85rem 1rem}.loading-row+.loading-row{border-top:1px solid var(--border)}.loading-row span{width:40%;height:.65rem;border-radius:3px;background:color-mix(in srgb,var(--muted) 15%,transparent)}.loading-row span+span{width:65%;height:.5rem}.drop-card{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem;padding:.7rem .85rem;border:1px dashed color-mix(in srgb,var(--muted) 35%,var(--border));border-radius:var(--ui-radius, 8px);background:var(--panel)}.drop-icon{display:grid;place-items:center;flex-shrink:0;width:1.8rem;height:1.8rem;color:var(--muted)}.drop-icon svg{width:1.1rem;height:1.1rem}.drop-copy{min-width:0;display:flex;align-items:baseline;flex-wrap:wrap;gap:.2rem .6rem}.drop-copy strong{font-size:.8rem;font-weight:500}.drop-copy>span{color:var(--muted);font-size:.75rem}.drop-browse{min-width:7rem;margin-left:auto;flex-shrink:0}.content-hidden .filename,.content-hidden .report-name,.content-hidden .report-uploader{color:var(--muted)}.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)}
|
|
74
|
+
`;var va=`.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:var(--ui-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:var(--ui-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(--scan-icon-color, var(--yellow));border-color:color-mix(in srgb,var(--scan-icon-color, var(--yellow)) 18%,var(--border));background:color-mix(in srgb,var(--scan-icon-color, var(--yellow)) 6%,var(--panel))}:host-context(body.theme-light) .page-scan .page-icon{--scan-icon-color: #bf8700}:host-context(body.theme-green) :is(.page-bundle,.page-scan) .page-icon,:host-context(body.theme-pink) :is(.page-bundle,.page-scan) .page-icon{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 16%,var(--border));background:color-mix(in srgb,var(--accent) 7%,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}}
|
|
75
|
+
`;var ya=`.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-bottom:.9rem}.toolbar input{flex:2 1 12rem}.toolbar select{flex:0 1 9rem}.toolbar repository-selector{flex:1 1 12rem}.toolbar user-selector{flex:1.5 1 16rem}.toolbar>*{min-width:0}.toolbar input[type=search],.toolbar select,.toolbar .btn{min-height:2rem;padding:.28rem .5rem;border-radius:var(--ui-radius, 5px)}.history{overflow-x:auto;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);background:var(--panel)}.row,.history-head{display:grid;grid-template-columns:4.7rem minmax(16rem,1fr) minmax(12rem,1fr) 12rem;align-items:center;gap:.85rem;min-width:52rem;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;align-items:center;gap:.35rem;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}
|
|
76
|
+
`;var _a=`.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:var(--ui-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:.7rem;font-weight:500;min-height:2.25rem;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:var(--ui-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:var(--ui-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;padding:.5rem .85rem;align-items:center}.users li{padding-top:.6rem;padding-bottom:.6rem}.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}
|
|
77
|
+
`;var wa=`.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:var(--ui-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}.aliases-link{margin-top:.75rem}.aliases-link .btn{min-height:1.75rem;padding:.2rem .55rem}.repository-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;margin-left:auto;margin-block:calc(-.45rem - 1px)}.breadcrumb{flex-wrap:wrap}.breadcrumb .breadcrumb-current{margin:0;color:var(--text);font-size:.85rem;font-weight:500}.public-repository-form{padding:1rem;margin:-1rem 0 1.5rem;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--panel)}.public-repository-form .confirm-field{margin:0}.search{flex:1 1 14rem;max-width:25rem;margin-right:auto}.search input{width:100%}.show-all,.show-all-paper{align-items:center;gap:.5rem;white-space:nowrap;font-size:.78rem}.show-all{display:var(--switch-button-display, inline-flex)}.show-all-paper{display:var(--switch-checkbox-display, none);& input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent)}}.show-all input{appearance:none;width:2rem;height:1.15rem;margin:0;padding:2px;border:1px solid var(--border);border-radius:var(--ui-radius, 1rem);background:var(--surface-active)}.show-all input:before{content:"";display:block;width:.775rem;height:.775rem;border-radius:50%;background:var(--muted)}.show-all input:checked{border-color:var(--accent);background:var(--accent)}.show-all input:checked:before{transform:translate(.85rem);background:var(--bg)}.show-all input:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.repository-count{margin:-.8rem 0 .6rem;color:var(--muted);font-size:.75rem;font-variant-numeric:tabular-nums}.repository-browser{display:flex;overflow:hidden;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--panel)}.organization-list{flex:0 0 12rem;padding:.4rem;border-right:1px solid var(--border);background:rgb(from var(--bg) r g b / .25)}.organization{display:flex;align-items:center;gap:.5rem;width:100%;padding:.5rem;border:0;border-radius:var(--ui-radius, 4px);color:var(--text);background:transparent;text-align:left;font-size:.76rem;cursor:default}.organization:hover{background:rgb(from var(--text) r g b / .05)}.organization[aria-pressed=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.organization-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.organization-count{color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums}.repo-results{flex:1;min-width:0}.organization-list,.repo-results{max-height:min(65vh,40rem);overflow:auto;overscroll-behavior:contain}.repo-group+.repo-group{border-top:1px solid var(--border)}.owner-head{position:sticky;top:0;z-index:1;display:flex;align-items:center;gap:.6rem;margin:0;padding:.55rem .85rem;color:var(--muted);background:var(--panel);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:var(--ui-radius, 5px);background:var(--surface);text-transform:uppercase;font-size:.75rem}.repos{margin:0;padding:0;list-style:none}.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}.btn.connect-app{min-height:1.9rem;padding:.3rem .6rem;font-size:.72rem}.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:var(--ui-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;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}.section{margin-top:1.75rem;border:1px solid var(--border);border-radius:var(--ui-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:var(--ui-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:var(--ui-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;overflow-wrap:anywhere}.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:var(--ui-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-line span{min-width:0}.confirm-field{display:grid;gap:.5rem;margin-top:1.1rem;color:var(--text);font-size:.78rem;line-height:1.5;overflow-wrap:anywhere}.confirm-name{width:100%;min-width:0;padding:.45rem .55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font:inherit;font-size:.78rem}.dialog-actions{display:flex;flex-wrap:wrap;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){.organization-list{flex-basis:9rem}.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}@container (max-width: 28rem){.repository-browser{flex-direction:column}.organization-list{display:flex;flex:0 0 auto;gap:.25rem;border-right:0;border-bottom:1px solid var(--border)}.organization{flex:0 0 auto;width:auto;max-width:12rem}}
|
|
78
78
|
`;var ur=`.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-markdown{--brand-bg:#374151;--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:var(--ui-radius, 10px);background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-weight:600;pointer-events:none}.report-list{overflow-x:auto;border:1px solid var(--border);border-radius:var(--ui-radius, 9px);background:var(--panel)}.reports{min-width:61rem;margin:0;padding:0;list-style:none}.report-list-head,.report-main{display:grid;grid-template-columns:1.5rem minmax(12rem,1fr) minmax(8rem,.6fr) 8rem 6.5rem 4.5rem 4.1rem 9rem;align-items:center;gap:.7rem;padding:.35rem .85rem}.report-list-head{min-width:61rem;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:2.7rem}.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-name{color:var(--text);font-size:.8rem;font-weight:500}.report-name,.report-location,.report-meta{min-width:0;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-uploader{color:var(--text);opacity:.8;font-size:.72rem}.report-size,.size-heading{padding-right:.65rem;text-align:right}.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:var(--ui-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:var(--ui-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}
|
|
79
|
-
`;var
|
|
80
|
-
`;var Di=`.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-field input[type=text],.location-actions .action{height:2rem;min-height:2rem;padding-block:.28rem}.location-actions{display:flex;gap:.4rem}.location-actions .action{width:auto;padding-inline:.65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);color:var(--text);background:var(--bg);font-size:.78rem}
|
|
81
|
-
`;var
|
|
82
|
-
`;S();te();xt();dr();var
|
|
79
|
+
`;var xa=`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:var(--ui-radius, 10px);background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.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,.bundle-icon img{width:1rem;height:1rem}.action{display:grid;place-items:center;width:2rem;height:2rem;padding:.45rem;border:1px solid transparent;border-radius:var(--ui-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)}.bundle-group{overflow:hidden;border:1px solid var(--border);border-radius:var(--ui-radius, 10px);background:var(--panel);overflow-x:auto}.bundle-group-head,.bundles{min-width:58rem}.bundle-row{display:grid;grid-template-columns:minmax(12rem,1fr) 8rem 6.5rem 4.5rem minmax(8rem,12rem) 4rem 8.6rem;align-items:center;gap:.85rem;padding:.35rem .85rem}.bundle-location{display:block;min-width:0;grid-column:auto;padding-left:0;color:var(--muted);font-size:.75rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;justify-content:flex-end;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:var(--ui-radius, 7px);background:transparent;color:var(--muted)}.filename{min-width:0;font-size:.8rem;font-weight:500;overflow-wrap:anywhere;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.meta{min-width:0;color:var(--muted);font-size:.65rem;line-height:1.5;font-variant-numeric:tabular-nums;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bundle-size{padding-right:.65rem;text-align:right}.bundle-provenance{flex-shrink:0;margin-left:-.35rem;padding:.05rem .35rem;border:1px solid rgb(from var(--accent) r g b / .25);border-radius:5px;background:rgb(from var(--accent) r g b / .07);color:var(--accent);font-size:.62rem;font-weight:500}.bundle-actions{display:flex;align-items:center;gap:.5rem}.bundle-open{padding:0;border:0;background:none;color:inherit;font:inherit;text-align:left}.bundle-open:hover{color:var(--accent)}.bundle-row>.location-editor{grid-column:1 / -1}.breadcrumb{flex-wrap:wrap}.breadcrumb .breadcrumb-current{margin:0;color:var(--text);font-size:.85rem;font-weight:500}
|
|
80
|
+
`;var Di=`.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-field input[type=text],.location-actions .action{height:2rem;min-height:2rem;padding-block:.28rem}.location-actions{display:flex;gap:.4rem}.location-actions .action{width:auto;padding-inline:.65rem;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);color:var(--text);background:var(--bg);font-size:.78rem}.location-field-header{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem;min-width:0;color:var(--muted);font-size:.75rem}.location-field-header>:first-child{flex-shrink:0}.location-metadata{display:flex;align-items:baseline;gap:.25rem;min-width:0;padding:0;border:0;color:inherit;background:none;font:inherit}.location-metadata>.ui-hint{flex-shrink:0}.location-metadata-value{min-width:0;user-select:text;-webkit-user-select:text;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}button.location-metadata:hover:not(:disabled){color:var(--text)}.location-origin{grid-column:1 / -1;margin:0;color:var(--muted);font-size:.72rem;overflow-wrap:anywhere}.origin-retry{padding:0;border:0;background:none;color:var(--accent);font:inherit}
|
|
81
|
+
`;var $a=`.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:var(--ui-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:.5rem;margin-bottom:1rem}.new-name{flex:1 1 14rem;width:16rem;max-width:24rem}.access-note{flex:1 1 24rem;margin:0 0 0 auto;color:var(--muted);font-size:.75rem;text-align:right}.team .icon-btn{width:1.8rem;height:1.8rem}.team{border:1px solid var(--border);border-radius:var(--ui-radius, 8px);margin-bottom:.85rem;background:var(--panel);overflow:hidden}.team-head{display:flex;align-items:center;gap:.5rem;min-height:2.75rem;padding:.4rem .85rem;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:1.25rem;height:1.25rem;color:var(--muted)}.team-icon svg{width:1.05rem;height:1.05rem}.team-name{margin:0;min-width:0;font-size:.875rem;font-weight:600;letter-spacing:-.015em;overflow-wrap:anywhere}.team-actions{display:flex;gap:.25rem;margin-left:auto}.team-hidden-note{margin:.75rem .85rem 0}.rename-input{flex:1;max-width:22rem;width:0}.team-body{display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr)}.sub{min-width:0;padding:.75rem .85rem}.sub+.sub{border-left:1px solid var(--border)}.sub-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .4rem;font-size:.75rem;font-weight:600}.sub-title .count{height:1.1rem;min-width:1.1rem;font-size:.75rem;padding:0 .3rem}.links{list-style:none;margin:0 0 .5rem;padding:0}.links li{display:flex;align-items:center;gap:.5rem;min-height:2.25rem;padding:.25rem 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:.1rem}.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:.3rem;padding:.15rem .3rem;border:1px solid var(--border);border-radius:4px;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:.45rem}.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:.5rem 0}@container (max-width: 50rem){.access-note{flex-basis:100%;margin-left:0;text-align:left}.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}.new-name{flex:1;width:0}.team-head,.sub{padding-left:.75rem;padding-right:.75rem}.add-row:has(.add-repo-sel){display:grid;grid-template-columns:minmax(0,1fr) auto}.add-row .add-repo-sel{width:100%}.add-repo-path{grid-column:1 / -1;grid-row:2;width:100%}}@container (max-width: 26rem){.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}}
|
|
82
|
+
`;S();te();xt();dr();var ka=(r,e,t)=>{let i=new Map;for(let s=e;s<=t;s++)i.set(r[s],s);return i},hr=ye(class extends re{constructor(r){if(super(r),r.type!==Y.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=Zn(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,m,p=0,u=s.length-1,f=0,b=o.length-1;for(;p<=u&&f<=b;)if(s[p]===null)p++;else if(s[u]===null)u--;else if(a[p]===n[f])l[f]=xe(s[p],o[f]),p++,f++;else if(a[u]===n[b])l[b]=xe(s[u],o[b]),u--,b--;else if(a[p]===n[b])l[b]=xe(s[p],o[b]),rt(r,l[b+1],s[p]),p++,b--;else if(a[u]===n[f])l[f]=xe(s[u],o[f]),rt(r,s[p],s[u]),u--,f++;else if(d===void 0&&(d=ka(n,f,b),m=ka(a,p,u)),d.has(a[p]))if(d.has(a[u])){let v=m.get(n[f]),y=v!==void 0?s[v]:null;if(y===null){let g=rt(r,s[p]);xe(g,o[f]),l[f]=g}else l[f]=xe(y,o[f]),rt(r,s[p],y),s[v]=null;f++}else cr(s[u]),u--;else cr(s[p]),p++;for(;f<=b;){let v=rt(r,l[b+1]);xe(v,o[f]),l[f++]=v}for(;p<=u;){let v=s[p++];v!==null&&cr(v)}return this.ut=n,it(r,l),j}});we();var lu=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"]]),cu=new Map([["openai","OpenAI"],["anthropic","Anthropic"],["moonshotai","Moonshot AI"],["google","Google"],["nvidia","NVIDIA"],["qwen","Qwen"],["deepseek","DeepSeek"],["x-ai","xAI"],["z-ai","Z.ai"]]),du=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"],["mimo","MiMo"],["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 Sa(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=du.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 De(r){return lu.get(r)??Sa(r.includes("/")?r.slice(r.indexOf("/")+1):r)}function Et(r){let e=r.includes("/")?r.split("/")[0]:"other";return{key:e,name:cu.get(e)??(e==="other"?"Other":Sa(e))}}function je(r){return r==="xhigh"?"Extra high":r?r[0].toUpperCase()+r.slice(1):"Unavailable"}function st(r){return r.efforts.includes("max")?"max":r.efforts.at(-1)??null}async function ot(r,e=fetch){let t=await e("/api/admin/scan/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 pu(i)}function pu(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}}S();function ji(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 Ui(r){return[...Map.groupBy(ji(r),t=>Et(t.id).key)].map(([t,i])=>({key:t,models:i}))}function Ca(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,m)=>d+m,0),o=Math.max(...i);for(;o<s;){let d=Math.floor((o+s)/2),m=0,p=1;for(let u of i)m+u>d&&(p++,m=0),m+=u;p>t?o=d+1:s=d}let n=[],a=[],l=0;for(let[d,m]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(m),l+=i[d];return n.push(a),n}S();S();var Ra=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>`;S();var Ea=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>`;S();var Aa=c`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
83
83
|
<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"/>
|
|
84
84
|
<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"/>
|
|
85
85
|
<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"/>
|
|
86
86
|
<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"/>
|
|
87
87
|
</svg>
|
|
88
|
-
`;S();var Aa=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>`;S();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="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>`;S();var Ma=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>`;S();var Ia=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>`;S();var La=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>`;S();var za=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>`;S();var Oa=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 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z"/></svg>
|
|
89
|
-
`;S();var Ta=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 Na={anthropic:Ca,deepseek:Ra,google:Ea,moonshot:Fi,moonshotai:Fi,nvidia:Ma,openai:Ia,openrouter:La,qwen:za,xiaomi:Oa,"x-ai":Aa,"z-ai":Ta},du=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 Hi(r){return Object.hasOwn(Na,r)?Na[r]:du}var pu=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>`,qi=class extends A{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=z`:host{display:block;min-width:0;container:scan-controls / inline-size}*{box-sizing:border-box}.layout{display:grid;grid-template-columns:minmax(16rem,1fr) minmax(14rem,1fr);gap:1.25rem;align-items:start}.layout.with-extra{grid-template-columns:minmax(16rem,.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:var(--ui-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:var(--ui-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,.pro-checkbox{position:absolute;right:2.05rem;top:50%;transform:translateY(-50%);align-items:center;justify-content:center;gap:.3rem;width:3.65rem;height:1.65rem;padding:.2rem .3rem;color:var(--muted);font:inherit;font-size:.65rem;font-weight:600;cursor:default;user-select:none}.pro-toggle{display:var(--switch-button-display, inline-flex);border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg)}.pro-checkbox{display:var(--switch-checkbox-display, none)}.pro-checkbox input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent)}.pro-toggle:hover{border-color:var(--muted);color:var(--text)}.pro-track{position:relative;flex:0 0 1.3rem;height:.8rem;border-radius:var(--ui-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.xiaomi{color:#ff6900}.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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-radius, 4px);background:var(--bg);color:var(--text);font:inherit}@container scan-controls (max-width: 50rem){.layout.with-extra{grid-template-columns:minmax(16rem,1fr) minmax(14rem,1fr)}.layout.with-extra .extra{grid-column:1 / -1;align-self:start;min-height:0}}@container scan-controls (max-width: 33rem){.layout,.layout.with-extra{grid-template-columns:minmax(0,1fr);gap:1rem}.layout.with-extra .extra{grid-column:auto}}`;constructor(){super(),this.loadModels=ot,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(st(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 ji(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=Ui(this._models),d=l.reduce((R,I)=>R+I.models.length,0),u=Math.min(3,l.length,Math.ceil((d+l.length*1.5)/9)),p=parseFloat(getComputedStyle(s).fontSize),h=0;for(let R of s.querySelectorAll(".choice span, legend")){let I=document.createRange();I.selectNodeContents(R),h=Math.max(h,I.getBoundingClientRect().width)}let f=Math.max(11*p,Math.min(18*p,h+2.5*p)),b=1.3*p+2,v=Math.max(1,Math.min(u,Math.floor((window.innerWidth-a*2-b+p)/(f+p)))),y=Math.min(v*f+(v-1)*p+b,window.innerWidth-a*2),g=Math.max(a,Math.min(o.left,window.innerWidth-y-a));if(this._menuColumns=v,await this.updateComplete,e!==this._positionRequest||!this.isConnected||!t.open)return;s.style.left=`${g}px`,s.style.width=`${y}px`,s.style.setProperty("--model-columns",v),s.style.maxHeight=`${Math.max(0,window.innerHeight-a*2)}px`;let k=s.getBoundingClientRect().height,C=window.innerHeight-o.bottom-n-a,L=o.top-n-a,M=C<k&&L>C?o.top-n-k:o.bottom+n;s.style.bottom="auto",s.style.top=`${Math.max(a,Math.min(M,window.innerHeight-k-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:st(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>`:m}</div>`;let t=this._selectedRow,i=Et(e.id),s=Sa(Ui(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>`:m}<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">${Hi(i.key)}</span><span class="selected-copy"><strong id="selected-model">${De(t.id)}</strong><small>${i.name}</small></span>${t.pro?c`<span class="pro-space" aria-hidden="true"></span>`:m}${pu}</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><label class="pro-checkbox"><input type="checkbox" aria-label="Pro model" .checked="${e.id===t.pro.id}" @change="${this._togglePro}"><span>Pro</span></label>`:m}</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>`:m}</div>`}_modelSection({key:e,models:t}){return c`<fieldset><legend><span class="${`icon ${e}`}" aria-hidden="true">${Hi(e)}</span>${Et(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>${De(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">${je(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="${je(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 ${je(s)}`}" aria-pressed="${s===this.effort}" @click="${()=>this._setEffort(s)}">${je(s)}</button>`)}</div></div></div>`}};customElements.get("scan-model-picker")||customElements.define("scan-model-picker",qi);function uu(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 Pa=r=>r.normalize("NFKC").toLocaleLowerCase(),Vi=(r,e)=>r.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"}),Gi=Symbol("other repositories");function mr(r,e="",t=null,{includeSingletonOrganizations:i=!1}={}){let s=r.map(g=>({...g,...g.special?{owner:null,name:g.label}:uu(g.label)})),o=new Map;for(let g of s)g.owner!=null&&o.set(g.owner,(o.get(g.owner)??0)+1);let n=i?1:2,a=[...o].filter(([,g])=>g>=n).toSorted(([g],[k])=>Vi(g,k)).map(([g,k])=>({value:g,name:g,count:k})),l=g=>(o.get(g.owner)??0)<n,d=s.filter(g=>!g.special&&!g.reset&&l(g)).length;d>0&&a.push({value:Gi,name:"Other",count:d});let u=a.some(g=>g.value===t)?t:null,p=Pa(e.trim()).split(/\s+/u).filter(Boolean),h=g=>p.every(k=>Pa(g.label).includes(k)),f=s.filter(g=>g.reset||g.special&&h(g)),b=s.filter(g=>!g.reset&&!g.special&&h(g)&&(u==null||(u===Gi?l(g):g.owner===u))),v=new Map;for(let g of b){let k=(o.get(g.owner)??0)>=n?g.owner:null;v.has(k)||v.set(k,[]),v.get(k).push(g)}let y=[...v].toSorted(([g],[k])=>g==null?1:k==null?-1:Vi(g,k)).map(([g,k])=>({label:g??(a.some(C=>C.value!==Gi)?"Other":null),organization:g!=null,options:k.toSorted((C,L)=>Vi(C.label,L.label))}));return{facets:a,activeFacet:u,pinned:f,sections:y,count:b.length+f.filter(g=>!g.reset).length,total:s.filter(g=>!g.reset).length,showFacets:a.length>1}}var Wi=class extends F{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 mr(this.options,this._query,this._facet)}};customElements.get("repository-selector")||customElements.define("repository-selector",Wi);var Ki=class extends F{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",Ki);S();_e();function se(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 At(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 Zi(r){return(r??[]).filter(e=>!["resource:base64","directory"].includes(e.format))}function hu(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}=At(e.files);o!=null&&s.push(`${o.toLocaleString()} LoC`)}else e.summary&&(Number.isSafeInteger(e.summary.files)&&e.summary.files>=0&&s.push(`${e.summary.files.toLocaleString()} files`),Number.isSafeInteger(e.summary.lines)&&e.summary.lines>=0&&s.push(`${e.summary.lines.toLocaleString()} LoC`));return{value:e.id,label:e.filename,detail:i,format:t,secondary:s.join(" \xB7 ")}})}var Ji=class extends F{static properties={bundles:{attribute:!1}};static styles=[F.styles,z`.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=hu(this.bundles))}optionIcon(e){return c`<span class="bundle-icon" aria-hidden="true">${e.format==="sourcemap"?P(we):c`<img src="./stasis.svg" alt="">`}</span>`}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",Ji);S();S();var fr=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>`,gr=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg>`,br=z`.row-action{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;padding:.25rem;border:0;border-radius:var(--ui-radius, 4px);color:var(--muted);background:transparent}.row-action:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.row-action:disabled{opacity:.4}.row-action svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.4}`;var Mt=r=>({kind:r,sourceIds:[null],ids:new Set}),Yi=class extends A{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=Mt("bundle"),this._link=Mt("repository")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("tooltip-root-connected",{bubbles:!0,composed:!0}))}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 _selectedParents(){let e=this._parents;return this._current.sourceIds.map(t=>e.find(i=>i.id===t)).filter(Boolean)}get _parent(){return this._selectedParents[0]}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(){let e=this._selectedParents;return e.length===0?[]:this.mode==="merge"?(this._sources?.merge?.results??[]).filter(t=>t.bundleId===e[0].id):(this._sources?.link?.reports??[]).filter(t=>this._current.kind==="workspace"?e[0].reports.includes(t.id):t.repoIds.some(i=>e.some(s=>s.id===i)))}get selection(){let e=this._selectedParents,t=e[0],i=t?this.mode==="link"&&this._current.kind==="repository"?{kind:"repository",ids:e.map(s=>s.id),label:e.map(s=>s.label).join(", ")}:{kind:this._current.kind,id:t.id,label:t.label??t.filename}:null;return{mode:this.mode,source:i,inputs:this._loading||this._error?[]:this._inputs.filter(s=>this._current.ids.has(s.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=Mt("bundle"),this._link=Mt(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,t=0){if(t<0||t>=this._current.sourceIds.length||this._current.sourceIds.includes(e)||!this._parents.some(s=>s.id===e))return;let i=new Set(this.mode==="link"&&this._current.kind==="repository"?this._inputs.map(s=>s.id):[]);this._setCurrent({...this._current,sourceIds:this._current.sourceIds.map((s,o)=>o===t?e:s)}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(s=>!i.has(s.id)||this._current.ids.has(s.id)).map(s=>s.id))}),this._notify()}get _canAddRepository(){return this.mode==="link"&&this._current.kind==="repository"&&!this._loading&&!this._current.sourceIds.includes(null)&&this._parents.some(e=>!this._current.sourceIds.includes(e.id))}_addRepository(){this._canAddRepository&&(this._link={...this._link,sourceIds:[...this._link.sourceIds,null]},this._focusRepository(this._link.sourceIds.length-1))}_removeRepository(e){this.mode!=="link"||this._link.kind!=="repository"||this._loading||this._link.sourceIds.length<=1||e<0||e>=this._link.sourceIds.length||(this._link={...this._link,sourceIds:this._link.sourceIds.filter((t,i)=>i!==e)},this._link={...this._link,ids:new Set(this._inputs.filter(t=>this._link.ids.has(t.id)).map(t=>t.id))},this._notify(),this._focusRepository(Math.min(e,this._link.sourceIds.length-1)))}async _focusRepository(e){await this.updateComplete,this.renderRoot?.querySelectorAll("repository-selector")[e]?.renderRoot?.querySelector(".trigger")?.focus()}_changeKind(e){["workspace","repository"].includes(e)&&(e==="workspace"&&!Array.isArray(this._sources?.link?.workspaces)||(e!==this._link.kind&&(this._link=Mt(e)),this._selectOnlySource(),this._notify()))}_selectOnlySource(){this.mode==="link"&&this._current.sourceIds.length===1&&this._current.sourceIds[0]==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;if(this.mode==="link"&&(t==="workspace"?!Array.isArray(this._sources.link?.workspaces):t!=="repository"))return;let i=this.mode==="link"&&t==="repository"?e.source.ids??[e.source.id]:[e.source.id],s=[...new Set(i)].filter(o=>o!=null);this._setCurrent({kind:t,sourceIds:s.length>0?s:[null],ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(o=>e.inputIds.includes(o.id)).map(o=>o.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>`:m}<div class="field">${e?c`<span>Bundle with scan results</span>`:m} ${e?c`<bundle-selector .bundles="${this._parents}" .value="${this._current.sourceIds[0]}" ?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.sourceIds[0]}" ?disabled="${this._loading}" @workspace-change="${n=>this._selectSource(n.detail.value)}"></workspace-selector>`:this._repositoryFields()}</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>`}_repositoryFields(){let e=this._current.sourceIds,t=this._scopeOptions;return c`<div class="repository-fields"><div class="repository-rows">${e.map((i,s)=>c`<div class="repository-row"><repository-selector .options="${t.filter(o=>o.value===i||!e.includes(o.value))}" .value="${i}" label="${`Choose repository ${s+1}`}" ?disabled="${this._loading}" @repository-change="${o=>this._selectSource(o.detail.value,s)}"></repository-selector>${e.length>1?c`<button type="button" class="row-action" aria-label="${`Remove repository ${s+1}`}" ?disabled="${this._loading}" @click="${()=>this._removeRepository(s)}">${gr}</button>`:m}</div>`)}</div><button type="button" class="row-action" aria-label="Add repository" ?disabled="${!this._canAddRepository}" @click="${()=>this._addRepository()}">${fr}</button></div>`}_row(e){let t=this.mode==="link"?e.appFindings:e.findings,i=[e.model?De(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),s=e.title??e.filename,o=i.join(" \xB7 ");return c`<label class="option"><input type="checkbox" ?disabled="${this._loading}" .checked="${this._current.ids.has(e.id)}" @change="${n=>this._toggle(e.id,n.target.checked)}">${P(Ei[e.analyzer]??Ei.default)}<span class="copy"><strong data-tooltip-truncated data-tooltip="${s}">${s}</strong><span data-tooltip-truncated data-tooltip="${o}">${o}</span></span></label>`}static styles=z`
|
|
88
|
+
`;S();var Ia=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>`;S();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="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>`;S();var Ma=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>`;S();var La=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>`;S();var za=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>`;S();var Oa=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>`;S();var Ta=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 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z"/></svg>
|
|
89
|
+
`;S();var Na=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 Pa={anthropic:Ra,deepseek:Ea,google:Aa,moonshot:Fi,moonshotai:Fi,nvidia:Ma,openai:La,openrouter:za,qwen:Oa,xiaomi:Ta,"x-ai":Ia,"z-ai":Na},uu=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 Hi(r){return Object.hasOwn(Pa,r)?Pa[r]:uu}var hu=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>`,qi=class extends A{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=z`:host{display:block;min-width:0;container:scan-controls / inline-size}*{box-sizing:border-box}.layout{display:grid;grid-template-columns:minmax(16rem,1fr) minmax(14rem,1fr);gap:1.25rem;align-items:start}.layout.with-extra{grid-template-columns:minmax(16rem,.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:var(--ui-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:var(--ui-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,.pro-checkbox{position:absolute;right:2.05rem;top:50%;transform:translateY(-50%);align-items:center;justify-content:center;gap:.3rem;width:3.65rem;height:1.65rem;padding:.2rem .3rem;color:var(--muted);font:inherit;font-size:.65rem;font-weight:600;cursor:default;user-select:none}.pro-toggle{display:var(--switch-button-display, inline-flex);border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg)}.pro-checkbox{display:var(--switch-checkbox-display, none)}.pro-checkbox input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent)}.pro-toggle:hover{border-color:var(--muted);color:var(--text)}.pro-track{position:relative;flex:0 0 1.3rem;height:.8rem;border-radius:var(--ui-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.xiaomi{color:#ff6900}.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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-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:var(--ui-radius, 4px);background:var(--bg);color:var(--text);font:inherit}@container scan-controls (max-width: 50rem){.layout.with-extra{grid-template-columns:minmax(16rem,1fr) minmax(14rem,1fr)}.layout.with-extra .extra{grid-column:1 / -1;align-self:start;min-height:0}}@container scan-controls (max-width: 33rem){.layout,.layout.with-extra{grid-template-columns:minmax(0,1fr);gap:1rem}.layout.with-extra .extra{grid-column:auto}}`;constructor(){super(),this.loadModels=ot,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(st(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 ji(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=Ui(this._models),d=l.reduce((R,M)=>R+M.models.length,0),m=Math.min(3,l.length,Math.ceil((d+l.length*1.5)/9)),p=parseFloat(getComputedStyle(s).fontSize),u=0;for(let R of s.querySelectorAll(".choice span, legend")){let M=document.createRange();M.selectNodeContents(R),u=Math.max(u,M.getBoundingClientRect().width)}let f=Math.max(11*p,Math.min(18*p,u+2.5*p)),b=1.3*p+2,v=Math.max(1,Math.min(m,Math.floor((window.innerWidth-a*2-b+p)/(f+p)))),y=Math.min(v*f+(v-1)*p+b,window.innerWidth-a*2),g=Math.max(a,Math.min(o.left,window.innerWidth-y-a));if(this._menuColumns=v,await this.updateComplete,e!==this._positionRequest||!this.isConnected||!t.open)return;s.style.left=`${g}px`,s.style.width=`${y}px`,s.style.setProperty("--model-columns",v),s.style.maxHeight=`${Math.max(0,window.innerHeight-a*2)}px`;let k=s.getBoundingClientRect().height,C=window.innerHeight-o.bottom-n-a,L=o.top-n-a,I=C<k&&L>C?o.top-n-k:o.bottom+n;s.style.bottom="auto",s.style.top=`${Math.max(a,Math.min(I,window.innerHeight-k-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:st(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=Et(e.id),s=Ca(Ui(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">${Hi(i.key)}</span><span class="selected-copy"><strong id="selected-model">${De(t.id)}</strong><small>${i.name}</small></span>${t.pro?c`<span class="pro-space" aria-hidden="true"></span>`:h}${hu}</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><label class="pro-checkbox"><input type="checkbox" aria-label="Pro model" .checked="${e.id===t.pro.id}" @change="${this._togglePro}"><span>Pro</span></label>`: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">${Hi(e)}</span>${Et(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>${De(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">${je(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="${je(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 ${je(s)}`}" aria-pressed="${s===this.effort}" @click="${()=>this._setEffort(s)}">${je(s)}</button>`)}</div></div></div>`}};customElements.get("scan-model-picker")||customElements.define("scan-model-picker",qi);function mu(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 Ba=r=>r.normalize("NFKC").toLocaleLowerCase(),Vi=(r,e)=>r.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"}),Gi=Symbol("other repositories");function mr(r,e="",t=null,{includeSingletonOrganizations:i=!1}={}){let s=r.map(g=>({...g,...g.special?{owner:null,name:g.label}:mu(g.label)})),o=new Map;for(let g of s)g.owner!=null&&o.set(g.owner,(o.get(g.owner)??0)+1);let n=i?1:2,a=[...o].filter(([,g])=>g>=n).toSorted(([g],[k])=>Vi(g,k)).map(([g,k])=>({value:g,name:g,count:k})),l=g=>(o.get(g.owner)??0)<n,d=s.filter(g=>!g.special&&!g.reset&&l(g)).length;d>0&&a.push({value:Gi,name:"Other",count:d});let m=a.some(g=>g.value===t)?t:null,p=Ba(e.trim()).split(/\s+/u).filter(Boolean),u=g=>p.every(k=>Ba(g.label).includes(k)),f=s.filter(g=>g.reset||g.special&&u(g)),b=s.filter(g=>!g.reset&&!g.special&&u(g)&&(m==null||(m===Gi?l(g):g.owner===m))),v=new Map;for(let g of b){let k=(o.get(g.owner)??0)>=n?g.owner:null;v.has(k)||v.set(k,[]),v.get(k).push(g)}let y=[...v].toSorted(([g],[k])=>g==null?1:k==null?-1:Vi(g,k)).map(([g,k])=>({label:g??(a.some(C=>C.value!==Gi)?"Other":null),organization:g!=null,options:k.toSorted((C,L)=>Vi(C.label,L.label))}));return{facets:a,activeFacet:m,pinned:f,sections:y,count:b.length+f.filter(g=>!g.reset).length,total:s.filter(g=>!g.reset).length,showFacets:a.length>1}}var Wi=class extends F{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 mr(this.options,this._query,this._facet)}};customElements.get("repository-selector")||customElements.define("repository-selector",Wi);var Ki=class extends F{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",Ki);S();we();function se(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 At(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 Zi(r){return(r??[]).filter(e=>!["resource:base64","directory"].includes(e.format))}function fu(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}=At(e.files);o!=null&&s.push(`${o.toLocaleString()} LoC`)}else e.summary&&(Number.isSafeInteger(e.summary.files)&&e.summary.files>=0&&s.push(`${e.summary.files.toLocaleString()} files`),Number.isSafeInteger(e.summary.lines)&&e.summary.lines>=0&&s.push(`${e.summary.lines.toLocaleString()} LoC`));return{value:e.id,label:e.filename,detail:i,format:t,secondary:s.join(" \xB7 ")}})}var Ji=class extends F{static properties={bundles:{attribute:!1}};static styles=[F.styles,z`.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=fu(this.bundles))}optionIcon(e){return c`<span class="bundle-icon" aria-hidden="true">${e.format==="sourcemap"?P(_e):c`<img src="./stasis.svg" alt="">`}</span>`}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",Ji);S();S();var fr=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>`,gr=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg>`,br=z`.row-action{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;padding:.25rem;border:0;border-radius:var(--ui-radius, 4px);color:var(--muted);background:transparent}.row-action:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.row-action:disabled{opacity:.4}.row-action svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.4}`;var It=r=>({kind:r,sourceIds:[null],ids:new Set}),Yi=class extends A{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=It("bundle"),this._link=It("repository")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("tooltip-root-connected",{bubbles:!0,composed:!0}))}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 _selectedParents(){let e=this._parents;return this._current.sourceIds.map(t=>e.find(i=>i.id===t)).filter(Boolean)}get _parent(){return this._selectedParents[0]}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(){let e=this._selectedParents;return e.length===0?[]:this.mode==="merge"?(this._sources?.merge?.results??[]).filter(t=>t.bundleId===e[0].id):(this._sources?.link?.reports??[]).filter(t=>this._current.kind==="workspace"?e[0].reports.includes(t.id):t.repoIds.some(i=>e.some(s=>s.id===i)))}get selection(){let e=this._selectedParents,t=e[0],i=t?this.mode==="link"&&this._current.kind==="repository"?{kind:"repository",ids:e.map(s=>s.id),label:e.map(s=>s.label).join(", ")}:{kind:this._current.kind,id:t.id,label:t.label??t.filename}:null;return{mode:this.mode,source:i,inputs:this._loading||this._error?[]:this._inputs.filter(s=>this._current.ids.has(s.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=It("bundle"),this._link=It(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,t=0){if(t<0||t>=this._current.sourceIds.length||this._current.sourceIds.includes(e)||!this._parents.some(s=>s.id===e))return;let i=new Set(this.mode==="link"&&this._current.kind==="repository"?this._inputs.map(s=>s.id):[]);this._setCurrent({...this._current,sourceIds:this._current.sourceIds.map((s,o)=>o===t?e:s)}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(s=>!i.has(s.id)||this._current.ids.has(s.id)).map(s=>s.id))}),this._notify()}get _canAddRepository(){return this.mode==="link"&&this._current.kind==="repository"&&!this._loading&&!this._current.sourceIds.includes(null)&&this._parents.some(e=>!this._current.sourceIds.includes(e.id))}_addRepository(){this._canAddRepository&&(this._link={...this._link,sourceIds:[...this._link.sourceIds,null]},this._focusRepository(this._link.sourceIds.length-1))}_removeRepository(e){this.mode!=="link"||this._link.kind!=="repository"||this._loading||this._link.sourceIds.length<=1||e<0||e>=this._link.sourceIds.length||(this._link={...this._link,sourceIds:this._link.sourceIds.filter((t,i)=>i!==e)},this._link={...this._link,ids:new Set(this._inputs.filter(t=>this._link.ids.has(t.id)).map(t=>t.id))},this._notify(),this._focusRepository(Math.min(e,this._link.sourceIds.length-1)))}async _focusRepository(e){await this.updateComplete,this.renderRoot?.querySelectorAll("repository-selector")[e]?.renderRoot?.querySelector(".trigger")?.focus()}_changeKind(e){["workspace","repository"].includes(e)&&(e==="workspace"&&!Array.isArray(this._sources?.link?.workspaces)||(e!==this._link.kind&&(this._link=It(e)),this._selectOnlySource(),this._notify()))}_selectOnlySource(){this.mode==="link"&&this._current.sourceIds.length===1&&this._current.sourceIds[0]==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;if(this.mode==="link"&&(t==="workspace"?!Array.isArray(this._sources.link?.workspaces):t!=="repository"))return;let i=this.mode==="link"&&t==="repository"?e.source.ids??[e.source.id]:[e.source.id],s=[...new Set(i)].filter(o=>o!=null);this._setCurrent({kind:t,sourceIds:s.length>0?s:[null],ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(o=>e.inputIds.includes(o.id)).map(o=>o.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.sourceIds[0]}" ?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.sourceIds[0]}" ?disabled="${this._loading}" @workspace-change="${n=>this._selectSource(n.detail.value)}"></workspace-selector>`:this._repositoryFields()}</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>`}_repositoryFields(){let e=this._current.sourceIds,t=this._scopeOptions;return c`<div class="repository-fields"><div class="repository-rows">${e.map((i,s)=>c`<div class="repository-row"><repository-selector .options="${t.filter(o=>o.value===i||!e.includes(o.value))}" .value="${i}" label="${`Choose repository ${s+1}`}" ?disabled="${this._loading}" @repository-change="${o=>this._selectSource(o.detail.value,s)}"></repository-selector>${e.length>1?c`<button type="button" class="row-action" aria-label="${`Remove repository ${s+1}`}" ?disabled="${this._loading}" @click="${()=>this._removeRepository(s)}">${gr}</button>`:h}</div>`)}</div><button type="button" class="row-action" aria-label="Add repository" ?disabled="${!this._canAddRepository}" @click="${()=>this._addRepository()}">${fr}</button></div>`}_row(e){let t=this.mode==="link"?e.appFindings:e.findings,i=[e.model?De(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),s=e.title??e.filename,o=i.join(" \xB7 ");return c`<label class="option"><input type="checkbox" ?disabled="${this._loading}" .checked="${this._current.ids.has(e.id)}" @change="${n=>this._toggle(e.id,n.target.checked)}">${P(Ei[e.analyzer]??Ei.default)}<span class="copy"><strong data-tooltip-truncated data-tooltip="${s}">${s}</strong><span data-tooltip-truncated data-tooltip="${o}">${o}</span></span></label>`}static styles=z`
|
|
90
90
|
:host { display: block; min-width: 0; }
|
|
91
91
|
* { box-sizing: border-box; }
|
|
92
92
|
button, .field > span, .list-head, .empty:not([role='alert']) { cursor: default; user-select: none; -webkit-user-select: none; }
|
|
@@ -122,8 +122,8 @@ ${f.join(`
|
|
|
122
122
|
.copy span { max-width: 55%; color: var(--muted); font-size: .66rem; }
|
|
123
123
|
.empty { margin: 0; padding: 1rem .9rem; color: var(--muted); font-size: .76rem; }
|
|
124
124
|
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
125
|
-
`};customElements.get("scan-report-inputs")||customElements.define("scan-report-inputs",Yi);S();S();var mu=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h7M6 8h7M6 12h7M3 4h.01M3 8h.01M3 12h.01"/></svg>`,fu=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>`,Xi=class extends A{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?m:"scan-depth-description"}">${[[!1,"List",mu],[!0,"Isolate",fu]].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?m: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=z`: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:var(--ui-radius, 8px);background:var(--bg)}.depth-options:before{content:"";position:absolute;inset:.2rem auto .2rem .2rem;width:calc((100% - .4rem)/2);border-radius:var(--ui-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:var(--ui-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",Xi);var Qi=["security","generic","correctness"],gu=r=>JSON.stringify([r.mode,r.model,r.effort,r.isolate]);function Ba(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 Da(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:st(t)}:null}function es(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:Qi.includes(i.mode)?i.mode:"generic",model:s.id,effort:s.efforts.includes(i.effort)?i.effort:st(s),isolate:!!i.isolate}}):[]}function ts(r){let e=new Set;return r.map(t=>{let i=gu(t),s=e.has(i);return e.add(i),s})}var rs=class extends A{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=es(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&&!ts(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=Ba(this._rows),t=Da((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=es([{...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=ts(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>`:m} ${hr(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="${G(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>${De(e.model)}</strong></span><span class="app-model-effort">Effort: <strong>${je(e.effort)}</strong></span></summary><div class="app-model-controls"><scan-model-picker .loadModels="${this._sharedModels}" .value="${G(e.model)}" .effort="${G(e.effort)}" @model-change="${t=>{t.stopPropagation(),this._changeAppModel(t.detail)}}"></scan-model-picker></div></details>`:m}_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}`:m}"><div class="mode" role="radiogroup" aria-label="Scan mode">${Qi.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="${G(e.model)}" .effort="${G(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>`:m}</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=z`: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:var(--ui-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:var(--ui-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:var(--ui-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",rs);S();_e();var ja=`: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:var(--ui-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:var(--ui-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:var(--ui-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}}
|
|
126
|
-
`;var
|
|
125
|
+
`};customElements.get("scan-report-inputs")||customElements.define("scan-report-inputs",Yi);S();S();var gu=c`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h7M6 8h7M6 12h7M3 4h.01M3 8h.01M3 12h.01"/></svg>`,bu=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>`,Xi=class extends A{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",gu],[!0,"Isolate",bu]].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=z`: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:var(--ui-radius, 8px);background:var(--bg)}.depth-options:before{content:"";position:absolute;inset:.2rem auto .2rem .2rem;width:calc((100% - .4rem)/2);border-radius:var(--ui-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:var(--ui-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",Xi);var Qi=["security","generic","correctness"],vu=r=>JSON.stringify([r.mode,r.model,r.effort,r.isolate]);function Da(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 ja(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:st(t)}:null}function es(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:Qi.includes(i.mode)?i.mode:"generic",model:s.id,effort:s.efforts.includes(i.effort)?i.effort:st(s),isolate:!!i.isolate}}):[]}function ts(r){let e=new Set;return r.map(t=>{let i=vu(t),s=e.has(i);return e.add(i),s})}var rs=class extends A{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=es(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&&!ts(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=Da(this._rows),t=ja((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=es([{...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=ts(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} ${hr(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="${G(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>${De(e.model)}</strong></span><span class="app-model-effort">Effort: <strong>${je(e.effort)}</strong></span></summary><div class="app-model-controls"><scan-model-picker .loadModels="${this._sharedModels}" .value="${G(e.model)}" .effort="${G(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">${Qi.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="${G(e.model)}" .effort="${G(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=z`: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:var(--ui-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:var(--ui-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:var(--ui-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",rs);S();we();var Ua=`: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:var(--ui-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:var(--ui-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:var(--ui-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}}
|
|
126
|
+
`;var _u=[{id:"code",label:"Code",detail:"Run a full scan of the codebase",icon:lr},{id:"dependencies",label:"Dependency alerts",detail:"Validate incoming alerts against actual code",icon:Bn},{id:"agentic",label:"Agentic",detail:"Free-form analysis with your instructions",icon:jn},{id:"report",label:"Reports",detail:"Link saved reports or merge scan results",icon:et}],wu=[{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"}],xu=[{id:"link",label:"Link",detail:"Link findings across saved reports"},{id:"merge",label:"Merge",detail:"Combine scan results for one bundle"}],is=class extends A{static properties={mode:{},analyzer:{},reportMode:{}};static styles=$(Ua);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?wu:xu,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>${_u.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">${P(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",is);S();var Fa=z`
|
|
127
127
|
/* The containing page owns the outer gutters, in both Manage and local. */
|
|
128
128
|
:host { display: block; box-sizing: border-box; color: var(--text); }
|
|
129
129
|
* { box-sizing: border-box; }
|
|
@@ -261,19 +261,19 @@ ${f.join(`
|
|
|
261
261
|
@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; } }
|
|
262
262
|
@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; } }
|
|
263
263
|
@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; } }
|
|
264
|
-
`;S();var Fa=[{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 Ha(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=>!Fa.some(s=>s.key===i))?null:[{id:"",label:"All files",subtitle:"Everything"},...Fa.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 ss=class extends A{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 m;let t=Ha(e);if(!t)return c`<label class="scope-field"><span>Scope</span><select aria-label="${this.label}" .value="${G(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=z`:host{display:block;min-width:0}*{box-sizing:border-box}.scope-toggle,.scope-field{cursor:default;user-select:none;-webkit-user-select:none}.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:var(--ui-radius, 5px);overflow:hidden;background:var(--bg)}.scope-option{position:relative;flex:1 0 auto}.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:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font:inherit;font-size:.76rem}:host([compact]) .scope-toggle{min-height:0;gap:.3rem .5rem}:host([compact]) .scope-option span{height:auto;padding:2px 8px;font-size:.68rem;line-height:1.2}:host([compact]) .scope-field{font-size:.68rem}:host([compact]) .scope-description{display:none}:host([compact]) select{width:auto;max-width:22ch;padding:2px 6px;font-size:.68rem;line-height:1.2}`};customElements.get("bundle-scope-selector")||customElements.define("bundle-scope-selector",ss);var qa={code:P(lr),report:P(et)},os=class extends A{static properties={hideHeading:{type:Boolean,attribute:"hide-heading"},sourceLoading:{type:Boolean,attribute:!1},selection:{attribute:!1},scopeLabel:{type:String,attribute:"scope-label"},createBundleHref:{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=Ua;constructor(){super(),this.loadModels=ot,this.canRun=!0,this.hideHeading=!1,this._tab="new",this._mode="code",this.source=null,this.selection=null,this.scopeLabel="Repository",this._pendingSelection=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("selection")&&(this._pendingSelection=this.selection),e.has("source")&&(this._bundles=this.source?.bundles??[],this._repositories=this.source?.repositories??[],this._scans=this.source?.scans??[]),e.has("source")||e.has("selection")){this._excluded=new Set,this._excludedModules=new Set;let t=this._repositories.find(o=>o.id===this._selectedRepoId),i=this._pendingSelection,s=i?this._bundles.find(o=>o.id===i.bundleId&&(i.repoId==null||o.repoId===i.repoId)):this._bundles.find(o=>o.id===this._selectedBundleId&&o.repoId===this._selectedRepoId)??(this.scopeLabel==="Workspace"?null:this._bundles.find(o=>o.id===this._selectedBundleId))??(t?this._bundles.find(o=>o.repoId===t.id):this._bundles[0]);this._selectedRepoId=s?.repoId??i?.repoId??t?.id??this._repositories[0]?.id??"unattached",this._selectedBundleId=s?.id??null,this._reason=s?.reasons?.[0]?.id??"",i&&(this._tab="new",this._mode=i.mode==="report"?"report":"code",i.mode==="report"&&(this._reportMode="link",this._reportRestore=null,this._reportInput=null,this._pendingSelection=null),this._notice=i.mode==="report"||s||this.source==null?null:"The selected bundle is no longer available in this source. Choose another bundle.",s&&(this._pendingSelection=null))}}updated(e){(e.has("source")||e.has("selection")||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,repoId:s.repoId,repo:s.repo}: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 _scopeFiles(){let e=this._reasonData,t=e?.fileModules,i=e?.filePaths?new Set(e.filePaths):null;return(this._bundle?.files??[]).filter(s=>(t==null||t.includes(s.module))&&(i==null||i.has(s.path))).toSorted((s,o)=>o.bytes-s.bytes)}get _files(){return Zi(this._scopeFiles)}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>`:m} ${this._bundleError?c`<p class="notice" role="alert">Couldn’t load bundle: ${this._bundleError}<button @click="${()=>{this._loadSelectedBundle()}}">Retry</button></p>`:m} ${this._tab==="new"?this._newScan():this._history()}</div>`}_newScan(){let e=this._mode,t=this._bundle,i=e==="code"?this._files:e==="dependencies"?this._scopeFiles:t?.files??[],s=this._excluded,o=this._excludedModules,n=i.filter(f=>!s.has(f.path)&&!o.has(f.module)),a=At(t?.files?n:null),l=new Map;for(let f of i){let b=l.get(f.module)??{bytes:0,count:0,included:0};b.bytes+=f.bytes,b.count++,s.has(f.path)||b.included++,l.set(f.module,b)}let d=[...l.keys()].toSorted((f,b)=>l.get(b).bytes-l.get(f).bytes||this._packageLabel(f).localeCompare(this._packageLabel(b))),u=i.slice(0,80),p=d.filter(f=>!o.has(f)).length,h=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="${f=>this._changeMode(f.detail.mode)}" @scan-analyzer-change="${f=>this._setOption("analyzer",f.detail.analyzer)}" @scan-report-mode-change="${f=>{this._reportMode=f.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="${f=>{this._reportInput=f.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>${se(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(f=>{let{bytes:b,count:v,included:y}=l.get(f),g=!o.has(f);return c`<label class="${`package-row ${g?"":"excluded"}`}"><input type="checkbox" .checked="${g}" @change="${k=>this._toggleModule(f)}"><span class="package-name" data-tooltip-truncated data-tooltip="${this._packageLabel(f)}">${this._packageLabel(f)}</span><span class="package-size">${se(b)} · ${y}/${v}</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(f=>{let b=!s.has(f.path)&&!o.has(f.module);return c`<label class="${`file ${b?"":"excluded"}`}"><input type="checkbox" .checked="${b}" @change="${v=>this._toggleFile(f,v.target.checked)}"><span class="file-copy"><span class="file-path" data-tooltip-truncated data-tooltip="${f.path}">${f.path}</span><span class="file-meta">${f.size} · ${this._packageLabel(f.module)}</span></span></label>`})}</div>`}</section></div></details>`:m} ${e==="agentic"?this._agenticPanel():m}<slot name="access"></slot>${this._optionsPanel(e,t,e==="report"?h.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:Zi(d.files)}:d.summary?{...d,summary:{...d.summary,files:d.summary.codeFiles}}:d):this._repoBundles,{lines:s}=At(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","dependencies"].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>${this.scopeLabel}</span>${this.scopeLabel==="Workspace"?c`<workspace-selector .options="${l}" .value="${this._selectedRepoId}" @workspace-change="${d=>this._selectRepoById(d.detail.value)}"></workspace-selector>`:c`<repository-selector .options="${l}" .value="${this._selectedRepoId}" @repository-change="${d=>this._selectRepoById(d.detail.value)}"></repository-selector>`}</div>`:m}<div class="field">${n||this.createBundleHref?this._bundleLabel():m}${i.length>0?c`<bundle-selector .bundles="${i}" .value="${e?.id??null}" @bundle-change="${d=>this._selectBundleById(d.detail.value)}"></bundle-selector>`:this._emptyBundles()}</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">${qa.report}<strong>${t.length}</strong><span>files</span></div><div class="metric">${qa.code}<strong>${s==null?"\u2014":s.toLocaleString()}</strong><span>LoC</span></div><div class="metric">${P(we)}<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>`:m}</div></div></section>`}_bundleLabel(){let e=this.createBundleHref?.(this._selectedRepoId);return c`<div class="bundle-label"><span>Bundle</span>${e?c`<a class="create-bundle-button" href="${e}">Create a bundle</a>`:m}</div>`}_emptyBundles(){let e=this.createBundleHref?.(this._selectedRepoId);return c`<div class="choice-empty"><span>${this._bundles.length===0?"No stored bundles.":`No stored bundles for this ${this.scopeLabel.toLowerCase()}.`}</span>${e?c`<a href="${e}">Create?</a>`:m}</div>`}_scopeField(e){if(!["code","agentic","dependencies"].includes(this._mode))return m;let t=(e?.reasons??[]).filter(i=>i.id!=="all");return t.length===0?m: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>`:m}</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":m}" .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>`:m}</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>`:m;return c`<div class="scan-row"><div class="scan-main"><div class="scan-title"><strong data-tooltip-truncated data-tooltip="${e.bundleName}">${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>`:m}${e.status==="stopped"?c`<button type="button" class="action" @click="${()=>this._restartScan(e)}">Restart as new scan</button>`:m}</span><span aria-hidden="true"></span></div>`}_selectBundle(e){this._pendingSelection=null,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,this._pendingSelection=null;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="row-action" aria-label="Add prompt" @click="${()=>this._addPrompt()}">${fr}</button></div><div class="agentic-fields">${hr(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="${G(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="row-action" aria-label="${`Remove prompt ${t+1}`}" @click="${()=>this._removePrompt(e.id)}">${gr}</button>`:m}</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)):e==="dependencies"?this._scopeFiles: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==="report"?this._reportMode==="merge"?"Merge scan results":"Link saved reports":this._reasonData?.label??"All files",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!=="report"&&(a.repoId=this._selectedRepoId,a.scopeId=this._reason),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.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&&(e.repoId==null||i.repoId===e.repoId));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??"",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",os);S();te();var Se=r=>r??m;B();S();var _u={__proto__:null,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",py:"python",pyw:"python",pyi:"python",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"},Va={__proto__:null,module:"javascript",commonjs:"javascript","module-typescript":"typescript","commonjs-typescript":"typescript",json:"json",solidity:"solidity",php:"php",shell:"bash",rust:"rust",java:"java",objc:"objectivec",objcpp:"objectivec",c:"c","c-header":"c",cpp:"cpp","cpp-header":"cpp",ruby:"ruby",podspec:"ruby",podfile:"ruby",fastlane:"ruby","podfile-lock":"yaml",xml:"markup"};function vr(r,e){if(typeof e=="string"&&Va[e])return Va[e];if(typeof r!="string")return null;let t=r.slice(r.lastIndexOf("/")+1),i=t.lastIndexOf(".");return i<=0?null:_u[t.slice(i+1).toLowerCase()]??null}var xu=V`<path d="M8 1C4.5 1 4 1.5 4 3v1h4v1H3C1.5 5 1 6 1 8s.5 3 2 3h1V9c0-1.5 1-2 2.5-2H10c1.5 0 2-.5 2-2V3c0-1.5-.5-2-4-2Z" fill="#3776ab"/><path d="M8 1C4.5 1 4 1.5 4 3v1h4v1H3C1.5 5 1 6 1 8s.5 3 2 3h1V9c0-1.5 1-2 2.5-2H10c1.5 0 2-.5 2-2V3c0-1.5-.5-2-4-2Z" fill="#ffd43b" transform="rotate(180 8 8)"/><circle cx="6" cy="2.8" r=".65" fill="#fff"/><circle cx="10" cy="13.2" r=".65" fill="#fff"/>`,$u=V`<path d="m7 0 2 0 .4 1.6 1.3.5 1.4-.9 1.4 1.4-.9 1.4.5 1.3 1.6.4v2l-1.6.4-.5 1.3.9 1.4-1.4 1.4-1.4-.9-1.3.5-.4 1.6H7l-.4-1.6-1.3-.5-1.4.9-1.4-1.4.9-1.4-.5-1.3L1.3 9V7l1.6-.4.5-1.3-.9-1.4 1.4-1.4 1.4.9 1.3-.5Z" fill="#c97d5d"/><circle cx="8" cy="8" r="4.4" fill="var(--surface, #fff)"/><text x="8" y="10.8" text-anchor="middle" fill="currentColor" font-family="serif" font-size="8" font-weight="700">R</text>`;var ku=V`<g fill="#8892bf" transform="translate(0 .5) scale(.5)"><path d="M28 10a4 4 0 0 0-4-4h-6v6a6 6 0 0 1-6 6h-2v2h2v6h4v-6h8v6h4V16h2v-4a2 2 0 0 0-2-2"/><path d="M12 4H8v2a6 6 0 0 0-6 6v6a2 2 0 0 0 2 2v2H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5H6a2 2 0 0 0 2-2v-8h4a4 4 0 0 0 4-4V8a4 4 0 0 0-4-4M6 14H4v-2h2Z"/></g>`;function Su(r,e){let t=vr(r,e);return["javascript","jsx"].includes(t)?"js":["typescript","tsx"].includes(t)?"ts":["solidity","rust","php","python","json"].includes(t)?t:"generic"}function ns(r,e){let t=Su(r,e),i=t==="js"||t==="ts"?V`<rect x="1" y="1" width="14" height="14" rx="2" fill=${t==="js"?"#e6c84f":"#3178c6"}/><text x="8" y="11.5" text-anchor="middle" fill=${t==="js"?"#202020":"#fff"} font-family="sans-serif" font-size="8" font-weight="700">${t.toUpperCase()}</text>`:t==="solidity"?V`<path d="m8 1 4 6-4 2-4-2Z" fill="currentColor"/><path d="m4 8 4 2 4-2-4 7Z" fill="currentColor" opacity=".65"/>`:t==="rust"?$u:t==="php"?ku:t==="python"?xu:t==="json"?V`<path d="M3 1h6l5 5v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1Z" fill="#e6c84f"/><path d="M9 1v4a1 1 0 0 0 1 1h4Z" fill="#202020" opacity=".2"/><path d="M6.5 6.5h-.75a.75.75 0 0 0-.75.75v1.5L4 9.5l1 .75v1.5a.75.75 0 0 0 .75.75h.75m3-6h.75a.75.75 0 0 1 .75.75v1.5l1 .75-1 .75v1.5a.75.75 0 0 1-.75.75H9.5" fill="none" stroke="#202020" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/>`:V`<path d="M4 1.5h5l3 3v10H4Zm5 0v3h3M6 8h4M6 10.5h4" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/>`;return c`<svg class="source-file-icon" data-file-type="${t}" width="16" height="16" viewBox="0 0 16 16" style="flex: none" aria-hidden="true">${i}</svg>`}var Ga=c`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" style="flex: none" aria-hidden="true"><path d="M1.5 4V2.5h5L8 4h6.5v9h-13Z" stroke-linejoin="round"/></svg>`,m1=c`<svg class="bundle-code-tree-npm" width="12" height="12" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 1h14v14H1Zm3 3v8h4V6h2v6h2V4Z"/></svg>`,f1=c`<svg class="bundle-code-tree-soldeer" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="m8 1 6 3.5v7L8 15l-6-3.5v-7Z" fill="none" stroke="currentColor" stroke-width="1"/><path d="m8 3 2.5 4L8 8.5 5.5 7Zm-2.5 5L8 9.5 10.5 8 8 13Z" fill="currentColor"/></svg>`,g1=c`<svg class="bundle-code-tree-composer" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1 15 4.5v7L8 15l-7-3.5v-7Z" fill="#8892bf"/><path d="m1 4.5 7 3.5 7-3.5M8 8v7M4.5 2.75l7 3.5" fill="none" stroke="var(--surface, #fff)" stroke-width=".9"/></svg>`,b1=c`<svg class="bundle-code-tree-cargo" width="12" height="12" viewBox="9.25 6.14 14 14" aria-hidden="true"><path d="m16.264 11.547 6.2-2.446v8.16l-6.2 2.485Zm0-.019-6.2-2.481v8.123l6.2 2.522Z" fill="#e5ac3d" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m16.277 11.508 6.169-2.435-6.2-2.531-6.2 2.467Z" fill="#e3b04e" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m12.82 10.149 6.196-2.467" fill="none" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m18.301 7.395-6.24 2.484 1.482.593 6.196-2.466z" fill="#fff" stroke="#73561f" stroke-miterlimit="10" stroke-width=".04741218643894885px" opacity=".3"/><path d="m13.562 10.47-1.453-.565v1.645l.201-.136.18.285.104.04.138-.121.137.228.129.05.189-.166.238.332.137.053zm-1.423 7.576 1.461.545-.023-1.645-.2.139-.184-.282-.104-.039-.136.123-.14-.226-.131-.049-.186.169-.243-.329-.137-.051z" fill="#fff" stroke="#73561f" stroke-miterlimit="10" stroke-width=".06661495224335688px" opacity=".3"/><path d="m21.426 13.49-.172-.039V13.4l.148-.208a.1.1 0 0 0 .018-.065.035.035 0 0 0-.037-.03l-.189.006-.015-.045.118-.222a.07.07 0 0 0 .007-.063.04.04 0 0 0-.045-.018l-.2.051-.024-.037.084-.229a.06.06 0 0 0 0-.058.04.04 0 0 0-.051-.006l-.2.094-.032-.027.047-.227a.05.05 0 0 0-.016-.052.05.05 0 0 0-.056.007l-.2.133-.039-.017.007-.215a.04.04 0 0 0-.026-.043.07.07 0 0 0-.058.02l-.184.166-.045-.006-.033-.2a.036.036 0 0 0-.036-.032.08.08 0 0 0-.057.031l-.164.194-.049.005-.071-.168a.036.036 0 0 0-.044-.021.1.1 0 0 0-.055.042l-.138.214-.05.016-.107-.135a.04.04 0 0 0-.05-.008.1.1 0 0 0-.05.051l-.107.226-.05.026-.138-.1a.05.05 0 0 0-.055 0 .1.1 0 0 0-.044.058l-.071.228-.049.036-.164-.054a.06.06 0 0 0-.057.017.1.1 0 0 0-.036.063l-.033.223-.045.044-.184-.01a.08.08 0 0 0-.058.029.1.1 0 0 0-.026.065l.007.209-.039.05-.2.035a.1.1 0 0 0-.056.04.1.1 0 0 0-.016.065l.046.187-.032.054-.2.079a.1.1 0 0 0-.051.049.07.07 0 0 0 0 .062l.084.157-.024.057-.2.119a.1.1 0 0 0-.045.057.06.06 0 0 0 .007.057l.118.122-.015.058-.189.155a.1.1 0 0 0-.037.062.045.045 0 0 0 .018.05l.148.082v.055l-.172.185a.1.1 0 0 0-.028.065.04.04 0 0 0 .028.041l.172.039v.051l-.148.208a.1.1 0 0 0-.018.065.035.035 0 0 0 .037.03l.189-.006.015.045-.118.222a.07.07 0 0 0-.007.063.04.04 0 0 0 .045.018l.2-.051.024.037-.084.229a.06.06 0 0 0 0 .058.04.04 0 0 0 .051.006l.2-.094.032.027-.046.227a.05.05 0 0 0 .016.051.05.05 0 0 0 .056-.007l.2-.133.039.017-.007.215a.04.04 0 0 0 .026.043.07.07 0 0 0 .058-.02l.184-.166.045.006.033.2a.035.035 0 0 0 .036.032.08.08 0 0 0 .057-.031l.164-.194.049-.005.071.168a.036.036 0 0 0 .044.02.1.1 0 0 0 .055-.042l.138-.214.05-.016.107.135a.04.04 0 0 0 .05.008.1.1 0 0 0 .05-.051l.107-.226.05-.027.138.1a.05.05 0 0 0 .055 0 .1.1 0 0 0 .044-.058l.071-.228.049-.036.164.054a.06.06 0 0 0 .057-.017.1.1 0 0 0 .036-.063l.033-.223.045-.044.184.01a.08.08 0 0 0 .058-.029.1.1 0 0 0 .026-.065l-.007-.209.039-.05.2-.035a.1.1 0 0 0 .056-.04.1.1 0 0 0 .016-.065l-.046-.187.017-.053.2-.079a.1.1 0 0 0 .051-.049.07.07 0 0 0 0-.062l-.084-.157.024-.057.2-.119a.1.1 0 0 0 .045-.057.06.06 0 0 0-.007-.057l-.118-.122.015-.058.189-.155a.1.1 0 0 0 .037-.062.045.045 0 0 0-.018-.05l-.148-.082v-.055l.172-.185a.1.1 0 0 0 .028-.065.04.04 0 0 0-.014-.039m-1.153 1.988c-.066.013-.108-.037-.094-.112a.21.21 0 0 1 .145-.16c.066-.013.108.037.094.112a.21.21 0 0 1-.145.16m-.059-.39a.19.19 0 0 0-.132.146l-.061.325a2.3 2.3 0 0 1-.619.4 1.4 1.4 0 0 1-.632.123l-.061-.273c-.013-.057-.072-.072-.132-.033l-.252.164a1 1 0 0 1-.13-.106l1.226-.521q.022-.007.023-.026v-.455c0-.013-.009-.012-.023-.006l-.359.152v-.288l.388-.165a.16.16 0 0 1 .239.115c.015.057.049.249.072.3s.117.172.217.13l.611-.26.022-.012a3 3 0 0 1-.139.23Zm-1.7 1.13c-.066.043-.131.026-.145-.037a.2.2 0 0 1 .094-.192c.066-.043.131-.026.145.037a.2.2 0 0 1-.09.192Zm-.465-1.779a.18.18 0 0 1-.062.2c-.062.055-.134.056-.161 0a.18.18 0 0 1 .062-.2c.066-.051.138-.053.165 0Zm-.143.416.263-.234a.16.16 0 0 0 .057-.178l-.054-.105.213-.09v1l-.429.182a1.4 1.4 0 0 1-.057-.407c.001-.052.001-.11.011-.168Zm1.152-.587v-.3l.506-.215c.026-.011.185-.047.185.077 0 .1-.122.192-.222.234l-.47.2Zm1.84-.516v.118l-.154.065a.04.04 0 0 0-.022.036v.074a.31.31 0 0 1-.176.3c-.078.043-.165.036-.176-.01-.046-.253-.123-.278-.245-.327a1 1 0 0 0 .308-.578.3.3 0 0 0-.235-.315.57.57 0 0 0-.322.026l-1.592.677a2.7 2.7 0 0 1 .84-.853l.188.127c.042.029.113 0 .157-.063l.21-.3a.94.94 0 0 1 1.027.33l-.144.4c-.025.069 0 .128.057.13l.277.011q.004.073.004.152Zm-1.591-1.044c.049-.069.126-.1.172-.069s.045.113 0 .183-.126.1-.172.069-.044-.114.005-.184Zm1.427.6a.19.19 0 0 1 .161-.133c.062 0 .089.066.062.142a.19.19 0 0 1-.161.133c-.057-.006-.085-.07-.058-.15Z" opacity=".55"/><path d="M0 16.309h22.926v9.971L45.72 13.139 22.926 0v9.97H0z" fill="#231f20" transform="matrix(0 -.029 .022 .013 10.451 11.138)"/><path d="M0 16.309h22.926v9.971L45.72 13.139 22.926 0v9.97H0z" fill="#231f20" transform="matrix(0 -.029 .022 .013 15.013 12.984)"/></svg>`;var Wa=`:host{padding:0}.field,.browser,.entry-points{line-height:1.5}.note{color:var(--muted);font-size:.75rem}.source-fields{display:grid;grid-template-columns:minmax(12rem,1fr) minmax(0,1.6fr);align-items:end;gap:1rem;margin:1rem 0}.field{display:flex;flex-direction:column;gap:.4rem;min-width:0;font-size:.75rem;color:var(--muted)}.revision{display:flex;align-items:center;min-width:0;height:2rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg)}.revision:focus-within{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.revision-name{flex:1}.revision input{height:100%;min-height:0;padding:.3rem .6rem;min-width:0;border:0;border-radius:0;background:transparent;color:var(--text);font-size:.76rem}.revision input:focus-visible{outline:none}.revision-switch{display:flex;flex:none;align-self:stretch;padding:2px;gap:2px}.revision-switch button{display:grid;place-items:center;width:1.8rem;padding:0;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted)}.revision-switch button:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.revision-switch button:focus-visible{outline-offset:-2px}.revision-switch button[aria-pressed=true]{color:var(--accent);background:color-mix(in srgb,var(--accent) 15%,var(--bg))}.revision-switch svg{width:1rem;height:1rem}.revision-expand{display:grid;place-items:center;align-self:stretch;flex:none;width:2rem;padding:0;border:0;border-radius:var(--ui-radius, 4px);color:var(--muted);background:transparent}.revision-expand svg{width:.9rem;height:.9rem}.revision-expand:hover:not(:disabled){color:var(--text)}.revision-expand:focus-visible{outline-offset:-2px}.revision-menu{visibility:hidden;position:fixed;inset:auto;margin:0;padding:.45rem;overflow:auto;overscroll-behavior:contain;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--surface-active);color:var(--text);box-shadow:0 .65rem 1.8rem #00000073}.revision-menu[data-positioned]{visibility:visible}.revision-options{display:grid;grid-template-columns:repeat(var(--revision-columns, 1),minmax(0,1fr));gap:.15rem .5rem}.revision-options button{min-width:0;padding:.4rem .6rem;border:0;border-radius:var(--ui-radius, 4px);background:transparent;color:var(--text);text-align:left;font-size:.76rem}.revision-options button span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.revision-options button[aria-selected=true]{color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,transparent)}.revision-options button:hover,.revision-options button[data-active]{background:color-mix(in srgb,var(--text) 8%,transparent)}.revision-options button[data-active]{outline:1px solid var(--accent);outline-offset:-1px}.revision-empty{margin:0;padding:.65rem;color:var(--muted);font-size:.75rem}button:disabled,input:disabled{opacity:.5}.browser{border:1px solid var(--border);border-radius:var(--ui-radius, 7px);overflow:hidden}.browser-head{display:flex;align-items:center;gap:.75rem;padding:.65rem .8rem;border-bottom:1px solid var(--border);background:var(--bg);font-size:.75rem}.commit-link{display:inline-flex;align-items:center;flex:none;gap:.3rem;margin-left:auto;color:var(--muted);text-decoration:none}.commit-link svg{width:1rem;height:1rem}.commit-link:hover{color:var(--accent)}.commit-link:focus-visible{outline:1px solid var(--accent);outline-offset:3px;border-radius:var(--ui-radius, 2px)}.breadcrumbs{display:flex;align-items:center;flex-wrap:wrap;gap:.35rem;min-width:0}.breadcrumbs button{border:0;padding:.1rem;background:transparent;color:var(--muted);overflow-wrap:anywhere}.breadcrumbs button[aria-current]{color:var(--text)}.breadcrumbs button:hover:not(:disabled){color:var(--accent)}.file-browser{min-height:18rem;max-height:50vh;overflow:auto;padding:.75rem}.file-browser:has(>.empty){display:grid;place-items:center}.file-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,16rem),1fr));gap:.5rem}.file-tile{display:flex;align-items:center;gap:.5rem;min-width:0;height:2.05rem;padding:.4rem .6rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font-size:.75rem}.file-tile>span:not(.arrow){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left}.file-tile input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent);flex:none}.file-tile:hover,.file-tile:focus-within{border-color:var(--accent)}.file-tile.selected{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--bg))}.directory{color:var(--muted)}.directory .arrow{margin-left:auto}.unsupported{opacity:.55}.empty{margin:0;padding:1rem;border:0;border-radius:0;text-align:center;color:var(--muted);font-size:.8rem;line-height:1.5}.error{color:var(--critical)}.message{padding:.5rem .8rem;color:var(--muted);font-size:.75rem;line-height:1.5}.text-action{border:0;padding:.1rem .2rem;color:var(--accent);background:transparent;font-size:.75rem}.entry-points{display:flex;align-items:center;gap:1rem;margin-top:1rem}.package-suggestions{display:flex;align-items:center;gap:1rem;margin-top:1rem;color:var(--muted);font-size:.75rem}.package-suggestions>div{flex:1;min-width:0}.package-suggestions p{margin:0 0 .4rem}.package-suggestions .suggestions-note{margin:.4rem 0 0}.package-suggestions ul{display:flex;flex-wrap:wrap;gap:.4rem .8rem;padding:0;margin:0;list-style:none;max-height:6rem;overflow:auto}.package-suggestions li{min-width:0;max-width:100%}.package-suggestions li code{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)}.package-suggestions .btn{flex:none;font-size:.72rem}.selection{flex:1;min-width:0}.selection .note{margin:.5rem 0 0}.selection-head{display:flex;align-items:center;gap:.75rem}.btn.clear-selection{min-height:1.65rem;padding:.2rem .5rem;font-size:.72rem}h2{margin:0;font-size:.8rem;font-weight:500}h2 span{color:var(--muted);margin-left:.4rem}.entry-points ul{padding:0;display:flex;flex-wrap:wrap;gap:.4rem;list-style:none;max-height:7rem;overflow:auto;margin:.6rem 0 0}.entry-points li{display:flex;align-items:center;gap:.4rem;min-width:0;max-width:100%;padding:.2rem .4rem;border:1px solid var(--border);border-radius:var(--ui-radius, 4px);background:var(--bg);font-size:.72rem}.entry-points li span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.entry-points li button{display:grid;place-items:center;flex:none;width:1.3rem;height:1.3rem;padding:0;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted);cursor:default}.entry-points li button svg{width:1rem;height:1rem}.entry-points li button:hover{color:var(--critical);background:color-mix(in srgb,var(--critical) 12%,transparent)}.entry-points li button:focus-visible{outline:1px solid var(--accent);outline-offset:1px}@container (width <= 45rem){.source-fields{grid-template-columns:1fr}}
|
|
265
|
-
`;S();function
|
|
266
|
-
`;var ls=["import","require","default"],Eu=[...ls,"node","node-addons","module-sync"],It=[{id:"node",label:"Node.js",conditions:["node"],automatic:Eu,icon:V`<path d="m8 1.5 5.5 3.2v6.6L8 14.5l-5.5-3.2V4.7Z"/><path d="M6 10V6l4 4V6"/>`},{id:"browser",label:"Browser",conditions:["browser","module"],automatic:ls,icon:V`<rect x="1.5" y="2.5" width="13" height="11" rx="1.5"/><path d="M1.5 6h13M4 4.3h.1m2 0h.1"/>`},{id:"metro",label:"Metro",conditions:["react-native"],automatic:ls,icon:V`<rect x="4" y="1.5" width="8" height="13" rx="2"/><path d="M6.5 3.5h3M7 12.5h2"/>`}],Xa=16-Math.max(...It.map(r=>r.conditions.length)),as=[{id:"ios",label:"iOS"},{id:"android",label:"Android"}],Au=new Intl.ListFormat("en",{type:"conjunction"});function Qa(){return{preset:"node",conditions:["node"],platforms:[]}}var cs=class extends A{static styles=[x(N),x(Ya)];static properties={showConditions:{attribute:!1},_preset:{state:!0},_manual:{state:!0},_platforms:{state:!0},_draft:{state:!0},_error:{state:!0},_manualOpen:{state:!0}};constructor(){super(),this.showConditions=!0,this._preset="node",this._manual=[],this._platforms=["ios","android"],this._draft="",this._error="",this._manualOpen=!1}get value(){return{preset:this._preset,conditions:this.conditions,platforms:this._preset==="metro"?[...this._platforms]:[]}}get presetConditions(){return It.find(e=>e.id===this._preset).conditions}get automaticConditions(){return It.find(e=>e.id===this._preset).automatic}get conditions(){return[...new Set([...this.presetConditions,...this._preset==="metro"?[]:this._manual])]}notifyChange(){this.dispatchEvent(new CustomEvent("conditions-change",{detail:this.value,bubbles:!0,composed:!0}))}selectPreset(e){It.find(i=>i.id===e)&&(this._preset=e,this._draft="",this._error="",this.notifyChange())}togglePlatform(e){if(!as.some(i=>i.id===e))return;let t=this._platforms.includes(e);t&&this._platforms.length===1||(this._platforms=as.map(i=>i.id).filter(i=>i===e?!t:this._platforms.includes(i)),this.notifyChange())}addConditions(){if(this._preset==="metro")return;let e=this._draft.trim().split(/[\s,]+/u).filter(Boolean);if(e.length===0)return;if(e.some(i=>this.automaticConditions.includes(i)&&!this.presetConditions.includes(i))){this._error=`${Au.format(this.automaticConditions)} are handled automatically.`;return}if(e.some(i=>i.length>64||i.startsWith(".")||/^\d+$/u.test(i))){this._error="Use condition names of up to 64 characters, without a leading dot or an all-numeric name.";return}let t=[...new Set([...this._manual,...e.filter(i=>!this.presetConditions.includes(i))])];if(t.length>Xa){this._error=`Use up to ${Xa} manual conditions.`;return}this._manual=t,this._draft="",this._error="",this.notifyChange()}removeCondition(e){this.presetConditions.includes(e)||(this._manual=this._manual.filter(t=>t!==e),this._error="",this.notifyChange())}render(){let e=this._preset!=="metro",t=this.automaticConditions.filter(i=>i!=="import"&&i!=="require");return c`<section aria-label="${this.showConditions?"Conditions":"Bundle actions"}"><div class="conditions-head" ?data-conditions-hidden="${!this.showConditions}"><h2 id="conditions-heading">Conditions</h2><div class="presets" role="group" aria-label="Condition preset">${It.map(i=>c`<button type="button" aria-pressed="${this._preset===i.id}" @click="${()=>this.selectPreset(i.id)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${i.icon}</svg>${i.label}</button>`)}</div>${this._preset==="metro"?c`<div class="platforms" role="group" aria-label="Metro platforms"><span>Platforms</span>${as.map(({id:i,label:s})=>c`<label><input type="checkbox" .checked="${this._platforms.includes(i)}" ?disabled="${this._platforms.includes(i)&&this._platforms.length===1}" @change="${()=>this.togglePlatform(i)}">${s}</label>`)}</div>`:m} <button type="button" class="manual-toggle" ?hidden="${!e}" aria-expanded="${this._manualOpen}" aria-controls="manual-conditions" @click="${()=>{this._manualOpen=!this._manualOpen}}"><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="m6 4 4 4-4 4"/></svg>Manual conditions</button><slot name="actions"></slot></div><div id="manual-conditions" ?hidden="${!this.showConditions||!e||!this._manualOpen}"><form class="condition-editor" @submit="${i=>{i.preventDefault(),this.addConditions()}}"><ul aria-label="Export conditions">${this.conditions.map(i=>this.presetConditions.includes(i)?c`<li class="preset"><code>${i}</code></li>`:c`<li><code>${i}</code><button type="button" aria-label="${`Remove condition ${i}`}" @click="${()=>this.removeCondition(i)}"><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></button></li>`)}</ul><div class="condition-input"><input type="text" aria-label="Add conditions" aria-describedby="conditions-help" aria-invalid="${!!this._error}" aria-errormessage="condition-error" placeholder="Add condition…" autocomplete="off" maxlength="1040" .value="${this._draft}" @input="${i=>{this._draft=i.target.value,this._error=""}}" @keydown="${i=>{i.key===" "&&!i.isComposing&&(i.preventDefault(),this.addConditions())}}" @blur="${()=>this.addConditions()}"></div></form><p id="conditions-help">Package export conditions. <code>import</code> / <code>require</code>${t.map((i,s)=>c`${s<t.length-1?", ":t.length>1?", and ":" and "}<code>${i}</code>`)} are automatic.</p>${this._error?c`<p id="condition-error" class="error" role="alert">${this._error}</p>`:m}</div></section>`}};customElements.define("bundle-conditions",cs);var el=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="8" cy="8" r="3"/><path d="M1 8h4m6 0h4"/></svg>`,Mu=100,Iu=[{kind:"branch",label:"Branch",icon:c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="4" cy="3" r="1.5"/><circle cx="4" cy="13" r="1.5"/><circle cx="12" cy="3" r="1.5"/><path d="M4 4.5v7m0-3h3a5 5 0 0 0 5-4"/></svg>`},{kind:"tag",label:"Tag",icon:c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round" aria-hidden="true"><path d="M2 2h5.5l6.5 6.5-5.5 5.5L2 7.5Z"/><circle cx="5" cy="5" r="1"/></svg>`},{kind:"commit",label:"Commit SHA",icon:el}];async function ds(r,e,t){let i=await $(`/api/admin/repositories/${r}?${new URLSearchParams(e)}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:t});if(!i.ok){let s=await i.json().catch(()=>null);if(s?.error==="github-rate-limited"){let o=Number(i.headers.get("retry-after")),n=Math.ceil(o/60),a=Number.isFinite(o)&&o>0?` Try again in about ${n} ${n===1?"minute":"minutes"}.`:" Try again after the limit resets.";throw new Error(`GitHub\u2019s API rate limit has been reached.${a}`)}throw s?.error==="github-status-403"?new Error("GitHub denied this request. Check repository access and the GitHub App\u2019s read permissions."):s?.error==="github-unauthorized"?new Error("GitHub authentication has expired or was revoked. Sign in again and check the repository App installation."):s?.error==="github-unreachable"?new Error("Could not connect to GitHub. Try again shortly."):i.status===404?new Error("This repository, revision, or directory is unavailable."):i.status===403?new Error("Repository access is required to browse files."):new Error("Could not load repository files from GitHub. Try again.")}return i.json()}var ps=class extends A{static styles=[x(N),x(Wa)];static properties={installTooltips:{attribute:!1},createBundle:{attribute:!1},_building:{state:!0},_opening:{state:!0},_buildError:{state:!0},initialRepoId:{attribute:!1},_repos:{state:!0},_loadingRepos:{state:!0},_reposError:{state:!0},_repoId:{state:!0},_refs:{state:!0},_refKind:{state:!0},_refName:{state:!0},_path:{state:!0},_entries:{state:!0},_selected:{state:!0},_commit:{state:!0},_packageEntryPoints:{state:!0},_solidityEntryPoints:{state:!0},_soliditySuggestionsLimited:{state:!0},_loadingRefs:{state:!0},_loading:{state:!0},_error:{state:!0},_refsError:{state:!0},_limited:{state:!0},_revisionOpen:{state:!0},_revisionQuery:{state:!0},_activeRevision:{state:!0}};constructor(){super(),this._repos=[],this._loadingRepos=!0,this._reposError="",this.initialRepoId=null,this._building=!1,this._opening=!1,this._buildError="",this._repoId=null,this._refs={branches:[],tags:[]},this._refKind="branch",this._refName="",this._path="",this._entries=null,this._selected=new Set,this._dismissedSuggestions=new Set,this._bundleConditions=Qa(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._commit="",this._directories=new Map,this._loadingRefs=!1,this._loading=!1,this._error="",this._refsError="",this._limited=!1,this._revisionOpen=!1,this._revisionQuery="",this._activeRevision=-1,this._onViewport=()=>this.positionRevisionSuggestions()}connectedCallback(){super.connectedCallback(),globalThis.addEventListener("resize",this._onViewport),globalThis.addEventListener("scroll",this._onViewport,!0)}updated(e){e.has("installTooltips")&&this.installTooltips?.(this.renderRoot),this.positionRevisionSuggestions()}firstUpdated(){this.loadRepositories()}async loadRepositories(){this._reposRequest?.abort(),this.selectRepository(null),this._repos=[],this._reposError="",this._loadingRepos=!0;let e=new AbortController;this._reposRequest=e;try{let t=await ds("browsable",{},e.signal);if(e.signal.aborted)return;this._repos=t.repos,this._repos.some(i=>i.repoId===this.initialRepoId)&&this.selectRepository(this.initialRepoId)}catch{e.signal.aborted||(this._reposError="Could not load repositories. Try again.")}finally{e.signal.aborted||(this._loadingRepos=!1)}}disconnectedCallback(){this._buildRequest?.abort(),this._opening=!1,globalThis.removeEventListener("resize",this._onViewport),globalThis.removeEventListener("scroll",this._onViewport,!0),clearTimeout(this._browseTimer),this._reposRequest?.abort(),this._refsRequest?.abort(),this._request?.abort(),this._directories.clear(),this._dismissedSuggestions.clear(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,super.disconnectedCallback()}resetFiles(){this._buildError="",clearTimeout(this._browseTimer),this._request?.abort(),this._directories.clear(),this._loading=!1,this._entries=null,this._path="",this._commit="",this._selected=new Set,this._dismissedSuggestions.clear(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._error="",this._limited=!1}async selectRepository(e){if(this.closeRevisionSuggestions(),this._refsRequest?.abort(),this.resetFiles(),this._repoId=e,this._refs={branches:[],tags:[]},this._refsError="",this._refKind="branch",this._refName="",e==null){this._loadingRefs=!1;return}let t=new AbortController;this._refsRequest=t,this._loadingRefs=!0;try{let{defaultContents:i,...s}=await ds("refs",{repoId:e,withDefault:"true"},t.signal);if(t.signal.aborted)return;this._refs=s,this._refName=s.defaultBranch||s.branches[0]||"",i?this.useDirectory(i,""):this._refName&&this.loadDirectory("")}catch(i){t.signal.aborted||(this._refsError=i.message)}finally{t.signal.aborted||(this._loadingRefs=!1)}}changeRevision(e,t){this._refsRequest?.abort(),this._loadingRefs=!1,this.resetFiles(),this._refKind=e,this._refName=t}selectRevisionType(e){this._refKind!==e&&(this.closeRevisionSuggestions(),this.changeRevision(e,e==="branch"&&this._refs.defaultBranch||""),this._refName&&this.loadDirectory(""))}editRevision(e){this.changeRevision(this._refKind,e);let t=e.trim();if(!t)return;let i=this._refKind==="branch"?this._refs.branches:this._refs.tags;this._refKind!=="commit"&&(i.includes(t)||this._refKind==="branch"&&t===this._refs.defaultBranch)?this.loadDirectory(""):this._browseTimer=setTimeout(()=>{this.loadDirectory("")},350)}revisionSuggestions(){let e=this._refKind==="branch"?this._refs.branches:this._refKind==="tag"?this._refs.tags:[],t=this._refKind==="branch"&&this._refs.defaultBranch?[this._refs.defaultBranch,...e.filter(s=>s!==this._refs.defaultBranch)]:e,i=this._revisionQuery.trim().toLowerCase();return t.filter(s=>s.toLowerCase().includes(i))}showRevisionSuggestions(e=!0){this._refKind==="commit"||this._repoId==null||this._loadingRefs||(this._revisionQuery=e?"":this._refName,this._activeRevision=-1,this.renderRoot.querySelector(".revision-menu").showPopover())}closeRevisionSuggestions(){this.renderRoot?.querySelector(".revision-menu")?.hidePopover(),this._revisionOpen=!1,this._activeRevision=-1}pickRevision(e){this.editRevision(e),this.renderRoot.querySelector(".revision-name").focus({preventScroll:!0}),this.closeRevisionSuggestions()}positionRevisionSuggestions(){if(!this._revisionOpen)return;let e=this.renderRoot.querySelector(".revision-menu"),t=this.renderRoot.querySelector(".revision-name").getBoundingClientRect(),i=8,s=6,n=15*parseFloat(getComputedStyle(this).fontSize),a=Math.max(1,Math.min(3,Math.ceil(this.revisionSuggestions().length/8),Math.floor((window.innerWidth-2*i)/n))),l=Math.min(Math.max(t.width,a*n),window.innerWidth-2*i);e.style.width=`${l}px`,e.style.setProperty("--revision-columns",a),e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-l-i))}px`;let d=window.innerHeight-t.bottom-s-i,u=t.top-s-i,p=d<Math.min(e.scrollHeight,320)&&u>d;e.style.maxHeight=`${Math.max(0,Math.min(320,p?u:d))}px`,e.style.top=`${Math.max(i,p?t.top-e.offsetHeight-s:t.bottom+s)}px`,e.dataset.positioned=""}async revisionKeyDown(e){if(e.key==="Escape"||e.key==="Tab"){e.key==="Escape"&&this._revisionOpen&&(e.preventDefault(),e.stopPropagation()),this.closeRevisionSuggestions();return}if(e.key==="Enter"){let i=this.revisionSuggestions()[this._activeRevision];this._revisionOpen&&i!=null?(e.preventDefault(),this.pickRevision(i)):this.closeRevisionSuggestions();return}if(this._refKind==="commit"||!["ArrowDown","ArrowUp"].includes(e.key))return;e.preventDefault(),this._revisionOpen||this.showRevisionSuggestions();let t=this.revisionSuggestions().length;this._activeRevision=t===0?-1:e.key==="ArrowDown"?Math.min(this._activeRevision+1,t-1):this._activeRevision<=0?t-1:this._activeRevision-1,await this.updateComplete,this.renderRoot.querySelector("[data-active]")?.scrollIntoView({block:"nearest"})}async loadDirectory(e,t=!1){if(clearTimeout(this._browseTimer),this._repoId==null||!this._refName.trim())return;t&&this.resetFiles(),this._request?.abort();let i=new AbortController;this._request=i,this._path=e,this._entries=null,this._error="",this._limited=!1,this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._loading=!1;let s=this._refName.trim();if(this._refKind==="commit"&&!/^[a-f\d]{7,40}$/iu.test(s)){this._error="Enter a commit SHA with 7 to 40 hexadecimal characters.";return}let o=this._commit||(this._refKind==="commit"?s:`${this._refKind==="branch"?"heads":"tags"}/${s}`),n=JSON.stringify([this._repoId,this._commit,e]),a=this._commit&&this._directories.get(n);if(a){this._directories.delete(n),this._directories.set(n,a),this._entries=a.entries,this._limited=a.limited,this._packageEntryPoints=a.packageEntryPoints,this._solidityEntryPoints=a.solidityEntryPoints,this._soliditySuggestionsLimited=a.soliditySuggestionsLimited;return}this._loading=!0;try{let l=await ds("contents",{repoId:this._repoId,ref:o,path:e},i.signal);if(i.signal.aborted)return;this.useDirectory(l,e)}catch(l){i.signal.aborted||(this._directories.clear(),this._error=l.message)}finally{i.signal.aborted||(this._loading=!1)}}useDirectory(e,t){this._path=t,this._commit=e.commit,this._entries=e.entries.toSorted((s,o)=>+(o.type==="dir")-+(s.type==="dir")||s.name.localeCompare(o.name)),this._limited=e.limited,this._packageEntryPoints=e.packageEntryPoints??[],this._solidityEntryPoints=e.solidityEntryPoints??[],this._soliditySuggestionsLimited=e.soliditySuggestionsLimited??!1;let i=[...this._packageEntryPoints,...this._solidityEntryPoints].filter(s=>!this._dismissedSuggestions.has(s));if(this._selected=new Set([...this._selected,...i]),/^[a-f\d]{40}$/iu.test(e.commit)){let s=JSON.stringify([this._repoId,e.commit,t]);this._directories.set(s,{entries:this._entries,limited:this._limited,packageEntryPoints:this._packageEntryPoints,solidityEntryPoints:this._solidityEntryPoints,soliditySuggestionsLimited:this._soliditySuggestionsLimited}),this._directories.size>Mu&&this._directories.delete(this._directories.keys().next().value)}}toggleFile(e){let t=new Set(this._selected);t.has(e)?(t.delete(e),this._dismissedSuggestions.add(e)):(t.add(e),this._dismissedSuggestions.delete(e)),this._selected=t}clearFiles(){for(let e of this._selected)this._dismissedSuggestions.add(e);this._selected=new Set}hasScriptEntryPoints(){return[...this._selected].some(e=>/\.[cm]?[tj]sx?$/iu.test(e))}async buildBundle(){if(this._building||this._opening||!this.createBundle||!this._commit||this._selected.size===0)return;let e=new AbortController;this._buildRequest=e,this._building=!0,this._buildError="";try{let t=await this.createBundle({repoId:this._repoId,commit:this._commit,entries:[...this._selected],conditions:this._bundleConditions},e.signal);e.signal.aborted||(this._opening=!0,this.dispatchEvent(new CustomEvent("bundle-created",{detail:t,bubbles:!0,composed:!0})))}catch(t){e.signal.aborted||(this._buildError=t.message)}finally{this._building=!1}}render(){let e=this._building||this._opening,t=this._repos.find(a=>a.repoId===this._repoId),i=this._path.split("/").filter(Boolean),s=t&&this._commit?`https://github.com/${[...t.fullName.split("/"),"tree",this._commit,...i].map(encodeURIComponent).join("/")}`:null,o=this.revisionSuggestions(),n=this._refKind==="commit"?"Commit SHA":this._refKind==="tag"?"Tag":"Branch";return c`<p class="intro ui-hint">Choose a repository and revision, then select files to use as entry points.</p><div ?inert="${e}"><div class="source-fields"><div class="field"><span>Repository</span><repository-selector label="Repository" ?disabled="${this._loadingRepos}" .options="${this._repos.map(a=>({value:a.repoId,label:a.fullName}))}" .value="${this._repoId}" @repository-change="${a=>this.selectRepository(a.detail.value)}"></repository-selector></div><form class="revision" @focusout="${a=>{a.currentTarget.contains(a.relatedTarget)||this.closeRevisionSuggestions()}}" @submit="${a=>{a.preventDefault(),this.loadDirectory("",!0)}}"><div class="revision-switch" role="group" aria-label="Revision type">${Iu.map(({kind:a,label:l,icon:d})=>c`<button type="button" aria-label="${l}" data-tooltip="${l}" aria-pressed="${this._refKind===a}" ?disabled="${!t||this._loadingRefs}" @click="${()=>{this.selectRevisionType(a),this.renderRoot.querySelector(".revision-name").focus(),this.showRevisionSuggestions()}}">${d}</button>`)}</div><input class="revision-name" type="text" aria-label="${n}" role="${Se(this._refKind==="commit"?void 0:"combobox")}" aria-autocomplete="${Se(this._refKind==="commit"?void 0:"list")}" aria-expanded="${Se(this._refKind==="commit"?void 0:String(this._revisionOpen))}" aria-controls="${Se(this._refKind==="commit"?void 0:"bundle-revisions")}" aria-activedescendant="${Se(this._revisionOpen&&this._activeRevision>=0?`revision-${this._activeRevision}`:void 0)}" autocomplete="off" placeholder="${this._refKind==="commit"?"Commit SHA\u2026":`Choose or enter a ${this._refKind}\u2026`}" .value="${this._refName}" ?disabled="${!t||this._loadingRefs}" @focus="${()=>this.showRevisionSuggestions()}" @click="${()=>this.showRevisionSuggestions()}" @keydown="${this.revisionKeyDown}" @input="${a=>{this.editRevision(a.target.value),this.showRevisionSuggestions(!1)}}"> ${this._refKind==="commit"?m:c`<button type="button" class="revision-expand" aria-label="${`Show ${this._refKind} suggestions`}" aria-expanded="${this._revisionOpen}" ?disabled="${!t||this._loadingRefs}" @mousedown="${a=>a.preventDefault()}" @click="${()=>{this._revisionOpen?this.closeRevisionSuggestions():(this.renderRoot.querySelector(".revision-name").focus(),this.showRevisionSuggestions())}}"><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="revision-menu" id="bundle-revisions" popover="auto" role="listbox" aria-label="${`${n} suggestions`}" @beforetoggle="${a=>{this._revisionOpen=a.newState==="open",delete a.target.dataset.positioned,this._revisionOpen||(this._activeRevision=-1)}}"><div class="revision-options">${o.map((a,l)=>c`<button type="button" role="option" id="${`revision-${l}`}" aria-selected="${a===this._refName}" ?data-active="${l===this._activeRevision}" tabindex="-1" @mousedown="${d=>d.preventDefault()}" @click="${()=>this.pickRevision(a)}"><span data-tooltip-truncated data-tooltip="${a}">${a}</span></button>`)}</div>${o.length>0?m:c`<p class="revision-empty">${this._revisionQuery?"No matching suggestions. Enter a revision name to browse.":`No ${this._refKind} suggestions available.`}</p>`}</div></form></div>${this._reposError?c`<p class="message" role="alert">${this._reposError} <button type="button" class="text-action" @click="${()=>this.loadRepositories()}">Retry</button></p>`:m} ${this._refsError?c`<p class="message" role="status">${this._refsError} <button type="button" class="text-action" @click="${()=>this.selectRepository(this._repoId)}">Retry</button></p>`:m}<section class="browser" aria-label="Repository files" aria-busy="${this._loadingRepos||this._loading||this._loadingRefs}"><div class="browser-head"><nav class="breadcrumbs" aria-label="Repository directory"><button type="button" ?disabled="${!this._commit}" aria-current="${Se(this._path?void 0:"location")}" @click="${()=>this.loadDirectory("")}">${t?.fullName??"Repository"}</button>${i.map((a,l)=>c`<span aria-hidden="true">/</span><button type="button" aria-current="${Se(l===i.length-1?"location":void 0)}" @click="${()=>this.loadDirectory(i.slice(0,l+1).join("/"))}">${a}</button>`)}</nav>${s?c`<a class="commit-link" href="${s}" target="_blank" rel="noopener noreferrer" data-tooltip="${this._commit}" aria-label="${`View directory at commit ${this._commit.slice(0,7)} on GitHub`}">${el}<code>${this._commit.slice(0,7)}</code></a>`:m}</div><div class="file-browser">${this._loadingRepos||this._loading||this._loadingRefs?c`<p class="empty" role="status">${this._loadingRepos?"Loading repositories\u2026":this._loadingRefs?"Loading revisions\u2026":"Loading files\u2026"}</p>`:this._error?c`<p class="empty error" role="alert">${this._error} <button type="button" class="text-action" @click="${()=>this.loadDirectory(this._path)}">Retry</button></p>`:this._entries==null?c`<p class="empty">${t?"Choose a revision to browse its files.":this._repos.length>0?"Select a repository to browse its files.":"No accessible repositories available."}</p>`:this._entries.length===0?c`<p class="empty">This directory is empty.</p>`:c`<div class="file-grid">${this._entries.map(a=>a.type==="dir"?c`<button type="button" class="file-tile directory" @click="${()=>this.loadDirectory(a.path)}">${Ga}<span data-tooltip-truncated data-tooltip="${a.path}">${a.name}</span><span class="arrow" aria-hidden="true">›</span></button>`:c`<label class="${`file-tile ${this._selected.has(a.path)?"selected":""} ${a.type==="file"?"":"unsupported"}`}" data-tooltip="${a.type==="file"?m:`${a.path} (${a.type})`}"><input type="checkbox" aria-label="${`Select ${a.path} as an entry point`}" .checked="${this._selected.has(a.path)}" ?disabled="${a.type!=="file"}" @change="${()=>this.toggleFile(a.path)}">${ns(a.name)}<span data-tooltip-truncated data-tooltip="${a.type==="file"?a.path:m}">${a.name}</span></label>`)}</div>`}</div>${this._limited?c`<p class="message">Showing GitHub’s first 1,000 entries in this directory.</p>`:m}</section>${Ka(this._packageEntryPoints,this._selected,a=>{this._selected=new Set([...this._selected,...a])})} ${Za(this._solidityEntryPoints,this._selected,a=>{this._selected=new Set([...this._selected,...a])},this._soliditySuggestionsLimited)}<section class="entry-points" aria-label="Selected entry points"><div class="selection"><div class="selection-head"><h2>Entry points <span aria-live="polite">${this._selected.size}</span></h2>${this._selected.size>0?c`<button type="button" class="btn clear-selection" @click="${this.clearFiles}">Clear all</button>`:m}</div>${this._selected.size>0?c`<ul>${[...this._selected].map(a=>c`<li>${ns(a)}<span data-tooltip-truncated data-tooltip="${a}">${a}</span><button type="button" aria-label="${`Remove ${a}`}" @click="${()=>this.toggleFile(a)}"><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></button></li>`)}</ul>`:c`<p class="note">Select files above. You can choose entry points from multiple directories.</p>`}</div></section><bundle-conditions .showConditions="${this.hasScriptEntryPoints()}" @conditions-change="${a=>{this._bundleConditions=a.detail}}"><button type="button" slot="actions" class="btn primary" ?disabled="${e||!this.createBundle||!this._commit||this._selected.size===0||this._loading||this._loadingRefs}" @click="${this.buildBundle}">${this._opening?"Opening\u2026":this._building?"Creating\u2026":"Create a bundle"}</button></bundle-conditions></div>${e?c`<p class="message" role="status">${this._opening?"Opening bundle\u2026":"Building the selected entry points with Stasis\u2026"}</p>`:m} ${this._buildError?c`<p class="message error" role="alert">${this._buildError}</p>`:m}`}};customElements.define("managed-create-bundle",ps);var Lu=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"}),zu=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 Ou(r){let e=typeof r=="string"?r.slice(r.lastIndexOf("/")+1):"",t=e.lastIndexOf("."),i=t>0?e.slice(t+1).trim().toLowerCase():"",s=vr(r)??zu[i];return s?{key:s,label:Lu[s]??s}:i?{key:`extension:${i}`,label:`.${i}`}:{key:"other",label:"Other"}}function tl(r,e){let t=new Map,i=0,s=0;for(let[o,n]of r){let a=Ou(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))}}hs();var Tu=new Set(["module","commonjs","json","module-typescript","commonjs-typescript"]),Nu=new Set(["solidity","php","shell","rust"]),Pu=new Set(["java","kotlin","gradle","objc","objcpp","swift","c","cpp","c-header","cpp-header","ruby","python","cmake","podspec","podfile","podfile-lock","template","xml","env","fastlane","pbxproj"]),Bu=new Set(["resource","resource:base64"]),ol=new Set(["stat:file","stat:directory"]),Du=new Set([...Tu,...Nu,...Pu,...Bu,"patch","directory",...ol]),ms=r=>ol.has(r);var rl=r=>r==="directory"||r==="stat:directory"?"directory":"file";function ju(r,e,t){if(r===e)return r;let i=ms(r);if(i!==ms(e)&&rl(r)===rl(e))return i?e:r;throw new Error(`format conflict for '${t}' ('${e}' vs '${r}')`)}function Ue(r,e){return e===""?r:r==="."?e:`${r}/${e}`}var Uu=/^(?=[A-Za-z0-9-]{1,39}\/)[A-Za-z0-9](?:-?[A-Za-z0-9])*\/(?!\.\.?$)[\w.-]{1,100}$/u,Fu=/^(?!\.\.?(?:\/|$))[\w.~@+-]+(?:\/(?!\.\.?(?:\/|$))[\w.~@+-]+)*$/u,Hu=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u,fs={github:r=>typeof r=="string"&&Uu.test(r),directory:r=>typeof r=="string"&&r.length<=1024&&(r===""||Fu.test(r)),commit:r=>typeof r=="string"&&Hu.test(r)},nl=(r,e)=>r?.toLowerCase()===e?.toLowerCase();var _r=(r,e,t)=>{if(r===void 0)return;Fe(r)||_(!1,`${t} must be an object`);for(let s of Object.keys(r))Object.hasOwn(e,s)||_(!1,`unknown ${t} key '${s}'`);let i=Object.entries(e).map(([s,o])=>typeof o=="object"?[s,_r(r[s],o,`${t}.${s}`)]:(r[s]!==void 0&&!o(r[s])&&_(!1,`invalid ${t}.${s}: ${JSON.stringify(r[s])}`),[s,r[s]])).filter(([,s])=>s!==void 0);return i.length===0?void 0:Object.freeze(X(i))},xr=(r,e="bundle repo")=>_r(r,fs,e),qu=(r,e)=>e??(He(r)?"npm":void 0),al=(r,{ecosystem:e,repo:t},i)=>{if(t===void 0)return;qu(r,e)===void 0&&_(!1,`${i}: '${r}' is no dependency's bucket, and carries no repo`);let s=xr(t,`${i} module '${r}' repo`);return s?.github===void 0&&_(!1,`${i} module '${r}' repo has no github`),s},wr=({name:r,version:e,ecosystem:t,repo:i,files:s})=>({name:r,version:e,...t===void 0?{}:{ecosystem:t},...i===void 0?{}:{repo:i},files:s});function gs({name:r,version:e,ecosystem:t,repo:i,files:s},o,n){return _(t===void 0||typeof t=="string"),wr({name:r,version:e??void 0,ecosystem:t,repo:al(o,{ecosystem:t,repo:i},n),files:X(Object.entries(s))})}function ll(r,{scope:e="full"}={}){let t=new Set;for(let[i,{files:s}]of r)if(!(e!=="full"&&!He(i)))for(let o of Object.keys(s))t.add(Ue(i,o));return t}function Vu(r,{what:e,files:t,formats:i,scope:s}){if(r.includes("\\"))return"holds a '\\'";if(Lt(r))return"escapes the root";if(s!=="full"&&!He(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":ms(o)?`is a payload-free '${o}' record, not a file`:null}function cl(r,{what:e,files:t,formats:i,scope:s}){for(let o of r){let n=Vu(o,{what:e,files:t,formats:i,scope:s});_(n===null,`${e}: executable entry '${o}' ${n}`)}}function dl(r,{what:e,files:t,formats:i,scope:s="full"}){if(r===void 0)return new Set;let o=`${e}: executable`;_(Array.isArray(r),`${o} must be an array of file paths`);let n=new Set;for(let a of r)_(typeof a=="string"&&a!=="",`${o} entry must be a non-empty string`),_(!n.has(a),`${o} entry '${a}' is listed twice`),n.add(a);return cl(n,{what:e,files:t,formats:i,scope:s}),n}function pl(r,{what:e,modules:t,formats:i,scope:s}){if(r.size!==0)return cl(r,{what:e,files:ll(t,{scope:s}),formats:i,scope:s}),$r(r)}function _(r,e){if(!r)throw new Error(e)}function ul(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 yr=(r,e)=>ul(r[0],e[0]),Fe=r=>r&&[null,Object.prototype].includes(Object.getPrototypeOf(r)),X=r=>Object.setPrototypeOf(Object.fromEntries(r),null),$r=r=>[...r].toSorted(ul),bs=(r,{sorted:e=!0}={})=>{let t=e?[...r].toSorted(yr):[...r];return X(t.map(([i,s])=>[i,s instanceof Map?bs(s,{sorted:e}):s]))},il=(r,e)=>r.get(e)??r.set(e,new Map).get(e),hl=r=>new Map(Object.entries(r).map(([e,t])=>[e,Fe(t)?hl(t):t]));function Lt(r){if(r.startsWith("/"))return!0;if(!r.includes(".."))return!1;let e=0;for(let t of r.split("/"))if(!(t==="."||t==="")){if(t!=="..")e++;else if(--e<0)return!0}return!1}var ml=r=>r.includes("\\")||Lt(r),le=(r,e)=>_(!ml(r),`${e}: path '${r}' escapes the root or holds a '\\'`),fl=(r,e)=>_(typeof r=="string"&&r!==""&&!ml(r),`${e}: invalid entry ${JSON.stringify(r)}`);function gl(r,e){_(Array.isArray(r),`${e}: entries must be an array of file paths`);let t=new Set;for(let i of r)fl(i,e),_(!t.has(i),`${e}: entry '${i}' is listed twice`),t.add(i);return t}function bl(r,e){for(let t of r)fl(t,e);return $r(r)}function vl(r,e){le(r,"formats"),_(Du.has(e),`unknown format '${e}' for ${r}`)}function yl(r){_(Fe(r));let e=new Map;for(let[t,i]of Object.entries(r)){vl(t,i);let s=t===""?".":t;_(!e.has(s),`duplicate format key '${s}'`),e.set(s,i)}return e}function wl(r){for(let[e,t]of r)vl(e,t);return bs(r)}function _l(r){for(let[,e]of r){_(e instanceof Map);for(let[t,i]of e){le(t,"imports"),_(i instanceof Map);for(let[,s]of i){if(typeof s=="string"){le(s,"imports");continue}_(s instanceof Map&&s.size>0,"import target must be a file or a non-empty {platform: file} map");for(let[o,n]of s)_(typeof o=="string"&&o.length>0&&!o.includes("/"),`invalid platform key '${o}'`),_(typeof n=="string"),le(n,"imports")}}}}function xl(r){_(Fe(r));let e=hl(r);return _l(e),e}function $l(r){return _l(r),bs(r)}function kl(r,{skipEmpty:e=!1,repo:t=!0,what:i}={}){let s={modules:[],sources:[]};for(let[o,n]of r){if(e&&Object.keys(n.files).length===0)continue;let a=He(o);a&&_(n.name&&n.version&&n.files);let l=X(Object.entries(n.files).toSorted(yr));s[a?"modules":"sources"].push([o,wr({...n,repo:t?al(o,n,i):void 0,files:l})])}return{modules:X(s.modules.toSorted(yr)),sources:X(s.sources.toSorted(yr))}}function Gu(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 sl=r=>r instanceof Map?`{${[...r].map(([e,t])=>`${e}: ${t}`).join(", ")}}`:r;function Sl(r,e,t){let i=new Map,s=o=>{for(let[n,a]of o){let l=il(i,n);for(let[d,u]of a){let p=il(l,d);for(let[h,f]of u)p.has(h)?_(Gu(p.get(h),f),`${t}: import '${h}' from '${d}' resolves differently ('${sl(p.get(h))}' vs '${sl(f)}')`):p.set(h,f instanceof Map?new Map(f):f)}}};return s(r),s(e),i}function Cl(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,ju(a,l,n))}catch(d){throw new Error(`${t}: ${d.message}`,{cause:d})}}};return s(r),s(e),i}function Rl(r,e,t,i){if(r.size===0)return new Set(e);let s=ll(t,{scope:i}),o=new Set(e);for(let n of r)s.has(n)||o.add(n);return o}var Wu=/(?:^|\/)\.{0,2}(?:\/|$)/u;function kr(r,e,t){let i=Ue(r,e);return(i!=="."||e!=="")&&Wu.test(i)&&_(!1,`${t}: non-canonical file key ${JSON.stringify(i)}`),i.includes("\\")&&_(!1,`${t}: file key '${i}' holds a '\\', which no path may`),i}function Sr(r,e,t){let i=new Map;for(let[s,{files:o}]of r){typeof s!="string"&&_(!1,`${e}: bucket dir ${String(s)} is not a string`),le(s,e);for(let n of Object.keys(o)){let a=kr(s,n,e),l=i.get(a);l!==void 0&&t(a,l,s),i.set(a,s)}}return i}var El=(r,e)=>t=>_(!1,`duplicate file key '${t}' across ${r} buckets -- module bucketing changed between writes (a workspace package without a version now owns its own bucket); regenerate the ${e}`);function Al(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,wr({...a,files:Object.assign(Object.create(null),a.files)}));continue}_(l.name===a.name,`${t}: module '${n}' name mismatch ('${l.name}' vs '${a.name}')`),_(l.version===a.version,`${t}: module '${n}' version mismatch ('${l.version}' vs '${a.version}')`+(l.version==null==(a.version==null)?"":" -- an artifact from an older stasis may record a placeholder version for a workspace package without one; regenerate it (bundle=replace / lock=replace)")),_(l.ecosystem===a.ecosystem,`${t}: module '${n}' ecosystem mismatch ('${l.ecosystem??"(none)"}' vs '${a.ecosystem??"(none)"}')`),l.repo===void 0&&a.repo!==void 0&&i.set(n,wr({...l,repo:a.repo}));for(let[d,u]of Object.entries(a.files))Object.hasOwn(l.files,d)?_(l.files[d]===u,`${t}: content mismatch for '${Ue(n,d)}'`):l.files[d]=u}};return s(r),s(e),Sr(i,t,(o,n,a)=>_(!1,`${t}: file '${o}' is bucketed under both '${n}' and '${a}' -- module bucketing changed between the artifacts (a workspace package without a version now owns its own bucket); regenerate the artifact (bundle=replace / lock=replace)`)),i}function He(r){return r.split("/").includes("node_modules")}function Ku(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 Ml(r){let e="node_modules/",t=Ku(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 Ce=1,Il=0,Ll=El("bundle","artifact (bundle=replace)"),zl=r=>Ml(r)??{dir:".",rel:r==="."?"":r,name:null};function Zu(){throw new Error("bundle: file contents are not retained by this contents-free Bundle")}var Ju=(r,{files:e,...t})=>{let i=Object.create(null);for(let[s,o]of Object.entries(e))typeof o!="symbol"&&_(!1,`bundle: file '${Ue(r,s)}' is not a placeholder`),Object.defineProperty(i,s,{get:Zu,enumerable:!0});return{...t,files:Object.freeze(i)}},vs=(r,e)=>{if(r===void 0&&e===void 0)return;let t=new Map;for(let i of[r,e])for(let[s,o]of Object.entries(i??{})){if(!Array.isArray(o))continue;let n=t.get(s);n===void 0&&t.set(s,n=new Set);for(let a of o)n.add(a)}return X([...t.keys()].toSorted().map(i=>[i,$r(t.get(i))]))};var Yu=(r,e)=>{if(r?.github===void 0||!nl(r.github,e?.github))return;let t=Object.keys(fs).filter(i=>r[i]!==void 0&&(i==="github"||r[i]===e[i]));return X(t.map(i=>[i,r[i]]))},Xu=r=>{if(!Fe(r)||r.root!==!0||Object.hasOwn(r,"directory"))return r;let{root:e,...t}=r;return t},Ol=r=>typeof r=="string"&&/^[\w.+@/~'!()*-]+$/u.test(r),ys={name:Ol,version:Ol},Tl={npm:ys,composer:ys,cargo:ys},Qu=(r,e)=>X(Object.keys(Tl).map(t=>{let[i,s]=[r?.[t],e?.[t]];return[t,i?.name!==void 0&&i.name===s?.name?X(Object.entries(i).filter(([o,n])=>n===s[o])):void 0]})),qe=class r{static VERSION=Ce;version=Ce;config;entries;modules;formats;imports;executable;reason;#e;get repo(){return this.#e}set repo(e){this.#e=xr(e)}#t;get package(){return this.#t}set package(e){this.#t=_r(e,Tl,"bundle package")}constructor({config:e={scope:"full"},entries:t,modules:i,formats:s,imports:o,executable:n,reason:a,repo:l,package:d,version:u=Ce}={}){_([Il,Ce].includes(u)),_(["node_modules","full"].includes(e.scope)),this.version=u,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,this.repo=xr(l),this.package=d}get sources(){let e=new Map;for(let[t,{files:i}]of this.modules)for(let[s,o]of Object.entries(i))e.set(Ue(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(Ue(e,i))))return!0;return!1}static parse(e){return r.fromJSON(JSON.parse(e))}static fileKeyAt(e){let[t,i,s,o]=e;if(typeof i=="string"){if(e.length===2&&t==="sources"){let n=zl(i);return kr(n.dir,n.rel,"bundle")}if(e.length===4&&(t==="sources"||t==="modules")&&s==="files"&&typeof o=="string")return kr(i,o,"bundle")}}static fromJSON(e,{contents:t=!0}={}){_(e.version===Ce||e.version===Il),_(["node_modules","full"].includes(e.config?.scope));let i=yl(e.formats),s=new Map,o=new Set;if(e.version===Ce){let l=e.config.scope==="full";if(e.modules!==void 0){_(typeof e.modules=="object"&&e.modules!==null);for(let[d,u]of Object.entries(e.modules))_(He(d)),le(d,"bundle"),_(u?.name&&u.version&&u.files),s.set(d,gs(u,d,"bundle"))}if(l){_(e.sources&&typeof e.sources=="object");for(let[d,u]of Object.entries(e.sources))_(!He(d)),le(d,"bundle"),_(u?.name&&u.files),s.set(d,gs(u,d,"bundle"));e.entries!==void 0&&(o=gl(e.entries,"bundle"))}else _(e.entries===void 0),_(e.sources===void 0)}else{_(e.sources);for(let[l,d]of Object.entries(e.sources)){le(l,"bundle");let{dir:u,rel:p,name:h}=zl(l);_(!Lt(u)&&!Lt(p)),s.has(u)||s.set(u,{name:h,version:null,files:Object.create(null)});let{files:f}=s.get(u);_(!Object.hasOwn(f,p),"bundle: duplicate file key '.' (v0 '' and '.')"),f[p]=d}}let n=Sr(s,"bundle",Ll),a=xl(e.imports);if(!t)for(let[l,d]of s)s.set(l,Ju(l,d));return new r({version:e.version,config:e.config,entries:o,modules:s,formats:i,imports:a,executable:e.version===Ce?dl(e.executable,{what:"bundle",files:n,formats:i,scope:e.config.scope}):new Set,reason:Fe(e.reason)?e.reason:void 0,repo:Xu(e.repo),package:e.package})}serialize(){Sr(this.modules,"bundle",Ll);let{modules:e,sources:t}=kl(this.modules,{skipEmpty:!0,what:"bundle"}),i=this.config.scope==="full",s={version:Ce,config:this.config};this.repo!==void 0&&(s.repo=this.repo),this.package!==void 0&&(s.package=this.package),i&&(s.entries=bl(this.entries,"bundle")),s.formats=wl(this.formats),s.imports=$l(this.imports);let o=pl(this.executable,{what:"bundle",modules:this.modules,formats:this.formats,scope:this.config.scope});return o!==void 0&&(s.executable=o),this.reason!==void 0&&(s.reason=vs(this.reason,void 0)),i&&(s.sources=t),s.modules=e,JSON.stringify(s,void 0,2)}withReason(e){let{version:t,config:i,entries:s,modules:o,formats:n,imports:a,executable:l,repo:d,package:u}=this,p=vs(this.reason,{[e]:[...this.sources.keys()]});return new r({version:t,config:i,entries:s,modules:o,formats:n,imports:a,executable:l,reason:p,repo:d,package:u})}merge(e){return _(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:Al(this.modules,e.modules,"bundle merge"),formats:Cl(this.formats,e.formats,"bundle merge"),imports:Sl(this.imports,e.imports,"bundle merge"),executable:Rl(this.executable,e.executable,e.modules,this.config.scope),reason:vs(this.reason,e.reason),repo:Yu(this.repo,e.repo),package:Qu(this.package,e.package)})}};var eh=new TextEncoder,H1=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});var th=2;function ws(r){if(typeof r!="string")throw new TypeError(`utf8ByteLength expects a string, got ${typeof r}`);if(/[\u0100-\uFFFF]/.test(r))return eh.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<th;i++)r.codePointAt(i)>127?(t++,s=0):s++;e.lastIndex=i}return t}var _s=new WeakMap,xs=new WeakMap,$s=new WeakMap;function Cr(r){if(r?.metadataOnly)return new Map;let e=r?.bundle??r?.json;if(e&&_s.has(e))return _s.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"&&(qe.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&&_s.set(e,t),t}function rh(r){let e=r?.bundle??r?.json;if(e&&xs.has(e))return xs.get(e);let t=new Map(Cr(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&&xs.set(e,t),t}var ih="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function sh(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&&ih.indexOf(t.at(-1))&(i===2?15:3)?null:Math.floor(t.length*3/4)}function oh(r){return typeof r=="string"?ws(r):r?.format==="base64"?sh(r.data):null}function zt(r){if(r?.fileSizes)return r.fileSizes;let e=r?.bundle??r?.json;if(e&&$s.has(e))return $s.get(e);let t=new Map,i=rh(r),s=r?.kind==="stasis"?r.bundle?.sources.keys():r?.json?.sources;for(let o of s??[])t.set(o,oh(i.get(o)));return e&&$s.set(e,t),t}function Nl(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 nh=4,Pl=nh;function Bl(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 Dl(r,e){if(![1,2,3,Pl].includes(r?.version)||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!==Pl,i=r.version===1,s=new Map,o=new Map,n=new Map;for(let d of r.files){if(!Array.isArray(d)||d.length!==4&&!(i&&d.length===3))throw new Error("Invalid bundle metadata file");let[u,p,h,f]=d;if(typeof u!="string"||o.has(u)||p!==null&&(!Number.isSafeInteger(p)||p<0)||h!==null&&(typeof h!="string"||!/^sha512-[A-Za-z0-9+/]{86}==$/u.test(h))||p===null&&h!==null||i&&p!==null&&h===null||f!=null&&(!Number.isSafeInteger(f)||f<0))throw new Error("Invalid bundle metadata file");o.set(u,p),h!==null&&s.set(u,h),f!=null&&n.set(u,f)}let a=new Set(r.unsized??[]);if(r.unsized!==void 0&&(i||!Array.isArray(r.unsized)||a.size!==r.unsized.length)||[...a].some(d=>typeof d!="string"||!o.has(d)||o.get(d)!==null))throw new Error("Invalid bundle metadata");let l={integrity:e,kind:r.kind,size:r.size,metadataOnly:!0,fileSizes:o,fileHashes:s,lineCounts:n,unsizedFiles:a,stale:t};if(r.kind==="stasis"){l.bundle=qe.parse(JSON.stringify(r.bundle));let d=l.bundle.sources;if(d.size!==o.size||[...d.keys()].some(p=>!o.has(p)))throw new Error("Invalid bundle metadata inventory");let u=l.bundle.formats;if(!i&&[...o].some(([p,h])=>s.has(p)!==(h!==null&&!qe.isResourceFormat(u.get(p)))))throw new Error("Invalid bundle metadata inventory");if([...a].some(p=>u.get(p)!=="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(d=>!o.has(d))||!Array.isArray(r.sourceSizes)||r.sourceSizes.length!==r.json.sources.length||r.sourceSizes.some(d=>d!==null&&(!Number.isSafeInteger(d)||d<0))||[...o].some(([d,u])=>s.has(d)!==(u!==null))||a.size>0)throw new Error("Invalid sourcemap inventory");l.json=r.json,l.sourceSizes=r.sourceSizes,l.namesCount=r.namesCount}if(r.codeStats===void 0)l.codeStats=tl(n,o);else{let d=r.codeStats,u=p=>Number.isSafeInteger(p)&&p>=0;if(!d||![d.files,d.lines,d.bytes].every(u)||!Array.isArray(d.languages)||d.languages.some(p=>!p||typeof p.key!="string"||typeof p.label!="string"||![p.files,p.lines,p.bytes].every(u)))throw new Error("Invalid bundle code stats");l.codeStats=d}return l}function ks(r,{packageDir:e=null}={}){if(e){if(e!=="."){let t=e.match(/(?:^|\/)node_modules\/(@[^/]+\/[^/]+|[^/]+)$/u);return t&&t[1]!==".pnpm"?t[1]:e}}else{let t=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,i;for(;(i=t.exec(r))!==null;)if(i[1]!==".pnpm")return i[1]}return"__own__"}function Ss(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??[...zt(r)].filter(([,o])=>o!=null).map(([o])=>o));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 jl(r,e){if(e.error)throw new Error(e.error);let t=Nl(e),i=e.kind==="stasis"?e.bundle?.formats:null,s=e.lineCounts??new Map([...Cr(e)].map(([a,l])=>[a,Bl(l)])),o=[...zt(e)].filter(([,a])=>a!=null).map(([a,l])=>({path:a,format:i?.get(a)??null,bytes:l,lines:s.get(a)??0,size:se(l),module:ks(a,{packageDir:t?.get(a)})})),n=[{id:"all",label:"All",filePaths:null},...[...Ss(e,o.map(a=>a.path))].map(([a,l])=>({id:`reason:${a}`,label:a,filePaths:[...l]}))];return{...r,files:o,reasons:n,size:se(e.size)}}function Ul(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:se(i.byteSize),files:null,reasons:[]}});return{repositories:[...e.values()],bundles:t,scans:[]}}async function Fl(r,e){let t=await Ii(r.id,{signal:e});e?.throwIfAborted();let i=Dl(t,r.integrity);return jl(r,i)}var Hl=new Set(["overview","graph","treemap","compare","advisories","issues","code","search","terminal"]);var ah=/^\d+$/u;function lh(r){for(let e=0;e<r.length;e++){let t=r.codePointAt(e);if(t<32||t===127)return!0}return!1}var ql=512;function ch(r){return typeof r=="string"&&r.length>0&&r.length<=ql&&!lh(r)}function Vl(r){return ch(r)&&!ah.test(r)}var Gl=Object.freeze({manage:"/manage","manage-bundles":"/manage/bundle","manage-scans":"/manage/scans","manage-reports":"/manage/report","manage-repos":"/manage/repositories","admin-users":"/manage/users","manage-teams":"/manage/team","manage-import":"/manage/import","manage-links":"/manage/links","manage-deduplication":"/manage/deduplication","manage-history":"/manage/history"});function dh(r){if(!Vl(r)||r==="."||r==="..")return null;try{return`/finding/${encodeURIComponent(r)}`}catch{return null}}function Wl(r){if(!r)return null;if(r.view==="home")return"/";if(r.view==="workspace-reports"||r.view==="workspace-bundles")return/^[A-Za-z0-9_-]+$/u.test(r.teamSlug??"")?`/team/${r.teamSlug}/${r.view.slice(10)}`:null;if(r.view==="bundles"){if(!/^[A-Za-z0-9_-]+$/u.test(r.bundleSlug??"")||r.teamSlug!=null&&!/^[A-Za-z0-9_-]+$/u.test(r.teamSlug))return null;let i=r.bundleTab??"overview";return Hl.has(i)?`${r.teamSlug?`/team/${r.teamSlug}`:"/manage"}/bundle/${r.bundleSlug}${i==="overview"?"":`/${i}`}`:null}if(Object.hasOwn(Gl,r.view)){let i=Gl[r.view];return r.view==="manage-deduplication"&&r.linkId?`${i}?report=${encodeURIComponent(r.linkId)}`:r.view==="manage-bundles"&&Number.isSafeInteger(r.createRepoId)&&r.createRepoId>0?`${i}?createRepo=${r.createRepoId}`:r.view==="manage-scans"&&r.scanMode==="link"?`${i}?mode=link`:r.view==="manage-scans"&&r.bundleId?`${i}?bundle=${encodeURIComponent(r.bundleId)}`:r.view==="manage-history"&&r.actor?`${i}?actor=${encodeURIComponent(r.actor)}`:i}if(!["findings","files"].includes(r.view)||!r.teamSlug||[r.teamSlug,r.reportSlug].some(i=>i!=null&&!/^[A-Za-z0-9_-]+$/u.test(i)))return null;let e=`/team/${encodeURIComponent(r.teamSlug)}`,t=r.reportSlug?`/report/${encodeURIComponent(r.reportSlug)}`:"";if(r.finding){let i=dh(r.finding.id);return r.view==="findings"&&i?`${e}${t}${i}`:null}return`${e}${t}${r.view==="files"?"/files":""}`}ve();function ph(r){let{data:e}=Nn(r);return e&&Kl(e)>0?e:null}function Kl(r){return(be(r)??[]).filter(e=>(Array.isArray(e)?e:[e]).some(t=>t&&typeof t=="object"&&ni(t,t.source??r.source))).length}function Zl(r,e){let t=(r.reports??[]).filter(n=>n.visible&&n.repoId!=null).flatMap(n=>{let a=ph(n.content??"");return a?[{id:n.id,filename:n.filename,repoIds:[n.repoId],repo:n.repoFullName,directory:n.repoDirectory,analyzer:n.analyzer,appFindings:Kl(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:se(n.byteSize)})),results:s},link:{repositories:[...i.values()].filter(n=>t.some(a=>a.repoIds.includes(n.id))),reports:t}}}S();Cs();B();function Yl(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 Xl(r,e){let t=e.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),i=r.filter(o=>!o.reset),s=i.filter(o=>t.every(n=>o.label.normalize("NFKC").toLocaleLowerCase().includes(n))).toSorted((o,n)=>o.label.localeCompare(n.label,void 0,{sensitivity:"base",numeric:!0}));return{pinned:r.filter(o=>o.reset),sections:[{label:null,options:s}],facets:[],showFacets:!1,count:s.length,total:i.length}}var Rs=class extends F{static properties={users:{attribute:!1},resetLabel:{type:String,attribute:"reset-label"}};static styles=[F.styles,z`.avatar{position:relative;overflow:hidden}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}`];constructor(){super(),this.users=[],this.resetLabel="",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")||e.has("resetLabel"))&&(this.options=[...this.resetLabel?[{value:"",label:this.resetLabel,reset:!0}]:[],...Yl(this.users)])}choices(){return Xl(this.options,this._query)}optionIcon(e){return e.initials?c`<span class="avatar" aria-hidden="true">${e.initials}${Ee()?m:Rr(e.value,c`<img alt="" loading="lazy" decoding="async" src="${`/api/avatar/${encodeURIComponent(e.value)}`}" @error="${t=>{t.currentTarget.hidden=!0}}">`)}</span>`:m}};customElements.get("user-selector")||customElements.define("user-selector",Rs);S();B();var Ql=`:host{padding:0;margin-top:2rem;container-type:normal}.heading{display:flex;align-items:center;justify-content:space-between;gap:1rem}h2{margin:0;font-size:1.125rem}.intro{margin:.5rem 0 1rem}.alias-table{overflow-x:auto;padding-bottom:.5rem}table{width:100%;border-collapse:collapse;text-align:left}th,td{padding:.35rem .5rem;border-bottom:1px solid var(--border)}th{color:var(--muted);font-weight:500}td:not(.actions,.empty){overflow-wrap:anywhere}input{width:100%;min-width:7rem;padding:.3rem .45rem;border:1px solid var(--border);border-radius:.375rem;background:var(--bg);color:var(--text);font:inherit}.actions{white-space:nowrap;text-align:right}.actions .btn{min-height:1.75rem;padding:.2rem .55rem}.actions .btn+.btn{margin-left:.25rem}
|
|
267
|
-
`;var hh="/api/admin/repositories/aliases";async function ec(r="",e={}){let t=await $(`${hh}${r}`,{credentials:"same-origin",...e}),i=await t.json();if(!t.ok){let s={"alias-exists":"An alias already exists for this old repository and path. Edit that row instead.","bad-old-repo":"Enter the old repository as owner/name or a GitHub URL.","bad-directory":"Enter repository directories without parent segments, backslashes, or surrounding whitespace.","bad-repo":"Choose a connected repository.","no-alias":"This alias was removed. Refresh the list and try again."};throw new Error(s[i?.error]??`HTTP ${t.status}`)}return i}var Es=class extends T{static properties={repositories:{attribute:!1},_data:{state:!0},_edit:{state:!0},_error:{state:!0},_busy:{state:!0}};static styles=[x(N),x(Ql)];constructor(){super(),this._data=null,this._edit=null,this._error=null,this._busy=!1}connectedCallback(){super.connectedCallback(),this._load()}updated(e){e.has("repositories")&&e.get("repositories")!==void 0&&(this.appState.invalidate(["repository-aliases"]),this._load())}async _load(){this._error=null,await this._loadCollection("repository-aliases","repository aliases",e=>ec("",{signal:e}),e=>{this._data=e})}_start(e=null){this._error=null,this._edit=e?{...e}:{id:null,oldRepo:"",oldPath:"",repoId:null,newPath:""}}async _mutate(e,t,i){if(!(this._busy||!this._csrf||this._role!=="admin")){this._busy=!0,this._error=null;try{await this.appState.mutate(()=>ec(t?`/${encodeURIComponent(t)}`:"",{method:e,headers:{"content-type":"application/json","x-csrf-token":this._csrf},...i?{body:JSON.stringify(i)}:{}}),["repository-aliases","workspace-import"]),this._edit=null,await this._load()}catch(s){this._error=String(s?.message??s)}finally{this._busy=!1}}}_save(){let{id:e,...t}=this._edit;return this._mutate(e?"PATCH":"POST",e,t)}_field(e,t,i){return c`<td><input type="text" aria-label="${t}" placeholder="${i}" .value="${this._edit[e]}" ?disabled="${this._busy}" @input="${s=>{this._edit={...this._edit,[e]:s.target.value}}}"></td>`}_editor(){let e=(this._data?.repos??[]).filter(t=>t.active!==!1).map(t=>({value:t.repoId,label:t.fullName}));return c`<tr>${this._field("oldRepo","Old repository","owner/repository")}${this._field("oldPath","Old path","Repository root")}<td><repository-selector label="New repository" placeholder="Choose repository…" .options="${e}" .value="${this._edit.repoId}" ?disabled="${this._busy}" @repository-change="${t=>{this._edit={...this._edit,repoId:t.detail.value}}}"></repository-selector></td>${this._field("newPath","New path","Repository root")}<td class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._edit.oldRepo.trim()||this._edit.repoId==null}" @click="${()=>{this._save()}}">${this._busy?"Saving\u2026":"Save"}</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>{this._edit=null,this._error=null}}">Cancel</button></td></tr>`}render(){let e=this._data?.aliases??[],t=this._data?.repos??[];return c`<section aria-labelledby="aliases-heading"><div class="heading"><h2 id="aliases-heading">Aliases</h2><button type="button" class="btn" ?disabled="${this._busy||this._edit!=null||!this._data}" @click="${()=>this._start()}">Add alias</button></div><p class="intro">Map repository locations when importing new reports and bundles.</p>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:m}<div aria-busy="${this._loading}">${this._data===null?this._error?c`<button type="button" class="btn" @click="${()=>{this._load()}}">Try again</button>`:q("Loading repository aliases\u2026"):c`<div class="alias-table"><table><thead><tr><th>Old repository</th><th>Old path</th><th>New repository</th><th>New path</th><th><span class="sr-only">Actions</span></th></tr></thead><tbody>${e.map(i=>this._edit?.id===i.id?this._editor():c`<tr><td>${i.oldRepo}</td><td class="mono">${i.oldPath||"/"}</td><td>${t.find(s=>s.repoId===i.repoId)?.fullName??"Removed repository"}${t.find(s=>s.repoId===i.repoId)?.active===!1?" (inactive)":""}</td><td class="mono">${i.newPath||"/"}</td><td class="actions"><button type="button" class="btn" ?disabled="${this._busy||this._edit!=null}" @click="${()=>this._start(i)}">Edit</button> <button type="button" class="btn" ?disabled="${this._busy||this._edit!=null}" @click="${()=>{this._mutate("DELETE",i.id)}}">Delete</button></td></tr>`)} ${this._edit?.id===null?this._editor():m} ${e.length===0&&!this._edit?c`<tr><td colspan="5" class="empty">No repository aliases yet.</td></tr>`:m}</tbody></table></div>`}</div></section>`}};customElements.define("managed-repository-aliases",Es);function tc(r){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:r},bubbles:!0,composed:!0}))}function oc(r,e){return c`<span class="avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${Ee()?m:c`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" @error="${t=>t.currentTarget.classList.add("broken")}">`}</span>`}var mh=P(Hn),js=P(qn),rc=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>`,As=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>`,fh={admin:"Admin",manage:"Manager",triage:"Triage",view:"Viewer",none:"No access"},gh={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"},Ms=class extends T{static styles=[x(ba),x(N)];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">${U("manage",this._role,this.allowShare)}<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>`:m} <button type="button" class="history-link" @click="${()=>tc("manage-history")}"><span class="page-icon" aria-hidden="true">${D("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 ${D("arrow")}</span></button>`}</div>`}_page([e,t,i,s]){return c`<button type="button" class="${`page page-${s}`}" @click="${()=>tc(e)}"><span class="page-top"><span class="page-icon" aria-hidden="true">${D(s)}</span><strong class="page-title">${t}</strong><span class="arrow" aria-hidden="true">${D("arrow")}</span></span> <span class="page-copy"><span>${i}</span></span></button>`}};customElements.define("managed-admin-home",Ms);var Is=class extends T{static properties={_page:{state:!0},_history:{state:!0},_total:{state:!0},_error:{state:!0},_filter:{state:!0},_query:{state:!0},_repo:{state:!0},_actor:{state:!0},_options:{state:!0}};static styles=[x(va),x(N)];constructor(){super(),this._history=null,this._total=0,this._searchTimer=null,this._error=null,this._page=1,this._filter="all",this._query="",this._repo="",this._actor="",this._options={repos:[],users:[]},this._onActorFilter=e=>{let t=e.detail?.actor;if(typeof t!="string")return;let i=t.startsWith("user:")||t.startsWith("legacy:");this._query=i?"":t,this._filter="all",this._repo="",this._actor=i?t:"",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=this._actor,o=this._repo,n=`history:${JSON.stringify([e,t,i,o,s])}`;await this._loadCollection(n,"history",a=>ea(a,e,t,i,o,s),a=>{this._history=a.history,this._total=a.total,this._page=a.page,this._options=a.filters??{repos:[],users:[]}})}_search(e){this._query=e,clearTimeout(this._searchTimer),this._loadRequest?.abort(),this._loadRequest=null,this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},250)}_setRepo(e){return this._repo=e,this._load()}_setActor(e){return this._actor=e,this._load()}_clearContext(){return this._repo="",this._actor="",this._load()}_contextFilters(){let e=this._options.repos,t=this._options.users??[],i=[{value:"",label:"All repositories",special:!0,reset:!0},...this._repo&&!e.includes(this._repo)?[{value:this._repo,label:this._repo}]:[],...e.map(s=>({value:s,label:s}))];return c`<repository-selector label="Filter history by repository" .options="${i}" .value="${this._repo}" @repository-change="${s=>{this._setRepo(s.detail.value)}}"></repository-selector><user-selector label="Filter history by user" reset-label="All users" placeholder="${this._actor?"Selected user":"All users"}" .users="${t}" .value="${this._actor}" @user-change="${s=>{this._setActor(s.detail.value)}}"></user-selector><button type="button" class="btn" aria-label="Clear repository and user filters" ?disabled="${!this._repo&&!this._actor}" @click="${()=>{this._clearContext()}}">Clear selection</button>`}render(){let e=this._history??[],t=this._page,i=(t-1)*100;return c`<div class="wrap">${U("manage-history",this._role,this.allowShare)}<h1 class="sr-only">History</h1><div class="page-intro"><p class="intro">${this._role==="admin"?"Uploads, builds, 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 history…" .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 and builds</option><option value="repository">${this._role==="admin"?"Repositories":"Assignments"}</option>${this._role==="admin"?c`<option value="access">Access</option>`:m}<option value="delete">Deletions</option></select> ${this._contextFilters()} <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>`:m}<div class="manage-list" aria-busy="${this._loading}">${this._history==null?this._error?m:q("Loading history\u2026"):e.length===0?c`<div class="history"><p class="empty">${this._query.trim()||this._filter!=="all"||this._repo||this._actor?"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>`:m}</div>`}async _changePage(e){await this._load(e),await this.updateComplete,this.renderRoot.querySelector(".manage-list")?.scrollTo({top:0})}_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">${Ls(e.at)}</span></div>`}};customElements.define("managed-admin-history",Is);function Ls(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 ic(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 sc(r){return r?.lastActivityAt??r?.lastActivity??r?.lastWriteAt??r?.lastActiveAt}var zs=class extends T{static properties={_query:{state:!0},_users:{state:!0},_teams:{state:!0},_error:{state:!0}};static styles=[x(ya),x(N)];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([ta(e),Ni(e)]),([e,t])=>{this._users=e,this._teams=Array.isArray(t?.teams)?t.teams:[]})}_filteredUsers(){let e=this._query.trim().toLocaleLowerCase();return(this._users??[]).filter(t=>[t.name,t.login,t.role,...(this._teams??[]).filter(i=>i.members?.some(s=>s.userId===t.id)).map(i=>i.name)].filter(Boolean).join(" ").toLocaleLowerCase().includes(e))}render(){let e=this._filteredUsers();return c`<div class="wrap">${U("admin-users",this._role,this.allowShare)}<h1 class="sr-only">Users</h1><div class="page-intro"><p class="intro">Manage workspace access and roles.</p></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="${t=>{this._query=t.target.value}}"><span class="result-count" role="status">${this._users&&this._query.trim()?`${e.length} matching out of `:""}${this._users?.length??"\u2026"} users</span></div>${this._error?c`<p class="msg error" role="alert">Couldn't load users: ${this._error}</p>`:m}<div class="manage-list" aria-busy="${this._loading}">${this._users==null?this._error?m:q("Loading users\u2026"):this._list(e)}</div></div>`}_list(e){return this._users.length===0?c`<p class="msg">No users yet.</p>`:e.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">${e.map(t=>this._row(t))}</ul></div>${this._users.some(t=>t.id===this._me)?c`<p class="self-note">Your own role can only be changed by another admin.</p>`:m}`}_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">${oc(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>`:m}</span> <span class="login">@${e.login}</span> </span></span><span class="memberships">${Ge(e.role,"manage")?c`<span class="team-access"><strong>${e.role==="admin"?"All reports":"Owned and team reports"}</strong><span class="team-perms"><span class="permission-granted">+ Deps</span><span class="permission-granted">+ Security</span></span></span>`:i.length===0?c`<span class="no-team">No team access</span>`:i.map(({team:s,member:o})=>c`<span class="team-access"><strong>${D("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="${ic(e.lastSeenAt)}">${Ls(e.lastSeenAt)}</span> <button type="button" class="activity-link" aria-label="${`Show activity by ${e.login}`}" @click="${()=>this._showActivity(e.id)}"><span class="last-activity" aria-label="${`Last activity ${ic(sc(e)).replace(/^Last seen /u,"")}`}">${Ls(sc(e))}</span></button> <span class="access"><select class="role" ?disabled="${t}" aria-label="${`Change ${e.login}\u2019s role`}" aria-description="${gh[e.role]??""}" @change="${s=>this._changeRole(e,s.target.value,s.target)}">${Re.map(s=>c`<option value="${s}" ?selected="${s===e.role}">${fh[s]}</option>`)}</select></span></li>`}async _changeRole(e,t,i){let s=e.role;if(t!==s){try{await this.appState.mutate(()=>ra(e.id,t,this._csrf),["users","teams","reports","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:`user:${e}`},bubbles:!0,composed:!0}))}};customElements.define("managed-admin-users",zs);var nc=D("repo"),Os=class extends T{static properties={_publicRepoOpen:{state:!0},_publicRepository:{state:!0},_publicRepoError:{state:!0},_addingPublic:{state:!0},_data:{state:!0},_error:{state:!0},_actionError:{state:!0},_scope:{state:!0},_showAll:{state:!0},_query:{state:!0},_organization:{state:!0},_loading:{state:!0},_busy:{state:!0},_connectingApp:{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=[x(wa),x(N)];constructor(){super(),this._publicRepoOpen=!1,this._publicRepository="",this._publicRepoError=null,this._addingPublic=!1,this._data=null,this._error=null,this._actionError=null,this._scope="connected",this._showAll=!1,this._query="",this._organization=null,this._loading=!0,this._busy=null,this._connectingApp=!1,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}connectedCallback(){super.connectedCallback(),this._load()}disconnectedCallback(){super.disconnectedCallback(),this._impactRequest?.abort()}_repositoryKey(){return`repos:${JSON.stringify([this._scope,this._showAll])}`}async _load(e=!1){this._error=null;let{_scope:t,_showAll:i}=this;await this._loadCollection(this._repositoryKey(),"repositories",s=>ia(t,i,e,s),s=>{this._data=s,this._organization=this._repositoryChoices().activeFacet})}_open(e){this._impactRequest?.abort(),this._publicRepoOpen=!1,this._scope=e,this._showAll=!1,this._query="",this._organization=null,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()}_setShowAll(e){this._showAll=e,this._organization=null,this._data=null,this._load()}_search(e){this._query=e}_repositoryChoices(){let e=(this._data?.repositories??[]).map(t=>({value:t.id,label:t.fullName,repo:t}));return mr(e,this._query,this._organization,{includeSingletonOrganizations:!0})}_back(e=null){return c`<div 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> ${e?c`<h1 class="breadcrumb-current">${e}</h1>`:m}</div>`}_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=>na(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`,i=this._repositoryChoices();return c`<div class="wrap">${U("manage-repos",this._role,this.allowShare)} ${e?c`<h1 class="sr-only">${t}</h1>`:this._back(t)}<div class="page-intro"><p class="intro">${e?"Manage connected repositories and their settings.":this._scope==="installed"?this._showAll?"Showing all repositories the GitHub App can read.":"Showing installed repositories you can access on GitHub.":"Choose a public repository your GitHub account is involved with."}</p>${e?c`<div class="repository-actions"><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> ${this._role==="admin"&&this._data?.canAddAnyPublicRepository?c`<button type="button" class="btn" aria-expanded="${this._publicRepoOpen}" @click="${()=>this._openPublicRepository()}">${this._accessIcon("public")} Add a public repository</button>`:m}</div>`:m}</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>`:m}<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="${s=>this._search(s.target.value)}"></label> ${this._scope==="installed"?c`<label class="show-all"><input type="checkbox" role="switch" .checked="${this._showAll}" @change="${s=>this._setShowAll(s.target.checked)}"><span>Show all</span></label><label class="show-all-paper"><input type="checkbox" .checked="${this._showAll}" @change="${s=>this._setShowAll(s.target.checked)}"><span>Show all</span></label>`:m} ${e?c`<span class="result-count" role="status">${this._data&&(this._query.trim()||i.activeFacet!=null)?`${i.count} ${i.count===1?"repository":"repositories"} out of `:""}${this._data?.connectedCount??"\u2026"} connected</span>`:c`<button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>{this._load(!0)}}">Refresh</button>`}</div>${e&&this._publicRepoOpen&&this._role==="admin"&&this._data?.canAddAnyPublicRepository?this._publicRepositoryForm():m} ${this._actionError?c`<p class="msg error" role="alert">${this._actionError}</p>`:m} ${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>`:m} ${!e&&this._data?c`<p class="repository-count" role="status">${i.count}${i.count===i.total?"":` of ${i.total}`} ${i.total===1?"repository":"repositories"}</p>`:m}<div aria-busy="${this._loading}">${this._body(i)}</div>${e&&this._role==="admin"?c`<managed-repository-aliases .session="${this.session}" .repositories="${this._data?.repositories}"></managed-repository-aliases>`:m}</div>`}_body(e){return this._data?c`${this._data.tokenMissing&&!this._showAll&&this._scope!=="connected"?c`<p class="msg">Log out and back in to refresh your GitHub membership access.</p>`:m}<div class="repository-browser">${e.showFacets?c`<nav class="organization-list" aria-label="Filter by organization"><button type="button" class="organization" aria-pressed="${e.activeFacet==null}" @click="${()=>{this._organization=null}}"><span class="organization-name">All organizations</span><span class="organization-count">${e.total}</span></button> ${e.facets.map(t=>c`<button type="button" class="organization" aria-pressed="${e.activeFacet===t.value}" @click="${()=>{this._organization=t.value}}"><span class="organization-name" data-tooltip-truncated data-tooltip="${t.name}">${t.name}</span><span class="organization-count">${t.count}</span></button>`)}</nav>`:m}<div class="repo-results">${e.sections.map(t=>c`<section class="repo-group" aria-label="${t.label??"Repositories"}">${t.label?c`<h2 class="owner-head"><span class="owner-icon" aria-hidden="true">${t.label[0]??"?"}</span>${t.label}</h2>`:m}<ul class="repos">${t.options.map(i=>this._row(i.repo,t.organization?i.name:i.label))}</ul></section>`)} ${e.count?m:c`<div class="empty"><strong>${e.total?"No matching repositories":this._scope==="connected"?"No connected repositories yet":`No ${this._scope} repositories available`}</strong><p>${e.total?"Try a different search or organization.":this._scope==="connected"?"Add an installed or public repository to get started.":this._scope==="installed"?this._showAll?"Install the GitHub App, then refresh this list.":"No installed repositories match your GitHub access. Turn on Show all to browse every installation.":"Public repositories associated with your GitHub account will appear here."}</p></div>`}</div></div>`:this._error?m:q("Loading repositories\u2026")}_openPublicRepository(){this._publicRepoOpen=!0,this._publicRepoError=null,this.updateComplete.then(()=>this.renderRoot?.querySelector("#public-repository")?.focus())}_publicRepositoryForm(){return c`<form class="public-repository-form" aria-label="Add a public repository" @submit="${e=>{e.preventDefault(),this._addPublicRepository()}}"><label class="confirm-field" for="public-repository"><span>Public GitHub repository</span> <input id="public-repository" class="confirm-name" type="text" placeholder="owner/repo or https://github.com/owner/repo" autocomplete="off" required .value="${this._publicRepository}" ?disabled="${this._addingPublic}" @input="${e=>{this._publicRepository=e.target.value}}"></label><div class="dialog-actions"><button type="button" class="btn" ?disabled="${this._addingPublic}" @click="${()=>{this._publicRepoOpen=!1}}">Cancel</button><button type="submit" class="btn" ?disabled="${this._addingPublic||!this._publicRepository.trim()}">${this._addingPublic?"Adding\u2026":"Add repository"}</button></div>${this._publicRepoError?c`<p class="msg error" role="alert">${this._publicRepoError}</p>`:m}</form>`}async _addPublicRepository(){if(!(this._addingPublic||!this._publicRepository.trim())){this._addingPublic=!0,this._publicRepoError=null;try{await this.appState.mutate(()=>oa(this._publicRepository.trim(),this._csrf),["repos","reports","bundles","teams","users","history","scan-sources"]),this._publicRepoOpen=!1,this._publicRepository="",await this._load()}catch(e){this._publicRepoError=e?.message??String(e)}finally{this._addingPublic=!1}}}_row(e,t){let i=`${this._accessLabel(e)}${this._scope==="connected"&&e.active===!1?" \xB7 Deactivated":""}`,s=c`${nc}<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){let t=e.visibility==="public"?"Public":e.visibility==="internal"?"Internal":e.private?"Private":null,i=e.installed?"GitHub App":"GitHub";return t?`${t} \xB7 ${i}`:i}_connectAppButton(e){return e.installed?m:c`<button type="button" class="btn connect-app" aria-label="${`Connect GitHub App to ${e.fullName}`}" ?disabled="${this._busy!=null}" @click="${()=>{this._connectApp(e)}}">${this._connectingApp&&this._busy===e.id?"Connecting\u2026":"Connect GitHub App"}</button>`}async _connectApp(e){if(!(this._busy!=null||e.installed)){this._busy=e.id,this._connectingApp=!0,this._actionError=null;try{let t=await this.appState.mutate(()=>aa(e.id,this._csrf),["repos","history","scan-sources"]);if(!this.isConnected)return;if(!t.connected){globalThis.location.assign(t.installUrl);return}this._detail?.id===e.id&&(this._detail={...this._detail,installed:!0}),this._data&&(this._data={...this._data,repositories:this._data.repositories.map(i=>i.id===e.id?{...i,installed:!0}:i)}),await this._load()}catch(t){this._actionError=`Couldn't connect ${e.fullName}: ${t?.message??t}`}finally{this._busy=null,this._connectingApp=!1}}}_detailPage(e){let t=e.active!==!1,i=this._impact?.reports??[],s=this._impact?.bundles??[];return c`<div class="wrap">${U("manage-repos",this._role,this.allowShare)}<div class="head">${this._back()}<h1>${e.fullName}</h1></div><p class="intro ui-hint">Repository settings and stored data.</p>${this._actionError?c`<p class="msg error" role="alert">${this._actionError}</p>`:m}<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> ${this._connectAppButton(e)} ${e.htmlUrl?c`<a class="btn" href="${e.htmlUrl}" target="_blank" rel="noopener noreferrer">View on GitHub</a>`:m}</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&&!this._connectingApp?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}`:m}</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):m}</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>${tt(n.filename)}${n.repoDirectory?` \xB7 ${n.repoDirectory}`:m}</li>`)}</ul></section><section><h3>Bundles to delete (${i.length})</h3><ul>${i.map(n=>c`<li>${n.filename}</li>`)}</ul></section></div>`:m} <label class="confirm-line"><input type="checkbox" .checked="${this._acknowledge}" @change="${n=>{this._acknowledge=n.target.checked}}"><span>I understand this permanently deletes the repository connection${s?", reports, and bundles":""}.</span></label> ${(this._impact?.triageCount??0)>0?c`<label class="confirm-line"><input type="checkbox" .checked="${this._deleteTriage}" @change="${n=>{this._deleteTriage=n.target.checked}}"><span>Also delete ${this._impact.triageCount} triage entr${this._impact.triageCount===1?"y":"ies"} belonging only to this repository.</span></label>`:m} ${s?c`<label class="confirm-field"><span>Type <strong>${e.fullName}</strong> to confirm.</span><input class="confirm-name" type="text" autocomplete="off" .value="${this._confirmName}" @input="${n=>{this._confirmName=n.target.value}}"></label>`:m}<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(()=>sa(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(()=>la(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",Os);function Ts(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 ac(r){return[{value:null,label:"No repository",special:!0},...r.map(e=>({value:e.repoId,label:e.fullName}))]}var Ns=class extends T{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}};static styles=[x(ur),x(Di),x(N),x(Bi)];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._teardownDrop=null,this._queue=[],this._localImport=new kt(this,"report",e=>Pi(this,e,t=>zi(t,this._csrf),["reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ct(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",ca,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>`:m}<div class="wrap">${U("manage-reports",this._role,this.allowShare)}<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">${D("upload")}</span><span class="drop-copy"><strong>Upload reports</strong><span>Drop files anywhere on this page.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>St(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></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>`:m} ${this._body()}</div>`}_body(){let e=Array.isArray(this._data?.reports)?this._data.reports:[],t=this._query.trim().toLocaleLowerCase(),i=e.filter(o=>[o.filename,tt(o.filename),o.repoFullName,o.repoDirectory,o.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(t)&&(this._visibility==="all"||!!o.visible==(this._visibility==="visible"))),s=`${t||this._visibility!=="all"?`${i.length} of `:""}${e.length} ${e.length===1?"report":"reports"}`;return c`<div class="collection-toolbar" role="search"><input type="search" aria-label="Search reports" placeholder="Search reports or repositories…" .value="${this._query}" @input="${o=>{this._query=o.target.value}}"><select aria-label="Report visibility" .value="${this._visibility}" @change="${o=>{this._visibility=o.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":s}</span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:m}<div class="manage-list" aria-busy="${this._loading}">${this._data==null?this._error?m:q("Loading reports\u2026"):i.length>0?c`<div class="report-list"><div class="report-list-head" aria-hidden="true"><span class="report-heading">Report</span><span>Repository</span><span>Uploaded by</span><span>Date</span><span class="size-heading">Size</span><span>Visibility</span><span class="actions-heading">Actions</span></div><ul class="reports">${i.map(o=>this._row(o))}</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=tt(e.filename),i=e.analyzer??e.source??e.producer??"default",s=Ai[i]??Ai.default,o=e.repoEmbedded!==!0&&e.canChangeRepo!==!1,n=e.repoEmbedded===!0||e.repoId!=null,a=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",l=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="${`report${e.visible===!1?" content-hidden":""}`}"><div class="report-main"><span class="report-mark" aria-hidden="true">${P(s)}</span> <span class="report-name" data-tooltip-truncated data-tooltip="${t}">${t}</span> <span class="report-location" data-tooltip-truncated data-tooltip="${a}">${a}</span> <span class="report-meta report-uploader" data-tooltip-truncated data-tooltip="${e.uploadedByLogin??"Uploader removed"}">${e.uploadedByLogin??"Uploader removed"}</span> <span class="report-meta report-date">${l}</span> <span class="report-meta report-size">${Ts(e.byteSize)}</span> <span class="${`status ${e.visible?"visible":"hidden"}`}">${e.visible?"Visible":"Hidden"}</span> <span class="report-actions">${o?c`<button type="button" class="action" data-tooltip="Set repository location" aria-label="${`Set location for ${t}`}" @click="${()=>this._openLocation(e)}">${D("repo")}</button>`:c`<span class="action-spacer"></span>`} <button type="button" class="action" aria-label="${`Preview ${t}`}" aria-expanded="${this._preview===e.id}" @click="${()=>{this._togglePreview(e)}}">${D("preview")}</button> <button type="button" class="action" data-tooltip="${e.visible?"Hide from teams":n?"Make visible to teams":"Assign a repository before publishing"}" aria-label="${`${e.visible?"Hide":"Make visible"} ${t}`}" ?disabled="${e.canChangeRepo===!1||!n&&!e.visible}" @click="${()=>{this._setVisible(e,!e.visible)}}">${D(e.visible?"hide":"show")}</button> <a class="action" aria-label="${`Download ${t}`}" href="${`/api/admin/reports/${encodeURIComponent(e.id)}`}">${D("download")}</a> <button type="button" class="action danger" aria-label="${`Delete ${t}`}" ?disabled="${e.canChangeRepo===!1}" @click="${()=>this._delete(e)}">${js}</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>`:m} ${this._locationReport===e.id?this._locationEditor(e):m}</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="${ac(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(()=>ua(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 $(`/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?`
|
|
268
|
-
\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(()=>pa(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){await Rt(this,e,t=>zi(t,this._csrf),["reports","repo-impact","history","scan-sources"])}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${tt(e.filename)}\u201D? This can't be undone.`)){this._error=null;try{await this.appState.mutate(()=>ha(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",Ns);var bh=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>`,Ps=class extends T{static properties={createRepoId:{attribute:!1},installTooltips:{attribute:!1},localImportSource:{attribute:!1},_query:{state:!0},_visibility:{state:!0},_visibilityBusy:{state:!0},_creating:{state:!0},_data:{state:!0},_locationBundle:{state:!0},_locationOrigin:{state:!0},_locationOriginError:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[x(_a),x(Di),x(N),x(Bi)];constructor(){super(),this._query="",this._visibility="all",this._visibilityBusy=null,this._creating=!1,this._data=null,this._error=null,this._busy=!1,this._locationBundle=null,this._locationOrigin=null,this._locationOriginError=null,this._locationOriginRequest=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._dragOver=!1,this._teardownDrop=null,this._queue=[],this._localImport=new kt(this,"bundle",e=>Pi(this,e,t=>Ti(t,this._csrf),["bundles","reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ct(this,e=>{this._creating||this._upload(e)},e=>{this._dragOver=!this._creating&&e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._closeLocation()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("bundles","bundles",Oi,t=>{this._data=t,this._locationBundle&&!t.bundles?.some(i=>i.id===this._locationBundle)&&this._closeLocation()})}_showCreate(e){if(!e&&this.createRepoId!=null){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-bundles"},bubbles:!0,composed:!0}));return}this._creating=e,this._dragOver=!1,e||this.updateComplete.then(()=>this.renderRoot.querySelector(".create-bundle-action")?.focus())}willUpdate(e){e.has("createRepoId")&&(this._creating=this.createRepoId!=null)}render(){return this._creating?c`<div class="wrap">${U("manage-bundles",this._role,this.allowShare)}<div 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 bundles" @click="${()=>this._showCreate(!1)}">Bundles</button> <span class="breadcrumb-separator" aria-hidden="true">›</span><h1 class="breadcrumb-current">Create a bundle</h1></div><managed-create-bundle .initialRepoId="${this.createRepoId??null}" .installTooltips="${this.installTooltips}" .createBundle="${this._csrf?(e,t)=>this.appState.mutate(()=>da(e,this._csrf,t),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"]):void 0}" @bundle-created="${e=>this.dispatchEvent(new CustomEvent("managed-bundle-open",{detail:e.detail,bubbles:!0,composed:!0}))}"></managed-create-bundle></div>`:c`${this._dragOver?c`<div class="dropzone">Drop bundles to upload</div>`:m}<div class="wrap">${U("manage-bundles",this._role,this.allowShare)}<h1 class="sr-only">Bundles</h1><div class="page-intro"><p class="intro">Source bundles for your repositories.</p><div class="bundle-actions">${this._localImport.renderAction()}<button type="button" class="local-import-toggle create-bundle-action" ?disabled="${!this._data}" @click="${()=>this._showCreate(!0)}">Create</button></div></div>${this._localImport.renderPanel(this._busy||!this._csrf)}<section class="drop-card" aria-label="Upload bundles"><span class="drop-icon" aria-hidden="true">${D("upload")}</span><span class="drop-copy"><strong>Upload source bundles</strong><span>Drop source archives anywhere on this page.</span></span> <button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>St(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></section>${this._body()}</div>`}_body(){let e=Array.isArray(this._data?.bundles)?this._data.bundles:[],t=this._query.trim().toLocaleLowerCase(),i=e.filter(l=>[l.filename,l.repoFullName,l.repoDirectory,l.kind,l.provenance==="build"?"built":null,l.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(t)&&(this._visibility==="all"||l.visible!==!1==(this._visibility==="visible"))),s=i.filter(l=>l.repoId==null).length,o=i.reduce((l,d)=>l+(Number.isFinite(d.byteSize)?d.byteSize:0),0),n=`${t||this._visibility!=="all"?`${i.length} of `:""}${e.length} ${e.length===1?"bundle":"bundles"}`,a=Map.groupBy(i,l=>l.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="${l=>{this._query=l.target.value}}"> <select aria-label="Bundle visibility" .value="${this._visibility}" @change="${l=>{this._visibility=l.target.value}}"><option value="all">All bundles</option><option value="visible">Visible to teams</option><option value="hidden">Hidden bundles</option></select> <span class="summary result-count" role="status"><span>${this._data==null?"\u2026 bundles":n}</span><span>${this._data==null?"\u2026":Ts(o)}</span> ${this._data==null||s?c`<span class="unassigned">${this._data==null?"\u2026 unattached":`${s} unattached`}</span>`:m}</span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:m}<div class="manage-list" aria-busy="${this._loading}">${this._data==null?this._error?m:q("Loading bundles\u2026"):i.length>0?c`<div class="bundle-groups">${[...a].toSorted(([l],[d])=>l==="Unattached"?-1:d==="Unattached"?1:l.localeCompare(d)).map(([l,d])=>c`<section class="bundle-group"><div class="bundle-group-head"><strong>${l}</strong><span>${d.length} ${d.length===1?"bundle":"bundles"}</span></div><ul class="bundles">${d.map(u=>this._row(u))}</ul></section>`)}</div>`:c`<div class="empty"><strong>${e.length>0?"No matching bundles":"No bundles uploaded yet"}</strong><p>${e.length>0?"Try a different search or visibility filter.":"Drop source archives here or browse files above."}</p></div>`}</div>`}_row(e){let t=e.visible!==!1,i=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",s=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="${`bundle-row${t?"":" content-hidden"}`}"><span class="identity"><span class="bundle-icon" aria-hidden="true">${e.kind==="stasis"?c`<img src="./stasis.svg" width="16" height="16" alt="">`:bh}</span> <button type="button" class="filename bundle-open" data-tooltip-truncated data-tooltip="${e.filename}" @click="${()=>this.dispatchEvent(new CustomEvent("managed-bundle-open",{detail:e,bubbles:!0,composed:!0}))}">${e.filename}</button> ${e.provenance==="build"?c`<span class="bundle-provenance" data-tooltip="Generated on this server from the repository">Built</span>`:m} </span><span class="meta bundle-uploader" data-tooltip-truncated data-tooltip="${e.uploadedByLogin?`@${e.uploadedByLogin}`:""}">${e.uploadedByLogin?`@${e.uploadedByLogin}`:""}</span> <span class="meta bundle-date">${s}</span> <span class="meta bundle-size">${Ts(e.byteSize)}</span> <span class="bundle-location" data-tooltip-truncated data-tooltip="${i}">${i}</span> <span class="${`status ${t?"visible":"hidden"}`}">${t?"Visible":"Hidden"}</span> <span class="actions">${e.canChangeRepo===!1?m:c`<button type="button" class="action" aria-label="${`Set location for ${e.filename}`}" data-tooltip="Set repository location" ?disabled="${this._locationBusy}" @click="${()=>this._openLocation(e)}">${D("repo")}</button>`} <button type="button" class="action" aria-label="${`${t?"Hide":"Make visible"} ${e.filename}`}" data-tooltip="${t?"Hide from teams":e.repoId==null?"Assign a repository before publishing":"Make visible to teams"}" ?disabled="${this._visibilityBusy!=null||e.canChangeRepo===!1||!t&&e.repoId==null}" @click="${()=>{this._setVisible(e,!t)}}">${D(t?"hide":"show")}</button> <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":m}" @click="${()=>this._delete(e)}">${js}</button> </span>${this._locationBundle===e.id?this._locationEditor(e):m}</li>`}async _setVisible(e,t){if(!(this._visibilityBusy!=null||e.canChangeRepo===!1)){this._visibilityBusy=e.id,this._error=null;try{await this.appState.mutate(()=>fa(e.id,t,this._csrf),["bundles","teams","history","scan-sources"]),e.visible=t,this.requestUpdate(),await this._load()}catch(i){this._error=`Couldn't change bundle visibility: ${String(i?.message??i)}`}finally{this._visibilityBusy=null}}}_openLocation(e){this._locationBusy||e.canChangeRepo===!1||(this._closeLocation(),this._locationBundle=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null,e.kind==="stasis"&&this._loadLocationOrigin(e))}_closeLocation(){this._locationOriginRequest?.abort(),this._locationOriginRequest=null,this._locationBundle=null,this._locationOrigin=null,this._locationOriginError=null}async _loadLocationOrigin(e){this._locationOriginRequest?.abort();let t=new AbortController;this._locationOriginRequest=t,this._locationOrigin=void 0,this._locationOriginError=null;try{let i=await Yn(e.id,{signal:t.signal});if(this._locationOriginRequest!==t)return;i?.repoId!=null&&this._data&&(this._data={...this._data,repos:[...(this._data.repos??[]).filter(s=>s.repoId!==i.repoId),{repoId:i.repoId,fullName:i.github}]}),this._locationOrigin=typeof i?.github=="string"&&i.github?{github:i.github,directory:typeof i.directory=="string"?i.directory:i.root===!0?"/":null}:null}catch(i){if(this._locationOriginRequest!==t)return;this._locationOrigin=null,i?.name!=="AbortError"&&(this._locationOriginError="Couldn't load the bundle\u2019s suggested location.")}}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[],i=this._locationOrigin,s=Xe({repo:i})?.toLowerCase(),o=s&&t.find(a=>a.fullName.toLowerCase()===s),n=(a,l,d)=>{let u=c`<span class="ui-hint">metadata: </span><span class="location-metadata-value" data-tooltip-truncated data-tooltip="${a}">${a}</span>`;return d?c`<button type="button" class="location-metadata" aria-label="${`Use ${l} from metadata: ${a}`}" ?disabled="${this._locationBusy}" @click="${d}">${u}</button>`:c`<span class="location-metadata">${u}</span>`};return c`<div class="location-editor"><div class="location-field"><div class="location-field-header"><span class="ui-hint">Repository</span>${i?n(i.github,"repository",o?()=>{this._locationRepo=o.repoId,i.directory!=null&&(this._locationDirectory=i.directory)}:null):m}</div><repository-selector label="Repository for bundle" .options="${ac(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${a=>{this._locationRepo=a.detail.value}}"></repository-selector></div><div class="location-field"><div class="location-field-header"><label for="${`bundle-dir-${e.id}`}">Directory (optional)</label>${i?n(i.directory??"Directory not specified","directory",i.directory==null?null:()=>{this._locationDirectory=i.directory}):m}</div><input id="${`bundle-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" ?disabled="${this._locationBusy}" @input="${a=>{this._locationDirectory=a.target.value}}"></div><div class="location-actions"><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>this._closeLocation()}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>{this._saveLocation(e)}}">Save</button></div>${this._locationOriginError?c`<p class="location-origin" role="status">${this._locationOriginError} <button type="button" class="origin-retry" @click="${()=>{this._loadLocationOrigin(e)}}">Retry</button></p>`:m}</div>`}async _saveLocation(e){if(!(this._locationBusy||e.canChangeRepo===!1)){this._locationBusy=!0,this._error=null;try{await this.appState.mutate(()=>ga(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),["bundles","teams","repo-impact","history","scan-sources"]),this._closeLocation(),await this._load({preserveError:!0})}catch(t){this._error=`Couldn't set bundle location: ${String(t?.message??t)}`}finally{this._locationBusy=!1}}}async _upload(e){await Rt(this,e,t=>Ti(t,this._csrf),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"])}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(()=>ma(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",Ps);var Bs=class extends T{static properties={selection:{attribute:!1},_source:{state:!0},_error:{state:!0}};static styles=x(N);constructor(){super(),this._loadModels=(e,t)=>this.appState.load("models","scan models",i=>ot(i,$),{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([$("/api/admin/reports",{signal:i,credentials:"same-origin"}),$("/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 $(`/api/admin/reports/${encodeURIComponent(a.id)}`,{signal:i,credentials:"same-origin"});if(!l.ok)throw new Error(`Report ${tt(a.filename)}: HTTP ${l.status}`);return{...a,content:await l.text()}})),Zl(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",Oi,e=>{this._source=Ul(e)})}render(){return c`<div class="wrap">${U("manage-scans",this._role,this.allowShare)} ${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>`:m}<deepview-scan-page hide-heading .selection="${this.selection}" .source="${this._source}" .sourceLoading="${this._loading&&this._source==null}" .loadBundle="${Fl}" .loadModels="${this._loadModels}" .loadReportSources="${this._loadReportSources}" .createBundleHref="${e=>Number.isSafeInteger(e)&&e>0?Wl({view:"manage-bundles",createRepoId:e}):null}"></deepview-scan-page></div>`}};customElements.define("managed-admin-scans",Bs);var Ds=class extends T{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_renamingId:{state:!0},_repoChoices:{state:!0},_memberChoices:{state:!0}};static styles=[x(xa),x(N)];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",Ni,t=>{this._data=t})}async _do(e){if(!this._busy){this._busy=!0,this._error=null;try{await this.appState.mutate(e,["teams","users","reports","history"])}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load({preserveError:!0})}}}render(){return c`<div class="wrap">${U("manage-teams",this._role,this.allowShare)}<h1 class="sr-only">Teams</h1><div class="page-intro"><p class="intro">Manage repository and finding access for each team.</p><span class="result-count">${this._data?.teams?.length??"\u2026"} teams</span></div><div class="create-team"><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()}">${As} Create team</button><p class="access-note">All members can view standard findings. Set dependencies and security access per member.</p></div><div class="manage-list" 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 q("Loading teams\u2026");let e=Array.isArray(this._data.teams)?this._data.teams:[];return c`${this._error==null?m: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>${e.hidden?c`<span class="muted ui-hint">Hidden</span>`:m} <span class="team-actions"><button class="btn" aria-label="${`${e.hidden?"Restore":"Hide"} ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>ie("/api/admin/teams/set-hidden",this._csrf,{teamId:e.id,hidden:!e.hidden}))}">${e.hidden?"Restore":"Hide"}</button> <button class="icon-btn" aria-label="${`Rename ${e.name}`}" ?disabled="${this._busy}" @click="${()=>{this._renamingId=e.id}}">${mh}</button> <button class="icon-btn danger" aria-label="${`Delete ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._deleteTeam(e)}">${js}</button></span>`}</div>${e.hidden?c`<p class="team-hidden-note muted ui-hint">Hidden from everyone's sidebar. Access grants and public links are disabled until this team is restored.</p>`:m}<div class="team-body"><div class="sub"><h3 class="sub-title">Repositories <span class="count">${e.repos.length}</span></h3>${e.repos.length===0?c`<p class="muted ui-hint">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>${e.members.length===0?c`<p class="muted ui-hint">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">${nc} <span class="repo-copy"><span class="ln">${t.fullName}</span>${t.path?c`<span class="path">/${t.path.replace(/^\/+/u,"")}</span>`:m}</span> <button class="icon-btn danger" aria-label="${`Remove ${t.fullName}${t.path?`/${t.path}`:""} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>ie("/api/admin/teams/remove-repo",this._csrf,{teamId:e.id,repoId:t.repoId,path:t.path??null}))}">${rc}</button></li>`}_addRepoRow(e){let t=Array.isArray(this._data.repos)?this._data.repos:[];return t.length===0?c`<p class="muted ui-hint">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)}">${As} Add</button></div>`}_memberRow(e,t){let i=Array.isArray(this._data.permissions)?this._data.permissions:[],s=this._data.users?.some(o=>o.id===t.userId&&Ge(o.role,"manage"));return c`<li class="member-row"><span class="member">${oc(t.userId,t.login)}<span class="ln">${t.login}</span></span> <span class="perms">${i.map(o=>c`<label class="perm"><input type="checkbox" .checked="${s||t[o]===!0}" ?disabled="${this._busy||s}" aria-label="${`${Br[o]??o} access for ${t.login} in ${e.name}`}" @change="${n=>this._togglePerm(e,t,o,n.target.checked)}"> ${Br[o]??o}</label>`)} </span><button class="icon-btn danger" aria-label="${`Remove ${t.login} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>ie("/api/admin/teams/remove-member",this._csrf,{teamId:e.id,userId:t.userId}))}">${rc}</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)}">${As} Add</button></div>`}_create(){let e=this.renderRoot.querySelector(".new-name"),t=e?.value.trim();t&&this._do(async()=>{await ie("/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(()=>ie("/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(()=>ie("/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 ie("/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 ie("/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){if(this._data.users?.some(n=>n.id===t.userId&&Ge(n.role,"manage")))return;let o={};for(let n of this._data.permissions??[])o[n]=t[n]===!0;o[i]=s,this._do(()=>ie("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t.userId,...o}))}};customElements.define("managed-admin-teams",Ds);S();B();var Er=`.link-team{margin-top:1.5rem}.link-team h2{margin:0 0 .5rem;font-size:1rem;font-weight:600}.link-table{overflow-x:auto}table{width:100%;border-collapse:collapse;text-align:left;font-size:.8rem}th{color:var(--muted);font-weight:500}th,td{padding:.6rem .65rem;border-bottom:1px solid var(--border);white-space:nowrap}th:first-child,td:first-child{padding-left:0}th:last-child,td:last-child{padding-right:0;text-align:right}
|
|
269
|
-
`;async function
|
|
264
|
+
`;S();var Ha=[{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 qa(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=>!Ha.some(s=>s.key===i))?null:[{id:"",label:"All files",subtitle:"Everything"},...Ha.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 ss=class extends A{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=qa(e);if(!t)return c`<label class="scope-field"><span>Scope</span><select aria-label="${this.label}" .value="${G(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=z`:host{display:block;min-width:0}*{box-sizing:border-box}.scope-toggle,.scope-field{cursor:default;user-select:none;-webkit-user-select:none}.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:var(--ui-radius, 5px);overflow:hidden;background:var(--bg)}.scope-option{position:relative;flex:1 0 auto}.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:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font:inherit;font-size:.76rem}:host([compact]) .scope-toggle{min-height:0;gap:.3rem .5rem}:host([compact]) .scope-option span{height:auto;padding:2px 8px;font-size:.68rem;line-height:1.2}:host([compact]) .scope-field{font-size:.68rem}:host([compact]) .scope-description{display:none}:host([compact]) select{width:auto;max-width:22ch;padding:2px 6px;font-size:.68rem;line-height:1.2}`};customElements.get("bundle-scope-selector")||customElements.define("bundle-scope-selector",ss);var Va={code:P(lr),report:P(et)},os=class extends A{static properties={hideHeading:{type:Boolean,attribute:"hide-heading"},sourceLoading:{type:Boolean,attribute:!1},selection:{attribute:!1},scopeLabel:{type:String,attribute:"scope-label"},createBundleHref:{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=Fa;constructor(){super(),this.loadModels=ot,this.canRun=!0,this.hideHeading=!1,this._tab="new",this._mode="code",this.source=null,this.selection=null,this.scopeLabel="Repository",this._pendingSelection=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("selection")&&(this._pendingSelection=this.selection),e.has("source")&&(this._bundles=this.source?.bundles??[],this._repositories=this.source?.repositories??[],this._scans=this.source?.scans??[]),e.has("source")||e.has("selection")){this._excluded=new Set,this._excludedModules=new Set;let t=this._repositories.find(o=>o.id===this._selectedRepoId),i=this._pendingSelection,s=i?this._bundles.find(o=>o.id===i.bundleId&&(i.repoId==null||o.repoId===i.repoId)):this._bundles.find(o=>o.id===this._selectedBundleId&&o.repoId===this._selectedRepoId)??(this.scopeLabel==="Workspace"?null:this._bundles.find(o=>o.id===this._selectedBundleId))??(t?this._bundles.find(o=>o.repoId===t.id):this._bundles[0]);this._selectedRepoId=s?.repoId??i?.repoId??t?.id??this._repositories[0]?.id??"unattached",this._selectedBundleId=s?.id??null,this._reason=s?.reasons?.[0]?.id??"",i&&(this._tab="new",this._mode=i.mode==="report"?"report":"code",i.mode==="report"&&(this._reportMode="link",this._reportRestore=null,this._reportInput=null,this._pendingSelection=null),this._notice=i.mode==="report"||s||this.source==null?null:"The selected bundle is no longer available in this source. Choose another bundle.",s&&(this._pendingSelection=null))}}updated(e){(e.has("source")||e.has("selection")||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,repoId:s.repoId,repo:s.repo}: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 _scopeFiles(){let e=this._reasonData,t=e?.fileModules,i=e?.filePaths?new Set(e.filePaths):null;return(this._bundle?.files??[]).filter(s=>(t==null||t.includes(s.module))&&(i==null||i.has(s.path))).toSorted((s,o)=>o.bytes-s.bytes)}get _files(){return Zi(this._scopeFiles)}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:e==="dependencies"?this._scopeFiles:t?.files??[],s=this._excluded,o=this._excludedModules,n=i.filter(f=>!s.has(f.path)&&!o.has(f.module)),a=At(t?.files?n:null),l=new Map;for(let f of i){let b=l.get(f.module)??{bytes:0,count:0,included:0};b.bytes+=f.bytes,b.count++,s.has(f.path)||b.included++,l.set(f.module,b)}let d=[...l.keys()].toSorted((f,b)=>l.get(b).bytes-l.get(f).bytes||this._packageLabel(f).localeCompare(this._packageLabel(b))),m=i.slice(0,80),p=d.filter(f=>!o.has(f)).length,u=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="${f=>this._changeMode(f.detail.mode)}" @scan-analyzer-change="${f=>this._setOption("analyzer",f.detail.analyzer)}" @scan-report-mode-change="${f=>{this._reportMode=f.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="${f=>{this._reportInput=f.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>${se(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(f=>{let{bytes:b,count:v,included:y}=l.get(f),g=!o.has(f);return c`<label class="${`package-row ${g?"":"excluded"}`}"><input type="checkbox" .checked="${g}" @change="${k=>this._toggleModule(f)}"><span class="package-name" data-tooltip-truncated data-tooltip="${this._packageLabel(f)}">${this._packageLabel(f)}</span><span class="package-size">${se(b)} · ${y}/${v}</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 ${m.length} of ${i.length}</span></div>${i.length===0?c`<p class="empty">No files in this selection.</p>`:c`<div class="file-list">${m.map(f=>{let b=!s.has(f.path)&&!o.has(f.module);return c`<label class="${`file ${b?"":"excluded"}`}"><input type="checkbox" .checked="${b}" @change="${v=>this._toggleFile(f,v.target.checked)}"><span class="file-copy"><span class="file-path" data-tooltip-truncated data-tooltip="${f.path}">${f.path}</span><span class="file-meta">${f.size} · ${this._packageLabel(f.module)}</span></span></label>`})}</div>`}</section></div></details>`:h} ${e==="agentic"?this._agenticPanel():h}<slot name="access"></slot>${this._optionsPanel(e,t,e==="report"?u.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:Zi(d.files)}:d.summary?{...d,summary:{...d.summary,files:d.summary.codeFiles}}:d):this._repoBundles,{lines:s}=At(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","dependencies"].includes(this._mode)&&e!=null&&(!e.filename.toLowerCase().endsWith(".map")||e.reasons?.some(d=>d.id!=="all")),l=this._repositories.map(d=>{let m=o.get(d.id)??0;return{value:d.id,label:d.label,detail:`${m} ${m===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>${this.scopeLabel}</span>${this.scopeLabel==="Workspace"?c`<workspace-selector .options="${l}" .value="${this._selectedRepoId}" @workspace-change="${d=>this._selectRepoById(d.detail.value)}"></workspace-selector>`:c`<repository-selector .options="${l}" .value="${this._selectedRepoId}" @repository-change="${d=>this._selectRepoById(d.detail.value)}"></repository-selector>`}</div>`:h}<div class="field">${n||this.createBundleHref?this._bundleLabel():h}${i.length>0?c`<bundle-selector .bundles="${i}" .value="${e?.id??null}" @bundle-change="${d=>this._selectBundleById(d.detail.value)}"></bundle-selector>`:this._emptyBundles()}</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">${Va.report}<strong>${t.length}</strong><span>files</span></div><div class="metric">${Va.code}<strong>${s==null?"\u2014":s.toLocaleString()}</strong><span>LoC</span></div><div class="metric">${P(_e)}<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>`}_bundleLabel(){let e=this.createBundleHref?.(this._selectedRepoId);return c`<div class="bundle-label"><span>Bundle</span>${e?c`<a class="create-bundle-button" href="${e}">Create a bundle</a>`:h}</div>`}_emptyBundles(){let e=this.createBundleHref?.(this._selectedRepoId);return c`<div class="choice-empty"><span>${this._bundles.length===0?"No stored bundles.":`No stored bundles for this ${this.scopeLabel.toLowerCase()}.`}</span>${e?c`<a href="${e}">Create?</a>`:h}</div>`}_scopeField(e){if(!["code","agentic","dependencies"].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 data-tooltip-truncated data-tooltip="${e.bundleName}">${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._pendingSelection=null,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,this._pendingSelection=null;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="row-action" aria-label="Add prompt" @click="${()=>this._addPrompt()}">${fr}</button></div><div class="agentic-fields">${hr(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="${G(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="row-action" aria-label="${`Remove prompt ${t+1}`}" @click="${()=>this._removePrompt(e.id)}">${gr}</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)):e==="dependencies"?this._scopeFiles: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==="report"?this._reportMode==="merge"?"Merge scan results":"Link saved reports":this._reasonData?.label??"All files",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!=="report"&&(a.repoId=this._selectedRepoId,a.scopeId=this._reason),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.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&&(e.repoId==null||i.repoId===e.repoId));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??"",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",os);S();te();var Se=r=>r??h;B();S();var $u={__proto__:null,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",py:"python",pyw:"python",pyi:"python",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"},Ga={__proto__:null,module:"javascript",commonjs:"javascript","module-typescript":"typescript","commonjs-typescript":"typescript",json:"json",solidity:"solidity",php:"php",shell:"bash",rust:"rust",java:"java",objc:"objectivec",objcpp:"objectivec",c:"c","c-header":"c",cpp:"cpp","cpp-header":"cpp",ruby:"ruby",podspec:"ruby",podfile:"ruby",fastlane:"ruby","podfile-lock":"yaml",xml:"markup"};function vr(r,e){if(typeof e=="string"&&Ga[e])return Ga[e];if(typeof r!="string")return null;let t=r.slice(r.lastIndexOf("/")+1),i=t.lastIndexOf(".");return i<=0?null:$u[t.slice(i+1).toLowerCase()]??null}var ku=V`<path d="M8 1C4.5 1 4 1.5 4 3v1h4v1H3C1.5 5 1 6 1 8s.5 3 2 3h1V9c0-1.5 1-2 2.5-2H10c1.5 0 2-.5 2-2V3c0-1.5-.5-2-4-2Z" fill="#3776ab"/><path d="M8 1C4.5 1 4 1.5 4 3v1h4v1H3C1.5 5 1 6 1 8s.5 3 2 3h1V9c0-1.5 1-2 2.5-2H10c1.5 0 2-.5 2-2V3c0-1.5-.5-2-4-2Z" fill="#ffd43b" transform="rotate(180 8 8)"/><circle cx="6" cy="2.8" r=".65" fill="#fff"/><circle cx="10" cy="13.2" r=".65" fill="#fff"/>`,Su=V`<path d="m7 0 2 0 .4 1.6 1.3.5 1.4-.9 1.4 1.4-.9 1.4.5 1.3 1.6.4v2l-1.6.4-.5 1.3.9 1.4-1.4 1.4-1.4-.9-1.3.5-.4 1.6H7l-.4-1.6-1.3-.5-1.4.9-1.4-1.4.9-1.4-.5-1.3L1.3 9V7l1.6-.4.5-1.3-.9-1.4 1.4-1.4 1.4.9 1.3-.5Z" fill="#c97d5d"/><circle cx="8" cy="8" r="4.4" fill="var(--surface, #fff)"/><text x="8" y="10.8" text-anchor="middle" fill="currentColor" font-family="serif" font-size="8" font-weight="700">R</text>`;var Cu=V`<g fill="#8892bf" transform="translate(0 .5) scale(.5)"><path d="M28 10a4 4 0 0 0-4-4h-6v6a6 6 0 0 1-6 6h-2v2h2v6h4v-6h8v6h4V16h2v-4a2 2 0 0 0-2-2"/><path d="M12 4H8v2a6 6 0 0 0-6 6v6a2 2 0 0 0 2 2v2H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5H6a2 2 0 0 0 2-2v-8h4a4 4 0 0 0 4-4V8a4 4 0 0 0-4-4M6 14H4v-2h2Z"/></g>`;function Ru(r,e){let t=vr(r,e);return["javascript","jsx"].includes(t)?"js":["typescript","tsx"].includes(t)?"ts":["solidity","rust","php","python","json"].includes(t)?t:"generic"}function ns(r,e){let t=Ru(r,e),i=t==="js"||t==="ts"?V`<rect x="1" y="1" width="14" height="14" rx="2" fill=${t==="js"?"#e6c84f":"#3178c6"}/><text x="8" y="11.5" text-anchor="middle" fill=${t==="js"?"#202020":"#fff"} font-family="sans-serif" font-size="8" font-weight="700">${t.toUpperCase()}</text>`:t==="solidity"?V`<path d="m8 1 4 6-4 2-4-2Z" fill="currentColor"/><path d="m4 8 4 2 4-2-4 7Z" fill="currentColor" opacity=".65"/>`:t==="rust"?Su:t==="php"?Cu:t==="python"?ku:t==="json"?V`<path d="M3 1h6l5 5v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1Z" fill="#e6c84f"/><path d="M9 1v4a1 1 0 0 0 1 1h4Z" fill="#202020" opacity=".2"/><path d="M6.5 6.5h-.75a.75.75 0 0 0-.75.75v1.5L4 9.5l1 .75v1.5a.75.75 0 0 0 .75.75h.75m3-6h.75a.75.75 0 0 1 .75.75v1.5l1 .75-1 .75v1.5a.75.75 0 0 1-.75.75H9.5" fill="none" stroke="#202020" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"/>`:V`<path d="M4 1.5h5l3 3v10H4Zm5 0v3h3M6 8h4M6 10.5h4" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/>`;return c`<svg class="source-file-icon" data-file-type="${t}" width="16" height="16" viewBox="0 0 16 16" style="flex: none" aria-hidden="true">${i}</svg>`}var Wa=c`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" style="flex: none" aria-hidden="true"><path d="M1.5 4V2.5h5L8 4h6.5v9h-13Z" stroke-linejoin="round"/></svg>`,g1=c`<svg class="bundle-code-tree-npm" width="12" height="12" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 1h14v14H1Zm3 3v8h4V6h2v6h2V4Z"/></svg>`,b1=c`<svg class="bundle-code-tree-soldeer" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="m8 1 6 3.5v7L8 15l-6-3.5v-7Z" fill="none" stroke="currentColor" stroke-width="1"/><path d="m8 3 2.5 4L8 8.5 5.5 7Zm-2.5 5L8 9.5 10.5 8 8 13Z" fill="currentColor"/></svg>`,v1=c`<svg class="bundle-code-tree-composer" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 1 15 4.5v7L8 15l-7-3.5v-7Z" fill="#8892bf"/><path d="m1 4.5 7 3.5 7-3.5M8 8v7M4.5 2.75l7 3.5" fill="none" stroke="var(--surface, #fff)" stroke-width=".9"/></svg>`,y1=c`<svg class="bundle-code-tree-cargo" width="12" height="12" viewBox="9.25 6.14 14 14" aria-hidden="true"><path d="m16.264 11.547 6.2-2.446v8.16l-6.2 2.485Zm0-.019-6.2-2.481v8.123l6.2 2.522Z" fill="#e5ac3d" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m16.277 11.508 6.169-2.435-6.2-2.531-6.2 2.467Z" fill="#e3b04e" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m12.82 10.149 6.196-2.467" fill="none" stroke="#73561f" stroke-miterlimit="10" stroke-width=".05430921534373718px"/><path d="m18.301 7.395-6.24 2.484 1.482.593 6.196-2.466z" fill="#fff" stroke="#73561f" stroke-miterlimit="10" stroke-width=".04741218643894885px" opacity=".3"/><path d="m13.562 10.47-1.453-.565v1.645l.201-.136.18.285.104.04.138-.121.137.228.129.05.189-.166.238.332.137.053zm-1.423 7.576 1.461.545-.023-1.645-.2.139-.184-.282-.104-.039-.136.123-.14-.226-.131-.049-.186.169-.243-.329-.137-.051z" fill="#fff" stroke="#73561f" stroke-miterlimit="10" stroke-width=".06661495224335688px" opacity=".3"/><path d="m21.426 13.49-.172-.039V13.4l.148-.208a.1.1 0 0 0 .018-.065.035.035 0 0 0-.037-.03l-.189.006-.015-.045.118-.222a.07.07 0 0 0 .007-.063.04.04 0 0 0-.045-.018l-.2.051-.024-.037.084-.229a.06.06 0 0 0 0-.058.04.04 0 0 0-.051-.006l-.2.094-.032-.027.047-.227a.05.05 0 0 0-.016-.052.05.05 0 0 0-.056.007l-.2.133-.039-.017.007-.215a.04.04 0 0 0-.026-.043.07.07 0 0 0-.058.02l-.184.166-.045-.006-.033-.2a.036.036 0 0 0-.036-.032.08.08 0 0 0-.057.031l-.164.194-.049.005-.071-.168a.036.036 0 0 0-.044-.021.1.1 0 0 0-.055.042l-.138.214-.05.016-.107-.135a.04.04 0 0 0-.05-.008.1.1 0 0 0-.05.051l-.107.226-.05.026-.138-.1a.05.05 0 0 0-.055 0 .1.1 0 0 0-.044.058l-.071.228-.049.036-.164-.054a.06.06 0 0 0-.057.017.1.1 0 0 0-.036.063l-.033.223-.045.044-.184-.01a.08.08 0 0 0-.058.029.1.1 0 0 0-.026.065l.007.209-.039.05-.2.035a.1.1 0 0 0-.056.04.1.1 0 0 0-.016.065l.046.187-.032.054-.2.079a.1.1 0 0 0-.051.049.07.07 0 0 0 0 .062l.084.157-.024.057-.2.119a.1.1 0 0 0-.045.057.06.06 0 0 0 .007.057l.118.122-.015.058-.189.155a.1.1 0 0 0-.037.062.045.045 0 0 0 .018.05l.148.082v.055l-.172.185a.1.1 0 0 0-.028.065.04.04 0 0 0 .028.041l.172.039v.051l-.148.208a.1.1 0 0 0-.018.065.035.035 0 0 0 .037.03l.189-.006.015.045-.118.222a.07.07 0 0 0-.007.063.04.04 0 0 0 .045.018l.2-.051.024.037-.084.229a.06.06 0 0 0 0 .058.04.04 0 0 0 .051.006l.2-.094.032.027-.046.227a.05.05 0 0 0 .016.051.05.05 0 0 0 .056-.007l.2-.133.039.017-.007.215a.04.04 0 0 0 .026.043.07.07 0 0 0 .058-.02l.184-.166.045.006.033.2a.035.035 0 0 0 .036.032.08.08 0 0 0 .057-.031l.164-.194.049-.005.071.168a.036.036 0 0 0 .044.02.1.1 0 0 0 .055-.042l.138-.214.05-.016.107.135a.04.04 0 0 0 .05.008.1.1 0 0 0 .05-.051l.107-.226.05-.027.138.1a.05.05 0 0 0 .055 0 .1.1 0 0 0 .044-.058l.071-.228.049-.036.164.054a.06.06 0 0 0 .057-.017.1.1 0 0 0 .036-.063l.033-.223.045-.044.184.01a.08.08 0 0 0 .058-.029.1.1 0 0 0 .026-.065l-.007-.209.039-.05.2-.035a.1.1 0 0 0 .056-.04.1.1 0 0 0 .016-.065l-.046-.187.017-.053.2-.079a.1.1 0 0 0 .051-.049.07.07 0 0 0 0-.062l-.084-.157.024-.057.2-.119a.1.1 0 0 0 .045-.057.06.06 0 0 0-.007-.057l-.118-.122.015-.058.189-.155a.1.1 0 0 0 .037-.062.045.045 0 0 0-.018-.05l-.148-.082v-.055l.172-.185a.1.1 0 0 0 .028-.065.04.04 0 0 0-.014-.039m-1.153 1.988c-.066.013-.108-.037-.094-.112a.21.21 0 0 1 .145-.16c.066-.013.108.037.094.112a.21.21 0 0 1-.145.16m-.059-.39a.19.19 0 0 0-.132.146l-.061.325a2.3 2.3 0 0 1-.619.4 1.4 1.4 0 0 1-.632.123l-.061-.273c-.013-.057-.072-.072-.132-.033l-.252.164a1 1 0 0 1-.13-.106l1.226-.521q.022-.007.023-.026v-.455c0-.013-.009-.012-.023-.006l-.359.152v-.288l.388-.165a.16.16 0 0 1 .239.115c.015.057.049.249.072.3s.117.172.217.13l.611-.26.022-.012a3 3 0 0 1-.139.23Zm-1.7 1.13c-.066.043-.131.026-.145-.037a.2.2 0 0 1 .094-.192c.066-.043.131-.026.145.037a.2.2 0 0 1-.09.192Zm-.465-1.779a.18.18 0 0 1-.062.2c-.062.055-.134.056-.161 0a.18.18 0 0 1 .062-.2c.066-.051.138-.053.165 0Zm-.143.416.263-.234a.16.16 0 0 0 .057-.178l-.054-.105.213-.09v1l-.429.182a1.4 1.4 0 0 1-.057-.407c.001-.052.001-.11.011-.168Zm1.152-.587v-.3l.506-.215c.026-.011.185-.047.185.077 0 .1-.122.192-.222.234l-.47.2Zm1.84-.516v.118l-.154.065a.04.04 0 0 0-.022.036v.074a.31.31 0 0 1-.176.3c-.078.043-.165.036-.176-.01-.046-.253-.123-.278-.245-.327a1 1 0 0 0 .308-.578.3.3 0 0 0-.235-.315.57.57 0 0 0-.322.026l-1.592.677a2.7 2.7 0 0 1 .84-.853l.188.127c.042.029.113 0 .157-.063l.21-.3a.94.94 0 0 1 1.027.33l-.144.4c-.025.069 0 .128.057.13l.277.011q.004.073.004.152Zm-1.591-1.044c.049-.069.126-.1.172-.069s.045.113 0 .183-.126.1-.172.069-.044-.114.005-.184Zm1.427.6a.19.19 0 0 1 .161-.133c.062 0 .089.066.062.142a.19.19 0 0 1-.161.133c-.057-.006-.085-.07-.058-.15Z" opacity=".55"/><path d="M0 16.309h22.926v9.971L45.72 13.139 22.926 0v9.97H0z" fill="#231f20" transform="matrix(0 -.029 .022 .013 10.451 11.138)"/><path d="M0 16.309h22.926v9.971L45.72 13.139 22.926 0v9.97H0z" fill="#231f20" transform="matrix(0 -.029 .022 .013 15.013 12.984)"/></svg>`;var Ka=`:host{padding:0}.field,.browser,.entry-points{line-height:1.5}.note{color:var(--muted);font-size:.75rem}.source-fields{display:grid;grid-template-columns:minmax(12rem,1fr) minmax(0,1.6fr);align-items:end;gap:1rem;margin:1rem 0}.field{display:flex;flex-direction:column;gap:.4rem;min-width:0;font-size:.75rem;color:var(--muted)}.revision{display:flex;align-items:center;min-width:0;height:2rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg)}.revision:focus-within{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.revision-name{flex:1}.revision input{height:100%;min-height:0;padding:.3rem .6rem;min-width:0;border:0;border-radius:0;background:transparent;color:var(--text);font-size:.76rem}.revision input:focus-visible{outline:none}.revision-switch{display:flex;flex:none;align-self:stretch;padding:2px;gap:2px}.revision-switch button{display:grid;place-items:center;width:1.8rem;padding:0;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted)}.revision-switch button:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.revision-switch button:focus-visible{outline-offset:-2px}.revision-switch button[aria-pressed=true]{color:var(--accent);background:color-mix(in srgb,var(--accent) 15%,var(--bg))}.revision-switch svg{width:1rem;height:1rem}.revision-expand{display:grid;place-items:center;align-self:stretch;flex:none;width:2rem;padding:0;border:0;border-radius:var(--ui-radius, 4px);color:var(--muted);background:transparent}.revision-expand svg{width:.9rem;height:.9rem}.revision-expand:hover:not(:disabled){color:var(--text)}.revision-expand:focus-visible{outline-offset:-2px}.revision-menu{visibility:hidden;position:fixed;inset:auto;margin:0;padding:.45rem;overflow:auto;overscroll-behavior:contain;border:1px solid var(--border);border-radius:var(--ui-radius, 8px);background:var(--surface-active);color:var(--text);box-shadow:0 .65rem 1.8rem #00000073}.revision-menu[data-positioned]{visibility:visible}.revision-options{display:grid;grid-template-columns:repeat(var(--revision-columns, 1),minmax(0,1fr));gap:.15rem .5rem}.revision-options button{min-width:0;padding:.4rem .6rem;border:0;border-radius:var(--ui-radius, 4px);background:transparent;color:var(--text);text-align:left;font-size:.76rem}.revision-options button span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.revision-options button[aria-selected=true]{color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,transparent)}.revision-options button:hover,.revision-options button[data-active]{background:color-mix(in srgb,var(--text) 8%,transparent)}.revision-options button[data-active]{outline:1px solid var(--accent);outline-offset:-1px}.revision-empty{margin:0;padding:.65rem;color:var(--muted);font-size:.75rem}button:disabled,input:disabled{opacity:.5}.browser{border:1px solid var(--border);border-radius:var(--ui-radius, 7px);overflow:hidden}.browser-head{display:flex;align-items:center;gap:.75rem;padding:.65rem .8rem;border-bottom:1px solid var(--border);background:var(--bg);font-size:.75rem}.commit-link{display:inline-flex;align-items:center;flex:none;gap:.3rem;margin-left:auto;color:var(--muted);text-decoration:none}.commit-link svg{width:1rem;height:1rem}.commit-link:hover{color:var(--accent)}.commit-link:focus-visible{outline:1px solid var(--accent);outline-offset:3px;border-radius:var(--ui-radius, 2px)}.breadcrumbs{display:flex;align-items:center;flex-wrap:wrap;gap:.35rem;min-width:0}.breadcrumbs button{border:0;padding:.1rem;background:transparent;color:var(--muted);overflow-wrap:anywhere}.breadcrumbs button[aria-current]{color:var(--text)}.breadcrumbs button:hover:not(:disabled){color:var(--accent)}.file-browser{min-height:18rem;max-height:50vh;overflow:auto;padding:.75rem}.file-browser:has(>.empty){display:grid;place-items:center}.file-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,16rem),1fr));gap:.5rem}.file-tile{display:flex;align-items:center;gap:.5rem;min-width:0;height:2.05rem;padding:.4rem .6rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg);color:var(--text);font-size:.75rem}.file-tile>span:not(.arrow){overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left}.file-tile input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent);flex:none}.file-tile:hover,.file-tile:focus-within{border-color:var(--accent)}.file-tile.selected{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--bg))}.directory{color:var(--muted)}.directory .arrow{margin-left:auto}.unsupported{opacity:.55}.empty{margin:0;padding:1rem;border:0;border-radius:0;text-align:center;color:var(--muted);font-size:.8rem;line-height:1.5}.error{color:var(--critical)}.message{padding:.5rem .8rem;color:var(--muted);font-size:.75rem;line-height:1.5}.text-action{border:0;padding:.1rem .2rem;color:var(--accent);background:transparent;font-size:.75rem}.entry-points{display:flex;align-items:center;gap:1rem;margin-top:1rem}.package-suggestions{display:flex;align-items:center;gap:1rem;margin-top:1rem;color:var(--muted);font-size:.75rem}.package-suggestions>div{flex:1;min-width:0}.package-suggestions p{margin:0 0 .4rem}.package-suggestions .suggestions-note{margin:.4rem 0 0}.package-suggestions ul{display:flex;flex-wrap:wrap;gap:.4rem .8rem;padding:0;margin:0;list-style:none;max-height:6rem;overflow:auto}.package-suggestions li{min-width:0;max-width:100%}.package-suggestions li code{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)}.package-suggestions .btn{flex:none;font-size:.72rem}.selection{flex:1;min-width:0}.selection .note{margin:.5rem 0 0}.selection-head{display:flex;align-items:center;gap:.75rem}.btn.clear-selection{min-height:1.65rem;padding:.2rem .5rem;font-size:.72rem}h2{margin:0;font-size:.8rem;font-weight:500}h2 span{color:var(--muted);margin-left:.4rem}.entry-points ul{padding:0;display:flex;flex-wrap:wrap;gap:.4rem;list-style:none;max-height:7rem;overflow:auto;margin:.6rem 0 0}.entry-points li{display:flex;align-items:center;gap:.4rem;min-width:0;max-width:100%;padding:.2rem .4rem;border:1px solid var(--border);border-radius:var(--ui-radius, 4px);background:var(--bg);font-size:.72rem}.entry-points li span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.entry-points li button{display:grid;place-items:center;flex:none;width:1.3rem;height:1.3rem;padding:0;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted);cursor:default}.entry-points li button svg{width:1rem;height:1rem}.entry-points li button:hover{color:var(--critical);background:color-mix(in srgb,var(--critical) 12%,transparent)}.entry-points li button:focus-visible{outline:1px solid var(--accent);outline-offset:1px}@container (width <= 45rem){.source-fields{grid-template-columns:1fr}}
|
|
265
|
+
`;S();function Za(r,e,t){return Ya(r,e,t,c`Entry points declared in <code>package.json</code>`,"Suggested entry points")}function Ja(r,e,t,i){return Ya(r,e,t,"Suggested Solidity sources","Suggested Solidity sources",i)}function Ya(r,e,t,i,s,o=!1){let n=r.filter(a=>!e.has(a));return n.length===0&&!o?h:c`<aside class="package-suggestions" aria-label="${s}"><div><p>${i}</p>${n.length>0?c`<ul>${n.map(a=>c`<li><code data-tooltip-truncated data-tooltip="${a}">${a}</code></li>`)}</ul>`:h} ${o?c`<p class="suggestions-note">Suggestions are limited. Browse the source directories to select more files.</p>`:h}</div>${n.length>0?c`<button type="button" class="btn" @click="${()=>t(n)}">Use suggestions</button>`:h}</aside>`}S();var Xa=`:host{padding:0;margin:1.2rem 0}.conditions-head{display:flex;align-items:center;flex-wrap:wrap;gap:.65rem 1rem}.conditions-head[data-conditions-hidden]>:not(slot){visibility:hidden}slot[name=actions]::slotted(*){flex:none}h2{margin:0;font-size:.8rem;font-weight:500}.presets{display:flex;gap:2px;padding:3px;border:1px solid var(--border);border-radius:var(--ui-radius, 6px);background:var(--bg)}.presets button{display:inline-flex;align-items:center;gap:.35rem;padding:.3rem .65rem;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted);font-size:.75rem}.presets button:hover{background:var(--surface-active);color:var(--text)}.presets button[aria-pressed=true]{background:color-mix(in srgb,var(--accent) 15%,var(--bg));color:var(--accent)}.presets button:focus-visible{outline-offset:-1px}svg{width:1rem;height:1rem;flex:none}.platforms{display:flex;align-items:center;flex-wrap:wrap;gap:.75rem;font-size:.75rem}.platforms>span{color:var(--muted)}.platforms label{display:inline-flex;align-items:center;gap:.35rem}.platforms input{margin:0;width:.85rem;height:.85rem}.manual-toggle{display:flex;align-items:center;gap:.25rem;margin-left:auto;padding:.25rem 0;border:0;border-radius:var(--ui-radius, 2px);background:transparent;color:var(--muted);font-size:.75rem;white-space:nowrap}.manual-toggle:hover{color:var(--text)}.manual-toggle[hidden]{visibility:hidden}.manual-toggle[aria-expanded=true] svg{transform:rotate(90deg)}#manual-conditions{margin-top:.75rem}.condition-editor{display:flex;align-items:center;flex-wrap:wrap;gap:.35rem;min-height:2.25rem;padding:.3rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg)}.condition-editor:focus-within{border-color:var(--accent)}ul{display:flex;flex-wrap:wrap;gap:.35rem;max-width:100%;margin:0;padding:0;list-style:none}li{display:inline-flex;align-items:center;gap:.35rem;min-width:0;max-width:100%;min-height:1.5rem;padding:0 .25rem 0 .5rem;border:1px solid var(--border);border-radius:var(--ui-radius, 4px);background:var(--surface);color:var(--text);font-size:.73rem}li.preset{padding-right:.5rem}li code{overflow-wrap:anywhere}li button{display:grid;place-items:center;flex:none;width:1.3rem;height:1.3rem;padding:0;border:0;border-radius:var(--ui-radius, 3px);background:transparent;color:var(--muted)}li button:hover{color:var(--critical);background:color-mix(in srgb,var(--critical) 12%,transparent)}.condition-input{display:flex;align-items:center;flex:1;min-width:9rem}.condition-editor input{flex:1;width:0;min-width:0;min-height:1.5rem;padding:.15rem .4rem;border:0;border-radius:0;background:transparent;font-size:.75rem}.condition-editor input:focus-visible{outline:none}p{margin:.5rem 0 0;color:var(--muted);font-size:.7rem}.error{color:var(--critical)}@container (width <= 30rem){.conditions-head{gap:.6rem}.presets{margin-left:auto}.presets button{padding-inline:.4rem}.platforms{flex-basis:100%}}
|
|
266
|
+
`;var ls=["import","require","default"],Iu=[...ls,"node","node-addons","module-sync"],Mt=[{id:"node",label:"Node.js",conditions:["node"],automatic:Iu,icon:V`<path d="m8 1.5 5.5 3.2v6.6L8 14.5l-5.5-3.2V4.7Z"/><path d="M6 10V6l4 4V6"/>`},{id:"browser",label:"Browser",conditions:["browser","module"],automatic:ls,icon:V`<rect x="1.5" y="2.5" width="13" height="11" rx="1.5"/><path d="M1.5 6h13M4 4.3h.1m2 0h.1"/>`},{id:"metro",label:"Metro",conditions:["react-native"],automatic:ls,icon:V`<rect x="4" y="1.5" width="8" height="13" rx="2"/><path d="M6.5 3.5h3M7 12.5h2"/>`}],Qa=16-Math.max(...Mt.map(r=>r.conditions.length)),as=[{id:"ios",label:"iOS"},{id:"android",label:"Android"}],Mu=new Intl.ListFormat("en",{type:"conjunction"});function el(){return{preset:"node",conditions:["node"],platforms:[]}}var cs=class extends A{static styles=[$(N),$(Xa)];static properties={showConditions:{attribute:!1},_preset:{state:!0},_manual:{state:!0},_platforms:{state:!0},_draft:{state:!0},_error:{state:!0},_manualOpen:{state:!0}};constructor(){super(),this.showConditions=!0,this._preset="node",this._manual=[],this._platforms=["ios","android"],this._draft="",this._error="",this._manualOpen=!1}get value(){return{preset:this._preset,conditions:this.conditions,platforms:this._preset==="metro"?[...this._platforms]:[]}}get presetConditions(){return Mt.find(e=>e.id===this._preset).conditions}get automaticConditions(){return Mt.find(e=>e.id===this._preset).automatic}get conditions(){return[...new Set([...this.presetConditions,...this._preset==="metro"?[]:this._manual])]}notifyChange(){this.dispatchEvent(new CustomEvent("conditions-change",{detail:this.value,bubbles:!0,composed:!0}))}selectPreset(e){Mt.find(i=>i.id===e)&&(this._preset=e,this._draft="",this._error="",this.notifyChange())}togglePlatform(e){if(!as.some(i=>i.id===e))return;let t=this._platforms.includes(e);t&&this._platforms.length===1||(this._platforms=as.map(i=>i.id).filter(i=>i===e?!t:this._platforms.includes(i)),this.notifyChange())}addConditions(){if(this._preset==="metro")return;let e=this._draft.trim().split(/[\s,]+/u).filter(Boolean);if(e.length===0)return;if(e.some(i=>this.automaticConditions.includes(i)&&!this.presetConditions.includes(i))){this._error=`${Mu.format(this.automaticConditions)} are handled automatically.`;return}if(e.some(i=>i.length>64||i.startsWith(".")||/^\d+$/u.test(i))){this._error="Use condition names of up to 64 characters, without a leading dot or an all-numeric name.";return}let t=[...new Set([...this._manual,...e.filter(i=>!this.presetConditions.includes(i))])];if(t.length>Qa){this._error=`Use up to ${Qa} manual conditions.`;return}this._manual=t,this._draft="",this._error="",this.notifyChange()}removeCondition(e){this.presetConditions.includes(e)||(this._manual=this._manual.filter(t=>t!==e),this._error="",this.notifyChange())}render(){let e=this._preset!=="metro",t=this.automaticConditions.filter(i=>i!=="import"&&i!=="require");return c`<section aria-label="${this.showConditions?"Conditions":"Bundle actions"}"><div class="conditions-head" ?data-conditions-hidden="${!this.showConditions}"><h2 id="conditions-heading">Conditions</h2><div class="presets" role="group" aria-label="Condition preset">${Mt.map(i=>c`<button type="button" aria-pressed="${this._preset===i.id}" @click="${()=>this.selectPreset(i.id)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${i.icon}</svg>${i.label}</button>`)}</div>${this._preset==="metro"?c`<div class="platforms" role="group" aria-label="Metro platforms"><span>Platforms</span>${as.map(({id:i,label:s})=>c`<label><input type="checkbox" .checked="${this._platforms.includes(i)}" ?disabled="${this._platforms.includes(i)&&this._platforms.length===1}" @change="${()=>this.togglePlatform(i)}">${s}</label>`)}</div>`:h} <button type="button" class="manual-toggle" ?hidden="${!e}" aria-expanded="${this._manualOpen}" aria-controls="manual-conditions" @click="${()=>{this._manualOpen=!this._manualOpen}}"><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="m6 4 4 4-4 4"/></svg>Manual conditions</button><slot name="actions"></slot></div><div id="manual-conditions" ?hidden="${!this.showConditions||!e||!this._manualOpen}"><form class="condition-editor" @submit="${i=>{i.preventDefault(),this.addConditions()}}"><ul aria-label="Export conditions">${this.conditions.map(i=>this.presetConditions.includes(i)?c`<li class="preset"><code>${i}</code></li>`:c`<li><code>${i}</code><button type="button" aria-label="${`Remove condition ${i}`}" @click="${()=>this.removeCondition(i)}"><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></button></li>`)}</ul><div class="condition-input"><input type="text" aria-label="Add conditions" aria-describedby="conditions-help" aria-invalid="${!!this._error}" aria-errormessage="condition-error" placeholder="Add condition…" autocomplete="off" maxlength="1040" .value="${this._draft}" @input="${i=>{this._draft=i.target.value,this._error=""}}" @keydown="${i=>{i.key===" "&&!i.isComposing&&(i.preventDefault(),this.addConditions())}}" @blur="${()=>this.addConditions()}"></div></form><p id="conditions-help">Package export conditions. <code>import</code> / <code>require</code>${t.map((i,s)=>c`${s<t.length-1?", ":t.length>1?", and ":" and "}<code>${i}</code>`)} are automatic.</p>${this._error?c`<p id="condition-error" class="error" role="alert">${this._error}</p>`:h}</div></section>`}};customElements.define("bundle-conditions",cs);var tl=c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="8" cy="8" r="3"/><path d="M1 8h4m6 0h4"/></svg>`,Lu=100,zu=[{kind:"branch",label:"Branch",icon:c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" aria-hidden="true"><circle cx="4" cy="3" r="1.5"/><circle cx="4" cy="13" r="1.5"/><circle cx="12" cy="3" r="1.5"/><path d="M4 4.5v7m0-3h3a5 5 0 0 0 5-4"/></svg>`},{kind:"tag",label:"Tag",icon:c`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round" aria-hidden="true"><path d="M2 2h5.5l6.5 6.5-5.5 5.5L2 7.5Z"/><circle cx="5" cy="5" r="1"/></svg>`},{kind:"commit",label:"Commit SHA",icon:tl}];async function ds(r,e,t){let i=await x(`/api/admin/repositories/${r}?${new URLSearchParams(e)}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:t});if(!i.ok){let s=await i.json().catch(()=>null);if(s?.error==="github-rate-limited"){let o=Number(i.headers.get("retry-after")),n=Math.ceil(o/60),a=Number.isFinite(o)&&o>0?` Try again in about ${n} ${n===1?"minute":"minutes"}.`:" Try again after the limit resets.";throw new Error(`GitHub\u2019s API rate limit has been reached.${a}`)}throw s?.error==="github-status-403"?new Error("GitHub denied this request. Check repository access and the GitHub App\u2019s read permissions."):s?.error==="github-unauthorized"?new Error("GitHub authentication has expired or was revoked. Sign in again and check the repository App installation."):s?.error==="github-unreachable"?new Error("Could not connect to GitHub. Try again shortly."):i.status===404?new Error("This repository, revision, or directory is unavailable."):i.status===403?new Error("Repository access is required to browse files."):new Error("Could not load repository files from GitHub. Try again.")}return i.json()}var ps=class extends A{static styles=[$(N),$(Ka)];static properties={installTooltips:{attribute:!1},createBundle:{attribute:!1},_building:{state:!0},_opening:{state:!0},_buildError:{state:!0},initialRepoId:{attribute:!1},_repos:{state:!0},_loadingRepos:{state:!0},_reposError:{state:!0},_repoId:{state:!0},_refs:{state:!0},_refKind:{state:!0},_refName:{state:!0},_path:{state:!0},_entries:{state:!0},_selected:{state:!0},_commit:{state:!0},_packageEntryPoints:{state:!0},_solidityEntryPoints:{state:!0},_soliditySuggestionsLimited:{state:!0},_loadingRefs:{state:!0},_loading:{state:!0},_error:{state:!0},_refsError:{state:!0},_limited:{state:!0},_revisionOpen:{state:!0},_revisionQuery:{state:!0},_activeRevision:{state:!0}};constructor(){super(),this._repos=[],this._loadingRepos=!0,this._reposError="",this.initialRepoId=null,this._building=!1,this._opening=!1,this._buildError="",this._repoId=null,this._refs={branches:[],tags:[]},this._refKind="branch",this._refName="",this._path="",this._entries=null,this._selected=new Set,this._dismissedSuggestions=new Set,this._bundleConditions=el(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._commit="",this._directories=new Map,this._loadingRefs=!1,this._loading=!1,this._error="",this._refsError="",this._limited=!1,this._revisionOpen=!1,this._revisionQuery="",this._activeRevision=-1,this._onViewport=()=>this.positionRevisionSuggestions()}connectedCallback(){super.connectedCallback(),globalThis.addEventListener("resize",this._onViewport),globalThis.addEventListener("scroll",this._onViewport,!0)}updated(e){e.has("installTooltips")&&this.installTooltips?.(this.renderRoot),this.positionRevisionSuggestions()}firstUpdated(){this.loadRepositories()}async loadRepositories(){this._reposRequest?.abort(),this.selectRepository(null),this._repos=[],this._reposError="",this._loadingRepos=!0;let e=new AbortController;this._reposRequest=e;try{let t=await ds("browsable",{},e.signal);if(e.signal.aborted)return;this._repos=t.repos,this._repos.some(i=>i.repoId===this.initialRepoId)&&this.selectRepository(this.initialRepoId)}catch{e.signal.aborted||(this._reposError="Could not load repositories. Try again.")}finally{e.signal.aborted||(this._loadingRepos=!1)}}disconnectedCallback(){this._buildRequest?.abort(),this._opening=!1,globalThis.removeEventListener("resize",this._onViewport),globalThis.removeEventListener("scroll",this._onViewport,!0),clearTimeout(this._browseTimer),this._reposRequest?.abort(),this._refsRequest?.abort(),this._request?.abort(),this._directories.clear(),this._dismissedSuggestions.clear(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,super.disconnectedCallback()}resetFiles(){this._buildError="",clearTimeout(this._browseTimer),this._request?.abort(),this._directories.clear(),this._loading=!1,this._entries=null,this._path="",this._commit="",this._selected=new Set,this._dismissedSuggestions.clear(),this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._error="",this._limited=!1}async selectRepository(e){if(this.closeRevisionSuggestions(),this._refsRequest?.abort(),this.resetFiles(),this._repoId=e,this._refs={branches:[],tags:[]},this._refsError="",this._refKind="branch",this._refName="",e==null){this._loadingRefs=!1;return}let t=new AbortController;this._refsRequest=t,this._loadingRefs=!0;try{let{defaultContents:i,...s}=await ds("refs",{repoId:e,withDefault:"true"},t.signal);if(t.signal.aborted)return;this._refs=s,this._refName=s.defaultBranch||s.branches[0]||"",i?this.useDirectory(i,""):this._refName&&this.loadDirectory("")}catch(i){t.signal.aborted||(this._refsError=i.message)}finally{t.signal.aborted||(this._loadingRefs=!1)}}changeRevision(e,t){this._refsRequest?.abort(),this._loadingRefs=!1,this.resetFiles(),this._refKind=e,this._refName=t}selectRevisionType(e){this._refKind!==e&&(this.closeRevisionSuggestions(),this.changeRevision(e,e==="branch"&&this._refs.defaultBranch||""),this._refName&&this.loadDirectory(""))}editRevision(e){this.changeRevision(this._refKind,e);let t=e.trim();if(!t)return;let i=this._refKind==="branch"?this._refs.branches:this._refs.tags;this._refKind!=="commit"&&(i.includes(t)||this._refKind==="branch"&&t===this._refs.defaultBranch)?this.loadDirectory(""):this._browseTimer=setTimeout(()=>{this.loadDirectory("")},350)}revisionSuggestions(){let e=this._refKind==="branch"?this._refs.branches:this._refKind==="tag"?this._refs.tags:[],t=this._refKind==="branch"&&this._refs.defaultBranch?[this._refs.defaultBranch,...e.filter(s=>s!==this._refs.defaultBranch)]:e,i=this._revisionQuery.trim().toLowerCase();return t.filter(s=>s.toLowerCase().includes(i))}showRevisionSuggestions(e=!0){this._refKind==="commit"||this._repoId==null||this._loadingRefs||(this._revisionQuery=e?"":this._refName,this._activeRevision=-1,this.renderRoot.querySelector(".revision-menu").showPopover())}closeRevisionSuggestions(){this.renderRoot?.querySelector(".revision-menu")?.hidePopover(),this._revisionOpen=!1,this._activeRevision=-1}pickRevision(e){this.editRevision(e),this.renderRoot.querySelector(".revision-name").focus({preventScroll:!0}),this.closeRevisionSuggestions()}positionRevisionSuggestions(){if(!this._revisionOpen)return;let e=this.renderRoot.querySelector(".revision-menu"),t=this.renderRoot.querySelector(".revision-name").getBoundingClientRect(),i=8,s=6,n=15*parseFloat(getComputedStyle(this).fontSize),a=Math.max(1,Math.min(3,Math.ceil(this.revisionSuggestions().length/8),Math.floor((window.innerWidth-2*i)/n))),l=Math.min(Math.max(t.width,a*n),window.innerWidth-2*i);e.style.width=`${l}px`,e.style.setProperty("--revision-columns",a),e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-l-i))}px`;let d=window.innerHeight-t.bottom-s-i,m=t.top-s-i,p=d<Math.min(e.scrollHeight,320)&&m>d;e.style.maxHeight=`${Math.max(0,Math.min(320,p?m:d))}px`,e.style.top=`${Math.max(i,p?t.top-e.offsetHeight-s:t.bottom+s)}px`,e.dataset.positioned=""}async revisionKeyDown(e){if(e.key==="Escape"||e.key==="Tab"){e.key==="Escape"&&this._revisionOpen&&(e.preventDefault(),e.stopPropagation()),this.closeRevisionSuggestions();return}if(e.key==="Enter"){let i=this.revisionSuggestions()[this._activeRevision];this._revisionOpen&&i!=null?(e.preventDefault(),this.pickRevision(i)):this.closeRevisionSuggestions();return}if(this._refKind==="commit"||!["ArrowDown","ArrowUp"].includes(e.key))return;e.preventDefault(),this._revisionOpen||this.showRevisionSuggestions();let t=this.revisionSuggestions().length;this._activeRevision=t===0?-1:e.key==="ArrowDown"?Math.min(this._activeRevision+1,t-1):this._activeRevision<=0?t-1:this._activeRevision-1,await this.updateComplete,this.renderRoot.querySelector("[data-active]")?.scrollIntoView({block:"nearest"})}async loadDirectory(e,t=!1){if(clearTimeout(this._browseTimer),this._repoId==null||!this._refName.trim())return;t&&this.resetFiles(),this._request?.abort();let i=new AbortController;this._request=i,this._path=e,this._entries=null,this._error="",this._limited=!1,this._packageEntryPoints=[],this._solidityEntryPoints=[],this._soliditySuggestionsLimited=!1,this._loading=!1;let s=this._refName.trim();if(this._refKind==="commit"&&!/^[a-f\d]{7,40}$/iu.test(s)){this._error="Enter a commit SHA with 7 to 40 hexadecimal characters.";return}let o=this._commit||(this._refKind==="commit"?s:`${this._refKind==="branch"?"heads":"tags"}/${s}`),n=JSON.stringify([this._repoId,this._commit,e]),a=this._commit&&this._directories.get(n);if(a){this._directories.delete(n),this._directories.set(n,a),this._entries=a.entries,this._limited=a.limited,this._packageEntryPoints=a.packageEntryPoints,this._solidityEntryPoints=a.solidityEntryPoints,this._soliditySuggestionsLimited=a.soliditySuggestionsLimited;return}this._loading=!0;try{let l=await ds("contents",{repoId:this._repoId,ref:o,path:e},i.signal);if(i.signal.aborted)return;this.useDirectory(l,e)}catch(l){i.signal.aborted||(this._directories.clear(),this._error=l.message)}finally{i.signal.aborted||(this._loading=!1)}}useDirectory(e,t){this._path=t,this._commit=e.commit,this._entries=e.entries.toSorted((s,o)=>+(o.type==="dir")-+(s.type==="dir")||s.name.localeCompare(o.name)),this._limited=e.limited,this._packageEntryPoints=e.packageEntryPoints??[],this._solidityEntryPoints=e.solidityEntryPoints??[],this._soliditySuggestionsLimited=e.soliditySuggestionsLimited??!1;let i=[...this._packageEntryPoints,...this._solidityEntryPoints].filter(s=>!this._dismissedSuggestions.has(s));if(this._selected=new Set([...this._selected,...i]),/^[a-f\d]{40}$/iu.test(e.commit)){let s=JSON.stringify([this._repoId,e.commit,t]);this._directories.set(s,{entries:this._entries,limited:this._limited,packageEntryPoints:this._packageEntryPoints,solidityEntryPoints:this._solidityEntryPoints,soliditySuggestionsLimited:this._soliditySuggestionsLimited}),this._directories.size>Lu&&this._directories.delete(this._directories.keys().next().value)}}toggleFile(e){let t=new Set(this._selected);t.has(e)?(t.delete(e),this._dismissedSuggestions.add(e)):(t.add(e),this._dismissedSuggestions.delete(e)),this._selected=t}clearFiles(){for(let e of this._selected)this._dismissedSuggestions.add(e);this._selected=new Set}hasScriptEntryPoints(){return[...this._selected].some(e=>/\.[cm]?[tj]sx?$/iu.test(e))}async buildBundle(){if(this._building||this._opening||!this.createBundle||!this._commit||this._selected.size===0)return;let e=new AbortController;this._buildRequest=e,this._building=!0,this._buildError="";try{let t=await this.createBundle({repoId:this._repoId,commit:this._commit,entries:[...this._selected],conditions:this._bundleConditions},e.signal);e.signal.aborted||(this._opening=!0,this.dispatchEvent(new CustomEvent("bundle-created",{detail:t,bubbles:!0,composed:!0})))}catch(t){e.signal.aborted||(this._buildError=t.message)}finally{this._building=!1}}render(){let e=this._building||this._opening,t=this._repos.find(a=>a.repoId===this._repoId),i=this._path.split("/").filter(Boolean),s=t&&this._commit?`https://github.com/${[...t.fullName.split("/"),"tree",this._commit,...i].map(encodeURIComponent).join("/")}`:null,o=this.revisionSuggestions(),n=this._refKind==="commit"?"Commit SHA":this._refKind==="tag"?"Tag":"Branch";return c`<p class="intro ui-hint">Choose a repository and revision, then select files to use as entry points.</p><div ?inert="${e}"><div class="source-fields"><div class="field"><span>Repository</span><repository-selector label="Repository" ?disabled="${this._loadingRepos}" .options="${this._repos.map(a=>({value:a.repoId,label:a.fullName}))}" .value="${this._repoId}" @repository-change="${a=>this.selectRepository(a.detail.value)}"></repository-selector></div><form class="revision" @focusout="${a=>{a.currentTarget.contains(a.relatedTarget)||this.closeRevisionSuggestions()}}" @submit="${a=>{a.preventDefault(),this.loadDirectory("",!0)}}"><div class="revision-switch" role="group" aria-label="Revision type">${zu.map(({kind:a,label:l,icon:d})=>c`<button type="button" aria-label="${l}" data-tooltip="${l}" aria-pressed="${this._refKind===a}" ?disabled="${!t||this._loadingRefs}" @click="${()=>{this.selectRevisionType(a),this.renderRoot.querySelector(".revision-name").focus(),this.showRevisionSuggestions()}}">${d}</button>`)}</div><input class="revision-name" type="text" aria-label="${n}" role="${Se(this._refKind==="commit"?void 0:"combobox")}" aria-autocomplete="${Se(this._refKind==="commit"?void 0:"list")}" aria-expanded="${Se(this._refKind==="commit"?void 0:String(this._revisionOpen))}" aria-controls="${Se(this._refKind==="commit"?void 0:"bundle-revisions")}" aria-activedescendant="${Se(this._revisionOpen&&this._activeRevision>=0?`revision-${this._activeRevision}`:void 0)}" autocomplete="off" placeholder="${this._refKind==="commit"?"Commit SHA\u2026":`Choose or enter a ${this._refKind}\u2026`}" .value="${this._refName}" ?disabled="${!t||this._loadingRefs}" @focus="${()=>this.showRevisionSuggestions()}" @click="${()=>this.showRevisionSuggestions()}" @keydown="${this.revisionKeyDown}" @input="${a=>{this.editRevision(a.target.value),this.showRevisionSuggestions(!1)}}"> ${this._refKind==="commit"?h:c`<button type="button" class="revision-expand" aria-label="${`Show ${this._refKind} suggestions`}" aria-expanded="${this._revisionOpen}" ?disabled="${!t||this._loadingRefs}" @mousedown="${a=>a.preventDefault()}" @click="${()=>{this._revisionOpen?this.closeRevisionSuggestions():(this.renderRoot.querySelector(".revision-name").focus(),this.showRevisionSuggestions())}}"><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="revision-menu" id="bundle-revisions" popover="auto" role="listbox" aria-label="${`${n} suggestions`}" @beforetoggle="${a=>{this._revisionOpen=a.newState==="open",delete a.target.dataset.positioned,this._revisionOpen||(this._activeRevision=-1)}}"><div class="revision-options">${o.map((a,l)=>c`<button type="button" role="option" id="${`revision-${l}`}" aria-selected="${a===this._refName}" ?data-active="${l===this._activeRevision}" tabindex="-1" @mousedown="${d=>d.preventDefault()}" @click="${()=>this.pickRevision(a)}"><span data-tooltip-truncated data-tooltip="${a}">${a}</span></button>`)}</div>${o.length>0?h:c`<p class="revision-empty">${this._revisionQuery?"No matching suggestions. Enter a revision name to browse.":`No ${this._refKind} suggestions available.`}</p>`}</div></form></div>${this._reposError?c`<p class="message" role="alert">${this._reposError} <button type="button" class="text-action" @click="${()=>this.loadRepositories()}">Retry</button></p>`:h} ${this._refsError?c`<p class="message" role="status">${this._refsError} <button type="button" class="text-action" @click="${()=>this.selectRepository(this._repoId)}">Retry</button></p>`:h}<section class="browser" aria-label="Repository files" aria-busy="${this._loadingRepos||this._loading||this._loadingRefs}"><div class="browser-head"><nav class="breadcrumbs" aria-label="Repository directory"><button type="button" ?disabled="${!this._commit}" aria-current="${Se(this._path?void 0:"location")}" @click="${()=>this.loadDirectory("")}">${t?.fullName??"Repository"}</button>${i.map((a,l)=>c`<span aria-hidden="true">/</span><button type="button" aria-current="${Se(l===i.length-1?"location":void 0)}" @click="${()=>this.loadDirectory(i.slice(0,l+1).join("/"))}">${a}</button>`)}</nav>${s?c`<a class="commit-link" href="${s}" target="_blank" rel="noopener noreferrer" data-tooltip="${this._commit}" aria-label="${`View directory at commit ${this._commit.slice(0,7)} on GitHub`}">${tl}<code>${this._commit.slice(0,7)}</code></a>`:h}</div><div class="file-browser">${this._loadingRepos||this._loading||this._loadingRefs?c`<p class="empty" role="status">${this._loadingRepos?"Loading repositories\u2026":this._loadingRefs?"Loading revisions\u2026":"Loading files\u2026"}</p>`:this._error?c`<p class="empty error" role="alert">${this._error} <button type="button" class="text-action" @click="${()=>this.loadDirectory(this._path)}">Retry</button></p>`:this._entries==null?c`<p class="empty">${t?"Choose a revision to browse its files.":this._repos.length>0?"Select a repository to browse its files.":"No accessible repositories available."}</p>`:this._entries.length===0?c`<p class="empty">This directory is empty.</p>`:c`<div class="file-grid">${this._entries.map(a=>a.type==="dir"?c`<button type="button" class="file-tile directory" @click="${()=>this.loadDirectory(a.path)}">${Wa}<span data-tooltip-truncated data-tooltip="${a.path}">${a.name}</span><span class="arrow" aria-hidden="true">›</span></button>`:c`<label class="${`file-tile ${this._selected.has(a.path)?"selected":""} ${a.type==="file"?"":"unsupported"}`}" data-tooltip="${a.type==="file"?h:`${a.path} (${a.type})`}"><input type="checkbox" aria-label="${`Select ${a.path} as an entry point`}" .checked="${this._selected.has(a.path)}" ?disabled="${a.type!=="file"}" @change="${()=>this.toggleFile(a.path)}">${ns(a.name)}<span data-tooltip-truncated data-tooltip="${a.type==="file"?a.path:h}">${a.name}</span></label>`)}</div>`}</div>${this._limited?c`<p class="message">Showing GitHub’s first 1,000 entries in this directory.</p>`:h}</section>${Za(this._packageEntryPoints,this._selected,a=>{this._selected=new Set([...this._selected,...a])})} ${Ja(this._solidityEntryPoints,this._selected,a=>{this._selected=new Set([...this._selected,...a])},this._soliditySuggestionsLimited)}<section class="entry-points" aria-label="Selected entry points"><div class="selection"><div class="selection-head"><h2>Entry points <span aria-live="polite">${this._selected.size}</span></h2>${this._selected.size>0?c`<button type="button" class="btn clear-selection" @click="${this.clearFiles}">Clear all</button>`:h}</div>${this._selected.size>0?c`<ul>${[...this._selected].map(a=>c`<li>${ns(a)}<span data-tooltip-truncated data-tooltip="${a}">${a}</span><button type="button" aria-label="${`Remove ${a}`}" @click="${()=>this.toggleFile(a)}"><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></button></li>`)}</ul>`:c`<p class="note">Select files above. You can choose entry points from multiple directories.</p>`}</div></section><bundle-conditions .showConditions="${this.hasScriptEntryPoints()}" @conditions-change="${a=>{this._bundleConditions=a.detail}}"><button type="button" slot="actions" class="btn primary" ?disabled="${e||!this.createBundle||!this._commit||this._selected.size===0||this._loading||this._loadingRefs}" @click="${this.buildBundle}">${this._opening?"Opening\u2026":this._building?"Creating\u2026":"Create a bundle"}</button></bundle-conditions></div>${e?c`<p class="message" role="status">${this._opening?"Opening bundle\u2026":"Building the selected entry points with Stasis\u2026"}</p>`:h} ${this._buildError?c`<p class="message error" role="alert">${this._buildError}</p>`:h}`}};customElements.define("managed-create-bundle",ps);var Ou=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"}),Tu=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 Nu(r){let e=typeof r=="string"?r.slice(r.lastIndexOf("/")+1):"",t=e.lastIndexOf("."),i=t>0?e.slice(t+1).trim().toLowerCase():"",s=vr(r)??Tu[i];return s?{key:s,label:Ou[s]??s}:i?{key:`extension:${i}`,label:`.${i}`}:{key:"other",label:"Other"}}function rl(r,e){let t=new Map,i=0,s=0;for(let[o,n]of r){let a=Nu(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))}}hs();var Pu=new Set(["module","commonjs","json","module-typescript","commonjs-typescript"]),Bu=new Set(["solidity","php","shell","rust"]),Du=new Set(["java","kotlin","gradle","objc","objcpp","swift","c","cpp","c-header","cpp-header","ruby","python","cmake","podspec","podfile","podfile-lock","template","xml","env","fastlane","pbxproj"]),ju=new Set(["resource","resource:base64"]),nl=new Set(["stat:file","stat:directory"]),Uu=new Set([...Pu,...Bu,...Du,...ju,"patch","directory",...nl]),ms=r=>nl.has(r);var il=r=>r==="directory"||r==="stat:directory"?"directory":"file";function Fu(r,e,t){if(r===e)return r;let i=ms(r);if(i!==ms(e)&&il(r)===il(e))return i?e:r;throw new Error(`format conflict for '${t}' ('${e}' vs '${r}')`)}function Ue(r,e){return e===""?r:r==="."?e:`${r}/${e}`}var Hu=/^(?=[A-Za-z0-9-]{1,39}\/)[A-Za-z0-9](?:-?[A-Za-z0-9])*\/(?!\.\.?$)[\w.-]{1,100}$/u,qu=/^(?!\.\.?(?:\/|$))[\w.~@+-]+(?:\/(?!\.\.?(?:\/|$))[\w.~@+-]+)*$/u,Vu=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u,fs={github:r=>typeof r=="string"&&Hu.test(r),directory:r=>typeof r=="string"&&r.length<=1024&&(r===""||qu.test(r)),commit:r=>typeof r=="string"&&Vu.test(r)},al=(r,e)=>r?.toLowerCase()===e?.toLowerCase();var wr=(r,e,t)=>{if(r===void 0)return;Fe(r)||w(!1,`${t} must be an object`);for(let s of Object.keys(r))Object.hasOwn(e,s)||w(!1,`unknown ${t} key '${s}'`);let i=Object.entries(e).map(([s,o])=>typeof o=="object"?[s,wr(r[s],o,`${t}.${s}`)]:(r[s]!==void 0&&!o(r[s])&&w(!1,`invalid ${t}.${s}: ${JSON.stringify(r[s])}`),[s,r[s]])).filter(([,s])=>s!==void 0);return i.length===0?void 0:Object.freeze(X(i))},xr=(r,e="bundle repo")=>wr(r,fs,e),Gu=(r,e)=>e??(He(r)?"npm":void 0),ll=(r,{ecosystem:e,repo:t},i)=>{if(t===void 0)return;Gu(r,e)===void 0&&w(!1,`${i}: '${r}' is no dependency's bucket, and carries no repo`);let s=xr(t,`${i} module '${r}' repo`);return s?.github===void 0&&w(!1,`${i} module '${r}' repo has no github`),s},_r=({name:r,version:e,ecosystem:t,repo:i,files:s})=>({name:r,version:e,...t===void 0?{}:{ecosystem:t},...i===void 0?{}:{repo:i},files:s});function gs({name:r,version:e,ecosystem:t,repo:i,files:s},o,n){return w(t===void 0||typeof t=="string"),_r({name:r,version:e??void 0,ecosystem:t,repo:ll(o,{ecosystem:t,repo:i},n),files:X(Object.entries(s))})}function cl(r,{scope:e="full"}={}){let t=new Set;for(let[i,{files:s}]of r)if(!(e!=="full"&&!He(i)))for(let o of Object.keys(s))t.add(Ue(i,o));return t}function Wu(r,{what:e,files:t,formats:i,scope:s}){if(r.includes("\\"))return"holds a '\\'";if(Lt(r))return"escapes the root";if(s!=="full"&&!He(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":ms(o)?`is a payload-free '${o}' record, not a file`:null}function dl(r,{what:e,files:t,formats:i,scope:s}){for(let o of r){let n=Wu(o,{what:e,files:t,formats:i,scope:s});w(n===null,`${e}: executable entry '${o}' ${n}`)}}function pl(r,{what:e,files:t,formats:i,scope:s="full"}){if(r===void 0)return new Set;let o=`${e}: executable`;w(Array.isArray(r),`${o} must be an array of file paths`);let n=new Set;for(let a of r)w(typeof a=="string"&&a!=="",`${o} entry must be a non-empty string`),w(!n.has(a),`${o} entry '${a}' is listed twice`),n.add(a);return dl(n,{what:e,files:t,formats:i,scope:s}),n}function ul(r,{what:e,modules:t,formats:i,scope:s}){if(r.size!==0)return dl(r,{what:e,files:cl(t,{scope:s}),formats:i,scope:s}),$r(r)}function w(r,e){if(!r)throw new Error(e)}function hl(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 yr=(r,e)=>hl(r[0],e[0]),Fe=r=>r&&[null,Object.prototype].includes(Object.getPrototypeOf(r)),X=r=>Object.setPrototypeOf(Object.fromEntries(r),null),$r=r=>[...r].toSorted(hl),bs=(r,{sorted:e=!0}={})=>{let t=e?[...r].toSorted(yr):[...r];return X(t.map(([i,s])=>[i,s instanceof Map?bs(s,{sorted:e}):s]))},sl=(r,e)=>r.get(e)??r.set(e,new Map).get(e),ml=r=>new Map(Object.entries(r).map(([e,t])=>[e,Fe(t)?ml(t):t]));function Lt(r){if(r.startsWith("/"))return!0;if(!r.includes(".."))return!1;let e=0;for(let t of r.split("/"))if(!(t==="."||t==="")){if(t!=="..")e++;else if(--e<0)return!0}return!1}var fl=r=>r.includes("\\")||Lt(r),le=(r,e)=>w(!fl(r),`${e}: path '${r}' escapes the root or holds a '\\'`),gl=(r,e)=>w(typeof r=="string"&&r!==""&&!fl(r),`${e}: invalid entry ${JSON.stringify(r)}`);function bl(r,e){w(Array.isArray(r),`${e}: entries must be an array of file paths`);let t=new Set;for(let i of r)gl(i,e),w(!t.has(i),`${e}: entry '${i}' is listed twice`),t.add(i);return t}function vl(r,e){for(let t of r)gl(t,e);return $r(r)}function yl(r,e){le(r,"formats"),w(Uu.has(e),`unknown format '${e}' for ${r}`)}function _l(r){w(Fe(r));let e=new Map;for(let[t,i]of Object.entries(r)){yl(t,i);let s=t===""?".":t;w(!e.has(s),`duplicate format key '${s}'`),e.set(s,i)}return e}function wl(r){for(let[e,t]of r)yl(e,t);return bs(r)}function xl(r){for(let[,e]of r){w(e instanceof Map);for(let[t,i]of e){le(t,"imports"),w(i instanceof Map);for(let[,s]of i){if(typeof s=="string"){le(s,"imports");continue}w(s instanceof Map&&s.size>0,"import target must be a file or a non-empty {platform: file} map");for(let[o,n]of s)w(typeof o=="string"&&o.length>0&&!o.includes("/"),`invalid platform key '${o}'`),w(typeof n=="string"),le(n,"imports")}}}}function $l(r){w(Fe(r));let e=ml(r);return xl(e),e}function kl(r){return xl(r),bs(r)}function Sl(r,{skipEmpty:e=!1,repo:t=!0,what:i}={}){let s={modules:[],sources:[]};for(let[o,n]of r){if(e&&Object.keys(n.files).length===0)continue;let a=He(o);a&&w(n.name&&n.version&&n.files);let l=X(Object.entries(n.files).toSorted(yr));s[a?"modules":"sources"].push([o,_r({...n,repo:t?ll(o,n,i):void 0,files:l})])}return{modules:X(s.modules.toSorted(yr)),sources:X(s.sources.toSorted(yr))}}function Ku(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 ol=r=>r instanceof Map?`{${[...r].map(([e,t])=>`${e}: ${t}`).join(", ")}}`:r;function Cl(r,e,t){let i=new Map,s=o=>{for(let[n,a]of o){let l=sl(i,n);for(let[d,m]of a){let p=sl(l,d);for(let[u,f]of m)p.has(u)?w(Ku(p.get(u),f),`${t}: import '${u}' from '${d}' resolves differently ('${ol(p.get(u))}' vs '${ol(f)}')`):p.set(u,f instanceof Map?new Map(f):f)}}};return s(r),s(e),i}function Rl(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,Fu(a,l,n))}catch(d){throw new Error(`${t}: ${d.message}`,{cause:d})}}};return s(r),s(e),i}function El(r,e,t,i){if(r.size===0)return new Set(e);let s=cl(t,{scope:i}),o=new Set(e);for(let n of r)s.has(n)||o.add(n);return o}var Zu=/(?:^|\/)\.{0,2}(?:\/|$)/u;function kr(r,e,t){let i=Ue(r,e);return(i!=="."||e!=="")&&Zu.test(i)&&w(!1,`${t}: non-canonical file key ${JSON.stringify(i)}`),i.includes("\\")&&w(!1,`${t}: file key '${i}' holds a '\\', which no path may`),i}function Sr(r,e,t){let i=new Map;for(let[s,{files:o}]of r){typeof s!="string"&&w(!1,`${e}: bucket dir ${String(s)} is not a string`),le(s,e);for(let n of Object.keys(o)){let a=kr(s,n,e),l=i.get(a);l!==void 0&&t(a,l,s),i.set(a,s)}}return i}var Al=(r,e)=>t=>w(!1,`duplicate file key '${t}' across ${r} buckets -- module bucketing changed between writes (a workspace package without a version now owns its own bucket); regenerate the ${e}`);function Il(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,_r({...a,files:Object.assign(Object.create(null),a.files)}));continue}w(l.name===a.name,`${t}: module '${n}' name mismatch ('${l.name}' vs '${a.name}')`),w(l.version===a.version,`${t}: module '${n}' version mismatch ('${l.version}' vs '${a.version}')`+(l.version==null==(a.version==null)?"":" -- an artifact from an older stasis may record a placeholder version for a workspace package without one; regenerate it (bundle=replace / lock=replace)")),w(l.ecosystem===a.ecosystem,`${t}: module '${n}' ecosystem mismatch ('${l.ecosystem??"(none)"}' vs '${a.ecosystem??"(none)"}')`),l.repo===void 0&&a.repo!==void 0&&i.set(n,_r({...l,repo:a.repo}));for(let[d,m]of Object.entries(a.files))Object.hasOwn(l.files,d)?w(l.files[d]===m,`${t}: content mismatch for '${Ue(n,d)}'`):l.files[d]=m}};return s(r),s(e),Sr(i,t,(o,n,a)=>w(!1,`${t}: file '${o}' is bucketed under both '${n}' and '${a}' -- module bucketing changed between the artifacts (a workspace package without a version now owns its own bucket); regenerate the artifact (bundle=replace / lock=replace)`)),i}function He(r){return r.split("/").includes("node_modules")}function Ju(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 Ml(r){let e="node_modules/",t=Ju(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 Ce=1,Ll=0,zl=Al("bundle","artifact (bundle=replace)"),Ol=r=>Ml(r)??{dir:".",rel:r==="."?"":r,name:null};function Yu(){throw new Error("bundle: file contents are not retained by this contents-free Bundle")}var Xu=(r,{files:e,...t})=>{let i=Object.create(null);for(let[s,o]of Object.entries(e))typeof o!="symbol"&&w(!1,`bundle: file '${Ue(r,s)}' is not a placeholder`),Object.defineProperty(i,s,{get:Yu,enumerable:!0});return{...t,files:Object.freeze(i)}},vs=(r,e)=>{if(r===void 0&&e===void 0)return;let t=new Map;for(let i of[r,e])for(let[s,o]of Object.entries(i??{})){if(!Array.isArray(o))continue;let n=t.get(s);n===void 0&&t.set(s,n=new Set);for(let a of o)n.add(a)}return X([...t.keys()].toSorted().map(i=>[i,$r(t.get(i))]))};var Qu=(r,e)=>{if(r?.github===void 0||!al(r.github,e?.github))return;let t=Object.keys(fs).filter(i=>r[i]!==void 0&&(i==="github"||r[i]===e[i]));return X(t.map(i=>[i,r[i]]))},eh=r=>{if(!Fe(r)||r.root!==!0||Object.hasOwn(r,"directory"))return r;let{root:e,...t}=r;return t},Tl=r=>typeof r=="string"&&/^[\w.+@/~'!()*-]+$/u.test(r),ys={name:Tl,version:Tl},Nl={npm:ys,composer:ys,cargo:ys},th=(r,e)=>X(Object.keys(Nl).map(t=>{let[i,s]=[r?.[t],e?.[t]];return[t,i?.name!==void 0&&i.name===s?.name?X(Object.entries(i).filter(([o,n])=>n===s[o])):void 0]})),qe=class r{static VERSION=Ce;version=Ce;config;entries;modules;formats;imports;executable;reason;#e;get repo(){return this.#e}set repo(e){this.#e=xr(e)}#t;get package(){return this.#t}set package(e){this.#t=wr(e,Nl,"bundle package")}constructor({config:e={scope:"full"},entries:t,modules:i,formats:s,imports:o,executable:n,reason:a,repo:l,package:d,version:m=Ce}={}){w([Ll,Ce].includes(m)),w(["node_modules","full"].includes(e.scope)),this.version=m,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,this.repo=xr(l),this.package=d}get sources(){let e=new Map;for(let[t,{files:i}]of this.modules)for(let[s,o]of Object.entries(i))e.set(Ue(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(Ue(e,i))))return!0;return!1}static parse(e){return r.fromJSON(JSON.parse(e))}static fileKeyAt(e){let[t,i,s,o]=e;if(typeof i=="string"){if(e.length===2&&t==="sources"){let n=Ol(i);return kr(n.dir,n.rel,"bundle")}if(e.length===4&&(t==="sources"||t==="modules")&&s==="files"&&typeof o=="string")return kr(i,o,"bundle")}}static fromJSON(e,{contents:t=!0}={}){w(e.version===Ce||e.version===Ll),w(["node_modules","full"].includes(e.config?.scope));let i=_l(e.formats),s=new Map,o=new Set;if(e.version===Ce){let l=e.config.scope==="full";if(e.modules!==void 0){w(typeof e.modules=="object"&&e.modules!==null);for(let[d,m]of Object.entries(e.modules))w(He(d)),le(d,"bundle"),w(m?.name&&m.version&&m.files),s.set(d,gs(m,d,"bundle"))}if(l){w(e.sources&&typeof e.sources=="object");for(let[d,m]of Object.entries(e.sources))w(!He(d)),le(d,"bundle"),w(m?.name&&m.files),s.set(d,gs(m,d,"bundle"));e.entries!==void 0&&(o=bl(e.entries,"bundle"))}else w(e.entries===void 0),w(e.sources===void 0)}else{w(e.sources);for(let[l,d]of Object.entries(e.sources)){le(l,"bundle");let{dir:m,rel:p,name:u}=Ol(l);w(!Lt(m)&&!Lt(p)),s.has(m)||s.set(m,{name:u,version:null,files:Object.create(null)});let{files:f}=s.get(m);w(!Object.hasOwn(f,p),"bundle: duplicate file key '.' (v0 '' and '.')"),f[p]=d}}let n=Sr(s,"bundle",zl),a=$l(e.imports);if(!t)for(let[l,d]of s)s.set(l,Xu(l,d));return new r({version:e.version,config:e.config,entries:o,modules:s,formats:i,imports:a,executable:e.version===Ce?pl(e.executable,{what:"bundle",files:n,formats:i,scope:e.config.scope}):new Set,reason:Fe(e.reason)?e.reason:void 0,repo:eh(e.repo),package:e.package})}serialize(){Sr(this.modules,"bundle",zl);let{modules:e,sources:t}=Sl(this.modules,{skipEmpty:!0,what:"bundle"}),i=this.config.scope==="full",s={version:Ce,config:this.config};this.repo!==void 0&&(s.repo=this.repo),this.package!==void 0&&(s.package=this.package),i&&(s.entries=vl(this.entries,"bundle")),s.formats=wl(this.formats),s.imports=kl(this.imports);let o=ul(this.executable,{what:"bundle",modules:this.modules,formats:this.formats,scope:this.config.scope});return o!==void 0&&(s.executable=o),this.reason!==void 0&&(s.reason=vs(this.reason,void 0)),i&&(s.sources=t),s.modules=e,JSON.stringify(s,void 0,2)}withReason(e){let{version:t,config:i,entries:s,modules:o,formats:n,imports:a,executable:l,repo:d,package:m}=this,p=vs(this.reason,{[e]:[...this.sources.keys()]});return new r({version:t,config:i,entries:s,modules:o,formats:n,imports:a,executable:l,reason:p,repo:d,package:m})}merge(e){return w(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:Il(this.modules,e.modules,"bundle merge"),formats:Rl(this.formats,e.formats,"bundle merge"),imports:Cl(this.imports,e.imports,"bundle merge"),executable:El(this.executable,e.executable,e.modules,this.config.scope),reason:vs(this.reason,e.reason),repo:Qu(this.repo,e.repo),package:th(this.package,e.package)})}};var rh=new TextEncoder,V1=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});var ih=2;function _s(r){if(typeof r!="string")throw new TypeError(`utf8ByteLength expects a string, got ${typeof r}`);if(/[\u0100-\uFFFF]/.test(r))return rh.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<ih;i++)r.codePointAt(i)>127?(t++,s=0):s++;e.lastIndex=i}return t}var ws=new WeakMap,xs=new WeakMap,$s=new WeakMap;function Cr(r){if(r?.metadataOnly)return new Map;let e=r?.bundle??r?.json;if(e&&ws.has(e))return ws.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"&&(qe.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&&ws.set(e,t),t}function sh(r){let e=r?.bundle??r?.json;if(e&&xs.has(e))return xs.get(e);let t=new Map(Cr(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&&xs.set(e,t),t}var oh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function nh(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&&oh.indexOf(t.at(-1))&(i===2?15:3)?null:Math.floor(t.length*3/4)}function ah(r){return typeof r=="string"?_s(r):r?.format==="base64"?nh(r.data):null}function zt(r){if(r?.fileSizes)return r.fileSizes;let e=r?.bundle??r?.json;if(e&&$s.has(e))return $s.get(e);let t=new Map,i=sh(r),s=r?.kind==="stasis"?r.bundle?.sources.keys():r?.json?.sources;for(let o of s??[])t.set(o,ah(i.get(o)));return e&&$s.set(e,t),t}function Pl(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 lh=4,Bl=lh;function Dl(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 jl(r,e){if(![1,2,3,Bl].includes(r?.version)||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!==Bl,i=r.version===1,s=new Map,o=new Map,n=new Map;for(let d of r.files){if(!Array.isArray(d)||d.length!==4&&!(i&&d.length===3))throw new Error("Invalid bundle metadata file");let[m,p,u,f]=d;if(typeof m!="string"||o.has(m)||p!==null&&(!Number.isSafeInteger(p)||p<0)||u!==null&&(typeof u!="string"||!/^sha512-[A-Za-z0-9+/]{86}==$/u.test(u))||p===null&&u!==null||i&&p!==null&&u===null||f!=null&&(!Number.isSafeInteger(f)||f<0))throw new Error("Invalid bundle metadata file");o.set(m,p),u!==null&&s.set(m,u),f!=null&&n.set(m,f)}let a=new Set(r.unsized??[]);if(r.unsized!==void 0&&(i||!Array.isArray(r.unsized)||a.size!==r.unsized.length)||[...a].some(d=>typeof d!="string"||!o.has(d)||o.get(d)!==null))throw new Error("Invalid bundle metadata");let l={integrity:e,kind:r.kind,size:r.size,metadataOnly:!0,fileSizes:o,fileHashes:s,lineCounts:n,unsizedFiles:a,stale:t};if(r.kind==="stasis"){l.bundle=qe.parse(JSON.stringify(r.bundle));let d=l.bundle.sources;if(d.size!==o.size||[...d.keys()].some(p=>!o.has(p)))throw new Error("Invalid bundle metadata inventory");let m=l.bundle.formats;if(!i&&[...o].some(([p,u])=>s.has(p)!==(u!==null&&!qe.isResourceFormat(m.get(p)))))throw new Error("Invalid bundle metadata inventory");if([...a].some(p=>m.get(p)!=="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(d=>!o.has(d))||!Array.isArray(r.sourceSizes)||r.sourceSizes.length!==r.json.sources.length||r.sourceSizes.some(d=>d!==null&&(!Number.isSafeInteger(d)||d<0))||[...o].some(([d,m])=>s.has(d)!==(m!==null))||a.size>0)throw new Error("Invalid sourcemap inventory");l.json=r.json,l.sourceSizes=r.sourceSizes,l.namesCount=r.namesCount}if(r.codeStats===void 0)l.codeStats=rl(n,o);else{let d=r.codeStats,m=p=>Number.isSafeInteger(p)&&p>=0;if(!d||![d.files,d.lines,d.bytes].every(m)||!Array.isArray(d.languages)||d.languages.some(p=>!p||typeof p.key!="string"||typeof p.label!="string"||![p.files,p.lines,p.bytes].every(m)))throw new Error("Invalid bundle code stats");l.codeStats=d}return l}function ks(r,{packageDir:e=null}={}){if(e){if(e!=="."){let t=e.match(/(?:^|\/)node_modules\/(@[^/]+\/[^/]+|[^/]+)$/u);return t&&t[1]!==".pnpm"?t[1]:e}}else{let t=/(?:^|\/)(?:node_modules|dependencies)\/(@[^/]+\/[^/]+|[^/]+)/gu,i;for(;(i=t.exec(r))!==null;)if(i[1]!==".pnpm")return i[1]}return"__own__"}function Ss(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??[...zt(r)].filter(([,o])=>o!=null).map(([o])=>o));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 Ul(r,e){if(e.error)throw new Error(e.error);let t=Pl(e),i=e.kind==="stasis"?e.bundle?.formats:null,s=e.lineCounts??new Map([...Cr(e)].map(([a,l])=>[a,Dl(l)])),o=[...zt(e)].filter(([,a])=>a!=null).map(([a,l])=>({path:a,format:i?.get(a)??null,bytes:l,lines:s.get(a)??0,size:se(l),module:ks(a,{packageDir:t?.get(a)})})),n=[{id:"all",label:"All",filePaths:null},...[...Ss(e,o.map(a=>a.path))].map(([a,l])=>({id:`reason:${a}`,label:a,filePaths:[...l]}))];return{...r,files:o,reasons:n,size:se(e.size)}}function Fl(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:se(i.byteSize),files:null,reasons:[]}});return{repositories:[...e.values()],bundles:t,scans:[]}}async function Hl(r,e){let t=await Mi(r.id,{signal:e});e?.throwIfAborted();let i=jl(t,r.integrity);return Ul(r,i)}var ql=new Set(["overview","graph","treemap","compare","advisories","issues","code","search","terminal"]);var ch=/^\d+$/u;function dh(r){for(let e=0;e<r.length;e++){let t=r.codePointAt(e);if(t<32||t===127)return!0}return!1}var Vl=512;function ph(r){return typeof r=="string"&&r.length>0&&r.length<=Vl&&!dh(r)}function Gl(r){return ph(r)&&!ch.test(r)}var Wl=Object.freeze({manage:"/manage","manage-bundles":"/manage/bundle","manage-scans":"/manage/scans","manage-reports":"/manage/report","manage-repos":"/manage/repositories","admin-users":"/manage/users","manage-teams":"/manage/team","manage-import":"/manage/import","manage-links":"/manage/links","manage-deduplication":"/manage/deduplication","manage-history":"/manage/history"});function uh(r){if(!Gl(r)||r==="."||r==="..")return null;try{return`/finding/${encodeURIComponent(r)}`}catch{return null}}function Kl(r){if(!r)return null;if(r.view==="home")return"/";if(r.view==="workspace-reports"||r.view==="workspace-bundles")return/^[A-Za-z0-9_-]+$/u.test(r.teamSlug??"")?`/team/${r.teamSlug}/${r.view.slice(10)}`:null;if(r.view==="bundles"){if(!/^[A-Za-z0-9_-]+$/u.test(r.bundleSlug??"")||r.teamSlug!=null&&!/^[A-Za-z0-9_-]+$/u.test(r.teamSlug))return null;let i=r.bundleTab??"overview";return ql.has(i)?`${r.teamSlug?`/team/${r.teamSlug}`:"/manage"}/bundle/${r.bundleSlug}${i==="overview"?"":`/${i}`}`:null}if(Object.hasOwn(Wl,r.view)){let i=Wl[r.view];return r.view==="manage-deduplication"&&r.linkId?`${i}?report=${encodeURIComponent(r.linkId)}`:r.view==="manage-bundles"&&Number.isSafeInteger(r.createRepoId)&&r.createRepoId>0?`${i}?createRepo=${r.createRepoId}`:r.view==="manage-scans"&&r.scanMode==="link"?`${i}?mode=link`:r.view==="manage-scans"&&r.bundleId?`${i}?bundle=${encodeURIComponent(r.bundleId)}`:r.view==="manage-history"&&r.actor?`${i}?actor=${encodeURIComponent(r.actor)}`:i}if(!["findings","files"].includes(r.view)||!r.teamSlug||[r.teamSlug,r.reportSlug].some(i=>i!=null&&!/^[A-Za-z0-9_-]+$/u.test(i)))return null;let e=`/team/${encodeURIComponent(r.teamSlug)}`,t=r.reportSlug?`/report/${encodeURIComponent(r.reportSlug)}`:"";if(r.finding){let i=uh(r.finding.id);return r.view==="findings"&&i?`${e}${t}${i}`:null}return`${e}${t}${r.view==="files"?"/files":""}`}ve();function hh(r){let{data:e}=Nn(r);return e&&Zl(e)>0?e:null}function Zl(r){return(be(r)??[]).filter(e=>(Array.isArray(e)?e:[e]).some(t=>t&&typeof t=="object"&&ni(t,t.source??r.source))).length}function Jl(r,e){let t=(r.reports??[]).filter(n=>n.visible&&n.repoId!=null).flatMap(n=>{let a=hh(n.content??"");return a?[{id:n.id,filename:n.filename,repoIds:[n.repoId],repo:n.repoFullName,directory:n.repoDirectory,analyzer:n.analyzer,appFindings:Zl(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:se(n.byteSize)})),results:s},link:{repositories:[...i.values()].filter(n=>t.some(a=>a.repoIds.includes(n.id))),reports:t}}}S();Cs();B();function Xl(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 Ql(r,e){let t=e.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),i=r.filter(o=>!o.reset),s=i.filter(o=>t.every(n=>o.label.normalize("NFKC").toLocaleLowerCase().includes(n))).toSorted((o,n)=>o.label.localeCompare(n.label,void 0,{sensitivity:"base",numeric:!0}));return{pinned:r.filter(o=>o.reset),sections:[{label:null,options:s}],facets:[],showFacets:!1,count:s.length,total:i.length}}var Rs=class extends F{static properties={users:{attribute:!1},resetLabel:{type:String,attribute:"reset-label"}};static styles=[F.styles,z`.avatar{position:relative;overflow:hidden}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}`];constructor(){super(),this.users=[],this.resetLabel="",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")||e.has("resetLabel"))&&(this.options=[...this.resetLabel?[{value:"",label:this.resetLabel,reset:!0}]:[],...Xl(this.users)])}choices(){return Ql(this.options,this._query)}optionIcon(e){return e.initials?c`<span class="avatar" aria-hidden="true">${e.initials}${Ee()?h:Rr(e.value,c`<img alt="" loading="lazy" decoding="async" src="${`/api/avatar/${encodeURIComponent(e.value)}`}" @error="${t=>{t.currentTarget.hidden=!0}}">`)}</span>`:h}};customElements.get("user-selector")||customElements.define("user-selector",Rs);S();B();var ec=`:host{padding:0;container-type:normal}.alias-table{overflow-x:auto;padding-bottom:.5rem}table{width:100%;border-collapse:collapse;text-align:left}th,td{padding:.35rem .5rem;border-bottom:1px solid var(--border)}th{color:var(--muted);font-weight:500}td:not(.actions,.empty){overflow-wrap:anywhere}input{width:100%;min-width:7rem;padding:.3rem .45rem;border:1px solid var(--border);border-radius:.375rem;background:var(--bg);color:var(--text);font:inherit}.actions{white-space:nowrap;text-align:right}.actions .btn{min-height:1.75rem;padding:.2rem .55rem}.actions .btn+.btn{margin-left:.25rem}
|
|
267
|
+
`;var fh="/api/admin/repositories/aliases";async function tc(r="",e={}){let t=await x(`${fh}${r}`,{credentials:"same-origin",...e}),i=await t.json();if(!t.ok){let s={"alias-exists":"An alias already exists for this old repository and path. Edit that row instead.","bad-old-repo":"Enter the old repository as owner/name or a GitHub URL.","bad-directory":"Enter repository directories without parent segments, backslashes, or surrounding whitespace.","bad-repo":"Choose a connected repository.","no-alias":"This alias was removed. Refresh the list and try again."};throw new Error(s[i?.error]??`HTTP ${t.status}`)}return i}var Es=class extends T{static properties={repositories:{attribute:!1},_data:{state:!0},_edit:{state:!0},_error:{state:!0},_busy:{state:!0}};static styles=[$(N),$(ec)];constructor(){super(),this._data=null,this._edit=null,this._error=null,this._busy=!1}connectedCallback(){super.connectedCallback(),this._load()}updated(e){e.has("repositories")&&e.get("repositories")!==void 0&&(this.appState.invalidate(["repository-aliases"]),this._load())}async _load(){this._error=null,await this._loadCollection("repository-aliases","repository aliases",e=>tc("",{signal:e}),e=>{this._data=e})}_start(e=null){this._error=null,this._edit=e?{...e}:{id:null,oldRepo:"",oldPath:"",repoId:null,newPath:""}}async _mutate(e,t,i){if(!(this._busy||!this._csrf||this._role!=="admin")){this._busy=!0,this._error=null;try{await this.appState.mutate(()=>tc(t?`/${encodeURIComponent(t)}`:"",{method:e,headers:{"content-type":"application/json","x-csrf-token":this._csrf},...i?{body:JSON.stringify(i)}:{}}),["repository-aliases","workspace-import"]),this._edit=null,await this._load()}catch(s){this._error=String(s?.message??s)}finally{this._busy=!1}}}_save(){let{id:e,...t}=this._edit;return this._mutate(e?"PATCH":"POST",e,t)}_field(e,t,i){return c`<td><input type="text" aria-label="${t}" placeholder="${i}" .value="${this._edit[e]}" ?disabled="${this._busy}" @input="${s=>{this._edit={...this._edit,[e]:s.target.value}}}"></td>`}_editor(){let e=(this._data?.repos??[]).filter(t=>t.active!==!1).map(t=>({value:t.repoId,label:t.fullName}));return c`<tr>${this._field("oldRepo","Old repository","owner/repository")}${this._field("oldPath","Old path","Repository root")}<td><repository-selector label="New repository" placeholder="Choose repository…" .options="${e}" .value="${this._edit.repoId}" ?disabled="${this._busy}" @repository-change="${t=>{this._edit={...this._edit,repoId:t.detail.value}}}"></repository-selector></td>${this._field("newPath","New path","Repository root")}<td class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._edit.oldRepo.trim()||this._edit.repoId==null}" @click="${()=>{this._save()}}">${this._busy?"Saving\u2026":"Save"}</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>{this._edit=null,this._error=null}}">Cancel</button></td></tr>`}render(){let e=this._data?.aliases??[],t=this._data?.repos??[];return c`<section aria-label="Repository aliases"><div class="page-intro"><p class="intro">Map repository locations when importing new reports and bundles.</p><button type="button" class="btn" ?disabled="${this._busy||this._edit!=null||!this._data}" @click="${()=>this._start()}">Add alias</button></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div aria-busy="${this._loading}">${this._data===null?this._error?c`<button type="button" class="btn" @click="${()=>{this._load()}}">Try again</button>`:q("Loading repository aliases\u2026"):c`<div class="alias-table"><table><thead><tr><th>Old repository</th><th>Old path</th><th>New repository</th><th>New path</th><th><span class="sr-only">Actions</span></th></tr></thead><tbody>${e.map(i=>this._edit?.id===i.id?this._editor():c`<tr><td>${i.oldRepo}</td><td class="mono">${i.oldPath||"/"}</td><td>${t.find(s=>s.repoId===i.repoId)?.fullName??"Removed repository"}${t.find(s=>s.repoId===i.repoId)?.active===!1?" (inactive)":""}</td><td class="mono">${i.newPath||"/"}</td><td class="actions"><button type="button" class="btn" ?disabled="${this._busy||this._edit!=null}" @click="${()=>this._start(i)}">Edit</button> <button type="button" class="btn" ?disabled="${this._busy||this._edit!=null}" @click="${()=>{this._mutate("DELETE",i.id)}}">Delete</button></td></tr>`)} ${this._edit?.id===null?this._editor():h} ${e.length===0&&!this._edit?c`<tr><td colspan="5" class="empty">No repository aliases yet.</td></tr>`:h}</tbody></table></div>`}</div></section>`}};customElements.define("managed-repository-aliases",Es);function rc(r){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:r},bubbles:!0,composed:!0}))}function nc(r,e){return c`<span class="avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${Ee()?h:c`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" @error="${t=>t.currentTarget.classList.add("broken")}">`}</span>`}var gh=P(Hn),js=P(qn),ic=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>`,As=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>`,bh={admin:"Admin",manage:"Manager",triage:"Triage",view:"Viewer",none:"No access"},vh={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"},Is=class extends T{static styles=[$(va),$(N)];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">${U("manage",this._role,this.allowShare)}<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="${()=>rc("manage-history")}"><span class="page-icon" aria-hidden="true">${D("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 ${D("arrow")}</span></button>`}</div>`}_page([e,t,i,s]){return c`<button type="button" class="${`page page-${s}`}" @click="${()=>rc(e)}"><span class="page-top"><span class="page-icon" aria-hidden="true">${D(s)}</span><strong class="page-title">${t}</strong><span class="arrow" aria-hidden="true">${D("arrow")}</span></span> <span class="page-copy"><span>${i}</span></span></button>`}};customElements.define("managed-admin-home",Is);var Ms=class extends T{static properties={_page:{state:!0},_history:{state:!0},_total:{state:!0},_error:{state:!0},_filter:{state:!0},_query:{state:!0},_repo:{state:!0},_actor:{state:!0},_options:{state:!0}};static styles=[$(ya),$(N)];constructor(){super(),this._history=null,this._total=0,this._searchTimer=null,this._error=null,this._page=1,this._filter="all",this._query="",this._repo="",this._actor="",this._options={repos:[],users:[]},this._onActorFilter=e=>{let t=e.detail?.actor;if(typeof t!="string")return;let i=t.startsWith("user:")||t.startsWith("legacy:");this._query=i?"":t,this._filter="all",this._repo="",this._actor=i?t:"",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=this._actor,o=this._repo,n=`history:${JSON.stringify([e,t,i,o,s])}`;await this._loadCollection(n,"history",a=>ea(a,e,t,i,o,s),a=>{this._history=a.history,this._total=a.total,this._page=a.page,this._options=a.filters??{repos:[],users:[]}})}_search(e){this._query=e,clearTimeout(this._searchTimer),this._loadRequest?.abort(),this._loadRequest=null,this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},250)}_setRepo(e){return this._repo=e,this._load()}_setActor(e){return this._actor=e,this._load()}_clearContext(){return this._repo="",this._actor="",this._load()}_contextFilters(){let e=this._options.repos,t=this._options.users??[],i=[{value:"",label:"All repositories",special:!0,reset:!0},...this._repo&&!e.includes(this._repo)?[{value:this._repo,label:this._repo}]:[],...e.map(s=>({value:s,label:s}))];return c`<repository-selector label="Filter history by repository" .options="${i}" .value="${this._repo}" @repository-change="${s=>{this._setRepo(s.detail.value)}}"></repository-selector><user-selector label="Filter history by user" reset-label="All users" placeholder="${this._actor?"Selected user":"All users"}" .users="${t}" .value="${this._actor}" @user-change="${s=>{this._setActor(s.detail.value)}}"></user-selector><button type="button" class="btn" aria-label="Clear repository and user filters" ?disabled="${!this._repo&&!this._actor}" @click="${()=>{this._clearContext()}}">Clear selection</button>`}render(){let e=this._history??[],t=this._page,i=(t-1)*100;return c`<div class="wrap">${U("manage-history",this._role,this.allowShare)}<h1 class="sr-only">History</h1><div class="page-intro"><p class="intro">${this._role==="admin"?"Uploads, builds, 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 history…" .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 and builds</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> ${this._contextFilters()} <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 class="manage-list" aria-busy="${this._loading}">${this._history==null?this._error?h:q("Loading history\u2026"):e.length===0?c`<div class="history"><p class="empty">${this._query.trim()||this._filter!=="all"||this._repo||this._actor?"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(".manage-list")?.scrollTo({top:0})}_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">${Ls(e.at)}</span></div>`}};customElements.define("managed-admin-history",Ms);function Ls(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 sc(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 oc(r){return r?.lastActivityAt??r?.lastActivity??r?.lastWriteAt??r?.lastActiveAt}var zs=class extends T{static properties={_query:{state:!0},_users:{state:!0},_teams:{state:!0},_error:{state:!0}};static styles=[$(_a),$(N)];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([ta(e),Ni(e)]),([e,t])=>{this._users=e,this._teams=Array.isArray(t?.teams)?t.teams:[]})}_filteredUsers(){let e=this._query.trim().toLocaleLowerCase();return(this._users??[]).filter(t=>[t.name,t.login,t.role,...(this._teams??[]).filter(i=>i.members?.some(s=>s.userId===t.id)).map(i=>i.name)].filter(Boolean).join(" ").toLocaleLowerCase().includes(e))}render(){let e=this._filteredUsers();return c`<div class="wrap">${U("admin-users",this._role,this.allowShare)}<h1 class="sr-only">Users</h1><div class="page-intro"><p class="intro">Manage workspace access and roles.</p></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="${t=>{this._query=t.target.value}}"><span class="result-count" role="status">${this._users&&this._query.trim()?`${e.length} matching out of `:""}${this._users?.length??"\u2026"} users</span></div>${this._error?c`<p class="msg error" role="alert">Couldn't load users: ${this._error}</p>`:h}<div class="manage-list" aria-busy="${this._loading}">${this._users==null?this._error?h:q("Loading users\u2026"):this._list(e)}</div></div>`}_list(e){return this._users.length===0?c`<p class="msg">No users yet.</p>`:e.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">${e.map(t=>this._row(t))}</ul></div>${this._users.some(t=>t.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">${nc(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">${Ge(e.role,"manage")?c`<span class="team-access"><strong>${e.role==="admin"?"All reports":"Owned and team reports"}</strong><span class="team-perms"><span class="permission-granted">+ Deps</span><span class="permission-granted">+ Security</span></span></span>`:i.length===0?c`<span class="no-team">No team access</span>`:i.map(({team:s,member:o})=>c`<span class="team-access"><strong>${D("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="${sc(e.lastSeenAt)}">${Ls(e.lastSeenAt)}</span> <button type="button" class="activity-link" aria-label="${`Show activity by ${e.login}`}" @click="${()=>this._showActivity(e.id)}"><span class="last-activity" aria-label="${`Last activity ${sc(oc(e)).replace(/^Last seen /u,"")}`}">${Ls(oc(e))}</span></button> <span class="access"><select class="role" ?disabled="${t}" aria-label="${`Change ${e.login}\u2019s role`}" aria-description="${vh[e.role]??""}" @change="${s=>this._changeRole(e,s.target.value,s.target)}">${Re.map(s=>c`<option value="${s}" ?selected="${s===e.role}">${bh[s]}</option>`)}</select></span></li>`}async _changeRole(e,t,i){let s=e.role;if(t!==s){try{await this.appState.mutate(()=>ra(e.id,t,this._csrf),["users","teams","reports","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:`user:${e}`},bubbles:!0,composed:!0}))}};customElements.define("managed-admin-users",zs);var ac=D("repo"),Os=class extends T{static properties={_publicRepoOpen:{state:!0},_publicRepository:{state:!0},_publicRepoError:{state:!0},_addingPublic:{state:!0},_data:{state:!0},_error:{state:!0},_actionError:{state:!0},_scope:{state:!0},_showAll:{state:!0},_query:{state:!0},_organization:{state:!0},_loading:{state:!0},_busy:{state:!0},_connectingApp:{state:!0},_detail:{state:!0},_aliases:{state:!0},_impact:{state:!0},_impactLoading:{state:!0},_removeOpen:{state:!0},_acknowledge:{state:!0},_deleteTriage:{state:!0},_confirmName:{state:!0}};static styles=[$(wa),$(N)];constructor(){super(),this._publicRepoOpen=!1,this._publicRepository="",this._publicRepoError=null,this._addingPublic=!1,this._data=null,this._error=null,this._actionError=null,this._scope="connected",this._showAll=!1,this._query="",this._organization=null,this._loading=!0,this._busy=null,this._connectingApp=!1,this._detail=null,this._aliases=!1,this._impact=null,this._impactLoading=!1,this._impactFresh=!1,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._impactRequest=null}connectedCallback(){super.connectedCallback(),this._load()}disconnectedCallback(){super.disconnectedCallback(),this._impactRequest?.abort()}_repositoryKey(){return`repos:${JSON.stringify([this._scope,this._showAll])}`}async _load(e=!1){this._error=null;let{_scope:t,_showAll:i}=this;await this._loadCollection(this._repositoryKey(),"repositories",s=>ia(t,i,e,s),s=>{this._data=s,this._organization=this._repositoryChoices().activeFacet})}_open(e){this._impactRequest?.abort(),this._publicRepoOpen=!1,this._scope=e,this._showAll=!1,this._query="",this._organization=null,this._detail=null,this._aliases=!1,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._data=null,this._actionError=null,this._load()}_setShowAll(e){this._showAll=e,this._organization=null,this._data=null,this._load()}_search(e){this._query=e}_repositoryChoices(){let e=(this._data?.repositories??[]).map(t=>({value:t.id,label:t.fullName,repo:t}));return mr(e,this._query,this._organization,{includeSingletonOrganizations:!0})}_back(e=null){return c`<div 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._aliases?this._aliases=!1:this._open("connected")}}">Repositories</button> <span class="breadcrumb-separator" aria-hidden="true">›</span> ${e?c`<h1 class="breadcrumb-current">${e}</h1>`:h}</div>`}_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=>na(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);if(this._aliases)return this._aliasesPage();let e=this._scope==="connected",t=e?"Repositories":`Add ${this._scope} repository`,i=this._repositoryChoices();return c`<div class="wrap">${U("manage-repos",this._role,this.allowShare)} ${e?c`<h1 class="sr-only">${t}</h1>`:this._back(t)}<div class="page-intro"><p class="intro">${e?"Manage connected repositories and their settings.":this._scope==="installed"?this._showAll?"Showing all repositories the GitHub App can read.":"Showing installed repositories you can access on GitHub.":"Choose a public repository your GitHub account is involved with."}</p>${e?c`<div class="repository-actions"><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> ${this._role==="admin"&&this._data?.canAddAnyPublicRepository?c`<button type="button" class="btn" aria-expanded="${this._publicRepoOpen}" @click="${()=>this._openPublicRepository()}">${this._accessIcon("public")} Add a public repository</button>`:h}</div>`: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="${s=>this._search(s.target.value)}"></label> ${this._scope==="installed"?c`<label class="show-all"><input type="checkbox" role="switch" .checked="${this._showAll}" @change="${s=>this._setShowAll(s.target.checked)}"><span>Show all</span></label><label class="show-all-paper"><input type="checkbox" .checked="${this._showAll}" @change="${s=>this._setShowAll(s.target.checked)}"><span>Show all</span></label>`:h} ${e?c`<span class="result-count" role="status">${this._data&&(this._query.trim()||i.activeFacet!=null)?`${i.count} ${i.count===1?"repository":"repositories"} out of `:""}${this._data?.connectedCount??"\u2026"} connected</span>`:c`<button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>{this._load(!0)}}">Refresh</button>`}</div>${e&&this._publicRepoOpen&&this._role==="admin"&&this._data?.canAddAnyPublicRepository?this._publicRepositoryForm():h} ${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} ${!e&&this._data?c`<p class="repository-count" role="status">${i.count}${i.count===i.total?"":` of ${i.total}`} ${i.total===1?"repository":"repositories"}</p>`:h}<div class="manage-list"><div aria-busy="${this._loading}">${this._body(i)}</div>${e&&this._role==="admin"?c`<div class="aliases-link"><button type="button" class="btn" @click="${()=>{this._publicRepoOpen=!1,this._actionError=null,this._aliases=!0}}">Aliases</button></div>`:h}</div></div>`}_aliasesPage(){return c`<div class="wrap">${U("manage-repos",this._role,this.allowShare)} ${this._back("Aliases")}<div class="manage-list"><managed-repository-aliases .session="${this.session}" .repositories="${this._data?.repositories}"></managed-repository-aliases></div></div>`}_body(e){return this._data?c`${this._data.tokenMissing&&!this._showAll&&this._scope!=="connected"?c`<p class="msg">Log out and back in to refresh your GitHub membership access.</p>`:h}<div class="repository-browser">${e.showFacets?c`<nav class="organization-list" aria-label="Filter by organization"><button type="button" class="organization" aria-pressed="${e.activeFacet==null}" @click="${()=>{this._organization=null}}"><span class="organization-name">All organizations</span><span class="organization-count">${e.total}</span></button> ${e.facets.map(t=>c`<button type="button" class="organization" aria-pressed="${e.activeFacet===t.value}" @click="${()=>{this._organization=t.value}}"><span class="organization-name" data-tooltip-truncated data-tooltip="${t.name}">${t.name}</span><span class="organization-count">${t.count}</span></button>`)}</nav>`:h}<div class="repo-results">${e.sections.map(t=>c`<section class="repo-group" aria-label="${t.label??"Repositories"}">${t.label?c`<h2 class="owner-head"><span class="owner-icon" aria-hidden="true">${t.label[0]??"?"}</span>${t.label}</h2>`:h}<ul class="repos">${t.options.map(i=>this._row(i.repo,t.organization?i.name:i.label))}</ul></section>`)} ${e.count?h:c`<div class="empty"><strong>${e.total?"No matching repositories":this._scope==="connected"?"No connected repositories yet":`No ${this._scope} repositories available`}</strong><p>${e.total?"Try a different search or organization.":this._scope==="connected"?"Add an installed or public repository to get started.":this._scope==="installed"?this._showAll?"Install the GitHub App, then refresh this list.":"No installed repositories match your GitHub access. Turn on Show all to browse every installation.":"Public repositories associated with your GitHub account will appear here."}</p></div>`}</div></div>`:this._error?h:q("Loading repositories\u2026")}_openPublicRepository(){this._publicRepoOpen=!0,this._publicRepoError=null,this.updateComplete.then(()=>this.renderRoot?.querySelector("#public-repository")?.focus())}_publicRepositoryForm(){return c`<form class="public-repository-form" aria-label="Add a public repository" @submit="${e=>{e.preventDefault(),this._addPublicRepository()}}"><label class="confirm-field" for="public-repository"><span>Public GitHub repository</span> <input id="public-repository" class="confirm-name" type="text" placeholder="owner/repo or https://github.com/owner/repo" autocomplete="off" required .value="${this._publicRepository}" ?disabled="${this._addingPublic}" @input="${e=>{this._publicRepository=e.target.value}}"></label><div class="dialog-actions"><button type="button" class="btn" ?disabled="${this._addingPublic}" @click="${()=>{this._publicRepoOpen=!1}}">Cancel</button><button type="submit" class="btn" ?disabled="${this._addingPublic||!this._publicRepository.trim()}">${this._addingPublic?"Adding\u2026":"Add repository"}</button></div>${this._publicRepoError?c`<p class="msg error" role="alert">${this._publicRepoError}</p>`:h}</form>`}async _addPublicRepository(){if(!(this._addingPublic||!this._publicRepository.trim())){this._addingPublic=!0,this._publicRepoError=null;try{await this.appState.mutate(()=>oa(this._publicRepository.trim(),this._csrf),["repos","reports","bundles","teams","users","history","scan-sources"]),this._publicRepoOpen=!1,this._publicRepository="",await this._load()}catch(e){this._publicRepoError=e?.message??String(e)}finally{this._addingPublic=!1}}}_row(e,t){let i=`${this._accessLabel(e)}${this._scope==="connected"&&e.active===!1?" \xB7 Deactivated":""}`,s=c`${ac}<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){let t=e.visibility==="public"?"Public":e.visibility==="internal"?"Internal":e.private?"Private":null,i=e.installed?"GitHub App":"GitHub";return t?`${t} \xB7 ${i}`:i}_connectAppButton(e){return e.installed?h:c`<button type="button" class="btn connect-app" aria-label="${`Connect GitHub App to ${e.fullName}`}" ?disabled="${this._busy!=null}" @click="${()=>{this._connectApp(e)}}">${this._connectingApp&&this._busy===e.id?"Connecting\u2026":"Connect GitHub App"}</button>`}async _connectApp(e){if(!(this._busy!=null||e.installed)){this._busy=e.id,this._connectingApp=!0,this._actionError=null;try{let t=await this.appState.mutate(()=>aa(e.id,this._csrf),["repos","history","scan-sources"]);if(!this.isConnected)return;if(!t.connected){globalThis.location.assign(t.installUrl);return}this._detail?.id===e.id&&(this._detail={...this._detail,installed:!0}),this._data&&(this._data={...this._data,repositories:this._data.repositories.map(i=>i.id===e.id?{...i,installed:!0}:i)}),await this._load()}catch(t){this._actionError=`Couldn't connect ${e.fullName}: ${t?.message??t}`}finally{this._busy=null,this._connectingApp=!1}}}_detailPage(e){let t=e.active!==!1,i=this._impact?.reports??[],s=this._impact?.bundles??[];return c`<div class="wrap">${U("manage-repos",this._role,this.allowShare)}<div class="head">${this._back()}<h1>${e.fullName}</h1></div><p class="intro ui-hint">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> ${this._connectAppButton(e)} ${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&&!this._connectingApp?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>${tt(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}}"><span>I understand this permanently deletes the repository connection${s?", reports, and bundles":""}.</span></label> ${(this._impact?.triageCount??0)>0?c`<label class="confirm-line"><input type="checkbox" .checked="${this._deleteTriage}" @change="${n=>{this._deleteTriage=n.target.checked}}"><span>Also delete ${this._impact.triageCount} triage entr${this._impact.triageCount===1?"y":"ies"} belonging only to this repository.</span></label>`:h} ${s?c`<label class="confirm-field"><span>Type <strong>${e.fullName}</strong> to confirm.</span><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(()=>sa(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(()=>la(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",Os);function Ts(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 lc(r){return[{value:null,label:"No repository",special:!0},...r.map(e=>({value:e.repoId,label:e.fullName}))]}function cc(r,e,t,i,s){let o=c`<span class="ui-hint">${r}: </span><span class="location-metadata-value" data-tooltip-truncated data-tooltip="${e}">${e}</span>`;return i?c`<button type="button" class="location-metadata" aria-label="${`Use ${t} from ${r}: ${e}`}" ?disabled="${s}" @click="${i}">${o}</button>`:c`<span class="location-metadata">${o}</span>`}var Ns=class extends T{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},_locationOrigin:{state:!0},_locationOriginError:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0}};static styles=[$(ur),$(Di),$(N),$(Bi)];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._locationOrigin=null,this._locationOriginError=null,this._locationOriginRequest=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._teardownDrop=null,this._queue=[],this._localImport=new kt(this,"report",e=>Pi(this,e,t=>zi(t,this._csrf),["reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ct(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._cancelPreview(),this._closeLocation()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("reports","reports",ca,t=>{this._data=t,this._preview&&!t.reports?.some(i=>i.id===this._preview)&&this._cancelPreview(),this._locationReport&&!t.reports?.some(i=>i.id===this._locationReport)&&this._closeLocation()})}render(){return c`${this._dragOver?c`<div class="dropzone">Drop reports to upload</div>`:h}<div class="wrap">${U("manage-reports",this._role,this.allowShare)}<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">${D("upload")}</span><span class="drop-copy"><strong>Upload reports</strong><span>Drop files anywhere on this page.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>St(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></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(o=>[o.filename,tt(o.filename),o.repoFullName,o.repoDirectory,o.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(t)&&(this._visibility==="all"||!!o.visible==(this._visibility==="visible"))),s=`${t||this._visibility!=="all"?`${i.length} of `:""}${e.length} ${e.length===1?"report":"reports"}`;return c`<div class="collection-toolbar" role="search"><input type="search" aria-label="Search reports" placeholder="Search reports or repositories…" .value="${this._query}" @input="${o=>{this._query=o.target.value}}"><select aria-label="Report visibility" .value="${this._visibility}" @change="${o=>{this._visibility=o.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":s}</span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div class="manage-list" aria-busy="${this._loading}">${this._data==null?this._error?h:q("Loading reports\u2026"):i.length>0?c`<div class="report-list"><div class="report-list-head" aria-hidden="true"><span class="report-heading">Report</span><span>Repository</span><span>Uploaded by</span><span>Date</span><span class="size-heading">Size</span><span>Visibility</span><span class="actions-heading">Actions</span></div><ul class="reports">${i.map(o=>this._row(o))}</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=tt(e.filename),i=e.analyzer??e.source??e.producer??"default",s=Ai[i]??Ai.default,o=e.repoEmbedded!==!0&&e.canChangeRepo!==!1,n=e.repoEmbedded===!0||e.repoId!=null,a=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",l=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="${`report${e.visible===!1?" content-hidden":""}`}"><div class="report-main"><span class="report-mark" aria-hidden="true">${P(s)}</span> <span class="report-name" data-tooltip-truncated data-tooltip="${t}">${t}</span> <span class="report-location" data-tooltip-truncated data-tooltip="${a}">${a}</span> <span class="report-meta report-uploader" data-tooltip-truncated data-tooltip="${e.uploadedByLogin??"Uploader removed"}">${e.uploadedByLogin??"Uploader removed"}</span> <span class="report-meta report-date">${l}</span> <span class="report-meta report-size">${Ts(e.byteSize)}</span> <span class="${`status ${e.visible?"visible":"hidden"}`}">${e.visible?"Visible":"Hidden"}</span> <span class="report-actions">${o?c`<button type="button" class="action" data-tooltip="Set repository location" aria-label="${`Set location for ${t}`}" @click="${()=>this._openLocation(e)}">${D("repo")}</button>`:c`<span class="action-spacer"></span>`} <button type="button" class="action" aria-label="${`Preview ${t}`}" aria-expanded="${this._preview===e.id}" @click="${()=>{this._togglePreview(e)}}">${D("preview")}</button> <button type="button" class="action" data-tooltip="${e.visible?"Hide from teams":n?"Make visible to teams":"Assign a repository before publishing"}" aria-label="${`${e.visible?"Hide":"Make visible"} ${t}`}" ?disabled="${e.canChangeRepo===!1||!n&&!e.visible}" @click="${()=>{this._setVisible(e,!e.visible)}}">${D(e.visible?"hide":"show")}</button> <a class="action" aria-label="${`Download ${t}`}" href="${`/api/admin/reports/${encodeURIComponent(e.id)}`}">${D("download")}</a> <button type="button" class="action danger" aria-label="${`Delete ${t}`}" ?disabled="${e.canChangeRepo===!1}" @click="${()=>this._delete(e)}">${js}</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._closeLocation(),this._locationReport=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null,this._loadLocationOrigin(e))}_closeLocation(){this._locationOriginRequest?.abort(),this._locationOriginRequest=null,this._locationReport=null,this._locationOrigin=null,this._locationOriginError=null}async _loadLocationOrigin(e){this._locationOriginRequest?.abort();let t=new AbortController;this._locationOriginRequest=t,this._locationOrigin=void 0,this._locationOriginError=null;try{let i=await ha(e.id,AbortSignal.any([t.signal,this.appState.sessionController.signal]));if(this._locationOriginRequest!==t)return;i?.repoId!=null&&this._data&&(this._data={...this._data,repos:[...(this._data.repos??[]).filter(s=>s.repoId!==i.repoId),{repoId:i.repoId,fullName:i.github}]}),this._locationOrigin=typeof i?.github=="string"&&i.github?{github:i.github,repoId:i.repoId??null,directory:typeof i.directory=="string"?i.directory||"/":null}:null}catch(i){if(this._locationOriginRequest!==t)return;this._locationOrigin=null,i?.name!=="AbortError"&&(this._locationOriginError="Couldn't load the report\u2019s suggested location.")}}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[],i=this._locationOrigin,s=i?.repoId!=null&&t.find(n=>n.repoId===i.repoId),o=(n,a,l)=>cc("report",n,a,l,this._locationBusy);return c`<div class="location-editor"><div class="location-field"><div class="location-field-header"><span class="ui-hint">Repository</span>${i?o(i.github,"repository",s?()=>{this._locationRepo=s.repoId,i.directory!=null&&(this._locationDirectory=i.directory)}:null):h}</div><repository-selector label="Repository for report" .options="${lc(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${n=>{this._locationRepo=n.detail.value}}"></repository-selector></div><div class="location-field"><div class="location-field-header"><label for="${`report-dir-${e.id}`}">Directory (optional)</label>${i?o(i.directory??"Directory not specified","directory",i.directory==null?null:()=>{this._locationDirectory=i.directory}):h}</div><input id="${`report-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" ?disabled="${this._locationBusy}" @input="${n=>{this._locationDirectory=n.target.value}}"></div><div class="location-actions"><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>this._closeLocation()}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>{this._saveLocation(e)}}">Save</button></div>${this._locationOriginError?c`<p class="location-origin" role="status">${this._locationOriginError} <button type="button" class="origin-retry" @click="${()=>{this._loadLocationOrigin(e)}}">Retry</button></p>`:h}</div>`}async _saveLocation(e){if(!this._locationBusy){this._locationBusy=!0,this._error=null;try{await this.appState.mutate(()=>ua(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),["reports","repo-impact","history","scan-sources"]),this._closeLocation(),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 x(`/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?`
|
|
268
|
+
\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(()=>pa(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){await Rt(this,e,t=>zi(t,this._csrf),["reports","repo-impact","history","scan-sources"])}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${tt(e.filename)}\u201D? This can't be undone.`)){this._error=null;try{await this.appState.mutate(()=>ma(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",Ns);var yh=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>`,Ps=class extends T{static properties={createRepoId:{attribute:!1},installTooltips:{attribute:!1},localImportSource:{attribute:!1},_query:{state:!0},_visibility:{state:!0},_visibilityBusy:{state:!0},_creating:{state:!0},_data:{state:!0},_locationBundle:{state:!0},_locationOrigin:{state:!0},_locationOriginError:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[$(xa),$(Di),$(N),$(Bi)];constructor(){super(),this._query="",this._visibility="all",this._visibilityBusy=null,this._creating=!1,this._data=null,this._error=null,this._busy=!1,this._locationBundle=null,this._locationOrigin=null,this._locationOriginError=null,this._locationOriginRequest=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._dragOver=!1,this._teardownDrop=null,this._queue=[],this._localImport=new kt(this,"bundle",e=>Pi(this,e,t=>Ti(t,this._csrf),["bundles","reports","repo-impact","history","scan-sources"]))}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ct(this,e=>{this._creating||this._upload(e)},e=>{this._dragOver=!this._creating&&e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._closeLocation()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("bundles","bundles",Oi,t=>{this._data=t,this._locationBundle&&!t.bundles?.some(i=>i.id===this._locationBundle)&&this._closeLocation()})}_showCreate(e){if(!e&&this.createRepoId!=null){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-bundles"},bubbles:!0,composed:!0}));return}this._creating=e,this._dragOver=!1,e||this.updateComplete.then(()=>this.renderRoot.querySelector(".create-bundle-action")?.focus())}willUpdate(e){e.has("createRepoId")&&(this._creating=this.createRepoId!=null)}render(){return this._creating?c`<div class="wrap">${U("manage-bundles",this._role,this.allowShare)}<div 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 bundles" @click="${()=>this._showCreate(!1)}">Bundles</button> <span class="breadcrumb-separator" aria-hidden="true">›</span><h1 class="breadcrumb-current">Create a bundle</h1></div><managed-create-bundle .initialRepoId="${this.createRepoId??null}" .installTooltips="${this.installTooltips}" .createBundle="${this._csrf?(e,t)=>this.appState.mutate(()=>da(e,this._csrf,t),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"]):void 0}" @bundle-created="${e=>this.dispatchEvent(new CustomEvent("managed-bundle-open",{detail:e.detail,bubbles:!0,composed:!0}))}"></managed-create-bundle></div>`:c`${this._dragOver?c`<div class="dropzone">Drop bundles to upload</div>`:h}<div class="wrap">${U("manage-bundles",this._role,this.allowShare)}<h1 class="sr-only">Bundles</h1><div class="page-intro"><p class="intro">Source bundles for your repositories.</p><div class="bundle-actions">${this._localImport.renderAction()}<button type="button" class="local-import-toggle create-bundle-action" ?disabled="${!this._data}" @click="${()=>this._showCreate(!0)}">Create</button></div></div>${this._localImport.renderPanel(this._busy||!this._csrf)}<section class="drop-card" aria-label="Upload bundles"><span class="drop-icon" aria-hidden="true">${D("upload")}</span><span class="drop-copy"><strong>Upload source bundles</strong><span>Drop source archives anywhere on this page.</span></span> <button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>St(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></section>${this._body()}</div>`}_body(){let e=Array.isArray(this._data?.bundles)?this._data.bundles:[],t=this._query.trim().toLocaleLowerCase(),i=e.filter(l=>[l.filename,l.repoFullName,l.repoDirectory,l.kind,l.provenance==="build"?"built":null,l.uploadedByLogin].filter(Boolean).join(" ").toLocaleLowerCase().includes(t)&&(this._visibility==="all"||l.visible!==!1==(this._visibility==="visible"))),s=i.filter(l=>l.repoId==null).length,o=i.reduce((l,d)=>l+(Number.isFinite(d.byteSize)?d.byteSize:0),0),n=`${t||this._visibility!=="all"?`${i.length} of `:""}${e.length} ${e.length===1?"bundle":"bundles"}`,a=Map.groupBy(i,l=>l.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="${l=>{this._query=l.target.value}}"> <select aria-label="Bundle visibility" .value="${this._visibility}" @change="${l=>{this._visibility=l.target.value}}"><option value="all">All bundles</option><option value="visible">Visible to teams</option><option value="hidden">Hidden bundles</option></select> <span class="summary result-count" role="status"><span>${this._data==null?"\u2026 bundles":n}</span><span>${this._data==null?"\u2026":Ts(o)}</span> ${this._data==null||s?c`<span class="unassigned">${this._data==null?"\u2026 unattached":`${s} unattached`}</span>`:h}</span></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div class="manage-list" aria-busy="${this._loading}">${this._data==null?this._error?h:q("Loading bundles\u2026"):i.length>0?c`<div class="bundle-groups">${[...a].toSorted(([l],[d])=>l==="Unattached"?-1:d==="Unattached"?1:l.localeCompare(d)).map(([l,d])=>c`<section class="bundle-group"><div class="bundle-group-head"><strong>${l}</strong><span>${d.length} ${d.length===1?"bundle":"bundles"}</span></div><ul class="bundles">${d.map(m=>this._row(m))}</ul></section>`)}</div>`:c`<div class="empty"><strong>${e.length>0?"No matching bundles":"No bundles uploaded yet"}</strong><p>${e.length>0?"Try a different search or visibility filter.":"Drop source archives here or browse files above."}</p></div>`}</div>`}_row(e){let t=e.visible!==!1,i=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",s=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return c`<li class="${`bundle-row${t?"":" content-hidden"}`}"><span class="identity"><span class="bundle-icon" aria-hidden="true">${e.kind==="stasis"?c`<img src="./stasis.svg" width="16" height="16" alt="">`:yh}</span> <button type="button" class="filename bundle-open" data-tooltip-truncated data-tooltip="${e.filename}" @click="${()=>this.dispatchEvent(new CustomEvent("managed-bundle-open",{detail:e,bubbles:!0,composed:!0}))}">${e.filename}</button> ${e.provenance==="build"?c`<span class="bundle-provenance" data-tooltip="Generated on this server from the repository">Built</span>`:h} </span><span class="meta bundle-uploader" data-tooltip-truncated data-tooltip="${e.uploadedByLogin?`@${e.uploadedByLogin}`:""}">${e.uploadedByLogin?`@${e.uploadedByLogin}`:""}</span> <span class="meta bundle-date">${s}</span> <span class="meta bundle-size">${Ts(e.byteSize)}</span> <span class="bundle-location" data-tooltip-truncated data-tooltip="${i}">${i}</span> <span class="${`status ${t?"visible":"hidden"}`}">${t?"Visible":"Hidden"}</span> <span class="actions">${e.canChangeRepo===!1?h:c`<button type="button" class="action" aria-label="${`Set location for ${e.filename}`}" data-tooltip="Set repository location" ?disabled="${this._locationBusy}" @click="${()=>this._openLocation(e)}">${D("repo")}</button>`} <button type="button" class="action" aria-label="${`${t?"Hide":"Make visible"} ${e.filename}`}" data-tooltip="${t?"Hide from teams":e.repoId==null?"Assign a repository before publishing":"Make visible to teams"}" ?disabled="${this._visibilityBusy!=null||e.canChangeRepo===!1||!t&&e.repoId==null}" @click="${()=>{this._setVisible(e,!t)}}">${D(t?"hide":"show")}</button> <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":h}" @click="${()=>this._delete(e)}">${js}</button> </span>${this._locationBundle===e.id?this._locationEditor(e):h}</li>`}async _setVisible(e,t){if(!(this._visibilityBusy!=null||e.canChangeRepo===!1)){this._visibilityBusy=e.id,this._error=null;try{await this.appState.mutate(()=>ga(e.id,t,this._csrf),["bundles","teams","history","scan-sources"]),e.visible=t,this.requestUpdate(),await this._load()}catch(i){this._error=`Couldn't change bundle visibility: ${String(i?.message??i)}`}finally{this._visibilityBusy=null}}}_openLocation(e){this._locationBusy||e.canChangeRepo===!1||(this._closeLocation(),this._locationBundle=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null,e.kind==="stasis"&&this._loadLocationOrigin(e))}_closeLocation(){this._locationOriginRequest?.abort(),this._locationOriginRequest=null,this._locationBundle=null,this._locationOrigin=null,this._locationOriginError=null}async _loadLocationOrigin(e){this._locationOriginRequest?.abort();let t=new AbortController;this._locationOriginRequest=t,this._locationOrigin=void 0,this._locationOriginError=null;try{let i=await Yn(e.id,{signal:t.signal});if(this._locationOriginRequest!==t)return;i?.repoId!=null&&this._data&&(this._data={...this._data,repos:[...(this._data.repos??[]).filter(s=>s.repoId!==i.repoId),{repoId:i.repoId,fullName:i.github}]}),this._locationOrigin=typeof i?.github=="string"&&i.github?{github:i.github,directory:typeof i.directory=="string"?i.directory:i.root===!0?"/":null}:null}catch(i){if(this._locationOriginRequest!==t)return;this._locationOrigin=null,i?.name!=="AbortError"&&(this._locationOriginError="Couldn't load the bundle\u2019s suggested location.")}}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[],i=this._locationOrigin,s=Xe({repo:i})?.toLowerCase(),o=s&&t.find(a=>a.fullName.toLowerCase()===s),n=(a,l,d)=>cc("metadata",a,l,d,this._locationBusy);return c`<div class="location-editor"><div class="location-field"><div class="location-field-header"><span class="ui-hint">Repository</span>${i?n(i.github,"repository",o?()=>{this._locationRepo=o.repoId,i.directory!=null&&(this._locationDirectory=i.directory)}:null):h}</div><repository-selector label="Repository for bundle" .options="${lc(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${a=>{this._locationRepo=a.detail.value}}"></repository-selector></div><div class="location-field"><div class="location-field-header"><label for="${`bundle-dir-${e.id}`}">Directory (optional)</label>${i?n(i.directory??"Directory not specified","directory",i.directory==null?null:()=>{this._locationDirectory=i.directory}):h}</div><input id="${`bundle-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" ?disabled="${this._locationBusy}" @input="${a=>{this._locationDirectory=a.target.value}}"></div><div class="location-actions"><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>this._closeLocation()}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy}" @click="${()=>{this._saveLocation(e)}}">Save</button></div>${this._locationOriginError?c`<p class="location-origin" role="status">${this._locationOriginError} <button type="button" class="origin-retry" @click="${()=>{this._loadLocationOrigin(e)}}">Retry</button></p>`:h}</div>`}async _saveLocation(e){if(!(this._locationBusy||e.canChangeRepo===!1)){this._locationBusy=!0,this._error=null;try{await this.appState.mutate(()=>ba(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),["bundles","teams","repo-impact","history","scan-sources"]),this._closeLocation(),await this._load({preserveError:!0})}catch(t){this._error=`Couldn't set bundle location: ${String(t?.message??t)}`}finally{this._locationBusy=!1}}}async _upload(e){await Rt(this,e,t=>Ti(t,this._csrf),["bundles","bundle-metadata","reports","repo-impact","history","scan-sources"])}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(()=>fa(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",Ps);var Bs=class extends T{static properties={selection:{attribute:!1},_source:{state:!0},_error:{state:!0}};static styles=$(N);constructor(){super(),this._loadModels=(e,t)=>this.appState.load("models","scan models",i=>ot(i,x),{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([x("/api/admin/reports",{signal:i,credentials:"same-origin"}),x("/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 x(`/api/admin/reports/${encodeURIComponent(a.id)}`,{signal:i,credentials:"same-origin"});if(!l.ok)throw new Error(`Report ${tt(a.filename)}: HTTP ${l.status}`);return{...a,content:await l.text()}})),Jl(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",Oi,e=>{this._source=Fl(e)})}render(){return c`<div class="wrap">${U("manage-scans",this._role,this.allowShare)} ${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 .selection="${this.selection}" .source="${this._source}" .sourceLoading="${this._loading&&this._source==null}" .loadBundle="${Hl}" .loadModels="${this._loadModels}" .loadReportSources="${this._loadReportSources}" .createBundleHref="${e=>Number.isSafeInteger(e)&&e>0?Kl({view:"manage-bundles",createRepoId:e}):null}"></deepview-scan-page></div>`}};customElements.define("managed-admin-scans",Bs);var Ds=class extends T{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_renamingId:{state:!0},_repoChoices:{state:!0},_memberChoices:{state:!0}};static styles=[$($a),$(N)];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",Ni,t=>{this._data=t})}async _do(e){if(!this._busy){this._busy=!0,this._error=null;try{await this.appState.mutate(e,["teams","users","reports","history"])}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load({preserveError:!0})}}}render(){return c`<div class="wrap">${U("manage-teams",this._role,this.allowShare)}<h1 class="sr-only">Teams</h1><div class="page-intro"><p class="intro">Manage repository and finding access for each team.</p><span class="result-count">${this._data?.teams?.length??"\u2026"} teams</span></div><div class="create-team"><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()}">${As} Create team</button><p class="access-note">All members can view standard findings. Set dependencies and security access per member.</p></div><div class="manage-list" 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 q("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>${e.hidden?c`<span class="muted ui-hint">Hidden</span>`:h} <span class="team-actions"><button class="btn" aria-label="${`${e.hidden?"Restore":"Hide"} ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>ie("/api/admin/teams/set-hidden",this._csrf,{teamId:e.id,hidden:!e.hidden}))}">${e.hidden?"Restore":"Hide"}</button> <button class="icon-btn" aria-label="${`Rename ${e.name}`}" ?disabled="${this._busy}" @click="${()=>{this._renamingId=e.id}}">${gh}</button> <button class="icon-btn danger" aria-label="${`Delete ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._deleteTeam(e)}">${js}</button></span>`}</div>${e.hidden?c`<p class="team-hidden-note muted ui-hint">Hidden from everyone's sidebar. Access grants and public links are disabled until this team is restored.</p>`:h}<div class="team-body"><div class="sub"><h3 class="sub-title">Repositories <span class="count">${e.repos.length}</span></h3>${e.repos.length===0?c`<p class="muted ui-hint">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>${e.members.length===0?c`<p class="muted ui-hint">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">${ac} <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(()=>ie("/api/admin/teams/remove-repo",this._csrf,{teamId:e.id,repoId:t.repoId,path:t.path??null}))}">${ic}</button></li>`}_addRepoRow(e){let t=Array.isArray(this._data.repos)?this._data.repos:[];return t.length===0?c`<p class="muted ui-hint">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)}">${As} Add</button></div>`}_memberRow(e,t){let i=Array.isArray(this._data.permissions)?this._data.permissions:[],s=this._data.users?.some(o=>o.id===t.userId&&Ge(o.role,"manage"));return c`<li class="member-row"><span class="member">${nc(t.userId,t.login)}<span class="ln">${t.login}</span></span> <span class="perms">${i.map(o=>c`<label class="perm"><input type="checkbox" .checked="${s||t[o]===!0}" ?disabled="${this._busy||s}" aria-label="${`${Br[o]??o} access for ${t.login} in ${e.name}`}" @change="${n=>this._togglePerm(e,t,o,n.target.checked)}"> ${Br[o]??o}</label>`)} </span><button class="icon-btn danger" aria-label="${`Remove ${t.login} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>ie("/api/admin/teams/remove-member",this._csrf,{teamId:e.id,userId:t.userId}))}">${ic}</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)}">${As} Add</button></div>`}_create(){let e=this.renderRoot.querySelector(".new-name"),t=e?.value.trim();t&&this._do(async()=>{await ie("/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(()=>ie("/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(()=>ie("/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 ie("/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 ie("/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){if(this._data.users?.some(n=>n.id===t.userId&&Ge(n.role,"manage")))return;let o={};for(let n of this._data.permissions??[])o[n]=t[n]===!0;o[i]=s,this._do(()=>ie("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t.userId,...o}))}};customElements.define("managed-admin-teams",Ds);S();B();var Er=`.link-team{margin-top:1.5rem}.link-team h2{margin:0 0 .5rem;font-size:1rem;font-weight:600}.link-table{overflow-x:auto}table{width:100%;border-collapse:collapse;text-align:left;font-size:.8rem}th{color:var(--muted);font-weight:500}th,td{padding:.6rem .65rem;border-bottom:1px solid var(--border);white-space:nowrap}th:first-child,td:first-child{padding-left:0}th:last-child,td:last-child{padding-right:0;text-align:right}
|
|
269
|
+
`;async function Mh(r){let e=await x("/api/admin/links",{signal:r,credentials:"same-origin"});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();if(!Array.isArray(t?.shares))throw new Error("No public links returned");return t}var Ws=class extends T{static properties={_data:{state:!0},_error:{state:!0}};static styles=[$(N),$(Er)];constructor(){super(),this._data=null,this._error=null}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null,await this._loadCollection("links","public links",Mh,e=>{this._data=e})}async _edit(e){let{openManagedShareDialog:t}=await Promise.resolve().then(()=>(Gs(),Vs));await t({id:e.teamId,name:e.teamName},e.id,this.session),this.isConnected&&await this._load()}_groups(){let e=new Map;for(let t of this._data?.shares??[])e.has(t.teamId)||e.set(t.teamId,{name:t.teamName,links:[]}),e.get(t.teamId).links.push(t);return[...e.values()]}_body(){return this._data==null?this._error?c`<p class="msg error">Couldn't load public links: ${this._error}</p>`:q("Loading public links\u2026"):this._data.shares.length===0?c`<p class="msg">No public links. Create one with the share button beside a workspace in the sidebar.</p>`:this._groups().map(e=>c`<section class="link-team" aria-label="${e.name}"><h2>${e.name}</h2><div class="link-table"><table><thead><tr><th>Link</th><th>Created by</th><th>Created</th><th>Security</th><th>Dependencies</th><th><span class="sr-only">Actions</span></th></tr></thead><tbody>${e.links.map(t=>c`<tr><td><span data-tooltip="${t.id}">${t.id.slice(0,8)}</span></td><td>${t.createdBy}</td><td>${new Date(t.createdAt).toLocaleString()}</td><td>${t.permissions.security?"On":"Off"}</td><td>${t.permissions.dependencies?"On":"Off"}</td><td><button class="btn" aria-label="${`Edit public link ${t.id.slice(0,8)} for ${e.name}`}" @click="${()=>this._edit(t)}">Edit</button></td></tr>`)}</tbody></table></div></section>`)}render(){return c`<div class="wrap">${U("manage-links",this._role,this.allowShare)}<h1 class="sr-only">Public links</h1><div class="page-intro"><p class="intro">Manage public links and the findings each link can show.</p><span class="result-count">${this._data?.shares.length??"\u2026"} links</span></div>${this._loading&&this._data?c`<span class="sr-only" role="status">Refreshing public links…</span>`:h}<div class="manage-list" aria-busy="${this._loading}">${this._body()}</div></div>`}};customElements.define("managed-admin-links",Ws);S();B();var Lh="/api/admin/deduplication";async function Ks(r="",e={}){let t=await x(`${Lh}${r}`,{credentials:"same-origin",...e}),i=await t.json();if(!t.ok){let s={"storage-encryption-required":"Configure MANAGED_STORAGE_ENCRYPTION_KEY on the server to import encrypted link reports.","invalid-link-report":'Choose a link report containing arrays of finding IDs, such as [["id1", "id2"]].',"too-large":"This link report exceeds the server upload limit."};throw new Error(s[i?.error]??`HTTP ${t.status}`)}return i}var Zs=class extends T{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[$(N),$(ur),$(Er)];constructor(){super(),this._data=null,this._error=null,this._busy=!1,this._dragOver=!1,this._queue=[]}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ct(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){this._teardownDrop?.(),super.disconnectedCallback()}async _load({preserveError:e=!1}={}){e||(this._error=null),await this._loadCollection("deduplication","deduplication reports",t=>Ks("",{signal:t}),t=>{this._data=t})}_upload(e){if(!(!this._csrf||this._role!=="admin"))return Rt(this,e,t=>Ks("",{method:"POST",headers:{"content-type":"application/json","x-report-filename":encodeURIComponent(t.name),"x-csrf-token":this._csrf},body:t}),["deduplication","reports","teams"])}async _toggle(e){if(!(this._busy||!this._csrf)){this._busy=!0,this._error=null;try{await this.appState.mutate(()=>Ks(`/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"content-type":"application/json","x-csrf-token":this._csrf},body:JSON.stringify({enabled:!e.enabled})}),["deduplication","reports","teams"])}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load({preserveError:!0});let t=this._queue.splice(0);t.length>0&&this._upload(t)}}}_view(e){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-deduplication",linkId:e.id},bubbles:!0,composed:!0}))}_linkReports(){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-scans",scanMode:"link"},bubbles:!0,composed:!0}))}render(){let e=this._data?.reports??[];return c`${this._dragOver?c`<div class="dropzone">Drop link reports to import</div>`:h}<div class="wrap">${U("manage-deduplication",this._role,this.allowShare)}<h1 class="sr-only">Deduplication</h1><div class="page-intro"><p class="intro">Link duplicate findings across all teams.</p><span class="result-count">${this._data?e.length:"\u2026"} reports</span><button type="button" class="btn" @click="${()=>this._linkReports()}">Link reports</button></div><div class="drop-card"><span class="drop-icon" aria-hidden="true">${D("upload")}</span><span class="drop-copy"><strong>Import link reports</strong><span>Drop *.link.json files anywhere on this page.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy||!this._csrf}" @click="${()=>St(t=>{this._upload(t)})}">${this._busy?"Saving\u2026":"Browse files"}</button></div>${this._error?c`<p class="msg error" role="alert">${this._error}</p>`:h}<div class="manage-list" aria-busy="${this._loading}">${this._data===null?this._error?h:q("Loading deduplication reports\u2026"):e.length===0?c`<div class="empty"><strong>No link reports imported yet</strong><p>Each row in a link report lists IDs for the same finding.</p></div>`:c`<div class="link-table"><table><thead><tr><th>Report</th><th>Groups</th><th>Finding IDs</th><th>Imported by</th><th>Imported</th><th>Status</th><th><span class="sr-only">Actions</span></th></tr></thead><tbody>${e.map(t=>c`<tr><td>${t.filename}</td><td>${t.groupCount}</td><td>${t.findingCount}</td><td>${t.uploadedByLogin??"Removed user"}</td><td>${new Date(t.uploadedAt).toLocaleDateString()}</td><td>${t.enabled?"Enabled":"Disabled"}</td><td><button type="button" class="btn" aria-label="${`View ${t.filename}`}" @click="${()=>this._view(t)}">View</button> <button type="button" class="btn" ?disabled="${this._busy}" aria-label="${`${t.enabled?"Disable":"Enable"} ${t.filename}`}" @click="${()=>{this._toggle(t)}}">${t.enabled?"Disable":"Enable"}</button></td></tr>`)}</tbody></table></div>`}</div></div>`}};customElements.define("managed-admin-deduplication",Zs);B();ae();at();B();function zh(r,e){return new Promise(t=>{if(e.aborted){t();return}let i=()=>{clearTimeout(s),e.removeEventListener("abort",i),t()},s=setTimeout(i,r);e.addEventListener("abort",i,{once:!0})})}async function Oh(r,{signal:e,onUpdate:t,onTeams:i,onClose:s,reportId:o=null}){if(Ee())return;let n=1e3,a=async(l,d,m)=>{if(m.throwIfAborted(),l==="close")return await s(),!1;if(l==="triage"||l==="teams"){let p=null;if(l==="teams")try{let u=JSON.parse(d);typeof u?.revision=="string"&&(p=u.revision)}catch{}if(await(l==="teams"?i?.(m,p):t(m))===!1)throw new Error("Team refresh failed");m.throwIfAborted(),n=1e3}return!0};for(;!e.aborted;){let l=new AbortController,d=()=>l.abort();e.addEventListener("abort",d,{once:!0});let m,p,u=()=>{clearTimeout(p),p=setTimeout(d,45e3)};try{u();let f=o===null?"":`?reportId=${encodeURIComponent(o)}`,b=await x(r?`/api/teams/${encodeURIComponent(r)}/feed${f}`:"/api/teams/feed",{credentials:"same-origin",headers:{accept:"text/event-stream"},signal:l.signal});if([401,403,404].includes(b.status)){await b.body?.cancel(),e.aborted||await s();return}if(!b.ok||!b.headers.get("content-type")?.startsWith("text/event-stream"))throw await b.body?.cancel(),new Error("Team feed unavailable");if(m=b.body.getReader(),await Th(m,e,u,(y,g)=>a(y,g,l.signal)))return}catch{}finally{clearTimeout(p),d(),await m?.cancel().catch(()=>{}),e.removeEventListener("abort",d)}await zh(n,e),n=Math.min(n*2,3e4)}}async function Th(r,e,t,i){let s=new TextDecoder,o="";for(;!e.aborted;){let{done:n,value:a}=await r.read();if(n)return!1;if(t(),o=(o+s.decode(a,{stream:!0})).replaceAll(`\r
|
|
270
270
|
`,`
|
|
271
271
|
`),o.length>16384)throw new Error("Team feed frame too large");let l;for(;(l=o.indexOf(`
|
|
272
272
|
|
|
273
|
-
`))!==-1;){let d=o.slice(0,l);o=o.slice(l+2);let
|
|
274
|
-
`).find(
|
|
275
|
-
`).filter(
|
|
276
|
-
`);if(e.aborted||await i(
|
|
273
|
+
`))!==-1;){let d=o.slice(0,l);o=o.slice(l+2);let m=d.split(`
|
|
274
|
+
`).find(u=>u.startsWith("event:"))?.slice(6).trim(),p=d.split(`
|
|
275
|
+
`).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trimStart()).join(`
|
|
276
|
+
`);if(e.aborted||await i(m,p)===!1)return!0}}return!0}at();ae();var Ec=r=>`reports:content:${r}`;async function Js(r,e){let t=Ec(r),i=E.read(t);if(i!==void 0)return i;try{return await E.load(t,"report",async s=>{let o=await e(s);if(o===null)throw new Error("Could not load report");return o})}catch{return null}}function Nh(r){return Js(r,e=>zr(r,{signal:e}))}async function Ph(r){let e=[...new Set(r)].filter(s=>{let o=E.resources.get(Ec(s));return o?.data===void 0&&!o?.pending}).toSorted(),t,i=await Promise.all(r.map(s=>Js(s,async o=>(t??=xc(e,{signal:o}),(await t)?.[e.indexOf(s)]??null))));return i.some(s=>s===null)?null:i}function Bh(r,{reportId:e=null}={}){let t=e===null?"":`:${e}`;return Js(`team:${r}${t}`,i=>$c(r,{signal:i,reportId:e}))}ve();B();at();async function Ys(r,e){let t=await x(r,{credentials:"same-origin",signal:e});if(!t.ok)throw new Error(`Could not load link report (HTTP ${t.status})`);return t.json()}async function Dh(r,{signal:e}={}){let t=await Ys(`/api/admin/deduplication/${encodeURIComponent(r)}`,e),i=await Ys("/api/admin/reports",e),s=new Set(t.groups.flat()),o=[],n=0,a=await Promise.allSettled(Array.from({length:Math.min(4,i.reports.length)},async()=>{for(;n<i.reports.length;){e?.throwIfAborted();let l=n++,d=i.reports[l],m=await zr(d.id,{signal:e});if(!m)throw new Error(`Could not load ${d.filename}. Reopen this link report to try again.`);let u=(be(m.data)??[]).filter(f=>(Array.isArray(f)?f:[f]).some(b=>s.has(b?.id)));u.length>0&&(o[l]={id:d.id,filename:d.filename,repo:m.repo,data:{...m.data,[Array.isArray(m.data.findings)?"findings":"groups"]:u}})}}));for(let l of a)if(l.status==="rejected")throw l.reason;return await Ys(`/api/admin/deduplication/${encodeURIComponent(r)}`,e),[...o.filter(Boolean),{id:t.id,filename:t.filename,repo:{github:null,directory:""},data:{source:"links",findings:[],links:t.groups}}]}B();ae();at();B();ae();function Or(r,e){return E.resources.get(`report-sources:${e??""}:${r}`)}function jh(){E.invalidate(["report-sources"])}async function Uh(r,e){let t=`report-sources:${e??""}:${r}`,i=Or(r,e);if(i?.data!==void 0)return i.data;if(i?.error)return null;let s=E.load(t,"report sources",async n=>{let a=await x(`/api/reports/${encodeURIComponent(r)}/sources${Ve(e)}`,{credentials:"same-origin",signal:n});if(a.status===204||a.status===404)return null;if(!a.ok)throw new Error(`Sources request failed (${a.status})`);let l=await a.json();return{integrity:l.integrity,sources:new Map(l.files),paths:new Map(l.paths),imports:new Map((l.imports??[]).map(([d,m])=>[d,new Map(m)])),formats:new Map(l.formats??[]),packageDirs:new Map(l.packageDirs??[])}}),o=Or(r,e);try{return await s}catch(n){if(n.name!=="AbortError"){let a=Or(r,e);a===o&&(a.error=n)}throw n}}function Cw(){E.invalidate(["finding-history"])}async function Rw(){(await import("./client-managed-import.js")).registerWorkspaceImport(T,x)}async function Ew(...r){return(await Promise.resolve().then(()=>(Gs(),Vs))).openManagedShareDialog(...r)}async function Aw(r){return(await Promise.resolve().then(()=>(Pc(),Nc))).openManagedIssueDialog(r)}async function Iw(r){return(await Promise.resolve().then(()=>(Jc(),Zc))).openFindingHistoryDialog(r)}export{Sc as changeWorkspaceShare,Cw as clearFindingHistory,jh as clearReportSources,l_ as deleteReportComment,u_ as downloadManagedBundle,Yp as fetchBundleAdvisories,Jp as fetchBundleContents,Mi as fetchBundleMetadata,o_ as fetchFixes,Zp as fetchManagedBundleCatalog,Dh as fetchManagedLinkWorkspace,Nh as fetchReport,n_ as fetchReportComments,Uh as fetchReportSources,s_ as fetchReportTriage,Ph as fetchReports,i_ as fetchTeamAnnotations,Bh as fetchTeamReports,Ee as getPreviewRole,kc as listWorkspaceShares,Rw as loadWorkspaceImportPage,d_ as login,p_ as logout,Iw as openFindingHistoryDialog,Aw as openManagedIssueDialog,Ew as openManagedShareDialog,t_ as probeSession,r_ as probeTeams,c_ as pushReportTriage,Or as readReportSources,qp as resetManagedAppState,a_ as saveReportComment,Fp as setManagedAppSession,Hp as setManagedReportCatalog,Qc as setPreviewRole,Ve as teamQuery,Oh as watchTeamFeed};
|
|
277
277
|
/*!
|
|
278
278
|
* PHP elephant adapted from Material Icon Theme:
|
|
279
279
|
* https://github.com/material-extensions/vscode-material-icon-theme/blob/main/icons/php_elephant.svg
|