text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("request"),require("cheerio"),require("bluebird")):"function"==typeof define&&define.amd?define("wikifakt",["request","cheerio","bluebird"],t):"object"==typeof exports?exports.wikifakt=t(require("request"),require("cheerio"),require("bluebird")):e.wikifakt=t(e.request,e.cheerio,e.bluebird)}(this,function(e,t,r){return function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=i(n),a=r(2),u=i(a),d=r(3),c=i(d),f="https://en.wikipedia.org/wiki/Special:Random",l="https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=";t["default"]={factLengthLimit:200,preload:!0,preloadedFact:"",getRandomFact:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];return new c["default"](function(r,i){var n=!1;e.preload&&""!==e.preloadedFact&&(n=!0,r(e.preloadedFact),e.preloadedFact=""),e.getRandomArticleTitle().then(function(i){var a=i.split(" ").join("%20");(0,o["default"])(l+a,function(i,o,a){if(i||200!==o.statusCode||""===a)n||e.getRandomFact(t).then(function(e){r(e)});else{var u=JSON.parse(a),d=Object.keys(u.query.pages);if(0===d.length)return e.getRandomFact();var c=u.query.pages[d[0]],f=c.extract;if(f&&""!==f){if(f.length>e.factLengthLimit){var l=f.split(".");f=l[0]+=".",f.length<e.factLengthLimit&&l.length>1&&(f+=l[1]+".")}n?e.preloadedFact=f:(r(f),!t&&e.preload&&""===e.preloadedFact&&e.getRandomFact(!0).then(function(t){e.preloadedFact=t}))}else e.getRandomFact(t).then(function(e){r(e)})}})})})},getRandomArticleTitle:function(){return new c["default"](function(e,t){(0,o["default"])(f,function(r,i,n){if(r||200!==i.statusCode)t(r);else{var o=u["default"].load(n),a=o("#firstHeading").text();e(a)}})})}},e.exports=t["default"]},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r}])});
  //# sourceMappingURL=wikifakt.min.js.map