@webority/ui-elements 0.150.0 → 0.152.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 (110) hide show
  1. package/dist/{WuiCommentThread-By-u3c5S.js → WuiCommentThread-BmRsl0K1.js} +1 -1
  2. package/dist/{WuiDataTable-D8UW2DMH.js → WuiDataTable-B4BYCd_s.js} +1 -1
  3. package/dist/WuiInlineEdit-BlBuWkHG.js +1 -0
  4. package/dist/{WuiLightbox-D7Nf1SbH.js → WuiLightbox-C2A14vHx.js} +1 -1
  5. package/dist/{WuiMarkdown-N96OX-To.js → WuiMarkdown-BXY0QKaO.js} +1 -1
  6. package/dist/{WuiMentionInput-BFB57FZI.js → WuiMentionInput-8Xjkzdqg.js} +1 -1
  7. package/dist/{WuiNotificationCenter-C6e13nCh.js → WuiNotificationCenter-ClkCTUnp.js} +1 -1
  8. package/dist/{WuiOverflow-CeLUmJR-.js → WuiOverflow-B0wA6aDe.js} +1 -1
  9. package/dist/{WuiPhone-rtex3VDC.js → WuiPhone-BVNVerap.js} +1 -1
  10. package/dist/{WuiRelativeTime-RdC80Zii.js → WuiRelativeTime-DyeUQOQ8.js} +1 -1
  11. package/dist/{WuiRollingNumber-YRMeRCGW.js → WuiRollingNumber-sfgNzaP0.js} +1 -1
  12. package/dist/WuiSavedViews-UaiP6YNG.js +1 -0
  13. package/dist/WuiSelect-DBPre2oe.js +9 -0
  14. package/dist/WuiTour-Cx61ijsm.js +1 -0
  15. package/dist/{WuiTree-ZD9GGmtg.js → WuiTree-0Yqu199O.js} +1 -1
  16. package/dist/{chips-2yXiMhK4.js → chips-Dony2fgq.js} +1 -1
  17. package/dist/{dataTable-D23oUOhU.js → dataTable-B-7oAeii.js} +1 -1
  18. package/dist/{drawerDiscard-CUN8L47U.js → drawerDiscard-C0yRSl1I.js} +1 -1
  19. package/dist/elements/comment-thread.js +1 -1
  20. package/dist/elements/data-table.js +1 -1
  21. package/dist/elements/inline-edit.js +1 -1
  22. package/dist/elements/kanban.js +1 -1
  23. package/dist/elements/lightbox.js +1 -1
  24. package/dist/elements/markdown.js +1 -1
  25. package/dist/elements/mention-input.js +1 -1
  26. package/dist/elements/notification-center.js +1 -1
  27. package/dist/elements/overflow.js +1 -1
  28. package/dist/elements/phone.js +1 -1
  29. package/dist/elements/relative-time.js +1 -1
  30. package/dist/elements/rolling-number.js +1 -1
  31. package/dist/elements/saved-views.js +1 -1
  32. package/dist/elements/select.js +1 -1
  33. package/dist/elements/tour.js +1 -1
  34. package/dist/elements/tree.js +1 -1
  35. package/dist/{fileViewerImage-tzF4DDq7.js → fileViewerImage-Bt1jeArm.js} +1 -1
  36. package/dist/{fileViewerPdf-BLMhF8NT.js → fileViewerPdf-CdaDuaRJ.js} +1 -1
  37. package/dist/formatters-ljfITOZ3.js +1 -0
  38. package/dist/helpers.js +1 -1
  39. package/dist/{inlineEditText-H7Pr8IU9.js → inlineEditText-CsLCQbcg.js} +1 -1
  40. package/dist/{kanban-CJ587-XT.js → kanban-Dz8m-17x.js} +1 -1
  41. package/dist/{kanbanModel-BdqSa1lJ.js → kanbanModel-C2IOPJ8L.js} +1 -1
  42. package/dist/{notificationDays-BKVW7xYD.js → notificationDays-BIWczft0.js} +1 -1
  43. package/dist/{relativeTime-YTAOONRy.js → relativeTime-BahImc8F.js} +1 -1
  44. package/dist/{search-BXcvm716.js → search-C8xIzt6h.js} +1 -1
  45. package/dist/server.js +1 -1
  46. package/dist/ui-calendar.global.js +1 -1
  47. package/dist/ui-calendar.js +1 -1
  48. package/dist/ui-chart.global.js +2 -2
  49. package/dist/ui-chart.js +2 -2
  50. package/dist/ui-elements/carousel.global.js +1 -1
  51. package/dist/ui-elements/code-block.global.js +1 -1
  52. package/dist/ui-elements/command-palette.global.js +1 -1
  53. package/dist/ui-elements/comment-thread.global.js +1 -1
  54. package/dist/ui-elements/consent-banner.global.js +1 -1
  55. package/dist/ui-elements/context-menu.global.js +1 -1
  56. package/dist/ui-elements/date-range.global.js +1 -1
  57. package/dist/ui-elements/drawer.global.js +1 -1
  58. package/dist/ui-elements/glyphs.global.js +1 -1
  59. package/dist/ui-elements/image-crop.global.js +1 -1
  60. package/dist/ui-elements/inline-edit.global.js +1 -1
  61. package/dist/ui-elements/kanban.global.js +1 -1
  62. package/dist/ui-elements/lead-popup.global.js +1 -1
  63. package/dist/ui-elements/lightbox.global.js +1 -1
  64. package/dist/ui-elements/markdown.global.js +2 -2
  65. package/dist/ui-elements/org-tree.global.js +1 -1
  66. package/dist/ui-elements/phone.global.js +2 -2
  67. package/dist/ui-elements/resizable.global.js +1 -1
  68. package/dist/ui-elements/saved-views.global.js +1 -1
  69. package/dist/ui-elements/select-chips.global.js +1 -1
  70. package/dist/ui-elements/select-recents.global.js +1 -1
  71. package/dist/ui-elements/select-search.global.js +1 -1
  72. package/dist/ui-elements/slider.global.js +1 -1
  73. package/dist/ui-elements/sortable.global.js +1 -1
  74. package/dist/ui-elements/status-icon.global.js +1 -1
  75. package/dist/ui-elements/timepicker.global.js +1 -1
  76. package/dist/ui-elements/tour.global.js +1 -1
  77. package/dist/ui-elements/tree.global.js +1 -1
  78. package/dist/ui-elements/wizard.global.js +1 -1
  79. package/dist/ui-elements.global.js +9 -9
  80. package/dist/ui-elements.js +1 -1
  81. package/dist/ui-file-viewer.global.js +1 -1
  82. package/dist/ui-file-viewer.js +1 -1
  83. package/dist/ui-tour.global.js +1 -1
  84. package/dist/{wuiHttp-523iN_RF.js → wuiHttp-DGbD7Fra.js} +1 -1
  85. package/package.json +4 -3
  86. package/types/WuiCommentThread.d.ts +2 -2
  87. package/types/WuiImageCrop.d.ts +4 -4
  88. package/types/WuiSelect.d.ts +9 -0
  89. package/types/WuiTour.d.ts +1 -1
  90. package/types/chartSpec.d.ts +20 -20
  91. package/types/fileValidation.d.ts +2 -2
  92. package/types/fileViewerPdf.d.ts +3 -3
  93. package/types/formatters.d.ts +19 -14
  94. package/types/inputMask.d.ts +3 -3
  95. package/types/kanban.d.ts +1 -1
  96. package/types/listQuery.d.ts +10 -10
  97. package/types/razor-js/modules/api.d.ts +3 -0
  98. package/types/razor-js/modules/buttons.d.ts +1 -0
  99. package/types/razor-js/modules/widgets.d.ts +1 -0
  100. package/types/razor-js/webority-ui.d.ts +3 -0
  101. package/types/select/list.d.ts +8 -8
  102. package/types/server/remoteModal.d.ts +12 -12
  103. package/types/server/wuiHttp.d.ts +5 -5
  104. package/types/stepperHeader.d.ts +2 -2
  105. package/types/themeTransition.d.ts +2 -2
  106. package/dist/WuiInlineEdit-r55qgh8A.js +0 -1
  107. package/dist/WuiSavedViews-DtyAoZKb.js +0 -1
  108. package/dist/WuiSelect-D9ABfsdZ.js +0 -9
  109. package/dist/WuiTour-CrIFLmSK.js +0 -1
  110. package/dist/formatters-C3V6M5zV.js +0 -1
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./anchorOverlay-CXnWfezA.js";import{n,t as r}from"./buttonClass-GtEi8hAY.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{t as a}from"./tourOpenMark-nPeAJFSo.js";import{t as o}from"./tourSeenStore-z0Y_Znzx.js";var s=`data-advance`,c=`wui-tour-hint`,l=`wui-tour-pointer`,u=`Click {actionName} to continue.`,d=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,f=(e,t)=>e?.advanceOn===`click`&&!!t,p=e=>(e??``).replace(/\s+/g,` `).trim(),m=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,h=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 g(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(m(e)??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=p(e);if(t)return t}return``}function _(e){for(let t of[e,...e.querySelectorAll(d)])if((t instanceof HTMLElement||t instanceof SVGElement)&&t.tabIndex>=0&&!h(t))return t;return null}function v(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 ee(e,t){let n=e.querySelector(`.${c}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;if(!t)n?.remove(),i&&v(e,i,!1);else{if(!n){n=e.ownerDocument.createElement(`p`),n.className=c,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&&v(e,i,!0)}}function te(e,t){let n=e.querySelector(`.${l}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=l,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ne=e=>getComputedStyle(e).animationName;function y(e,{layer:t,spot:n,card:r},i,a){let o=f(i,a);t.toggleAttribute(s,o&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(s)&&(n.removeAttribute(s),o&&ne(n)),o&&n.setAttribute(s,``),te(n,o);let c=r.querySelector(`.wui-tour-next`);if(!(c instanceof HTMLElement))throw Error(`Tour card has no next button.`);c.classList.toggle(`btn-primary`,!o),c.classList.toggle(`btn-link`,o);let l=o?p(i?.actionLabel)||g(a):``,d=e.getAttribute(`advance-label`)||u,m=l?d.replace(/\{actionName\}/g,()=>l):``;return ee(r,m),m}function b(e,t,n){if(!f(e,t))return()=>{};let r,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function x(e,t,n,r){return e.contains(r)||f(t,n)&&n.contains(r)}function re(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=f(r,i)?_(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 ie=2/3,ae=1e3,oe=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),S=/* @__PURE__ */ new WeakMap,C=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],w=e=>`transitionProperty`in e&&e.transitionProperty===`opacity`,se=e=>`transitionProperty`in e&&typeof e.transitionProperty==`string`&&oe.has(e.transitionProperty),ce=e=>`animationName`in e&&typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function T(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,ae);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function le(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?C(t,se):[]){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*ie-r)}return n}function E(e){let t=le(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={};S.set(e,n);let r=()=>{S.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=C(e,ce);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function D(e){return e.dataset.state=`leaving`,T(C(e,w))}function ue(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?T(C(n,w)):null;r?(e.setAttribute(`inert`,``),r.then(()=>e.remove())):e.remove()}var O=2,k=12,A=8,j=4,M=20,de=`(max-width: 575.98px)`,fe=[`bottom`,`top`,`right`,`left`],N=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],P,F=(e,t,n)=>Math.max(t,Math.min(e,n)),I=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function L(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=H(e),r=e.offsetHeight+k;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+O}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function R(e,t,n){let r=e.style,i=t.style,a=me(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 N)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`,z(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=H(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-k,top:o.top-k-l.top,right:l.right-o.right-k,left:o.left-k-l.left},f=window.matchMedia(de).matches,p=fe.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+A)-Math.max(o.top,l.top-A);p?B(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?V(t,a,o,l,c):pe(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function z(e,t){P??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of N)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),P&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function B(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=I(r.left,r.right,i.left,i.right);s=F(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+k:r.top-k-a.height,l=F(e-s,M,a.width-M)}else{let e=I(r.top,r.bottom,i.top,i.bottom);c=F(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+k:r.left-k-a.width,l=F(e-c,M,a.height-M)}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 V(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)-j;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${F(n.left+j,r.left,r.right-i.width)}px`}function pe(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+k:r.top-k-c}px`;let l=I(r.left,r.right,i.left,i.right);e.style.left=`${F(l-a.width/2,i.left,i.right-a.width)}px`}function H(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e]??``)||0;return{top:r(`paddingTop`)+A,bottom:window.innerHeight-r(`paddingBottom`)-A,left:r(`paddingLeft`)+A,right:window.innerWidth-r(`paddingRight`)-A}}function me(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 he=0,ge=`btn btn-sm btn-link`;function U(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`Expected "${t}" to match a ${n.name}.`);return r}function _e(e,t,i){let a=`wui-tour-end-${++he}`,o=!!(t.nextLabel&&t.nextHref),s=e.createElement(`div`);s.className=`wui-tour-card wui-tour-end`,s.dataset.layout=`center`,o&&(s.dataset.next=``),s.setAttribute(`role`,`dialog`),i&&s.setAttribute(`aria-modal`,`true`),s.tabIndex=-1,s.setAttribute(`aria-labelledby`,`${a}-title`),s.setAttribute(`aria-describedby`,`${a}-message`),s.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${a}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${a}-message"></p> <div class="wui-tour-actions">${o?`<a class="${n(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${r}"></a>`:``}<button type="button" class="${o?ge:n(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${r}"></button></div>`,U(s,`.wui-tour-end-title`,HTMLElement).textContent=t.title,U(s,`.wui-tour-end-message`,HTMLElement).textContent=t.message,U(s,`.wui-tour-end-button`,HTMLButtonElement).textContent=t.button;let{nextLabel:c,nextHref:l}=t;if(o&&c&&l){let e=U(s,`.wui-tour-end-next`,HTMLAnchorElement);e.textContent=c,e.setAttribute(`href`,l)}return s}var ve=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function ye(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=_e(r,t,i),o=U(a,`.wui-tour-end-button`,HTMLButtonElement),s=a.querySelector(`.wui-tour-end-next`);if(s!==null&&!(s instanceof HTMLAnchorElement))throw Error(`The end dialog's next link is not a link.`);let c=s,l=c?[c,o]:[o],u=c??o,d=new AbortController;return new Promise(s=>{let f=e=>{d.abort(),s(e)};if(n?.aborted){f(`done`);return}let p=U(e,`.wui-tour-card:not(.wui-tour-end)`,HTMLElement),m=U(e,`.wui-tour-spot`,HTMLElement),h=U(e,`[role=status]`,HTMLElement),g={signal:d.signal};n?.addEventListener(`abort`,()=>f(`done`),g),o.addEventListener(`click`,()=>f(`done`),g),c&&c.addEventListener(`click`,e=>{ve(e)&&(e.preventDefault(),f(`next`))},g),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),f(`done`);else if(e.key===`Enter`&&c&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===c)e.preventDefault(),f(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=r.activeElement,n=t instanceof HTMLElement?l.indexOf(t):-1,i=n===-1?e.shiftKey?l.length-1:0:(n+(e.shiftKey?-1:1)+l.length)%l.length,a=l[i];if(!a)throw Error(`The end dialog has no focus stop.`);a.focus()}}},{capture:!0,signal:d.signal}),i&&r.addEventListener(`focusin`,e=>{let t=e.target;if(t!==null&&!(t instanceof Node))throw Error(`Focus moved to a target that is not a node.`);a.contains(t)||u.focus()},g);let _=()=>{d.signal.aborted||(p.hidden=!0,R(m,p,null),e.append(a),E(a),h.textContent=[t.title,t.message].filter(Boolean).join(`. `),u.focus())},v=D(p);v?v.then(_):_()})}var be=` :host { all: initial; ${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); } .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: 2px; } .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-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::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; } } `,W=`wui-tour-media`,xe=`wui-tour-media-toggle`,G=`http://www.w3.org/2000/svg`,Se=`M6 5h4v14H6zM14 5h4v14h-4z`,Ce=`M8 5v14l11-7z`,we={pause:`Pause animation`,play:`Play animation`},Te=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function Ee(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 De(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 Oe(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 ke(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=xe;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(Ee(r?Se:Ce))};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 Ae(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 je(e,t,n=we){if(Ae(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=W,t.mediaType===`video`){let e=Oe(t,!Te());r.append(e,ke(e,n))}else r.appendChild(De(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var Me=`Step {current} of {total}`;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 Ne(e,t,n){return(e.getAttribute(`progress-label`)||Me).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Pe(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 Fe=`wui-tour-step`,Ie=`wui-tour-host`,q=`data-tracking`,Le={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},Re={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`},ze=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},Be=0,Y=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,X=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function Z(e,t,n){let r=e.querySelector(t);if(!(r instanceof n))throw Error(`<wui-tour> layer has no ${t}`);return r}var Q=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Ve(e){$||($=new CSSStyleSheet,$.replaceSync(be)),e.adoptedStyleSheets=[$]}var He=class extends i{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 > ${Fe}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:(e.textContent??``).trim()};for(let[n,r]of ze)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`?o():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Re[e])||Le[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&&!Y(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(Y(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-${++Be}`,i=document.createElement(`div`);i.className=`wui-tour-layer`,i.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${t}-title" aria-describedby="${t}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${t}-title"></h2> <p class="wui-tour-text" id="${t}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="${n(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${r}"></button> <button type="button" class="${n(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${r}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let o=i;this._shadow=null,this.isolated&&(o=document.createElement(Ie),this._shadow=o.attachShadow({mode:`open`}),Ve(this._shadow),this._shadow.appendChild(i)),document.body.appendChild(o),document.documentElement.setAttribute(a,``),this._outer=o,this._layer=i;let s=Z(i,`.wui-tour-spot`,HTMLDivElement),c=Z(i,`.wui-tour-card`,HTMLDivElement),l=Z(i,`[role=status]`,HTMLElement);this._spot=s,this._card=c,this._live=l,Z(c,`.wui-tour-skip`,HTMLElement).addEventListener(`click`,()=>this._close(`skipped`,`button`)),Z(c,`.wui-tour-back`,HTMLElement).addEventListener(`click`,()=>this._move(-1)),Z(c,`.wui-tour-next`,HTMLElement).addEventListener(`click`,()=>this._move(1)),this._shadow&&c.removeAttribute(`aria-modal`);let u=e=>this._key(e);this._onKey=u;let d=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`);x(t,r,n?.target??null,e.target)||c.focus()};this._onFocusIn=d,document.addEventListener(`keydown`,u,!0),this._shadow||document.addEventListener(`focusin`,d),e(o,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_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`);let c=this._progress.position(t),l=this._progress.total(),u=c===l&&!this._endDialogText(),d=Ne(this,c,l);Pe(o,{text:d,position:c,total:l}),je(o,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),o.toggleAttribute(`data-welcome`,!n);let f=y(this,{layer:i,spot:a,card:o},r,n),p=Z(o,`.wui-tour-title`,HTMLElement);p.textContent=r.title||``,p.hidden=!r.title,Z(o,`.wui-tour-text`,HTMLElement).textContent=r.description||``,Z(o,`.wui-tour-skip`,HTMLElement).textContent=this._label(`skip`);let m=Z(o,`.wui-tour-back`,HTMLElement);m.textContent=this._label(`back`),m.hidden=t<=this._firstIndex,Z(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,L(o,n),a.removeAttribute(q),this._place(),E(o),this._unbindAdvance?.(),this._unbindAdvance=b(r,n,()=>this._move(1));let g=this._active();(g!==null&&o.contains(g)?!(g instanceof HTMLElement&&g.hidden):this._shadow!==null&&X(Q()))||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`);R(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=D(e);if(t&&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 y(this,{layer:t,spot:n,card:r},null,null),n.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),ye(t,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(X(e.composedPath?.()[0]??e.target))return;if(e.preventDefault(),e.key===`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`);re(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`);ue(n),document.documentElement.removeAttribute(a),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()}:J,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=J,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{He as t};
@@ -1 +1 @@
1
- import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,t as r}from"./formMirror-9IpSgeZb.js";import{t as i}from"./iconGlyphs.g-DPqoOoXy.js";import{t as a}from"./listboxKeyNav-4LeEjKq6.js";import{l as o}from"./wuiHttp-523iN_RF.js";var s=[`none`,`single`,`multiple`],c=e=>s.some(t=>t===e),l=`parentId`,u=`Loading`,d=`Could not load. Try again.`,f=`:scope > input[data-wui-mirror]`,p=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],m=0;function h(e,t,n){let r=document.createElement(e);t&&(r.className=t);for(let[e,t]of Object.entries(n??{}))t!=null&&r.setAttribute(e,String(t));return r}var g=class extends t{_uid;_seq;_roots;_byId;_prev;_staged;_els;_checked;_selected;_focusId;_loader;_list;_live;_ready;_nav;_onKeyDown;_onClick;_onFocusIn;static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++m}`,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._nav=a({getVisibleOptions:()=>this._visible().map(e=>{let t=this._els.get(e.id)?.row;if(!t)throw Error(`Row for node "${e.id}" is not rendered.`);return t}),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[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=>{let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e=/* @__PURE__ */ new Map;for(let t of p)Object.hasOwn(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=h(`ul`,`wui-tree`),this._list.setAttribute(`role`,`tree`),this._live=h(`div`,`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._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 c(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`)??u}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??d}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){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=>{let r=e?.id==null?``:String(e.id);if(!r)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(r))throw Error(`<wui-tree> node id "${r}" is used twice.`);let i=this._prev?.get(r),a={id:r,raw:e,parent:t,level:n,seq:++this._seq,label:e.label==null?r: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:i?i.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(r,a),this._staged?.ids.push(r);let o=e.children??(e.hasChildren?i?.children?.map(e=>e.raw):void 0);return Array.isArray(o)&&(a.children=this._adopt(o,a,n+1)),a.loading=!!i?.loading&&a.children===null&&a.hasChildren,e.checked&&!i&&this._staged?.checks.push(r),a})}_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(){let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),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)}_focusNode(e){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(l,e.id);let r=await o(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){if(e.key===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else e.key===`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`)n(this,this.values);else if(e===`single`)r(this,this._selected??``);else for(let e of this.querySelectorAll(f))e.remove()}_render(){if(!this._list)return;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),this._els=/* @__PURE__ */ new Map;let r=this.getAttribute(`aria-label`);r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),this._list.replaceChildren(...this._buildLevel(this._roots)),t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_buildLevel(e){return e.map((t,n)=>this._buildItem(t,n+1,e.length))}_buildItem(e,t,n){let r=this.selection,a=this._isBranch(e),o=this._state(e),s=h(`li`,`wui-tree-item`,{role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":t,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});a&&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`,o===`mixed`?`mixed`:String(o===`checked`));let c=h(`div`,`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=h(`span`,a?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,{"aria-hidden":`true`});if(a&&(l.innerHTML=i(`chevron-right`,{size:16})),c.append(l),r===`multiple`){let t=h(`input`,`form-check-input wui-tree-check`,{type:`checkbox`,tabindex:-1,"aria-hidden":`true`});t.checked=o===`checked`,t.indeterminate=o===`mixed`,t.disabled=e.disabled,t.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(t)}if(e.icon){let t=h(`span`,`wui-tree-icon`,{"aria-hidden":`true`});t.innerHTML=i(e.icon,{size:16}),c.append(t)}let u=h(`span`,`wui-tree-label`,{id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let t=h(`span`,`badge wui-tree-badge${e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``}`,{id:`${this._uid}-${e.seq}-badge`});t.textContent=e.badge,c.append(t)}if(e.loading&&c.append(h(`span`,`wui-tree-spinner`,{"aria-hidden":`true`})),s.append(c),e.expanded&&e.children?.length){let t=h(`ul`,`wui-tree-group`,{role:`group`});t.append(...this._buildLevel(e.children)),s.append(t)}return this._els.set(e.id,{li:s,row:c}),s}};export{g as t};
1
+ import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,t as r}from"./formMirror-9IpSgeZb.js";import{t as i}from"./iconGlyphs.g-DPqoOoXy.js";import{t as a}from"./listboxKeyNav-4LeEjKq6.js";import{l as o}from"./wuiHttp-DGbD7Fra.js";var s=[`none`,`single`,`multiple`],c=e=>s.some(t=>t===e),l=`parentId`,u=`Loading`,d=`Could not load. Try again.`,f=`:scope > input[data-wui-mirror]`,p=[`nodes`,`selection`,`selected`,`values`,`loadChildren`,`loadUrl`,`name`],m=0;function h(e,t,n){let r=document.createElement(e);t&&(r.className=t);for(let[e,t]of Object.entries(n??{}))t!=null&&r.setAttribute(e,String(t));return r}var g=class extends t{_uid;_seq;_roots;_byId;_prev;_staged;_els;_checked;_selected;_focusId;_loader;_list;_live;_ready;_nav;_onKeyDown;_onClick;_onFocusIn;static get observedAttributes(){return[`selection`,`selected`,`name`,`aria-label`,`loading-text`,`error-text`]}constructor(){super(),this._uid=`wui-tree-${++m}`,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._nav=a({getVisibleOptions:()=>this._visible().map(e=>{let t=this._els.get(e.id)?.row;if(!t)throw Error(`Row for node "${e.id}" is not rendered.`);return t}),getActive:()=>this._visible().findIndex(e=>e.id===this._focusId),setActive:e=>this._focusNode(this._visible()[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=>{let t=this._nodeFrom(e.target);t&&t.id!==this._focusId&&this._setRoving(t)}}connectedCallback(){let e=/* @__PURE__ */ new Map;for(let t of p)Object.hasOwn(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=h(`ul`,`wui-tree`),this._list.setAttribute(`role`,`tree`),this._live=h(`div`,`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._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 c(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`)??u}set loadingText(e){this.setAttribute(`loading-text`,String(e??``))}get errorText(){return this.getAttribute(`error-text`)??d}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){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=>{let r=e?.id==null?``:String(e.id);if(!r)throw Error(`<wui-tree> every node needs an id.`);if(this._byId.has(r))throw Error(`<wui-tree> node id "${r}" is used twice.`);let i=this._prev?.get(r),a={id:r,raw:e,parent:t,level:n,seq:++this._seq,label:e.label==null?r: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:i?i.expanded:!!e.expanded,loading:!1,failed:!1};this._byId.set(r,a),this._staged?.ids.push(r);let o=e.children??(e.hasChildren?i?.children?.map(e=>e.raw):void 0);return Array.isArray(o)&&(a.children=this._adopt(o,a,n+1)),a.loading=!!i?.loading&&a.children===null&&a.hasChildren,e.checked&&!i&&this._staged?.checks.push(r),a})}_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(){let e=[],t=n=>{for(let r of n)e.push(r),r.expanded&&r.children&&t(r.children)};return t(this._roots),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)}_focusNode(e){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(l,e.id);let r=await o(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){if(e.key===`ArrowRight`){if(e.preventDefault(),!this._isBranch(t)||t.disabled)return;t.expanded?t.children?.length&&this._focusNode(t.children[0]):this._expand(t)}else e.key===`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`)n(this,this.values);else if(e===`single`)r(this,this._selected??``);else for(let e of this.querySelectorAll(f))e.remove()}_render(){if(!this._list)return;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),this._els=/* @__PURE__ */ new Map;let r=this.getAttribute(`aria-label`);r?this._list.setAttribute(`aria-label`,r):this._list.removeAttribute(`aria-label`),this._list.replaceChildren(...this._buildLevel(this._roots)),t&&this._focusId&&this._els.get(this._focusId)?.li.focus(),this._syncForm()}_buildLevel(e){return e.map((t,n)=>this._buildItem(t,n+1,e.length))}_buildItem(e,t,n){let r=this.selection,a=this._isBranch(e),o=this._state(e),s=h(`li`,`wui-tree-item`,{role:`treeitem`,tabindex:e.id===this._focusId?0:-1,"aria-level":e.level,"aria-setsize":n,"aria-posinset":t,"aria-labelledby":`${this._uid}-${e.seq}`,"aria-describedby":e.badge?`${this._uid}-${e.seq}-badge`:null});a&&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`,o===`mixed`?`mixed`:String(o===`checked`));let c=h(`div`,`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=h(`span`,a?`wui-tree-toggle`:`wui-tree-toggle wui-tree-toggle-leaf`,{"aria-hidden":`true`});if(a&&(l.innerHTML=i(`chevron-right`,{size:16})),c.append(l),r===`multiple`){let t=h(`input`,`form-check-input wui-tree-check`,{type:`checkbox`,tabindex:-1,"aria-hidden":`true`});t.checked=o===`checked`,t.indeterminate=o===`mixed`,t.disabled=e.disabled,t.addEventListener(`mousedown`,e=>e.preventDefault()),c.append(t)}if(e.icon){let t=h(`span`,`wui-tree-icon`,{"aria-hidden":`true`});t.innerHTML=i(e.icon,{size:16}),c.append(t)}let u=h(`span`,`wui-tree-label`,{id:`${this._uid}-${e.seq}`});if(u.textContent=e.label,c.append(u),e.badge){let t=h(`span`,`badge wui-tree-badge${e.badgeTone&&e.badgeTone!==`neutral`?` badge-${e.badgeTone}`:``}`,{id:`${this._uid}-${e.seq}-badge`});t.textContent=e.badge,c.append(t)}if(e.loading&&c.append(h(`span`,`wui-tree-spinner`,{"aria-hidden":`true`})),s.append(c),e.expanded&&e.children?.length){let t=h(`ul`,`wui-tree-group`,{role:`group`});t.append(...this._buildLevel(e.children)),s.append(t)}return this._els.set(e.id,{li:s,row:c}),s}};export{g as t};
@@ -1,2 +1,2 @@
1
- import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-DPqoOoXy.js";import{a as r,i,n as a,r as o}from"./optionLabel-4xjXWy74.js";import{t as s}from"./customRule-Chp7YwFb.js";import{r as c}from"./WuiSelect-D9ABfsdZ.js";var l={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},u={enter:`
1
+ import{n as e,t}from"./fieldState-D-zQcXUS.js";import{t as n}from"./iconGlyphs.g-DPqoOoXy.js";import{a as r,i,n as a,r as o}from"./optionLabel-4xjXWy74.js";import{t as s}from"./customRule-Chp7YwFb.js";import{r as c}from"./WuiSelect-DBPre2oe.js";var l={enter:`Enter`,comma:`,`,space:` `,tab:`Tab`},u={enter:`
2
2
  `,comma:`,`,space:` `,tab:` `},d=e=>l[e],ee=e=>u[e];function te(e,t){let n=[String(e??``)];for(let e of t)n=n.flatMap(t=>t.split(e));return n.map(e=>e.trim()).filter(Boolean)}var ne=(e,t)=>t.some(t=>String(e??``).includes(t));function f(e,t){if(e===null)throw TypeError(`The chip row needs ${t}, and it is not mounted.`);return e}var p=(e,t)=>{let n=document.createElement(e);return n.className=t,n};function m(){let l,u,m=null,h=null,g=null,_=null,v=null,y=null,b=null,x=null,S=!1,C=()=>f(h,`the draft input`),w=()=>l.mode===`tag`,T=()=>Array.isArray(l.value)?l.value.slice():[],E=()=>(l.getAttribute(`separators`)||`enter,comma`).split(`,`).map(e=>e.trim()).filter(Boolean),re=()=>new Set(E().map(d).filter(Boolean)),D=()=>{let e=parseInt(l.getAttribute(`max-tags`)??``,10);return e>0?e:0},O=()=>{let e=D();return e>0&&T().length>=e},k=(e,t)=>!l.hasAttribute(`allow-duplicates`)&&e.some(e=>e.toLowerCase()===t.toLowerCase()),A=e=>(l.options||[]).find(t=>String(t.value)===String(e)),j=e=>{let t=e.trim().toLowerCase();return(l.options||[]).find(e=>String(e.value??``).toLowerCase()===t||i(e).trim().toLowerCase()===t)},ie=e=>{for(let t of E()){let n=ee(t)??t;if(ne(e,[n]))return te(e,[n])}return[e.trim()]},M=()=>h?h.value:l._query||``,ae=()=>w()||l.hasAttribute(`allow-custom`),N=()=>l.getAttribute(`placeholder`)||(w()?`Add…`:`Select…`),P=()=>{let e=l.getAttribute(`aria-label`);if(e)return e;let t=l.closest(`label`)?.textContent?.trim();if(t)return t;let n=l.id;return(n?[...document.querySelectorAll(`label[for]`)].find(e=>e instanceof HTMLLabelElement&&e.htmlFor===n):void 0)?.textContent?.trim()||(w()?`Add tags`:`Select`)},F=()=>{h&&(h.setAttribute(`aria-expanded`,String(!u.menu.hidden)),u.list.id&&h.setAttribute(`aria-controls`,u.list.id),h.setAttribute(`aria-label`,P()))},oe=()=>!e(l)&&!l.hasAttribute(`loading`),se=e=>{S=!0,C().setAttribute(`aria-invalid`,`true`),l.setError(e)},I=()=>{S&&(S=!1,C().removeAttribute(`aria-invalid`),l.setError(null))},L=(e,{quiet:t=!1,strip:n=!1}={})=>{let r=T(),i=r.slice(),a=D(),o=[],c=``,u=!1;for(let t of e){let e=(n?t.trim().replace(/,+$/,``):t).trim();if(!e)continue;if(a&&i.length>=a)break;let r=j(e);if(r){if(r.disabled){o.push(e),c||=r.disabledHint||l.getAttribute(`invalid-message`)||`That option is not available.`;continue}k(i,String(r.value))||i.push(String(r.value));continue}let d=s(l,e);d?(o.push(e),c||=d):k(i,e)||(i.push(e),u=!0)}i.length!==r.length&&(u?l.commit(i,{isCustom:!0}):l.commit(i)),C().value=o.join(`, `),c?t||se(c):I()},R=e=>{t(l)||L([C().value],e)},z=e=>l.commit(T().filter(t=>t!==e)),ce=()=>{let e=p(`span`,`wui-select-placeholder`);return e.textContent=l.getAttribute(`placeholder`)||`Select…`,e},B=e=>{let t=A(e),s=p(`span`,`chip chip-sm`),c=p(`span`,`chip-label`);if(c.innerHTML=t?o(t):a(e),s.append(c),oe()){let a=p(`button`,`chip-remove`);a.type=`button`,a.dataset.remove=e;let o=t?i(t):r(e);a.setAttribute(`aria-label`,`Remove ${o}`),a.innerHTML=n(`x`),s.append(a)}return s};function V(){if(!m)return;m.querySelector(`:scope > .chip-more`)?.remove();let e=[...m.querySelectorAll(`:scope > .chip`)].map(e=>{if(!(e instanceof HTMLElement))throw Error(`The chip row holds a node that is not an element.`);return e});for(let t of e)t.style.display=``;let t=e.at(-1);if(!l.hasAttribute(`collapse-chips`)||!t)return;let n=m.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t)<=n)return;let i=p(`span`,`chip chip-sm chip-more`);i.textContent=`+${e.length}`,t.after(i);let a=i.offsetWidth+6,o=0;for(let t of e)if(r(t)<=n-a)o+=1;else break;o<1&&(o=1);for(let t of e.slice(o))t.style.display=`none`;i.textContent=`+${e.length-o}`}function H(){if(!m)return!1;m.parentNode!==u.value&&u.value.append(m);for(let e of m.querySelectorAll(`:scope > .chip, :scope > .wui-select-placeholder`))e.remove();let e=T(),n=m,r=e=>{h?n.insertBefore(e,h):n.append(e)};w()||h||e.length||r(ce());for(let t of e)r(B(t));return h&&(h.placeholder=w()||!e.length?N():``,h.disabled=l.hasAttribute(`disabled`),h.readOnly=t(l),F()),w()||(f(_,`the footer text`).textContent=(l.getAttribute(`selected-text`)||`{n} selected`).replace(`{n}`,()=>String(e.length)),f(v,`the clear-all button`).textContent=l.getAttribute(`clear-all-label`)||`Clear all`),V(),!0}function U(e){if(e.key===`Backspace`){let t=h?!M():!M()&&!u.menu.hidden,n=T().at(-1);return!t||n===void 0?!1:(e.preventDefault(),z(n),!0)}if(!h)return!1;let t=h.value;if(e.key===`Escape`){if(!w())return!1;let n=!u.menu.hidden;return!n&&!t?!1:(n&&(e.preventDefault(),e.stopPropagation()),h.value=``,I(),l.closeMenu({focusControl:!1}),!0)}let n=!w()&&!t.trim(),r=re();return e.key===`Enter`&&r.has(`Enter`)?n||u.list.querySelector(`.is-active`)?!1:(e.preventDefault(),R(),!0):e.key===`,`&&r.has(`,`)?!n&&(e.preventDefault(),R({strip:!0}),!0):e.key===` `&&r.has(` `)&&t.trim()||e.key===`Tab`&&r.has(`Tab`)&&!n?(e.preventDefault(),R(),!0):!1}function W(e){let t=String(e.value);if(w()||h&&!A(t))return L([t]),!0;let n=T();return n.includes(t)?l.commit(n.filter(e=>e!==t)):h?L([t]):l.commit([...n,t]),h?.value&&(h.value=``,I()),!0}function G(e){if(!h)return null;let t=String(e??``).trim().replace(/,+$/,``).trim();if(!t||O()||j(t)||k(T(),t))return null;let n=l.getAttribute(`create-label`)||`Create '{text}'`;return{position:w()?`top`:`bottom`,label:n.replace(`{text}`,()=>t),value:t}}function K(e){let n=e.target,r=n instanceof Element?n.closest(`[data-remove]`):null;if(r instanceof HTMLElement){if(t(l))return;e.stopPropagation(),z(r.dataset.remove??``),h?.focus()}else h&&!t(l)&&h.focus()}function q(){I();let e=C().value.trim();!w()&&e&&u.menu.hidden&&(G(e)||c(l.options||[],e).length)&&l.openMenu()}function J(e){e.preventDefault(),t(l)||L(ie(e.clipboardData?.getData(`text/plain`)??``))}function Y(){C().value.trim()&&R({quiet:!0,strip:!0}),l.closeMenu({focusControl:!1})}function X(e){e.relatedTarget instanceof Node&&l.contains(e.relatedTarget)||Y()}function le(){return h?(Y(),!0):!1}function Z(){C().value.trim()&&R({strip:!0})}function Q(){t(l)||l.commit([])}function $(e){e.target!==h&&e.preventDefault()}function ue(e,t,n={}){l=e,u=t,m=p(`div`,`wui-select-chips`),m.addEventListener(`click`,K),u.value.append(m),ae()&&(h=p(`input`,`wui-select-draft`),h.type=`text`,h.setAttribute(`autocomplete`,`off`),h.setAttribute(`role`,`combobox`),h.setAttribute(`aria-autocomplete`,`list`),l.hasAttribute(`required`)&&h.setAttribute(`aria-required`,`true`),x=new MutationObserver(F),x.observe(u.menu,{attributes:!0,attributeFilter:[`hidden`]}),m.append(h),h.value=n.carry?.draft??``,u.input=h,h.addEventListener(`input`,q),h.addEventListener(`paste`,J),h.addEventListener(`blur`,X),m.addEventListener(`mousedown`,$),y=l.closest(`form`),y?.addEventListener(`submit`,Z,!0)),w()||(g=p(`div`,`wui-select-footer`),_=document.createElement(`span`),v=p(`button`,`wui-select-clear-all`),v.type=`button`,v.addEventListener(`click`,Q),g.append(_,v),u.menu.append(g)),typeof ResizeObserver<`u`&&(b=new ResizeObserver(V),b.observe(m)),H()}function de(){m?.removeEventListener(`click`,K),m?.removeEventListener(`mousedown`,$),h&&(h.removeEventListener(`input`,q),h.removeEventListener(`paste`,J),h.removeEventListener(`blur`,X),u.input=null),v&&v.removeEventListener(`click`,Q),y?.removeEventListener(`submit`,Z,!0),y=null,b?.disconnect(),b=null,x?.disconnect(),x=null,g?.remove(),m?.remove(),m=null,h=null,g=null,S=!1}return{mount:ue,onKey:U,onPick:W,renderValue:H,actionRow:G,onQuery:()=>!1,onBlur:le,teardown:de}}export{m as default};
@@ -1 +1 @@
1
- import{f as e}from"./formatters-C3V6M5zV.js";var t=48,n=1200,r=10,i=50,a=[`start`,`end`],o=8,s={comfortable:72,cozy:48,compact:40},c={resize:e=>e?`Resize ${e} column`:`Resize column`,width:e=>`${e} pixels`,rows:t=>`${e(t,{decimals:0})} ${t===1?`row`:`rows`}`,saved:e=>e?`${e} saved.`:`Row saved.`,savedMany:t=>`${e(t,{decimals:0})} rows saved.`,notSaved:(e,t)=>`${e?`${e} was not saved.`:`Row was not saved.`}${t?` ${t}`:``}`},l=t=>e(t,{decimals:0}),u=e=>Math.min(n,Math.max(48,Math.round(Number(e)||0)));function d(e,t,n=[]){let r=new Map(n.map(e=>[e,[]]));return e.forEach((e,n)=>{let i=t(e,n),a=r.get(i);a||(a=[],r.set(i,a)),a.push(e)}),[...r].filter(([,e])=>e.length>0).map(([e,t])=>({key:e,items:t}))}function f({scrollTop:e,viewport:t,rowHeight:n,count:r,overscan:i=8}){let a=n>0?n:s.comfortable,o=Math.floor(Math.max(0,e)/a),c=Math.max(0,o-i);c-=c%2;let l=Math.min(r,o+Math.ceil(Math.max(0,t)/a)+i),u=Math.min(c,l);return{start:u,end:l,before:u*a,after:Math.max(0,r-l)*a}}var p=e=>`wui-widths:${e}`;function m(e){if(!e)return{};try{let t=JSON.parse(window.localStorage.getItem(p(e))||`{}`),n={};if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))Number.isFinite(r)&&(n[e]=u(r));return n}catch{return{}}}function h(e,t){if(e)try{Object.keys(t).length?window.localStorage.setItem(p(e),JSON.stringify(t)):window.localStorage.removeItem(p(e))}catch{}}var g=(e,t)=>`--wui-pin-${e}-${t}`,_=`--wui-pin-at`,v=(e,t)=>`var(${g(e,t)}, 0px)`;function y(e){let t=e.map(()=>null),n=-1;e.forEach((e,t)=>{e===`start`&&(n=t)});let r=0;for(let i=0;i<=n;i++)(e[i]===`start`||e[i]===`lead`)&&(t[i]={side:`start`,ordinal:r++,edge:!1});let i=t[n];i&&(i.edge=!0);let a=-1;r=0;for(let n=e.length-1;n>=0;n--)e[n]===`end`&&(t[n]={side:`end`,ordinal:r++,edge:!1},a=n);let o=t[a];return o&&(o.edge=!0),t}var b=e=>e?`wui-pin-${e.side}${e.edge?` wui-pin-${e.side}-edge`:``}`:``,x=200,S=220,C=`cubic-bezier(0.22, 1, 0.36, 1)`,w=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,T=e=>e.getAttribute(`data-row-key`)??e;function E(e){let t=[...e];if(t.length>200)return null;let n=/* @__PURE__ */ new Map;for(let e of t)e.hidden||n.set(T(e),e.offsetTop);return n}function D(e,t){let n=[...e];if(!t||n.length>200||w())return 0;let r=0;for(let e of n){if(e.hidden||typeof e.animate!=`function`)continue;let n=t.get(T(e));if(n===void 0)continue;let i=n-e.offsetTop;Math.abs(i)<1||(e.animate([{transform:`translateY(${i}px)`},{transform:`translateY(0)`}],{duration:220,easing:C}),r++)}return r}function O(e,t){if(!e||!t)return!1;let n=new Set(t),r=new Set(e),i=e.filter(e=>n.has(e)),a=t.filter(e=>r.has(e));return i.some((e,t)=>e!==a[t])}var k=[`saving`,`error`],A=`data-wui-save-state`,j=`wui-row-save-error`,M=e=>{let t=e.querySelector(`:scope > .wui-name-cell`);return t instanceof HTMLTableCellElement?t:[...e.cells].find(e=>!e.matches(`.wui-select-cell, .wui-expand-cell`))??null};function N(e){let t=M(e);if(!t)return``;let n=t.querySelector(`.u-name`);if(n)return(n.textContent??``).trim();let r=``;for(let e of t.childNodes)e instanceof Element&&e.classList.contains(`wui-row-save-error`)||(r+=e.textContent??``);return r.replace(/\s+/g,` `).trim()}function P(e,t,n=``){if(t!==null&&!k.includes(t))throw Error(`A row's save state is ${k.join(` or `)} (or null to clear it), not "${t}".`);e.querySelector(`:scope > * > .${j}`)?.remove(),t===null?e.removeAttribute(A):e.setAttribute(A,t),t===`saving`?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let r=t===`error`&&n?M(e):null;if(r){let t=e.ownerDocument.createElement(`span`);t.className=j,t.textContent=n,r.append(t)}}function F(e,t){let n=[];if(!e)return n;for(let[r,i]of e){let e=t.get(r);i.state===`saving`&&e&&e.state!==`saving`&&n.push({label:e.label,ok:e.state!==`error`,message:e.message||``})}return n}function I(e){let t=e.filter(e=>e.ok),n=[],[r]=t;t.length===1&&r?n.push(c.saved(r.label)):t.length>1&&n.push(c.savedMany(t.length));for(let t of e)t.ok||n.push(c.notSaved(t.label,t.message));return n.join(` `)}export{F as A,y as C,O as D,N as E,h as M,I as O,g as S,m as T,d as _,a,v as b,s as c,A as d,j as f,l as g,u as h,_ as i,f as j,P as k,x as l,o as m,t as n,r as o,k as p,c as r,i as s,n as t,S as u,M as v,D as w,b as x,E as y};
1
+ import{f as e}from"./formatters-ljfITOZ3.js";var t=48,n=1200,r=10,i=50,a=[`start`,`end`],o=8,s={comfortable:72,cozy:48,compact:40},c={resize:e=>e?`Resize ${e} column`:`Resize column`,width:e=>`${e} pixels`,rows:t=>`${e(t,{decimals:0})} ${t===1?`row`:`rows`}`,saved:e=>e?`${e} saved.`:`Row saved.`,savedMany:t=>`${e(t,{decimals:0})} rows saved.`,notSaved:(e,t)=>`${e?`${e} was not saved.`:`Row was not saved.`}${t?` ${t}`:``}`},l=t=>e(t,{decimals:0}),u=e=>Math.min(n,Math.max(48,Math.round(Number(e)||0)));function d(e,t,n=[]){let r=new Map(n.map(e=>[e,[]]));return e.forEach((e,n)=>{let i=t(e,n),a=r.get(i);a||(a=[],r.set(i,a)),a.push(e)}),[...r].filter(([,e])=>e.length>0).map(([e,t])=>({key:e,items:t}))}function f({scrollTop:e,viewport:t,rowHeight:n,count:r,overscan:i=8}){let a=n>0?n:s.comfortable,o=Math.floor(Math.max(0,e)/a),c=Math.max(0,o-i);c-=c%2;let l=Math.min(r,o+Math.ceil(Math.max(0,t)/a)+i),u=Math.min(c,l);return{start:u,end:l,before:u*a,after:Math.max(0,r-l)*a}}var p=e=>`wui-widths:${e}`;function m(e){if(!e)return{};try{let t=JSON.parse(window.localStorage.getItem(p(e))||`{}`),n={};if(t&&typeof t==`object`)for(let[e,r]of Object.entries(t))Number.isFinite(r)&&(n[e]=u(r));return n}catch{return{}}}function h(e,t){if(e)try{Object.keys(t).length?window.localStorage.setItem(p(e),JSON.stringify(t)):window.localStorage.removeItem(p(e))}catch{}}var g=(e,t)=>`--wui-pin-${e}-${t}`,_=`--wui-pin-at`,v=(e,t)=>`var(${g(e,t)}, 0px)`;function y(e){let t=e.map(()=>null),n=-1;e.forEach((e,t)=>{e===`start`&&(n=t)});let r=0;for(let i=0;i<=n;i++)(e[i]===`start`||e[i]===`lead`)&&(t[i]={side:`start`,ordinal:r++,edge:!1});let i=t[n];i&&(i.edge=!0);let a=-1;r=0;for(let n=e.length-1;n>=0;n--)e[n]===`end`&&(t[n]={side:`end`,ordinal:r++,edge:!1},a=n);let o=t[a];return o&&(o.edge=!0),t}var b=e=>e?`wui-pin-${e.side}${e.edge?` wui-pin-${e.side}-edge`:``}`:``,x=200,S=220,C=`cubic-bezier(0.22, 1, 0.36, 1)`,w=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,T=e=>e.getAttribute(`data-row-key`)??e;function E(e){let t=[...e];if(t.length>200)return null;let n=/* @__PURE__ */ new Map;for(let e of t)e.hidden||n.set(T(e),e.offsetTop);return n}function D(e,t){let n=[...e];if(!t||n.length>200||w())return 0;let r=0;for(let e of n){if(e.hidden||typeof e.animate!=`function`)continue;let n=t.get(T(e));if(n===void 0)continue;let i=n-e.offsetTop;Math.abs(i)<1||(e.animate([{transform:`translateY(${i}px)`},{transform:`translateY(0)`}],{duration:220,easing:C}),r++)}return r}function O(e,t){if(!e||!t)return!1;let n=new Set(t),r=new Set(e),i=e.filter(e=>n.has(e)),a=t.filter(e=>r.has(e));return i.some((e,t)=>e!==a[t])}var k=[`saving`,`error`],A=`data-wui-save-state`,j=`wui-row-save-error`,M=e=>{let t=e.querySelector(`:scope > .wui-name-cell`);return t instanceof HTMLTableCellElement?t:[...e.cells].find(e=>!e.matches(`.wui-select-cell, .wui-expand-cell`))??null};function N(e){let t=M(e);if(!t)return``;let n=t.querySelector(`.u-name`);if(n)return(n.textContent??``).trim();let r=``;for(let e of t.childNodes)e instanceof Element&&e.classList.contains(`wui-row-save-error`)||(r+=e.textContent??``);return r.replace(/\s+/g,` `).trim()}function P(e,t,n=``){if(t!==null&&!k.includes(t))throw Error(`A row's save state is ${k.join(` or `)} (or null to clear it), not "${t}".`);e.querySelector(`:scope > * > .${j}`)?.remove(),t===null?e.removeAttribute(A):e.setAttribute(A,t),t===`saving`?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`);let r=t===`error`&&n?M(e):null;if(r){let t=e.ownerDocument.createElement(`span`);t.className=j,t.textContent=n,r.append(t)}}function F(e,t){let n=[];if(!e)return n;for(let[r,i]of e){let e=t.get(r);i.state===`saving`&&e&&e.state!==`saving`&&n.push({label:e.label,ok:e.state!==`error`,message:e.message||``})}return n}function I(e){let t=e.filter(e=>e.ok),n=[],[r]=t;t.length===1&&r?n.push(c.saved(r.label)):t.length>1&&n.push(c.savedMany(t.length));for(let t of e)t.ok||n.push(c.notSaved(t.label,t.message));return n.join(` `)}export{F as A,y as C,O as D,N as E,h as M,I as O,g as S,m as T,d as _,a,v as b,s as c,A as d,j as f,l as g,u as h,_ as i,f as j,P as k,x as l,o as m,t as n,r as o,k as p,c as r,i as s,n as t,S as u,M as v,D as w,b as x,E as y};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n,r,t as i}from"./dom-Do1pAA12.js";import{t as a}from"./loader-ByHAB1wi.js";import{n as o,t as s}from"./devWarn-DXdRWZs3.js";import{E as c,k as l,r as u,w as ee,y as d}from"./dataTable-D23oUOhU.js";import{t as te}from"./iconGlyphs.g-DPqoOoXy.js";import{LIST_QUERY_RESERVED as f,SEARCH_PARAM as p}from"./listQuery.js";import{l as ne,s as m}from"./wuiHttp-523iN_RF.js";function re(e,t){let n=e.getInstance(t);n&&(n.tip?.isConnected?(t.addEventListener(`hidden${e.EVENT_KEY}`,()=>n.dispose(),{once:!0}),n.hide()):n.dispose())}var h=`Select all rows`,g=`Select row`,_=`wui-select-cell`,ie=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function v(e=document){let t=e.createElement(`th`);return t.className=_,t.appendChild(ie(e,h)),t}function ae(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=_;let r=ie(e,g);return r.disabled=t,n.appendChild(r),n}function oe(e=document){let t=e.createElement(`td`);return t.className=_,t}var y=e=>e.firstElementChild?.classList.contains(_),b=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`),x=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function se(e){for(let t of e){if(y(t)||b(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(ae(t.ownerDocument,{disabled:e}),t.firstChild)}}function ce(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;y(t)||t.insertBefore(v(e.ownerDocument),t.firstChild),se(x(e,`tbody tr`,HTMLTableRowElement));for(let t of x(e,`tfoot tr`,HTMLTableRowElement))y(t)||t.insertBefore(oe(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${_} .wui-check`);return n instanceof HTMLInputElement?n:null}function le(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 ue=`tbody .${_} .wui-check:not(:disabled)`;function de(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,ue,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 S=Object.freeze({loading:`Loading rows`,error:`These rows did not load. Try again.`,network:`The connection dropped before the rows loaded. Check it and try again.`,forbidden:`You do not have access to these rows.`,retry:`Retry`,actionFailed:`That did not work. Try again.`,actionForbidden:`You do not have permission to do that.`,empty:`No rows`}),fe=5,pe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,me=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,he=e=>pe(e)&&`type`in e&&e.type===`hidden`,C=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),w=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},T=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},ge=e=>e.localName===`wui-select`,_e=/* @__PURE__ */ new WeakMap,E=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ve=e=>({total:E(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:E(e.dataset.page,1),pageSize:E(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),ye=(e,t)=>{e&&k().toast(e,{variant:t})},be=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!he(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!f.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of C(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},xe=new Intl.NumberFormat(`en-IN`),Se=(e,t)=>t?`${xe.format(e)}+`:xe.format(e),Ce=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?w(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Se(t,n))};function D(e=document){let t=C(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(_e.has(e))continue;let t=we(e);_e.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function O(e){let t=e instanceof Element?T(e,`[data-wui-server]`,HTMLElement):null;return t&&_e.get(t)||null}function we(n){let i=w(n,`.table-wrap`,HTMLElement),a=i?w(i,`:scope > table`,HTMLTableElement):null,re=n.dataset.src;if(!i||!a||!re)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let h=w(i,`:scope > [data-wui-table-state]`,HTMLElement),g=w(n,`[data-wui-table-pager]`,HTMLElement),ie=w(n,`[data-wui-table-status]`,HTMLElement),v={urlState:n.dataset.urlState!==`false`,refreshOnSuccess:n.dataset.refreshOnSuccess!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||S.loading,errorText:n.dataset.errorText||S.error},ae=new URL(re,window.location.href),oe=new Set(ae.searchParams.keys()),y=a.hasAttribute(`data-app-datatable-selectable`),b=/* @__PURE__ */ new Set,x=!1,ue=m(),_e=new AbortController,E={signal:_e.signal},xe=w(a,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),D=r(xe,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),O=ve(D),we=null,Te=null,Ee=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))oe.has(n)||t.append(n,r);return t},De=e=>Ee(new URL(e,window.location.href).search),Oe=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},ke=e=>{let t=new URL(ae.href);for(let[n,r]of e)oe.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},je=(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=je(v.urlState?Ee(window.location.search):new URLSearchParams,O);v.urlState&&Oe(A)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,Oe(A));let j=(e,t)=>i.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),M=e=>{ie&&(ie.textContent=e)},Me=e=>{if(e.total===0)return S.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Se(e.total,!0):`${e.total}`;return`Page ${e.page} of ${t}, ${n} ${e.total===1?`row`:`rows`}`},N=()=>C(a,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),P=e=>{if(y&&C(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.`)},F=e=>{let t=n.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`)}},Ne=e=>{if(y){se(e);for(let t of e){let e=w(t,`.${_} .wui-check:not(:disabled)`,HTMLInputElement);e&&(x&&b.add(t.dataset.rowKey),e.checked=b.has(t.dataset.rowKey))}le(a)}F(e);let t=N();if(a.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`)})},Pe=e=>Ne(C(e,`:scope > tr`,HTMLTableRowElement)),Fe=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})),Ie=(e,t)=>{if(!h)return;let n=w(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(h),t.total===0&&n?(h.replaceChildren(n.content.cloneNode(!0)),h.hidden=!1):(h.replaceChildren(),h.hidden=!0)},Le=e=>{let t=ve(e),n=t.sortBy!==O.sortBy||t.sortOrder!==O.sortOrder?d(D.rows):null;if(g){let t=w(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement);I(g),g.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),g.hidden=!1}Ie(e,t);let r=w(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement),o=v.filtersRegion&&r?w(document,v.filtersRegion,HTMLElement):null;o&&r&&(I(o),o.replaceChildren(r.content.cloneNode(!0))),Fe(e),I(D),a.replaceChild(e,D),D=e;let s=x&&t.total!==O.total;return O=t,s&&(x=!1),i.removeAttribute(`data-wui-table-error`),Pe(e),H(),ee(e.rows,n),s&&We(),o},Re=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=w(t.content,`tbody[data-wui-rows]`,HTMLTableSectionElement);return n&&P(n),n?document.importNode(n,!0):null},ze=(e,t=N())=>{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},L=()=>{if(D.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,N().length);D.replaceChildren(...Array.from({length:fe},()=>{let t=ze(e);return t.setAttribute(`data-wui-skeleton`,``),t})),i.removeAttribute(`data-wui-table-error`),h&&(h.hidden=!0)},R=e=>{e?(i.setAttribute(`aria-busy`,`true`),L()):i.removeAttribute(`aria-busy`)},Be=e=>e===`forbidden`?S.forbidden:e===`network`?S.network:v.errorText,Ve=n=>{let r=Be(n);if(i.setAttribute(`data-wui-table-error`,n),g&&(g.hidden=!0),h){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`,a.innerHTML=te(n===`forbidden`?`lock`:`alert-circle`,{size:24});let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=r;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=e(`primary`,`outline`,`sm`),c.dataset.wui=t,c.setAttribute(`data-wui-table-retry`,``),c.textContent=S.retry,s.append(c),i.append(a,o,s),I(h),h.replaceChildren(i),h.hidden=!1}M(r)},z=()=>v.filtersForm?w(document,v.filtersForm,HTMLFormElement):null,B=async(e,t=`none`,{quiet:r=!1}={})=>{let a=new URLSearchParams(e);r||(we={query:a,mode:t},R(!0),M(v.loadingText)),j(`wui:table:loading`,{query:a.toString()});let c=await ue.run(ke(a));if(c.kind===`aborted`||c.kind===`stale`||c.kind===`session`)return c;r||R(!1);let l=null;if(c.ok)try{l=Re(c.html)}catch(e){s(e)}if(!c.ok||!l){let e=c.ok?`server`:c.kind;return r?o(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ve(e),j(`wui:table:error`,{status:c.status,kind:e,message:Be(e)}),c}let u=Le(l);return A=je(a,O),be(z(),A),v.urlState&&t===`push`?window.history.pushState(window.history.state,``,Oe(A)):v.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,Oe(A)),r||M(Me(O)),k().refresh(i),u&&k().refresh(u),Ce(n,O.total,O.totalCapped),j(`wui:table:loaded`,{...O,query:A.toString()}),c},V=e=>(e.delete(`page`),e),He=()=>C(a,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),H=()=>{for(let e of He()){let t=e.dataset.sortKey===O.sortBy;e.setAttribute(`aria-sort`,t?O.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of He())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`,n.innerHTML=te(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let Ue=e=>{let t=V(new URLSearchParams(A)),n=O.sortBy===e&&O.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),B(t,`push`)};a.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&a.tHead?.contains(t)&&Ue(t.dataset.sortKey??``)}),a.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?T(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&a.tHead?.contains(t)&&(e.preventDefault(),Ue(t.dataset.sortKey??``))});let We=()=>{le(a);let e=x?{selected:O.total,total:O.total,allMatching:x}:{selected:b.size,total:O.total};a.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};y&&(de(a,(e,t)=>{for(let n of e){let e=T(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?b.add(e):b.delete(e))}t||(x=!1)}),a.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(x=!1),a.tHead?.contains(t))for(let e of C(D,`:scope > tr`,HTMLTableRowElement)){let n=w(e,`.${_} .wui-check:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?b.add(e.dataset.rowKey):b.delete(e.dataset.rowKey))}else{let e=T(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?b.add(e):b.delete(e)}We()}})),g&&(g.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),B(De(t.getAttribute(`href`)??``),`push`))}),g.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),B(De(t.value),`push`))}));let U=()=>{if(!v.searchInput)return null;let e=w(document,v.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?w(e,`input`,HTMLInputElement):null},W=()=>n.isConnected?!0:(_e.abort(),clearTimeout(Te??void 0),!1),Ge=(e,t)=>{let n=[...e.elements].filter(pe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!he(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!me(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},Ke=(e,t)=>{let n=new Set([...e.elements].filter(pe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&f.includes(e);for(let[e,t]of A)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of Ge(e,t))a===``||i(n)||oe.has(n)||r.append(n,a);let a=U();if(a){r.delete(p);let e=a.value.trim();e&&r.set(p,e)}return B(r,`push`)},qe=e=>v.filtersForm&&e.closest?.(v.filtersForm)||v.filtersRegion&&e.closest?.(v.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&v.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(v.filtersForm)&&(e.preventDefault(),Ke(e.target,e.submitter))},E),document.addEventListener(`change`,e=>{if(!W()||!v.filtersForm||!(e.target instanceof Element))return;let t=T(e.target,v.filtersForm,HTMLFormElement);!t||e.target===U()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||Ke(t)},E);let Je=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of C(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 C(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(ge)){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?T(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!qe(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=V(De(n.href));Je(t.closest(`form`),r),be(t.closest(`form`),r),B(r,`push`)},E),document.addEventListener(`input`,e=>{if(!W())return;let t=U();t&&e.target===t&&(clearTimeout(Te??void 0),Te=setTimeout(()=>{if(!W())return;let e=V(new URLSearchParams(A)),n=t.value.trim();n?e.set(p,n):e.delete(p),e.toString()!==A.toString()&&B(e,`replace`)},300))},E),v.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=Ee(window.location.search),t=U();t&&(t.value=e.get(`search`)??``),be(z(),e),B(e,`none`)},E),document.addEventListener(`wui:modal:success`,()=>{W()&&v.refreshOnSuccess&&B(A,`none`)},E),h?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&we&&B(we.query,we.mode)});let G=e=>[...D.rows].find(t=>t.dataset.rowKey===e)??null,Ye=e=>{if(!e?.trim())return null;let t=document.createElement(`template`);if(t.innerHTML=`<table><tbody>${e}</tbody></table>`,t.content.querySelector(`tbody[data-wui-rows]`))return null;let n=C(t.content,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},Xe=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let a=[];for(let n of e){let e=n===r?t:G(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),a.push(n))}return Ne(a),k().refresh(i),r},Ze=e=>e.message||(e.kind===`forbidden`?S.actionForbidden:S.actionFailed),Qe=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&l(e,null)},$e=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=w(t.content,`table > tbody > tr`,HTMLTableRowElement);return document.importNode(r(n,"saveRow's `row` is the row as it will read: a <tr> element or its HTML."),!0)},et=async({url:e,method:t=`POST`,body:n,key:r,row:a}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let o=r==null,s=o?null:G(String(r));if(!o&&!s)throw Error(`saveRow found no row with data-row-key="${r}" on this page.`);let ee=N().filter(e=>!e.classList.contains(_)),d=a?$e(a):s??ze(Math.max(1,ee.length),ee);s&&d!==s?s.replaceWith(d):s||D.insertBefore(d,D.firstChild),d!==s&&Ne([d]),h&&!i.hasAttribute(`data-wui-table-error`)&&(h.hidden=!0),l(d,`saving`);let te=c(d),f=await ne(e,{method:t.toUpperCase(),body:n});if(f.kind===`session`)return!1;if(f.ok){let e=Ye(f.html),t=e&&d.isConnected?Xe(e,d,o):null;return t?M(u.saved(c(t)||te)):(await B(A,`none`),Qe(d)),Ae(f,f.toastVariant||`success`),j(`wui:table:saved`,{key:t?.dataset.rowKey??(o?null:String(r)),added:o,status:f.status}),!0}let p=Ze(f),m=d;return s&&d!==s&&d.isConnected?(d.replaceWith(s),m=s):o&&!a&&(d.remove(),m=null,h?.childElementCount&&!D.querySelector(`:scope > tr`)&&(h.hidden=!1)),m?.isConnected&&l(m,`error`,p),f.kind!==`aborted`&&ye(p,`danger`),M(u.notSaved(te,p)),j(`wui:table:failed`,{key:o?null:String(r),added:o,status:f.status,kind:f.kind,message:p}),!1},tt=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=T(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?c(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&l(n,`saving`);let o=await ne(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)Qe(n);else{if(o.ok){Ae(o,o.toastVariant||`success`);let e=n?.isConnected?Ye(o.html):null,t=e&&n?Xe(e,n,!1):null;t?M(u.saved(c(t)||a)):(await B(A,`none`),Qe(n))}else{let e=Ze(o);ye(e,`danger`),n?.isConnected&&l(n,`error`,e),M(u.notSaved(a,e))}j(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return a.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&D.contains(t)&&!t.disabled&&(e.preventDefault(),tt(t))}),P(D),Fe(D),y&&ce(a),Pe(D),H(),{el:n,reload:async e=>{let t=e?.quiet===!0;return t&&i.getAttribute(`aria-busy`)===`true`?null:B(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`),B(t,`push`)},saveRow:et,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),F(C(D,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...b],count:()=>x?O.total:b.size,allMatching:()=>x,selectAllMatching:()=>{x=!0;for(let e of C(D,`:scope > tr`,HTMLTableRowElement)){let t=w(e,`.${_} .wui-check`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&b.add(e.dataset.rowKey))}We()},clear:()=>{x=!1,b.clear();for(let e of C(D,`:scope > tr > .${_} .wui-check:not(:disabled)`,HTMLInputElement))e.checked=!1;We()}}}}var Te=8e3,Ee=`That did not work. Try again.`,De=[`success`,`info`,`warning`,`danger`],Oe=e=>De.some(t=>t===e);function ke(e){if(!Oe(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function k(){return r(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Ae(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?k().toast(e.message,{variant:ke(t),duration:Te,action:{label:n.label,onClick:()=>je(n)}}):k().toast(e.message,{variant:ke(t)})}async function je(e){let t=await ne(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Ae(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&O(e)?.reload()}else k().toast(t.message||Ee,{variant:`danger`})}}var A=`wui-remote-modal`,j=`wui-remote-drawer`,M=Object.freeze({sm:360,md:480,lg:640,xl:720}),Me=`wui-modal-fullscreen`,N=Object.freeze({sm:380,md:440,lg:640,xl:880}),P=Object.freeze({loading:`Loading`,close:`Close`,retry:`Try again`,errorTitle:`This could not be loaded`,forbidden:`You do not have access to this.`,client:`It may have been moved or deleted.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`,submitFailed:`Your changes were not saved.`,invalid:`Some fields need attention.`}),F=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Ne=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Pe=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Fe=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,I=`[data-wui-modal-content]`,Ie=`[data-wui-pane-close], [data-bs-dismiss="modal"]`,Le=`<button type="button" class="wui-modal-close" data-bs-dismiss="modal" aria-label="Close"><svg 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"></path></svg></button>`,Re=/* @__PURE__ */ new WeakMap,ze=/* @__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},Be=(e,t,n)=>L(R(e,t),n),Ve=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),z=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),B=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},He=e=>{let t=window.bootstrap?.Modal;if(!t)throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return t},H=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},Ue=e=>Object.hasOwn(N,e),We=e=>Object.hasOwn(M,e);function U(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Ue(e))return{px:N[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, fullscreen or a px number.`)}var W=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:N.md}},Ge=(e,t)=>{e.classList.toggle(Me,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Ke=[`center`,`top`];function qe(e){if(e==null||e===``)return null;if(We(e))return{px:M[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 Je=e=>e.container===`drawer`,G=e=>e.container===`pane`,Ye=e=>e.container!==`modal`,Xe=(e,t)=>Je(e)?qe(t):U(t),Ze=()=>document.getElementById(`wui-remote-drawer`)?.classList.contains(`show`)??!1,Qe=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},$e=e=>G(e)?e.shell:Be(e.shell,`.modal-dialog`,`a dialog frame`);function et(e=`modal`){let t=e===`drawer`,n=t?j:A,r=document.getElementById(n);return r||(r=document.createElement(`div`),r.id=n,r.className=t?`modal fade wui-modal-shell wui-remote-drawer`:`modal fade wui-modal-shell`,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.style.setProperty(`--wui-modal-max-width`,`${t?M.md:N.md}px`),r.innerHTML=t?`<div class="modal-dialog wui-remote-drawer-dialog"><div class="modal-content wui-modal"></div></div>`:`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal"></div></div>`,document.body.appendChild(r),r)}var tt=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${H(e)}</div></div></div>${Le}</div>`,nt=e=>`<div class="modal-content wui-modal" aria-busy="true">${tt(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${H(P.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`,rt=(n,r)=>`<div class="modal-content wui-modal" data-wui-modal-error="${H(r)}">${tt(n)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${H(P.errorTitle)}</p><p class="wui-modal-state-text">${H(P[r]||P.server)}</p><div class="wui-modal-state-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${H(P.close)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-wui-modal-retry data-wui="${t}">${H(P.retry)}</button></div></div></div></div>`,it=e=>{let t=document.createElement(`template`);return t.innerHTML=e,Be(t.content,`.modal-content`,`a card`)},K=e=>R(e.shell,`.modal-content`);function at(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=t?[t.Tooltip,t.Popover]:[];for(let r of[e,...e.querySelectorAll(`*`)]){for(let e of n)re(e,r);t?.Dropdown.getInstance(r)?.dispose()}}function ot(e,t){let n=K(e),r=n?ct(n):/* @__PURE__ */ new Map;at(n),n?n.replaceWith(t):$e(e).appendChild(t),lt(t,r),k().refresh()}var st=`input[type="file"][name]`;function ct(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(st)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function lt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(st)){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 ut=e=>G(e)?!e.shell.hidden:e.shell.classList.contains(`show`);function dt(e,t,n=!1){let r=t?R(e,Pe):null,i=r?r.matches(F)?r:R(r,F)||r:null;if(!i&&n)i=R(e,`[data-autofocus]`)||R(e,Ne)||R(e,`.wui-modal-close`);else if(!i){let t=Ve(e,F);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 ft(e,t){let n=Ve(e,F).filter(e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`);if(!n.length){t.preventDefault(),e.focus();return}let r=L(n[0],`a focusable control`),i=L(n[n.length-1],`a focusable control`),a=document.activeElement;!e.contains(a)||a===e?(t.preventDefault(),(t.shiftKey?i:r).focus()):t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}function pt(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`,``),$e(e).appendChild(n)),n.textContent=``,n.textContent=t}var mt=e=>{let t=R(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},ht=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function gt(e,t,n,r){let i={...r,container:e.container};ht(t,`wui:modal:${n}`,i),Je(e)&&ht(t,`wui:drawer:${n}`,i),G(e)&&ht(t,`wui:pane:${n}`,i)}var _t=e=>e.matches(`[data-wui-pane-host]`)?`pane`:e.classList.contains(`wui-remote-drawer`)?`drawer`:`modal`;function vt(e){let t=Re.get(e);if(t)return t;let n={shell:e,container:_t(e),queue:m(),defaultSize:W(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:K({shell:e})?.outerHTML||`<div class="modal-content wui-modal"></div>`,remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return Re.set(e,n),e.addEventListener(`submit`,e=>Rt(n,e)),e.addEventListener(`click`,e=>{V(e.target,`[data-wui-modal-retry]`)&&n.session&&(e.preventDefault(),J(n,n.session))}),G(n)&&e.addEventListener(`click`,t=>{let r=V(t.target,Ie);r&&e.contains(r)&&n.session&&q(n,n.session,`dismissed`,null)}),e.addEventListener(`hidden.bs.modal`,t=>{t.target===e&&(e.classList.contains(`wui-modal-stacked`)&&xt(n),St(n))}),e.addEventListener(`shown.bs.modal`,t=>{if(t.target!==e)return;e.classList.contains(`wui-modal-stacked`)&&[...document.querySelectorAll(`.modal-backdrop`)].at(-1)?.classList.add(`wui-modal-backdrop-stacked`);let r=K(n);n.session&&r?.matches(I)&&!r.contains(document.activeElement)&&dt(r,!1,Ye(n))}),n.remoteUrl&&e.addEventListener(`show.bs.modal`,t=>{t.target===e&&Ct(n,t)}),n}function yt(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)?bt(e,t):window.bootstrap?.Modal.getOrCreateInstance(e.shell).hide())}function bt(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,at(K(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),gt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function xt(e){e.shell.classList.remove(`wui-modal-stacked`),Ze()&&(document.body.classList.add(`modal-open`),document.body.style.overflow=`hidden`)}function St(e){let t=e.session;if(e.queue.abort(),e.session=null,mt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),gt(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||(ot(e,it(e.placeholder)),e.loadedUrl=null,Ge(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ct(e,t){let n=`relatedTarget`in t?t.relatedTarget:null,r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=yt(e,i,{trigger:r});a.explicitSize=wt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&Ge(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&ot(e,it(e.placeholder)),J(e,a,{keepPlaceholder:!0}))}function wt(e,t){try{return Xe(e,t)}catch(e){return s(e),null}}async function J(e,t,{keepPlaceholder:n=!1}={}){n||ot(e,it(nt(t.options.title||Tt(e))));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if((r.kind===`ok`||r.kind===`validation`)&&kt(e,t,r.html,!1))return e.loadedUrl=t.url,gt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return ot(e,it(rt(t.options.title||Tt(e),i))),ut(e)&&dt(L(K(e),`a card`),!1,Ye(e)),gt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Tt=e=>K(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Et=`/_content/Webority.Ui.Razor/js/`,Dt=e=>new URL(e,window.location.href).pathname.includes(Et);function Ot(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function kt(e,t,n,r){let i=document.createElement(`template`);i.innerHTML=n;let a=!1;for(let e of i.content.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Dt(t)?Ot(t):a=!0}a&&o(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let c=R(i.content,I);if(!c)return s(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(ot(e,c),r||mt(e),!G(e)){Ge(e.shell,t.explicitSize||wt(e,c.getAttribute(`data-wui-size`))||e.defaultSize);let n=c.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return ut(e)&&dt(c,r,Ye(e)),!0}var At=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function jt(e,t,n){let r=[...e.elements].filter(e=>e.matches(At));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.insertAdjacentHTML(`afterbegin`,`<span class="spinner-border spinner-border-sm me-2" aria-hidden="true" data-wui-submit-spinner></span>`))}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 Mt(e){for(let t of e.querySelectorAll(Fe))t.remove();for(let t of e.querySelectorAll(Pe))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Nt=/* @__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(`.`)),Pt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Ft(e){if(!e||e.status<400||e.status>499||e.status===422||!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(Pt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=Nt.has(r.toLowerCase())||r.toLowerCase()===i;return n(Pt(t,`message`))||n(Pt(t,`detail`))||(r&&!a?r:null)}function It(e,t,n,r){let i=t.closest(`.wui-modal-body`)||t;i.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Mt(i);let a=document.createElement(`div`);a.className=`alert alert-danger wui-modal-submit-error`,a.setAttribute(`role`,`alert`),a.setAttribute(`data-wui-modal-submit-error`,``),a.innerHTML=H(`${P.submitFailed} ${r||P[n]||P.server}`),i.prepend(a),pt(e,a.textContent)}var Lt=(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 Rt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(I)||(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(),c=new FormData(n);i?.name&&!c.has(i.name)&&c.append(i.name,i.value);let l=o===`GET`;jt(n,i,!0);let u;try{u=await e.queue.run(l?Lt(a,c):a,{method:o,body:l?void 0:c,navigate:r.options.navigate})}catch(t){s(t),e.session===r&&n.isConnected&&(jt(n,i,!1),It(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&jt(n,i,!1),u.kind===`ok`&&u.result===`success`){zt(e,r,u);return}if(u.kind===`aborted`||u.kind===`stale`||u.kind===`session`)return;if(u.kind===`validation`&&kt(e,r,u.html,!0)){let t=L(K(e),`a card`).querySelector(Fe)?.textContent?.replace(/\s+/g,` `).trim();pt(e,t||P.invalid);return}if(u.kind===`ok`&&u.html&&kt(e,r,u.html,!1))return;let ee=u.kind===`ok`||u.kind===`validation`?`server`:u.kind,d=await Ft(u.response);e.session===r&&It(e,n,ee,d)}function zt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!Qt(a))throw TypeError(`Unknown toast variant "${a}". Use ${Zt.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?Sn(r,a):r&&k().toast(r,{variant:a}),gt(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&&kt(e,t,n.html,!1):q(e,t,`success`,o)}function Bt(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`)?Jt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{B(e)||s(e)}):t.hasAttribute(`data-wui-modal`)?Wt(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=>{B(e)||s(e)}):Kt(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=>{B(e)||s(e)})))}function Vt(e){if(e.key!==`Tab`||e.defaultPrevented)return;let t=e.currentTarget;if(!(t instanceof Document))return;let n=Ve(t,`.modal.show`),r=R(t,`.modal.show.wui-modal-stacked`)??n[n.length-1];r&&ft(r,e)}function Ht(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=V(e.target,qt),n=t&&Re.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`.modal.show`)&&q(n,n.session,`dismissed`,null)}function Ut(e=document){let t=e instanceof Document?e:L(e.ownerDocument,`an owner document`);ze.has(t)||(ze.add(t),t.addEventListener(`click`,Bt),t.addEventListener(`keydown`,Vt),t.addEventListener(`keydown`,Ht));let n=Ve(e,`.modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)vt(e)}function Wt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=He(e),r=t.container===`drawer`,i=r?qe(t.size):U(t.size),a=t.placement||`center`;if(!Ke.includes(a))throw TypeError(`WUI.modal.load: unsupported placement "${a}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(z());let o=et(r?`drawer`:`modal`);Ut(document);let s=vt(o),c=ut(s),l=yt(s,e,t);l.explicitSize=i,Ge(o,i||s.defaultSize),r||Be(o,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,a===`center`),t.title&&o.setAttribute(`aria-label`,t.title),c||(!r&&Ze()&&(document.body.appendChild(o),o.classList.add(`wui-modal-stacked`)),n.getInstance(o)?.dispose(),n.getOrCreateInstance(o,{backdrop:t.staticBackdrop===!1||`static`,keyboard:t.staticBackdrop===!1}));let u=c?Promise.resolve():new Promise(e=>o.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),ee=J(s,l);return c||n.getOrCreateInstance(o).show(),Gt(s,l,t,u,ee,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Gt(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(z())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw z();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 Kt(e,t={}){return Wt(e,{...t,container:`drawer`,placement:void 0})}var qt=`[data-wui-pane-host]`;function Jt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=Qe(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(z());Ut(document);let r=vt(n),i=yt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=J(r,i);return Gt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Yt(e){let t=Qe(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=Re.get(t);n?.session&&q(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,Xt=Object.freeze([`danger`]),Zt=Object.freeze([`success`,`info`,`warning`,`danger`]),Qt=e=>Zt.some(t=>t===e),$t=`wui.flash`,X=Object.freeze({confirmTitle:`Are you sure?`,confirmLabel:`Confirm`,cancelLabel:`Cancel`,failed:`That did not work. Try again.`,forbidden:`You do not have permission to do that.`,network:`Could not reach the server. Check your connection and try again.`}),en=/* @__PURE__ */ new WeakSet,tn=/* @__PURE__ */ new WeakSet,nn=null,rn=null,an=!1,on=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},sn=(e,t)=>{e&&k().toast(e,{variant:t})},cn=()=>r(window.bootstrap?.Modal,`data-wui-confirm: Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);function ln(){let n=document.getElementById(Y);return n||(n=document.createElement(`div`),n.id=Y,n.className=`modal fade wui-modal-shell`,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-modal`,`true`),n.style.setProperty(`--wui-modal-max-width`,`${N.md}px`),n.innerHTML=`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal wui-confirm"><div class="wui-modal-body"><div class="wui-confirm-content"><span class="wui-confirm-icon"><wui-status-icon tone="info" size="120"></wui-status-icon></span><h3 class="wui-confirm-title" tabindex="-1" data-autofocus></h3><p class="wui-confirm-msg"></p></div></div><div class="wui-modal-footer"><div class="wui-confirm-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${on(X.cancelLabel)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-app-confirm data-wui="${t}"></button></div></div></div></div>`,document.body.appendChild(n),n)}function un(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Xt.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);dn({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 dn({title:e,message:t,label:n,danger:r},i){let a=cn(),o=ln(),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=n||X.confirmLabel,c.classList.toggle(`btn-danger`,r),c.classList.toggle(`btn-primary`,!r),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,r?`delete`:`info`),o.setAttribute(`aria-label`,u),rn=i,an=!1,a.getOrCreateInstance(o).show()}var fn=(e,t)=>{nn=e;try{t()}finally{nn=null}},pn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},mn=e=>{if(typeof e!=`object`||!e)throw TypeError(`confirmAction: options must be an object with a message.`);let t=Reflect.get(e,`message`);if(typeof t!=`string`)throw TypeError(`confirmAction: message must be text.`);return{title:pn(e,`title`),message:t,label:pn(e,`label`),tone:pn(e,`tone`)}};function hn(e,t,n){let{title:r,message:i,label:a,tone:o}=mn(t);if(o!=null&&!Xt.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Fn(e.ownerDocument),dn({title:r,message:i,label:a,danger:o===`danger`},()=>fn(e,n))}var gn=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,_n=e=>{n(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function vn(e){let t=i(e.target,`[data-wui-confirm]:not(form)`);t&&t!==nn&&!gn(t)&&(e.preventDefault(),e.stopImmediatePropagation(),un(t,()=>fn(t,()=>_n(t))))}function yn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===nn||e.submitter&&e.submitter===nn||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;un(t,()=>fn(t,()=>t.requestSubmit(r)))}function bn(e){let t=i(e.target,`#${Y} [data-app-confirm]`);if(!t||t.hasAttribute(`disabled`)||!rn)return;an=!0;let n=cn(),a=r(t.closest(`#${Y}`),`#${Y} is missing around its confirm button.`);n.getOrCreateInstance(a).hide()}function xn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=an?rn:null;rn=null,an=!1,t?.()}function Sn(e,t){e&&window.sessionStorage.setItem($t,JSON.stringify({message:e,variant:t}))}var Cn=e=>e===`forbidden`?X.forbidden:e===`network`?X.network:X.failed;function wn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&O(e)?.reload()}var Tn=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function En(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 Dn(t,e)}async function Dn(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.`);Tn(t,!0),t.setAttribute(`aria-busy`,`true`);let i=await ne(e,{method:`POST`,body:n});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;i.ok&&(i.redirect||r===`page`)?(Sn(i.message,a),i.redirect?window.location.assign(i.redirect):window.location.reload()):(Tn(t,!1),t.removeAttribute(`aria-busy`),i.ok?(Ae(i,a),wn()):sn(i.message||Cn(i.kind),`danger`))}function On(e,t){Tn(e,!1),e.removeAttribute(`aria-busy`),s(t),sn(X.failed,`danger`)}function kn(e){let t=i(e.target,`[data-wui-post]`);t&&(e.preventDefault(),gn(t)||t.getAttribute(`aria-busy`)===`true`||En(t).catch(e=>On(t,e)))}function An(e){let t=i(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let n=r(e.submitter||t.querySelector(`button`),`A data-wui-post-form needs a submit button to report its result on.`);if(n.getAttribute(`aria-busy`)===`true`)return;Dn(t.action,n,new FormData(t)).catch(e=>On(n,e));let a=t.closest(`.dropdown`)?.querySelector(`[data-bs-toggle='dropdown']`);a&&window.bootstrap?.Dropdown?.getInstance(a)?.hide()}function jn(){let e=window.sessionStorage.getItem($t);if(!e)return;window.sessionStorage.removeItem($t);let t=JSON.parse(e);if(typeof t!=`object`||!t)throw TypeError(`stored flash is not an object.`);let n=Reflect.get(t,`message`),r=Reflect.get(t,`variant`);if(typeof r!=`string`||!Qt(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);sn(n,r)}function Mn(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(!Qt(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${Zt.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),sn(n,t)}}var Nn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Pn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=Nn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Fn(e){tn.has(e)||(tn.add(e),e.addEventListener(`click`,bn),e.addEventListener(`hidden.bs.modal`,xn))}function In(e=document){let t=e instanceof Element?e.ownerDocument:e;en.has(t)||(en.add(t),t.addEventListener(`click`,vn,!0),t.addEventListener(`submit`,yn,!0),Fn(t),t.addEventListener(`click`,kn),t.addEventListener(`submit`,An),t.addEventListener(`change`,Pn),jn()),Mn(e)}var Ln=Object.freeze({title:`Leave without saving?`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,leaveLabel:`Leave`}),Rn=`form[data-wui-unsaved]`,zn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Bn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Vn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Hn=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Un=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Wn=e=>Un(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Gn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,Kn=e=>typeof e==`object`&&!!e,qn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Jn(e){let t=JSON.parse(e);if(!qn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,Yn=/* @__PURE__ */ new WeakSet,Xn=e=>`${e.name}:${e.size}:${e.lastModified}`,Zn=e=>[...e.querySelectorAll(Rn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)Gn(n)&&!Wn(n)&&(Un(n)&&Vn.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(Xn)]):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 Qn(e){return Q(e)}function $n(e,t){let n=/* @__PURE__ */ new Map,r=Jn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Jn(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function er(e){for(let t of e.elements)if(Un(t)&&t.name&&!Wn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Hn.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 tr=e=>({saved:e.querySelector(zn)&&er(e)?null:Q(e),engaged:!1,discarded:!1});function nr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var rr=(e,t)=>Zn(e).filter(e=>e!==t&&nr(e)),ir=()=>!!window.bootstrap?.Modal;function ar(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Ln.message;hn(e,{title:Ln.title,message:r,label:Ln.leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function or(e){if(e.matches(Bn))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 sr(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 cr(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=i(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!or(n))return;let r=rr(n.ownerDocument,null);r.length&&ir()&&(e.preventDefault(),ar(n,r,()=>n.click()))}function lr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!sr(t,e.submitter))return;let n=rr(t.ownerDocument,t);if(n.length&&ir()){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;ar(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function ur(e){rr(document,null).length&&(e.preventDefault(),e.returnValue=``)}function dr(e){let t=e.target,n=i(t,Rn);return n instanceof HTMLFormElement?n:null}function fr(e){let t=dr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function pr(e){let t=dr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function mr(e){for(let t of Zn(e)){let e=Z.get(t);e?.saved&&(e.saved=$n(t,e.saved))}}function hr(e){let t=Kn(e)?e.handle:void 0;return Kn(t)?t.el:void 0}function gr(e){if(!(e instanceof CustomEvent))return;let t=hr(e.detail);if(t instanceof Element)for(let e of Zn(t))vr(e)}function _r(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Yn.has(t)){Yn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,fr,!0);for(let e of[`input`,`change`])t.addEventListener(e,pr,!0);t.addEventListener(`click`,cr),t.addEventListener(`submit`,lr),t.addEventListener(`wui:modal:success`,gr),t.addEventListener(a,()=>mr(t)),r(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,ur)}let n=Zn(e);e instanceof HTMLFormElement&&e.matches(Rn)&&n.unshift(e);for(let e of n)Z.has(e)||Z.set(e,tr(e))}function vr(e){if(!(e instanceof HTMLFormElement)||!e.matches(Rn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var yr=Object.freeze({question:`Discard your changes?`,discard:`Discard`,keep:`Keep editing`}),br=`wui:drawer:discard`,xr=`wui-drawer[confirm-discard]`,Sr=`.wui-modal-shell`,Cr=`data-wui-no-discard`,wr=`.wui-drawer-discard`,Tr=`input, select, textarea`,Er=e=>typeof e==`object`&&!!e||typeof e==`function`;function Dr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Or(e,t){return i(e,t)}var kr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Ar=/* @__PURE__ */ new WeakSet,jr=/* @__PURE__ */ new WeakSet;function Mr(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 Nr(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,Mr(e,`danger`,`solid`,`data-wui-discard-confirm`,yr.discard),Mr(e,`primary`,`soft`,`data-wui-discard-keep`,yr.keep)),n}function Pr(e){if(!(e instanceof Element))return null;let t=e.closest(xr);if(t)return t;let n=e.closest(Sr);return n&&Lr(n).length?n:null}function Fr(e){return e.closest(xr)??e.closest(Sr)}function Ir(e,t){return t.hasAttribute(Cr)||e.hasAttribute(Cr)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Lr(e){return e.matches(xr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Ir(t,e))}function Rr(e){let t=$.get(e);return t!=null&&Qn(e)!==t}function zr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,r(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),jr.add(t),t}function Br(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),jr.add(t),t}function Vr(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 Hr(e,t,n){let r=e.querySelector(wr);if(r){Vr(r);return}let i=Nr(e.ownerDocument,t),a;if(e.matches(xr))a=e.querySelector(`.wui-drawer-footer`)??zr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Br(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`),a?a.prepend(i):(a=n,n.append(i))}a.classList.add(`wui-drawer-discarding`),Vr(i)}function Ur(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),jr.has(t)&&t.remove()}function Wr(e){for(let t of Lr(e))for(let e of t.querySelectorAll(Tr))if(kr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Gr(e){let t=Pr(e.target);if(t)for(let e of Lr(t))$.get(e)??$.set(e,Qn(e))}function Kr(e){for(let t of Dr(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,$n(t,e))}}function qr(e){let t=e.target;t instanceof HTMLFormElement&&Pr(t)&&$.set(t,Qn(t))}function Jr(e){if(!Er(e))return;let t=Reflect.get(e,`handle`);if(Er(t))return Reflect.get(t,`el`)}function Yr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Jr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function Xr(e){let t=e.target;t instanceof Element&&t.matches(xr)&&[...Lr(t)].some(Rr)&&(e.preventDefault(),Hr(t,t.getAttribute(`confirm-discard`),null))}function Zr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Sr))return;let n=[...Lr(t)].find(Rr);n&&(e.preventDefault(),Hr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??yr.question,n))}function Qr(e){let t=e.closest(`wui-drawer`);if(t){t.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}))&&t.hide();return}let n=e.closest(Sr);n&&window.bootstrap?.Modal.getInstance(n)?.hide()}function $r(e){let t=r(e.closest(wr),`The discard button is outside its prompt.`),n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Lr(n))$.set(e,Qn(e));n.dispatchEvent(new CustomEvent(br,{bubbles:!0})),n.matches(xr)?r(n.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():r(window.bootstrap?.Modal.getInstance(n),`Bootstrap's Modal has no instance for the discarded dialog.`).hide()}function ei(e){let t=r(e.closest(wr),`The keep button is outside its prompt.`),n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);Wr(n)}function ti(e){let t=Or(e.target,`[data-wui-discard-confirm]`);if(t){$r(t);return}let n=Or(e.target,`[data-wui-discard-keep]`);if(n){ei(n);return}let r=Or(e.target,`[data-wui-dismiss]`);r&&Qr(r)}function ni(e){if(e.key!==`Escape`)return;let t=Dr(e).querySelector(wr);if(!t)return;e.preventDefault(),e.stopPropagation();let n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);Wr(n)}function ri(e=document){let t=e instanceof Document?e:e.ownerDocument;Ar.has(t)||(Ar.add(t),t.addEventListener(`focusin`,Gr),t.addEventListener(`pointerdown`,Gr),t.addEventListener(`submit`,qr),t.addEventListener(a,Kr),t.addEventListener(`wui:modal:success`,Yr),t.addEventListener(`wui:modal:loaded`,Yr),t.addEventListener(`wui-drawer-close`,Xr,!0),t.addEventListener(`hide.bs.modal`,Zr),t.addEventListener(`click`,ti),t.addEventListener(`keydown`,ni,!0))}export{Ae as C,je as S,D as T,Ut as _,Ln as a,Jt as b,vr as c,$t as d,Zt as f,Yt as g,In as h,ri as i,Y as l,hn as m,yr as n,Qn as o,X as p,Nr as r,_r as s,br as t,Xt as u,Kt as v,O as w,Te as x,Wt as y};
1
+ import{n as e,t}from"./buttonClass-GtEi8hAY.js";import{n,r,t as i}from"./dom-Do1pAA12.js";import{t as a}from"./loader-ByHAB1wi.js";import{n as o,t as s}from"./devWarn-DXdRWZs3.js";import{E as c,k as l,r as u,w as ee,y as d}from"./dataTable-B-7oAeii.js";import{t as te}from"./iconGlyphs.g-DPqoOoXy.js";import{LIST_QUERY_RESERVED as f,SEARCH_PARAM as p}from"./listQuery.js";import{l as ne,s as m}from"./wuiHttp-DGbD7Fra.js";function re(e,t){let n=e.getInstance(t);n&&(n.tip?.isConnected?(t.addEventListener(`hidden${e.EVENT_KEY}`,()=>n.dispose(),{once:!0}),n.hide()):n.dispose())}var h=`Select all rows`,g=`Select row`,_=`wui-select-cell`,ie=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function v(e=document){let t=e.createElement(`th`);return t.className=_,t.appendChild(ie(e,h)),t}function ae(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=_;let r=ie(e,g);return r.disabled=t,n.appendChild(r),n}function oe(e=document){let t=e.createElement(`td`);return t.className=_,t}var y=e=>e.firstElementChild?.classList.contains(_),b=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`),x=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n);function se(e){for(let t of e){if(y(t)||b(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(ae(t.ownerDocument,{disabled:e}),t.firstChild)}}function ce(e){let t=e.querySelector(`thead tr`);if(!(t instanceof HTMLTableRowElement))return null;y(t)||t.insertBefore(v(e.ownerDocument),t.firstChild),se(x(e,`tbody tr`,HTMLTableRowElement));for(let t of x(e,`tfoot tr`,HTMLTableRowElement))y(t)||t.insertBefore(oe(e.ownerDocument),t.firstChild);let n=t.querySelector(`.${_} .wui-check`);return n instanceof HTMLInputElement?n:null}function le(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 ue=`tbody .${_} .wui-check:not(:disabled)`;function de(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,ue,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 S=Object.freeze({loading:`Loading rows`,error:`These rows did not load. Try again.`,network:`The connection dropped before the rows loaded. Check it and try again.`,forbidden:`You do not have access to these rows.`,retry:`Retry`,actionFailed:`That did not work. Try again.`,actionForbidden:`You do not have permission to do that.`,empty:`No rows`}),fe=5,pe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,me=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,he=e=>pe(e)&&`type`in e&&e.type===`hidden`,C=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),w=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},T=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},ge=e=>e.localName===`wui-select`,_e=/* @__PURE__ */ new WeakMap,E=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ve=e=>({total:E(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:E(e.dataset.page,1),pageSize:E(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),ye=(e,t)=>{e&&k().toast(e,{variant:t})},be=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!he(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!f.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of C(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},xe=new Intl.NumberFormat(`en-IN`),Se=(e,t)=>t?`${xe.format(e)}+`:xe.format(e),Ce=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?w(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Se(t,n))};function D(e=document){let t=C(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(_e.has(e))continue;let t=we(e);_e.set(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function O(e){let t=e instanceof Element?T(e,`[data-wui-server]`,HTMLElement):null;return t&&_e.get(t)||null}function we(n){let i=w(n,`.table-wrap`,HTMLElement),a=i?w(i,`:scope > table`,HTMLTableElement):null,re=n.dataset.src;if(!i||!a||!re)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let h=w(i,`:scope > [data-wui-table-state]`,HTMLElement),g=w(n,`[data-wui-table-pager]`,HTMLElement),ie=w(n,`[data-wui-table-status]`,HTMLElement),v={urlState:n.dataset.urlState!==`false`,refreshOnSuccess:n.dataset.refreshOnSuccess!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||S.loading,errorText:n.dataset.errorText||S.error},ae=new URL(re,window.location.href),oe=new Set(ae.searchParams.keys()),y=a.hasAttribute(`data-app-datatable-selectable`),b=/* @__PURE__ */ new Set,x=!1,ue=m(),_e=new AbortController,E={signal:_e.signal},xe=w(a,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),D=r(xe,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),O=ve(D),we=null,Te=null,Ee=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))oe.has(n)||t.append(n,r);return t},De=e=>Ee(new URL(e,window.location.href).search),Oe=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},ke=e=>{let t=new URL(ae.href);for(let[n,r]of e)oe.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},je=(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=je(v.urlState?Ee(window.location.search):new URLSearchParams,O);v.urlState&&Oe(A)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,Oe(A));let j=(e,t)=>i.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),M=e=>{ie&&(ie.textContent=e)},Me=e=>{if(e.total===0)return S.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Se(e.total,!0):`${e.total}`;return`Page ${e.page} of ${t}, ${n} ${e.total===1?`row`:`rows`}`},N=()=>C(a,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),P=e=>{if(y&&C(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.`)},F=e=>{let t=n.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`)}},Ne=e=>{if(y){se(e);for(let t of e){let e=w(t,`.${_} .wui-check:not(:disabled)`,HTMLInputElement);e&&(x&&b.add(t.dataset.rowKey),e.checked=b.has(t.dataset.rowKey))}le(a)}F(e);let t=N();if(a.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`)})},Pe=e=>Ne(C(e,`:scope > tr`,HTMLTableRowElement)),Fe=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})),Ie=(e,t)=>{if(!h)return;let n=w(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);I(h),t.total===0&&n?(h.replaceChildren(n.content.cloneNode(!0)),h.hidden=!1):(h.replaceChildren(),h.hidden=!0)},Le=e=>{let t=ve(e),n=t.sortBy!==O.sortBy||t.sortOrder!==O.sortOrder?d(D.rows):null;if(g){let t=w(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement);I(g),g.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),g.hidden=!1}Ie(e,t);let r=w(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement),o=v.filtersRegion&&r?w(document,v.filtersRegion,HTMLElement):null;o&&r&&(I(o),o.replaceChildren(r.content.cloneNode(!0))),Fe(e),I(D),a.replaceChild(e,D),D=e;let s=x&&t.total!==O.total;return O=t,s&&(x=!1),i.removeAttribute(`data-wui-table-error`),Pe(e),H(),ee(e.rows,n),s&&We(),o},Re=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=w(t.content,`tbody[data-wui-rows]`,HTMLTableSectionElement);return n&&P(n),n?document.importNode(n,!0):null},ze=(e,t=N())=>{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},L=()=>{if(D.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,N().length);D.replaceChildren(...Array.from({length:fe},()=>{let t=ze(e);return t.setAttribute(`data-wui-skeleton`,``),t})),i.removeAttribute(`data-wui-table-error`),h&&(h.hidden=!0)},R=e=>{e?(i.setAttribute(`aria-busy`,`true`),L()):i.removeAttribute(`aria-busy`)},Be=e=>e===`forbidden`?S.forbidden:e===`network`?S.network:v.errorText,Ve=n=>{let r=Be(n);if(i.setAttribute(`data-wui-table-error`,n),g&&(g.hidden=!0),h){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`,a.innerHTML=te(n===`forbidden`?`lock`:`alert-circle`,{size:24});let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=r;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=e(`primary`,`outline`,`sm`),c.dataset.wui=t,c.setAttribute(`data-wui-table-retry`,``),c.textContent=S.retry,s.append(c),i.append(a,o,s),I(h),h.replaceChildren(i),h.hidden=!1}M(r)},z=()=>v.filtersForm?w(document,v.filtersForm,HTMLFormElement):null,B=async(e,t=`none`,{quiet:r=!1}={})=>{let a=new URLSearchParams(e);r||(we={query:a,mode:t},R(!0),M(v.loadingText)),j(`wui:table:loading`,{query:a.toString()});let c=await ue.run(ke(a));if(c.kind===`aborted`||c.kind===`stale`||c.kind===`session`)return c;r||R(!1);let l=null;if(c.ok)try{l=Re(c.html)}catch(e){s(e)}if(!c.ok||!l){let e=c.ok?`server`:c.kind;return r?o(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ve(e),j(`wui:table:error`,{status:c.status,kind:e,message:Be(e)}),c}let u=Le(l);return A=je(a,O),be(z(),A),v.urlState&&t===`push`?window.history.pushState(window.history.state,``,Oe(A)):v.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,Oe(A)),r||M(Me(O)),k().refresh(i),u&&k().refresh(u),Ce(n,O.total,O.totalCapped),j(`wui:table:loaded`,{...O,query:A.toString()}),c},V=e=>(e.delete(`page`),e),He=()=>C(a,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),H=()=>{for(let e of He()){let t=e.dataset.sortKey===O.sortBy;e.setAttribute(`aria-sort`,t?O.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of He())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`,n.innerHTML=te(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let Ue=e=>{let t=V(new URLSearchParams(A)),n=O.sortBy===e&&O.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),B(t,`push`)};a.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&a.tHead?.contains(t)&&Ue(t.dataset.sortKey??``)}),a.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?T(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&a.tHead?.contains(t)&&(e.preventDefault(),Ue(t.dataset.sortKey??``))});let We=()=>{le(a);let e=x?{selected:O.total,total:O.total,allMatching:x}:{selected:b.size,total:O.total};a.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};y&&(de(a,(e,t)=>{for(let n of e){let e=T(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?b.add(e):b.delete(e))}t||(x=!1)}),a.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(x=!1),a.tHead?.contains(t))for(let e of C(D,`:scope > tr`,HTMLTableRowElement)){let n=w(e,`.${_} .wui-check:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?b.add(e.dataset.rowKey):b.delete(e.dataset.rowKey))}else{let e=T(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?b.add(e):b.delete(e)}We()}})),g&&(g.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),B(De(t.getAttribute(`href`)??``),`push`))}),g.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),B(De(t.value),`push`))}));let U=()=>{if(!v.searchInput)return null;let e=w(document,v.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?w(e,`input`,HTMLInputElement):null},W=()=>n.isConnected?!0:(_e.abort(),clearTimeout(Te??void 0),!1),Ge=(e,t)=>{let n=[...e.elements].filter(pe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!he(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!me(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},Ke=(e,t)=>{let n=new Set([...e.elements].filter(pe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&f.includes(e);for(let[e,t]of A)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of Ge(e,t))a===``||i(n)||oe.has(n)||r.append(n,a);let a=U();if(a){r.delete(p);let e=a.value.trim();e&&r.set(p,e)}return B(r,`push`)},qe=e=>v.filtersForm&&e.closest?.(v.filtersForm)||v.filtersRegion&&e.closest?.(v.filtersRegion)||null;document.addEventListener(`submit`,e=>{W()&&v.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(v.filtersForm)&&(e.preventDefault(),Ke(e.target,e.submitter))},E),document.addEventListener(`change`,e=>{if(!W()||!v.filtersForm||!(e.target instanceof Element))return;let t=T(e.target,v.filtersForm,HTMLFormElement);!t||e.target===U()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||Ke(t)},E);let Je=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of C(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 C(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(ge)){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?T(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!qe(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=V(De(n.href));Je(t.closest(`form`),r),be(t.closest(`form`),r),B(r,`push`)},E),document.addEventListener(`input`,e=>{if(!W())return;let t=U();t&&e.target===t&&(clearTimeout(Te??void 0),Te=setTimeout(()=>{if(!W())return;let e=V(new URLSearchParams(A)),n=t.value.trim();n?e.set(p,n):e.delete(p),e.toString()!==A.toString()&&B(e,`replace`)},300))},E),v.urlState&&window.addEventListener(`popstate`,()=>{if(!W())return;let e=Ee(window.location.search),t=U();t&&(t.value=e.get(`search`)??``),be(z(),e),B(e,`none`)},E),document.addEventListener(`wui:modal:success`,()=>{W()&&v.refreshOnSuccess&&B(A,`none`)},E),h?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&we&&B(we.query,we.mode)});let G=e=>[...D.rows].find(t=>t.dataset.rowKey===e)??null,Ye=e=>{if(!e?.trim())return null;let t=document.createElement(`template`);if(t.innerHTML=`<table><tbody>${e}</tbody></table>`,t.content.querySelector(`tbody[data-wui-rows]`))return null;let n=C(t.content,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},Xe=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let a=[];for(let n of e){let e=n===r?t:G(n.dataset.rowKey);e&&(I(e),e.replaceWith(n),a.push(n))}return Ne(a),k().refresh(i),r},Ze=e=>e.message||(e.kind===`forbidden`?S.actionForbidden:S.actionFailed),Qe=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&l(e,null)},$e=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=w(t.content,`table > tbody > tr`,HTMLTableRowElement);return document.importNode(r(n,"saveRow's `row` is the row as it will read: a <tr> element or its HTML."),!0)},et=async({url:e,method:t=`POST`,body:n,key:r,row:a}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let o=r==null,s=o?null:G(String(r));if(!o&&!s)throw Error(`saveRow found no row with data-row-key="${r}" on this page.`);let ee=N().filter(e=>!e.classList.contains(_)),d=a?$e(a):s??ze(Math.max(1,ee.length),ee);s&&d!==s?s.replaceWith(d):s||D.insertBefore(d,D.firstChild),d!==s&&Ne([d]),h&&!i.hasAttribute(`data-wui-table-error`)&&(h.hidden=!0),l(d,`saving`);let te=c(d),f=await ne(e,{method:t.toUpperCase(),body:n});if(f.kind===`session`)return!1;if(f.ok){let e=Ye(f.html),t=e&&d.isConnected?Xe(e,d,o):null;return t?M(u.saved(c(t)||te)):(await B(A,`none`),Qe(d)),Ae(f,f.toastVariant||`success`),j(`wui:table:saved`,{key:t?.dataset.rowKey??(o?null:String(r)),added:o,status:f.status}),!0}let p=Ze(f),m=d;return s&&d!==s&&d.isConnected?(d.replaceWith(s),m=s):o&&!a&&(d.remove(),m=null,h?.childElementCount&&!D.querySelector(`:scope > tr`)&&(h.hidden=!1)),m?.isConnected&&l(m,`error`,p),f.kind!==`aborted`&&ye(p,`danger`),M(u.notSaved(te,p)),j(`wui:table:failed`,{key:o?null:String(r),added:o,status:f.status,kind:f.kind,message:p}),!1},tt=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=T(e,`tr`,HTMLTableRowElement),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,a=n?c(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&l(n,`saving`);let o=await ne(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),o.kind===`session`||o.kind===`aborted`)Qe(n);else{if(o.ok){Ae(o,o.toastVariant||`success`);let e=n?.isConnected?Ye(o.html):null,t=e&&n?Xe(e,n,!1):null;t?M(u.saved(c(t)||a)):(await B(A,`none`),Qe(n))}else{let e=Ze(o);ye(e,`danger`),n?.isConnected&&l(n,`error`,e),M(u.notSaved(a,e))}j(`wui:table:action`,{action:i,key:r,ok:o.ok,status:o.status})}};return a.addEventListener(`click`,e=>{let t=e.target instanceof Element?T(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&D.contains(t)&&!t.disabled&&(e.preventDefault(),tt(t))}),P(D),Fe(D),y&&ce(a),Pe(D),H(),{el:n,reload:async e=>{let t=e?.quiet===!0;return t&&i.getAttribute(`aria-busy`)===`true`?null:B(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`),B(t,`push`)},saveRow:et,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),F(C(D,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...b],count:()=>x?O.total:b.size,allMatching:()=>x,selectAllMatching:()=>{x=!0;for(let e of C(D,`:scope > tr`,HTMLTableRowElement)){let t=w(e,`.${_} .wui-check`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&b.add(e.dataset.rowKey))}We()},clear:()=>{x=!1,b.clear();for(let e of C(D,`:scope > tr > .${_} .wui-check:not(:disabled)`,HTMLInputElement))e.checked=!1;We()}}}}var Te=8e3,Ee=`That did not work. Try again.`,De=[`success`,`info`,`warning`,`danger`],Oe=e=>De.some(t=>t===e);function ke(e){if(!Oe(e))throw RangeError(`Unknown toast variant "${e}".`);return e}function k(){return r(window.WUI,`window.WUI is not defined: the Razor behaviour script did not load on this page.`)}function Ae(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?k().toast(e.message,{variant:ke(t),duration:Te,action:{label:n.label,onClick:()=>je(n)}}):k().toast(e.message,{variant:ke(t)})}async function je(e){let t=await ne(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){Ae(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e instanceof HTMLElement&&e.dataset.refreshOnSuccess!==`false`&&O(e)?.reload()}else k().toast(t.message||Ee,{variant:`danger`})}}var A=`wui-remote-modal`,j=`wui-remote-drawer`,M=Object.freeze({sm:360,md:480,lg:640,xl:720}),Me=`wui-modal-fullscreen`,N=Object.freeze({sm:380,md:440,lg:640,xl:880}),P=Object.freeze({loading:`Loading`,close:`Close`,retry:`Try again`,errorTitle:`This could not be loaded`,forbidden:`You do not have access to this.`,client:`It may have been moved or deleted.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`,submitFailed:`Your changes were not saved.`,invalid:`Some fields need attention.`}),F=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,Ne=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,Pe=`[aria-invalid="true"], .is-invalid, .input-validation-error`,Fe=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,I=`[data-wui-modal-content]`,Ie=`[data-wui-pane-close], [data-bs-dismiss="modal"]`,Le=`<button type="button" class="wui-modal-close" data-bs-dismiss="modal" aria-label="Close"><svg 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"></path></svg></button>`,Re=/* @__PURE__ */ new WeakMap,ze=/* @__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},Be=(e,t,n)=>L(R(e,t),n),Ve=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),z=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),B=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},He=e=>{let t=window.bootstrap?.Modal;if(!t)throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return t},H=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},Ue=e=>Object.hasOwn(N,e),We=e=>Object.hasOwn(M,e);function U(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Ue(e))return{px:N[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, fullscreen or a px number.`)}var W=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:N.md}},Ge=(e,t)=>{e.classList.toggle(Me,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},Ke=[`center`,`top`];function qe(e){if(e==null||e===``)return null;if(We(e))return{px:M[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 Je=e=>e.container===`drawer`,G=e=>e.container===`pane`,Ye=e=>e.container!==`modal`,Xe=(e,t)=>Je(e)?qe(t):U(t),Ze=()=>document.getElementById(`wui-remote-drawer`)?.classList.contains(`show`)??!1,Qe=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},$e=e=>G(e)?e.shell:Be(e.shell,`.modal-dialog`,`a dialog frame`);function et(e=`modal`){let t=e===`drawer`,n=t?j:A,r=document.getElementById(n);return r||(r=document.createElement(`div`),r.id=n,r.className=t?`modal fade wui-modal-shell wui-remote-drawer`:`modal fade wui-modal-shell`,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.style.setProperty(`--wui-modal-max-width`,`${t?M.md:N.md}px`),r.innerHTML=t?`<div class="modal-dialog wui-remote-drawer-dialog"><div class="modal-content wui-modal"></div></div>`:`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal"></div></div>`,document.body.appendChild(r),r)}var tt=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${H(e)}</div></div></div>${Le}</div>`,nt=e=>`<div class="modal-content wui-modal" aria-busy="true">${tt(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${H(P.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`,rt=(n,r)=>`<div class="modal-content wui-modal" data-wui-modal-error="${H(r)}">${tt(n)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${H(P.errorTitle)}</p><p class="wui-modal-state-text">${H(P[r]||P.server)}</p><div class="wui-modal-state-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${H(P.close)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-wui-modal-retry data-wui="${t}">${H(P.retry)}</button></div></div></div></div>`,it=e=>{let t=document.createElement(`template`);return t.innerHTML=e,Be(t.content,`.modal-content`,`a card`)},K=e=>R(e.shell,`.modal-content`);function at(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=t?[t.Tooltip,t.Popover]:[];for(let r of[e,...e.querySelectorAll(`*`)]){for(let e of n)re(e,r);t?.Dropdown.getInstance(r)?.dispose()}}function ot(e,t){let n=K(e),r=n?ct(n):/* @__PURE__ */ new Map;at(n),n?n.replaceWith(t):$e(e).appendChild(t),lt(t,r),k().refresh()}var st=`input[type="file"][name]`;function ct(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(st)){if(!(n instanceof HTMLInputElement))continue;let e=n.files;e&&e.length>0&&t.set(n.name,[...e])}return t}function lt(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(st)){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 ut=e=>G(e)?!e.shell.hidden:e.shell.classList.contains(`show`);function dt(e,t,n=!1){let r=t?R(e,Pe):null,i=r?r.matches(F)?r:R(r,F)||r:null;if(!i&&n)i=R(e,`[data-autofocus]`)||R(e,Ne)||R(e,`.wui-modal-close`);else if(!i){let t=Ve(e,F);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 ft(e,t){let n=Ve(e,F).filter(e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`);if(!n.length){t.preventDefault(),e.focus();return}let r=L(n[0],`a focusable control`),i=L(n[n.length-1],`a focusable control`),a=document.activeElement;!e.contains(a)||a===e?(t.preventDefault(),(t.shiftKey?i:r).focus()):t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}function pt(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`,``),$e(e).appendChild(n)),n.textContent=``,n.textContent=t}var mt=e=>{let t=R(e.shell,`[data-wui-modal-live]`);t&&(t.textContent=``)},ht=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};function gt(e,t,n,r){let i={...r,container:e.container};ht(t,`wui:modal:${n}`,i),Je(e)&&ht(t,`wui:drawer:${n}`,i),G(e)&&ht(t,`wui:pane:${n}`,i)}var _t=e=>e.matches(`[data-wui-pane-host]`)?`pane`:e.classList.contains(`wui-remote-drawer`)?`drawer`:`modal`;function vt(e){let t=Re.get(e);if(t)return t;let n={shell:e,container:_t(e),queue:m(),defaultSize:W(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:K({shell:e})?.outerHTML||`<div class="modal-content wui-modal"></div>`,remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null};return Re.set(e,n),e.addEventListener(`submit`,e=>Rt(n,e)),e.addEventListener(`click`,e=>{V(e.target,`[data-wui-modal-retry]`)&&n.session&&(e.preventDefault(),J(n,n.session))}),G(n)&&e.addEventListener(`click`,t=>{let r=V(t.target,Ie);r&&e.contains(r)&&n.session&&q(n,n.session,`dismissed`,null)}),e.addEventListener(`hidden.bs.modal`,t=>{t.target===e&&(e.classList.contains(`wui-modal-stacked`)&&xt(n),St(n))}),e.addEventListener(`shown.bs.modal`,t=>{if(t.target!==e)return;e.classList.contains(`wui-modal-stacked`)&&[...document.querySelectorAll(`.modal-backdrop`)].at(-1)?.classList.add(`wui-modal-backdrop-stacked`);let r=K(n);n.session&&r?.matches(I)&&!r.contains(document.activeElement)&&dt(r,!1,Ye(n))}),n.remoteUrl&&e.addEventListener(`show.bs.modal`,t=>{t.target===e&&Ct(n,t)}),n}function yt(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)?bt(e,t):window.bootstrap?.Modal.getOrCreateInstance(e.shell).hide())}function bt(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,at(K(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),gt(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function xt(e){e.shell.classList.remove(`wui-modal-stacked`),Ze()&&(document.body.classList.add(`modal-open`),document.body.style.overflow=`hidden`)}function St(e){let t=e.session;if(e.queue.abort(),e.session=null,mt(e),t){let n=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n.status,detail:n.detail}),gt(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||(ot(e,it(e.placeholder)),e.loadedUrl=null,Ge(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Ct(e,t){let n=`relatedTarget`in t?t.relatedTarget:null,r=n instanceof HTMLElement?n:null,i=r?.getAttribute(`data-wui-url`)||e.remoteUrl||``,a=yt(e,i,{trigger:r});a.explicitSize=wt(e,r?.getAttribute(`data-wui-size`)),a.explicitSize&&Ge(e.shell,a.explicitSize),e.cache&&e.loadedUrl===i||(e.loadedUrl&&ot(e,it(e.placeholder)),J(e,a,{keepPlaceholder:!0}))}function wt(e,t){try{return Xe(e,t)}catch(e){return s(e),null}}async function J(e,t,{keepPlaceholder:n=!1}={}){n||ot(e,it(nt(t.options.title||Tt(e))));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if((r.kind===`ok`||r.kind===`validation`)&&kt(e,t,r.html,!1))return e.loadedUrl=t.url,gt(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return ot(e,it(rt(t.options.title||Tt(e),i))),ut(e)&&dt(L(K(e),`a card`),!1,Ye(e)),gt(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Tt=e=>K(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Et=`/_content/Webority.Ui.Razor/js/`,Dt=e=>new URL(e,window.location.href).pathname.includes(Et);function Ot(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function kt(e,t,n,r){let i=document.createElement(`template`);i.innerHTML=n;let a=!1;for(let e of i.content.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Dt(t)?Ot(t):a=!0}a&&o(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let c=R(i.content,I);if(!c)return s(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(ot(e,c),r||mt(e),!G(e)){Ge(e.shell,t.explicitSize||wt(e,c.getAttribute(`data-wui-size`))||e.defaultSize);let n=c.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return ut(e)&&dt(c,r,Ye(e)),!0}var At=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function jt(e,t,n){let r=[...e.elements].filter(e=>e.matches(At));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.insertAdjacentHTML(`afterbegin`,`<span class="spinner-border spinner-border-sm me-2" aria-hidden="true" data-wui-submit-spinner></span>`))}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 Mt(e){for(let t of e.querySelectorAll(Fe))t.remove();for(let t of e.querySelectorAll(Pe))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Nt=/* @__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(`.`)),Pt=(e,t)=>{if(typeof e==`object`&&e&&t in e)return Reflect.get(e,t)};async function Ft(e){if(!e||e.status<400||e.status>499||e.status===422||!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(Pt(t,`title`)),i=(e.statusText||``).trim().toLowerCase(),a=Nt.has(r.toLowerCase())||r.toLowerCase()===i;return n(Pt(t,`message`))||n(Pt(t,`detail`))||(r&&!a?r:null)}function It(e,t,n,r){let i=t.closest(`.wui-modal-body`)||t;i.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Mt(i);let a=document.createElement(`div`);a.className=`alert alert-danger wui-modal-submit-error`,a.setAttribute(`role`,`alert`),a.setAttribute(`data-wui-modal-submit-error`,``),a.innerHTML=H(`${P.submitFailed} ${r||P[n]||P.server}`),i.prepend(a),pt(e,a.textContent)}var Lt=(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 Rt(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(I)||(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(),c=new FormData(n);i?.name&&!c.has(i.name)&&c.append(i.name,i.value);let l=o===`GET`;jt(n,i,!0);let u;try{u=await e.queue.run(l?Lt(a,c):a,{method:o,body:l?void 0:c,navigate:r.options.navigate})}catch(t){s(t),e.session===r&&n.isConnected&&(jt(n,i,!1),It(e,n,`server`,null));return}if(e.session!==r)return;if(n.isConnected&&jt(n,i,!1),u.kind===`ok`&&u.result===`success`){zt(e,r,u);return}if(u.kind===`aborted`||u.kind===`stale`||u.kind===`session`)return;if(u.kind===`validation`&&kt(e,r,u.html,!0)){let t=L(K(e),`a card`).querySelector(Fe)?.textContent?.replace(/\s+/g,` `).trim();pt(e,t||P.invalid);return}if(u.kind===`ok`&&u.html&&kt(e,r,u.html,!1))return;let ee=u.kind===`ok`||u.kind===`validation`?`server`:u.kind,d=await Ft(u.response);e.session===r&&It(e,n,ee,d)}function zt(e,t,n){let r=n.message,i=n.redirect||null,a=n.toastVariant||`success`;if(!Qt(a))throw TypeError(`Unknown toast variant "${a}". Use ${Zt.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?Sn(r,a):r&&k().toast(r,{variant:a}),gt(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&&kt(e,t,n.html,!1):q(e,t,`success`,o)}function Bt(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`)?Jt(t.getAttribute(`data-wui-pane`)??``,{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{B(e)||s(e)}):t.hasAttribute(`data-wui-modal`)?Wt(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=>{B(e)||s(e)}):Kt(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=>{B(e)||s(e)})))}function Vt(e){if(e.key!==`Tab`||e.defaultPrevented)return;let t=e.currentTarget;if(!(t instanceof Document))return;let n=Ve(t,`.modal.show`),r=R(t,`.modal.show.wui-modal-stacked`)??n[n.length-1];r&&ft(r,e)}function Ht(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=V(e.target,qt),n=t&&Re.get(t),r=e.currentTarget;n?.session&&r instanceof Document&&!r.querySelector(`.modal.show`)&&q(n,n.session,`dismissed`,null)}function Ut(e=document){let t=e instanceof Document?e:L(e.ownerDocument,`an owner document`);ze.has(t)||(ze.add(t),t.addEventListener(`click`,Bt),t.addEventListener(`keydown`,Vt),t.addEventListener(`keydown`,Ht));let n=Ve(e,`.modal[data-wui-remote-url]`);e instanceof HTMLElement&&e.matches(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)vt(e)}function Wt(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=He(e),r=t.container===`drawer`,i=r?qe(t.size):U(t.size),a=t.placement||`center`;if(!Ke.includes(a))throw TypeError(`WUI.modal.load: unsupported placement "${a}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(z());let o=et(r?`drawer`:`modal`);Ut(document);let s=vt(o),c=ut(s),l=yt(s,e,t);l.explicitSize=i,Ge(o,i||s.defaultSize),r||Be(o,`.modal-dialog`,`a dialog frame`).classList.toggle(`modal-dialog-centered`,a===`center`),t.title&&o.setAttribute(`aria-label`,t.title),c||(!r&&Ze()&&(document.body.appendChild(o),o.classList.add(`wui-modal-stacked`)),n.getInstance(o)?.dispose(),n.getOrCreateInstance(o,{backdrop:t.staticBackdrop===!1||`static`,keyboard:t.staticBackdrop===!1}));let u=c?Promise.resolve():new Promise(e=>o.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),ee=J(s,l);return c||n.getOrCreateInstance(o).show(),Gt(s,l,t,u,ee,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Gt(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(z())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw z();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 Kt(e,t={}){return Wt(e,{...t,container:`drawer`,placement:void 0})}var qt=`[data-wui-pane-host]`;function Jt(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=Qe(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(z());Ut(document);let r=vt(n),i=yt(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=J(r,i);return Gt(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function Yt(e){let t=Qe(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=Re.get(t);n?.session&&q(n,n.session,`dismissed`,null)}var Y=`wuiConfirm`,Xt=Object.freeze([`danger`]),Zt=Object.freeze([`success`,`info`,`warning`,`danger`]),Qt=e=>Zt.some(t=>t===e),$t=`wui.flash`,X=Object.freeze({confirmTitle:`Are you sure?`,confirmLabel:`Confirm`,cancelLabel:`Cancel`,failed:`That did not work. Try again.`,forbidden:`You do not have permission to do that.`,network:`Could not reach the server. Check your connection and try again.`}),en=/* @__PURE__ */ new WeakSet,tn=/* @__PURE__ */ new WeakSet,nn=null,rn=null,an=!1,on=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},sn=(e,t)=>{e&&k().toast(e,{variant:t})},cn=()=>r(window.bootstrap?.Modal,`data-wui-confirm: Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);function ln(){let n=document.getElementById(Y);return n||(n=document.createElement(`div`),n.id=Y,n.className=`modal fade wui-modal-shell`,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-modal`,`true`),n.style.setProperty(`--wui-modal-max-width`,`${N.md}px`),n.innerHTML=`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal wui-confirm"><div class="wui-modal-body"><div class="wui-confirm-content"><span class="wui-confirm-icon"><wui-status-icon tone="info" size="120"></wui-status-icon></span><h3 class="wui-confirm-title" tabindex="-1" data-autofocus></h3><p class="wui-confirm-msg"></p></div></div><div class="wui-modal-footer"><div class="wui-confirm-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${on(X.cancelLabel)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-app-confirm data-wui="${t}"></button></div></div></div></div>`,document.body.appendChild(n),n)}function un(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Xt.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);dn({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 dn({title:e,message:t,label:n,danger:r},i){let a=cn(),o=ln(),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=n||X.confirmLabel,c.classList.toggle(`btn-danger`,r),c.classList.toggle(`btn-primary`,!r),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,r?`delete`:`info`),o.setAttribute(`aria-label`,u),rn=i,an=!1,a.getOrCreateInstance(o).show()}var fn=(e,t)=>{nn=e;try{t()}finally{nn=null}},pn=(e,t)=>{let n=Reflect.get(e,t);if(n===void 0||typeof n==`string`)return n;throw TypeError(`confirmAction: ${t} must be text.`)},mn=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:pn(e,`title`),message:t,label:pn(e,`label`),tone:pn(e,`tone`)}};function hn(e,t,n){let{title:r,message:i,label:a,tone:o}=mn(t);if(o!=null&&!Xt.includes(o))throw TypeError(`confirmAction: tone "${o}" is not supported. Use danger, or leave it off.`);Fn(e.ownerDocument),dn({title:r,message:i,label:a,danger:o===`danger`},()=>fn(e,n))}var gn=e=>`disabled`in e&&e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`,_n=e=>{n(e,HTMLElement,`data-wui-confirm needs an HTML element to click.`).click()};function vn(e){let t=i(e.target,`[data-wui-confirm]:not(form)`);t&&t!==nn&&!gn(t)&&(e.preventDefault(),e.stopImmediatePropagation(),un(t,()=>fn(t,()=>_n(t))))}function yn(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===nn||e.submitter&&e.submitter===nn||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;un(t,()=>fn(t,()=>t.requestSubmit(r)))}function bn(e){let t=i(e.target,`#${Y} [data-app-confirm]`);if(!t||t.hasAttribute(`disabled`)||!rn)return;an=!0;let n=cn(),a=r(t.closest(`#${Y}`),`#${Y} is missing around its confirm button.`);n.getOrCreateInstance(a).hide()}function xn(e){if(!(e.target instanceof Element)||e.target.id!==`wuiConfirm`)return;let t=an?rn:null;rn=null,an=!1,t?.()}function Sn(e,t){e&&window.sessionStorage.setItem($t,JSON.stringify({message:e,variant:t}))}var Cn=e=>e===`forbidden`?X.forbidden:e===`network`?X.network:X.failed;function wn(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.getAttribute(`data-refresh-on-success`)!==`false`&&O(e)?.reload()}var Tn=(e,t)=>{`disabled`in e&&(e.disabled=t)};async function En(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 Dn(t,e)}async function Dn(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.`);Tn(t,!0),t.setAttribute(`aria-busy`,`true`);let i=await ne(e,{method:`POST`,body:n});if(i.kind===`session`||i.kind===`aborted`)return;let a=i.toastVariant||`success`;i.ok&&(i.redirect||r===`page`)?(Sn(i.message,a),i.redirect?window.location.assign(i.redirect):window.location.reload()):(Tn(t,!1),t.removeAttribute(`aria-busy`),i.ok?(Ae(i,a),wn()):sn(i.message||Cn(i.kind),`danger`))}function On(e,t){Tn(e,!1),e.removeAttribute(`aria-busy`),s(t),sn(X.failed,`danger`)}function kn(e){let t=i(e.target,`[data-wui-post]`);t&&(e.preventDefault(),gn(t)||t.getAttribute(`aria-busy`)===`true`||En(t).catch(e=>On(t,e)))}function An(e){let t=i(e.target,`form[data-wui-post-form]`);if(!(t instanceof HTMLFormElement)||e.defaultPrevented)return;e.preventDefault();let n=r(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(n.getAttribute(`aria-busy`)===`true`)return;Dn(t.action,n,new FormData(t)).catch(e=>On(n,e));let a=t.closest(`.dropdown`)?.querySelector(`[data-bs-toggle='dropdown']`);a&&window.bootstrap?.Dropdown?.getInstance(a)?.hide()}function jn(){let e=window.sessionStorage.getItem($t);if(!e)return;window.sessionStorage.removeItem($t);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`||!Qt(r))throw TypeError(`stored flash variant "${String(r)}" is not supported.`);if(typeof n!=`string`)throw TypeError(`stored flash message is not text.`);sn(n,r)}function Mn(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(!Qt(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${Zt.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),sn(n,t)}}var Nn=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.form:null;function Pn(e){if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-wui-auto-submit]`);if(!t)return;let n=Nn(e.target)||t.closest(`form`);n instanceof HTMLFormElement&&n.requestSubmit()}function Fn(e){tn.has(e)||(tn.add(e),e.addEventListener(`click`,bn),e.addEventListener(`hidden.bs.modal`,xn))}function In(e=document){let t=e instanceof Element?e.ownerDocument:e;en.has(t)||(en.add(t),t.addEventListener(`click`,vn,!0),t.addEventListener(`submit`,yn,!0),Fn(t),t.addEventListener(`click`,kn),t.addEventListener(`submit`,An),t.addEventListener(`change`,Pn),jn()),Mn(e)}var Ln=Object.freeze({title:`Leave without saving?`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,leaveLabel:`Leave`}),Rn=`form[data-wui-unsaved]`,zn=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,Bn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,Vn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),Hn=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Un=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Wn=e=>Un(e)?e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled:`disabled`in e&&!!e.disabled,Gn=e=>`name`in e&&typeof e.name==`string`&&e.name!==``,Kn=e=>typeof e==`object`&&!!e,qn=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&typeof e[0]==`string`);function Jn(e){let t=JSON.parse(e);if(!qn(t))throw Error(`unsaved-changes snapshot is malformed`);return t}var Z=/* @__PURE__ */ new WeakMap,Yn=/* @__PURE__ */ new WeakSet,Xn=e=>`${e.name}:${e.size}:${e.lastModified}`,Zn=e=>[...e.querySelectorAll(Rn)].filter(e=>e instanceof HTMLFormElement);function Q(e){let t=[];for(let n of e.elements)Gn(n)&&!Wn(n)&&(Un(n)&&Vn.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(Xn)]):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 Qn(e){return Q(e)}function $n(e,t){let n=/* @__PURE__ */ new Map,r=Jn(t);for(let e of r){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let i=Jn(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())i.push(...e);return JSON.stringify(i)}function er(e){for(let t of e.elements)if(Un(t)&&t.name&&!Wn(t)){if(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!Hn.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 tr=e=>({saved:e.querySelector(zn)&&er(e)?null:Q(e),engaged:!1,discarded:!1});function nr(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var rr=(e,t)=>Zn(e).filter(e=>e!==t&&nr(e)),ir=()=>!!window.bootstrap?.Modal;function ar(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||Ln.message;hn(e,{title:Ln.title,message:r,label:Ln.leaveLabel,tone:`danger`},()=>{for(let e of t){let t=Z.get(e);t&&(t.discarded=!0)}n()})}function or(e){if(e.matches(Bn))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 sr(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 cr(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target,n=i(t,`a[href]`);if(!(n instanceof HTMLAnchorElement)||!or(n))return;let r=rr(n.ownerDocument,null);r.length&&ir()&&(e.preventDefault(),ar(n,r,()=>n.click()))}function lr(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!sr(t,e.submitter))return;let n=rr(t.ownerDocument,t);if(n.length&&ir()){e.preventDefault();let r=e.submitter,i=(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.form===t?r:void 0;ar(t,n,()=>t.requestSubmit(i));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function ur(e){rr(document,null).length&&(e.preventDefault(),e.returnValue=``)}function dr(e){let t=e.target,n=i(t,Rn);return n instanceof HTMLFormElement?n:null}function fr(e){let t=dr(e);if(!t)return;let n=Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function pr(e){let t=dr(e),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function mr(e){for(let t of Zn(e)){let e=Z.get(t);e?.saved&&(e.saved=$n(t,e.saved))}}function hr(e){let t=Kn(e)?e.handle:void 0;return Kn(t)?t.el:void 0}function gr(e){if(!(e instanceof CustomEvent))return;let t=hr(e.detail);if(t instanceof Element)for(let e of Zn(t))vr(e)}function _r(e=document){let t=e instanceof Document?e:e.ownerDocument;if(!Yn.has(t)){Yn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,fr,!0);for(let e of[`input`,`change`])t.addEventListener(e,pr,!0);t.addEventListener(`click`,cr),t.addEventListener(`submit`,lr),t.addEventListener(`wui:modal:success`,gr),t.addEventListener(a,()=>mr(t)),r(t.defaultView,`unsaved-changes guard needs a document with a window`).addEventListener(`beforeunload`,ur)}let n=Zn(e);e instanceof HTMLFormElement&&e.matches(Rn)&&n.unshift(e);for(let e of n)Z.has(e)||Z.set(e,tr(e))}function vr(e){if(!(e instanceof HTMLFormElement)||!e.matches(Rn))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var yr=Object.freeze({question:`Discard your changes?`,discard:`Discard`,keep:`Keep editing`}),br=`wui:drawer:discard`,xr=`wui-drawer[confirm-discard]`,Sr=`.wui-modal-shell`,Cr=`data-wui-no-discard`,wr=`.wui-drawer-discard`,Tr=`input, select, textarea`,Er=e=>typeof e==`object`&&!!e||typeof e==`function`;function Dr(e){let t=e.currentTarget;if(!(t instanceof Document))throw Error(`The discard guard is not wired on a document.`);return t}function Or(e,t){return i(e,t)}var kr=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement,$=/* @__PURE__ */ new WeakMap,Ar=/* @__PURE__ */ new WeakSet,jr=/* @__PURE__ */ new WeakSet;function Mr(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 Nr(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,Mr(e,`danger`,`solid`,`data-wui-discard-confirm`,yr.discard),Mr(e,`primary`,`soft`,`data-wui-discard-keep`,yr.keep)),n}function Pr(e){if(!(e instanceof Element))return null;let t=e.closest(xr);if(t)return t;let n=e.closest(Sr);return n&&Lr(n).length?n:null}function Fr(e){return e.closest(xr)??e.closest(Sr)}function Ir(e,t){return t.hasAttribute(Cr)||e.hasAttribute(Cr)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Lr(e){return e.matches(xr)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Ir(t,e))}function Rr(e){let t=$.get(e);return t!=null&&Qn(e)!==t}function zr(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,r(e.querySelector(`.wui-drawer-panel`),`The drawer has no panel to hold its footer.`).append(t),jr.add(t),t}function Br(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),jr.add(t),t}function Vr(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 Hr(e,t,n){let r=e.querySelector(wr);if(r){Vr(r);return}let i=Nr(e.ownerDocument,t),a;if(e.matches(xr))a=e.querySelector(`.wui-drawer-footer`)??zr(e),a.prepend(i);else if(e.hasAttribute(`confirm-discard`))a=e.querySelector(`.wui-modal-footer`)??Br(e),a.prepend(i);else{if(!n)throw Error(`A discard prompt needs the form that is dirty.`);a=n.querySelector(`.modal-footer`),a?a.prepend(i):(a=n,n.append(i))}a.classList.add(`wui-drawer-discarding`),Vr(i)}function Ur(e){let t=e.parentElement;if(e.remove(),!t)throw Error(`The discard prompt has no footer.`);t.classList.remove(`wui-drawer-discarding`),jr.has(t)&&t.remove()}function Wr(e){for(let t of Lr(e))for(let e of t.querySelectorAll(Tr))if(kr(e)&&e.type!==`hidden`&&!e.disabled){e.focus({preventScroll:!0});return}}function Gr(e){let t=Pr(e.target);if(t)for(let e of Lr(t))$.get(e)??$.set(e,Qn(e))}function Kr(e){for(let t of Dr(e).querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,$n(t,e))}}function qr(e){let t=e.target;t instanceof HTMLFormElement&&Pr(t)&&$.set(t,Qn(t))}function Jr(e){if(!Er(e))return;let t=`handle`in e?e.handle:void 0;if(Er(t))return`el`in t?t.el:void 0}function Yr(e){if(!(e instanceof CustomEvent))return;let t=e.detail,n=Jr(t);if(n instanceof Element)for(let e of n.querySelectorAll(`form`))$.delete(e)}function Xr(e){let t=e.target;t instanceof Element&&t.matches(xr)&&[...Lr(t)].some(Rr)&&(e.preventDefault(),Hr(t,t.getAttribute(`confirm-discard`),null))}function Zr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Sr))return;let n=[...Lr(t)].find(Rr);n&&(e.preventDefault(),Hr(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??yr.question,n))}function Qr(e){let t=e.closest(`wui-drawer`);if(t){t.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}))&&t.hide();return}let n=e.closest(Sr);n&&window.bootstrap?.Modal.getInstance(n)?.hide()}function $r(e){let t=r(e.closest(wr),`The discard button is outside its prompt.`),n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);for(let e of Lr(n))$.set(e,Qn(e));n.dispatchEvent(new CustomEvent(br,{bubbles:!0})),n.matches(xr)?r(n.closest(`wui-drawer`),`The confirm-discard drawer is not a wui-drawer.`).hide():r(window.bootstrap?.Modal.getInstance(n),`Bootstrap's Modal has no instance for the discarded dialog.`).hide()}function ei(e){let t=r(e.closest(wr),`The keep button is outside its prompt.`),n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);Wr(n)}function ti(e){let t=Or(e.target,`[data-wui-discard-confirm]`);if(t){$r(t);return}let n=Or(e.target,`[data-wui-discard-keep]`);if(n){ei(n);return}let r=Or(e.target,`[data-wui-dismiss]`);r&&Qr(r)}function ni(e){if(e.key!==`Escape`)return;let t=Dr(e).querySelector(wr);if(!t)return;e.preventDefault(),e.stopPropagation();let n=Fr(t);if(Ur(t),!n)throw Error(`The discard prompt is outside its drawer or modal.`);Wr(n)}function ri(e=document){let t=e instanceof Document?e:e.ownerDocument;Ar.has(t)||(Ar.add(t),t.addEventListener(`focusin`,Gr),t.addEventListener(`pointerdown`,Gr),t.addEventListener(`submit`,qr),t.addEventListener(a,Kr),t.addEventListener(`wui:modal:success`,Yr),t.addEventListener(`wui:modal:loaded`,Yr),t.addEventListener(`wui-drawer-close`,Xr,!0),t.addEventListener(`hide.bs.modal`,Zr),t.addEventListener(`click`,ti),t.addEventListener(`keydown`,ni,!0))}export{Ae as C,je as S,D as T,Ut as _,Ln as a,Jt as b,vr as c,$t as d,Zt as f,Yt as g,In as h,ri as i,Y as l,hn as m,yr as n,Qn as o,X as p,Nr as r,_r as s,br as t,Xt as u,Kt as v,O as w,Te as x,Wt as y};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"../commentText-BnX7rA2-.js";import{n as r}from"../elementBase-Cxeyx0tU.js";import{t as i}from"../WuiCommentThread-By-u3c5S.js";import"./mention-input.js";r(`wui-comment-thread`,i);export{n as COMMENT_INTENTS,e as COMMENT_REACTIONS,t as COMMENT_TEXT,i as WuiCommentThread};
1
+ import{n as e,r as t,t as n}from"../commentText-BnX7rA2-.js";import{n as r}from"../elementBase-Cxeyx0tU.js";import{t as i}from"../WuiCommentThread-BmRsl0K1.js";import"./mention-input.js";r(`wui-comment-thread`,i);export{n as COMMENT_INTENTS,e as COMMENT_REACTIONS,t as COMMENT_TEXT,i as WuiCommentThread};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiDataTable-D8UW2DMH.js";import{A as n,C as r,D as i,E as a,M as o,O as s,S as c,T as l,_ as u,a as d,b as f,c as p,d as m,f as h,g,h as _,i as v,j as y,k as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"../dataTable-D23oUOhU.js";e(`wui-data-table`,t);export{O as COLUMN_MAX_WIDTH,C as COLUMN_MIN_WIDTH,E as DATA_TABLE_TEXT,v as PIN_AT_VAR,d as PIN_SIDES,w as RESIZE_STEP,D as RESIZE_STEP_LARGE,p as ROW_HEIGHTS,x as ROW_MOVE_LIMIT,k as ROW_MOVE_MS,m as ROW_SAVE_ATTR,h as ROW_SAVE_ERROR_CLASS,T as ROW_SAVE_STATES,S as VIRTUAL_OVERSCAN,t as WuiDataTable,_ as clampColumnWidth,g as groupCount,u as groupItems,A as identityCell,N as measureRows,f as pinAtValue,M as pinClasses,c as pinOffsetVar,r as planPins,j as playRowMoves,l as readColumnWidths,a as rowLabel,i as rowOrderChanged,s as saveOutcomeText,b as setRowSaveState,n as settledRows,y as virtualRange,o as writeColumnWidths};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiDataTable-B4BYCd_s.js";import{A as n,C as r,D as i,E as a,M as o,O as s,S as c,T as l,_ as u,a as d,b as f,c as p,d as m,f as h,g,h as _,i as v,j as y,k as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"../dataTable-B-7oAeii.js";e(`wui-data-table`,t);export{O as COLUMN_MAX_WIDTH,C as COLUMN_MIN_WIDTH,E as DATA_TABLE_TEXT,v as PIN_AT_VAR,d as PIN_SIDES,w as RESIZE_STEP,D as RESIZE_STEP_LARGE,p as ROW_HEIGHTS,x as ROW_MOVE_LIMIT,k as ROW_MOVE_MS,m as ROW_SAVE_ATTR,h as ROW_SAVE_ERROR_CLASS,T as ROW_SAVE_STATES,S as VIRTUAL_OVERSCAN,t as WuiDataTable,_ as clampColumnWidth,g as groupCount,u as groupItems,A as identityCell,N as measureRows,f as pinAtValue,M as pinClasses,c as pinOffsetVar,r as planPins,j as playRowMoves,l as readColumnWidths,a as rowLabel,i as rowOrderChanged,s as saveOutcomeText,b as setRowSaveState,n as settledRows,y as virtualRange,o as writeColumnWidths};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{i as t,n,r,t as i}from"../inlineEditText-H7Pr8IU9.js";import{t as a}from"../WuiInlineEdit-r55qgh8A.js";e(`wui-inline-edit`,a);export{i as INLINE_EDIT_SAVED_MS,n as INLINE_EDIT_TEXT,r as INLINE_EDIT_TYPES,a as WuiInlineEdit,t as inlineEditText};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{i as t,n,r,t as i}from"../inlineEditText-CsLCQbcg.js";import{t as a}from"../WuiInlineEdit-BlBuWkHG.js";e(`wui-inline-edit`,a);export{i as INLINE_EDIT_SAVED_MS,n as INLINE_EDIT_TEXT,r as INLINE_EDIT_TYPES,a as WuiInlineEdit,t as inlineEditText};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../kanban-CJ587-XT.js";import{a as n,c as r,d as i,f as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"../kanbanModel-BdqSa1lJ.js";e(`wui-kanban`,t);export{h as KANBAN_DRAG_THRESHOLD_PX,u as KANBAN_LONG_PRESS_MS,p as KANBAN_PHONE_QUERY,s as KANBAN_STORAGE_PREFIX,n as KANBAN_SUMMARY_FORMATS,d as KANBAN_TEXT,m as KANBAN_TONES,t as WuiKanban,r as kanbanCardLabel,c as kanbanOverflow,g as kanbanStorageKey,i as kanbanSummaryFormat,a as kanbanVisibleLimit,f as readKanbanCollapsed,l as sumKanbanValues,o as writeKanbanCollapsed};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../kanban-Dz8m-17x.js";import{a as n,c as r,d as i,f as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"../kanbanModel-C2IOPJ8L.js";e(`wui-kanban`,t);export{h as KANBAN_DRAG_THRESHOLD_PX,u as KANBAN_LONG_PRESS_MS,p as KANBAN_PHONE_QUERY,s as KANBAN_STORAGE_PREFIX,n as KANBAN_SUMMARY_FORMATS,d as KANBAN_TEXT,m as KANBAN_TONES,t as WuiKanban,r as kanbanCardLabel,c as kanbanOverflow,g as kanbanStorageKey,i as kanbanSummaryFormat,a as kanbanVisibleLimit,f as readKanbanCollapsed,l as sumKanbanValues,o as writeKanbanCollapsed};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiLightbox-D7Nf1SbH.js";e(`wui-lightbox`,t);export{t as WuiLightbox};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiLightbox-C2A14vHx.js";e(`wui-lightbox`,t);export{t as WuiLightbox};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiMarkdown-N96OX-To.js";e(`wui-markdown`,t);export{t as WuiMarkdown};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiMarkdown-BXY0QKaO.js";e(`wui-markdown`,t);export{t as WuiMarkdown};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{i as t,n,r,t as i}from"../mentionText-BJsw_opZ.js";import{i as a,n as o,r as s,t as c}from"../WuiMentionInput-BFB57FZI.js";e(`wui-mention-input`,a);export{i as MENTION_ID_PATTERN,c as MENTION_MAX_QUERY,o as MENTION_MAX_RESULTS,s as MENTION_TEXT,a as WuiMentionInput,n as mentionLabel,r as mentionTextFromValue,t as mentionValueFromText};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{i as t,n,r,t as i}from"../mentionText-BJsw_opZ.js";import{i as a,n as o,r as s,t as c}from"../WuiMentionInput-8Xjkzdqg.js";e(`wui-mention-input`,a);export{i as MENTION_ID_PATTERN,c as MENTION_MAX_QUERY,o as MENTION_MAX_RESULTS,s as MENTION_TEXT,a as WuiMentionInput,n as mentionLabel,r as mentionTextFromValue,t as mentionValueFromText};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiNotificationCenter-C6e13nCh.js";e(`wui-notification-center`,t);export{t as WuiNotificationCenter};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiNotificationCenter-ClkCTUnp.js";e(`wui-notification-center`,t);export{t as WuiNotificationCenter};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiOverflow-CeLUmJR-.js";e(`wui-overflow`,t);export{t as WuiOverflow};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiOverflow-B0wA6aDe.js";e(`wui-overflow`,t);export{t as WuiOverflow};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiPhone-rtex3VDC.js";e(`wui-phone`,t);export{t as WuiPhone};
1
+ import{n as e}from"../elementBase-Cxeyx0tU.js";import{t}from"../WuiPhone-BVNVerap.js";e(`wui-phone`,t);export{t as WuiPhone};