Commit f248ca05bdb0626b1f2c779fa6c3b3c6e4bab34b
0 parents
初始化版本 -张卓
Showing
16 changed files
with
6137 additions
and
0 deletions
.babelrc
0 → 100644
.gitignore
0 → 100644
1 | +++ a/.gitignore | |
1 | +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | |
2 | + | |
3 | +# dependencies | |
4 | +/node_modules | |
5 | +/.pnp | |
6 | +.pnp.js | |
7 | + | |
8 | +# testing | |
9 | +/coverage | |
10 | + | |
11 | +# production | |
12 | +/build | |
13 | + | |
14 | +# misc | |
15 | +.DS_Store | |
16 | +.env.local | |
17 | +.env.development.local | |
18 | +.env.test.local | |
19 | +.env.production.local | |
20 | + | |
21 | +npm-debug.log* | |
22 | +yarn-debug.log* | |
23 | +yarn-error.log* | ... | ... |
README.md
0 → 100644
1 | +++ a/README.md | |
1 | +#### React 17版本以上的组件封装 | |
2 | + | |
3 | +##### flv播放器封装 | |
4 | + | |
5 | +介绍:支持大屏适配宽度高度百分百,支持视频切换。 | |
6 | + | |
7 | +解释:只需要传入不同的videoUrl | |
8 | + | |
9 | +使用: | |
10 | + | |
11 | +```react | |
12 | +import {FlvCom} from "zzreact" | |
13 | +export default class App extends Component { | |
14 | + constructor() { | |
15 | + super(); | |
16 | + this.state = { | |
17 | + vidoeUrl: "" | |
18 | + } | |
19 | + } | |
20 | + render() { | |
21 | + let {vidoeUrl} = this.state | |
22 | + return <FlvCom vidoeUrl={vidoeUrl}></FlvCom> | |
23 | + } | |
24 | +} | |
25 | +``` | |
26 | + | |
27 | +##### time时间组件封装 | |
28 | + | |
29 | +介绍:用来大屏展示时间用 | |
30 | + | |
31 | +解释:可以加入className来自行改变样式 | |
32 | + | |
33 | +使用: | |
34 | + | |
35 | +```react | |
36 | +import {Timer} from "zzreact" | |
37 | + | |
38 | +export default class App extends Component { | |
39 | + render() {//通过下面的className写在css中样式就会生效 | |
40 | + //type可以不传默认YYYY-MM-DD HH:mm:ss | |
41 | + //也可以改变,规则和moment.js中format的规则一致 | |
42 | + return (<div> | |
43 | + <Timer className="timerComCssss" type="YYYY-MM-DD HH:mm:ss"></Timer> | |
44 | + <Timer className="timerComCssss"></Timer> | |
45 | + </div>) | |
46 | + } | |
47 | +} | |
48 | +``` | |
49 | + | ... | ... |
dist/index.html
0 → 100644
dist/index.js
0 → 100644
1 | +++ a/dist/index.js | |
1 | +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(window,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=16)}([function(e,t,i){"use strict";var n,s="object"==typeof Reflect?Reflect:null,r=s&&"function"==typeof s.apply?s.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};n=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(i,n){function s(){void 0!==r&&e.removeListener("error",r),i([].slice.call(arguments))}var r;"error"!==t&&(r=function(i){e.removeListener(t,s),n(i)},e.once("error",r)),e.once(t,s)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var l=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function d(e,t,i,n){var s,r,a,o;if(h(i),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),r=e._events),a=r[t]),void 0===a)a=r[t]=i,++e._eventsCount;else if("function"==typeof a?a=r[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),(s=u(e))>0&&a.length>s&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,o=l,console&&console.warn&&console.warn(o)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},s=c.bind(n);return s.listener=i,n.wrapFn=s,s}function f(e,t,i){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?i?[s.listener||s]:[s]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(s):p(s,s.length)}function m(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function p(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||a(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)r(l,this,t);else{var h=l.length,u=p(l,h);for(i=0;i<h;++i)r(u[i],this,t)}return!0},o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)},o.prototype.once=function(e,t){return h(t),this.on(e,_(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,_(this,e,t)),this},o.prototype.removeListener=function(e,t){var i,n,s,r,a;if(h(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(s=-1,r=i.length-1;r>=0;r--)if(i[r]===t||i[r].listener===t){a=i[r].listener,s=r;break}if(s<0)return this;0===s?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,s),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,a||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var s,r=Object.keys(i);for(n=0;n<r.length;++n)"removeListener"!==(s=r[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,i){"use strict";e.exports=i(8)},function(e,t,i){"use strict";var n,s=function(){return void 0===n&&(n=Boolean(window&&document&&document.all&&!window.atob)),n},r=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),a=[];function o(e){for(var t=-1,i=0;i<a.length;i++)if(a[i].identifier===e){t=i;break}return t}function l(e,t){for(var i={},n=[],s=0;s<e.length;s++){var r=e[s],l=t.base?r[0]+t.base:r[0],h=i[l]||0,u="".concat(l," ").concat(h);i[l]=h+1;var d=o(u),c={css:r[1],media:r[2],sourceMap:r[3]};-1!==d?(a[d].references++,a[d].updater(c)):a.push({identifier:u,updater:p(c,t),references:1}),n.push(u)}return n}function h(e){var t=document.createElement("style"),n=e.attributes||{};if(void 0===n.nonce){var s=i.nc;s&&(n.nonce=s)}if(Object.keys(n).forEach((function(e){t.setAttribute(e,n[e])})),"function"==typeof e.insert)e.insert(t);else{var a=r(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var u,d=(u=[],function(e,t){return u[e]=t,u.filter(Boolean).join("\n")});function c(e,t,i,n){var s=i?"":n.media?"@media ".concat(n.media," {").concat(n.css,"}"):n.css;if(e.styleSheet)e.styleSheet.cssText=d(t,s);else{var r=document.createTextNode(s),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(r,a[t]):e.appendChild(r)}}function _(e,t,i){var n=i.css,s=i.media,r=i.sourceMap;if(s?e.setAttribute("media",s):e.removeAttribute("media"),r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var f=null,m=0;function p(e,t){var i,n,s;if(t.singleton){var r=m++;i=f||(f=h(t)),n=c.bind(null,i,r,!1),s=c.bind(null,i,r,!0)}else i=h(t),n=_.bind(null,i,t),s=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(i)};return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else s()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=s());var i=l(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var n=0;n<i.length;n++){var s=o(i[n]);a[s].references--}for(var r=l(e,t),h=0;h<i.length;h++){var u=o(i[h]);0===a[u].references&&(a[u].updater(),a.splice(u,1))}i=r}}}},function(e,t,i){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i=e(t);return t[2]?"@media ".concat(t[2]," {").concat(i,"}"):i})).join("")},t.i=function(e,i,n){"string"==typeof e&&(e=[[null,e,""]]);var s={};if(n)for(var r=0;r<this.length;r++){var a=this[r][0];null!=a&&(s[a]=!0)}for(var o=0;o<e.length;o++){var l=[].concat(e[o]);n&&s[l[0]]||(i&&(l[2]?l[2]="".concat(i," and ").concat(l[2]):l[2]=i),t.push(l))}},t}},function(e,t,i){"use strict";(function(e){var n,s;function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)} | |
2 | +//! moment.js | |
3 | +//! version : 2.29.1 | |
4 | +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors | |
5 | +//! license : MIT | |
6 | +//! momentjs.com | |
7 | +function a(){return n.apply(null,arguments)}function o(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function l(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function u(e){if(Object.getOwnPropertyNames)return 0===Object.getOwnPropertyNames(e).length;var t;for(t in e)if(h(e,t))return!1;return!0}function d(e){return void 0===e}function c(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function _(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function f(e,t){var i,n=[];for(i=0;i<e.length;++i)n.push(t(e[i],i));return n}function m(e,t){for(var i in t)h(t,i)&&(e[i]=t[i]);return h(t,"toString")&&(e.toString=t.toString),h(t,"valueOf")&&(e.valueOf=t.valueOf),e}function p(e,t,i,n){return Lt(e,t,i,n,!0).utc()}function g(e){return null==e._pf&&(e._pf={empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}),e._pf}function y(e){if(null==e._isValid){var t=g(e),i=s.call(t.parsedDateParts,(function(e){return null!=e})),n=!isNaN(e._d.getTime())&&t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&i);if(e._strict&&(n=n&&0===t.charsLeftOver&&0===t.unusedTokens.length&&void 0===t.bigHour),null!=Object.isFrozen&&Object.isFrozen(e))return n;e._isValid=n}return e._isValid}function v(e){var t=p(NaN);return null!=e?m(g(t),e):g(t).userInvalidated=!0,t}s=Array.prototype.some?Array.prototype.some:function(e){var t,i=Object(this),n=i.length>>>0;for(t=0;t<n;t++)if(t in i&&e.call(this,i[t],t,i))return!0;return!1};var S=a.momentProperties=[],E=!1;function b(e,t){var i,n,s;if(d(t._isAMomentObject)||(e._isAMomentObject=t._isAMomentObject),d(t._i)||(e._i=t._i),d(t._f)||(e._f=t._f),d(t._l)||(e._l=t._l),d(t._strict)||(e._strict=t._strict),d(t._tzm)||(e._tzm=t._tzm),d(t._isUTC)||(e._isUTC=t._isUTC),d(t._offset)||(e._offset=t._offset),d(t._pf)||(e._pf=g(t)),d(t._locale)||(e._locale=t._locale),S.length>0)for(i=0;i<S.length;i++)d(s=t[n=S[i]])||(e[n]=s);return e}function w(e){b(this,e),this._d=new Date(null!=e._d?e._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),!1===E&&(E=!0,a.updateOffset(this),E=!1)}function R(e){return e instanceof w||null!=e&&null!=e._isAMomentObject}function k(e){!1===a.suppressDeprecationWarnings&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+e)}function A(e,t){var i=!0;return m((function(){if(null!=a.deprecationHandler&&a.deprecationHandler(null,e),i){var n,s,o,l=[];for(s=0;s<arguments.length;s++){if(n="","object"===r(arguments[s])){for(o in n+="\n["+s+"] ",arguments[0])h(arguments[0],o)&&(n+=o+": "+arguments[0][o]+", ");n=n.slice(0,-2)}else n=arguments[s];l.push(n)}k(e+"\nArguments: "+Array.prototype.slice.call(l).join("")+"\n"+(new Error).stack),i=!1}return t.apply(this,arguments)}),t)}var L,D={};function T(e,t){null!=a.deprecationHandler&&a.deprecationHandler(e,t),D[e]||(k(t),D[e]=!0)}function M(e){return"undefined"!=typeof Function&&e instanceof Function||"[object Function]"===Object.prototype.toString.call(e)}function O(e,t){var i,n=m({},e);for(i in t)h(t,i)&&(l(e[i])&&l(t[i])?(n[i]={},m(n[i],e[i]),m(n[i],t[i])):null!=t[i]?n[i]=t[i]:delete n[i]);for(i in e)h(e,i)&&!h(t,i)&&l(e[i])&&(n[i]=m({},n[i]));return n}function C(e){null!=e&&this.set(e)}a.suppressDeprecationWarnings=!1,a.deprecationHandler=null,L=Object.keys?Object.keys:function(e){var t,i=[];for(t in e)h(e,t)&&i.push(t);return i};function I(e,t,i){var n=""+Math.abs(e),s=t-n.length;return(e>=0?i?"+":"":"-")+Math.pow(10,Math.max(0,s)).toString().substr(1)+n}var x=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,N=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,P={},U={};function B(e,t,i,n){var s=n;"string"==typeof n&&(s=function(){return this[n]()}),e&&(U[e]=s),t&&(U[t[0]]=function(){return I(s.apply(this,arguments),t[1],t[2])}),i&&(U[i]=function(){return this.localeData().ordinal(s.apply(this,arguments),e)})}function F(e,t){return e.isValid()?(t=Y(t,e.localeData()),P[t]=P[t]||function(e){var t,i,n,s=e.match(x);for(t=0,i=s.length;t<i;t++)U[s[t]]?s[t]=U[s[t]]:s[t]=(n=s[t]).match(/\[[\s\S]/)?n.replace(/^\[|\]$/g,""):n.replace(/\\/g,"");return function(t){var n,r="";for(n=0;n<i;n++)r+=M(s[n])?s[n].call(t,e):s[n];return r}}(t),P[t](e)):e.localeData().invalidDate()}function Y(e,t){var i=5;function n(e){return t.longDateFormat(e)||e}for(N.lastIndex=0;i>=0&&N.test(e);)e=e.replace(N,n),N.lastIndex=0,i-=1;return e}var G={};function V(e,t){var i=e.toLowerCase();G[i]=G[i+"s"]=G[t]=e}function j(e){return"string"==typeof e?G[e]||G[e.toLowerCase()]:void 0}function W(e){var t,i,n={};for(i in e)h(e,i)&&(t=j(i))&&(n[t]=e[i]);return n}var H={};function z(e,t){H[e]=t}function $(e){return e%4==0&&e%100!=0||e%400==0}function q(e){return e<0?Math.ceil(e)||0:Math.floor(e)}function K(e){var t=+e,i=0;return 0!==t&&isFinite(t)&&(i=q(t)),i}function Z(e,t){return function(i){return null!=i?(J(this,e,i),a.updateOffset(this,t),this):X(this,e)}}function X(e,t){return e.isValid()?e._d["get"+(e._isUTC?"UTC":"")+t]():NaN}function J(e,t,i){e.isValid()&&!isNaN(i)&&("FullYear"===t&&$(e.year())&&1===e.month()&&29===e.date()?(i=K(i),e._d["set"+(e._isUTC?"UTC":"")+t](i,e.month(),Re(i,e.month()))):e._d["set"+(e._isUTC?"UTC":"")+t](i))}var Q,ee=/\d/,te=/\d\d/,ie=/\d{3}/,ne=/\d{4}/,se=/[+-]?\d{6}/,re=/\d\d?/,ae=/\d\d\d\d?/,oe=/\d\d\d\d\d\d?/,le=/\d{1,3}/,he=/\d{1,4}/,ue=/[+-]?\d{1,6}/,de=/\d+/,ce=/[+-]?\d+/,_e=/Z|[+-]\d\d:?\d\d/gi,fe=/Z|[+-]\d\d(?::?\d\d)?/gi,me=/[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;function pe(e,t,i){Q[e]=M(t)?t:function(e,n){return e&&i?i:t}}function ge(e,t){return h(Q,e)?Q[e](t._strict,t._locale):new RegExp(ye(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,(function(e,t,i,n,s){return t||i||n||s}))))}function ye(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}Q={};var ve={};function Se(e,t){var i,n=t;for("string"==typeof e&&(e=[e]),c(t)&&(n=function(e,i){i[t]=K(e)}),i=0;i<e.length;i++)ve[e[i]]=n}function Ee(e,t){Se(e,(function(e,i,n,s){n._w=n._w||{},t(e,n._w,n,s)}))}function be(e,t,i){null!=t&&h(ve,e)&&ve[e](t,i._a,i,e)}var we;function Re(e,t){if(isNaN(e)||isNaN(t))return NaN;var i,n=(t%(i=12)+i)%i;return e+=(t-n)/12,1===n?$(e)?29:28:31-n%7%2}we=Array.prototype.indexOf?Array.prototype.indexOf:function(e){var t;for(t=0;t<this.length;++t)if(this[t]===e)return t;return-1},B("M",["MM",2],"Mo",(function(){return this.month()+1})),B("MMM",0,0,(function(e){return this.localeData().monthsShort(this,e)})),B("MMMM",0,0,(function(e){return this.localeData().months(this,e)})),V("month","M"),z("month",8),pe("M",re),pe("MM",re,te),pe("MMM",(function(e,t){return t.monthsShortRegex(e)})),pe("MMMM",(function(e,t){return t.monthsRegex(e)})),Se(["M","MM"],(function(e,t){t[1]=K(e)-1})),Se(["MMM","MMMM"],(function(e,t,i,n){var s=i._locale.monthsParse(e,n,i._strict);null!=s?t[1]=s:g(i).invalidMonth=e}));var ke="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),Ae="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),Le=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,De=me,Te=me;function Me(e,t,i){var n,s,r,a=e.toLocaleLowerCase();if(!this._monthsParse)for(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],n=0;n<12;++n)r=p([2e3,n]),this._shortMonthsParse[n]=this.monthsShort(r,"").toLocaleLowerCase(),this._longMonthsParse[n]=this.months(r,"").toLocaleLowerCase();return i?"MMM"===t?-1!==(s=we.call(this._shortMonthsParse,a))?s:null:-1!==(s=we.call(this._longMonthsParse,a))?s:null:"MMM"===t?-1!==(s=we.call(this._shortMonthsParse,a))||-1!==(s=we.call(this._longMonthsParse,a))?s:null:-1!==(s=we.call(this._longMonthsParse,a))||-1!==(s=we.call(this._shortMonthsParse,a))?s:null}function Oe(e,t){var i;if(!e.isValid())return e;if("string"==typeof t)if(/^\d+$/.test(t))t=K(t);else if(!c(t=e.localeData().monthsParse(t)))return e;return i=Math.min(e.date(),Re(e.year(),t)),e._d["set"+(e._isUTC?"UTC":"")+"Month"](t,i),e}function Ce(e){return null!=e?(Oe(this,e),a.updateOffset(this,!0),this):X(this,"Month")}function Ie(){function e(e,t){return t.length-e.length}var t,i,n=[],s=[],r=[];for(t=0;t<12;t++)i=p([2e3,t]),n.push(this.monthsShort(i,"")),s.push(this.months(i,"")),r.push(this.months(i,"")),r.push(this.monthsShort(i,""));for(n.sort(e),s.sort(e),r.sort(e),t=0;t<12;t++)n[t]=ye(n[t]),s[t]=ye(s[t]);for(t=0;t<24;t++)r[t]=ye(r[t]);this._monthsRegex=new RegExp("^("+r.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+n.join("|")+")","i")}function xe(e){return $(e)?366:365}B("Y",0,0,(function(){var e=this.year();return e<=9999?I(e,4):"+"+e})),B(0,["YY",2],0,(function(){return this.year()%100})),B(0,["YYYY",4],0,"year"),B(0,["YYYYY",5],0,"year"),B(0,["YYYYYY",6,!0],0,"year"),V("year","y"),z("year",1),pe("Y",ce),pe("YY",re,te),pe("YYYY",he,ne),pe("YYYYY",ue,se),pe("YYYYYY",ue,se),Se(["YYYYY","YYYYYY"],0),Se("YYYY",(function(e,t){t[0]=2===e.length?a.parseTwoDigitYear(e):K(e)})),Se("YY",(function(e,t){t[0]=a.parseTwoDigitYear(e)})),Se("Y",(function(e,t){t[0]=parseInt(e,10)})),a.parseTwoDigitYear=function(e){return K(e)+(K(e)>68?1900:2e3)};var Ne=Z("FullYear",!0);function Pe(e,t,i,n,s,r,a){var o;return e<100&&e>=0?(o=new Date(e+400,t,i,n,s,r,a),isFinite(o.getFullYear())&&o.setFullYear(e)):o=new Date(e,t,i,n,s,r,a),o}function Ue(e){var t,i;return e<100&&e>=0?((i=Array.prototype.slice.call(arguments))[0]=e+400,t=new Date(Date.UTC.apply(null,i)),isFinite(t.getUTCFullYear())&&t.setUTCFullYear(e)):t=new Date(Date.UTC.apply(null,arguments)),t}function Be(e,t,i){var n=7+t-i;return-((7+Ue(e,0,n).getUTCDay()-t)%7)+n-1}function Fe(e,t,i,n,s){var r,a,o=1+7*(t-1)+(7+i-n)%7+Be(e,n,s);return o<=0?a=xe(r=e-1)+o:o>xe(e)?(r=e+1,a=o-xe(e)):(r=e,a=o),{year:r,dayOfYear:a}}function Ye(e,t,i){var n,s,r=Be(e.year(),t,i),a=Math.floor((e.dayOfYear()-r-1)/7)+1;return a<1?n=a+Ge(s=e.year()-1,t,i):a>Ge(e.year(),t,i)?(n=a-Ge(e.year(),t,i),s=e.year()+1):(s=e.year(),n=a),{week:n,year:s}}function Ge(e,t,i){var n=Be(e,t,i),s=Be(e+1,t,i);return(xe(e)-n+s)/7}B("w",["ww",2],"wo","week"),B("W",["WW",2],"Wo","isoWeek"),V("week","w"),V("isoWeek","W"),z("week",5),z("isoWeek",5),pe("w",re),pe("ww",re,te),pe("W",re),pe("WW",re,te),Ee(["w","ww","W","WW"],(function(e,t,i,n){t[n.substr(0,1)]=K(e)}));function Ve(e,t){return e.slice(t,7).concat(e.slice(0,t))}B("d",0,"do","day"),B("dd",0,0,(function(e){return this.localeData().weekdaysMin(this,e)})),B("ddd",0,0,(function(e){return this.localeData().weekdaysShort(this,e)})),B("dddd",0,0,(function(e){return this.localeData().weekdays(this,e)})),B("e",0,0,"weekday"),B("E",0,0,"isoWeekday"),V("day","d"),V("weekday","e"),V("isoWeekday","E"),z("day",11),z("weekday",11),z("isoWeekday",11),pe("d",re),pe("e",re),pe("E",re),pe("dd",(function(e,t){return t.weekdaysMinRegex(e)})),pe("ddd",(function(e,t){return t.weekdaysShortRegex(e)})),pe("dddd",(function(e,t){return t.weekdaysRegex(e)})),Ee(["dd","ddd","dddd"],(function(e,t,i,n){var s=i._locale.weekdaysParse(e,n,i._strict);null!=s?t.d=s:g(i).invalidWeekday=e})),Ee(["d","e","E"],(function(e,t,i,n){t[n]=K(e)}));var je="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),We="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),He="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ze=me,$e=me,qe=me;function Ke(e,t,i){var n,s,r,a=e.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],n=0;n<7;++n)r=p([2e3,1]).day(n),this._minWeekdaysParse[n]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[n]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[n]=this.weekdays(r,"").toLocaleLowerCase();return i?"dddd"===t?-1!==(s=we.call(this._weekdaysParse,a))?s:null:"ddd"===t?-1!==(s=we.call(this._shortWeekdaysParse,a))?s:null:-1!==(s=we.call(this._minWeekdaysParse,a))?s:null:"dddd"===t?-1!==(s=we.call(this._weekdaysParse,a))||-1!==(s=we.call(this._shortWeekdaysParse,a))||-1!==(s=we.call(this._minWeekdaysParse,a))?s:null:"ddd"===t?-1!==(s=we.call(this._shortWeekdaysParse,a))||-1!==(s=we.call(this._weekdaysParse,a))||-1!==(s=we.call(this._minWeekdaysParse,a))?s:null:-1!==(s=we.call(this._minWeekdaysParse,a))||-1!==(s=we.call(this._weekdaysParse,a))||-1!==(s=we.call(this._shortWeekdaysParse,a))?s:null}function Ze(){function e(e,t){return t.length-e.length}var t,i,n,s,r,a=[],o=[],l=[],h=[];for(t=0;t<7;t++)i=p([2e3,1]).day(t),n=ye(this.weekdaysMin(i,"")),s=ye(this.weekdaysShort(i,"")),r=ye(this.weekdays(i,"")),a.push(n),o.push(s),l.push(r),h.push(n),h.push(s),h.push(r);a.sort(e),o.sort(e),l.sort(e),h.sort(e),this._weekdaysRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+a.join("|")+")","i")}function Xe(){return this.hours()%12||12}function Je(e,t){B(e,0,0,(function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)}))}function Qe(e,t){return t._meridiemParse}B("H",["HH",2],0,"hour"),B("h",["hh",2],0,Xe),B("k",["kk",2],0,(function(){return this.hours()||24})),B("hmm",0,0,(function(){return""+Xe.apply(this)+I(this.minutes(),2)})),B("hmmss",0,0,(function(){return""+Xe.apply(this)+I(this.minutes(),2)+I(this.seconds(),2)})),B("Hmm",0,0,(function(){return""+this.hours()+I(this.minutes(),2)})),B("Hmmss",0,0,(function(){return""+this.hours()+I(this.minutes(),2)+I(this.seconds(),2)})),Je("a",!0),Je("A",!1),V("hour","h"),z("hour",13),pe("a",Qe),pe("A",Qe),pe("H",re),pe("h",re),pe("k",re),pe("HH",re,te),pe("hh",re,te),pe("kk",re,te),pe("hmm",ae),pe("hmmss",oe),pe("Hmm",ae),pe("Hmmss",oe),Se(["H","HH"],3),Se(["k","kk"],(function(e,t,i){var n=K(e);t[3]=24===n?0:n})),Se(["a","A"],(function(e,t,i){i._isPm=i._locale.isPM(e),i._meridiem=e})),Se(["h","hh"],(function(e,t,i){t[3]=K(e),g(i).bigHour=!0})),Se("hmm",(function(e,t,i){var n=e.length-2;t[3]=K(e.substr(0,n)),t[4]=K(e.substr(n)),g(i).bigHour=!0})),Se("hmmss",(function(e,t,i){var n=e.length-4,s=e.length-2;t[3]=K(e.substr(0,n)),t[4]=K(e.substr(n,2)),t[5]=K(e.substr(s)),g(i).bigHour=!0})),Se("Hmm",(function(e,t,i){var n=e.length-2;t[3]=K(e.substr(0,n)),t[4]=K(e.substr(n))})),Se("Hmmss",(function(e,t,i){var n=e.length-4,s=e.length-2;t[3]=K(e.substr(0,n)),t[4]=K(e.substr(n,2)),t[5]=K(e.substr(s))}));var et=Z("Hours",!0);var tt,it={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:ke,monthsShort:Ae,week:{dow:0,doy:6},weekdays:je,weekdaysMin:He,weekdaysShort:We,meridiemParse:/[ap]\.?m?\.?/i},nt={},st={};function rt(e,t){var i,n=Math.min(e.length,t.length);for(i=0;i<n;i+=1)if(e[i]!==t[i])return i;return n}function at(e){return e?e.toLowerCase().replace("_","-"):e}function ot(t){var n=null;if(void 0===nt[t]&&void 0!==e&&e&&e.exports)try{n=tt._abbr,void 0,i(15)("./"+t),lt(n)}catch(e){nt[t]=null}return nt[t]}function lt(e,t){var i;return e&&((i=d(t)?ut(e):ht(e,t))?tt=i:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),tt._abbr}function ht(e,t){if(null!==t){var i,n=it;if(t.abbr=e,null!=nt[e])T("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=nt[e]._config;else if(null!=t.parentLocale)if(null!=nt[t.parentLocale])n=nt[t.parentLocale]._config;else{if(null==(i=ot(t.parentLocale)))return st[t.parentLocale]||(st[t.parentLocale]=[]),st[t.parentLocale].push({name:e,config:t}),null;n=i._config}return nt[e]=new C(O(n,t)),st[e]&&st[e].forEach((function(e){ht(e.name,e.config)})),lt(e),nt[e]}return delete nt[e],null}function ut(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return tt;if(!o(e)){if(t=ot(e))return t;e=[e]}return function(e){for(var t,i,n,s,r=0;r<e.length;){for(t=(s=at(e[r]).split("-")).length,i=(i=at(e[r+1]))?i.split("-"):null;t>0;){if(n=ot(s.slice(0,t).join("-")))return n;if(i&&i.length>=t&&rt(s,i)>=t-1)break;t--}r++}return tt}(e)}function dt(e){var t,i=e._a;return i&&-2===g(e).overflow&&(t=i[1]<0||i[1]>11?1:i[2]<1||i[2]>Re(i[0],i[1])?2:i[3]<0||i[3]>24||24===i[3]&&(0!==i[4]||0!==i[5]||0!==i[6])?3:i[4]<0||i[4]>59?4:i[5]<0||i[5]>59?5:i[6]<0||i[6]>999?6:-1,g(e)._overflowDayOfYear&&(t<0||t>2)&&(t=2),g(e)._overflowWeeks&&-1===t&&(t=7),g(e)._overflowWeekday&&-1===t&&(t=8),g(e).overflow=t),e}var ct=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,_t=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ft=/Z|[+-]\d\d(?::?\d\d)?/,mt=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,!1],["YYYY",/\d{4}/,!1]],pt=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],gt=/^\/?Date\((-?\d+)/i,yt=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,vt={UT:0,GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function St(e){var t,i,n,s,r,a,o=e._i,l=ct.exec(o)||_t.exec(o);if(l){for(g(e).iso=!0,t=0,i=mt.length;t<i;t++)if(mt[t][1].exec(l[1])){s=mt[t][0],n=!1!==mt[t][2];break}if(null==s)return void(e._isValid=!1);if(l[3]){for(t=0,i=pt.length;t<i;t++)if(pt[t][1].exec(l[3])){r=(l[2]||" ")+pt[t][0];break}if(null==r)return void(e._isValid=!1)}if(!n&&null!=r)return void(e._isValid=!1);if(l[4]){if(!ft.exec(l[4]))return void(e._isValid=!1);a="Z"}e._f=s+(r||"")+(a||""),kt(e)}else e._isValid=!1}function Et(e){var t=parseInt(e,10);return t<=49?2e3+t:t<=999?1900+t:t}function bt(e){var t,i,n,s,r,a,o,l,h=yt.exec(e._i.replace(/\([^)]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,""));if(h){if(i=h[4],n=h[3],s=h[2],r=h[5],a=h[6],o=h[7],l=[Et(i),Ae.indexOf(n),parseInt(s,10),parseInt(r,10),parseInt(a,10)],o&&l.push(parseInt(o,10)),t=l,!function(e,t,i){return!e||We.indexOf(e)===new Date(t[0],t[1],t[2]).getDay()||(g(i).weekdayMismatch=!0,i._isValid=!1,!1)}(h[1],t,e))return;e._a=t,e._tzm=function(e,t,i){if(e)return vt[e];if(t)return 0;var n=parseInt(i,10),s=n%100;return 60*((n-s)/100)+s}(h[8],h[9],h[10]),e._d=Ue.apply(null,e._a),e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),g(e).rfc2822=!0}else e._isValid=!1}function wt(e,t,i){return null!=e?e:null!=t?t:i}function Rt(e){var t,i,n,s,r,o=[];if(!e._d){for(n=function(e){var t=new Date(a.now());return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}(e),e._w&&null==e._a[2]&&null==e._a[1]&&function(e){var t,i,n,s,r,a,o,l,h;null!=(t=e._w).GG||null!=t.W||null!=t.E?(r=1,a=4,i=wt(t.GG,e._a[0],Ye(Dt(),1,4).year),n=wt(t.W,1),((s=wt(t.E,1))<1||s>7)&&(l=!0)):(r=e._locale._week.dow,a=e._locale._week.doy,h=Ye(Dt(),r,a),i=wt(t.gg,e._a[0],h.year),n=wt(t.w,h.week),null!=t.d?((s=t.d)<0||s>6)&&(l=!0):null!=t.e?(s=t.e+r,(t.e<0||t.e>6)&&(l=!0)):s=r);n<1||n>Ge(i,r,a)?g(e)._overflowWeeks=!0:null!=l?g(e)._overflowWeekday=!0:(o=Fe(i,n,s,r,a),e._a[0]=o.year,e._dayOfYear=o.dayOfYear)}(e),null!=e._dayOfYear&&(r=wt(e._a[0],n[0]),(e._dayOfYear>xe(r)||0===e._dayOfYear)&&(g(e)._overflowDayOfYear=!0),i=Ue(r,0,e._dayOfYear),e._a[1]=i.getUTCMonth(),e._a[2]=i.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=o[t]=n[t];for(;t<7;t++)e._a[t]=o[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[3]&&0===e._a[4]&&0===e._a[5]&&0===e._a[6]&&(e._nextDay=!0,e._a[3]=0),e._d=(e._useUTC?Ue:Pe).apply(null,o),s=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[3]=24),e._w&&void 0!==e._w.d&&e._w.d!==s&&(g(e).weekdayMismatch=!0)}}function kt(e){if(e._f!==a.ISO_8601)if(e._f!==a.RFC_2822){e._a=[],g(e).empty=!0;var t,i,n,s,r,o,l=""+e._i,h=l.length,u=0;for(n=Y(e._f,e._locale).match(x)||[],t=0;t<n.length;t++)s=n[t],(i=(l.match(ge(s,e))||[])[0])&&((r=l.substr(0,l.indexOf(i))).length>0&&g(e).unusedInput.push(r),l=l.slice(l.indexOf(i)+i.length),u+=i.length),U[s]?(i?g(e).empty=!1:g(e).unusedTokens.push(s),be(s,i,e)):e._strict&&!i&&g(e).unusedTokens.push(s);g(e).charsLeftOver=h-u,l.length>0&&g(e).unusedInput.push(l),e._a[3]<=12&&!0===g(e).bigHour&&e._a[3]>0&&(g(e).bigHour=void 0),g(e).parsedDateParts=e._a.slice(0),g(e).meridiem=e._meridiem,e._a[3]=function(e,t,i){var n;if(null==i)return t;return null!=e.meridiemHour?e.meridiemHour(t,i):null!=e.isPM?((n=e.isPM(i))&&t<12&&(t+=12),n||12!==t||(t=0),t):t}(e._locale,e._a[3],e._meridiem),null!==(o=g(e).era)&&(e._a[0]=e._locale.erasConvertYear(o,e._a[0])),Rt(e),dt(e)}else bt(e);else St(e)}function At(e){var t=e._i,i=e._f;return e._locale=e._locale||ut(e._l),null===t||void 0===i&&""===t?v({nullInput:!0}):("string"==typeof t&&(e._i=t=e._locale.preparse(t)),R(t)?new w(dt(t)):(_(t)?e._d=t:o(i)?function(e){var t,i,n,s,r,a,o=!1;if(0===e._f.length)return g(e).invalidFormat=!0,void(e._d=new Date(NaN));for(s=0;s<e._f.length;s++)r=0,a=!1,t=b({},e),null!=e._useUTC&&(t._useUTC=e._useUTC),t._f=e._f[s],kt(t),y(t)&&(a=!0),r+=g(t).charsLeftOver,r+=10*g(t).unusedTokens.length,g(t).score=r,o?r<n&&(n=r,i=t):(null==n||r<n||a)&&(n=r,i=t,a&&(o=!0));m(e,i||t)}(e):i?kt(e):function(e){var t=e._i;d(t)?e._d=new Date(a.now()):_(t)?e._d=new Date(t.valueOf()):"string"==typeof t?function(e){var t=gt.exec(e._i);null===t?(St(e),!1===e._isValid&&(delete e._isValid,bt(e),!1===e._isValid&&(delete e._isValid,e._strict?e._isValid=!1:a.createFromInputFallback(e)))):e._d=new Date(+t[1])}(e):o(t)?(e._a=f(t.slice(0),(function(e){return parseInt(e,10)})),Rt(e)):l(t)?function(e){if(!e._d){var t=W(e._i),i=void 0===t.day?t.date:t.day;e._a=f([t.year,t.month,i,t.hour,t.minute,t.second,t.millisecond],(function(e){return e&&parseInt(e,10)})),Rt(e)}}(e):c(t)?e._d=new Date(t):a.createFromInputFallback(e)}(e),y(e)||(e._d=null),e))}function Lt(e,t,i,n,s){var r,a={};return!0!==t&&!1!==t||(n=t,t=void 0),!0!==i&&!1!==i||(n=i,i=void 0),(l(e)&&u(e)||o(e)&&0===e.length)&&(e=void 0),a._isAMomentObject=!0,a._useUTC=a._isUTC=s,a._l=i,a._i=e,a._f=t,a._strict=n,(r=new w(dt(At(a))))._nextDay&&(r.add(1,"d"),r._nextDay=void 0),r}function Dt(e,t,i,n){return Lt(e,t,i,n,!1)}a.createFromInputFallback=A("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",(function(e){e._d=new Date(e._i+(e._useUTC?" UTC":""))})),a.ISO_8601=function(){},a.RFC_2822=function(){};var Tt=A("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",(function(){var e=Dt.apply(null,arguments);return this.isValid()&&e.isValid()?e<this?this:e:v()})),Mt=A("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",(function(){var e=Dt.apply(null,arguments);return this.isValid()&&e.isValid()?e>this?this:e:v()}));function Ot(e,t){var i,n;if(1===t.length&&o(t[0])&&(t=t[0]),!t.length)return Dt();for(i=t[0],n=1;n<t.length;++n)t[n].isValid()&&!t[n][e](i)||(i=t[n]);return i}var Ct=["year","quarter","month","week","day","hour","minute","second","millisecond"];function It(e){var t=W(e),i=t.year||0,n=t.quarter||0,s=t.month||0,r=t.week||t.isoWeek||0,a=t.day||0,o=t.hour||0,l=t.minute||0,u=t.second||0,d=t.millisecond||0;this._isValid=function(e){var t,i,n=!1;for(t in e)if(h(e,t)&&(-1===we.call(Ct,t)||null!=e[t]&&isNaN(e[t])))return!1;for(i=0;i<Ct.length;++i)if(e[Ct[i]]){if(n)return!1;parseFloat(e[Ct[i]])!==K(e[Ct[i]])&&(n=!0)}return!0}(t),this._milliseconds=+d+1e3*u+6e4*l+1e3*o*60*60,this._days=+a+7*r,this._months=+s+3*n+12*i,this._data={},this._locale=ut(),this._bubble()}function xt(e){return e instanceof It}function Nt(e){return e<0?-1*Math.round(-1*e):Math.round(e)}function Pt(e,t){B(e,0,0,(function(){var e=this.utcOffset(),i="+";return e<0&&(e=-e,i="-"),i+I(~~(e/60),2)+t+I(~~e%60,2)}))}Pt("Z",":"),Pt("ZZ",""),pe("Z",fe),pe("ZZ",fe),Se(["Z","ZZ"],(function(e,t,i){i._useUTC=!0,i._tzm=Bt(fe,e)}));var Ut=/([\+\-]|\d\d)/gi;function Bt(e,t){var i,n,s=(t||"").match(e);return null===s?null:0===(n=60*(i=((s[s.length-1]||[])+"").match(Ut)||["-",0,0])[1]+K(i[2]))?0:"+"===i[0]?n:-n}function Ft(e,t){var i,n;return t._isUTC?(i=t.clone(),n=(R(e)||_(e)?e.valueOf():Dt(e).valueOf())-i.valueOf(),i._d.setTime(i._d.valueOf()+n),a.updateOffset(i,!1),i):Dt(e).local()}function Yt(e){return-Math.round(e._d.getTimezoneOffset())}function Gt(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}a.updateOffset=function(){};var Vt=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,jt=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function Wt(e,t){var i,n,s,a=e,o=null;return xt(e)?a={ms:e._milliseconds,d:e._days,M:e._months}:c(e)||!isNaN(+e)?(a={},t?a[t]=+e:a.milliseconds=+e):(o=Vt.exec(e))?(i="-"===o[1]?-1:1,a={y:0,d:K(o[2])*i,h:K(o[3])*i,m:K(o[4])*i,s:K(o[5])*i,ms:K(Nt(1e3*o[6]))*i}):(o=jt.exec(e))?(i="-"===o[1]?-1:1,a={y:Ht(o[2],i),M:Ht(o[3],i),w:Ht(o[4],i),d:Ht(o[5],i),h:Ht(o[6],i),m:Ht(o[7],i),s:Ht(o[8],i)}):null==a?a={}:"object"===r(a)&&("from"in a||"to"in a)&&(s=function(e,t){var i;if(!e.isValid()||!t.isValid())return{milliseconds:0,months:0};t=Ft(t,e),e.isBefore(t)?i=zt(e,t):((i=zt(t,e)).milliseconds=-i.milliseconds,i.months=-i.months);return i}(Dt(a.from),Dt(a.to)),(a={}).ms=s.milliseconds,a.M=s.months),n=new It(a),xt(e)&&h(e,"_locale")&&(n._locale=e._locale),xt(e)&&h(e,"_isValid")&&(n._isValid=e._isValid),n}function Ht(e,t){var i=e&&parseFloat(e.replace(",","."));return(isNaN(i)?0:i)*t}function zt(e,t){var i={};return i.months=t.month()-e.month()+12*(t.year()-e.year()),e.clone().add(i.months,"M").isAfter(t)&&--i.months,i.milliseconds=+t-+e.clone().add(i.months,"M"),i}function $t(e,t){return function(i,n){var s;return null===n||isNaN(+n)||(T(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),s=i,i=n,n=s),qt(this,Wt(i,n),e),this}}function qt(e,t,i,n){var s=t._milliseconds,r=Nt(t._days),o=Nt(t._months);e.isValid()&&(n=null==n||n,o&&Oe(e,X(e,"Month")+o*i),r&&J(e,"Date",X(e,"Date")+r*i),s&&e._d.setTime(e._d.valueOf()+s*i),n&&a.updateOffset(e,r||o))}Wt.fn=It.prototype,Wt.invalid=function(){return Wt(NaN)};var Kt=$t(1,"add"),Zt=$t(-1,"subtract");function Xt(e){return"string"==typeof e||e instanceof String}function Jt(e){return R(e)||_(e)||Xt(e)||c(e)||function(e){var t=o(e),i=!1;t&&(i=0===e.filter((function(t){return!c(t)&&Xt(e)})).length);return t&&i}(e)||function(e){var t,i,n=l(e)&&!u(e),s=!1,r=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"];for(t=0;t<r.length;t+=1)i=r[t],s=s||h(e,i);return n&&s}(e)||null==e}function Qt(e){var t,i=l(e)&&!u(e),n=!1,s=["sameDay","nextDay","lastDay","nextWeek","lastWeek","sameElse"];for(t=0;t<s.length;t+=1)n=n||h(e,s[t]);return i&&n}function ei(e,t){if(e.date()<t.date())return-ei(t,e);var i=12*(t.year()-e.year())+(t.month()-e.month()),n=e.clone().add(i,"months");return-(i+(t-n<0?(t-n)/(n-e.clone().add(i-1,"months")):(t-n)/(e.clone().add(i+1,"months")-n)))||0}function ti(e){var t;return void 0===e?this._locale._abbr:(null!=(t=ut(e))&&(this._locale=t),this)}a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",a.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var ii=A("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",(function(e){return void 0===e?this.localeData():this.locale(e)}));function ni(){return this._locale}function si(e,t){return(e%t+t)%t}function ri(e,t,i){return e<100&&e>=0?new Date(e+400,t,i)-126227808e5:new Date(e,t,i).valueOf()}function ai(e,t,i){return e<100&&e>=0?Date.UTC(e+400,t,i)-126227808e5:Date.UTC(e,t,i)}function oi(e,t){return t.erasAbbrRegex(e)}function li(){var e,t,i=[],n=[],s=[],r=[],a=this.eras();for(e=0,t=a.length;e<t;++e)n.push(ye(a[e].name)),i.push(ye(a[e].abbr)),s.push(ye(a[e].narrow)),r.push(ye(a[e].name)),r.push(ye(a[e].abbr)),r.push(ye(a[e].narrow));this._erasRegex=new RegExp("^("+r.join("|")+")","i"),this._erasNameRegex=new RegExp("^("+n.join("|")+")","i"),this._erasAbbrRegex=new RegExp("^("+i.join("|")+")","i"),this._erasNarrowRegex=new RegExp("^("+s.join("|")+")","i")}function hi(e,t){B(0,[e,e.length],0,t)}function ui(e,t,i,n,s){var r;return null==e?Ye(this,n,s).year:(t>(r=Ge(e,n,s))&&(t=r),di.call(this,e,t,i,n,s))}function di(e,t,i,n,s){var r=Fe(e,t,i,n,s),a=Ue(r.year,0,r.dayOfYear);return this.year(a.getUTCFullYear()),this.month(a.getUTCMonth()),this.date(a.getUTCDate()),this}B("N",0,0,"eraAbbr"),B("NN",0,0,"eraAbbr"),B("NNN",0,0,"eraAbbr"),B("NNNN",0,0,"eraName"),B("NNNNN",0,0,"eraNarrow"),B("y",["y",1],"yo","eraYear"),B("y",["yy",2],0,"eraYear"),B("y",["yyy",3],0,"eraYear"),B("y",["yyyy",4],0,"eraYear"),pe("N",oi),pe("NN",oi),pe("NNN",oi),pe("NNNN",(function(e,t){return t.erasNameRegex(e)})),pe("NNNNN",(function(e,t){return t.erasNarrowRegex(e)})),Se(["N","NN","NNN","NNNN","NNNNN"],(function(e,t,i,n){var s=i._locale.erasParse(e,n,i._strict);s?g(i).era=s:g(i).invalidEra=e})),pe("y",de),pe("yy",de),pe("yyy",de),pe("yyyy",de),pe("yo",(function(e,t){return t._eraYearOrdinalRegex||de})),Se(["y","yy","yyy","yyyy"],0),Se(["yo"],(function(e,t,i,n){var s;i._locale._eraYearOrdinalRegex&&(s=e.match(i._locale._eraYearOrdinalRegex)),i._locale.eraYearOrdinalParse?t[0]=i._locale.eraYearOrdinalParse(e,s):t[0]=parseInt(e,10)})),B(0,["gg",2],0,(function(){return this.weekYear()%100})),B(0,["GG",2],0,(function(){return this.isoWeekYear()%100})),hi("gggg","weekYear"),hi("ggggg","weekYear"),hi("GGGG","isoWeekYear"),hi("GGGGG","isoWeekYear"),V("weekYear","gg"),V("isoWeekYear","GG"),z("weekYear",1),z("isoWeekYear",1),pe("G",ce),pe("g",ce),pe("GG",re,te),pe("gg",re,te),pe("GGGG",he,ne),pe("gggg",he,ne),pe("GGGGG",ue,se),pe("ggggg",ue,se),Ee(["gggg","ggggg","GGGG","GGGGG"],(function(e,t,i,n){t[n.substr(0,2)]=K(e)})),Ee(["gg","GG"],(function(e,t,i,n){t[n]=a.parseTwoDigitYear(e)})),B("Q",0,"Qo","quarter"),V("quarter","Q"),z("quarter",7),pe("Q",ee),Se("Q",(function(e,t){t[1]=3*(K(e)-1)})),B("D",["DD",2],"Do","date"),V("date","D"),z("date",9),pe("D",re),pe("DD",re,te),pe("Do",(function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient})),Se(["D","DD"],2),Se("Do",(function(e,t){t[2]=K(e.match(re)[0])}));var ci=Z("Date",!0);B("DDD",["DDDD",3],"DDDo","dayOfYear"),V("dayOfYear","DDD"),z("dayOfYear",4),pe("DDD",le),pe("DDDD",ie),Se(["DDD","DDDD"],(function(e,t,i){i._dayOfYear=K(e)})),B("m",["mm",2],0,"minute"),V("minute","m"),z("minute",14),pe("m",re),pe("mm",re,te),Se(["m","mm"],4);var _i=Z("Minutes",!1);B("s",["ss",2],0,"second"),V("second","s"),z("second",15),pe("s",re),pe("ss",re,te),Se(["s","ss"],5);var fi,mi,pi=Z("Seconds",!1);for(B("S",0,0,(function(){return~~(this.millisecond()/100)})),B(0,["SS",2],0,(function(){return~~(this.millisecond()/10)})),B(0,["SSS",3],0,"millisecond"),B(0,["SSSS",4],0,(function(){return 10*this.millisecond()})),B(0,["SSSSS",5],0,(function(){return 100*this.millisecond()})),B(0,["SSSSSS",6],0,(function(){return 1e3*this.millisecond()})),B(0,["SSSSSSS",7],0,(function(){return 1e4*this.millisecond()})),B(0,["SSSSSSSS",8],0,(function(){return 1e5*this.millisecond()})),B(0,["SSSSSSSSS",9],0,(function(){return 1e6*this.millisecond()})),V("millisecond","ms"),z("millisecond",16),pe("S",le,ee),pe("SS",le,te),pe("SSS",le,ie),fi="SSSS";fi.length<=9;fi+="S")pe(fi,de);function gi(e,t){t[6]=K(1e3*("0."+e))}for(fi="S";fi.length<=9;fi+="S")Se(fi,gi);mi=Z("Milliseconds",!1),B("z",0,0,"zoneAbbr"),B("zz",0,0,"zoneName");var yi=w.prototype;function vi(e){return e}yi.add=Kt,yi.calendar=function(e,t){1===arguments.length&&(arguments[0]?Jt(arguments[0])?(e=arguments[0],t=void 0):Qt(arguments[0])&&(t=arguments[0],e=void 0):(e=void 0,t=void 0));var i=e||Dt(),n=Ft(i,this).startOf("day"),s=a.calendarFormat(this,n)||"sameElse",r=t&&(M(t[s])?t[s].call(this,i):t[s]);return this.format(r||this.localeData().calendar(s,this,Dt(i)))},yi.clone=function(){return new w(this)},yi.diff=function(e,t,i){var n,s,r;if(!this.isValid())return NaN;if(!(n=Ft(e,this)).isValid())return NaN;switch(s=6e4*(n.utcOffset()-this.utcOffset()),t=j(t)){case"year":r=ei(this,n)/12;break;case"month":r=ei(this,n);break;case"quarter":r=ei(this,n)/3;break;case"second":r=(this-n)/1e3;break;case"minute":r=(this-n)/6e4;break;case"hour":r=(this-n)/36e5;break;case"day":r=(this-n-s)/864e5;break;case"week":r=(this-n-s)/6048e5;break;default:r=this-n}return i?r:q(r)},yi.endOf=function(e){var t,i;if(void 0===(e=j(e))||"millisecond"===e||!this.isValid())return this;switch(i=this._isUTC?ai:ri,e){case"year":t=i(this.year()+1,0,1)-1;break;case"quarter":t=i(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=i(this.year(),this.month()+1,1)-1;break;case"week":t=i(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=i(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf(),t+=36e5-si(t+(this._isUTC?0:6e4*this.utcOffset()),36e5)-1;break;case"minute":t=this._d.valueOf(),t+=6e4-si(t,6e4)-1;break;case"second":t=this._d.valueOf(),t+=1e3-si(t,1e3)-1}return this._d.setTime(t),a.updateOffset(this,!0),this},yi.format=function(e){e||(e=this.isUtc()?a.defaultFormatUtc:a.defaultFormat);var t=F(this,e);return this.localeData().postformat(t)},yi.from=function(e,t){return this.isValid()&&(R(e)&&e.isValid()||Dt(e).isValid())?Wt({to:this,from:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()},yi.fromNow=function(e){return this.from(Dt(),e)},yi.to=function(e,t){return this.isValid()&&(R(e)&&e.isValid()||Dt(e).isValid())?Wt({from:this,to:e}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()},yi.toNow=function(e){return this.to(Dt(),e)},yi.get=function(e){return M(this[e=j(e)])?this[e]():this},yi.invalidAt=function(){return g(this).overflow},yi.isAfter=function(e,t){var i=R(e)?e:Dt(e);return!(!this.isValid()||!i.isValid())&&("millisecond"===(t=j(t)||"millisecond")?this.valueOf()>i.valueOf():i.valueOf()<this.clone().startOf(t).valueOf())},yi.isBefore=function(e,t){var i=R(e)?e:Dt(e);return!(!this.isValid()||!i.isValid())&&("millisecond"===(t=j(t)||"millisecond")?this.valueOf()<i.valueOf():this.clone().endOf(t).valueOf()<i.valueOf())},yi.isBetween=function(e,t,i,n){var s=R(e)?e:Dt(e),r=R(t)?t:Dt(t);return!!(this.isValid()&&s.isValid()&&r.isValid())&&(("("===(n=n||"()")[0]?this.isAfter(s,i):!this.isBefore(s,i))&&(")"===n[1]?this.isBefore(r,i):!this.isAfter(r,i)))},yi.isSame=function(e,t){var i,n=R(e)?e:Dt(e);return!(!this.isValid()||!n.isValid())&&("millisecond"===(t=j(t)||"millisecond")?this.valueOf()===n.valueOf():(i=n.valueOf(),this.clone().startOf(t).valueOf()<=i&&i<=this.clone().endOf(t).valueOf()))},yi.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)},yi.isSameOrBefore=function(e,t){return this.isSame(e,t)||this.isBefore(e,t)},yi.isValid=function(){return y(this)},yi.lang=ii,yi.locale=ti,yi.localeData=ni,yi.max=Mt,yi.min=Tt,yi.parsingFlags=function(){return m({},g(this))},yi.set=function(e,t){if("object"===r(e)){var i,n=function(e){var t,i=[];for(t in e)h(e,t)&&i.push({unit:t,priority:H[t]});return i.sort((function(e,t){return e.priority-t.priority})),i}(e=W(e));for(i=0;i<n.length;i++)this[n[i].unit](e[n[i].unit])}else if(M(this[e=j(e)]))return this[e](t);return this},yi.startOf=function(e){var t,i;if(void 0===(e=j(e))||"millisecond"===e||!this.isValid())return this;switch(i=this._isUTC?ai:ri,e){case"year":t=i(this.year(),0,1);break;case"quarter":t=i(this.year(),this.month()-this.month()%3,1);break;case"month":t=i(this.year(),this.month(),1);break;case"week":t=i(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=i(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf(),t-=si(t+(this._isUTC?0:6e4*this.utcOffset()),36e5);break;case"minute":t=this._d.valueOf(),t-=si(t,6e4);break;case"second":t=this._d.valueOf(),t-=si(t,1e3)}return this._d.setTime(t),a.updateOffset(this,!0),this},yi.subtract=Zt,yi.toArray=function(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]},yi.toObject=function(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}},yi.toDate=function(){return new Date(this.valueOf())},yi.toISOString=function(e){if(!this.isValid())return null;var t=!0!==e,i=t?this.clone().utc():this;return i.year()<0||i.year()>9999?F(i,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"):M(Date.prototype.toISOString)?t?this.toDate().toISOString():new Date(this.valueOf()+60*this.utcOffset()*1e3).toISOString().replace("Z",F(i,"Z")):F(i,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")},yi.inspect=function(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e,t,i,n="moment",s="";return this.isLocal()||(n=0===this.utcOffset()?"moment.utc":"moment.parseZone",s="Z"),e="["+n+'("]',t=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY","-MM-DD[T]HH:mm:ss.SSS",i=s+'[")]',this.format(e+t+"-MM-DD[T]HH:mm:ss.SSS"+i)},"undefined"!=typeof Symbol&&null!=Symbol.for&&(yi[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"}),yi.toJSON=function(){return this.isValid()?this.toISOString():null},yi.toString=function(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},yi.unix=function(){return Math.floor(this.valueOf()/1e3)},yi.valueOf=function(){return this._d.valueOf()-6e4*(this._offset||0)},yi.creationData=function(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}},yi.eraName=function(){var e,t,i,n=this.localeData().eras();for(e=0,t=n.length;e<t;++e){if(i=this.clone().startOf("day").valueOf(),n[e].since<=i&&i<=n[e].until)return n[e].name;if(n[e].until<=i&&i<=n[e].since)return n[e].name}return""},yi.eraNarrow=function(){var e,t,i,n=this.localeData().eras();for(e=0,t=n.length;e<t;++e){if(i=this.clone().startOf("day").valueOf(),n[e].since<=i&&i<=n[e].until)return n[e].narrow;if(n[e].until<=i&&i<=n[e].since)return n[e].narrow}return""},yi.eraAbbr=function(){var e,t,i,n=this.localeData().eras();for(e=0,t=n.length;e<t;++e){if(i=this.clone().startOf("day").valueOf(),n[e].since<=i&&i<=n[e].until)return n[e].abbr;if(n[e].until<=i&&i<=n[e].since)return n[e].abbr}return""},yi.eraYear=function(){var e,t,i,n,s=this.localeData().eras();for(e=0,t=s.length;e<t;++e)if(i=s[e].since<=s[e].until?1:-1,n=this.clone().startOf("day").valueOf(),s[e].since<=n&&n<=s[e].until||s[e].until<=n&&n<=s[e].since)return(this.year()-a(s[e].since).year())*i+s[e].offset;return this.year()},yi.year=Ne,yi.isLeapYear=function(){return $(this.year())},yi.weekYear=function(e){return ui.call(this,e,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)},yi.isoWeekYear=function(e){return ui.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)},yi.quarter=yi.quarters=function(e){return null==e?Math.ceil((this.month()+1)/3):this.month(3*(e-1)+this.month()%3)},yi.month=Ce,yi.daysInMonth=function(){return Re(this.year(),this.month())},yi.week=yi.weeks=function(e){var t=this.localeData().week(this);return null==e?t:this.add(7*(e-t),"d")},yi.isoWeek=yi.isoWeeks=function(e){var t=Ye(this,1,4).week;return null==e?t:this.add(7*(e-t),"d")},yi.weeksInYear=function(){var e=this.localeData()._week;return Ge(this.year(),e.dow,e.doy)},yi.weeksInWeekYear=function(){var e=this.localeData()._week;return Ge(this.weekYear(),e.dow,e.doy)},yi.isoWeeksInYear=function(){return Ge(this.year(),1,4)},yi.isoWeeksInISOWeekYear=function(){return Ge(this.isoWeekYear(),1,4)},yi.date=ci,yi.day=yi.days=function(e){if(!this.isValid())return null!=e?this:NaN;var t=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=e?(e=function(e,t){return"string"!=typeof e?e:isNaN(e)?"number"==typeof(e=t.weekdaysParse(e))?e:null:parseInt(e,10)}(e,this.localeData()),this.add(e-t,"d")):t},yi.weekday=function(e){if(!this.isValid())return null!=e?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return null==e?t:this.add(e-t,"d")},yi.isoWeekday=function(e){if(!this.isValid())return null!=e?this:NaN;if(null!=e){var t=function(e,t){return"string"==typeof e?t.weekdaysParse(e)%7||7:isNaN(e)?null:e}(e,this.localeData());return this.day(this.day()%7?t:t-7)}return this.day()||7},yi.dayOfYear=function(e){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"d")},yi.hour=yi.hours=et,yi.minute=yi.minutes=_i,yi.second=yi.seconds=pi,yi.millisecond=yi.milliseconds=mi,yi.utcOffset=function(e,t,i){var n,s=this._offset||0;if(!this.isValid())return null!=e?this:NaN;if(null!=e){if("string"==typeof e){if(null===(e=Bt(fe,e)))return this}else Math.abs(e)<16&&!i&&(e*=60);return!this._isUTC&&t&&(n=Yt(this)),this._offset=e,this._isUTC=!0,null!=n&&this.add(n,"m"),s!==e&&(!t||this._changeInProgress?qt(this,Wt(e-s,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,a.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?s:Yt(this)},yi.utc=function(e){return this.utcOffset(0,e)},yi.local=function(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e&&this.subtract(Yt(this),"m")),this},yi.parseZone=function(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if("string"==typeof this._i){var e=Bt(_e,this._i);null!=e?this.utcOffset(e):this.utcOffset(0,!0)}return this},yi.hasAlignedHourOffset=function(e){return!!this.isValid()&&(e=e?Dt(e).utcOffset():0,(this.utcOffset()-e)%60==0)},yi.isDST=function(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},yi.isLocal=function(){return!!this.isValid()&&!this._isUTC},yi.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},yi.isUtc=Gt,yi.isUTC=Gt,yi.zoneAbbr=function(){return this._isUTC?"UTC":""},yi.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},yi.dates=A("dates accessor is deprecated. Use date instead.",ci),yi.months=A("months accessor is deprecated. Use month instead",Ce),yi.years=A("years accessor is deprecated. Use year instead",Ne),yi.zone=A("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",(function(e,t){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()})),yi.isDSTShifted=A("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",(function(){if(!d(this._isDSTShifted))return this._isDSTShifted;var e,t={};return b(t,this),(t=At(t))._a?(e=t._isUTC?p(t._a):Dt(t._a),this._isDSTShifted=this.isValid()&&function(e,t,i){var n,s=Math.min(e.length,t.length),r=Math.abs(e.length-t.length),a=0;for(n=0;n<s;n++)(i&&e[n]!==t[n]||!i&&K(e[n])!==K(t[n]))&&a++;return a+r}(t._a,e.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted}));var Si=C.prototype;function Ei(e,t,i,n){var s=ut(),r=p().set(n,t);return s[i](r,e)}function bi(e,t,i){if(c(e)&&(t=e,e=void 0),e=e||"",null!=t)return Ei(e,t,i,"month");var n,s=[];for(n=0;n<12;n++)s[n]=Ei(e,n,i,"month");return s}function wi(e,t,i,n){"boolean"==typeof e?(c(t)&&(i=t,t=void 0),t=t||""):(i=t=e,e=!1,c(t)&&(i=t,t=void 0),t=t||"");var s,r=ut(),a=e?r._week.dow:0,o=[];if(null!=i)return Ei(t,(i+a)%7,n,"day");for(s=0;s<7;s++)o[s]=Ei(t,(s+a)%7,n,"day");return o}Si.calendar=function(e,t,i){var n=this._calendar[e]||this._calendar.sameElse;return M(n)?n.call(t,i):n},Si.longDateFormat=function(e){var t=this._longDateFormat[e],i=this._longDateFormat[e.toUpperCase()];return t||!i?t:(this._longDateFormat[e]=i.match(x).map((function(e){return"MMMM"===e||"MM"===e||"DD"===e||"dddd"===e?e.slice(1):e})).join(""),this._longDateFormat[e])},Si.invalidDate=function(){return this._invalidDate},Si.ordinal=function(e){return this._ordinal.replace("%d",e)},Si.preparse=vi,Si.postformat=vi,Si.relativeTime=function(e,t,i,n){var s=this._relativeTime[i];return M(s)?s(e,t,i,n):s.replace(/%d/i,e)},Si.pastFuture=function(e,t){var i=this._relativeTime[e>0?"future":"past"];return M(i)?i(t):i.replace(/%s/i,t)},Si.set=function(e){var t,i;for(i in e)h(e,i)&&(M(t=e[i])?this[i]=t:this["_"+i]=t);this._config=e,this._dayOfMonthOrdinalParseLenient=new RegExp((this._dayOfMonthOrdinalParse.source||this._ordinalParse.source)+"|"+/\d{1,2}/.source)},Si.eras=function(e,t){var i,n,s,o=this._eras||ut("en")._eras;for(i=0,n=o.length;i<n;++i){switch(r(o[i].since)){case"string":s=a(o[i].since).startOf("day"),o[i].since=s.valueOf()}switch(r(o[i].until)){case"undefined":o[i].until=1/0;break;case"string":s=a(o[i].until).startOf("day").valueOf(),o[i].until=s.valueOf()}}return o},Si.erasParse=function(e,t,i){var n,s,r,a,o,l=this.eras();for(e=e.toUpperCase(),n=0,s=l.length;n<s;++n)if(r=l[n].name.toUpperCase(),a=l[n].abbr.toUpperCase(),o=l[n].narrow.toUpperCase(),i)switch(t){case"N":case"NN":case"NNN":if(a===e)return l[n];break;case"NNNN":if(r===e)return l[n];break;case"NNNNN":if(o===e)return l[n]}else if([r,a,o].indexOf(e)>=0)return l[n]},Si.erasConvertYear=function(e,t){var i=e.since<=e.until?1:-1;return void 0===t?a(e.since).year():a(e.since).year()+(t-e.offset)*i},Si.erasAbbrRegex=function(e){return h(this,"_erasAbbrRegex")||li.call(this),e?this._erasAbbrRegex:this._erasRegex},Si.erasNameRegex=function(e){return h(this,"_erasNameRegex")||li.call(this),e?this._erasNameRegex:this._erasRegex},Si.erasNarrowRegex=function(e){return h(this,"_erasNarrowRegex")||li.call(this),e?this._erasNarrowRegex:this._erasRegex},Si.months=function(e,t){return e?o(this._months)?this._months[e.month()]:this._months[(this._months.isFormat||Le).test(t)?"format":"standalone"][e.month()]:o(this._months)?this._months:this._months.standalone},Si.monthsShort=function(e,t){return e?o(this._monthsShort)?this._monthsShort[e.month()]:this._monthsShort[Le.test(t)?"format":"standalone"][e.month()]:o(this._monthsShort)?this._monthsShort:this._monthsShort.standalone},Si.monthsParse=function(e,t,i){var n,s,r;if(this._monthsParseExact)return Me.call(this,e,t,i);for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),n=0;n<12;n++){if(s=p([2e3,n]),i&&!this._longMonthsParse[n]&&(this._longMonthsParse[n]=new RegExp("^"+this.months(s,"").replace(".","")+"$","i"),this._shortMonthsParse[n]=new RegExp("^"+this.monthsShort(s,"").replace(".","")+"$","i")),i||this._monthsParse[n]||(r="^"+this.months(s,"")+"|^"+this.monthsShort(s,""),this._monthsParse[n]=new RegExp(r.replace(".",""),"i")),i&&"MMMM"===t&&this._longMonthsParse[n].test(e))return n;if(i&&"MMM"===t&&this._shortMonthsParse[n].test(e))return n;if(!i&&this._monthsParse[n].test(e))return n}},Si.monthsRegex=function(e){return this._monthsParseExact?(h(this,"_monthsRegex")||Ie.call(this),e?this._monthsStrictRegex:this._monthsRegex):(h(this,"_monthsRegex")||(this._monthsRegex=Te),this._monthsStrictRegex&&e?this._monthsStrictRegex:this._monthsRegex)},Si.monthsShortRegex=function(e){return this._monthsParseExact?(h(this,"_monthsRegex")||Ie.call(this),e?this._monthsShortStrictRegex:this._monthsShortRegex):(h(this,"_monthsShortRegex")||(this._monthsShortRegex=De),this._monthsShortStrictRegex&&e?this._monthsShortStrictRegex:this._monthsShortRegex)},Si.week=function(e){return Ye(e,this._week.dow,this._week.doy).week},Si.firstDayOfYear=function(){return this._week.doy},Si.firstDayOfWeek=function(){return this._week.dow},Si.weekdays=function(e,t){var i=o(this._weekdays)?this._weekdays:this._weekdays[e&&!0!==e&&this._weekdays.isFormat.test(t)?"format":"standalone"];return!0===e?Ve(i,this._week.dow):e?i[e.day()]:i},Si.weekdaysMin=function(e){return!0===e?Ve(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin},Si.weekdaysShort=function(e){return!0===e?Ve(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort},Si.weekdaysParse=function(e,t,i){var n,s,r;if(this._weekdaysParseExact)return Ke.call(this,e,t,i);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;n<7;n++){if(s=p([2e3,1]).day(n),i&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(s,"").replace(".","\\.?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(s,"").replace(".","\\.?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(s,"").replace(".","\\.?")+"$","i")),this._weekdaysParse[n]||(r="^"+this.weekdays(s,"")+"|^"+this.weekdaysShort(s,"")+"|^"+this.weekdaysMin(s,""),this._weekdaysParse[n]=new RegExp(r.replace(".",""),"i")),i&&"dddd"===t&&this._fullWeekdaysParse[n].test(e))return n;if(i&&"ddd"===t&&this._shortWeekdaysParse[n].test(e))return n;if(i&&"dd"===t&&this._minWeekdaysParse[n].test(e))return n;if(!i&&this._weekdaysParse[n].test(e))return n}},Si.weekdaysRegex=function(e){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Ze.call(this),e?this._weekdaysStrictRegex:this._weekdaysRegex):(h(this,"_weekdaysRegex")||(this._weekdaysRegex=ze),this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex)},Si.weekdaysShortRegex=function(e){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Ze.call(this),e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(h(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=$e),this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)},Si.weekdaysMinRegex=function(e){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Ze.call(this),e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(h(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=qe),this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)},Si.isPM=function(e){return"p"===(e+"").toLowerCase().charAt(0)},Si.meridiem=function(e,t,i){return e>11?i?"pm":"PM":i?"am":"AM"},lt("en",{eras:[{since:"0001-01-01",until:1/0,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-1/0,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10;return e+(1===K(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th")}}),a.lang=A("moment.lang is deprecated. Use moment.locale instead.",lt),a.langData=A("moment.langData is deprecated. Use moment.localeData instead.",ut);var Ri=Math.abs;function ki(e,t,i,n){var s=Wt(t,i);return e._milliseconds+=n*s._milliseconds,e._days+=n*s._days,e._months+=n*s._months,e._bubble()}function Ai(e){return e<0?Math.floor(e):Math.ceil(e)}function Li(e){return 4800*e/146097}function Di(e){return 146097*e/4800}function Ti(e){return function(){return this.as(e)}}var Mi=Ti("ms"),Oi=Ti("s"),Ci=Ti("m"),Ii=Ti("h"),xi=Ti("d"),Ni=Ti("w"),Pi=Ti("M"),Ui=Ti("Q"),Bi=Ti("y");function Fi(e){return function(){return this.isValid()?this._data[e]:NaN}}var Yi=Fi("milliseconds"),Gi=Fi("seconds"),Vi=Fi("minutes"),ji=Fi("hours"),Wi=Fi("days"),Hi=Fi("months"),zi=Fi("years");var $i=Math.round,qi={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function Ki(e,t,i,n,s){return s.relativeTime(t||1,!!i,e,n)}var Zi=Math.abs;function Xi(e){return(e>0)-(e<0)||+e}function Ji(){if(!this.isValid())return this.localeData().invalidDate();var e,t,i,n,s,r,a,o,l=Zi(this._milliseconds)/1e3,h=Zi(this._days),u=Zi(this._months),d=this.asSeconds();return d?(e=q(l/60),t=q(e/60),l%=60,e%=60,i=q(u/12),u%=12,n=l?l.toFixed(3).replace(/\.?0+$/,""):"",s=d<0?"-":"",r=Xi(this._months)!==Xi(d)?"-":"",a=Xi(this._days)!==Xi(d)?"-":"",o=Xi(this._milliseconds)!==Xi(d)?"-":"",s+"P"+(i?r+i+"Y":"")+(u?r+u+"M":"")+(h?a+h+"D":"")+(t||e||l?"T":"")+(t?o+t+"H":"")+(e?o+e+"M":"")+(l?o+n+"S":"")):"P0D"}var Qi=It.prototype;Qi.isValid=function(){return this._isValid},Qi.abs=function(){var e=this._data;return this._milliseconds=Ri(this._milliseconds),this._days=Ri(this._days),this._months=Ri(this._months),e.milliseconds=Ri(e.milliseconds),e.seconds=Ri(e.seconds),e.minutes=Ri(e.minutes),e.hours=Ri(e.hours),e.months=Ri(e.months),e.years=Ri(e.years),this},Qi.add=function(e,t){return ki(this,e,t,1)},Qi.subtract=function(e,t){return ki(this,e,t,-1)},Qi.as=function(e){if(!this.isValid())return NaN;var t,i,n=this._milliseconds;if("month"===(e=j(e))||"quarter"===e||"year"===e)switch(t=this._days+n/864e5,i=this._months+Li(t),e){case"month":return i;case"quarter":return i/3;case"year":return i/12}else switch(t=this._days+Math.round(Di(this._months)),e){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return 24*t+n/36e5;case"minute":return 1440*t+n/6e4;case"second":return 86400*t+n/1e3;case"millisecond":return Math.floor(864e5*t)+n;default:throw new Error("Unknown unit "+e)}},Qi.asMilliseconds=Mi,Qi.asSeconds=Oi,Qi.asMinutes=Ci,Qi.asHours=Ii,Qi.asDays=xi,Qi.asWeeks=Ni,Qi.asMonths=Pi,Qi.asQuarters=Ui,Qi.asYears=Bi,Qi.valueOf=function(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*K(this._months/12):NaN},Qi._bubble=function(){var e,t,i,n,s,r=this._milliseconds,a=this._days,o=this._months,l=this._data;return r>=0&&a>=0&&o>=0||r<=0&&a<=0&&o<=0||(r+=864e5*Ai(Di(o)+a),a=0,o=0),l.milliseconds=r%1e3,e=q(r/1e3),l.seconds=e%60,t=q(e/60),l.minutes=t%60,i=q(t/60),l.hours=i%24,a+=q(i/24),o+=s=q(Li(a)),a-=Ai(Di(s)),n=q(o/12),o%=12,l.days=a,l.months=o,l.years=n,this},Qi.clone=function(){return Wt(this)},Qi.get=function(e){return e=j(e),this.isValid()?this[e+"s"]():NaN},Qi.milliseconds=Yi,Qi.seconds=Gi,Qi.minutes=Vi,Qi.hours=ji,Qi.days=Wi,Qi.weeks=function(){return q(this.days()/7)},Qi.months=Hi,Qi.years=zi,Qi.humanize=function(e,t){if(!this.isValid())return this.localeData().invalidDate();var i,n,s=!1,a=qi;return"object"===r(e)&&(t=e,e=!1),"boolean"==typeof e&&(s=e),"object"===r(t)&&(a=Object.assign({},qi,t),null!=t.s&&null==t.ss&&(a.ss=t.s-1)),n=function(e,t,i,n){var s=Wt(e).abs(),r=$i(s.as("s")),a=$i(s.as("m")),o=$i(s.as("h")),l=$i(s.as("d")),h=$i(s.as("M")),u=$i(s.as("w")),d=$i(s.as("y")),c=r<=i.ss&&["s",r]||r<i.s&&["ss",r]||a<=1&&["m"]||a<i.m&&["mm",a]||o<=1&&["h"]||o<i.h&&["hh",o]||l<=1&&["d"]||l<i.d&&["dd",l];return null!=i.w&&(c=c||u<=1&&["w"]||u<i.w&&["ww",u]),(c=c||h<=1&&["M"]||h<i.M&&["MM",h]||d<=1&&["y"]||["yy",d])[2]=t,c[3]=+e>0,c[4]=n,Ki.apply(null,c)}(this,!s,a,i=this.localeData()),s&&(n=i.pastFuture(+this,n)),i.postformat(n)},Qi.toISOString=Ji,Qi.toString=Ji,Qi.toJSON=Ji,Qi.locale=ti,Qi.localeData=ni,Qi.toIsoString=A("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Ji),Qi.lang=ii,B("X",0,0,"unix"),B("x",0,0,"valueOf"),pe("x",ce),pe("X",/[+-]?\d+(\.\d{1,3})?/),Se("X",(function(e,t,i){i._d=new Date(1e3*parseFloat(e))})),Se("x",(function(e,t,i){i._d=new Date(K(e))})),//! moment.js | |
8 | +a.version="2.29.1",n=Dt,a.fn=yi,a.min=function(){var e=[].slice.call(arguments,0);return Ot("isBefore",e)},a.max=function(){var e=[].slice.call(arguments,0);return Ot("isAfter",e)},a.now=function(){return Date.now?Date.now():+new Date},a.utc=p,a.unix=function(e){return Dt(1e3*e)},a.months=function(e,t){return bi(e,t,"months")},a.isDate=_,a.locale=lt,a.invalid=v,a.duration=Wt,a.isMoment=R,a.weekdays=function(e,t,i){return wi(e,t,i,"weekdays")},a.parseZone=function(){return Dt.apply(null,arguments).parseZone()},a.localeData=ut,a.isDuration=xt,a.monthsShort=function(e,t){return bi(e,t,"monthsShort")},a.weekdaysMin=function(e,t,i){return wi(e,t,i,"weekdaysMin")},a.defineLocale=ht,a.updateLocale=function(e,t){if(null!=t){var i,n,s=it;null!=nt[e]&&null!=nt[e].parentLocale?nt[e].set(O(nt[e]._config,t)):(null!=(n=ot(e))&&(s=n._config),t=O(s,t),null==n&&(t.abbr=e),(i=new C(t)).parentLocale=nt[e],nt[e]=i),lt(e)}else null!=nt[e]&&(null!=nt[e].parentLocale?(nt[e]=nt[e].parentLocale,e===lt()&<(e)):null!=nt[e]&&delete nt[e]);return nt[e]},a.locales=function(){return L(nt)},a.weekdaysShort=function(e,t,i){return wi(e,t,i,"weekdaysShort")},a.normalizeUnits=j,a.relativeTimeRounding=function(e){return void 0===e?$i:"function"==typeof e&&($i=e,!0)},a.relativeTimeThreshold=function(e,t){return void 0!==qi[e]&&(void 0===t?qi[e]:(qi[e]=t,"s"===e&&(qi.ss=t-1),!0))},a.calendarFormat=function(e,t){var i=e.diff(t,"days",!0);return i<-6?"sameElse":i<-1?"lastWeek":i<0?"lastDay":i<1?"sameDay":i<2?"nextDay":i<7?"nextWeek":"sameElse"},a.prototype=yi,a.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},t.a=a}).call(this,i(14)(e))},function(e,t,i){"use strict";var n=i(3),s=i.n(n)()((function(e){return e[1]}));s.push([e.i,".flvWai,.flvWai>.videoFlv{\r\n width: 100%; \r\n height: 100%; \r\n}\r\n.flvWai>.videoFlv:hover{\r\n outline: none;\r\n}",""]),t.a=s},function(e,t,i){"use strict";var n=i(3),s=i.n(n)()((function(e){return e[1]}));s.push([e.i,'.timerComCss{\r\n font-family: "fontInit";\r\n color: rgb(47, 233, 242);\r\n font-size: 20px;\r\n letter-spacing: 2px;\r\n}',""]),t.a=s},function(e,t,i){"use strict";i.r(t);var n=i(4); | |
9 | +//! moment.js locale configuration | |
10 | +//! locale : Chinese (China) [zh-cn] | |
11 | +//! author : suupic : https://github.com/suupic | |
12 | +//! author : Zeno Zeng : https://github.com/zenozeng | |
13 | +//! author : uu109 : https://github.com/uu109 | |
14 | +t.default=n.a.defineLocale("zh-cn",{months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),longDateFormat:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},meridiemParse:/凌晨|早上|上午|中午|下午|晚上/,meridiemHour:function(e,t){return 12===e&&(e=0),"凌晨"===t||"早上"===t||"上午"===t?e:"下午"===t||"晚上"===t?e+12:e>=11?e:e+12},meridiem:function(e,t,i){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1130?"上午":n<1230?"中午":n<1800?"下午":"晚上"},calendar:{sameDay:"[今天]LT",nextDay:"[明天]LT",nextWeek:function(e){return e.week()!==this.week()?"[下]dddLT":"[本]dddLT"},lastDay:"[昨天]LT",lastWeek:function(e){return this.week()!==e.week()?"[上]dddLT":"[本]dddLT"},sameElse:"L"},dayOfMonthOrdinalParse:/\d{1,2}(日|月|周)/,ordinal:function(e,t){switch(t){case"d":case"D":case"DDD":return e+"日";case"M":return e+"月";case"w":case"W":return e+"周";default:return e}},relativeTime:{future:"%s后",past:"%s前",s:"几秒",ss:"%d 秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",w:"1 周",ww:"%d 周",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},week:{dow:1,doy:4}})},function(e,t,i){"use strict"; | |
15 | +/** @license React v17.0.1 | |
16 | + * react.production.min.js | |
17 | + * | |
18 | + * Copyright (c) Facebook, Inc. and its affiliates. | |
19 | + * | |
20 | + * This source code is licensed under the MIT license found in the | |
21 | + * LICENSE file in the root directory of this source tree. | |
22 | + */var n=i(9),s=60103,r=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var a=60109,o=60110,l=60112;t.Suspense=60113;var h=60115,u=60116;if("function"==typeof Symbol&&Symbol.for){var d=Symbol.for;s=d("react.element"),r=d("react.portal"),t.Fragment=d("react.fragment"),t.StrictMode=d("react.strict_mode"),t.Profiler=d("react.profiler"),a=d("react.provider"),o=d("react.context"),l=d("react.forward_ref"),t.Suspense=d("react.suspense"),h=d("react.memo"),u=d("react.lazy")}var c="function"==typeof Symbol&&Symbol.iterator;function _(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m={};function p(e,t,i){this.props=e,this.context=t,this.refs=m,this.updater=i||f}function g(){}function y(e,t,i){this.props=e,this.context=t,this.refs=m,this.updater=i||f}p.prototype.isReactComponent={},p.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(_(85));this.updater.enqueueSetState(this,e,t,"setState")},p.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},g.prototype=p.prototype;var v=y.prototype=new g;v.constructor=y,n(v,p.prototype),v.isPureReactComponent=!0;var S={current:null},E=Object.prototype.hasOwnProperty,b={key:!0,ref:!0,__self:!0,__source:!0};function w(e,t,i){var n,r={},a=null,o=null;if(null!=t)for(n in void 0!==t.ref&&(o=t.ref),void 0!==t.key&&(a=""+t.key),t)E.call(t,n)&&!b.hasOwnProperty(n)&&(r[n]=t[n]);var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){for(var h=Array(l),u=0;u<l;u++)h[u]=arguments[u+2];r.children=h}if(e&&e.defaultProps)for(n in l=e.defaultProps)void 0===r[n]&&(r[n]=l[n]);return{$$typeof:s,type:e,key:a,ref:o,props:r,_owner:S.current}}function R(e){return"object"==typeof e&&null!==e&&e.$$typeof===s}var k=/\/+/g;function A(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function L(e,t,i,n,a){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l=!1;if(null===e)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case s:case r:l=!0}}if(l)return a=a(l=e),e=""===n?"."+A(l,0):n,Array.isArray(a)?(i="",null!=e&&(i=e.replace(k,"$&/")+"/"),L(a,t,i,"",(function(e){return e}))):null!=a&&(R(a)&&(a=function(e,t){return{$$typeof:s,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(a,i+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(k,"$&/")+"/")+e)),t.push(a)),1;if(l=0,n=""===n?".":n+":",Array.isArray(e))for(var h=0;h<e.length;h++){var u=n+A(o=e[h],h);l+=L(o,t,i,u,a)}else if("function"==typeof(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=c&&e[c]||e["@@iterator"])?e:null}(e)))for(e=u.call(e),h=0;!(o=e.next()).done;)l+=L(o=o.value,t,i,u=n+A(o,h++),a);else if("object"===o)throw t=""+e,Error(_(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return l}function D(e,t,i){if(null==e)return e;var n=[],s=0;return L(e,n,"","",(function(e){return t.call(i,e,s++)})),n}function T(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var M={current:null};function O(){var e=M.current;if(null===e)throw Error(_(321));return e}var C={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:S,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:D,forEach:function(e,t,i){D(e,(function(){t.apply(this,arguments)}),i)},count:function(e){var t=0;return D(e,(function(){t++})),t},toArray:function(e){return D(e,(function(e){return e}))||[]},only:function(e){if(!R(e))throw Error(_(143));return e}},t.Component=p,t.PureComponent=y,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=C,t.cloneElement=function(e,t,i){if(null==e)throw Error(_(267,e));var r=n({},e.props),a=e.key,o=e.ref,l=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,l=S.current),void 0!==t.key&&(a=""+t.key),e.type&&e.type.defaultProps)var h=e.type.defaultProps;for(u in t)E.call(t,u)&&!b.hasOwnProperty(u)&&(r[u]=void 0===t[u]&&void 0!==h?h[u]:t[u])}var u=arguments.length-2;if(1===u)r.children=i;else if(1<u){h=Array(u);for(var d=0;d<u;d++)h[d]=arguments[d+2];r.children=h}return{$$typeof:s,type:e.type,key:a,ref:o,props:r,_owner:l}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:o,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=w,t.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=R,t.lazy=function(e){return{$$typeof:u,_payload:{_status:-1,_result:e},_init:T}},t.memo=function(e,t){return{$$typeof:h,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return O().useCallback(e,t)},t.useContext=function(e,t){return O().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return O().useEffect(e,t)},t.useImperativeHandle=function(e,t,i){return O().useImperativeHandle(e,t,i)},t.useLayoutEffect=function(e,t){return O().useLayoutEffect(e,t)},t.useMemo=function(e,t){return O().useMemo(e,t)},t.useReducer=function(e,t,i){return O().useReducer(e,t,i)},t.useRef=function(e){return O().useRef(e)},t.useState=function(e){return O().useState(e)},t.version="17.0.1"},function(e,t,i){"use strict"; | |
23 | +/* | |
24 | +object-assign | |
25 | +(c) Sindre Sorhus | |
26 | +@license MIT | |
27 | +*/var n=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},i=0;i<10;i++)t["_"+String.fromCharCode(i)]=i;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var i,o,l=a(e),h=1;h<arguments.length;h++){for(var u in i=Object(arguments[h]))s.call(i,u)&&(l[u]=i[u]);if(n){o=n(i);for(var d=0;d<o.length;d++)r.call(i,o[d])&&(l[o[d]]=i[o[d]])}}return l}},function(e,t,i){(function(t,i){ | |
28 | +/*! | |
29 | + * @overview es6-promise - a tiny implementation of Promises/A+. | |
30 | + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) | |
31 | + * @license Licensed under MIT license | |
32 | + * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE | |
33 | + * @version v4.2.8+1e68dce6 | |
34 | + */var n;n=function(){"use strict";function e(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=0,r=void 0,a=void 0,o=function(e,t){f[s]=e,f[s+1]=t,2===(s+=2)&&(a?a(m):S())},l="undefined"!=typeof window?window:void 0,h=l||{},u=h.MutationObserver||h.WebKitMutationObserver,d="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),c="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function _(){var e=setTimeout;return function(){return e(m,1)}}var f=new Array(1e3);function m(){for(var e=0;e<s;e+=2)(0,f[e])(f[e+1]),f[e]=void 0,f[e+1]=void 0;s=0}var p,g,y,v,S=void 0;function E(e,t){var i=this,n=new this.constructor(R);void 0===n[w]&&x(n);var s=i._state;if(s){var r=arguments[s-1];o((function(){return C(s,n,r,i._result)}))}else M(i,n,e,t);return n}function b(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(R);return A(t,e),t}d?S=function(){return t.nextTick(m)}:u?(g=0,y=new u(m),v=document.createTextNode(""),y.observe(v,{characterData:!0}),S=function(){v.data=g=++g%2}):c?((p=new MessageChannel).port1.onmessage=m,S=function(){return p.port2.postMessage(0)}):S=void 0===l?function(){try{var e=Function("return this")().require("vertx");return void 0!==(r=e.runOnLoop||e.runOnContext)?function(){r(m)}:_()}catch(e){return _()}}():_();var w=Math.random().toString(36).substring(2);function R(){}function k(t,i,n){i.constructor===t.constructor&&n===E&&i.constructor.resolve===b?function(e,t){1===t._state?D(e,t._result):2===t._state?T(e,t._result):M(t,void 0,(function(t){return A(e,t)}),(function(t){return T(e,t)}))}(t,i):void 0===n?D(t,i):e(n)?function(e,t,i){o((function(e){var n=!1,s=function(e,t,i,n){try{e.call(t,i,n)}catch(e){return e}}(i,t,(function(i){n||(n=!0,t!==i?A(e,i):D(e,i))}),(function(t){n||(n=!0,T(e,t))}),e._label);!n&&s&&(n=!0,T(e,s))}),e)}(t,i,n):D(t,i)}function A(e,t){if(e===t)T(e,new TypeError("You cannot resolve a promise with itself"));else if(s=typeof(n=t),null===n||"object"!==s&&"function"!==s)D(e,t);else{var i=void 0;try{i=t.then}catch(t){return void T(e,t)}k(e,t,i)}var n,s}function L(e){e._onerror&&e._onerror(e._result),O(e)}function D(e,t){void 0===e._state&&(e._result=t,e._state=1,0!==e._subscribers.length&&o(O,e))}function T(e,t){void 0===e._state&&(e._state=2,e._result=t,o(L,e))}function M(e,t,i,n){var s=e._subscribers,r=s.length;e._onerror=null,s[r]=t,s[r+1]=i,s[r+2]=n,0===r&&e._state&&o(O,e)}function O(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var n=void 0,s=void 0,r=e._result,a=0;a<t.length;a+=3)n=t[a],s=t[a+i],n?C(i,n,s,r):s(r);e._subscribers.length=0}}function C(t,i,n,s){var r=e(n),a=void 0,o=void 0,l=!0;if(r){try{a=n(s)}catch(e){l=!1,o=e}if(i===a)return void T(i,new TypeError("A promises callback cannot return that same promise."))}else a=s;void 0!==i._state||(r&&l?A(i,a):!1===l?T(i,o):1===t?D(i,a):2===t&&T(i,a))}var I=0;function x(e){e[w]=I++,e._state=void 0,e._result=void 0,e._subscribers=[]}var N=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(R),this.promise[w]||x(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?D(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&D(this.promise,this._result))):T(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;void 0===this._state&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,n=i.resolve;if(n===b){var s=void 0,r=void 0,a=!1;try{s=e.then}catch(e){a=!0,r=e}if(s===E&&void 0!==e._state)this._settledAt(e._state,t,e._result);else if("function"!=typeof s)this._remaining--,this._result[t]=e;else if(i===P){var o=new i(R);a?T(o,r):k(o,e,s),this._willSettleAt(o,t)}else this._willSettleAt(new i((function(t){return t(e)})),t)}else this._willSettleAt(n(e),t)},e.prototype._settledAt=function(e,t,i){var n=this.promise;void 0===n._state&&(this._remaining--,2===e?T(n,i):this._result[t]=i),0===this._remaining&&D(n,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;M(e,void 0,(function(e){return i._settledAt(1,t,e)}),(function(e){return i._settledAt(2,t,e)}))},e}(),P=function(){function t(e){this[w]=I++,this._result=this._state=void 0,this._subscribers=[],R!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(e,t){try{t((function(t){A(e,t)}),(function(t){T(e,t)}))}catch(t){T(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var i=this.constructor;return e(t)?this.then((function(e){return i.resolve(t()).then((function(){return e}))}),(function(e){return i.resolve(t()).then((function(){throw e}))})):this.then(t,t)},t}();return P.prototype.then=E,P.all=function(e){return new N(this,e).promise},P.race=function(e){var t=this;return n(e)?new t((function(i,n){for(var s=e.length,r=0;r<s;r++)t.resolve(e[r]).then(i,n)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))},P.resolve=b,P.reject=function(e){var t=new this(R);return T(t,e),t},P._setScheduler=function(e){a=e},P._setAsap=function(e){o=e},P._asap=o,P.polyfill=function(){var e=void 0;if(void 0!==i)e=i;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=P},P.Promise=P,P},e.exports=n()}).call(this,i(11),i(12))},function(e,t){var i,n,s=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(e){if(i===setTimeout)return setTimeout(e,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(e){i=r}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var l,h=[],u=!1,d=-1;function c(){u&&l&&(u=!1,l.length?h=l.concat(h):d=-1,h.length&&_())}function _(){if(!u){var e=o(c);u=!0;for(var t=h.length;t;){for(l=h,h=[];++d<t;)l&&l[d].run();d=-1,t=h.length}l=null,u=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function m(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];h.push(new f(e,t)),1!==h.length||u||o(_)},f.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){var i=arguments[3],n=arguments[4],s=arguments[5],r=JSON.stringify;e.exports=function(e,t){for(var a,o=Object.keys(s),l=0,h=o.length;l<h;l++){var u=o[l],d=s[u].exports;if(d===e||d&&d.default===e){a=u;break}}if(!a){a=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var c={};for(l=0,h=o.length;l<h;l++){c[u=o[l]]=u}n[a]=["function(require,module,exports){"+e+"(self); }",c]}var _=Math.floor(Math.pow(16,8)*Math.random()).toString(16),f={};f[a]=a,n[_]=["function(require,module,exports){var f = require("+r(a)+");(f.default ? f.default : f)(self);}",f];var m={};!function e(t){for(var i in m[t]=!0,n[t][1]){var s=n[t][1][i];m[s]||e(s)}}(_);var p="("+i+")({"+Object.keys(m).map((function(e){return r(e)+":["+n[e][0]+","+r(n[e][1])+"]"})).join(",")+"},{},["+r(_)+"])",g=window.URL||window.webkitURL||window.mozURL||window.msURL,y=new Blob([p],{type:"text/javascript"});if(t&&t.bare)return y;var v=g.createObjectURL(y),S=new Worker(v);return S.objectURL=v,S}},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},function(e,t,i){var n={"./zh-cn":7,"./zh-cn.js":7};function s(e){var t=r(e);return i(t)}function r(e){if(!i.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}s.keys=function(){return Object.keys(n)},s.resolve=r,e.exports=s,s.id=15},function(e,t,i){"use strict";i.r(t),i.d(t,"FlvCom",(function(){return we})),i.d(t,"Timer",(function(){return Ie}));var n=i(1),s=i.n(n);class r{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");let t=Object(e);for(let e=1;e<arguments.length;e++){let i=arguments[e];if(null!=i)for(let e in i)i.hasOwnProperty(e)&&(t[e]=i[e])}return t},"function"!=typeof self.Promise&&i(10).polyfill()}}r.install();var a=r,o=i(0),l=i.n(o);class h{static e(e,t){e&&!h.FORCE_GLOBAL_TAG||(e=h.GLOBAL_TAG);let i=`[${e}] > ${t}`;h.ENABLE_CALLBACK&&h.emitter.emit("log","error",i),h.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}static i(e,t){e&&!h.FORCE_GLOBAL_TAG||(e=h.GLOBAL_TAG);let i=`[${e}] > ${t}`;h.ENABLE_CALLBACK&&h.emitter.emit("log","info",i),h.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}static w(e,t){e&&!h.FORCE_GLOBAL_TAG||(e=h.GLOBAL_TAG);let i=`[${e}] > ${t}`;h.ENABLE_CALLBACK&&h.emitter.emit("log","warn",i),h.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}static d(e,t){e&&!h.FORCE_GLOBAL_TAG||(e=h.GLOBAL_TAG);let i=`[${e}] > ${t}`;h.ENABLE_CALLBACK&&h.emitter.emit("log","debug",i),h.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}static v(e,t){e&&!h.FORCE_GLOBAL_TAG||(e=h.GLOBAL_TAG);let i=`[${e}] > ${t}`;h.ENABLE_CALLBACK&&h.emitter.emit("log","verbose",i),h.ENABLE_VERBOSE&&console.log(i)}}h.GLOBAL_TAG="flv.js",h.FORCE_GLOBAL_TAG=!1,h.ENABLE_ERROR=!0,h.ENABLE_INFO=!0,h.ENABLE_WARN=!0,h.ENABLE_DEBUG=!0,h.ENABLE_VERBOSE=!0,h.ENABLE_CALLBACK=!1,h.emitter=new l.a;var u=h;var d=class{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}};class c{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class _ extends c{constructor(e){super(e)}get name(){return"IllegalStateException"}}class f extends c{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends c{constructor(e){super(e)}get name(){return"NotImplementedException"}}const p={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},g={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class y{constructor(e){this._type=e||"undefined",this._status=p.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=p.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===p.kConnecting||this._status===p.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(e,t){throw new m("Unimplemented abstract function!")}abort(){throw new m("Unimplemented abstract function!")}}let v={};!function(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],n={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},s={};if(n.browser){s[n.browser]=!0;let e=n.majorVersion.split(".");s.version={major:parseInt(n.majorVersion,10),string:n.version},e.length>1&&(s.version.minor=parseInt(e[1],10)),e.length>2&&(s.version.build=parseInt(e[2],10))}if(n.platform&&(s[n.platform]=!0),(s.chrome||s.opr||s.safari)&&(s.webkit=!0),s.rv||s.iemobile){s.rv&&delete s.rv;let e="msie";n.browser=e,s[e]=!0}if(s.edge){delete s.edge;let e="msedge";n.browser=e,s[e]=!0}if(s.opr){let e="opera";n.browser=e,s[e]=!0}if(s.safari&&s.android){let e="android";n.browser=e,s[e]=!0}s.name=n.browser,s.platform=n.platform;for(let e in v)v.hasOwnProperty(e)&&delete v[e];Object.assign(v,s)}();var S=v;var E=class extends y{static isSupported(){try{let e=S.msedge&&S.version.minor>=15048,t=!S.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let i=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(i=e.redirectedURL);let n=this._seekHandler.getConfig(i,t),s=new self.Headers;if("object"==typeof n.headers){let e=n.headers;for(let t in e)e.hasOwnProperty(t)&&s.append(t,e[t])}let r={method:"GET",headers:s,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(let e in this._config.headers)s.append(e,this._config.headers[e]);!1===e.cors&&(r.mode="same-origin"),e.withCredentials&&(r.credentials="include"),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),this._status=p.kConnecting,self.fetch(n.url,r).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=p.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==n.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=p.kError,!this._onError)throw new c("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=p.kError,!this._onError)throw e;this._onError(g.EXCEPTION,{code:-1,msg:e.message})})}abort(){this._requestAbort=!0}_pump(e){return e.read().then(t=>{if(t.done)if(null!==this._contentLength&&this._receivedLength<this._contentLength){this._status=p.kError;let e=g.EARLY_EOF,t={code:-1,msg:"Fetch stream meet Early-EOF"};if(!this._onError)throw new c(t.msg);this._onError(e,t)}else this._status=p.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1);else{if(!0===this._requestAbort)return this._requestAbort=!1,this._status=p.kComplete,e.cancel();this._status=p.kBuffering;let i=t.value.buffer,n=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength,this._onDataArrival&&this._onDataArrival(i,n,this._receivedLength),this._pump(e)}}).catch(e=>{if(11===e.code&&S.msedge)return;this._status=p.kError;let t=0,i=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength<this._contentLength)?(t=g.EXCEPTION,i={code:e.code,msg:e.message}):(t=g.EARLY_EOF,i={code:e.code,msg:"Fetch stream meet Early-EOF"}),!this._onError)throw new c(i.msg);this._onError(t,i)})}};var b=class extends y{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return u.w("MozChunkedLoader",e.message),!1}}constructor(e,t){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let i=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(i=e.redirectedURL);let n=this._seekHandler.getConfig(i,t);this._requestURL=n.url;let s=this._xhr=new XMLHttpRequest;if(s.open("GET",n.url,!0),s.responseType="moz-chunked-arraybuffer",s.onreadystatechange=this._onReadyStateChange.bind(this),s.onprogress=this._onProgress.bind(this),s.onloadend=this._onLoadEnd.bind(this),s.onerror=this._onXhrError.bind(this),e.withCredentials&&(s.withCredentials=!0),"object"==typeof n.headers){let e=n.headers;for(let t in e)e.hasOwnProperty(t)&&s.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&s.setRequestHeader(t,e[t])}this._status=p.kConnecting,s.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=p.kComplete}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){let e=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(e)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=p.kError,!this._onError)throw new c("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=p.kBuffering}}_onProgress(e){if(this._status===p.kError)return;null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==p.kError&&(this._status=p.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=p.kError;let t=0,i=null;if(this._contentLength&&e.loaded<this._contentLength?(t=g.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=g.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new c(i.msg);this._onError(t,i)}};var w=class extends y{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return u.w("RangeLoader",e.message),!1}}constructor(e,t){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=e,this._config=t,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new d,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(e,t){this._dataSource=e,this._range=t,this._status=p.kConnecting;let i=!1;null!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(i=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||i?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}_openSubRange(){let e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,i=t+e;null!=this._contentLength&&i-this._range.from>=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let i=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?i=this._currentRedirectedURL:null!=e.redirectedURL&&(i=e.redirectedURL));let n=this._seekHandler.getConfig(i,t);this._currentRequestURL=n.url;let s=this._xhr=new XMLHttpRequest;if(s.open("GET",n.url,!0),s.responseType="arraybuffer",s.onreadystatechange=this._onReadyStateChange.bind(this),s.onprogress=this._onProgress.bind(this),s.onload=this._onLoad.bind(this),s.onerror=this._onXhrError.bind(this),e.withCredentials&&(s.withCredentials=!0),"object"==typeof n.headers){let e=n.headers;for(let t in e)e.hasOwnProperty(t)&&s.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&s.setRequestHeader(t,e[t])}s.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=p.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(null!=t.responseURL){let e=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&e!==this._currentRedirectedURL&&(this._currentRedirectedURL=e,this._onURLRedirect&&this._onURLRedirect(e))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=p.kBuffering}else{if(this._status=p.kError,!this._onError)throw new c("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===p.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let t=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(t)}_normalizeSpeed(e){let t=this._chunkSizeKBList,i=t.length-1,n=0,s=0,r=i;if(e<t[0])return t[0];for(;s<=r;){if(n=s+Math.floor((r-s)/2),n===i||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?s=n+1:r=n-1}}_onLoad(e){if(this._status===p.kError)return;if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;let t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let i=e.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;let s=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():s=!0,this._onDataArrival&&this._onDataArrival(i,n,this._receivedLength),s&&(this._status=p.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(e){this._status=p.kError;let t=0,i=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=g.EARLY_EOF,i={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=g.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new c(i.msg);this._onError(t,i)}};var R=class extends y{static isSupported(){try{return void 0!==self.WebSocket}catch(e){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(e){try{let t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=p.kConnecting}catch(e){this._status=p.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new c(t.msg);this._onError(g.EXCEPTION,t)}}abort(){let e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=p.kComplete}_onWebSocketOpen(e){this._status=p.kBuffering}_onWebSocketClose(e){!0!==this._requestAbort?(this._status=p.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1}_onWebSocketMessage(e){if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){let t=new FileReader;t.onload=()=>{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=p.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new c(t.msg);this._onError(g.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onWebSocketError(e){this._status=p.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new c(t.msg);this._onError(g.EXCEPTION,t)}};var k=class{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let i={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,i.Range=e}else this._zeroStart&&(i.Range="bytes=0-");return{url:e,headers:i}}removeURLParameters(e){return e}};var A=class{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let i=e;if(0!==t.from||-1!==t.to){let e=!0;-1===i.indexOf("?")&&(i+="?",e=!1),e&&(i+="&"),i+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(i+=`&${this._endName}=${t.to.toString()}`)}return{url:i,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],i=void 0,n=e.indexOf("?");-1!==n&&(i=e.substring(n+1));let s="";if(null!=i&&i.length>0){let e=i.split("&");for(let t=0;t<e.length;t++){let i=e[t].split("="),n=t>0;i[0]!==this._startName&&i[0]!==this._endName&&(n&&(s+="&"),s+=e[t])}}return 0===s.length?t:t+"?"+s}};var L=class{constructor(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=393216,null!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new d,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===w?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new k(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new A(t,i)}else{if("custom"!==e.seekType)throw new f("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new f("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=R;else if(E.isSupported())this._loaderClass=E;else if(b.isSupported())this._loaderClass=b;else{if(!w.isSupported())throw new c("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=w}}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new f("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+1048576<e;)t*=2;if(t+=1048576,t===this._bufferSize)return;let i=new ArrayBuffer(t);if(this._stashUsed>0){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(i,0,t).set(e,0)}this._stashBuffer=i,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,i=t.length-1,n=0,s=0,r=i;if(e<t[0])return t[0];for(;s<=r;){if(n=s+Math.floor((r-s)/2),n===i||e>=t[n]&&e<t[n+1])return t[n];t[n]<e?s=n+1:r=n-1}}_adjustStashSize(e){let t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let i=1024*t+1048576;this._bufferSize<i&&this._expandBuffer(i),this._stashSize=1024*t}_dispatchChunks(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}_onURLRedirect(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)}_onContentLengthKnown(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)}_onLoaderChunkArrival(e,t,i){if(!this._onDataArrival)throw new _("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);let n=this._speedSampler.lastSecondKBps;if(0!==n){let e=this._normalizeSpeed(n);this._speedNormalized!==e&&(this._speedNormalized=e,this._adjustStashSize(e))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){new Uint8Array(this._stashBuffer,0,this._stashSize).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let i=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart);if(n<t.byteLength){if(n>0){let e=new Uint8Array(t,n);i.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=n}}else this._stashUsed=0,this._stashByteStart+=n;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let n=this._dispatchChunks(e,t);if(n<e.byteLength){let s=e.byteLength-n;s>this._bufferSize&&(this._expandBuffer(s),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e,n),0),this._stashUsed+=s,this._stashByteStart=t+n}}}else if(0===this._stashUsed){let i=this._dispatchChunks(e,t);if(i<e.byteLength){let n=e.byteLength-i;n>this._bufferSize&&this._expandBuffer(n),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(e,i),0),this._stashUsed+=n,this._stashByteStart=t+i}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let i=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(i<this._stashUsed&&i>0){let e=new Uint8Array(this._stashBuffer,i);t.set(e,0)}this._stashUsed-=i,this._stashByteStart+=i}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),n=t.byteLength-i;if(i<t.byteLength){if(!e){if(i>0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),n=new Uint8Array(t,i);e.set(n,0),this._stashUsed=n.byteLength,this._stashByteStart+=i}return 0}u.w(this.TAG,n+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,n}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(u.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=g.UNRECOVERABLE_EARLY_EOF),e){case g.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e<this._totalLength&&(u.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(e,!1)))}e=g.UNRECOVERABLE_EARLY_EOF}if(!this._onError)throw new c("IOException: "+t.msg);this._onError(e,t)}};const D={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function T(){return Object.assign({},D)}class M{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let e=new L({},T()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t}static getNetworkLoaderTypeName(){let e=new L({},T()),t=e.loaderType;return e.destroy(),t}static supportNativeMediaPlayback(e){null==M.videoElement&&(M.videoElement=window.document.createElement("video"));let t=M.videoElement.canPlayType(e);return"probably"===t||"maybe"==t}static getFeatureList(){let e={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return e.mseFlvPlayback=M.supportMSEH264Playback(),e.networkStreamIO=M.supportNetworkStreamIO(),e.networkLoaderName=M.getNetworkLoaderTypeName(),e.mseLiveFlvPlayback=e.mseFlvPlayback&&e.networkStreamIO,e.nativeMP4H264Playback=M.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),e.nativeWebmVP8Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),e.nativeWebmVP9Playback=M.supportNativeMediaPlayback('video/webm; codecs="vp9"'),e}}var O=M;var C={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};class I{static get forceGlobalTag(){return u.FORCE_GLOBAL_TAG}static set forceGlobalTag(e){u.FORCE_GLOBAL_TAG=e,I._notifyChange()}static get globalTag(){return u.GLOBAL_TAG}static set globalTag(e){u.GLOBAL_TAG=e,I._notifyChange()}static get enableAll(){return u.ENABLE_VERBOSE&&u.ENABLE_DEBUG&&u.ENABLE_INFO&&u.ENABLE_WARN&&u.ENABLE_ERROR}static set enableAll(e){u.ENABLE_VERBOSE=e,u.ENABLE_DEBUG=e,u.ENABLE_INFO=e,u.ENABLE_WARN=e,u.ENABLE_ERROR=e,I._notifyChange()}static get enableDebug(){return u.ENABLE_DEBUG}static set enableDebug(e){u.ENABLE_DEBUG=e,I._notifyChange()}static get enableVerbose(){return u.ENABLE_VERBOSE}static set enableVerbose(e){u.ENABLE_VERBOSE=e,I._notifyChange()}static get enableInfo(){return u.ENABLE_INFO}static set enableInfo(e){u.ENABLE_INFO=e,I._notifyChange()}static get enableWarn(){return u.ENABLE_WARN}static set enableWarn(e){u.ENABLE_WARN=e,I._notifyChange()}static get enableError(){return u.ENABLE_ERROR}static set enableError(e){u.ENABLE_ERROR=e,I._notifyChange()}static getConfig(){return{globalTag:u.GLOBAL_TAG,forceGlobalTag:u.FORCE_GLOBAL_TAG,enableVerbose:u.ENABLE_VERBOSE,enableDebug:u.ENABLE_DEBUG,enableInfo:u.ENABLE_INFO,enableWarn:u.ENABLE_WARN,enableError:u.ENABLE_ERROR,enableCallback:u.ENABLE_CALLBACK}}static applyConfig(e){u.GLOBAL_TAG=e.globalTag,u.FORCE_GLOBAL_TAG=e.forceGlobalTag,u.ENABLE_VERBOSE=e.enableVerbose,u.ENABLE_DEBUG=e.enableDebug,u.ENABLE_INFO=e.enableInfo,u.ENABLE_WARN=e.enableWarn,u.ENABLE_ERROR=e.enableError,u.ENABLE_CALLBACK=e.enableCallback}static _notifyChange(){let e=I.emitter;if(e.listenerCount("change")>0){let t=I.getConfig();e.emit("change",t)}}static registerListener(e){I.emitter.addListener("change",e)}static removeListener(e){I.emitter.removeListener("change",e)}static addLogListener(e){u.emitter.addListener("log",e),u.emitter.listenerCount("log")>0&&(u.ENABLE_CALLBACK=!0,I._notifyChange())}static removeLogListener(e){u.emitter.removeListener("log",e),0===u.emitter.listenerCount("log")&&(u.ENABLE_CALLBACK=!1,I._notifyChange())}}I.emitter=new l.a;var x=I;var N=class{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}}_search(e,t){let i=0,n=e.length-1,s=0,r=0,a=n;for(t<e[0]&&(i=0,r=a+1);r<=a;){if(s=r+Math.floor((a-r)/2),s===n||t>=e[s]&&t<e[s+1]){i=s;break}e[s]<t?r=s+1:a=s-1}return i}};function P(e,t,i){let n=e;if(t+i<n.length){for(;i--;)if(128!=(192&n[++t]))return!1;return!0}return!1}var U=function(e){let t=[],i=e,n=0,s=e.length;for(;n<s;)if(i[n]<128)t.push(String.fromCharCode(i[n])),++n;else{if(i[n]<192);else if(i[n]<224){if(P(i,n,1)){let e=(31&i[n])<<6|63&i[n+1];if(e>=128){t.push(String.fromCharCode(65535&e)),n+=2;continue}}}else if(i[n]<240){if(P(i,n,2)){let e=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),n+=3;continue}}}else if(i[n]<248&&P(i,n,3)){let e=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),n+=4;continue}}t.push(String.fromCharCode(65533)),++n}return t.join("")};let B=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class F{static parseScriptData(e,t,i){let n={};try{let s=F.parseValue(e,t,i),r=F.parseValue(e,t+s.size,i-s.size);n[s.data]=r.data}catch(e){u.e("AMF",e.toString())}return n}static parseObject(e,t,i){if(i<3)throw new _("Data not enough when parse ScriptDataObject");let n=F.parseString(e,t,i),s=F.parseValue(e,t+n.size,i-n.size),r=s.objectEnd;return{data:{name:n.data,value:s.data},size:n.size+s.size,objectEnd:r}}static parseVariable(e,t,i){return F.parseObject(e,t,i)}static parseString(e,t,i){if(i<2)throw new _("Data not enough when parse String");let n,s=new DataView(e,t,i).getUint16(0,!B);return n=s>0?U(new Uint8Array(e,t+2,s)):"",{data:n,size:2+s}}static parseLongString(e,t,i){if(i<4)throw new _("Data not enough when parse LongString");let n,s=new DataView(e,t,i).getUint32(0,!B);return n=s>0?U(new Uint8Array(e,t+4,s)):"",{data:n,size:4+s}}static parseDate(e,t,i){if(i<10)throw new _("Data size invalid when parse Date");let n=new DataView(e,t,i),s=n.getFloat64(0,!B);return s+=60*n.getInt16(8,!B)*1e3,{data:new Date(s),size:10}}static parseValue(e,t,i){if(i<1)throw new _("Data not enough when parse Value");let n,s=new DataView(e,t,i),r=1,a=s.getUint8(0),o=!1;try{switch(a){case 0:n=s.getFloat64(1,!B),r+=8;break;case 1:n=!!s.getUint8(1),r+=1;break;case 2:{let s=F.parseString(e,t+1,i-1);n=s.data,r+=s.size;break}case 3:{n={};let a=0;for(9==(16777215&s.getUint32(i-4,!B))&&(a=3);r<i-4;){let s=F.parseObject(e,t+r,i-r-a);if(s.objectEnd)break;n[s.data.name]=s.data.value,r+=s.size}if(r<=i-3){9===(16777215&s.getUint32(r-1,!B))&&(r+=3)}break}case 8:{n={},r+=4;let a=0;for(9==(16777215&s.getUint32(i-4,!B))&&(a=3);r<i-8;){let s=F.parseVariable(e,t+r,i-r-a);if(s.objectEnd)break;n[s.data.name]=s.data.value,r+=s.size}if(r<=i-3){9===(16777215&s.getUint32(r-1,!B))&&(r+=3)}break}case 9:n=void 0,r=1,o=!0;break;case 10:{n=[];let a=s.getUint32(1,!B);r+=4;for(let s=0;s<a;s++){let s=F.parseValue(e,t+r,i-r);n.push(s.data),r+=s.size}break}case 11:{let s=F.parseDate(e,t+1,i-1);n=s.data,r+=s.size;break}case 12:{let s=F.parseString(e,t+1,i-1);n=s.data,r+=s.size;break}default:r=i,u.w("AMF","Unsupported AMF value type "+a)}}catch(e){u.e("AMF",e.toString())}return{data:n,size:r,objectEnd:o}}}var Y=F;var G=class{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)throw new _("ExpGolomb: _fillCurrentWord() but no bytes available");let t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32)throw new f("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let i=e-this._current_word_bits_left;this._fillCurrentWord();let n=Math.min(i,this._current_word_bits_left),s=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,t=t<<n|s,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(0!=(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}};class V{static _ebsp2rbsp(e){let t=e,i=t.byteLength,n=new Uint8Array(i),s=0;for(let e=0;e<i;e++)e>=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(n[s]=t[e],s++);return new Uint8Array(n.buffer,0,s)}static parseSPS(e){let t=V._ebsp2rbsp(e),i=new G(t);i.readByte();let n=i.readByte();i.readByte();let s=i.readByte();i.readUEG();let r=V.getProfileString(n),a=V.getLevelString(s),o=1,l=420,h=[0,420,422,444],u=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(o=i.readUEG(),3===o&&i.readBits(1),o<=3&&(l=h[o]),u=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==o?8:12;for(let t=0;t<e;t++)i.readBool()&&(t<6?V._skipScalingList(i,16):V._skipScalingList(i,64))}i.readUEG();let d=i.readUEG();if(0===d)i.readUEG();else if(1===d){i.readBits(1),i.readSEG(),i.readSEG();let e=i.readUEG();for(let t=0;t<e;t++)i.readSEG()}let c=i.readUEG();i.readBits(1);let _=i.readUEG(),f=i.readUEG(),m=i.readBits(1);0===m&&i.readBits(1),i.readBits(1);let p=0,g=0,y=0,v=0;i.readBool()&&(p=i.readUEG(),g=i.readUEG(),y=i.readUEG(),v=i.readUEG());let S=1,E=1,b=0,w=!0,R=0,k=0;if(i.readBool()){if(i.readBool()){let e=i.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],n=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(S=t[e-1],E=n[e-1]):255===e&&(S=i.readByte()<<8|i.readByte(),E=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){let e=i.readBits(32),t=i.readBits(32);w=i.readBool(),R=t,k=2*e,b=R/k}}let A=1;1===S&&1===E||(A=S/E);let L=0,D=0;if(0===o)L=1,D=2-m;else{L=3===o?1:2,D=(1===o?2:1)*(2-m)}let T=16*(_+1),M=16*(f+1)*(2-m);T-=(p+g)*L,M-=(y+v)*D;let O=Math.ceil(T*A);return i.destroy(),i=null,{profile_string:r,level_string:a,bit_depth:u,ref_frames:c,chroma_format:l,chroma_format_string:V.getChromaFormatString(l),frame_rate:{fixed:w,fps:b,fps_den:k,fps_num:R},sar_ratio:{width:S,height:E},codec_size:{width:T,height:M},present_size:{width:O,height:M}}}static _skipScalingList(e,t){let i=8,n=8,s=0;for(let r=0;r<t;r++)0!==n&&(s=e.readSEG(),n=(i+s+256)%256),i=0===n?i:n}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var j=V;var W={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};class H{constructor(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new N,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(e){let t=new Uint8Array(e),i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;let n=(4&t[4])>>>2!=0,s=0!=(1&t[4]),r=(a=t)[o=5]<<24|a[o+1]<<16|a[o+2]<<8|a[o+3];var a,o;return r<9?i:{match:!0,consumed:r,dataOffset:r,hasAudioTrack:n,hasVideoTrack:s}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new N}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new _("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let i=0,n=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;i=H.probe(e).dataOffset}if(this._firstParse){this._firstParse=!1,t+i!==this._dataOffset&&u.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==new DataView(e,i).getUint32(0,!n)&&u.w(this.TAG,"PrevTagSize0 !== 0 !!!"),i+=4}for(;i<e.byteLength;){this._dispatch=!0;let s=new DataView(e,i);if(i+11+4>e.byteLength)break;let r=s.getUint8(0),a=16777215&s.getUint32(0,!n);if(i+11+a+4>e.byteLength)break;if(8!==r&&9!==r&&18!==r){u.w(this.TAG,`Unsupported tag type ${r}, skipped`),i+=11+a+4;continue}let o=s.getUint8(4),l=s.getUint8(5),h=s.getUint8(6)|l<<8|o<<16|s.getUint8(7)<<24;0!==(16777215&s.getUint32(7,!n))&&u.w(this.TAG,"Meet tag which has StreamID != 0!");let d=i+11;switch(r){case 8:this._parseAudioData(e,d,a,h);break;case 9:this._parseVideoData(e,d,a,h,t+i);break;case 18:this._parseScriptData(e,d,a)}let c=s.getUint32(11+a,!n);c!==11+a&&u.w(this.TAG,"Invalid PrevTagSize "+c),i+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),i}_parseScriptData(e,t,i){let n=Y.parseScriptData(e,t,i);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!=typeof n.onMetaData)return void u.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&u.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"==typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"==typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"==typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"==typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"==typeof e.width&&(this._mediaInfo.width=e.width),"number"==typeof e.height&&(this._mediaInfo.height=e.height),"number"==typeof e.duration){if(!this._durationOverrided){let t=Math.floor(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}}else this._mediaInfo.duration=0;if("number"==typeof e.framerate){let t=Math.floor(1e3*e.framerate);if(t>0){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"==typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,u.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))}_parseKeyframesIndex(e){let t=[],i=[];for(let n=1;n<e.times.length;n++){let s=this._timestampBase+Math.floor(1e3*e.times[n]);t.push(s),i.push(e.filepositions[n])}return{times:t,filepositions:i}}_parseAudioData(e,t,i,n){if(i<=1)return void u.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0===this._hasAudioFlagOverrided&&!1===this._hasAudio)return;this._littleEndian;let s=new DataView(e,t,i).getUint8(0),r=s>>>4;if(2!==r&&10!==r)return void this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+r);let a=0,o=(12&s)>>>2;if(!(o>=0&&o<=4))return void this._onError(W.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+o);a=this._flvSoundRateTable[o];let l=1&s,h=this._audioMetadata,d=this._audioTrack;if(h||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),h=this._audioMetadata={},h.type="audio",h.id=d.id,h.timescale=this._timescale,h.duration=this._duration,h.audioSampleRate=a,h.channelCount=0===l?1:2),10===r){let s=this._parseAACAudioData(e,t+1,i-1);if(null==s)return;if(0===s.packetType){h.config&&u.w(this.TAG,"Found another AudioSpecificConfig!");let e=s.data;h.audioSampleRate=e.samplingRate,h.channelCount=e.channelCount,h.codec=e.codec,h.originalCodec=e.originalCodec,h.config=e.config,h.refSampleDuration=1024/h.audioSampleRate*h.timescale,u.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",h);let t=this._mediaInfo;t.audioCodec=h.originalCodec,t.audioSampleRate=h.audioSampleRate,t.audioChannelCount=h.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===s.packetType){let e=this._timestampBase+n,t={unit:s.data,length:s.data.byteLength,dts:e,pts:e};d.samples.push(t),d.length+=s.data.length}else u.e(this.TAG,"Flv: Unsupported AAC data type "+s.packetType)}else if(2===r){if(!h.codec){let n=this._parseMP3AudioData(e,t+1,i-1,!0);if(null==n)return;h.audioSampleRate=n.samplingRate,h.channelCount=n.channelCount,h.codec=n.codec,h.originalCodec=n.originalCodec,h.refSampleDuration=1152/h.audioSampleRate*h.timescale,u.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",h);let s=this._mediaInfo;s.audioCodec=h.codec,s.audioSampleRate=h.audioSampleRate,s.audioChannelCount=h.channelCount,s.audioDataRate=n.bitRate,s.hasVideo?null!=s.videoCodec&&(s.mimeType='video/x-flv; codecs="'+s.videoCodec+","+s.audioCodec+'"'):s.mimeType='video/x-flv; codecs="'+s.audioCodec+'"',s.isComplete()&&this._onMediaInfo(s)}let s=this._parseMP3AudioData(e,t+1,i-1,!1);if(null==s)return;let r=this._timestampBase+n,a={unit:s,length:s.byteLength,dts:r,pts:r};d.samples.push(a),d.length+=s.length}}_parseAACAudioData(e,t,i){if(i<=1)return void u.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let n={},s=new Uint8Array(e,t,i);return n.packetType=s[0],0===s[0]?n.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):n.data=s.subarray(1),n}_parseAACAudioSpecificConfig(e,t,i){let n=new Uint8Array(e,t,i),s=null,r=0,a=0,o=null,l=0,h=null;if(r=a=n[0]>>>3,l=(7&n[0])<<1|n[1]>>>7,l<0||l>=this._mpegSamplingRates.length)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let u=this._mpegSamplingRates[l],d=(120&n[1])>>>3;if(d<0||d>=8)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===r&&(h=(7&n[1])<<1|n[2]>>>7,o=(124&n[2])>>>2);let c=self.navigator.userAgent.toLowerCase();return-1!==c.indexOf("firefox")?l>=6?(r=5,s=new Array(4),h=l-3):(r=2,s=new Array(2),h=l):-1!==c.indexOf("android")?(r=2,s=new Array(2),h=l):(r=5,h=l,s=new Array(4),l>=6?h=l-3:1===d&&(r=2,s=new Array(2),h=l)),s[0]=r<<3,s[0]|=(15&l)>>>1,s[1]=(15&l)<<7,s[1]|=(15&d)<<3,5===r&&(s[1]|=(15&h)>>>1,s[2]=(1&h)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:u,channelCount:d,codec:"mp4a.40."+r,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,i,n){if(i<4)return void u.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let s=new Uint8Array(e,t,i),r=null;if(n){if(255!==s[0])return;let e=s[1]>>>3&3,t=(6&s[1])>>1,i=(240&s[2])>>>4,n=(12&s[2])>>>2,a=3!==(s[3]>>>6&3)?2:1,o=0,l=0,h=34,u="mp3";switch(e){case 0:o=this._mpegAudioV25SampleRateTable[n];break;case 2:o=this._mpegAudioV20SampleRateTable[n];break;case 3:o=this._mpegAudioV10SampleRateTable[n]}switch(t){case 1:h=34,i<this._mpegAudioL3BitRateTable.length&&(l=this._mpegAudioL3BitRateTable[i]);break;case 2:h=33,i<this._mpegAudioL2BitRateTable.length&&(l=this._mpegAudioL2BitRateTable[i]);break;case 3:h=32,i<this._mpegAudioL1BitRateTable.length&&(l=this._mpegAudioL1BitRateTable[i])}r={bitRate:l,samplingRate:o,channelCount:a,codec:u,originalCodec:u}}else r=s;return r}_parseVideoData(e,t,i,n,s){if(i<=1)return void u.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0===this._hasVideoFlagOverrided&&!1===this._hasVideo)return;let r=new Uint8Array(e,t,i)[0],a=(240&r)>>>4,o=15&r;7===o?this._parseAVCVideoPacket(e,t+1,i-1,n,s,a):this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+o)}_parseAVCVideoPacket(e,t,i,n,s,r){if(i<4)return void u.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,o=new DataView(e,t,i),l=o.getUint8(0),h=(16777215&o.getUint32(0,!a))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===l)this._parseAVCVideoData(e,t+4,i-4,n,s,r,h);else if(2!==l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,i){if(i<7)return void u.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let n=this._videoMetadata,s=this._videoTrack,r=this._littleEndian,a=new DataView(e,t,i);n?void 0!==n.avcc&&u.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),n=this._videoMetadata={},n.type="video",n.id=s.id,n.timescale=this._timescale,n.duration=this._duration);let o=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==o||0===l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(W.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let h=31&a.getUint8(5);if(0===h)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");h>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+h);let d=6;for(let i=0;i<h;i++){let s=a.getUint16(d,!r);if(d+=2,0===s)continue;let o=new Uint8Array(e,t+d,s);d+=s;let l=j.parseSPS(o);if(0!==i)continue;n.codecWidth=l.codec_size.width,n.codecHeight=l.codec_size.height,n.presentWidth=l.present_size.width,n.presentHeight=l.present_size.height,n.profile=l.profile_string,n.level=l.level_string,n.bitDepth=l.bit_depth,n.chromaFormat=l.chroma_format,n.sarRatio=l.sar_ratio,n.frameRate=l.frame_rate,!1!==l.frame_rate.fixed&&0!==l.frame_rate.fps_num&&0!==l.frame_rate.fps_den||(n.frameRate=this._referenceFrameRate);let h=n.frameRate.fps_den,u=n.frameRate.fps_num;n.refSampleDuration=n.timescale*(h/u);let c=o.subarray(1,4),_="avc1.";for(let e=0;e<3;e++){let t=c[e].toString(16);t.length<2&&(t="0"+t),_+=t}n.codec=_;let f=this._mediaInfo;f.width=n.codecWidth,f.height=n.codecHeight,f.fps=n.frameRate.fps,f.profile=n.profile,f.level=n.level,f.refFrames=l.ref_frames,f.chromaFormat=l.chroma_format_string,f.sarNum=n.sarRatio.width,f.sarDen=n.sarRatio.height,f.videoCodec=_,f.hasAudio?null!=f.audioCodec&&(f.mimeType='video/x-flv; codecs="'+f.videoCodec+","+f.audioCodec+'"'):f.mimeType='video/x-flv; codecs="'+f.videoCodec+'"',f.isComplete()&&this._onMediaInfo(f)}let c=a.getUint8(d);if(0!==c){c>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+c),d++;for(let e=0;e<c;e++){let e=a.getUint16(d,!r);d+=2,0!==e&&(d+=e)}n.avcc=new Uint8Array(i),n.avcc.set(new Uint8Array(e,t,i),0),u.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",n)}else this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}_parseAVCVideoData(e,t,i,n,s,r,a){let o=this._littleEndian,l=new DataView(e,t,i),h=[],d=0,c=0;const _=this._naluLengthSize;let f=this._timestampBase+n,m=1===r;for(;c<i;){if(c+4>=i){u.w(this.TAG,`Malformed Nalu near timestamp ${f}, offset = ${c}, dataSize = ${i}`);break}let n=l.getUint32(c,!o);if(3===_&&(n>>>=8),n>i-_)return void u.w(this.TAG,`Malformed Nalus near timestamp ${f}, NaluSize > DataSize!`);let s=31&l.getUint8(c+_);5===s&&(m=!0);let r=new Uint8Array(e,t+c,_+n),a={type:s,data:r};h.push(a),d+=r.byteLength,c+=_+n}if(h.length){let e=this._videoTrack,t={units:h,length:d,isKeyframe:m,dts:f,cts:a,pts:f+a};m&&(t.fileposition=s),e.samples.push(t),e.length+=d}}}var z=H;class ${static init(){$.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let e in $.types)$.types.hasOwnProperty(e)&&($.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=$.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,n=Array.prototype.slice.call(arguments,1),s=n.length;for(let e=0;e<s;e++)t+=n[e].byteLength;i=new Uint8Array(t),i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let r=8;for(let e=0;e<s;e++)i.set(n[e],r),r+=n[e].byteLength;return i}static generateInitSegment(e){let t=$.box($.types.ftyp,$.constants.FTYP),i=$.moov(e),n=new Uint8Array(t.byteLength+i.byteLength);return n.set(t,0),n.set(i,t.byteLength),n}static moov(e){let t=$.mvhd(e.timescale,e.duration),i=$.trak(e),n=$.mvex(e);return $.box($.types.moov,t,i,n)}static mvhd(e,t){return $.box($.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}static trak(e){return $.box($.types.trak,$.tkhd(e),$.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,n=e.presentWidth,s=e.presentHeight;return $.box($.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>>8&255,255&n,0,0,s>>>8&255,255&s,0,0]))}static mdia(e){return $.box($.types.mdia,$.mdhd(e),$.hdlr(e),$.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return $.box($.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?$.constants.HDLR_AUDIO:$.constants.HDLR_VIDEO,$.box($.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?$.box($.types.smhd,$.constants.SMHD):$.box($.types.vmhd,$.constants.VMHD),$.box($.types.minf,t,$.dinf(),$.stbl(e))}static dinf(){return $.box($.types.dinf,$.box($.types.dref,$.constants.DREF))}static stbl(e){return $.box($.types.stbl,$.stsd(e),$.box($.types.stts,$.constants.STTS),$.box($.types.stsc,$.constants.STSC),$.box($.types.stsz,$.constants.STSZ),$.box($.types.stco,$.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?$.box($.types.stsd,$.constants.STSD_PREFIX,$.mp3(e)):$.box($.types.stsd,$.constants.STSD_PREFIX,$.mp4a(e)):$.box($.types.stsd,$.constants.STSD_PREFIX,$.avc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return $.box($.types[".mp3"],n)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return $.box($.types.mp4a,n,$.esds(e))}static esds(e){let t=e.config||[],i=t.length,n=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return $.box($.types.esds,n)}static avc1(e){let t=e.avcc,i=e.codecWidth,n=e.codecHeight,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,n>>>8&255,255&n,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return $.box($.types.avc1,s,$.box($.types.avcC,t))}static mvex(e){return $.box($.types.mvex,$.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return $.box($.types.trex,i)}static moof(e,t){return $.box($.types.moof,$.mfhd(e.sequenceNumber),$.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return $.box($.types.mfhd,t)}static traf(e,t){let i=e.id,n=$.box($.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),s=$.box($.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),r=$.sdtp(e),a=$.trun(e,r.byteLength+16+16+8+16+8+8);return $.box($.types.traf,n,s,a,r)}static sdtp(e){let t=e.samples||[],i=t.length,n=new Uint8Array(4+i);for(let e=0;e<i;e++){let i=t[e].flags;n[e+4]=i.isLeading<<6|i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy}return $.box($.types.sdtp,n)}static trun(e,t){let i=e.samples||[],n=i.length,s=12+16*n,r=new Uint8Array(s);t+=8+s,r.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e<n;e++){let t=i[e].duration,n=i[e].size,s=i[e].flags,a=i[e].cts;r.set([t>>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*e)}return $.box($.types.trun,r)}static mdat(e){return $.box($.types.mdat,e)}}$.init();var q=$;var K=class{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null}};class Z{constructor(e,t,i,n,s){this.dts=e,this.pts=t,this.duration=i,this.originalDts=n,this.isSyncPoint=s,this.fileposition=null}}class X{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class J{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))}getLastSyncPointBeforeDts(e){if(0==this._list.length)return null;let t=this._list,i=0,n=t.length-1,s=0,r=0,a=n;for(e<t[0].dts&&(i=0,r=a+1);r<=a;){if(s=r+Math.floor((a-r)/2),s===n||e>=t[s].dts&&e<t[s+1].dts){i=s;break}t[s].dts<e?r=s+1:a=s-1}return this._list[i]}}class Q{constructor(e){this._type=e,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return 0===this._list.length}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(e){let t=this._list;if(0===t.length)return-2;let i=t.length-1,n=0,s=0,r=i,a=0;if(e<t[0].originalBeginDts)return a=-1,a;for(;s<=r;){if(n=s+Math.floor((r-s)/2),n===i||e>t[n].lastSample.originalDts&&e<t[n+1].originalBeginDts){a=n;break}t[n].originalBeginDts<e?s=n+1:r=n-1}return a}_searchNearestSegmentAfter(e){return this._searchNearestSegmentBefore(e)+1}append(e){let t=this._list,i=e,n=this._lastAppendLocation,s=0;-1!==n&&n<t.length&&i.originalBeginDts>=t[n].lastSample.originalDts&&(n===t.length-1||n<t.length-1&&i.originalBeginDts<t[n+1].originalBeginDts)?s=n+1:t.length>0&&(s=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=s,this._list.splice(s,0,i)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;for(;0===i.length&&t>0;)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null}}var ee=class{constructor(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new Q("audio"),this._videoSegmentInfoList=new Q("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!S.chrome||!(S.version.major<50||50===S.version.major&&S.version.build<2661)),this._fillSilentAfterSeek=S.msedge||S.msie,this._mp3UseMpegAudio=!S.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new _("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let i=null,n="mp4",s=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(n="mpeg",s="",i=new Uint8Array):i=q.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=q.generateInitSegment(t)}if(!this._onInitSegment)throw new _("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:s,container:`${e}/${n}`,mediaDuration:t.duration})}_calculateDtsBase(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);let n={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(n.samples.push(t),n.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(n,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let i=e,n=i.samples,s=void 0,r=-1,a=-1,o=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,h=this._dtsBaseInited&&void 0===this._audioNextDts,d=!1;if(!n||0===n.length)return;if(1===n.length&&!t)return;let c=0,_=null,f=0;l?(c=0,f=i.length):(c=8,f=8+i.length);let m=null;if(n.length>1&&(m=n.pop(),f-=m.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,n.unshift(e),f+=e.length}null!=m&&(this._audioStashedLastSample=m);let p=n[0].dts-this._dtsBase;if(this._audioNextDts)s=p-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())s=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(d=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0),s=p-(e.dts+e.duration+t)}else s=0}if(d){let e=p-s,t=this._videoSegmentInfoList.getLastSegmentBefore(p);if(null!=t&&t.beginDts<e){let i=K.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(i){let s=t.beginDts,r=e-t.beginDts;u.v(this.TAG,`InsertPrefixSilentAudio: dts: ${s}, duration: ${r}`),n.unshift({unit:i,dts:s,pts:s}),f+=i.byteLength}}else d=!1}let g=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.unit,a=t.dts-this._dtsBase,l=a-s;-1===r&&(r=l);let h=0;if(e!==n.length-1){h=n[e+1].dts-this._dtsBase-s-l}else if(null!=m){h=m.dts-this._dtsBase-s-l}else h=g.length>=1?g[g.length-1].duration:Math.floor(o);let d=!1,c=null;if(h>1.5*o&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!S.safari){d=!0;let e=Math.abs(h-o),t=Math.ceil(e/o),n=l+o;u.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${l+h} ms, expected: ${l+Math.round(o)} ms, delta: ${Math.round(e)} ms, generate: ${t} frames`);let s=K.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==s&&(u.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),s=i),c=[];for(let e=0;e<t;e++){let e=Math.round(n);if(c.length>0){let t=c[c.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:s,size:s.byteLength,duration:0,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};c.push(t),f+=t.size,n+=o}let r=c[c.length-1];r.duration=l+h-r.dts,h=Math.round(o)}g.push({dts:l,pts:l,cts:0,unit:t.unit,size:t.unit.byteLength,duration:h,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,c)}l?_=new Uint8Array(f):(_=new Uint8Array(f),_[0]=f>>>24&255,_[1]=f>>>16&255,_[2]=f>>>8&255,_[3]=255&f,_.set(q.types.mdat,4));for(let e=0;e<g.length;e++){let t=g[e].unit;_.set(t,c),c+=t.byteLength}let y=g[g.length-1];a=y.dts+y.duration,this._audioNextDts=a;let v=new X;v.beginDts=r,v.endDts=a,v.beginPts=r,v.endPts=a,v.originalBeginDts=g[0].originalDts,v.originalEndDts=y.originalDts+y.duration,v.firstSample=new Z(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,!1),v.lastSample=new Z(y.dts,y.pts,y.duration,y.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(v),i.samples=g,i.sequenceNumber++;let E=null;E=l?new Uint8Array:q.moof(i,r),i.samples=[],i.length=0;let b={type:"audio",data:this._mergeBoxes(E,_).buffer,sampleCount:g.length,info:v};l&&h&&(b.timestampOffset=r),this._onMediaSegment("audio",b)}_remuxVideo(e,t){if(null==this._videoMeta)return;let i=e,n=i.samples,s=void 0,r=-1,a=-1,o=-1,l=-1;if(!n||0===n.length)return;if(1===n.length&&!t)return;let h=8,u=null,d=8+e.length,c=null;if(n.length>1&&(c=n.pop(),d-=c.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,n.unshift(e),d+=e.length}null!=c&&(this._videoStashedLastSample=c);let _=n[0].dts-this._dtsBase;if(this._videoNextDts)s=_-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())s=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(_);if(null!=e){let t=_-(e.originalDts+e.duration);t<=3&&(t=0),s=_-(e.dts+e.duration+t)}else s=0}let f=new X,m=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.dts-this._dtsBase,a=t.isKeyframe,l=i-s,h=t.cts,u=l+h;-1===r&&(r=l,o=u);let d=0;if(e!==n.length-1){d=n[e+1].dts-this._dtsBase-s-l}else if(null!=c){d=c.dts-this._dtsBase-s-l}else d=m.length>=1?m[m.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(a){let e=new Z(l,u,d,t.dts,!0);e.fileposition=t.fileposition,f.appendSyncPoint(e)}m.push({dts:l,pts:u,cts:h,units:t.units,size:t.length,isKeyframe:a,duration:d,originalDts:i,flags:{isLeading:0,dependsOn:a?2:1,isDependedOn:a?1:0,hasRedundancy:0,isNonSync:a?0:1}})}u=new Uint8Array(d),u[0]=d>>>24&255,u[1]=d>>>16&255,u[2]=d>>>8&255,u[3]=255&d,u.set(q.types.mdat,4);for(let e=0;e<m.length;e++){let t=m[e].units;for(;t.length;){let e=t.shift().data;u.set(e,h),h+=e.byteLength}}let p=m[m.length-1];if(a=p.dts+p.duration,l=p.pts+p.duration,this._videoNextDts=a,f.beginDts=r,f.endDts=a,f.beginPts=o,f.endPts=l,f.originalBeginDts=m[0].originalDts,f.originalEndDts=p.originalDts+p.duration,f.firstSample=new Z(m[0].dts,m[0].pts,m[0].duration,m[0].originalDts,m[0].isKeyframe),f.lastSample=new Z(p.dts,p.pts,p.duration,p.originalDts,p.isKeyframe),this._isLive||this._videoSegmentInfoList.append(f),i.samples=m,i.sequenceNumber++,this._forceFirstIDR){let e=m[0].flags;e.dependsOn=2,e.isNonSync=0}let g=q.moof(i,r);i.samples=[],i.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(g,u).buffer,sampleCount:m.length,info:f})}_mergeBoxes(e,t){let i=new Uint8Array(e.byteLength+t.byteLength);return i.set(e,0),i.set(t,e.byteLength),i}};var te={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};var ie=class{constructor(e,t){this.TAG="TransmuxingController",this._emitter=new l.a,this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;let i=0;this._mediaDataSource.segments.forEach(n=>{n.timestampBase=i,i+=n.duration,n.cors=e.cors,n.withCredentials=e.withCredentials,t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy)}),isNaN(i)||this._mediaDataSource.duration===i||(this._mediaDataSource.duration=i),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let i=this._mediaDataSource.segments[e],n=this._ioctl=new L(i,this._config,e);n.onError=this._onIOException.bind(this),n.onSeeked=this._onIOSeeked.bind(this),n.onComplete=this._onIOComplete.bind(this),n.onRedirect=this._onIORedirect.bind(this),n.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):n.onDataArrival=this._onInitChunkArrival.bind(this),n.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let i=this._mediaInfo.segments[t];if(null==i)this._pendingSeekTime=e;else{let t=i.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let i=this._mediaInfo.segments[t];if(null==i)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let n=i.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,n.fileposition),this._pendingResolveSeekPoint=n.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,i=t.length-1;for(let n=0;n<t.length;n++)if(e<t[n].timestampBase){i=n-1;break}return i}_onInitChunkArrival(e,t){let i=null,n=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,n=this._demuxer.parseChunks(e,t);else if((i=z.probe(e)).match){this._demuxer=new z(i,this._config),this._remuxer||(this._remuxer=new ee(this._config));let s=this._mediaDataSource;null==s.duration||isNaN(s.duration)||(this._demuxer.overridedDuration=s.duration),"boolean"==typeof s.hasAudio&&(this._demuxer.overridedHasAudio=s.hasAudio),"boolean"==typeof s.hasVideo&&(this._demuxer.overridedHasVideo=s.hasVideo),this._demuxer.timestampBase=s.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),n=this._demuxer.parseChunks(e,t)}else i=null,u.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(te.DEMUX_ERROR,W.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),n=0;return n}_onMediaInfo(e){null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,N.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,N.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(te.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(t)):(this._remuxer.flushStashedSamples(),this._emitter.emit(te.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(e){let t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e}_onIORecoveredEarlyEof(){this._emitter.emit(te.RECOVERED_EARLY_EOF)}_onIOException(e,t){u.e(this.TAG,`IOException: type = ${e}, code = ${t.code}, msg = ${t.msg}`),this._emitter.emit(te.IO_ERROR,e,t),this._disableStatisticsReporter()}_onDemuxException(e,t){u.e(this.TAG,`DemuxException: type = ${e}, info = ${t}`),this._emitter.emit(te.DEMUX_ERROR,e,t)}_onRemuxerInitSegmentArrival(e,t){this._emitter.emit(te.INIT_SEGMENT,e,t)}_onRemuxerMediaSegmentArrival(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(te.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){let e=t.info.syncPoints,i=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,S.safari&&e.length>0&&e[0].originalDts===i&&(i=e[0].pts),this._emitter.emit(te.RECOMMEND_SEEKPOINT,i)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(te.MEDIA_INFO,i)}_reportStatisticsInfo(){let e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(te.STATISTICS_INFO,e)}};var ne=function(e){let t=null,i=function(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}.bind(this);function n(t,i){let n={msg:te.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(n,[i.data])}function s(t,i){let n={msg:te.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(n,[i.data])}function r(){let t={msg:te.LOADING_COMPLETE};e.postMessage(t)}function o(){let t={msg:te.RECOVERED_EARLY_EOF};e.postMessage(t)}function l(t){let i={msg:te.MEDIA_INFO,data:t};e.postMessage(i)}function h(t){let i={msg:te.METADATA_ARRIVED,data:t};e.postMessage(i)}function u(t){let i={msg:te.SCRIPTDATA_ARRIVED,data:t};e.postMessage(i)}function d(t){let i={msg:te.STATISTICS_INFO,data:t};e.postMessage(i)}function c(t,i){e.postMessage({msg:te.IO_ERROR,data:{type:t,info:i}})}function _(t,i){e.postMessage({msg:te.DEMUX_ERROR,data:{type:t,info:i}})}function f(t){e.postMessage({msg:te.RECOMMEND_SEEKPOINT,data:t})}a.install(),e.addEventListener("message",(function(a){switch(a.data.cmd){case"init":t=new ie(a.data.param[0],a.data.param[1]),t.on(te.IO_ERROR,c.bind(this)),t.on(te.DEMUX_ERROR,_.bind(this)),t.on(te.INIT_SEGMENT,n.bind(this)),t.on(te.MEDIA_SEGMENT,s.bind(this)),t.on(te.LOADING_COMPLETE,r.bind(this)),t.on(te.RECOVERED_EARLY_EOF,o.bind(this)),t.on(te.MEDIA_INFO,l.bind(this)),t.on(te.METADATA_ARRIVED,h.bind(this)),t.on(te.SCRIPTDATA_ARRIVED,u.bind(this)),t.on(te.STATISTICS_INFO,d.bind(this)),t.on(te.RECOMMEND_SEEKPOINT,f.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(a.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=a.data.param;x.applyConfig(e),!0===e.enableCallback?x.addLogListener(i):x.removeLogListener(i);break}}}))};var se=class{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new l.a,t.enableWorker&&"undefined"!=typeof Worker)try{let n=i(13);this._worker=n(ne),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},x.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:x.getConfig()})}catch(i){u.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ie(e,t)}else this._controller=new ie(e,t);if(this._controller){let e=this._controller;e.on(te.IO_ERROR,this._onIOError.bind(this)),e.on(te.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(te.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(te.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(te.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(te.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(te.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(te.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(te.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(te.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(te.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),x.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(te.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(te.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(te.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,i=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case te.INIT_SEGMENT:case te.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case te.LOADING_COMPLETE:case te.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case te.MEDIA_INFO:Object.setPrototypeOf(i,N.prototype),this._emitter.emit(t.msg,i);break;case te.METADATA_ARRIVED:case te.SCRIPTDATA_ARRIVED:case te.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case te.IO_ERROR:case te.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case te.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":u.emitter.emit("log",i.type,i.logcat)}}};var re={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var ae=class{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new l.a,this._config.isLive&&null==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new J}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new _("MediaSource has been attached to an HTMLMediaElement!");let t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let e=this._mediaSource;for(let t in this._sourceBuffers){let i=this._pendingSegments[t];i.splice(0,i.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let n=this._sourceBuffers[t];if(n){if("closed"!==e.readyState){try{e.removeSourceBuffer(n)}catch(e){u.e(this.TAG,e.message)}n.removeEventListener("error",this.e.onSourceBufferError),n.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){u.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let i=e,n=""+i.container;i.codec&&i.codec.length>0&&(n+=";codecs="+i.codec);let s=!1;if(u.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])u.v(this.TAG,`Notice: ${i.type} mimeType changed, origin: ${this._mimeTypes[i.type]}, target: ${n}`);else{s=!0;try{let e=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.e(this.TAG,e.message),void this._emitter.emit(re.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}t||this._pendingSegments[i.type].push(i),s||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),S.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){u.e(this.TAG,e.message)}this._idrList.clear();let i=this._pendingSegments[e];if(i.splice(0,i.length),"closed"!==this._mediaSource.readyState){for(let i=0;i<t.buffered.length;i++){let n=t.buffered.start(i),s=t.buffered.end(i);this._pendingRemoveRanges[e].push({start:n,end:s})}if(t.updating||this._doRemoveRanges(),S.safari){let i=this._lastInitSegments[e];i&&(this._pendingSegments[e].push(i),t.updating||this._doAppendSegments())}}}}endOfStream(){let e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)}getNearestKeyframe(e){return this._idrList.getLastSyncPointBeforeDts(e)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let i=this._sourceBuffers[t];if(i){let t=i.buffered;if(t.length>=1&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let i=this._sourceBuffers[t];if(i){let n=i.buffered,s=!1;for(let i=0;i<n.length;i++){let r=n.start(i),a=n.end(i);if(r<=e&&e<a+3){if(e-r>=this._config.autoCleanupMaxBackwardDuration){s=!0;let i=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:r,end:i})}}else a<e&&(s=!0,this._pendingRemoveRanges[t].push({start:r,end:a}))}s&&!i.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let e=this._sourceBuffers;if(0===this._mediaElement.readyState||"open"!==this._mediaSource.readyState)return;if(e.video&&e.video.updating||e.audio&&e.audio.updating)return;let t=this._mediaSource.duration,i=this._pendingMediaDuration;i>0&&(isNaN(t)||i>t)&&(u.v(this.TAG,`Update MediaSource duration from ${t} to ${i}`),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let e in this._pendingRemoveRanges){if(!this._sourceBuffers[e]||this._sourceBuffers[e].updating)continue;let t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];for(;i.length&&!t.updating;){let e=i.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){let i=e[t].shift();if(i.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,n=i.timestampOffset/1e3;Math.abs(e-n)>.1&&(u.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${n}`),this._sourceBuffers[t].timestampOffset=n),delete i.timestampOffset}if(!i.data||0===i.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(i.data),this._isBufferFull=!1,"video"===t&&i.hasOwnProperty("info")&&this._idrList.appendArray(i.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(i),22===e.code?(this._isBufferFull||this._emitter.emit(re.BUFFER_FULL),this._isBufferFull=!0):(u.e(this.TAG,e.message),this._emitter.emit(re.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(u.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;for(;e.length;){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(re.SOURCE_OPEN)}_onSourceEnded(){u.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){u.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let e=this._pendingSegments;return e.video.length>0||e.audio.length>0}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(re.UPDATE_END)}_onSourceBufferError(e){u.e(this.TAG,"SourceBuffer Error: "+e)}};const oe={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},le={NETWORK_EXCEPTION:g.EXCEPTION,NETWORK_STATUS_CODE_INVALID:g.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:g.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:g.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:W.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:W.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:W.CODEC_UNSUPPORTED};var he=class{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new l.a,this._config=T(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let i=S.chrome&&(S.version.major<50||50===S.version.major&&S.version.build<2661);this._alwaysSeekKeyframe=!!(i||S.msedge||S.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===C.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(C.MEDIA_INFO,this.mediaInfo)}):e===C.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(C.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new ae(this._config),this._msectl.on(re.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(re.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(re.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(re.ERROR,e=>{this._emitter.emit(C.ERROR,oe.MEDIA_ERROR,le.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new _("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new se(this._mediaDataSource,this._config),this._transmuxer.on(te.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(te.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(te.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(C.LOADING_COMPLETE)}),this._transmuxer.on(te.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(C.RECOVERED_EARLY_EOF)}),this._transmuxer.on(te.IO_ERROR,(e,t)=>{this._emitter.emit(C.ERROR,oe.NETWORK_ERROR,e,t)}),this._transmuxer.on(te.DEMUX_ERROR,(e,t)=>{this._emitter.emit(C.ERROR,oe.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(te.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(C.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(te.METADATA_ARRIVED,e=>{this._emitter.emit(C.METADATA_ARRIVED,e)}),this._transmuxer.on(te.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(C.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(te.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(C.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(te.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open()))}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,n=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,i=0,n=0;for(let s=0;s<e.length;s++){let r=e.start(s),a=e.end(s);if(r<=t&&t<a){i=r,n=a;break}}n>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){u.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1;for(let n=0;n<t.length;n++){let s=t.start(n),r=t.end(n);if(e>=s&&e<r){e>=r-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(u.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let i=0;i<t.length;i++){let n=t.start(i),s=t.end(i);if(e>=n&&e<s)return!0}return!1}_internalSeek(e){let t=this._isTimepointBuffered(e),i=!1,n=0;if(e<1&&this._mediaElement.buffered.length>0){let t=this._mediaElement.buffered.start(0);(t<1&&e<t||S.safari)&&(i=!0,n=S.safari?.1:t)}if(i)this._requestSetTime=!0,this._mediaElement.currentTime=n;else if(t){if(this._alwaysSeekKeyframe){let t=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=t?t.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(e){let t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){let e=t.buffered;e.length>0&&t.currentTime<e.start(0)&&(u.w(this.TAG,`Playback seems stuck at ${t.currentTime}, seek to ${e.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=e.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(e){let t=this._mediaElement.currentTime,i=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&i.length>0){let e=i.start(0);if(e<1&&t<e||S.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=S.safari?.1:e)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){let e=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=e&&(this._requestSetTime=!0,this._mediaElement.currentTime=e.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}}_onvCanPlay(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(e){this._checkAndResumeStuckPlayback(!0)}_onvProgress(e){this._checkAndResumeStuckPlayback()}};var ue=class{constructor(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new l.a,this._config=T(),"object"==typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new f("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new f(`NativePlayer(${e.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===C.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(C.MEDIA_INFO,this.mediaInfo)}):e===C.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(C.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,n=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,n=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,n=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=n),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(C.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(C.STATISTICS_INFO,this.statisticsInfo)}};a.install();let de={createPlayer:function(e,t){let i=e;if(null==i||"object"!=typeof i)throw new f("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new f("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"flv":return new he(i,t);default:return new ue(i,t)}},isSupported:function(){return O.supportMSEH264Playback()},getFeatureList:function(){return O.getFeatureList()}};de.BaseLoader=y,de.LoaderStatus=p,de.LoaderErrors=g,de.Events=C,de.ErrorTypes=oe,de.ErrorDetails=le,de.FlvPlayer=he,de.NativePlayer=ue,de.LoggingControl=x,Object.defineProperty(de,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var ce=de,_e=i(2),fe=i.n(_e),me=i(5),pe={insert:"head",singleton:!1};fe()(me.a,pe),me.a.locals;function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ve(e,t){return(ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Se(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=be(e);if(t){var s=be(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Ee(this,i)}}function Ee(e,t){return!t||"object"!==ge(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function be(e){return(be=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var we=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ve(e,t)}(a,e);var t,i,n,r=Se(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=r.call(this,e)).state={vidoeUrl:"",id:(new Date).getTime()+Math.floor(9999*Math.random())+1},t}return t=a,n=[{key:"getDerivedStateFromProps",value:function(e){var t=e.vidoeUrl;return t?{vidoeUrl:t}:null}}],(i=[{key:"componentDidUpdate",value:function(){this.state.vidoeUrl&&this.startFlv()}},{key:"componentDidMount",value:function(){this.state.vidoeUrl&&this.startFlv()}},{key:"startFlv",value:function(){var e=this.state,t=e.vidoeUrl,i=e.id;if(ce.isSupported()){var n=document.getElementById(i);this.flvPlayer&&this.destroyFlv(),this.flvPlayer=ce.createPlayer({type:"flv",isLive:!0,hasAudio:!1,url:t},{enableStashBuffer:!0,stashInitialSize:128}),this.flvPlayer.attachMediaElement(n),this.flvPlayer.load(),this.flvPlayer.play()}else alert("请更换浏览器,该浏览器暂不支持。")}},{key:"destroyFlv",value:function(){this.flvPlayer.pause(),this.flvPlayer.unload(),this.flvPlayer.detachMediaElement(),this.flvPlayer.destroy(),this.flvPlayer=null}},{key:"render",value:function(){return s.a.createElement("div",{className:"flvWai"},s.a.createElement("video",{id:this.state.id,className:"videoFlv",autoPlay:!0,controls:!0,muted:!0}))}}])&&ye(t.prototype,i),n&&ye(t,n),a}(n.Component),Re=i(4),ke=i(6),Ae={insert:"head",singleton:!1};fe()(ke.a,Ae),ke.a.locals;function Le(e){return(Le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function De(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Te(e,t){return(Te=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=Ce(e);if(t){var s=Ce(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Oe(this,i)}}function Oe(e,t){return!t||"object"!==Le(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ce(e){return(Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Ie=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Te(e,t)}(a,e);var t,i,n,r=Me(a);function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(e=r.call(this)).state={showDateTime:"",classInfo:""},e}return t=a,n=[{key:"getDerivedStateFromProps",value:function(e,t){var i=e.className;return i!==t.className?{classInfo:i}:null}}],(i=[{key:"forShowDateTime",value:function(){var e=this.props.type,t=void 0===e?"YYYY-MM-DD HH:mm:ss":e;this.setState({showDateTime:Object(Re.a)().format(t)})}},{key:"componentDidMount",value:function(){var e=this;this.forShowDateTime(),this.timer=setInterval((function(){e.forShowDateTime()}),1e3)}},{key:"render",value:function(){var e=this.state,t=e.classInfo,i=e.showDateTime;return s.a.createElement("div",{className:"timerComCss"},s.a.createElement("p",{className:t},i))}}])&&De(t.prototype,i),n&&De(t,n),a}(n.Component)}])})); | |
0 | 35 | \ No newline at end of file | ... | ... |
package.json
0 → 100644
1 | +++ a/package.json | |
1 | +{ | |
2 | + "name": "zzreact", | |
3 | + "version": "1.0.7", | |
4 | + "description": "react中使用的组件第一版", | |
5 | + "main": "dist/index.js", | |
6 | + "files": [ | |
7 | + "dist" | |
8 | + ], | |
9 | + "scripts": { | |
10 | + "start": "set NODE_ENV=dev&& webpack-dev-server", | |
11 | + "build": "set NODE_ENV=prod&& webpack" | |
12 | + }, | |
13 | + "author": "reqingzai", | |
14 | + "license": "ISC", | |
15 | + "devDependencies": { | |
16 | + "@babel/cli": "^7.2.3", | |
17 | + "@babel/core": "^7.2.2", | |
18 | + "@babel/preset-env": "^7.3.1", | |
19 | + "@babel/preset-react": "^7.0.0", | |
20 | + "babel-loader": "^8.0.5", | |
21 | + "css-loader": "^5.0.1", | |
22 | + "file-loader": "^6.2.0", | |
23 | + "html-webpack-plugin": "^3.2.0", | |
24 | + "react": "^17.0.1", | |
25 | + "react-dom": "^17.0.1", | |
26 | + "style-loader": "^2.0.0", | |
27 | + "webpack": "^4.29.0", | |
28 | + "webpack-cli": "^3.2.1", | |
29 | + "webpack-dev-server": "^3.1.14" | |
30 | + }, | |
31 | + "dependencies": { | |
32 | + "flv.js": "^1.5.0" | |
33 | + } | |
34 | +} | ... | ... |
public/index.html
0 → 100644
src/components/flvCom/flvCom.css
0 → 100644
src/components/flvCom/flvCom.js
0 → 100644
1 | +++ a/src/components/flvCom/flvCom.js | |
1 | +import React, { Component } from "react" | |
2 | +import flvjs from "flv.js"; | |
3 | +import "./flvCom.css" | |
4 | +export default class FlvCom extends Component { | |
5 | + constructor(props){ | |
6 | + super(props); | |
7 | + this.state = { | |
8 | + vidoeUrl:"", | |
9 | + id:new Date().getTime()+Math.floor(Math.random() * (10000 - 1)) + 1, | |
10 | + } | |
11 | + } | |
12 | + static getDerivedStateFromProps(props){ | |
13 | + let {vidoeUrl} = props | |
14 | + if(vidoeUrl){ | |
15 | + return{ | |
16 | + vidoeUrl | |
17 | + } | |
18 | + } | |
19 | + return null; | |
20 | + } | |
21 | + componentDidUpdate(){ | |
22 | + if(this.state.vidoeUrl){ | |
23 | + this.startFlv() | |
24 | + } | |
25 | + } | |
26 | + componentDidMount(){ | |
27 | + if(this.state.vidoeUrl){ | |
28 | + this.startFlv() | |
29 | + } | |
30 | + } | |
31 | + startFlv(){ | |
32 | + let {vidoeUrl,id} = this.state | |
33 | + if (flvjs.isSupported()) { | |
34 | + const videoElement = document.getElementById(id); | |
35 | + if(this.flvPlayer) this.destroyFlv() | |
36 | + this.flvPlayer = flvjs.createPlayer( | |
37 | + { | |
38 | + type: "flv", | |
39 | + isLive: true, | |
40 | + hasAudio: false, | |
41 | + //必须与node搭建的流媒体服务器中的http的端口和推流的参数吻合 | |
42 | + url: vidoeUrl, | |
43 | + }, | |
44 | + { | |
45 | + enableStashBuffer: true, | |
46 | + stashInitialSize: 128, | |
47 | + } | |
48 | + ); | |
49 | + this.flvPlayer.attachMediaElement(videoElement); | |
50 | + this.flvPlayer.load(); | |
51 | + this.flvPlayer.play(); | |
52 | + } else { | |
53 | + alert("请更换浏览器,该浏览器暂不支持。") | |
54 | + } | |
55 | + } | |
56 | + destroyFlv(){ | |
57 | + this.flvPlayer.pause(); | |
58 | + this.flvPlayer.unload(); | |
59 | + this.flvPlayer.detachMediaElement(); | |
60 | + this.flvPlayer.destroy(); | |
61 | + this.flvPlayer = null; | |
62 | + } | |
63 | + render() { | |
64 | + return ( | |
65 | + <div className="flvWai"> | |
66 | + <video | |
67 | + id={this.state.id} | |
68 | + className="videoFlv" | |
69 | + autoPlay | |
70 | + controls | |
71 | + muted | |
72 | + ></video> | |
73 | + </div> | |
74 | + ) | |
75 | + } | |
76 | +} | |
0 | 77 | \ No newline at end of file | ... | ... |
src/components/index.js
0 → 100644
src/components/timer/lib/locale/zh-cn.js
0 → 100644
1 | +++ a/src/components/timer/lib/locale/zh-cn.js | |
1 | +//! moment.js locale configuration | |
2 | +//! locale : Chinese (China) [zh-cn] | |
3 | +//! author : suupic : https://github.com/suupic | |
4 | +//! author : Zeno Zeng : https://github.com/zenozeng | |
5 | +//! author : uu109 : https://github.com/uu109 | |
6 | + | |
7 | +import moment from '../moment'; | |
8 | + | |
9 | +export default moment.defineLocale('zh-cn', { | |
10 | + months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split( | |
11 | + '_' | |
12 | + ), | |
13 | + monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split( | |
14 | + '_' | |
15 | + ), | |
16 | + weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), | |
17 | + weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), | |
18 | + weekdaysMin: '日_一_二_三_四_五_六'.split('_'), | |
19 | + longDateFormat: { | |
20 | + LT: 'HH:mm', | |
21 | + LTS: 'HH:mm:ss', | |
22 | + L: 'YYYY/MM/DD', | |
23 | + LL: 'YYYY年M月D日', | |
24 | + LLL: 'YYYY年M月D日Ah点mm分', | |
25 | + LLLL: 'YYYY年M月D日ddddAh点mm分', | |
26 | + l: 'YYYY/M/D', | |
27 | + ll: 'YYYY年M月D日', | |
28 | + lll: 'YYYY年M月D日 HH:mm', | |
29 | + llll: 'YYYY年M月D日dddd HH:mm', | |
30 | + }, | |
31 | + meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, | |
32 | + meridiemHour: function (hour, meridiem) { | |
33 | + if (hour === 12) { | |
34 | + hour = 0; | |
35 | + } | |
36 | + if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') { | |
37 | + return hour; | |
38 | + } else if (meridiem === '下午' || meridiem === '晚上') { | |
39 | + return hour + 12; | |
40 | + } else { | |
41 | + // '中午' | |
42 | + return hour >= 11 ? hour : hour + 12; | |
43 | + } | |
44 | + }, | |
45 | + meridiem: function (hour, minute, isLower) { | |
46 | + var hm = hour * 100 + minute; | |
47 | + if (hm < 600) { | |
48 | + return '凌晨'; | |
49 | + } else if (hm < 900) { | |
50 | + return '早上'; | |
51 | + } else if (hm < 1130) { | |
52 | + return '上午'; | |
53 | + } else if (hm < 1230) { | |
54 | + return '中午'; | |
55 | + } else if (hm < 1800) { | |
56 | + return '下午'; | |
57 | + } else { | |
58 | + return '晚上'; | |
59 | + } | |
60 | + }, | |
61 | + calendar: { | |
62 | + sameDay: '[今天]LT', | |
63 | + nextDay: '[明天]LT', | |
64 | + nextWeek: function (now) { | |
65 | + if (now.week() !== this.week()) { | |
66 | + return '[下]dddLT'; | |
67 | + } else { | |
68 | + return '[本]dddLT'; | |
69 | + } | |
70 | + }, | |
71 | + lastDay: '[昨天]LT', | |
72 | + lastWeek: function (now) { | |
73 | + if (this.week() !== now.week()) { | |
74 | + return '[上]dddLT'; | |
75 | + } else { | |
76 | + return '[本]dddLT'; | |
77 | + } | |
78 | + }, | |
79 | + sameElse: 'L', | |
80 | + }, | |
81 | + dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/, | |
82 | + ordinal: function (number, period) { | |
83 | + switch (period) { | |
84 | + case 'd': | |
85 | + case 'D': | |
86 | + case 'DDD': | |
87 | + return number + '日'; | |
88 | + case 'M': | |
89 | + return number + '月'; | |
90 | + case 'w': | |
91 | + case 'W': | |
92 | + return number + '周'; | |
93 | + default: | |
94 | + return number; | |
95 | + } | |
96 | + }, | |
97 | + relativeTime: { | |
98 | + future: '%s后', | |
99 | + past: '%s前', | |
100 | + s: '几秒', | |
101 | + ss: '%d 秒', | |
102 | + m: '1 分钟', | |
103 | + mm: '%d 分钟', | |
104 | + h: '1 小时', | |
105 | + hh: '%d 小时', | |
106 | + d: '1 天', | |
107 | + dd: '%d 天', | |
108 | + w: '1 周', | |
109 | + ww: '%d 周', | |
110 | + M: '1 个月', | |
111 | + MM: '%d 个月', | |
112 | + y: '1 年', | |
113 | + yy: '%d 年', | |
114 | + }, | |
115 | + week: { | |
116 | + // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效 | |
117 | + dow: 1, // Monday is the first day of the week. | |
118 | + doy: 4, // The week that contains Jan 4th is the first week of the year. | |
119 | + }, | |
120 | +}); | ... | ... |
src/components/timer/lib/moment.js
0 → 100644
Changes suppressed. Click to show
1 | +++ a/src/components/timer/lib/moment.js | |
1 | +//! moment.js | |
2 | +//! version : 2.29.1 | |
3 | +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors | |
4 | +//! license : MIT | |
5 | +//! momentjs.com | |
6 | + | |
7 | +var hookCallback; | |
8 | + | |
9 | +function hooks() { | |
10 | + return hookCallback.apply(null, arguments); | |
11 | +} | |
12 | + | |
13 | +// This is done to register the method called with moment() | |
14 | +// without creating circular dependencies. | |
15 | +function setHookCallback(callback) { | |
16 | + hookCallback = callback; | |
17 | +} | |
18 | + | |
19 | +function isArray(input) { | |
20 | + return ( | |
21 | + input instanceof Array || | |
22 | + Object.prototype.toString.call(input) === '[object Array]' | |
23 | + ); | |
24 | +} | |
25 | + | |
26 | +function isObject(input) { | |
27 | + // IE8 will treat undefined and null as object if it wasn't for | |
28 | + // input != null | |
29 | + return ( | |
30 | + input != null && | |
31 | + Object.prototype.toString.call(input) === '[object Object]' | |
32 | + ); | |
33 | +} | |
34 | + | |
35 | +function hasOwnProp(a, b) { | |
36 | + return Object.prototype.hasOwnProperty.call(a, b); | |
37 | +} | |
38 | + | |
39 | +function isObjectEmpty(obj) { | |
40 | + if (Object.getOwnPropertyNames) { | |
41 | + return Object.getOwnPropertyNames(obj).length === 0; | |
42 | + } else { | |
43 | + var k; | |
44 | + for (k in obj) { | |
45 | + if (hasOwnProp(obj, k)) { | |
46 | + return false; | |
47 | + } | |
48 | + } | |
49 | + return true; | |
50 | + } | |
51 | +} | |
52 | + | |
53 | +function isUndefined(input) { | |
54 | + return input === void 0; | |
55 | +} | |
56 | + | |
57 | +function isNumber(input) { | |
58 | + return ( | |
59 | + typeof input === 'number' || | |
60 | + Object.prototype.toString.call(input) === '[object Number]' | |
61 | + ); | |
62 | +} | |
63 | + | |
64 | +function isDate(input) { | |
65 | + return ( | |
66 | + input instanceof Date || | |
67 | + Object.prototype.toString.call(input) === '[object Date]' | |
68 | + ); | |
69 | +} | |
70 | + | |
71 | +function map(arr, fn) { | |
72 | + var res = [], | |
73 | + i; | |
74 | + for (i = 0; i < arr.length; ++i) { | |
75 | + res.push(fn(arr[i], i)); | |
76 | + } | |
77 | + return res; | |
78 | +} | |
79 | + | |
80 | +function extend(a, b) { | |
81 | + for (var i in b) { | |
82 | + if (hasOwnProp(b, i)) { | |
83 | + a[i] = b[i]; | |
84 | + } | |
85 | + } | |
86 | + | |
87 | + if (hasOwnProp(b, 'toString')) { | |
88 | + a.toString = b.toString; | |
89 | + } | |
90 | + | |
91 | + if (hasOwnProp(b, 'valueOf')) { | |
92 | + a.valueOf = b.valueOf; | |
93 | + } | |
94 | + | |
95 | + return a; | |
96 | +} | |
97 | + | |
98 | +function createUTC(input, format, locale, strict) { | |
99 | + return createLocalOrUTC(input, format, locale, strict, true).utc(); | |
100 | +} | |
101 | + | |
102 | +function defaultParsingFlags() { | |
103 | + // We need to deep clone this object. | |
104 | + return { | |
105 | + empty: false, | |
106 | + unusedTokens: [], | |
107 | + unusedInput: [], | |
108 | + overflow: -2, | |
109 | + charsLeftOver: 0, | |
110 | + nullInput: false, | |
111 | + invalidEra: null, | |
112 | + invalidMonth: null, | |
113 | + invalidFormat: false, | |
114 | + userInvalidated: false, | |
115 | + iso: false, | |
116 | + parsedDateParts: [], | |
117 | + era: null, | |
118 | + meridiem: null, | |
119 | + rfc2822: false, | |
120 | + weekdayMismatch: false, | |
121 | + }; | |
122 | +} | |
123 | + | |
124 | +function getParsingFlags(m) { | |
125 | + if (m._pf == null) { | |
126 | + m._pf = defaultParsingFlags(); | |
127 | + } | |
128 | + return m._pf; | |
129 | +} | |
130 | + | |
131 | +var some; | |
132 | +if (Array.prototype.some) { | |
133 | + some = Array.prototype.some; | |
134 | +} else { | |
135 | + some = function (fun) { | |
136 | + var t = Object(this), | |
137 | + len = t.length >>> 0, | |
138 | + i; | |
139 | + | |
140 | + for (i = 0; i < len; i++) { | |
141 | + if (i in t && fun.call(this, t[i], i, t)) { | |
142 | + return true; | |
143 | + } | |
144 | + } | |
145 | + | |
146 | + return false; | |
147 | + }; | |
148 | +} | |
149 | + | |
150 | +function isValid(m) { | |
151 | + if (m._isValid == null) { | |
152 | + var flags = getParsingFlags(m), | |
153 | + parsedParts = some.call(flags.parsedDateParts, function (i) { | |
154 | + return i != null; | |
155 | + }), | |
156 | + isNowValid = | |
157 | + !isNaN(m._d.getTime()) && | |
158 | + flags.overflow < 0 && | |
159 | + !flags.empty && | |
160 | + !flags.invalidEra && | |
161 | + !flags.invalidMonth && | |
162 | + !flags.invalidWeekday && | |
163 | + !flags.weekdayMismatch && | |
164 | + !flags.nullInput && | |
165 | + !flags.invalidFormat && | |
166 | + !flags.userInvalidated && | |
167 | + (!flags.meridiem || (flags.meridiem && parsedParts)); | |
168 | + | |
169 | + if (m._strict) { | |
170 | + isNowValid = | |
171 | + isNowValid && | |
172 | + flags.charsLeftOver === 0 && | |
173 | + flags.unusedTokens.length === 0 && | |
174 | + flags.bigHour === undefined; | |
175 | + } | |
176 | + | |
177 | + if (Object.isFrozen == null || !Object.isFrozen(m)) { | |
178 | + m._isValid = isNowValid; | |
179 | + } else { | |
180 | + return isNowValid; | |
181 | + } | |
182 | + } | |
183 | + return m._isValid; | |
184 | +} | |
185 | + | |
186 | +function createInvalid(flags) { | |
187 | + var m = createUTC(NaN); | |
188 | + if (flags != null) { | |
189 | + extend(getParsingFlags(m), flags); | |
190 | + } else { | |
191 | + getParsingFlags(m).userInvalidated = true; | |
192 | + } | |
193 | + | |
194 | + return m; | |
195 | +} | |
196 | + | |
197 | +// Plugins that add properties should also add the key here (null value), | |
198 | +// so we can properly clone ourselves. | |
199 | +var momentProperties = (hooks.momentProperties = []), | |
200 | + updateInProgress = false; | |
201 | + | |
202 | +function copyConfig(to, from) { | |
203 | + var i, prop, val; | |
204 | + | |
205 | + if (!isUndefined(from._isAMomentObject)) { | |
206 | + to._isAMomentObject = from._isAMomentObject; | |
207 | + } | |
208 | + if (!isUndefined(from._i)) { | |
209 | + to._i = from._i; | |
210 | + } | |
211 | + if (!isUndefined(from._f)) { | |
212 | + to._f = from._f; | |
213 | + } | |
214 | + if (!isUndefined(from._l)) { | |
215 | + to._l = from._l; | |
216 | + } | |
217 | + if (!isUndefined(from._strict)) { | |
218 | + to._strict = from._strict; | |
219 | + } | |
220 | + if (!isUndefined(from._tzm)) { | |
221 | + to._tzm = from._tzm; | |
222 | + } | |
223 | + if (!isUndefined(from._isUTC)) { | |
224 | + to._isUTC = from._isUTC; | |
225 | + } | |
226 | + if (!isUndefined(from._offset)) { | |
227 | + to._offset = from._offset; | |
228 | + } | |
229 | + if (!isUndefined(from._pf)) { | |
230 | + to._pf = getParsingFlags(from); | |
231 | + } | |
232 | + if (!isUndefined(from._locale)) { | |
233 | + to._locale = from._locale; | |
234 | + } | |
235 | + | |
236 | + if (momentProperties.length > 0) { | |
237 | + for (i = 0; i < momentProperties.length; i++) { | |
238 | + prop = momentProperties[i]; | |
239 | + val = from[prop]; | |
240 | + if (!isUndefined(val)) { | |
241 | + to[prop] = val; | |
242 | + } | |
243 | + } | |
244 | + } | |
245 | + | |
246 | + return to; | |
247 | +} | |
248 | + | |
249 | +// Moment prototype object | |
250 | +function Moment(config) { | |
251 | + copyConfig(this, config); | |
252 | + this._d = new Date(config._d != null ? config._d.getTime() : NaN); | |
253 | + if (!this.isValid()) { | |
254 | + this._d = new Date(NaN); | |
255 | + } | |
256 | + // Prevent infinite loop in case updateOffset creates new moment | |
257 | + // objects. | |
258 | + if (updateInProgress === false) { | |
259 | + updateInProgress = true; | |
260 | + hooks.updateOffset(this); | |
261 | + updateInProgress = false; | |
262 | + } | |
263 | +} | |
264 | + | |
265 | +function isMoment(obj) { | |
266 | + return ( | |
267 | + obj instanceof Moment || (obj != null && obj._isAMomentObject != null) | |
268 | + ); | |
269 | +} | |
270 | + | |
271 | +function warn(msg) { | |
272 | + if ( | |
273 | + hooks.suppressDeprecationWarnings === false && | |
274 | + typeof console !== 'undefined' && | |
275 | + console.warn | |
276 | + ) { | |
277 | + console.warn('Deprecation warning: ' + msg); | |
278 | + } | |
279 | +} | |
280 | + | |
281 | +function deprecate(msg, fn) { | |
282 | + var firstTime = true; | |
283 | + | |
284 | + return extend(function () { | |
285 | + if (hooks.deprecationHandler != null) { | |
286 | + hooks.deprecationHandler(null, msg); | |
287 | + } | |
288 | + if (firstTime) { | |
289 | + var args = [], | |
290 | + arg, | |
291 | + i, | |
292 | + key; | |
293 | + for (i = 0; i < arguments.length; i++) { | |
294 | + arg = ''; | |
295 | + if (typeof arguments[i] === 'object') { | |
296 | + arg += '\n[' + i + '] '; | |
297 | + for (key in arguments[0]) { | |
298 | + if (hasOwnProp(arguments[0], key)) { | |
299 | + arg += key + ': ' + arguments[0][key] + ', '; | |
300 | + } | |
301 | + } | |
302 | + arg = arg.slice(0, -2); // Remove trailing comma and space | |
303 | + } else { | |
304 | + arg = arguments[i]; | |
305 | + } | |
306 | + args.push(arg); | |
307 | + } | |
308 | + warn( | |
309 | + msg + | |
310 | + '\nArguments: ' + | |
311 | + Array.prototype.slice.call(args).join('') + | |
312 | + '\n' + | |
313 | + new Error().stack | |
314 | + ); | |
315 | + firstTime = false; | |
316 | + } | |
317 | + return fn.apply(this, arguments); | |
318 | + }, fn); | |
319 | +} | |
320 | + | |
321 | +var deprecations = {}; | |
322 | + | |
323 | +function deprecateSimple(name, msg) { | |
324 | + if (hooks.deprecationHandler != null) { | |
325 | + hooks.deprecationHandler(name, msg); | |
326 | + } | |
327 | + if (!deprecations[name]) { | |
328 | + warn(msg); | |
329 | + deprecations[name] = true; | |
330 | + } | |
331 | +} | |
332 | + | |
333 | +hooks.suppressDeprecationWarnings = false; | |
334 | +hooks.deprecationHandler = null; | |
335 | + | |
336 | +function isFunction(input) { | |
337 | + return ( | |
338 | + (typeof Function !== 'undefined' && input instanceof Function) || | |
339 | + Object.prototype.toString.call(input) === '[object Function]' | |
340 | + ); | |
341 | +} | |
342 | + | |
343 | +function set(config) { | |
344 | + var prop, i; | |
345 | + for (i in config) { | |
346 | + if (hasOwnProp(config, i)) { | |
347 | + prop = config[i]; | |
348 | + if (isFunction(prop)) { | |
349 | + this[i] = prop; | |
350 | + } else { | |
351 | + this['_' + i] = prop; | |
352 | + } | |
353 | + } | |
354 | + } | |
355 | + this._config = config; | |
356 | + // Lenient ordinal parsing accepts just a number in addition to | |
357 | + // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. | |
358 | + // TODO: Remove "ordinalParse" fallback in next major release. | |
359 | + this._dayOfMonthOrdinalParseLenient = new RegExp( | |
360 | + (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + | |
361 | + '|' + | |
362 | + /\d{1,2}/.source | |
363 | + ); | |
364 | +} | |
365 | + | |
366 | +function mergeConfigs(parentConfig, childConfig) { | |
367 | + var res = extend({}, parentConfig), | |
368 | + prop; | |
369 | + for (prop in childConfig) { | |
370 | + if (hasOwnProp(childConfig, prop)) { | |
371 | + if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { | |
372 | + res[prop] = {}; | |
373 | + extend(res[prop], parentConfig[prop]); | |
374 | + extend(res[prop], childConfig[prop]); | |
375 | + } else if (childConfig[prop] != null) { | |
376 | + res[prop] = childConfig[prop]; | |
377 | + } else { | |
378 | + delete res[prop]; | |
379 | + } | |
380 | + } | |
381 | + } | |
382 | + for (prop in parentConfig) { | |
383 | + if ( | |
384 | + hasOwnProp(parentConfig, prop) && | |
385 | + !hasOwnProp(childConfig, prop) && | |
386 | + isObject(parentConfig[prop]) | |
387 | + ) { | |
388 | + // make sure changes to properties don't modify parent config | |
389 | + res[prop] = extend({}, res[prop]); | |
390 | + } | |
391 | + } | |
392 | + return res; | |
393 | +} | |
394 | + | |
395 | +function Locale(config) { | |
396 | + if (config != null) { | |
397 | + this.set(config); | |
398 | + } | |
399 | +} | |
400 | + | |
401 | +var keys; | |
402 | + | |
403 | +if (Object.keys) { | |
404 | + keys = Object.keys; | |
405 | +} else { | |
406 | + keys = function (obj) { | |
407 | + var i, | |
408 | + res = []; | |
409 | + for (i in obj) { | |
410 | + if (hasOwnProp(obj, i)) { | |
411 | + res.push(i); | |
412 | + } | |
413 | + } | |
414 | + return res; | |
415 | + }; | |
416 | +} | |
417 | + | |
418 | +var defaultCalendar = { | |
419 | + sameDay: '[Today at] LT', | |
420 | + nextDay: '[Tomorrow at] LT', | |
421 | + nextWeek: 'dddd [at] LT', | |
422 | + lastDay: '[Yesterday at] LT', | |
423 | + lastWeek: '[Last] dddd [at] LT', | |
424 | + sameElse: 'L', | |
425 | +}; | |
426 | + | |
427 | +function calendar(key, mom, now) { | |
428 | + var output = this._calendar[key] || this._calendar['sameElse']; | |
429 | + return isFunction(output) ? output.call(mom, now) : output; | |
430 | +} | |
431 | + | |
432 | +function zeroFill(number, targetLength, forceSign) { | |
433 | + var absNumber = '' + Math.abs(number), | |
434 | + zerosToFill = targetLength - absNumber.length, | |
435 | + sign = number >= 0; | |
436 | + return ( | |
437 | + (sign ? (forceSign ? '+' : '') : '-') + | |
438 | + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + | |
439 | + absNumber | |
440 | + ); | |
441 | +} | |
442 | + | |
443 | +var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, | |
444 | + localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, | |
445 | + formatFunctions = {}, | |
446 | + formatTokenFunctions = {}; | |
447 | + | |
448 | +// token: 'M' | |
449 | +// padded: ['MM', 2] | |
450 | +// ordinal: 'Mo' | |
451 | +// callback: function () { this.month() + 1 } | |
452 | +function addFormatToken(token, padded, ordinal, callback) { | |
453 | + var func = callback; | |
454 | + if (typeof callback === 'string') { | |
455 | + func = function () { | |
456 | + return this[callback](); | |
457 | + }; | |
458 | + } | |
459 | + if (token) { | |
460 | + formatTokenFunctions[token] = func; | |
461 | + } | |
462 | + if (padded) { | |
463 | + formatTokenFunctions[padded[0]] = function () { | |
464 | + return zeroFill(func.apply(this, arguments), padded[1], padded[2]); | |
465 | + }; | |
466 | + } | |
467 | + if (ordinal) { | |
468 | + formatTokenFunctions[ordinal] = function () { | |
469 | + return this.localeData().ordinal( | |
470 | + func.apply(this, arguments), | |
471 | + token | |
472 | + ); | |
473 | + }; | |
474 | + } | |
475 | +} | |
476 | + | |
477 | +function removeFormattingTokens(input) { | |
478 | + if (input.match(/\[[\s\S]/)) { | |
479 | + return input.replace(/^\[|\]$/g, ''); | |
480 | + } | |
481 | + return input.replace(/\\/g, ''); | |
482 | +} | |
483 | + | |
484 | +function makeFormatFunction(format) { | |
485 | + var array = format.match(formattingTokens), | |
486 | + i, | |
487 | + length; | |
488 | + | |
489 | + for (i = 0, length = array.length; i < length; i++) { | |
490 | + if (formatTokenFunctions[array[i]]) { | |
491 | + array[i] = formatTokenFunctions[array[i]]; | |
492 | + } else { | |
493 | + array[i] = removeFormattingTokens(array[i]); | |
494 | + } | |
495 | + } | |
496 | + | |
497 | + return function (mom) { | |
498 | + var output = '', | |
499 | + i; | |
500 | + for (i = 0; i < length; i++) { | |
501 | + output += isFunction(array[i]) | |
502 | + ? array[i].call(mom, format) | |
503 | + : array[i]; | |
504 | + } | |
505 | + return output; | |
506 | + }; | |
507 | +} | |
508 | + | |
509 | +// format date using native date object | |
510 | +function formatMoment(m, format) { | |
511 | + if (!m.isValid()) { | |
512 | + return m.localeData().invalidDate(); | |
513 | + } | |
514 | + | |
515 | + format = expandFormat(format, m.localeData()); | |
516 | + formatFunctions[format] = | |
517 | + formatFunctions[format] || makeFormatFunction(format); | |
518 | + | |
519 | + return formatFunctions[format](m); | |
520 | +} | |
521 | + | |
522 | +function expandFormat(format, locale) { | |
523 | + var i = 5; | |
524 | + | |
525 | + function replaceLongDateFormatTokens(input) { | |
526 | + return locale.longDateFormat(input) || input; | |
527 | + } | |
528 | + | |
529 | + localFormattingTokens.lastIndex = 0; | |
530 | + while (i >= 0 && localFormattingTokens.test(format)) { | |
531 | + format = format.replace( | |
532 | + localFormattingTokens, | |
533 | + replaceLongDateFormatTokens | |
534 | + ); | |
535 | + localFormattingTokens.lastIndex = 0; | |
536 | + i -= 1; | |
537 | + } | |
538 | + | |
539 | + return format; | |
540 | +} | |
541 | + | |
542 | +var defaultLongDateFormat = { | |
543 | + LTS: 'h:mm:ss A', | |
544 | + LT: 'h:mm A', | |
545 | + L: 'MM/DD/YYYY', | |
546 | + LL: 'MMMM D, YYYY', | |
547 | + LLL: 'MMMM D, YYYY h:mm A', | |
548 | + LLLL: 'dddd, MMMM D, YYYY h:mm A', | |
549 | +}; | |
550 | + | |
551 | +function longDateFormat(key) { | |
552 | + var format = this._longDateFormat[key], | |
553 | + formatUpper = this._longDateFormat[key.toUpperCase()]; | |
554 | + | |
555 | + if (format || !formatUpper) { | |
556 | + return format; | |
557 | + } | |
558 | + | |
559 | + this._longDateFormat[key] = formatUpper | |
560 | + .match(formattingTokens) | |
561 | + .map(function (tok) { | |
562 | + if ( | |
563 | + tok === 'MMMM' || | |
564 | + tok === 'MM' || | |
565 | + tok === 'DD' || | |
566 | + tok === 'dddd' | |
567 | + ) { | |
568 | + return tok.slice(1); | |
569 | + } | |
570 | + return tok; | |
571 | + }) | |
572 | + .join(''); | |
573 | + | |
574 | + return this._longDateFormat[key]; | |
575 | +} | |
576 | + | |
577 | +var defaultInvalidDate = 'Invalid date'; | |
578 | + | |
579 | +function invalidDate() { | |
580 | + return this._invalidDate; | |
581 | +} | |
582 | + | |
583 | +var defaultOrdinal = '%d', | |
584 | + defaultDayOfMonthOrdinalParse = /\d{1,2}/; | |
585 | + | |
586 | +function ordinal(number) { | |
587 | + return this._ordinal.replace('%d', number); | |
588 | +} | |
589 | + | |
590 | +var defaultRelativeTime = { | |
591 | + future: 'in %s', | |
592 | + past: '%s ago', | |
593 | + s: 'a few seconds', | |
594 | + ss: '%d seconds', | |
595 | + m: 'a minute', | |
596 | + mm: '%d minutes', | |
597 | + h: 'an hour', | |
598 | + hh: '%d hours', | |
599 | + d: 'a day', | |
600 | + dd: '%d days', | |
601 | + w: 'a week', | |
602 | + ww: '%d weeks', | |
603 | + M: 'a month', | |
604 | + MM: '%d months', | |
605 | + y: 'a year', | |
606 | + yy: '%d years', | |
607 | +}; | |
608 | + | |
609 | +function relativeTime(number, withoutSuffix, string, isFuture) { | |
610 | + var output = this._relativeTime[string]; | |
611 | + return isFunction(output) | |
612 | + ? output(number, withoutSuffix, string, isFuture) | |
613 | + : output.replace(/%d/i, number); | |
614 | +} | |
615 | + | |
616 | +function pastFuture(diff, output) { | |
617 | + var format = this._relativeTime[diff > 0 ? 'future' : 'past']; | |
618 | + return isFunction(format) ? format(output) : format.replace(/%s/i, output); | |
619 | +} | |
620 | + | |
621 | +var aliases = {}; | |
622 | + | |
623 | +function addUnitAlias(unit, shorthand) { | |
624 | + var lowerCase = unit.toLowerCase(); | |
625 | + aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; | |
626 | +} | |
627 | + | |
628 | +function normalizeUnits(units) { | |
629 | + return typeof units === 'string' | |
630 | + ? aliases[units] || aliases[units.toLowerCase()] | |
631 | + : undefined; | |
632 | +} | |
633 | + | |
634 | +function normalizeObjectUnits(inputObject) { | |
635 | + var normalizedInput = {}, | |
636 | + normalizedProp, | |
637 | + prop; | |
638 | + | |
639 | + for (prop in inputObject) { | |
640 | + if (hasOwnProp(inputObject, prop)) { | |
641 | + normalizedProp = normalizeUnits(prop); | |
642 | + if (normalizedProp) { | |
643 | + normalizedInput[normalizedProp] = inputObject[prop]; | |
644 | + } | |
645 | + } | |
646 | + } | |
647 | + | |
648 | + return normalizedInput; | |
649 | +} | |
650 | + | |
651 | +var priorities = {}; | |
652 | + | |
653 | +function addUnitPriority(unit, priority) { | |
654 | + priorities[unit] = priority; | |
655 | +} | |
656 | + | |
657 | +function getPrioritizedUnits(unitsObj) { | |
658 | + var units = [], | |
659 | + u; | |
660 | + for (u in unitsObj) { | |
661 | + if (hasOwnProp(unitsObj, u)) { | |
662 | + units.push({ unit: u, priority: priorities[u] }); | |
663 | + } | |
664 | + } | |
665 | + units.sort(function (a, b) { | |
666 | + return a.priority - b.priority; | |
667 | + }); | |
668 | + return units; | |
669 | +} | |
670 | + | |
671 | +function isLeapYear(year) { | |
672 | + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; | |
673 | +} | |
674 | + | |
675 | +function absFloor(number) { | |
676 | + if (number < 0) { | |
677 | + // -0 -> 0 | |
678 | + return Math.ceil(number) || 0; | |
679 | + } else { | |
680 | + return Math.floor(number); | |
681 | + } | |
682 | +} | |
683 | + | |
684 | +function toInt(argumentForCoercion) { | |
685 | + var coercedNumber = +argumentForCoercion, | |
686 | + value = 0; | |
687 | + | |
688 | + if (coercedNumber !== 0 && isFinite(coercedNumber)) { | |
689 | + value = absFloor(coercedNumber); | |
690 | + } | |
691 | + | |
692 | + return value; | |
693 | +} | |
694 | + | |
695 | +function makeGetSet(unit, keepTime) { | |
696 | + return function (value) { | |
697 | + if (value != null) { | |
698 | + set$1(this, unit, value); | |
699 | + hooks.updateOffset(this, keepTime); | |
700 | + return this; | |
701 | + } else { | |
702 | + return get(this, unit); | |
703 | + } | |
704 | + }; | |
705 | +} | |
706 | + | |
707 | +function get(mom, unit) { | |
708 | + return mom.isValid() | |
709 | + ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() | |
710 | + : NaN; | |
711 | +} | |
712 | + | |
713 | +function set$1(mom, unit, value) { | |
714 | + if (mom.isValid() && !isNaN(value)) { | |
715 | + if ( | |
716 | + unit === 'FullYear' && | |
717 | + isLeapYear(mom.year()) && | |
718 | + mom.month() === 1 && | |
719 | + mom.date() === 29 | |
720 | + ) { | |
721 | + value = toInt(value); | |
722 | + mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit]( | |
723 | + value, | |
724 | + mom.month(), | |
725 | + daysInMonth(value, mom.month()) | |
726 | + ); | |
727 | + } else { | |
728 | + mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); | |
729 | + } | |
730 | + } | |
731 | +} | |
732 | + | |
733 | +// MOMENTS | |
734 | + | |
735 | +function stringGet(units) { | |
736 | + units = normalizeUnits(units); | |
737 | + if (isFunction(this[units])) { | |
738 | + return this[units](); | |
739 | + } | |
740 | + return this; | |
741 | +} | |
742 | + | |
743 | +function stringSet(units, value) { | |
744 | + if (typeof units === 'object') { | |
745 | + units = normalizeObjectUnits(units); | |
746 | + var prioritized = getPrioritizedUnits(units), | |
747 | + i; | |
748 | + for (i = 0; i < prioritized.length; i++) { | |
749 | + this[prioritized[i].unit](units[prioritized[i].unit]); | |
750 | + } | |
751 | + } else { | |
752 | + units = normalizeUnits(units); | |
753 | + if (isFunction(this[units])) { | |
754 | + return this[units](value); | |
755 | + } | |
756 | + } | |
757 | + return this; | |
758 | +} | |
759 | + | |
760 | +var match1 = /\d/, // 0 - 9 | |
761 | + match2 = /\d\d/, // 00 - 99 | |
762 | + match3 = /\d{3}/, // 000 - 999 | |
763 | + match4 = /\d{4}/, // 0000 - 9999 | |
764 | + match6 = /[+-]?\d{6}/, // -999999 - 999999 | |
765 | + match1to2 = /\d\d?/, // 0 - 99 | |
766 | + match3to4 = /\d\d\d\d?/, // 999 - 9999 | |
767 | + match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999 | |
768 | + match1to3 = /\d{1,3}/, // 0 - 999 | |
769 | + match1to4 = /\d{1,4}/, // 0 - 9999 | |
770 | + match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999 | |
771 | + matchUnsigned = /\d+/, // 0 - inf | |
772 | + matchSigned = /[+-]?\d+/, // -inf - inf | |
773 | + matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z | |
774 | + matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z | |
775 | + matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 | |
776 | + // any word (or two) characters or numbers including two/three word month in arabic. | |
777 | + // includes scottish gaelic two word and hyphenated months | |
778 | + matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, | |
779 | + regexes; | |
780 | + | |
781 | +regexes = {}; | |
782 | + | |
783 | +function addRegexToken(token, regex, strictRegex) { | |
784 | + regexes[token] = isFunction(regex) | |
785 | + ? regex | |
786 | + : function (isStrict, localeData) { | |
787 | + return isStrict && strictRegex ? strictRegex : regex; | |
788 | + }; | |
789 | +} | |
790 | + | |
791 | +function getParseRegexForToken(token, config) { | |
792 | + if (!hasOwnProp(regexes, token)) { | |
793 | + return new RegExp(unescapeFormat(token)); | |
794 | + } | |
795 | + | |
796 | + return regexes[token](config._strict, config._locale); | |
797 | +} | |
798 | + | |
799 | +// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript | |
800 | +function unescapeFormat(s) { | |
801 | + return regexEscape( | |
802 | + s | |
803 | + .replace('\\', '') | |
804 | + .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function ( | |
805 | + matched, | |
806 | + p1, | |
807 | + p2, | |
808 | + p3, | |
809 | + p4 | |
810 | + ) { | |
811 | + return p1 || p2 || p3 || p4; | |
812 | + }) | |
813 | + ); | |
814 | +} | |
815 | + | |
816 | +function regexEscape(s) { | |
817 | + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
818 | +} | |
819 | + | |
820 | +var tokens = {}; | |
821 | + | |
822 | +function addParseToken(token, callback) { | |
823 | + var i, | |
824 | + func = callback; | |
825 | + if (typeof token === 'string') { | |
826 | + token = [token]; | |
827 | + } | |
828 | + if (isNumber(callback)) { | |
829 | + func = function (input, array) { | |
830 | + array[callback] = toInt(input); | |
831 | + }; | |
832 | + } | |
833 | + for (i = 0; i < token.length; i++) { | |
834 | + tokens[token[i]] = func; | |
835 | + } | |
836 | +} | |
837 | + | |
838 | +function addWeekParseToken(token, callback) { | |
839 | + addParseToken(token, function (input, array, config, token) { | |
840 | + config._w = config._w || {}; | |
841 | + callback(input, config._w, config, token); | |
842 | + }); | |
843 | +} | |
844 | + | |
845 | +function addTimeToArrayFromToken(token, input, config) { | |
846 | + if (input != null && hasOwnProp(tokens, token)) { | |
847 | + tokens[token](input, config._a, config, token); | |
848 | + } | |
849 | +} | |
850 | + | |
851 | +var YEAR = 0, | |
852 | + MONTH = 1, | |
853 | + DATE = 2, | |
854 | + HOUR = 3, | |
855 | + MINUTE = 4, | |
856 | + SECOND = 5, | |
857 | + MILLISECOND = 6, | |
858 | + WEEK = 7, | |
859 | + WEEKDAY = 8; | |
860 | + | |
861 | +function mod(n, x) { | |
862 | + return ((n % x) + x) % x; | |
863 | +} | |
864 | + | |
865 | +var indexOf; | |
866 | + | |
867 | +if (Array.prototype.indexOf) { | |
868 | + indexOf = Array.prototype.indexOf; | |
869 | +} else { | |
870 | + indexOf = function (o) { | |
871 | + // I know | |
872 | + var i; | |
873 | + for (i = 0; i < this.length; ++i) { | |
874 | + if (this[i] === o) { | |
875 | + return i; | |
876 | + } | |
877 | + } | |
878 | + return -1; | |
879 | + }; | |
880 | +} | |
881 | + | |
882 | +function daysInMonth(year, month) { | |
883 | + if (isNaN(year) || isNaN(month)) { | |
884 | + return NaN; | |
885 | + } | |
886 | + var modMonth = mod(month, 12); | |
887 | + year += (month - modMonth) / 12; | |
888 | + return modMonth === 1 | |
889 | + ? isLeapYear(year) | |
890 | + ? 29 | |
891 | + : 28 | |
892 | + : 31 - ((modMonth % 7) % 2); | |
893 | +} | |
894 | + | |
895 | +// FORMATTING | |
896 | + | |
897 | +addFormatToken('M', ['MM', 2], 'Mo', function () { | |
898 | + return this.month() + 1; | |
899 | +}); | |
900 | + | |
901 | +addFormatToken('MMM', 0, 0, function (format) { | |
902 | + return this.localeData().monthsShort(this, format); | |
903 | +}); | |
904 | + | |
905 | +addFormatToken('MMMM', 0, 0, function (format) { | |
906 | + return this.localeData().months(this, format); | |
907 | +}); | |
908 | + | |
909 | +// ALIASES | |
910 | + | |
911 | +addUnitAlias('month', 'M'); | |
912 | + | |
913 | +// PRIORITY | |
914 | + | |
915 | +addUnitPriority('month', 8); | |
916 | + | |
917 | +// PARSING | |
918 | + | |
919 | +addRegexToken('M', match1to2); | |
920 | +addRegexToken('MM', match1to2, match2); | |
921 | +addRegexToken('MMM', function (isStrict, locale) { | |
922 | + return locale.monthsShortRegex(isStrict); | |
923 | +}); | |
924 | +addRegexToken('MMMM', function (isStrict, locale) { | |
925 | + return locale.monthsRegex(isStrict); | |
926 | +}); | |
927 | + | |
928 | +addParseToken(['M', 'MM'], function (input, array) { | |
929 | + array[MONTH] = toInt(input) - 1; | |
930 | +}); | |
931 | + | |
932 | +addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { | |
933 | + var month = config._locale.monthsParse(input, token, config._strict); | |
934 | + // if we didn't find a month name, mark the date as invalid. | |
935 | + if (month != null) { | |
936 | + array[MONTH] = month; | |
937 | + } else { | |
938 | + getParsingFlags(config).invalidMonth = input; | |
939 | + } | |
940 | +}); | |
941 | + | |
942 | +// LOCALES | |
943 | + | |
944 | +var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split( | |
945 | + '_' | |
946 | + ), | |
947 | + defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split( | |
948 | + '_' | |
949 | + ), | |
950 | + MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, | |
951 | + defaultMonthsShortRegex = matchWord, | |
952 | + defaultMonthsRegex = matchWord; | |
953 | + | |
954 | +function localeMonths(m, format) { | |
955 | + if (!m) { | |
956 | + return isArray(this._months) | |
957 | + ? this._months | |
958 | + : this._months['standalone']; | |
959 | + } | |
960 | + return isArray(this._months) | |
961 | + ? this._months[m.month()] | |
962 | + : this._months[ | |
963 | + (this._months.isFormat || MONTHS_IN_FORMAT).test(format) | |
964 | + ? 'format' | |
965 | + : 'standalone' | |
966 | + ][m.month()]; | |
967 | +} | |
968 | + | |
969 | +function localeMonthsShort(m, format) { | |
970 | + if (!m) { | |
971 | + return isArray(this._monthsShort) | |
972 | + ? this._monthsShort | |
973 | + : this._monthsShort['standalone']; | |
974 | + } | |
975 | + return isArray(this._monthsShort) | |
976 | + ? this._monthsShort[m.month()] | |
977 | + : this._monthsShort[ | |
978 | + MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone' | |
979 | + ][m.month()]; | |
980 | +} | |
981 | + | |
982 | +function handleStrictParse(monthName, format, strict) { | |
983 | + var i, | |
984 | + ii, | |
985 | + mom, | |
986 | + llc = monthName.toLocaleLowerCase(); | |
987 | + if (!this._monthsParse) { | |
988 | + // this is not used | |
989 | + this._monthsParse = []; | |
990 | + this._longMonthsParse = []; | |
991 | + this._shortMonthsParse = []; | |
992 | + for (i = 0; i < 12; ++i) { | |
993 | + mom = createUTC([2000, i]); | |
994 | + this._shortMonthsParse[i] = this.monthsShort( | |
995 | + mom, | |
996 | + '' | |
997 | + ).toLocaleLowerCase(); | |
998 | + this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); | |
999 | + } | |
1000 | + } | |
1001 | + | |
1002 | + if (strict) { | |
1003 | + if (format === 'MMM') { | |
1004 | + ii = indexOf.call(this._shortMonthsParse, llc); | |
1005 | + return ii !== -1 ? ii : null; | |
1006 | + } else { | |
1007 | + ii = indexOf.call(this._longMonthsParse, llc); | |
1008 | + return ii !== -1 ? ii : null; | |
1009 | + } | |
1010 | + } else { | |
1011 | + if (format === 'MMM') { | |
1012 | + ii = indexOf.call(this._shortMonthsParse, llc); | |
1013 | + if (ii !== -1) { | |
1014 | + return ii; | |
1015 | + } | |
1016 | + ii = indexOf.call(this._longMonthsParse, llc); | |
1017 | + return ii !== -1 ? ii : null; | |
1018 | + } else { | |
1019 | + ii = indexOf.call(this._longMonthsParse, llc); | |
1020 | + if (ii !== -1) { | |
1021 | + return ii; | |
1022 | + } | |
1023 | + ii = indexOf.call(this._shortMonthsParse, llc); | |
1024 | + return ii !== -1 ? ii : null; | |
1025 | + } | |
1026 | + } | |
1027 | +} | |
1028 | + | |
1029 | +function localeMonthsParse(monthName, format, strict) { | |
1030 | + var i, mom, regex; | |
1031 | + | |
1032 | + if (this._monthsParseExact) { | |
1033 | + return handleStrictParse.call(this, monthName, format, strict); | |
1034 | + } | |
1035 | + | |
1036 | + if (!this._monthsParse) { | |
1037 | + this._monthsParse = []; | |
1038 | + this._longMonthsParse = []; | |
1039 | + this._shortMonthsParse = []; | |
1040 | + } | |
1041 | + | |
1042 | + // TODO: add sorting | |
1043 | + // Sorting makes sure if one month (or abbr) is a prefix of another | |
1044 | + // see sorting in computeMonthsParse | |
1045 | + for (i = 0; i < 12; i++) { | |
1046 | + // make the regex if we don't have it already | |
1047 | + mom = createUTC([2000, i]); | |
1048 | + if (strict && !this._longMonthsParse[i]) { | |
1049 | + this._longMonthsParse[i] = new RegExp( | |
1050 | + '^' + this.months(mom, '').replace('.', '') + '$', | |
1051 | + 'i' | |
1052 | + ); | |
1053 | + this._shortMonthsParse[i] = new RegExp( | |
1054 | + '^' + this.monthsShort(mom, '').replace('.', '') + '$', | |
1055 | + 'i' | |
1056 | + ); | |
1057 | + } | |
1058 | + if (!strict && !this._monthsParse[i]) { | |
1059 | + regex = | |
1060 | + '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); | |
1061 | + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); | |
1062 | + } | |
1063 | + // test the regex | |
1064 | + if ( | |
1065 | + strict && | |
1066 | + format === 'MMMM' && | |
1067 | + this._longMonthsParse[i].test(monthName) | |
1068 | + ) { | |
1069 | + return i; | |
1070 | + } else if ( | |
1071 | + strict && | |
1072 | + format === 'MMM' && | |
1073 | + this._shortMonthsParse[i].test(monthName) | |
1074 | + ) { | |
1075 | + return i; | |
1076 | + } else if (!strict && this._monthsParse[i].test(monthName)) { | |
1077 | + return i; | |
1078 | + } | |
1079 | + } | |
1080 | +} | |
1081 | + | |
1082 | +// MOMENTS | |
1083 | + | |
1084 | +function setMonth(mom, value) { | |
1085 | + var dayOfMonth; | |
1086 | + | |
1087 | + if (!mom.isValid()) { | |
1088 | + // No op | |
1089 | + return mom; | |
1090 | + } | |
1091 | + | |
1092 | + if (typeof value === 'string') { | |
1093 | + if (/^\d+$/.test(value)) { | |
1094 | + value = toInt(value); | |
1095 | + } else { | |
1096 | + value = mom.localeData().monthsParse(value); | |
1097 | + // TODO: Another silent failure? | |
1098 | + if (!isNumber(value)) { | |
1099 | + return mom; | |
1100 | + } | |
1101 | + } | |
1102 | + } | |
1103 | + | |
1104 | + dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); | |
1105 | + mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); | |
1106 | + return mom; | |
1107 | +} | |
1108 | + | |
1109 | +function getSetMonth(value) { | |
1110 | + if (value != null) { | |
1111 | + setMonth(this, value); | |
1112 | + hooks.updateOffset(this, true); | |
1113 | + return this; | |
1114 | + } else { | |
1115 | + return get(this, 'Month'); | |
1116 | + } | |
1117 | +} | |
1118 | + | |
1119 | +function getDaysInMonth() { | |
1120 | + return daysInMonth(this.year(), this.month()); | |
1121 | +} | |
1122 | + | |
1123 | +function monthsShortRegex(isStrict) { | |
1124 | + if (this._monthsParseExact) { | |
1125 | + if (!hasOwnProp(this, '_monthsRegex')) { | |
1126 | + computeMonthsParse.call(this); | |
1127 | + } | |
1128 | + if (isStrict) { | |
1129 | + return this._monthsShortStrictRegex; | |
1130 | + } else { | |
1131 | + return this._monthsShortRegex; | |
1132 | + } | |
1133 | + } else { | |
1134 | + if (!hasOwnProp(this, '_monthsShortRegex')) { | |
1135 | + this._monthsShortRegex = defaultMonthsShortRegex; | |
1136 | + } | |
1137 | + return this._monthsShortStrictRegex && isStrict | |
1138 | + ? this._monthsShortStrictRegex | |
1139 | + : this._monthsShortRegex; | |
1140 | + } | |
1141 | +} | |
1142 | + | |
1143 | +function monthsRegex(isStrict) { | |
1144 | + if (this._monthsParseExact) { | |
1145 | + if (!hasOwnProp(this, '_monthsRegex')) { | |
1146 | + computeMonthsParse.call(this); | |
1147 | + } | |
1148 | + if (isStrict) { | |
1149 | + return this._monthsStrictRegex; | |
1150 | + } else { | |
1151 | + return this._monthsRegex; | |
1152 | + } | |
1153 | + } else { | |
1154 | + if (!hasOwnProp(this, '_monthsRegex')) { | |
1155 | + this._monthsRegex = defaultMonthsRegex; | |
1156 | + } | |
1157 | + return this._monthsStrictRegex && isStrict | |
1158 | + ? this._monthsStrictRegex | |
1159 | + : this._monthsRegex; | |
1160 | + } | |
1161 | +} | |
1162 | + | |
1163 | +function computeMonthsParse() { | |
1164 | + function cmpLenRev(a, b) { | |
1165 | + return b.length - a.length; | |
1166 | + } | |
1167 | + | |
1168 | + var shortPieces = [], | |
1169 | + longPieces = [], | |
1170 | + mixedPieces = [], | |
1171 | + i, | |
1172 | + mom; | |
1173 | + for (i = 0; i < 12; i++) { | |
1174 | + // make the regex if we don't have it already | |
1175 | + mom = createUTC([2000, i]); | |
1176 | + shortPieces.push(this.monthsShort(mom, '')); | |
1177 | + longPieces.push(this.months(mom, '')); | |
1178 | + mixedPieces.push(this.months(mom, '')); | |
1179 | + mixedPieces.push(this.monthsShort(mom, '')); | |
1180 | + } | |
1181 | + // Sorting makes sure if one month (or abbr) is a prefix of another it | |
1182 | + // will match the longer piece. | |
1183 | + shortPieces.sort(cmpLenRev); | |
1184 | + longPieces.sort(cmpLenRev); | |
1185 | + mixedPieces.sort(cmpLenRev); | |
1186 | + for (i = 0; i < 12; i++) { | |
1187 | + shortPieces[i] = regexEscape(shortPieces[i]); | |
1188 | + longPieces[i] = regexEscape(longPieces[i]); | |
1189 | + } | |
1190 | + for (i = 0; i < 24; i++) { | |
1191 | + mixedPieces[i] = regexEscape(mixedPieces[i]); | |
1192 | + } | |
1193 | + | |
1194 | + this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); | |
1195 | + this._monthsShortRegex = this._monthsRegex; | |
1196 | + this._monthsStrictRegex = new RegExp( | |
1197 | + '^(' + longPieces.join('|') + ')', | |
1198 | + 'i' | |
1199 | + ); | |
1200 | + this._monthsShortStrictRegex = new RegExp( | |
1201 | + '^(' + shortPieces.join('|') + ')', | |
1202 | + 'i' | |
1203 | + ); | |
1204 | +} | |
1205 | + | |
1206 | +// FORMATTING | |
1207 | + | |
1208 | +addFormatToken('Y', 0, 0, function () { | |
1209 | + var y = this.year(); | |
1210 | + return y <= 9999 ? zeroFill(y, 4) : '+' + y; | |
1211 | +}); | |
1212 | + | |
1213 | +addFormatToken(0, ['YY', 2], 0, function () { | |
1214 | + return this.year() % 100; | |
1215 | +}); | |
1216 | + | |
1217 | +addFormatToken(0, ['YYYY', 4], 0, 'year'); | |
1218 | +addFormatToken(0, ['YYYYY', 5], 0, 'year'); | |
1219 | +addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); | |
1220 | + | |
1221 | +// ALIASES | |
1222 | + | |
1223 | +addUnitAlias('year', 'y'); | |
1224 | + | |
1225 | +// PRIORITIES | |
1226 | + | |
1227 | +addUnitPriority('year', 1); | |
1228 | + | |
1229 | +// PARSING | |
1230 | + | |
1231 | +addRegexToken('Y', matchSigned); | |
1232 | +addRegexToken('YY', match1to2, match2); | |
1233 | +addRegexToken('YYYY', match1to4, match4); | |
1234 | +addRegexToken('YYYYY', match1to6, match6); | |
1235 | +addRegexToken('YYYYYY', match1to6, match6); | |
1236 | + | |
1237 | +addParseToken(['YYYYY', 'YYYYYY'], YEAR); | |
1238 | +addParseToken('YYYY', function (input, array) { | |
1239 | + array[YEAR] = | |
1240 | + input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); | |
1241 | +}); | |
1242 | +addParseToken('YY', function (input, array) { | |
1243 | + array[YEAR] = hooks.parseTwoDigitYear(input); | |
1244 | +}); | |
1245 | +addParseToken('Y', function (input, array) { | |
1246 | + array[YEAR] = parseInt(input, 10); | |
1247 | +}); | |
1248 | + | |
1249 | +// HELPERS | |
1250 | + | |
1251 | +function daysInYear(year) { | |
1252 | + return isLeapYear(year) ? 366 : 365; | |
1253 | +} | |
1254 | + | |
1255 | +// HOOKS | |
1256 | + | |
1257 | +hooks.parseTwoDigitYear = function (input) { | |
1258 | + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); | |
1259 | +}; | |
1260 | + | |
1261 | +// MOMENTS | |
1262 | + | |
1263 | +var getSetYear = makeGetSet('FullYear', true); | |
1264 | + | |
1265 | +function getIsLeapYear() { | |
1266 | + return isLeapYear(this.year()); | |
1267 | +} | |
1268 | + | |
1269 | +function createDate(y, m, d, h, M, s, ms) { | |
1270 | + // can't just apply() to create a date: | |
1271 | + // https://stackoverflow.com/q/181348 | |
1272 | + var date; | |
1273 | + // the date constructor remaps years 0-99 to 1900-1999 | |
1274 | + if (y < 100 && y >= 0) { | |
1275 | + // preserve leap years using a full 400 year cycle, then reset | |
1276 | + date = new Date(y + 400, m, d, h, M, s, ms); | |
1277 | + if (isFinite(date.getFullYear())) { | |
1278 | + date.setFullYear(y); | |
1279 | + } | |
1280 | + } else { | |
1281 | + date = new Date(y, m, d, h, M, s, ms); | |
1282 | + } | |
1283 | + | |
1284 | + return date; | |
1285 | +} | |
1286 | + | |
1287 | +function createUTCDate(y) { | |
1288 | + var date, args; | |
1289 | + // the Date.UTC function remaps years 0-99 to 1900-1999 | |
1290 | + if (y < 100 && y >= 0) { | |
1291 | + args = Array.prototype.slice.call(arguments); | |
1292 | + // preserve leap years using a full 400 year cycle, then reset | |
1293 | + args[0] = y + 400; | |
1294 | + date = new Date(Date.UTC.apply(null, args)); | |
1295 | + if (isFinite(date.getUTCFullYear())) { | |
1296 | + date.setUTCFullYear(y); | |
1297 | + } | |
1298 | + } else { | |
1299 | + date = new Date(Date.UTC.apply(null, arguments)); | |
1300 | + } | |
1301 | + | |
1302 | + return date; | |
1303 | +} | |
1304 | + | |
1305 | +// start-of-first-week - start-of-year | |
1306 | +function firstWeekOffset(year, dow, doy) { | |
1307 | + var // first-week day -- which january is always in the first week (4 for iso, 1 for other) | |
1308 | + fwd = 7 + dow - doy, | |
1309 | + // first-week day local weekday -- which local weekday is fwd | |
1310 | + fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; | |
1311 | + | |
1312 | + return -fwdlw + fwd - 1; | |
1313 | +} | |
1314 | + | |
1315 | +// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday | |
1316 | +function dayOfYearFromWeeks(year, week, weekday, dow, doy) { | |
1317 | + var localWeekday = (7 + weekday - dow) % 7, | |
1318 | + weekOffset = firstWeekOffset(year, dow, doy), | |
1319 | + dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, | |
1320 | + resYear, | |
1321 | + resDayOfYear; | |
1322 | + | |
1323 | + if (dayOfYear <= 0) { | |
1324 | + resYear = year - 1; | |
1325 | + resDayOfYear = daysInYear(resYear) + dayOfYear; | |
1326 | + } else if (dayOfYear > daysInYear(year)) { | |
1327 | + resYear = year + 1; | |
1328 | + resDayOfYear = dayOfYear - daysInYear(year); | |
1329 | + } else { | |
1330 | + resYear = year; | |
1331 | + resDayOfYear = dayOfYear; | |
1332 | + } | |
1333 | + | |
1334 | + return { | |
1335 | + year: resYear, | |
1336 | + dayOfYear: resDayOfYear, | |
1337 | + }; | |
1338 | +} | |
1339 | + | |
1340 | +function weekOfYear(mom, dow, doy) { | |
1341 | + var weekOffset = firstWeekOffset(mom.year(), dow, doy), | |
1342 | + week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, | |
1343 | + resWeek, | |
1344 | + resYear; | |
1345 | + | |
1346 | + if (week < 1) { | |
1347 | + resYear = mom.year() - 1; | |
1348 | + resWeek = week + weeksInYear(resYear, dow, doy); | |
1349 | + } else if (week > weeksInYear(mom.year(), dow, doy)) { | |
1350 | + resWeek = week - weeksInYear(mom.year(), dow, doy); | |
1351 | + resYear = mom.year() + 1; | |
1352 | + } else { | |
1353 | + resYear = mom.year(); | |
1354 | + resWeek = week; | |
1355 | + } | |
1356 | + | |
1357 | + return { | |
1358 | + week: resWeek, | |
1359 | + year: resYear, | |
1360 | + }; | |
1361 | +} | |
1362 | + | |
1363 | +function weeksInYear(year, dow, doy) { | |
1364 | + var weekOffset = firstWeekOffset(year, dow, doy), | |
1365 | + weekOffsetNext = firstWeekOffset(year + 1, dow, doy); | |
1366 | + return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; | |
1367 | +} | |
1368 | + | |
1369 | +// FORMATTING | |
1370 | + | |
1371 | +addFormatToken('w', ['ww', 2], 'wo', 'week'); | |
1372 | +addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); | |
1373 | + | |
1374 | +// ALIASES | |
1375 | + | |
1376 | +addUnitAlias('week', 'w'); | |
1377 | +addUnitAlias('isoWeek', 'W'); | |
1378 | + | |
1379 | +// PRIORITIES | |
1380 | + | |
1381 | +addUnitPriority('week', 5); | |
1382 | +addUnitPriority('isoWeek', 5); | |
1383 | + | |
1384 | +// PARSING | |
1385 | + | |
1386 | +addRegexToken('w', match1to2); | |
1387 | +addRegexToken('ww', match1to2, match2); | |
1388 | +addRegexToken('W', match1to2); | |
1389 | +addRegexToken('WW', match1to2, match2); | |
1390 | + | |
1391 | +addWeekParseToken(['w', 'ww', 'W', 'WW'], function ( | |
1392 | + input, | |
1393 | + week, | |
1394 | + config, | |
1395 | + token | |
1396 | +) { | |
1397 | + week[token.substr(0, 1)] = toInt(input); | |
1398 | +}); | |
1399 | + | |
1400 | +// HELPERS | |
1401 | + | |
1402 | +// LOCALES | |
1403 | + | |
1404 | +function localeWeek(mom) { | |
1405 | + return weekOfYear(mom, this._week.dow, this._week.doy).week; | |
1406 | +} | |
1407 | + | |
1408 | +var defaultLocaleWeek = { | |
1409 | + dow: 0, // Sunday is the first day of the week. | |
1410 | + doy: 6, // The week that contains Jan 6th is the first week of the year. | |
1411 | +}; | |
1412 | + | |
1413 | +function localeFirstDayOfWeek() { | |
1414 | + return this._week.dow; | |
1415 | +} | |
1416 | + | |
1417 | +function localeFirstDayOfYear() { | |
1418 | + return this._week.doy; | |
1419 | +} | |
1420 | + | |
1421 | +// MOMENTS | |
1422 | + | |
1423 | +function getSetWeek(input) { | |
1424 | + var week = this.localeData().week(this); | |
1425 | + return input == null ? week : this.add((input - week) * 7, 'd'); | |
1426 | +} | |
1427 | + | |
1428 | +function getSetISOWeek(input) { | |
1429 | + var week = weekOfYear(this, 1, 4).week; | |
1430 | + return input == null ? week : this.add((input - week) * 7, 'd'); | |
1431 | +} | |
1432 | + | |
1433 | +// FORMATTING | |
1434 | + | |
1435 | +addFormatToken('d', 0, 'do', 'day'); | |
1436 | + | |
1437 | +addFormatToken('dd', 0, 0, function (format) { | |
1438 | + return this.localeData().weekdaysMin(this, format); | |
1439 | +}); | |
1440 | + | |
1441 | +addFormatToken('ddd', 0, 0, function (format) { | |
1442 | + return this.localeData().weekdaysShort(this, format); | |
1443 | +}); | |
1444 | + | |
1445 | +addFormatToken('dddd', 0, 0, function (format) { | |
1446 | + return this.localeData().weekdays(this, format); | |
1447 | +}); | |
1448 | + | |
1449 | +addFormatToken('e', 0, 0, 'weekday'); | |
1450 | +addFormatToken('E', 0, 0, 'isoWeekday'); | |
1451 | + | |
1452 | +// ALIASES | |
1453 | + | |
1454 | +addUnitAlias('day', 'd'); | |
1455 | +addUnitAlias('weekday', 'e'); | |
1456 | +addUnitAlias('isoWeekday', 'E'); | |
1457 | + | |
1458 | +// PRIORITY | |
1459 | +addUnitPriority('day', 11); | |
1460 | +addUnitPriority('weekday', 11); | |
1461 | +addUnitPriority('isoWeekday', 11); | |
1462 | + | |
1463 | +// PARSING | |
1464 | + | |
1465 | +addRegexToken('d', match1to2); | |
1466 | +addRegexToken('e', match1to2); | |
1467 | +addRegexToken('E', match1to2); | |
1468 | +addRegexToken('dd', function (isStrict, locale) { | |
1469 | + return locale.weekdaysMinRegex(isStrict); | |
1470 | +}); | |
1471 | +addRegexToken('ddd', function (isStrict, locale) { | |
1472 | + return locale.weekdaysShortRegex(isStrict); | |
1473 | +}); | |
1474 | +addRegexToken('dddd', function (isStrict, locale) { | |
1475 | + return locale.weekdaysRegex(isStrict); | |
1476 | +}); | |
1477 | + | |
1478 | +addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { | |
1479 | + var weekday = config._locale.weekdaysParse(input, token, config._strict); | |
1480 | + // if we didn't get a weekday name, mark the date as invalid | |
1481 | + if (weekday != null) { | |
1482 | + week.d = weekday; | |
1483 | + } else { | |
1484 | + getParsingFlags(config).invalidWeekday = input; | |
1485 | + } | |
1486 | +}); | |
1487 | + | |
1488 | +addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { | |
1489 | + week[token] = toInt(input); | |
1490 | +}); | |
1491 | + | |
1492 | +// HELPERS | |
1493 | + | |
1494 | +function parseWeekday(input, locale) { | |
1495 | + if (typeof input !== 'string') { | |
1496 | + return input; | |
1497 | + } | |
1498 | + | |
1499 | + if (!isNaN(input)) { | |
1500 | + return parseInt(input, 10); | |
1501 | + } | |
1502 | + | |
1503 | + input = locale.weekdaysParse(input); | |
1504 | + if (typeof input === 'number') { | |
1505 | + return input; | |
1506 | + } | |
1507 | + | |
1508 | + return null; | |
1509 | +} | |
1510 | + | |
1511 | +function parseIsoWeekday(input, locale) { | |
1512 | + if (typeof input === 'string') { | |
1513 | + return locale.weekdaysParse(input) % 7 || 7; | |
1514 | + } | |
1515 | + return isNaN(input) ? null : input; | |
1516 | +} | |
1517 | + | |
1518 | +// LOCALES | |
1519 | +function shiftWeekdays(ws, n) { | |
1520 | + return ws.slice(n, 7).concat(ws.slice(0, n)); | |
1521 | +} | |
1522 | + | |
1523 | +var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split( | |
1524 | + '_' | |
1525 | + ), | |
1526 | + defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), | |
1527 | + defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), | |
1528 | + defaultWeekdaysRegex = matchWord, | |
1529 | + defaultWeekdaysShortRegex = matchWord, | |
1530 | + defaultWeekdaysMinRegex = matchWord; | |
1531 | + | |
1532 | +function localeWeekdays(m, format) { | |
1533 | + var weekdays = isArray(this._weekdays) | |
1534 | + ? this._weekdays | |
1535 | + : this._weekdays[ | |
1536 | + m && m !== true && this._weekdays.isFormat.test(format) | |
1537 | + ? 'format' | |
1538 | + : 'standalone' | |
1539 | + ]; | |
1540 | + return m === true | |
1541 | + ? shiftWeekdays(weekdays, this._week.dow) | |
1542 | + : m | |
1543 | + ? weekdays[m.day()] | |
1544 | + : weekdays; | |
1545 | +} | |
1546 | + | |
1547 | +function localeWeekdaysShort(m) { | |
1548 | + return m === true | |
1549 | + ? shiftWeekdays(this._weekdaysShort, this._week.dow) | |
1550 | + : m | |
1551 | + ? this._weekdaysShort[m.day()] | |
1552 | + : this._weekdaysShort; | |
1553 | +} | |
1554 | + | |
1555 | +function localeWeekdaysMin(m) { | |
1556 | + return m === true | |
1557 | + ? shiftWeekdays(this._weekdaysMin, this._week.dow) | |
1558 | + : m | |
1559 | + ? this._weekdaysMin[m.day()] | |
1560 | + : this._weekdaysMin; | |
1561 | +} | |
1562 | + | |
1563 | +function handleStrictParse$1(weekdayName, format, strict) { | |
1564 | + var i, | |
1565 | + ii, | |
1566 | + mom, | |
1567 | + llc = weekdayName.toLocaleLowerCase(); | |
1568 | + if (!this._weekdaysParse) { | |
1569 | + this._weekdaysParse = []; | |
1570 | + this._shortWeekdaysParse = []; | |
1571 | + this._minWeekdaysParse = []; | |
1572 | + | |
1573 | + for (i = 0; i < 7; ++i) { | |
1574 | + mom = createUTC([2000, 1]).day(i); | |
1575 | + this._minWeekdaysParse[i] = this.weekdaysMin( | |
1576 | + mom, | |
1577 | + '' | |
1578 | + ).toLocaleLowerCase(); | |
1579 | + this._shortWeekdaysParse[i] = this.weekdaysShort( | |
1580 | + mom, | |
1581 | + '' | |
1582 | + ).toLocaleLowerCase(); | |
1583 | + this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); | |
1584 | + } | |
1585 | + } | |
1586 | + | |
1587 | + if (strict) { | |
1588 | + if (format === 'dddd') { | |
1589 | + ii = indexOf.call(this._weekdaysParse, llc); | |
1590 | + return ii !== -1 ? ii : null; | |
1591 | + } else if (format === 'ddd') { | |
1592 | + ii = indexOf.call(this._shortWeekdaysParse, llc); | |
1593 | + return ii !== -1 ? ii : null; | |
1594 | + } else { | |
1595 | + ii = indexOf.call(this._minWeekdaysParse, llc); | |
1596 | + return ii !== -1 ? ii : null; | |
1597 | + } | |
1598 | + } else { | |
1599 | + if (format === 'dddd') { | |
1600 | + ii = indexOf.call(this._weekdaysParse, llc); | |
1601 | + if (ii !== -1) { | |
1602 | + return ii; | |
1603 | + } | |
1604 | + ii = indexOf.call(this._shortWeekdaysParse, llc); | |
1605 | + if (ii !== -1) { | |
1606 | + return ii; | |
1607 | + } | |
1608 | + ii = indexOf.call(this._minWeekdaysParse, llc); | |
1609 | + return ii !== -1 ? ii : null; | |
1610 | + } else if (format === 'ddd') { | |
1611 | + ii = indexOf.call(this._shortWeekdaysParse, llc); | |
1612 | + if (ii !== -1) { | |
1613 | + return ii; | |
1614 | + } | |
1615 | + ii = indexOf.call(this._weekdaysParse, llc); | |
1616 | + if (ii !== -1) { | |
1617 | + return ii; | |
1618 | + } | |
1619 | + ii = indexOf.call(this._minWeekdaysParse, llc); | |
1620 | + return ii !== -1 ? ii : null; | |
1621 | + } else { | |
1622 | + ii = indexOf.call(this._minWeekdaysParse, llc); | |
1623 | + if (ii !== -1) { | |
1624 | + return ii; | |
1625 | + } | |
1626 | + ii = indexOf.call(this._weekdaysParse, llc); | |
1627 | + if (ii !== -1) { | |
1628 | + return ii; | |
1629 | + } | |
1630 | + ii = indexOf.call(this._shortWeekdaysParse, llc); | |
1631 | + return ii !== -1 ? ii : null; | |
1632 | + } | |
1633 | + } | |
1634 | +} | |
1635 | + | |
1636 | +function localeWeekdaysParse(weekdayName, format, strict) { | |
1637 | + var i, mom, regex; | |
1638 | + | |
1639 | + if (this._weekdaysParseExact) { | |
1640 | + return handleStrictParse$1.call(this, weekdayName, format, strict); | |
1641 | + } | |
1642 | + | |
1643 | + if (!this._weekdaysParse) { | |
1644 | + this._weekdaysParse = []; | |
1645 | + this._minWeekdaysParse = []; | |
1646 | + this._shortWeekdaysParse = []; | |
1647 | + this._fullWeekdaysParse = []; | |
1648 | + } | |
1649 | + | |
1650 | + for (i = 0; i < 7; i++) { | |
1651 | + // make the regex if we don't have it already | |
1652 | + | |
1653 | + mom = createUTC([2000, 1]).day(i); | |
1654 | + if (strict && !this._fullWeekdaysParse[i]) { | |
1655 | + this._fullWeekdaysParse[i] = new RegExp( | |
1656 | + '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', | |
1657 | + 'i' | |
1658 | + ); | |
1659 | + this._shortWeekdaysParse[i] = new RegExp( | |
1660 | + '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', | |
1661 | + 'i' | |
1662 | + ); | |
1663 | + this._minWeekdaysParse[i] = new RegExp( | |
1664 | + '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', | |
1665 | + 'i' | |
1666 | + ); | |
1667 | + } | |
1668 | + if (!this._weekdaysParse[i]) { | |
1669 | + regex = | |
1670 | + '^' + | |
1671 | + this.weekdays(mom, '') + | |
1672 | + '|^' + | |
1673 | + this.weekdaysShort(mom, '') + | |
1674 | + '|^' + | |
1675 | + this.weekdaysMin(mom, ''); | |
1676 | + this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); | |
1677 | + } | |
1678 | + // test the regex | |
1679 | + if ( | |
1680 | + strict && | |
1681 | + format === 'dddd' && | |
1682 | + this._fullWeekdaysParse[i].test(weekdayName) | |
1683 | + ) { | |
1684 | + return i; | |
1685 | + } else if ( | |
1686 | + strict && | |
1687 | + format === 'ddd' && | |
1688 | + this._shortWeekdaysParse[i].test(weekdayName) | |
1689 | + ) { | |
1690 | + return i; | |
1691 | + } else if ( | |
1692 | + strict && | |
1693 | + format === 'dd' && | |
1694 | + this._minWeekdaysParse[i].test(weekdayName) | |
1695 | + ) { | |
1696 | + return i; | |
1697 | + } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { | |
1698 | + return i; | |
1699 | + } | |
1700 | + } | |
1701 | +} | |
1702 | + | |
1703 | +// MOMENTS | |
1704 | + | |
1705 | +function getSetDayOfWeek(input) { | |
1706 | + if (!this.isValid()) { | |
1707 | + return input != null ? this : NaN; | |
1708 | + } | |
1709 | + var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); | |
1710 | + if (input != null) { | |
1711 | + input = parseWeekday(input, this.localeData()); | |
1712 | + return this.add(input - day, 'd'); | |
1713 | + } else { | |
1714 | + return day; | |
1715 | + } | |
1716 | +} | |
1717 | + | |
1718 | +function getSetLocaleDayOfWeek(input) { | |
1719 | + if (!this.isValid()) { | |
1720 | + return input != null ? this : NaN; | |
1721 | + } | |
1722 | + var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; | |
1723 | + return input == null ? weekday : this.add(input - weekday, 'd'); | |
1724 | +} | |
1725 | + | |
1726 | +function getSetISODayOfWeek(input) { | |
1727 | + if (!this.isValid()) { | |
1728 | + return input != null ? this : NaN; | |
1729 | + } | |
1730 | + | |
1731 | + // behaves the same as moment#day except | |
1732 | + // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) | |
1733 | + // as a setter, sunday should belong to the previous week. | |
1734 | + | |
1735 | + if (input != null) { | |
1736 | + var weekday = parseIsoWeekday(input, this.localeData()); | |
1737 | + return this.day(this.day() % 7 ? weekday : weekday - 7); | |
1738 | + } else { | |
1739 | + return this.day() || 7; | |
1740 | + } | |
1741 | +} | |
1742 | + | |
1743 | +function weekdaysRegex(isStrict) { | |
1744 | + if (this._weekdaysParseExact) { | |
1745 | + if (!hasOwnProp(this, '_weekdaysRegex')) { | |
1746 | + computeWeekdaysParse.call(this); | |
1747 | + } | |
1748 | + if (isStrict) { | |
1749 | + return this._weekdaysStrictRegex; | |
1750 | + } else { | |
1751 | + return this._weekdaysRegex; | |
1752 | + } | |
1753 | + } else { | |
1754 | + if (!hasOwnProp(this, '_weekdaysRegex')) { | |
1755 | + this._weekdaysRegex = defaultWeekdaysRegex; | |
1756 | + } | |
1757 | + return this._weekdaysStrictRegex && isStrict | |
1758 | + ? this._weekdaysStrictRegex | |
1759 | + : this._weekdaysRegex; | |
1760 | + } | |
1761 | +} | |
1762 | + | |
1763 | +function weekdaysShortRegex(isStrict) { | |
1764 | + if (this._weekdaysParseExact) { | |
1765 | + if (!hasOwnProp(this, '_weekdaysRegex')) { | |
1766 | + computeWeekdaysParse.call(this); | |
1767 | + } | |
1768 | + if (isStrict) { | |
1769 | + return this._weekdaysShortStrictRegex; | |
1770 | + } else { | |
1771 | + return this._weekdaysShortRegex; | |
1772 | + } | |
1773 | + } else { | |
1774 | + if (!hasOwnProp(this, '_weekdaysShortRegex')) { | |
1775 | + this._weekdaysShortRegex = defaultWeekdaysShortRegex; | |
1776 | + } | |
1777 | + return this._weekdaysShortStrictRegex && isStrict | |
1778 | + ? this._weekdaysShortStrictRegex | |
1779 | + : this._weekdaysShortRegex; | |
1780 | + } | |
1781 | +} | |
1782 | + | |
1783 | +function weekdaysMinRegex(isStrict) { | |
1784 | + if (this._weekdaysParseExact) { | |
1785 | + if (!hasOwnProp(this, '_weekdaysRegex')) { | |
1786 | + computeWeekdaysParse.call(this); | |
1787 | + } | |
1788 | + if (isStrict) { | |
1789 | + return this._weekdaysMinStrictRegex; | |
1790 | + } else { | |
1791 | + return this._weekdaysMinRegex; | |
1792 | + } | |
1793 | + } else { | |
1794 | + if (!hasOwnProp(this, '_weekdaysMinRegex')) { | |
1795 | + this._weekdaysMinRegex = defaultWeekdaysMinRegex; | |
1796 | + } | |
1797 | + return this._weekdaysMinStrictRegex && isStrict | |
1798 | + ? this._weekdaysMinStrictRegex | |
1799 | + : this._weekdaysMinRegex; | |
1800 | + } | |
1801 | +} | |
1802 | + | |
1803 | +function computeWeekdaysParse() { | |
1804 | + function cmpLenRev(a, b) { | |
1805 | + return b.length - a.length; | |
1806 | + } | |
1807 | + | |
1808 | + var minPieces = [], | |
1809 | + shortPieces = [], | |
1810 | + longPieces = [], | |
1811 | + mixedPieces = [], | |
1812 | + i, | |
1813 | + mom, | |
1814 | + minp, | |
1815 | + shortp, | |
1816 | + longp; | |
1817 | + for (i = 0; i < 7; i++) { | |
1818 | + // make the regex if we don't have it already | |
1819 | + mom = createUTC([2000, 1]).day(i); | |
1820 | + minp = regexEscape(this.weekdaysMin(mom, '')); | |
1821 | + shortp = regexEscape(this.weekdaysShort(mom, '')); | |
1822 | + longp = regexEscape(this.weekdays(mom, '')); | |
1823 | + minPieces.push(minp); | |
1824 | + shortPieces.push(shortp); | |
1825 | + longPieces.push(longp); | |
1826 | + mixedPieces.push(minp); | |
1827 | + mixedPieces.push(shortp); | |
1828 | + mixedPieces.push(longp); | |
1829 | + } | |
1830 | + // Sorting makes sure if one weekday (or abbr) is a prefix of another it | |
1831 | + // will match the longer piece. | |
1832 | + minPieces.sort(cmpLenRev); | |
1833 | + shortPieces.sort(cmpLenRev); | |
1834 | + longPieces.sort(cmpLenRev); | |
1835 | + mixedPieces.sort(cmpLenRev); | |
1836 | + | |
1837 | + this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); | |
1838 | + this._weekdaysShortRegex = this._weekdaysRegex; | |
1839 | + this._weekdaysMinRegex = this._weekdaysRegex; | |
1840 | + | |
1841 | + this._weekdaysStrictRegex = new RegExp( | |
1842 | + '^(' + longPieces.join('|') + ')', | |
1843 | + 'i' | |
1844 | + ); | |
1845 | + this._weekdaysShortStrictRegex = new RegExp( | |
1846 | + '^(' + shortPieces.join('|') + ')', | |
1847 | + 'i' | |
1848 | + ); | |
1849 | + this._weekdaysMinStrictRegex = new RegExp( | |
1850 | + '^(' + minPieces.join('|') + ')', | |
1851 | + 'i' | |
1852 | + ); | |
1853 | +} | |
1854 | + | |
1855 | +// FORMATTING | |
1856 | + | |
1857 | +function hFormat() { | |
1858 | + return this.hours() % 12 || 12; | |
1859 | +} | |
1860 | + | |
1861 | +function kFormat() { | |
1862 | + return this.hours() || 24; | |
1863 | +} | |
1864 | + | |
1865 | +addFormatToken('H', ['HH', 2], 0, 'hour'); | |
1866 | +addFormatToken('h', ['hh', 2], 0, hFormat); | |
1867 | +addFormatToken('k', ['kk', 2], 0, kFormat); | |
1868 | + | |
1869 | +addFormatToken('hmm', 0, 0, function () { | |
1870 | + return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); | |
1871 | +}); | |
1872 | + | |
1873 | +addFormatToken('hmmss', 0, 0, function () { | |
1874 | + return ( | |
1875 | + '' + | |
1876 | + hFormat.apply(this) + | |
1877 | + zeroFill(this.minutes(), 2) + | |
1878 | + zeroFill(this.seconds(), 2) | |
1879 | + ); | |
1880 | +}); | |
1881 | + | |
1882 | +addFormatToken('Hmm', 0, 0, function () { | |
1883 | + return '' + this.hours() + zeroFill(this.minutes(), 2); | |
1884 | +}); | |
1885 | + | |
1886 | +addFormatToken('Hmmss', 0, 0, function () { | |
1887 | + return ( | |
1888 | + '' + | |
1889 | + this.hours() + | |
1890 | + zeroFill(this.minutes(), 2) + | |
1891 | + zeroFill(this.seconds(), 2) | |
1892 | + ); | |
1893 | +}); | |
1894 | + | |
1895 | +function meridiem(token, lowercase) { | |
1896 | + addFormatToken(token, 0, 0, function () { | |
1897 | + return this.localeData().meridiem( | |
1898 | + this.hours(), | |
1899 | + this.minutes(), | |
1900 | + lowercase | |
1901 | + ); | |
1902 | + }); | |
1903 | +} | |
1904 | + | |
1905 | +meridiem('a', true); | |
1906 | +meridiem('A', false); | |
1907 | + | |
1908 | +// ALIASES | |
1909 | + | |
1910 | +addUnitAlias('hour', 'h'); | |
1911 | + | |
1912 | +// PRIORITY | |
1913 | +addUnitPriority('hour', 13); | |
1914 | + | |
1915 | +// PARSING | |
1916 | + | |
1917 | +function matchMeridiem(isStrict, locale) { | |
1918 | + return locale._meridiemParse; | |
1919 | +} | |
1920 | + | |
1921 | +addRegexToken('a', matchMeridiem); | |
1922 | +addRegexToken('A', matchMeridiem); | |
1923 | +addRegexToken('H', match1to2); | |
1924 | +addRegexToken('h', match1to2); | |
1925 | +addRegexToken('k', match1to2); | |
1926 | +addRegexToken('HH', match1to2, match2); | |
1927 | +addRegexToken('hh', match1to2, match2); | |
1928 | +addRegexToken('kk', match1to2, match2); | |
1929 | + | |
1930 | +addRegexToken('hmm', match3to4); | |
1931 | +addRegexToken('hmmss', match5to6); | |
1932 | +addRegexToken('Hmm', match3to4); | |
1933 | +addRegexToken('Hmmss', match5to6); | |
1934 | + | |
1935 | +addParseToken(['H', 'HH'], HOUR); | |
1936 | +addParseToken(['k', 'kk'], function (input, array, config) { | |
1937 | + var kInput = toInt(input); | |
1938 | + array[HOUR] = kInput === 24 ? 0 : kInput; | |
1939 | +}); | |
1940 | +addParseToken(['a', 'A'], function (input, array, config) { | |
1941 | + config._isPm = config._locale.isPM(input); | |
1942 | + config._meridiem = input; | |
1943 | +}); | |
1944 | +addParseToken(['h', 'hh'], function (input, array, config) { | |
1945 | + array[HOUR] = toInt(input); | |
1946 | + getParsingFlags(config).bigHour = true; | |
1947 | +}); | |
1948 | +addParseToken('hmm', function (input, array, config) { | |
1949 | + var pos = input.length - 2; | |
1950 | + array[HOUR] = toInt(input.substr(0, pos)); | |
1951 | + array[MINUTE] = toInt(input.substr(pos)); | |
1952 | + getParsingFlags(config).bigHour = true; | |
1953 | +}); | |
1954 | +addParseToken('hmmss', function (input, array, config) { | |
1955 | + var pos1 = input.length - 4, | |
1956 | + pos2 = input.length - 2; | |
1957 | + array[HOUR] = toInt(input.substr(0, pos1)); | |
1958 | + array[MINUTE] = toInt(input.substr(pos1, 2)); | |
1959 | + array[SECOND] = toInt(input.substr(pos2)); | |
1960 | + getParsingFlags(config).bigHour = true; | |
1961 | +}); | |
1962 | +addParseToken('Hmm', function (input, array, config) { | |
1963 | + var pos = input.length - 2; | |
1964 | + array[HOUR] = toInt(input.substr(0, pos)); | |
1965 | + array[MINUTE] = toInt(input.substr(pos)); | |
1966 | +}); | |
1967 | +addParseToken('Hmmss', function (input, array, config) { | |
1968 | + var pos1 = input.length - 4, | |
1969 | + pos2 = input.length - 2; | |
1970 | + array[HOUR] = toInt(input.substr(0, pos1)); | |
1971 | + array[MINUTE] = toInt(input.substr(pos1, 2)); | |
1972 | + array[SECOND] = toInt(input.substr(pos2)); | |
1973 | +}); | |
1974 | + | |
1975 | +// LOCALES | |
1976 | + | |
1977 | +function localeIsPM(input) { | |
1978 | + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays | |
1979 | + // Using charAt should be more compatible. | |
1980 | + return (input + '').toLowerCase().charAt(0) === 'p'; | |
1981 | +} | |
1982 | + | |
1983 | +var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, | |
1984 | + // Setting the hour should keep the time, because the user explicitly | |
1985 | + // specified which hour they want. So trying to maintain the same hour (in | |
1986 | + // a new timezone) makes sense. Adding/subtracting hours does not follow | |
1987 | + // this rule. | |
1988 | + getSetHour = makeGetSet('Hours', true); | |
1989 | + | |
1990 | +function localeMeridiem(hours, minutes, isLower) { | |
1991 | + if (hours > 11) { | |
1992 | + return isLower ? 'pm' : 'PM'; | |
1993 | + } else { | |
1994 | + return isLower ? 'am' : 'AM'; | |
1995 | + } | |
1996 | +} | |
1997 | + | |
1998 | +var baseConfig = { | |
1999 | + calendar: defaultCalendar, | |
2000 | + longDateFormat: defaultLongDateFormat, | |
2001 | + invalidDate: defaultInvalidDate, | |
2002 | + ordinal: defaultOrdinal, | |
2003 | + dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, | |
2004 | + relativeTime: defaultRelativeTime, | |
2005 | + | |
2006 | + months: defaultLocaleMonths, | |
2007 | + monthsShort: defaultLocaleMonthsShort, | |
2008 | + | |
2009 | + week: defaultLocaleWeek, | |
2010 | + | |
2011 | + weekdays: defaultLocaleWeekdays, | |
2012 | + weekdaysMin: defaultLocaleWeekdaysMin, | |
2013 | + weekdaysShort: defaultLocaleWeekdaysShort, | |
2014 | + | |
2015 | + meridiemParse: defaultLocaleMeridiemParse, | |
2016 | +}; | |
2017 | + | |
2018 | +// internal storage for locale config files | |
2019 | +var locales = {}, | |
2020 | + localeFamilies = {}, | |
2021 | + globalLocale; | |
2022 | + | |
2023 | +function commonPrefix(arr1, arr2) { | |
2024 | + var i, | |
2025 | + minl = Math.min(arr1.length, arr2.length); | |
2026 | + for (i = 0; i < minl; i += 1) { | |
2027 | + if (arr1[i] !== arr2[i]) { | |
2028 | + return i; | |
2029 | + } | |
2030 | + } | |
2031 | + return minl; | |
2032 | +} | |
2033 | + | |
2034 | +function normalizeLocale(key) { | |
2035 | + return key ? key.toLowerCase().replace('_', '-') : key; | |
2036 | +} | |
2037 | + | |
2038 | +// pick the locale from the array | |
2039 | +// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each | |
2040 | +// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root | |
2041 | +function chooseLocale(names) { | |
2042 | + var i = 0, | |
2043 | + j, | |
2044 | + next, | |
2045 | + locale, | |
2046 | + split; | |
2047 | + | |
2048 | + while (i < names.length) { | |
2049 | + split = normalizeLocale(names[i]).split('-'); | |
2050 | + j = split.length; | |
2051 | + next = normalizeLocale(names[i + 1]); | |
2052 | + next = next ? next.split('-') : null; | |
2053 | + while (j > 0) { | |
2054 | + locale = loadLocale(split.slice(0, j).join('-')); | |
2055 | + if (locale) { | |
2056 | + return locale; | |
2057 | + } | |
2058 | + if ( | |
2059 | + next && | |
2060 | + next.length >= j && | |
2061 | + commonPrefix(split, next) >= j - 1 | |
2062 | + ) { | |
2063 | + //the next array item is better than a shallower substring of this one | |
2064 | + break; | |
2065 | + } | |
2066 | + j--; | |
2067 | + } | |
2068 | + i++; | |
2069 | + } | |
2070 | + return globalLocale; | |
2071 | +} | |
2072 | + | |
2073 | +function loadLocale(name) { | |
2074 | + var oldLocale = null, | |
2075 | + aliasedRequire; | |
2076 | + // TODO: Find a better way to register and load all the locales in Node | |
2077 | + if ( | |
2078 | + locales[name] === undefined && | |
2079 | + typeof module !== 'undefined' && | |
2080 | + module && | |
2081 | + module.exports | |
2082 | + ) { | |
2083 | + try { | |
2084 | + oldLocale = globalLocale._abbr; | |
2085 | + aliasedRequire = require; | |
2086 | + aliasedRequire('./locale/' + name); | |
2087 | + getSetGlobalLocale(oldLocale); | |
2088 | + } catch (e) { | |
2089 | + // mark as not found to avoid repeating expensive file require call causing high CPU | |
2090 | + // when trying to find en-US, en_US, en-us for every format call | |
2091 | + locales[name] = null; // null means not found | |
2092 | + } | |
2093 | + } | |
2094 | + return locales[name]; | |
2095 | +} | |
2096 | + | |
2097 | +// This function will load locale and then set the global locale. If | |
2098 | +// no arguments are passed in, it will simply return the current global | |
2099 | +// locale key. | |
2100 | +function getSetGlobalLocale(key, values) { | |
2101 | + var data; | |
2102 | + if (key) { | |
2103 | + if (isUndefined(values)) { | |
2104 | + data = getLocale(key); | |
2105 | + } else { | |
2106 | + data = defineLocale(key, values); | |
2107 | + } | |
2108 | + | |
2109 | + if (data) { | |
2110 | + // moment.duration._locale = moment._locale = data; | |
2111 | + globalLocale = data; | |
2112 | + } else { | |
2113 | + if (typeof console !== 'undefined' && console.warn) { | |
2114 | + //warn user if arguments are passed but the locale could not be set | |
2115 | + console.warn( | |
2116 | + 'Locale ' + key + ' not found. Did you forget to load it?' | |
2117 | + ); | |
2118 | + } | |
2119 | + } | |
2120 | + } | |
2121 | + | |
2122 | + return globalLocale._abbr; | |
2123 | +} | |
2124 | + | |
2125 | +function defineLocale(name, config) { | |
2126 | + if (config !== null) { | |
2127 | + var locale, | |
2128 | + parentConfig = baseConfig; | |
2129 | + config.abbr = name; | |
2130 | + if (locales[name] != null) { | |
2131 | + deprecateSimple( | |
2132 | + 'defineLocaleOverride', | |
2133 | + 'use moment.updateLocale(localeName, config) to change ' + | |
2134 | + 'an existing locale. moment.defineLocale(localeName, ' + | |
2135 | + 'config) should only be used for creating a new locale ' + | |
2136 | + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.' | |
2137 | + ); | |
2138 | + parentConfig = locales[name]._config; | |
2139 | + } else if (config.parentLocale != null) { | |
2140 | + if (locales[config.parentLocale] != null) { | |
2141 | + parentConfig = locales[config.parentLocale]._config; | |
2142 | + } else { | |
2143 | + locale = loadLocale(config.parentLocale); | |
2144 | + if (locale != null) { | |
2145 | + parentConfig = locale._config; | |
2146 | + } else { | |
2147 | + if (!localeFamilies[config.parentLocale]) { | |
2148 | + localeFamilies[config.parentLocale] = []; | |
2149 | + } | |
2150 | + localeFamilies[config.parentLocale].push({ | |
2151 | + name: name, | |
2152 | + config: config, | |
2153 | + }); | |
2154 | + return null; | |
2155 | + } | |
2156 | + } | |
2157 | + } | |
2158 | + locales[name] = new Locale(mergeConfigs(parentConfig, config)); | |
2159 | + | |
2160 | + if (localeFamilies[name]) { | |
2161 | + localeFamilies[name].forEach(function (x) { | |
2162 | + defineLocale(x.name, x.config); | |
2163 | + }); | |
2164 | + } | |
2165 | + | |
2166 | + // backwards compat for now: also set the locale | |
2167 | + // make sure we set the locale AFTER all child locales have been | |
2168 | + // created, so we won't end up with the child locale set. | |
2169 | + getSetGlobalLocale(name); | |
2170 | + | |
2171 | + return locales[name]; | |
2172 | + } else { | |
2173 | + // useful for testing | |
2174 | + delete locales[name]; | |
2175 | + return null; | |
2176 | + } | |
2177 | +} | |
2178 | + | |
2179 | +function updateLocale(name, config) { | |
2180 | + if (config != null) { | |
2181 | + var locale, | |
2182 | + tmpLocale, | |
2183 | + parentConfig = baseConfig; | |
2184 | + | |
2185 | + if (locales[name] != null && locales[name].parentLocale != null) { | |
2186 | + // Update existing child locale in-place to avoid memory-leaks | |
2187 | + locales[name].set(mergeConfigs(locales[name]._config, config)); | |
2188 | + } else { | |
2189 | + // MERGE | |
2190 | + tmpLocale = loadLocale(name); | |
2191 | + if (tmpLocale != null) { | |
2192 | + parentConfig = tmpLocale._config; | |
2193 | + } | |
2194 | + config = mergeConfigs(parentConfig, config); | |
2195 | + if (tmpLocale == null) { | |
2196 | + // updateLocale is called for creating a new locale | |
2197 | + // Set abbr so it will have a name (getters return | |
2198 | + // undefined otherwise). | |
2199 | + config.abbr = name; | |
2200 | + } | |
2201 | + locale = new Locale(config); | |
2202 | + locale.parentLocale = locales[name]; | |
2203 | + locales[name] = locale; | |
2204 | + } | |
2205 | + | |
2206 | + // backwards compat for now: also set the locale | |
2207 | + getSetGlobalLocale(name); | |
2208 | + } else { | |
2209 | + // pass null for config to unupdate, useful for tests | |
2210 | + if (locales[name] != null) { | |
2211 | + if (locales[name].parentLocale != null) { | |
2212 | + locales[name] = locales[name].parentLocale; | |
2213 | + if (name === getSetGlobalLocale()) { | |
2214 | + getSetGlobalLocale(name); | |
2215 | + } | |
2216 | + } else if (locales[name] != null) { | |
2217 | + delete locales[name]; | |
2218 | + } | |
2219 | + } | |
2220 | + } | |
2221 | + return locales[name]; | |
2222 | +} | |
2223 | + | |
2224 | +// returns locale data | |
2225 | +function getLocale(key) { | |
2226 | + var locale; | |
2227 | + | |
2228 | + if (key && key._locale && key._locale._abbr) { | |
2229 | + key = key._locale._abbr; | |
2230 | + } | |
2231 | + | |
2232 | + if (!key) { | |
2233 | + return globalLocale; | |
2234 | + } | |
2235 | + | |
2236 | + if (!isArray(key)) { | |
2237 | + //short-circuit everything else | |
2238 | + locale = loadLocale(key); | |
2239 | + if (locale) { | |
2240 | + return locale; | |
2241 | + } | |
2242 | + key = [key]; | |
2243 | + } | |
2244 | + | |
2245 | + return chooseLocale(key); | |
2246 | +} | |
2247 | + | |
2248 | +function listLocales() { | |
2249 | + return keys(locales); | |
2250 | +} | |
2251 | + | |
2252 | +function checkOverflow(m) { | |
2253 | + var overflow, | |
2254 | + a = m._a; | |
2255 | + | |
2256 | + if (a && getParsingFlags(m).overflow === -2) { | |
2257 | + overflow = | |
2258 | + a[MONTH] < 0 || a[MONTH] > 11 | |
2259 | + ? MONTH | |
2260 | + : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) | |
2261 | + ? DATE | |
2262 | + : a[HOUR] < 0 || | |
2263 | + a[HOUR] > 24 || | |
2264 | + (a[HOUR] === 24 && | |
2265 | + (a[MINUTE] !== 0 || | |
2266 | + a[SECOND] !== 0 || | |
2267 | + a[MILLISECOND] !== 0)) | |
2268 | + ? HOUR | |
2269 | + : a[MINUTE] < 0 || a[MINUTE] > 59 | |
2270 | + ? MINUTE | |
2271 | + : a[SECOND] < 0 || a[SECOND] > 59 | |
2272 | + ? SECOND | |
2273 | + : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 | |
2274 | + ? MILLISECOND | |
2275 | + : -1; | |
2276 | + | |
2277 | + if ( | |
2278 | + getParsingFlags(m)._overflowDayOfYear && | |
2279 | + (overflow < YEAR || overflow > DATE) | |
2280 | + ) { | |
2281 | + overflow = DATE; | |
2282 | + } | |
2283 | + if (getParsingFlags(m)._overflowWeeks && overflow === -1) { | |
2284 | + overflow = WEEK; | |
2285 | + } | |
2286 | + if (getParsingFlags(m)._overflowWeekday && overflow === -1) { | |
2287 | + overflow = WEEKDAY; | |
2288 | + } | |
2289 | + | |
2290 | + getParsingFlags(m).overflow = overflow; | |
2291 | + } | |
2292 | + | |
2293 | + return m; | |
2294 | +} | |
2295 | + | |
2296 | +// iso 8601 regex | |
2297 | +// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) | |
2298 | +var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, | |
2299 | + basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, | |
2300 | + tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, | |
2301 | + isoDates = [ | |
2302 | + ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], | |
2303 | + ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], | |
2304 | + ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], | |
2305 | + ['GGGG-[W]WW', /\d{4}-W\d\d/, false], | |
2306 | + ['YYYY-DDD', /\d{4}-\d{3}/], | |
2307 | + ['YYYY-MM', /\d{4}-\d\d/, false], | |
2308 | + ['YYYYYYMMDD', /[+-]\d{10}/], | |
2309 | + ['YYYYMMDD', /\d{8}/], | |
2310 | + ['GGGG[W]WWE', /\d{4}W\d{3}/], | |
2311 | + ['GGGG[W]WW', /\d{4}W\d{2}/, false], | |
2312 | + ['YYYYDDD', /\d{7}/], | |
2313 | + ['YYYYMM', /\d{6}/, false], | |
2314 | + ['YYYY', /\d{4}/, false], | |
2315 | + ], | |
2316 | + // iso time formats and regexes | |
2317 | + isoTimes = [ | |
2318 | + ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], | |
2319 | + ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], | |
2320 | + ['HH:mm:ss', /\d\d:\d\d:\d\d/], | |
2321 | + ['HH:mm', /\d\d:\d\d/], | |
2322 | + ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], | |
2323 | + ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], | |
2324 | + ['HHmmss', /\d\d\d\d\d\d/], | |
2325 | + ['HHmm', /\d\d\d\d/], | |
2326 | + ['HH', /\d\d/], | |
2327 | + ], | |
2328 | + aspNetJsonRegex = /^\/?Date\((-?\d+)/i, | |
2329 | + // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 | |
2330 | + rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, | |
2331 | + obsOffsets = { | |
2332 | + UT: 0, | |
2333 | + GMT: 0, | |
2334 | + EDT: -4 * 60, | |
2335 | + EST: -5 * 60, | |
2336 | + CDT: -5 * 60, | |
2337 | + CST: -6 * 60, | |
2338 | + MDT: -6 * 60, | |
2339 | + MST: -7 * 60, | |
2340 | + PDT: -7 * 60, | |
2341 | + PST: -8 * 60, | |
2342 | + }; | |
2343 | + | |
2344 | +// date from iso format | |
2345 | +function configFromISO(config) { | |
2346 | + var i, | |
2347 | + l, | |
2348 | + string = config._i, | |
2349 | + match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), | |
2350 | + allowTime, | |
2351 | + dateFormat, | |
2352 | + timeFormat, | |
2353 | + tzFormat; | |
2354 | + | |
2355 | + if (match) { | |
2356 | + getParsingFlags(config).iso = true; | |
2357 | + | |
2358 | + for (i = 0, l = isoDates.length; i < l; i++) { | |
2359 | + if (isoDates[i][1].exec(match[1])) { | |
2360 | + dateFormat = isoDates[i][0]; | |
2361 | + allowTime = isoDates[i][2] !== false; | |
2362 | + break; | |
2363 | + } | |
2364 | + } | |
2365 | + if (dateFormat == null) { | |
2366 | + config._isValid = false; | |
2367 | + return; | |
2368 | + } | |
2369 | + if (match[3]) { | |
2370 | + for (i = 0, l = isoTimes.length; i < l; i++) { | |
2371 | + if (isoTimes[i][1].exec(match[3])) { | |
2372 | + // match[2] should be 'T' or space | |
2373 | + timeFormat = (match[2] || ' ') + isoTimes[i][0]; | |
2374 | + break; | |
2375 | + } | |
2376 | + } | |
2377 | + if (timeFormat == null) { | |
2378 | + config._isValid = false; | |
2379 | + return; | |
2380 | + } | |
2381 | + } | |
2382 | + if (!allowTime && timeFormat != null) { | |
2383 | + config._isValid = false; | |
2384 | + return; | |
2385 | + } | |
2386 | + if (match[4]) { | |
2387 | + if (tzRegex.exec(match[4])) { | |
2388 | + tzFormat = 'Z'; | |
2389 | + } else { | |
2390 | + config._isValid = false; | |
2391 | + return; | |
2392 | + } | |
2393 | + } | |
2394 | + config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); | |
2395 | + configFromStringAndFormat(config); | |
2396 | + } else { | |
2397 | + config._isValid = false; | |
2398 | + } | |
2399 | +} | |
2400 | + | |
2401 | +function extractFromRFC2822Strings( | |
2402 | + yearStr, | |
2403 | + monthStr, | |
2404 | + dayStr, | |
2405 | + hourStr, | |
2406 | + minuteStr, | |
2407 | + secondStr | |
2408 | +) { | |
2409 | + var result = [ | |
2410 | + untruncateYear(yearStr), | |
2411 | + defaultLocaleMonthsShort.indexOf(monthStr), | |
2412 | + parseInt(dayStr, 10), | |
2413 | + parseInt(hourStr, 10), | |
2414 | + parseInt(minuteStr, 10), | |
2415 | + ]; | |
2416 | + | |
2417 | + if (secondStr) { | |
2418 | + result.push(parseInt(secondStr, 10)); | |
2419 | + } | |
2420 | + | |
2421 | + return result; | |
2422 | +} | |
2423 | + | |
2424 | +function untruncateYear(yearStr) { | |
2425 | + var year = parseInt(yearStr, 10); | |
2426 | + if (year <= 49) { | |
2427 | + return 2000 + year; | |
2428 | + } else if (year <= 999) { | |
2429 | + return 1900 + year; | |
2430 | + } | |
2431 | + return year; | |
2432 | +} | |
2433 | + | |
2434 | +function preprocessRFC2822(s) { | |
2435 | + // Remove comments and folding whitespace and replace multiple-spaces with a single space | |
2436 | + return s | |
2437 | + .replace(/\([^)]*\)|[\n\t]/g, ' ') | |
2438 | + .replace(/(\s\s+)/g, ' ') | |
2439 | + .replace(/^\s\s*/, '') | |
2440 | + .replace(/\s\s*$/, ''); | |
2441 | +} | |
2442 | + | |
2443 | +function checkWeekday(weekdayStr, parsedInput, config) { | |
2444 | + if (weekdayStr) { | |
2445 | + // TODO: Replace the vanilla JS Date object with an independent day-of-week check. | |
2446 | + var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), | |
2447 | + weekdayActual = new Date( | |
2448 | + parsedInput[0], | |
2449 | + parsedInput[1], | |
2450 | + parsedInput[2] | |
2451 | + ).getDay(); | |
2452 | + if (weekdayProvided !== weekdayActual) { | |
2453 | + getParsingFlags(config).weekdayMismatch = true; | |
2454 | + config._isValid = false; | |
2455 | + return false; | |
2456 | + } | |
2457 | + } | |
2458 | + return true; | |
2459 | +} | |
2460 | + | |
2461 | +function calculateOffset(obsOffset, militaryOffset, numOffset) { | |
2462 | + if (obsOffset) { | |
2463 | + return obsOffsets[obsOffset]; | |
2464 | + } else if (militaryOffset) { | |
2465 | + // the only allowed military tz is Z | |
2466 | + return 0; | |
2467 | + } else { | |
2468 | + var hm = parseInt(numOffset, 10), | |
2469 | + m = hm % 100, | |
2470 | + h = (hm - m) / 100; | |
2471 | + return h * 60 + m; | |
2472 | + } | |
2473 | +} | |
2474 | + | |
2475 | +// date and time from ref 2822 format | |
2476 | +function configFromRFC2822(config) { | |
2477 | + var match = rfc2822.exec(preprocessRFC2822(config._i)), | |
2478 | + parsedArray; | |
2479 | + if (match) { | |
2480 | + parsedArray = extractFromRFC2822Strings( | |
2481 | + match[4], | |
2482 | + match[3], | |
2483 | + match[2], | |
2484 | + match[5], | |
2485 | + match[6], | |
2486 | + match[7] | |
2487 | + ); | |
2488 | + if (!checkWeekday(match[1], parsedArray, config)) { | |
2489 | + return; | |
2490 | + } | |
2491 | + | |
2492 | + config._a = parsedArray; | |
2493 | + config._tzm = calculateOffset(match[8], match[9], match[10]); | |
2494 | + | |
2495 | + config._d = createUTCDate.apply(null, config._a); | |
2496 | + config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); | |
2497 | + | |
2498 | + getParsingFlags(config).rfc2822 = true; | |
2499 | + } else { | |
2500 | + config._isValid = false; | |
2501 | + } | |
2502 | +} | |
2503 | + | |
2504 | +// date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict | |
2505 | +function configFromString(config) { | |
2506 | + var matched = aspNetJsonRegex.exec(config._i); | |
2507 | + if (matched !== null) { | |
2508 | + config._d = new Date(+matched[1]); | |
2509 | + return; | |
2510 | + } | |
2511 | + | |
2512 | + configFromISO(config); | |
2513 | + if (config._isValid === false) { | |
2514 | + delete config._isValid; | |
2515 | + } else { | |
2516 | + return; | |
2517 | + } | |
2518 | + | |
2519 | + configFromRFC2822(config); | |
2520 | + if (config._isValid === false) { | |
2521 | + delete config._isValid; | |
2522 | + } else { | |
2523 | + return; | |
2524 | + } | |
2525 | + | |
2526 | + if (config._strict) { | |
2527 | + config._isValid = false; | |
2528 | + } else { | |
2529 | + // Final attempt, use Input Fallback | |
2530 | + hooks.createFromInputFallback(config); | |
2531 | + } | |
2532 | +} | |
2533 | + | |
2534 | +hooks.createFromInputFallback = deprecate( | |
2535 | + 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + | |
2536 | + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + | |
2537 | + 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.', | |
2538 | + function (config) { | |
2539 | + config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); | |
2540 | + } | |
2541 | +); | |
2542 | + | |
2543 | +// Pick the first defined of two or three arguments. | |
2544 | +function defaults(a, b, c) { | |
2545 | + if (a != null) { | |
2546 | + return a; | |
2547 | + } | |
2548 | + if (b != null) { | |
2549 | + return b; | |
2550 | + } | |
2551 | + return c; | |
2552 | +} | |
2553 | + | |
2554 | +function currentDateArray(config) { | |
2555 | + // hooks is actually the exported moment object | |
2556 | + var nowValue = new Date(hooks.now()); | |
2557 | + if (config._useUTC) { | |
2558 | + return [ | |
2559 | + nowValue.getUTCFullYear(), | |
2560 | + nowValue.getUTCMonth(), | |
2561 | + nowValue.getUTCDate(), | |
2562 | + ]; | |
2563 | + } | |
2564 | + return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; | |
2565 | +} | |
2566 | + | |
2567 | +// convert an array to a date. | |
2568 | +// the array should mirror the parameters below | |
2569 | +// note: all values past the year are optional and will default to the lowest possible value. | |
2570 | +// [year, month, day , hour, minute, second, millisecond] | |
2571 | +function configFromArray(config) { | |
2572 | + var i, | |
2573 | + date, | |
2574 | + input = [], | |
2575 | + currentDate, | |
2576 | + expectedWeekday, | |
2577 | + yearToUse; | |
2578 | + | |
2579 | + if (config._d) { | |
2580 | + return; | |
2581 | + } | |
2582 | + | |
2583 | + currentDate = currentDateArray(config); | |
2584 | + | |
2585 | + //compute day of the year from weeks and weekdays | |
2586 | + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { | |
2587 | + dayOfYearFromWeekInfo(config); | |
2588 | + } | |
2589 | + | |
2590 | + //if the day of the year is set, figure out what it is | |
2591 | + if (config._dayOfYear != null) { | |
2592 | + yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); | |
2593 | + | |
2594 | + if ( | |
2595 | + config._dayOfYear > daysInYear(yearToUse) || | |
2596 | + config._dayOfYear === 0 | |
2597 | + ) { | |
2598 | + getParsingFlags(config)._overflowDayOfYear = true; | |
2599 | + } | |
2600 | + | |
2601 | + date = createUTCDate(yearToUse, 0, config._dayOfYear); | |
2602 | + config._a[MONTH] = date.getUTCMonth(); | |
2603 | + config._a[DATE] = date.getUTCDate(); | |
2604 | + } | |
2605 | + | |
2606 | + // Default to current date. | |
2607 | + // * if no year, month, day of month are given, default to today | |
2608 | + // * if day of month is given, default month and year | |
2609 | + // * if month is given, default only year | |
2610 | + // * if year is given, don't default anything | |
2611 | + for (i = 0; i < 3 && config._a[i] == null; ++i) { | |
2612 | + config._a[i] = input[i] = currentDate[i]; | |
2613 | + } | |
2614 | + | |
2615 | + // Zero out whatever was not defaulted, including time | |
2616 | + for (; i < 7; i++) { | |
2617 | + config._a[i] = input[i] = | |
2618 | + config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i]; | |
2619 | + } | |
2620 | + | |
2621 | + // Check for 24:00:00.000 | |
2622 | + if ( | |
2623 | + config._a[HOUR] === 24 && | |
2624 | + config._a[MINUTE] === 0 && | |
2625 | + config._a[SECOND] === 0 && | |
2626 | + config._a[MILLISECOND] === 0 | |
2627 | + ) { | |
2628 | + config._nextDay = true; | |
2629 | + config._a[HOUR] = 0; | |
2630 | + } | |
2631 | + | |
2632 | + config._d = (config._useUTC ? createUTCDate : createDate).apply( | |
2633 | + null, | |
2634 | + input | |
2635 | + ); | |
2636 | + expectedWeekday = config._useUTC | |
2637 | + ? config._d.getUTCDay() | |
2638 | + : config._d.getDay(); | |
2639 | + | |
2640 | + // Apply timezone offset from input. The actual utcOffset can be changed | |
2641 | + // with parseZone. | |
2642 | + if (config._tzm != null) { | |
2643 | + config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); | |
2644 | + } | |
2645 | + | |
2646 | + if (config._nextDay) { | |
2647 | + config._a[HOUR] = 24; | |
2648 | + } | |
2649 | + | |
2650 | + // check for mismatching day of week | |
2651 | + if ( | |
2652 | + config._w && | |
2653 | + typeof config._w.d !== 'undefined' && | |
2654 | + config._w.d !== expectedWeekday | |
2655 | + ) { | |
2656 | + getParsingFlags(config).weekdayMismatch = true; | |
2657 | + } | |
2658 | +} | |
2659 | + | |
2660 | +function dayOfYearFromWeekInfo(config) { | |
2661 | + var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek; | |
2662 | + | |
2663 | + w = config._w; | |
2664 | + if (w.GG != null || w.W != null || w.E != null) { | |
2665 | + dow = 1; | |
2666 | + doy = 4; | |
2667 | + | |
2668 | + // TODO: We need to take the current isoWeekYear, but that depends on | |
2669 | + // how we interpret now (local, utc, fixed offset). So create | |
2670 | + // a now version of current config (take local/utc/offset flags, and | |
2671 | + // create now). | |
2672 | + weekYear = defaults( | |
2673 | + w.GG, | |
2674 | + config._a[YEAR], | |
2675 | + weekOfYear(createLocal(), 1, 4).year | |
2676 | + ); | |
2677 | + week = defaults(w.W, 1); | |
2678 | + weekday = defaults(w.E, 1); | |
2679 | + if (weekday < 1 || weekday > 7) { | |
2680 | + weekdayOverflow = true; | |
2681 | + } | |
2682 | + } else { | |
2683 | + dow = config._locale._week.dow; | |
2684 | + doy = config._locale._week.doy; | |
2685 | + | |
2686 | + curWeek = weekOfYear(createLocal(), dow, doy); | |
2687 | + | |
2688 | + weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); | |
2689 | + | |
2690 | + // Default to current week. | |
2691 | + week = defaults(w.w, curWeek.week); | |
2692 | + | |
2693 | + if (w.d != null) { | |
2694 | + // weekday -- low day numbers are considered next week | |
2695 | + weekday = w.d; | |
2696 | + if (weekday < 0 || weekday > 6) { | |
2697 | + weekdayOverflow = true; | |
2698 | + } | |
2699 | + } else if (w.e != null) { | |
2700 | + // local weekday -- counting starts from beginning of week | |
2701 | + weekday = w.e + dow; | |
2702 | + if (w.e < 0 || w.e > 6) { | |
2703 | + weekdayOverflow = true; | |
2704 | + } | |
2705 | + } else { | |
2706 | + // default to beginning of week | |
2707 | + weekday = dow; | |
2708 | + } | |
2709 | + } | |
2710 | + if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { | |
2711 | + getParsingFlags(config)._overflowWeeks = true; | |
2712 | + } else if (weekdayOverflow != null) { | |
2713 | + getParsingFlags(config)._overflowWeekday = true; | |
2714 | + } else { | |
2715 | + temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); | |
2716 | + config._a[YEAR] = temp.year; | |
2717 | + config._dayOfYear = temp.dayOfYear; | |
2718 | + } | |
2719 | +} | |
2720 | + | |
2721 | +// constant that refers to the ISO standard | |
2722 | +hooks.ISO_8601 = function () {}; | |
2723 | + | |
2724 | +// constant that refers to the RFC 2822 form | |
2725 | +hooks.RFC_2822 = function () {}; | |
2726 | + | |
2727 | +// date from string and format string | |
2728 | +function configFromStringAndFormat(config) { | |
2729 | + // TODO: Move this to another part of the creation flow to prevent circular deps | |
2730 | + if (config._f === hooks.ISO_8601) { | |
2731 | + configFromISO(config); | |
2732 | + return; | |
2733 | + } | |
2734 | + if (config._f === hooks.RFC_2822) { | |
2735 | + configFromRFC2822(config); | |
2736 | + return; | |
2737 | + } | |
2738 | + config._a = []; | |
2739 | + getParsingFlags(config).empty = true; | |
2740 | + | |
2741 | + // This array is used to make a Date, either with `new Date` or `Date.UTC` | |
2742 | + var string = '' + config._i, | |
2743 | + i, | |
2744 | + parsedInput, | |
2745 | + tokens, | |
2746 | + token, | |
2747 | + skipped, | |
2748 | + stringLength = string.length, | |
2749 | + totalParsedInputLength = 0, | |
2750 | + era; | |
2751 | + | |
2752 | + tokens = | |
2753 | + expandFormat(config._f, config._locale).match(formattingTokens) || []; | |
2754 | + | |
2755 | + for (i = 0; i < tokens.length; i++) { | |
2756 | + token = tokens[i]; | |
2757 | + parsedInput = (string.match(getParseRegexForToken(token, config)) || | |
2758 | + [])[0]; | |
2759 | + if (parsedInput) { | |
2760 | + skipped = string.substr(0, string.indexOf(parsedInput)); | |
2761 | + if (skipped.length > 0) { | |
2762 | + getParsingFlags(config).unusedInput.push(skipped); | |
2763 | + } | |
2764 | + string = string.slice( | |
2765 | + string.indexOf(parsedInput) + parsedInput.length | |
2766 | + ); | |
2767 | + totalParsedInputLength += parsedInput.length; | |
2768 | + } | |
2769 | + // don't parse if it's not a known token | |
2770 | + if (formatTokenFunctions[token]) { | |
2771 | + if (parsedInput) { | |
2772 | + getParsingFlags(config).empty = false; | |
2773 | + } else { | |
2774 | + getParsingFlags(config).unusedTokens.push(token); | |
2775 | + } | |
2776 | + addTimeToArrayFromToken(token, parsedInput, config); | |
2777 | + } else if (config._strict && !parsedInput) { | |
2778 | + getParsingFlags(config).unusedTokens.push(token); | |
2779 | + } | |
2780 | + } | |
2781 | + | |
2782 | + // add remaining unparsed input length to the string | |
2783 | + getParsingFlags(config).charsLeftOver = | |
2784 | + stringLength - totalParsedInputLength; | |
2785 | + if (string.length > 0) { | |
2786 | + getParsingFlags(config).unusedInput.push(string); | |
2787 | + } | |
2788 | + | |
2789 | + // clear _12h flag if hour is <= 12 | |
2790 | + if ( | |
2791 | + config._a[HOUR] <= 12 && | |
2792 | + getParsingFlags(config).bigHour === true && | |
2793 | + config._a[HOUR] > 0 | |
2794 | + ) { | |
2795 | + getParsingFlags(config).bigHour = undefined; | |
2796 | + } | |
2797 | + | |
2798 | + getParsingFlags(config).parsedDateParts = config._a.slice(0); | |
2799 | + getParsingFlags(config).meridiem = config._meridiem; | |
2800 | + // handle meridiem | |
2801 | + config._a[HOUR] = meridiemFixWrap( | |
2802 | + config._locale, | |
2803 | + config._a[HOUR], | |
2804 | + config._meridiem | |
2805 | + ); | |
2806 | + | |
2807 | + // handle era | |
2808 | + era = getParsingFlags(config).era; | |
2809 | + if (era !== null) { | |
2810 | + config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]); | |
2811 | + } | |
2812 | + | |
2813 | + configFromArray(config); | |
2814 | + checkOverflow(config); | |
2815 | +} | |
2816 | + | |
2817 | +function meridiemFixWrap(locale, hour, meridiem) { | |
2818 | + var isPm; | |
2819 | + | |
2820 | + if (meridiem == null) { | |
2821 | + // nothing to do | |
2822 | + return hour; | |
2823 | + } | |
2824 | + if (locale.meridiemHour != null) { | |
2825 | + return locale.meridiemHour(hour, meridiem); | |
2826 | + } else if (locale.isPM != null) { | |
2827 | + // Fallback | |
2828 | + isPm = locale.isPM(meridiem); | |
2829 | + if (isPm && hour < 12) { | |
2830 | + hour += 12; | |
2831 | + } | |
2832 | + if (!isPm && hour === 12) { | |
2833 | + hour = 0; | |
2834 | + } | |
2835 | + return hour; | |
2836 | + } else { | |
2837 | + // this is not supposed to happen | |
2838 | + return hour; | |
2839 | + } | |
2840 | +} | |
2841 | + | |
2842 | +// date from string and array of format strings | |
2843 | +function configFromStringAndArray(config) { | |
2844 | + var tempConfig, | |
2845 | + bestMoment, | |
2846 | + scoreToBeat, | |
2847 | + i, | |
2848 | + currentScore, | |
2849 | + validFormatFound, | |
2850 | + bestFormatIsValid = false; | |
2851 | + | |
2852 | + if (config._f.length === 0) { | |
2853 | + getParsingFlags(config).invalidFormat = true; | |
2854 | + config._d = new Date(NaN); | |
2855 | + return; | |
2856 | + } | |
2857 | + | |
2858 | + for (i = 0; i < config._f.length; i++) { | |
2859 | + currentScore = 0; | |
2860 | + validFormatFound = false; | |
2861 | + tempConfig = copyConfig({}, config); | |
2862 | + if (config._useUTC != null) { | |
2863 | + tempConfig._useUTC = config._useUTC; | |
2864 | + } | |
2865 | + tempConfig._f = config._f[i]; | |
2866 | + configFromStringAndFormat(tempConfig); | |
2867 | + | |
2868 | + if (isValid(tempConfig)) { | |
2869 | + validFormatFound = true; | |
2870 | + } | |
2871 | + | |
2872 | + // if there is any input that was not parsed add a penalty for that format | |
2873 | + currentScore += getParsingFlags(tempConfig).charsLeftOver; | |
2874 | + | |
2875 | + //or tokens | |
2876 | + currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; | |
2877 | + | |
2878 | + getParsingFlags(tempConfig).score = currentScore; | |
2879 | + | |
2880 | + if (!bestFormatIsValid) { | |
2881 | + if ( | |
2882 | + scoreToBeat == null || | |
2883 | + currentScore < scoreToBeat || | |
2884 | + validFormatFound | |
2885 | + ) { | |
2886 | + scoreToBeat = currentScore; | |
2887 | + bestMoment = tempConfig; | |
2888 | + if (validFormatFound) { | |
2889 | + bestFormatIsValid = true; | |
2890 | + } | |
2891 | + } | |
2892 | + } else { | |
2893 | + if (currentScore < scoreToBeat) { | |
2894 | + scoreToBeat = currentScore; | |
2895 | + bestMoment = tempConfig; | |
2896 | + } | |
2897 | + } | |
2898 | + } | |
2899 | + | |
2900 | + extend(config, bestMoment || tempConfig); | |
2901 | +} | |
2902 | + | |
2903 | +function configFromObject(config) { | |
2904 | + if (config._d) { | |
2905 | + return; | |
2906 | + } | |
2907 | + | |
2908 | + var i = normalizeObjectUnits(config._i), | |
2909 | + dayOrDate = i.day === undefined ? i.date : i.day; | |
2910 | + config._a = map( | |
2911 | + [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], | |
2912 | + function (obj) { | |
2913 | + return obj && parseInt(obj, 10); | |
2914 | + } | |
2915 | + ); | |
2916 | + | |
2917 | + configFromArray(config); | |
2918 | +} | |
2919 | + | |
2920 | +function createFromConfig(config) { | |
2921 | + var res = new Moment(checkOverflow(prepareConfig(config))); | |
2922 | + if (res._nextDay) { | |
2923 | + // Adding is smart enough around DST | |
2924 | + res.add(1, 'd'); | |
2925 | + res._nextDay = undefined; | |
2926 | + } | |
2927 | + | |
2928 | + return res; | |
2929 | +} | |
2930 | + | |
2931 | +function prepareConfig(config) { | |
2932 | + var input = config._i, | |
2933 | + format = config._f; | |
2934 | + | |
2935 | + config._locale = config._locale || getLocale(config._l); | |
2936 | + | |
2937 | + if (input === null || (format === undefined && input === '')) { | |
2938 | + return createInvalid({ nullInput: true }); | |
2939 | + } | |
2940 | + | |
2941 | + if (typeof input === 'string') { | |
2942 | + config._i = input = config._locale.preparse(input); | |
2943 | + } | |
2944 | + | |
2945 | + if (isMoment(input)) { | |
2946 | + return new Moment(checkOverflow(input)); | |
2947 | + } else if (isDate(input)) { | |
2948 | + config._d = input; | |
2949 | + } else if (isArray(format)) { | |
2950 | + configFromStringAndArray(config); | |
2951 | + } else if (format) { | |
2952 | + configFromStringAndFormat(config); | |
2953 | + } else { | |
2954 | + configFromInput(config); | |
2955 | + } | |
2956 | + | |
2957 | + if (!isValid(config)) { | |
2958 | + config._d = null; | |
2959 | + } | |
2960 | + | |
2961 | + return config; | |
2962 | +} | |
2963 | + | |
2964 | +function configFromInput(config) { | |
2965 | + var input = config._i; | |
2966 | + if (isUndefined(input)) { | |
2967 | + config._d = new Date(hooks.now()); | |
2968 | + } else if (isDate(input)) { | |
2969 | + config._d = new Date(input.valueOf()); | |
2970 | + } else if (typeof input === 'string') { | |
2971 | + configFromString(config); | |
2972 | + } else if (isArray(input)) { | |
2973 | + config._a = map(input.slice(0), function (obj) { | |
2974 | + return parseInt(obj, 10); | |
2975 | + }); | |
2976 | + configFromArray(config); | |
2977 | + } else if (isObject(input)) { | |
2978 | + configFromObject(config); | |
2979 | + } else if (isNumber(input)) { | |
2980 | + // from milliseconds | |
2981 | + config._d = new Date(input); | |
2982 | + } else { | |
2983 | + hooks.createFromInputFallback(config); | |
2984 | + } | |
2985 | +} | |
2986 | + | |
2987 | +function createLocalOrUTC(input, format, locale, strict, isUTC) { | |
2988 | + var c = {}; | |
2989 | + | |
2990 | + if (format === true || format === false) { | |
2991 | + strict = format; | |
2992 | + format = undefined; | |
2993 | + } | |
2994 | + | |
2995 | + if (locale === true || locale === false) { | |
2996 | + strict = locale; | |
2997 | + locale = undefined; | |
2998 | + } | |
2999 | + | |
3000 | + if ( | |
3001 | + (isObject(input) && isObjectEmpty(input)) || | |
3002 | + (isArray(input) && input.length === 0) | |
3003 | + ) { | |
3004 | + input = undefined; | |
3005 | + } | |
3006 | + // object construction must be done this way. | |
3007 | + // https://github.com/moment/moment/issues/1423 | |
3008 | + c._isAMomentObject = true; | |
3009 | + c._useUTC = c._isUTC = isUTC; | |
3010 | + c._l = locale; | |
3011 | + c._i = input; | |
3012 | + c._f = format; | |
3013 | + c._strict = strict; | |
3014 | + | |
3015 | + return createFromConfig(c); | |
3016 | +} | |
3017 | + | |
3018 | +function createLocal(input, format, locale, strict) { | |
3019 | + return createLocalOrUTC(input, format, locale, strict, false); | |
3020 | +} | |
3021 | + | |
3022 | +var prototypeMin = deprecate( | |
3023 | + 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', | |
3024 | + function () { | |
3025 | + var other = createLocal.apply(null, arguments); | |
3026 | + if (this.isValid() && other.isValid()) { | |
3027 | + return other < this ? this : other; | |
3028 | + } else { | |
3029 | + return createInvalid(); | |
3030 | + } | |
3031 | + } | |
3032 | + ), | |
3033 | + prototypeMax = deprecate( | |
3034 | + 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', | |
3035 | + function () { | |
3036 | + var other = createLocal.apply(null, arguments); | |
3037 | + if (this.isValid() && other.isValid()) { | |
3038 | + return other > this ? this : other; | |
3039 | + } else { | |
3040 | + return createInvalid(); | |
3041 | + } | |
3042 | + } | |
3043 | + ); | |
3044 | + | |
3045 | +// Pick a moment m from moments so that m[fn](other) is true for all | |
3046 | +// other. This relies on the function fn to be transitive. | |
3047 | +// | |
3048 | +// moments should either be an array of moment objects or an array, whose | |
3049 | +// first element is an array of moment objects. | |
3050 | +function pickBy(fn, moments) { | |
3051 | + var res, i; | |
3052 | + if (moments.length === 1 && isArray(moments[0])) { | |
3053 | + moments = moments[0]; | |
3054 | + } | |
3055 | + if (!moments.length) { | |
3056 | + return createLocal(); | |
3057 | + } | |
3058 | + res = moments[0]; | |
3059 | + for (i = 1; i < moments.length; ++i) { | |
3060 | + if (!moments[i].isValid() || moments[i][fn](res)) { | |
3061 | + res = moments[i]; | |
3062 | + } | |
3063 | + } | |
3064 | + return res; | |
3065 | +} | |
3066 | + | |
3067 | +// TODO: Use [].sort instead? | |
3068 | +function min() { | |
3069 | + var args = [].slice.call(arguments, 0); | |
3070 | + | |
3071 | + return pickBy('isBefore', args); | |
3072 | +} | |
3073 | + | |
3074 | +function max() { | |
3075 | + var args = [].slice.call(arguments, 0); | |
3076 | + | |
3077 | + return pickBy('isAfter', args); | |
3078 | +} | |
3079 | + | |
3080 | +var now = function () { | |
3081 | + return Date.now ? Date.now() : +new Date(); | |
3082 | +}; | |
3083 | + | |
3084 | +var ordering = [ | |
3085 | + 'year', | |
3086 | + 'quarter', | |
3087 | + 'month', | |
3088 | + 'week', | |
3089 | + 'day', | |
3090 | + 'hour', | |
3091 | + 'minute', | |
3092 | + 'second', | |
3093 | + 'millisecond', | |
3094 | +]; | |
3095 | + | |
3096 | +function isDurationValid(m) { | |
3097 | + var key, | |
3098 | + unitHasDecimal = false, | |
3099 | + i; | |
3100 | + for (key in m) { | |
3101 | + if ( | |
3102 | + hasOwnProp(m, key) && | |
3103 | + !( | |
3104 | + indexOf.call(ordering, key) !== -1 && | |
3105 | + (m[key] == null || !isNaN(m[key])) | |
3106 | + ) | |
3107 | + ) { | |
3108 | + return false; | |
3109 | + } | |
3110 | + } | |
3111 | + | |
3112 | + for (i = 0; i < ordering.length; ++i) { | |
3113 | + if (m[ordering[i]]) { | |
3114 | + if (unitHasDecimal) { | |
3115 | + return false; // only allow non-integers for smallest unit | |
3116 | + } | |
3117 | + if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { | |
3118 | + unitHasDecimal = true; | |
3119 | + } | |
3120 | + } | |
3121 | + } | |
3122 | + | |
3123 | + return true; | |
3124 | +} | |
3125 | + | |
3126 | +function isValid$1() { | |
3127 | + return this._isValid; | |
3128 | +} | |
3129 | + | |
3130 | +function createInvalid$1() { | |
3131 | + return createDuration(NaN); | |
3132 | +} | |
3133 | + | |
3134 | +function Duration(duration) { | |
3135 | + var normalizedInput = normalizeObjectUnits(duration), | |
3136 | + years = normalizedInput.year || 0, | |
3137 | + quarters = normalizedInput.quarter || 0, | |
3138 | + months = normalizedInput.month || 0, | |
3139 | + weeks = normalizedInput.week || normalizedInput.isoWeek || 0, | |
3140 | + days = normalizedInput.day || 0, | |
3141 | + hours = normalizedInput.hour || 0, | |
3142 | + minutes = normalizedInput.minute || 0, | |
3143 | + seconds = normalizedInput.second || 0, | |
3144 | + milliseconds = normalizedInput.millisecond || 0; | |
3145 | + | |
3146 | + this._isValid = isDurationValid(normalizedInput); | |
3147 | + | |
3148 | + // representation for dateAddRemove | |
3149 | + this._milliseconds = | |
3150 | + +milliseconds + | |
3151 | + seconds * 1e3 + // 1000 | |
3152 | + minutes * 6e4 + // 1000 * 60 | |
3153 | + hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 | |
3154 | + // Because of dateAddRemove treats 24 hours as different from a | |
3155 | + // day when working around DST, we need to store them separately | |
3156 | + this._days = +days + weeks * 7; | |
3157 | + // It is impossible to translate months into days without knowing | |
3158 | + // which months you are are talking about, so we have to store | |
3159 | + // it separately. | |
3160 | + this._months = +months + quarters * 3 + years * 12; | |
3161 | + | |
3162 | + this._data = {}; | |
3163 | + | |
3164 | + this._locale = getLocale(); | |
3165 | + | |
3166 | + this._bubble(); | |
3167 | +} | |
3168 | + | |
3169 | +function isDuration(obj) { | |
3170 | + return obj instanceof Duration; | |
3171 | +} | |
3172 | + | |
3173 | +function absRound(number) { | |
3174 | + if (number < 0) { | |
3175 | + return Math.round(-1 * number) * -1; | |
3176 | + } else { | |
3177 | + return Math.round(number); | |
3178 | + } | |
3179 | +} | |
3180 | + | |
3181 | +// compare two arrays, return the number of differences | |
3182 | +function compareArrays(array1, array2, dontConvert) { | |
3183 | + var len = Math.min(array1.length, array2.length), | |
3184 | + lengthDiff = Math.abs(array1.length - array2.length), | |
3185 | + diffs = 0, | |
3186 | + i; | |
3187 | + for (i = 0; i < len; i++) { | |
3188 | + if ( | |
3189 | + (dontConvert && array1[i] !== array2[i]) || | |
3190 | + (!dontConvert && toInt(array1[i]) !== toInt(array2[i])) | |
3191 | + ) { | |
3192 | + diffs++; | |
3193 | + } | |
3194 | + } | |
3195 | + return diffs + lengthDiff; | |
3196 | +} | |
3197 | + | |
3198 | +// FORMATTING | |
3199 | + | |
3200 | +function offset(token, separator) { | |
3201 | + addFormatToken(token, 0, 0, function () { | |
3202 | + var offset = this.utcOffset(), | |
3203 | + sign = '+'; | |
3204 | + if (offset < 0) { | |
3205 | + offset = -offset; | |
3206 | + sign = '-'; | |
3207 | + } | |
3208 | + return ( | |
3209 | + sign + | |
3210 | + zeroFill(~~(offset / 60), 2) + | |
3211 | + separator + | |
3212 | + zeroFill(~~offset % 60, 2) | |
3213 | + ); | |
3214 | + }); | |
3215 | +} | |
3216 | + | |
3217 | +offset('Z', ':'); | |
3218 | +offset('ZZ', ''); | |
3219 | + | |
3220 | +// PARSING | |
3221 | + | |
3222 | +addRegexToken('Z', matchShortOffset); | |
3223 | +addRegexToken('ZZ', matchShortOffset); | |
3224 | +addParseToken(['Z', 'ZZ'], function (input, array, config) { | |
3225 | + config._useUTC = true; | |
3226 | + config._tzm = offsetFromString(matchShortOffset, input); | |
3227 | +}); | |
3228 | + | |
3229 | +// HELPERS | |
3230 | + | |
3231 | +// timezone chunker | |
3232 | +// '+10:00' > ['10', '00'] | |
3233 | +// '-1530' > ['-15', '30'] | |
3234 | +var chunkOffset = /([\+\-]|\d\d)/gi; | |
3235 | + | |
3236 | +function offsetFromString(matcher, string) { | |
3237 | + var matches = (string || '').match(matcher), | |
3238 | + chunk, | |
3239 | + parts, | |
3240 | + minutes; | |
3241 | + | |
3242 | + if (matches === null) { | |
3243 | + return null; | |
3244 | + } | |
3245 | + | |
3246 | + chunk = matches[matches.length - 1] || []; | |
3247 | + parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; | |
3248 | + minutes = +(parts[1] * 60) + toInt(parts[2]); | |
3249 | + | |
3250 | + return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes; | |
3251 | +} | |
3252 | + | |
3253 | +// Return a moment from input, that is local/utc/zone equivalent to model. | |
3254 | +function cloneWithOffset(input, model) { | |
3255 | + var res, diff; | |
3256 | + if (model._isUTC) { | |
3257 | + res = model.clone(); | |
3258 | + diff = | |
3259 | + (isMoment(input) || isDate(input) | |
3260 | + ? input.valueOf() | |
3261 | + : createLocal(input).valueOf()) - res.valueOf(); | |
3262 | + // Use low-level api, because this fn is low-level api. | |
3263 | + res._d.setTime(res._d.valueOf() + diff); | |
3264 | + hooks.updateOffset(res, false); | |
3265 | + return res; | |
3266 | + } else { | |
3267 | + return createLocal(input).local(); | |
3268 | + } | |
3269 | +} | |
3270 | + | |
3271 | +function getDateOffset(m) { | |
3272 | + // On Firefox.24 Date#getTimezoneOffset returns a floating point. | |
3273 | + // https://github.com/moment/moment/pull/1871 | |
3274 | + return -Math.round(m._d.getTimezoneOffset()); | |
3275 | +} | |
3276 | + | |
3277 | +// HOOKS | |
3278 | + | |
3279 | +// This function will be called whenever a moment is mutated. | |
3280 | +// It is intended to keep the offset in sync with the timezone. | |
3281 | +hooks.updateOffset = function () {}; | |
3282 | + | |
3283 | +// MOMENTS | |
3284 | + | |
3285 | +// keepLocalTime = true means only change the timezone, without | |
3286 | +// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> | |
3287 | +// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset | |
3288 | +// +0200, so we adjust the time as needed, to be valid. | |
3289 | +// | |
3290 | +// Keeping the time actually adds/subtracts (one hour) | |
3291 | +// from the actual represented time. That is why we call updateOffset | |
3292 | +// a second time. In case it wants us to change the offset again | |
3293 | +// _changeInProgress == true case, then we have to adjust, because | |
3294 | +// there is no such time in the given timezone. | |
3295 | +function getSetOffset(input, keepLocalTime, keepMinutes) { | |
3296 | + var offset = this._offset || 0, | |
3297 | + localAdjust; | |
3298 | + if (!this.isValid()) { | |
3299 | + return input != null ? this : NaN; | |
3300 | + } | |
3301 | + if (input != null) { | |
3302 | + if (typeof input === 'string') { | |
3303 | + input = offsetFromString(matchShortOffset, input); | |
3304 | + if (input === null) { | |
3305 | + return this; | |
3306 | + } | |
3307 | + } else if (Math.abs(input) < 16 && !keepMinutes) { | |
3308 | + input = input * 60; | |
3309 | + } | |
3310 | + if (!this._isUTC && keepLocalTime) { | |
3311 | + localAdjust = getDateOffset(this); | |
3312 | + } | |
3313 | + this._offset = input; | |
3314 | + this._isUTC = true; | |
3315 | + if (localAdjust != null) { | |
3316 | + this.add(localAdjust, 'm'); | |
3317 | + } | |
3318 | + if (offset !== input) { | |
3319 | + if (!keepLocalTime || this._changeInProgress) { | |
3320 | + addSubtract( | |
3321 | + this, | |
3322 | + createDuration(input - offset, 'm'), | |
3323 | + 1, | |
3324 | + false | |
3325 | + ); | |
3326 | + } else if (!this._changeInProgress) { | |
3327 | + this._changeInProgress = true; | |
3328 | + hooks.updateOffset(this, true); | |
3329 | + this._changeInProgress = null; | |
3330 | + } | |
3331 | + } | |
3332 | + return this; | |
3333 | + } else { | |
3334 | + return this._isUTC ? offset : getDateOffset(this); | |
3335 | + } | |
3336 | +} | |
3337 | + | |
3338 | +function getSetZone(input, keepLocalTime) { | |
3339 | + if (input != null) { | |
3340 | + if (typeof input !== 'string') { | |
3341 | + input = -input; | |
3342 | + } | |
3343 | + | |
3344 | + this.utcOffset(input, keepLocalTime); | |
3345 | + | |
3346 | + return this; | |
3347 | + } else { | |
3348 | + return -this.utcOffset(); | |
3349 | + } | |
3350 | +} | |
3351 | + | |
3352 | +function setOffsetToUTC(keepLocalTime) { | |
3353 | + return this.utcOffset(0, keepLocalTime); | |
3354 | +} | |
3355 | + | |
3356 | +function setOffsetToLocal(keepLocalTime) { | |
3357 | + if (this._isUTC) { | |
3358 | + this.utcOffset(0, keepLocalTime); | |
3359 | + this._isUTC = false; | |
3360 | + | |
3361 | + if (keepLocalTime) { | |
3362 | + this.subtract(getDateOffset(this), 'm'); | |
3363 | + } | |
3364 | + } | |
3365 | + return this; | |
3366 | +} | |
3367 | + | |
3368 | +function setOffsetToParsedOffset() { | |
3369 | + if (this._tzm != null) { | |
3370 | + this.utcOffset(this._tzm, false, true); | |
3371 | + } else if (typeof this._i === 'string') { | |
3372 | + var tZone = offsetFromString(matchOffset, this._i); | |
3373 | + if (tZone != null) { | |
3374 | + this.utcOffset(tZone); | |
3375 | + } else { | |
3376 | + this.utcOffset(0, true); | |
3377 | + } | |
3378 | + } | |
3379 | + return this; | |
3380 | +} | |
3381 | + | |
3382 | +function hasAlignedHourOffset(input) { | |
3383 | + if (!this.isValid()) { | |
3384 | + return false; | |
3385 | + } | |
3386 | + input = input ? createLocal(input).utcOffset() : 0; | |
3387 | + | |
3388 | + return (this.utcOffset() - input) % 60 === 0; | |
3389 | +} | |
3390 | + | |
3391 | +function isDaylightSavingTime() { | |
3392 | + return ( | |
3393 | + this.utcOffset() > this.clone().month(0).utcOffset() || | |
3394 | + this.utcOffset() > this.clone().month(5).utcOffset() | |
3395 | + ); | |
3396 | +} | |
3397 | + | |
3398 | +function isDaylightSavingTimeShifted() { | |
3399 | + if (!isUndefined(this._isDSTShifted)) { | |
3400 | + return this._isDSTShifted; | |
3401 | + } | |
3402 | + | |
3403 | + var c = {}, | |
3404 | + other; | |
3405 | + | |
3406 | + copyConfig(c, this); | |
3407 | + c = prepareConfig(c); | |
3408 | + | |
3409 | + if (c._a) { | |
3410 | + other = c._isUTC ? createUTC(c._a) : createLocal(c._a); | |
3411 | + this._isDSTShifted = | |
3412 | + this.isValid() && compareArrays(c._a, other.toArray()) > 0; | |
3413 | + } else { | |
3414 | + this._isDSTShifted = false; | |
3415 | + } | |
3416 | + | |
3417 | + return this._isDSTShifted; | |
3418 | +} | |
3419 | + | |
3420 | +function isLocal() { | |
3421 | + return this.isValid() ? !this._isUTC : false; | |
3422 | +} | |
3423 | + | |
3424 | +function isUtcOffset() { | |
3425 | + return this.isValid() ? this._isUTC : false; | |
3426 | +} | |
3427 | + | |
3428 | +function isUtc() { | |
3429 | + return this.isValid() ? this._isUTC && this._offset === 0 : false; | |
3430 | +} | |
3431 | + | |
3432 | +// ASP.NET json date format regex | |
3433 | +var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, | |
3434 | + // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html | |
3435 | + // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere | |
3436 | + // and further modified to allow for strings containing both week and day | |
3437 | + isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; | |
3438 | + | |
3439 | +function createDuration(input, key) { | |
3440 | + var duration = input, | |
3441 | + // matching against regexp is expensive, do it on demand | |
3442 | + match = null, | |
3443 | + sign, | |
3444 | + ret, | |
3445 | + diffRes; | |
3446 | + | |
3447 | + if (isDuration(input)) { | |
3448 | + duration = { | |
3449 | + ms: input._milliseconds, | |
3450 | + d: input._days, | |
3451 | + M: input._months, | |
3452 | + }; | |
3453 | + } else if (isNumber(input) || !isNaN(+input)) { | |
3454 | + duration = {}; | |
3455 | + if (key) { | |
3456 | + duration[key] = +input; | |
3457 | + } else { | |
3458 | + duration.milliseconds = +input; | |
3459 | + } | |
3460 | + } else if ((match = aspNetRegex.exec(input))) { | |
3461 | + sign = match[1] === '-' ? -1 : 1; | |
3462 | + duration = { | |
3463 | + y: 0, | |
3464 | + d: toInt(match[DATE]) * sign, | |
3465 | + h: toInt(match[HOUR]) * sign, | |
3466 | + m: toInt(match[MINUTE]) * sign, | |
3467 | + s: toInt(match[SECOND]) * sign, | |
3468 | + ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match | |
3469 | + }; | |
3470 | + } else if ((match = isoRegex.exec(input))) { | |
3471 | + sign = match[1] === '-' ? -1 : 1; | |
3472 | + duration = { | |
3473 | + y: parseIso(match[2], sign), | |
3474 | + M: parseIso(match[3], sign), | |
3475 | + w: parseIso(match[4], sign), | |
3476 | + d: parseIso(match[5], sign), | |
3477 | + h: parseIso(match[6], sign), | |
3478 | + m: parseIso(match[7], sign), | |
3479 | + s: parseIso(match[8], sign), | |
3480 | + }; | |
3481 | + } else if (duration == null) { | |
3482 | + // checks for null or undefined | |
3483 | + duration = {}; | |
3484 | + } else if ( | |
3485 | + typeof duration === 'object' && | |
3486 | + ('from' in duration || 'to' in duration) | |
3487 | + ) { | |
3488 | + diffRes = momentsDifference( | |
3489 | + createLocal(duration.from), | |
3490 | + createLocal(duration.to) | |
3491 | + ); | |
3492 | + | |
3493 | + duration = {}; | |
3494 | + duration.ms = diffRes.milliseconds; | |
3495 | + duration.M = diffRes.months; | |
3496 | + } | |
3497 | + | |
3498 | + ret = new Duration(duration); | |
3499 | + | |
3500 | + if (isDuration(input) && hasOwnProp(input, '_locale')) { | |
3501 | + ret._locale = input._locale; | |
3502 | + } | |
3503 | + | |
3504 | + if (isDuration(input) && hasOwnProp(input, '_isValid')) { | |
3505 | + ret._isValid = input._isValid; | |
3506 | + } | |
3507 | + | |
3508 | + return ret; | |
3509 | +} | |
3510 | + | |
3511 | +createDuration.fn = Duration.prototype; | |
3512 | +createDuration.invalid = createInvalid$1; | |
3513 | + | |
3514 | +function parseIso(inp, sign) { | |
3515 | + // We'd normally use ~~inp for this, but unfortunately it also | |
3516 | + // converts floats to ints. | |
3517 | + // inp may be undefined, so careful calling replace on it. | |
3518 | + var res = inp && parseFloat(inp.replace(',', '.')); | |
3519 | + // apply sign while we're at it | |
3520 | + return (isNaN(res) ? 0 : res) * sign; | |
3521 | +} | |
3522 | + | |
3523 | +function positiveMomentsDifference(base, other) { | |
3524 | + var res = {}; | |
3525 | + | |
3526 | + res.months = | |
3527 | + other.month() - base.month() + (other.year() - base.year()) * 12; | |
3528 | + if (base.clone().add(res.months, 'M').isAfter(other)) { | |
3529 | + --res.months; | |
3530 | + } | |
3531 | + | |
3532 | + res.milliseconds = +other - +base.clone().add(res.months, 'M'); | |
3533 | + | |
3534 | + return res; | |
3535 | +} | |
3536 | + | |
3537 | +function momentsDifference(base, other) { | |
3538 | + var res; | |
3539 | + if (!(base.isValid() && other.isValid())) { | |
3540 | + return { milliseconds: 0, months: 0 }; | |
3541 | + } | |
3542 | + | |
3543 | + other = cloneWithOffset(other, base); | |
3544 | + if (base.isBefore(other)) { | |
3545 | + res = positiveMomentsDifference(base, other); | |
3546 | + } else { | |
3547 | + res = positiveMomentsDifference(other, base); | |
3548 | + res.milliseconds = -res.milliseconds; | |
3549 | + res.months = -res.months; | |
3550 | + } | |
3551 | + | |
3552 | + return res; | |
3553 | +} | |
3554 | + | |
3555 | +// TODO: remove 'name' arg after deprecation is removed | |
3556 | +function createAdder(direction, name) { | |
3557 | + return function (val, period) { | |
3558 | + var dur, tmp; | |
3559 | + //invert the arguments, but complain about it | |
3560 | + if (period !== null && !isNaN(+period)) { | |
3561 | + deprecateSimple( | |
3562 | + name, | |
3563 | + 'moment().' + | |
3564 | + name + | |
3565 | + '(period, number) is deprecated. Please use moment().' + | |
3566 | + name + | |
3567 | + '(number, period). ' + | |
3568 | + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.' | |
3569 | + ); | |
3570 | + tmp = val; | |
3571 | + val = period; | |
3572 | + period = tmp; | |
3573 | + } | |
3574 | + | |
3575 | + dur = createDuration(val, period); | |
3576 | + addSubtract(this, dur, direction); | |
3577 | + return this; | |
3578 | + }; | |
3579 | +} | |
3580 | + | |
3581 | +function addSubtract(mom, duration, isAdding, updateOffset) { | |
3582 | + var milliseconds = duration._milliseconds, | |
3583 | + days = absRound(duration._days), | |
3584 | + months = absRound(duration._months); | |
3585 | + | |
3586 | + if (!mom.isValid()) { | |
3587 | + // No op | |
3588 | + return; | |
3589 | + } | |
3590 | + | |
3591 | + updateOffset = updateOffset == null ? true : updateOffset; | |
3592 | + | |
3593 | + if (months) { | |
3594 | + setMonth(mom, get(mom, 'Month') + months * isAdding); | |
3595 | + } | |
3596 | + if (days) { | |
3597 | + set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); | |
3598 | + } | |
3599 | + if (milliseconds) { | |
3600 | + mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); | |
3601 | + } | |
3602 | + if (updateOffset) { | |
3603 | + hooks.updateOffset(mom, days || months); | |
3604 | + } | |
3605 | +} | |
3606 | + | |
3607 | +var add = createAdder(1, 'add'), | |
3608 | + subtract = createAdder(-1, 'subtract'); | |
3609 | + | |
3610 | +function isString(input) { | |
3611 | + return typeof input === 'string' || input instanceof String; | |
3612 | +} | |
3613 | + | |
3614 | +// type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined | |
3615 | +function isMomentInput(input) { | |
3616 | + return ( | |
3617 | + isMoment(input) || | |
3618 | + isDate(input) || | |
3619 | + isString(input) || | |
3620 | + isNumber(input) || | |
3621 | + isNumberOrStringArray(input) || | |
3622 | + isMomentInputObject(input) || | |
3623 | + input === null || | |
3624 | + input === undefined | |
3625 | + ); | |
3626 | +} | |
3627 | + | |
3628 | +function isMomentInputObject(input) { | |
3629 | + var objectTest = isObject(input) && !isObjectEmpty(input), | |
3630 | + propertyTest = false, | |
3631 | + properties = [ | |
3632 | + 'years', | |
3633 | + 'year', | |
3634 | + 'y', | |
3635 | + 'months', | |
3636 | + 'month', | |
3637 | + 'M', | |
3638 | + 'days', | |
3639 | + 'day', | |
3640 | + 'd', | |
3641 | + 'dates', | |
3642 | + 'date', | |
3643 | + 'D', | |
3644 | + 'hours', | |
3645 | + 'hour', | |
3646 | + 'h', | |
3647 | + 'minutes', | |
3648 | + 'minute', | |
3649 | + 'm', | |
3650 | + 'seconds', | |
3651 | + 'second', | |
3652 | + 's', | |
3653 | + 'milliseconds', | |
3654 | + 'millisecond', | |
3655 | + 'ms', | |
3656 | + ], | |
3657 | + i, | |
3658 | + property; | |
3659 | + | |
3660 | + for (i = 0; i < properties.length; i += 1) { | |
3661 | + property = properties[i]; | |
3662 | + propertyTest = propertyTest || hasOwnProp(input, property); | |
3663 | + } | |
3664 | + | |
3665 | + return objectTest && propertyTest; | |
3666 | +} | |
3667 | + | |
3668 | +function isNumberOrStringArray(input) { | |
3669 | + var arrayTest = isArray(input), | |
3670 | + dataTypeTest = false; | |
3671 | + if (arrayTest) { | |
3672 | + dataTypeTest = | |
3673 | + input.filter(function (item) { | |
3674 | + return !isNumber(item) && isString(input); | |
3675 | + }).length === 0; | |
3676 | + } | |
3677 | + return arrayTest && dataTypeTest; | |
3678 | +} | |
3679 | + | |
3680 | +function isCalendarSpec(input) { | |
3681 | + var objectTest = isObject(input) && !isObjectEmpty(input), | |
3682 | + propertyTest = false, | |
3683 | + properties = [ | |
3684 | + 'sameDay', | |
3685 | + 'nextDay', | |
3686 | + 'lastDay', | |
3687 | + 'nextWeek', | |
3688 | + 'lastWeek', | |
3689 | + 'sameElse', | |
3690 | + ], | |
3691 | + i, | |
3692 | + property; | |
3693 | + | |
3694 | + for (i = 0; i < properties.length; i += 1) { | |
3695 | + property = properties[i]; | |
3696 | + propertyTest = propertyTest || hasOwnProp(input, property); | |
3697 | + } | |
3698 | + | |
3699 | + return objectTest && propertyTest; | |
3700 | +} | |
3701 | + | |
3702 | +function getCalendarFormat(myMoment, now) { | |
3703 | + var diff = myMoment.diff(now, 'days', true); | |
3704 | + return diff < -6 | |
3705 | + ? 'sameElse' | |
3706 | + : diff < -1 | |
3707 | + ? 'lastWeek' | |
3708 | + : diff < 0 | |
3709 | + ? 'lastDay' | |
3710 | + : diff < 1 | |
3711 | + ? 'sameDay' | |
3712 | + : diff < 2 | |
3713 | + ? 'nextDay' | |
3714 | + : diff < 7 | |
3715 | + ? 'nextWeek' | |
3716 | + : 'sameElse'; | |
3717 | +} | |
3718 | + | |
3719 | +function calendar$1(time, formats) { | |
3720 | + // Support for single parameter, formats only overload to the calendar function | |
3721 | + if (arguments.length === 1) { | |
3722 | + if (!arguments[0]) { | |
3723 | + time = undefined; | |
3724 | + formats = undefined; | |
3725 | + } else if (isMomentInput(arguments[0])) { | |
3726 | + time = arguments[0]; | |
3727 | + formats = undefined; | |
3728 | + } else if (isCalendarSpec(arguments[0])) { | |
3729 | + formats = arguments[0]; | |
3730 | + time = undefined; | |
3731 | + } | |
3732 | + } | |
3733 | + // We want to compare the start of today, vs this. | |
3734 | + // Getting start-of-today depends on whether we're local/utc/offset or not. | |
3735 | + var now = time || createLocal(), | |
3736 | + sod = cloneWithOffset(now, this).startOf('day'), | |
3737 | + format = hooks.calendarFormat(this, sod) || 'sameElse', | |
3738 | + output = | |
3739 | + formats && | |
3740 | + (isFunction(formats[format]) | |
3741 | + ? formats[format].call(this, now) | |
3742 | + : formats[format]); | |
3743 | + | |
3744 | + return this.format( | |
3745 | + output || this.localeData().calendar(format, this, createLocal(now)) | |
3746 | + ); | |
3747 | +} | |
3748 | + | |
3749 | +function clone() { | |
3750 | + return new Moment(this); | |
3751 | +} | |
3752 | + | |
3753 | +function isAfter(input, units) { | |
3754 | + var localInput = isMoment(input) ? input : createLocal(input); | |
3755 | + if (!(this.isValid() && localInput.isValid())) { | |
3756 | + return false; | |
3757 | + } | |
3758 | + units = normalizeUnits(units) || 'millisecond'; | |
3759 | + if (units === 'millisecond') { | |
3760 | + return this.valueOf() > localInput.valueOf(); | |
3761 | + } else { | |
3762 | + return localInput.valueOf() < this.clone().startOf(units).valueOf(); | |
3763 | + } | |
3764 | +} | |
3765 | + | |
3766 | +function isBefore(input, units) { | |
3767 | + var localInput = isMoment(input) ? input : createLocal(input); | |
3768 | + if (!(this.isValid() && localInput.isValid())) { | |
3769 | + return false; | |
3770 | + } | |
3771 | + units = normalizeUnits(units) || 'millisecond'; | |
3772 | + if (units === 'millisecond') { | |
3773 | + return this.valueOf() < localInput.valueOf(); | |
3774 | + } else { | |
3775 | + return this.clone().endOf(units).valueOf() < localInput.valueOf(); | |
3776 | + } | |
3777 | +} | |
3778 | + | |
3779 | +function isBetween(from, to, units, inclusivity) { | |
3780 | + var localFrom = isMoment(from) ? from : createLocal(from), | |
3781 | + localTo = isMoment(to) ? to : createLocal(to); | |
3782 | + if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) { | |
3783 | + return false; | |
3784 | + } | |
3785 | + inclusivity = inclusivity || '()'; | |
3786 | + return ( | |
3787 | + (inclusivity[0] === '(' | |
3788 | + ? this.isAfter(localFrom, units) | |
3789 | + : !this.isBefore(localFrom, units)) && | |
3790 | + (inclusivity[1] === ')' | |
3791 | + ? this.isBefore(localTo, units) | |
3792 | + : !this.isAfter(localTo, units)) | |
3793 | + ); | |
3794 | +} | |
3795 | + | |
3796 | +function isSame(input, units) { | |
3797 | + var localInput = isMoment(input) ? input : createLocal(input), | |
3798 | + inputMs; | |
3799 | + if (!(this.isValid() && localInput.isValid())) { | |
3800 | + return false; | |
3801 | + } | |
3802 | + units = normalizeUnits(units) || 'millisecond'; | |
3803 | + if (units === 'millisecond') { | |
3804 | + return this.valueOf() === localInput.valueOf(); | |
3805 | + } else { | |
3806 | + inputMs = localInput.valueOf(); | |
3807 | + return ( | |
3808 | + this.clone().startOf(units).valueOf() <= inputMs && | |
3809 | + inputMs <= this.clone().endOf(units).valueOf() | |
3810 | + ); | |
3811 | + } | |
3812 | +} | |
3813 | + | |
3814 | +function isSameOrAfter(input, units) { | |
3815 | + return this.isSame(input, units) || this.isAfter(input, units); | |
3816 | +} | |
3817 | + | |
3818 | +function isSameOrBefore(input, units) { | |
3819 | + return this.isSame(input, units) || this.isBefore(input, units); | |
3820 | +} | |
3821 | + | |
3822 | +function diff(input, units, asFloat) { | |
3823 | + var that, zoneDelta, output; | |
3824 | + | |
3825 | + if (!this.isValid()) { | |
3826 | + return NaN; | |
3827 | + } | |
3828 | + | |
3829 | + that = cloneWithOffset(input, this); | |
3830 | + | |
3831 | + if (!that.isValid()) { | |
3832 | + return NaN; | |
3833 | + } | |
3834 | + | |
3835 | + zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; | |
3836 | + | |
3837 | + units = normalizeUnits(units); | |
3838 | + | |
3839 | + switch (units) { | |
3840 | + case 'year': | |
3841 | + output = monthDiff(this, that) / 12; | |
3842 | + break; | |
3843 | + case 'month': | |
3844 | + output = monthDiff(this, that); | |
3845 | + break; | |
3846 | + case 'quarter': | |
3847 | + output = monthDiff(this, that) / 3; | |
3848 | + break; | |
3849 | + case 'second': | |
3850 | + output = (this - that) / 1e3; | |
3851 | + break; // 1000 | |
3852 | + case 'minute': | |
3853 | + output = (this - that) / 6e4; | |
3854 | + break; // 1000 * 60 | |
3855 | + case 'hour': | |
3856 | + output = (this - that) / 36e5; | |
3857 | + break; // 1000 * 60 * 60 | |
3858 | + case 'day': | |
3859 | + output = (this - that - zoneDelta) / 864e5; | |
3860 | + break; // 1000 * 60 * 60 * 24, negate dst | |
3861 | + case 'week': | |
3862 | + output = (this - that - zoneDelta) / 6048e5; | |
3863 | + break; // 1000 * 60 * 60 * 24 * 7, negate dst | |
3864 | + default: | |
3865 | + output = this - that; | |
3866 | + } | |
3867 | + | |
3868 | + return asFloat ? output : absFloor(output); | |
3869 | +} | |
3870 | + | |
3871 | +function monthDiff(a, b) { | |
3872 | + if (a.date() < b.date()) { | |
3873 | + // end-of-month calculations work correct when the start month has more | |
3874 | + // days than the end month. | |
3875 | + return -monthDiff(b, a); | |
3876 | + } | |
3877 | + // difference in months | |
3878 | + var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()), | |
3879 | + // b is in (anchor - 1 month, anchor + 1 month) | |
3880 | + anchor = a.clone().add(wholeMonthDiff, 'months'), | |
3881 | + anchor2, | |
3882 | + adjust; | |
3883 | + | |
3884 | + if (b - anchor < 0) { | |
3885 | + anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); | |
3886 | + // linear across the month | |
3887 | + adjust = (b - anchor) / (anchor - anchor2); | |
3888 | + } else { | |
3889 | + anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); | |
3890 | + // linear across the month | |
3891 | + adjust = (b - anchor) / (anchor2 - anchor); | |
3892 | + } | |
3893 | + | |
3894 | + //check for negative zero, return zero if negative zero | |
3895 | + return -(wholeMonthDiff + adjust) || 0; | |
3896 | +} | |
3897 | + | |
3898 | +hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; | |
3899 | +hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; | |
3900 | + | |
3901 | +function toString() { | |
3902 | + return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); | |
3903 | +} | |
3904 | + | |
3905 | +function toISOString(keepOffset) { | |
3906 | + if (!this.isValid()) { | |
3907 | + return null; | |
3908 | + } | |
3909 | + var utc = keepOffset !== true, | |
3910 | + m = utc ? this.clone().utc() : this; | |
3911 | + if (m.year() < 0 || m.year() > 9999) { | |
3912 | + return formatMoment( | |
3913 | + m, | |
3914 | + utc | |
3915 | + ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' | |
3916 | + : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ' | |
3917 | + ); | |
3918 | + } | |
3919 | + if (isFunction(Date.prototype.toISOString)) { | |
3920 | + // native implementation is ~50x faster, use it when we can | |
3921 | + if (utc) { | |
3922 | + return this.toDate().toISOString(); | |
3923 | + } else { | |
3924 | + return new Date(this.valueOf() + this.utcOffset() * 60 * 1000) | |
3925 | + .toISOString() | |
3926 | + .replace('Z', formatMoment(m, 'Z')); | |
3927 | + } | |
3928 | + } | |
3929 | + return formatMoment( | |
3930 | + m, | |
3931 | + utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ' | |
3932 | + ); | |
3933 | +} | |
3934 | + | |
3935 | +/** | |
3936 | + * Return a human readable representation of a moment that can | |
3937 | + * also be evaluated to get a new moment which is the same | |
3938 | + * | |
3939 | + * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects | |
3940 | + */ | |
3941 | +function inspect() { | |
3942 | + if (!this.isValid()) { | |
3943 | + return 'moment.invalid(/* ' + this._i + ' */)'; | |
3944 | + } | |
3945 | + var func = 'moment', | |
3946 | + zone = '', | |
3947 | + prefix, | |
3948 | + year, | |
3949 | + datetime, | |
3950 | + suffix; | |
3951 | + if (!this.isLocal()) { | |
3952 | + func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; | |
3953 | + zone = 'Z'; | |
3954 | + } | |
3955 | + prefix = '[' + func + '("]'; | |
3956 | + year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY'; | |
3957 | + datetime = '-MM-DD[T]HH:mm:ss.SSS'; | |
3958 | + suffix = zone + '[")]'; | |
3959 | + | |
3960 | + return this.format(prefix + year + datetime + suffix); | |
3961 | +} | |
3962 | + | |
3963 | +function format(inputString) { | |
3964 | + if (!inputString) { | |
3965 | + inputString = this.isUtc() | |
3966 | + ? hooks.defaultFormatUtc | |
3967 | + : hooks.defaultFormat; | |
3968 | + } | |
3969 | + var output = formatMoment(this, inputString); | |
3970 | + return this.localeData().postformat(output); | |
3971 | +} | |
3972 | + | |
3973 | +function from(time, withoutSuffix) { | |
3974 | + if ( | |
3975 | + this.isValid() && | |
3976 | + ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) | |
3977 | + ) { | |
3978 | + return createDuration({ to: this, from: time }) | |
3979 | + .locale(this.locale()) | |
3980 | + .humanize(!withoutSuffix); | |
3981 | + } else { | |
3982 | + return this.localeData().invalidDate(); | |
3983 | + } | |
3984 | +} | |
3985 | + | |
3986 | +function fromNow(withoutSuffix) { | |
3987 | + return this.from(createLocal(), withoutSuffix); | |
3988 | +} | |
3989 | + | |
3990 | +function to(time, withoutSuffix) { | |
3991 | + if ( | |
3992 | + this.isValid() && | |
3993 | + ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) | |
3994 | + ) { | |
3995 | + return createDuration({ from: this, to: time }) | |
3996 | + .locale(this.locale()) | |
3997 | + .humanize(!withoutSuffix); | |
3998 | + } else { | |
3999 | + return this.localeData().invalidDate(); | |
4000 | + } | |
4001 | +} | |
4002 | + | |
4003 | +function toNow(withoutSuffix) { | |
4004 | + return this.to(createLocal(), withoutSuffix); | |
4005 | +} | |
4006 | + | |
4007 | +// If passed a locale key, it will set the locale for this | |
4008 | +// instance. Otherwise, it will return the locale configuration | |
4009 | +// variables for this instance. | |
4010 | +function locale(key) { | |
4011 | + var newLocaleData; | |
4012 | + | |
4013 | + if (key === undefined) { | |
4014 | + return this._locale._abbr; | |
4015 | + } else { | |
4016 | + newLocaleData = getLocale(key); | |
4017 | + if (newLocaleData != null) { | |
4018 | + this._locale = newLocaleData; | |
4019 | + } | |
4020 | + return this; | |
4021 | + } | |
4022 | +} | |
4023 | + | |
4024 | +var lang = deprecate( | |
4025 | + 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', | |
4026 | + function (key) { | |
4027 | + if (key === undefined) { | |
4028 | + return this.localeData(); | |
4029 | + } else { | |
4030 | + return this.locale(key); | |
4031 | + } | |
4032 | + } | |
4033 | +); | |
4034 | + | |
4035 | +function localeData() { | |
4036 | + return this._locale; | |
4037 | +} | |
4038 | + | |
4039 | +var MS_PER_SECOND = 1000, | |
4040 | + MS_PER_MINUTE = 60 * MS_PER_SECOND, | |
4041 | + MS_PER_HOUR = 60 * MS_PER_MINUTE, | |
4042 | + MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; | |
4043 | + | |
4044 | +// actual modulo - handles negative numbers (for dates before 1970): | |
4045 | +function mod$1(dividend, divisor) { | |
4046 | + return ((dividend % divisor) + divisor) % divisor; | |
4047 | +} | |
4048 | + | |
4049 | +function localStartOfDate(y, m, d) { | |
4050 | + // the date constructor remaps years 0-99 to 1900-1999 | |
4051 | + if (y < 100 && y >= 0) { | |
4052 | + // preserve leap years using a full 400 year cycle, then reset | |
4053 | + return new Date(y + 400, m, d) - MS_PER_400_YEARS; | |
4054 | + } else { | |
4055 | + return new Date(y, m, d).valueOf(); | |
4056 | + } | |
4057 | +} | |
4058 | + | |
4059 | +function utcStartOfDate(y, m, d) { | |
4060 | + // Date.UTC remaps years 0-99 to 1900-1999 | |
4061 | + if (y < 100 && y >= 0) { | |
4062 | + // preserve leap years using a full 400 year cycle, then reset | |
4063 | + return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS; | |
4064 | + } else { | |
4065 | + return Date.UTC(y, m, d); | |
4066 | + } | |
4067 | +} | |
4068 | + | |
4069 | +function startOf(units) { | |
4070 | + var time, startOfDate; | |
4071 | + units = normalizeUnits(units); | |
4072 | + if (units === undefined || units === 'millisecond' || !this.isValid()) { | |
4073 | + return this; | |
4074 | + } | |
4075 | + | |
4076 | + startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; | |
4077 | + | |
4078 | + switch (units) { | |
4079 | + case 'year': | |
4080 | + time = startOfDate(this.year(), 0, 1); | |
4081 | + break; | |
4082 | + case 'quarter': | |
4083 | + time = startOfDate( | |
4084 | + this.year(), | |
4085 | + this.month() - (this.month() % 3), | |
4086 | + 1 | |
4087 | + ); | |
4088 | + break; | |
4089 | + case 'month': | |
4090 | + time = startOfDate(this.year(), this.month(), 1); | |
4091 | + break; | |
4092 | + case 'week': | |
4093 | + time = startOfDate( | |
4094 | + this.year(), | |
4095 | + this.month(), | |
4096 | + this.date() - this.weekday() | |
4097 | + ); | |
4098 | + break; | |
4099 | + case 'isoWeek': | |
4100 | + time = startOfDate( | |
4101 | + this.year(), | |
4102 | + this.month(), | |
4103 | + this.date() - (this.isoWeekday() - 1) | |
4104 | + ); | |
4105 | + break; | |
4106 | + case 'day': | |
4107 | + case 'date': | |
4108 | + time = startOfDate(this.year(), this.month(), this.date()); | |
4109 | + break; | |
4110 | + case 'hour': | |
4111 | + time = this._d.valueOf(); | |
4112 | + time -= mod$1( | |
4113 | + time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), | |
4114 | + MS_PER_HOUR | |
4115 | + ); | |
4116 | + break; | |
4117 | + case 'minute': | |
4118 | + time = this._d.valueOf(); | |
4119 | + time -= mod$1(time, MS_PER_MINUTE); | |
4120 | + break; | |
4121 | + case 'second': | |
4122 | + time = this._d.valueOf(); | |
4123 | + time -= mod$1(time, MS_PER_SECOND); | |
4124 | + break; | |
4125 | + } | |
4126 | + | |
4127 | + this._d.setTime(time); | |
4128 | + hooks.updateOffset(this, true); | |
4129 | + return this; | |
4130 | +} | |
4131 | + | |
4132 | +function endOf(units) { | |
4133 | + var time, startOfDate; | |
4134 | + units = normalizeUnits(units); | |
4135 | + if (units === undefined || units === 'millisecond' || !this.isValid()) { | |
4136 | + return this; | |
4137 | + } | |
4138 | + | |
4139 | + startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; | |
4140 | + | |
4141 | + switch (units) { | |
4142 | + case 'year': | |
4143 | + time = startOfDate(this.year() + 1, 0, 1) - 1; | |
4144 | + break; | |
4145 | + case 'quarter': | |
4146 | + time = | |
4147 | + startOfDate( | |
4148 | + this.year(), | |
4149 | + this.month() - (this.month() % 3) + 3, | |
4150 | + 1 | |
4151 | + ) - 1; | |
4152 | + break; | |
4153 | + case 'month': | |
4154 | + time = startOfDate(this.year(), this.month() + 1, 1) - 1; | |
4155 | + break; | |
4156 | + case 'week': | |
4157 | + time = | |
4158 | + startOfDate( | |
4159 | + this.year(), | |
4160 | + this.month(), | |
4161 | + this.date() - this.weekday() + 7 | |
4162 | + ) - 1; | |
4163 | + break; | |
4164 | + case 'isoWeek': | |
4165 | + time = | |
4166 | + startOfDate( | |
4167 | + this.year(), | |
4168 | + this.month(), | |
4169 | + this.date() - (this.isoWeekday() - 1) + 7 | |
4170 | + ) - 1; | |
4171 | + break; | |
4172 | + case 'day': | |
4173 | + case 'date': | |
4174 | + time = startOfDate(this.year(), this.month(), this.date() + 1) - 1; | |
4175 | + break; | |
4176 | + case 'hour': | |
4177 | + time = this._d.valueOf(); | |
4178 | + time += | |
4179 | + MS_PER_HOUR - | |
4180 | + mod$1( | |
4181 | + time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), | |
4182 | + MS_PER_HOUR | |
4183 | + ) - | |
4184 | + 1; | |
4185 | + break; | |
4186 | + case 'minute': | |
4187 | + time = this._d.valueOf(); | |
4188 | + time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1; | |
4189 | + break; | |
4190 | + case 'second': | |
4191 | + time = this._d.valueOf(); | |
4192 | + time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1; | |
4193 | + break; | |
4194 | + } | |
4195 | + | |
4196 | + this._d.setTime(time); | |
4197 | + hooks.updateOffset(this, true); | |
4198 | + return this; | |
4199 | +} | |
4200 | + | |
4201 | +function valueOf() { | |
4202 | + return this._d.valueOf() - (this._offset || 0) * 60000; | |
4203 | +} | |
4204 | + | |
4205 | +function unix() { | |
4206 | + return Math.floor(this.valueOf() / 1000); | |
4207 | +} | |
4208 | + | |
4209 | +function toDate() { | |
4210 | + return new Date(this.valueOf()); | |
4211 | +} | |
4212 | + | |
4213 | +function toArray() { | |
4214 | + var m = this; | |
4215 | + return [ | |
4216 | + m.year(), | |
4217 | + m.month(), | |
4218 | + m.date(), | |
4219 | + m.hour(), | |
4220 | + m.minute(), | |
4221 | + m.second(), | |
4222 | + m.millisecond(), | |
4223 | + ]; | |
4224 | +} | |
4225 | + | |
4226 | +function toObject() { | |
4227 | + var m = this; | |
4228 | + return { | |
4229 | + years: m.year(), | |
4230 | + months: m.month(), | |
4231 | + date: m.date(), | |
4232 | + hours: m.hours(), | |
4233 | + minutes: m.minutes(), | |
4234 | + seconds: m.seconds(), | |
4235 | + milliseconds: m.milliseconds(), | |
4236 | + }; | |
4237 | +} | |
4238 | + | |
4239 | +function toJSON() { | |
4240 | + // new Date(NaN).toJSON() === null | |
4241 | + return this.isValid() ? this.toISOString() : null; | |
4242 | +} | |
4243 | + | |
4244 | +function isValid$2() { | |
4245 | + return isValid(this); | |
4246 | +} | |
4247 | + | |
4248 | +function parsingFlags() { | |
4249 | + return extend({}, getParsingFlags(this)); | |
4250 | +} | |
4251 | + | |
4252 | +function invalidAt() { | |
4253 | + return getParsingFlags(this).overflow; | |
4254 | +} | |
4255 | + | |
4256 | +function creationData() { | |
4257 | + return { | |
4258 | + input: this._i, | |
4259 | + format: this._f, | |
4260 | + locale: this._locale, | |
4261 | + isUTC: this._isUTC, | |
4262 | + strict: this._strict, | |
4263 | + }; | |
4264 | +} | |
4265 | + | |
4266 | +addFormatToken('N', 0, 0, 'eraAbbr'); | |
4267 | +addFormatToken('NN', 0, 0, 'eraAbbr'); | |
4268 | +addFormatToken('NNN', 0, 0, 'eraAbbr'); | |
4269 | +addFormatToken('NNNN', 0, 0, 'eraName'); | |
4270 | +addFormatToken('NNNNN', 0, 0, 'eraNarrow'); | |
4271 | + | |
4272 | +addFormatToken('y', ['y', 1], 'yo', 'eraYear'); | |
4273 | +addFormatToken('y', ['yy', 2], 0, 'eraYear'); | |
4274 | +addFormatToken('y', ['yyy', 3], 0, 'eraYear'); | |
4275 | +addFormatToken('y', ['yyyy', 4], 0, 'eraYear'); | |
4276 | + | |
4277 | +addRegexToken('N', matchEraAbbr); | |
4278 | +addRegexToken('NN', matchEraAbbr); | |
4279 | +addRegexToken('NNN', matchEraAbbr); | |
4280 | +addRegexToken('NNNN', matchEraName); | |
4281 | +addRegexToken('NNNNN', matchEraNarrow); | |
4282 | + | |
4283 | +addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function ( | |
4284 | + input, | |
4285 | + array, | |
4286 | + config, | |
4287 | + token | |
4288 | +) { | |
4289 | + var era = config._locale.erasParse(input, token, config._strict); | |
4290 | + if (era) { | |
4291 | + getParsingFlags(config).era = era; | |
4292 | + } else { | |
4293 | + getParsingFlags(config).invalidEra = input; | |
4294 | + } | |
4295 | +}); | |
4296 | + | |
4297 | +addRegexToken('y', matchUnsigned); | |
4298 | +addRegexToken('yy', matchUnsigned); | |
4299 | +addRegexToken('yyy', matchUnsigned); | |
4300 | +addRegexToken('yyyy', matchUnsigned); | |
4301 | +addRegexToken('yo', matchEraYearOrdinal); | |
4302 | + | |
4303 | +addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR); | |
4304 | +addParseToken(['yo'], function (input, array, config, token) { | |
4305 | + var match; | |
4306 | + if (config._locale._eraYearOrdinalRegex) { | |
4307 | + match = input.match(config._locale._eraYearOrdinalRegex); | |
4308 | + } | |
4309 | + | |
4310 | + if (config._locale.eraYearOrdinalParse) { | |
4311 | + array[YEAR] = config._locale.eraYearOrdinalParse(input, match); | |
4312 | + } else { | |
4313 | + array[YEAR] = parseInt(input, 10); | |
4314 | + } | |
4315 | +}); | |
4316 | + | |
4317 | +function localeEras(m, format) { | |
4318 | + var i, | |
4319 | + l, | |
4320 | + date, | |
4321 | + eras = this._eras || getLocale('en')._eras; | |
4322 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4323 | + switch (typeof eras[i].since) { | |
4324 | + case 'string': | |
4325 | + // truncate time | |
4326 | + date = hooks(eras[i].since).startOf('day'); | |
4327 | + eras[i].since = date.valueOf(); | |
4328 | + break; | |
4329 | + } | |
4330 | + | |
4331 | + switch (typeof eras[i].until) { | |
4332 | + case 'undefined': | |
4333 | + eras[i].until = +Infinity; | |
4334 | + break; | |
4335 | + case 'string': | |
4336 | + // truncate time | |
4337 | + date = hooks(eras[i].until).startOf('day').valueOf(); | |
4338 | + eras[i].until = date.valueOf(); | |
4339 | + break; | |
4340 | + } | |
4341 | + } | |
4342 | + return eras; | |
4343 | +} | |
4344 | + | |
4345 | +function localeErasParse(eraName, format, strict) { | |
4346 | + var i, | |
4347 | + l, | |
4348 | + eras = this.eras(), | |
4349 | + name, | |
4350 | + abbr, | |
4351 | + narrow; | |
4352 | + eraName = eraName.toUpperCase(); | |
4353 | + | |
4354 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4355 | + name = eras[i].name.toUpperCase(); | |
4356 | + abbr = eras[i].abbr.toUpperCase(); | |
4357 | + narrow = eras[i].narrow.toUpperCase(); | |
4358 | + | |
4359 | + if (strict) { | |
4360 | + switch (format) { | |
4361 | + case 'N': | |
4362 | + case 'NN': | |
4363 | + case 'NNN': | |
4364 | + if (abbr === eraName) { | |
4365 | + return eras[i]; | |
4366 | + } | |
4367 | + break; | |
4368 | + | |
4369 | + case 'NNNN': | |
4370 | + if (name === eraName) { | |
4371 | + return eras[i]; | |
4372 | + } | |
4373 | + break; | |
4374 | + | |
4375 | + case 'NNNNN': | |
4376 | + if (narrow === eraName) { | |
4377 | + return eras[i]; | |
4378 | + } | |
4379 | + break; | |
4380 | + } | |
4381 | + } else if ([name, abbr, narrow].indexOf(eraName) >= 0) { | |
4382 | + return eras[i]; | |
4383 | + } | |
4384 | + } | |
4385 | +} | |
4386 | + | |
4387 | +function localeErasConvertYear(era, year) { | |
4388 | + var dir = era.since <= era.until ? +1 : -1; | |
4389 | + if (year === undefined) { | |
4390 | + return hooks(era.since).year(); | |
4391 | + } else { | |
4392 | + return hooks(era.since).year() + (year - era.offset) * dir; | |
4393 | + } | |
4394 | +} | |
4395 | + | |
4396 | +function getEraName() { | |
4397 | + var i, | |
4398 | + l, | |
4399 | + val, | |
4400 | + eras = this.localeData().eras(); | |
4401 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4402 | + // truncate time | |
4403 | + val = this.clone().startOf('day').valueOf(); | |
4404 | + | |
4405 | + if (eras[i].since <= val && val <= eras[i].until) { | |
4406 | + return eras[i].name; | |
4407 | + } | |
4408 | + if (eras[i].until <= val && val <= eras[i].since) { | |
4409 | + return eras[i].name; | |
4410 | + } | |
4411 | + } | |
4412 | + | |
4413 | + return ''; | |
4414 | +} | |
4415 | + | |
4416 | +function getEraNarrow() { | |
4417 | + var i, | |
4418 | + l, | |
4419 | + val, | |
4420 | + eras = this.localeData().eras(); | |
4421 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4422 | + // truncate time | |
4423 | + val = this.clone().startOf('day').valueOf(); | |
4424 | + | |
4425 | + if (eras[i].since <= val && val <= eras[i].until) { | |
4426 | + return eras[i].narrow; | |
4427 | + } | |
4428 | + if (eras[i].until <= val && val <= eras[i].since) { | |
4429 | + return eras[i].narrow; | |
4430 | + } | |
4431 | + } | |
4432 | + | |
4433 | + return ''; | |
4434 | +} | |
4435 | + | |
4436 | +function getEraAbbr() { | |
4437 | + var i, | |
4438 | + l, | |
4439 | + val, | |
4440 | + eras = this.localeData().eras(); | |
4441 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4442 | + // truncate time | |
4443 | + val = this.clone().startOf('day').valueOf(); | |
4444 | + | |
4445 | + if (eras[i].since <= val && val <= eras[i].until) { | |
4446 | + return eras[i].abbr; | |
4447 | + } | |
4448 | + if (eras[i].until <= val && val <= eras[i].since) { | |
4449 | + return eras[i].abbr; | |
4450 | + } | |
4451 | + } | |
4452 | + | |
4453 | + return ''; | |
4454 | +} | |
4455 | + | |
4456 | +function getEraYear() { | |
4457 | + var i, | |
4458 | + l, | |
4459 | + dir, | |
4460 | + val, | |
4461 | + eras = this.localeData().eras(); | |
4462 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4463 | + dir = eras[i].since <= eras[i].until ? +1 : -1; | |
4464 | + | |
4465 | + // truncate time | |
4466 | + val = this.clone().startOf('day').valueOf(); | |
4467 | + | |
4468 | + if ( | |
4469 | + (eras[i].since <= val && val <= eras[i].until) || | |
4470 | + (eras[i].until <= val && val <= eras[i].since) | |
4471 | + ) { | |
4472 | + return ( | |
4473 | + (this.year() - hooks(eras[i].since).year()) * dir + | |
4474 | + eras[i].offset | |
4475 | + ); | |
4476 | + } | |
4477 | + } | |
4478 | + | |
4479 | + return this.year(); | |
4480 | +} | |
4481 | + | |
4482 | +function erasNameRegex(isStrict) { | |
4483 | + if (!hasOwnProp(this, '_erasNameRegex')) { | |
4484 | + computeErasParse.call(this); | |
4485 | + } | |
4486 | + return isStrict ? this._erasNameRegex : this._erasRegex; | |
4487 | +} | |
4488 | + | |
4489 | +function erasAbbrRegex(isStrict) { | |
4490 | + if (!hasOwnProp(this, '_erasAbbrRegex')) { | |
4491 | + computeErasParse.call(this); | |
4492 | + } | |
4493 | + return isStrict ? this._erasAbbrRegex : this._erasRegex; | |
4494 | +} | |
4495 | + | |
4496 | +function erasNarrowRegex(isStrict) { | |
4497 | + if (!hasOwnProp(this, '_erasNarrowRegex')) { | |
4498 | + computeErasParse.call(this); | |
4499 | + } | |
4500 | + return isStrict ? this._erasNarrowRegex : this._erasRegex; | |
4501 | +} | |
4502 | + | |
4503 | +function matchEraAbbr(isStrict, locale) { | |
4504 | + return locale.erasAbbrRegex(isStrict); | |
4505 | +} | |
4506 | + | |
4507 | +function matchEraName(isStrict, locale) { | |
4508 | + return locale.erasNameRegex(isStrict); | |
4509 | +} | |
4510 | + | |
4511 | +function matchEraNarrow(isStrict, locale) { | |
4512 | + return locale.erasNarrowRegex(isStrict); | |
4513 | +} | |
4514 | + | |
4515 | +function matchEraYearOrdinal(isStrict, locale) { | |
4516 | + return locale._eraYearOrdinalRegex || matchUnsigned; | |
4517 | +} | |
4518 | + | |
4519 | +function computeErasParse() { | |
4520 | + var abbrPieces = [], | |
4521 | + namePieces = [], | |
4522 | + narrowPieces = [], | |
4523 | + mixedPieces = [], | |
4524 | + i, | |
4525 | + l, | |
4526 | + eras = this.eras(); | |
4527 | + | |
4528 | + for (i = 0, l = eras.length; i < l; ++i) { | |
4529 | + namePieces.push(regexEscape(eras[i].name)); | |
4530 | + abbrPieces.push(regexEscape(eras[i].abbr)); | |
4531 | + narrowPieces.push(regexEscape(eras[i].narrow)); | |
4532 | + | |
4533 | + mixedPieces.push(regexEscape(eras[i].name)); | |
4534 | + mixedPieces.push(regexEscape(eras[i].abbr)); | |
4535 | + mixedPieces.push(regexEscape(eras[i].narrow)); | |
4536 | + } | |
4537 | + | |
4538 | + this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); | |
4539 | + this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i'); | |
4540 | + this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i'); | |
4541 | + this._erasNarrowRegex = new RegExp( | |
4542 | + '^(' + narrowPieces.join('|') + ')', | |
4543 | + 'i' | |
4544 | + ); | |
4545 | +} | |
4546 | + | |
4547 | +// FORMATTING | |
4548 | + | |
4549 | +addFormatToken(0, ['gg', 2], 0, function () { | |
4550 | + return this.weekYear() % 100; | |
4551 | +}); | |
4552 | + | |
4553 | +addFormatToken(0, ['GG', 2], 0, function () { | |
4554 | + return this.isoWeekYear() % 100; | |
4555 | +}); | |
4556 | + | |
4557 | +function addWeekYearFormatToken(token, getter) { | |
4558 | + addFormatToken(0, [token, token.length], 0, getter); | |
4559 | +} | |
4560 | + | |
4561 | +addWeekYearFormatToken('gggg', 'weekYear'); | |
4562 | +addWeekYearFormatToken('ggggg', 'weekYear'); | |
4563 | +addWeekYearFormatToken('GGGG', 'isoWeekYear'); | |
4564 | +addWeekYearFormatToken('GGGGG', 'isoWeekYear'); | |
4565 | + | |
4566 | +// ALIASES | |
4567 | + | |
4568 | +addUnitAlias('weekYear', 'gg'); | |
4569 | +addUnitAlias('isoWeekYear', 'GG'); | |
4570 | + | |
4571 | +// PRIORITY | |
4572 | + | |
4573 | +addUnitPriority('weekYear', 1); | |
4574 | +addUnitPriority('isoWeekYear', 1); | |
4575 | + | |
4576 | +// PARSING | |
4577 | + | |
4578 | +addRegexToken('G', matchSigned); | |
4579 | +addRegexToken('g', matchSigned); | |
4580 | +addRegexToken('GG', match1to2, match2); | |
4581 | +addRegexToken('gg', match1to2, match2); | |
4582 | +addRegexToken('GGGG', match1to4, match4); | |
4583 | +addRegexToken('gggg', match1to4, match4); | |
4584 | +addRegexToken('GGGGG', match1to6, match6); | |
4585 | +addRegexToken('ggggg', match1to6, match6); | |
4586 | + | |
4587 | +addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function ( | |
4588 | + input, | |
4589 | + week, | |
4590 | + config, | |
4591 | + token | |
4592 | +) { | |
4593 | + week[token.substr(0, 2)] = toInt(input); | |
4594 | +}); | |
4595 | + | |
4596 | +addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { | |
4597 | + week[token] = hooks.parseTwoDigitYear(input); | |
4598 | +}); | |
4599 | + | |
4600 | +// MOMENTS | |
4601 | + | |
4602 | +function getSetWeekYear(input) { | |
4603 | + return getSetWeekYearHelper.call( | |
4604 | + this, | |
4605 | + input, | |
4606 | + this.week(), | |
4607 | + this.weekday(), | |
4608 | + this.localeData()._week.dow, | |
4609 | + this.localeData()._week.doy | |
4610 | + ); | |
4611 | +} | |
4612 | + | |
4613 | +function getSetISOWeekYear(input) { | |
4614 | + return getSetWeekYearHelper.call( | |
4615 | + this, | |
4616 | + input, | |
4617 | + this.isoWeek(), | |
4618 | + this.isoWeekday(), | |
4619 | + 1, | |
4620 | + 4 | |
4621 | + ); | |
4622 | +} | |
4623 | + | |
4624 | +function getISOWeeksInYear() { | |
4625 | + return weeksInYear(this.year(), 1, 4); | |
4626 | +} | |
4627 | + | |
4628 | +function getISOWeeksInISOWeekYear() { | |
4629 | + return weeksInYear(this.isoWeekYear(), 1, 4); | |
4630 | +} | |
4631 | + | |
4632 | +function getWeeksInYear() { | |
4633 | + var weekInfo = this.localeData()._week; | |
4634 | + return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); | |
4635 | +} | |
4636 | + | |
4637 | +function getWeeksInWeekYear() { | |
4638 | + var weekInfo = this.localeData()._week; | |
4639 | + return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy); | |
4640 | +} | |
4641 | + | |
4642 | +function getSetWeekYearHelper(input, week, weekday, dow, doy) { | |
4643 | + var weeksTarget; | |
4644 | + if (input == null) { | |
4645 | + return weekOfYear(this, dow, doy).year; | |
4646 | + } else { | |
4647 | + weeksTarget = weeksInYear(input, dow, doy); | |
4648 | + if (week > weeksTarget) { | |
4649 | + week = weeksTarget; | |
4650 | + } | |
4651 | + return setWeekAll.call(this, input, week, weekday, dow, doy); | |
4652 | + } | |
4653 | +} | |
4654 | + | |
4655 | +function setWeekAll(weekYear, week, weekday, dow, doy) { | |
4656 | + var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), | |
4657 | + date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); | |
4658 | + | |
4659 | + this.year(date.getUTCFullYear()); | |
4660 | + this.month(date.getUTCMonth()); | |
4661 | + this.date(date.getUTCDate()); | |
4662 | + return this; | |
4663 | +} | |
4664 | + | |
4665 | +// FORMATTING | |
4666 | + | |
4667 | +addFormatToken('Q', 0, 'Qo', 'quarter'); | |
4668 | + | |
4669 | +// ALIASES | |
4670 | + | |
4671 | +addUnitAlias('quarter', 'Q'); | |
4672 | + | |
4673 | +// PRIORITY | |
4674 | + | |
4675 | +addUnitPriority('quarter', 7); | |
4676 | + | |
4677 | +// PARSING | |
4678 | + | |
4679 | +addRegexToken('Q', match1); | |
4680 | +addParseToken('Q', function (input, array) { | |
4681 | + array[MONTH] = (toInt(input) - 1) * 3; | |
4682 | +}); | |
4683 | + | |
4684 | +// MOMENTS | |
4685 | + | |
4686 | +function getSetQuarter(input) { | |
4687 | + return input == null | |
4688 | + ? Math.ceil((this.month() + 1) / 3) | |
4689 | + : this.month((input - 1) * 3 + (this.month() % 3)); | |
4690 | +} | |
4691 | + | |
4692 | +// FORMATTING | |
4693 | + | |
4694 | +addFormatToken('D', ['DD', 2], 'Do', 'date'); | |
4695 | + | |
4696 | +// ALIASES | |
4697 | + | |
4698 | +addUnitAlias('date', 'D'); | |
4699 | + | |
4700 | +// PRIORITY | |
4701 | +addUnitPriority('date', 9); | |
4702 | + | |
4703 | +// PARSING | |
4704 | + | |
4705 | +addRegexToken('D', match1to2); | |
4706 | +addRegexToken('DD', match1to2, match2); | |
4707 | +addRegexToken('Do', function (isStrict, locale) { | |
4708 | + // TODO: Remove "ordinalParse" fallback in next major release. | |
4709 | + return isStrict | |
4710 | + ? locale._dayOfMonthOrdinalParse || locale._ordinalParse | |
4711 | + : locale._dayOfMonthOrdinalParseLenient; | |
4712 | +}); | |
4713 | + | |
4714 | +addParseToken(['D', 'DD'], DATE); | |
4715 | +addParseToken('Do', function (input, array) { | |
4716 | + array[DATE] = toInt(input.match(match1to2)[0]); | |
4717 | +}); | |
4718 | + | |
4719 | +// MOMENTS | |
4720 | + | |
4721 | +var getSetDayOfMonth = makeGetSet('Date', true); | |
4722 | + | |
4723 | +// FORMATTING | |
4724 | + | |
4725 | +addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); | |
4726 | + | |
4727 | +// ALIASES | |
4728 | + | |
4729 | +addUnitAlias('dayOfYear', 'DDD'); | |
4730 | + | |
4731 | +// PRIORITY | |
4732 | +addUnitPriority('dayOfYear', 4); | |
4733 | + | |
4734 | +// PARSING | |
4735 | + | |
4736 | +addRegexToken('DDD', match1to3); | |
4737 | +addRegexToken('DDDD', match3); | |
4738 | +addParseToken(['DDD', 'DDDD'], function (input, array, config) { | |
4739 | + config._dayOfYear = toInt(input); | |
4740 | +}); | |
4741 | + | |
4742 | +// HELPERS | |
4743 | + | |
4744 | +// MOMENTS | |
4745 | + | |
4746 | +function getSetDayOfYear(input) { | |
4747 | + var dayOfYear = | |
4748 | + Math.round( | |
4749 | + (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5 | |
4750 | + ) + 1; | |
4751 | + return input == null ? dayOfYear : this.add(input - dayOfYear, 'd'); | |
4752 | +} | |
4753 | + | |
4754 | +// FORMATTING | |
4755 | + | |
4756 | +addFormatToken('m', ['mm', 2], 0, 'minute'); | |
4757 | + | |
4758 | +// ALIASES | |
4759 | + | |
4760 | +addUnitAlias('minute', 'm'); | |
4761 | + | |
4762 | +// PRIORITY | |
4763 | + | |
4764 | +addUnitPriority('minute', 14); | |
4765 | + | |
4766 | +// PARSING | |
4767 | + | |
4768 | +addRegexToken('m', match1to2); | |
4769 | +addRegexToken('mm', match1to2, match2); | |
4770 | +addParseToken(['m', 'mm'], MINUTE); | |
4771 | + | |
4772 | +// MOMENTS | |
4773 | + | |
4774 | +var getSetMinute = makeGetSet('Minutes', false); | |
4775 | + | |
4776 | +// FORMATTING | |
4777 | + | |
4778 | +addFormatToken('s', ['ss', 2], 0, 'second'); | |
4779 | + | |
4780 | +// ALIASES | |
4781 | + | |
4782 | +addUnitAlias('second', 's'); | |
4783 | + | |
4784 | +// PRIORITY | |
4785 | + | |
4786 | +addUnitPriority('second', 15); | |
4787 | + | |
4788 | +// PARSING | |
4789 | + | |
4790 | +addRegexToken('s', match1to2); | |
4791 | +addRegexToken('ss', match1to2, match2); | |
4792 | +addParseToken(['s', 'ss'], SECOND); | |
4793 | + | |
4794 | +// MOMENTS | |
4795 | + | |
4796 | +var getSetSecond = makeGetSet('Seconds', false); | |
4797 | + | |
4798 | +// FORMATTING | |
4799 | + | |
4800 | +addFormatToken('S', 0, 0, function () { | |
4801 | + return ~~(this.millisecond() / 100); | |
4802 | +}); | |
4803 | + | |
4804 | +addFormatToken(0, ['SS', 2], 0, function () { | |
4805 | + return ~~(this.millisecond() / 10); | |
4806 | +}); | |
4807 | + | |
4808 | +addFormatToken(0, ['SSS', 3], 0, 'millisecond'); | |
4809 | +addFormatToken(0, ['SSSS', 4], 0, function () { | |
4810 | + return this.millisecond() * 10; | |
4811 | +}); | |
4812 | +addFormatToken(0, ['SSSSS', 5], 0, function () { | |
4813 | + return this.millisecond() * 100; | |
4814 | +}); | |
4815 | +addFormatToken(0, ['SSSSSS', 6], 0, function () { | |
4816 | + return this.millisecond() * 1000; | |
4817 | +}); | |
4818 | +addFormatToken(0, ['SSSSSSS', 7], 0, function () { | |
4819 | + return this.millisecond() * 10000; | |
4820 | +}); | |
4821 | +addFormatToken(0, ['SSSSSSSS', 8], 0, function () { | |
4822 | + return this.millisecond() * 100000; | |
4823 | +}); | |
4824 | +addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { | |
4825 | + return this.millisecond() * 1000000; | |
4826 | +}); | |
4827 | + | |
4828 | +// ALIASES | |
4829 | + | |
4830 | +addUnitAlias('millisecond', 'ms'); | |
4831 | + | |
4832 | +// PRIORITY | |
4833 | + | |
4834 | +addUnitPriority('millisecond', 16); | |
4835 | + | |
4836 | +// PARSING | |
4837 | + | |
4838 | +addRegexToken('S', match1to3, match1); | |
4839 | +addRegexToken('SS', match1to3, match2); | |
4840 | +addRegexToken('SSS', match1to3, match3); | |
4841 | + | |
4842 | +var token, getSetMillisecond; | |
4843 | +for (token = 'SSSS'; token.length <= 9; token += 'S') { | |
4844 | + addRegexToken(token, matchUnsigned); | |
4845 | +} | |
4846 | + | |
4847 | +function parseMs(input, array) { | |
4848 | + array[MILLISECOND] = toInt(('0.' + input) * 1000); | |
4849 | +} | |
4850 | + | |
4851 | +for (token = 'S'; token.length <= 9; token += 'S') { | |
4852 | + addParseToken(token, parseMs); | |
4853 | +} | |
4854 | + | |
4855 | +getSetMillisecond = makeGetSet('Milliseconds', false); | |
4856 | + | |
4857 | +// FORMATTING | |
4858 | + | |
4859 | +addFormatToken('z', 0, 0, 'zoneAbbr'); | |
4860 | +addFormatToken('zz', 0, 0, 'zoneName'); | |
4861 | + | |
4862 | +// MOMENTS | |
4863 | + | |
4864 | +function getZoneAbbr() { | |
4865 | + return this._isUTC ? 'UTC' : ''; | |
4866 | +} | |
4867 | + | |
4868 | +function getZoneName() { | |
4869 | + return this._isUTC ? 'Coordinated Universal Time' : ''; | |
4870 | +} | |
4871 | + | |
4872 | +var proto = Moment.prototype; | |
4873 | + | |
4874 | +proto.add = add; | |
4875 | +proto.calendar = calendar$1; | |
4876 | +proto.clone = clone; | |
4877 | +proto.diff = diff; | |
4878 | +proto.endOf = endOf; | |
4879 | +proto.format = format; | |
4880 | +proto.from = from; | |
4881 | +proto.fromNow = fromNow; | |
4882 | +proto.to = to; | |
4883 | +proto.toNow = toNow; | |
4884 | +proto.get = stringGet; | |
4885 | +proto.invalidAt = invalidAt; | |
4886 | +proto.isAfter = isAfter; | |
4887 | +proto.isBefore = isBefore; | |
4888 | +proto.isBetween = isBetween; | |
4889 | +proto.isSame = isSame; | |
4890 | +proto.isSameOrAfter = isSameOrAfter; | |
4891 | +proto.isSameOrBefore = isSameOrBefore; | |
4892 | +proto.isValid = isValid$2; | |
4893 | +proto.lang = lang; | |
4894 | +proto.locale = locale; | |
4895 | +proto.localeData = localeData; | |
4896 | +proto.max = prototypeMax; | |
4897 | +proto.min = prototypeMin; | |
4898 | +proto.parsingFlags = parsingFlags; | |
4899 | +proto.set = stringSet; | |
4900 | +proto.startOf = startOf; | |
4901 | +proto.subtract = subtract; | |
4902 | +proto.toArray = toArray; | |
4903 | +proto.toObject = toObject; | |
4904 | +proto.toDate = toDate; | |
4905 | +proto.toISOString = toISOString; | |
4906 | +proto.inspect = inspect; | |
4907 | +if (typeof Symbol !== 'undefined' && Symbol.for != null) { | |
4908 | + proto[Symbol.for('nodejs.util.inspect.custom')] = function () { | |
4909 | + return 'Moment<' + this.format() + '>'; | |
4910 | + }; | |
4911 | +} | |
4912 | +proto.toJSON = toJSON; | |
4913 | +proto.toString = toString; | |
4914 | +proto.unix = unix; | |
4915 | +proto.valueOf = valueOf; | |
4916 | +proto.creationData = creationData; | |
4917 | +proto.eraName = getEraName; | |
4918 | +proto.eraNarrow = getEraNarrow; | |
4919 | +proto.eraAbbr = getEraAbbr; | |
4920 | +proto.eraYear = getEraYear; | |
4921 | +proto.year = getSetYear; | |
4922 | +proto.isLeapYear = getIsLeapYear; | |
4923 | +proto.weekYear = getSetWeekYear; | |
4924 | +proto.isoWeekYear = getSetISOWeekYear; | |
4925 | +proto.quarter = proto.quarters = getSetQuarter; | |
4926 | +proto.month = getSetMonth; | |
4927 | +proto.daysInMonth = getDaysInMonth; | |
4928 | +proto.week = proto.weeks = getSetWeek; | |
4929 | +proto.isoWeek = proto.isoWeeks = getSetISOWeek; | |
4930 | +proto.weeksInYear = getWeeksInYear; | |
4931 | +proto.weeksInWeekYear = getWeeksInWeekYear; | |
4932 | +proto.isoWeeksInYear = getISOWeeksInYear; | |
4933 | +proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear; | |
4934 | +proto.date = getSetDayOfMonth; | |
4935 | +proto.day = proto.days = getSetDayOfWeek; | |
4936 | +proto.weekday = getSetLocaleDayOfWeek; | |
4937 | +proto.isoWeekday = getSetISODayOfWeek; | |
4938 | +proto.dayOfYear = getSetDayOfYear; | |
4939 | +proto.hour = proto.hours = getSetHour; | |
4940 | +proto.minute = proto.minutes = getSetMinute; | |
4941 | +proto.second = proto.seconds = getSetSecond; | |
4942 | +proto.millisecond = proto.milliseconds = getSetMillisecond; | |
4943 | +proto.utcOffset = getSetOffset; | |
4944 | +proto.utc = setOffsetToUTC; | |
4945 | +proto.local = setOffsetToLocal; | |
4946 | +proto.parseZone = setOffsetToParsedOffset; | |
4947 | +proto.hasAlignedHourOffset = hasAlignedHourOffset; | |
4948 | +proto.isDST = isDaylightSavingTime; | |
4949 | +proto.isLocal = isLocal; | |
4950 | +proto.isUtcOffset = isUtcOffset; | |
4951 | +proto.isUtc = isUtc; | |
4952 | +proto.isUTC = isUtc; | |
4953 | +proto.zoneAbbr = getZoneAbbr; | |
4954 | +proto.zoneName = getZoneName; | |
4955 | +proto.dates = deprecate( | |
4956 | + 'dates accessor is deprecated. Use date instead.', | |
4957 | + getSetDayOfMonth | |
4958 | +); | |
4959 | +proto.months = deprecate( | |
4960 | + 'months accessor is deprecated. Use month instead', | |
4961 | + getSetMonth | |
4962 | +); | |
4963 | +proto.years = deprecate( | |
4964 | + 'years accessor is deprecated. Use year instead', | |
4965 | + getSetYear | |
4966 | +); | |
4967 | +proto.zone = deprecate( | |
4968 | + 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', | |
4969 | + getSetZone | |
4970 | +); | |
4971 | +proto.isDSTShifted = deprecate( | |
4972 | + 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', | |
4973 | + isDaylightSavingTimeShifted | |
4974 | +); | |
4975 | + | |
4976 | +function createUnix(input) { | |
4977 | + return createLocal(input * 1000); | |
4978 | +} | |
4979 | + | |
4980 | +function createInZone() { | |
4981 | + return createLocal.apply(null, arguments).parseZone(); | |
4982 | +} | |
4983 | + | |
4984 | +function preParsePostFormat(string) { | |
4985 | + return string; | |
4986 | +} | |
4987 | + | |
4988 | +var proto$1 = Locale.prototype; | |
4989 | + | |
4990 | +proto$1.calendar = calendar; | |
4991 | +proto$1.longDateFormat = longDateFormat; | |
4992 | +proto$1.invalidDate = invalidDate; | |
4993 | +proto$1.ordinal = ordinal; | |
4994 | +proto$1.preparse = preParsePostFormat; | |
4995 | +proto$1.postformat = preParsePostFormat; | |
4996 | +proto$1.relativeTime = relativeTime; | |
4997 | +proto$1.pastFuture = pastFuture; | |
4998 | +proto$1.set = set; | |
4999 | +proto$1.eras = localeEras; | |
5000 | +proto$1.erasParse = localeErasParse; | |
5001 | +proto$1.erasConvertYear = localeErasConvertYear; | |
5002 | +proto$1.erasAbbrRegex = erasAbbrRegex; | |
5003 | +proto$1.erasNameRegex = erasNameRegex; | |
5004 | +proto$1.erasNarrowRegex = erasNarrowRegex; | |
5005 | + | |
5006 | +proto$1.months = localeMonths; | |
5007 | +proto$1.monthsShort = localeMonthsShort; | |
5008 | +proto$1.monthsParse = localeMonthsParse; | |
5009 | +proto$1.monthsRegex = monthsRegex; | |
5010 | +proto$1.monthsShortRegex = monthsShortRegex; | |
5011 | +proto$1.week = localeWeek; | |
5012 | +proto$1.firstDayOfYear = localeFirstDayOfYear; | |
5013 | +proto$1.firstDayOfWeek = localeFirstDayOfWeek; | |
5014 | + | |
5015 | +proto$1.weekdays = localeWeekdays; | |
5016 | +proto$1.weekdaysMin = localeWeekdaysMin; | |
5017 | +proto$1.weekdaysShort = localeWeekdaysShort; | |
5018 | +proto$1.weekdaysParse = localeWeekdaysParse; | |
5019 | + | |
5020 | +proto$1.weekdaysRegex = weekdaysRegex; | |
5021 | +proto$1.weekdaysShortRegex = weekdaysShortRegex; | |
5022 | +proto$1.weekdaysMinRegex = weekdaysMinRegex; | |
5023 | + | |
5024 | +proto$1.isPM = localeIsPM; | |
5025 | +proto$1.meridiem = localeMeridiem; | |
5026 | + | |
5027 | +function get$1(format, index, field, setter) { | |
5028 | + var locale = getLocale(), | |
5029 | + utc = createUTC().set(setter, index); | |
5030 | + return locale[field](utc, format); | |
5031 | +} | |
5032 | + | |
5033 | +function listMonthsImpl(format, index, field) { | |
5034 | + if (isNumber(format)) { | |
5035 | + index = format; | |
5036 | + format = undefined; | |
5037 | + } | |
5038 | + | |
5039 | + format = format || ''; | |
5040 | + | |
5041 | + if (index != null) { | |
5042 | + return get$1(format, index, field, 'month'); | |
5043 | + } | |
5044 | + | |
5045 | + var i, | |
5046 | + out = []; | |
5047 | + for (i = 0; i < 12; i++) { | |
5048 | + out[i] = get$1(format, i, field, 'month'); | |
5049 | + } | |
5050 | + return out; | |
5051 | +} | |
5052 | + | |
5053 | +// () | |
5054 | +// (5) | |
5055 | +// (fmt, 5) | |
5056 | +// (fmt) | |
5057 | +// (true) | |
5058 | +// (true, 5) | |
5059 | +// (true, fmt, 5) | |
5060 | +// (true, fmt) | |
5061 | +function listWeekdaysImpl(localeSorted, format, index, field) { | |
5062 | + if (typeof localeSorted === 'boolean') { | |
5063 | + if (isNumber(format)) { | |
5064 | + index = format; | |
5065 | + format = undefined; | |
5066 | + } | |
5067 | + | |
5068 | + format = format || ''; | |
5069 | + } else { | |
5070 | + format = localeSorted; | |
5071 | + index = format; | |
5072 | + localeSorted = false; | |
5073 | + | |
5074 | + if (isNumber(format)) { | |
5075 | + index = format; | |
5076 | + format = undefined; | |
5077 | + } | |
5078 | + | |
5079 | + format = format || ''; | |
5080 | + } | |
5081 | + | |
5082 | + var locale = getLocale(), | |
5083 | + shift = localeSorted ? locale._week.dow : 0, | |
5084 | + i, | |
5085 | + out = []; | |
5086 | + | |
5087 | + if (index != null) { | |
5088 | + return get$1(format, (index + shift) % 7, field, 'day'); | |
5089 | + } | |
5090 | + | |
5091 | + for (i = 0; i < 7; i++) { | |
5092 | + out[i] = get$1(format, (i + shift) % 7, field, 'day'); | |
5093 | + } | |
5094 | + return out; | |
5095 | +} | |
5096 | + | |
5097 | +function listMonths(format, index) { | |
5098 | + return listMonthsImpl(format, index, 'months'); | |
5099 | +} | |
5100 | + | |
5101 | +function listMonthsShort(format, index) { | |
5102 | + return listMonthsImpl(format, index, 'monthsShort'); | |
5103 | +} | |
5104 | + | |
5105 | +function listWeekdays(localeSorted, format, index) { | |
5106 | + return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); | |
5107 | +} | |
5108 | + | |
5109 | +function listWeekdaysShort(localeSorted, format, index) { | |
5110 | + return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); | |
5111 | +} | |
5112 | + | |
5113 | +function listWeekdaysMin(localeSorted, format, index) { | |
5114 | + return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); | |
5115 | +} | |
5116 | + | |
5117 | +getSetGlobalLocale('en', { | |
5118 | + eras: [ | |
5119 | + { | |
5120 | + since: '0001-01-01', | |
5121 | + until: +Infinity, | |
5122 | + offset: 1, | |
5123 | + name: 'Anno Domini', | |
5124 | + narrow: 'AD', | |
5125 | + abbr: 'AD', | |
5126 | + }, | |
5127 | + { | |
5128 | + since: '0000-12-31', | |
5129 | + until: -Infinity, | |
5130 | + offset: 1, | |
5131 | + name: 'Before Christ', | |
5132 | + narrow: 'BC', | |
5133 | + abbr: 'BC', | |
5134 | + }, | |
5135 | + ], | |
5136 | + dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, | |
5137 | + ordinal: function (number) { | |
5138 | + var b = number % 10, | |
5139 | + output = | |
5140 | + toInt((number % 100) / 10) === 1 | |
5141 | + ? 'th' | |
5142 | + : b === 1 | |
5143 | + ? 'st' | |
5144 | + : b === 2 | |
5145 | + ? 'nd' | |
5146 | + : b === 3 | |
5147 | + ? 'rd' | |
5148 | + : 'th'; | |
5149 | + return number + output; | |
5150 | + }, | |
5151 | +}); | |
5152 | + | |
5153 | +// Side effect imports | |
5154 | + | |
5155 | +hooks.lang = deprecate( | |
5156 | + 'moment.lang is deprecated. Use moment.locale instead.', | |
5157 | + getSetGlobalLocale | |
5158 | +); | |
5159 | +hooks.langData = deprecate( | |
5160 | + 'moment.langData is deprecated. Use moment.localeData instead.', | |
5161 | + getLocale | |
5162 | +); | |
5163 | + | |
5164 | +var mathAbs = Math.abs; | |
5165 | + | |
5166 | +function abs() { | |
5167 | + var data = this._data; | |
5168 | + | |
5169 | + this._milliseconds = mathAbs(this._milliseconds); | |
5170 | + this._days = mathAbs(this._days); | |
5171 | + this._months = mathAbs(this._months); | |
5172 | + | |
5173 | + data.milliseconds = mathAbs(data.milliseconds); | |
5174 | + data.seconds = mathAbs(data.seconds); | |
5175 | + data.minutes = mathAbs(data.minutes); | |
5176 | + data.hours = mathAbs(data.hours); | |
5177 | + data.months = mathAbs(data.months); | |
5178 | + data.years = mathAbs(data.years); | |
5179 | + | |
5180 | + return this; | |
5181 | +} | |
5182 | + | |
5183 | +function addSubtract$1(duration, input, value, direction) { | |
5184 | + var other = createDuration(input, value); | |
5185 | + | |
5186 | + duration._milliseconds += direction * other._milliseconds; | |
5187 | + duration._days += direction * other._days; | |
5188 | + duration._months += direction * other._months; | |
5189 | + | |
5190 | + return duration._bubble(); | |
5191 | +} | |
5192 | + | |
5193 | +// supports only 2.0-style add(1, 's') or add(duration) | |
5194 | +function add$1(input, value) { | |
5195 | + return addSubtract$1(this, input, value, 1); | |
5196 | +} | |
5197 | + | |
5198 | +// supports only 2.0-style subtract(1, 's') or subtract(duration) | |
5199 | +function subtract$1(input, value) { | |
5200 | + return addSubtract$1(this, input, value, -1); | |
5201 | +} | |
5202 | + | |
5203 | +function absCeil(number) { | |
5204 | + if (number < 0) { | |
5205 | + return Math.floor(number); | |
5206 | + } else { | |
5207 | + return Math.ceil(number); | |
5208 | + } | |
5209 | +} | |
5210 | + | |
5211 | +function bubble() { | |
5212 | + var milliseconds = this._milliseconds, | |
5213 | + days = this._days, | |
5214 | + months = this._months, | |
5215 | + data = this._data, | |
5216 | + seconds, | |
5217 | + minutes, | |
5218 | + hours, | |
5219 | + years, | |
5220 | + monthsFromDays; | |
5221 | + | |
5222 | + // if we have a mix of positive and negative values, bubble down first | |
5223 | + // check: https://github.com/moment/moment/issues/2166 | |
5224 | + if ( | |
5225 | + !( | |
5226 | + (milliseconds >= 0 && days >= 0 && months >= 0) || | |
5227 | + (milliseconds <= 0 && days <= 0 && months <= 0) | |
5228 | + ) | |
5229 | + ) { | |
5230 | + milliseconds += absCeil(monthsToDays(months) + days) * 864e5; | |
5231 | + days = 0; | |
5232 | + months = 0; | |
5233 | + } | |
5234 | + | |
5235 | + // The following code bubbles up values, see the tests for | |
5236 | + // examples of what that means. | |
5237 | + data.milliseconds = milliseconds % 1000; | |
5238 | + | |
5239 | + seconds = absFloor(milliseconds / 1000); | |
5240 | + data.seconds = seconds % 60; | |
5241 | + | |
5242 | + minutes = absFloor(seconds / 60); | |
5243 | + data.minutes = minutes % 60; | |
5244 | + | |
5245 | + hours = absFloor(minutes / 60); | |
5246 | + data.hours = hours % 24; | |
5247 | + | |
5248 | + days += absFloor(hours / 24); | |
5249 | + | |
5250 | + // convert days to months | |
5251 | + monthsFromDays = absFloor(daysToMonths(days)); | |
5252 | + months += monthsFromDays; | |
5253 | + days -= absCeil(monthsToDays(monthsFromDays)); | |
5254 | + | |
5255 | + // 12 months -> 1 year | |
5256 | + years = absFloor(months / 12); | |
5257 | + months %= 12; | |
5258 | + | |
5259 | + data.days = days; | |
5260 | + data.months = months; | |
5261 | + data.years = years; | |
5262 | + | |
5263 | + return this; | |
5264 | +} | |
5265 | + | |
5266 | +function daysToMonths(days) { | |
5267 | + // 400 years have 146097 days (taking into account leap year rules) | |
5268 | + // 400 years have 12 months === 4800 | |
5269 | + return (days * 4800) / 146097; | |
5270 | +} | |
5271 | + | |
5272 | +function monthsToDays(months) { | |
5273 | + // the reverse of daysToMonths | |
5274 | + return (months * 146097) / 4800; | |
5275 | +} | |
5276 | + | |
5277 | +function as(units) { | |
5278 | + if (!this.isValid()) { | |
5279 | + return NaN; | |
5280 | + } | |
5281 | + var days, | |
5282 | + months, | |
5283 | + milliseconds = this._milliseconds; | |
5284 | + | |
5285 | + units = normalizeUnits(units); | |
5286 | + | |
5287 | + if (units === 'month' || units === 'quarter' || units === 'year') { | |
5288 | + days = this._days + milliseconds / 864e5; | |
5289 | + months = this._months + daysToMonths(days); | |
5290 | + switch (units) { | |
5291 | + case 'month': | |
5292 | + return months; | |
5293 | + case 'quarter': | |
5294 | + return months / 3; | |
5295 | + case 'year': | |
5296 | + return months / 12; | |
5297 | + } | |
5298 | + } else { | |
5299 | + // handle milliseconds separately because of floating point math errors (issue #1867) | |
5300 | + days = this._days + Math.round(monthsToDays(this._months)); | |
5301 | + switch (units) { | |
5302 | + case 'week': | |
5303 | + return days / 7 + milliseconds / 6048e5; | |
5304 | + case 'day': | |
5305 | + return days + milliseconds / 864e5; | |
5306 | + case 'hour': | |
5307 | + return days * 24 + milliseconds / 36e5; | |
5308 | + case 'minute': | |
5309 | + return days * 1440 + milliseconds / 6e4; | |
5310 | + case 'second': | |
5311 | + return days * 86400 + milliseconds / 1000; | |
5312 | + // Math.floor prevents floating point math errors here | |
5313 | + case 'millisecond': | |
5314 | + return Math.floor(days * 864e5) + milliseconds; | |
5315 | + default: | |
5316 | + throw new Error('Unknown unit ' + units); | |
5317 | + } | |
5318 | + } | |
5319 | +} | |
5320 | + | |
5321 | +// TODO: Use this.as('ms')? | |
5322 | +function valueOf$1() { | |
5323 | + if (!this.isValid()) { | |
5324 | + return NaN; | |
5325 | + } | |
5326 | + return ( | |
5327 | + this._milliseconds + | |
5328 | + this._days * 864e5 + | |
5329 | + (this._months % 12) * 2592e6 + | |
5330 | + toInt(this._months / 12) * 31536e6 | |
5331 | + ); | |
5332 | +} | |
5333 | + | |
5334 | +function makeAs(alias) { | |
5335 | + return function () { | |
5336 | + return this.as(alias); | |
5337 | + }; | |
5338 | +} | |
5339 | + | |
5340 | +var asMilliseconds = makeAs('ms'), | |
5341 | + asSeconds = makeAs('s'), | |
5342 | + asMinutes = makeAs('m'), | |
5343 | + asHours = makeAs('h'), | |
5344 | + asDays = makeAs('d'), | |
5345 | + asWeeks = makeAs('w'), | |
5346 | + asMonths = makeAs('M'), | |
5347 | + asQuarters = makeAs('Q'), | |
5348 | + asYears = makeAs('y'); | |
5349 | + | |
5350 | +function clone$1() { | |
5351 | + return createDuration(this); | |
5352 | +} | |
5353 | + | |
5354 | +function get$2(units) { | |
5355 | + units = normalizeUnits(units); | |
5356 | + return this.isValid() ? this[units + 's']() : NaN; | |
5357 | +} | |
5358 | + | |
5359 | +function makeGetter(name) { | |
5360 | + return function () { | |
5361 | + return this.isValid() ? this._data[name] : NaN; | |
5362 | + }; | |
5363 | +} | |
5364 | + | |
5365 | +var milliseconds = makeGetter('milliseconds'), | |
5366 | + seconds = makeGetter('seconds'), | |
5367 | + minutes = makeGetter('minutes'), | |
5368 | + hours = makeGetter('hours'), | |
5369 | + days = makeGetter('days'), | |
5370 | + months = makeGetter('months'), | |
5371 | + years = makeGetter('years'); | |
5372 | + | |
5373 | +function weeks() { | |
5374 | + return absFloor(this.days() / 7); | |
5375 | +} | |
5376 | + | |
5377 | +var round = Math.round, | |
5378 | + thresholds = { | |
5379 | + ss: 44, // a few seconds to seconds | |
5380 | + s: 45, // seconds to minute | |
5381 | + m: 45, // minutes to hour | |
5382 | + h: 22, // hours to day | |
5383 | + d: 26, // days to month/week | |
5384 | + w: null, // weeks to month | |
5385 | + M: 11, // months to year | |
5386 | + }; | |
5387 | + | |
5388 | +// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize | |
5389 | +function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { | |
5390 | + return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); | |
5391 | +} | |
5392 | + | |
5393 | +function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) { | |
5394 | + var duration = createDuration(posNegDuration).abs(), | |
5395 | + seconds = round(duration.as('s')), | |
5396 | + minutes = round(duration.as('m')), | |
5397 | + hours = round(duration.as('h')), | |
5398 | + days = round(duration.as('d')), | |
5399 | + months = round(duration.as('M')), | |
5400 | + weeks = round(duration.as('w')), | |
5401 | + years = round(duration.as('y')), | |
5402 | + a = | |
5403 | + (seconds <= thresholds.ss && ['s', seconds]) || | |
5404 | + (seconds < thresholds.s && ['ss', seconds]) || | |
5405 | + (minutes <= 1 && ['m']) || | |
5406 | + (minutes < thresholds.m && ['mm', minutes]) || | |
5407 | + (hours <= 1 && ['h']) || | |
5408 | + (hours < thresholds.h && ['hh', hours]) || | |
5409 | + (days <= 1 && ['d']) || | |
5410 | + (days < thresholds.d && ['dd', days]); | |
5411 | + | |
5412 | + if (thresholds.w != null) { | |
5413 | + a = | |
5414 | + a || | |
5415 | + (weeks <= 1 && ['w']) || | |
5416 | + (weeks < thresholds.w && ['ww', weeks]); | |
5417 | + } | |
5418 | + a = a || | |
5419 | + (months <= 1 && ['M']) || | |
5420 | + (months < thresholds.M && ['MM', months]) || | |
5421 | + (years <= 1 && ['y']) || ['yy', years]; | |
5422 | + | |
5423 | + a[2] = withoutSuffix; | |
5424 | + a[3] = +posNegDuration > 0; | |
5425 | + a[4] = locale; | |
5426 | + return substituteTimeAgo.apply(null, a); | |
5427 | +} | |
5428 | + | |
5429 | +// This function allows you to set the rounding function for relative time strings | |
5430 | +function getSetRelativeTimeRounding(roundingFunction) { | |
5431 | + if (roundingFunction === undefined) { | |
5432 | + return round; | |
5433 | + } | |
5434 | + if (typeof roundingFunction === 'function') { | |
5435 | + round = roundingFunction; | |
5436 | + return true; | |
5437 | + } | |
5438 | + return false; | |
5439 | +} | |
5440 | + | |
5441 | +// This function allows you to set a threshold for relative time strings | |
5442 | +function getSetRelativeTimeThreshold(threshold, limit) { | |
5443 | + if (thresholds[threshold] === undefined) { | |
5444 | + return false; | |
5445 | + } | |
5446 | + if (limit === undefined) { | |
5447 | + return thresholds[threshold]; | |
5448 | + } | |
5449 | + thresholds[threshold] = limit; | |
5450 | + if (threshold === 's') { | |
5451 | + thresholds.ss = limit - 1; | |
5452 | + } | |
5453 | + return true; | |
5454 | +} | |
5455 | + | |
5456 | +function humanize(argWithSuffix, argThresholds) { | |
5457 | + if (!this.isValid()) { | |
5458 | + return this.localeData().invalidDate(); | |
5459 | + } | |
5460 | + | |
5461 | + var withSuffix = false, | |
5462 | + th = thresholds, | |
5463 | + locale, | |
5464 | + output; | |
5465 | + | |
5466 | + if (typeof argWithSuffix === 'object') { | |
5467 | + argThresholds = argWithSuffix; | |
5468 | + argWithSuffix = false; | |
5469 | + } | |
5470 | + if (typeof argWithSuffix === 'boolean') { | |
5471 | + withSuffix = argWithSuffix; | |
5472 | + } | |
5473 | + if (typeof argThresholds === 'object') { | |
5474 | + th = Object.assign({}, thresholds, argThresholds); | |
5475 | + if (argThresholds.s != null && argThresholds.ss == null) { | |
5476 | + th.ss = argThresholds.s - 1; | |
5477 | + } | |
5478 | + } | |
5479 | + | |
5480 | + locale = this.localeData(); | |
5481 | + output = relativeTime$1(this, !withSuffix, th, locale); | |
5482 | + | |
5483 | + if (withSuffix) { | |
5484 | + output = locale.pastFuture(+this, output); | |
5485 | + } | |
5486 | + | |
5487 | + return locale.postformat(output); | |
5488 | +} | |
5489 | + | |
5490 | +var abs$1 = Math.abs; | |
5491 | + | |
5492 | +function sign(x) { | |
5493 | + return (x > 0) - (x < 0) || +x; | |
5494 | +} | |
5495 | + | |
5496 | +function toISOString$1() { | |
5497 | + // for ISO strings we do not use the normal bubbling rules: | |
5498 | + // * milliseconds bubble up until they become hours | |
5499 | + // * days do not bubble at all | |
5500 | + // * months bubble up until they become years | |
5501 | + // This is because there is no context-free conversion between hours and days | |
5502 | + // (think of clock changes) | |
5503 | + // and also not between days and months (28-31 days per month) | |
5504 | + if (!this.isValid()) { | |
5505 | + return this.localeData().invalidDate(); | |
5506 | + } | |
5507 | + | |
5508 | + var seconds = abs$1(this._milliseconds) / 1000, | |
5509 | + days = abs$1(this._days), | |
5510 | + months = abs$1(this._months), | |
5511 | + minutes, | |
5512 | + hours, | |
5513 | + years, | |
5514 | + s, | |
5515 | + total = this.asSeconds(), | |
5516 | + totalSign, | |
5517 | + ymSign, | |
5518 | + daysSign, | |
5519 | + hmsSign; | |
5520 | + | |
5521 | + if (!total) { | |
5522 | + // this is the same as C#'s (Noda) and python (isodate)... | |
5523 | + // but not other JS (goog.date) | |
5524 | + return 'P0D'; | |
5525 | + } | |
5526 | + | |
5527 | + // 3600 seconds -> 60 minutes -> 1 hour | |
5528 | + minutes = absFloor(seconds / 60); | |
5529 | + hours = absFloor(minutes / 60); | |
5530 | + seconds %= 60; | |
5531 | + minutes %= 60; | |
5532 | + | |
5533 | + // 12 months -> 1 year | |
5534 | + years = absFloor(months / 12); | |
5535 | + months %= 12; | |
5536 | + | |
5537 | + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js | |
5538 | + s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; | |
5539 | + | |
5540 | + totalSign = total < 0 ? '-' : ''; | |
5541 | + ymSign = sign(this._months) !== sign(total) ? '-' : ''; | |
5542 | + daysSign = sign(this._days) !== sign(total) ? '-' : ''; | |
5543 | + hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; | |
5544 | + | |
5545 | + return ( | |
5546 | + totalSign + | |
5547 | + 'P' + | |
5548 | + (years ? ymSign + years + 'Y' : '') + | |
5549 | + (months ? ymSign + months + 'M' : '') + | |
5550 | + (days ? daysSign + days + 'D' : '') + | |
5551 | + (hours || minutes || seconds ? 'T' : '') + | |
5552 | + (hours ? hmsSign + hours + 'H' : '') + | |
5553 | + (minutes ? hmsSign + minutes + 'M' : '') + | |
5554 | + (seconds ? hmsSign + s + 'S' : '') | |
5555 | + ); | |
5556 | +} | |
5557 | + | |
5558 | +var proto$2 = Duration.prototype; | |
5559 | + | |
5560 | +proto$2.isValid = isValid$1; | |
5561 | +proto$2.abs = abs; | |
5562 | +proto$2.add = add$1; | |
5563 | +proto$2.subtract = subtract$1; | |
5564 | +proto$2.as = as; | |
5565 | +proto$2.asMilliseconds = asMilliseconds; | |
5566 | +proto$2.asSeconds = asSeconds; | |
5567 | +proto$2.asMinutes = asMinutes; | |
5568 | +proto$2.asHours = asHours; | |
5569 | +proto$2.asDays = asDays; | |
5570 | +proto$2.asWeeks = asWeeks; | |
5571 | +proto$2.asMonths = asMonths; | |
5572 | +proto$2.asQuarters = asQuarters; | |
5573 | +proto$2.asYears = asYears; | |
5574 | +proto$2.valueOf = valueOf$1; | |
5575 | +proto$2._bubble = bubble; | |
5576 | +proto$2.clone = clone$1; | |
5577 | +proto$2.get = get$2; | |
5578 | +proto$2.milliseconds = milliseconds; | |
5579 | +proto$2.seconds = seconds; | |
5580 | +proto$2.minutes = minutes; | |
5581 | +proto$2.hours = hours; | |
5582 | +proto$2.days = days; | |
5583 | +proto$2.weeks = weeks; | |
5584 | +proto$2.months = months; | |
5585 | +proto$2.years = years; | |
5586 | +proto$2.humanize = humanize; | |
5587 | +proto$2.toISOString = toISOString$1; | |
5588 | +proto$2.toString = toISOString$1; | |
5589 | +proto$2.toJSON = toISOString$1; | |
5590 | +proto$2.locale = locale; | |
5591 | +proto$2.localeData = localeData; | |
5592 | + | |
5593 | +proto$2.toIsoString = deprecate( | |
5594 | + 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', | |
5595 | + toISOString$1 | |
5596 | +); | |
5597 | +proto$2.lang = lang; | |
5598 | + | |
5599 | +// FORMATTING | |
5600 | + | |
5601 | +addFormatToken('X', 0, 0, 'unix'); | |
5602 | +addFormatToken('x', 0, 0, 'valueOf'); | |
5603 | + | |
5604 | +// PARSING | |
5605 | + | |
5606 | +addRegexToken('x', matchSigned); | |
5607 | +addRegexToken('X', matchTimestamp); | |
5608 | +addParseToken('X', function (input, array, config) { | |
5609 | + config._d = new Date(parseFloat(input) * 1000); | |
5610 | +}); | |
5611 | +addParseToken('x', function (input, array, config) { | |
5612 | + config._d = new Date(toInt(input)); | |
5613 | +}); | |
5614 | + | |
5615 | +//! moment.js | |
5616 | + | |
5617 | +hooks.version = '2.29.1'; | |
5618 | + | |
5619 | +setHookCallback(createLocal); | |
5620 | + | |
5621 | +hooks.fn = proto; | |
5622 | +hooks.min = min; | |
5623 | +hooks.max = max; | |
5624 | +hooks.now = now; | |
5625 | +hooks.utc = createUTC; | |
5626 | +hooks.unix = createUnix; | |
5627 | +hooks.months = listMonths; | |
5628 | +hooks.isDate = isDate; | |
5629 | +hooks.locale = getSetGlobalLocale; | |
5630 | +hooks.invalid = createInvalid; | |
5631 | +hooks.duration = createDuration; | |
5632 | +hooks.isMoment = isMoment; | |
5633 | +hooks.weekdays = listWeekdays; | |
5634 | +hooks.parseZone = createInZone; | |
5635 | +hooks.localeData = getLocale; | |
5636 | +hooks.isDuration = isDuration; | |
5637 | +hooks.monthsShort = listMonthsShort; | |
5638 | +hooks.weekdaysMin = listWeekdaysMin; | |
5639 | +hooks.defineLocale = defineLocale; | |
5640 | +hooks.updateLocale = updateLocale; | |
5641 | +hooks.locales = listLocales; | |
5642 | +hooks.weekdaysShort = listWeekdaysShort; | |
5643 | +hooks.normalizeUnits = normalizeUnits; | |
5644 | +hooks.relativeTimeRounding = getSetRelativeTimeRounding; | |
5645 | +hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; | |
5646 | +hooks.calendarFormat = getCalendarFormat; | |
5647 | +hooks.prototype = proto; | |
5648 | + | |
5649 | +// currently HTML5 input type only supports 24-hour formats | |
5650 | +hooks.HTML5_FMT = { | |
5651 | + DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" /> | |
5652 | + DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" /> | |
5653 | + DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" /> | |
5654 | + DATE: 'YYYY-MM-DD', // <input type="date" /> | |
5655 | + TIME: 'HH:mm', // <input type="time" /> | |
5656 | + TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" /> | |
5657 | + TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" /> | |
5658 | + WEEK: 'GGGG-[W]WW', // <input type="week" /> | |
5659 | + MONTH: 'YYYY-MM', // <input type="month" /> | |
5660 | +}; | |
5661 | + | |
5662 | +export default hooks; | ... | ... |
src/components/timer/timer.css
0 → 100644
src/components/timer/timer.js
0 → 100644
1 | +++ a/src/components/timer/timer.js | |
1 | +import React, { Component } from "react" | |
2 | +import moment from "./lib/moment" | |
3 | +import "./timer.css" | |
4 | +export default class Timer extends Component { | |
5 | + constructor() { | |
6 | + super(); | |
7 | + this.state = { | |
8 | + showDateTime: "", | |
9 | + classInfo: "" | |
10 | + } | |
11 | + } | |
12 | + static getDerivedStateFromProps(props, state) { | |
13 | + let { className } = props | |
14 | + if (className !== state.className) { | |
15 | + return { | |
16 | + classInfo: className | |
17 | + } | |
18 | + } | |
19 | + return null; | |
20 | + } | |
21 | + forShowDateTime() { | |
22 | + let { type = "YYYY-MM-DD HH:mm:ss" } = this.props; | |
23 | + this.setState({ | |
24 | + showDateTime: moment().format(type) | |
25 | + }) | |
26 | + } | |
27 | + componentDidMount() { | |
28 | + this.forShowDateTime() | |
29 | + this.timer = setInterval(() => { | |
30 | + this.forShowDateTime() | |
31 | + }, 1000) | |
32 | + } | |
33 | + render() { | |
34 | + let { classInfo, showDateTime } = this.state; | |
35 | + return (<div className="timerComCss"> | |
36 | + <p className={classInfo}>{showDateTime}</p> | |
37 | + </div>) | |
38 | + } | |
39 | +} | |
0 | 40 | \ No newline at end of file | ... | ... |
src/index.js
0 → 100644
1 | +++ a/src/index.js | |
1 | +import React,{Component} from 'react'; | |
2 | +import ReactDOM from 'react-dom'; | |
3 | +import { FlvCom ,Timer} from "./components/index" | |
4 | +// import {FlvCom,Timer} from "../dist/index.js" | |
5 | +class App extends Component{ | |
6 | + render(){ | |
7 | + return ( | |
8 | + <div style={{ | |
9 | + width: "300px", height: "300px" | |
10 | + }}> | |
11 | + <FlvCom vidoeUrl=""></FlvCom> | |
12 | + <Timer className="timerComCssss" type="YYYY-MM-DD HH:mm:ss"></Timer> | |
13 | + </div> | |
14 | + ) | |
15 | + } | |
16 | +} | |
17 | + | |
18 | +ReactDOM.render(<App />, document.getElementById('root')); | ... | ... |
webpack.config.js
0 → 100644
1 | +++ a/webpack.config.js | |
1 | +const path = require('path'); | |
2 | +const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
3 | +const htmlWebpackPlugin = new HtmlWebpackPlugin({ | |
4 | + template: path.join(__dirname, "./public/index.html"), | |
5 | + filename: "./index.html" | |
6 | +}); | |
7 | +var NODE_ENV = process.env.NODE_ENV; | |
8 | +module.exports = { | |
9 | + mode:NODE_ENV=='dev'?"development":"production", | |
10 | + entry: path.join(__dirname, NODE_ENV=='dev'?"./src/index.js":"./src/components"), | |
11 | + output: { | |
12 | + path: path.join(__dirname, "dist"), | |
13 | + libraryTarget: 'umd', //发布组件专用 | |
14 | + filename: "index.js" | |
15 | + }, | |
16 | + module: { | |
17 | + rules: [{ | |
18 | + test: /\.(js|jsx)$/, | |
19 | + use: "babel-loader", | |
20 | + exclude: /node_modules/ | |
21 | + }, { | |
22 | + test: /\.css$/, | |
23 | + use: [ | |
24 | + 'style-loader', | |
25 | + 'css-loader' | |
26 | + ] | |
27 | + }, | |
28 | + { | |
29 | + test: /\.(woff|woff2|eot|otf|ttf)$/, | |
30 | + use: ['file-loader'] | |
31 | + }] | |
32 | + }, | |
33 | + plugins: [htmlWebpackPlugin], | |
34 | + resolve: { | |
35 | + extensions: [".js", ".jsx"] | |
36 | + }, | |
37 | + devServer: { | |
38 | + port: 8080 | |
39 | + } | |
40 | +}; | |
0 | 41 | \ No newline at end of file | ... | ... |