text: !function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.GiphyAPI=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function _handleErr(err,callback){if(callback)return callback(err);if(promisesExist)return Promise.reject(err);throw new Error(err)}var queryString=require("querystring"),httpService=require("./util/http"),API_HOSTNAME="api.giphy.com",API_BASE_PATH="/v1/",PUBLIC_BETA_API_KEY="dc6zaTOxFJmzC",promisesExist="undefined"!=typeof Promise,GiphyAPI=function(options){if("string"==typeof options||"undefined"==typeof options||null===options)this.apiKey=options||PUBLIC_BETA_API_KEY,options={};else{if("object"!=typeof options)throw new Error("Invalid options passed to giphy-api");this.apiKey=options.apiKey||PUBLIC_BETA_API_KEY}this.https=options.https,this.timeout=options.timeout||3e4};GiphyAPI.prototype={search:function(options,callback){return options?this._request({api:options.api||"gifs",endpoint:"search",query:"string"==typeof options?{q:options}:options},callback):_handleErr("Search phrase cannot be empty.",callback)},id:function(id,callback){var idIsArr=Array.isArray(id);return!id||idIsArr&&0===id.length?_handleErr("Id required for id API call",callback):(idIsArr&&(id=id.join()),this._request({api:"gifs",query:{ids:id}},callback))},translate:function(options,callback){return options?this._request({api:options.api||"gifs",endpoint:"translate",query:"string"==typeof options?{s:options}:options},callback):_handleErr("Translate phrase cannot be empty.",callback)},random:function(options,callback){var reqOptions={api:(options?options.api:null)||"gifs",endpoint:"random"};return"string"==typeof options?reqOptions.query={tag:options}:"object"==typeof options?reqOptions.query=options:"function"==typeof options&&(callback=options),this._request(reqOptions,callback)},trending:function(options,callback){var reqOptions={endpoint:"trending"};return reqOptions.api=(options?options.api:null)||"gifs",options&&delete options.api,"object"==typeof options&&0!==Object.keys(options).length?reqOptions.query=options:"function"==typeof options&&(callback=options),this._request(reqOptions,callback)},_request:function(options,callback){if(!callback&&!promisesExist)throw new Error("Callback must be provided if promises are unavailable");var endpoint="";options.endpoint&&(endpoint="/"+options.endpoint),endpoint+="?";var query,self=this;if("undefined"!=typeof options.query&&"object"==typeof options.query){if(0===Object.keys(options.query).length)return callback?callback("Options object should not be empty"):Promise.reject("Options object should not be empty");options.query.api_key=this.apiKey,query=queryString.stringify(options.query)}else query=queryString.stringify({api_key:self.apiKey});var httpOptions={request:{host:API_HOSTNAME,path:API_BASE_PATH+options.api+endpoint+query},https:this.https,timeout:this.timeout,fmt:options.query&&options.query.fmt},makeRequest=function(resolve,reject){httpService.get(httpOptions,resolve,reject)};if(!callback){if(!promisesExist)throw new Error("Callback must be provided unless Promises are available");return new Promise(function(resolve,reject){makeRequest(resolve,reject)})}var resolve=function(res){callback(null,res)},reject=function(err){callback(err)};makeRequest(resolve,reject)}},module.exports=function(apiKey,options){return new GiphyAPI(apiKey,options)}},{"./util/http":5,querystring:4}],2:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;maxKeys>0&&len>maxKeys&&(len=maxKeys);for(var i=0;i<len;++i){var kstr,vstr,k,v,x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq);idx>=0?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],3:[function(require,module,exports){"use strict";function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i<xs.length;i++)res.push(f(xs[i],i));return res}var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)},objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],4:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":2,"./encode":3}],5:[function(require,module,exports){exports.get=function(options,resolve,reject){var request=options.request,timeout=options.timeout,fmt=options.fmt,timerId=setTimeout(function(){reject(new Error("Timeout while fetching asset"))},timeout),xhr=new XMLHttpRequest;xhr.withCredentials=!1;var onFail=function(err){clearTimeout(timerId),err=err||new Error("Giphy API request failed!"),reject(err)};xhr.addEventListener("error",onFail),xhr.addEventListener("abort",onFail),xhr.addEventListener("load",function(){clearTimeout(timerId);var body=xhr.response;"html"!==fmt&&(body=JSON.parse(body)),resolve(body)});var protocol=options.https?"https":"http",host=request.host,path=request.path,url=protocol+"://"+host+path;xhr.open("GET",url,!0),xhr.send()}},{}]},{},[1])(1)});