@webority/ui-elements 0.144.2 → 0.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{WuiCodeBlock-CXBYH2Ej.js → WuiCodeBlock-CCCJwsk5.js} +1 -1
  2. package/dist/{WuiCommentThread-ZXxBt71o.js → WuiCommentThread-B9bkBMIq.js} +1 -1
  3. package/dist/{WuiConsentBanner-CYOU67bp.js → WuiConsentBanner-jkeRiC1_.js} +1 -1
  4. package/dist/{WuiSavedViews-KUVaYmGJ.js → WuiSavedViews-CQSrMJUb.js} +1 -1
  5. package/dist/WuiTour-Cz_SaC60.js +1 -0
  6. package/dist/{WuiWizardStep-DB-BbyEO.js → WuiWizardStep-CIYuIp4a.js} +1 -1
  7. package/dist/buttonClass-Yk0Fwgs6.js +1 -0
  8. package/dist/drawerDiscard-Cvwk_Yke.js +1 -0
  9. package/dist/elements/code-block.js +1 -1
  10. package/dist/elements/comment-thread.js +1 -1
  11. package/dist/elements/consent-banner.js +1 -1
  12. package/dist/elements/saved-views.js +1 -1
  13. package/dist/elements/tour.js +1 -1
  14. package/dist/elements/wizard.js +1 -1
  15. package/dist/server.js +1 -1
  16. package/dist/ui-calendar.global.js +1 -1
  17. package/dist/ui-calendar.js +1 -1
  18. package/dist/ui-consent-banner.global.js +1 -1
  19. package/dist/ui-elements/carousel.global.js +1 -1
  20. package/dist/ui-elements/code-block.global.js +1 -1
  21. package/dist/ui-elements/command-palette.global.js +1 -1
  22. package/dist/ui-elements/comment-thread.global.js +1 -1
  23. package/dist/ui-elements/consent-banner.global.js +1 -1
  24. package/dist/ui-elements/context-menu.global.js +1 -1
  25. package/dist/ui-elements/date-range.global.js +1 -1
  26. package/dist/ui-elements/drawer.global.js +1 -1
  27. package/dist/ui-elements/image-crop.global.js +1 -1
  28. package/dist/ui-elements/inline-edit.global.js +1 -1
  29. package/dist/ui-elements/kanban.global.js +1 -1
  30. package/dist/ui-elements/lead-popup.global.js +1 -1
  31. package/dist/ui-elements/lightbox.global.js +1 -1
  32. package/dist/ui-elements/markdown.global.js +1 -1
  33. package/dist/ui-elements/org-tree.global.js +1 -1
  34. package/dist/ui-elements/phone.global.js +1 -1
  35. package/dist/ui-elements/resizable.global.js +1 -1
  36. package/dist/ui-elements/saved-views.global.js +1 -1
  37. package/dist/ui-elements/select-chips.global.js +1 -1
  38. package/dist/ui-elements/select-search.global.js +1 -1
  39. package/dist/ui-elements/slider.global.js +1 -1
  40. package/dist/ui-elements/sortable.global.js +1 -1
  41. package/dist/ui-elements/status-icon.global.js +1 -1
  42. package/dist/ui-elements/timepicker.global.js +1 -1
  43. package/dist/ui-elements/tour.global.js +1 -1
  44. package/dist/ui-elements/tree.global.js +1 -1
  45. package/dist/ui-elements/wizard.global.js +1 -1
  46. package/dist/ui-elements.global.js +2 -2
  47. package/dist/ui-elements.js +1 -1
  48. package/dist/ui-file-viewer.global.js +10 -10
  49. package/dist/ui-file-viewer.js +1 -1
  50. package/dist/ui-tour.global.js +1 -1
  51. package/package.json +3 -3
  52. package/dist/WuiTour-D18C-wQP.js +0 -1
  53. package/dist/buttonClass-DpG9WzgJ.js +0 -1
  54. package/dist/drawerDiscard-DdoTN5aX.js +0 -1
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-DpG9WzgJ.js";import{n,t as r}from"./copyText-DM5HhXjf.js";import{t as i}from"./elementBase-DV9IZZCu.js";import{t as a}from"./iconGlyphs.g-BlwTSNXS.js";var o=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),s=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),c=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),l=`(?![\\s\\S])`,u=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${l})`).source,d=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,c([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],f=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],p=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`--[^\\n]*|${u}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`])],[`type`,c([`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`,/[(),;]/]],h=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,c([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,c(/* @__PURE__ */ `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`,/[|&;<>(){}[\]]+/]],g=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],_=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${l})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],v={json:d,js:f,cs:p,sql:m,bash:h,http:g,css:[[`comment`,new RegExp(u)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:_,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},y=/* @__PURE__ */ new Map;function b(e){let t=y.get(e);if(!t){let n=v[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)},y.set(e,t)}return t}function x(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function S(e,t,n=[]){let{re:r,types:i}=b(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;x(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?S(`htmlTag`,o[0],n):x(n,i[r],o[0]),a=o.index+o[0].length}return x(n,`plain`,t.slice(a)),n}function C(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return S(`http`,e);let n=S(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?S(`json`,r,n):i===`<`?S(`html`,r,n):(x(n,`plain`,r),n)}function w(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?C(n):!Object.hasOwn(v,t)||t===`htmlTag`?[[`plain`,n]]:S(t,n)}function T(e,t){let n=[[]];for(let[r,i]of w(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var E=class extends i{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._title=null,this._view=null,this._codeEl=null,this._copyIcon=null,this._copyText=null,this._copied=!1,this._observer=null,this._timer=0,this._cancelFrame=null}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=o.includes(t)?t:`text`,r=this.getAttribute(`label`)||``,i=T(this._code(),n);this._title.textContent=r||s[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>D(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=e.createElement(`div`);n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,this._codeEl=e.createElement(`code`),r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this._view=n,this.append(t)}_bar(i){let a=i.createElement(`div`);a.className=`wui-code-bar`,this._title=i.createElement(`span`),this._title.className=`wui-code-title`;let o=i.createElement(`button`);return o.type=`button`,o.className=`${e(`ghost`,`sm`)} wui-code-copy`,o.dataset.wui=t,o.setAttribute(`aria-live`,`polite`),this._copyIcon=i.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=i.createElement(`span`),this._setCopied(!1),o.append(this._copyIcon,this._copyText),o.addEventListener(`click`,async()=>{await n(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>this._setCopied(!1),r))}),a.append(this._title,o),a}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=a(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function D(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}export{E as t};
1
+ import{n as e,t}from"./buttonClass-Yk0Fwgs6.js";import{n,t as r}from"./copyText-DM5HhXjf.js";import{t as i}from"./elementBase-DV9IZZCu.js";import{t as a}from"./iconGlyphs.g-BlwTSNXS.js";var o=Object.freeze([`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`]),s=Object.freeze({text:``,json:`JSON`,js:`JavaScript`,cs:`C#`,sql:`SQL`,bash:`Bash`,http:`HTTP`,html:`HTML`,css:`CSS`}),c=e=>RegExp(`\\b(?:${e.join(`|`)})\\b`),l=`(?![\\s\\S])`,u=RegExp(`/\\*[\\s\\S]*?(?:\\*/|${l})`).source,d=[[`attr`,/"(?:[^"\\\n]|\\.)*"(?=\s*:)/],[`string`,/"(?:[^"\\\n]|\\.)*"?/],[`number`,/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/],[`literal`,c([`true`,`false`,`null`])],[`punct`,/[{}[\],:]/]],f=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?|`(?:[^`\\]|\\[\s\S])*`?/],[`number`,/\b(?:0[xX][\da-fA-F_]+|\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?n?)\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`])],[`function`,/(?<![\w$])[A-Za-z_$][\w$]*(?=\s*\()/],[`type`,/(?<![\w$])[A-Z][\w$]*/],[`punct`,/[{}()[\];,]/]],p=[[`comment`,RegExp(`//[^\\n]*|${u}`)],[`string`,/@"(?:[^"]|"")*"?|\$@?"(?:[^"\\\n]|\\.)*"?|"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`number`,/\b\d[\d_]*\.?\d*(?:[eE][+-]?\d+)?[fFdDmMlLuU]{0,2}\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`,`null`])],[`function`,/(?<!\w)[A-Za-z_]\w*(?=\s*\()/],[`type`,/(?<!\w)[A-Z]\w*/],[`punct`,/[{}()[\];,]/]],m=[[`comment`,RegExp(`--[^\\n]*|${u}`)],[`string`,/'(?:[^']|'')*'?/],[`variable`,/@@?\w+/],[`number`,/\b\d+(?:\.\d+)?\b/],[`keyword`,c(/* @__PURE__ */ `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`,c([`true`,`false`])],[`type`,c([`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`,/[(),;]/]],h=[[`comment`,/(?<![^\s;|&(])#[^\n]*/],[`string`,/"(?:[^"\\]|\\[\s\S])*"?|'[^']*'?/],[`variable`,/\$(?:\{[^}\n]*\}?|[A-Za-z_]\w*|[0-9@#?$!*-])/],[`attr`,/(?<![\w-])--?[A-Za-z][\w-]*/],[`number`,/(?<![\w.-])\d+(?:\.\d+)?\b/],[`keyword`,c([`case`,`do`,`done`,`elif`,`else`,`esac`,`exit`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`return`,`select`,`then`,`until`,`while`])],[`function`,c(/* @__PURE__ */ `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`,/[|&;<>(){}[\]]+/]],g=[[`comment`,/^#[^\n]*/m],[`keyword`,/^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)(?= )/m],[`literal`,/HTTP\/\d(?:\.\d)?/],[`number`,/(?<=^HTTP\/\d(?:\.\d)? )\d{3}\b/m],[`function`,/(?<=^[A-Z]+ )\S+/m],[`attr`,/^[A-Za-z][\w-]*(?=:)/m],[`string`,/(?<=^[A-Za-z][\w-]*:[ \t]*)[^\n]+/m]],_=[[`comment`,RegExp(`<!--[\\s\\S]*?(?:-->|${l})`)],[`keyword`,/<![A-Za-z][^>]*>?/],[`tag`,/<\/?[A-Za-z][^<>]*>?/],[`literal`,/&#?\w+;/]],v={json:d,js:f,cs:p,sql:m,bash:h,http:g,css:[[`comment`,new RegExp(u)],[`string`,/"(?:[^"\\\n]|\\.)*"?|'(?:[^'\\\n]|\\.)*'?/],[`keyword`,/@[\w-]+|!important/],[`attr`,/[\w-]+(?=\s*:[^{};]*[;}])/],[`number`,/#[0-9a-fA-F]{3,8}\b|(?<![\w-])-?(?:\d+\.?\d*|\.\d+)(?:%|[A-Za-z]{1,4})?/],[`function`,/[\w-]+(?=\()/],[`type`,/[.#](?!\d)[A-Za-z_][\w-]*/],[`punct`,/[{}();:,]/]],html:_,htmlTag:[[`tag`,/^<\/?[\w:.-]+/],[`string`,/"[^"]*"?|'[^']*'?/],[`attr`,/(?<=\s)[^\s=<>/"']+/],[`punct`,/\/?>|=/]]},y=/* @__PURE__ */ new Map;function b(e){let t=y.get(e);if(!t){let n=v[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)},y.set(e,t)}return t}function x(e,t,n){if(!n)return;let r=e[e.length-1];r&&r[0]===t?r[1]+=n:e.push([t,n])}function S(e,t,n=[]){let{re:r,types:i}=b(e),a=0;for(let o of t.matchAll(r)){if(!o[0])continue;x(n,`plain`,t.slice(a,o.index));let r=i.findIndex((e,t)=>o[t+1]!==void 0);e===`html`&&i[r]===`tag`?S(`htmlTag`,o[0],n):x(n,i[r],o[0]),a=o.index+o[0].length}return x(n,`plain`,t.slice(a)),n}function C(e){let t=/\r?\n\r?\n/.exec(e);if(!t)return S(`http`,e);let n=S(`http`,e.slice(0,t.index+t[0].length)),r=e.slice(t.index+t[0].length),i=r.trimStart()[0];return i===`{`||i===`[`?S(`json`,r,n):i===`<`?S(`html`,r,n):(x(n,`plain`,r),n)}function w(e,t){let n=String(e??``);return!n||n.length>1e5?n?[[`plain`,n]]:[]:t===`http`?C(n):!Object.hasOwn(v,t)||t===`htmlTag`?[[`plain`,n]]:S(t,n)}function T(e,t){let n=[[]];for(let[r,i]of w(e,t))i.split(/\r\n|\r|\n/).forEach((e,t)=>{t>0&&n.push([]),e&&n[n.length-1].push([r,e])});return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var E=class extends i{static get observedAttributes(){return[`language`,`line-numbers`,`wrap`,`label`,`copy-label`,`copied-label`]}constructor(){super(),this._chrome=null,this._title=null,this._view=null,this._codeEl=null,this._copyIcon=null,this._copyText=null,this._copied=!1,this._observer=null,this._timer=0,this._cancelFrame=null}connectedCallback(){this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._chrome?.contains(e.target))&&this._schedule()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._cancelPending()}attributeChangedCallback(){this.isConnected&&this._render()}_source(){return Array.from(this.children).find(e=>e.classList.contains(`wui-code-source`))}_code(){return(this._source()?.textContent??``).replace(/\r?\n$/,``)}_schedule(){if(this._cancelFrame)return;let e=()=>{this._cancelFrame=null,this._render()};if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);this._cancelFrame=()=>cancelAnimationFrame(t)}else{let t=!0;queueMicrotask(()=>{t&&e()}),this._cancelFrame=()=>{t=!1}}}_cancelPending(){this._cancelFrame?.(),this._cancelFrame=null}_render(){if(!this._source())return;this._cancelPending();let e=this.ownerDocument;this._chrome||this._build(e);let t=this.getAttribute(`language`),n=o.includes(t)?t:`text`,r=this.getAttribute(`label`)||``,i=T(this._code(),n);this._title.textContent=r||s[n],this._view.setAttribute(`aria-label`,r||`Code`),this._view.style.setProperty(`--wui-code-digits`,String(String(i.length).length)),this._codeEl.replaceChildren(...i.map(t=>D(e,t))),this._copied||(this._copyText.textContent=this._copyLabel()),this.setAttribute(`data-wui-ready`,``),this._observer?.takeRecords()}_build(e){let t=e.createElement(`div`);t.className=`wui-code-chrome`,t.append(this._bar(e));let n=e.createElement(`div`);n.className=`wui-code-view`,n.setAttribute(`role`,`region`),n.tabIndex=0;let r=e.createElement(`pre`);r.className=`wui-code-pre`,this._codeEl=e.createElement(`code`),r.append(this._codeEl),n.append(r),t.append(n),this._chrome=t,this._view=n,this.append(t)}_bar(i){let a=i.createElement(`div`);a.className=`wui-code-bar`,this._title=i.createElement(`span`),this._title.className=`wui-code-title`;let o=i.createElement(`button`);return o.type=`button`,o.className=`${e(`primary`,`ghost`,`sm`)} wui-code-copy`,o.dataset.wui=t,o.setAttribute(`aria-live`,`polite`),this._copyIcon=i.createElement(`span`),this._copyIcon.className=`wui-code-copy-icon`,this._copyText=i.createElement(`span`),this._setCopied(!1),o.append(this._copyIcon,this._copyText),o.addEventListener(`click`,async()=>{await n(this._code())&&(this._setCopied(!0),clearTimeout(this._timer),this._timer=setTimeout(()=>this._setCopied(!1),r))}),a.append(this._title,o),a}_setCopied(e){this._copied=e,this._copyIcon.innerHTML=a(e?`check`:`files`,{size:14}),this._copyText.textContent=this._copyLabel()}_copyLabel(){return this._copied?this.getAttribute(`copied-label`)||`Copied`:this.getAttribute(`copy-label`)||`Copy`}};function D(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}export{E as t};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,t as i}from"./buttonClass-DpG9WzgJ.js";import{t as a}from"./elementBase-DV9IZZCu.js";import{l as o}from"./wuiHttp-DgnM7K2Q.js";var s=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),c=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),l=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),u=`[data-wui-items]`,d=`[data-wui-picker]`,f=`[data-wui-composer]`,p=`[data-wui-comment]`,m=`[data-wui-live]`,h=e=>typeof e?.message==`string`&&e.message?e.message:l.failed.server,g=class extends a{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(d)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&n(this._pickerFor.button,this.querySelector(d))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey);let e=this.querySelector(`${f} wui-mention-input`);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:s}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(d),n=e?this._pickerFor?.comment:t.closest(p);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(p);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=this.querySelector(d);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(p),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:l.replyLabel(r),placeholder:l.replyPlaceholder,value:``,send:l.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n?.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:l.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:l.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&s.setAttribute(e,this.getAttribute(e));let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`sm`,`send`,i),this._button(`ghost`,`sm`,`cancel`,l.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(s,c,u),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let d=s.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n,a){let o=this.ownerDocument.createElement(`button`);return o.type=`button`,o.className=r(e,t),o.dataset.wui=i,o.setAttribute(`data-wui-action`,n),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=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(t,r){let i=this.querySelector(d);i&&t&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:t,button:r},r.setAttribute(`aria-expanded`,`true`),i.hidden=!1,n(r,i),e(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let n=this._pickerFor;if(!n)return;this._pickerFor=null;let r=this.querySelector(d);r&&(r.hidden=!0),n.button.setAttribute(`aria-expanded`,`false`),t(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&n.button.isConnected&&n.button.focus()}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,l.emptyBody),n?.focus();return}let i=t.closest(p);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,u=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),l.done[e]&&this._announce(l.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:u}}))):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:h(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:l.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await o(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||l.failed[r.kind]||l.failed.server}}_swapItems(e){let t=this.querySelector(u);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(u);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(p)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${f} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${m}`);t&&e&&(t.textContent=``,t.textContent=e)}};export{g as i,s as n,l as r,c as t};
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,t as i}from"./buttonClass-Yk0Fwgs6.js";import{t as a}from"./elementBase-DV9IZZCu.js";import{l as o}from"./wuiHttp-DgnM7K2Q.js";var s=Object.freeze([`👍`,`❤️`,`🎉`,`😄`,`👀`,`🙏`]),c=Object.freeze([`post`,`reply`,`edit`,`delete`,`react`]),l=Object.freeze({listName:`Comments`,empty:`No comments yet.`,deleted:`This comment was deleted.`,edited:`Edited`,reply:`Reply`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,save:`Save`,post:`Comment`,confirmDelete:`Delete this comment?`,composerLabel:`Add a comment`,composerPlaceholder:`Write a comment. Type @ to mention someone.`,replyLabel:e=>`Reply to ${e}`,replyPlaceholder:`Write a reply`,editLabel:`Edit comment`,repliesName:e=>`Replies to ${e}`,reactions:`Reactions`,addReaction:`Add a reaction`,pickerName:`Choose a reaction`,emptyBody:`Write something first.`,done:Object.freeze({post:`Comment posted.`,reply:`Reply posted.`,edit:`Comment saved.`,delete:`Comment deleted.`,react:``}),failed:Object.freeze({forbidden:`You do not have permission to do this.`,client:`This did not go through. Refresh the page and try again.`,validation:`This was not accepted. Check it and try again.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`})}),u=`[data-wui-items]`,d=`[data-wui-picker]`,f=`[data-wui-composer]`,p=`[data-wui-comment]`,m=`[data-wui-live]`,h=e=>typeof e?.message==`string`&&e.message?e.message:l.failed.server,g=class extends a{constructor(){super(),this._wired=!1,this._busy=!1,this._peopleProp=null,this._pickerFor=null,this._onClick=this._onClick.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onSubmitKey=this._onSubmitKey.bind(this),this._onDocClick=e=>{this._pickerFor&&!this.querySelector(d)?.contains(e.target)&&!this._pickerFor.button.contains(e.target)&&this._closePicker(!1)},this._repositionPicker=()=>{this._pickerFor&&n(this._pickerFor.button,this.querySelector(d))}}connectedCallback(){if(Object.hasOwn(this,`people`)){let e=this.people;delete this.people,this.people=e}if(this._wired)return;this._wired=!0,this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wui:mention-input:submit`,this._onSubmitKey);let e=this.querySelector(`${f} wui-mention-input`);this._handPeople(e),this._applyComposerPlaceholder(e)}disconnectedCallback(){this._closePicker(!1)}get people(){return this._peopleProp?this._peopleProp:[...this.querySelectorAll(`:scope > [data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0}))}set people(e){this._peopleProp=Array.isArray(e)?e:[];for(let e of this.querySelectorAll(`wui-mention-input`))e.people=this._peopleProp}_handPeople(e){!e||this.hasAttribute(`remote`)||this.hasAttribute(`source`)||(e.people=this.people)}_applyComposerPlaceholder(e){let t=this.getAttribute(`composer-placeholder`);e&&t!=null&&e.setAttribute(`placeholder`,t)}_reactionChoices(){let e=this.getAttribute(`reaction-choices`),t=e?e.split(/\s+/).filter(Boolean):[];return t.length?t:s}_onClick(e){let t=e.target.closest?.(`[data-wui-emoji]`);if(t&&this.contains(t)&&!t.disabled){let e=t.closest(d),n=e?this._pickerFor?.comment:t.closest(p);e&&this._closePicker(!0),n&&this._react(n,t.getAttribute(`data-wui-emoji`));return}let n=e.target.closest?.(`[data-wui-action]`);if(!n||!this.contains(n)||n.disabled)return;let r=n.closest(p);switch(n.getAttribute(`data-wui-action`)){case`reply`:this._openReply(r,n);break;case`edit`:this._openEditor(r,n);break;case`delete`:this._askDelete(r);break;case`cancel-delete`:this._closeConfirm(r,!0);break;case`confirm-delete`:this._send(`delete`,{commentId:r.getAttribute(`data-wui-comment`)},{comment:r,scope:r});break;case`react-menu`:this._pickerFor?.button===n?this._closePicker(!0):this._openPicker(r,n);break;case`cancel`:this._closeSlot(n.closest(`[data-wui-reply], [data-wui-editor]`),!0);break;case`post`:case`send`:this._sendFrom(n)}}_onKeyDown(e){let t=this.querySelector(d);if(this._pickerFor&&t?.contains(e.target)){let n=[...t.querySelectorAll(`[data-wui-emoji]`)],r=n.indexOf(e.target);e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._closePicker(!0)):e.key===`ArrowRight`||e.key===`ArrowLeft`?(e.preventDefault(),n[(r+(e.key===`ArrowRight`?1:-1)+n.length)%n.length]?.focus()):e.key===`Tab`&&this._closePicker(!1);return}if(e.key!==`Escape`)return;let n=e.target.closest?.(`[data-wui-reply], [data-wui-editor]`);if(n&&this.contains(n)){e.preventDefault(),e.stopPropagation(),this._closeSlot(n,!0);return}let r=e.target.closest?.(`[data-wui-confirm]`);r&&(e.preventDefault(),e.stopPropagation(),this._closeConfirm(r.closest(p),!0))}_onSubmitKey(e){let t=(e.target.closest?.(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`))?.querySelector(`[data-wui-action="send"], [data-wui-action="post"]`);t&&!t.disabled&&this._sendFrom(t)}_openReply(e,t){if(this.hasAttribute(`no-replies`))return;let n=e?.querySelector(`:scope > [data-wui-reply]`);if(!n)return;if(!n.hidden){n.querySelector(`wui-mention-input`)?.focus();return}let r=e.querySelector(`.wui-comment-author`)?.textContent.trim()||``;this._fillSlot(n,{label:l.replyLabel(r),placeholder:l.replyPlaceholder,value:``,send:l.reply,opener:t})}_openEditor(e,t){let n=e?.querySelector(`:scope > .wui-comment-row [data-wui-editor]`);if(!n?.hidden)return;let r=n.parentElement.querySelector(`:scope > [data-wui-text]`);r&&(r.hidden=!0),this._fillSlot(n,{label:l.editLabel,placeholder:``,value:e.getAttribute(`data-value`)??``,send:l.save,opener:t})}_fillSlot(e,{label:t,placeholder:n,value:r,send:i,opener:a}){let o=this.ownerDocument,s=o.createElement(`wui-mention-input`);s.className=`wui-mention-input`,s.setAttribute(`label`,t),n&&s.setAttribute(`placeholder`,n),s.setAttribute(`rows`,`2`),s.setAttribute(`value`,r);for(let e of[`remote`,`source`,`min-chars`,`debounce`])this.hasAttribute(e)&&s.setAttribute(e,this.getAttribute(e));let c=o.createElement(`div`);c.className=`wui-comment-form-actions`,c.append(this._button(`primary`,`solid`,`sm`,`send`,i),this._button(`primary`,`ghost`,`sm`,`cancel`,l.cancel));let u=o.createElement(`div`);u.className=`wui-comment-error`,u.setAttribute(`data-wui-error`,``),u.hidden=!0,e.replaceChildren(s,c,u),this._handPeople(s),e.hidden=!1,this._openers??=/* @__PURE__ */ new WeakMap,this._openers.set(e,a),s.focus();let d=s.querySelector(`textarea`);d?.setSelectionRange(d.value.length,d.value.length)}_button(e,t,n,a,o){let s=this.ownerDocument.createElement(`button`);return s.type=`button`,s.className=r(e,t,n),s.dataset.wui=i,s.setAttribute(`data-wui-action`,a),s.textContent=o,s}_closeSlot(e,t){if(!e||e.hidden)return;if(e.hidden=!0,e.replaceChildren(),e.hasAttribute(`data-wui-editor`)){let t=e.parentElement?.querySelector(`:scope > [data-wui-text]`);t&&(t.hidden=!1)}let n=this._openers?.get(e);t&&n?.isConnected&&n.focus()}_askDelete(e){let t=e?.querySelector(`:scope > .wui-comment-row`),n=t?.querySelector(`[data-wui-confirm]`),r=t?.querySelector(`[data-wui-actions]`);n&&(n.hidden=!1,r&&(r.hidden=!0),n.querySelector(`[data-wui-action="cancel-delete"]`)?.focus())}_closeConfirm(e,t){let n=e?.querySelector(`:scope > .wui-comment-row`),r=n?.querySelector(`[data-wui-confirm]`),i=n?.querySelector(`[data-wui-actions]`);r&&(r.hidden=!0),i&&(i.hidden=!1),t&&i?.querySelector(`[data-wui-action="delete"]`)?.focus()}_openPicker(t,r){let i=this.querySelector(d);i&&t&&!this.hasAttribute(`no-reactions`)&&(this._closePicker(!1),this._pickerFor={comment:t,button:r},r.setAttribute(`aria-expanded`,`true`),i.hidden=!1,n(r,i),e(this,this._repositionPicker),this.ownerDocument.addEventListener(`click`,this._onDocClick,!0),i.querySelector(`[data-wui-emoji]`)?.focus())}_closePicker(e){let n=this._pickerFor;if(!n)return;this._pickerFor=null;let r=this.querySelector(d);r&&(r.hidden=!0),n.button.setAttribute(`aria-expanded`,`false`),t(this),this.ownerDocument.removeEventListener(`click`,this._onDocClick,!0),e&&n.button.isConnected&&n.button.focus()}_react(e,t){t&&!this.hasAttribute(`no-reactions`)&&this._send(`react`,{commentId:e.getAttribute(`data-wui-comment`),emoji:t},{comment:e,scope:e})}_sendFrom(e){let t=e.closest(`[data-wui-reply], [data-wui-editor], [data-wui-composer]`);if(!t)return;let n=t.querySelector(`wui-mention-input`),r=n?.value??``;if(!r.trim()){this._showError(t,l.emptyBody),n?.focus();return}let i=t.closest(p);t.hasAttribute(`data-wui-composer`)?this._send(`post`,{body:r},{scope:t,form:t}):t.hasAttribute(`data-wui-reply`)?this._send(`reply`,{parentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t}):this._send(`edit`,{commentId:i.getAttribute(`data-wui-comment`),body:r},{comment:i,scope:t,form:t})}async _send(e,t,{comment:n,scope:r,form:i}){if(this._busy)return;this._busy=!0,this.setAttribute(`aria-busy`,`true`);let a=i??n?.querySelector(`:scope > .wui-comment-row`)??this;this._showError(a,null);let o=[...r.querySelectorAll(`button, textarea`)].filter(e=>!e.disabled);for(let e of o)e.disabled=!0;let s=await this._persist({intent:e,...t});for(let e of o)e.isConnected&&(e.disabled=!1);this._busy=!1,this.removeAttribute(`aria-busy`);let c=t.commentId??null,u=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),l.done[e]&&this._announce(l.done[e]),this.dispatchEvent(new CustomEvent(`wui:comment-thread:done`,{bubbles:!0,detail:{intent:e,commentId:c,parentId:u}}))):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:h(e)}}}let t=this.getAttribute(`action`);if(!t)return{ok:!1,kind:`client`,message:l.failed.client};let n=new URLSearchParams;for(let[t,r]of Object.entries(e))r!=null&&n.set(t,r);let r=await o(t,{method:`POST`,body:n});return r.ok?{ok:!0,html:r.html}:{ok:!1,kind:r.kind,message:r.message||l.failed[r.kind]||l.failed.server}}_swapItems(e){let t=this.querySelector(u);if(!t||!e.trim())return;let n=this.ownerDocument.createElement(`template`);n.innerHTML=e;let r=n.content.querySelector(u);t.replaceChildren(...r?r.childNodes:n.content.childNodes)}_restoreFocus(e,t,n){let r=this.ownerDocument,i=r.activeElement;if(i&&i!==r.body&&i.isConnected&&this.contains(i)&&!i.disabled)return;let a=e=>e?[...this.querySelectorAll(p)].find(t=>t.getAttribute(`data-wui-comment`)===e):null,o=e=>a(e)?.querySelector(`:scope > .wui-comment-row`),s=null;if(e===`post`)s=n?.querySelector(`textarea`);else if(e===`reply`)s=o(t.parentId)?.querySelector(`[data-wui-action="reply"]`);else if(e===`edit`)s=o(t.commentId)?.querySelector(`[data-wui-action="edit"]`);else if(e===`react`){let e=o(t.commentId);s=[...e?.querySelectorAll(`button[data-wui-emoji]`)??[]].find(e=>e.getAttribute(`data-wui-emoji`)===t.emoji)??e?.querySelector(`[data-wui-action="react-menu"]`)}s??=this.querySelector(`${f} textarea`),s?.focus()}_showError(e,t){let n=e?.querySelector?.(`:scope > [data-wui-error], :scope > .wui-comment-main > [data-wui-error]`);n&&(n.textContent=t||``,n.hidden=!t)}_announce(e){let t=this.querySelector(`:scope > ${m}`);t&&e&&(t.textContent=``,t.textContent=e)}};export{g as i,s as n,l as r,c as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-DpG9WzgJ.js";import{n}from"./devWarn-DXdRWZs3.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{t as i}from"./tourOpenMark-nPeAJFSo.js";var a={"--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`},o=e=>`var(${e}, ${a[e]})`,s=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${o(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${o(`--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: ${o(`--color-surface`)}; border: 1px solid ${o(`--color-border`)}; border-radius: ${o(`--wui-radius-lg`)}; box-shadow: ${o(`--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: ${o(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${o(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${o(`--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 ${o(`--color-border`)}; border-bottom: 1px solid ${o(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${o(`--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: ${o(`--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: ${o(`--color-primary`)}; background: ${o(`--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 ${o(`--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 ${o(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${o(`--color-primary`)}; border-color: ${o(`--color-primary`)}; color: ${o(`--color-on-primary`)}; } .btn-primary:hover { background: ${o(`--color-primary-hover`)}; border-color: ${o(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${o(`--color-text-muted`)}; color: ${o(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${o(`--color-bg-muted`)}; color: ${o(`--color-text`)}; } .btn-link { font-weight: 400; color: ${o(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${o(`--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; } } `,c=`wui-consent-save`,l=`[data-consent-settings]`,u=`tour-open`,d=`--wui-consent-banner-block`,f=`--wui-consent-banner-inline`,p={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},m=[`analytics`,`functional`,`marketing`],h={analytics:{label:p.analyticsLabel,description:`analyticsDescription`},functional:{label:p.functionalLabel,description:`functionalDescription`},marketing:{label:p.marketingLabel,description:`marketingDescription`}},g=/* @__PURE__ */ new Set;function _(e){g.has(e)||(g.add(e),n(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${m.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var v=0,y=null;function b(e){y||(y=new CSSStyleSheet,y.replaceSync(s)),e.adoptedStyleSheets=[y]}var x=class extends r{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),v+=1,this._uid=`wui-consent-${v}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(l)&&(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`)||p.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||p.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`)||p.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||p.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||p.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||p.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...m];let t=e.split(/\s+/).filter(Boolean);for(let e of t)m.includes(e)||_(e);let n=m.filter(e=>t.includes(e));return n.length?n:[...m]}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(m.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:[i]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(u,document.documentElement.hasAttribute(i))}attributeChangedCallback(){this._rendered&&this.render()}render(){let n=this.isOpen,r=this._uid,i=this.policyHref?` <a class="wui-consent-banner-policy" href="${w(this.policyHref)}">${C(this.policyLabel)}</a>`:``,a=this._root();a!==this&&b(a),a.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${r}-heading" aria-describedby="${r}-description" hidden> <h2 class="wui-consent-banner-heading" id="${r}-heading">${C(this.heading)}</h2> <p class="wui-consent-banner-description" id="${r}-description">${C(this.description)}${i}</p> <div class="wui-consent-banner-settings" hidden> ${S(r,`essential`,p.essentialLabel,p.essentialDescription,!0)} ${this.categories.map(e=>S(r,e,h[e].label,this[h[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${p.settingsLabel}</button> <button type="button" class="${e(`outline-secondary`,`sm`)} wui-consent-banner-reject" data-wui="${t}">${p.rejectLabel}</button> <button type="button" class="${e(`primary`,`sm`)} wui-consent-banner-accept" data-wui="${t}">${p.acceptLabel}</button> <button type="button" class="${e(`primary`,`sm`)} wui-consent-banner-save" hidden data-wui="${t}">${p.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),n&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(d),document.documentElement.style.removeProperty(f)}_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(d,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(f,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(c,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(m.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of m)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of m){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function S(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${C(n)}</label> </div> <p class="wui-consent-banner-category-description">${C(r)}</p> </div>`}var C=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),w=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{x as t};
1
+ import{n as e,t}from"./buttonClass-Yk0Fwgs6.js";import{n}from"./devWarn-DXdRWZs3.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{t as i}from"./tourOpenMark-nPeAJFSo.js";var a={"--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`},o=e=>`var(${e}, ${a[e]})`,s=` :host { all: initial; position: fixed; bottom: 20px; left: 20px; right: auto; z-index: ${o(`--wui-z-fixed`)}; display: block; width: 420px; max-width: calc(100vw - 40px); font-family: inherit; font-size: 16px; line-height: 1.5; color: ${o(`--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: ${o(`--color-surface`)}; border: 1px solid ${o(`--color-border`)}; border-radius: ${o(`--wui-radius-lg`)}; box-shadow: ${o(`--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: ${o(`--color-text`)}; } .wui-consent-banner-description { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: ${o(`--color-text-muted`)}; } .wui-consent-banner-policy { color: ${o(`--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 ${o(`--color-border`)}; border-bottom: 1px solid ${o(`--color-border`)}; } .wui-consent-banner-category-description { margin: 2px 0 0; padding-inline-start: 2.5em; font-size: 12px; line-height: 1.4; color: ${o(`--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: ${o(`--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: ${o(`--color-primary`)}; background: ${o(`--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 ${o(`--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 ${o(`--color-primary`)}; outline-offset: 2px; } .btn-primary { background: ${o(`--color-primary`)}; border-color: ${o(`--color-primary`)}; color: ${o(`--color-on-primary`)}; } .btn-primary:hover { background: ${o(`--color-primary-hover`)}; border-color: ${o(`--color-primary-hover`)}; } .btn-outline-neutral { border-color: ${o(`--color-text-muted`)}; color: ${o(`--color-text-muted`)}; } .btn-outline-neutral:hover { background: ${o(`--color-bg-muted`)}; color: ${o(`--color-text`)}; } .btn-link { font-weight: 400; color: ${o(`--color-primary-text`)}; text-decoration: underline; } .btn-link:hover { color: ${o(`--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; } } `,c=`wui-consent-save`,l=`[data-consent-settings]`,u=`tour-open`,d=`--wui-consent-banner-block`,f=`--wui-consent-banner-inline`,p={heading:`Cookies on this site`,description:`We use cookies to understand how the site is used and to measure our campaigns. You can change your choice at any time.`,policyLabel:`Cookie policy`,essentialLabel:`Essential cookies`,essentialDescription:`Required for the site to work and stay secure. Always on.`,analyticsLabel:`Analytics cookies`,analyticsDescription:`Help us understand how visitors use the site.`,functionalLabel:`Functional cookies`,functionalDescription:`Remember choices you make, such as your preferences.`,marketingLabel:`Marketing cookies`,marketingDescription:`Measure how well our campaigns work.`,settingsLabel:`Cookie settings`,rejectLabel:`Reject all`,acceptLabel:`Accept all`,saveLabel:`Save preferences`},m=[`analytics`,`functional`,`marketing`],h={analytics:{label:p.analyticsLabel,description:`analyticsDescription`},functional:{label:p.functionalLabel,description:`functionalDescription`},marketing:{label:p.marketingLabel,description:`marketingDescription`}},g=/* @__PURE__ */ new Set;function _(e){g.has(e)||(g.add(e),n(`[@webority/ui-elements] <wui-consent-banner> received categories containing "${e}", which is not one of ${m.map(e=>`"${e}"`).join(` | `)}. It is ignored.`))}var v=0,y=null;function b(e){y||(y=new CSSStyleSheet,y.replaceSync(s)),e.adoptedStyleSheets=[y]}var x=class extends r{static get observedAttributes(){return[`heading`,`description`,`policy-href`,`policy-label`,`analytics-description`,`functional-description`,`marketing-description`,`categories`]}constructor(){super(),v+=1,this._uid=`wui-consent-${v}`,this._preferences={analytics:!1,functional:!1,marketing:!1},this._settings=!1,this._onDocumentClick=e=>{e.target instanceof Element&&e.target.closest(l)&&(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`)||p.heading}set heading(e){this.setAttribute(`heading`,String(e??``))}get description(){return this.getAttribute(`description`)||p.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`)||p.policyLabel}set policyLabel(e){this.setAttribute(`policy-label`,String(e??``))}get analyticsDescription(){return this.getAttribute(`analytics-description`)||p.analyticsDescription}set analyticsDescription(e){this.setAttribute(`analytics-description`,String(e??``))}get functionalDescription(){return this.getAttribute(`functional-description`)||p.functionalDescription}set functionalDescription(e){this.setAttribute(`functional-description`,String(e??``))}get marketingDescription(){return this.getAttribute(`marketing-description`)||p.marketingDescription}set marketingDescription(e){this.setAttribute(`marketing-description`,String(e??``))}get categories(){let e=this.getAttribute(`categories`);if(!e?.trim())return[...m];let t=e.split(/\s+/).filter(Boolean);for(let e of t)m.includes(e)||_(e);let n=m.filter(e=>t.includes(e));return n.length?n:[...m]}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(m.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:[i]}),this.preview&&!this.isOpen&&this.open(),this.isOpen&&this._trackRoom()}disconnectedCallback(){document.removeEventListener(`click`,this._onDocumentClick),this._tourWatch?.disconnect(),this._untrackRoom()}_syncTour(){this.toggleAttribute(u,document.documentElement.hasAttribute(i))}attributeChangedCallback(){this._rendered&&this.render()}render(){let n=this.isOpen,r=this._uid,i=this.policyHref?` <a class="wui-consent-banner-policy" href="${w(this.policyHref)}">${C(this.policyLabel)}</a>`:``,a=this._root();a!==this&&b(a),a.innerHTML=` <div class="wui-consent-banner-panel" role="dialog" aria-labelledby="${r}-heading" aria-describedby="${r}-description" hidden> <h2 class="wui-consent-banner-heading" id="${r}-heading">${C(this.heading)}</h2> <p class="wui-consent-banner-description" id="${r}-description">${C(this.description)}${i}</p> <div class="wui-consent-banner-settings" hidden> ${S(r,`essential`,p.essentialLabel,p.essentialDescription,!0)} ${this.categories.map(e=>S(r,e,h[e].label,this[h[e].description],!1)).join(` `)} </div> <div class="wui-consent-banner-actions"> <button type="button" class="btn btn-sm btn-link wui-consent-banner-settings-toggle" aria-expanded="false">${p.settingsLabel}</button> <button type="button" class="${e(`neutral`,`outline`,`sm`)} wui-consent-banner-reject" data-wui="${t}">${p.rejectLabel}</button> <button type="button" class="${e(`primary`,`solid`,`sm`)} wui-consent-banner-accept" data-wui="${t}">${p.acceptLabel}</button> <button type="button" class="${e(`primary`,`solid`,`sm`)} wui-consent-banner-save" hidden data-wui="${t}">${p.saveLabel}</button> </div> </div>`,this._rendered=!0,this._wire(),this._applyPreferences(),this._showSettings(this._settings),n&&(this._panel().hidden=!1)}open({settings:e=!1,focus:t=!1}={}){this._rendered||this.render(),this._applyPreferences(),this._showSettings(e),this._panel().hidden=!1,this.setAttribute(`open`,``),this._trackRoom(),t&&(e?this._root().querySelector(`.wui-consent-banner-category input:not([disabled])`):this._root().querySelector(`.wui-consent-banner-accept`))?.focus()}close(){let e=this._panel();e&&(e.hidden=!0),this.removeAttribute(`open`),this._showSettings(!1),this._untrackRoom()}_trackRoom(){this.isConnected&&!this.preview&&(typeof ResizeObserver<`u`&&(this._roomObserver??=new ResizeObserver(()=>this._reserveRoom()),this._roomObserver.observe(this)),window.addEventListener(`resize`,this._onWindowResize),this._reserveRoom())}_untrackRoom(){this._roomObserver?.disconnect(),window.removeEventListener(`resize`,this._onWindowResize),document.documentElement.style.removeProperty(d),document.documentElement.style.removeProperty(f)}_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(d,`${Math.ceil(window.innerHeight-e.top)}px`),n.setProperty(f,`${Math.ceil(t)}px`)}_root(){return this.shadowRoot?this.shadowRoot:this.standalone?this.attachShadow({mode:`open`}):this}_panel(){return this._root().querySelector(`.wui-consent-banner-panel`)}_wire(){let e=this._root();e.querySelector(`.wui-consent-banner-accept`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!0))),e.querySelector(`.wui-consent-banner-reject`)?.addEventListener(`click`,()=>this._save(this._choiceForShown(!1))),e.querySelector(`.wui-consent-banner-save`)?.addEventListener(`click`,()=>this._save(this._switchValues())),e.querySelector(`.wui-consent-banner-settings-toggle`)?.addEventListener(`click`,()=>this._showSettings(!this._settings))}_save(e){this._preferences={...e},this.dispatchEvent(new CustomEvent(c,{bubbles:!0,composed:!0,detail:{...e}})),this.close()}_choiceForShown(e){let t=this.categories;return Object.fromEntries(m.map(n=>[n,e&&t.includes(n)]))}_switchValues(){let e={};for(let t of m)e[t]=this._root().querySelector(`input[data-category="${t}"]`)?.checked===!0;return e}_applyPreferences(){for(let e of m){let t=this._root().querySelector(`input[data-category="${e}"]`);t&&(t.checked=this._preferences[e])}}_showSettings(e){this._settings=e;let t=this._root(),n=t.querySelector(`.wui-consent-banner-settings`);if(!n)return;n.hidden=!e,t.querySelector(`.wui-consent-banner-settings-toggle`)?.setAttribute(`aria-expanded`,e?`true`:`false`);let r=t.querySelector(`.wui-consent-banner-save`);r&&(r.hidden=!e);for(let n of[`.wui-consent-banner-reject`,`.wui-consent-banner-accept`]){let r=t.querySelector(n);r&&(r.hidden=e)}}};function S(e,t,n,r,i){let a=`${e}-${t}`;return`<div class="wui-consent-banner-category"> <div class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" id="${a}" data-category="${t}"${i?` checked disabled`:``} /> <label class="form-check-label" for="${a}">${C(n)}</label> </div> <p class="wui-consent-banner-category-description">${C(r)}</p> </div>`}var C=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),w=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{x as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-DpG9WzgJ.js";import{t as n}from"./elementBase-DV9IZZCu.js";import{l as r}from"./wuiHttp-DgnM7K2Q.js";var i=`wui-saved-views:`,a=20,o=e=>typeof e?.name==`string`&&typeof e?.query==`string`,s=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`]}constructor(){super(),this._doc=null,this._views=[],this._open=!1,this._busy=!1,this._error=null,this._trigger=null,this._menu=null,this._divider=null,this._form=null,this._input=null,this._save=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._menu.contains(e.target)&&!/input|textarea/i.test(e.target.tagName)&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!this.contains(e.target)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;await this._request(`save`,{name:t,query:this._doc.location.search})&&(this._input.value=``);return}let n=this._doc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._input.value=``}}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}async _request(e,t={}){let n=this.getAttribute(`action`),i=this.getAttribute(`key`),s=n,c;e===`list`?s+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):c={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let l=await r(s,c);if(this._busy=!1,this._doc===null)return!1;if(l.ok){let e=new DOMParser().parseFromString(l.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].map(e=>({name:e.dataset.name,query:e.dataset.query})).filter(o).slice(0,a),this._error=null,this._render(),!0}return this._error=l.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._doc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`outline-secondary`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick),this._menu=n.createElement(`div`),this._menu.className=`dropdown-menu`,this._divider=n.createElement(`div`),this._divider.className=`dropdown-divider`,this._input=n.createElement(`input`),this._input.type=`text`,this._input.className=`form-control form-control-sm`,this._input.setAttribute(`aria-label`,`View name`),this._input.placeholder=`Name this view`;let r=n.createElement(`button`);r.type=`submit`,r.className=e(`primary`,`sm`),r.dataset.wui=t,r.textContent=`Save this view`,this._save=r,this._form=n.createElement(`form`),this._form.className=`d-flex gap-2 px-3 py-2`,this._form.append(this._input,r),this._form.addEventListener(`submit`,this._onSubmit),this.append(this._trigger,this._menu)}_render(){let e=this._doc,t=[];for(let n of this._views){let r=e.createElement(`a`);r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+n.query),r.textContent=n.name;let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${n.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:n.name}):this._commit(this._views.filter(e=>e.name!==n.name))),t.push(r,i)}if(this._error){let n=e.createElement(`div`);n.className=`dropdown-item-text text-danger small`,n.setAttribute(`role`,`alert`),n.textContent=this._error,t.push(n)}this._save.disabled=this._busy,this._menu.replaceChildren(...t,this._divider,this._form)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._menu.classList.toggle(`show`,e),this._trigger.setAttribute(`aria-expanded`,String(e)),e?this._doc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._doc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{return{store:this._doc.defaultView.localStorage,key:i+e}}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(o).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch{}}};export{s as t};
1
+ import{n as e,t}from"./buttonClass-Yk0Fwgs6.js";import{t as n}from"./elementBase-DV9IZZCu.js";import{l as r}from"./wuiHttp-DgnM7K2Q.js";var i=`wui-saved-views:`,a=20,o=e=>typeof e?.name==`string`&&typeof e?.query==`string`,s=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`]}constructor(){super(),this._doc=null,this._views=[],this._open=!1,this._busy=!1,this._error=null,this._trigger=null,this._menu=null,this._divider=null,this._form=null,this._input=null,this._save=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&this.contains(e.target)&&(e.key===`Escape`?(e.stopPropagation(),this._setOpen(!1),this._trigger.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._menu.contains(e.target)&&!/input|textarea/i.test(e.target.tagName)&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!this.contains(e.target)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;await this._request(`save`,{name:t,query:this._doc.location.search})&&(this._input.value=``);return}let n=this._doc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,a)),this._input.value=``}}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}async _request(e,t={}){let n=this.getAttribute(`action`),i=this.getAttribute(`key`),s=n,c;e===`list`?s+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:i}):c={method:`POST`,body:new URLSearchParams({intent:e,key:i,...t})},this._busy=!0,this._render();let l=await r(s,c);if(this._busy=!1,this._doc===null)return!1;if(l.ok){let e=new DOMParser().parseFromString(l.html,`text/html`);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].map(e=>({name:e.dataset.name,query:e.dataset.query})).filter(o).slice(0,a),this._error=null,this._render(),!0}return this._error=l.message||`The views could not be updated. Try again.`,this._render(),!1}_build(){let n=this._doc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=`Views`,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick),this._menu=n.createElement(`div`),this._menu.className=`dropdown-menu`,this._divider=n.createElement(`div`),this._divider.className=`dropdown-divider`,this._input=n.createElement(`input`),this._input.type=`text`,this._input.className=`form-control form-control-sm`,this._input.setAttribute(`aria-label`,`View name`),this._input.placeholder=`Name this view`;let r=n.createElement(`button`);r.type=`submit`,r.className=e(`primary`,`solid`,`sm`),r.dataset.wui=t,r.textContent=`Save this view`,this._save=r,this._form=n.createElement(`form`),this._form.className=`d-flex gap-2 px-3 py-2`,this._form.append(this._input,r),this._form.addEventListener(`submit`,this._onSubmit),this.append(this._trigger,this._menu)}_render(){let e=this._doc,t=[];for(let n of this._views){let r=e.createElement(`a`);r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+n.query),r.textContent=n.name;let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=`Delete`,i.setAttribute(`aria-label`,`Delete ${n.name}`),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:n.name}):this._commit(this._views.filter(e=>e.name!==n.name))),t.push(r,i)}if(this._error){let n=e.createElement(`div`);n.className=`dropdown-item-text text-danger small`,n.setAttribute(`role`,`alert`),n.textContent=this._error,t.push(n)}this._save.disabled=this._busy,this._menu.replaceChildren(...t,this._divider,this._form)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._menu.classList.toggle(`show`,e),this._trigger.setAttribute(`aria-expanded`,String(e)),e?this._doc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._doc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{return{store:this._doc.defaultView.localStorage,key:i+e}}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(o).slice(0,a):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch{}}};export{s as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./anchorOverlay-CBMAnDUt.js";import{n,t as r}from"./buttonClass-Yk0Fwgs6.js";import{t as i}from"./elementBase-DV9IZZCu.js";import{t as a}from"./tourOpenMark-nPeAJFSo.js";var o=`data-advance`,s=`wui-tour-hint`,c=`wui-tour-pointer`,l=`Click {actionName} to continue.`,u=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]`,d=(e,t)=>e?.advanceOn===`click`&&!!t,f=e=>(e??``).replace(/\s+/g,` `).trim();function p(e){let t=e.ownerDocument,n=(e.getAttribute(`aria-labelledby`)||``).split(/\s+/).filter(Boolean),r=e.tagName===`INPUT`&&/^(button|submit|reset)$/.test(e.type)?e.value:``,i=[n.map(e=>t.getElementById(e)?.textContent??``).join(` `),e.getAttribute(`aria-label`),Array.from(e.labels??[],e=>e.textContent).join(` `),e.getAttribute(`alt`),r,e.textContent,e.getAttribute(`title`)];for(let e of i){let t=f(e);if(t)return t}return``}function m(e){for(let t of[e,...e.querySelectorAll(u)])if(t.tabIndex>=0&&!t.disabled)return t;return null}function h(e,t,n){let r=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(e=>e&&e!==t);n&&r.push(t),r.length>0?e.setAttribute(`aria-describedby`,r.join(` `)):e.removeAttribute(`aria-describedby`)}function g(e,t){let n=e.querySelector(`.${s}`),r=e.querySelector(`.wui-tour-text`)?.id,i=r?`${r.replace(/-text$/,``)}-hint`:``;t?(n||(n=e.ownerDocument.createElement(`p`),n.className=s,i&&(n.id=i),e.querySelector(`.wui-tour-actions`).before(n)),n.textContent=t,i&&h(e,i,!0)):(n?.remove(),i&&h(e,i,!1))}function _(e,t){let n=e.querySelector(`.${c}`);if(!t){n?.remove();return}if(n)return;let r=e.ownerDocument.createElement(`span`);r.className=c,r.setAttribute(`aria-hidden`,`true`),e.append(r)}var ee=e=>getComputedStyle(e).animationName;function v(e,{layer:t,spot:n,card:r},i,a){let s=d(i,a);t.toggleAttribute(o,s&&!(t.getRootNode()instanceof ShadowRoot)),n.hasAttribute(o)&&(n.removeAttribute(o),s&&ee(n)),s&&n.setAttribute(o,``),_(n,s);let c=r.querySelector(`.wui-tour-next`);c.classList.toggle(`btn-primary`,!s),c.classList.toggle(`btn-link`,s);let u=s?f(i.actionLabel)||p(a):``,m=e.getAttribute(`advance-label`)||l,h=u?m.replace(/\{actionName\}/g,()=>u):``;return g(r,h),h}function te(e,t,n){if(!d(e,t))return()=>{};let r=null,i=()=>{r??=setTimeout(n,0)};return t.addEventListener(`click`,i),()=>{t.removeEventListener(`click`,i),clearTimeout(r)}}function ne(e,t,n,r){return e.contains(r)||d(t,n)&&n.contains(r)}function re(e,{card:t,active:n,step:r,target:i}){let a=Array.from(t.querySelectorAll(`button`)).filter(e=>!e.hidden),o=d(r,i)?m(i):null;o&&a.push(o);let s=a.findIndex(e=>e===n||e===o&&i.contains(n));e.preventDefault(),a[s===-1?e.shiftKey?a.length-1:0:(s+(e.shiftKey?-1:1)+a.length)%a.length].focus()}var y=2/3,b=1e3,ie=/* @__PURE__ */ new Set([`top`,`left`,`width`,`height`]),x=/* @__PURE__ */ new WeakMap,S=(e,t)=>typeof e.getAnimations==`function`?e.getAnimations().filter(t):[],C=e=>e.transitionProperty===`opacity`,ae=e=>ie.has(e.transitionProperty),oe=e=>typeof e.animationName==`string`&&e.animationName.startsWith(`wui-tour-`);function w(e){return e.length===0?null:new Promise(t=>{let n=setTimeout(t,b);Promise.allSettled(e.map(e=>e.finished)).then(()=>{clearTimeout(n),t()})})}function se(e){let t=e.parentElement?.querySelector(`:scope > .wui-tour-spot`),n=0;for(let e of t?S(t,ae):[]){let t=e.effect?.getComputedTiming?.();if(typeof t?.duration!=`number`)continue;let r=typeof e.currentTime==`number`?e.currentTime:0;n=Math.max(n,(t.delay??0)+t.duration*y-r)}return n}function T(e){let t=se(e);t>0?e.style.setProperty(`--wui-tour-card-delay`,`${Math.round(t)}ms`):e.style.removeProperty(`--wui-tour-card-delay`),e.dataset.state=`entering`;let n={};x.set(e,n);let r=()=>{x.get(e)===n&&e.dataset.state===`entering`&&(e.dataset.state=`shown`)},i=S(e,oe);i.length===0?r():Promise.allSettled(i.map(e=>e.finished)).then(r)}function E(e){return e.dataset.state=`leaving`,w(S(e,C))}function D(e){let t=e.classList.contains(`wui-tour-layer`)?e:e.shadowRoot?.querySelector(`.wui-tour-layer`);t&&(t.dataset.state=`leaving`);let n=t?w(S(t,C)):null;n?(e.setAttribute(`inert`,``),n.then(()=>e.remove())):e.remove()}var O=2,k=12,A=8,j=4,M=20,ce=`(max-width: 575.98px)`,le=[`bottom`,`top`,`right`,`left`],N=[`top-left`,`top-right`,`bottom-right`,`bottom-left`],P,F=(e,t,n)=>Math.max(t,Math.min(e,n)),I=(e,t,n,r)=>(Math.max(e,n)+Math.min(t,r))/2;function L(e,t){if(!t?.scrollIntoView)return;e.style.maxHeight=``;let n=U(e),r=e.offsetHeight+k;if(t.getBoundingClientRect().height+4+r*2<=n.bottom-n.top){t.scrollIntoView({block:`center`,inline:`nearest`});return}let i=t.style.scrollMarginTop;t.style.scrollMarginTop=`${n.top+r+O}px`,t.scrollIntoView({block:`start`,inline:`nearest`}),t.style.scrollMarginTop=i}function R(e,t,n){let r=e.style,i=t.style,a=W(t);if(!n){r.top=`50%`,r.left=`50%`,r.width=`0px`,r.height=`0px`,r.boxShadow=`0 0 0 100vmax var(--color-scrim-strong)`;for(let e of N)r.removeProperty(`border-${e}-radius`),r.removeProperty(`corner-${e}-shape`);t.dataset.placement=`center`,a.hidden=!0,i.position=`fixed`,i.top=`50%`,i.left=`50%`,i.transform=`translate(-50%, -50%)`,i.maxHeight=`calc(100vh - 16px)`;return}r.boxShadow=``,i.transform=``,i.position=`fixed`;let o=n.getBoundingClientRect();r.top=`${o.top}px`,r.left=`${o.left}px`,r.width=`${o.width}px`,r.height=`${o.height}px`,z(r,n);let s=t.scrollTop;i.maxHeight=``;let c={width:t.offsetWidth,height:t.offsetHeight},l=U(t),u=l.bottom-l.top,d={bottom:l.bottom-o.bottom-k,top:o.top-k-l.top,right:l.right-o.right-k,left:o.left-k-l.left},f=window.matchMedia(ce).matches,p=le.find(e=>e===`top`||e===`bottom`?c.height<=d[e]+1:!f&&c.width<=d[e]+1&&c.height<=u+1),m=Math.min(o.bottom,l.bottom+A)-Math.max(o.top,l.top-A);p?B(t,a,p,o,l,c):m>=Math.min(c.height,u)+8?V(t,a,o,l,c):H(t,a,d.bottom>=d.top?`bottom`:`top`,o,l,c,d),t.scrollTop=s}function z(e,t){P??=CSS.supports(`corner-top-left-shape`,`squircle`);let n=getComputedStyle(t);for(let t of N)e.setProperty(`border-${t}-radius`,n.getPropertyValue(`border-${t}-radius`)),P&&e.setProperty(`corner-${t}-shape`,n.getPropertyValue(`corner-${t}-shape`))}function B(e,t,n,r,i,a){let o=n===`top`||n===`bottom`,s,c,l;if(o){let e=I(r.left,r.right,i.left,i.right);s=F(e-a.width/2,i.left,i.right-a.width),c=n===`bottom`?r.bottom+k:r.top-k-a.height,l=F(e-s,M,a.width-M)}else{let e=I(r.top,r.bottom,i.top,i.bottom);c=F(e-a.height/2,i.top,i.bottom-a.height),s=n===`right`?r.right+k:r.left-k-a.width,l=F(e-c,M,a.height-M)}e.dataset.placement=n,e.style.top=`${c}px`,e.style.left=`${s}px`,t.hidden=!1,t.style.left=o?`${l-e.clientLeft-t.offsetWidth/2}px`:``,t.style.top=o?``:`${l-e.clientTop-t.offsetHeight/2}px`}function V(e,t,n,r,i){let a=r.bottom-r.top;e.dataset.placement=`overlap`,t.hidden=!0,e.style.maxHeight=i.height>a?`${Math.max(a,0)}px`:``;let o=Math.min(n.bottom,r.bottom)-j;e.style.top=`${Math.max(r.top,o-Math.min(i.height,a))}px`,e.style.left=`${F(n.left+j,r.left,r.right-i.width)}px`}function H(e,t,n,r,i,a,o){let s=Math.max(o[n],0),c=Math.min(a.height,s);e.dataset.placement=n,t.hidden=!0,e.style.maxHeight=a.height>s?`${s}px`:``,e.style.top=`${n===`bottom`?r.bottom+k:r.top-k-c}px`;let l=I(r.left,r.right,i.left,i.right);e.style.left=`${F(l-a.width/2,i.left,i.right-a.width)}px`}function U(e){let t=e.parentElement,n=t?getComputedStyle(t):null,r=e=>Number.parseFloat(n?.[e])||0;return{top:r(`paddingTop`)+A,bottom:window.innerHeight-r(`paddingBottom`)-A,left:r(`paddingLeft`)+A,right:window.innerWidth-r(`paddingRight`)-A}}function W(e){let t=e.querySelector(`:scope > .wui-tour-arrow`);return t||(t=document.createElement(`span`),t.className=`wui-tour-arrow`,t.setAttribute(`aria-hidden`,`true`),t.hidden=!0,e.append(t)),t}var ue=0,de=`btn btn-sm btn-link`;function fe(e,t,i){let a=`wui-tour-end-${++ue}`,o=!!(t.nextLabel&&t.nextHref),s=e.createElement(`div`);if(s.className=`wui-tour-card wui-tour-end`,s.dataset.layout=`center`,o&&(s.dataset.next=``),s.setAttribute(`role`,`dialog`),i&&s.setAttribute(`aria-modal`,`true`),s.tabIndex=-1,s.setAttribute(`aria-labelledby`,`${a}-title`),s.setAttribute(`aria-describedby`,`${a}-message`),s.innerHTML=` <div class="wui-tour-end-mark" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></div> <h2 class="wui-tour-title wui-tour-end-title" id="${a}-title"></h2> <p class="wui-tour-text wui-tour-end-message" id="${a}-message"></p> <div class="wui-tour-actions">${o?`<a class="${n(`primary`,`solid`,`sm`)} wui-tour-end-next" data-wui="${r}"></a>`:``}<button type="button" class="${o?de:n(`primary`,`solid`,`sm`)} wui-tour-end-button" data-wui="${r}"></button></div>`,s.querySelector(`.wui-tour-end-title`).textContent=t.title,s.querySelector(`.wui-tour-end-message`).textContent=t.message,s.querySelector(`.wui-tour-end-button`).textContent=t.button,o){let e=s.querySelector(`.wui-tour-end-next`);e.textContent=t.nextLabel,e.setAttribute(`href`,t.nextHref)}return s}var pe=e=>e.button===0&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey;function me(e,t,n){let r=e.ownerDocument,i=e.getRootNode()===r,a=e.querySelector(`.wui-tour-card:not(.wui-tour-end)`),o=e.querySelector(`.wui-tour-spot`),s=e.querySelector(`[role=status]`),c=fe(r,t,i),l=c.querySelector(`.wui-tour-end-button`),u=c.querySelector(`.wui-tour-end-next`),d=u?[u,l]:[l],f=new AbortController;return new Promise(p=>{let m=e=>{f.abort(),p(e)};if(n?.aborted){m(`done`);return}let h={signal:f.signal};n?.addEventListener(`abort`,()=>m(`done`),h),l.addEventListener(`click`,()=>m(`done`),h),u&&u.addEventListener(`click`,e=>{pe(e)&&(e.preventDefault(),m(`next`))},h),r.addEventListener(`keydown`,e=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),m(`done`);else if(e.key===`Enter`&&u&&!e.shiftKey&&(e.composedPath?.()[0]??e.target)===u)e.preventDefault(),m(`next`);else if(e.key===`Tab`&&i){e.preventDefault();let t=d.indexOf(r.activeElement),n=t===-1?e.shiftKey?d.length-1:0:(t+(e.shiftKey?-1:1)+d.length)%d.length;d[n].focus()}}},{capture:!0,signal:f.signal}),i&&r.addEventListener(`focusin`,e=>{c.contains(e.target)||d[0].focus()},h);let g=()=>{f.signal.aborted||(a.hidden=!0,R(o,a,null),e.append(c),T(c),s.textContent=[t.title,t.message].filter(Boolean).join(`. `),d[0].focus())},_=E(a);_?_.then(g):g()})}var he=` :host { all: initial; ${Object.entries({"--wui-z-tour":`1550`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-popover":`0px 8px 28px -6px rgba(7, 20, 55, 0.14)`,"--wui-ease-out":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-motion-duration":`200ms`,"--wui-tour-motion-ease":`cubic-bezier(0.22, 1, 0.36, 1)`,"--wui-tour-spot-duration":`240ms`,"--wui-tour-spot-ease":`cubic-bezier(0.32, 0.72, 0, 1)`,"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-text":`#4F46E5`,"--color-focus-ring":`#4F46E5`,"--wui-focus-ring-width":`2px`,"--wui-focus-ring-offset":`2px`,"--color-on-primary":`#FFFFFF`,"--color-success-soft":`#E8FAEE`,"--color-success-text":`#0e7531`,"--color-on-scrim":`#FFFFFF`,"--color-scrim-strong":`color-mix(in srgb, #071437 62%, transparent)`,"--color-surface":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-bg-muted":`#F5F6FA`}).map(([e,t])=>` ${e}: ${t};`).join(` `)} } *, *::before, *::after { box-sizing: border-box; } [hidden] { display: none !important; } .visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; } .btn { display: inline-block; margin: 0; padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: 0.375rem; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; line-height: 1.5; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; } .btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; } .btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); } .btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); } .btn-outline-neutral { border-color: var(--color-text-muted); color: var(--color-text-muted); } .btn-outline-neutral:hover { background: var(--color-bg-muted); color: var(--color-text); } .btn-link { font-weight: 400; color: var(--color-primary-text); text-decoration: underline; } .btn-link:hover { color: var(--color-primary-hover); } .wui-tour-layer { pointer-events: none; font-family: "Webority Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; font-weight: 400; line-height: 1.5; color: var(--color-text); text-align: start; } .wui-tour-card { pointer-events: auto; } .wui-tour-layer { position: fixed; inset: 0; z-index: var(--wui-z-tour); } .wui-tour-spot { position: fixed; box-shadow: 0 0 0 2px var(--color-primary), 0 0 4px 2px color-mix(in srgb, var(--color-primary) 30%, transparent), 0 0 0 100vmax var(--color-scrim-strong); pointer-events: none; } .wui-tour-card { display: flex; flex-direction: column; gap: 8px; width: min(360px, 100vw - 16px); padding: 16px; overflow-y: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--wui-radius-lg); corner-shape: squircle; box-shadow: var(--wui-shadow-popover); } .wui-tour-card:focus { outline: none; } .wui-tour-card:focus-visible { outline: var(--wui-focus-ring-width) solid var(--color-focus-ring); outline-offset: var(--wui-focus-ring-offset); } .wui-tour-title { margin: 0; font-size: 16px; font-weight: 600; } .wui-tour-text { margin: 0; font-size: 14px; color: var(--color-text-muted); } .wui-tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; } .wui-tour-nav { display: flex; gap: 8px; } .wui-tour-skip { color: var(--color-text-muted); } .wui-tour-back, .wui-tour-next { min-width: 64px; } @keyframes wui-tour-fade-in { from { opacity: 0; } to { opacity: 1; } } @keyframes wui-tour-card-enter { from { opacity: 0; scale: 0.96; translate: var(--wui-tour-card-lift, 0 6px); } to { opacity: 1; scale: 1; translate: 0 0; } } .wui-tour-layer[data-state=leaving], .wui-tour-card[data-state=leaving] { opacity: 0; } .wui-tour-layer[data-state=leaving], .wui-tour-layer[data-state=leaving] * { pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .wui-tour-layer { animation: wui-tour-fade-in var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-layer[data-state=leaving] { transition: opacity var(--wui-tour-motion-duration) var(--wui-tour-motion-ease); } .wui-tour-spot { transition: top var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), left var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), width var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), height var(--wui-tour-spot-duration) var(--wui-tour-spot-ease), border-radius var(--wui-tour-spot-duration) var(--wui-tour-spot-ease); } .wui-tour-spot[data-tracking] { transition: none; } .wui-tour-card { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=top] { --wui-tour-card-lift: 0 -6px; transform-origin: bottom center; } .wui-tour-card[data-placement=bottom] { --wui-tour-card-lift: 0 6px; transform-origin: top center; } .wui-tour-card[data-placement=left] { --wui-tour-card-lift: -6px 0; transform-origin: right center; } .wui-tour-card[data-placement=right] { --wui-tour-card-lift: 6px 0; transform-origin: left center; } .wui-tour-card[data-placement=overlap], .wui-tour-card[data-placement=center] { --wui-tour-card-lift: 0 0; transform-origin: center; } .wui-tour-card[data-state=entering] { animation: wui-tour-card-enter var(--wui-tour-motion-duration) var(--wui-tour-motion-ease) var(--wui-tour-card-delay, 0ms) both; } .wui-tour-card[data-state=leaving] { transition: opacity calc(var(--wui-tour-motion-duration) / 2) var(--wui-tour-motion-ease); } } @media (prefers-reduced-motion: reduce) { .wui-tour-layer { animation: wui-tour-fade-in 120ms linear; } .wui-tour-layer[data-state=leaving] { transition: opacity 120ms linear; } .wui-tour-card[data-state=entering] { animation: wui-tour-fade-in 120ms linear both; } } .wui-tour-progress-bar { display: flex; gap: 4px; } .wui-tour-progress-segment { flex: 1 1 0; height: 4px; border-radius: 999px; background: var(--color-border); } .wui-tour-progress-segment[data-filled] { background: var(--color-primary); } .wui-tour-position { margin: 0; font-size: 12px; color: var(--color-text-muted); } .wui-tour-layer { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); } .wui-tour-card:has(.wui-tour-arrow:not([hidden])) { overflow: visible; } .wui-tour-arrow { position: absolute; width: 8px; height: 8px; background: var(--color-surface); border: 1px solid var(--color-border); rotate: 45deg; pointer-events: none; } .wui-tour-card[data-placement=bottom] .wui-tour-arrow { top: -5px; border-right-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=top] .wui-tour-arrow { bottom: -5px; border-top-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=right] .wui-tour-arrow { left: -5px; border-top-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); } .wui-tour-card[data-placement=left] .wui-tour-arrow { right: -5px; border-bottom-color: rgba(0, 0, 0, 0); border-left-color: rgba(0, 0, 0, 0); } @media (max-width: 575.98px) { .wui-tour-card { width: calc(100vw - 16px); } .wui-tour-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; } } .wui-tour-media { position: relative; order: -1; flex: none; aspect-ratio: 16/9; margin: -16px -16px 4px; overflow: hidden; background: var(--color-border); } .wui-tour-media>img, .wui-tour-media>video { display: block; width: 100%; height: 100%; object-fit: cover; } .wui-tour-card[data-welcome] { width: min(420px, 100vw - 16px); } .wui-tour-media-toggle { position: absolute; inset-block-end: 8px; inset-inline-end: 8px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--color-scrim-strong); color: var(--color-on-scrim); cursor: pointer; } .wui-tour-media-toggle>svg { width: 20px; height: 20px; fill: currentColor; } .wui-tour-media-toggle:focus-visible { outline: 2px solid var(--color-on-scrim); outline-offset: 2px; } .wui-tour-layer[data-advance] { pointer-events: none; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-card { pointer-events: auto; } .wui-tour-layer[data-advance]:not([data-state=leaving]) .wui-tour-spot::before { content: ""; position: absolute; inset: -100vmax; pointer-events: auto; clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 100vmax 100vmax, calc(100% - 100vmax) 100vmax, calc(100% - 100vmax) calc(100% - 100vmax), 100vmax calc(100% - 100vmax), 100vmax 100vmax); } .wui-tour-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text); } .wui-tour-pointer { position: absolute; top: 50%; left: 50%; width: 18px; height: 24px; pointer-events: none; } .wui-tour-pointer::before { content: ""; position: absolute; inset: 0; background: var(--color-primary); clip-path: polygon(0 0, 0 75%, 28% 58%, 46% 100%, 62% 92%, 45% 52%, 85% 52%); filter: drop-shadow(1px 0 0 var(--color-surface)) drop-shadow(-1px 0 0 var(--color-surface)) drop-shadow(0 1px 0 var(--color-surface)) drop-shadow(0 -1px 0 var(--color-surface)); } .wui-tour-pointer::after { content: ""; position: absolute; top: -16px; left: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); opacity: 0; display: none; } @media (max-width: 575.98px) { .wui-tour-pointer { width: 24px; height: 24px; translate: -50% -50%; } .wui-tour-pointer::before { clip-path: none; border-radius: 50%; box-shadow: 0 0 0 2px var(--color-surface); filter: none; } .wui-tour-pointer::after { top: -4px; left: -4px; } } @keyframes wui-tour-tap { 0% { opacity: 0; transform: translate(56px, 44px) scale(1); } 10% { opacity: 1; transform: translate(56px, 44px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 52% { transform: translate(0, 0) scale(0.86); } 60% { transform: translate(0, 0) scale(1); } 85% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(0, 0) scale(1); } } @keyframes wui-tour-ripple { 0%, 50% { opacity: 0; transform: scale(0.2); } 52% { opacity: 0.35; transform: scale(0.2); } 80%, 100% { opacity: 0; transform: scale(1); } } @media (prefers-reduced-motion: no-preference) { .wui-tour-pointer { opacity: 0; animation: wui-tour-tap calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } .wui-tour-pointer::after { display: block; animation: wui-tour-ripple calc(var(--wui-duration-slow) * 6) var(--wui-ease-out) var(--wui-tour-spot-duration) infinite; } } @keyframes wui-tour-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } } .wui-tour-end[data-layout=center] { --wui-tour-card-lift: 0 0; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); transform-origin: center; align-items: center; gap: 8px; width: min(420px, 100vw - 16px); max-height: calc(100vh - 16px); padding: 24px; text-align: center; } .wui-tour-end[data-layout=center] .wui-tour-actions { justify-content: center; margin-top: 8px; } .wui-tour-end[data-layout=center][data-next] .wui-tour-actions { flex-direction: column; align-items: stretch; width: 100%; gap: var(--wui-space-xs); } .wui-tour-end-mark { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success-text); } .wui-tour-end-mark>svg { width: 26px; height: 26px; } .wui-tour-end-mark path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; } .wui-tour-end-title { font-size: 18px; } .wui-tour-end-message { text-wrap: balance; } .wui-tour-end-next { text-wrap: balance; } .wui-tour-end-button { min-width: 120px; } @media (prefers-reduced-motion: no-preference) { .wui-tour-end-mark path { animation: wui-tour-check 300ms var(--wui-ease-out) calc(var(--wui-tour-card-delay, 0ms) + 120ms) both; } } `,G=`wui-tour-media`,ge=`wui-tour-media-toggle`,K=`http://www.w3.org/2000/svg`,_e=`M6 5h4v14H6zM14 5h4v14h-4z`,ve=`M8 5v14l11-7z`,ye={pause:`Pause animation`,play:`Play animation`},be=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0;function xe(e){let t=document.createElementNS(K,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(K,`path`);return n.setAttribute(`d`,e),t.appendChild(n),t}function Se(e){let t=document.createElement(`img`);return t.setAttribute(`alt`,e.mediaAlt??``),t.setAttribute(`width`,`1280`),t.setAttribute(`height`,`720`),t.setAttribute(`loading`,`lazy`),t.setAttribute(`decoding`,`async`),t.setAttribute(`src`,e.media),t}function Ce(e,t){let n=document.createElement(`video`);return n.muted=!0,n.setAttribute(`muted`,``),n.loop=!0,n.setAttribute(`playsinline`,``),t&&n.setAttribute(`autoplay`,``),n.setAttribute(`preload`,t?`auto`:`metadata`),e.mediaAlt&&n.setAttribute(`aria-label`,e.mediaAlt),e.mediaPoster&&n.setAttribute(`poster`,e.mediaPoster),n.setAttribute(`src`,e.media),n}function we(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=ge;let r=(r=!e.paused)=>{n.setAttribute(`aria-label`,r?t.pause:t.play),n.replaceChildren(xe(r?_e:ve))};return e.addEventListener(`play`,()=>r()),e.addEventListener(`pause`,()=>r()),n.addEventListener(`click`,()=>{e.paused?e.play()?.catch(()=>r()):e.pause()}),r(e.hasAttribute(`autoplay`)),n}function Te(e){let t=e.querySelector(`:scope > .${G}`);if(!t)return;let n=t.querySelector(`video`);n&&(n.pause(),n.removeAttribute(`src`),n.load()),t.remove()}function Ee(e,t,n=ye){if(Te(e),!t.media){e.removeAttribute(`data-media`);return}let r=document.createElement(`div`);if(r.className=G,t.mediaType===`video`){let e=Ce(t,!be());r.append(e,we(e,n))}else r.appendChild(Se(t));e.prepend(r),e.setAttribute(`data-media`,t.target?`step`:`welcome`)}var De=`Step {current} of {total}`;function Oe(e){let t=/* @__PURE__ */ new Set;return{drop:e=>{t.add(e)},position:e=>{t.delete(e);let n=0;for(let r of t)r<e&&n++;return e+1-n},total:()=>e-t.size}}function ke(e,t,n){return(e.getAttribute(`progress-label`)||De).replace(/\{(current|total)\}/g,(e,r)=>String(r===`current`?t:n))}function Ae(e,{text:t,position:n,total:r}){let i=e.querySelector(`.wui-tour-position`);i.textContent=t;let a=e.querySelector(`.wui-tour-progress-bar`);if(!a){let t=e.ownerDocument,n=t.createElement(`div`);n.className=`wui-tour-progress`,n.setAttribute(`aria-hidden`,`true`),a=t.createElement(`div`),a.className=`wui-tour-progress-bar`,n.append(a),i.before(n)}let o=a.children;for(;o.length<r;){let t=e.ownerDocument.createElement(`span`);t.className=`wui-tour-progress-segment`,a.append(t)}for(;o.length>r;)a.lastElementChild.remove();for(let e=0;e<o.length;e++)o[e].toggleAttribute(`data-filled`,e<n)}var je=`wui-tour-step`,Me=`wui-tour-host`,Ne=`wui-tour-seen:`,q=`data-tracking`,Pe={back:`Back`,next:`Next`,skip:`Skip`,done:`Done`,mediaPause:`Pause animation`,mediaPlay:`Play animation`,endTitle:`You're all set`,endMessage:`You know your way around now. Enjoy exploring.`,endButton:`Done`},Fe={back:`back-label`,next:`next-label`,skip:`skip-label`,done:`done-label`,mediaPause:`media-pause-label`,mediaPlay:`media-play-label`,endTitle:`end-title`,endMessage:`end-message`,endButton:`end-button`},Ie=[[`media`,`media`],[`mediaAlt`,`media-alt`],[`mediaPoster`,`media-poster`],[`mediaType`,`media-type`],[`advanceOn`,`advance-on`],[`actionLabel`,`action-label`]],J={index:null,position:null,total:null},Le=0;function Y(e=Ne,t=globalThis.localStorage){return{isSeen:async n=>t.getItem(e+n)===`1`,markSeen:async n=>{t.setItem(e+n,`1`)}}}var X=e=>!e?.isConnected||getComputedStyle(e).visibility===`hidden`?!1:e.getClientRects().length>0,Z=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),Q=()=>{let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e},$=null;function Re(e){$||($=new CSSStyleSheet,$.replaceSync(he)),e.adoptedStyleSheets=[$]}var ze=class extends i{static get observedAttributes(){return[`open`]}constructor(){super(),this.seenStore=null,this.onBeforeStep=null,this._run=0,this._running=!1,this._layer=null,this._outer=null,this._shadow=null,this._unbindAdvance=null,this._ending=null,this._seenMark=null}connectedCallback(){this.hasAttribute(`open`)&&this.start()}disconnectedCallback(){this.stop()}attributeChangedCallback(e,t,n){e===`open`&&this.isConnected&&(n===null?this.stop():this.start())}get tourId(){return this.getAttribute(`tour-id`)||``}set tourId(e){e==null||e===``?this.removeAttribute(`tour-id`):this.setAttribute(`tour-id`,String(e))}get isolated(){return this.hasAttribute(`isolated`)}set isolated(e){this.toggleAttribute(`isolated`,e===!0||e===``||e===`true`)}_stepList(){return Array.from(this.querySelectorAll(`:scope > ${je}`),e=>{let t={target:e.getAttribute(`target`)||``,title:e.getAttribute(`title`)||void 0,description:e.textContent.trim()};for(let[n,r]of Ie)e.hasAttribute(r)&&(t[n]=e.getAttribute(r));return t})}_store(){return this.seenStore?this.seenStore:this.getAttribute(`seen-store`)===`local`?Y():globalThis.window?.WUI?.tour?.seenStore||null}_label(e){return this.getAttribute(Fe[e])||Pe[e]}_endDialogText(){if(this.getAttribute(`end-dialog`)===`false`)return null;let e=(this.getAttribute(`end-next-label`)??``).trim(),t=(this.getAttribute(`end-next-href`)??``).trim();return{title:this._label(`endTitle`),message:this._label(`endMessage`),button:this._label(`endButton`),nextLabel:e,nextHref:t}}_markSeen(e){let t=this._store();return t?t.markSeen(this.tourId,e):null}async start(){if(this._running)return;this._running=!0;let e=++this._run;this.hasAttribute(`open`)||this.setAttribute(`open`,``);try{await this._start(e)}catch(t){throw e===this._run&&(this._running=!1),t}}async _start(e){this._steps=this._stepList(),this._progress=Oe(this._steps.length);let t=this._store();if(t&&!this.tourId)throw Error(`<wui-tour> needs a tour-id to use a seen store.`);if(t&&await t.isSeen(this.tourId)){e===this._run&&this._finish(`alreadySeen`);return}for(let[e,t]of this._steps.entries())t.target&&!X(document.querySelector(t.target))&&this._progress.drop(e);this._returnFocus=document.activeElement;let n=await this._locate(0,1,e);e===this._run&&(n?(this._firstIndex=n.index,this.dispatchEvent(new CustomEvent(`wui-tour:start`,{bubbles:!0,detail:{total:this._progress.total()}})),e===this._run&&(this._build(),this._show(n))):this._finish(`noTargets`))}next(){return this._move(1)}back(){return!this._current||this._current.index<=this._firstIndex?Promise.resolve():this._move(-1)}async goTo(e){if(this._current){if(!Number.isInteger(e)||e<0||e>=this._steps.length)throw RangeError(`<wui-tour> has no step ${e}; it has ${this._steps.length}.`);await this._go(e,1)}}stop(){this._running&&(this._run++,this._teardown(),this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`))}async _locate(e,t,n){let r=this._steps;for(let i=e;i>=0&&i<r.length;i+=t){let e=r[i];if(await this._beforeStep(e,i),n!==this._run)return null;if(!e.target)return{index:i,target:null};let t=document.querySelector(e.target);if(X(t))return this._progress.position(i),{index:i,target:t};this._progress.drop(i)}return null}async _beforeStep(e,t){let n=[];this.dispatchEvent(new CustomEvent(`wui-tour:beforestep`,{bubbles:!0,detail:{step:e,index:t,wait:e=>n.push(e)}})),await Promise.all(n),typeof this.onBeforeStep==`function`&&await this.onBeforeStep(e,t)}_build(){let t=`wui-tour-${++Le}`,i=document.createElement(`div`);i.className=`wui-tour-layer`,i.innerHTML=` <div class="wui-tour-spot" aria-hidden="true"></div> <div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${t}-title" aria-describedby="${t}-text"> <p class="wui-tour-position"></p> <h2 class="wui-tour-title" id="${t}-title"></h2> <p class="wui-tour-text" id="${t}-text"></p> <div class="wui-tour-actions"> <button type="button" class="btn btn-sm btn-link wui-tour-skip"></button> <div class="wui-tour-nav"> <button type="button" class="${n(`neutral`,`outline`,`sm`)} wui-tour-back" data-wui="${r}"></button> <button type="button" class="${n(`primary`,`solid`,`sm`)} wui-tour-next" data-wui="${r}"></button> </div> </div> </div> <div class="visually-hidden" role="status" aria-live="polite"></div>`;let o=i;this._shadow=null,this.isolated&&(o=document.createElement(Me),this._shadow=o.attachShadow({mode:`open`}),Re(this._shadow),this._shadow.appendChild(i)),document.body.appendChild(o),document.documentElement.setAttribute(a,``),this._outer=o,this._layer=i,this._spot=i.querySelector(`.wui-tour-spot`),this._card=i.querySelector(`.wui-tour-card`),this._live=i.querySelector(`[role=status]`),this._card.querySelector(`.wui-tour-skip`).addEventListener(`click`,()=>this._close(`skipped`,`button`)),this._card.querySelector(`.wui-tour-back`).addEventListener(`click`,()=>this._move(-1)),this._card.querySelector(`.wui-tour-next`).addEventListener(`click`,()=>this._move(1)),this._shadow&&this._card.removeAttribute(`aria-modal`),this._onKey=e=>this._key(e),this._onFocusIn=e=>{if(!this._layer||this._ending)return;let t=this._current,n=t?this._steps[t.index]:null;ne(this._layer,n,t?.target??null,e.target)||this._card.focus()},document.addEventListener(`keydown`,this._onKey,!0),this._shadow||document.addEventListener(`focusin`,this._onFocusIn),e(o,()=>this._follow())}_active(){return this._shadow?this._shadow.activeElement:document.activeElement}_show(e){this._current=e;let{index:t,target:n}=e,r=this._steps[t],i=this._card,a=this._progress.position(t),o=this._progress.total(),s=a===o&&!this._endDialogText(),c=ke(this,a,o);Ae(i,{text:c,position:a,total:o}),Ee(i,r,{pause:this._label(`mediaPause`),play:this._label(`mediaPlay`)}),i.toggleAttribute(`data-welcome`,!n);let l=v(this,{layer:this._layer,spot:this._spot,card:i},r,n),u=i.querySelector(`.wui-tour-title`);u.textContent=r.title||``,u.hidden=!r.title,i.querySelector(`.wui-tour-text`).textContent=r.description||``,i.querySelector(`.wui-tour-skip`).textContent=this._label(`skip`),i.querySelector(`.wui-tour-back`).textContent=this._label(`back`),i.querySelector(`.wui-tour-back`).hidden=t<=this._firstIndex,i.querySelector(`.wui-tour-next`).textContent=this._label(s?`done`:`next`);let d=[c,r.title,r.description].filter(Boolean).join(`. `);this._live.textContent=l?[d,l].join(/[.!?]$/.test(d)?` `:`. `):d,L(i,n),this._spot.removeAttribute(q),this._place(),T(i),this._unbindAdvance?.(),this._unbindAdvance=te(r,n,()=>this._move(1));let f=this._active();(i.contains(f)?!f.hidden:this._shadow!==null&&Z(Q()))||i.focus(),this.dispatchEvent(new CustomEvent(`wui-tour:step`,{bubbles:!0,detail:{step:r,index:t,position:a,total:o}}))}_place(){this._current&&this._layer&&R(this._spot,this._card,this._current.target)}_follow(){if(!this._current||!this._layer||this._ending)return;let e=this._spot.style.cssText;this._place(),this._spot.style.cssText!==e&&this._spot.setAttribute(q,``)}async _move(e){this._current&&await this._go(this._current.index+e,e)}async _go(e,t){if(!this._current||this._moving)return;this._moving=!0;let n=this._run;try{let r=await this._locate(e,t,n);if(n!==this._run)return;if(r){let e=E(this._card);if(e&&await e,n!==this._run)return;this._show(r)}else if(t>0){let e=this._endDialogText(),t=e?await this._showEnd(e):`done`;if(n!==this._run)return;let r=await this._close(t===`next`?`next`:`finished`);t===`next`&&r&&this.ownerDocument.defaultView.location.assign(e.nextHref)}}finally{this._moving=!1}}_showEnd(e){return this._unbindAdvance?.(),this._unbindAdvance=null,v(this,{layer:this._layer,spot:this._spot,card:this._card},null,null),this._spot.removeAttribute(q),this._ending=new AbortController,this._seenMark=this._markSeen(`finished`),me(this._layer,e,this._ending.signal)}_key(e){if(!(!this._layer||this._ending||e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this._close(`skipped`,`escape`);else if(e.key===`ArrowRight`||e.key===`ArrowLeft`){if(Z(e.composedPath?.()[0]??e.target))return;e.preventDefault(),e.key===`ArrowRight`?this._move(1):this._current.index>this._firstIndex&&this._move(-1)}else if(e.key===`Tab`&&!this._shadow){let{index:t,target:n}=this._current;re(e,{card:this._card,active:this._active(),step:this._steps[t],target:n})}}}_teardown(){if(!this._layer)return;document.removeEventListener(`keydown`,this._onKey,!0),document.removeEventListener(`focusin`,this._onFocusIn);let e=!this._shadow||this._shadow.activeElement!==null||!document.activeElement||document.activeElement===document.body;this._unbindAdvance?.(),this._unbindAdvance=null,this._ending?.abort(),this._ending=null,this._seenMark=null,t(this._outer),D(this._outer),document.documentElement.removeAttribute(a),this._outer=null,this._shadow=null,this._layer=null,this._current=null;let n=this._returnFocus;this._returnFocus=null,e&&n?.isConnected&&n.focus?.()}async _close(e,t=null){let n=this._run,r=this._current,i=r?{index:r.index,position:this._progress.position(r.index),total:this._progress.total()}:J,a=this._seenMark;this._teardown();let o=e===`next`?`finished`:e,s=!1;try{n===this._run&&await(a??this._markSeen(o)),s=n===this._run}finally{this._finish(e,i,t)}return s}_finish(e,t=J,n=null){this._run++,this._running=!1,this.hasAttribute(`open`)&&this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`wui-tour:close`,{bubbles:!0,detail:{reason:e,...t,via:n}}))}};export{Y as n,ze as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./devWarn-DXdRWZs3.js";import{n,t as r}from"./buttonClass-DpG9WzgJ.js";import{t as i}from"./iconGlyphs.g-BlwTSNXS.js";import{n as a}from"./stepperHeader-yinJ_7Dk.js";var o=`wui-wizard-step`,s=`:scope > [data-wui-glyphs]`,c={done:`Done`,active:`Current`,pending:`To do`,error:`Error`,skipped:`Skipped`},l=[`data-nav`,`data-step`,`data-close`],u=/* @__PURE__ */ new WeakSet,d=class extends e{static get observedAttributes(){return[`active`,`variant`,`orientation`,`align`,`icon-size`,`non-linear`,`hide-stepper`,`hide-connectors`,`disabled`,`skippable`,`label`,`back-label`,`next-label`,`skip-label`,`finish-label`,`top-bar`,`bar-title`,`close-label`]}constructor(){super(),this._active=0,this._skipped=/* @__PURE__ */ new Set,this._invalid=/* @__PURE__ */ new Set,this._finished=!1,this._rendered=!1,this._reflecting=!1,this._beforeNext=null,this._header=null,this._footer=null,this._topBar=null,this._onTopBarClick=e=>{e.target.closest(`[data-close]`)&&this.dispatchEvent(new CustomEvent(`wui-wizard:close`,{detail:{index:this._active},bubbles:!0}))},this._known=[],this._observer=null,this._glyphs=null,this._glyphObserver=null}get active(){return this._active}set active(e){let t=Number.parseInt(e,10);Number.isFinite(t)&&this._go(t,`set`)}get beforeNext(){return this._beforeNext}set beforeNext(e){this._beforeNext=typeof e==`function`?e:null}get _steps(){return[...this.querySelectorAll(`:scope > ${o}`)]}refresh(){this._rendered&&this._renderChrome()}connectedCallback(){if(this._rendered)this._wire(),this._onStepsMutated();else{let e=Number.parseInt(this.getAttribute(`active`),10);this._active=Number.isFinite(e)&&e>=0?e:0,this.render()}}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){if(this._rendered&&!this._reflecting){if(e===`active`){let e=Number.parseInt(n,10);Number.isFinite(e)&&this._go(e,`set`)}else this._renderChrome()}}render(){let e=this._steps;this._header||(this._header=document.createElement(`nav`),this._header.className=`stepper wizard-stepper`,this._footer=document.createElement(`div`),this._footer.className=`form-actions wizard-footer form-actions-between`,e.length?(this.insertBefore(this._header,e[0]),e[e.length-1].after(this._footer)):(this.prepend(this._header),this.append(this._footer))),this._known=e,this._renderChrome(),this._rendered=!0,this._wire()}_renderChrome(){let e=this._reconcileSteps();this._placeChrome(e),this._clampActive(e),this._syncPanels(e);let t=this._focusedControl();this._syncTopBar(e),this._header.innerHTML=this._headerHtml(e),this._footer.innerHTML=this._footerHtml(e),this._header.hidden=this.hasAttribute(`hide-stepper`),this._restoreFocus(t)}_focusedControl(){let e=document.activeElement;if(!e||![this._topBar,this._header,this._footer].some(t=>t?.contains(e)))return null;let t=l.find(t=>e.hasAttribute(t));return t?{attr:t,value:e.getAttribute(t)}:null}_restoreFocus(e){if(e)for(let t of[this._topBar,this._header,this._footer]){let n=t&&[...t.querySelectorAll(`[${e.attr}]`)].find(t=>t.getAttribute(e.attr)===e.value);if(n){n.disabled||n.focus({preventScroll:!0});return}}}_syncTopBar(e){if(!this.hasAttribute(`top-bar`)){this._topBar?.removeEventListener(`click`,this._onTopBarClick),this._topBar?.remove(),this._topBar=null;return}this._topBar||(this._topBar=document.createElement(`div`),this._topBar.className=`wui-wizard-topbar`,this._rendered&&this._topBar.addEventListener(`click`,this._onTopBarClick)),this._header.previousElementSibling!==this._topBar&&this.insertBefore(this._topBar,this._header);let t=this.getAttribute(`bar-title`)||``,n=this.getAttribute(`close-label`)||`Close`,r=e.length?`<span class="wui-wizard-topbar-count">Step ${this._active+1} of ${e.length}</span>`:``;this._topBar.innerHTML=`<span class="wui-wizard-topbar-title">${p(t)}</span>${r}<button type="button" class="wui-wizard-topbar-close" data-close aria-label="${m(n)}">${this._glyph(`x`)}</button>`}_clampActive(e){let t=Math.max(0,e.length-1);this._active>t&&(this._active=t),this._active<0&&(this._active=0)}_reconcileSteps(){let e=this._steps,t=this._known;if(this._known=e,f(e,t))return e;let n=n=>new Set([...n].map(n=>e.indexOf(t[n])).filter(e=>e>=0));this._skipped=n(this._skipped),this._invalid=n(this._invalid);let r=t[this._active];if(!r)return e;let i=e.indexOf(r);if(i<0){let n=t=>e.includes(t),r=t.slice(this._active+1).find(n)??t.slice(0,this._active).reverse().find(n);i=r?e.indexOf(r):this._active}return i=Math.min(i,Math.max(0,e.length-1)),i!==this._active&&(this._active=i,this._reflectActive(i)),e}_placeChrome(e){if(!e.length)return;let t=e[e.length-1];this._header.nextElementSibling!==e[0]&&this.insertBefore(this._header,e[0]),this._footer.previousElementSibling!==t&&t.after(this._footer)}_onStepsMutated(){if(!this._rendered)return;let e=this._steps,t=!e.length||this._header.nextElementSibling===e[0]&&this._footer.previousElementSibling===e[e.length-1];this.querySelector(s)!==this._glyphs&&(this._watchGlyphs(),this._renderHeader()),t&&f(e,this._known)||(this._renderChrome(),this._observer?.takeRecords())}_syncPanels(e){e.forEach((e,t)=>{let n=t===this._active;e.classList.add(`wizard-panel`),e.hidden=!n,e.setAttribute(`role`,`tabpanel`),e.setAttribute(`aria-hidden`,n?`false`:`true`)})}_stepStatus(e,t){return e.getAttribute(`status`)||(this._invalid.has(t)?`error`:this._finished?`done`:t===this._active?`active`:t<this._active?this._skipped.has(t)?`skipped`:`done`:`pending`)}_headerHtml(e){let n=this.getAttribute(`variant`)===`journey`,r=this.getAttribute(`variant`)===`icons`,i=this.getAttribute(`variant`)===`tiles`,o=this.getAttribute(`orientation`)===`vertical`,s=!this.hasAttribute(`hide-connectors`),l=this.getAttribute(`align`)===`start`;this._header.className=[`stepper`,`wizard-stepper`,n&&`stepper-journey`,r&&`stepper-icons`,i&&`wui-step-tiles`,o&&`stepper-vertical`,!s&&`wui-stepper-no-connectors`,l&&`wui-stepper-start`].filter(Boolean).join(` `),this._header.setAttribute(`aria-label`,this.getAttribute(`label`)||`Progress`);let d=this.hasAttribute(`non-linear`);for(let n of e)n.getAttribute(`label`)||u.has(n)||(u.add(n),t(`wui-wizard: a <wui-wizard-step> needs a label attribute; its header segment is empty.`));let f=a(e.map(e=>({label:e.getAttribute(`label`)||``,icon:e.getAttribute(`icon`)||void 0})),{statusOf:t=>this._stepStatus(e[t],t),journey:n,connectors:s}).map(t=>{let a=t.index,o=e[a],s=t.status,l=o.getAttribute(`label`)||``,u=o.getAttribute(`description`)||``,f=a+1,m=t.glyph.icon?this._glyph(t.glyph.icon):String(t.glyph.number),h=t.className,g=t.current?` aria-current="step"`:``,_=d||a<this._active;if(i){let e=`<span class="step-circle">${m}</span><span class="step-text"><span class="step-label">${p(l)}</span><span class="wui-step-tile-state">${c[s]??``}</span></span>`,t=_?`<button type="button" class="wui-step-tile-body" data-step="${a}"${g}>${e}</button>`:`<div class="wui-step-tile-body"${g}>${e}</div>`;return`<li class="${s===`pending`?`wui-step-tile`:`wui-step-tile ${s}`}">${t}</li>`}let v=u?`<span class="step-desc">${p(u)}</span>`:``,y;y=n?`<span class="step-circle">${m}</span><span class="step-text"><span class="step-index">Step ${f}</span><span class="step-label">${p(l)}</span>${v}</span>`:r?`<span class="step-circle">${m}</span><span class="step-index">Step ${f}</span><span class="step-label">${p(l)}</span>${v}`:`<span class="step-circle">${m}</span><span class="step-label">${p(l)}</span>${v}`;let b=_?`<button type="button" class="${h}" data-step="${a}"${g}>${y}</button>`:`<div class="${h}"${g}>${y}</div>`;return t.line?`${b}<span class="step-line${t.line.done?` done`:``}" aria-hidden="true"></span>`:b}).join(``);return i?`<ol>${f}</ol>`:f}_footerHtml(e){let t=this._active,a=e.length-1,o=this.hasAttribute(`disabled`)?` disabled`:``,s=e[t]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`),c=this.getAttribute(`back-label`)||`Back`,l=this.getAttribute(`next-label`)||`Next`,u=this.getAttribute(`skip-label`)||`Skip`,d=this.getAttribute(`finish-label`)||`Finish`;return`${t>0?`<button type="button" class="${n(`soft`,`md`)}" data-nav="back"${o} data-wui="${r}">${i(`arrow-left`,{className:`me-2`})}${p(c)}</button>`:`<span></span>`}<span class="wizard-footer-actions">${s&&t<a?`<button type="button" class="${n(`neutral`,`md`)}" data-nav="skip"${o} data-wui="${r}">${p(u)}</button>`:``}${t<a?`<button type="button" class="${n(`primary`,`md`)}" data-nav="next"${o} data-wui="${r}">${p(l)}${i(`arrow-right`,{className:`ms-2`})}</button>`:`<button type="button" class="${n(`primary`,`md`)}" data-nav="finish"${o} data-wui="${r}">${p(d)}</button>`}</span>`}_wire(){this._teardown(),this._onHeaderClick=e=>{let t=e.target.closest(`[data-step]`);t&&this.contains(t)&&this._stepTo(Number.parseInt(t.dataset.step,10))},this._onFooterClick=e=>{let t=e.target.closest(`[data-nav]`);if(!t||!this.contains(t)||this.hasAttribute(`disabled`))return;let n=t.dataset.nav;n===`back`?this._back():n===`skip`?this._skip():(n===`next`||n===`finish`)&&this._next()},this._header.addEventListener(`click`,this._onHeaderClick),this._footer.addEventListener(`click`,this._onFooterClick),this._topBar?.addEventListener(`click`,this._onTopBarClick),this._observer=new MutationObserver(()=>this._onStepsMutated()),this._observer.observe(this,{childList:!0}),this._watchGlyphs()}_glyph(e){let t=this.querySelector(s),n=t&&[...t.children].find(t=>t.getAttribute(`data-icon`)===e);if(n)return n.outerHTML;let r=Number.parseInt(this.getAttribute(`icon-size`),10);return i(e,r>0?{size:r}:void 0)}_watchGlyphs(){this._glyphObserver?.disconnect(),this._glyphObserver=null,this._glyphs=this.querySelector(s),this._glyphs&&(this._glyphObserver=new MutationObserver(()=>this._renderHeader()),this._glyphObserver.observe(this._glyphs,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}_renderHeader(){if(!this._rendered)return;let e=this._focusedControl();this._header.innerHTML=this._headerHtml(this._steps),this._restoreFocus(e)}_teardown(){this._header&&this._onHeaderClick&&this._header.removeEventListener(`click`,this._onHeaderClick),this._footer&&this._onFooterClick&&this._footer.removeEventListener(`click`,this._onFooterClick),this._topBar?.removeEventListener(`click`,this._onTopBarClick),this._observer?.disconnect(),this._observer=null,this._glyphObserver?.disconnect(),this._glyphObserver=null}_stepTo(e){this.hasAttribute(`disabled`)||!this.hasAttribute(`non-linear`)&&e>=this._active||this._go(e,`step`)}_back(){this._active>0&&this._go(this._active-1,`back`)}async _next(){this._reconcileSteps();let e=this._active,t=this._steps,n=e>=t.length-1,r=t[e];if(!this.dispatchEvent(new CustomEvent(`wui-wizard:beforechange`,{detail:n?{index:e,next:e,reason:`finish`}:{index:e,next:e+1,reason:`next`},cancelable:!0})))return this._flagInvalid(e);if(this._beforeNext){let i;try{i=await this._beforeNext(e)}catch{i=!1}if(this._reconcileSteps(),t=this._steps,e=t.indexOf(r),e<0)return;if(n=e>=t.length-1,i===!1)return this._flagInvalid(e)}if(this._invalid.delete(e),this._skipped.delete(e),n)return this._finish();this._go(e+1,`next`)}_skip(){let e=this._active,t=this._steps;if(t[e]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`)){if(this._invalid.delete(e),this._skipped.add(e),this.dispatchEvent(new CustomEvent(`wui-wizard:skip`,{detail:{index:e}})),e>=t.length-1)return this._finish();this._go(e+1,`skip`)}}_flagInvalid(e){this._invalid.add(e),this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:invalid`,{detail:{index:e}}))}_finish(){this._invalid.delete(this._active),this._finished=!0,this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:finish`,{detail:{index:this._active}}))}_go(e,t){let n=this._reconcileSteps(),r=Math.max(0,n.length-1),i=Math.min(Math.max(e,0),r),a=this._active;this._finished=!1,this._invalid.delete(a),this._active=i,this._reflectActive(i),this._renderChrome(),t!==`silent`&&i!==a&&this.dispatchEvent(new CustomEvent(`wui-wizard:change`,{detail:{index:i,previous:a,reason:t}}))}_reflectActive(e){this._reflecting=!0,this.setAttribute(`active`,String(e)),this._reflecting=!1}},f=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),p=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),m=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),h=class extends e{static get observedAttributes(){return[`label`,`description`,`optional`,`icon`,`status`]}attributeChangedCallback(){let e=this.closest(`wui-wizard`);e&&typeof e.refresh==`function`&&e.refresh()}};export{d as n,h as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t}from"./devWarn-DXdRWZs3.js";import{n,t as r}from"./buttonClass-Yk0Fwgs6.js";import{t as i}from"./iconGlyphs.g-BlwTSNXS.js";import{n as a}from"./stepperHeader-yinJ_7Dk.js";var o=`wui-wizard-step`,s=`:scope > [data-wui-glyphs]`,c={done:`Done`,active:`Current`,pending:`To do`,error:`Error`,skipped:`Skipped`},l=[`data-nav`,`data-step`,`data-close`],u=/* @__PURE__ */ new WeakSet,d=class extends e{static get observedAttributes(){return[`active`,`variant`,`orientation`,`align`,`icon-size`,`non-linear`,`hide-stepper`,`hide-connectors`,`disabled`,`skippable`,`label`,`back-label`,`next-label`,`skip-label`,`finish-label`,`top-bar`,`bar-title`,`close-label`]}constructor(){super(),this._active=0,this._skipped=/* @__PURE__ */ new Set,this._invalid=/* @__PURE__ */ new Set,this._finished=!1,this._rendered=!1,this._reflecting=!1,this._beforeNext=null,this._header=null,this._footer=null,this._topBar=null,this._onTopBarClick=e=>{e.target.closest(`[data-close]`)&&this.dispatchEvent(new CustomEvent(`wui-wizard:close`,{detail:{index:this._active},bubbles:!0}))},this._known=[],this._observer=null,this._glyphs=null,this._glyphObserver=null}get active(){return this._active}set active(e){let t=Number.parseInt(e,10);Number.isFinite(t)&&this._go(t,`set`)}get beforeNext(){return this._beforeNext}set beforeNext(e){this._beforeNext=typeof e==`function`?e:null}get _steps(){return[...this.querySelectorAll(`:scope > ${o}`)]}refresh(){this._rendered&&this._renderChrome()}connectedCallback(){if(this._rendered)this._wire(),this._onStepsMutated();else{let e=Number.parseInt(this.getAttribute(`active`),10);this._active=Number.isFinite(e)&&e>=0?e:0,this.render()}}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){if(this._rendered&&!this._reflecting){if(e===`active`){let e=Number.parseInt(n,10);Number.isFinite(e)&&this._go(e,`set`)}else this._renderChrome()}}render(){let e=this._steps;this._header||(this._header=document.createElement(`nav`),this._header.className=`stepper wizard-stepper`,this._footer=document.createElement(`div`),this._footer.className=`form-actions wizard-footer form-actions-between`,e.length?(this.insertBefore(this._header,e[0]),e[e.length-1].after(this._footer)):(this.prepend(this._header),this.append(this._footer))),this._known=e,this._renderChrome(),this._rendered=!0,this._wire()}_renderChrome(){let e=this._reconcileSteps();this._placeChrome(e),this._clampActive(e),this._syncPanels(e);let t=this._focusedControl();this._syncTopBar(e),this._header.innerHTML=this._headerHtml(e),this._footer.innerHTML=this._footerHtml(e),this._header.hidden=this.hasAttribute(`hide-stepper`),this._restoreFocus(t)}_focusedControl(){let e=document.activeElement;if(!e||![this._topBar,this._header,this._footer].some(t=>t?.contains(e)))return null;let t=l.find(t=>e.hasAttribute(t));return t?{attr:t,value:e.getAttribute(t)}:null}_restoreFocus(e){if(e)for(let t of[this._topBar,this._header,this._footer]){let n=t&&[...t.querySelectorAll(`[${e.attr}]`)].find(t=>t.getAttribute(e.attr)===e.value);if(n){n.disabled||n.focus({preventScroll:!0});return}}}_syncTopBar(e){if(!this.hasAttribute(`top-bar`)){this._topBar?.removeEventListener(`click`,this._onTopBarClick),this._topBar?.remove(),this._topBar=null;return}this._topBar||(this._topBar=document.createElement(`div`),this._topBar.className=`wui-wizard-topbar`,this._rendered&&this._topBar.addEventListener(`click`,this._onTopBarClick)),this._header.previousElementSibling!==this._topBar&&this.insertBefore(this._topBar,this._header);let t=this.getAttribute(`bar-title`)||``,n=this.getAttribute(`close-label`)||`Close`,r=e.length?`<span class="wui-wizard-topbar-count">Step ${this._active+1} of ${e.length}</span>`:``;this._topBar.innerHTML=`<span class="wui-wizard-topbar-title">${p(t)}</span>${r}<button type="button" class="wui-wizard-topbar-close" data-close aria-label="${m(n)}">${this._glyph(`x`)}</button>`}_clampActive(e){let t=Math.max(0,e.length-1);this._active>t&&(this._active=t),this._active<0&&(this._active=0)}_reconcileSteps(){let e=this._steps,t=this._known;if(this._known=e,f(e,t))return e;let n=n=>new Set([...n].map(n=>e.indexOf(t[n])).filter(e=>e>=0));this._skipped=n(this._skipped),this._invalid=n(this._invalid);let r=t[this._active];if(!r)return e;let i=e.indexOf(r);if(i<0){let n=t=>e.includes(t),r=t.slice(this._active+1).find(n)??t.slice(0,this._active).reverse().find(n);i=r?e.indexOf(r):this._active}return i=Math.min(i,Math.max(0,e.length-1)),i!==this._active&&(this._active=i,this._reflectActive(i)),e}_placeChrome(e){if(!e.length)return;let t=e[e.length-1];this._header.nextElementSibling!==e[0]&&this.insertBefore(this._header,e[0]),this._footer.previousElementSibling!==t&&t.after(this._footer)}_onStepsMutated(){if(!this._rendered)return;let e=this._steps,t=!e.length||this._header.nextElementSibling===e[0]&&this._footer.previousElementSibling===e[e.length-1];this.querySelector(s)!==this._glyphs&&(this._watchGlyphs(),this._renderHeader()),t&&f(e,this._known)||(this._renderChrome(),this._observer?.takeRecords())}_syncPanels(e){e.forEach((e,t)=>{let n=t===this._active;e.classList.add(`wizard-panel`),e.hidden=!n,e.setAttribute(`role`,`tabpanel`),e.setAttribute(`aria-hidden`,n?`false`:`true`)})}_stepStatus(e,t){return e.getAttribute(`status`)||(this._invalid.has(t)?`error`:this._finished?`done`:t===this._active?`active`:t<this._active?this._skipped.has(t)?`skipped`:`done`:`pending`)}_headerHtml(e){let n=this.getAttribute(`variant`)===`journey`,r=this.getAttribute(`variant`)===`icons`,i=this.getAttribute(`variant`)===`tiles`,o=this.getAttribute(`orientation`)===`vertical`,s=!this.hasAttribute(`hide-connectors`),l=this.getAttribute(`align`)===`start`;this._header.className=[`stepper`,`wizard-stepper`,n&&`stepper-journey`,r&&`stepper-icons`,i&&`wui-step-tiles`,o&&`stepper-vertical`,!s&&`wui-stepper-no-connectors`,l&&`wui-stepper-start`].filter(Boolean).join(` `),this._header.setAttribute(`aria-label`,this.getAttribute(`label`)||`Progress`);let d=this.hasAttribute(`non-linear`);for(let n of e)n.getAttribute(`label`)||u.has(n)||(u.add(n),t(`wui-wizard: a <wui-wizard-step> needs a label attribute; its header segment is empty.`));let f=a(e.map(e=>({label:e.getAttribute(`label`)||``,icon:e.getAttribute(`icon`)||void 0})),{statusOf:t=>this._stepStatus(e[t],t),journey:n,connectors:s}).map(t=>{let a=t.index,o=e[a],s=t.status,l=o.getAttribute(`label`)||``,u=o.getAttribute(`description`)||``,f=a+1,m=t.glyph.icon?this._glyph(t.glyph.icon):String(t.glyph.number),h=t.className,g=t.current?` aria-current="step"`:``,_=d||a<this._active;if(i){let e=`<span class="step-circle">${m}</span><span class="step-text"><span class="step-label">${p(l)}</span><span class="wui-step-tile-state">${c[s]??``}</span></span>`,t=_?`<button type="button" class="wui-step-tile-body" data-step="${a}"${g}>${e}</button>`:`<div class="wui-step-tile-body"${g}>${e}</div>`;return`<li class="${s===`pending`?`wui-step-tile`:`wui-step-tile ${s}`}">${t}</li>`}let v=u?`<span class="step-desc">${p(u)}</span>`:``,y;y=n?`<span class="step-circle">${m}</span><span class="step-text"><span class="step-index">Step ${f}</span><span class="step-label">${p(l)}</span>${v}</span>`:r?`<span class="step-circle">${m}</span><span class="step-index">Step ${f}</span><span class="step-label">${p(l)}</span>${v}`:`<span class="step-circle">${m}</span><span class="step-label">${p(l)}</span>${v}`;let b=_?`<button type="button" class="${h}" data-step="${a}"${g}>${y}</button>`:`<div class="${h}"${g}>${y}</div>`;return t.line?`${b}<span class="step-line${t.line.done?` done`:``}" aria-hidden="true"></span>`:b}).join(``);return i?`<ol>${f}</ol>`:f}_footerHtml(e){let t=this._active,a=e.length-1,o=this.hasAttribute(`disabled`)?` disabled`:``,s=e[t]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`),c=this.getAttribute(`back-label`)||`Back`,l=this.getAttribute(`next-label`)||`Next`,u=this.getAttribute(`skip-label`)||`Skip`,d=this.getAttribute(`finish-label`)||`Finish`;return`${t>0?`<button type="button" class="${n(`primary`,`soft`,`md`)}" data-nav="back"${o} data-wui="${r}">${i(`arrow-left`,{className:`me-2`})}${p(c)}</button>`:`<span></span>`}<span class="wizard-footer-actions">${s&&t<a?`<button type="button" class="${n(`neutral`,`soft`,`md`)}" data-nav="skip"${o} data-wui="${r}">${p(u)}</button>`:``}${t<a?`<button type="button" class="${n(`primary`,`solid`,`md`)}" data-nav="next"${o} data-wui="${r}">${p(l)}${i(`arrow-right`,{className:`ms-2`})}</button>`:`<button type="button" class="${n(`primary`,`solid`,`md`)}" data-nav="finish"${o} data-wui="${r}">${p(d)}</button>`}</span>`}_wire(){this._teardown(),this._onHeaderClick=e=>{let t=e.target.closest(`[data-step]`);t&&this.contains(t)&&this._stepTo(Number.parseInt(t.dataset.step,10))},this._onFooterClick=e=>{let t=e.target.closest(`[data-nav]`);if(!t||!this.contains(t)||this.hasAttribute(`disabled`))return;let n=t.dataset.nav;n===`back`?this._back():n===`skip`?this._skip():(n===`next`||n===`finish`)&&this._next()},this._header.addEventListener(`click`,this._onHeaderClick),this._footer.addEventListener(`click`,this._onFooterClick),this._topBar?.addEventListener(`click`,this._onTopBarClick),this._observer=new MutationObserver(()=>this._onStepsMutated()),this._observer.observe(this,{childList:!0}),this._watchGlyphs()}_glyph(e){let t=this.querySelector(s),n=t&&[...t.children].find(t=>t.getAttribute(`data-icon`)===e);if(n)return n.outerHTML;let r=Number.parseInt(this.getAttribute(`icon-size`),10);return i(e,r>0?{size:r}:void 0)}_watchGlyphs(){this._glyphObserver?.disconnect(),this._glyphObserver=null,this._glyphs=this.querySelector(s),this._glyphs&&(this._glyphObserver=new MutationObserver(()=>this._renderHeader()),this._glyphObserver.observe(this._glyphs,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}_renderHeader(){if(!this._rendered)return;let e=this._focusedControl();this._header.innerHTML=this._headerHtml(this._steps),this._restoreFocus(e)}_teardown(){this._header&&this._onHeaderClick&&this._header.removeEventListener(`click`,this._onHeaderClick),this._footer&&this._onFooterClick&&this._footer.removeEventListener(`click`,this._onFooterClick),this._topBar?.removeEventListener(`click`,this._onTopBarClick),this._observer?.disconnect(),this._observer=null,this._glyphObserver?.disconnect(),this._glyphObserver=null}_stepTo(e){this.hasAttribute(`disabled`)||!this.hasAttribute(`non-linear`)&&e>=this._active||this._go(e,`step`)}_back(){this._active>0&&this._go(this._active-1,`back`)}async _next(){this._reconcileSteps();let e=this._active,t=this._steps,n=e>=t.length-1,r=t[e];if(!this.dispatchEvent(new CustomEvent(`wui-wizard:beforechange`,{detail:n?{index:e,next:e,reason:`finish`}:{index:e,next:e+1,reason:`next`},cancelable:!0})))return this._flagInvalid(e);if(this._beforeNext){let i;try{i=await this._beforeNext(e)}catch{i=!1}if(this._reconcileSteps(),t=this._steps,e=t.indexOf(r),e<0)return;if(n=e>=t.length-1,i===!1)return this._flagInvalid(e)}if(this._invalid.delete(e),this._skipped.delete(e),n)return this._finish();this._go(e+1,`next`)}_skip(){let e=this._active,t=this._steps;if(t[e]?.hasAttribute(`optional`)||this.hasAttribute(`skippable`)){if(this._invalid.delete(e),this._skipped.add(e),this.dispatchEvent(new CustomEvent(`wui-wizard:skip`,{detail:{index:e}})),e>=t.length-1)return this._finish();this._go(e+1,`skip`)}}_flagInvalid(e){this._invalid.add(e),this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:invalid`,{detail:{index:e}}))}_finish(){this._invalid.delete(this._active),this._finished=!0,this._renderChrome(),this.dispatchEvent(new CustomEvent(`wui-wizard:finish`,{detail:{index:this._active}}))}_go(e,t){let n=this._reconcileSteps(),r=Math.max(0,n.length-1),i=Math.min(Math.max(e,0),r),a=this._active;this._finished=!1,this._invalid.delete(a),this._active=i,this._reflectActive(i),this._renderChrome(),t!==`silent`&&i!==a&&this.dispatchEvent(new CustomEvent(`wui-wizard:change`,{detail:{index:i,previous:a,reason:t}}))}_reflectActive(e){this._reflecting=!0,this.setAttribute(`active`,String(e)),this._reflecting=!1}},f=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),p=e=>String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),m=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`),h=class extends e{static get observedAttributes(){return[`label`,`description`,`optional`,`icon`,`status`]}attributeChangedCallback(){let e=this.closest(`wui-wizard`);e&&typeof e.refresh==`function`&&e.refresh()}};export{d as n,h as t};
@@ -0,0 +1 @@
1
+ var e=`AppButton`,t=/* @__PURE__ */ new Set([`primary`,`success`,`warning`,`danger`,`info`,`neutral`]),n={solid:e=>`btn-${e}`,soft:e=>`btn-soft-${e}`,outline:e=>`btn-outline-${e}`,ghost:e=>`btn-ghost-${e}`,link:e=>`btn-link-${e}`,glass:()=>`btn-glass`};function r(e=`primary`,r=`solid`,i=`md`){if(!t.has(e))throw RangeError(`buttonClass: unknown tone "${e}"`);if(!Object.hasOwn(n,r))throw RangeError(`buttonClass: unknown variant "${r}"`);let a=n[r](e);return i===`md`?`btn ${a}`:`btn ${a} btn-${i}`}export{r as n,e as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./buttonClass-Yk0Fwgs6.js";import{t as n}from"./loader-CVFmEPjv.js";import{n as r,t as i}from"./devWarn-DXdRWZs3.js";import{l as a,s as o}from"./wuiHttp-DgnM7K2Q.js";import{E as s,k as c,r as l,w as u,y as ee}from"./dataTable-BGZc5iC1.js";import{t as d}from"./iconGlyphs.g-BlwTSNXS.js";import{LIST_QUERY_RESERVED as te,SEARCH_PARAM as f}from"./listQuery.js";function p(e,t){e&&(e.tip?.isConnected?(t.addEventListener(`hidden${e.constructor.EVENT_KEY}`,()=>e.dispose(),{once:!0}),e.hide()):e.dispose())}var m=`wui-remote-modal`,h=`wui-remote-drawer`,g=Object.freeze({sm:360,md:480,lg:640,xl:720}),_=`wui-modal-fullscreen`,v=Object.freeze({sm:380,md:440,lg:640,xl:880}),y=Object.freeze({loading:`Loading`,close:`Close`,retry:`Try again`,errorTitle:`This could not be loaded`,forbidden:`You do not have access to this.`,client:`It may have been moved or deleted.`,server:`Something went wrong on our side. Try again in a moment.`,network:`Could not reach the server. Check your connection and try again.`,submitFailed:`Your changes were not saved.`,invalid:`Some fields need attention.`}),b=`a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,ne=`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled]),[contenteditable="true"]`,x=`[aria-invalid="true"], .is-invalid, .input-validation-error`,S=`.wui-error-summary, [data-wui-form-errors], .validation-summary-errors, [data-valmsg-summary]`,C=`[data-wui-modal-content]`,re=`[data-wui-pane-close], [data-bs-dismiss="modal"]`,ie=`<button type="button" class="wui-modal-close" data-bs-dismiss="modal" aria-label="Close"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"></path></svg></button>`,w=/* @__PURE__ */ new WeakMap,T=/* @__PURE__ */ new WeakSet,E=()=>Object.assign(/* @__PURE__ */ Error(`The remote modal load was aborted.`),{name:`AbortError`}),ae=e=>{let t=window.bootstrap?.Modal;if(!t)throw Error(`WUI.modal.load(${String(e)}): Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return t},D=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML};function oe(e){if(e==null||e===``)return null;if(e===`fullscreen`)return{fullscreen:!0};if(Object.hasOwn(v,e))return{px:v[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported modal size "${String(e)}". Use sm, md, lg, xl, fullscreen or a px number.`)}var se=e=>{if(e.classList.contains(`wui-modal-fullscreen`))return{fullscreen:!0};let t=Number.parseInt(e.style.getPropertyValue(`--wui-modal-max-width`),10);return{px:t>0?t:v.md}},O=(e,t)=>{e.classList.toggle(_,!!t.fullscreen),t.fullscreen?e.style.removeProperty(`--wui-modal-max-width`):e.style.setProperty(`--wui-modal-max-width`,`${t.px}px`)},ce=[`center`,`top`];function le(e){if(e==null||e===``)return null;if(Object.hasOwn(g,e))return{px:g[e]};let t=typeof e==`number`?e:/^\d+$/.test(String(e))?Number(e):NaN;if(Number.isInteger(t)&&t>0)return{px:t};throw TypeError(`Unsupported drawer size "${String(e)}". Use sm, md, lg, xl or a px number.`)}var k=e=>e.container===`drawer`,A=e=>e.container===`pane`,j=e=>e.container!==`modal`,ue=(e,t)=>k(e)?le(t):oe(t),M=()=>document.getElementById(`wui-remote-drawer`)?.classList.contains(`show`)??!1,de=e=>{let t=typeof e==`string`?document.querySelector(e):e;return t?.matches?.(`[data-wui-pane-host]`)?t:null},fe=e=>A(e)?e.shell:e.shell.querySelector(`.modal-dialog`);function pe(e=`modal`){let t=e===`drawer`,n=t?h:m,r=document.getElementById(n);return r||(r=document.createElement(`div`),r.id=n,r.className=t?`modal fade wui-modal-shell wui-remote-drawer`:`modal fade wui-modal-shell`,r.tabIndex=-1,r.setAttribute(`aria-hidden`,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.style.setProperty(`--wui-modal-max-width`,`${t?g.md:v.md}px`),r.innerHTML=t?`<div class="modal-dialog wui-remote-drawer-dialog"><div class="modal-content wui-modal"></div></div>`:`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal"></div></div>`,document.body.appendChild(r),r)}var me=e=>`<div class="wui-modal-header"><div class="wui-modal-heading"><div class="wui-modal-headtext"><div class="wui-modal-title">${D(e)}</div></div></div>${ie}</div>`,he=e=>`<div class="modal-content wui-modal" aria-busy="true">${me(e)}<div class="wui-modal-body"><div class="wui-modal-loading" role="status"><span class="visually-hidden">${D(y.loading)}</span><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton"></div><div class="skeleton wui-modal-skeleton wui-modal-skeleton--short"></div></div></div></div>`,N=(n,r)=>`<div class="modal-content wui-modal" data-wui-modal-error="${D(r)}">${me(n)}<div class="wui-modal-body"><div class="wui-modal-state" role="alert"><p class="wui-modal-state-title">${D(y.errorTitle)}</p><p class="wui-modal-state-text">${D(y[r]||y.server)}</p><div class="wui-modal-state-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${D(y.close)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-wui-modal-retry data-wui="${t}">${D(y.retry)}</button></div></div></div></div>`,ge=e=>{let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelector(`.modal-content`)},P=e=>e.shell.querySelector(`.modal-content`);function _e(e){if(!e)return;e.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0}));let t=window.bootstrap,n=[t?.Tooltip,t?.Popover].filter(e=>e?.getInstance);for(let r of[e,...e.querySelectorAll(`*`)]){for(let e of n)p(e.getInstance(r),r);t?.Dropdown?.getInstance?.(r)?.dispose()}}function F(e,t){let n=P(e),r=n?ye(n):/* @__PURE__ */ new Map;_e(n),n?n.replaceWith(t):fe(e).appendChild(t),be(t,r),window.WUI?.refresh?.()}var ve=`input[type="file"][name]`;function ye(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(ve))n.files.length>0&&t.set(n.name,[...n.files]);return t}function be(e,t){if(t.size!==0&&typeof DataTransfer<`u`)for(let n of e.querySelectorAll(ve)){let e=t.get(n.name);if(!e)continue;let r=new DataTransfer;for(let t of e)r.items.add(t);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}var xe=e=>A(e)?!e.shell.hidden:e.shell.classList.contains(`show`);function I(e,t,n=!1){let r=t&&e.querySelector(x),i=r?r.matches(b)?r:r.querySelector(b)||r:null;if(!i&&n)i=e.querySelector(`[data-autofocus]`)||e.querySelector(ne)||e.querySelector(`.wui-modal-close`);else if(!i){let t=[...e.querySelectorAll(b)];i=e.querySelector(`[data-autofocus]`)||t.find(e=>!e.classList.contains(`wui-modal-close`))||t[0]||e}r?i?.focus?.():i?.focus?.({preventScroll:!0})}function L(e,t){let n=[...e.querySelectorAll(b)].filter(e=>e.getClientRects().length>0&&getComputedStyle(e).visibility!==`hidden`);if(!n.length){t.preventDefault(),e.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;!e.contains(a)||a===e?(t.preventDefault(),(t.shiftKey?i:r).focus()):t.shiftKey&&a===r?(t.preventDefault(),i.focus()):!t.shiftKey&&a===i&&(t.preventDefault(),r.focus())}function Se(e,t){let n=e.shell.querySelector(`[data-wui-modal-live]`);n||(n=document.createElement(`div`),n.className=`visually-hidden`,n.setAttribute(`aria-live`,`assertive`),n.setAttribute(`data-wui-modal-live`,``),fe(e).appendChild(n)),n.textContent=``,n.textContent=t}var Ce=e=>{let t=e.shell.querySelector(`[data-wui-modal-live]`);t&&(t.textContent=``)},we=(e,t,n)=>e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}));function R(e,t,n,r){let i={...r,container:e.container};we(t,`wui:modal:${n}`,i),k(e)&&we(t,`wui:drawer:${n}`,i),A(e)&&we(t,`wui:pane:${n}`,i)}var Te=e=>e.matches(`[data-wui-pane-host]`)?`pane`:e.classList.contains(`wui-remote-drawer`)?`drawer`:`modal`;function z(e){let t=w.get(e);return t||(t={shell:e,container:Te(e),queue:o(),defaultSize:se(e),defaultLabel:e.getAttribute(`aria-label`),placeholder:P({shell:e})?.outerHTML||`<div class="modal-content wui-modal"></div>`,remoteUrl:e.getAttribute(`data-wui-remote-url`),cache:e.getAttribute(`data-wui-remote-cache`)===`true`,loadedUrl:null,session:null},w.set(e,t),e.addEventListener(`submit`,e=>Ue(t,e)),e.addEventListener(`click`,e=>{e.target.closest?.(`[data-wui-modal-retry]`)&&t.session&&(e.preventDefault(),H(t,t.session))}),A(t)&&e.addEventListener(`click`,e=>{let n=e.target.closest?.(re);n&&e.currentTarget.contains(n)&&t.session&&V(t,t.session,`dismissed`,null)}),e.addEventListener(`hidden.bs.modal`,n=>{n.target===e&&(e.classList.contains(`wui-modal-stacked`)&&De(t),Oe(t))}),e.addEventListener(`shown.bs.modal`,n=>{if(n.target!==e)return;e.classList.contains(`wui-modal-stacked`)&&[...document.querySelectorAll(`.modal-backdrop`)].at(-1)?.classList.add(`wui-modal-backdrop-stacked`);let r=P(t);t.session&&r?.matches(C)&&!r.contains(document.activeElement)&&I(r,!1,j(t))}),t.remoteUrl&&e.addEventListener(`show.bs.modal`,n=>{n.target===e&&ke(t,n)}),t)}function B(e,t,n){e.session&&(e.queue.abort(),e.session.resolveClosed({status:`dismissed`,detail:{replaced:!0}}));let r,i=new Promise(e=>{r=e}),a={url:t,method:(n.method||`GET`).toUpperCase(),body:n.body,options:n,trigger:n.trigger||null,explicitSize:null,closing:null,resolveClosed:r,handle:null};return a.handle={el:e.shell,closed:i,close:()=>V(e,a,`dismissed`,null),reload:()=>H(e,a)},e.session=a,a}function V(e,t,n,r){e.session===t&&(t.closing={status:n,detail:r},A(e)?Ee(e,t):window.bootstrap?.Modal?.getOrCreateInstance(e.shell).hide())}function Ee(e,t){let n=e.shell,{status:r,detail:i}=t.closing,a=n.contains(document.activeElement);e.queue.abort(),e.session=null,_e(P(e)),n.replaceChildren(),n.hidden=!0,n.removeAttribute(`data-open`),t.resolveClosed({status:r,detail:i}),R(e,n,`closed`,{status:r,url:t.url}),a&&t.trigger?.isConnected&&t.trigger.focus?.()}function De(e){e.shell.classList.remove(`wui-modal-stacked`),M()&&(document.body.classList.add(`modal-open`),document.body.style.overflow=`hidden`)}function Oe(e){let t=e.session;if(e.queue.abort(),e.session=null,Ce(e),t){let{status:n,detail:r}=t.closing||{status:`dismissed`,detail:null};t.resolveClosed({status:n,detail:r}),R(e,e.shell,`closed`,{status:n,url:t.url});let i=document.activeElement;t.trigger?.isConnected&&(!i||i===document.body||e.shell.contains(i))&&t.trigger.focus?.()}e.cache||(F(e,ge(e.placeholder)),e.loadedUrl=null,O(e.shell,e.defaultSize),e.defaultLabel?e.shell.setAttribute(`aria-label`,e.defaultLabel):e.shell.removeAttribute(`aria-label`))}function ke(e,t){let n=t.relatedTarget instanceof Element?t.relatedTarget:null,r=n?.getAttribute(`data-wui-url`)||e.remoteUrl,i=B(e,r,{trigger:n});i.explicitSize=Ae(e,n?.getAttribute(`data-wui-size`)),i.explicitSize&&O(e.shell,i.explicitSize),e.cache&&e.loadedUrl===r||(e.loadedUrl&&F(e,ge(e.placeholder)),H(e,i,{keepPlaceholder:!0}))}function Ae(e,t){try{return ue(e,t)}catch(e){return i(e),null}}async function H(e,t,{keepPlaceholder:n=!1}={}){n||F(e,ge(he(t.options.title||je(e))));let r=await e.queue.run(t.url,{method:t.method,body:t.body,navigate:t.options.navigate});if(e.session!==t||r.kind===`aborted`||r.kind===`stale`)return`aborted`;if(r.kind===`session`)return`session`;if((r.kind===`ok`||r.kind===`validation`)&&Fe(e,t,r.html,!1))return e.loadedUrl=t.url,R(e,e.shell,`loaded`,{url:t.url,handle:t.handle}),`loaded`;let i=r.kind===`ok`||r.kind===`validation`?`server`:r.kind;return F(e,ge(N(t.options.title||je(e),i))),xe(e)&&I(P(e),!1,j(e)),R(e,e.shell,`error`,{url:t.url,kind:i,status:r.status}),`error`}var je=e=>P(e)?.querySelector(`.wui-modal-title`)?.textContent||e.shell.getAttribute(`aria-label`)||``,Me=`/_content/Webority.Ui.Razor/js/`,Ne=e=>new URL(e,window.location.href).pathname.includes(Me);function Pe(e){if([...document.scripts].some(t=>t.getAttribute(`src`)===e))return;let t=document.createElement(`script`);t.src=e,document.head.appendChild(t)}function Fe(e,t,n,a){let o=document.createElement(`template`);o.innerHTML=n;let s=!1;for(let e of o.content.querySelectorAll(`script`)){if(e.getAttribute(`type`)===`application/json`)continue;let t=e.getAttribute(`src`);e.remove(),t&&Ne(t)?Pe(t):s=!0}s&&r(`WUI.modal: ${t.url} returned a fragment with script; it was removed. Keep page behaviour in the page.`);let c=o.content.querySelector(C);if(!c)return i(`WUI.modal: ${t.url} did not answer with an <app-modal-content> fragment.`),!1;if(F(e,c),a||Ce(e),!A(e)){O(e.shell,t.explicitSize||Ae(e,c.getAttribute(`data-wui-size`))||e.defaultSize);let n=c.getAttribute(`data-wui-title`);n&&e.shell.setAttribute(`aria-label`,n)}return xe(e)&&I(c,a,j(e)),!0}var Ie=`button[type="submit"], button:not([type]), input[type="submit"], input[type="image"]`;function Le(e,t,n){let r=[...e.elements].filter(e=>e.matches(Ie));if(n){e.setAttribute(`data-wui-submitting`,``);let n=t&&r.includes(t)?t:r[0];for(let e of r)e.toggleAttribute(`data-wui-was-disabled`,e.disabled),e.disabled=!0;n&&(n.classList.add(`is-loading`),n.setAttribute(`aria-busy`,`true`),n.tagName===`BUTTON`&&n.insertAdjacentHTML(`afterbegin`,`<span class="spinner-border spinner-border-sm me-2" aria-hidden="true" data-wui-submit-spinner></span>`))}else{e.removeAttribute(`data-wui-submitting`);for(let e of r)e.disabled=e.hasAttribute(`data-wui-was-disabled`),e.removeAttribute(`data-wui-was-disabled`),e.classList.remove(`is-loading`),e.removeAttribute(`aria-busy`),e.querySelector(`[data-wui-submit-spinner]`)?.remove()}}function Re(e){for(let t of e.querySelectorAll(S))t.remove();for(let t of e.querySelectorAll(x))t.removeAttribute(`aria-invalid`),t.classList.remove(`is-invalid`,`input-validation-error`);for(let t of e.querySelectorAll(`.field-error`))t.textContent=``}var ze=/* @__PURE__ */ new Set(/* @__PURE__ */ `bad request.unauthorized.payment required.forbidden.not found.method not allowed.not acceptable.proxy authentication required.request timeout.conflict.gone.length required.precondition failed.payload too large.uri too long.unsupported media type.range not satisfiable.expectation failed.misdirected request.unprocessable content.unprocessable entity.locked.failed dependency.too early.upgrade required.precondition required.too many requests.request header fields too large.unavailable for legal reasons`.split(`.`));async function Be(e){if(!e||e.status<400||e.status>499||e.status===422||!e.headers.get(`content-type`)?.toLowerCase().includes(`json`))return null;let t;try{t=JSON.parse(await e.text())}catch{return null}let n=e=>typeof e==`string`?e.trim():``,r=n(t?.title),i=(e.statusText||``).trim().toLowerCase(),a=ze.has(r.toLowerCase())||r.toLowerCase()===i;return n(t?.message)||n(t?.detail)||(r&&!a?r:null)}function Ve(e,t,n,r){let i=t.closest(`.wui-modal-body`)||t;i.querySelector(`[data-wui-modal-submit-error]`)?.remove(),Re(i);let a=document.createElement(`div`);a.className=`alert alert-danger wui-modal-submit-error`,a.setAttribute(`role`,`alert`),a.setAttribute(`data-wui-modal-submit-error`,``),a.innerHTML=D(`${y.submitFailed} ${r||y[n]||y.server}`),i.prepend(a),Se(e,a.textContent)}var He=(e,t)=>{let n=new URL(e,window.location.href);for(let[e,r]of t)typeof r==`string`&&n.searchParams.append(e,r);return n.origin===window.location.origin?n.pathname+n.search:n.href};async function Ue(e,t){let n=t.target,r=e.session;if(!(n instanceof HTMLFormElement)||!r||n.hasAttribute(`data-wui-native`)||!n.closest(C)||(t.preventDefault(),n.hasAttribute(`data-wui-submitting`)))return;let i=t.submitter||null,a=i?.getAttribute(`formaction`)||n.getAttribute(`action`)||r.url,o=(i?.getAttribute(`formmethod`)||n.getAttribute(`method`)||`GET`).toUpperCase(),s=new FormData(n);i?.name&&!s.has(i.name)&&s.append(i.name,i.value);let c=o===`GET`;Le(n,i,!0);let l=await e.queue.run(c?He(a,s):a,{method:o,body:c?void 0:s,navigate:r.options.navigate});if(e.session!==r)return;if(n.isConnected&&Le(n,i,!1),l.kind===`ok`&&l.result===`success`){We(e,r,l);return}if(l.kind===`aborted`||l.kind===`stale`||l.kind===`session`)return;if(l.kind===`validation`&&Fe(e,r,l.html,!0)){let t=P(e).querySelector(S)?.textContent.replace(/\s+/g,` `).trim();Se(e,t||y.invalid);return}if(l.kind===`ok`&&l.html&&Fe(e,r,l.html,!1))return;let u=l.kind===`ok`||l.kind===`validation`?`server`:l.kind,ee=await Be(l.response);e.session===r&&Ve(e,n,u,ee)}function We(e,t,n){let r=n.message,i=n.redirect||null,a={url:t.url,trigger:t.trigger,handle:t.handle,message:r,redirect:i,data:n.data??null,container:e.container};r&&window.WUI?.toast?.(r,{variant:`success`}),R(e,t.trigger?.isConnected?t.trigger:document,`success`,a),t.options.onSuccess?.(a,t.handle),i&&(t.options.navigate||(e=>window.location.assign(e)))(i),n.next&&!i?(t.url=n.next,t.method=`GET`,t.body=void 0,H(e,t)):n.keepOpen?n.html&&Fe(e,t,n.html,!1):V(e,t,`success`,a)}function Ge(e){let t=e.target.closest?.(`[data-wui-modal], [data-wui-drawer], [data-wui-pane]`);t&&(t.matches(`a[href]`)&&(e.ctrlKey||e.metaKey||e.shiftKey||e.button!==0)||(e.preventDefault(),t.hasAttribute(`data-wui-pane`)?$e(t.getAttribute(`data-wui-pane`),{target:t.getAttribute(`data-wui-pane-target`),trigger:t}).catch(e=>{e?.name!==`AbortError`&&i(e)}):t.hasAttribute(`data-wui-modal`)?Ye(t.getAttribute(`data-wui-modal`),{size:t.getAttribute(`data-wui-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{e?.name!==`AbortError`&&i(e)}):Ze(t.getAttribute(`data-wui-drawer`),{size:t.getAttribute(`data-wui-drawer-size`)||void 0,title:t.getAttribute(`data-wui-title`)||void 0,trigger:t}).catch(e=>{e?.name!==`AbortError`&&i(e)})))}function Ke(e){if(e.key!==`Tab`||e.defaultPrevented)return;let t=e.currentTarget.querySelectorAll(`.modal.show`),n=e.currentTarget.querySelector(`.modal.show.wui-modal-stacked`)??t[t.length-1];n&&L(n,e)}function qe(e){if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target.closest?.(Qe),n=t&&w.get(t);n?.session&&!e.currentTarget.querySelector(`.modal.show`)&&V(n,n.session,`dismissed`,null)}function Je(e=document){let t=e.ownerDocument||e;T.has(t)||(T.add(t),t.addEventListener(`click`,Ge),t.addEventListener(`keydown`,Ke),t.addEventListener(`keydown`,qe));let n=[...e.querySelectorAll?.(`.modal[data-wui-remote-url]`)||[]];e.matches?.(`.modal[data-wui-remote-url]`)&&n.unshift(e);for(let e of n)z(e)}function Ye(e,t={}){try{if(!e)throw TypeError(`WUI.modal.load: a fragment url is required.`);let n=ae(e),r=t.container===`drawer`,i=r?le(t.size):oe(t.size),a=t.placement||`center`;if(!ce.includes(a))throw TypeError(`WUI.modal.load: unsupported placement "${a}". Use center or top.`);if(t.signal?.aborted)return Promise.reject(E());let o=pe(r?`drawer`:`modal`);Je(document);let s=z(o),c=xe(s),l=B(s,e,t);l.explicitSize=i,O(o,i||s.defaultSize),r||o.querySelector(`.modal-dialog`).classList.toggle(`modal-dialog-centered`,a===`center`),t.title&&o.setAttribute(`aria-label`,t.title),c||(!r&&M()&&(document.body.appendChild(o),o.classList.add(`wui-modal-stacked`)),n.getInstance(o)?.dispose(),n.getOrCreateInstance(o,{backdrop:t.staticBackdrop===!1||`static`,keyboard:t.staticBackdrop===!1}));let u=c?Promise.resolve():new Promise(e=>o.addEventListener(`shown.bs.modal`,()=>e(),{once:!0})),ee=H(s,l);return c||n.getOrCreateInstance(o).show(),Xe(s,l,t,u,ee,`WUI.modal.load`)}catch(e){return Promise.reject(e)}}function Xe(e,t,n,r,i,a){let o=new Promise((r,i)=>{n.signal?.addEventListener(`abort`,()=>{e.session===t&&(e.queue.abort(),V(e,t,`dismissed`,{aborted:!0})),i(E())},{once:!0})}),s=Promise.all([r,i]).then(([,e])=>{if(e===`aborted`)throw E();if(e===`session`)throw Error(`${a}(${t.url}): the session expired; the browser is signing in again.`);return t.handle});return Promise.race([s,o])}function Ze(e,t={}){return Ye(e,{...t,container:`drawer`,placement:void 0})}var Qe=`[data-wui-pane-host]`;function $e(e,t={}){try{if(!e)throw TypeError(`WUI.pane.load: a fragment url is required.`);let n=de(t.target);if(!n)throw TypeError(`WUI.pane.load: the target is not an <app-detail-pane>.`);if(t.signal?.aborted)return Promise.reject(E());Je(document);let r=z(n),i=B(r,e,t);n.hidden=!1,n.setAttribute(`data-open`,``);let a=H(r,i);return Xe(r,i,t,Promise.resolve(),a,`WUI.pane.load`)}catch(e){return Promise.reject(e)}}function et(e){let t=de(e);if(!t)throw TypeError(`WUI.pane.close: the target is not an <app-detail-pane>.`);let n=w.get(t);n?.session&&V(n,n.session,`dismissed`,null)}var tt=`Select all rows`,nt=`Select row`,U=`wui-select-cell`,rt=(e,t)=>{let n=e.createElement(`input`);return n.type=`checkbox`,n.className=`wui-check`,n.setAttribute(`aria-label`,t),n};function it(e=document){let t=e.createElement(`th`);return t.className=U,t.appendChild(rt(e,tt)),t}function at(e=document,{disabled:t=!1}={}){let n=e.createElement(`td`);n.className=U;let r=rt(e,nt);return r.disabled=t,n.appendChild(r),n}function ot(e=document){let t=e.createElement(`td`);return t.className=U,t}var st=e=>e.firstElementChild?.classList.contains(U),ct=e=>e.matches(`.wui-group-row, .wui-virtual-spacer`);function lt(e){for(let t of e){if(st(t)||ct(t))continue;let e=t.getAttribute(`data-row-selectable`)===`false`;t.insertBefore(at(t.ownerDocument,{disabled:e}),t.firstChild)}}function ut(e){let t=e.querySelector(`thead tr`);if(!t)return null;st(t)||t.insertBefore(it(e.ownerDocument),t.firstChild),lt(e.querySelectorAll(`tbody tr`));for(let t of e.querySelectorAll(`tfoot tr`))st(t)||t.insertBefore(ot(e.ownerDocument),t.firstChild);return t.querySelector(`.${U} .wui-check`)}function dt(e){let t=e.querySelector(`thead .${U} .wui-check`),n=[...e.querySelectorAll(`tbody tr .wui-check:not(:disabled)`)],r=n.length,i=n.filter(e=>e.checked).length;t&&(t.checked=r>0&&i===r,t.indeterminate=i>0&&i<r);for(let t of e.querySelectorAll(`tbody tr`))t.classList.toggle(`is-selected`,!!t.querySelector(`.wui-check`)?.checked);return{selected:i,total:r}}var ft=`tbody .${U} .wui-check:not(:disabled)`;function pt(e,t){let n=null,r=e=>e instanceof Element&&e.matches(`.wui-select-cell .wui-check:not(:disabled)`)&&!!e.closest(`tbody`);e.addEventListener(`mousedown`,e=>{e.shiftKey&&r(e.target)&&e.preventDefault()}),e.addEventListener(`click`,i=>{let a=i.target;if(r(a)){if(i.shiftKey&&n?.isConnected&&n!==a){let r=[...e.querySelectorAll(ft)],i=r.indexOf(n),o=r.indexOf(a);if(i>=0&&o>=0){let e=[];for(let t of r.slice(Math.min(i,o),Math.max(i,o)+1))t!==a&&t.checked!==a.checked&&(t.checked=a.checked,e.push(t));e.length&&t?.(e,a.checked)}}n=a}})}var mt=8e3,ht=`That did not work. Try again.`;function gt(e,t=`success`){if(!e?.message)return;let n=e.toastAction;n?window.WUI?.toast?.(e.message,{variant:t,duration:mt,action:{label:n.label,onClick:()=>_t(n)}}):window.WUI?.toast?.(e.message,{variant:t})}async function _t(e){let t=await a(e.url,{method:e.method});if(t.kind!==`session`&&t.kind!==`aborted`){if(t.ok){gt(t,t.toastVariant||`success`);for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&Dt(e)?.reload()}else window.WUI?.toast?.(t.message||ht,{variant:`danger`})}}var W=Object.freeze({loading:`Loading rows`,error:`These rows did not load. Try again.`,network:`The connection dropped before the rows loaded. Check it and try again.`,forbidden:`You do not have access to these rows.`,retry:`Retry`,actionFailed:`That did not work. Try again.`,actionForbidden:`You do not have permission to do that.`,empty:`No rows`}),vt=5,yt=/* @__PURE__ */ new WeakMap,bt=(e,t)=>{let n=Number(e);return Number.isInteger(n)?n:t},xt=e=>({total:bt(e.dataset.total,0),page:bt(e.dataset.page,1),pageSize:bt(e.dataset.pageSize,0),sortBy:e.dataset.sortBy||``,sortOrder:e.dataset.sortOrder===`desc`?`desc`:`asc`}),St=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},Ct=(e,t)=>{if(!e)return;let n=new Set([...e.elements].filter(e=>e.type!==`hidden`||e.hasAttribute(`data-range-mirror`)).map(e=>e.getAttribute(`name`)).filter(e=>e&&!te.includes(e))),r=[...t].some(([e,t])=>t!==``&&n.has(e));for(let t of e.querySelectorAll(`[data-wui-filter-clear]`))t.hidden=!r},wt=new Intl.NumberFormat(`en-IN`),Tt=(e,t)=>{let n=e.closest(`.wui-list-card`)?.querySelector(`.wui-list-card-count`);n&&(n.textContent=wt.format(t))};function Et(e=document){let t=e.querySelectorAll?[...e.querySelectorAll(`[data-wui-server]`)]:[];e instanceof Element&&e.matches(`[data-wui-server]`)&&t.unshift(e);for(let e of t)yt.has(e)||yt.set(e,Ot(e))}function Dt(e){let t=e instanceof Element?e.closest(`[data-wui-server]`):null;return t&&yt.get(t)||null}function Ot(n){let p=n.querySelector(`.table-wrap`),m=p?.querySelector(`:scope > table`),h=n.dataset.src;if(!m||!h)throw Error(`A server-paged table needs data-src and a .table-wrap > table: render it with <app-data-table src>.`);let g=p.querySelector(`:scope > [data-wui-table-state]`),_=n.querySelector(`[data-wui-table-pager]`),v=n.querySelector(`[data-wui-table-status]`),y={urlState:n.dataset.urlState!==`false`,refreshOnSuccess:n.dataset.refreshOnSuccess!==`false`,filtersForm:n.dataset.filtersForm||null,filtersRegion:n.dataset.filtersRegion||null,searchInput:n.dataset.searchInput||null,loadingText:n.dataset.loadingText||W.loading,errorText:n.dataset.errorText||W.error},b=new URL(h,window.location.href),ne=new Set(b.searchParams.keys()),x=m.hasAttribute(`data-app-datatable-selectable`),S=/* @__PURE__ */ new Set,C=!1,re=o(),ie=new AbortController,w={signal:ie.signal},T=m.querySelector(`:scope > tbody[data-wui-rows]`);if(!T)throw Error(`A server-paged table needs its rows in <app-table-rows> (tbody[data-wui-rows]).`);let E=xt(T),ae=null,D=null,oe=e=>{let t=new URLSearchParams;for(let[n,r]of new URLSearchParams(e))ne.has(n)||t.append(n,r);return t},se=e=>oe(new URL(e,window.location.href).search),O=e=>{let t=e.toString();return`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`},ce=e=>{let t=new URL(b.href);for(let[n,r]of e)ne.has(n)||t.searchParams.append(n,r);return t.origin===window.location.origin?`${t.pathname}${t.search}`:t.href},le=(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},k=le(y.urlState?oe(window.location.search):new URLSearchParams,E);y.urlState&&O(k)!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,O(k));let A=(e,t)=>p.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t})),j=e=>{v&&(v.textContent=e)},ue=e=>{if(e.total===0)return W.empty;let t=e.pageSize>0?Math.max(1,Math.ceil(e.total/e.pageSize)):1;return`Page ${e.page} of ${t}, ${e.total} ${e.total===1?`row`:`rows`}`},M=()=>[...m.querySelectorAll(`:scope > thead > tr:first-child > th`)],de=e=>{if(x&&[...e.querySelectorAll(`:scope > tr:not(.wui-group-row, .wui-virtual-spacer)`)].some(e=>!e.dataset.rowKey))throw Error(`A selectable server-paged table needs data-row-key on every row, so a selection can span pages.`)},fe=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`)}},pe=e=>{if(x){lt(e);for(let t of e){let e=t.querySelector(`.${U} .wui-check:not(:disabled)`);e&&(C&&S.add(t.dataset.rowKey),e.checked=S.has(t.dataset.rowKey))}dt(m)}fe(e);let t=M();if(m.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`)})},me=e=>pe([...e.querySelectorAll(`:scope > tr`)]),he=e=>{for(let t of e.querySelectorAll(`:scope > template[data-wui-pager], :scope > template[data-wui-empty], :scope > template[data-wui-filters]`))t.remove()},N=e=>e?.dispatchEvent(new CustomEvent(`wui:teardown`,{bubbles:!0})),ge=(e,t)=>{if(!g)return;let n=e.querySelector(`:scope > template[data-wui-empty]`);N(g),t.total===0&&n?(g.replaceChildren(n.content.cloneNode(!0)),g.hidden=!1):(g.replaceChildren(),g.hidden=!0)},P=e=>{let t=xt(e),n=t.sortBy!==E.sortBy||t.sortOrder!==E.sortOrder?ee(T.rows):null;if(_){let t=e.querySelector(`:scope > template[data-wui-pager]`);N(_),_.replaceChildren(...t?[t.content.cloneNode(!0)]:[]),_.hidden=!1}ge(e,t);let r=e.querySelector(`:scope > template[data-wui-filters]`),i=y.filtersRegion&&r?document.querySelector(y.filtersRegion):null;i&&(N(i),i.replaceChildren(r.content.cloneNode(!0))),he(e),N(T),m.replaceChild(e,T),T=e;let a=C&&t.total!==E.total;return E=t,a&&(C=!1),p.removeAttribute(`data-wui-table-error`),me(e),we(),u(e.rows,n),a&&Te(),i},_e=e=>{let t=document.createElement(`template`);t.innerHTML=`<table>${e}</table>`;let n=t.content.querySelector(`tbody[data-wui-rows]`);return n&&de(n),n?document.importNode(n,!0):null},F=(e,t=M())=>{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},ve=()=>{if(T.querySelector(`:scope > tr:not([data-wui-skeleton])`))return;let e=Math.max(1,M().length);T.replaceChildren(...Array.from({length:vt},()=>{let t=F(e);return t.setAttribute(`data-wui-skeleton`,``),t})),p.removeAttribute(`data-wui-table-error`),g&&(g.hidden=!0)},ye=e=>{e?(p.setAttribute(`aria-busy`,`true`),ve()):p.removeAttribute(`aria-busy`)},be=e=>e===`forbidden`?W.forbidden:e===`network`?W.network:y.errorText,xe=n=>{let r=be(n);if(p.setAttribute(`data-wui-table-error`,n),_&&(_.hidden=!0),g){let i=document.createElement(`div`);i.className=`empty-state wui-empty-state-table wui-table-error`,i.setAttribute(`role`,`alert`);let a=document.createElement(`span`);a.className=`empty-state-icon`,a.innerHTML=d(n===`forbidden`?`lock`:`alert-circle`,{size:24});let o=document.createElement(`div`);o.className=`empty-state-title`,o.textContent=r;let s=document.createElement(`div`);s.className=`empty-state-action`;let c=document.createElement(`button`);c.type=`button`,c.className=e(`primary`,`outline`,`sm`),c.dataset.wui=t,c.setAttribute(`data-wui-table-retry`,``),c.textContent=W.retry,s.append(c),i.append(a,o,s),N(g),g.replaceChildren(i),g.hidden=!1}j(r)},I=()=>y.filtersForm?document.querySelector(y.filtersForm):null,L=async(e,t=`none`,{quiet:a=!1}={})=>{let o=new URLSearchParams(e);a||(ae={query:o,mode:t},ye(!0),j(y.loadingText)),A(`wui:table:loading`,{query:o.toString()});let s=await re.run(ce(o));if(s.kind===`aborted`||s.kind===`stale`||s.kind===`session`)return s;a||ye(!1);let c=null,l=s.ok?null:s.kind;if(s.ok){try{c=_e(s.html)}catch(e){i(e)}c||(l=`server`)}if(l)return a?r(`A quiet server table refresh failed; the rows on screen are kept.`,l):xe(l),A(`wui:table:error`,{status:s.status,kind:l,message:be(l)}),s;let u=P(c);return k=le(o,E),Ct(I(),k),y.urlState&&t===`push`?window.history.pushState(window.history.state,``,O(k)):y.urlState&&t===`replace`&&window.history.replaceState(window.history.state,``,O(k)),a||j(ue(E)),window.WUI?.refresh?.(p),u&&window.WUI?.refresh?.(u),Tt(n,E.total),A(`wui:table:loaded`,{...E,query:k.toString()}),s},Se=e=>(e.delete(`page`),e),Ce=()=>[...m.querySelectorAll(`:scope > thead th[data-sort-key]`)],we=()=>{for(let e of Ce()){let t=e.dataset.sortKey===E.sortBy;e.setAttribute(`aria-sort`,t?E.sortOrder===`desc`?`descending`:`ascending`:`none`)}};for(let e of Ce())if(e.classList.add(`sortable`),e.tabIndex=0,!e.querySelector(`.sort-icon`)){let t=e.classList.contains(`num`)||e.classList.contains(`text-end`),n=document.createElement(`span`);n.className=t?`sort-icon wui-sort-lead`:`sort-icon`,n.innerHTML=d(`chevrons-up-down`,{size:14}),t?e.prepend(n):e.append(n)}let R=e=>{let t=Se(new URLSearchParams(k)),n=E.sortBy===e&&E.sortOrder===`asc`?`desc`:`asc`;return t.set(`sortBy`,e),t.set(`sortOrder`,n),L(t,`push`)};m.addEventListener(`click`,e=>{let t=e.target.closest(`th[data-sort-key]`);t&&m.tHead?.contains(t)&&R(t.dataset.sortKey)}),m.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest?.(`th[data-sort-key]`);t&&m.tHead?.contains(t)&&(e.preventDefault(),R(t.dataset.sortKey))});let Te=()=>{dt(m);let e=C?{selected:E.total,total:E.total,allMatching:C}:{selected:S.size,total:E.total};m.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:e}))};x&&(pt(m,(e,t)=>{for(let n of e){let e=n.closest(`tr`)?.dataset.rowKey;e&&(t?S.add(e):S.delete(e))}t||(C=!1)}),m.addEventListener(`change`,e=>{let t=e.target;if(t.matches?.(`.wui-select-cell .wui-check:not(:disabled)`)){if(t.checked||(C=!1),m.tHead?.contains(t))for(let e of T.querySelectorAll(`:scope > tr`)){let n=e.querySelector(`.${U} .wui-check:not(:disabled)`);n&&(n.checked=t.checked,t.checked?S.add(e.dataset.rowKey):S.delete(e.dataset.rowKey))}else{let e=t.closest(`tr`)?.dataset.rowKey;if(!e)return;t.checked?S.add(e):S.delete(e)}Te()}})),_&&(_.addEventListener(`click`,e=>{let t=e.target.closest(`a[href]`);!t||e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),L(se(t.getAttribute(`href`)),`push`))}),_.addEventListener(`change`,e=>{e.target.classList?.contains(`tpg-select`)&&e.target.value&&(e.stopPropagation(),L(se(e.target.value),`push`))}));let z=()=>{if(!y.searchInput)return null;let e=document.querySelector(y.searchInput);return e&&(e.matches(`input, textarea`)?e:e.querySelector(`input`))},B=()=>n.isConnected?!0:(ie.abort(),clearTimeout(D),!1),V=(e,t)=>{let n=/* @__PURE__ */ new Set;for(let t of e.elements)t.name&&t.type!==`hidden`&&n.add(t.name);let r=[];for(let t of e.elements)if(t.name&&!t.disabled){if(t.matches(`input[type="hidden"][data-wui-carried]`))n.has(t.name)||r.push([t.name,t.value]);else if(t.matches(`input[type=checkbox], input[type=radio]`))t.checked&&r.push([t.name,t.value]);else if(t.matches(`input, textarea`))t.matches(`[type=submit], [type=button], [type=reset], [type=image], [type=file]`)||r.push([t.name,t.value]);else if(t.localName===`select`)for(let e of t.selectedOptions)r.push([t.name,e.value])}return t?.name&&!t.disabled&&r.push([t.name,t.value]),r},Ee=(e,t)=>{let n=new Set([...e.elements].map(e=>e.name).filter(Boolean)),r=new URLSearchParams,i=e=>e!==`search`&&te.includes(e);for(let[e,t]of k)e!==`page`&&(i(e)||!n.has(e))&&r.append(e,t);for(let[n,a]of V(e,t))a===``||i(n)||ne.has(n)||r.append(n,a);let a=z();if(a){r.delete(f);let e=a.value.trim();e&&r.set(f,e)}return L(r,`push`)},De=e=>y.filtersForm&&e.closest?.(y.filtersForm)||y.filtersRegion&&e.closest?.(y.filtersRegion)||null;document.addEventListener(`submit`,e=>{B()&&y.filtersForm&&e.target instanceof HTMLFormElement&&e.target.matches(y.filtersForm)&&(e.preventDefault(),Ee(e.target,e.submitter))},w),document.addEventListener(`change`,e=>{if(!B()||!y.filtersForm)return;let t=e.target.closest?.(y.filtersForm);!t||e.target===z()||t.hasAttribute(`data-wui-apply-on-change`)||e.target.closest?.(`wui-filter-popover`)||Ee(t)},w);let Oe=(e,t)=>{if(!e)return;let n=e=>t.get(e)??``;for(let r of e.querySelectorAll(`input[name]:not([type=hidden])`))if(r.type===`checkbox`)r.checked=t.getAll(r.name).includes(r.value);else if(r.type===`radio`){let e=n(r.name)===r.value;if(r.checked===e)continue;r.checked=e,e&&r.dispatchEvent(new Event(`change`))}else r.value!==n(r.name)&&(r.value=n(r.name),r.dispatchEvent(new Event(`input`,{bubbles:!0})));for(let r of e.querySelectorAll(`select[name]`))if(!r.multiple)r.value=n(r.name);else for(let e of r.options)e.selected=t.getAll(r.name).includes(e.value);for(let r of e.querySelectorAll(`wui-select[name]`)){let e=r.getAttribute(`name`);r.value=r.mode===`multiple`||r.mode===`tag`?t.getAll(e):n(e)}for(let t of e.querySelectorAll(`wui-date-range`)){let e=t.getAttribute(`start-name`)||t.getAttribute(`name`),r=t.getAttribute(`end-name`);t.value={start:e?n(e):``,end:r?n(r):``}}};document.addEventListener(`click`,e=>{if(!B())return;let t=e.target.closest?.(`a[href]`);if(!t||!De(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=Se(se(n.href));Oe(t.closest(`form`),r),Ct(t.closest(`form`),r),L(r,`push`)},w),document.addEventListener(`input`,e=>{if(!B())return;let t=z();t&&e.target===t&&(clearTimeout(D),D=setTimeout(()=>{if(!B())return;let e=Se(new URLSearchParams(k)),n=t.value.trim();n?e.set(f,n):e.delete(f),e.toString()!==k.toString()&&L(e,`replace`)},300))},w),y.urlState&&window.addEventListener(`popstate`,()=>{if(!B())return;let e=oe(window.location.search),t=z();t&&(t.value=e.get(`search`)??``),Ct(I(),e),L(e,`none`)},w),document.addEventListener(`wui:modal:success`,()=>{B()&&y.refreshOnSuccess&&L(k,`none`)},w),g?.addEventListener(`click`,e=>{e.target.closest(`[data-wui-table-retry]`)&&ae&&L(ae.query,ae.mode)});let ke=e=>[...T.rows].find(t=>t.dataset.rowKey===e)??null,Ae=e=>{if(!e?.trim())return null;let t=document.createElement(`template`);if(t.innerHTML=`<table><tbody>${e}</tbody></table>`,t.content.querySelector(`tbody[data-wui-rows]`))return null;let n=[...t.content.querySelectorAll(`table > tbody > tr[data-row-key]`)];return n.length?n.map(e=>document.importNode(e,!0)):null},H=(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:ke(n.dataset.rowKey);e&&(N(e),e.replaceWith(n),i.push(n))}return pe(i),window.WUI?.refresh?.(p),r},je=e=>e.message||(e.kind===`forbidden`?W.actionForbidden:W.actionFailed),Me=e=>{e?.isConnected&&e.getAttribute(`data-wui-save-state`)===`saving`&&c(e,null)},Ne=e=>{if(e instanceof HTMLTableRowElement)return e;let t=document.createElement(`template`);t.innerHTML=`<table><tbody>${String(e)}</tbody></table>`;let n=t.content.querySelector(`table > tbody > tr`);if(!n)throw Error("saveRow's `row` is the row as it will read: a <tr> element or its HTML.");return document.importNode(n,!0)},Pe=async({url:e,method:t=`POST`,body:n,key:r,row:i}={})=>{if(!e)throw Error("saveRow needs `url`: the handler that saves the row.");let o=r==null,u=o?null:ke(String(r));if(!o&&!u)throw Error(`saveRow found no row with data-row-key="${r}" on this page.`);let ee=M().filter(e=>!e.classList.contains(U)),d=i?Ne(i):u??F(Math.max(1,ee.length),ee);u&&d!==u?u.replaceWith(d):u||T.insertBefore(d,T.firstChild),d!==u&&pe([d]),g&&!p.hasAttribute(`data-wui-table-error`)&&(g.hidden=!0),c(d,`saving`);let te=s(d),f=await a(e,{method:t.toUpperCase(),body:n});if(f.kind===`session`)return!1;if(f.ok){let e=Ae(f.html),t=e&&d.isConnected?H(e,d,o):null;return t?j(l.saved(s(t)||te)):(await L(k,`none`),Me(d)),gt(f,f.toastVariant||`success`),A(`wui:table:saved`,{key:t?.dataset.rowKey??(o?null:String(r)),added:o,status:f.status}),!0}let m=je(f),h=d;return u&&d!==u&&d.isConnected?(d.replaceWith(u),h=u):o&&!i&&(d.remove(),h=null,g?.childElementCount&&!T.querySelector(`:scope > tr`)&&(g.hidden=!1)),h?.isConnected&&c(h,`error`,m),f.kind!==`aborted`&&St(m,`danger`),j(l.notSaved(te,m)),A(`wui:table:failed`,{key:o?null:String(r),added:o,status:f.status,kind:f.kind,message:m}),!1},Fe=async e=>{let t=e.dataset.url;if(!t)throw Error(`A data-wui-row-action button needs data-url: the handler the action posts to.`);let n=e.closest(`tr`),r=n?.dataset.rowKey??null,i=e.dataset.wuiRowAction||``,o=n?s(n):``;e.disabled=!0,e.setAttribute(`aria-busy`,`true`),n&&c(n,`saving`);let u=await a(t,{method:(e.dataset.method||`post`).toUpperCase()});if(e.disabled=!1,e.removeAttribute(`aria-busy`),u.kind===`session`||u.kind===`aborted`)Me(n);else{if(u.ok){gt(u,u.toastVariant||`success`);let e=n?.isConnected?Ae(u.html):null,t=e?H(e,n,!1):null;t?j(l.saved(s(t)||o)):(await L(k,`none`),Me(n))}else{let e=je(u);St(e,`danger`),n?.isConnected&&c(n,`error`,e),j(l.notSaved(o,e))}A(`wui:table:action`,{action:i,key:r,ok:u.ok,status:u.status})}};return m.addEventListener(`click`,e=>{let t=e.target.closest(`[data-wui-row-action]`);t&&T.contains(t)&&!t.disabled&&(e.preventDefault(),Fe(t))}),de(T),he(T),x&&ut(m),me(T),we(),{el:n,reload:async e=>{let t=e?.quiet===!0;return t&&p.getAttribute(`aria-busy`)===`true`?null:L(k,`none`,{quiet:t})},query:()=>new URLSearchParams(k),setQuery:e=>{let t=new URLSearchParams(k);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`),L(t,`push`)},saveRow:Pe,setActiveRow:e=>{n.dataset.activeRowKey=e==null?``:String(e),fe([...T.querySelectorAll(`:scope > tr`)])},selection:{keys:()=>[...S],count:()=>C?E.total:S.size,allMatching:()=>C,selectAllMatching:()=>{C=!0;for(let e of T.querySelectorAll(`:scope > tr`)){let t=e.querySelector(`.${U} .wui-check`);t?.disabled||(t&&(t.checked=!0),e.dataset.rowKey&&S.add(e.dataset.rowKey))}Te()},clear:()=>{C=!1,S.clear();for(let e of T.querySelectorAll(`:scope > tr > .${U} .wui-check:not(:disabled)`))e.checked=!1;Te()}}}}var G=`wuiConfirm`,kt=Object.freeze([`danger`]),At=Object.freeze([`success`,`info`,`warning`,`danger`]),jt=`wui.flash`,K=Object.freeze({confirmTitle:`Are you sure?`,confirmLabel:`Confirm`,cancelLabel:`Cancel`,failed:`That did not work. Try again.`,forbidden:`You do not have permission to do that.`,network:`Could not reach the server. Check your connection and try again.`}),Mt=/* @__PURE__ */ new WeakSet,Nt=/* @__PURE__ */ new WeakSet,Pt=null,Ft=null,It=!1,Lt=e=>{let t=document.createElement(`span`);return t.textContent=e??``,t.innerHTML},Rt=(e,t)=>{e&&window.WUI?.toast?.(e,{variant:t})},zt=()=>{let e=window.bootstrap?.Modal;if(!e)throw Error(`data-wui-confirm: Bootstrap's bundle (window.bootstrap) is not loaded on this page.`);return e};function Bt(){let n=document.getElementById(G);return n||(n=document.createElement(`div`),n.id=G,n.className=`modal fade wui-modal-shell`,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-modal`,`true`),n.style.setProperty(`--wui-modal-max-width`,`${v.md}px`),n.innerHTML=`<div class="modal-dialog modal-dialog-centered wui-rb-dialog"><div class="modal-content wui-modal wui-confirm"><div class="wui-modal-body"><div class="wui-confirm-content"><span class="wui-confirm-icon"><wui-status-icon tone="info" size="120"></wui-status-icon></span><h3 class="wui-confirm-title" tabindex="-1" data-autofocus></h3><p class="wui-confirm-msg"></p></div></div><div class="wui-modal-footer"><div class="wui-confirm-actions"><button type="button" class="${e(`primary`,`soft`,`md`)}" data-bs-dismiss="modal" data-wui="${t}">${Lt(K.cancelLabel)}</button><button type="button" class="${e(`primary`,`solid`,`md`)}" data-app-confirm data-wui="${t}"></button></div></div></div></div>`,document.body.appendChild(n),n)}function Vt(e,t){let n=e.getAttribute(`data-wui-confirm-tone`);if(n!==null&&!kt.includes(n))throw TypeError(`data-wui-confirm-tone="${n}" is not supported. Use danger, or leave it off.`);Ht({title:e.getAttribute(`data-wui-confirm-title`),message:e.getAttribute(`data-wui-confirm`),label:e.getAttribute(`data-wui-confirm-label`),danger:n===`danger`},t)}function Ht({title:e,message:t,label:n,danger:r},i){let a=zt(),o=Bt(),s=o.querySelector(`.wui-confirm-title`),c=o.querySelector(`[data-app-confirm]`);if(!s||!c)throw Error(`#${G} is not a confirm dialog with a confirm button. Render <app-confirm-dialog id="${G}"> without confirm-href, or leave the dialog to the library.`);let l=o.querySelector(`.wui-confirm-msg`);l||(l=document.createElement(`p`),l.className=`wui-confirm-msg`,s.after(l)),s.textContent=e||K.confirmTitle,l.textContent=t,c.textContent=n||K.confirmLabel,c.classList.toggle(`btn-danger`,r),c.classList.toggle(`btn-primary`,!r),o.querySelector(`wui-status-icon`)?.setAttribute(`tone`,r?`delete`:`info`),o.setAttribute(`aria-label`,s.textContent),Ft=i,It=!1,a.getOrCreateInstance(o).show()}var Ut=(e,t)=>{Pt=e;try{t()}finally{Pt=null}};function Wt(e,{title:t,message:n,label:r,tone:i},a){if(i!=null&&!kt.includes(i))throw TypeError(`confirmAction: tone "${i}" is not supported. Use danger, or leave it off.`);sn(e.ownerDocument),Ht({title:t,message:n,label:r,danger:i===`danger`},()=>Ut(e,a))}var Gt=e=>e.disabled===!0||e.getAttribute(`aria-disabled`)===`true`;function Kt(e){let t=e.target.closest?.(`[data-wui-confirm]:not(form)`);t&&t!==Pt&&!Gt(t)&&(e.preventDefault(),e.stopImmediatePropagation(),Vt(t,()=>Ut(t,()=>t.click())))}function qt(e){let t=e.target;if(!(t instanceof HTMLFormElement)||!t.hasAttribute(`data-wui-confirm`)||t===Pt||e.submitter&&e.submitter===Pt||t.querySelector(`input[data-app-repeater-hidden]`))return;e.preventDefault(),e.stopImmediatePropagation();let n=e.submitter?.form===t?e.submitter:void 0;Vt(t,()=>Ut(t,()=>t.requestSubmit(n)))}function Jt(e){let t=e.target.closest?.(`#${G} [data-app-confirm]`);t&&!t.disabled&&Ft&&(It=!0,zt().getOrCreateInstance(t.closest(`#${G}`)).hide())}function Yt(e){if(e.target.id!==`wuiConfirm`)return;let t=It?Ft:null;Ft=null,It=!1,t?.()}var Xt=(e,t)=>{e&&window.sessionStorage.setItem(jt,JSON.stringify({message:e,variant:t}))},Zt=e=>e===`forbidden`?K.forbidden:e===`network`?K.network:K.failed;function Qt(){for(let e of document.querySelectorAll(`[data-wui-server]`))e.dataset.refreshOnSuccess!==`false`&&Dt(e)?.reload()}async function $t(e){let t=e.getAttribute(`data-wui-post`);if(!t)throw Error(`A data-wui-post button needs the URL the action posts to.`);return en(t,e)}async function en(e,t,n){let r=t.getAttribute(`data-wui-post-reload`);if(r!==null&&r!==`page`)throw TypeError(`data-wui-post-reload="${r}" is not supported. Use page, or leave it off to reload the server tables.`);t.disabled=!0,t.setAttribute(`aria-busy`,`true`);let i=await a(e,{method:`POST`,body:n});if(i.kind===`session`||i.kind===`aborted`)return;let o=i.toastVariant||`success`;i.ok&&(i.redirect||r===`page`)?(Xt(i.message,o),i.redirect?window.location.assign(i.redirect):window.location.reload()):(t.disabled=!1,t.removeAttribute(`aria-busy`),i.ok?(gt(i,o),Qt()):Rt(i.message||Zt(i.kind),`danger`))}function tn(e){let t=e.target.closest?.(`[data-wui-post]`);t&&(e.preventDefault(),Gt(t)||t.getAttribute(`aria-busy`)===`true`||$t(t).catch(e=>i(e)))}function nn(e){let t=e.target.closest?.(`form[data-wui-post-form]`);if(!t||e.defaultPrevented)return;e.preventDefault();let n=e.submitter||t.querySelector(`button`);n.getAttribute(`aria-busy`)!==`true`&&(en(t.getAttribute(`action`),n,new FormData(t)).catch(e=>i(e)),window.bootstrap?.Dropdown?.getInstance(t.closest(`.dropdown`)?.querySelector(`[data-bs-toggle='dropdown']`))?.hide())}function rn(){let e=window.sessionStorage.getItem(jt);if(!e)return;window.sessionStorage.removeItem(jt);let{message:t,variant:n}=JSON.parse(e);Rt(t,n)}function an(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(!At.includes(t))throw TypeError(`data-wui-flash-variant="${t}" is not supported. Use ${At.join(`, `)}.`);let n=e.getAttribute(`data-wui-flash`)||e.textContent.trim();e.remove(),Rt(n,t)}}function on(e){let t=e.target instanceof Element?e.target.closest(`[data-wui-auto-submit]`):null,n=t&&(e.target.form||t.closest(`form`));n&&n.requestSubmit()}function sn(e){Nt.has(e)||(Nt.add(e),e.addEventListener(`click`,Jt),e.addEventListener(`hidden.bs.modal`,Yt))}function cn(e=document){let t=e.ownerDocument||e;Mt.has(t)||(Mt.add(t),t.addEventListener(`click`,Kt,!0),t.addEventListener(`submit`,qt,!0),sn(t),t.addEventListener(`click`,tn),t.addEventListener(`submit`,nn),t.addEventListener(`change`,on),rn()),an(e)}var ln=Object.freeze({title:`Leave without saving?`,message:`Your changes on this page are not saved. If you leave now, they are lost.`,leaveLabel:`Leave`}),q=`form[data-wui-unsaved]`,un=`[aria-invalid="true"], .field-error:not(:empty), .field-validation-error, .validation-summary-errors, .wui-error-summary`,dn=`[download], [data-wui-modal], [data-wui-post], [data-bs-toggle]`,fn=/* @__PURE__ */ new Set([`submit`,`button`,`reset`,`image`]),pn=/* @__PURE__ */ new Set([`hidden`,`checkbox`,`radio`,`file`,`submit`,`button`,`reset`,`image`,`range`,`color`]),J=/* @__PURE__ */ new WeakMap,mn=/* @__PURE__ */ new WeakSet,hn=e=>`${e.name}:${e.size}:${e.lastModified}`;function Y(e){let t=[];for(let n of e.elements)!n.name||n.disabled||fn.has(n.type)||(n.type===`checkbox`||n.type===`radio`?t.push([n.name,n.value,n.checked]):n.type===`file`?t.push([n.name,[...n.files||[]].map(hn)]):n.type===`select-multiple`?t.push([n.name,[...n.selectedOptions].map(e=>e.value)]):t.push([n.name,n.value]));return JSON.stringify(t)}function X(e){return Y(e)}function gn(e,t){let n=/* @__PURE__ */ new Map;for(let e of JSON.parse(t)){let t=n.get(e[0]);t?t.push(e):n.set(e[0],[e])}let r=JSON.parse(Y(e)).map(e=>n.get(e[0])?.shift()??e);for(let e of n.values())r.push(...e);return JSON.stringify(r)}function _n(e){for(let t of e.elements)if(t.name&&!t.disabled){if(t.tagName===`TEXTAREA`||t.tagName===`INPUT`&&!pn.has(t.type)){if(t.value.trim()!==``)return!0}else if(t.tagName===`INPUT`&&t.type===`file`&&t.files?.length>0)return!0}return!1}var vn=e=>({saved:e.querySelector(un)&&_n(e)?null:Y(e),engaged:!1,discarded:!1});function yn(e){let t=J.get(e);return!t||t.discarded||!e.isConnected?!1:t.saved===null||t.engaged&&Y(e)!==t.saved}var bn=(e,t)=>[...e.querySelectorAll(q)].filter(e=>e!==t&&yn(e)),xn=()=>!!window.bootstrap?.Modal;function Sn(e,t,n){let r=t.map(e=>e.getAttribute(`data-wui-unsaved`)).find(Boolean)||ln.message;Wt(e,{title:ln.title,message:r,label:ln.leaveLabel,tone:`danger`},()=>{for(let e of t)J.get(e).discarded=!0;n()})}function Cn(e){if(e.matches(dn))return!1;let t=e.getAttribute(`target`);if(t&&t.toLowerCase()!==`_self`)return!1;let n=new URL(e.getAttribute(`href`),window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)return!1;let r=window.location;return!(n.hash&&n.origin===r.origin&&n.pathname===r.pathname&&n.search===r.search)}function wn(e,t){if((t?.getAttribute(`formmethod`)||e.getAttribute(`method`)||`get`).toLowerCase()===`dialog`)return!1;let n=t?.getAttribute(`formtarget`)||e.getAttribute(`target`);return!n||n.toLowerCase()===`_self`}function Tn(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target.closest?.(`a[href]`);if(!t||!Cn(t))return;let n=bn(t.ownerDocument,null);n.length&&xn()&&(e.preventDefault(),Sn(t,n,()=>t.click()))}function En(e){let t=e.target;if(!(t instanceof HTMLFormElement)||e.defaultPrevented||!wn(t,e.submitter))return;let n=bn(t.ownerDocument,t);if(n.length&&xn()){e.preventDefault();let r=e.submitter?.form===t?e.submitter:void 0;Sn(t,n,()=>t.requestSubmit(r));return}let r=J.get(t);r&&(r.saved=Y(t),r.discarded=!1)}function Dn(e){bn(document,null).length&&(e.preventDefault(),e.returnValue=``)}function On(e){let t=e.target.closest?.(q),n=t&&J.get(t);n&&!n.engaged&&(n.saved!==null&&(n.saved=Y(t)),n.engaged=!0)}function kn(e){let t=e.target.closest?.(q),n=t&&J.get(t);n&&(n.discarded=!1,e.isTrusted&&(n.engaged=!0))}function An(e){for(let t of e.currentTarget.querySelectorAll(q)){let e=J.get(t);e?.saved&&(e.saved=gn(t,e.saved))}}function jn(e){let t=e.detail?.handle?.el;if(t instanceof Element)for(let e of t.querySelectorAll(q))Nn(e)}function Mn(e=document){let t=e.ownerDocument||e;if(!mn.has(t)){mn.add(t);for(let e of[`focusin`,`pointerdown`,`drop`])t.addEventListener(e,On,!0);for(let e of[`input`,`change`])t.addEventListener(e,kn,!0);t.addEventListener(`click`,Tn),t.addEventListener(`submit`,En),t.addEventListener(`wui:modal:success`,jn),t.addEventListener(n,An),t.defaultView.addEventListener(`beforeunload`,Dn)}let r=[...e.querySelectorAll?.(q)||[]];e.matches?.(q)&&r.unshift(e);for(let e of r)J.has(e)||J.set(e,vn(e))}function Nn(e){if(!(e instanceof HTMLFormElement)||!e.matches(q))throw TypeError(`resetUnsavedChanges: ${String(e)} is not a <form data-wui-unsaved>.`);J.set(e,{saved:Y(e),engaged:!1,discarded:!1})}var Pn=Object.freeze({question:`Discard your changes?`,discard:`Discard`,keep:`Keep editing`}),Fn=`wui:drawer:discard`,Z=`wui-drawer[confirm-discard]`,In=`.wui-modal-shell`,Ln=`data-wui-no-discard`,Rn=`.wui-drawer-discard`,zn=`input, select, textarea`,Q=/* @__PURE__ */ new WeakMap,Bn=/* @__PURE__ */ new WeakSet,Vn=/* @__PURE__ */ new WeakSet;function Hn(n,r,i,a,o){let s=n.createElement(`button`);return s.type=`button`,s.className=e(r,i,`sm`),s.dataset.wui=t,s.setAttribute(a,``),s.textContent=o,s}function Un(e,t){let n=e.createElement(`div`);n.className=`wui-drawer-discard`,n.setAttribute(`role`,`alert`);let r=e.createElement(`span`);return r.className=`wui-drawer-discard-text`,r.textContent=t,n.append(r,Hn(e,`danger`,`solid`,`data-wui-discard-confirm`,Pn.discard),Hn(e,`primary`,`soft`,`data-wui-discard-keep`,Pn.keep)),n}function Wn(e){let t=e.closest?.(Z);if(t)return t;let n=e.closest?.(In);return n&&$(n).length?n:null}function Gn(e){return e.closest(Z)??e.closest(In)}function Kn(e,t){return t.hasAttribute(Ln)||e.hasAttribute(Ln)?!1:t.hasAttribute(`confirm-discard`)||e.hasAttribute(`data-wui-confirm-discard`)?!0:(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`}function $(e){return e.matches(Z)?e.querySelectorAll(`form`):[...e.querySelectorAll(`form`)].filter(t=>Kn(t,e))}function qn(e){let t=Q.get(e);return t!=null&&X(e)!==t}function Jn(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-drawer-footer`,e.querySelector(`.wui-drawer-panel`).append(t),Vn.add(t),t}function Yn(e){let t=e.ownerDocument.createElement(`div`);return t.className=`wui-modal-footer`,(e.querySelector(`.wui-modal-body`)?.parentElement??e.querySelector(`.modal-content`)??e).append(t),Vn.add(t),t}function Xn(e){e.querySelector(`[data-wui-discard-confirm]`).focus()}function Zn(e,t,n){let r=e.querySelector(Rn);if(r){Xn(r);return}let i=Un(e.ownerDocument,t),a;e.matches(Z)?(a=e.querySelector(`.wui-drawer-footer`)??Jn(e),a.prepend(i)):e.hasAttribute(`confirm-discard`)?(a=e.querySelector(`.wui-modal-footer`)??Yn(e),a.prepend(i)):(a=n.querySelector(`.modal-footer`),a?a.prepend(i):(a=n,n.append(i))),a.classList.add(`wui-drawer-discarding`),Xn(i)}function Qn(e){let t=e.parentElement;e.remove(),t.classList.remove(`wui-drawer-discarding`),Vn.has(t)&&t.remove()}function $n(e){for(let t of $(e)){let e=[...t.querySelectorAll(zn)].find(e=>e.type!==`hidden`&&!e.disabled);if(e){e.focus({preventScroll:!0});return}}}function er(e){let t=Wn(e.target);if(t)for(let e of $(t))Q.get(e)??Q.set(e,X(e))}function tr(e){for(let t of e.currentTarget.querySelectorAll(`form`)){let e=Q.get(t);e!=null&&Q.set(t,gn(t,e))}}function nr(e){let t=e.target;t instanceof HTMLFormElement&&Wn(t)&&Q.set(t,X(t))}function rr(e){let t=e.detail?.handle?.el;if(t instanceof Element)for(let e of t.querySelectorAll(`form`))Q.delete(e)}function ir(e){let t=e.target;t instanceof Element&&t.matches(Z)&&[...$(t)].some(qn)&&(e.preventDefault(),Zn(t,t.getAttribute(`confirm-discard`),null))}function ar(e){let t=e.target;if(!(t instanceof Element)||!t.matches(In))return;let n=[...$(t)].find(qn);n&&(e.preventDefault(),Zn(t,n.getAttribute(`data-wui-confirm-discard`)??t.getAttribute(`confirm-discard`)??Pn.question,n))}function or(e){let t=e.closest(`wui-drawer`);if(t){t.dispatchEvent(new CustomEvent(`wui-drawer-close`,{bubbles:!0,cancelable:!0}))&&t.hide();return}let n=e.closest(In);n&&window.bootstrap?.Modal?.getInstance(n)?.hide()}function sr(e){let t=e.closest(Rn),n=Gn(t);Qn(t);for(let e of $(n))Q.set(e,X(e));n.dispatchEvent(new CustomEvent(Fn,{bubbles:!0})),n.matches(Z)?n.hide():window.bootstrap.Modal.getInstance(n).hide()}function cr(e){let t=e.closest(Rn),n=Gn(t);Qn(t),$n(n)}function lr(e){let t=e.target,n=t.closest?.(`[data-wui-discard-confirm]`);if(n){sr(n);return}let r=t.closest?.(`[data-wui-discard-keep]`);if(r){cr(r);return}let i=t.closest?.(`[data-wui-dismiss]`);i&&or(i)}function ur(e){if(e.key!==`Escape`)return;let t=e.currentTarget.querySelector(Rn);if(!t)return;e.preventDefault(),e.stopPropagation();let n=Gn(t);Qn(t),$n(n)}function dr(e=document){let t=e.ownerDocument||e;Bn.has(t)||(Bn.add(t),t.addEventListener(`focusin`,er),t.addEventListener(`pointerdown`,er),t.addEventListener(`submit`,nr),t.addEventListener(n,tr),t.addEventListener(`wui:modal:success`,rr),t.addEventListener(`wui:modal:loaded`,rr),t.addEventListener(`wui-drawer-close`,ir,!0),t.addEventListener(`hide.bs.modal`,ar),t.addEventListener(`click`,lr),t.addEventListener(`keydown`,ur,!0))}export{Ze as C,Je as S,$e as T,Et as _,ln as a,gt as b,Nn as c,jt as d,At as f,Dt as g,cn as h,dr as i,G as l,Wt as m,Pn as n,X as o,K as p,Un as r,Mn as s,Fn as t,kt as u,mt as v,Ye as w,et as x,_t as y};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiCodeBlock-CXBYH2Ej.js";e(`wui-code-block`,t);export{t as WuiCodeBlock};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiCodeBlock-CCCJwsk5.js";e(`wui-code-block`,t);export{t as WuiCodeBlock};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{i as t,n,r,t as i}from"../WuiCommentThread-ZXxBt71o.js";import"./mention-input.js";e(`wui-comment-thread`,t);export{i as COMMENT_INTENTS,n as COMMENT_REACTIONS,r as COMMENT_TEXT,t as WuiCommentThread};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{i as t,n,r,t as i}from"../WuiCommentThread-B9bkBMIq.js";import"./mention-input.js";e(`wui-comment-thread`,t);export{i as COMMENT_INTENTS,n as COMMENT_REACTIONS,r as COMMENT_TEXT,t as WuiCommentThread};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiConsentBanner-CYOU67bp.js";e(`wui-consent-banner`,t);export{t as WuiConsentBanner};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiConsentBanner-jkeRiC1_.js";e(`wui-consent-banner`,t);export{t as WuiConsentBanner};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiSavedViews-KUVaYmGJ.js";e(`wui-saved-views`,t);export{t as WuiSavedViews};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{t}from"../WuiSavedViews-CQSrMJUb.js";e(`wui-saved-views`,t);export{t as WuiSavedViews};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{n as t,t as n}from"../WuiTour-D18C-wQP.js";e(`wui-tour`,n);export{n as WuiTour,t as createLocalSeenStore};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{n as t,t as n}from"../WuiTour-Cz_SaC60.js";e(`wui-tour`,n);export{n as WuiTour,t as createLocalSeenStore};
@@ -1 +1 @@
1
- import{n as e}from"../elementBase-DV9IZZCu.js";import{n as t,t as n}from"../WuiWizardStep-DB-BbyEO.js";e(`wui-wizard-step`,n),e(`wui-wizard`,t);export{t as WuiWizard,n as WuiWizardStep};
1
+ import{n as e}from"../elementBase-DV9IZZCu.js";import{n as t,t as n}from"../WuiWizardStep-CIYuIp4a.js";e(`wui-wizard-step`,n),e(`wui-wizard`,t);export{t as WuiWizard,n as WuiWizardStep};