@webority/ui-elements 0.198.0 → 0.198.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/server.js +1 -1
  2. package/dist/ui-elements/calendar-views.global.js +1 -1
  3. package/dist/ui-elements/carousel.global.js +1 -1
  4. package/dist/ui-elements/code-block.global.js +1 -1
  5. package/dist/ui-elements/command-palette.global.js +1 -1
  6. package/dist/ui-elements/comment-thread.global.js +1 -1
  7. package/dist/ui-elements/consent-banner.global.js +1 -1
  8. package/dist/ui-elements/context-menu.global.js +1 -1
  9. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  10. package/dist/ui-elements/data-table.global.js +1 -1
  11. package/dist/ui-elements/date-range.global.js +1 -1
  12. package/dist/ui-elements/date-time.global.js +1 -1
  13. package/dist/ui-elements/datepicker.global.js +1 -1
  14. package/dist/ui-elements/dock.global.js +1 -1
  15. package/dist/ui-elements/drawer.global.js +1 -1
  16. package/dist/ui-elements/dropdown.global.js +1 -1
  17. package/dist/ui-elements/entry-grid.global.js +1 -1
  18. package/dist/ui-elements/gantt.global.js +1 -1
  19. package/dist/ui-elements/glyphs-a.global.js +1 -1
  20. package/dist/ui-elements/glyphs-b.global.js +1 -1
  21. package/dist/ui-elements/glyphs-c.global.js +1 -1
  22. package/dist/ui-elements/glyphs-d.global.js +1 -1
  23. package/dist/ui-elements/glyphs-e.global.js +1 -1
  24. package/dist/ui-elements/glyphs-f.global.js +1 -1
  25. package/dist/ui-elements/glyphs-g.global.js +1 -1
  26. package/dist/ui-elements/glyphs-h.global.js +1 -1
  27. package/dist/ui-elements/glyphs-i.global.js +1 -1
  28. package/dist/ui-elements/glyphs-j.global.js +1 -1
  29. package/dist/ui-elements/glyphs-k.global.js +1 -1
  30. package/dist/ui-elements/glyphs-l.global.js +1 -1
  31. package/dist/ui-elements/glyphs-m.global.js +1 -1
  32. package/dist/ui-elements/glyphs-n.global.js +1 -1
  33. package/dist/ui-elements/glyphs-o.global.js +1 -1
  34. package/dist/ui-elements/glyphs-p.global.js +1 -1
  35. package/dist/ui-elements/glyphs-q.global.js +1 -1
  36. package/dist/ui-elements/glyphs-r.global.js +1 -1
  37. package/dist/ui-elements/glyphs-s.global.js +1 -1
  38. package/dist/ui-elements/glyphs-t.global.js +1 -1
  39. package/dist/ui-elements/glyphs-u.global.js +1 -1
  40. package/dist/ui-elements/glyphs-v.global.js +1 -1
  41. package/dist/ui-elements/glyphs-w.global.js +1 -1
  42. package/dist/ui-elements/glyphs-x.global.js +1 -1
  43. package/dist/ui-elements/glyphs-z.global.js +1 -1
  44. package/dist/ui-elements/glyphs.global.js +1 -1
  45. package/dist/ui-elements/hover-card.global.js +1 -1
  46. package/dist/ui-elements/image-crop.global.js +1 -1
  47. package/dist/ui-elements/inline-edit.global.js +1 -1
  48. package/dist/ui-elements/kanban.global.js +1 -1
  49. package/dist/ui-elements/lead-popup.global.js +1 -1
  50. package/dist/ui-elements/lightbox.global.js +1 -1
  51. package/dist/ui-elements/markdown.global.js +1 -1
  52. package/dist/ui-elements/mini-calendar.global.js +1 -1
  53. package/dist/ui-elements/navigation-menu.global.js +1 -1
  54. package/dist/ui-elements/notification-center.global.js +1 -1
  55. package/dist/ui-elements/offline-banner.global.js +1 -1
  56. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  57. package/dist/ui-elements/org-tree.global.js +1 -1
  58. package/dist/ui-elements/otp.global.js +1 -1
  59. package/dist/ui-elements/overflow.global.js +1 -1
  60. package/dist/ui-elements/phone.global.js +1 -1
  61. package/dist/ui-elements/popover.global.js +1 -1
  62. package/dist/ui-elements/rating.global.js +1 -1
  63. package/dist/ui-elements/record-pager.global.js +1 -1
  64. package/dist/ui-elements/relative-time.global.js +1 -1
  65. package/dist/ui-elements/saved-views.global.js +1 -1
  66. package/dist/ui-elements/select-chips.global.js +1 -1
  67. package/dist/ui-elements/select-recents.global.js +1 -1
  68. package/dist/ui-elements/select-search.global.js +1 -1
  69. package/dist/ui-elements/select-window.global.js +1 -1
  70. package/dist/ui-elements/server.global.js +1 -1
  71. package/dist/ui-elements/shell.global.js +1 -1
  72. package/dist/ui-elements/shortcuts.global.js +1 -1
  73. package/dist/ui-elements/show-more.global.js +1 -1
  74. package/dist/ui-elements/slider.global.js +1 -1
  75. package/dist/ui-elements/sortable.global.js +1 -1
  76. package/dist/ui-elements/status-icon.global.js +1 -1
  77. package/dist/ui-elements/table-export.global.js +1 -1
  78. package/dist/ui-elements/timepicker.global.js +1 -1
  79. package/dist/ui-elements/tour.global.js +1 -1
  80. package/dist/ui-elements/tree-picker.global.js +1 -1
  81. package/dist/ui-elements/tree.global.js +1 -1
  82. package/dist/ui-elements/truncate.global.js +1 -1
  83. package/dist/ui-elements/whats-new.global.js +1 -1
  84. package/dist/ui-elements/wizard.global.js +1 -1
  85. package/dist/ui-elements.global.js +1 -1
  86. package/package.json +5 -5
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-Dh5iyZSR.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,g as u,h as d,i as f,l as p,m as ee,n as m,p as h,s as g,t as _}from"./wuiHttp-8CYWEbRz.js";import{n as te,t as ne}from"./buttonClass-C8BRtTk8.js";import{E as v,M as y,N as b,b as x,k as S,y as C}from"./dataTable-D48Rwq1a.js";import{n as w,t as re}from"./devWarn-DXdRWZs3.js";import{t as ie}from"./iconGlyphs.g-DRNDTVOs.js";import{LIST_QUERY_RESERVED as ae,SEARCH_PARAM as oe}from"./listQuery.js";import{a as se,c as ce,i as le,n as T,r as ue,s as de}from"./tableSelect-B2lLTEj1.js";import{t as fe}from"./dataTable.g-1PsmN1Nj.js";import{t as pe}from"./httpFailure.g-DjZzGxPj.js";import{S as E,_ as D,b as O,c as me,d as he,g as k,h as ge,i as _e,m as ve,n as A,p as ye,v as j,y as M}from"./refreshAfter-DhYgWXmQ.js";import{S as N,_ as be,a as xe,b as Se,c as P,d as Ce,f as we,g as F,h as Te,i as I,l as L,m as R,n as Ee,o as z,p as De,r as Oe,s as ke,t as Ae,u as je,v as B,x as Me,y as Ne}from"./drawerDiscard-mFYviRfI.js";var V=()=>r(`dataTable`,fe),Pe=5,Fe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Ie=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Le=e=>Fe(e)&&`type`in e&&e.type===`hidden`,H=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),U=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},W=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Re=e=>e.localName===`wui-select`,G=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ze=e=>({total:G(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:G(e.dataset.page,1),pageSize:G(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:G(e.dataset.rowCount,0)}),Be=(e,t)=>{e&&D().toast(e,{variant:t})},Ve=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Le(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ae.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of H(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},He=new Intl.NumberFormat(`en-IN`),Ue=(e,t)=>t?`${He.format(e)}+`:He.format(e),We=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?U(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Ue(t,n))};function Ge(e=document){let t=H(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(ve(e))continue;let t=Ke(e);ge(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Ke(n){let a=U(n,`.table-wrap`,HTMLElement),s=a?U(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=U(a,`:scope > [data-wui-table-state]`,HTMLElement),u=U(n,`[data-wui-table-pager]`,HTMLElement),d=U(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||V().loadingText,errorText:n.dataset.errorText||V().errorText,timeoutMs:h(n.getAttribute(`data-wui-timeout`))??3e4},m=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),fe=/* @__PURE__ */ new Set([...m.searchParams.keys(),..._?.searchParams.keys()??[]]),E=s.hasAttribute(`data-app-datatable-selectable`),O=/* @__PURE__ */ new Set,k=!1,ge=p(),ve=new AbortController,A={signal:ve.signal},ye=U(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),j=e(ye,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),M=ze(j),N=null,be=null,xe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))fe.has(n)||t.append(n,r);return t},Se=e=>xe(new URL(e,window.location.href).search),P=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Ce=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)fe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},we=e=>Ce(m,e),F=(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},I=F(f.urlState?xe(window.location.search):new URLSearchParams,M);f.urlState&&P(I)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,P(I));let L=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),R=e=>{d&&(d.textContent=e)},Ee=e=>{if(e.pending)return e.rowCount===0?V().emptyLabel:i(V().pageTextPending,{page:e.page});if(e.total===0)return V().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Ue(e.total,!0):`${e.total}`;return i(e.total===1?V().pageTextOne:V().pageTextOther,{page:e.page,pages:t,total:n})},z=()=>H(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),De=e=>{if(E&&H(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Oe=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},ke=e=>{if(E){ue(e);for(let t of e){let e=U(t,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(k&&O.add(t.dataset.rowKey),e.checked=O.has(t.dataset.rowKey))}ce(s)}Oe(e);let t=z();if(s.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`)})},Ae=e=>ke(H(e,`:scope > tr`,HTMLTableRowElement)),je=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},B=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Me=(e,t)=>{if(!l)return;let n=U(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);B(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ne=e=>{u&&(B(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},He=e=>{let t=f.filtersRegion&&e?U(document,f.filtersRegion,HTMLElement):null;return t&&e&&(B(t),t.replaceChildren(e.content.cloneNode(!0))),t},Ge=0,Ke=e=>{let t=ze(e);t.pending&&Object.assign(t,{total:M.total,totalCapped:M.totalCapped});let n=t.sortBy!==M.sortBy||t.sortOrder!==M.sortOrder?C(j.rows):null;Ne(U(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Me(e,t);let r=He(U(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));je(e),B(j),s.replaceChild(e,j),j=e,Ge+=1;let i=k&&t.total!==M.total;return M=t,i&&(k=!1),a.removeAttribute(`data-wui-table-error`),Ae(e),rt(),v(e.rows,n),i&&Z(),r},qe=e=>{let t=U(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&De(t),t?document.importNode(t,!0):null},Je=(e,t=z())=>{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},Ye=()=>{if(j.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,z().length);j.replaceChildren(...Array.from({length:Pe},()=>{let t=Je(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},K=e=>{e?(a.setAttribute(`aria-busy`,`true`),Ye()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?V().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,pe).networkCheckText:e===`network`?V().networkMessage:e===`timeout`?V().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=ie(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=te(`primary`,`outline`,`sm`),s.dataset.wui=ne,s.setAttribute(`data-wui-table-retry`,``),s.textContent=V().retryLabel,o.append(s),n.append(r,a,o),B(l),l.replaceChildren(n),l.hidden=!1}R(t)},Qe=()=>f.filtersForm?U(document,f.filtersForm,HTMLFormElement):null,q=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(N={query:i,mode:t},K(!0),R(f.loadingText)),L(`wui:table:loading`,{query:i.toString()});let o=await ge.run(we(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||K(!1);let s=null;if(o.ok)try{s=qe(o.html)}catch(e){re(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?w(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),L(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ke(s);return I=F(i,M),Ve(Qe(),I),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,P(I)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,P(I)),r||R(Ee(M)),D().refresh(a),c&&D().refresh(c),M.pending?nt():We(n,M.total,M.totalCapped),L(`wui:table:loaded`,{...M,query:I.toString()}),o},J=[],$e=null,et=()=>{if(J.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=J;J=[],q(I,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},Y=async(e,t=`none`,n={})=>{let r;try{r=await q(e,t,n)}catch(e){let t=J;J=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&($e=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=J;J=[];for(let t of e)t.resolve(r)}return et(),r},tt=e=>(e.delete(`page`),e),nt=()=>{if(!_||!M.pending)return;let e=Ge;ee(Ce(_,I),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Ge)return;if(!t.ok){w(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=U(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){w(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(G(r.dataset.page,-1)!==M.page||G(r.dataset.pageSize,-1)!==M.pageSize)return;let i=G(r.dataset.total,-1);if(i<0){w(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=k&&i!==M.total;M={...M,total:i,totalCapped:a,pending:!1},s&&(k=!1);let c=U(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Ne(c);let l=He(U(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&D().refresh(l),We(n,M.total,M.totalCapped),R(Ee(M)),s&&Z(),L(`wui:table:total`,{total:i,totalCapped:a})})},X=()=>H(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),rt=()=>{for(let e of X()){let t=e.dataset.sortKey===M.sortBy;e.setAttribute(`aria-sort`,t?M.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of X())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`;let r=ie(`chevrons-up-down`,{size:14});r&&n.replaceChildren(r),t?e.prepend(n):e.append(n)}let it=e=>{let t=tt(new URLSearchParams(I)),n=M.sortBy===e&&M.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),Y(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&it(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),it(t.dataset.sortKey??``))});let Z=()=>{ce(s),de(s);let e=k?{selected:M.total,total:M.total,allMatching:k}:{selected:O.size,total:M.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};E&&(se(s,(e,t)=>{for(let n of e){let e=W(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?O.add(e):O.delete(e))}t||(k=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(k=!1),s.tHead?.contains(t))for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=U(e,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?O.add(e.dataset.rowKey):O.delete(e.dataset.rowKey))}else if(W(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=W(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=U(n,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?O.add(r):O.delete(r))}}else{let e=W(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?O.add(e):O.delete(e)}Z()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),Y(Se(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),Y(Se(t.value),`push`))}));let Q=()=>{if(!f.searchInput)return null;let e=U(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?U(e,`input`,HTMLInputElement):null},$=()=>n.isConnected?!0:(ve.abort(),clearTimeout(be??void 0),!1),at=(e,t)=>{let n=[...e.elements].filter(Fe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Le(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Ie(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},ot=(e,t)=>{let n=new Set([...e.elements].filter(Fe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&ae.includes(e);for(let[e,t]of I)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of at(e,t))a===``||i(n)||fe.has(n)||r.append(n,a);let a=Q();if(a){r.delete(oe);let e=a.value.trim();e&&r.set(oe,e)}return Y(r,`push`)},st=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{$()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),ot(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!$()||!f.filtersForm||!(e.target instanceof Element))return;let t=W(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||ot(t)},A);let ct=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of H(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of H(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Re)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!st(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=tt(Se(n.href));ct(t.closest(`form`),r),Ve(t.closest(`form`),r),Y(r,`push`)},A),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();t&&e.target===t&&(clearTimeout(be??void 0),be=setTimeout(()=>{if(!$())return;let e=tt(new URLSearchParams(I)),n=t.value.trim();n?e.set(oe,n):e.delete(oe),e.toString()!==I.toString()&&Y(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=xe(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),Ve(Qe(),e),Y(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&N&&Y(N.query,N.mode)});let lt=e=>[...j.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=H(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:lt(n.dataset.rowKey);e&&(B(e),e.replaceWith(n),i.push(n))}return ke(i),D().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?V().actionForbiddenMessage:V().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&b(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:lt(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=z().filter(e=>!e.classList.contains(T)),f=s===void 0?u??Je(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||j.insertBefore(f,j.firstChild),f!==u&&ke([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),b(f,`saving`);let p=S(f),m=await ee(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!_e(n)&&he(m))return pt(f),L(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await me(m,{origin:n}),!0;let e=ut(m.html),t=e&&f.isConnected?dt(e,f,c):null;return t&&R(y(S(t)||p)),Te(m,m.toastVariant||`success`),_e(n)||await me(m,{skip:t?n:null,origin:n}),pt(f),L(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let h=ft(m),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):c&&!s&&(f.remove(),g=null,l?.childElementCount&&!j.querySelector(`:scope > tr`)&&(l.hidden=!1)),g?.isConnected&&b(g,`error`,h),m.kind!==`aborted`&&Be(h,`danger`),R(x(p,h)),L(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:h}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=W(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?S(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&b(r,`saving`);let s=await ee(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)pt(r);else if(s.ok&&!_e(e)&&he(s))pt(r),L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await me(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?ut(s.html):null,i=t&&r?dt(t,r,!1):null;i&&R(y(S(i)||o)),_e(e)||await me(s,{skip:i?n:null,origin:e}),pt(r)}else{let e=ft(s);Be(e,`danger`),r?.isConnected&&b(r,`error`,e),R(x(o,e))}L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&j.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),De(j),je(j),E&&le(s),Ae(j),rt(),M.pending&&(R(Ee(M)),nt()),{el:n,reload:async e=>{if($e)return $e;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{J.push({resolve:e,reject:t})}):Y(I,`none`,{quiet:t})},query:()=>new URLSearchParams(I),setQuery:e=>{let t=new URLSearchParams(I);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`),Y(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),Oe(H(j,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...O],count:()=>k?M.total:O.size,allMatching:()=>k,selectAllMatching:()=>{if(M.pending)w(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{k=!0;for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=U(e,`.${T} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&O.add(e.dataset.rowKey))}Z()}},clear:()=>{k=!1,O.clear();for(let e of H(j,`:scope > tr > .${T} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;Z()}}}}var qe=/* @__PURE__ */ new WeakSet;function Je(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(!O(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${M.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&F(n,t)}}function Ye(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!qe.has(t)){qe.add(t);let e=E();e&&F(e.message,e.variant,e.action)}Je(e)}var K=/* @__PURE__ */ new WeakMap;function Xe(e,t){K.set(e,t)}function Ze(e){K.delete(e)}function Qe(e){let t=e?.closest(`[data-app-shell]`);return(t&&K.get(t))??null}var q=()=>r(`shell`,a),J=31536e3;function $e(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?et(n):String(n)}var et=e=>e>99?`99+`:String(e),Y=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function tt(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function nt(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=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var X=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},rt=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},it=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Z=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},Q=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},$=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},at=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ot=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function st(t,r){let i=e(X(t,`input.search-input`,HTMLInputElement),`search input missing`),a=X(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=X(t,`.wui-topsearch-open`,HTMLElement),l=X(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,ee=Number(t.dataset.minChars??2),m=Number(t.dataset.debounceMs??250),h=t.dataset.noResultsText??q().noResultsText,g=t.dataset.resultsCountText??q().resultsCountText,_=t.dataset.resultCountText??q().resultCountText,te=p(),ne,v=-1,y=()=>it(s(),`.wui-topsearch-hit`,HTMLElement),b=e=>{let t=y();v=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===v;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=v>=0?t[v]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},x=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),v=-1},S=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},C=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},w=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},re=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await te.run(ot(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=X(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),y().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):y().length;l&&(l.textContent=r===0?h:Y(r===1?_:g,{count:r}))}else s().replaceChildren($(`wui-topsearch-empty`,q().searchUnavailableMessage));v=-1,S()}};i.addEventListener(`input`,()=>{clearTimeout(ne);let e=i.value.trim();e.length<ee?(te.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),x()):ne=setTimeout(()=>re(e),m)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||y().length===0)return;e.preventDefault(),b(v+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=y(),n=v>=0?t[v]:void 0;!s().hidden&&n?(e.preventDefault(),w(Q(n))):f&&i.value.trim()!==``&&(e.preventDefault(),w(ot(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),C(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),x()))}),s().addEventListener(`click`,e=>{let t=rt(Z(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),w(Q(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);C(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||at(e.target)||(e.preventDefault(),C(!0),i.focus())},ae=e=>{e.target instanceof Node&&t.contains(e.target)||(x(),t.classList.contains(`is-open`)&&C(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,ae),r.push(()=>{clearTimeout(ne),te.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,ae)})}function ct(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{tt(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{nt(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{Z(t).closest(`[data-wui-tabbar-more]`)&&X(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=X(e,`[data-wui-topsearch]`,HTMLElement);i&&st(i,t);let a={el:e,setTabCount(t,n,r){$e(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=X(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};Xe(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();Ze(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function lt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...it(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,ct(e))}function ut(e){let t=rt(e,`[data-app-shell]`,HTMLElement);return t?(Qe(t)||lt(t),Qe(t)):null}export{ke as CONFIRM_DIALOG_ID,P as CONFIRM_TONES,_ as CSRF_META_NAME,m as DEFAULT_CSRF_HEADER,Ae as DISCARD_EVENT,j as FLASH_STORAGE_KEY,M as FLASH_VARIANTS,f as HTTP_KINDS,d as TOAST_ACTION_METHODS,De as TOAST_ACTION_MS,s as WUI_HEADERS,N as WuiPostError,A as applyRefresh,g as classifyStatus,be as closeRemotePane,c as configureCsrf,L as confirmAction,Ee as createDiscardPrompt,p as createRequestQueue,I as formValues,ye as getServerTable,ut as getShell,Oe as initDrawerDiscard,Ye as initFlashToasts,B as initRemoteModals,je as initServerActions,Ge as initServerTables,lt as initShellParts,xe as initUnsavedChanges,Ne as loadRemoteDrawer,Se as loadRemoteModal,Me as loadRemotePane,o as parseServerHtml,u as parseToastAction,Ce as postAction,l as readCsrf,me as refreshAfter,k as refreshRegions,he as reloadsPage,z as resetUnsavedChanges,R as runToastAction,Te as showResultToast,F as showToast,h as timeoutFromAttribute,ee as wuiFetch,we as wuiUpload};
1
+ import{i as e,n as t}from"./dom-DMQu--xV.js";import{n}from"./imeSafeEnter-DeO_3lXy.js";import{r,t as i}from"./textStore-Dh5iyZSR.js";import{t as a}from"./shell.g-BhC11Oe3.js";import{t as o}from"./serverHtml-BC6tAyAl.js";import{a as s,c,d as l,g as u,h as d,i as f,l as p,m as ee,n as m,p as h,s as g,t as _}from"./wuiHttp-8CYWEbRz.js";import{n as te,t as ne}from"./buttonClass-C8BRtTk8.js";import{E as v,M as y,N as b,b as x,k as S,y as C}from"./dataTable-D48Rwq1a.js";import{n as w,t as re}from"./devWarn-DXdRWZs3.js";import{t as ie}from"./iconGlyphs.g-DRNDTVOs.js";import{LIST_QUERY_RESERVED as ae,SEARCH_PARAM as oe}from"./listQuery.js";import{a as se,c as ce,i as le,n as T,r as ue,s as de}from"./tableSelect-B2lLTEj1.js";import{t as fe}from"./dataTable.g-1PsmN1Nj.js";import{t as pe}from"./httpFailure.g-DjZzGxPj.js";import{S as E,_ as D,b as O,c as me,d as he,g as k,h as ge,i as _e,m as ve,n as A,p as ye,v as j,y as M}from"./refreshAfter-DhYgWXmQ.js";import{S as N,_ as be,a as xe,b as Se,c as P,d as Ce,f as we,g as F,h as Te,i as I,l as L,m as R,n as Ee,o as z,p as De,r as Oe,s as ke,t as Ae,u as je,v as B,x as Me,y as Ne}from"./drawerDiscard-mFYviRfI.js";var V=()=>r(`dataTable`,fe),Pe=5,Fe=e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLButtonElement||e instanceof HTMLFieldSetElement||e instanceof HTMLObjectElement||e instanceof HTMLOutputElement,Ie=e=>e instanceof HTMLObjectElement||e instanceof HTMLOutputElement?!1:e.disabled,Le=e=>Fe(e)&&`type`in e&&e.type===`hidden`,H=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),U=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},W=(e,t,n)=>{let r=e.closest(t);return r instanceof n?r:null},Re=e=>e.localName===`wui-select`,G=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},ze=e=>({total:G(e.dataset.total,0),totalCapped:e.dataset.totalCapped===`true`,page:G(e.dataset.page,1),pageSize:G(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`,pending:e.dataset.totalPending===`true`,rowCount:G(e.dataset.rowCount,0)}),Be=(e,t)=>{e&&D().toast(e,{variant:t})},Ve=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>!Le(e)||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!ae.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of H(e,`[data-wui-filter-clear]`,HTMLElement))t.hidden=!r},He=new Intl.NumberFormat(`en-IN`),Ue=(e,t)=>t?`${He.format(e)}+`:He.format(e),We=(e,t,n)=>{let r=e.closest(`.wui-list-card`),i=r?U(r,`.wui-list-card-count`,HTMLElement):null;i&&(i.textContent=Ue(t,n))};function Ge(e=document){let t=H(e,`[data-wui-server]`,HTMLElement);e instanceof HTMLElement&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t){if(ve(e))continue;let t=Ke(e);ge(e,t),e.hasAttribute(`data-load-first-page`)&&t.reload()}}function Ke(n){let a=U(n,`.table-wrap`,HTMLElement),s=a?U(a,`:scope > table`,HTMLTableElement):null,c=n.dataset.src;if(!a||!s||!c)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let l=U(a,`:scope > [data-wui-table-state]`,HTMLElement),u=U(n,`[data-wui-table-pager]`,HTMLElement),d=U(n,`[data-wui-table-status]`,HTMLElement),f={urlState:n.dataset.urlState!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||V().loadingText,errorText:n.dataset.errorText||V().errorText,timeoutMs:h(n.getAttribute(`data-wui-timeout`))??3e4},m=new URL(c,window.location.href),g=n.dataset.totalSrc||null,_=g===null?null:new URL(g,window.location.href),fe=/* @__PURE__ */ new Set([...m.searchParams.keys(),..._?.searchParams.keys()??[]]),E=s.hasAttribute(`data-app-datatable-selectable`),O=/* @__PURE__ */ new Set,k=!1,ge=p(),ve=new AbortController,A={signal:ve.signal},ye=U(s,`:scope > tbody[data-wui-rows]`,HTMLTableSectionElement),j=e(ye,`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`),M=ze(j),N=null,be=null,xe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))fe.has(n)||t.append(n,r);return t},Se=e=>xe(new URL(e,window.location.href).search),P=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},Ce=(e,t)=>{let n=new URL(e.href);for(let[e,r]of t)fe.has(e)||n.searchParams.append(e,r);return n.origin===window.location.origin?`${n.pathname}${n.search}`:n.href},we=e=>Ce(m,e),F=(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},I=F(f.urlState?xe(window.location.search):new URLSearchParams,M);f.urlState&&P(I)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,P(I));let L=(e,t)=>a.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),R=e=>{d&&(d.textContent=e)},Ee=e=>{if(e.pending)return e.rowCount===0?V().emptyLabel:i(V().pageTextPending,{page:e.page});if(e.total===0)return V().emptyLabel;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1,n=e.totalCapped?Ue(e.total,!0):`${e.total}`;return i(e.total===1?V().pageTextOne:V().pageTextOther,{page:e.page,pages:t,total:n})},z=()=>H(s,`:scope > thead > tr:first-child > th`,HTMLTableCellElement),De=e=>{if(E&&H(e,`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`,HTMLTableRowElement).some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},Oe=e=>{let t=n.dataset.activeRowKey;if(t!==void 0)for(let n of e){let e=n.classList.contains(`wui-row-active`),r=t!==``&&n.dataset.rowKey===t;n.classList.toggle(`wui-row-active`,r),r?n.setAttribute(`aria-current`,`true`):e&&n.removeAttribute(`aria-current`)}},ke=e=>{if(E){ue(e);for(let t of e){let e=U(t,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);e&&(k&&O.add(t.dataset.rowKey),e.checked=O.has(t.dataset.rowKey))}ce(s)}Oe(e);let t=z();if(s.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`)})},Ae=e=>ke(H(e,`:scope > tr`,HTMLTableRowElement)),je=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},B=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),Me=(e,t)=>{if(!l)return;let n=U(e,`:scope > template[data-wui-empty]`,HTMLTemplateElement);B(l),(t.pending?t.rowCount:t.total)===0&&n?(l.replaceChildren(n.content.cloneNode(!0)),l.hidden=!1):(l.replaceChildren(),l.hidden=!0)},Ne=e=>{u&&(B(u),u.replaceChildren(...e?[e.content.cloneNode(!0)]:[]),u.hidden=!1)},He=e=>{let t=f.filtersRegion&&e?U(document,f.filtersRegion,HTMLElement):null;return t&&e&&(B(t),t.replaceChildren(e.content.cloneNode(!0))),t},Ge=0,Ke=e=>{let t=ze(e);t.pending&&Object.assign(t,{total:M.total,totalCapped:M.totalCapped});let n=t.sortBy!==M.sortBy||t.sortOrder!==M.sortOrder?C(j.rows):null;Ne(U(e,`:scope > template[data-wui-pager]`,HTMLTemplateElement)),Me(e,t);let r=He(U(e,`:scope > template[data-wui-filters]`,HTMLTemplateElement));je(e),B(j),s.replaceChild(e,j),j=e,Ge+=1;let i=k&&t.total!==M.total;return M=t,i&&(k=!1),a.removeAttribute(`data-wui-table-error`),Ae(e),rt(),v(e.rows,n),i&&Z(),r},qe=e=>{let t=U(o(`<table>${e}</table>`),`tbody[data-wui-rows]`,HTMLTableSectionElement);return t&&De(t),t?document.importNode(t,!0):null},Je=(e,t=z())=>{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},Ye=()=>{if(j.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,z().length);j.replaceChildren(...Array.from({length:Pe},()=>{let t=Je(e);return t.setAttribute(`data-wui-skeleton`,``),t})),a.removeAttribute(`data-wui-table-error`),l&&(l.hidden=!0)},K=e=>{e?(a.setAttribute(`aria-busy`,`true`),Ye()):a.removeAttribute(`aria-busy`)},Xe=e=>e===`forbidden`?V().forbiddenMessage:e===`networkCheck`?r(`httpFailure`,pe).networkCheckText:e===`network`?V().networkMessage:e===`timeout`?V().timeoutMessage:f.errorText,Ze=e=>{let t=Xe(e);if(a.setAttribute(`data-wui-table-error`,e),u&&(u.hidden=!0),l){let n=document.createElement(`div`);n.className=`empty-state wui-empty-state-table wui-table-error`,n.setAttribute(`role`,`alert`);let r=document.createElement(`span`);r.className=`empty-state-icon`;let i=ie(e===`forbidden`?`lock`:`alert-circle`,{size:24});i&&r.replaceChildren(i);let a=document.createElement(`div`);a.className=`empty-state-title`,a.textContent=t;let o=document.createElement(`div`);o.className=`empty-state-action`;let s=document.createElement(`button`);s.type=`button`,s.className=te(`primary`,`outline`,`sm`),s.dataset.wui=ne,s.setAttribute(`data-wui-table-retry`,``),s.textContent=V().retryLabel,o.append(s),n.append(r,a,o),B(l),l.replaceChildren(n),l.hidden=!1}R(t)},Qe=()=>f.filtersForm?U(document,f.filtersForm,HTMLFormElement):null,q=async(e,t=`none`,{quiet:r=!1}={})=>{let i=new URLSearchParams(e);r||(N={query:i,mode:t},K(!0),R(f.loadingText)),L(`wui:table:loading`,{query:i.toString()});let o=await ge.run(we(i),{timeoutMs:f.timeoutMs});if(o.kind===`aborted`||o.kind===`stale`||o.kind===`session`)return o;r||K(!1);let s=null;if(o.ok)try{s=qe(o.html)}catch(e){re(e)}if(!o.ok||!s){let e=o.ok?`server`:o.kind;return r?w(`A quiet server table refresh failed; the rows on screen are kept.`,e):Ze(e),L(`wui:table:error`,{status:o.status,kind:e,message:Xe(e)}),o}let c=Ke(s);return I=F(i,M),Ve(Qe(),I),f.urlState&&t===`push`?window.history.pushState(window.history.state,``,P(I)):f.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,P(I)),r||R(Ee(M)),D().refresh(a),c&&D().refresh(c),M.pending?nt():We(n,M.total,M.totalCapped),L(`wui:table:loaded`,{...M,query:I.toString()}),o},J=[],$e=null,et=()=>{if(J.length===0||a.getAttribute(`aria-busy`)===`true`)return;let e=J;J=[],q(I,`none`,{quiet:!0}).then(t=>{for(let n of e)n.resolve(t)},t=>{for(let n of e)n.reject(t)})},Y=async(e,t=`none`,n={})=>{let r;try{r=await q(e,t,n)}catch(e){let t=J;J=[];for(let n of t)n.reject(e);throw e}r.kind===`session`&&($e=r);let i=r.kind===`aborted`&&a.getAttribute(`aria-busy`)===`true`;if(r.kind===`session`||r.kind===`aborted`&&!i){let e=J;J=[];for(let t of e)t.resolve(r)}return et(),r},tt=e=>(e.delete(`page`),e),nt=()=>{if(!_||!M.pending)return;let e=Ge;ee(Ce(_,I),{timeoutMs:f.timeoutMs}).then(t=>{if(e!==Ge)return;if(!t.ok){w(`[@webority/ui-elements] A server table's total did not load; its pager keeps Previous and Next.`,t.kind);return}let r=U(o(t.html),`div[data-wui-total]`,HTMLElement);if(!r){w(`[@webority/ui-elements] A server table's count answer has no div[data-wui-total]; its pager keeps Previous and Next.`);return}if(G(r.dataset.page,-1)!==M.page||G(r.dataset.pageSize,-1)!==M.pageSize)return;let i=G(r.dataset.total,-1);if(i<0){w(`[@webority/ui-elements] A server table's count answer has no whole data-total; its pager keeps Previous and Next.`);return}let a=r.dataset.totalCapped===`true`,s=k&&i!==M.total;M={...M,total:i,totalCapped:a,pending:!1},s&&(k=!1);let c=U(r,`:scope > template[data-wui-pager]`,HTMLTemplateElement);c&&Ne(c);let l=He(U(r,`:scope > template[data-wui-filters]`,HTMLTemplateElement));l&&D().refresh(l),We(n,M.total,M.totalCapped),R(Ee(M)),s&&Z(),L(`wui:table:total`,{total:i,totalCapped:a})})},X=()=>H(s,`:scope > thead th[data-sort-key]`,HTMLTableCellElement),rt=()=>{for(let e of X()){let t=e.dataset.sortKey===M.sortBy;e.setAttribute(`aria-sort`,t?M.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of X())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=document.createElement(`span`);t.className=`sort-icon`;let n=ie(`chevrons-up-down`,{size:14});n&&t.replaceChildren(n),e.append(t)}let it=e=>{let t=tt(new URLSearchParams(I)),n=M.sortBy===e&&M.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),Y(t,`push`)};s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&it(t.dataset.sortKey??``)}),s.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target instanceof Element?W(e.target,`th[data-sort-key]`,HTMLTableCellElement):null;t&&s.tHead?.contains(t)&&(e.preventDefault(),it(t.dataset.sortKey??``))});let Z=()=>{ce(s),de(s);let e=k?{selected:M.total,total:M.total,allMatching:k}:{selected:O.size,total:M.total};s.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};E&&(se(s,(e,t)=>{for(let n of e){let e=W(n,`tr`,HTMLTableRowElement)?.dataset.rowKey;e&&(t?O.add(e):O.delete(e))}t||(k=!1)}),s.addEventListener(`change`,e=>{let t=e.target;if(t instanceof HTMLInputElement&&t.matches(`.wui-select-cell .form-check-input:not(:disabled)`)){if(t.checked||(k=!1),s.tHead?.contains(t))for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let n=U(e,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement);n&&(n.checked=t.checked,t.checked?O.add(e.dataset.rowKey):O.delete(e.dataset.rowKey))}else if(W(t,`tr`,HTMLTableRowElement)?.classList.contains(`wui-group-row`)){let e=W(t,`tr`,HTMLTableRowElement);for(let n=e?.nextElementSibling;n instanceof HTMLTableRowElement&&!n.matches(`tr.wui-group-row`);n=n.nextElementSibling){let e=U(n,`.${T} .form-check-input:not(:disabled)`,HTMLInputElement),r=n.dataset.rowKey;e&&r&&(e.checked=t.checked,t.checked?O.add(r):O.delete(r))}}else{let e=W(t,`tr`,HTMLTableRowElement)?.dataset.rowKey;if(!e)return;t.checked?O.add(e):O.delete(e)}Z()}})),u&&(u.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),Y(Se(t.getAttribute(`href`)??``),`push`))}),u.addEventListener(`change`,e=>{let t=e.target;t instanceof HTMLSelectElement&&t.classList.contains(`tpg-select`)&&t.value&&(e.stopPropagation(),Y(Se(t.value),`push`))}));let Q=()=>{if(!f.searchInput)return null;let e=U(document,f.searchInput,HTMLElement);return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e:e?U(e,`input`,HTMLInputElement):null},$=()=>n.isConnected?!0:(ve.abort(),clearTimeout(be??void 0),!1),at=(e,t)=>{let n=[...e.elements].filter(Fe),r=/* @__PURE__ */ new Set;for(let e of n)e.name&&!Le(e)&&r.add(e.name);let i=[];for(let e of n)if(e.name&&!Ie(e)){if(e instanceof HTMLInputElement&&e.matches(`input[type="hidden"][data-wui-carried]`))r.has(e.name)||i.push([e.name,e.value]);else if(e instanceof HTMLInputElement&&e.matches(`input[type=checkbox], input[type=radio]`))e.checked&&i.push([e.name,e.value]);else if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||i.push([e.name,e.value]);else if(e instanceof HTMLSelectElement)for(let t of e.selectedOptions)i.push([e.name,t.value])}return(t instanceof HTMLButtonElement||t instanceof HTMLInputElement)&&t.name&&!t.disabled&&i.push([t.name,t.value]),i},ot=(e,t)=>{let n=new Set([...e.elements].filter(Fe).map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&ae.includes(e);for(let[e,t]of I)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of at(e,t))a===``||i(n)||fe.has(n)||r.append(n,a);let a=Q();if(a){r.delete(oe);let e=a.value.trim();e&&r.set(oe,e)}return Y(r,`push`)},st=e=>f.filtersForm&&e.closest?.(f.filtersForm)||f.filtersRegion&&e.closest?.(f.filtersRegion)||null;document.addEventListener(`submit`,e=>{$()&&f.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(f.filtersForm)&&(e.preventDefault(),ot(e.target,e.submitter))},A),document.addEventListener(`change`,e=>{if(!$()||!f.filtersForm||!(e.target instanceof Element))return;let t=W(e.target,f.filtersForm,HTMLFormElement);!t||e.target===Q()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest(`wui-filter-popover`)||ot(t)},A);let ct=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of H(e,`input[name]:not([type=hidden])`,HTMLInputElement))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of H(e,`select[name]`,HTMLSelectElement))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of[...e.querySelectorAll(`wui-select[name]`)].filter(Re)){let e=r.getAttribute(`name`)??``;r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!$())return;let t=e.target instanceof Element?W(e.target,`a[href]`,HTMLAnchorElement):null;if(!t||!st(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=tt(Se(n.href));ct(t.closest(`form`),r),Ve(t.closest(`form`),r),Y(r,`push`)},A),document.addEventListener(`input`,e=>{if(!$())return;let t=Q();t&&e.target===t&&(clearTimeout(be??void 0),be=setTimeout(()=>{if(!$())return;let e=tt(new URLSearchParams(I)),n=t.value.trim();n?e.set(oe,n):e.delete(oe),e.toString()!==I.toString()&&Y(e,`replace`)},300))},A),f.urlState&&window.addEventListener(`popstate`,()=>{if(!$())return;let e=xe(window.location.search),t=Q();t&&(t.value=e.get(`search`)??``),Ve(Qe(),e),Y(e,`none`)},A),l?.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`[data-wui-table-retry]`)&&N&&Y(N.query,N.mode)});let lt=e=>[...j.rows].find(t=>t.dataset.rowKey===e)??null,ut=e=>{if(!e?.trim())return null;let t=o(`<table><tbody>${e}</tbody></table>`);if(t.querySelector(`tbody[data-wui-rows]`))return null;let n=H(t,`table > tbody > tr[data-row-key]`,HTMLTableRowElement);return n.length?n.map(e=>document.importNode(e,!0)):null},dt=(e,t,n)=>{let r=n?e[0]:e.find(e=>e.dataset.rowKey===t.dataset.rowKey);if(!r)return null;let i=[];for(let n of e){let e=n===r?t:lt(n.dataset.rowKey);e&&(B(e),e.replaceWith(n),i.push(n))}return ke(i),D().refresh(a),r},ft=e=>e.message||(e.kind===`forbidden`?V().actionForbiddenMessage:V().actionFailedMessage),pt=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&b(e,null)},mt=async({url:e,method:r=`POST`,body:i,key:o,row:s}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let c=o==null,u=c?null:lt(String(o));if(!c&&!u)throw Error(`saveRow found no row with data-row-key="${o}" on this page.`);let d=z().filter(e=>!e.classList.contains(T)),f=s===void 0?u??Je(Math.max(1,d.length),d):t(s,HTMLTableRowElement,"saveRow's `row` is required to be a row element: the <tr> as it will read, not its HTML.");u&&f!==u?u.replaceWith(f):u||j.insertBefore(f,j.firstChild),f!==u&&ke([f]),l&&!a.hasAttribute(`data-wui-table-error`)&&(l.hidden=!0),b(f,`saving`);let p=S(f),m=await ee(e,{method:r.toUpperCase(),body:i});if(m.kind===`session`)return!1;if(m.ok){if(!_e(n)&&he(m))return pt(f),L(`wui:table:saved`,{key:c?null:String(o),added:c,status:m.status}),await me(m,{origin:n}),!0;let e=ut(m.html),t=e&&f.isConnected?dt(e,f,c):null;return t&&R(y(S(t)||p)),Te(m,m.toastVariant||`success`),_e(n)||await me(m,{skip:t?n:null,origin:n}),pt(f),L(`wui:table:saved`,{key:t?.dataset.rowKey??(c?null:String(o)),added:c,status:m.status}),!0}let h=ft(m),g=f;return u&&f!==u&&f.isConnected?(f.replaceWith(u),g=u):c&&!s&&(f.remove(),g=null,l?.childElementCount&&!j.querySelector(`:scope > tr`)&&(l.hidden=!1)),g?.isConnected&&b(g,`error`,h),m.kind!==`aborted`&&Be(h,`danger`),R(x(p,h)),L(`wui:table:failed`,{key:c?null:String(o),added:c,status:m.status,kind:m.kind,message:h}),!1},ht=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let r=W(e,`tr`,HTMLTableRowElement),i=r?.dataset.rowKey??null,a=e.dataset.wuiRowAction||``,o=r?S(r):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),r&&b(r,`saving`);let s=await ee(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),s.kind===`session`||s.kind===`aborted`)pt(r);else if(s.ok&&!_e(e)&&he(s))pt(r),L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status}),await me(s,{origin:e});else{if(s.ok){Te(s,s.toastVariant||`success`);let t=r?.isConnected?ut(s.html):null,i=t&&r?dt(t,r,!1):null;i&&R(y(S(i)||o)),_e(e)||await me(s,{skip:i?n:null,origin:e}),pt(r)}else{let e=ft(s);Be(e,`danger`),r?.isConnected&&b(r,`error`,e),R(x(o,e))}L(`wui:table:action`,{action:a,key:i,ok:s.ok,status:s.status})}};return s.addEventListener(`click`,e=>{let t=e.target instanceof Element?W(e.target,`[data-wui-row-action]`,HTMLButtonElement):null;t&&j.contains(t)&&!t.disabled&&(e.preventDefault(),ht(t))}),De(j),je(j),E&&le(s),Ae(j),rt(),M.pending&&(R(Ee(M)),nt()),{el:n,reload:async e=>{if($e)return $e;let t=e?.quiet===!0;return t&&a.getAttribute(`aria-busy`)===`true`?new Promise((e,t)=>{J.push({resolve:e,reject:t})}):Y(I,`none`,{quiet:t})},query:()=>new URLSearchParams(I),setQuery:e=>{let t=new URLSearchParams(I);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`),Y(t,`push`)},saveRow:mt,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),Oe(H(j,`:scope > tr`,HTMLTableRowElement))},selection:{keys:()=>[...O],count:()=>k?M.total:O.size,allMatching:()=>k,selectAllMatching:()=>{if(M.pending)w(`[@webority/ui-elements] select all matching needs the total; the table is still waiting for its count.`);else{k=!0;for(let e of H(j,`:scope > tr:not(.wui-group-row)`,HTMLTableRowElement)){let t=U(e,`.${T} .form-check-input`,HTMLInputElement);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&O.add(e.dataset.rowKey))}Z()}},clear:()=>{k=!1,O.clear();for(let e of H(j,`:scope > tr > .${T} .form-check-input:not(:disabled)`,HTMLInputElement))e.checked=!1;Z()}}}}var qe=/* @__PURE__ */ new WeakSet;function Je(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(!O(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${M.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||(e.textContent??``).trim();e.remove(),n&&F(n,t)}}function Ye(e=document){let t=e instanceof Element?e.ownerDocument:e;if(!qe.has(t)){qe.add(t);let e=E();e&&F(e.message,e.variant,e.action)}Je(e)}var K=/* @__PURE__ */ new WeakMap;function Xe(e,t){K.set(e,t)}function Ze(e){K.delete(e)}function Qe(e){let t=e?.closest(`[data-app-shell]`);return(t&&K.get(t))??null}var q=()=>r(`shell`,a),J=31536e3;function $e(e,t,n,r){let i=[...e.querySelectorAll(`nav.wui-tabbar a.wui-tabbar-item`)].find(e=>e.getAttribute(`href`)===t);if(!i)throw Error(`setTabCount: no tab bar item links to ${t}.`);let a=i.querySelector(`:scope > .wui-tabbar-badge`);if(n===null||n===0){a?.remove();return}a||(a=document.createElement(`span`),i.append(a)),a.className=`wui-tabbar-badge${r?` tone-${r}`:``}`;let o=e.querySelector(`nav.wui-tabbar`)?.hasAttribute(`data-wui-cap-badges`)===!0;a.textContent=o?et(n):String(n)}var et=e=>e>99?`99+`:String(e),Y=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,()=>String(n)),e);function tt(e,t,n=document){try{n.cookie=`${e}=${t?`1`:`0`}; Path=/; Max-Age=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}function nt(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=${J}; SameSite=Lax`}catch(e){if(!(e instanceof DOMException&&e.name===`SecurityError`))throw e}}var X=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},rt=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},it=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Z=e=>{if(!(e.target instanceof Element))throw Error(`event target is not an element`);return e.target},Q=e=>{let t=e.getAttribute(`href`);if(t===null)throw Error(`search hit has no href`);return t},$=(e,t)=>{let n=document.createElement(`div`);return n.className=e,n.textContent=t,n},at=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),ot=(e,t,n)=>`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(n)}`;function st(t,r){let i=e(X(t,`input.search-input`,HTMLInputElement),`search input missing`),a=X(t,`.wui-topsearch-results`,HTMLElement),s=()=>e(a,`search results missing`),c=X(t,`.wui-topsearch-open`,HTMLElement),l=X(t,`[data-wui-topsearch-live]`,HTMLElement),{src:u,param:d=`q`,resultsHref:f}=t.dataset,ee=Number(t.dataset.minChars??2),m=Number(t.dataset.debounceMs??250),h=t.dataset.noResultsText??q().noResultsText,g=t.dataset.resultsCountText??q().resultsCountText,_=t.dataset.resultCountText??q().resultCountText,te=p(),ne,v=-1,y=()=>it(s(),`.wui-topsearch-hit`,HTMLElement),b=e=>{let t=y();v=t.length===0?-1:(e+t.length)%t.length,t.forEach((e,t)=>{let n=t===v;e.classList.toggle(`is-active`,n),e.setAttribute(`aria-selected`,n?`true`:`false`)});let n=v>=0?t[v]:void 0;n?(i.setAttribute(`aria-activedescendant`,n.id),n.scrollIntoView?.({block:`nearest`})):i.removeAttribute(`aria-activedescendant`)},x=()=>{s().hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.removeAttribute(`aria-activedescendant`),v=-1},S=()=>{s().hidden=!1,i.setAttribute(`aria-expanded`,`true`)},C=e=>{t.classList.toggle(`is-open`,e),c?.setAttribute(`aria-expanded`,e?`true`:`false`)},w=e=>{let n=new CustomEvent(`wui:search:select`,{bubbles:!0,cancelable:!0,detail:{href:e}});t.dispatchEvent(n)&&window.location.assign(e)},re=async e=>{if(t.classList.add(`is-loading`),u===void 0)throw Error(`search has no data-src`);let n=await te.run(ot(u,d,e));if(n.kind!==`aborted`&&n.kind!==`stale`&&n.kind!==`session`){if(t.classList.remove(`is-loading`),n.ok){let e=o(n.html),t=X(e,`[data-wui-count]`,HTMLElement);s().replaceChildren(e),y().forEach((e,t)=>{e.id=`${s().id}-opt-${t}`});let r=t?Number(t.getAttribute(`data-wui-count`)):y().length;l&&(l.textContent=r===0?h:Y(r===1?_:g,{count:r}))}else s().replaceChildren($(`wui-topsearch-empty`,q().searchUnavailableMessage));v=-1,S()}};i.addEventListener(`input`,()=>{clearTimeout(ne);let e=i.value.trim();e.length<ee?(te.abort(),t.classList.remove(`is-loading`),s().replaceChildren(),x()):ne=setTimeout(()=>re(e),m)}),i.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(s().hidden||y().length===0)return;e.preventDefault(),b(v+(e.key===`ArrowDown`?1:-1))}else if(n(e)){let t=y(),n=v>=0?t[v]:void 0;!s().hidden&&n?(e.preventDefault(),w(Q(n))):f&&i.value.trim()!==``&&(e.preventDefault(),w(ot(f,d,i.value.trim())))}else e.key===`Escape`&&(s().hidden?t.classList.contains(`is-open`)&&(e.preventDefault(),e.stopPropagation(),C(!1),c?.focus()):(e.preventDefault(),e.stopPropagation(),x()))}),s().addEventListener(`click`,e=>{let t=rt(Z(e),`.wui-topsearch-hit`,HTMLElement);!t||e.ctrlKey||e.metaKey||e.shiftKey||e.button===1||(e.preventDefault(),w(Q(t)))}),c?.addEventListener(`click`,()=>{let e=!t.classList.contains(`is-open`);C(e),e&&i.focus()});let ie=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||at(e.target)||(e.preventDefault(),C(!0),i.focus())},ae=e=>{e.target instanceof Node&&t.contains(e.target)||(x(),t.classList.contains(`is-open`)&&C(!1))};document.addEventListener(`keydown`,ie),document.addEventListener(`pointerdown`,ae),r.push(()=>{clearTimeout(ne),te.abort(),document.removeEventListener(`keydown`,ie),document.removeEventListener(`pointerdown`,ae)})}function ct(e){let t=[],n=e.dataset.wuiCollapsedCookie;n&&e.addEventListener(`wui:shell:collapse`,e=>{tt(n,!!e.detail?.collapsed)});let r=e.dataset.wuiFoldedCookie;r&&e.addEventListener(`wui:shell:nav-fold`,e=>{nt(r,e.detail?.key,!!e.detail?.folded)}),e.addEventListener(`click`,t=>{Z(t).closest(`[data-wui-tabbar-more]`)&&X(e,`[data-app-shell-menu]`,HTMLElement)?.click()});let i=X(e,`[data-wui-topsearch]`,HTMLElement);i&&st(i,t);let a={el:e,setTabCount(t,n,r){$e(e,t,n,r)},get collapsed(){return e.classList.contains(`collapsed`)},set collapsed(t){if(!!t===e.classList.contains(`collapsed`))return;let n=X(e,`[data-app-shell-collapse]`,HTMLElement);n?n.click():e.classList.toggle(`collapsed`,!!t)}};Xe(e,a);let o=n=>{if(n.target===e||n.target instanceof Node&&n.target.contains(e)){for(let e of t)e();Ze(e),delete e.dataset.wuiPartsWired,document.removeEventListener(`wui:teardown`,o)}};return document.addEventListener(`wui:teardown`,o),a}function lt(e=document){let t=[];e instanceof HTMLElement&&e.matches(`[data-app-shell]`)&&t.push(e),t.push(...it(e,`[data-app-shell]`,HTMLElement));for(let e of t)e.dataset.wuiPartsWired||(e.dataset.wuiPartsWired=`1`,ct(e))}function ut(e){let t=rt(e,`[data-app-shell]`,HTMLElement);return t?(Qe(t)||lt(t),Qe(t)):null}export{ke as CONFIRM_DIALOG_ID,P as CONFIRM_TONES,_ as CSRF_META_NAME,m as DEFAULT_CSRF_HEADER,Ae as DISCARD_EVENT,j as FLASH_STORAGE_KEY,M as FLASH_VARIANTS,f as HTTP_KINDS,d as TOAST_ACTION_METHODS,De as TOAST_ACTION_MS,s as WUI_HEADERS,N as WuiPostError,A as applyRefresh,g as classifyStatus,be as closeRemotePane,c as configureCsrf,L as confirmAction,Ee as createDiscardPrompt,p as createRequestQueue,I as formValues,ye as getServerTable,ut as getShell,Oe as initDrawerDiscard,Ye as initFlashToasts,B as initRemoteModals,je as initServerActions,Ge as initServerTables,lt as initShellParts,xe as initUnsavedChanges,Ne as loadRemoteDrawer,Se as loadRemoteModal,Me as loadRemotePane,o as parseServerHtml,u as parseToastAction,Ce as postAction,l as readCsrf,me as refreshAfter,k as refreshRegions,he as reloadsPage,z as resetUnsavedChanges,R as runToastAction,Te as showResultToast,F as showToast,h as timeoutFromAttribute,ee as wuiFetch,we as wuiUpload};
@@ -1 +1 @@
1
- (function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=globalThis.WeborityUiElementsInternal?.version;if(r!==`0.198.0`)throw Error(`[webority-ui] calendar-views expects ui-elements 0.198.0 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=`#view=`,l=`wui-calendar-views:view-change`,u=`wui-calendar-views:period-change`,d=[`previous`,`next`,`today`],f=`.wui-cal-views-switch input[type='radio']`,p=class extends n.ElementBase{constructor(){super(),s(this,`_onChange`,void 0),s(this,`_onClick`,void 0),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=m(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(f),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(f))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let n=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,n),h(n),this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{view:n}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),r=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&d.includes(r)&&this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:{step:r}}))}};function m(e){if(!window.location.hash.startsWith(c))return null;let t=window.location.hash.slice(6);return e.includes(t)?t:null}function h(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}(0,t.defineElement)(`wui-calendar-views`,p),e.WuiCalendarViews=p})(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.198.1`)throw Error(`[webority-ui] calendar-views expects ui-elements 0.198.1 but the page loaded `+r+`.`);function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=`#view=`,l=`wui-calendar-views:view-change`,u=`wui-calendar-views:period-change`,d=[`previous`,`next`,`today`],f=`.wui-cal-views-switch input[type='radio']`,p=class extends n.ElementBase{constructor(){super(),s(this,`_onChange`,void 0),s(this,`_onClick`,void 0),this._onChange=e=>this._choose(e),this._onClick=e=>this._step(e)}static get observedAttributes(){return[`view`]}connectedCallback(){if(this.addEventListener(`change`,this._onChange),this.addEventListener(`click`,this._onClick),!this.hasAttribute(`data-controlled`)){let e=m(this._views());e&&this.setAttribute(`view`,e)}if(!this.hasAttribute(`view`)){let e=this._views()[0];e&&this.setAttribute(`view`,e)}this._sync()}disconnectedCallback(){this.removeEventListener(`change`,this._onChange),this.removeEventListener(`click`,this._onClick)}attributeChangedCallback(){this._sync()}_views(){return Array.from(this.querySelectorAll(f),e=>e.value)}_sync(){let e=this.getAttribute(`view`)??``;for(let t of this.querySelectorAll(f))t.checked=t.value===e;for(let t of this.querySelectorAll(`:scope > .wui-cal-views-body[data-view]`))t.hidden=t.dataset.view!==e}_choose(e){let t=e.target;if(!(t instanceof HTMLInputElement)||t.type!==`radio`||!this.contains(t))return;let n=t.value;this.hasAttribute(`data-controlled`)||this.setAttribute(`view`,n),h(n),this.dispatchEvent(new CustomEvent(l,{bubbles:!0,detail:{view:n}})),this._sync()}_step(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`button[data-step]`),r=n?.getAttribute(`data-step`)??``;n&&this.contains(n)&&d.includes(r)&&this.dispatchEvent(new CustomEvent(u,{bubbles:!0,detail:{step:r}}))}};function m(e){if(!window.location.hash.startsWith(c))return null;let t=window.location.hash.slice(6);return e.includes(t)?t:null}function h(e){let t=new URL(window.location.href);t.hash=`view=${e}`,window.history.replaceState(window.history.state,``,t)}(0,t.defineElement)(`wui-calendar-views`,p),e.WuiCalendarViews=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase);
@@ -1 +1 @@
1
- (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.198.0`)throw Error(`[webority-ui] carousel expects ui-elements 0.198.0 but the page loaded `+a+`.`);var o={carouselLabel:`carousel`,dotLabel:`Go to slide`,nextLabel:`Next slide`,pauseLabel:`Pause`,playLabel:`Play`,previousLabel:`Previous slide`,slideLabel:`slide`,slideText:`{n} of {total}`,statusTextOne:`Slide {first} of {total}`,statusTextOther:`Slides {first} to {last} of {total}`};function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=()=>(0,i.readText)(`carousel`,o),f=120,p=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),u(this,`_page`,void 0),u(this,`_pages`,void 0),u(this,`_perView`,void 0),u(this,`_paused`,void 0),u(this,`_hover`,void 0),u(this,`_focus`,void 0),u(this,`_timer`,void 0),u(this,`_settleTimer`,void 0),u(this,`_status`,void 0),u(this,`_ready`,void 0),u(this,`_motion`,void 0),u(this,`_mutations`,void 0),u(this,`_resizer`,void 0),u(this,`_doc`,void 0),u(this,`_track`,void 0),u(this,`_onClick`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onEnter`,void 0),u(this,`_onLeave`,void 0),u(this,`_onFocusIn`,void 0),u(this,`_onFocusOut`,void 0),u(this,`_onVisibility`,void 0),u(this,`_onMotion`,void 0),u(this,`_tick`,void 0),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._track=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),f)},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 instanceof Node&&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(){let e=this.querySelector(`.wui-carousel-track`);if(this._track=e instanceof HTMLElement?e:null,!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let t=this.getAttribute(`data-wui-style`);if(t){for(let e of t.split(`;`)){let t=e.indexOf(`:`);t>0&&this.style.setProperty(e.slice(0,t).trim(),e.slice(t+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,this._timer!==null&&clearTimeout(this._timer),this._settleTimer!==null&&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 Math.max(e||0,0)}_slides(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);return Array.from(e.children).filter(e=>e instanceof HTMLElement&&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 instanceof Element?e.target:null)?.closest(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`),n=t instanceof HTMLElement?t:null;if(!n||!this.contains(n))return;let r=this._track;if(!r)throw Error(`WuiCarousel used before it was connected`);r.contains(n)||(n.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):n.getAttribute(`aria-disabled`)===`true`?e.preventDefault():n.classList.contains(`wui-carousel-prev`)?this.prev():n.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(n.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)}[(0,r.mirrorKey)(e.key,(0,r.isRtl)(this))];t&&(e.preventDefault(),t())}_perViewNow(){let e=``;if(typeof window<`u`){let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);e=window.getComputedStyle(t).getPropertyValue(`--wui-carousel-view`)}return Math.max(Number.parseInt(e,10)||0,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=(0,i.fillText)(d().slideText,{n:n+1,total: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`)||d().dotLabel;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;if(!e)throw Error(`WuiCarousel used before it was connected`);let 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._track;if(!t)throw Error(`WuiCarousel used before it was connected`);let n=this._slides()[this._start(this._page)];if(n){let e=this._motion?.matches?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({left:n.offsetLeft,behavior:e}):t.scrollLeft=n.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))e instanceof HTMLElement&&(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=r===a?(0,i.fillText)(d().statusTextOne,{first:r,total:n}):(0,i.fillText)(d().statusTextOther,{first:r,last:a,total: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(){this._timer!==null&&clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t instanceof HTMLElement){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||d().playLabel:this.getAttribute(`pause-label`)||d().pauseLabel,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`,p),e.WuiCarousel=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=globalThis.WeborityUiElementsInternal?.version;if(a!==`0.198.1`)throw Error(`[webority-ui] carousel expects ui-elements 0.198.1 but the page loaded `+a+`.`);var o={carouselLabel:`carousel`,dotLabel:`Go to slide`,nextLabel:`Next slide`,pauseLabel:`Pause`,playLabel:`Play`,previousLabel:`Previous slide`,slideLabel:`slide`,slideText:`{n} of {total}`,statusTextOne:`Slide {first} of {total}`,statusTextOther:`Slides {first} to {last} of {total}`};function s(e){"@babel/helpers - typeof";return s=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},s(e)}function c(e,t){if(s(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e){var t=c(e,`string`);return s(t)==`symbol`?t:t+``}function u(e,t,n){return(t=l(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=()=>(0,i.readText)(`carousel`,o),f=120,p=class extends n.ElementBase{static get observedAttributes(){return[`autoplay`]}constructor(){super(),u(this,`_page`,void 0),u(this,`_pages`,void 0),u(this,`_perView`,void 0),u(this,`_paused`,void 0),u(this,`_hover`,void 0),u(this,`_focus`,void 0),u(this,`_timer`,void 0),u(this,`_settleTimer`,void 0),u(this,`_status`,void 0),u(this,`_ready`,void 0),u(this,`_motion`,void 0),u(this,`_mutations`,void 0),u(this,`_resizer`,void 0),u(this,`_doc`,void 0),u(this,`_track`,void 0),u(this,`_onClick`,void 0),u(this,`_onKeyDown`,void 0),u(this,`_onScroll`,void 0),u(this,`_onEnter`,void 0),u(this,`_onLeave`,void 0),u(this,`_onFocusIn`,void 0),u(this,`_onFocusOut`,void 0),u(this,`_onVisibility`,void 0),u(this,`_onMotion`,void 0),u(this,`_tick`,void 0),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._track=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onScroll=()=>{this._settleTimer!==null&&clearTimeout(this._settleTimer),this._settleTimer=setTimeout(()=>this._settle(),f)},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 instanceof Node&&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(){let e=this.querySelector(`.wui-carousel-track`);if(this._track=e instanceof HTMLElement?e:null,!this._track){this.ownerDocument.readyState===`loading`&&this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.connectedCallback(),{once:!0});return}this._doc=this.ownerDocument;let t=this.getAttribute(`data-wui-style`);if(t){for(let e of t.split(`;`)){let t=e.indexOf(`:`);t>0&&this.style.setProperty(e.slice(0,t).trim(),e.slice(t+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,this._timer!==null&&clearTimeout(this._timer),this._settleTimer!==null&&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 Math.max(e||0,0)}_slides(){let e=this._track;if(!e)throw Error(`WuiCarousel used before it was connected`);return Array.from(e.children).filter(e=>e instanceof HTMLElement&&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 instanceof Element?e.target:null)?.closest(`.wui-carousel-pause, .wui-carousel-prev, .wui-carousel-next, .wui-carousel-dot`),n=t instanceof HTMLElement?t:null;if(!n||!this.contains(n))return;let r=this._track;if(!r)throw Error(`WuiCarousel used before it was connected`);r.contains(n)||(n.classList.contains(`wui-carousel-pause`)?(this._paused=!this._paused,this._hover=!1,this._focus=!1,this._sync()):n.getAttribute(`aria-disabled`)===`true`?e.preventDefault():n.classList.contains(`wui-carousel-prev`)?this.prev():n.classList.contains(`wui-carousel-next`)?this.next():this._go(Number(n.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)}[(0,r.mirrorKey)(e.key,(0,r.isRtl)(this))];t&&(e.preventDefault(),t())}_perViewNow(){let e=``;if(typeof window<`u`){let t=this._track;if(!t)throw Error(`WuiCarousel used before it was connected`);e=window.getComputedStyle(t).getPropertyValue(`--wui-carousel-view`)}return Math.max(Number.parseInt(e,10)||0,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=(0,i.fillText)(d().slideText,{n:n+1,total: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`)||d().dotLabel;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;if(!e)throw Error(`WuiCarousel used before it was connected`);let 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._track;if(!t)throw Error(`WuiCarousel used before it was connected`);let n=this._slides()[this._start(this._page)];if(n){let e=this._motion?.matches?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({left:n.offsetLeft,behavior:e}):t.scrollLeft=n.offsetLeft}this._render(!0),this._sync()}_render(e){let t=this.hasAttribute(`loop`);for(let e of this.querySelectorAll(`.wui-carousel-dot`))e instanceof HTMLElement&&(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=r===a?(0,i.fillText)(d().statusTextOne,{first:r,total:n}):(0,i.fillText)(d().statusTextOther,{first:r,last:a,total: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(){this._timer!==null&&clearTimeout(this._timer),this._timer=null;let e=this._interval(),t=this.querySelector(`.wui-carousel-pause`);if(t instanceof HTMLElement){t.hidden=e===0||this._pages<=1||!!this._motion?.matches;let n=this._paused?this.getAttribute(`play-label`)||d().playLabel:this.getAttribute(`pause-label`)||d().pauseLabel,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`,p),e.WuiCarousel=p})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.textStore);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.198.0`)throw Error(`[webority-ui] code-block expects ui-elements 0.198.0 but the page loaded `+c+`.`);Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var l=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),u=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),d=`(?![\\s\\S])`,f=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${d})`).source,p=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,u([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],m=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,u(`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`,u([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,RegExp(`(?<![\\w$])[A-Za-z_$][\\w$]*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<![\\w$])[A-Z][\\w$]*`,``)],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,u(`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`,u([`true`,`false`,`null`])],[`function`,RegExp(`(?<!\\w)[A-Za-z_]\\w*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<!\\w)[A-Z]\\w*`,``)],[`punct`,/[{}()[\];,]/]],g=[[`comment`,RegExp(`--[^\\n]*|${f}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,u(`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`,u([`true`,`false`])],[`type`,u([`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`,/[(),;]/]],_=[[`comment`,RegExp(`(?<![^\\s;|&(])#[^\\n]*`,``)],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,RegExp(`(?<![\\w-])--?[A-Za-z][\\w-]*`,``)],[`number`,RegExp(`(?<![\\w.-])\\d+(?:\\.\\d+)?\\b`,``)],[`keyword`,u([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,u(`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`,/[|&;<>(){}[\]]+/]],v=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,RegExp(`(?<=^HTTP\\/\\d(?:\\.\\d)? )\\d{3}\\b`,`m`)],[`function`,RegExp(`(?<=^[A-Z]+ )\\S+`,`m`)],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,RegExp(`(?<=^[A-Za-z][\\w-]*:[ \\t]*)[^\\n]+`,`m`)]],y=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${d})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],b=[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,RegExp(`(?<=\\s)[^\\s=<>/"']+`,``)],[`punct`,/\/?>|=/]],x={json:p,js:m,cs:h,sql:g,bash:_,http:v,css:[[`comment`,new RegExp(f)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,RegExp(`#[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:y,htmlTag:b},S=e=>(0,r.hasOwn)(x,e),C=new Map;function w(e){let t=C.get(e);if(!t){let n=x[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)},C.set(e,t)}return t}function T(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function E(e,t,n=[]){let{re:r,types:i}=w(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;T(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?E(`htmlTag`,r,n):T(n,i[s]??`plain`,r),a=o.index+r.length}return T(n,`plain`,t.slice(a)),n}function D(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return E(`http`,e);let n=t[0]??``,r=E(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?E(`json`,i,r):a===`<`?E(`html`,i,r):(T(r,`plain`,i),r)}function O(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return D(n);let r=t===`razor`?`html`:t;return!S(r)||r===`htmlTag`?[[`plain`,n]]:E(r,n)}function k(e,t){let n=[],r=[n];for(let[i,a]of O(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var A={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};function j(e){"@babel/helpers - typeof";return j=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=()=>(0,s.readText)(`codeBlock`,A);function I(e){return(0,r.hasOwn)(l,e)}var L=class extends a.ElementBase{constructor(){super(),P(this,`_title`,void 0),P(this,`_view`,void 0),P(this,`_codeEl`,void 0),P(this,`_copyIcon`,void 0),P(this,`_copyText`,void 0),P(this,`_chrome`,null),P(this,`_copied`,!1),P(this,`_observer`,null),P(this,`_timer`,0),P(this,`_cancelFrame`,null);let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}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=t!==null&&I(t)?t:`text`,r=this.getAttribute(`label`)||``,i=k(this._code(),n);this._title.textContent=r||l[n],this._view.setAttribute(`aria-label`,r||F().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>R(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=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let r=e.createElement(`button`);return r.type=`button`,r.className=`${(0,n.buttonClass)(`primary`,`ghost`,`sm`)} wui-code-copy`,r.dataset.wui=n.APP_BUTTON_MARKER,r.setAttribute(`aria-live`,`polite`),this._setCopied(!1),r.append(this._copyIcon,this._copyText),r.addEventListener(`click`,async()=>{await(0,i.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),i.COPY_FEEDBACK_MS))}),t.append(this._title,r),t}_setCopied(e){this._copied=e;let t=(0,o.glyphNode)(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||F().copiedLabel:this.getAttribute(`copy-label`)||F().copyLabel}};function R(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`,L),e.WuiCodeBlock=L})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=globalThis.WeborityUiElementsInternal?.version;if(c!==`0.198.1`)throw Error(`[webority-ui] code-block expects ui-elements 0.198.1 but the page loaded `+c+`.`);Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`]);var l=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,razor:`Razor`,css:`CSS`}),u=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),d=`(?![\\s\\S])`,f=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${d})`).source,p=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,u([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],m=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,u(`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`,u([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,RegExp(`(?<![\\w$])[A-Za-z_$][\\w$]*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<![\\w$])[A-Z][\\w$]*`,``)],[`punct`,/[{}()[\];,]/]],h=[[`comment`,RegExp(`//[^\\n]*|${f}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,u(`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`,u([`true`,`false`,`null`])],[`function`,RegExp(`(?<!\\w)[A-Za-z_]\\w*(?=\\s*\\()`,``)],[`type`,RegExp(`(?<!\\w)[A-Z]\\w*`,``)],[`punct`,/[{}()[\];,]/]],g=[[`comment`,RegExp(`--[^\\n]*|${f}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,u(`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`,u([`true`,`false`])],[`type`,u([`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`,/[(),;]/]],_=[[`comment`,RegExp(`(?<![^\\s;|&(])#[^\\n]*`,``)],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,RegExp(`(?<![\\w-])--?[A-Za-z][\\w-]*`,``)],[`number`,RegExp(`(?<![\\w.-])\\d+(?:\\.\\d+)?\\b`,``)],[`keyword`,u([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,u(`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`,/[|&;<>(){}[\]]+/]],v=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,RegExp(`(?<=^HTTP\\/\\d(?:\\.\\d)? )\\d{3}\\b`,`m`)],[`function`,RegExp(`(?<=^[A-Z]+ )\\S+`,`m`)],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,RegExp(`(?<=^[A-Za-z][\\w-]*:[ \\t]*)[^\\n]+`,`m`)]],y=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${d})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],b=[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,RegExp(`(?<=\\s)[^\\s=<>/"']+`,``)],[`punct`,/\/?>|=/]],x={json:p,js:m,cs:h,sql:g,bash:_,http:v,css:[[`comment`,new RegExp(f)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,RegExp(`#[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:y,htmlTag:b},S=e=>(0,r.hasOwn)(x,e),C=new Map;function w(e){let t=C.get(e);if(!t){let n=x[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)},C.set(e,t)}return t}function T(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function E(e,t,n=[]){let{re:r,types:i}=w(e),a=0;for(let o of t.matchAll(r)){let r=o[0];if(!r)continue;T(n,`plain`,t.slice(a,o.index));let s=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[s]===`tag`?E(`htmlTag`,r,n):T(n,i[s]??`plain`,r),a=o.index+r.length}return T(n,`plain`,t.slice(a)),n}function D(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return E(`http`,e);let n=t[0]??``,r=E(`http`,e.slice(0,t.index+n.length)),i=e.slice(t.index+n.length),a=i.trimStart()[0];return a===`{`||a===`[`?E(`json`,i,r):a===`<`?E(`html`,i,r):(T(r,`plain`,i),r)}function O(e,t){let n=String(e??``);if(!n||n.length>1e5)return n?[[`plain`,n]]:[];if(t===`http`)return D(n);let r=t===`razor`?`html`:t;return!S(r)||r===`htmlTag`?[[`plain`,n]]:E(r,n)}function k(e,t){let n=[],r=[n];for(let[i,a]of O(e,t))a.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&(n=[],r.push(n)),e&&n.push([i,e])});return r.length>1&&n.length===0&&r.pop(),r}var A={copiedLabel:`Copied`,copyLabel:`Copy`,label:`Code`};function j(e){"@babel/helpers - typeof";return j=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},j(e)}function M(e,t){if(j(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(j(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function N(e){var t=M(e,`string`);return j(t)==`symbol`?t:t+``}function P(e,t,n){return(t=N(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=()=>(0,s.readText)(`codeBlock`,A);function I(e){return(0,r.hasOwn)(l,e)}var L=class extends a.ElementBase{constructor(){super(),P(this,`_title`,void 0),P(this,`_view`,void 0),P(this,`_codeEl`,void 0),P(this,`_copyIcon`,void 0),P(this,`_copyText`,void 0),P(this,`_chrome`,null),P(this,`_copied`,!1),P(this,`_observer`,null),P(this,`_timer`,0),P(this,`_cancelFrame`,null);let e=this.ownerDocument;this._title=e.createElement(`span`),this._title.className=`wui-code-title`,this._view=e.createElement(`div`),this._codeEl=e.createElement(`code`),this._copyIcon=e.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=e.createElement(`span`)}static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}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=t!==null&&I(t)?t:`text`,r=this.getAttribute(`label`)||``,i=k(this._code(),n);this._title.textContent=r||l[n],this._view.setAttribute(`aria-label`,r||F().label),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>R(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=this._view;n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this.append(t)}_bar(e){let t=e.createElement(`div`);t.className=`wui-code-bar`;let r=e.createElement(`button`);return r.type=`button`,r.className=`${(0,n.buttonClass)(`primary`,`ghost`,`sm`)} wui-code-copy`,r.dataset.wui=n.APP_BUTTON_MARKER,r.setAttribute(`aria-live`,`polite`),this._setCopied(!1),r.append(this._copyIcon,this._copyText),r.addEventListener(`click`,async()=>{await(0,i.copyTextToClipboard)(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=window.setTimeout(()=>this._setCopied(!1),i.COPY_FEEDBACK_MS))}),t.append(this._title,r),t}_setCopied(e){this._copied=e;let t=(0,o.glyphNode)(e?`check`:`files`,{size:14});this._copyIcon.replaceChildren(...t?[t]:[]),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||F().copiedLabel:this.getAttribute(`copy-label`)||F().copyLabel}};function R(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`,L),e.WuiCodeBlock=L})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.copyText,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.iconGlyphs,WeborityUiElementsInternal.modules.textStore);
@@ -1,2 +1,2 @@
1
- (function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.198.0`)throw Error(`[webority-ui] command-palette expects ui-elements 0.198.0 but the page loaded `+o+`.`);var s={allCountText:`All ({count})`,ariaLabel:`Search`,backLabel:`Back`,emptyText:`No results`,errorRetryLabel:`Try again`,placeholder:`Search…`,recentsLabel:`Recent`,resultGroupsLabel:`Result groups`,resultsLabel:`Results`,rootLabel:`All`};function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=`[role="option"]`,p=()=>(0,i.readText)(`commandPalette`,s),m=5,h=20,g=`.wui-cmd-back, [data-depth]`,_=`[data-group-tab]`,v=`.wui-cmd-error-retry`,y=0;function b(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var x=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},S=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),C=class extends r.ElementBase{static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),d(this,`_path`,void 0),d(this,`_group`,void 0),d(this,`_crumbSig`,void 0),d(this,`_modal`,void 0),d(this,`_recentsId`,void 0),d(this,`_onModalClosed`,void 0),d(this,`_activeId`,void 0),d(this,`_lastQuery`,void 0),d(this,`_lastIds`,void 0),d(this,`_userChose`,void 0),d(this,`_onKeyDown`,void 0),d(this,`_onClick`,void 0),d(this,`_onMouseDown`,void 0),d(this,`_onMouseMove`,void 0),d(this,`_onInput`,void 0),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++y}`,this._onModalClosed=()=>{this._setKeyboard(!1),this._reset(),this.hasAttribute(`path`)&&this._restart()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=b(e.target,v);if(t&&this.contains(t)){this.dispatchEvent(new CustomEvent(`wui-command-palette:retry`,{bubbles:!0}));return}let n=b(e.target,g);if(n&&this.contains(n)){let e=n.matches(`.wui-cmd-back`)?this._path.length-1:Number(n.dataset.depth);this._goTo(this._path.slice(0,e));return}let r=b(e.target,_);if(r&&this.contains(r)){this._pickGroup(r.dataset.groupTab||null);return}let i=this._optionFrom(e.target);i&&this._select(i)},this._onMouseDown=e=>{let t=b(e.target,g),n=b(e.target,_);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,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(`wui-modal`),this._modal?.addEventListener(`wui-modal-closed`,this._onModalClosed),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`)??p().emptyText}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();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,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=globalThis.WeborityUiElementsInternal?.version;if(o!==`0.198.1`)throw Error(`[webority-ui] command-palette expects ui-elements 0.198.1 but the page loaded `+o+`.`);var s={allCountText:`All ({count})`,ariaLabel:`Search`,backLabel:`Back`,emptyText:`No results`,errorRetryLabel:`Try again`,placeholder:`Search…`,recentsLabel:`Recent`,resultGroupsLabel:`Result groups`,resultsLabel:`Results`,rootLabel:`All`};function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var f=`[role="option"]`,p=()=>(0,i.readText)(`commandPalette`,s),m=5,h=20,g=`.wui-cmd-back, [data-depth]`,_=`[data-group-tab]`,v=`.wui-cmd-error-retry`,y=0;function b(e,t){if(!(e instanceof Element))return null;let n=e.closest(t);return n instanceof HTMLElement?n:null}var x=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},S=(e,t,n)=>[...e.querySelectorAll(t)].filter(e=>e instanceof n),C=class extends r.ElementBase{static get observedAttributes(){return[`filter`,`group-filter`,`highlight`,`empty-text`,`path`,`root-label`,`recents-key`,`recents-limit`,`recents-label`]}constructor(){super(),d(this,`_path`,void 0),d(this,`_group`,void 0),d(this,`_crumbSig`,void 0),d(this,`_modal`,void 0),d(this,`_recentsId`,void 0),d(this,`_onModalClosed`,void 0),d(this,`_activeId`,void 0),d(this,`_lastQuery`,void 0),d(this,`_lastIds`,void 0),d(this,`_userChose`,void 0),d(this,`_onKeyDown`,void 0),d(this,`_onClick`,void 0),d(this,`_onMouseDown`,void 0),d(this,`_onMouseMove`,void 0),d(this,`_onInput`,void 0),this._path=[],this._group=null,this._crumbSig=null,this._modal=null,this._recentsId=`wui-cmd-recents-${++y}`,this._onModalClosed=()=>{this._setKeyboard(!1),this._reset(),this.hasAttribute(`path`)&&this._restart()},this._activeId=null,this._lastQuery=null,this._lastIds=null,this._userChose=!1,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>{let t=b(e.target,v);if(t&&this.contains(t)){this.dispatchEvent(new CustomEvent(`wui-command-palette:retry`,{bubbles:!0}));return}let n=b(e.target,g);if(n&&this.contains(n)){let e=n.matches(`.wui-cmd-back`)?this._path.length-1:Number(n.dataset.depth);this._goTo(this._path.slice(0,e));return}let r=b(e.target,_);if(r&&this.contains(r)){this._pickGroup(r.dataset.groupTab||null);return}let i=this._optionFrom(e.target);i&&this._select(i)},this._onMouseDown=e=>{let t=b(e.target,g),n=b(e.target,_);(t&&this.contains(t)||n&&this.contains(n)||this._optionFrom(e.target,!0))&&e.preventDefault()},this._onMouseMove=e=>{let t=this._optionFrom(e.target);t&&t.id!==this._activeId&&(this._setKeyboard(!1),this._userChose=!0,this._setActive(t,!1))},this._onInput=e=>{this.hasAttribute(`filter`)&&e.target===this._input()&&(this._group=null,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(`wui-modal`),this._modal?.addEventListener(`wui-modal-closed`,this._onModalClosed),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`)??p().emptyText}set emptyText(e){this.setAttribute(`empty-text`,String(e??``))}refresh(){this._renderRecents(),this._renderCrumbs(),this._syncTabs();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._setKeyboard(!1)),this._setActive(o??r[0]??null,n)}_input(){let e=this.querySelector(`[role="combobox"]`);return e instanceof HTMLInputElement?e:null}_optionFrom(e,t=!1){let n=b(e,f);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!==!1||(b(e,`[role="group"]`)?.hidden??!1)!==!1}_selectableOptions(){return S(this,f,HTMLElement).filter(e=>!this._isHidden(e)&&!this._isDisabled(e))}_setActive(e,t){this._activeId=e?e.id:null;for(let t of S(this,f,HTMLElement))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._setKeyboard(!0),this._setActive(t[r]??null,!0)}_setKeyboard(e){this.toggleAttribute(`data-keyboard`,e)}_handleKeyDown(e){let t=this._input();if(t&&e.target===t){if(e.key===`ArrowDown`||e.key===`ArrowUp`)e.preventDefault(),this._move(e.key===`ArrowDown`?1:-1);else if(e.key===`Tab`&&this._groupActive()&&this._tabs().length)e.preventDefault(),this._cycleGroup(e.shiftKey?-1:1);else if(e.key===`Backspace`&&!e.isComposing&&this._path.length&&!t.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=S(this,`.wui-cmd-page`,HTMLElement).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())}_tabs(){return S(this,_,HTMLElement)}_groupActive(){return this.hasAttribute(`group-filter`)&&this._path.length===0}_pickGroup(e){this._group=e,this._applyFilter(),this.refresh()}_cycleGroup(e){let t=this._tabs().map(e=>e.dataset.groupTab||null),n=Math.max(0,t.indexOf(this._group));this._pickGroup(t[(n+e+t.length)%t.length]??null)}_syncTabs(){if(!this.hasAttribute(`group-filter`))return;let e=x(this,`.wui-cmd-tabs`,HTMLElement);e&&(e.hidden=!this._groupActive());for(let e of this._tabs())e.setAttribute(`aria-selected`,String((e.dataset.groupTab||null)===this._group))}_restart(){this._group=null;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=x(this,`.wui-cmd-crumbs`,HTMLElement);if(!e)return;let t=this.getAttribute(`root-label`)??p().rootLabel,n=JSON.stringify([t,this._path]);if(e.hidden=this._path.length===0,n===this._crumbSig)return;this._crumbSig=n;let r=x(e,`.wui-cmd-trail`,HTMLElement);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`);if(a.className=`wui-cmd-crumb`,a.textContent=e,r)a.setAttribute(`aria-current`,`page`);else{if(!(a instanceof HTMLButtonElement))throw Error(`breadcrumb button missing`);a.type=`button`,a.dataset.depth=String(t)}return n.append(a),n}))}_recentsHost(){return x(this,`.wui-cmd-recents`,HTMLElement)}_realOptions(){let e=this._recentsHost();return S(this,f,HTMLElement).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,h):m}_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(e){if(!(e instanceof DOMException))throw e}}_renderRecents(){let e=this._recentsHost();if(!e)return;let t=this._input(),n=this._groupActive()?this._group:null,r=this._path.length===0&&!(t?.value??``).trim()?this._recentEntries().filter(e=>!n||e.g===n):[],i=this._realOptions(),a=[];for(let e of r){let t=i.find(t=>t.dataset.groupKey===e.g&&t.dataset.key===e.k);if(t&&!t.dataset.opens&&!this._isDisabled(t)&&a.push(t),a.length>=this._recentsLimit())break}if(!a.length){e.firstChild&&e.replaceChildren();return}let o=`${this._recentsId}-label`,s=document.createElement(`div`);s.className=`wui-cmd-group`,s.setAttribute(`role`,`group`),s.setAttribute(`aria-labelledby`,o);let c=document.createElement(`div`);c.className=`wui-cmd-group-label`,c.setAttribute(`role`,`presentation`),c.id=o,c.textContent=this.getAttribute(`recents-label`)??p().recentsLabel,s.append(c);for(let e of a){let t=e.cloneNode(!0);if(!(t instanceof HTMLElement))throw Error(`recent option copy is not an element`);t.id=`${this._recentsId}-${e.id}`,t.hidden=!1,t.removeAttribute(`aria-selected`),s.append(t)}e.replaceChildren(s)}_inScope(e,t){return!t||(b(e,`.wui-cmd-page`)?.dataset.page??null)===(this._path[this._path.length-1]?.key??null)}_navigate(e){window.location.assign(e)}_applyFilter(){let e=this._input(),t=(e?e.value:``).trim(),r=t.toLowerCase(),i=this.highlight,o=S(this,`.wui-cmd-page`,HTMLElement),s=o.length>0,c=this._path[this._path.length-1]?.key??null;for(let e of o)e.hidden=e.dataset.page!==c;let l=this._groupActive()?this._group:null,u=0;for(let e of this._realOptions()){let o=x(e,`.wui-cmd-item-label`,HTMLElement),c=e.dataset.label??o?.textContent??``,d=(e.dataset.keywords??``).split(/\s+/).filter(Boolean),f=!r||c.toLowerCase().includes(r)||d.some(e=>e.toLowerCase().includes(r)),p=this._inScope(e,s)&&(!l||e.dataset.groupKey===l)&&f;e.hidden=!p,p&&u++,o&&o.replaceChildren(...(0,a.matchSegments)(c,i?t:``).map(e=>e.match?(0,n.make)(`mark`,{class:`wui-cmd-mark`},e.text):e.text))}let d=this._recentsHost();for(let e of S(this,`[role="group"]`,HTMLElement))d?.contains(e)||(e.hidden=!S(e,f,HTMLElement).some(e=>!e.hidden));let p=x(this,`[role="listbox"]`,HTMLElement);p&&(p.hidden=u===0||x(this,`.wui-cmd-error`,HTMLElement)!==null);let m=x(this,`.wui-cmd-empty`,HTMLElement);m&&(m.textContent=r&&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(`wui-modal-closed`,this._onModalClosed),this._modal=null}};(0,t.defineElement)(`wui-command-palette`,C),e.WuiCommandPalette=C})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.textMatch);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var g=globalThis.WeborityUiElementsInternal?.version;if(g!==`0.198.0`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.198.0 but the page loaded `+g+`.`);var _=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),v=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),y={addReactionLabel:`Add a reaction`,attachmentsLabel:`Attachments`,cancelLabel:`Cancel`,chooseReactionLabel:`Choose a reaction`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,deleteConfirmText:`Delete this comment?`,deleteLabel:`Delete`,deletedText:`This comment was deleted.`,doneDeleteText:`Comment deleted.`,doneEditText:`Comment saved.`,donePostText:`Comment posted.`,doneReplyText:`Reply posted.`,editCommentLabel:`Edit comment`,editLabel:`Edit`,editedLabel:`Edited`,emptyBodyMessage:`Write something first.`,failedClientMessage:`This did not go through. Refresh the page and try again.`,failedServerMessage:`Something went wrong on our side. Try again in a moment.`,forbiddenMessage:`You do not have permission to do this.`,internalLabel:`Internal note`,label:`Comments`,noCommentsText:`No comments yet.`,peopleLabel:`People`,postLabel:`Comment`,reactionsLabel:`Reactions`,repliesToLabel:`Replies to {name}`,replyLabel:`Reply`,replyPlaceholder:`Write a reply`,replyToText:`Reply to {author}`,saveLabel:`Save`,validationMessage:`This was not accepted. Check it and try again.`},b={foundTextOne:`1 person. Up and down to choose, Enter to mention.`,foundTextOther:`{count} people. Up and down to choose, Enter to mention.`,helpLabel:`More information`,listNameLabel:`People`,mentioned:`Mentioned {label}.`,noMatchLabel:`No one matches`,searchFailedMessage:`Couldn't load people. Keep typing to try again.`,searchingLabel:`Searching…`};function x(e){"@babel/helpers - typeof";return x=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},x(e)}function S(e,t){if(x(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(x(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function C(e){var t=S(e,`string`);return x(t)==`symbol`?t:t+``}function w(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var T=()=>(0,l.readText)(`mentionInput`,b),E=`[data-wui-control]`,D=`[data-wui-field]`,O=`[data-wui-menu]`,k=`[data-wui-live]`,A=0,j=e=>!!(e&&h.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,h.mentionLabel)(e.label)!==``);function M(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function N(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function P(e,t){t.readOnly=(0,d.isReadOnly)(e)||e.hasAttribute(`loading`)}function F(e){let t=e.ownerDocument;e.id||=`wui-mention-${++A}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control 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`),P(e,n),M(e,n),N(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`)??T().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var I=class extends r.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),w(this,`_wired`,void 0),w(this,`_pendingValue`,void 0),w(this,`_text`,void 0),w(this,`_mentions`,void 0),w(this,`_peopleProp`,void 0),w(this,`_declared`,void 0),w(this,`_loading`,void 0),w(this,`_searchFailed`,void 0),w(this,`_query`,void 0),w(this,`_results`,void 0),w(this,`_active`,void 0),w(this,`_timer`,void 0),w(this,`_searchSeq`,void 0),w(this,`_lastSearch`,void 0),w(this,`_abort`,void 0),w(this,`_onMenuDown`,void 0),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if((0,i.hasOwn)(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(E)||F(this);let e=this._requireControl();N(this,e);let t=this.querySelector(D)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(P(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(P(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?M(this,r):e===`class`?N(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,h.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(j):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(E)}_menu(){return this.querySelector(O)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=(0,h.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(D);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,d.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.charAt(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,h.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)}`,a=await(0,c.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=(0,s.parseServerHtml)(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(j),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&(0,a.isPopoverOpen)(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=(0,h.mentionLabel)(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?T().searchingLabel:this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}(0,a.openAnchoredPopover)(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?(0,l.pluralText)(T(),`foundText`,this._results.length,{count:(0,f.formatNumber)(this._results.length,{decimals:0})}):this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel}.`)}_syncState(){let e=this._control();e&&(0,d.syncFieldState)(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=(0,a.isPopoverOpen)(e);(0,a.closeAnchoredPopover)(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,m.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if(((0,p.isImeSafeEnter)(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}(0,p.isImeSafeEnter)(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,h.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((0,l.fillText)(T().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(k);t&&(t.textContent=``,t.textContent=e)}},L=`[data-wui-items]`,R=`[data-wui-picker]`,z=`[data-wui-composer]`,B=`[data-wui-comment]`,V=`[data-wui-live]`,H=()=>(0,l.readText)(`commentThread`,y),U=e=>({forbidden:H().forbiddenMessage,networkCheck:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:H().failedClientMessage,validation:H().validationMessage,server:H().failedServerMessage,network:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkText})[e],W=e=>({post:H().donePostText,reply:H().doneReplyText,edit:H().doneEditText,delete:H().doneDeleteText,react:``})[e],G=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:H().failedServerMessage},K=e=>e instanceof Element?e:null,q=e=>`disabled`in e&&e.disabled===!0,J=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},Y=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},Z=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Q=class extends r.ElementBase{constructor(){super(),w(this,`_wired`,void 0),w(this,`_busy`,void 0),w(this,`_peopleProp`,void 0),w(this,`_pickerFor`,void 0),w(this,`_openers`,void 0),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)}connectedCallback(){if((0,i.hasOwn)(this,`people`)){let e=this.people;Reflect.deleteProperty(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),customElements.upgrade(this);let e=Y(this,`${z} wui-mention-input`,I);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:Z(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).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:_}_onClick(e){let t=X(K(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!q(t)){let e=t.closest(R),n=e?this._pickerFor?.comment:t.closest(B);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=X(K(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||q(n))return;let r=n.closest(B);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`:{let e=J(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=Y(this,R,HTMLElement),n=K(e.target),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));if(this._pickerFor&&t?.contains(n)){let i=Z(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=X(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(B),!0))}_onSubmitKey(e){let t=Y(X(K(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!q(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=Y(e,`:scope > [data-wui-reply]`,HTMLElement);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:(0,l.fillText)(H().replyToText,{author:r}),placeholder:H().replyPlaceholder,value:``,send:H().replyLabel,opener:t})}_openEditor(e,t){let n=Y(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=Y(J(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:H().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:H().saveLabel,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`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,H().cancelLabel));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,r,i,a){let o=this.ownerDocument.createElement(`button`);return o.type=`button`,o.className=(0,n.buttonClass)(e,t,r),o.dataset.wui=n.APP_BUTTON_MARKER,o.setAttribute(`data-wui-action`,i),o.textContent=a,o}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=Y(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=Y(e,`:scope > .wui-comment-row`,HTMLElement),n=Y(t,`[data-wui-comment-confirm]`,HTMLElement),r=Y(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),Y(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=Y(e,`:scope > .wui-comment-row`,HTMLElement),r=Y(n,`[data-wui-comment-confirm]`,HTMLElement),i=Y(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&Y(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=Y(this,R,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),(0,a.openAnchoredPopover)(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),Y(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=Y(this,R,HTMLElement);n&&(0,a.closeAnchoredPopover)(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=Y(this,R,HTMLElement),t=this._pickerFor;!t||e&&(0,a.isPopoverOpen)(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_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=X(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,H().emptyBodyMessage),n?.focus();return}let i=t.closest(B);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:J(i,`comment`).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??Y(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).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),W(e)&&this._announce(W(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:G(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:H().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,c.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||U(r.kind)||H().failedServerMessage}}_swapItems(e){let t=Y(this,L,HTMLElement);if(!t||!e.trim())return;let n=(0,s.parseServerHtml)(e),r=Y(n,L,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!q(i))return;let a=e=>e?Z(this,B,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>Y(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=Y(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=Y(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=Z(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??Y(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=Y(this,`${z} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=Y(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=Y(this,`:scope > ${V}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,I),(0,t.defineElement)(`wui-comment-thread`,Q),e.COMMENT_INTENTS=v,e.COMMENT_REACTIONS=_,e.WuiCommentThread=Q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.mentionText);
1
+ (function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var g=globalThis.WeborityUiElementsInternal?.version;if(g!==`0.198.1`)throw Error(`[webority-ui] comment-thread expects ui-elements 0.198.1 but the page loaded `+g+`.`);var _=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),v=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),y={addReactionLabel:`Add a reaction`,attachmentsLabel:`Attachments`,cancelLabel:`Cancel`,chooseReactionLabel:`Choose a reaction`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,deleteConfirmText:`Delete this comment?`,deleteLabel:`Delete`,deletedText:`This comment was deleted.`,doneDeleteText:`Comment deleted.`,doneEditText:`Comment saved.`,donePostText:`Comment posted.`,doneReplyText:`Reply posted.`,editCommentLabel:`Edit comment`,editLabel:`Edit`,editedLabel:`Edited`,emptyBodyMessage:`Write something first.`,failedClientMessage:`This did not go through. Refresh the page and try again.`,failedServerMessage:`Something went wrong on our side. Try again in a moment.`,forbiddenMessage:`You do not have permission to do this.`,internalLabel:`Internal note`,label:`Comments`,noCommentsText:`No comments yet.`,peopleLabel:`People`,postLabel:`Comment`,reactionsLabel:`Reactions`,repliesToLabel:`Replies to {name}`,replyLabel:`Reply`,replyPlaceholder:`Write a reply`,replyToText:`Reply to {author}`,saveLabel:`Save`,validationMessage:`This was not accepted. Check it and try again.`},b={foundTextOne:`1 person. Up and down to choose, Enter to mention.`,foundTextOther:`{count} people. Up and down to choose, Enter to mention.`,helpLabel:`More information`,listNameLabel:`People`,mentioned:`Mentioned {label}.`,noMatchLabel:`No one matches`,searchFailedMessage:`Couldn't load people. Keep typing to try again.`,searchingLabel:`Searching…`};function x(e){"@babel/helpers - typeof";return x=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},x(e)}function S(e,t){if(x(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(x(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function C(e){var t=S(e,`string`);return x(t)==`symbol`?t:t+``}function w(e,t,n){return(t=C(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var T=()=>(0,l.readText)(`mentionInput`,b),E=`[data-wui-control]`,D=`[data-wui-field]`,O=`[data-wui-menu]`,k=`[data-wui-live]`,A=0,j=e=>!!(e&&h.MENTION_ID_PATTERN.test(String(e.value??``))&&(0,h.mentionLabel)(e.label)!==``);function M(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function N(e,t){t.classList.toggle(`wui-input-underline`,e.classList.contains(`wui-input-underline`))}function P(e,t){t.readOnly=(0,d.isReadOnly)(e)||e.hasAttribute(`loading`)}function F(e){let t=e.ownerDocument;e.id||=`wui-mention-${++A}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control 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`),P(e,n),M(e,n),N(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`)??T().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var I=class extends r.ElementBase{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`class`,`aria-invalid`,`aria-describedby`]}constructor(){super(),w(this,`_wired`,void 0),w(this,`_pendingValue`,void 0),w(this,`_text`,void 0),w(this,`_mentions`,void 0),w(this,`_peopleProp`,void 0),w(this,`_declared`,void 0),w(this,`_loading`,void 0),w(this,`_searchFailed`,void 0),w(this,`_query`,void 0),w(this,`_results`,void 0),w(this,`_active`,void 0),w(this,`_timer`,void 0),w(this,`_searchSeq`,void 0),w(this,`_lastSearch`,void 0),w(this,`_abort`,void 0),w(this,`_onMenuDown`,void 0),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if((0,i.hasOwn)(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(E)||F(this);let e=this._requireControl();N(this,e);let t=this.querySelector(D)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(P(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(P(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?M(this,r):e===`class`?N(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return(0,h.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(j):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(E)}_menu(){return this.querySelector(O)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=(0,h.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(D);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||(0,d.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.charAt(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,h.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)}`,a=await(0,c.wuiFetch)(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=(0,s.parseServerHtml)(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(j),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&(0,a.isPopoverOpen)(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=(0,h.mentionLabel)(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?T().searchingLabel:this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}(0,a.openAnchoredPopover)(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?(0,l.pluralText)(T(),`foundText`,this._results.length,{count:(0,f.formatNumber)(this._results.length,{decimals:0})}):this._searchFailed?T().searchFailedMessage:`${T().noMatchLabel}.`)}_syncState(){let e=this._control();e&&(0,d.syncFieldState)(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=(0,a.isPopoverOpen)(e);(0,a.closeAnchoredPopover)(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);(0,m.moveActiveRow)(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if(((0,p.isImeSafeEnter)(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}(0,p.isImeSafeEnter)(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=(0,h.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((0,l.fillText)(T().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(k);t&&(t.textContent=``,t.textContent=e)}},L=`[data-wui-items]`,R=`[data-wui-picker]`,z=`[data-wui-composer]`,B=`[data-wui-comment]`,V=`[data-wui-live]`,H=()=>(0,l.readText)(`commentThread`,y),U=e=>({forbidden:H().forbiddenMessage,networkCheck:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkCheckText,client:H().failedClientMessage,validation:H().validationMessage,server:H().failedServerMessage,network:(0,l.readText)(`httpFailure`,u.HTTP_FAILURE_TEXT).networkText})[e],W=e=>({post:H().donePostText,reply:H().doneReplyText,edit:H().doneEditText,delete:H().doneDeleteText,react:``})[e],G=e=>{let t=typeof e==`object`&&e&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:H().failedServerMessage},K=e=>e instanceof Element?e:null,q=e=>`disabled`in e&&e.disabled===!0,J=(e,t)=>{if(e==null)throw Error(`${t} missing`);return e},Y=(e,t,n)=>{let r=e?.querySelector(t);return r instanceof n?r:null},X=(e,t,n)=>{let r=e?.closest(t);return r instanceof n?r:null},Z=(e,t,n)=>e?[...e.querySelectorAll(t)].filter(e=>e instanceof n):[],Q=class extends r.ElementBase{constructor(){super(),w(this,`_wired`,void 0),w(this,`_busy`,void 0),w(this,`_peopleProp`,void 0),w(this,`_pickerFor`,void 0),w(this,`_openers`,void 0),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)}connectedCallback(){if((0,i.hasOwn)(this,`people`)){let e=this.people;Reflect.deleteProperty(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),customElements.upgrade(this);let e=Y(this,`${z} wui-mention-input`,I);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:Z(this,`:scope > [data-wui-people] > wui-option`,HTMLElement).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:_}_onClick(e){let t=X(K(e.target),`[data-wui-emoji]`,HTMLElement);if(t&&this.contains(t)&&!q(t)){let e=t.closest(R),n=e?this._pickerFor?.comment:t.closest(B);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=X(K(e.target),`[data-wui-action]`,HTMLElement);if(!n||!this.contains(n)||q(n))return;let r=n.closest(B);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`:{let e=J(r,`comment`);this._send(`delete`,{commentId:e.getAttribute(`data-wui-comment`)},{comment:e,scope:e});break}case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=Y(this,R,HTMLElement),n=K(e.target),r=(0,o.mirrorKey)(e.key,(0,o.isRtl)(this));if(this._pickerFor&&t?.contains(n)){let i=Z(t,`[data-wui-emoji]`,HTMLElement),a=n instanceof HTMLElement?i.indexOf(n):-1;e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):r===`ArrowRight`||r===`ArrowLeft`?(e.preventDefault(),i[(a+(r===`ArrowRight`?1:-1)+i.length)%i.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let i=X(n,`[data-wui-reply], [data-wui-editor]`,HTMLElement);if(i&&this.contains(i)){e.preventDefault(),e.stopPropagation(),this._closeSlot(i,!0);return}let a=X(n,`[data-wui-comment-confirm]`,HTMLElement);a&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(a.closest(B),!0))}_onSubmitKey(e){let t=Y(X(K(e.target),`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement),`[data-wui-action="send"], [data-wui-action="post"]`,HTMLElement);t&&!q(t)&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=Y(e,`:scope > [data-wui-reply]`,HTMLElement);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:(0,l.fillText)(H().replyToText,{author:r}),placeholder:H().replyPlaceholder,value:``,send:H().replyLabel,opener:t})}_openEditor(e,t){let n=Y(e,`:scope > .wui-comment-row [data-wui-editor]`,HTMLElement);if(!n?.hidden)return;let r=Y(J(n.parentElement,`comment row`),`:scope > [data-wui-text]`,HTMLElement);r&&(r.hidden=!0),this._fillSlot(n,{label:H().editCommentLabel,placeholder:``,value:e?.getAttribute(`data-value`)??``,send:H().saveLabel,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`]){let t=this.getAttribute(e);t!=null&&s.setAttribute(e,t)}let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,H().cancelLabel));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,r,i,a){let o=this.ownerDocument.createElement(`button`);return o.type=`button`,o.className=(0,n.buttonClass)(e,t,r),o.dataset.wui=n.APP_BUTTON_MARKER,o.setAttribute(`data-wui-action`,i),o.textContent=a,o}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=Y(e.parentElement,`:scope > [data-wui-text]`,HTMLElement);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=Y(e,`:scope > .wui-comment-row`,HTMLElement),n=Y(t,`[data-wui-comment-confirm]`,HTMLElement),r=Y(t,`[data-wui-actions]`,HTMLElement);n&&(n.hidden=!1,r&&(r.hidden=!0),Y(n,`[data-wui-action="cancel-delete"]`,HTMLElement)?.focus())}_closeConfirm(e,t){let n=Y(e,`:scope > .wui-comment-row`,HTMLElement),r=Y(n,`[data-wui-comment-confirm]`,HTMLElement),i=Y(n,`[data-wui-actions]`,HTMLElement);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&Y(i,`[data-wui-action="delete"]`,HTMLElement)?.focus()}_openPicker(e,t){let n=Y(this,R,HTMLElement);n&&e&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:e,button:t},t.setAttribute(`aria-expanded`,`true`),(0,a.openAnchoredPopover)(t,n,{mode:`auto`,onClosed:()=>this._pickerClosed()}),Y(n,`[data-wui-emoji]`,HTMLElement)?.focus())}_closePicker(e){let t=this._pickerFor;if(!t)return;let n=Y(this,R,HTMLElement);n&&(0,a.closeAnchoredPopover)(n),this._pickerClosed(),e&&t.button.isConnected&&t.button.focus()}_pickerClosed(){let e=Y(this,R,HTMLElement),t=this._pickerFor;!t||e&&(0,a.isPopoverOpen)(e)||(this._pickerFor=null,t.button.setAttribute(`aria-expanded`,`false`))}_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=X(e,`[data-wui-reply], [data-wui-editor], [data-wui-composer]`,HTMLElement);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,H().emptyBodyMessage),n?.focus();return}let i=t.closest(B);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:J(i,`comment`).getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:J(i,`comment`).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??Y(n,`:scope > .wui-comment-row`,HTMLElement)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>e instanceof HTMLButtonElement||e instanceof HTMLTextAreaElement).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),W(e)&&this._announce(W(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:G(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:H().failedClientMessage};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await(0,c.wuiFetch)(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||U(r.kind)||H().failedServerMessage}}_swapItems(e){let t=Y(this,L,HTMLElement);if(!t||!e.trim())return;let n=(0,s.parseServerHtml)(e),r=Y(n,L,HTMLElement);t.replaceChildren(...r?r.childNodes:n.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!q(i))return;let a=e=>e?Z(this,B,HTMLElement).find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>Y(a(e),`:scope > .wui-comment-row`,HTMLElement),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=Y(o(t.parentId),`[data-wui-action="reply"]`,HTMLElement);else if(e===`edit`)s=Y(o(t.commentId),`[data-wui-action="edit"]`,HTMLElement);else if(e===`react`){let e=o(t.commentId);s=Z(e,`button[data-wui-emoji]`,HTMLButtonElement).find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??Y(e,`[data-wui-action="react-menu"]`,HTMLElement)}s??=Y(this,`${z} textarea`,HTMLTextAreaElement),s?.focus()}_showError(e,t){let n=Y(e,`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`,HTMLElement);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=Y(this,`:scope > ${V}`,HTMLElement);t&&e&&(t.textContent=``,t.textContent=e)}};(0,t.defineElement)(`wui-mention-input`,I),(0,t.defineElement)(`wui-comment-thread`,Q),e.COMMENT_INTENTS=v,e.COMMENT_REACTIONS=_,e.WuiCommentThread=Q})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.hasOwn,WeborityUiElementsInternal.modules.nativeOverlay,WeborityUiElementsInternal.modules.rtl,WeborityUiElementsInternal.modules.serverHtml,WeborityUiElementsInternal.modules.wuiHttp,WeborityUiElementsInternal.modules.textStore,WeborityUiElementsInternal.modules.httpFailureText,WeborityUiElementsInternal.modules.fieldState,WeborityUiElementsInternal.modules.formatters,WeborityUiElementsInternal.modules.imeSafeEnter,WeborityUiElementsInternal.modules.listboxKeyNav,WeborityUiElementsInternal.modules.mentionText);
@@ -1 +1 @@
1
- (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.198.0`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.198.0 but the page loaded `+s+`.`);var c={"--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`},l=e=>`var(${e}, ${c[e]})`,u=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${l(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${l(`--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: ${l(`--color-surface`)}; border: 1px solid ${l(`--color-border`)}; border-radius: ${l(`--wui-radius-lg`)}; box-shadow: ${l(`--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: ${l(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${l(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${l(`--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 ${l(`--color-border`)}; border-bottom: 1px solid ${l(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${l(`--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: ${l(`--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: ${l(`--color-primary`)}; background: ${l(`--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 ${l(`--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 ${l(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${l(`--color-primary`)}; border-color: ${l(`--color-primary`)}; color: ${l(`--color-on-primary`)}; } .btn-primary:hover { background: ${l(`--color-primary-hover`)}; border-color: ${l(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${l(`--color-text-muted`)}; color: ${l(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${l(`--color-bg-muted`)}; color: ${l(`--color-text`)}; } .btn-link { font-weight: 400; color: ${l(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${l(`--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; } } `,d={acceptLabel:`Accept all`,analyticsDescription:`Help us understand how visitors use the site.`,analyticsLabel:`Analytics cookies`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,essentialDescription:`Required for the site to work and stay secure. Always on.`,essentialLabel:`Essential cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,functionalLabel:`Functional cookies`,heading:`Cookies on this site`,marketingDescription:`Measure how well our campaigns work.`,marketingLabel:`Marketing cookies`,policyLabel:`Cookie policy`,rejectLabel:`Reject all`,saveLabel:`Save preferences`,settingsLabel:`Cookie settings`},f=`data-wui-tour-open`;function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=`wui-consent-save`,v=`[data-consent-settings]`,y=`tour-open`,b=`--wui-consent-banner-block`,x=`--wui-consent-banner-inline`,S=()=>(0,o.readText)(`consentBanner`,d),C=[`analytics`,`functional`,`marketing`],w={analytics:{label:`analyticsLabel`,description:`analyticsDescription`},functional:{label:`functionalLabel`,description:`functionalDescription`},marketing:{label:`marketingLabel`,description:`marketingDescription`}};function T(e){return C.some(t=>t===e)}var E=new Set;function D(e){E.has(e)||(E.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${C.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var O=0,k=null;function A(e){k||(k=new CSSStyleSheet,k.replaceSync(u)),e.adoptedStyleSheets=[k]}var j=class extends a.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g(this,`_uid`,void 0),g(this,`_preferences`,void 0),g(this,`_settings`,void 0),g(this,`_onDocumentClick`,void 0),g(this,`_tourWatch`,void 0),g(this,`_roomObserver`,void 0),g(this,`_onWindowResize`,void 0),g(this,`_rendered`,void 0),O+=1,this._uid=`wui-consent-${O}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(v)&&(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`)||S().heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||S().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`)||S().policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||S().analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||S().functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||S().marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...C];let t=e.split(/\s+/).filter(Boolean);for(let e of t)T(e)||D(e);let n=C.filter(e=>t.includes(e));return n.length?n:[...C]}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(C.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:[f]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(y,document.documentElement.hasAttribute(f))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?(0,i.make)(`a`,{class:`wui-consent-banner-policy`,href:this.policyHref},this.policyLabel):null,a=this._root();a instanceof ShadowRoot&&A(a),a.replaceChildren((0,i.make)(`div`,{class:`wui-consent-banner-panel`,role:`dialog`,"aria-labelledby":`${t}-heading`,"aria-describedby":`${t}-description`,hidden:!0},(0,i.make)(`h2`,{class:`wui-consent-banner-heading`,id:`${t}-heading`},this.heading),(0,i.make)(`p`,{class:`wui-consent-banner-description`,id:`${t}-description`},r?`${this.description} `:this.description,r),(0,i.make)(`div`,{class:`wui-consent-banner-settings`,hidden:!0},M(t,`essential`,S().essentialLabel,S().essentialDescription,!0),...this.categories.map(e=>M(t,e,S()[w[e].label],this[w[e].description],!1))),(0,i.make)(`div`,{class:`wui-consent-banner-actions`},(0,i.make)(`button`,{type:`button`,class:`btn btn-sm btn-link wui-consent-banner-settings-toggle`,"aria-expanded":`false`},S().settingsLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`neutral`,`outline`,`sm`)} wui-consent-banner-reject`,"data-wui":n.APP_BUTTON_MARKER},S().rejectLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-accept`,"data-wui":n.APP_BUTTON_MARKER},S().acceptLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-save`,hidden:!0,"data-wui":n.APP_BUTTON_MARKER},S().saveLabel)))),this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._requirePanel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){if(this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._requirePanel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t){let t=e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`);t instanceof HTMLElement&&t.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(b),document.documentElement.style.removeProperty(x)}_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(b,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(x,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){let e=this._root().querySelector(`.wui-consent-banner-panel`);return e instanceof HTMLElement?e:null}_requirePanel(){let e=this._panel();if(!e)throw Error(`consent banner panel is missing`);return e}_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(_,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return{analytics:e&&t.includes(`analytics`),functional:e&&t.includes(`functional`),marketing:e&&t.includes(`marketing`)}}_switchValues(){let e={analytics:!1,functional:!1,marketing:!1};for(let t of C){let n=this._root().querySelector(`input[data-category="${t}"]`);e[t]=n instanceof HTMLInputElement&&n.checked}return e}_applyPreferences(){for(let e of C){let t=this._root().querySelector(`input[data-category="${e}"]`);t instanceof HTMLInputElement&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!(n instanceof HTMLElement))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 instanceof HTMLElement&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r instanceof HTMLElement&&(r.hidden=e)}}};function M(e,t,n,r,a){let o=`${e}-${t}`;return(0,i.make)(`div`,{class:`wui-consent-banner-category`},(0,i.make)(`div`,{class:`form-check form-switch`},(0,i.make)(`input`,{class:`form-check-input`,type:`checkbox`,role:`switch`,id:o,"data-category":t,checked:a,disabled:a}),(0,i.make)(`label`,{class:`form-check-label`,for:o},n)),(0,i.make)(`p`,{class:`wui-consent-banner-category-description`},r))}(0,t.defineElement)(`wui-consent-banner`,j),e.WuiConsentBanner=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);
1
+ (function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=globalThis.WeborityUiElementsInternal?.version;if(s!==`0.198.1`)throw Error(`[webority-ui] consent-banner expects ui-elements 0.198.1 but the page loaded `+s+`.`);var c={"--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`},l=e=>`var(${e}, ${c[e]})`,u=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${l(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${l(`--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: ${l(`--color-surface`)}; border: 1px solid ${l(`--color-border`)}; border-radius: ${l(`--wui-radius-lg`)}; box-shadow: ${l(`--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: ${l(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${l(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${l(`--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 ${l(`--color-border`)}; border-bottom: 1px solid ${l(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${l(`--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: ${l(`--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: ${l(`--color-primary`)}; background: ${l(`--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 ${l(`--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 ${l(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${l(`--color-primary`)}; border-color: ${l(`--color-primary`)}; color: ${l(`--color-on-primary`)}; } .btn-primary:hover { background: ${l(`--color-primary-hover`)}; border-color: ${l(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${l(`--color-text-muted`)}; color: ${l(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${l(`--color-bg-muted`)}; color: ${l(`--color-text`)}; } .btn-link { font-weight: 400; color: ${l(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${l(`--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; } } `,d={acceptLabel:`Accept all`,analyticsDescription:`Help us understand how visitors use the site.`,analyticsLabel:`Analytics cookies`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,essentialDescription:`Required for the site to work and stay secure. Always on.`,essentialLabel:`Essential cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,functionalLabel:`Functional cookies`,heading:`Cookies on this site`,marketingDescription:`Measure how well our campaigns work.`,marketingLabel:`Marketing cookies`,policyLabel:`Cookie policy`,rejectLabel:`Reject all`,saveLabel:`Save preferences`,settingsLabel:`Cookie settings`},f=`data-wui-tour-open`;function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=`wui-consent-save`,v=`[data-consent-settings]`,y=`tour-open`,b=`--wui-consent-banner-block`,x=`--wui-consent-banner-inline`,S=()=>(0,o.readText)(`consentBanner`,d),C=[`analytics`,`functional`,`marketing`],w={analytics:{label:`analyticsLabel`,description:`analyticsDescription`},functional:{label:`functionalLabel`,description:`functionalDescription`},marketing:{label:`marketingLabel`,description:`marketingDescription`}};function T(e){return C.some(t=>t===e)}var E=new Set;function D(e){E.has(e)||(E.add(e),(0,r.devWarn)(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${C.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var O=0,k=null;function A(e){k||(k=new CSSStyleSheet,k.replaceSync(u)),e.adoptedStyleSheets=[k]}var j=class extends a.ElementBase{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),g(this,`_uid`,void 0),g(this,`_preferences`,void 0),g(this,`_settings`,void 0),g(this,`_onDocumentClick`,void 0),g(this,`_tourWatch`,void 0),g(this,`_roomObserver`,void 0),g(this,`_onWindowResize`,void 0),g(this,`_rendered`,void 0),O+=1,this._uid=`wui-consent-${O}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(v)&&(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`)||S().heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||S().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`)||S().policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||S().analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||S().functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||S().marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...C];let t=e.split(/\s+/).filter(Boolean);for(let e of t)T(e)||D(e);let n=C.filter(e=>t.includes(e));return n.length?n:[...C]}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(C.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:[f]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(y,document.documentElement.hasAttribute(f))}attributeChangedCallback(){this._rendered&&this.render()}render(){let e=this.isOpen,t=this._uid,r=this.policyHref?(0,i.make)(`a`,{class:`wui-consent-banner-policy`,href:this.policyHref},this.policyLabel):null,a=this._root();a instanceof ShadowRoot&&A(a),a.replaceChildren((0,i.make)(`div`,{class:`wui-consent-banner-panel`,role:`dialog`,"aria-labelledby":`${t}-heading`,"aria-describedby":`${t}-description`,hidden:!0},(0,i.make)(`h2`,{class:`wui-consent-banner-heading`,id:`${t}-heading`},this.heading),(0,i.make)(`p`,{class:`wui-consent-banner-description`,id:`${t}-description`},r?`${this.description} `:this.description,r),(0,i.make)(`div`,{class:`wui-consent-banner-settings`,hidden:!0},M(t,`essential`,S().essentialLabel,S().essentialDescription,!0),...this.categories.map(e=>M(t,e,S()[w[e].label],this[w[e].description],!1))),(0,i.make)(`div`,{class:`wui-consent-banner-actions`},(0,i.make)(`button`,{type:`button`,class:`btn btn-sm btn-link wui-consent-banner-settings-toggle`,"aria-expanded":`false`},S().settingsLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`neutral`,`outline`,`sm`)} wui-consent-banner-reject`,"data-wui":n.APP_BUTTON_MARKER},S().rejectLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-accept`,"data-wui":n.APP_BUTTON_MARKER},S().acceptLabel),(0,i.make)(`button`,{type:`button`,class:`${(0,n.buttonClass)(`primary`,`solid`,`sm`)} wui-consent-banner-save`,hidden:!0,"data-wui":n.APP_BUTTON_MARKER},S().saveLabel)))),this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),e&&(this._requirePanel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){if(this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._requirePanel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t){let t=e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`);t instanceof HTMLElement&&t.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(b),document.documentElement.style.removeProperty(x)}_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(b,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(x,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){let e=this._root().querySelector(`.wui-consent-banner-panel`);return e instanceof HTMLElement?e:null}_requirePanel(){let e=this._panel();if(!e)throw Error(`consent banner panel is missing`);return e}_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(_,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return{analytics:e&&t.includes(`analytics`),functional:e&&t.includes(`functional`),marketing:e&&t.includes(`marketing`)}}_switchValues(){let e={analytics:!1,functional:!1,marketing:!1};for(let t of C){let n=this._root().querySelector(`input[data-category="${t}"]`);e[t]=n instanceof HTMLInputElement&&n.checked}return e}_applyPreferences(){for(let e of C){let t=this._root().querySelector(`input[data-category="${e}"]`);t instanceof HTMLInputElement&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!(n instanceof HTMLElement))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 instanceof HTMLElement&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r instanceof HTMLElement&&(r.hidden=e)}}};function M(e,t,n,r,a){let o=`${e}-${t}`;return(0,i.make)(`div`,{class:`wui-consent-banner-category`},(0,i.make)(`div`,{class:`form-check form-switch`},(0,i.make)(`input`,{class:`form-check-input`,type:`checkbox`,role:`switch`,id:o,"data-category":t,checked:a,disabled:a}),(0,i.make)(`label`,{class:`form-check-label`,for:o},n)),(0,i.make)(`p`,{class:`wui-consent-banner-category-description`},r))}(0,t.defineElement)(`wui-consent-banner`,j),e.WuiConsentBanner=j})(this.WeborityUiElements=this.WeborityUiElements||{},WeborityUiElementsInternal.modules.defineElement,WeborityUiElementsInternal.modules.buttonClass,WeborityUiElementsInternal.modules.devWarn,WeborityUiElementsInternal.modules.dom,WeborityUiElementsInternal.modules.elementBase,WeborityUiElementsInternal.modules.textStore);