(function(){try{var g=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};g["__faroBundleId_Speechify Chrome Extension"]="13.4.1"}catch(l){}})();
import{a as M,f as m,h as b}from"./chunk-XBE3KAOI.js";function V(){return p||(p=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _(){return x||(x=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function k(e){let t=new Promise((n,s)=>{let o=()=>{e.removeEventListener("success",i),e.removeEventListener("error",r)},i=()=>{n(u(e.result)),o()},r=()=>{s(e.error),o()};e.addEventListener("success",i),e.addEventListener("error",r)});return y.set(t,e),t}function K(e){if(B.has(e))return;let t=new Promise((n,s)=>{let o=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",r),e.removeEventListener("abort",r)},i=()=>{n(),o()},r=()=>{s(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",i),e.addEventListener("error",r),e.addEventListener("abort",r)});B.set(e,t)}function O(e){g=e(g)}function W(e){return _().includes(e)?function(...t){return e.apply(E(this),t),u(this.request)}:function(...t){return u(e.apply(E(this),t))}}function F(e){return typeof e=="function"?W(e):(e instanceof IDBTransaction&&K(e),h(e,V())?new Proxy(e,g):e)}function u(e){if(e instanceof IDBRequest)return k(e);if(I.has(e))return I.get(e);let t=F(e);return t!==e&&(I.set(e,t),y.set(t,e)),t}function C(e,t,{blocked:n,upgrade:s,blocking:o,terminated:i}={}){let r=indexedDB.open(e,t),S=u(r);return s&&r.addEventListener("upgradeneeded",a=>{s(u(r.result),a.oldVersion,a.newVersion,u(r.transaction),a)}),n&&r.addEventListener("blocked",a=>n(a.oldVersion,a.newVersion,a)),S.then(a=>{i&&a.addEventListener("close",()=>i()),o&&a.addEventListener("versionchange",d=>o(d.oldVersion,d.newVersion,d))}).catch(()=>{}),S}function T(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(w.get(t))return w.get(t);let n=t.replace(/FromIndex$/,""),s=t!==n,o=z.includes(n);if(!(n in(s?IDBIndex:IDBObjectStore).prototype)||!(o||$.includes(n)))return;let i=async function(r,...S){let a=this.transaction(r,o?"readwrite":"readonly"),d=a.store;return s&&(d=d.index(S.shift())),(await Promise.all([d[n](...S),o&&a.done]))[0]};return w.set(t,i),i}async function*J(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,H);for(N.set(n,t),y.set(n,E(t));t;)yield n,t=await(P.get(n)||t.continue()),P.delete(n)}function L(e,t){return t===Symbol.asyncIterator&&h(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&h(e,[IDBIndex,IDBObjectStore])}var h,p,x,B,I,y,g,E,$,z,w,G,A,P,N,H,v=M(()=>{"use strict";m();b();h=(e,t)=>t.some(n=>e instanceof n);B=new WeakMap,I=new WeakMap,y=new WeakMap;g={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return B.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return u(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};E=e=>y.get(e);$=["get","getKey","getAll","getAllKeys","count"],z=["put","add","delete","clear"],w=new Map;O(e=>({...e,get:(t,n,s)=>T(t,n)||e.get(t,n,s),has:(t,n)=>!!T(t,n)||e.has(t,n)}));G=["continue","continuePrimaryKey","advance"],A={},P=new WeakMap,N=new WeakMap,H={get(e,t){if(!G.includes(t))return e[t];let n=A[t];return n||(n=A[t]=function(...s){P.set(this,N.get(this)[t](...s))}),n}};O(e=>({...e,get(t,n,s){return L(t,n)?J:e.get(t,n,s)},has(t,n){return L(t,n)||e.has(t,n)}}))});var Q,f,l,X,D,c,re,oe,ie,ae,ce,de,ue,le,Y=M(()=>{m();b();v();Q="sidepanel-db",f="url-states",l="sessions",X=2,D=null,c=()=>D||(D=C(Q,X,{upgrade(e){e.objectStoreNames.contains(f)||e.createObjectStore(f),e.objectStoreNames.contains(l)||e.createObjectStore(l).createIndex("by-startTime","startTime")}}),D),re=async e=>(await c()).get(f,e),oe=async(e,t)=>{await(await c()).put(f,t,e)},ie=async e=>(await c()).get(l,e),ae=async e=>{await(await c()).put(l,e,e.sessionId)},ce=async()=>(await(await c()).getAll(l)).sort((n,s)=>s.startTime-n.startTime),de=async e=>{await(await c()).delete(l,e)},ue=async()=>{await(await c()).clear(l)},le=async()=>{let e=await c(),t=await e.getAll(f),n=await e.getAllKeys(f),s=new Map;for(let o=0;o<n.length;o++){let i=n[o],r=t[o];r&&s.set(i,r)}return s}});export{re as a,oe as b,ie as c,ae as d,ce as e,de as f,ue as g,le as h,Y as i};
//# sourceMappingURL=chunk-O2NGNVNH.js.map
