Registry.require(["promise","helper","asker"],function(){var e=Registry.get("promise"),l=Registry.get("helper"),m=Registry.get("asker"),c=!1,d=null,h=null,f=function(){return c?c:e.Pledge()},n=function(a){rea.permissions.supported&&(rea.permissions.onAdded.addListener(function(b){a({added:b})}),rea.permissions.onRemoved.addListener(function(b){a({removed:b})}))},g={permDownloads:"downloads",get:function(){var a=e();d={};h={};c=a.promise();rea.permissions.supported?rea.permissions.getAll(function(b){b.permissions&&
l.each(b.permissions,function(a,b){d[a]=!0});b.origins&&l.each(b.origins,function(a,b){h[a]=!0});c=null;a.resolve()}):a.resolve();return a.promise()},has:function(a){return f().then(function(){return rea.permissions.supported?d?!!d[a]||!!h[a]:(n(function(){f().then(g.get)}),g.get().then(function(){return g.has(a)})):!0})},hasOrigin:function(a){Array.isArray(a)||(a=[a]);return f().then(function(){var b=e();rea.permissions.supported?rea.permissions.contains({origins:a},function(a){b.resolve(a)}):b.resolve(!0);
return b.promise()})},ask:function(a,b,c){Array.isArray(a)||(a=[a]);var k=e();rea.permissions.supported?m.askForPermission({permissions:a},b,c).done(function(b){b.granted&&(d||(d={}),d[a]=!0);k.resolve(b.granted)}):k.resolve(!1);return k.promise()},askOrigin:function(a,b,d){Array.isArray(a)||(a=[a]);var c=e();rea.permissions.supported?m.askForPermission({origins:a},b,d).done(function(a){c.resolve(a.granted)}):c.resolve(!1);return c.promise()},remove:function(a){return f().then(function(){var b=e();
rea.permissions.supported?(c=b.promise(),rea.permissions.remove({permissions:[a]},function(e){c=null;d&&(d[a]=!1);b.resolve(e)})):b.resolve(!0);return b.promise()})},addListener:n};Registry.register("permission","6095",g)});
