@webority/ui-elements 0.186.0 → 0.187.0

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 (83) hide show
  1. package/dist/WuiNavigationMenu-BvYLbEmA.js +1 -0
  2. package/dist/WuiSelect-C1NNAsFQ.js +1 -0
  3. package/dist/{chips-DxSWAJDI.js → chips-DtDYq3XM.js} +1 -1
  4. package/dist/{country-T7AfpJpN.js → country-BySxiqti.js} +1 -1
  5. package/dist/elements/navigation-menu.js +1 -1
  6. package/dist/elements/select.js +1 -1
  7. package/dist/{recents-B9efQ1Au.js → recents-Da5C5_lV.js} +1 -1
  8. package/dist/search-BAgNDqG2.js +1 -0
  9. package/dist/search.g-chn0itlW.js +1 -0
  10. package/dist/text/en.json +3 -0
  11. package/dist/text.js +1 -1
  12. package/dist/ui-elements/calendar-views.global.js +1 -1
  13. package/dist/ui-elements/carousel.global.js +1 -1
  14. package/dist/ui-elements/code-block.global.js +1 -1
  15. package/dist/ui-elements/command-palette.global.js +1 -1
  16. package/dist/ui-elements/comment-thread.global.js +1 -1
  17. package/dist/ui-elements/consent-banner.global.js +1 -1
  18. package/dist/ui-elements/context-menu.global.js +1 -1
  19. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  20. package/dist/ui-elements/data-table.global.js +1 -1
  21. package/dist/ui-elements/date-range.global.js +1 -1
  22. package/dist/ui-elements/date-time.global.js +1 -1
  23. package/dist/ui-elements/datepicker.global.js +1 -1
  24. package/dist/ui-elements/dock.global.js +1 -1
  25. package/dist/ui-elements/drawer.global.js +1 -1
  26. package/dist/ui-elements/dropdown.global.js +1 -1
  27. package/dist/ui-elements/entry-grid.global.js +1 -1
  28. package/dist/ui-elements/gantt.global.js +1 -1
  29. package/dist/ui-elements/glyphs.global.js +1 -1
  30. package/dist/ui-elements/hover-card.global.js +1 -1
  31. package/dist/ui-elements/image-crop.global.js +1 -1
  32. package/dist/ui-elements/inline-edit.global.js +1 -1
  33. package/dist/ui-elements/kanban.global.js +1 -1
  34. package/dist/ui-elements/lead-popup.global.js +1 -1
  35. package/dist/ui-elements/lightbox.global.js +1 -1
  36. package/dist/ui-elements/markdown.global.js +1 -1
  37. package/dist/ui-elements/mini-calendar.global.js +1 -1
  38. package/dist/ui-elements/navigation-menu.global.js +1 -1
  39. package/dist/ui-elements/notification-center.global.js +1 -1
  40. package/dist/ui-elements/offline-banner.global.js +1 -1
  41. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  42. package/dist/ui-elements/org-tree.global.js +1 -1
  43. package/dist/ui-elements/otp.global.js +1 -1
  44. package/dist/ui-elements/overflow.global.js +1 -1
  45. package/dist/ui-elements/phone.global.js +1 -1
  46. package/dist/ui-elements/popover.global.js +1 -1
  47. package/dist/ui-elements/rating.global.js +1 -1
  48. package/dist/ui-elements/record-pager.global.js +1 -1
  49. package/dist/ui-elements/relative-time.global.js +1 -1
  50. package/dist/ui-elements/saved-views.global.js +1 -1
  51. package/dist/ui-elements/select-chips.global.js +1 -1
  52. package/dist/ui-elements/select-recents.global.js +1 -1
  53. package/dist/ui-elements/select-search.global.js +1 -1
  54. package/dist/ui-elements/select-window.global.js +1 -1
  55. package/dist/ui-elements/server.global.js +1 -1
  56. package/dist/ui-elements/shell.global.js +1 -1
  57. package/dist/ui-elements/shortcuts.global.js +1 -1
  58. package/dist/ui-elements/show-more.global.js +1 -1
  59. package/dist/ui-elements/slider.global.js +1 -1
  60. package/dist/ui-elements/sortable.global.js +1 -1
  61. package/dist/ui-elements/status-icon.global.js +1 -1
  62. package/dist/ui-elements/table-export.global.js +1 -1
  63. package/dist/ui-elements/timepicker.global.js +1 -1
  64. package/dist/ui-elements/tour.global.js +1 -1
  65. package/dist/ui-elements/tree-picker.global.js +1 -1
  66. package/dist/ui-elements/tree.global.js +1 -1
  67. package/dist/ui-elements/truncate.global.js +1 -1
  68. package/dist/ui-elements/whats-new.global.js +1 -1
  69. package/dist/ui-elements/wizard.global.js +1 -1
  70. package/dist/ui-elements.global.js +1 -1
  71. package/dist/ui-elements.js +1 -1
  72. package/package.json +5 -5
  73. package/types/WuiNavigationMenu.d.ts +9 -1
  74. package/types/WuiSelect.d.ts +9 -9
  75. package/types/select/list.d.ts +5 -2
  76. package/types/select/part.d.ts +17 -5
  77. package/types/select/search.d.ts +1 -1
  78. package/types/text/web/filePicker.g.d.ts +2 -0
  79. package/types/text/web/select.g.d.ts +1 -0
  80. package/dist/WuiNavigationMenu-KdW7yuLn.js +0 -1
  81. package/dist/WuiSelect-B0CT2utp.js +0 -1
  82. package/dist/search-DLRWJomU.js +0 -1
  83. package/dist/search.g-B5d1s59A.js +0 -1
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.186.0`)throw Error(`[webority-ui] datepicker expects ui-elements 0.186.0 but the page loaded `+p+`.`);function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=()=>(0,d.readText)(`datePicker`,f.DATE_PICKER_TEXT),y=e=>e-(e%10+10)%10-1,b=class extends i.ElementBase{static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}get _open(){return(0,r.must)(this._openFn,`open missing`)}get _close(){return(0,r.must)(this._closeFn,`close missing`)}constructor(){super(),_(this,`_internals`,void 0),_(this,`_value`,void 0),_(this,`_defaultValue`,void 0),_(this,`_rendered`,void 0),_(this,`_viewY`,void 0),_(this,`_viewM`,void 0),_(this,`_mode`,void 0),_(this,`_focus`,void 0),_(this,`_gridFocus`,void 0),_(this,`_slide`,void 0),_(this,`_viewNavigated`,void 0),_(this,`_openFn`,void 0),_(this,`_closeFn`,void 0),_(this,`_onKeyBound`,void 0),_(this,`_closingQuietly`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(0,l.isPopoverOpen)(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,(0,s.syncFormMirror)(this,this._value),this._syncTrigger()}_firstDay(){return(0,n.firstWeekday)(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=(0,n.parseIsoYear)(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return(0,n.parseIso)(e);let t=(0,n.parseIsoMonth)(this._monthKey(e));return t?{y:t.y,m:t.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?v().yearPlaceholder:this._monthOnly()?v().monthPlaceholder:v().placeholder)}_label(e){let t=this.getAttribute(`display-format`);return this._yearOnly()?(0,n.fmtYear)(e,t):this._monthOnly()?(0,n.fmtMonth)(this._monthKey(e)||``,t):(0,n.fmt)(e,t)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),i=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,o=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`);this.replaceChildren((0,r.make)(`div`,{class:`datepicker`},(0,r.make)(`button`,{type:`button`,class:`input datepicker-trigger${i}${t?` has-value`:``}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":o,"aria-describedby":l},(0,r.make)(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),(0,c.glyphNode)(`calendar-dots`)),(0,r.make)(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`.datepicker-trigger`)),(0,s.syncFormMirror)(this,this._value),this._wire()}_syncFormValue(){(0,s.syncFormMirror)(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`)),(0,a.syncFieldState)(this,e)}_limits(){if(this._yearOnly()){let e=(0,n.parseIsoYear)(this.getAttribute(`min`)),t=(0,n.parseIsoYear)(this.getAttribute(`max`)),r=e?e.y:-1/0,i=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<r||e>i}}if(this._monthOnly()){let e=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`min`))),t=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=t?t.y*12+t.m:1/0,a=e?e.y:-1/0,o=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=(0,n.parseIso)(this.getAttribute(`min`)),t=(0,n.parseIso)(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0,a=new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&a.add(Number(t))}return{dayDisabled:(e,t,n)=>{let o=new Date(e,t,n),s=o.getTime();return s<r||s>i||a.has(o.getDay())},monthDisabled:(e,t)=>{let a=new Date(e,t,1).getTime();return new Date(e,t,(0,n.daysIn)(e,t)).getTime()<r||a>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{(0,l.closeAnchoredPopover)(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,i=(0,n.daysIn)(this._viewY,this._viewM),s=(0,n.parseIso)(this._value),l=new Date,{dayDisabled:u}=this._limits(),d=this._focus||s||{y:this._viewY,m:this._viewM,d:1},f=(e,t,i,a)=>{let o=(0,n.toIso)(e,t,i),c=s&&s.y===e&&s.m===t&&s.d===i,f=l.getFullYear()===e&&l.getMonth()===t&&l.getDate()===i,p=d.y===e&&d.m===t&&d.d===i,m=u(e,t,i),h=[`datepicker-day`,a?`is-outside`:``,f?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);return(0,r.make)(`button`,{type:`button`,class:h,"data-iso":o,role:`gridcell`,tabindex:p&&!m?`0`:`-1`,"aria-selected":c?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},i)},p=[],m=(0,n.clampMonth)(this._viewY,this._viewM-1),h=(0,n.daysIn)(m.y,m.m);for(let e=t-1;e>=0;e--)p.push(f(m.y,m.m,h-e,!0));for(let e=1;e<=i;e++)p.push(f(this._viewY,this._viewM,e,!1));let g=(0,n.clampMonth)(this._viewY,this._viewM+1),_=(7-(t+i)%7)%7;for(let e=1;e<=_;e++)p.push(f(g.y,g.m,e,!0));let y=u(l.getFullYear(),l.getMonth(),l.getDate()),b=(0,a.isInert)(this)?null:(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},v().clearLabel),x=Array.from({length:7},(t,n)=>(0,r.make)(`span`,null,(0,o.weekdayLabel)((n+e)%7,`min`)));return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":v().previousMonth},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":v().chooseMonthYearLabel},`${(0,o.monthLongLabel)(this._viewM)} ${this._viewY}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":v().nextMonth},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-weekdays`},...x),(0,r.make)(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...p),(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:y?!0:void 0},v().todayLabel),b)]}_clearFoot(e){return!e||(0,a.isInert)(this)?[]:[(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},v().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=new Date,{monthDisabled:n}=this._limits(),i=[];for(let a=0;a<12;a++){let s=e&&e.y===this._viewY&&e.m===a,c=t.getFullYear()===this._viewY&&t.getMonth()===a,l=n(this._viewY,a),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push((0,r.make)(`button`,{type:`button`,class:u,"data-month":a,tabindex:this._monthOnly()?this._viewY*12+a===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},(0,o.monthLabel)(a)))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":v().previousYearLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":v().chooseYearLabel},this._viewY),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":v().nextYearLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),i=y(this._viewY),a=[];for(let o=0;o<12;o++){let s=i+o,c=e&&e.y===s,l=t===s,u=n(s),d=[`datepicker-cell`,l?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);a.push((0,r.make)(`button`,{type:`button`,class:d,"data-year":s,tabindex:this._yearOnly()?s===this._gridFocus&&!u?0:-1:void 0,disabled:u?!0:void 0},s))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":v().previousDecadeLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`span`,{class:`datepicker-month`},`${i+1} to ${i+10}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":v().nextDecadeLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...a),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored((0,n.toIsoMonth)(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:y,unit:e=>e,cell:e=>e,disabled:e,iso:n.toIsoYear}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,r,i){let{y:a,m:o}=(0,n.clampMonth)(e,t);this._focus={y:a,m:o,d:r};let s=a!==this._viewY||o!==this._viewM;this._viewY=a,this._viewM=o,this._slide=s&&i||``,this._renderView(),this._slide=``;let c=this.querySelector(`.datepicker-day[data-iso="${(0,n.toIso)(a,o,r)}"]`);c instanceof HTMLButtonElement&&c.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let r=this._focus||(0,n.parseIso)(this._value)||{y:this._viewY,m:this._viewM,d:1},i=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},a=(t,n,a=t<0?-1:1)=>{e.preventDefault(),i(r.y,r.m,r.d+t,a,n)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1,`slide-prev`);break;case`ArrowRight`:a(1,`slide-next`);break;case`ArrowUp`:a(-7,`slide-prev`);break;case`ArrowDown`:a(7,`slide-next`);break;case`Home`:a(-((new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:a(6-(new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m-(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m+(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(r.y,r.m,r.d)||(this.value=(0,n.toIso)(r.y,r.m,r.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),r=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,l.isPopoverOpen)(t),o=()=>{r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if((0,a.isInert)(this))return;let n=new Date,s=this._parts(this._value),c=this._gridKind();if(c)this._viewY=s?s.y:n.getFullYear(),this._mode=c.view,this._focus=null,this._gridFocus=this._gridFocusCell(c);else{(s||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=s&&s.y===this._viewY&&s.m===this._viewM;if(this._focus=t?s:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),(0,l.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!i())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let u=t.querySelector(`[tabindex="0"]`);u instanceof HTMLElement&&u.focus()},this._closeFn=()=>{(0,l.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>i()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(r.dataset.nav)<0?`slide-prev`:`slide-next`;let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let i=t.closest(`[data-nav-year]`);if(i instanceof HTMLElement){this._viewY+=Number(i.dataset.navYear),this._syncGridFocus(),this._renderView();return}let a=t.closest(`[data-nav-decade]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-view]`);if(o instanceof HTMLElement){this._mode=o.dataset.view,this._renderView();return}let s=t.closest(`[data-month]`);if(s instanceof HTMLButtonElement&&!s.disabled){if(this._monthOnly()){this.value=this._monthStored((0,n.toIsoMonth)(this._viewY,Number(s.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(s.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let c=t.closest(`[data-year]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._yearOnly()){this.value=(0,n.toIsoYear)(Number(c.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(c.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=(0,n.toIso)(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let l=t.closest(`.datepicker-day[data-iso]`);l instanceof HTMLButtonElement&&!l.disabled&&(this.value=l.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{i()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};_(b,`formAssociated`,!0),(0,t.defineElement)(`wui-datepicker`,b),e.WuiDatePicker=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.187.0`)throw Error(`[webority-ui] datepicker expects ui-elements 0.187.0 but the page loaded `+p+`.`);function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=()=>(0,d.readText)(`datePicker`,f.DATE_PICKER_TEXT),y=e=>e-(e%10+10)%10-1,b=class extends i.ElementBase{static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`disabled-weekdays`,`display-format`,`mode`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}get _open(){return(0,r.must)(this._openFn,`open missing`)}get _close(){return(0,r.must)(this._closeFn,`close missing`)}constructor(){super(),_(this,`_internals`,void 0),_(this,`_value`,void 0),_(this,`_defaultValue`,void 0),_(this,`_rendered`,void 0),_(this,`_viewY`,void 0),_(this,`_viewM`,void 0),_(this,`_mode`,void 0),_(this,`_focus`,void 0),_(this,`_gridFocus`,void 0),_(this,`_slide`,void 0),_(this,`_viewNavigated`,void 0),_(this,`_openFn`,void 0),_(this,`_closeFn`,void 0),_(this,`_onKeyBound`,void 0),_(this,`_closingQuietly`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._gridFocus=null,this._slide=``}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`)this._syncInvalid();else if(this._rendered){if(e===`value`)this._value=n||``,this._syncFormValue(),this._syncTrigger();else if(e===`display-format`)this._syncTrigger();else if(e===`first-day`){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(0,l.isPopoverOpen)(e)&&this._renderView()}else this.render()}}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e instanceof HTMLButtonElement&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,(0,s.syncFormMirror)(this,this._value),this._syncTrigger()}_firstDay(){return(0,n.firstWeekday)(this)}_monthOnly(){return this.getAttribute(`mode`)===`month`}_yearOnly(){return this.getAttribute(`mode`)===`year`}_monthKey(e){return e&&this.hasAttribute(`value-as-date`)?e.slice(0,7):e}_monthStored(e){return this.hasAttribute(`value-as-date`)?`${e}-01`:e}_parts(e){if(this._yearOnly()){let t=(0,n.parseIsoYear)(e);return t?{y:t.y,m:0,d:1}:null}if(!this._monthOnly())return(0,n.parseIso)(e);let t=(0,n.parseIsoMonth)(this._monthKey(e));return t?{y:t.y,m:t.m,d:1}:null}_placeholder(){return this.getAttribute(`placeholder`)||(this._yearOnly()?v().yearPlaceholder:this._monthOnly()?v().monthPlaceholder:v().placeholder)}_label(e){let t=this.getAttribute(`display-format`);return this._yearOnly()?(0,n.fmtYear)(e,t):this._monthOnly()?(0,n.fmtMonth)(this._monthKey(e)||``,t):(0,n.fmt)(e,t)}render(){this._dropPanel(),this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this._placeholder(),t=this._parts(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),i=n===`sm`?` wui-input-sm`:n===`lg`?` wui-input-lg`:n===`xl`?` wui-input-xl`:``,o=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`);this.replaceChildren((0,r.make)(`div`,{class:`datepicker`},(0,r.make)(`button`,{type:`button`,class:`input datepicker-trigger${i}${t?` has-value`:``}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)?!0:void 0,"aria-label":o,"aria-describedby":l},(0,r.make)(`span`,{"data-trigger-label":!0,class:t?``:`wui-select-placeholder`},t?this._label(this._value):e),(0,c.glyphNode)(`calendar-dots`)),(0,r.make)(`div`,{class:`datepicker-pop`,role:`dialog`,popover:`auto`}))),this._rendered=!0,(0,a.syncFieldState)(this,this.querySelector(`.datepicker-trigger`)),(0,s.syncFormMirror)(this,this._value),this._wire()}_syncFormValue(){(0,s.syncFormMirror)(this,this._value)}_syncTrigger(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`[data-trigger-label]`);if(!(t instanceof HTMLSpanElement))return;let n=this._parts(this._value);t.textContent=n?this._label(this._value):this._placeholder(),t.classList.toggle(`wui-select-placeholder`,!n),e?.classList.toggle(`has-value`,!!n),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`)),(0,a.syncFieldState)(this,e)}_limits(){if(this._yearOnly()){let e=(0,n.parseIsoYear)(this.getAttribute(`min`)),t=(0,n.parseIsoYear)(this.getAttribute(`max`)),r=e?e.y:-1/0,i=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:()=>!0,yearDisabled:e=>e<r||e>i}}if(this._monthOnly()){let e=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`min`))),t=(0,n.parseIsoMonth)(this._monthKey(this.getAttribute(`max`))),r=e?e.y*12+e.m:-1/0,i=t?t.y*12+t.m:1/0,a=e?e.y:-1/0,o=t?t.y:1/0;return{dayDisabled:()=>!0,monthDisabled:(e,t)=>{let n=e*12+t;return n<r||n>i},yearDisabled:e=>e<a||e>o}}let e=(0,n.parseIso)(this.getAttribute(`min`)),t=(0,n.parseIso)(this.getAttribute(`max`)),r=e?new Date(e.y,e.m,e.d).getTime():-1/0,i=t?new Date(t.y,t.m,t.d).getTime():1/0,a=new Set;for(let e of(this.getAttribute(`disabled-weekdays`)||``).split(`,`)){let t=e.trim();/^[0-6]$/.test(t)&&a.add(Number(t))}return{dayDisabled:(e,t,n)=>{let o=new Date(e,t,n),s=o.getTime();return s<r||s>i||a.has(o.getDay())},monthDisabled:(e,t)=>{let a=new Date(e,t,1).getTime();return new Date(e,t,(0,n.daysIn)(e,t)).getTime()<r||a>i},yearDisabled:e=>{let t=new Date(e,0,1).getTime();return new Date(e,11,31).getTime()<r||t>i}}}_dropPanel(){let e=this.querySelector(`.datepicker-pop`);if(e instanceof HTMLDivElement){this._closingQuietly=!0;try{(0,l.closeAnchoredPopover)(e)}finally{this._closingQuietly=!1}}}_renderView(){let e=this.querySelector(`.datepicker-pop`);e instanceof HTMLDivElement&&(this._mode===`months`?e.replaceChildren(...this._monthsNodes()):this._mode===`years`?e.replaceChildren(...this._yearsNodes()):e.replaceChildren(...this._daysNodes()),this._focusActive())}_daysNodes(){let e=this._firstDay(),t=(new Date(this._viewY,this._viewM,1).getDay()-e+7)%7,i=(0,n.daysIn)(this._viewY,this._viewM),s=(0,n.parseIso)(this._value),l=new Date,{dayDisabled:u}=this._limits(),d=this._focus||s||{y:this._viewY,m:this._viewM,d:1},f=(e,t,i,a)=>{let o=(0,n.toIso)(e,t,i),c=s&&s.y===e&&s.m===t&&s.d===i,f=l.getFullYear()===e&&l.getMonth()===t&&l.getDate()===i,p=d.y===e&&d.m===t&&d.d===i,m=u(e,t,i),h=[`datepicker-day`,a?`is-outside`:``,f?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);return(0,r.make)(`button`,{type:`button`,class:h,"data-iso":o,role:`gridcell`,tabindex:p&&!m?`0`:`-1`,"aria-selected":c?`true`:void 0,disabled:m?!0:void 0,"aria-disabled":m?`true`:void 0},i)},p=[],m=(0,n.clampMonth)(this._viewY,this._viewM-1),h=(0,n.daysIn)(m.y,m.m);for(let e=t-1;e>=0;e--)p.push(f(m.y,m.m,h-e,!0));for(let e=1;e<=i;e++)p.push(f(this._viewY,this._viewM,e,!1));let g=(0,n.clampMonth)(this._viewY,this._viewM+1),_=(7-(t+i)%7)%7;for(let e=1;e<=_;e++)p.push(f(g.y,g.m,e,!0));let y=u(l.getFullYear(),l.getMonth(),l.getDate()),b=(0,a.isInert)(this)?null:(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},v().clearLabel),x=Array.from({length:7},(t,n)=>(0,r.make)(`span`,null,(0,o.weekdayLabel)((n+e)%7,`min`)));return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`-1`,"aria-label":v().previousMonth},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`months`,"aria-label":v().chooseMonthYearLabel},`${(0,o.monthLongLabel)(this._viewM)} ${this._viewY}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":`1`,"aria-label":v().nextMonth},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-weekdays`},...x),(0,r.make)(`div`,{class:`datepicker-grid${this._slide?` ${this._slide}`:``}`,role:`grid`},...p),(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-today":!0,disabled:y?!0:void 0},v().todayLabel),b)]}_clearFoot(e){return!e||(0,a.isInert)(this)?[]:[(0,r.make)(`div`,{class:`datepicker-foot`},(0,r.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},v().clearLabel))]}_monthsNodes(){let e=this._parts(this._value),t=new Date,{monthDisabled:n}=this._limits(),i=[];for(let a=0;a<12;a++){let s=e&&e.y===this._viewY&&e.m===a,c=t.getFullYear()===this._viewY&&t.getMonth()===a,l=n(this._viewY,a),u=[`datepicker-cell`,c?`is-today`:``,s?`is-selected`:``].filter(Boolean).join(` `);i.push((0,r.make)(`button`,{type:`button`,class:u,"data-month":a,tabindex:this._monthOnly()?this._viewY*12+a===this._gridFocus&&!l?0:-1:void 0,disabled:l?!0:void 0},(0,o.monthLabel)(a)))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`-1`,"aria-label":v().previousYearLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`button`,{type:`button`,class:`datepicker-month`,"data-view":`years`,"aria-label":v().chooseYearLabel},this._viewY),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-year":`1`,"aria-label":v().nextYearLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...i),...this._clearFoot(this._monthOnly())]}_yearsNodes(){let e=this._parts(this._value),t=new Date().getFullYear(),{yearDisabled:n}=this._limits(),i=y(this._viewY),a=[];for(let o=0;o<12;o++){let s=i+o,c=e&&e.y===s,l=t===s,u=n(s),d=[`datepicker-cell`,l?`is-today`:``,c?`is-selected`:``].filter(Boolean).join(` `);a.push((0,r.make)(`button`,{type:`button`,class:d,"data-year":s,tabindex:this._yearOnly()?s===this._gridFocus&&!u?0:-1:void 0,disabled:u?!0:void 0},s))}return[(0,r.make)(`div`,{class:`datepicker-head`},(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`-1`,"aria-label":v().previousDecadeLabel},(0,c.glyphNode)(`chevron-left`)),(0,r.make)(`span`,{class:`datepicker-month`},`${i+1} to ${i+10}`),(0,r.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav-decade":`1`,"aria-label":v().nextDecadeLabel},(0,c.glyphNode)(`chevron-right`))),(0,r.make)(`div`,{class:`datepicker-cells`},...a),...this._clearFoot(this._yearOnly())]}_gridKind(){if(this._monthOnly()){let{monthDisabled:e}=this._limits(),t=e=>e-Math.floor(e/12)*12;return{view:`months`,attr:`month`,per:12,page:12,lo:e=>e*12,unit:(e,t)=>e*12+t,cell:t,disabled:n=>e(Math.floor(n/12),t(n)),iso:e=>this._monthStored((0,n.toIsoMonth)(Math.floor(e/12),t(e)))}}if(this._yearOnly()){let{yearDisabled:e}=this._limits();return{view:`years`,attr:`year`,per:1,page:10,lo:y,unit:e=>e,cell:e=>e,disabled:e,iso:n.toIsoYear}}return null}_gridFocusCell(e){let t=e.lo(this._viewY),n=e=>e!==null&&e>=t&&e<t+12,r=this._parts(this._value),i=new Date,a=[r?e.unit(r.y,r.m):null,e.unit(i.getFullYear(),i.getMonth())];for(let t of a)if(n(t)&&!e.disabled(t))return t;for(let n=t;n<t+12;n++)if(!e.disabled(n))return n;return null}_syncGridFocus(){let e=this._gridKind();e&&(this._gridFocus=this._gridFocusCell(e))}_focusActive(){let e=this.querySelector(`.datepicker-pop`);if(!(e instanceof HTMLDivElement))return;let t=e.querySelector(`[tabindex="0"]`)||e.querySelector(`.is-selected`)||e.querySelector(`.datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)`);t instanceof HTMLElement&&e.contains(document.activeElement)&&t.focus()}_setFocus(e,t,r,i){let{y:a,m:o}=(0,n.clampMonth)(e,t);this._focus={y:a,m:o,d:r};let s=a!==this._viewY||o!==this._viewM;this._viewY=a,this._viewM=o,this._slide=s&&i||``,this._renderView(),this._slide=``;let c=this.querySelector(`.datepicker-day[data-iso="${(0,n.toIso)(a,o,r)}"]`);c instanceof HTMLButtonElement&&c.focus()}_seek(e,t,n,r){let{dayDisabled:i}=this._limits(),a=new Date(e,t,n);for(let e=0;e<400;e++,a.setDate(a.getDate()+r))if(!i(a.getFullYear(),a.getMonth(),a.getDate()))return new Date(a);return null}_onGridKey(e,t){let n=(e,n)=>{for(let r=0;r<100*t.per;r++,e+=n)if(!t.disabled(e))return e;return null},r=(e,t)=>{let r=n(t>0?e:e+11,t);return r!==null&&r>=e&&r<e+12?r:null},i=e=>{this._viewY=Math.floor(e/t.per),this._gridFocus=e,this._renderView();let n=this.querySelector(`.datepicker-cell[data-${t.attr}="${t.cell(e)}"]`);n instanceof HTMLButtonElement&&n.focus()},a=r=>{e.preventDefault();let a=t.lo(this._viewY),o=n((this._gridFocus??(r<0?a+12:a-1))+r,r<0?-1:1);o!==null&&i(o)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1);break;case`ArrowRight`:a(1);break;case`ArrowUp`:a(-3);break;case`ArrowDown`:a(3);break;case`Home`:{e.preventDefault();let n=r(t.lo(this._viewY),1);n!==null&&i(n);break}case`End`:{e.preventDefault();let n=r(t.lo(this._viewY),-1);n!==null&&i(n);break}case`PageUp`:case`PageDown`:{e.preventDefault();let n=(this._gridFocus??t.lo(this._viewY))+(e.key===`PageUp`?-1:1)*t.page,a=t.disabled(n)?r(t.lo(Math.floor(n/t.per)),1):n;a!==null&&i(a);break}case`Enter`:case` `:{e.preventDefault();let n=this._gridFocus;n!==null&&!t.disabled(n)&&(this.value=t.iso(n),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());break}}}_onKey(e){let t=this._gridKind();if(t&&this._mode===t.view){this._onGridKey(e,t);return}if(this._mode!==`days`)return;let r=this._focus||(0,n.parseIso)(this._value)||{y:this._viewY,m:this._viewM,d:1},i=(e,t,n,r,i)=>{let a=this._seek(e,t,n,r);a&&this._setFocus(a.getFullYear(),a.getMonth(),a.getDate(),i)},a=(t,n,a=t<0?-1:1)=>{e.preventDefault(),i(r.y,r.m,r.d+t,a,n)};switch((0,u.mirrorKey)(e.key,(0,u.isRtl)(this))){case`ArrowLeft`:a(-1,`slide-prev`);break;case`ArrowRight`:a(1,`slide-next`);break;case`ArrowUp`:a(-7,`slide-prev`);break;case`ArrowDown`:a(7,`slide-next`);break;case`Home`:a(-((new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7),`slide-prev`,1);break;case`End`:a(6-(new Date(r.y,r.m,r.d).getDay()-this._firstDay()+7)%7,`slide-next`,-1);break;case`PageUp`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m-(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),-1,`slide-prev`);break}case`PageDown`:{e.preventDefault();let t=(0,n.clampMonth)(r.y,r.m+(e.shiftKey?12:1));i(t.y,t.m,Math.min(r.d,(0,n.daysIn)(t.y,t.m)),1,`slide-next`);break}case`Enter`:case` `:e.preventDefault(),this._limits().dayDisabled(r.y,r.m,r.d)||(this.value=(0,n.toIso)(r.y,r.m,r.d),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close());return}}_wire(){let e=this.querySelector(`.datepicker-trigger`),t=this.querySelector(`.datepicker-pop`),r=this.querySelector(`.datepicker`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,l.isPopoverOpen)(t),o=()=>{r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this._closingQuietly||e.focus()};this._openFn=()=>{if((0,a.isInert)(this))return;let n=new Date,s=this._parts(this._value),c=this._gridKind();if(c)this._viewY=s?s.y:n.getFullYear(),this._mode=c.view,this._focus=null,this._gridFocus=this._gridFocusCell(c);else{(s||!this._viewNavigated)&&(this._viewY=n.getFullYear(),this._viewM=n.getMonth()),this._mode=`days`;let e=n.getFullYear()===this._viewY&&n.getMonth()===this._viewM,t=s&&s.y===this._viewY&&s.m===this._viewM;if(this._focus=t?s:{y:this._viewY,m:this._viewM,d:e?n.getDate():1},this._limits().dayDisabled(this._focus.y,this._focus.m,this._focus.d)){let e=this._focus,t=[1,-1].map(t=>this._seek(e.y,e.m,e.d,t)).find(t=>t&&t.getMonth()===e.m);t&&(this._focus={y:t.getFullYear(),m:t.getMonth(),d:t.getDate()})}}if(this._renderView(),(0,l.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:o}),!i())return;r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`);let u=t.querySelector(`[tabindex="0"]`);u instanceof HTMLElement&&u.focus()},this._closeFn=()=>{(0,l.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>i()?this._close():this._open()),t.addEventListener(`click`,e=>{let t=e.target;if(!(t instanceof Element))throw Error(`click target is not an element`);let r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){this._viewNavigated=!0,this._slide=Number(r.dataset.nav)<0?`slide-prev`:`slide-next`;let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._focus={y:e.y,m:e.m,d:1},this._renderView(),this._slide=``;return}let i=t.closest(`[data-nav-year]`);if(i instanceof HTMLElement){this._viewY+=Number(i.dataset.navYear),this._syncGridFocus(),this._renderView();return}let a=t.closest(`[data-nav-decade]`);if(a instanceof HTMLElement){this._viewY+=Number(a.dataset.navDecade)*10,this._syncGridFocus(),this._renderView();return}let o=t.closest(`[data-view]`);if(o instanceof HTMLElement){this._mode=o.dataset.view,this._renderView();return}let s=t.closest(`[data-month]`);if(s instanceof HTMLButtonElement&&!s.disabled){if(this._monthOnly()){this.value=this._monthStored((0,n.toIsoMonth)(this._viewY,Number(s.dataset.month))),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewM=Number(s.dataset.month),this._mode=`days`,this._focus={y:this._viewY,m:this._viewM,d:1},this._renderView();return}let c=t.closest(`[data-year]`);if(c instanceof HTMLButtonElement&&!c.disabled){if(this._yearOnly()){this.value=(0,n.toIsoYear)(Number(c.dataset.year)),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}this._viewNavigated=!0,this._viewY=Number(c.dataset.year),this._mode=`months`,this._syncGridFocus(),this._renderView();return}if(t.closest(`[data-today]`)){let e=new Date;if(this._limits().dayDisabled(e.getFullYear(),e.getMonth(),e.getDate()))return;this.value=(0,n.toIso)(e.getFullYear(),e.getMonth(),e.getDate()),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}if(t.closest(`[data-clear]`)){this.value=``,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close();return}let l=t.closest(`.datepicker-day[data-iso]`);l instanceof HTMLButtonElement&&!l.disabled&&(this.value=l.dataset.iso,this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}),this._onKeyBound=e=>{i()&&this._onKey(e)},t.addEventListener(`keydown`,this._onKeyBound),this._syncFormValue()}};_(b,`formAssociated`,!0),(0,t.defineElement)(`wui-datepicker`,b),e.WuiDatePicker=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText);
@@ -1 +1 @@
1
- (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.186.0`)throw Error(`[webority-ui] dock expects ui-elements 0.186.0 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class extends r.ElementBase{static get observedAttributes(){return[`static`,`max-scale`,`radius`]}constructor(){super(),c(this,`_pointerMoveListener`,void 0),c(this,`_pointerLeaveListener`,void 0),c(this,`_frame`,void 0),c(this,`_pointerX`,void 0),this._pointerMoveListener=null,this._pointerLeaveListener=null,this._frame=0,this._pointerX=0}connectedCallback(){this._wire()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){e===`static`&&this.isConnected&&this._wire()}_maxScale(){return d(this.getAttribute(`max-scale`),1.6)}_radius(){return d(this.getAttribute(`radius`),100)}_magnifyEnabled(){return!(this.hasAttribute(`static`)||typeof matchMedia==`function`&&(matchMedia(`(pointer: coarse)`).matches||matchMedia(`(prefers-reduced-motion: reduce)`).matches))}_applyMagnification(){this._frame=0;let e=this._maxScale(),t=this._radius();for(let n of this.querySelectorAll(`.dock-item`)){let r=u(n),i=r.getBoundingClientRect(),a=Math.abs(this._pointerX-(i.left+i.width/2)),o=Math.max(0,1-a/t),s=1+(e-1)*o;r.style.setProperty(`--wui-dock-mag`,s.toFixed(3))}}_resetMagnification(){this._frame&&=(cancelAnimationFrame(this._frame),0);for(let e of this.querySelectorAll(`.dock-item`))u(e).style.removeProperty(`--wui-dock-mag`)}_wire(){this._teardown(),this._magnifyEnabled()&&(this._pointerMoveListener=e=>{this._pointerX=e.clientX,this._frame||=requestAnimationFrame(()=>this._applyMagnification())},this._pointerLeaveListener=()=>this._resetMagnification(),this.addEventListener(`pointermove`,this._pointerMoveListener),this.addEventListener(`pointerleave`,this._pointerLeaveListener))}_teardown(){this._pointerMoveListener&&=(this.removeEventListener(`pointermove`,this._pointerMoveListener),null),this._pointerLeaveListener&&=(this.removeEventListener(`pointerleave`,this._pointerLeaveListener),null),this._resetMagnification()}},u=e=>(0,n.elementOf)(e,HTMLElement,`wui-dock item must be an HTML element`),d=(e,t)=>{let n=Number.parseFloat(e??``);return Number.isFinite(n)?n:t};(0,t.defineElement)(`wui-dock`,l),e.WuiDock=l})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
1
+ (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.187.0`)throw Error(`[webority-ui] dock expects ui-elements 0.187.0 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class extends r.ElementBase{static get observedAttributes(){return[`static`,`max-scale`,`radius`]}constructor(){super(),c(this,`_pointerMoveListener`,void 0),c(this,`_pointerLeaveListener`,void 0),c(this,`_frame`,void 0),c(this,`_pointerX`,void 0),this._pointerMoveListener=null,this._pointerLeaveListener=null,this._frame=0,this._pointerX=0}connectedCallback(){this._wire()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){e===`static`&&this.isConnected&&this._wire()}_maxScale(){return d(this.getAttribute(`max-scale`),1.6)}_radius(){return d(this.getAttribute(`radius`),100)}_magnifyEnabled(){return!(this.hasAttribute(`static`)||typeof matchMedia==`function`&&(matchMedia(`(pointer: coarse)`).matches||matchMedia(`(prefers-reduced-motion: reduce)`).matches))}_applyMagnification(){this._frame=0;let e=this._maxScale(),t=this._radius();for(let n of this.querySelectorAll(`.dock-item`)){let r=u(n),i=r.getBoundingClientRect(),a=Math.abs(this._pointerX-(i.left+i.width/2)),o=Math.max(0,1-a/t),s=1+(e-1)*o;r.style.setProperty(`--wui-dock-mag`,s.toFixed(3))}}_resetMagnification(){this._frame&&=(cancelAnimationFrame(this._frame),0);for(let e of this.querySelectorAll(`.dock-item`))u(e).style.removeProperty(`--wui-dock-mag`)}_wire(){this._teardown(),this._magnifyEnabled()&&(this._pointerMoveListener=e=>{this._pointerX=e.clientX,this._frame||=requestAnimationFrame(()=>this._applyMagnification())},this._pointerLeaveListener=()=>this._resetMagnification(),this.addEventListener(`pointermove`,this._pointerMoveListener),this.addEventListener(`pointerleave`,this._pointerLeaveListener))}_teardown(){this._pointerMoveListener&&=(this.removeEventListener(`pointermove`,this._pointerMoveListener),null),this._pointerLeaveListener&&=(this.removeEventListener(`pointerleave`,this._pointerLeaveListener),null),this._resetMagnification()}},u=e=>(0,n.elementOf)(e,HTMLElement,`wui-dock item must be an HTML element`),d=(e,t)=>{let n=Number.parseFloat(e??``);return Number.isFinite(n)?n:t};(0,t.defineElement)(`wui-dock`,l),e.WuiDock=l})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.186.0`)throw Error(`[webority-ui] drawer expects ui-elements 0.186.0 but the page loaded `+s+`.`);var c=[50,90],l=10,u=100;function d(e,t=c){let n=Array.isArray(e)?e:String(e??``).split(`,`),r=[];for(let e of n){if(typeof e==`string`&&e.trim()===``)return t;let n=Number(e);if(!Number.isFinite(n)||n<l||n>u)return t;r.includes(n)||r.push(n)}return r.length?r.sort((e,t)=>e-t):t}function f(e){let{points:t,index:n,visible:r,velocity:i,canDismiss:a}=e,o=a?-1:0;if(Math.abs(i)>=.5)return i>0?Math.max(n-1,o):Math.min(n+1,t.length-1);let s=t[0];if(a&&s!==void 0&&r<s/2)return-1;let c=0;for(let e=1;e<t.length;e++){let n=t[e],i=t[c];if(n===void 0||i===void 0)throw Error(`snap point missing`);Math.abs(n-r)<Math.abs(i-r)&&(c=e)}return c}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=()=>(0,a.readText)(`drawer`,o.DRAWER_TEXT),v=`(max-width: 767.98px)`,y=4;function b(e,t){let n=e[t];if(n===void 0)throw RangeError(`no snap point at ${t}`);return n}var x=class extends r.ElementBase{static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),g(this,`_doc`,void 0),g(this,`_media`,void 0),g(this,`_shown`,void 0),g(this,`_trigger`,void 0),g(this,`_returnTo`,void 0),g(this,`_release`,void 0),g(this,`_snap`,void 0),g(this,`_drag`,void 0),g(this,`_onMedia`,void 0),g(this,`_onPointerDown`,void 0),g(this,`_onPointerMove`,void 0),g(this,`_onPointerUp`,void 0),g(this,`_onKeyDown`,void 0),g(this,`_onTransitionEnd`,void 0),g(this,`_settled`,void 0),this._doc=null,this._media=null,this._shown=!1,this._trigger=null,this._returnTo=null,this._release=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this.isOpen&&this._announce()},this._settled=!1}connectedCallback(){this._doc=this.ownerDocument,(0,i.wireOpenTriggers)(this._doc),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(v):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._endDrag(),this._teardown(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){this._trigger=e??null,this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return d(this.getAttribute(`snap-points`),c)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!(t instanceof Element))return;let r=(0,n.must)(e[this._snap],`The drawer has no snap point to report.`);t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(r)),t.setAttribute(`aria-valuetext`,(0,a.fillText)(_().screenText,{now:r}))}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;let e=this._dialog();this._shown=!0,this._settled=null;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.dispatchEvent(new CustomEvent(`wui-drawer-open`,{bubbles:!0,detail:{trigger:this._trigger}})),this._returnTo=this._trigger,this._trigger=null,this._release=(0,i.openModalDialog)(e,{escape:this._dismissible(),backdrop:this._dismissible(),focus:this._sheet()?`panel`:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this._shown=!1,this._settled=null;let e=this._release;this._release=null;let t=this._dialog();(0,i.closeModalDialog)(t).then(()=>{e?.(),(0,i.returnFocus)(this._returnTo,t),this._returnTo=null,this._announce()})}_teardown(){this._shown=!1;let e=this._release;this._release=null,e&&(e(),this._panel()?.close())}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._settled&&(this._settled=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_document(){let e=this._doc;if(!e)throw TypeError(`wui-drawer is not connected`);return e}_panel(){let e=this.querySelector(`.wui-drawer-panel`);return e instanceof HTMLDialogElement?e:null}_dialog(){let e=this._panel();if(!e)throw TypeError(`wui-drawer has no dialog panel`);return e}_dismissible(){return!this.hasAttribute(`static`)&&!this.hasAttribute(`no-dismiss`)}_requestClose(e){let t=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}));return t&&this.hide(),t}_keyDown(e){e.target instanceof Element&&e.target.closest(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};if(!(e.key in n))return;let r=n[e.key];r!==void 0&&(e.preventDefault(),this._setSnap(r))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-wui-drawer-grip]`);n instanceof HTMLElement&&!t.closest(`button`)&&(this._drag={grip:n,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},n.setPointerCapture?.(e.pointerId),n.addEventListener(`pointermove`,this._onPointerMove),n.addEventListener(`pointerup`,this._onPointerUp),n.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){let e=this._document().defaultView;if(!e)throw TypeError(`wui-drawer has no window`);return e.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<y)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(b(i,i.length-1)-b(i,this._snap))/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let a=this._points(),o=this._viewport(),s=(b(a,this._snap)/100*o-i)/(o/100),c=this._dismissible(),l=f({points:a,index:this._snap,visible:s,velocity:r,canDismiss:c});l>=0?this._setSnap(l):this._requestClose(`drag`)}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};(0,t.defineElement)(`wui-drawer`,x),e.WuiDrawer=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.drawerText);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.187.0`)throw Error(`[webority-ui] drawer expects ui-elements 0.187.0 but the page loaded `+s+`.`);var c=[50,90],l=10,u=100;function d(e,t=c){let n=Array.isArray(e)?e:String(e??``).split(`,`),r=[];for(let e of n){if(typeof e==`string`&&e.trim()===``)return t;let n=Number(e);if(!Number.isFinite(n)||n<l||n>u)return t;r.includes(n)||r.push(n)}return r.length?r.sort((e,t)=>e-t):t}function f(e){let{points:t,index:n,visible:r,velocity:i,canDismiss:a}=e,o=a?-1:0;if(Math.abs(i)>=.5)return i>0?Math.max(n-1,o):Math.min(n+1,t.length-1);let s=t[0];if(a&&s!==void 0&&r<s/2)return-1;let c=0;for(let e=1;e<t.length;e++){let n=t[e],i=t[c];if(n===void 0||i===void 0)throw Error(`snap point missing`);Math.abs(n-r)<Math.abs(i-r)&&(c=e)}return c}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=()=>(0,a.readText)(`drawer`,o.DRAWER_TEXT),v=`(max-width: 767.98px)`,y=4;function b(e,t){let n=e[t];if(n===void 0)throw RangeError(`no snap point at ${t}`);return n}var x=class extends r.ElementBase{static get observedAttributes(){return[`open`,`snap-points`,`no-sheet`]}constructor(){super(),g(this,`_doc`,void 0),g(this,`_media`,void 0),g(this,`_shown`,void 0),g(this,`_trigger`,void 0),g(this,`_returnTo`,void 0),g(this,`_release`,void 0),g(this,`_snap`,void 0),g(this,`_drag`,void 0),g(this,`_onMedia`,void 0),g(this,`_onPointerDown`,void 0),g(this,`_onPointerMove`,void 0),g(this,`_onPointerUp`,void 0),g(this,`_onKeyDown`,void 0),g(this,`_onTransitionEnd`,void 0),g(this,`_settled`,void 0),this._doc=null,this._media=null,this._shown=!1,this._trigger=null,this._returnTo=null,this._release=null,this._snap=0,this._drag=null,this._onMedia=()=>this._syncMode(),this._onPointerDown=e=>this._pointerDown(e),this._onPointerMove=e=>this._pointerMove(e),this._onPointerUp=e=>this._pointerUp(e),this._onKeyDown=e=>this._keyDown(e),this._onTransitionEnd=e=>{e.target===this._panel()&&e.propertyName===`transform`&&this.isOpen&&this._announce()},this._settled=!1}connectedCallback(){this._doc=this.ownerDocument,(0,i.wireOpenTriggers)(this._doc),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`transitionend`,this._onTransitionEnd),this._media=typeof matchMedia==`function`?matchMedia(v):null,this._media?.addEventListener?.(`change`,this._onMedia),this._syncMode(),this._applyPoints(),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._endDrag(),this._teardown(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`transitionend`,this._onTransitionEnd),this._media?.removeEventListener?.(`change`,this._onMedia),this._media=null,this._doc=null}attributeChangedCallback(e){this._doc&&(e===`open`?this.hasAttribute(`open`)?this._open():this._close():e===`no-sheet`?this._syncMode():(this._snap=Math.min(this._snap,this._points().length-1),this._applyPoints()))}get isOpen(){return this.hasAttribute(`open`)}show(e){this._trigger=e??null,this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_points(){return d(this.getAttribute(`snap-points`),c)}_sheet(){return!!this._media?.matches&&!this.hasAttribute(`no-sheet`)}_syncMode(){this.setAttribute(`data-mode`,this._sheet()?`sheet`:`side`)}_applyPoints(){let e=this._points();this._snap=Math.min(Math.max(this._snap,0),e.length-1),this.style.setProperty(`--wui-drawer-max`,String(e[e.length-1])),this.style.setProperty(`--wui-drawer-snap`,String(e[this._snap])),this.setAttribute(`data-snap`,String(this._snap));let t=this.querySelector(`.wui-drawer-handle`);if(!(t instanceof Element))return;let r=(0,n.must)(e[this._snap],`The drawer has no snap point to report.`);t.setAttribute(`aria-valuemin`,String(e[0])),t.setAttribute(`aria-valuemax`,String(e[e.length-1])),t.setAttribute(`aria-valuenow`,String(r)),t.setAttribute(`aria-valuetext`,(0,a.fillText)(_().screenText,{now:r}))}_setSnap(e){let t=this._points(),n=Math.min(Math.max(e,0),t.length-1),r=n!==this._snap;this._snap=n,this._applyPoints(),r&&this.dispatchEvent(new CustomEvent(`wui-drawer-snap`,{bubbles:!0,detail:{index:n,percent:t[n]}}))}_open(){if(this._shown)return;let e=this._dialog();this._shown=!0,this._settled=null;let t=Number.parseInt(this.getAttribute(`default-snap`)??`0`,10);this._snap=Number.isFinite(t)?t:0,this._syncMode(),this._applyPoints(),this.dispatchEvent(new CustomEvent(`wui-drawer-open`,{bubbles:!0,detail:{trigger:this._trigger}})),this._returnTo=this._trigger,this._trigger=null,this._release=(0,i.openModalDialog)(e,{escape:this._dismissible(),backdrop:this._dismissible(),focus:this._sheet()?`panel`:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle()}_close(){if(!this._shown)return;this._endDrag(),this._shown=!1,this._settled=null;let e=this._release;this._release=null;let t=this._dialog();(0,i.closeModalDialog)(t).then(()=>{e?.(),(0,i.returnFocus)(this._returnTo,t),this._returnTo=null,this._announce()})}_teardown(){this._shown=!1;let e=this._release;this._release=null,e&&(e(),this._panel()?.close())}_settle(){(this._panel()?.getAnimations?.()??[]).length||this._announce()}_announce(){let e=this.isOpen;e!==this._settled&&(this._settled=e,this.dispatchEvent(new CustomEvent(e?`wui-drawer-opened`:`wui-drawer-closed`,{bubbles:!0})))}_document(){let e=this._doc;if(!e)throw TypeError(`wui-drawer is not connected`);return e}_panel(){let e=this.querySelector(`.wui-drawer-panel`);return e instanceof HTMLDialogElement?e:null}_dialog(){let e=this._panel();if(!e)throw TypeError(`wui-drawer has no dialog panel`);return e}_dismissible(){return!this.hasAttribute(`static`)&&!this.hasAttribute(`no-dismiss`)}_requestClose(e){let t=this.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}));return t&&this.hide(),t}_keyDown(e){e.target instanceof Element&&e.target.closest(`.wui-drawer-handle`)&&this._sheet()&&this._handleKey(e)}_handleKey(e){let t=this._points().length-1,n={ArrowUp:this._snap+1,ArrowDown:this._snap-1,Home:0,End:t};if(!(e.key in n))return;let r=n[e.key];r!==void 0&&(e.preventDefault(),this._setSnap(r))}_pointerDown(e){if(!this.isOpen||!this._sheet()||(e.button??0)!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-wui-drawer-grip]`);n instanceof HTMLElement&&!t.closest(`button`)&&(this._drag={grip:n,id:e.pointerId,startY:e.clientY,lastY:e.clientY,lastT:e.timeStamp,velocity:0,moved:!1},n.setPointerCapture?.(e.pointerId),n.addEventListener(`pointermove`,this._onPointerMove),n.addEventListener(`pointerup`,this._onPointerUp),n.addEventListener(`pointercancel`,this._onPointerUp))}_viewport(){let e=this._document().defaultView;if(!e)throw TypeError(`wui-drawer has no window`);return e.innerHeight}_pointerMove(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let n=e.clientY-t.startY;if(!t.moved&&Math.abs(n)<y)return;t.moved=!0,this.classList.add(`is-dragging`);let r=e.timeStamp-t.lastT;r>0&&(t.velocity=(e.clientY-t.lastY)/r),t.lastY=e.clientY,t.lastT=e.timeStamp;let i=this._points(),a=(b(i,i.length-1)-b(i,this._snap))/100*this._viewport();t.offset=Math.max(n,-a),this.style.setProperty(`--wui-drawer-drag`,`${t.offset}px`)}_pointerUp(e){let t=this._drag;if(!t||e.pointerId!==t.id)return;let{moved:n,velocity:r,offset:i=0}=t;if(this._endDrag(),!n)return;let a=this._points(),o=this._viewport(),s=(b(a,this._snap)/100*o-i)/(o/100),c=this._dismissible(),l=f({points:a,index:this._snap,visible:s,velocity:r,canDismiss:c});l>=0?this._setSnap(l):this._requestClose(`drag`)}_endDrag(){let e=this._drag;e&&(this._drag=null,e.grip.releasePointerCapture?.(e.id),e.grip.removeEventListener(`pointermove`,this._onPointerMove),e.grip.removeEventListener(`pointerup`,this._onPointerUp),e.grip.removeEventListener(`pointercancel`,this._onPointerUp),this.classList.remove(`is-dragging`),this.style.removeProperty(`--wui-drawer-drag`))}};(0,t.defineElement)(`wui-drawer`,x),e.WuiDrawer=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.drawerText);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.186.0`)throw Error(`[webority-ui] dropdown expects ui-elements 0.186.0 but the page loaded `+o+`.`);function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=`[data-wui-dropdown-trigger]`,f=`[data-wui-dropdown-menu]`,p=`.dropdown-item`,m=`[data-wui-keep-open]`,h=2,g=150,_=class extends n.ElementBase{static get observedAttributes(){return[`open`,`align`]}constructor(){super(),u(this,`_unbindKeys`,void 0),u(this,`_rect`,void 0),u(this,`_pendingFocus`,void 0),u(this,`_pressOpen`,void 0),u(this,`_settling`,void 0),u(this,`_settleTimer`,void 0),u(this,`_endSettle`,void 0),u(this,`_onSettleScroll`,void 0),u(this,`_onClick`,void 0),u(this,`_onPointerDown`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onResize`,void 0),u(this,`_onClosed`,void 0),this._unbindKeys=null,this._rect=null,this._pendingFocus=!1,this._pressOpen=null,this._settling=!1,this._settleTimer=null,this._endSettle=()=>this._stopSettling(),this._onSettleScroll=()=>this._armQuiet(),this._onClick=e=>this._click(e),this._onPointerDown=e=>{e.target instanceof Element&&e.target.closest(d)&&(this._pressOpen=this.isOpen)},this._onKeyDown=e=>this._key(e),this._onScroll=()=>this._scrolled(),this._onResize=()=>{this._request(!1,`resize`)},this._onClosed=()=>this._dismissed()}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.addEventListener(`keydown`,this._onKeyDown),this._trigger()?.setAttribute(`aria-expanded`,String(this.isOpen)),this.isOpen&&this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.removeEventListener(`keydown`,this._onKeyDown),this._stop();let e=this._menu();e&&(0,a.closeAnchoredPopover)(e)}attributeChangedCallback(e){e===`open`&&this.isConnected&&this._sync()}get isOpen(){return this.hasAttribute(`open`)}show(){this.isOpen||this._request(!0,`trigger`)}hide(){this.isOpen&&this._request(!1,`trigger`)}_request(e,t){let n=this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,cancelable:!0,detail:{open:e,source:t}}));return n&&this._apply(e),n}_apply(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}_dismissed(){if(!this.isConnected||!this.isOpen)return;let e=this._menu()?.contains(this.ownerDocument.activeElement)??!1;this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,detail:{open:!1,source:`dismiss`}})),this.removeAttribute(`open`),e&&this._trigger()?.focus()}_sync(){let{trigger:e,menu:t}=this._markup();this.isOpen?this._open(e,t):this._close(e,t)}_open(e,t){(0,a.isPopoverOpen)(t)||(this._pendingFocus&&this._startSettling(),(0,a.openAnchoredPopover)(this._anchor(e),t,{mode:`auto`,alignEnd:this.getAttribute(`align`)===`end`,onClosed:this._onClosed,scrollSettling:()=>this._settling}),e.setAttribute(`aria-expanded`,`true`),this._rect=this._anchor(e).getBoundingClientRect(),this._unbindKeys=(0,i.bindMenuKeys)(t,{items:()=>this._rows(t)}),window.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onResize),this._pendingFocus&&(this._pendingFocus=!1,queueMicrotask(()=>{this.isOpen&&(0,a.isPopoverOpen)(t)&&this._rows(t)[0]?.focus()})))}_close(e,t){this._pendingFocus=!1,this._stop(),e.setAttribute(`aria-expanded`,`false`),(0,a.closeAnchoredPopover)(t)}_stop(){this._stopSettling(),this._unbindKeys?.(),this._unbindKeys=null,window.removeEventListener(`scroll`,this._onScroll,{capture:!0}),window.removeEventListener(`resize`,this._onResize)}_startSettling(){this._settling=!0,this.ownerDocument.addEventListener(`scroll`,this._onSettleScroll,{capture:!0,passive:!0}),this.ownerDocument.addEventListener(`scrollend`,this._endSettle,{capture:!0}),this._armQuiet()}_armQuiet(){this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(this._endSettle,g)}_stopSettling(){if(this._settling&&(this._settling=!1,this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=null,this.ownerDocument.removeEventListener(`scroll`,this._onSettleScroll,{capture:!0}),this.ownerDocument.removeEventListener(`scrollend`,this._endSettle,{capture:!0}),this.isConnected)){let{trigger:e}=this._markup();this._rect=this._anchor(e).getBoundingClientRect()}}_scrolled(){if(this._settling)return;let{trigger:e}=this._markup(),t=this._anchor(e).getBoundingClientRect(),n=this._rect;(!n||Math.abs(t.top-n.top)>h||Math.abs(t.left-n.left)>h)&&this._request(!1,`scroll`)}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=this._pressOpen;this._pressOpen=null;let r=t.closest(d);if(r&&this.contains(r)){if((n??this.isOpen)&&!this.isOpen)return;this._request(!this.isOpen,`trigger`);return}let i=this._menu(),a=t.closest(p);if(!i||!a||!i.contains(a)||a.getAttribute(`aria-disabled`)===`true`)return;let o=a.closest(m);o&&i.contains(o)||this.isOpen&&this._request(!1,`select`)}_key(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=e.target;if(t instanceof Element&&this._trigger()?.contains(t)){if(this.isOpen){let t=this._menu(),n=t?this._rows(t):[],r=e.key===`ArrowDown`?n[0]:n[n.length-1];if(!r)return;e.preventDefault(),r.focus()}else e.key===`ArrowDown`&&(e.preventDefault(),this._pendingFocus=!0,this._request(!0,`trigger`))}}_trigger(){return this.querySelector(d)}_anchor(e){return(e.closest(`[data-wui-overflow-hidden]`)?.closest(`wui-overflow`))?.querySelector(`:scope > .wui-overflow-more`)??e}_menu(){return this.querySelector(f)}_rows(e){return Array.from(e.querySelectorAll(p)).filter(r.isDrawn)}_markup(){let e=this._trigger(),t=this._menu();if(!e||!t)throw RangeError(`<wui-dropdown> needs a [data-wui-dropdown-trigger] control and a [data-wui-dropdown-menu] panel.`);return{trigger:e,menu:t}}};(0,t.defineElement)(`wui-dropdown`,_),e.WuiDropdown=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay);
1
+ (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.187.0`)throw Error(`[webority-ui] dropdown expects ui-elements 0.187.0 but the page loaded `+o+`.`);function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=`[data-wui-dropdown-trigger]`,f=`[data-wui-dropdown-menu]`,p=`.dropdown-item`,m=`[data-wui-keep-open]`,h=2,g=150,_=class extends n.ElementBase{static get observedAttributes(){return[`open`,`align`]}constructor(){super(),u(this,`_unbindKeys`,void 0),u(this,`_rect`,void 0),u(this,`_pendingFocus`,void 0),u(this,`_pressOpen`,void 0),u(this,`_settling`,void 0),u(this,`_settleTimer`,void 0),u(this,`_endSettle`,void 0),u(this,`_onSettleScroll`,void 0),u(this,`_onClick`,void 0),u(this,`_onPointerDown`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onResize`,void 0),u(this,`_onClosed`,void 0),this._unbindKeys=null,this._rect=null,this._pendingFocus=!1,this._pressOpen=null,this._settling=!1,this._settleTimer=null,this._endSettle=()=>this._stopSettling(),this._onSettleScroll=()=>this._armQuiet(),this._onClick=e=>this._click(e),this._onPointerDown=e=>{e.target instanceof Element&&e.target.closest(d)&&(this._pressOpen=this.isOpen)},this._onKeyDown=e=>this._key(e),this._onScroll=()=>this._scrolled(),this._onResize=()=>{this._request(!1,`resize`)},this._onClosed=()=>this._dismissed()}connectedCallback(){this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.addEventListener(`keydown`,this._onKeyDown),this._trigger()?.setAttribute(`aria-expanded`,String(this.isOpen)),this.isOpen&&this._sync()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,{capture:!0}),this.removeEventListener(`keydown`,this._onKeyDown),this._stop();let e=this._menu();e&&(0,a.closeAnchoredPopover)(e)}attributeChangedCallback(e){e===`open`&&this.isConnected&&this._sync()}get isOpen(){return this.hasAttribute(`open`)}show(){this.isOpen||this._request(!0,`trigger`)}hide(){this.isOpen&&this._request(!1,`trigger`)}_request(e,t){let n=this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,cancelable:!0,detail:{open:e,source:t}}));return n&&this._apply(e),n}_apply(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}_dismissed(){if(!this.isConnected||!this.isOpen)return;let e=this._menu()?.contains(this.ownerDocument.activeElement)??!1;this.dispatchEvent(new CustomEvent(`wui-dropdown-toggle`,{bubbles:!0,detail:{open:!1,source:`dismiss`}})),this.removeAttribute(`open`),e&&this._trigger()?.focus()}_sync(){let{trigger:e,menu:t}=this._markup();this.isOpen?this._open(e,t):this._close(e,t)}_open(e,t){(0,a.isPopoverOpen)(t)||(this._pendingFocus&&this._startSettling(),(0,a.openAnchoredPopover)(this._anchor(e),t,{mode:`auto`,alignEnd:this.getAttribute(`align`)===`end`,onClosed:this._onClosed,scrollSettling:()=>this._settling}),e.setAttribute(`aria-expanded`,`true`),this._rect=this._anchor(e).getBoundingClientRect(),this._unbindKeys=(0,i.bindMenuKeys)(t,{items:()=>this._rows(t)}),window.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onResize),this._pendingFocus&&(this._pendingFocus=!1,queueMicrotask(()=>{this.isOpen&&(0,a.isPopoverOpen)(t)&&this._rows(t)[0]?.focus()})))}_close(e,t){this._pendingFocus=!1,this._stop(),e.setAttribute(`aria-expanded`,`false`),(0,a.closeAnchoredPopover)(t)}_stop(){this._stopSettling(),this._unbindKeys?.(),this._unbindKeys=null,window.removeEventListener(`scroll`,this._onScroll,{capture:!0}),window.removeEventListener(`resize`,this._onResize)}_startSettling(){this._settling=!0,this.ownerDocument.addEventListener(`scroll`,this._onSettleScroll,{capture:!0,passive:!0}),this.ownerDocument.addEventListener(`scrollend`,this._endSettle,{capture:!0}),this._armQuiet()}_armQuiet(){this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(this._endSettle,g)}_stopSettling(){if(this._settling&&(this._settling=!1,this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=null,this.ownerDocument.removeEventListener(`scroll`,this._onSettleScroll,{capture:!0}),this.ownerDocument.removeEventListener(`scrollend`,this._endSettle,{capture:!0}),this.isConnected)){let{trigger:e}=this._markup();this._rect=this._anchor(e).getBoundingClientRect()}}_scrolled(){if(this._settling)return;let{trigger:e}=this._markup(),t=this._anchor(e).getBoundingClientRect(),n=this._rect;(!n||Math.abs(t.top-n.top)>h||Math.abs(t.left-n.left)>h)&&this._request(!1,`scroll`)}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=this._pressOpen;this._pressOpen=null;let r=t.closest(d);if(r&&this.contains(r)){if((n??this.isOpen)&&!this.isOpen)return;this._request(!this.isOpen,`trigger`);return}let i=this._menu(),a=t.closest(p);if(!i||!a||!i.contains(a)||a.getAttribute(`aria-disabled`)===`true`)return;let o=a.closest(m);o&&i.contains(o)||this.isOpen&&this._request(!1,`select`)}_key(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=e.target;if(t instanceof Element&&this._trigger()?.contains(t)){if(this.isOpen){let t=this._menu(),n=t?this._rows(t):[],r=e.key===`ArrowDown`?n[0]:n[n.length-1];if(!r)return;e.preventDefault(),r.focus()}else e.key===`ArrowDown`&&(e.preventDefault(),this._pendingFocus=!0,this._request(!0,`trigger`))}}_trigger(){return this.querySelector(d)}_anchor(e){return(e.closest(`[data-wui-overflow-hidden]`)?.closest(`wui-overflow`))?.querySelector(`:scope > .wui-overflow-more`)??e}_menu(){return this.querySelector(f)}_rows(e){return Array.from(e.querySelectorAll(p)).filter(r.isDrawn)}_markup(){let e=this._trigger(),t=this._menu();if(!e||!t)throw RangeError(`<wui-dropdown> needs a [data-wui-dropdown-trigger] control and a [data-wui-dropdown-menu] panel.`);return{trigger:e,menu:t}}};(0,t.defineElement)(`wui-dropdown`,_),e.WuiDropdown=_})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay);
@@ -1,3 +1,3 @@
1
- (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.186.0`)throw Error(`[webority-ui] entry-grid expects ui-elements 0.186.0 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=`tbody > tr.wui-entry-grid-row[data-row-key]`,u=`input, select, textarea, button, [tabindex]:not([tabindex="-1"])`,d=e=>[`dirty`,`saving`,`saved`,`failed`].find(t=>e.classList.contains(`wui-entry-grid-row-${t}`))??`clean`,f=class extends r.ElementBase{constructor(){super(),c(this,`_onKeyDown`,void 0),c(this,`_onFocusIn`,void 0),c(this,`_onClick`,void 0),c(this,`_pendingCell`,null),c(this,`_ready`,!1),c(this,`_rowActionsObserver`,new MutationObserver(()=>this._syncRowActions())),c(this,`_onMouseDown`,e=>{this._owns((0,n.closestOf)(e.target,`td.wui-entry-grid__row-actions`))&&e.preventDefault()}),c(this,`_onPointerDown`,e=>{if(e.button!==0)return;let t=this._ownRow(e.target),r=t?.dataset.rowKey;if(!t||r===void 0||r===this.getAttribute(`active-row`))return;let i=(0,n.closestOf)(e.target,`td`),a=i?Array.from(t.children).indexOf(i):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})}),c(this,`_onPaste`,e=>{let t=this._ownRow(e.target),r=t?.dataset.rowKey,i=(0,n.closestOf)(e.target,`td[data-column-key]`)?.getAttribute(`data-column-key`);if(!t||r===void 0||!i)return;let a=e.clipboardData?.getData(`text/plain`)??``;if(!/[\t\r\n]/.test(a))return;let o=a.replace(/\r\n/g,`
1
+ (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.187.0`)throw Error(`[webority-ui] entry-grid expects ui-elements 0.187.0 but the page loaded `+i+`.`);function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=`tbody > tr.wui-entry-grid-row[data-row-key]`,u=`input, select, textarea, button, [tabindex]:not([tabindex="-1"])`,d=e=>[`dirty`,`saving`,`saved`,`failed`].find(t=>e.classList.contains(`wui-entry-grid-row-${t}`))??`clean`,f=class extends r.ElementBase{constructor(){super(),c(this,`_onKeyDown`,void 0),c(this,`_onFocusIn`,void 0),c(this,`_onClick`,void 0),c(this,`_pendingCell`,null),c(this,`_ready`,!1),c(this,`_rowActionsObserver`,new MutationObserver(()=>this._syncRowActions())),c(this,`_onMouseDown`,e=>{this._owns((0,n.closestOf)(e.target,`td.wui-entry-grid__row-actions`))&&e.preventDefault()}),c(this,`_onPointerDown`,e=>{if(e.button!==0)return;let t=this._ownRow(e.target),r=t?.dataset.rowKey;if(!t||r===void 0||r===this.getAttribute(`active-row`))return;let i=(0,n.closestOf)(e.target,`td`),a=i?Array.from(t.children).indexOf(i):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})}),c(this,`_onPaste`,e=>{let t=this._ownRow(e.target),r=t?.dataset.rowKey,i=(0,n.closestOf)(e.target,`td[data-column-key]`)?.getAttribute(`data-column-key`);if(!t||r===void 0||!i)return;let a=e.clipboardData?.getData(`text/plain`)??``;if(!/[\t\r\n]/.test(a))return;let o=a.replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `);o[o.length-1]===``&&o.pop(),o.length<=1&&!(o[0]??``).includes(` `)||(e.preventDefault(),this._emit(`paste`,{rowKey:r,columnKey:i,rows:o.map(e=>e.split(` `))}))}),this._onKeyDown=e=>this._keyDown(e),this._onFocusIn=e=>this._focusIn(e),this._onClick=e=>{this._owns((0,n.closestOf)(e.target,`.wui-entry-grid-add`))&&this._emit(`add`,{});let t=(0,n.closestOf)(e.target,`.wui-entry-grid-save, .wui-entry-grid-cancel`);t&&this._owns(t)&&this._rowAction(t,e.target);let r=(0,n.closestOf)(e.target,`thead th[data-sortable]`),i=r?.getAttribute(`data-column-key`);this._owns(r)&&i&&this._emit(`sort`,{columnKey:i})}}static get observedAttributes(){return[`active-row`]}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`paste`,this._onPaste),this.addEventListener(`mousedown`,this._onMouseDown),this.hasAttribute(`data-row-actions`)&&(this._rowActionsObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`]}),this._syncRowActions()),this._ready=!0}disconnectedCallback(){this._ready=!1,this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`paste`,this._onPaste),this.removeEventListener(`mousedown`,this._onMouseDown),this._rowActionsObserver.disconnect()}attributeChangedCallback(e,t,n){t!==n&&this._ready&&queueMicrotask(()=>this._focusActiveRow())}_owns(e){return(0,n.closestOf)(e,`wui-entry-grid`)===this}_rows(){return[...this.querySelectorAll(l)].filter(e=>e instanceof HTMLElement&&this._owns(e))}_ownRow(e){let t=(0,n.closestOf)(e,l);return t instanceof HTMLElement&&this._owns(t)?t:null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-entry-grid:${e}`,{detail:t,bubbles:!0,composed:!0}))}_focusActiveRow(){let e=this.getAttribute(`active-row`),t=this._pendingCell;if(this._pendingCell=null,!this.isConnected||!e)return;let n=this._rows().find(t=>t.dataset.rowKey===e);n&&!n.contains(this.ownerDocument.activeElement)&&((t===null?void 0:n.children[t])?.querySelector(u)??n.querySelector(u))?.focus()}_rowAction(e,t){let n=this._ownRow(t),r=n?.dataset.rowKey;n&&r!==void 0&&(e instanceof HTMLButtonElement&&e.disabled||(r!==this.getAttribute(`active-row`)&&this._emit(`active`,{rowKey:r}),e.matches(`.wui-entry-grid-save`)?this._emit(`commit`,{rowKey:r,move:`stay`}):this._emit(`discard`,{rowKey:r})))}_syncRowActions(){if(!this.hasAttribute(`data-row-actions`))return;let e=this.querySelector(`template.wui-entry-grid-actions`);if(e)for(let t of this._rows()){let n=t.querySelector(`:scope > td.wui-entry-grid__row-actions`);if(!n)continue;let r=d(t);if(n.getAttribute(`data-row-actions-state`)!==r&&(n.replaceChildren(),n.setAttribute(`data-row-actions-state`,r),(r===`dirty`||r===`failed`||r===`saving`)&&(n.append(e.content.cloneNode(!0)),r===`saving`))){let e=n.querySelector(`.wui-entry-grid-save`);e&&(e.disabled=!0),n.querySelector(`.wui-entry-grid-cancel`)?.remove()}}}_keyDown(e){if(e.defaultPrevented||e.isComposing||e.keyCode===229)return;let t=(0,n.closestOf)(e.target,`thead th[data-sortable]`),r=t?.getAttribute(`data-column-key`);if(this._owns(t)&&r&&(e.key===`Enter`||e.key===` `)){e.preventDefault(),this._emit(`sort`,{columnKey:r});return}let i=this._ownRow(e.target),a=i?.dataset.rowKey;if(!i||a===void 0)return;let o=e.target instanceof Element?e.target:null,s=e.ctrlKey||e.metaKey;if(e.ctrlKey&&e.key===`Delete`||e.metaKey&&e.key===`Backspace`){if(!this.hasAttribute(`removable`))return;e.preventDefault(),this._emit(`remove`,{rowKey:a})}else if(e.key===`Enter`){if(s||e.shiftKey||e.altKey||o?.closest(`textarea, button`)||o?.getAttribute(`aria-expanded`)===`true`)return;e.preventDefault(),this._emit(`commit`,{rowKey:a,move:`next`})}else if(s&&e.key.toLowerCase()===`s`)e.preventDefault(),this._emit(`commit`,{rowKey:a,move:`stay`});else if(e.key===`Escape`){if(o?.getAttribute(`aria-expanded`)===`true`)return;e.preventDefault(),this._emit(`discard`,{rowKey:a})}else if(s&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault();let t=this._rows(),r=t[t.indexOf(i)+(e.key===`ArrowUp`?-1:1)]?.dataset.rowKey;if(r!==void 0){let t=(0,n.closestOf)(e.target,`td`),a=t?Array.from(i.children).indexOf(t):-1;this._pendingCell=a>=0?a:null,this._emit(`active`,{rowKey:r})}}}_focusIn(e){let t=this._ownRow(e.target),r=t?.dataset.rowKey;t&&r!==void 0&&(e.target instanceof HTMLInputElement&&(0,n.closestOf)(e.target,`td[data-kind="number"]`)&&e.target.select(),r!==this.getAttribute(`active-row`)&&this._emit(`active`,{rowKey:r}))}};(0,t.defineElement)(`wui-entry-grid`,f),e.WuiEntryGrid=f})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.186.0`)throw Error(`[webority-ui] gantt expects ui-elements 0.186.0 but the page loaded `+p+`.`);var m=864e5,h={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},g={table:{rowH:36,groupH:32,barH:20,barTop:8,groupBarTop:13,ppd:{day:22,week:7.3,month:4.9}},lanes:{rowH:40,groupH:52,barH:26,barTop:7,groupBarTop:36,ppd:{day:39,week:13.2,month:9}}},_=4,v=6,y=8,b=90,x=170,ee=6.7,te=16,ne=16,re=6,S=3.5,ie=24,ae=4,C=6,oe=48,se=new Set([`neutral`,`warning`]),ce=new Set([`start`,`end`]),le=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ue=new Set([`day`,`week`,`month`]),de=new Set([`table`,`lanes`]),fe=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),pe=/^(\d{4})-(\d{2})-(\d{2})$/,me=new Intl.DateTimeFormat(`en-CA`,{timeZone:o.IST_TIME_ZONE,year:`numeric`,month:`2-digit`,day:`2-digit`}),w=class extends Error{};function he(e){return new Set((e??[]).map(O))}var T=e=>le[e]??``,E=e=>String(e).padStart(2,`0`),D=e=>{let t=pe.exec(e);if(!t)return null;let[,n=``,r=``,i=``]=t,a=Number(n),o=Number(r)-1,s=Number(i),c=new Date(0);return c.setUTCFullYear(a,o,s),c.getUTCFullYear()===a&&c.getUTCMonth()===o&&c.getUTCDate()===s?c.getTime():null};function O(e){let t=D(e);if(t===null)throw new w(`"${e}" is not a calendar day.`);return t}function k(e){let t=new Date(e);return`${E(t.getUTCDate())}-${T(t.getUTCMonth())}-${t.getUTCFullYear()}`}function ge(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${E(t.getUTCMonth()+1)}-${E(t.getUTCDate())}`}function _e(e=Date.now()){let t=me.formatToParts(e),n=e=>{let n=t.find(t=>t.type===e);if(!n)throw Error(`The Asia/Kolkata date has no ${e} part.`);return n.value};return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}var A=(e,t)=>{let n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)};function ve(e,t){return e===`day`?t-8*m:e===`week`?j(`week`,t-21*m):A(t,-1)}function j(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*m:A(t,0)}function ye(e,t,n,r){return r===void 0?e===`month`?A(t,_/2*n):t+h.spanDays[e]/2*n*m:t+r*7*n*m}var M=(e,t,n)=>{let r=[],i=e;for(;i<t;){let e=Math.min(n(i),t);r.push({start:i,end:e}),i=e}return r},be=e=>e+m,xe=e=>e+7*m,Se=e=>A(e,1),Ce=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function we(e,t,n,r={}){let i=r.weeks,a=r.holidays??new Set,o=i===void 0?g[e].ppd[t]:oe,s=i===void 0?t===`month`?A(n,_):n+h.spanDays[t]*m:n+i*7*m,c=(s-n)/m,l=e=>(e-n)/m*o,u=e=>({x:l(e.start),w:(e.end-e.start)/m*o}),d=t===`month`?M(n,s,Ce).map(e=>({...u(e),label:String(new Date(e.start).getUTCFullYear())})):M(n,s,Se).map(e=>{let t=u(e),n=new Date(e.start),r=T(n.getUTCMonth());return{...t,label:t.w<b?r:`${r} ${n.getUTCFullYear()}`}}),f=[];if(t===`day`||i!==void 0)for(let e of M(n,s,be)){let t=new Date(e.start),n=t.getUTCDay();f.push({...u(e),label:String(t.getUTCDate()),sub:`MTWTFSS`.charAt((n+6)%7),weekend:n===0||n===6||a.has(e.start)})}else if(t===`week`)for(let e of M(n,s,xe))f.push({...u(e),label:E(new Date(e.start).getUTCDate())});else for(let e of M(n,s,Se))f.push({...u(e),label:T(new Date(e.start).getUTCMonth())});return{startMs:n,endMs:s,days:c,width:c*o,ppd:o,x:l,top:d,bottom:f,gridX:f.map(e=>e.x),weekendX:f.filter(e=>e.weekend===!0).map(e=>e.x)}}var N=(e,t)=>new w(`Gantt row "${e}": ${t}.`),Te=e=>{if(D(e)===null)throw new w(`Gantt holiday "${e}" is not a calendar day.`)},Ee=(e,t)=>{let n=P(e,`start`,t.start);if(P(e,`end`,t.end)<n)throw N(e,`bar end "${t.end}" is before its start "${t.start}"`);if(t.label.trim()===``)throw N(e,`a bar has an empty label`);if(!se.has(t.tone))throw N(e,`bar tone "${String(t.tone)}" is not neutral or warning`);if(t.half!==void 0&&!ce.has(t.half))throw N(e,`bar half "${String(t.half)}" is not start or end`)},P=(e,t,n)=>{let r=D(n);if(r===null)throw N(e,`${t} "${n}" is not a calendar day`);return r};function De(e){if(e.layout!==void 0&&!de.has(e.layout))throw new w(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!ue.has(e.zoom))throw new w(`Gantt zoom "${e.zoom}" is not day, week or month.`);if(e.weeks!==void 0){if(e.weeks!==1&&e.weeks!==2)throw new w(`Gantt weeks "${String(e.weeks)}" is not 1 or 2.`);if((e.zoom??`week`)!==`week`||e.layout!==`lanes`)throw new w(`Gantt weeks needs the week zoom and the lanes layout.`)}for(let t of e.holidays??[])Te(t);let t=new Set;for(let n of e.rows){if(t.has(n.key))throw N(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw N(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw N(n.key,`end is set without a start`);if(n.start!==void 0){let e=P(n.key,`start`,n.start);if(n.end!==void 0&&P(n.key,`end`,n.end)<e)throw N(n.key,`end "${n.end}" is before start "${n.start}"`)}if(n.progress!==void 0&&!(Number.isInteger(n.progress)&&n.progress>=0&&n.progress<=100))throw N(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!fe.has(n.status))throw N(n.key,`status "${n.status}" is not a known status`);if(n.bars!==void 0){if(n.start!==void 0||n.end!==void 0)throw N(n.key,`bars and a start or end cannot both be set`);if(n.dependsOn!==void 0&&n.dependsOn.length>0)throw N(n.key,`a row with bars takes no dependsOn`);if(e.layout!==`lanes`)throw N(n.key,`bars need the lanes layout`);for(let e of n.bars)Ee(n.key,e)}}let n=new Map;for(let t of e.rows)n.set(t.key,t);for(let t of e.rows)for(let e of t.dependsOn??[]){if(e===t.key)throw N(t.key,`depends on itself`);if(!n.has(e))throw N(t.key,`depends on "${e}", which is no row`);if(n.get(e)?.bars!==void 0)throw N(t.key,`depends on "${e}", which has bars`)}let r=new Map,i=e=>(r.set(e,`onPath`),{key:e,deps:n.get(e)?.dependsOn??[],next:0});for(let t of e.rows){if(r.has(t.key))continue;let e=[i(t.key)];for(;e.length>0;){let t=e[e.length-1];if(!t)break;let n=t.deps[t.next];if(n===void 0){r.set(t.key,`done`),e.pop();continue}t.next++;let a=r.get(n);if(a===`onPath`)throw N(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function Oe(e,t,n){return ee*(e.length+String(t).length+4)+te<=n?`inside`:`after`}function ke(e,t){let{arrow:n,elbow:r}=h;return{d:t.l-e.r>=ne?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+re} V${(e.y+t.y)/2} H${t.l-r} V${t.y} H${t.l-n}`,head:`${t.l-n},${t.y-S} ${t.l},${t.y} ${t.l-n},${t.y+S}`}}var F=(e,t,n,r,i)=>({row:e,kind:t,index:n,top:r,height:i,x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!0}),I=(e,t)=>Math.round((t-e.startMs)/m),L=(e,t,n)=>[Math.max(0,I(e,t)),Math.min(e.days,I(e,n))];function Ae(e,t,n,r,i){let a=(e.bars??[]).map((e,t)=>({bar:e,i:t,s:O(e.start),e:O(e.end)+m})).sort((e,t)=>e.s-t.s||e.i-t.i),o=[],s=[],c=Array(r.days).fill(0);for(let e of a){let t=o.findIndex(t=>t<=e.s);t===-1?(t=o.length,o.push(e.e)):o[t]=e.e;let a=r.x(e.s)+(e.bar.half===`start`?r.ppd/2:0),l=r.x(e.e)-(e.bar.half===`end`?r.ppd/2:0),u=a>=r.width||l<=0,d=Math.max(a,0),f=Math.min(l,r.width);s.push({index:e.i,label:e.bar.label,tone:e.bar.tone,half:e.bar.half,top:n+ae+t*(i.barH+C),height:i.barH,x:u?0:d,w:u?0:Math.max(f-d,v),clippedLeft:a<0,clippedRight:l>r.width,hidden:u});let[p,m]=L(r,e.s,e.e);for(let e=p;e<m;e++)c[e]=(c[e]??0)+1}let l=[];for(let e=0;e<c.length;e++){if((c[e]??0)<2)continue;let t=e;for(;t<c.length&&(c[t]??0)>=2;)t++;l.push({x:r.x(r.startMs+e*m),w:(t-e)*r.ppd}),e=t}let u=o.length;return{row:e,kind:`lane`,index:t,top:n,height:Math.max(i.rowH,8+u*(i.barH+C)-C),x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!1,bars:s,clashes:l,subs:u}}function je(e,t){let n=g[t.layout],r=we(t.layout,t.zoom,t.fromMs,{weeks:t.weeks,holidays:t.holidays}),{ppd:i,width:a}=r,o=new Set(e.folded??[]),s=e.rows.map((e,t)=>({row:e,index:t,startMs:e.start===void 0?void 0:O(e.start),endEx:e.end===void 0?void 0:O(e.end)+m})),c=new Map;for(let e of s){let t=e.row.group;if(t===void 0)continue;let n=c.get(t)??{name:t,count:0,sum:0,n:0,emitted:!1};if(c.set(t,n),n.count++,e.startMs!==void 0){let t=e.endEx??e.startMs+864e5;n.startMs=n.startMs===void 0?e.startMs:Math.min(n.startMs,e.startMs),n.endMs=n.endMs===void 0?t:Math.max(n.endMs,t)}e.endEx!==void 0&&(n.sum+=e.row.progress??0,n.n++)}let l=[],u=new Map,d=null,f=0;if(e.rows.some(e=>e.bars!==void 0)){let t=Array(r.days).fill(0);for(let n of e.rows)for(let e of n.bars??[]){let[n,i]=L(r,O(e.start),O(e.end)+m);for(let e=n;e<i;e++)t[e]=(t[e]??0)+1}d={top:0,height:ie,counts:t},f=ie}for(let e of s){let{row:s,index:d}=e,p=s.group===void 0?void 0:c.get(s.group);if(p!==void 0&&!p.emitted){p.emitted=!0;let e=o.has(p.name),t=p.startMs!==void 0&&p.endMs!==void 0,i=p.startMs??r.startMs,c=p.endMs??r.startMs,u=r.x(i),m=r.x(c),h=t&&m>0&&u<a;l.push({row:s,kind:`group`,index:d,top:f,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(m,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&m>a,hidden:!1,group:{name:p.name,count:p.count,percent:p.n>0?Math.round(p.sum/p.n):0,folded:e,startMs:i,endMs:c}}),f+=n.groupH}let m=s.group!==void 0&&o.has(s.group);if(s.bars!==void 0){if(m){l.push(F(s,`lane`,d,f,0));continue}let e=Ae(s,d,f,r,n);l.push(e),f+=e.height;continue}let g=e.endEx===void 0?`milestone`:`bar`;if(m){l.push(F(s,g,d,f,0));continue}let _=f;if(f+=n.rowH,e.startMs===void 0){l.push(F(s,g,d,_,n.rowH));continue}let b;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;b=o<-8||o>a+y?F(s,g,d,_,n.rowH):{row:s,kind:g,index:d,top:_,height:n.rowH,x:o,w:h.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-x}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,v);if(i>=a||i+o<=0)b=F(s,g,d,_,n.rowH);else{let e=Math.max(i,0),r=Math.min(i+o,a),c=i<0,l=i+o>a;r-e<v&&(c?r=Math.min(v,a):e=Math.max(0,r-v)),b={row:s,kind:g,index:d,top:_,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(b.place=Oe(s.name,s.progress??0,r-e))}}l.push(b),b.hidden||u.set(s.key,b)}let p=[];for(let e of l){if(e.kind!==`bar`&&e.kind!==`milestone`||e.hidden)continue;let t=e.kind===`milestone`?e.x-y:e.x,r=new Set;for(let i of e.row.dependsOn??[]){let a=u.get(i);if(a===void 0||r.has(i))continue;r.add(i);let o=ke({r:a.kind===`milestone`?a.x+y:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});p.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:f,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:p,count:d}}var Me=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),R=/\p{L}/u,Ne=/\p{N}/u;function Pe(e){let t=``,n=0;for(let r of e)r===`(`?(n+=1,t+=` `):r===`)`?(n=Math.max(0,n-1),t+=` `):n===0&&(t+=r);return t}function z(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function B(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function Fe(e,t=2){let n=Pe(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(R).filter(e=>!Me.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>R.test(e))&&(i=r(Ne)),i.length===0)return``;let a=z(i,0,`first word`);if(i.length===1)return B(a.slice(0,t));let o=z(i,1,`second word`);return B([z(a,0,`first letter`),z(o,0,`second letter`)])}var Ie=`data-wui-gantt-pick`,V=e=>`${e}px`,H=(e,t,n)=>{let r=(0,i.make)(`div`,{class:`wui-gantt-table-cell`},n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function Le(e){let t=e.text,n=(0,i.make)(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=(0,i.make)(`div`);r.setAttribute(`role`,`rowgroup`);let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=V(e.headHeight),a.append(H(`name`,`columnheader`,t.tableName),H(`owner`,`columnheader`,t.detailsOwner),H(`start`,`columnheader`,t.tableStart),H(`end`,`columnheader`,t.tableEnd),H(`done`,`columnheader`,t.detailsDone)),r.append(a);let o=(0,i.make)(`div`);o.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let r=n.row;if(n.kind===`group`){let r=n.group;if(!r)continue;let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=r.name,a.setAttribute(`role`,`row`),a.style.height=V(n.height);let s=(0,i.make)(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});s.setAttribute(`role`,`rowheader`);let u=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});u.type=`button`,u.setAttribute(`aria-expanded`,String(!r.folded)),u.setAttribute(`aria-label`,(0,l.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),u.setAttribute(e.focusAttr,`group:${r.name}`);let d=(0,c.glyphNode)(r.folded?`chevron-right`:`chevron-down`,{size:16});u.replaceChildren(...d?[d]:[]),s.append(u,(0,i.make)(`span`,null,r.name),(0,i.make)(`span`,null,(0,l.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),a.append(s),o.append(a);continue}let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=r.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=r.key,a.dataset.wuiGanttPick=r.key,r.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=V(n.height);let u=H(`name`,`rowheader`,r.name);u.title=r.name;let d=H(`owner`,`cell`,``);r.owner&&(d.title=r.owner,d.replaceChildren(...[(0,s.avatarNode)({initials:Fe(r.owner)},`avatar-xs`)].filter(e=>e!==null)),d.append((0,i.make)(`span`,{class:`visually-hidden`},r.owner)));let f=H(`start`,`cell`,r.start===void 0?``:k(O(r.start))),p=H(`end`,`cell`,r.end===void 0?``:k(O(r.end))),m=H(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);a.append(u,d,f,p,m),o.append(a)}let u=e.skeleton;for(let e=0;u&&e<u.rows;e+=1){let e=(0,i.make)(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=V(u.rowHeight);let t=(0,i.make)(`span`,{class:`wui-gantt-skeleton`});t.style.height=V(u.barHeight),e.append(t),o.append(e)}return n.append(r,o),n}var Re={addTaskLabel:`Add task`,barLabel:`{name}, {start} to {end}, {percent} percent, {status}`,barLabelAfter:`{label}, after {names}`,clashLabel:`Clash`,countLabel:`Count`,dayLabel:`Day`,detailsCloseLabel:`Close details`,detailsDates:`Dates`,detailsDone:`Done`,detailsOwner:`Owner`,detailsRange:`{start} to {end}`,detailsStartsAfter:`Starts after`,earlierLabel:`Earlier`,emptyText:`Add a task with a start and an end date and it is drawn here as a bar.`,emptyTitle:`No tasks on the plan yet`,errorText:`The plan did not load. Check your connection and try again.`,foldLabel:`Fold {group}`,groupSummaryOne:`{count} item, {percent}% done`,groupSummaryOther:`{count} items, {percent}% done`,helpText:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to move along a row. Press Enter to open the details and Escape to close them.`,helpTextTable:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to follow a dependency. Press Enter to choose a row and Escape to clear the choice.`,laterLabel:`Later`,legendLabel:`Key`,legendRemaining:`Lighter part of a bar is work still to do`,loadingText:`Loading plan`,milestoneBarLabel:`{name}, {date}, milestone, after {names}`,milestoneLabel:`Milestone`,monthLabel:`Month`,retryLabel:`Try again`,scaleLabel:`Time scale`,statusAtRisk:`At risk`,statusDone:`Done`,statusInProgress:`In progress`,statusNotStarted:`Not started`,summaryMilestonesOne:`{count} milestone`,summaryMilestonesOther:`{count} milestones`,summaryRange:`{from} to {to}`,summaryTasksOne:`{count} task`,summaryTasksOther:`{count} tasks`,tableEnd:`End`,tableName:`Task`,tableStart:`Start`,tableStatus:`Status`,todayLabel:`Today`,unfoldLabel:`Unfold {group}`,weekLabel:`Week`};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function ze(e,t){if(U(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Be(e){var t=ze(e,`string`);return U(t)==`symbol`?t:t+``}function W(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=()=>(0,l.readText)(`gantt`,Re),Ve=`wui-gantt:zoom-change`,He=`wui-gantt:from-change`,Ue=`wui-gantt:fold-change`,We=`wui-gantt:select`,Ge=`wui-gantt:add-task`,Ke=`wui-gantt:retry`,K=`data-wui-gantt-focus`,q=`bar:`,J=`http://www.w3.org/2000/svg`,qe=[`day`,`week`,`month`],Y=3,Je=16,Ye=300,Xe=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Ze=0,X=e=>`${e}px`;function Qe(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Z(e){let t=G();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Q=e=>e.progress??0,$=e=>e.status??`notStarted`,$e=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),et=class extends a.ElementBase{constructor(){super(),W(this,`uid`,void 0),W(this,`_spec`,null),W(this,`_prev`,null),W(this,`_zoom`,`week`),W(this,`_fromMs`,null),W(this,`_folded`,new Set),W(this,`_selected`,null),W(this,`_controlled`,!1),W(this,`_awaitingSpec`,!1),W(this,`_connected`,!1),W(this,`_focusAfter`,null),W(this,`_resolved`,null),W(this,`_specRows`,[]),W(this,`_card`,null),W(this,`_onClick`,void 0),W(this,`_onKeyDown`,void 0),W(this,`_onChange`,void 0),Ze+=1,this.uid=`wui-gantt-${Ze}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if((0,u.hasOwn)(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=((0,d.closeAnchoredPopover)(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?O(e.from):null),n(!$e(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(Ve,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:j(e,this._fromMs),this._draw())}_setFrom(e){this._emit(He,{from:ge(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Ue,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(We,{key:e}),this._focusAfter=`${q}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=qe.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${K}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(K)??``,n);return}let r=t.closest(`[${Ie}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(q)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(Ge):e===`retry`?this._emit(Ke):n&&e===`nav:earlier`?this._setFrom(ye(n.zoom,n.fromMs,-1,n.weeks)):n&&e===`nav:later`?this._setFrom(ye(n.zoom,n.fromMs,1,n.weeks)):n&&e===`nav:today`?this._setFrom(n.weeks===void 0?ve(n.zoom,n.todayMs):j(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${K}^="${q}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!Xe.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(K)?.startsWith(q))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),(0,f.mirrorKey)(e.key,(0,f.isRtl)(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n[n.length-1]);break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(K)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(K):null}_draw(){if(this._card&&=((0,d.closeAnchoredPopover)(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let t;try{t=this._compose()}catch(e){(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),t=[this._stateBlock(`error`,G().errorText)]}if(this.replaceChildren(...t),this._card){let e=(0,i.must)(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),(0,d.openAnchoredPopover)(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let n=[...this.querySelectorAll(`[${K}]`)].find(t=>t.getAttribute(K)===e);n instanceof HTMLElement&&(e.startsWith(q)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Qe(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),De(e);let t=e.layout??`table`,n=g[t],r=G(),a=O(e.today??_e()),o=this._zoom,s=o===`week`&&t===`lanes`?e.weeks:void 0,c=he(e.holidays),l=j(o,this._fromMs??(s===void 0?ve(o,a):j(o,a))),u={layout:t,zoom:o,fromMs:l,todayMs:a,weeks:s,holidays:c};this._resolved=u,this._specRows=e.rows;let d=e.rows.some(e=>e.start!==void 0||e.bars!==void 0),f=(e.state??`ready`)===`ready`&&!d?`empty`:e.state??`ready`;this.dataset.state=f,this.dataset.zoom=o,this.dataset.layout=t,f===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let p=f===`ready`?je({...e,folded:[...this._folded],selected:this._selected},u):null,m=p?.axis??we(t,o,l,{weeks:s,holidays:c}),_=(0,i.make)(`div`,{class:`wui-gantt-lane`});_.style.width=X(m.width),p?this._fillLane(_,e,p):f===`loading`&&(_.style.height=X(Y*n.rowH));let v=[];f===`loading`&&v.push(this._fillSkeleton(_,e,n)),f===`empty`&&v.push(this._emptyBlock(e)),f===`error`&&v.push(this._stateBlock(`error`,e.errorText||r.errorText));let y=this._head(m),b=(0,i.make)(`div`,{class:`wui-gantt-plot`});b.append(y,_);let x=(0,i.make)(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=Le({title:e.title,rows:p?.rows??[],headHeight:2*h.tierH,selected:this._selected,text:r,focusAttr:K,skeleton:f===`loading`?{rows:Y,rowHeight:n.rowH,barHeight:n.barH}:void 0});x.append(t,b)}else{let t=p?this._nameColumn(p,e):null;x.append(...t?[t]:[],b)}return[this._toolbar(e,f===`ready`),x,...v,this._legend(t)]}_nameColumn(e,t){let n=e.rows.filter(e=>e.kind===`lane`);if(e.count===null&&n.length===0)return null;let r=(0,i.make)(`div`,{class:`wui-gantt-names`});r.setAttribute(`aria-hidden`,`true`),r.style.paddingTop=X(2*h.tierH);let a=(0,i.make)(`div`,{class:`wui-gantt-names-rows`});a.style.height=X(e.height),e.count&&a.append(this._nameCell(e.count.top,e.count.height,t.countLabel||G().countLabel));for(let e of n)a.append(this._nameCell(e.top,e.height,e.row.name));return r.append(a),r}_nameCell(e,t,n){let r=(0,i.make)(`div`,{class:`wui-gantt-name`},n);return r.style.top=X(e),r.style.height=X(t),r}_countRow(e,t){let n=e.count,r=(0,i.make)(`div`,{class:`wui-gantt-counts`});return r.setAttribute(`role`,`listitem`),r.setAttribute(`aria-label`,t.countLabel||G().countLabel),r.style.top=X(n?.top??0),r.style.height=X(n?.height??0),r.style.width=X(e.axis.width),(n?.counts??[]).forEach((t,n)=>{if(t===0)return;let a=(0,i.make)(`span`,{class:`wui-gantt-count-cell`},String(t));a.style.left=X(e.axis.x(e.axis.startMs)+n*e.axis.ppd),a.style.width=X(e.axis.ppd),r.append(a)}),r}_drawLane(e,t,n){let r=G();e.setAttribute(`aria-label`,t.row.name);for(let a of t.clashes??[]){let o=(0,i.make)(`div`,{class:`wui-gantt-clash`},n.clashLabel||r.clashLabel);o.setAttribute(`aria-hidden`,`true`),o.style.left=X(a.x),o.style.top=X(t.top),o.style.width=X(a.w),o.style.height=X(t.height),e.append(o)}for(let n of t.bars??[]){if(n.hidden)continue;let t=(0,i.make)(`span`,{class:`wui-gantt-lane-bar`},n.label);t.dataset.tone=n.tone,n.half!==void 0&&(t.dataset.half=n.half),t.title=n.label,t.style.left=X(n.x),t.style.top=X(n.top),t.style.width=X(n.w),t.style.height=X(n.height),e.append(t)}}_toolbar(e,t){let n=(0,i.make)(`div`,{class:`wui-gantt-toolbar`});return t&&n.append((0,i.make)(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=G(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,O(e.start??``)),a=Math.max(a,O(e.end??e.start??``));return[(0,l.pluralText)(t,`summaryTasks`,n.length-r),(0,l.pluralText)(t,`summaryMilestones`,r),(0,l.fillText)(t.summaryRange,{from:k(i),to:k(a)})].join(`, `)}_scale(){let e=G(),t=(0,i.make)(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign((0,i.make)(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of qe){let r=(0,i.make)(`label`,{class:`segmented-option`}),a=(0,i.make)(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(K,`zoom:${e}`),r.append(a,n[e]),t.append(r)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=X(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let e=G(),t=(0,i.make)(`div`,{class:`wui-gantt-nav`}),r=(e,t,r)=>{let a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,t),a.setAttribute(K,e);let o=(0,c.glyphNode)(r,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},e.todayLabel);return a.type=`button`,a.setAttribute(K,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),a),t}_head(e){let t=(0,i.make)(`div`,{class:`wui-gantt-head`});t.style.width=X(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=(0,i.make)(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=(0,i.make)(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=X(t.x),e.style.width=X(t.w),t.sub&&e.append((0,i.make)(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=G(),n=(0,i.make)(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=(0,i.make)(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=(0,i.make)(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,r(t,Z(e))}let a=(0,i.make)(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,r(a,t.milestoneLabel),e===`table`){let e=(0,i.make)(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=G(),a=(0,i.make)(`div`,{class:`wui-gantt-state`});if(e===`error`){a.setAttribute(`role`,`alert`),a.append((0,i.make)(`p`,null,t));let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},r.retryLabel);e.type=`button`,e.setAttribute(K,`retry`),a.append(e)}else a.append((0,i.make)(`p`,null,t));return a}_emptyBlock(e){let t=G(),r=(0,i.make)(`div`,{class:`wui-gantt-state`});if(r.append((0,i.make)(`p`,{class:`fw-semibold`},t.emptyTitle),(0,i.make)(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`primary`,`solid`,`sm`)},t.addTaskLabel);e.type=`button`,e.setAttribute(K,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=(0,i.make)(`div`,{class:`visually-hidden`},t.loadingText||G().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<Y;t+=1){let r=(0,i.make)(`div`,{class:`wui-gantt-skeleton`});r.style.top=X(t*n.rowH+n.barTop),r.style.left=X(40+t*60),r.style.width=X(240),r.style.height=X(n.barH),r.setAttribute(`aria-hidden`,`true`),e.append(r)}return r}_fillLane(e,t,n){let r=G(),{axis:a}=n,o=n.layout===`table`;e.style.height=X(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=(0,i.make)(`p`,{class:`visually-hidden`},o?r.helpTextTable:r.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,r,a)=>{let o=(0,i.make)(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=X(t),o.style.top=X(n),o.style.width=X(r),o.style.height=X(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=(0,i.make)(`div`,{class:`wui-gantt-today-flag rounded-pill`},r.todayLabel);e.style.left=X(n.today.x),l.push(e)}n.count&&l.push(this._countRow(n,t));let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let r=(0,i.make)(`div`,{class:`wui-gantt-item`});r.setAttribute(`role`,`listitem`),r.style.display=`contents`,e.kind===`group`?this._drawGroup(r,e,n):e.kind===`milestone`?this._drawMilestone(r,e,u,n):e.kind===`lane`?this._drawLane(r,e,t):this._drawBar(r,e,u,n),l.push(r)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${K}^="${q}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=G(),r=this._names(e,t);if(e.end===void 0){let t=k(O(e.start??``));return r?(0,l.fillText)(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=(0,l.fillText)(n.barLabel,{name:e.name,start:k(O(e.start??``)),end:k(O(e.end)),percent:Q(e),status:Z($(e)).toLowerCase()});return r?(0,l.fillText)(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,r){let a=(0,i.make)(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=$(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(K,`${q}${e.key}`),r?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,r){let a=(0,i.make)(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=X(t),a.style.top=X(n),a.style.height=X(r),a}_drawBar(e,t,n,r){let{row:a}=t,{geometry:o}=r,s=r.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=X(t.x),c.style.width=X(t.w),c.style.top=X(l),c.style.height=X(o.barH);let u=Q(a),d=(0,i.make)(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append((0,i.make)(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+Je,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=h.milestone/2,c=t.top+(a.rowH-h.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=X(t.x-s),l.style.top=X(c),l.style.width=X(h.milestone),l.style.height=X(h.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${k(O(i.start??``))}`,t.x+h.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=X(r.axis.width-(t.x-h.milestone))),e.append(u)}_drawGroup(e,t,n){let r=G(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=(0,i.make)(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=X(8),n.style.top=X(t.top+6);let o=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,(0,l.fillText)(a.folded?r.unfoldLabel:r.foldLabel,{group:a.name})),o.setAttribute(K,`group:${a.name}`);let s=(0,c.glyphNode)(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...s?[s]:[]),n.append(o,(0,i.make)(`span`,null,a.name),(0,i.make)(`span`,null,(0,l.pluralText)(r,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=(0,i.make)(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=X(t.x),o.style.width=X(t.w),o.style.top=X(t.top+n.geometry.groupBarTop),o.style.height=X(h.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(J,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(J,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(J,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(e,t){let r=this._selected,a=r===null?void 0:e.rows.find(e=>e.row.key===r&&(e.kind===`bar`||e.kind===`milestone`)&&!e.hidden);if(!a)return null;let o=G(),{row:s}=a,c=(0,i.make)(`div`,{class:`wui-gantt-details`});c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,s.name),c.style.width=X(Ye);let u=(0,i.make)(`dl`),d=(e,t)=>{u.append((0,i.make)(`dt`,null,e),(0,i.make)(`dd`,null,t))},f=k(O(s.start??``));s.owner&&d(o.detailsOwner,s.owner),d(o.detailsDates,s.end===void 0?f:(0,l.fillText)(o.detailsRange,{start:f,end:k(O(s.end))})),s.end!==void 0&&d(o.detailsDone,`${Q(s)}%, ${Z($(s))}`);let p=this._names(s,t);p&&d(o.detailsStartsAfter,p);let m=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return m.type=`button`,m.setAttribute(K,`close`),c.append((0,i.make)(`h3`,{class:`h6`},s.name),u,m),c}};(0,t.defineElement)(`wui-gantt`,et),e.WuiGantt=et})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.zone,WeborityUiElementsInternal.modules.avatarNode,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=globalThis.WeborityUiElementsInternal?.version;if(p!==`0.187.0`)throw Error(`[webority-ui] gantt expects ui-elements 0.187.0 but the page loaded `+p+`.`);var m=864e5,h={groupBarH:6,milestone:14,tierH:28,spanDays:{day:28,week:84},arrow:5,elbow:8},g={table:{rowH:36,groupH:32,barH:20,barTop:8,groupBarTop:13,ppd:{day:22,week:7.3,month:4.9}},lanes:{rowH:40,groupH:52,barH:26,barTop:7,groupBarTop:36,ppd:{day:39,week:13.2,month:9}}},_=4,v=6,y=8,b=90,x=170,ee=6.7,te=16,ne=16,re=6,S=3.5,ie=24,ae=4,C=6,oe=48,se=new Set([`neutral`,`warning`]),ce=new Set([`start`,`end`]),le=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ue=new Set([`day`,`week`,`month`]),de=new Set([`table`,`lanes`]),fe=new Set([`done`,`inProgress`,`atRisk`,`notStarted`]),pe=/^(\d{4})-(\d{2})-(\d{2})$/,me=new Intl.DateTimeFormat(`en-CA`,{timeZone:o.IST_TIME_ZONE,year:`numeric`,month:`2-digit`,day:`2-digit`}),w=class extends Error{};function he(e){return new Set((e??[]).map(O))}var T=e=>le[e]??``,E=e=>String(e).padStart(2,`0`),D=e=>{let t=pe.exec(e);if(!t)return null;let[,n=``,r=``,i=``]=t,a=Number(n),o=Number(r)-1,s=Number(i),c=new Date(0);return c.setUTCFullYear(a,o,s),c.getUTCFullYear()===a&&c.getUTCMonth()===o&&c.getUTCDate()===s?c.getTime():null};function O(e){let t=D(e);if(t===null)throw new w(`"${e}" is not a calendar day.`);return t}function k(e){let t=new Date(e);return`${E(t.getUTCDate())}-${T(t.getUTCMonth())}-${t.getUTCFullYear()}`}function ge(e){let t=new Date(e);return`${String(t.getUTCFullYear()).padStart(4,`0`)}-${E(t.getUTCMonth()+1)}-${E(t.getUTCDate())}`}function _e(e=Date.now()){let t=me.formatToParts(e),n=e=>{let n=t.find(t=>t.type===e);if(!n)throw Error(`The Asia/Kolkata date has no ${e} part.`);return n.value};return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}var A=(e,t)=>{let n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)};function ve(e,t){return e===`day`?t-8*m:e===`week`?j(`week`,t-21*m):A(t,-1)}function j(e,t){return e===`day`?t:e===`week`?t-(new Date(t).getUTCDay()+6)%7*m:A(t,0)}function ye(e,t,n,r){return r===void 0?e===`month`?A(t,_/2*n):t+h.spanDays[e]/2*n*m:t+r*7*n*m}var M=(e,t,n)=>{let r=[],i=e;for(;i<t;){let e=Math.min(n(i),t);r.push({start:i,end:e}),i=e}return r},be=e=>e+m,xe=e=>e+7*m,Se=e=>A(e,1),Ce=e=>Date.UTC(new Date(e).getUTCFullYear()+1,0,1);function we(e,t,n,r={}){let i=r.weeks,a=r.holidays??new Set,o=i===void 0?g[e].ppd[t]:oe,s=i===void 0?t===`month`?A(n,_):n+h.spanDays[t]*m:n+i*7*m,c=(s-n)/m,l=e=>(e-n)/m*o,u=e=>({x:l(e.start),w:(e.end-e.start)/m*o}),d=t===`month`?M(n,s,Ce).map(e=>({...u(e),label:String(new Date(e.start).getUTCFullYear())})):M(n,s,Se).map(e=>{let t=u(e),n=new Date(e.start),r=T(n.getUTCMonth());return{...t,label:t.w<b?r:`${r} ${n.getUTCFullYear()}`}}),f=[];if(t===`day`||i!==void 0)for(let e of M(n,s,be)){let t=new Date(e.start),n=t.getUTCDay();f.push({...u(e),label:String(t.getUTCDate()),sub:`MTWTFSS`.charAt((n+6)%7),weekend:n===0||n===6||a.has(e.start)})}else if(t===`week`)for(let e of M(n,s,xe))f.push({...u(e),label:E(new Date(e.start).getUTCDate())});else for(let e of M(n,s,Se))f.push({...u(e),label:T(new Date(e.start).getUTCMonth())});return{startMs:n,endMs:s,days:c,width:c*o,ppd:o,x:l,top:d,bottom:f,gridX:f.map(e=>e.x),weekendX:f.filter(e=>e.weekend===!0).map(e=>e.x)}}var N=(e,t)=>new w(`Gantt row "${e}": ${t}.`),Te=e=>{if(D(e)===null)throw new w(`Gantt holiday "${e}" is not a calendar day.`)},Ee=(e,t)=>{let n=P(e,`start`,t.start);if(P(e,`end`,t.end)<n)throw N(e,`bar end "${t.end}" is before its start "${t.start}"`);if(t.label.trim()===``)throw N(e,`a bar has an empty label`);if(!se.has(t.tone))throw N(e,`bar tone "${String(t.tone)}" is not neutral or warning`);if(t.half!==void 0&&!ce.has(t.half))throw N(e,`bar half "${String(t.half)}" is not start or end`)},P=(e,t,n)=>{let r=D(n);if(r===null)throw N(e,`${t} "${n}" is not a calendar day`);return r};function De(e){if(e.layout!==void 0&&!de.has(e.layout))throw new w(`Gantt layout "${e.layout}" is not table or lanes.`);if(e.zoom!==void 0&&!ue.has(e.zoom))throw new w(`Gantt zoom "${e.zoom}" is not day, week or month.`);if(e.weeks!==void 0){if(e.weeks!==1&&e.weeks!==2)throw new w(`Gantt weeks "${String(e.weeks)}" is not 1 or 2.`);if((e.zoom??`week`)!==`week`||e.layout!==`lanes`)throw new w(`Gantt weeks needs the week zoom and the lanes layout.`)}for(let t of e.holidays??[])Te(t);let t=new Set;for(let n of e.rows){if(t.has(n.key))throw N(n.key,`key is used by more than one row`);if(t.add(n.key),n.name.trim()===``)throw N(n.key,`name is empty`);if(n.end!==void 0&&n.start===void 0)throw N(n.key,`end is set without a start`);if(n.start!==void 0){let e=P(n.key,`start`,n.start);if(n.end!==void 0&&P(n.key,`end`,n.end)<e)throw N(n.key,`end "${n.end}" is before start "${n.start}"`)}if(n.progress!==void 0&&!(Number.isInteger(n.progress)&&n.progress>=0&&n.progress<=100))throw N(n.key,`progress ${n.progress} is not a whole number from 0 to 100`);if(n.status!==void 0&&!fe.has(n.status))throw N(n.key,`status "${n.status}" is not a known status`);if(n.bars!==void 0){if(n.start!==void 0||n.end!==void 0)throw N(n.key,`bars and a start or end cannot both be set`);if(n.dependsOn!==void 0&&n.dependsOn.length>0)throw N(n.key,`a row with bars takes no dependsOn`);if(e.layout!==`lanes`)throw N(n.key,`bars need the lanes layout`);for(let e of n.bars)Ee(n.key,e)}}let n=new Map;for(let t of e.rows)n.set(t.key,t);for(let t of e.rows)for(let e of t.dependsOn??[]){if(e===t.key)throw N(t.key,`depends on itself`);if(!n.has(e))throw N(t.key,`depends on "${e}", which is no row`);if(n.get(e)?.bars!==void 0)throw N(t.key,`depends on "${e}", which has bars`)}let r=new Map,i=e=>(r.set(e,`onPath`),{key:e,deps:n.get(e)?.dependsOn??[],next:0});for(let t of e.rows){if(r.has(t.key))continue;let e=[i(t.key)];for(;e.length>0;){let t=e[e.length-1];if(!t)break;let n=t.deps[t.next];if(n===void 0){r.set(t.key,`done`),e.pop();continue}t.next++;let a=r.get(n);if(a===`onPath`)throw N(n,`dependencies form a loop`);a===void 0&&e.push(i(n))}}}function Oe(e,t,n){return ee*(e.length+String(t).length+4)+te<=n?`inside`:`after`}function ke(e,t){let{arrow:n,elbow:r}=h;return{d:t.l-e.r>=ne?`M${e.r} ${e.y} H${e.r+r} V${t.y} H${t.l-n}`:`M${e.r} ${e.y} H${e.r+re} V${(e.y+t.y)/2} H${t.l-r} V${t.y} H${t.l-n}`,head:`${t.l-n},${t.y-S} ${t.l},${t.y} ${t.l-n},${t.y+S}`}}var F=(e,t,n,r,i)=>({row:e,kind:t,index:n,top:r,height:i,x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!0}),I=(e,t)=>Math.round((t-e.startMs)/m),L=(e,t,n)=>[Math.max(0,I(e,t)),Math.min(e.days,I(e,n))];function Ae(e,t,n,r,i){let a=(e.bars??[]).map((e,t)=>({bar:e,i:t,s:O(e.start),e:O(e.end)+m})).sort((e,t)=>e.s-t.s||e.i-t.i),o=[],s=[],c=Array(r.days).fill(0);for(let e of a){let t=o.findIndex(t=>t<=e.s);t===-1?(t=o.length,o.push(e.e)):o[t]=e.e;let a=r.x(e.s)+(e.bar.half===`start`?r.ppd/2:0),l=r.x(e.e)-(e.bar.half===`end`?r.ppd/2:0),u=a>=r.width||l<=0,d=Math.max(a,0),f=Math.min(l,r.width);s.push({index:e.i,label:e.bar.label,tone:e.bar.tone,half:e.bar.half,top:n+ae+t*(i.barH+C),height:i.barH,x:u?0:d,w:u?0:Math.max(f-d,v),clippedLeft:a<0,clippedRight:l>r.width,hidden:u});let[p,m]=L(r,e.s,e.e);for(let e=p;e<m;e++)c[e]=(c[e]??0)+1}let l=[];for(let e=0;e<c.length;e++){if((c[e]??0)<2)continue;let t=e;for(;t<c.length&&(c[t]??0)>=2;)t++;l.push({x:r.x(r.startMs+e*m),w:(t-e)*r.ppd}),e=t}let u=o.length;return{row:e,kind:`lane`,index:t,top:n,height:Math.max(i.rowH,8+u*(i.barH+C)-C),x:0,w:0,clippedLeft:!1,clippedRight:!1,hidden:!1,bars:s,clashes:l,subs:u}}function je(e,t){let n=g[t.layout],r=we(t.layout,t.zoom,t.fromMs,{weeks:t.weeks,holidays:t.holidays}),{ppd:i,width:a}=r,o=new Set(e.folded??[]),s=e.rows.map((e,t)=>({row:e,index:t,startMs:e.start===void 0?void 0:O(e.start),endEx:e.end===void 0?void 0:O(e.end)+m})),c=new Map;for(let e of s){let t=e.row.group;if(t===void 0)continue;let n=c.get(t)??{name:t,count:0,sum:0,n:0,emitted:!1};if(c.set(t,n),n.count++,e.startMs!==void 0){let t=e.endEx??e.startMs+864e5;n.startMs=n.startMs===void 0?e.startMs:Math.min(n.startMs,e.startMs),n.endMs=n.endMs===void 0?t:Math.max(n.endMs,t)}e.endEx!==void 0&&(n.sum+=e.row.progress??0,n.n++)}let l=[],u=new Map,d=null,f=0;if(e.rows.some(e=>e.bars!==void 0)){let t=Array(r.days).fill(0);for(let n of e.rows)for(let e of n.bars??[]){let[n,i]=L(r,O(e.start),O(e.end)+m);for(let e=n;e<i;e++)t[e]=(t[e]??0)+1}d={top:0,height:ie,counts:t},f=ie}for(let e of s){let{row:s,index:d}=e,p=s.group===void 0?void 0:c.get(s.group);if(p!==void 0&&!p.emitted){p.emitted=!0;let e=o.has(p.name),t=p.startMs!==void 0&&p.endMs!==void 0,i=p.startMs??r.startMs,c=p.endMs??r.startMs,u=r.x(i),m=r.x(c),h=t&&m>0&&u<a;l.push({row:s,kind:`group`,index:d,top:f,height:n.groupH,x:h?Math.max(u,0):0,w:h?Math.min(m,a)-Math.max(u,0):0,clippedLeft:h&&u<0,clippedRight:h&&m>a,hidden:!1,group:{name:p.name,count:p.count,percent:p.n>0?Math.round(p.sum/p.n):0,folded:e,startMs:i,endMs:c}}),f+=n.groupH}let m=s.group!==void 0&&o.has(s.group);if(s.bars!==void 0){if(m){l.push(F(s,`lane`,d,f,0));continue}let e=Ae(s,d,f,r,n);l.push(e),f+=e.height;continue}let g=e.endEx===void 0?`milestone`:`bar`;if(m){l.push(F(s,g,d,f,0));continue}let _=f;if(f+=n.rowH,e.startMs===void 0){l.push(F(s,g,d,_,n.rowH));continue}let b;if(e.endEx===void 0){let o=r.x(e.startMs)+i/2;b=o<-8||o>a+y?F(s,g,d,_,n.rowH):{row:s,kind:g,index:d,top:_,height:n.rowH,x:o,w:h.milestone,clippedLeft:!1,clippedRight:!1,hidden:!1,flip:t.layout===`lanes`&&o>a-x}}else{let i=r.x(e.startMs),o=Math.max(r.x(e.endEx)-i,v);if(i>=a||i+o<=0)b=F(s,g,d,_,n.rowH);else{let e=Math.max(i,0),r=Math.min(i+o,a),c=i<0,l=i+o>a;r-e<v&&(c?r=Math.min(v,a):e=Math.max(0,r-v)),b={row:s,kind:g,index:d,top:_,height:n.rowH,x:e,w:r-e,clippedLeft:c,clippedRight:l,hidden:!1},t.layout===`lanes`&&(b.place=Oe(s.name,s.progress??0,r-e))}}l.push(b),b.hidden||u.set(s.key,b)}let p=[];for(let e of l){if(e.kind!==`bar`&&e.kind!==`milestone`||e.hidden)continue;let t=e.kind===`milestone`?e.x-y:e.x,r=new Set;for(let i of e.row.dependsOn??[]){let a=u.get(i);if(a===void 0||r.has(i))continue;r.add(i);let o=ke({r:a.kind===`milestone`?a.x+y:a.x+a.w,y:a.top+n.rowH/2},{l:t,y:e.top+n.rowH/2});p.push({fromKey:i,toKey:e.row.key,d:o.d,head:o.head})}}return{layout:t.layout,geometry:n,axis:r,rows:l,height:f,today:{x:r.x(t.todayMs)+i/2,inWindow:t.todayMs>=r.startMs&&t.todayMs<r.endMs},arrows:p,count:d}}var Me=new Set([`pvt`,`private`,`ltd`,`limited`,`llp`,`llc`,`inc`,`corp`,`co`]),R=/\p{L}/u,Ne=/\p{N}/u;function Pe(e){let t=``,n=0;for(let r of e)r===`(`?(n+=1,t+=` `):r===`)`?(n=Math.max(0,n-1),t+=` `):n===0&&(t+=r);return t}function z(e,t,n){let r=e[t];if(r===void 0)throw Error(`initialsOf: the ${n} is missing`);return r}function B(e){return e.map(e=>{let t=e.toUpperCase();return Array.from(t).length===1?t:e}).join(``)}function Fe(e,t=2){let n=Pe(String(e??``)).split(/\s+/),r=e=>n.map(t=>Array.from(t).filter(t=>e.test(t))).filter(e=>e.length>0),i=r(R).filter(e=>!Me.has(e.join(``).toLowerCase()));if(i.length===0&&!n.some(e=>R.test(e))&&(i=r(Ne)),i.length===0)return``;let a=z(i,0,`first word`);if(i.length===1)return B(a.slice(0,t));let o=z(i,1,`second word`);return B([z(a,0,`first letter`),z(o,0,`second letter`)])}var Ie=`data-wui-gantt-pick`,V=e=>`${e}px`,H=(e,t,n)=>{let r=(0,i.make)(`div`,{class:`wui-gantt-table-cell`},n);return r.setAttribute(`role`,t),r.dataset.col=e,r};function Le(e){let t=e.text,n=(0,i.make)(`div`,{class:`wui-gantt-table`});n.setAttribute(`role`,`table`),n.setAttribute(`aria-label`,e.title);let r=(0,i.make)(`div`);r.setAttribute(`role`,`rowgroup`);let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`head`,a.setAttribute(`role`,`row`),a.style.height=V(e.headHeight),a.append(H(`name`,`columnheader`,t.tableName),H(`owner`,`columnheader`,t.detailsOwner),H(`start`,`columnheader`,t.tableStart),H(`end`,`columnheader`,t.tableEnd),H(`done`,`columnheader`,t.detailsDone)),r.append(a);let o=(0,i.make)(`div`);o.setAttribute(`role`,`rowgroup`);for(let n of e.rows){if(n.height===0)continue;let r=n.row;if(n.kind===`group`){let r=n.group;if(!r)continue;let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=`group`,a.dataset.wuiGanttGroup=r.name,a.setAttribute(`role`,`row`),a.style.height=V(n.height);let s=(0,i.make)(`div`,{class:`wui-gantt-table-cell wui-gantt-table-group`});s.setAttribute(`role`,`rowheader`);let u=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});u.type=`button`,u.setAttribute(`aria-expanded`,String(!r.folded)),u.setAttribute(`aria-label`,(0,l.fillText)(r.folded?t.unfoldLabel:t.foldLabel,{group:r.name})),u.setAttribute(e.focusAttr,`group:${r.name}`);let d=(0,c.glyphNode)(r.folded?`chevron-right`:`chevron-down`,{size:16});u.replaceChildren(...d?[d]:[]),s.append(u,(0,i.make)(`span`,null,r.name),(0,i.make)(`span`,null,(0,l.pluralText)(t,`groupSummary`,r.count,{percent:r.percent}))),a.append(s),o.append(a);continue}let a=(0,i.make)(`div`,{class:`wui-gantt-table-row`});a.dataset.kind=r.end===void 0?`milestone`:`bar`,a.dataset.wuiGanttKey=r.key,a.dataset.wuiGanttPick=r.key,r.key===e.selected&&(a.dataset.selected=`true`),a.setAttribute(`role`,`row`),a.style.height=V(n.height);let u=H(`name`,`rowheader`,r.name);u.title=r.name;let d=H(`owner`,`cell`,``);r.owner&&(d.title=r.owner,d.replaceChildren(...[(0,s.avatarNode)({initials:Fe(r.owner)},`avatar-xs`)].filter(e=>e!==null)),d.append((0,i.make)(`span`,{class:`visually-hidden`},r.owner)));let f=H(`start`,`cell`,r.start===void 0?``:k(O(r.start))),p=H(`end`,`cell`,r.end===void 0?``:k(O(r.end))),m=H(`done`,`cell`,r.end===void 0?``:`${r.progress??0}%`);a.append(u,d,f,p,m),o.append(a)}let u=e.skeleton;for(let e=0;u&&e<u.rows;e+=1){let e=(0,i.make)(`div`,{class:`wui-gantt-table-row`});e.dataset.kind=`skeleton`,e.setAttribute(`role`,`row`),e.setAttribute(`aria-hidden`,`true`),e.style.height=V(u.rowHeight);let t=(0,i.make)(`span`,{class:`wui-gantt-skeleton`});t.style.height=V(u.barHeight),e.append(t),o.append(e)}return n.append(r,o),n}var Re={addTaskLabel:`Add task`,barLabel:`{name}, {start} to {end}, {percent} percent, {status}`,barLabelAfter:`{label}, after {names}`,clashLabel:`Clash`,countLabel:`Count`,dayLabel:`Day`,detailsCloseLabel:`Close details`,detailsDates:`Dates`,detailsDone:`Done`,detailsOwner:`Owner`,detailsRange:`{start} to {end}`,detailsStartsAfter:`Starts after`,earlierLabel:`Earlier`,emptyText:`Add a task with a start and an end date and it is drawn here as a bar.`,emptyTitle:`No tasks on the plan yet`,errorText:`The plan did not load. Check your connection and try again.`,foldLabel:`Fold {group}`,groupSummaryOne:`{count} item, {percent}% done`,groupSummaryOther:`{count} items, {percent}% done`,helpText:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to move along a row. Press Enter to open the details and Escape to close them.`,helpTextTable:`Use the Up and Down arrow keys to move between bars and the Left and Right keys to follow a dependency. Press Enter to choose a row and Escape to clear the choice.`,laterLabel:`Later`,legendLabel:`Key`,legendRemaining:`Lighter part of a bar is work still to do`,loadingText:`Loading plan`,milestoneBarLabel:`{name}, {date}, milestone, after {names}`,milestoneLabel:`Milestone`,monthLabel:`Month`,retryLabel:`Try again`,scaleLabel:`Time scale`,statusAtRisk:`At risk`,statusDone:`Done`,statusInProgress:`In progress`,statusNotStarted:`Not started`,summaryMilestonesOne:`{count} milestone`,summaryMilestonesOther:`{count} milestones`,summaryRange:`{from} to {to}`,summaryTasksOne:`{count} task`,summaryTasksOther:`{count} tasks`,tableEnd:`End`,tableName:`Task`,tableStart:`Start`,tableStatus:`Status`,todayLabel:`Today`,unfoldLabel:`Unfold {group}`,weekLabel:`Week`};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function ze(e,t){if(U(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Be(e){var t=ze(e,`string`);return U(t)==`symbol`?t:t+``}function W(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=()=>(0,l.readText)(`gantt`,Re),Ve=`wui-gantt:zoom-change`,He=`wui-gantt:from-change`,Ue=`wui-gantt:fold-change`,We=`wui-gantt:select`,Ge=`wui-gantt:add-task`,Ke=`wui-gantt:retry`,K=`data-wui-gantt-focus`,q=`bar:`,J=`http://www.w3.org/2000/svg`,qe=[`day`,`week`,`month`],Y=3,Je=16,Ye=300,Xe=[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`Escape`,`Enter`,` `],Ze=0,X=e=>`${e}px`;function Qe(e){return typeof e==`object`&&!!e&&`rows`in e&&Array.isArray(e.rows)&&`title`in e&&typeof e.title==`string`}function Z(e){let t=G();switch(e){case`done`:return t.statusDone;case`inProgress`:return t.statusInProgress;case`atRisk`:return t.statusAtRisk;case`notStarted`:return t.statusNotStarted;default:throw RangeError(`Unknown gantt status ${String(e)}.`)}}var Q=e=>e.progress??0,$=e=>e.status??`notStarted`,$e=(e,t)=>(e??[]).join(`\0`)===(t??[]).join(`\0`),et=class extends a.ElementBase{constructor(){super(),W(this,`uid`,void 0),W(this,`_spec`,null),W(this,`_prev`,null),W(this,`_zoom`,`week`),W(this,`_fromMs`,null),W(this,`_folded`,new Set),W(this,`_selected`,null),W(this,`_controlled`,!1),W(this,`_awaitingSpec`,!1),W(this,`_connected`,!1),W(this,`_focusAfter`,null),W(this,`_resolved`,null),W(this,`_specRows`,[]),W(this,`_card`,null),W(this,`_onClick`,void 0),W(this,`_onKeyDown`,void 0),W(this,`_onChange`,void 0),Ze+=1,this.uid=`wui-gantt-${Ze}`,this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onChange=e=>this._handleChange(e)}get spec(){return this._spec}set spec(e){this._spec=e??null,this._connected&&this._draw()}connectedCallback(){if((0,u.hasOwn)(this,`spec`)){let e=this.spec;delete this.spec,this._spec=e??null}this._spec??=this._readScript(),this._spec==null&&!this.querySelector(`:scope > script[type='application/json']`)&&(this._awaitingSpec=!0,queueMicrotask(()=>{this._awaitingSpec=!1,this._connected&&this._draw()})),this.classList.add(`wui-gantt`),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`change`,this._onChange),this._connected=!0,this._draw()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`change`,this._onChange),this._card&&=((0,d.closeAnchoredPopover)(this._card),this._card.remove(),null),this._connected=!1}_readScript(){let e=this.querySelector(`:scope > script[type="application/json"]`);if(!(e instanceof HTMLScriptElement))return null;try{return JSON.parse(String(e.textContent))}catch(e){return(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not read its JSON spec:`,e instanceof Error?e.message:void 0),null}}_seed(e){let t=this._prev;this._controlled=e.controlled===!0;let n=e=>this._controlled||t===null||e;n(t?.zoom!==e.zoom)&&(this._zoom=e.zoom??`week`),n(t?.from!==e.from)&&(this._fromMs=e.from?O(e.from):null),n(!$e(t?.folded,e.folded))&&(this._folded=new Set(e.folded??[])),n(t?.selected!==e.selected)&&(this._selected=e.selected??null),this._prev=e}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_setZoom(e){this._emit(Ve,{zoom:e}),this._controlled?this._syncRadios():(this._zoom=e,this._fromMs=this._fromMs===null?null:j(e,this._fromMs),this._draw())}_setFrom(e){this._emit(He,{from:ge(e)}),this._controlled||(this._fromMs=e,this._draw())}_setFolded(e){let t=new Set(this._folded);t.delete(e)||t.add(e),this._emit(Ue,{folded:[...t]}),this._controlled||(this._folded=t,this._draw())}_setSelected(e){this._emit(We,{key:e}),this._focusAfter=`${q}${e??this._selected??``}`,this._controlled||(this._selected=e),this._draw()}_syncRadios(){for(let e of this.querySelectorAll(`.segmented-input`))e.checked=e.value===this._zoom}_handleChange(e){let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-gantt-scale .segmented-input`))return;let n=qe.find(e=>e===t.value);n&&this._setZoom(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[${K}]`);if(n instanceof HTMLElement&&this.contains(n)){this._activate(n.getAttribute(K)??``,n);return}let r=t.closest(`[${Ie}]`);if(!(r instanceof HTMLElement)||!this.contains(r))return;let i=r.getAttribute(`data-wui-gantt-pick`)??``;this._setSelected(i===this._selected?null:i)}_activate(e,t){let n=this._resolved;if(e.startsWith(q)){let t=e.slice(4);this._setSelected(t===this._selected?null:t)}else e.startsWith(`group:`)?this._setFolded(e.slice(6)):e===`close`?this._setSelected(null):e===`add`?this._emit(Ge):e===`retry`?this._emit(Ke):n&&e===`nav:earlier`?this._setFrom(ye(n.zoom,n.fromMs,-1,n.weeks)):n&&e===`nav:later`?this._setFrom(ye(n.zoom,n.fromMs,1,n.weeks)):n&&e===`nav:today`?this._setFrom(n.weeks===void 0?ve(n.zoom,n.todayMs):j(n.zoom,n.todayMs)):e.startsWith(`zoom:`)&&t.click()}_bars(){return[...this.querySelectorAll(`.wui-gantt-lane [${K}^="${q}"]`)].filter(e=>e instanceof HTMLElement)}_focusBar(e){if(e){for(let t of this._bars())t.tabIndex=t===e?0:-1;e.focus()}}_barByKey(e){return e===void 0?void 0:this._bars().find(t=>t.dataset.wuiGanttKey===e)}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey||!Xe.includes(e.key))return;if(e.key===`Escape`){if(this._selected===null)return;e.preventDefault(),this._setSelected(null);return}let t=e.target;if(!(t instanceof HTMLElement)||!t.getAttribute(K)?.startsWith(q))return;let n=this._bars(),r=n.indexOf(t),i=t.dataset.wuiGanttKey,a=this._specRows.find(e=>e.key===i);switch(e.preventDefault(),(0,f.mirrorKey)(e.key,(0,f.isRtl)(this))){case`ArrowDown`:this._focusBar(n[r+1]);break;case`ArrowUp`:this._focusBar(n[r-1]);break;case`Home`:this._focusBar(n[0]);break;case`End`:this._focusBar(n[n.length-1]);break;case`ArrowLeft`:this._focusBar((a?.dependsOn??[]).map(e=>this._barByKey(e)).find(e=>e));break;case`ArrowRight`:this._focusBar(this._specRows.filter(e=>e.dependsOn?.includes(i??``)).map(e=>this._barByKey(e.key)).find(e=>e));break;default:this._activate(t.getAttribute(K)??``,t)}}_focusToken(){let e=document.activeElement;return e instanceof HTMLElement&&this.contains(e)?e.getAttribute(K):null}_draw(){if(this._card&&=((0,d.closeAnchoredPopover)(this._card),this._card.remove(),null),this._spec==null&&this._awaitingSpec)return;let e=this._focusAfter??this._focusToken();this._focusAfter=null;let t;try{t=this._compose()}catch(e){(0,r.devError)(`[@webority/ui-elements] <wui-gantt> could not draw its spec:`,e instanceof Error?e.message:void 0),this._resolved=null,this._specRows=[],this._card=null,this.dataset.state=`error`,this.removeAttribute(`aria-busy`),t=[this._stateBlock(`error`,G().errorText)]}if(this.replaceChildren(...t),this._card){let e=(0,i.must)(this._barByKey(this._selected??void 0),`selected gantt bar`);this.append(this._card),(0,d.openAnchoredPopover)(e,this._card,{mode:`manual`,side:`auto`,align:`start`,flipAlign:!0,gap:4,keepOffscreen:!0})}if(this._placeThumb(),e===null)return;let n=[...this.querySelectorAll(`[${K}]`)].find(t=>t.getAttribute(K)===e);n instanceof HTMLElement&&(e.startsWith(q)?this._focusBar(n):n.focus())}_compose(){let e=this._spec;if(!Qe(e))throw TypeError("<wui-gantt> has no spec: set the `spec` property or add a JSON script child.");this._seed(e),De(e);let t=e.layout??`table`,n=g[t],r=G(),a=O(e.today??_e()),o=this._zoom,s=o===`week`&&t===`lanes`?e.weeks:void 0,c=he(e.holidays),l=j(o,this._fromMs??(s===void 0?ve(o,a):j(o,a))),u={layout:t,zoom:o,fromMs:l,todayMs:a,weeks:s,holidays:c};this._resolved=u,this._specRows=e.rows;let d=e.rows.some(e=>e.start!==void 0||e.bars!==void 0),f=(e.state??`ready`)===`ready`&&!d?`empty`:e.state??`ready`;this.dataset.state=f,this.dataset.zoom=o,this.dataset.layout=t,f===`loading`?this.setAttribute(`aria-busy`,`true`):this.removeAttribute(`aria-busy`);let p=f===`ready`?je({...e,folded:[...this._folded],selected:this._selected},u):null,m=p?.axis??we(t,o,l,{weeks:s,holidays:c}),_=(0,i.make)(`div`,{class:`wui-gantt-lane`});_.style.width=X(m.width),p?this._fillLane(_,e,p):f===`loading`&&(_.style.height=X(Y*n.rowH));let v=[];f===`loading`&&v.push(this._fillSkeleton(_,e,n)),f===`empty`&&v.push(this._emptyBlock(e)),f===`error`&&v.push(this._stateBlock(`error`,e.errorText||r.errorText));let y=this._head(m),b=(0,i.make)(`div`,{class:`wui-gantt-plot`});b.append(y,_);let x=(0,i.make)(`div`,{class:`wui-gantt-scroller`});if(t===`table`){let t=Le({title:e.title,rows:p?.rows??[],headHeight:2*h.tierH,selected:this._selected,text:r,focusAttr:K,skeleton:f===`loading`?{rows:Y,rowHeight:n.rowH,barHeight:n.barH}:void 0});x.append(t,b)}else{let t=p?this._nameColumn(p,e):null;x.append(...t?[t]:[],b)}return[this._toolbar(e,f===`ready`),x,...v,this._legend(t)]}_nameColumn(e,t){let n=e.rows.filter(e=>e.kind===`lane`);if(e.count===null&&n.length===0)return null;let r=(0,i.make)(`div`,{class:`wui-gantt-names`});r.setAttribute(`aria-hidden`,`true`),r.style.paddingTop=X(2*h.tierH);let a=(0,i.make)(`div`,{class:`wui-gantt-names-rows`});a.style.height=X(e.height),e.count&&a.append(this._nameCell(e.count.top,e.count.height,t.countLabel||G().countLabel));for(let e of n)a.append(this._nameCell(e.top,e.height,e.row.name));return r.append(a),r}_nameCell(e,t,n){let r=(0,i.make)(`div`,{class:`wui-gantt-name`},n);return r.style.top=X(e),r.style.height=X(t),r}_countRow(e,t){let n=e.count,r=(0,i.make)(`div`,{class:`wui-gantt-counts`});return r.setAttribute(`role`,`listitem`),r.setAttribute(`aria-label`,t.countLabel||G().countLabel),r.style.top=X(n?.top??0),r.style.height=X(n?.height??0),r.style.width=X(e.axis.width),(n?.counts??[]).forEach((t,n)=>{if(t===0)return;let a=(0,i.make)(`span`,{class:`wui-gantt-count-cell`},String(t));a.style.left=X(e.axis.x(e.axis.startMs)+n*e.axis.ppd),a.style.width=X(e.axis.ppd),r.append(a)}),r}_drawLane(e,t,n){let r=G();e.setAttribute(`aria-label`,t.row.name);for(let a of t.clashes??[]){let o=(0,i.make)(`div`,{class:`wui-gantt-clash`},n.clashLabel||r.clashLabel);o.setAttribute(`aria-hidden`,`true`),o.style.left=X(a.x),o.style.top=X(t.top),o.style.width=X(a.w),o.style.height=X(t.height),e.append(o)}for(let n of t.bars??[]){if(n.hidden)continue;let t=(0,i.make)(`span`,{class:`wui-gantt-lane-bar`},n.label);t.dataset.tone=n.tone,n.half!==void 0&&(t.dataset.half=n.half),t.title=n.label,t.style.left=X(n.x),t.style.top=X(n.top),t.style.width=X(n.w),t.style.height=X(n.height),e.append(t)}}_toolbar(e,t){let n=(0,i.make)(`div`,{class:`wui-gantt-toolbar`});return t&&n.append((0,i.make)(`p`,{class:`wui-gantt-count`},this._countText(e.rows))),n.append(this._scale(),this._nav()),n}_countText(e){let t=G(),n=e.filter(e=>e.start!==void 0),r=n.filter(e=>e.end===void 0).length,i=1/0,a=-1/0;for(let e of n)i=Math.min(i,O(e.start??``)),a=Math.max(a,O(e.end??e.start??``));return[(0,l.pluralText)(t,`summaryTasks`,n.length-r),(0,l.pluralText)(t,`summaryMilestones`,r),(0,l.fillText)(t.summaryRange,{from:k(i),to:k(a)})].join(`, `)}_scale(){let e=G(),t=(0,i.make)(`div`,{class:`segmented segmented-sm wui-gantt-scale`});t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-label`,e.scaleLabel),t.append(Object.assign((0,i.make)(`span`,{class:`segmented-thumb`}),{ariaHidden:`true`}));let n={day:e.dayLabel,week:e.weekLabel,month:e.monthLabel};for(let e of qe){let r=(0,i.make)(`label`,{class:`segmented-option`}),a=(0,i.make)(`input`,{class:`segmented-input`});a.type=`radio`,a.name=`${this.uid}-scale`,a.value=e,a.checked=e===this._zoom,a.setAttribute(K,`zoom:${e}`),r.append(a,n[e]),t.append(r)}return t}_placeThumb(){let e=this.querySelector(`.wui-gantt-scale`),t=e?.querySelector(`.segmented-thumb`),n=e?.querySelector(`.segmented-option:has(.segmented-input:checked)`);e instanceof HTMLElement&&t instanceof HTMLElement&&n instanceof HTMLElement&&e.offsetWidth&&(t.style.width=X(n.offsetWidth),t.style.transform=`translateX(${n.offsetLeft}px)`,t.style.opacity=`1`)}_nav(){let e=G(),t=(0,i.make)(`div`,{class:`wui-gantt-nav`}),r=(e,t,r)=>{let a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)});a.type=`button`,a.setAttribute(`aria-label`,t),a.setAttribute(K,e);let o=(0,c.glyphNode)(r,{size:16});return a.replaceChildren(...o?[o]:[]),a},a=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},e.todayLabel);return a.type=`button`,a.setAttribute(K,`nav:today`),t.append(r(`nav:earlier`,e.earlierLabel,`chevron-left`),r(`nav:later`,e.laterLabel,`chevron-right`),a),t}_head(e){let t=(0,i.make)(`div`,{class:`wui-gantt-head`});t.style.width=X(e.width),t.setAttribute(`aria-hidden`,`true`);let n=(e,t)=>{let n=(0,i.make)(`div`,{class:`wui-gantt-tier ${t}`});for(let t of e){let e=(0,i.make)(`div`,{class:t.weekend?`wui-gantt-cell wui-gantt-cell-weekend`:`wui-gantt-cell`});e.style.left=X(t.x),e.style.width=X(t.w),t.sub&&e.append((0,i.make)(`small`,null,t.sub)),e.append(t.label),n.append(e)}return n};return t.append(n(e.top,`wui-gantt-tier-top`),n(e.bottom,`wui-gantt-tier-bottom`)),t}_legend(e){let t=G(),n=(0,i.make)(`div`,{class:`wui-gantt-legend`});n.setAttribute(`role`,`list`),n.setAttribute(`aria-label`,t.legendLabel);let r=(e,t)=>{let r=(0,i.make)(`span`,null);r.setAttribute(`role`,`listitem`),r.append(e,t),n.append(r)};for(let e of[`done`,`inProgress`,`atRisk`,`notStarted`]){let t=(0,i.make)(`span`,{class:`wui-gantt-swatch`});t.dataset.status=e,r(t,Z(e))}let a=(0,i.make)(`span`,{class:`wui-gantt-swatch`});if(a.dataset.kind=`milestone`,r(a,t.milestoneLabel),e===`table`){let e=(0,i.make)(`span`,{class:`wui-gantt-legend-note`},t.legendRemaining);e.setAttribute(`role`,`listitem`),n.append(e)}return n}_stateBlock(e,t){let r=G(),a=(0,i.make)(`div`,{class:`wui-gantt-state`});if(e===`error`){a.setAttribute(`role`,`alert`),a.append((0,i.make)(`p`,null,t));let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`soft`,`sm`)},r.retryLabel);e.type=`button`,e.setAttribute(K,`retry`),a.append(e)}else a.append((0,i.make)(`p`,null,t));return a}_emptyBlock(e){let t=G(),r=(0,i.make)(`div`,{class:`wui-gantt-state`});if(r.append((0,i.make)(`p`,{class:`fw-semibold`},t.emptyTitle),(0,i.make)(`p`,null,e.emptyText||t.emptyText)),e.addTask){let e=(0,i.make)(`button`,{class:(0,n.buttonClass)(`primary`,`solid`,`sm`)},t.addTaskLabel);e.type=`button`,e.setAttribute(K,`add`),r.append(e)}return r}_fillSkeleton(e,t,n){let r=(0,i.make)(`div`,{class:`visually-hidden`},t.loadingText||G().loadingText);r.setAttribute(`role`,`status`);for(let t=0;t<Y;t+=1){let r=(0,i.make)(`div`,{class:`wui-gantt-skeleton`});r.style.top=X(t*n.rowH+n.barTop),r.style.left=X(40+t*60),r.style.width=X(240),r.style.height=X(n.barH),r.setAttribute(`aria-hidden`,`true`),e.append(r)}return r}_fillLane(e,t,n){let r=G(),{axis:a}=n,o=n.layout===`table`;e.style.height=X(n.height),e.setAttribute(`role`,`list`),e.setAttribute(`aria-label`,t.title);let s=(0,i.make)(`p`,{class:`visually-hidden`},o?r.helpTextTable:r.helpText);s.id=`${this.uid}-help`,e.setAttribute(`aria-describedby`,s.id);let c=(e,t,n,r,a)=>{let o=(0,i.make)(`div`,{class:e});return o.setAttribute(`aria-hidden`,`true`),o.style.left=X(t),o.style.top=X(n),o.style.width=X(r),o.style.height=X(a),o},l=[s];for(let e of n.rows){if(e.height===0)continue;let t=c(`wui-gantt-row`,0,e.top,a.width,e.height);o&&e.kind!==`group`&&e.row.key===this._selected&&(t.dataset.selected=`true`),l.push(t)}for(let e of a.weekendX)l.push(c(`wui-gantt-weekend`,e,0,a.ppd,n.height));for(let e of a.gridX)l.push(c(`wui-gantt-grid`,e,0,1,n.height));if(n.today.inWindow){l.push(c(`wui-gantt-today`,n.today.x-1,0,2,n.height));let e=(0,i.make)(`div`,{class:`wui-gantt-today-flag rounded-pill`},r.todayLabel);e.style.left=X(n.today.x),l.push(e)}n.count&&l.push(this._countRow(n,t));let u=new Map(t.rows.map(e=>[e.key,e]));for(let e of n.rows){if(e.hidden)continue;let r=(0,i.make)(`div`,{class:`wui-gantt-item`});r.setAttribute(`role`,`listitem`),r.style.display=`contents`,e.kind===`group`?this._drawGroup(r,e,n):e.kind===`milestone`?this._drawMilestone(r,e,u,n):e.kind===`lane`?this._drawLane(r,e,t):this._drawBar(r,e,u,n),l.push(r)}l.push(this._deps(n)),this._card=o?null:this._details(n,u),e.append(...l);let d=e.querySelector(`[${K}^="${q}"]`);d instanceof HTMLElement&&(d.tabIndex=0)}_names(e,t){return(e.dependsOn??[]).map(e=>t.get(e)?.name??e).join(`, `)}_barSentence(e,t){let n=G(),r=this._names(e,t);if(e.end===void 0){let t=k(O(e.start??``));return r?(0,l.fillText)(n.milestoneBarLabel,{name:e.name,date:t,names:r}):`${e.name}, ${t}, ${n.milestoneLabel.toLowerCase()}`}let i=(0,l.fillText)(n.barLabel,{name:e.name,start:k(O(e.start??``)),end:k(O(e.end)),percent:Q(e),status:Z($(e)).toLowerCase()});return r?(0,l.fillText)(n.barLabelAfter,{label:i,names:r}):i}_focusable(e,t,n,r){let a=(0,i.make)(`button`,{class:t});a.type=`button`;let o=this._barSentence(e,n);return a.setAttribute(`aria-label`,o),a.title=o,a.tabIndex=-1,a.dataset.status=$(e),a.dataset.wuiGanttKey=e.key,a.setAttribute(K,`${q}${e.key}`),r?a.setAttribute(`aria-pressed`,String(this._selected===e.key)):a.setAttribute(`aria-expanded`,String(this._selected===e.key)),this._selected===e.key&&(a.dataset.selected=`true`),a}_afterLabel(e,t,n,r){let a=(0,i.make)(`span`,{class:`wui-gantt-label wui-gantt-label-surface`},e);return a.style.left=X(t),a.style.top=X(n),a.style.height=X(r),a}_drawBar(e,t,n,r){let{row:a}=t,{geometry:o}=r,s=r.layout===`table`,c=this._focusable(a,`wui-gantt-bar rounded-2`,n,s),l=t.top+o.barTop;c.style.left=X(t.x),c.style.width=X(t.w),c.style.top=X(l),c.style.height=X(o.barH);let u=Q(a),d=(0,i.make)(`span`,{class:`wui-gantt-bar-progress`});if(d.style.width=`${u}%`,c.append(d),e.append(c),s)return;let f=`${a.name} ${u}%`;t.place===`inside`?c.append((0,i.make)(`span`,{class:`wui-gantt-bar-label`},f)):e.append(this._afterLabel(f,t.x+t.w+Je,l,o.barH))}_drawMilestone(e,t,n,r){let{row:i}=t,{geometry:a}=r,o=r.layout===`table`,s=h.milestone/2,c=t.top+(a.rowH-h.milestone)/2,l=this._focusable(i,`wui-gantt-milestone`,n,o);if(l.style.left=X(t.x-s),l.style.top=X(c),l.style.width=X(h.milestone),l.style.height=X(h.milestone),e.append(l),o)return;let u=this._afterLabel(`${i.name}, ${k(O(i.start??``))}`,t.x+h.milestone,t.top+a.barTop,a.barH);t.flip&&(u.style.left=``,u.style.right=X(r.axis.width-(t.x-h.milestone))),e.append(u)}_drawGroup(e,t,n){let r=G(),a=t.group;if(!a)return;if(n.layout===`lanes`){let n=(0,i.make)(`div`,{class:`wui-gantt-group wui-gantt-label wui-gantt-label-surface`});n.dataset.wuiGanttGroup=a.name,n.style.left=X(8),n.style.top=X(t.top+6);let o=(0,i.make)(`button`,{class:`wui-gantt-group-toggle`});o.type=`button`,o.setAttribute(`aria-expanded`,String(!a.folded)),o.setAttribute(`aria-label`,(0,l.fillText)(a.folded?r.unfoldLabel:r.foldLabel,{group:a.name})),o.setAttribute(K,`group:${a.name}`);let s=(0,c.glyphNode)(a.folded?`chevron-right`:`chevron-down`,{size:16});o.replaceChildren(...s?[s]:[]),n.append(o,(0,i.make)(`span`,null,a.name),(0,i.make)(`span`,null,(0,l.pluralText)(r,`groupSummary`,a.count,{percent:a.percent}))),e.append(n)}let o=(0,i.make)(`div`,{class:`wui-gantt-group-summary`});o.dataset.wuiGanttGroup=a.name,o.style.left=X(t.x),o.style.width=X(t.w),o.style.top=X(t.top+n.geometry.groupBarTop),o.style.height=X(h.groupBarH),e.append(o)}_deps(e){let t=document.createElementNS(J,`svg`);t.setAttribute(`class`,`wui-gantt-deps`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`width`,String(e.axis.width)),t.setAttribute(`height`,String(e.height));for(let n of e.arrows){let e=document.createElementNS(J,`path`);e.setAttribute(`d`,n.d),e.setAttribute(`fill`,`none`);let r=document.createElementNS(J,`polygon`);r.setAttribute(`points`,n.head),e.dataset.from=n.fromKey,e.dataset.to=n.toKey,t.append(e,r)}return t}_details(e,t){let r=this._selected,a=r===null?void 0:e.rows.find(e=>e.row.key===r&&(e.kind===`bar`||e.kind===`milestone`)&&!e.hidden);if(!a)return null;let o=G(),{row:s}=a,c=(0,i.make)(`div`,{class:`wui-gantt-details`});c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,s.name),c.style.width=X(Ye);let u=(0,i.make)(`dl`),d=(e,t)=>{u.append((0,i.make)(`dt`,null,e),(0,i.make)(`dd`,null,t))},f=k(O(s.start??``));s.owner&&d(o.detailsOwner,s.owner),d(o.detailsDates,s.end===void 0?f:(0,l.fillText)(o.detailsRange,{start:f,end:k(O(s.end))})),s.end!==void 0&&d(o.detailsDone,`${Q(s)}%, ${Z($(s))}`);let p=this._names(s,t);p&&d(o.detailsStartsAfter,p);let m=(0,i.make)(`button`,{class:(0,n.buttonClass)(`neutral`,`ghost`,`sm`)},o.detailsCloseLabel);return m.type=`button`,m.setAttribute(K,`close`),c.append((0,i.make)(`h3`,{class:`h6`},s.name),u,m),c}};(0,t.defineElement)(`wui-gantt`,et),e.WuiGantt=et})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.zone,WeborityUiElementsInternal.modules.avatarNode,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);