//>>built define(["dojo","dijit","dojox","dojo/require!dojo/gears,dojox/storage/Provider,dojox/storage/manager,dojox/sql"],function(f,m,c){f.provide("dojox.storage.GearsStorageProvider");f.require("dojo.gears");f.require("dojox.storage.Provider");f.require("dojox.storage.manager");f.require("dojox.sql");f.gears.available&&function(){f.declare("dojox.storage.GearsStorageProvider",c.storage.Provider,{constructor:function(){},TABLE_NAME:"__DOJO_STORAGE",initialized:!1,_available:null,_storageReady:!1,initialize:function(){1!= f.config.disableGearsStorage&&(this.TABLE_NAME="__DOJO_STORAGE",this.initialized=!0,c.storage.manager.loaded())},isAvailable:function(){return this._available=f.gears.available},put:function(a,b,e,d){this._initStorage();if(!this.isValidKey(a))throw Error("Invalid key given: "+a);d=d||this.DEFAULT_NAMESPACE;if(!this.isValidKey(d))throw Error("Invalid namespace given: "+a);b=f.isString(b)?"string:"+b:f.toJson(b);try{c.sql("DELETE FROM "+this.TABLE_NAME+" WHERE namespace \x3d ? AND key \x3d ?",d,a), c.sql("INSERT INTO "+this.TABLE_NAME+" VALUES (?, ?, ?)",d,a,b)}catch(h){console.debug("dojox.storage.GearsStorageProvider.put:",h);e(this.FAILED,a,h.toString(),d);return}e&&e(c.storage.SUCCESS,a,null,d)},get:function(a,b){this._initStorage();if(!this.isValidKey(a))throw Error("Invalid key given: "+a);b=b||this.DEFAULT_NAMESPACE;if(!this.isValidKey(b))throw Error("Invalid namespace given: "+a);a=c.sql("SELECT * FROM "+this.TABLE_NAME+" WHERE namespace \x3d ? AND key \x3d ?",b,a);if(a.length)a=a[0].value; else return null;return a=f.isString(a)&&/^string:/.test(a)?a.substring(7):f.fromJson(a)},getNamespaces:function(){this._initStorage();for(var a=[c.storage.DEFAULT_NAMESPACE],b=c.sql("SELECT namespace FROM "+this.TABLE_NAME+" DESC GROUP BY namespace"),e=0;e