classDefineLoclStorage{staticgetItem(key =""){let data = localStorage.getItem(key);try{
data =JSON.parse(data);}catch(error){throw error;}return data;}staticgetItemPubsub(key, cb){if(!Array.isArray(this.EventList[key])){this.EventList[key]=[];}constID=++this.EventId;this.EventList[key].push({id:ID,
cb,});returnID;}staticclearItemEvent(key, id){if(!Array.isArray(this.EventList[key])){this.EventList[key]=[];}this.EventList[key]=this.EventList[key].filter((item)=> item.id !== id
);}staticdispatch(key, value){const data = value ||this.getItem(key);const event =this.EventList[key]||[];
event.forEach((item)=>{if(typeof item?.cb =="function"){
item?.cb(data);}});}staticsetItem(key, data){
localStorage.setItem(key,JSON.stringify(data));this.dispatch(key, data);}staticpushItem(key, value){const data =this.getItem(key)||[];
data.push(value);this.setItem(key, data);}staticsetArraryItem(key,cb){if(typeof cb !=="function"){thrownewError('cb must be a gunction')return}this.setItem(key,cb(this.getItem(key)))}static EventList ={};static EventId =0;}