@preventive/triage 1.0.0-alpha.43 → 1.0.0-alpha.45

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.
Files changed (186) hide show
  1. package/common/bundle-compare-diff.js +2 -167
  2. package/common/bundle-compare-versions.js +172 -0
  3. package/common/bundle-comparison.d.ts +8 -0
  4. package/common/bundle-comparison.js +62 -0
  5. package/common/bundle-sources.js +20 -1
  6. package/common/default-scan-models.ts +1 -1
  7. package/common/dependency-reviews.d.ts +0 -5
  8. package/common/dependency-reviews.js +0 -17
  9. package/common/managed/agent-tasks.ts +292 -0
  10. package/common/managed/github-agents.ts +92 -0
  11. package/common/managed/github-logins.ts +49 -0
  12. package/common/managed/roles.ts +7 -0
  13. package/common/managed/routes.js +91 -10
  14. package/common/managed/team-app.d.ts +5 -2
  15. package/common/managed/team-app.js +2 -2
  16. package/common/server-info.ts +11 -0
  17. package/common/workspace-app.js +19 -3
  18. package/out/brotli-fallback.js +3 -3
  19. package/out/chunk-2XUEZHIP.js +18 -18
  20. package/out/chunk-2ZDZWLFY.js +1 -0
  21. package/out/chunk-3PS4KWD2.js +10 -0
  22. package/out/chunk-5DHL5NG3.js +2 -0
  23. package/out/chunk-6HNXNIQY.js +52 -0
  24. package/out/chunk-7C7DWL7I.js +1 -0
  25. package/out/chunk-AFLZH7WG.js +1 -0
  26. package/out/chunk-BC2UCLFJ.js +1 -0
  27. package/out/chunk-C4Z6ZBXV.js +6 -6
  28. package/out/chunk-GDPCLSOS.js +2 -0
  29. package/out/chunk-GO7FT4OD.js +1 -0
  30. package/out/chunk-HMAJDVXN.js +1 -0
  31. package/out/chunk-I2MDGSQX.js +3 -0
  32. package/out/chunk-IYPY47MC.js +1 -0
  33. package/out/chunk-IZ7POWI3.js +18 -0
  34. package/out/chunk-JCIIBLKR.js +1 -0
  35. package/out/chunk-NPW52BM2.js +17 -0
  36. package/out/chunk-NRPC74AM.js +1 -1
  37. package/out/chunk-NV7ES4EW.js +1 -0
  38. package/out/chunk-OKRLLE5I.js +17 -0
  39. package/out/chunk-OOJM4CTU.js +1 -1
  40. package/out/chunk-PNHBZGDD.js +1 -1
  41. package/out/chunk-PTGDYLNS.js +36 -0
  42. package/out/chunk-PXK7EU4V.js +1 -0
  43. package/out/chunk-Q6MVYGYV.js +3 -0
  44. package/out/chunk-QB4CBOX2.js +1 -0
  45. package/out/chunk-QRD6GIG5.js +229 -0
  46. package/out/chunk-R3NZFXVR.js +1 -0
  47. package/out/chunk-R5O6FAW4.js +1 -1
  48. package/out/chunk-SXV2T5C4.js +80 -0
  49. package/out/chunk-TUII34K2.js +1 -1
  50. package/out/chunk-VFWMQ3LG.js +2 -0
  51. package/out/chunk-VH4XMZIW.js +2 -0
  52. package/out/chunk-WFYLMF6Z.js +10 -0
  53. package/out/chunk-WI7Z5A2T.js +6 -0
  54. package/out/chunk-WQ74ZBZF.js +7 -0
  55. package/out/chunk-XVBEOGOS.js +3 -0
  56. package/out/client-managed-import.js +3 -3
  57. package/out/client-managed.js +31 -35
  58. package/out/client-sync.js +11 -11
  59. package/out/compare.js +35 -0
  60. package/out/dialogs.js +51 -0
  61. package/out/github-issue-authorized.html +1 -1
  62. package/out/github-issue-authorized.js +1 -1
  63. package/out/graph.js +17 -17
  64. package/out/index.html +31 -31
  65. package/out/prism.js +14 -14
  66. package/out/scan.js +2 -0
  67. package/out/terminal.js +294 -293
  68. package/out/view.css +1 -1
  69. package/out/view.js +16 -107
  70. package/package.json +55 -6
  71. package/risk/actions/findings.js +156 -0
  72. package/risk/actions/resolve.js +219 -0
  73. package/risk/actions/scripts/commands.js +182 -0
  74. package/risk/actions/scripts/grade.js +113 -0
  75. package/risk/actions/scripts/packages.js +123 -0
  76. package/risk/actions/scripts/shell.js +165 -0
  77. package/risk/actions/uses.js +76 -0
  78. package/risk/actions/workflow.js +110 -0
  79. package/risk/files/hosts.js +6 -6
  80. package/risk/files/readability.js +23 -17
  81. package/risk/files/runs-code.js +18 -6
  82. package/risk/files/script.js +7 -3
  83. package/risk/files/stamps.js +8 -7
  84. package/risk/index.d.ts +68 -1
  85. package/risk/index.js +6 -2
  86. package/risk/npm/assess.js +13 -8
  87. package/risk/npm/compare.js +34 -10
  88. package/risk/npm/dependencies.js +11 -0
  89. package/risk/npm/files.js +413 -2
  90. package/risk/npm/tarball.js +56 -73
  91. package/server-managed/agent-merges.ts +198 -0
  92. package/server-managed/app-agents.ts +30 -0
  93. package/server-managed/avatar-store.ts +1 -0
  94. package/server-managed/commit-coauthors.ts +83 -0
  95. package/server-managed/commit-lockfiles.ts +62 -0
  96. package/server-managed/comparison.ts +41 -0
  97. package/server-managed/db-methods.ts +29 -10
  98. package/server-managed/db-neon.ts +30 -2
  99. package/server-managed/db-schema.ts +9 -2
  100. package/server-managed/db.ts +7 -0
  101. package/server-managed/dependabot-access.ts +60 -0
  102. package/server-managed/dependabot-alerts.ts +185 -0
  103. package/server-managed/dependency-review-comments.ts +97 -0
  104. package/server-managed/dependency-reviews.ts +65 -15
  105. package/server-managed/github-accounts.ts +33 -0
  106. package/server-managed/github-actions.ts +71 -0
  107. package/server-managed/github-app.ts +23 -9
  108. package/server-managed/github-errors.ts +2 -0
  109. package/server-managed/github-link-oauth.ts +69 -0
  110. package/server-managed/github-links.ts +204 -0
  111. package/server-managed/github-oauth.ts +5 -2
  112. package/server-managed/github-users.ts +30 -0
  113. package/server-managed/http.ts +1219 -81
  114. package/server-managed/index.ts +6 -2
  115. package/server-managed/locked-packages.ts +48 -16
  116. package/server-managed/lockfile-scope.ts +49 -0
  117. package/server-managed/npm-delta-worker.js +23 -0
  118. package/server-managed/npm-delta.ts +173 -0
  119. package/server-managed/npm-insights.ts +20 -11
  120. package/server-managed/npm-kept.ts +51 -4
  121. package/server-managed/npm-loads.ts +20 -13
  122. package/server-managed/npm-packages.ts +24 -64
  123. package/server-managed/pretty-print.ts +14 -9
  124. package/server-managed/public-workspace.ts +26 -8
  125. package/server-managed/pull-comment-reviews.ts +161 -0
  126. package/server-managed/pull-dependencies.ts +280 -0
  127. package/server-managed/pull-dependency-reviews.ts +318 -0
  128. package/server-managed/pull-reviews.ts +205 -0
  129. package/server-managed/release-commits.ts +84 -0
  130. package/server-managed/repository-actions.ts +209 -0
  131. package/server-managed/repository-agents.ts +220 -0
  132. package/server-managed/repository-browser.ts +54 -13
  133. package/server-managed/repository-changes.ts +284 -0
  134. package/server-managed/repository-code.ts +52 -0
  135. package/server-managed/repository-dependency-reviews.ts +135 -0
  136. package/server-managed/repository-history.ts +445 -0
  137. package/server-managed/repository-issues.ts +181 -0
  138. package/server-managed/repository-pulse.ts +432 -0
  139. package/server-managed/repository-risk-read.ts +165 -0
  140. package/server-managed/repository-risk.ts +116 -106
  141. package/server-managed/reviewed-dependencies.ts +149 -0
  142. package/server-managed/session.ts +9 -5
  143. package/server-managed/sql.ts +1 -1
  144. package/server-managed/storage-stores.ts +5 -0
  145. package/server-managed/team-app.ts +54 -14
  146. package/server-managed/workspace-shares.ts +4 -1
  147. package/server.ts +11 -0
  148. package/out/chunk-2KBF5TZ7.js +0 -2
  149. package/out/chunk-35VE6CDH.js +0 -2
  150. package/out/chunk-3BZ7JERB.js +0 -1
  151. package/out/chunk-4F6JSF57.js +0 -3
  152. package/out/chunk-4XCDFGDP.js +0 -10
  153. package/out/chunk-7RU5EDRO.js +0 -226
  154. package/out/chunk-A7M4GV7M.js +0 -1
  155. package/out/chunk-CLPKNNC7.js +0 -51
  156. package/out/chunk-CMQA4DM6.js +0 -1
  157. package/out/chunk-CVVJAXVY.js +0 -2
  158. package/out/chunk-DIJJNTRH.js +0 -10
  159. package/out/chunk-GJ4IUCNS.js +0 -1
  160. package/out/chunk-GNXOKIGP.js +0 -80
  161. package/out/chunk-GZ4MS3TE.js +0 -13
  162. package/out/chunk-IU3CCINR.js +0 -3
  163. package/out/chunk-K3X5EJBQ.js +0 -2
  164. package/out/chunk-KEX2ATEW.js +0 -2
  165. package/out/chunk-KYCNJVB7.js +0 -1
  166. package/out/chunk-LAAB5SZT.js +0 -2
  167. package/out/chunk-NWZ4PVPN.js +0 -1
  168. package/out/chunk-OSIMGFUF.js +0 -1
  169. package/out/chunk-RFZQQXSG.js +0 -17
  170. package/out/chunk-RSHMVYNS.js +0 -1
  171. package/out/chunk-TZ5KB2Y5.js +0 -10
  172. package/out/chunk-UNTRGE26.js +0 -2
  173. package/out/chunk-UXNUAIIC.js +0 -33
  174. package/out/chunk-UYAXVRVL.js +0 -1
  175. package/out/chunk-V3ME6FI5.js +0 -2
  176. package/out/chunk-V5O7M2YT.js +0 -1
  177. package/out/chunk-VIHGO77Y.js +0 -1
  178. package/out/chunk-VQJCXGIY.js +0 -7
  179. package/out/chunk-W4J3MGLB.js +0 -1
  180. package/out/chunk-WGG7KQUH.js +0 -1
  181. package/out/chunk-WZDTZE64.js +0 -1
  182. package/out/chunk-XOCAPDCM.js +0 -1
  183. package/out/chunk-XYFXXB2G.js +0 -10
  184. package/out/chunk-YVZH5SHP.js +0 -1
  185. package/out/chunk-ZBBOBQ43.js +0 -1
  186. package/out/chunk-ZMQQCGF6.js +0 -2
@@ -1,33 +0,0 @@
1
- import{b as _e,h as Ee}from"./chunk-4F6JSF57.js";import{a as Le,e as Ce,h as Ie}from"./chunk-YVZH5SHP.js";import{A as Re,B as z,E as Se,b as G,c as ee,d as ye,j as L,m as C,p as I,s as xe,t as $e,w as ke,z as te}from"./chunk-GNXOKIGP.js";import{a as P,b as U,c as B}from"./chunk-C4Z6ZBXV.js";import{c as Q,f as N,g as ve}from"./chunk-2XUEZHIP.js";var tn=U(class extends B{constructor(e){if(super(e),e.type!==P.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(let o in t)t[o]&&!this.nt?.has(o)&&this.st.add(o);return this.render(t)}let n=e.element.classList;for(let o of this.st)o in t||(n.remove(o),this.st.delete(o));for(let o in t){let i=!!t[o];i===this.st.has(o)||this.nt?.has(o)||(i?(n.add(o),this.st.add(o)):(n.remove(o),this.st.delete(o)))}return N}});var Me="important",ut=" !"+Me,ln=U(class extends B{constructor(e){if(super(e),e.type!==P.ATTRIBUTE||e.name!=="style"||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let o=e[n];return o==null?t:t+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${o};`},"")}update(e,[t]){let{style:n}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let o of this.ft)t[o]==null&&(this.ft.delete(o),o.includes("-")?n.removeProperty(o):n[o]=null);for(let o in t){let i=t[o];if(i!=null){this.ft.add(o);let r=typeof i=="string"&&i.endsWith(ut);o.includes("-")||r?n.setProperty(o,r?i.slice(0,-11):i,r?Me:""):n[o]=i}}return N}});function H(e){return e.id??String(e._id)}function ne(e){let t=I(e);return t!==""&&t!=="revalidation"}var K=[{value:"confirmed",label:"Confirmed",kinds:["confirmed","partial","revalidation"]},{value:"unreachable",label:"Unreachable",kinds:["unreachable"]},{value:"refuted",label:"Refuted",kinds:["refuted"]}];function Ae(e){return K.find(t=>t.value===e)?.kinds??null}var ft=["","exclude","only"];function oe(e,t){let n=Ae(e);return n?.includes("partial")?t==="only"?["partial"]:t==="exclude"?["confirmed"]:n:n}function V(e){if(e.confidence!==void 0)return e.confidence;if(e.critical===!0||e._source)return 10}var pt=e=>e.confidence!==void 0||e.critical===!0;function dt(e){return e.every(t=>t.every(n=>V(n)!==void 0))&&e.some(t=>t.some(pt))}function Te(e,t,n){return e.some(o=>{let i=["refuted","unreachable"].includes(n(o))?0:V(o);return i===void 0?t===0:i>=t})}function gt(e,t){let n=e.map(t).filter(r=>r.length>0);if(!n.some(r=>r.some(s=>V(s)!==void 0)))return 0;let o=r=>n.reduce((s,l)=>s+(l.some(a=>(V(a)??-1)>=r)?1:0),0),i;for(o(6)<=25?i=6:o(7)<=25?i=7:i=8;i>0&&o(i-1)===o(i);)i--;return i}function je(e,t){return dt(e)?t:0}function ht(e,t,n){let o=new Set(e.ruledOutIds??[]);for(let i of e)for(let r of i)["refuted","unreachable"].includes(n(r))&&o.add(H(r));for(let i of e){let r=t(i);if(r.length!==0&&r.some(s=>oe("confirmed","").includes(n(s)||(s._source&&!s._sourcePass?"revalidation":"")))){for(let s of i)if(o.add(H(s)),s.isApp&&Array.isArray(s.revalidateInputs))for(let l of s.revalidateInputs)l&&o.add(l)}}return o}function mt(e,t,n,o){let i=je(e,t),r=e.filter(l=>Te(l,i,o));if(r.length===0)return!1;let s=new Set(oe("confirmed",""));return e.some(l=>l.some(a=>s.has(o(a))))?r.every(l=>l.every(a=>n.has(H(a)))):!1}function hn(e,{tabs:t,kindOf:n,severityMode:o}){let i=e.map(t).filter(l=>l.length>0),r=ht(e,t,n);if(!mt(i,gt(e,t),r,n))return!1;let s=je(i,6);return i.every(l=>!Te(l,s,n)||!l.some(a=>C(a,o)!=="low")||l.every(a=>r.has(H(a))))}var S=!0;function jn(e,t=!1){S=e!==!1&&!t}function Fn(){return S}function A(e){return S?I(e):""}function Dn(e){return I(e)!==""}function On(e){return e.some(t=>(t.groups??[]).some(n=>n.some(ne)))}function bt(e){let t=A(e);return t&&t!=="revalidation"?t:null}function Nn(e){return A(e)==="revalidation"}var Ve=new Set(["refuted","unreachable"]);function Pn(e){return Ve.has(A(e))}function Un(e){return Ve.has(A(e))}function Bn(e){let t=new Set(e);return K.filter(n=>n.kinds.some(o=>t.has(o)))}function Z(e){return new RegExp(`(^|/)${e}/`,"u")}function Ke(e){return new RegExp(`^(?:.*/)?${e}/(?:@[^/]+/[^/]+|[^/]+)/(.*)$`,"u")}var wt=Z("node_modules"),vt=Z("vendor"),M="node_modules",ae=Z(M),We=Ke(M);function yt(e){e!==M&&(M=e,ae=Z(e),We=Ke(e))}function Gn(e){yt(_e(e))}function Ze(){return M}function q(e){return ae.test(e)}var ie=new WeakSet;function zn(e){let t=!1;for(let n of e??[])for(let o of n.groups??[])for(let i of o){if(i.isApp!==!1)continue;let r=ie.has(i);"isUpstream"in i&&!r||(q(i.file)?(i.isUpstream!==!0&&(t=!0),i.isUpstream=!0,ie.add(i)):r&&(t=!0,delete i.isUpstream,ie.delete(i)))}return t}function Fe(e){let t=typeof e=="string"?e:"";return wt.test(t)||vt.test(t)||ae.test(t)}var xt=/^(.*(?:^|\/)node_modules\/(?:@[^/]+\/[^/]+|[^/]+))(?:\/|$)/u;function De(e){return xt.exec(typeof e=="string"?e:"")?.[1]??null}function Hn(e){return typeof e!="number"||!Number.isFinite(e)?null:Le(e)}function Vn(e){if(e.length<=1)return{prefix:"",stripped:[...e]};let t=e.map(s=>s.split("/")),n=Math.min(...t.map(s=>s.length)),o=0;for(let s=0;s<n-1&&t.every(l=>l[s]===t[0][s]);s++)o=s+1;if(o>0&&t[0][o-1].startsWith("@")&&o--,o>0&&t[0][o-1]==="node_modules"&&o--,o===0)return{prefix:"",stripped:[...e]};let i=`${t[0].slice(0,o).join("/")}/`,r=t.map(s=>s.slice(o).join("/"));return{prefix:i,stripped:r}}function $t(e){return e.match(We)?.[1]??e}function Kn(e){let t=S?[bt(e),e.revalidateVerdict,e.revalidateRecommendation]:[];return[e.file,e.title,e.description,e.impact,e.reproduction,Ft(e),e.recommendation,e.confidenceReason,...t,e.discoveredIn,e.repo?.github].filter(Boolean).join(`
2
- `).toLowerCase()}function Wn(e){return[typeof e?.category=="string"?e.category.trim():"",xe(e,S)].filter(Boolean).join(" \xB7 ")}function Zn(e){if(e.length===0)return"";let t=e[0];for(let n=1;n<e.length;n++){for(;t&&!e[n].startsWith(t);)t=t.slice(0,-1);if(!t)return""}return t}function qn(e){if(!e)return"";let t=e.match(/github\.com\/([^/?#]+\/[^/?#]+?)(?:\.git)?(?:[/?#]|$)/iu);return t?t[1]:e}function qe(e){if(!e)return null;let t=e.trim().replace(/\/$/u,"");return t?/^https?:\/\//iu.test(t)?t:/^github\.com\//iu.test(t)?`https://${t}`:`https://github.com/${t}`:null}var kt=/^(?:@[\w.-]+\/)?[\w.-]+@[^/\s@]+$/u;function Rt(e){return kt.test(e||"")}function Oe(e){if(e==null||typeof e=="string")return{id:e??"",prefix:""};let t=Se(e);return{id:typeof e.github=="string"?e.github:"",prefix:t?`${t}/`:""}}function St(e,t,n){if(Rt(e))return null;let o=Oe(t);if(o.id)return`https://github.com/${o.id}/blob/HEAD/${o.prefix}${$t(e)}`;if(q(e))return null;let i=Oe(n),r=qe(i.id);return r?`${r}/blob/HEAD/${i.prefix}${e}`:null}function Yn(e,t){let n=e?.file??"",o=W(e,t);return o?Q`<a href="${_t(o)}" target="_blank" rel="noopener">${n}</a>`:n}function _t(e){return e.replace(/#L\d+(?:-L?\d+)?$/u,"")}function W(e,t){if(!e)return null;if(z(e.location))return e.location;let n=St(e.file,e.repo,t);if(!n)return null;let o=parseInt(e.line,10);return Number.isFinite(o)?`${n}#L${o}`:n}var Et=/^https?:\/\/(?:www\.)?github\.com\/([^/\s]+\/[^/\s]+)\/(?:blob|tree|blame)\/[^/\s]+\/(\S+)$/u,Lt=/#L(\d+)(?:-L?(\d+))?$/u;function Jn(e){let t=typeof e=="string"?Et.exec(e):null;if(!t)return"";let n=t[2],o=Lt.exec(n);if(!o)return`${t[1]}/${n}`;n=n.slice(0,o.index);let i=o[2]?`${o[1]}-${o[2]}`:o[1];return`${t[1]}/${n}:${i}`}var Ct=/^(?:\s+\S|[-*+] |\d+[.)] |>|#{1,6} |\||`{3}|~{3})/u;function Ye(e){return e.split(/(\n{2,})/u).map(t=>{if(/^\n+$/u.test(t))return t;let n=t.split(`
3
- `);return n.some(o=>Ct.test(o))?t:n.map(o=>o.trim()).filter(Boolean).join(" ")}).join("")}function Ne(e,t,n){let o=t?/^\n*/u.exec(e)[0]:"",i=e.slice(o.length),r=n?/\n*$/u.exec(i)[0]:"";return o+Ye(i.slice(0,i.length-r.length))+r}function Xn(e){if(!e)return e;let t=G(e);if(t.length===0)return Ye(e);let n=[],o=0;for(let[i,r]of t)i>o&&n.push(Ne(e.slice(o,i),o>0,!0)),n.push(e.slice(i,r)),o=r;return o<e.length&&n.push(Ne(e.slice(o),!0,!1)),n.join("")}var Pe=/^( *)(`{3,}|~{3,})(.*)$/u,It=/^[a-z0-9+#._-]{1,20}$/u;function Je(e,t){let n=0;for(;n<t&&e[n]===" ";)n++;return e.slice(n)}function Mt(e){let t=e.split(`
4
- `),n=Pe.exec(t[0]),o=(n?.[2]??"```").slice(0,3),i=(n?.[3]??"").trim().split(/\s+/u)[0].toLowerCase(),s=!!(t.length>1?Pe.exec(t.at(-1)):null)?.[2].startsWith(o),l=n?.[1].length??0,a=t.slice(1,s?-1:void 0);return{lang:It.test(i)?i:"",code:(l>0?a.map(u=>Je(u,l)):a).join(`
5
- `)}}function Qn(e){let t=G(e||"");if(t.length===0)return[e];let n=[],o=0,i=(r,s)=>{let l=(s?r.replace(/^\n+/u,""):r).replace(/\n+$/u,"");l&&n.push(l)};for(let[r,s]of t)r>o&&i(e.slice(o,r),o>0),n.push(Mt(e.slice(r,s))),o=s;return o<e.length&&i(e.slice(o),!0),n}var re=/^( *)(?:[-*+]|(\d{1,9})[.)]) +(?=\S)/u,Ue=/^ {0,3}([-*_])(?: *\1){2,} *$/u;function At(e){return/^ */u.exec(e)[0].length}function Be(e){let t=e.length;for(;t>0&&!e[t-1].trim();)t--;return e.slice(0,t).join(`
6
- `)}function eo(e){let t=typeof e=="string"?e:"";if(!t)return[e];let n=G(t),o=t.split(`
7
- `),i=[],r=0;for(let g of o)i.push(r),r+=g.length+1;let s=g=>!ee(n,i[g])&&!Ue.test(o[g])&&re.test(o[g]),l=[],a=0,u=0,p=g=>{let h=o.slice(a,g).join(`
8
- `).replace(/^\n+/u,"").replace(/\n+$/u,"");h.trim()&&l.push(h)};for(;u<o.length;){if(!s(u)){u++;continue}p(u);let g=re.exec(o[u]),h=!!g[2],y=[],w=null,m=!1;for(;u<o.length;){let x=o[u];if(!ee(n,i[u])){if(!x.trim()){w.lines.push(""),m=!0,u++;continue}let $=At(x),R=Ue.test(x)?null:re.exec(x);if(R&&(!w||$<w.column)){if(!!R[2]!==h)break;w&&y.push(Be(w.lines)),w={column:R[0].length,lines:[x.slice(R[0].length)]},m=!1,u++;continue}if($<w.column&&m)break}w.lines.push(Je(x,w.column)),m=!1,u++}w&&y.push(Be(w.lines)),l.push({ordered:h,start:h?Number(g[2]):null,items:y}),a=u}return l.length===0?[e]:(p(o.length),l)}var Tt=/^(\d+)(?:\s*-\s*(\d+))?$/u;function se(e){if(typeof e=="number")return Number.isFinite(e)&&e>=1?{start:Math.floor(e),end:Math.floor(e)}:null;let t=Tt.exec(String(e??"").trim());if(!t)return null;let n=parseInt(t[1],10),o=t[2]===void 0?n:parseInt(t[2],10);return!Number.isFinite(n)||n<1||!Number.isFinite(o)||o<1?null:{start:Math.min(n,o),end:Math.max(n,o)}}function to(e){return e?e.start===e.end?String(e.start):`${e.start}-${e.end}`:""}function jt(e){if(e&&typeof e=="object"){let t=se(e.start);if(!t)return null;let n=se(e.end)??t;return{start:t.start,end:Math.max(t.start,n.end)}}return se(e)}function no(e,t,n=4){let o=typeof e=="string"&&e!==""?e.split(`
9
- `):[];if(o.length===0)return{text:"",startLine:1,lines:[]};let i=jt(t),r=i&&{start:Math.min(i.start,o.length),end:Math.min(i.end,o.length)},s=r?Math.max(1,r.start-n):1,l=r?Math.min(o.length,r.end+n):Math.min(o.length,n*2+1),a=o.slice(s-1,l);return{text:a.join(`
10
- `),startLine:s,lines:a}}function oo(e,t,n,o){if(z(e?.url))return e.url;let i=e?.file;if(typeof i!="string"||i==="")return null;let r=t?.file??"",s=t?.repo?.github,l=()=>s?W({file:i,line:e?.line,repo:t.repo},null):null;if(o===0&&i===r)return l();let a=De(i);return a!==null&&a===De(r)?l():Fe(i)?null:s&&!Fe(r)?l():W({file:i,line:e?.line},n)}function Xe(e,{spaced:t=!1}={}){let n=Array.isArray(e?.evidence)?e.evidence:[];return n.length===0?"":n.map((o,i)=>{let r=te(o),s=[`${i+1}. ${o.url?`[${r}](${o.url})`:r}`],l=Re(o);if(l)for(let a of l.split(`
11
- `))s.push(` ${a}`);return s.join(`
12
- `)}).join(t?`
13
-
14
- `:`
15
- `)}function Ft(e){let t=Xe(e);return t?`**Evidence:**
16
- ${t}`:""}function io(e){let t=/^\[([^\]]+)\]\(([^)\s]+)\)$/u.exec(e);return!t||!z(t[2])?null:{label:ye(t[1].trim())||t[2],url:t[2]}}function ro(e,t){let n=parseInt(e?.line,10);if(!Number.isFinite(n))return ve;let o=W(e,t),i=`line ${n}`;return o?Q`<a href="${o}" target="_blank" rel="noopener">${i}</a>`:i}function so(e,t){return!e||!t?null:`${/^https?:/iu.test(e)?e.replace(/\/$/u,""):`https://github.com/${e}`}/commit/${t}`}var Dt=[["Impact","impact"],["Reproduction","reproduction"],["Recommendation","recommendation"],["Confidence reason","confidenceReason"],["Revalidation verdict","revalidateVerdict"],["Revalidation recommendation","revalidateRecommendation"]];function co(e,t){let n=[];t&&n.push(`Repo: ${t}`);let o=te(e);o&&n.push(`Location: ${o}`),e?.confidence!=null&&n.push(`Confidence: ${e.confidence}/10`);let i=A(e);i&&n.push(`Revalidation: ${i}`);let r=[];n.length>0&&r.push(n.join(`
17
- `));let{title:s,body:l}=ke(e);s&&r.push(`# ${s}`),l&&r.push(l.trim());let a=Xe(e,{spaced:!0});a&&r.push(`# Evidence
18
-
19
- ${a}`);for(let[u,p]of Dt){if(!S&&p.startsWith("revalidate"))continue;let g=$e(e?.[p],e)?.trim();g&&r.push(`# ${u}
20
-
21
- ${g}`)}return r.join(`
22
-
23
- `)}function ao(e,{title:t,body:n,labels:o=[]}={}){let i=qe(e);if(!i)return null;let r;try{r=new URL(i).host.toLowerCase()}catch{return null}if(r!=="github.com")return null;let s=new URLSearchParams;t&&s.set("title",t),n&&s.set("body",n),o.length>0&&s.set("labels",o.join(","));let l=s.toString();return l?`${i}/issues/new?${l}`:`${i}/issues/new`}var Ot=/^[a-zA-Z\d](?:-?[a-zA-Z\d])*$/u,Nt=/^[a-zA-Z\d._-]+$/u,Pt=/^[1-9]\d{0,9}$/u,Ut=/^[a-fA-F\d]{7,40}$/u,Bt=/^#[\w-]+$/u,Ge=/^GHSA(?:-[0-9a-z]{4}){3}$/u;function ze(e){return e.length<=39&&Ot.test(e)}function He(e){return e.length<=100&&e!=="."&&e!==".."&&Nt.test(e)}function Gt(e){let t;try{t=new URL(e)}catch{return null}if(t.href!==e||t.protocol!=="https:"||t.hostname.toLowerCase()!=="github.com"||t.port||t.username||t.password)return null;let n=t.pathname.split("/");if(n.at(-1)===""&&n.pop(),n.length===3&&n[1]==="advisories"){let p=n[2];return Ge.test(p)?{url:`https://github.com/advisories/${p}`,label:p}:null}if(n.length===6&&n[3]==="security"&&n[4]==="advisories"){let[,p,g,,,h]=n;return!ze(p)||!He(g)||!Ge.test(h)?null:{url:`https://github.com/${p}/${g}/security/advisories/${h}`,label:h}}if(n.length!==5)return null;let[,o,i,r,s]=n;if(!ze(o)||!He(i))return null;let l;if(r==="issues"||r==="pull"){if(!Pt.test(s))return null;l=`${o}/${i}#${s}`}else if(r==="commit"){if(!Ut.test(s))return null;l=`${o}/${i}@${s.slice(0,7)}`}else return null;let a=Bt.test(t.hash)?t.hash:"";return{url:`https://github.com/${o}/${i}/${r}/${s}${a}`,label:l}}var zt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u;function Ht(e){if(typeof e!="string")return null;let t=Vt(e);return t!==e||zt.test(e)?t.slice(0,8):null}function Vt(e){let t=String(e),n="https://chatgpt.com/codex/cloud/security/findings/";return t.startsWith(n)?t.slice(n.length):t}function Kt(e,t){let n=Ee(e,{managed:t});if(!n)return null;let o=Ht(n.id);return{url:t?n.path:`#${n.fragment}`,label:o?`finding ${o}`:"finding",self:!0}}var ce=/https?:\/\/[^\s<>"'`(){}[\]|\\^]+/giu,Wt=new Set([")",".",",","!","?",";",":","'",'"',"*","]","}",">"]);function Zt(e){let t=e.length;for(;t>0&&Wt.has(e[t-1]);)t--;return t===e.length?e:e.slice(0,t)}function lo(e,{managed:t=!1}={}){if(typeof e!="string"||e.length===0)return[];let n=[],o=0;ce.lastIndex=0;let i;for(;(i=ce.exec(e))!==null;){let r=Zt(i[0]),s=r?Gt(r)??Kt(r,t):null;s&&(i.index>o&&n.push(e.slice(o,i.index)),n.push(s),o=i.index+r.length,ce.lastIndex=o)}return o<e.length&&n.push(e.slice(o)),n}var Y={showAll:!1,packagesView:!1,dependencyPackagesView:!1,flowPackagesView:!1,bundleIssues:!1,bundleLayout:"graph",bundleReason:null,bundleReasonFor:null,selected:null,focusedPkg:null,topPkgsTab:"issues",edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:"",hidden:new Set,solo:null,graphState:null,layoutCache:null,keptViewport:null};function po({keepViewport:e=!1}={}){Y.graphState?._cleanup?Y.graphState._cleanup({keepViewport:e}):e||(Y.keptViewport=null),Y.graphState=null}function mo(e){if(!e)return null;let t=Ze(),n=new RegExp(`^(?:.*/)?${t}/(@[^/]+/[^/]+|[^/]+)`,"u"),o=e.match(n);return o?o[1]:"__own__"}function bo(e){return new Set(e.filter(t=>!q(t)))}var Qe=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],et=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function ue(){if(typeof document>"u")return!1;let e=document.body?.classList;return!!e&&(e.contains("theme-light")||e.contains("theme-pink")||e.contains("theme-paper"))}var le=new Map;function wo(e){let t=ue()?et:Qe;return t[e%t.length]}var vo=()=>ue()?"#8c959f":"#6e7681";function yo(e){let t=ue(),n=t?et:Qe,o=e??"__own__",i=`${t?"l":"d"}:${o}`;if(le.has(i))return le.get(i);let r=0;for(let u of o)r=r*37+u.codePointAt(0)|0;let l=((r%n.length+n.length)%n.length*7+3)%n.length,a=n[l];return le.set(i,a),a}function ko(e){return"tree-"+e.replaceAll(/[^\w-]+/gu,"_")}var nt=()=>Object.fromEntries(L.map(e=>[e,0]));function Ro(e,t){let n=new Map;for(let o of e)for(let i of o){n.has(i.file)||n.set(i.file,nt());let r=n.get(i.file),s=C(i,t);r[s]!==void 0&&r[s]++}return n}function So(e){let t=null;for(let n of e)if(n?.tree){t||(t={});for(let o of Object.keys(n.tree)){let i=n.tree[o];if(!t[o]){t[o]={...i,imports:[...i.imports??[]]};continue}let r=new Set(t[o].imports);for(let s of i.imports??[])r.has(s)||(r.add(s),t[o].imports.push(s));t[o].size==null&&i.size!=null&&(t[o].size=i.size)}}return t}function _o(e,t){let n=Object.keys(e),o=new Map(n.map((a,u)=>[a,u])),i=n.map(()=>nt()),r=n.map(()=>[]);for(let[a,u]of n.entries())for(let p of e[u].imports??[]){let g=o.get(p);g!==void 0&&r[g].push(a)}let s=new Uint32Array(n.length),l=0;for(let[a,u]of t){let p=o.get(a);if(p===void 0||!u)continue;let g=L.map(m=>[m,u[m]??0]).filter(([,m])=>m!==0);if(g.length===0)continue;let h=++l,y=[],w=m=>{s[m]!==h&&(s[m]=h,y.push(m))};for(let m of r[p])w(m);for(;y.length>0;){let m=y.pop();for(let[x,$]of g)i[m][x]+=$;for(let x of r[m])w(x)}}return new Map(n.map((a,u)=>[a,i[u]]))}function Eo(e,t,n){let o=t.get(e),i=n.get(e);return tt(o)>0||tt(i)>0}function tt(e){if(!e)return 0;let t=0;for(let n of L)t+=e[n]??0;return t}var ot={package:"@babel/core",path:/^lib\/config\//u},fe={package:"@babel/core",path:/^lib\/config\/files\/(?:module-types|plugins)\.js$/u},st=Object.freeze([{id:"react-native-codegen-discovery",reason:"Codegen discovers package metadata and React Native configuration.",from:{package:"react-native",path:/^scripts\/codegen\/generate-artifacts-executor\.js$/u},to:{path:/(?:^|\/)(?:package\.json|react-native\.config\.js)$/u}},{id:"react-native-release-version",reason:"The CLI release checker reads the installed React Native version.",from:{package:"@react-native-community/cli-tools",path:/^build\/releaseChecker\/index\.js$/u},to:{package:"react-native",path:/^package\.json$/u}},{id:"react-native-platform-config",reason:"React Native configuration loads platform CLIs supplied by the host project.",from:{package:"react-native",path:/^react-native\.config\.js$/u},to:{package:/^@react-native-community\/cli-platform-(?:android|ios)$/u,path:/^build\/index\.js$/u}},{id:"babel-project-config",reason:"Babel discovers project configuration.",from:ot,to:{path:/(?:^|\/)babel\.config\.js$/u}},{id:"babel-typescript-preset",reason:"Babel configuration loads the TypeScript preset.",from:ot,to:{package:"@babel/preset-typescript",path:/./u}},{id:"babel-react-native-preset",reason:"Babel config loaders load the configured React Native preset.",from:fe,to:{package:"@react-native/babel-preset",path:/^(?:src\/)?index\.js$/u}},{id:"babel-reanimated-plugin",reason:"Babel config loaders load the configured Reanimated plugin, including scoped copies.",from:fe,to:{package:/^(?:@[^/]+\/)?react-native-reanimated$/u,path:/^plugin\/index\.js$/u}},{id:"babel-transform-plugin",reason:"Babel config loaders load configured transform plugins.",from:fe,to:{package:/^@babel\/plugin-transform-[^/]+$/u,path:/^lib\/index\.js$/u}},{id:"cosmiconfig-config",reason:"Cosmiconfig loads discovered configuration, including dependency configuration.",from:{package:"cosmiconfig",path:/^dist\/loaders\.js$/u},to:{path:/\.config\.js$/u}},{id:"import-fresh-own-config",reason:"import-fresh loads host-project configuration.",from:{package:"import-fresh",path:/./u},to:{path:/\.config\.js$/u},ownSourceOnly:!0}].map(e=>Object.freeze({...e,from:Object.freeze(e.from),to:Object.freeze(e.to)})));function it(e){return typeof e=="string"&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>t!==""&&t!=="."&&t!==".."&&t!=="node_modules")}function rt(e,t){let n=e.package;return n!==void 0&&t.ownSource===!0?!1:(n===void 0||(typeof n=="string"?n===t.package:n.test(t.package??"")))&&e.path.test(t.path)}function pe(e,t){if(!(e?.ownSource===!0||!it(e?.path)||!it(t?.path)))return st.find(n=>(!n.ownSourceOnly||t.ownSource===!0)&&rt(n.from,e)&&rt(n.to,t))}function ct(e,t){let o=e.split(/(?:^|\/)node_modules\//u).slice(1).at(-1)?.match(/^(@[^/]+\/[^/]+|[^/]+)\/(.+)$/u);return{package:o?.[1],path:o?.[2]??e.replace(/^\/+/u,""),ownSource:t??Ce(e)==="__own__"}}function de(e,t,n,o){return!pe(ct(e,o),ct(t,n))}function jo(e,t=n=>n.file){let n=new Map(e.nodes.map(i=>[i.file,i])),o=new Map(e.nodes.map(i=>[t(i),new Set]));for(let[i,r]of e.importsOf){let s=n.get(i);if(s)for(let l of r){let a=n.get(l);a&&de(s.origFile??i,a.origFile??l,e.ownSourceFiles?.has(l),e.ownSourceFiles?.has(i))&&o.get(t(s)).add(t(a))}}return o}var ge=class{constructor(t){this.nodes=[...t];for(let[n,o]of this.nodes.entries())o.position=n;for(let n=(this.nodes.length>>1)-1;n>=0;n--)this.down(n)}before(t,n){return Math.abs(t.balance)>Math.abs(n.balance)||Math.abs(t.balance)===Math.abs(n.balance)&&(t.balance>n.balance||t.balance===n.balance&&t.tie<n.tie)}swap(t,n){let o=this.nodes,i=o[t];o[t]=o[n],o[n]=i,o[t].position=t,o[n].position=n}down(t){let n=this.nodes;for(;2*t+1<n.length;){let o=2*t+1;if(o+1<n.length&&this.before(n[o+1],n[o])&&o++,!this.before(n[o],n[t]))break;this.swap(t,o),t=o}}update(t){if(t.position<0)return;let n=t.position;for(;n>0;){let o=n-1>>1;if(!this.before(t,this.nodes[o]))break;this.swap(n,o),n=o}this.down(n)}take(){let t=this.nodes[0],n=this.nodes.pop();return t.position=-1,this.nodes.length>0&&(this.nodes[0]=n,n.position=0,this.down(0)),t}};function qt(e,t){for(let n=0;n<8;n++){let o=!1;for(let i=0;i<e.length-1;i++){let r=n%2?e.length-2-i:i,s=e[r],l=e[r+1];(t.get(l)?.get(s)?.cycleCount??0)<=(t.get(s)?.get(l)?.cycleCount??0)||(e[r]=l,e[r+1]=s,o=!0)}if(!o)break}return e}function Yt(e){let t=[],n=new Set;for(let o of e.values())o.outgoing.sort((i,r)=>r[1]-i[1]||i[0].tie-r[0].tie);for(let o of e.values()){if(n.has(o))continue;let i=[{node:o,next:0}];for(n.add(o);i.length>0;){let r=i.at(-1);if(r.next===r.node.outgoing.length){t.push(r.node.id),i.pop();continue}let s=r.node.outgoing[r.next++][0];n.has(s)||(n.add(s),i.push({node:s,next:0}))}}return t.toReversed()}function he(e,t){let n=new Map(e.map((i,r)=>[i,r])),o=0;for(let i of t.values())for(let[r,s]of i.outgoing)n.get(i.id)<n.get(r.id)&&(o+=s);return o}function Jt(e,t){let n=he(e,t),o=n,i=0;for(let r=0;r<e.length-1;r++)n-=t.get(e[r]).originalBalance,n>o&&(o=n,i=r+1);return[...e.slice(i),...e.slice(0,i)]}function at(e,t){if(e.length<2)return e;let n=new Map(e.map((a,u)=>[a,{id:a,tie:u,balance:0,incoming:[],outgoing:[]}]));for(let a of n.values())for(let u of t.get(a.id)?.values()??[]){let p=n.get(u.to);!p||p===a||!u.cycleCount||(a.outgoing.push([p,u.cycleCount]),p.incoming.push([a,u.cycleCount]),a.balance+=u.cycleCount,p.balance-=u.cycleCount)}for(let a of n.values())a.originalBalance=a.balance;let o=[],i=new ge(n.values()),r=[];for(;i.nodes.length>0;){let a=i.take();a.balance>=0?o.push(a.id):r.push(a.id);for(let[u,p]of a.outgoing)u.position<0||(u.balance+=p,i.update(u));for(let[u,p]of a.incoming)u.position<0||(u.balance-=p,i.update(u))}let s=e,l=he(e,n);for(let a of[[...o,...r.toReversed()],Yt(n),e,e.toReversed()]){let u=qt(Jt(a,n),t),p=he(u,n);p>l&&(s=u,l=p)}return s}function Xt(e,t){let n=new Set(e),o=new Map(e.map(a=>[a,[]]));for(let[a,u]of t)for(let p of u)n.has(a)&&n.has(p)&&o.get(p).push(a);let i=[],r=new Set;for(let a of e){if(r.has(a))continue;r.add(a);let u=[[a,(t.get(a)??[])[Symbol.iterator]()]];for(;u.length>0;){let[p,g]=u.at(-1),h=g.next();if(h.done){i.push(p),u.pop();continue}n.has(h.value)&&!r.has(h.value)&&(r.add(h.value),u.push([h.value,(t.get(h.value)??[])[Symbol.iterator]()]))}}let s=new Map,l=[];for(let a of i.toReversed()){if(s.has(a))continue;let u=[],p=l.length,g=[a];for(s.set(a,p);g.length>0;){let h=g.pop();u.push(h);for(let y of o.get(h))s.has(y)||(s.set(y,p),g.push(y))}l.push(u.toSorted())}return{groups:l,componentOf:s}}function Uo(e,{expanded:t=new Set,order:n="structure",query:o="",neighborhood:i=null,cyclesOnly:r=!1}={}){let s=new Map,l=new Map,a=new Map;for(let c of e.nodes){let d=t.has(c.pkg),f=`${d?"f":"p"}:${d?c.file:c.pkg}`;s.has(f)||s.set(f,{id:f,pkg:c.pkg,file:d?c.file:null,label:d?c.file:Ie(c.pkg),files:[],size:0,issues:0,incoming:0,outgoing:0,importers:0,dependencies:0});let v=s.get(f);v.files.push(c.file),v.size+=c.size??0,v.issues+=c.totalIssues??0,l.set(c.file,f),a.set(c.file,c.origFile??c.file)}let u=new Map,p=new Set,g=new Set,h=new Map([...s.keys()].map(c=>[c,new Set])),y=0;for(let[c,d]of e.importsOf){let f=l.get(c);if(f)for(let v of new Set(d)){let b=l.get(v);if(!b)continue;u.has(f)||u.set(f,new Map),u.get(f).has(b)||u.get(f).set(b,{from:f,to:b,count:0,cycleCount:0,examples:[]});let k=u.get(f).get(b);k.count++;let E=de(a.get(c),a.get(v),e.ownSourceFiles?.has(v),e.ownSourceFiles?.has(c));k.examples.length<80&&(!r||E)&&k.examples.push([c,v]),y++,s.get(f).outgoing++,s.get(b).incoming++,f!==b&&(g.add(f),p.add(b)),E&&(k.cycleCount++,(f!==b||s.get(f).file)&&h.get(f).add(b))}}let w=[...s.keys()].toSorted(),{groups:m,componentOf:x}=Xt(w,h),$=new Set(m.flatMap(c=>c.length>1||h.get(c[0]).has(c[0])?c:[]));for(let c of s.values())c.cyclic=$.has(c.id),c.component=x.get(c.id);let R=e.ownSourcePackages??new Set(e.layerRoots?.roots??[]),T=c=>c.pkg==="__own__"?0:R.has(c.pkg)?1:2,j=c=>p.has(c.id)&&g.has(c.id)?0:1,me=new Map(m.map((c,d)=>[d,c.reduce((f,v)=>Math.min(f,T(s.get(v))),2)])),F=(c,d)=>c.pkg.localeCompare(d.pkg)||c.label.localeCompare(d.label),J=new Map;if(n==="structure"){for(let c of m)if(!(c.length<2))for(let d of Map.groupBy(c,f=>T(s.get(f))).values()){let f=d.toSorted((v,b)=>F(s.get(v),s.get(b)));at(f,u).forEach((v,b)=>J.set(v,b))}}if(r){y=0,p.clear(),g.clear();for(let c of s.values())c.incoming=0,c.outgoing=0}for(let[c,d]of u){for(let f of d.values())if(f.cyclic=f.cycleCount>0&&$.has(c)&&x.get(c)===x.get(f.to)&&(c!==f.to||s.get(c).file!==null),!!r){if(!f.cyclic){d.delete(f.to);continue}f.count=f.cycleCount,y+=f.count,s.get(c).outgoing+=f.count,s.get(f.to).incoming+=f.count,c!==f.to&&(g.add(c),p.add(f.to))}d.size===0&&u.delete(c)}for(let[c,d]of u)for(let f of d.keys())c!==f&&(s.get(c).dependencies++,s.get(f).importers++);let D=o.trim().toLowerCase(),O=new Set(w.filter(c=>!D||s.get(c).files.some(d=>d.toLowerCase().includes(D))||s.get(c).label.toLowerCase().includes(D))),X=new Set(i?[i]:O);if(D||i)for(let[c,d]of u)for(let f of d.keys())(i?c===i:O.has(c))&&X.add(f),(i?f===i:O.has(f))&&X.add(c);let lt=(c,d)=>{if(n==="structure"){let b=me.get(c.component)-me.get(d.component);if(b)return b;let k=j(c)-j(d);if(k)return k;let E=c.component-d.component;if(E)return E}let f=T(c)-T(d);if(f)return f;if(n==="importers")return d.importers-c.importers||F(c,d);if(n==="imports")return d.dependencies-c.dependencies||F(c,d);let v=j(c)-j(d);if(v)return v;if(n==="structure"&&c.component===d.component){let b=(J.get(c.id)??0)-(J.get(d.id)??0);if(b)return b}return F(c,d)},be=[...s.values()].filter(c=>X.has(c.id)&&(!r||c.cyclic)).toSorted(lt),_=new Map(be.map((c,d)=>[c.id,d])),we=[];for(let[c,d]of u)if(_.has(c))for(let f of d.values())_.has(f.to)&&we.push({...f,row:_.get(c),col:_.get(f.to)});return{rows:be,byId:s,cells:u,visibleCells:we,index:_,matches:O,importCount:y,totalRows:s.size,cycleCount:m.filter(c=>$.has(c[0])).length}}export{tn as a,ln as b,H as c,ne as d,K as e,Ae as f,ft as g,oe as h,V as i,dt as j,gt as k,ht as l,mt as m,hn as n,jn as o,Fn as p,A as q,Dn as r,On as s,bt as t,Nn as u,Pn as v,Un as w,Bn as x,Gn as y,Ze as z,q as A,zn as B,Hn as C,Vn as D,Kn as E,Wn as F,Zn as G,qn as H,Yn as I,W as J,Jn as K,Xn as L,Qn as M,eo as N,se as O,to as P,no as Q,oo as R,Ft as S,io as T,ro as U,so as V,co as W,ao as X,Ht as Y,Vt as Z,lo as _,Y as $,po as aa,mo as ba,bo as ca,wo as da,vo as ea,yo as fa,ko as ga,Ro as ha,So as ia,_o as ja,Eo as ka,tt as la,de as ma,jo as na,at as oa,Xt as pa,Uo as qa};
24
- /*! Bundled license information:
25
-
26
- lit-html/directives/class-map.js:
27
- lit-html/directives/style-map.js:
28
- (**
29
- * @license
30
- * Copyright 2018 Google LLC
31
- * SPDX-License-Identifier: BSD-3-Clause
32
- *)
33
- */
@@ -1 +0,0 @@
1
- var a=["admin","manage","triage","view","none"];function p(e){return typeof e=="string"&&a.includes(e)}function c(e,o){let n=a.indexOf(e);return n!==-1&&n<=a.indexOf(o)}function s(e){if(!e?.startsWith("#public="))return null;let o=/^#public=([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{43})$/u.exec(e);return o?{id:o[1],token:o[2]}:{id:"",token:""}}var l=globalThis.location?.hash,i=s(l);globalThis.addEventListener?.("hashchange",()=>{let e=globalThis.location?.hash;e?.startsWith("#public=")&&e!==l&&globalThis.location.reload()});function h(){return i}function d(e=i){return`/api/shares/${encodeURIComponent(e.id)}/workspace`}function g(e,o=i){return o?`${e.replace(/#.*$/su,"")}#public=${o.id}.${o.token}`:e}function f(e=null){let o=["anthropic/claude-opus-5.5","anthropic/claude-fable-5.1","anthropic/claude-sonnet-5.5","anthropic/claude-haiku-5.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","mistralai/mistral-large-4-0"],n=e==="moonshot"?"moonshotai":e,r=o.filter(t=>!["anthropic","openai","moonshot"].includes(e??"")||t.startsWith(`${n}/`)).map(t=>({id:t,efforts:["low","medium","high","xhigh","max"]}));return{models:r,defaultModel:r[0].id}}export{a,p as b,c,f as d,s as e,h as f,d as g,g as h};
@@ -1,2 +0,0 @@
1
- import{a,c as i,j as r}from"./chunk-2XUEZHIP.js";var s=`:host{display:inline-flex;flex-shrink:0;vertical-align:middle;--switch-track-width: 26px;--switch-track-height: 14px}button,.checkbox-mode{align-items:center;gap:8px;box-sizing:border-box;height:30px;margin:0;padding:0 .6rem;border:1px solid var(--border);border-radius:var(--ui-radius, 4px);background:transparent;color:var(--muted);font:inherit;font-size:.78rem;font-weight:500;line-height:1;white-space:nowrap;cursor:default}button{display:var(--switch-button-display, inline-flex);&:hover:not(:disabled){color:var(--text);background:rgb(from var(--text) r g b / .04)}&[aria-pressed=true]{color:var(--text)}&:disabled{opacity:.4}&:focus-visible{outline:1px solid var(--accent);outline-offset:-2px}}.checkbox-mode{display:var(--switch-checkbox-display, none);border:0;color:var(--text);&:has(:disabled){opacity:.4}& input{width:.85rem;height:.85rem;margin:0;accent-color:var(--accent)}}.track{position:relative;flex-shrink:0;width:var(--switch-track-width);height:var(--switch-track-height);background:var(--border);border-radius:var(--ui-radius, 8px);transition:background .15s;&:after{content:"";position:absolute;top:2px;left:2px;width:calc(var(--switch-track-height) - 4px);height:calc(var(--switch-track-height) - 4px);border-radius:50%;background:var(--muted);transition:transform .15s,background .15s}}button[aria-pressed=true] .track{background:color-mix(in oklch,var(--accent) 22%,transparent);&:after{transform:translate(calc(var(--switch-track-width) - var(--switch-track-height)));background:var(--accent)}}:host([borderless]) :is(button,.checkbox-mode){height:100%;border:0;border-radius:0}:host([compact]){--switch-track-width: 22px;--switch-track-height: 12px}:host([compact]) :is(button,.checkbox-mode){height:auto;gap:7px;padding:2px 8px;border-radius:var(--ui-radius, 6px);font-size:.68rem;line-height:1.2}
2
- `;var t=class extends r{static properties={checked:{type:Boolean,reflect:!0},disabled:{type:Boolean,reflect:!0},label:{type:String},accessibleLabel:{type:String,attribute:"accessible-label"}};static styles=a(s);constructor(){super(),this.checked=!1,this.disabled=!1,this.label="",this.accessibleLabel=""}_checkboxClick(e){(this.disabled||e.target.tagName!=="INPUT")&&e.stopPropagation()}render(){return i`<button type="button" part="button" aria-pressed="${String(this.checked)}" aria-label="${this.accessibleLabel||this.label}" ?disabled="${this.disabled}"><span>${this.label}</span><span class="track" part="track" aria-hidden="true"></span></button> <label class="checkbox-mode" @click="${this._checkboxClick}"><input type="checkbox" part="checkbox" .checked="${this.checked}" ?disabled="${this.disabled}" aria-label="${this.accessibleLabel||this.label}"> <span>${this.label}</span></label>`}};customElements.get("mode-switch")||customElements.define("mode-switch",t);
@@ -1 +0,0 @@
1
- var r="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="M11.998 24c-.321 0-.641-.084-.922-.247l-2.936-1.737c-.438-.245-.224-.332-.08-.383c.585-.203.703-.25 1.328-.604c.065-.037.151-.023.218.017l2.256 1.339c.082.045.197.045.272 0l8.795-5.076c.082-.047.134-.141.134-.238V6.921c0-.099-.053-.192-.137-.242l-8.791-5.072c-.081-.047-.189-.047-.271 0L3.075 6.68C2.99 6.729 2.936 6.825 2.936 6.921v10.15c0 .097.054.189.139.235l2.409 1.392c1.307.654 2.108-.116 2.108-.89V7.787c0-.142.114-.253.256-.253h1.115c.139 0 .255.112.255.253v10.021c0 1.745-.95 2.745-2.604 2.745c-.508 0-.909 0-2.026-.551L2.28 18.675c-.57-.329-.922-.945-.922-1.604V6.921c0-.659.353-1.275.922-1.603l8.795-5.082c.557-.315 1.296-.315 1.848 0l8.794 5.082c.57.329.924.944.924 1.603v10.15c0 .659-.354 1.273-.924 1.604l-8.794 5.078C12.643 23.916 12.324 24 11.998 24zM19.099 13.993c0-1.9-1.284-2.406-3.987-2.763c-2.731-.361-3.009-.548-3.009-1.187c0-.528.235-1.233 2.258-1.233c1.807 0 2.473.389 2.747 1.607c.024.115.129.199.247.199h1.141c.071 0 .138-.031.186-.081c.048-.054.074-.123.067-.196c-.177-2.098-1.571-3.076-4.388-3.076c-2.508 0-4.004 1.058-4.004 2.833c0 1.925 1.488 2.457 3.895 2.695c2.88.282 3.103.703 3.103 1.269c0 .983-.789 1.402-2.642 1.402c-2.327 0-2.839-.584-3.011-1.742c-.02-.124-.126-.215-.253-.215h-1.137c-.141 0-.254.112-.254.253c0 1.482.806 3.248 4.655 3.248C17.501 17.007 19.099 15.91 19.099 13.993z",t='<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>',o='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 1h14v14H1Zm3 3v8h4V6h2v6h2V4Z"/></svg>',i='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="4" width="11" height="9" rx="1.2"/><path d="M6 4V3h4v1"/></svg>',l='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="m4.5 4.5 7 2-5 5z"/><circle cx="4.5" cy="4.5" r="2" fill="currentColor"/><circle cx="11.5" cy="6.5" r="2" fill="currentColor"/><circle cx="6.5" cy="11.5" r="2" fill="currentColor"/></svg>',h='<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><rect x="1" y="1.5" width="14" height="3" rx=".5"/><rect x="1" y="6.5" width="8" height="3" rx=".5"/><rect x="11" y="6.5" width="4" height="3" rx=".5"/><rect x="1" y="11.5" width="4" height="3" rx=".5"/><rect x="7" y="11.5" width="8" height="3" rx=".5"/></svg>',n='<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M1 1h4v4H1zm5 5h4v4H6zm5 5h4v4h-4z"/><path d="M6 1h4v4H6zm5 0h4v4h-4zM1 6h4v4H1zm10 0h4v4h-4zM1 11h4v4H1zm5 0h4v4H6z" opacity=".35"/></svg>',c='<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>',d='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>',s='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6.67 8.67a3.33 3.33 0 0 0 5.03.36l2-2a3.33 3.33 0 0 0-4.71-4.71l-1.15 1.14"/><path d="M9.33 7.33a3.33 3.33 0 0 0-5.03-.36l-2 2a3.33 3.33 0 0 0 4.71 4.71l1.14-1.14"/></svg>',a='<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>',v='<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>',u='<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>',x='<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>',g='<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>',p='<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>',w='<svg viewBox="0 0 16 16" width="12" height="12" 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>',C='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 4-8 8H2v-4l8-8Zm-1 1 4 4"/></svg>',k='<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>';export{r as a,e as b,t as c,o as d,i as e,l as f,h as g,n as h,c as i,d as j,s as k,a as l,v as m,u as n,x as o,g as p,p as q,w as r,C as s,k as t};
@@ -1 +0,0 @@
1
- import{a as Ne}from"./chunk-GJ4IUCNS.js";import{a as V,b as N}from"./chunk-PNHBZGDD.js";import{a as d,c as m}from"./chunk-TUII34K2.js";var v=new Uint8Array([68,86,69,49]),$=12,st=32,ct="deepview-passkey.v1.content-key";function q(){return!(typeof window>"u"||typeof PublicKeyCredential>"u"||typeof navigator>"u"||!navigator.credentials)}async function $e(){if(typeof PublicKeyCredential>"u")return!1;let e=PublicKeyCredential.getClientCapabilities;if(typeof e!="function")return null;try{let t=await e.call(PublicKeyCredential);if(!t||typeof t!="object")return null;let r=t["extension:prf"],n=t.prf;return r===!0||n===!0?!0:r===!1||n===!1?!1:null}catch{return null}}function Z(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),t}async function he(e){if(e.length<32)throw new Error(`PRF output too short (${e.length} bytes; need \u2265 32)`);let t=await crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveBits"]),r=await crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:new Uint8Array,info:d(ct)},t,st*8);return new Uint8Array(r)}function ve(e){return crypto.subtle.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt","decrypt"])}async function A(e,t,r){let n=Z($),a=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:n,additionalData:r},e,t)),o=new Uint8Array(v.length+$+a.length);return o.set(v,0),o.set(n,v.length),o.set(a,v.length+$),o}async function O(e,t,r){if(!E(t))throw new Error("passkey: missing envelope magic");if(t.length<v.length+$+16)throw new Error("passkey: envelope too short");let n=t.subarray(v.length,v.length+$),a=t.subarray(v.length+$);return new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:n,additionalData:r},e,a))}function E(e){if(e.length<v.length)return!1;for(let t=0;t<v.length;t++)if(e[t]!==v[t])return!1;return!0}async function Te(e){if(!q())throw new Error("passkey: not supported in this environment");let t=Z(32),r=Z(32),n=await navigator.credentials.create({publicKey:{challenge:t,rp:{name:e.rpName,id:e.rpId},user:{id:e.userId,name:e.userName,displayName:e.userName},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"required"},extensions:{prf:{eval:{first:r}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(n instanceof PublicKeyCredential))throw new Error("passkey: registration returned no credential");let a=new Uint8Array(n.rawId).toBase64({alphabet:"base64url",omitPadding:!0}),o=n.getClientExtensionResults().prf,i=o?.results?.first?new Uint8Array(o.results.first):null;return{credentialId:a,prfSalt:r.toBase64({alphabet:"base64url",omitPadding:!0}),prfOutput:i}}async function Ee(e){if(!q())throw new Error("passkey: not supported in this environment");let t=Z(32),r=Uint8Array.fromBase64(e.credentialId,{alphabet:"base64url"}),n=Uint8Array.fromBase64(e.prfSalt,{alphabet:"base64url"}),a=await navigator.credentials.get({publicKey:{challenge:t,rpId:e.rpId,allowCredentials:[{type:"public-key",id:r}],userVerification:"required",extensions:{prf:{eval:{first:n}}},timeout:e.timeoutMs??12e4},...e.signal?{signal:e.signal}:{}});if(!(a instanceof PublicKeyCredential))throw new Error("passkey: assertion returned no credential");let i=a.getClientExtensionResults().prf?.results?.first;if(!i)throw new Error("passkey: authenticator did not return PRF output (extension unsupported)");return new Uint8Array(i)}var T=Object.freeze(["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.sync.password","deepview.repoUrls","deepview.fileCounts","deepview.workspaceApp","deepview.lastFile","deepview.scan.access"]),p=new Map,ee=!1,S=new Map,w=new Map,Q=new Set;function Kt(e){let t=()=>e();return Q.add(t),ee&&queueMicrotask(()=>{if(Q.has(t))try{t()}catch(r){console.warn("secure-storage after-hydrate listener:",r)}}),()=>Q.delete(t)}function lt(){for(let e of Q)try{e()}catch(t){console.warn("secure-storage after-hydrate listener:",t)}}function re(e){let t=Re()??"";return d(`deepview.secure.v1|${t}|${e}`)}function be(e){try{let t=Uint8Array.fromBase64(e);if(E(t))return t}catch{}return null}function me(e){return p.get(e)??null}async function He(e,t){if(typeof t!="string")throw new TypeError("secure-storage: value must be a string");if(x()&&!y())throw new Error(`secure-storage: vault locked, cannot save "${e}"`);if(Le())throw new Error(`secure-storage: wipe in progress, cannot save "${e}"`);let r=p.has(e),n=p.get(e);p.set(e,t),w.set(e,t);let a=S.get(e)??Promise.resolve(),o=()=>{w.get(e)===t&&w.delete(e)},i=a.catch(()=>{}).then(()=>ut(e,t)).then(()=>o(),s=>{throw o(),p.get(e)===t&&(r?p.set(e,n):p.delete(e)),s});S.set(e,i.catch(()=>{})),await i}async function _t(e){let t=Symbol("secure-storage:removed");p.delete(e),w.set(e,t);let r=S.get(e)??Promise.resolve(),n=()=>{try{localStorage.removeItem(e)}catch{}w.get(e)===t&&(w.delete(e),p.delete(e))},a=r.catch(()=>{}).then(()=>n());S.set(e,a.catch(()=>{})),await a}async function ut(e,t){let r=y();if(r){let n=await A(r,d(t),re(e));localStorage.setItem(e,n.toBase64())}else localStorage.setItem(e,t)}async function Se(){ee||te(()=>{Se().catch(e=>console.warn("secure-storage rehydrate:",e))}),ee=!0;for(let e of[...p.keys()])w.has(e)||p.delete(e);await Ve(T,!0)}async function Mt(e){if(!T.includes(e))throw new Error(`secure-storage: unknown secure key "${e}"`);return w.has(e)||p.delete(e),(await Ve([e],!1)).get(e)??null}async function Ve(e,t){let r=y(),n=[],a=new Map;for(let o of e){if(w.has(o)){a.set(o,me(o));continue}let i=localStorage.getItem(o);if(i===null)continue;let s=be(i);if(s){if(!r)continue;try{let c=await O(r,s,re(o));if(w.has(o)){a.set(o,me(o));continue}let u=m(c);p.set(o,u),a.set(o,u)}catch(c){console.warn(`secure-storage: decrypt failed for "${o}":`,c)}}else p.set(o,i),a.set(o,i),r&&x()&&n.push([o,i])}return t&&lt(),n.length>0&&queueMicrotask(()=>{for(let[o,i]of n)p.get(o)===i&&He(o,i).catch(s=>{console.warn(`secure-storage: self-heal failed for "${o}":`,s)})}),a}async function qe(e,t){let r=S.get(e)??Promise.resolve(),n=async()=>{if(w.has(e))return;let o=localStorage.getItem(e);if(o===null)return;let i=await t(o);i!==null&&(w.has(e)||(localStorage.setItem(e,i.storageValue),p.set(e,i.cacheValue)))},a=r.catch(()=>{}).then(n);S.set(e,a.catch(()=>{})),await a}async function Nt({seal:e}){for(let t of T)await qe(t,async r=>{if(be(r))return null;let n=y();return n?{storageValue:(await A(n,d(r),re(t))).toBase64(),cacheValue:r}:null})}async function $t({open:e}){for(let t of T)await qe(t,async r=>{let n=be(r);if(!n)return null;let a=await e(n,re(t)),o=m(a);return{storageValue:o,cacheValue:o}})}var ft="deepview.secure.v1.mutate:";function Tt(e,t){return T.includes(e)?navigator.locks.request(ft+e,async()=>{let r=S.get(e);r&&await r.catch(()=>{}),await Se();let n=me(e),a=await t(n);if(!(a==null||a===n)){if(typeof a!="string")throw new TypeError(`secure-storage: mutate updater for "${e}" must return a string`);await He(e,a)}}):Promise.reject(new Error(`secure-storage: mutate() called with non-secure key "${e}"`))}async function We(){await Promise.allSettled([...S.values()]),w.clear(),S.clear()}typeof window<"u"&&window.addEventListener("storage",e=>{!ee||!e.key||!T.includes(e.key)||Se().catch(()=>{})});var G="deepview.passkey.v1",L="deepview.passkey.userId",ae="deepview.passkey.cleanDisable",F="deepview.passkey.v1.write",dt="deepview.triage.v1|",pt="deepview.opfs.v1|",wt="deepview.bundle.v1|",l=null,b=null,I=null,j=0;function qt(){return j>0}var xe=0;function Le(){return xe>0}function C(){try{let e=localStorage.getItem(G);if(!e)return null;let t=JSON.parse(e);return t&&typeof t=="object"&&t.enabled===!0&&typeof t.credentialId=="string"&&t.credentialId.length>0&&typeof t.prfSalt=="string"&&t.prfSalt.length>0&&typeof t.userId=="string"&&t.userId.length>0?t:null}catch{return null}}function je(e){localStorage.setItem(G,JSON.stringify(e))}function yt(){localStorage.removeItem(G)}function gt(){try{let t=localStorage.getItem(L);if(t){let r=Uint8Array.fromBase64(t,{alphabet:"base64url"});if(r.length===16)return r}}catch{}let e=new Uint8Array(16);crypto.getRandomValues(e);try{localStorage.setItem(L,e.toBase64({alphabet:"base64url",omitPadding:!0}))}catch{}return e}function oe(){return typeof location>"u"?"":location.hostname}function x(){return C()!==null}function ht(){return l!==null}function Wt(){return!(!q()||typeof navigator>"u"||!navigator.locks?.request||!oe())}function Re(){return b}function vt(){if(C()!==null)return!1;try{return localStorage.getItem(ae)==="1"?!1:localStorage.getItem(L)!==null}catch{return!1}}function y(){return l}function Ge(){return d(dt+(b??""))}function ie(e){if(typeof e!="string")throw new TypeError("passkey vault: OPFS AAD requires a filename string");return d(pt+(b??"")+"|"+e)}function se(e){if(typeof e!="string")throw new TypeError("passkey vault: bundle AAD requires a slot string");return d(wt+(b??"")+"|"+e)}var Ae=new Set;function te(e){return Ae.add(e),()=>Ae.delete(e)}function R(){for(let e of Ae)try{e()}catch(t){console.warn("passkey vault listener:",t)}}async function jt({signal:e}={}){let t=C();if(!t)return!1;let r;try{r=await Ee({credentialId:t.credentialId,prfSalt:t.prfSalt,rpId:t.rpId??oe(),...e?{signal:e}:{}})}catch(a){if(a&&a.name==="NotAllowedError"||a&&a.name==="AbortError")return!1;throw a&&a.message?.includes("PRF")?W(a):a}if(!r||r.length<32)throw W();let n=await he(r);return r.fill(0),navigator.locks.request(F,async()=>{let a=C();if(!a||a.credentialId!==t.credentialId)throw n.fill(0),new Error("passkey: vault state changed during unlock (another tab wiped or re-enabled it). Reload this page and try again.");return l=await ve(n),n.fill(0),b=a.userId,I=a.credentialId,R(),!0})}function W(e){let t=new Error("Your browser or authenticator doesn't support passkey-derived encryption keys (the WebAuthn PRF extension). Try Chrome 116+, Safari 18+, or Firefox 130+ on a device with a platform authenticator (TouchID / Windows Hello).");return e&&(t.cause=e),t}function Gt({migrate:e,userName:t,rpName:r,signal:n,acknowledgeOrphan:a}){if(!q())throw new Error("passkey: WebAuthn unavailable in this environment");if(vt()&&!a)throw new Error("passkey: a previous vault exists on this device with no metadata. Any data encrypted under the old passkey will be unreadable after a new setup. Call enableEncryption({acknowledgeOrphan: true}) to proceed, or wipeAllVaultData() to start clean first.");let o=oe();return navigator.locks.request(F,async()=>{if(x())throw new Error("passkey: encryption is already enabled");if(await $e()===!1)throw W();let s=gt(),c=await Te({userName:t||"DeepView user",userId:s,rpName:r||"DeepView",rpId:o,...n?{signal:n}:{}}),u=c.prfOutput;if(!u)try{u=await Ee({credentialId:c.credentialId,prfSalt:c.prfSalt,rpId:o,...n?{signal:n}:{}})}catch(P){let ge=s.toBase64({alphabet:"base64url",omitPadding:!0});await ne({credentialId:c.credentialId,rpId:o,userId:ge}).catch(()=>{});try{localStorage.removeItem(L)}catch{}throw P&&P.message?.includes("PRF")?W(P):P}if(!u||u.length<32){let P=s.toBase64({alphabet:"base64url",omitPadding:!0});await ne({credentialId:c.credentialId,rpId:o,userId:P}).catch(()=>{});try{localStorage.removeItem(L)}catch{}throw W()}let h=await he(u);u.fill(0);let M=await ve(h);h.fill(0);let Me=s.toBase64({alphabet:"base64url",omitPadding:!0}),ot={enabled:!0,credentialId:c.credentialId,prfSalt:c.prfSalt,userId:Me,rpId:o,createdAt:Date.now()};l=M,b=Me,I=c.credentialId,je(ot),typeof e=="function"&&await e({seal:(ge,it)=>A(M,ge,it)});try{localStorage.removeItem(ae)}catch{}return R(),!0})}async function Jt({migrate:e}){if(!x())return{disabled:!1,signalAttempted:!1};if(!ht())throw new Error("passkey: must unlock before disabling encryption");j+=1;try{return await navigator.locks.request(F,async()=>{let t=C();if(!t)return{disabled:!1,signalAttempted:!1};let r=l;if(!r)return{disabled:!1,signalAttempted:!1};if(yt(),l=null,I=null,typeof e=="function"){let a=(o,i)=>O(r,o,i);try{await e({open:a})}catch(o){throw je(t),l=r,I=t.credentialId,R(),o}}b=null;try{localStorage.setItem(ae,"1")}catch{}let n=await ne(t).catch(()=>!1);return R(),{disabled:!0,signalAttempted:n}})}finally{j-=1}}async function ne({credentialId:e,rpId:t,userId:r}){if(typeof PublicKeyCredential>"u"||!t)return!1;let n=PublicKeyCredential,a=!1;if(typeof n.signalUnknownCredential=="function"){a=!0;try{await n.signalUnknownCredential({rpId:t,credentialId:e})}catch{}}if(typeof n.signalAllAcceptedCredentials=="function"&&r){a=!0;try{await n.signalAllAcceptedCredentials({rpId:t,userId:r,allAcceptedCredentialIds:[]})}catch{}}return a}async function Et(e,t){try{return await e.removeEntry(t,{recursive:!0}),null}catch(r){return r?.name==="NotFoundError"?null:`${t}: ${r?.message??String(r)}`}}async function mt(e){let t=[];if(typeof navigator>"u"||!navigator.storage?.getDirectory)return t;let r;try{r=await navigator.storage.getDirectory()}catch(n){return t.push(`storage root: ${n?.message??String(n)}`),t}for(let n of e){let a=await Et(r,n);a&&t.push(a)}return t}async function Xt({refuseIfEnabled:e=!1}={}){j+=1,xe+=1;try{return await navigator.locks.request(F,async()=>{if(e&&x())throw new Error("passkey: encryption was just enabled in another tab. Reload this page to unlock instead of wiping.");await We();let t=C();if(t)try{await ne({credentialId:t.credentialId,rpId:t.rpId??oe(),userId:t.userId})}catch{}try{localStorage.removeItem(G)}catch{}try{localStorage.removeItem(L)}catch{}try{localStorage.removeItem(ae)}catch{}for(let n of["deepview.workspaces","deepview.sync.sessions","deepview.sync.userEnabled","deepview.repoUrls","deepview.fileCounts","deepview.workspaceApp","deepview.lastFile","deepview.scan.access","deepview.triage","deepview.triage.pending","deepview.passkey.firstImportPrompted","deepview.viewMode"])try{localStorage.removeItem(n)}catch{}try{let n=[];for(let a=0;a<localStorage.length;a+=1){let o=localStorage.key(a);o&&o.startsWith("deepview.report:")&&n.push(o)}for(let a of n)try{localStorage.removeItem(a)}catch{}}catch{}l=null,b=null,I=null,R();let r=await mt(["deepview-reports","deepview-bundles"]);if(r.length>0)throw new Error(`passkey: wipe partially succeeded \u2014 localStorage cleared but the following OPFS paths could not be removed: ${r.join("; ")}. Open DevTools \u2192 Application \u2192 Storage \u2192 Origin Private File System to inspect, or use the browser's site-data clear tool to finish.`)})}finally{j-=1,xe-=1}}function zt(e){return l?A(l,e,Ge()):Promise.reject(new Error("passkey: vault locked, cannot seal triage"))}function Yt(e){return l?O(l,e,Ge()):Promise.reject(new Error("passkey: vault locked, cannot open triage"))}function ce(e,t){return l?A(l,e,ie(t)):Promise.reject(new Error("passkey: vault locked, cannot seal OPFS file"))}function Je(e,t){return l?O(l,e,ie(t)):Promise.reject(new Error("passkey: vault locked, cannot open OPFS file"))}function le(e,t){return l?A(l,e,se(t)):Promise.reject(new Error("passkey: vault locked, cannot seal bundle"))}function ue(e,t){return l?O(l,e,se(t)):Promise.reject(new Error("passkey: vault locked, cannot open bundle"))}typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key!==G)return;let t=C();(!t&&l||t&&l&&t.credentialId!==I)&&(l=null,b=null,I=null),R()});var ke="__meta__",bt="deepview-reports",Ue="deepview-bundles",k="deepview.report:";function Ze(e,t,r,n){return navigator.locks.request(`deepview-storage/${e}/${t}`,{mode:r},n)}function nr(e,t,r){return Ze(e,t,"shared",r)}function z(e,t,r){return Ze(e,t,"exclusive",()=>navigator.locks.request(F,{mode:"shared"},r))}var Xe=!1;async function Pe(e,{create:t,warnOnce:r=!1}={}){try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(e,{create:t})}catch(n){return r&&!Xe&&(Xe=!0,console.warn("OPFS unavailable, falling back to gzipped localStorage (limited quota).",n)),null}}async function Y(e,t){let r=await e.createWritable();try{await r.write(t),await r.close()}catch(n){try{await r.abort(n)}catch{}throw n}}async function Oe(e,t){if(!E(e))return e;if(!y())throw new Error(`storage: vault locked, cannot decrypt "${t}"`);return await Je(e,t)}function we(e){return e.length===0?!0:e.length>=18&&e[0]===31&&e[1]===139&&e.at(-4)===0&&e.at(-3)===0&&e.at(-2)===0&&e.at(-1)===0}async function Ce(e,t){J(e)===t&&(console.warn(`storage: report "${e}" is an empty/corrupt on-disk entry \u2014 quarantining, will read as missing`),await navigator.locks.request(F,{mode:"exclusive"},async()=>{if(J(e)!==t)return;f(e),g.delete(e);let r=await U();if(r)try{await r.removeEntry(e)}catch{}ye(e),f(e),D(e,"delete")}))}async function De(e,t,r){try{(await t.getFile()).size===0&&await e.removeEntry(r)}catch{}}async function H(e,t,r,n,a=()=>{}){if(x()&&!y())throw a(),new Error(`storage: vault locked, cannot save ${n}`);let o=y(),i=o?await t(e,r):e;if(y()!==o)throw a(),new Error(`storage: vault state changed mid-save for ${n}; retry`);return i}function U(){return Pe(bt,{create:!0,warnOnce:!0})}function fe(e){try{return localStorage.getItem(k+e)}catch{return null}}function ye(e){try{localStorage.removeItem(k+e)}catch{}}function St(){let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r&&r.startsWith(k)&&e.push(r.slice(k.length))}return e}var g=new Map,B=new Map,Ie=new Map;function f(e){Ie.set(e,(Ie.get(e)??0)+1)}function J(e){return Ie.get(e)??0}var Fe=new Set;function ar(e){return Fe.add(e),()=>Fe.delete(e)}function D(e,t){for(let r of Fe)try{r(e,t)}catch(n){console.warn("storage file-change listener:",n)}}async function xt(){let e=new Set(St()),t=await U();if(t)for await(let[r]of t.entries())e.add(r);return[...e].toSorted()}async function ze(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");if(t==="")throw new Error(`Refusing to save empty report "${e}"`);return f(e),z("report",e,async()=>{let r=await U();if(r){let o=await V(d(t));o=await H(o,ce,e,`"${e}"`,()=>f(e));let i=await r.getFileHandle(e,{create:!0}),s=await i.createWritable();try{await s.write(o),await s.close()}catch(c){g.delete(e),f(e);try{await s.abort(c)}catch{}throw await De(r,i,e),c}g.set(e,t),f(e),ye(e),D(e,"save");return}let n=d(t);n=await V(n),n=await H(n,ce,e,`"${e}"`,()=>f(e));let a=n.toBase64();try{localStorage.setItem(k+e,a),g.set(e,t),f(e),D(e,"save")}catch(o){throw f(e),new Error(`localStorage write failed for ${e}: ${o.message}`,{cause:o})}})}async function Ye(e,t){let r=fe(e);if(r===null)return null;let n=Uint8Array.fromBase64(r);if(n=await Oe(n,e),we(n))throw await Ce(e,t),new Error(`File not found: ${e}`);return m(await N(n))}async function or(e){if(g.has(e))return g.get(e);if(B.has(e))return B.get(e);let t=J(e),r=(async()=>{let n=await U();if(n){let o;try{o=await n.getFileHandle(e)}catch(u){if(u instanceof DOMException&&u.name==="NotFoundError"){let h=await Ye(e,t);if(h!==null)return ze(e,h).catch(M=>{console.warn(`storage: stranded-localStorage migration of "${e}" failed:`,M)}),h}throw u}let i=await o.getFile(),s=new Uint8Array(await i.arrayBuffer());if(s=await Oe(s,e),we(s))throw await Ce(e,t),new Error(`File not found: ${e}`);if(s.length>=2&&s[0]===31&&s[1]===139){let u=await N(s);return m(u)}let c=m(s);return ze(e,c).catch(u=>{console.warn(`storage: legacy-uncompressed migration of "${e}" failed:`,u)}),c}let a=await Ye(e,t);if(a===null)throw new Error(`File not found: ${e}`);return a})();B.set(e,r);try{let n=await r;return J(e)===t&&g.set(e,n),n}finally{B.delete(e)}}async function At(e){let t=J(e),r=await U(),n;if(r){let a=null;try{a=await r.getFileHandle(e)}catch(o){if(!(o instanceof DOMException)||o.name!=="NotFoundError")throw o;let i=fe(e);if(i===null)throw o;n=Uint8Array.fromBase64(i)}if(a){let o=await a.getFile();n=new Uint8Array(await o.arrayBuffer())}}else{let a=fe(e);if(a===null)throw new Error(`File not found: ${e}`);n=Uint8Array.fromBase64(a)}if(n=await Oe(n,e),we(n))throw await Ce(e,t),new Error(`File not found: ${e}`);return n}async function ir(e){let t=await At(e),r=t[0]===31&&t[1]===139?await N(t):t;return m(r)}async function sr(e,t){if(typeof e!="string"||e.includes("\0"))throw new Error("Invalid report name: contains NUL byte or is not a string");if(we(t))throw new Error(`Refusing to save empty report bytes for "${e}"`);return f(e),g.delete(e),z("report",e,async()=>{let r=await H(t,ce,e,`"${e}"`,()=>f(e)),n=await U();if(n){let a=await n.getFileHandle(e,{create:!0}),o=await a.createWritable();try{await o.write(r),await o.close()}catch(i){f(e);try{await o.abort(i)}catch{}throw await De(n,a,e),i}f(e),ye(e),D(e,"save");return}try{localStorage.setItem(k+e,r.toBase64()),f(e),D(e,"save")}catch(a){throw f(e),new Error(`localStorage write failed for ${e}: ${a.message}`,{cause:a})}})}async function cr(e){return f(e),g.delete(e),B.delete(e),z("report",e,async()=>{let t=await U();if(t){try{await t.removeEntry(e)}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw f(e),r}ye(e),f(e),D(e,"delete");return}localStorage.removeItem(k+e),f(e),D(e,"delete")})}var X="_meta.json",de=".index-v1",Be=new Set;function lr(e){return Be.add(e),()=>Be.delete(e)}function pe(e,t){for(let r of Be)try{r(e,t)}catch(n){console.warn("storage bundle-change listener:",n)}}function _(){return Pe(Ue,{create:!0})}function K(e){return e.replaceAll("/","_")}async function Ke(e){let t;try{let a=await(await e.getFileHandle(X)).getFile();t=new Uint8Array(await a.arrayBuffer())}catch(n){return n instanceof DOMException&&n.name==="NotFoundError"?[]:(console.warn("readBundleMeta: failed to read _meta.json:",n),[])}let r=t;if(E(t)){if(!y())return console.warn("readBundleMeta: vault locked, returning empty bundle list"),[];try{r=await ue(t,ke)}catch(a){return console.warn("readBundleMeta: decrypt failed (tampering, key mismatch, or vault identity drift):",a),[]}}try{let n=JSON.parse(m(r));return Array.isArray(n)?n:[]}catch(n){return console.warn("readBundleMeta: JSON.parse failed:",n),[]}}async function Qe(e,t){let r=d(JSON.stringify(t));r=await H(r,le,ke,"bundle metadata");try{await e.removeEntry(X)}catch{}let n=await e.getFileHandle(X,{create:!0});await Y(n,r)}var et=`${Ue}/${X}`;function _e(e){return navigator.locks.request(et,e)}async function ur(){let e=await _();return e?[...await navigator.locks.request(et,{mode:"shared"},()=>Ke(e))].toSorted((r,n)=>r.name.localeCompare(n.name)):[]}function fr(){return tt(()=>!0)}function dr(){return tt((e,t)=>t.kind==="file"&&/^sha512-[A-Za-z0-9+_]{86}==$/u.test(e))}async function tt(e){if(typeof navigator>"u"||!navigator.storage?.getDirectory)return!1;let t=await Pe(Ue,{create:!1});if(!t)return!1;try{for await(let[r,n]of t.entries())if(e(r,n))return!0}catch{}return!1}async function pr(e,t){let r=await _();if(!r)throw new Error(`Cannot save bundle ${e}: OPFS unavailable`);let n=t instanceof Uint8Array?t:d(t),a=await Ne(n),o=K(a),i=e.toLowerCase().endsWith(".map")?await V(n):n;return z("bundle",a,async()=>{i=await H(i,le,a,`bundle "${e}"`);try{await r.removeEntry(o)}catch{}let s=await r.getFileHandle(o,{create:!0});await Y(s,i);try{await _e(async()=>{let c=await Ke(r),u=c.findIndex(h=>h.integrity===a);u>=0?c[u]={integrity:a,name:e}:c.push({integrity:a,name:e}),await Qe(r,c)})}catch(c){try{await r.removeEntry(o),pe(a,"delete")}catch{}throw c}return pe(a,"save"),{integrity:a,name:e}})}async function wr(e){let t=await _();if(t)return z("bundle",e,async()=>{try{await t.removeEntry(K(e))}catch(r){if(!(r instanceof DOMException)||r.name!=="NotFoundError")throw r}pe(e,"delete");try{await _e(async()=>{try{await t.removeEntry(K(e)+de)}catch(a){if(!(a instanceof DOMException)||a.name!=="NotFoundError")throw a}let r=await Ke(t),n=r.filter(a=>a.integrity!==e);n.length!==r.length&&await Qe(t,n)})}finally{pe(e,"delete")}})}async function yr(e){let t=await _();if(!t)throw new Error("OPFS unavailable");let n=await(await t.getFileHandle(K(e))).getFile(),a=new Uint8Array(await n.arrayBuffer());if(E(a)){if(!y())throw new Error(`storage: vault locked, cannot read bundle "${e}"`);a=await ue(a,e)}return a.length>=2&&a[0]===31&&a[1]===139?await N(a):a}async function gr(e){let t=await _();if(!t||x()&&!y())return null;try{let r=await t.getFileHandle(K(e)+de),n=new Uint8Array(await(await r.getFile()).arrayBuffer());return E(n)&&(n=await ue(n,e+de)),JSON.parse(m(await N(n)))}catch{return null}}async function hr(e,t){let r=await V(d(JSON.stringify(t)));return navigator.locks.request(F,{mode:"shared"},()=>_e(async()=>{let n=await _();if(!n)return;await n.getFileHandle(K(e));let a=e+de,o=await H(r,le,a,"bundle index"),i=await n.getFileHandle(K(a),{create:!0});await Y(i,o)}))}async function It(e,t){let r=await U();if(r){let i=null;try{i=await r.getFileHandle(e)}catch(s){if(!(s instanceof DOMException)||s.name!=="NotFoundError")throw s}if(i){let s=await i.getFile(),c=new Uint8Array(await s.arrayBuffer()),u=await t(c);if(u===null)return;g.delete(e),B.delete(e),f(e);let h=await r.getFileHandle(e,{create:!0});try{await Y(h,u)}catch(M){throw await De(r,h,e),M}f(e);return}}let n=fe(e);if(n===null)return;let a=Uint8Array.fromBase64(n),o=await t(a);o!==null&&(g.delete(e),B.delete(e),f(e),localStorage.setItem(k+e,o.toBase64()),f(e))}function rt(e,t){return e.seal?r=>E(r)?null:e.seal(r,t):r=>E(r)?e.open(r,t):null}async function nt(e){let t=await xt();for(let r of t)try{await It(r,rt(e,ie(r)))}catch(n){if(n instanceof DOMException&&n.name==="NotFoundError")continue;throw n}}var vr=({seal:e})=>nt({seal:e}),Er=({open:e})=>nt({open:e});async function Ft(){let e=await _();if(!e)return{dir:null,keys:[]};let t=[];for await(let[r]of e.entries())t.push(r);return{dir:e,keys:t}}function Bt(e){return e===X?ke:e.startsWith("sha512-")?e.replaceAll("_","/"):null}async function kt(e,t,r){let a=await(await e.getFileHandle(t)).getFile(),o=new Uint8Array(await a.arrayBuffer()),i=await r(o);if(i===null)return;let s=await e.getFileHandle(t,{create:!0});await Y(s,i)}async function at(e){let{dir:t,keys:r}=await Ft();if(t)for(let n of r){let a=Bt(n);if(a!==null)try{await kt(t,n,rt(e,se(a)))}catch(o){if(o instanceof DOMException&&o.name==="NotFoundError")continue;throw o}}}var mr=({seal:e})=>at({seal:e}),br=({open:e})=>at({open:e});te(()=>{g.clear(),B.clear()});export{E as a,F as b,qt as c,x as d,ht as e,Wt as f,vt as g,y as h,Ge as i,te as j,jt as k,Gt as l,Jt as m,Xt as n,zt as o,Yt as p,Kt as q,me as r,He as s,_t as t,Se as u,Mt as v,Nt as w,$t as x,Tt as y,nr as z,ar as A,xt as B,ze as C,or as D,At as E,ir as F,sr as G,cr as H,lr as I,ur as J,fr as K,dr as L,pr as M,wr as N,yr as O,gr as P,hr as Q,vr as R,Er as S,mr as T,br as U};
@@ -1,7 +0,0 @@
1
- import{a}from"./chunk-TUII34K2.js";var v="deepview-objstore.v1.put",y="deepview-objstore.v1.delete",h="deepview-objstore.v1.fetch",I="deepview-objstore.v1.fetch-rest",w="deepview-objstore.v1.put-rest",j="deepview-objstore.v1.delete-rest";function l(e){return e==null?"":String(e)}function p(e){return e??""}function x(e,n){return a([v,e.workspaceTag,e.resourceTag,l(e.prevVersion),p(e.prevIncarnation),e.contentHash,String(e.expectedLength),n].join(`
2
- `))}function O(e,n){return a([y,e.workspaceTag,e.resourceTag,l(e.prevVersion),p(e.prevIncarnation),n].join(`
3
- `))}function P(e,n,r){return a([h,e,n,r].join(`
4
- `))}async function i(e,n){return new Uint8Array(await crypto.subtle.sign({name:"Ed25519"},e,n)).toBase64({alphabet:"base64url",omitPadding:!0})}function B(e,n,r){return i(e,x(n,r))}function D(e,n,r){return i(e,O(n,r))}function R(e,n,r,o){return i(e,P(n,r,o))}function A(e,n,r){return a([I,e,n,String(r)].join(`
5
- `))}function _(e,n,r,o){return i(e,A(n,r,o))}function N(e,n){return a([w,e.workspaceTag,e.resourceTag,l(e.prevVersion),p(e.prevIncarnation),e.contentHash,String(e.expectedLength),String(n)].join(`
6
- `))}function U(e,n,r){return i(e,N(n,r))}function T(e,n){return a([j,e.workspaceTag,e.resourceTag,l(e.prevVersion),p(e.prevIncarnation),String(n)].join(`
7
- `))}function L(e,n,r){return i(e,T(n,r))}async function H(e){let n=await crypto.subtle.digest("SHA-256",e);return new Uint8Array(n).toBase64({alphabet:"base64url",omitPadding:!0})}var m="/api/config";var J="http://127.0.0.1:3123/";function d(e){if(typeof e!="string"||!e.trim())return null;try{let n=new URL(e);return!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash?null:(n.pathname=n.pathname.replace(/\/+$/u,"")+"/",n.href)}catch{return null}}var b="deepview.sync.serverInfo",g="deepview.sync.standaloneProbe";function $(){try{return localStorage.getItem(g)==="1"}catch{return!1}}function X(){try{localStorage.setItem(g,"1")}catch{}}function f(e){return e==="managed+e2e"||e==="e2e+managed"}function q(e,n){return(e==="managed"||f(e))&&/^\/(?:team|manage|npm|my)(?:\/|$)/u.test(n)}function Q(e,n=null){return n&&(f(e)||e===n)?n:e==="managed"||e==="managed+e2e"?"managed":"e2e"}function W(e,n){return e&&f(e.mode)&&n.mode==="e2e"?{...e,githubNewIssueLabels:n.githubNewIssueLabels??"",...n.deepviewScanServer?{deepviewScanServer:n.deepviewScanServer}:{}}:n}function S(e){if(e==null||typeof e!="object")return null;let n=e.mode;if(n!=="e2e"&&n!=="managed"&&n!=="managed+e2e"&&n!=="e2e+managed")return null;let r=null,o=e.managed;if(o!=null&&typeof o=="object"){let u=o.loginPath,c=o.cookieName;typeof u=="string"&&typeof c=="string"&&(r={loginPath:u,cookieName:c},o.allowShare===!0&&(r.allowShare=!0))}let t=n==="managed"?null:d(e.deepviewScanServer),s=e.githubNewIssueLabels;return{mode:n,managed:r,...t?{deepviewScanServer:t}:{},...typeof s=="string"&&s.length<=4096?{githubNewIssueLabels:s}:{}}}async function Z(){try{let e=await fetch(m,{credentials:"same-origin",cache:"no-store",headers:{accept:"application/json"}});return e.status===404?"standalone":e.ok?S(await e.json()):null}catch{return null}}async function ee(e,n=3e3){let r;try{return await Promise.race([e,new Promise(o=>{r=setTimeout(()=>o(null),n)})])}catch{return null}finally{clearTimeout(r)}}function ne(){try{let e=localStorage.getItem(b);if(e==null)return null;let n=S(JSON.parse(e));return n?{mode:n.mode,managed:n.managed}:null}catch{return null}}function re(e){try{localStorage.setItem(b,JSON.stringify({mode:e.mode,managed:e.managed})),localStorage.removeItem(g)}catch{}}var E="deepview.objstore-presence.";function M(e){return E+e}function C(e){try{let n=localStorage.getItem(M(e));if(!n)return null;let r=JSON.parse(n);return!r||typeof r!="object"?null:{names:r.names&&typeof r.names=="object"?r.names:{},bundles:r.bundles&&typeof r.bundles=="object"?r.bundles:{},bundleNames:r.bundleNames&&typeof r.bundleNames=="object"?r.bundleNames:{},baselines:k(r.baselines,r.localVersions)}}catch{return null}}function k(e,n){let r={};if(n&&typeof n=="object")for(let[o,t]of Object.entries(n))Number.isSafeInteger(t)&&t>=0&&(r[o]={version:t,incarnation:null,synced:!0,hash:null});if(e&&typeof e=="object")for(let[o,t]of Object.entries(e))!t||typeof t!="object"||!Number.isSafeInteger(t.version)||t.version<0||t.incarnation!=null&&typeof t.incarnation!="string"||(r[o]={version:t.version,incarnation:t.incarnation??null,synced:t.synced===!0,hash:typeof t.hash=="string"?t.hash:null});return r}function oe(e,n,r,o){let t=C(e),s=Object.entries((n==="bundle"?t?.bundles:t?.names)??{}).find(([,c])=>c===r)?.[0],u=t?.baselines?.[s];return{synced:s!==void 0&&(n==="bundle"||u?.synced===!0&&u.hash===o),cached:!0}}export{B as a,D as b,R as c,_ as d,U as e,L as f,H as g,J as h,d as i,$ as j,X as k,f as l,q as m,Q as n,W as o,S as p,Z as q,ee as r,ne as s,re as t,M as u,C as v,oe as w};
@@ -1 +0,0 @@
1
- function f(e){return e==="inprogress"||e==="fixed"||e==="invalid"||e==="deleted"||e==="ignored"?e:void 0}function d(e){if(e)return f(e.triage)??(e.deleted?"deleted":void 0)}function l(e){let n=d(e);return n===void 0||n==="ignored"}function c(e){return e?!e.color&&!d(e)&&!e.comment&&!e.fix&&!(e.ignoredReports&&e.ignoredReports.length>0)&&e.flagged===void 0:!0}function R(e,n,r){let t=e.get(n)?.ignoredReports;return Array.isArray(t)&&t.includes(r)}function y(e,n){return Array.isArray(e?.scopedIgnoredReports)&&e.scopedIgnoredReports.includes(n)}function u(e){if(!e||typeof e!="object")return;let n=e,r={};typeof n.color=="string"&&n.color&&(r.color=n.color);let t=f(n.triage)??(n.deleted?"deleted":void 0);if(t&&(r.triage=t),typeof n.comment=="string"&&n.comment&&(r.comment=n.comment),typeof n.fix=="string"&&n.fix&&(r.fix=n.fix),typeof n.flagged=="boolean"&&(r.flagged=n.flagged),Array.isArray(n.ignoredReports)){let o=n.ignoredReports.filter(i=>typeof i=="string"&&i.length>0);o.length>0&&(r.ignoredReports=o)}if(Array.isArray(n.scopedIgnoredReports)&&r.ignoredReports){let o=[...new Set(n.scopedIgnoredReports.filter(i=>typeof i=="string"&&r.ignoredReports.includes(i)))];o.length>0&&(r.scopedIgnoredReports=o)}return c(r)?void 0:r}function g(e,n){let r=e??[],t=n??[];if(r.length!==t.length)return!1;if(r.length===0)return!0;let o=new Set(r);for(let i of t)if(!o.has(i))return!1;return!0}function a(e,n){let r=e??{},t=n??{};return(r.color??"")===(t.color??"")&&(d(r)??"")===(d(t)??"")&&(r.comment??"")===(t.comment??"")&&(r.fix??"")===(t.fix??"")&&r.flagged===t.flagged&&g(r.ignoredReports,t.ignoredReports)&&g(r.scopedIgnoredReports,t.scopedIgnoredReports)}function p(e,n,r){let t=e.get(n),o=u({...t,...r});return o===void 0?e.delete(n):a(t,o)?!1:(e.set(n,o),!0)}function T(e,n,r){let t=u(r),o=e.get(n);return t===void 0?e.delete(n):a(o,t)?!1:(e.set(n,t),!0)}function x(e,n,r,t,o=!1){let i=new Set(e.get(n)?.ignoredReports??[]);t?i.add(r):i.delete(r);let s=new Set(e.get(n)?.scopedIgnoredReports??[]);return t&&o&&s.add(r),p(e,n,{ignoredReports:i.size>0?[...i]:void 0,scopedIgnoredReports:[...s]})}export{d as a,l as b,R as c,y as d,u as e,p as f,T as g,x as h};
@@ -1 +0,0 @@
1
- import{A as d,B as e,C as f,D as g,E as h,F as i,G as j,H as k,I as l,J as m,K as n,L as o,M as p,N as q,O as r,P as s,Q as t,R as u,S as v,T as w,U as x,d as b,z as c}from"./chunk-VIHGO77Y.js";import"./chunk-GJ4IUCNS.js";import{b as a}from"./chunk-PNHBZGDD.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";export{q as deleteBundle,k as deleteFile,a as gunzipBytes,n as hasAnyBundles,o as hasStoredBundleBytes,b as isEncryptionEnabled,m as listBundles,e as listFiles,x as migrateOpfsBundlesDecrypt,w as migrateOpfsBundlesEncrypt,v as migrateOpfsFilesDecrypt,u as migrateOpfsFilesEncrypt,l as onBundleMutated,d as onFileMutated,r as readBundle,s as readBundleIndex,g as readFile,h as readFileBytes,i as readFileFresh,p as saveBundle,t as saveBundleIndex,f as saveFile,j as saveFileBytes,c as withStoredItem};
@@ -1 +0,0 @@
1
- var A=new Set(["overview","graph","treemap","compare","advisories","issues","code","search","terminal"]);var Z=/^\d+$/u;function D(e){for(let l=0;l<e.length;l++){let a=e.codePointAt(l);if(a<32||a===127)return!0}return!1}var L=512;function G(e){return typeof e=="string"&&e.length>0&&e.length<=L&&!D(e)}function E(e){return G(e)&&!Z.test(e)}var F=/^(?=.{1,214}$)(?:@[\w.-]+\/[\w-]|[\dA-Za-z])[\w.-]*$/u,j=/^(?=.{1,256}$)[\dA-Za-z][\w.+-]*$/u,X=/^@[\da-z~-][\w.~-]*$/u;function $(e){return typeof e=="string"&&F.test(e)}function m(e){return typeof e=="string"&&j.test(e)}function J(e){if(typeof e!="string")return null;let l=e.trim().toLowerCase(),a=l.startsWith("@")?l:`@${l}`;return a.length<=214&&X.test(a)?a:null}var h=new Set(["code","diff"]),ne=e=>h.has(e)?"code":"overview",x=e=>h.has(e)?{compareMode:"code"}:{},y=e=>h.has(e)?"/code":"",M=Object.freeze({manage:"/manage","manage-bundles":"/manage/bundle","manage-scans":"/manage/scans","manage-reports":"/manage/report","manage-repos":"/manage/repositories","manage-repo-risk":"/manage/repositories/risk","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 O(e){if(!E(e)||e==="."||e==="..")return null;try{return`/finding/${encodeURIComponent(e)}`}catch{return null}}function ae(e){if(!e)return null;if(e.view==="home")return"/";if(e.view==="reviews")return"/my/reviews";if(e.view==="npm")return H(e);if(e.view==="workspace-reports"||e.view==="workspace-bundles")return/^[A-Za-z0-9_-]+$/u.test(e.teamSlug??"")?`/team/${e.teamSlug}/${e.view.slice(10)}`:null;if(e.view==="bundles"){if(!/^[A-Za-z0-9_-]+$/u.test(e.bundleSlug??"")||[e.teamSlug,e.compareSlug].some(u=>u!=null&&!/^[A-Za-z0-9_-]+$/u.test(u)))return null;let n=e.bundleTab??"overview";if(!A.has(n))return null;let r=e.teamSlug?`/team/${e.teamSlug}`:"/manage",o=n==="code"&&g(e.file)?`/${e.file}`:"",s=o&&g(e.line)?`#L${e.line}${g(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:""}`:"",t=n==="compare"&&e.compareSlug!=null?`/${e.compareSlug}${y(e.compareMode)}`:"";return`${r}/bundle/${e.bundleSlug}${n==="overview"?"":`/${n}`}${o}${t}${s}`}if(Object.hasOwn(M,e.view)){let n=M[e.view];return e.view==="manage-deduplication"&&e.linkId?`${n}?report=${encodeURIComponent(e.linkId)}`:e.view==="manage-bundles"&&Number.isSafeInteger(e.createRepoId)&&e.createRepoId>0?`${n}?createRepo=${e.createRepoId}`:e.view==="manage-scans"&&e.scanMode==="link"?`${n}?mode=link`:e.view==="manage-scans"&&e.bundleId?`${n}?bundle=${encodeURIComponent(e.bundleId)}${e.scanMode==="dependencies"?"&mode=dependencies":""}`:e.view==="manage-history"&&e.actor?`${n}?actor=${encodeURIComponent(e.actor)}`:n}if(!["findings","files"].includes(e.view)||!e.teamSlug||[e.teamSlug,e.reportSlug].some(n=>n!=null&&!/^[A-Za-z0-9_-]+$/u.test(n)))return null;let l=`/team/${encodeURIComponent(e.teamSlug)}`,a=e.reportSlug?`/report/${encodeURIComponent(e.reportSlug)}`:"";if(e.finding){let n=O(e.finding.id);return e.view==="findings"&&n?`${l}${a}${n}`:null}return`${l}${a}${e.view==="files"?"/files":""}`}var B=new Set(["overview","code","compare","review","treemap"]);function H(e){if(e.packageName==null)return"/npm";let l=e.bundleTab??"overview";if(!$(e.packageName)||e.packageSpec!=null&&!m(e.packageSpec)||!B.has(l)||e.compareSpec!=null&&!m(e.compareSpec))return null;if(l==="review"){if(e.reviewPackage!=null&&!$(e.reviewPackage)||e.reviewSpec!=null&&!m(e.reviewSpec))return null;let o=e.reviewPackage==null?"":`/${e.reviewPackage}${e.reviewSpec==null?"":`@${e.reviewSpec}`}`;return`/npm/${e.packageName}${e.packageSpec==null?"":`@${e.packageSpec}`}/review${o}`}let a=l==="code"&&g(e.file)?`/${e.file}`:"",n=a&&g(e.line)?`#L${e.line}${g(e.endLine)&&e.endLine>e.line?`-L${e.endLine}`:""}`:"",r=l==="compare"&&e.compareSpec!=null?`/${e.compareSpec}${y(e.compareMode)}`:"";return`/npm/${e.packageName}${e.packageSpec==null?"":`@${e.packageSpec}`}${l==="overview"?"":`/${l}`}${a}${r}${n}`}function K(e,l){let a=/^\/npm\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?\/review(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?)?$/u.exec(e);if(a){if(!$(a[1])||a[2]!=null&&!m(a[2])||a[3]!=null&&!$(a[3])||a[4]!=null&&!m(a[4]))return null;let s=a[3]&&/^\d+\.\d+\.\d+(?:[-+].*)?$/u.test(a[3])&&a[4]==null;return{view:"npm",packageName:a[1],packageSpec:a[2]??null,bundleTab:"review",...a[3]?{reviewPackage:s?a[1]:a[3],reviewSpec:s?a[3]:a[4]??null}:{}}}let n=/^\/npm(?:\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(code|compare|treemap)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u.exec(e);if(!n)return;if(n[1]==null)return{view:"npm"};if(!$(n[1])||n[2]!=null&&!m(n[2]))return null;let r={view:"npm",packageName:n[1],packageSpec:n[2]??null,bundleTab:n[3]??"overview"};if(n[4]==null)return r;if(r.bundleTab==="compare")return m(n[4])&&(n[5]==null||h.has(n[5]))?{...r,compareSpec:n[4],...x(n[5])}:null;if(r.bundleTab!=="code")return null;let o=Number(n[4]);return!n[5]&&/^[1-9]\d*$/u.test(n[4])&&Number.isSafeInteger(o)?{...r,file:o,...T(l)}:null}function g(e){return Number.isSafeInteger(e)&&e>0}function T(e){let l=/^#L([1-9]\d*)(?:-L([1-9]\d*))?$/u.exec(e),[a,n]=l?[Number(l[1]),Number(l[2]??l[1])]:[];return!g(a)||!g(n)?{}:a===n?{line:a}:{line:Math.min(a,n),endLine:Math.max(a,n)}}function le(e){let l=e.pathname.replace(/\/$/u,"")||"/";if(l==="/"||l==="/index.html")return{view:"home"};if(l==="/my/reviews")return{view:"reviews"};let a=Object.keys(M).find(t=>M[t]===l);if(a){let t=Number(e.searchParams.get("createRepo"));return{view:a,...a==="manage-deduplication"&&e.searchParams.get("report")?{linkId:e.searchParams.get("report")}:{},...a==="manage-bundles"&&Number.isSafeInteger(t)&&t>0?{createRepoId:t}:{},...a==="manage-history"&&e.searchParams.get("actor")?{actor:e.searchParams.get("actor")}:{},...a==="manage-scans"?e.searchParams.get("mode")==="link"?{scanMode:"link"}:e.searchParams.get("bundle")?{bundleId:e.searchParams.get("bundle"),...e.searchParams.get("mode")==="dependencies"?{scanMode:"dependencies"}:{}}:{}:{}}}let n=/^(?:\/team\/([A-Za-z0-9_-]+)|\/manage)\/bundle\/([A-Za-z0-9_-]+)(?:\/([a-z]+)(?:\/([A-Za-z0-9_-]+)(?:\/([a-z]+))?)?)?$/u.exec(l);if(n){let t=n[3]??"overview";if(!A.has(t))return null;let u={view:"bundles",teamSlug:n[1]??null,bundleSlug:n[2],bundleTab:t};if(n[4]==null)return u;if(t==="compare")return n[5]==null||h.has(n[5])?{...u,compareSlug:n[4],...x(n[5])}:null;let c=Number(n[4]);return t!=="code"||n[5]||!/^[1-9]\d*$/u.test(n[4])||!Number.isSafeInteger(c)?null:{...u,file:c,...T(e.hash)}}let r=K(l,e.hash);if(r!==void 0)return r;let o=/^\/team\/([A-Za-z0-9_-]+)\/(reports|bundles)$/u.exec(l);if(o)return{view:`workspace-${o[2]}`,teamSlug:o[1]};let s=/^\/team\/([^/]+)(?:\/report\/([^/]+))?(?:\/(files)|\/finding\/([^/]+))?$/u.exec(l);if(!s)return null;try{let t=decodeURIComponent(s[1]),u=s[2]?decodeURIComponent(s[2]):null;if([t,u].some(p=>p!=null&&!/^[A-Za-z0-9_-]+$/u.test(p))||s[4]?.length>L*9)return null;let c=s[4]?decodeURIComponent(s[4]):null;return c!=null&&!O(c)?null:{view:s[3]?"files":"findings",teamSlug:t,reportSlug:u,...c==null?{}:{finding:{id:c}}}}catch{return null}}function R(e,l,a=[]){if(e.view==="workspace-reports"||e.view==="workspace-bundles"){let i=l.filter(f=>f.slug===e.teamSlug);return i.length===1?{view:e.view,teamId:i[0].id}:null}if(e.view==="bundles"){let{teamSlug:i,bundleSlug:f,compareSlug:I,compareMode:v,...k}=e,b=i==null?[]:l.filter(S=>S.slug===i);if(i!=null&&b.length!==1)return null;let w=b[0],N=i==null?a:l.flatMap(S=>S.bundles??[]),d=S=>new Set(N.filter(_=>_.slug===S).map(_=>_.id)),z=d(f),P=(w?.bundles??a).find(S=>S.slug===f);if(!f||!P||z.size!==1)return null;let C=I==null?null:d(I),U=C?.size===1?{compareId:[...C][0],...x(v)}:{};return{...k,teamId:w?.id??null,bundleId:P.id,...U}}if(!["findings","files"].includes(e.view))return e;let{teamSlug:n,reportSlug:r,...o}=e,s=l.filter(i=>i.slug===n);if(!n||s.length!==1)return null;let t=s[0];if(r==null)return{...o,teamId:t.id,reportId:null};let u=l.flatMap(i=>i.reports??[]).filter(i=>i.slug===r),c=new Set(u.map(i=>i.id)),p=(t.reports??[]).find(i=>i.slug===r);return p&&c.size===1?{...o,teamId:t.id,reportId:p.id}:null}function ie(e,l,a=[]){if(e.view==="workspace-reports"||e.view==="workspace-bundles"){let c=l.find(i=>i.id===e.teamId),p={view:e.view,teamSlug:c?.slug};return c?.slug&&R(p,l)?p:null}if(e.view==="bundles"){let{teamId:c,bundleId:p,compareId:i,compareMode:f,...I}=e,v=l.find(d=>d.id===c);if(c!=null&&!v?.slug)return null;let k=(v?.bundles??a).find(d=>d.id===p);if(!k?.slug)return null;let b=i==null?null:(c==null?a:l.flatMap(d=>d.bundles??[])).find(d=>d.id===i),w={...I,teamSlug:v?.slug??null,bundleSlug:k.slug,...b?.slug?{compareSlug:b.slug,...x(f)}:{}},N=R(w,l,a);if(!N)return null;if(w.compareSlug!=null&&N.compareId!==i){let{compareSlug:d,compareMode:z,...P}=w;return P}return w}if(!["findings","files"].includes(e.view))return e;let{teamId:n,reportId:r,...o}=e,s=l.find(c=>c.id===n),t=r==null?null:s?.reports?.find(c=>c.id===r);if(!s?.slug||r!=null&&!t?.slug)return null;let u={...o,teamSlug:s.slug,reportSlug:t?.slug??null};return R(u,l)?u:null}export{A as a,L as b,E as c,$ as d,m as e,J as f,ne as g,x as h,M as i,ae as j,B as k,le as l,R as m,ie as n};
@@ -1 +0,0 @@
1
- import{c as a,d as b}from"./chunk-A7M4GV7M.js";import"./chunk-7RU5EDRO.js";import"./chunk-K3X5EJBQ.js";import"./chunk-CVVJAXVY.js";import"./chunk-VIHGO77Y.js";import"./chunk-RFZQQXSG.js";import"./chunk-RSHMVYNS.js";import"./chunk-CLPKNNC7.js";import"./chunk-UYAXVRVL.js";import"./chunk-NRPC74AM.js";import"./chunk-VQJCXGIY.js";import"./chunk-W4J3MGLB.js";import"./chunk-GJ4IUCNS.js";import"./chunk-PNHBZGDD.js";import"./chunk-UXNUAIIC.js";import"./chunk-R5O6FAW4.js";import"./chunk-CMQA4DM6.js";import"./chunk-4F6JSF57.js";import"./chunk-YVZH5SHP.js";import"./chunk-4XCDFGDP.js";import"./chunk-3BZ7JERB.js";import"./chunk-TZ5KB2Y5.js";import"./chunk-XYFXXB2G.js";import"./chunk-DIJJNTRH.js";import"./chunk-WZDTZE64.js";import"./chunk-GNXOKIGP.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-V5O7M2YT.js";import"./chunk-OOJM4CTU.js";export{a as revealFinding,b as revealFindingInReport};
@@ -1,10 +0,0 @@
1
- import{h as _}from"./chunk-2XUEZHIP.js";var{I:c}=_,o=e=>e;var v=e=>e.strings===void 0,A=()=>document.createComment(""),u=(e,s,t)=>{let a=e._$AA.parentNode,l=s===void 0?e._$AB:s._$AA;if(t===void 0){let r=a.insertBefore(A(),l),$=a.insertBefore(A(),l);t=new c(r,$,e,e.options)}else{let r=t._$AB.nextSibling,$=t._$AM,n=$!==e;if(n){let i;t._$AQ?.(e),t._$AM=e,t._$AP!==void 0&&(i=e._$AU)!==$._$AU&&t._$AP(i)}if(r!==l||n){let i=t._$AA;for(;i!==r;){let m=o(i).nextSibling;o(a).insertBefore(i,l),i=m}}}return t},f=(e,s,t=e)=>(e._$AI(s,t),e),p={},T=(e,s=p)=>e._$AH=s,P=e=>e._$AH,g=e=>{e._$AR(),e._$AA.remove()};export{v as a,u as b,f as c,T as d,P as e,g as f};
2
- /*! Bundled license information:
3
-
4
- lit-html/directive-helpers.js:
5
- (**
6
- * @license
7
- * Copyright 2020 Google LLC
8
- * SPDX-License-Identifier: BSD-3-Clause
9
- *)
10
- */
@@ -1 +0,0 @@
1
- function c(e){return!Number.isFinite(e)||e<0?"\u2014":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KiB`:e<1073741824?`${(e/1048576).toFixed(1)} MiB`:`${(e/1073741824).toFixed(1)} GiB`}function s(e){return Array.isArray(e)?e.reduce((n,r)=>({bytes:n.bytes!=null&&Number.isFinite(r.bytes)?n.bytes+r.bytes:null,lines:n.lines!=null&&Number.isFinite(r.lines)?n.lines+r.lines:null}),{bytes:0,lines:0}):{bytes:null,lines:null}}function f(e,n,r){if(Array.isArray(e?.files))return{files:n.length,lines:s(n).lines,packages:new Set(n.map(o=>o.module)).size};let t=o=>Number.isSafeInteger(o)&&o>=0?o:null,u=e?.summary;return{files:t(u?.[r==="code"?"codeFiles":"files"]),lines:t(u?.lines),packages:null}}function _(e){return(e??[]).filter(n=>!["resource:base64","directory"].includes(n.format))}function i(e,{packageDir:n=null}={}){if(n){if(n!=="."){let r=n.match(/(?:^|\/)node_modules\/(@[^/]+\/[^/]+|[^/]+)$/u);return r&&r[1]!==".pnpm"?r[1]:n}}else{let r=/\.sol$/iu.test(e)?/(?:^|\/)(?:node_modules\/(@[^/]+\/[^/]+|[^/]+)|dependencies\/(@[^/]+\/[^/]+|[^/]+)\/)/gu:/(?:^|\/)node_modules\/(@[^/]+\/[^/]+|[^/]+)/gu,t;for(;(t=r.exec(e))!==null;){let u=t[1]??t[2];if(u!==".pnpm")return u}}return"__own__"}function l(e,n=null){return i(e,{packageDir:n})==="__own__"||!!n&&!/(?:^|\/)(?:node_modules|dependencies|vendor)(?:\/|$)/u.test(n)}function m(e,n=null){let r=[],t=[];for(let u of e)(l(u,n?.get(u))?r:t).push(u);return[...r,...t]}function p(e){return e==="__own__"?"Own source":typeof e!="string"?e:e.match(/^(?:.*\/)?vendor\/(.+)$/u)?.[1]??e}export{c as a,s as b,f as c,_ as d,i as e,l as f,m as g,p as h};
@@ -1 +0,0 @@
1
- import{d as p}from"./chunk-IU3CCINR.js";import{f as h,g as R}from"./chunk-UYAXVRVL.js";import{i as S}from"./chunk-WZDTZE64.js";import{J as C}from"./chunk-GNXOKIGP.js";async function y(e,t=null,n={}){let o;try{o=await p(e,{credentials:"same-origin",headers:{accept:"application/json"},...n})}catch{return t}if(o.status===401||o.status===403)return null;if(!o.ok)return t;try{return await o.json()}catch{return t}}async function T({fallback:e=null}={}){let t;try{let o=h(),s=await p(o?R(o):"/api/auth/session",{credentials:"same-origin",headers:{accept:"application/json"}});if(s.status===401||s.status===403)return null;if(!s.ok)return e;t=await s.json()}catch{return e}let n=t?.user;return n===null?null:n===void 0||typeof n.login!="string"?e:{id:n.id,login:n.login,name:typeof n.name=="string"?n.name:null,avatarUrl:typeof n.avatarUrl=="string"?n.avatarUrl:null,role:typeof n.role=="string"?n.role:"none",csrfToken:typeof t.csrfToken=="string"?t.csrfToken:null,...h()?{publicShare:!0}:{},...typeof t.viewer?.login=="string"?{viewer:{id:t.viewer.id,login:t.viewer.login,name:typeof t.viewer.name=="string"?t.viewer.name:null}}:{}}}function b(e){return e?.appMode===!1?{appMode:!1}:e?.appMode===!0&&Number.isSafeInteger(e.appFindings)&&e.appFindings>=0?{appMode:!0,appFindings:e.appFindings}:null}function O(e){if(typeof e?.sha!="string"||typeof e.github!="string"||!Array.isArray(e.tags))return null;let t=e.details,n=s=>typeof s=="string"?s:null,o=s=>Number.isSafeInteger(s)?s:null;return{sha:e.sha,github:e.github,tags:e.tags.filter(s=>typeof s=="string"),details:typeof t?.subject=="string"?{subject:t.subject,authorName:n(t.authorName),authorLogin:n(t.authorLogin),authoredAt:o(t.authoredAt),committedAt:o(t.committedAt)}:null}}async function F({fallback:e=[],signal:t,onRevision:n}={}){let o=h(),s=o?await y(R(o),null,{signal:t}):null,a=o?{teams:s?.team?[s.team]:[]}:await y("/api/teams",{teams:e},{signal:t}),l=a?.teams;return Array.isArray(l)?(n?.(typeof a.revision=="string"?a.revision:null),l.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.name=="string").map(i=>({id:i.id,slug:i.slug,name:i.name,...!o&&i.dependencyReview===!0?{dependencyReview:!0}:{},...i.permissions?{permissions:{dependencies:i.permissions.dependencies===!0,security:i.permissions.security===!0}}:{},...typeof i.cacheKey=="string"?{cacheKey:i.cacheKey}:{},...b(i.app)?{app:b(i.app)}:{},reports:Array.isArray(i.reports)?i.reports.filter(r=>r!=null&&typeof r.id=="string"&&typeof r.filename=="string").map(r=>({id:r.id,slug:r.slug,filename:r.filename,visible:r.visible!==!1,...r.analyzer===null||typeof r.analyzer=="string"?{analyzer:r.analyzer}:{},repoFullName:typeof r.repoFullName=="string"?r.repoFullName:"",repoDirectory:typeof r.repoDirectory=="string"?r.repoDirectory:"",...typeof r.cacheKey=="string"?{cacheKey:r.cacheKey}:{}})):[],bundles:Array.isArray(i.bundles)?i.bundles.filter(r=>r!=null&&typeof r.id=="string"&&typeof r.filename=="string").map(r=>({id:r.id,slug:r.slug,integrity:r.integrity,byteSize:r.byteSize,repoId:r.repoId,filename:r.filename,kind:r.kind,visible:r.visible!==!1,summary:r.summary??null,summaryRetryAt:Number.isSafeInteger(r.summaryRetryAt)&&r.summaryRetryAt>0?r.summaryRetryAt:null,repoDirectory:typeof r.repoDirectory=="string"?r.repoDirectory:"",repoFullName:typeof r.repoFullName=="string"?r.repoFullName:"",commitInfo:O(r.commitInfo)})):[]}))):a==null?[]:e}function x(e){return e?.links===void 0?[]:Array.isArray(e.links)&&e.links.every(t=>Array.isArray(t)&&t.length>=2&&t.every(n=>typeof n=="string"))?e.links:null}function $(e){return C(e?.data)===null||typeof e.repo?.directory!="string"||e.repo.github!==null&&typeof e.repo.github!="string"||x(e)===null?null:{data:e.data,repo:e.repo,...e.links?{links:e.links}:{}}}async function P(e,{signal:t}={}){return $(await y(`/api/reports/${encodeURIComponent(e)}`,null,{signal:t}))}async function M(e,{signal:t}={}){let n=[...new Set(e)];if(n.length===0)return[];let o=await y("/api/reports/query",null,{method:"POST",signal:t,headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({ids:n})});if(!Array.isArray(o?.reports)||o.reports.length!==n.length)return null;let s=new Map;for(let l of o.reports){let i=$(l);if(!i||!n.includes(l.id)||s.has(l.id))return null;s.set(l.id,i)}let a=x(o);return a===null?null:e.map(l=>({...s.get(l),...a.length>0?{links:a}:{}}))}async function D(e,{signal:t,reportId:n=null}={}){let o=n===null?"":`?reportId=${encodeURIComponent(n)}`,s=await y(`/api/teams/${encodeURIComponent(e)}/reports${o}`,null,{signal:t});if(!Array.isArray(s?.reports))return null;let a=[],l=new Set;for(let r of s.reports){let m=$(r);if(!m||typeof r.id!="string"||typeof r.filename!="string"||l.has(r.id))return null;l.add(r.id),a.push({id:r.id,filename:r.filename,...m})}let i=x(s);return i===null?null:(Object.defineProperty(a,"links",{value:i}),a)}function w(e){return e?`?team=${encodeURIComponent(e)}`:""}async function L(e,{reportId:t,...n}={}){let o=t==null?"":`?reportId=${encodeURIComponent(t)}`,s=await y(`/api/teams/${encodeURIComponent(e)}/annotations${o}`,null,n),{reports:a,entries:l,comments:i,issues:r={}}=s??{};if(!a||typeof a!="object"||Array.isArray(a)||!l||typeof l!="object"||Array.isArray(l)||!Array.isArray(i)||!r||typeof r!="object"||Array.isArray(r)||Object.values(a).some(c=>!Array.isArray(c)||c.some(d=>typeof d!="string"))||i.some(c=>!c||typeof c.findingId!="string"))return null;let m=new Map;for(let[c,d]of i.entries()){let f=d.findingId,g=m.get(f)??[];g.push(c),m.set(f,g)}let j=new Map,A=new Map;return c=>{if(!Object.hasOwn(a,c))return null;if(A.has(c))return A.get(c);let d=JSON.stringify(a[c]),f=j.get(d);if(!f){let g=[...new Set(a[c])],U=g.flatMap(u=>m.get(u)??[]);f={entries:Object.fromEntries(g.filter(u=>Object.hasOwn(l,u)).map(u=>[u,l[u]])),comments:U.toSorted((u,k)=>u-k).map(u=>i[u]),issues:Object.fromEntries(g.filter(u=>Object.hasOwn(r,u)).map(u=>[u,r[u]]))},j.set(d,f)}return A.set(c,f),f}}async function J(e,t,n){let s=(await y(`/api/reports/${encodeURIComponent(e)}/triage${w(t)}`,null,n))?.entries;return s!=null&&typeof s=="object"&&!Array.isArray(s)?s:null}async function z(e,t,n=null){if(h())return[];let o=n===null?"":`?reportId=${encodeURIComponent(n)}`,s=await y(`/api/teams/${encodeURIComponent(e)}/fixes${o}`,null,{signal:t});return Array.isArray(s?.fixes)?s.fixes:null}async function K(e,t,n){let o=await y(`/api/reports/${encodeURIComponent(e)}/comments${w(t)}`,null,n);return Array.isArray(o?.comments)?o.comments:null}async function q(e,{findingId:t,body:n,commentId:o=null,version:s},a,l){let i=o==null?"":`/${encodeURIComponent(o)}`;try{let r=await p(`/api/reports/${encodeURIComponent(e)}/comments${i}${w(l)}`,{method:o==null?"POST":"PATCH",credentials:"same-origin",headers:{"content-type":"application/json",...a?{"x-csrf-token":a}:{}},body:JSON.stringify(o==null?{findingId:t,body:n}:{body:n,version:s})});return{status:r.status,comment:r.ok?(await r.json()).comment:null}}catch{return{status:0,comment:null}}}async function H(e,t,n,o,s){try{return(await p(`/api/reports/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}${w(s)}`,{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json",...o?{"x-csrf-token":o}:{}},body:JSON.stringify({version:n})})).status}catch{return 0}}async function B(e,t,n,o){try{return(await p(`/api/reports/${encodeURIComponent(e)}/triage${w(o)}`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",...n?{"x-csrf-token":n}:{}},body:JSON.stringify({entries:t})})).status}catch{return 0}}function G(e){e&&(location.href=e)}async function W(e){if(h()){location.href="/";return}try{await p("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:e?{"x-csrf-token":e}:{}})}catch{}location.reload()}async function _(e,t){let n=await p("/api/auth/view-as",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",...t?{"x-csrf-token":t}:{}},body:JSON.stringify({userId:e})});if(!n.ok)throw new Error(`HTTP ${n.status}`);location.assign("/")}async function Q(e){try{await p("/api/auth/view-as",{method:"DELETE",credentials:"same-origin",headers:e?{"x-csrf-token":e}:{}})}catch{}location.assign(S["admin-users"])}async function V(e){let t=await p(`/api/teams/${encodeURIComponent(e)}/share`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Could not load public links (${t.status})`);return(await t.json()).shares}async function X(e,t,{id:n,revoke:o=!1,dependencies:s=!1,security:a=!1}={}){let l=n?`/${encodeURIComponent(n)}`:"",i=await p(`/api/teams/${encodeURIComponent(e)}/share${l}`,{method:o?"DELETE":n?"PATCH":"POST",credentials:"same-origin",headers:{"x-csrf-token":t,"content-type":"application/json"},...o?{}:{body:JSON.stringify({dependencies:s,security:a})}});if(!i.ok)throw new Error(`Could not ${o?"revoke":n?"update":"create"} public link (${i.status})`);return i.json()}async function Y(e,t){let n=await p(`/api/bundles/${encodeURIComponent(e)}/download`,{credentials:"same-origin"});if(!n.ok)throw new Error(`Could not download bundle (${n.status})`);let o=URL.createObjectURL(await n.blob()),s=document.createElement("a");s.href=o,s.download=t,s.click(),setTimeout(()=>URL.revokeObjectURL(o),6e4)}export{T as a,F as b,P as c,M as d,D as e,w as f,L as g,J as h,z as i,K as j,q as k,H as l,B as m,G as n,W as o,_ as p,Q as q,V as r,X as s,Y as t};
@@ -1,2 +0,0 @@
1
- import{g as a,h as u}from"./chunk-CVVJAXVY.js";import{r as o,s as h}from"./chunk-ZBBOBQ43.js";import{a as c}from"./chunk-KYCNJVB7.js";import"./chunk-IU3CCINR.js";import"./chunk-UYAXVRVL.js";import"./chunk-PNHBZGDD.js";import"./chunk-CMQA4DM6.js";import"./chunk-3BZ7JERB.js";import"./chunk-WZDTZE64.js";import"./chunk-GNXOKIGP.js";import{a as d,c as i,g as n}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-V5O7M2YT.js";import"./chunk-OOJM4CTU.js";var p=`.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)}
2
- `;var l=class extends a{static styles=[...a.styles,d(p)];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(s){let e=this.links.find(t=>t.id===s);this.selectedId=e?.id??"",this.dependencies=e?.permissions.dependencies===!0,this.security=e?.permissions.security===!0,this.message=""}async load(s=this.selectedId){this.busy=!0;try{let e=await o(this.team.id);return this._settled?void 0:(this.links=e,this.select(s),!0)}catch(e){return this.message=e.message,!1}finally{this.busy=!1}}async change(s=!1,e=!1){if(!this.busy){this.busy=!0,this.message="";try{let t=await h(this.team.id,this.session?.csrfToken,{id:e?void 0:this.selectedId||void 0,revoke:s,dependencies:this.dependencies,security:this.security});if(c.invalidate(["links","history"]),this._settled)return;t.path&&(this.urls.set(t.id,new URL(t.path,location.origin).href),this.links=[{id:t.id,createdAt:Date.now(),createdBy:this.session?.login??"",permissions:{dependencies:this.dependencies,security:this.security}},...this.links],this.selectedId=t.id),s&&(e?this.urls.clear():this.urls.delete(this.selectedId)),await this.load(s?"":t.id??this.selectedId)&&(this.message=s?e?"All public links revoked.":"Link revoked.":t.path?"Link created.":"Permissions saved. The link URL is unchanged.")}catch(t){this.message=t.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 s=this.urls.get(this.selectedId);return i`<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="${e=>this.select(e.target.value)}"><option value="" ?selected="${!this.selectedId}">Create a new link</option>${this.links.map(e=>i`<option value="${e.id}" ?selected="${this.selectedId===e.id}">${new Date(e.createdAt).toLocaleString()} · ${e.createdBy} · ${e.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="${e=>{this.security=e.target.checked}}"> Security findings and advisories</label> <label><input type="checkbox" .checked="${this.dependencies}" @change="${e=>{this.dependencies=e.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>${s?i`<label class="share-field">Public link<input class="nwd-input" readonly="readonly" .value="${s}" @focus="${e=>e.target.select()}"></label>`:n} ${this.message?i`<p class="nwd-note" role="status">${this.message}</p>`:n}<footer class="nwd-actions">${this.selectedId?i`<button class="danger" ?disabled="${this.busy}" @click="${()=>this.change(!0)}">Revoke link</button>`:n} <span class="nwd-spacer"></span> ${s?i`<button @click="${()=>this.copy()}">Copy link</button>`:n} <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?i`<button class="revoke-all" ?disabled="${this.busy}" @click="${()=>this.change(!0,!0)}">Revoke all links for this workspace</button>`:n}</dialog>`}};customElements.define("managed-share-dialog",l);function w(r,s="",e=null){return u("managed-share-dialog",{team:r,initialId:s,session:e})}export{w as openManagedShareDialog};