resources-f170fbe8.js 5.1 KB

123456
  1. var __awaiter=this&&this.__awaiter||function(e,t,n,r){function a(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function i(e){try{s(r.next(e))}catch(e){o(e)}}function u(e){try{s(r["throw"](e))}catch(e){o(e)}}function s(e){e.done?n(e.value):a(e.value).then(i,u)}s((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,a,o,i;return i={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function u(e){return function(t){return s([e,t])}}function s(i){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,a&&(o=i[0]&2?a["return"]:i[0]?a["throw"]||((o=a["return"])&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;if(a=0,o)i=[i[0]&2,o.value];switch(i[0]){case 0:case 1:o=i;break;case 4:n.label++;return{value:i[1],done:false};case 5:n.label++;a=i[1];i=[0];continue;case 7:i=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){n=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){n.label=i[1];break}if(i[0]===6&&n.label<o[1]){n.label=o[1];o=i;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(i);break}if(o[2])n.ops.pop();n.trys.pop();continue}i=t.call(e,n)}catch(e){i=[6,e];a=0}finally{r=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};
  2. /*!
  3. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  4. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  5. * v1.0.0-beta.82
  6. */import{a as getAssetPath}from"./index-8ece2564.js";import{a as locales}from"./locale-7ce850e5.js";function getSupportedLocale(e){if(e===void 0){e=""}if(locales.indexOf(e)>-1){return e}e=e.toLowerCase();if(e.includes("-")){e=e.replace(/(\w+)-(\w+)/,(function(e,t,n){return"".concat(t,"-").concat(n.toUpperCase())}));if(!locales.includes(e)){e=e.split("-")[0]}}return locales.includes(e)?e:"en"}var translationCache={};var requestCache={};function getLocaleData(e){return __awaiter(this,void 0,void 0,(function(){var t,n;return __generator(this,(function(r){switch(r.label){case 0:t=getSupportedLocale(e);if(translationCache[t]){return[2,translationCache[t]]}if(!requestCache[t]){requestCache[t]=fetch(getAssetPath("./assets/date-picker/nls/".concat(t,".json"))).then((function(e){return e.json()})).catch((function(){console.error('Translations for "'.concat(t,'" not found or invalid, falling back to english'));return getLocaleData("en")}))}return[4,requestCache[t]];case 1:n=r.sent();translationCache[t]=n;return[2,n]}}))}))}function inRange(e,t,n){var r=e.getTime();var a=!(t instanceof Date)||r>=t.getTime();var o=!(n instanceof Date)||r<=n.getTime();return a&&o}function dateFromRange(e,t,n){if(!(e instanceof Date)){return null}var r=e.getTime();var a=t instanceof Date&&r<t.getTime();var o=n instanceof Date&&r>n.getTime();if(a){return t}if(o){return n}return e}function dateFromISO(e){if(e instanceof Date){return e}if(!e||typeof e!=="string"){return null}var t=e.split(/[: T-]/).map(parseFloat);var n=new Date(t[0],(t[1]||1)-1,t[2]||1);n.setFullYear(t[0]);if(isNaN(n.getTime())){throw new Error('Invalid ISO 8601 date: "'.concat(e,'"'))}return n}function dateToISO(e){if(typeof e==="string"){return e}if(e instanceof Date){return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().split("T")[0]}return""}function sameDate(e,t){return e instanceof Date&&t instanceof Date&&e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}function prevMonth(e){var t=e.getMonth();var n=new Date(e);n.setMonth(t-1);if(t===n.getMonth()){return new Date(e.getFullYear(),t,0)}return n}function nextMonth(e){var t=e.getMonth();var n=new Date(e);n.setMonth(t+1);if((t+2)%7===n.getMonth()%7){return new Date(e.getFullYear(),t+2,0)}return n}function localizeNumber(e,t){return String(e).split("").map((function(e){return t.numerals[e]})).join("")}function parseNumber(e,t){var n="0123456789";return parseInt(e.split("").map((function(e){return n[t.numerals.indexOf(e)]})).filter((function(e){return e})).join(""))}function parseDateString(e,t){var n=t.separator,r=t.unitOrder;var a=getOrder(r);var o=replaceArabicNumerals(e).split(n);return{day:parseInt(o[a.indexOf("d")]),month:parseInt(o[a.indexOf("m")])-1,year:parseInt(o[a.indexOf("y")])}}function replaceArabicNumerals(e){if(e===void 0){e=""}return e.replace(/[\u0660-\u0669]/g,(function(e){return e.charCodeAt(0)-1632})).replace(/[\u06f0-\u06f9]/g,(function(e){return e.charCodeAt(0)-1776}))}function getOrder(e){var t=["d","m","y"];var n=e.toLowerCase();return t.sort((function(e,t){return n.indexOf(e)-n.indexOf(t)}))}function getDaysDiff(e,t){var n=e.getTime();var r=t.getTime();return(n-r)/(1e3*3600*24)}var HEADING_LEVEL=2;var TEXT={nextMonth:"Next month",prevMonth:"Previous month",year:"Year"};export{HEADING_LEVEL as H,TEXT as T,dateFromISO as a,dateFromRange as b,getDaysDiff as c,dateToISO as d,getOrder as e,prevMonth as f,getLocaleData as g,parseNumber as h,inRange as i,localizeNumber as l,nextMonth as n,parseDateString as p,sameDate as s};