/*! Moment Duration Format v2.2.2 * https://github.com/jsmreese/moment-duration-format * Date: 2018-02-16 * * Duration format plugin function for the Moment.js library * http://momentjs.com/ * * Copyright 2018 John Madhavan-Reese * Released under the MIT license */ !function(e,t){if("function"==typeof define&&define.amd)define(["moment"],t);else if("object"==typeof exports)try{module.exports=t(require("moment"))}catch(e){module.exports=t}e&&(e.momentDurationFormatSetup=e.moment?t(e.moment):t)}(this,function(e){var t=!1,n=!1,i=!1,r=!1,a="escape years months weeks days hours minutes seconds milliseconds general".split(" "),u=[{type:"seconds",targets:[{type:"minutes",value:60},{type:"hours",value:3600},{type:"days",value:86400},{type:"weeks",value:604800},{type:"months",value:2678400},{type:"years",value:31536e3}]},{type:"minutes",targets:[{type:"hours",value:60},{type:"days",value:1440},{type:"weeks",value:10080},{type:"months",value:44640},{type:"years",value:525600}]},{type:"hours",targets:[{type:"days",value:24},{type:"weeks",value:168},{type:"months",value:744},{type:"years",value:8760}]},{type:"days",targets:[{type:"weeks",value:7},{type:"months",value:31},{type:"years",value:365}]},{type:"months",targets:[{type:"years",value:12}]}];function o(e,t){return!(t.length>e.length)&&-1!==e.indexOf(t)}function l(e){for(var t="";e;)t+="0",e-=1;return t}function s(e,t){var n=e+"+"+d(D(t).sort(),function(e){return e+":"+t[e]}).join(",");return s.cache[n]||(s.cache[n]=Intl.NumberFormat(e,t)),s.cache[n]}function c(e,t,a){var u,o,m,f=t.useToLocaleString,p=t.useGrouping,g=p&&t.grouping.slice(),h=t.maximumSignificantDigits,y=t.minimumIntegerDigits||1,d=t.fractionDigits||0,v=t.groupingSeparator,w=t.decimalSeparator;if(f&&a){var S={minimumIntegerDigits:y,useGrouping:p};if(d&&(S.maximumFractionDigits=d,S.minimumFractionDigits=d),h&&e>0&&(S.maximumSignificantDigits=h),i){var V;if(!r)(V=x({},t)).useGrouping=!1,V.decimalSeparator=".",e=parseFloat(c(e,V),10);return s(a,S).format(e)}return n||((V=x({},t)).useGrouping=!1,V.decimalSeparator=".",e=parseFloat(c(e,V),10)),e.toLocaleString(a,S)}var _=(h?e.toPrecision(h+1):e.toFixed(d+1)).split("e");m=_[1]||"",o=(_=_[0].split("."))[1]||"";var D=(u=_[0]||"").length,b=o.length,M=D+b,L=u+o;(h&&M===h+1||!h&&b===d+1)&&((L=function(e){for(var t=e.split("").reverse(),n=0,i=!0;i&&n0?o.length<=k?(u+=o+=l(k-o.length),o=""):(u+=o.slice(0,k),o=o.slice(k)):k<0&&(o=l(Math.abs(k)-u.length)+u+o,u="0"),h||((o=o.slice(0,d)).lengtht.label.length?-1:e.label.length0,Y=W?r.precision:0,z=Y,B=r.minValue,J=!1,Q=r.maxValue,X=!1,Z=r.useToLocaleString,ee=r.groupingSeparator,te=r.decimalSeparator,ne=r.grouping;Z=Z&&(t||i);var ie=r.trim;p(ie)&&(ie=ie.join(" ")),null===ie&&(O||Q||W)&&(ie="all"),null!==ie&&!0!==ie&&"left"!==ie&&"right"!==ie||(ie="large"),!1===ie&&(ie="");var re=function(e){return e.test(ie)},ae=/both/,ue=/^all|[^sm]all/,oe=O>0||b([/large/,ae,ue],re),le=b([/small/,ae,ue],re),se=b([/mid/,ue],re),ce=b([/final/,ue],re),me=d(G.match(j),function(e,t){var n=I(e);return"*"===e.slice(0,1)&&(e=e.slice(1),"escape"!==n&&"general"!==n&&H.push(n)),{index:t,length:e.length,text:"",token:"escape"===n?e.replace(F.escape,"$1"):e,type:"escape"===n||"general"===n?null:n}}),fe={index:0,length:0,token:"",text:"",type:null},pe=[];K&&me.reverse(),y(me,function(e){if(e.type)return(fe.type||fe.text)&&pe.push(fe),void(fe=e);K?fe.text=e.token+fe.text:fe.text+=e.token}),(fe.type||fe.text)&&pe.push(fe),K&&pe.reverse();var ge=V(a,S(w(v(pe,"type"))));if(!ge.length)return v(pe,"text").join("");ge=d(ge,function(e,t){var n,i=t+1===ge.length,a=!t;n="years"===e||"months"===e?k.as(e):L.as(e);var u=Math.floor(n),o=n-u,l=h(pe,function(t){return e===t.type});return a&&Q&&n>Q&&(X=!0),i&&B&&Math.abs(r.duration.as(e))1&&(q=!0),L.subtract(u,e),k.subtract(u,e),{rawValue:n,wholeValue:u,decimalValue:i?o:0,isSmallest:i,isLargest:a,type:e,tokenLength:l.length}});var he,ye=C?Math.floor:Math.round,de=function(e,t){var n=Math.pow(10,t);return ye(e*n)/n},ve=!1,we=!1,Se=function(e,t){var n={useGrouping:A,groupingSeparator:ee,decimalSeparator:te,grouping:ne,useToLocaleString:Z};return W&&(Y<=0?(e.rawValue=0,e.wholeValue=0,e.decimalValue=0):(n.maximumSignificantDigits=Y,e.significantDigits=Y)),X&&!we&&(e.isLargest?(e.wholeValue=Q,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),J&&!we&&(e.isSmallest?(e.wholeValue=B,e.decimalValue=0):(e.wholeValue=0,e.decimalValue=0)),e.isSmallest||e.significantDigits&&e.significantDigits-e.wholeValue.toString().length<=0?U<0?e.value=de(e.wholeValue,U):0===U?e.value=ye(e.wholeValue+e.decimalValue):W?(e.value=C?de(e.rawValue,Y-e.wholeValue.toString().length):e.rawValue,e.wholeValue&&(Y-=e.wholeValue.toString().length)):(n.fractionDigits=U,e.value=C?e.wholeValue+de(e.decimalValue,U):e.wholeValue+e.decimalValue):W&&e.wholeValue?(e.value=Math.round(de(e.wholeValue,e.significantDigits-e.wholeValue.toString().length)),Y-=e.wholeValue.toString().length):e.value=e.wholeValue,e.tokenLength>1&&(q||ve)&&(n.minimumIntegerDigits=e.tokenLength,we&&n.maximumSignificantDigits0||""===ie||h(H,e.type)||h(E,e.type))&&(ve=!0),e.formattedValue=c(e.value,n,$),n.useGrouping=!1,n.decimalSeparator=".",e.formattedValueEn=c(e.value,n,"en"),2===e.tokenLength&&"milliseconds"===e.type&&(e.formattedValueMS=c(e.value,{minimumIntegerDigits:3,useGrouping:!1},"en").slice(0,2)),e};if((ge=w(ge=d(ge,Se))).length>1){var Ve=function(e){return h(ge,function(t){return t.type===e})};y(u,function(e){var t=Ve(e.type);t&&y(e.targets,function(e){var n=Ve(e.type);n&&parseInt(t.formattedValueEn,10)===e.value&&(t.rawValue=0,t.wholeValue=0,t.decimalValue=0,n.rawValue+=1,n.wholeValue+=1,n.decimalValue=0,n.formattedValueEn=n.wholeValue.toString(),we=!0)})})}return we&&(ve=!1,Y=z,ge=w(ge=d(ge,Se))),!E||X&&!r.trim?(oe&&(ge=_(ge,function(e){return!e.isSmallest&&!e.wholeValue&&!h(H,e.type)})),O&&ge.length&&(ge=ge.slice(0,O)),le&&ge.length>1&&(he=function(e){return!e.wholeValue&&!h(H,e.type)&&!e.isLargest},ge=_(ge.slice().reverse(),he).reverse()),se&&(ge=w(ge=d(ge,function(e,t){return t>0&&t ",X=!1,J=!1),M&&(t.value>0||""===ie||h(H,t.type)||h(E,t.type))&&(n+="-",M=!1),"milliseconds"===e.type&&t.formattedValueMS?n+=t.formattedValueMS:n+=t.formattedValue,K||(n+=e.text),n})).join("").replace(/(,| |:|\.)*$/,"").replace(/^(,| |:|\.)*/,""))}function F(){var e=this.duration,t=function(t){return e._data[t]},n=h(this.types,t),i=function(e,t){for(var n=e.length;n-=1;)if(t(e[n]))return e[n]}(this.types,t);switch(n){case"milliseconds":return"S __";case"seconds":case"minutes":return"*_MS_";case"hours":return"_HMS_";case"days":if(n===i)return"d __";case"weeks":return n===i?"w __":(null===this.trim&&(this.trim="both"),"w __, d __, h __");case"months":if(n===i)return"M __";case"years":return n===i?"y __":(null===this.trim&&(this.trim="both"),"y __, M __, d __");default:return null===this.trim&&(this.trim="both"),"y __, d __, h __, m __, s __"}}function I(e){if(!e)throw"Moment Duration Format init cannot find moment instance.";e.duration.format=k,e.duration.fn.format=T,e.duration.fn.format.defaults={trim:null,stopTrim:null,largest:null,maxValue:null,minValue:null,precision:0,trunc:!1,forceLength:null,userLocale:null,usePlural:!0,useLeftUnits:!1,useGrouping:!0,useSignificantDigits:!1,template:F,useToLocaleString:!0,groupingSeparator:",",decimalSeparator:".",grouping:[3]},e.updateLocale("en",f)}var j=function(e,t,n){return e.toLocaleString(t,n)};t=function(){try{(0).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}()&&L(j),n=t&&M(j);var G=function(e,t,n){if("undefined"!=typeof window&&window&&window.Intl&&window.Intl.NumberFormat)return window.Intl.NumberFormat(t,n).format(e)};return i=L(G),r=i&&M(G),I(e),I});