@webority/ui-elements 0.135.0 β†’ 0.136.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 (36) hide show
  1. package/dist/WuiOrgTree-DuaBtFl9.js +1 -0
  2. package/dist/drawerDiscard-DRTki0-d.js +1 -0
  3. package/dist/elements/org-tree.js +1 -0
  4. package/dist/server.js +1 -1
  5. package/dist/ui-elements/autocomplete.global.js +1 -1
  6. package/dist/ui-elements/carousel.global.js +1 -1
  7. package/dist/ui-elements/code-block.global.js +1 -1
  8. package/dist/ui-elements/command-palette.global.js +1 -1
  9. package/dist/ui-elements/comment-thread.global.js +1 -1
  10. package/dist/ui-elements/consent-banner.global.js +1 -1
  11. package/dist/ui-elements/context-menu.global.js +1 -1
  12. package/dist/ui-elements/date-range.global.js +1 -1
  13. package/dist/ui-elements/drawer.global.js +1 -1
  14. package/dist/ui-elements/image-crop.global.js +1 -1
  15. package/dist/ui-elements/inline-edit.global.js +1 -1
  16. package/dist/ui-elements/kanban.global.js +1 -1
  17. package/dist/ui-elements/lead-popup.global.js +1 -1
  18. package/dist/ui-elements/lightbox.global.js +1 -1
  19. package/dist/ui-elements/markdown.global.js +1 -1
  20. package/dist/ui-elements/multiselect.global.js +1 -1
  21. package/dist/ui-elements/org-tree.global.js +1 -0
  22. package/dist/ui-elements/phone.global.js +1 -1
  23. package/dist/ui-elements/resizable.global.js +1 -1
  24. package/dist/ui-elements/saved-views.global.js +1 -1
  25. package/dist/ui-elements/slider.global.js +1 -1
  26. package/dist/ui-elements/sortable.global.js +1 -1
  27. package/dist/ui-elements/status-icon.global.js +1 -1
  28. package/dist/ui-elements/taginput.global.js +1 -1
  29. package/dist/ui-elements/timepicker.global.js +1 -1
  30. package/dist/ui-elements/tour.global.js +1 -1
  31. package/dist/ui-elements/tree.global.js +1 -1
  32. package/dist/ui-elements/wizard.global.js +1 -1
  33. package/dist/ui-elements.global.js +1 -1
  34. package/dist/ui-elements.js +1 -1
  35. package/package.json +3 -2
  36. package/dist/drawerDiscard-WVoYg0lh.js +0 -1
@@ -0,0 +1 @@
1
+ import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-DV9IZZCu.js";var n=`li[data-wui-org-node]`,r=`:scope > .wui-org-tree-node`,i=`:scope > .wui-org-tree-node > .wui-org-tree-text > .wui-org-tree-name`,a=`:scope > .wui-org-tree-children`,o=`:scope > .wui-org-tree-node > [data-wui-org-toggle]`,s=`[data-wui-org-toggle]`,c=`a, button, input, select, textarea`,l=`.wui-org-tree-overlay`,u=`[data-wui-org-search]`,d=`[data-wui-org-canvas]`,f=`[data-wui-org-live]`,p=`--wui-org-tree-print-scale`,m=718,h=1e3,g=150,_=`Show {name}'s team`,v=`Hide {name}'s team`,y=`{count} found`,b=`No one found`,x=e=>[...e.querySelectorAll(n)],S=e=>e.querySelector(i)?.textContent.trim()??``,C=e=>e.getAttribute(`data-wui-org-node`),w=e=>e.getAttribute(`aria-expanded`)===`true`,T=class extends t{static get observedAttributes(){return[`selected`,`selectable`,`expand-label`,`collapse-label`,`search-results-text`,`search-empty-text`]}constructor(){super(),this._query=``,this._snapshot=null,this._observer=null,this._announceTimer=null,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onInput=e=>this._handleInput(e),this._onBeforePrint=()=>this._scaleForPrint(),this._onAfterPrint=()=>this.style.removeProperty(p)}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`input`,this._onInput),window.addEventListener(`beforeprint`,this._onBeforePrint),window.addEventListener(`afterprint`,this._onAfterPrint);let t=this.querySelector(d);t?(this._observer=new MutationObserver(()=>{this._query&&this._applySearch(this._query)}),this._observer.observe(t,{childList:!0,subtree:!0})):e(`[@webority/ui-elements] <wui-org-tree> has no [data-wui-org-canvas]; render the tree markup inside it.`)}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`input`,this._onInput),window.removeEventListener(`beforeprint`,this._onBeforePrint),window.removeEventListener(`afterprint`,this._onAfterPrint),this._observer?.disconnect(),this._observer=null,clearTimeout(this._announceTimer)}attributeChangedCallback(e){e===`selected`||e===`selectable`?this._applySelected():(e===`expand-label`||e===`collapse-label`)&&this._syncToggles()}get selected(){return this.getAttribute(`selected`)}set selected(e){e==null?this.removeAttribute(`selected`):this.setAttribute(`selected`,String(e))}get selectable(){return this.hasAttribute(`selectable`)}set selectable(e){this.toggleAttribute(`selectable`,!!e)}_items(){return x(this)}_hasChildren(e){return!!e.querySelector(a)}_isVisible(e){for(let t=e;t&&t!==this;t=t.parentElement)if(t.hasAttribute(`hidden`))return!1;return!0}_visibleItems(){return this._items().filter(e=>this._isVisible(e))}_parentItem(e){let t=e.parentElement?.closest(n);return t&&this.contains(t)?t:null}_visibleChildren(e){let t=e.querySelector(a);return t?[...t.children].filter(e=>e.matches(n)&&this._isVisible(e)):[]}_siblingItem(e,t){let r=e[t];for(;r&&!(r.matches(n)&&this._isVisible(r));)r=r[t];return r}_setRoving(e){for(let t of this._items())t.setAttribute(`tabindex`,t===e?`0`:`-1`)}_focusItem(e){e&&(this._setRoving(e),e.focus())}_toggleLabel(e,t){return(t?this.getAttribute(`collapse-label`)??v:this.getAttribute(`expand-label`)??_).split(`{name}`).join(S(e))}_setExpanded(e,t){let n=e.querySelector(a);n&&(e.setAttribute(`aria-expanded`,String(t)),n.hidden=!t,e.querySelector(o)?.setAttribute(`aria-label`,this._toggleLabel(e,t)),!t&&n.contains(document.activeElement)&&this._focusItem(e))}_toggle(e){this._setExpanded(e,!w(e))}_syncToggles(){for(let e of this._items())this._hasChildren(e)&&this._setExpanded(e,w(e))}_applySelected(){for(let e of this._items())this.selectable?e.setAttribute(`aria-selected`,String(C(e)===this.selected)):e.removeAttribute(`aria-selected`)}_select(e){this.selectable&&(this.selected=C(e),this.dispatchEvent(new CustomEvent(`wui-org-tree:select`,{detail:{id:this.selected},bubbles:!0,composed:!0})))}_activate(e){this.selectable?this._select(e):this._hasChildren(e)&&this._toggle(e)}_handleFocusIn(e){let t=e.target.closest?.(n);t&&this.contains(t)&&this._setRoving(t)}_handleClick(e){let t=e.target.closest?.(n);t&&this.contains(t)&&(this._setRoving(t),e.target.closest(s)?this._hasChildren(t)&&this._toggle(t):t.querySelector(r)?.contains(e.target)&&(e.target.closest(c)?.closest(l)||this._select(t)))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t.matches?.(n)&&this.contains(t))switch(e.key){case`ArrowDown`:if(e.preventDefault(),!this._hasChildren(t))return;w(t)||this._setExpanded(t,!0),this._focusItem(this._visibleChildren(t)[0]);return;case`ArrowUp`:e.preventDefault(),this._focusItem(this._parentItem(t));return;case`ArrowRight`:e.preventDefault(),this._focusItem(this._siblingItem(t,`nextElementSibling`));return;case`ArrowLeft`:e.preventDefault(),this._focusItem(this._siblingItem(t,`previousElementSibling`));return;case`Home`:e.preventDefault(),this._focusItem(this._visibleItems()[0]);return;case`End`:e.preventDefault(),this._focusItem(this._visibleItems().at(-1));return;case`+`:case`=`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!0);return;case`-`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!1);return;case`Enter`:case` `:e.preventDefault(),this._activate(t);return}}_handleInput(e){e.target.matches?.(u)&&this._search(e.target.value.trim().toLocaleLowerCase())}_search(e){clearTimeout(this._announceTimer),e?(this._snapshot||=this._captureExpanded(),this._query=e,this._applySearch(e),this._announceTimer=setTimeout(()=>this._announce(this._resultText()),g)):(this._snapshot&&this._restore(this._snapshot),this._snapshot=null,this._query=``,this._announce(``))}_captureExpanded(){return new Map(this._items().filter(e=>this._hasChildren(e)).map(e=>[C(e),w(e)]))}_restore(e){for(let t of this._items()){t.hidden=!1,t.classList.remove(`wui-org-tree-match`);let n=C(t);e.has(n)&&this._setExpanded(t,e.get(n))}}_applySearch(e){let t=this._items(),n=new Set(t.filter(t=>S(t).toLocaleLowerCase().includes(e))),r=new Set(n);for(let e of n)for(let t=this._parentItem(e);t;t=this._parentItem(t))r.add(t),w(t)||this._setExpanded(t,!0);for(let e of t)e.classList.toggle(`wui-org-tree-match`,n.has(e)),e.hidden=!r.has(e);let i=t.filter(e=>r.has(e));i.length&&!i.some(e=>e.getAttribute(`tabindex`)===`0`)&&this._setRoving(i[0])}_resultText(){let e=this._items().filter(e=>e.classList.contains(`wui-org-tree-match`)).length;return e===0?this.getAttribute(`search-empty-text`)??b:(this.getAttribute(`search-results-text`)??y).split(`{count}`).join(String(e))}_announce(e){let t=this.querySelector(f);t&&(t.textContent=e)}_scaleForPrint(){let e=this.querySelector(d);if(!e)return;let t=Math.min(1,m/e.scrollWidth,h/e.scrollHeight);this.style.setProperty(p,String(t))}};export{T as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./buttonClass-DpG9WzgJ.js";import{n,t as r}from"./devWarn-DXdRWZs3.js";import{l as i,s as a}from"./wuiHttp-DgnM7K2Q.js";import{E as o,k as s,r as c,w as l,y as u}from"./dataTable-CUILMcga.js";import{t as d}from"./iconGlyphs.g-gURMSeyB.js";import{LIST_QUERY_RESERVED as f,SEARCH_PARAM as ee}from"./listQuery.js";var p=Object.freeze({autocomplete:{entries:[`elements/autocomplete.js`],tags:[`wui-autocomplete`]},carousel:{entries:[`elements/carousel.js`],tags:[`wui-carousel`]},"code-block":{entries:[`elements/code-block.js`],tags:[`wui-code-block`]},"command-palette":{entries:[`elements/command-palette.js`],tags:[`wui-command-palette`]},"comment-thread":{entries:[`elements/comment-thread.js`],tags:[`wui-mention-input`,`wui-comment-thread`]},"consent-banner":{entries:[`elements/consent-banner.js`],tags:[`wui-consent-banner`]},"context-menu":{entries:[`elements/context-menu.js`],tags:[`wui-context-menu`]},"date-range":{entries:[`elements/date-range.js`],tags:[`wui-date-range`]},drawer:{entries:[`elements/drawer.js`],tags:[`wui-drawer`]},"image-crop":{entries:[`elements/image-crop.js`],tags:[`wui-image-crop`]},"inline-edit":{entries:[`elements/inline-edit.js`],tags:[`wui-inline-edit`]},kanban:{entries:[`elements/kanban.js`],tags:[`wui-kanban`]},"lead-popup":{entries:[`elements/lead-popup.js`],tags:[`wui-lead-popup`]},lightbox:{entries:[`elements/lightbox.js`],tags:[`wui-lightbox`]},"org-tree":{entries:[`elements/org-tree.js`],tags:[`wui-org-tree`]},markdown:{entries:[`elements/markdown.js`],tags:[`wui-markdown`]},multiselect:{entries:[`elements/multiselect.js`],tags:[`wui-multiselect`]},phone:{entries:[`elements/phone.js`,`elements/country-select.js`],tags:[`wui-phone`,`wui-country-select`]},resizable:{entries:[`elements/resizable.js`],tags:[`wui-resizable`]},"saved-views":{entries:[`elements/saved-views.js`],tags:[`wui-saved-views`]},slider:{entries:[`elements/slider.js`],tags:[`wui-slider`]},sortable:{entries:[`elements/sortable.js`],tags:[`wui-sortable`]},"status-icon":{entries:[`elements/status-icon.js`],tags:[`wui-status-icon`]},taginput:{entries:[`elements/taginput.js`],tags:[`wui-taginput`]},timepicker:{entries:[`elements/timepicker.js`],tags:[`wui-timepicker`]},tour:{entries:[`elements/tour.js`],tags:[`wui-tour`]},tree:{entries:[`elements/tree.js`],tags:[`wui-tree`]},wizard:{entries:[`elements/wizard.js`],tags:[`wui-wizard-step`,`wui-wizard`]},chart:{file:`ui-chart.global.js`,tags:[`wui-chart`],selfContained:!0},calendar:{file:`ui-calendar.global.js`,tags:[`wui-calendar`],selfContained:!0},"rich-text":{file:`ui-rich-text.global.js`,tags:[`wui-rich-text`],selfContained:!0},"file-viewer":{file:`ui-file-viewer.global.js`,tags:[`wui-file-viewer`],selfContained:!0}});Object.freeze({anchorOverlay:`anchorOverlay.js`,buttonClass:`buttonClass.js`,calendarMath:`calendarMath.js`,copyText:`copyText.js`,dataTable:`dataTable.js`,defineElement:`defineElement.js`,devWarn:`devWarn.js`,elementBase:`elementBase.js`,fieldState:`fieldState.js`,formatters:`formatters.js`,formMirror:`formMirror.js`,iconGlyphs:`iconGlyphs.g.js`,listboxKeyNav:`listboxKeyNav.js`,loader:`global/loader.js`,mentionText:`mentionText.js`,notificationDays:`notificationDays.js`,optionLabel:`optionLabel.js`,stepperHeader:`stepperHeader.js`,tableSelect:`tableSelect.js`,textMatch:`textMatch.js`,wuiHttp:`server/wuiHttp.js`,WuiSelect:`WuiSelect.js`,zone:`zone.js`});var m=`wui-elements:defined`,h=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(p))for(let n of t.tags)h.set(n,e);[...h.keys()].join(`,`);function g(e,t){e&&(e.tip?.isConnected?(t.addEventListener(`hidden${e.constructor.EVENT_KEY}`,()=>e.dispose(),{once:!0}),e.hide()):e.dispose())}var _=`wui-remote-modal`,v=`wui-remote-drawer`,te=Object.freeze({sm:360,md:480,lg:640,xl:720}),y=`wui-modal-fullscreen`,b=Object.freeze({sm:380,md:440,lg:640,xl:880}),x=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.`}),S=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,C=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,w=`[aria-invalid="true"], .is-invalid, .input-validation-error`,ne=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,re=`[data-wui-modal-content]`,T=`[data-wui-pane-close], [data-bs-dismiss="modal"]`,E=`<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>`,D=/* @__PURE__ */ new WeakMap,ie=/* @__PURE__ */ new WeakSet,O=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),ae=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},k=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML};function A(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Object.hasOwn(b,e))return{px:b[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 oe=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:b.md}},j=(e,t)=>{e.classList.toggle(y,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},M=[`center`,`top`];function N(e){if(e==null||e===``)return null;if(Object.hasOwn(te,e))return{px:te[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 P=e=>e.container===`drawer`,F=e=>e.container===`pane`,I=e=>e.container!==`modal`,se=(e,t)=>P(e)?N(t):A(t),ce=()=>document.getElementById(`wui-remote-drawer`)?.classList.contains(`show`)??!1,le=e=>{let t=typeof e==`string`?document.querySelector(e):e;return t?.matches?.(`[data-wui-pane-host]`)?t:null},ue=e=>F(e)?e.shell:e.shell.querySelector(`.modal-dialog`);function de(e=`modal`){let t=e===`drawer`,n=t?v:_,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?te.md:b.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 L=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${k(e)}</div></div></div>${E}</div>`,fe=e=>`<div class="modal-content wui-modal" aria-busy="true">${L(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${k(x.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>`,pe=(n,r)=>`<div class="modal-content wui-modal" data-wui-modal-error="${k(r)}">${L(n)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${k(x.errorTitle)}</p><p class="wui-modal-state-text">${k(x[r]||x.server)}</p><div class="wui-modal-state-actions"><button type="button" class="${e(`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${k(x.close)}</button><button type="button" class="${e(`primary`,`md`)}" data-wui-modal-retry data-wui="${t}">${k(x.retry)}</button></div></div></div></div>`,me=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelector(`.modal-content`)},R=e=>e.shell.querySelector(`.modal-content`);function he(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=[t?.Tooltip,t?.Popover].filter(e=>e?.getInstance);for(let r of[e,...e.querySelectorAll(`*`)]){for(let e of n)g(e.getInstance(r),r);t?.Dropdown?.getInstance?.(r)?.dispose()}}function z(e,t){let n=R(e),r=n?_e(n):/* @__PURE__ */ new Map;he(n),n?n.replaceWith(t):ue(e).appendChild(t),ve(t,r),window.WUI?.refresh?.()}var ge=`input[type="file"][name]`;function _e(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(ge))n.files.length>0&&t.set(n.name,[...n.files]);return t}function ve(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(ge)){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 B=e=>F(e)?!e.shell.hidden:e.shell.classList.contains(`show`);function ye(e,t,n=!1){let r=t&&e.querySelector(w),i=r?r.matches(S)?r:r.querySelector(S)||r:null;if(!i&&n)i=e.querySelector(`[data-autofocus]`)||e.querySelector(C)||e.querySelector(`.wui-modal-close`);else if(!i){let t=[...e.querySelectorAll(S)];i=e.querySelector(`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}i?.focus?.()}function be(e,t){let n=[...e.querySelectorAll(S)].filter(e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`);if(!n.length){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],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 xe(e,t){let n=e.shell.querySelector(`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),ue(e).appendChild(n)),n.textContent=``,n.textContent=t}var Se=e=>{let t=e.shell.querySelector(`[data-wui-modal-live]`);t&&(t.textContent=``)},V=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}));function H(e,t,n,r){let i={...r,container:e.container};V(t,`wui:modal:${n}`,i),P(e)&&V(t,`wui:drawer:${n}`,i),F(e)&&V(t,`wui:pane:${n}`,i)}var U=e=>e.matches(`[data-wui-pane-host]`)?`pane`:e.classList.contains(`wui-remote-drawer`)?`drawer`:`modal`;function Ce(e){let t=D.get(e);return t||(t={shell:e,container:U(e),queue:a(),defaultSize:oe(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:R({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},D.set(e,t),e.addEventListener(`submit`,e=>He(t,e)),e.addEventListener(`click`,e=>{e.target.closest?.(`[data-wui-modal-retry]`)&&t.session&&(e.preventDefault(),G(t,t.session))}),F(t)&&e.addEventListener(`click`,e=>{let n=e.target.closest?.(T);n&&e.currentTarget.contains(n)&&t.session&&W(t,t.session,`dismissed`,null)}),e.addEventListener(`hidden.bs.modal`,n=>{n.target===e&&(e.classList.contains(`wui-modal-stacked`)&&Ee(t),De(t))}),e.addEventListener(`shown.bs.modal`,n=>{if(n.target!==e)return;e.classList.contains(`wui-modal-stacked`)&&[...document.querySelectorAll(`.modal-backdrop`)].at(-1)?.classList.add(`wui-modal-backdrop-stacked`);let r=R(t);t.session&&r?.matches(re)&&!r.contains(document.activeElement)&&ye(r,!1,I(t))}),t.remoteUrl&&e.addEventListener(`show.bs.modal`,n=>{n.target===e&&Oe(t,n)}),t)}function we(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r,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:null};return a.handle={el:e.shell,closed:i,close:()=>W(e,a,`dismissed`,null),reload:()=>G(e,a)},e.session=a,a}function W(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},F(e)?Te(e,t):window.bootstrap?.Modal?.getOrCreateInstance(e.shell).hide())}function Te(e,t){let n=e.shell,{status:r,detail:i}=t.closing,a=n.contains(document.activeElement);e.queue.abort(),e.session=null,he(R(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),H(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function Ee(e){e.shell.classList.remove(`wui-modal-stacked`),ce()&&(document.body.classList.add(`modal-open`),document.body.style.overflow=`hidden`)}function De(e){let t=e.session;if(e.queue.abort(),e.session=null,Se(e),t){let{status:n,detail:r}=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n,detail:r}),H(e,e.shell,`closed`,{status:n,url:t.url});let i=document.activeElement;t.trigger?.isConnected&&(!i||i===document.body||e.shell.contains(i))&&t.trigger.focus?.()}e.cache||(z(e,me(e.placeholder)),e.loadedUrl=null,j(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function Oe(e,t){let n=t.relatedTarget instanceof Element?t.relatedTarget:null,r=n?.getAttribute(`data-wui-url`)||e.remoteUrl,i=we(e,r,{trigger:n});i.explicitSize=ke(e,n?.getAttribute(`data-wui-size`)),i.explicitSize&&j(e.shell,i.explicitSize),e.cache&&e.loadedUrl===r||(e.loadedUrl&&z(e,me(e.placeholder)),G(e,i,{keepPlaceholder:!0}))}function ke(e,t){try{return se(e,t)}catch(e){return r(e),null}}async function G(e,t,{keepPlaceholder:n=!1}={}){n||z(e,me(fe(t.options.title||Ae(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`)&&Pe(e,t,r.html,!1))return e.loadedUrl=t.url,H(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return z(e,me(pe(t.options.title||Ae(e),i))),B(e)&&ye(R(e),!1,I(e)),H(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var Ae=e=>R(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,je=`/_content/Webority.Ui.Razor/js/`,Me=e=>new URL(e,window.location.href).pathname.includes(je);function Ne(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Pe(e,t,i,a){let o=document.createElement(`template`);o.innerHTML=i;let s=!1;for(let e of o.content.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Me(t)?Ne(t):s=!0}s&&n(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let c=o.content.querySelector(re);if(!c)return r(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(z(e,c),a||Se(e),!F(e)){j(e.shell,t.explicitSize||ke(e,c.getAttribute(`data-wui-size`))||e.defaultSize);let n=c.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return B(e)&&ye(c,a,I(e)),!0}var Fe=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Ie(e,t,n){let r=[...e.elements].filter(e=>e.matches(Fe));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 Le(e){for(let t of e.querySelectorAll(ne))t.remove();for(let t of e.querySelectorAll(w))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var Re=/* @__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(`.`));async function ze(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(t?.title),i=(e.statusText||``).trim().toLowerCase(),a=Re.has(r.toLowerCase())||r.toLowerCase()===i;return n(t?.message)||n(t?.detail)||(r&&!a?r:null)}function Be(e,t,n,r){let i=t.closest(`.wui-modal-body`)||t;i.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Le(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=k(`${x.submitFailed} ${r||x[n]||x.server}`),i.prepend(a),xe(e,a.textContent)}var Ve=(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 He(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(re)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=t.submitter||null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;Ie(n,i,!0);let l=await e.queue.run(c?Ve(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate});if(e.session!==r)return;if(n.isConnected&&Ie(n,i,!1),l.kind===`ok`&&l.result===`success`){Ue(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`validation`&&Pe(e,r,l.html,!0)){let t=R(e).querySelector(ne)?.textContent.replace(/\s+/g,` `).trim();xe(e,t||x.invalid);return}if(l.kind===`ok`&&l.html&&Pe(e,r,l.html,!1))return;let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,d=await ze(l.response);e.session===r&&Be(e,n,u,d)}function Ue(e,t,n){let r=n.message,i=n.redirect||null,a={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};r&&window.WUI?.toast?.(r,{variant:`success`}),H(e,t.trigger?.isConnected?t.trigger:document,`success`,a),t.options.onSuccess?.(a,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),n.next&&!i?(t.url=n.next,t.method=`GET`,t.body=void 0,G(e,t)):n.keepOpen?n.html&&Pe(e,t,n.html,!1):W(e,t,`success`,a)}function We(e){let t=e.target.closest?.(`[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`)?Qe(t.getAttribute(`data-wui-pane`),{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{e?.name!==`AbortError`&&r(e)}):t.hasAttribute(`data-wui-modal`)?Je(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=>{e?.name!==`AbortError`&&r(e)}):Xe(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=>{e?.name!==`AbortError`&&r(e)})))}function Ge(e){if(e.key!==`Tab`||e.defaultPrevented)return;let t=e.currentTarget.querySelectorAll(`.modal.show`),n=e.currentTarget.querySelector(`.modal.show.wui-modal-stacked`)??t[t.length-1];n&&be(n,e)}function Ke(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target.closest?.(Ze),n=t&&D.get(t);n?.session&&!e.currentTarget.querySelector(`.modal.show`)&&W(n,n.session,`dismissed`,null)}function qe(e=document){let t=e.ownerDocument||e;ie.has(t)||(ie.add(t),t.addEventListener(`click`,We),t.addEventListener(`keydown`,Ge),t.addEventListener(`keydown`,Ke));let n=[...e.querySelectorAll?.(`.modal[data-wui-remote-url]`)||[]];e.matches?.(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)Ce(e)}function Je(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=ae(e),r=t.container===`drawer`,i=r?N(t.size):A(t.size),a=t.placement||`center`;if(!M.includes(a))throw TypeError(`WUI.modal.load: unsupported placement "${a}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(O());let o=de(r?`drawer`:`modal`);qe(document);let s=Ce(o),c=B(s),l=we(s,e,t);l.explicitSize=i,j(o,i||s.defaultSize),r||o.querySelector(`.modal-dialog`).classList.toggle(`modal-dialog-centered`,a===`center`),t.title&&o.setAttribute(`aria-label`,t.title),c||(!r&&ce()&&(document.body.appendChild(o),o.classList.add(`wui-modal-stacked`)),n.getInstance(o)?.dispose(),n.getOrCreateInstance(o,{backdrop:!t.staticBackdrop||`static`,keyboard:!t.staticBackdrop}));let u=c?Promise.resolve():new Promise(e=>o.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),d=G(s,l);return c||n.getOrCreateInstance(o).show(),Ye(s,l,t,u,d,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Ye(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),W(e,t,`dismissed`,{aborted:!0})),i(O())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw O();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 Xe(e,t={}){return Je(e,{...t,container:`drawer`,placement:void 0})}var Ze=`[data-wui-pane-host]`;function Qe(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=le(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(O());qe(document);let r=Ce(n),i=we(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=G(r,i);return Ye(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function $e(e){let t=le(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=D.get(t);n?.session&&W(n,n.session,`dismissed`,null)}var et=`Select all rows`,tt=`Select row`,K=`wui-select-cell`,nt=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function rt(e=document){let t=e.createElement(`th`);return t.className=K,t.appendChild(nt(e,et)),t}function it(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=K;let r=nt(e,tt);return r.disabled=t,n.appendChild(r),n}function at(e=document){let t=e.createElement(`td`);return t.className=K,t}var ot=e=>e.firstElementChild?.classList.contains(K),st=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`);function ct(e){for(let t of e){if(ot(t)||st(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(it(t.ownerDocument,{disabled:e}),t.firstChild)}}function lt(e){let t=e.querySelector(`thead tr`);if(!t)return null;ot(t)||t.insertBefore(rt(e.ownerDocument),t.firstChild),ct(e.querySelectorAll(`tbody tr`));for(let t of e.querySelectorAll(`tfoot tr`))ot(t)||t.insertBefore(at(e.ownerDocument),t.firstChild);return t.querySelector(`.${K} .wui-check`)}function ut(e){let t=e.querySelector(`thead .${K} .wui-check`),n=[...e.querySelectorAll(`tbody tr .wui-check:not(:disabled)`)],r=n.length,i=n.filter(e=>e.checked).length;t&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of e.querySelectorAll(`tbody tr`))t.classList.toggle(`is-selected`,!!t.querySelector(`.wui-check`)?.checked);return{selected:i,total:r}}var dt=`tbody .${K} .wui-check:not(:disabled)`;function ft(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=[...e.querySelectorAll(dt)],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 pt=8e3,mt=`That did not work. Try again.`;function ht(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?window.WUI?.toast?.(e.message,{variant:t,duration:pt,action:{label:n.label,onClick:()=>gt(n)}}):window.WUI?.toast?.(e.message,{variant:t})}async function gt(e){let t=await i(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){ht(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&Et(e)?.reload()}else window.WUI?.toast?.(t.message||mt,{variant:`danger`})}}var q=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`}),_t=5,vt=/* @__PURE__ */ new WeakMap,yt=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},bt=e=>({total:yt(e.dataset.total,0),page:yt(e.dataset.page,1),pageSize:yt(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),xt=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},St=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>e.type!==`hidden`||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 e.querySelectorAll(`[data-wui-filter-clear]`))t.hidden=!r},Ct=new Intl.NumberFormat(`en-IN`),wt=(e,t)=>{let n=e.closest(`.wui-list-card`)?.querySelector(`.wui-list-card-count`);n&&(n.textContent=Ct.format(t))};function Tt(e=document){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-server]`)]:[];e instanceof Element&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t)vt.has(e)||vt.set(e,Dt(e))}function Et(e){let t=e instanceof Element?e.closest(`[data-wui-server]`):null;return t&&vt.get(t)||null}function Dt(p){let m=p.querySelector(`.table-wrap`),h=m?.querySelector(`:scope > table`),g=p.dataset.src;if(!h||!g)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let _=m.querySelector(`:scope > [data-wui-table-state]`),v=p.querySelector(`[data-wui-table-pager]`),te=p.querySelector(`[data-wui-table-status]`),y={urlState:p.dataset.urlState!==`false`,refreshOnSuccess:p.dataset.refreshOnSuccess!==`false`,filtersForm:p.dataset.filtersForm||null,filtersRegion:p.dataset.filtersRegion||null,searchInput:p.dataset.searchInput||null,loadingText:p.dataset.loadingText||q.loading,errorText:p.dataset.errorText||q.error},b=new URL(g,window.location.href),x=new Set(b.searchParams.keys()),S=h.hasAttribute(`data-app-datatable-selectable`),C=/* @__PURE__ */ new Set,w=!1,ne=a(),re=new AbortController,T={signal:re.signal},E=h.querySelector(`:scope > tbody[data-wui-rows]`);if(!E)throw Error(`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`);let D=bt(E),ie=null,O=null,ae=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))x.has(n)||t.append(n,r);return t},k=e=>ae(new URL(e,window.location.href).search),A=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},oe=e=>{let t=new URL(b.href);for(let[n,r]of e)x.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},j=(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},M=j(y.urlState?ae(window.location.search):new URLSearchParams,D);y.urlState&&A(M)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,A(M));let N=(e,t)=>m.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),P=e=>{te&&(te.textContent=e)},F=e=>{if(e.total===0)return q.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1;return`Page ${e.page} of ${t}, ${e.total} ${e.total===1?`row`:`rows`}`},I=()=>[...h.querySelectorAll(`:scope > thead > tr:first-child > th`)],se=e=>{if(S&&[...e.querySelectorAll(`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`)].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.`)},ce=e=>{let t=p.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`)}},le=e=>{if(S){ct(e);for(let t of e){let e=t.querySelector(`.${K} .wui-check:not(:disabled)`);e&&(w&&C.add(t.dataset.rowKey),e.checked=C.has(t.dataset.rowKey))}ut(h)}ce(e);let t=I();if(h.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`)})},ue=e=>le([...e.querySelectorAll(`:scope > tr`)]),de=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},L=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),fe=(e,t)=>{if(!_)return;let n=e.querySelector(`:scope > template[data-wui-empty]`);L(_),t.total===0&&n?(_.replaceChildren(n.content.cloneNode(!0)),_.hidden=!1):(_.replaceChildren(),_.hidden=!0)},pe=e=>{let t=bt(e),n=t.sortBy!==D.sortBy||t.sortOrder!==D.sortOrder?u(E.rows):null;if(v){let t=e.querySelector(`:scope > template[data-wui-pager]`);L(v),v.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),v.hidden=!1}fe(e,t);let r=e.querySelector(`:scope > template[data-wui-filters]`),i=y.filtersRegion&&r?document.querySelector(y.filtersRegion):null;i&&(L(i),i.replaceChildren(r.content.cloneNode(!0))),de(e),L(E),h.replaceChild(e,E),E=e;let a=w&&t.total!==D.total;return D=t,a&&(w=!1),m.removeAttribute(`data-wui-table-error`),ue(e),xe(),l(e.rows,n),a&&V(),i},me=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=t.content.querySelector(`tbody[data-wui-rows]`);return n&&se(n),n?document.importNode(n,!0):null},R=(e,t=I())=>{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},he=()=>{if(E.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,I().length);E.replaceChildren(...Array.from({length:_t},()=>{let t=R(e);return t.setAttribute(`data-wui-skeleton`,``),t})),m.removeAttribute(`data-wui-table-error`),_&&(_.hidden=!0)},z=e=>{e?(m.setAttribute(`aria-busy`,`true`),he()):m.removeAttribute(`aria-busy`)},ge=e=>e===`forbidden`?q.forbidden:e===`network`?q.network:y.errorText,_e=n=>{let r=ge(n);if(m.setAttribute(`data-wui-table-error`,n),v&&(v.hidden=!0),_){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=d(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(`outline`,`sm`),c.dataset.wui=t,c.setAttribute(`data-wui-table-retry`,``),c.textContent=q.retry,s.append(c),i.append(a,o,s),L(_),_.replaceChildren(i),_.hidden=!1}P(r)},ve=()=>y.filtersForm?document.querySelector(y.filtersForm):null,B=async(e,t=`none`,{quiet:i=!1}={})=>{let a=new URLSearchParams(e);i||(ie={query:a,mode:t},z(!0),P(y.loadingText)),N(`wui:table:loading`,{query:a.toString()});let o=await ne.run(oe(a));if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;i||z(!1);let s=null,c=o.ok?null:o.kind;if(o.ok){try{s=me(o.html)}catch(e){r(e)}s||(c=`server`)}if(c)return i?n(`A quiet server table refresh failed; the rows on screen are kept.`,c):_e(c),N(`wui:table:error`,{status:o.status,kind:c,message:ge(c)}),o;let l=pe(s);return M=j(a,D),St(ve(),M),y.urlState&&t===`push`?window.history.pushState(window.history.state,``,A(M)):y.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,A(M)),i||P(F(D)),window.WUI?.refresh?.(m),l&&window.WUI?.refresh?.(l),wt(p,D.total),N(`wui:table:loaded`,{...D,query:M.toString()}),o},ye=e=>(e.delete(`page`),e),be=()=>[...h.querySelectorAll(`:scope > thead th[data-sort-key]`)],xe=()=>{for(let e of be()){let t=e.dataset.sortKey===D.sortBy;e.setAttribute(`aria-sort`,t?D.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of be())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=d(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let Se=e=>{let t=ye(new URLSearchParams(M)),n=D.sortBy===e&&D.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),B(t,`push`)};h.addEventListener(`click`,e=>{let t=e.target.closest(`th[data-sort-key]`);t&&h.tHead?.contains(t)&&Se(t.dataset.sortKey)}),h.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest?.(`th[data-sort-key]`);t&&h.tHead?.contains(t)&&(e.preventDefault(),Se(t.dataset.sortKey))});let V=()=>{ut(h);let e=w?{selected:D.total,total:D.total,allMatching:w}:{selected:C.size,total:D.total};h.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};S&&(ft(h,(e,t)=>{for(let n of e){let e=n.closest(`tr`)?.dataset.rowKey;e&&(t?C.add(e):C.delete(e))}t||(w=!1)}),h.addEventListener(`change`,e=>{let t=e.target;if(t.matches?.(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(w=!1),h.tHead?.contains(t))for(let e of E.querySelectorAll(`:scope > tr`)){let n=e.querySelector(`.${K} .wui-check:not(:disabled)`);n&&(n.checked=t.checked,t.checked?C.add(e.dataset.rowKey):C.delete(e.dataset.rowKey))}else{let e=t.closest(`tr`)?.dataset.rowKey;if(!e)return;t.checked?C.add(e):C.delete(e)}V()}})),v&&(v.addEventListener(`click`,e=>{let t=e.target.closest(`a[href]`);!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),B(k(t.getAttribute(`href`)),`push`))}),v.addEventListener(`change`,e=>{e.target.classList?.contains(`tpg-select`)&&e.target.value&&(e.stopPropagation(),B(k(e.target.value),`push`))}));let H=()=>{if(!y.searchInput)return null;let e=document.querySelector(y.searchInput);return e&&(e.matches(`input, textarea`)?e:e.querySelector(`input`))},U=()=>p.isConnected?!0:(re.abort(),clearTimeout(O),!1),Ce=(e,t)=>{let n=/* @__PURE__ */ new Set;for(let t of e.elements)t.name&&t.type!==`hidden`&&n.add(t.name);let r=[];for(let t of e.elements)if(t.name&&!t.disabled){if(t.matches(`input[type="hidden"][data-wui-carried]`))n.has(t.name)||r.push([t.name,t.value]);else if(t.matches(`input[type=checkbox], input[type=radio]`))t.checked&&r.push([t.name,t.value]);else if(t.matches(`input, textarea`))t.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||r.push([t.name,t.value]);else if(t.localName===`select`)for(let e of t.selectedOptions)r.push([t.name,e.value])}return t?.name&&!t.disabled&&r.push([t.name,t.value]),r},we=(e,t)=>{let n=new Set([...e.elements].map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&f.includes(e);for(let[e,t]of M)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of Ce(e,t))a===``||i(n)||x.has(n)||r.append(n,a);let a=H();if(a){r.delete(ee);let e=a.value.trim();e&&r.set(ee,e)}return B(r,`push`)},W=e=>y.filtersForm&&e.closest?.(y.filtersForm)||y.filtersRegion&&e.closest?.(y.filtersRegion)||null;document.addEventListener(`submit`,e=>{U()&&y.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(y.filtersForm)&&(e.preventDefault(),we(e.target,e.submitter))},T),document.addEventListener(`change`,e=>{if(!U()||!y.filtersForm)return;let t=e.target.closest?.(y.filtersForm);!t||e.target===H()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest?.(`wui-filter-popover`)||we(t)},T);let Te=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of e.querySelectorAll(`input[name]:not([type=hidden])`))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 e.querySelectorAll(`select[name]`))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 t of e.querySelectorAll(`wui-select[name]`))t.value=n(t.getAttribute(`name`));for(let n of e.querySelectorAll(`wui-multiselect[name]`))n.values=t.getAll(n.getAttribute(`name`));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(!U())return;let t=e.target.closest?.(`a[href]`);if(!t||!W(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=ye(k(n.href));Te(t.closest(`form`),r),St(t.closest(`form`),r),B(r,`push`)},T),document.addEventListener(`input`,e=>{if(!U())return;let t=H();t&&e.target===t&&(clearTimeout(O),O=setTimeout(()=>{if(!U())return;let e=ye(new URLSearchParams(M)),n=t.value.trim();n?e.set(ee,n):e.delete(ee),e.toString()!==M.toString()&&B(e,`replace`)},300))},T),y.urlState&&window.addEventListener(`popstate`,()=>{if(!U())return;let e=ae(window.location.search),t=H();t&&(t.value=e.get(`search`)??``),St(ve(),e),B(e,`none`)},T),document.addEventListener(`wui:modal:success`,()=>{U()&&y.refreshOnSuccess&&B(M,`none`)},T),_?.addEventListener(`click`,e=>{e.target.closest(`[data-wui-table-retry]`)&&ie&&B(ie.query,ie.mode)});let Ee=e=>[...E.rows].find(t=>t.dataset.rowKey===e)??null,De=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=[...t.content.querySelectorAll(`table > tbody > tr[data-row-key]`)];return n.length?n.map(e=>document.importNode(e,!0)):null},Oe=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:Ee(n.dataset.rowKey);e&&(L(e),e.replaceWith(n),i.push(n))}return le(i),window.WUI?.refresh?.(m),r},ke=e=>e.message||(e.kind===`forbidden`?q.actionForbidden:q.actionFailed),G=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&s(e,null)},Ae=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=t.content.querySelector(`table > tbody > tr`);if(!n)throw Error("saveRow's `row` is the row as it will read: a <tr> element or its HTML.");return document.importNode(n,!0)},je=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 l=r==null,u=l?null:Ee(String(r));if(!l&&!u)throw Error(`saveRow found no row with data-row-key="${r}" on this page.`);let d=I().filter(e=>!e.classList.contains(K)),f=a?Ae(a):u??R(Math.max(1,d.length),d);u&&f!==u?u.replaceWith(f):u||E.insertBefore(f,E.firstChild),f!==u&&le([f]),_&&!m.hasAttribute(`data-wui-table-error`)&&(_.hidden=!0),s(f,`saving`);let ee=o(f),p=await i(e,{method:t.toUpperCase(),body:n});if(p.kind===`session`)return!1;if(p.ok){let e=De(p.html),t=e&&f.isConnected?Oe(e,f,l):null;return t?P(c.saved(o(t)||ee)):(await B(M,`none`),G(f)),ht(p,p.toastVariant||`success`),N(`wui:table:saved`,{key:t?.dataset.rowKey??(l?null:String(r)),added:l,status:p.status}),!0}let h=ke(p),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):l&&!a&&(f.remove(),g=null,_?.childElementCount&&!E.querySelector(`:scope > tr`)&&(_.hidden=!1)),g?.isConnected&&s(g,`error`,h),p.kind!==`aborted`&&xt(h,`danger`),P(c.notSaved(ee,h)),N(`wui:table:failed`,{key:l?null:String(r),added:l,status:p.status,kind:p.kind,message:h}),!1},Me=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=e.closest(`tr`),r=n?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,l=n?o(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&s(n,`saving`);let u=await i(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),u.kind===`session`||u.kind===`aborted`)G(n);else{if(u.ok){ht(u,u.toastVariant||`success`);let e=n?.isConnected?De(u.html):null,t=e?Oe(e,n,!1):null;t?P(c.saved(o(t)||l)):(await B(M,`none`),G(n))}else{let e=ke(u);xt(e,`danger`),n?.isConnected&&s(n,`error`,e),P(c.notSaved(l,e))}N(`wui:table:action`,{action:a,key:r,ok:u.ok,status:u.status})}};return h.addEventListener(`click`,e=>{let t=e.target.closest(`[data-wui-row-action]`);t&&E.contains(t)&&!t.disabled&&(e.preventDefault(),Me(t))}),se(E),de(E),S&&lt(h),ue(E),xe(),{el:p,reload:async e=>{let t=e?.quiet===!0;return t&&m.getAttribute(`aria-busy`)===`true`?null:B(M,`none`,{quiet:t})},query:()=>new URLSearchParams(M),setQuery:e=>{let t=new URLSearchParams(M);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:je,setActiveRow:e=>{p.dataset.activeRowKey=e==null?``:String(e),ce([...E.querySelectorAll(`:scope > tr`)])},selection:{keys:()=>[...C],count:()=>w?D.total:C.size,allMatching:()=>w,selectAllMatching:()=>{w=!0;for(let e of E.querySelectorAll(`:scope > tr`)){let t=e.querySelector(`.${K} .wui-check`);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&C.add(e.dataset.rowKey))}V()},clear:()=>{w=!1,C.clear();for(let e of E.querySelectorAll(`:scope > tr > .${K} .wui-check:not(:disabled)`))e.checked=!1;V()}}}}var J=`wuiConfirm`,Ot=Object.freeze([`danger`]),kt=Object.freeze([`success`,`info`,`warning`,`danger`]),At=`wui.flash`,Y=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.`}),jt=/* @__PURE__ */ new WeakSet,Mt=/* @__PURE__ */ new WeakSet,Nt=null,Pt=null,Ft=!1,It=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},Lt=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},Rt=()=>{let e=window.bootstrap?.Modal;if(!e)throw Error(`data-wui-confirm: Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return e};function zt(){let n=document.getElementById(J);return n||(n=document.createElement(`div`),n.id=J,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`,`${b.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(`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${It(Y.cancelLabel)}</button><button type="button" class="${e(`primary`,`md`)}" data-app-confirm data-wui="${t}"></button></div></div></div></div>`,document.body.appendChild(n),n)}function Bt(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!Ot.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);Vt({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 Vt({title:e,message:t,label:n,danger:r},i){let a=Rt(),o=zt(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${J} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${J}"> 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)),s.textContent=e||Y.confirmTitle,l.textContent=t,c.textContent=n||Y.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`,s.textContent),Pt=i,Ft=!1,a.getOrCreateInstance(o).show()}var Ht=(e,t)=>{Nt=e;try{t()}finally{Nt=null}};function Ut(e,{title:t,message:n,label:r,tone:i},a){if(i!=null&&!Ot.includes(i))throw TypeError(`confirmAction: tone "${i}" is not supported. Use danger, or leave it off.`);on(e.ownerDocument),Vt({title:t,message:n,label:r,danger:i===`danger`},()=>Ht(e,a))}var Wt=e=>e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`;function Gt(e){let t=e.target.closest?.(`[data-wui-confirm]:not(form)`);t&&t!==Nt&&!Wt(t)&&(e.preventDefault(),e.stopImmediatePropagation(),Bt(t,()=>Ht(t,()=>t.click())))}function Kt(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===Nt||e.submitter&&e.submitter===Nt||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter?.form===t?e.submitter:void 0;Bt(t,()=>Ht(t,()=>t.requestSubmit(n)))}function qt(e){let t=e.target.closest?.(`#${J} [data-app-confirm]`);t&&!t.disabled&&Pt&&(Ft=!0,Rt().getOrCreateInstance(t.closest(`#${J}`)).hide())}function Jt(e){if(e.target.id!==`wuiConfirm`)return;let t=Ft?Pt:null;Pt=null,Ft=!1,t?.()}var Yt=(e,t)=>{e&&window.sessionStorage.setItem(At,JSON.stringify({message:e,variant:t}))},Xt=e=>e===`forbidden`?Y.forbidden:e===`network`?Y.network:Y.failed;function Zt(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&Et(e)?.reload()}async function Qt(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 $t(t,e)}async function $t(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.`);t.disabled=!0,t.setAttribute(`aria-busy`,`true`);let a=await i(e,{method:`POST`,body:n});if(a.kind===`session`||a.kind===`aborted`)return;let o=a.toastVariant||`success`;a.ok&&(a.redirect||r===`page`)?(Yt(a.message,o),a.redirect?window.location.assign(a.redirect):window.location.reload()):(t.disabled=!1,t.removeAttribute(`aria-busy`),a.ok?(ht(a,o),Zt()):Lt(a.message||Xt(a.kind),`danger`))}function en(e){let t=e.target.closest?.(`[data-wui-post]`);t&&(e.preventDefault(),Wt(t)||t.getAttribute(`aria-busy`)===`true`||Qt(t).catch(e=>r(e)))}function tn(e){let t=e.target.closest?.(`form[data-wui-post-form]`);if(!t||e.defaultPrevented)return;e.preventDefault();let n=e.submitter||t.querySelector(`button`);n.getAttribute(`aria-busy`)!==`true`&&($t(t.getAttribute(`action`),n,new FormData(t)).catch(e=>r(e)),window.bootstrap?.Dropdown?.getInstance(t.closest(`.dropdown`)?.querySelector(`[data-bs-toggle='dropdown']`))?.hide())}function nn(){let e=window.sessionStorage.getItem(At);if(!e)return;window.sessionStorage.removeItem(At);let{message:t,variant:n}=JSON.parse(e);Lt(t,n)}function rn(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(!kt.includes(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${kt.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||e.textContent.trim();e.remove(),Lt(n,t)}}function an(e){let t=e.target instanceof Element?e.target.closest(`[data-wui-auto-submit]`):null,n=t&&(e.target.form||t.closest(`form`));n&&n.requestSubmit()}function on(e){Mt.has(e)||(Mt.add(e),e.addEventListener(`click`,qt),e.addEventListener(`hidden.bs.modal`,Jt))}function sn(e=document){let t=e.ownerDocument||e;jt.has(t)||(jt.add(t),t.addEventListener(`click`,Gt,!0),t.addEventListener(`submit`,Kt,!0),on(t),t.addEventListener(`click`,en),t.addEventListener(`submit`,tn),t.addEventListener(`change`,an),nn()),rn(e)}var cn=Object.freeze({title:`Leave without saving?`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,leaveLabel:`Leave`}),X=`form[data-wui-unsaved]`,ln=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,un=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,dn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),fn=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),Z=/* @__PURE__ */ new WeakMap,pn=/* @__PURE__ */ new WeakSet,mn=e=>`${e.name}:${e.size}:${e.lastModified}`;function Q(e){let t=[];for(let n of e.elements)!n.name||n.disabled||dn.has(n.type)||(n.type===`checkbox`||n.type===`radio`?t.push([n.name,n.value,n.checked]):n.type===`file`?t.push([n.name,[...n.files||[]].map(mn)]):n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):t.push([n.name,n.value]));return JSON.stringify(t)}function hn(e){return Q(e)}function gn(e,t){let n=/* @__PURE__ */ new Map;for(let e of JSON.parse(t)){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let r=JSON.parse(Q(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())r.push(...e);return JSON.stringify(r)}function _n(e){for(let t of e.elements)if(t.name&&!t.disabled){if(t.tagName===`TEXTAREA`||t.tagName===`INPUT`&&!fn.has(t.type)){if(t.value.trim()!==``)return!0}else if(t.tagName===`INPUT`&&t.type===`file`&&t.files?.length>0)return!0}return!1}var vn=e=>({saved:e.querySelector(ln)&&_n(e)?null:Q(e),engaged:!1,discarded:!1});function yn(e){let t=Z.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Q(e)!==t.saved}var bn=(e,t)=>[...e.querySelectorAll(X)].filter(e=>e!==t&&yn(e)),xn=()=>!!window.bootstrap?.Modal;function Sn(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||cn.message;Ut(e,{title:cn.title,message:r,label:cn.leaveLabel,tone:`danger`},()=>{for(let e of t)Z.get(e).discarded=!0;n()})}function Cn(e){if(e.matches(un))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=new URL(e.getAttribute(`href`),window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)return!1;let r=window.location;return!(n.hash&&n.origin===r.origin&&n.pathname===r.pathname&&n.search===r.search)}function wn(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 Tn(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target.closest?.(`a[href]`);if(!t||!Cn(t))return;let n=bn(t.ownerDocument,null);n.length&&xn()&&(e.preventDefault(),Sn(t,n,()=>t.click()))}function En(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!wn(t,e.submitter))return;let n=bn(t.ownerDocument,t);if(n.length&&xn()){e.preventDefault();let r=e.submitter?.form===t?e.submitter:void 0;Sn(t,n,()=>t.requestSubmit(r));return}let r=Z.get(t);r&&(r.saved=Q(t),r.discarded=!1)}function Dn(e){bn(document,null).length&&(e.preventDefault(),e.returnValue=``)}function On(e){let t=e.target.closest?.(X),n=t&&Z.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Q(t)),n.engaged=!0)}function kn(e){let t=e.target.closest?.(X),n=t&&Z.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function An(e){for(let t of e.currentTarget.querySelectorAll(X)){let e=Z.get(t);e?.saved&&(e.saved=gn(t,e.saved))}}function jn(e){let t=e.detail?.handle?.el;if(t instanceof Element)for(let e of t.querySelectorAll(X))Nn(e)}function Mn(e=document){let t=e.ownerDocument||e;if(!pn.has(t)){pn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,On,!0);for(let e of[`input`,`change`])t.addEventListener(e,kn,!0);t.addEventListener(`click`,Tn),t.addEventListener(`submit`,En),t.addEventListener(`wui:modal:success`,jn),t.addEventListener(m,An),t.defaultView.addEventListener(`beforeunload`,Dn)}let n=[...e.querySelectorAll?.(X)||[]];e.matches?.(X)&&n.unshift(e);for(let e of n)Z.has(e)||Z.set(e,vn(e))}function Nn(e){if(!(e instanceof HTMLFormElement)||!e.matches(X))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);Z.set(e,{saved:Q(e),engaged:!1,discarded:!1})}var Pn=Object.freeze({question:`Discard your changes?`,discard:`Discard`,keep:`Keep editing`}),Fn=`wui:drawer:discard`,In=`wui-drawer[confirm-discard]`,Ln=`.wui-modal-shell`,Rn=`data-wui-no-discard`,zn=`.wui-drawer-discard`,Bn=`input, select, textarea`,$=/* @__PURE__ */ new WeakMap,Vn=/* @__PURE__ */ new WeakSet,Hn=/* @__PURE__ */ new WeakSet;function Un(n,r,i,a){let o=n.createElement(`button`);return o.type=`button`,o.className=e(r,`sm`),o.dataset.wui=t,o.setAttribute(i,``),o.textContent=a,o}function Wn(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,Un(e,`danger`,`data-wui-discard-confirm`,Pn.discard),Un(e,`soft`,`data-wui-discard-keep`,Pn.keep)),n}function Gn(e){let t=e.closest?.(In);if(t)return t;let n=e.closest?.(Ln);return n&&Jn(n).length?n:null}function Kn(e){return e.closest(In)??e.closest(Ln)}function qn(e,t){return t.hasAttribute(Rn)||e.hasAttribute(Rn)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function Jn(e){return e.matches(In)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>qn(t,e))}function Yn(e){let t=$.get(e);return t!=null&&hn(e)!==t}function Xn(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,e.querySelector(`.wui-drawer-panel`).append(t),Hn.add(t),t}function Zn(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),Hn.add(t),t}function Qn(e){e.querySelector(`[data-wui-discard-confirm]`).focus()}function $n(e,t,n){let r=e.querySelector(zn);if(r){Qn(r);return}let i=Wn(e.ownerDocument,t),a;e.matches(In)?(a=e.querySelector(`.wui-drawer-footer`)??Xn(e),a.prepend(i)):e.hasAttribute(`confirm-discard`)?(a=e.querySelector(`.wui-modal-footer`)??Zn(e),a.prepend(i)):(a=n.querySelector(`.modal-footer`),a?a.prepend(i):(a=n,n.append(i))),a.classList.add(`wui-drawer-discarding`),Qn(i)}function er(e){let t=e.parentElement;e.remove(),t.classList.remove(`wui-drawer-discarding`),Hn.has(t)&&t.remove()}function tr(e){for(let t of Jn(e)){let e=[...t.querySelectorAll(Bn)].find(e=>e.type!==`hidden`&&!e.disabled);if(e){e.focus();return}}}function nr(e){let t=Gn(e.target);if(t)for(let e of Jn(t))$.get(e)??$.set(e,hn(e))}function rr(e){for(let t of e.currentTarget.querySelectorAll(`form`)){let e=$.get(t);e!=null&&$.set(t,gn(t,e))}}function ir(e){let t=e.target;t instanceof HTMLFormElement&&Gn(t)&&$.set(t,hn(t))}function ar(e){let t=e.detail?.handle?.el;if(t instanceof Element)for(let e of t.querySelectorAll(`form`))$.delete(e)}function or(e){let t=e.target;t instanceof Element&&t.matches(In)&&[...Jn(t)].some(Yn)&&(e.preventDefault(),$n(t,t.getAttribute(`confirm-discard`),null))}function sr(e){let t=e.target;if(!(t instanceof Element)||!t.matches(Ln))return;let n=[...Jn(t)].find(Yn);n&&(e.preventDefault(),$n(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Pn.question,n))}function cr(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(Ln);n&&window.bootstrap?.Modal?.getInstance(n)?.hide()}function lr(e){let t=e.closest(zn),n=Kn(t);er(t);for(let e of Jn(n))$.set(e,hn(e));n.dispatchEvent(new CustomEvent(Fn,{bubbles:!0})),n.matches(In)?n.hide():window.bootstrap.Modal.getInstance(n).hide()}function ur(e){let t=e.closest(zn),n=Kn(t);er(t),tr(n)}function dr(e){let t=e.target,n=t.closest?.(`[data-wui-discard-confirm]`);if(n){lr(n);return}let r=t.closest?.(`[data-wui-discard-keep]`);if(r){ur(r);return}let i=t.closest?.(`[data-wui-dismiss]`);i&&cr(i)}function fr(e){if(e.key!==`Escape`)return;let t=e.currentTarget.querySelector(zn);if(!t)return;e.preventDefault(),e.stopPropagation();let n=Kn(t);er(t),tr(n)}function pr(e=document){let t=e.ownerDocument||e;Vn.has(t)||(Vn.add(t),t.addEventListener(`focusin`,nr),t.addEventListener(`pointerdown`,nr),t.addEventListener(`submit`,ir),t.addEventListener(m,rr),t.addEventListener(`wui:modal:success`,ar),t.addEventListener(`wui:modal:loaded`,ar),t.addEventListener(`wui-drawer-close`,or,!0),t.addEventListener(`hide.bs.modal`,sr),t.addEventListener(`click`,dr),t.addEventListener(`keydown`,fr,!0))}export{Xe as C,qe as S,Qe as T,Tt as _,cn as a,ht as b,Nn as c,At as d,kt as f,Et as g,sn as h,pr as i,J as l,Ut as m,Pn as n,hn as o,Y as p,Wn as r,Mn as s,Fn as t,Ot as u,pt as v,Je as w,$e as x,gt as y};
@@ -0,0 +1 @@
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiOrgTree-DuaBtFl9.js";e(`wui-org-tree`,t);export{t as WuiOrgTree};
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x,w as S,x as C,y as w}from"./drawerDiscard-WVoYg0lh.js";import{a as T,c as E,d as D,i as O,l as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./wuiHttp-DgnM7K2Q.js";var I=31536e3,L=/* @__PURE__ */ new WeakMap,R=e=>e>99?`99+`:String(e),z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function B(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${I}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function V(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${I}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var H=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content},U=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n};function W(e,t){let n=e.querySelector(`.wui-bell-trigger`),r=e.querySelector(`.wui-bell-count`),i=e.querySelector(`[data-wui-bell-live]`),a=e.querySelector(`[data-wui-bell-list]`),o=e.querySelector(`.wui-bell-menu`),{src:s,readAction:c}=e.dataset,l=e.dataset.label||`Notifications`,u=e.dataset.emptyText||`You are all caught up.`,d=e.dataset.loadingText??`Loading…`,f=e.dataset.noUnreadText??`No unread notifications`,p=e.dataset.unreadText??`{count} unread notifications`,m=e.dataset.bellLabel??`{label}, {count} unread`,h=Number(e.dataset.pollSeconds??60),g=N(),_=Number(e.dataset.unread)||0,v=(t,a=!0)=>{let o=Math.max(0,Number(t)||0),s=o!==_;_=o,e.dataset.unread=String(o),r&&(r.textContent=R(o),r.hidden=o===0),n?.setAttribute(`aria-label`,o===0?l:z(m,{label:l,count:R(o)})),a&&s&&i&&(i.textContent=o===0?f:z(p,{count:R(o)}))},y=()=>o?.classList.contains(`show`)??!1,b=()=>{let e=U(`wui-bell-state`,`Could not load notifications. `),t=document.createElement(`button`);t.type=`button`,t.className=`btn btn-link btn-sm`,t.dataset.wuiBellRetry=``,t.textContent=`Retry`,e.append(t),a.replaceChildren(e)},x=async t=>{t&&(a.setAttribute(`aria-busy`,`true`),a.querySelector(`.wui-bell-item`)||a.replaceChildren(U(`wui-bell-state`,d)));let n=await g.run(s);if(n.kind===`aborted`||n.kind===`stale`||n.kind===`session`)return;if(a.removeAttribute(`aria-busy`),!n.ok){t&&b();return}let r=H(n.html),i=r.querySelector(`[data-wui-unread]`),o=i?Number(i.getAttribute(`data-wui-unread`)):_;v(o),(t||y())&&(r.querySelector(`.wui-bell-item`)?a.replaceChildren(r):a.replaceChildren(U(`wui-bell-state`,u))),e.dispatchEvent(new CustomEvent(`wui:notifications:loaded`,{bubbles:!0,detail:{unread:o}}))};e.addEventListener(`show.bs.dropdown`,()=>x(!0)),e.addEventListener(`click`,async e=>{if(e.target.closest(`[data-wui-bell-retry]`)){x(!0);return}let t=e.target.closest(`[data-wui-bell-read]`);if(!t||!c)return;t.disabled=!0;let n=await k(c,{method:`POST`});t.disabled=!1,n.ok&&(v(0),x(!0))});let S=null,C=()=>{h>0&&S===null&&(S=setInterval(()=>x(y()),h*1e3))},w=()=>{S!==null&&clearInterval(S),S=null},T=()=>{document.hidden?w():(x(y()),C())};return h>0&&(document.addEventListener(`visibilitychange`,T),document.hidden||C()),t.push(()=>{w(),g.abort(),document.removeEventListener(`visibilitychange`,T)}),{setUnread:e=>v(e),refresh:()=>x(y())}}var G=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),K=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function q(e,t){let n=e.querySelector(`input.search-input`),r=e.querySelector(`.wui-topsearch-results`),i=e.querySelector(`.wui-topsearch-open`),a=e.querySelector(`[data-wui-topsearch-live]`),{src:o,param:s=`q`,resultsHref:c}=e.dataset,l=Number(e.dataset.minChars??2),u=Number(e.dataset.debounceMs??250),d=e.dataset.noResultsText??`No results`,f=e.dataset.resultsCountText??`{count} results`,p=e.dataset.resultCountText??`{count} result`,m=N(),h=null,g=-1,_=()=>[...r.querySelectorAll(`.wui-topsearch-hit`)],v=e=>{let t=_();g=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===g;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)}),g>=0?(n.setAttribute(`aria-activedescendant`,t[g].id),t[g].scrollIntoView?.({block:`nearest`})):n.removeAttribute(`aria-activedescendant`)},y=()=>{r.hidden=!0,n.setAttribute(`aria-expanded`,`false`),n.removeAttribute(`aria-activedescendant`),g=-1},b=()=>{r.hidden=!1,n.setAttribute(`aria-expanded`,`true`)},x=t=>{e.classList.toggle(`is-open`,t),i?.setAttribute(`aria-expanded`,t?`true`:`false`)},S=t=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:t}});e.dispatchEvent(n)&&window.location.assign(t)},C=async t=>{e.classList.add(`is-loading`);let n=await m.run(K(o,s,t));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(e.classList.remove(`is-loading`),n.ok){let e=H(n.html),t=e.querySelector(`[data-wui-count]`);r.replaceChildren(e),_().forEach((e,t)=>{e.id=`${r.id}-opt-${t}`});let i=t?Number(t.getAttribute(`data-wui-count`)):_().length;a&&(a.textContent=i===0?d:z(i===1?p:f,{count:i}))}else r.replaceChildren(U(`wui-topsearch-empty`,`Search is unavailable right now.`));g=-1,b()}};n.addEventListener(`input`,()=>{clearTimeout(h);let t=n.value.trim();t.length<l?(m.abort(),e.classList.remove(`is-loading`),r.replaceChildren(),y()):h=setTimeout(()=>C(t),u)}),n.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){if(r.hidden||_().length===0)return;t.preventDefault(),v(g+(t.key===`ArrowDown`?1:-1))}else if(t.key===`Enter`){let e=_();!r.hidden&&g>=0&&e[g]?(t.preventDefault(),S(e[g].getAttribute(`href`))):c&&n.value.trim()!==``&&(t.preventDefault(),S(K(c,s,n.value.trim())))}else t.key===`Escape`&&(r.hidden?e.classList.contains(`is-open`)&&(t.preventDefault(),t.stopPropagation(),x(!1),i?.focus()):(t.preventDefault(),t.stopPropagation(),y()))}),r.addEventListener(`click`,e=>{let t=e.target.closest(`.wui-topsearch-hit`);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),S(t.getAttribute(`href`)))}),i?.addEventListener(`click`,()=>{let t=!e.classList.contains(`is-open`);x(t),t&&n.focus()});let w=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||G(e.target)||(e.preventDefault(),x(!0),n.focus())},T=t=>{e.contains(t.target)||(y(),e.classList.contains(`is-open`)&&x(!1))};document.addEventListener(`keydown`,w),document.addEventListener(`pointerdown`,T),t.push(()=>{clearTimeout(h),m.abort(),document.removeEventListener(`keydown`,w),document.removeEventListener(`pointerdown`,T)})}function J(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>B(n,!!e.detail?.collapsed));let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>V(r,e.detail?.key,!!e.detail?.folded)),e.addEventListener(`click`,t=>{t.target.closest(`[data-wui-tabbar-more]`)&&e.querySelector(`[data-app-shell-menu]`)?.click()});let i=e.querySelector(`[data-wui-bell]`),a=i?W(i,t):null,o=e.querySelector(`[data-wui-topsearch]`);o&&q(o,t);let s={el:e,setUnread(e){if(!a)throw Error(`WUI.shell: this <app-shell> has no <app-shell-notifications>.`);a.setUnread(e)},refreshNotifications(){if(!a)throw Error(`WUI.shell: this <app-shell> has no <app-shell-notifications>.`);return a.refresh()},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=e.querySelector(`[data-app-shell-collapse]`);n?n.click():e.classList.toggle(`collapsed`,!!t)}};L.set(e,s);let c=n=>{if(n.target===e||n.target.contains?.(e)){for(let e of t)e();L.delete(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,c)}};return document.addEventListener(`wui:teardown`,c),s}function Y(e=document){let t=[];e instanceof Element&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...e.querySelectorAll(`[data-app-shell]`));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,J(e))}function X(e){let t=e?.closest?.(`[data-app-shell]`)??null;return t?(L.has(t)||Y(t),L.get(t)??null):null}export{f as CONFIRM_DIALOG_ID,b as CONFIRM_TONES,P as CSRF_META_NAME,A as DEFAULT_CSRF_HEADER,y as DISCARD_EVENT,m as DISCARD_TEXT,s as FLASH_STORAGE_KEY,c as FLASH_VARIANTS,M as HTTP_KINDS,g as SERVER_ACTION_TEXT,F as TOAST_ACTION_METHODS,x as TOAST_ACTION_MS,i as UNSAVED_TEXT,O as WUI_HEADERS,T as classifyStatus,C as closeRemotePane,j as configureCsrf,p as confirmAction,_ as createDiscardPrompt,N as createRequestQueue,h as formValues,l as getServerTable,X as getShell,d as initDrawerDiscard,t as initRemoteModals,u as initServerActions,r as initServerTables,Y as initShellParts,v as initUnsavedChanges,e as loadRemoteDrawer,S as loadRemoteModal,n as loadRemotePane,D as parseToastAction,E as readCsrf,o as resetUnsavedChanges,w as runToastAction,a as showResultToast,k as wuiFetch};
1
+ import{C as e,S as t,T as n,_ as r,a as i,b as a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x,w as S,x as C,y as w}from"./drawerDiscard-DRTki0-d.js";import{a as T,c as E,d as D,i as O,l as k,n as A,o as j,r as M,s as N,t as P,u as F}from"./wuiHttp-DgnM7K2Q.js";var I=31536e3,L=/* @__PURE__ */ new WeakMap,R=e=>e>99?`99+`:String(e),z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function B(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${I}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function V(e,t,n,r=document){try{let i=`${e}=`,a=r.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(i)),o=new Set(a?a.slice(i.length).split(`.`).filter(Boolean):[]);n?o.add(t):o.delete(t),r.cookie=`${e}=${[...o].join(`.`)}; Path=/; Max-Age=${I}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var H=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content},U=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n};function W(e,t){let n=e.querySelector(`.wui-bell-trigger`),r=e.querySelector(`.wui-bell-count`),i=e.querySelector(`[data-wui-bell-live]`),a=e.querySelector(`[data-wui-bell-list]`),o=e.querySelector(`.wui-bell-menu`),{src:s,readAction:c}=e.dataset,l=e.dataset.label||`Notifications`,u=e.dataset.emptyText||`You are all caught up.`,d=e.dataset.loadingText??`Loading…`,f=e.dataset.noUnreadText??`No unread notifications`,p=e.dataset.unreadText??`{count} unread notifications`,m=e.dataset.bellLabel??`{label}, {count} unread`,h=Number(e.dataset.pollSeconds??60),g=N(),_=Number(e.dataset.unread)||0,v=(t,a=!0)=>{let o=Math.max(0,Number(t)||0),s=o!==_;_=o,e.dataset.unread=String(o),r&&(r.textContent=R(o),r.hidden=o===0),n?.setAttribute(`aria-label`,o===0?l:z(m,{label:l,count:R(o)})),a&&s&&i&&(i.textContent=o===0?f:z(p,{count:R(o)}))},y=()=>o?.classList.contains(`show`)??!1,b=()=>{let e=U(`wui-bell-state`,`Could not load notifications. `),t=document.createElement(`button`);t.type=`button`,t.className=`btn btn-link btn-sm`,t.dataset.wuiBellRetry=``,t.textContent=`Retry`,e.append(t),a.replaceChildren(e)},x=async t=>{t&&(a.setAttribute(`aria-busy`,`true`),a.querySelector(`.wui-bell-item`)||a.replaceChildren(U(`wui-bell-state`,d)));let n=await g.run(s);if(n.kind===`aborted`||n.kind===`stale`||n.kind===`session`)return;if(a.removeAttribute(`aria-busy`),!n.ok){t&&b();return}let r=H(n.html),i=r.querySelector(`[data-wui-unread]`),o=i?Number(i.getAttribute(`data-wui-unread`)):_;v(o),(t||y())&&(r.querySelector(`.wui-bell-item`)?a.replaceChildren(r):a.replaceChildren(U(`wui-bell-state`,u))),e.dispatchEvent(new CustomEvent(`wui:notifications:loaded`,{bubbles:!0,detail:{unread:o}}))};e.addEventListener(`show.bs.dropdown`,()=>x(!0)),e.addEventListener(`click`,async e=>{if(e.target.closest(`[data-wui-bell-retry]`)){x(!0);return}let t=e.target.closest(`[data-wui-bell-read]`);if(!t||!c)return;t.disabled=!0;let n=await k(c,{method:`POST`});t.disabled=!1,n.ok&&(v(0),x(!0))});let S=null,C=()=>{h>0&&S===null&&(S=setInterval(()=>x(y()),h*1e3))},w=()=>{S!==null&&clearInterval(S),S=null},T=()=>{document.hidden?w():(x(y()),C())};return h>0&&(document.addEventListener(`visibilitychange`,T),document.hidden||C()),t.push(()=>{w(),g.abort(),document.removeEventListener(`visibilitychange`,T)}),{setUnread:e=>v(e),refresh:()=>x(y())}}var G=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),K=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function q(e,t){let n=e.querySelector(`input.search-input`),r=e.querySelector(`.wui-topsearch-results`),i=e.querySelector(`.wui-topsearch-open`),a=e.querySelector(`[data-wui-topsearch-live]`),{src:o,param:s=`q`,resultsHref:c}=e.dataset,l=Number(e.dataset.minChars??2),u=Number(e.dataset.debounceMs??250),d=e.dataset.noResultsText??`No results`,f=e.dataset.resultsCountText??`{count} results`,p=e.dataset.resultCountText??`{count} result`,m=N(),h=null,g=-1,_=()=>[...r.querySelectorAll(`.wui-topsearch-hit`)],v=e=>{let t=_();g=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===g;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)}),g>=0?(n.setAttribute(`aria-activedescendant`,t[g].id),t[g].scrollIntoView?.({block:`nearest`})):n.removeAttribute(`aria-activedescendant`)},y=()=>{r.hidden=!0,n.setAttribute(`aria-expanded`,`false`),n.removeAttribute(`aria-activedescendant`),g=-1},b=()=>{r.hidden=!1,n.setAttribute(`aria-expanded`,`true`)},x=t=>{e.classList.toggle(`is-open`,t),i?.setAttribute(`aria-expanded`,t?`true`:`false`)},S=t=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:t}});e.dispatchEvent(n)&&window.location.assign(t)},C=async t=>{e.classList.add(`is-loading`);let n=await m.run(K(o,s,t));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(e.classList.remove(`is-loading`),n.ok){let e=H(n.html),t=e.querySelector(`[data-wui-count]`);r.replaceChildren(e),_().forEach((e,t)=>{e.id=`${r.id}-opt-${t}`});let i=t?Number(t.getAttribute(`data-wui-count`)):_().length;a&&(a.textContent=i===0?d:z(i===1?p:f,{count:i}))}else r.replaceChildren(U(`wui-topsearch-empty`,`Search is unavailable right now.`));g=-1,b()}};n.addEventListener(`input`,()=>{clearTimeout(h);let t=n.value.trim();t.length<l?(m.abort(),e.classList.remove(`is-loading`),r.replaceChildren(),y()):h=setTimeout(()=>C(t),u)}),n.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){if(r.hidden||_().length===0)return;t.preventDefault(),v(g+(t.key===`ArrowDown`?1:-1))}else if(t.key===`Enter`){let e=_();!r.hidden&&g>=0&&e[g]?(t.preventDefault(),S(e[g].getAttribute(`href`))):c&&n.value.trim()!==``&&(t.preventDefault(),S(K(c,s,n.value.trim())))}else t.key===`Escape`&&(r.hidden?e.classList.contains(`is-open`)&&(t.preventDefault(),t.stopPropagation(),x(!1),i?.focus()):(t.preventDefault(),t.stopPropagation(),y()))}),r.addEventListener(`click`,e=>{let t=e.target.closest(`.wui-topsearch-hit`);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),S(t.getAttribute(`href`)))}),i?.addEventListener(`click`,()=>{let t=!e.classList.contains(`is-open`);x(t),t&&n.focus()});let w=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||G(e.target)||(e.preventDefault(),x(!0),n.focus())},T=t=>{e.contains(t.target)||(y(),e.classList.contains(`is-open`)&&x(!1))};document.addEventListener(`keydown`,w),document.addEventListener(`pointerdown`,T),t.push(()=>{clearTimeout(h),m.abort(),document.removeEventListener(`keydown`,w),document.removeEventListener(`pointerdown`,T)})}function J(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>B(n,!!e.detail?.collapsed));let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>V(r,e.detail?.key,!!e.detail?.folded)),e.addEventListener(`click`,t=>{t.target.closest(`[data-wui-tabbar-more]`)&&e.querySelector(`[data-app-shell-menu]`)?.click()});let i=e.querySelector(`[data-wui-bell]`),a=i?W(i,t):null,o=e.querySelector(`[data-wui-topsearch]`);o&&q(o,t);let s={el:e,setUnread(e){if(!a)throw Error(`WUI.shell: this <app-shell> has no <app-shell-notifications>.`);a.setUnread(e)},refreshNotifications(){if(!a)throw Error(`WUI.shell: this <app-shell> has no <app-shell-notifications>.`);return a.refresh()},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=e.querySelector(`[data-app-shell-collapse]`);n?n.click():e.classList.toggle(`collapsed`,!!t)}};L.set(e,s);let c=n=>{if(n.target===e||n.target.contains?.(e)){for(let e of t)e();L.delete(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,c)}};return document.addEventListener(`wui:teardown`,c),s}function Y(e=document){let t=[];e instanceof Element&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...e.querySelectorAll(`[data-app-shell]`));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,J(e))}function X(e){let t=e?.closest?.(`[data-app-shell]`)??null;return t?(L.has(t)||Y(t),L.get(t)??null):null}export{f as CONFIRM_DIALOG_ID,b as CONFIRM_TONES,P as CSRF_META_NAME,A as DEFAULT_CSRF_HEADER,y as DISCARD_EVENT,m as DISCARD_TEXT,s as FLASH_STORAGE_KEY,c as FLASH_VARIANTS,M as HTTP_KINDS,g as SERVER_ACTION_TEXT,F as TOAST_ACTION_METHODS,x as TOAST_ACTION_MS,i as UNSAVED_TEXT,O as WUI_HEADERS,T as classifyStatus,C as closeRemotePane,j as configureCsrf,p as confirmAction,_ as createDiscardPrompt,N as createRequestQueue,h as formValues,l as getServerTable,X as getShell,d as initDrawerDiscard,t as initRemoteModals,u as initServerActions,r as initServerTables,Y as initShellParts,v as initUnsavedChanges,e as loadRemoteDrawer,S as loadRemoteModal,n as loadRemotePane,D as parseToastAction,E as readCsrf,o as resetUnsavedChanges,w as runToastAction,a as showResultToast,k as wuiFetch};
@@ -1,4 +1,4 @@
1
- (function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.135.0`)throw Error(`[webority-ui] autocomplete expects ui-elements 0.135.0 but the page loaded `+l+`.`);var u=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},d=(e,t=`wui-opt-avatar`)=>{let n=u(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${(0,r.escapeHtml)(e.initials??``)}</span>${n?`<img class="avatar-img" src="${f(n)}" alt="" />`:``}</span>`},f=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),p=!1,m=!1;function h(){m||typeof document>`u`||(m=!0,document.addEventListener(`keydown`,e=>{p=e.key===`Tab`},!0),document.addEventListener(`keyup`,()=>{p=!1},!0))}function g(){return p}var _=class extends i.ElementBase{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`readonly`,`loading`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`,`open`,`value-avatar`,`value-initials`]}constructor(){super(),this._value=``,this._label=``,this._valueAvatar=``,this._valueInitials=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered)this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();else if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){e===`value`?this.value=n:e===`value-avatar`?(this._valueAvatar=n??``,this._syncValueAvatar()):e===`value-initials`?(this._valueInitials=n??``,this._syncValueAvatar()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._syncPinned?.():this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),(0,o.syncFormMirror)(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?(0,r.optionText)(t):``,this._value||(this._valueAvatar=``,this._valueInitials=``),this._syncInput(),this._syncValueAvatar(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=(0,r.optionText)(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),(0,a.syncFieldState)(this,this._refs().control),this._renderOptions()}get loading(){return this._loading||this.hasAttribute(`loading`)}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>(0,r.optionText)(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[r.TRUSTED_HTML]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r;let i=(0,a.isReadOnly)(this)||this.hasAttribute(`loading`);this.innerHTML=`
1
+ (function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=globalThis.WeborityUiElementsInternal?.version;if(l!==`0.136.0`)throw Error(`[webority-ui] autocomplete expects ui-elements 0.136.0 but the page loaded `+l+`.`);var u=e=>{let t=String(e??``).trim();return/^(https?:)?\/\//i.test(t)||/^\/(?!\/)/.test(t)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t)?t:``},d=(e,t=`wui-opt-avatar`)=>{let n=u(e.avatar);return!n&&!e.initials?``:`<span class="avatar ${t}" aria-hidden="true"><span class="avatar-face">${(0,r.escapeHtml)(e.initials??``)}</span>${n?`<img class="avatar-img" src="${f(n)}" alt="" />`:``}</span>`},f=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),p=!1,m=!1;function h(){m||typeof document>`u`||(m=!0,document.addEventListener(`keydown`,e=>{p=e.key===`Tab`},!0),document.addEventListener(`keyup`,()=>{p=!1},!0))}function g(){return p}var _=class extends i.ElementBase{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`value`,`placeholder`,`disabled`,`readonly`,`loading`,`min-chars`,`debounce`,`remote`,`size`,`aria-label`,`allow-custom`,`aria-invalid`,`open`,`value-avatar`,`value-initials`]}constructor(){super(),this._value=``,this._label=``,this._valueAvatar=``,this._valueInitials=``,this._optionsProp=null,this._loading=!1,this._active=-1,this._timer=null,this._reqSeq=0,this._pendingSearch=null,this._typeahead=``,this._typeaheadTimer=null;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(!this._rendered)this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render();else if(this._bindGlobal?.(),this._pendingSearch){let{query:e,seq:t}=this._pendingSearch;clearTimeout(this._timer),this._timer=setTimeout(()=>this._fireSearch(e,t),this._debounceMs)}}formResetCallback(){this.value=this._defaultValue||``}attributeChangedCallback(e,t,n){e===`value`?this.value=n:e===`value-avatar`?(this._valueAvatar=n??``,this._syncValueAvatar()):e===`value-initials`?(this._valueInitials=n??``,this._syncValueAvatar()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._syncPinned?.():this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get value(){return this._value}set value(e){this._value=e==null?``:String(e),(0,o.syncFormMirror)(this,this._value);let t=this._readOptions().find(e=>String(e.value)===this._value);this._label=t?(0,r.optionText)(t):``,this._value||(this._valueAvatar=``,this._valueInitials=``),this._syncInput(),this._syncValueAvatar(),this._renderOptions(``)}set options(e){this._optionsProp=Array.isArray(e)?e:[];let t=this._readOptions().find(e=>String(e.value)===this._value);t&&(this._label=(0,r.optionText)(t)),this._renderOptions(),this._syncInput()}get options(){return this._readOptions()}set loading(e){this._loading=!!e,this._renderLoading(),(0,a.syncFieldState)(this,this._refs().control),this._renderOptions()}get loading(){return this._loading||this.hasAttribute(`loading`)}get _remote(){return this.hasAttribute(`remote`)}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_matchesKnownOption(e){let t=e.toLowerCase();return this._readOptions().some(e=>(0,r.optionText)(e).toLowerCase()===t||String(e.value??``).toLowerCase()===t)}get _minChars(){let e=+!!this._remote,t=this.getAttribute(`min-chars`);if(t==null||t.trim()===``)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}get _debounceMs(){let e=this.getAttribute(`debounce`);if(e==null||e===``)return 250;let t=Number(e);return Number.isFinite(t)&&t>=0?t:250}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>({value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[r.TRUSTED_HTML]:!0,selected:e.hasAttribute(`selected`)})))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}render(){this._snapshotDeclared();let e=this.getAttribute(`placeholder`)||`Search…`,t=this.getAttribute(`size`),n=t===`sm`?` search-select-sm`:t===`lg`?` search-select-lg`:``;this.id||=`wui-autocomplete-${Math.random().toString(36).slice(2,9)}`;let r=`${this.id}-listbox`;this._listboxId=r;let i=(0,a.isReadOnly)(this)||this.hasAttribute(`loading`);this.innerHTML=`
2
2
  <div class="search-select${n}">
3
3
  <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${v(r)}" aria-label="${v(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}>
4
4
  <input class="search-select-input search-select-ac-input" placeholder="${v(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``}${i?` readonly`:``} />
@@ -1 +1 @@
1
- (function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.135.0`)throw Error(`[webority-ui] carousel expects ui-elements 0.135.0 but the page loaded `+r+`.`);var i=Object.freeze({slide:(e,t)=>`${e} of ${t}`,status:(e,t,n)=>e===t?`Slide ${e} of ${n}`:`Slides ${e} to ${t} of ${n}`,dot:`Go to slide`,pause:`Pause`,play:`Play`}),a=120,o=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),a)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:!!e.relatedTarget&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){if(this._track=this.querySelector(`.wui-carousel-track`),!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let e=this.getAttribute(`data-wui-style`);if(e){for(let t of e.split(`;`)){let e=t.indexOf(`:`);e>0&&this.style.setProperty(t.slice(0,e).trim(),t.slice(e+1).trim())}this.removeAttribute(`data-wui-style`)}this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,clearTimeout(this._timer),clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return e>0?e:0}_slides(){return Array.from(this._track.children).filter(e=>e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=e.target.closest?.(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`);t&&this.contains(t)&&!this._track.contains(t)&&(t.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):t.getAttribute(`aria-disabled`)===`true`?e.preventDefault():t.classList.contains(`wui-carousel-prev`)?this.prev():t.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(t.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[e.key];t&&(e.preventDefault(),t())}_perViewNow(){let e=typeof window<`u`?window.getComputedStyle(this._track).getPropertyValue(`--wui-carousel-view`):``,t=Number.parseInt(e,10);return t>=1?t:1}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((t,n)=>{let r=i.slide(n+1,e.length);t.getAttribute(`aria-label`)!==r&&t.setAttribute(`aria-label`,r)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let t=Math.max(1,Math.ceil(e/this._perView)),n=this.querySelector(`.wui-carousel-dots`);if(n&&n.children.length!==t){let e=this.getAttribute(`dot-label`)||i.dot;n.replaceChildren(...Array.from({length:t},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=t,this._page=Math.min(this._page,t-1),this.toggleAttribute(`data-single`,t<=1),this._render(!1),this._sync()}_settle(){let e=this._track,t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._slides()[this._start(this._page)];if(t){let e=this._motion?.matches?`auto`:`smooth`;typeof this._track.scrollTo==`function`?this._track.scrollTo({left:t.offsetLeft,behavior:e}):this._track.scrollLeft=t.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`);this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!t&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!t&&this._page===this._pages-1));let n=this._slides().length,r=this._start(this._page)+1,a=Math.min(n,r+this._perView-1),o=i.status(r,a,n);if(o===this._status||(this._status=o,!e))return;let s=this.querySelector(`[data-wui-status]`);s&&!this._playing()&&(s.textContent=o),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||i.play:this.getAttribute(`pause-label`)||i.pause,r=t.querySelector(`.wui-carousel-pause-text`);r&&r.textContent!==n&&(r.textContent=n),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};(0,t.defineElement)(`wui-carousel`,o),e.WuiCarousel=o})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
1
+ (function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.136.0`)throw Error(`[webority-ui] carousel expects ui-elements 0.136.0 but the page loaded `+r+`.`);var i=Object.freeze({slide:(e,t)=>`${e} of ${t}`,status:(e,t,n)=>e===t?`Slide ${e} of ${n}`:`Slides ${e} to ${t} of ${n}`,dot:`Go to slide`,pause:`Pause`,play:`Play`}),a=120,o=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),this._page=0,this._pages=1,this._perView=1,this._paused=!1,this._hover=!1,this._focus=!1,this._timer=null,this._settleTimer=null,this._status=``,this._ready=!1,this._motion=null,this._mutations=null,this._resizer=null,this._doc=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),a)},this._onEnter=()=>this._hold({hover:!0}),this._onLeave=()=>this._hold({hover:!1}),this._onFocusIn=()=>this._hold({focus:!0}),this._onFocusOut=e=>this._hold({focus:!!e.relatedTarget&&this.contains(e.relatedTarget)}),this._onVisibility=()=>this._sync(),this._onMotion=()=>this._sync(),this._tick=()=>{this._timer=null,this._go(this._page+1<this._pages?this._page+1:0)}}connectedCallback(){if(this._track=this.querySelector(`.wui-carousel-track`),!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let e=this.getAttribute(`data-wui-style`);if(e){for(let t of e.split(`;`)){let e=t.indexOf(`:`);e>0&&this.style.setProperty(t.slice(0,e).trim(),t.slice(e+1).trim())}this.removeAttribute(`data-wui-style`)}this._motion=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-reduced-motion: reduce)`):null,this._motion?.addEventListener(`change`,this._onMotion),this.addEventListener(`click`,this._onClick),this.addEventListener(`mouseenter`,this._onEnter),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._track.addEventListener(`keydown`,this._onKeyDown),this._track.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._doc.addEventListener(`visibilitychange`,this._onVisibility),typeof MutationObserver<`u`&&(this._mutations=new MutationObserver(()=>this._refresh()),this._mutations.observe(this._track,{childList:!0})),typeof ResizeObserver<`u`&&(this._resizer=new ResizeObserver(()=>this._refresh()),this._resizer.observe(this._track)),this._ready=!0,this._refresh()}disconnectedCallback(){this._ready=!1,clearTimeout(this._timer),clearTimeout(this._settleTimer),this._timer=null,this._motion?.removeEventListener(`change`,this._onMotion),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mouseenter`,this._onEnter),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._track?.removeEventListener(`keydown`,this._onKeyDown),this._track?.removeEventListener(`scroll`,this._onScroll),this._doc?.removeEventListener(`visibilitychange`,this._onVisibility),this._mutations?.disconnect(),this._resizer?.disconnect(),this._mutations=this._resizer=this._motion=this._doc=null}attributeChangedCallback(){this._ready&&this._sync()}get paused(){return this._paused}set paused(e){this._paused=!!e,this._ready&&this._sync()}next(){this._page+1<this._pages?this._go(this._page+1):this.hasAttribute(`loop`)&&this._go(0)}prev(){this._page>0?this._go(this._page-1):this.hasAttribute(`loop`)&&this._go(this._pages-1)}goTo(e){this._go(Number(e))}_interval(){let e=Number.parseInt(this.getAttribute(`autoplay`)??``,10);return e>0?e:0}_slides(){return Array.from(this._track.children).filter(e=>e.classList.contains(`wui-carousel-slide`))}_playing(){return this._interval()>0&&this._pages>1&&!this._paused&&!this._hover&&!this._focus&&!this._motion?.matches&&!this._doc?.hidden}_hold({hover:e=this._hover,focus:t=this._focus}){this._hover=e,this._focus=t,this._sync()}_click(e){let t=e.target.closest?.(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`);t&&this.contains(t)&&!this._track.contains(t)&&(t.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):t.getAttribute(`aria-disabled`)===`true`?e.preventDefault():t.classList.contains(`wui-carousel-prev`)?this.prev():t.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(t.dataset.page)))}_key(e){if(e.target!==this._track||e.altKey||e.ctrlKey||e.metaKey)return;let t={ArrowRight:()=>this.next(),ArrowLeft:()=>this.prev(),Home:()=>this._go(0),End:()=>this._go(this._pages-1)}[e.key];t&&(e.preventDefault(),t())}_perViewNow(){let e=typeof window<`u`?window.getComputedStyle(this._track).getPropertyValue(`--wui-carousel-view`):``,t=Number.parseInt(e,10);return t>=1?t:1}_start(e){return Math.min(e*this._perView,Math.max(0,this._slides().length-this._perView))}_label(){let e=this._slides();return e.forEach((t,n)=>{let r=i.slide(n+1,e.length);t.getAttribute(`aria-label`)!==r&&t.setAttribute(`aria-label`,r)}),e.length}_refresh(){let e=this._label();this._perView=this._perViewNow();let t=Math.max(1,Math.ceil(e/this._perView)),n=this.querySelector(`.wui-carousel-dots`);if(n&&n.children.length!==t){let e=this.getAttribute(`dot-label`)||i.dot;n.replaceChildren(...Array.from({length:t},(t,n)=>{let r=this.ownerDocument.createElement(`button`);return r.type=`button`,r.className=`wui-carousel-dot`,r.dataset.page=String(n),r.setAttribute(`aria-label`,`${e} ${this._start(n)+1}`),r}))}this._pages=t,this._page=Math.min(this._page,t-1),this.toggleAttribute(`data-single`,t<=1),this._render(!1),this._sync()}_settle(){let e=this._track,t=this._slides();if(!t.length)return;let n;if(e.scrollWidth>e.clientWidth&&e.scrollLeft+e.clientWidth>=e.scrollWidth-2)n=this._pages-1;else{let r=0,i=1/0;t.forEach((t,n)=>{let a=Math.abs(t.offsetLeft-e.scrollLeft);a<i&&(i=a,r=n)}),n=Math.min(this._pages-1,Math.round(r/this._perView))}n!==this._page&&(this._page=n,this._render(!0),this._sync())}_go(e){if(!Number.isInteger(e))return;this._page=Math.max(0,Math.min(this._pages-1,e));let t=this._slides()[this._start(this._page)];if(t){let e=this._motion?.matches?`auto`:`smooth`;typeof this._track.scrollTo==`function`?this._track.scrollTo({left:t.offsetLeft,behavior:e}):this._track.scrollLeft=t.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))Number(e.dataset.page)===this._page?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`);this.querySelector(`.wui-carousel-prev`)?.setAttribute(`aria-disabled`,String(!t&&this._page===0)),this.querySelector(`.wui-carousel-next`)?.setAttribute(`aria-disabled`,String(!t&&this._page===this._pages-1));let n=this._slides().length,r=this._start(this._page)+1,a=Math.min(n,r+this._perView-1),o=i.status(r,a,n);if(o===this._status||(this._status=o,!e))return;let s=this.querySelector(`[data-wui-status]`);s&&!this._playing()&&(s.textContent=o),this.dispatchEvent(new CustomEvent(`wui:carousel:change`,{bubbles:!0,detail:{page:this._page,pages:this._pages}}))}_sync(){clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||i.play:this.getAttribute(`pause-label`)||i.pause,r=t.querySelector(`.wui-carousel-pause-text`);r&&r.textContent!==n&&(r.textContent=n),this.toggleAttribute(`data-paused`,this._paused)}this._playing()&&(this._timer=setTimeout(this._tick,e))}};(0,t.defineElement)(`wui-carousel`,o),e.WuiCarousel=o})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.135.0`)throw Error(`[webority-ui] code-block expects ui-elements 0.135.0 but the page loaded `+o+`.`);var s=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),c=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),l=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),u=`(?![\\s\\S])`,d=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${u})`).source,f=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,l([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],p=[[`comment`,RegExp(`//[^\\n]*|${d}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,l(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,l([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`//[^\\n]*|${d}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,l(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,l([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`--[^\\n]*|${d}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,l(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,l([`true`,`false`])],[`type`,l([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],g=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,l([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,l(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],_=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],v=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${u})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],y={json:f,js:p,cs:m,sql:h,bash:g,http:_,css:[[`comment`,new RegExp(d)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:v,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},b=new Map;function x(e){let t=b.get(e);if(!t){let n=y[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},b.set(e,t)}return t}function S(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function C(e,t,n=[]){let{re:r,types:i}=x(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;S(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?C(`htmlTag`,o[0],n):S(n,i[r],o[0]),a=o.index+o[0].length}return S(n,`plain`,t.slice(a)),n}function w(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return C(`http`,e);let n=C(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?C(`json`,r,n):i===`<`?C(`html`,r,n):(S(n,`plain`,r),n)}function T(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?w(n):!Object.hasOwn(y,t)||t===`htmlTag`?[[`plain`,n]]:C(t,n)}function E(e,t){let n=[[]];for(let[r,i]of T(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var D=class extends i.ElementBase{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._title=null,this._view=null,this._codeEl=null,this._copyIcon=null,this._copyText=null,this._copied=!1,this._observer=null,this._timer=0,this._cancelFrame=null}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=s.includes(t)?t:`text`,r=this.getAttribute(`label`)||``,i=E(this._code(),n);this._title.textContent=r||c[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>O(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=e.createElement(`div`);n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,this._codeEl=e.createElement(`code`),r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this._view=n,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`,this._title=e.createElement(`span`),this._title.className=`wui-code-title`;let i=e.createElement(`button`);return i.type=`button`,i.className=`${(0,n.buttonClass)(`ghost`,`sm`)} wui-code-copy`,i.dataset.wui=n.APP_BUTTON_MARKER,i.setAttribute(`aria-live`,`polite`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`),this._setCopied(!1),i.append(this._copyIcon,this._copyText),i.addEventListener(`click`,async()=>{await(0,r.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>this._setCopied(!1),r.COPY_FEEDBACK_MS))}),t.append(this._title,i),t}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=(0,a.glyphSvg)(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function O(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}(0,t.defineElement)(`wui-code-block`,D),e.WuiCodeBlock=D})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs);
1
+ (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.136.0`)throw Error(`[webority-ui] code-block expects ui-elements 0.136.0 but the page loaded `+o+`.`);var s=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),c=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),l=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),u=`(?![\\s\\S])`,d=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${u})`).source,f=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,l([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],p=[[`comment`,RegExp(`//[^\\n]*|${d}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,l(`async.await.break.case.catch.class.const.continue.default.delete.do.else.export.extends.finally.for.from.function.if.import.in.instanceof.let.new.of.return.static.super.switch.this.throw.try.typeof.var.void.while.yield`.split(`.`))],[`literal`,l([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`//[^\\n]*|${d}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,l(`abstract.as.async.await.base.bool.break.byte.case.catch.char.checked.class.const.continue.decimal.default.delegate.do.double.else.enum.event.explicit.extern.finally.fixed.float.for.foreach.get.goto.if.implicit.in.init.int.interface.internal.is.lock.long.namespace.new.object.operator.out.override.params.private.protected.public.readonly.record.ref.required.return.sbyte.sealed.set.short.sizeof.static.string.struct.switch.this.throw.try.typeof.uint.ulong.unchecked.unsafe.ushort.using.var.virtual.void.volatile.when.while.with`.split(`.`))],[`literal`,l([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`--[^\\n]*|${d}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,l(`add.all.alter.and.as.asc.begin.between.by.case.check.column.commit.constraint.create.cross.database.declare.default.delete.desc.distinct.drop.else.end.exec.execute.exists.foreign.from.full.function.group.having.if.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.over.partition.primary.procedure.references.return.returns.right.rollback.select.set.table.then.top.transaction.union.unique.update.values.view.when.where.while.with`.split(`.`))],[`literal`,l([`true`,`false`])],[`type`,l([`bigint`,`bit`,`char`,`date`,`datetime`,`datetime2`,`decimal`,`float`,`int`,`money`,`nchar`,`numeric`,`nvarchar`,`real`,`smallint`,`text`,`time`,`tinyint`,`uniqueidentifier`,`varchar`])],[`function`,/\b[A-Za-z_]\w*(?=\s*\()/],[`punct`,/[(),;]/]],g=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,l([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,l(`awk.az.cat.cd.chmod.chown.cp.curl.docker.dotnet.echo.gcloud.git.grep.kubectl.ls.mkdir.mv.npm.npx.pnpm.rm.sed.source.sudo.wget`.split(`.`))],[`punct`,/[|&;<>(){}[\]]+/]],_=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],v=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${u})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],y={json:f,js:p,cs:m,sql:h,bash:g,http:_,css:[[`comment`,new RegExp(d)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:v,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},b=new Map;function x(e){let t=b.get(e);if(!t){let n=y[e],r=e===`sql`?`gi`:`g`,i=n.map(([,e])=>`(${e.source})`).join(`|`);t={re:new RegExp(i,`${r}m`),types:n.map(([e])=>e)},b.set(e,t)}return t}function S(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function C(e,t,n=[]){let{re:r,types:i}=x(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;S(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?C(`htmlTag`,o[0],n):S(n,i[r],o[0]),a=o.index+o[0].length}return S(n,`plain`,t.slice(a)),n}function w(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return C(`http`,e);let n=C(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?C(`json`,r,n):i===`<`?C(`html`,r,n):(S(n,`plain`,r),n)}function T(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?w(n):!Object.hasOwn(y,t)||t===`htmlTag`?[[`plain`,n]]:C(t,n)}function E(e,t){let n=[[]];for(let[r,i]of T(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var D=class extends i.ElementBase{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._title=null,this._view=null,this._codeEl=null,this._copyIcon=null,this._copyText=null,this._copied=!1,this._observer=null,this._timer=0,this._cancelFrame=null}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=s.includes(t)?t:`text`,r=this.getAttribute(`label`)||``,i=E(this._code(),n);this._title.textContent=r||c[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>O(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=e.createElement(`div`);n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,this._codeEl=e.createElement(`code`),r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this._view=n,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`,this._title=e.createElement(`span`),this._title.className=`wui-code-title`;let i=e.createElement(`button`);return i.type=`button`,i.className=`${(0,n.buttonClass)(`ghost`,`sm`)} wui-code-copy`,i.dataset.wui=n.APP_BUTTON_MARKER,i.setAttribute(`aria-live`,`polite`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`),this._setCopied(!1),i.append(this._copyIcon,this._copyText),i.addEventListener(`click`,async()=>{await(0,r.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>this._setCopied(!1),r.COPY_FEEDBACK_MS))}),t.append(this._title,i),t}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=(0,a.glyphSvg)(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function O(e,t){let n=e.createElement(`span`);n.className=`wui-code-line`;for(let[r,i]of t){if(r===`plain`){n.append(i);continue}let t=e.createElement(`span`);t.className=`wui-code-t-${r}`,t.textContent=i,n.append(t)}return n}(0,t.defineElement)(`wui-code-block`,D),e.WuiCodeBlock=D})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs);
@@ -1,2 +1,2 @@
1
- (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.135.0`)throw Error(`[webority-ui] command-palette expects ui-elements 0.135.0 but the page loaded `+a+`.`);var o=`[role="option"]`,s=`No results`,c=`All`,l=`Recent`,u=5,d=20,f=`.wui-cmd-back, [data-depth]`,p=0,m=class extends n.ElementBase{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++p}`,this._onModalHidden=()=>this._reset(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=e.target?.closest?.(f);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=this._optionFrom(e.target);n&&this._select(n)},this._onMouseDown=e=>{let t=e.target?.closest?.(f);(t&&this.contains(t)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`.modal`),this._modal?.addEventListener(`hidden.bs.modal`,this._onModalHidden),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??s}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
1
+ (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.136.0`)throw Error(`[webority-ui] command-palette expects ui-elements 0.136.0 but the page loaded `+a+`.`);var o=`[role="option"]`,s=`No results`,c=`All`,l=`Recent`,u=5,d=20,f=`.wui-cmd-back, [data-depth]`,p=0,m=class extends n.ElementBase{static get observedAttributes(){return[`filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),this._path=[],this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++p}`,this._onModalHidden=()=>this._reset(),this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=e.target?.closest?.(f);if(t&&this.contains(t)){let e=t.matches(`.wui-cmd-back`)?this._path.length-1:Number(t.dataset.depth);this._goTo(this._path.slice(0,e));return}let n=this._optionFrom(e.target);n&&this._select(n)},this._onMouseDown=e=>{let t=e.target?.closest?.(f);(t&&this.contains(t)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._applyFilter(),this.refresh())}}connectedCallback(){this._teardown(),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`mousedown`,this._onMouseDown),this.addEventListener(`mousemove`,this._onMouseMove),this.addEventListener(`input`,this._onInput),this._modal=this.closest(`.modal`),this._modal?.addEventListener(`hidden.bs.modal`,this._onModalHidden),this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e){this.isConnected&&(e===`path`&&this._readPath(),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh())}get filter(){return this.hasAttribute(`filter`)}set filter(e){this.toggleAttribute(`filter`,!!e)}get highlight(){return this.getAttribute(`highlight`)!==`false`}set highlight(e){this.setAttribute(`highlight`,e?`true`:`false`)}get emptyText(){return this.getAttribute(`empty-text`)??s}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs();let e=this._input(),t=e?e.value:``,n=t!==this._lastQuery;this._lastQuery=t;let r=this._selectableOptions(),i=r.map(e=>e.id).join(`
2
2
  `),a=i!==this._lastIds;this._lastIds=i;let o=!n&&(this._userChose||!a)?r.find(e=>e.id===this._activeId):null;o||(this._userChose=!1),this._setActive(o??r[0]??null,n)}_input(){return this.querySelector(`[role="combobox"]`)}_optionFrom(e,t=!1){let n=e?.closest?.(o);return n&&this.contains(n)&&!this._isHidden(n)&&(t||!this._isDisabled(n))?n:null}_isDisabled(e){return e.getAttribute(`aria-disabled`)===`true`}_isHidden(e){return e.hidden||!!e.closest(`[role="group"]`)?.hidden}_selectableOptions(){return[...this.querySelectorAll(o)].filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of this.querySelectorAll(o))t.setAttribute(`aria-selected`,t===e?`true`:`false`);let n=this._input();n&&(e?n.setAttribute(`aria-activedescendant`,e.id):n.removeAttribute(`aria-activedescendant`)),e&&t&&e.scrollIntoView({block:`nearest`})}_move(e){let t=this._selectableOptions();if(!t.length)return;let n=t.findIndex(e=>e.id===this._activeId),r=n<0?e>0?0:t.length-1:(n+e+t.length)%t.length;this._userChose=!0,this._setActive(t[r],!0)}_handleKeyDown(e){if(e.target===this._input()){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!e.target.value)e.preventDefault(),this._goTo(this._path.slice(0,-1));else if(e.key===`Enter`&&!e.isComposing){let t=this._selectableOptions().find(e=>e.id===this._activeId);if(!t)return;e.preventDefault(),this._select(t)}}}_select(e){this._remember(e),this.dispatchEvent(new CustomEvent(`wui-command-palette:select`,{bubbles:!0,cancelable:!0,detail:{key:e.dataset.key??null,groupKey:e.dataset.groupKey??null,id:e.id}}))&&(e.dataset.opens?this._open(e.dataset.opens):e.dataset.href&&this._navigate(e.dataset.href))}_open(e){let t=[...this.querySelectorAll(`.wui-cmd-page`)].find(t=>t.dataset.page===e);this._goTo([...this._path,{key:e,label:t?.dataset.label??e}])}_goTo(e){this._input()?.focus(),this.dispatchEvent(new CustomEvent(`wui-command-palette:navigate`,{bubbles:!0,cancelable:!0,detail:{path:e}}))&&(this._path=e,this._restart())}_restart(){let e=this._input();e&&(e.value=``),this.hasAttribute(`filter`)&&this._applyFilter(),this.refresh()}_reset(){this.hasAttribute(`path`)||(this._path=[],this._restart())}_readPath(){let e=this.getAttribute(`path`);if(e==null)return;let t=JSON.parse(e);this._path=Array.isArray(t)?t.filter(e=>e&&typeof e.key==`string`&&typeof e.label==`string`):[]}_renderCrumbs(){let e=this.querySelector(`.wui-cmd-crumbs`);if(!e)return;let t=this.getAttribute(`root-label`)??c,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=e.querySelector(`.wui-cmd-trail`);if(!r)return;let i=[t,...this._path.map(e=>e.label)];r.replaceChildren(...i.map((e,t)=>{let n=document.createElement(`li`),r=t===i.length-1,a=document.createElement(r?`span`:`button`);return a.className=`wui-cmd-crumb`,a.textContent=e,r?a.setAttribute(`aria-current`,`page`):(a.type=`button`,a.dataset.depth=String(t)),n.append(a),n}))}_recentsHost(){return this.querySelector(`.wui-cmd-recents`)}_realOptions(){let e=this._recentsHost();return[...this.querySelectorAll(o)].filter(t=>!e?.contains(t))}_recentEntries(){let e=this.getAttribute(`recents-key`);if(!e)return[];let t;try{t=JSON.parse(globalThis.localStorage?.getItem(e)??`[]`)}catch{return[]}return Array.isArray(t)?t.filter(e=>e&&typeof e.g==`string`&&typeof e.k==`string`):[]}_recentsLimit(){let e=Number.parseInt(this.getAttribute(`recents-limit`)??``,10);return Number.isFinite(e)&&e>0?Math.min(e,d):u}_remember(e){let t=this.getAttribute(`recents-key`),{groupKey:n,key:r,opens:i}=e.dataset;if(!t||i||n==null||r==null)return;let a=[{g:n,k:r},...this._recentEntries().filter(e=>e.g!==n||e.k!==r)];try{globalThis.localStorage?.setItem(t,JSON.stringify(a.slice(0,this._recentsLimit())))}catch{}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries():[],r=this._realOptions(),i=[];for(let e of n){let t=r.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&i.push(t),i.length>=this._recentsLimit())break}if(!i.length){e.firstChild&&e.replaceChildren();return}let a=`${this._recentsId}-label`,o=document.createElement(`div`);o.className=`wui-cmd-group`,o.setAttribute(`role`,`group`),o.setAttribute(`aria-labelledby`,a);let s=document.createElement(`div`);s.className=`wui-cmd-group-label`,s.setAttribute(`role`,`presentation`),s.id=a,s.textContent=this.getAttribute(`recents-label`)??l,o.append(s);for(let e of i){let t=e.cloneNode(!0);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),o.append(t)}e.replaceChildren(o)}_inScope(e,t){return!t||(e.closest(`.wui-cmd-page`)?.dataset.page??null)===(this._path.at(-1)?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),t=(e?e.value:``).trim(),n=t.toLowerCase(),a=this.highlight,s=[...this.querySelectorAll(`.wui-cmd-page`)],c=s.length>0,l=this._path.at(-1)?.key??null;for(let e of s)e.hidden=e.dataset.page!==l;let u=0;for(let e of this._realOptions()){let o=e.querySelector(`.wui-cmd-item-label`),s=e.dataset.label??o?.textContent??``,l=this._inScope(e,c)&&(!n||s.toLowerCase().includes(n));e.hidden=!l,l&&u++,o&&(o.innerHTML=(0,i.matchSegments)(s,a?t:``).map(e=>e.match?`<mark class="wui-cmd-mark">${(0,r.escapeHtml)(e.text)}</mark>`:(0,r.escapeHtml)(e.text)).join(``))}let d=this._recentsHost();for(let e of this.querySelectorAll(`[role="group"]`))d?.contains(e)||(e.hidden=![...e.querySelectorAll(o)].some(e=>!e.hidden));let f=this.querySelector(`[role="listbox"]`);f&&(f.hidden=u===0);let p=this.querySelector(`.wui-cmd-empty`);p&&(p.textContent=n&&u===0?this.emptyText:``)}_teardown(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`mousedown`,this._onMouseDown),this.removeEventListener(`mousemove`,this._onMouseMove),this.removeEventListener(`input`,this._onInput),this._modal?.removeEventListener(`hidden.bs.modal`,this._onModalHidden),this._modal=null}};(0,t.defineElement)(`wui-command-palette`,m),e.WuiCommandPalette=m})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.optionLabel,WeborityUiElementsInternal.modules.textMatch);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.135.0`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.135.0 but the page loaded `+u+`.`);var d=Object.freeze([`πŸ‘`,`❀️`,`πŸŽ‰`,`πŸ˜„`,`πŸ‘€`,`πŸ™`]),f=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),p=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),m=`[data-wui-items]`,h=`[data-wui-picker]`,g=`[data-wui-composer]`,_=`[data-wui-comment]`,v=`[data-wui-live]`,y=e=>typeof e?.message==`string`&&e.message?e.message:p.failed.server,b=class extends i.ElementBase{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(h)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&(0,n.anchorOverlay)(this._pickerFor.button,this.querySelector(h))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey);let e=this.querySelector(`${g} wui-mention-input`);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:d}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(h),n=e?this._pickerFor?.comment:t.closest(_);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(_);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=this.querySelector(h);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(_),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:p.replyLabel(r),placeholder:p.replyPlaceholder,value:``,send:p.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n?.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:p.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:p.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&s.setAttribute(e,this.getAttribute(e));let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`sm`,`send`,i),this._button(`ghost`,`sm`,`cancel`,p.cancel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(e,t,n,i){let a=this.ownerDocument.createElement(`button`);return a.type=`button`,a.className=(0,r.buttonClass)(e,t),a.dataset.wui=r.APP_BUTTON_MARKER,a.setAttribute(`data-wui-action`,n),a.textContent=i,a}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,t){let r=this.querySelector(h);r&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),r.hidden=!1,(0,n.anchorOverlay)(t,r),(0,n.bindReanchor)(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),r.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(h);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),(0,n.unbindReanchor)(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,p.emptyBody),n?.focus();return}let i=t.closest(_);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),p.done[e]&&this._announce(p.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:y(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:p.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,a.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||p.failed[r.kind]||p.failed.server}}_swapItems(e){let t=this.querySelector(m);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(m);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(_)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${g} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${v}`);t&&e&&(t.textContent=``,t.textContent=e)}},x=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${(0,c.formatNumber)(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),S=`[data-wui-control]`,C=`[data-wui-field]`,w=`[data-wui-menu]`,T=`[data-wui-live]`,E=0,D=e=>e&&o.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,o.mentionLabel)(e.label)!==``;function O(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function k(e,t){t.readOnly=(0,s.isReadOnly)(e)||e.hasAttribute(`loading`)}function A(e){let t=e.ownerDocument;e.id||=`wui-mention-${++E}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),k(e,n),O(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??x.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var j=class extends i.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(S)||A(this);let e=this._control(),t=this.querySelector(C)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(k(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(k(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?O(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,o.mentionValueFromText)(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(D):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(S)}_menu(){return this.querySelector(w)}_load(e){let{text:t,mentions:n}=(0,o.mentionTextFromValue)(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(C);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,s.isInert)(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'β€œβ€˜]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>(0,o.mentionLabel)(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,o=await(0,a.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!o.ok){this._peopleProp=[],this.loading=!1;return}let s=this.ownerDocument.createElement(`template`);s.innerHTML=o.html,this._peopleProp=[...s.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(D),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let s=r.createElement(`span`);if(s.className=`wui-mention-option-label`,s.textContent=(0,o.mentionLabel)(t.label),a.appendChild(s),t.description){let e=r.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?x.searching:`${x.noMatch} β€œ${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||(0,n.bindReanchor)(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?x.found(this._results.length):`${x.noMatch}.`)}_syncState(){let e=this._control();e&&(0,s.syncFieldState)(this,e)}_position(){(0,n.anchorOverlay)(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),(0,n.unbindReanchor)(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,l.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,o.mentionLabel)(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(x.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(T);t&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,j),(0,t.defineElement)(`wui-comment-thread`,b),e.COMMENT_INTENTS=f,e.COMMENT_REACTIONS=d,e.COMMENT_TEXT=p,e.WuiCommentThread=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.anchorOverlay,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.mentionText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.listboxKeyNav);
1
+ (function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var u=globalThis.WeborityUiElementsInternal?.version;if(u!==`0.136.0`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.136.0 but the page loaded `+u+`.`);var d=Object.freeze([`πŸ‘`,`❀️`,`πŸŽ‰`,`πŸ˜„`,`πŸ‘€`,`πŸ™`]),f=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),p=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),m=`[data-wui-items]`,h=`[data-wui-picker]`,g=`[data-wui-composer]`,_=`[data-wui-comment]`,v=`[data-wui-live]`,y=e=>typeof e?.message==`string`&&e.message?e.message:p.failed.server,b=class extends i.ElementBase{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(h)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&(0,n.anchorOverlay)(this._pickerFor.button,this.querySelector(h))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey);let e=this.querySelector(`${g} wui-mention-input`);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:d}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(h),n=e?this._pickerFor?.comment:t.closest(_);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(_);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=this.querySelector(h);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(_),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:p.replyLabel(r),placeholder:p.replyPlaceholder,value:``,send:p.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n?.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:p.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:p.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&s.setAttribute(e,this.getAttribute(e));let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`sm`,`send`,i),this._button(`ghost`,`sm`,`cancel`,p.cancel));let l=o.createElement(`div`);l.className=`wui-comment-error`,l.setAttribute(`data-wui-error`,``),l.hidden=!0,e.replaceChildren(s,c,l),this._handPeople(s),e.hidden=!1,this._openers??=new WeakMap,this._openers.set(e,a),s.focus();let u=s.querySelector(`textarea`);u?.setSelectionRange(u.value.length,u.value.length)}_button(e,t,n,i){let a=this.ownerDocument.createElement(`button`);return a.type=`button`,a.className=(0,r.buttonClass)(e,t),a.dataset.wui=r.APP_BUTTON_MARKER,a.setAttribute(`data-wui-action`,n),a.textContent=i,a}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(e,t){let r=this.querySelector(h);r&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),r.hidden=!1,(0,n.anchorOverlay)(t,r),(0,n.bindReanchor)(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),r.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;this._pickerFor=null;let r=this.querySelector(h);r&&(r.hidden=!0),t.button.setAttribute(`aria-expanded`,`false`),(0,n.unbindReanchor)(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&t.button.isConnected&&t.button.focus()}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,p.emptyBody),n?.focus();return}let i=t.closest(_);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,l=t.parentId??null;s.ok?(s.html!=null&&this._swapItems(s.html),e===`post`?i?.querySelector(`wui-mention-input`)?.clear():i?.isConnected&&this._closeSlot(i,!1),e===`delete`&&n?.isConnected&&this._closeConfirm(n,!1),this._restoreFocus(e,t,i),p.done[e]&&this._announce(p.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:l}}))):s.kind!==`session`&&s.kind!==`aborted`&&(this._showError(a.isConnected?a:this,s.message),this._announce(s.message),this.dispatchEvent(new CustomEvent(`wui:comment-thread:failed`,{bubbles:!0,detail:{intent:e,kind:s.kind,message:s.message}})))}async _persist(e){if(this.hasAttribute(`controlled`)){if(typeof this.submit!=`function`)return{ok:!0,html:null};try{return await this.submit(e),{ok:!0,html:null}}catch(e){return{ok:!1,kind:`server`,message:y(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:p.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,a.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||p.failed[r.kind]||p.failed.server}}_swapItems(e){let t=this.querySelector(m);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(m);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(_)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${g} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${v}`);t&&e&&(t.textContent=``,t.textContent=e)}},x=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${(0,c.formatNumber)(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),S=`[data-wui-control]`,C=`[data-wui-field]`,w=`[data-wui-menu]`,T=`[data-wui-live]`,E=0,D=e=>e&&o.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,o.mentionLabel)(e.label)!==``;function O(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function k(e,t){t.readOnly=(0,s.isReadOnly)(e)||e.hasAttribute(`loading`)}function A(e){let t=e.ownerDocument;e.id||=`wui-mention-${++E}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),k(e,n),O(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??x.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var j=class extends i.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(S)||A(this);let e=this._control(),t=this.querySelector(C)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(k(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(k(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?O(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,o.mentionValueFromText)(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(D):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(S)}_menu(){return this.querySelector(w)}_load(e){let{text:t,mentions:n}=(0,o.mentionTextFromValue)(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(C);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,s.isInert)(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'β€œβ€˜]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>(0,o.mentionLabel)(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,o=await(0,a.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!o.ok){this._peopleProp=[],this.loading=!1;return}let s=this.ownerDocument.createElement(`template`);s.innerHTML=o.html,this._peopleProp=[...s.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(D),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let r=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),t.src){let e=r.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let s=r.createElement(`span`);if(s.className=`wui-mention-option-label`,s.textContent=(0,o.mentionLabel)(t.label),a.appendChild(s),t.description){let e=r.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=r.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?x.searching:`${x.noMatch} β€œ${this._query.text}”`,e.appendChild(t)}let i=this._isOpen();e.hidden=!1,i||(0,n.bindReanchor)(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?x.found(this._results.length):`${x.noMatch}.`)}_syncState(){let e=this._control();e&&(0,s.syncFieldState)(this,e)}_position(){(0,n.anchorOverlay)(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),(0,n.unbindReanchor)(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,l.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,o.mentionLabel)(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(x.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(T);t&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,j),(0,t.defineElement)(`wui-comment-thread`,b),e.COMMENT_INTENTS=f,e.COMMENT_REACTIONS=d,e.COMMENT_TEXT=p,e.WuiCommentThread=b})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.anchorOverlay,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.mentionText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.listboxKeyNav);
@@ -1 +1 @@
1
- (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.135.0`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.135.0 but the page loaded `+a+`.`);var o={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},s=e=>`var(${e}, ${o[e]})`,c=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${s(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${s(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${s(`--color-surface`)}; border: 1px solid ${s(`--color-border`)}; border-radius: ${s(`--wui-radius-lg`)}; box-shadow: ${s(`--wui-shadow-modal`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${s(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${s(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${s(`--color-primary-text`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${s(`--color-border`)}; border-bottom: 1px solid ${s(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${s(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${s(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${s(`--color-primary`)}; background: ${s(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${s(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${s(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${s(`--color-primary`)}; border-color: ${s(`--color-primary`)}; color: ${s(`--color-on-primary`)}; } .btn-primary:hover { background: ${s(`--color-primary-hover`)}; border-color: ${s(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${s(`--color-text-muted`)}; color: ${s(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${s(`--color-bg-muted`)}; color: ${s(`--color-text`)}; } .btn-link { font-weight: 400; color: ${s(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${s(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } /* The actions are small buttons, which fall under the 44px touch target on touch screens. This sheet's .btn is inline-block, so it centres the label itself. */ @media (max-width: 575.98px), (pointer: coarse) { .wui-consent-banner-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } `,l=`data-wui-tour-open`,u=`wui-consent-save`,d=`[data-consent-settings]`,f=`tour-open`,p=`--wui-consent-banner-block`,m=`--wui-consent-banner-inline`,h={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},g=[`analytics`,`functional`,`marketing`],_={analytics:{label:h.analyticsLabel,description:`analyticsDescription`},functional:{label:h.functionalLabel,description:`functionalDescription`},marketing:{label:h.marketingLabel,description:`marketingDescription`}},v=new Set;function y(e){v.has(e)||(v.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${g.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var b=0,x=null;function S(e){x||(x=new CSSStyleSheet,x.replaceSync(c)),e.adoptedStyleSheets=[x]}var C=class extends i.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),b+=1,this._uid=`wui-consent-${b}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(d)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||h.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||h.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||h.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||h.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||h.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||h.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...g];let t=e.split(/\s+/).filter(Boolean);for(let e of t)g.includes(e)||y(e);let n=g.filter(e=>t.includes(e));return n.length?n:[...g]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(g.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[l]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(f,document.documentElement.hasAttribute(l))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?` <a class="wui-consent-banner-policy" href="${E(this.policyHref)}">${T(this.policyLabel)}</a>`:``,i=this._root();i!==this&&S(i),i.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${T(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${T(this.description)}${r}</p> <div class="wui-consent-banner-settings" hidden> ${w(t,`essential`,h.essentialLabel,h.essentialDescription,!0)} ${this.categories.map(e=>w(t,e,_[e].label,this[_[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${h.settingsLabel}</button> <button type="button" class="${(0,n.buttonClass)(`outline-secondary`,`sm`)} wui-consent-banner-reject" data-wui="${n.APP_BUTTON_MARKER}">${h.rejectLabel}</button> <button type="button" class="${(0,n.buttonClass)(`primary`,`sm`)} wui-consent-banner-accept" data-wui="${n.APP_BUTTON_MARKER}">${h.acceptLabel}</button> <button type="button" class="${(0,n.buttonClass)(`primary`,`sm`)} wui-consent-banner-save" hidden data-wui="${n.APP_BUTTON_MARKER}">${h.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(p),document.documentElement.style.removeProperty(m)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(p,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(m,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(g.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of g)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of g){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function w(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${T(n)}</label> </div> <p class="wui-consent-banner-category-description">${T(r)}</p> </div>`}var T=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),E=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);(0,t.defineElement)(`wui-consent-banner`,C),e.WuiConsentBanner=C})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase);
1
+ (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.136.0`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.136.0 but the page loaded `+a+`.`);var o={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-surface":`#FFFFFF`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-fixed":`1030`},s=e=>`var(${e}, ${o[e]})`,c=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${s(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${s(`--color-text`)}; } :host([position="bottom-right"]) { right: 20px; left: auto; } :host([position="bar"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } :host([position="bar"]) .wui-consent-banner-panel { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } :host(:not([open])) { pointer-events: none; } :host([tour-open]) { visibility: hidden; } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .wui-consent-banner-panel { padding: 20px; background: ${s(`--color-surface`)}; border: 1px solid ${s(`--color-border`)}; border-radius: ${s(`--wui-radius-lg`)}; box-shadow: ${s(`--wui-shadow-modal`)}; text-align: start; pointer-events: auto; } .wui-consent-banner-heading { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.3; color: ${s(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${s(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${s(`--color-primary-text`)}; font-weight: 500; } .wui-consent-banner-settings { display: grid; gap: 12px; max-height: 50vh; margin: 0 0 16px; padding: 12px 0; overflow-y: auto; border-top: 1px solid ${s(`--color-border`)}; border-bottom: 1px solid ${s(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${s(`--color-text-muted`)}; } .form-check { display: flex; align-items: center; gap: 0.5em; margin: 0; font-size: 14px; } .form-check-input { appearance: none; flex: none; width: 2em; height: 1em; margin: 0; border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2em; background: ${s(`--color-surface`)} radial-gradient(circle, rgba(0, 0, 0, 0.25) 0.35em, transparent 0.4em) left / 1em 1em no-repeat; cursor: pointer; transition: background-position 0.15s ease-in-out; } .form-check-input:checked { border-color: ${s(`--color-primary`)}; background: ${s(`--color-primary`)} radial-gradient(circle, #fff 0.35em, transparent 0.4em) right / 1em 1em no-repeat; } .form-check-input:disabled { opacity: 0.5; cursor: default; } .form-check-input:focus-visible { outline: 2px solid ${s(`--color-primary`)}; outline-offset: 2px; } .form-check-label { cursor: pointer; } .wui-consent-banner-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; } .btn { display: inline-block; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid ${s(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${s(`--color-primary`)}; border-color: ${s(`--color-primary`)}; color: ${s(`--color-on-primary`)}; } .btn-primary:hover { background: ${s(`--color-primary-hover`)}; border-color: ${s(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${s(`--color-text-muted`)}; color: ${s(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${s(`--color-bg-muted`)}; color: ${s(`--color-text`)}; } .btn-link { font-weight: 400; color: ${s(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${s(`--color-primary-hover`)}; } .wui-consent-banner-settings-toggle { margin-inline-end: auto; padding-inline: 0; } .wui-consent-banner-save { flex: 1 1 100%; } @media (max-width: 575.98px) { :host, :host([position="bottom-right"]) { left: 0; right: 0; bottom: 0; width: auto; max-width: none; } .wui-consent-banner-panel { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0; border-radius: 0; } /* Hidden on phones, but it stays the dialog's accessible name. */ .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } .wui-consent-banner-description { margin: 0 0 8px; font-size: 13px; line-height: 1.4; } .wui-consent-banner-actions { gap: 6px; } } @media (min-width: 576px) { :host([position="bar"]) .wui-consent-banner-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; } /* Hidden on the bar, but it stays the dialog's accessible name. */ :host([position="bar"]) .wui-consent-banner-heading { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } :host([position="bar"]) .wui-consent-banner-description { margin: 0; flex: 1 1 320px; } :host([position="bar"]) .wui-consent-banner-actions { flex: none; } :host([position="bar"]) .wui-consent-banner-settings { flex-basis: 100%; margin: 0; } } /* The actions are small buttons, which fall under the 44px touch target on touch screens. This sheet's .btn is inline-block, so it centres the label itself. */ @media (max-width: 575.98px), (pointer: coarse) { .wui-consent-banner-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } `,l=`data-wui-tour-open`,u=`wui-consent-save`,d=`[data-consent-settings]`,f=`tour-open`,p=`--wui-consent-banner-block`,m=`--wui-consent-banner-inline`,h={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},g=[`analytics`,`functional`,`marketing`],_={analytics:{label:h.analyticsLabel,description:`analyticsDescription`},functional:{label:h.functionalLabel,description:`functionalDescription`},marketing:{label:h.marketingLabel,description:`marketingDescription`}},v=new Set;function y(e){v.has(e)||(v.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${g.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var b=0,x=null;function S(e){x||(x=new CSSStyleSheet,x.replaceSync(c)),e.adoptedStyleSheets=[x]}var C=class extends i.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),b+=1,this._uid=`wui-consent-${b}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(d)&&(e.preventDefault(),this.open({settings:!0,focus:!0}))},this._tourWatch=null,this._roomObserver=null,this._onWindowResize=()=>this._reserveRoom()}get position(){let e=this.getAttribute(`position`);return e===`bottom-right`||e===`bar`?e:`bottom-left`}set position(e){this.setAttribute(`position`,String(e??`bottom-left`))}get standalone(){return this.hasAttribute(`standalone`)}set standalone(e){this.toggleAttribute(`standalone`,e===!0||e===``||e===`true`)}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}get heading(){return this.getAttribute(`heading`)||h.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||h.description}set description(e){this.setAttribute(`description`,String(e??``))}get policyHref(){return this.getAttribute(`policy-href`)||``}set policyHref(e){this.setAttribute(`policy-href`,String(e??``))}get policyLabel(){return this.getAttribute(`policy-label`)||h.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||h.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||h.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||h.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...g];let t=e.split(/\s+/).filter(Boolean);for(let e of t)g.includes(e)||y(e);let n=g.filter(e=>t.includes(e));return n.length?n:[...g]}set categories(e){e==null?this.removeAttribute(`categories`):this.setAttribute(`categories`,Array.isArray(e)?e.join(` `):String(e))}get preferences(){let e=this.categories;return Object.fromEntries(g.map(t=>[t,e.includes(t)&&this._preferences[t]]))}set preferences(e){this._preferences={analytics:e?.analytics===!0,functional:e?.functional===!0,marketing:e?.marketing===!0},this._applyPreferences()}get isOpen(){return this.hasAttribute(`open`)}connectedCallback(){this._rendered||this.render(),document.addEventListener(`click`,this._onDocumentClick),this._syncTour(),this._tourWatch??=new MutationObserver(()=>this._syncTour()),this._tourWatch.observe(document.documentElement,{attributes:!0,attributeFilter:[l]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(f,document.documentElement.hasAttribute(l))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?` <a class="wui-consent-banner-policy" href="${E(this.policyHref)}">${T(this.policyLabel)}</a>`:``,i=this._root();i!==this&&S(i),i.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${t}-heading" aria-describedby="${t}-description" hidden> <h2 class="wui-consent-banner-heading" id="${t}-heading">${T(this.heading)}</h2> <p class="wui-consent-banner-description" id="${t}-description">${T(this.description)}${r}</p> <div class="wui-consent-banner-settings" hidden> ${w(t,`essential`,h.essentialLabel,h.essentialDescription,!0)} ${this.categories.map(e=>w(t,e,_[e].label,this[_[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${h.settingsLabel}</button> <button type="button" class="${(0,n.buttonClass)(`outline-secondary`,`sm`)} wui-consent-banner-reject" data-wui="${n.APP_BUTTON_MARKER}">${h.rejectLabel}</button> <button type="button" class="${(0,n.buttonClass)(`primary`,`sm`)} wui-consent-banner-accept" data-wui="${n.APP_BUTTON_MARKER}">${h.acceptLabel}</button> <button type="button" class="${(0,n.buttonClass)(`primary`,`sm`)} wui-consent-banner-save" hidden data-wui="${n.APP_BUTTON_MARKER}">${h.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(p),document.documentElement.style.removeProperty(m)}_reserveRoom(){let e=this.getBoundingClientRect(),t=this.position===`bar`?0:this.position===`bottom-right`?window.innerWidth-e.left:e.right,n=document.documentElement.style;n.setProperty(p,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(m,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(g.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of g)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of g){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function w(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${T(n)}</label> </div> <p class="wui-consent-banner-category-description">${T(r)}</p> </div>`}var T=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),E=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);(0,t.defineElement)(`wui-consent-banner`,C),e.WuiConsentBanner=C})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.elementBase);