define(["idbcore"],function(idb){"use strict";var databaseInstance,indexedDB=self.indexedDB,dbName="useractions",dbVersion=2;function getActionDb(){return new Promise(function(resolve,reject){var request;databaseInstance?resolve(databaseInstance):((request=indexedDB.open(dbName,dbVersion)).onerror=reject,request.onblocked=reject,request.onupgradeneeded=function(event){var db=request.result;event.oldVersion<1&&db.createObjectStore(dbName),event.oldVersion<2&&request.transaction.objectStore(dbName).createIndex("Index_ServerId","ServerId")},request.onsuccess=function(event){var db=event.target.result;db.onversionchange=function(){db.close(),databaseInstance=null},resolve(databaseInstance=db)})})}function deleteUserAction(key){return getActionDb().then(function(db){return idb.deleteObject(db,key)})}return{getUserAction:function(key){return getActionDb().then(function(db){return idb.getObjectByKey(db,key)})},addUserAction:function(key,val){return getActionDb().then(function(db){return idb.addObject(db,key,val)})},deleteUserAction:deleteUserAction,deleteUserActions:function(keys){return Promise.all(keys.map(deleteUserAction))},clearUserActions:function(){return getActionDb().then(function(db){return idb.clearObjects(db)})},getByServerId:function(serverId){return getActionDb().then(function(db){return idb.getObjectsByIndexKeys(db,"Index_ServerId",serverId)})}}});