//>>built define(["dojo","dijit","dojox","dojo/require!dojox/storage/manager,dojox/storage/Provider"],function(g,l,h){g.provide("dojox.storage.AirDBStorageProvider");g.require("dojox.storage.manager");g.require("dojox.storage.Provider");g.isAIR&&function(){if(!f)var f={};f.File=window.runtime.flash.filesystem.File;f.SQLConnection=window.runtime.flash.data.SQLConnection;f.SQLStatement=window.runtime.flash.data.SQLStatement;g.declare("dojox.storage.AirDBStorageProvider",[h.storage.Provider],{DATABASE_FILE:"dojo.db", TABLE_NAME:"__DOJO_STORAGE",initialized:!1,_db:null,initialize:function(){this.initialized=!1;try{this._db=new f.SQLConnection,this._db.open(f.File.applicationStorageDirectory.resolvePath(this.DATABASE_FILE)),this._sql("CREATE TABLE IF NOT EXISTS "+this.TABLE_NAME+"(namespace TEXT, key TEXT, value TEXT)"),this._sql("CREATE UNIQUE INDEX IF NOT EXISTS namespace_key_index ON "+this.TABLE_NAME+" (namespace, key)"),this.initialized=!0}catch(a){console.debug("dojox.storage.AirDBStorageProvider.initialize:", a)}h.storage.manager.loaded()},_sql:function(a,b){var c=new f.SQLStatement;c.sqlConnection=this._db;c.text=a;if(b)for(var d in b)c.parameters[d]=b[d];c.execute();return c.getResult()},_beginTransaction:function(){this._db.begin()},_commitTransaction:function(){this._db.commit()},isAvailable:function(){return!0},put:function(a,b,c,d){if(0==this.isValidKey(a))throw Error("Invalid key given: "+a);d=d||this.DEFAULT_NAMESPACE;if(0==this.isValidKey(d))throw Error("Invalid namespace given: "+d);try{this._sql("DELETE FROM "+ this.TABLE_NAME+" WHERE namespace \x3d :namespace AND key \x3d :key",{":namespace":d,":key":a}),this._sql("INSERT INTO "+this.TABLE_NAME+" VALUES (:namespace, :key, :value)",{":namespace":d,":key":a,":value":b})}catch(e){console.debug("dojox.storage.AirDBStorageProvider.put:",e);c(this.FAILED,a,e.toString());return}c&&c(this.SUCCESS,a,null,d)},get:function(a,b){if(0==this.isValidKey(a))throw Error("Invalid key given: "+a);b=b||this.DEFAULT_NAMESPACE;a=this._sql("SELECT * FROM "+this.TABLE_NAME+" WHERE namespace \x3d :namespace AND key \x3d :key", {":namespace":b,":key":a});return a.data&&a.data.length?a.data[0].value:null},getNamespaces:function(){var a=[this.DEFAULT_NAMESPACE],b=this._sql("SELECT namespace FROM "+this.TABLE_NAME+" DESC GROUP BY namespace");if(b.data)for(var c=0;c