/* global React, KitChrome, ReactDOM */ const { useState, useEffect } = React; const { StatusStrip, Nav, Footer, Eyebrow, MasterEquationArtifact, CrossLinkStrip, AxisSigil, StatGrid, } = KitChrome; /* ── Canonical record categories. Maps the patient_vault.data_type strings the backend uses to a display label + relevant axis tint. ── */ const CATEGORY_META = { dream: { label: 'Dream journals', axis: 'ER' }, journal: { label: 'Reflections', axis: 'ER' }, nutrition: { label: 'Nutrition logs', axis: 'NM' }, vitals: { label: 'Vital signs', axis: 'PO' }, goal: { label: 'Goals & plans', axis: 'PV' }, wellness: { label: 'Wellness notes', axis: 'SC' }, lab: { label: 'Lab results', axis: 'NM' }, medication: { label: 'Medications', axis: 'TA' }, ch_score: { label: 'CH snapshots', axis: 'TA' }, imaging: { label: 'Imaging', axis: 'PO' }, encounter: { label: 'Clinical encounters', axis: 'SC' }, notes: { label: 'Clinical notes', axis: 'SC' }, genetic: { label: 'Genomic data', axis: 'PV' }, appointment: { label: 'Appointments', axis: 'TA' }, prescription: { label: 'Prescriptions', axis: 'TA' }, }; const CATEGORY_ORDER = []; /* ── Data context (shared with guardian-orb) ──────────────────────── */ const VaultCtx = React.createContext({ phase: 'loading' }); const useVault = () => React.useContext(VaultCtx); function bytesPretty(n) { if (n == null) return null; if (n < 1024) return n + ' B'; if (n < 1024**2) return (n / 1024).toFixed(1) + ' KB'; if (n < 1024**3) return (n / 1024**2).toFixed(1) + ' MB'; return (n / 1024**3).toFixed(2) + ' GB'; } const VaultProvider = ({ children }) => { const [state, setState] = useState({ phase: 'loading' }); useEffect(() => { let dead = false; (async () => { try { const me = await window.CHVault.me(); if (dead) return; if (!me) { setState({ phase: 'signedout' }); return; } const get = async (p) => { try { const r = await fetch(window.CHVault.apiRoot + p, { credentials: 'include', headers: { 'Accept': 'application/json' } }); if (!r.ok) return null; return await r.json(); } catch { return null; } }; const [summary, entries, sharing, audit] = await Promise.all([ get('/api/v1/vault/summary'), get('/api/v1/vault/data?include_deleted=false'), get('/api/v1/vault/sharing'), get('/api/v1/datavault/access-log'), ]); setState({ phase: 'ready', me, summary: summary || [], entries: entries || [], sharing: sharing || [], audit: audit || [] }); } catch (e) { if (!dead) setState({ phase: 'error', error: e.message || String(e) }); } })(); return () => { dead = true; }; }, []); return {children}; }; /* ── Sign-in CTA (mirrors guardian-orb pattern) ──────────────────── */ const SignInPanel = () => (
Data Vault · Locked

Sign in to open your vault.

Your records are AES-256-GCM encrypted with your key. Conceptual Health stores the ciphertext only — we cannot read your records. Sign in once and the same session works across Guardian Orb, Datavault, Wallet, and Clinical.

Open Guardian Orb to sign in →
HIPAA · AES-256-GCM · Patent Pending 63/921,717
); const LoadingPanel = () => (
Reading your vault…
); /* ── App ──────────────────────────────────────────────────────────── */ function AppInner() { const v = useVault(); const [tab, setTab] = useState('My Records'); const [recordFilter, setRecordFilter] = useState('All'); if (v.phase === 'loading') return ; if (v.phase === 'signedout') return ; if (v.phase === 'error') return ; const summary = v.summary || []; const entries = v.entries || []; const totalRecords = summary.reduce((s, x) => s + (x.count || 0), 0); const totalBytes = entries.reduce((s, e) => s + (e.payload_size || e.encrypted_payload_size || 0), 0); const activeShares = (v.sharing || []).length; const lastSealedISO = entries.length ? entries[0].last_modified : null; // Group entries by data_type → CATEGORY_META for filters. const haveTypes = new Set(entries.map(e => e.data_type)); const filterTypes = []; const shownEntries = entries.filter(e => recordFilter === 'All' || e.data_type === recordFilter); const heroStats = []; return (
AES-256 · Zero-Knowledge· HIPAA · GDPR · 21 CFR Part 11· Unlocked · {v.me && (v.me.display_name || v.me.email)} } />
); } /* ── Tabs ──────────────────────────────────────────────────────── */ const SharedTab = ({ sharing }) => (
Active grants

Who can read what.

{sharing.length === 0 ? (
No active provider grants. When you authorize a clinic or clinician to read part of your vault, the grant will appear here with full scope detail. Revocation is one click and immediate.
) : ( {sharing.map(s => ( ))}
GranteeScopeGrantedExpires
{s.clinic_name || s.grantee_name || 'Clinic ' + String(s.clinic_id || s.grantee_id || '').slice(0, 8)} {(s.shared_categories || s.scope || []).join(', ') || 'none'} {s.consent_date ? new Date(s.consent_date).toLocaleDateString() : '—'} {s.expires_at ? new Date(s.expires_at).toLocaleDateString() : 'No expiry'}
)}
); const AuditTab = ({ audit }) => (
Audit log

Every read, every write, signed to chain.

{audit.length === 0 ? (
No vault-access events recorded yet. Every read of an encrypted entry — by you, by a clinician you've granted access to, or by an automated sync — appears here HMAC-chained so anomalies are detectable.
) : ( {audit.map((a, i) => ( ))}
WhenActorActionTarget
{a.at ? new Date(a.at).toLocaleString() : '—'} {a.actor || a.actor_name || a.user_id || '—'} {a.action || a.event_type || '—'} {a.target || a.entity_id || '—'}
)}
); const SettingsTab = ({ me }) => (
Account

Your vault, your keys.

Member{me && (me.display_name || me.email)}
Member ID{me && (me.member_id || me.id)}
Email{me && me.email}
Recovery keyConfigured (or rotate via the iOS app)
); /* ── Mount ────────────────────────────────────────────────────── */ ReactDOM.createRoot(document.getElementById('root')).render( );