import loader = require ( './loader' ) ; declare var process ; declare var require ; module has { export interface IHas { ( name ) : any ; add ( name , value , now ? , force ? ) : void ; add ( name , value , now ? , force ? ) : void ; } } interface has extends has . IHas , loader . ILoaderPlugin { } var has = require . has ; if ( ! has ) { has = ( function ( ) : has { var hasCache = Object . create ( null ) ; var global = this ; var document = global . document ; var element = document && document . createElement ( 'div' ) ; var has = < has > function ( name ) : any { return typeof hasCache [ name ] === 'function' ? ( hasCache [ name ] = hasCache [ name ] ( global , document , element ) ) : hasCache [ name ] ; } ; has . add = function ( name , test , now , force ) : void { ( ! ( name in hasCache ) || force ) && ( hasCache [ name ] = test ) ; now && has ( name ) ; } ; return has ; } ) ( ) ; has . add ( 'host-browser' , typeof document !== 'undefined' && typeof location !== 'undefined' ) ; has . add ( 'host-node' , typeof process === 'object' && process . versions && process . versions . node ) ; has . add ( 'debug' , true ) ; } has . normalize = function ( resourceId , normalize ) : string { var tokens = resourceId . match ( /[\?:]|[^:\?]*/g ) ; var i = 0 ; function get ( skip ? ) { var term = tokens [ i ++ ] ; if ( term === ':' ) { return null ; } else { if ( tokens [ i ++ ] === '?' ) { if ( ! skip && has ( term ) ) { return get ( ) ; } else { get ( true ) ; return get ( skip ) ; } } return term ; } } resourceId = get ( ) ; return resourceId && normalize ( resourceId ) ; } ; has . load = function ( resourceId , require , load ) : void { if ( resourceId ) { require ( [ resourceId ] , load ) ; } else { load ( ) ; } } ; export = has ;