@webority/ui-elements 0.176.0 → 0.177.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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/WuiCommentThread-e5t7HceL.js +1 -0
  3. package/dist/WuiDateRange-BnEJ2WpL.js +1 -0
  4. package/dist/{WuiInlineEdit-B7VCQXeG.js → WuiInlineEdit-p0cm_i90.js} +1 -1
  5. package/dist/{WuiMarkdown-DsN4YbiZ.js → WuiMarkdown-DRtGPxQX.js} +1 -1
  6. package/dist/WuiMentionInput-DPpEVL2s.js +1 -0
  7. package/dist/{WuiNotificationCenter-BIxUJ0tJ.js → WuiNotificationCenter-DuvGrqwr.js} +1 -1
  8. package/dist/{WuiPhone-CBge7oVA.js → WuiPhone--w-taM5Q.js} +1 -1
  9. package/dist/{WuiSavedViews-BmJmnkHu.js → WuiSavedViews-BKpnSd-Y.js} +1 -1
  10. package/dist/{WuiSelect-CBcfLzOF.js → WuiSelect-iUXaHKw5.js} +1 -1
  11. package/dist/{WuiSlider-R_mTula0.js → WuiSlider-CK7_l_R5.js} +1 -1
  12. package/dist/WuiTour-BgpMa8J5.js +1 -0
  13. package/dist/WuiTree-BjtuCasB.js +1 -0
  14. package/dist/{chips-DpD0EbS0.js → chips-xXgAvIFy.js} +1 -1
  15. package/dist/drawerDiscard-z1PsI4cx.js +1 -0
  16. package/dist/elements/comment-thread.js +1 -1
  17. package/dist/elements/date-range.js +1 -1
  18. package/dist/elements/inline-edit.js +1 -1
  19. package/dist/elements/kanban.js +1 -1
  20. package/dist/elements/markdown.js +1 -1
  21. package/dist/elements/mention-input.js +1 -1
  22. package/dist/elements/notification-center.js +1 -1
  23. package/dist/elements/phone.js +1 -1
  24. package/dist/elements/saved-views.js +1 -1
  25. package/dist/elements/select.js +1 -1
  26. package/dist/elements/slider.js +1 -1
  27. package/dist/elements/tour.js +1 -1
  28. package/dist/elements/tree.js +1 -1
  29. package/dist/helpers.js +1 -1
  30. package/dist/httpFailure.g-DjZzGxPj.js +1 -0
  31. package/dist/{kanban-BCOQDfvj.js → kanban-jQCTLG3Q.js} +1 -1
  32. package/dist/{listboxKeyNav-DNtuh6Ob.js → listboxKeyNav-CNso9shL.js} +1 -1
  33. package/dist/{search-BTNIAZY3.js → search-Bhn-bjLL.js} +1 -1
  34. package/dist/server.js +1 -1
  35. package/dist/text/en.json +1 -1
  36. package/dist/text.js +1 -1
  37. package/dist/themeTransition-TF0BqM20.js +1 -0
  38. package/dist/ui-calendar.global.js +1 -1
  39. package/dist/ui-calendar.js +1 -1
  40. package/dist/ui-elements/carousel.global.js +1 -1
  41. package/dist/ui-elements/code-block.global.js +1 -1
  42. package/dist/ui-elements/command-palette.global.js +1 -1
  43. package/dist/ui-elements/comment-thread.global.js +1 -1
  44. package/dist/ui-elements/consent-banner.global.js +1 -1
  45. package/dist/ui-elements/context-menu.global.js +1 -1
  46. package/dist/ui-elements/date-range.global.js +1 -1
  47. package/dist/ui-elements/date-time.global.js +1 -1
  48. package/dist/ui-elements/datepicker.global.js +1 -1
  49. package/dist/ui-elements/drawer.global.js +1 -1
  50. package/dist/ui-elements/dropdown.global.js +1 -1
  51. package/dist/ui-elements/entry-grid.global.js +1 -1
  52. package/dist/ui-elements/gantt.global.js +1 -1
  53. package/dist/ui-elements/glyphs.global.js +1 -1
  54. package/dist/ui-elements/image-crop.global.js +1 -1
  55. package/dist/ui-elements/inline-edit.global.js +1 -1
  56. package/dist/ui-elements/kanban.global.js +1 -1
  57. package/dist/ui-elements/lead-popup.global.js +1 -1
  58. package/dist/ui-elements/lightbox.global.js +1 -1
  59. package/dist/ui-elements/markdown.global.js +2 -2
  60. package/dist/ui-elements/org-tree.global.js +1 -1
  61. package/dist/ui-elements/phone.global.js +1 -1
  62. package/dist/ui-elements/popover.global.js +1 -1
  63. package/dist/ui-elements/saved-views.global.js +1 -1
  64. package/dist/ui-elements/select-chips.global.js +1 -1
  65. package/dist/ui-elements/select-recents.global.js +1 -1
  66. package/dist/ui-elements/select-search.global.js +1 -1
  67. package/dist/ui-elements/select-window.global.js +1 -1
  68. package/dist/ui-elements/slider.global.js +1 -1
  69. package/dist/ui-elements/sortable.global.js +1 -1
  70. package/dist/ui-elements/status-icon.global.js +1 -1
  71. package/dist/ui-elements/table-export.global.js +1 -1
  72. package/dist/ui-elements/timepicker.global.js +1 -1
  73. package/dist/ui-elements/tour.global.js +1 -1
  74. package/dist/ui-elements/tree-picker.global.js +1 -1
  75. package/dist/ui-elements/tree.global.js +1 -1
  76. package/dist/ui-elements/wizard.global.js +1 -1
  77. package/dist/ui-elements.global.js +1 -1
  78. package/dist/ui-elements.js +1 -1
  79. package/dist/ui-tour.global.js +1 -1
  80. package/dist/{wuiHttp-BiwgFpmq.js → wuiHttp-Cw7V8u2w.js} +1 -1
  81. package/package.json +6 -6
  82. package/types/calendarAdapter.d.ts +8 -21
  83. package/types/calendarEngine.d.ts +22 -0
  84. package/types/commandShortcut.d.ts +12 -0
  85. package/types/globals.d.ts +0 -4
  86. package/types/helpers.d.ts +1 -1
  87. package/types/listboxKeyNav.d.ts +2 -3
  88. package/types/razor-js/modules/api.d.ts +0 -5
  89. package/types/server/index.d.ts +1 -0
  90. package/types/server/shellParts.d.ts +6 -0
  91. package/types/server/wuiHttp.d.ts +2 -0
  92. package/types/server/wuiUpload.d.ts +15 -0
  93. package/dist/WuiCommentThread-D8Cv8y8v.js +0 -1
  94. package/dist/WuiDateRange-qTncGobM.js +0 -1
  95. package/dist/WuiMentionInput-DAPLGewp.js +0 -1
  96. package/dist/WuiTour-BU00-6Lf.js +0 -1
  97. package/dist/WuiTree-C3yMSmC2.js +0 -1
  98. package/dist/drawerDiscard-Dl33Ytd2.js +0 -1
  99. package/dist/httpFailure.g-SkEFc60Y.js +0 -1
  100. package/dist/themeTransition-DBv2olsl.js +0 -1
@@ -1 +0,0 @@
1
- import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-DTW53DjY.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{n as o}from"./imeSafeEnter-DeO_3lXy.js";import{n as s}from"./listboxKeyNav-DNtuh6Ob.js";import{i as c,n as l,r as u,t as d}from"./mentionText-BJsw_opZ.js";import{a as f,l as p,s as m}from"./nativeOverlay-BHD2QV02.js";import{t as h}from"./serverHtml-BC6tAyAl.js";import{d as g}from"./wuiHttp-BiwgFpmq.js";import{n as _,r as v,t as y}from"./textStore-DBplASiZ.js";import{t as b}from"./mentionInput.g-DJo6d2Gm.js";var x=8,S=40,C=()=>v(`mentionInput`,b),w=`[data-wui-control]`,T=`[data-wui-field]`,E=`[data-wui-menu]`,D=`[data-wui-live]`,O=0,k=e=>!!(e&&d.test(String(e.value??``))&&l(e.label)!==``);function A(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function j(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function M(e){let t=e.ownerDocument;e.id||=`wui-mention-${++O}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),j(e,n),A(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??C().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var N=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(a(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(w)||M(this);let e=this._requireControl(),t=this.querySelector(T)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(j(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(j(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?A(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return c(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(k):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(w)}_menu(){return this.querySelector(E)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=u(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(T);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>l(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await g(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=h(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(k),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&m(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=l(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?C().searchingLabel:this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}p(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?_(C(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?C().searchFailedMessage:`${C().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=m(e);f(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);s(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((o(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}o(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=l(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(y(C().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(D);t&&(t.textContent=``,t.textContent=e)}};export{x as n,N as r,S as t};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./anchorOverlay-daGdh_91.js";import{n,t as r}from"./buttonClass-C8BRtTk8.js";import{r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{d as o,f as s,o as c,u as l}from"./nativeOverlay-BHD2QV02.js";import{n as u,t as d}from"./rtl-g7G8Bsib.js";import{r as f}from"./textStore-DBplASiZ.js";import{n as p,t as m}from"./tourAdvance.g-BJqDnqag.js";import{n as h}from"./imeSafeEnter-DeO_3lXy.js";import{t as g}from"./svgNodes-CyPS2oFH.js";import{t as _}from"./tourOpenMark-nPeAJFSo.js";import{t as v}from"./tourSeenStore-z0Y_Znzx.js";var y=`data-advance`,b=`wui-tour-hint`,x=`wui-tour-pointer`,ee=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,te=()=>f(`tourAdvance`,m),S=(e,t)=>e?.advanceOn===`click`&&!!t,C=e=>(e??``).replace(/\s+/g,` `).trim(),ne=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLMeterElement||e instanceof HTMLOutputElement||e instanceof HTMLProgressElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,re=e=>e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLFieldSetElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement?e.disabled:!1;function ie(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e instanceof HTMLInputElement&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(ne(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=C(e);if(t)return t}return``}function ae(e){for(let t of[e,...e.querySelectorAll(ee)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!re(t))return t;return null}function w(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function oe(e,t){let n=e.querySelector(`.${b}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&w(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=b,i&&(n.id=i);let t=e.querySelector(`.wui-tour-actions`);if(!t)throw Error(`Tour card has no actions row.`);t.before(n)}n.textContent=t,i&&w(e,i,!0)}}function se(e,t){let n=e.querySelector(`.${x}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=x,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ce=e=>getComputedStyle(e).animationName;function T(e,{layer:t,spot:n,card:r},i,a){let o=S(i,a);t.toggleAttribute(y,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(y)&&(n.removeAttribute(y),o&&ce(n)),o&&n.setAttribute(y,``),se(n,o);let s=r.querySelector(`.wui-tour-next`);if(!(s instanceof HTMLElement))throw Error(`Tour card has no next button.`);s.classList.toggle(`btn-primary`,!o),s.classList.toggle(`btn-link`,o);let c=o?C(i?.actionLabel)||ie(a):``,l=e.getAttribute(`advance-label`)||te().advanceLabel,u=c?l.replace(/\{actionName\}/g,()=>c):``;return oe(r,u),u}function le(e,t,n){if(!S(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ue(e,t,n,r){return e.contains(r)||S(t,n)&&n.contains(r)}function de(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=S(r,i)?ae(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i?.contains(n));e.preventDefault();let c=a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length];if(!c)throw Error(`Tour card has no focus stop.`);c.focus()}var fe=2/3,pe=1e3,me=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),E=/* @__PURE__ */ new WeakMap,D=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],O=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,he=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&me.has(e.transitionProperty),ge=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function k(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,pe);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function _e(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?D(t,he):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*fe-r)}return n}function A(e){let t=_e(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};E.set(e,n);let r=()=>{E.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=D(e,ge);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function j(e){return e.dataset.state=`leaving`,k(D(e,O))}function ve(e){let t=e.shadowRoot?.querySelector(`.wui-tour-layer`),n=e.classList.contains(`wui-tour-layer`)?e:t instanceof HTMLElement?t:null;n&&(n.dataset.state=`leaving`);let r=n?k(D(n,O)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var ye=2,M=12,N=8,P=4,F=20,be=`(max-width: 575.98px)`,xe=[`bottom`,`top`,`right`,`left`],Se=[`bottom`,`top`,`left`,`right`],I=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],L,R=(e,t,n)=>Math.max(t,Math.min(e,n)),z=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function Ce(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=V(e),r=e.offsetHeight+M;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+ye}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function B(e,t,n){let r=e.style,i=t.style,a=Oe(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of I)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,we(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=V(t),u=l.bottom-l.top,f={bottom:l.bottom-o.bottom-M,top:o.top-M-l.top,right:l.right-o.right-M,left:o.left-M-l.left},p=window.matchMedia(be).matches,m=(d(n)?Se:xe).find(e=>e===`top`||e===`bottom`?c.height<=f[e]+1:!p&&c.width<=f[e]+1&&c.height<=u+1),h=Math.min(o.bottom,l.bottom+N)-Math.max(o.top,l.top-N);m?Te(t,a,m,o,l,c):h>=Math.min(c.height,u)+8?Ee(t,a,o,l,c):De(t,a,f.bottom>=f.top?`bottom`:`top`,o,l,c,f),t.scrollTop=s}function we(e,t){L??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of I)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),L&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function Te(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=z(r.left,r.right,i.left,i.right);s=R(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+M:r.top-M-a.height,l=R(e-s,F,a.width-F)}else{let e=z(r.top,r.bottom,i.top,i.bottom);c=R(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+M:r.left-M-a.width,l=R(e-c,F,a.height-F)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function Ee(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-P;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${R(n.left+P,r.left,r.right-i.width)}px`}function De(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+M:r.top-M-c}px`;let l=z(r.left,r.right,i.left,i.right);e.style.left=`${R(l-a.width/2,i.left,i.right-a.width)}px`}function V(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+N,bottom:window.innerHeight-r(`paddingBottom`)-N,left:r(`paddingLeft`)+N,right:window.innerWidth-r(`paddingRight`)-N}}function Oe(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);if(t instanceof HTMLElement)return t;let n=document.createElement(`span`);return n.className=`wui-tour-arrow`,n.setAttribute(`aria-hidden`,`true`),n.hidden=!0,e.append(n),n}var ke=0,Ae=`btn btn-sm btn-link`;function H(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function je(e,t){let a=`wui-tour-end-${++ke}`,{nextLabel:o,nextHref:s}=e,c=o&&s?i(`a`,{class:`${n(`primary`,`solid`,`sm`)} wui-tour-end-next`,"data-wui":r,href:s},o):null,l=c!==null,u=l?Ae:n(`primary`,`solid`,`sm`),d=i(`button`,{type:`button`,class:`${u} wui-tour-end-button`,"data-wui":r},e.button);return i(t?`dialog`:`div`,{class:`wui-tour-card wui-tour-end`,"data-layout":`center`,"data-next":l||void 0,role:`dialog`,tabindex:-1,"aria-labelledby":`${a}-title`,"aria-describedby":`${a}-message`},i(`div`,{class:`wui-tour-end-mark`,"aria-hidden":`true`},g({viewBox:`0 0 24 24`,focusable:`false`},[[`path`,{d:`M5 12.5l4.5 4.5L19 7.5`}]])),i(`h2`,{class:`wui-tour-title wui-tour-end-title`,id:`${a}-title`},e.title),i(`p`,{class:`wui-tour-text wui-tour-end-message`,id:`${a}-message`},e.message),i(`div`,{class:`wui-tour-actions`},c,d))}var Me=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function Ne(e,t,n){let r=e.ownerDocument,i=je(t,e.getRootNode()===r),a=H(i,`.wui-tour-end-button`,HTMLButtonElement),o=i.querySelector(`.wui-tour-end-next`);if(o!==null&&!(o instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let s=o,u=s??a,d=new AbortController,f=i instanceof HTMLDialogElement?i:null,p=null;return new Promise(o=>{let m=e=>{if(d.abort(),p&&f){let e=p;p=null,c(f).then(e)}o(e)};if(n?.aborted){m(`done`);return}let g=H(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),_=H(e,`.wui-tour-spot`,HTMLElement),v=H(e,`[role=status]`,HTMLElement),y={signal:d.signal};n?.addEventListener(`abort`,()=>m(`done`),y),a.addEventListener(`click`,()=>m(`done`),y),s&&s.addEventListener(`click`,e=>{Me(e)&&(e.preventDefault(),m(`next`))},y),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`){if(p)return;e.preventDefault(),e.stopPropagation(),m(`done`)}else h(e)&&s&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===s&&(e.preventDefault(),m(`next`))}},{capture:!0,signal:d.signal});let b=()=>{d.signal.aborted||(g.hidden=!0,B(_,g,null),e.append(i),A(i),f&&(p=l(f,{escape:!0,backdrop:!1,focus:`first-control`,onRequestClose:()=>m(`done`)})),v.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},x=j(g);x===null?b():x.then(b)})}var Pe=` :host { all: initial; display: revert-layer; position: fixed; inset: 0; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-ease-linear":`cubic-bezier(0, 0, 1, 1)`,"--wui-duration-fast":`150ms`,"--wui-duration-default":`250ms`,"--wui-duration-slow":`400ms`,"--wui-space-xs":`4px`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; background: none; } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-duration-fast) var(--wui-ease-linear); } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in var(--wui-duration-fast) var(--wui-ease-linear) both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-tap-rtl { 0% { opacity: 0; transform: translate(-56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(-56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer:dir(rtl) { animation-name: wui-tour-tap-rtl; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check var(--wui-duration-default) var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + var(--wui-duration-fast)) both; } } `,U=()=>f(`tour`,p),W=`wui-tour-media`,Fe=`wui-tour-media-toggle`,G=`http://www.w3.org/2000/svg`,Ie=`M6 5h4v14H6zM14 5h4v14h-4z`,Le=`M8 5v14l11-7z`,Re=()=>({pause:U().mediaPauseLabel,play:U().mediaPlayLabel}),ze=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function Be(e){let t=document.createElementNS(G,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(G,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Ve(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media??``),t}function He(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media??``),n}function Ue(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=Fe;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(Be(r?Ie:Le))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function We(e){let t=e.querySelector(`:scope > .${W}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ge(e,t,n=Re()){if(We(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=W,t.mediaType===`video`){let e=He(t,!ze());r.append(e,Ue(e,n))}else r.appendChild(Ve(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var Ke=()=>f(`tour`,p);function K(e){let t=/* @__PURE__ */ new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function qe(e,t,n){return(e.getAttribute(`progress-label`)||Ke().progressLabel).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Je(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);if(!(i instanceof HTMLElement))throw Error(`tour position label missing`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;){let e=a.lastElementChild;if(!e)throw Error(`progress bar segment missing`);e.remove()}for(let e=0;e<o.length;e++){let t=o[e];if(!t)throw Error(`progress bar segment missing`);t.toggleAttribute(`data-filled`,e<n)}}var Ye=`wui-tour-step`,Xe=`wui-tour-host`,q=`data-tracking`,J=()=>f(`tour`,p),Ze=()=>({back:J().backLabel,next:J().nextLabel,skip:J().skipLabel,done:J().doneLabel,mediaPause:J().mediaPauseLabel,mediaPlay:J().mediaPlayLabel,endTitle:J().endTitle,endMessage:J().endMessage,endButton:J().doneLabel}),Qe={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},$e=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],Y={index:null,position:null,total:null},et=0,X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Q(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var tt=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function nt(e){$||($=new CSSStyleSheet,$.replaceSync(Pe)),e.adoptedStyleSheets=[$]}var rt=class extends a{seenStore;onBeforeStep;_run;_running;_layer;_outer;_shadow;_unbindAdvance;_ending;_seenMark;_steps=[];_progress=K(0);_firstIndex=0;_returnFocus=null;_current=null;_moving=!1;_card=null;_spot=null;_live=null;_onKey=null;_onFocusIn=null;static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${Ye}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of $e)e.hasAttribute(r)&&(t[n]=e.getAttribute(r)??``);return t})}_stepAt(e){let t=this._steps[e];if(!t)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);return t}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?v():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Qe[e])||Ze()[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=K(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(!e)break;if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target),a=t instanceof HTMLElement||t instanceof SVGElement?t:null;if(X(a))return this._progress.position(i),{index:i,target:a};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let t=`wui-tour-${++et}`,a=document.createElement(`div`);a.className=`wui-tour-layer`,a.replaceChildren(i(`div`,{class:`wui-tour-spot`,"aria-hidden":`true`}),i(`div`,{class:`wui-tour-card`,role:`dialog`,tabindex:`-1`,"aria-labelledby":`${t}-title`,"aria-describedby":`${t}-text`},i(`p`,{class:`wui-tour-position`}),i(`h2`,{class:`wui-tour-title`,id:`${t}-title`}),i(`p`,{class:`wui-tour-text`,id:`${t}-text`}),i(`div`,{class:`wui-tour-actions`},i(`button`,{type:`button`,class:`btn btn-sm btn-link wui-tour-skip`}),i(`div`,{class:`wui-tour-nav`},i(`button`,{type:`button`,class:`${n(`neutral`,`outline`,`sm`)} wui-tour-back`,"data-wui":r}),i(`button`,{type:`button`,class:`${n(`primary`,`solid`,`sm`)} wui-tour-next`,"data-wui":r})))),i(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}));let s=a;this._shadow=null,this.isolated&&(s=document.createElement(Xe),this._shadow=s.attachShadow({mode:`open`}),nt(this._shadow),this._shadow.appendChild(a)),s.setAttribute(`popover`,`manual`),o(document).appendChild(s),document.documentElement.setAttribute(_,``),this._outer=s,this._layer=a;let c=Q(a,`.wui-tour-spot`,HTMLDivElement),l=Q(a,`.wui-tour-card`,HTMLDivElement),u=Q(a,`[role=status]`,HTMLElement);this._spot=c,this._card=l,this._live=u,Q(l,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Q(l,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Q(l,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1));let d=e=>this._key(e);this._onKey=d;let f=e=>{let t=this._layer;if(!t||this._ending)return;let n=this._current,r=n?this._stepAt(n.index):null;if(!(e.target instanceof Node))throw Error(`<wui-tour> saw a focus change from a non-node target`);ue(t,r,n?.target??null,e.target)||l.focus()};this._onFocusIn=f,document.addEventListener(`keydown`,d,!0),this._shadow||document.addEventListener(`focusin`,f),e(s,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_raise(){let e=this._outer;if(!e)throw Error(`<wui-tour> raises a step before its host is built`);let t=o(this.ownerDocument);e.parentElement!==t&&t.appendChild(e),s(e)}_show(e){this._current=e;let{index:t,target:n}=e,r=this._stepAt(t),i=this._layer,a=this._spot,o=this._card,s=this._live;if(!i||!a||!o||!s)throw Error(`<wui-tour> shows a step before its layer is built`);this._raise();let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=qe(this,c,l);Je(o,{text:d,position:c,total:l}),Ge(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=T(this,{layer:i,spot:a,card:o},r,n),p=Q(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Q(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Q(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Q(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Q(o,`.wui-tour-next`,HTMLElement).textContent=this._label(u?`done`:`next`);let h=[d,r.title,r.description].filter(Boolean).join(`. `);s.textContent=f?[h,f].join(/[.!?]$/.test(h)?` `:`. `):h,Ce(o,n),a.removeAttribute(q),this._place(),A(o),this._unbindAdvance?.(),this._unbindAdvance=le(r,n,()=>void this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&Z(tt()))||o.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:c,total:l}}))}_place(){if(!this._current||!this._layer)return;let e=this._spot,t=this._card;if(!e||!t)throw Error(`<wui-tour> places a step before its layer is built`);B(e,t,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot;if(!e)throw Error(`<wui-tour> follows a step before its spot is built`);let t=e.style.cssText;this._place(),e.style.cssText!==t&&e.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=this._card;if(!e)throw Error(`<wui-tour> moved with no card showing`);let t=j(e);if(t!==null&&await t,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);if(t===`next`&&r&&e){let t=this.ownerDocument.defaultView;if(!t)throw Error(`<wui-tour> has no window to follow its next link in`);t.location.assign(e.nextHref)}}}finally{this._moving=!1}}_showEnd(e){this._unbindAdvance?.(),this._unbindAdvance=null;let t=this._layer,n=this._spot,r=this._card;if(!t||!n||!r)throw Error(`<wui-tour> ends a tour before its layer is built`);return T(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),Ne(t,e,this._ending.signal)}_key(e){if(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)return;let t=u(e.key,d(this));if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(t===`ArrowRight`||t===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),t===`ArrowRight`)this._move(1);else{let e=this._current;if(!e)throw Error(`<wui-tour> moved back with no step showing`);e.index>this._firstIndex&&this._move(-1)}}else if(e.key===`Tab`&&!this._shadow){let t=this._current,n=this._card;if(!t||!n)throw Error(`<wui-tour> cycled focus with no step showing`);de(e,{card:n,active:this._active(),step:this._stepAt(t.index),target:t.target})}}_teardown(){if(!this._layer)return;this._onKey&&document.removeEventListener(`keydown`,this._onKey,!0),this._onFocusIn&&document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null;let n=this._outer;if(t(n),!n)throw Error(`<wui-tour> has a layer with no host to remove`);ve(n),document.documentElement.removeAttribute(_),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let r=this._returnFocus;this._returnFocus=null,e&&r?.isConnected&&(r instanceof HTMLElement||r instanceof SVGElement)&&r.focus()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:Y,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=Y,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{rt as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./devWarn-DXdRWZs3.js";import{r as t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{n as r,t as i}from"./formMirror-9IpSgeZb.js";import{t as a}from"./hasOwn-CJsplJ62.js";import{t as o}from"./iconGlyphs.g-a9FtjPXh.js";import{t as s}from"./listboxKeyNav-DNtuh6Ob.js";import{n as c,t as l}from"./rtl-g7G8Bsib.js";import{n as u,r as d,t as f}from"./window-BZWK3rQk.js";import{d as p}from"./wuiHttp-BiwgFpmq.js";import{r as m}from"./textStore-DBplASiZ.js";import{t as h}from"./tree.g-RId8xZSk.js";var g=()=>m(`tree`,h),_=[`none`,`single`,`multiple`],v=e=>_.some(t=>t===e),y=300,b=8,x=300,S=`parentId`,C=`:scope > input[data-wui-mirror]`,w=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],T=0;function E(e){for(let t=e;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement)if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY))return t;return null}var D=class extends n{_uid;_seq;_roots;_byId;_prev;_staged;_els;_checked;_selected;_focusId;_loader;_list;_live;_ready;_flat;_win;_rowH;_rowMeasured;_box;_unbind;_frame;_nav;_onKeyDown;_onClick;_onFocusIn;static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++T}`,this._seq=0,this._roots=[],this._byId=/* @__PURE__ */ new Map,this._prev=null,this._staged=null,this._els=/* @__PURE__ */ new Map,this._checked=/* @__PURE__ */ new Set,this._selected=null,this._focusId=null,this._loader=null,this._list=null,this._live=null,this._ready=!1,this._flat=null,this._win=null,this._rowH=36,this._rowMeasured=!1,this._box=null,this._unbind=null,this._frame=0,this._nav=s({getVisibleOptions:()=>[...this._els.values()].map(e=>e.row),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[e]),getCount:()=>this._visible().length,getOptionAt:e=>this._els.get(this._visible()[e]?.id??``)?.row,findByPrefix:e=>this._visible().findIndex(t=>t.label.toLowerCase().startsWith(e)),onEnter:()=>{let e=this._focusId===null?void 0:this._byId.get(this._focusId);e&&this._activate(e)}}),this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>{if(e.target===this._list){this._focusNode(this._focusId===null?void 0:this._byId.get(this._focusId));return}let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e=/* @__PURE__ */ new Map;for(let t of w)a(this,t)&&(e.set(t,Reflect.get(this,t)),Reflect.deleteProperty(this,t));if(!this._ready){this._ready=!0;let e=this._readScript();this.replaceChildren(),this._list=t(`ul`,{class:`wui-tree`}),this._list.setAttribute(`role`,`tree`),this._live=t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`}),this.append(this._list,this._live),e&&this._adoptAll(e)}for(let[t,n]of e)Reflect.set(this,t,n);this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this._render(),this._loadOpenNodes()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this._unbindWindow(),this._nav.teardown()}attributeChangedCallback(e,t,n){e===`selected`&&(this._selected=n),this._ready&&this.isConnected&&this._render()}get nodes(){return this._roots.map(e=>e.raw)}set nodes(e){this._adoptAll(e??[]),this._render(),this._loadOpenNodes()}get selection(){let e=this.getAttribute(`selection`);return v(e)?e:`none`}set selection(e){this.setAttribute(`selection`,String(e))}get selected(){return this._selected}set selected(e){this._selected=e==null?null:String(e),this._render()}get values(){let e=[],t=n=>{for(let r of n)this._state(r)===`checked`&&e.push(r.id),r.children&&t(r.children)};return t(this._roots),[...e,...[...this._checked].filter(e=>!this._byId.has(e))]}set values(e){this._checked.clear();for(let t of e??[]){let e=this._byId.get(String(t));e?this._setChecked(e,!0):this._checked.add(String(t))}this._render()}get loadChildren(){return this._loader}set loadChildren(e){this._loader=typeof e==`function`?e:null}get loadUrl(){return this.getAttribute(`load-url`)}set loadUrl(e){e==null?this.removeAttribute(`load-url`):this.setAttribute(`load-url`,String(e))}get name(){return this.getAttribute(`name`)}set name(e){e==null?this.removeAttribute(`name`):this.setAttribute(`name`,String(e))}get loadingText(){return this.getAttribute(`loading-text`)??g().loadingText}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??g().errorText}set errorText(e){this.setAttribute(`error-text`,String(e??``))}_readScript(){let t=this.querySelector(`:scope > script[type='application/json']`);if(!t)return null;try{return JSON.parse(t.textContent??``)}catch(t){return e(`[@webority/ui-elements] <wui-tree> could not read its JSON nodes:`,t instanceof Error?t.message:void 0),null}}_adoptAll(e){this._flat=null;let t=this._byId;this._prev=t,this._byId=/* @__PURE__ */ new Map;let n;try{n=this._adoptStaged(e,null,1)}catch(e){throw this._byId=t,e}finally{this._prev=null}this._roots=n;for(let e of t.keys())this._byId.has(e)||this._checked.delete(e);for(let e of this._roots)this._passChecksDown(e);this._focusId&&!this._byId.has(this._focusId)&&(this._focusId=null)}_adoptStaged(e,t,n){let r=[],i=[];this._staged={ids:r,checks:i};try{let r=this._adopt(e,t,n);for(let e of i)this._checked.add(e);return r}catch(e){for(let e of r)this._byId.delete(e);throw e}finally{this._staged=null}}_adopt(e,t,n){if(!Array.isArray(e))throw Error(`<wui-tree> nodes must be an array.`);return e.map((e,r)=>{let i=e?.id==null?``:String(e.id);if(!i)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(i))throw Error(`<wui-tree> node id "${i}" is used twice.`);let a=this._prev?.get(i),o={id:i,raw:e,parent:t,level:n,seq:++this._seq,pos:r,label:e.label==null?i:String(e.label),icon:e.icon||null,badge:e.badge==null||e.badge===``?null:String(e.badge),badgeTone:e.badgeTone||null,disabled:!!e.disabled,hasChildren:!!e.hasChildren,children:null,expanded:a?a.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(i,o),this._staged?.ids.push(i);let s=e.children??(e.hasChildren?a?.children?.map(e=>e.raw):void 0);return Array.isArray(s)&&(o.children=this._adopt(s,o,n+1)),o.loading=!!a?.loading&&o.children===null&&o.hasChildren,e.checked&&!a&&this._staged?.checks.push(i),o})}_passChecksDown(e){e.children?.length&&this._checked.has(e.id)&&(this._checked.delete(e.id),this._setChecked(e,!0));for(let t of e.children??[])this._passChecksDown(t)}_loadOpenNodes(){queueMicrotask(()=>{if(this.isConnected)for(let e of[...this._byId.values()])e.expanded&&e.children===null&&e.hasChildren&&!e.loading&&this._load(e)})}_isBranch(e){return e.children?e.children.length>0:e.hasChildren}_visible(){if(this._flat)return this._flat;let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),this._flat=e,e}_state(e){if(e.children?.length){let t=0,n=0;for(let r of e.children){let e=this._state(r);e===`checked`?t++:e===`unchecked`&&n++}return t===e.children.length?`checked`:n===e.children.length?`unchecked`:`mixed`}return this._checked.has(e.id)?`checked`:`unchecked`}_setChecked(e,t){if(e.children?.length)for(let n of e.children)n.disabled||this._setChecked(n,t);else t?this._checked.add(e.id):this._checked.delete(e.id)}_nodeFrom(e){if(!(e instanceof Element))return null;let t=e.closest(`li.wui-tree-item`);if(!t)return null;for(let[e,n]of this._els)if(n.li===t)return this._byId.get(e)??null;return null}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-tree:${e}`,{detail:t,bubbles:!0,composed:!0}))}_announce(e){this._live&&(this._live.textContent=e)}_setRoving(e){let t=this._focusId===null?void 0:this._els.get(this._focusId);t&&(t.li.tabIndex=-1),this._focusId=e.id;let n=this._els.get(e.id);n&&(n.li.tabIndex=0),this._syncTab()}_syncTab(){this._list&&(this._focusId!==null&&!this._els.has(this._focusId)?this._list.tabIndex=0:this._list.removeAttribute(`tabindex`))}_focusNode(e){e&&(this._win&&!this._els.has(e.id)&&this._reveal(e),this._setRoving(e),this._els.get(e.id)?.li.focus())}_activate(e){e.disabled||(this.selection===`single`&&(this._selected=e.id,this._render(),this._syncForm()),this._emit(`select`,{id:e.id,node:e.raw}))}_enabledLeaves(e){return e.disabled?[]:e.children?.length?e.children.flatMap(e=>this._enabledLeaves(e)):[e]}_toggleCheck(e){let t=this._enabledLeaves(e);if(!t.length)return;let n=!t.every(e=>this._checked.has(e.id));this._setChecked(e,n),this._render(),this._syncForm(),this._emit(`check`,{id:e.id,checked:n,values:this.values})}_toggleExpand(e){!e.disabled&&this._isBranch(e)&&(e.expanded?(e.expanded=!1,this._render()):this._expand(e))}_expand(e){e.expanded=!0,e.children===null?this._load(e):this._render()}async _load(e){if(e.loading)return;e.loading=!0,e.failed=!1,this._announce(this.loadingText),this._render();let t=[],n=null;try{t=await this._fetchChildren(e)}catch(e){n=e}let r=this._byId.get(e.id);if(!r)this._announce(``);else if(r.loading){if(r.loading=!1,!n)try{r.children=this._adoptStaged(t,r,r.level+1),this._passChecksDown(r),this._announce(``)}catch(e){n=e}n&&(r.failed=!0,r.expanded=!1,this._announce(this.errorText),this._emit(`error`,{id:r.id,message:n instanceof Error?n.message:String(n)})),this._render(),this._syncForm()}}async _fetchChildren(e){if(this._loader)return this._loader(e.raw);let t=this.getAttribute(`load-url`);if(!t)throw Error(`<wui-tree> has a node with children to load but no loadChildren or load-url.`);let n=new URL(t,window.location.href);n.searchParams.set(S,e.id);let r=await p(n.href,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Loading children answered ${r.kind}.`);return JSON.parse(r.html)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this._nodeFrom(t);n&&!n.disabled&&(this._focusNode(n),t.closest(`.wui-tree-toggle`)?this._toggleExpand(n):t.closest(`.wui-tree-check`)?(e.preventDefault(),this._toggleCheck(n)):this._activate(n))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=this._nodeFrom(e.target);if(!t||e.target!==this._els.get(t.id)?.li)return;let n=c(e.key,l(this));if(n===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else n===`ArrowLeft`?(e.preventDefault(),t.expanded&&this._isBranch(t)&&!t.disabled?this._toggleExpand(t):t.parent&&this._focusNode(t.parent)):e.key===` `?(e.preventDefault(),this.selection===`multiple`?this._toggleCheck(t):this.selection===`single`&&this._activate(t)):this._nav.handler(e)}_syncForm(){let e=this.selection;if(e===`multiple`)r(this,this.values);else if(e===`single`)i(this,this._selected??``);else for(let e of this.querySelectorAll(C))e.remove()}_render(){if(!this._list)return;this._flat=null;let e=document.activeElement,t=!!e&&this._list.contains(e),n=this._visible();n.some(e=>e.id===this._focusId)||(this._focusId=(n.find(e=>e.id===this._selected)??n[0])?.id??null);let r=this.getAttribute(`aria-label`);if(r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),n.length>y){this._bindWindow();let e={heights:f(n.length,this._rowH),start:0,end:0};this._win=e,this._paint(n,e)}else this._unbindWindow(),this._win=null,this._list.style.paddingTop=``,this._list.style.paddingBottom=``,this._drawRows(n);t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_drawRows(e){this._list&&(this._els=/* @__PURE__ */ new Map,this._list.replaceChildren(...e.map(e=>this._buildItem(e))),this._syncTab())}_metrics(){let e=this._box,t=this._list?.getBoundingClientRect().top??0,n=e?e.getBoundingClientRect().top:0,r=(e?e.clientHeight:window.innerHeight)||x;return{scrollTop:Math.max(0,n-t),viewport:r}}_rangeOf(e){return d(e.heights,{...this._metrics(),overscan:b})}_draw(e,t){let{start:n,end:r}=this._rangeOf(t);t.start=n,t.end=r,this._drawRows(e.slice(n,r));let i=this._list?.style;i&&(i.paddingTop=`${t.heights.offsetOf(n)}px`,i.paddingBottom=`${t.heights.total()-t.heights.offsetOf(r)}px`)}_measure(e,t){let{heights:n}=t,r=n.indexAt(this._metrics().scrollTop),i=n.offsetOf(r),a=!1;for(let r=t.start;r<t.end;r++){let t=e[r]?.id,i=t===void 0?void 0:this._els.get(t)?.li,o=i?i.getBoundingClientRect().height:0;if(o>0){if(!this._rowMeasured){this._rowMeasured=!0,this._rowH=o;let e=n.estimate;n.setEstimate(o),n.estimate!==e&&(a=!0)}n.set(r,o)&&(a=!0)}}return a?{changed:a,delta:n.offsetOf(r)-i}:{changed:!1,delta:0}}_scrollBy(e){this._box?this._box.scrollTop+=e:window.scrollBy(0,e)}_paint(e,t){this._draw(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=this._measure(e,t);if(!n)return;r&&this._scrollBy(r),this._draw(e,t)}}_repaintWindow(){let e=this._win;if(!e||!this._list)return;let{start:t,end:n}=this._rangeOf(e);if(t===e.start&&n===e.end)return;let r=document.activeElement,i=!!r&&this._list.contains(r);this._paint(this._visible(),e),i&&this._focusId&&this._els.get(this._focusId)?.li.focus({preventScroll:!0})}_schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=0,this._repaintWindow()})}_reveal(e){let t=this._win;if(!t)return;let n=this._visible(),r=n.indexOf(e);if(!(r<0))for(let i=0;i<2;i++){let i=this._metrics(),a=u(t.heights,r,i);if(Math.abs(a-i.scrollTop)>.5)this._scrollBy(a-i.scrollTop);else if(this._els.has(e.id))break;this._paint(n,t)}}_bindWindow(){if(this._unbind||!this.isConnected)return;let e=E(this),t=e??window,n=()=>this._schedule();t.addEventListener(`scroll`,n,{passive:!0});let r=null;e?(r=new ResizeObserver(n),r.observe(e)):window.addEventListener(`resize`,n),this._box=e,this._unbind=()=>{t.removeEventListener(`scroll`,n),r?r.disconnect():window.removeEventListener(`resize`,n)}}_unbindWindow(){this._unbind?.(),this._unbind=null,this._box=null,this._frame&&cancelAnimationFrame(this._frame),this._frame=0}_buildItem(e){let n=e.parent?e.parent.children?.length??0:this._roots.length,r=this.selection,i=this._isBranch(e),a=this._state(e),s=t(`li`,{class:`wui-tree-item`,role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":e.pos+1,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});i&&s.setAttribute(`aria-expanded`,String(e.expanded)),e.disabled&&s.setAttribute(`aria-disabled`,`true`),e.loading&&s.setAttribute(`aria-busy`,`true`),r===`single`&&s.setAttribute(`aria-selected`,String(e.id===this._selected)),r===`multiple`&&s.setAttribute(`aria-checked`,a===`mixed`?`mixed`:String(a===`checked`));let c=t(`div`,{class:`wui-tree-row`,role:`presentation`});c.style.setProperty(`--wui-tree-level`,String(e.level-1)),r===`single`&&e.id===this._selected&&c.classList.add(`wui-tree-row-selected`),e.failed&&c.classList.add(`wui-tree-row-error`);let l=t(`span`,{class:i?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,"aria-hidden":`true`});if(i){let e=o(`chevron-right`,{size:16});l.replaceChildren(...e?[e]:[])}if(c.append(l),r===`multiple`){let n=t(`input`,{class:`form-check-input wui-tree-check`,type:`checkbox`,tabindex:-1,"aria-hidden":`true`});n.checked=a===`checked`,n.indeterminate=a===`mixed`,n.disabled=e.disabled,n.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(n)}if(e.icon){let n=t(`span`,{class:`wui-tree-icon`,"aria-hidden":`true`}),r=o(e.icon,{size:16});n.replaceChildren(...r?[r]:[]),c.append(n)}let u=t(`span`,{class:`wui-tree-label`,id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let n=e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``,r=t(`span`,{class:`badge wui-tree-badge${n}`,id:`${this._uid}-${e.seq}-badge`});r.textContent=e.badge,c.append(r)}return e.loading&&c.append(t(`span`,{class:`wui-tree-spinner`,"aria-hidden":`true`})),s.append(c),this._els.set(e.id,{li:s,row:c}),s}};export{D as t};
@@ -1 +0,0 @@
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-SkEFc60Y.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{c as he,d as g,u as ge}from"./wuiHttp-BiwgFpmq.js";var _e=()=>s(`tableSelect`,p),_=`wui-select-cell`,v=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,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(`.${_} .wui-check`);return n instanceof HTMLInputElement?n:null}function Ce(e){let t=e.querySelector(`thead .${_} .wui-check`),n=x(e,`tbody tr .wui-check: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(`.wui-check`);t.classList.toggle(`is-selected`,e instanceof HTMLInputElement&&e.checked)}return{selected:i,total:r}}var S=`tbody .${_} .wui-check:not(:disabled)`;function we(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check: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,`.${_} .wui-check: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 .wui-check:not(:disabled)`)){if(t.checked||(y=!1),o.tHead?.contains(t))for(let e of w(x,`:scope > tr`,HTMLTableRowElement)){let n=T(e,`.${_} .wui-check: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`)||t.getAttribute(`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,`.${_} .wui-check`,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 > .${_} .wui-check: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 +0,0 @@
1
- var e={networkCheckText:`A network check stopped this request. Try again, or report it if it keeps happening.`,networkText:`Could not reach the server. Check your connection and try again.`};export{e as t};
@@ -1 +0,0 @@
1
- import{i as e,t}from"./dom-DMQu--xV.js";import{r as n,t as r}from"./textStore-DBplASiZ.js";import{t as i}from"./devWarn-DXdRWZs3.js";import{n as a}from"./imeSafeEnter-DeO_3lXy.js";import{t as o}from"./rowDrop.g-DQpB10Ey.js";var s=`wui:row-drop`,c=`is-drop-over`,l=`application/x-wui-rows`,u=`wui-row-dragging`,d=`[data-wui-drop-target]`,f=`tbody tr[data-row-key]`,ee=`input, button, a, select, textarea, label`,p=`.wui-select-cell .wui-check`,m=/* @__PURE__ */ new WeakMap,h=/* @__PURE__ */ new WeakSet,g=null,_=null;function v(e){let t=e.querySelector(p);return t instanceof HTMLInputElement&&t.checked}function y(e){let t=[];for(let n of e.querySelectorAll(`tbody tr`))n instanceof HTMLElement&&v(n)&&t.push(n.dataset.rowKey);return t}function b(e,n){return t(e,n)}function x(e,t){let n=b(e,t);return n instanceof HTMLElement?n:null}function te(e){let t=e.textContent;if(t===null)throw Error(`A drop target has no text content.`);return t.trim()}var S=e=>typeof e==`object`&&!!e&&`selected`in e&&typeof e.selected==`number`;function C(){g=null,document.body.classList.remove(u);for(let e of document.querySelectorAll(`${d}.${c}`))e.classList.remove(c)}function w(e,t,n){e.dispatchEvent(new CustomEvent(s,{bubbles:!0,detail:{keys:t,target:n.dataset.wuiDropTarget}}))}function T(t){let n=x(t.target,d);if(!n||!g)return;t.preventDefault();let r=e(t.dataTransfer,`A drag event arrived without its DataTransfer.`);r.dropEffect=`move`,n.classList.add(c)}function ne(e){let t=x(e.target,d);!t||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||t.classList.remove(c)}function re(e){let t=x(e.target,d);if(!t||!g)return;e.preventDefault(),t.classList.remove(c);let{root:n,keys:r}=g;w(n,r,t),C()}function E(e){let t=x(e.target,d);t&&_?.keys.length&&(e.preventDefault(),w(_.root,_.keys,t))}function ie(e){(a(e)||e.key===` `)&&E(e)}function ae(e){h.has(e)||(h.add(e),e.addEventListener(`dragover`,T),e.addEventListener(`dragenter`,T),e.addEventListener(`dragleave`,ne),e.addEventListener(`drop`,re),e.addEventListener(`click`,E),e.addEventListener(`keydown`,ie))}function oe(t){let n=m.get(t);if(n)return n;ae(t.ownerDocument||t);let r=e=>{let n=x(e.target,f);if(!n||!t.contains(n))return;let r=b(e.target,ee);r&&n.contains(r)||(n.draggable=!0)},i=n=>{let r=x(n.target,f);if(!r||!t.contains(r))return;let i=v(r)?y(t):[r.dataset.rowKey],a=e(n.dataTransfer,`A drag event arrived without its DataTransfer.`);a.setData(l,JSON.stringify(i)),a.setData(`text/plain`,i.join(`,`)),a.effectAllowed=`move`,g={root:t,keys:i},document.body.classList.add(u)},a=e=>{let n=e instanceof CustomEvent?e.detail:void 0;if(S(n)){let{keys:e}=n;n.selected>0?_={root:t,keys:Array.isArray(e)?e:y(t)}:n.selected===0&&(_=null)}O(document)};t.addEventListener(`pointerdown`,r),t.addEventListener(`dragstart`,i),t.addEventListener(`dragend`,C),t.addEventListener(`selectionchange`,a);let o=()=>{t.removeEventListener(`pointerdown`,r),t.removeEventListener(`dragstart`,i),t.removeEventListener(`dragend`,C),t.removeEventListener(`selectionchange`,a),m.delete(t)};return m.set(t,o),o}var D=()=>n(`rowDrop`,o);function O(e=document){let t=e.querySelector(`[data-wui-row-drag] tbody tr ${p}:checked`)!==null;for(let n of e.querySelectorAll(d)){n.tagName!==`BUTTON`&&(n.setAttribute(`role`,`button`),n.setAttribute(`tabindex`,`0`)),t?n.removeAttribute(`aria-disabled`):n.setAttribute(`aria-disabled`,`true`);let e=n.getAttribute(`data-wui-drop-label`)||te(n);n.setAttribute(`aria-label`,r(D().moveText,{label:e}))}for(let t of e.querySelectorAll(`.wui-drop-tray`))t.hasAttribute(`role`)||(t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,D().moveLabel))}var k=[`light`,`dark`,`auto`],A=[`wave`,`circle`,`slide`,`blinds`,`fade`,`none`],j=`fade`,M=`theme`,N={wave:1100,circle:700,slide:600,blinds:900,fade:350,none:0},P=`wui-theme-switching`,F=`wui:theme:change`,I=`(prefers-color-scheme: dark)`,L=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches,R=e=>k.some(t=>t===e);function z(e){return e===`dark`||e===`auto`&&L(I)?`dark`:`light`}function B(e=M){let t=null;try{t=window.localStorage.getItem(e)}catch(e){if(!(e instanceof DOMException))throw e}return R(t)?t:`auto`}function V(e,t=M){try{window.localStorage.setItem(t,e)}catch(e){if(!(e instanceof DOMException))throw e}}function H(e){let t=document.documentElement,n=z(e);t.setAttribute(`data-theme`,e),t.setAttribute(`data-bs-theme`,n),document.dispatchEvent(new CustomEvent(F,{detail:{mode:n,preference:e}}))}var U=`((k)=>{let m;try{m=localStorage.getItem(k)}catch{m=null}if(m!=='light'&&m!=='dark')m='auto';const r=document.documentElement,q=window.matchMedia?window.matchMedia('(prefers-color-scheme: dark)'):null;function s(){const t=r.getAttribute('data-theme');r.setAttribute('data-bs-theme',t==='auto'?(q?.matches?'dark':'light'):t)}r.setAttribute('data-theme',m);s();if(q?.addEventListener)q.addEventListener('change',()=>{if(r.getAttribute('data-theme')==='auto')s()})})(`;function W(e=M){return`${U}${JSON.stringify(String(e)).replace(/</g,`\\u003c`)})`}function G(e,{includeAuto:t=!1}={}){return e===`light`?`dark`:e===`dark`&&t?`auto`:`light`}function K(e){if(typeof window>`u`||typeof window.matchMedia!=`function`)return()=>{};let t=window.matchMedia(I),n=()=>e(t.matches?`dark`:`light`);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}var q=60,se=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,J=e=>e.toFixed(1),Y=(e,t)=>`${J(e)}px ${J(t)}px`,X={amplitude:22,segments:36,cycles:1.5,ripples:2},Z=6,ce=(e,t,n,r,i)=>{let{amplitude:a,segments:o,cycles:s}=X,c=n*(t+2*a),l=i?t+a-c:c-a,u=i?t+2*a:-2*a,d=[Y(0,u)];for(let t=0;t<=o;t++){let n=e*t/o,i=l+a*Math.sin(2*Math.PI*s*t/o+r);d.push(Y(n,i))}return d.push(Y(e,u)),`polygon(${d.join(`, `)})`},le=(e,t,n,r)=>{let i=t/Z,a=[];for(let t=0;t<Z;t++){let o=t*i,s=i*n,c=r?o+i-s:o,l=r?o+i:o+s;a.push(Y(0,c),Y(e,c),Y(e,l),Y(0,l))}return`polygon(${a.join(`, `)})`};function Q(e,{width:t,height:n,to:r=`dark`,origin:i}){let a=r===`dark`,o=[];for(let r=0;r<=q;r++){let s=r/q,c=se(s);switch(e){case`circle`:{let e=i?.x??t/2,r=i?.y??n/2,a=Math.hypot(Math.max(e,t-e),Math.max(r,n-r));o.push({clipPath:`circle(${J(a*c)}px at ${J(e)}px ${J(r)}px)`});break}case`slide`:{let e=n*(1-c);o.push({clipPath:a?`inset(${J(e)}px 0px 0px 0px)`:`inset(0px 0px ${J(e)}px 0px)`});break}case`blinds`:o.push({clipPath:le(t,n,c,a)});break;case`fade`:o.push({clipPath:`none`,opacity:c});break;case`none`:return[];default:o.push({clipPath:ce(t,n,c,s*X.ripples*2*Math.PI,a)})}}return o}var $=e=>{e instanceof DOMException&&(e.name===`AbortError`||e.name===`InvalidStateError`)||i(`[@webority/ui-elements] The theme view transition failed:`,e)};function ue(e,{effect:t=j,to:n,origin:r,duration:i}={}){let a=document.documentElement,o=n!==void 0&&a.getAttribute(`data-bs-theme`)===n;if(t===`none`||o||L(`(prefers-reduced-motion: reduce)`)||typeof document.startViewTransition!=`function`||typeof a.animate!=`function`)return e(),Promise.resolve(!1);a.classList.add(P);let s=document.startViewTransition(e),c=i??N[t]??N.fade;return s.ready.then(()=>{let e=Q(t,{width:window.innerWidth,height:window.innerHeight,to:n,origin:r});a.animate(e,{duration:c,easing:`linear`,fill:`both`,pseudoElement:`::view-transition-new(root)`})}).catch($),s.finished.catch($).finally(()=>a.classList.remove(P)).then(()=>!0)}export{s as _,N as a,H as c,z as d,V as f,K as g,ue as h,A as i,G as l,Q as m,M as n,k as o,W as p,F as r,P as s,j as t,B as u,oe as v,O as y};