@webority/ui-elements 0.191.3 → 0.193.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 (218) hide show
  1. package/dist/{WuiCodeBlock-C4GqrGyO.js → WuiCodeBlock-BnRpTBm_.js} +1 -1
  2. package/dist/{WuiCommandPalette-CNwakljH.js → WuiCommandPalette-BSWDxEPw.js} +1 -1
  3. package/dist/{WuiDataTable-DKfTPdsn.js → WuiDataTable-D_9TWU-r.js} +1 -1
  4. package/dist/{WuiDatePicker-gZUfaTkZ.js → WuiDatePicker-B77M2_E7.js} +1 -1
  5. package/dist/{WuiDateRange-CNDyrPUT.js → WuiDateRange-BQ1GH9Mu.js} +1 -1
  6. package/dist/{WuiGantt-iEbrAdTQ.js → WuiGantt-wx8VSXiZ.js} +1 -1
  7. package/dist/WuiImageCrop-Cl97BHN4.js +1 -0
  8. package/dist/{WuiLightbox-DqAm2n8s.js → WuiLightbox-DFaHN2Fb.js} +1 -1
  9. package/dist/{WuiPhone-9dBrkfZf.js → WuiPhone-qw_6W3Q2.js} +1 -1
  10. package/dist/{WuiSelect-bvcpSY50.js → WuiSelect-DqHu2OW_.js} +1 -1
  11. package/dist/{WuiTimePicker-BIuLkZqU.js → WuiTimePicker-Bl3GcIS_.js} +1 -1
  12. package/dist/{WuiTour-CFRs1xE-.js → WuiTour-BS7Jd1Tt.js} +1 -1
  13. package/dist/{WuiTree-MMiIcWOJ.js → WuiTree-Qno7SM6z.js} +1 -1
  14. package/dist/{WuiTreePicker-CCkoPctd.js → WuiTreePicker-DWCLntLz.js} +1 -1
  15. package/dist/{WuiWizardStep-Cnc0DYg1.js → WuiWizardStep-CSS4B8g4.js} +1 -1
  16. package/dist/a.g-BUrXZ0Qj.js +1 -0
  17. package/dist/b.g-c7AZ9uVu.js +1 -0
  18. package/dist/c.g-1tKnlc4e.js +1 -0
  19. package/dist/{chips-DZpPt2SC.js → chips-DCkeuEvb.js} +1 -1
  20. package/dist/d.g-Cl1m1hN-.js +1 -0
  21. package/dist/{drawerDiscard-BsVbaCgB.js → drawerDiscard-mFYviRfI.js} +1 -1
  22. package/dist/e.g-BvqbeKNX.js +1 -0
  23. package/dist/elements/code-block.js +1 -1
  24. package/dist/elements/command-palette.js +1 -1
  25. package/dist/elements/data-table.js +1 -1
  26. package/dist/elements/date-range.js +1 -1
  27. package/dist/elements/datepicker.js +1 -1
  28. package/dist/elements/gantt.js +1 -1
  29. package/dist/elements/image-crop.js +1 -1
  30. package/dist/elements/lightbox.js +1 -1
  31. package/dist/elements/phone.js +1 -1
  32. package/dist/elements/select.js +1 -1
  33. package/dist/elements/status-icon.js +1 -1
  34. package/dist/elements/timepicker.js +1 -1
  35. package/dist/elements/tour.js +1 -1
  36. package/dist/elements/tree-picker.js +1 -1
  37. package/dist/elements/tree.js +1 -1
  38. package/dist/elements/wizard.js +1 -1
  39. package/dist/f.g-CNmxMCET.js +1 -0
  40. package/dist/fileViewer.g-DnuE1_o9.js +1 -0
  41. package/dist/{fileViewerImage-DnzDd-rQ.js → fileViewerImage-BxvHyZ4w.js} +1 -1
  42. package/dist/{fileViewerMedia-Dm99qAjY.js → fileViewerMedia-I9wn32xJ.js} +1 -1
  43. package/dist/{fileViewerPdf-BET_tiP6.js → fileViewerPdf-COm4n8i7.js} +1 -1
  44. package/dist/g.g-B-tbDuHa.js +1 -0
  45. package/dist/h.g-D63tQoPL.js +1 -0
  46. package/dist/helpers.js +1 -1
  47. package/dist/i.g-DRCcFvgj.js +1 -0
  48. package/dist/iconGlyphs.g-DRNDTVOs.js +1 -0
  49. package/dist/j.g-6OVN_siI.js +1 -0
  50. package/dist/k.g-BWqvhE7s.js +1 -0
  51. package/dist/l.g-BHoPnVck.js +1 -0
  52. package/dist/loader-sSdQNOg6.js +1 -0
  53. package/dist/m.g-BVQq45TF.js +1 -0
  54. package/dist/n.g-CFb-ps6H.js +1 -0
  55. package/dist/o.g-CGJASwcf.js +1 -0
  56. package/dist/{optionLabel-wbpl8OTJ.js → optionLabel-CuShfg_A.js} +1 -1
  57. package/dist/p.g-DRXC-OFe.js +1 -0
  58. package/dist/q.g-CIah8JGo.js +1 -0
  59. package/dist/r.g-BlQw7Aox.js +1 -0
  60. package/dist/s.g-DwIkkKgS.js +1 -0
  61. package/dist/{search-BtwgxJ0e.js → search-OPWGeniZ.js} +1 -1
  62. package/dist/server.js +1 -1
  63. package/dist/statusIcons-DISKRFbg.js +1 -0
  64. package/dist/{svgNodes-CyPS2oFH.js → svgNodes-CaPMDvv7.js} +1 -1
  65. package/dist/t.g-045-l40U.js +1 -0
  66. package/dist/u.g-CK8fmXKY.js +1 -0
  67. package/dist/ui-elements/calendar-views.global.js +1 -1
  68. package/dist/ui-elements/carousel.global.js +1 -1
  69. package/dist/ui-elements/code-block.global.js +1 -1
  70. package/dist/ui-elements/command-palette.global.js +2 -2
  71. package/dist/ui-elements/comment-thread.global.js +1 -1
  72. package/dist/ui-elements/consent-banner.global.js +1 -1
  73. package/dist/ui-elements/context-menu.global.js +1 -1
  74. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  75. package/dist/ui-elements/data-table.global.js +1 -1
  76. package/dist/ui-elements/date-range.global.js +1 -1
  77. package/dist/ui-elements/date-time.global.js +1 -1
  78. package/dist/ui-elements/datepicker.global.js +1 -1
  79. package/dist/ui-elements/dock.global.js +1 -1
  80. package/dist/ui-elements/drawer.global.js +1 -1
  81. package/dist/ui-elements/dropdown.global.js +1 -1
  82. package/dist/ui-elements/entry-grid.global.js +1 -1
  83. package/dist/ui-elements/gantt.global.js +1 -1
  84. package/dist/ui-elements/glyphs-a.global.js +1 -0
  85. package/dist/ui-elements/glyphs-b.global.js +1 -0
  86. package/dist/ui-elements/glyphs-c.global.js +1 -0
  87. package/dist/ui-elements/glyphs-d.global.js +1 -0
  88. package/dist/ui-elements/glyphs-e.global.js +1 -0
  89. package/dist/ui-elements/glyphs-f.global.js +1 -0
  90. package/dist/ui-elements/glyphs-g.global.js +1 -0
  91. package/dist/ui-elements/glyphs-h.global.js +1 -0
  92. package/dist/ui-elements/glyphs-i.global.js +1 -0
  93. package/dist/ui-elements/glyphs-j.global.js +1 -0
  94. package/dist/ui-elements/glyphs-k.global.js +1 -0
  95. package/dist/ui-elements/glyphs-l.global.js +1 -0
  96. package/dist/ui-elements/glyphs-m.global.js +1 -0
  97. package/dist/ui-elements/glyphs-n.global.js +1 -0
  98. package/dist/ui-elements/glyphs-o.global.js +1 -0
  99. package/dist/ui-elements/glyphs-p.global.js +1 -0
  100. package/dist/ui-elements/glyphs-q.global.js +1 -0
  101. package/dist/ui-elements/glyphs-r.global.js +1 -0
  102. package/dist/ui-elements/glyphs-s.global.js +1 -0
  103. package/dist/ui-elements/glyphs-t.global.js +1 -0
  104. package/dist/ui-elements/glyphs-u.global.js +1 -0
  105. package/dist/ui-elements/glyphs-v.global.js +1 -0
  106. package/dist/ui-elements/glyphs-w.global.js +1 -0
  107. package/dist/ui-elements/glyphs-x.global.js +1 -0
  108. package/dist/ui-elements/glyphs-z.global.js +1 -0
  109. package/dist/ui-elements/glyphs.global.js +1 -1
  110. package/dist/ui-elements/hover-card.global.js +1 -1
  111. package/dist/ui-elements/image-crop.global.js +1 -1
  112. package/dist/ui-elements/inline-edit.global.js +1 -1
  113. package/dist/ui-elements/kanban.global.js +1 -1
  114. package/dist/ui-elements/lead-popup.global.js +1 -1
  115. package/dist/ui-elements/lightbox.global.js +1 -1
  116. package/dist/ui-elements/markdown.global.js +1 -1
  117. package/dist/ui-elements/mini-calendar.global.js +1 -1
  118. package/dist/ui-elements/navigation-menu.global.js +1 -1
  119. package/dist/ui-elements/notification-center.global.js +1 -1
  120. package/dist/ui-elements/offline-banner.global.js +1 -1
  121. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  122. package/dist/ui-elements/org-tree.global.js +1 -1
  123. package/dist/ui-elements/otp.global.js +1 -1
  124. package/dist/ui-elements/overflow.global.js +1 -1
  125. package/dist/ui-elements/phone.global.js +1 -1
  126. package/dist/ui-elements/popover.global.js +1 -1
  127. package/dist/ui-elements/rating.global.js +1 -1
  128. package/dist/ui-elements/record-pager.global.js +1 -1
  129. package/dist/ui-elements/relative-time.global.js +1 -1
  130. package/dist/ui-elements/saved-views.global.js +1 -1
  131. package/dist/ui-elements/select-chips.global.js +1 -1
  132. package/dist/ui-elements/select-recents.global.js +1 -1
  133. package/dist/ui-elements/select-search.global.js +1 -1
  134. package/dist/ui-elements/select-window.global.js +1 -1
  135. package/dist/ui-elements/server.global.js +1 -1
  136. package/dist/ui-elements/shell.global.js +1 -1
  137. package/dist/ui-elements/shortcuts.global.js +1 -1
  138. package/dist/ui-elements/show-more.global.js +1 -1
  139. package/dist/ui-elements/slider.global.js +1 -1
  140. package/dist/ui-elements/sortable.global.js +1 -1
  141. package/dist/ui-elements/status-icon.global.js +1 -1
  142. package/dist/ui-elements/table-export.global.js +1 -1
  143. package/dist/ui-elements/timepicker.global.js +1 -1
  144. package/dist/ui-elements/tour.global.js +1 -1
  145. package/dist/ui-elements/tree-picker.global.js +1 -1
  146. package/dist/ui-elements/tree.global.js +1 -1
  147. package/dist/ui-elements/truncate.global.js +1 -1
  148. package/dist/ui-elements/whats-new.global.js +1 -1
  149. package/dist/ui-elements/wizard.global.js +1 -1
  150. package/dist/ui-elements.global.js +1 -1
  151. package/dist/ui-elements.js +1 -1
  152. package/dist/ui-file-viewer.global.js +10 -10
  153. package/dist/ui-file-viewer.js +1 -1
  154. package/dist/v.g-BpLD1c9M.js +1 -0
  155. package/dist/w.g-CDqV9dT6.js +1 -0
  156. package/dist/x.g-T5k9qAoo.js +1 -0
  157. package/dist/z.g-B8smtOck.js +1 -0
  158. package/package.json +5 -5
  159. package/types/global/glyphChunks.g.d.ts +1 -0
  160. package/types/global/glyphs.d.ts +9 -12
  161. package/types/global/parts/glyphs-a.g.d.ts +1 -0
  162. package/types/global/parts/glyphs-b.g.d.ts +1 -0
  163. package/types/global/parts/glyphs-c.g.d.ts +1 -0
  164. package/types/global/parts/glyphs-d.g.d.ts +1 -0
  165. package/types/global/parts/glyphs-e.g.d.ts +1 -0
  166. package/types/global/parts/glyphs-f.g.d.ts +1 -0
  167. package/types/global/parts/glyphs-g.g.d.ts +1 -0
  168. package/types/global/parts/glyphs-h.g.d.ts +1 -0
  169. package/types/global/parts/glyphs-i.g.d.ts +1 -0
  170. package/types/global/parts/glyphs-j.g.d.ts +1 -0
  171. package/types/global/parts/glyphs-k.g.d.ts +1 -0
  172. package/types/global/parts/glyphs-l.g.d.ts +1 -0
  173. package/types/global/parts/glyphs-m.g.d.ts +1 -0
  174. package/types/global/parts/glyphs-n.g.d.ts +1 -0
  175. package/types/global/parts/glyphs-o.g.d.ts +1 -0
  176. package/types/global/parts/glyphs-p.g.d.ts +1 -0
  177. package/types/global/parts/glyphs-q.g.d.ts +1 -0
  178. package/types/global/parts/glyphs-r.g.d.ts +1 -0
  179. package/types/global/parts/glyphs-s.g.d.ts +1 -0
  180. package/types/global/parts/glyphs-t.g.d.ts +1 -0
  181. package/types/global/parts/glyphs-u.g.d.ts +1 -0
  182. package/types/global/parts/glyphs-v.g.d.ts +1 -0
  183. package/types/global/parts/glyphs-w.g.d.ts +1 -0
  184. package/types/global/parts/glyphs-x.g.d.ts +1 -0
  185. package/types/global/parts/glyphs-z.g.d.ts +1 -0
  186. package/types/glyphTable.d.ts +23 -0
  187. package/types/iconCatalog/a.g.d.ts +2 -0
  188. package/types/iconCatalog/b.g.d.ts +2 -0
  189. package/types/iconCatalog/c.g.d.ts +2 -0
  190. package/types/iconCatalog/d.g.d.ts +2 -0
  191. package/types/iconCatalog/e.g.d.ts +2 -0
  192. package/types/iconCatalog/f.g.d.ts +2 -0
  193. package/types/iconCatalog/g.g.d.ts +2 -0
  194. package/types/iconCatalog/h.g.d.ts +2 -0
  195. package/types/iconCatalog/i.g.d.ts +2 -0
  196. package/types/iconCatalog/j.g.d.ts +2 -0
  197. package/types/iconCatalog/k.g.d.ts +2 -0
  198. package/types/iconCatalog/l.g.d.ts +2 -0
  199. package/types/iconCatalog/m.g.d.ts +2 -0
  200. package/types/iconCatalog/n.g.d.ts +2 -0
  201. package/types/iconCatalog/o.g.d.ts +2 -0
  202. package/types/iconCatalog/p.g.d.ts +2 -0
  203. package/types/iconCatalog/q.g.d.ts +2 -0
  204. package/types/iconCatalog/r.g.d.ts +2 -0
  205. package/types/iconCatalog/s.g.d.ts +2 -0
  206. package/types/iconCatalog/t.g.d.ts +2 -0
  207. package/types/iconCatalog/u.g.d.ts +2 -0
  208. package/types/iconCatalog/v.g.d.ts +2 -0
  209. package/types/iconCatalog/w.g.d.ts +2 -0
  210. package/types/iconCatalog/x.g.d.ts +2 -0
  211. package/types/iconCatalog/z.g.d.ts +2 -0
  212. package/types/iconCatalogNames.g.d.ts +1 -0
  213. package/types/iconGlyphs.g.d.ts +3 -6
  214. package/dist/WuiImageCrop-97d50aEw.js +0 -1
  215. package/dist/fileViewer.g-D_zLw_p-.js +0 -1
  216. package/dist/iconGlyphs.g-a9FtjPXh.js +0 -1
  217. package/dist/loader-X2uBXCDm.js +0 -1
  218. package/dist/statusIcons-Cd3GJcBR.js +0 -1
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var g=globalThis.WeborityUiElementsInternal?.version;if(g!==`0.191.3`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.191.3 but the page loaded `+g+`.`);var _=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),v=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),y={addReactionLabel:`Add a reaction`,attachmentsLabel:`Attachments`,cancelLabel:`Cancel`,chooseReactionLabel:`Choose a reaction`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,deleteConfirmText:`Delete this comment?`,deleteLabel:`Delete`,deletedText:`This comment was deleted.`,doneDeleteText:`Comment deleted.`,doneEditText:`Comment saved.`,donePostText:`Comment posted.`,doneReplyText:`Reply posted.`,editCommentLabel:`Edit comment`,editLabel:`Edit`,editedLabel:`Edited`,emptyBodyMessage:`Write something first.`,failedClientMessage:`This did not go through. Refresh the page and try again.`,failedServerMessage:`Something went wrong on our side. Try again in a moment.`,forbiddenMessage:`You do not have permission to do this.`,internalLabel:`Internal note`,label:`Comments`,noCommentsText:`No comments yet.`,peopleLabel:`People`,postLabel:`Comment`,reactionsLabel:`Reactions`,repliesToLabel:`Replies to {name}`,replyLabel:`Reply`,replyPlaceholder:`Write a reply`,replyToText:`Reply to {author}`,saveLabel:`Save`,validationMessage:`This was not accepted. Check it and try again.`},b={foundTextOne:`1 person. Up and down to choose, Enter to mention.`,foundTextOther:`{count} people. Up and down to choose, Enter to mention.`,helpLabel:`More information`,listNameLabel:`People`,mentioned:`Mentioned {label}.`,noMatchLabel:`No one matches`,searchFailedMessage:`Couldn't load people. Keep typing to try again.`,searchingLabel:`Searching…`};function x(e){"@babel/helpers - typeof";return x=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},x(e)}function S(e,t){if(x(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(x(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function C(e){var t=S(e,`string`);return x(t)==`symbol`?t:t+``}function w(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var T=()=>(0,l.readText)(`mentionInput`,b),E=`[data-wui-control]`,D=`[data-wui-field]`,O=`[data-wui-menu]`,k=`[data-wui-live]`,A=0,j=e=>!!(e&&h.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,h.mentionLabel)(e.label)!==``);function M(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function N(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function P(e,t){t.readOnly=(0,d.isReadOnly)(e)||e.hasAttribute(`loading`)}function F(e){let t=e.ownerDocument;e.id||=`wui-mention-${++A}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),P(e,n),M(e,n),N(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??T().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var I=class extends r.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),w(this,`_wired`,void 0),w(this,`_pendingValue`,void 0),w(this,`_text`,void 0),w(this,`_mentions`,void 0),w(this,`_peopleProp`,void 0),w(this,`_declared`,void 0),w(this,`_loading`,void 0),w(this,`_searchFailed`,void 0),w(this,`_query`,void 0),w(this,`_results`,void 0),w(this,`_active`,void 0),w(this,`_timer`,void 0),w(this,`_searchSeq`,void 0),w(this,`_lastSearch`,void 0),w(this,`_abort`,void 0),w(this,`_onMenuDown`,void 0),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if((0,i.hasOwn)(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(E)||F(this);let e=this._requireControl();N(this,e);let t=this.querySelector(D)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(P(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(P(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?M(this,r):e===`class`?N(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,h.mentionValueFromText)(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(j):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(E)}_menu(){return this.querySelector(O)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=(0,h.mentionTextFromValue)(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(D);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,d.isInert)(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n.charAt(r-1)))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>(0,h.mentionLabel)(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await(0,c.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=(0,s.parseServerHtml)(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(j),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&(0,a.isPopoverOpen)(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=(0,h.mentionLabel)(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?T().searchingLabel:this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}(0,a.openAnchoredPopover)(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?(0,l.pluralText)(T(),`foundText`,this._results.length,{count:(0,f.formatNumber)(this._results.length,{decimals:0})}):this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel}.`)}_syncState(){let e=this._control();e&&(0,d.syncFieldState)(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=(0,a.isPopoverOpen)(e);(0,a.closeAnchoredPopover)(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,m.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if(((0,p.isImeSafeEnter)(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}(0,p.isImeSafeEnter)(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,h.mentionLabel)(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce((0,l.fillText)(T().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(k);t&&(t.textContent=``,t.textContent=e)}},L=`[data-wui-items]`,R=`[data-wui-picker]`,z=`[data-wui-composer]`,B=`[data-wui-comment]`,V=`[data-wui-live]`,H=()=>(0,l.readText)(`commentThread`,y),U=e=>({forbidden:H().forbiddenMessage,networkCheck:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:H().failedClientMessage,validation:H().validationMessage,server:H().failedServerMessage,network:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkText})[e],W=e=>({post:H().donePostText,reply:H().doneReplyText,edit:H().doneEditText,delete:H().doneDeleteText,react:``})[e],G=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:H().failedServerMessage},K=e=>e instanceof Element?e:null,q=e=>`disabled`in e&&e.disabled===!0,J=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},Y=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},Z=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Q=class extends r.ElementBase{constructor(){super(),w(this,`_wired`,void 0),w(this,`_busy`,void 0),w(this,`_peopleProp`,void 0),w(this,`_pickerFor`,void 0),w(this,`_openers`,void 0),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if((0,i.hasOwn)(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=Y(this,`${z} wui-mention-input`,I);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:Z(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:_}_onClick(e){let t=X(K(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!q(t)){let e=t.closest(R),n=e?this._pickerFor?.comment:t.closest(B);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=X(K(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||q(n))return;let r=n.closest(B);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=J(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=Y(this,R,HTMLElement),n=K(e.target),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));if(this._pickerFor&&t?.contains(n)){let i=Z(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=X(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(B),!0))}_onSubmitKey(e){let t=Y(X(K(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!q(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=Y(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:(0,l.fillText)(H().replyToText,{author:r}),placeholder:H().replyPlaceholder,value:``,send:H().replyLabel,opener:t})}_openEditor(e,t){let n=Y(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=Y(J(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:H().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:H().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,H().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(e,t,r,i,a){let o=this.ownerDocument.createElement(`button`);return o.type=`button`,o.className=(0,n.buttonClass)(e,t,r),o.dataset.wui=n.APP_BUTTON_MARKER,o.setAttribute(`data-wui-action`,i),o.textContent=a,o}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=Y(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=Y(e,`:scope > .wui-comment-row`,HTMLElement),n=Y(t,`[data-wui-comment-confirm]`,HTMLElement),r=Y(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),Y(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=Y(e,`:scope > .wui-comment-row`,HTMLElement),r=Y(n,`[data-wui-comment-confirm]`,HTMLElement),i=Y(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&Y(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=Y(this,R,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),(0,a.openAnchoredPopover)(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),Y(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=Y(this,R,HTMLElement);n&&(0,a.closeAnchoredPopover)(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=Y(this,R,HTMLElement),t=this._pickerFor;!t||e&&(0,a.isPopoverOpen)(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=X(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,H().emptyBodyMessage),n?.focus();return}let i=t.closest(B);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??Y(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),W(e)&&this._announce(W(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:G(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:H().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,c.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||U(r.kind)||H().failedServerMessage}}_swapItems(e){let t=Y(this,L,HTMLElement);if(!t||!e.trim())return;let n=(0,s.parseServerHtml)(e),r=Y(n,L,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!q(i))return;let a=e=>e?Z(this,B,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>Y(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=Y(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=Y(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=Z(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??Y(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=Y(this,`${z} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=Y(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=Y(this,`:scope > ${V}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,I),(0,t.defineElement)(`wui-comment-thread`,Q),e.COMMENT_INTENTS=v,e.COMMENT_REACTIONS=_,e.WuiCommentThread=Q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.mentionText);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var g=globalThis.WeborityUiElementsInternal?.version;if(g!==`0.193.0`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.193.0 but the page loaded `+g+`.`);var _=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),v=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),y={addReactionLabel:`Add a reaction`,attachmentsLabel:`Attachments`,cancelLabel:`Cancel`,chooseReactionLabel:`Choose a reaction`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,deleteConfirmText:`Delete this comment?`,deleteLabel:`Delete`,deletedText:`This comment was deleted.`,doneDeleteText:`Comment deleted.`,doneEditText:`Comment saved.`,donePostText:`Comment posted.`,doneReplyText:`Reply posted.`,editCommentLabel:`Edit comment`,editLabel:`Edit`,editedLabel:`Edited`,emptyBodyMessage:`Write something first.`,failedClientMessage:`This did not go through. Refresh the page and try again.`,failedServerMessage:`Something went wrong on our side. Try again in a moment.`,forbiddenMessage:`You do not have permission to do this.`,internalLabel:`Internal note`,label:`Comments`,noCommentsText:`No comments yet.`,peopleLabel:`People`,postLabel:`Comment`,reactionsLabel:`Reactions`,repliesToLabel:`Replies to {name}`,replyLabel:`Reply`,replyPlaceholder:`Write a reply`,replyToText:`Reply to {author}`,saveLabel:`Save`,validationMessage:`This was not accepted. Check it and try again.`},b={foundTextOne:`1 person. Up and down to choose, Enter to mention.`,foundTextOther:`{count} people. Up and down to choose, Enter to mention.`,helpLabel:`More information`,listNameLabel:`People`,mentioned:`Mentioned {label}.`,noMatchLabel:`No one matches`,searchFailedMessage:`Couldn't load people. Keep typing to try again.`,searchingLabel:`Searching…`};function x(e){"@babel/helpers - typeof";return x=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},x(e)}function S(e,t){if(x(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(x(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function C(e){var t=S(e,`string`);return x(t)==`symbol`?t:t+``}function w(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var T=()=>(0,l.readText)(`mentionInput`,b),E=`[data-wui-control]`,D=`[data-wui-field]`,O=`[data-wui-menu]`,k=`[data-wui-live]`,A=0,j=e=>!!(e&&h.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,h.mentionLabel)(e.label)!==``);function M(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function N(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function P(e,t){t.readOnly=(0,d.isReadOnly)(e)||e.hasAttribute(`loading`)}function F(e){let t=e.ownerDocument;e.id||=`wui-mention-${++A}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),P(e,n),M(e,n),N(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??T().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var I=class extends r.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),w(this,`_wired`,void 0),w(this,`_pendingValue`,void 0),w(this,`_text`,void 0),w(this,`_mentions`,void 0),w(this,`_peopleProp`,void 0),w(this,`_declared`,void 0),w(this,`_loading`,void 0),w(this,`_searchFailed`,void 0),w(this,`_query`,void 0),w(this,`_results`,void 0),w(this,`_active`,void 0),w(this,`_timer`,void 0),w(this,`_searchSeq`,void 0),w(this,`_lastSearch`,void 0),w(this,`_abort`,void 0),w(this,`_onMenuDown`,void 0),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if((0,i.hasOwn)(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(E)||F(this);let e=this._requireControl();N(this,e);let t=this.querySelector(D)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(P(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(P(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?M(this,r):e===`class`?N(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,h.mentionValueFromText)(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(j):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(E)}_menu(){return this.querySelector(O)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=(0,h.mentionTextFromValue)(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(D);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,d.isInert)(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n.charAt(r-1)))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>(0,h.mentionLabel)(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await(0,c.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=(0,s.parseServerHtml)(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(j),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&(0,a.isPopoverOpen)(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=(0,h.mentionLabel)(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?T().searchingLabel:this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}(0,a.openAnchoredPopover)(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?(0,l.pluralText)(T(),`foundText`,this._results.length,{count:(0,f.formatNumber)(this._results.length,{decimals:0})}):this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel}.`)}_syncState(){let e=this._control();e&&(0,d.syncFieldState)(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=(0,a.isPopoverOpen)(e);(0,a.closeAnchoredPopover)(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,m.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if(((0,p.isImeSafeEnter)(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}(0,p.isImeSafeEnter)(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,h.mentionLabel)(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce((0,l.fillText)(T().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(k);t&&(t.textContent=``,t.textContent=e)}},L=`[data-wui-items]`,R=`[data-wui-picker]`,z=`[data-wui-composer]`,B=`[data-wui-comment]`,V=`[data-wui-live]`,H=()=>(0,l.readText)(`commentThread`,y),U=e=>({forbidden:H().forbiddenMessage,networkCheck:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:H().failedClientMessage,validation:H().validationMessage,server:H().failedServerMessage,network:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkText})[e],W=e=>({post:H().donePostText,reply:H().doneReplyText,edit:H().doneEditText,delete:H().doneDeleteText,react:``})[e],G=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:H().failedServerMessage},K=e=>e instanceof Element?e:null,q=e=>`disabled`in e&&e.disabled===!0,J=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},Y=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},Z=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Q=class extends r.ElementBase{constructor(){super(),w(this,`_wired`,void 0),w(this,`_busy`,void 0),w(this,`_peopleProp`,void 0),w(this,`_pickerFor`,void 0),w(this,`_openers`,void 0),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this)}connectedCallback(){if((0,i.hasOwn)(this,`people`)){let e=this.people;Reflect.deleteProperty(this,`people`),this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),customElements.upgrade(this);let e=Y(this,`${z} wui-mention-input`,I);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:Z(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:_}_onClick(e){let t=X(K(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!q(t)){let e=t.closest(R),n=e?this._pickerFor?.comment:t.closest(B);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=X(K(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||q(n))return;let r=n.closest(B);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:{let e=J(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=Y(this,R,HTMLElement),n=K(e.target),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));if(this._pickerFor&&t?.contains(n)){let i=Z(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=X(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(B),!0))}_onSubmitKey(e){let t=Y(X(K(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!q(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=Y(e,`:scope > [data-wui-reply]`,HTMLElement);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e?.querySelector(`.wui-comment-author`)?.textContent?.trim()||``;this._fillSlot(n,{label:(0,l.fillText)(H().replyToText,{author:r}),placeholder:H().replyPlaceholder,value:``,send:H().replyLabel,opener:t})}_openEditor(e,t){let n=Y(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=Y(J(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:H().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:H().saveLabel,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,H().cancelLabel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(e,t,r,i,a){let o=this.ownerDocument.createElement(`button`);return o.type=`button`,o.className=(0,n.buttonClass)(e,t,r),o.dataset.wui=n.APP_BUTTON_MARKER,o.setAttribute(`data-wui-action`,i),o.textContent=a,o}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=Y(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=Y(e,`:scope > .wui-comment-row`,HTMLElement),n=Y(t,`[data-wui-comment-confirm]`,HTMLElement),r=Y(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),Y(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=Y(e,`:scope > .wui-comment-row`,HTMLElement),r=Y(n,`[data-wui-comment-confirm]`,HTMLElement),i=Y(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&Y(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=Y(this,R,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),(0,a.openAnchoredPopover)(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),Y(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=Y(this,R,HTMLElement);n&&(0,a.closeAnchoredPopover)(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=Y(this,R,HTMLElement),t=this._pickerFor;!t||e&&(0,a.isPopoverOpen)(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=X(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,H().emptyBodyMessage),n?.focus();return}let i=t.closest(B);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??Y(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),W(e)&&this._announce(W(e)),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:G(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:H().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,c.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||U(r.kind)||H().failedServerMessage}}_swapItems(e){let t=Y(this,L,HTMLElement);if(!t||!e.trim())return;let n=(0,s.parseServerHtml)(e),r=Y(n,L,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!q(i))return;let a=e=>e?Z(this,B,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>Y(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=Y(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=Y(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=Z(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??Y(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=Y(this,`${z} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=Y(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=Y(this,`:scope > ${V}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,I),(0,t.defineElement)(`wui-comment-thread`,Q),e.COMMENT_INTENTS=v,e.COMMENT_REACTIONS=_,e.WuiCommentThread=Q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.mentionText);
@@ -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.191.3`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.191.3 but the page loaded `+s+`.`);var c={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},l=e=>`var(${e}, ${c[e]})`,u=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${l(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${l(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${l(`--color-surface`)}; border: 1px solid ${l(`--color-border`)}; border-radius: ${l(`--wui-radius-lg`)}; box-shadow: ${l(`--wui-shadow-modal`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${l(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${l(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${l(`--color-primary-text`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${l(`--color-border`)}; border-bottom: 1px solid ${l(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${l(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${l(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${l(`--color-primary`)}; background: ${l(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${l(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${l(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${l(`--color-primary`)}; border-color: ${l(`--color-primary`)}; color: ${l(`--color-on-primary`)}; } .btn-primary:hover { background: ${l(`--color-primary-hover`)}; border-color: ${l(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${l(`--color-text-muted`)}; color: ${l(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${l(`--color-bg-muted`)}; color: ${l(`--color-text`)}; } .btn-link { font-weight: 400; color: ${l(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${l(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } /* The actions are small buttons, which fall under the 44px touch target on touch screens. This sheet's .btn is inline-block, so it centres the label itself. */ @media (max-width: 575.98px), (pointer: coarse) { .wui-consent-banner-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } `,d={acceptLabel:`Accept all`,analyticsDescription:`Help us understand how visitors use the site.`,analyticsLabel:`Analytics cookies`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,essentialDescription:`Required for the site to work and stay secure. Always on.`,essentialLabel:`Essential cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,functionalLabel:`Functional cookies`,heading:`Cookies on this site`,marketingDescription:`Measure how well our campaigns work.`,marketingLabel:`Marketing cookies`,policyLabel:`Cookie policy`,rejectLabel:`Reject all`,saveLabel:`Save preferences`,settingsLabel:`Cookie settings`},f=`data-wui-tour-open`;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 _=`wui-consent-save`,v=`[data-consent-settings]`,y=`tour-open`,b=`--wui-consent-banner-block`,x=`--wui-consent-banner-inline`,S=()=>(0,o.readText)(`consentBanner`,d),C=[`analytics`,`functional`,`marketing`],w={analytics:{label:`analyticsLabel`,description:`analyticsDescription`},functional:{label:`functionalLabel`,description:`functionalDescription`},marketing:{label:`marketingLabel`,description:`marketingDescription`}};function T(e){return C.some(t=>t===e)}var E=new Set;function D(e){E.has(e)||(E.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${C.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var O=0,k=null;function A(e){k||(k=new CSSStyleSheet,k.replaceSync(u)),e.adoptedStyleSheets=[k]}var j=class extends a.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g(this,`_uid`,void 0),g(this,`_preferences`,void 0),g(this,`_settings`,void 0),g(this,`_onDocumentClick`,void 0),g(this,`_tourWatch`,void 0),g(this,`_roomObserver`,void 0),g(this,`_onWindowResize`,void 0),g(this,`_rendered`,void 0),O+=1,this._uid=`wui-consent-${O}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(v)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||S().heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||S().description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||S().policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||S().analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||S().functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||S().marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...C];let t=e.split(/\s+/).filter(Boolean);for(let e of t)T(e)||D(e);let n=C.filter(e=>t.includes(e));return n.length?n:[...C]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(C.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[f]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(y,document.documentElement.hasAttribute(f))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?(0,i.make)(`a`,{class:`wui-consent-banner-policy`,href:this.policyHref},this.policyLabel):null,a=this._root();a instanceof ShadowRoot&&A(a),a.replaceChildren((0,i.make)(`div`,{class:`wui-consent-banner-panel`,role:`dialog`,"aria-labelledby":`${t}-heading`,"aria-describedby":`${t}-description`,hidden:!0},(0,i.make)(`h2`,{class:`wui-consent-banner-heading`,id:`${t}-heading`},this.heading),(0,i.make)(`p`,{class:`wui-consent-banner-description`,id:`${t}-description`},r?`${this.description} `:this.description,r),(0,i.make)(`div`,{class:`wui-consent-banner-settings`,hidden:!0},M(t,`essential`,S().essentialLabel,S().essentialDescription,!0),...this.categories.map(e=>M(t,e,S()[w[e].label],this[w[e].description],!1))),(0,i.make)(`div`,{class:`wui-consent-banner-actions`},(0,i.make)(`button`,{type:`button`,class:`btn btn-sm btn-link wui-consent-banner-settings-toggle`,"aria-expanded":`false`},S().settingsLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`neutral`,`outline`,`sm`)} wui-consent-banner-reject`,"data-wui":n.APP_BUTTON_MARKER},S().rejectLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-accept`,"data-wui":n.APP_BUTTON_MARKER},S().acceptLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-save`,hidden:!0,"data-wui":n.APP_BUTTON_MARKER},S().saveLabel)))),this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._requirePanel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){if(this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._requirePanel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t){let t=e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`);t instanceof HTMLElement&&t.focus()}}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(b),document.documentElement.style.removeProperty(x)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(b,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(x,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){let e=this._root().querySelector(`.wui-consent-banner-panel`);return e instanceof HTMLElement?e:null}_requirePanel(){let e=this._panel();if(!e)throw Error(`consent banner panel is missing`);return e}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return{analytics:e&&t.includes(`analytics`),functional:e&&t.includes(`functional`),marketing:e&&t.includes(`marketing`)}}_switchValues(){let e={analytics:!1,functional:!1,marketing:!1};for(let t of C){let n=this._root().querySelector(`input[data-category="${t}"]`);e[t]=n instanceof HTMLInputElement&&n.checked}return e}_applyPreferences(){for(let e of C){let t=this._root().querySelector(`input[data-category="${e}"]`);t instanceof HTMLInputElement&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!(n instanceof HTMLElement))return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r instanceof HTMLElement&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r instanceof HTMLElement&&(r.hidden=e)}}};function M(e,t,n,r,a){let o=`${e}-${t}`;return(0,i.make)(`div`,{class:`wui-consent-banner-category`},(0,i.make)(`div`,{class:`form-check form-switch`},(0,i.make)(`input`,{class:`form-check-input`,type:`checkbox`,role:`switch`,id:o,"data-category":t,checked:a,disabled:a}),(0,i.make)(`label`,{class:`form-check-label`,for:o},n)),(0,i.make)(`p`,{class:`wui-consent-banner-category-description`},r))}(0,t.defineElement)(`wui-consent-banner`,j),e.WuiConsentBanner=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.193.0`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.193.0 but the page loaded `+s+`.`);var c={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},l=e=>`var(${e}, ${c[e]})`,u=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${l(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${l(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${l(`--color-surface`)}; border: 1px solid ${l(`--color-border`)}; border-radius: ${l(`--wui-radius-lg`)}; box-shadow: ${l(`--wui-shadow-modal`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${l(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${l(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${l(`--color-primary-text`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${l(`--color-border`)}; border-bottom: 1px solid ${l(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${l(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${l(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${l(`--color-primary`)}; background: ${l(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${l(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${l(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${l(`--color-primary`)}; border-color: ${l(`--color-primary`)}; color: ${l(`--color-on-primary`)}; } .btn-primary:hover { background: ${l(`--color-primary-hover`)}; border-color: ${l(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${l(`--color-text-muted`)}; color: ${l(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${l(`--color-bg-muted`)}; color: ${l(`--color-text`)}; } .btn-link { font-weight: 400; color: ${l(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${l(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } /* The actions are small buttons, which fall under the 44px touch target on touch screens. This sheet's .btn is inline-block, so it centres the label itself. */ @media (max-width: 575.98px), (pointer: coarse) { .wui-consent-banner-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } `,d={acceptLabel:`Accept all`,analyticsDescription:`Help us understand how visitors use the site.`,analyticsLabel:`Analytics cookies`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,essentialDescription:`Required for the site to work and stay secure. Always on.`,essentialLabel:`Essential cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,functionalLabel:`Functional cookies`,heading:`Cookies on this site`,marketingDescription:`Measure how well our campaigns work.`,marketingLabel:`Marketing cookies`,policyLabel:`Cookie policy`,rejectLabel:`Reject all`,saveLabel:`Save preferences`,settingsLabel:`Cookie settings`},f=`data-wui-tour-open`;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 _=`wui-consent-save`,v=`[data-consent-settings]`,y=`tour-open`,b=`--wui-consent-banner-block`,x=`--wui-consent-banner-inline`,S=()=>(0,o.readText)(`consentBanner`,d),C=[`analytics`,`functional`,`marketing`],w={analytics:{label:`analyticsLabel`,description:`analyticsDescription`},functional:{label:`functionalLabel`,description:`functionalDescription`},marketing:{label:`marketingLabel`,description:`marketingDescription`}};function T(e){return C.some(t=>t===e)}var E=new Set;function D(e){E.has(e)||(E.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${C.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var O=0,k=null;function A(e){k||(k=new CSSStyleSheet,k.replaceSync(u)),e.adoptedStyleSheets=[k]}var j=class extends a.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g(this,`_uid`,void 0),g(this,`_preferences`,void 0),g(this,`_settings`,void 0),g(this,`_onDocumentClick`,void 0),g(this,`_tourWatch`,void 0),g(this,`_roomObserver`,void 0),g(this,`_onWindowResize`,void 0),g(this,`_rendered`,void 0),O+=1,this._uid=`wui-consent-${O}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(v)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||S().heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||S().description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||S().policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||S().analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||S().functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||S().marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...C];let t=e.split(/\s+/).filter(Boolean);for(let e of t)T(e)||D(e);let n=C.filter(e=>t.includes(e));return n.length?n:[...C]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(C.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[f]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(y,document.documentElement.hasAttribute(f))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?(0,i.make)(`a`,{class:`wui-consent-banner-policy`,href:this.policyHref},this.policyLabel):null,a=this._root();a instanceof ShadowRoot&&A(a),a.replaceChildren((0,i.make)(`div`,{class:`wui-consent-banner-panel`,role:`dialog`,"aria-labelledby":`${t}-heading`,"aria-describedby":`${t}-description`,hidden:!0},(0,i.make)(`h2`,{class:`wui-consent-banner-heading`,id:`${t}-heading`},this.heading),(0,i.make)(`p`,{class:`wui-consent-banner-description`,id:`${t}-description`},r?`${this.description} `:this.description,r),(0,i.make)(`div`,{class:`wui-consent-banner-settings`,hidden:!0},M(t,`essential`,S().essentialLabel,S().essentialDescription,!0),...this.categories.map(e=>M(t,e,S()[w[e].label],this[w[e].description],!1))),(0,i.make)(`div`,{class:`wui-consent-banner-actions`},(0,i.make)(`button`,{type:`button`,class:`btn btn-sm btn-link wui-consent-banner-settings-toggle`,"aria-expanded":`false`},S().settingsLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`neutral`,`outline`,`sm`)} wui-consent-banner-reject`,"data-wui":n.APP_BUTTON_MARKER},S().rejectLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-accept`,"data-wui":n.APP_BUTTON_MARKER},S().acceptLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-save`,hidden:!0,"data-wui":n.APP_BUTTON_MARKER},S().saveLabel)))),this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._requirePanel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){if(this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._requirePanel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t){let t=e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`);t instanceof HTMLElement&&t.focus()}}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(b),document.documentElement.style.removeProperty(x)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(b,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(x,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){let e=this._root().querySelector(`.wui-consent-banner-panel`);return e instanceof HTMLElement?e:null}_requirePanel(){let e=this._panel();if(!e)throw Error(`consent banner panel is missing`);return e}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return{analytics:e&&t.includes(`analytics`),functional:e&&t.includes(`functional`),marketing:e&&t.includes(`marketing`)}}_switchValues(){let e={analytics:!1,functional:!1,marketing:!1};for(let t of C){let n=this._root().querySelector(`input[data-category="${t}"]`);e[t]=n instanceof HTMLInputElement&&n.checked}return e}_applyPreferences(){for(let e of C){let t=this._root().querySelector(`input[data-category="${e}"]`);t instanceof HTMLInputElement&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!(n instanceof HTMLElement))return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r instanceof HTMLElement&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r instanceof HTMLElement&&(r.hidden=e)}}};function M(e,t,n,r,a){let o=`${e}-${t}`;return(0,i.make)(`div`,{class:`wui-consent-banner-category`},(0,i.make)(`div`,{class:`form-check form-switch`},(0,i.make)(`input`,{class:`form-check-input`,type:`checkbox`,role:`switch`,id:o,"data-category":t,checked:a,disabled:a}),(0,i.make)(`label`,{class:`form-check-label`,for:o},n)),(0,i.make)(`p`,{class:`wui-consent-banner-category-description`},r))}(0,t.defineElement)(`wui-consent-banner`,j),e.WuiConsentBanner=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.191.3`)throw Error(`[webority-ui] context-menu expects ui-elements 0.191.3 but the page loaded `+c+`.`);function l(e){"@babel/helpers - typeof";return l=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},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=`[role="menuitem"]`,m=`.wui-context-menu-sub`,h=`input.wui-context-menu-search`,g=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,_=500,v=10,y=400,b=null,x=null,S=0;function C(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var w=new WeakMap;function T(e,t,n){let r=w.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return w.set(e,{region:t,cancel:n}),!0}var E=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,D=e=>`focus`in e,O=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),k=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),A=e=>[...e.children].filter(e=>e instanceof HTMLElement),j=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},M=e=>j(e,0),N=e=>j(e,1),P=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null};function F(e,t){return!(e instanceof Node)||e.contains(t)}function I(e){let t=new Map;for(let n=e;n;n=n.parentElement)t.set(n,[n.scrollLeft,n.scrollTop]);return{x:window.scrollX,y:window.scrollY,scrollers:t}}function L(e,t){if(!(t instanceof Element))return window.scrollX!==e.x||window.scrollY!==e.y;let n=e.scrollers.get(t);return!n||t.scrollLeft!==n[0]||t.scrollTop!==n[1]}var R=class extends n.ElementBase{static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),f(this,`_region`,void 0),f(this,`_origin`,void 0),f(this,`_returnFocus`,void 0),f(this,`_press`,void 0),f(this,`_scrollMark`,void 0),f(this,`_swallowClick`,void 0),f(this,`_unbindKeys`,void 0),f(this,`_anchor`,void 0),f(this,`_closingByKey`,void 0),f(this,`_onContextMenu`,void 0),f(this,`_onContextMenuCapture`,void 0),f(this,`_onDocKeyDown`,void 0),f(this,`_onDocClick`,void 0),f(this,`_onPointerDown`,void 0),f(this,`_onPressMove`,void 0),f(this,`_onPressEnd`,void 0),f(this,`_onClickCapture`,void 0),f(this,`_onKeyDown`,void 0),f(this,`_onClick`,void 0),f(this,`_onInput`,void 0),f(this,`_onMouseMove`,void 0),f(this,`_onDismiss`,void 0),f(this,`_onPointerDownCapture`,void 0),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._scrollMark=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>v&&this._cancelPress()},this._onPressEnd=e=>{(e.type!==`scroll`||!this._press||F(e.target,this._press.region)&&L(this._press.mark,e.target))&&this._cancelPress()},this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&P(E(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=P(E(e.target),p);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||(e.type!==`scroll`||!this._inPanel(e.target)&&F(e.target,this._region??this)&&(!this._scrollMark||L(this._scrollMark,e.target)))&&this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&(0,o.isPopoverOpen)(e)}open(e,t,{region:n=this,origin:r=n,trigger:i=null,keyboard:s=!1}={}){let c=this._panel();if(!c)return!1;let l=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:r,trigger:i}});if(this.dispatchEvent(l),l.defaultPrevented)return!1;if(this._decorate(c),b&&b!==this&&b.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&D(e)?e:null}this._region=n,this._origin=r,this._scrollMark=I(n),x=null,b=this,this._unbindKeys?.(),this._unbindKeys=(0,a.bindMenuKeys)(c,{items:()=>this._menuRows()}),this._anchor?.remove();let u=this.hasAttribute(`open`);return this._anchor=C(e,t,u),(0,o.openAnchoredPopover)(this._anchor,c,{mode:u?`manual`:`auto`,keepOffscreen:u,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{(0,o.isPopoverOpen)(c)&&((s?this._rowsOf(c)[0]:null)??c).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:r,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&(0,o.isPopoverOpen)(t)&&(e&&(this._closingByKey=!0),(0,o.closeAnchoredPopover)(t))}_finish(e){let t=this._panel();if(t)for(let e of k(t,m))this._setSub(e,!1);b===this&&(b=null),this._scrollMark=null,window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||(0,o.isPopoverOpen)(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=E(document.activeElement);if(!e||e.matches(h))return[];let t=P(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return A(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?k(e,p).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&(0,i.isDrawn)(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=E(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(g))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=E(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=P(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return x?.menu===this&&this.isOpen&&performance.now()-x.at<y}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!w.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||T(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:E(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!w.has(e))return;if((0,r.isImeSafeEnter)(e)){let t=this._triggerFor(e.target);if(!t||!T(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!T(e,t,()=>this.close(!0)))return;let n=E(e.target);if(!n)return;let i=n.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:t,origin:n,keyboard:!0})&&(e.preventDefault(),x={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!T(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!T(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=E(e.target);this._press={x:n,y:r,region:t,mark:I(t),timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},_)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let t=E(e.target);if(!t)return;if(t.matches(h)){this._handleSearchKey(e,t);return}let n=P(t,`[role="menu"]`);if(!n)return;let i=P(t,p),a=n.matches(`.wui-context-menu-subpanel`)?n.parentElement:null,o=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(e.key===`Tab`)this.close(!0);else if(o===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(o===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else((0,r.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=P(t,m);if(!n)return;let r=this._rowsOf(N(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(m)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of A(n))t!==e&&t.matches(m)&&this._closeSub(t);this._setSub(e,!0);let r=N(e).querySelector(`:scope > ${h}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(N(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of k(N(e),m))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),M(e).focus({preventScroll:!0})}_setSub(e,t){let n=N(e);t?((0,o.openAnchoredPopover)(M(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),M(e).setAttribute(`aria-expanded`,String((0,o.isPopoverOpen)(n)))):(0,o.isPopoverOpen)(n)?(0,o.closeAnchoredPopover)(n):this._onSubClosed(e)}_onSubClosed(e){let t=N(e);if((0,o.isPopoverOpen)(t))return;let n=M(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of A(N(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(p)?t.hidden=n!==``&&!O(t).toLowerCase().includes(n):t.matches(m)&&(t.hidden=n!==``&&!O(M(t)).toLowerCase().includes(n))}_handleInput(e){let t=E(e.target)?.closest(h);if(!(t instanceof HTMLInputElement))return;let n=P(t,m);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of k(e,p)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++S}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=P(E(e.target),p);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...k(e,m)].reverse())(0,o.closeAnchoredPopover)(N(t));(0,o.closeAnchoredPopover)(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};(0,t.defineElement)(`wui-context-menu`,R),e.WuiContextMenu=R})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
1
+ (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.193.0`)throw Error(`[webority-ui] context-menu expects ui-elements 0.193.0 but the page loaded `+c+`.`);function l(e){"@babel/helpers - typeof";return l=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},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=`[role="menuitem"]`,m=`.wui-context-menu-sub`,h=`input.wui-context-menu-search`,g=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,_=500,v=10,y=400,b=null,x=null,S=0;function C(e,t,n){let r=document.createElement(`span`);return r.setAttribute(`aria-hidden`,`true`),r.style.cssText=n?`position:absolute;left:${e+window.scrollX}px;top:${t+window.scrollY}px;width:0;height:0;`:`position:fixed;left:${e}px;top:${t}px;width:0;height:0;`,document.body.append(r),r}var w=new WeakMap;function T(e,t,n){let r=w.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return w.set(e,{region:t,cancel:n}),!0}var E=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,D=e=>`focus`in e,O=e=>[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE||e instanceof Element&&!e.matches(`.wui-context-menu-hint, .wui-context-menu-tick`)).map(e=>e.textContent).join(``),k=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),A=e=>[...e.children].filter(e=>e instanceof HTMLElement),j=(e,t)=>{let n=e.children[t];if(!(n instanceof HTMLElement))throw Error(`a submenu holds its opener and then its panel`);return n},M=e=>j(e,0),N=e=>j(e,1),P=(e,t)=>{let n=e?.closest(t);return n instanceof HTMLElement?n:null};function F(e,t){return!(e instanceof Node)||e.contains(t)}function I(e){let t=new Map;for(let n=e;n;n=n.parentElement)t.set(n,[n.scrollLeft,n.scrollTop]);return{x:window.scrollX,y:window.scrollY,scrollers:t}}function L(e,t){if(!(t instanceof Element))return window.scrollX!==e.x||window.scrollY!==e.y;let n=e.scrollers.get(t);return!n||t.scrollLeft!==n[0]||t.scrollTop!==n[1]}var R=class extends n.ElementBase{static get observedAttributes(){return[`disabled`,`open`]}constructor(){super(),f(this,`_region`,void 0),f(this,`_origin`,void 0),f(this,`_returnFocus`,void 0),f(this,`_press`,void 0),f(this,`_scrollMark`,void 0),f(this,`_swallowClick`,void 0),f(this,`_unbindKeys`,void 0),f(this,`_anchor`,void 0),f(this,`_closingByKey`,void 0),f(this,`_onContextMenu`,void 0),f(this,`_onContextMenuCapture`,void 0),f(this,`_onDocKeyDown`,void 0),f(this,`_onDocClick`,void 0),f(this,`_onPointerDown`,void 0),f(this,`_onPressMove`,void 0),f(this,`_onPressEnd`,void 0),f(this,`_onClickCapture`,void 0),f(this,`_onKeyDown`,void 0),f(this,`_onClick`,void 0),f(this,`_onInput`,void 0),f(this,`_onMouseMove`,void 0),f(this,`_onDismiss`,void 0),f(this,`_onPointerDownCapture`,void 0),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._scrollMark=null,this._swallowClick=!1,this._unbindKeys=null,this._anchor=null,this._closingByKey=!1,this._onContextMenu=e=>this._handleContextMenu(e),this._onContextMenuCapture=e=>{this.isOpen&&!this._inPanel(e.target)&&!this._isKeyEcho()&&this.close()},this._onDocKeyDown=e=>this._handleDocKeyDown(e),this._onDocClick=e=>this._handleDocClick(e),this._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>v&&this._cancelPress()},this._onPressEnd=e=>{(e.type!==`scroll`||!this._press||F(e.target,this._press.region)&&L(this._press.mark,e.target))&&this._cancelPress()},this._onClickCapture=e=>{if(this._swallowClick&&this._region){if(!(e.target instanceof Node))throw Error(`a click target is always a node`);this._region.contains(e.target)&&(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())}},this._onKeyDown=e=>{if(this.isOpen&&this._inPanel(e.target)){if(e.key===`Escape`){if(e.stopPropagation(),this.hasAttribute(`open`)&&P(E(e.target),`[role="menu"]`)===this._panel()){e.preventDefault(),this.close(!0);return}this._closingByKey=!0}this._handleMenuKey(e)}},this._onClick=e=>this._handleClick(e),this._onInput=e=>this._handleInput(e),this._onMouseMove=e=>{let t=P(E(e.target),p);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{this.hasAttribute(`open`)||(e.type!==`scroll`||!this._inPanel(e.target)&&F(e.target,this._region??this)&&(!this._scrollMark||L(this._scrollMark,e.target)))&&this.close()},this._onPointerDownCapture=()=>{this._swallowClick=!1}}connectedCallback(){this._teardown(),document.addEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.addEventListener(`contextmenu`,this._onContextMenu),document.addEventListener(`keydown`,this._onDocKeyDown),document.addEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.addEventListener(`pointerdown`,this._onPointerDown),document.addEventListener(`click`,this._onClickCapture,!0),document.addEventListener(`click`,this._onDocClick),window.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`input`,this._onInput),this.addEventListener(`mousemove`,this._onMouseMove),this._syncOpen()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){e===`open`?this.isConnected&&this._syncOpen():this.disabled&&this.close()}get target(){return this.getAttribute(`target`)}set target(e){e==null||e===``?this.removeAttribute(`target`):this.setAttribute(`target`,String(e))}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get isOpen(){let e=this._panel();return!!e&&(0,o.isPopoverOpen)(e)}open(e,t,{region:n=this,origin:r=n,trigger:i=null,keyboard:s=!1}={}){let c=this._panel();if(!c)return!1;let l=new CustomEvent(`wui-context-menu:beforeopen`,{bubbles:!0,cancelable:!0,detail:{region:n,origin:r,trigger:i}});if(this.dispatchEvent(l),l.defaultPrevented)return!1;if(this._decorate(c),b&&b!==this&&b.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)&&D(e)?e:null}this._region=n,this._origin=r,this._scrollMark=I(n),x=null,b=this,this._unbindKeys?.(),this._unbindKeys=(0,a.bindMenuKeys)(c,{items:()=>this._menuRows()}),this._anchor?.remove();let u=this.hasAttribute(`open`);return this._anchor=C(e,t,u),(0,o.openAnchoredPopover)(this._anchor,c,{mode:u?`manual`:`auto`,keepOffscreen:u,clampHeight:!0,onClosed:()=>this._onPanelClosed()}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),queueMicrotask(()=>{(0,o.isPopoverOpen)(c)&&((s?this._rowsOf(c)[0]:null)??c).focus({preventScroll:!0})}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:n,origin:r,x:e,y:t}})),!0}_syncOpen(){if(!this.hasAttribute(`open`)){this.close(this._inPanel(document.activeElement));return}let e=this.target?document.querySelector(this.target):this,t=e&&this._regionRect(e);e&&t&&this.open(t.left,t.top,{region:e,origin:e})}_regionRect(e){if(e!==this)return e.getBoundingClientRect();let t=[...this.children].filter(e=>e!==this._panel()).map(e=>e.getBoundingClientRect());return t.length?{left:Math.min(...t.map(e=>e.left)),top:Math.min(...t.map(e=>e.top))}:null}close(e=!1){let t=this._panel();t&&(0,o.isPopoverOpen)(t)&&(e&&(this._closingByKey=!0),(0,o.closeAnchoredPopover)(t))}_finish(e){let t=this._panel();if(t)for(let e of k(t,m))this._setSub(e,!1);b===this&&(b=null),this._scrollMark=null,window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._unbindKeys?.(),this._unbindKeys=null,this._anchor?.remove(),this._anchor=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_onPanelClosed(){let e=this._panel();if(!e||(0,o.isPopoverOpen)(e))return;let t=this._closingByKey;this._closingByKey=!1,this._finish(t)}_menuRows(){let e=E(document.activeElement);if(!e||e.matches(h))return[];let t=P(e,`[role="menu"]`);return t?this._rowsOf(t):[]}_panel(){return A(this).find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return e instanceof Node&&!!this._panel()?.contains(e)}_rowsOf(e){return e?k(e,p).filter(t=>t.closest(`[role="menu"]`)===e&&!this._isDisabled(t)&&(0,i.isDrawn)(t)):[]}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=E(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(g))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_triggerFor(e){let t=E(e),n=this.getAttribute(`trigger`);if(!t||!n||this._inPanel(t))return null;let r=P(t,n),i=r&&this._regionFor(r);return r&&i?{trigger:r,region:i}:null}_isKeyEcho(){return x?.menu===this&&this.isOpen&&performance.now()-x.at<y}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!w.has(e))return;let t=this._regionFor(e.target);t&&(this._isKeyEcho()?e.preventDefault():e.shiftKey||T(e,t,()=>this.close(!0))&&this.open(e.clientX,e.clientY,{region:t,origin:E(e.target)})&&e.preventDefault())}_handleDocKeyDown(e){if(e.defaultPrevented&&!w.has(e))return;if((0,r.isImeSafeEnter)(e)){let t=this._triggerFor(e.target);if(!t||!T(e,t.region,()=>this.close(!0)))return;e.preventDefault(),t.trigger.click();return}if(!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!T(e,t,()=>this.close(!0)))return;let n=E(e.target);if(!n)return;let i=n.getBoundingClientRect();this.open(i.left+Math.min(16,i.width/2),i.bottom,{region:t,origin:n,keyboard:!0})&&(e.preventDefault(),x={menu:this,at:performance.now()})}_handleDocClick(e){let t=this._triggerFor(e.target);if(!t||!T(e,t.region,()=>this.close(!0)))return;let n=t.trigger.getBoundingClientRect();this.open(n.left,n.bottom,{region:t.region,origin:t.trigger,trigger:t.trigger,keyboard:e.detail===0})}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!T(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=E(e.target);this._press={x:n,y:r,region:t,mark:I(t),timer:setTimeout(()=>{this._cancelPress(),this.open(n,r,{region:t,origin:i})&&(this._swallowClick=!0)},_)},document.addEventListener(`pointermove`,this._onPressMove,{passive:!0}),document.addEventListener(`pointerup`,this._onPressEnd),document.addEventListener(`pointercancel`,this._onPressEnd),window.addEventListener(`scroll`,this._onPressEnd,!0)}_cancelPress(){this._press&&(clearTimeout(this._press.timer),this._press=null,document.removeEventListener(`pointermove`,this._onPressMove),document.removeEventListener(`pointerup`,this._onPressEnd),document.removeEventListener(`pointercancel`,this._onPressEnd),window.removeEventListener(`scroll`,this._onPressEnd,!0))}_handleMenuKey(e){if(!this.isOpen)return;let t=E(e.target);if(!t)return;if(t.matches(h)){this._handleSearchKey(e,t);return}let n=P(t,`[role="menu"]`);if(!n)return;let i=P(t,p),a=n.matches(`.wui-context-menu-subpanel`)?n.parentElement:null,o=(0,s.mirrorKey)(e.key,(0,s.isRtl)(this));if(e.key===`Tab`)this.close(!0);else if(o===`ArrowRight`){let t=i&&this._subOf(i);if(!t)return;e.preventDefault(),this._openSub(t,!0)}else if(o===`ArrowLeft`){if(!a)return;e.preventDefault(),this._closeSubByKey(a)}else((0,r.isImeSafeEnter)(e)||e.key===` `)&&(e.preventDefault(),i?.click())}_handleSearchKey(e,t){let n=P(t,m);if(!n)return;let r=this._rowsOf(N(n));e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closeSubByKey(n)):e.key===`ArrowDown`?(e.preventDefault(),r[0]?.focus({preventScroll:!0})):e.key===`ArrowUp`?(e.preventDefault(),r[r.length-1]?.focus({preventScroll:!0})):e.key===`Tab`&&this.close(!0)}_subOf(e){return e.hasAttribute(`aria-haspopup`)&&e.parentElement?.matches(m)?e.parentElement:null}_openSub(e,t){let n=e.parentElement;if(!n)throw Error(`a submenu is always inside its menu panel`);for(let t of A(n))t!==e&&t.matches(m)&&this._closeSub(t);this._setSub(e,!0);let r=N(e).querySelector(`:scope > ${h}`),i=e.hasAttribute(`data-searchable`)&&r instanceof HTMLInputElement?r:null;i?(i.value=``,this._filter(e,``),i.focus({preventScroll:!0})):t&&this._rowsOf(N(e))[0]?.focus({preventScroll:!0})}_closeSub(e){for(let t of k(N(e),m))this._setSub(t,!1);this._setSub(e,!1)}_closeSubByKey(e){this._closeSub(e),M(e).focus({preventScroll:!0})}_setSub(e,t){let n=N(e);t?((0,o.openAnchoredPopover)(M(e),n,{mode:`auto`,beside:!0,onClosed:()=>this._onSubClosed(e)}),M(e).setAttribute(`aria-expanded`,String((0,o.isPopoverOpen)(n)))):(0,o.isPopoverOpen)(n)?(0,o.closeAnchoredPopover)(n):this._onSubClosed(e)}_onSubClosed(e){let t=N(e);if((0,o.isPopoverOpen)(t))return;let n=M(e);n.setAttribute(`aria-expanded`,`false`),t.removeAttribute(`data-side`);let r=this._closingByKey;this._closingByKey=!1,r&&n.focus({preventScroll:!0})}_filter(e,t){let n=t.trim().toLowerCase();for(let t of A(N(e)))t.tagName===`HR`?t.hidden=n!==``:t.matches(p)?t.hidden=n!==``&&!O(t).toLowerCase().includes(n):t.matches(m)&&(t.hidden=n!==``&&!O(M(t)).toLowerCase().includes(n))}_handleInput(e){let t=E(e.target)?.closest(h);if(!(t instanceof HTMLInputElement))return;let n=P(t,m);n?.hasAttribute(`data-searchable`)&&this._inPanel(n)&&this._filter(n,t.value)}_decorate(e){for(let t of k(e,p)){let e=t.getAttribute(`aria-checked`)===`true`,n=t.querySelector(`:scope > .wui-context-menu-tick`);if(e&&!n){let e=document.createElement(`span`);e.className=`wui-context-menu-tick`,e.setAttribute(`aria-hidden`,`true`),t.prepend(e)}else!e&&n&&n.remove();let r=t.querySelector(`:scope > .wui-context-menu-hint`),i=t.dataset.hint;if(i){let e=r??document.createElement(`span`);r||(e.className=`wui-context-menu-hint`,e.id=`wui-context-menu-hint-${++S}`,t.append(e)),e.textContent=i,t.setAttribute(`aria-describedby`,e.id)}else r&&(r.remove(),t.removeAttribute(`aria-describedby`))}}_handleClick(e){let t=P(E(e.target),p);if(!t||!this._inPanel(t))return;if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}let n=this._subOf(t);n?(e.preventDefault(),this._openSub(n,e.detail===0)):(this.close(!0),this.dispatchEvent(new CustomEvent(`wui-context-menu:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,region:this._region,origin:this._origin}})))}_teardown(){let e=this._panel();if(this._closingByKey=!1,e){for(let t of[...k(e,m)].reverse())(0,o.closeAnchoredPopover)(N(t));(0,o.closeAnchoredPopover)(e)}this._anchor&&this._finish(!1),this._cancelPress(),document.removeEventListener(`contextmenu`,this._onContextMenuCapture,!0),document.removeEventListener(`contextmenu`,this._onContextMenu),document.removeEventListener(`keydown`,this._onDocKeyDown),document.removeEventListener(`pointerdown`,this._onPointerDownCapture,!0),document.removeEventListener(`pointerdown`,this._onPointerDown),document.removeEventListener(`click`,this._onClickCapture,!0),document.removeEventListener(`click`,this._onDocClick),window.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`input`,this._onInput),this.removeEventListener(`mousemove`,this._onMouseMove)}};(0,t.defineElement)(`wui-context-menu`,R),e.WuiContextMenu=R})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.isDrawn,WeborityUiElementsInternal.modules.menuKeyNav,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl);
@@ -1 +1 @@
1
- (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.191.3`)throw Error(`[webority-ui] dashboard-grid expects ui-elements 0.191.3 but the page loaded `+i+`.`);var a={addEmptyText:`Every widget is shown.`,addLabel:`Add a widget`,earlierLabel:`Move {title} earlier`,earlierText:`Earlier`,editLabel:`Arrange widgets`,hiddenText:`{title} hidden.`,hideLabel:`Hide {title}`,hideText:`Hide`,laterLabel:`Move {title} later`,laterText:`Later`,movedText:`{title} moved to position {position} of {count}.`,resetLabel:`Reset to default`,resetText:`Layout reset to the default.`,showLabel:`Add {title}`,shownText:`{title} shown at position {position} of {count}.`};function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=`wui:layoutchange`,d=`wui:reset`,f=`wui-dashboard-cell`,p=`wui-dashboard-cell-tools`,m=`wui-dashboard-grid-bar`,h=`wui-dashboard-grid-menu`,g=`wui-dashboard-grid-live`,_=()=>(0,r.readText)(`dashboardGrid`,a);function v(e){if(e.classList.contains(`wui-dashboard-cell-fifth`))return 5;for(let t of[3,4,6,8])if(e.classList.contains(`wui-dashboard-cell-${t}`))return t;return 12}function y(e){let t=document.createElement(`p`);return t.className=`wui-dashboard-grid-empty`,t.textContent=e,t}function b(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.dataset.wuiAction=t,r.textContent=e,r}var x=class extends n.ElementBase{constructor(...e){super(...e),l(this,`tools`,null),l(this,`live`,null),l(this,`menu`,null),l(this,`add`,null),l(this,`observer`,null),l(this,`menuKey`,null),l(this,`focusId`,null),l(this,`onClick`,e=>{let t=e.target instanceof Element?e.target.closest(`button[data-wui-action]`):null;if(!(t instanceof HTMLButtonElement))return;let n=t.dataset.wuiAction;if(n===`reset`){this.reset();return}if(n===`add`){this.menu&&(this.menu.hidden=!this.menu.hidden),this.add?.setAttribute(`aria-expanded`,String(this.menu?.hidden===!1));return}if(n===`show`){this.setHidden(t.dataset.widgetId??``,!1);return}let r=t.closest(`.${f}`),i=r instanceof HTMLElement?r.dataset.widgetId:void 0;i&&(n===`earlier`&&this.moveBy(i,-1),n===`later`&&this.moveBy(i,1),n===`hide`&&this.setHidden(i,!0))}),l(this,`onKeydown`,e=>{let t=e.target;if(!(t instanceof HTMLElement)||t.parentElement!==this||!t.classList.contains(f))return;let n=t.dataset.widgetId;if(!n)return;let r=null;(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(r=-1),(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(r=1),r!==null&&(e.preventDefault(),this.moveBy(n,r))})}connectedCallback(){this.hasAttribute(`editable`)&&(this.checkCells(),this.tools||this.build(),this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`]}),this.addEventListener(`click`,this.onClick),this.addEventListener(`keydown`,this.onKeydown))}disconnectedCallback(){this.observer?.disconnect(),this.observer=null,this.removeEventListener(`click`,this.onClick),this.removeEventListener(`keydown`,this.onKeydown)}cells(){return Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(f))}checkCells(){for(let e of this.cells())if(!e.dataset.widgetId)throw Error(`<wui-dashboard-grid>: every cell needs a widget id (data-widget-id) when the grid is editable.`)}cellById(e){return this.cells().find(t=>t.dataset.widgetId===e)}titleFor(e){let t=this.cellById(e);return t?this.titleOf(t):e}titleOf(e){return e.dataset.wuiTitle??e.dataset.widgetId??``}build(){let e=_(),t=document.createElement(`div`);t.className=m,t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,e.editLabel);let n=b(e.addLabel,`add`,`wui-dashboard-grid-add`);n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`div`);i.className=h,i.hidden=!0,t.append(n,i,b(e.resetLabel,`reset`,`wui-dashboard-grid-reset`));let a=document.createElement(`p`);a.className=g,a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),this.prepend(t,a),this.tools=t,this.menu=i,this.add=n,this.live=a;for(let t of this.cells()){t.tabIndex=0;let n=this.titleOf(t),i=document.createElement(`div`);i.className=p,i.append(this.cellButton((0,r.fillText)(e.earlierLabel,{title:n}),e.earlierText,`earlier`),this.cellButton((0,r.fillText)(e.laterLabel,{title:n}),e.laterText,`later`),this.cellButton((0,r.fillText)(e.hideLabel,{title:n}),e.hideText,`hide`)),t.prepend(i)}this.sync()}cellButton(e,t,n){let r=b(t,n,`wui-dashboard-cell-tool`);return r.setAttribute(`aria-label`,e),r}layout(){return this.cells().map(e=>({id:e.dataset.widgetId??``,span:v(e),hidden:e.hidden!==!1}))}sync(){if(!this.menu||!this.add)return;let e=this.cells().filter(e=>e.hidden),t=e.map(e=>e.dataset.widgetId??``).join(`\0`);if(t!==this.menuKey){this.menuKey=t;let n=_(),i=e.length===0?[y(n.addEmptyText)]:e.map(e=>{let t=this.titleOf(e),i=b((0,r.fillText)(n.showLabel,{title:t}),`show`,`wui-dashboard-grid-show`);return i.dataset.widgetId=e.dataset.widgetId??``,i});this.menu.replaceChildren(...i)}if(this.focusId!==null){let e=this.cellById(this.focusId);this.focusId=null,e&&!e.hidden&&e.focus()}}commit(e,t,n){this.focusId=n,this.hasAttribute(`controlled`)||(this.apply(e),this.sync()),this.live&&(this.live.textContent=t),this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:JSON.stringify(e)}))}apply(e){for(let t of e){let e=this.cellById(t.id);e&&(this.append(e),e.hidden=t.hidden)}}moveBy(e,t){let n=this.layout(),i=n.filter(e=>!e.hidden),a=i.findIndex(t=>t.id===e);if(a<0)return;let o=i[a],s=i[a+t];if(!o||!s)return;let c=n.indexOf(o),l=n.indexOf(s);[n[c],n[l]]=[s,o];let u=this.titleFor(e),d=a+t+1;this.commit(n,(0,r.fillText)(_().movedText,{title:u,position:d,count:i.length}),e)}setHidden(e,t){let n=this.layout(),i=n.find(t=>t.id===e);if(!i)return;i.hidden=t;let a=this.titleFor(e),o=_();if(t){this.commit(n,(0,r.fillText)(o.hiddenText,{title:a}),null);return}let s=n.filter(e=>!e.hidden),c=s.findIndex(t=>t.id===e)+1;this.commit(n,(0,r.fillText)(o.shownText,{title:a,position:c,count:s.length}),e)}reset(){this.live&&(this.live.textContent=_().resetText),this.dispatchEvent(new CustomEvent(d,{bubbles:!0}))}};(0,t.defineElement)(`wui-dashboard-grid`,x),e.LAYOUT_CHANGE_EVENT=u,e.LAYOUT_RESET_EVENT=d,e.WuiDashboardGrid=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=globalThis.WeborityUiElementsInternal?.version;if(i!==`0.193.0`)throw Error(`[webority-ui] dashboard-grid expects ui-elements 0.193.0 but the page loaded `+i+`.`);var a={addEmptyText:`Every widget is shown.`,addLabel:`Add a widget`,earlierLabel:`Move {title} earlier`,earlierText:`Earlier`,editLabel:`Arrange widgets`,hiddenText:`{title} hidden.`,hideLabel:`Hide {title}`,hideText:`Hide`,laterLabel:`Move {title} later`,laterText:`Later`,movedText:`{title} moved to position {position} of {count}.`,resetLabel:`Reset to default`,resetText:`Layout reset to the default.`,showLabel:`Add {title}`,shownText:`{title} shown at position {position} of {count}.`};function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=`wui:layoutchange`,d=`wui:reset`,f=`wui-dashboard-cell`,p=`wui-dashboard-cell-tools`,m=`wui-dashboard-grid-bar`,h=`wui-dashboard-grid-menu`,g=`wui-dashboard-grid-live`,_=()=>(0,r.readText)(`dashboardGrid`,a);function v(e){if(e.classList.contains(`wui-dashboard-cell-fifth`))return 5;for(let t of[3,4,6,8])if(e.classList.contains(`wui-dashboard-cell-${t}`))return t;return 12}function y(e){let t=document.createElement(`p`);return t.className=`wui-dashboard-grid-empty`,t.textContent=e,t}function b(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.dataset.wuiAction=t,r.textContent=e,r}var x=class extends n.ElementBase{constructor(...e){super(...e),l(this,`tools`,null),l(this,`live`,null),l(this,`menu`,null),l(this,`add`,null),l(this,`observer`,null),l(this,`menuKey`,null),l(this,`focusId`,null),l(this,`onClick`,e=>{let t=e.target instanceof Element?e.target.closest(`button[data-wui-action]`):null;if(!(t instanceof HTMLButtonElement))return;let n=t.dataset.wuiAction;if(n===`reset`){this.reset();return}if(n===`add`){this.menu&&(this.menu.hidden=!this.menu.hidden),this.add?.setAttribute(`aria-expanded`,String(this.menu?.hidden===!1));return}if(n===`show`){this.setHidden(t.dataset.widgetId??``,!1);return}let r=t.closest(`.${f}`),i=r instanceof HTMLElement?r.dataset.widgetId:void 0;i&&(n===`earlier`&&this.moveBy(i,-1),n===`later`&&this.moveBy(i,1),n===`hide`&&this.setHidden(i,!0))}),l(this,`onKeydown`,e=>{let t=e.target;if(!(t instanceof HTMLElement)||t.parentElement!==this||!t.classList.contains(f))return;let n=t.dataset.widgetId;if(!n)return;let r=null;(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(r=-1),(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(r=1),r!==null&&(e.preventDefault(),this.moveBy(n,r))})}connectedCallback(){this.hasAttribute(`editable`)&&(this.checkCells(),this.tools||this.build(),this.observer=new MutationObserver(()=>this.sync()),this.observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`]}),this.addEventListener(`click`,this.onClick),this.addEventListener(`keydown`,this.onKeydown))}disconnectedCallback(){this.observer?.disconnect(),this.observer=null,this.removeEventListener(`click`,this.onClick),this.removeEventListener(`keydown`,this.onKeydown)}cells(){return Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.classList.contains(f))}checkCells(){for(let e of this.cells())if(!e.dataset.widgetId)throw Error(`<wui-dashboard-grid>: every cell needs a widget id (data-widget-id) when the grid is editable.`)}cellById(e){return this.cells().find(t=>t.dataset.widgetId===e)}titleFor(e){let t=this.cellById(e);return t?this.titleOf(t):e}titleOf(e){return e.dataset.wuiTitle??e.dataset.widgetId??``}build(){let e=_(),t=document.createElement(`div`);t.className=m,t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,e.editLabel);let n=b(e.addLabel,`add`,`wui-dashboard-grid-add`);n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`div`);i.className=h,i.hidden=!0,t.append(n,i,b(e.resetLabel,`reset`,`wui-dashboard-grid-reset`));let a=document.createElement(`p`);a.className=g,a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),this.prepend(t,a),this.tools=t,this.menu=i,this.add=n,this.live=a;for(let t of this.cells()){t.tabIndex=0;let n=this.titleOf(t),i=document.createElement(`div`);i.className=p,i.append(this.cellButton((0,r.fillText)(e.earlierLabel,{title:n}),e.earlierText,`earlier`),this.cellButton((0,r.fillText)(e.laterLabel,{title:n}),e.laterText,`later`),this.cellButton((0,r.fillText)(e.hideLabel,{title:n}),e.hideText,`hide`)),t.prepend(i)}this.sync()}cellButton(e,t,n){let r=b(t,n,`wui-dashboard-cell-tool`);return r.setAttribute(`aria-label`,e),r}layout(){return this.cells().map(e=>({id:e.dataset.widgetId??``,span:v(e),hidden:e.hidden!==!1}))}sync(){if(!this.menu||!this.add)return;let e=this.cells().filter(e=>e.hidden),t=e.map(e=>e.dataset.widgetId??``).join(`\0`);if(t!==this.menuKey){this.menuKey=t;let n=_(),i=e.length===0?[y(n.addEmptyText)]:e.map(e=>{let t=this.titleOf(e),i=b((0,r.fillText)(n.showLabel,{title:t}),`show`,`wui-dashboard-grid-show`);return i.dataset.widgetId=e.dataset.widgetId??``,i});this.menu.replaceChildren(...i)}if(this.focusId!==null){let e=this.cellById(this.focusId);this.focusId=null,e&&!e.hidden&&e.focus()}}commit(e,t,n){this.focusId=n,this.hasAttribute(`controlled`)||(this.apply(e),this.sync()),this.live&&(this.live.textContent=t),this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:JSON.stringify(e)}))}apply(e){for(let t of e){let e=this.cellById(t.id);e&&(this.append(e),e.hidden=t.hidden)}}moveBy(e,t){let n=this.layout(),i=n.filter(e=>!e.hidden),a=i.findIndex(t=>t.id===e);if(a<0)return;let o=i[a],s=i[a+t];if(!o||!s)return;let c=n.indexOf(o),l=n.indexOf(s);[n[c],n[l]]=[s,o];let u=this.titleFor(e),d=a+t+1;this.commit(n,(0,r.fillText)(_().movedText,{title:u,position:d,count:i.length}),e)}setHidden(e,t){let n=this.layout(),i=n.find(t=>t.id===e);if(!i)return;i.hidden=t;let a=this.titleFor(e),o=_();if(t){this.commit(n,(0,r.fillText)(o.hiddenText,{title:a}),null);return}let s=n.filter(e=>!e.hidden),c=s.findIndex(t=>t.id===e)+1;this.commit(n,(0,r.fillText)(o.shownText,{title:a,position:c,count:s.length}),e)}reset(){this.live&&(this.live.textContent=_().resetText),this.dispatchEvent(new CustomEvent(d,{bubbles:!0}))}};(0,t.defineElement)(`wui-dashboard-grid`,x),e.LAYOUT_CHANGE_EVENT=u,e.LAYOUT_RESET_EVENT=d,e.WuiDashboardGrid=x})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.191.3`)throw Error(`[webority-ui] data-table expects ui-elements 0.191.3 but the page loaded `+l+`.`);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 d(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 f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=`.wui-col-resize`,h=`.wui-group-row, .wui-virtual-spacer`,g=`.wui-select-cell, .wui-expand-cell`;function _(){return(0,o.svgRoot)({class:`wui-icon`,"data-icon":`chevron-down`,"data-wui":`AppIcon`,width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[[`path`,{stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":`10`,"stroke-width":`1.5`,d:`M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95`}]])}function v(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function y(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var b=e=>{let t=(0,r.closestOf)(e,m);return t instanceof HTMLElement?t:null},x=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),S=class extends i.ElementBase{constructor(){super(),p(this,`_frame`,void 0),p(this,`_headDirty`,void 0),p(this,`_rowsDirty`,void 0),p(this,`_frozenSig`,void 0),p(this,`_natural`,void 0),p(this,`_widths`,void 0),p(this,`_collapsed`,void 0),p(this,`_groupOrder`,void 0),p(this,`_items`,void 0),p(this,`_range`,void 0),p(this,`_drag`,void 0),p(this,`_userSized`,void 0),p(this,`_swallowClick`,void 0),p(this,`_mo`,void 0),p(this,`_ro`,void 0),p(this,`_fonts`,void 0),p(this,`_onPointerDown`,void 0),p(this,`_onKeyDown`,void 0),p(this,`_onClick`,void 0),p(this,`_onDblClick`,void 0),p(this,`_onScroll`,void 0),p(this,`_onFonts`,void 0),p(this,`_top`,null),p(this,`_bottom`,null),p(this,`_rowHeight`,0),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=b(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=(0,n.readColumnWidths)(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._paintSaves(),this._schedule()}_paintSaves(){this.querySelectorAll(`tbody > tr[data-wui-save-state]`).forEach(e=>{e instanceof HTMLTableRowElement&&(0,n.paintSaveStatus)(e,e.getAttribute(n.ROW_SAVE_ATTR))})}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,t){let r=this._headCells(e),i=r.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(g)?`lead`:null});if(!i.some(e=>e===`start`||e===`end`))return;let a=(0,n.planPins)(i);a.forEach((e,t)=>{e&&this._ro?.observe(v(r[t]))});let o=e=>v(r[e]).getBoundingClientRect().width,s=0;a.forEach((t,r)=>{t?.side===`start`&&(this._setVar(e,(0,n.pinOffsetVar)(`start`,t.ordinal),s),s+=o(r))}),s=0;for(let t=a.length-1;t>=0;t--){let r=a[t];r?.side===`end`&&(this._setVar(e,(0,n.pinOffsetVar)(`end`,r.ordinal),s),s+=o(t))}if(t)for(let t of e.rows)t.matches(`${h}, .wui-row-expanded`)||t.cells.length!==r.length||a.forEach((e,r)=>{if(!e)return;let i=v(t.cells[r]);i.classList.contains(`wui-pin-${e.side}`)||i.classList.add(`wui-pin-${e.side}`),e.edge&&!i.classList.contains(`wui-pin-${e.side}-edge`)&&i.classList.add(`wui-pin-${e.side}-edge`);let a=(0,n.pinAtValue)(e.side,e.ordinal);i.style.getPropertyValue(n.PIN_AT_VAR)!==a&&i.style.setProperty(n.PIN_AT_VAR,a)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(g))}_handles(e){let t=this._headCells(e),r=this._resizable(t);t.forEach((e,t)=>{if(!r[t]||e.querySelector(m))return;let i=e.ownerDocument.createElement(`span`);i.className=`wui-col-resize`,i.setAttribute(`role`,`separator`),i.setAttribute(`aria-orientation`,`vertical`),i.setAttribute(`aria-valuemin`,String(n.COLUMN_MIN_WIDTH)),i.setAttribute(`aria-valuemax`,String(n.COLUMN_MAX_WIDTH)),i.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();i.setAttribute(`aria-label`,(0,n.resizeName)(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(i)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(h)&&!x(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let r=t.querySelector(m);r&&this._handleValue(r,(0,n.clampColumnWidth)(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(g))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let r=(0,n.clampColumnWidth)(t);e.style.width=`${r}px`,e.setAttribute(`data-wui-width`,``);let i=e.querySelector(m);return i&&this._handleValue(i,r),r}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,(0,n.widthText)(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(v(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},(0,n.writeColumnWidths)(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let r=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,(0,n.writeColumnWidths)(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(t,r),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=b(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=b(e.target);if(!t||!this.contains(t))return;let r=t.closest(`th`);if((0,a.isImeSafeEnter)(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(r);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let i=this._table;if(!i)return;this._ensureFrozen(i);let o=v(r),s=e.shiftKey?n.RESIZE_STEP_LARGE:n.RESIZE_STEP,c=e.key===`ArrowRight`!==this._rtl(),l=Number.parseFloat(o.style.width)||o.getBoundingClientRect().width;this._resizeTo(o,l+(c?s:-s),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(m)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}let n=(0,r.closestOf)(e.target,`[data-wui-table-export], [data-wui-density]`);if(n&&this.contains(n)){e.preventDefault(),n.hasAttribute(`data-wui-density`)?this._setDensity(n.getAttribute(`data-wui-density`)??``):this._export(n.getAttribute(`data-wui-table-export`)??``);return}if(!this.hasAttribute(`group-by`))return;let i=(0,r.closestOf)(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(i instanceof HTMLTableRowElement)||!this.contains(i))return;let a=i.dataset.groupKey;this._collapsed.has(a)?this._collapsed.delete(a):this._collapsed.add(a),this._showGroup(i,!this._collapsed.has(a));let o=this._table;o&&this.hasAttribute(`virtual`)&&(this._virtual(o,!0),this._mo?.takeRecords())}async _export(e){if(e!==`csv`&&e!==`xlsx`)return;let t=this.querySelector(`:scope > table`);if(!(t instanceof HTMLTableElement))return;let n=Array.from(t.tBodies[0]?.rows??[]).filter(e=>!e.hidden&&!e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`)&&!x(e)),r=new Set;for(let e of n)for(let[t,n]of Array.from(e.cells).entries())(n.matches(g)||n.querySelector(`.u-row-actions`))&&r.add(t);let i=e=>Array.from(e).filter((e,t)=>!r.has(t)).map(e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;for(let e of t.querySelectorAll(`.visually-hidden, .wui-col-resize, .infotip`))e.remove();return(t.textContent??``).replace(/\s+/g,` `).trim()}),a=i(t.tHead?.rows[0]?.cells??[]),o=n.map(e=>i(e.cells)),c=this.getAttribute(`export-name`)??`table`,{downloadTable:l,tableCsv:u,tableXlsx:d}=await(0,s.loadTableExport)();e===`csv`?l([u(a,o)],`text/csv;charset=utf-8`,`${c}.csv`):l([d(a,o)],`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`${c}.xlsx`)}_setDensity(e){let t=this.querySelector(`:scope > table`);if(t instanceof HTMLTableElement){t.classList.remove(`wui-table-cozy`,`wui-table-compact`),(e===`cozy`||e===`compact`)&&t.classList.add(`wui-table-${e}`);for(let t of this.querySelectorAll(`[data-wui-density]`))t.setAttribute(`aria-pressed`,String(t.getAttribute(`data-wui-density`)===e))}}_group(e){let t=this.getAttribute(`group-by`),r=this._headCells(e),i=r.findIndex(e=>e.dataset.key===t);if(i<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(h));if(o.some(x))return;let s=this.ownerDocument,l=new Map;for(let e of a.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&l.set(e.dataset.groupKey,e);let u=this.closest(`[data-wui-server]`)?[]:this._groupOrder,d=(0,n.groupItems)(o,e=>e.dataset.group??e.cells[i]?.textContent?.trim()??``,u);this._groupOrder=d.map(e=>e.key);let f=s.createDocumentFragment(),p=e.hasAttribute(`data-app-datatable-selectable`),m=d.map(e=>{let t=l.get(e.key)??this._groupRow(s,e.key);l.delete(e.key);let i=y(t.querySelector(`.wui-group-cell`),HTMLTableCellElement);return p&&!t.querySelector(`.${c.GROUP_SELECT_CLASS}`)&&t.insertBefore((0,c.createGroupSelectCell)(s,e.key),i),i.colSpan=p?r.length-1:r.length,y(t.querySelector(`.wui-group-count`),HTMLElement).textContent=(0,n.groupCount)(e.items.length),y(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${(0,n.groupRowsText)(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of m)this._showGroup(e,!this._collapsed.has(t));p&&(0,c.syncGroupSelect)(e)}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.replaceChildren(_());let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(h);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let r=e.tBodies[0];if(!r)return;if(t){this._top=this._spacer(r,this._top),this._bottom=this._spacer(r,this._bottom),r.firstElementChild!==this._top&&r.insertBefore(this._top,r.firstChild),r.lastElementChild!==this._bottom&&r.append(this._bottom);let t=Math.max(1,this._headCells(e).length);v(this._top.cells[0]).colSpan=t,v(this._bottom.cells[0]).colSpan=t,this._items=[...r.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let i=e.tHead?.getBoundingClientRect().height||0,a=(0,n.virtualRange)({scrollTop:this.scrollTop-i,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===a.start&&o.end===a.end)return;let s=o?Math.min(o.start,a.start):0,c=o?Math.max(o.end,a.end):this._items.length;for(let e=s;e<c;e++){let t=e<a.start||e>=a.end,n=v(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=a;let l=v(this._top),u=v(this._bottom);l.hidden=a.before===0,u.hidden=a.after===0,v(l.cells[0]).style.height=`${a.before}px`,v(u.cells[0]).style.height=`${a.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?n.ROW_HEIGHTS.compact:e.classList.contains(`wui-table-cozy`)?n.ROW_HEIGHTS.cozy:n.ROW_HEIGHTS.comfortable}};(0,t.defineElement)(`wui-data-table`,S),Object.defineProperty(e,"COLUMN_MAX_WIDTH",{enumerable:!0,get:function(){return n.COLUMN_MAX_WIDTH}}),Object.defineProperty(e,"COLUMN_MIN_WIDTH",{enumerable:!0,get:function(){return n.COLUMN_MIN_WIDTH}}),Object.defineProperty(e,"PIN_AT_VAR",{enumerable:!0,get:function(){return n.PIN_AT_VAR}}),Object.defineProperty(e,"PIN_SIDES",{enumerable:!0,get:function(){return n.PIN_SIDES}}),Object.defineProperty(e,"RESIZE_STEP",{enumerable:!0,get:function(){return n.RESIZE_STEP}}),Object.defineProperty(e,"RESIZE_STEP_LARGE",{enumerable:!0,get:function(){return n.RESIZE_STEP_LARGE}}),Object.defineProperty(e,"ROW_HEIGHTS",{enumerable:!0,get:function(){return n.ROW_HEIGHTS}}),Object.defineProperty(e,"ROW_MOVE_LIMIT",{enumerable:!0,get:function(){return n.ROW_MOVE_LIMIT}}),Object.defineProperty(e,"ROW_MOVE_MS",{enumerable:!0,get:function(){return n.ROW_MOVE_MS}}),Object.defineProperty(e,"ROW_SAVE_ATTR",{enumerable:!0,get:function(){return n.ROW_SAVE_ATTR}}),Object.defineProperty(e,"ROW_SAVE_ERROR_CLASS",{enumerable:!0,get:function(){return n.ROW_SAVE_ERROR_CLASS}}),Object.defineProperty(e,"ROW_SAVE_STATES",{enumerable:!0,get:function(){return n.ROW_SAVE_STATES}}),Object.defineProperty(e,"VIRTUAL_OVERSCAN",{enumerable:!0,get:function(){return n.VIRTUAL_OVERSCAN}}),e.WuiDataTable=S,Object.defineProperty(e,"clampColumnWidth",{enumerable:!0,get:function(){return n.clampColumnWidth}}),Object.defineProperty(e,"groupCount",{enumerable:!0,get:function(){return n.groupCount}}),Object.defineProperty(e,"groupItems",{enumerable:!0,get:function(){return n.groupItems}}),Object.defineProperty(e,"identityCell",{enumerable:!0,get:function(){return n.identityCell}}),Object.defineProperty(e,"measureRows",{enumerable:!0,get:function(){return n.measureRows}}),Object.defineProperty(e,"pinAtValue",{enumerable:!0,get:function(){return n.pinAtValue}}),Object.defineProperty(e,"pinClasses",{enumerable:!0,get:function(){return n.pinClasses}}),Object.defineProperty(e,"pinOffsetVar",{enumerable:!0,get:function(){return n.pinOffsetVar}}),Object.defineProperty(e,"planPins",{enumerable:!0,get:function(){return n.planPins}}),Object.defineProperty(e,"playRowMoves",{enumerable:!0,get:function(){return n.playRowMoves}}),Object.defineProperty(e,"readColumnWidths",{enumerable:!0,get:function(){return n.readColumnWidths}}),Object.defineProperty(e,"rowLabel",{enumerable:!0,get:function(){return n.rowLabel}}),Object.defineProperty(e,"rowOrderChanged",{enumerable:!0,get:function(){return n.rowOrderChanged}}),Object.defineProperty(e,"saveOutcomeText",{enumerable:!0,get:function(){return n.saveOutcomeText}}),Object.defineProperty(e,"setRowSaveState",{enumerable:!0,get:function(){return n.setRowSaveState}}),Object.defineProperty(e,"settledRows",{enumerable:!0,get:function(){return n.settledRows}}),Object.defineProperty(e,"virtualRange",{enumerable:!0,get:function(){return n.virtualRange}}),Object.defineProperty(e,"writeColumnWidths",{enumerable:!0,get:function(){return n.writeColumnWidths}})})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dataTable,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.tableExport,WeborityUiElementsInternal.modules.tableSelect);
1
+ (function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.193.0`)throw Error(`[webority-ui] data-table expects ui-elements 0.193.0 but the page loaded `+l+`.`);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 d(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 f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=`.wui-col-resize`,h=`.wui-group-row, .wui-virtual-spacer`,g=`.wui-select-cell, .wui-expand-cell`;function _(){return(0,o.svgRoot)({class:`wui-icon`,"data-icon":`chevron-down`,"data-wui":`AppIcon`,width:16,height:16,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[[`path`,{stroke:`currentColor`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":`10`,"stroke-width":`1.5`,d:`M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95`}]])}function v(e){if(e==null)throw TypeError(`Missing DOM node`);return e}function y(e,t){if(e instanceof t)return e;throw TypeError(`Missing DOM node`)}var b=e=>{let t=(0,r.closestOf)(e,m);return t instanceof HTMLElement?t:null},x=e=>e.hasAttribute(`data-wui-skeleton`)||!!e.querySelector(`:scope > td > .skeleton`),S=class extends i.ElementBase{constructor(){super(),p(this,`_frame`,void 0),p(this,`_headDirty`,void 0),p(this,`_rowsDirty`,void 0),p(this,`_frozenSig`,void 0),p(this,`_natural`,void 0),p(this,`_widths`,void 0),p(this,`_collapsed`,void 0),p(this,`_groupOrder`,void 0),p(this,`_items`,void 0),p(this,`_range`,void 0),p(this,`_drag`,void 0),p(this,`_userSized`,void 0),p(this,`_swallowClick`,void 0),p(this,`_mo`,void 0),p(this,`_ro`,void 0),p(this,`_fonts`,void 0),p(this,`_onPointerDown`,void 0),p(this,`_onKeyDown`,void 0),p(this,`_onClick`,void 0),p(this,`_onDblClick`,void 0),p(this,`_onScroll`,void 0),p(this,`_onFonts`,void 0),p(this,`_top`,null),p(this,`_bottom`,null),p(this,`_rowHeight`,0),this._frame=0,this._headDirty=!0,this._rowsDirty=!0,this._frozenSig=null,this._natural=[],this._widths={},this._collapsed=new Set,this._groupOrder=[],this._items=[],this._range=null,this._drag=null,this._userSized=!1,this._swallowClick=!1,this._mo=null,this._ro=null,this._fonts=null,this._onPointerDown=e=>this._startDrag(e),this._onKeyDown=e=>this._key(e),this._onClick=e=>this._click(e),this._onDblClick=e=>{let t=b(e.target);t&&this.contains(t)&&this._reset(t.closest(`th`))},this._onScroll=()=>{this.hasAttribute(`virtual`)&&this._schedule()},this._onFonts=()=>{this._userSized||this._drag||this._frozenSig===null||!this.hasAttribute(`resizable`)||(this._frozenSig=null,this._schedule())}}connectedCallback(){this._widths=(0,n.readColumnWidths)(this.getAttribute(`view-key`)),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.addEventListener(`keydown`,this._onKeyDown,!0),this.addEventListener(`click`,this._onClick,!0),this.addEventListener(`dblclick`,this._onDblClick),this.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._fonts=this.ownerDocument.fonts??null,this._fonts?.addEventListener(`loadingdone`,this._onFonts),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(e=>this._mutated(e)),this._mo.observe(this,{childList:!0,subtree:!0})),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._schedule()),this._ro.observe(this)),this._headDirty=!0,this._rowsDirty=!0,this._paintSaves(),this._schedule()}_paintSaves(){this.querySelectorAll(`tbody > tr[data-wui-save-state]`).forEach(e=>{e instanceof HTMLTableRowElement&&(0,n.paintSaveStatus)(e,e.getAttribute(n.ROW_SAVE_ATTR))})}disconnectedCallback(){this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this.removeEventListener(`keydown`,this._onKeyDown,!0),this.removeEventListener(`click`,this._onClick,!0),this.removeEventListener(`dblclick`,this._onDblClick),this.removeEventListener(`scroll`,this._onScroll),this._fonts?.removeEventListener(`loadingdone`,this._onFonts),this._fonts=null,this._mo?.disconnect(),this._ro?.disconnect(),this._mo=null,this._ro=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this._drag=null}refresh(){this._headDirty=!0,this._rowsDirty=!0,this._run()}get _table(){let e=this.querySelector(`:scope > table`);return e instanceof HTMLTableElement?e:null}_headCells(e){let t=e.tHead?.rows[0];return t?[...t.cells]:[]}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._run()})}_mutated(e){for(let t of e){let e=t.target instanceof Element?t.target:t.target.parentElement;e&&((e.closest(`thead`)||e===this._table||e===this)&&(this._headDirty=!0),(e.closest(`tbody, tfoot`)||e===this._table||e===this)&&(this._rowsDirty=!0))}this._schedule()}_run(){let e=this._table;if(!e)return;let t=this._headDirty,n=this._rowsDirty;this._headDirty=!1,this._rowsDirty=!1,n&&this.hasAttribute(`group-by`)&&this._group(e),this._pins(e,t||n),this.hasAttribute(`resizable`)&&(t&&this._handles(e),this._layout(e)),this.hasAttribute(`virtual`)&&this._virtual(e,t||n),this._mo?.takeRecords()}_pins(e,t){let r=this._headCells(e),i=r.map(e=>{let t=e.dataset.pin;return t===`start`||t===`end`?t:e.matches(g)?`lead`:null});if(!i.some(e=>e===`start`||e===`end`))return;let a=(0,n.planPins)(i);a.forEach((e,t)=>{e&&this._ro?.observe(v(r[t]))});let o=e=>v(r[e]).getBoundingClientRect().width,s=0;a.forEach((t,r)=>{t?.side===`start`&&(this._setVar(e,(0,n.pinOffsetVar)(`start`,t.ordinal),s),s+=o(r))}),s=0;for(let t=a.length-1;t>=0;t--){let r=a[t];r?.side===`end`&&(this._setVar(e,(0,n.pinOffsetVar)(`end`,r.ordinal),s),s+=o(t))}if(t)for(let t of e.rows)t.matches(`${h}, .wui-row-expanded`)||t.cells.length!==r.length||a.forEach((e,r)=>{if(!e)return;let i=v(t.cells[r]);i.classList.contains(`wui-pin-${e.side}`)||i.classList.add(`wui-pin-${e.side}`),e.edge&&!i.classList.contains(`wui-pin-${e.side}-edge`)&&i.classList.add(`wui-pin-${e.side}-edge`);let a=(0,n.pinAtValue)(e.side,e.ordinal);i.style.getPropertyValue(n.PIN_AT_VAR)!==a&&i.style.setProperty(n.PIN_AT_VAR,a)})}_setVar(e,t,n){let r=`${Math.round(n*100)/100}px`;e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}_resizable(e){return e.map((t,n)=>n<e.length-1&&!t.matches(g))}_handles(e){let t=this._headCells(e),r=this._resizable(t);t.forEach((e,t)=>{if(!r[t]||e.querySelector(m))return;let i=e.ownerDocument.createElement(`span`);i.className=`wui-col-resize`,i.setAttribute(`role`,`separator`),i.setAttribute(`aria-orientation`,`vertical`),i.setAttribute(`aria-valuemin`,String(n.COLUMN_MIN_WIDTH)),i.setAttribute(`aria-valuemax`,String(n.COLUMN_MAX_WIDTH)),i.setAttribute(`tabindex`,`0`);let a=(e.textContent??``).trim();i.setAttribute(`aria-label`,(0,n.resizeName)(a)),a&&!e.hasAttribute(`aria-label`)&&e.setAttribute(`aria-label`,a),e.classList.add(`wui-col-resizable`),e.appendChild(i)})}_hasRows(e){for(let t of e.tBodies)for(let e of t.rows)if(!e.matches(h)&&!x(e))return!0;return!1}_signature(e){return e.map(e=>e.dataset.key||(e.textContent??``).trim()).join(``)}_layout(e){let t=this._headCells(e),n=this._signature(t);t.length&&n!==this._frozenSig&&(this._hasRows(e)?this._freeze(e,t,n):this._applyRemembered(t))}_applyRemembered(e){for(let t of e){let e=t.dataset.key&&this._widths[t.dataset.key];e&&(t.style.width=`${e}px`);let r=t.querySelector(m);r&&this._handleValue(r,(0,n.clampColumnWidth)(e||t.getBoundingClientRect().width))}}_freeze(e,t,n){e.style.tableLayout=``,e.style.width=``,e.removeAttribute(`data-wui-fixed`);for(let e of t)e.hasAttribute(`data-wui-width`)&&(e.style.width=``,e.removeAttribute(`data-wui-width`));this._natural=t.map(e=>e.getBoundingClientRect().width),t.forEach((e,n)=>{if(n===t.length-1||e.matches(g))return;let r=e.dataset.key&&this._widths[e.dataset.key];this._setWidth(e,r||this._natural[n])}),e.style.tableLayout=`fixed`,e.setAttribute(`data-wui-fixed`,``),this._frozenSig=n,this._fitTable(e,t)}_setWidth(e,t){let r=(0,n.clampColumnWidth)(t);e.style.width=`${r}px`,e.setAttribute(`data-wui-width`,``);let i=e.querySelector(m);return i&&this._handleValue(i,r),r}_handleValue(e,t){e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,(0,n.widthText)(t))}_fitTable(e,t){let n=t.length-1,r=this._natural[n]||0;for(let e=0;e<n;e++)r+=Number.parseFloat(v(t[e]).style.width)||this._natural[e]||0;e.style.width=`max(100%, ${Math.round(r)}px)`}_ensureFrozen(e){let t=this._headCells(e),n=this._signature(t);return n!==this._frozenSig&&this._freeze(e,t,n),t}_resizeTo(e,t,n){let r=this._table;if(!r)return;let i=this._ensureFrozen(r);this._userSized=!0,this._setWidth(e,t),this._fitTable(r,i),n&&this._remember(e),this._pins(r,!1)}_remember(e){let t=e.dataset.key;t&&(this._widths={...this._widths,[t]:Number.parseFloat(e.style.width)},(0,n.writeColumnWidths)(this.getAttribute(`view-key`),this._widths))}_reset(e){let t=this._table;if(!e||!t)return;let r=this._ensureFrozen(t);this._userSized=!0;let i=e.dataset.key;if(i&&i in this._widths){let{[i]:e,...t}=this._widths;this._widths=t,(0,n.writeColumnWidths)(this.getAttribute(`view-key`),this._widths)}this._setWidth(e,this._natural[r.indexOf(e)]||0),this._fitTable(t,r),this._pins(t,!1)}_rtl(){return getComputedStyle(this).direction===`rtl`}_startDrag(e){let t=b(e.target);if(!t||!this.contains(t)||e.button!==0)return;e.preventDefault(),e.stopPropagation();let n=t.closest(`th`),r=this._table;if(!n||!r)return;this._ensureFrozen(r);let i={th:n,x:e.clientX,from:n.getBoundingClientRect().width,dir:this._rtl()?-1:1,moved:!1};this._drag=i,t.setPointerCapture?.(e.pointerId),t.classList.add(`is-dragging`);let a=e=>{let t=(e.clientX-i.x)*i.dir;Math.abs(t)>1&&(i.moved=!0),this._resizeTo(n,i.from+t,!1)},o=e=>{t.removeEventListener(`pointermove`,a),t.removeEventListener(`pointerup`,o),t.removeEventListener(`pointercancel`,o),t.classList.remove(`is-dragging`),this._drag=null,e.type===`pointercancel`?this._resizeTo(n,i.from,!1):i.moved&&this._remember(n),this._swallowClick=!0,setTimeout(()=>{this._swallowClick=!1},0)};t.addEventListener(`pointermove`,a),t.addEventListener(`pointerup`,o),t.addEventListener(`pointercancel`,o)}_key(e){let t=b(e.target);if(!t||!this.contains(t))return;let r=t.closest(`th`);if((0,a.isImeSafeEnter)(e)||e.key===` `){e.preventDefault(),e.stopPropagation();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),this._reset(r);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault(),e.stopPropagation();let i=this._table;if(!i)return;this._ensureFrozen(i);let o=v(r),s=e.shiftKey?n.RESIZE_STEP_LARGE:n.RESIZE_STEP,c=e.key===`ArrowRight`!==this._rtl(),l=Number.parseFloat(o.style.width)||o.getBoundingClientRect().width;this._resizeTo(o,l+(c?s:-s),!0)}_click(e){let t=e.target instanceof Element&&e.target.closest(m)!==null;if(this._swallowClick||t){e.stopPropagation(),(t||this._swallowClick)&&e.preventDefault(),this._swallowClick=!1;return}let n=(0,r.closestOf)(e.target,`[data-wui-table-export], [data-wui-density]`);if(n&&this.contains(n)){e.preventDefault(),n.hasAttribute(`data-wui-density`)?this._setDensity(n.getAttribute(`data-wui-density`)??``):this._export(n.getAttribute(`data-wui-table-export`)??``);return}if(!this.hasAttribute(`group-by`))return;let i=(0,r.closestOf)(e.target,`.wui-group-toggle`)?.closest(`.wui-group-row`);if(!(i instanceof HTMLTableRowElement)||!this.contains(i))return;let a=i.dataset.groupKey;this._collapsed.has(a)?this._collapsed.delete(a):this._collapsed.add(a),this._showGroup(i,!this._collapsed.has(a));let o=this._table;o&&this.hasAttribute(`virtual`)&&(this._virtual(o,!0),this._mo?.takeRecords())}async _export(e){if(e!==`csv`&&e!==`xlsx`)return;let t=this.querySelector(`:scope > table`);if(!(t instanceof HTMLTableElement))return;let n=Array.from(t.tBodies[0]?.rows??[]).filter(e=>!e.hidden&&!e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`)&&!x(e)),r=new Set;for(let e of n)for(let[t,n]of Array.from(e.cells).entries())(n.matches(g)||n.querySelector(`.u-row-actions`))&&r.add(t);let i=e=>Array.from(e).filter((e,t)=>!r.has(t)).map(e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;for(let e of t.querySelectorAll(`.visually-hidden, .wui-col-resize, .infotip`))e.remove();return(t.textContent??``).replace(/\s+/g,` `).trim()}),a=i(t.tHead?.rows[0]?.cells??[]),o=n.map(e=>i(e.cells)),c=this.getAttribute(`export-name`)??`table`,{downloadTable:l,tableCsv:u,tableXlsx:d}=await(0,s.loadTableExport)();e===`csv`?l([u(a,o)],`text/csv;charset=utf-8`,`${c}.csv`):l([d(a,o)],`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`${c}.xlsx`)}_setDensity(e){let t=this.querySelector(`:scope > table`);if(t instanceof HTMLTableElement){t.classList.remove(`wui-table-cozy`,`wui-table-compact`),(e===`cozy`||e===`compact`)&&t.classList.add(`wui-table-${e}`);for(let t of this.querySelectorAll(`[data-wui-density]`))t.setAttribute(`aria-pressed`,String(t.getAttribute(`data-wui-density`)===e))}}_group(e){let t=this.getAttribute(`group-by`),r=this._headCells(e),i=r.findIndex(e=>e.dataset.key===t);if(i<0)throw Error(`<wui-data-table group-by="${t}"> needs a header cell with data-key="${t}".`);let a=e.tBodies[0];if(!a)return;let o=[...a.rows].filter(e=>!e.matches(h));if(o.some(x))return;let s=this.ownerDocument,l=new Map;for(let e of a.querySelectorAll(`:scope > tr.wui-group-row`))e instanceof HTMLTableRowElement&&l.set(e.dataset.groupKey,e);let u=this.closest(`[data-wui-server]`)?[]:this._groupOrder,d=(0,n.groupItems)(o,e=>e.dataset.group??e.cells[i]?.textContent?.trim()??``,u);this._groupOrder=d.map(e=>e.key);let f=s.createDocumentFragment(),p=e.hasAttribute(`data-app-datatable-selectable`),m=d.map(e=>{let t=l.get(e.key)??this._groupRow(s,e.key);l.delete(e.key);let i=y(t.querySelector(`.wui-group-cell`),HTMLTableCellElement);return p&&!t.querySelector(`.${c.GROUP_SELECT_CLASS}`)&&t.insertBefore((0,c.createGroupSelectCell)(s,e.key),i),i.colSpan=p?r.length-1:r.length,y(t.querySelector(`.wui-group-count`),HTMLElement).textContent=(0,n.groupCount)(e.items.length),y(t.querySelector(`.wui-group-rows`),HTMLElement).textContent=`, ${(0,n.groupRowsText)(e.items.length)}`,f.append(t,...e.items),[t,e.key]});for(let e of l.values())e.remove();a.insertBefore(f,this._bottom?.parentNode===a?this._bottom:null);for(let[e,t]of m)this._showGroup(e,!this._collapsed.has(t));p&&(0,c.syncGroupSelect)(e)}_groupRow(e,t){let n=e.createElement(`tr`);n.className=`wui-group-row`,n.dataset.groupKey=t;let r=e.createElement(`th`);r.className=`wui-group-cell`,r.scope=`rowgroup`;let i=e.createElement(`button`);i.type=`button`,i.className=`wui-group-toggle`,i.replaceChildren(_());let a=e.createElement(`span`);a.className=`wui-group-label`,a.textContent=t;let o=e.createElement(`span`);o.className=`wui-group-count`,o.setAttribute(`aria-hidden`,`true`);let s=e.createElement(`span`);return s.className=`visually-hidden wui-group-rows`,i.append(a,o,s),r.append(i),n.append(r),n}_showGroup(e,t){if(e){e.querySelector(`.wui-group-toggle`)?.setAttribute(`aria-expanded`,String(t));for(let n=e.nextElementSibling;n&&!n.matches(h);n=n.nextElementSibling)n instanceof HTMLElement&&(n.hidden=!t)}}_spacer(e,t){if(t?.parentNode===e)return t;let n=e.ownerDocument,r=n.createElement(`tr`);return r.className=`wui-virtual-spacer`,r.setAttribute(`aria-hidden`,`true`),r.append(n.createElement(`td`)),r}_virtual(e,t){let r=e.tBodies[0];if(!r)return;if(t){this._top=this._spacer(r,this._top),this._bottom=this._spacer(r,this._bottom),r.firstElementChild!==this._top&&r.insertBefore(this._top,r.firstChild),r.lastElementChild!==this._bottom&&r.append(this._bottom);let t=Math.max(1,this._headCells(e).length);v(this._top.cells[0]).colSpan=t,v(this._bottom.cells[0]).colSpan=t,this._items=[...r.rows].filter(e=>!e.classList.contains(`wui-virtual-spacer`)&&!e.hidden),this._range=null,e.setAttribute(`aria-rowcount`,String(this._items.length+1)),e.tHead?.rows[0]?.setAttribute(`aria-rowindex`,`1`),this._items.forEach((e,t)=>{e.setAttribute(`aria-rowindex`,String(t+2))}),this._rowHeight>0||(this._rowHeight=this._measureRow(e))}let i=e.tHead?.getBoundingClientRect().height||0,a=(0,n.virtualRange)({scrollTop:this.scrollTop-i,viewport:this.clientHeight,rowHeight:this._rowHeight,count:this._items.length}),o=this._range;if(o&&o.start===a.start&&o.end===a.end)return;let s=o?Math.min(o.start,a.start):0,c=o?Math.max(o.end,a.end):this._items.length;for(let e=s;e<c;e++){let t=e<a.start||e>=a.end,n=v(this._items[e]);n.classList.contains(`wui-virtual-off`)!==t&&n.classList.toggle(`wui-virtual-off`,t)}this._range=a;let l=v(this._top),u=v(this._bottom);l.hidden=a.before===0,u.hidden=a.after===0,v(l.cells[0]).style.height=`${a.before}px`,v(u.cells[0]).style.height=`${a.after}px`}_measureRow(e){let t=this._items.find(e=>!e.classList.contains(`wui-group-row`)&&!e.classList.contains(`wui-virtual-off`))?.getBoundingClientRect().height??0;return t>0?t:e.classList.contains(`wui-table-compact`)?n.ROW_HEIGHTS.compact:e.classList.contains(`wui-table-cozy`)?n.ROW_HEIGHTS.cozy:n.ROW_HEIGHTS.comfortable}};(0,t.defineElement)(`wui-data-table`,S),Object.defineProperty(e,"COLUMN_MAX_WIDTH",{enumerable:!0,get:function(){return n.COLUMN_MAX_WIDTH}}),Object.defineProperty(e,"COLUMN_MIN_WIDTH",{enumerable:!0,get:function(){return n.COLUMN_MIN_WIDTH}}),Object.defineProperty(e,"PIN_AT_VAR",{enumerable:!0,get:function(){return n.PIN_AT_VAR}}),Object.defineProperty(e,"PIN_SIDES",{enumerable:!0,get:function(){return n.PIN_SIDES}}),Object.defineProperty(e,"RESIZE_STEP",{enumerable:!0,get:function(){return n.RESIZE_STEP}}),Object.defineProperty(e,"RESIZE_STEP_LARGE",{enumerable:!0,get:function(){return n.RESIZE_STEP_LARGE}}),Object.defineProperty(e,"ROW_HEIGHTS",{enumerable:!0,get:function(){return n.ROW_HEIGHTS}}),Object.defineProperty(e,"ROW_MOVE_LIMIT",{enumerable:!0,get:function(){return n.ROW_MOVE_LIMIT}}),Object.defineProperty(e,"ROW_MOVE_MS",{enumerable:!0,get:function(){return n.ROW_MOVE_MS}}),Object.defineProperty(e,"ROW_SAVE_ATTR",{enumerable:!0,get:function(){return n.ROW_SAVE_ATTR}}),Object.defineProperty(e,"ROW_SAVE_ERROR_CLASS",{enumerable:!0,get:function(){return n.ROW_SAVE_ERROR_CLASS}}),Object.defineProperty(e,"ROW_SAVE_STATES",{enumerable:!0,get:function(){return n.ROW_SAVE_STATES}}),Object.defineProperty(e,"VIRTUAL_OVERSCAN",{enumerable:!0,get:function(){return n.VIRTUAL_OVERSCAN}}),e.WuiDataTable=S,Object.defineProperty(e,"clampColumnWidth",{enumerable:!0,get:function(){return n.clampColumnWidth}}),Object.defineProperty(e,"groupCount",{enumerable:!0,get:function(){return n.groupCount}}),Object.defineProperty(e,"groupItems",{enumerable:!0,get:function(){return n.groupItems}}),Object.defineProperty(e,"identityCell",{enumerable:!0,get:function(){return n.identityCell}}),Object.defineProperty(e,"measureRows",{enumerable:!0,get:function(){return n.measureRows}}),Object.defineProperty(e,"pinAtValue",{enumerable:!0,get:function(){return n.pinAtValue}}),Object.defineProperty(e,"pinClasses",{enumerable:!0,get:function(){return n.pinClasses}}),Object.defineProperty(e,"pinOffsetVar",{enumerable:!0,get:function(){return n.pinOffsetVar}}),Object.defineProperty(e,"planPins",{enumerable:!0,get:function(){return n.planPins}}),Object.defineProperty(e,"playRowMoves",{enumerable:!0,get:function(){return n.playRowMoves}}),Object.defineProperty(e,"readColumnWidths",{enumerable:!0,get:function(){return n.readColumnWidths}}),Object.defineProperty(e,"rowLabel",{enumerable:!0,get:function(){return n.rowLabel}}),Object.defineProperty(e,"rowOrderChanged",{enumerable:!0,get:function(){return n.rowOrderChanged}}),Object.defineProperty(e,"saveOutcomeText",{enumerable:!0,get:function(){return n.saveOutcomeText}}),Object.defineProperty(e,"setRowSaveState",{enumerable:!0,get:function(){return n.setRowSaveState}}),Object.defineProperty(e,"settledRows",{enumerable:!0,get:function(){return n.settledRows}}),Object.defineProperty(e,"virtualRange",{enumerable:!0,get:function(){return n.virtualRange}}),Object.defineProperty(e,"writeColumnWidths",{enumerable:!0,get:function(){return n.writeColumnWidths}})})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dataTable,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.svgNodes,WeborityUiElementsInternal.modules.tableExport,WeborityUiElementsInternal.modules.tableSelect);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=globalThis.WeborityUiElementsInternal?.version;if(f!==`0.191.3`)throw Error(`[webority-ui] date-range expects ui-elements 0.191.3 but the page loaded `+f+`.`);var p={clearLabel:`Clear`,endLabel:`End`,helpLabel:`More information`,last30DaysLabel:`Last 30 days`,last7DaysLabel:`Last 7 days`,lastMonthLabel:`Last month`,nextMonthLabel:`Next month`,optionalLabel:`(optional)`,pickEndDateLabel:`Pick an end date`,pickStartDateLabel:`Pick a start date`,placeholder:`Start to End`,previousMonthLabel:`Previous month`,quickRangesLabel:`Quick ranges`,rangeText:`{start} to {end}`,startLabel:`Start`,thisFinancialYearLabel:`This financial year`,thisMonthLabel:`This month`,todayLabel:`Today`,yesterdayLabel:`Yesterday`},m=4,h=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],g={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},_=e=>String(e).padStart(2,`0`),v=e=>`${e.getUTCFullYear()}-${_(e.getUTCMonth()+1)}-${_(e.getUTCDate())}`;function y(e){return h.includes(e)}function b(e,t=new Date,{timeZone:r=a.IST_TIME_ZONE,financialYearStart:o=m}={}){if(!y(e))return null;let s=(0,n.parseIso)((0,a.todayIn)(r,t));if(!s)throw Error(`today missing`);let{y:c,m:l,d:u}=s,d=(e,t,n)=>v(new Date(Date.UTC(e,t,n))),f=(0,i.readText)(`dateRangePicker`,p)[g[e]];switch(e){case`today`:return{label:f,start:d(c,l,u),end:d(c,l,u)};case`yesterday`:return{label:f,start:d(c,l,u-1),end:d(c,l,u-1)};case`last7Days`:return{label:f,start:d(c,l,u-6),end:d(c,l,u)};case`last30Days`:return{label:f,start:d(c,l,u-29),end:d(c,l,u)};case`thisMonth`:return{label:f,start:d(c,l,1),end:d(c,l+1,0)};case`lastMonth`:return{label:f,start:d(c,l-1,1),end:d(c,l,0)};case`thisFinancialYear`:{let e=o-1,t=l>=e?c:c-1;return{label:f,start:d(t,e,1),end:d(t+1,e,0)}}default:return null}}function x(e){(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function S(e){return typeof e==`object`&&!!e}function C(e,t=new Date,r={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return x(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let n=b(e,t,r);n?o.push(n):x(`"${e}" is not one of ${h.join(`, `)}`)}else S(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&(0,n.parseIso)(e.start)&&(0,n.parseIso)(e.end)?o.push({label:e.label,start:e.start,end:e.end}):x(`an item needs a label and ISO start and end dates, or a preset name`);return o}function w(e){"@babel/helpers - typeof";return w=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},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function E(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function D(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=()=>(0,i.readText)(`dateRangePicker`,p);function k(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function A(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var j=class extends s.ElementBase{get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!(0,c.isInert)(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super(),D(this,`_internals`,void 0),D(this,`_start`,void 0),D(this,`_end`,void 0),D(this,`_hover`,void 0),D(this,`_viewY`,void 0),D(this,`_viewM`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return(0,n.firstWeekday)(this)}_label(){let e=this.getAttribute(`placeholder`)||O().placeholder;return!this._start&&!this._end?{text:e,empty:!0}:{text:(0,i.fillText)(O().rangeText,{start:(0,n.fmt)(this._start)||O().startLabel,end:(0,n.fmt)(this._end)||O().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=(0,n.parseIso)(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),r=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),s=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),d=(0,o.make)(`button`,{type:`button`,class:`form-control daterange-trigger${r}${a?``:` has-value`}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":s||null,"aria-describedby":l||null},(0,o.make)(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),(0,u.glyphNode)(`calendar`));this.replaceChildren((0,o.make)(`div`,{class:`daterange`},d,(0,o.make)(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),(0,c.syncFieldState)(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){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;return(e,t,n)=>{let a=new Date(e,t,n).getTime();return a<r||a>i}}_monthHtml(e,t){let r=this._firstDay(),i=(new Date(e,t,1).getDay()-r+7)%7,a=(0,n.daysIn)(e,t),s=this._limits(),c=Array.from({length:7},(e,t)=>(0,o.make)(`span`,null,(0,l.weekdayLabel)((t+r)%7,`min`))),u=(e,t,r,i)=>{let a=(0,n.toIso)(e,t,r),c=s(e,t,r),l=[`datepicker-day`,i?`is-outside`:``].filter(Boolean).join(` `);return(0,o.make)(`button`,{type:`button`,class:l,"data-iso":a,disabled:c},r)},d=[],f=(0,n.clampMonth)(e,t-1),p=(0,n.daysIn)(f.y,f.m);for(let e=i-1;e>=0;e--)d.push(u(f.y,f.m,p-e,!0));for(let n=1;n<=a;n++)d.push(u(e,t,n,!1));let m=(0,n.clampMonth)(e,t+1),h=(7-(i+a)%7)%7;for(let e=1;e<=h;e++)d.push(u(m.y,m.m,e,!0));return(0,o.make)(`div`,{class:`daterange-cal`},(0,o.make)(`div`,{class:`datepicker-month-label`},`${(0,l.monthLongLabel)(t)} ${e}`),(0,o.make)(`div`,{class:`datepicker-weekdays`},...c),(0,o.make)(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=a.IST_TIME_ZONE;e!==null&&((0,a.isTimeZone)(e)?t=e:(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),i=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?i=e:(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:i}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let r=(0,n.parseIso)(t);if(!r)throw Error(`Expected a preset date, found "${t}".`);return e(r.y,r.m,r.d)},r=this._presetList.map((e,n)=>(0,o.make)(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return(0,o.make)(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":O().quickRangesLabel},...r)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=(0,n.clampMonth)(this._viewY,this._viewM+1),r=this._presetsHtml(),i=[(0,o.make)(`div`,{class:`daterange-head`},(0,o.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":O().previousMonthLabel},(0,u.glyphNode)(`chevron-left`)),(0,o.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":O().nextMonthLabel},(0,u.glyphNode)(`chevron-right`))),(0,o.make)(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),(0,o.make)(`div`,{class:`datepicker-foot`},(0,o.make)(`span`,{class:`daterange-hint`,"data-range-hint":!0}),(0,o.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},O().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,r!==null),e.replaceChildren(...r?[r,(0,o.make)(`div`,{class:`wui-daterange-main`},...i)]:i),this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,r=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(r=this._hover);let a=r?new Date(r).getTime():null;for(let n of A(e,`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso??``).getTime(),r=t!=null&&e===t,i=a!=null&&e===a,o=t!=null&&a!=null&&e>t&&e<a;n.classList.toggle(`is-range-start`,r),n.classList.toggle(`is-range-end`,i),n.classList.toggle(`in-range`,o)}A(e,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let o=e.querySelector(`[data-range-hint]`);o&&(o.textContent=this._start?this._end?(0,i.fillText)(O().rangeText,{start:(0,n.fmt)(this._start),end:(0,n.fmt)(this._end)}):O().pickEndDateLabel:O().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&(0,d.closeAnchoredPopover)(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),r=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,d.isPopoverOpen)(t),a=()=>{this._hover=``,r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let o=(0,n.parseIso)(this._start);if(o)this._viewY=o.y,this._viewM=o.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=C(this.getAttribute(`presets`),new Date,this._presetOptions()),this._renderView(),(0,d.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:a}),i()&&(r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{(0,d.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>{i()?this._close():(0,c.isInert)(this)||this._open()}),t.addEventListener(`click`,e=>{let t=k(e),r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let i=t.closest(`[data-preset]`);if(i instanceof HTMLButtonElement&&!i.disabled){let e=this._presetList?.[Number(i.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=k(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};D(j,`formAssociated`,!0),(0,t.defineElement)(`wui-date-range`,j),e.WuiDateRange=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.zone,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=globalThis.WeborityUiElementsInternal?.version;if(f!==`0.193.0`)throw Error(`[webority-ui] date-range expects ui-elements 0.193.0 but the page loaded `+f+`.`);var p={clearLabel:`Clear`,endLabel:`End`,helpLabel:`More information`,last30DaysLabel:`Last 30 days`,last7DaysLabel:`Last 7 days`,lastMonthLabel:`Last month`,nextMonthLabel:`Next month`,optionalLabel:`(optional)`,pickEndDateLabel:`Pick an end date`,pickStartDateLabel:`Pick a start date`,placeholder:`Start to End`,previousMonthLabel:`Previous month`,quickRangesLabel:`Quick ranges`,rangeText:`{start} to {end}`,startLabel:`Start`,thisFinancialYearLabel:`This financial year`,thisMonthLabel:`This month`,todayLabel:`Today`,yesterdayLabel:`Yesterday`},m=4,h=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],g={today:`todayLabel`,yesterday:`yesterdayLabel`,last7Days:`last7DaysLabel`,last30Days:`last30DaysLabel`,thisMonth:`thisMonthLabel`,lastMonth:`lastMonthLabel`,thisFinancialYear:`thisFinancialYearLabel`},_=e=>String(e).padStart(2,`0`),v=e=>`${e.getUTCFullYear()}-${_(e.getUTCMonth()+1)}-${_(e.getUTCDate())}`;function y(e){return h.includes(e)}function b(e,t=new Date,{timeZone:r=a.IST_TIME_ZONE,financialYearStart:o=m}={}){if(!y(e))return null;let s=(0,n.parseIso)((0,a.todayIn)(r,t));if(!s)throw Error(`today missing`);let{y:c,m:l,d:u}=s,d=(e,t,n)=>v(new Date(Date.UTC(e,t,n))),f=(0,i.readText)(`dateRangePicker`,p)[g[e]];switch(e){case`today`:return{label:f,start:d(c,l,u),end:d(c,l,u)};case`yesterday`:return{label:f,start:d(c,l,u-1),end:d(c,l,u-1)};case`last7Days`:return{label:f,start:d(c,l,u-6),end:d(c,l,u)};case`last30Days`:return{label:f,start:d(c,l,u-29),end:d(c,l,u)};case`thisMonth`:return{label:f,start:d(c,l,1),end:d(c,l+1,0)};case`lastMonth`:return{label:f,start:d(c,l-1,1),end:d(c,l,0)};case`thisFinancialYear`:{let e=o-1,t=l>=e?c:c-1;return{label:f,start:d(t,e,1),end:d(t+1,e,0)}}default:return null}}function x(e){(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function S(e){return typeof e==`object`&&!!e}function C(e,t=new Date,r={}){let i=String(e??``).trim();if(!i)return[];let a;if(i.startsWith(`[`))try{a=JSON.parse(i)}catch{return x(`the attribute is not valid JSON`),[]}else a=i.split(`,`).map(e=>e.trim());let o=[];for(let e of a)if(typeof e==`string`){let n=b(e,t,r);n?o.push(n):x(`"${e}" is not one of ${h.join(`, `)}`)}else S(e)&&typeof e.label==`string`&&e.label&&typeof e.start==`string`&&typeof e.end==`string`&&(0,n.parseIso)(e.start)&&(0,n.parseIso)(e.end)?o.push({label:e.label,start:e.start,end:e.end}):x(`an item needs a label and ISO start and end dates, or a preset name`);return o}function w(e){"@babel/helpers - typeof";return w=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},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function E(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function D(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=()=>(0,i.readText)(`dateRangePicker`,p);function k(e){if(!(e.target instanceof Element))throw Error(`Expected the event target to be an element.`);return e.target}function A(e,t){return[...e.querySelectorAll(t)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`Expected every "${t}" to be an HTML element.`);return e})}var j=class extends s.ElementBase{get open(){return this.querySelector(`.daterange`)?.classList.contains(`open`)??!1}set open(e){e?!(0,c.isInert)(this)&&!this.open&&this._open?.():this.open&&this._close?.()}static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`readonly`,`loading`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`time-zone`,`financial-year-start`,`aria-invalid`]}constructor(){super(),D(this,`_internals`,void 0),D(this,`_start`,void 0),D(this,`_end`,void 0),D(this,`_hover`,void 0),D(this,`_viewY`,void 0),D(this,`_viewM`,void 0);try{this._internals=this.attachInternals()}catch{this._internals=null}this._start=``,this._end=``,this._hover=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth()}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){this._dropPanel()}attributeChangedCallback(e,t,n){e===`aria-invalid`?this._syncInvalid():this._rendered&&(e===`start`||e===`end`?(this._start=this.getAttribute(`start`)||``,this._end=this.getAttribute(`end`)||``,this._syncTrigger(),this._syncMirrors()):this.render())}_syncInvalid(){let e=this.querySelector(`.daterange-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return{start:this._start,end:this._end}}set value(e){this._start=e?.start||``,this._end=e?.end||``,this._syncTrigger(),this._syncMirrors()}_firstDay(){return(0,n.firstWeekday)(this)}_label(){let e=this.getAttribute(`placeholder`)||O().placeholder;return!this._start&&!this._end?{text:e,empty:!0}:{text:(0,i.fillText)(O().rangeText,{start:(0,n.fmt)(this._start)||O().startLabel,end:(0,n.fmt)(this._end)||O().endLabel}),empty:!1}}render(){this._dropPanel(),this._defaultStart===void 0&&(this._defaultStart=this.getAttribute(`start`)||``,this._defaultEnd=this.getAttribute(`end`)||``,this._start=this._defaultStart||this._start,this._end=this._defaultEnd||this._end);let e=(0,n.parseIso)(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),r=t===`sm`?` wui-input-sm`:t===`lg`?` wui-input-lg`:t===`xl`?` wui-input-xl`:``,{text:i,empty:a}=this._label(),s=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),d=(0,o.make)(`button`,{type:`button`,class:`form-control daterange-trigger${r}${a?``:` has-value`}${this.classList.contains(`wui-input-underline`)?` wui-input-underline`:``}`,"aria-haspopup":`dialog`,"aria-expanded":`false`,"aria-invalid":this.hasAttribute(`aria-invalid`)?`true`:null,disabled:this.hasAttribute(`disabled`),"aria-label":s||null,"aria-describedby":l||null},(0,o.make)(`span`,{"data-range-label":!0,class:a?`wui-select-placeholder`:``},i),(0,u.glyphNode)(`calendar`));this.replaceChildren((0,o.make)(`div`,{class:`daterange`},d,(0,o.make)(`div`,{class:`daterange-pop`,role:`dialog`,popover:`auto`}))),(0,c.syncFieldState)(this,this.querySelector(`.daterange-trigger`)),this._rendered=!0,this._syncMirrors(),this._wire()}formResetCallback(){this.value={start:this._defaultStart||``,end:this._defaultEnd||``}}_syncTrigger(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`[data-range-label]`);if(!t)return;let{text:n,empty:r}=this._label();t.textContent=n,t.classList.toggle(`wui-select-placeholder`,r),e?.classList.toggle(`has-value`,!r),e?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirror(`start`,e,this._start),this._mirror(`end`,t,this._end)}_mirror(e,t,n){if(!t)return;let r=this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`),i;r instanceof HTMLInputElement?i=r:(i=document.createElement(`input`),i.type=`hidden`,i.setAttribute(`data-range-mirror`,e),this.appendChild(i)),i.name=t,i.value=n||``,i.disabled=this.hasAttribute(`disabled`)}_limits(){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;return(e,t,n)=>{let a=new Date(e,t,n).getTime();return a<r||a>i}}_monthHtml(e,t){let r=this._firstDay(),i=(new Date(e,t,1).getDay()-r+7)%7,a=(0,n.daysIn)(e,t),s=this._limits(),c=Array.from({length:7},(e,t)=>(0,o.make)(`span`,null,(0,l.weekdayLabel)((t+r)%7,`min`))),u=(e,t,r,i)=>{let a=(0,n.toIso)(e,t,r),c=s(e,t,r),l=[`datepicker-day`,i?`is-outside`:``].filter(Boolean).join(` `);return(0,o.make)(`button`,{type:`button`,class:l,"data-iso":a,disabled:c},r)},d=[],f=(0,n.clampMonth)(e,t-1),p=(0,n.daysIn)(f.y,f.m);for(let e=i-1;e>=0;e--)d.push(u(f.y,f.m,p-e,!0));for(let n=1;n<=a;n++)d.push(u(e,t,n,!1));let m=(0,n.clampMonth)(e,t+1),h=(7-(i+a)%7)%7;for(let e=1;e<=h;e++)d.push(u(m.y,m.m,e,!0));return(0,o.make)(`div`,{class:`daterange-cal`},(0,o.make)(`div`,{class:`datepicker-month-label`},`${(0,l.monthLongLabel)(t)} ${e}`),(0,o.make)(`div`,{class:`datepicker-weekdays`},...c),(0,o.make)(`div`,{class:`datepicker-grid`,role:`grid`},...d))}_presetOptions(){let e=this.getAttribute(`time-zone`),t=a.IST_TIME_ZONE;e!==null&&((0,a.isTimeZone)(e)?t=e:(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> time-zone="${e}" is not a time zone this browser knows; India Standard Time is used.`));let n=this.getAttribute(`financial-year-start`),i=4;if(n!==null){let e=Number(n);Number.isInteger(e)&&e>=1&&e<=12?i=e:(0,r.devWarn)(`[@webority/ui-elements] <wui-date-range> financial-year-start="${n}" must be a month number from 1 to 12; April (4) is used.`)}return{timeZone:t,financialYearStart:i}}_presetsHtml(){if(!this._presetList?.length)return null;let e=this._limits(),t=t=>{let r=(0,n.parseIso)(t);if(!r)throw Error(`Expected a preset date, found "${t}".`);return e(r.y,r.m,r.d)},r=this._presetList.map((e,n)=>(0,o.make)(`button`,{type:`button`,class:`wui-daterange-preset`,"data-preset":n,disabled:t(e.start)||t(e.end)},e.label));return(0,o.make)(`div`,{class:`wui-daterange-presets`,role:`group`,"aria-label":O().quickRangesLabel},...r)}_renderView(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=(0,n.clampMonth)(this._viewY,this._viewM+1),r=this._presetsHtml(),i=[(0,o.make)(`div`,{class:`daterange-head`},(0,o.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":-1,"aria-label":O().previousMonthLabel},(0,u.glyphNode)(`chevron-left`)),(0,o.make)(`button`,{type:`button`,class:`datepicker-nav-btn`,"data-nav":1,"aria-label":O().nextMonthLabel},(0,u.glyphNode)(`chevron-right`))),(0,o.make)(`div`,{class:`daterange-cals`},this._monthHtml(this._viewY,this._viewM),this._monthHtml(t.y,t.m)),(0,o.make)(`div`,{class:`datepicker-foot`},(0,o.make)(`span`,{class:`daterange-hint`,"data-range-hint":!0}),(0,o.make)(`button`,{type:`button`,class:`datepicker-link`,"data-clear":!0},O().clearLabel))];e.classList.toggle(`wui-daterange-pop--presets`,r!==null),e.replaceChildren(...r?[r,(0,o.make)(`div`,{class:`wui-daterange-main`},...i)]:i),this._paint()}_paint(){let e=this.querySelector(`.daterange-pop`);if(!e)return;let t=this._start?new Date(this._start).getTime():null,r=this._end;t&&!this._end&&this._hover&&new Date(this._hover).getTime()>=t&&(r=this._hover);let a=r?new Date(r).getTime():null;for(let n of A(e,`.datepicker-day[data-iso]`)){let e=new Date(n.dataset.iso??``).getTime(),r=t!=null&&e===t,i=a!=null&&e===a,o=t!=null&&a!=null&&e>t&&e<a;n.classList.toggle(`is-range-start`,r),n.classList.toggle(`is-range-end`,i),n.classList.toggle(`in-range`,o)}A(e,`[data-preset]`).forEach(e=>{let t=this._presetList?.[Number(e.dataset.preset)],n=!!t&&t.start===this._start&&t.end===this._end;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))});let o=e.querySelector(`[data-range-hint]`);o&&(o.textContent=this._start?this._end?(0,i.fillText)(O().rangeText,{start:(0,n.fmt)(this._start),end:(0,n.fmt)(this._end)}):O().pickEndDateLabel:O().pickStartDateLabel)}_pick(e){!this._start||this._start&&this._end?(this._start=e,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint()):new Date(e).getTime()<new Date(this._start).getTime()?(this._start=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))):(this._end=e,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close())}_applyPreset({start:e,end:t}){this._start=e,this._end=t,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._paint(),this.dispatchEvent(new Event(`change`,{bubbles:!0})),this._close()}_dropPanel(){let e=this.querySelector(`.daterange-pop`);e instanceof HTMLDivElement&&(0,d.closeAnchoredPopover)(e)}_wire(){let e=this.querySelector(`.daterange-trigger`),t=this.querySelector(`.daterange-pop`),r=this.querySelector(`.daterange`);if(!(e instanceof HTMLButtonElement)||!(t instanceof HTMLDivElement))return;let i=()=>(0,d.isPopoverOpen)(t),a=()=>{this._hover=``,r?.classList.remove(`open`),e.setAttribute(`aria-expanded`,`false`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!1}}))};this._open=()=>{let o=(0,n.parseIso)(this._start);if(o)this._viewY=o.y,this._viewM=o.m;else{let e=new Date;this._viewY=e.getFullYear(),this._viewM=e.getMonth()}this._presetList=C(this.getAttribute(`presets`),new Date,this._presetOptions()),this._renderView(),(0,d.openAnchoredPopover)(e,t,{mode:`auto`,clampHeight:!0,onClosed:a}),i()&&(r?.classList.add(`open`),e.setAttribute(`aria-expanded`,`true`),this.dispatchEvent(new CustomEvent(`wui-date-range:openchange`,{bubbles:!0,detail:{open:!0}})))},this._close=()=>{(0,d.closeAnchoredPopover)(t)},e.addEventListener(`click`,()=>{i()?this._close():(0,c.isInert)(this)||this._open()}),t.addEventListener(`click`,e=>{let t=k(e),r=t.closest(`[data-nav]`);if(r instanceof HTMLElement){let e=(0,n.clampMonth)(this._viewY,this._viewM+Number(r.dataset.nav));this._viewY=e.y,this._viewM=e.m,this._renderView();return}if(t.closest(`[data-clear]`)){this._start=``,this._end=``,this._hover=``,this._syncTrigger(),this._syncMirrors(),this._renderView(),this.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let i=t.closest(`[data-preset]`);if(i instanceof HTMLButtonElement&&!i.disabled){let e=this._presetList?.[Number(i.dataset.preset)];e&&this._applyPreset(e);return}let a=t.closest(`.datepicker-day[data-iso]`);if(a instanceof HTMLButtonElement&&!a.disabled){let e=a.dataset.iso;e!==void 0&&this._pick(e)}}),t.addEventListener(`mouseover`,e=>{let t=k(e).closest(`.datepicker-day[data-iso]`),n=t instanceof HTMLButtonElement?t.dataset.iso:void 0;n!==void 0&&this._start&&!this._end&&(this._hover=n,this._paint())}),this._syncMirrors()}};D(j,`formAssociated`,!0),(0,t.defineElement)(`wui-date-range`,j),e.WuiDateRange=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.calendarMath,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.zone,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.nativeOverlay);
@@ -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.191.3`)throw Error(`[webority-ui] date-time expects ui-elements 0.191.3 but the page loaded `+s+`.`);function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=()=>(0,i.readText)(`datePicker`,a.DATE_PICKER_TEXT),p=`data-wui-part`,m=[`disabled`,`readonly`,`required`],h=(e,t=2)=>String(e).padStart(t,`0`);function g(e,t){if(e===``)return{date:``,time:``};let n=Date.parse(e);if(Number.isNaN(n))throw Error(`<wui-date-time> "${e}" is not an ISO UTC date-time.`);let r=(0,o.zoneParts)(n,t);return{date:`${h(r.year,4)}-${h(r.month+1)}-${h(r.day)}`,time:`${h(r.hour)}:${h(r.minute)}`}}function _({date:e,time:t},n){if(e===``||t===``)return``;let[r=0,i=0,a=0]=e.split(`-`).map(Number),[s=0,c=0]=t.split(`:`).map(Number);return new Date((0,o.wallToInstant)(Date.UTC(r,i-1,a,s,c),n)).toISOString()}function v(e,t,n){e.getAttribute(t)!==n&&(n===null?e.removeAttribute(t):e.setAttribute(t,n))}function y(e){return`value`in e&&typeof e.value==`string`?e.value:``}var b=class extends n.ElementBase{static get observedAttributes(){return[`value`,`min`,`max`,`zone`,`name`,`id`,`disabled`,`readonly`,`required`,`aria-label`,`aria-describedby`,`aria-invalid`,`time-label`,`date-placeholder`,`time-placeholder`]}constructor(){super(),d(this,`_date`,``),d(this,`_time`,``),d(this,`_zone`,o.IST_TIME_ZONE),d(this,`_rendered`,!1),d(this,`_written`,!1),d(this,`_defaultValue`,``),this.addEventListener(`change`,e=>this._onPartChange(e))}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){if(this._rendered){if(e===`value`)this._write(n??``);else if(e===`zone`){let e=this.value;this._zone=this._readZone(),this._setParts(e)}else if(e===`name`){this._syncMirror();return}this._syncChildren(),e===`disabled`&&this._syncMirror()}}formResetCallback(){this._setParts(this._defaultValue),this._syncChildren(),this._syncMirror()}get value(){return _({date:this._date,time:this._time},this._zone)}set value(e){this._zone=this._readZone(),this._written=!0,this._write(e||``),this._rendered&&(this._syncChildren(),this._syncMirror())}render(){this._zone=this._readZone(),this._defaultValue=this.getAttribute(`value`)??``,this._written||this._setParts(this._defaultValue);let e=document.createElement(`div`);e.className=`d-flex flex-wrap gap-2`;for(let[t,n]of[[`wui-datepicker`,`date`],[`wui-timepicker`,`time`]]){let r=document.createElement(t);r.setAttribute(p,n),e.append(r)}this.replaceChildren(e),this._rendered=!0,this._syncChildren(),this._syncMirror()}_readZone(){let e=this.getAttribute(`zone`)||o.IST_TIME_ZONE;if(!(0,o.isTimeZone)(e))throw Error(`<wui-date-time> zone "${e}" is not an IANA time zone such as "${o.IST_TIME_ZONE}".`);return e}_setParts(e){let t=g(e,this._zone);this._date=t.date,this._time=t.time}_write(e){e!==this.value&&this._setParts(e)}_limit(e){let t=this.getAttribute(e);return t?g(t,this._zone).date:null}_child(e){let t=this.querySelector(`[${p}="${e}"]`);return t instanceof HTMLElement?t:null}_syncChildren(){let e=this._child(`date`),t=this._child(`time`);if(!e||!t)return;let n=this.getAttribute(`id`);v(e,`id`,n?`${n}-date`:null),v(e,`value`,this._date||null),v(e,`min`,this._limit(`min`)),v(e,`max`,this._limit(`max`)),v(e,`placeholder`,this.getAttribute(`date-placeholder`)),v(e,`aria-label`,this.getAttribute(`aria-label`)),v(e,`aria-describedby`,this.getAttribute(`aria-describedby`)),v(e,`aria-invalid`,this.getAttribute(`aria-invalid`)),v(t,`value`,this._time||null),v(t,`placeholder`,this.getAttribute(`time-placeholder`)),v(t,`aria-label`,this.getAttribute(`time-label`)||f().dateTimeLabel);for(let n of m)for(let r of[e,t])v(r,n,this.hasAttribute(n)?``:null)}_syncMirror(){(0,r.syncFormMirror)(this,this.value)}_onPartChange(e){if(e.target===this)return;e.stopImmediatePropagation();let t=e.target,n=t instanceof Element?t.getAttribute(p):null;if(!(t instanceof Element)||n!==`date`&&n!==`time`)return;let r=y(t);n===`date`?this._date=r:this._time=r,v(t,`value`,r||null),this._syncMirror(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}};d(b,`formAssociated`,!0),(0,t.defineElement)(`wui-date-time`,b),e.WuiDateTime=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText,WeborityUiElementsInternal.modules.zone);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.193.0`)throw Error(`[webority-ui] date-time expects ui-elements 0.193.0 but the page loaded `+s+`.`);function c(e){"@babel/helpers - typeof";return c=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},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=()=>(0,i.readText)(`datePicker`,a.DATE_PICKER_TEXT),p=`data-wui-part`,m=[`disabled`,`readonly`,`required`],h=(e,t=2)=>String(e).padStart(t,`0`);function g(e,t){if(e===``)return{date:``,time:``};let n=Date.parse(e);if(Number.isNaN(n))throw Error(`<wui-date-time> "${e}" is not an ISO UTC date-time.`);let r=(0,o.zoneParts)(n,t);return{date:`${h(r.year,4)}-${h(r.month+1)}-${h(r.day)}`,time:`${h(r.hour)}:${h(r.minute)}`}}function _({date:e,time:t},n){if(e===``||t===``)return``;let[r=0,i=0,a=0]=e.split(`-`).map(Number),[s=0,c=0]=t.split(`:`).map(Number);return new Date((0,o.wallToInstant)(Date.UTC(r,i-1,a,s,c),n)).toISOString()}function v(e,t,n){e.getAttribute(t)!==n&&(n===null?e.removeAttribute(t):e.setAttribute(t,n))}function y(e){return`value`in e&&typeof e.value==`string`?e.value:``}var b=class extends n.ElementBase{static get observedAttributes(){return[`value`,`min`,`max`,`zone`,`name`,`id`,`disabled`,`readonly`,`required`,`aria-label`,`aria-describedby`,`aria-invalid`,`time-label`,`date-placeholder`,`time-placeholder`]}constructor(){super(),d(this,`_date`,``),d(this,`_time`,``),d(this,`_zone`,o.IST_TIME_ZONE),d(this,`_rendered`,!1),d(this,`_written`,!1),d(this,`_defaultValue`,``),this.addEventListener(`change`,e=>this._onPartChange(e))}connectedCallback(){this._rendered||this.render()}attributeChangedCallback(e,t,n){if(this._rendered){if(e===`value`)this._write(n??``);else if(e===`zone`){let e=this.value;this._zone=this._readZone(),this._setParts(e)}else if(e===`name`){this._syncMirror();return}this._syncChildren(),e===`disabled`&&this._syncMirror()}}formResetCallback(){this._setParts(this._defaultValue),this._syncChildren(),this._syncMirror()}get value(){return _({date:this._date,time:this._time},this._zone)}set value(e){this._zone=this._readZone(),this._written=!0,this._write(e||``),this._rendered&&(this._syncChildren(),this._syncMirror())}render(){this._zone=this._readZone(),this._defaultValue=this.getAttribute(`value`)??``,this._written||this._setParts(this._defaultValue);let e=document.createElement(`div`);e.className=`d-flex flex-wrap gap-2`;for(let[t,n]of[[`wui-datepicker`,`date`],[`wui-timepicker`,`time`]]){let r=document.createElement(t);r.setAttribute(p,n),e.append(r)}this.replaceChildren(e),this._rendered=!0,this._syncChildren(),this._syncMirror()}_readZone(){let e=this.getAttribute(`zone`)||o.IST_TIME_ZONE;if(!(0,o.isTimeZone)(e))throw Error(`<wui-date-time> zone "${e}" is not an IANA time zone such as "${o.IST_TIME_ZONE}".`);return e}_setParts(e){let t=g(e,this._zone);this._date=t.date,this._time=t.time}_write(e){e!==this.value&&this._setParts(e)}_limit(e){let t=this.getAttribute(e);return t?g(t,this._zone).date:null}_child(e){let t=this.querySelector(`[${p}="${e}"]`);return t instanceof HTMLElement?t:null}_syncChildren(){let e=this._child(`date`),t=this._child(`time`);if(!e||!t)return;let n=this.getAttribute(`id`);v(e,`id`,n?`${n}-date`:null),v(e,`value`,this._date||null),v(e,`min`,this._limit(`min`)),v(e,`max`,this._limit(`max`)),v(e,`placeholder`,this.getAttribute(`date-placeholder`)),v(e,`aria-label`,this.getAttribute(`aria-label`)),v(e,`aria-describedby`,this.getAttribute(`aria-describedby`)),v(e,`aria-invalid`,this.getAttribute(`aria-invalid`)),v(t,`value`,this._time||null),v(t,`placeholder`,this.getAttribute(`time-placeholder`)),v(t,`aria-label`,this.getAttribute(`time-label`)||f().dateTimeLabel);for(let n of m)for(let r of[e,t])v(r,n,this.hasAttribute(n)?``:null)}_syncMirror(){(0,r.syncFormMirror)(this,this.value)}_onPartChange(e){if(e.target===this)return;e.stopImmediatePropagation();let t=e.target,n=t instanceof Element?t.getAttribute(p):null;if(!(t instanceof Element)||n!==`date`&&n!==`time`)return;let r=y(t);n===`date`?this._date=r:this._time=r,v(t,`value`,r||null),this._syncMirror(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}};d(b,`formAssociated`,!0),(0,t.defineElement)(`wui-date-time`,b),e.WuiDateTime=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.formMirror,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.datePickerText,WeborityUiElementsInternal.modules.zone);