diff --git a/index.html b/index.html
index 28c8d0c..1fa673e 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-
idb-cache
\ No newline at end of file
+idb-cache
\ No newline at end of file
diff --git a/static/js/index.f903cc38.js b/static/js/index.2c01aff4.js
similarity index 62%
rename from static/js/index.f903cc38.js
rename to static/js/index.2c01aff4.js
index 21f2fb9..079a784 100644
--- a/static/js/index.f903cc38.js
+++ b/static/js/index.2c01aff4.js
@@ -1 +1 @@
-(()=>{"use strict";var e={5182:function(e,t,r){var n,o=r("1549"),i=r("4194"),a=r("8082"),s=r("4831");class c extends Error{constructor(e){super(e),this.name="IDBCacheError",Object.setPrototypeOf(this,new.target.prototype)}}class l extends c{constructor(e){super(e),this.name="DatabaseError"}}class d extends c{constructor(e){super(e),this.name="CryptoError"}}class h extends c{constructor(e){super(e),this.name="WorkerInitializationError"}}class u extends c{constructor(e){super(e),this.name="EncryptionError"}}class m extends c{constructor(e){super(e),this.name="DecryptionError"}}class p extends c{constructor(e){super(e),this.name="TimeoutError"}}function f(e,t){e.forEach((r,n)=>{r.reject(new h(t)),clearTimeout(r.timer),e.delete(n)})}async function w(e,t,r,n,o,i=5e3){return new Promise((a,s)=>{let c=setTimeout(()=>{let e=n.get(t);e&&(e.reject(new p("Request timed out")),n.delete(t))},i);n.set(t,{resolve:a,reject:s,timer:c});let l=[];o&&o.length>0&&l.push(...o);try{l.length>0?e.postMessage(r,l):e.postMessage(r)}catch(r){console.error("Failed to post message to worker:",r);let e=n.get(t);e&&(clearTimeout(e.timer),e.reject(new h("Failed to communicate with the worker.")),n.delete(t));return}})}async function y(e,t,r){let n=crypto.randomUUID();try{return await w(e,n,{requestId:n,type:"encrypt",payload:{value:t}},r,[],5e3)}catch(e){if(e instanceof h||e instanceof u||e instanceof c)throw e;throw new u(e instanceof Error?e.message:"Unknown encryption error")}}async function g(e,t,r,n){let o=crypto.randomUUID();try{return await w(e,o,{requestId:o,type:"decrypt",payload:{iv:t,ciphertext:r}},n,[t,r],5e3)}catch(e){if(e instanceof h||e instanceof m||e instanceof c)throw e;throw new m(e instanceof Error?e.message:"Unknown decryption error")}}let b=new Map;async function x(e,t){let r=`${e}:${t}`;if(b.has(r)){let e=b.get(r);if("string"==typeof e)return e}let n=new TextEncoder().encode(r),o=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",n))).map(e=>e.toString(16).padStart(2,"0")).join(""),i=[o.slice(0,8),o.slice(8,12),`4${o.slice(13,16)}`,(3&Number.parseInt(o.slice(16,17),16)|8).toString(16)+o.slice(17,20),o.slice(20,32)].join("-");return b.set(r,i),i}async function k(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}async function j(e,t,r){let n=[],o=e.transaction(t,"readonly"),i=o.store,a=`${r}-chunk-000000-`,s=`${r}-chunk-999999\uffff`,c=IDBKeyRange.bound(a,s,!1,!1),l=await i.openKeyCursor(c);for(;l;)n.push(l.key),l=await l.continue();return await o.done,n}function v(e,t){if(!e.objectStoreNames.contains(t)){let r=e.createObjectStore(t,{keyPath:"key"});r.createIndex("byTimestamp","timestamp"),r.createIndex("byCacheBuster","cacheBuster")}}async function I(e,t,r){try{return await (0,s.X3)(e,r,{upgrade(e){v(e,t)}})}catch(n){if(n instanceof DOMException&&"VersionError"===n.name)return console.warn(`VersionError: Deleting database ${e} and retrying...`),await (0,s.Lj)(e),await (0,s.X3)(e,r,{upgrade(e){v(e,t)}});throw n}}function C(){let e=null,t=new Map,r=1e5,n=null,o=null;async function i(e){if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let n=`${new TextDecoder().decode(e)}-${new TextDecoder().decode(new Uint8Array(o))}`;if(t.has(n)){let e=t.get(n);if(void 0!==e)return e}let i=await crypto.subtle.importKey("raw",e,{name:"PBKDF2"},!1,["deriveKey"]),a=await crypto.subtle.deriveKey({name:"PBKDF2",salt:o,iterations:r,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return t.set(n,a),a}async function a(){if(!e)throw Error("Cache key not provided for encryption worker");try{null==n||n.postMessage({type:"ready"})}catch(t){console.error("Worker: Failed to initialize AES key:",t);let e=t instanceof Error?t.message:"Unknown initialization error";null==n||n.postMessage({type:"initError",error:e})}}async function s(t){if(!e)throw Error("Cache key not initialized");if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let r=crypto.getRandomValues(new Uint8Array(12)),n=new TextEncoder,a=await i(e),s=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},a,n.encode(t));return{iv:r.buffer,ciphertext:s}}async function c(t,r){if(!e)throw Error("AES key not initialized");if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let n=new Uint8Array(t),a=await i(e),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:n},a,r);return new TextDecoder().decode(s)}let l=[],d=1,h=0;function u(e){l.push(e),m()}async function m(){for(;h0;){let e=l.shift();e&&(h++,(async()=>{let t=performance.now();try{await e()}catch(e){console.error("Worker: Task execution error:",e)}finally{(function(e){e<40&&d<10?d++:e>80&&d>1&&d--})(performance.now()-t),h--,m()}})())}}async function p(t){var i,l,d,h,m;let{type:p,payload:f,requestId:w}=t.data;switch(p){case"initialize":{let{cacheKey:t,pbkdf2Iterations:n,cacheBuster:i}=f;e=new TextEncoder().encode(t),r=n||1e5,o=new TextEncoder().encode(i).buffer,await a()}break;case"encrypt":{;let{value:e}=f;await (i=w,l=e,void u(async()=>{try{let e=await s(l);if(!n)throw Error("MessagePort is not available");n.postMessage({requestId:i,type:"encryptResult",result:e},[e.iv,e.ciphertext])}catch(t){console.error("Worker: Encryption error:",t);let e=t instanceof Error?t.message:"Unknown encryption error";n&&n.postMessage({requestId:i,type:"error",error:e})}}))}break;case"decrypt":{;let{iv:e,ciphertext:t}=f;await (d=w,h=e,m=t,void u(async()=>{try{let e=await c(h,m);if(!n)throw Error("MessagePort is not available");n.postMessage({requestId:d,type:"decryptResult",result:e})}catch(t){console.error("Worker: Decryption error:",t);let e=t instanceof Error?t.message:"Unknown decryption error";n&&n.postMessage({requestId:d,type:"error",error:e})}}))}break;case"destroy":e&&(e.fill(0),e=null),o&&(new Uint8Array(o).fill(0),o=null),n&&(n.close(),n=null),self.close();break;default:console.warn(`Worker: Unknown message type received: ${p}. Ignoring the message.`)}}self.onmessage=function(e){let{type:t}=e.data;"init"===t&&e.ports&&e.ports.length>0&&((n=e.ports[0]).onmessage=p,n.start())}}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let E=null===(n=crypto)||void 0===n?void 0:n.subtle;var M=r("2773"),z=r.n(M);function P(e){let t=0;for(let r=0;r{var o,i,a,s;let{worker:l,port:p}=function(e,t){let r=new Blob([`(${e.toString()})()`],{type:"application/javascript"}),n=URL.createObjectURL(r),o=new Worker(n),i=new MessageChannel;return o.postMessage({type:"init"},[i.port2]),o.onmessage=()=>{URL.revokeObjectURL(n)},o.onerror=e=>{console.error("Worker encountered an error:",e.message),t("Worker encountered an error and was terminated."),o.terminate()},i.port1.onmessageerror=()=>{console.warn("MessagePort encountered a message error. Worker may have been terminated."),t("Worker was terminated unexpectedly."),i.port1.close()},{worker:o,port:i.port1}}(C,e=>{n(new h(e)),f(this.pendingRequests,e)});this.worker=l,this.port=p,o=p,i=r,a=n,s=this.pendingRequests,o.onmessage=e=>{let t=e.data;if("ready"===t.type)i();else if("initError"===t.type)a(new h(t.error)),f(s,t.error);else{var r,n,o;if("encryptResult"===(r=t).type&&"string"==typeof r.requestId){let{requestId:e,result:r}=t,n=s.get(e);n&&(clearTimeout(n.timer),n.resolve(r),s.delete(e))}else{;if("decryptResult"===(n=t).type&&"string"==typeof n.requestId){let{requestId:e,result:r}=t,n=s.get(e);n&&(clearTimeout(n.timer),n.resolve(r),s.delete(e))}else{;if("error"===(o=t).type&&"string"==typeof o.requestId){let{requestId:e,error:r}=t,n=s.get(e);if(n){let t;let o=r.toLowerCase();t=o.includes("encrypt")?new u(r):o.includes("decrypt")?new m(r):o.includes("key")?new d(r):new c(r),clearTimeout(n.timer),n.reject(t),s.delete(e)}}else console.warn("WorkerUtils: Unknown message type received. Ignoring the message.",t)}}}},o.onmessageerror=e=>{console.error("Worker encountered a message error:",e),a(new h("Worker failed to initialize")),f(s,"Worker encountered an error and was terminated."),o.close()},p.postMessage({type:"initialize",payload:{cacheKey:e,cacheBuster:t,pbkdf2Iterations:this.pbkdf2Iterations}})});try{await this.workerReadyPromise}catch(e){if(console.error("Worker failed to initialize:",e),e instanceof c)throw e;throw new h("Worker failed to initialize.")}}async flushBustedCacheItems(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store.index("byCacheBuster"),r=this.cacheBuster,n=IDBKeyRange.upperBound(r,!0),o=IDBKeyRange.lowerBound(r,!0),i=async e=>{let r=0,n=await t.openCursor(e);for(;n;)this.debug&&console.debug("Deleting item with cacheBuster:",n.value.cacheBuster),await n.delete(),r++,n=await n.continue();return r},a=await Promise.all([i(n),i(o)]);await e.done,this.debug&&a.reduce((e,t)=>e+(t||0),0)>0&&console.debug("Flushed old cache items with different cacheBuster.")}catch(e){if(console.error("Error during flushBustedCacheItems:",e),e instanceof l)throw e;throw new l("Failed to flush old cache items.")}}async cleanupExpiredItems(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store.index("byTimestamp"),r=Date.now(),n=await t.openCursor();for(;n;){let{timestamp:e}=n.value;if(e<=r){let t=r-e;this.debug&&console.debug(`Deleting item with timestamp ${e}. It is ${t}ms older than the expiration.`),await n.delete()}else break;n=await n.continue()}await e.done}catch(e){if(console.error("Error during cleanupExpiredItems:",e),e instanceof l)throw e;throw new l("Failed to clean up expired items.")}}async ensureWorkerInitialized(){if(!this.workerReadyPromise)throw new h("Worker is not initialized.");await this.workerReadyPromise}getPort(){if(!this.port)throw new h("Worker port is not initialized.");return this.port}async getItem(e){try{let t=Date.now();if(!this.dbReadyPromise)return null;await this.ensureWorkerInitialized();let r=await this.dbReadyPromise,n=await x(this.cacheKey,e),o=Date.now(),i=await j(r,this.storeName,n);if(this.debug&&(0===i.length?console.debug(`Cache miss for key ${e}`):console.debug(`Cache hit for key ${e}`)),0===i.length)return null;let a=[];for(let t of i){let n=await r.get(this.storeName,t);if(!n)continue;if(n.timestamp<=o)return await this.removeItem(e),null;if(n.cacheBuster!==this.cacheBuster)continue;let i=function(e){let t=e.split("-chunk-");return t.length<2?-1:Number.parseInt(t[1].split("-")[0],10)}(t);a.push({index:i,data:n})}if(0===a.length)return null;a.sort((e,t)=>e.index-t.index);let s=await Promise.all(a.map(({data:{iv:e,ciphertext:t}})=>g(this.getPort(),e,t,this.pendingRequests))),c=Date.now()-t;return this.debug&&c>200&&console.debug(`getItem for key ${e} took ${c}ms`),s.join("")}catch(t){if(t instanceof m)throw console.error(`Decryption failed for key ${e}:`,t),t;if(t instanceof l)throw console.error(`Database error while getting key ${e}:`,t),t;if(t instanceof h)throw console.error(`Worker initialization error while getting key ${e}:`,t),t;if(t instanceof c)throw console.error(`IDBCache error while getting key ${e}:`,t),t;throw console.error(`Unexpected error while getting key ${e}:`,t),new c("An unexpected error occurred.")}}async setItem(e,t){try{let i=Date.now();if(!this.dbReadyPromise)return;await this.ensureWorkerInitialized();let a=await this.dbReadyPromise,s=await x(this.cacheKey,e),c=Date.now()+this.gcTime,l=await j(a,this.storeName,s),d=new Set(l),h=new Set,u=[],m=[];for(let e=0;e!h.has(e)),f=a.transaction(this.storeName,"readwrite"),w=f.store,g=[];for(let e of m)g.push(w.put(e));for(let{chunkKey:e,encryptedChunk:t}of u)g.push(w.put({...t,key:e,timestamp:c}));for(let e of p)g.push(w.delete(e));await Promise.all(g),await f.done;let b=Date.now()-i;this.debug&&b>200&&console.debug(`setItem for key ${e} took ${b}ms`)}catch(e){if(e instanceof h)throw console.error("Worker port is not initialized:",e),e;if(e instanceof l)throw console.error("Database error in setItem:",e),e;if(e instanceof u)throw console.error("Encryption error in setItem:",e),e;if(e instanceof c)throw console.error("IDBCache error in setItem:",e),e;throw console.error("Unexpected error in setItem:",e),new c("An unexpected error occurred during setItem.")}}async removeItem(e){try{let t=await this.dbReadyPromise,r=await x(this.cacheKey,e),n=await j(t,this.storeName,r),o=t.transaction(this.storeName,"readwrite"),i=o.store,a=n.map(e=>i.delete(e));await Promise.all(a),await o.done}catch(e){if(console.error("Error in removeItem:",e),e instanceof l||e instanceof c)throw e;throw new l("Failed to remove item from the cache.")}}async count(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readonly"),t=e.store,r=await t.count();return await e.done,this.debug&&console.debug(`Total entries in cache: ${r}`),r}catch(e){if(console.error("Error in count():",e),e instanceof l)throw e;throw new l("Failed to count items in the cache.")}}async clear(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store;await t.clear(),await e.done,this.debug&&console.debug("All items have been cleared from the cache.")}catch(e){if(console.error("Error in clear:",e),e instanceof l||e instanceof c)throw e;throw new l("Failed to clear the cache.")}}async destroy(e){let{clearData:t=!1}=e||{};try{t&&await this.clear(),void 0!==this.cleanupIntervalId&&clearInterval(this.cleanupIntervalId),this.pendingRequests.forEach((e,t)=>{e.reject(new c("IDBCache instance is being destroyed.")),this.pendingRequests.delete(t)}),this.port&&(this.port.postMessage({type:"destroy"}),this.port.close(),this.port=null),this.worker&&(this.worker.terminate(),this.worker=null),this.workerReadyPromise=null,this.debug&&console.debug("IDBCache instance has been destroyed.")}catch(e){if(console.error("Error in destroy:",e),e instanceof c)throw e;throw new c("Failed to destroy the cache instance.")}}constructor(e){S(this,"dbReadyPromise",void 0),S(this,"storeName",void 0),S(this,"worker",null),S(this,"port",null),S(this,"pendingRequests",void 0),S(this,"workerReadyPromise",null),S(this,"gcTime",void 0),S(this,"cleanupIntervalId",void 0),S(this,"cacheKey",void 0),S(this,"chunkSize",void 0),S(this,"cleanupInterval",void 0),S(this,"pbkdf2Iterations",void 0),S(this,"cacheBuster",void 0),S(this,"debug",void 0);let{cacheKey:t,cacheBuster:r,debug:n=!1,dbName:o="idb-cache",gcTime:i=6048e5,chunkSize:a=25e3,cleanupInterval:s=6e4,pbkdf2Iterations:c=1e5}=e;if(this.storeName="cache",this.cacheKey=t,this.debug=n,this.gcTime=i,this.chunkSize=a,this.cleanupInterval=s,this.pbkdf2Iterations=c,this.cacheBuster=r,this.pendingRequests=new Map,!window.indexedDB)throw new l("IndexedDB is not supported.");if(!E)throw new d("Web Crypto API not available in this environment");this.dbReadyPromise=I(o,this.storeName,1),this.cleanupIntervalId=window.setInterval(this.cleanupExpiredItems.bind(this),this.cleanupInterval),this.initWorker(t,r).then(()=>{this.cleanupExpiredItems().catch(e=>console.error("Initial cleanup failed:",e)),this.flushBustedCacheItems().catch(e=>console.error("Failed to flush old cache items:",e))}).catch(e=>{console.error("Worker initialization failed:",e)})}}({cacheKey:W,cacheBuster:T,debug:!0}),L=Number.parseInt(localStorage.getItem("itemSize")||String(10240))||10240,G=()=>(0,o.jsx)("span",{style:{color:"#ddd"},children:"------"}),K=document.getElementById("root");K&&a.createRoot(K).render((0,o.jsx)(i.StrictMode,{children:(0,o.jsx)(()=>{let[e,t]=(0,i.useState)(null),[r,n]=(0,i.useState)(null),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(null),[d,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(null),[p,f]=(0,i.useState)(null),[w,y]=(0,i.useState)(L),[g,b]=(0,i.useState)(null),[x,k]=(0,i.useState)(()=>crypto.randomUUID()),j=(0,i.useCallback)(async()=>{let e=crypto.randomUUID();k(e);let r=performance.now(),n=Array.from({length:1},(t,r)=>(function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=`${e}-${r}`;if(R[n])return R[n];let o=z().create(r),i=Math.ceil(e),a=Array(i);for(let e=0;ee;)s=s.slice(0,-1);return R[n]=s,s})(w,`${T}-${e}-${r}`));s(performance.now()-r);let o=performance.now();for(let t=0;t<1;t++)await A.setItem(`item-${e}-${t}`,n[t]);l(performance.now()-o),t(P(n.join("")))},[w]),v=(0,i.useCallback)(async()=>{let e=[],t=performance.now();for(let t=0;t<1;t++){let r=await A.getItem(`item-${x}-${t}`);e.push(r)}h(performance.now()-t),n(e.filter(e=>e).length>0?P(e.join("")):null)},[x]),I=(0,i.useCallback)(async()=>{let e=performance.now(),t=await A.count();m(performance.now()-e),b(t)},[]),C=(0,i.useCallback)(async()=>{let e=performance.now();await A.clear(),f(performance.now()-e)},[]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("a",{href:"https://github.com/instructure/idb-cache","aria-label":"View source on GitHub",children:[(0,o.jsxs)("svg",{width:80,height:80,viewBox:"0 0 250 250",style:{fill:"#151513",color:"#fff",position:"absolute",top:0,border:0,right:0},"aria-hidden":"true",children:[(0,o.jsx)("path",{d:"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"}),(0,o.jsx)("path",{d:"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2",fill:"currentColor",style:{transformOrigin:"130px 106px"},className:"octo-arm"}),(0,o.jsx)("path",{d:"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z",fill:"currentColor",className:"octo-body"})]}),(0,o.jsx)("span",{style:{position:"absolute",left:"-9999px"},children:"View source on GitHub"})]}),(0,o.jsx)("div",{className:"min-h-screen bg-gray-50 p-8",children:(0,o.jsxs)("div",{className:"max-w-4xl mx-auto p-6 bg-white shadow-md rounded-lg",children:[(0,o.jsx)(U.X,{level:"h1",margin:"0 0 small 0",children:"@instructure/idb-cache"}),(0,o.jsxs)("form",{children:[(0,o.jsxs)("fieldset",{className:"border border-gray-300 rounded-lg p-4 mb-6",children:[(0,o.jsx)("legend",{className:"text-lg font-semibold text-gray-700",children:"Test Configuration"}),(0,o.jsxs)(N.kC,{direction:"column",gap:"small",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("span",{children:["Cache key: ",(0,o.jsx)("code",{className:"text-sm",children:W})]}),(0,o.jsx)(B.z,{onClick:()=>{localStorage.removeItem("cacheKey"),window.location.reload()},children:"Reset"})]}),(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("span",{children:["Cache buster: ",(0,o.jsx)("code",{className:"text-sm",children:T})]}),(0,o.jsx)(B.z,{onClick:()=>{localStorage.removeItem("cacheBuster"),window.location.reload()},children:"Reset"})]}),(0,o.jsxs)(N.kC,{gap:"medium",children:[(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)(O.Y,{renderLabel:"Size of data (kb):",onChange:e=>{let t=Math.max(1024*Number.parseInt(e.target.value),1024);y(t),localStorage.setItem("itemSize",String(t))},onIncrement:()=>{let e=Math.max(Math.round(w)+1024,1024);y(e),localStorage.setItem("itemSize",String(e))},onDecrement:()=>{let e=Math.max(Math.round(w)-1024,1024);y(e),localStorage.setItem("itemSize",String(e))},isRequired:!0,value:Math.round(w/1024)})}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)(O.Y,{renderLabel:"Number of chunks:",interaction:"disabled",value:Math.ceil(w/25e3)})})]})]})]}),(0,o.jsxs)("fieldset",{className:"border border-gray-300 rounded-lg p-4",children:[(0,o.jsx)("legend",{className:"text-lg font-semibold text-gray-700",children:"Performance Tests"}),(0,o.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:j,children:"setItem"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"generate test data",renderValue:null!==c?`${Math.round(a||0)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"setItem",renderValue:null!==c?`${Math.round(c)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"hash",renderValue:e||(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:v,children:"getItem"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"getItem",renderValue:null!==d?`${Math.round(d)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"hash",renderValue:r||(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:I,children:"count"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"clear",renderValue:null!==u?`${Math.round(u)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"chunks",renderValue:"number"==typeof g?g:(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:C,children:"clear"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"clear",renderValue:null!==p?`${Math.round(p)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"})]})})]})})]})]})]})]})})]})},{})}))}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.m=e,r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},(()=>{var e,t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__};r.t=function(n,o){if(1&o&&(n=this(n)),8&o||"object"==typeof n&&n&&(4&o&&n.__esModule||16&o&&"function"==typeof n.then))return n;var i=Object.create(null);r.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&o&&n;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(function(e){a[e]=function(){return n[e]}});return a.default=function(){return n},r.d(i,a),i}})(),r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e=[];r.O=function(t,n,o,i){if(n){i=i||0;for(var a=e.length;a>0&&e[a-1][2]>i;a--)e[a]=e[a-1];e[a]=[n,o,i];return}for(var s=1/0,a=0;a=i)&&Object.keys(r.O).every(function(e){return r.O[e](n[l])})?n.splice(l--,1):(c=!1,i{var e={980:0};r.O.j=function(t){return 0===e[t]};var t=function(t,n){var o=n[0],i=n[1],a=n[2],s,c,l=0;if(o.some(function(t){return 0!==e[t]})){for(s in i)r.o(i,s)&&(r.m[s]=i[s]);if(a)var d=a(r)}for(t&&t(n);l{"use strict";var e={5182:function(e,t,r){var n,o=r("1549"),i=r("4194"),a=r("8082"),s=r("4831");class c extends Error{constructor(e){super(e),this.name="IDBCacheError",Object.setPrototypeOf(this,new.target.prototype)}}class l extends c{constructor(e){super(e),this.name="DatabaseError"}}class d extends c{constructor(e){super(e),this.name="CryptoError"}}class h extends c{constructor(e){super(e),this.name="WorkerInitializationError"}}class u extends c{constructor(e){super(e),this.name="EncryptionError"}}class m extends c{constructor(e){super(e),this.name="DecryptionError"}}class p extends c{constructor(e){super(e),this.name="TimeoutError"}}function f(e,t){e.forEach((r,n)=>{r.reject(new h(t)),clearTimeout(r.timer),e.delete(n)})}async function w(e,t,r,n,o,i=5e3){return new Promise((a,s)=>{let c=setTimeout(()=>{let e=n.get(t);e&&(e.reject(new p("Request timed out")),n.delete(t))},i);n.set(t,{resolve:a,reject:s,timer:c});let l=[];o&&o.length>0&&l.push(...o);try{l.length>0?e.postMessage(r,l):e.postMessage(r)}catch(r){console.error("Failed to post message to worker:",r);let e=n.get(t);e&&(clearTimeout(e.timer),e.reject(new h("Failed to communicate with the worker.")),n.delete(t));return}})}async function y(e,t,r){let n=crypto.randomUUID();try{return await w(e,n,{requestId:n,type:"encrypt",payload:{value:t}},r,[],5e3)}catch(e){if(e instanceof h||e instanceof u||e instanceof c)throw e;throw new u(e instanceof Error?e.message:"Unknown encryption error")}}async function g(e,t,r,n){let o=crypto.randomUUID();try{return await w(e,o,{requestId:o,type:"decrypt",payload:{iv:t,ciphertext:r}},n,[t,r],5e3)}catch(e){if(e instanceof h||e instanceof m||e instanceof c)throw e;throw new m(e instanceof Error?e.message:"Unknown decryption error")}}let b=new Map;async function x(e,t){let r=`${e}:${t}`;if(b.has(r)){let e=b.get(r);if("string"==typeof e)return e}let n=new TextEncoder().encode(r),o=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",n))).map(e=>e.toString(16).padStart(2,"0")).join(""),i=[o.slice(0,8),o.slice(8,12),`4${o.slice(13,16)}`,(3&Number.parseInt(o.slice(16,17),16)|8).toString(16)+o.slice(17,20),o.slice(20,32)].join("-");return b.set(r,i),i}async function k(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}async function j(e,t,r){let n=[],o=e.transaction(t,"readonly"),i=o.store,a=`${r}-chunk-000000-`,s=`${r}-chunk-999999\uffff`,c=IDBKeyRange.bound(a,s,!1,!1),l=await i.openKeyCursor(c);for(;l;)n.push(l.key),l=await l.continue();return await o.done,n}function v(e,t){if(!e.objectStoreNames.contains(t)){let r=e.createObjectStore(t,{keyPath:"key"});r.createIndex("byTimestamp","timestamp"),r.createIndex("byCacheBuster","cacheBuster")}}async function I(e,t,r){try{return await (0,s.X3)(e,r,{upgrade(e){v(e,t)}})}catch(n){if(n instanceof DOMException&&"VersionError"===n.name)return console.warn(`VersionError: Deleting database ${e} and retrying...`),await (0,s.Lj)(e),await (0,s.X3)(e,r,{upgrade(e){v(e,t)}});throw n}}function C(){let e=null,t=new Map,r=1e5,n=null,o=null;async function i(e){if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let n=`${new TextDecoder().decode(e)}-${new TextDecoder().decode(new Uint8Array(o))}`;if(t.has(n)){let e=t.get(n);if(void 0!==e)return e}let i=await crypto.subtle.importKey("raw",e,{name:"PBKDF2"},!1,["deriveKey"]),a=await crypto.subtle.deriveKey({name:"PBKDF2",salt:o,iterations:r,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return t.set(n,a),a}async function a(){if(!e)throw Error("Cache key not provided for encryption worker");try{null==n||n.postMessage({type:"ready"})}catch(t){console.error("Worker: Failed to initialize AES key:",t);let e=t instanceof Error?t.message:"Unknown initialization error";null==n||n.postMessage({type:"initError",error:e})}}async function s(t){if(!e)throw Error("Cache key not initialized");if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let r=crypto.getRandomValues(new Uint8Array(12)),n=new TextEncoder,a=await i(e),s=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},a,n.encode(t));return{iv:r.buffer,ciphertext:s}}async function c(t,r){if(!e)throw Error("AES key not initialized");if(!o)throw Error("Fixed salt (cacheBuster) not initialized");let n=new Uint8Array(t),a=await i(e),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:n},a,r);return new TextDecoder().decode(s)}let l=[],d=1,h=0;function u(e){l.push(e),m()}async function m(){for(;h0;){let e=l.shift();e&&(h++,(async()=>{let t=performance.now();try{await e()}catch(e){console.error("Worker: Task execution error:",e)}finally{(function(e){e<40&&d<10?d++:e>80&&d>1&&d--})(performance.now()-t),h--,m()}})())}}async function p(t){var i,l,d,h,m;let{type:p,payload:f,requestId:w}=t.data;switch(p){case"initialize":{let{cacheKey:t,pbkdf2Iterations:n,cacheBuster:i}=f;e=new TextEncoder().encode(t),r=n||1e5,o=new TextEncoder().encode(i).buffer,await a()}break;case"encrypt":{;let{value:e}=f;await (i=w,l=e,void u(async()=>{try{let e=await s(l);if(!n)throw Error("MessagePort is not available");n.postMessage({requestId:i,type:"encryptResult",result:e},[e.iv,e.ciphertext])}catch(t){console.error("Worker: Encryption error:",t);let e=t instanceof Error?t.message:"Unknown encryption error";n&&n.postMessage({requestId:i,type:"error",error:e})}}))}break;case"decrypt":{;let{iv:e,ciphertext:t}=f;await (d=w,h=e,m=t,void u(async()=>{try{let e=await c(h,m);if(!n)throw Error("MessagePort is not available");n.postMessage({requestId:d,type:"decryptResult",result:e})}catch(t){console.error("Worker: Decryption error:",t);let e=t instanceof Error?t.message:"Unknown decryption error";n&&n.postMessage({requestId:d,type:"error",error:e})}}))}break;case"destroy":e&&(e.fill(0),e=null),o&&(new Uint8Array(o).fill(0),o=null),n&&(n.close(),n=null),self.close();break;default:console.warn(`Worker: Unknown message type received: ${p}. Ignoring the message.`)}}self.onmessage=function(e){let{type:t}=e.data;"init"===t&&e.ports&&e.ports.length>0&&((n=e.ports[0]).onmessage=p,n.start())}}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let E=null===(n=crypto)||void 0===n?void 0:n.subtle;var M=r("2773"),z=r.n(M);function P(e){let t=0;for(let r=0;r{var o,i,a,s;let{worker:l,port:p}=function(e,t){let r=new Blob([`(${e.toString()})()`],{type:"application/javascript"}),n=URL.createObjectURL(r),o=new Worker(n),i=new MessageChannel;return o.postMessage({type:"init"},[i.port2]),o.onmessage=()=>{URL.revokeObjectURL(n)},o.onerror=e=>{console.error("Worker encountered an error:",e.message),t("Worker encountered an error and was terminated."),o.terminate()},i.port1.onmessageerror=()=>{console.warn("MessagePort encountered a message error. Worker may have been terminated."),t("Worker was terminated unexpectedly."),i.port1.close()},{worker:o,port:i.port1}}(C,e=>{n(new h(e)),f(this.pendingRequests,e)});this.worker=l,this.port=p,o=p,i=r,a=n,s=this.pendingRequests,o.onmessage=e=>{let t=e.data;if("ready"===t.type)i();else if("initError"===t.type)a(new h(t.error)),f(s,t.error);else{var r,n,o;if("encryptResult"===(r=t).type&&"string"==typeof r.requestId){let{requestId:e,result:r}=t,n=s.get(e);n&&(clearTimeout(n.timer),n.resolve(r),s.delete(e))}else{;if("decryptResult"===(n=t).type&&"string"==typeof n.requestId){let{requestId:e,result:r}=t,n=s.get(e);n&&(clearTimeout(n.timer),n.resolve(r),s.delete(e))}else{;if("error"===(o=t).type&&"string"==typeof o.requestId){let{requestId:e,error:r}=t,n=s.get(e);if(n){let t;let o=r.toLowerCase();t=o.includes("encrypt")?new u(r):o.includes("decrypt")?new m(r):o.includes("key")?new d(r):new c(r),clearTimeout(n.timer),n.reject(t),s.delete(e)}}else console.warn("WorkerUtils: Unknown message type received. Ignoring the message.",t)}}}},o.onmessageerror=e=>{console.error("Worker encountered a message error:",e),a(new h("Worker failed to initialize")),f(s,"Worker encountered an error and was terminated."),o.close()},p.postMessage({type:"initialize",payload:{cacheKey:e,cacheBuster:t,pbkdf2Iterations:this.pbkdf2Iterations}})});try{await this.workerReadyPromise}catch(e){if(console.error("Worker failed to initialize:",e),e instanceof c)throw e;throw new h("Worker failed to initialize.")}}async flushBustedCacheItems(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store.index("byCacheBuster"),r=this.cacheBuster,n=IDBKeyRange.upperBound(r,!0),o=IDBKeyRange.lowerBound(r,!0),i=async e=>{let r=0,n=await t.openCursor(e);for(;n;)this.debug&&console.debug("Deleting item with cacheBuster:",n.value.cacheBuster),await n.delete(),r++,n=await n.continue();return r},a=await Promise.all([i(n),i(o)]);await e.done,this.debug&&a.reduce((e,t)=>e+(t||0),0)>0&&console.debug("Flushed old cache items with different cacheBuster.")}catch(e){if(console.error("Error during flushBustedCacheItems:",e),e instanceof l)throw e;throw new l("Failed to flush old cache items.")}}async cleanupExpiredItems(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store.index("byTimestamp"),r=Date.now(),n=await t.openCursor();for(;n;){let{timestamp:e}=n.value;if(e<=r){let t=r-e;this.debug&&console.debug(`Deleting item with timestamp ${e}. It is ${t}ms older than the expiration.`),await n.delete()}else break;n=await n.continue()}await e.done}catch(e){if(console.error("Error during cleanupExpiredItems:",e),e instanceof l)throw e;throw new l("Failed to clean up expired items.")}}async ensureWorkerInitialized(){if(!this.workerReadyPromise)throw new h("Worker is not initialized.");await this.workerReadyPromise}getPort(){if(!this.port)throw new h("Worker port is not initialized.");return this.port}async getItem(e){try{let t=Date.now();if(!this.dbReadyPromise)return null;await this.ensureWorkerInitialized();let r=await this.dbReadyPromise,n=await x(this.cacheKey,e),o=Date.now(),i=await j(r,this.storeName,n);if(this.debug&&(0===i.length?console.debug(`Cache miss for key ${e}`):console.debug(`Cache hit for key ${e}`)),0===i.length)return null;let a=[];for(let t of i){let n=await r.get(this.storeName,t);if(!n)continue;if(n.timestamp<=o)return await this.removeItem(e),null;if(n.cacheBuster!==this.cacheBuster)continue;let i=function(e){let t=e.split("-chunk-");return t.length<2?-1:Number.parseInt(t[1].split("-")[0],10)}(t);a.push({index:i,data:n})}if(0===a.length)return null;a.sort((e,t)=>e.index-t.index);let s=await Promise.all(a.map(({data:{iv:e,ciphertext:t}})=>g(this.getPort(),e,t,this.pendingRequests))),c=Date.now()-t;return this.debug&&c>200&&console.debug(`getItem for key ${e} took ${c}ms`),s.join("")}catch(t){if(t instanceof m)throw console.error(`Decryption failed for key ${e}:`,t),t;if(t instanceof l)throw console.error(`Database error while getting key ${e}:`,t),t;if(t instanceof h)throw console.error(`Worker initialization error while getting key ${e}:`,t),t;if(t instanceof c)throw console.error(`IDBCache error while getting key ${e}:`,t),t;throw console.error(`Unexpected error while getting key ${e}:`,t),new c("An unexpected error occurred.")}}async setItem(e,t){try{let i=Date.now();if(!this.dbReadyPromise)return;await this.ensureWorkerInitialized();let a=await this.dbReadyPromise,s=await x(this.cacheKey,e),c=Date.now()+this.gcTime,l=await j(a,this.storeName,s),d=new Set(l),h=new Set,u=[],m=[];for(let e=0;e!h.has(e)),f=a.transaction(this.storeName,"readwrite"),w=f.store,g=[];for(let e of m)g.push(w.put(e));for(let{chunkKey:e,encryptedChunk:t}of u)g.push(w.put({...t,key:e,timestamp:c}));for(let e of p)g.push(w.delete(e));await Promise.all(g),await f.done;let b=Date.now()-i;this.debug&&b>200&&console.debug(`setItem for key ${e} took ${b}ms`)}catch(e){if(e instanceof h)throw console.error("Worker port is not initialized:",e),e;if(e instanceof l)throw console.error("Database error in setItem:",e),e;if(e instanceof u)throw console.error("Encryption error in setItem:",e),e;if(e instanceof c)throw console.error("IDBCache error in setItem:",e),e;throw console.error("Unexpected error in setItem:",e),new c("An unexpected error occurred during setItem.")}}async removeItem(e){try{let t=await this.dbReadyPromise,r=await x(this.cacheKey,e),n=await j(t,this.storeName,r),o=t.transaction(this.storeName,"readwrite"),i=o.store,a=n.map(e=>i.delete(e));await Promise.all(a),await o.done}catch(e){if(console.error("Error in removeItem:",e),e instanceof l||e instanceof c)throw e;throw new l("Failed to remove item from the cache.")}}async count(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readonly"),t=e.store,r=await t.count();return await e.done,this.debug&&console.debug(`Total entries in cache: ${r}`),r}catch(e){if(console.error("Error in count():",e),e instanceof l)throw e;throw new l("Failed to count items in the cache.")}}async clear(){try{let e=(await this.dbReadyPromise).transaction(this.storeName,"readwrite"),t=e.store;await t.clear(),await e.done,this.debug&&console.debug("All items have been cleared from the cache.")}catch(e){if(console.error("Error in clear:",e),e instanceof l||e instanceof c)throw e;throw new l("Failed to clear the cache.")}}async destroy(e){let{clearData:t=!1}=e||{};try{t&&await this.clear(),void 0!==this.cleanupIntervalId&&clearInterval(this.cleanupIntervalId),this.pendingRequests.forEach((e,t)=>{e.reject(new c("IDBCache instance is being destroyed.")),this.pendingRequests.delete(t)}),this.port&&(this.port.postMessage({type:"destroy"}),this.port.close(),this.port=null),this.worker&&(this.worker.terminate(),this.worker=null),this.workerReadyPromise=null,this.debug&&console.debug("IDBCache instance has been destroyed.")}catch(e){if(console.error("Error in destroy:",e),e instanceof c)throw e;throw new c("Failed to destroy the cache instance.")}}constructor(e){S(this,"dbReadyPromise",void 0),S(this,"storeName",void 0),S(this,"worker",null),S(this,"port",null),S(this,"pendingRequests",void 0),S(this,"workerReadyPromise",null),S(this,"gcTime",void 0),S(this,"cleanupIntervalId",void 0),S(this,"cacheKey",void 0),S(this,"chunkSize",void 0),S(this,"cleanupInterval",void 0),S(this,"pbkdf2Iterations",void 0),S(this,"cacheBuster",void 0),S(this,"debug",void 0);let{cacheKey:t,cacheBuster:r,debug:n=!1,dbName:o="idb-cache",gcTime:i=6048e5,chunkSize:a=25e3,cleanupInterval:s=6e4,pbkdf2Iterations:c=1e5}=e;if(this.storeName="cache",this.cacheKey=t,this.debug=n,this.gcTime=i,this.chunkSize=a,this.cleanupInterval=s,this.pbkdf2Iterations=c,this.cacheBuster=r,this.pendingRequests=new Map,!window.indexedDB)throw new l("IndexedDB is not supported.");if(!E)throw new d("Web Crypto API not available in this environment");this.dbReadyPromise=I(o,this.storeName,1),this.cleanupIntervalId=window.setInterval(this.cleanupExpiredItems.bind(this),this.cleanupInterval),this.initWorker(t,r).then(()=>{this.cleanupExpiredItems().catch(e=>console.error("Initial cleanup failed:",e)),this.flushBustedCacheItems().catch(e=>console.error("Failed to flush old cache items:",e))}).catch(e=>{console.error("Worker initialization failed:",e)})}}({cacheKey:W,cacheBuster:T,debug:!0});window.idbCacheInstance=A;let L=Number.parseInt(localStorage.getItem("itemSize")||String(32768))||32768,G=()=>(0,o.jsx)("span",{style:{color:"#ddd"},children:"------"}),K=document.getElementById("root");K&&a.createRoot(K).render((0,o.jsx)(i.StrictMode,{children:(0,o.jsx)(()=>{let[e,t]=(0,i.useState)(null),[r,n]=(0,i.useState)(null),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(null),[d,h]=(0,i.useState)(null),[u,m]=(0,i.useState)(null),[p,f]=(0,i.useState)(null),[w,y]=(0,i.useState)(L),[g,b]=(0,i.useState)(null),[x,k]=(0,i.useState)(()=>crypto.randomUUID()),j=(0,i.useCallback)(async()=>{let e=crypto.randomUUID();k(e);let r=performance.now(),n=Array.from({length:1},(t,r)=>(function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=`${e}-${r}`;if(R[n])return R[n];let o=z().create(r),i=Math.ceil(e),a=Array(i);for(let e=0;ee;)s=s.slice(0,-1);return R[n]=s,s})(w,`${T}-${e}-${r}`));s(performance.now()-r);let o=performance.now();for(let t=0;t<1;t++)await A.setItem(`item-${e}-${t}`,n[t]);l(performance.now()-o),t(P(n.join("")))},[w]),v=(0,i.useCallback)(async()=>{let e=[],t=performance.now();for(let t=0;t<1;t++){let r=await A.getItem(`item-${x}-${t}`);e.push(r)}h(performance.now()-t),n(e.filter(e=>e).length>0?P(e.join("")):null)},[x]),I=(0,i.useCallback)(async()=>{let e=performance.now(),t=await A.count();m(performance.now()-e),b(t)},[]),C=(0,i.useCallback)(async()=>{let e=performance.now();await A.clear(),f(performance.now()-e)},[]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("a",{href:"https://github.com/instructure/idb-cache","aria-label":"View source on GitHub",children:[(0,o.jsxs)("svg",{width:80,height:80,viewBox:"0 0 250 250",style:{fill:"#151513",color:"#fff",position:"absolute",top:0,border:0,right:0},"aria-hidden":"true",children:[(0,o.jsx)("path",{d:"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"}),(0,o.jsx)("path",{d:"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2",fill:"currentColor",style:{transformOrigin:"130px 106px"},className:"octo-arm"}),(0,o.jsx)("path",{d:"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z",fill:"currentColor",className:"octo-body"})]}),(0,o.jsx)("span",{style:{position:"absolute",left:"-9999px"},children:"View source on GitHub"})]}),(0,o.jsx)("div",{className:"min-h-screen bg-gray-50 p-8",children:(0,o.jsxs)("div",{className:"max-w-4xl mx-auto p-6 bg-white shadow-md rounded-lg",children:[(0,o.jsx)(U.X,{level:"h1",margin:"0 0 small 0",children:"@instructure/idb-cache"}),(0,o.jsxs)("form",{children:[(0,o.jsxs)("fieldset",{className:"border border-gray-300 rounded-lg p-4 mb-6",children:[(0,o.jsx)("legend",{className:"text-lg font-semibold text-gray-700",children:"Test Configuration"}),(0,o.jsxs)(N.kC,{direction:"column",gap:"small",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("span",{children:["Cache key: ",(0,o.jsx)("code",{className:"text-sm",children:W})]}),(0,o.jsx)(B.z,{onClick:()=>{localStorage.removeItem("cacheKey"),window.location.reload()},children:"Reset"})]}),(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("span",{children:["Cache buster: ",(0,o.jsx)("code",{className:"text-sm",children:T})]}),(0,o.jsx)(B.z,{onClick:()=>{localStorage.removeItem("cacheBuster"),window.location.reload()},children:"Reset"})]}),(0,o.jsxs)(N.kC,{gap:"medium",children:[(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)(O.Y,{renderLabel:"Size of data (kb):",onChange:e=>{let t=Math.max(1024*Number.parseInt(e.target.value),1024);y(t),localStorage.setItem("itemSize",String(t))},onIncrement:()=>{let e=Math.max(Math.round(w)+1024,1024);y(e),localStorage.setItem("itemSize",String(e))},onDecrement:()=>{let e=Math.max(Math.round(w)-1024,1024);y(e),localStorage.setItem("itemSize",String(e))},isRequired:!0,value:Math.round(w/1024)})}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)(O.Y,{renderLabel:"Number of chunks:",interaction:"disabled",value:Math.ceil(w/25e3)})})]})]})]}),(0,o.jsxs)("fieldset",{className:"border border-gray-300 rounded-lg p-4",children:[(0,o.jsx)("legend",{className:"text-lg font-semibold text-gray-700",children:"Performance Tests"}),(0,o.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:j,children:"setItem"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"generate test data",renderValue:null!==c?`${Math.round(a||0)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"setItem",renderValue:null!==c?`${Math.round(c)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"hash",renderValue:e||(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:v,children:"getItem"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"getItem",renderValue:null!==d?`${Math.round(d)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"hash",renderValue:r||(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:I,children:"count"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"clear",renderValue:null!==u?`${Math.round(u)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:(0,o.jsx)($.j,{renderLabel:"chunks",renderValue:"number"==typeof g?g:(0,o.jsx)(G,{})})})]})})]})}),(0,o.jsx)(D.G,{as:"span",display:"inline-block",margin:"none",padding:"medium",background:"primary",shadow:"resting",children:(0,o.jsxs)(N.kC,{direction:"column",children:[(0,o.jsx)(B.z,{color:"primary",onClick:C,children:"clear"}),(0,o.jsx)(D.G,{padding:"medium 0 0 0",children:(0,o.jsxs)(N.kC,{children:[(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"}),(0,o.jsx)(N.kC.Item,{shouldGrow:!0,children:(0,o.jsx)($.j,{renderLabel:"clear",renderValue:null!==p?`${Math.round(p)} ms`:(0,o.jsx)(G,{})})}),(0,o.jsx)(N.kC.Item,{size:"33.3%",children:"\xa0"})]})})]})})]})]})]})]})})]})},{})}))}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.m=e,r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},(()=>{var e,t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__};r.t=function(n,o){if(1&o&&(n=this(n)),8&o||"object"==typeof n&&n&&(4&o&&n.__esModule||16&o&&"function"==typeof n.then))return n;var i=Object.create(null);r.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&o&&n;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(function(e){a[e]=function(){return n[e]}});return a.default=function(){return n},r.d(i,a),i}})(),r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e=[];r.O=function(t,n,o,i){if(n){i=i||0;for(var a=e.length;a>0&&e[a-1][2]>i;a--)e[a]=e[a-1];e[a]=[n,o,i];return}for(var s=1/0,a=0;a=i)&&Object.keys(r.O).every(function(e){return r.O[e](n[l])})?n.splice(l--,1):(c=!1,i{var e={980:0};r.O.j=function(t){return 0===e[t]};var t=function(t,n){var o=n[0],i=n[1],a=n[2],s,c,l=0;if(o.some(function(t){return 0!==e[t]})){for(s in i)r.o(i,s)&&(r.m[s]=i[s]);if(a)var d=a(r)}for(t&&t(n);l