@webority/ui-elements 0.171.3 → 0.172.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/dist/WuiCarousel-CFKmFVzc.js +1 -0
  2. package/dist/{WuiCodeBlock-Du-JZO3A.js → WuiCodeBlock-fBc3Uwsw.js} +1 -1
  3. package/dist/{WuiCommandPalette-BKW0e-ho.js → WuiCommandPalette-BQCy0bon.js} +2 -2
  4. package/dist/WuiCommentThread-jy4rMc9Q.js +1 -0
  5. package/dist/WuiConsentBanner-DlAE3DTf.js +1 -0
  6. package/dist/WuiContextMenu-hLeCs0qw.js +1 -0
  7. package/dist/WuiDataTable-B-JaTsrI.js +1 -0
  8. package/dist/WuiDatePicker-4tdWakGX.js +1 -0
  9. package/dist/WuiDateRange-D7LJuY2F.js +1 -0
  10. package/dist/WuiDateTime-BSJfyZ0q.js +1 -0
  11. package/dist/{WuiDock-d5abaLkL.js → WuiDock-2LGlbEFx.js} +1 -1
  12. package/dist/{WuiDrawer-BMkPnEFz.js → WuiDrawer-D-XfW1kl.js} +1 -1
  13. package/dist/{WuiDropdown-B9WeT-gH.js → WuiDropdown-5-6E5Q9d.js} +1 -1
  14. package/dist/{WuiEntryGrid-Bm5_MizA.js → WuiEntryGrid-DkW0tIDy.js} +1 -1
  15. package/dist/WuiGantt-XMvgsZsn.js +1 -0
  16. package/dist/{WuiHoverCard-D6JBAqdW.js → WuiHoverCard-DhJcIIM1.js} +1 -1
  17. package/dist/WuiImageCrop-CIAjHOGk.js +1 -0
  18. package/dist/WuiInlineEdit-C9FxCWCk.js +1 -0
  19. package/dist/WuiLeadPopup-KyguGV-q.js +345 -0
  20. package/dist/WuiLightbox-CBiqJmGE.js +1 -0
  21. package/dist/WuiMarkdown-DsN4YbiZ.js +4 -0
  22. package/dist/WuiMentionInput-CktKQjQc.js +1 -0
  23. package/dist/{WuiModal-DMGgOCBU.js → WuiModal-DQbVJGUo.js} +1 -1
  24. package/dist/WuiNavigationMenu-KdW7yuLn.js +1 -0
  25. package/dist/{WuiNotificationCenter-DgcJYPV3.js → WuiNotificationCenter-DZariS2K.js} +1 -1
  26. package/dist/WuiOrgTree-CFxoY9Vr.js +1 -0
  27. package/dist/WuiOtp-Cc0formv.js +1 -0
  28. package/dist/{WuiOverflow-MzrZwzud.js → WuiOverflow-CXYk2ubC.js} +1 -1
  29. package/dist/WuiPhone-BI438y4S.js +1 -0
  30. package/dist/{WuiPopover-BYO_H-fk.js → WuiPopover-BvWKRNQY.js} +1 -1
  31. package/dist/{WuiRating-DLVduJZ_.js → WuiRating-DIQfif9x.js} +1 -1
  32. package/dist/{WuiRecordPager-Dye7AfCS.js → WuiRecordPager-DAyoD650.js} +1 -1
  33. package/dist/{WuiRelativeTime-CujAFS_w.js → WuiRelativeTime-CPzs4tjM.js} +1 -1
  34. package/dist/WuiSavedViews-BAqHgVj2.js +1 -0
  35. package/dist/WuiSelect-htggZB0v.js +1 -0
  36. package/dist/{WuiShortcuts-Crj8lFVz.js → WuiShortcuts-DWzmRKEG.js} +1 -1
  37. package/dist/{WuiShowMore-CGhWrlmK.js → WuiShowMore-DyfGnrob.js} +1 -1
  38. package/dist/WuiSlider-LE2wquOo.js +1 -0
  39. package/dist/WuiSortable-DxwYjicc.js +1 -0
  40. package/dist/WuiTimePicker-xrPYytjq.js +1 -0
  41. package/dist/WuiTour-D-H5sMJS.js +1 -0
  42. package/dist/WuiTree-BnlK9fYL.js +1 -0
  43. package/dist/WuiTreePicker-Bx9nvRrC.js +1 -0
  44. package/dist/{WuiWhatsNew-DjnQWqlF.js → WuiWhatsNew-Dm4Yl68x.js} +1 -1
  45. package/dist/WuiWizardStep-n8Ge5GDI.js +1 -0
  46. package/dist/anchorOverlay-daGdh_91.js +1 -0
  47. package/dist/avatarNode-BaEvz5Xr.js +1 -0
  48. package/dist/{calendarMath-DIoh4HjR.js → calendarMath-rI1aBVRd.js} +1 -1
  49. package/dist/chips-DrTvHdbb.js +2 -0
  50. package/dist/{dataTable-oR_YiFJc.js → dataTable-Bz6HxUx0.js} +1 -1
  51. package/dist/dataTable.g-DazoWWps.js +1 -0
  52. package/dist/datePicker.g-sGQE8c3n.js +1 -0
  53. package/dist/dom-DMQu--xV.js +1 -0
  54. package/dist/drawerDiscard-B33Oc_Sv.js +1 -0
  55. package/dist/elements/carousel.js +1 -1
  56. package/dist/elements/code-block.js +1 -1
  57. package/dist/elements/command-palette.js +1 -1
  58. package/dist/elements/comment-thread.js +1 -1
  59. package/dist/elements/consent-banner.js +1 -1
  60. package/dist/elements/context-menu.js +1 -1
  61. package/dist/elements/data-table.js +1 -1
  62. package/dist/elements/date-range.js +1 -1
  63. package/dist/elements/date-time.js +1 -0
  64. package/dist/elements/datepicker.js +1 -1
  65. package/dist/elements/dock.js +1 -1
  66. package/dist/elements/drawer.js +1 -1
  67. package/dist/elements/dropdown.js +1 -1
  68. package/dist/elements/entry-grid.js +1 -1
  69. package/dist/elements/filter-popover.js +1 -1
  70. package/dist/elements/gantt.js +1 -1
  71. package/dist/elements/hover-card.js +1 -1
  72. package/dist/elements/image-crop.js +1 -1
  73. package/dist/elements/inline-edit.js +1 -1
  74. package/dist/elements/kanban.js +1 -1
  75. package/dist/elements/lead-popup.js +1 -1
  76. package/dist/elements/lightbox.js +1 -1
  77. package/dist/elements/markdown.js +1 -1
  78. package/dist/elements/mention-input.js +1 -1
  79. package/dist/elements/modal.js +1 -1
  80. package/dist/elements/navigation-menu.js +1 -1
  81. package/dist/elements/notification-center.js +1 -1
  82. package/dist/elements/org-tree.js +1 -1
  83. package/dist/elements/otp.js +1 -1
  84. package/dist/elements/overflow.js +1 -1
  85. package/dist/elements/phone.js +1 -1
  86. package/dist/elements/popover.js +1 -1
  87. package/dist/elements/rating.js +1 -1
  88. package/dist/elements/record-pager.js +1 -1
  89. package/dist/elements/relative-time.js +1 -1
  90. package/dist/elements/saved-views.js +1 -1
  91. package/dist/elements/select.js +1 -1
  92. package/dist/elements/shortcuts.js +1 -1
  93. package/dist/elements/show-more.js +1 -1
  94. package/dist/elements/slider.js +1 -1
  95. package/dist/elements/sortable.js +1 -1
  96. package/dist/elements/status-icon.js +1 -1
  97. package/dist/elements/timepicker.js +1 -1
  98. package/dist/elements/tour.js +1 -1
  99. package/dist/elements/tree-picker.js +1 -1
  100. package/dist/elements/tree.js +1 -1
  101. package/dist/elements/whats-new.js +1 -1
  102. package/dist/elements/wizard.js +1 -1
  103. package/dist/fileViewer.g-B6N9K2xi.js +1 -0
  104. package/dist/{fileViewerImage-uL9m83k1.js → fileViewerImage-ItX9j9U9.js} +2 -2
  105. package/dist/fileViewerMedia-BCqp2Z96.js +1 -0
  106. package/dist/{fileViewerPdf-BsSc-9fL.js → fileViewerPdf-aaI2R2nB.js} +2 -2
  107. package/dist/{filterPopover-C_oDfQBg.js → filterPopover-D7LGrhnO.js} +1 -1
  108. package/dist/formatters-DikbTYA4.js +1 -0
  109. package/dist/helpers.js +1 -1
  110. package/dist/iconGlyphs.g-P04RJkSE.js +1 -0
  111. package/dist/{inlineEditText-CGaAKZhR.js → inlineEditText-C6g6qhye.js} +1 -1
  112. package/dist/kanban-CX6DyApZ.js +1 -0
  113. package/dist/{kanbanModel-sAwpMCpn.js → kanbanModel-CuMgMnSc.js} +1 -1
  114. package/dist/loader-B3lirubB.js +1 -0
  115. package/dist/{nativeOverlay-DGady-wN.js → nativeOverlay-BHD2QV02.js} +1 -1
  116. package/dist/{notificationDays-DQlrEZ3z.js → notificationDays-grsj1DtM.js} +1 -1
  117. package/dist/optionLabel-CmrOSHbD.js +1 -0
  118. package/dist/{relativeTime-CQuwuwZ-.js → relativeTime-vdCXtfKg.js} +1 -1
  119. package/dist/rtl-g7G8Bsib.js +1 -0
  120. package/dist/{search-w5M6FzD9.js → search-DwboX91o.js} +1 -1
  121. package/dist/server.js +1 -1
  122. package/dist/serverHtml-BC6tAyAl.js +1 -0
  123. package/dist/{shortcutKeys-DmPiY4T7.js → shortcutKeys-6iLc6oDR.js} +1 -1
  124. package/dist/statusIcons-Cd3GJcBR.js +1 -0
  125. package/dist/svgNodes-CyPS2oFH.js +1 -0
  126. package/dist/tableExport-D1OdFVQj.js +2 -0
  127. package/dist/tableSelect.g-Bmd-ExRE.js +1 -0
  128. package/dist/text/en.json +14 -2
  129. package/dist/text.js +1 -1
  130. package/dist/{themeTransition-CA1qzCZk.js → themeTransition-D7HJ4A4m.js} +1 -1
  131. package/dist/ui-calendar.global.js +1 -1
  132. package/dist/ui-calendar.js +1 -1
  133. package/dist/ui-chart.global.js +15 -15
  134. package/dist/ui-chart.js +10 -10
  135. package/dist/ui-consent-banner.global.js +1 -1
  136. package/dist/ui-elements/carousel.global.js +1 -1
  137. package/dist/ui-elements/code-block.global.js +1 -1
  138. package/dist/ui-elements/command-palette.global.js +2 -2
  139. package/dist/ui-elements/comment-thread.global.js +1 -1
  140. package/dist/ui-elements/consent-banner.global.js +1 -1
  141. package/dist/ui-elements/context-menu.global.js +1 -1
  142. package/dist/ui-elements/date-range.global.js +1 -25
  143. package/dist/ui-elements/date-time.global.js +1 -0
  144. package/dist/ui-elements/datepicker.global.js +1 -0
  145. package/dist/ui-elements/drawer.global.js +1 -1
  146. package/dist/ui-elements/dropdown.global.js +1 -1
  147. package/dist/ui-elements/entry-grid.global.js +1 -1
  148. package/dist/ui-elements/gantt.global.js +1 -1
  149. package/dist/ui-elements/glyphs.global.js +1 -1
  150. package/dist/ui-elements/image-crop.global.js +1 -17
  151. package/dist/ui-elements/inline-edit.global.js +1 -1
  152. package/dist/ui-elements/kanban.global.js +1 -1
  153. package/dist/ui-elements/lead-popup.global.js +40 -77
  154. package/dist/ui-elements/lightbox.global.js +1 -1
  155. package/dist/ui-elements/markdown.global.js +3 -3
  156. package/dist/ui-elements/org-tree.global.js +1 -1
  157. package/dist/ui-elements/phone.global.js +1 -16
  158. package/dist/ui-elements/popover.global.js +1 -1
  159. package/dist/ui-elements/saved-views.global.js +1 -1
  160. package/dist/ui-elements/select-chips.global.js +2 -2
  161. package/dist/ui-elements/select-recents.global.js +1 -1
  162. package/dist/ui-elements/select-search.global.js +1 -1
  163. package/dist/ui-elements/select-window.global.js +1 -1
  164. package/dist/ui-elements/slider.global.js +1 -51
  165. package/dist/ui-elements/sortable.global.js +1 -1
  166. package/dist/ui-elements/status-icon.global.js +1 -10
  167. package/dist/ui-elements/table-export.global.js +2 -0
  168. package/dist/ui-elements/timepicker.global.js +1 -9
  169. package/dist/ui-elements/tour.global.js +1 -1
  170. package/dist/ui-elements/tree-picker.global.js +1 -1
  171. package/dist/ui-elements/tree.global.js +1 -1
  172. package/dist/ui-elements/wizard.global.js +1 -1
  173. package/dist/ui-elements.global.js +1 -55
  174. package/dist/ui-elements.js +1 -1
  175. package/dist/ui-file-viewer.global.js +11 -11
  176. package/dist/ui-file-viewer.js +1 -1
  177. package/dist/ui-lead-popup.global.js +1 -1
  178. package/dist/ui-rich-text.global.js +53 -63
  179. package/dist/ui-rich-text.js +53 -63
  180. package/dist/ui-tour.global.js +1 -1
  181. package/dist/wuiHttp-BWf9dDsZ.js +1 -0
  182. package/dist/zone-BR02ZkHF.js +1 -0
  183. package/package.json +10 -6
  184. package/types/WuiCommandPalette.d.ts +0 -60
  185. package/types/WuiDataTable.d.ts +2 -0
  186. package/types/WuiDatePicker.d.ts +6 -4
  187. package/types/WuiDateRange.d.ts +2 -2
  188. package/types/WuiDateTime.d.ts +26 -0
  189. package/types/WuiInlineEdit.d.ts +1 -1
  190. package/types/WuiLeadPopup.d.ts +1 -1
  191. package/types/WuiMarkdown.d.ts +4 -4
  192. package/types/WuiNavigationMenu.d.ts +30 -0
  193. package/types/WuiOrgTree.d.ts +12 -0
  194. package/types/WuiTimePicker.d.ts +1 -1
  195. package/types/WuiTree.d.ts +58 -0
  196. package/types/WuiTreePicker.d.ts +38 -0
  197. package/types/WuiWizard.d.ts +3 -3
  198. package/types/anchorOverlay.d.ts +3 -1
  199. package/types/{avatarHtml.d.ts → avatarNode.d.ts} +3 -3
  200. package/types/chartSpec.d.ts +10 -1
  201. package/types/dom.d.ts +7 -0
  202. package/types/elements/date-time.d.ts +2 -0
  203. package/types/global/core.d.ts +2 -3
  204. package/types/global/glyphs.d.ts +5 -4
  205. package/types/global/parts/table-export.d.ts +1 -0
  206. package/types/global/shared.d.ts +12 -2
  207. package/types/global/tableExport.d.ts +6 -0
  208. package/types/globals.d.ts +3 -1
  209. package/types/helpers.d.ts +3 -2
  210. package/types/iconGlyphs.g.d.ts +5 -4
  211. package/types/iconGlyphsCore.g.d.ts +2 -1
  212. package/types/iconGlyphsLazy.g.d.ts +2 -1
  213. package/types/index.d.ts +2 -1
  214. package/types/optionLabel.d.ts +9 -15
  215. package/types/razor-js/modules/shared.d.ts +1 -1
  216. package/types/razor-js/webority-ui.d.ts +1 -0
  217. package/types/richTextIcons.d.ts +14 -1
  218. package/types/rtl.d.ts +2 -0
  219. package/types/select/list.d.ts +9 -4
  220. package/types/server/index.d.ts +2 -1
  221. package/types/server/serverHtml.d.ts +6 -0
  222. package/types/server/serverTable.d.ts +1 -1
  223. package/types/server/wuiHttp.d.ts +8 -1
  224. package/types/svgNodes.d.ts +7 -0
  225. package/types/tableExport.d.ts +9 -0
  226. package/types/tableExportLoader.d.ts +4 -0
  227. package/types/text/web/chart.g.d.ts +1 -0
  228. package/types/text/web/confirmDialog.g.d.ts +1 -0
  229. package/types/text/web/dataTable.g.d.ts +7 -0
  230. package/types/text/web/datePicker.g.d.ts +2 -0
  231. package/types/text/web/modal.g.d.ts +1 -0
  232. package/types/toastTypes.d.ts +2 -1
  233. package/types/tooltips.d.ts +3 -3
  234. package/dist/WuiCarousel-CRx2-eKV.js +0 -1
  235. package/dist/WuiCommentThread-DZEYOHsk.js +0 -1
  236. package/dist/WuiConsentBanner-CWvXnwBH.js +0 -1
  237. package/dist/WuiContextMenu-DvYwIicr.js +0 -1
  238. package/dist/WuiDataTable-BSMhRQ1i.js +0 -1
  239. package/dist/WuiDatePicker-DxPethoe.js +0 -34
  240. package/dist/WuiDateRange-zPmNewOW.js +0 -25
  241. package/dist/WuiGantt-DaEgtdOU.js +0 -1
  242. package/dist/WuiImageCrop-BTY59Qsm.js +0 -17
  243. package/dist/WuiInlineEdit-BlsGNQSC.js +0 -1
  244. package/dist/WuiLeadPopup-L9UCTVA5.js +0 -382
  245. package/dist/WuiLightbox-BnLEEkj1.js +0 -1
  246. package/dist/WuiMarkdown-B7nfQ6tW.js +0 -4
  247. package/dist/WuiMentionInput-DvKw8MXS.js +0 -1
  248. package/dist/WuiNavigationMenu-CfD0FWvt.js +0 -1
  249. package/dist/WuiOrgTree-5v0vqPVk.js +0 -1
  250. package/dist/WuiOtp-DonxSwVn.js +0 -14
  251. package/dist/WuiPhone-BFb_LjJa.js +0 -16
  252. package/dist/WuiSavedViews-BsAyuOzX.js +0 -1
  253. package/dist/WuiSelect-iE3EVUWK.js +0 -9
  254. package/dist/WuiSlider-J9YPWu9e.js +0 -51
  255. package/dist/WuiSortable-BfOm57Mj.js +0 -1
  256. package/dist/WuiTimePicker-BsnPOYNw.js +0 -9
  257. package/dist/WuiTour-C2CRQvS7.js +0 -1
  258. package/dist/WuiTree-DGZSXgBh.js +0 -1
  259. package/dist/WuiTreePicker-CkTfNUQx.js +0 -1
  260. package/dist/WuiWizardStep-CryQ5BlK.js +0 -1
  261. package/dist/anchorOverlay-DSzkGQPi.js +0 -1
  262. package/dist/avatarHtml-BWlA0cm-.js +0 -1
  263. package/dist/chips-B4ZNRO-h.js +0 -2
  264. package/dist/dataTable.g-BVxhub_d.js +0 -1
  265. package/dist/datePicker.g-VdBlhA2G.js +0 -1
  266. package/dist/dom-Do1pAA12.js +0 -1
  267. package/dist/drawerDiscard-B4OcoR8S.js +0 -1
  268. package/dist/fileViewer.g-D5lbrn8g.js +0 -1
  269. package/dist/fileViewerMedia-cfmycjzl.js +0 -1
  270. package/dist/formatters-CMTSYlW9.js +0 -1
  271. package/dist/iconGlyphs.g-BUF97bUu.js +0 -1
  272. package/dist/kanban-CRRLqNn_.js +0 -1
  273. package/dist/loader-Cf_ozcXz.js +0 -1
  274. package/dist/optionLabel-CWMhBkdO.js +0 -1
  275. package/dist/statusIcons-CRtqA_1C.js +0 -10
  276. package/dist/tableSelect.g-DKZqXQT_.js +0 -1
  277. package/dist/wuiHttp-DGbD7Fra.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e}from"./calendarMath-rI1aBVRd.js";import{n as t,r as n,t as r}from"./digitGrouping-CCPI3HK3.js";import{t as i}from"./elementBase-Cxeyx0tU.js";import{o as a}from"./formatters-DikbTYA4.js";import{t as o}from"./imeSafeEnter-DPs9qL3S.js";import{n as s,t as c}from"./inlineEditText-C6g6qhye.js";import{d as l}from"./wuiHttp-BWf9dDsZ.js";import{r as u,t as d}from"./textStore-opIEM4lu.js";import{t as f}from"./inlineEdit.g-ZxRNYq0t.js";var p=()=>u(`inlineEdit`,f),m=e=>s.some(t=>t===e),h=`[data-wui-display]`,g=`[data-wui-value]`,_=`[data-wui-editor]`,v=`[data-wui-control]`,y=`[data-wui-error]`,b=`[data-wui-live]`,x=`[aria-expanded="true"]`,S=/* @__PURE__ */ new Set([`select`,`date`]),C=e=>{let t=(typeof e==`object`||typeof e==`function`)&&e!==null&&`message`in e?e.message:void 0;return typeof t==`string`&&t?t:p().serverMessage},w=e=>e instanceof HTMLElement&&typeof(`value`in e?e.value:void 0)==`string`,T=(e,t)=>{let n=e?.querySelector(t)??null;return n instanceof HTMLElement?n:null},E=class extends i{_wired;_editing;_busy;_draft;_pressed;_popupOpen;_savedTimer;static get observedAttributes(){return[`disabled`]}constructor(){super(),this._wired=!1,this._editing=!1,this._busy=!1,this._draft=null,this._pressed=!1,this._popupOpen=!1,this._savedTimer=null,this._onClick=this._onClick.bind(this),this._onKeyCapture=this._onKeyCapture.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onChange=this._onChange.bind(this)}connectedCallback(){this._wired||(this._wired=!0,this._grouping(),this.addEventListener(`click`,this._onClick),this.addEventListener(`auxclick`,this._onClick),this.addEventListener(`keydown`,this._onKeyCapture,!0),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`change`,this._onChange))}disconnectedCallback(){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,this._releasePress()}attributeChangedCallback(e){e===`disabled`&&this.hasAttribute(`disabled`)&&this.cancel()}edit(){if(this._editing||this._busy||this.hasAttribute(`disabled`))return;let e=T(this,h),t=T(this,_),n=this._control();e&&t&&n&&(this._editing=!0,this._setState(null),n.value=this._draft??this._value(),t.hidden=!1,this.setAttribute(`data-wui-editing`,``),this._focusControl(n),e.hidden=!0)}cancel(){this._editing&&(this._draft=null,this._setError(null),this.getAttribute(`data-wui-state`)===`error`&&this._setState(null),this._close())}_onClick(e){e.stopPropagation();let t=e.target instanceof Node?e.target:null;e.type===`click`&&!this._editing&&this.querySelector(h)?.contains(t)&&this.edit()}_onKeyCapture(){this._popupOpen=!!(this._editing&&this.querySelector(_)?.querySelector(x))}_onKeyDown(e){if(!this._editing){(o(e)||e.key===` `)&&e.stopPropagation();return}if(e.stopPropagation(),this._popupOpen)return;if(e.key===`Escape`){e.preventDefault(),this.cancel();return}let t=this._type();e.key!==`Enter`||S.has(t)||(t!==`textarea`||e.ctrlKey||e.metaKey)&&(e.preventDefault(),this._commit(this._control()?.value??``))}_onFocusOut(e){if(!this._editing||this._pressed)return;let t=e.relatedTarget instanceof Node?e.relatedTarget:null;t&&this.contains(t)||document.hasFocus()&&this._commit(this._control()?.value??``)}_onPointerDown(){this._editing&&(this._pressed=!0,document.addEventListener(`pointerup`,this._onPointerUp,!0),document.addEventListener(`pointercancel`,this._onPointerUp,!0))}_onPointerUp(){this._releasePress(),setTimeout(()=>{this._pressed=!1,this._editing&&!this.contains(document.activeElement)&&document.hasFocus()&&this._commit(this._control()?.value??``)},0)}_releasePress(){document.removeEventListener(`pointerup`,this._onPointerUp,!0),document.removeEventListener(`pointercancel`,this._onPointerUp,!0)}_onChange(e){if(!this._editing||!S.has(this._type()))return;let t=this._control();t&&e.target===t&&queueMicrotask(()=>this._commit(t.value))}async _commit(e){if(!this._editing||this._busy)return;let t=this._value();if(e===t){this.cancel();return}let n=typeof this.validate==`function`?this.validate(e):null;if(n){this._setError(n),this._announce(n);return}let r=this.hasAttribute(`controlled`);this._draft=null,this._setError(null),this._busy=!0,this._setState(`saving`),this.setAttribute(`aria-busy`,`true`);let i=r?null:this._readShown();r||this._showValue(e),this._close();let a=await this._persist(e,r);this._busy=!1,this.removeAttribute(`aria-busy`);let o=this.getAttribute(`label`)||``;a.ok?(this.setAttribute(`value`,e),!r&&a.text&&this._showText(a.text,!1),this._setState(`saved`),this._savedTimer=setTimeout(()=>this._setState(null),c),this._announce(d(p().savedText,{label:o})),this._fire(`wui:inline-edit:saved`,{value:e,previous:t})):(i&&this._restoreShown(i),a.kind===`session`||a.kind===`aborted`?this._setState(null):(this._draft=e,this._setState(`error`),this._setError(a.message),this._announce(d(p().notSavedText,{label:o,reason:a.message})),this._fire(`wui:inline-edit:failed`,{value:e,previous:t,kind:a.kind,message:a.message})))}async _persist(e,t){if(t){if(typeof this.save!=`function`)return{ok:!0};try{return await this.save(e),{ok:!0}}catch(e){return{ok:!1,kind:`server`,message:C(e)}}}let n=this.getAttribute(`action`);if(!n)return{ok:!0};let r=new URLSearchParams({[this.getAttribute(`name`)||`value`]:e}),i=await l(n,{method:`POST`,body:r});if(i.ok)return{ok:!0,text:i.html.trim()};let a={forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().validationMessage,server:p().serverMessage,network:p().networkMessage};return{ok:!1,kind:i.kind,message:i.message||a[i.kind]||p().serverMessage}}_close(){let e=T(this,h),t=T(this,_),n=this.contains(document.activeElement);this._editing=!1,this.removeAttribute(`data-wui-editing`),t&&(t.hidden=!0),e&&(e.hidden=!1),T(t,x)?.click(),n&&e?.focus()}_focusControl(e){if(!S.has(this._type())){e.focus(),e.select?.();return}let t=T(e,`button`);t&&(t.focus(),t.getAttribute(`aria-expanded`)!==`true`&&t.click())}_showValue(t){if(t===``){this._showText(this.getAttribute(`placeholder`)||a(),!0);return}let n=this._type(),i=t;if(n===`date`)i=e(t)||t;else if(n===`select`){let e=[...this._control()?.querySelectorAll(`[data-value]`)??[]].find(e=>e.getAttribute(`data-value`)===t);e&&(i=(e.textContent??``).trim())}else n===`number`&&this._grouping()===`indian`&&(i=r(t));this._showText(i,!1)}_readShown(){let e=this.querySelector(g);return e?{nodes:[...e.childNodes].map(e=>e.cloneNode(!0)),empty:e.hasAttribute(`data-wui-empty`)}:null}_restoreShown(e){let t=this.querySelector(g);t&&(t.replaceChildren(...e.nodes),t.toggleAttribute(`data-wui-empty`,e.empty))}_showText(e,t){let n=this.querySelector(g);n&&(n.textContent=e,n.toggleAttribute(`data-wui-empty`,t))}_setError(e){let t=T(this,y),n=this._control();t&&(t.textContent=e||``,t.hidden=!e),e?n?.setAttribute(`aria-invalid`,`true`):n?.removeAttribute(`aria-invalid`)}_setState(e){clearTimeout(this._savedTimer??void 0),this._savedTimer=null,e?this.setAttribute(`data-wui-state`,e):this.removeAttribute(`data-wui-state`)}_announce(e){let t=this.querySelector(b);t&&e&&(t.textContent=``,t.textContent=e)}_fire(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))}_control(){let e=this.querySelector(v);return w(e)?e:null}_value(){return this.getAttribute(`value`)??``}_type(){let e=this.getAttribute(`type`);return m(e)?e:`text`}_grouping(){let e=this.getAttribute(`grouping`)??`none`;if(!n(e))throw Error(t(e));return e}};export{E as t};
@@ -0,0 +1,345 @@
1
+ import{n as e,t}from"./devWarn-DXdRWZs3.js";import{r as n}from"./dom-DMQu--xV.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i,t as a}from"./textStore-opIEM4lu.js";import{t as o}from"./leadPopup.g-BfMPz9nH.js";var s={"--color-primary":`#4F46E5`,"--color-primary-hover":`#4338CA`,"--color-primary-soft":`#E0E7FF`,"--color-primary-text":`#4F46E5`,"--color-on-primary":`#FFFFFF`,"--color-text":`#071437`,"--color-text-muted":`#4B5675`,"--color-border":`#EBEDF3`,"--color-border-strong":`#C4CADA`,"--color-surface":`#FFFFFF`,"--wui-radius-sm":`8px`,"--wui-radius-lg":`14px`,"--wui-shadow-modal":`0px 24px 60px -16px rgba(7, 20, 55, 0.28)`,"--wui-z-modal":`1505`},c=e=>`var(${e}, ${s[e]})`,l=`
2
+ :host {
3
+ all: initial;
4
+ display: contents;
5
+ font-family: inherit;
6
+ font-size: 16px;
7
+ line-height: 1.5;
8
+ color: ${c(`--color-text`)};
9
+ }
10
+ *, *::before, *::after {
11
+ box-sizing: border-box;
12
+ }
13
+ [hidden] {
14
+ display: none !important;
15
+ }
16
+
17
+ dialog {
18
+ z-index: ${c(`--wui-z-modal`)};
19
+ width: 100%;
20
+ max-width: none;
21
+ height: 100%;
22
+ max-height: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ border: 0;
26
+ background: transparent;
27
+ color: inherit;
28
+ }
29
+ dialog[open] {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ }
34
+ :host([preview]) dialog {
35
+ position: static;
36
+ height: auto;
37
+ }
38
+ dialog::backdrop {
39
+ background: rgba(0, 0, 0, 0.7);
40
+ backdrop-filter: blur(5px);
41
+ }
42
+ dialog[open]::backdrop {
43
+ animation: wlp-fade 0.3s ease-out;
44
+ }
45
+
46
+ .wlp-card {
47
+ position: relative;
48
+ width: 90%;
49
+ max-width: 440px;
50
+ max-height: calc(100dvh - 32px);
51
+ overflow-y: auto;
52
+ padding: 24px;
53
+ background: ${c(`--color-surface`)};
54
+ color: ${c(`--color-text`)};
55
+ border: 1px solid ${c(`--color-border`)};
56
+ border-radius: ${c(`--wui-radius-lg`)};
57
+ box-shadow: ${c(`--wui-shadow-modal`)};
58
+ text-align: start;
59
+ }
60
+ dialog[open] .wlp-card {
61
+ animation: wlp-card-in 0.2s ease-out;
62
+ }
63
+
64
+ .wlp-close {
65
+ position: absolute;
66
+ top: 12px;
67
+ inset-inline-end: 12px;
68
+ width: 32px;
69
+ height: 32px;
70
+ padding: 0;
71
+ border: 0;
72
+ border-radius: 50%;
73
+ background: transparent;
74
+ color: ${c(`--color-text-muted`)};
75
+ font: inherit;
76
+ font-size: 22px;
77
+ line-height: 1;
78
+ cursor: pointer;
79
+ }
80
+ .wlp-close:focus-visible,
81
+ .wlp-button:focus-visible,
82
+ .wlp-input:focus-visible,
83
+ .wlp-secondary:focus-visible {
84
+ outline: 2px solid ${c(`--color-primary`)};
85
+ outline-offset: 2px;
86
+ }
87
+
88
+ .wlp-heading {
89
+ margin: 0 32px 8px 0;
90
+ font-size: 20px;
91
+ font-weight: 600;
92
+ line-height: 1.3;
93
+ color: ${c(`--color-text`)};
94
+ }
95
+ .wlp-description {
96
+ margin: 0 0 16px;
97
+ font-size: 14px;
98
+ color: ${c(`--color-text-muted`)};
99
+ }
100
+
101
+ .wlp-form {
102
+ display: grid;
103
+ gap: 14px;
104
+ margin: 0;
105
+ }
106
+ .wlp-field {
107
+ display: grid;
108
+ gap: 4px;
109
+ }
110
+ .wlp-label {
111
+ font-size: 14px;
112
+ font-weight: 500;
113
+ color: ${c(`--color-text`)};
114
+ }
115
+ .wlp-req {
116
+ margin-inline-start: 2px;
117
+ color: ${c(`--color-primary`)};
118
+ }
119
+ .wlp-input {
120
+ width: 100%;
121
+ padding: 9px 12px;
122
+ border: 1px solid ${c(`--color-border`)};
123
+ border-radius: 8px;
124
+ background: ${c(`--color-surface`)};
125
+ color: ${c(`--color-text`)};
126
+ font: inherit;
127
+ font-size: 15px;
128
+ }
129
+ textarea.wlp-input {
130
+ resize: vertical;
131
+ min-height: 96px;
132
+ }
133
+ .wlp-input[aria-invalid="true"] {
134
+ border-color: var(--color-danger, #B42318);
135
+ }
136
+ .wlp-error {
137
+ margin: 0;
138
+ font-size: 13px;
139
+ color: var(--color-danger, #B42318);
140
+ }
141
+ .wlp-form-error {
142
+ margin: 0;
143
+ font-size: 14px;
144
+ color: var(--color-danger, #B42318);
145
+ }
146
+ /* The consent field uses the theme's checkbox markup; its look is restated here because the
147
+ theme's rules cannot reach the shadow root. */
148
+ .form-check {
149
+ display: grid;
150
+ grid-template-columns: auto 1fr;
151
+ align-items: center;
152
+ column-gap: 12px;
153
+ font-size: 14px;
154
+ line-height: 1.4;
155
+ color: ${c(`--color-text`)};
156
+ }
157
+ .form-check-input {
158
+ flex: none;
159
+ width: 20px;
160
+ height: 20px;
161
+ margin: 0;
162
+ appearance: none;
163
+ -webkit-appearance: none;
164
+ border: 1.6px solid ${c(`--color-border-strong`)};
165
+ border-radius: ${c(`--wui-radius-sm`)};
166
+ corner-shape: squircle;
167
+ background-color: ${c(`--color-surface`)};
168
+ background-repeat: no-repeat;
169
+ background-position: center;
170
+ background-size: 15px 15px;
171
+ cursor: pointer;
172
+ transition:
173
+ border-color 0.15s ease,
174
+ background-color 0.15s ease,
175
+ box-shadow 0.15s ease;
176
+ }
177
+ .form-check-input:hover:not(:checked) {
178
+ border-color: ${c(`--color-primary`)};
179
+ box-shadow: 0 0 0 2px ${c(`--color-primary-soft`)};
180
+ }
181
+ .form-check-input:checked {
182
+ border-color: ${c(`--color-primary`)};
183
+ background-color: ${c(`--color-primary`)};
184
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E");
185
+ }
186
+ .form-check-input:focus-visible {
187
+ outline: 2px solid ${c(`--color-primary`)};
188
+ outline-offset: 2px;
189
+ box-shadow: none;
190
+ }
191
+ .form-check-input[aria-invalid="true"] {
192
+ border-color: var(--color-danger, #B42318);
193
+ }
194
+ .form-check-label {
195
+ min-width: 0;
196
+ cursor: pointer;
197
+ }
198
+ .wlp-field-consent .wlp-error {
199
+ margin-inline-start: 32px;
200
+ }
201
+ .wlp-consent-link {
202
+ grid-column: 2;
203
+ justify-self: start;
204
+ color: ${c(`--color-primary-text`)};
205
+ font-weight: 500;
206
+ text-decoration: underline;
207
+ text-underline-offset: 3px;
208
+ }
209
+ .wlp-consent-link:focus-visible {
210
+ outline: 2px solid ${c(`--color-primary`)};
211
+ outline-offset: 2px;
212
+ border-radius: 4px;
213
+ }
214
+ .wlp-visually-hidden {
215
+ position: absolute;
216
+ width: 1px;
217
+ height: 1px;
218
+ margin: -1px;
219
+ padding: 0;
220
+ overflow: hidden;
221
+ clip: rect(0, 0, 0, 0);
222
+ white-space: nowrap;
223
+ border: 0;
224
+ }
225
+ .wlp-honeypot {
226
+ position: absolute !important;
227
+ left: -9999px !important;
228
+ width: 1px;
229
+ height: 1px;
230
+ opacity: 0;
231
+ pointer-events: none;
232
+ }
233
+
234
+ .wlp-actions {
235
+ display: flex;
236
+ justify-content: flex-end;
237
+ align-items: center;
238
+ gap: 8px;
239
+ margin-top: 4px;
240
+ }
241
+ .wlp-button {
242
+ display: inline-flex;
243
+ align-items: center;
244
+ justify-content: center;
245
+ min-height: 36px;
246
+ padding: 8px 16px;
247
+ border: 1px solid ${c(`--color-primary`)};
248
+ border-radius: 8px;
249
+ background: ${c(`--color-primary`)};
250
+ color: ${c(`--color-on-primary`)};
251
+ font: inherit;
252
+ font-size: 15px;
253
+ font-weight: 500;
254
+ cursor: pointer;
255
+ }
256
+ .wlp-button:hover {
257
+ background: ${c(`--color-primary-hover`)};
258
+ border-color: ${c(`--color-primary-hover`)};
259
+ }
260
+ .wlp-button:disabled {
261
+ opacity: 0.6;
262
+ cursor: default;
263
+ }
264
+ .wlp-notice {
265
+ margin: 4px 0 0;
266
+ font-size: 12px;
267
+ line-height: 1.4;
268
+ color: ${c(`--color-text-muted`)};
269
+ }
270
+ .wlp-notice a {
271
+ color: inherit;
272
+ text-decoration: underline;
273
+ }
274
+
275
+ .wlp-secondary-row {
276
+ display: flex;
277
+ align-items: center;
278
+ gap: 10px;
279
+ margin-top: 14px;
280
+ font-size: 14px;
281
+ color: ${c(`--color-text-muted`)};
282
+ }
283
+ .wlp-secondary-row::before,
284
+ .wlp-secondary-row::after {
285
+ content: "";
286
+ flex: 1;
287
+ height: 1px;
288
+ background: ${c(`--color-border`)};
289
+ }
290
+ .wlp-secondary {
291
+ display: block;
292
+ margin-top: 10px;
293
+ text-align: center;
294
+ color: ${c(`--color-primary`)};
295
+ font-weight: 500;
296
+ }
297
+
298
+ .wlp-success-title {
299
+ margin: 0 32px 8px 0;
300
+ font-size: 20px;
301
+ font-weight: 600;
302
+ color: ${c(`--color-text`)};
303
+ }
304
+ .wlp-success-text {
305
+ margin: 0 0 16px;
306
+ color: ${c(`--color-text-muted`)};
307
+ }
308
+ .wlp-success-view .wlp-button {
309
+ width: 100%;
310
+ }
311
+
312
+ @keyframes wlp-fade {
313
+ from { opacity: 0; }
314
+ to { opacity: 1; }
315
+ }
316
+ @keyframes wlp-card-in {
317
+ from { opacity: 0; transform: scale(0.96); }
318
+ to { opacity: 1; transform: scale(1); }
319
+ }
320
+
321
+ @media (max-width: 575.98px) {
322
+ .wlp-card {
323
+ width: calc(100% - 32px);
324
+ max-width: none;
325
+ padding: 20px 16px;
326
+ }
327
+ .wlp-input {
328
+ font-size: 16px;
329
+ }
330
+ .wlp-button,
331
+ .wlp-close {
332
+ min-height: 44px;
333
+ }
334
+ .wlp-close {
335
+ min-width: 44px;
336
+ }
337
+ }
338
+
339
+ @media (prefers-reduced-motion: reduce) {
340
+ dialog[open]::backdrop,
341
+ dialog[open] .wlp-card {
342
+ animation: none;
343
+ }
344
+ }
345
+ `,u=[`name`,`email`,`phone`,`company`,`message`,`consent`],d=[`name`,`email`],f=()=>i(`leadPopup`,o),p={name:100,email:320,phone:40,company:150,message:1e3},m={name:`name`,email:`email`,phone:`tel`,company:`organization`},h=`input:not([type=hidden]), textarea, select, button, a[href]`,g=[`exit`,`delay`,`scroll`,`pages`],_=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,v=864e5,y=`comment_subject`,b=`__RequestVerificationToken`,x=`__FormStamp`,S=`__CaptchaToken`,C=/* @__PURE__ */ `action.public-form.heading.description.fields.required.field-prefix.field-names.labels.max-lengths.submit-label.success-title.success-text.error-text.close-label.secondary-label.secondary-href.secondary-divider.consent-href.triggers.delay-seconds.scroll-percent.pages-viewed.storage-key.dismiss-days.submitted-days.success-close-seconds.preview`.split(`.`),w=/* @__PURE__ */ new Set;function T(t,n){w.has(t)||(w.add(t),e(n))}var E=0;function D(e){return(e??``).split(/\s+/).map(e=>e.trim()).filter(Boolean)}function O(e){let t={};for(let n of(e??``).split(`;`)){let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}var k=null;function A(e){k||(k=new CSSStyleSheet,k.replaceSync(l)),e.adoptedStyleSheets=[k]}function j(e,t){return e instanceof Error&&e.message?e.message:t}function M(e){return u.some(t=>t===e)}function N(e){return g.some(t=>t===e)}function P(e,t,n){if(e instanceof t)return e;throw Error(`${n} missing`)}var F=class extends r{_uid;_rendered;_open;_opened;_posting;_stale;_armed;_session;_returnTo;_prevOverflow;_delayTimer;_closeTimer;_modal;_onMouseLeave;_onVisibility;_onScroll;static get observedAttributes(){return C}constructor(){super(),E+=1,this._uid=`wlp-${E}`,this._rendered=!1,this._open=!1,this._opened=!1,this._posting=!1,this._stale=!1,this._armed=!1,this._session=null,this._returnTo=null,this._prevOverflow=``,this._delayTimer=null,this._closeTimer=null,this._onMouseLeave=e=>{!this._fine()||e.clientY>0||!this._engaged()||this.open(`exit`)},this._onVisibility=()=>{document.visibilityState===`hidden`&&!this._fine()&&this._engaged()&&this.open(`exit`)},this._onScroll=()=>this._trackScroll()}get isOpen(){return this._open}set isOpen(e){e?this.open(`manual`):this.close(`dismiss`)}connectedCallback(){this._rendered||this._render(),this._arm(),this.preview&&!this._open&&this.open(`manual`)}disconnectedCallback(){this._disarm(),this._open&&this._release()}attributeChangedCallback(){this._rendered&&(this._open?this._stale=!0:this._render())}open(e=`manual`){if(!this._open&&!(e!==`manual`&&(this._opened||this._blocked()||document.querySelector(`dialog[open], .modal.show`)))){if(this._rendered||this._render(),this._opened=!0,this._open=!0,clearTimeout(this._delayTimer??void 0),this._showForm(),this._modal=!this.preview,this._modal){let e=document.activeElement;this._returnTo=e instanceof HTMLElement||e instanceof SVGElement?e:null,this._prevOverflow=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`;let t=this._dialog();t.showModal();let n=t.querySelector(`[data-wlp-field] [data-wlp-input]`);n instanceof HTMLElement&&n.focus()}else this._dialog().setAttribute(`open`,``);this._remember(`shown`),this._emit(`wui-lead-popup-shown`,{trigger:e})}}close(e=`dismiss`){if(!this._open)return;clearTimeout(this._closeTimer??void 0),this._release();let t=this._returnTo;this._returnTo=null,t?.isConnected&&typeof t.focus==`function`&&t.focus(),this._stale&&this._render(),this._emit(`wui-lead-popup-closed`,{reason:e})}_release(){this._open=!1,this._dialog().close(),this._modal&&(document.documentElement.style.overflow=this._prevOverflow)}_root(){return this.shadowRoot??this.attachShadow({mode:`open`})}_dialog(){return P(this._root().querySelector(`dialog`),HTMLDialogElement,`dialog`)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_text(e,t=``){return this.getAttribute(e)||t}_number(e,t){let n=this.getAttribute(e);if(n===null||n.trim()===``)return t;let r=Number(n);return Number.isFinite(r)&&r>=0?r:t}get preview(){return this.hasAttribute(`preview`)}set preview(e){this.toggleAttribute(`preview`,e===!0||e===``||e===`true`)}_fieldKeys(){let e=D(this.getAttribute(`fields`)).filter(e=>M(e)?!0:(T(`field:${e}`,`[@webority/ui-elements] <wui-lead-popup> has no field "${e}". It is ignored.`),!1));return e.length?e:d}_requiredKeys(){let e=this._fieldKeys();return D(this.getAttribute(`required`)).filter(t=>M(t)&&e.includes(t))}_label(e){return O(this.getAttribute(`labels`))[e]||f()[e]}_postedName(e){return this._text(`field-prefix`)+(O(this.getAttribute(`field-names`))[e]||e)}_maxLength(e){let t=Number(O(this.getAttribute(`max-lengths`))[e]);return Number.isInteger(t)&&t>0?t:p[e]}_triggers(){if(this.preview)return[];let e=(this.getAttribute(`triggers`)??``).split(/\s+/).filter(N);return e.length?this.getAttribute(`storage-key`)?e:(T(`storage-key`,`[@webority/ui-elements] <wui-lead-popup> has triggers but no storage-key. The triggers are off.`),[]):[]}_render(){let e=this._root();A(e);let t=this._uid,r=this._fieldKeys(),i=new Set(this._requiredKeys()),a=this._text(`heading`),o=this._text(`description`),s=this._text(`secondary-label`),c=this._text(`secondary-href`),l=s&&c?[n(`div`,{class:`wlp-secondary-row`},n(`span`,null,this._text(`secondary-divider`,f().secondaryDividerLabel))),n(`a`,{class:`wlp-secondary`,href:c,"data-wlp-secondary":!0},s)]:[],u=this._text(`success-text`),d=n(`dialog`,{class:`wlp-dialog`,"aria-labelledby":`${t}-h`,"aria-describedby":o?`${t}-d`:null},n(`div`,{class:`wlp-card`},n(`button`,{type:`button`,class:`wlp-close`,"aria-label":this._text(`close-label`,f().closeLabel),"data-wlp-close":!0},`×`),n(`div`,{class:`wlp-form-view`},n(`h2`,{class:`wlp-heading`,id:`${t}-h`},a),o?n(`p`,{class:`wlp-description`,id:`${t}-d`},o):null,n(`form`,{class:`wlp-form`,novalidate:!0,"data-wlp-form":!0},...r.map(e=>this._fieldNode(e,i.has(e))),n(`p`,{class:`wlp-form-error`,role:`alert`,hidden:!0,"data-wlp-form-error":!0}),n(`div`,{class:`wlp-actions`},n(`button`,{type:`submit`,class:`wlp-button`,"data-wlp-submit":!0},this._text(`submit-label`,f().submitLabel))),n(`input`,{type:`text`,name:y,class:`wlp-honeypot`,tabindex:`-1`,autocomplete:`off`,"aria-hidden":`true`,"data-wlp-honeypot":!0}),n(`p`,{class:`wlp-notice`,"data-recaptcha-notice":!0},`${f().recaptchaNoticeText} `,n(`a`,{href:`https://policies.google.com/privacy`,target:`_blank`,rel:`noopener`},f().privacyPolicyLabel),` and `,n(`a`,{href:`https://policies.google.com/terms`,target:`_blank`,rel:`noopener`},f().termsOfServiceLabel),` ${f().recaptchaNoticeEndText}`)),...l),n(`div`,{class:`wlp-success-view`,hidden:!0},n(`h2`,{class:`wlp-success-title`,role:`status`,tabindex:`-1`,"data-wlp-success-title":!0},this._text(`success-title`,f().successTitle)),u?n(`p`,{class:`wlp-success-text`},u):null,n(`button`,{type:`button`,class:`wlp-button`,"data-wlp-done":!0},this._text(`close-label`,f().closeLabel))))),p=document.createDocumentFragment();p.append(d),e.replaceChildren(p),this._rendered=!0,this._stale=!1,this._wire()}_fieldNode(e,t){let r=`${this._uid}-f-${e}`,i=`${this._uid}-e-${e}`,a=this._label(e),o=this._postedName(e),s=t?[n(`span`,{class:`wlp-req`,"aria-hidden":`true`},`*`),n(`span`,{class:`wlp-visually-hidden`},f().requiredLabel)]:[],c=t?`true`:null;if(e===`consent`){let t=this._text(`consent-href`),l=t?n(`a`,{class:`wlp-consent-link`,href:t},this._label(`consentLink`)):null;return n(`div`,{class:`wlp-field wlp-field-consent`,"data-wlp-field":e},n(`div`,{class:`form-check`},n(`input`,{class:`form-check-input`,type:`checkbox`,id:r,"data-wlp-input":e,name:o,"aria-required":c}),` `,n(`label`,{class:`form-check-label`,for:r},a,...s),l?` `:null,l),n(`p`,{class:`wlp-error`,id:i,hidden:!0}))}let l={id:r,"data-wlp-input":e,name:o,maxlength:this._maxLength(e),"aria-required":c},u=e===`message`?n(`textarea`,{class:`wlp-input`,rows:4,...l}):n(`input`,{class:`wlp-input`,type:e===`email`?`email`:e===`phone`?`tel`:`text`,...l,autocomplete:m[e]??null});return n(`div`,{class:`wlp-field`,"data-wlp-field":e},n(`label`,{class:`wlp-label`,for:r},a,...s),` `,u,n(`p`,{class:`wlp-error`,id:i,hidden:!0}))}_wire(){let e=this._dialog();e.addEventListener(`cancel`,e=>{e.preventDefault(),this.close(`escape`)}),e.addEventListener(`click`,t=>{t.target===e&&this.close(`backdrop`)}),e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`||!this._modal)return;let n=Array.from(e.querySelectorAll(h)).filter(e=>e instanceof HTMLElement&&!(`disabled`in e&&e.disabled===!0)&&e.getClientRects().length>0);if(!n.length)return;let r=this._root().activeElement,i=r instanceof HTMLElement?n.indexOf(r):-1;t.preventDefault();let a=n[i===-1?t.shiftKey?n.length-1:0:(i+(t.shiftKey?-1:1)+n.length)%n.length];if(!a)throw Error(`tab stop missing`);a.focus()});for(let t of e.querySelectorAll(`[data-wlp-close]`))t.addEventListener(`click`,()=>this.close(`dismiss`));e.querySelector(`[data-wlp-done]`)?.addEventListener(`click`,()=>this.close(`submitted`)),e.querySelector(`[data-wlp-secondary]`)?.addEventListener(`click`,()=>this.close(`secondary`)),P(e.querySelector(`[data-wlp-form]`),HTMLFormElement,`form`).addEventListener(`submit`,e=>this._onSubmit(e))}_showForm(){let e=this._root();P(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!1,P(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`).hidden=!0}_showSuccess(){let e=this._root();P(e.querySelector(`.wlp-form-view`),HTMLElement,`form view`).hidden=!0;let t=P(e.querySelector(`.wlp-success-view`),HTMLElement,`success view`);t.hidden=!1,P(e.querySelector(`[data-wlp-success-title]`),HTMLElement,`success title`).focus()}_setFieldError(e,t){let n=this._root(),r=P(n.querySelector(`[data-wlp-input="${e}"]`),HTMLElement,`${e} field`),i=P(n.querySelector(`#${this._uid}-e-${e}`),HTMLElement,`${e} error`);return i.textContent=t,i.hidden=!t,t?(r.setAttribute(`aria-invalid`,`true`),r.setAttribute(`aria-describedby`,i.id)):(r.removeAttribute(`aria-invalid`),r.removeAttribute(`aria-describedby`)),r}_validate(){let e=new Set(this._requiredKeys()),t=null,n={};for(let r of this._fieldKeys()){let i=this._root().querySelector(`[data-wlp-input="${r}"]`);if(!(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement))throw Error(`${r} field missing`);let o=r===`consent`&&i instanceof HTMLInputElement?i.checked:i.value.trim();n[r]=o;let s=``;!o&&e.has(r)?s=r===`consent`?f().consentRequiredMessage:a(f().fieldRequiredMessage,{label:this._label(r).toLowerCase()}):r===`email`&&o&&!_.test(String(o))&&(s=f().emailInvalidMessage);let c=this._setFieldError(r,s);s&&!t&&(t=c)}return t?(t.focus(),null):n}_setBusy(e){this._posting=e;let t=P(this._root().querySelector(`[data-wlp-form]`),HTMLElement,`form`);e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`),P(this._root().querySelector(`[data-wlp-submit]`),HTMLButtonElement,`submit button`).disabled=e}_fail(e,t){this._setBusy(!1);let n=P(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`);n.textContent=t,n.hidden=!t,this._emit(`wui-lead-popup-error`,{message:t,reason:e})}async _onSubmit(e){if(e.preventDefault(),this._posting)return;P(this._root().querySelector(`[data-wlp-form-error]`),HTMLElement,`form error`).hidden=!0;let t=this._validate();t&&!this.preview&&await this._post(t)}async _post(e){let n=globalThis.WeborityPublicForms;if(!n){T(`gate`,`[@webority/ui-elements] <wui-lead-popup> needs window.WeborityPublicForms. Load Webority.Security.Razor's public-form.js.`),this._fail(`gate`,this._text(`error-text`,f().errorText));return}let r=this._text(`error-text`,f().errorText),i=this._text(`public-form`);this._setBusy(!0);let a,o;try{a=await n.session(),o=await n.mintToken(i)}catch(e){this._fail(`gate`,j(e,r));return}let s=this._root(),c=new FormData;for(let t of this._fieldKeys())c.append(this._postedName(t),String(e[t]));c.set(b,a.token),c.set(x,a.formStamp),c.set(S,o),c.set(y,P(s.querySelector(`[data-wlp-honeypot]`),HTMLInputElement,`honeypot`).value),this._emit(`wui-lead-popup-before-submit`,{formData:c});let l;try{l=await fetch(this._text(`action`),{method:`POST`,body:c,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}})}catch{this._fail(`network`,r);return}let u;try{u=await this._readJson(l)}catch(e){t(`<wui-lead-popup> could not read the response body`,e),this._fail(`server`,r);return}if(l.ok)this._succeed(e,u);else{let e=typeof u==`object`&&u&&`detail`in u&&typeof u.detail==`string`?u.detail.trim():``;this._fail(`server`,e||r)}}async _readJson(e){return e.json()}_succeed(e,t){this._setBusy(!1),this._remember(`submitted`),this._emit(`wui-lead-popup-submitted`,{values:e,response:t}),this._showSuccess();let n=this._number(`success-close-seconds`,5);n>0&&(this._closeTimer=setTimeout(()=>this.close(`submitted`),n*1e3))}_arm(){if(this._armed)return;this._armed=!0;let e=this._triggers();if(!e.length)return;this._session=this._loadSession();let t=location.pathname+location.search;if(this._session.pages.includes(t)||this._session.pages.push(t),this._saveSession(),e.includes(`exit`)&&(document.documentElement.addEventListener(`mouseleave`,this._onMouseLeave),document.addEventListener(`visibilitychange`,this._onVisibility)),e.includes(`delay`)){let e=Math.max(0,this._number(`delay-seconds`,30)*1e3-(Date.now()-this._session.start));this._delayTimer=setTimeout(()=>this.open(`delay`),e)}e.includes(`scroll`)&&(window.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackScroll()),e.includes(`pages`)&&this._session.pages.length>this._number(`pages-viewed`,2)&&this.open(`pages`)}_disarm(){this._armed=!1,clearTimeout(this._delayTimer??void 0),clearTimeout(this._closeTimer??void 0),document.documentElement.removeEventListener(`mouseleave`,this._onMouseLeave),document.removeEventListener(`visibilitychange`,this._onVisibility),window.removeEventListener(`scroll`,this._onScroll)}_trackScroll(){let e=document.documentElement.scrollHeight;if(this._session&&e>0){let t=(window.scrollY+window.innerHeight)/e*100;t>this._session.maxScroll&&(this._session.maxScroll=t,this._saveSession()),this._session.maxScroll>this._number(`scroll-percent`,50)&&this.open(`scroll`)}}_fine(){return typeof matchMedia!=`function`||matchMedia(`(pointer: fine)`).matches}_engaged(){let e=this._session;return e?Date.now()-e.start>this._number(`delay-seconds`,30)*1e3||e.maxScroll>this._number(`scroll-percent`,50)||e.pages.length>this._number(`pages-viewed`,2):!1}_sessionKey(){return`wui-lead-popup:${this.getAttribute(`storage-key`)}`}_loadSession(){let e={start:Date.now(),maxScroll:0,pages:[]};try{let e=sessionStorage.getItem(this._sessionKey());if(e){let t=JSON.parse(e);if(Number.isFinite(t.start)&&Number.isFinite(t.maxScroll)&&Array.isArray(t.pages))return t}}catch{return e}return e}_saveSession(){try{sessionStorage.setItem(this._sessionKey(),JSON.stringify(this._session))}catch(e){if(!(e instanceof DOMException))throw e}}_readMemory(){let e=this.getAttribute(`storage-key`);if(!e)return null;try{let t=JSON.parse(localStorage.getItem(e)??`null`);if((t?.state===`shown`||t?.state===`submitted`)&&Number.isFinite(Date.parse(t.at)))return t}catch{return null}return null}_blocked(){let e=this._readMemory();if(!e)return!1;let t=e.state===`shown`?this._number(`dismiss-days`,30):this._number(`submitted-days`,365);return Date.now()-Date.parse(e.at)<t*v}_remember(e){let t=this.getAttribute(`storage-key`);if(t&&!this.preview)try{localStorage.setItem(t,JSON.stringify({state:e,at:(/* @__PURE__ */ new Date()).toISOString()}))}catch(e){if(!(e instanceof DOMException))throw e}}};export{F as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{f as n}from"./formatters-DikbTYA4.js";import{t as r}from"./iconGlyphs.g-P04RJkSE.js";import{u as i}from"./nativeOverlay-BHD2QV02.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";import{r as s,t as c}from"./textStore-opIEM4lu.js";import{t as l}from"./lightbox.g-DDrycPou.js";var u=`a.wui-lightbox-item`,d=1,f=4,p=.5,m=2,h=50,g=6,_=300,v=300;function y(e){return Number.isFinite(e)?Math.min(f,Math.max(d,e)):d}function b(e,t,n,r){let i=(e,n)=>Math.max(0,(e*t-n)/2),a=i(r.width,n.width),o=i(r.height,n.height);return{x:Math.min(a,Math.max(-a,e.x)),y:Math.min(o,Math.max(-o,e.y))}}function x(e,t){return Math.abs(e)<h||Math.abs(e)<Math.abs(t)*1.5?0:e<0?1:-1}function S(e){let t=(String(e??``).split(/[?#]/)[0]??``).split(`/`).filter(Boolean).pop()??``;try{return decodeURIComponent(t)}catch{return t}}var C=()=>s(`lightbox`,l);function w(t,n,i){let a=e(`button`,{class:`u-action wui-lightbox-btn ${i}`,type:`button`,"aria-label":n,title:n});a.style.setProperty(`--wui-action-size`,`40px`);let o=r(t,{size:20});return a.replaceChildren(...o?[o]:[]),a}var T=class extends t{_ui;_index;_zoom;_pan;_pointers;_gesture;_lastTap;_returnTo;_release;_onClick;static get observedAttributes(){return[`open-index`]}constructor(){super(),this._ui=null,this._index=0,this._zoom=d,this._pan={x:0,y:0},this._pointers=/* @__PURE__ */ new Map,this._gesture=null,this._lastTap=-1/0,this._returnTo=null,this._release=null,this._onClick=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let t=e.target,n=t instanceof Element?t.closest(u):null;if(!(n instanceof HTMLAnchorElement)||!this.contains(n))return;let r=this._links().indexOf(n);r<0||(e.preventDefault(),this.open(r))}}get _view(){if(!this._ui)throw Error(`<wui-lightbox> viewer is not open.`);return this._ui}get download(){return this.hasAttribute(`download`)}set download(e){this.toggleAttribute(`download`,e===!0||e===``||e===`true`)}get label(){return this.getAttribute(`label`)||C().label}set label(e){this.setAttribute(`label`,String(e??``))}get layout(){return this.getAttribute(`layout`)===`single`?`single`:`gallery`}set layout(e){if(e===`single`)this.setAttribute(`layout`,`single`);else if(e===`gallery`||e===``)this.removeAttribute(`layout`);else throw Error(`<wui-lightbox> layout must be "gallery" or "single", received "${e}".`)}get isOpen(){return this._ui!==null}connectedCallback(){this.addEventListener(`click`,this._onClick),this._syncOpenIndex()}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this._teardown()}attributeChangedCallback(){this.isConnected&&this._syncOpenIndex()}_syncOpenIndex(){let e=this.getAttribute(`open-index`);e===null?this.close():this.open(Number(e))}_links(){return[...this.querySelectorAll(u)].filter(e=>e instanceof HTMLAnchorElement)}_items(){return this._links().map(e=>{let t=e.getAttribute(`href`)??``;return{link:e,src:t,alt:e.querySelector(`img`)?.getAttribute(`alt`)??``,caption:e.dataset.caption??``,name:e.dataset.name||S(t)}})}open(e=0){let t=this._items();if(!t.length)return!1;if(!this._ui){let t=document.activeElement;this._returnTo=t instanceof HTMLElement||t instanceof SVGElement?t:null,this._build(),this.dispatchEvent(new CustomEvent(`wui-lightbox:open`,{bubbles:!0,detail:{index:e}}))}return this._show(e,t),!0}close(){if(!this._ui)return;let e=this._index,t=this._links()[e]??this._returnTo;this._teardown(),t?.isConnected&&t.focus(),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-lightbox:close`,{bubbles:!0,detail:{index:e}}))}_teardown(){this._ui&&(this._release?.(),this._release=null,this._ui.root.open&&this._ui.root.close(),this._ui.root.remove(),this._ui=null,this._pointers.clear(),this._gesture=null)}_build(){let t=e(`dialog`,{class:`wui-lightbox-overlay`,role:`dialog`,"aria-label":this.label,tabindex:`-1`}),n=e(`div`,{class:`wui-lightbox-bar`}),a=e(`span`,{class:`wui-lightbox-count`,"aria-live":`polite`}),o=e(`div`,{class:`wui-lightbox-tools`}),s=w(`zoom-out`,C().zoomOutLabel,`wui-lightbox-zoom-out`),c=w(`zoom-in`,C().zoomInLabel,`wui-lightbox-zoom-in`),l=e(`a`,{class:`u-action wui-lightbox-btn wui-lightbox-download`,"aria-label":C().downloadLabel,title:C().downloadLabel});l.style.setProperty(`--wui-action-size`,`40px`);let u=r(`download`,{size:20});l.replaceChildren(...u?[u]:[]),l.hidden=!this.download;let d=w(`x`,C().closeLabel,`wui-lightbox-close`);o.append(s,c,l,d),n.append(a,o);let f=e(`div`,{class:`wui-lightbox-stage`}),m=w(`chevron-left`,C().previousImageLabel,`wui-lightbox-nav wui-lightbox-prev`),h=w(`chevron-right`,C().nextImageLabel,`wui-lightbox-nav wui-lightbox-next`),g=e(`img`,{class:`wui-lightbox-image`,decoding:`async`,draggable:`false`,alt:``}),_=e(`p`,{class:`wui-lightbox-status`,role:`status`});f.append(g,_,m,h);let v=e(`p`,{class:`wui-lightbox-caption`});t.append(n,f,v);let y={root:t,count:a,zoomOut:s,zoomIn:c,download:l,close:d,stage:f,prev:m,next:h,image:g,status:_,caption:v};this._ui=y,d.addEventListener(`click`,()=>this.close()),m.addEventListener(`click`,()=>this.step(-1)),h.addEventListener(`click`,()=>this.step(1)),s.addEventListener(`click`,()=>this._setZoom(this._zoom-p)),c.addEventListener(`click`,()=>this._setZoom(this._zoom+p)),t.addEventListener(`keydown`,e=>this._onKeyDown(e)),f.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),f.addEventListener(`pointermove`,e=>this._onPointerMove(e)),f.addEventListener(`pointerup`,e=>this._onPointerEnd(e,!0)),f.addEventListener(`pointercancel`,e=>this._onPointerEnd(e,!1)),f.addEventListener(`wheel`,e=>this._onWheel(e),{passive:!1}),g.addEventListener(`load`,()=>{this._ui===y&&(_.textContent=``,f.removeAttribute(`aria-busy`),g.hidden=!1,this._applyTransform())}),g.addEventListener(`error`,()=>{this._ui===y&&(f.removeAttribute(`aria-busy`),g.hidden=!0,_.textContent=C().imageFailedMessage)}),this.append(t),this._release=i(t,{escape:!0,backdrop:!1,focus:`panel`,onRequestClose:()=>this.close()})}step(e){if(!this._ui||!e)return;let t=this._items();t.length<2||this._show((this._index+e+t.length)%t.length,t)}_show(e,t){let r=this._view,i=Math.min(t.length-1,Math.max(0,Math.trunc(Number(e))||0)),a=t[i];if(!a)throw Error(`<wui-lightbox> image missing.`);let o=i!==this._index||!r.image.getAttribute(`src`);if(this._index=i,this._zoom=d,this._pan={x:0,y:0},r.count.textContent=c(C().countText,{position:n(i+1,{decimals:0}),total:n(t.length,{decimals:0})}),r.caption.textContent=a.caption,r.caption.hidden=!a.caption,r.download.href=a.src,r.download.setAttribute(`download`,a.name),r.prev.hidden=r.next.hidden=t.length<2,r.stage.setAttribute(`aria-busy`,`true`),r.status.textContent=``,r.image.hidden=!1,r.image.alt=a.alt||a.caption,r.image.src=a.src,this._applyTransform(),this._syncZoomButtons(),t.length>1){let e=t[(i+1)%t.length],n=t[(i-1+t.length)%t.length];if(!e||!n)throw Error(`<wui-lightbox> neighbour image missing.`);for(let t of[e,n])new Image().src=t.src}o&&this.dispatchEvent(new CustomEvent(`wui-lightbox:change`,{bubbles:!0,detail:{index:i}}))}_syncZoomButtons(){let e=this._view;e.zoomOut.disabled=this._zoom<=d,e.zoomIn.disabled=this._zoom>=f;let t=document.activeElement;(t===e.zoomOut||t===e.zoomIn)&&t instanceof HTMLButtonElement&&t.disabled&&e.close.focus()}_setZoom(e){this._ui&&(this._zoom=y(e),this._pan=this._clampedPan(this._pan),this._applyTransform(),this._syncZoomButtons())}_clampedPan(e){let{stage:t,image:n}=this._view;return b(e,this._zoom,{width:t.clientWidth,height:t.clientHeight},{width:n.offsetWidth,height:n.offsetHeight})}_applyTransform(){let{image:e,stage:t}=this._view;e.style.transform=`translate(${this._pan.x}px, ${this._pan.y}px) scale(${this._zoom})`,t.classList.toggle(`wui-lightbox-zoomed`,this._zoom>d)}_onKeyDown(e){let t=a(e.key,o(this));if(t===`ArrowLeft`||t===`ArrowRight`)e.preventDefault(),this.step(t===`ArrowRight`?1:-1);else if(e.key===`Home`||e.key===`End`){e.preventDefault();let t=this._items();this._show(e.key===`Home`?0:t.length-1,t)}else e.key===`+`||e.key===`=`?(e.preventDefault(),this._setZoom(this._zoom+p)):e.key===`-`?(e.preventDefault(),this._setZoom(this._zoom-p)):e.key===`0`&&(e.preventDefault(),this._setZoom(d))}_onWheel(e){e.preventDefault(),this._setZoom(this._zoom*(e.deltaY<0?1.15:1/1.15))}_onPointerDown(e){let t=e.target;if(t instanceof Element&&t.closest(`.wui-lightbox-nav`))return;let n=this._view;if(n.stage.setPointerCapture?.(e.pointerId),this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this._pointers.size===2){let e=[...this._pointers.values()],t=e[0],n=e[1];if(!t||!n)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._gesture={kind:`pinch`,distance:Math.hypot(t.x-n.x,t.y-n.y)||1,zoom:this._zoom}}else this._pointers.size===1&&(this._gesture={kind:`drag`,startX:e.clientX,startY:e.clientY,startTime:e.timeStamp,pan:{...this._pan},onImage:e.target===n.image,moved:!1})}_onPointerMove(e){let t=this._gesture;if(t&&this._pointers.has(e.pointerId)){if(this._pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.kind===`pinch`&&this._pointers.size===2){let e=[...this._pointers.values()],n=e[0],r=e[1];if(!n||!r)throw Error(`<wui-lightbox> pinch needs two pointers.`);this._setZoom(t.zoom*Math.hypot(n.x-r.x,n.y-r.y)/t.distance)}else if(t.kind===`drag`){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>g&&(t.moved=!0),this._zoom>d&&(this._pan=this._clampedPan({x:t.pan.x+n,y:t.pan.y+r}),this._view.stage.classList.add(`is-dragging`),this._applyTransform())}}}_onPointerEnd(e,t){let n=this._gesture;if(this._pointers.delete(e.pointerId),this._ui?.stage.classList.remove(`is-dragging`),!n)return;if(n.kind===`pinch`){this._pointers.size<2&&(this._gesture=null);return}if(this._gesture=null,!t)return;let r=e.clientX-n.startX,i=e.clientY-n.startY;n.moved?this._zoom===d&&this.step(x(r,i)):e.timeStamp-n.startTime>_||(n.onImage?e.timeStamp-this._lastTap<v?(this._lastTap=-1/0,this._setZoom(this._zoom>d?d:m)):this._lastTap=e.timeStamp:this.close())}};export{T as t};
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";var n=/\[([^[\]\n]+)\](?!\()/g,r=/* @__PURE__ */ new Set(`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`),i=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,a=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/y,o=new RegExp(n.source,`y`),s=e=>/[\p{L}\p{N}]/u.test(e);function c(e,t){let n=0;for(let r=t-1;r>=0&&e.charAt(r)===`\\`;--r)n+=1;return n%2==1}function l(e,t,n){let r=n.length===1;for(let i=e.indexOf(n,t);i!==-1;i=e.indexOf(n,i+1)){let a=i>t&&!/\s/.test(e.charAt(t))&&!/\s/.test(e.charAt(i-1)),o=r&&(e.charAt(i+1)===n||e.charAt(i-1)===n),l=n===`_`&&s(e.charAt(i+n.length));if(a&&!o&&!l&&!c(e,i))return i}return-1}function u(e,t){let n=t?.isCitation,c=[],d=``,f=()=>{d&&=(c.push({type:`text`,text:d}),``)},p=0;for(;p<e.length;){let m=e.charAt(p),h=e.charAt(p+1);if(m===`\\`&&r.has(h)){d+=h,p+=2;continue}if(m==="`"){let t=e.indexOf("`",p+1);if(t>p+1){f(),c.push({type:`code`,text:e.slice(p+1,t)}),p=t+1;continue}}let g=m+h;if(g===`**`||g===`__`||g===`~~`){let n=l(e,p+2,g);if(n!==-1&&!(g===`__`&&s(e.charAt(p-1)))){f();let r=u(e.slice(p+2,n),t);g===`~~`?c.push({type:`strike`,children:r}):c.push({type:`strong`,children:r}),p=n+2;continue}d+=g,p+=2}else{if(m===`*`||m===`_`){let n=l(e,p+1,m);if(n!==-1&&!(m===`_`&&s(e.charAt(p-1)))){f(),c.push({type:`em`,children:u(e.slice(p+1,n),t)}),p=n+1;continue}}if(m===`[`){i.lastIndex=p;let t=i.exec(e);if(t){let e=t[1],n=t[2];if(e===void 0||n===void 0)throw Error(`The link pattern always captures its label and href`);f(),c.push({type:`link`,href:n,children:u(e)}),p+=t[0].length;continue}if(n){o.lastIndex=p;let t=o.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The citation pattern always captures its inner text`);if(n(e)){f(),c.push({type:`citation`,text:e}),p+=t[0].length;continue}}}}if(m===`!`){a.lastIndex=p;let t=a.exec(e);if(t){let e=t[1];if(e===void 0)throw Error(`The image pattern always captures its alt text`);f(),c.push({type:`image`,children:u(e)}),p+=t[0].length;continue}}d+=m,p+=1}}return f(),c.map((e,t)=>({...e,key:t}))}var d=/^[a-z][a-z0-9+.-]*:[a-z0-9_-]+\/[a-z0-9_.~-]+$/i,f=/^https?:/i,p=/^(mailto|tel):/i,m=/^(?:\/(?![/\\])|#|\?|\.{1,2}\/)/,h=/^https:\/\/[^/?#@\\\s]+$/i,g=/^[a-z][a-z0-9+.-]*:/i;function _(e){if(typeof e!=`string`)return null;let t=e.endsWith(`/`)?e.slice(0,-1):e;return h.test(t)?t:null}function v(e,t,n,r,i){if(n&&(t===`page`||d.test(e))){let t=n(e);if(t!=null)return{kind:`app`,target:t}}if(t===`app`)return null;let a=i==null?null:_(i),o=a===null?e:y(e,a);return o===null?null:m.test(o)?{kind:`page`,href:o}:t===`page`&&!(f.test(o)&&r&&b(o,r))?null:f.test(o)?{kind:r&&b(o,r)?`page`:`web`,href:o}:p.test(o)?{kind:`contact`,href:o}:null}function y(e,t){if(g.test(e))return e;if(e.startsWith(`//`))return`https:${e}`;if(e===``)return null;let n=e.indexOf(`#`),r=n<0?``:e.slice(n),i=n<0?e:e.slice(0,n),a=i.indexOf(`?`),o=a<0?i:i.slice(0,a),s=a<0?``:i.slice(a);return o===``?`${t}${s}${r}`:`${t}${ee(o.startsWith(`/`)?o:`/${o}`)}${s}${r}`}function ee(e){let t=e.split(`/`),n=[];return t.forEach((e,r)=>{let i=r===t.length-1;e===`.`?i&&n.push(``):e===`..`?(n.length>1&&n.pop(),i&&n.push(``)):n.push(e)}),n.join(`/`)}function b(e,t){if(e.slice(0,t.length).toLowerCase()!==t.toLowerCase())return!1;let n=e[t.length];return n===void 0||n===`/`||n===`?`||n===`#`}function x(e){return typeof e!=`string`||!e.startsWith(`/`)||e[1]===`/`||e[1]===`\\`?null:e}var S=/^\s*```/,C=/^\s*```\s*(\S*)/,w=/^\s{0,3}(#{1,6})\s+(.*?)(?:\s+#+)?\s*$/,T=/^\s*([-*_])(\s*\1){2,}\s*$/,E=/^(\s*)[-*+]\s+(.*)$/,D=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,O=/^\s*>\s?(.*)$/,te=/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/,ne=[1,2,3,4,5,6],k=e=>e.includes(`|`);function A(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function j(e,t){let n=e[t];if(n===void 0)throw Error(`startsTable was called past the last source line`);let r=e[t+1];return r!==void 0&&k(n)&&r.includes(`|`)&&te.test(r)}function M(e,t){let n=e[t];if(n===void 0)throw Error(`startsBlock was called past the last source line`);return S.test(n)||O.test(n)||E.test(n)||D.test(n)||w.test(n)||T.test(n)||j(e,t)}function N(e){let t=e.replace(/\t/g,` `).length;return Math.min(Math.floor(t/2),4)}function P(e){let t=D.exec(e);if(t){let e=t[1],n=t[2],r=t[3];if(e===void 0||n===void 0||r===void 0)throw Error(`The ordered list pattern always captures its indent, number and text`);return{text:r,depth:N(e),ordered:!0,number:Number(n)}}let n=E.exec(e);if(n){let e=n[1],t=n[2];if(e===void 0||t===void 0)throw Error(`The bullet list pattern always captures its indent and text`);return{text:t,depth:N(e),ordered:!1,number:0}}return null}function F(e){let t=(e??``).replace(/\r\n?/g,`
2
+ `).split(`
3
+ `),n=[],r=0;for(;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()){r+=1;continue}if(S.test(e)){let i=C.exec(e)?.[1]||null,a=[];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(S.test(e))break;a.push(e),r+=1}r+=1,n.push({type:`code`,text:a.join(`
4
+ `),language:i});continue}if(j(t,r)){let i=A(e),a=[];for(r+=2;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||!k(e))break;a.push(A(e)),r+=1}n.push({type:`table`,header:i,rows:a});continue}if(T.test(e)){n.push({type:`rule`}),r+=1;continue}let i=w.exec(e);if(i){let e=i[1],t=i[2];if(e===void 0||t===void 0)throw Error(`The heading pattern always captures its hashes and text`);let a=ne[e.length-1];if(a===void 0)throw Error(`The heading pattern always captures one to six hashes`);n.push({type:`heading`,level:a,text:t}),r+=1;continue}if(O.test(e)){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);let i=O.exec(n);if(!i)break;let a=i[1];if(a===void 0)throw Error(`The quote pattern always captures its text`);e.push(a),r+=1}n.push({type:`quote`,lines:e});continue}let a=P(e);if(a){let e=[];for(;r<t.length;){let n=t[r];if(n===void 0)throw Error(`parseMarkdown read past the last source line`);if(!n.trim())break;let i=P(n);if(i){if(i.depth===0&&i.ordered!==a.ordered)break;e.push(i)}else if(M(t,r))break;else{let t=e[e.length-1];if(t===void 0)throw Error(`A list continuation line follows a list with no item`);t.text+=` ${n.trim()}`}r+=1}n.push({type:`list`,ordered:a.ordered,start:a.ordered?a.number:1,items:e});continue}let o=[e];for(r+=1;r<t.length;){let e=t[r];if(e===void 0)throw Error(`parseMarkdown read past the last source line`);if(!e.trim()||M(t,r))break;o.push(e),r+=1}n.push({type:`paragraph`,lines:o})}return n.map((e,t)=>({...e,key:t}))}var I=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],L=[`razor`,`cshtml`],R=[`app`,`web`,`page`],z=e=>e!==void 0&&R.includes(e);function B(e,t,n,r,i=null){let a=V(n,r).map((e,n)=>{let r=t[n],i=r?.sig===e.sig?r.nodes:null;return{sig:e.sig,nodes:i??e.build()}}),o=new Set(a.flatMap(e=>e.nodes));for(let e of t)for(let t of e.nodes)o.has(t)||t.parentNode?.removeChild(t);let s=i;for(let t of a.flatMap(e=>e.nodes))(t.parentNode!==e||t.previousSibling!==s)&&e.insertBefore(t,s?s.nextSibling:e.firstChild),s=t;return a}function V(e,t){let n={links:z(t.links)?t.links:`web`,headings:t.headings===`text`?`text`:`outline`,resolveLink:t.resolveLink,isCitation:t.isCitation,figureText:typeof t.figureText==`function`?t.figureText:void 0,base:typeof t.base==`string`?t.base:void 0},r=t.resolverGeneration??0;return F(e).map(e=>({sig:`${JSON.stringify(e)}|${n.links}|${n.headings}|${n.base??``}|${r}`,build:()=>U(n,e)}))}var H=class extends t{_drawn;_blocks;_observer;_connected;_resolveLink;_isCitation;_resolverGeneration;_figureText;static get observedAttributes(){return[`links`,`headings`,`base`]}constructor(){super(),this._drawn=[],this._blocks=[],this._observer=null,this._connected=!1,this._resolveLink=void 0,this._isCitation=void 0,this._resolverGeneration=0,this._figureText=void 0}connectedCallback(){this._connected=!0,this._render(),typeof MutationObserver<`u`&&(this._observer=new MutationObserver(e=>{e.some(e=>!this._drawn.some(t=>t.contains(e.target)))&&this._render()}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._connected=!1,this._observer?.disconnect(),this._observer=null}get resolveLink(){return this._resolveLink}set resolveLink(e){this._resolveLink=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get base(){return this.getAttribute(`base`)??void 0}set base(e){e==null?this.removeAttribute(`base`):this.setAttribute(`base`,String(e))}get isCitation(){return this._isCitation}set isCitation(e){this._isCitation=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}get figureText(){return this._figureText}set figureText(e){this._figureText=typeof e==`function`?e:void 0,this._resolverGeneration+=1,this._connected&&this._render()}attributeChangedCallback(e,t,n){t!==n&&this._connected&&this._render()}_source(){return Array.from(this.children).find(e=>e instanceof HTMLPreElement&&e.classList.contains(`wui-markdown-source`))}_render(){let e=this._source();e&&(this._blocks=B(this,this._blocks,e.textContent??``,{links:this.getAttribute(`links`)??void 0,headings:this.getAttribute(`headings`)??void 0,base:this.getAttribute(`base`)??void 0,resolveLink:this._resolveLink,isCitation:this._isCitation,figureText:this._figureText,resolverGeneration:this._resolverGeneration},e),this._drawn=this._blocks.flatMap(e=>e.nodes),e.hidden=!0,this._observer?.takeRecords())}};function U(t,n){switch(n.type){case`paragraph`:return[e(`p`,null,...W(t,n.lines))];case`heading`:return[G(t,n)];case`list`:return K(t,n.items);case`table`:return[J(t,n)];case`code`:return[X(n)];case`quote`:return[e(`blockquote`,null,...W(t,n.lines))];case`rule`:return[e(`hr`)];default:return[]}}function W(t,n){let r=[];return n.forEach((n,i)=>{i>0&&r.push(e(`br`)),r.push(...Z(t,n))}),r}function G(t,n){let r=Z(t,n.text);return t.headings===`text`?e(`p`,{class:`fw-semibold`},...r):e(`h2`,null,...r)}function K(e,t){let n=[];for(let r=0;r<t.length;){let i=q(e,t,r);n.push(i.list),r=i.next}return n}function q(t,n,r){let i=n[r];if(!i)throw Error(`List run starts past its items.`);let{depth:a,ordered:o,number:s}=i,c=e(o?`ol`:`ul`,o&&s!==1?{start:s}:null),l=null,u=r,d=n[u];for(;d&&d.depth>=a;){if(d.depth===a)l=e(`li`,null,...Z(t,d.text)),c.append(l),u+=1;else{let e=q(t,n,u);if(!l)throw Error(`Nested list has no item before it.`);l.append(e.list),u=e.next}d=n[u]}return{list:c,next:u}}function J(t,n){let r=n.header.map(n=>e(`th`,{scope:`col`},...Z(t,n))),i=n.rows.map(r=>e(`tr`,null,...n.header.map((n,i)=>e(`td`,null,...Z(t,r[i]??``))))),a=e(`table`,{class:`table`},e(`thead`,null,e(`tr`,null,...r)),e(`tbody`,null,...i));return e(`div`,{class:`table-responsive`},a)}function Y(e){return e===null?`text`:L.includes(e.toLowerCase())?`razor`:I.includes(e)?e:`text`}function X(t){let n=e(`code`,null,t.text),r=e(`pre`,{class:`wui-code-source`},n);return e(`wui-code-block`,{class:`wui-code-block`,language:Y(t.language)},r)}function Z(e,t){return Q(e,u(t,{isCitation:e.isCitation}))}function Q(e,t){return t.flatMap(t=>re(e,t))}function re(t,n){switch(n.type){case`code`:return[e(`code`,null,n.text)];case`strong`:return[e(`strong`,null,...Q(t,n.children))];case`em`:return[e(`em`,null,...Q(t,n.children))];case`strike`:return[e(`del`,null,...Q(t,n.children))];case`image`:return[document.createTextNode(`[`),...Q(t,n.children),document.createTextNode(`]`)];case`link`:return ie(t,n);case`citation`:return[oe(n.text)];case`text`:return t.figureText?ae(t.figureText,n.text):[document.createTextNode(n.text)];default:throw Error(`wui-markdown: unknown inline token ${JSON.stringify(n)}`)}}function ie(e,t){let n=Q(e,t.children),r=v(t.href,e.links,e.resolveLink,globalThis.location?.origin,e.base);if(!r)return n;if(r.kind===`app`){let e=x(r.target);return e?[$(e,n,!1)]:n}return[$(r.href,n,r.kind===`web`)]}function ae(t,n){return t(n).map(t=>t.kind===`sub`||t.kind===`sup`?e(t.kind,null,t.text):document.createTextNode(t.text))}function oe(t){let n=e(`span`,{class:`chip-label`},t),r=e(`button`,{type:`button`,class:`chip-body`,"aria-label":t},n);return r.addEventListener(`click`,()=>{r.dispatchEvent(new CustomEvent(`wui-markdown-citation`,{bubbles:!0,detail:{citation:t}}))}),e(`span`,{class:`chip primary chip-outline chip-sm chip-clickable wui-markdown-citation`,"data-wui":`AppChip`},r)}function $(t,n,r){let i=e(`span`,{class:`wui-link__label`},...n);return e(`a`,{class:`wui-link wui-link--static`,"data-wui":`AppLink`,href:t,target:r?`_blank`:void 0,rel:r?`noopener noreferrer`:void 0},i)}export{H as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{n as t,r as n,t as r}from"./fieldState-D-zQcXUS.js";import{f as i}from"./formatters-DikbTYA4.js";import{t as a}from"./imeSafeEnter-DPs9qL3S.js";import{n as o}from"./listboxKeyNav-DtlIOryj.js";import{i as s,n as c,r as l,t as u}from"./mentionText-BJsw_opZ.js";import{a as d,l as f,s as p}from"./nativeOverlay-BHD2QV02.js";import{t as m}from"./serverHtml-BC6tAyAl.js";import{d as h}from"./wuiHttp-BWf9dDsZ.js";import{n as g,r as _,t as v}from"./textStore-opIEM4lu.js";import{t as y}from"./mentionInput.g-DJo6d2Gm.js";var b=8,x=40,S=()=>_(`mentionInput`,y),C=`[data-wui-control]`,w=`[data-wui-field]`,T=`[data-wui-menu]`,E=`[data-wui-live]`,D=0,O=e=>!!(e&&u.test(String(e.value??``))&&c(e.label)!==``);function k(e,t){let n=e.getAttribute(`size`);t.classList.toggle(`wui-input-sm`,n===`sm`),t.classList.toggle(`wui-input-lg`,n===`lg`),t.classList.toggle(`wui-input-xl`,n===`xl`)}function A(e,n){n.readOnly=t(e)||e.hasAttribute(`loading`)}function j(e){let t=e.ownerDocument;e.id||=`wui-mention-${++D}`;let n=t.createElement(`textarea`);n.id=`${e.id}-text`,n.className=`form-control textarea wui-mention-input-text`,n.rows=Number(e.getAttribute(`rows`))>0?Number(e.getAttribute(`rows`)):3,n.setAttribute(`data-wui-control`,``),n.setAttribute(`aria-autocomplete`,`list`),n.setAttribute(`aria-controls`,`${e.id}-people`);let r=e.getAttribute(`label`);r&&n.setAttribute(`aria-label`,r);let i=e.getAttribute(`placeholder`);i&&(n.placeholder=i);for(let t of[`aria-describedby`,`aria-invalid`]){let r=e.getAttribute(t);r&&n.setAttribute(t,r)}n.disabled=e.hasAttribute(`disabled`),A(e,n),k(e,n),e.appendChild(n);let a=e.getAttribute(`name`);if(a){let n=t.createElement(`input`);n.type=`hidden`,n.name=a,n.value=e.getAttribute(`value`)??``,n.setAttribute(`data-wui-field`,``),e.appendChild(n)}let o=t.createElement(`div`);o.className=`wui-mention-menu`,o.id=`${e.id}-people`,o.setAttribute(`role`,`listbox`),o.setAttribute(`aria-label`,e.getAttribute(`people-label`)??S().listNameLabel),o.setAttribute(`data-wui-menu`,``),o.setAttribute(`popover`,`manual`),e.appendChild(o);let s=t.createElement(`span`);s.className=`visually-hidden`,s.setAttribute(`data-wui-live`,``),s.setAttribute(`aria-live`,`polite`),s.setAttribute(`aria-atomic`,`true`),e.appendChild(s)}var M=class extends e{_wired;_pendingValue;_text;_mentions;_peopleProp;_declared;_loading;_searchFailed;_query;_results;_active;_timer;_searchSeq;_lastSearch;_abort;_onMenuDown;static get observedAttributes(){return[`disabled`,`readonly`,`loading`,`size`,`aria-invalid`,`aria-describedby`]}constructor(){super(),this._wired=!1,this._text=``,this._mentions=[],this._peopleProp=null,this._declared=null,this._loading=!1,this._searchFailed=!1,this._query=null,this._results=[],this._active=-1,this._timer=void 0,this._searchSeq=0,this._abort=null,this._onInput=this._onInput.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onCaret=this._onCaret.bind(this),this._onFocusOut=this._onFocusOut.bind(this),this._onMenuDown=e=>e.preventDefault(),this._onMenuClick=this._onMenuClick.bind(this)}connectedCallback(){for(let e of[`people`,`loading`,`searchFailed`,`value`])if(Object.hasOwn(this,e)){let t=Reflect.get(this,e);Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}if(this._wired)return;this._wired=!0,this.querySelector(C)||j(this);let e=this._requireControl(),t=this.querySelector(w)?.value??this.getAttribute(`value`)??``;this._pendingValue===void 0?this._load(t):this._load(this._pendingValue),this._pendingValue=void 0,this._syncState(),e.addEventListener(`input`,this._onInput),e.addEventListener(`keydown`,this._onKeyDown),e.addEventListener(`click`,this._onCaret),e.addEventListener(`keyup`,this._onCaret),this.addEventListener(`focusout`,this._onFocusOut);let n=this._requireMenu();n.addEventListener(`mousedown`,this._onMenuDown),n.addEventListener(`click`,this._onMenuClick),n.addEventListener(`mousemove`,e=>{let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&Number(t.dataset.index)!==this._active&&this._setActive(Number(t.dataset.index),{reveal:!1})})}disconnectedCallback(){this._close(),clearTimeout(this._timer),this._abort?.abort()}attributeChangedCallback(e,t,n){let r=this._control();r&&(e===`disabled`?(r.disabled=n!==null,n!==null&&this._close()):e===`readonly`?(A(this,r),n!==null&&this._close(),this._syncState()):e===`loading`?(A(this,r),this._syncState(),this._query!==null&&this._renderMenu()):e===`size`?k(this,r):n===null?r.removeAttribute(e):r.setAttribute(e,n))}get value(){return s(this._text,this._mentions)}set value(e){let t=e==null?``:String(e);this._wired?t!==this.value&&this._load(t):this._pendingValue=t}get mentions(){let e=/* @__PURE__ */ new Set,t=[];for(let n of[...this._mentions].sort((e,t)=>e.start-t.start))e.has(n.id)||(e.add(n.id),t.push({id:n.id,label:n.label}));return t}get people(){return this._peopleProp?this._peopleProp:(this._declared||=[...this.querySelectorAll(`[data-wui-people] > wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})),this._declared)}set people(e){this._peopleProp=Array.isArray(e)?e.filter(O):[],this._searchFailed=!1,(this._isOpen()||this._query!==null)&&this._refresh()}get searchFailed(){return this._searchFailed}set searchFailed(e){this._searchFailed=!!e,this._query!==null&&this._renderMenu()}get loading(){return this._loading||this.hasAttribute(`loading`)}set loading(e){this._loading=!!e,this.toggleAttribute(`loading`,this._loading),this._query!==null&&this._renderMenu()}focus(e){this._control()?.focus(e)}clear(){this._load(``),this._emit()}_control(){return this.querySelector(C)}_menu(){return this.querySelector(T)}_requireControl(){let e=this._control();if(!e)throw Error(`<wui-mention-input> has no text box.`);return e}_requireMenu(){let e=this._menu();if(!e)throw Error(`<wui-mention-input> has no people list.`);return e}_load(e){let{text:t,mentions:n}=l(e);this._text=t,this._mentions=n;let r=this._control();r&&(r.defaultValue=t,r.value=t),this._syncField(),this._close()}_syncField(){let e=this.querySelector(w);e&&(e.value=this.value)}_emit(){this._syncField(),this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:this.value,mentions:this.mentions}}))}_onInput(){let e=this._requireControl(),t=e.value,n=this._text,r=t.length-n.length,i=Math.min(n.length,t.length),a=Math.max(0,Math.min(i,e.selectionEnd-Math.max(r,0))),o=0;for(;o<a&&n[o]===t[o];)o++;let s=0;for(;s<i-o&&n[n.length-1-s]===t[t.length-1-s];)s++;let c=n.length-s;this._mentions=this._mentions.filter(e=>e.end<=o||e.start>=c).map(e=>e.start>=c?{...e,start:e.start+r,end:e.end+r}:e),this._text=t,this._emit(),this._onCaret()}_onCaret(e){if(e instanceof KeyboardEvent&&e.type===`keyup`&&[`ArrowUp`,`ArrowDown`,`Enter`,`Tab`,`Escape`].includes(e.key))return;let t=this._queryAtCaret();t?this._query&&t.text===this._query.text&&t.start===this._query.start||(this._query=t,this._refresh()):this._close()}_queryAtCaret(){let e=this._control();if(!e||r(this)||e.selectionStart!==e.selectionEnd)return null;let t=e.selectionStart,n=this._text,i=n.lastIndexOf(`@`,t-1);if(i<0||i>0&&!/[\s([{"'“‘]/.test(n.charAt(i-1)))return null;let a=n.slice(i+1,t);return a.length>40||/[\n@]/.test(a)||/^\s/.test(a)||/\s{2}/.test(a)||this._mentions.some(e=>i>=e.start&&i<e.end)?null:{start:i,end:t,text:a}}_refresh(){if(!this._query)return;let e=this.hasAttribute(`remote`)||this.hasAttribute(`source`);if(e&&this._query.text.length<this._minChars()){this._results=[],this._close();return}e&&!this._answered(this._query.text)&&this._search(this._query.text);let t=this._query.text.toLowerCase(),n=e?this.people:this.people.filter(e=>c(e.label).toLowerCase().includes(t));this._results=n.slice(0,8),this._renderMenu()}_answered(e){return this._lastSearch===e}_minChars(){let e=this.getAttribute(`min-chars`),t=e==null||e===``?1:Number(e);return Number.isFinite(t)&&t>=0?t:1}_debounce(){let e=this.getAttribute(`debounce`),t=e==null||e===``?250:Number(e);return Number.isFinite(t)&&t>=0?t:250}_search(e){this._lastSearch=e,clearTimeout(this._timer);let t=++this._searchSeq;this._timer=setTimeout(()=>{let n=this.getAttribute(`source`);n?this._fetchPeople(n,e,t):this.dispatchEvent(new CustomEvent(`search`,{bubbles:!0,detail:{query:e,seq:t}}))},this._debounce())}async _fetchPeople(e,t,n){this._abort?.abort();let r=new AbortController;this._abort=r,this.loading=!0;let i=`${e}${e.includes(`?`)?`&`:`?`}q=${encodeURIComponent(t)}`,a=await h(i,{signal:r.signal});if(n!==this._searchSeq)return;if(this._abort=null,!a.ok){this._peopleProp=[],this._searchFailed=!0,this.loading=!1,this._refresh();return}this._searchFailed=!1;let o=m(a.html);this._peopleProp=[...o.querySelectorAll(`wui-option`)].map(e=>({value:e.getAttribute(`value`)??``,label:(e.textContent??``).trim(),description:e.getAttribute(`data-description`)||void 0,src:e.getAttribute(`data-src`)||void 0})).filter(O),this.loading=!1,this._refresh()}_isOpen(){let e=this._menu();return e!==null&&p(e)}_renderMenu(){let e=this._menu(),t=this._control();if(!e||!t||!this._query)return;this._syncState();let n=this.ownerDocument;if(e.replaceChildren(),this._results.forEach((t,r)=>{let i=n.createElement(`div`);if(i.className=`wui-mention-option`,i.id=`${e.id}-${r}`,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.dataset.index=String(r),t.src){let e=n.createElement(`img`);e.className=`wui-mention-option-photo`,e.src=t.src,e.alt=``,i.appendChild(e)}let a=n.createElement(`span`);a.className=`wui-mention-option-text`;let o=n.createElement(`span`);if(o.className=`wui-mention-option-label`,o.textContent=c(t.label),a.appendChild(o),t.description){let e=n.createElement(`span`);e.className=`wui-mention-option-description`,e.textContent=String(t.description),a.appendChild(e)}i.appendChild(a),e.appendChild(i)}),!this._results.length){let t=n.createElement(`div`);t.className=`wui-mention-empty`,t.textContent=this.loading?S().searchingLabel:this._searchFailed?S().searchFailedMessage:`${S().noMatchLabel} “${this._query.text}”`,e.appendChild(t)}f(t,e,{mode:`manual`}),this._setActive(this._results.length?0:-1),this.loading||this._announce(this._results.length?g(S(),`foundText`,this._results.length,{count:i(this._results.length,{decimals:0})}):this._searchFailed?S().searchFailedMessage:`${S().noMatchLabel}.`)}_syncState(){let e=this._control();e&&n(this,e)}_close(){this._query=null,this._lastSearch=void 0,clearTimeout(this._timer);let e=this._menu();if(e){let t=p(e);d(e),t&&e.replaceChildren()}this._active=-1,this._control()?.removeAttribute(`aria-activedescendant`)}_setActive(e,{reveal:t=!0}={}){let n=this._requireMenu(),r=[...n.querySelectorAll(`.wui-mention-option`)];this._active=e>=0&&e<r.length?e:-1;let i=this._active>=0?r[this._active]??null:null;for(let e of r)e.setAttribute(`aria-selected`,e===i?`true`:`false`);o(n,i),i?(t&&i.scrollIntoView?.({block:`nearest`}),this._requireControl().setAttribute(`aria-activedescendant`,i.id)):this._requireControl().removeAttribute(`aria-activedescendant`)}_onKeyDown(e){if(this._isOpen()&&this._query){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=this._results.length;if(!t)return;let n=e.key===`ArrowDown`?1:-1;this._setActive((this._active+n+t)%t);return}if((a(e)||e.key===`Tab`)&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._active>=0){e.preventDefault(),this._pick(this._results[this._active]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close();return}}a(e)&&(e.ctrlKey||e.metaKey)?(e.preventDefault(),this.dispatchEvent(new CustomEvent(`wui:mention-input:submit`,{bubbles:!0,detail:{value:this.value}}))):e.key===`Backspace`&&this._removeWholeMention(e)}_removeWholeMention(e){let t=this._requireControl();if(t.selectionStart!==t.selectionEnd)return;let n=t.selectionStart,r=this._mentions.find(e=>e.end===n);r&&(e.preventDefault(),this._replace(r.start,r.end,``))}_onMenuClick(e){let t=e.target instanceof Element?e.target.closest(`.wui-mention-option`):null;t&&this._pick(this._results[Number(t.dataset.index)])}_pick(e){if(!e||!this._query)return;let t=c(e.label),{start:n,end:r}=this._query,i=this._text.slice(r),a=`@${t}${/^\s/.test(i)?``:` `}`;this._replace(n,r,a,{id:String(e.value),label:t}),this._announce(v(S().mentioned,{label:t}))}_replace(e,t,n,r){let i=this._requireControl(),a=n.length-(t-e);this._mentions=this._mentions.filter(n=>n.end<=e||n.start>=t).map(e=>e.start>=t?{...e,start:e.start+a,end:e.end+a}:e),r&&this._mentions.push({start:e,end:e+1+r.label.length,id:r.id,label:r.label}),this._text=this._text.slice(0,e)+n+this._text.slice(t),i.value=this._text;let o=e+n.length;i.setSelectionRange(o,o),this._close(),i.focus(),this._emit()}_onFocusOut(e){e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this._close()}_announce(e){let t=this.querySelector(E);t&&(t.textContent=``,t.textContent=e)}};export{b as n,M as r,x as t};
@@ -1 +1 @@
1
- import{t as e}from"./elementBase-Cxeyx0tU.js";import{h as t,o as n,p as r,u as i}from"./nativeOverlay-DGady-wN.js";var a=class extends e{_doc;_release;_opener;_returnTo;_session;_closing;_reopen;static get observedAttributes(){return[`open`,`static`,`no-escape`]}constructor(){super(),this._doc=null,this._release=null,this._opener=null,this._returnTo=null,this._session=0,this._closing=!1,this._reopen=!1}connectedCallback(){this._doc=this.ownerDocument,t(this._doc),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._session++,this._closing=!1,this._reopen=!1;let e=this.querySelector(`dialog`);this._release&&e instanceof HTMLDialogElement&&e.close(),this._releaseDialog(),this._opener=null,this._returnTo=null,this._doc=null}attributeChangedCallback(e){this._doc&&e===`open`&&(this.hasAttribute(`open`)?this._open():this._close())}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_open(){if(this._closing){this._reopen=!0;return}if(this._release)return;let e=++this._session,t=this._opener;if(this._returnTo=t,this._opener=null,this.dispatchEvent(new CustomEvent(`wui-modal-open`,{bubbles:!0,detail:{trigger:t}})),!this.isOpen)return;let n=this._dialog();this._release=i(n,{escape:!this.hasAttribute(`no-escape`),backdrop:!this.hasAttribute(`static`),focus:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle(e,n)}_close(){if(this._closing){this._reopen=!1;return}if(!this._release)return;this._closing=!0;let e=this._session,t=this._dialog();n(t).then(()=>{e===this._session&&(this._closing=!1,this._releaseDialog(),r(this._returnTo,t),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-modal-closed`,{bubbles:!0})),this._reopen&&(this._reopen=!1,this.isOpen&&this._open()))})}_settle(e,t){let n=t.getAnimations?.()??[];n.length?Promise.allSettled(n.map(e=>e.finished)).then(()=>{e===this._session&&this.isOpen&&this._announceOpened()}):this._announceOpened()}_announceOpened(){this.dispatchEvent(new CustomEvent(`wui-modal-opened`,{bubbles:!0}))}_requestClose(e){this.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}))&&this.removeAttribute(`open`)}_releaseDialog(){let e=this._release;this._release=null,e?.()}_dialog(){let e=this.querySelector(`dialog`);if(!(e instanceof HTMLDialogElement))throw TypeError(`wui-modal has no <dialog>`);return e}};export{a as t};
1
+ import{t as e}from"./elementBase-Cxeyx0tU.js";import{h as t,o as n,p as r,u as i}from"./nativeOverlay-BHD2QV02.js";var a=class extends e{_doc;_release;_opener;_returnTo;_session;_closing;_reopen;static get observedAttributes(){return[`open`,`static`,`no-escape`]}constructor(){super(),this._doc=null,this._release=null,this._opener=null,this._returnTo=null,this._session=0,this._closing=!1,this._reopen=!1}connectedCallback(){this._doc=this.ownerDocument,t(this._doc),this.hasAttribute(`open`)&&this._open()}disconnectedCallback(){this._session++,this._closing=!1,this._reopen=!1;let e=this.querySelector(`dialog`);this._release&&e instanceof HTMLDialogElement&&e.close(),this._releaseDialog(),this._opener=null,this._returnTo=null,this._doc=null}attributeChangedCallback(e){this._doc&&e===`open`&&(this.hasAttribute(`open`)?this._open():this._close())}get isOpen(){return this.hasAttribute(`open`)}show(e){e&&(this._opener=e),this.setAttribute(`open`,``)}hide(){this.removeAttribute(`open`)}_open(){if(this._closing){this._reopen=!0;return}if(this._release)return;let e=++this._session,t=this._opener;if(this._returnTo=t,this._opener=null,this.dispatchEvent(new CustomEvent(`wui-modal-open`,{bubbles:!0,detail:{trigger:t}})),!this.isOpen)return;let n=this._dialog();this._release=i(n,{escape:!this.hasAttribute(`no-escape`),backdrop:!this.hasAttribute(`static`),focus:`first-control`,onRequestClose:e=>this._requestClose(e)}),this._settle(e,n)}_close(){if(this._closing){this._reopen=!1;return}if(!this._release)return;this._closing=!0;let e=this._session,t=this._dialog();n(t).then(()=>{e===this._session&&(this._closing=!1,this._releaseDialog(),r(this._returnTo,t),this._returnTo=null,this.dispatchEvent(new CustomEvent(`wui-modal-closed`,{bubbles:!0})),this._reopen&&(this._reopen=!1,this.isOpen&&this._open()))})}_settle(e,t){let n=t.getAnimations?.()??[];n.length?Promise.allSettled(n.map(e=>e.finished)).then(()=>{e===this._session&&this.isOpen&&this._announceOpened()}):this._announceOpened()}_announceOpened(){this.dispatchEvent(new CustomEvent(`wui-modal-opened`,{bubbles:!0}))}_requestClose(e){this.dispatchEvent(new CustomEvent(`wui-modal-close`,{bubbles:!0,cancelable:!0,detail:{reason:e}}))&&this.removeAttribute(`open`)}_releaseDialog(){let e=this._release;this._release=null,e?.()}_dialog(){let e=this.querySelector(`dialog`);if(!(e instanceof HTMLDialogElement))throw TypeError(`wui-modal has no <dialog>`);return e}};export{a as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{a as n,l as r,s as i}from"./nativeOverlay-BHD2QV02.js";import{n as a,t as o}from"./rtl-g7G8Bsib.js";var s=`.wui-nav-menu-link`,c=`(max-width: 767.98px)`,l=`data-open`,u=e=>e instanceof Element?e:e instanceof Node?e.parentElement:null,d=e=>[...e].filter(e=>e instanceof HTMLElement),f=e=>{let t=e.children[0];if(!(t instanceof HTMLElement))throw Error(`Navigation entry has no control.`);return t},p=e=>{let t=e.children[1];return t instanceof HTMLElement?t:null},m=(e,t,n)=>{let r=e[t];if(r===void 0)throw Error(n);return r},h=class extends t{constructor(){super(),this._onClick=e=>this._handleClick(e),this._onKeyDown=e=>this._handleKeyDown(e),this._onFocusOut=e=>{let t=this._openItem(),n=e.relatedTarget;t&&n instanceof Node&&!t.contains(n)&&this._set(t,!1)},this._onPointerDown=()=>{this._pressedOpen=this._openItem()},this._onModeChange=()=>{let e=this._openItem();e&&this._set(e,!1)},this._onOutsidePress=e=>{let t=this._openItem();t&&!e.composedPath().includes(t)&&this._set(t,!1)},this._pressedOpen=null,this._media=null}connectedCallback(){this._teardown(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`pointerdown`,this._onPointerDown,!0),this._media=window.matchMedia(c),this._media.addEventListener(`change`,this._onModeChange)}disconnectedCallback(){this._teardown()}open(e){let t=this._items().find(t=>{let n=t.children[0];return n instanceof HTMLElement&&this._isTrigger(n)&&n.dataset.key===e});t&&this._set(t,!0)}close(e=!1){let t=this._openItem();t&&(this._set(t,!1),e&&f(t).focus({preventScroll:!0}))}_items(){return d(this.querySelectorAll(`.wui-nav-menu-item`))}_openItem(){return this._items().find(e=>{let t=p(e);return t!==null&&this._isOpen(t)})??null}_isOpen(e){return e.hasAttribute(l)||i(e)}_isTrigger(e){return!!e?.classList.contains(`wui-nav-menu-trigger`)}_entries(){return this._items().map(f)}_links(e){let t=p(e);return t?d(t.querySelectorAll(s)):[]}_set(e,t){let a=p(e);if(!a)return;let o=f(e);if(t){let t=this._openItem();if(t&&t!==e&&this._set(t,!1),this._isOpen(a))return;o.setAttribute(`aria-expanded`,`true`),window.matchMedia(c).matches?(a.setAttribute(l,``),document.addEventListener(`pointerdown`,this._onOutsidePress,!0)):r(o,a,{mode:`auto`,below:!0,flipAlign:!0,onClosed:()=>this._settle(e)}),this._emit(o,!0)}else a.removeAttribute(l),document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),i(a)&&n(a),this._settle(e)}_settle(e){let t=f(e);t.getAttribute(`aria-expanded`)!==`false`&&(t.setAttribute(`aria-expanded`,`false`),this._emit(t,!1))}_emit(e,t){this.dispatchEvent(new CustomEvent(`wui-navigation-menu:toggle`,{bubbles:!0,detail:{key:e.dataset.key??null,open:t}}))}_handleClick(t){let n=this._pressedOpen;this._pressedOpen=null;let r=u(t.target),i=r?.closest(`.wui-nav-menu-trigger`);if(i&&this.contains(i)){let t=e(i.parentElement,`Navigation trigger has no entry.`),r=e(p(t),`Navigation entry has no panel.`),a=n===t||this._isOpen(r);this._set(t,!a);return}let a=r?.closest(s);a&&this.contains(a)&&this.close()}_handleKeyDown(t){if(this._pressedOpen=null,t.altKey||t.ctrlKey||t.metaKey)return;let n=u(t.target)?.closest(`.wui-nav-menu-trigger, .wui-nav-menu-toplink, .wui-nav-menu-link`);if(!(n instanceof HTMLElement)||!this.contains(n))return;let r=this._openItem();if(t.key===`Escape`){if(!r||!p(r)?.hasAttribute(l))return;t.preventDefault(),t.stopPropagation();let e=r.contains(n);this._set(r,!1),e&&f(r).focus({preventScroll:!0});return}if(n.matches(s)){this._linkKey(t,n);return}let i=this._entries(),c=i.indexOf(n),d=a(t.key,o(this));if(d===`ArrowRight`||d===`ArrowLeft`||d===`Home`||d===`End`){t.preventDefault();let e=d===`Home`?0:d===`End`?i.length-1:(c+(d===`ArrowRight`?1:-1)+i.length)%i.length;r&&this._set(r,!1),m(i,e,`Navigation has no entry to focus.`).focus({preventScroll:!0})}else if(t.key===`ArrowDown`&&this._isTrigger(n)){t.preventDefault();let r=e(n.parentElement,`Navigation trigger has no entry.`);this._set(r,!0),m(this._links(r),0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})}}_linkKey(t,n){let r=e(n.closest(`.wui-nav-menu-item`),`Navigation link has no entry.`),i=this._links(r),a=i.indexOf(n);t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),m(i,(a+(t.key===`ArrowDown`?1:-1)+i.length)%i.length,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`Home`?(t.preventDefault(),m(i,0,`Navigation panel has no link to focus.`).focus({preventScroll:!0})):t.key===`End`&&(t.preventDefault(),m(i,i.length-1,`Navigation panel has no link to focus.`).focus({preventScroll:!0}))}_teardown(){for(let e of this._items()){let t=p(e);if(!t)continue;let r=t.hasAttribute(l);t.removeAttribute(l),n(t),r&&this._settle(e)}this._media?.removeEventListener(`change`,this._onModeChange),this._media=null,document.removeEventListener(`pointerdown`,this._onOutsidePress,!0),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`pointerdown`,this._onPointerDown,!0)}};export{h as t};
@@ -1 +1 @@
1
- import{r as e}from"./dom-Do1pAA12.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-DGady-wN.js";import{o as s,r as c,s as l}from"./notificationDays-DQlrEZ3z.js";import{l as u}from"./wuiHttp-DGbD7Fra.js";import{r as d}from"./textStore-opIEM4lu.js";import{t as f}from"./notificationCentre.g-UsAurkUz.js";var p=()=>d(`notificationCentre`,f),m=`.wui-notification-center-trigger`,h=`.wui-notification-center-panel`,g=`.wui-notification-center-count`,_=`.wui-notification-center-live`,v=`.wui-notification-center-markall`,y=`.wui-notification-center-item`,b=`wui-notification-center-item-read`,x=`.wui-notification-center-unread-label`,S=`.app-tabs`,C=`.wui-notification-center-tabs [role='tablist']`,w=`.wui-notification-center-tabs [role='tab']`,T=`.wui-notification-center-empty`,E=`(max-width: 767.98px)`,D={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},O=e=>!!e,k=()=>({forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().clientMessage,server:p().serverMessage,network:p().networkMessage}),A=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},j=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),M=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(A(this,h)===null||A(this,m)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=A(this,h);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){A(this,h)!==null&&A(this,m)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(A(this,h),`<wui-notification-center> needs its panel to open.`),n=e(A(this,m),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(E).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=A(this,h);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=A(this,h);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(A(this,h),`<wui-notification-center> needs its panel to open.`),e(A(this,m),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),A(this,h)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&A(this,m)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(m)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${y}:not(.${b}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(w);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(`${m}, ${v}, ${y}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(m)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(v)?this._markAll():this._markItem(r)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(h)?.contains(t)||t.closest(S))return;let r=D[e.key];if(r===void 0)return;let i=j(this,y).filter(n);if(i.length===0)return;let a=t.closest(y),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(b)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(O),!1))}async _markAll(){if(this._busy)return;let e=j(this,`${y}:not(.${b})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(O),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||k()[e]||p().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(p().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(C);if(t instanceof HTMLElement){for(let n of j(t,w)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of j(this,C)){let t=A(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of j(this,y)){let r=n.dataset.archived===`true`,i=n.classList.contains(b),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of j(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=A(this,T);n&&(n.hidden=t)}_applyRead(e){e.classList.add(b),e.querySelector(x)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=A(this,g);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(m)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||p().label,this._unread));let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(_);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{M as t};
1
+ import{i as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{t as n}from"./isDrawn-BbF4phmB.js";import{a as r,l as i,m as a,s as o}from"./nativeOverlay-BHD2QV02.js";import{o as s,r as c,s as l}from"./notificationDays-grsj1DtM.js";import{d as u}from"./wuiHttp-BWf9dDsZ.js";import{r as d}from"./textStore-opIEM4lu.js";import{t as f}from"./notificationCentre.g-UsAurkUz.js";var p=()=>d(`notificationCentre`,f),m=`.wui-notification-center-trigger`,h=`.wui-notification-center-panel`,g=`.wui-notification-center-count`,_=`.wui-notification-center-live`,v=`.wui-notification-center-markall`,y=`.wui-notification-center-item`,b=`wui-notification-center-item-read`,x=`.wui-notification-center-unread-label`,S=`.app-tabs`,C=`.wui-notification-center-tabs [role='tablist']`,w=`.wui-notification-center-tabs [role='tab']`,T=`.wui-notification-center-empty`,E=`(max-width: 767.98px)`,D={ArrowDown:1,ArrowUp:-1,Home:`first`,End:`last`},O=e=>!!e,k=()=>({forbidden:p().forbiddenMessage,client:p().clientMessage,validation:p().clientMessage,server:p().serverMessage,network:p().networkMessage}),A=(e,t)=>{let n=e.querySelector(t);return n instanceof HTMLElement?n:null},j=(e,t)=>[...e.querySelectorAll(t)].filter(e=>e instanceof HTMLElement),M=class extends t{constructor(){super(),this._unread=0,this._busy=!1,this._sheet=!1,this._awaitChildren=null,this._onClick=e=>this._click(e),this._onKeyDown=e=>this._key(e),this._onToggle=e=>{e.type===`toggle`&&`newState`in e&&e.newState===`closed`&&this._closedByBrowser()},this._onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&!this.contains(t)&&this.close()}}static get observedAttributes(){return[`open`]}connectedCallback(){this._unread=this._initialUnread(),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`focusout`,this._onFocusOut),this.addEventListener(`toggle`,this._onToggle,!0),this.isOpen&&(A(this,h)===null||A(this,m)===null)?(this._awaitChildren=new MutationObserver(()=>this._finishAwaitedOpen()),this._awaitChildren.observe(this,{childList:!0})):(this._syncOpen(),this.isOpen&&this._showPanel())}disconnectedCallback(){this._disarmAwait(),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`focusout`,this._onFocusOut),this.removeEventListener(`toggle`,this._onToggle,!0);let e=A(this,h);e&&r(e)}attributeChangedCallback(e,t,n){e===`open`&&t!==n&&(this._awaitChildren?n===null&&this._disarmAwait():this.isConnected&&(n===null?this._hidePanel():this._showPanel()))}_finishAwaitedOpen(){A(this,h)!==null&&A(this,m)!==null&&(this._disarmAwait(),this._syncOpen(),this._showPanel())}_disarmAwait(){this._awaitChildren?.disconnect(),this._awaitChildren=null}_showPanel(){let t=e(A(this,h),`<wui-notification-center> needs its panel to open.`),n=e(A(this,m),`<wui-notification-center> needs its trigger to open.`);o(t)||(this._sheet=window.matchMedia(E).matches,this._sheet?a(t,!0):i(n,t,{mode:`auto`,onClosed:()=>this._closedByBrowser()}),o(t)&&this._layoutTabs())}_hidePanel(){let e=A(this,h);e&&o(e)&&(this._sheet?a(e,!1):r(e))}_closedByBrowser(){if(!this.isConnected||!this.hasAttribute(`open`))return;let e=A(this,h);this.close({restoreFocus:e?.contains(this.ownerDocument.activeElement)??!1})}get isOpen(){return this.hasAttribute(`open`)}open(){this.isOpen||(e(A(this,h),`<wui-notification-center> needs its panel to open.`),e(A(this,m),`<wui-notification-center> needs its trigger to open.`),this.setAttribute(`open`,``),this._syncOpen(),A(this,h)?.focus(),this._announceToggle())}close({restoreFocus:e=!1}={}){this.isOpen&&(this.removeAttribute(`open`),this._syncOpen(),e&&A(this,m)?.focus(),this._announceToggle())}toggle(){this.isOpen?this.close():this.open()}_announceToggle(){this.dispatchEvent(new CustomEvent(`wui:notification-center:toggle`,{bubbles:!0,detail:{open:this.isOpen}}))}_syncOpen(){this.querySelector(m)?.setAttribute(`aria-expanded`,this.isOpen?`true`:`false`)}_initialUnread(){let e=Number.parseInt(this.getAttribute(`unread`)??``,10);return Number.isInteger(e)&&e>=0?e:this.querySelectorAll(`${y}:not(.${b}):not([data-archived="true"])`).length}_click(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(w);if(n instanceof HTMLElement&&this.contains(n)){if(this.hasAttribute(`controlled`))return;this._pickTab(n);return}let r=t.closest(`${m}, ${v}, ${y}`);r instanceof HTMLElement&&this.contains(r)&&(r.matches(m)?this.toggle():this.hasAttribute(`controlled`)||(r.matches(v)?this._markAll():this._markItem(r)))}_key(e){if(!this.isOpen)return;let t=e.target;if(!(t instanceof Element))throw Error(`Keyboard event target is not an element.`);if(!this.querySelector(h)?.contains(t)||t.closest(S))return;let r=D[e.key];if(r===void 0)return;let i=j(this,y).filter(n);if(i.length===0)return;let a=t.closest(y),o=a instanceof HTMLElement?i.indexOf(a):-1,s;s=r===`first`?0:r===`last`?i.length-1:o===-1?r===1?0:i.length-1:Math.min(i.length-1,Math.max(0,o+r)),e.preventDefault(),i[s]?.focus()}_markItem(e){e.classList.contains(b)||(this._applyRead(e),e.dataset.archived!==`true`&&(this._unread=Math.max(0,this._unread-1)),this._render(),this._say(l(this._unread)),this._emitRead([e.dataset.id].filter(O),!1))}async _markAll(){if(this._busy)return;let e=j(this,`${y}:not(.${b})`);if(e.length===0&&this._unread===0)return;let t=e.map(e=>e.dataset.id).filter(O),n=this.getAttribute(`read-action`);if(n){this._setBusy(!0);let e=new URLSearchParams;for(let n of t)e.append(`ids`,n);let r=await u(n,{method:`POST`,body:e});if(this._setBusy(!1),!r.ok){if(r.kind===`session`||r.kind===`aborted`)return;let e=r.kind,t=r.message||k()[e]||p().serverMessage;this._say(t),this.dispatchEvent(new CustomEvent(`wui:notification-center:failed`,{bubbles:!0,detail:{kind:e,message:t}}));return}}for(let t of e)this._applyRead(t);this._unread=0,this._render(),this._say(p().allReadText),this._emitRead(t,!0)}_pickTab(e){let t=e.closest(C);if(t instanceof HTMLElement){for(let n of j(t,w)){let t=n===e;n.classList.toggle(`active`,t),n.setAttribute(`aria-selected`,t?`true`:`false`),n.setAttribute(`tabindex`,t?`0`:`-1`)}this._layoutTabs(),this._filterItems(e.dataset.key)}}_layoutTabs(){for(let e of j(this,C)){let t=A(e,`.app-tab.active`);t&&(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.setAttribute(`data-wui-tabs`,``)}}_filterItems(e){let t=!1;for(let n of j(this,y)){let r=n.dataset.archived===`true`,i=n.classList.contains(b),a=e===`archived`?r:!r&&(e!==`unread`||!i);a&&(t=!0);let o=n.closest(`li`);o&&(o.hidden=!a)}for(let e of j(this,`.wui-notification-center-list section`))e.hidden=[...e.querySelectorAll(`li`)].every(e=>e.hidden);let n=A(this,T);n&&(n.hidden=t)}_applyRead(e){e.classList.add(b),e.querySelector(x)?.remove()}_setBusy(e){this._busy=e;let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=e||this._unread===0,e?t.setAttribute(`aria-busy`,`true`):t.removeAttribute(`aria-busy`))}_render(){let e=A(this,g);e&&(e.textContent=c(this._unread),e.hidden=this._unread===0),this.querySelector(m)?.setAttribute(`aria-label`,s(this.getAttribute(`label`)||p().label,this._unread));let t=this.querySelector(v);t instanceof HTMLButtonElement&&(t.disabled=this._unread===0)}_say(e){let t=this.querySelector(_);t&&(t.textContent=e)}_emitRead(e,t){this.dispatchEvent(new CustomEvent(`wui:notification-center:read`,{bubbles:!0,detail:{ids:e,all:t}}))}};export{M as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./devWarn-DXdRWZs3.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,t as r}from"./rtl-g7G8Bsib.js";import{r as i}from"./textStore-opIEM4lu.js";import{t as a}from"./orgTree.g-CIg75quV.js";var o=`li[data-wui-org-node]`,s=`:scope > .wui-org-tree-node`,c=`:scope > .wui-org-tree-node > .wui-org-tree-text > .wui-org-tree-name`,l=`:scope > .wui-org-tree-children`,u=`:scope > .wui-org-tree-node > [data-wui-org-toggle]`,d=`[data-wui-org-toggle]`,f=`a, button, input, select, textarea`,p=`.wui-org-tree-overlay`,m=`[data-wui-org-search]`,h=`[data-wui-org-canvas]`,g=`[data-wui-org-live]`,_=`--wui-org-tree-print-scale`,v=718,y=1e3,b=150,x=()=>i(`orgTree`,a),S=e=>[...e.querySelectorAll(o)].filter(e=>e instanceof HTMLElement),C=e=>e.querySelector(c)?.textContent?.trim()??``,w=e=>e.getAttribute(`data-wui-org-node`),T=e=>e.getAttribute(`aria-expanded`)===`true`,E=class extends t{static get observedAttributes(){return[`selected`,`selectable`,`expand-label`,`collapse-label`,`search-results-text`,`search-empty-text`]}constructor(){super(),this._query=``,this._snapshot=null,this._observer=null,this._announceTimer=void 0,this._onKeyDown=e=>this._handleKeyDown(e),this._onClick=e=>this._handleClick(e),this._onFocusIn=e=>this._handleFocusIn(e),this._onInput=e=>this._handleInput(e),this._onBeforePrint=()=>this._scaleForPrint(),this._onAfterPrint=()=>this.style.removeProperty(_)}connectedCallback(){this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`click`,this._onClick),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`input`,this._onInput),window.addEventListener(`beforeprint`,this._onBeforePrint),window.addEventListener(`afterprint`,this._onAfterPrint);let t=this.querySelector(h);t?(this._observer=new MutationObserver(()=>{this._query&&this._applySearch(this._query)}),this._observer.observe(t,{childList:!0,subtree:!0})):e(`[@webority/ui-elements] <wui-org-tree> has no [data-wui-org-canvas]; render the tree markup inside it.`)}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`input`,this._onInput),window.removeEventListener(`beforeprint`,this._onBeforePrint),window.removeEventListener(`afterprint`,this._onAfterPrint),this._observer?.disconnect(),this._observer=null,clearTimeout(this._announceTimer)}attributeChangedCallback(e){e===`selected`||e===`selectable`?this._applySelected():(e===`expand-label`||e===`collapse-label`)&&this._syncToggles()}get selected(){return this.getAttribute(`selected`)}set selected(e){e==null?this.removeAttribute(`selected`):this.setAttribute(`selected`,String(e))}get selectable(){return this.hasAttribute(`selectable`)}set selectable(e){this.toggleAttribute(`selectable`,!!e)}_items(){return S(this)}_hasChildren(e){return!!e.querySelector(l)}_isVisible(e){for(let t=e;t&&t!==this;t=t.parentElement)if(t.hasAttribute(`hidden`))return!1;return!0}_visibleItems(){return this._items().filter(e=>this._isVisible(e))}_parentItem(e){let t=e.parentElement?.closest(o);return t instanceof HTMLElement&&this.contains(t)?t:null}_visibleChildren(e){let t=e.querySelector(l);return t?[...t.children].filter(e=>e.matches(o)&&this._isVisible(e)):[]}_isVisibleItem(e){return e instanceof HTMLElement&&e.matches(o)&&this._isVisible(e)}_siblingItem(e,t){let n=e[t];for(;n&&!this._isVisibleItem(n);)n=n[t];return this._isVisibleItem(n)?n:null}_setRoving(e){for(let t of this._items())t.setAttribute(`tabindex`,t===e?`0`:`-1`)}_focusItem(e){e&&(this._setRoving(e),e.focus())}_toggleLabel(e,t){return(t?this.getAttribute(`collapse-label`)??x().collapseLabel:this.getAttribute(`expand-label`)??x().expandLabel).split(`{name}`).join(C(e))}_setExpanded(e,t){let n=e.querySelector(l);n instanceof HTMLElement&&(e.setAttribute(`aria-expanded`,String(t)),n.hidden=!t,e.querySelector(u)?.setAttribute(`aria-label`,this._toggleLabel(e,t)),!t&&n.contains(document.activeElement)&&this._focusItem(e))}_toggle(e){this._setExpanded(e,!T(e))}_syncToggles(){for(let e of this._items())this._hasChildren(e)&&this._setExpanded(e,T(e))}_applySelected(){for(let e of this._items())this.selectable?e.setAttribute(`aria-selected`,String(w(e)===this.selected)):e.removeAttribute(`aria-selected`)}_select(e){this.selectable&&(this.selected=w(e),this.dispatchEvent(new CustomEvent(`wui-org-tree:select`,{detail:{id:this.selected},bubbles:!0,composed:!0})))}_activate(e){this.selectable?this._select(e):this._hasChildren(e)&&this._toggle(e)}_handleFocusIn(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(o);n instanceof HTMLElement&&this.contains(n)&&this._setRoving(n)}_handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(o);n instanceof HTMLElement&&this.contains(n)&&(this._setRoving(n),t.closest(d)?this._hasChildren(n)&&this._toggle(n):n.querySelector(s)?.contains(t)&&(t.closest(f)?.closest(p)||this._select(n)))}_handleKeyDown(e){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement&&t.matches(o)&&this.contains(t))switch(n(e.key,r(this))){case`ArrowDown`:if(e.preventDefault(),!this._hasChildren(t))return;T(t)||this._setExpanded(t,!0),this._focusItem(this._visibleChildren(t)[0]);return;case`ArrowUp`:e.preventDefault(),this._focusItem(this._parentItem(t));return;case`ArrowRight`:e.preventDefault(),this._focusItem(this._siblingItem(t,`nextElementSibling`));return;case`ArrowLeft`:e.preventDefault(),this._focusItem(this._siblingItem(t,`previousElementSibling`));return;case`Home`:e.preventDefault(),this._focusItem(this._visibleItems()[0]);return;case`End`:e.preventDefault(),this._focusItem(this._visibleItems().at(-1));return;case`+`:case`=`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!0);return;case`-`:if(!this._hasChildren(t))return;e.preventDefault(),this._setExpanded(t,!1);return;case`Enter`:case` `:e.preventDefault(),this._activate(t);return}}_handleInput(e){let t=e.target;t instanceof HTMLInputElement&&t.matches(m)&&this._search(t.value.trim().toLocaleLowerCase())}_search(e){clearTimeout(this._announceTimer),e?(this._snapshot||=this._captureExpanded(),this._query=e,this._applySearch(e),this._announceTimer=window.setTimeout(()=>this._announce(this._resultText()),b)):(this._snapshot&&this._restore(this._snapshot),this._snapshot=null,this._query=``,this._announce(``))}_captureExpanded(){return new Map(this._items().filter(e=>this._hasChildren(e)).map(e=>[w(e),T(e)]))}_restore(e){for(let t of this._items()){t.hidden=!1,t.classList.remove(`wui-org-tree-match`);let n=w(t);e.has(n)&&this._setExpanded(t,e.get(n)??!1)}}_applySearch(e){let t=this._items(),n=new Set(t.filter(t=>C(t).toLocaleLowerCase().includes(e))),r=new Set(n);for(let e of n)for(let t=this._parentItem(e);t;t=this._parentItem(t))r.add(t),T(t)||this._setExpanded(t,!0);for(let e of t)e.classList.toggle(`wui-org-tree-match`,n.has(e)),e.hidden=!r.has(e);let i=t.filter(e=>r.has(e)),a=i[0];a&&!i.some(e=>e.getAttribute(`tabindex`)===`0`)&&this._setRoving(a)}_resultText(){let e=this._items().filter(e=>e.classList.contains(`wui-org-tree-match`)).length;return e===0?this.getAttribute(`search-empty-text`)??x().noResultsText:(this.getAttribute(`search-results-text`)??x().resultsText).split(`{count}`).join(String(e))}_announce(e){let t=this.querySelector(g);t&&(t.textContent=e)}_scaleForPrint(){let e=this.querySelector(h);if(!(e instanceof HTMLElement))return;let t=Math.min(1,v/e.scrollWidth,y/e.scrollHeight);this.style.setProperty(_,String(t))}};export{E as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./dom-DMQu--xV.js";import{t}from"./elementBase-Cxeyx0tU.js";import{n,r,t as i}from"./fieldState-D-zQcXUS.js";import{t as a}from"./formMirror-9IpSgeZb.js";var o=/[^0-9]/g,s=/[^0-9a-zA-Z]/g,c=class extends t{static formAssociated=!0;static get observedAttributes(){return[`value`,`length`,`mode`,`disabled`,`readonly`,`loading`,`size`,`aria-label`]}get length(){let e=Number.parseInt(this.getAttribute(`length`)??`6`,10);return Number.isFinite(e)&&e>0?e:6}set length(e){this.setAttribute(`length`,String(e))}get mode(){return this.getAttribute(`mode`)===`alphanumeric`?`alphanumeric`:`numeric`}set mode(e){this.setAttribute(`mode`,String(e??`numeric`))}get value(){return this._value??``}set value(e){this._value=this._clean(e),a(this,this._value),this._paint()}_clean(e){return(e==null?``:String(e)).replace(this.mode===`alphanumeric`?s:o,``).slice(0,this.length)}constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=null}}connectedCallback(){this._rendered?this._onSelectionChange&&document.addEventListener(`selectionchange`,this._onSelectionChange):(this._defaultCaptured||=(this._defaultValue=this._value,!0),this.render())}formResetCallback(){this._value=this._defaultValue||``,a(this,this._value),this._paint()}attributeChangedCallback(e,t,n){this._rendered&&(e===`value`?(this._value=this._clean(n),a(this,this._value),this._paint()):this.render())}render(){this._value=this._clean(this.getAttribute(`value`)??this._value);let t=this.length,i=this.mode===`numeric`,o=this.hasAttribute(`disabled`),s=n(this)||this.hasAttribute(`loading`),c=this.getAttribute(`size`),l=c===`sm`||c===`lg`?` otp-${c}`:``,u=Array.from({length:t},()=>e(`span`,{class:`otp-slot`,"aria-hidden":`true`})),d=this.getAttribute(`aria-label`);this.replaceChildren(e(`div`,{class:`otp${l}`},e(`input`,{class:`otp-field`,type:`text`,autocomplete:`one-time-code`,inputmode:i?`numeric`:`text`,pattern:i?`[0-9]*`:void 0,"aria-label":d||void 0,autocapitalize:`off`,autocorrect:`off`,spellcheck:`false`,disabled:o,readonly:s}),e(`div`,{class:`otp-slots`,"aria-hidden":`true`},...u))),this._rendered=!0,a(this,this._value),r(this,this.querySelector(`.otp`)),this._wire(),this._paint()}_refs(){let e=this.querySelector(`.otp-field`);return{input:e instanceof HTMLInputElement?e:null,slots:[...this.querySelectorAll(`.otp-slot`)].filter(e=>e instanceof HTMLElement)}}_paint(){let{input:e,slots:t}=this._refs();if(!e||!t.length)return;e.value!==this._value&&(e.value=this._value);let n=e.selectionStart??this._value.length,r=Math.min(n,t.length-1),i=document.activeElement===e;t.forEach((e,t)=>{e.textContent=this._value[t]??``,e.classList.toggle(`filled`,!!this._value[t]),e.classList.toggle(`active`,i&&t===r)})}_wire(){let{input:e}=this._refs();if(!e)return;let t=e=>{let t=this._clean(e),n=t!==this._value;this._value=t,a(this,this._value),this._paint(),n&&this.dispatchEvent(new Event(`change`,{bubbles:!0})),n&&t.length===this.length&&this.dispatchEvent(new CustomEvent(`complete`,{bubbles:!0,detail:t}))};e.addEventListener(`input`,()=>{let n=e.value;if(this._value.length===this.length&&n.length>this._value.length&&n.startsWith(this._value)){let e=this._clean(n.slice(this._value.length));if(e){t(e);return}}t(n)}),e.addEventListener(`paste`,e=>{if(i(this))return;let n=e.clipboardData?.getData(`text`);n!=null&&(e.preventDefault(),t(n))});for(let t of[`keyup`,`click`,`blur`,`select`])e.addEventListener(t,()=>this._paint());e.addEventListener(`focus`,()=>{this._value.length===this.length&&e.select(),this._paint()}),this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange),this._onSelectionChange=()=>{document.activeElement===e&&this._paint()},document.addEventListener(`selectionchange`,this._onSelectionChange)}disconnectedCallback(){this._onSelectionChange&&document.removeEventListener(`selectionchange`,this._onSelectionChange)}};export{c as t};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./anchorOverlay-DSzkGQPi.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i}from"./textStore-opIEM4lu.js";import{t as a}from"./overflow.g-BfcGEhwR.js";var o=`data-wui-overflow-hidden`,s=`[aria-selected="true"], .active`,c=`.chip-body, input, a[href], button:not(.chip-remove)`,l=()=>i(`overflow`,a),u=1,d=`data-wui-overflow-menu`,f=`[aria-haspopup], [data-wui-dropdown-trigger]`,p=0,m=e=>Number.parseFloat(e)||0,h=e=>e.nodeType===1,g=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent?.trim();e&&n.push(e)}else h(t)&&!t.matches(`svg, img, [aria-hidden='true'], [data-wui-dropdown-menu]`)&&r(t)};if(r(e),n.length)return n.join(` `);let i=_(e)??e;return i.getAttribute(`aria-label`)||e.getAttribute(`aria-label`)||i.title||e.title},_=e=>{if(e.matches(`button, a[href], label, input`))return e;let t=e.querySelector(c);return t instanceof HTMLElement?t:null},v=e=>{let t=_(e);return t?.matches(f)?t:null},y=class extends r{constructor(){super(),this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!e.composedPath().includes(this)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,t(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){let e=this._more?.firstChild;e&&(e.textContent=this._label())}_label(){return this.getAttribute(`label`)||l().label}_list(){let e=this.querySelector(`[data-wui-overflow-list]`);return e instanceof HTMLElement?e:null}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++p}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();this._mo&&e!==this._observedList&&(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(o),e.removeAttribute(d);this._more.hidden=!0;let n=this.clientWidth,r=[];if(t.length&&n<=0&&this.getClientRects().length>0)r=t;else if(n>0&&t.length){let i=getComputedStyle(e),a=m(i.columnGap),o=m(i.paddingLeft)+m(i.paddingRight)+m(i.borderLeftWidth)+m(i.borderRightWidth),c=t.map(e=>e.offsetWidth);if(c.reduce((e,t)=>e+t,0)+a*(t.length-1)>n-o+u){this._more.hidden=!1;let e=n-o-this._more.offsetWidth-m(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):s,l=/* @__PURE__ */ new Set,u=0,d=0,f=i?t.filter(e=>e.matches(i)):[];for(let n of f){let r=u+(c[t.indexOf(n)]??0)+(d?a:0);r>e||(l.add(n),u=r,d+=1)}for(let n=0;n<t.length;n+=1){let r=t[n];if(!r||l.has(r))continue;let i=u+(c[n]??0)+(d?a:0);if(i>e)break;l.add(r),u=i,d+=1}r=t.filter(e=>!l.has(e))}}for(let e of r)e.setAttribute(o,``),v(e)&&e.setAttribute(d,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let i=r.map(e=>t.indexOf(e)).join(`,`);i!==this._hiddenKey&&(this._hiddenKey=i,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(o)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n instanceof HTMLInputElement?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=_(t),i=!r||`disabled`in r&&r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=g(t),e.addEventListener(`click`,()=>{i||r&&this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=v(e)?.isConnected?e.querySelector(`.dropdown-item:not([aria-disabled='true'])`):null;if(n){n.focus();return}let r=!e.hasAttribute(o)&&e.matches(`button, a[href]`)?e:this._more;r.hidden||r.focus()}_open(t){let r=this._hiddenItems();if(!r.length)return;this._fill(r),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>n(this._more,this._menu);if(i(),e(this,i),t){let e=this._menu.firstElementChild;e instanceof HTMLElement&&e.focus()}}_close(e){this._menu&&!this._menu.hidden&&(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),t(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children].filter(e=>e instanceof HTMLElement),n=this.ownerDocument.activeElement,r=n instanceof HTMLElement?t.indexOf(n):-1,i=null;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),i?.focus()}};export{y as t};
1
+ import{n as e,r as t,t as n}from"./anchorOverlay-daGdh_91.js";import{t as r}from"./elementBase-Cxeyx0tU.js";import{r as i}from"./textStore-opIEM4lu.js";import{t as a}from"./overflow.g-BfcGEhwR.js";var o=`data-wui-overflow-hidden`,s=`[aria-selected="true"], .active`,c=`.chip-body, input, a[href], button:not(.chip-remove)`,l=()=>i(`overflow`,a),u=1,d=`data-wui-overflow-menu`,f=`[aria-haspopup], [data-wui-dropdown-trigger]`,p=0,m=e=>Number.parseFloat(e)||0,h=e=>e.nodeType===1,g=e=>{let t=e.getAttribute(`data-overflow-label`);if(t)return t;let n=[],r=e=>{for(let t of e.childNodes)if(t.nodeType===3){let e=t.textContent?.trim();e&&n.push(e)}else h(t)&&!t.matches(`svg, img, [aria-hidden='true'], [data-wui-dropdown-menu]`)&&r(t)};if(r(e),n.length)return n.join(` `);let i=_(e)??e;return i.getAttribute(`aria-label`)||e.getAttribute(`aria-label`)||i.title||e.title},_=e=>{if(e.matches(`button, a[href], label, input`))return e;let t=e.querySelector(c);return t instanceof HTMLElement?t:null},v=e=>{let t=_(e);return t?.matches(f)?t:null},y=class extends r{constructor(){super(),this._hiddenKey=``,this._ro=null,this._mo=null,this._observedList=null,this._doc=null,this._onDocDown=e=>{!this._menu.hidden&&!e.composedPath().includes(this)&&this._close(!1)}}connectedCallback(){this.classList.add(`wui-overflow`),this._build(),this._doc=this.ownerDocument,this._doc.addEventListener(`pointerdown`,this._onDocDown,!0),typeof ResizeObserver<`u`&&(this._ro=new ResizeObserver(()=>this.layout()),this._ro.observe(this)),typeof MutationObserver<`u`&&(this._mo=new MutationObserver(()=>this.layout()),this._watch()),this.layout()}disconnectedCallback(){this._ro?.disconnect(),this._mo?.disconnect(),this._ro=null,this._mo=null,this._observedList=null,this._doc?.removeEventListener(`pointerdown`,this._onDocDown,!0),this._doc=null,t(this)}static get observedAttributes(){return[`label`]}attributeChangedCallback(){let e=this._more?.firstChild;e&&(e.textContent=this._label())}_label(){return this.getAttribute(`label`)||l().label}_list(){let e=this.querySelector(`[data-wui-overflow-list]`);return e instanceof HTMLElement?e:null}_items(e){return[...e.children].filter(e=>!e.hasAttribute(`data-wui-overflow-skip`))}_build(){if(this._more)return;let e=`wui-overflow-menu-${++p}`,t=this.ownerDocument.createElement(`button`);t.type=`button`,t.className=`wui-overflow-more`,t.hidden=!0,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.setAttribute(`aria-controls`,e),t.append(this._label());let n=this.ownerDocument.createElement(`div`);n.className=`wui-overflow-menu`,n.id=e,n.setAttribute(`role`,`menu`),n.hidden=!0,this.append(t,n),this._more=t,this._menu=n,t.addEventListener(`click`,()=>this._menu.hidden?this._open(!1):this._close(!0)),t.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this._open(!0))}),n.addEventListener(`keydown`,e=>this._onMenuKey(e))}_watch(){let e=this._list();this._mo&&e!==this._observedList&&(this._mo.disconnect(),this._observedList=e,e&&this._mo.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`aria-selected`,`disabled`,`aria-disabled`,`data-overflow-label`]}))}layout(){let e=this._list();if(this._watch(),!e||!this._more)return;let t=this._items(e);for(let e of t)e.removeAttribute(o),e.removeAttribute(d);this._more.hidden=!0;let n=this.clientWidth,r=[];if(t.length&&n<=0&&this.getClientRects().length>0)r=t;else if(n>0&&t.length){let i=getComputedStyle(e),a=m(i.columnGap),o=m(i.paddingLeft)+m(i.paddingRight)+m(i.borderLeftWidth)+m(i.borderRightWidth),c=t.map(e=>e.offsetWidth);if(c.reduce((e,t)=>e+t,0)+a*(t.length-1)>n-o+u){this._more.hidden=!1;let e=n-o-this._more.offsetWidth-m(getComputedStyle(this).columnGap),i=this.hasAttribute(`keep`)?this.getAttribute(`keep`):s,l=/* @__PURE__ */ new Set,u=0,d=0,f=i?t.filter(e=>e.matches(i)):[];for(let n of f){let r=u+(c[t.indexOf(n)]??0)+(d?a:0);r>e||(l.add(n),u=r,d+=1)}for(let n=0;n<t.length;n+=1){let r=t[n];if(!r||l.has(r))continue;let i=u+(c[n]??0)+(d?a:0);if(i>e)break;l.add(r),u=i,d+=1}r=t.filter(e=>!l.has(e))}}for(let e of r)e.setAttribute(o,``),v(e)&&e.setAttribute(d,``);this._more.hidden=r.length===0,r.length?this._menu.hidden||this._fill(r):this._close(!1);let i=r.map(e=>t.indexOf(e)).join(`,`);i!==this._hiddenKey&&(this._hiddenKey=i,this.dispatchEvent(new CustomEvent(`wui-overflow-change`,{bubbles:!0,detail:{hidden:r.length}})))}_hiddenItems(){let e=this._list();return e?this._items(e).filter(e=>e.hasAttribute(o)):[]}_fill(e){this._menu.replaceChildren();for(let t of e){let e=this.ownerDocument.createElement(`button`);e.type=`button`,e.className=`wui-overflow-item`,e.tabIndex=-1;let n=t.querySelector(`input[type=checkbox], input[type=radio]`);n instanceof HTMLInputElement?(e.setAttribute(`role`,n.type===`radio`?`menuitemradio`:`menuitemcheckbox`),e.setAttribute(`aria-checked`,String(n.checked))):e.setAttribute(`role`,`menuitem`);let r=_(t),i=!r||`disabled`in r&&r.disabled||r.getAttribute(`aria-disabled`)===`true`||t.matches(`.disabled, [aria-disabled='true']`);i&&e.setAttribute(`aria-disabled`,`true`),e.textContent=g(t),e.addEventListener(`click`,()=>{i||r&&this._choose(t,r)}),this._menu.append(e)}}_choose(e,t){this._close(!1),t.click(),this.layout();let n=v(e)?.isConnected?e.querySelector(`.dropdown-item:not([aria-disabled='true'])`):null;if(n){n.focus();return}let r=!e.hasAttribute(o)&&e.matches(`button, a[href]`)?e:this._more;r.hidden||r.focus()}_open(t){let r=this._hiddenItems();if(!r.length)return;this._fill(r),this._menu.hidden=!1,this._more.setAttribute(`aria-expanded`,`true`);let i=()=>n(this._more,this._menu);if(i(),e(this,i),t){let e=this._menu.firstElementChild;e instanceof HTMLElement&&e.focus()}}_close(e){this._menu&&!this._menu.hidden&&(this._menu.hidden=!0,this._more.setAttribute(`aria-expanded`,`false`),t(this),e&&this._more.focus())}_onMenuKey(e){let t=[...this._menu.children].filter(e=>e instanceof HTMLElement),n=this.ownerDocument.activeElement,r=n instanceof HTMLElement?t.indexOf(n):-1,i=null;if(e.key===`ArrowDown`)i=t[(r+1)%t.length];else if(e.key===`ArrowUp`)i=t[(r-1+t.length)%t.length];else if(e.key===`Home`)i=t[0];else if(e.key===`End`)i=t[t.length-1];else if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this._close(!0);return}else if(e.key===`Tab`){this._close(!1);return}else return;e.preventDefault(),i?.focus()}};export{y as t};