1import{r as e}from"./chunk-CilyBKbf.js";import{A as t,D as n,F as r,H as i,K as a,L as o,M as s,O as c,P as l,U as u,V as d,W as f,c as p,j as m,u as h,z as g}from"./index-BP9j8KNs.js";import{t as _}from"./main-Dfqyd2_D.js";var v=e(_(),1),y=r(`<div class=peach-health-loading-screen aria-busy=true aria-live=polite><div class=peach-health-loading-glyph aria-hidden=true><svg width=32 height=32 viewBox="0 0 32 32"fill=none><circle cx=16 cy=16 r=13 stroke=currentColor stroke-width=1.2 opacity=0.18></circle><path d="M16 3a13 13 0 0 1 13 13"stroke=currentColor stroke-width=1.6 stroke-linecap=round><animateTransform attributeName=transform type=rotate from="0 16 16"to="360 16 16"dur=1.2s repeatCount=indefinite></animateTransform></path></svg></div><h2 class=peach-health-loading-title>Checking your vault's health</h2><p class=peach-health-loading-copy>Scanning for reused, breached, weak, and aging credentials. Just a moment…</p><div class=peach-health-loading-track aria-hidden=true><div class=peach-health-loading-fill>`),b=r(`<div class=peach-health-pro-queue><div class=peach-health-pro-queue-head><span class=peach-health-pro-queue-title>Remediation queue</span><span class=peach-health-pro-queue-score>Vault score <!>/100`),x=r(`<span class=peach-health-summary-warn> <!> attention`),S=r(`<div class="peach-overlay-view ov-enter-right"style=display:flex><div class=peach-overlay-header><button class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"aria-label=Back><svg width=7 height=12 viewBox="0 0 7 12"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round><path d="M6 1L1 6L6 11"></path></svg></button><span class=peach-overlay-title>vault health</span><div class=peach-overlay-spacer></div></div><div class=peach-health-body><div class=peach-health-summary></div><div class=peach-health-check-row><button class="peach-btn peach-btn--accent peach-btn--sm peach-health-check-btn"><svg width=10 height=12 viewBox="0 0 10 12"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-right:5px><path d="M9 6L5 10L1 6"></path><path d="M5 10V2"></path></svg></button></div><div class=peach-health-sections>`),ee=r(`<div class=peach-health-pro-row><div class=peach-health-pro-row-info><span class=peach-health-pro-row-name></span><span class=peach-health-pro-row-meta></span><div class=peach-health-pro-bar aria-hidden=true><div class=peach-health-pro-bar-fill></div></div></div><button class="peach-btn peach-btn--accent peach-btn--sm">`),te=r(`<span class=peach-health-summary-ok>Your vault looks healthy.`),C=r(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta style=color:var(--peach-breach)></span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),w=r(`<div class=peach-health-loading>Computing...`),T=r(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name>Used in <!> places</span><span class=peach-health-row-meta></span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">View<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),E=r(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta>score: <!> (<!>)</span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),D=r(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta>last changed </span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">Fix<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),O=r(`<div class=peach-health-row><div class=peach-health-row-info><span class=peach-health-row-name></span><span class=peach-health-row-meta> • <!> • </span></div><button class="peach-btn peach-btn--ghost peach-btn--sm peach-health-fix-btn">View<svg width=6 height=10 viewBox="0 0 6 10"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round style=margin-left:4px><path d="M1 5L5 9M5 9L5 5M5 9L1 9">`),k=r(`<div class=peach-health-section-body>`),A=r(`<div class=peach-health-section><button class=peach-health-section-header><div class=peach-health-section-title-row><span class=peach-health-count-badge></span><span class=peach-health-section-title></span></div><svg class=peach-health-chevron width=10 height=6 viewBox="0 0 10 6"fill=none stroke=currentColor stroke-width=1.1 stroke-linecap=round stroke-linejoin=round><path d="M1 1L5 5L9 1">`),j=r(`<div class=peach-health-empty>`);function M(e){let t=new TextEncoder().encode(e);return crypto.subtle.digest(`SHA-256`,t).then(e=>Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``))}function N(e){return e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k exposures`:`${e.toLocaleString()} ${e===1?`exposure`:`exposures`}`}function P(e){let t=Math.floor(e/1e3);if(t<60)return`just now`;let n=Math.floor(t/60);if(n<60)return`${n} minute${n===1?``:`s`} ago`;let r=Math.floor(n/60);if(r<24)return`${r} hour${r===1?``:`s`} ago`;let i=Math.floor(r/24);if(i<30)return`${i} day${i===1?``:`s`} ago`;let a=Math.floor(i/30);if(a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function ne(e){return[`very weak`,`weak`,`fair`,`good`,`strong`][e]??`unknown`}function F(e){let[t,r]=f(!1),[_,k]=f([]),[A,j]=f(!0),[F,L]=f({breached:!0,reused:!0,weak:!0,old:!0,passkeys:!0}),[R,z]=f(null),[B,V]=f(null),[H,U]=f(!1),[W,G]=f(null);a(async()=>{if(e.isPro){U(!0);try{let e=await n({type:`GET_ADVANCED_HEALTH_REPORT`});e.ok&&V(e.data??null)}finally{U(!1)}}});async function K(e){G(e);let t=await n({type:`INITIATE_PASSWORD_CHANGE`,payload:{id:e}});G(null),t.ok&&window.close()}let q=365*24*60*60*1e3,J=i(()=>e.entries.filter(e=>(e.breach??0)>0).sort((e,t)=>(t.breach??0)-(e.breach??0))),Y=i(()=>{let t=e.entries.filter(e=>e.type!==`note`&&e.password).map(e=>({entry:e,score:(0,v.default)(e.password).score})).filter(({score:e})=>e<=1);return t.sort((e,t)=>e.score-t.score),t}),X=i(()=>e.entries.filter(e=>e.type===`login`&&e.modifiedAt<Date.now()-q).sort((e,t)=>e.modifiedAt-t.modifiedAt)),Z=i(()=>e.entries.filter(e=>e.passkey!==void 0).map(e=>{let t=e.passkey,n=t.lastUsedAt??t.createdAt??e.createdAt,r=Date.now()-n;return{entry:e,lastActivity:n,status:t.signCount===0&&r>=720*60*60*1e3?`Unused`:r>=q?`Old`:null}}).filter(e=>e.status!==null).sort((e,t)=>e.lastActivity-t.lastActivity));async function re(){let t=e.entries.filter(e=>e.type!==`note`&&e.password);if(t.length===0){k([]),j(!1);return}let n=await Promise.all(t.map(async e=>({entry:e,hash:await M(e.password)}))),r=new Map;for(let{entry:e,hash:t}of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}let i=[];r.forEach((e,t)=>{e.length>=2&&i.push({hash:t,entries:e})}),i.sort((e,t)=>t.entries.length-e.entries.length),k(i),j(!1)}re();function Q(e){L(t=>({...t,[e]:!t[e]}))}async function ie(){r(!0);let t=await n({type:`CHECK_ALL_BREACHES`});r(!1),t.ok&&e.onRefresh()}let $=i(()=>J().length+_().length+Y().length+X().length+Z().length);return[(()=>{var n=S(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,f=a.firstChild,p=f.nextSibling,v=p.firstChild;v.firstChild;var k=p.nextSibling;return c(i,`click`,e.onBack,!0),m(a,d(g,{get when(){return s(()=>!!e.isPro)()&&H()},get children(){return y()}}),f),m(a,d(g,{get when(){return s(()=>!!(e.isPro&&!H()&&B()))()&&B().remediation.length>0},get children(){var e=b(),t=e.firstChild.firstChild.nextSibling,n=t.firstChild.nextSibling;return n.nextSibling,m(t,()=>B().vaultScore,n),m(e,d(o,{get each(){return B().remediation.slice(0,8)},children:e=>(()=>{var t=ee(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,a=i.nextSibling.firstChild,o=n.nextSibling;return m(r,()=>e.title),m(i,()=>e.reasons.join(` · `)),o.$$click=()=>void K(e.id),m(o,()=>W()===e.id?`opening…`:`Change this password`),u(t=>{var n=`${Math.min(e.score,100)}%`,r=W()===e.id;return n!==t.e&&l(a,`width`,t.e=n),r!==t.t&&(o.disabled=t.t=r),t},{e:void 0,t:void 0}),t})()}),null),e}}),f),m(f,d(g,{get when(){return $()>0},get fallback(){return te()},get children(){var e=x(),t=e.firstChild,n=t.nextSibling;return n.nextSibling,m(e,$,t),m(e,()=>$()===1?`entry needs`:`entries need`,n),e}})),v.$$click=()=>void ie(),m(v,()=>t()?`checking...`:`Check all breaches now`,null),m(k,d(I,{title:`Breached`,get count(){return J().length},get expanded(){return F().breached},onToggle:()=>Q(`breached`),emptyMessage:`No breached entries`,get children(){return d(o,{get each(){return J()},children:t=>(()=>{var n=C(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling;return m(i,()=>t.title),m(a,()=>N(t.breach??0)),o.$$click=()=>e.onFixEntry(t),n})()})}}),null),m(k,d(I,{title:`Reused`,get count(){return _().length},get expanded(){return F().reused},onToggle:()=>Q(`reused`),get loading(){return A()},emptyMessage:`No reused passwords`,get children(){return d(g,{get when(){return!A()},get fallback(){return w()},get children(){return d(o,{get each(){return _()},children:e=>(()=>{var t=T(),n=t.firstChild,r=n.firstChild,i=r.firstChild.nextSibling;i.nextSibling;var a=r.nextSibling,o=n.nextSibling;return m(r,()=>e.entries.length,i),m(a,()=>e.entries.map(e=>e.title).join(`, `)),o.$$click=()=>z(e.entries),t})()})}})}}),null),m(k,d(I,{title:`Weak`,get count(){return Y().length},get expanded(){return F().weak},onToggle:()=>Q(`weak`),emptyMessage:`No weak passwords`,get children(){return d(o,{get each(){return Y()},children:({entry:t,score:n})=>(()=>{var r=E(),i=r.firstChild,a=i.firstChild,o=a.nextSibling,c=o.firstChild.nextSibling,l=c.nextSibling.nextSibling;l.nextSibling;var u=i.nextSibling;return m(a,(()=>{var e=s(()=>!!t.url);return()=>e()?h(t.url):t.title})()),m(o,n,c),m(o,()=>ne(n),l),u.$$click=()=>e.onFixEntry(t),r})()})}}),null),m(k,d(I,{title:`Old`,get count(){return X().length},get expanded(){return F().old},onToggle:()=>Q(`old`),emptyMessage:`No old entries`,get children(){return d(o,{get each(){return X()},children:t=>{let n=Date.now()-t.modifiedAt;return(()=>{var r=D(),i=r.firstChild,a=i.firstChild,o=a.nextSibling;o.firstChild;var c=i.nextSibling;return m(a,(()=>{var e=s(()=>!!t.url);return()=>e()?h(t.url):t.title})()),m(o,()=>P(n),null),c.$$click=()=>e.onFixEntry(t),r})()}})}}),null),m(k,d(I,{title:`Passkeys`,get count(){return Z().length},get expanded(){return F().passkeys},onToggle:()=>Q(`passkeys`),emptyMessage:`No stale passkeys`,get children(){return d(o,{get each(){return Z()},children:t=>(()=>{var n=O(),r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=a.firstChild,s=o.nextSibling;s.nextSibling;var c=r.nextSibling;return m(i,()=>t.entry.title),m(a,()=>t.status,o),m(a,()=>t.entry.rpId,s),m(a,()=>P(Date.now()-t.lastActivity),null),c.$$click=()=>e.onFixEntry(t.entry),n})()})}}),null),u(()=>v.disabled=t()),n})(),d(g,{get when(){return R()},get children(){return d(p,{get entries(){return R()},selectedEntryId:void 0,sortOrder:`az`,onSortOrderChange:()=>{},onSelectEntry:t=>{z(null),e.onFixEntry(t)},onAdd:()=>{},onClose:()=>z(null)})}})]}function I(e){return(()=>{var t=A(),n=t.firstChild,r=n.firstChild,i=r.firstChild,a=i.nextSibling,o=r.nextSibling;return c(n,`click`,e.onToggle,!0),m(i,()=>e.count),m(a,()=>e.title),m(t,d(g,{get when(){return e.expanded},get children(){var t=k();return m(t,d(g,{get when(){return s(()=>!e.loading)()&&e.count>0},get fallback(){return d(g,{get when(){return!e.loading},get children(){var t=j();return m(t,()=>e.emptyMessage),t}})},get children(){return e.children}})),t}}),null),u(()=>o.classList.toggle(`is-expanded`,!!e.expanded)),t})()}t([`click`]);export{F as HealthView};