@webority/ui-elements 0.128.0 → 0.129.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 (131) hide show
  1. package/README.md +4 -0
  2. package/dist/WuiAutocomplete-Q6lFj3yx.js +13 -0
  3. package/dist/{WuiCodeBlock-DafK2Kgc.js → WuiCodeBlock-Cdz6meSs.js} +1 -1
  4. package/dist/{WuiCommandPalette-CiEj7qnn.js → WuiCommandPalette-DS7VtDSy.js} +1 -1
  5. package/dist/{WuiCommentThread-2U3rwoH1.js → WuiCommentThread-0GshmzBj.js} +1 -1
  6. package/dist/{WuiCountrySelect-kgShmlip.js → WuiCountrySelect-RBhlw3vb.js} +1 -1
  7. package/dist/{WuiDataTable-BICQ8DT7.js → WuiDataTable-BVagEWAU.js} +1 -1
  8. package/dist/WuiDatePicker-DR6ZIW_8.js +31 -0
  9. package/dist/WuiDateRange-BgI9zi3w.js +25 -0
  10. package/dist/{WuiInlineEdit-DtSFAmEv.js → WuiInlineEdit-C6E6bGpU.js} +1 -1
  11. package/dist/WuiLeadPopup-CWv93qlo.js +306 -0
  12. package/dist/{WuiLightbox-D_7mpvkt.js → WuiLightbox-zFBcRDsq.js} +1 -1
  13. package/dist/WuiMarkdown-DNVK_5BI.js +4 -0
  14. package/dist/WuiMentionInput-DhJ180iU.js +1 -0
  15. package/dist/WuiMultiSelect-DwOzpXFZ.js +25 -0
  16. package/dist/{WuiNotificationCenter-BWL56BPm.js → WuiNotificationCenter-Br_cd0C_.js} +1 -1
  17. package/dist/WuiOtp-BqWijfNj.js +14 -0
  18. package/dist/WuiPhone-Bb9OF7-U.js +16 -0
  19. package/dist/{WuiRelativeTime-9u8XG-nr.js → WuiRelativeTime-CcbKgVjE.js} +1 -1
  20. package/dist/{WuiRollingNumber-C72xBgyG.js → WuiRollingNumber-D7uHyeQB.js} +1 -1
  21. package/dist/WuiSavedViews-B5DNBGpt.js +1 -0
  22. package/dist/WuiSelect-Czp_9FoM.js +15 -0
  23. package/dist/WuiSlider-2kB__6zU.js +51 -0
  24. package/dist/WuiTagInput-Dpfz3DQQ.js +6 -0
  25. package/dist/WuiTimePicker-Cp4MfJlU.js +9 -0
  26. package/dist/{WuiTree-BNNk1CQ5.js → WuiTree-Dh5Tc_Ex.js} +1 -1
  27. package/dist/WuiWizardStep-DK2qWwP9.js +1 -0
  28. package/dist/{dataTable-4RjZ1c5V.js → dataTable-CUILMcga.js} +1 -1
  29. package/dist/elements/autocomplete.js +1 -1
  30. package/dist/elements/code-block.js +1 -1
  31. package/dist/elements/command-palette.js +1 -1
  32. package/dist/elements/comment-thread.js +1 -1
  33. package/dist/elements/country-select.js +1 -1
  34. package/dist/elements/data-table.js +1 -1
  35. package/dist/elements/date-range.js +1 -1
  36. package/dist/elements/datepicker.js +1 -1
  37. package/dist/elements/inline-edit.js +1 -1
  38. package/dist/elements/kanban.js +1 -1
  39. package/dist/elements/lead-popup.js +1 -0
  40. package/dist/elements/lightbox.js +1 -1
  41. package/dist/elements/markdown.js +1 -1
  42. package/dist/elements/mention-input.js +1 -1
  43. package/dist/elements/multiselect.js +1 -1
  44. package/dist/elements/notification-center.js +1 -1
  45. package/dist/elements/otp.js +1 -1
  46. package/dist/elements/phone.js +1 -1
  47. package/dist/elements/relative-time.js +1 -1
  48. package/dist/elements/rolling-number.js +1 -1
  49. package/dist/elements/saved-views.js +1 -1
  50. package/dist/elements/select.js +1 -1
  51. package/dist/elements/slider.js +1 -1
  52. package/dist/elements/taginput.js +1 -1
  53. package/dist/elements/timepicker.js +1 -1
  54. package/dist/elements/tree.js +1 -1
  55. package/dist/elements/wizard.js +1 -1
  56. package/dist/fieldState-D-zQcXUS.js +1 -0
  57. package/dist/{fileViewerImage-Bn5HCF30.js → fileViewerImage-DQYAoEzn.js} +1 -1
  58. package/dist/{fileViewerMedia-zSDnvCSa.js → fileViewerMedia-DwkIYzmY.js} +1 -1
  59. package/dist/{fileViewerPdf-C1QZnzCq.js → fileViewerPdf-CvY7afCX.js} +1 -1
  60. package/dist/fileViewerUi-D9R6-gZt.js +1 -0
  61. package/dist/{focusOrigin-BPTN3GY3.js → focusOrigin-0sYG-5El.js} +1 -1
  62. package/dist/formatters-D1zbsEJJ.js +1 -0
  63. package/dist/helpers.js +1 -1
  64. package/dist/iconGlyphs.g-DaOONrBK.js +1 -0
  65. package/dist/kanban-DqdYQ6sC.js +1 -0
  66. package/dist/{notificationDays-CZNthz7L.js → notificationDays-CMjhBP1Z.js} +1 -1
  67. package/dist/{optionLabel-BaLjjB-0.js → optionLabel-BkmbyLNL.js} +1 -1
  68. package/dist/server-XVcnIJ_Y.js +1 -0
  69. package/dist/server.js +1 -0
  70. package/dist/ui-calendar.global.js +1 -1
  71. package/dist/ui-calendar.js +1 -1
  72. package/dist/ui-chart.global.js +2 -2
  73. package/dist/ui-chart.js +2 -2
  74. package/dist/ui-elements/autocomplete.global.js +6 -6
  75. package/dist/ui-elements/carousel.global.js +1 -1
  76. package/dist/ui-elements/code-block.global.js +1 -1
  77. package/dist/ui-elements/command-palette.global.js +1 -1
  78. package/dist/ui-elements/comment-thread.global.js +1 -1
  79. package/dist/ui-elements/consent-banner.global.js +1 -1
  80. package/dist/ui-elements/context-menu.global.js +1 -1
  81. package/dist/ui-elements/date-range.global.js +9 -9
  82. package/dist/ui-elements/drawer.global.js +1 -1
  83. package/dist/ui-elements/image-crop.global.js +1 -1
  84. package/dist/ui-elements/inline-edit.global.js +1 -1
  85. package/dist/ui-elements/kanban.global.js +1 -1
  86. package/dist/ui-elements/lead-popup.global.js +306 -0
  87. package/dist/ui-elements/lightbox.global.js +1 -1
  88. package/dist/ui-elements/markdown.global.js +3 -3
  89. package/dist/ui-elements/multiselect.global.js +14 -14
  90. package/dist/ui-elements/phone.global.js +9 -9
  91. package/dist/ui-elements/resizable.global.js +1 -1
  92. package/dist/ui-elements/saved-views.global.js +1 -1
  93. package/dist/ui-elements/slider.global.js +10 -7
  94. package/dist/ui-elements/sortable.global.js +1 -1
  95. package/dist/ui-elements/status-icon.global.js +1 -1
  96. package/dist/ui-elements/taginput.global.js +4 -4
  97. package/dist/ui-elements/timepicker.global.js +3 -3
  98. package/dist/ui-elements/tour.global.js +1 -1
  99. package/dist/ui-elements/tree.global.js +1 -1
  100. package/dist/ui-elements/wizard.global.js +1 -1
  101. package/dist/ui-elements.global.js +30 -30
  102. package/dist/ui-elements.js +1 -1
  103. package/dist/ui-file-viewer.global.js +1 -1
  104. package/dist/ui-file-viewer.js +1 -1
  105. package/dist/ui-lead-popup.global.js +1 -0
  106. package/dist/ui-rich-text.global.js +57 -57
  107. package/dist/ui-rich-text.js +55 -55
  108. package/dist/wuiHttp-DgnM7K2Q.js +1 -0
  109. package/dist/zone-D82f-GU_.js +1 -0
  110. package/package.json +8 -5
  111. package/dist/WuiAutocomplete-DE9q2G-l.js +0 -13
  112. package/dist/WuiDatePicker-CkBUk76L.js +0 -31
  113. package/dist/WuiDateRange-3NYNJiIa.js +0 -25
  114. package/dist/WuiMarkdown-BxmKHb3T.js +0 -4
  115. package/dist/WuiMentionInput-DIRekJlq.js +0 -1
  116. package/dist/WuiMultiSelect-Brdm5tAI.js +0 -25
  117. package/dist/WuiOtp-Hw6srogj.js +0 -14
  118. package/dist/WuiPhone-D0ixbxGE.js +0 -16
  119. package/dist/WuiSavedViews-DrJWvWuf.js +0 -1
  120. package/dist/WuiSelect-Bma_H42p.js +0 -15
  121. package/dist/WuiSlider-DXJGSJHP.js +0 -48
  122. package/dist/WuiTagInput-C38b3LfS.js +0 -6
  123. package/dist/WuiTimePicker-Bw5BKBCD.js +0 -9
  124. package/dist/WuiWizardStep-DkEdAXc8.js +0 -1
  125. package/dist/fileViewerUi-CHY-0j9d.js +0 -1
  126. package/dist/formatters-7rx97Lnm.js +0 -1
  127. package/dist/iconGlyphs.g-CQcMoS6_.js +0 -1
  128. package/dist/kanban-CTIFNgJE.js +0 -1
  129. package/dist/ui-chat.global.js +0 -11
  130. package/dist/ui-chat.js +0 -11
  131. package/dist/wuiHttp-CYxlXwsy.js +0 -1
@@ -0,0 +1,306 @@
1
+ import{n as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-DV9IZZCu.js";var n={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--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-modal":`1505`},r=e=>`var(${e}, ${n[e]})`,i=`
2
+ :host {
3
+ all: initial;
4
+ display: contents;
5
+ font-family: inherit;
6
+ font-size: 16px;
7
+ line-height: 1.5;
8
+ color: ${r(`--color-text`)};
9
+ }
10
+ *, *::before, *::after {
11
+ box-sizing: border-box;
12
+ }
13
+ [hidden] {
14
+ display: none !important;
15
+ }
16
+
17
+ dialog {
18
+ z-index: ${r(`--wui-z-modal`)};
19
+ width: 100%;
20
+ max-width: none;
21
+ height: 100%;
22
+ max-height: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ border: 0;
26
+ background: transparent;
27
+ color: inherit;
28
+ }
29
+ dialog[open] {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ }
34
+ :host([preview]) dialog {
35
+ position: static;
36
+ height: auto;
37
+ }
38
+ dialog::backdrop {
39
+ background: rgba(0, 0, 0, 0.7);
40
+ backdrop-filter: blur(5px);
41
+ }
42
+ dialog[open]::backdrop {
43
+ animation: wlp-fade 0.3s ease-out;
44
+ }
45
+
46
+ .wlp-card {
47
+ position: relative;
48
+ width: 90%;
49
+ max-width: 440px;
50
+ max-height: calc(100dvh - 32px);
51
+ overflow-y: auto;
52
+ padding: 24px;
53
+ background: ${r(`--color-surface`)};
54
+ color: ${r(`--color-text`)};
55
+ border: 1px solid ${r(`--color-border`)};
56
+ border-radius: ${r(`--wui-radius-lg`)};
57
+ box-shadow: ${r(`--wui-shadow-modal`)};
58
+ text-align: start;
59
+ }
60
+ dialog[open] .wlp-card {
61
+ animation: wlp-card-in 0.2s ease-out;
62
+ }
63
+
64
+ .wlp-close {
65
+ position: absolute;
66
+ top: 12px;
67
+ inset-inline-end: 12px;
68
+ width: 32px;
69
+ height: 32px;
70
+ padding: 0;
71
+ border: 0;
72
+ border-radius: 50%;
73
+ background: transparent;
74
+ color: ${r(`--color-text-muted`)};
75
+ font: inherit;
76
+ font-size: 22px;
77
+ line-height: 1;
78
+ cursor: pointer;
79
+ }
80
+ .wlp-close:focus-visible,
81
+ .wlp-button:focus-visible,
82
+ .wlp-input:focus-visible,
83
+ .wlp-secondary:focus-visible {
84
+ outline: 2px solid ${r(`--color-primary`)};
85
+ outline-offset: 2px;
86
+ }
87
+
88
+ .wlp-heading {
89
+ margin: 0 32px 8px 0;
90
+ font-size: 20px;
91
+ font-weight: 600;
92
+ line-height: 1.3;
93
+ color: ${r(`--color-text`)};
94
+ }
95
+ .wlp-description {
96
+ margin: 0 0 16px;
97
+ font-size: 14px;
98
+ color: ${r(`--color-text-muted`)};
99
+ }
100
+
101
+ .wlp-form {
102
+ display: grid;
103
+ gap: 14px;
104
+ margin: 0;
105
+ }
106
+ .wlp-field {
107
+ display: grid;
108
+ gap: 4px;
109
+ }
110
+ .wlp-label {
111
+ font-size: 14px;
112
+ font-weight: 500;
113
+ color: ${r(`--color-text`)};
114
+ }
115
+ .wlp-req {
116
+ margin-inline-start: 2px;
117
+ color: ${r(`--color-primary`)};
118
+ }
119
+ .wlp-input {
120
+ width: 100%;
121
+ padding: 9px 12px;
122
+ border: 1px solid ${r(`--color-border`)};
123
+ border-radius: 8px;
124
+ background: ${r(`--color-surface`)};
125
+ color: ${r(`--color-text`)};
126
+ font: inherit;
127
+ font-size: 15px;
128
+ }
129
+ textarea.wlp-input {
130
+ resize: vertical;
131
+ min-height: 96px;
132
+ }
133
+ .wlp-input[aria-invalid="true"] {
134
+ border-color: var(--color-danger, #B42318);
135
+ }
136
+ .wlp-error {
137
+ margin: 0;
138
+ font-size: 13px;
139
+ color: var(--color-danger, #B42318);
140
+ }
141
+ .wlp-form-error {
142
+ margin: 0;
143
+ font-size: 14px;
144
+ color: var(--color-danger, #B42318);
145
+ }
146
+ .wlp-visually-hidden {
147
+ position: absolute;
148
+ width: 1px;
149
+ height: 1px;
150
+ margin: -1px;
151
+ padding: 0;
152
+ overflow: hidden;
153
+ clip: rect(0, 0, 0, 0);
154
+ white-space: nowrap;
155
+ border: 0;
156
+ }
157
+ .wlp-honeypot {
158
+ position: absolute !important;
159
+ left: -9999px !important;
160
+ width: 1px;
161
+ height: 1px;
162
+ opacity: 0;
163
+ pointer-events: none;
164
+ }
165
+
166
+ .wlp-actions {
167
+ display: flex;
168
+ justify-content: flex-end;
169
+ align-items: center;
170
+ gap: 8px;
171
+ margin-top: 4px;
172
+ }
173
+ .wlp-button {
174
+ display: inline-flex;
175
+ align-items: center;
176
+ justify-content: center;
177
+ min-height: 36px;
178
+ padding: 8px 16px;
179
+ border: 1px solid ${r(`--color-primary`)};
180
+ border-radius: 8px;
181
+ background: ${r(`--color-primary`)};
182
+ color: ${r(`--color-on-primary`)};
183
+ font: inherit;
184
+ font-size: 15px;
185
+ font-weight: 500;
186
+ cursor: pointer;
187
+ }
188
+ .wlp-button:hover {
189
+ background: ${r(`--color-primary-hover`)};
190
+ border-color: ${r(`--color-primary-hover`)};
191
+ }
192
+ .wlp-button:disabled {
193
+ opacity: 0.6;
194
+ cursor: default;
195
+ }
196
+ .wlp-notice {
197
+ margin: 4px 0 0;
198
+ font-size: 12px;
199
+ line-height: 1.4;
200
+ color: ${r(`--color-text-muted`)};
201
+ }
202
+ .wlp-notice a {
203
+ color: inherit;
204
+ text-decoration: underline;
205
+ }
206
+
207
+ .wlp-secondary-row {
208
+ display: flex;
209
+ align-items: center;
210
+ gap: 10px;
211
+ margin-top: 14px;
212
+ font-size: 14px;
213
+ color: ${r(`--color-text-muted`)};
214
+ }
215
+ .wlp-secondary-row::before,
216
+ .wlp-secondary-row::after {
217
+ content: "";
218
+ flex: 1;
219
+ height: 1px;
220
+ background: ${r(`--color-border`)};
221
+ }
222
+ .wlp-secondary {
223
+ display: block;
224
+ margin-top: 10px;
225
+ text-align: center;
226
+ color: ${r(`--color-primary`)};
227
+ font-weight: 500;
228
+ }
229
+
230
+ .wlp-success-title {
231
+ margin: 0 32px 8px 0;
232
+ font-size: 20px;
233
+ font-weight: 600;
234
+ color: ${r(`--color-text`)};
235
+ }
236
+ .wlp-success-text {
237
+ margin: 0 0 16px;
238
+ color: ${r(`--color-text-muted`)};
239
+ }
240
+ .wlp-success-view .wlp-button {
241
+ width: 100%;
242
+ }
243
+
244
+ @keyframes wlp-fade {
245
+ from { opacity: 0; }
246
+ to { opacity: 1; }
247
+ }
248
+ @keyframes wlp-card-in {
249
+ from { opacity: 0; transform: scale(0.96); }
250
+ to { opacity: 1; transform: scale(1); }
251
+ }
252
+
253
+ @media (max-width: 575.98px) {
254
+ .wlp-card {
255
+ width: calc(100% - 32px);
256
+ max-width: none;
257
+ padding: 20px 16px;
258
+ }
259
+ .wlp-input {
260
+ font-size: 16px;
261
+ }
262
+ .wlp-button,
263
+ .wlp-close {
264
+ min-height: 44px;
265
+ }
266
+ .wlp-close {
267
+ min-width: 44px;
268
+ }
269
+ }
270
+
271
+ @media (prefers-reduced-motion: reduce) {
272
+ dialog[open]::backdrop,
273
+ dialog[open] .wlp-card {
274
+ animation: none;
275
+ }
276
+ }
277
+ `,a=[`name`,`email`,`phone`,`company`,`message`],o=[`name`,`email`],s={name:`Name`,email:`Email`,phone:`Phone number`,company:`Company`,message:`Message`},c={name:100,email:320,phone:40,company:150,message:1e3},l={name:`name`,email:`email`,phone:`tel`,company:`organization`},u=`input:not([type=hidden]), textarea, select, button, a[href]`,d=[`exit`,`delay`,`scroll`,`pages`],f=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,p=864e5,m=`comment_subject`,h=`__RequestVerificationToken`,g=`__FormStamp`,_=`__CaptchaToken`,v=`Something went wrong. Please try again or contact us directly.`,y=/* @__PURE__ */ `action.public-form.heading.description.fields.required.field-prefix.field-names.labels.max-lengths.submit-label.success-title.success-text.error-text.close-label.secondary-label.secondary-href.secondary-divider.triggers.delay-seconds.scroll-percent.pages-viewed.storage-key.dismiss-days.submitted-days.success-close-seconds.preview`.split(`.`),b=/* @__PURE__ */ new Set;function x(t,n){b.has(t)||(b.add(t),e(n))}var S=0;function C(e){return(e??``).split(/\s+/).map(e=>e.trim()).filter(Boolean)}function w(e){let t={};for(let n of(e??``).split(`;`)){let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function T(e){return String(e??``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var E=null;function D(e){E||(E=new CSSStyleSheet,E.replaceSync(i)),e.adoptedStyleSheets=[E]}function O(e,t){return e instanceof Error&&e.message?e.message:t}var k=class extends t{static get observedAttributes(){return y}constructor(){super(),S+=1,this._uid=`wlp-${S}`,this._rendered=!1,this._open=!1,this._opened=!1,this._posting=!1,this._stale=!1,this._armed=!1,this._session=null,this._returnTo=null,this._prevOverflow=``,this._delayTimer=null,this._closeTimer=null,this._onMouseLeave=e=>{!this._fine()||e.clientY>0||!this._engaged()||this.open(`exit`)},this._onVisibility=()=>{document.visibilityState===`hidden`&&!this._fine()&&this._engaged()&&this.open(`exit`)},this._onScroll=()=>this._trackScroll()}get isOpen(){return this._open}set isOpen(e){e?this.open(`manual`):this.close(`dismiss`)}connectedCallback(){this._rendered||this._render(),this._arm(),this.preview&&!this._open&&this.open(`manual`)}disconnectedCallback(){this._disarm(),this._open&&this._release()}attributeChangedCallback(){this._rendered&&(this._open?this._stale=!0:this._render())}open(e=`manual`){this._open||e!==`manual`&&(this._opened||this._blocked()||document.querySelector(`dialog[open], .modal.show`))||(this._rendered||this._render(),this._opened=!0,this._open=!0,clearTimeout(this._delayTimer),this._showForm(),this._modal=!this.preview,this._modal?(this._returnTo=document.activeElement,this._prevOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`,this._dialog().showModal(),this._dialog().querySelector(`[data-wlp-field] [data-wlp-input]`)?.focus()):this._dialog().setAttribute(`open`,``),this._remember(`shown`),this._emit(`wui-lead-popup-shown`,{trigger:e}))}close(e=`dismiss`){if(!this._open)return;clearTimeout(this._closeTimer),this._release();let t=this._returnTo;this._returnTo=null,t?.isConnected&&typeof t.focus==`function`&&t.focus(),this._stale&&this._render(),this._emit(`wui-lead-popup-closed`,{reason:e})}_release(){this._open=!1,this._dialog().close(),this._modal&&(document.documentElement.style.overflow=this._prevOverflow)}_root(){return this.shadowRoot??this.attachShadow({mode:`open`})}_dialog(){return this._root().querySelector(`dialog`)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_text(e,t=``){return this.getAttribute(e)||t}_number(e,t){let n=this.getAttribute(e);if(n===null||n.trim()===``)return t;let r=Number(n);return Number.isFinite(r)&&r>=0?r:t}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}_fieldKeys(){let e=C(this.getAttribute(`fields`)).filter(e=>a.includes(e)?!0:(x(`field:${e}`,`[@webority/ui-elements] <wui-lead-popup> has no field "${e}". It is ignored.`),!1));return e.length?e:o}_requiredKeys(){let e=this._fieldKeys();return C(this.getAttribute(`required`)).filter(t=>e.includes(t))}_label(e){return w(this.getAttribute(`labels`))[e]||s[e]}_postedName(e){return this._text(`field-prefix`)+(w(this.getAttribute(`field-names`))[e]||e)}_maxLength(e){let t=Number(w(this.getAttribute(`max-lengths`))[e]);return Number.isInteger(t)&&t>0?t:c[e]}_triggers(){if(this.preview)return[];let e=(this.getAttribute(`triggers`)??``).split(/\s+/).filter(e=>d.includes(e));return e.length?this.getAttribute(`storage-key`)?e:(x(`storage-key`,`[@webority/ui-elements] <wui-lead-popup> has triggers but no storage-key. The triggers are off.`),[]):[]}_render(){let e=this._root();D(e);let t=this._uid,n=this._fieldKeys(),r=new Set(this._requiredKeys()),i=this._text(`heading`),a=this._text(`description`),o=this._text(`secondary-label`),s=this._text(`secondary-href`),c=n.map(e=>this._fieldMarkup(e,r.has(e))).join(``),l=document.createElement(`template`);l.innerHTML=`
278
+ <dialog class="wlp-dialog" aria-labelledby="${t}-h"${a?` aria-describedby="${t}-d"`:``}>
279
+ <div class="wlp-card">
280
+ <button type="button" class="wlp-close" aria-label="${T(this._text(`close-label`,`Close`))}" data-wlp-close>&times;</button>
281
+ <div class="wlp-form-view">
282
+ <h2 class="wlp-heading" id="${t}-h">${T(i)}</h2>
283
+ ${a?`<p class="wlp-description" id="${t}-d">${T(a)}</p>`:``}
284
+ <form class="wlp-form" novalidate data-wlp-form>
285
+ ${c}
286
+ <p class="wlp-form-error" role="alert" hidden data-wlp-form-error></p>
287
+ <div class="wlp-actions">
288
+ <button type="submit" class="wlp-button" data-wlp-submit>${T(this._text(`submit-label`,`Send`))}</button>
289
+ </div>
290
+ <input type="text" name="${m}" class="wlp-honeypot" tabindex="-1" autocomplete="off" aria-hidden="true" data-wlp-honeypot>
291
+ <p class="wlp-notice" data-recaptcha-notice>This site is protected by reCAPTCHA and the Google <a href="https://policies.google.com/privacy" target="_blank" rel="noopener">Privacy Policy</a> and <a href="https://policies.google.com/terms" target="_blank" rel="noopener">Terms of Service</a> apply.</p>
292
+ </form>
293
+ ${o&&s?`<div class="wlp-secondary-row"><span>${T(this._text(`secondary-divider`,`or`))}</span></div><a class="wlp-secondary" href="${T(s)}" data-wlp-secondary>${T(o)}</a>`:``}
294
+ </div>
295
+ <div class="wlp-success-view" hidden>
296
+ <h2 class="wlp-success-title" role="status" tabindex="-1" data-wlp-success-title>${T(this._text(`success-title`,`Thank you`))}</h2>
297
+ ${this._text(`success-text`)?`<p class="wlp-success-text">${T(this._text(`success-text`))}</p>`:``}
298
+ <button type="button" class="wlp-button" data-wlp-done>${T(this._text(`close-label`,`Close`))}</button>
299
+ </div>
300
+ </div>
301
+ </dialog>`,e.replaceChildren(l.content),this._rendered=!0,this._stale=!1,this._wire()}_fieldMarkup(e,t){let n=`${this._uid}-f-${e}`,r=`${this._uid}-e-${e}`,i=this._label(e),a=T(this._postedName(e)),o=this._maxLength(e),s=t?`<span class="wlp-req" aria-hidden="true">*</span><span class="wlp-visually-hidden">required</span>`:``,c=`id="${n}" data-wlp-input="${e}" name="${a}" maxlength="${o}"${t?` aria-required="true"`:``}`,u=e===`message`?`<textarea class="wlp-input" rows="4" ${c}></textarea>`:`<input class="wlp-input" type="${e===`email`?`email`:e===`phone`?`tel`:`text`}" ${c}${l[e]?` autocomplete="${l[e]}"`:``}>`;return`
302
+ <div class="wlp-field" data-wlp-field="${e}">
303
+ <label class="wlp-label" for="${n}">${T(i)}${s}</label>
304
+ ${u}
305
+ <p class="wlp-error" id="${r}" hidden></p>
306
+ </div>`}_wire(){let e=this._dialog();e.addEventListener(`cancel`,e=>{e.preventDefault(),this.close(`escape`)}),e.addEventListener(`click`,t=>{t.target===e&&this.close(`backdrop`)}),e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`||!this._modal)return;let n=Array.from(e.querySelectorAll(u)).filter(e=>!e.disabled&&e.getClientRects().length>0);if(!n.length)return;let r=n.indexOf(this._root().activeElement);t.preventDefault(),n[r===-1?t.shiftKey?n.length-1:0:(r+(t.shiftKey?-1:1)+n.length)%n.length].focus()});for(let t of e.querySelectorAll(`[data-wlp-close]`))t.addEventListener(`click`,()=>this.close(`dismiss`));e.querySelector(`[data-wlp-done]`)?.addEventListener(`click`,()=>this.close(`submitted`)),e.querySelector(`[data-wlp-secondary]`)?.addEventListener(`click`,()=>this.close(`secondary`)),e.querySelector(`[data-wlp-form]`).addEventListener(`submit`,e=>this._onSubmit(e))}_showForm(){let e=this._root();e.querySelector(`.wlp-form-view`).hidden=!1,e.querySelector(`.wlp-success-view`).hidden=!0}_showSuccess(){let e=this._root();e.querySelector(`.wlp-form-view`).hidden=!0;let t=e.querySelector(`.wlp-success-view`);t.hidden=!1,e.querySelector(`[data-wlp-success-title]`).focus()}_setFieldError(e,t){let n=this._root(),r=n.querySelector(`[data-wlp-input="${e}"]`),i=n.querySelector(`#${this._uid}-e-${e}`);return i.textContent=t,i.hidden=!t,t?(r.setAttribute(`aria-invalid`,`true`),r.setAttribute(`aria-describedby`,i.id)):(r.removeAttribute(`aria-invalid`),r.removeAttribute(`aria-describedby`)),r}_validate(){let e=new Set(this._requiredKeys()),t=null,n={};for(let r of this._fieldKeys()){let i=this._root().querySelector(`[data-wlp-input="${r}"]`).value.trim();n[r]=i;let a=``;!i&&e.has(r)?a=`Enter your ${this._label(r).toLowerCase()}`:r===`email`&&i&&!f.test(i)&&(a=`Enter a valid email address`);let o=this._setFieldError(r,a);a&&!t&&(t=o)}return t?(t.focus(),null):n}_setBusy(e){this._posting=e;let t=this._root().querySelector(`[data-wlp-form]`);e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`),this._root().querySelector(`[data-wlp-submit]`).disabled=e}_fail(e,t){this._setBusy(!1);let n=this._root().querySelector(`[data-wlp-form-error]`);n.textContent=t,n.hidden=!t,this._emit(`wui-lead-popup-error`,{message:t,reason:e})}async _onSubmit(e){if(e.preventDefault(),this._posting)return;this._root().querySelector(`[data-wlp-form-error]`).hidden=!0;let t=this._validate();t&&!this.preview&&await this._post(t)}async _post(e){let t=globalThis.WeborityPublicForms;if(!t){x(`gate`,`[@webority/ui-elements] <wui-lead-popup> needs window.WeborityPublicForms. Load Webority.Security.Razor's public-form.js.`),this._fail(`gate`,this._text(`error-text`,v));return}let n=this._text(`error-text`,v),r=this._text(`public-form`);this._setBusy(!0);let i,a;try{i=await t.session(),a=await t.mintToken(r)}catch(e){this._fail(`gate`,O(e,n));return}let o=this._root(),s=new FormData;for(let t of this._fieldKeys())s.append(this._postedName(t),e[t]);s.set(h,i.token),s.set(g,i.formStamp),s.set(_,a),s.set(m,o.querySelector(`[data-wlp-honeypot]`).value),this._emit(`wui-lead-popup-before-submit`,{formData:s});let c;try{c=await fetch(this._text(`action`),{method:`POST`,body:s,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}})}catch{this._fail(`network`,n);return}if(!c.ok){let e=await c.json().catch(()=>null),t=typeof e?.detail==`string`?e.detail.trim():``;this._fail(`server`,t||n);return}let l=await c.json().catch(()=>null);this._succeed(e,l)}_succeed(e,t){this._setBusy(!1),this._remember(`submitted`),this._emit(`wui-lead-popup-submitted`,{values:e,response:t}),this._showSuccess();let n=this._number(`success-close-seconds`,5);n>0&&(this._closeTimer=setTimeout(()=>this.close(`submitted`),n*1e3))}_arm(){if(this._armed)return;this._armed=!0;let e=this._triggers();if(!e.length)return;this._session=this._loadSession();let t=location.pathname+location.search;if(this._session.pages.includes(t)||this._session.pages.push(t),this._saveSession(),e.includes(`exit`)&&(document.documentElement.addEventListener(`mouseleave`,this._onMouseLeave),document.addEventListener(`visibilitychange`,this._onVisibility)),e.includes(`delay`)){let e=Math.max(0,this._number(`delay-seconds`,30)*1e3-(Date.now()-this._session.start));this._delayTimer=setTimeout(()=>this.open(`delay`),e)}e.includes(`scroll`)&&(window.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackScroll()),e.includes(`pages`)&&this._session.pages.length>this._number(`pages-viewed`,2)&&this.open(`pages`)}_disarm(){this._armed=!1,clearTimeout(this._delayTimer),clearTimeout(this._closeTimer),document.documentElement.removeEventListener(`mouseleave`,this._onMouseLeave),document.removeEventListener(`visibilitychange`,this._onVisibility),window.removeEventListener(`scroll`,this._onScroll)}_trackScroll(){let e=document.documentElement.scrollHeight;if(this._session&&e>0){let t=(window.scrollY+window.innerHeight)/e*100;t>this._session.maxScroll&&(this._session.maxScroll=t,this._saveSession()),this._session.maxScroll>this._number(`scroll-percent`,50)&&this.open(`scroll`)}}_fine(){return typeof matchMedia!=`function`||matchMedia(`(pointer: fine)`).matches}_engaged(){let e=this._session;return e?Date.now()-e.start>this._number(`delay-seconds`,30)*1e3||e.maxScroll>this._number(`scroll-percent`,50)||e.pages.length>this._number(`pages-viewed`,2):!1}_sessionKey(){return`wui-lead-popup:${this.getAttribute(`storage-key`)}`}_loadSession(){let e={start:Date.now(),maxScroll:0,pages:[]};try{let e=sessionStorage.getItem(this._sessionKey());if(e){let t=JSON.parse(e);if(Number.isFinite(t.start)&&Number.isFinite(t.maxScroll)&&Array.isArray(t.pages))return t}}catch{return e}return e}_saveSession(){try{sessionStorage.setItem(this._sessionKey(),JSON.stringify(this._session))}catch{}}_readMemory(){let e=this.getAttribute(`storage-key`);if(!e)return null;try{let t=JSON.parse(localStorage.getItem(e)??`null`);if((t?.state===`shown`||t?.state===`submitted`)&&Number.isFinite(Date.parse(t.at)))return t}catch{return null}return null}_blocked(){let e=this._readMemory();if(!e)return!1;let t=e.state===`shown`?this._number(`dismiss-days`,30):this._number(`submitted-days`,365);return Date.now()-Date.parse(e.at)<t*p}_remember(e){let t=this.getAttribute(`storage-key`);if(t&&!this.preview)try{localStorage.setItem(t,JSON.stringify({state:e,at:(/* @__PURE__ */ new Date()).toISOString()}))}catch{}}};export{k as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{p as t}from"./formatters-7rx97Lnm.js";import{t as n}from"./iconGlyphs.g-CQcMoS6_.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(r);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(r)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._ui,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a],s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1)for(let e of[n[(a+1)%n.length],n[(a-1+n.length)%n.length]])new Image().src=e.src;s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=i,this._ui.zoomIn.disabled=this._zoom>=a;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):e.shiftKey||i!==r&&this._ui.root.contains(i)||(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`)){if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;n.moved?this._zoom===i&&this.step(m(r,a)):e.timeStamp-n.startTime>u||(n.onImage?e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp:this.close())}};export{v as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{f as t}from"./formatters-D1zbsEJJ.js";import{t as n}from"./iconGlyphs.g-DaOONrBK.js";var r=`a.wui-lightbox-item`,i=1,a=4,o=.5,s=2,c=50,l=6,u=300,d=300;function f(e){return Number.isFinite(e)?Math.min(a,Math.max(i,e)):i}function p(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function m(e,t){return Math.abs(e)<c||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function h(e){let t=String(e??``).split(/[?#]/)[0].split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}function g(e,t,n={}){let r=document.createElement(e);r.className=t;for(let[e,t]of Object.entries(n))r.setAttribute(e,t);return r}function _(e,t,r){let i=g(`button`,`u-action wui-lightbox-btn ${r}`,{type:`button`,"aria-label":t,title:t});return i.style.setProperty(`--wui-action-size`,`40px`),i.innerHTML=n(e,{size:20}),i}var v=class extends e{static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=i,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._lockedOverflow=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target?.closest?.(r);if(!t||!this.contains(t))return;let n=this._links().indexOf(t);n<0||(e.preventDefault(),this.open(n))}}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||`Image viewer`}set label(e){this.setAttribute(`label`,String(e??``))}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(r)]}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||h(t)}})}open(e=0){let t=this._items();return t.length?(this._ui||(this._returnTo=document.activeElement,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))),this._show(e,t),this._ui.close.focus(),!0):!1}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null,this._lockedOverflow!==null&&(document.documentElement.style.overflow=this._lockedOverflow,this._lockedOverflow=null))}_build(){let e=g(`div`,`wui-lightbox-overlay`,{role:`dialog`,"aria-modal":`true`,"aria-label":this.label,tabindex:`-1`}),t=g(`div`,`wui-lightbox-bar`),r=g(`span`,`wui-lightbox-count`,{"aria-live":`polite`}),i=g(`div`,`wui-lightbox-tools`),a=_(`zoom-out`,`Zoom out`,`wui-lightbox-zoom-out`),s=_(`zoom-in`,`Zoom in`,`wui-lightbox-zoom-in`),c=g(`a`,`u-action wui-lightbox-btn wui-lightbox-download`,{"aria-label":`Download`,title:`Download`});c.style.setProperty(`--wui-action-size`,`40px`),c.innerHTML=n(`download`,{size:20}),c.hidden=!this.download;let l=_(`x`,`Close`,`wui-lightbox-close`);i.append(a,s,c,l),t.append(r,i);let u=g(`div`,`wui-lightbox-stage`),d=_(`chevron-left`,`Previous image`,`wui-lightbox-nav wui-lightbox-prev`),f=_(`chevron-right`,`Next image`,`wui-lightbox-nav wui-lightbox-next`),p=g(`img`,`wui-lightbox-image`,{decoding:`async`,draggable:`false`,alt:``}),m=g(`p`,`wui-lightbox-status`,{role:`status`});u.append(p,m,d,f);let h=g(`p`,`wui-lightbox-caption`);e.append(t,u,h);let v={root:e,count:r,zoomOut:a,zoomIn:s,download:c,close:l,stage:u,prev:d,next:f,image:p,status:m,caption:h};this._ui=v,l.addEventListener(`click`,()=>this.close()),d.addEventListener(`click`,()=>this.step(-1)),f.addEventListener(`click`,()=>this.step(1)),a.addEventListener(`click`,()=>this._setZoom(this._zoom-o)),s.addEventListener(`click`,()=>this._setZoom(this._zoom+o)),e.addEventListener(`keydown`,e=>this._onKeyDown(e)),u.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),u.addEventListener(`pointermove`,e=>this._onPointerMove(e)),u.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),u.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),u.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),p.addEventListener(`load`,()=>{this._ui===v&&(m.textContent=``,u.removeAttribute(`aria-busy`),p.hidden=!1,this._applyTransform())}),p.addEventListener(`error`,()=>{this._ui===v&&(u.removeAttribute(`aria-busy`),p.hidden=!0,m.textContent=`This image can't be shown.`)}),this.append(e),this._lockedOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,n){let r=this._ui,a=Math.min(n.length-1,Math.max(0,Math.trunc(Number(e))||0)),o=n[a],s=a!==this._index||!r.image.getAttribute(`src`);if(this._index=a,this._zoom=i,this._pan={x:0,y:0},r.count.textContent=`${t(a+1,{decimals:0})} of ${t(n.length,{decimals:0})}`,r.caption.textContent=o.caption,r.caption.hidden=!o.caption,r.download.href=o.src,r.download.setAttribute(`download`,o.name),r.prev.hidden=r.next.hidden=n.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=o.alt||o.caption,r.image.src=o.src,this._applyTransform(),this._syncZoomButtons(),n.length>1)for(let e of[n[(a+1)%n.length],n[(a-1+n.length)%n.length]])new Image().src=e.src;s&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:a}}))}_syncZoomButtons(){this._ui.zoomOut.disabled=this._zoom<=i,this._ui.zoomIn.disabled=this._zoom>=a;let e=document.activeElement;(e===this._ui.zoomOut||e===this._ui.zoomIn)&&e.disabled&&this._ui.close.focus()}_setZoom(e){this._ui&&(this._zoom=f(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._ui;return p(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._ui;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>i)}_onKeyDown(e){if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.close();else if(e.key===`Tab`)this._trapTab(e);else if(e.key===`ArrowLeft`||e.key===`ArrowRight`)e.preventDefault(),this.step(e.key===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+o)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-o)):e.key===`0`&&(e.preventDefault(),this._setZoom(i))}_trapTab(e){let t=[...this._ui.root.querySelectorAll(`button, a[href]`)].filter(e=>!e.hidden&&!e.disabled);if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||!this._ui.root.contains(i))?(e.preventDefault(),r.focus()):e.shiftKey||i!==r&&this._ui.root.contains(i)||(e.preventDefault(),n.focus())}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){if(!e.target.closest(`.wui-lightbox-nav`)){if(this._ui.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let[e,t]=[...this._pointers.values()];this._gesture={kind:`pinch`,distance:Math.hypot(e.x-t.x,e.y-t.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===this._ui.image,moved:!1})}}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let[e,n]=[...this._pointers.values()];this._setZoom(t.zoom*Math.hypot(e.x-n.x,e.y-n.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>l&&(t.moved=!0),this._zoom>i&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._ui.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,a=e.clientY-n.startY;n.moved?this._zoom===i&&this.step(m(r,a)):e.timeStamp-n.startTime>u||(n.onImage?e.timeStamp-this._lastTap<d?(this._lastTap=-1/0,this._setZoom(this._zoom>i?i:s)):this._lastTap=e.timeStamp:this.close())}};export{v as t};
@@ -0,0 +1,4 @@
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";var t=/\[([^[\]\n]+)\](?!\()/g,n=/* @__PURE__ */ new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),r=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,i=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,a=new RegExp(t.source,`y`),o=e=>/[\p{L}\p{N}]/u.test(e);function s(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function c(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),c=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),l=n===`_`&&o(e.charAt(i+n.length));if(a&&!c&&!l&&!s(e,i))return i}return-1}function l(e,t){let s=t?.isCitation,u=[],d=``,f=()=>{d&&=(u.push({type:`text`,text:d}),``)},p=0;for(;p<e.length;){let m=e.charAt(p),h=e.charAt(p+1);if(m===`\\`&&n.has(h)){d+=h,p+=2;continue}if(m==="`"){let t=e.indexOf("`",p+1);if(t>p+1){f(),u.push({type:`code`,text:e.slice(p+1,t)}),p=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=c(e,p+2,g);if(n!==-1&&!(g===`__`&&o(e.charAt(p-1)))){f();let r=l(e.slice(p+2,n),t);g===`~~`?u.push({type:`strike`,children:r}):u.push({type:`strong`,children:r}),p=n+2;continue}d+=g,p+=2}else{if(m===`*`||m===`_`){let n=c(e,p+1,m);if(n!==-1&&!(m===`_`&&o(e.charAt(p-1)))){f(),u.push({type:`em`,children:l(e.slice(p+1,n),t)}),p=n+1;continue}}if(m===`[`){r.lastIndex=p;let t=r.exec(e);if(t){f(),u.push({type:`link`,href:t[2],children:l(t[1])}),p+=t[0].length;continue}if(s){a.lastIndex=p;let t=a.exec(e);if(t&&s(t[1])){f(),u.push({type:`citation`,text:t[1]}),p+=t[0].length;continue}}}if(m===`!`){i.lastIndex=p;let t=i.exec(e);if(t){f(),u.push({type:`image`,children:l(t[1])}),p+=t[0].length;continue}}d+=m,p+=1}}return f(),u.map((e,t)=>({...e,key:t}))}var u=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,d=/^https?:/i,f=/^(mailto|tel):/i,p=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/;function m(e,t,n,r){if(n&&u.test(e)){let t=n(e);if(t!=null)return{kind:`app`,target:t}}return t===`app`?null:p.test(e)?{kind:`page`,href:e}:d.test(e)?{kind:r&&h(e,r)?`page`:`web`,href:e}:f.test(e)?{kind:`contact`,href:e}:null}function h(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function g(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var _=/^\s*```/,v=/^\s*```\s*(\S*)/,y=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,b=/^\s*([-*_])(\s*\1){2,}\s*$/,x=/^(\s*)[-*+]\s+(.*)$/,S=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,C=/^\s*>\s?(.*)$/,w=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,T=e=>e.includes(`|`);function E(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function D(e,t){return T(e[t])&&t+1<e.length&&e[t+1].includes(`|`)&&w.test(e[t+1])}function O(e,t){let n=e[t];return _.test(n)||C.test(n)||x.test(n)||S.test(n)||y.test(n)||b.test(n)||D(e,t)}function k(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function A(e){let t=S.exec(e);if(t)return{text:t[3],depth:k(t[1]),ordered:!0,number:Number(t[2])};let n=x.exec(e);return n?{text:n[2],depth:k(n[1]),ordered:!1,number:0}:null}function j(e){let t=(e??``).replace(/\r\n?/g,`
2
+ `).split(`
3
+ `),n=[],r=0;for(;r<t.length;){let e=t[r];if(!e.trim()){r+=1;continue}if(_.test(e)){let i=v.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length&&!_.test(t[r]);)a.push(t[r]),r+=1;r+=1,n.push({type:`code`,text:a.join(`
4
+ `),language:i});continue}if(D(t,r)){let i=E(e),a=[];for(r+=2;r<t.length&&t[r].trim()&&T(t[r]);)a.push(E(t[r])),r+=1;n.push({type:`table`,header:i,rows:a});continue}if(b.test(e)){n.push({type:`rule`}),r+=1;continue}let i=y.exec(e);if(i){n.push({type:`heading`,level:i[1].length,text:i[2]}),r+=1;continue}if(C.test(e)){let e=[];for(;r<t.length;){let n=C.exec(t[r]);if(!n)break;e.push(n[1]),r+=1}n.push({type:`quote`,lines:e});continue}let a=A(e);if(a){let e=[];for(;r<t.length&&t[r].trim();){let n=A(t[r]);if(n){if(n.depth===0&&n.ordered!==a.ordered)break;e.push(n)}else if(O(t,r))break;else e[e.length-1].text+=` ${t[r].trim()}`;r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length&&t[r].trim()&&!O(t,r);)o.push(t[r]),r+=1;n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var M=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`];function N(e,t,n,r,i=null){let a=P(e.ownerDocument,n,r).map((e,n)=>{let r=t[n]?.sig===e.sig?t[n].nodes:null;return{sig:e.sig,nodes:r??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.remove();let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function P(e,t,n){let r={doc:e,links:n.links===`app`?`app`:`web`,headings:n.headings===`text`?`text`:`outline`,resolveLink:n.resolveLink,isCitation:n.isCitation},i=n.resolverGeneration??0;return j(t).map(e=>({sig:`${JSON.stringify(e)}|${r.links}|${r.headings}|${i}`,build:()=>L(r,e)}))}var F=class extends e{static get observedAttributes(){return[`links`,`headings`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e.tagName===`PRE`&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=N(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function I(e,t,n=[]){let r=e.createElement(t);return r.append(...n),r}function L(e,t){switch(t.type){case`paragraph`:return[I(e.doc,`p`,R(e,t.lines))];case`heading`:return[z(e,t)];case`list`:return B(e,t.items);case`table`:return[H(e,t)];case`code`:return[U(e.doc,t)];case`quote`:return[I(e.doc,`blockquote`,R(e,t.lines))];case`rule`:return[e.doc.createElement(`hr`)];default:return[]}}function R(e,t){let n=[];return t.forEach((t,r)=>{r>0&&n.push(e.doc.createElement(`br`)),n.push(...W(e,t))}),n}function z(e,t){let n=W(e,t.text);if(e.headings===`text`){let t=I(e.doc,`p`,n);return t.className=`fw-semibold`,t}return I(e.doc,`h2`,n)}function B(e,t){let n=[];for(let r=0;r<t.length;){let i=V(e,t,r);n.push(i.list),r=i.next}return n}function V(e,t,n){let{depth:r,ordered:i,number:a}=t[n],o=e.doc.createElement(i?`ol`:`ul`);i&&a!==1&&o.setAttribute(`start`,String(a));let s=null,c=n;for(;c<t.length&&t[c].depth>=r;)if(t[c].depth===r)s=I(e.doc,`li`,W(e,t[c].text)),o.append(s),c+=1;else{let n=V(e,t,c);s.append(n.list),c=n.next}return{list:o,next:c}}function H(e,t){let n=t.header.map(t=>{let n=I(e.doc,`th`,W(e,t));return n.setAttribute(`scope`,`col`),n}),r=t.rows.map(n=>I(e.doc,`tr`,t.header.map((t,r)=>I(e.doc,`td`,W(e,n[r]??``))))),i=I(e.doc,`table`,[I(e.doc,`thead`,[I(e.doc,`tr`,n)]),I(e.doc,`tbody`,r)]);i.className=`table`;let a=I(e.doc,`div`,[i]);return a.className=`table-responsive`,a}function U(e,t){let n=I(e,`pre`,[I(e,`code`,[e.createTextNode(t.text)])]);n.className=`wui-code-source`;let r=I(e,`wui-code-block`,[n]);return r.className=`wui-code-block`,r.setAttribute(`language`,M.includes(t.language)?t.language:`text`),r}function W(e,t){return G(e,l(t,{isCitation:e.isCitation}))}function G(e,t){return t.flatMap(t=>K(e,t))}function K(e,t){let{doc:n}=e;switch(t.type){case`code`:return[I(n,`code`,[n.createTextNode(t.text)])];case`strong`:return[I(n,`strong`,G(e,t.children))];case`em`:return[I(n,`em`,G(e,t.children))];case`strike`:return[I(n,`del`,G(e,t.children))];case`image`:return[n.createTextNode(`[`),...G(e,t.children),n.createTextNode(`]`)];case`link`:return q(e,t);case`citation`:return[J(n,t.text)];default:return[n.createTextNode(t.text)]}}function q(e,t){let n=G(e,t.children),r=m(t.href,e.links,e.resolveLink,e.doc.location?.origin);if(!r)return n;if(r.kind===`app`){let t=g(r.target);return t?[Y(e.doc,t,n,!1)]:n}return[Y(e.doc,r.href,n,r.kind===`web`)]}function J(e,t){let n=e.createElement(`span`);n.className=`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,n.setAttribute(`data-wui`,`AppChip`);let r=e.createElement(`button`);r.type=`button`,r.className=`chip-body`,r.setAttribute(`aria-label`,t),r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:t}}))});let i=e.createElement(`span`);return i.className=`chip-label`,i.textContent=t,r.append(i),n.append(r),n}function Y(e,t,n,r){let i=I(e,`span`,n);i.className=`wui-link__label`;let a=I(e,`a`,[i]);return a.className=`wui-link wui-link--static`,a.setAttribute(`data-wui`,`AppLink`),a.setAttribute(`href`,t),r&&(a.setAttribute(`target`,`_blank`),a.setAttribute(`rel`,`noopener noreferrer`)),a}export{F as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{t as r}from"./elementBase-DV9IZZCu.js";import{n as i,r as a,t as o}from"./fieldState-D-zQcXUS.js";import{f as s}from"./formatters-D1zbsEJJ.js";import{n as c}from"./listboxKeyNav-DMIvs9d6.js";import{l}from"./wuiHttp-DgnM7K2Q.js";var u=/^[A-Za-z0-9_.:-]{1,64}$/,d=/@(\\+)\[|@\[([^[\]\n]{1,100})\]\(([A-Za-z0-9_.:-]{1,64})\)/g,f=/@(\\*)\[/g;function p(e){return String(e??``).replace(/[[\]\r\n]+/g,` `).replace(/\s+/g,` `).trim().slice(0,100)}var m=e=>e.replace(f,(e,t)=>`@\\${t}[`);function h(e){let t=String(e??``),n=[],r=e=>{if(!e)return;let t=n[n.length-1];t&&`text`in t?t.text+=e:n.push({text:e})},i=0;for(let e of t.matchAll(d))r(t.slice(i,e.index)),e[1]===void 0?n.push({id:e[3],label:e[2]}):r(`@${e[1].slice(1)}[`),i=e.index+e[0].length;return r(t.slice(i)),n}function g(e){let t=``,n=[];for(let r of h(e)){if(`text`in r){t+=r.text;continue}let e=`@${r.label}`;n.push({start:t.length,end:t.length+e.length,id:r.id,label:r.label}),t+=e}return{text:t,mentions:n}}function _(e,t=[]){let n=String(e??``),r=[...t].sort((e,t)=>e.start-t.start),i=``,a=0;for(let e of r)e.start<a||n.slice(e.start,e.end)!==`@${e.label}`||!u.test(e.id)||(i+=m(n.slice(a,e.start)),i+=`@[${e.label}](${e.id})`,a=e.end);return i+m(n.slice(a))}function v(e){let t=[];for(let n of h(e))`id`in n&&!t.includes(n.id)&&t.push(n.id);return t}var y=8,b=40,x=Object.freeze({listName:`People`,searching:`Searching…`,noMatch:`No one matches`,found:e=>`${e===1?`1 person`:`${s(e,{decimals:0})} people`}. Up and down to choose, Enter to mention.`,mentioned:e=>`Mentioned ${e}.`}),S=`[data-wui-control]`,C=`[data-wui-field]`,w=`[data-wui-menu]`,T=`[data-wui-live]`,E=0,D=e=>e&&u.test(String(e.value??``))&&p(e.label)!==``;function O(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`input-sm`,n===`sm`),t.classList.toggle(`input-lg`,n===`lg`)}function k(e,t){t.readOnly=i(e)||e.hasAttribute(`loading`)}function A(e){let t=e.ownerDocument;e.id||=`wui-mention-${++E}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),k(e,n),O(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??x.listName),o.setAttribute(`data-wui-menu`,``),o.hidden=!0,e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var j=class extends r{static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._query=null,this._results=[],this._active=-1,this._timer=null,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this),this._reposition=()=>{this._isOpen()&&this._position()}}connectedCallback(){for(let e of[`people`,`loading`,`value`])if(Object.hasOwn(this,e)){let t=this[e];delete this[e],this[e]=t}if(this._wired)return;this._wired=!0,this.querySelector(S)||A(this);let e=this._control(),t=this.querySelector(C)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._menu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target.closest?.(`.wui-mention-option`);t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(k(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(k(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?O(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return _(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(D):[],(this._isOpen()||this._query!==null)&&this._refresh()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(S)}_menu(){return this.querySelector(w)}_load(e){let{text:t,mentions:n}=g(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(C);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._control(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e?.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||o(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,r=n.lastIndexOf(`@`,t-1);if(r<0||r>0&&!/[\s([{"'“‘]/.test(n[r-1]))return null;let i=n.slice(r+1,t);return i.length>40||/[\n@]/.test(i)||/^\s/.test(i)||/\s{2}/.test(i)||this._mentions.some(e=>r>=e.start&&r<e.end)?null:{start:r,end:t,text:i}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>p(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await l(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this.loading=!1;return}let o=this.ownerDocument.createElement(`template`);o.innerHTML=a.html,this._peopleProp=[...o.content.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:e.textContent.trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(D),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return!(!e||e.hidden)}_renderMenu(){let t=this._menu(),n=this._control();if(!t||!n||!this._query)return;this._syncState();let r=this.ownerDocument;if(t.replaceChildren(),this._results.forEach((e,n)=>{let i=r.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${t.id}-${n}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(n),e.src){let t=r.createElement(`img`);t.className=`wui-mention-option-photo`,t.src=e.src,t.alt=``,i.appendChild(t)}let a=r.createElement(`span`);a.className=`wui-mention-option-text`;let o=r.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=p(e.label),a.appendChild(o),e.description){let t=r.createElement(`span`);t.className=`wui-mention-option-description`,t.textContent=String(e.description),a.appendChild(t)}i.appendChild(a),t.appendChild(i)}),!this._results.length){let e=r.createElement(`div`);e.className=`wui-mention-empty`,e.textContent=this.loading?x.searching:`${x.noMatch} “${this._query.text}”`,t.appendChild(e)}let i=this._isOpen();t.hidden=!1,i||e(this,this._reposition),this._position(),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?x.found(this._results.length):`${x.noMatch}.`)}_syncState(){let e=this._control();e&&a(this,e)}_position(){n(this._control(),this._menu())}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();e&&!e.hidden&&(e.hidden=!0,e.replaceChildren()),this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`),t(this)}_setActive(e,{reveal:t=!0}={}){let n=this._menu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);c(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._control().setAttribute(`aria-activedescendant`,i.id)):this._control().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._control();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target.closest?.(`.wui-mention-option`);t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=p(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(x.mentioned(t))}_replace(e,t,n,r){let i=this._control(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(T);t&&(t.textContent=``,t.textContent=e)}};export{u as a,_ as c,j as i,v as l,y as n,p as o,x as r,g as s,b as t,h as u};
@@ -0,0 +1,25 @@
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,r as i,t as a}from"./focusOrigin-0sYG-5El.js";import{n as o}from"./devWarn-DXdRWZs3.js";import{t as s}from"./elementBase-DV9IZZCu.js";import{n as c,r as l,t as u}from"./fieldState-D-zQcXUS.js";import{n as d}from"./formMirror-BMQTenSi.js";import{t as f}from"./iconGlyphs.g-DaOONrBK.js";import{n as p,t as m}from"./listboxKeyNav-DMIvs9d6.js";import{a as h,i as g,n as _,r as v,t as y}from"./optionLabel-BkmbyLNL.js";import{i as b,t as x}from"./tokenCommit-BKckxgtg.js";var S=class extends s{static formAssociated=!0;_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||`Select`}static get observedAttributes(){return[`placeholder`,`search-placeholder`,`searchable`,`disabled`,`readonly`,`loading`,`icon`,`size`,`collapse-chips`,`aria-label`,`aria-invalid`,`allow-custom`,`custom-pattern`,`custom-invalid-message`]}constructor(){super(),this._values=[],this._optionsProp=null,this._active=-1,this._typeahead=``,this._typeaheadTimer=null,this._customError=``;try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){if(this._rendered)this._bindGlobal?.();else{if(!this._valuesInit&&!this._optionsProp&&!this._values.length){let e=this.getAttribute(`value`);if(e!=null&&e!==``)this._values=e.split(`,`).map(e=>e.trim()).filter(Boolean);else{let e=[...this.querySelectorAll(`:scope > wui-option[selected]`)].map(e=>e.getAttribute(`value`)??e.textContent.trim());e.length&&(this._values=e.map(String))}}this._valuesInit=!0,this._defaultCaptured||=(this._defaultValues=this._values.slice(),!0),this.render()}}formResetCallback(){this.values=(this._defaultValues||[]).slice();let e=this.querySelector(`[data-input]`);e&&(e.value=``),this._setCustomError(``)}attributeChangedCallback(e){e===`aria-invalid`?this._syncInvalid():e!==`custom-pattern`&&e!==`custom-invalid-message`&&this._rendered&&this.render()}_syncInvalid(){let e=this.querySelector(`.search-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._customError?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}get values(){return this._values.slice()}set values(e){this._values=Array.isArray(e)?e.map(String):[],d(this,this._values),this._rendered&&(this._renderControl(),this._renderOptions(this._query()))}set options(e){this._optionsProp=Array.isArray(e)?e:null,this._rendered&&this._allowCustom?(this._renderControl(),this._renderOptions(this._query())):this.isConnected&&this.render()}get options(){return this._readOptions()}get validateCustom(){return this._validateCustom??null}set validateCustom(e){this._validateCustom=typeof e==`function`?e:null}get _allowCustom(){return this.hasAttribute(`allow-custom`)}_query(){let e=this.querySelector(this._allowCustom?`[data-input]`:`.search-select-input`);return e?e.value:``}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t={value:e.getAttribute(`value`)??e.textContent.trim(),label:e.innerHTML,icon:e.getAttribute(`icon`)||void 0,[y]:!0,selected:e.hasAttribute(`selected`)};for(let[n,r]of w){let i=e.getAttribute(n);i&&(t[r]=i)}return e.hasAttribute(`disabled`)&&(t.disabled=!0),t}))}_readOptions(){return this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_labelFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?g(t):h(e)}_labelHtmlFor(e){let t=this._readOptions().find(t=>String(t.value)===String(e));return t?v(t):_(e)}render(){this._snapshotDeclared();let e=this._allowCustom,t=this.hasAttribute(`searchable`)&&!e,n=this.getAttribute(`search-placeholder`)||`Search…`,r=this.getAttribute(`icon`),i=this.getAttribute(`size`),a=i===`sm`?` search-select-sm`:i===`lg`?` search-select-lg`:``;d(this,this._values),this.id||=`wui-multiselect-${Math.random().toString(36).slice(2,9)}`;let o=`${this.id}-listbox`;this._listboxId=o;let s=this.hasAttribute(`disabled`),c=u(this);if(e){let e=`${this.id}-custom-error`;this.innerHTML=`
2
+ <div class="search-select${a}">
3
+ <div class="input search-select-control search-select-multi"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${s?` aria-disabled="true"`:``}>
4
+ ${r?f(r,{className:`search-select-icon`}):``}
5
+ <div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${k(o)}" aria-label="${k(this._accessibleName())}" aria-describedby="${k(e)}" autocomplete="off"${s?` disabled`:c?` readonly`:``} /></div>
6
+ ${f(`chevron-down`,{className:`search-select-caret`})}
7
+ </div>
8
+ <div class="search-select-menu search-select-menu-fixed" hidden>
9
+ <div class="search-select-options" role="listbox" id="${k(o)}" aria-multiselectable="true" tabindex="-1"></div>
10
+ </div>
11
+ </div>
12
+ <div class="field-error wui-ms-custom-error" id="${k(e)}" aria-live="polite" hidden></div>`}else this.innerHTML=`
13
+ <div class="search-select${a}">
14
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${k(o)}" aria-label="${k(this._accessibleName())}"${this.hasAttribute(`aria-invalid`)?` aria-invalid="true"`:``}${s?` aria-disabled="true"`:` tabindex="0"`}>
15
+ ${r?f(r,{className:`search-select-icon`}):``}
16
+ <div class="ms-chips" data-chips></div>
17
+ ${f(`chevron-down`,{className:`search-select-caret`})}
18
+ </div>
19
+ <div class="search-select-menu search-select-menu-fixed" hidden>
20
+ ${t?`<div class="search-select-search">${f(`search`)}<input class="search-select-input" placeholder="${k(n)}" aria-label="${k(n)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${f(`x`)}</button></div>`:``}
21
+ <div class="search-select-options" role="listbox" id="${k(o)}" aria-multiselectable="true" tabindex="-1"></div>
22
+ <div class="search-select-empty" hidden>No matches</div>
23
+ </div>
24
+ </div>`;this._rendered=!0,this._customError=``,d(this,this._values),this._renderControl(),this._renderOptions(),this._wire(),l(this,this.querySelector(`.search-select-control`))}_renderControl(){let e=this.querySelector(`[data-chips]`);if(!e)return;let t=this.getAttribute(`placeholder`)||`Select…`,n=this._allowCustom?e.querySelector(`[data-input]`):null,r=!c(this)&&!this.hasAttribute(`loading`),i=this._values.map(e=>`<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span>${r?`<button type="button" class="chip-remove" data-remove="${k(e)}" aria-label="Remove ${k(this._labelFor(e))}">${f(`x`)}</button>`:``}</span>`).join(``);if(n){for(let t of[...e.querySelectorAll(`:scope > .chip`)])t.remove();n.insertAdjacentHTML(`beforebegin`,i),n.placeholder=this._values.length?``:t,this._collapseChips()}else this._values.length?(e.innerHTML=i,this._collapseChips()):e.innerHTML=`<span class="search-select-placeholder">${_(t)}</span>`}_collapseChips(){let e=this.querySelector(`[data-chips]`);if(!e||!this.hasAttribute(`collapse-chips`)||!this._values.length)return;e.querySelector(`.chip-more`)?.remove();let t=[...e.querySelectorAll(`:scope > .chip:not(.chip-more)`)];for(let e of t)e.style.display=``;if(!t.length)return;let n=e.clientWidth,r=e=>e.offsetLeft+e.offsetWidth;if(r(t[t.length-1])<=n)return;let i=document.createElement(`span`);i.className=`chip chip-sm chip-more`,i.textContent=`+${t.length}`,t[t.length-1].after(i);let a=i.offsetWidth+6,o=0;for(let e of t)if(r(e)<=n-a)o+=1;else break;o<1&&(o=1);for(let e=o;e<t.length;e+=1)t[e].style.display=`none`;i.textContent=`+${t.length-o}`}_matches(e,t){return g(e).toLowerCase().includes(t)||String(e.description??``).toLowerCase().includes(t)}_optionNamed(e){let t=e.trim().toLowerCase();return this._readOptions().find(e=>String(e.value??``).toLowerCase()===t||g(e).trim().toLowerCase()===t)}_renderOptions(e){let t=this.querySelector(`.search-select-options`),n=this.querySelector(`.search-select-empty`);if(!t)return;let r=(e||``).trim(),i=r.toLowerCase(),a=this._readOptions();i&&(a=a.filter(e=>this._matches(e,i)));let o=this._listboxId||`${this.id||`wui-multiselect`}-listbox`,s=this._allowCustom&&r&&!this._optionNamed(r),c=a.map((e,t)=>{let n=this._values.includes(String(e.value)),r=`${o}-opt-${t}`;return T(e)?E(e,r,n):`<button type="button" role="option" id="${k(r)}" class="search-select-option${n?` selected`:``}" data-value="${k(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${v(e)}</span><span class="ms-check">${f(`check`)}</span></button>`});s&&c.push(`<button type="button" role="option" id="${k(`${o}-opt-${a.length}`)}" class="search-select-option search-select-option-custom" data-value="${k(r)}" data-custom="true" aria-selected="false">Add “${_(r)}”</button>`),t.innerHTML=c.join(``),n&&(n.hidden=a.length>0),this._active=-1,this._combobox()?.removeAttribute(`aria-activedescendant`),this._allowCustom&&this._syncCustomMenu?.(),this._reanchor?.()}_combobox(){return this._allowCustom?this.querySelector(`[data-input]`):this.querySelector(`.search-select-control`)}_setCustomError(e){this._customError=e||``;let t=this.querySelector(`.wui-ms-custom-error`),n=this.querySelector(`[data-input]`);t&&(t.textContent=this._customError,t.hidden=!this._customError),n&&(this._customError?n.setAttribute(`aria-invalid`,`true`):n.removeAttribute(`aria-invalid`)),this._syncInvalid()}_customRefusal(e){let t=this.getAttribute(`custom-invalid-message`)||`Enter a valid value.`,n=this.getAttribute(`custom-pattern`);if(n){let r=O(n);if(r&&!r.test(e))return t}let r=this._validateCustom;if(r){let n=r(e);return n===!0?``:typeof n==`string`&&n?n:t}return``}_commitTyped(e){let t=e.trim().replace(/,+$/,``).trim();if(!t)return``;let n=this._optionNamed(t),r;if(n){if(n.disabled)return n.disabledHint||this.getAttribute(`custom-invalid-message`)||`That option is not available.`;r=String(n.value)}else{let e=this._customRefusal(t);if(e)return e;r=t}let i=r.toLowerCase();return this._values.some(e=>e.toLowerCase()===i)||(this._values=[...this._values,r]),``}_wire(){this._teardown();let i=this.querySelector(`.search-select-control`),o=this.querySelector(`.search-select-menu`),s=this.querySelector(`.search-select-input`),c=this.querySelector(`.search-select-clear`),l=this.querySelector(`.search-select-options`),f=this._allowCustom,h=f?this.querySelector(`[data-input]`):null,g=h||i;if(!i||!o)return;let _=()=>u(this),v=()=>n(i,o,{matchWidth:!0}),y=()=>[...this.querySelectorAll(`.search-select-option`)],S=()=>y().filter(e=>!e.hidden),w=(e,{reveal:t=!0}={})=>{let n=S();this._active=e,p(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),g.setAttribute(`aria-activedescendant`,n[e].id)):g.removeAttribute(`aria-activedescendant`)},T=!1,E=()=>f?T:!o.hidden,D=()=>{let e=T&&y().length>0,t=o.hidden;o.hidden=!e,g.setAttribute(`aria-expanded`,String(e)),i.classList.toggle(`open`,e),e&&t&&v()};this._syncCustomMenu=f?D:null;let O=()=>{E()&&v()},k=()=>{_()||(e(this,O),f?(T=!0,D()):(o.hidden=!1,i.setAttribute(`aria-expanded`,`true`),i.classList.add(`open`),v(),s&&(s.value=``,this._renderOptions(``),s.focus())))},A=()=>{let e=f?T:i.getAttribute(`aria-expanded`)===`true`;f?(T=!1,D()):(o.hidden=!0,i.setAttribute(`aria-expanded`,`false`),i.classList.remove(`open`)),w(-1),clearTimeout(this._typeaheadTimer),this._typeaheadTimer=null,this._typeahead=``,t(this),e&&this.dispatchEvent(new Event(`wui-multiselect:close`,{bubbles:!0}))},j=()=>{d(this,this._values),this.dispatchEvent(new Event(`change`,{bubbles:!0}))},M=e=>{let t=String(e);if(this._values.includes(t))this._values=this._values.filter(e=>e!==t);else if(f&&this._values.some(e=>e.toLowerCase()===t.toLowerCase()))return;else this._values=[...this._values,t];this._renderControl(),this._renderOptions(this._query()),j()},N=e=>{this._values=this._values.filter(t=>t!==String(e)),this._renderControl(),this._renderOptions(this._query()),j()},P=(e,{quiet:t=!1}={})=>{let n=this._values.length,r=x(e,C)?b(e,C):[e],i=[],a=``;for(let e of r){let t=this._commitTyped(e);t&&(i.push(e.trim()),a||=t)}t&&i.length||(h.value=i.join(`, `),this._setCustomError(a),this._values.length!==n&&(this._renderControl(),j()),this._renderOptions(h.value))},F=e=>{e&&e.getAttribute(`aria-disabled`)!==`true`&&(e.dataset.custom===`true`?P(e.dataset.value):(M(e.dataset.value),h?.value&&(h.value=``,this._setCustomError(``),this._renderOptions(``))))};i.addEventListener(`click`,e=>{if(_())return;let t=e.target.closest(`[data-remove]`);if(t)e.stopPropagation(),N(t.dataset.remove),h?.focus();else if(h){let t=E();e.target!==h&&h.focus(),e.target===h||!t?k():A()}else E()?A():k()}),l.addEventListener(`click`,e=>{let t=e.target.closest(`.search-select-option`);t&&(F(t),(h||s)?.focus())}),l.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.search-select-option`);t&&!t.classList.contains(`is-active`)&&w(S().indexOf(t),{reveal:!1})}),l.addEventListener(`mouseleave`,()=>w(-1)),l.addEventListener(`error`,e=>{e.target?.classList?.contains(`avatar-img`)&&e.target.remove()},!0),s?.addEventListener(`input`,()=>{this._renderOptions(s.value),c&&(c.hidden=!s.value),w(-1)}),this._navHandler=m({getVisibleOptions:S,getActive:()=>this._active,setActive:e=>w(e),onEnter:e=>{e?F(e):h?.value.trim()&&P(h.value)},onEscape:()=>{this._navHandler.clearTypeahead(),A(),h||i.focus()}});let I=e=>{if(_())return;let t=h||s;e.key===`Backspace`&&!t?.value&&this._values.length?N(this._values[this._values.length-1]):(e.key===`Escape`&&E()&&(e.preventDefault(),e.stopPropagation()),this._navHandler.handler(e))};if(s?.addEventListener(`keydown`,I),c?.addEventListener(`click`,()=>{s.value=``,this._renderOptions(``),c.hidden=!0,s.focus()}),h){let e=e=>{e.target!==h&&e.preventDefault()};l.addEventListener(`mousedown`,e),i.addEventListener(`mousedown`,e),r(),h.addEventListener(`focus`,()=>{a()&&k()}),h.addEventListener(`input`,()=>{this._customError&&this._setCustomError(``),this._renderOptions(h.value),k()}),h.addEventListener(`keydown`,e=>{if(!_()){if(e.key===`,`&&h.value.trim())e.preventDefault(),P(h.value);else if(e.key===`Enter`){if(this._active<0&&!h.value.trim())return;this._navHandler.handler(e)}else e.key!==`ArrowDown`&&e.key!==`ArrowUp`||E()||k(),I(e)}}),h.addEventListener(`paste`,e=>{if(_())return;let t=e.clipboardData?.getData(`text/plain`)??``;x(t,C)&&(e.preventDefault(),P(`${h.value}${t}`))}),h.addEventListener(`blur`,e=>{e.relatedTarget&&this.contains(e.relatedTarget)||(h.value.trim()&&P(h.value,{quiet:!0}),A())})}else i.addEventListener(`keydown`,e=>{E()?I(e):_()||(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),k())});this._bindGlobal=()=>{this._teardown(),!this._ro&&typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this._collapseChips()),this._ro.observe(this)),this._onDocClick=e=>{E()&&!this.contains(e.target)&&A()},document.addEventListener(`click`,this._onDocClick),E()&&e(this,O)},this._bindGlobal()}_teardown(){this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this),this._navHandler?.teardown()}disconnectedCallback(){this._teardown(),this._ro?.disconnect(),this._ro=null}},C=[`,`,`;`,`
25
+ `,` `],w=[[`description`,`description`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],T=e=>!!(e.description||e.avatar||e.initials||e.disabled||e.disabledHint),E=(e,t,n)=>{let r=!!e.disabled,a=e.description?`<span class="wui-opt-desc">${_(e.description)}</span>`:``,o=e.disabledHint&&r?`<span class="wui-opt-hint">${_(e.disabledHint)}</span>`:``;return`<button type="button" role="option" id="${k(t)}" class="search-select-option wui-opt-rich${n?` selected`:``}" data-value="${k(e.value)}" aria-selected="${n}"${r?` aria-disabled="true"`:``}><span class="ms-opt-label"><span class="wui-opt-name">${v(e)}</span>${a}</span>${o}${i(e)}<span class="ms-check">${f(`check`)}</span></button>`},D=/* @__PURE__ */ new Map,O=e=>{if(D.has(e))return D.get(e);let t=null;try{t=RegExp(`^(?:${e})$`,`u`)}catch{o(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`)}return D.set(e,t),t},k=e=>String(e??``).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{S as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t,i as n,n as r,s as i}from"./notificationDays-CZNthz7L.js";import{c as a}from"./wuiHttp-CYxlXwsy.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=`.app-tabs`,h=`.wui-notification-center-tabs [role='tablist']`,g=`.wui-notification-center-tabs [role='tab']`,_=`.wui-notification-center-empty`,v=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen(),this.isOpen&&this._layoutTabs()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this._layoutTabs(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f}):not([data-archived="true"])`).length}_click(e){let t=e.target.closest?.(g);if(t&&this.contains(t)){if(this.hasAttribute(`controlled`))return;this._pickTab(t);return}let n=e.target.closest?.(`${o}, ${u}, ${d}`);n&&this.contains(n)&&(n.matches(o)?this.toggle():this.hasAttribute(`controlled`)||(n.matches(u)?this._markAll():this._markItem(n)))}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target)||e.target.closest(m))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)].filter(e=>!e.closest(`[hidden]`));if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(t(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(Boolean),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let i=await a(n,{method:`POST`,body:e});if(this._setBusy(!1),!i.ok){if(i.kind===`session`||i.kind===`aborted`)return;let e=i.message||r.failed[i.kind]||r.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:i.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(r.allRead),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(h);if(t){for(let n of t.querySelectorAll(g)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of this.querySelectorAll(h)){let t=e.querySelector(`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of this.querySelectorAll(d)){let r=n.dataset.archived===`true`,i=n.classList.contains(f),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of this.querySelectorAll(`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=this.querySelector(_);n&&(n.hidden=t)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=n(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,i(this.getAttribute(`label`)||r.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{v as t};
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{c as t,i as n,n as r,s as i}from"./notificationDays-CMjhBP1Z.js";import{l as a}from"./wuiHttp-DgnM7K2Q.js";var o=`.wui-notification-center-trigger`,s=`.wui-notification-center-panel`,c=`.wui-notification-center-count`,l=`.wui-notification-center-live`,u=`.wui-notification-center-markall`,d=`.wui-notification-center-item`,f=`wui-notification-center-item-read`,p=`.wui-notification-center-unread-label`,m=`.app-tabs`,h=`.wui-notification-center-tabs [role='tablist']`,g=`.wui-notification-center-tabs [role='tab']`,_=`.wui-notification-center-empty`,v=class extends e{constructor(){super(),this._doc=null,this._unread=0,this._busy=!1,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onOutside=e=>{this.contains(e.target)||this.close()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}connectedCallback(){this._doc=this.ownerDocument,this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`mousedown`,this._onOutside),this.addEventListener(`focusout`,this._onFocusOut),this._syncOpen(),this.isOpen&&this._layoutTabs()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`mousedown`,this._onOutside),this.removeEventListener(`focusout`,this._onFocusOut),this._doc=null}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(this.setAttribute(`open`,``),this._syncOpen(),this._layoutTabs(),this.querySelector(s)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&this.querySelector(o)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(o)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${d}:not(.${f}):not([data-archived="true"])`).length}_click(e){let t=e.target.closest?.(g);if(t&&this.contains(t)){if(this.hasAttribute(`controlled`))return;this._pickTab(t);return}let n=e.target.closest?.(`${o}, ${u}, ${d}`);n&&this.contains(n)&&(n.matches(o)?this.toggle():this.hasAttribute(`controlled`)||(n.matches(u)?this._markAll():this._markItem(n)))}_key(e){if(e.key===`Escape`&&this.isOpen){e.preventDefault(),e.stopPropagation(),this.close({restoreFocus:!0});return}if(!this.isOpen||!this.querySelector(s)?.contains(e.target)||e.target.closest(m))return;let t={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`}[e.key];if(t===void 0)return;let n=[...this.querySelectorAll(d)].filter(e=>!e.closest(`[hidden]`));if(n.length===0)return;let r=n.indexOf(e.target.closest(d)),i;i=t===`first`?0:t===`last`?n.length-1:r===-1?t===1?0:n.length-1:Math.min(n.length-1,Math.max(0,r+t)),e.preventDefault(),n[i].focus()}_markItem(e){e.classList.contains(f)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(t(this._unread)),this._emitRead([e.dataset.id].filter(Boolean),!1))}async _markAll(){if(this._busy)return;let e=[...this.querySelectorAll(`${d}:not(.${f})`)];if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(Boolean),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let i=await a(n,{method:`POST`,body:e});if(this._setBusy(!1),!i.ok){if(i.kind===`session`||i.kind===`aborted`)return;let e=i.message||r.failed[i.kind]||r.failed.server;this._say(e),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:i.kind,message:e}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(r.allRead),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(h);if(t){for(let n of t.querySelectorAll(g)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of this.querySelectorAll(h)){let t=e.querySelector(`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of this.querySelectorAll(d)){let r=n.dataset.archived===`true`,i=n.classList.contains(f),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of this.querySelectorAll(`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=this.querySelector(_);n&&(n.hidden=t)}_applyRead(e){e.classList.add(f),e.querySelector(p)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(u);t&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=this.querySelector(c);e&&(e.textContent=n(this._unread),e.hidden=this._unread===0),this.querySelector(o)?.setAttribute(`aria-label`,i(this.getAttribute(`label`)||r.label,this._unread));let t=this.querySelector(u);t&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(l);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{v as t};
@@ -0,0 +1,14 @@
1
+ import{t as e}from"./elementBase-DV9IZZCu.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{t as i}from"./formMirror-BMQTenSi.js";var a=/[^0-9]/g,o=/[^0-9a-zA-Z]/g,s=class extends e{static formAssociated=!0;static get observedAttributes(){return[`value`,`length`,`mode`,`disabled`,`readonly`,`loading`,`size`,`aria-label`]}get length(){let e=Number.parseInt(this.getAttribute(`length`)??`6`,10);return Number.isFinite(e)&&e>0?e:6}set length(e){this.setAttribute(`length`,String(e))}get mode(){return this.getAttribute(`mode`)===`alphanumeric`?`alphanumeric`:`numeric`}set mode(e){this.setAttribute(`mode`,String(e??`numeric`))}get value(){return this._value??``}set value(e){this._value=this._clean(e),i(this,this._value),this._paint()}_clean(e){return(e==null?``:String(e)).replace(this.mode===`alphanumeric`?o:a,``).slice(0,this.length)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){this._rendered?this._onSelectionChange&&document.addEventListener(`selectionchange`,this._onSelectionChange):(this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render())}formResetCallback(){this._value=this._defaultValue||``,i(this,this._value),this._paint()}attributeChangedCallback(e,t,n){this._rendered&&(e===`value`?(this._value=this._clean(n),i(this,this._value),this._paint()):this.render())}render(){this._value=this._clean(this.getAttribute(`value`)??this._value);let e=this.length,r=this.mode===`numeric`,a=this.hasAttribute(`disabled`),o=t(this)||this.hasAttribute(`loading`),s=this.getAttribute(`size`),c=s===`sm`||s===`lg`?` otp-${s}`:``,l=Array.from({length:e},()=>`<span class="otp-slot" aria-hidden="true"></span>`).join(``),u=this.getAttribute(`aria-label`),d=u?` aria-label="${u.replace(/"/g,`&quot;`)}"`:``;this.innerHTML=`
2
+ <div class="otp${c}">
3
+ <input
4
+ class="otp-field"
5
+ type="text"
6
+ autocomplete="one-time-code"
7
+ inputmode="${r?`numeric`:`text`}"
8
+ ${r?`pattern="[0-9]*"`:``}${d}
9
+ autocapitalize="off"
10
+ autocorrect="off"
11
+ spellcheck="false"
12
+ ${a?`disabled`:``}${o?` readonly`:``} />
13
+ <div class="otp-slots" aria-hidden="true">${l}</div>
14
+ </div>`,this._rendered=!0,i(this,this._value),n(this,this.querySelector(`.otp`)),this._wire(),this._paint()}_refs(){return{input:this.querySelector(`.otp-field`),slots:[...this.querySelectorAll(`.otp-slot`)]}}_paint(){let{input:e,slots:t}=this._refs();if(!e||!t.length)return;e.value!==this._value&&(e.value=this._value);let n=e.selectionStart??this._value.length,r=Math.min(n,t.length-1),i=document.activeElement===e;t.forEach((e,t)=>{e.textContent=this._value[t]??``,e.classList.toggle(`filled`,!!this._value[t]),e.classList.toggle(`active`,i&&t===r)})}_wire(){let{input:e}=this._refs();if(!e)return;let t=e=>{let t=this._clean(e),n=t!==this._value;this._value=t,i(this,this._value),this._paint(),n&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),n&&t.length===this.length&&this.dispatchEvent(new CustomEvent(`complete`,{bubbles:!0,detail:t}))};e.addEventListener(`input`,()=>{let n=e.value;if(this._value.length===this.length&&n.length>this._value.length&&n.startsWith(this._value)){let e=this._clean(n.slice(this._value.length));if(e){t(e);return}}t(n)}),e.addEventListener(`paste`,e=>{if(r(this))return;let n=e.clipboardData?.getData(`text`);n!=null&&(e.preventDefault(),t(n))});for(let t of[`keyup`,`click`,`blur`,`select`])e.addEventListener(t,()=>this._paint());e.addEventListener(`focus`,()=>{this._value.length===this.length&&e.select(),this._paint()}),this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange),this._onSelectionChange=()=>{document.activeElement===e&&this._paint()},document.addEventListener(`selectionchange`,this._onSelectionChange)}disconnectedCallback(){this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange)}};export{s as t};
@@ -0,0 +1,16 @@
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-CBMAnDUt.js";import{n as r,t as i}from"./countries-CvmZ2xpG.js";import{t as a}from"./elementBase-DV9IZZCu.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{t as c}from"./formMirror-BMQTenSi.js";import{t as l}from"./iconGlyphs.g-DaOONrBK.js";import{n as u}from"./listboxKeyNav-DMIvs9d6.js";var d={AD:[`Europe/Andorra`],AE:[`Asia/Dubai`],AF:[`Asia/Kabul`],AG:[`America/Antigua`],AI:[`America/Anguilla`],AL:[`Europe/Tirane`],AM:[`Asia/Yerevan`],AO:[`Africa/Luanda`],AR:[`America/Argentina/Buenos_Aires`,`America/Argentina/Catamarca`,`America/Argentina/ComodRivadavia`,`America/Argentina/Cordoba`,`America/Argentina/Jujuy`,`America/Argentina/La_Rioja`,`America/Argentina/Mendoza`,`America/Argentina/Rio_Gallegos`,`America/Argentina/Salta`,`America/Argentina/San_Juan`,`America/Argentina/San_Luis`,`America/Argentina/Tucuman`,`America/Argentina/Ushuaia`,`America/Buenos_Aires`,`America/Catamarca`,`America/Cordoba`,`America/Jujuy`,`America/Mendoza`,`America/Rosario`],AS:[`Pacific/Pago_Pago`,`Pacific/Samoa`,`US/Samoa`],AT:[`Europe/Vienna`],AU:[`Antarctica/Macquarie`,`Australia/Adelaide`,`Australia/Brisbane`,`Australia/Broken_Hill`,`Australia/Canberra`,`Australia/Currie`,`Australia/Darwin`,`Australia/Eucla`,`Australia/Hobart`,`Australia/LHI`,`Australia/Lindeman`,`Australia/Lord_Howe`,`Australia/Melbourne`,`Australia/NSW`,`Australia/North`,`Australia/Perth`,`Australia/Queensland`,`Australia/South`,`Australia/Sydney`,`Australia/Tasmania`,`Australia/Victoria`,`Australia/West`,`Australia/Yancowinna`],AW:[`America/Aruba`],AX:[`Europe/Mariehamn`],AZ:[`Asia/Baku`],BA:[`Europe/Sarajevo`],BB:[`America/Barbados`],BD:[`Asia/Dacca`,`Asia/Dhaka`],BE:[`Europe/Brussels`],BF:[`Africa/Ouagadougou`],BG:[`Europe/Sofia`],BH:[`Asia/Bahrain`],BI:[`Africa/Bujumbura`],BJ:[`Africa/Porto-Novo`],BL:[`America/St_Barthelemy`],BM:[`Atlantic/Bermuda`],BN:[`Asia/Brunei`],BO:[`America/La_Paz`],BQ:[`America/Kralendijk`],BR:[`America/Araguaina`,`America/Bahia`,`America/Belem`,`America/Boa_Vista`,`America/Campo_Grande`,`America/Cuiaba`,`America/Eirunepe`,`America/Fortaleza`,`America/Maceio`,`America/Manaus`,`America/Noronha`,`America/Porto_Acre`,`America/Porto_Velho`,`America/Recife`,`America/Rio_Branco`,`America/Santarem`,`America/Sao_Paulo`,`Brazil/DeNoronha`,`Brazil/East`,`Brazil/West`],BS:[`America/Nassau`],BT:[`Asia/Thimbu`,`Asia/Thimphu`],BW:[`Africa/Gaborone`],BY:[`Europe/Minsk`],BZ:[`America/Belize`],CA:/* @__PURE__ */ `America/Atikokan.America/Blanc-Sablon.America/Cambridge_Bay.America/Coral_Harbour.America/Creston.America/Dawson.America/Dawson_Creek.America/Edmonton.America/Fort_Nelson.America/Glace_Bay.America/Goose_Bay.America/Halifax.America/Inuvik.America/Iqaluit.America/Moncton.America/Montreal.America/Nipigon.America/Pangnirtung.America/Rainy_River.America/Rankin_Inlet.America/Regina.America/Resolute.America/St_Johns.America/Swift_Current.America/Thunder_Bay.America/Toronto.America/Vancouver.America/Whitehorse.America/Winnipeg.America/Yellowknife.Canada/Atlantic.Canada/Central.Canada/Eastern.Canada/Mountain.Canada/Newfoundland.Canada/Pacific.Canada/Saskatchewan.Canada/Yukon`.split(`.`),CC:[`Indian/Cocos`],CD:[`Africa/Kinshasa`,`Africa/Lubumbashi`],CF:[`Africa/Bangui`],CG:[`Africa/Brazzaville`],CH:[`Europe/Zurich`],CI:[`Africa/Abidjan`],CK:[`Pacific/Rarotonga`],CL:[`America/Coyhaique`,`America/Punta_Arenas`,`America/Santiago`,`Chile/Continental`,`Chile/EasterIsland`,`Pacific/Easter`],CM:[`Africa/Douala`],CN:[`Asia/Chongqing`,`Asia/Harbin`,`Asia/Kashgar`,`Asia/Shanghai`,`Asia/Urumqi`],CO:[`America/Bogota`],CR:[`America/Costa_Rica`],CU:[`America/Havana`],CV:[`Atlantic/Cape_Verde`],CW:[`America/Curacao`],CX:[`Indian/Christmas`],CY:[`Asia/Famagusta`,`Asia/Nicosia`,`Europe/Nicosia`],CZ:[`Europe/Prague`],DE:[`Europe/Berlin`,`Europe/Busingen`],DJ:[`Africa/Djibouti`],DK:[`Europe/Copenhagen`],DM:[`America/Dominica`],DO:[`America/Santo_Domingo`],DZ:[`Africa/Algiers`],EC:[`America/Guayaquil`,`Pacific/Galapagos`],EE:[`Europe/Tallinn`],EG:[`Africa/Cairo`],EH:[`Africa/El_Aaiun`],ER:[`Africa/Asmara`,`Africa/Asmera`],ES:[`Africa/Ceuta`,`Atlantic/Canary`,`Europe/Madrid`],ET:[`Africa/Addis_Ababa`],FI:[`Europe/Helsinki`],FJ:[`Pacific/Fiji`],FK:[`Atlantic/Stanley`],FM:[`Pacific/Chuuk`,`Pacific/Kosrae`,`Pacific/Pohnpei`,`Pacific/Ponape`,`Pacific/Truk`,`Pacific/Yap`],FO:[`Atlantic/Faeroe`,`Atlantic/Faroe`],FR:[`Europe/Paris`],GA:[`Africa/Libreville`],GB:[`Europe/Belfast`,`Europe/London`],GD:[`America/Grenada`],GE:[`Asia/Tbilisi`],GF:[`America/Cayenne`],GG:[`Europe/Guernsey`],GH:[`Africa/Accra`],GI:[`Europe/Gibraltar`],GL:[`America/Danmarkshavn`,`America/Godthab`,`America/Nuuk`,`America/Scoresbysund`,`America/Thule`],GM:[`Africa/Banjul`],GN:[`Africa/Conakry`],GP:[`America/Guadeloupe`],GQ:[`Africa/Malabo`],GR:[`Europe/Athens`],GT:[`America/Guatemala`],GU:[`Pacific/Guam`],GW:[`Africa/Bissau`],GY:[`America/Guyana`],HK:[`Asia/Hong_Kong`],HN:[`America/Tegucigalpa`],HR:[`Europe/Zagreb`],HT:[`America/Port-au-Prince`],HU:[`Europe/Budapest`],ID:[`Asia/Jakarta`,`Asia/Jayapura`,`Asia/Makassar`,`Asia/Pontianak`,`Asia/Ujung_Pandang`],IE:[`Europe/Dublin`],IL:[`Asia/Jerusalem`,`Asia/Tel_Aviv`],IM:[`Europe/Isle_of_Man`],IN:[`Asia/Calcutta`,`Asia/Kolkata`],IO:[`Indian/Chagos`],IQ:[`Asia/Baghdad`],IR:[`Asia/Tehran`],IS:[`Atlantic/Reykjavik`],IT:[`Europe/Rome`],JE:[`Europe/Jersey`],JM:[`America/Jamaica`],JO:[`Asia/Amman`],JP:[`Asia/Tokyo`],KE:[`Africa/Nairobi`],KG:[`Asia/Bishkek`],KH:[`Asia/Phnom_Penh`],KI:[`Pacific/Enderbury`,`Pacific/Kanton`,`Pacific/Kiritimati`,`Pacific/Tarawa`],KM:[`Indian/Comoro`],KN:[`America/St_Kitts`],KP:[`Asia/Pyongyang`],KR:[`Asia/Seoul`],KW:[`Asia/Kuwait`],KY:[`America/Cayman`],KZ:[`Asia/Almaty`,`Asia/Aqtau`,`Asia/Aqtobe`,`Asia/Atyrau`,`Asia/Oral`,`Asia/Qostanay`,`Asia/Qyzylorda`],LA:[`Asia/Vientiane`],LB:[`Asia/Beirut`],LC:[`America/St_Lucia`],LI:[`Europe/Vaduz`],LK:[`Asia/Colombo`],LR:[`Africa/Monrovia`],LS:[`Africa/Maseru`],LT:[`Europe/Vilnius`],LU:[`Europe/Luxembourg`],LV:[`Europe/Riga`],LY:[`Africa/Tripoli`],MA:[`Africa/Casablanca`],MC:[`Europe/Monaco`],MD:[`Europe/Chisinau`,`Europe/Tiraspol`],ME:[`Europe/Podgorica`],MF:[`America/Marigot`],MG:[`Indian/Antananarivo`],MH:[`Pacific/Kwajalein`,`Pacific/Majuro`],MK:[`Europe/Skopje`],ML:[`Africa/Bamako`,`Africa/Timbuktu`],MM:[`Asia/Rangoon`,`Asia/Yangon`],MN:[`Asia/Choibalsan`,`Asia/Hovd`,`Asia/Ulaanbaatar`,`Asia/Ulan_Bator`],MO:[`Asia/Macao`,`Asia/Macau`],MP:[`Pacific/Saipan`],MQ:[`America/Martinique`],MR:[`Africa/Nouakchott`],MS:[`America/Montserrat`],MT:[`Europe/Malta`],MU:[`Indian/Mauritius`],MV:[`Indian/Maldives`],MW:[`Africa/Blantyre`],MX:[`America/Bahia_Banderas`,`America/Cancun`,`America/Chihuahua`,`America/Ciudad_Juarez`,`America/Ensenada`,`America/Hermosillo`,`America/Matamoros`,`America/Mazatlan`,`America/Merida`,`America/Mexico_City`,`America/Monterrey`,`America/Ojinaga`,`America/Santa_Isabel`,`America/Tijuana`,`Mexico/BajaNorte`,`Mexico/BajaSur`,`Mexico/General`],MY:[`Asia/Kuala_Lumpur`,`Asia/Kuching`],MZ:[`Africa/Maputo`],NA:[`Africa/Windhoek`],NC:[`Pacific/Noumea`],NE:[`Africa/Niamey`],NF:[`Pacific/Norfolk`],NG:[`Africa/Lagos`],NI:[`America/Managua`],NL:[`Europe/Amsterdam`],NO:[`Europe/Oslo`],NP:[`Asia/Kathmandu`,`Asia/Katmandu`],NR:[`Pacific/Nauru`],NU:[`Pacific/Niue`],NZ:[`Pacific/Auckland`,`Pacific/Chatham`],OM:[`Asia/Muscat`],PA:[`America/Panama`],PE:[`America/Lima`],PF:[`Pacific/Gambier`,`Pacific/Marquesas`,`Pacific/Tahiti`],PG:[`Pacific/Bougainville`,`Pacific/Port_Moresby`],PH:[`Asia/Manila`],PK:[`Asia/Karachi`],PL:[`Europe/Warsaw`],PM:[`America/Miquelon`],PR:[`America/Puerto_Rico`],PS:[`Asia/Gaza`,`Asia/Hebron`],PT:[`Atlantic/Azores`,`Atlantic/Madeira`,`Europe/Lisbon`],PW:[`Pacific/Palau`],PY:[`America/Asuncion`],QA:[`Asia/Qatar`],RE:[`Indian/Reunion`],RO:[`Europe/Bucharest`],RS:[`Europe/Belgrade`],RU:/* @__PURE__ */ `Asia/Anadyr.Asia/Barnaul.Asia/Chita.Asia/Irkutsk.Asia/Kamchatka.Asia/Khandyga.Asia/Krasnoyarsk.Asia/Magadan.Asia/Novokuznetsk.Asia/Novosibirsk.Asia/Omsk.Asia/Sakhalin.Asia/Srednekolymsk.Asia/Tomsk.Asia/Ust-Nera.Asia/Vladivostok.Asia/Yakutsk.Asia/Yekaterinburg.Europe/Astrakhan.Europe/Kaliningrad.Europe/Kirov.Europe/Moscow.Europe/Samara.Europe/Saratov.Europe/Ulyanovsk.Europe/Volgograd`.split(`.`),RW:[`Africa/Kigali`],SA:[`Asia/Riyadh`],SB:[`Pacific/Guadalcanal`],SC:[`Indian/Mahe`],SD:[`Africa/Khartoum`],SE:[`Europe/Stockholm`],SG:[`Asia/Singapore`],SH:[`Atlantic/St_Helena`],SI:[`Europe/Ljubljana`],SJ:[`Arctic/Longyearbyen`,`Atlantic/Jan_Mayen`],SK:[`Europe/Bratislava`],SL:[`Africa/Freetown`],SM:[`Europe/San_Marino`],SN:[`Africa/Dakar`],SO:[`Africa/Mogadishu`],SR:[`America/Paramaribo`],SS:[`Africa/Juba`],ST:[`Africa/Sao_Tome`],SV:[`America/El_Salvador`],SX:[`America/Lower_Princes`],SY:[`Asia/Damascus`],SZ:[`Africa/Mbabane`],TC:[`America/Grand_Turk`],TD:[`Africa/Ndjamena`],TG:[`Africa/Lome`],TH:[`Asia/Bangkok`],TJ:[`Asia/Dushanbe`],TK:[`Pacific/Fakaofo`],TL:[`Asia/Dili`],TM:[`Asia/Ashgabat`,`Asia/Ashkhabad`],TN:[`Africa/Tunis`],TO:[`Pacific/Tongatapu`],TR:[`Asia/Istanbul`,`Europe/Istanbul`],TT:[`America/Port_of_Spain`],TV:[`Pacific/Funafuti`],TW:[`Asia/Taipei`],TZ:[`Africa/Dar_es_Salaam`],UA:[`Europe/Kiev`,`Europe/Kyiv`,`Europe/Simferopol`,`Europe/Uzhgorod`,`Europe/Zaporozhye`],UG:[`Africa/Kampala`],US:/* @__PURE__ */ `America/Adak.America/Anchorage.America/Atka.America/Boise.America/Chicago.America/Denver.America/Detroit.America/Fort_Wayne.America/Indiana/Indianapolis.America/Indiana/Knox.America/Indiana/Marengo.America/Indiana/Petersburg.America/Indiana/Tell_City.America/Indiana/Vevay.America/Indiana/Vincennes.America/Indiana/Winamac.America/Indianapolis.America/Juneau.America/Kentucky/Louisville.America/Kentucky/Monticello.America/Knox_IN.America/Los_Angeles.America/Louisville.America/Menominee.America/Metlakatla.America/New_York.America/Nome.America/North_Dakota/Beulah.America/North_Dakota/Center.America/North_Dakota/New_Salem.America/Phoenix.America/Shiprock.America/Sitka.America/Yakutat.Pacific/Honolulu.US/Alaska.US/Aleutian.US/Arizona.US/Central.US/East-Indiana.US/Eastern.US/Hawaii.US/Indiana-Starke.US/Michigan.US/Mountain.US/Pacific`.split(`.`),UY:[`America/Montevideo`],UZ:[`Asia/Samarkand`,`Asia/Tashkent`],VA:[`Europe/Vatican`],VC:[`America/St_Vincent`],VE:[`America/Caracas`],VG:[`America/Tortola`],VI:[`America/St_Thomas`,`America/Virgin`],VN:[`Asia/Ho_Chi_Minh`,`Asia/Saigon`],VU:[`Pacific/Efate`],WF:[`Pacific/Wallis`],WS:[`Pacific/Apia`],YE:[`Asia/Aden`],YT:[`Indian/Mayotte`],ZA:[`Africa/Johannesburg`],ZM:[`Africa/Lusaka`],ZW:[`Africa/Harare`]},f=new Set(i.map(([e])=>e)),p=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(d))for(let n of t)p.set(n,e);function m(e){let t=p.get(e);return t&&f.has(t)?t:null}function h(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&f.has(t)?t:null}function g(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return m(e)||h(t)||null}function _(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>v(e,t.default||t))}function v(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var y=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,b=e=>e?`+${r(e)}`:``,x=null,S=null;function C(){return x?Promise.resolve(x):(S||=_().then(e=>(x=e,x)).catch(()=>null),S)}function w(e,t){let n=`+${r(e)}`;return t?.startsWith(n)?t.slice(n.length).trimStart():null}function T(e,t){if(!x||!t||!e)return t;try{return w(e,new x.AsYouType(e).input(`+${r(e)}${t}`))||t}catch{return t}}function E(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function D(e){if(!x||!e)return null;try{return w(e,x.getExampleNumber(e,x.examples)?.formatInternational())||null}catch{return null}}function O(e){let t=D(e);return t?`For example ${t}`:null}function k(e){if(!x||!e)return null;try{if(!x.isValidPhoneNumber(e))return!1;let t=x.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function A(e){if(!x||!e)return null;try{let t=x.getExampleNumber(e,x.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function j(e,t,n){try{let r=x.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function M(e){if(!x||!e?.trim().startsWith(`+`))return null;try{let t=new x.AsYouType;t.input(e.trim());let n=t.getCountry();return n?{country:n,national:t.getNationalNumber()||``}:null}catch{return null}}function N(e,t){let n=String(t??``).trim();if(!n.startsWith(`+`))return null;let i=n.replace(/[^0-9]/g,``),a=String(r(e));return{country:e,national:i.startsWith(a)?i.slice(a.length):i}}var P=class extends a{static formAssociated=!0;static get observedAttributes(){return[`value`,`country`,`locked-country`,`placeholder`,`disabled`,`readonly`,`loading`,`required`,`aria-label`,`aria-describedby`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._defaultCountry=g()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered?this._bindGlobal?.():this.render()}attributeChangedCallback(e,t,n){if(e===`value`)this.value=n;else if(this._rendered){if(e===`aria-label`){let t=this.querySelector(`input[type=tel]`);t&&(n==null?t.removeAttribute(e):t.setAttribute(e,n))}else if(e===`aria-describedby`)this._syncDescribedBy();else if(e===`country`){if(this._locked)return;let e=this.value;if(this._country=n||this._defaultCountry,this._suppressCountryRender)return;this.render(),this.value!==e&&(this._emitInput(),this._emitChange())}else this.render()}}formResetCallback(){this._validateOnInput=!1,this.value=this._defaultValue||``}get _locked(){return(this.getAttribute(`locked-country`)||``).toUpperCase()||null}get value(){return this._national&&this._country?`+${r(this._country)}${this._national}`:``}set value(e){let t=String(e??``).trim();this._locked&&(this._country=this._locked);let n=this._locked?null:M(t);if(n)this._country=n.country,this._national=n.national.replace(/[^0-9]/g,``);else if(t.startsWith(`+`)){let e=t.replace(/[^0-9]/g,``),n=String(r(this._locked||this.getAttribute(`country`)||this._country));n&&e.startsWith(n)&&(e=e.slice(n.length)),this._national=e}else this._national=t.replace(/[^0-9]/g,``);n&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){c(this,this.value)}_syncDescribedBy(){let e=this.querySelector(`input[type=tel]`);if(!e)return;let t=[this.getAttribute(`aria-describedby`),this.querySelector(`[data-phone-error]`)?.id].filter(Boolean);t.length?e.setAttribute(`aria-describedby`,t.join(` `)):e.removeAttribute(`aria-describedby`)}_emitInput(){this.dispatchEvent(new Event(`input`,{bubbles:!0}))}_emitChange(){this._committedValue=this.value,this.dispatchEvent(new Event(`change`,{bubbles:!0}))}render(){this._defaultValue===void 0&&(this._defaultValue=this.getAttribute(`value`)||``),this._country=this._locked||this.getAttribute(`country`)||this._country;let e=this.getAttribute(`placeholder`)||O(this._country)||`Enter phone number`;this.id||=`wui-phone-${Math.random().toString(36).slice(2,9)}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?`<div class="phone-country-adornment"><span class="wui-phone-prefix"><span class="${y(this._country)}" data-flag aria-hidden="true"></span><span class="phone-dial" data-dial>${b(this._country)}</span></span></div>`:`<div class="phone-country-adornment">
2
+ <button type="button" class="country-toggle" aria-label="Choose country" aria-haspopup="listbox" aria-expanded="false" aria-controls="${F(t)}"${this.hasAttribute(`disabled`)?` disabled`:``}>
3
+ <span class="${y(this._country)}" data-flag aria-hidden="true"></span>
4
+ ${l(`chevron-down`,{className:`phone-chevron`})}
5
+ <span class="phone-dial" data-dial>${b(this._country)}</span>
6
+ </button>
7
+ <div class="country-dropdown-menu" hidden>
8
+ <div class="dropdown-search-wrapper"><span class="dropdown-search-icon">${l(`search`)}</span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" aria-controls="${F(t)}" aria-autocomplete="list" /></div>
9
+ <div class="country-list-scroll" role="listbox" id="${F(t)}" tabindex="-1"></div>
10
+ <div class="country-empty" hidden>No countries found</div>
11
+ </div>
12
+ </div>`;this.innerHTML=`
13
+ <div class="phone-input-wrap">
14
+ ${n}
15
+ <input type="tel" class="input" placeholder="${F(e)}" value="${F(T(this._country,this._national))}"${this.getAttribute(`aria-label`)?` aria-label="${F(this.getAttribute(`aria-label`))}"`:``}${this.getAttribute(`aria-describedby`)?` aria-describedby="${F(this.getAttribute(`aria-describedby`))}"`:``}${this.hasAttribute(`required`)?` required aria-required="true"`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${s(this)?` readonly`:``} />
16
+ </div>`,this._rendered=!0,o(this,this.querySelector(`input.input`)),c(this,this.value),this._wire()}_ensureItems(){let e=this.querySelector(`.country-list-scroll`);if(!e||e.querySelector(`.country-dropdown-item`))return;let t=this._listboxId,n=i.map(([e,n,r],i)=>`<button type="button" role="option" id="${F(`${t}-opt-${i}`)}" class="country-dropdown-item${e===this._country?` selected`:``}" data-iso="${e}" aria-selected="${e===this._country}"><span class="${y(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join(``);e.insertAdjacentHTML(`afterbegin`,n)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)]}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){this._teardown();let i=this.querySelector(`.country-toggle`),a=this.querySelector(`.phone-input-wrap`),o=this.querySelector(`.country-dropdown-menu`),c=this.querySelector(`.dropdown-search-input`),l=this.querySelector(`.country-list-scroll`),d=this.querySelector(`.country-empty`),f=this.querySelector(`input[type=tel]`),p=this.querySelector(`[data-flag]`),m=this.querySelector(`[data-dial]`),h=()=>!!o&&!o.hidden,g=()=>n(a||i,o),_=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(l,e>=0&&n[e]||null),e>=0&&n[e]?(t&&n[e].scrollIntoView({block:`nearest`}),c?.setAttribute(`aria-activedescendant`,n[e].id)):c?.removeAttribute(`aria-activedescendant`)},v=()=>{h()&&g()},b=()=>{s(this)||(this._ensureItems(),o.hidden=!1,i.setAttribute(`aria-expanded`,`true`),c.value=``,S(``),g(),e(this,v),c.focus(),_(this._visibleItems().findIndex(e=>e.classList.contains(`selected`))))},x=()=>{o.hidden=!0,i.setAttribute(`aria-expanded`,`false`),_(-1),t(this)},S=e=>{let t=e.trim().toLowerCase(),n=0;for(let e of this._itemEls()){let r=!t||e.textContent.toLowerCase().includes(t);e.hidden=!r,r&&(n+=1)}d&&(d.hidden=n>0)},w=e=>{this._country=e,this.getAttribute(`country`)!==e&&(this._suppressCountryRender=!0,this.setAttribute(`country`,e),this._suppressCountryRender=!1),p&&(p.className=y(e)),m&&(m.textContent=`+${r(e)}`);for(let t of this._itemEls()){let n=t.dataset.iso===e;t.classList.toggle(`selected`,n),t.setAttribute(`aria-selected`,String(n))}!this.getAttribute(`placeholder`)&&f&&(f.placeholder=O(e)||`Enter phone number`),f&&this._national&&(f.value=T(e,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&F(I()),f?.focus()},P=e=>{let t=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!h()){b();return}_(Math.min(this._active+1,t.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!h())return;_(Math.max(this._active-1,0))}else e.key===`Enter`?(e.preventDefault(),h()&&t[this._active]&&w(t[this._active].dataset.iso)):e.key===`Escape`&&h()&&(e.preventDefault(),e.stopPropagation(),x(),i.focus())};i?.addEventListener(`click`,()=>h()?x():b()),i?.addEventListener(`keydown`,e=>{h()?P(e):(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),b())}),c?.addEventListener(`input`,()=>{S(c.value);let e=this._visibleItems();_(e.length?0:-1)}),l?.addEventListener(`click`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&w(t.dataset.iso)}),l?.addEventListener(`mousemove`,e=>{let t=e.target.closest(`.country-dropdown-item`);t&&!t.classList.contains(`is-active`)&&_(this._visibleItems().indexOf(t),{reveal:!1})}),l?.addEventListener(`mouseleave`,()=>_(-1)),o?.addEventListener(`keydown`,P);let F=e=>{f.classList.toggle(`is-invalid`,e),e?f.setAttribute(`aria-invalid`,`true`):f.removeAttribute(`aria-invalid`);let t=this.querySelector(`[data-phone-error]`);if(e&&!this.hasAttribute(`external-error`)){t||(t=document.createElement(`div`),t.className=`field-error`,t.id=`${this.id}-phone-error`,t.setAttribute(`data-phone-error`,``),a.after(t));let e=D(this._country);t.textContent=this._country?e?`Enter a valid phone number, e.g. ${e}`:`Enter a valid phone number`:`Choose a country`}else t?.remove();this._syncDescribedBy()},I=()=>this._national.length>0&&(!this._country||k(this.value)===!1);f.addEventListener(`input`,e=>{e.stopPropagation();let t=f.selectionStart??f.value.length,n=f.value.slice(0,t).replace(/[^0-9]/g,``).length,r=f.value.replace(/[^0-9]/g,``),i=A(this._country);if(i&&r.length>i){let e=j(this._country,r,i);e?(n=Math.max(0,n-(r.length-e.length)),r=e):r=r.slice(0,i)}this._national=r;let a=T(this._country,this._national);if(f.value!==a){f.value=a;let e=E(a,Math.min(n,r.length));f.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&F(I())}),f.addEventListener(`change`,e=>e.stopPropagation()),f.addEventListener(`blur`,()=>{let e=I();F(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),f.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?N(this._locked,t):M(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?f.value=T(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&f.isConnected&&F(I()),this.querySelector(`input[type=tel]`)?.focus())}),this._bindGlobal=()=>{this._teardownGlobals?.(),this._onDocClick=e=>{h()&&!this.contains(e.target)&&x()},document.addEventListener(`click`,this._onDocClick),h()&&e(this,v)},this._teardownGlobals=()=>{this._onDocClick&&=(document.removeEventListener(`click`,this._onDocClick),null),t(this)},this._bindGlobal(),this._validateOnInput&&F(I()),C().then(e=>{if(e&&f.isConnected&&(this._national&&(f.value=T(this._country,this._national)),!this.getAttribute(`placeholder`))){let e=O(this._country);e&&(f.placeholder=e)}}),this._syncMirror()}_teardown(){this._teardownGlobals?.()}disconnectedCallback(){this._teardown()}},F=e=>String(e??``).replace(/"/g,`&quot;`).replace(/</g,`&lt;`);export{P as t};