!function(t,e){"use strict";"object"==typeofmodule&&module.exports?module.exports=e(t.Record):t.Record=e(t.Record)}(this,function(){"use strict";returnclass{constructor(t){if(this.store=(t||{}).store,this.debug=(t||{}).debug||!1,this.records=[],this.store&&localStorage){this._log("Initializing localStorage for "+this.store);lett=this._load()||[];this.records=[...t]}}_log(){this.debug&&console.log(...arguments)}add(t){if(Array.isArray(t)){lete=[];returnt.forEach(()=>{t.id||(t.id=Math.random().toString(36).substr(2,9)),this.records.push(t),this.entries.push(t)}),this._save(),e}returnt.id||(t.id=Math.random().toString(36).substr(2,9)),this.records.push(t),this._save(),t}update(t){vare=this.records.indexOf(t);returnthis.records[e].id===t.id&&(this.records.splice(e,1,t),this._save(),t)}find(t){if(!t)returnthis.records;if("string"==typeoft||"number"==typeoft)returnthis.records.filter(e=>e.id===t);lete=Object.keys(t);returnthis.records.filter(r=>-1!==e.indexOf("id")?r.id===t.id:e.every(e=>r[e]===t[e]))}remove(t){if(!t||Array.isArray(t))returnthis._log(console.error("remove() accepts a single object")),[];lete=this.find(t);returne.forEach(t=>{this.records.splice(this.records.indexOf(t),1)}),this._save(),e}clear(){this.records=[],this._save()}_save(){this.store&&localStorage&&localStorage.setItem(this.store,JSON.stringify(this.records))}_load(){if(this.store&&localStorage)returnJSON.parse(localStorage.getItem(this.store))||[]}dump(){!function(t,e){letr=document.createElement("a"),s=newBlob([e],{type:"text/plain"});r.href=URL.createObjectURL(s),r.download=t,r.click()}(`${this.store||"data"}.json`,JSON.stringify(this._load(),null,4))}}});