@webority/ui-elements 0.198.1 → 0.200.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 (234) hide show
  1. package/README.md +4 -3
  2. package/dist/{WuiCarousel-UTqrn7Nx.js → WuiCarousel-CHgYsQLy.js} +1 -1
  3. package/dist/{WuiCodeBlock-BnRpTBm_.js → WuiCodeBlock-DjNv0Jzb.js} +1 -1
  4. package/dist/{WuiCommandPalette-BSWDxEPw.js → WuiCommandPalette-18xqK2S3.js} +1 -1
  5. package/dist/{WuiCommentThread-BGoAONw2.js → WuiCommentThread-KZ3bibV8.js} +1 -1
  6. package/dist/{WuiConsentBanner-B8D2lE8q.js → WuiConsentBanner-DhFgz2Mn.js} +1 -1
  7. package/dist/{WuiContextMenu-oKlQvt3V.js → WuiContextMenu-CEJS12YY.js} +1 -1
  8. package/dist/{WuiDashboardGrid-5rXZvTsm.js → WuiDashboardGrid-Cr3qsN_T.js} +1 -1
  9. package/dist/{WuiDataTable-D_9TWU-r.js → WuiDataTable-08HFWRjn.js} +1 -1
  10. package/dist/WuiDatePicker-_S1KRPAW.js +1 -0
  11. package/dist/WuiDateRange-tlkzGlT4.js +1 -0
  12. package/dist/WuiDateTime-BM_hQc8Y.js +1 -0
  13. package/dist/{WuiDrawer-Dj7lXuGm.js → WuiDrawer-BSFyJN4i.js} +1 -1
  14. package/dist/{WuiDropdown-6g074v1T.js → WuiDropdown-BRofo083.js} +1 -1
  15. package/dist/{WuiGantt-wx8VSXiZ.js → WuiGantt-DThIgEVR.js} +1 -1
  16. package/dist/{WuiHoverCard-DhJcIIM1.js → WuiHoverCard-B_plKt-t.js} +1 -1
  17. package/dist/{WuiImageCrop-Cl97BHN4.js → WuiImageCrop-CPBoKzox.js} +1 -1
  18. package/dist/WuiInlineEdit-8QIAUktT.js +1 -0
  19. package/dist/{WuiLeadPopup-tkt78XlW.js → WuiLeadPopup-CdGXuUdh.js} +1 -1
  20. package/dist/WuiLightbox-BbBHUwEH.js +1 -0
  21. package/dist/WuiMentionInput-CLf66bZv.js +1 -0
  22. package/dist/WuiModal-LgGTsIpb.js +1 -0
  23. package/dist/{WuiNavigationMenu-BvYLbEmA.js → WuiNavigationMenu-BebcHPiK.js} +1 -1
  24. package/dist/{WuiNotificationCenter-DWFg3H-C.js → WuiNotificationCenter-63IkQgw7.js} +1 -1
  25. package/dist/{WuiOrgTree-Be7gK2ls.js → WuiOrgTree-CTcLLmFi.js} +1 -1
  26. package/dist/{WuiOverflow-DCNivxjH.js → WuiOverflow-Czk6Er81.js} +1 -1
  27. package/dist/{WuiPhone-qw_6W3Q2.js → WuiPhone-CdpOXNyu.js} +1 -1
  28. package/dist/{WuiPopover-BvWKRNQY.js → WuiPopover-y07DZA1J.js} +1 -1
  29. package/dist/{WuiRecordPager-DLO5IWE9.js → WuiRecordPager-ByLruWFG.js} +1 -1
  30. package/dist/{WuiRelativeTime-BGeb8bNG.js → WuiRelativeTime-3cYKtfSP.js} +1 -1
  31. package/dist/{WuiSavedViews-NAZArw5y.js → WuiSavedViews-CQjUtOHV.js} +1 -1
  32. package/dist/{WuiSelect-DqHu2OW_.js → WuiSelect-Cbr_4yCe.js} +1 -1
  33. package/dist/{WuiShortcuts-CHOfUeFx.js → WuiShortcuts-BdMGawiV.js} +1 -1
  34. package/dist/{WuiShowMore-B73_umah.js → WuiShowMore-CG1offsP.js} +1 -1
  35. package/dist/{WuiSlider-BjzqYCFt.js → WuiSlider-DuPqp8Ru.js} +1 -1
  36. package/dist/{WuiSortable-DjhJiH0o.js → WuiSortable-6HHTncRn.js} +1 -1
  37. package/dist/{WuiTimePicker-Bl3GcIS_.js → WuiTimePicker-C6KHFFOx.js} +1 -1
  38. package/dist/WuiTour-CWy-OMxR.js +1 -0
  39. package/dist/{WuiTree-Qno7SM6z.js → WuiTree-BsT2thnb.js} +1 -1
  40. package/dist/{WuiTreePicker-DWCLntLz.js → WuiTreePicker-D4Ep2n3T.js} +1 -1
  41. package/dist/{WuiWhatsNew-Dm4Yl68x.js → WuiWhatsNew-naVvdes5.js} +1 -1
  42. package/dist/WuiWizardStep-CPGBX4U8.js +1 -0
  43. package/dist/{calendarMath-CeawKuZQ.js → calendarMath-D8B0i3XW.js} +1 -1
  44. package/dist/{chips-DCkeuEvb.js → chips-BMNFRLY4.js} +1 -1
  45. package/dist/{country-CX7Ok3Md.js → country-COqU5UPA.js} +1 -1
  46. package/dist/{customRule-vAOiOqYH.js → customRule-CYqAWNFg.js} +1 -1
  47. package/dist/{dataTable-D48Rwq1a.js → dataTable-CSP1x4ZA.js} +1 -1
  48. package/dist/{drawerDiscard-mFYviRfI.js → drawerDiscard-233UVlX5.js} +1 -1
  49. package/dist/elements/carousel.js +1 -1
  50. package/dist/elements/code-block.js +1 -1
  51. package/dist/elements/command-palette.js +1 -1
  52. package/dist/elements/comment-thread.js +1 -1
  53. package/dist/elements/consent-banner.js +1 -1
  54. package/dist/elements/context-menu.js +1 -1
  55. package/dist/elements/dashboard-grid.js +1 -1
  56. package/dist/elements/data-table.js +1 -1
  57. package/dist/elements/date-range.js +1 -1
  58. package/dist/elements/date-time.js +1 -1
  59. package/dist/elements/datepicker.js +1 -1
  60. package/dist/elements/drawer.js +1 -1
  61. package/dist/elements/dropdown.js +1 -1
  62. package/dist/elements/filter-popover.js +1 -1
  63. package/dist/elements/gantt.js +1 -1
  64. package/dist/elements/hover-card.js +1 -1
  65. package/dist/elements/image-crop.js +1 -1
  66. package/dist/elements/inline-edit.js +1 -1
  67. package/dist/elements/kanban.js +1 -1
  68. package/dist/elements/lead-popup.js +1 -1
  69. package/dist/elements/lightbox.js +1 -1
  70. package/dist/elements/mention-input.js +1 -1
  71. package/dist/elements/modal.js +1 -1
  72. package/dist/elements/navigation-menu.js +1 -1
  73. package/dist/elements/notification-center.js +1 -1
  74. package/dist/elements/org-tree.js +1 -1
  75. package/dist/elements/overflow.js +1 -1
  76. package/dist/elements/phone.js +1 -1
  77. package/dist/elements/popover.js +1 -1
  78. package/dist/elements/record-pager.js +1 -1
  79. package/dist/elements/relative-time.js +1 -1
  80. package/dist/elements/saved-views.js +1 -1
  81. package/dist/elements/select.js +1 -1
  82. package/dist/elements/shortcuts.js +1 -1
  83. package/dist/elements/show-more.js +1 -1
  84. package/dist/elements/slider.js +1 -1
  85. package/dist/elements/sortable.js +1 -1
  86. package/dist/elements/timepicker.js +1 -1
  87. package/dist/elements/tour.js +1 -1
  88. package/dist/elements/tree-picker.js +1 -1
  89. package/dist/elements/tree.js +1 -1
  90. package/dist/elements/whats-new.js +1 -1
  91. package/dist/elements/wizard.js +1 -1
  92. package/dist/{filterPopover-DopUJ22D.js → filterPopover-Cv9IsBG3.js} +1 -1
  93. package/dist/formatters-lNUhNemK.js +1 -0
  94. package/dist/helpers.js +1 -1
  95. package/dist/{initials-DKg3IeUa.js → initials-CYUX7uHC.js} +1 -1
  96. package/dist/inlineEditText-BjHkrr4q.js +1 -0
  97. package/dist/kanban-C_u1_ctX.js +1 -0
  98. package/dist/{kanbanModel-BQWAC9vs.js → kanbanModel-zqkEKM2x.js} +1 -1
  99. package/dist/{loader-sSdQNOg6.js → loader-AIIVAlsd.js} +1 -1
  100. package/dist/{nativeOverlay-BHD2QV02.js → nativeOverlay-MOABXAAh.js} +1 -1
  101. package/dist/notificationDays-CO6i0_h3.js +1 -0
  102. package/dist/{recents-DTddcnaM.js → recents-C_0aUCxK.js} +1 -1
  103. package/dist/relativeTime-CBiAE0E5.js +1 -0
  104. package/dist/{search-OPWGeniZ.js → search-DenTt9we.js} +1 -1
  105. package/dist/server.js +1 -1
  106. package/dist/{shortcutKeys-CoZBxKsS.js → shortcutKeys-DO6ZWyN6.js} +1 -1
  107. package/dist/{tableSelect-B2lLTEj1.js → tableSelect-BrQSoqzs.js} +1 -1
  108. package/dist/text.js +1 -1
  109. package/dist/textStore-Cs1SGBoI.js +1 -0
  110. package/dist/{themeTransition-DowOV08f.js → themeTransition-DBd5lF43.js} +1 -1
  111. package/dist/ui-calendar.global.js +1 -1
  112. package/dist/ui-calendar.js +1 -1
  113. package/dist/ui-chart.global.js +15 -15
  114. package/dist/ui-chart.js +15 -15
  115. package/dist/ui-elements/calendar-views.global.js +1 -1
  116. package/dist/ui-elements/carousel.global.js +1 -1
  117. package/dist/ui-elements/code-block.global.js +1 -1
  118. package/dist/ui-elements/command-palette.global.js +1 -1
  119. package/dist/ui-elements/comment-thread.global.js +1 -1
  120. package/dist/ui-elements/consent-banner.global.js +1 -1
  121. package/dist/ui-elements/context-menu.global.js +1 -1
  122. package/dist/ui-elements/dashboard-grid.global.js +1 -1
  123. package/dist/ui-elements/data-table.global.js +1 -1
  124. package/dist/ui-elements/date-range.global.js +1 -1
  125. package/dist/ui-elements/date-time.global.js +1 -1
  126. package/dist/ui-elements/datepicker.global.js +1 -1
  127. package/dist/ui-elements/dock.global.js +1 -1
  128. package/dist/ui-elements/drawer.global.js +1 -1
  129. package/dist/ui-elements/dropdown.global.js +1 -1
  130. package/dist/ui-elements/entry-grid.global.js +1 -1
  131. package/dist/ui-elements/gantt.global.js +1 -1
  132. package/dist/ui-elements/glyphs-a.global.js +1 -1
  133. package/dist/ui-elements/glyphs-b.global.js +1 -1
  134. package/dist/ui-elements/glyphs-c.global.js +1 -1
  135. package/dist/ui-elements/glyphs-d.global.js +1 -1
  136. package/dist/ui-elements/glyphs-e.global.js +1 -1
  137. package/dist/ui-elements/glyphs-f.global.js +1 -1
  138. package/dist/ui-elements/glyphs-g.global.js +1 -1
  139. package/dist/ui-elements/glyphs-h.global.js +1 -1
  140. package/dist/ui-elements/glyphs-i.global.js +1 -1
  141. package/dist/ui-elements/glyphs-j.global.js +1 -1
  142. package/dist/ui-elements/glyphs-k.global.js +1 -1
  143. package/dist/ui-elements/glyphs-l.global.js +1 -1
  144. package/dist/ui-elements/glyphs-m.global.js +1 -1
  145. package/dist/ui-elements/glyphs-n.global.js +1 -1
  146. package/dist/ui-elements/glyphs-o.global.js +1 -1
  147. package/dist/ui-elements/glyphs-p.global.js +1 -1
  148. package/dist/ui-elements/glyphs-q.global.js +1 -1
  149. package/dist/ui-elements/glyphs-r.global.js +1 -1
  150. package/dist/ui-elements/glyphs-s.global.js +1 -1
  151. package/dist/ui-elements/glyphs-t.global.js +1 -1
  152. package/dist/ui-elements/glyphs-u.global.js +1 -1
  153. package/dist/ui-elements/glyphs-v.global.js +1 -1
  154. package/dist/ui-elements/glyphs-w.global.js +1 -1
  155. package/dist/ui-elements/glyphs-x.global.js +1 -1
  156. package/dist/ui-elements/glyphs-z.global.js +1 -1
  157. package/dist/ui-elements/glyphs.global.js +1 -1
  158. package/dist/ui-elements/hover-card.global.js +1 -1
  159. package/dist/ui-elements/image-crop.global.js +1 -1
  160. package/dist/ui-elements/inline-edit.global.js +1 -1
  161. package/dist/ui-elements/kanban.global.js +1 -1
  162. package/dist/ui-elements/lead-popup.global.js +1 -1
  163. package/dist/ui-elements/lightbox.global.js +1 -1
  164. package/dist/ui-elements/markdown.global.js +1 -1
  165. package/dist/ui-elements/mini-calendar.global.js +1 -1
  166. package/dist/ui-elements/navigation-menu.global.js +1 -1
  167. package/dist/ui-elements/notification-center.global.js +1 -1
  168. package/dist/ui-elements/offline-banner.global.js +1 -1
  169. package/dist/ui-elements/onboarding-checklist.global.js +1 -1
  170. package/dist/ui-elements/org-tree.global.js +1 -1
  171. package/dist/ui-elements/otp.global.js +1 -1
  172. package/dist/ui-elements/overflow.global.js +1 -1
  173. package/dist/ui-elements/phone.global.js +1 -1
  174. package/dist/ui-elements/popover.global.js +1 -1
  175. package/dist/ui-elements/rating.global.js +1 -1
  176. package/dist/ui-elements/record-pager.global.js +1 -1
  177. package/dist/ui-elements/relative-time.global.js +1 -1
  178. package/dist/ui-elements/saved-views.global.js +1 -1
  179. package/dist/ui-elements/select-chips.global.js +1 -1
  180. package/dist/ui-elements/select-recents.global.js +1 -1
  181. package/dist/ui-elements/select-search.global.js +1 -1
  182. package/dist/ui-elements/select-window.global.js +1 -1
  183. package/dist/ui-elements/server.global.js +1 -1
  184. package/dist/ui-elements/shell.global.js +1 -1
  185. package/dist/ui-elements/shortcuts.global.js +1 -1
  186. package/dist/ui-elements/show-more.global.js +1 -1
  187. package/dist/ui-elements/slider.global.js +1 -1
  188. package/dist/ui-elements/sortable.global.js +1 -1
  189. package/dist/ui-elements/status-icon.global.js +1 -1
  190. package/dist/ui-elements/table-export.global.js +1 -1
  191. package/dist/ui-elements/timepicker.global.js +1 -1
  192. package/dist/ui-elements/tour.global.js +1 -1
  193. package/dist/ui-elements/tree-picker.global.js +1 -1
  194. package/dist/ui-elements/tree.global.js +1 -1
  195. package/dist/ui-elements/truncate.global.js +1 -1
  196. package/dist/ui-elements/whats-new.global.js +1 -1
  197. package/dist/ui-elements/wizard.global.js +1 -1
  198. package/dist/ui-elements.global.js +1 -1
  199. package/dist/ui-elements.js +1 -1
  200. package/dist/ui-tour.global.js +1 -1
  201. package/dist/{zone-BR02ZkHF.js → zone-CIUYudtC.js} +1 -1
  202. package/dist/zone-VKarLPzU.js +1 -0
  203. package/package.json +5 -5
  204. package/types/WuiChart.d.ts +12 -6
  205. package/types/WuiModal.d.ts +1 -0
  206. package/types/chart.d.ts +0 -1
  207. package/types/chartAdapter.d.ts +12 -3
  208. package/types/chartSpec.d.ts +8 -3
  209. package/types/global/core.d.ts +2 -3
  210. package/types/global/shared.d.ts +1 -1
  211. package/types/helpers.d.ts +1 -3
  212. package/types/index.d.ts +0 -1
  213. package/types/kanbanModel.d.ts +3 -2
  214. package/types/nativeOverlay.d.ts +2 -2
  215. package/types/razor-js/modules/generatedScreens.d.ts +1 -0
  216. package/types/zone.d.ts +0 -18
  217. package/dist/WuiDatePicker-B77M2_E7.js +0 -1
  218. package/dist/WuiDateRange-BQ1GH9Mu.js +0 -1
  219. package/dist/WuiDateTime-NTZCa0dZ.js +0 -1
  220. package/dist/WuiInlineEdit-D0a_5oAM.js +0 -1
  221. package/dist/WuiLightbox-DFaHN2Fb.js +0 -1
  222. package/dist/WuiMentionInput-Dcm3F-e-.js +0 -1
  223. package/dist/WuiModal-DQbVJGUo.js +0 -1
  224. package/dist/WuiTour-BS7Jd1Tt.js +0 -1
  225. package/dist/WuiWizardStep-CSS4B8g4.js +0 -1
  226. package/dist/formatters-CXMylefd.js +0 -1
  227. package/dist/formatters.g-BNAu1PMe.js +0 -1
  228. package/dist/inlineEditText-B35MKEul.js +0 -1
  229. package/dist/kanban-BkovNHsk.js +0 -1
  230. package/dist/notificationDays-CZxUShyr.js +0 -1
  231. package/dist/relativeTime-wpijOw5j.js +0 -1
  232. package/dist/textStore-Dh5iyZSR.js +0 -1
  233. package/types/currency.d.ts +0 -6
  234. package/types/formatters.d.ts +0 -138
@@ -1 +1 @@
1
- import{n as e,t}from"./countries-DQL9nAUt.js";import{t as n}from"./devWarn-DXdRWZs3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{t as c}from"./iconGlyphs.g-DRNDTVOs.js";import{n as l}from"./imeSafeEnter-DeO_3lXy.js";import{n as u}from"./listboxKeyNav-CNso9shL.js";import{a as d,l as f,s as p}from"./nativeOverlay-BHD2QV02.js";import{r as m,t as h}from"./textStore-Dh5iyZSR.js";import{t as g}from"./phone.g-P66U-SK5.js";var _={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`]},v=new Set(t.map(([e])=>e)),y=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(_))for(let n of t)y.set(n,e);function b(e){let t=e===void 0?void 0:y.get(e);return t&&v.has(t)?t:null}function x(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&v.has(t)?t:null}function S(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return b(e)||x(t)||null}function C(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>w(e,t.default||t))}function w(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isSupportedCountry:e.isSupportedCountry,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var T=()=>m(`phone`,g);function E(e,t){return e.isSupportedCountry(t)}var D=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,O=t=>t?`+${e(t)}`:``,k=null,A=null;function j(){return k?Promise.resolve(k):(A||=C().then(e=>(k=e,k)).catch(e=>(n(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),A)}function M(t,n){let r=`+${e(t)}`;return n?.startsWith(r)?n.slice(r.length).trimStart():null}function N(t,n){if(!k||!n||!t||!E(k,t))return n;try{return M(t,new k.AsYouType(t).input(`+${e(t)}${n}`))||n}catch{return n}}function P(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 F(e){if(!k||!e||!E(k,e))return null;try{return M(e,k.getExampleNumber(e,k.examples)?.formatInternational())||null}catch{return null}}function I(e){let t=F(e);return t?h(T().examplePlaceholder,{example:t}):null}function L(e){if(!k||!e)return null;try{if(!k.isValidPhoneNumber(e))return!1;let t=k.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function R(e){if(!k||!e||!E(k,e))return null;try{let t=k.getExampleNumber(e,k.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function z(e,t,n){if(!k||!E(k,e))return null;try{let r=k.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function B(e){if(!k||!e?.trim().startsWith(`+`))return null;try{let t=new k.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!J(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function V(t,n){let r=String(n??``).trim();if(!r.startsWith(`+`))return null;let i=r.replace(/[^0-9]/g,``),a=String(e(t));return{country:t,national:i.startsWith(a)?i.slice(a.length):i}}var H=0;function U(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(H+=1,String(H))}var W=class extends i{static formAssociated=!0;static whenFormatted(){return j().then(()=>void 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=S()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=K(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&d(e)}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?`+${e(this._country)}${this._national}`:``}set value(t){let n=String(t??``).trim();this._locked&&(this._country=this._locked);let r=this._locked?null:B(n);if(r)this._country=r.country,this._national=r.national.replace(/[^0-9]/g,``);else if(n.startsWith(`+`)){let t=n.replace(/[^0-9]/g,``),r=String(e(this._locked||this.getAttribute(`country`)||this._country));r&&t.startsWith(r)&&(t=t.slice(r.length)),this._national=t}else this._national=n.replace(/[^0-9]/g,``);r&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){s(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`)||I(this._country)||T().placeholder;this.id||=`wui-phone-${U()}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?r(`div`,{class:`phone-country-adornment`},r(`span`,{class:`wui-phone-prefix`},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country)))):r(`div`,{class:`phone-country-adornment`},r(`button`,{type:`button`,class:`country-toggle`,"aria-label":T().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),c(`chevron-down`,{className:`phone-chevron`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country))),r(`div`,{class:`country-dropdown-menu`,popover:`auto`},r(`div`,{class:`dropdown-search-wrapper`},r(`span`,{class:`dropdown-search-icon`},c(`search`)),r(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:T().searchCountryPlaceholder,"aria-label":T().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),r(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),r(`div`,{class:`country-empty`,hidden:!0},T().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),u=r(`input`,{type:`tel`,class:`form-control`,placeholder:e,value:N(this._country,this._national),"aria-label":i||void 0,"aria-describedby":l||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:o(this)||void 0}),d=this.classList.contains(`wui-input-underline`);this.replaceChildren(r(`div`,{class:d?`phone-input-wrap wui-input-underline`:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.form-control`)),s(this,this.value),this._wire()}_ensureItems(){let e=K(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let n=this._listboxId,i=t.map(([e,t,i],a)=>r(`button`,{type:`button`,role:`option`,id:`${n}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},r(`span`,{class:D(e),"aria-hidden":`true`}),r(`span`,{class:`country-name-text`},t,r(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...i)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let t=K(this.querySelector(`.country-toggle`),HTMLButtonElement),n=G(K(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),r=K(this.querySelector(`.country-dropdown-menu`),HTMLElement),i=K(this.querySelector(`.dropdown-search-input`),HTMLInputElement),a=K(this.querySelector(`.country-list-scroll`),HTMLElement),s=K(this.querySelector(`.country-empty`),HTMLElement),c=G(K(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),m=K(this.querySelector(`[data-flag]`),HTMLElement),g=K(this.querySelector(`[data-dial]`),HTMLElement),_=()=>r!==null&&p(r),v=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(G(a,`country list`),e>=0&&n[e]||null);let r=e>=0?n[e]:void 0;r?(t&&r.scrollIntoView({block:`nearest`}),i?.setAttribute(`aria-activedescendant`,r.id)):i?.removeAttribute(`aria-activedescendant`)},y=()=>{_()||(G(t,`country toggle`).setAttribute(`aria-expanded`,`false`),v(-1))},b=()=>{if(o(this)||(this._ensureItems(),f(n,G(r,`country menu`),{mode:`auto`,onClosed:y}),!_()))return;G(t,`country toggle`).setAttribute(`aria-expanded`,`true`);let e=G(i,`country search`);e.value=``,S(``),e.focus(),v(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{d(G(r,`country menu`))},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)}s&&(s.hidden=n>0)},C=t=>{this._country=t,this.getAttribute(`country`)!==t&&(this._suppressCountryRender=!0,this.setAttribute(`country`,t),this._suppressCountryRender=!1),m&&(m.className=D(t)),g&&(g.textContent=`+${e(t)}`);for(let e of this._itemEls()){let n=e.dataset.iso===t;e.classList.toggle(`selected`,n),e.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(c.placeholder=I(t)||T().placeholder),this._national&&(c.value=N(t,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&E(O()),c.focus()},w=e=>{let n=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!_()){b();return}v(Math.min(this._active+1,n.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!_())return;v(Math.max(this._active-1,0))}else if(l(e)){e.preventDefault();let t=n[this._active];_()&&t?.dataset.iso&&C(t.dataset.iso)}else e.key===`Escape`&&_()&&(e.preventDefault(),e.stopPropagation(),x(),G(t,`country toggle`).focus())};t?.addEventListener(`click`,()=>_()?x():b()),t?.addEventListener(`keydown`,e=>{_()?w(e):(e.key===`ArrowDown`||l(e)||e.key===` `)&&(e.preventDefault(),b())}),i&&i.addEventListener(`input`,()=>{S(i.value);let e=this._visibleItems();v(e.length?0:-1)}),a?.addEventListener(`click`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&C(t.dataset.iso)}),a?.addEventListener(`mousemove`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&v(this._visibleItems().indexOf(t),{reveal:!1})}),a?.addEventListener(`mouseleave`,()=>v(-1)),r?.addEventListener(`keydown`,w);let E=e=>{c.classList.toggle(`is-invalid`,e),e?c.setAttribute(`aria-invalid`,`true`):c.removeAttribute(`aria-invalid`);let t=K(this.querySelector(`[data-phone-error]`),HTMLElement);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`,``),n.after(t));let e=F(this._country);t.textContent=this._country?e?h(T().invalidNumberExampleMessage,{example:e}):T().invalidNumberMessage:T().chooseCountryMessage}else t?.remove();this._syncDescribedBy()},O=()=>this._national.length>0&&(!this._country||L(this.value)===!1);c.addEventListener(`input`,e=>{e.stopPropagation();let t=c.selectionStart??c.value.length,n=c.value.slice(0,t).replace(/[^0-9]/g,``).length,r=c.value.replace(/[^0-9]/g,``),i=R(this._country);if(i&&r.length>i){let e=z(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=N(this._country,this._national);if(c.value!==a){c.value=a;let e=P(a,Math.min(n,r.length));c.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&E(O())}),c.addEventListener(`change`,e=>e.stopPropagation()),c.addEventListener(`blur`,()=>{let e=O();E(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),c.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?V(this._locked,t):B(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?c.value=N(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&c.isConnected&&E(O()),K(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&E(O()),j().then(e=>{if(e&&c.isConnected){if(this._national){let e=N(this._country,this._national);c.defaultValue=e,c.value=e}if(!this.getAttribute(`placeholder`)){let e=I(this._country);e&&(c.placeholder=e)}}}),this._syncMirror()}};function G(e,t){if(e==null)throw Error(`${t} missing`);return e}function K(e,t){return e instanceof t?e:null}function q(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function J(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}export{W as t};
1
+ import{n as e,t}from"./countries-DQL9nAUt.js";import{t as n}from"./devWarn-DXdRWZs3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{t as c}from"./iconGlyphs.g-DRNDTVOs.js";import{n as l}from"./imeSafeEnter-DeO_3lXy.js";import{n as u}from"./listboxKeyNav-CNso9shL.js";import{a as d,l as f,s as p}from"./nativeOverlay-MOABXAAh.js";import{r as m,t as h}from"./textStore-Cs1SGBoI.js";import{t as g}from"./phone.g-P66U-SK5.js";var _={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`]},v=new Set(t.map(([e])=>e)),y=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(_))for(let n of t)y.set(n,e);function b(e){let t=e===void 0?void 0:y.get(e);return t&&v.has(t)?t:null}function x(e){if(!e)return null;let t;try{t=new Intl.Locale(e).region}catch{return null}return t&&v.has(t)?t:null}function S(){let e;try{e=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{e=void 0}let t=typeof navigator>`u`?void 0:navigator.language;return b(e)||x(t)||null}function C(){return Promise.all([import(`./max-ByBKGsXq.js`),import(`./examples.mobile.json-GS1_MGh9.js`)]).then(([e,t])=>w(e,t.default||t))}function w(e,t){return{AsYouType:e.AsYouType,getExampleNumber:e.getExampleNumber,isSupportedCountry:e.isSupportedCountry,isValidPhoneNumber:e.isValidPhoneNumber,parsePhoneNumber:e.parsePhoneNumber,examples:t}}var T=()=>m(`phone`,g);function E(e,t){return e.isSupportedCountry(t)}var D=e=>e?`wui-flag wui-flag-${String(e).toLowerCase()}`:`wui-flag`,O=t=>t?`+${e(t)}`:``,k=null,A=null;function j(){return k?Promise.resolve(k):(A||=C().then(e=>(k=e,k)).catch(e=>(n(`[@webority/ui-elements] <wui-phone> could not load its phone number metadata.`,e),null)),A)}function M(t,n){let r=`+${e(t)}`;return n?.startsWith(r)?n.slice(r.length).trimStart():null}function N(t,n){if(!k||!n||!t||!E(k,t))return n;try{return M(t,new k.AsYouType(t).input(`+${e(t)}${n}`))||n}catch{return n}}function P(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 F(e){if(!k||!e||!E(k,e))return null;try{return M(e,k.getExampleNumber(e,k.examples)?.formatInternational())||null}catch{return null}}function I(e){let t=F(e);return t?h(T().examplePlaceholder,{example:t}):null}function L(e){if(!k||!e)return null;try{if(!k.isValidPhoneNumber(e))return!1;let t=k.parsePhoneNumber(e)?.getType?.();return t===void 0||t===`MOBILE`||t===`FIXED_LINE_OR_MOBILE`}catch{return null}}function R(e){if(!k||!e||!E(k,e))return null;try{let t=k.getExampleNumber(e,k.examples);return t?.nationalNumber?t.nationalNumber.length:null}catch{return null}}function z(e,t,n){if(!k||!E(k,e))return null;try{let r=k.parsePhoneNumber(t,e),i=r?.nationalNumber;return!i||r.country!==e||i.length>n||!t.endsWith(i)?null:i}catch{return null}}function B(e){if(!k||!e?.trim().startsWith(`+`))return null;try{let t=new k.AsYouType;t.input(e.trim());let n=t.getCountry();return!n||!J(t)?null:{country:n,national:t.getNationalNumber()||``}}catch{return null}}function V(t,n){let r=String(n??``).trim();if(!r.startsWith(`+`))return null;let i=r.replace(/[^0-9]/g,``),a=String(e(t));return{country:t,national:i.startsWith(a)?i.slice(a.length):i}}var H=0;function U(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(H+=1,String(H))}var W=class extends i{static formAssociated=!0;static whenFormatted(){return j().then(()=>void 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=S()||``,this._country=this._defaultCountry,this._national=``,this._active=-1,this._committedValue=``,this._validateOnInput=!1}connectedCallback(){this._rendered||this.render()}disconnectedCallback(){let e=K(this.querySelector(`.country-dropdown-menu`),HTMLElement);e&&d(e)}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?`+${e(this._country)}${this._national}`:``}set value(t){let n=String(t??``).trim();this._locked&&(this._country=this._locked);let r=this._locked?null:B(n);if(r)this._country=r.country,this._national=r.national.replace(/[^0-9]/g,``);else if(n.startsWith(`+`)){let t=n.replace(/[^0-9]/g,``),r=String(e(this._locked||this.getAttribute(`country`)||this._country));r&&t.startsWith(r)&&(t=t.slice(r.length)),this._national=t}else this._national=n.replace(/[^0-9]/g,``);r&&this.getAttribute(`country`)!==this._country?this.setAttribute(`country`,this._country):this._rendered&&this.render(),this._committedValue=this.value,this._syncMirror()}_syncMirror(){s(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`)||I(this._country)||T().placeholder;this.id||=`wui-phone-${U()}`;let t=`${this.id}-listbox`;this._listboxId=t;let n=this._locked?r(`div`,{class:`phone-country-adornment`},r(`span`,{class:`wui-phone-prefix`},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country)))):r(`div`,{class:`phone-country-adornment`},r(`button`,{type:`button`,class:`country-toggle`,"aria-label":T().chooseCountryLabel,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":t,disabled:this.hasAttribute(`disabled`)||void 0},r(`span`,{class:D(this._country),"data-flag":!0,"aria-hidden":`true`}),c(`chevron-down`,{className:`phone-chevron`}),r(`span`,{class:`phone-dial`,"data-dial":!0},O(this._country))),r(`div`,{class:`country-dropdown-menu`,popover:`auto`},r(`div`,{class:`dropdown-search-wrapper`},r(`span`,{class:`dropdown-search-icon`},c(`search`)),r(`input`,{type:`text`,class:`dropdown-search-input`,placeholder:T().searchCountryPlaceholder,"aria-label":T().searchCountriesLabel,"aria-controls":t,"aria-autocomplete":`list`})),r(`div`,{class:`country-list-scroll`,role:`listbox`,id:t,tabindex:`-1`}),r(`div`,{class:`country-empty`,hidden:!0},T().noCountriesFoundLabel))),i=this.getAttribute(`aria-label`),l=this.getAttribute(`aria-describedby`),u=r(`input`,{type:`tel`,class:`form-control`,placeholder:e,value:N(this._country,this._national),"aria-label":i||void 0,"aria-describedby":l||void 0,required:this.hasAttribute(`required`)||void 0,"aria-required":this.hasAttribute(`required`)?`true`:void 0,disabled:this.hasAttribute(`disabled`)||void 0,readonly:o(this)||void 0}),d=this.classList.contains(`wui-input-underline`);this.replaceChildren(r(`div`,{class:d?`phone-input-wrap wui-input-underline`:`phone-input-wrap`},n,u)),this._rendered=!0,a(this,this.querySelector(`input.form-control`)),s(this,this.value),this._wire()}_ensureItems(){let e=K(this.querySelector(`.country-list-scroll`),HTMLElement);if(!e||e.querySelector(`.country-dropdown-item`))return;let n=this._listboxId,i=t.map(([e,t,i],a)=>r(`button`,{type:`button`,role:`option`,id:`${n}-opt-${a}`,class:`country-dropdown-item${e===this._country?` selected`:``}`,"data-iso":e,"aria-selected":String(e===this._country)},r(`span`,{class:D(e),"aria-hidden":`true`}),r(`span`,{class:`country-name-text`},t,r(`span`,{class:`country-code-text`},`+${i}`))));e.prepend(...i)}_itemEls(){return[...this.querySelectorAll(`.country-dropdown-item`)].filter(e=>e instanceof HTMLElement)}_visibleItems(){return this._itemEls().filter(e=>!e.hidden)}_wire(){let t=K(this.querySelector(`.country-toggle`),HTMLButtonElement),n=G(K(this.querySelector(`.phone-input-wrap`),HTMLElement),`phone input wrapper`),r=K(this.querySelector(`.country-dropdown-menu`),HTMLElement),i=K(this.querySelector(`.dropdown-search-input`),HTMLInputElement),a=K(this.querySelector(`.country-list-scroll`),HTMLElement),s=K(this.querySelector(`.country-empty`),HTMLElement),c=G(K(this.querySelector(`input[type=tel]`),HTMLInputElement),`phone input`),m=K(this.querySelector(`[data-flag]`),HTMLElement),g=K(this.querySelector(`[data-dial]`),HTMLElement),_=()=>r!==null&&p(r),v=(e,{reveal:t=!0}={})=>{let n=this._visibleItems();this._active=e,u(G(a,`country list`),e>=0&&n[e]||null);let r=e>=0?n[e]:void 0;r?(t&&r.scrollIntoView({block:`nearest`}),i?.setAttribute(`aria-activedescendant`,r.id)):i?.removeAttribute(`aria-activedescendant`)},y=()=>{_()||(G(t,`country toggle`).setAttribute(`aria-expanded`,`false`),v(-1))},b=()=>{if(o(this)||(this._ensureItems(),f(n,G(r,`country menu`),{mode:`auto`,onClosed:y}),!_()))return;G(t,`country toggle`).setAttribute(`aria-expanded`,`true`);let e=G(i,`country search`);e.value=``,S(``),e.focus(),v(this._visibleItems().findIndex(e=>e.classList.contains(`selected`)))},x=()=>{d(G(r,`country menu`))},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)}s&&(s.hidden=n>0)},C=t=>{this._country=t,this.getAttribute(`country`)!==t&&(this._suppressCountryRender=!0,this.setAttribute(`country`,t),this._suppressCountryRender=!1),m&&(m.className=D(t)),g&&(g.textContent=`+${e(t)}`);for(let e of this._itemEls()){let n=e.dataset.iso===t;e.classList.toggle(`selected`,n),e.setAttribute(`aria-selected`,String(n))}this.getAttribute(`placeholder`)||(c.placeholder=I(t)||T().placeholder),this._national&&(c.value=N(t,this._national)),x(),this._syncMirror(),this._emitChange(),this._validateOnInput&&E(O()),c.focus()},w=e=>{let n=this._visibleItems();if(e.key===`ArrowDown`){if(e.preventDefault(),!_()){b();return}v(Math.min(this._active+1,n.length-1))}else if(e.key===`ArrowUp`){if(e.preventDefault(),!_())return;v(Math.max(this._active-1,0))}else if(l(e)){e.preventDefault();let t=n[this._active];_()&&t?.dataset.iso&&C(t.dataset.iso)}else e.key===`Escape`&&_()&&(e.preventDefault(),e.stopPropagation(),x(),G(t,`country toggle`).focus())};t?.addEventListener(`click`,()=>_()?x():b()),t?.addEventListener(`keydown`,e=>{_()?w(e):(e.key===`ArrowDown`||l(e)||e.key===` `)&&(e.preventDefault(),b())}),i&&i.addEventListener(`input`,()=>{S(i.value);let e=this._visibleItems();v(e.length?0:-1)}),a?.addEventListener(`click`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t?.dataset.iso&&C(t.dataset.iso)}),a?.addEventListener(`mousemove`,e=>{let t=K(q(e).closest(`.country-dropdown-item`),HTMLElement);t&&!t.classList.contains(`is-active`)&&v(this._visibleItems().indexOf(t),{reveal:!1})}),a?.addEventListener(`mouseleave`,()=>v(-1)),r?.addEventListener(`keydown`,w);let E=e=>{c.classList.toggle(`is-invalid`,e),e?c.setAttribute(`aria-invalid`,`true`):c.removeAttribute(`aria-invalid`);let t=K(this.querySelector(`[data-phone-error]`),HTMLElement);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`,``),n.after(t));let e=F(this._country);t.textContent=this._country?e?h(T().invalidNumberExampleMessage,{example:e}):T().invalidNumberMessage:T().chooseCountryMessage}else t?.remove();this._syncDescribedBy()},O=()=>this._national.length>0&&(!this._country||L(this.value)===!1);c.addEventListener(`input`,e=>{e.stopPropagation();let t=c.selectionStart??c.value.length,n=c.value.slice(0,t).replace(/[^0-9]/g,``).length,r=c.value.replace(/[^0-9]/g,``),i=R(this._country);if(i&&r.length>i){let e=z(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=N(this._country,this._national);if(c.value!==a){c.value=a;let e=P(a,Math.min(n,r.length));c.setSelectionRange(e,e)}this._syncMirror(),this._emitInput(),this._validateOnInput&&E(O())}),c.addEventListener(`change`,e=>e.stopPropagation()),c.addEventListener(`blur`,()=>{let e=O();E(e),e&&(this._validateOnInput=!0),this.value!==this._committedValue&&this._emitChange()}),c.addEventListener(`paste`,e=>{let t=e.clipboardData?.getData(`text`),n=this._locked?V(this._locked,t):B(t);n&&(e.preventDefault(),this._national=n.national.replace(/[^0-9]/g,``),n.country===this._country?c.value=N(this._country,this._national):(this._country=n.country,this.setAttribute(`country`,n.country)),this._syncMirror(),this._emitInput(),this._emitChange(),this._validateOnInput&&c.isConnected&&E(O()),K(this.querySelector(`input[type=tel]`),HTMLInputElement)?.focus())}),this._validateOnInput&&E(O()),j().then(e=>{if(e&&c.isConnected){if(this._national){let e=N(this._country,this._national);c.defaultValue=e,c.value=e}if(!this.getAttribute(`placeholder`)){let e=I(this._country);e&&(c.placeholder=e)}}}),this._syncMirror()}};function G(e,t){if(e==null)throw Error(`${t} missing`);return e}function K(e,t){return e instanceof t?e:null}function q(e){if(!(e.target instanceof Element))throw Error(`Event target is not an element`);return e.target}function J(e){return`getNationalNumber`in e&&typeof e.getNationalNumber==`function`}export{W as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-BHD2QV02.js";var i=80,a=220,o=`:scope > [data-wui-popover-trigger]`,s=`:scope > [data-wui-popover-panel]`,c=`.popover-arrow`,l=`.popover-header`,u=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,d=[`click`,`hover`,`focus`],f=[`top`,`bottom`,`start`,`end`,`auto`],p=0;function m(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function h(e){return e.pointerType===`touch`||e.pointerType===`pen`}var g=class extends e{_open;_timer;_pressOpen;_refocusing;_awaitChildren;_onPress;_onClick;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`,`trigger`,`placement`,`open-delay`,`close-delay`,`role-dialog`,`auto-focus`,`labelled-by`]}constructor(){super(),this._open=!1,this._timer=null,this._pressOpen=null,this._refocusing=!1,this._awaitChildren=null,this._onPress=e=>{this._pressOpen=this._zone(e.target)===`trigger`?this._open:null},this._onClick=e=>{if(this._zone(e.target)!==`trigger`||!this._kinds().includes(`click`))return;let t=this._pressOpen??this._open;this._pressOpen=null,this._requestOpen(!t)},this._onOver=e=>{if(h(e))return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._kinds().includes(`hover`)&&this._schedule(!0)},this._onOut=e=>{!h(e)&&this._kinds().includes(`hover`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{if(this._refocusing)return;let t=this._zone(e.target);t===`trigger`&&this._kinds().includes(`focus`)?this._requestOpen(!0):t===`panel`&&this._clear()},this._onFocusOut=e=>{this._kinds().includes(`focus`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._requestOpen(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this._open)return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._requestOpen(!1),t&&!this._open&&this._trigger?.focus()}}get isOpen(){return this._open}show(){this._open||(this._applyOpen(!0),this._notify(!0,!1))}hide(){this._open&&(this._applyOpen(!1),this._notify(!1,!1))}connectedCallback(){this.addEventListener(`pointerdown`,this._onPress),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._stampTrigger(),this._openOrAwaitChildren()}attributeChangedCallback(e){e===`open`&&this._awaitChildren?this.hasAttribute(`open`)||this._disarmAwait():e===`open`&&this.isConnected&&this._openOrAwaitChildren()}disconnectedCallback(){this._disarmAwait(),this._clear(),this.removeEventListener(`pointerdown`,this._onPress),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this._open=!1;let e=this._panel;e&&t(e)}get _panel(){return m(this,s)}get _trigger(){let e=m(this,o);if(e)return e;for(let e of this.children)if(e instanceof HTMLElement&&!e.hasAttribute(`data-wui-popover-panel`))return e;return null}_stampTrigger(){let e=this._trigger;e&&(e.setAttribute(`data-wui-popover-trigger`,``),(this.getAttribute(`trigger`)??`click`).split(/\s+/).includes(`click`)&&!e.hasAttribute(`aria-expanded`)&&e.setAttribute(`aria-expanded`,`false`))}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_kinds(){let e=(this.getAttribute(`trigger`)??`click`).split(/\s+/).filter(Boolean),t=[];for(let n of e){let e=d.find(e=>e===n);if(!e)throw RangeError(`<wui-popover>: trigger="${n}" is not click, hover or focus.`);t.push(e)}if(t.length===0)throw RangeError(`<wui-popover>: trigger is empty; name click, hover or focus.`);return t}_side(){let e=this.getAttribute(`placement`)??`bottom`,t=f.find(t=>t===e);if(!t)throw RangeError(`<wui-popover>: placement="${e}" is not top, bottom, start, end or auto.`);return t}_delay(e,t){if(!this.hasAttribute(e))return t;let n=this.getAttribute(e)??``,r=Number(n);if(n.trim()===``||!Number.isFinite(r)||r<0)throw RangeError(`<wui-popover>: ${e}="${n}" is not zero or more milliseconds.`);return r}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this._open===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._requestOpen(e)},t)}_requestOpen(e){e!==this._open&&(e&&this._ready(),this._notify(e,!0)&&this._applyOpen(e))}_notify(e,t){return this.dispatchEvent(new CustomEvent(`wui-popover-toggle`,{bubbles:!0,cancelable:t,detail:{open:e}}))}_mode(){return this._kinds().includes(`click`)?`auto`:`manual`}_ready(){let e=this._panel;if(!e)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to open.`);let t=this._trigger;if(!t)throw Error(`<wui-popover> has no trigger: a child element is required to open.`);return{panel:e,trigger:t,side:this._side(),mode:this._mode()}}_applyOpen(e){if(this._stampTrigger(),e===this._open)return;if(e){let{panel:e,trigger:i,side:a,mode:o}=this._ready();this._open=!0,this._name(e);try{n(i,e,{mode:o,side:a,align:`center`,clampHeight:!0,arrow:m(e,c),onClosed:()=>this._onNativeClose()})}catch(n){throw this._open=!1,t(e),n}this.setAttribute(`open`,``),o===`manual`&&this.ownerDocument.addEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&queueMicrotask(()=>{this._open&&r(e)&&m(e,u)?.focus()}),i.hasAttribute(`aria-expanded`)&&i.setAttribute(`aria-expanded`,`true`);return}let i=this._panel;if(!i)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to close.`);let a=this._trigger;if(!a)throw Error(`<wui-popover> has no trigger: a child element is required to close.`);this._open=!1,this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&this._mode()===`manual`&&i.contains(this.ownerDocument.activeElement)&&this._refocus(),t(i),this.removeAttribute(`open`),a.hasAttribute(`aria-expanded`)&&a.setAttribute(`aria-expanded`,`false`)}_openOrAwaitChildren(){if(this.hasAttribute(`open`)&&(this._panel===null||this._trigger===null)){if(this._awaitChildren)return;this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})}else this._applyOpen(this.hasAttribute(`open`))}_finishAwaitedOpen(){this._panel!==null&&this._trigger!==null&&(this._disarmAwait(),this._applyOpen(this.hasAttribute(`open`)))}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_onNativeClose(){let e=this._panel;if(!this._open||!e||r(e))return;let t=e.contains(this.ownerDocument.activeElement);this._applyOpen(!1),t&&this._refocus(),this._notify(!1,!1)}_refocus(){let e=this._trigger;e&&(this._refocusing=!0,e.focus(),this._refocusing=!1)}_name(e){if(!this.hasAttribute(`role-dialog`))return;e.setAttribute(`role`,`dialog`);let t=this.getAttribute(`labelled-by`);if(t){e.setAttribute(`aria-labelledby`,t);return}let n=m(e,l);n&&(n.id||=`wui-popover-title-${++p}`,e.setAttribute(`aria-labelledby`,n.id))}};export{g as t};
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{a as t,l as n,s as r}from"./nativeOverlay-MOABXAAh.js";var i=80,a=220,o=`:scope > [data-wui-popover-trigger]`,s=`:scope > [data-wui-popover-panel]`,c=`.popover-arrow`,l=`.popover-header`,u=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,d=[`click`,`hover`,`focus`],f=[`top`,`bottom`,`start`,`end`,`auto`],p=0;function m(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function h(e){return e.pointerType===`touch`||e.pointerType===`pen`}var g=class extends e{_open;_timer;_pressOpen;_refocusing;_awaitChildren;_onPress;_onClick;_onOver;_onOut;_onFocusIn;_onFocusOut;_onKeyDown;static get observedAttributes(){return[`open`,`trigger`,`placement`,`open-delay`,`close-delay`,`role-dialog`,`auto-focus`,`labelled-by`]}constructor(){super(),this._open=!1,this._timer=null,this._pressOpen=null,this._refocusing=!1,this._awaitChildren=null,this._onPress=e=>{this._pressOpen=this._zone(e.target)===`trigger`?this._open:null},this._onClick=e=>{if(this._zone(e.target)!==`trigger`||!this._kinds().includes(`click`))return;let t=this._pressOpen??this._open;this._pressOpen=null,this._requestOpen(!t)},this._onOver=e=>{if(h(e))return;let t=this._zone(e.target);t===`panel`?this._clear():t===`trigger`&&this._kinds().includes(`hover`)&&this._schedule(!0)},this._onOut=e=>{!h(e)&&this._kinds().includes(`hover`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._schedule(!1)},this._onFocusIn=e=>{if(this._refocusing)return;let t=this._zone(e.target);t===`trigger`&&this._kinds().includes(`focus`)?this._requestOpen(!0):t===`panel`&&this._clear()},this._onFocusOut=e=>{this._kinds().includes(`focus`)&&this._zone(e.target)&&!this._zone(e.relatedTarget)&&this._requestOpen(!1)},this._onKeyDown=e=>{if(e.key!==`Escape`||!this._open)return;e.preventDefault();let t=this._zone(this.ownerDocument.activeElement)===`panel`;this._clear(),this._requestOpen(!1),t&&!this._open&&this._trigger?.focus()}}get isOpen(){return this._open}show(){this._open||(this._applyOpen(!0),this._notify(!0,!1))}hide(){this._open&&(this._applyOpen(!1),this._notify(!1,!1))}connectedCallback(){this.addEventListener(`pointerdown`,this._onPress),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerover`,this._onOver),this.addEventListener(`pointerout`,this._onOut),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._stampTrigger(),this._openOrAwaitChildren()}attributeChangedCallback(e){e===`open`&&this._awaitChildren?this.hasAttribute(`open`)||this._disarmAwait():e===`open`&&this.isConnected&&this._openOrAwaitChildren()}disconnectedCallback(){this._disarmAwait(),this._clear(),this.removeEventListener(`pointerdown`,this._onPress),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerover`,this._onOver),this.removeEventListener(`pointerout`,this._onOut),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this._open=!1;let e=this._panel;e&&t(e)}get _panel(){return m(this,s)}get _trigger(){let e=m(this,o);if(e)return e;for(let e of this.children)if(e instanceof HTMLElement&&!e.hasAttribute(`data-wui-popover-panel`))return e;return null}_stampTrigger(){let e=this._trigger;e&&(e.setAttribute(`data-wui-popover-trigger`,``),(this.getAttribute(`trigger`)??`click`).split(/\s+/).includes(`click`)&&!e.hasAttribute(`aria-expanded`)&&e.setAttribute(`aria-expanded`,`false`))}_zone(e){if(!(e instanceof Node)||!this.contains(e))return null;let t=e instanceof Element?e:e.parentElement;return this._panel?.contains(t)?`panel`:this._trigger?.contains(t)?`trigger`:null}_kinds(){let e=(this.getAttribute(`trigger`)??`click`).split(/\s+/).filter(Boolean),t=[];for(let n of e){let e=d.find(e=>e===n);if(!e)throw RangeError(`<wui-popover>: trigger="${n}" is not click, hover or focus.`);t.push(e)}if(t.length===0)throw RangeError(`<wui-popover>: trigger is empty; name click, hover or focus.`);return t}_side(){let e=this.getAttribute(`placement`)??`bottom`,t=f.find(t=>t===e);if(!t)throw RangeError(`<wui-popover>: placement="${e}" is not top, bottom, start, end or auto.`);return t}_delay(e,t){if(!this.hasAttribute(e))return t;let n=this.getAttribute(e)??``,r=Number(n);if(n.trim()===``||!Number.isFinite(r)||r<0)throw RangeError(`<wui-popover>: ${e}="${n}" is not zero or more milliseconds.`);return r}_clear(){this._timer!==null&&clearTimeout(this._timer),this._timer=null}_schedule(e){if(this._clear(),this._open===e)return;let t=e?this._delay(`open-delay`,i):this._delay(`close-delay`,a);this._timer=setTimeout(()=>{this._timer=null,this._requestOpen(e)},t)}_requestOpen(e){e!==this._open&&(e&&this._ready(),this._notify(e,!0)&&this._applyOpen(e))}_notify(e,t){return this.dispatchEvent(new CustomEvent(`wui-popover-toggle`,{bubbles:!0,cancelable:t,detail:{open:e}}))}_mode(){return this._kinds().includes(`click`)?`auto`:`manual`}_ready(){let e=this._panel;if(!e)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to open.`);let t=this._trigger;if(!t)throw Error(`<wui-popover> has no trigger: a child element is required to open.`);return{panel:e,trigger:t,side:this._side(),mode:this._mode()}}_applyOpen(e){if(this._stampTrigger(),e===this._open)return;if(e){let{panel:e,trigger:i,side:a,mode:o}=this._ready();this._open=!0,this._name(e);try{n(i,e,{mode:o,side:a,align:`center`,clampHeight:!0,arrow:m(e,c),onClosed:()=>this._onNativeClose()})}catch(n){throw this._open=!1,t(e),n}this.setAttribute(`open`,``),o===`manual`&&this.ownerDocument.addEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&queueMicrotask(()=>{this._open&&r(e)&&m(e,u)?.focus()}),i.hasAttribute(`aria-expanded`)&&i.setAttribute(`aria-expanded`,`true`);return}let i=this._panel;if(!i)throw Error(`<wui-popover> has no panel: a child with data-wui-popover-panel is required to close.`);let a=this._trigger;if(!a)throw Error(`<wui-popover> has no trigger: a child element is required to close.`);this._open=!1,this.ownerDocument.removeEventListener(`keydown`,this._onKeyDown),this.hasAttribute(`auto-focus`)&&this._mode()===`manual`&&i.contains(this.ownerDocument.activeElement)&&this._refocus(),t(i),this.removeAttribute(`open`),a.hasAttribute(`aria-expanded`)&&a.setAttribute(`aria-expanded`,`false`)}_openOrAwaitChildren(){if(this.hasAttribute(`open`)&&(this._panel===null||this._trigger===null)){if(this._awaitChildren)return;this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})}else this._applyOpen(this.hasAttribute(`open`))}_finishAwaitedOpen(){this._panel!==null&&this._trigger!==null&&(this._disarmAwait(),this._applyOpen(this.hasAttribute(`open`)))}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_onNativeClose(){let e=this._panel;if(!this._open||!e||r(e))return;let t=e.contains(this.ownerDocument.activeElement);this._applyOpen(!1),t&&this._refocus(),this._notify(!1,!1)}_refocus(){let e=this._trigger;e&&(this._refocusing=!0,e.focus(),this._refocusing=!1)}_name(e){if(!this.hasAttribute(`role-dialog`))return;e.setAttribute(`role`,`dialog`);let t=this.getAttribute(`labelled-by`);if(t){e.setAttribute(`aria-labelledby`,t);return}let n=m(e,l);n&&(n.id||=`wui-popover-title-${++p}`,e.setAttribute(`aria-labelledby`,n.id))}};export{g as t};
@@ -1 +1 @@
1
- import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{l as n,r}from"./shortcutKeys-CoZBxKsS.js";var i=class extends t{_doc;_onKeyDown;constructor(){super(),this._doc=null,this._onKeyDown=e=>{this.hasAttribute(`keys`)&&n(e,{j:()=>this._press(`.wui-record-pager-next`),k:()=>this._press(`.wui-record-pager-prev`)},this.closest(`[${r}]`))}}connectedCallback(){this._doc=this.ownerDocument,e(this._doc,`wui-record-pager has no owner document`).addEventListener(`keydown`,this._onKeyDown)}disconnectedCallback(){this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc=null}_press(e){let t=this.querySelector(e);!(t instanceof HTMLElement)||t instanceof HTMLButtonElement&&t.disabled||t.getAttribute(`aria-disabled`)===`true`||t.click()}};export{i as t};
1
+ import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{l as n,r}from"./shortcutKeys-DO6ZWyN6.js";var i=class extends t{_doc;_onKeyDown;constructor(){super(),this._doc=null,this._onKeyDown=e=>{this.hasAttribute(`keys`)&&n(e,{j:()=>this._press(`.wui-record-pager-next`),k:()=>this._press(`.wui-record-pager-prev`)},this.closest(`[${r}]`))}}connectedCallback(){this._doc=this.ownerDocument,e(this._doc,`wui-record-pager has no owner document`).addEventListener(`keydown`,this._onKeyDown)}disconnectedCallback(){this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc=null}_press(e){let t=this.querySelector(e);!(t instanceof HTMLElement)||t instanceof HTMLButtonElement&&t.disabled||t.getAttribute(`aria-disabled`)===`true`||t.click()}};export{i as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n}from"./relativeTime-wpijOw5j.js";var r=3e4,i=/* @__PURE__ */ new Set,a=null,o=()=>{if(!(typeof document<`u`&&document.hidden))for(let e of i)e.refresh()},s=e=>{i.add(e),i.size===1&&(a=setInterval(o,r),document.addEventListener(`visibilitychange`,o))},c=e=>{i.delete(e),i.size===0&&(clearInterval(a??void 0),a=null,document.removeEventListener(`visibilitychange`,o))},l=class extends e{_observer;constructor(){super(),this._observer=null}connectedCallback(){this.refresh(),s(this),this._observer=new MutationObserver(()=>this.refresh()),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`datetime`]})}disconnectedCallback(){c(this),this._observer?.disconnect(),this._observer=null}refresh(){let e=this.querySelector(`time[datetime]`);if(!(e instanceof HTMLTimeElement))return;let r=e.getAttribute(`datetime`),i=t(r);e.textContent!==i&&(e.textContent=i);let a=n(r);this.getAttribute(`data-wui-tooltip`)!==a&&this.setAttribute(`data-wui-tooltip`,a)}};export{l as t};
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n}from"./relativeTime-CBiAE0E5.js";var r=3e4,i=/* @__PURE__ */ new Set,a=null,o=()=>{if(!(typeof document<`u`&&document.hidden))for(let e of i)e.refresh()},s=e=>{i.add(e),i.size===1&&(a=setInterval(o,r),document.addEventListener(`visibilitychange`,o))},c=e=>{i.delete(e),i.size===0&&(clearInterval(a??void 0),a=null,document.removeEventListener(`visibilitychange`,o))},l=class extends e{_observer;constructor(){super(),this._observer=null}connectedCallback(){this.refresh(),s(this),this._observer=new MutationObserver(()=>this.refresh()),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`datetime`]})}disconnectedCallback(){c(this),this._observer?.disconnect(),this._observer=null}refresh(){let e=this.querySelector(`time[datetime]`);if(!(e instanceof HTMLTimeElement))return;let r=e.getAttribute(`datetime`),i=t(r);e.textContent!==i&&(e.textContent=i);let a=n(r);this.getAttribute(`data-wui-tooltip`)!==a&&this.setAttribute(`data-wui-tooltip`,a)}};export{l as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{m as i}from"./wuiHttp-8CYWEbRz.js";import{r as a,t as o}from"./textStore-Dh5iyZSR.js";import{t as s}from"./savedViews.g-CzzEliTR.js";var c=`wui-saved-views:`,l=20,u=0,d=()=>a(`savedViews`,s),f=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,p=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,l)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,a=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:a}):s={method:`POST`,body:new URLSearchParams({intent:e,key:a,...t})},this._busy=!0,this._render();let c=await i(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=r(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(f),this._error=null,this._render(),!0}return this._error=c.message||d().viewsNotUpdatedMessage,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=d().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control wui-input-sm`,a.setAttribute(`aria-label`,d().viewNameLabel),a.placeholder=d().nameViewPlaceholder;let o=n.createElement(`button`);o.type=`submit`,o.className=e(`primary`,`solid`,`sm`),o.dataset.wui=t,o.textContent=d().saveViewLabel;let s=n.createElement(`form`);s.className=`d-flex gap-2 px-3 py-2`,s.append(a,o),s.addEventListener(`submit`,this._onSubmit);let c=n.createElement(`input`);c.type=`checkbox`,c.className=`form-check-input`,c.setAttribute(`role`,`switch`),c.id=`wui-saved-views-share-${u++}`;let l=n.createElement(`label`);l.className=`form-check-label`,l.htmlFor=c.id,l.textContent=d().shareTeamLabel;let f=n.createElement(`div`);f.className=`form-check form-switch mb-0`,f.append(c,l);let p=n.createElement(`div`);p.className=`px-3 pb-2`,p.hidden=!0,p.append(f),this._dom={menu:r,divider:i,form:s,input:a,save:o,shareRow:p,share:c},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=d().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=d().deleteLabel,i.setAttribute(`aria-label`,o(d().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:c+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(f).slice(0,l):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{p as t};
1
+ import{n as e,t}from"./buttonClass-C8BRtTk8.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{t as r}from"./serverHtml-BC6tAyAl.js";import{m as i}from"./wuiHttp-8CYWEbRz.js";import{r as a,t as o}from"./textStore-Cs1SGBoI.js";import{t as s}from"./savedViews.g-CzzEliTR.js";var c=`wui-saved-views:`,l=20,u=0,d=()=>a(`savedViews`,s),f=e=>typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`query`in e&&typeof e.query==`string`,p=class extends n{static get observedAttributes(){return[`key`,`mode`,`action`,`can-share`]}_doc=null;_dom=null;_views;_open;_busy;_error;_trigger;_onTriggerClick;_onKeyDown;_onPointerDown;_onSubmit;constructor(){super(),this._views=[],this._open=!1,this._busy=!1,this._error=null,this._onTriggerClick=()=>this._setOpen(!this._open),this._onKeyDown=e=>{this._open&&e.target instanceof Node&&this.contains(e.target)&&(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this._setOpen(!1),this._trigger?.focus()):(e.key===`ArrowDown`||e.key===`ArrowUp`)&&this._ui.menu.contains(e.target)&&!(e.target instanceof Element&&/input|textarea/i.test(e.target.tagName))&&(e.preventDefault(),e.stopPropagation()))},this._onPointerDown=e=>{this._open&&!e.composedPath().includes(this)&&this._setOpen(!1)},this._onSubmit=async e=>{e.preventDefault();let t=this._ui.input.value.trim();if(!t)return;if(this._server()){if(this._busy)return;let e={name:t,query:this._ownerDoc.location.search};this._canShare()&&(e.shared=String(this._ui.share.checked)),await this._request(`save`,e)&&(this._ui.input.value=``,this._ui.share.checked=!1);return}let n=this._ownerDoc.location.search;this._commit([{name:t,query:n},...this._views.filter(e=>e.name!==t)].slice(0,l)),this._ui.input.value=``}}get _ownerDoc(){if(!this._doc)throw Error(`wui-saved-views is not connected`);return this._doc}get _ui(){if(!this._dom)throw Error(`wui-saved-views is not built`);return this._dom}connectedCallback(){this._doc=this.ownerDocument,this._trigger||this._build(),window.addEventListener(`keydown`,this._onKeyDown,!0),this._reload()}disconnectedCallback(){this._setOpen(!1),window.removeEventListener(`keydown`,this._onKeyDown,!0),this._doc=null}attributeChangedCallback(){this._doc&&this._trigger&&this._reload()}_reload(){this._server()?(this._views=[],this._render(),this._request(`list`)):(this._views=this._load(),this._render())}_server(){return this.getAttribute(`mode`)===`server`&&!!this.getAttribute(`action`)&&!!this.getAttribute(`key`)}_canShare(){return this._server()&&this.getAttribute(`can-share`)===`true`}async _request(e,t={}){let n=this.getAttribute(`action`)??``,a=this.getAttribute(`key`)??``,o=n,s;e===`list`?o+=(n.includes(`?`)?`&`:`?`)+new URLSearchParams({intent:`list`,key:a}):s={method:`POST`,body:new URLSearchParams({intent:e,key:a,...t})},this._busy=!0,this._render();let c=await i(o,s);if(this._busy=!1,this._doc===null)return!1;if(c.ok){let e=r(c.html);return this._views=[...e.querySelectorAll(`[data-wui-saved-views-items] > li`)].filter(e=>e instanceof HTMLLIElement).map(e=>({name:e.dataset.name,query:e.dataset.query,shared:e.dataset.shared===`true`})).filter(f),this._error=null,this._render(),!0}return this._error=c.message||d().viewsNotUpdatedMessage,this._render(),!1}_build(){let n=this._ownerDoc;this.classList.add(`dropdown`),this._trigger=n.createElement(`button`),this._trigger.type=`button`,this._trigger.className=e(`neutral`,`outline`,`sm`),this._trigger.dataset.wui=t,this._trigger.textContent=d().viewsLabel,this._trigger.setAttribute(`aria-haspopup`,`true`),this._trigger.setAttribute(`aria-expanded`,`false`),this._trigger.addEventListener(`click`,this._onTriggerClick);let r=n.createElement(`div`);r.className=`dropdown-menu`;let i=n.createElement(`div`);i.className=`dropdown-divider`;let a=n.createElement(`input`);a.type=`text`,a.className=`form-control wui-input-sm`,a.setAttribute(`aria-label`,d().viewNameLabel),a.placeholder=d().nameViewPlaceholder;let o=n.createElement(`button`);o.type=`submit`,o.className=e(`primary`,`solid`,`sm`),o.dataset.wui=t,o.textContent=d().saveViewLabel;let s=n.createElement(`form`);s.className=`d-flex gap-2 px-3 py-2`,s.append(a,o),s.addEventListener(`submit`,this._onSubmit);let c=n.createElement(`input`);c.type=`checkbox`,c.className=`form-check-input`,c.setAttribute(`role`,`switch`),c.id=`wui-saved-views-share-${u++}`;let l=n.createElement(`label`);l.className=`form-check-label`,l.htmlFor=c.id,l.textContent=d().shareTeamLabel;let f=n.createElement(`div`);f.className=`form-check form-switch mb-0`,f.append(c,l);let p=n.createElement(`div`);p.className=`px-3 pb-2`,p.hidden=!0,p.append(f),this._dom={menu:r,divider:i,form:s,input:a,save:o,shareRow:p,share:c},this.append(this._trigger,r)}_render(){let e=this._ownerDoc,t=this._ui,n=[];for(let t of this._views){let r=e.createElement(`a`);if(r.className=`dropdown-item`,r.setAttribute(`href`,e.location.pathname+t.query),r.textContent=t.name,t.shared){let t=e.createElement(`span`);t.className=`badge text-bg-secondary ms-2`,t.textContent=d().sharedLabel,r.append(t)}let i=e.createElement(`button`);i.type=`button`,i.className=`btn btn-link btn-sm`,i.textContent=d().deleteLabel,i.setAttribute(`aria-label`,o(d().deleteText,{name:t.name})),i.disabled=this._busy,i.addEventListener(`click`,()=>this._server()?this._request(`delete`,{name:t.name}):this._commit(this._views.filter(e=>e.name!==t.name))),n.push(r,i)}if(this._error){let t=e.createElement(`div`);t.className=`dropdown-item-text text-danger small`,t.setAttribute(`role`,`alert`),t.textContent=this._error,n.push(t)}t.save.disabled=this._busy,t.share.disabled=this._busy,t.shareRow.hidden=!this._canShare(),t.menu.replaceChildren(...n,t.divider,t.form,t.shareRow)}_commit(e){this._views=e,this._write(e),this._render()}_setOpen(e){e!==this._open&&(this._open=e,this._ui.menu.classList.toggle(`show`,e),this._trigger?.setAttribute(`aria-expanded`,String(e)),e?this._ownerDoc.addEventListener(`pointerdown`,this._onPointerDown,!0):this._ownerDoc.removeEventListener(`pointerdown`,this._onPointerDown,!0))}_storage(){let e=this.getAttribute(`key`);if(!e)return null;try{let t=this._ownerDoc.defaultView;return t?{store:t.localStorage,key:c+e}:null}catch{return null}}_load(){let e=this._storage();if(!e)return[];try{let t=JSON.parse(e.store.getItem(e.key)??`[]`);return Array.isArray(t)?t.filter(f).slice(0,l):[]}catch{return[]}}_write(e){let t=this._storage();if(t)try{t.store.setItem(t.key,JSON.stringify(e))}catch(e){if(!(e instanceof DOMException))throw e}}};export{p as t};
@@ -1 +1 @@
1
- import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-sSdQNOg6.js";import{t as d}from"./iconGlyphs.g-DRNDTVOs.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-BHD2QV02.js";import{i as v,n as y,t as b}from"./optionLabel-CuShfg_A.js";import{r as x}from"./textStore-Dh5iyZSR.js";import{n as S,r as C,t as w}from"./search.g-chn0itlW.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,loadingMoreText:l=k().loadingMoreText,hintText:u=k().hintText,actionRow:d=[],recents:f=null}=n,p=new Set(r.map(String)),m=A(t,a),h=e.id,g=d.filter(e=>e.position===`top`),_=d.filter(e=>e.position===`bottom`),v=f?.options.length?f.options:[],y=g.length+v.length+m.length+_.length,b=m.length>300,x=P,S=b&&x!==void 0,C=e=>S?{index:e,size:y}:void 0,w=0,T=e=>{let t=w++;return i(`button`,{type:`button`,role:`option`,id:R(h,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(C(t))},e.label)},E=e=>{let t=w++;return ne(e,R(h,t),p.has(String(e.value)),C(t))},D=g.map(T),O=v.length&&f?[i(`div`,{class:`wui-select-group`},f.label),...v.map(E),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],F=w,I=[];if(S)w+=m.length;else{let e=``;for(let t of m)t.group&&t.group!==e&&I.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,I.push(E(t))}let L=_.map(T),z=[];if(o===`loading`||o===`more`?z=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),o===`more`?l:c)]:o===`hint`?z=[i(`div`,{class:`wui-select-hint`},u)]:(o===`empty`||m.length===0&&d.length===0)&&(z=[i(`div`,{class:`wui-select-empty`},s)]),S&&x){let n=[...D,...O],r=[...L,...z];return x.render(e,{options:t,query:a,rows:m,pre:n,post:r,preSig:N(n),postSig:N(r),picked:p,top:g,recent:v,bottom:_,bodyBase:F,total:y}),{rows:y,windowed:!0,long:b}}x?.clear(e);let B=[...D,...O,...I,...L,...z],V=N(B);return j.get(e)===V||(j.set(e,V),e.replaceChildren(...B)),{rows:w,windowed:!1,long:b}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function V(e,t){return P?P.reveal(e,t):z(e)[t]??null}function ee(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function te(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function ne(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,U={recents:()=>import(`./recents-DTddcnaM.js`),chips:()=>import(`./chips-DCkeuEvb.js`),search:()=>import(`./search-OPWGeniZ.js`),country:()=>import(`./country-CX7Ok3Md.js`)};function ie(e){let t=T(U,e)?U[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var W=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),ae=300,G=`<div class="wui-select-spacer" aria-hidden="true"></div>`,K=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),q=/* @__PURE__ */ new WeakMap,J=(e,t)=>{let n=e.entries[e.optionEntry[t]??-1];return n?.kind===`option`?n.option:void 0},oe=(e,t,n)=>e.query===t&&e.count>0&&n.length>e.count&&n[0]===J(e,0)&&n[e.count-1]===J(e,e.count-1);function se(e,t,n,r){let i=q.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=i!==void 0&&oe(i,n,r),o=[],s=new Int32Array(r.length),c=``;r.forEach((e,t)=>{e.group&&e.group!==c&&o.push({kind:`group`,label:e.group}),c=e.group??``,s[t]=o.length,o.push({kind:`option`,option:e,ord:t})});let l={options:t,query:n,count:r.length,entries:o,optionEntry:s,heights:O(o.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};if(q.set(e,l),i&&a){l.heights.setEstimate(i.heights.estimate),l.estimated=i.estimated,l.bodyTop=i.bodyTop;for(let e=0;e<i.entries.length;e++)l.heights.set(e,i.heights.heightOf(e))}else i&&(e.scrollTop=0);return l}var Y=e=>e.clientHeight||ae,ce=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:Y(e)});function le(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(ne(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function ue(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function de(e,t){let{start:n,end:r}=ce(e,t);t.start=n,t.end=r;let i=le(t,e.id,n,r),a=t.preSig+G+N(i)+G+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,K(),...i,K(),...t.post)),ue(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function fe(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function X(e,t){de(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=fe(e,t);if(!n)return;ue(e,t),r&&(e.scrollTop+=r),de(e,t)}}function pe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),X(e,n)}function me(e){let t=q.get(e);if(!t)return!1;let{start:n,end:r}=ce(e,t);return n===t.start&&r===t.end?!1:(X(e,t),!0)}function he(e,t){let n=q.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:Y(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;X(e,n)}return a()}function ge(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var _e=e=>e&&!(`position`in e)?e:void 0;function ve(e,t){let n=q.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=_e(ge(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ye=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function be(e,t){let n=q.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=ge(n,e);if(r&&ye(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:pe,refresh:me,reveal:he,indexOfValue:ve,indexByPrefix:be,clear(e){q.delete(e)}});function xe(){return Promise.resolve()}var Z=()=>x(`select`,C),Se=()=>x(`search`,w),Ce=()=>x(`field`,S),we=160,Te=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_endFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._endFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},ke)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Ae)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Q(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Q(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Pe.has(e)?this._rendered&&(this._drawValue(),this.renderList()):Ne.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:De(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Oe.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Oe.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Q(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||Z().emptyText,searchingText:this.getAttribute(`searching-text`)||Z().searchingText,loadingMoreText:Z().loadingMoreText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu(),this._watchListEnd()}_watchListEnd(){this._endFrame===null&&this._activePartsList().some(e=>e.onListEnd)&&(this._endFrame=requestAnimationFrame(()=>{this._endFrame=null,this._checkListEnd()}))}_checkListEnd(){let e=this._refs().list;if(e?.clientHeight&&this._menuOpen()&&!(e.scrollTop+e.clientHeight<e.scrollHeight-we))for(let e of this._activePartsList())e.onListEnd?.()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Q(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Q(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`form-control wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`form-control wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":Z().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?Z().countrySearchPlaceholder:Se().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":Se().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||Z().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??Ve(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Fe){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Me()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Ce().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=$(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=$(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:$(this,`.wui-select-control`,HTMLElement),value:$(this,`.wui-select-value`,HTMLElement),menu:$(this,`.wui-select-menu`,HTMLElement),list:$(this,`.wui-select-options`,HTMLElement),search:$(this,`.wui-select-search input`,HTMLInputElement),input:$(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=$(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>je}_visible(){let e=this._refs();return e.list?Be(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?V(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&(this._windowed&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1}),this._checkListEnd())}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?ee(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:Ve(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&W(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r($(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=$(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=$(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?te(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=ze(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=ze(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null,this._endFrame!==null&&cancelAnimationFrame(this._endFrame),this._endFrame=null}_dropMenu(){let e=$(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Le(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>He(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=xe().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(Z().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=Ee(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},Ee=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},De=e=>re.includes(e),Oe=[`comfortable`,`compact`],ke=150,Ae=250,je=10,Me=()=>{let e=Z();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},Ne=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Pe=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Fe=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Q=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Ie=(e,t)=>t===`multiple`?W(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?W(e)?[`chips`,`search`]:[`chips`]:[],Le=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Ie(e,t)]:Ie(e,t),Re=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,ze=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},$=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),Ve=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},He=(e,t)=>ie(t).then(e=>{if(!Re(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(Z().partLoadMessage),null));export{W as n,A as r,Te as t};
1
+ import{t as e}from"./anchorOverlay-daGdh_91.js";import{t}from"./avatarNode-BaEvz5Xr.js";import{n}from"./devWarn-DXdRWZs3.js";import{i as r,r as i}from"./dom-DMQu--xV.js";import{t as a}from"./elementBase-Cxeyx0tU.js";import{r as o,t as s}from"./fieldState-D-zQcXUS.js";import{n as c,t as l}from"./formMirror-9IpSgeZb.js";import{n as u}from"./loader-AIIVAlsd.js";import{t as d}from"./iconGlyphs.g-DRNDTVOs.js";import{n as f}from"./imeSafeEnter-DeO_3lXy.js";import{n as p,t as m}from"./listboxKeyNav-CNso9shL.js";import{a as h,l as g,s as _}from"./nativeOverlay-MOABXAAh.js";import{i as v,n as y,t as b}from"./optionLabel-CuShfg_A.js";import{r as x}from"./textStore-Cs1SGBoI.js";import{n as S,r as C,t as w}from"./search.g-chn0itlW.js";import{t as T}from"./hasOwn-CJsplJ62.js";import{n as E,r as D,t as O}from"./window-BZWK3rQk.js";var k=()=>x(`select`,C);function A(e,t){let n=String(t??``).trim().toLowerCase();return n?e.filter(e=>[y(e),e.description,e.meta].some(e=>String(e??``).toLowerCase().includes(n))):e}var j=/* @__PURE__ */ new WeakMap,M=e=>e?{"data-index":String(e.index),"aria-setsize":String(e.size),"aria-posinset":String(e.index+1)}:{},N=e=>e.map(e=>e instanceof Element?e.outerHTML:e.textContent??``).join(``),P;function F(e){P=e}function I(e){P?.clear(e),j.delete(e),e.replaceChildren()}function L(e,t,n={}){let{selected:r=[],query:a=``,status:o=`idle`,emptyText:s=k().emptyText,searchingText:c=k().searchingText,loadingMoreText:l=k().loadingMoreText,hintText:u=k().hintText,actionRow:d=[],recents:f=null}=n,p=new Set(r.map(String)),m=A(t,a),h=e.id,g=d.filter(e=>e.position===`top`),_=d.filter(e=>e.position===`bottom`),v=f?.options.length?f.options:[],y=g.length+v.length+m.length+_.length,b=m.length>300,x=P,S=b&&x!==void 0,C=e=>S?{index:e,size:y}:void 0,w=0,T=e=>{let t=w++;return i(`button`,{type:`button`,role:`option`,id:R(h,t),class:`wui-select-option wui-select-add`,"data-value":String(e.value??``),"data-custom":`true`,"aria-selected":`false`,...M(C(t))},e.label)},E=e=>{let t=w++;return ne(e,R(h,t),p.has(String(e.value)),C(t))},D=g.map(T),O=v.length&&f?[i(`div`,{class:`wui-select-group`},f.label),...v.map(E),i(`div`,{class:`wui-select-sep`,"aria-hidden":`true`})]:[],F=w,I=[];if(S)w+=m.length;else{let e=``;for(let t of m)t.group&&t.group!==e&&I.push(i(`div`,{class:`wui-select-group`},t.group)),e=t.group??``,I.push(E(t))}let L=_.map(T),z=[];if(o===`loading`||o===`more`?z=[i(`div`,{class:`wui-select-loading`},i(`span`,{class:`wui-select-spinner spinner-border spinner-border-sm`,role:`status`,"aria-hidden":`true`}),o===`more`?l:c)]:o===`hint`?z=[i(`div`,{class:`wui-select-hint`},u)]:(o===`empty`||m.length===0&&d.length===0)&&(z=[i(`div`,{class:`wui-select-empty`},s)]),S&&x){let n=[...D,...O],r=[...L,...z];return x.render(e,{options:t,query:a,rows:m,pre:n,post:r,preSig:N(n),postSig:N(r),picked:p,top:g,recent:v,bottom:_,bodyBase:F,total:y}),{rows:y,windowed:!0,long:b}}x?.clear(e);let B=[...D,...O,...I,...L,...z],V=N(B);return j.get(e)===V||(j.set(e,V),e.replaceChildren(...B)),{rows:w,windowed:!1,long:b}}var R=(e,t)=>`${e}-opt-${t}`,z=e=>[...e.querySelectorAll(`.wui-select-option`)];function B(e){return P?P.refresh(e):!1}function V(e,t){return P?P.reveal(e,t):z(e)[t]??null}function ee(e,t){if(P)return P.indexOfValue(e,t);let n=new Set(t.map(String));return z(e).findIndex(e=>n.has(e.dataset.value??``))}function te(e,t){return P?P.indexByPrefix(e,t):z(e).findIndex(e=>(e.textContent??``).trim().toLowerCase().startsWith(t))}function ne(e,n,r,a){let o=!!e.disabled,s={id:n,role:`option`,"data-value":String(e.value??``),"aria-selected":String(r),"aria-disabled":o?`true`:void 0,title:o&&e.disabledHint?e.disabledHint:void 0,...M(a)},c=i(`span`,{class:`wui-select-check`,"aria-hidden":`true`},d(`check`));if(!e.description&&!e.meta)return i(`button`,{type:`button`,class:`wui-select-option${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-opt-name`},...b(e)),c);let l=e.description?i(`span`,{class:`wui-select-opt-desc`},e.description):null,u=e.meta?i(`span`,{class:`wui-select-opt-meta`},e.meta):null;return i(`div`,{class:`wui-select-option wui-select-option-rich${r?` selected`:``}`,...s},t(e),i(`span`,{class:`wui-select-option-text`},i(`span`,{class:`wui-opt-label`},...b(e)),l),u,c)}var re=Object.freeze([`single`,`multiple`,`search`,`tag`,`country`]),H=e=>e===`multiple`||e===`tag`,U={recents:()=>import(`./recents-C_0aUCxK.js`),chips:()=>import(`./chips-BMNFRLY4.js`),search:()=>import(`./search-DenTt9we.js`),country:()=>import(`./country-COqU5UPA.js`)};function ie(e){let t=T(U,e)?U[e]:void 0;return t?t():Promise.reject(/* @__PURE__ */ Error(`Unknown <wui-select> part: ${e}.`))}var W=e=>typeof e.loadOptions==`function`||!!e.getAttribute(`source`)||e.hasAttribute(`remote`),ae=300,G=`<div class="wui-select-spacer" aria-hidden="true"></div>`,K=()=>i(`div`,{class:`wui-select-spacer`,"aria-hidden":`true`}),q=/* @__PURE__ */ new WeakMap,J=(e,t)=>{let n=e.entries[e.optionEntry[t]??-1];return n?.kind===`option`?n.option:void 0},oe=(e,t,n)=>e.query===t&&e.count>0&&n.length>e.count&&n[0]===J(e,0)&&n[e.count-1]===J(e,e.count-1);function se(e,t,n,r){let i=q.get(e);if(i&&i.options===t&&i.query===n&&i.count===r.length)return i;let a=i!==void 0&&oe(i,n,r),o=[],s=new Int32Array(r.length),c=``;r.forEach((e,t)=>{e.group&&e.group!==c&&o.push({kind:`group`,label:e.group}),c=e.group??``,s[t]=o.length,o.push({kind:`option`,option:e,ord:t})});let l={options:t,query:n,count:r.length,entries:o,optionEntry:s,heights:O(o.length),estimated:!1,bodyTop:0,start:0,end:0,pre:[],post:[],preSig:``,postSig:``,picked:/* @__PURE__ */ new Set,top:[],recent:[],bottom:[],bodyBase:0,total:0};if(q.set(e,l),i&&a){l.heights.setEstimate(i.heights.estimate),l.estimated=i.estimated,l.bodyTop=i.bodyTop;for(let e=0;e<i.entries.length;e++)l.heights.set(e,i.heights.heightOf(e))}else i&&(e.scrollTop=0);return l}var Y=e=>e.clientHeight||ae,ce=(e,t)=>D(t.heights,{scrollTop:Math.max(0,e.scrollTop-t.bodyTop),viewport:Y(e)});function le(e,t,n,r){let a=[];for(let o=n;o<r;o++){let n=e.entries[o];if(n){if(n.kind===`group`)a.push(i(`div`,{class:`wui-select-group`,"data-entry":o},n.label));else{let r=e.bodyBase+n.ord;a.push(ne(n.option,R(t,r),e.picked.has(String(n.option.value)),{index:r,size:e.total}))}}}return a}function ue(e,t){let[n,r]=e.querySelectorAll(`.wui-select-spacer`);n&&r&&(n.style.flex=r.style.flex=`none`,n.style.height=`${t.heights.offsetOf(t.start)}px`,r.style.height=`${t.heights.total()-t.heights.offsetOf(t.end)}px`)}function de(e,t){let{start:n,end:r}=ce(e,t);t.start=n,t.end=r;let i=le(t,e.id,n,r),a=t.preSig+G+N(i)+G+t.postSig,o=e.scrollTop;j.get(e)!==a&&(j.set(e,a),e.replaceChildren(...t.pre,K(),...i,K(),...t.post)),ue(e,t),e.scrollTop!==o&&(e.scrollTop=o)}function fe(e,t){let n={changed:!1,delta:0};if(!e.clientHeight)return n;let{heights:r}=t,i=e.querySelector(`.wui-select-spacer`),a=[],o=!0,s=!1;if(i){let n=i.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;Math.abs(n-t.bodyTop)>.5&&(t.bodyTop=n,s=!0)}let c=r.indexAt(Math.max(0,e.scrollTop-t.bodyTop)),l=r.offsetOf(c),u=0;for(let n of e.querySelectorAll(`.wui-select-option[data-index], .wui-select-group[data-entry]`)){let e=n.getBoundingClientRect().height;if(n.dataset.entry!==void 0)a.push([Number(n.dataset.entry),e]);else{let r=Number(n.dataset.index)-t.bodyBase,i=r>=0?t.optionEntry[r]:void 0;if(i===void 0)continue;o&&(u=e),o=!1,a.push([i,e])}}if(!t.estimated&&u>0){let e=r.estimate;r.setEstimate(u),t.estimated=!0,r.estimate!==e&&(s=!0)}for(let[e,t]of a)r.set(e,t)&&(s=!0);return s?{changed:s,delta:r.offsetOf(c)-l}:n}function X(e,t){de(e,t);for(let n=0;n<2;n++){let{changed:n,delta:r}=fe(e,t);if(!n)return;ue(e,t),r&&(e.scrollTop+=r),de(e,t)}}function pe(e,t){let n=se(e,t.options,t.query,t.rows);Object.assign(n,{pre:t.pre,post:t.post,preSig:t.preSig,postSig:t.postSig,picked:t.picked,top:t.top,recent:t.recent,bottom:t.bottom,bodyBase:t.bodyBase,total:t.total}),X(e,n)}function me(e){let t=q.get(e);if(!t)return!1;let{start:n,end:r}=ce(e,t);return n===t.start&&r===t.end?!1:(X(e,t),!0)}function he(e,t){let n=q.get(e);if(!n||t<0||t>=n.total)return null;let r=t-n.bodyBase,i=r>=0?n.optionEntry[r]:void 0,a=()=>e.querySelector(`[data-index="${t}"]`);if(i===void 0)return a();for(let t=0;t<2;t++){let t={scrollTop:e.scrollTop-n.bodyTop,viewport:Y(e)},r=n.bodyTop+E(n.heights,i,t);if(Math.abs(r-e.scrollTop)>.5)e.scrollTop=r;else if(a())break;X(e,n)}return a()}function ge(e,t){if(t<0||t>=e.total)return;if(t<e.top.length)return e.top[t];let n=t-e.top.length;if(n<e.recent.length)return e.recent[n];let r=t-e.bodyBase;if(r<e.count){let t=e.entries[e.optionEntry[r]??-1];return t?.kind===`option`?t.option:void 0}return e.bottom[r-e.count]}var _e=e=>e&&!(`position`in e)?e:void 0;function ve(e,t){let n=q.get(e);if(!n||t.length===0)return-1;let r=new Set(t.map(String));for(let e=0;e<n.total;e++){let t=_e(ge(n,e));if(t&&r.has(String(t.value)))return e}return-1}var ye=e=>`position`in e?e.label:`${e.initials??``}${y(e)}${e.description??``}${e.meta??``}`;function be(e,t){let n=q.get(e);if(!n)return-1;for(let e=0;e<n.total;e++){let r=ge(n,e);if(r&&ye(r).trim().toLowerCase().startsWith(t))return e}return-1}F({render:pe,refresh:me,reveal:he,indexOfValue:ve,indexByPrefix:be,clear(e){q.delete(e)}});function xe(){return Promise.resolve()}var Z=()=>x(`select`,C),Se=()=>x(`search`,w),Ce=()=>x(`field`,S),we=160,Te=class extends a{static formAssociated=!0;_internals;_value;_optionsProp;_partOptions;_known;_loadOptionsFn;_validateFn;_declared;_query;_ownsFilter;_active;_rows;_windowed;_windowLoad;_windowFailed;_scrollFrame;_endFrame;_status;_error;_nav;_parts;_partSig;_partsMounted;_partToken;_rendered;_searchShown;_defaultValue;_warnedMode;_warnedDensity;_hoverTimer;_hoverOpened;_onHoverOver;_onHoverOut;_panelShown;_pressOpen;static get observedAttributes(){return/* @__PURE__ */ `class.mode.value.placeholder.search-placeholder.empty-text.searchable.clearable.disabled.readonly.loading.required.size.density.icon.prefix.open.open-on-hover.lazy-options.aria-label.aria-describedby.aria-invalid.min-chars.debounce.source.remote.allow-custom.add-label.searching-text.hint-text.value-label.value-avatar.value-initials.max-tags.allow-duplicates.separators.pattern.invalid-message.create-label.collapse-chips.selected-text.clear-all-label.countries.suggested.suggested-label.all-countries-label.recents-key.recents-limit.recents-label`.split(`.`)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=``,this._optionsProp=null,this._partOptions=null,this._known=/* @__PURE__ */ new Map,this._loadOptionsFn=null,this._validateFn=null,this._declared=void 0,this._query=``,this._ownsFilter=!1,this._active=-1,this._rows=0,this._windowed=!1,this._windowLoad=null,this._windowFailed=!1,this._scrollFrame=null,this._endFrame=null,this._status=`idle`,this._error=``,this._nav=null,this._parts=null,this._partSig=``,this._partsMounted=!1,this._partToken=0,this._rendered=!1,this._searchShown=!1,this._defaultValue=void 0,this._warnedMode=null,this._hoverTimer=null,this._hoverOpened=!1,this._panelShown=!1,this._pressOpen=null,this._onHoverOver=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&(this._clearHover(),!this._menuOpen()&&this._hoverEligible()&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,!this._menuOpen()&&this._hoverEligible()&&(this._open({focus:!1}),this._hoverOpened=!0)},ke)))},this._onHoverOut=e=>{e.pointerType===`mouse`&&this._hoverZone(e.target)&&!this._hoverZone(e.relatedTarget)&&(this._clearHover(),this._menuOpen()&&this.hasAttribute(`open-on-hover`)&&(this._hoverTimer=setTimeout(()=>{this._hoverTimer=null,this._close()},Ae)))}}connectedCallback(){this.addEventListener(`pointerover`,this._onHoverOver),this.addEventListener(`pointerout`,this._onHoverOut),this._rendered||this.render(),this._ensureParts(),this._mountParts()}disconnectedCallback(){this.removeEventListener(`pointerover`,this._onHoverOver),this.removeEventListener(`pointerout`,this._onHoverOut),this._clearHover(),this._dropMenu(),this._teardown(),this._teardownParts()}attributeChangedCallback(e,t,n){e===`class`?this._syncUnderline():e===`value`?(this._value=Q(n,H(this.mode)),this._applyValue()):e===`aria-invalid`?this._syncInvalid():e===`open`?this._rendered&&(this.hasAttribute(`open`)?this._open({focus:!1}):this._close({force:!0})):e===`open-on-hover`?this.hasAttribute(`open-on-hover`)||this._clearHover():e!==`lazy-options`&&(e===`mode`&&(this._value=Q(this._value,H(this.mode)),this._partOptions=null,this._known.clear(),this._ensureParts()),(e===`source`||e===`remote`||e===`recents-key`)&&this._ensureParts(),Pe.has(e)?this._rendered&&(this._drawValue(),this.renderList()):Ne.has(e)?this._remountParts():this._rendered&&this.render())}formResetCallback(){if(this.value=this._defaultValue??``,!this._rendered)return;let e=this._refs();e.input&&(e.input.value=``,e.input.removeAttribute(`aria-invalid`)),e.search&&(e.search.value=``),this.setError(``),this._query!==``&&this._onQueryChange(``)}get mode(){let e=this.getAttribute(`mode`);return e===null?`single`:De(e)?e:(e!==this._warnedMode&&(this._warnedMode=e,n(`<wui-select> mode "${e}" is not one of ${re.join(`, `)}; it is treated as "single".`)),`single`)}_checkDensity(){let e=this.getAttribute(`density`);e===null||Oe.includes(e)||e===this._warnedDensity||(this._warnedDensity=e,n(`<wui-select> density "${e}" is not one of ${Oe.join(`, `)}; it is treated as "comfortable".`))}set mode(e){this.setAttribute(`mode`,String(e))}get value(){return Array.isArray(this._value)?this._value.slice():this._value}set value(e){this._value=Q(e,H(this.mode)),this._applyValue()}get options(){return this._readOptions()}set options(e){this._optionsProp=Array.isArray(e)?e:null,this.mode!==`country`&&(this._partOptions=null);for(let e of this._activePartsList())e.onOptions?.();if(this._rendered){if(this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._autoSearch()!==this._searchShown){this.render();return}this._drawValue(),this.renderList()}}get loadOptions(){return this._loadOptionsFn}set loadOptions(e){this._loadOptionsFn=typeof e==`function`?e:null,this._ensureParts()}get validate(){return this._validateFn}set validate(e){this._validateFn=typeof e==`function`?e:null}commit(e,t={}){this.value=e,this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{isCustom:!!t.isCustom}}))}setPartOptions(e){this._partOptions=Array.isArray(e)?e:null,this._drawValue(),this.renderList()}setStatus(e){this._status=e,this.renderList()}setError(e){this._error=e?String(e):``,this._syncError()}openMenu(){s(this)||this._open({focus:!1})}closeMenu({focusControl:e=!1}={}){this._close(),e&&this._refs().control?.focus()}renderList(){let e=this._refs();if(!e.list)return;let t=this._ownsFilter?``:this._query,n=this._actionRows(),r=this._recents();if(this.hasAttribute(`lazy-options`)&&!this._menuOpen()){this._rows=A(this._listOptions(),t).length+n.length+(r?.options.length??0),this._windowed=!1,I(e.list),this._anchorMenu();return}let i=L(e.list,this._listOptions(),{selected:this._selectedValues(),query:t,status:this._status,emptyText:this.getAttribute(`empty-text`)||Z().emptyText,searchingText:this.getAttribute(`searching-text`)||Z().searchingText,loadingMoreText:Z().loadingMoreText,hintText:this.getAttribute(`hint-text`)||void 0,actionRow:n,recents:r});this._rows=i.rows,this._windowed=i.windowed,i.long&&!i.windowed&&!this._windowFailed&&this._loadWindow(),this._active>=this._rowCount()&&(this._active=-1),this._active>=0&&this._setActive(this._active,{reveal:!1}),this._anchorMenu(),this._watchListEnd()}_watchListEnd(){this._endFrame===null&&this._activePartsList().some(e=>e.onListEnd)&&(this._endFrame=requestAnimationFrame(()=>{this._endFrame=null,this._checkListEnd()}))}_checkListEnd(){let e=this._refs().list;if(e?.clientHeight&&this._menuOpen()&&!(e.scrollTop+e.clientHeight<e.scrollHeight-we))for(let e of this._activePartsList())e.onListEnd?.()}render(){this._dropMenu();let e=this._carry();this._teardownParts(),this._snapshotDeclared();let t=this.mode;this._checkDensity();let n=H(t),r=t===`tag`,a=n&&(r||this.hasAttribute(`allow-custom`));this._value=Q(this._value,n),this._defaultValue===void 0&&n&&this._value.length===0&&(this._value=this._declaredSelected()),n||this._preselect(),this._defaultValue===void 0&&(this._defaultValue=Q(this._value,n));let s=this.getAttribute(`size`),c=s===`sm`?` wui-select-sm`:s===`lg`?` wui-select-lg`:s===`xl`?` wui-select-xl`:``,l=this.getAttribute(`icon`),u=this.getAttribute(`prefix`),f=this.hasAttribute(`clearable`),p=this.hasAttribute(`disabled`);if(!this.id){let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(8));this.id=`wui-select-${Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}`}let m=`${this.id}-listbox`,h=`${this.id}-entry-error`,g=this.getAttribute(`aria-describedby`)?.trim(),_=g?`${g} ${h}`:h,v=this.hasAttribute(`aria-invalid`)||!!this._error,y=this.hasAttribute(`required`)&&!a,b=this._accessibleName(),x=a?{}:{role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":`false`,"aria-controls":m},S={"aria-label":b,"aria-describedby":_,"aria-invalid":v?`true`:void 0,"aria-required":y?`true`:void 0},C=n?i(`div`,{class:`form-control wui-select-control wui-select-multi`,...x,...S,"aria-disabled":p?`true`:void 0,tabindex:!p&&!r?`0`:void 0}):i(`button`,{type:`button`,class:`form-control wui-select-control`,...x,...S,disabled:p||void 0}),w=[l?d(l,{className:`wui-select-icon`}):null,u?i(`span`,{class:`wui-select-prefix`},u):null,i(`span`,{class:`wui-select-value`,"data-label":!0}),f?i(`span`,{class:`wui-select-reset`,role:`button`,"aria-label":Z().clearSelectionLabel,hidden:!0},d(`x`)):null,d(`chevron-down`,{className:`wui-select-caret`})];C.append(...w.filter(e=>e!==null));let T=this.getAttribute(`searchable`),E=T===null?t===`multiple`||t===`country`||this._autoSearch():T!==`false`,D=t===`search`||E&&!a;this._searchShown=D;let O=this.getAttribute(`search-placeholder`)||(t===`country`?Z().countrySearchPlaceholder:Se().placeholder),k=D?i(`div`,{class:`wui-select-search`},d(`search`),i(`input`,{class:`wui-select-input`,placeholder:O,"aria-label":O,"aria-autocomplete":`list`}),i(`button`,{type:`button`,class:`wui-select-clear`,"aria-label":Se().clearLabel,hidden:!0},d(`x`))):null,A=i(`div`,{class:`wui-select-options`,role:`listbox`,id:m,tabindex:`-1`,"aria-multiselectable":n?`true`:void 0}),j=i(`div`,{class:`wui-select-menu wui-select-menu-fixed`,popover:`auto`},k,A),M=i(`div`,{class:`field-error wui-select-error`,id:h,"aria-live":`polite`,hidden:!this._error||void 0},this._error||null);this.replaceChildren(i(`div`,{class:`wui-select${c}`},C,j),M),this._rendered=!0,this._syncMirror(),this._syncValidity(),this._drawValue(),this._syncReset(),this.renderList(),this._wire(),o(this,this.querySelector(`.wui-select-control`)),this._syncUnderline(),this._mountParts(e)}_accessibleName(){return this.getAttribute(`aria-label`)||this.getAttribute(`placeholder`)||Z().fallbackName}_snapshotDeclared(){if(this._declared)return;let e=[...this.querySelectorAll(`:scope > wui-option`)];e.length&&(this._declared=e.map(e=>{let t=document.createDocumentFragment();for(let n of e.childNodes)t.append(n.cloneNode(!0));let n={value:e.getAttribute(`value`)??Ve(e).trim(),label:t.textContent??``,selected:e.hasAttribute(`selected`)};for(let[t,r]of Fe){let i=e.getAttribute(t);i&&(n[r]=i)}return e.hasAttribute(`disabled`)&&(n.disabled=!0),v(n,t)}))}_readOptions(){return this.mode===`country`?this._partOptions||[]:this._partOptions?this._partOptions:this._optionsProp?this._optionsProp:(this._snapshotDeclared(),this._declared||[])}_listOptions(){let e=this._readOptions(),t=this.getAttribute(`value-label`);if(this.mode!==`search`||!t||this._value===``)return e;let n=String(this._value);return e.some(e=>String(e.value)===n)?e:[...e,{value:n,label:t}]}_declaredSelected(){return this._optionsProp?[]:(this._declared??[]).filter(e=>e.selected).map(e=>String(e.value))}_preselect(){let e=this._readOptions(),t=this._value!==``&&e.find(e=>String(e.value)===this._value)||e.find(e=>`selected`in e&&!!e.selected);t&&(this._value=String(t.value))}_optionFor(e){let t=String(e),n=this._readOptions().find(e=>String(e.value)===t);return n?(this._known.set(t,n),n):this._known.get(t)}_placeholder(){return this.getAttribute(`placeholder`)||Me()[this.mode]}_hasValue(){return Array.isArray(this._value)?this._value.length>0:this._value!==``}_selectedValues(){return Array.isArray(this._value)?this._value:this._value===``?this._listOptions().some(e=>String(e.value)===``)?[``]:[]:[this._value]}_applyValue(){this._syncMirror(),this._syncValidity(),this._rendered&&(this._drawValue(),this._syncReset(),this.renderList())}_syncMirror(){H(this.mode)?c(this,this._selectedValues()):l(this,this._value)}_drawValue(){let e=this._refs();if(!e.value)return;let t=H(this.mode),n=t?void 0:this._optionFor(this._value);if(this._syncTitle(n),this._syncValueAvatar(),this._activePartsList().some(e=>e.renderValue?.()===!0))return;if(t){e.value.classList.remove(`wui-select-placeholder`),e.value.textContent=``;return}e.value.classList.toggle(`wui-select-placeholder`,!n);let r=this._placeholder();e.value.replaceChildren(...n?b(n):r?[r]:[])}_syncTitle(e){let t=this.querySelector(`.wui-select-control`);if(!t)return;let n=e&&!this.hasAttribute(`title`)?y(e).trim():``;n?t.setAttribute(`title`,n):t.removeAttribute(`title`)}_syncValueAvatar(){let e=this.querySelector(`.wui-select-control`);if(!e)return;e.querySelector(`:scope > .wui-select-value-avatar`)?.remove();let n=!H(this.mode)&&this._hasValue()?t({avatar:this.getAttribute(`value-avatar`),initials:this.getAttribute(`value-initials`)},`avatar-xs`):null;e.classList.toggle(`wui-has-value-avatar`,!!n),n&&e.prepend(i(`span`,{class:`wui-select-value-avatar`,"aria-hidden":`true`},n))}_syncValidity(){let e=this._internals;if(typeof e?.setValidity==`function`){if(this.hasAttribute(`required`)&&!this._hasValue()){let t=this.querySelector(`.wui-select-control`);e.setValidity({valueMissing:!0},Ce().requiredFieldMessage,t instanceof HTMLElement?t:void 0)}else e.setValidity({})}}_syncReset(){let e=$(this,`.wui-select-reset`,HTMLElement);e&&(e.hidden=!(this.hasAttribute(`clearable`)&&this._hasValue()&&!s(this)))}_syncUnderline(){this.querySelector(`.wui-select-control`)?.classList.toggle(`wui-input-underline`,this.classList.contains(`wui-input-underline`))}_syncInvalid(){let e=this.querySelector(`.wui-select-control`);e&&(this.hasAttribute(`aria-invalid`)||this._error?e.setAttribute(`aria-invalid`,`true`):e.removeAttribute(`aria-invalid`))}_syncError(){let e=$(this,`.wui-select-error`,HTMLElement);e&&(e.textContent=this._error,e.hidden=!this._error),this._syncInvalid()}_refs(){return{control:$(this,`.wui-select-control`,HTMLElement),value:$(this,`.wui-select-value`,HTMLElement),menu:$(this,`.wui-select-menu`,HTMLElement),list:$(this,`.wui-select-options`,HTMLElement),search:$(this,`.wui-select-search input`,HTMLInputElement),input:$(this,`.wui-select-draft`,HTMLInputElement)}}_menuOpen(){let e=$(this,`.wui-select-menu`,HTMLElement);return e!==null&&_(e)}_hoverZone(e){if(!(e instanceof Element))return!1;let t=e.closest(`.wui-select-control, .wui-select-menu`);return t!==null&&this.contains(t)}_hoverEligible(){if(!this.hasAttribute(`open-on-hover`)||s(this)||this.mode===`tag`)return!1;let e=this._refs();return e.search===null&&e.input===null}_clearHover(){this._hoverTimer!==null&&clearTimeout(this._hoverTimer),this._hoverTimer=null}_autoSearch(){return this.mode===`single`&&this.getAttribute(`searchable`)===null&&this._readOptions().length>je}_visible(){let e=this._refs();return e.list?Be(e.list,`.wui-select-option`):[]}_rowCount(){return this._windowed?this._rows:this._visible().length}_rowEl(e){if(!this._windowed)return this._visible()[e];let t=this._refs().list?.querySelector(`[data-index="${e}"]`);return t instanceof HTMLElement?t:void 0}_setActive(e,{reveal:t=!0}={}){let n=this._refs();if(!n.list||!n.control)return;this._active=e;let r=null;e>=0&&e<this._rowCount()&&(r=this._rowEl(e)??(this._windowed&&t?V(n.list,e):null)),p(n.list,r),r?(t&&r.scrollIntoView({block:`nearest`}),n.control.setAttribute(`aria-activedescendant`,r.id)):n.control.removeAttribute(`aria-activedescendant`)}_onListScroll(){this._scrollFrame=null;let e=this._refs().list;e&&(this._windowed&&B(e)&&this._active>=0&&this._setActive(this._active,{reveal:!1}),this._checkListEnd())}_actionRows(){let e=[];for(let t of this._activePartsList()){let n=t.actionRow?.(this._query);n&&e.push(n)}return e}_recents(){if(this._query.trim()!==``)return null;for(let e of this._activePartsList()){let t=e.recents?.(this._listOptions());if(t)return t}return null}_menuPlacement(e,t){let n=this.hasAttribute(`open`)?{below:!0}:{};if(this.getAttribute(`density`)!==`compact`)return{matchWidth:!0,...n};let r=e.getBoundingClientRect();return t.style.width=`max-content`,t.style.minWidth=`${r.width}px`,t.style.maxWidth=`280px`,n}_anchorMenu(){let t=this._refs();t.control&&t.menu&&this._menuOpen()&&e(t.control,t.menu,this._menuPlacement(t.control,t.menu))}_showMenu(e,t){g(e,t,{...this._menuPlacement(e,t),mode:`auto`,keepOffscreen:this.hasAttribute(`open`),onClosed:()=>this._onPanelClosed()}),this._panelShown=!0}_onPanelClosed(){if(!this._panelShown)return;this._panelShown=!1;let e=this._refs();e.control&&(e.control.setAttribute(`aria-expanded`,`false`),this._setActive(-1),this._nav?.clearTypeahead(),this.dispatchEvent(new CustomEvent(`wui-select:close`,{bubbles:!0})))}_open({focus:e=!0}={}){let t=this._refs();if(!t.menu||!t.control)return;let n=this._menuOpen();this._hoverOpened=!1,t.control.setAttribute(`aria-expanded`,`true`),this._query=t.input?t.input.value:``,this._ownsFilter=this._ownsFilter&&this._query!==``;let r=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);if(r&&(r.hidden=!0),t.search&&(t.search.value=``),n||this._showMenu(t.control,t.menu),this.renderList(),e&&(t.search?.focus(),this._setActive(this._windowed&&t.list?ee(t.list,this._selectedValues()):this._visible().findIndex(e=>e.classList.contains(`selected`)))),!n){this.dispatchEvent(new CustomEvent(`wui-select:open`,{bubbles:!0}));for(let e of this._activePartsList())e.onOpen?.()}}_close({force:e=!1}={}){if(!e&&this.hasAttribute(`open`))return;let t=this._refs();if(!t.menu||!t.control)return;this._hoverOpened=!1;let n=t.menu.contains(document.activeElement);_(t.menu)&&h(t.menu),this._onPanelClosed(),n&&t.control.focus()}_onQueryChange(e){this._query=e,this._setActive(-1);let t=$(this,`.wui-select-search .wui-select-clear`,HTMLElement);t&&(t.hidden=!e);let n=!1;for(let t of this._activePartsList())t.onQuery?.(e)===!0&&(n=!0);this._ownsFilter=n,this.renderList()}_pick(e){if(e.getAttribute(`aria-disabled`)===`true`)return;let t=e.dataset.custom===`true`,n=e.dataset.value??``,r=t?{value:n,label:Ve(e).trim()}:this._listOptions().find(e=>String(e.value)===n)??{value:n,label:n},i=this._activePartsList().some(e=>e.onPick?.(r,{isCustom:t})===!0);H(this.mode)||(i||this.commit(n,{isCustom:t}),this._close(),this._refs().control?.focus())}_draftOpens(){return this.mode===`multiple`?this.hasAttribute(`allow-custom`):this.mode===`tag`&&W(this)}_onKeyDown(e){if(!s(this)){for(let t of this._activePartsList())if(t.onKey?.(e)===!0)return;if(!this._menuOpen()){if(e.target instanceof HTMLInputElement){if(e.key!==`ArrowDown`||!this._draftOpens())return;this._open({focus:!1})}else{(e.key===`ArrowDown`||f(e)||e.key===` `)&&(e.preventDefault(),this._open({focus:!0}));return}}r(this._nav,`Listbox keys are not wired.`).handler(e)}}_wire(){this._teardown();let e=this._refs(),t=e.control,n=e.list;if(!t||!e.menu||!n)return;let i=r($(this,`.wui-select`,HTMLElement),`The select wrapper is missing.`),a=$(this,`.wui-select-search .wui-select-clear`,HTMLElement),o=$(this,`.wui-select-reset`,HTMLElement);this._nav=m({getVisibleOptions:()=>this._visible(),getActive:()=>this._active,setActive:e=>this._setActive(e),getCount:()=>this._rowCount(),getOptionAt:e=>this._rowEl(e),findByPrefix:e=>this._windowed?te(n,e):this._visible().findIndex(t=>t.textContent.trim().toLowerCase().startsWith(e)),onEnter:(e,t)=>{if(e)this._pick(e);else if(this._query.trim()!==``){let e=t.find(e=>e.dataset.custom===`true`);if(e)this._pick(e);else if(t.length===1){let e=t[0];e&&this._pick(e)}}},onEscape:e=>{e.preventDefault(),this._nav?.clearTypeahead(),this._close(),t.focus()}}),i.addEventListener(`keydown`,e=>this._onKeyDown(e)),i.addEventListener(`input`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement)||!t.matches(`.wui-select-input, .wui-select-draft`))return;this._onQueryChange(t.value);let n=t.matches(`.wui-select-draft`),r=this._rows>0||this._actionRows().length>0;n&&r&&!this._menuOpen()&&!s(this)&&this._draftOpens()&&this._open({focus:!1})}),i.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||!this._activePartsList().some(e=>e.onBlur?.()===!0)&&t&&this._close()}),a?.addEventListener(`click`,()=>{let t=r(e.search,`The search input is missing.`);t.value=``,this._onQueryChange(``),t.focus()}),t.addEventListener(`pointerdown`,()=>{this._pressOpen=this._menuOpen()}),t.addEventListener(`click`,e=>{if(e.target instanceof Element&&e.target.closest(`[data-remove]`))return;if(this.mode===`tag`){if(s(this))return;this._refs().input?.focus(),!this._menuOpen()&&this._draftOpens()&&this._open({focus:!1});return}if(e.target instanceof HTMLInputElement){!this._menuOpen()&&!s(this)&&this._open({focus:!1});return}let t=e.detail>0&&this._pressOpen!==null?this._pressOpen:this._menuOpen();this._pressOpen=null,this._clearHover(),this._hoverOpened&&t?(this._hoverOpened=!1,this._open({focus:!0})):t?this._close():s(this)||this._open({focus:!0})}),o?.addEventListener(`click`,e=>{e.stopPropagation(),this.commit(H(this.mode)?[]:``),this._close(),t.focus()}),n.addEventListener(`click`,n=>{let r=ze(n).closest(`.wui-select-option`);if(r instanceof HTMLElement&&(this._pick(r),H(this.mode))){let n=this.querySelector(`.wui-select-draft`);(e.search??(n instanceof HTMLElement?n:t)).focus()}}),n.addEventListener(`mousedown`,e=>{H(this.mode)&&e.target instanceof Element&&e.target.closest(`.wui-select-option`)&&e.preventDefault()}),n.addEventListener(`mousemove`,e=>{let t=ze(e).closest(`.wui-select-option`);t instanceof HTMLElement&&!t.classList.contains(`is-active`)&&this._setActive(this._windowed?Number(t.dataset.index):this._visible().indexOf(t),{reveal:!1})}),n.addEventListener(`scroll`,()=>{this._scrollFrame===null&&(this._scrollFrame=requestAnimationFrame(()=>this._onListScroll()))},{passive:!0}),n.addEventListener(`mouseleave`,()=>this._setActive(-1)),n.addEventListener(`error`,e=>{let t=e.target;t instanceof Element&&t.classList.contains(`avatar-img`)&&t.remove()},!0),this.hasAttribute(`open`)&&this._open({focus:!1})}_teardown(){this._nav?.clearTypeahead(),this._scrollFrame!==null&&cancelAnimationFrame(this._scrollFrame),this._scrollFrame=null,this._endFrame!==null&&cancelAnimationFrame(this._endFrame),this._endFrame=null}_dropMenu(){let e=$(this,`.wui-select-menu`,HTMLElement);e&&h(e)}_activePartsList(){return this._partsMounted?r(this._parts,`The mounted parts are missing.`):[]}_ensureParts(){if(!this.isConnected)return;(this.hasAttribute(`source`)||this.hasAttribute(`remote`)||this.hasAttribute(`recents-key`)||this._loadOptionsFn!==null)&&this._loadWindow();let e=Le(this,this.mode),t=e.join(`,`);if(t===this._partSig)return;this._teardownParts(),this._parts=null,this._partSig=t;let n=++this._partToken;Promise.all(e.map(e=>He(this,e))).then(e=>{n===this._partToken&&(this._parts=e.filter(e=>e!==null),this._mountParts())})}_loadWindow(){this._windowLoad===null&&(this._windowLoad=xe().then(()=>this.renderList(),()=>{this._windowFailed=!0,document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:`select-window`}})),this.setError(Z().partLoadMessage)}))}_mountParts(e={draft:``,query:``}){if(!this._parts||this._partsMounted||!this._rendered||!this.isConnected)return;this._partsMounted=!0;let t=Ee(this._refs());for(let n of this._parts)n.mount(this,t,{carry:e});this._drawValue(),this.renderList()}_teardownParts(){let e=this._activePartsList();this._partsMounted=!1;for(let t of e)t.teardown()}_remountParts(){if(!this._partsMounted)return;let e=this._carry();this._teardownParts(),this._mountParts(e)}_carry(){let e=this._refs();return{draft:e.input?.value??``,query:e.search?.value??``}}},Ee=e=>{let{control:t,value:n,menu:i,list:a}=e;return{control:r(t,`control missing`),value:r(n,`value missing`),menu:r(i,`menu missing`),list:r(a,`list missing`),search:e.search,input:e.input}},De=e=>re.includes(e),Oe=[`comfortable`,`compact`],ke=150,Ae=250,je=10,Me=()=>{let e=Z();return{single:e.placeholder,search:e.placeholder,multiple:e.placeholder,tag:e.tagPlaceholder,country:e.countryPlaceholder}},Ne=/* @__PURE__ */ new Set([`countries`,`suggested`,`suggested-label`,`all-countries-label`,`max-tags`,`pattern`,`collapse-chips`,`source`,`remote`,`min-chars`]),Pe=/* @__PURE__ */ new Set([`separators`,`allow-duplicates`,`invalid-message`,`create-label`,`add-label`,`selected-text`,`clear-all-label`,`value-label`,`value-avatar`,`value-initials`,`hint-text`,`recents-key`,`recents-limit`,`recents-label`]),Fe=[[`icon`,`icon`],[`description`,`description`],[`meta`,`meta`],[`group`,`group`],[`avatar`,`avatar`],[`initials`,`initials`],[`disabled-hint`,`disabledHint`]],Q=(e,t)=>t?Array.isArray(e)?e.map(String):e==null||e===``?[]:String(e).split(`,`).map(e=>e.trim()).filter(Boolean):Array.isArray(e)?e.length?String(e[0]):``:e==null?``:String(e),Ie=(e,t)=>t===`multiple`?W(e)?[`chips`,`search`]:[`chips`]:t===`search`?[`search`]:t===`country`?[`country`]:t===`tag`?W(e)?[`chips`,`search`]:[`chips`]:[],Le=(e,t)=>e.hasAttribute(`recents-key`)?[`recents`,...Ie(e,t)]:Ie(e,t),Re=e=>typeof e==`object`&&!!e&&`default`in e&&typeof e.default==`function`,ze=e=>{if(e.target instanceof Element)return e.target;throw Error(`The event target is not an element.`)},$=(e,t,n)=>{let r=e.querySelector(t);return r instanceof n?r:null},Be=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),Ve=e=>{let t=e.textContent;if(t===null)throw Error(`The element has no text.`);return t},He=(e,t)=>ie(t).then(e=>{if(!Re(e))throw Error(`The part ${t} has no default export.`);return e.default()}).catch(()=>(document.dispatchEvent(new CustomEvent(u,{bubbles:!0,composed:!0,detail:{chunk:t}})),e.setError(Z().partLoadMessage),null));export{W as n,A as r,Te as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-BHD2QV02.js";import{a as o,c as s,d as c,f as l,l as u,o as d,p as f,r as p}from"./shortcutKeys-CoZBxKsS.js";var m=`wui-shortcuts-open-change`;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function g(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var _=class extends n{_doc;_onKeyDown;_onClick;_onDocClick;_onPointerDown;_onPressEnd;_pressedOpen;_pinned;_mirroring;static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let n=t(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);n&&this.matches(n)&&this.setOpen(!0)},this._onPointerDown=e=>{t(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&t(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&r(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&a(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(t,{focus:n=!0}={}){let o=this._sheet();if(!o)return;let s=h(this,`.wui-shortcut-toggle`);if(t||(this._pinned=!1),t){o.removeAttribute(`hidden`);let t=this.hasAttribute(`no-trigger`)?s??this:e(s,`<wui-shortcuts> needs its toggle to anchor the sheet.`);i(t,o,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else r(o);this._mirror(t),n&&(t?queueMicrotask(()=>{a(o)&&h(o,`.wui-shortcut-close`)?.focus()}):s?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),h(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:{open:e}})))}_sheet(){return h(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=h(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${p}]`);return e instanceof HTMLElement?e:null}_items(){let t=this.getAttribute(`items`);return t?g(e(this._scope()??this._doc,`WuiShortcuts used before it was connected`),t):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else t.closest(`.wui-shortcut-close`)&&this.setOpen(!1)}}_tickFocused(){let t=this._items(),n=e(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=n?.closest?.(`li, tr`),i=t.find(e=>e===n||e.contains(n)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let t=this.getAttribute(`search`);if(!t)return;let n=e(this._doc,`WuiShortcuts used before it was connected`);(h(this._scope()??n,t)??h(n,t))?.focus()}_keydown(t){if(t.defaultPrevented)return;let n=l(t);if(!n)return;if(n===`esc`&&this.open){t.preventDefault(),this.setOpen(!1);return}let r=this._scope(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>s(this._items(),1),i.k=()=>s(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[n]){u(t,i,r);return}if(n===`enter`)return;let a=e(this._doc,`WuiShortcuts used before it was connected`),p=t.target instanceof Node?t.target:null;if(f(a)||!o(p,r)||d(p))return;let m=c(n),_=g(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===m);if(!_)return;let v=(r??a).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),y=v instanceof HTMLElement?v.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(`wui:shortcut`,{bubbles:!0,cancelable:!0,detail:{key:m,itemKey:y}}))){t.preventDefault();return}let b=_.dataset.target,x=b?h(a,b):null;x&&(t.preventDefault(),x.click())}};export{_ as t};
1
+ import{i as e,t}from"./dom-DMQu--xV.js";import{t as n}from"./elementBase-Cxeyx0tU.js";import{a as r,l as i,s as a}from"./nativeOverlay-MOABXAAh.js";import{a as o,c as s,d as c,f as l,l as u,o as d,p as f,r as p}from"./shortcutKeys-DO6ZWyN6.js";var m=`wui-shortcuts-open-change`;function h(e,t){let n=e.querySelector(t);return n instanceof HTMLElement?n:null}function g(e,t){return[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement)}var _=class extends n{_doc;_onKeyDown;_onClick;_onDocClick;_onPointerDown;_onPressEnd;_pressedOpen;_pinned;_mirroring;static get observedAttributes(){return[`open`,`no-trigger`]}constructor(){super(),this._doc=null,this._pressedOpen=!1,this._pinned=!1,this._mirroring=!1,this._onKeyDown=e=>this._keydown(e),this._onClick=e=>this._click(e),this._onDocClick=e=>{let n=t(e.target,`[data-wui-shortcuts-open]`)?.getAttribute(`data-wui-shortcuts-open`);n&&this.matches(n)&&this.setOpen(!0)},this._onPointerDown=e=>{t(e.target,`.wui-shortcut-toggle`)&&(this._pressedOpen=this.open)},this._onPressEnd=e=>{e.type===`pointerup`&&t(e.target,`.wui-shortcut-toggle`)||(this._pressedOpen=!1)}}connectedCallback(){this._doc=this.ownerDocument,this._doc.addEventListener(`keydown`,this._onKeyDown),this._doc.addEventListener(`click`,this._onDocClick),this._doc.addEventListener(`pointerup`,this._onPressEnd,!0),this._doc.addEventListener(`pointercancel`,this._onPressEnd,!0),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this.hasAttribute(`open`)&&!this.open&&(this._pinned=!0,this.setOpen(!0,{focus:!1})),this._syncTrigger()}attributeChangedCallback(e,t,n){e===`no-trigger`?this._syncTrigger():(this._mirroring||(this._pinned=n!==null),this._sheet()&&n!==null!==this.open&&this.setOpen(n!==null))}disconnectedCallback(){let e=this._sheet();e&&r(e),this._doc?.removeEventListener(`keydown`,this._onKeyDown),this._doc?.removeEventListener(`click`,this._onDocClick),this._doc?.removeEventListener(`pointerup`,this._onPressEnd,!0),this._doc?.removeEventListener(`pointercancel`,this._onPressEnd,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown,!0),this._doc=null}get open(){let e=this._sheet();return!!(e&&a(e))}set open(e){let t=e===!0||e===``||e===`true`;this._pinned=t,this._sheet()?t!==this.open&&this.setOpen(t):this.toggleAttribute(`open`,t)}setOpen(t,{focus:n=!0}={}){let o=this._sheet();if(!o)return;let s=h(this,`.wui-shortcut-toggle`);if(t||(this._pinned=!1),t){o.removeAttribute(`hidden`);let t=this.hasAttribute(`no-trigger`)?s??this:e(s,`<wui-shortcuts> needs its toggle to anchor the sheet.`);i(t,o,{mode:`auto`,side:`top`,align:`end`,flipAlign:!0,gap:8,keepOffscreen:this._pinned,onClosed:()=>{this._pinned=!1,this._mirror(!1)}})}else r(o);this._mirror(t),n&&(t?queueMicrotask(()=>{a(o)&&h(o,`.wui-shortcut-close`)?.focus()}):s?.focus())}_mirror(e){let t=this._sheet();t&&(t.hidden=!e),h(this,`.wui-shortcut-toggle`)?.setAttribute(`aria-expanded`,String(e)),this.hasAttribute(`open`)!==e&&(this._mirroring=!0,this.toggleAttribute(`open`,e),this._mirroring=!1,this.dispatchEvent(new CustomEvent(m,{bubbles:!0,detail:{open:e}})))}_sheet(){return h(this,`.wui-shortcut-sheet`)}_syncTrigger(){let e=h(this,`.wui-shortcut-toggle`);e&&(e.hidden=this.hasAttribute(`no-trigger`))}_scope(){let e=this.closest(`[${p}]`);return e instanceof HTMLElement?e:null}_items(){let t=this.getAttribute(`items`);return t?g(e(this._scope()??this._doc,`WuiShortcuts used before it was connected`),t):[]}_click(e){let t=e.target;if(t instanceof Element){if(t.closest(`.wui-shortcut-toggle`)){let e=this._pressedOpen;this._pressedOpen=!1,this.setOpen(!e&&!this.open)}else t.closest(`.wui-shortcut-close`)&&this.setOpen(!1)}}_tickFocused(){let t=this._items(),n=e(this._doc,`WuiShortcuts used before it was connected`).activeElement,r=n?.closest?.(`li, tr`),i=t.find(e=>e===n||e.contains(n)||r?.contains(e)),a=(i?.closest(`li, tr`)??i)?.querySelector(`input[type="checkbox"]`);a instanceof HTMLInputElement&&a.click()}_focusSearch(){let t=this.getAttribute(`search`);if(!t)return;let n=e(this._doc,`WuiShortcuts used before it was connected`);(h(this._scope()??n,t)??h(n,t))?.focus()}_keydown(t){if(t.defaultPrevented)return;let n=l(t);if(!n)return;if(n===`esc`&&this.open){t.preventDefault(),this.setOpen(!1);return}let r=this._scope(),i={help:()=>this.setOpen(!this.open)};if(this.getAttribute(`items`)&&(i.j=()=>s(this._items(),1),i.k=()=>s(this._items(),-1),i.x=()=>this._tickFocused()),this.getAttribute(`search`)&&(i.slash=()=>this._focusSearch()),i[n]){u(t,i,r);return}if(n===`enter`)return;let a=e(this._doc,`WuiShortcuts used before it was connected`),p=t.target instanceof Node?t.target:null;if(f(a)||!o(p,r)||d(p))return;let m=c(n),_=g(this,`.wui-shortcut-keys [data-shortcut]`).find(e=>e.dataset.shortcut===m);if(!_)return;let v=(r??a).querySelector(`[aria-current="true"]`)?.closest(`[data-key]`),y=v instanceof HTMLElement?v.dataset.key??null:null;if(!this.dispatchEvent(new CustomEvent(`wui:shortcut`,{bubbles:!0,cancelable:!0,detail:{key:m,itemKey:y}}))){t.preventDefault();return}let b=_.dataset.target,x=b?h(a,b):null;x&&(t.preventDefault(),x.click())}};export{_ as t};
@@ -1 +1 @@
1
- import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-Dh5iyZSR.js";import{t as r}from"./showMore.g-BdQ5MUSd.js";var i=3,a=()=>n(`showMore`,r),o=class extends t{_width;_observer;_toggle;_onClick;constructor(){super(),this._width=-1,this._observer=null,this._toggle=null,this._onClick=()=>this.toggle()}connectedCallback(){let e=this.querySelector(`.wui-show-more-toggle`);if(this._toggle=e instanceof HTMLButtonElement?e:null,!this._toggle)return;let t=Number.parseInt(this.getAttribute(`lines`)??``,10);this.style.setProperty(`--wui-show-more-lines`,String(t>=1?t:i)),this._toggle.addEventListener(`click`,this._onClick),this._sync(),this._check(),typeof ResizeObserver<`u`&&(this._observer=new ResizeObserver(()=>{this.clientWidth!==this._width&&this._check()}),this._observer.observe(this))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._toggle?.removeEventListener(`click`,this._onClick),this._toggle=null}get expanded(){return this.hasAttribute(`expanded`)}toggle(e=!this.expanded){this.toggleAttribute(`expanded`,!!e),this._sync(),this.dispatchEvent(new CustomEvent(`wui:show-more:toggle`,{bubbles:!0,detail:{expanded:this.expanded}}))}_sync(){let t=e(this._toggle,`WuiShowMore used before it was connected`),n=this.expanded;t.setAttribute(`aria-expanded`,String(n)),t.textContent=n?this.getAttribute(`less-label`)||a().lessLabel:this.getAttribute(`more-label`)||a().moreLabel}_check(){let t=this.querySelector(`.wui-show-more-body`);if(!(t instanceof HTMLElement))return;this._width=this.clientWidth;let n=this.expanded;n&&this.removeAttribute(`expanded`);let r=t.scrollHeight>t.clientHeight+1;n&&this.setAttribute(`expanded`,``);let i=e(this._toggle,`WuiShowMore used before it was connected`);i.hidden=!r}};export{o as t};
1
+ import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{r as n}from"./textStore-Cs1SGBoI.js";import{t as r}from"./showMore.g-BdQ5MUSd.js";var i=3,a=()=>n(`showMore`,r),o=class extends t{_width;_observer;_toggle;_onClick;constructor(){super(),this._width=-1,this._observer=null,this._toggle=null,this._onClick=()=>this.toggle()}connectedCallback(){let e=this.querySelector(`.wui-show-more-toggle`);if(this._toggle=e instanceof HTMLButtonElement?e:null,!this._toggle)return;let t=Number.parseInt(this.getAttribute(`lines`)??``,10);this.style.setProperty(`--wui-show-more-lines`,String(t>=1?t:i)),this._toggle.addEventListener(`click`,this._onClick),this._sync(),this._check(),typeof ResizeObserver<`u`&&(this._observer=new ResizeObserver(()=>{this.clientWidth!==this._width&&this._check()}),this._observer.observe(this))}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._toggle?.removeEventListener(`click`,this._onClick),this._toggle=null}get expanded(){return this.hasAttribute(`expanded`)}toggle(e=!this.expanded){this.toggleAttribute(`expanded`,!!e),this._sync(),this.dispatchEvent(new CustomEvent(`wui:show-more:toggle`,{bubbles:!0,detail:{expanded:this.expanded}}))}_sync(){let t=e(this._toggle,`WuiShowMore used before it was connected`),n=this.expanded;t.setAttribute(`aria-expanded`,String(n)),t.textContent=n?this.getAttribute(`less-label`)||a().lessLabel:this.getAttribute(`more-label`)||a().moreLabel}_check(){let t=this.querySelector(`.wui-show-more-body`);if(!(t instanceof HTMLElement))return;this._width=this.clientWidth;let n=this.expanded;n&&this.removeAttribute(`expanded`);let r=t.scrollHeight>t.clientHeight+1;n&&this.setAttribute(`expanded`,``);let i=e(this._toggle,`WuiShowMore used before it was connected`);i.hidden=!r}};export{o as t};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./digitGrouping-CCPI3HK3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{r as c,t as l}from"./textStore-Dh5iyZSR.js";import{t as u}from"./slider.g-BPNfxZEV.js";var d=()=>c(`slider`,u),f=class extends i{static formAssociated=!0;_internals;_value;_start;_end;_isDragging;_dragThumb;_pointerDownListener;_pointerMoveListener;_pointerUpListener;_thumbKeyListener;_trackClickListener;_rendered;_defaultsCaptured;_defaultValue;_defaultStart;_defaultEnd;static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(p(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(p(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(p(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(p(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(p(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(p(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return p(this.getAttribute(`min`),0)}_max(){return p(this.getAttribute(`max`),100)}_step(){return p(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),n=this._isRange(),i=this.getAttribute(`size`),o=i===`sm`?` slider-sm`:i===`lg`?` slider-lg`:``,s=this.hasAttribute(`disabled`),c=this.hasAttribute(`readonly`);n?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=n?[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":d().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":c?`true`:void 0,disabled:s}),r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":d().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":c?`true`:void 0,disabled:s})]:[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":c?`true`:void 0,disabled:s,"aria-label":this.getAttribute(`aria-label`)||d().ariaLabel})],f=r(`div`,{class:`wui-slider-rail`},r(`div`,{class:`slider-track`,role:`presentation`}),r(`div`,{class:`slider-fill`,role:`presentation`}),...u),p=this.hasAttribute(`show-value`)?r(`span`,{class:`slider-value`},n?l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren(r(`div`,{class:`slider${o}`},f,p)),this._rendered=!0,this._placeParts(),this._syncMirrors(),a(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?n(String(e)):String(e)}${t}`}_grouping(){let n=this.getAttribute(`grouping`)??`none`;if(!t(n))throw Error(e(n));return n}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=m(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(m(this,`[data-thumb="start"]`),i),s(m(this,`[data-thumb="end"]`),a)):s(m(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=m(this,`[data-thumb="start"]`),t=m(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=m(this,`.slider-value`);n&&(n.textContent=l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=m(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=m(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&s(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=h(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=m(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=m(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),o(this))return;let e=g(this,`.slider-thumb`),t=m(this,`.slider-track`),n=this._isRange(),r=e=>{if(o(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a))},i=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},a=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if(o(this))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),s=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=s+n):e.key===`PageDown`?(e.preventDefault(),i=s-r):e.key===`PageUp`?(e.preventDefault(),i=s+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if(o(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=i,this._pointerUpListener=a,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of g(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=m(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},p=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},m=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},h=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},g=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);export{f as t};
1
+ import{n as e,r as t,t as n}from"./digitGrouping-CCPI3HK3.js";import{r}from"./dom-DMQu--xV.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{r as a,t as o}from"./fieldState-D-zQcXUS.js";import{t as s}from"./formMirror-9IpSgeZb.js";import{r as c,t as l}from"./textStore-Cs1SGBoI.js";import{t as u}from"./slider.g-BPNfxZEV.js";var d=()=>c(`slider`,u),f=class extends i{static formAssociated=!0;_internals;_value;_start;_end;_isDragging;_dragThumb;_pointerDownListener;_pointerMoveListener;_pointerUpListener;_thumbKeyListener;_trackClickListener;_rendered;_defaultsCaptured;_defaultValue;_defaultStart;_defaultEnd;static get observedAttributes(){return[`min`,`max`,`step`,`value`,`start`,`end`,`name`,`start-name`,`end-name`,`disabled`,`readonly`,`loading`,`size`,`show-value`,`unit`,`grouping`,`aria-label`]}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}this._value=50,this._start=25,this._end=75,this._isDragging=!1,this._dragThumb=null,this._pointerDownListener=null,this._pointerMoveListener=null,this._pointerUpListener=null,this._thumbKeyListener=null,this._trackClickListener=null}connectedCallback(){this._rendered?this._wire():this.render()}get value(){return this._value}set value(e){this._value=this._snapToStep(this._clamp(p(e,this._value))),this._syncValue(),this._syncMirrors()}get start(){return this._start}set start(e){this._start=Math.min(this._snapToStep(this._clamp(p(e,this._start))),this._end),this._syncValue(),this._syncMirrors()}get end(){return this._end}set end(e){this._end=Math.max(this._snapToStep(this._clamp(p(e,this._end))),this._start),this._syncValue(),this._syncMirrors()}attributeChangedCallback(e,t,n){e===`value`||e===`start`||e===`end`||e===`min`||e===`max`||e===`step`?(this._updateFromAttribute(e),this._rendered&&(this._syncValue(),this._syncMirrors())):this._rendered&&this.render()}formResetCallback(){this._isRange()?this._resetRange():this._resetSingle()}_updateFromAttribute(e){e===`value`?this._value=this._snapToStep(this._clamp(p(this.getAttribute(`value`),this._value))):e===`start`?this._start=this._snapToStep(this._clamp(p(this.getAttribute(`start`),this._start))):e===`end`&&(this._end=this._snapToStep(this._clamp(p(this.getAttribute(`end`),this._end))))}_isRange(){return this.hasAttribute(`range`)}_min(){return p(this.getAttribute(`min`),0)}_max(){return p(this.getAttribute(`max`),100)}_step(){return p(this.getAttribute(`step`),1)}_clamp(e){return Math.max(this._min(),Math.min(e,this._max()))}_snapToStep(e){let t=this._step();if(t<=0)return e;let n=this._min();return this._clamp(n+Math.round((e-n)/t)*t)}_captureDefaults(){this._defaultsCaptured||=(this._isRange()?(this._defaultStart=this._start,this._defaultEnd=this._end):this._defaultValue=this._value,!0)}_resetSingle(){this._value=this._defaultValue??50,this._syncValue(),this._syncMirrors()}_resetRange(){this._start=this._defaultStart??25,this._end=this._defaultEnd??75,this._syncValue(),this._syncMirrors()}render(){this._captureDefaults();let e=this._min(),t=this._max(),n=this._isRange(),i=this.getAttribute(`size`),o=i===`sm`?` slider-sm`:i===`lg`?` slider-lg`:``,s=this.hasAttribute(`disabled`),c=this.hasAttribute(`readonly`);n?(this._start=this._clamp(this._start),this._end=this._clamp(this._end),this._start>this._end&&([this._start,this._end]=[this._end,this._start])):this._value=this._clamp(this._value);let u=n?[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`start`,"aria-label":d().minimumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._start,"aria-valuetext":this._formatValue(this._start),"aria-readonly":c?`true`:void 0,disabled:s}),r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`end`,"aria-label":d().maximumLabel,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._end,"aria-valuetext":this._formatValue(this._end),"aria-readonly":c?`true`:void 0,disabled:s})]:[r(`button`,{type:`button`,role:`slider`,class:`slider-thumb`,"data-thumb":`single`,"aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":this._value,"aria-valuetext":this._formatValue(this._value),"aria-readonly":c?`true`:void 0,disabled:s,"aria-label":this.getAttribute(`aria-label`)||d().ariaLabel})],f=r(`div`,{class:`wui-slider-rail`},r(`div`,{class:`slider-track`,role:`presentation`}),r(`div`,{class:`slider-fill`,role:`presentation`}),...u),p=this.hasAttribute(`show-value`)?r(`span`,{class:`slider-value`},n?l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}):this._formatValue(this._value)):!1;this.replaceChildren(r(`div`,{class:`slider${o}`},f,p)),this._rendered=!0,this._placeParts(),this._syncMirrors(),a(this,this.querySelector(`.slider`)),this._wire()}_formatValue(e){let t=this.getAttribute(`unit`)||``;return`${this._grouping()===`indian`?n(String(e)):String(e)}${t}`}_grouping(){let n=this.getAttribute(`grouping`)??`none`;if(!t(n))throw Error(e(n));return n}_placeParts(){let e=this._min(),t=this._max(),n=n=>t===e?0:(n-e)/(t-e),r=this._isRange(),i=r?n(this._start):0,a=n(r?this._end:this._value),o=m(this,`.slider-fill`);o&&(o.style.left=`${i*100}%`,o.style.right=`${100-a*100}%`,r&&o.style.setProperty(`--wui-fill-start`,String(i)),o.style.setProperty(`--wui-fill-end`,String(a)));let s=(e,t)=>{e&&(e.style.left=`${t*100}%`,e.style.setProperty(`--wui-t`,String(t)))};r?(s(m(this,`[data-thumb="start"]`),i),s(m(this,`[data-thumb="end"]`),a)):s(m(this,`.slider-thumb`),a)}_syncValue(){if(this._rendered){if(this._placeParts(),this._isRange()){let e=m(this,`[data-thumb="start"]`),t=m(this,`[data-thumb="end"]`);e&&(e.setAttribute(`aria-valuenow`,String(this._start)),e.setAttribute(`aria-valuetext`,this._formatValue(this._start))),t&&(t.setAttribute(`aria-valuenow`,String(this._end)),t.setAttribute(`aria-valuetext`,this._formatValue(this._end)));let n=m(this,`.slider-value`);n&&(n.textContent=l(d().rangeText,{start:this._formatValue(this._start),end:this._formatValue(this._end)}))}else{let e=m(this,`.slider-thumb`);e&&(e.setAttribute(`aria-valuenow`,String(this._value)),e.setAttribute(`aria-valuetext`,this._formatValue(this._value)));let t=m(this,`.slider-value`);t&&(t.textContent=this._formatValue(this._value))}}}_syncMirrors(){this._isRange()?this._syncRangeMirrors():this._syncSingleMirror()}_syncSingleMirror(){this.getAttribute(`name`)&&s(this,String(this._value))}_syncRangeMirrors(){let e=this.getAttribute(`start-name`),t=this.getAttribute(`end-name`);this._mirrorRange(`start`,e,this._start),this._mirrorRange(`end`,t,this._end)}_mirrorRange(e,t,n){if(!t)return;let r=h(this,`input[type="hidden"][data-slider-mirror="${e}"]`);r||(r=document.createElement(`input`),r.type=`hidden`,r.setAttribute(`data-slider-mirror`,e),this.appendChild(r)),r.name=t,r.value=String(n),r.disabled=this.hasAttribute(`disabled`)}_valueAtPosition(e){let t=m(this,`.slider-track`);if(!t)return this._min();let n=t.getBoundingClientRect(),r=m(this,`.slider-thumb`),i=r?r.offsetWidth/2:0,a=n.width-i*2,o=a>0?Math.max(0,Math.min(1,(e-n.left-i)/a)):0,s=this._min()+o*(this._max()-this._min());return this._snapToStep(s)}_nearestThumb(e){return Math.abs(e-this._start)<=Math.abs(e-this._end)?`start`:`end`}_wire(){if(this._teardown(),o(this))return;let e=g(this,`.slider-thumb`),t=m(this,`.slider-track`),n=this._isRange(),r=e=>{if(o(this))return;let t=e.target;if(!(t instanceof Element))throw Error(`Pointer event target is not an element`);let n=t.closest(`.slider-thumb`);n&&(e.preventDefault(),this._isDragging=!0,this._dragThumb=n.getAttribute(`data-thumb`),document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a))},i=e=>{if(!this._isDragging)return;e.preventDefault();let t=this._valueAtPosition(e.clientX);if(this._dragThumb===`single`)this._value=this._clamp(t),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{value:this._value}}));else if(this._dragThumb===`start`){let e=Math.min(t,this._end);this._start=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}else if(this._dragThumb===`end`){let e=Math.max(t,this._start);this._end=this._clamp(e),this._syncValue(),this.dispatchEvent(new CustomEvent(`slide`,{detail:{start:this._start,end:this._end}}))}},a=()=>{this._isDragging&&(this._isDragging=!1,this._dragThumb=null,document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},s=e=>{if(!(e.currentTarget instanceof HTMLElement))throw Error(`Keyboard event target is not an element`);let t=e.currentTarget;if(o(this))return;let n=this._step(),r=n*10,i=null,a=t.getAttribute(`data-thumb`),s=a===`end`?this._end:a===`start`?this._start:this._value;e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),i=s-n):e.key===`ArrowRight`||e.key===`ArrowUp`?(e.preventDefault(),i=s+n):e.key===`PageDown`?(e.preventDefault(),i=s-r):e.key===`PageUp`?(e.preventDefault(),i=s+r):e.key===`Home`?(e.preventDefault(),i=this._min()):e.key===`End`&&(e.preventDefault(),i=this._max()),i!=null&&(i=this._clamp(i),a===`single`?this._value=i:a===`start`?this._start=Math.min(i,this._end):a===`end`&&(this._end=Math.max(i,this._start)),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0})))},c=e=>{if(o(this))return;let t=this._valueAtPosition(e.clientX);n?this._nearestThumb(t)===`start`?this._start=Math.min(this._clamp(t),this._end):this._end=Math.max(this._clamp(t),this._start):this._value=this._clamp(t),this._syncValue(),this._syncMirrors(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))};this._pointerDownListener=r,this._pointerMoveListener=i,this._pointerUpListener=a,this._thumbKeyListener=s,this._trackClickListener=c,e.forEach(e=>{e.addEventListener(`pointerdown`,r),e.addEventListener(`keydown`,s)}),t?.addEventListener(`click`,c)}_teardown(){for(let e of g(this,`.slider-thumb`))this._pointerDownListener&&e.removeEventListener(`pointerdown`,this._pointerDownListener),this._thumbKeyListener&&e.removeEventListener(`keydown`,this._thumbKeyListener);this._pointerMoveListener&&document.removeEventListener(`pointermove`,this._pointerMoveListener),this._pointerUpListener&&(document.removeEventListener(`pointerup`,this._pointerUpListener),document.removeEventListener(`pointercancel`,this._pointerUpListener)),this._isDragging=!1,this._dragThumb=null;let e=m(this,`.slider-track`);e&&this._trackClickListener&&e.removeEventListener(`click`,this._trackClickListener)}disconnectedCallback(){this._teardown()}},p=(e,t)=>{let n=Number.parseFloat(String(e));return Number.isFinite(n)?n:t},m=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},h=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLInputElement?n:null},g=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement);export{f as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./formMirror-9IpSgeZb.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i,t as a}from"./textStore-Dh5iyZSR.js";import{t as o}from"./sortable.g-BsTKys5-.js";var s=()=>i(`sortable`,o),c=/* @__PURE__ */ new Set,l=`.wui-sortable-handle`,u=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,d=4,f=8,p=250,m=48,h=18,g=class extends e{_drag;_kb;_moving;controlled;_observer;_onDragStart;_onDocTouchMove;_onSelectStart;static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){c.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){c.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){t(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let i=this._items().filter(t=>t!==e),a=this._horizontal(),o=r(this);for(let[e,r]of i.entries()){let i=r.getBoundingClientRect(),s=n<=i.bottom&&(o?t>i.left+i.width/2:t<i.left+i.width/2);if(a?n<i.top||s:n<i.top+i.height/2)return e}return i.length}_peers(){let e=this.getAttribute(`group`);return[...c].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return a(s().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${l}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(u);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?f:d,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},p)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=v(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=_(e.y,r,i),c=_(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),c=r.order,l=r!==t,u=t.order;l&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let d=r._labelOf(e),f=l&&r.getAttribute(`aria-label`)?a(s().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};l&&this._emit(t,`wui-sortable:change`,{...p,ids:u}),this._emit(r,`wui-sortable:change`,{...p,ids:c}),r._announce(a(s().movedPositionText,{label:String(d),destination:f,position:i+1,total:c.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let i=t.closest(l),o=i instanceof HTMLElement?i:null,c=o&&o.parentElement?.parentElement===this?o.parentElement:null;if(!o||!c||this._itemDisabled(c)||this._drag)return;let u=n(e.key,r(this));if(!this._kb){if(u!==` `&&u!==`Enter`)return;e.preventDefault(),this._liftKeyboard(c,o)}else if(this._kb.item===c){if(u===` `||u===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(u===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(u)){e.preventDefault();let t=this._items(),n=t.indexOf(c),r=t.length-1,i=u===`Home`?0:u===`End`?r:Math.max(0,Math.min(r,n+(u===`ArrowUp`||u===`ArrowLeft`?-1:1)));if(i===n){let e=s();this._announce(a(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(c)),position:this._position(c)}));return}this._moveFocused(()=>this._insertAt(c,i),o),this._announce(a(s().movedText,{label:String(this._labelOf(c)),position:this._position(c)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce(a(s().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce(a(s().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce(a(s().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function _(e,t,n){return e<t+m?-Math.ceil(h*Math.min(1,(t+m-e)/m)):e>n-m?Math.ceil(h*Math.min(1,(e-(n-m))/m)):0}function v(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}export{g as t};
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t}from"./formMirror-9IpSgeZb.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i,t as a}from"./textStore-Cs1SGBoI.js";import{t as o}from"./sortable.g-BsTKys5-.js";var s=()=>i(`sortable`,o),c=/* @__PURE__ */ new Set,l=`.wui-sortable-handle`,u=`a[href],button,input,select,textarea,label,summary,[contenteditable='true'],[role='button'],[role='link']`,d=4,f=8,p=250,m=48,h=18,g=class extends e{_drag;_kb;_moving;controlled;_observer;_onDragStart;_onDocTouchMove;_onSelectStart;static get observedAttributes(){return[`name`,`disabled`]}constructor(){super(),this._drag=null,this._kb=null,this._moving=!1,this.controlled=!1,this._observer=null,this._onPointerDown=this._onPointerDown.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onDragStart=e=>e.preventDefault(),this._onDocMove=this._onDocMove.bind(this),this._onDocUp=this._onDocUp.bind(this),this._onDocCancel=this._onDocCancel.bind(this),this._onDocKey=this._onDocKey.bind(this),this._onDocTouchMove=e=>{this._drag?.started&&e.preventDefault()},this._onSelectStart=e=>e.preventDefault(),this._scrollTick=this._scrollTick.bind(this)}connectedCallback(){c.add(this),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`dragstart`,this._onDragStart),this._observer=new MutationObserver(()=>this._syncMirrors()),this._observer.observe(this,{childList:!0}),this._syncMirrors()}disconnectedCallback(){c.delete(this),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`dragstart`,this._onDragStart),this._observer?.disconnect(),this._observer=null,this._abort()}attributeChangedCallback(e){e===`disabled`&&this._abort(),this.isConnected&&this._syncMirrors()}get order(){return this._items().map(e=>e.getAttribute(`data-id`))}set order(e){if(this._drag?.started||this._kb)return;let t=this._items(),n=new Map(t.map(e=>[e.getAttribute(`data-id`),e])),r=[];for(let t of e??[]){let e=n.get(String(t));e&&!r.includes(e)&&r.push(e)}[...r,...t.filter(e=>!r.includes(e))].forEach((e,t)=>{let n=this._items()[t]??null;n!==e&&this.insertBefore(e,n)}),this._syncMirrors()}_items(){return[...this.querySelectorAll(`:scope > [data-id]`)].filter(e=>e instanceof HTMLElement)}_itemFrom(e){let t=e;for(;t&&t.parentElement!==this;)t=t.parentElement;return t instanceof HTMLElement&&t.hasAttribute(`data-id`)?t:null}_itemDisabled(e){return e.hasAttribute(`data-disabled`)}_horizontal(){return this.getAttribute(`orientation`)===`horizontal`}_syncMirrors(){t(this,this.order.map(e=>e??``))}_insertAt(e,t){let n=this._items();if(n.indexOf(e)===t)return;let r=n.filter(t=>t!==e),i=r[t]??null;i?this.insertBefore(e,i):r.length>0?r[r.length-1]?.after(e):this.appendChild(e)}_indexFor(e,t,n){let i=this._items().filter(t=>t!==e),a=this._horizontal(),o=r(this);for(let[e,r]of i.entries()){let i=r.getBoundingClientRect(),s=n<=i.bottom&&(o?t>i.left+i.width/2:t<i.left+i.width/2);if(a?n<i.top||s:n<i.top+i.height/2)return e}return i.length}_peers(){let e=this.getAttribute(`group`);return[...c].filter(t=>t===this||e&&t.getAttribute(`group`)===e&&!t.hasAttribute(`disabled`))}_labelOf(e){return e.getAttribute(`data-label`)||(e.textContent??``).replace(/\s+/g,` `).trim()||e.getAttribute(`data-id`)}_announce(e){let t=this.querySelector(`:scope > .wui-sortable-live`);t||(t=document.createElement(`div`),t.className=`wui-sortable-live`,t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-atomic`,`true`),this.appendChild(t)),t.textContent=e}_position(e){let t=this._items();return a(s().positionText,{position:t.indexOf(e)+1,total:t.length})}_onPointerDown(e){if(this._drag||this._kb||this.hasAttribute(`disabled`)||e.pointerType===`mouse`&&e.button!==0)return;let t=e.target;if(!(t instanceof Element))return;let n=this._itemFrom(t);if(!n||this._itemDisabled(n))return;let r=n.querySelector(`:scope > ${l}`),i=!!r&&r.contains(t);if(this.hasAttribute(`handle`)&&!i)return;if(!i){let e=t.closest?.(u);if(e&&e!==n&&n.contains(e))return}let a=e.pointerType===`touch`&&!i,o={item:n,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY,slop:e.pointerType===`touch`?f:d,ready:!a,started:!1,timer:null,raf:0,list:this,ghost:null,offsetX:0,offsetY:0,fromIndex:0};this._drag=o,a&&(o.timer=setTimeout(()=>{o.timer=null,o.ready=!0,this._begin()},p)),document.addEventListener(`pointermove`,this._onDocMove),document.addEventListener(`pointerup`,this._onDocUp),document.addEventListener(`pointercancel`,this._onDocCancel),document.addEventListener(`keydown`,this._onDocKey,!0),document.addEventListener(`touchmove`,this._onDocTouchMove,{passive:!1})}_onDocMove(e){let t=this._drag;if(t&&e.pointerId===t.pointerId){if(t.x=e.clientX,t.y=e.clientY,!t.started){let e=Math.hypot(t.x-t.startX,t.y-t.startY);if(!t.ready){e>t.slop&&this._finish(!0);return}if(e<t.slop||(this._begin(),!this._drag?.started))return}e.preventDefault?.(),this._moveGhost(),this._update()}}_onDocUp(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!1)}_onDocCancel(e){this._drag&&e.pointerId===this._drag.pointerId&&this._finish(!0)}_onDocKey(e){e.key===`Escape`&&this._drag&&(e.preventDefault(),e.stopPropagation(),this._finish(!0))}_begin(){let e=this._drag;if(!e||e.started)return;e.started=!0;let t=e.item.getBoundingClientRect();e.offsetX=e.startX-t.left,e.offsetY=e.startY-t.top,e.fromIndex=this._items().indexOf(e.item);let n=e.item.cloneNode(!0);if(!(n instanceof HTMLElement))throw Error(`drag ghost is not an HTML element`);for(let e of[n,...n.querySelectorAll(`[id],[data-id]`)])e.removeAttribute(`id`),e.removeAttribute(`data-id`);n.classList.add(`wui-sortable-ghost`),n.setAttribute(`aria-hidden`,`true`),n.inert=!0,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,e.ghost=n,e.item.classList.add(`wui-sortable-dragging`),document.body.appendChild(n),document.documentElement.classList.add(`wui-sortable-active`),document.addEventListener(`selectstart`,this._onSelectStart),this._moveGhost(),e.raf=requestAnimationFrame(this._scrollTick),this._emit(this,`wui-sortable:start`,{id:e.item.getAttribute(`data-id`)})}_moveGhost(){let e=this._drag;e?.ghost&&(e.ghost.style.transform=`translate(${e.x-e.offsetX}px, ${e.y-e.offsetY}px)`)}_update(){let e=this._drag;if(!e?.started)return;let t=e.list;for(let n of this._peers()){let r=n.getBoundingClientRect();if(e.x>=r.left&&e.x<=r.right&&e.y>=r.top&&e.y<=r.bottom){t=n;break}}let n=t._indexFor(e.item,e.x,e.y);(t!==e.list||n!==t._items().indexOf(e.item))&&t._insertAt(e.item,n),e.list=t}_scrollTick(){let e=this._drag;if(!e?.started)return;let t=v(e.list),n=t?t.getBoundingClientRect():null,r=Math.max(n?.top??0,0),i=Math.min(n?.bottom??window.innerHeight,window.innerHeight),a=Math.max(n?.left??0,0),o=Math.min(n?.right??window.innerWidth,window.innerWidth),s=_(e.y,r,i),c=_(e.x,a,o);(c||s)&&(t?(t.scrollTop+=s,t.scrollLeft+=c):window.scrollBy(c,s),this._update()),e.raf=requestAnimationFrame(this._scrollTick)}_finish(e){let t=this._drag;if(!t||(this._drag=null,clearTimeout(t.timer??void 0),cancelAnimationFrame(t.raf),document.removeEventListener(`pointermove`,this._onDocMove),document.removeEventListener(`pointerup`,this._onDocUp),document.removeEventListener(`pointercancel`,this._onDocCancel),document.removeEventListener(`keydown`,this._onDocKey,!0),document.removeEventListener(`touchmove`,this._onDocTouchMove),document.removeEventListener(`selectstart`,this._onSelectStart),!t.started))return;t.ghost?.remove(),document.documentElement.classList.remove(`wui-sortable-active`),t.item.classList.remove(`wui-sortable-dragging`);let n=t.item.getAttribute(`data-id`);e?(this._insertAt(t.item,t.fromIndex),this._syncMirrors(),t.list!==this&&t.list._syncMirrors()):this._settle(t.item,this,t.fromIndex,t.list),this._emit(this,`wui-sortable:end`,{id:n,cancelled:e})}_settle(e,t,n,r){let i=r._items().indexOf(e);if(r===t&&i===n)return;let o=e.getAttribute(`data-id`),c=r.order,l=r!==t,u=t.order;l&&(t.controlled||r.controlled)&&t._insertAt(e,n),t._syncMirrors(),r._syncMirrors();let d=r._labelOf(e),f=l&&r.getAttribute(`aria-label`)?a(s().destinationText,{destination:String(r.getAttribute(`aria-label`))}):``,p={id:o,fromIndex:n,toIndex:i,from:t,to:r};l&&this._emit(t,`wui-sortable:change`,{...p,ids:u}),this._emit(r,`wui-sortable:change`,{...p,ids:c}),r._announce(a(s().movedPositionText,{label:String(d),destination:f,position:i+1,total:c.length}))}_emit(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}_abort(){this._drag&&this._finish(!0),this._kb&&this._dropKeyboard(!0)}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=e.target;if(!(t instanceof Element))return;let i=t.closest(l),o=i instanceof HTMLElement?i:null,c=o&&o.parentElement?.parentElement===this?o.parentElement:null;if(!o||!c||this._itemDisabled(c)||this._drag)return;let u=n(e.key,r(this));if(!this._kb){if(u!==` `&&u!==`Enter`)return;e.preventDefault(),this._liftKeyboard(c,o)}else if(this._kb.item===c){if(u===` `||u===`Enter`)e.preventDefault(),this._dropKeyboard(!1);else if(u===`Escape`)e.preventDefault(),e.stopPropagation(),this._dropKeyboard(!0);else if([`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`,`Home`,`End`].includes(u)){e.preventDefault();let t=this._items(),n=t.indexOf(c),r=t.length-1,i=u===`Home`?0:u===`End`?r:Math.max(0,Math.min(r,n+(u===`ArrowUp`||u===`ArrowLeft`?-1:1)));if(i===n){let e=s();this._announce(a(n===0?e.alreadyFirstText:e.alreadyLastText,{label:String(this._labelOf(c)),position:this._position(c)}));return}this._moveFocused(()=>this._insertAt(c,i),o),this._announce(a(s().movedText,{label:String(this._labelOf(c)),position:this._position(c)}))}}}_onFocusOut(e){if(!this._kb||this._moving)return;let t=e.relatedTarget;if(t&&!(t instanceof Node))throw Error(`focus moved to a non-node target`);t&&this._kb.handle.contains(t)||this._dropKeyboard(!1)}_liftKeyboard(e,t){this._kb={item:e,handle:t,fromIndex:this._items().indexOf(e)},t.setAttribute(`aria-pressed`,`true`),this._announce(a(s().liftedText,{label:String(this._labelOf(e)),position:this._position(e)}))}_dropKeyboard(e){let t=this._kb;t&&(this._kb=null,t.handle.removeAttribute(`aria-pressed`),e?(this._moveFocused(()=>this._insertAt(t.item,t.fromIndex),t.handle),this._announce(a(s().reorderCancelledText,{label:String(this._labelOf(t.item)),position:this._position(t.item)}))):this._items().indexOf(t.item)===t.fromIndex?this._announce(a(s().droppedText,{label:String(this._labelOf(t.item)),position:this._position(t.item)})):this._settle(t.item,this,t.fromIndex,this))}_moveFocused(e,t){this._moving=!0;let n=this.contains(document.activeElement);e(),n&&document.activeElement!==t&&t.focus(),this._moving=!1}};function _(e,t,n){return e<t+m?-Math.ceil(h*Math.min(1,(t+m-e)/m)):e>n-m?Math.ceil(h*Math.min(1,(e-(n-m))/m)):0}function v(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let e=getComputedStyle(t),n=/(auto|scroll)/.test(e.overflowY)&&t.scrollHeight>t.clientHeight,r=/(auto|scroll)/.test(e.overflowX)&&t.scrollWidth>t.clientWidth;if(n||r)return t}return null}export{g as t};