@webority/ui-elements 0.177.0 → 0.178.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/WuiInlineEdit-D7AuEv1R.js +1 -0
  2. package/dist/{WuiSavedViews-BKpnSd-Y.js → WuiSavedViews-BR6ZHd9Y.js} +1 -1
  3. package/dist/{WuiSelect-iUXaHKw5.js → WuiSelect-CNff3FNi.js} +1 -1
  4. package/dist/{chips-xXgAvIFy.js → chips-BdpsN50B.js} +1 -1
  5. package/dist/{drawerDiscard-z1PsI4cx.js → drawerDiscard-APy8TZxi.js} +1 -1
  6. package/dist/elements/inline-edit.js +1 -1
  7. package/dist/elements/saved-views.js +1 -1
  8. package/dist/elements/select.js +1 -1
  9. package/dist/{fileViewerPdf-Tb26qdtM.js → fileViewerPdf-BET_tiP6.js} +1 -1
  10. package/dist/inlineEdit.g-DLDVospu.js +1 -0
  11. package/dist/loader-A38-PdcB.js +1 -0
  12. package/dist/{search-Bhn-bjLL.js → search-Dl07KqWw.js} +1 -1
  13. package/dist/server.js +1 -1
  14. package/dist/text.js +1 -1
  15. package/dist/ui-elements/carousel.global.js +1 -1
  16. package/dist/ui-elements/code-block.global.js +1 -1
  17. package/dist/ui-elements/command-palette.global.js +1 -1
  18. package/dist/ui-elements/comment-thread.global.js +1 -1
  19. package/dist/ui-elements/consent-banner.global.js +1 -1
  20. package/dist/ui-elements/context-menu.global.js +1 -1
  21. package/dist/ui-elements/data-table.global.js +1 -0
  22. package/dist/ui-elements/date-range.global.js +1 -1
  23. package/dist/ui-elements/date-time.global.js +1 -1
  24. package/dist/ui-elements/datepicker.global.js +1 -1
  25. package/dist/ui-elements/dock.global.js +1 -0
  26. package/dist/ui-elements/drawer.global.js +1 -1
  27. package/dist/ui-elements/dropdown.global.js +1 -1
  28. package/dist/ui-elements/entry-grid.global.js +1 -1
  29. package/dist/ui-elements/gantt.global.js +1 -1
  30. package/dist/ui-elements/glyphs.global.js +1 -1
  31. package/dist/ui-elements/hover-card.global.js +1 -0
  32. package/dist/ui-elements/image-crop.global.js +1 -1
  33. package/dist/ui-elements/inline-edit.global.js +1 -1
  34. package/dist/ui-elements/kanban.global.js +1 -1
  35. package/dist/ui-elements/lead-popup.global.js +1 -1
  36. package/dist/ui-elements/lightbox.global.js +1 -1
  37. package/dist/ui-elements/markdown.global.js +1 -1
  38. package/dist/ui-elements/navigation-menu.global.js +1 -0
  39. package/dist/ui-elements/notification-center.global.js +1 -0
  40. package/dist/ui-elements/onboarding-checklist.global.js +1 -0
  41. package/dist/ui-elements/org-tree.global.js +1 -1
  42. package/dist/ui-elements/otp.global.js +1 -0
  43. package/dist/ui-elements/overflow.global.js +1 -0
  44. package/dist/ui-elements/phone.global.js +1 -1
  45. package/dist/ui-elements/popover.global.js +1 -1
  46. package/dist/ui-elements/rating.global.js +1 -0
  47. package/dist/ui-elements/record-pager.global.js +1 -0
  48. package/dist/ui-elements/relative-time.global.js +1 -0
  49. package/dist/ui-elements/saved-views.global.js +1 -1
  50. package/dist/ui-elements/select-chips.global.js +1 -1
  51. package/dist/ui-elements/select-recents.global.js +1 -1
  52. package/dist/ui-elements/select-search.global.js +1 -1
  53. package/dist/ui-elements/select-window.global.js +1 -1
  54. package/dist/ui-elements/shortcuts.global.js +1 -0
  55. package/dist/ui-elements/show-more.global.js +1 -0
  56. package/dist/ui-elements/slider.global.js +1 -1
  57. package/dist/ui-elements/sortable.global.js +1 -1
  58. package/dist/ui-elements/status-icon.global.js +1 -1
  59. package/dist/ui-elements/table-export.global.js +1 -1
  60. package/dist/ui-elements/timepicker.global.js +1 -1
  61. package/dist/ui-elements/tour.global.js +1 -1
  62. package/dist/ui-elements/tree-picker.global.js +1 -1
  63. package/dist/ui-elements/tree.global.js +1 -1
  64. package/dist/ui-elements/truncate.global.js +1 -0
  65. package/dist/ui-elements/whats-new.global.js +1 -0
  66. package/dist/ui-elements/wizard.global.js +1 -1
  67. package/dist/ui-elements.global.js +1 -1
  68. package/dist/ui-elements.js +1 -1
  69. package/dist/ui-file-viewer.global.js +1 -1
  70. package/dist/ui-file-viewer.js +1 -1
  71. package/package.json +5 -5
  72. package/types/WuiInlineEdit.d.ts +10 -0
  73. package/types/global/core.d.ts +1 -17
  74. package/types/global/shared.d.ts +6 -0
  75. package/types/razor-js/modules/lazyModules.d.ts +22 -0
  76. package/types/razor-js/modules/themeCopy.d.ts +1 -0
  77. package/types/razor-js/webority-ui.d.ts +2 -2
  78. package/dist/WuiInlineEdit-p0cm_i90.js +0 -1
  79. package/dist/inlineEdit.g-ZxRNYq0t.js +0 -1
  80. package/dist/loader-DvNLnnaO.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e}from"./calendarMath-CT99RyhR.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DTW53DjY.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s,t as c}from"./inlineEditText-DRBhMnam.js";import{m as l}from"./wuiHttp-Cw7V8u2w.js";import{r as u,t as d}from"./textStore-DBplASiZ.js";import{n as f,t as p}from"./inlineEdit.g-DLDVospu.js";import{t as m}from"./httpFailure.g-DjZzGxPj.js";var h=()=>u(`inlineEdit`,p),g=()=>u(`asyncBlock`,f),_=e=>typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`&&`label`in e&&typeof e.label==`string`;async function v(e){let t=await l(new URL(e,window.location.href).href,{headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Loading options answered ${t.kind}.`);let n=JSON.parse(t.html),r=Array.isArray(n)?n:[];if(!Array.isArray(n)||!r.every(_))throw Error(`Options must be a JSON array of { value, label } strings.`);return r.filter(_)}var y=e=>s.some(t=>t===e),b=`[data-wui-display]`,x=`[data-wui-value]`,S=`[data-wui-editor]`,C=`[data-wui-control]`,w=`[data-wui-error]`,T=`[data-wui-live]`,E=`[aria-expanded="true"]`,D=/* @__PURE__ */ new Set([`select`,`date`]),O=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:h().serverMessage},k=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,A=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},j=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;_optionsLoaded;_optionsLoading;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._optionsLoaded=!1,this._optionsLoading=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._grouping(),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??void 0),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=A(this,b),t=A(this,S),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._needsLoad()&&this._loadOptions(),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_needsLoad(){return this._type()===`select`&&this.hasAttribute(`load-url`)&&!this._optionsLoaded}_loadOptions(){let e=this.getAttribute(`load-url`),t=this._control();e&&t&&this._optionsLoading===null&&(this._setError(null),t.setAttribute(`disabled`,``),this.setAttribute(`aria-busy`,`true`),Object.assign(t,{options:[{value:``,label:g().loadingLabel}]}),this._optionsLoading=v(e).then(e=>{this._optionsLoading=null,this._optionsLoaded=!0,this._showRows(t,e)},()=>{this._optionsLoading=null,this._showLoadError()}))}_showRows(e,t){this.removeAttribute(`aria-busy`),e.removeAttribute(`disabled`),Object.assign(e,{options:t}),e.value=this._draft??this._value(),this._editing&&this._focusControl(e)}_showLoadError(){this.removeAttribute(`aria-busy`);let e=A(this,w);if(!e)return;let t=g(),n=document.createElement(`button`);n.type=`button`,n.setAttribute(`data-wui-retry`,``),n.textContent=t.retryLabel,n.addEventListener(`click`,()=>this._loadOptions()),e.replaceChildren(`${t.errorTitle} `,n),e.hidden=!1,this._announce(t.errorTitle)}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(b)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(S)?.querySelector(E))}_onKeyDown(e){if(!this._editing){(o(e)||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`||D.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 instanceof Node?e.relatedTarget:null;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||!D.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;if(this._optionsLoading!==null){this.cancel();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 i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(h().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(h().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:O(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:h().forbiddenMessage,networkCheck:u(`httpFailure`,m).networkCheckText,client:h().clientMessage,validation:h().validationMessage,server:h().serverMessage,network:h().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||h().serverMessage}}_close(){let e=A(this,b),t=A(this,S),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),A(t,E)?.click(),n&&e?.focus()}_focusControl(e){if(!D.has(this._type())){e.focus(),e.select?.();return}let t=A(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(x);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(x);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(x);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=A(this,w),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??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(T);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(C);return k(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return y(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{j as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{m as i}from"./wuiHttp-Cw7V8u2w.js";import{r as a,t as o}from"./textStore-DBplASiZ.js";import{t as s}from"./savedViews.g-CzzEliTR.js";var c=`wui-saved-views:`,l=20,u=0,d=()=>a(`savedViews`,s),f=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,p=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,l)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,a=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:a}):s={method:`POST`,body:new URLSearchParams({intent:e,key:a,...t})},this._busy=!0,this._render();let c=await i(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=r(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(f),this._error=null,this._render(),!0}return this._error=c.message||d().viewsNotUpdatedMessage,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=d().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control form-control-sm`,a.setAttribute(`aria-label`,d().viewNameLabel),a.placeholder=d().nameViewPlaceholder;let o=n.createElement(`button`);o.type=`submit`,o.className=e(`primary`,`solid`,`sm`),o.dataset.wui=t,o.textContent=d().saveViewLabel;let s=n.createElement(`form`);s.className=`d-flex gap-2 px-3 py-2`,s.append(a,o),s.addEventListener(`submit`,this._onSubmit);let c=n.createElement(`input`);c.type=`checkbox`,c.className=`form-check-input`,c.setAttribute(`role`,`switch`),c.id=`wui-saved-views-share-${u++}`;let l=n.createElement(`label`);l.className=`form-check-label`,l.htmlFor=c.id,l.textContent=d().shareTeamLabel;let f=n.createElement(`div`);f.className=`form-check form-switch mb-0`,f.append(c,l);let p=n.createElement(`div`);p.className=`px-3 pb-2`,p.hidden=!0,p.append(f),this._dom={menu:r,divider:i,form:s,input:a,save:o,shareRow:p,share:c},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=d().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=d().deleteLabel,i.setAttribute(`aria-label`,o(d().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:c+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(f).slice(0,l):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{p as t};
1
+ import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{m as i}from"./wuiHttp-Cw7V8u2w.js";import{r as a,t as o}from"./textStore-DBplASiZ.js";import{t as s}from"./savedViews.g-CzzEliTR.js";var c=`wui-saved-views:`,l=20,u=0,d=()=>a(`savedViews`,s),f=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,p=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,l)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,a=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:a}):s={method:`POST`,body:new URLSearchParams({intent:e,key:a,...t})},this._busy=!0,this._render();let c=await i(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=r(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(f),this._error=null,this._render(),!0}return this._error=c.message||d().viewsNotUpdatedMessage,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=d().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control wui-input-sm`,a.setAttribute(`aria-label`,d().viewNameLabel),a.placeholder=d().nameViewPlaceholder;let o=n.createElement(`button`);o.type=`submit`,o.className=e(`primary`,`solid`,`sm`),o.dataset.wui=t,o.textContent=d().saveViewLabel;let s=n.createElement(`form`);s.className=`d-flex gap-2 px-3 py-2`,s.append(a,o),s.addEventListener(`submit`,this._onSubmit);let c=n.createElement(`input`);c.type=`checkbox`,c.className=`form-check-input`,c.setAttribute(`role`,`switch`),c.id=`wui-saved-views-share-${u++}`;let l=n.createElement(`label`);l.className=`form-check-label`,l.htmlFor=c.id,l.textContent=d().shareTeamLabel;let f=n.createElement(`div`);f.className=`form-check form-switch mb-0`,f.append(c,l);let p=n.createElement(`div`);p.className=`px-3 pb-2`,p.hidden=!0,p.append(f),this._dom={menu:r,divider:i,form:s,input:a,save:o,shareRow:p,share:c},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=d().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=d().deleteLabel,i.setAttribute(`aria-label`,o(d().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:c+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(f).slice(0,l):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{p as t};
@@ -1 +1 @@
1
- import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-DvNLnnaO.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-xXgAvIFy.js`),search:()=>import(`./search-Bhn-bjLL.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},De)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Oe)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=Z(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:Te(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Z(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Z(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Z(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`input wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`input wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":X().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?X().countrySearchPlaceholder:xe().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":xe().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Ae()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>ke}_visible(){let e=this._refs();return e.list?Re(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?ee(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?te(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:$(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&U(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?ne(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=Le(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=Le(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._windowed&&this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Fe(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},we=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
1
+ import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-A38-PdcB.js";import{t as d}from"./iconGlyphs.g-a9FtjPXh.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-wbpl8OTJ.js";import{r as x}from"./textStore-DBplASiZ.js";import{n as S,r as C,t as w}from"./search.g-B5d1s59A.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,hintText:l=k().hintText,actionRow:u=[],recents:d=null}=n,f=new Set(r.map(String)),p=A(t,a),m=e.id,h=u.filter(e=>e.position===`top`),g=u.filter(e=>e.position===`bottom`),_=d?.options.length?d.options:[],v=h.length+_.length+p.length+g.length,y=p.length>300,b=P,x=y&&b!==void 0,S=e=>x?{index:e,size:v}:void 0,C=0,w=e=>{let t=C++;return i(`button`,{type:`button`,role:`option`,id:R(m,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(S(t))},e.label)},T=e=>{let t=C++;return V(e,R(m,t),f.has(String(e.value)),S(t))},E=h.map(w),D=_.length&&d?[i(`div`,{class:`wui-select-group`},d.label),..._.map(T),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],O=C,F=[];if(x)C+=p.length;else{let e=``;for(let t of p)t.group&&t.group!==e&&F.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,F.push(T(t))}let I=g.map(w),L=[];if(o===`loading`?L=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),c)]:o===`hint`?L=[i(`div`,{class:`wui-select-hint`},l)]:(o===`empty`||p.length===0&&u.length===0)&&(L=[i(`div`,{class:`wui-select-empty`},s)]),x&&b){let n=[...E,...D],r=[...I,...L];return b.render(e,{options:t,query:a,rows:p,pre:n,post:r,preSig:N(n),postSig:N(r),picked:f,top:h,recent:_,bottom:g,bodyBase:O,total:v}),{rows:v,windowed:!0,long:y}}b?.clear(e);let z=[...E,...D,...F,...I,...L],B=N(z);return j.get(e)===B||(j.set(e,B),e.replaceChildren(...z)),{rows:C,windowed:!1,long:y}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function ee(e,t){return P?P.reveal(e,t):z(e)[t]??null}function te(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function ne(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function V(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,ie={recents:()=>import(`./recents-B9efQ1Au.js`),chips:()=>import(`./chips-BdpsN50B.js`),search:()=>import(`./search-Dl07KqWw.js`),country:()=>import(`./country-T7AfpJpN.js`)};function ae(e){let t=T(ie,e)?ie[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var U=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),oe=300,W=`<div class="wui-select-spacer" aria-hidden="true"></div>`,G=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),K=/* @__PURE__ */ new WeakMap;function se(e,t,n,r){let i=K.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=[],o=new Int32Array(r.length),s=``;r.forEach((e,t)=>{e.group&&e.group!==s&&a.push({kind:`group`,label:e.group}),s=e.group??``,o[t]=a.length,a.push({kind:`option`,option:e,ord:t})});let c={options:t,query:n,count:r.length,entries:a,optionEntry:o,heights:O(a.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};return K.set(e,c),e.scrollTop=0,c}var q=e=>e.clientHeight||oe,J=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:q(e)});function ce(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(V(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function le(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function ue(e,t){let{start:n,end:r}=J(e,t);t.start=n,t.end=r;let i=ce(t,e.id,n,r),a=t.preSig+W+N(i)+W+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,G(),...i,G(),...t.post)),le(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function de(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function Y(e,t){ue(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=de(e,t);if(!n)return;le(e,t),r&&(e.scrollTop+=r),ue(e,t)}}function fe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),Y(e,n)}function pe(e){let t=K.get(e);if(!t)return!1;let{start:n,end:r}=J(e,t);return n===t.start&&r===t.end?!1:(Y(e,t),!0)}function me(e,t){let n=K.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:q(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;Y(e,n)}return a()}function he(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var ge=e=>e&&!(`position`in e)?e:void 0;function _e(e,t){let n=K.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=ge(he(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ve=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function ye(e,t){let n=K.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=he(n,e);if(r&&ve(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:fe,refresh:pe,reveal:me,indexOfValue:_e,indexByPrefix:ye,clear(e){K.delete(e)}});function be(){return Promise.resolve()}var X=()=>x(`select`,C),xe=()=>x(`search`,w),Se=()=>x(`field`,S),Ce=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},De)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Oe)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`value`?(this._value=Z(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Z(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Me.has(e)?this._rendered&&(this._drawValue(),this.renderList()):je.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:Te(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Ee.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Ee.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Z(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||X().emptyText,searchingText:this.getAttribute(`searching-text`)||X().searchingText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Z(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Z(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`input wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`input wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":X().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?X().countrySearchPlaceholder:xe().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":xe().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||X().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??$(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Ne){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Ae()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Se().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=Q(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=Q(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:Q(this,`.wui-select-control`,HTMLElement),value:Q(this,`.wui-select-value`,HTMLElement),menu:Q(this,`.wui-select-menu`,HTMLElement),list:Q(this,`.wui-select-options`,HTMLElement),search:Q(this,`.wui-select-search input`,HTMLInputElement),input:Q(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=Q(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>ke}_visible(){let e=this._refs();return e.list?Re(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?ee(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1})}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?te(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:$(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&U(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r(Q(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=Q(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=Q(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?ne(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=Le(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=Le(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._windowed&&this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null}_dropMenu(){let e=Q(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Fe(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>ze(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=be().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(X().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=we(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},we=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},Te=e=>re.includes(e),Ee=[`comfortable`,`compact`],De=150,Oe=250,ke=10,Ae=()=>{let e=X();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},je=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Me=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Ne=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Z=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Pe=(e,t)=>t===`multiple`?U(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?U(e)?[`chips`,`search`]:[`chips`]:[],Fe=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Pe(e,t)]:Pe(e,t),Ie=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,Le=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},Q=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Re=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),$=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},ze=(e,t)=>ae(t).then(e=>{if(!Ie(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(X().partLoadMessage),null));export{U as n,A as r,Ce as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./dom-DMQu--xV.js";import{n as t,t as n}from"./fieldState-D-zQcXUS.js";import{t as r}from"./iconGlyphs.g-a9FtjPXh.js";import{n as i}from"./imeSafeEnter-DeO_3lXy.js";import{s as a}from"./nativeOverlay-BHD2QV02.js";import{n as o,r as s,t as c}from"./optionLabel-wbpl8OTJ.js";import{r as l,t as u}from"./textStore-DBplASiZ.js";import{r as d}from"./search.g-B5d1s59A.js";import{t as ee}from"./customRule-BpwcjVLb.js";import{r as f}from"./WuiSelect-iUXaHKw5.js";var p={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},m={enter:`
1
+ import{r as e}from"./dom-DMQu--xV.js";import{n as t,t as n}from"./fieldState-D-zQcXUS.js";import{t as r}from"./iconGlyphs.g-a9FtjPXh.js";import{n as i}from"./imeSafeEnter-DeO_3lXy.js";import{s as a}from"./nativeOverlay-BHD2QV02.js";import{n as o,r as s,t as c}from"./optionLabel-wbpl8OTJ.js";import{r as l,t as u}from"./textStore-DBplASiZ.js";import{r as d}from"./search.g-B5d1s59A.js";import{t as ee}from"./customRule-BpwcjVLb.js";import{r as f}from"./WuiSelect-CNff3FNi.js";var p={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},m={enter:`
2
2
  `,comma:`,`,space:` `,tab:` `},te=e=>p[e],h=e=>m[e];function ne(e,t){let n=[String(e??``)];for(let e of t)n=n.flatMap(t=>t.split(e));return n.map(e=>e.trim()).filter(Boolean)}var re=(e,t)=>t.some(t=>String(e??``).includes(t)),g=()=>l(`select`,d),_=/* @__PURE__ */ new WeakMap;function v(e,t){if(e===null)throw TypeError(`The chip row needs ${t}, and it is not mounted.`);return e}function y(){let l,d,p=null,m=null,y=null,b=null,x=null,S=null,C=null,w=!1,T=()=>v(m,`the draft input`),E=()=>l.mode===`tag`,D=()=>Array.isArray(l.value)?l.value.slice():[],O=()=>(l.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),ie=()=>new Set(O().map(te).filter(Boolean)),k=()=>{let e=parseInt(l.getAttribute(`max-tags`)??``,10)||0;return Math.max(e,0)},A=()=>{let e=k();return e>0&&D().length>=e},j=(e,t)=>!l.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),M=()=>{let e=_.get(l);return e||(e=/* @__PURE__ */ new Map,_.set(l,e)),e},N=e=>(l.options||[]).find(t=>String(t.value)===String(e))??M().get(String(e)),P=e=>{let t=M();for(let n of l.options||[])e.includes(String(n.value))&&t.set(String(n.value),n);for(let n of t.keys())e.includes(n)||t.delete(n)},F=e=>{let t=e.trim().toLowerCase();return(l.options||[]).find(e=>String(e.value??``).toLowerCase()===t||o(e).trim().toLowerCase()===t)},ae=e=>{for(let t of O()){let n=h(t)??t;if(re(e,[n]))return ne(e,[n])}return[e.trim()]},I=()=>m?m.value:l._query||``,oe=()=>E()||l.hasAttribute(`allow-custom`),se=()=>l.getAttribute(`placeholder`)||(E()?g().tagPlaceholder:g().placeholder),ce=()=>{let e=l.getAttribute(`aria-label`);if(e)return e;let t=l.closest(`label`)?.textContent?.trim();if(t)return t;let n=l.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e instanceof HTMLLabelElement&&e.htmlFor===n):void 0)?.textContent?.trim()||(E()?g().addTagsLabel:g().fallbackName)},L=()=>{m&&(m.setAttribute(`aria-expanded`,String(a(d.menu))),d.list.id&&m.setAttribute(`aria-controls`,d.list.id),m.setAttribute(`aria-label`,ce()))},le=()=>!t(l)&&!l.hasAttribute(`loading`),ue=e=>{w=!0,T().setAttribute(`aria-invalid`,`true`),l.setError(e)},R=()=>{w&&(w=!1,T().removeAttribute(`aria-invalid`),l.setError(null))},z=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=D(),i=r.slice(),a=k(),o=[],s=``,c=!1;for(let t of e){let e=(n?t.trim().replace(/,+$/,``):t).trim();if(!e)continue;if(a&&i.length>=a)break;let r=F(e);if(r){if(r.disabled){o.push(e),s||=r.disabledHint||l.getAttribute(`invalid-message`)||g().invalidMessage;continue}j(i,String(r.value))||i.push(String(r.value));continue}let u=ee(l,e);u?(o.push(e),s||=u):j(i,e)||(i.push(e),c=!0)}i.length!==r.length&&(c?l.commit(i,{isCustom:!0}):l.commit(i)),T().value=o.join(`, `),s?t||ue(s):R()},B=e=>{n(l)||z([T().value],e)},V=e=>l.commit(D().filter(t=>t!==e)),H=()=>e(`span`,{class:`wui-select-placeholder`},l.getAttribute(`placeholder`)||g().placeholder),de=t=>{let n=N(t),i=e(`span`,{class:`chip chip-sm`}),a=e(`span`,{class:`chip-label`});if(a.replaceChildren(...n?c(n):[t]),i.append(a),le()){let a=n?o(n):s(t),c=e(`button`,{class:`chip-remove`,type:`button`,"data-remove":t,"aria-label":u(g().removeText,{text:a})}),l=r(`x`);l&&c.replaceChildren(l),i.append(c)}return i};function U(){if(!p)return;p.querySelector(`:scope > .chip-more`)?.remove();let t=[...p.querySelectorAll(`:scope > .chip`)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`The chip row holds a node that is not an element.`);return e});for(let e of t)e.style.display=``;let n=t[t.length-1];if(!l.hasAttribute(`collapse-chips`)||!n)return;let r=p.clientWidth,i=e=>e.offsetLeft+e.offsetWidth;if(i(n)<=r)return;let a=e(`span`,{class:`chip chip-sm chip-more`});a.textContent=`+${t.length}`,n.after(a);let o=a.offsetWidth+6,s=0;for(let e of t)if(i(e)<=r-o)s+=1;else break;s<1&&(s=1);for(let e of t.slice(s))e.style.display=`none`;a.textContent=`+${t.length-s}`}function W(){if(!p)return!1;p.parentNode!==d.value&&d.value.append(p);for(let e of p.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=D();P(e);let t=p,r=e=>{m?t.insertBefore(e,m):t.append(e)};E()||m||e.length||r(H());for(let t of e)r(de(t));return m&&(m.placeholder=E()||!e.length?se():``,m.disabled=l.hasAttribute(`disabled`),m.readOnly=n(l),L()),E()||(v(b,`the footer text`).textContent=(()=>{let t=l.getAttribute(`selected-text`);return t?t.replace(`{n}`,()=>String(e.length)):u(g().selectedText,{count:e.length})})(),v(x,`the clear-all button`).textContent=l.getAttribute(`clear-all-label`)||g().clearAllLabel),U(),!0}function fe(e){if(e.key===`Backspace`){let t=m?!I():!I()&&a(d.menu),n=D(),r=n[n.length-1];return!t||r===void 0?!1:(e.preventDefault(),V(r),!0)}if(!m)return!1;let t=m.value;if(e.key===`Escape`){if(!E())return!1;let n=a(d.menu);return!n&&!t?!1:(e.preventDefault(),n&&e.stopPropagation(),m.value=``,R(),l.closeMenu({focusControl:!1}),!0)}let n=!E()&&!t.trim(),r=ie();return i(e)&&r.has(`Enter`)?n||d.list.querySelector(`.is-active`)?!1:(e.preventDefault(),B(),!0):e.key===`,`&&r.has(`,`)?!n&&(e.preventDefault(),B({strip:!0}),!0):e.key===` `&&r.has(` `)&&t.trim()||e.key===`Tab`&&r.has(`Tab`)&&!n?(e.preventDefault(),B(),!0):!1}function pe(e){let t=String(e.value);if(E()||m&&!N(t))return z([t]),!0;let n=D();return n.includes(t)?l.commit(n.filter(e=>e!==t)):m?z([t]):l.commit([...n,t]),m?.value&&(m.value=``,R()),!0}function G(e){if(!m)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||A()||F(t)||j(D(),t))return null;let n=l.getAttribute(`create-label`)||g().createLabel;return{position:E()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let t=e.target,r=t instanceof Element?t.closest(`[data-remove]`):null;if(r instanceof HTMLElement){if(n(l))return;e.stopPropagation(),V(r.dataset.remove??``),m?.focus()}else m&&!n(l)&&m.focus()}function q(){R();let e=T().value.trim();E()||!e||a(d.menu)||(G(e)||f(l.options||[],e).length)&&l.openMenu()}function J(e){e.preventDefault(),n(l)||z(ae(e.clipboardData?.getData(`text/plain`)??``))}function Y(){T().value.trim()&&B({quiet:!0,strip:!0}),l.closeMenu({focusControl:!1})}function X(e){e.relatedTarget instanceof Node&&l.contains(e.relatedTarget)||Y()}function me(){return m?(Y(),!0):!1}function Z(){T().value.trim()&&B({strip:!0})}function Q(){n(l)||l.commit([])}function $(e){e.target!==m&&e.preventDefault()}function he(t,n,r={}){l=t,d=n,p=e(`div`,{class:`wui-select-chips`}),p.addEventListener(`click`,K),d.value.append(p),oe()&&(m=e(`input`,{class:`wui-select-draft`,type:`text`,autocomplete:`off`,role:`combobox`,"aria-autocomplete":`list`}),l.hasAttribute(`required`)&&m.setAttribute(`aria-required`,`true`),d.menu.addEventListener(`toggle`,L),p.append(m),m.value=r.carry?.draft??``,d.input=m,m.addEventListener(`input`,q),m.addEventListener(`paste`,J),m.addEventListener(`blur`,X),p.addEventListener(`mousedown`,$),S=l.closest(`form`),S?.addEventListener(`submit`,Z,!0)),E()||(y=e(`div`,{class:`wui-select-footer`}),b=document.createElement(`span`),x=e(`button`,{class:`wui-select-clear-all`,type:`button`}),x.addEventListener(`click`,Q),y.append(b,x),d.menu.append(y)),typeof ResizeObserver<`u`&&(C=new ResizeObserver(U),C.observe(p)),W()}function ge(){p?.removeEventListener(`click`,K),p?.removeEventListener(`mousedown`,$),m&&(m.removeEventListener(`input`,q),m.removeEventListener(`paste`,J),m.removeEventListener(`blur`,X),d.input=null),x&&x.removeEventListener(`click`,Q),S?.removeEventListener(`submit`,Z,!0),S=null,C?.disconnect(),C=null,d.menu.removeEventListener(`toggle`,L),y?.remove(),p?.remove(),p=null,m=null,y=null,w=!1}return{mount:he,onKey:fe,onPick:pe,renderValue:W,actionRow:G,onQuery:()=>!1,onBlur:me,teardown:ge}}export{y as default};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-DvNLnnaO.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./drawer.g-B-zYKBfQ.js";import{a as u,i as d,n as ee,r as f,t as p}from"./tableSelect.g-Bmd-ExRE.js";import{M as m,O as te,T as ne,b as re,j as ie,y as ae}from"./dataTable-VB3nBucm.js";import{n as oe,t as h}from"./devWarn-DXdRWZs3.js";import{t as se}from"./httpFailure.g-DjZzGxPj.js";import{t as ce}from"./hasOwn-CJsplJ62.js";import{t as le}from"./svgNodes-CyPS2oFH.js";import{t as ue}from"./serverHtml-BC6tAyAl.js";import{t as de}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as fe,SEARCH_PARAM as pe}from"./listQuery.js";import{t as me}from"./dataTable.g-DazoWWps.js";import{l as he,m as g,p as ge}from"./wuiHttp-Cw7V8u2w.js";var _e=()=>s(`tableSelect`,p),_=`wui-select-cell`,v=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`form-check-input`,n.setAttribute(`aria-label`,t),n};function y(e=document){let t=e.createElement(`th`);return t.className=_,t.appendChild(v(e,_e().selectAllLabel)),t}function ve(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=_;let r=v(e,_e().selectRowLabel);return r.disabled=t,n.appendChild(r),n}function ye(e=document){let t=e.createElement(`td`);return t.className=_,t}var b=e=>e.firstElementChild?.classList.contains(_),be=e=>e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`),x=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function xe(e){for(let t of e){if(b(t)||be(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(ve(t.ownerDocument,{disabled:e}),t.firstChild)}}function Se(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;b(t)||t.insertBefore(y(e.ownerDocument),t.firstChild),xe(x(e,`tbody tr`,HTMLTableRowElement));for(let t of x(e,`tfoot tr`,HTMLTableRowElement))b(t)||t.insertBefore(ye(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${_} .form-check-input`);return n instanceof HTMLInputElement?n:null}function Ce(e){let t=e.querySelector(`thead .${_} .form-check-input`),n=x(e,`tbody tr .form-check-input:not(:disabled)`,HTMLInputElement),r=n.length,i=n.filter(e=>e.checked).length;t instanceof HTMLInputElement&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of x(e,`tbody tr`,HTMLTableRowElement)){let e=t.querySelector(`.form-check-input`);t.classList.toggle(`is-selected`,e instanceof HTMLInputElement&&e.checked)}return{selected:i,total:r}}var S=`tbody .${_} .form-check-input:not(:disabled)`;function we(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .form-check-input:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=x(e,S,HTMLInputElement),i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t!==a&&t.checked!==a.checked&&(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var C=()=>s(`dataTable`,me),Te=5,Ee=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,De=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Oe=e=>Ee(e)&&`type`in e&&e.type===`hidden`,w=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),T=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},E=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},ke=e=>e.localName===`wui-select`,D=/* @__PURE__ */ new WeakMap,O=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Ae=e=>({total:O(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:O(e.dataset.page,1),pageSize:O(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:O(e.dataset.rowCount,0)}),je=(e,t)=>{e&&M().toast(e,{variant:t})},Me=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Oe(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!fe.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of w(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},Ne=new Intl.NumberFormat(`en-IN`),Pe=(e,t)=>t?`${Ne.format(e)}+`:Ne.format(e),Fe=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?T(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Pe(t,n))};function Ie(e=document){let t=w(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(D.has(e))continue;let t=Le(e);D.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function k(e){let t=e instanceof Element?E(e,`[data-wui-server]`,HTMLElement):null;return t&&D.get(t)||null}function Le(i){let a=T(i,`.table-wrap`,HTMLElement),o=a?T(a,`:scope > table`,HTMLTableElement):null,l=i.dataset.src;if(!a||!o||!l)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let u=T(a,`:scope > [data-wui-table-state]`,HTMLElement),d=T(i,`[data-wui-table-pager]`,HTMLElement),ee=T(i,`[data-wui-table-status]`,HTMLElement),f={urlState:i.dataset.urlState!==`false`,refreshOnSuccess:i.dataset.refreshOnSuccess!==`false`,filtersForm:i.dataset.filtersForm||null,filtersRegion:i.dataset.filtersRegion||null,searchInput:i.dataset.searchInput||null,loadingText:i.dataset.loadingText||C().loadingText,errorText:i.dataset.errorText||C().errorText,timeoutMs:ge(i.getAttribute(`data-wui-timeout`))??3e4},p=new URL(l,window.location.href),ce=i.dataset.totalSrc||null,le=ce===null?null:new URL(ce,window.location.href),me=/* @__PURE__ */ new Set([...p.searchParams.keys(),...le?.searchParams.keys()??[]]),_e=o.hasAttribute(`data-app-datatable-selectable`),v=/* @__PURE__ */ new Set,y=!1,ve=he(),ye=new AbortController,b={signal:ye.signal},be=T(o,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),x=n(be,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),S=Ae(x),D=null,Ne=null,Ie=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))me.has(n)||t.append(n,r);return t},k=e=>Ie(new URL(e,window.location.href).search),Le=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Re=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)me.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},ze=e=>Re(p,e),Be=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},A=Be(f.urlState?Ie(window.location.search):new URLSearchParams,S);f.urlState&&Le(A)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,Le(A));let j=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),N=e=>{ee&&(ee.textContent=e)},He=e=>{if(e.pending)return e.rowCount===0?C().emptyLabel:c(C().pageTextPending,{page:e.page});if(e.total===0)return C().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Pe(e.total,!0):`${e.total}`;return c(e.total===1?C().pageTextOne:C().pageTextOther,{page:e.page,pages:t,total:n})},Ue=()=>w(o,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),We=e=>{if(_e&&w(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Ge=e=>{let t=i.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},Ke=e=>{if(_e){xe(e);for(let t of e){let e=T(t,`.${_} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(y&&v.add(t.dataset.rowKey),e.checked=v.has(t.dataset.rowKey))}Ce(o)}Ge(e);let t=Ue();if(o.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},P=e=>Ke(w(e,`:scope > tr`,HTMLTableRowElement)),F=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},I=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),qe=(e,t)=>{if(!u)return;let n=T(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(u),(t.pending?t.rowCount:t.total)===0&&n?(u.replaceChildren(n.content.cloneNode(!0)),u.hidden=!1):(u.replaceChildren(),u.hidden=!0)},Je=e=>{d&&(I(d),d.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),d.hidden=!1)},Ye=e=>{let t=f.filtersRegion&&e?T(document,f.filtersRegion,HTMLElement):null;return t&&e&&(I(t),t.replaceChildren(e.content.cloneNode(!0))),t},Xe=0,Ze=e=>{let t=Ae(e);t.pending&&Object.assign(t,{total:S.total,totalCapped:S.totalCapped});let n=t.sortBy!==S.sortBy||t.sortOrder!==S.sortOrder?ae(x.rows):null;Je(T(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),qe(e,t);let r=Ye(T(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));F(e),I(x),o.replaceChild(e,x),x=e,Xe+=1;let i=y&&t.total!==S.total;return S=t,i&&(y=!1),a.removeAttribute(`data-wui-table-error`),P(e),V(),ne(e.rows,n),i&&H(),r},Qe=e=>{let t=T(ue(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&We(t),t?document.importNode(t,!0):null},$e=(e,t=Ue())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},et=()=>{if(x.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,Ue().length);x.replaceChildren(...Array.from({length:Te},()=>{let t=$e(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),u&&(u.hidden=!0)},tt=e=>{e?(a.setAttribute(`aria-busy`,`true`),et()):a.removeAttribute(`aria-busy`)},nt=e=>e===`forbidden`?C().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,se).networkCheckText:e===`network`?C().networkMessage:e===`timeout`?C().timeoutMessage:f.errorText,L=n=>{let r=nt(n);if(a.setAttribute(`data-wui-table-error`,n),d&&(d.hidden=!0),u){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`;let o=de(n===`forbidden`?`lock`:`alert-circle`,{size:24});o&&a.replaceChildren(o);let s=document.createElement(`div`);s.className=`empty-state-title`,s.textContent=r;let c=document.createElement(`div`);c.className=`empty-state-action`;let l=document.createElement(`button`);l.type=`button`,l.className=e(`primary`,`outline`,`sm`),l.dataset.wui=t,l.setAttribute(`data-wui-table-retry`,``),l.textContent=C().retryLabel,c.append(l),i.append(a,s,c),I(u),u.replaceChildren(i),u.hidden=!1}N(r)},R=()=>f.filtersForm?T(document,f.filtersForm,HTMLFormElement):null,z=async(e,t=`none`,{quiet:n=!1}={})=>{let r=new URLSearchParams(e);n||(D={query:r,mode:t},tt(!0),N(f.loadingText)),j(`wui:table:loading`,{query:r.toString()});let o=await ve.run(ze(r),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;n||tt(!1);let s=null;if(o.ok)try{s=Qe(o.html)}catch(e){h(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return n?oe(`A quiet server table refresh failed; the rows on screen are kept.`,e):L(e),j(`wui:table:error`,{status:o.status,kind:e,message:nt(e)}),o}let c=Ze(s);return A=Be(r,S),Me(R(),A),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,Le(A)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,Le(A)),n||N(He(S)),M().refresh(a),c&&M().refresh(c),S.pending?B():Fe(i,S.total,S.totalCapped),j(`wui:table:loaded`,{...S,query:A.toString()}),o},rt=e=>(e.delete(`page`),e),B=()=>{if(!le||!S.pending)return;let e=Xe;g(Re(le,A),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Xe)return;if(!t.ok){oe(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let n=T(ue(t.html),`div[data-wui-total]`,HTMLElement);if(!n){oe(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(O(n.dataset.page,-1)!==S.page||O(n.dataset.pageSize,-1)!==S.pageSize)return;let r=O(n.dataset.total,-1);if(r<0){oe(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=n.dataset.totalCapped===`true`,o=y&&r!==S.total;S={...S,total:r,totalCapped:a,pending:!1},o&&(y=!1);let s=T(n,`:scope > template[data-wui-pager]`,HTMLTemplateElement);s&&Je(s);let c=Ye(T(n,`:scope > template[data-wui-filters]`,HTMLTemplateElement));c&&M().refresh(c),Fe(i,S.total,S.totalCapped),N(He(S)),o&&H(),j(`wui:table:total`,{total:r,totalCapped:a})})},it=()=>w(o,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),V=()=>{for(let e of it()){let t=e.dataset.sortKey===S.sortBy;e.setAttribute(`aria-sort`,t?S.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of it())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=de(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let at=e=>{let t=rt(new URLSearchParams(A)),n=S.sortBy===e&&S.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),z(t,`push`)};o.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&at(t.dataset.sortKey??``)}),o.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?E(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&(e.preventDefault(),at(t.dataset.sortKey??``))});let H=()=>{Ce(o);let e=y?{selected:S.total,total:S.total,allMatching:y}:{selected:v.size,total:S.total};o.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};_e&&(we(o,(e,t)=>{for(let n of e){let e=E(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?v.add(e):v.delete(e))}t||(y=!1)}),o.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(y=!1),o.tHead?.contains(t))for(let e of w(x,`:scope > tr`,HTMLTableRowElement)){let n=T(e,`.${_} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?v.add(e.dataset.rowKey):v.delete(e.dataset.rowKey))}else{let e=E(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?v.add(e):v.delete(e)}H()}})),d&&(d.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),z(k(t.getAttribute(`href`)??``),`push`))}),d.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),z(k(t.value),`push`))}));let U=()=>{if(!f.searchInput)return null;let e=T(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?T(e,`input`,HTMLInputElement):null},W=()=>i.isConnected?!0:(ye.abort(),clearTimeout(Ne??void 0),!1),ot=(e,t)=>{let n=[...e.elements].filter(Ee),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Oe(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!De(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},st=(e,t)=>{let n=new Set([...e.elements].filter(Ee).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&fe.includes(e);for(let[e,t]of A)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of ot(e,t))a===``||i(n)||me.has(n)||r.append(n,a);let a=U();if(a){r.delete(pe);let e=a.value.trim();e&&r.set(pe,e)}return z(r,`push`)},ct=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),st(e.target,e.submitter))},b),document.addEventListener(`change`,e=>{if(!W()||!f.filtersForm||!(e.target instanceof Element))return;let t=E(e.target,f.filtersForm,HTMLFormElement);!t||e.target===U()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||st(t)},b);let lt=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of w(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of w(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(ke)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!W())return;let t=e.target instanceof Element?E(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!ct(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=rt(k(n.href));lt(t.closest(`form`),r),Me(t.closest(`form`),r),z(r,`push`)},b),document.addEventListener(`input`,e=>{if(!W())return;let t=U();t&&e.target===t&&(clearTimeout(Ne??void 0),Ne=setTimeout(()=>{if(!W())return;let e=rt(new URLSearchParams(A)),n=t.value.trim();n?e.set(pe,n):e.delete(pe),e.toString()!==A.toString()&&z(e,`replace`)},300))},b),f.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=Ie(window.location.search),t=U();t&&(t.value=e.get(`search`)??``),Me(R(),e),z(e,`none`)},b),document.addEventListener(`wui:modal:success`,()=>{W()&&f.refreshOnSuccess&&z(A,`none`)},b),u?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&D&&z(D.query,D.mode)});let G=e=>[...x.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=ue(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=w(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:G(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),i.push(n))}return Ke(i),M().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?C().actionForbiddenMessage:C().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&m(e,null)},mt=async({url:e,method:t=`POST`,body:n,key:i,row:o}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let s=i==null,c=s?null:G(String(i));if(!s&&!c)throw Error(`saveRow found no row with data-row-key="${i}" on this page.`);let l=Ue().filter(e=>!e.classList.contains(_)),d=o===void 0?c??$e(Math.max(1,l.length),l):r(o,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");c&&d!==c?c.replaceWith(d):c||x.insertBefore(d,x.firstChild),d!==c&&Ke([d]),u&&!a.hasAttribute(`data-wui-table-error`)&&(u.hidden=!0),m(d,`saving`);let ee=te(d),f=await g(e,{method:t.toUpperCase(),body:n});if(f.kind===`session`)return!1;if(f.ok){let e=ut(f.html),t=e&&d.isConnected?dt(e,d,s):null;return t?N(ie(te(t)||ee)):(await z(A,`none`),pt(d)),Ve(f,f.toastVariant||`success`),j(`wui:table:saved`,{key:t?.dataset.rowKey??(s?null:String(i)),added:s,status:f.status}),!0}let p=ft(f),ne=d;return c&&d!==c&&d.isConnected?(d.replaceWith(c),ne=c):s&&!o&&(d.remove(),ne=null,u?.childElementCount&&!x.querySelector(`:scope > tr`)&&(u.hidden=!1)),ne?.isConnected&&m(ne,`error`,p),f.kind!==`aborted`&&je(p,`danger`),N(re(ee,p)),j(`wui:table:failed`,{key:s?null:String(i),added:s,status:f.status,kind:f.kind,message:p}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=E(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?te(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&m(n,`saving`);let o=await g(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)pt(n);else{if(o.ok){Ve(o,o.toastVariant||`success`);let e=n?.isConnected?ut(o.html):null,t=e&&n?dt(e,n,!1):null;t?N(ie(te(t)||a)):(await z(A,`none`),pt(n))}else{let e=ft(o);je(e,`danger`),n?.isConnected&&m(n,`error`,e),N(re(a,e))}j(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return o.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&x.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),We(x),F(x),_e&&Se(o),P(x),V(),S.pending&&(N(He(S)),B()),{el:i,reload:async e=>{let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?null:z(A,`none`,{quiet:t})},query:()=>new URLSearchParams(A),setQuery:e=>{let t=new URLSearchParams(A);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),z(t,`push`)},saveRow:mt,setActiveRow:e=>{i.dataset.activeRowKey=e==null?``:String(e),Ge(w(x,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...v],count:()=>y?S.total:v.size,allMatching:()=>y,selectAllMatching:()=>{if(S.pending)oe(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{y=!0;for(let e of w(x,`:scope > tr`,HTMLTableRowElement)){let t=T(e,`.${_} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&v.add(e.dataset.rowKey))}H()}},clear:()=>{y=!1,v.clear();for(let e of w(x,`:scope > tr > .${_} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;H()}}}}var Re=8e3,ze=()=>s(`toast`,ee),Be=[`success`,`info`,`warning`,`danger`],A=e=>Be.some(t=>t===e);function j(e){if(!A(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function M(){return n(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Ve(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?M().toast(e.message,{variant:j(t),duration:Re,action:{label:n.label,onClick:()=>N(n)}}):M().toast(e.message,{variant:j(t)})}async function N(e){let t=await g(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Ve(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&k(e)?.reload()}else M().toast(t.message||ze().failedText,{variant:`danger`})}}var He=`wui-remote-modal`,Ue=`wui-remote-drawer`,We=Object.freeze({sm:360,md:480,lg:640,xl:720}),Ge=`wui-modal-fullscreen`,Ke=`wui-modal-wide`,P=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),F=()=>s(`modal`,f),I=e=>ge(e?.getAttribute(`data-wui-timeout`)??null)??3e4,qe=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Je=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Ye=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Xe=`invalid`,Ze=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,Qe=`[data-wui-modal-content]`,$e=`[data-wui-pane-close], [data-wui-dismiss]`,et=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":F().closeLabel},le({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),tt=/* @__PURE__ */ new WeakMap,nt=/* @__PURE__ */ new WeakSet;function L(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var R=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},z=(e,t,n)=>L(R(e,t),n),rt=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),B=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),it=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,V=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},at=e=>ce(P,e),H=e=>ce(We,e);function U(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(at(e))return e===`wide`?{px:P.wide,wide:!0}:{px:P[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var W=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:P.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:P.md}},ot=(e,t)=>{e.classList.toggle(Ge,!!t.fullscreen),e.classList.toggle(Ke,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},st=[`center`,`top`];function ct(e){if(e==null||e===``)return null;if(H(e))return{px:We[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var lt=e=>e.container===`drawer`,G=e=>e.container===`pane`,ut=e=>e.container!==`modal`,dt=(e,t)=>lt(e)?ct(t):U(t),ft=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},pt=e=>G(e)?e.shell:z(e.shell,`.modal-dialog`,`a dialog frame`);function mt(e=`modal`){let t=e===`drawer`,n=t?Ue:He,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?We.md:P.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var ht=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),et()),gt=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},ht(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},F().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),_t=(n,r)=>{let a={forbidden:F().forbiddenMessage,networkCheck:s(`httpFailure`,se).networkCheckText,client:F().clientMessage,server:F().serverMessage,network:F().networkMessage,timeout:F().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},ht(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},F().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||F().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},F().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},F().retryLabel)))))},K=e=>R(e.shell,`.modal-content`),vt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function yt(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function bt(e,t){let n=K(e),r=n?St(n):/* @__PURE__ */ new Map;yt(n),n?n.replaceWith(t):pt(e).appendChild(t),Ct(t,r),M().refresh()}var xt=`input[type="file"][name]`;function St(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function Ct(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var wt=e=>G(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function Tt(e,t,n=!1){let r=t?R(e,Ye):null,i=r?r.matches(qe)?r:R(r,qe)||r:null;if(!i&&n)i=R(e,`[data-autofocus]`)||R(e,Je)||R(e,`.wui-modal-close`);else if(!i){let t=rt(e,qe);i=R(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function Et(e,t){let n=R(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),pt(e).appendChild(n)),n.textContent=``,n.textContent=t}var Dt=e=>{let t=R(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},Ot=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function kt(e,t,n,r){let i={...r,container:e.container};Ot(t,`wui:modal:${n}`,i),lt(e)&&Ot(t,`wui:drawer:${n}`,i),G(e)&&Ot(t,`wui:pane:${n}`,i)}var At=e=>e.matches(`[data-wui-pane-host]`)?`pane`:z(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,jt=e=>L(e.host.closest(`wui-modal`),`a wui-modal host`);function Mt(e){let t=tt.get(e);if(t)return t;let n=At(e),r=n===`pane`?e:z(e,`dialog`,`a dialog`),a=K({shell:r}),o={host:e,shell:r,container:n,queue:he(),defaultSize:W(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?vt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return tt.set(e,o),e.addEventListener(`submit`,e=>Qt(o,e)),e.addEventListener(`click`,e=>{V(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),J(o,o.session))}),G(o)&&e.addEventListener(`click`,t=>{let n=V(t.target,$e);n&&e.contains(n)&&o.session&&q(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&Jt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&It(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=K(o);o.session&&n?.matches(Qe)&&!n.contains(document.activeElement)&&Tt(n,!1,ut(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Lt(o,t)}),o}function Nt(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r=()=>void 0,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:{el:e.shell,closed:i,close:()=>q(e,a,`dismissed`,null),reload:()=>J(e,a)}};return e.session=a,a}function q(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},G(e)?Ft(e,t):Pt(e))}function Pt(e){let t=jt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Ft(e,t){let n=e.shell,{status:r,detail:i}=L(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,yt(K(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),kt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function It(e){let t=e.session;if(e.queue.abort(),e.session=null,Dt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),kt(e,e.shell,`closed`,{status:n.status,url:t.url});let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(bt(e,vt(e.placeholder)),e.loadedUrl=null,ot(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Lt(e,t){let n=Jt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=Nt(e,i,{trigger:r});a.explicitSize=Rt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&ot(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&bt(e,vt(e.placeholder)),J(e,a,{keepPlaceholder:!0}))}function Rt(e,t){try{return dt(e,t)}catch(e){return h(e),null}}async function J(e,t,{keepPlaceholder:n=!1}={}){n||bt(e,gt(t.options.title||zt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:I(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Ut(e,t,r.html,!1))return e.loadedUrl=t.url,kt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return bt(e,_t(t.options.title||zt(e),i)),wt(e)&&Tt(L(K(e),`a card`),!1,ut(e)),kt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var zt=e=>K(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Bt=`/_content/Webority.Ui.Razor/js/`,Vt=e=>new URL(e,window.location.href).pathname.includes(Bt);function Ht(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Ut(e,t,n,r){let i=ue(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Vt(t)?Ht(t):a=!0}a&&oe(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=R(i,Qe);if(!o)return h(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(bt(e,o),r||Dt(e),!G(e)){ot(e.shell,t.explicitSize||Rt(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return wt(e)&&Tt(o,r,ut(e)),!0}var Wt=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Gt(e,t,n){let r=[...e.elements].filter(e=>e.matches(Wt));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Kt(e){for(let t of e.querySelectorAll(Ze))t.remove();for(let t of e.querySelectorAll(Ye))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var qt=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),Jt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Yt(e){if(!e||e.status<400||e.status>499||!e.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await e.text())}catch{return null}let n=e=>typeof e==`string`?e.trim():``,r=n(Jt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=qt.has(r.toLowerCase())||r.toLowerCase()===i;return n(Jt(t,`message`))||n(Jt(t,`detail`))||(r&&!a?r:null)}function Xt(e,t,n,r){let i={forbidden:F().forbiddenMessage,networkCheck:s(`httpFailure`,se).networkCheckText,client:F().clientMessage,server:F().serverMessage,network:F().networkMessage,timeout:F().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Kt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${F().submitFailedMessage} ${r||i[n]||F().serverMessage}`,a.prepend(o),Et(e,o.textContent)}var Zt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Qt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(Qe)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;Gt(n,i,!0);let l;try{l=await e.queue.run(c?Zt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:I(r.trigger)})}catch(t){h(t),e.session===r&&n.isConnected&&(Gt(n,i,!1),Xt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&Gt(n,i,!1),l.kind===`ok`&&l.result===`success`){$t(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Xe;if(Ut(e,r,l.html,t)){if(t){let t=L(K(e),`a card`).querySelector(Ze)?.textContent?.replace(/\s+/g,` `).trim();Et(e,t||F().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await Yt(l.response);e.session===r&&Xt(e,n,u,d)}function $t(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!fn(a))throw TypeError(`Unknown toast variant "${a}". Use ${dn.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};i&&!t.options.navigate?Nn(r,a):r&&M().toast(r,{variant:a}),kt(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i);let s=n.next;s&&!i?(t.url=s,t.method=`GET`,t.body=void 0,J(e,t)):n.keepOpen?n.html&&Ut(e,t,n.html,!1):q(e,t,`success`,o)}function en(e){let t=V(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?cn(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{it(e)||h(e)}):t.hasAttribute(`data-wui-modal`)?rn(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{it(e)||h(e)}):on(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{it(e)||h(e)})))}function tn(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=V(e.target,sn);if(!t)return;let n=tt.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),q(n,n.session,`dismissed`,null)))}function nn(e=document){let t=e instanceof Document?e:L(e.ownerDocument,`an owner document`);nt.has(t)||(nt.add(t),t.addEventListener(`click`,en),t.addEventListener(`keydown`,tn));let n=rt(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)Mt(e)}function rn(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ct(t.size):U(t.size),i=t.placement||`center`;if(!st.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(B());let a=mt(n?`drawer`:`modal`);nn(document);let o=Mt(a),s=wt(o),c=Nt(o,e,t);c.explicitSize=r,ot(o.shell,r||o.defaultSize),n||z(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=J(o,c);return s||jt(o).show(),an(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function an(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),q(e,t,`dismissed`,{aborted:!0})),i(B())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw B();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function on(e,t={}){return rn(e,{...t,container:`drawer`,placement:void 0})}var sn=`[data-wui-pane-host]`;function cn(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=ft(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(B());nn(document);let r=Mt(n),i=Nt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=J(r,i);return an(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function ln(e){let t=ft(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=tt.get(t);n?.session&&q(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,un=Object.freeze([`danger`]),dn=Object.freeze([`success`,`info`,`warning`,`danger`]),fn=e=>dn.some(t=>t===e),pn=`wui.flash`,X=()=>s(`confirmDialog`,d),mn=/* @__PURE__ */ new WeakSet,hn=/* @__PURE__ */ new WeakSet,gn=null,_n=null,vn=!1,yn=(e,t)=>{e&&M().toast(e,{variant:t})};function bn(){let r=document.getElementById(Y);if(r)return n(r.closest(`wui-modal`),`#${Y} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=Y;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${P.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},X().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function xn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!un.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);Sn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`},t)}function Sn({title:e,message:t,label:r,danger:i},a){let o=bn(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${Y} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${Y}"> without confirm-href, or leave the dialog to the library.`);let l=o.querySelector(`.wui-confirm-msg`);l||(l=document.createElement(`p`),l.className=`wui-confirm-msg`,s.after(l));let u=e||X().confirmTitle;s.textContent=u,l.textContent=t,c.textContent=r||X().confirmLabel,c.classList.toggle(`btn-danger`,i),c.classList.toggle(`btn-primary`,!i),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,i?`delete`:`info`),n(o.querySelector(`dialog`),`#${Y} has no <dialog>.`).setAttribute(`aria-label`,u),_n=a,vn=!1,o.show()}var Cn=(e,t)=>{gn=e;try{t()}finally{gn=null}},wn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},Tn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:wn(e,`title`),message:t,label:wn(e,`label`),tone:wn(e,`tone`)}};function En(e,t,n){let{title:r,message:i,label:a,tone:o}=Tn(t);if(o!=null&&!un.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Yn(e.ownerDocument),Sn({title:r,message:i,label:a,danger:o===`danger`},()=>Cn(e,n))}var Dn=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,On=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function kn(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==gn&&!Dn(t)&&(e.preventDefault(),e.stopImmediatePropagation(),xn(t,()=>Cn(t,()=>On(t))))}function An(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===gn||e.submitter&&e.submitter===gn||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;xn(t,()=>Cn(t,()=>t.requestSubmit(r)))}function jn(e){let t=a(e.target,`#${Y} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&_n&&(vn=!0,n(t.closest(`wui-modal`),`#${Y} is missing around its confirm button.`).hide())}function Mn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=vn?_n:null;_n=null,vn=!1,t?.()}function Nn(e,t){e&&window.sessionStorage.setItem(pn,JSON.stringify({message:e,variant:t}))}var Pn=e=>e===`forbidden`?X().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,se).networkCheckText:e===`network`?X().networkMessage:e===`timeout`?X().timeoutMessage:X().failedMessage;function Fn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&k(e)?.reload()}var In=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function Ln(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return Rn(t,e)}async function Rn(e,t,n){let r=t.getAttribute(`data-wui-post-reload`);if(r!==null&&r!==`page`)throw TypeError(`data-wui-post-reload="${r}" is not supported. Use page, or leave it off to reload the server tables.`);In(t,!0),t.setAttribute(`aria-busy`,`true`);let i=ge(t.getAttribute(`data-wui-timeout`))??3e4,a=await g(e,{method:`POST`,body:n,timeoutMs:i});if(a.kind===`session`||a.kind===`aborted`)return;let o=a.toastVariant||`success`;a.ok&&(a.redirect||r===`page`)?(Nn(a.message,o),a.redirect?window.location.assign(a.redirect):window.location.reload()):(In(t,!1),t.removeAttribute(`aria-busy`),a.ok?(Ve(a,o),Fn()):yn(a.message||Pn(a.kind),`danger`))}function zn(e,t){In(e,!1),e.removeAttribute(`aria-busy`),h(t),yn(X().failedMessage,`danger`)}function Bn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),Dn(t)||t.getAttribute(`aria-busy`)===`true`||Ln(t).catch(e=>zn(t,e)))}function Vn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;Rn(i,r,new FormData(t)).catch(e=>zn(r,e)),t.closest(`wui-dropdown`)?.hide()}var Hn=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&m(t,null)};async function Un(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&m(t,`saving`);let r=ge(e.getAttribute(`data-wui-timeout`))??3e4,i=await g(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){Hn(e,t);return}if(i.ok){Nn(i.message,i.toastVariant||`success`),i.redirect?window.location.assign(i.redirect):window.location.reload();return}let a=i.message||Pn(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&m(t,`error`,a),yn(a,`danger`)}function Wn(e){let t=a(e.target,`[data-wui-row-action]`);if(!(t instanceof HTMLButtonElement)||t.closest(`[data-wui-server]`)||(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`))return;let n=t.closest(`tr`);Un(t,n).catch(e=>{Hn(t,n),h(e),yn(X().failedMessage,`danger`)})}function Gn(){let e=window.sessionStorage.getItem(pn);if(!e)return;window.sessionStorage.removeItem(pn);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=`message`in t?t.message:void 0,r=`variant`in t?t.variant:void 0;if(typeof r!=`string`||!fn(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);yn(n,r)}function Kn(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!fn(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${dn.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),yn(n,t)}}var qn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Jn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=qn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Yn(e){hn.has(e)||(hn.add(e),e.addEventListener(`click`,jn),e.addEventListener(`wui-modal-closed`,Mn))}function Xn(e=document){let t=e instanceof Element?e.ownerDocument:e;mn.has(t)||(mn.add(t),t.addEventListener(`click`,kn,!0),t.addEventListener(`submit`,An,!0),Yn(t),t.addEventListener(`click`,Bn),t.addEventListener(`click`,Wn),t.addEventListener(`submit`,Vn),t.addEventListener(`change`,Jn),Gn()),Kn(e)}var Zn=()=>s(`unsavedChanges`,u),Qn=`form[data-wui-unsaved]`,$n=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,er=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,tr=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),nr=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),rr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,ir=e=>rr(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,ar=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,or=e=>typeof e==`object`&&!!e,sr=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function cr(e){let t=JSON.parse(e);if(!sr(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,lr=/* @__PURE__ */ new WeakSet,ur=e=>`${e.name}:${e.size}:${e.lastModified}`,dr=e=>[...e.querySelectorAll(Qn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)ar(n)&&!ir(n)&&(rr(n)&&tr.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(ur)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function fr(e){return Q(e)}function pr(e,t){let n=/* @__PURE__ */ new Map,r=cr(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=cr(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function mr(e){for(let t of e.elements)if(rr(t)&&t.name&&!ir(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!nr.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var hr=e=>({saved:e.querySelector($n)&&mr(e)?null:Q(e),engaged:!1,discarded:!1});function gr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var _r=(e,t)=>dr(e).filter(e=>e!==t&&gr(e));function vr(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Zn().message;En(e,{title:Zn().title,message:r,label:Zn().leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function yr(e){if(e.matches(er))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function br(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function xr(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!yr(n))return;let r=_r(n.ownerDocument,null);r.length&&(e.preventDefault(),vr(n,r,()=>n.click()))}function Sr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!br(t,e.submitter))return;let n=_r(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;vr(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function Cr(e){_r(document,null).length&&e.preventDefault()}function wr(e){let t=e.target,n=a(t,Qn);return n instanceof HTMLFormElement?n:null}function Tr(e){let t=wr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function Er(e){let t=wr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Dr(e){for(let t of dr(e)){let e=Z.get(t);e?.saved&&(e.saved=pr(t,e.saved))}}function Or(e){let t=or(e)?e.handle:void 0;return or(t)?t.el:void 0}function kr(e){if(!(e instanceof CustomEvent))return;let t=Or(e.detail);if(t instanceof Element)for(let e of dr(t))jr(e)}function Ar(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!lr.has(t)){lr.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,Tr,!0);for(let e of[`input`,`change`])t.addEventListener(e,Er,!0);t.addEventListener(`click`,xr),t.addEventListener(`submit`,Sr),t.addEventListener(`wui:modal:success`,kr),t.addEventListener(o,()=>Dr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,Cr)}let r=dr(e);e instanceof HTMLFormElement&&e.matches(Qn)&&r.unshift(e);for(let e of r)Z.has(e)||Z.set(e,hr(e))}function jr(e){if(!(e instanceof HTMLFormElement)||!e.matches(Qn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var Mr=()=>s(`drawer`,l),Nr=`wui:drawer:discard`,Pr=`wui-drawer[confirm-discard]`,Fr=`wui-modal`,Ir=`data-wui-no-discard`,Lr=`.wui-drawer-discard`,Rr=`input, select, textarea`,zr=e=>typeof e==`object`&&!!e||typeof e==`function`;function Br(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Vr(e,t){return a(e,t)}var Hr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Ur=/* @__PURE__ */ new WeakSet,Wr=/* @__PURE__ */ new WeakSet;function Gr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Kr(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,Gr(e,`danger`,`solid`,`data-wui-discard-confirm`,Mr().discardLabel),Gr(e,`primary`,`soft`,`data-wui-discard-keep`,Mr().keepLabel)),n}function qr(e){if(!(e instanceof Element))return null;let t=e.closest(Pr);if(t)return t;let n=e.closest(Fr);return n&&Xr(n).length?n:null}function Jr(e){return e.closest(Pr)??e.closest(Fr)}function Yr(e,t){return t.hasAttribute(Ir)||e.hasAttribute(Ir)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Xr(e){return e.matches(Pr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Yr(t,e))}function Zr(e){let t=$.get(e);return t!=null&&fr(e)!==t}function Qr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Wr.add(t),t}function $r(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Wr.add(t),t}function ei(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function ti(e,t,n){let r=e.querySelector(Lr);if(r){ei(r);return}let i=Kr(e.ownerDocument,t),a;if(e.matches(Pr))a=e.querySelector(`.wui-drawer-footer`)??Qr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??$r(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??$r(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),ei(i)}function ni(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Wr.has(t)&&t.remove()}function ri(e){for(let t of Xr(e))for(let e of t.querySelectorAll(Rr))if(Hr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function ii(e){let t=qr(e.target);if(t)for(let e of Xr(t))$.get(e)??$.set(e,fr(e))}function ai(e){for(let t of Br(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,pr(t,e))}}function oi(e){let t=e.target;t instanceof HTMLFormElement&&qr(t)&&$.set(t,fr(t))}function si(e){if(!zr(e))return;let t=`handle`in e?e.handle:void 0;if(zr(t))return`el`in t?t.el:void 0}function ci(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=si(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function li(e){let t=e.target;t instanceof Element&&t.matches(Pr)&&[...Xr(t)].some(Zr)&&(e.preventDefault(),ti(t,t.getAttribute(`confirm-discard`),null))}function ui(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Fr))return;let n=[...Xr(t)].find(Zr);n&&(e.preventDefault(),ti(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Mr().confirmDiscard,n))}function di(e){let t=n(e.closest(Lr),`The discard button is outside its prompt.`),r=Jr(t);if(ni(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Xr(r))$.set(e,fr(e));r.dispatchEvent(new CustomEvent(Nr,{bubbles:!0})),r.matches(Pr)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function fi(e){let t=n(e.closest(Lr),`The keep button is outside its prompt.`),r=Jr(t);if(ni(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);ri(r)}function pi(e){let t=Vr(e.target,`[data-wui-discard-confirm]`);if(t){di(t);return}let n=Vr(e.target,`[data-wui-discard-keep]`);n&&fi(n)}function mi(e=document){let t=e instanceof Document?e:e.ownerDocument;Ur.has(t)||(Ur.add(t),t.addEventListener(`focusin`,ii),t.addEventListener(`pointerdown`,ii),t.addEventListener(`submit`,oi),t.addEventListener(o,ai),t.addEventListener(`wui:modal:success`,ci),t.addEventListener(`wui:modal:loaded`,ci),t.addEventListener(`wui-drawer-close`,li,!0),t.addEventListener(`wui-modal-close`,ui),t.addEventListener(`click`,pi))}export{Ie as S,cn as _,Ar as a,Ve as b,un as c,En as d,Xn as f,rn as g,on as h,fr as i,pn as l,nn as m,Kr as n,jr as o,ln as p,mi as r,Y as s,Nr as t,dn as u,Re as v,k as x,N as y};
1
+ import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{i as n,n as r,r as i,t as a}from"./dom-DMQu--xV.js";import{t as o}from"./loader-A38-PdcB.js";import{r as s,t as c}from"./textStore-DBplASiZ.js";import{t as l}from"./drawer.g-B-zYKBfQ.js";import{a as u,i as d,n as ee,r as f,t as p}from"./tableSelect.g-Bmd-ExRE.js";import{M as m,O as te,T as ne,b as re,j as ie,y as ae}from"./dataTable-VB3nBucm.js";import{n as oe,t as h}from"./devWarn-DXdRWZs3.js";import{t as se}from"./httpFailure.g-DjZzGxPj.js";import{t as ce}from"./hasOwn-CJsplJ62.js";import{t as le}from"./svgNodes-CyPS2oFH.js";import{t as ue}from"./serverHtml-BC6tAyAl.js";import{t as de}from"./iconGlyphs.g-a9FtjPXh.js";import{LIST_QUERY_RESERVED as fe,SEARCH_PARAM as pe}from"./listQuery.js";import{t as me}from"./dataTable.g-DazoWWps.js";import{l as he,m as g,p as ge}from"./wuiHttp-Cw7V8u2w.js";var _e=()=>s(`tableSelect`,p),_=`wui-select-cell`,v=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`form-check-input`,n.setAttribute(`aria-label`,t),n};function y(e=document){let t=e.createElement(`th`);return t.className=_,t.appendChild(v(e,_e().selectAllLabel)),t}function ve(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=_;let r=v(e,_e().selectRowLabel);return r.disabled=t,n.appendChild(r),n}function ye(e=document){let t=e.createElement(`td`);return t.className=_,t}var b=e=>e.firstElementChild?.classList.contains(_),be=e=>e.matches(`.wui-group-row, .wui-virtual-spacer, .wui-row-expanded`),x=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function xe(e){for(let t of e){if(b(t)||be(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(ve(t.ownerDocument,{disabled:e}),t.firstChild)}}function Se(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;b(t)||t.insertBefore(y(e.ownerDocument),t.firstChild),xe(x(e,`tbody tr`,HTMLTableRowElement));for(let t of x(e,`tfoot tr`,HTMLTableRowElement))b(t)||t.insertBefore(ye(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${_} .form-check-input`);return n instanceof HTMLInputElement?n:null}function Ce(e){let t=e.querySelector(`thead .${_} .form-check-input`),n=x(e,`tbody tr .form-check-input:not(:disabled)`,HTMLInputElement),r=n.length,i=n.filter(e=>e.checked).length;t instanceof HTMLInputElement&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of x(e,`tbody tr`,HTMLTableRowElement)){let e=t.querySelector(`.form-check-input`);t.classList.toggle(`is-selected`,e instanceof HTMLInputElement&&e.checked)}return{selected:i,total:r}}var S=`tbody .${_} .form-check-input:not(:disabled)`;function we(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .form-check-input:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=x(e,S,HTMLInputElement),i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t!==a&&t.checked!==a.checked&&(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var C=()=>s(`dataTable`,me),Te=5,Ee=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,De=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Oe=e=>Ee(e)&&`type`in e&&e.type===`hidden`,w=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),T=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},E=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},ke=e=>e.localName===`wui-select`,D=/* @__PURE__ */ new WeakMap,O=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},Ae=e=>({total:O(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:O(e.dataset.page,1),pageSize:O(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:O(e.dataset.rowCount,0)}),je=(e,t)=>{e&&M().toast(e,{variant:t})},Me=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Oe(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!fe.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of w(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},Ne=new Intl.NumberFormat(`en-IN`),Pe=(e,t)=>t?`${Ne.format(e)}+`:Ne.format(e),Fe=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?T(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Pe(t,n))};function Ie(e=document){let t=w(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(D.has(e))continue;let t=Le(e);D.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function k(e){let t=e instanceof Element?E(e,`[data-wui-server]`,HTMLElement):null;return t&&D.get(t)||null}function Le(i){let a=T(i,`.table-wrap`,HTMLElement),o=a?T(a,`:scope > table`,HTMLTableElement):null,l=i.dataset.src;if(!a||!o||!l)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let u=T(a,`:scope > [data-wui-table-state]`,HTMLElement),d=T(i,`[data-wui-table-pager]`,HTMLElement),ee=T(i,`[data-wui-table-status]`,HTMLElement),f={urlState:i.dataset.urlState!==`false`,refreshOnSuccess:i.dataset.refreshOnSuccess!==`false`,filtersForm:i.dataset.filtersForm||null,filtersRegion:i.dataset.filtersRegion||null,searchInput:i.dataset.searchInput||null,loadingText:i.dataset.loadingText||C().loadingText,errorText:i.dataset.errorText||C().errorText,timeoutMs:ge(i.getAttribute(`data-wui-timeout`))??3e4},p=new URL(l,window.location.href),ce=i.dataset.totalSrc||null,le=ce===null?null:new URL(ce,window.location.href),me=/* @__PURE__ */ new Set([...p.searchParams.keys(),...le?.searchParams.keys()??[]]),_e=o.hasAttribute(`data-app-datatable-selectable`),v=/* @__PURE__ */ new Set,y=!1,ve=he(),ye=new AbortController,b={signal:ye.signal},be=T(o,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),x=n(be,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),S=Ae(x),D=null,Ne=null,Ie=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))me.has(n)||t.append(n,r);return t},k=e=>Ie(new URL(e,window.location.href).search),Le=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Re=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)me.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},ze=e=>Re(p,e),Be=(e,t)=>{let n=new URLSearchParams(e);return n.has(`page`)&&n.set(`page`,String(t.page)),n.has(`pageSize`)&&n.set(`pageSize`,String(t.pageSize)),n.has(`sortBy`)?t.sortBy?(n.set(`sortBy`,t.sortBy),n.set(`sortOrder`,t.sortOrder)):(n.delete(`sortBy`),n.delete(`sortOrder`)):n.delete(`sortOrder`),n},A=Be(f.urlState?Ie(window.location.search):new URLSearchParams,S);f.urlState&&Le(A)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,Le(A));let j=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),N=e=>{ee&&(ee.textContent=e)},He=e=>{if(e.pending)return e.rowCount===0?C().emptyLabel:c(C().pageTextPending,{page:e.page});if(e.total===0)return C().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Pe(e.total,!0):`${e.total}`;return c(e.total===1?C().pageTextOne:C().pageTextOther,{page:e.page,pages:t,total:n})},Ue=()=>w(o,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),We=e=>{if(_e&&w(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Ge=e=>{let t=i.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},Ke=e=>{if(_e){xe(e);for(let t of e){let e=T(t,`.${_} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(y&&v.add(t.dataset.rowKey),e.checked=v.has(t.dataset.rowKey))}Ce(o)}Ge(e);let t=Ue();if(o.classList.contains(`wui-table-stack`))for(let n of e)[...n.cells].forEach((e,n)=>{let r=t[n]?.textContent?.trim();r&&!e.hasAttribute(`data-label`)&&e.setAttribute(`data-label`,r)});t.forEach((t,n)=>{if(t.classList.contains(`wui-col-hidden`))for(let t of e)t.cells[n]?.classList.add(`wui-col-hidden`)})},P=e=>Ke(w(e,`:scope > tr`,HTMLTableRowElement)),F=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},I=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),qe=(e,t)=>{if(!u)return;let n=T(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(u),(t.pending?t.rowCount:t.total)===0&&n?(u.replaceChildren(n.content.cloneNode(!0)),u.hidden=!1):(u.replaceChildren(),u.hidden=!0)},Je=e=>{d&&(I(d),d.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),d.hidden=!1)},Ye=e=>{let t=f.filtersRegion&&e?T(document,f.filtersRegion,HTMLElement):null;return t&&e&&(I(t),t.replaceChildren(e.content.cloneNode(!0))),t},Xe=0,Ze=e=>{let t=Ae(e);t.pending&&Object.assign(t,{total:S.total,totalCapped:S.totalCapped});let n=t.sortBy!==S.sortBy||t.sortOrder!==S.sortOrder?ae(x.rows):null;Je(T(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),qe(e,t);let r=Ye(T(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));F(e),I(x),o.replaceChild(e,x),x=e,Xe+=1;let i=y&&t.total!==S.total;return S=t,i&&(y=!1),a.removeAttribute(`data-wui-table-error`),P(e),V(),ne(e.rows,n),i&&H(),r},Qe=e=>{let t=T(ue(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&We(t),t?document.importNode(t,!0):null},$e=(e,t=Ue())=>{let n=document.createElement(`tr`);for(let r=0;r<e;r++){let e=t[r],i=e?.classList.contains(`text-center`),a=!i&&(e?.classList.contains(`num`)||e?.classList.contains(`text-end`)||e?.classList.contains(`wui-cell-end`)),o=document.createElement(`td`);i?o.classList.add(`text-center`):a&&o.classList.add(e?.classList.contains(`num`)?`num`:`wui-cell-end`);let s=document.createElement(`span`);s.className=`skeleton`,s.setAttribute(`aria-hidden`,`true`);let c=i?44:a?56:60;s.style.cssText=`display:block;width:${c}%;height:12px;border-radius:6px`,o.append(s),n.append(o)}return n},et=()=>{if(x.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,Ue().length);x.replaceChildren(...Array.from({length:Te},()=>{let t=$e(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),u&&(u.hidden=!0)},tt=e=>{e?(a.setAttribute(`aria-busy`,`true`),et()):a.removeAttribute(`aria-busy`)},nt=e=>e===`forbidden`?C().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,se).networkCheckText:e===`network`?C().networkMessage:e===`timeout`?C().timeoutMessage:f.errorText,L=n=>{let r=nt(n);if(a.setAttribute(`data-wui-table-error`,n),d&&(d.hidden=!0),u){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`;let o=de(n===`forbidden`?`lock`:`alert-circle`,{size:24});o&&a.replaceChildren(o);let s=document.createElement(`div`);s.className=`empty-state-title`,s.textContent=r;let c=document.createElement(`div`);c.className=`empty-state-action`;let l=document.createElement(`button`);l.type=`button`,l.className=e(`primary`,`outline`,`sm`),l.dataset.wui=t,l.setAttribute(`data-wui-table-retry`,``),l.textContent=C().retryLabel,c.append(l),i.append(a,s,c),I(u),u.replaceChildren(i),u.hidden=!1}N(r)},R=()=>f.filtersForm?T(document,f.filtersForm,HTMLFormElement):null,z=async(e,t=`none`,{quiet:n=!1}={})=>{let r=new URLSearchParams(e);n||(D={query:r,mode:t},tt(!0),N(f.loadingText)),j(`wui:table:loading`,{query:r.toString()});let o=await ve.run(ze(r),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;n||tt(!1);let s=null;if(o.ok)try{s=Qe(o.html)}catch(e){h(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return n?oe(`A quiet server table refresh failed; the rows on screen are kept.`,e):L(e),j(`wui:table:error`,{status:o.status,kind:e,message:nt(e)}),o}let c=Ze(s);return A=Be(r,S),Me(R(),A),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,Le(A)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,Le(A)),n||N(He(S)),M().refresh(a),c&&M().refresh(c),S.pending?B():Fe(i,S.total,S.totalCapped),j(`wui:table:loaded`,{...S,query:A.toString()}),o},rt=e=>(e.delete(`page`),e),B=()=>{if(!le||!S.pending)return;let e=Xe;g(Re(le,A),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Xe)return;if(!t.ok){oe(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let n=T(ue(t.html),`div[data-wui-total]`,HTMLElement);if(!n){oe(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(O(n.dataset.page,-1)!==S.page||O(n.dataset.pageSize,-1)!==S.pageSize)return;let r=O(n.dataset.total,-1);if(r<0){oe(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=n.dataset.totalCapped===`true`,o=y&&r!==S.total;S={...S,total:r,totalCapped:a,pending:!1},o&&(y=!1);let s=T(n,`:scope > template[data-wui-pager]`,HTMLTemplateElement);s&&Je(s);let c=Ye(T(n,`:scope > template[data-wui-filters]`,HTMLTemplateElement));c&&M().refresh(c),Fe(i,S.total,S.totalCapped),N(He(S)),o&&H(),j(`wui:table:total`,{total:r,totalCapped:a})})},it=()=>w(o,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),V=()=>{for(let e of it()){let t=e.dataset.sortKey===S.sortBy;e.setAttribute(`aria-sort`,t?S.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of it())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=de(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let at=e=>{let t=rt(new URLSearchParams(A)),n=S.sortBy===e&&S.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),z(t,`push`)};o.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&at(t.dataset.sortKey??``)}),o.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?E(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&o.tHead?.contains(t)&&(e.preventDefault(),at(t.dataset.sortKey??``))});let H=()=>{Ce(o);let e=y?{selected:S.total,total:S.total,allMatching:y}:{selected:v.size,total:S.total};o.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};_e&&(we(o,(e,t)=>{for(let n of e){let e=E(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?v.add(e):v.delete(e))}t||(y=!1)}),o.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(y=!1),o.tHead?.contains(t))for(let e of w(x,`:scope > tr`,HTMLTableRowElement)){let n=T(e,`.${_} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?v.add(e.dataset.rowKey):v.delete(e.dataset.rowKey))}else{let e=E(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?v.add(e):v.delete(e)}H()}})),d&&(d.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),z(k(t.getAttribute(`href`)??``),`push`))}),d.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),z(k(t.value),`push`))}));let U=()=>{if(!f.searchInput)return null;let e=T(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?T(e,`input`,HTMLInputElement):null},W=()=>i.isConnected?!0:(ye.abort(),clearTimeout(Ne??void 0),!1),ot=(e,t)=>{let n=[...e.elements].filter(Ee),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Oe(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!De(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},st=(e,t)=>{let n=new Set([...e.elements].filter(Ee).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&fe.includes(e);for(let[e,t]of A)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of ot(e,t))a===``||i(n)||me.has(n)||r.append(n,a);let a=U();if(a){r.delete(pe);let e=a.value.trim();e&&r.set(pe,e)}return z(r,`push`)},ct=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),st(e.target,e.submitter))},b),document.addEventListener(`change`,e=>{if(!W()||!f.filtersForm||!(e.target instanceof Element))return;let t=E(e.target,f.filtersForm,HTMLFormElement);!t||e.target===U()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||st(t)},b);let lt=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of w(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of w(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(ke)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!W())return;let t=e.target instanceof Element?E(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!ct(t)||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=new URL(t.getAttribute(`href`)??``,window.location.href);if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;e.preventDefault();let r=rt(k(n.href));lt(t.closest(`form`),r),Me(t.closest(`form`),r),z(r,`push`)},b),document.addEventListener(`input`,e=>{if(!W())return;let t=U();t&&e.target===t&&(clearTimeout(Ne??void 0),Ne=setTimeout(()=>{if(!W())return;let e=rt(new URLSearchParams(A)),n=t.value.trim();n?e.set(pe,n):e.delete(pe),e.toString()!==A.toString()&&z(e,`replace`)},300))},b),f.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=Ie(window.location.search),t=U();t&&(t.value=e.get(`search`)??``),Me(R(),e),z(e,`none`)},b),document.addEventListener(`wui:modal:success`,()=>{W()&&f.refreshOnSuccess&&z(A,`none`)},b),u?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&D&&z(D.query,D.mode)});let G=e=>[...x.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=ue(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=w(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:G(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),i.push(n))}return Ke(i),M().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?C().actionForbiddenMessage:C().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&m(e,null)},mt=async({url:e,method:t=`POST`,body:n,key:i,row:o}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let s=i==null,c=s?null:G(String(i));if(!s&&!c)throw Error(`saveRow found no row with data-row-key="${i}" on this page.`);let l=Ue().filter(e=>!e.classList.contains(_)),d=o===void 0?c??$e(Math.max(1,l.length),l):r(o,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");c&&d!==c?c.replaceWith(d):c||x.insertBefore(d,x.firstChild),d!==c&&Ke([d]),u&&!a.hasAttribute(`data-wui-table-error`)&&(u.hidden=!0),m(d,`saving`);let ee=te(d),f=await g(e,{method:t.toUpperCase(),body:n});if(f.kind===`session`)return!1;if(f.ok){let e=ut(f.html),t=e&&d.isConnected?dt(e,d,s):null;return t?N(ie(te(t)||ee)):(await z(A,`none`),pt(d)),Ve(f,f.toastVariant||`success`),j(`wui:table:saved`,{key:t?.dataset.rowKey??(s?null:String(i)),added:s,status:f.status}),!0}let p=ft(f),ne=d;return c&&d!==c&&d.isConnected?(d.replaceWith(c),ne=c):s&&!o&&(d.remove(),ne=null,u?.childElementCount&&!x.querySelector(`:scope > tr`)&&(u.hidden=!1)),ne?.isConnected&&m(ne,`error`,p),f.kind!==`aborted`&&je(p,`danger`),N(re(ee,p)),j(`wui:table:failed`,{key:s?null:String(i),added:s,status:f.status,kind:f.kind,message:p}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=E(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?te(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&m(n,`saving`);let o=await g(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)pt(n);else{if(o.ok){Ve(o,o.toastVariant||`success`);let e=n?.isConnected?ut(o.html):null,t=e&&n?dt(e,n,!1):null;t?N(ie(te(t)||a)):(await z(A,`none`),pt(n))}else{let e=ft(o);je(e,`danger`),n?.isConnected&&m(n,`error`,e),N(re(a,e))}j(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return o.addEventListener(`click`,e=>{let t=e.target instanceof Element?E(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&x.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),We(x),F(x),_e&&Se(o),P(x),V(),S.pending&&(N(He(S)),B()),{el:i,reload:async e=>{let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?null:z(A,`none`,{quiet:t})},query:()=>new URLSearchParams(A),setQuery:e=>{let t=new URLSearchParams(A);for(let[n,r]of Object.entries(e??{})){t.delete(n);for(let e of Array.isArray(r)?r:[r])e!=null&&e!==``&&t.append(n,String(e))}return e&&`page`in e||t.delete(`page`),z(t,`push`)},saveRow:mt,setActiveRow:e=>{i.dataset.activeRowKey=e==null?``:String(e),Ge(w(x,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...v],count:()=>y?S.total:v.size,allMatching:()=>y,selectAllMatching:()=>{if(S.pending)oe(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{y=!0;for(let e of w(x,`:scope > tr`,HTMLTableRowElement)){let t=T(e,`.${_} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&v.add(e.dataset.rowKey))}H()}},clear:()=>{y=!1,v.clear();for(let e of w(x,`:scope > tr > .${_} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;H()}}}}var Re=8e3,ze=()=>s(`toast`,ee),Be=[`success`,`info`,`warning`,`danger`],A=e=>Be.some(t=>t===e);function j(e){if(!A(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function M(){return n(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Ve(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?M().toast(e.message,{variant:j(t),duration:Re,action:{label:n.label,onClick:()=>N(n)}}):M().toast(e.message,{variant:j(t)})}async function N(e){let t=await g(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Ve(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&k(e)?.reload()}else M().toast(t.message||ze().failedText,{variant:`danger`})}}var He=`wui-remote-modal`,Ue=`wui-remote-drawer`,We=Object.freeze({sm:360,md:480,lg:640,xl:720}),Ge=`wui-modal-fullscreen`,Ke=`wui-modal-wide`,P=Object.freeze({sm:380,md:440,lg:640,xl:880,wide:1080}),F=()=>s(`modal`,f),I=e=>ge(e?.getAttribute(`data-wui-timeout`)??null)??3e4,qe=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Je=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Ye=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Xe=`invalid`,Ze=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,Qe=`[data-wui-modal-content]`,$e=`[data-wui-pane-close], [data-wui-dismiss]`,et=()=>i(`button`,{type:`button`,class:`wui-modal-close`,"data-wui-dismiss":!0,"aria-label":F().closeLabel},le({width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`},[[`path`,{d:`M18 6 6 18M6 6l12 12`}]])),tt=/* @__PURE__ */ new WeakMap,nt=/* @__PURE__ */ new WeakSet;function L(e,t){if(e==null)throw TypeError(`The remote modal needs ${t}, and the page does not have it.`);return e}var R=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},z=(e,t,n)=>L(R(e,t),n),rt=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),B=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),it=e=>typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`,V=(e,t)=>{let n=e instanceof Element?e.closest(t):null;return n instanceof HTMLElement?n:null},at=e=>ce(P,e),H=e=>ce(We,e);function U(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(at(e))return e===`wide`?{px:P.wide,wide:!0}:{px:P[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, wide, fullscreen or a px number.`)}var W=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};if(e.classList.contains(`wui-modal-wide`))return{px:P.wide,wide:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:P.md}},ot=(e,t)=>{e.classList.toggle(Ge,!!t.fullscreen),e.classList.toggle(Ke,!t.fullscreen&&!!t.wide),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},st=[`center`,`top`];function ct(e){if(e==null||e===``)return null;if(H(e))return{px:We[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var lt=e=>e.container===`drawer`,G=e=>e.container===`pane`,ut=e=>e.container!==`modal`,dt=(e,t)=>lt(e)?ct(t):U(t),ft=e=>{let t=typeof e==`string`?document.querySelector(e):e,n=t instanceof HTMLElement?t:null;return n?.matches(`[data-wui-pane-host]`)?n:null},pt=e=>G(e)?e.shell:z(e.shell,`.modal-dialog`,`a dialog frame`);function mt(e=`modal`){let t=e===`drawer`,n=t?Ue:He,r=document.getElementById(n);if(r)return r;let a=document.createElement(`wui-modal`);a.id=n,a.setAttribute(`data-wui`,`AppModal`);let o=document.createElement(`dialog`);return o.className=t?`modal wui-modal-shell wui-remote-drawer`:`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${t?We.md:P.md}px`),o.replaceChildren(i(`div`,{class:t?`modal-dialog wui-remote-drawer-dialog`:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal`}))),a.append(o),document.body.appendChild(a),a}var ht=e=>i(`div`,{class:`wui-modal-header`},i(`div`,{class:`wui-modal-heading`},i(`div`,{class:`wui-modal-headtext`},i(`div`,{class:`wui-modal-title`},e))),et()),gt=e=>i(`div`,{class:`modal-content wui-modal`,"aria-busy":`true`},ht(e),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-loading`,role:`status`},i(`span`,{class:`visually-hidden`},F().loadingLabel),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton`}),i(`div`,{class:`skeleton wui-modal-skeleton wui-modal-skeleton--short`})))),_t=(n,r)=>{let a={forbidden:F().forbiddenMessage,networkCheck:s(`httpFailure`,se).networkCheckText,client:F().clientMessage,server:F().serverMessage,network:F().networkMessage,timeout:F().timeoutMessage};return i(`div`,{class:`modal-content wui-modal`,"data-wui-modal-error":r},ht(n),i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-modal-state`,role:`alert`},i(`p`,{class:`wui-modal-state-title`},F().errorTitle),i(`p`,{class:`wui-modal-state-text`},a[r]||F().serverMessage),i(`div`,{class:`wui-modal-state-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":!0,"data-wui":t},F().closeLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-wui-modal-retry":!0,"data-wui":t},F().retryLabel)))))},K=e=>R(e.shell,`.modal-content`),vt=e=>r(e.cloneNode(!0),HTMLElement,`a card copy is not an element`);function yt(e){e&&e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}))}function bt(e,t){let n=K(e),r=n?St(n):/* @__PURE__ */ new Map;yt(n),n?n.replaceWith(t):pt(e).appendChild(t),Ct(t,r),M().refresh()}var xt=`input[type="file"][name]`;function St(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function Ct(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLInputElement))continue;let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var wt=e=>G(e)?!e.shell.hidden:e.host.hasAttribute(`open`);function Tt(e,t,n=!1){let r=t?R(e,Ye):null,i=r?r.matches(qe)?r:R(r,qe)||r:null;if(!i&&n)i=R(e,`[data-autofocus]`)||R(e,Je)||R(e,`.wui-modal-close`);else if(!i){let t=rt(e,qe);i=R(e,`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function Et(e,t){let n=R(e.shell,`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),pt(e).appendChild(n)),n.textContent=``,n.textContent=t}var Dt=e=>{let t=R(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},Ot=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function kt(e,t,n,r){let i={...r,container:e.container};Ot(t,`wui:modal:${n}`,i),lt(e)&&Ot(t,`wui:drawer:${n}`,i),G(e)&&Ot(t,`wui:pane:${n}`,i)}var At=e=>e.matches(`[data-wui-pane-host]`)?`pane`:z(e,`dialog`,`a dialog`).classList.contains(`wui-remote-drawer`)?`drawer`:`modal`,jt=e=>L(e.host.closest(`wui-modal`),`a wui-modal host`);function Mt(e){let t=tt.get(e);if(t)return t;let n=At(e),r=n===`pane`?e:z(e,`dialog`,`a dialog`),a=K({shell:r}),o={host:e,shell:r,container:n,queue:he(),defaultSize:W(r),defaultLabel:r.getAttribute(`aria-label`),placeholder:a?vt(a):i(`div`,{class:`modal-content wui-modal`}),remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return tt.set(e,o),e.addEventListener(`submit`,e=>Qt(o,e)),e.addEventListener(`click`,e=>{V(e.target,`[data-wui-modal-retry]`)&&o.session&&(e.preventDefault(),J(o,o.session))}),G(o)&&e.addEventListener(`click`,t=>{let n=V(t.target,$e);n&&e.contains(n)&&o.session&&q(o,o.session,`dismissed`,null)}),e.addEventListener(`wui-modal-close`,t=>{t.target===e&&t instanceof CustomEvent&&Jt(t.detail,`reason`)===`escape`&&e.querySelector(`form[data-wui-submitting]`)&&t.preventDefault()}),e.addEventListener(`wui-modal-closed`,t=>{t.target===e&&It(o)}),e.addEventListener(`wui-modal-opened`,t=>{if(t.target!==e)return;let n=K(o);o.session&&n?.matches(Qe)&&!n.contains(document.activeElement)&&Tt(n,!1,ut(o))}),o.remoteUrl&&e.addEventListener(`wui-modal-open`,t=>{t.target===e&&Lt(o,t)}),o}function Nt(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r=()=>void 0,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:{el:e.shell,closed:i,close:()=>q(e,a,`dismissed`,null),reload:()=>J(e,a)}};return e.session=a,a}function q(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},G(e)?Ft(e,t):Pt(e))}function Pt(e){let t=jt(e);t.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:`dismiss`}}))&&t.hide()}function Ft(e,t){let n=e.shell,{status:r,detail:i}=L(t.closing,`the closing state`),a=n.contains(document.activeElement);e.queue.abort(),e.session=null,yt(K(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),kt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function It(e){let t=e.session;if(e.queue.abort(),e.session=null,Dt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),kt(e,e.shell,`closed`,{status:n.status,url:t.url});let r=document.activeElement;t.trigger?.isConnected&&(!r||r===document.body||e.shell.contains(r))&&t.trigger.focus?.()}e.cache||(bt(e,vt(e.placeholder)),e.loadedUrl=null,ot(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Lt(e,t){let n=Jt(t instanceof CustomEvent?t.detail:null,`trigger`),r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=Nt(e,i,{trigger:r});a.explicitSize=Rt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&ot(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&bt(e,vt(e.placeholder)),J(e,a,{keepPlaceholder:!0}))}function Rt(e,t){try{return dt(e,t)}catch(e){return h(e),null}}async function J(e,t,{keepPlaceholder:n=!1}={}){n||bt(e,gt(t.options.title||zt(e)));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate,timeoutMs:I(t.trigger)});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if(r.kind===`ok`&&Ut(e,t,r.html,!1))return e.loadedUrl=t.url,kt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return bt(e,_t(t.options.title||zt(e),i)),wt(e)&&Tt(L(K(e),`a card`),!1,ut(e)),kt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var zt=e=>K(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Bt=`/_content/Webority.Ui.Razor/js/`,Vt=e=>new URL(e,window.location.href).pathname.includes(Bt);function Ht(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Ut(e,t,n,r){let i=ue(n),a=!1;for(let e of i.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Vt(t)?Ht(t):a=!0}a&&oe(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let o=R(i,Qe);if(!o)return h(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(bt(e,o),r||Dt(e),!G(e)){ot(e.shell,t.explicitSize||Rt(e,o.getAttribute(`data-wui-size`))||e.defaultSize);let n=o.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return wt(e)&&Tt(o,r,ut(e)),!0}var Wt=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Gt(e,t,n){let r=[...e.elements].filter(e=>e.matches(Wt));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.prepend(i(`span`,{class:`spinner-border spinner-border-sm me-2`,"aria-hidden":`true`,"data-wui-submit-spinner":!0})))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Kt(e){for(let t of e.querySelectorAll(Ze))t.remove();for(let t of e.querySelectorAll(Ye))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var qt=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`)),Jt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Yt(e){if(!e||e.status<400||e.status>499||!e.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await e.text())}catch{return null}let n=e=>typeof e==`string`?e.trim():``,r=n(Jt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=qt.has(r.toLowerCase())||r.toLowerCase()===i;return n(Jt(t,`message`))||n(Jt(t,`detail`))||(r&&!a?r:null)}function Xt(e,t,n,r){let i={forbidden:F().forbiddenMessage,networkCheck:s(`httpFailure`,se).networkCheckText,client:F().clientMessage,server:F().serverMessage,network:F().networkMessage,timeout:F().timeoutMessage},a=t.closest(`.wui-modal-body`)||t;a.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Kt(a);let o=document.createElement(`div`);o.className=`alert alert-danger wui-modal-submit-error`,o.setAttribute(`role`,`alert`),o.setAttribute(`data-wui-modal-submit-error`,``),o.textContent=`${F().submitFailedMessage} ${r||i[n]||F().serverMessage}`,a.prepend(o),Et(e,o.textContent)}var Zt=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Qt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(Qe)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=`submitter`in t&&(t.submitter instanceof HTMLButtonElement||t.submitter instanceof HTMLInputElement)?t.submitter:null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;Gt(n,i,!0);let l;try{l=await e.queue.run(c?Zt(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate,timeoutMs:I(r.trigger)})}catch(t){h(t),e.session===r&&n.isConnected&&(Gt(n,i,!1),Xt(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&Gt(n,i,!1),l.kind===`ok`&&l.result===`success`){$t(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`ok`&&l.html){let t=l.result===Xe;if(Ut(e,r,l.html,t)){if(t){let t=L(K(e),`a card`).querySelector(Ze)?.textContent?.replace(/\s+/g,` `).trim();Et(e,t||F().invalidMessage)}return}}let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await Yt(l.response);e.session===r&&Xt(e,n,u,d)}function $t(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!fn(a))throw TypeError(`Unknown toast variant "${a}". Use ${dn.join(`, `)}.`);let o={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};i&&!t.options.navigate?Nn(r,a):r&&M().toast(r,{variant:a}),kt(e,t.trigger?.isConnected?t.trigger:document,`success`,o),t.options.onSuccess?.(o,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i);let s=n.next;s&&!i?(t.url=s,t.method=`GET`,t.body=void 0,J(e,t)):n.keepOpen?n.html&&Ut(e,t,n.html,!1):q(e,t,`success`,o)}function en(e){let t=V(e.target,`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?cn(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{it(e)||h(e)}):t.hasAttribute(`data-wui-modal`)?rn(t.getAttribute(`data-wui-modal`)??``,{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{it(e)||h(e)}):on(t.getAttribute(`data-wui-drawer`)??``,{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{it(e)||h(e)})))}function tn(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=V(e.target,sn);if(!t)return;let n=tt.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`wui-modal[open]`)&&(t.querySelector(`form[data-wui-submitting]`)||(e.preventDefault(),q(n,n.session,`dismissed`,null)))}function nn(e=document){let t=e instanceof Document?e:L(e.ownerDocument,`an owner document`);nt.has(t)||(nt.add(t),t.addEventListener(`click`,en),t.addEventListener(`keydown`,tn));let n=rt(e,`wui-modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`wui-modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)Mt(e)}function rn(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=t.container===`drawer`,r=n?ct(t.size):U(t.size),i=t.placement||`center`;if(!st.includes(i))throw TypeError(`WUI.modal.load: unsupported placement "${i}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(B());let a=mt(n?`drawer`:`modal`);nn(document);let o=Mt(a),s=wt(o),c=Nt(o,e,t);c.explicitSize=r,ot(o.shell,r||o.defaultSize),n||z(o.shell,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,i===`center`),t.title&&o.shell.setAttribute(`aria-label`,t.title),s||(a.toggleAttribute(`static`,t.staticBackdrop!==!1),a.toggleAttribute(`no-escape`,t.closeOnEscape===!1));let l=s?Promise.resolve():new Promise(e=>a.addEventListener(`wui-modal-opened`,()=>e(),{once:!0})),u=J(o,c);return s||jt(o).show(),an(o,c,t,l,u,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function an(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),q(e,t,`dismissed`,{aborted:!0})),i(B())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw B();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function on(e,t={}){return rn(e,{...t,container:`drawer`,placement:void 0})}var sn=`[data-wui-pane-host]`;function cn(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=ft(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(B());nn(document);let r=Mt(n),i=Nt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=J(r,i);return an(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function ln(e){let t=ft(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=tt.get(t);n?.session&&q(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,un=Object.freeze([`danger`]),dn=Object.freeze([`success`,`info`,`warning`,`danger`]),fn=e=>dn.some(t=>t===e),pn=`wui.flash`,X=()=>s(`confirmDialog`,d),mn=/* @__PURE__ */ new WeakSet,hn=/* @__PURE__ */ new WeakSet,gn=null,_n=null,vn=!1,yn=(e,t)=>{e&&M().toast(e,{variant:t})};function bn(){let r=document.getElementById(Y);if(r)return n(r.closest(`wui-modal`),`#${Y} must be a wui-modal.`);let a=document.createElement(`wui-modal`);a.id=Y;let o=document.createElement(`dialog`);return o.className=`modal wui-modal-shell`,o.style.setProperty(`--wui-modal-max-width`,`${P.md}px`),o.replaceChildren(i(`div`,{class:`modal-dialog modal-dialog-centered wui-rb-dialog`},i(`div`,{class:`modal-content wui-modal wui-confirm`},i(`div`,{class:`wui-modal-body`},i(`div`,{class:`wui-confirm-content`},i(`span`,{class:`wui-confirm-icon`},i(`wui-status-icon`,{tone:`info`,size:120})),i(`h3`,{class:`wui-confirm-title`,tabindex:-1,"data-autofocus":``}),i(`p`,{class:`wui-confirm-msg`}))),i(`div`,{class:`wui-modal-footer`},i(`div`,{class:`wui-confirm-actions`},i(`button`,{type:`button`,class:e(`primary`,`soft`,`md`),"data-wui-dismiss":``,"data-wui":t},X().cancelLabel),i(`button`,{type:`button`,class:e(`primary`,`solid`,`md`),"data-app-confirm":``,"data-wui":t})))))),a.append(o),document.body.appendChild(a),a}function xn(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!un.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);Sn({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`},t)}function Sn({title:e,message:t,label:r,danger:i},a){let o=bn(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${Y} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${Y}"> without confirm-href, or leave the dialog to the library.`);let l=o.querySelector(`.wui-confirm-msg`);l||(l=document.createElement(`p`),l.className=`wui-confirm-msg`,s.after(l));let u=e||X().confirmTitle;s.textContent=u,l.textContent=t,c.textContent=r||X().confirmLabel,c.classList.toggle(`btn-danger`,i),c.classList.toggle(`btn-primary`,!i),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,i?`delete`:`info`),n(o.querySelector(`dialog`),`#${Y} has no <dialog>.`).setAttribute(`aria-label`,u),_n=a,vn=!1,o.show()}var Cn=(e,t)=>{gn=e;try{t()}finally{gn=null}},wn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},Tn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=`message`in e?e.message:void 0;if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:wn(e,`title`),message:t,label:wn(e,`label`),tone:wn(e,`tone`)}};function En(e,t,n){let{title:r,message:i,label:a,tone:o}=Tn(t);if(o!=null&&!un.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Yn(e.ownerDocument),Sn({title:r,message:i,label:a,danger:o===`danger`},()=>Cn(e,n))}var Dn=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,On=e=>{r(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function kn(e){let t=a(e.target,`[data-wui-confirm]:not(form)`);t&&t!==gn&&!Dn(t)&&(e.preventDefault(),e.stopImmediatePropagation(),xn(t,()=>Cn(t,()=>On(t))))}function An(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===gn||e.submitter&&e.submitter===gn||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter instanceof HTMLButtonElement||e.submitter instanceof HTMLInputElement?e.submitter:null,r=n?.form===t?n:void 0;xn(t,()=>Cn(t,()=>t.requestSubmit(r)))}function jn(e){let t=a(e.target,`#${Y} [data-app-confirm]`);t&&!t.hasAttribute(`disabled`)&&_n&&(vn=!0,n(t.closest(`wui-modal`),`#${Y} is missing around its confirm button.`).hide())}function Mn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=vn?_n:null;_n=null,vn=!1,t?.()}function Nn(e,t){e&&window.sessionStorage.setItem(pn,JSON.stringify({message:e,variant:t}))}var Pn=e=>e===`forbidden`?X().forbiddenMessage:e===`networkCheck`?s(`httpFailure`,se).networkCheckText:e===`network`?X().networkMessage:e===`timeout`?X().timeoutMessage:X().failedMessage;function Fn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&k(e)?.reload()}var In=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function Ln(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return Rn(t,e)}async function Rn(e,t,n){let r=t.getAttribute(`data-wui-post-reload`);if(r!==null&&r!==`page`)throw TypeError(`data-wui-post-reload="${r}" is not supported. Use page, or leave it off to reload the server tables.`);In(t,!0),t.setAttribute(`aria-busy`,`true`);let i=ge(t.getAttribute(`data-wui-timeout`))??3e4,a=await g(e,{method:`POST`,body:n,timeoutMs:i});if(a.kind===`session`||a.kind===`aborted`)return;let o=a.toastVariant||`success`;a.ok&&(a.redirect||r===`page`)?(Nn(a.message,o),a.redirect?window.location.assign(a.redirect):window.location.reload()):(In(t,!1),t.removeAttribute(`aria-busy`),a.ok?(Ve(a,o),Fn()):yn(a.message||Pn(a.kind),`danger`))}function zn(e,t){In(e,!1),e.removeAttribute(`aria-busy`),h(t),yn(X().failedMessage,`danger`)}function Bn(e){let t=a(e.target,`[data-wui-post]`);t&&(e.preventDefault(),Dn(t)||t.getAttribute(`aria-busy`)===`true`||Ln(t).catch(e=>zn(t,e)))}function Vn(e){let t=a(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let r=n(e.submitter||t.querySelector(`button:not(.repeater-add):not(.repeater-remove)`),`A data-wui-post-form needs a submit button to report its result on.`);if(r.getAttribute(`aria-busy`)===`true`)return;let i=new URL(n(t.getAttribute(`action`),`A data-wui-post-form needs an action attribute to post to.`),document.baseURI).href;Rn(i,r,new FormData(t)).catch(e=>zn(r,e)),t.closest(`wui-dropdown`)?.hide()}var Hn=(e,t)=>{e.disabled=!1,e.removeAttribute(`aria-busy`),t&&m(t,null)};async function Un(e,t){let n=e.dataset.url;if(!n)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);e.disabled=!0,e.setAttribute(`aria-busy`,`true`),t&&m(t,`saving`);let r=ge(e.getAttribute(`data-wui-timeout`))??3e4,i=await g(n,{method:(e.dataset.method||`post`).toUpperCase(),timeoutMs:r});if(i.kind===`session`)return;if(i.kind===`aborted`){Hn(e,t);return}if(i.ok){Nn(i.message,i.toastVariant||`success`),i.redirect?window.location.assign(i.redirect):window.location.reload();return}let a=i.message||Pn(i.kind);e.disabled=!1,e.removeAttribute(`aria-busy`),t&&m(t,`error`,a),yn(a,`danger`)}function Wn(e){let t=a(e.target,`[data-wui-row-action]`);if(!(t instanceof HTMLButtonElement)||t.closest(`[data-wui-server]`)||(e.preventDefault(),t.disabled||t.getAttribute(`aria-busy`)===`true`))return;let n=t.closest(`tr`);Un(t,n).catch(e=>{Hn(t,n),h(e),yn(X().failedMessage,`danger`)})}function Gn(){let e=window.sessionStorage.getItem(pn);if(!e)return;window.sessionStorage.removeItem(pn);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=`message`in t?t.message:void 0,r=`variant`in t?t.variant:void 0;if(typeof r!=`string`||!fn(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);yn(n,r)}function Kn(e){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-flash]`)]:[];e instanceof Element&&e.matches(`[data-wui-flash]`)&&t.unshift(e);for(let e of t){let t=e.getAttribute(`data-wui-flash-variant`)||`success`;if(!fn(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${dn.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),yn(n,t)}}var qn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Jn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=qn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Yn(e){hn.has(e)||(hn.add(e),e.addEventListener(`click`,jn),e.addEventListener(`wui-modal-closed`,Mn))}function Xn(e=document){let t=e instanceof Element?e.ownerDocument:e;mn.has(t)||(mn.add(t),t.addEventListener(`click`,kn,!0),t.addEventListener(`submit`,An,!0),Yn(t),t.addEventListener(`click`,Bn),t.addEventListener(`click`,Wn),t.addEventListener(`submit`,Vn),t.addEventListener(`change`,Jn),Gn()),Kn(e)}var Zn=()=>s(`unsavedChanges`,u),Qn=`form[data-wui-unsaved]`,$n=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,er=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,tr=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),nr=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),rr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,ir=e=>rr(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,ar=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,or=e=>typeof e==`object`&&!!e,sr=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function cr(e){let t=JSON.parse(e);if(!sr(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,lr=/* @__PURE__ */ new WeakSet,ur=e=>`${e.name}:${e.size}:${e.lastModified}`,dr=e=>[...e.querySelectorAll(Qn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)ar(n)&&!ir(n)&&(rr(n)&&tr.has(n.type)||(n instanceof HTMLInputElement&&(n.type===`checkbox`||n.type===`radio`)?t.push([n.name,n.value,n.checked]):n instanceof HTMLInputElement&&n.type===`file`?t.push([n.name,[...n.files||[]].map(ur)]):n instanceof HTMLSelectElement&&n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):n instanceof HTMLFieldSetElement||n instanceof HTMLObjectElement?t.push([n.name,null]):t.push([n.name,`value`in n?n.value:null])));return JSON.stringify(t)}function fr(e){return Q(e)}function pr(e,t){let n=/* @__PURE__ */ new Map,r=cr(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=cr(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function mr(e){for(let t of e.elements)if(rr(t)&&t.name&&!ir(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!nr.has(t.type)){if(t.value.trim()!==``)return!0}else if(t instanceof HTMLInputElement&&t.type===`file`&&(t.files?.length??0)>0)return!0}return!1}var hr=e=>({saved:e.querySelector($n)&&mr(e)?null:Q(e),engaged:!1,discarded:!1});function gr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var _r=(e,t)=>dr(e).filter(e=>e!==t&&gr(e));function vr(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Zn().message;En(e,{title:Zn().title,message:r,label:Zn().leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function yr(e){if(e.matches(er))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=e.getAttribute(`href`);if(n===null)return!1;let r=new URL(n,window.location.href);if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=window.location;return!(r.hash&&r.origin===i.origin&&r.pathname===i.pathname&&r.search===i.search)}function br(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function xr(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=a(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!yr(n))return;let r=_r(n.ownerDocument,null);r.length&&(e.preventDefault(),vr(n,r,()=>n.click()))}function Sr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!br(t,e.submitter))return;let n=_r(t.ownerDocument,t);if(n.length){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;vr(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function Cr(e){_r(document,null).length&&e.preventDefault()}function wr(e){let t=e.target,n=a(t,Qn);return n instanceof HTMLFormElement?n:null}function Tr(e){let t=wr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function Er(e){let t=wr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function Dr(e){for(let t of dr(e)){let e=Z.get(t);e?.saved&&(e.saved=pr(t,e.saved))}}function Or(e){let t=or(e)?e.handle:void 0;return or(t)?t.el:void 0}function kr(e){if(!(e instanceof CustomEvent))return;let t=Or(e.detail);if(t instanceof Element)for(let e of dr(t))jr(e)}function Ar(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!lr.has(t)){lr.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,Tr,!0);for(let e of[`input`,`change`])t.addEventListener(e,Er,!0);t.addEventListener(`click`,xr),t.addEventListener(`submit`,Sr),t.addEventListener(`wui:modal:success`,kr),t.addEventListener(o,()=>Dr(t)),n(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,Cr)}let r=dr(e);e instanceof HTMLFormElement&&e.matches(Qn)&&r.unshift(e);for(let e of r)Z.has(e)||Z.set(e,hr(e))}function jr(e){if(!(e instanceof HTMLFormElement)||!e.matches(Qn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var Mr=()=>s(`drawer`,l),Nr=`wui:drawer:discard`,Pr=`wui-drawer[confirm-discard]`,Fr=`wui-modal`,Ir=`data-wui-no-discard`,Lr=`.wui-drawer-discard`,Rr=`input, select, textarea`,zr=e=>typeof e==`object`&&!!e||typeof e==`function`;function Br(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Vr(e,t){return a(e,t)}var Hr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Ur=/* @__PURE__ */ new WeakSet,Wr=/* @__PURE__ */ new WeakSet;function Gr(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Kr(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,Gr(e,`danger`,`solid`,`data-wui-discard-confirm`,Mr().discardLabel),Gr(e,`primary`,`soft`,`data-wui-discard-keep`,Mr().keepLabel)),n}function qr(e){if(!(e instanceof Element))return null;let t=e.closest(Pr);if(t)return t;let n=e.closest(Fr);return n&&Xr(n).length?n:null}function Jr(e){return e.closest(Pr)??e.closest(Fr)}function Yr(e,t){return t.hasAttribute(Ir)||e.hasAttribute(Ir)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Xr(e){return e.matches(Pr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Yr(t,e))}function Zr(e){let t=$.get(e);return t!=null&&fr(e)!==t}function Qr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,n(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),Wr.add(t),t}function $r(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Wr.add(t),t}function ei(e){let t=e.querySelector(`[data-wui-discard-confirm]`);if(!(t instanceof HTMLElement))throw Error(`The discard prompt has no confirm button.`);t.focus()}function ti(e,t,n){let r=e.querySelector(Lr);if(r){ei(r);return}let i=Kr(e.ownerDocument,t),a;if(e.matches(Pr))a=e.querySelector(`.wui-drawer-footer`)??Qr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??$r(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`)??e.querySelector(`.wui-modal-footer`)??$r(e),a.prepend(i)}a.classList.add(`wui-drawer-discarding`),ei(i)}function ni(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),Wr.has(t)&&t.remove()}function ri(e){for(let t of Xr(e))for(let e of t.querySelectorAll(Rr))if(Hr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function ii(e){let t=qr(e.target);if(t)for(let e of Xr(t))$.get(e)??$.set(e,fr(e))}function ai(e){for(let t of Br(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,pr(t,e))}}function oi(e){let t=e.target;t instanceof HTMLFormElement&&qr(t)&&$.set(t,fr(t))}function si(e){if(!zr(e))return;let t=`handle`in e?e.handle:void 0;if(zr(t))return`el`in t?t.el:void 0}function ci(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=si(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function li(e){let t=e.target;t instanceof Element&&t.matches(Pr)&&[...Xr(t)].some(Zr)&&(e.preventDefault(),ti(t,t.getAttribute(`confirm-discard`),null))}function ui(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Fr))return;let n=[...Xr(t)].find(Zr);n&&(e.preventDefault(),ti(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Mr().confirmDiscard,n))}function di(e){let t=n(e.closest(Lr),`The discard button is outside its prompt.`),r=Jr(t);if(ni(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Xr(r))$.set(e,fr(e));r.dispatchEvent(new CustomEvent(Nr,{bubbles:!0})),r.matches(Pr)?n(r.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():n(r.closest(`wui-modal`),`The discarded dialog is not a wui-modal.`).hide()}function fi(e){let t=n(e.closest(Lr),`The keep button is outside its prompt.`),r=Jr(t);if(ni(t),!r)throw Error(`The discard prompt is outside its drawer or modal.`);ri(r)}function pi(e){let t=Vr(e.target,`[data-wui-discard-confirm]`);if(t){di(t);return}let n=Vr(e.target,`[data-wui-discard-keep]`);n&&fi(n)}function mi(e=document){let t=e instanceof Document?e:e.ownerDocument;Ur.has(t)||(Ur.add(t),t.addEventListener(`focusin`,ii),t.addEventListener(`pointerdown`,ii),t.addEventListener(`submit`,oi),t.addEventListener(o,ai),t.addEventListener(`wui:modal:success`,ci),t.addEventListener(`wui:modal:loaded`,ci),t.addEventListener(`wui-drawer-close`,li,!0),t.addEventListener(`wui-modal-close`,ui),t.addEventListener(`click`,pi))}export{Ie as S,cn as _,Ar as a,Ve as b,un as c,En as d,Xn as f,rn as g,on as h,fr as i,pn as l,nn as m,Kr as n,jr as o,ln as p,mi as r,Y as s,Nr as t,dn as u,Re as v,k as x,N as y};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"../inlineEditText-DRBhMnam.js";import{t as i}from"../WuiInlineEdit-p0cm_i90.js";e(`wui-inline-edit`,i);export{r as INLINE_EDIT_SAVED_MS,t as INLINE_EDIT_TYPES,i as WuiInlineEdit,n as inlineEditText};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"../inlineEditText-DRBhMnam.js";import{t as i}from"../WuiInlineEdit-D7AuEv1R.js";e(`wui-inline-edit`,i);export{r as INLINE_EDIT_SAVED_MS,t as INLINE_EDIT_TYPES,i as WuiInlineEdit,n as inlineEditText};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSavedViews-BKpnSd-Y.js";e(`wui-saved-views`,t);export{t as WuiSavedViews};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSavedViews-BR6ZHd9Y.js";e(`wui-saved-views`,t);export{t as WuiSavedViews};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSelect-iUXaHKw5.js";e(`wui-select`,t);export{t as WuiSelect};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiSelect-CNff3FNi.js";e(`wui-select`,t);export{t as WuiSelect};