1var e=`peach_trusted_networks`,t=`peach_paired_devices`,n=`peach_incoming_pair`;async function r(){try{return(await chrome.storage.local.get(e))[e]??[]}catch{return[]}}async function i(t){try{let n=await r();n.push(t),await chrome.storage.local.set({[e]:n})}catch(e){throw Error(`Failed to add trusted network: ${e}`)}}async function a(t){try{let n=(await r()).filter(e=>e.addedAt!==t);await chrome.storage.local.set({[e]:n})}catch(e){throw Error(`Failed to remove trusted network: ${e}`)}}async function o(){try{return(await chrome.storage.local.get(t))[t]??[]}catch{return[]}}async function s(e){try{let n=await o();if(n.some(t=>t.deviceId===e.deviceId))throw Error(`Device ${e.deviceId} is already paired`);n.push(e),await chrome.storage.local.set({[t]:n})}catch(e){throw Error(`Failed to add paired device: ${e}`)}}async function c(e){try{let n=(await o()).filter(t=>t.deviceId!==e);await chrome.storage.local.set({[t]:n})}catch(e){throw Error(`Failed to remove paired device: ${e}`)}}async function l(e){await chrome.storage.session.set({[n]:e})}async function u(){try{let e=(await chrome.storage.session.get(n))[n];return e?Date.now()>=e.expiresAt?(await d(),null):e:null}catch{return null}}async function d(){try{await chrome.storage.session.remove(n)}catch{}}export{s as addPairedDevice,i as addTrustedNetwork,d as clearIncomingPairingRequest,u as getIncomingPairingRequest,o as getPairedDevices,r as getTrustedNetworks,c as removePairedDevice,a as removeTrustedNetwork,l as setIncomingPairingRequest};