b[f].resources[g].copySync(u,l);return}}}if(h&&e)return a=h.skin.path,"\\"==c.sep&&(a=a.replace(/\\/g,"/")),a=a.split("/"),2<a.length&&(a[a.length-2]=a[a.length-2]+"_"+y),a=a.join(c.sep),a=a+c.sep+h.type+c.sep+h.name+c.sep+e.name,p=w+c.sep+h.type+c.sep+h.name,(e=t(p,e.name,a))?"custom/"+h.type+"/"+h.name+"/"+e:null};f.waterfall([function(a){v?a():d.remove(u,function(b){a(b)})},function(a){this.getRemoteWidgets(n,k,h?l:null,v,function(b,c){b?a(b):d.exists(x,function(b){b?d.move(x,A,function(b){a(b,
c)}):a(null,c)})}.bind(this))}.bind(this),function(b,d){a.processResourceList({resourceBuf:[],widgetBuf:[],processResourceSync:function(a){for(var c=0;c<this.resourceBuf.length;c++)if(this.resourceBuf[c]&&this.resourceBuf[c].ref==a)return this.resourceBuf[c].newRef;try{var d=C(a,b);this.resourceBuf.push({ref:a,newRef:d});return d}catch(F){return null}},processWidgetSync:function(a){for(var d=0;d<this.widgetBuf.length;d++){var f=this.widgetBuf[d];if(f&&f.widgetType==a.widgetType&&f.widgetName==a.widgetName)return}try{for(d=
g.remoteId,function(a,d){if(a)b&&b(a);else{var e=c.join(d+c.sep+m.aio.skinmanager.SkinManager.RESOURCE_FOLDER+c.sep+m.aio.skinmanager.SkinManager.CUSTOM_IN_REMOTE_WIDGET_FOLDER,g.widgetType,g.widgetName,g.resourcePath);f.exists(e,function(a){a?b&&b(null,e):b&&b(Error("no such resource"))})}}.bind(this)):b&&b(Error("no such resource"))},deleteResourceByURL:function(a,b){var e=require("path"),d=require("fs");a=m.aio.skinmanager.Url.resolve(a);if(a instanceof m.aio.skinmanager.LocalCustomWidgetUrl){var c=
this.customWidgetPath+e.sep+a.widgetType+e.sep+a.widgetName+e.sep+a.resourcePath;d.exists(c,function(a){a?d.unlink(c,function(a){b&&b(a)}):b&&b()})}else b&&b(Error("can not delete this type of resource"))},getSkinList:function(a,b,e){var d=[];a&&b?this._getInRemoteSkins(a,b,function(c,b){if(!c&&b)if(1==b.length)d.push(b[0]);else for(c=0;c<b.length;c++)if(b[c].base){d.push(b[c]);break}this._getPermittedSkins(a,this.skins,function(a,b){!a&&b&&(d=d.concat(b));e&&e(null,d)})}.bind(this)):this._getPermittedSkins(a,