text: var gdjs;(function(S){const f=new S.Logger("Storage");let d;(function(p){let h;(function(a){let c=null;try{typeof cc!="undefined"?c=cc.sys.localStorage:typeof window!="undefined"&&(c=window.localStorage)}catch(t){f.error("Unable to get access to the localStorage: "+t)}c||f.error("Storage actions won't work as no localStorage was found.");const u=new Hashtable;a.loadJSONFileFromStorage=t=>{if(u.containsKey(t))return;let i=null;try{c&&(i=c.getItem("GDJS_"+t))}catch(l){f.error('Unable to load data from localStorage for "'+t+'": '+l)}let o={};try{i&&(o=JSON.parse(i))}catch(l){f.error('Unable to load data from "'+t+'" - data is not valid JSON: '+l)}u.put(t,o)},a.unloadJSONFile=t=>{if(!u.containsKey(t))return;const i=u.get(t),o=JSON.stringify(i);try{c&&c.setItem("GDJS_"+t,o)}catch(l){f.error('Unable to save data to localStorage for "'+t+'": '+l)}u.remove(t)};const g=(t,i)=>{let o=!1;u.containsKey(t)||(o=!0,a.loadJSONFileFromStorage(t));const l=i(u.get(t));return o&&a.unloadJSONFile(t),l};a.clearJSONFile=t=>g(t,i=>{for(const o in i)i.hasOwnProperty(o)&&delete i[o];return!0}),a.elementExistsInJSONFile=(t,i)=>g(t,o=>{const l=i.split("/");let n=o;for(let e=0;e<l.length;++e){if(!n[l[e]])return!1;n=n[l[e]]}return!0}),a.deleteElementFromJSONFile=(t,i)=>g(t,o=>{const l=i.split("/");let n=o;for(let e=0;e<l.length;++e){if(!n[l[e]])return!1;e===l.length-1?delete n[l[e]]:n=n[l[e]]}return!0}),a.writeNumberInJSONFile=(t,i,o)=>g(t,l=>{const n=i.split("/");let e=l;for(let r=0;r<n.length;++r)e[n[r]]||(e[n[r]]={}),r===n.length-1?e[n[r]].value=o:e=e[n[r]];return!0}),a.writeStringInJSONFile=(t,i,o)=>g(t,l=>{const n=i.split("/");let e=l;for(let r=0;r<n.length;++r)e[n[r]]||(e[n[r]]={}),r===n.length-1?e[n[r]].str=o:e=e[n[r]];return!0}),a.readNumberFromJSONFile=(t,i,o,l)=>g(t,n=>{const e=i.split("/");let r=n;for(let s=0;s<e.length;++s){if(!r[e[s]])return!1;s===e.length-1&&typeof r[e[s]].value!="undefined"?l.setNumber(r[e[s]].value):r=r[e[s]]}return!0}),a.readStringFromJSONFile=(t,i,o,l)=>g(t,n=>{const e=i.split("/");let r=n;for(let s=0;s<e.length;++s){if(!r[e[s]])return!1;s===e.length-1&&typeof r[e[s]].str!="undefined"?l.setString(r[e[s]].str):r=r[e[s]]}return!0})})(h=p.storage||(p.storage={}))})(d=S.evtTools||(S.evtTools={}))})(gdjs||(gdjs={}));
  //# sourceMappingURL=storagetools.js.map
  