const s="bookmarks";function l(t){return t?!t.startsWith("/")&&!t.startsWith("?")&&!t.startsWith("#")?`/${t}`:t:"/"}function c(t,a){return`${t.toLowerCase()}${l(a)}`}async function i(){const a=(await chrome.storage.local.get(s))[s]??{};let e=!1;const o={};for(const[r,n]of Object.entries(a)){const m=n.ensName?.toLowerCase()??r.toLowerCase(),d=typeof n.path=="string"?n.path:"/",u=c(m,d),f={...n,ensName:m,path:d};o[u]=f,(r!==u||typeof n.path!="string")&&(e=!0)}return e&&await chrome.storage.local.set({[s]:o}),o}async function k(){const t=await i();return Object.values(t).sort((a,e)=>e.addedAt-a.addedAt)}async function w(t,a){const e=await i();return c(t,a)in e}async function p(t){const a={...t,ensName:t.ensName.toLowerCase(),path:l(t.path)},e=await i();e[c(a.ensName,a.path)]=a,await chrome.storage.local.set({[s]:e})}async function h(t,a){const e=c(t,a),o=await i();e in o&&(delete o[e],await chrome.storage.local.set({[s]:o}))}function g(t){chrome.storage.onChanged.addListener((a,e)=>{if(e!=="local"||!a[s])return;const o=a[s].newValue??{};t(Object.values(o).sort((r,n)=>n.addedAt-r.addedAt))})}export{p as a,k as g,w as i,l as n,g as o,h as r};
//# sourceMappingURL=chunk-Ci5y0mdV.js.map
