@aquera/nile-elements 2.0.18 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +10 -0
  2. package/demo/index.js +0 -1
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/index.js +1275 -490
  6. package/dist/nile-badge/index.cjs.js +1 -1
  7. package/dist/nile-badge/index.esm.js +1 -1
  8. package/dist/nile-badge/nile-badge.cjs.js +1 -1
  9. package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
  10. package/dist/nile-badge/nile-badge.css.cjs.js +1 -1
  11. package/dist/nile-badge/nile-badge.css.cjs.js.map +1 -1
  12. package/dist/nile-badge/nile-badge.css.esm.js +24 -3
  13. package/dist/nile-badge/nile-badge.esm.js +5 -3
  14. package/dist/nile-breadcrumb/nile-breadcrumb.cjs.js +1 -1
  15. package/dist/nile-breadcrumb/nile-breadcrumb.cjs.js.map +1 -1
  16. package/dist/nile-breadcrumb/nile-breadcrumb.esm.js +2 -2
  17. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.cjs.js +1 -1
  18. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.cjs.js.map +1 -1
  19. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.css.cjs.js +1 -1
  20. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.css.cjs.js.map +1 -1
  21. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.css.esm.js +14 -2
  22. package/dist/nile-breadcrumb-item/nile-breadcrumb-item.esm.js +4 -4
  23. package/dist/nile-calendar/index.cjs.js +1 -1
  24. package/dist/nile-calendar/index.esm.js +1 -1
  25. package/dist/nile-calendar/nile-calendar.cjs.js +2 -1
  26. package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
  27. package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
  28. package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
  29. package/dist/nile-calendar/nile-calendar.css.esm.js +357 -2
  30. package/dist/nile-calendar/nile-calendar.esm.js +365 -41
  31. package/dist/nile-calendar/timezones.cjs.js +1 -1
  32. package/dist/nile-calendar/timezones.cjs.js.map +1 -1
  33. package/dist/nile-calendar/timezones.esm.js +1 -1
  34. package/dist/nile-date-time-picker/index.cjs.js +2 -0
  35. package/dist/nile-date-time-picker/index.cjs.js.map +1 -0
  36. package/dist/nile-date-time-picker/index.esm.js +1 -0
  37. package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js +2 -0
  38. package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js.map +1 -0
  39. package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js +2 -0
  40. package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js.map +1 -0
  41. package/dist/nile-date-time-picker/nile-date-time-picker.css.esm.js +13 -0
  42. package/dist/nile-date-time-picker/nile-date-time-picker.esm.js +53 -0
  43. package/dist/nile-select/index.cjs.js +1 -1
  44. package/dist/nile-select/index.esm.js +1 -1
  45. package/dist/nile-select/nile-select.cjs.js +2 -2
  46. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  47. package/dist/nile-select/nile-select.esm.js +1 -1
  48. package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
  49. package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
  50. package/dist/nile-select/virtual-scroll-helper.esm.js +48 -47
  51. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +4 -4
  52. package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
  53. package/dist/nile-virtual-select/nile-virtual-select.esm.js +2 -2
  54. package/dist/src/index.d.ts +1 -0
  55. package/dist/src/index.js +1 -0
  56. package/dist/src/index.js.map +1 -1
  57. package/dist/src/nile-badge/nile-badge.css.js +24 -3
  58. package/dist/src/nile-badge/nile-badge.css.js.map +1 -1
  59. package/dist/src/nile-badge/nile-badge.d.ts +7 -4
  60. package/dist/src/nile-badge/nile-badge.js +22 -5
  61. package/dist/src/nile-badge/nile-badge.js.map +1 -1
  62. package/dist/src/nile-badge/nile-badge.test.js +88 -0
  63. package/dist/src/nile-badge/nile-badge.test.js.map +1 -1
  64. package/dist/src/nile-breadcrumb/nile-breadcrumb.d.ts +7 -0
  65. package/dist/src/nile-breadcrumb/nile-breadcrumb.js +24 -1
  66. package/dist/src/nile-breadcrumb/nile-breadcrumb.js.map +1 -1
  67. package/dist/src/nile-breadcrumb/nile-breadcrumb.test.js +51 -0
  68. package/dist/src/nile-breadcrumb/nile-breadcrumb.test.js.map +1 -1
  69. package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.css.js +12 -0
  70. package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.css.js.map +1 -1
  71. package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.d.ts +5 -0
  72. package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.js +9 -0
  73. package/dist/src/nile-breadcrumb-item/nile-breadcrumb-item.js.map +1 -1
  74. package/dist/src/nile-calendar/nile-calendar.css.js +355 -0
  75. package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  76. package/dist/src/nile-calendar/nile-calendar.d.ts +175 -0
  77. package/dist/src/nile-calendar/nile-calendar.js +1726 -26
  78. package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  79. package/dist/src/nile-calendar/nile-calendar.test.d.ts +1 -0
  80. package/dist/src/nile-calendar/nile-calendar.test.js +3580 -0
  81. package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
  82. package/dist/src/nile-calendar/timezones.d.ts +21 -0
  83. package/dist/src/nile-calendar/timezones.js +49 -0
  84. package/dist/src/nile-calendar/timezones.js.map +1 -1
  85. package/dist/src/nile-date-time-picker/index.d.ts +1 -0
  86. package/dist/src/nile-date-time-picker/index.js +2 -0
  87. package/dist/src/nile-date-time-picker/index.js.map +1 -0
  88. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.d.ts +11 -0
  89. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js +49 -0
  90. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js.map +1 -0
  91. package/dist/src/nile-date-time-picker/nile-date-time-picker.d.ts +173 -0
  92. package/dist/src/nile-date-time-picker/nile-date-time-picker.js +1270 -0
  93. package/dist/src/nile-date-time-picker/nile-date-time-picker.js.map +1 -0
  94. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.d.ts +143 -0
  95. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js +7277 -0
  96. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js.map +1 -0
  97. package/dist/src/nile-select/nile-select.d.ts +1 -0
  98. package/dist/src/nile-select/nile-select.js +16 -1
  99. package/dist/src/nile-select/nile-select.js.map +1 -1
  100. package/dist/src/nile-select/nile-select.test.js +430 -5
  101. package/dist/src/nile-select/nile-select.test.js.map +1 -1
  102. package/dist/src/nile-select/virtual-scroll-helper.js +7 -4
  103. package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
  104. package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +3 -1
  105. package/dist/src/nile-virtual-select/nile-virtual-select.js +14 -6
  106. package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
  107. package/dist/src/nile-virtual-select/nile-virtual-select.test.js +115 -1
  108. package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +1 -1
  109. package/dist/src/version.js +1 -1
  110. package/dist/src/version.js.map +1 -1
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/dist/utilities/animation-registry.cjs.js +1 -1
  113. package/dist/utilities/animation-registry.cjs.js.map +1 -1
  114. package/dist/utilities/animation-registry.esm.js +1 -1
  115. package/package.json +3 -1
  116. package/scripts/coverage-report.mjs +96 -0
  117. package/src/index.ts +1 -0
  118. package/src/nile-badge/nile-badge.css.ts +24 -3
  119. package/src/nile-badge/nile-badge.test.ts +102 -0
  120. package/src/nile-badge/nile-badge.ts +28 -5
  121. package/src/nile-breadcrumb/nile-breadcrumb.test.ts +57 -0
  122. package/src/nile-breadcrumb/nile-breadcrumb.ts +19 -0
  123. package/src/nile-breadcrumb-item/nile-breadcrumb-item.css.ts +12 -0
  124. package/src/nile-breadcrumb-item/nile-breadcrumb-item.ts +7 -0
  125. package/src/nile-calendar/nile-calendar.css.ts +355 -0
  126. package/src/nile-calendar/nile-calendar.test.ts +3793 -0
  127. package/src/nile-calendar/nile-calendar.ts +1760 -28
  128. package/src/nile-calendar/timezones.ts +57 -0
  129. package/src/nile-date-time-picker/index.ts +1 -0
  130. package/src/nile-date-time-picker/nile-date-time-picker.css.ts +54 -0
  131. package/src/nile-date-time-picker/nile-date-time-picker.test.ts +7886 -0
  132. package/src/nile-date-time-picker/nile-date-time-picker.ts +1153 -0
  133. package/src/nile-select/nile-select.test.ts +560 -5
  134. package/src/nile-select/nile-select.ts +21 -1
  135. package/src/nile-select/virtual-scroll-helper.ts +7 -4
  136. package/src/nile-virtual-select/nile-virtual-select.test.ts +139 -1
  137. package/src/nile-virtual-select/nile-virtual-select.ts +17 -6
  138. package/vscode-html-custom-data.json +200 -20
@@ -1,4 +1,4 @@
1
- import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";import{property as s,state as n,customElement as a}from"lit/decorators.js";import{s as r}from"./nile-calendar.css.esm.js";import{classMap as l}from"lit/directives/class-map.js";import{w as h}from"../internal/watch.esm.js";import{N as o}from"../internal/nile-element.esm.js";import{C as d}from"./nile-calendar.enum.esm.js";import"../internal/accessibility/a11y.state.enum.esm.js";import"../internal/accessibility/a11y.property.enum.esm.js";import"../internal/accessibility/role.enum.esm.js";let c=class extends o{constructor(){super(...arguments),this.valueAttribute=null,this.allowedDates=JSON.stringify({}),this.range=!1,this.hideTypes=!1,this.doubleClickUnselect=!1,this.allowClear=!1,this.type="absolute",this.hideDurationFields=[],this.showManualInputs=!1,this.showMonthDropdown=!1,this.showYearDropdown=!1,this.dateFormat="MM/DD/YYYY",this.startDate=null,this.endDate=null,this.isSelectingStart=!0,this.hideInput=!1,this.currentMonth=(new Date).getMonth(),this.currentYear=(new Date).getFullYear(),this.allowedDatesLocal=null,this.disabled=!1}static get styles(){return[r]}connectedCallback(){super.connectedCallback(),this.initializeValue(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.emit("nile-destroy")}updated(t){if(super.updated(t),t.has("valueAttribute")){this.valueAttribute||(this.value=null,this.startDate=null,this.endDate=null,this.isSelectingStart=!0);const t=new Date(this.valueAttribute||"");if(!isNaN(t.getTime())){const i=t.getTimezoneOffset();this.value=new Date(t.getTime()-60*i*1e3),this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear()}this.initializeValue()}}get monthNames(){return Array.from({length:12},((t,i)=>new Date(0,i).toLocaleString("default",{month:"long"})))}get yearOptions(){const t=this.startYear??2e3,i=this.endYear??2050;return t>i?[]:Array.from({length:i-t+1},((i,e)=>t+e))}onMonthSelected(t){this.currentMonth=t,this.emit("nile-month-change",{month:t})}onYearSelected(t){this.currentYear=t,this.emit("nile-year-change",{year:t})}checkValidAllowedDate(){let t;try{t=JSON.parse(this.allowedDates)}catch(i){t=null}if(!t||0==Object.keys(t).length)return void(this.allowedDatesLocal=null);this.hideInput=!0;this.getUTCDate(t.startDate)>this.getUTCDate(t.endDate)?console.error("StartDate must be greater than endDate"):this.allowedDatesLocal=t}isPrevDisabled(){return 0===this.currentMonth&&void 0!==this.startYear&&this.currentYear<=this.startYear}isNextDisabled(){return 11===this.currentMonth&&void 0!==this.endYear&&this.currentYear>=this.endYear}formatDate(t){if(!t)return"";const i=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");let n=this.dateFormat;return n=n.replace(/YYYY/g,String(i)),n=n.replace(/MM/g,e),n=n.replace(/DD/g,s),n=n.replace(/YY/g,String(i).slice(-2)),n}parseDate(t,i){if(!t||!this.dateFormat)return null;const e=this.dateFormat.replace(/YYYY/,"(?<year>\\d{4})").replace(/YY/,"(?<year>\\d{2})").replace(/MM/,"(?<month>\\d{1,2})").replace(/DD/,"(?<day>\\d{1,2})"),s=new RegExp(`^${e}$`),n=t.match(s);if(!n||!n.groups)return null;const a=2===n.groups.year.length?Number(`20${n.groups.year}`):Number(n.groups.year),r=Number(n.groups.month)-1,l=Number(n.groups.day),h=new Date(a,r,l);return i?h.setHours(i.getHours(),i.getMinutes(),i.getSeconds()):h.setHours(0,0,0),h}handleStartDateInput(t){t.stopPropagation();const i=this.parseDate(t.detail.value,this.startDate);i&&(i.setHours(0,0,0),this.startDate=i,this.currentMonth=i.getMonth(),this.currentYear=i.getFullYear(),this.requestUpdate())}handleEndDateInput(t){t.stopPropagation();const i=this.parseDate(t.detail.value,this.endDate);i&&(i.setHours(23,59,59),this.endDate=i,this.currentMonth=i.getMonth(),this.currentYear=i.getFullYear(),this.requestUpdate())}render(){return i`
1
+ import{__decorate as t}from"tslib";import{html as e,nothing as i}from"lit";import{property as s,state as n,customElement as r}from"lit/decorators.js";import{s as a}from"./nile-calendar.css.esm.js";import{classMap as l}from"lit/directives/class-map.js";import{w as o}from"../internal/watch.esm.js";import{N as h}from"../internal/nile-element.esm.js";import{C as d}from"./nile-calendar.enum.esm.js";import{i as c,D as u,a as p,f as m,l as v,u as $,T as b,b as f}from"./timezones.esm.js";import{a as g}from"../utilities/animation-registry.esm.js";import"../internal/accessibility/a11y.state.enum.esm.js";import"../internal/accessibility/a11y.property.enum.esm.js";import"../internal/accessibility/role.enum.esm.js";const y=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d{1,3})?(?:Z|[+-]\d{2}:?\d{2})$/,w=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{3}))?\[GMT([+-])(\d{2}):(\d{2})\s+([^\]]+)\]$/;function k(t){if("string"!=typeof t)return null;const e=t.trim();if(!y.test(e))return null;const i=new Date(e).getTime();return isNaN(i)?null:i}const D=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,3}))?$/;function N(t){if("string"!=typeof t)return null;const e=D.exec(t.trim());if(!e)return null;const i=Number(e[1]),s=Number(e[2])-1,n=Number(e[3]);if(s<0||s>11||n<1)return null;if(!f(Number(e[4]),Number(e[5]),Number(e[6]??0),Number(e[7]??0)))return null;const r=new Date($(i,s+1,0)).getUTCDate(),a=$(i,s,Math.min(n,r),Number(e[4]),Number(e[5]),Number(e[6]??0),Number(e[7]??0));if(isNaN(a))return null;const l=new Date(a);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hours:l.getUTCHours(),minutes:l.getUTCMinutes(),seconds:l.getUTCSeconds(),ms:l.getUTCMilliseconds()}}function M(t,e){const i=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),s={};for(const e of i.formatToParts(new Date(t)))"literal"!==e.type&&(s[e.type]=Number(e.value));return{year:s.year,month:s.month,day:s.day,hours:24===s.hour?0:s.hour,minutes:s.minute,seconds:s.second,ms:(t%1e3+1e3)%1e3}}let S=class extends h{constructor(){super(...arguments),this.valueAttribute=null,this.allowedDates=JSON.stringify({}),this.range=!1,this.hideTypes=!1,this.showTypes=!1,this.doubleClickUnselect=!1,this.allowClear=!1,this.type="absolute",this.hideDurationFields=[],this.showManualInputs=!1,this.showMonthDropdown=!1,this.showYearDropdown=!1,this.dateFormat="MM/DD/YYYY",this.structuredInput=!1,this.startDate=null,this.endDate=null,this.isSelectingStart=!0,this.hideInput=!1,this.currentMonth=(new Date).getMonth(),this.currentYear=(new Date).getFullYear(),this.allowedDatesLocal=null,this.disabled=!1,this.variant="default",this.timezone="UTC",this.configuredTimezone="UTC",this.internalTimezone=null,this.hideTimeFields=[],this.expanded=!1,this.tpLockedHeight=null,this.tpHours=null,this.tpMinutes=null,this.tpSeconds=null,this.tpMilliseconds=null,this.tpFocusedTimeField=null,this.tpFocusDate=null,this.tpEditingText="",this.seedInstant=null,this.seedFieldsKey=null,this.seedZone=null,this.tpObservedBase=null,this.maskValuesMap=new WeakMap,this.boundMaskInputs=[],this.onMaskKeydown=t=>{if(this.disabled||t.ctrlKey||t.metaKey||t.altKey)return;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Shift","Control","Meta","Alt","CapsLock"].includes(t.key))return;const e=t.currentTarget,i=e?.input;if(!e||!i)return;const s=e.classList.contains("time-input")?"time":"date",n=this.maskLayoutFor(s),r=this.maskValuesFor(i,n),{slotPos:a}=this.computeMaskDisplay(r,n),l=i.selectionStart??0,o=i.selectionEnd??l,h=(t,s)=>{i.value=t,e.value=t;try{i.setSelectionRange(s,s)}catch{}},d=t=>{const e=this.computeMaskDisplay(r,n),i=e.slotPos[t+1];return void 0!==i&&-1!==i?i:e.display.length};if(t.key>="0"&&t.key<="9"){t.preventDefault();let e=a.findIndex((t=>-1!==t&&t>=l));if(-1===e&&(e=r.findIndex((t=>""===t))),-1===e)return;return r[e]=t.key,this.clampMaskSegment(r,n,e),void h(this.computeMaskDisplay(r,n).display,d(e))}if("Backspace"!==t.key)if("Delete"!==t.key)1===t.key.length&&t.preventDefault();else{t.preventDefault();let e=-1;for(let t=0;t<r.length;t++)if(""!==r[t]&&-1!==a[t]&&a[t]>=l){e=t;break}if(-1===e)return;r[e]="";const i=this.computeMaskDisplay(r,n);h(i.display,-1!==i.slotPos[e]?i.slotPos[e]:l)}else{if(t.preventDefault(),l!==o){for(let t=0;t<r.length;t++)-1!==a[t]&&a[t]>=l&&a[t]<o&&(r[t]="");return void h(this.computeMaskDisplay(r,n).display,l)}let e=-1;for(let t=0;t<r.length;t++)""!==r[t]&&-1!==a[t]&&a[t]<l&&(e=t);if(-1===e)return;r[e]="";const i=this.computeMaskDisplay(r,n);h(i.display,-1!==i.slotPos[e]?i.slotPos[e]:Math.max(0,l-1))}},this.onMaskBlur=t=>{const e=t.currentTarget,i=e?.input;if(!e||!i)return;const s=e.classList.contains("time-input")?"time":"date",n=this.maskLayoutFor(s),r=this.maskValuesFor(i,n);if(!r.some((t=>""!==t)))return i.value="",e.value="",void e.emit?.("nile-change",{value:""});const a=[...new Set(n.slots.map((t=>t.segStart)))];for(const t of a){const e=n.slots.map(((e,i)=>e.segStart===t?i:-1)).filter((t=>-1!==t)),i=e.map((t=>r[t])).filter((t=>""!==t));if(i.length>0&&i.length<e.length){const t=i.join("").padStart(e.length,"0");e.forEach(((e,i)=>{r[e]=t[i]}))}}a.forEach((t=>this.clampMaskSegment(r,n,t)));const{display:l}=this.computeMaskDisplay(r,n);i.value=l,e.value=l,e.emit?.("nile-change",{value:l})}}static get styles(){return[a]}setTimezoneInternally(t){t!==this.timezone&&(this.internalTimezone=t),this.timezone=t}get resolvedTimeFields(){const t={hours:!0,minutes:!0,seconds:!0,milliseconds:!0,timezone:!0},e=Array.isArray(this.hideTimeFields)?this.hideTimeFields:[];for(const i of e)t[i]=!1;return t}get tpFewFieldsNoTz(){const t=this.resolvedTimeFields;if(!1!==t.timezone)return!1;return["hours","minutes","seconds","milliseconds"].filter((e=>!1!==t[e])).length<=2}connectedCallback(){super.connectedCallback(),this.hasUpdated||(this.configuredTimezone=this.timezone),this.initializeValue(),this.hasUpdated&&this.bindStructuredInput(),this.hasUpdated&&"date-time-picker"===this.variant&&this.observeCollapsedBase(),this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.releasePanelObserver(),this.unbindStructuredInput(),this.emit("nile-destroy")}firstUpdated(){this.bindStructuredInput()}updated(t){if(super.updated(t),t.has("timezone")&&(this.timezone!==this.internalTimezone&&(this.configuredTimezone=this.timezone),this.internalTimezone=null),t.has("timezone")&&!t.has("valueAttribute")&&null!==this.seedInstant&&(null!==this.seedZone?this.timezone!==this.seedZone&&this.clearInstantSeed():this.seedFieldsKey===this.instantSeedFieldsKey()?c(this.timezone)?this.seedFromInstant(this.seedInstant,this.timezone):(this.clearInstantSeed(),this.initializeValue()):this.clearInstantSeed()),(t.has("structuredInput")||t.has("variant")||t.has("range")||t.has("showManualInputs")||t.has("type")||t.has("dateFormat"))&&this.bindStructuredInput(),t.has("valueAttribute")){this.valueAttribute||(this.value=null,this.startDate=null,this.endDate=null,this.isSelectingStart=!0,"date-time-picker"===this.variant&&this.resetTimeUnits());const t=this.dateFromValueString(this.valueAttribute||"");isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear()),this.initializeValue()}"date-time-picker"===this.variant?(this.applyMonthYearDropdownAnimation(),this.captureCollapsedHeight()):this.releasePanelObserver()}releasePanelObserver(){this.tpResizeObserver?.disconnect(),this.tpResizeObserver=void 0,this.tpObservedBase=null}observeCollapsedBase(){const t=this.shadowRoot?.querySelector(".base--date-time-picker");return t?(this.tpObservedBase!==t&&(this.tpResizeObserver?.disconnect(),this.tpResizeObserver=new ResizeObserver((()=>this.measurePanel(t))),this.tpResizeObserver.observe(t),this.tpObservedBase=t),t):(this.releasePanelObserver(),null)}captureCollapsedHeight(){const t=this.observeCollapsedBase();t&&this.measurePanel(t)}measurePanel(t){if(this.expanded)return;const e=`${t.offsetHeight}px`;e!==this.tpLockedHeight&&(this.tpLockedHeight=e)}applyMonthYearDropdownAnimation(){const t=t=>{t?.querySelectorAll(".month-dropdown, .year-dropdown").forEach((t=>{g(t,"dropdown.show",{keyframes:[{opacity:0,scale:.9,translate:"0 -14px"},{opacity:1,scale:1,translate:"0 0"}],options:{duration:280,easing:"cubic-bezier(0.16, 1, 0.3, 1)"}}),g(t,"dropdown.hide",{keyframes:[{opacity:1,scale:1,translate:"0 0"},{opacity:0,scale:.9,translate:"0 -14px"}],options:{duration:160,easing:"ease"}})}))};t(this.shadowRoot);const e=this.shadowRoot?.querySelector(".tp-inner-calendar");if(e){const i=()=>t(e.shadowRoot);e.updateComplete?e.updateComplete.then(i):i()}}get monthNames(){return Array.from({length:12},((t,e)=>new Date(0,e).toLocaleString("default",{month:"long"})))}get yearOptions(){const t=this.startYear??u,e=this.endYear??p;return t>e?[]:Array.from({length:e-t+1},((e,i)=>t+i))}onMonthSelected(t){this.currentMonth=t,this.emit("nile-month-change",{month:t})}onYearSelected(t){this.currentYear=t,this.emit("nile-year-change",{year:t})}scrollSelectedIntoView(t){const e=this.shadowRoot?.querySelector(t);if(!e)return;const i=e.closest(".month-scroll-wrapper, .year-scroll-wrapper");if(!i)return void e.scrollIntoView({block:"center"});const s=i.scrollTop+(e.getBoundingClientRect().top-i.getBoundingClientRect().top)-(i.clientHeight-e.clientHeight)/2;window.matchMedia("(prefers-reduced-motion: reduce)").matches?i.scrollTop=s:this.smoothScrollTo(i,s,450)}smoothScrollTo(t,e,i){const s=t.scrollTop,n=e-s;if(0===n)return;const r=performance.now(),a=e=>{const l=Math.min(1,(e-r)/i);t.scrollTop=s+n*(t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2)(l),l<1&&requestAnimationFrame(a)};requestAnimationFrame(a)}checkValidAllowedDate(){let t;try{t=JSON.parse(this.allowedDates)}catch(e){t=null}if(!t||0==Object.keys(t).length)return void(this.allowedDatesLocal=null);this.hideInput=!0;this.getUTCDate(t.startDate)>this.getUTCDate(t.endDate)?console.error("StartDate must be greater than endDate"):this.allowedDatesLocal=t}get minYear(){return"date-time-picker"===this.variant?this.startYear??u:this.startYear}get maxYear(){return"date-time-picker"===this.variant?this.endYear??p:this.endYear}isPrevDisabled(){return 0===this.currentMonth&&void 0!==this.minYear&&this.currentYear<=this.minYear}isNextDisabled(){return 11===this.currentMonth&&void 0!==this.maxYear&&this.currentYear>=this.maxYear}formatDate(t){if(!t)return"";const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");let n=this.dateFormat;return n=n.replace(/YYYY/g,"date-time-picker"===this.variant?m(e):String(e)),n=n.replace(/MM/g,i),n=n.replace(/DD/g,s),n=n.replace(/YY/g,String(e).slice(-2)),n}parseDate(t,e){if(!t||!this.dateFormat)return null;const i=this.dateFormat.replace(/YYYY/,"(?<year>\\d{4})").replace(/YY/,"(?<year>\\d{2})").replace(/MM/,"(?<month>\\d{1,2})").replace(/DD/,"(?<day>\\d{1,2})"),s=new RegExp(`^${i}$`),n=t.match(s);if(!n||!n.groups)return null;const r="date-time-picker"===this.variant,a=n.groups.year;let l=2===a.length?Number(`20${a}`):Number(a);r&&2===a.length&&e&&Math.abs(e.getFullYear())%100===Number(a)&&(l=e.getFullYear());const o=Number(n.groups.month)-1,h=Number(n.groups.day),d=r?v(l,o,h):new Date(l,o,h);return e?d.setHours(e.getHours(),e.getMinutes(),e.getSeconds()):d.setHours(0,0,0),d}handleStartDateInput(t){t.stopPropagation();const e=this.parseDate(t.detail.value,this.startDate);e&&(e.setHours(0,0,0),this.startDate=e,this.currentMonth=e.getMonth(),this.currentYear=e.getFullYear(),this.requestUpdate())}handleEndDateInput(t){t.stopPropagation();const e=this.parseDate(t.detail.value,this.endDate);e&&(e.setHours(23,59,59),this.endDate=e,this.currentMonth=e.getMonth(),this.currentYear=e.getFullYear(),this.requestUpdate())}unbindStructuredInput(){for(const t of this.boundMaskInputs)t.removeEventListener("keydown",this.onMaskKeydown,!0),t.removeEventListener("focusout",this.onMaskBlur);this.boundMaskInputs=[]}bindStructuredInput(){if(this.unbindStructuredInput(),!this.structuredInput)return;const t=this.shadowRoot?.querySelectorAll(".calender-input nile-input");t?.forEach((t=>{t.addEventListener("keydown",this.onMaskKeydown,!0),t.addEventListener("focusout",this.onMaskBlur),this.boundMaskInputs.push(t)}))}dateMaskSegments(){const t=t=>{switch(t){case"YYYY":return{kind:"year",len:4,min:0,max:9999};case"YY":return{kind:"year",len:2,min:0,max:99};case"MM":return{kind:"month",len:2,min:1,max:12};default:return{kind:"day",len:2,min:1,max:31}}},e=this.dateFormat||"MM/DD/YYYY",i=/YYYY|YY|MM|DD/g,s=[];let n;for(;null!==(n=i.exec(e));)s.push({token:n[0],index:n.index});return s.map(((i,n)=>{const r=e.slice(i.index+i.token.length,n+1<s.length?s[n+1].index:e.length);return{...t(i.token),after:n<s.length-1?r:""}}))}timeMaskSegments(){return[{kind:"hour",len:2,min:0,max:23,after:":"},{kind:"minute",len:2,min:0,max:59,after:":"},{kind:"second",len:2,min:0,max:59,after:""}]}buildMaskLayout(t){const e=[],i=[];for(const s of t){const t=i.length;for(let n=0;n<s.len;n++)e.push({slot:i.length}),i.push({kind:s.kind,min:s.min,max:s.max,len:s.len,segStart:t});for(const t of s.after)e.push({lit:t})}return{tokens:e,slots:i,length:e.length}}maskLayoutFor(t){return this.buildMaskLayout("time"===t?this.timeMaskSegments():this.dateMaskSegments())}computeMaskDisplay(t,e){let i=-1;t.forEach(((t,e)=>{""!==t&&(i=e)}));let s="";const n=new Array(e.slots.length).fill(-1);for(const r of e.tokens)if("slot"in r){if(r.slot>i)break;n[r.slot]=s.length,t[r.slot]&&(s+=t[r.slot])}else s+=r.lit;return{display:-1===i?"":s,slotPos:n,lastFilled:i}}initMaskValues(t,e){const i=(t||"").replace(/\D/g,"").slice(0,e.slots.length);return e.slots.map(((t,e)=>i[e]??""))}clampMaskSegment(t,e,i){const s=e.slots[i];if("year"===s.kind)return;const n=[];e.slots.forEach(((t,e)=>{t.segStart===s.segStart&&n.push(e)}));const r=n.map((e=>t[e]));if(r.some((t=>""===t)))return;const a=r.join(""),l=Number(a);let o=null;l>s.max?o=String(Number(a[0])).padStart(s.len,"0"):l<s.min&&(o=String(s.min).padStart(s.len,"0")),null!==o&&n.forEach(((e,i)=>{t[e]=o[i]}))}maskValuesFor(t,e){let i=this.maskValuesMap.get(t);return i&&i.length===e.slots.length?this.computeMaskDisplay(i,e).display!==t.value&&(i=this.initMaskValues(t.value,e)):i=this.initMaskValues(t.value,e),this.maskValuesMap.set(t,i),i}render(){return"date-time-picker"===this.variant?this.renderDateTimePicker():e`
2
2
  <div
3
3
  class=${l({base:!0,base__range:this.range})}
4
4
  part="calendar-container"
@@ -15,9 +15,9 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
15
15
  ${"relative"==this.type?this.renderRelativeCalendar():""}
16
16
  ${"absolute"==this.type?this.renderAbsoluteCalendar():""}
17
17
 
18
- ${this.range?i`
18
+ ${this.range?e`
19
19
  <div class="button-container" part="button-container">
20
- ${this.allowClear?i`
20
+ ${this.allowClear?e`
21
21
  <nile-button
22
22
  class="clear-button"
23
23
  variant="secondary"
@@ -26,7 +26,7 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
26
26
  @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.clearDate()}}"
27
27
  @click="${this.clearDate}"
28
28
 
29
- > Reset</nile-button>`:e}
29
+ > Reset</nile-button>`:i}
30
30
  <nile-button
31
31
  class="apply-button"
32
32
  ?disabled="${!this.startDate||!this.endDate||this.disabled}"
@@ -36,13 +36,13 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
36
36
  </div>
37
37
  `:""}
38
38
  </div>
39
- `}renderAbsoluteCalendar(){return i`
39
+ `}renderAbsoluteCalendar(){return e`
40
40
  <div class="calendar-wrapper" part="calendar-wrapper">
41
41
  <div class="calendar-container" >
42
42
  ${this.renderMonth(this.currentYear,this.currentMonth,this.getDaysArray(this.currentYear,this.currentMonth))}
43
43
  </div>
44
44
  </div>
45
- ${this.range?i`
45
+ ${this.range?e`
46
46
  <div class="calender-input ${this.showManualInputs?"":"hidden"}" >
47
47
  <div class="from">
48
48
  <div class="from-date">
@@ -91,11 +91,11 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
91
91
  </div>
92
92
  </div>
93
93
  `:""}
94
- `}renderRelativeCalendar(){return i`
94
+ `}renderRelativeCalendar(){return e`
95
95
  <div class="units-wrapper">
96
96
  <div class="unit-container">
97
97
 
98
- ${this.hideDurationFields?.includes("minutes")?"":i`
98
+ ${this.hideDurationFields?.includes("minutes")?"":e`
99
99
  <div class="unit-group">
100
100
  <div class="duration-name">Minutes</div>
101
101
  <div class="duration-units">
@@ -104,7 +104,7 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
104
104
  </div>
105
105
  `}
106
106
 
107
- ${this.hideDurationFields?.includes("hours")?"":i`
107
+ ${this.hideDurationFields?.includes("hours")?"":e`
108
108
  <div class="unit-group">
109
109
  <div class="duration-name">Hours</div>
110
110
  <div class="duration-units">
@@ -113,7 +113,7 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
113
113
  </div>
114
114
  `}
115
115
 
116
- ${this.hideDurationFields?.includes("days")?"":i`
116
+ ${this.hideDurationFields?.includes("days")?"":e`
117
117
  <div class="unit-group">
118
118
  <div class="duration-name">Days</div>
119
119
  <div class="duration-units">
@@ -122,7 +122,7 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
122
122
  </div>
123
123
  `}
124
124
 
125
- ${this.hideDurationFields?.includes("weeks")?"":i`
125
+ ${this.hideDurationFields?.includes("weeks")?"":e`
126
126
  <div class="unit-group">
127
127
  <div class="duration-name">Weeks</div>
128
128
  <div class="duration-units">
@@ -131,7 +131,7 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
131
131
  </div>
132
132
  `}
133
133
 
134
- ${this.hideDurationFields?.includes("months")?"":i`
134
+ ${this.hideDurationFields?.includes("months")?"":e`
135
135
  <div class="unit-group">
136
136
  <div class="duration-name">Months</div>
137
137
  <div class="duration-units">
@@ -142,7 +142,37 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
142
142
  </div>
143
143
  </div>
144
144
 
145
- ${this.range?i`
145
+ ${"date-time-picker"===this.variant?e`
146
+ <div>
147
+ <div class="unit-input-container">
148
+ <nile-input
149
+ class="manual-input duration-input"
150
+ ?disabled="${this.disabled}"
151
+ label="Duration"
152
+ inputmode="numeric"
153
+ type="text"
154
+ value="${this.selectedValue}"
155
+ @nile-input="${this.handleDurationChange}"
156
+ @nile-change="${this.handleDurationChange}"
157
+ placeholder="Enter Value"
158
+ ></nile-input>
159
+
160
+ <nile-select
161
+ class="manual-input time-input"
162
+ ?disabled="${this.disabled}"
163
+ label="Unit of time"
164
+ value="${this.selectedUnit}"
165
+ @nile-change="${this.handleUnitChange}"
166
+ >
167
+ ${this.hideDurationFields?.includes("minutes")?"":e`<nile-option value="minutes">Minutes</nile-option>`}
168
+ ${this.hideDurationFields?.includes("hours")?"":e`<nile-option value="hours">Hours</nile-option>`}
169
+ ${this.hideDurationFields?.includes("days")?"":e`<nile-option value="days">Days</nile-option>`}
170
+ ${this.hideDurationFields?.includes("weeks")?"":e`<nile-option value="weeks">Weeks</nile-option>`}
171
+ ${this.hideDurationFields?.includes("months")?"":e`<nile-option value="months">Months</nile-option>`}
172
+ </nile-select>
173
+ </div>
174
+ </div>
175
+ `:this.range?e`
146
176
  <div>
147
177
  <div class="unit-input-container">
148
178
  <nile-input
@@ -172,13 +202,13 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
172
202
  </div>
173
203
  </div>
174
204
  `:""}
175
- `}renderTimeValues(t,e){return e.map((e=>i`
205
+ `}renderTimeValues(t,i){return i.map((i=>e`
176
206
  <div
177
- class="duration__value ${this.selectedUnit===t&&this.selectedValue===e?"duration__value--selected":""}"
178
- @click=${i=>this.handleTimeValueClick(t,e,i)}
179
- @keydown="${i=>{"Enter"!==i.key&&" "!==i.key||this.handleTimeValueClick(t,e,i)}}"
180
- >${e}
181
- </div>`))}renderMonth(t,s,n){const a=new Date(t,s,1).getDay(),r=new Date(t,s+1,0).getDay(),h=this.getDaysArray(0===s?t-1:t,0===s?11:s-1),o=this.getDaysArray(11===s?t+1:t,11===s?0:s+1),d=h.slice(h.length-a),c=o.slice(0,6-r),u=[...d,...n,...c],v=(t,i,e,s)=>{if(!s)return"";if(!this.range&&this.value){if(t===this.value.getDate()&&i===this.value.getMonth()&&e===this.value.getFullYear())return"selected-date"}const n=this.startDate&&t===this.startDate.getDate()&&i===this.startDate.getMonth()&&e===this.startDate.getFullYear(),a=this.endDate&&t===this.endDate.getDate()&&i===this.endDate.getMonth()&&e===this.endDate.getFullYear();return n?"range-start":a?"range-end":""},p=(t,i,e,s)=>{if(!s)return!1;if(this.startDate&&this.endDate){const s=new Date(e,i,t);return s>=this.startDate&&s<=this.endDate}return!1};return i`
207
+ class="duration__value ${this.selectedUnit===t&&this.selectedValue===i?"duration__value--selected":""}"
208
+ @click=${e=>this.handleTimeValueClick(t,i,e)}
209
+ @keydown="${e=>{"Enter"!==e.key&&" "!==e.key||this.handleTimeValueClick(t,i,e)}}"
210
+ >${i}
211
+ </div>`))}renderMonth(t,s,n){const r=new Date(t,s,1).getDay(),a=new Date(t,s+1,0).getDay(),o=this.getDaysArray(0===s?t-1:t,0===s?11:s-1),h=this.getDaysArray(11===s?t+1:t,11===s?0:s+1),d=o.slice(o.length-r),c=h.slice(0,6-a),u=[...d,...n,...c],p=(t,e,i,s)=>{if(!s)return"";if(!this.range&&this.value){if(t===this.value.getDate()&&e===this.value.getMonth()&&i===this.value.getFullYear())return"selected-date"}const n=this.startDate&&t===this.startDate.getDate()&&e===this.startDate.getMonth()&&i===this.startDate.getFullYear(),r=this.endDate&&t===this.endDate.getDate()&&e===this.endDate.getMonth()&&i===this.endDate.getFullYear();return n?"range-start":r?"range-end":""},m=(t,e,i,s)=>{if(!s)return!1;if(this.startDate&&this.endDate){const s=new Date(i,e,t);return s>=this.startDate&&s<=this.endDate}return!1};return e`
182
212
  <div class="calendar">
183
213
  <div class="calendar-header">
184
214
  <nile-icon
@@ -194,8 +224,8 @@ import{__decorate as t}from"tslib";import{html as i,nothing as e}from"lit";impor
194
224
  </nile-icon>
195
225
  <div class="calendar-header__center">
196
226
 
197
- ${this.showMonthDropdown||this.showYearDropdown?i`
198
- ${this.showMonthDropdown?i`
227
+ ${this.showMonthDropdown||this.showYearDropdown?e`
228
+ ${this.showMonthDropdown?e`
199
229
  <nile-dropdown ?disabled="${this.disabled}" class="month-dropdown">
200
230
  <span
201
231
  slot="trigger"
@@ -208,11 +238,11 @@ ${this.showMonthDropdown||this.showYearDropdown?i`
208
238
  </span>
209
239
  <nile-menu>
210
240
  <div class="month-scroll-wrapper">
211
- ${this.monthNames.map(((t,e)=>i`
241
+ ${this.monthNames.map(((t,i)=>e`
212
242
  <nile-menu-item
213
243
  class="month-menu-item"
214
- ?selected="${e===s}"
215
- @click="${()=>this.onMonthSelected(e)}"
244
+ ?selected="${i===s}"
245
+ @click="${()=>this.onMonthSelected(i)}"
216
246
  >
217
247
  ${t}
218
248
  </nile-menu-item>
@@ -220,12 +250,12 @@ ${this.showMonthDropdown||this.showYearDropdown?i`
220
250
  </div>
221
251
  </nile-menu>
222
252
  </nile-dropdown>
223
- `:i`
253
+ `:e`
224
254
  <span
225
255
  >${new Date(t,s).toLocaleString("default",{month:"long"})}</span
226
256
  >
227
257
  `}
228
- ${this.showYearDropdown?i`
258
+ ${this.showYearDropdown?e`
229
259
  <nile-dropdown ?disabled="${this.disabled}" class="year-dropdown">
230
260
  <span
231
261
  slot="trigger"
@@ -238,22 +268,22 @@ ${this.showMonthDropdown||this.showYearDropdown?i`
238
268
  </span>
239
269
  <nile-menu>
240
270
  <div class="year-scroll-wrapper">
241
- ${this.yearOptions.map((e=>i`
271
+ ${this.yearOptions.map((i=>e`
242
272
  <nile-menu-item
243
273
  class="year-menu-item"
244
- ?selected="${e===t}"
245
- @click="${()=>this.onYearSelected(e)}"
274
+ ?selected="${i===t}"
275
+ @click="${()=>this.onYearSelected(i)}"
246
276
  >
247
- ${e}
277
+ ${i}
248
278
  </nile-menu-item>
249
279
  `))}
250
280
  </div>
251
281
  </nile-menu>
252
282
  </nile-dropdown>
253
- `:i`
283
+ `:e`
254
284
  <span>${t}</span>
255
285
  `}
256
- `:i`
286
+ `:e`
257
287
  <span
258
288
  >${new Date(t,s).toLocaleString("default",{month:"long"})}
259
289
  ${t}</span
@@ -276,20 +306,314 @@ ${this.showMonthDropdown||this.showYearDropdown?i`
276
306
  </div>
277
307
 
278
308
  <div class="days_container">
279
- ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((t=>i`<div class="day_name">${t}</div>`))}
280
- ${u.map(((a,r)=>{const h=r>=d.length&&r<d.length+n.length,o=v(a,s,t,h),c={day_date:!0,"not-allowed":!this.isAllowedDate(a,s,t),"in-range":p(a,s,t,h),filler:!h};return o&&(c[o]=!0),i`
309
+ ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((t=>e`<div class="day_name">${t}</div>`))}
310
+ ${u.map(((r,a)=>{const o=a>=d.length&&a<d.length+n.length,h=p(r,s,t,o),c={day_date:!0,"not-allowed":!this.isAllowedDate(r,s,t),"in-range":m(r,s,t,o),filler:!o};return h&&(c[h]=!0),e`
281
311
  <div
282
- part="calendar-day-${a}"
312
+ part="calendar-day-${r}"
283
313
  class=${l(c)}
284
- tabindex="${h&&this.isAllowedDate(a,s,t)&&!this.disabled?"0":"-1"}"
285
- @keydown="${i=>{"Enter"!==i.key&&" "!==i.key||this.selectDate(a,s,t)}}"
286
- @click="${()=>{h&&this.selectDate(a,s,t)}}"
314
+ tabindex="${o&&this.isAllowedDate(r,s,t)&&!this.disabled?"0":"-1"}"
315
+ @keydown="${e=>{"Enter"!==e.key&&" "!==e.key||this.selectDate(r,s,t)}}"
316
+ @click="${()=>{o&&this.selectDate(r,s,t)}}"
287
317
  >
288
318
  <span style="position:relative;">
289
- ${a}
290
- ${((t,i,e)=>{const s=new Date;return t===s.getDate()&&i+1===s.getMonth()+1&&e===s.getFullYear()})(a,s,t)&&h?i`<div class="current__date__dot" part="current-date-dot"></div>`:e}
319
+ ${r}
320
+ ${((t,e,i)=>{const s=new Date;return t===s.getDate()&&e+1===s.getMonth()+1&&i===s.getFullYear()})(r,s,t)&&o?e`<div class="current__date__dot" part="current-date-dot"></div>`:i}
291
321
  </span>
292
322
  </div>`}))}
293
323
  </div>
294
324
  </div>
295
- `}isAllowedDate(t,i,e){if(!this.allowedDatesLocal)return!0;const s=new Date(Date.UTC(e,i,t)),n=this.getUTCDate(this.allowedDatesLocal.startDate),a=this.getUTCDate(this.allowedDatesLocal.endDate);a.setUTCHours(23,59,59,999);return s>=n&&s<=a}clearDate(t){(t??(this.range?"relative"===this.type?d.Relative:d.Range:d.Single))===d.Single?this.value=null:(this.valueAttribute="",this.startDate=null,this.endDate=null,this.selectedUnit=void 0,this.selectedValue=void 0),this.requestUpdate(),this.emit("nile-clear")}selectDate(t,i,e){if(this.disabled)return;const s=new Date(e,i,t);if(this.range)if(this.startDate&&this.endDate&&(this.startDate=null,this.endDate=null),this.isSelectingStart)this.startDate=s,this.endDate&&s>this.endDate&&(this.endDate=null),this.isSelectingStart=!1;else if(this.isSelectingStart=!0,this.startDate&&s<this.startDate)this.startDate=s,this.endDate=null,this.isSelectingStart=!1;else{const t=s;t.setHours(23,59,59,999),this.endDate=t}else{if(String(this.value)==String(s)&&this.doubleClickUnselect)return void this.clearDate();this.value=s,this.emitChangedData({value:this.value})}}initializeValue(){if(this.range)try{const t=JSON.parse(this.valueAttribute||"");this.startDate=new Date(t.startDate),this.endDate=new Date(t.endDate),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),this.value=null}catch(t){}else if(this.valueAttribute){let t=new Date(this.valueAttribute);t=new Date(t.getTime()-6e4*t.getTimezoneOffset()),isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear())}}handleDurationChange(t){t.stopPropagation(),t.detail.value=t.detail.value.replace(/e/gi,"");const i=Number(t.detail.value);i&&(this.selectedValue=i,this.selectedUnit&&this.selectedValue&&this.handleTimeValueClick(this.selectedUnit,this.selectedValue,t))}handleUnitChange(t){t.stopPropagation(),this.selectedUnit=t.detail.value,this.selectedUnit&&this.selectedValue&&this.handleTimeValueClick(this.selectedUnit,this.selectedValue,t)}handleTimeValueClick(t,i,e){this.createRelativePeriod(t,i),this.selectedUnit=t,this.selectedValue=i}createRelativePeriod(t,i){const e=new Date,s=new Date;switch(t){case"minutes":s.setMinutes(s.getMinutes()-i);break;case"hours":s.setHours(s.getHours()-i);break;case"days":s.setDate(s.getDate()-i);break;case"weeks":s.setDate(s.getDate()-7*i);break;case"months":s.setMonth(s.getMonth()-i)}return this.startDate=new Date(s.getTime()),this.endDate=new Date(e.getTime()),{startDate:this.startDate,endDate:this.endDate}}handleStartTimeInput(t){if(t.stopPropagation(),!this.startDate)return void(this.startDate=null);const i=this.parseTime(t.detail.value,this.startDate);i?this.startDate=i:this.startDate.setHours(0,0,0),this.requestUpdate()}handleEndTimeInput(t){if(t.stopPropagation(),!this.endDate)return void(this.endDate=null);const i=this.parseTime(t.detail.value,this.endDate);i?this.endDate=i:this.endDate.setHours(0,0,0),this.requestUpdate()}parseTime(t,i){if(!this.isValidTimeInput(t))return null;const[e,s,n]=t.split(":").map(Number),a=new Date(i.getTime());return a.setHours(e,s,n),a}isValidTimeInput(t){return/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/.test(t)}formatTime(t){if(!t)return"";return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}nextMonth(){if(!this.disabled)if(11===this.currentMonth){const t=this.currentYear+1;if(void 0!==this.endYear&&t>this.endYear)return;this.currentMonth=0,this.currentYear=t}else this.currentMonth++}prevMonth(){if(!this.disabled)if(0===this.currentMonth){const t=this.currentYear-1;if(void 0!==this.startYear&&t<this.startYear)return;this.currentMonth=11,this.currentYear=t}else this.currentMonth--}confimRange(){this.startDate&&this.endDate&&this.emitChangedData({startDate:this.startDate,endDate:this.endDate})}onTypeChange(t){this.disabled||(this.type=t.detail.value,this.emit("nile-type-change",{value:this.type}))}getUTCDate(t){return new Date(Date.UTC(t.slice(0,4),t.slice(5,7)-1,t.slice(8,10)))}emitChangedData(t){this.emit("nile-changed",t),this.emit("nile-change",t)}getDaysArray(t,i){const e=new Date(t,i+1,0).getDate();return Array.from({length:e},((t,i)=>i+1))}};t([s({type:String,attribute:"value"})],c.prototype,"valueAttribute",void 0),t([s({type:String,attribute:!0,reflect:!0})],c.prototype,"allowedDates",void 0),t([s({type:Boolean,reflect:!0})],c.prototype,"range",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],c.prototype,"hideTypes",void 0),t([s({type:Boolean,reflect:!0})],c.prototype,"doubleClickUnselect",void 0),t([s({type:Boolean,reflect:!0})],c.prototype,"allowClear",void 0),t([s({type:String,reflect:!0})],c.prototype,"type",void 0),t([s({type:String})],c.prototype,"selectedUnit",void 0),t([s({type:Number})],c.prototype,"selectedValue",void 0),t([s({type:Array,attribute:"hide-duration-fields"})],c.prototype,"hideDurationFields",void 0),t([s({type:Boolean})],c.prototype,"showManualInputs",void 0),t([s({type:Number,attribute:!0,reflect:!0})],c.prototype,"startYear",void 0),t([s({type:Number,attribute:!0,reflect:!0})],c.prototype,"endYear",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],c.prototype,"showMonthDropdown",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],c.prototype,"showYearDropdown",void 0),t([s({type:String,reflect:!0,attribute:!0})],c.prototype,"dateFormat",void 0),t([n()],c.prototype,"startDate",void 0),t([n()],c.prototype,"endDate",void 0),t([n()],c.prototype,"isSelectingStart",void 0),t([n()],c.prototype,"hideInput",void 0),t([n()],c.prototype,"value",void 0),t([n()],c.prototype,"currentMonth",void 0),t([n()],c.prototype,"currentYear",void 0),t([n()],c.prototype,"allowedDatesLocal",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],c.prototype,"disabled",void 0),t([h("allowedDates")],c.prototype,"checkValidAllowedDate",null),c=t([a("nile-calendar")],c);export{c as N};
325
+ `}isAllowedDate(t,e,i){if(!this.allowedDatesLocal)return!0;const s=new Date("date-time-picker"===this.variant?$(i,e,t):Date.UTC(i,e,t)),n=this.getUTCDate(this.allowedDatesLocal.startDate),r=this.getUTCDate(this.allowedDatesLocal.endDate);r.setUTCHours(23,59,59,999);return s>=n&&s<=r}dayCellLabel(t,e,i){return v(i,e,t,12).toLocaleDateString("default",{weekday:"long",day:"numeric",month:"long",year:"numeric"})}clearDate(t){const e=t??(this.range?"relative"===this.type?d.Relative:d.Range:d.Single);this.clearInstantSeed(),e===d.Single?this.value=null:(this.valueAttribute="",this.startDate=null,this.endDate=null,this.selectedUnit=void 0,this.selectedValue=void 0),this.requestUpdate(),this.emit("nile-clear")}selectDate(t,e,i){if(this.disabled)return;const s="date-time-picker"===this.variant?v(i,e,t):new Date(i,e,t);if(this.range)if(this.startDate&&this.endDate&&(this.startDate=null,this.endDate=null),this.isSelectingStart)this.startDate=s,this.endDate&&s>this.endDate&&(this.endDate=null),this.isSelectingStart=!1;else if(this.isSelectingStart=!0,this.startDate&&s<this.startDate)this.startDate=s,this.endDate=null,this.isSelectingStart=!1;else{const t=s;t.setHours(23,59,59,999),this.endDate=t}else{if(String(this.value)==String(s)&&this.doubleClickUnselect)return void this.clearDate();this.value=s,this.emitChangedData({value:this.value})}}initializeValue(){if(this.clearInstantSeed(),this.range)try{const t=JSON.parse(this.valueAttribute||"");this.startDate=this.rangeBoundFromValue(t.startDate,!1),this.endDate=this.rangeBoundFromValue(t.endDate,!0),this.startDate=new Date(this.startDate.getTime()),this.endDate=new Date(this.endDate.getTime()),"date-time-picker"===this.variant&&this.startDate&&!isNaN(this.startDate.getTime())&&(this.currentMonth=this.startDate.getMonth(),this.currentYear=this.startDate.getFullYear()),this.value=null}catch(t){}else{if("date-time-picker"===this.variant&&this.trySeedFromInstantValue())return;const t="date-time-picker"===this.variant?this.parseZonedValue(this.valueAttribute):null;if(t){this.setTimezoneInternally(t.timezone);const e=t.wall;return this.value=v(e.year,e.month-1,e.day,12,0,0,0),this.currentMonth=e.month-1,this.currentYear=e.year,this.tpHours=e.hours,this.tpMinutes=e.minutes,this.tpSeconds=e.seconds,void(this.tpMilliseconds=e.ms)}if("date-time-picker"===this.variant){const t=N(this.valueAttribute);if(t)return this.value=v(t.year,t.month-1,t.day,12,0,0,0),this.currentMonth=t.month-1,this.currentYear=t.year,this.tpHours=t.hours,this.tpMinutes=t.minutes,this.tpSeconds=t.seconds,void(this.tpMilliseconds=t.ms)}if("date-time-picker"===this.variant){const t=this.parsePresetValue(this.valueAttribute);return void(t?(this.value=t,this.currentMonth=t.getMonth(),this.currentYear=t.getFullYear(),this.tpHours=t.getHours(),this.tpMinutes=t.getMinutes(),this.tpSeconds=t.getSeconds(),this.tpMilliseconds=t.getMilliseconds()):this.valueAttribute&&(this.value=null,this.resetTimeUnits()))}if(this.valueAttribute){const t=this.dateFromValueString(this.valueAttribute);isNaN(t.getTime())||(this.value=t,this.currentMonth=this.value.getMonth(),this.currentYear=this.value.getFullYear())}}}clearInstantSeed(){this.seedInstant=null,this.seedFieldsKey=null,this.seedZone=null}instantSeedFieldsKey(){const t=this.value;return t?`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}|${this.tpHours}:${this.tpMinutes}:${this.tpSeconds}.${this.tpMilliseconds}`:null}seedFromInstant(t,e){const i=M(t,e);this.value=v(i.year,i.month-1,i.day,12,0,0,0),this.currentMonth=i.month-1,this.currentYear=i.year,this.tpHours=i.hours,this.tpMinutes=i.minutes,this.tpSeconds=i.seconds,this.tpMilliseconds=i.ms,this.seedInstant=t,this.seedFieldsKey=this.instantSeedFieldsKey()}trySeedFromInstantValue(){const t=k(this.valueAttribute);if(null!==t)return!!c(this.timezone)&&(this.seedFromInstant(t,this.timezone),this.seedZone=null,!0);const e=function(t){if("string"!=typeof t)return null;const e=w.exec(t.trim());if(!e)return null;const[,i,s,n,r,a,l,o,h,d,u,p]=e,m=p.trim();if(!c(m))return null;const v={year:Number(i),month:Number(s),day:Number(n),hours:Number(r),minutes:Number(a),seconds:Number(l),ms:Number(o??0)},b=24===v.hours;if(v.hours>24||b&&(0!==v.minutes||0!==v.seconds||0!==v.ms))return null;const f=("-"===h?-1:1)*(36e5*Number(d)+6e4*Number(u)),g=$(v.year,v.month-1,v.day,v.hours,v.minutes,v.seconds,v.ms),y=g-f,k=M(y,m),D=b?M(g,"UTC"):v;return k.year===D.year&&k.month===D.month&&k.day===D.day&&k.hours===D.hours&&k.minutes===D.minutes&&k.seconds===D.seconds&&k.ms===D.ms?{epochMs:y,timezone:m}:null}(this.valueAttribute);return!!e&&(this.setTimezoneInternally(e.timezone),this.seedFromInstant(e.epochMs,e.timezone),this.seedZone=e.timezone,!0)}dateFromValueString(t){const e=new Date(t);return new Date(e.getTime()-6e4*e.getTimezoneOffset())}rangeBoundFromValue(t,e){if("date-time-picker"===this.variant&&"string"==typeof t&&/^\d{4}-\d{2}-\d{2}$/.test(t)){const i=this.parsePresetValue(t);if(i)return e&&i.setHours(23,59,59,999),i}return new Date(t)}parsePresetValue(t){if(!t)return null;if(/^\d{4}-\d{2}-\d{2}$/.exec(t)){const e=Number(t.slice(0,4)),i=Number(t.slice(5,7))-1,s=Number(t.slice(8,10));if(i<0||i>11||s<1)return null;const n=v(e,i+1,0).getDate(),r=v(e,i,Math.min(s,n));return isNaN(r.getTime())?null:r}const e=new Date(t);return isNaN(e.getTime())?null:e}parseZonedValue(t){if(!t)return null;const e=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{3}))?\[GMT[+-]\d{2}:\d{2}\s+([^\]]+)\]$/.exec(t.trim());if(!e)return null;const[,i,s,n,r,a,l,o,h]=e,d=Number(s)-1,u=Number(r),p=Number(a),m=Number(l);if(d<0||d>11||u>23||p>59||m>59)return null;const $=Number(n);if($<1)return null;const b=v(Number(i),d+1,0).getDate(),f={year:Number(i),month:d+1,day:Math.min($,b),hours:u,minutes:p,seconds:m,ms:Number(o??0)},g=h.trim();return{wall:f,timezone:c(g)?g:"UTC"}}handleDurationChange(t){if(t.stopPropagation(),"date-time-picker"===this.variant){const e=t.target,i=String(t.detail?.value??e?.value??"").replace(/\D/g,"");e&&e.value!==i&&(e.value=i);const s=Number(i);return s?(this.selectedValue=s,void(this.selectedUnit&&this.selectedValue&&this.handleTimeValueClick(this.selectedUnit,this.selectedValue,t))):(this.selectedValue=void 0,this.startDate=null,this.endDate=null,void this.requestUpdate())}t.detail.value=t.detail.value.replace(/e/gi,"");const e=Number(t.detail.value);e&&(this.selectedValue=e,this.selectedUnit&&this.selectedValue&&this.handleTimeValueClick(this.selectedUnit,this.selectedValue,t))}handleUnitChange(t){t.stopPropagation(),this.selectedUnit=t.detail.value,this.selectedUnit&&this.selectedValue&&this.handleTimeValueClick(this.selectedUnit,this.selectedValue,t)}handleTimeValueClick(t,e,i){this.createRelativePeriod(t,e),this.selectedUnit=t,this.selectedValue=e}createRelativePeriod(t,e){const i=new Date,s=new Date,n="date-time-picker"===this.variant;switch(t){case"minutes":n?s.setTime(i.getTime()-6e4*e):s.setMinutes(s.getMinutes()-e);break;case"hours":n?s.setTime(i.getTime()-36e5*e):s.setHours(s.getHours()-e);break;case"days":s.setDate(s.getDate()-e);break;case"weeks":s.setDate(s.getDate()-7*e);break;case"months":if(n){const t=s.getDate();s.setDate(1),s.setMonth(s.getMonth()-e);const i=v(s.getFullYear(),s.getMonth()+1,0).getDate();s.setDate(Math.min(t,i))}else s.setMonth(s.getMonth()-e)}return n&&(isNaN(s.getTime())||isNaN(i.getTime()))?(this.startDate=null,this.endDate=null,{startDate:null,endDate:null}):(this.startDate=new Date(s.getTime()),this.endDate=new Date(i.getTime()),{startDate:this.startDate,endDate:this.endDate})}handleStartTimeInput(t){if(t.stopPropagation(),!this.startDate)return void(this.startDate=null);const e=this.parseTime(t.detail.value,this.startDate);e?this.startDate=e:this.startDate.setHours(0,0,0),this.requestUpdate()}handleEndTimeInput(t){if(t.stopPropagation(),!this.endDate)return void(this.endDate=null);const e=this.parseTime(t.detail.value,this.endDate);e?this.endDate=e:this.endDate.setHours(0,0,0),this.requestUpdate()}parseTime(t,e){if(!this.isValidTimeInput(t))return null;const[i,s,n]=t.split(":").map(Number),r=new Date(e.getTime());return r.setHours(i,s,n),r}isValidTimeInput(t){return/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/.test(t)}formatTime(t){if(!t)return"";return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}nextMonth(){if(!this.disabled)if(11===this.currentMonth){const t=this.currentYear+1;if(void 0!==this.maxYear&&t>this.maxYear)return;this.currentMonth=0,this.currentYear=t}else this.currentMonth++}prevMonth(){if(!this.disabled)if(0===this.currentMonth){const t=this.currentYear-1;if(void 0!==this.minYear&&t<this.minYear)return;this.currentMonth=11,this.currentYear=t}else this.currentMonth--}confimRange(){this.startDate&&this.endDate&&this.emitChangedData({startDate:this.startDate,endDate:this.endDate})}onTypeChange(t){this.disabled||(this.type=t.detail.value,"date-time-picker"===this.variant&&"absolute"!==this.type&&(this.expanded=!1),this.emit("nile-type-change",{value:this.type}))}getUTCDate(t){return"date-time-picker"===this.variant?new Date($(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10)))):new Date(Date.UTC(t.slice(0,4),t.slice(5,7)-1,t.slice(8,10)))}emitChangedData(t){this.emit("nile-changed",t),this.emit("nile-change",t)}getDaysArray(t,e){const i=new Date(t,e+1,0).getDate();return Array.from({length:i},((t,e)=>e+1))}renderDateTimePicker(){const t="absolute"===this.type&&this.expanded&&!!this.tpLockedHeight;return e`
326
+ <div
327
+ class=${l({base:!0,"base--date-time-picker":!0,"base--tp-expanded":this.expanded,"base--tp-fewfields":this.tpFewFieldsNoTz,"base--tp-height-locked":t})}
328
+ style=${t?`--nile-calendar-tp-locked-height:${this.tpLockedHeight}`:i}
329
+ part="calendar-container"
330
+ >
331
+ <div class=${l({"calendar-config":!0,hidden:!this.showTypes})} part="calendar-config">
332
+ <div class="calendar-switcher" part="calendar-switcher">
333
+ <nile-tab-group centered @nile-tab-show="${this.onTypeChange}" value="${this.type}">
334
+ <nile-tab slot="nav" panel="absolute" tabindex="${this.disabled?"-1":"0"}">Absolute</nile-tab>
335
+ <nile-tab slot="nav" panel="relative" tabindex="${this.disabled?"-1":"0"}">Relative</nile-tab>
336
+ </nile-tab-group>
337
+ </div>
338
+ </div>
339
+
340
+ ${"relative"===this.type?this.renderRelativeCalendar():this.renderDateTimePickerAbsolute()}
341
+
342
+ <div
343
+ class=${l({"tp-footer":!0,"tp-footer--relative":"relative"===this.type})}
344
+ part="tp-footer"
345
+ >
346
+ ${"absolute"===this.type?e`
347
+ <nile-button
348
+ id="tp-set-to-now"
349
+ class="tp-set-to-now-button"
350
+ part="tp-set-to-now-button"
351
+ variant="secondary"
352
+ ?disabled="${this.disabled}"
353
+ @click="${this.handleSetToNow}"
354
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.handleSetToNow()}}"
355
+ >Set to now <nile-glyph name="ng-clock" size="16" method="stroke" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":i}></nile-glyph></nile-button>
356
+ <nile-lite-tooltip
357
+ for="tp-set-to-now"
358
+ content="Sets the time to the current time"
359
+ size="small"
360
+ ></nile-lite-tooltip>
361
+ `:i}
362
+ <div class="tp-footer-actions" part="tp-footer-actions">
363
+ <nile-button
364
+ class="clear-button"
365
+ part="clear-button"
366
+ variant="secondary"
367
+ ?disabled="${this.disabled||!this.hasSelection()}"
368
+ @click="${this.handleReset}"
369
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.handleReset()}}"
370
+ >Reset</nile-button>
371
+ <nile-button
372
+ class="apply-button"
373
+ part="apply-button"
374
+ ?disabled="${this.disabled||!this.hasSelection()}"
375
+ @click="${this.handleApply}"
376
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.handleApply()}}"
377
+ >Apply</nile-button>
378
+ </div>
379
+ </div>
380
+ </div>
381
+ `}renderDateTimePickerAbsolute(){return e`
382
+ <div class="calendar-wrapper" part="calendar-wrapper">
383
+ <div class="calendar-container">
384
+ ${this.expanded?this.renderExpandedCalendar():this.renderCollapsedMonth(this.currentYear,this.currentMonth)}
385
+ </div>
386
+ </div>
387
+
388
+ <div
389
+ class=${l({"tp-chevron":!0,"tp-chevron--expanded":this.expanded})}
390
+ part="tp-chevron"
391
+ role="button"
392
+ tabindex="${this.disabled?"-1":"0"}"
393
+ aria-expanded="${this.expanded}"
394
+ aria-label="${this.expanded?"Collapse calendar":"Expand calendar"}"
395
+ @click="${this.toggleExpanded}"
396
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.toggleExpanded()}}"
397
+ >
398
+ <nile-icon name="arrowdropdown" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}></nile-icon>
399
+ </div>
400
+
401
+ <div class="tp-scroll-area" part="tp-scroll-area">
402
+ <div class="tp-scroll-content" part="tp-scroll-content">
403
+ ${this.renderTimeFields()}
404
+ ${this.resolvedTimeFields.timezone?this.renderTimezone():""}
405
+ </div>
406
+ </div>
407
+ `}renderExpandedCalendar(){return this.renderVariantMonth(this.currentYear,this.currentMonth,this.getFullMonthDays(this.currentYear,this.currentMonth))}renderCollapsedMonth(t,e){return this.renderVariantMonth(t,e,this.getCollapsedWindowDays(t,e))}renderVariantMonth(t,s,n){const r=(t,e,i,s)=>{if(!s)return"";if(this.value){if(t===this.value.getDate()&&e===this.value.getMonth()&&i===this.value.getFullYear())return"selected-date"}return""},a=(t,e,i)=>{const s=new Date;return t===s.getDate()&&e+1===s.getMonth()+1&&i===s.getFullYear()},o=t=>`${t.year}-${t.month}-${t.day}`,h=n.filter((t=>t.inMonth&&this.isAllowedDate(t.day,t.month,t.year))),d=[this.tpFocusDate&&this.tpFocusDate,this.value&&{year:this.value.getFullYear(),month:this.value.getMonth(),day:this.value.getDate()},(()=>{const t=new Date;return{year:t.getFullYear(),month:t.getMonth(),day:t.getDate()}})()];let c=null;for(const t of d)if(t&&h.some((e=>o(e)===o(t)))){c=o(t);break}return null===c&&h.length&&(c=o(h[0])),e`
408
+ <div class="calendar" part="calendar">
409
+ <div class="calendar-header" part="calendar-header">
410
+ <nile-icon
411
+ class="calendar-header__month-navigation"
412
+ part="calendar-header-prev"
413
+ name="var(--nile-icon-arrow-left, var(--ng-icon-chevron-left))"
414
+ method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))"
415
+ color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}
416
+ role="button"
417
+ aria-label="Previous month"
418
+ aria-disabled="${this.disabled||this.isPrevDisabled()}"
419
+ tabindex="${this.disabled||this.isPrevDisabled()?"-1":"0"}"
420
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.prevMonth()}}"
421
+ @click="${this.prevMonth}"
422
+ >
423
+ </nile-icon>
424
+ <div class="calendar-header__center" part="calendar-header-center">
425
+
426
+ ${this.showMonthDropdown||this.showYearDropdown?e`
427
+ ${this.showMonthDropdown?e`
428
+ <nile-dropdown ?disabled="${this.disabled}" class="month-dropdown"
429
+ @nile-after-show="${()=>this.scrollSelectedIntoView(".month-menu-item[selected]")}">
430
+ <span
431
+ slot="trigger"
432
+ class="calendar-header__trigger month-trigger"
433
+ role="button"
434
+ part="trigger"
435
+ tabindex="${this.disabled?"-1":"0"}"
436
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.currentTarget.click())}}"
437
+ >
438
+ ${new Date(t,s).toLocaleString("default",{month:"long"})}
439
+ <nile-icon name="arrowdropdown" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"} class="calendar-header__caret"></nile-icon>
440
+ </span>
441
+ <nile-menu>
442
+ <div class="month-scroll-wrapper">
443
+ ${this.monthNames.map(((t,i)=>e`
444
+ <nile-menu-item
445
+ class="month-menu-item"
446
+ ?selected="${i===s}"
447
+ @click="${()=>this.onMonthSelected(i)}"
448
+ >
449
+ ${t}
450
+ </nile-menu-item>
451
+ `))}
452
+ </div>
453
+ </nile-menu>
454
+ </nile-dropdown>
455
+ `:e`
456
+ <span
457
+ >${new Date(t,s).toLocaleString("default",{month:"long"})}</span
458
+ >
459
+ `}
460
+ ${this.showYearDropdown?e`
461
+ <nile-dropdown ?disabled="${this.disabled}" class="year-dropdown"
462
+ @nile-after-show="${()=>this.scrollSelectedIntoView(".year-menu-item[selected]")}">
463
+ <span
464
+ slot="trigger"
465
+ class="calendar-header__trigger"
466
+ role="button"
467
+ part="trigger"
468
+ tabindex="${this.disabled?"-1":"0"}"
469
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.currentTarget.click())}}"
470
+ >
471
+ ${t}
472
+ <nile-icon name="arrowdropdown" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"} class="calendar-header__caret"></nile-icon>
473
+ </span>
474
+ <nile-menu>
475
+ <div class="year-scroll-wrapper">
476
+ ${this.yearOptions.map((i=>e`
477
+ <nile-menu-item
478
+ class="year-menu-item"
479
+ ?selected="${i===t}"
480
+ @click="${()=>this.onYearSelected(i)}"
481
+ >
482
+ ${i}
483
+ </nile-menu-item>
484
+ `))}
485
+ </div>
486
+ </nile-menu>
487
+ </nile-dropdown>
488
+ `:e`
489
+ <span>${t}</span>
490
+ `}
491
+ `:e`
492
+ <span
493
+ >${new Date(t,s).toLocaleString("default",{month:"long"})}
494
+ ${t}</span
495
+ >
496
+ `}
497
+ </div>
498
+
499
+ <nile-icon
500
+ class="calendar-header__month-navigation"
501
+ part="calendar-header-next"
502
+ name="var(--nile-icon-arrow-right, var(--ng-icon-chevron-right))"
503
+ method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))"
504
+ color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}
505
+ role="button"
506
+ aria-label="Next month"
507
+ aria-disabled="${this.disabled||this.isNextDisabled()}"
508
+ tabindex="${this.disabled||this.isNextDisabled()?"-1":"0"}"
509
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||this.nextMonth()}}"
510
+ @click="${this.nextMonth}"
511
+ >
512
+ </nile-icon>
513
+ </div>
514
+
515
+ <div class="days_container" part="days-container">
516
+ ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((t=>e`<div class="day_name" part="day-name">${t}</div>`))}
517
+ ${n.map((t=>{const s=t.inMonth,n=r(t.day,t.month,t.year,s),h={day_date:!0,"not-allowed":!this.isAllowedDate(t.day,t.month,t.year),filler:!s};n&&(h[n]=!0);const d=this.isAllowedDate(t.day,t.month,t.year),u=a(t.day,t.month,t.year)&&s;return e`
518
+ <div
519
+ part="calendar-day-${t.day}"
520
+ class=${l(h)}
521
+ role=${s?"button":i}
522
+ aria-hidden=${s?i:"true"}
523
+ aria-label=${s?this.dayCellLabel(t.day,t.month,t.year):i}
524
+ aria-disabled=${!s||d&&!this.disabled?i:"true"}
525
+ aria-pressed=${s?String(!!n):i}
526
+ aria-current=${u?"date":i}
527
+ data-tp-date="${s?o(t):i}"
528
+ tabindex="${s&&!this.disabled&&o(t)===c?"0":"-1"}"
529
+ @keydown="${e=>{if(s)return"Enter"===e.key||" "===e.key?(e.preventDefault(),this.tpFocusDate={year:t.year,month:t.month,day:t.day},void this.tpSelectDate(t.day,t.month,t.year)):void this.handleDayNavigationKey(e,t)}}"
530
+ @click="${()=>{s&&(this.tpFocusDate={year:t.year,month:t.month,day:t.day},this.tpSelectDate(t.day,t.month,t.year))}}"
531
+ >
532
+ <span class="day-label" part="calendar-day-label">
533
+ ${t.day}
534
+ ${a(t.day,t.month,t.year)&&s?e`<div class="current__date__dot" part="current-date-dot"></div>`:i}
535
+ </span>
536
+ </div>`}))}
537
+ </div>
538
+ </div>
539
+ `}getCollapsedWindowDays(t,e){const i=new Date,s=i.getFullYear()===t&&i.getMonth()===e,n=i=>{const s=v(t,e,i),n=new Date(s);return n.setDate(s.getDate()-s.getDay()-7),n},r=this.value instanceof Date&&this.value.getFullYear()===t&&this.value.getMonth()===e?n(this.value.getDate()):s?n(i.getDate()):(()=>{const i=v(t,e,1),s=new Date(i);return s.setDate(1-i.getDay()),s})();return Array.from({length:21},((i,s)=>{const n=new Date(r);return n.setDate(r.getDate()+s),{day:n.getDate(),month:n.getMonth(),year:n.getFullYear(),inMonth:n.getMonth()===e&&n.getFullYear()===t}}))}getFullMonthDays(t,e){const i=v(t,e,1).getDay(),s=v(t,e+1,0).getDate(),n=7*Math.ceil((i+s)/7),r=v(t,e,1-i);return Array.from({length:n},((i,s)=>{const n=new Date(r);return n.setDate(r.getDate()+s),{day:n.getDate(),month:n.getMonth(),year:n.getFullYear(),inMonth:n.getMonth()===e&&n.getFullYear()===t}}))}handleDayNavigationKey(t,e){if(this.disabled||t.ctrlKey||t.metaKey||t.altKey)return;const i=v(e.year,e.month,e.day);let s=null;switch(t.key){case"ArrowLeft":s=v(e.year,e.month,e.day-1);break;case"ArrowRight":s=v(e.year,e.month,e.day+1);break;case"ArrowUp":s=v(e.year,e.month,e.day-7);break;case"ArrowDown":s=v(e.year,e.month,e.day+7);break;case"Home":s=v(e.year,e.month,e.day-i.getDay());break;case"End":s=v(e.year,e.month,e.day+(6-i.getDay()));break;case"PageUp":case"PageDown":{const i=("PageUp"===t.key?-1:1)*(t.shiftKey?12:1),n=e.month+i,r=v(e.year,n+1,0).getDate();s=v(e.year,n,Math.min(e.day,r));break}default:return}t.preventDefault(),this.moveDayFocus(s)}moveDayFocus(t){const e=t.getFullYear(),i=t.getMonth(),s=this.minYear,n=this.maxYear;if(void 0!==s&&e<s||void 0!==n&&e>n)return;this.tpFocusDate={year:e,month:i,day:t.getDate()},this.currentYear=e,this.currentMonth=i;const r=`[data-tp-date="${e}-${i}-${t.getDate()}"]`,a=()=>this.shadowRoot?.querySelector(r)?.focus();this.updateComplete.then((()=>{this.shadowRoot?.querySelector(r)?a():(this.expanded=!0,this.updateComplete.then(a).catch((()=>{})))})).catch((()=>{}))}tpSelectDate(t,e,i){if(this.disabled)return;if(!this.isAllowedDate(t,e,i))return;const s=v(i,e,t),n=!!this.value&&this.value.getFullYear()===i&&this.value.getMonth()===e&&this.value.getDate()===t;n&&this.doubleClickUnselect?this.handleReset():(n||this.resetTimeUnits(),this.value=s)}resetTimeUnits(){this.tpHours=null,this.tpMinutes=null,this.tpSeconds=null,this.tpMilliseconds=null,this.tpEditingText=""}renderTimeFields(){const t=this.resolvedTimeFields;return e`
540
+ <div class=${l({"tp-time-fields":!0,"tp-time-fields--stacked":this.tpFewFieldsNoTz})} part="tp-time-fields">
541
+ ${t.hours?this.renderTimeField("Hours (24H)","HH",23,this.tpHours,(t=>{this.tpHours=t})):""}
542
+ ${t.minutes?this.renderTimeField("Minutes","MM",59,this.tpMinutes,(t=>{this.tpMinutes=t})):""}
543
+ ${t.seconds?this.renderTimeField("Seconds","SS",59,this.tpSeconds,(t=>{this.tpSeconds=t})):""}
544
+ ${t.milliseconds?this.renderTimeField("Milliseconds","MS",999,this.tpMilliseconds,(t=>{this.tpMilliseconds=t})):""}
545
+ </div>
546
+ `}renderTimeField(t,s,n,r,a){const l=String(n).length,o=t=>{t.stopPropagation();const e=t.target,{text:i,value:s}=(t=>{let e=(t||"").replace(/\D/g,"");for(;e.length>l&&"0"===e[0];)e=e.slice(1);if(e.length>l&&(e=e.slice(0,l)),""===e)return{text:"",value:null};const i=Number(e);if(i>n){const t=Number(e[0]);return{text:String(t).padStart(l,"0"),value:t}}return{text:e,value:i}})(e.value);a(s),this.tpEditingText=i,e.value!==i&&(e.value=i)},h=(e,i)=>{if(this.disabled)return;if(i){const t=i.closest("nile-input");t?.input&&t.focus()}const s=n+1,o=null===r?1===e?0:n:((r+e)%s+s)%s;a(o),this.tpFocusedTimeField=t,this.tpEditingText=String(o).padStart(l,"0")},d=this.tpFocusedTimeField===t?this.tpEditingText:null!==r||this.value?String(r??0).padStart(l,"0"):"";return e`
547
+ <nile-input
548
+ class="tp-time-field"
549
+ part="tp-time-field"
550
+ type="text"
551
+ inputmode="numeric"
552
+ label="${t}"
553
+ placeholder="${s}"
554
+ ?disabled="${this.disabled}"
555
+ value="${d}"
556
+ @nile-change="${o}"
557
+ @nile-input="${o}"
558
+ @keydown="${t=>{"ArrowUp"===t.key?(t.preventDefault(),h(1)):"ArrowDown"===t.key&&(t.preventDefault(),h(-1))}}"
559
+ @nile-focus="${e=>{e.stopPropagation(),this.tpFocusedTimeField=t,this.tpEditingText=""}}"
560
+ @nile-blur="${e=>{e.stopPropagation(),this.tpFocusedTimeField===t&&(this.tpFocusedTimeField=null)}}"
561
+ >
562
+ <div
563
+ slot="suffix"
564
+ class="tp-stepper"
565
+ part="tp-stepper"
566
+ @mousedown="${t=>t.preventDefault()}"
567
+ >
568
+ <div
569
+ class="tp-stepper-btn tp-stepper-btn--up"
570
+ part="tp-stepper-btn tp-stepper-btn-up"
571
+ role="button"
572
+ tabindex="${this.disabled?"-1":"0"}"
573
+ aria-label="Increase ${t}"
574
+ @click="${t=>h(1,t.currentTarget)}"
575
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||h(1,t.currentTarget)}}"
576
+ >
577
+ <nile-icon name="arrowdropdown" size="16" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":i}></nile-icon>
578
+ </div>
579
+ <div
580
+ class="tp-stepper-btn"
581
+ part="tp-stepper-btn tp-stepper-btn-down"
582
+ role="button"
583
+ tabindex="${this.disabled?"-1":"0"}"
584
+ aria-label="Decrease ${t}"
585
+ @click="${t=>h(-1,t.currentTarget)}"
586
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||h(-1,t.currentTarget)}}"
587
+ >
588
+ <nile-icon name="arrowdropdown" size="16" color=${this.disabled?"var(--nile-colors-dark-500, var(--ng-colors-fg-disabled))":i}></nile-icon>
589
+ </div>
590
+ </div>
591
+ </nile-input>
592
+ `}get timezoneOptions(){const t="function"==typeof Intl.supportedValuesOf?Intl.supportedValuesOf("timeZone"):b;return t.includes("UTC")?t:["UTC",...t]}renderTimezone(){return e`
593
+ <div class="tp-timezone" part="tp-timezone">
594
+ <div class="tp-timezone-header" part="tp-timezone-header">
595
+ <span class="tp-timezone-label" part="tp-timezone-label">Timezone</span>
596
+ <span
597
+ class="tp-timezone-local-link"
598
+ part="tp-timezone-local-link"
599
+ role="button"
600
+ tabindex="${this.disabled?"-1":"0"}"
601
+ @click="${this.handleUseLocalTimezone}"
602
+ @keydown="${t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleUseLocalTimezone())}}"
603
+ >Use local timezone</span>
604
+ </div>
605
+ <nile-select
606
+ class="tp-timezone-select"
607
+ part="tp-timezone-select"
608
+ hoist
609
+ placement="top"
610
+ ?disabled="${this.disabled}"
611
+ searchEnabled
612
+ placeholder="Select timezone"
613
+ .value="${this.timezone}"
614
+ @nile-change="${this.handleTimezoneChange}"
615
+ >
616
+ ${this.timezoneOptions.map((t=>e`<nile-option value="${t}">${t}</nile-option>`))}
617
+ </nile-select>
618
+ </div>
619
+ `}handleTimezoneChange(t){t.stopPropagation();const e=t.detail&&(t.detail.value??t.detail)||t.target?.value;"string"==typeof e&&e&&this.setTimezoneInternally(e)}handleUseLocalTimezone(){if(this.disabled)return;const t=Intl.DateTimeFormat().resolvedOptions().timeZone;t&&this.setTimezoneInternally(t)}toggleExpanded(){this.disabled||(this.expanded=!this.expanded)}composeLocalTimezoneValue(){return this.value?null===this.seedInstant||this.seedFieldsKey!==this.instantSeedFieldsKey()||null!==this.seedZone&&this.seedZone!==this.timezone?this.wallClockToInstant(this.value.getFullYear(),this.value.getMonth(),this.value.getDate(),this.tpHours??0,this.tpMinutes??0,this.tpSeconds??0,this.tpMilliseconds??0):new Date(this.seedInstant):null}composeValueISO(t){const e=this.timezone||"UTC",i=(t,e=2)=>String(t).padStart(e,"0"),s=(t%1e3+1e3)%1e3;let n,r,a,l,o,h,d;try{const i=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),c={};for(const e of i.formatToParts(new Date(t)))"literal"!==e.type&&(c[e.type]=Number(e.value));n=c.year,r=c.month,a=c.day,l=c.hour,o=c.minute,h=c.second,d=this.zoneOffsetMs(t-s)}catch{const e=new Date(t);n=e.getFullYear(),r=e.getMonth()+1,a=e.getDate(),l=e.getHours(),o=e.getMinutes(),h=e.getSeconds(),d=0}d=6e4*Math.round(d/6e4);const c=d>=0?"+":"-",u=Math.abs(d),p=`${c}${i(Math.floor(u/36e5))}:${i(Math.floor(u%36e5/6e4))}`;return`${i(n,4)}-${i(r)}-${i(a)}T${i(l)}:${i(o)}:${i(h)}.${i(s,3)}[GMT${p} ${e}]`}wallClockToInstant(t,e,i,s,n,r,a){const l=$(t,e,i,s,n,r,0);try{const t=this.zoneOffsetMs(l);let e=l-t;const i=this.zoneOffsetMs(e);return i!==t&&(e=l-i),new Date(e+a)}catch{const t=new Date(this.value.getTime());return t.setHours(s,n,r,a),t}}zoneOffsetMs(t){const e=new Intl.DateTimeFormat("en-US",{timeZone:this.timezone,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),i={};for(const s of e.formatToParts(new Date(t)))"literal"!==s.type&&(i[s.type]=Number(s.value));return $(i.year,i.month-1,i.day,i.hour,i.minute,i.second)-t}hasSelection(){return"relative"===this.type?Boolean(this.startDate&&this.endDate):Boolean(this.value)}handleSetToNow(){if(this.disabled)return;const t=new Date;this.tpHours=t.getHours(),this.tpMinutes=t.getMinutes(),this.tpSeconds=t.getSeconds(),this.tpMilliseconds=t.getMilliseconds(),this.value=new Date(t.getFullYear(),t.getMonth(),t.getDate()),this.currentMonth=t.getMonth(),this.currentYear=t.getFullYear();const e=Intl.DateTimeFormat().resolvedOptions().timeZone;e&&this.setTimezoneInternally(e)}handleApply(){if(this.disabled||!this.hasSelection())return;if("relative"===this.type)return void this.emitDateTimePickerChange({startDate:this.startDate,endDate:this.endDate,timezone:"UTC"});const t=this.composeLocalTimezoneValue(),e=t?t.getTime():null;this.emitDateTimePickerChange({value:null===e?null:this.composeValueISO(e),localTimezoneValue:t,unixEpoch:e,timezone:this.timezone})}handleReset(){this.disabled||(this.clearInstantSeed(),this.value=null,this.startDate=null,this.endDate=null,this.selectedUnit=void 0,this.selectedValue=void 0,this.resetTimeUnits(),this.setTimezoneInternally(this.configuredTimezone),this.requestUpdate(),this.emit("nile-clear"))}emitDateTimePickerChange(t){this.emit("nile-change",t)}};t([s({type:String,attribute:"value"})],S.prototype,"valueAttribute",void 0),t([s({type:String,attribute:!0,reflect:!0})],S.prototype,"allowedDates",void 0),t([s({type:Boolean,reflect:!0})],S.prototype,"range",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],S.prototype,"hideTypes",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],S.prototype,"showTypes",void 0),t([s({type:Boolean,reflect:!0})],S.prototype,"doubleClickUnselect",void 0),t([s({type:Boolean,reflect:!0})],S.prototype,"allowClear",void 0),t([s({type:String,reflect:!0})],S.prototype,"type",void 0),t([s({type:String})],S.prototype,"selectedUnit",void 0),t([s({type:Number})],S.prototype,"selectedValue",void 0),t([s({type:Array,attribute:"hide-duration-fields"})],S.prototype,"hideDurationFields",void 0),t([s({type:Boolean})],S.prototype,"showManualInputs",void 0),t([s({type:Number,attribute:!0,reflect:!0})],S.prototype,"startYear",void 0),t([s({type:Number,attribute:!0,reflect:!0})],S.prototype,"endYear",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],S.prototype,"showMonthDropdown",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],S.prototype,"showYearDropdown",void 0),t([s({type:String,reflect:!0,attribute:!0})],S.prototype,"dateFormat",void 0),t([s({type:Boolean,reflect:!0})],S.prototype,"structuredInput",void 0),t([n()],S.prototype,"startDate",void 0),t([n()],S.prototype,"endDate",void 0),t([n()],S.prototype,"isSelectingStart",void 0),t([n()],S.prototype,"hideInput",void 0),t([n()],S.prototype,"value",void 0),t([n()],S.prototype,"currentMonth",void 0),t([n()],S.prototype,"currentYear",void 0),t([n()],S.prototype,"allowedDatesLocal",void 0),t([s({type:Boolean,attribute:!0,reflect:!0})],S.prototype,"disabled",void 0),t([s({type:String,attribute:!0})],S.prototype,"variant",void 0),t([s({type:String,attribute:!0})],S.prototype,"timezone",void 0),t([s({type:Array,attribute:"hide-time-fields"})],S.prototype,"hideTimeFields",void 0),t([n()],S.prototype,"expanded",void 0),t([n()],S.prototype,"tpLockedHeight",void 0),t([n()],S.prototype,"tpHours",void 0),t([n()],S.prototype,"tpMinutes",void 0),t([n()],S.prototype,"tpSeconds",void 0),t([n()],S.prototype,"tpMilliseconds",void 0),t([n()],S.prototype,"tpFocusedTimeField",void 0),t([n()],S.prototype,"tpFocusDate",void 0),t([n()],S.prototype,"tpEditingText",void 0),t([o("allowedDates")],S.prototype,"checkValidAllowedDate",null),S=t([r("nile-calendar")],S);export{S as N,N as a,k as i,M as w};