@webority/ui-elements 0.77.2 → 0.78.1

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 (60) hide show
  1. package/dist/{WuiAutocomplete-Cvoyr30K.js → WuiAutocomplete-le8obmeq.js} +1 -1
  2. package/dist/{WuiCommentThread-WL1GX7Jy.js → WuiCommentThread-xu56ddmv.js} +1 -1
  3. package/dist/WuiConsentBanner-DjgDtG3M.js +1 -0
  4. package/dist/{WuiContextMenu-BLNKaFsB.js → WuiContextMenu-fGlo4c_Z.js} +1 -1
  5. package/dist/{WuiCountrySelect-Dac15o75.js → WuiCountrySelect-DECdemVk.js} +1 -1
  6. package/dist/{WuiDatePicker-BUtDjbek.js → WuiDatePicker-BCbSGCzN.js} +1 -1
  7. package/dist/{WuiDateRange-DCNf4MSb.js → WuiDateRange-8HLWaXuU.js} +1 -1
  8. package/dist/{WuiHoverCard-Ql6CD3BL.js → WuiHoverCard-mrP_KEhB.js} +1 -1
  9. package/dist/{WuiInlineEdit-DrQmhWZ6.js → WuiInlineEdit-DJCxIh0J.js} +1 -1
  10. package/dist/{WuiMentionInput-BqcTKb8b.js → WuiMentionInput-D_pbskyy.js} +1 -1
  11. package/dist/{WuiMenubar-4MOZ51R_.js → WuiMenubar-CduCuK5G.js} +1 -1
  12. package/dist/{WuiMultiSelect-Pm9-F-YU.js → WuiMultiSelect-B2TqrJp2.js} +1 -1
  13. package/dist/{WuiNotificationCenter-Dc7hD9w-.js → WuiNotificationCenter-CYlxiwj9.js} +1 -1
  14. package/dist/{WuiOverflow-Ixc3PRuW.js → WuiOverflow-Cq_g0454.js} +1 -1
  15. package/dist/{WuiPhone-BhmKncvF.js → WuiPhone-CdJTlY2E.js} +1 -1
  16. package/dist/{WuiSelect-DR4PYwAw.js → WuiSelect-BT-kh9TD.js} +2 -2
  17. package/dist/{WuiTimePicker-CaJrTq3m.js → WuiTimePicker-CXLgydrh.js} +1 -1
  18. package/dist/{WuiTour-DOeTJa4V.js → WuiTour-DDY9N8AV.js} +1 -1
  19. package/dist/{WuiTree-amrUzT-J.js → WuiTree-CB1xoDIj.js} +1 -1
  20. package/dist/{WuiWhatsNew-68sOQOTO.js → WuiWhatsNew-Bhz_kR2O.js} +1 -1
  21. package/dist/{anchorOverlay-HAWsGzlr.js → anchorOverlay-D8di0B-z.js} +1 -1
  22. package/dist/elements/autocomplete.js +1 -1
  23. package/dist/elements/comment-thread.js +1 -1
  24. package/dist/elements/consent-banner.js +1 -1
  25. package/dist/elements/context-menu.js +1 -1
  26. package/dist/elements/country-select.js +1 -1
  27. package/dist/elements/date-range.js +1 -1
  28. package/dist/elements/datepicker.js +1 -1
  29. package/dist/elements/filter-popover.js +1 -1
  30. package/dist/elements/hover-card.js +1 -1
  31. package/dist/elements/inline-edit.js +1 -1
  32. package/dist/elements/kanban.js +1 -1
  33. package/dist/elements/mention-input.js +1 -1
  34. package/dist/elements/menubar.js +1 -1
  35. package/dist/elements/multiselect.js +1 -1
  36. package/dist/elements/notification-center.js +1 -1
  37. package/dist/elements/overflow.js +1 -1
  38. package/dist/elements/phone.js +1 -1
  39. package/dist/elements/select.js +1 -1
  40. package/dist/elements/timepicker.js +1 -1
  41. package/dist/elements/tour.js +1 -1
  42. package/dist/elements/tree.js +1 -1
  43. package/dist/elements/whats-new.js +1 -1
  44. package/dist/{fileViewerImage-BWrW3zAb.js → fileViewerImage-Bcsaoyei.js} +1 -1
  45. package/dist/{fileViewerMedia-CbvjcIc6.js → fileViewerMedia-B2kIU6tb.js} +1 -1
  46. package/dist/{fileViewerPdf-qmMcAn1q.js → fileViewerPdf-DuRqS6OC.js} +1 -1
  47. package/dist/fileViewerUi-CmfISSyD.js +1 -0
  48. package/dist/{filterPopover-wAZS4TuD.js → filterPopover-DuMhrdFk.js} +1 -1
  49. package/dist/kanban-DvHNWre-.js +1 -0
  50. package/dist/ui-consent-banner.global.js +1 -1
  51. package/dist/ui-elements.global.js +96 -53
  52. package/dist/ui-elements.js +1 -1
  53. package/dist/ui-file-viewer.global.js +1 -1
  54. package/dist/ui-file-viewer.js +1 -1
  55. package/dist/wuiHttp-CFSgthqb.js +1 -0
  56. package/package.json +1 -1
  57. package/dist/WuiConsentBanner-D6YE84__.js +0 -1
  58. package/dist/fileViewerUi-CSOkacnB.js +0 -1
  59. package/dist/kanban-Ca4U3YaX.js +0 -1
  60. package/dist/wuiHttp-27mq9Jpn.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as a,t as o}from"./focusOrigin-2imUSs-u.js";import{t as s}from"./formMirror-BgY7zkC3.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{a as u,i as d,n as f,r as p,t as m}from"./optionLabel-Bd3vP-XI.js";var h=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`]}constructor(){super(),this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();return}if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),s(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?d(t):``,this._syncInput(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=d(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),this._renderOptions()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>d(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[m]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r,this.innerHTML=`
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as a,t as o}from"./focusOrigin-2imUSs-u.js";import{t as s}from"./formMirror-BgY7zkC3.js";import{n as c,t as l}from"./listboxKeyNav-DMIvs9d6.js";import{a as u,i as d,n as f,r as p,t as m}from"./optionLabel-Bd3vP-XI.js";var h=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`]}constructor(){super(),this._value=``,this._label=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();return}if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),s(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?d(t):``,this._syncInput(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=d(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),this._renderOptions()}get loading(){return this._loading}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>d(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[m]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r,this.innerHTML=`
2
2
  <div class="search-select${n}">
3
3
  <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${g(r)}" aria-label="${g(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}>
4
4
  <input class="search-select-input search-select-ac-input" placeholder="${g(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``} />
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{c as i}from"./wuiHttp-27mq9Jpn.js";var a=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),o=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),s=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),c=`[data-wui-items]`,l=`[data-wui-picker]`,u=`[data-wui-composer]`,d=`[data-wui-comment]`,f=`[data-wui-live]`,p=e=>typeof e?.message==`string`&&e.message?e.message:s.failed.server,m=class extends e{constructor(){super(),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),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(l)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&r(this._pickerFor.button,this.querySelector(l))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),this._handPeople(this.querySelector(`${u} wui-mention-input`)))}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [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}))}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)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:a}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(l),n=e?this._pickerFor?.comment:t.closest(d);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(d);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`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n);break}}_onKeyDown(e){let t=this.querySelector(l);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(d),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){let n=e?.querySelector(`:scope > [data-wui-reply]`);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:s.replyLabel(r),placeholder:s.replyPlaceholder,value:``,send:s.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n||!n.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:s.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:s.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,c=o.createElement(`wui-mention-input`);c.className=`wui-mention-input`,c.setAttribute(`label`,t),n&&c.setAttribute(`placeholder`,n),c.setAttribute(`rows`,`2`),c.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&c.setAttribute(e,this.getAttribute(e));let l=o.createElement(`div`);l.className=`wui-comment-form-actions`,l.append(this._button(`btn btn-primary btn-sm`,`send`,i),this._button(`btn btn-ghost btn-sm`,`cancel`,s.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(c,l,u),this._handPeople(c),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),c.focus();let d=c.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n){let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=e,r.setAttribute(`data-wui-action`,t),r.textContent=n,r}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,n){let i=this.querySelector(l);!i||!e||(this._closePicker(!1),this._pickerFor={comment:e,button:n},n.setAttribute(`aria-expanded`,`true`),i.hidden=!1,r(n,i),t(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(l);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),n(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,s.emptyBody),n?.focus();return}let i=t.closest(d);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.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??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let c=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let l=t.commentId??null,u=t.parentId??null;if(c.ok){c.html!=null&&this._swapItems(c.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),s.done[e]&&this._announce(s.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:l,parentId:u}}));return}c.kind===`session`||c.kind===`aborted`||(this._showError(a.isConnected?a:this,c.message),this._announce(c.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:c.kind,message:c.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:p(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:s.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await i(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||s.failed[r.kind]||s.failed.server}}_swapItems(e){let t=this.querySelector(c);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(c);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(d)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${u} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${f}`);!t||!e||(t.textContent=``,t.textContent=e)}};export{m as i,a as n,s as r,o as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{c as i}from"./wuiHttp-CFSgthqb.js";var a=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),o=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),s=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),c=`[data-wui-items]`,l=`[data-wui-picker]`,u=`[data-wui-composer]`,d=`[data-wui-comment]`,f=`[data-wui-live]`,p=e=>typeof e?.message==`string`&&e.message?e.message:s.failed.server,m=class extends e{constructor(){super(),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),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(l)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&r(this._pickerFor.button,this.querySelector(l))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey),this._handPeople(this.querySelector(`${u} wui-mention-input`)))}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [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}))}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)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:a}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(l),n=e?this._pickerFor?.comment:t.closest(d);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(d);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`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n);break}}_onKeyDown(e){let t=this.querySelector(l);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(d),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){let n=e?.querySelector(`:scope > [data-wui-reply]`);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:s.replyLabel(r),placeholder:s.replyPlaceholder,value:``,send:s.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n||!n.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:s.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:s.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,c=o.createElement(`wui-mention-input`);c.className=`wui-mention-input`,c.setAttribute(`label`,t),n&&c.setAttribute(`placeholder`,n),c.setAttribute(`rows`,`2`),c.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&c.setAttribute(e,this.getAttribute(e));let l=o.createElement(`div`);l.className=`wui-comment-form-actions`,l.append(this._button(`btn btn-primary btn-sm`,`send`,i),this._button(`btn btn-ghost btn-sm`,`cancel`,s.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(c,l,u),this._handPeople(c),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),c.focus();let d=c.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n){let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=e,r.setAttribute(`data-wui-action`,t),r.textContent=n,r}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,n){let i=this.querySelector(l);!i||!e||(this._closePicker(!1),this._pickerFor={comment:e,button:n},n.setAttribute(`aria-expanded`,`true`),i.hidden=!1,r(n,i),t(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(l);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),n(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,s.emptyBody),n?.focus();return}let i=t.closest(d);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.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??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let c=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let l=t.commentId??null,u=t.parentId??null;if(c.ok){c.html!=null&&this._swapItems(c.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),s.done[e]&&this._announce(s.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:l,parentId:u}}));return}c.kind===`session`||c.kind===`aborted`||(this._showError(a.isConnected?a:this,c.message),this._announce(c.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:c.kind,message:c.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:p(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:s.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await i(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||s.failed[r.kind]||s.failed.server}}_swapItems(e){let t=this.querySelector(c);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(c);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(d)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${u} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${f}`);!t||!e||(t.textContent=``,t.textContent=e)}};export{m as i,a as n,s as r,o as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t}from"./devWarn-DXdRWZs3.js";import{t as n}from"./tourOpenMark-nPeAJFSo.js";var r={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-ink":`#4F46E5`,"--color-primary-text":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-overlay-lg":`0 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},i=e=>`var(${e}, ${r[e]})`,a=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${i(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${i(`--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: ${i(`--color-surface`)}; border: 1px solid ${i(`--color-border`)}; border-radius: ${i(`--wui-radius-lg`)}; box-shadow: ${i(`--wui-shadow-overlay-lg`)}; 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: ${i(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${i(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${i(`--color-primary-ink`)}; 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 ${i(`--color-border`)}; border-bottom: 1px solid ${i(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${i(`--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: ${i(`--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: ${i(`--color-primary`)}; background: ${i(`--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 ${i(`--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 ${i(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${i(`--color-primary`)}; border-color: ${i(`--color-primary`)}; color: ${i(`--color-primary-text`)}; } .btn-primary:hover { background: ${i(`--color-primary-hover`)}; border-color: ${i(`--color-primary-hover`)}; } .btn-outline-secondary { border-color: ${i(`--color-text-muted`)}; color: ${i(`--color-text-muted`)}; } .btn-outline-secondary:hover { background: ${i(`--color-bg-muted`)}; color: ${i(`--color-text`)}; } .btn-link { font-weight: 400; color: ${i(`--color-primary-ink`)}; text-decoration: underline; } .btn-link:hover { color: ${i(`--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; } } `,o=`wui-consent-save`,s=`[data-consent-settings]`,c=`tour-open`,l=`--wui-consent-banner-block`,u=`--wui-consent-banner-inline`,d={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},f=[`analytics`,`functional`,`marketing`],p={analytics:{label:d.analyticsLabel,description:`analyticsDescription`},functional:{label:d.functionalLabel,description:`functionalDescription`},marketing:{label:d.marketingLabel,description:`marketingDescription`}},m=new Set;function h(e){m.has(e)||(m.add(e),t(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${f.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var g=0,_=null;function v(e){_||(_=new CSSStyleSheet,_.replaceSync(a)),e.adoptedStyleSheets=[_]}var y=class extends e{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g+=1,this._uid=`wui-consent-${g}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(s)&&(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 heading(){return this.getAttribute(`heading`)||d.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||d.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`)||d.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||d.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||d.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||d.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...f];let t=e.split(/\s+/).filter(Boolean);for(let e of t)f.includes(e)||h(e);let n=f.filter(e=>t.includes(e));return n.length?n:[...f]}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(f.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:[n]}),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(c,document.documentElement.hasAttribute(n))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,n=this.policyHref?` <a class="wui-consent-banner-policy" href="${S(this.policyHref)}">${x(this.policyLabel)}</a>`:``,r=this._root();r!==this&&v(r),r.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${x(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${x(this.description)}${n}</p> <div class="wui-consent-banner-settings" hidden> ${b(t,`essential`,d.essentialLabel,d.essentialDescription,!0)} ${this.categories.map(e=>b(t,e,p[e].label,this[p[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${d.settingsLabel}</button> <button type="button" class="btn btn-sm btn-outline-secondary wui-consent-banner-reject">${d.rejectLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-accept">${d.acceptLabel}</button> <button type="button" class="btn btn-sm btn-primary wui-consent-banner-save" hidden>${d.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&(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(l),document.documentElement.style.removeProperty(u)}_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(l,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(u,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_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(o,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(f.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of f)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of f){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)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&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function b(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${x(n)}</label> </div> <p class="wui-consent-banner-category-description">${x(r)}</p> </div>`}var x=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),S=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{y as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./anchorOverlay-HAWsGzlr.js";import{t as n}from"./listboxKeyNav-DMIvs9d6.js";var r=`[role="menuitem"]`,i=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,a=`data-open`,o=500,s=10,c=400,l=null,u=null,d=new WeakMap;function f(e,t,n){let r=d.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return d.set(e,{region:t,cancel:n}),!0}var p=e=>e instanceof Element?e:e?.parentElement??null,m=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._nav=n({getVisibleOptions:()=>this._items(),getActive:()=>this._items().indexOf(document.activeElement),setActive:e=>this._items()[e]?.focus({preventScroll:!0})}),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._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>s&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{!this._swallowClick||!this._region?.contains(e.target)||(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())},this._onKeyDown=e=>{this._inPanel(e.target)&&this._handleMenuKey(e)},this._onClick=e=>this._handleClick(e),this._onMouseMove=e=>{let t=p(e.target)?.closest(r);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=e=>{this._swallowClick=!1,this.isOpen&&!this._inPanel(e.target)&&this.close()}}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),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousemove`,this._onMouseMove)}disconnectedCallback(){this._teardown()}attributeChangedCallback(){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(){return this._panel()?.hasAttribute(a)??!1}open(e,n,{region:r=this,origin:i=r,keyboard:o=!1}={}){let s=this._panel();if(s){if(l&&l!==this&&l.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)?e:null}this._region=r,this._origin=i,u=null,s.setAttribute(a,``),l=this,t({getBoundingClientRect:()=>({left:e,right:e,top:n,bottom:n,width:0,height:0})},s,{clampHeight:!0}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),((o?this._items()[0]:null)??s).focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:r,origin:i,x:e,y:n}}))}}close(e=!1){let t=this._panel();if(!t?.hasAttribute(a))return;t.removeAttribute(a),l===this&&(l=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._nav.teardown();let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_panel(){return[...this.children].find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return!!e&&!!this._panel()?.contains(e)}_items(){return[...this._panel()?.querySelectorAll(r)??[]].filter(e=>!this._isDisabled(e))}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=p(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(i))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_isKeyEcho(){return u?.menu===this&&this.isOpen&&performance.now()-u.at<c}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!d.has(e))return;let t=this._regionFor(e.target);if(t){if(this._isKeyEcho()){e.preventDefault();return}e.shiftKey||f(e,t,()=>this.close(!0))&&(e.preventDefault(),this.open(e.clientX,e.clientY,{region:t,origin:p(e.target)}))}}_handleDocKeyDown(e){if(e.defaultPrevented&&!d.has(e)||!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this.close(!0)))return;e.preventDefault();let n=p(e.target),r=n.getBoundingClientRect();this.open(r.left+Math.min(16,r.width/2),r.bottom,{region:t,origin:n,keyboard:!0}),u={menu:this,at:performance.now()}}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=p(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this._swallowClick=!0,this.open(n,r,{region:t,origin:i})},o)},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)if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close(!0);else if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._step(e.key===`ArrowDown`?1:-1);else if(e.key===` `){let t=p(e.target)?.closest(r);e.preventDefault(),t&&t.click()}else this._nav.handler(e)}_step(e){let t=this._items();if(!t.length)return;let n=t.indexOf(document.activeElement);t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length].focus({preventScroll:!0})}_handleClick(e){let t=p(e.target)?.closest(r);if(!(!t||!this._inPanel(t))){if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}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(){this.close(),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),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousemove`,this._onMouseMove)}};export{m as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{t}from"./anchorOverlay-D8di0B-z.js";import{t as n}from"./listboxKeyNav-DMIvs9d6.js";var r=`[role="menuitem"]`,i=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,a=`data-open`,o=500,s=10,c=400,l=null,u=null,d=new WeakMap;function f(e,t,n){let r=d.get(e);if(r){if(r.region===t||t.contains(r.region))return!1;r.cancel()}return d.set(e,{region:t,cancel:n}),!0}var p=e=>e instanceof Element?e:e?.parentElement??null,m=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._region=null,this._origin=null,this._returnFocus=null,this._press=null,this._swallowClick=!1,this._nav=n({getVisibleOptions:()=>this._items(),getActive:()=>this._items().indexOf(document.activeElement),setActive:e=>this._items()[e]?.focus({preventScroll:!0})}),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._onPointerDown=e=>this._handlePointerDown(e),this._onPressMove=e=>{this._press&&Math.hypot(e.clientX-this._press.x,e.clientY-this._press.y)>s&&this._cancelPress()},this._onPressEnd=()=>this._cancelPress(),this._onClickCapture=e=>{!this._swallowClick||!this._region?.contains(e.target)||(this._swallowClick=!1,e.preventDefault(),e.stopImmediatePropagation())},this._onKeyDown=e=>{this._inPanel(e.target)&&this._handleMenuKey(e)},this._onClick=e=>this._handleClick(e),this._onMouseMove=e=>{let t=p(e.target)?.closest(r);t&&this._inPanel(t)&&!this._isDisabled(t)&&t!==document.activeElement&&t.focus({preventScroll:!0})},this._onDismiss=e=>{e.type===`scroll`&&this._inPanel(e.target)||this.close()},this._onPointerDownCapture=e=>{this._swallowClick=!1,this.isOpen&&!this._inPanel(e.target)&&this.close()}}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),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousemove`,this._onMouseMove)}disconnectedCallback(){this._teardown()}attributeChangedCallback(){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(){return this._panel()?.hasAttribute(a)??!1}open(e,n,{region:r=this,origin:i=r,keyboard:o=!1}={}){let s=this._panel();if(s){if(l&&l!==this&&l.close(!0),!this.isOpen){let e=document.activeElement;this._returnFocus=e&&e!==document.body&&!this._inPanel(e)?e:null}this._region=r,this._origin=i,u=null,s.setAttribute(a,``),l=this,t({getBoundingClientRect:()=>({left:e,right:e,top:n,bottom:n,width:0,height:0})},s,{clampHeight:!0}),window.addEventListener(`scroll`,this._onDismiss,!0),window.addEventListener(`resize`,this._onDismiss),window.addEventListener(`blur`,this._onDismiss),((o?this._items()[0]:null)??s).focus({preventScroll:!0}),this.dispatchEvent(new CustomEvent(`wui-context-menu:open`,{bubbles:!0,detail:{region:r,origin:i,x:e,y:n}}))}}close(e=!1){let t=this._panel();if(!t?.hasAttribute(a))return;t.removeAttribute(a),l===this&&(l=null),window.removeEventListener(`scroll`,this._onDismiss,!0),window.removeEventListener(`resize`,this._onDismiss),window.removeEventListener(`blur`,this._onDismiss),this._nav.teardown();let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus({preventScroll:!0})}_panel(){return[...this.children].find(e=>e.getAttribute(`role`)===`menu`)??null}_inPanel(e){return!!e&&!!this._panel()?.contains(e)}_items(){return[...this._panel()?.querySelectorAll(r)??[]].filter(e=>!this._isDisabled(e))}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_regionFor(e){let t=p(e);if(!t||this.disabled||!this._panel()||this._inPanel(t)||t.closest(i))return null;let n=this.target;return n?t.closest(n):this.contains(t)?this:null}_isKeyEcho(){return u?.menu===this&&this.isOpen&&performance.now()-u.at<c}_handleContextMenu(e){if(this._inPanel(e.target)){e.preventDefault();return}if(e.defaultPrevented&&!d.has(e))return;let t=this._regionFor(e.target);if(t){if(this._isKeyEcho()){e.preventDefault();return}e.shiftKey||f(e,t,()=>this.close(!0))&&(e.preventDefault(),this.open(e.clientX,e.clientY,{region:t,origin:p(e.target)}))}}_handleDocKeyDown(e){if(e.defaultPrevented&&!d.has(e)||!(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey)||this._inPanel(e.target))return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this.close(!0)))return;e.preventDefault();let n=p(e.target),r=n.getBoundingClientRect();this.open(r.left+Math.min(16,r.width/2),r.bottom,{region:t,origin:n,keyboard:!0}),u={menu:this,at:performance.now()}}_handlePointerDown(e){if(e.pointerType!==`touch`)return;let t=this._regionFor(e.target);if(!t||!f(e,t,()=>this._cancelPress()))return;this._cancelPress();let{clientX:n,clientY:r}=e,i=p(e.target);this._press={x:n,y:r,timer:setTimeout(()=>{this._cancelPress(),this._swallowClick=!0,this.open(n,r,{region:t,origin:i})},o)},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)if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close(!0);else if(e.key===`Tab`)this.close(!0);else if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._step(e.key===`ArrowDown`?1:-1);else if(e.key===` `){let t=p(e.target)?.closest(r);e.preventDefault(),t&&t.click()}else this._nav.handler(e)}_step(e){let t=this._items();if(!t.length)return;let n=t.indexOf(document.activeElement);t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length].focus({preventScroll:!0})}_handleClick(e){let t=p(e.target)?.closest(r);if(!(!t||!this._inPanel(t))){if(this._isDisabled(t)){e.preventDefault(),e.stopPropagation();return}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(){this.close(),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),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousemove`,this._onMouseMove)}};export{m as t};
@@ -1 +1 @@
1
- import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-DR4PYwAw.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
1
+ import{t as e}from"./countries-CvmZ2xpG.js";import{t}from"./WuiSelect-BT-kh9TD.js";var n=e=>{if(e==null)return null;let t=String(e).split(`,`).map(e=>e.trim().toUpperCase()).filter(Boolean);return t.length?new Set(t):null},r=t=>{let r=n(t);return e.filter(([e])=>!r||r.has(e)).map(([e,t])=>({value:e,label:t,flag:e}))},i=class extends t{static get observedAttributes(){return[...t.observedAttributes,`countries`]}_readOptions(){let e=this.getAttribute(`countries`);return this._countryCache?.attr!==e&&(this._countryCache={attr:e,options:r(e)}),this._countryCache.options}};export{i as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,a(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Choose a date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`disabled-weekdays`,`display-format`,`size`,`aria-label`,`aria-describedby`,`aria-invalid`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``;let e=new Date(2e3,0,1);this._viewY=e.getFullYear(),this._viewM=e.getMonth(),this._mode=`days`,this._focus=null,this._slide=``}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}this._rendered&&(e===`value`?(this._value=n||``,this._syncFormValue(),this._syncTrigger()):e===`display-format`?this._syncTrigger():e===`first-day`?this.querySelector(`.datepicker-pop`)?.hidden||this._renderView():this.render())}_syncInvalid(){let e=this.querySelector(`.datepicker-trigger`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}formResetCallback(){this.value=this._defaultValue||``}get value(){return this._value}set value(e){this._value=e||``,a(this,this._value),this._syncTrigger()}_firstDay(){return s(this)}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``,this._value=this._defaultValue||this._value);let e=this.getAttribute(`placeholder`)||`Choose a date`,t=p(this._value);t&&(this._viewY=t.y,this._viewM=t.m);let n=this.getAttribute(`size`),r=n===`sm`?` input-sm`:n===`lg`?` input-lg`:``,s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
2
  <div class="datepicker">
3
3
  <button type="button" class="input datepicker-trigger${r}${t?` has-value`:``}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
4
  <span data-trigger-label class="${t?``:`search-select-placeholder`}">${o(t?d(this._value,this.getAttribute(`display-format`)):e)}</span>
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=`Asia/Kolkata`,g=3,_=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],v={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},y=e=>String(e).padStart(2,`0`),b=e=>`${e.getUTCFullYear()}-${y(e.getUTCMonth()+1)}-${y(e.getUTCDate())}`;function x(e=new Date){let t=new Intl.DateTimeFormat(`en-US`,{timeZone:h,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),n=e=>t.find(t=>t.type===e).value;return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}function S(e,t=new Date){let{y:n,m:r,d:i}=p(x(t)),a=(e,t,n)=>b(new Date(Date.UTC(e,t,n))),o=v[e];switch(e){case`today`:return{label:o,start:a(n,r,i),end:a(n,r,i)};case`yesterday`:return{label:o,start:a(n,r,i-1),end:a(n,r,i-1)};case`last7Days`:return{label:o,start:a(n,r,i-6),end:a(n,r,i)};case`last30Days`:return{label:o,start:a(n,r,i-29),end:a(n,r,i)};case`thisMonth`:return{label:o,start:a(n,r,1),end:a(n,r+1,0)};case`lastMonth`:return{label:o,start:a(n,r-1,1),end:a(n,r,0)};case`thisFinancialYear`:{let e=r>=g?n:n-1;return{label:o,start:a(e,g,1),end:a(e+1,g,0)}}default:return null}}function C(e){i(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function w(e,t=new Date){let n=String(e??``).trim();if(!n)return[];let r;if(n.startsWith(`[`))try{r=JSON.parse(n)}catch{return C(`the attribute is not valid JSON`),[]}else r=n.split(`,`).map(e=>e.trim());let i=[];for(let e of r)if(typeof e==`string`){let n=S(e,t);n?i.push(n):C(`"${e}" is not one of ${_.join(`, `)}`)}else e&&typeof e.label==`string`&&e.label&&p(e.start)&&p(e.end)?i.push({label:e.label,start:e.start,end:e.end}):C(`an item needs a label and ISO start and end dates, or a preset name`);return i}var T=class extends e{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`aria-invalid`]}constructor(){super();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(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}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 s(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${d(this._start)||`Start`} to ${d(this._end)||`End`}`,empty:!1}}render(){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=p(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o}from"./optionLabel-Bd3vP-XI.js";import{a as s,c,i as l,n as u,o as d,r as f,s as p,t as m}from"./calendarMath-BC2wGCD-.js";var h=`Asia/Kolkata`,g=3,_=[`today`,`yesterday`,`last7Days`,`last30Days`,`thisMonth`,`lastMonth`,`thisFinancialYear`],v={today:`Today`,yesterday:`Yesterday`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,thisMonth:`This month`,lastMonth:`Last month`,thisFinancialYear:`This financial year`},y=e=>String(e).padStart(2,`0`),b=e=>`${e.getUTCFullYear()}-${y(e.getUTCMonth()+1)}-${y(e.getUTCDate())}`;function x(e=new Date){let t=new Intl.DateTimeFormat(`en-US`,{timeZone:h,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(e),n=e=>t.find(t=>t.type===e).value;return`${n(`year`)}-${n(`month`)}-${n(`day`)}`}function S(e,t=new Date){let{y:n,m:r,d:i}=p(x(t)),a=(e,t,n)=>b(new Date(Date.UTC(e,t,n))),o=v[e];switch(e){case`today`:return{label:o,start:a(n,r,i),end:a(n,r,i)};case`yesterday`:return{label:o,start:a(n,r,i-1),end:a(n,r,i-1)};case`last7Days`:return{label:o,start:a(n,r,i-6),end:a(n,r,i)};case`last30Days`:return{label:o,start:a(n,r,i-29),end:a(n,r,i)};case`thisMonth`:return{label:o,start:a(n,r,1),end:a(n,r+1,0)};case`lastMonth`:return{label:o,start:a(n,r-1,1),end:a(n,r,0)};case`thisFinancialYear`:{let e=r>=g?n:n-1;return{label:o,start:a(e,g,1),end:a(e+1,g,0)}}default:return null}}function C(e){i(`[@webority/ui-elements] <wui-date-range> presets: ${e}`)}function w(e,t=new Date){let n=String(e??``).trim();if(!n)return[];let r;if(n.startsWith(`[`))try{r=JSON.parse(n)}catch{return C(`the attribute is not valid JSON`),[]}else r=n.split(`,`).map(e=>e.trim());let i=[];for(let e of r)if(typeof e==`string`){let n=S(e,t);n?i.push(n):C(`"${e}" is not one of ${_.join(`, `)}`)}else e&&typeof e.label==`string`&&e.label&&p(e.start)&&p(e.end)?i.push({label:e.label,start:e.start,end:e.end}):C(`an item needs a label and ISO start and end dates, or a preset name`);return i}var T=class extends e{static formAssociated=!0;static get observedAttributes(){return[`start`,`end`,`min`,`max`,`placeholder`,`disabled`,`first-day`,`size`,`aria-label`,`aria-describedby`,`name`,`start-name`,`end-name`,`presets`,`aria-invalid`]}constructor(){super();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(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`aria-invalid`){this._syncInvalid();return}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 s(this)}_label(){let e=this.getAttribute(`placeholder`)||`Start to End`;return!this._start&&!this._end?{text:e,empty:!0}:{text:`${d(this._start)||`Start`} to ${d(this._end)||`End`}`,empty:!1}}render(){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=p(this._start);e&&(this._viewY=e.y,this._viewM=e.m);let t=this.getAttribute(`size`),n=t===`sm`?` input-sm`:t===`lg`?` input-lg`:``,{text:r,empty:i}=this._label(),s=this.getAttribute(`aria-label`),c=this.getAttribute(`aria-describedby`);this.innerHTML=`
2
2
  <div class="daterange">
3
3
  <button type="button" class="input daterange-trigger${n}${i?``:` has-value`}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s?` aria-label="${o(s)}"`:``}${c?` aria-describedby="${o(c)}"`:``}>
4
4
  <span data-range-label class="${i?`search-select-placeholder`:``}">${o(r)}</span>
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0,u=class extends e{constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType===`touch`||e.pointerType===`pen`||this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen)return;e.stopPropagation();let t=this._panel?.contains(this.ownerDocument.activeElement);this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){return this._panel?.hasAttribute(`data-open`)??!1}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut)}disconnectedCallback(){this._clear(),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),n(this),this._doc=null}get _trigger(){return this.querySelector(o)}get _panel(){return this.querySelector(s)}get _anchor(){let e=this._trigger;return e?.querySelector(c)??e}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this.isOpen===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let r=this._panel;!r||this.isOpen===e||(e?(r.setAttribute(`data-open`,``),this._reposition(),t(this,()=>this._reposition()),this._doc?.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onKeyDown),this._describe(r)):(r.removeAttribute(`data-open`),n(this),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),this._described?.removeAttribute(`aria-describedby`),this._described=null),this.dispatchEvent(new CustomEvent(e?`wui:hover-card:open`:`wui:hover-card:close`,{bubbles:!0})))}_reposition(){this.isOpen&&r(this._trigger,this._panel,{clampHeight:!0})}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{u as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";var i=300,a=150,o=`.wui-hover-card-trigger`,s=`.wui-hover-card-panel`,c=`a[href],button,input,select,textarea,[tabindex]`,l=0,u=class extends e{constructor(){super(),this._doc=null,this._timer=null,this._described=null,this._refocusing=!1,this._onOver=e=>{if(e.pointerType===`touch`||e.pointerType===`pen`)return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._schedule(!0)},this._onOut=e=>{e.pointerType===`touch`||e.pointerType===`pen`||this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{this._refocusing||(this._zone(e.target)===`trigger`?this._schedule(!0):this._zone(e.target)===`panel`&&this._clear())},this._onFocusOut=e=>{this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this.isOpen)return;e.stopPropagation();let t=this._panel?.contains(this.ownerDocument.activeElement);this._clear(),this._setOpen(!1),t&&(this._refocusing=!0,this._anchor?.focus(),this._refocusing=!1)}}get isOpen(){return this._panel?.hasAttribute(`data-open`)??!1}connectedCallback(){this._doc=this.ownerDocument,this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut)}disconnectedCallback(){this._clear(),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),n(this),this._doc=null}get _trigger(){return this.querySelector(o)}get _panel(){return this.querySelector(s)}get _anchor(){let e=this._trigger;return e?.querySelector(c)??e}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_delay(e,t){let n=Number(this.getAttribute(e));return this.hasAttribute(e)&&Number.isFinite(n)&&n>=0?n:t}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this.isOpen===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._setOpen(e)},t)}_setOpen(e){let r=this._panel;!r||this.isOpen===e||(e?(r.setAttribute(`data-open`,``),this._reposition(),t(this,()=>this._reposition()),this._doc?.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`keydown`,this._onKeyDown),this._describe(r)):(r.removeAttribute(`data-open`),n(this),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`keydown`,this._onKeyDown),this._described?.removeAttribute(`aria-describedby`),this._described=null),this.dispatchEvent(new CustomEvent(e?`wui:hover-card:open`:`wui:hover-card:close`,{bubbles:!0})))}_reposition(){this.isOpen&&r(this._trigger,this._panel,{clampHeight:!0})}_describe(e){let t=this._anchor;t&&(e.id||=`wui-hover-card-${++l}`,t.setAttribute(`aria-describedby`,e.id),this._described=t)}};export{u as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import"./formatters-BAE__8ye.js";import{c as t}from"./wuiHttp-27mq9Jpn.js";import{o as n}from"./calendarMath-BC2wGCD-.js";var r=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),i=2e3,a=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function o(e,{type:t=`text`,options:r,placeholder:i}={}){let a=e==null?``:String(e);if(a===``)return{text:i||`-`,empty:!0};if(t===`date`)return{text:n(a)||a,empty:!1};if(t===`select`){let e=r?.find(e=>String(e.value)===a);return{text:typeof e?.label==`string`?e.label:a,empty:!1}}return{text:a,empty:!1}}var s=`[data-wui-display]`,c=`[data-wui-value]`,l=`[data-wui-editor]`,u=`[data-wui-control]`,d=`[data-wui-error]`,f=`[data-wui-live]`,p=`[aria-expanded="true"]`,m=new Set([`select`,`date`]),h=e=>typeof e?.message==`string`&&e.message?e.message:a.failed.server,g=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(s),t=this.querySelector(l),n=this._control();!e||!t||!n||(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),e.hidden=!0,t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n))}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(s)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(l)?.querySelector(p))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||m.has(t)||t===`textarea`&&!(e.ctrlKey||e.metaKey)||(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!m.has(this._type()))return;let t=this._control();!t||e.target!==t||queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=r?null:this._readShown();r||this._showValue(e),this._close();let s=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;if(s.ok){this.setAttribute(`value`,e),!r&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),i),this._announce(a.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t});return}if(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`){this._setState(null);return}this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(a.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.message})}async _persist(e,n){if(n){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:h(e)}}}let r=this.getAttribute(`action`);if(!r)return{ok:!0};let i=await t(r,{method:`POST`,body:new URLSearchParams({[this.getAttribute(`name`)||`value`]:e})});return i.ok?{ok:!0,text:i.html.trim()}:{ok:!1,kind:i.kind,message:i.message||a.failed[i.kind]||a.failed.server}}_close(){let e=this.querySelector(s),t=this.querySelector(l),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(p)?.click(),n&&e?.focus()}_focusControl(e){if(!m.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let t=this._type(),r=e;if(t===`date`)r=n(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(r=t.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(c);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(c);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(c);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(d),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(f);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(u)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return r.includes(e)?e:`text`}};export{o as a,g as i,a as n,r,i as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import"./formatters-BAE__8ye.js";import{c as t}from"./wuiHttp-CFSgthqb.js";import{o as n}from"./calendarMath-BC2wGCD-.js";var r=Object.freeze([`text`,`number`,`select`,`date`,`textarea`]),i=2e3,a=Object.freeze({edit:e=>`Edit ${e}: `,readOnly:e=>`${e}: `,saved:e=>`${e} saved.`,notSaved:(e,t)=>`${e} was not saved. ${t}`,failed:Object.freeze({forbidden:`You do not have permission to change this.`,client:`This could not be saved. Refresh the page and try again.`,validation:`This value was not accepted. Check it and try again.`,server:`Something went wrong on our side, so this was not saved. Try again in a moment.`,network:`Could not reach the server, so this was not saved. Check your connection and try again.`})});function o(e,{type:t=`text`,options:r,placeholder:i}={}){let a=e==null?``:String(e);if(a===``)return{text:i||`-`,empty:!0};if(t===`date`)return{text:n(a)||a,empty:!1};if(t===`select`){let e=r?.find(e=>String(e.value)===a);return{text:typeof e?.label==`string`?e.label:a,empty:!1}}return{text:a,empty:!1}}var s=`[data-wui-display]`,c=`[data-wui-value]`,l=`[data-wui-editor]`,u=`[data-wui-control]`,d=`[data-wui-error]`,f=`[data-wui-live]`,p=`[aria-expanded="true"]`,m=new Set([`select`,`date`]),h=e=>typeof e?.message==`string`&&e.message?e.message:a.failed.server,g=class extends e{static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=this.querySelector(s),t=this.querySelector(l),n=this._control();!e||!t||!n||(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),e.hidden=!0,t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n))}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation(),e.type===`click`&&!this._editing&&this.querySelector(s)?.contains(e.target)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(l)?.querySelector(p))}_onKeyDown(e){if(!this._editing){(e.key===`Enter`||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||m.has(t)||t===`textarea`&&!(e.ctrlKey||e.metaKey)||(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!m.has(this._type()))return;let t=this._control();!t||e.target!==t||queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let o=r?null:this._readShown();r||this._showValue(e),this._close();let s=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let c=this.getAttribute(`label`)||``;if(s.ok){this.setAttribute(`value`,e),!r&&s.text&&this._showText(s.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),i),this._announce(a.saved(c)),this._fire(`wui:inline-edit:saved`,{value:e,previous:t});return}if(o&&this._restoreShown(o),s.kind===`session`||s.kind===`aborted`){this._setState(null);return}this._draft=e,this._setState(`error`),this._setError(s.message),this._announce(a.notSaved(c,s.message)),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:s.kind,message:s.message})}async _persist(e,n){if(n){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:h(e)}}}let r=this.getAttribute(`action`);if(!r)return{ok:!0};let i=await t(r,{method:`POST`,body:new URLSearchParams({[this.getAttribute(`name`)||`value`]:e})});return i.ok?{ok:!0,text:i.html.trim()}:{ok:!1,kind:i.kind,message:i.message||a.failed[i.kind]||a.failed.server}}_close(){let e=this.querySelector(s),t=this.querySelector(l),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),t?.querySelector(p)?.click(),n&&e?.focus()}_focusControl(e){if(!m.has(this._type())){e.focus(),e.select?.();return}let t=e.querySelector(`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(e){if(e===``){this._showText(this.getAttribute(`placeholder`)||`-`,!0);return}let t=this._type(),r=e;if(t===`date`)r=n(e)||e;else if(t===`select`){let t=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(t=>t.getAttribute(`data-value`)===e);t&&(r=t.textContent.trim())}this._showText(r,!1)}_readShown(){let e=this.querySelector(c);return e?{html:e.innerHTML,empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(c);t&&(t.innerHTML=e.html,t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(c);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=this.querySelector(d),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(f);!t||!e||(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){return this.querySelector(u)}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return r.includes(e)?e:`text`}};export{o as a,g as i,a as n,r,i as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{f as i}from"./formatters-BAE__8ye.js";import{c as a}from"./wuiHttp-27mq9Jpn.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";var s=/^[A-Za-z0-9_.:-]{1,64}$/,c=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,l=/@(\\*)\[/g;function u(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var d=e=>e.replace(l,(e,t)=>`@\\${t}[`);function f(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(c))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function p(e){let t=``,n=[];for(let r of f(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function m(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!s.test(e.id)||(i+=d(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+d(n.slice(a))}function h(e){let t=[];for(let n of f(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var g=8,_=40,v=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${i(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),y=`[data-wui-control]`,b=`[data-wui-field]`,x=`[data-wui-menu]`,S=`[data-wui-live]`,C=0,w=e=>e&&s.test(String(e.value??``))&&u(e.label)!==``;function T(e){let t=e.ownerDocument;e.id||=`wui-mention-${++C}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea 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`),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`,v.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,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 E=class extends e{static get observedAttributes(){return[`disabled`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,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),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(y)||T(this);let e=this._control(),t=this.querySelector(b)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,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._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);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()):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return m(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);if(!this._wired){this._pendingValue=t;return}t!==this.value&&this._load(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(w):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading}set loading(e){this._loading=!!e,this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(y)}_menu(){return this.querySelector(x)}_load(e){let{text:t,mentions:n}=p(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(b);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._control(),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?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();if(!t){this._close();return}this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh())}_queryAtCaret(){let e=this._control();if(!e||e.disabled||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[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=>u(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`);if(!n){this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}));return}this._fetchPeople(n,e,t)},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=await a(`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!i.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=i.html,this._peopleProp=[...o.content.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(w),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!!(e&&!e.hidden)}_renderMenu(){let e=this._menu(),n=this._control();if(!e||!n||!this._query)return;let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=u(t.label),a.appendChild(o),t.description){let e=r.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=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this._loading?v.searching:`${v.noMatch} “${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||t(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this._loading||this._announce(this._results.length?v.found(this._results.length):`${v.noMatch}.`)}_position(){r(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),n(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);o(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().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((e.key===`Enter`||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}}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}));return}e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();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.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=u(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(v.mentioned(t))}_replace(e,t,n,r){let i=this._control(),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&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(S);t&&(t.textContent=``,t.textContent=e)}};export{s as a,m as c,E as i,h as l,g as n,u as o,v as r,p as s,_ as t,f as u};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{f as i}from"./formatters-BAE__8ye.js";import{c as a}from"./wuiHttp-CFSgthqb.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";var s=/^[A-Za-z0-9_.:-]{1,64}$/,c=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,l=/@(\\*)\[/g;function u(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var d=e=>e.replace(l,(e,t)=>`@\\${t}[`);function f(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(c))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function p(e){let t=``,n=[];for(let r of f(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function m(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!s.test(e.id)||(i+=d(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+d(n.slice(a))}function h(e){let t=[];for(let n of f(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var g=8,_=40,v=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${i(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),y=`[data-wui-control]`,b=`[data-wui-field]`,x=`[data-wui-menu]`,S=`[data-wui-live]`,C=0,w=e=>e&&s.test(String(e.value??``))&&u(e.label)!==``;function T(e){let t=e.ownerDocument;e.id||=`wui-mention-${++C}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea 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`),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`,v.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,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 E=class extends e{static get observedAttributes(){return[`disabled`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,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),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(y)||T(this);let e=this._control(),t=this.querySelector(b)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,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._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);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()):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return m(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);if(!this._wired){this._pendingValue=t;return}t!==this.value&&this._load(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(w):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading}set loading(e){this._loading=!!e,this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(y)}_menu(){return this.querySelector(x)}_load(e){let{text:t,mentions:n}=p(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(b);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._control(),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?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();if(!t){this._close();return}this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh())}_queryAtCaret(){let e=this._control();if(!e||e.disabled||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[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=>u(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`);if(!n){this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}));return}this._fetchPeople(n,e,t)},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=await a(`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!i.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=i.html,this._peopleProp=[...o.content.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(w),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!!(e&&!e.hidden)}_renderMenu(){let e=this._menu(),n=this._control();if(!e||!n||!this._query)return;let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=u(t.label),a.appendChild(o),t.description){let e=r.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=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this._loading?v.searching:`${v.noMatch} “${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||t(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this._loading||this._announce(this._results.length?v.found(this._results.length):`${v.noMatch}.`)}_position(){r(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),n(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);o(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().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((e.key===`Enter`||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}}if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}));return}e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();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.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=u(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(v.mentioned(t))}_replace(e,t,n,r){let i=this._control(),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&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(S);t&&(t.textContent=``,t.textContent=e)}};export{s as a,m as c,E as i,h as l,g as n,u as o,v as r,p as s,_ as t,f as u};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{t as i}from"./listboxKeyNav-DMIvs9d6.js";var a=`[role="menuitem"]`,o=`data-open`,s=4,c=e=>e instanceof Element?e:e?.parentElement??null,l=e=>e.getAttribute(`aria-disabled`)===`true`,u=class extends e{constructor(){super(),this._navPanel=null,this._nav=i({getVisibleOptions:()=>this._navPanel?this._rows(this._navPanel):[],getActive:()=>this._navPanel?this._rows(this._navPanel).indexOf(document.activeElement):-1,setActive:e=>this._rows(this._navPanel)[e]?.focus({preventScroll:!0})}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onMouseOver=e=>this._handleMouseOver(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onFocusOut=e=>{let t=e.relatedTarget;this._openMenu()&&t instanceof Node&&!this.contains(t)&&this.close()},this._onPointerDown=e=>{this._openMenu()&&!this.contains(e.target)&&this.close()}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseover`,this._onMouseOver),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),document.addEventListener(`pointerdown`,this._onPointerDown,!0)}disconnectedCallback(){this._teardown()}open(e,{focus:t=null}={}){let n=this._menus().find(t=>this._triggerOf(t).dataset.key===e);n&&this._openTop(n,t)}close(e=!1){let t=this._openMenu();if(t){for(let e of this._panelOf(t).querySelectorAll(`.wui-menubar-sub > [${o}]`))this._setSub(e.parentElement,!1);this._setTop(t,!1),n(this),this._nav.teardown(),e&&this._triggerOf(t).focus({preventScroll:!0})}}_menus(){return[...this.children].filter(e=>e.classList.contains(`wui-menubar-menu`))}_triggerOf(e){return e.children[0]}_panelOf(e){return e.children[1]}_openMenu(){return this._menus().find(e=>this._panelOf(e)?.hasAttribute(o))??null}_rows(e){let t=[];for(let n of e.children){let e=n.getAttribute(`role`)===`menuitem`?n:n.classList.contains(`wui-menubar-sub`)?n.children[0]:null;e&&!l(e)&&t.push(e)}return t}_setTop(e,t){this._panelOf(e).toggleAttribute(o,t),this._triggerOf(e).setAttribute(`aria-expanded`,String(t))}_setSub(e,t){let n=e.children[1];if(!t)for(let e of n.querySelectorAll(`.wui-menubar-sub > [${o}]`))this._setSub(e.parentElement,!1);n.toggleAttribute(o,t),e.children[0].setAttribute(`aria-expanded`,String(t)),t?this._placeSub(n):(n.removeAttribute(`data-side`),n.style.removeProperty(`--wui-menubar-sub-offset`))}_openTop(e,n){let i=this._openMenu();i&&i!==e&&this.close();let a=this._triggerOf(e),o=this._panelOf(e);if(this._setTop(e,!0),r(a,o),t(this,()=>{let e=this._openMenu();e&&r(this._triggerOf(e),this._panelOf(e))}),n){let e=this._rows(o);(n===`last`?e[e.length-1]:e[0])?.focus({preventScroll:!0})}}_openSub(e,t){let n=e.parentElement;for(let t of n.children)t!==e&&t.classList.contains(`wui-menubar-sub`)&&this._setSub(t,!1);this._setSub(e,!0),t&&this._rows(e.children[1])[0]?.focus({preventScroll:!0})}_placeSub(e){e.removeAttribute(`data-side`),e.style.removeProperty(`--wui-menubar-sub-offset`),e.getBoundingClientRect().right>window.innerWidth-s&&e.setAttribute(`data-side`,`start`);let t=e.getBoundingClientRect().bottom-(window.innerHeight-s);t>0&&e.style.setProperty(`--wui-menubar-sub-offset`,`${-t}px`)}_handleFocusIn(e){let t=c(e.target)?.closest(`.wui-menubar-trigger`);if(!(!t||!this.contains(t)))for(let e of this._menus())this._triggerOf(e).tabIndex=this._triggerOf(e)===t?0:-1}_handleKeyDown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=c(e.target)?.closest(a);!t||!this.contains(t)||(t.classList.contains(`wui-menubar-trigger`)?this._barKey(e,t):this._menuKey(e,t))}_barKey(e,t){let n=this._menus(),r=n.findIndex(e=>this._triggerOf(e)===t),i=this._openMenu()!==null,a=t=>{e.preventDefault(),i&&!l(this._triggerOf(t))?this._openTop(t,`first`):this._triggerOf(t).focus({preventScroll:!0})};e.key===`ArrowRight`?a(n[(r+1)%n.length]):e.key===`ArrowLeft`?a(n[(r-1+n.length)%n.length]):e.key===`Home`?a(n[0]):e.key===`End`?a(n[n.length-1]):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!l(t)?(e.preventDefault(),this._openTop(n[r],e.key===`ArrowDown`?`first`:`last`)):e.key===`Escape`&&i&&(e.preventDefault(),e.stopPropagation(),this.close(!0))}_menuKey(e,t){let n=t.closest(`[role="menu"]`);if(!n)return;let r=n.classList.contains(`wui-menubar-subpanel`),i=t.closest(`.wui-menubar-menu`),a=this._rows(n),o=a.indexOf(t);if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),a.length&&a[(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length].focus({preventScroll:!0});else if(e.key===`ArrowRight`)e.preventDefault(),t.hasAttribute(`aria-haspopup`)?this._openSub(t.parentElement,!0):this._adjacent(i,1);else if(e.key===`ArrowLeft`)if(e.preventDefault(),r){let e=n.parentElement;this._setSub(e,!1),e.children[0].focus({preventScroll:!0})}else this._adjacent(i,-1);else if(e.key===`Escape`)if(e.preventDefault(),e.stopPropagation(),r){let e=n.parentElement;this._setSub(e,!1),e.children[0].focus({preventScroll:!0})}else this.close(!0);else e.key===`Tab`?this.close(!0):e.key===` `?(e.preventDefault(),t.click()):(this._navPanel=n,this._nav.handler(e))}_adjacent(e,t){let n=this._menus(),r=n[(n.indexOf(e)+t+n.length)%n.length];r&&r!==e&&!l(this._triggerOf(r))&&this._openTop(r,`first`)}_handleClick(e){let t=c(e.target)?.closest(a);if(!t||!this.contains(t))return;let n=e.detail===0;if(t.classList.contains(`wui-menubar-trigger`)){if(l(t))return;let e=t.parentElement;this._openMenu()===e?this.close():this._openTop(e,n?`first`:null),(!n||!this._openMenu())&&t.focus({preventScroll:!0});return}if(l(t)){e.preventDefault(),e.stopPropagation();return}if(t.hasAttribute(`aria-haspopup`)){e.preventDefault(),this._openSub(t.parentElement,n);return}let r=t.closest(`.wui-menubar-menu`),i=r?this._triggerOf(r).dataset.key:void 0;this.close(!0),this.dispatchEvent(new CustomEvent(`wui-menubar:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,menu:i??null}}))}_handleMouseOver(e){let t=c(e.target)?.closest(a);if(!t||!this.contains(t)||l(t))return;if(t.classList.contains(`wui-menubar-trigger`)){let e=t.parentElement;this._openMenu()&&this._openMenu()!==e&&(this._openTop(e,null),t.focus({preventScroll:!0}));return}t!==document.activeElement&&t.focus({preventScroll:!0});let n=t.parentElement.classList.contains(`wui-menubar-sub`)&&t.parentElement.children[0]===t?t.parentElement:null;if(n)n.children[1].hasAttribute(o)||this._openSub(n,!1);else{let e=t.closest(`[role="menu"]`);for(let t of e.children)t.classList.contains(`wui-menubar-sub`)&&this._setSub(t,!1)}}_teardown(){this.close(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseover`,this._onMouseOver),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),document.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{u as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./listboxKeyNav-DMIvs9d6.js";var a=`[role="menuitem"]`,o=`data-open`,s=4,c=e=>e instanceof Element?e:e?.parentElement??null,l=e=>e.getAttribute(`aria-disabled`)===`true`,u=class extends e{constructor(){super(),this._navPanel=null,this._nav=i({getVisibleOptions:()=>this._navPanel?this._rows(this._navPanel):[],getActive:()=>this._navPanel?this._rows(this._navPanel).indexOf(document.activeElement):-1,setActive:e=>this._rows(this._navPanel)[e]?.focus({preventScroll:!0})}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onMouseOver=e=>this._handleMouseOver(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onFocusOut=e=>{let t=e.relatedTarget;this._openMenu()&&t instanceof Node&&!this.contains(t)&&this.close()},this._onPointerDown=e=>{this._openMenu()&&!this.contains(e.target)&&this.close()}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseover`,this._onMouseOver),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),document.addEventListener(`pointerdown`,this._onPointerDown,!0)}disconnectedCallback(){this._teardown()}open(e,{focus:t=null}={}){let n=this._menus().find(t=>this._triggerOf(t).dataset.key===e);n&&this._openTop(n,t)}close(e=!1){let t=this._openMenu();if(t){for(let e of this._panelOf(t).querySelectorAll(`.wui-menubar-sub > [${o}]`))this._setSub(e.parentElement,!1);this._setTop(t,!1),n(this),this._nav.teardown(),e&&this._triggerOf(t).focus({preventScroll:!0})}}_menus(){return[...this.children].filter(e=>e.classList.contains(`wui-menubar-menu`))}_triggerOf(e){return e.children[0]}_panelOf(e){return e.children[1]}_openMenu(){return this._menus().find(e=>this._panelOf(e)?.hasAttribute(o))??null}_rows(e){let t=[];for(let n of e.children){let e=n.getAttribute(`role`)===`menuitem`?n:n.classList.contains(`wui-menubar-sub`)?n.children[0]:null;e&&!l(e)&&t.push(e)}return t}_setTop(e,t){this._panelOf(e).toggleAttribute(o,t),this._triggerOf(e).setAttribute(`aria-expanded`,String(t))}_setSub(e,t){let n=e.children[1];if(!t)for(let e of n.querySelectorAll(`.wui-menubar-sub > [${o}]`))this._setSub(e.parentElement,!1);n.toggleAttribute(o,t),e.children[0].setAttribute(`aria-expanded`,String(t)),t?this._placeSub(n):(n.removeAttribute(`data-side`),n.style.removeProperty(`--wui-menubar-sub-offset`))}_openTop(e,n){let i=this._openMenu();i&&i!==e&&this.close();let a=this._triggerOf(e),o=this._panelOf(e);if(this._setTop(e,!0),r(a,o),t(this,()=>{let e=this._openMenu();e&&r(this._triggerOf(e),this._panelOf(e))}),n){let e=this._rows(o);(n===`last`?e[e.length-1]:e[0])?.focus({preventScroll:!0})}}_openSub(e,t){let n=e.parentElement;for(let t of n.children)t!==e&&t.classList.contains(`wui-menubar-sub`)&&this._setSub(t,!1);this._setSub(e,!0),t&&this._rows(e.children[1])[0]?.focus({preventScroll:!0})}_placeSub(e){e.removeAttribute(`data-side`),e.style.removeProperty(`--wui-menubar-sub-offset`),e.getBoundingClientRect().right>window.innerWidth-s&&e.setAttribute(`data-side`,`start`);let t=e.getBoundingClientRect().bottom-(window.innerHeight-s);t>0&&e.style.setProperty(`--wui-menubar-sub-offset`,`${-t}px`)}_handleFocusIn(e){let t=c(e.target)?.closest(`.wui-menubar-trigger`);if(!(!t||!this.contains(t)))for(let e of this._menus())this._triggerOf(e).tabIndex=this._triggerOf(e)===t?0:-1}_handleKeyDown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=c(e.target)?.closest(a);!t||!this.contains(t)||(t.classList.contains(`wui-menubar-trigger`)?this._barKey(e,t):this._menuKey(e,t))}_barKey(e,t){let n=this._menus(),r=n.findIndex(e=>this._triggerOf(e)===t),i=this._openMenu()!==null,a=t=>{e.preventDefault(),i&&!l(this._triggerOf(t))?this._openTop(t,`first`):this._triggerOf(t).focus({preventScroll:!0})};e.key===`ArrowRight`?a(n[(r+1)%n.length]):e.key===`ArrowLeft`?a(n[(r-1+n.length)%n.length]):e.key===`Home`?a(n[0]):e.key===`End`?a(n[n.length-1]):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&!l(t)?(e.preventDefault(),this._openTop(n[r],e.key===`ArrowDown`?`first`:`last`)):e.key===`Escape`&&i&&(e.preventDefault(),e.stopPropagation(),this.close(!0))}_menuKey(e,t){let n=t.closest(`[role="menu"]`);if(!n)return;let r=n.classList.contains(`wui-menubar-subpanel`),i=t.closest(`.wui-menubar-menu`),a=this._rows(n),o=a.indexOf(t);if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),a.length&&a[(o+(e.key===`ArrowDown`?1:-1)+a.length)%a.length].focus({preventScroll:!0});else if(e.key===`ArrowRight`)e.preventDefault(),t.hasAttribute(`aria-haspopup`)?this._openSub(t.parentElement,!0):this._adjacent(i,1);else if(e.key===`ArrowLeft`)if(e.preventDefault(),r){let e=n.parentElement;this._setSub(e,!1),e.children[0].focus({preventScroll:!0})}else this._adjacent(i,-1);else if(e.key===`Escape`)if(e.preventDefault(),e.stopPropagation(),r){let e=n.parentElement;this._setSub(e,!1),e.children[0].focus({preventScroll:!0})}else this.close(!0);else e.key===`Tab`?this.close(!0):e.key===` `?(e.preventDefault(),t.click()):(this._navPanel=n,this._nav.handler(e))}_adjacent(e,t){let n=this._menus(),r=n[(n.indexOf(e)+t+n.length)%n.length];r&&r!==e&&!l(this._triggerOf(r))&&this._openTop(r,`first`)}_handleClick(e){let t=c(e.target)?.closest(a);if(!t||!this.contains(t))return;let n=e.detail===0;if(t.classList.contains(`wui-menubar-trigger`)){if(l(t))return;let e=t.parentElement;this._openMenu()===e?this.close():this._openTop(e,n?`first`:null),(!n||!this._openMenu())&&t.focus({preventScroll:!0});return}if(l(t)){e.preventDefault(),e.stopPropagation();return}if(t.hasAttribute(`aria-haspopup`)){e.preventDefault(),this._openSub(t.parentElement,n);return}let r=t.closest(`.wui-menubar-menu`),i=r?this._triggerOf(r).dataset.key:void 0;this.close(!0),this.dispatchEvent(new CustomEvent(`wui-menubar:select`,{bubbles:!0,detail:{key:t.dataset.key??null,item:t,menu:i??null}}))}_handleMouseOver(e){let t=c(e.target)?.closest(a);if(!t||!this.contains(t)||l(t))return;if(t.classList.contains(`wui-menubar-trigger`)){let e=t.parentElement;this._openMenu()&&this._openMenu()!==e&&(this._openTop(e,null),t.focus({preventScroll:!0}));return}t!==document.activeElement&&t.focus({preventScroll:!0});let n=t.parentElement.classList.contains(`wui-menubar-sub`)&&t.parentElement.children[0]===t?t.parentElement:null;if(n)n.children[1].hasAttribute(o)||this._openSub(n,!1);else{let e=t.closest(`[role="menu"]`);for(let t of e.children)t.classList.contains(`wui-menubar-sub`)&&this._setSub(t,!1)}}_teardown(){this.close(),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseover`,this._onMouseOver),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),document.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{u as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o,t as s}from"./focusOrigin-2imUSs-u.js";import{n as c}from"./formMirror-BgY7zkC3.js";import{n as l,t as u}from"./listboxKeyNav-DMIvs9d6.js";import{a as d,i as f,n as p,r as m,t as h}from"./optionLabel-Bd3vP-XI.js";import{i as g,t as _}from"./tokenCommit-BKckxgtg.js";var v=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],c(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[h]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of b){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?f(t):d(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?m(t):p(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),o=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;c(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let s=`${this.id}-listbox`;this._listboxId=s;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{n as i}from"./devWarn-DXdRWZs3.js";import{t as a}from"./iconGlyphs.g-Bk8AzmSO.js";import{n as o,t as s}from"./focusOrigin-2imUSs-u.js";import{n as c}from"./formMirror-BgY7zkC3.js";import{n as l,t as u}from"./listboxKeyNav-DMIvs9d6.js";import{a as d,i as f,n as p,r as m,t as h}from"./optionLabel-Bd3vP-XI.js";import{i as g,t as _}from"./tokenCommit-BKckxgtg.js";var v=class extends e{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered){if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render();return}this._bindGlobal?.()}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){if(e===`aria-invalid`){this._syncInvalid();return}e===`custom-pattern`||e===`custom-invalid-message`||this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],c(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){if(this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom){this._renderControl(),this._renderOptions(this._query());return}this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[h]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of b){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?f(t):d(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?m(t):p(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),o=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;c(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let s=`${this.id}-listbox`;this._listboxId=s;let l=this.hasAttribute(`disabled`);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
2
2
  <div class="search-select${o}">
3
3
  <div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${l?` aria-disabled="true"`:``}>
4
4
  ${r?a(r,{className:`search-select-icon`}):``}
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{c as t}from"./wuiHttp-27mq9Jpn.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-pYmoU0g6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{c as t}from"./wuiHttp-CFSgthqb.js";import{c as n,i as r,n as i,s as a}from"./notificationDays-pYmoU0g6.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f})`).length}_click(e){let t=e.target.closest?.(`${o}, ${u}, ${d}`);if(!(!t||!this.contains(t))){if(t.matches(o)){this.toggle();return}this.hasAttribute(`controlled`)||(t.matches(u)?this._markAll():this._markItem(t))}}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)];if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),this._unread=Math.max(0,this._unread-1),this._render(),this._say(n(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let n=e.map(e=>e.dataset.id).filter(Boolean),r=this.getAttribute(`read-action`);if(r){this._setBusy(!0);let e=new URLSearchParams;for(let t of n)e.append(`ids`,t);let a=await t(r,{method:`POST`,body:e});if(this._setBusy(!1),!a.ok){if(a.kind===`session`||a.kind===`aborted`)return;let e=a.message||i.failed[a.kind]||i.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:a.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(i.allRead),this._emitRead(n,!0)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=r(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,a(this.getAttribute(`label`)||i.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{m as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";var i=`data-wui-overflow-hidden`,a=`[aria-selected="true"], .active`,o=`.chip-body, input, a[href], button:not(.chip-remove)`,s=1,c=0,l=e=>Number.parseFloat(e)||0,u=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent.trim();e&&n.push(e)}else t.nodeType===1&&!t.matches(`svg, img, [aria-hidden='true']`)&&r(t)};return r(e),n.join(` `)},d=e=>e.matches(`button, a[href], label, input`)?e:e.querySelector(o),f=class extends e{constructor(){super(),this._more=null,this._menu=null,this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!this.contains(e.target)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,n(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){this._more&&(this._more.firstChild.textContent=this._label())}_label(){return this.getAttribute(`label`)||`More`}_list(){return this.querySelector(`[data-wui-overflow-list]`)}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++c}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();!this._mo||e===this._observedList||(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(i);this._more.hidden=!0;let n=this.clientWidth,r=[];if(n>0&&t.length){let i=getComputedStyle(e),o=l(i.columnGap),c=l(i.paddingLeft)+l(i.paddingRight)+l(i.borderLeftWidth)+l(i.borderRightWidth),u=t.map(e=>e.offsetWidth);if(u.reduce((e,t)=>e+t,0)+o*(t.length-1)>n-c+s){this._more.hidden=!1;let e=n-c-this._more.offsetWidth-l(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):a,s=new Set(i?t.filter(e=>e.matches(i)):[]),d=0,f=0;for(let e of s)d+=u[t.indexOf(e)]+(f?o:0),f+=1;for(let n=0;n<t.length;n+=1){if(s.has(t[n]))continue;let r=d+u[n]+(f?o:0);if(r>e)break;s.add(t[n]),d=r,f+=1}r=t.filter(e=>!s.has(e))}}for(let e of r)e.setAttribute(i,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let o=r.map(e=>t.indexOf(e)).join(`,`);o!==this._hiddenKey&&(this._hiddenKey=o,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(i)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=d(t),i=!r||r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=u(t),e.addEventListener(`click`,()=>{i||this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=!e.hasAttribute(i)&&e.matches(`button, a[href]`)?e:this._more;n.hidden||n.focus()}_open(e){let n=this._hiddenItems();if(!n.length)return;this._fill(n),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>r(this._more,this._menu);i(),t(this,i),e&&this._menu.firstElementChild?.focus()}_close(e){!this._menu||this._menu.hidden||(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),n(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children],n=t.indexOf(this.ownerDocument.activeElement),r=null;if(e.key===`ArrowDown`)r=t[(n+1)%t.length];else if(e.key===`ArrowUp`)r=t[(n-1+t.length)%t.length];else if(e.key===`Home`)r=t[0];else if(e.key===`End`)r=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),r?.focus()}};export{f as t};
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";var i=`data-wui-overflow-hidden`,a=`[aria-selected="true"], .active`,o=`.chip-body, input, a[href], button:not(.chip-remove)`,s=1,c=0,l=e=>Number.parseFloat(e)||0,u=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent.trim();e&&n.push(e)}else t.nodeType===1&&!t.matches(`svg, img, [aria-hidden='true']`)&&r(t)};return r(e),n.join(` `)},d=e=>e.matches(`button, a[href], label, input`)?e:e.querySelector(o),f=class extends e{constructor(){super(),this._more=null,this._menu=null,this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!this.contains(e.target)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,n(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){this._more&&(this._more.firstChild.textContent=this._label())}_label(){return this.getAttribute(`label`)||`More`}_list(){return this.querySelector(`[data-wui-overflow-list]`)}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++c}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();!this._mo||e===this._observedList||(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(i);this._more.hidden=!0;let n=this.clientWidth,r=[];if(n>0&&t.length){let i=getComputedStyle(e),o=l(i.columnGap),c=l(i.paddingLeft)+l(i.paddingRight)+l(i.borderLeftWidth)+l(i.borderRightWidth),u=t.map(e=>e.offsetWidth);if(u.reduce((e,t)=>e+t,0)+o*(t.length-1)>n-c+s){this._more.hidden=!1;let e=n-c-this._more.offsetWidth-l(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):a,s=new Set(i?t.filter(e=>e.matches(i)):[]),d=0,f=0;for(let e of s)d+=u[t.indexOf(e)]+(f?o:0),f+=1;for(let n=0;n<t.length;n+=1){if(s.has(t[n]))continue;let r=d+u[n]+(f?o:0);if(r>e)break;s.add(t[n]),d=r,f+=1}r=t.filter(e=>!s.has(e))}}for(let e of r)e.setAttribute(i,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let o=r.map(e=>t.indexOf(e)).join(`,`);o!==this._hiddenKey&&(this._hiddenKey=o,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(i)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=d(t),i=!r||r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=u(t),e.addEventListener(`click`,()=>{i||this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=!e.hasAttribute(i)&&e.matches(`button, a[href]`)?e:this._more;n.hidden||n.focus()}_open(e){let n=this._hiddenItems();if(!n.length)return;this._fill(n),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>r(this._more,this._menu);i(),t(this,i),e&&this._menu.firstElementChild?.focus()}_close(e){!this._menu||this._menu.hidden||(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),n(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children],n=t.indexOf(this.ownerDocument.activeElement),r=null;if(e.key===`ArrowDown`)r=t[(n+1)%t.length];else if(e.key===`ArrowUp`)r=t[(n-1+t.length)%t.length];else if(e.key===`Home`)r=t[0];else if(e.key===`End`)r=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),r?.focus()}};export{f as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-HAWsGzlr.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";import{n as s,t as c}from"./countries-CvmZ2xpG.js";var l={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:`America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:`Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:`America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},u=new Set(c.map(([e])=>e)),d=new Map;for(let[e,t]of Object.entries(l))for(let n of t)d.set(n,e);function f(e){let t=d.get(e);return t&&u.has(t)?t:null}function p(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&u.has(t)?t:null}function m(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return f(e)||p(t)||null}function h(){return Promise.all([import(`./max-CNrKnpEj.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>g(e,t.default||t))}function g(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var _=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,v=e=>e?`+${s(e)}`:``,y=null,b=null;function x(){return y?Promise.resolve(y):(b||=h().then(e=>(y=e,y)).catch(()=>null),b)}function S(e,t){let n=`+${s(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function C(e,t){if(!y||!t||!e)return t;try{return S(e,new y.AsYouType(e).input(`+${s(e)}${t}`))||t}catch{return t}}function w(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function T(e){if(!y||!e)return null;try{return S(e,y.getExampleNumber(e,y.examples)?.formatInternational())||null}catch{return null}}function E(e){let t=T(e);return t?`For example ${t}`:null}function D(e){if(!y||!e)return null;try{if(!y.isValidPhoneNumber(e))return!1;let t=y.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function O(e){if(!y||!e)return null;try{let t=y.getExampleNumber(e,y.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function k(e,t,n){try{let r=y.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function A(e){if(!y||!e?.trim().startsWith(`+`))return null;try{let t=new y.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}var j=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`placeholder`,`disabled`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=m()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n));return}if(e===`aria-describedby`){this._syncDescribedBy();return}e===`country`&&(this._country=n||this._defaultCountry,this._suppressCountryRender)||this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get value(){return this._national&&this._country?`+${s(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim(),n=A(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(s(this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){a(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||E(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t,this.innerHTML=`
1
+ import{t as e}from"./elementBase-BlsR4tqa.js";import{n as t,r as n,t as r}from"./anchorOverlay-D8di0B-z.js";import{t as i}from"./iconGlyphs.g-Bk8AzmSO.js";import{t as a}from"./formMirror-BgY7zkC3.js";import{n as o}from"./listboxKeyNav-DMIvs9d6.js";import{n as s,t as c}from"./countries-CvmZ2xpG.js";var l={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:`America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:`Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:`America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},u=new Set(c.map(([e])=>e)),d=new Map;for(let[e,t]of Object.entries(l))for(let n of t)d.set(n,e);function f(e){let t=d.get(e);return t&&u.has(t)?t:null}function p(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&u.has(t)?t:null}function m(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return f(e)||p(t)||null}function h(){return Promise.all([import(`./max-CNrKnpEj.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>g(e,t.default||t))}function g(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var _=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,v=e=>e?`+${s(e)}`:``,y=null,b=null;function x(){return y?Promise.resolve(y):(b||=h().then(e=>(y=e,y)).catch(()=>null),b)}function S(e,t){let n=`+${s(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function C(e,t){if(!y||!t||!e)return t;try{return S(e,new y.AsYouType(e).input(`+${s(e)}${t}`))||t}catch{return t}}function w(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function T(e){if(!y||!e)return null;try{return S(e,y.getExampleNumber(e,y.examples)?.formatInternational())||null}catch{return null}}function E(e){let t=T(e);return t?`For example ${t}`:null}function D(e){if(!y||!e)return null;try{if(!y.isValidPhoneNumber(e))return!1;let t=y.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function O(e){if(!y||!e)return null;try{let t=y.getExampleNumber(e,y.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function k(e,t,n){try{let r=y.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function A(e){if(!y||!e?.trim().startsWith(`+`))return null;try{let t=new y.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}var j=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`placeholder`,`disabled`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=m()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){if(!this._rendered){this.render();return}this._bindGlobal?.()}attributeChangedCallback(e,t,n){if(e===`value`){this.value=n;return}if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n));return}if(e===`aria-describedby`){this._syncDescribedBy();return}e===`country`&&(this._country=n||this._defaultCountry,this._suppressCountryRender)||this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get value(){return this._national&&this._country?`+${s(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim(),n=A(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(s(this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){a(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||E(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t,this.innerHTML=`
2
2
  <div class="phone-input-wrap">
3
3
  <div class="phone-country-adornment">
4
4
  <button type="button" class="country-toggle" aria-label="Choose country" aria-haspopup="listbox" aria-expanded="false" aria-controls="${M(t)}"${this.hasAttribute(`disabled`)?` disabled`:``}>