UNPKG

latte_lib

Version:
2 lines 48.8 kB
!function(){function t(t){var e=function(t,e){return i("",t,e)},o=n;t&&(n[t]||(n[t]={}),o=n[t]),o.define&&o.define.packaged||(r.original=o.define,o.define=r,o.define.packaged=!0),o.require&&o.require.packaged||(i.original=o.require,o.require=e,o.require.packaged=!0,o.require.find=function(t,e){var n=t.length,i=[];return Object.keys(r.modules).forEach(function(r){if(0==r.indexOf(t)){var o=r.substring(n);e?i.push(o):o.indexOf("/")==-1&&i.push(o)}}),i})}var e="latte",n=function(){return this}();if(e||"undefined"==typeof requirejs){var r=function(t,e,n){return"string"!=typeof t?void(r.original?r.original.apply(window,arguments):(console.error("dropping module because define wasn't a string."),console.trace())):(2==arguments.length&&(n=e),r.modules||(r.modules={},r.payloads={}),r.payloads[t]=n,void(r.modules[t]=null))},i=function(t,e,n){if("[object Array]"===Object.prototype.toString.call(e)){for(var r=[],o=0,s=e.length;o<s;++o){var u=a(t,e[o]);if(!u&&i.original)return i.original.apply(window,arguments);r.push(u)}n&&n.apply(null,r)}else{if("string"==typeof e){var c=a(t,e);return!c&&i.original?i.original.apply(window,arguments):(n&&n(),c)}if(i.original)return i.original.apply(window,arguments)}},o=function(t,e){if("."==e.charAt(0)){for(var n,r=t.split("/"),i=(r.pop(),e.split("/"));n=i.shift();)".."==n?r.pop():"."!=n&&r.push(n);return r.join("/")}return e},s=function(t,e){if(e.indexOf("!")!==-1){var n=e.split("!");return s(t,n[0])+"!"+s(t,n[1])}return name=o(t,e),name},a=function(t,e){e=s(t,e);var o=r.modules[e];if(!o){if(o=r.payloads[e],"function"==typeof o){var u={},c={id:e,uri:"",exports:u,packaged:!0},l=function(t,n){return i(e,t,n)},f=o(l,u,c,n);u=f||c.exports,r.modules[e]=u,delete r.payloads[e]}o=u||o,o||e.indexOf(".js")!=-1||(o=r.modules[e]=a(t,e+".js")),o||e.indexOf("/index")!=-1||(o=r.modules[e]=a(t,e+"/index")),o||e.indexOf("/index.js")!=-1||(o=r.modules[e]=a(t,e+"/index.js"))}return r.modules[e]=o,o};t(e)}}(),latte.global=this,this.define=latte.define,latte.config={},function(){this.config={}}.call(latte),function(t){"use strict";t("latte_lib/basic/array.js",["require","exports","module","window"],function(t,e,n,r){var i=t("./lib.js"),o=t("./events.js"),s=t("./object"),a=function(t){var e=this;this.data=[];var n=function(n,r,i){var s=e.data.indexOf(this);s!=-1?(e.emit(s+"."+n,r,i,t),e.emit("change",s+"."+n,r,i,t)):o(this)},r=function(t){t.on("change",n)},o=function(t){s.isLatteObject(t)&&t.off("change",n)};!function(){t.forEach(function(t,n){var i=s.create(t);i?(r(i),e.data[n]=i):e.data[n]=t})}();var a=function(n,a,u){if(i.isArray(n)||(n=n.toString().split(".")),1!=n.length){for(var c,l=n.pop(),f=e,h=0,p=n.length;h<p;h++)c=f,f=f.get(n[h]),f||(f=new s({}),c.set(n[h],f));return e.get(n).set(l,a,u)}var d,l=n[0],y=e.data[l];t[l];switch(u){case 1:break;default:o(y);var d=s.create(a);return d?r(d):d=a,e.data[l]=d,t[l]=a,{ov:y,nv:d}}};this._set=a,this.set=function(t,n,r){var i=a(t,n,r);return t.indexOf(".")==-1&&(e.emit("change",t,i.nv,i.ov),e.emit(t,i.nv,i.ov)),e.emit("set",t,i.nv,i.ov),i},this.get=function(t){if("this"==t&&!e.data[t])return e;i.isArray(t)||(t=t.toString().split("."));if(1==t.length)return e.data[t[0]];var n=t.shift();return e.data[n].get(t)},this.push=function(t){var n=e.data.length,r=a(n,t);e.emit("splice",n,[],[r.nv]),e.emit("change",n,r.nv)},this.pop=function(){var t=a(e.length-1,null);e.data.pop(),e.emit("splice",e.length,[t.ov],[])},this.shift=function(){var t=e.data.shift();o(t),e.emit("splice",0,[t],[]);for(var n=0,r=e.data.length;n<r;n++)e.emit("change",n,e.data[n]);e.emit("change",e.data.length,null)},this.unshift=function(){var t=Array.prototype.map.call(arguments,function(t){var e=s.create(t);return e&&e.on("change",n),e||t});e.data.unshift.apply(e.data,t),e.emit("splice",0,[],t);for(var r=0,i=e.data.length;r<i;r++)e.emit("change",r,e.data[r])},this.splice=function(t,r){for(var i=e.data.length,a=Array.prototype.splice.call(arguments,2).map(function(t){var e=s.create(t);return e&&e.on("change",n),e||t}),u=[],c=0;c<r;c++){var l=e.get(t+c);l&&(o(l),u.push(l))}e.data.splice.apply(e.data,[t,r].concat(a)),e.emit("splice",t,u,a);for(var c=0,f=Math.max(i,e.data.length);c<f;c++)e.emit("change",c,e.data[c])},this.toJSON=function(){return t},this.indexOf=function(t){return e.data.indexOf(t)},this.forEach=function(t){e.data.forEach(t)},this.map=function(t){return e.data.map(t)},this.filter=function(t){return e.data.filter(t)},Object.defineProperty(e,"length",{get:function(){return e.data.length},set:function(t){throw new Error("暂时没处理")}}),this.getKeys=function(){return Object.keys(e.data)}};i.inherits(a,o),function(){}.call(a),n.exports=a})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/basic/async.js",["require","exports","module","window"],function(t,e,n,r){var i=t("./lib.js");i||console.log("no load lib"),function(){var t=this;this.setImmediate=i.setImmediate;var e=this.only_once=function(e){var n=!1;return function(){if(n)throw new Error("Callback was already called.");n=!0,e.apply(t,arguments)}};this.forEach=this.each=function(t,n,r){function o(e){e?(r(e),r=function(){}):(s+=1,s>=t.length&&r())}if(r=r||function(){},!t.length)return r();var s=0;i.forEach(t,function(t){n(t,e(o))})},this.forEachSeries=this.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0;!function i(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})}()},this.forEachLimit=this.eachLimit=function(t,e,r,i){var o=n(e);o.apply(null,[t,r,i])};var n=function(t){return function(e,n,r){if(r=r||function(){},!e.length||t<=0)return r();var i=0,o=0,s=0;!function a(){if(i>=e.length)return r();for(;s<t&&o<e.length;)o+=1,s+=1,n(e[o-1],function(t){t?(r(t),r=function(){}):(i+=1,s-=1,i>=e.length?r():a())})}()}},r=function(e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[t.each].concat(n))}},o=function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[n(t)].concat(r))}},s=function(e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[t.eachSeries].concat(n))}},a=function(t,e,n,r){if(e=i.map(e,function(t,e){return{index:e,value:t}}),r){var o=[];t(e,function(t,e){n(t.value,function(n,r){o[t.index]=r,e(n)})},function(t){r(t,o)})}else t(e,function(t,e){n(t.value,function(t){e(t)})})};this.map=r(a),this.mapSeries=s(a);var u=function(t){return o(t,a)};this.mapLimit=function(t,e,n,r){return u(e)(t,n,r)},this.inject=this.foldl=this.reduce=function(e,n,r,i){t.eachSeries(e,function(t,e){r(n,t,function(t,r){n=r,e(t)})},function(t){i(t,n)})},this.foldr=this.reduceRight=function(e,n,r,o){var s=i.map(e,function(t){return t}).reverse();t.reduce(s,n,r,o)};var c=function(t,e,n,r){var o=[];e=i.map(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&o.push(t),e()})},function(t){r(i.map(o.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};this.select=this.filter=r(c),this.selectSeries=this.filterSeries=s(c);var l=function(t,e,n,r){var o=[];e=i.map(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||o.push(t),e()})},function(t){r(i.map(o.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};this.reject=r(l),this.rejectSeries=s(l);var f=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(t){r()})};this.detect=r(f),this.detectSeries=s(f),this.any=this.some=function(e,n,r){t.each(e,function(t,e){n(t,function(t){t&&(r(!0),r=function(){}),e()})},function(t){r(!1)})},this.all=this.every=function(e,n,r){t.each(e,function(t,e){n(t,function(t){t||(r(!1),r=function(){}),e()})},function(t){r(!0)})},this.sortBy=function(e,n,r){t.map(e,function(t,e){n(t,function(n,r){n?e(n):e(null,{value:t,criteria:r})})},function(t,e){if(t)return r(t);var n=function(t,e){var n=t.criteria,r=e.criteria;return n<r?-1:n>r?1:0};r(null,i.map(e.sort(n),function(t){return t.value}))})},this.auto=function(t,e){e=e||function(){};var n=i.keys(t),r=n.length;if(!r)return e();var o={},s=[],a=function(t){s.unshift(t)},u=function(t){for(var e=0;e<s.length;e+=1)if(s[e]===t)return void s.splice(e,1)},c=function(){r--,i.forEach(s.slice(0),function(t){t()})};a(function(){if(!r){var t=e;e=function(){},t(null,o)}}),i.forEach(n,function(n){var r=i.isArray(t[n])?t[n]:[t[n]],s=function(t){var r=Array.prototype.slice.call(arguments,1);if(r.length<=1&&(r=r[0]),t){var s={};i.forEach(i.keys(o),function(t){s[t]=o[t]}),s[n]=r,e(t,s),e=function(){}}else o[n]=r,i.setImmediate(c)},l=r.slice(0,Math.abs(r.length-1))||[],f=function(){return i.reduce(l,function(t,e){return t&&o.hasOwnProperty(e)},!0)&&!o.hasOwnProperty(n)};if(f())r[r.length-1](s,o);else{var h=function(){f()&&(u(h),r[r.length-1](s,o))};a(h)}})},this.retry=function(e,n,r){var i=5,o=[];"function"==typeof e&&(r=n,n=e,e=i),e=parseInt(e,10)||i;var s=function(i,s){for(var a=function(t,e){return function(n){t(function(t,r){n(!t||e,{err:t,result:r})},s)}};e;)o.push(a(n,!(e-=1)));t.series(o,function(t,e){e=e[e.length-1],(i||r)(e.err,e.result)})};return r?s():s},this.waterfall=function(e,n){if(n=n||function(){},!i.isArray(e)){var r=new Error("First argument to waterfall must be an array of functions");return n(r)}if(!e.length)return n();var o=function(t){return function(e){if(e)n.apply(null,arguments),n=function(){};else{var r=Array.prototype.slice.call(arguments,1),s=t.next();s?r.push(o(s)):r.push(n),i.setImmediate(function(){t.apply(null,r)})}}};o(t.iterator(e))()};var h=function(t,e,n){if(n=n||function(){},i.isArray(e))t.map(e,function(t,e){t&&t(function(t){var n=Array.prototype.slice.call(arguments,1);n.length<=1&&(n=n[0]),e.call(null,t,n)})},n);else{var r={};t.each(i.keys(e),function(t,n){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[t]=i,n(e)})},function(t){n(t,r)})}};this.parallel=function(e,n){h({map:t.map,each:t.each},e,n)},this.parallelLimit=function(t,e,r){h({map:u(e),each:n(e)},t,r)},this.series=function(e,n){if(n=n||function(){},i.isArray(e))t.mapSeries(e,function(t,e){t&&t(function(t){var n=Array.prototype.slice.call(arguments,1);n.length<=1&&(n=n[0]),e.call(null,t,n)})},n);else{var r={};t.eachSeries(_keys(e),function(t,n){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[t]=i,n(e)})},function(t){n(t,r)})}},this.iterator=function(t){var e=function(n){var r=function(){return t.length&&t[n].apply(null,arguments),r.next()};return r.next=function(){return n<t.length-1?e(n+1):null},r};return e(0)},this.apply=function(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e.concat(Array.prototype.slice.call(arguments)))}};var p=function(t,e,n,r){var i=[];t(e,function(t,e){n(t,function(t,n){i=i.concat(n||[]),e(t)})},function(t){r(t,i)})};this.concat=r(p),this.concatSeries=s(p),this.whilst=function(e,n,r){e()?n(function(i){return i?r(i):void t.whilst(e,n,r)}):r()},this.doWhilst=function(e,n,r){e(function(i){if(i)return r(i);var o=Array.prototype.slice.call(arguments,1);n.apply(null,o)?t.doWhilst(e,n,r):r()})},this.until=function(e,n,r){e()?r():n(function(i){return i?r(i):void t.until(e,n,r)})},this.doUntil=function(e,n,r){e(function(i){if(i)return r(i);var o=Array.prototype.slice.call(arguments,1);n.apply(null,o)?r():t.doUntil(e,n,r)})},this.queue=function(t,n){function r(t,e,n,r){return t.started||(t.started=!0),_isArray(e)||(e=[e]),0==e.length?i.setImmediate(function(){t.drain&&t.drain()}):void i.forEach(e,function(e){var o={data:e,callback:"function"==typeof r?r:null};n?t.tasks.unshift(o):t.tasks.push(o),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),i.setImmediate(t.process)})}void 0===n&&(n=1);var o=0,s={tasks:[],concurrency:n,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(t,e){r(s,t,!1,e)},kill:function(){s.drain=null,s.tasks=[]},unshift:function(t,e){r(s,t,!0,e)},process:function(){if(!s.paused&&o<s.concurrency&&s.tasks.length){var n=s.tasks.shift();s.empty&&0===s.tasks.length&&s.empty(),o+=1;var r=function(){o-=1,n.callback&&n.callback.apply(n,arguments),s.drain&&s.tasks.length+o===0&&s.drain(),s.process()},i=e(r);t(n.data,i)}},length:function(){return s.tasks.length},running:function(){return o},idle:function(){return s.tasks.length+o===0},pause:function(){s.paused!==!0&&(s.paused=!0,s.process())},resume:function(){s.paused!==!1&&(s.paused=!1,s.process())}};return s},this.priorityQueue=function(e,n){function r(t,e){return t.priority-e.priority}function o(t,e,n){for(var r=-1,i=t.length-1;r<i;){var o=r+(i-r+1>>>1);n(e,t[o])>=0?r=o:i=o-1}return r}function s(t,e,n,s){return t.started||(t.started=!0),_isArray(e)||(e=[e]),0==e.length?i.setImmediate(function(){t.drain&&t.drain()}):void i.forEach(e,function(e){var a={data:e,priority:n,callback:"function"==typeof s?s:null};t.tasks.splice(o(t.tasks,a,r)+1,0,a),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),i.setImmediate(t.process)})}var a=t.queue(e,n);return a.push=function(t,e,n){s(a,t,e,n)},delete a.unshift,a},this.cargo=function(t,e){var n=!1,r=[],o={tasks:r,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,n){i.isArray(t)||(t=[t]),i.forEach(t,function(t){r.push({data:t,callback:"function"==typeof n?n:null}),o.drained=!1,o.saturated&&r.length===e&&o.saturated()}),i.setImmediate(o.process)},process:function s(){if(!n){if(0===r.length)return o.drain&&!o.drained&&o.drain(),void(o.drained=!0);var a="number"==typeof e?r.splice(0,e):r.splice(0,r.length),u=i.map(a,function(t){return t.data});o.empty&&o.empty(),n=!0,t(u,function(){n=!1;var t=arguments;i.forEach(a,function(e){e.callback&&e.callback.apply(null,t)}),s()})}},length:function(){return r.length},running:function(){return n}};return o};var d=function(t){return function(e){var n=Array.prototype.slice.call(arguments,1);e.apply(null,n.concat([function(e){var n=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&i.forEach(n,function(e){console[t](e)}))}]))}};this.log=d("log"),this.dir=d("dir"),this.memoize=function(t,e){var n={},r={};e=e||function(t){return t};var o=function(){var o=Array.prototype.slice.call(arguments),s=o.pop(),a=e.apply(null,o);a in n?i.nextTick(function(){s.apply(null,n[a])}):a in r?r[a].push(s):(r[a]=[s],t.apply(null,o.concat([function(){n[a]=arguments;var t=r[a];delete r[a];for(var e=0,i=t.length;e<i;e++)t[e].apply(null,arguments)}])))};return o.memo=n,o.unmemoized=t,o},this.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},this.times=function(e,n,r){for(var i=[],o=0;o<e;o++)i.push(o);return t.map(i,n,r)},this.timesSeries=function(e,n,r){for(var i=[],o=0;o<e;o++)i.push(o);return t.mapSeries(i,n,r)},this.seq=function(){var e=arguments;return function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();t.reduce(e,r,function(t,e,r){e.apply(n,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);r(t,e)}]))},function(t,e){i.apply(n,[t].concat(e))})}},this.compose=function(){return t.seq.apply(null,Array.prototype.reverse.call(arguments))};var y=function(t,e){var n=function(){var n=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(e,function(t,e){t.apply(n,r.concat([e]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return n.apply(this,r)}return n};this.applyEach=r(y),this.applyEachSeries=s(y),this.forever=function(t,e){function n(r){if(r){if(e)return e(r);throw r}t(n)}n()}}.call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/basic/events.js",["require","exports","module","window"],function(t,e,n,r){var i,o=t("./lib.js");if(o.isWindow){var i=function(){this._events=this._events||{}};(i.interface=function(){this.on=this.addEventListener=function(t,e){return this._events=this._events||{},(this._events[t]=this._events[t]||[]).push(e),this},this.once=function(t,e){function n(){r.off(t,n),e.apply(this,arguments)}var r=this;return this._events=this._events||{},n.fn=e,this.on(t,n),this},this.off=this.removeListener=this.removeAllListeners=this.removeEventListener=function(t,e){if(this._events=this._events||{},0==arguments.length)return this._events={},this;var n=this._events[t];if(!n)return this;if(1==arguments.length)return delete this._events[t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return this},this.emit=function(t){this._events=this._events||{};var e=[].slice.call(arguments,1),n=this._events[t];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this},this.listeners=function(t){return this._events=this._events||{},this._events[t]||[]},this.hasEvent=function(t,e){return this.listeners(t).indexOf(e)!=-1}}).call(i.prototype)}else i=t("events").EventEmitter;(function(){this.hasListeners=function(t){return!!this.listeners(t).length}}).call(i.prototype),n.exports=i})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/basic/format.js",["require","exports","module","window"],function(t,e,n,r){var i=t("./lib.js");(function(){function t(t,e){for(var n=t+"";n.length<e;)n="0"+n;return n}function n(e){return t(e,2)}function r(t){var e=Math.abs(t.getTimezoneOffset()),n=String(Math.floor(e/60)),r=String(e%60);return 1==n.length&&(n="0"+n),1==r.length&&(r="0"+r),t.getTimezoneOffset()<0?"+"+n+r:"-"+n+r}function o(t){return t?"["+f[t][0]+"m":""}function s(t){return t?"["+f[t][1]+"m":""}var a=this;this.ISO8601_FORMAT="yyyy-MM-dd hh:mm:ss.SSS",this.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ssO",this.DATETIME_FORMAT="hh:mm:ss.SSS",this.getDateReplace=function(e,i,o){i=i||"",o=o||"";var s=n(e.getDate()),a=n(e.getMonth()+1),u=n(e.getFullYear()),c=n(e.getFullYear().toString().substring(2,4)),l=n(e.getHours()),f=n(e.getMinutes()),h=n(e.getSeconds()),p=t(e.getMilliseconds(),3),d=r(e),y={};return y[i+"dd"+o]=s,y[i+"MM"+o]=a,y[i+"yyyy"+o]=u,y[i+"y{1,4}"+o]=c,y[i+"hh"+o]=l,y[i+"mm"+o]=f,y[i+"ss"+o]=h,y[i+"SSS"+o]=p,y[i+"O"+o]=d,y},this.dateFormat=function(t,n,r,o){n||(n=t||new Date,t=e.ISO8601_FORMAT);var s=t,u=a.getDateReplace(n,r,o);return i.jsonForEach(u,function(t,e){s=s.replace(new RegExp(t,"g"),e)}),s};var u=function(t,e){var n=[];if(e>0)for(var r=0;r<e;r++)n.push(t);return n.join("")},c=function(t,e,n,r){var o=r?u(n.t,e-1):"";if(null===t||void 0===t)return o+"null";switch(i.getClassName(t)){case"array":for(var s=u(n.t,e-1),a=[n.n+s+"["+n.n],l=[],f=0,h=t.length;f<h;f++)l.push(c(t[f],e+1,n,!0));return a.push(l.join(","+n.n)),a.push(n.n+s+"] "),a.join("");case"object":var p=[];for(var d in t)if(void 0!=t[d]){var a=[],s=u(n.t,e);a.push(s),a.push('"'+d+'" : ');var y=t[d];a.push(c(y,e+1,n)),p.push(a.join(""))}return(e>1&&!r?n.n:"")+u(n.t,e-1)+"{"+n.n+p.join(","+n.n)+n.n+u(n.t,e-1)+"}";case"number":return o+t.toString();case"boolean":return o+t.toString().toLowerCase();case"function":return t.toString();default:return o+('"'+t.toString()+'"')}},l={n:"\n",t:"\t"};this.jsonFormat=function(t,e){e=i.merger(l,e);try{return c(t,1,e)}catch(e){throw t}},this.templateStringFormat=function(t,e){var n=t;for(var r in e)n=n.replace(new RegExp("{{"+r+"}}","igm"),e[r]);return n},this.templateJsonFormat=function(t,e){var t=JSON.stringify(t),n=a.templateStringFormat(t,e);return JSON.parse(n)};var f={bold:[1,22],italic:[2,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};this.colorFormat=function(t,e){return o(e)+t+s(e)}}).call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/basic/lib.js",["require","exports","module","window"],function(t,e,n,r){(function(){this.env=function(){try{if(r)return"web"}catch(t){}try{if(process)return"node"}catch(t){}return"other"}(),this.isWindow=function(){try{if(r)return!0}catch(t){return!1}try{if(process)return!1}catch(t){return!0}return!1}();var e=this;e.trace=console.trace||function(t){var e=arguments.callee.caller,n=0;for(t=t||10,console.log("***---------------------------------------- ** "+(n+1));e&&n<t;)console.log(e.toString()),e=e.caller,n++,console.log("***---------------------------------------- ** "+(n+1))},this.setImmediate=this.nextTick=function(){return"undefined"!=typeof process&&process.nextTick?process.nextTick:r&&"function"==typeof r.setImmediate?r.setImmediate:function(t){setTimeout(t,0)}}(),this.inherits=this.extends=function(t,e){if("function"==typeof Object.create)t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});else{t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);r.forEach(function(e){for(var n in e)t.prototype[n]=e[n]})}},this.forEach=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0,r=t.length;n<r;n++)e(t[n],n,t)},this.keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e},this.copyArray=function(t){return t.concat([])},this.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1},this.removeArray=function(t,n,r){var i=e.copyArray(t);return e.removeLocalArray(i,n,r),i},this.removeLocalArray=function(t,e,n){return n=n||e,t.splice(e,n-e+1),t},this.inserLocalArray=function(t,e,n){return t.splice(e,0,n),t},this.copy=function(t){return JSON.parse(JSON.stringify(t))},this.clone=function(t){var n;n=e.isArray(t)?[]:{};for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n},this.reduce=function(t,n,r){return t.reduce?t.reduce(n,r):(e.forEach(t,function(t,e,i){r=n(r,t,e,i)}),r)},this.map=function(t,n){if(t.map)return t.map(n);var r=[];return e.forEach(t,function(t,e,i){r.push(n(t,e,i))}),r},this.jsonForEach=function(t,e){this.keys(t).forEach(function(n){e(n,t[n])})},this.getChar=function(t,e){var n=t.split("");return n[e]},Function.prototype.bind||(Function.prototype.bind=function(t){var e=Array.prototype.slice.call(arguments,1),n=this;return function(){n.apply(t,e.concat(Array.prototype.slice.call(arguments)))}}),this.isObject=function(t){return!!t&&t.constructor==Object},this.isArray=function(t){if(Array.isArray)return Array.isArray(t);throw"no handle isArray"},this.isDate=function(t){return t.constructor==Date},["String","Function","Boolean","Number"].forEach(function(t){e["is"+t]=function(e){return typeof e==t.toLowerCase()}}),this.isPromise=function(t){return e.isFunction(t.then)},this.getClassName=function(t){if(t){for(var n=["Array","String","Number","Date","Boolean","Function"],r=0,i=n.length;r<i;r++)if(e["is"+n[r]](t))return n[r].toLowerCase();return"object"}},this.merger=function(t){var t=e.clone(t);return Array.prototype.slice.call(arguments,1).forEach(function(e){e&&Object.keys(e).forEach(function(n){t[n]=e[n]})}),t},this.getErrorString=function(e){if(e.stack)return e.stack.toString();if(latte_lib.isString(e))return e.toString();var n;try{n=JSON.stringify(e)}catch(i){var r=t("util");n=r.inspect(e)}return n},this.defineProperties=Object.defineProperties||function(t,e){function n(e){function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(t){return"function"==typeof t}if("object"!=typeof e||null===e)throw new TypeError("不是正规的对象");var i={};if(n(e,"enumerable")&&(i.enumerable=!!t.enumerable),n(e,"configurable")&&(i.configurable=!!t.configurable),n(e,"value")&&(i.value=t.value),n(e,"writable")&&(i.writable=!!e.writable),n(e,"get")){var o=e.get;if(!r(o)&&"undefined"!==o)throw new TypeError("bad get");i.get=o}if(n(e,"set")){var s=e.set;if(!r(s)&&"undefined"!==s)throw new TypeError("bad set");i.set=s}if(("get"in i||"set"in i)&&("value"in i||"writable"in i))throw new TypeError("identity-confused descriptor");return i}if("object"!=typeof t||null===t)throw new TypeError("不是正规的对象");e=Object(e);for(var r=Object.keys(e),i=[],o=0;o<r.length;o++)i.push([r[o],n(e[r[o]])]);for(var o=0;o<i.length;o++)Object.defineProperty(t,i[o][0],i[o][1]);return t}}).call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/basic/object.js",["require","exports","module","window"],function(t,e,n,r){var i=t("./lib.js"),o=t("./events.js"),s=function(t){var e=this;this.childEvents={},e.data={};var n=function(n,r){e.childEvents[n]=function(r,i,o){e.emit(n+"."+r,i,o,t),e.emit("change",n+"."+r,i,o,t)},r.on("change",e.childEvents[n])},r=function(t,n){s.isLatteObject(n)&&(n.off("change",e.childEvents[t]),delete e.childEvents[t])};!function(){for(var r in t){var i=s.create(t[r]);i?(n(r,i),e.data[r]=i):e.data[r]=t[r]}}();var o=function(o,a,u){if(i.isArray(o)||(o=o.toString().split(".")),1!=o.length){for(var c,l=o.pop(),f=e,h=0,p=o.length;h<p;h++)c=f,f=f.get(o[h]),f||(f=new s({}),c.set(o[h],f));return e.get(o).set(l,a,u)}var d,l=o[0],y=e.data[l];t[l];switch(u){case 1:break;default:r(l,y);var d=s.create(a);return d?n(l,d):d=a,e.data[l]=d,t[l]=a,{ov:y,nv:d}}};this._set=o,this.merge=function(t){for(var n in t)e.set(n,t[n])},this.set=function(t,n,r){var i=o(t,n);return t.indexOf(".")==-1&&e.emit("change",t,i.nv,i.ov),e.emit(t,i.nv,i.ov),i},this.get=function(t){if("this"==t&&!e.data[t])return e;i.isArray(t)||(t=t.toString().split("."));if(1==t.length)return e.data[t[0]];var n=t.shift();return e.data[n].get(t)},this.toJSON=function(){return t},this.getKeys=function(){return Object.keys(e.data)}};(function(){this.isLatteArray=function(e){var n=t("./array");return e.constructor==n},this.isLatteObject=function(e){t("./array");return e&&(e.constructor==s||e.constructor==t("./array"))},this.getType=function(t){return s.isLatteObject(t)?"LatteObject":Array.isArray(t)?"Array":t&&t.constructor==Object?"Object":void 0},this.create=function(e){var n=t("./array");switch(s.getType(e)){case"LatteObject":return e;case"Array":return new n(e);case"Object":return new s(e);default:return null}},this.equal=function(t,e){if(null==t&&null==e)return!0;if(null==t&&null!=e||null!=t&&null==e)return!1;if(t.constructor!=e.constructor)return!1;if(i.isArray(t)){if(t.length!=e.length)return!1;for(var n=0,r=t.length;n<r;n++)if(!equal(t[n],e[n]))return!1;return!0}if(s.isLatteArray(t)){if(t.length!=e.length)return!1;for(var n=0,r=t.length;n<r;n++)if(!equal(t.get(n),e.get(n)))return!1;return!0}return s.isLatteObject(t)?t.toJSON()==e.toJSON():t==e}}).call(s),i.inherits(s,o),n.exports=s})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/index.js",["require","exports","module","window"],function(t,e,n,r){n.exports=t("./basic/lib"),function(){this.async=t("./basic/async"),this.object=t("./basic/object"),this.format=t("./basic/format"),this.events=t("./basic/events"),this.xhr=t("./test/xhr"),"web"!=this.env&&(this.fs=t("./test/fs")),this.promise=t("./test/promise"),this.debug=t("./test/debug")}.call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/test/debug.js",["require","exports","module","window"],function(t,e,n,r){(function(){this.disabled=!0;var e=t("../basic/format"),n=function(t){var e,n=t.toString().split("\n")[2];return e=n.indexOf("(")!=-1?n.substring(n.indexOf("(")+1,n.indexOf(")")):n.substring(n.indexOf("at ")+3)},r=this,i={log:"blue",info:"green",warn:"yellow",error:"red"};Object.keys(i).forEach(function(t){r[t]=function(){if(!r.disabled){var o=new Error("debug"),s=new Date;console[t].apply(console[t],[e.colorFormat(n(o.stack),i[t]),"-",e.colorFormat(e.dateFormat("yyyy-MM-dd hh:mm:ss",s),i[t]),":"].concat(Array.prototype.slice.call(arguments)))}}})}).call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/test/fs.js",["require","exports","module","window"],function(t,e,n,r){var i=t("fs"),o=t("path");(function(){var t=this;for(var e in i)t[e]=i[e];this.exists=function(t,e){return i.exists(t,e)},this.existsSync=function(t){return i.existsSync(t)},this.mkdirSync=function(e,n){if(t.existsSync(e))return null;if(!t.existsSync(o.dirname(e))){var r=t.mkdirSync(o.dirname(e),n);if(r)return r}return i.mkdirSync(e,n)},this.writeFileSync=function(e,n){var r=t.mkdirSync(o.dirname(e));return r?r:i.writeFileSync(e,n,{encoding:"utf8"})},this.writeFile=function(e,n,r){t.mkdir(o.dirname(e),null,function(){i.writeFile(e,n,{encoding:"utf8"},r)})},this.readFile=function(t,e){return i.readFile(t,function(t,n){e(t,n?n.toString():null)})},this.readFileSync=function(t){return i.readFileSync(t).toString()},this.mkdir=function(e,n,r){t.exists(e,function(s){s?r(null,e):t.mkdir(o.dirname(e),n,function(t){return t?r(t):void i.mkdir(e,n,r)})})},this.copyFile=function(e,n,r){try{var s=i.createReadStream(e);t.mkdir(o.dirname(n),null,function(t){var e=i.createWriteStream(n);s.pipe(e),r(null)})}catch(t){r(t)}},this.copyDir=function(t,e,n){},this.fileType=function(t){return o.extname(t).substring(1)},this.lstatSync=function(t){return i.lstatSync(t)},this.readdirSync=function(t){return i.readdirSync(t)},this.realpathSync=function(t,e){return i.realpathSync(t,e)},this.appendFile=function(t,e,n,r){return i.appendFile(t,e,n,r)},this.appendFileSync=function(t,e,n){return i.appendFile(t,e,n)},this.deleteFile=function(t,e){i.unlink(t,e)},this.deleteFileSync=function(t){return i.unlinkSync(t)},this.stat=function(t,e){return i.stat(t,e)},this.createReadStream=function(t,e){return i.createReadStream(t,e)},this.createWriteStream=function(e,n){t.mkdirSync(o.dirname(e));return i.createWriteStream(e,n)},this.rename=function(t,e,n){return i.rename(t,e,n)},this.watch=function(t,e,n){return i.watch(t,e,n)},this.statSync=function(t){return i.statSync(t)},this.WriteStream=i.WriteStream,this.getTimeSort=function(t){var e=i.readdirSync(t).map(function(e){var n=i.lstatSync(t+e);return{time:n.ctime.getTime(),obj:t+e}});return e.sort(function(t,e){return t.time>e.time}),e.map(function(t){return t.obj})}}).call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/test/promise.js",["require","exports","module","window"],function(t,e,n,r){n.exports=Promise||function(){function t(){this._callbacks=[]}return function(){this.then=function(e,n){var r;return this._isdone?r=e.apply(n,this.result):(r=new t,this._callbacks.push(function(){var t=e.apply(n,arguments);t&&"function"==typeof t.then&&t.then(r.done,r)})),r},this.done=function(){this.result=arguments,this._isdone=!0;for(var t=0,e=this._callbacks.length;t<e;t++)this._callbacks[t].apply(null,arguments);this._callbacks=[]}}.call(t.prototype),t}(),function(){function e(t){return"function"==typeof t.next&&"function"==typeof t.throw}function n(t){return"function"==typeof t.then}function r(t){var n=t.constructor;return!!n&&("GeneratorFunction"===n.name||"GeneratorFunction"===n.displayName||e(n.prototype))}this.join=function(t){function e(t){return function(){i+=1,r[t]=Array.prototype.slice.call(arguments),i===o&&n.done(r)}}var n=new Promise,r=[];if(!t||!t.length)return n.done(r),n;for(var i=0,o=t.length,s=0;s<o;s++)t[s].then(e(s));return n},this.chain=function(t,e){var n=new Promise;return 0===t.length?n.done.apply(n,e):t[0].apply(null,e).then(function(){t.splice(0,1),chain(t,arguments).then(function(){n.done.apply(n,arguments)})}),n};var i=Array.prototype.slice,o=function(t){return Promise.all(t.map(c,this))},s=function(t){function e(t,e){r[e]=void 0,o.push(t.then(function(t){r[e]=t}))}for(var r=new t.constructor,i=Object.keys(t),o=[],s=0;s<i.length;s++){var a=i[s],u=c.call(this,t[a]);u&&n(u)?e(u,a):r[a]=t[a]}return Promise.all(o).then(function(){return r})},a=this.thunkToPromise=function(t){var e=this;return new Promise(function(n,r){t.call(e,function(t,e){return t?r(t):(arguments.length>2&&(e=i.call(arguments,1)), void n(e))})})},u=this.functionToPromise=function(t){var e=this,n=i.call(arguments,1);return a(function(r){n.push(r),t.apply(e,n)})},c=this.toPromise=function(t){return t?n(t)?t:r(t)||e(t)?co.call(this,t):"function"==typeof t?u.apply(this,i.call(arguments,0)):Array.isArray(t)?o.call(this,t):isObject(t)?s.call(this,t):t:t},l=t("../basic/lib.js");this.co=function(t){var e=this,r=i.call(arguments,1);return new Promise(function(i,o){function s(e){var n;try{n=t.next(e)}catch(t){return o(t)}u(n)}function a(e){var n;try{n=t.throw(e)}catch(t){return o(t)}u(n)}function u(t){if(t.done)return i(t.value);var r=c.call(e,t.value);return r&&n(r)?r.then(s,a):a(new Error('You may only yield a function,promise, generator, array, or object, but the following object was passwed: "'+String(t.value)+'"'))}return l.isFunction(t)&&(t=t.apply(e,r)),t&&l.isFunction(t.next)?void s():i(t)})}}.call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)}),function(t){"use strict";t("latte_lib/test/xhr.js",["require","exports","module","window"],function(t,e,n,r){(function(){function e(t){return~[301,302,303,305,307,308].indexOf(t)}var n,r=t("../basic/lib.js"),i=t("../basic/events.js"),o={type:function(t){return t.split(/ *; */).shift()},params:function(t){return t.split(/ *; */).reduce(function(t,e){var n=e.split(/ *= */),r=n.shift(),i=n.shift();return r&&i&&(t[r]=i),t},{})},parseLinks:function(t){return t.split(/ *, */).reduce(function(t,e){var n=e.split(/ *; */),r=n[0].slice(1,-1),i=n[1].split(/ *= */)[1].slice(1,-1);return t[i]=r,t},{})}},s={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},a=function(t,e){this.method=t,this.url=e,this._headers={},this.headers={}};r.extends(a,i),function(){var t=this,e={type:"Content-type",accept:"Accept"};Object.keys(e).forEach(function(n){t[n]=function(t){return this.set(e[n],c.types[t]||t),this}}),this.set=this.setHeader=function(t,e){if(r.isObject(t)){for(var n in t)this.set(n,t[n]);return this}this._headers[t.toLowerCase()]=e,this.headers[t]=e},this.get=this.getHeader=function(t){this._headers[t.toLowerCase()]};var n=function(t){return encodeURIComponent(t)},i=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";case"object":return JSON.stringify(t);default:return""}},o=function(t,e,r){if(e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t)return Object.keys(t).map(function(e){var o=n(i(e))+r;return Array.isArray(t[e])?o+n(JSON.stringify(t[e])):o+n(i(t[e]))}).join(e)},o=function(){if(!r.isObject(obj))return obj;var t=[];for(var e in obj)pushEncodeKeyValuePair(t,e,object[e]);return t.join("&")};this.query=function(t){return r.isString(t)||(t=o(t)),t&&this._query.push(t),this},this.send=function(t){var e=r.isObject(t),n=this._headers["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only\t\t\t\t\t\t .send() or only .field() &.attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this.data))throw Error("Can't merge these send calls");if(e&&r.isObject(this._data))for(var i in t)this._data[i]=t[i];else r.isString(t)?(n||this.type("form"),n=this._headers["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(n||this.type("json"),this)},this.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||noop,this._appendQueryString(),this._end()};var n=function(t){return encodeURIComponent(t)},i=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";case"object":return JSON.stringify(t);default:return""}};this._appendQueryString=function(){this._queryString=u(this.qs)},this._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))},this.callback=function(t,e){if(this._maxRedirects&&this._retries++<this._maxRedirects&&shouldRetry(t,e))return this._retry();var n=this._callback||noop;if(this.clearTimeout(),this.called)return console.warn("superagent: double callback bug");if(this.called=!0,!t){if(this._isResponseOK(e))return n(t,e);var r="Unsuccessful HTTP response";e&&(r=s[e.status]||r),t=new Error(r),t.status=e?e.status:void 0}t.response=e,this._maxRedirects&&(t.retries=this._retries-1),t&&this.hasListeners("error")&&this.emit("error",t),n(t,e)},this.clearTimeout=function(){clearTimeout(this._timer),clearTimeout(this._responseTimeout),delete this._timer,delete this._responseTimeoutTimer},this._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)}}.call(a.prototype);var u=function(t,e,n){if(e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t)return Object.keys(t).map(function(e){var r=escape(stringifyPrimitive(e))+n;return Array.isArray(t[e])?r+escape(JSON.stringify(t[e])):r+escape(stringifyPrimitive(t[e]))}).join(e)},c=function(t,e){return r.isFunction(e)?new a("GET",t).end(e):1==arguments.length?new a(t,e):new a(t,e)};c.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded",text:"text/plain"};var l=this;this.request=function(t,e,n,i){var o=c(t,e);return r.isFunction(n)&&(i=n,n=null),n&&o.send(n),i&&o.end(i),o},["HEAD","GET","POST","PUT","PATCH","DELETE"].forEach(function(t){l[t.toLocaleLowerCase()]=function(){var e=Array.prototype.concat.call([t],Array.prototype.slice.call(arguments,0));return l.request.apply(l,e)}});var f={isJSON:function(t){return/[\/+]json\b/.test(t)},isText:function(t){var e=t.split("/"),n=e[0],r=e[1];return"text"==n||"x-www-form-urlencoded"==r},isImageOrVide:function(t){var e=t.split("/")[0];return"image"==e||"video"==e}},h={"application/x-www-form-urlencoded":u,"application/json":JSON.stringify};if("web"==r.env)(function(){var t=function(){return new XMLHttpRequest},e="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")},r={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},i=function(t){var n,r,i,o,s=t.split(/\r?\n/),a={};s.pop();for(var u=0,c=s.length;u<c;++u)r=s[u],n=r.indexOf(":"),i=r.slice(0,n).toLowerCase(),o=e(r.slice(n+1)),a[i]=o;return a};n=function(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"==this.req.method||""!==this.xhr.responseType&&"text"!==this.xhr.responseType&&"undefined"!=typeof this.xhr.responseType?null:this.xhr.responseText,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223==e&&(e=204),this._setStatusProperties(e),this.header=this.headers=i(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null},function(){this._parseBody=function(t){var e=r[this.type];if(this.req._parser)return this.req._parser(this,t);if(!e&&f.isJSON(this.type)&&(e=r["application/json"]),!(e&&t&&(t.length||t instanceof Object)))return null;try{return e(t)}catch(n){if(e==r["application/json"])return t=t.replace(/\[,/gim,"[null,").replace(/,\]/gim,",null]").replace(/,,/gim,",null,").replace(/,,/gim,",null,"),e(t)}}}.call(n.prototype),this._end=function(){var e=this;this.once("end",function(){var t=null,r=null;try{r=new n(e)}catch(t){return t.parse=!0,e.xhr?(t.rawResponse="undefined"==typeof e.xhr.responseType?e.xhr.responseText:e.xhr.response,t.status=e.xhr.status?e.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),e.callback(t)}e.emit("response",r);var i;try{e._isResponseOK(r)||(i=new Error(r.statusText||"Unsuccessful HTTP response"),i.original=t,i.response=r,i.status=r.status)}catch(t){i=t}i?e.callback(i,r):e.callback(null,r)});var r=this.xhr=t(),i=this._formData||this._data;this._setTimeouts(),r.onreadystatechange=function(){var t=r.readyState;if(t>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==t){var n;try{n=r.status}catch(t){n=0}if(!n){if(e.timeout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var o=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{r.onprogress=o.bind(null,"download"),r.upload&&(r.upload.onprogress=o.bind(null,"upload"))}catch(t){}try{this.username&&this.password?r.open(this.method,this.url,!0,this.username,this.password):r.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(r.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof i&&!this._isHost(i)){var s=this._headers["content-type"],a=this._serializer||h[s?s.split(";")[0]:""];!a&&f.isJSON(s)&&(a=h["application/json"]),a&&(i=a(i))}for(var u in this.headers)null!=this.headers[u]&&r.setRequestHeader(u,this.headers[u]);return this._responseType&&(r.responseType=this._responseType),this.emit("request",this),r.send("undefined"!=typeof i?i:null),this},this.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},this._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)}}).call(a.prototype);else{var p=function(t,e){var n=[];t.on("data",function(t){n.push(t)}),t.on("end",function(){e(null,Buffer.concat(n))})},d=t("querystring"),y={"application/x-www-form-urlencoded":function(t,e){t.text="",t.setEncoding("ascii"),t.on("data",function(e){t.text+=e}),t.on("end",function(){try{e(null,d.parse(t.text))}catch(t){e(t)}})},"application/json":function(t,e){t.text="",t.setEncoding("utf8"),t.on("data",function(e){t.text+=e}),t.on("end",function(){try{var n=t.text&&JSON.parse(t.text)}catch(e){var r=e;r.rawResponse=t.text||null,r.statusCode=t.statusCode}finally{e(r,n)}})},text:function(t,e){t.text="",t.setEncoding("utf8"),t.on("data",function(e){t.text+=e}),t.on("end",e)},"application/octet-stream":p,image:p};(function(){var i={"http:":t("http"),"https:":t("https")};n=function(t){var e=this.res=t.res;this.request=t,this.req=t.req,this.text=e.text,this.body=void 0!=e.body?e.body:{},this.header=this.headers=e.headers,this.files=e.files||{},this._setStatusProperties(e.statusCode),this._setHeaderProperties(this.header)},function(){}.call(n.prototype),this._emitResponse=function(t,e){var r=new n(this);return this.response=r,r.redirects=this._redirectList,void 0!==t&&(r.body=t),r.files=e,this.emit("response",r),r},this.createReq=function(){if(this.req)return this.req;var e=this,n={},r=this.url;this._retries;0!=r.indexOf("http")&&(r="http://"+r),r=t("url").parse(r),/^https?\+unix:/.test(r.protocol)===!0&&(r.protocol=r.protocol.split("+")[0]+":",n.socketPath=unixParts[1].replace(/%2F/g,"/"),r.pathname=unixParts[2]),n.method=this.method,n.port=r.port,n.path=r.pathname,n.host=r.hostname,n.ca=this._ca,n.key=this._key,n.pfx=this._pfx,n.cert=this._cert,n.agent=this._agent;var o=i[r.protocol],s=this.req=o.request(n);if("HEAD"!=n.method&&s.setHeader("Accept-Encoding","gzip, deflate"),this.protocol=r.protocol,this.host=r.host,s.once("drain",function(){e.emit("drain")}),s.once("error",function(t){e._aborted||e._retries===retries&&(e.response||e.callback(err))}),r.auth){var a=r.auth.split(":");this.auth(a[0],a[1])}this.cookies&&s.setHeader("Cookie",this.cookies);for(var u in this.headers)s.setHeader(u,this.headers[u]);try{this._appendQueryString(s)}catch(t){return this.emit("error",t)}return s},this._shouldUnzip=function(t){return 204!==t.statusCode&&304!==t.statusCode&&("0"!=t.headers["content-length"]&&/^\s*(?:deflate|gzip)\s*$/.test(t.headers["content-encoding"]))};t("url");this._end=function(){var t=this,n=this._data;this.createReq();var i=this.req,s=this._buffer,a=this.method;if(this._setTimeouts(),"HEAD"!=a&&!i.headerSent){if(!r.isString(n)){var u=i.getHeader("Content-Type");u&&(u=u.split(";")[0]);var c=h[u];!c&&f.isJSON(u)&&(c=h["application/json"]),c&&(n=c(n))}n&&!i.getHeader("Content-Length")&&i.setHeader("Content-Length",Buffer.isBuffer(n)?n.length:Buffer.byteLength(n))}i.once("response",function(n){if(t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),!t.piped){var r=t._maxRedirects,i=o.type(n.headers["content-type"]||"")||"text/plain",a=i.split("/")[0],u="multipart"==a,c=e(n.statusCode);if(c&&t._redirects++!=r)return t._redirect(n);var l=t._parser;if("HEAD"==t.method&&(t.emit("end"),t.callback(null,t._emitResponse())),!l)if(this._responseType)l=y.image,s=!0;else if(u){var h=new formidable.IncomingForm;l=h.parse.bind(h),s=!0}else f.isImageOrVide(i)?(l=y.image,s=!0):y[i]?l=y[i]:"text"==a?(l=y.text,s=s!==!1):f.isJSON(i)?(l=y["application/json"],s=s!==!1):s&&(l=y.text);(void 0===s&&isText(i)||f.isJSON(i))&&(s=!0);var p=!1;if(l)try{p=s,l(n,function(e,n,r){if(!t.timedout)return e&&!t._aborted?t.callback(e):void(p&&(t.emit("end"),t.callback(null,t._emitResponse(n,r))))})}catch(e){return void t.callback(e)}if(t.res=n,!s){if(t.callback(null,t._emitResponse()),u)return;return void n.once("end",function(){t.emit("end")})}n.once("error",function(e){t.callback(e,null)}),p||n.once("end",function(){t.emit("end"),t.callback(null,t._emitResponse())})}}),this.emit("request",this);var l=this._formData;if(l){var p=l.getHeaders();for(var d in p)i.setHeader(d,p[d]);l.getLength(function(e,n){"number"==typeof n&&i.setHeader("Content-Length",n);var r=function(){var e=!0,n=i.getHeader("Content-Length"),r=0,o=new Stream.Transform;return o._transform=function(i,o,s){r+=i.length,t.emit("progress",{direction:"upload",lengthComputable:e,loaded:r,total:n}),s(null,i)},o};l.pipe(r()).pipe(i)})}else i.end(n)}}).call(a.prototype)}(function(){this._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=o.type(e);var n=o.params(e);for(var r in n)this[r]=n[r];this.links={};try{t.link&&(this.links=o.parseLinks(t.link))}catch(t){}},this._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t},this.toError=function(){var t=this.req,e=t.method,n=t.url,r="cannot "+e+" "+n+" ("+this.status+")",i=new Error(r);return i.status=this.status,i.method=e,i.url=n,i}}).call(n.prototype)}).call(n.exports)})}("function"==typeof define?define:function(t,e,n){n(require,exports,module)});