@aussieljk/forkbook 0.0.0-stage → 0.0.1-10

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 (604) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +59 -2
  3. package/assets/addon-vitest/templates/vitest.config.4.template.ts +36 -0
  4. package/assets/browser/favicon-wrapper.svg +46 -0
  5. package/assets/browser/favicon.svg +1 -0
  6. package/assets/browser/inter-LICENSE.txt +92 -0
  7. package/assets/browser/inter-variable-italic.woff2 +0 -0
  8. package/assets/browser/inter-variable.woff2 +0 -0
  9. package/assets/browser/mirror-ball.png +0 -0
  10. package/assets/builder-vite/iframe.html +83 -0
  11. package/assets/create/rendererAssets/.eslintrc.json +16 -0
  12. package/assets/create/rendererAssets/common/Configure.mdx +388 -0
  13. package/assets/create/rendererAssets/common/assets/accessibility.png +0 -0
  14. package/assets/create/rendererAssets/common/assets/accessibility.svg +1 -0
  15. package/assets/create/rendererAssets/common/assets/addon-library.png +0 -0
  16. package/assets/create/rendererAssets/common/assets/assets.png +0 -0
  17. package/assets/create/rendererAssets/common/assets/avif-test-image.avif +0 -0
  18. package/assets/create/rendererAssets/common/assets/context.png +0 -0
  19. package/assets/create/rendererAssets/common/assets/discord.svg +1 -0
  20. package/assets/create/rendererAssets/common/assets/docs.png +0 -0
  21. package/assets/create/rendererAssets/common/assets/figma-plugin.png +0 -0
  22. package/assets/create/rendererAssets/common/assets/github.svg +1 -0
  23. package/assets/create/rendererAssets/common/assets/share.png +0 -0
  24. package/assets/create/rendererAssets/common/assets/styling.png +0 -0
  25. package/assets/create/rendererAssets/common/assets/testing.png +0 -0
  26. package/assets/create/rendererAssets/common/assets/theming.png +0 -0
  27. package/assets/create/rendererAssets/common/assets/tutorials.svg +1 -0
  28. package/assets/create/rendererAssets/common/assets/youtube.svg +1 -0
  29. package/assets/create/rendererAssets/common/button.css +30 -0
  30. package/assets/create/rendererAssets/common/header.css +32 -0
  31. package/assets/create/rendererAssets/common/page.css +68 -0
  32. package/assets/create/templates/react-native/index.expo.js +20 -0
  33. package/assets/create/templates/react-native/index.js +25 -0
  34. package/assets/docs/addon-backgrounds.gif +0 -0
  35. package/assets/docs/addon-controls-args-annotated.png +0 -0
  36. package/assets/docs/addon-controls-args-background-color.png +0 -0
  37. package/assets/docs/addon-controls-args-background-string.png +0 -0
  38. package/assets/docs/addon-controls-args-docs.png +0 -0
  39. package/assets/docs/addon-controls-args-logging.png +0 -0
  40. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  41. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  42. package/assets/docs/addon-controls-args-reflow.png +0 -0
  43. package/assets/docs/addon-controls-args-template.png +0 -0
  44. package/assets/docs/addon-controls-expanded.png +0 -0
  45. package/assets/docs/addon-controls-hero.gif +0 -0
  46. package/assets/docs/addon-controls-install.png +0 -0
  47. package/assets/docs/hero.gif +0 -0
  48. package/assets/docs/highlight.png +0 -0
  49. package/assets/docs/message-reference.png +0 -0
  50. package/assets/docs/viewport.png +0 -0
  51. package/assets/react-native/metro-env.d.ts +69 -0
  52. package/assets/server/addon.tsconfig.json +6 -0
  53. package/assets/server/base-preview-body.html +116 -0
  54. package/assets/server/base-preview-head.html +494 -0
  55. package/assets/server/openBrowser.applescript +94 -0
  56. package/assets/server/template.ejs +85 -0
  57. package/dist/.build-stamp +0 -0
  58. package/dist/_browser-chunks/Color-X63I7FHI.js +1025 -0
  59. package/dist/_browser-chunks/DocsRenderer-JXND3PVQ.js +10 -0
  60. package/dist/_browser-chunks/WithTooltip-5S6F2P7L.js +198 -0
  61. package/dist/_browser-chunks/chunk-2JDQ35OA.js +247 -0
  62. package/dist/_browser-chunks/chunk-2JT76G3E.js +104 -0
  63. package/dist/_browser-chunks/chunk-3HM3VWJS.js +2604 -0
  64. package/dist/_browser-chunks/chunk-3M5T7BW4.js +43 -0
  65. package/dist/_browser-chunks/chunk-46Z7NGAS.js +41 -0
  66. package/dist/_browser-chunks/chunk-4ATQOMJB.js +30 -0
  67. package/dist/_browser-chunks/chunk-4KIQBRD2.js +17 -0
  68. package/dist/_browser-chunks/chunk-5H4KFI44.js +386 -0
  69. package/dist/_browser-chunks/chunk-5I7E4GMO.js +62 -0
  70. package/dist/_browser-chunks/chunk-5WMXI5GW.js +816 -0
  71. package/dist/_browser-chunks/chunk-5Z65SURM.js +108 -0
  72. package/dist/_browser-chunks/chunk-6AKCRYVX.js +6 -0
  73. package/dist/_browser-chunks/chunk-6ELMKWKX.js +22 -0
  74. package/dist/_browser-chunks/chunk-76222HQR.js +253 -0
  75. package/dist/_browser-chunks/chunk-7DQREF4S.js +218 -0
  76. package/dist/_browser-chunks/chunk-AYRF6EJB.js +36 -0
  77. package/dist/_browser-chunks/chunk-B4AUNNU4.js +156 -0
  78. package/dist/_browser-chunks/chunk-BCP2FFXF.js +369 -0
  79. package/dist/_browser-chunks/chunk-BNP234B4.js +80 -0
  80. package/dist/_browser-chunks/chunk-C5TKXHTM.js +82 -0
  81. package/dist/_browser-chunks/chunk-CNED6RYH.js +18 -0
  82. package/dist/_browser-chunks/chunk-DNJ3OSLB.js +6021 -0
  83. package/dist/_browser-chunks/chunk-DRQKCCAG.js +136 -0
  84. package/dist/_browser-chunks/chunk-DS2WQZGO.js +1956 -0
  85. package/dist/_browser-chunks/chunk-DYNTDJ3O.js +155 -0
  86. package/dist/_browser-chunks/chunk-ECQ75MKQ.js +0 -0
  87. package/dist/_browser-chunks/chunk-ENKK74N4.js +12 -0
  88. package/dist/_browser-chunks/chunk-EQKMUQF3.js +224 -0
  89. package/dist/_browser-chunks/chunk-FENFYI4X.js +698 -0
  90. package/dist/_browser-chunks/chunk-FRAOQJDI.js +95 -0
  91. package/dist/_browser-chunks/chunk-GNZY6LOW.js +10116 -0
  92. package/dist/_browser-chunks/chunk-GRO2ZYEJ.js +157 -0
  93. package/dist/_browser-chunks/chunk-I4ATZPNZ.js +34 -0
  94. package/dist/_browser-chunks/chunk-IE4ULIOQ.js +14 -0
  95. package/dist/_browser-chunks/chunk-IFADVEQE.js +669 -0
  96. package/dist/_browser-chunks/chunk-IMSF75WX.js +42 -0
  97. package/dist/_browser-chunks/chunk-IWQGIXJS.js +14 -0
  98. package/dist/_browser-chunks/chunk-JPUOQJUI.js +8 -0
  99. package/dist/_browser-chunks/chunk-JWSKPMPC.js +73 -0
  100. package/dist/_browser-chunks/chunk-KBK7GKBN.js +35 -0
  101. package/dist/_browser-chunks/chunk-KYSD26D6.js +1966 -0
  102. package/dist/_browser-chunks/chunk-LAWXTSXK.js +18 -0
  103. package/dist/_browser-chunks/chunk-LE2LTDW3.js +14 -0
  104. package/dist/_browser-chunks/chunk-LEVSOOLQ.js +48 -0
  105. package/dist/_browser-chunks/chunk-LTCXWKZO.js +2935 -0
  106. package/dist/_browser-chunks/chunk-LYYXDWR2.js +411 -0
  107. package/dist/_browser-chunks/chunk-MJIDTL3X.js +78 -0
  108. package/dist/_browser-chunks/chunk-MLBOOZL4.js +67 -0
  109. package/dist/_browser-chunks/chunk-N3NRW5XX.js +117 -0
  110. package/dist/_browser-chunks/chunk-N5WQGLI7.js +11 -0
  111. package/dist/_browser-chunks/chunk-NA4ITZTK.js +324 -0
  112. package/dist/_browser-chunks/chunk-NGMQJMCY.js +53 -0
  113. package/dist/_browser-chunks/chunk-NPNIBOPF.js +18 -0
  114. package/dist/_browser-chunks/chunk-NQUD4B7H.js +91 -0
  115. package/dist/_browser-chunks/chunk-NTUHL5NS.js +54 -0
  116. package/dist/_browser-chunks/chunk-NULBREPZ.js +43 -0
  117. package/dist/_browser-chunks/chunk-NZMVUW5T.js +7 -0
  118. package/dist/_browser-chunks/chunk-O24AZJZ7.js +56 -0
  119. package/dist/_browser-chunks/chunk-ONTSNQON.js +20 -0
  120. package/dist/_browser-chunks/chunk-OOETBSA7.js +502 -0
  121. package/dist/_browser-chunks/chunk-OVH3USFB.js +20 -0
  122. package/dist/_browser-chunks/chunk-OZZPSYQR.js +14 -0
  123. package/dist/_browser-chunks/chunk-PJSMZ27A.js +13 -0
  124. package/dist/_browser-chunks/chunk-PZQRXPVR.js +21 -0
  125. package/dist/_browser-chunks/chunk-QC4HFS6K.js +41 -0
  126. package/dist/_browser-chunks/chunk-QDXFODK4.js +274 -0
  127. package/dist/_browser-chunks/chunk-RBCHTR7C.js +28 -0
  128. package/dist/_browser-chunks/chunk-RMYQ3QN3.js +294 -0
  129. package/dist/_browser-chunks/chunk-S6TK43XQ.js +836 -0
  130. package/dist/_browser-chunks/chunk-SC67XZST.js +18 -0
  131. package/dist/_browser-chunks/chunk-SFVA4SBT.js +683 -0
  132. package/dist/_browser-chunks/chunk-SZYFOQMT.js +25 -0
  133. package/dist/_browser-chunks/chunk-TBJCJXK4.js +18 -0
  134. package/dist/_browser-chunks/chunk-TTBPZQ24.js +3551 -0
  135. package/dist/_browser-chunks/chunk-UMDO3KB7.js +205 -0
  136. package/dist/_browser-chunks/chunk-UMGDO2ZM.js +169 -0
  137. package/dist/_browser-chunks/chunk-V5U45XXZ.js +24 -0
  138. package/dist/_browser-chunks/chunk-W7NE2JXW.js +84 -0
  139. package/dist/_browser-chunks/chunk-WGVAAM43.js +1110 -0
  140. package/dist/_browser-chunks/chunk-WHQRNHXD.js +8 -0
  141. package/dist/_browser-chunks/chunk-WOSOWBCA.js +12 -0
  142. package/dist/_browser-chunks/chunk-WZ7KR7SH.js +85 -0
  143. package/dist/_browser-chunks/chunk-XKTORVEQ.js +255 -0
  144. package/dist/_browser-chunks/chunk-XTQCLWVH.js +1500 -0
  145. package/dist/_browser-chunks/chunk-YI2IBIQS.js +7 -0
  146. package/dist/_browser-chunks/chunk-ZEHRUHTA.js +6 -0
  147. package/dist/_browser-chunks/chunk-ZHKZKFY4.js +199 -0
  148. package/dist/_browser-chunks/matchers-YLBYSYAF.js +1263 -0
  149. package/dist/_browser-chunks/react-dom-client-4OHE3QDV.js +9 -0
  150. package/dist/_node-chunks/attached-runtime-PDBJ2EGV.js +282 -0
  151. package/dist/_node-chunks/builder-manager-VLL26RPG.js +1139 -0
  152. package/dist/_node-chunks/chunk-3CSGIJKG.js +499 -0
  153. package/dist/_node-chunks/chunk-3W4KR5GX.js +2609 -0
  154. package/dist/_node-chunks/chunk-5NRWU7S2.js +194 -0
  155. package/dist/_node-chunks/chunk-5SMIGUYF.js +102 -0
  156. package/dist/_node-chunks/chunk-63LPGIV4.js +1049 -0
  157. package/dist/_node-chunks/chunk-6DHTL5G2.js +35 -0
  158. package/dist/_node-chunks/chunk-6DRVJCYP.js +299 -0
  159. package/dist/_node-chunks/chunk-7CV4VEA2.js +620 -0
  160. package/dist/_node-chunks/chunk-7KD5DKGZ.js +79 -0
  161. package/dist/_node-chunks/chunk-7O2UIVID.js +82 -0
  162. package/dist/_node-chunks/chunk-7OY4VMAT.js +90 -0
  163. package/dist/_node-chunks/chunk-AAL6X7YG.js +1986 -0
  164. package/dist/_node-chunks/chunk-ACSO4HQP.js +32 -0
  165. package/dist/_node-chunks/chunk-BDU3ZUMK.js +98 -0
  166. package/dist/_node-chunks/chunk-BMJPOQ2S.js +11 -0
  167. package/dist/_node-chunks/chunk-BNEC3EBC.js +28 -0
  168. package/dist/_node-chunks/chunk-BPL3ERBH.js +347 -0
  169. package/dist/_node-chunks/chunk-BXDMSX3D.js +30600 -0
  170. package/dist/_node-chunks/chunk-C3PLG47Q.js +25 -0
  171. package/dist/_node-chunks/chunk-CEDR5CNM.js +74 -0
  172. package/dist/_node-chunks/chunk-CKE4R4NL.js +26 -0
  173. package/dist/_node-chunks/chunk-CSFNS7HA.js +21 -0
  174. package/dist/_node-chunks/chunk-CZ3V3HHK.js +223 -0
  175. package/dist/_node-chunks/chunk-DNV3LPV3.js +33 -0
  176. package/dist/_node-chunks/chunk-DPILYJH4.js +33 -0
  177. package/dist/_node-chunks/chunk-DQ44ZAEM.js +25 -0
  178. package/dist/_node-chunks/chunk-DR7NW2MI.js +104 -0
  179. package/dist/_node-chunks/chunk-DRCP3DQF.js +209 -0
  180. package/dist/_node-chunks/chunk-EBWZKN2I.js +1297 -0
  181. package/dist/_node-chunks/chunk-ECOW63CV.js +92 -0
  182. package/dist/_node-chunks/chunk-ENBDAHOV.js +18 -0
  183. package/dist/_node-chunks/chunk-FAEOR2AW.js +40 -0
  184. package/dist/_node-chunks/chunk-FERXOKZY.js +80 -0
  185. package/dist/_node-chunks/chunk-FJFB7TWU.js +495 -0
  186. package/dist/_node-chunks/chunk-FQGQ5KHN.js +63 -0
  187. package/dist/_node-chunks/chunk-FR2ZDWKJ.js +45 -0
  188. package/dist/_node-chunks/chunk-FRBE7ES4.js +59 -0
  189. package/dist/_node-chunks/chunk-FWAF5NBL.js +20 -0
  190. package/dist/_node-chunks/chunk-FXBZWUW3.js +7044 -0
  191. package/dist/_node-chunks/chunk-FZ453CHY.js +25 -0
  192. package/dist/_node-chunks/chunk-G2ZUFOHU.js +68 -0
  193. package/dist/_node-chunks/chunk-GBVWRZHP.js +23 -0
  194. package/dist/_node-chunks/chunk-GGE7TBVX.js +121 -0
  195. package/dist/_node-chunks/chunk-GJSYGBI5.js +47 -0
  196. package/dist/_node-chunks/chunk-GKHLTHYM.js +4744 -0
  197. package/dist/_node-chunks/chunk-GQYATLH6.js +3708 -0
  198. package/dist/_node-chunks/chunk-HCP5DG52.js +2743 -0
  199. package/dist/_node-chunks/chunk-HVOSLI2K.js +20 -0
  200. package/dist/_node-chunks/chunk-ID3WA6WR.js +171 -0
  201. package/dist/_node-chunks/chunk-IGOX6TUG.js +95 -0
  202. package/dist/_node-chunks/chunk-IL7YA7QJ.js +148 -0
  203. package/dist/_node-chunks/chunk-IUPE4SU2.js +688 -0
  204. package/dist/_node-chunks/chunk-JVWXCB3L.js +7179 -0
  205. package/dist/_node-chunks/chunk-K4O2ZAMU.js +57 -0
  206. package/dist/_node-chunks/chunk-KRWR44KT.js +25 -0
  207. package/dist/_node-chunks/chunk-KWNBN3DV.js +132 -0
  208. package/dist/_node-chunks/chunk-LG3NMXCM.js +20 -0
  209. package/dist/_node-chunks/chunk-LH5QBX2U.js +1001 -0
  210. package/dist/_node-chunks/chunk-LX2XSPPL.js +59 -0
  211. package/dist/_node-chunks/chunk-M4QNXI37.js +21 -0
  212. package/dist/_node-chunks/chunk-MBPHOLXB.js +1218 -0
  213. package/dist/_node-chunks/chunk-MIWBXEUH.js +26 -0
  214. package/dist/_node-chunks/chunk-MKUA4ZCG.js +1193 -0
  215. package/dist/_node-chunks/chunk-MQC7ZY6L.js +5468 -0
  216. package/dist/_node-chunks/chunk-MRCPS4S3.js +48 -0
  217. package/dist/_node-chunks/chunk-MY7UVHPL.js +153 -0
  218. package/dist/_node-chunks/chunk-ND323XCC.js +33 -0
  219. package/dist/_node-chunks/chunk-NGFFEW2B.js +972 -0
  220. package/dist/_node-chunks/chunk-OPG46TLN.js +1119 -0
  221. package/dist/_node-chunks/chunk-PEL4YXU6.js +19 -0
  222. package/dist/_node-chunks/chunk-QFXAGOIO.js +115 -0
  223. package/dist/_node-chunks/chunk-QGC3UWR5.js +110 -0
  224. package/dist/_node-chunks/chunk-QGVU7IFS.js +414 -0
  225. package/dist/_node-chunks/chunk-QOFBJXPH.js +1525 -0
  226. package/dist/_node-chunks/chunk-QVLHVO4X.js +532 -0
  227. package/dist/_node-chunks/chunk-R2ZCFA7I.js +60 -0
  228. package/dist/_node-chunks/chunk-RC4HPD5Q.js +26 -0
  229. package/dist/_node-chunks/chunk-RJXAXHDJ.js +415 -0
  230. package/dist/_node-chunks/chunk-SGEPJMTU.js +1094 -0
  231. package/dist/_node-chunks/chunk-SYUOBOB5.js +35 -0
  232. package/dist/_node-chunks/chunk-T5VZYRL2.js +40 -0
  233. package/dist/_node-chunks/chunk-T6IU66AM.js +69 -0
  234. package/dist/_node-chunks/chunk-THDTJJMO.js +611 -0
  235. package/dist/_node-chunks/chunk-TNFH4Y4G.js +1133 -0
  236. package/dist/_node-chunks/chunk-TY2ZY7AO.js +155 -0
  237. package/dist/_node-chunks/chunk-TZIT6SZP.js +49 -0
  238. package/dist/_node-chunks/chunk-VG2KFIOW.js +45 -0
  239. package/dist/_node-chunks/chunk-VSHYJR23.js +56 -0
  240. package/dist/_node-chunks/chunk-VUMGWJ6Y.js +844 -0
  241. package/dist/_node-chunks/chunk-WVRM6DQU.js +3767 -0
  242. package/dist/_node-chunks/chunk-YU5TVYPS.js +87 -0
  243. package/dist/_node-chunks/chunk-ZBWAA2EY.js +2106 -0
  244. package/dist/_node-chunks/chunk-ZD5TUA6I.js +20 -0
  245. package/dist/_node-chunks/chunk-ZFLK7MY5.js +144 -0
  246. package/dist/_node-chunks/dist-7OJKTBKL.js +27 -0
  247. package/dist/_node-chunks/dist-MWP6WLW4.js +16 -0
  248. package/dist/_node-chunks/local-runtime-V5YTRN24.js +78 -0
  249. package/dist/_node-chunks/mdx-plugin-CBOD52VP.js +7813 -0
  250. package/dist/_node-chunks/monorepo-GF6H53U4.js +121 -0
  251. package/dist/_node-chunks/monorepo-optimized-tests-relaxed-limits-no-story-deletion-K4TTV2DQ.js +121 -0
  252. package/dist/_node-chunks/optimized-tests-KOTSVWTN.js +22 -0
  253. package/dist/_node-chunks/pattern-copy-play-M2QNC4IZ.js +807 -0
  254. package/dist/_node-chunks/postinstallAddon-WXKJL6DP.js +20 -0
  255. package/dist/_node-chunks/rehype-external-links-3IDE4CYH.js +121 -0
  256. package/dist/_node-chunks/rehype-slug-GKB3WS3U.js +52 -0
  257. package/dist/_node-chunks/relaxed-limits-C6QU365N.js +117 -0
  258. package/dist/_node-chunks/run-TMVS3KKA.js +4792 -0
  259. package/dist/_node-chunks/run-XWBUPXLN.js +103 -0
  260. package/dist/_node-chunks/session-id-VMH57SKN.js +23 -0
  261. package/dist/_node-chunks/setup-KEEJK4WI.js +278 -0
  262. package/dist/_node-chunks/vitest.config.4.template-74HEE4WJ.js +54 -0
  263. package/dist/actions/decorator.d.ts +7 -0
  264. package/dist/actions/decorator.js +44 -0
  265. package/dist/actions/index.d.ts +67 -0
  266. package/dist/actions/index.js +29 -0
  267. package/dist/addon-a11y/index.d.ts +52 -0
  268. package/dist/addon-a11y/index.js +17 -0
  269. package/dist/addon-a11y/manager.js +1432 -0
  270. package/dist/addon-a11y/preset.js +18 -0
  271. package/dist/addon-a11y/preview.d.ts +17 -0
  272. package/dist/addon-a11y/preview.js +16 -0
  273. package/dist/addon-docs/blocks.d.ts +1080 -0
  274. package/dist/addon-docs/blocks.js +2537 -0
  275. package/dist/addon-docs/index.d.ts +236 -0
  276. package/dist/addon-docs/index.js +16 -0
  277. package/dist/addon-docs/manager.js +90 -0
  278. package/dist/addon-docs/mdx-react-shim.d.ts +1 -0
  279. package/dist/addon-docs/mdx-react-shim.js +2 -0
  280. package/dist/addon-docs/preset.js +378 -0
  281. package/dist/addon-docs/preview.d.ts +4 -0
  282. package/dist/addon-docs/preview.js +7 -0
  283. package/dist/addon-links/index.d.ts +22 -0
  284. package/dist/addon-links/index.js +23 -0
  285. package/dist/addon-links/manager.js +14 -0
  286. package/dist/addon-links/preview.d.ts +6 -0
  287. package/dist/addon-links/preview.js +12 -0
  288. package/dist/addon-links/react/index.d.ts +25 -0
  289. package/dist/addon-links/react/index.js +55 -0
  290. package/dist/addon-mcp/preset.js +1353 -0
  291. package/dist/addon-mcp/preview.js +29 -0
  292. package/dist/addon-mcp/tools/preview-stories/preview-stories-app-script.js +1129 -0
  293. package/dist/addon-ondevice-actions/index.d.ts +4 -0
  294. package/dist/addon-ondevice-actions/index.js +11 -0
  295. package/dist/addon-ondevice-actions/register.js +11 -0
  296. package/dist/addon-ondevice-controls/index.d.ts +6 -0
  297. package/dist/addon-ondevice-controls/index.js +14 -0
  298. package/dist/addon-ondevice-controls/register.js +10 -0
  299. package/dist/addon-pseudo-states/index.d.ts +35 -0
  300. package/dist/addon-pseudo-states/index.js +15 -0
  301. package/dist/addon-pseudo-states/manager.js +53 -0
  302. package/dist/addon-pseudo-states/preview.d.ts +9 -0
  303. package/dist/addon-pseudo-states/preview.js +10 -0
  304. package/dist/addon-themes/index.d.ts +80 -0
  305. package/dist/addon-themes/index.js +104 -0
  306. package/dist/addon-themes/manager.js +97 -0
  307. package/dist/addon-themes/postinstall.js +33 -0
  308. package/dist/addon-themes/preview.d.ts +6 -0
  309. package/dist/addon-themes/preview.js +8 -0
  310. package/dist/addon-vitest/constants.d.ts +132 -0
  311. package/dist/addon-vitest/constants.js +66 -0
  312. package/dist/addon-vitest/index.d.ts +4 -0
  313. package/dist/addon-vitest/index.js +8 -0
  314. package/dist/addon-vitest/manager.js +665 -0
  315. package/dist/addon-vitest/node/coverage-reporter.js +1284 -0
  316. package/dist/addon-vitest/node/vitest.js +674 -0
  317. package/dist/addon-vitest/postinstall.js +24 -0
  318. package/dist/addon-vitest/preset.js +942 -0
  319. package/dist/addon-vitest/vitest-plugin/global-setup.js +162 -0
  320. package/dist/addon-vitest/vitest-plugin/index.d.ts +56 -0
  321. package/dist/addon-vitest/vitest-plugin/index.js +463 -0
  322. package/dist/addon-vitest/vitest-plugin/setup-file-with-project-annotations.js +9 -0
  323. package/dist/addon-vitest/vitest-plugin/setup-file.browser.4.js +20 -0
  324. package/dist/addon-vitest/vitest-plugin/setup-file.js +50 -0
  325. package/dist/addon-vitest/vitest-plugin/test-utils.js +128 -0
  326. package/dist/babel/index.d.ts +1550 -0
  327. package/dist/babel/index.js +55 -0
  328. package/dist/backgrounds/index.d.ts +6 -0
  329. package/dist/backgrounds/index.js +15 -0
  330. package/dist/bin/core.js +1706 -0
  331. package/dist/bin/dispatcher.js +45 -0
  332. package/dist/bin/loader.js +116 -0
  333. package/dist/builder-vite/index.d.ts +50 -0
  334. package/dist/builder-vite/index.js +245 -0
  335. package/dist/builder-vite/preset.js +27 -0
  336. package/dist/channels/index.d.ts +2 -0
  337. package/dist/channels/index.js +352 -0
  338. package/dist/chunk-BCoJQE-f.d.ts +602 -0
  339. package/dist/chunk-BGhyFTJO.d.ts +115 -0
  340. package/dist/chunk-BGkgZp-H.d.ts +214 -0
  341. package/dist/chunk-BXLImeLy.d.ts +197 -0
  342. package/dist/chunk-Bpi2tz-6.d.ts +511 -0
  343. package/dist/chunk-C6PAgHLT.d.ts +12 -0
  344. package/dist/chunk-CFk6djyM.d.ts +55 -0
  345. package/dist/chunk-CNqjcOmK.d.ts +15 -0
  346. package/dist/chunk-CT2iXaHz.d.ts +179 -0
  347. package/dist/chunk-CV4-Z2pn.d.ts +30 -0
  348. package/dist/chunk-CYuvV2sR.d.ts +282 -0
  349. package/dist/chunk-Ct9xd6IM.d.ts +65 -0
  350. package/dist/chunk-D0NUmzXp.d.ts +253 -0
  351. package/dist/chunk-D7DwV41f.d.ts +3622 -0
  352. package/dist/chunk-DDd8BhTY.d.ts +79 -0
  353. package/dist/chunk-DROZ9oel.d.ts +669 -0
  354. package/dist/chunk-DaVb55-_.d.ts +124 -0
  355. package/dist/chunk-DgRNfmj_.d.ts +40 -0
  356. package/dist/chunk-DgzPaTw9.d.ts +61 -0
  357. package/dist/chunk-Dm-iHJ-s.d.ts +59 -0
  358. package/dist/chunk-DoIGKY33.d.ts +666 -0
  359. package/dist/chunk-Dr3R0DXk.d.ts +40 -0
  360. package/dist/chunk-Dw_4ad2Y.d.ts +34 -0
  361. package/dist/chunk-Fg1Fm__9.d.ts +13091 -0
  362. package/dist/chunk-FjDVzZTj.d.ts +62 -0
  363. package/dist/chunk-Susgfkap.d.ts +20 -0
  364. package/dist/chunk-XP8oHzpE.d.ts +6 -0
  365. package/dist/chunk-pcFXCimE.d.ts +741 -0
  366. package/dist/cli/index.d.ts +321 -0
  367. package/dist/cli/index.js +703 -0
  368. package/dist/cli/skills/content/index.d.ts +72 -0
  369. package/dist/cli/skills/content/index.js +335 -0
  370. package/dist/cli/tools/sdk/child-host.d.ts +61 -0
  371. package/dist/cli/tools/sdk/child-host.js +131 -0
  372. package/dist/cli/tools/sdk/index.d.ts +137 -0
  373. package/dist/cli/tools/sdk/index.js +44 -0
  374. package/dist/cli-commands/bin/index.js +25 -0
  375. package/dist/client-logger/index.d.ts +31 -0
  376. package/dist/client-logger/index.js +65 -0
  377. package/dist/common/index.d.ts +1091 -0
  378. package/dist/common/index.js +358 -0
  379. package/dist/components/index.d.ts +1727 -0
  380. package/dist/components/index.js +7982 -0
  381. package/dist/core-events/index.d.ts +156 -0
  382. package/dist/core-events/index.js +138 -0
  383. package/dist/core-server/index.d.ts +2200 -0
  384. package/dist/core-server/index.js +4577 -0
  385. package/dist/core-server/presets/common-manager.js +3744 -0
  386. package/dist/core-server/presets/common-override-preset.js +83 -0
  387. package/dist/core-server/presets/common-preset.js +2194 -0
  388. package/dist/create/bin/index.js +23 -0
  389. package/dist/create/index.js +25 -0
  390. package/dist/csf/csf-utils.d.ts +2 -0
  391. package/dist/csf/csf-utils.js +19 -0
  392. package/dist/csf/index.d.ts +7 -0
  393. package/dist/csf/index.js +2077 -0
  394. package/dist/csf-tools/index.d.ts +1161 -0
  395. package/dist/csf-tools/index.js +738 -0
  396. package/dist/docs-tools/index.d.ts +197 -0
  397. package/dist/docs-tools/index.js +61 -0
  398. package/dist/highlight/index.d.ts +10 -0
  399. package/dist/highlight/index.js +15 -0
  400. package/dist/instrumenter/index.d.ts +113 -0
  401. package/dist/instrumenter/index.js +2597 -0
  402. package/dist/manager/_manager-chunks/globals-runtime-BKQscPdC.js +5661 -0
  403. package/dist/manager/_manager-chunks/globals-runtime-BY3epqww.js +1807 -0
  404. package/dist/manager/_manager-chunks/globals-runtime-BdGkqNEt.js +45 -0
  405. package/dist/manager/_manager-chunks/globals-runtime-Bj5KDUJi.js +8935 -0
  406. package/dist/manager/_manager-chunks/globals-runtime-Bs75QQ_I.js +9987 -0
  407. package/dist/manager/_manager-chunks/globals-runtime-BweHuXkK.js +6838 -0
  408. package/dist/manager/_manager-chunks/globals-runtime-CA8AuIRT.js +7617 -0
  409. package/dist/manager/_manager-chunks/globals-runtime-CBviMKtt.js +446 -0
  410. package/dist/manager/_manager-chunks/globals-runtime-CJL1dQtn.js +4674 -0
  411. package/dist/manager/_manager-chunks/globals-runtime-CfurFwS_.js +121 -0
  412. package/dist/manager/_manager-chunks/globals-runtime-CvIgTRVu.js +1190 -0
  413. package/dist/manager/_manager-chunks/globals-runtime-DBba3I9c.js +5307 -0
  414. package/dist/manager/_manager-chunks/globals-runtime-DvV_TF3-.js +12214 -0
  415. package/dist/manager/_manager-chunks/globals-runtime-DwFqpqya.js +722 -0
  416. package/dist/manager/_manager-chunks/globals-runtime-NwJK8t0T.js +9274 -0
  417. package/dist/manager/_manager-chunks/globals-runtime-WZKaeKm9.js +4091 -0
  418. package/dist/manager/_manager-chunks/globals-runtime-wjkxyMn0.js +5283 -0
  419. package/dist/manager/_manager-chunks/runtime-5B2mWjEm.js +294 -0
  420. package/dist/manager/_manager-chunks/runtime-5o_11Jae.js +78 -0
  421. package/dist/manager/_manager-chunks/runtime-B_nqedQW.js +197 -0
  422. package/dist/manager/_manager-chunks/runtime-BdGkqNEt.js +45 -0
  423. package/dist/manager/_manager-chunks/runtime-Bs3bEhuy.js +1232 -0
  424. package/dist/manager/_manager-chunks/runtime-CBQsKmch.js +2351 -0
  425. package/dist/manager/_manager-chunks/runtime-DG61zYUm.js +1158 -0
  426. package/dist/manager/_manager-chunks/runtime-DtCVCy4G.js +6841 -0
  427. package/dist/manager/_manager-chunks/runtime-P663lpsR.js +528 -0
  428. package/dist/manager/_manager-chunks/runtime-eBAgOym6.js +9010 -0
  429. package/dist/manager/_manager-chunks/runtime-j9yqh0tr.js +1023 -0
  430. package/dist/manager/_manager-chunks/runtime-jj8qYc2n.js +3488 -0
  431. package/dist/manager/globals-runtime.js +2 -0
  432. package/dist/manager/globals.d.ts +23 -0
  433. package/dist/manager/globals.js +26 -0
  434. package/dist/manager/manager-stores.d.ts +2 -0
  435. package/dist/manager/manager-stores.js +19 -0
  436. package/dist/manager/runtime.js +2 -0
  437. package/dist/manager-api/index.d.ts +2 -0
  438. package/dist/manager-api/index.js +3247 -0
  439. package/dist/manager-errors.d.ts +89 -0
  440. package/dist/manager-errors.js +20 -0
  441. package/dist/mcp/index.d.ts +270 -0
  442. package/dist/mcp/index.js +305 -0
  443. package/dist/mocking-utils/index.d.ts +689 -0
  444. package/dist/mocking-utils/index.js +526 -0
  445. package/dist/mocking-utils/mocker-runtime.js +1254 -0
  446. package/dist/nextjs-vite/config/preview.js +3 -0
  447. package/dist/nextjs-vite/export-mocks/cache/index.d.ts +25 -0
  448. package/dist/nextjs-vite/export-mocks/cache/index.js +29 -0
  449. package/dist/nextjs-vite/export-mocks/headers/index.d.ts +37 -0
  450. package/dist/nextjs-vite/export-mocks/headers/index.js +54 -0
  451. package/dist/nextjs-vite/export-mocks/link/index.d.ts +9 -0
  452. package/dist/nextjs-vite/export-mocks/link/index.js +59 -0
  453. package/dist/nextjs-vite/export-mocks/navigation/index.d.ts +28 -0
  454. package/dist/nextjs-vite/export-mocks/navigation/index.js +58 -0
  455. package/dist/nextjs-vite/export-mocks/router/index.d.ts +34 -0
  456. package/dist/nextjs-vite/export-mocks/router/index.js +63 -0
  457. package/dist/nextjs-vite/index.d.ts +92 -0
  458. package/dist/nextjs-vite/index.js +59 -0
  459. package/dist/nextjs-vite/node/index.d.ts +6 -0
  460. package/dist/nextjs-vite/node/index.js +20 -0
  461. package/dist/nextjs-vite/node-stand-ins/index.d.ts +68 -0
  462. package/dist/nextjs-vite/node-stand-ins/index.js +145 -0
  463. package/dist/nextjs-vite/preset.js +727 -0
  464. package/dist/nextjs-vite/preview.d.ts +20 -0
  465. package/dist/nextjs-vite/preview.js +11 -0
  466. package/dist/nextjs-vite/vite-plugin/index.d.ts +6 -0
  467. package/dist/nextjs-vite/vite-plugin/index.js +19 -0
  468. package/dist/nextjs-vite-plugin/index.d.ts +27 -0
  469. package/dist/nextjs-vite-plugin/index.js +908 -0
  470. package/dist/nextjs-vite-plugin/mocks/storybook.global.js +29 -0
  471. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-context.js +8 -0
  472. package/dist/nextjs-vite-plugin/plugins/next-image/alias/image-default-loader.js +23 -0
  473. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-image.js +28 -0
  474. package/dist/nextjs-vite-plugin/plugins/next-image/alias/next-legacy-image.js +17 -0
  475. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/cache/index.js +29 -0
  476. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/dynamic/index.js +40 -0
  477. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/headers/index.js +55 -0
  478. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/link/index.js +63 -0
  479. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/navigation/index.js +71 -0
  480. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/router/index.js +74 -0
  481. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/rsc/server-only.js +7 -0
  482. package/dist/nextjs-vite-plugin/plugins/next-mocks/alias/safe-stable-stringify/index.js +13 -0
  483. package/dist/nextjs-vite-plugin/plugins/next-mocks/compatibility/draft-mode.compat.js +7 -0
  484. package/dist/node-logger/index.d.ts +488 -0
  485. package/dist/node-logger/index.js +41 -0
  486. package/dist/oxc-parser/index.d.ts +99 -0
  487. package/dist/oxc-parser/index.js +273 -0
  488. package/dist/oxc-parser/worker.js +37 -0
  489. package/dist/preview/_chunks/runtime-BJwGQok8.js +3873 -0
  490. package/dist/preview/_chunks/runtime-BPwAnlRx.js +10411 -0
  491. package/dist/preview/_chunks/runtime-BUnOhg9h.js +6838 -0
  492. package/dist/preview/_chunks/runtime-BZ4pNS3g.js +284 -0
  493. package/dist/preview/_chunks/runtime-Bcv1hJky.js +6305 -0
  494. package/dist/preview/_chunks/runtime-BdGkqNEt.js +45 -0
  495. package/dist/preview/_chunks/runtime-BgPhfM5P.js +3681 -0
  496. package/dist/preview/_chunks/runtime-BhSZ1Mwt.js +5262 -0
  497. package/dist/preview/_chunks/runtime-BsMjBzuq.js +53 -0
  498. package/dist/preview/_chunks/runtime-C1jgT6tJ.js +4091 -0
  499. package/dist/preview/_chunks/runtime-CkOhMcXf.js +387 -0
  500. package/dist/preview/_chunks/runtime-WapFVPAh.js +8484 -0
  501. package/dist/preview/globals.d.ts +16 -0
  502. package/dist/preview/globals.js +20 -0
  503. package/dist/preview/runtime.js +6 -0
  504. package/dist/preview-api/index.d.ts +4 -0
  505. package/dist/preview-api/index.js +149 -0
  506. package/dist/preview-errors.d.ts +186 -0
  507. package/dist/preview-errors.js +56 -0
  508. package/dist/react/docgen/docgen-worker.js +37 -0
  509. package/dist/react/entry-preview-argtypes.js +9 -0
  510. package/dist/react/entry-preview-docs.js +12 -0
  511. package/dist/react/entry-preview-rsc.js +11 -0
  512. package/dist/react/entry-preview.js +22 -0
  513. package/dist/react/index.d.ts +119 -0
  514. package/dist/react/index.js +28 -0
  515. package/dist/react/preset.js +300 -0
  516. package/dist/react/preview.d.ts +2 -0
  517. package/dist/react/preview.js +12 -0
  518. package/dist/react-native/bin/get-stories.js +34 -0
  519. package/dist/react-native/index.d.ts +160 -0
  520. package/dist/react-native/index.js +1362 -0
  521. package/dist/react-native/metro/node.d.ts +83 -0
  522. package/dist/react-native/metro/node.js +22 -0
  523. package/dist/react-native/metro/withForkbook.d.ts +2269 -0
  524. package/dist/react-native/metro/withForkbook.js +139 -0
  525. package/dist/react-native/preview.d.ts +6 -0
  526. package/dist/react-native/preview.js +20 -0
  527. package/dist/react-native/scripts/generate.d.ts +22 -0
  528. package/dist/react-native/scripts/generate.js +18 -0
  529. package/dist/react-native/stub.js +20 -0
  530. package/dist/react-native-theming/index.d.ts +119 -0
  531. package/dist/react-native-theming/index.js +316 -0
  532. package/dist/react-native-ui/index.d.ts +129 -0
  533. package/dist/react-native-ui/index.js +1448 -0
  534. package/dist/react-native-ui-common/index.d.ts +229 -0
  535. package/dist/react-native-ui-common/index.js +514 -0
  536. package/dist/react-vite/index.d.ts +4 -0
  537. package/dist/react-vite/index.js +8 -0
  538. package/dist/react-vite/node/index.d.ts +6 -0
  539. package/dist/react-vite/node/index.js +20 -0
  540. package/dist/react-vite/preset.d.ts +6 -0
  541. package/dist/react-vite/preset.js +21 -0
  542. package/dist/router/index.d.ts +209 -0
  543. package/dist/router/index.js +1259 -0
  544. package/dist/server-errors.d.ts +2 -0
  545. package/dist/server-errors.js +149 -0
  546. package/dist/shared/open-service/index.d.ts +3 -0
  547. package/dist/shared/open-service/index.js +115 -0
  548. package/dist/shared/open-service/services/docgen/worker/docgen-worker.js +75 -0
  549. package/dist/shared/open-service/toolsets/docs/public.d.ts +1296 -0
  550. package/dist/shared/open-service/toolsets/docs/public.js +991 -0
  551. package/dist/telemetry/index.d.ts +314 -0
  552. package/dist/telemetry/index.js +101 -0
  553. package/dist/test/index.d.ts +158 -0
  554. package/dist/test/index.js +19656 -0
  555. package/dist/theming/create.d.ts +15 -0
  556. package/dist/theming/create.js +12 -0
  557. package/dist/theming/index.d.ts +54 -0
  558. package/dist/theming/index.js +536 -0
  559. package/dist/types/index.d.ts +2 -0
  560. package/dist/types/index.js +48 -0
  561. package/dist/viewport/index.d.ts +275 -0
  562. package/dist/viewport/index.js +21 -0
  563. package/package.json +1030 -4
  564. package/template/nextjs-vite/cli/.eslintrc.json +6 -0
  565. package/template/nextjs-vite/cli/js/Button.jsx +42 -0
  566. package/template/nextjs-vite/cli/js/Button.stories.js +49 -0
  567. package/template/nextjs-vite/cli/js/Configure.mdx +470 -0
  568. package/template/nextjs-vite/cli/js/Header.jsx +58 -0
  569. package/template/nextjs-vite/cli/js/Header.stories.js +30 -0
  570. package/template/nextjs-vite/cli/js/Page.jsx +68 -0
  571. package/template/nextjs-vite/cli/js/Page.stories.js +28 -0
  572. package/template/nextjs-vite/cli/ts/Button.stories.ts +54 -0
  573. package/template/nextjs-vite/cli/ts/Button.tsx +39 -0
  574. package/template/nextjs-vite/cli/ts/Configure.mdx +446 -0
  575. package/template/nextjs-vite/cli/ts/Header.stories.ts +34 -0
  576. package/template/nextjs-vite/cli/ts/Header.tsx +54 -0
  577. package/template/nextjs-vite/cli/ts/Page.stories.ts +33 -0
  578. package/template/nextjs-vite/cli/ts/Page.tsx +73 -0
  579. package/template/react/cli/.eslintrc.json +5 -0
  580. package/template/react/cli/js/Button.jsx +39 -0
  581. package/template/react/cli/js/Button.stories.js +49 -0
  582. package/template/react/cli/js/Header.jsx +56 -0
  583. package/template/react/cli/js/Header.stories.js +29 -0
  584. package/template/react/cli/js/Page.jsx +69 -0
  585. package/template/react/cli/js/Page.stories.js +28 -0
  586. package/template/react/cli/ts/Button.stories.ts +54 -0
  587. package/template/react/cli/ts/Button.tsx +37 -0
  588. package/template/react/cli/ts/Header.stories.ts +34 -0
  589. package/template/react/cli/ts/Header.tsx +56 -0
  590. package/template/react/cli/ts/Page.stories.ts +33 -0
  591. package/template/react/cli/ts/Page.tsx +73 -0
  592. package/template/react-vite/cli/.eslintrc.json +5 -0
  593. package/template/react-vite/cli/js/Button.jsx +39 -0
  594. package/template/react-vite/cli/js/Button.stories.js +49 -0
  595. package/template/react-vite/cli/js/Header.jsx +56 -0
  596. package/template/react-vite/cli/js/Header.stories.js +29 -0
  597. package/template/react-vite/cli/js/Page.jsx +69 -0
  598. package/template/react-vite/cli/js/Page.stories.js +28 -0
  599. package/template/react-vite/cli/ts/Button.stories.ts +54 -0
  600. package/template/react-vite/cli/ts/Button.tsx +37 -0
  601. package/template/react-vite/cli/ts/Header.stories.ts +34 -0
  602. package/template/react-vite/cli/ts/Header.tsx +56 -0
  603. package/template/react-vite/cli/ts/Page.stories.ts +33 -0
  604. package/template/react-vite/cli/ts/Page.tsx +73 -0
@@ -0,0 +1,3488 @@
1
+ import { a as __toESM, n as __esmMin } from "./runtime-BdGkqNEt.js";
2
+ import { Cr as init__storybook_global_react, Er as useCallback, Fr as useRef, Ir as useState, Mr as useLayoutEffect, Nr as useMemo, Pr as useReducer, _r as _storybook_global_react_exports, kr as useEffect, mr as Component, vr as cloneElement } from "./runtime-DG61zYUm.js";
3
+ import { n as require_react_is, p as require_prop_types } from "./runtime-CBQsKmch.js";
4
+ import { a as _inheritsLoose, l as _extends, o as init_inheritsLoose, t as _objectWithoutPropertiesLoose } from "./runtime-DtCVCy4G.js";
5
+ //#region ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
6
+ function getSymbols(object) {
7
+ return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
8
+ }
9
+ //#endregion
10
+ //#region ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
11
+ /**
12
+ * Gets the `toStringTag` of `value`.
13
+ *
14
+ * @private
15
+ * @param {T} value The value to query.
16
+ * @returns {string} Returns the `Object.prototype.toString.call` result.
17
+ */
18
+ function getTag(value) {
19
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
20
+ return Object.prototype.toString.call(value);
21
+ }
22
+ //#endregion
23
+ //#region ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
24
+ var regexpTag, stringTag, numberTag, booleanTag, symbolTag, dateTag, mapTag, setTag, arrayTag, functionTag, arrayBufferTag, objectTag, errorTag, dataViewTag, uint8ArrayTag, uint8ClampedArrayTag, uint16ArrayTag, uint32ArrayTag, bigUint64ArrayTag, int8ArrayTag, int16ArrayTag, int32ArrayTag, bigInt64ArrayTag, float32ArrayTag, float64ArrayTag;
25
+ function init_tags() {
26
+ return (init_tags = __esmMin((() => {
27
+ regexpTag = "[object RegExp]";
28
+ stringTag = "[object String]";
29
+ numberTag = "[object Number]";
30
+ booleanTag = "[object Boolean]";
31
+ symbolTag = "[object Symbol]";
32
+ dateTag = "[object Date]";
33
+ mapTag = "[object Map]";
34
+ setTag = "[object Set]";
35
+ arrayTag = "[object Array]";
36
+ functionTag = "[object Function]";
37
+ arrayBufferTag = "[object ArrayBuffer]";
38
+ objectTag = "[object Object]";
39
+ errorTag = "[object Error]";
40
+ dataViewTag = "[object DataView]";
41
+ uint8ArrayTag = "[object Uint8Array]";
42
+ uint8ClampedArrayTag = "[object Uint8ClampedArray]";
43
+ uint16ArrayTag = "[object Uint16Array]";
44
+ uint32ArrayTag = "[object Uint32Array]";
45
+ bigUint64ArrayTag = "[object BigUint64Array]";
46
+ int8ArrayTag = "[object Int8Array]";
47
+ int16ArrayTag = "[object Int16Array]";
48
+ int32ArrayTag = "[object Int32Array]";
49
+ bigInt64ArrayTag = "[object BigInt64Array]";
50
+ float32ArrayTag = "[object Float32Array]";
51
+ float64ArrayTag = "[object Float64Array]";
52
+ })))();
53
+ }
54
+ //#endregion
55
+ //#region ../../node_modules/es-toolkit/dist/_internal/globalThis.mjs
56
+ var globalThis_;
57
+ function init_globalThis() {
58
+ return (init_globalThis = __esmMin((() => {
59
+ globalThis_ = typeof globalThis === "object" && globalThis || typeof window === "object" && window || typeof self === "object" && self || typeof global === "object" && global || (function() {
60
+ return this;
61
+ })();
62
+ })))();
63
+ }
64
+ //#endregion
65
+ //#region ../../node_modules/es-toolkit/dist/predicate/isBuffer.mjs
66
+ /**
67
+ * Checks if the given value is a Buffer instance.
68
+ *
69
+ * This function tests whether the provided value is an instance of Buffer.
70
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
71
+ *
72
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
73
+ *
74
+ * @param x - The value to check if it is a Buffer.
75
+ * @returns Returns `true` if `x` is a Buffer, else `false`.
76
+ *
77
+ * @example
78
+ * const buffer = Buffer.from("test");
79
+ * console.log(isBuffer(buffer)); // true
80
+ *
81
+ * const notBuffer = "not a buffer";
82
+ * console.log(isBuffer(notBuffer)); // false
83
+ */
84
+ function isBuffer(x) {
85
+ return typeof globalThis_.Buffer !== "undefined" && globalThis_.Buffer.isBuffer(x);
86
+ }
87
+ function init_isBuffer() {
88
+ return (init_isBuffer = __esmMin((() => {
89
+ init_globalThis();
90
+ })))();
91
+ }
92
+ //#endregion
93
+ //#region ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
94
+ /**
95
+ * Checks if a given value is a plain object.
96
+ *
97
+ * @param value - The value to check.
98
+ * @returns True if the value is a plain object, otherwise false.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // ✅👇 True
103
+ *
104
+ * isPlainObject({ }); // ✅
105
+ * isPlainObject({ key: 'value' }); // ✅
106
+ * isPlainObject({ key: new Date() }); // ✅
107
+ * isPlainObject(new Object()); // ✅
108
+ * isPlainObject(Object.create(null)); // ✅
109
+ * isPlainObject({ nested: { key: true} }); // ✅
110
+ * isPlainObject(new Proxy({}, {})); // ✅
111
+ * isPlainObject({ [Symbol('tag')]: 'A' }); // ✅
112
+ *
113
+ * // ✅👇 (cross-realms, node context, workers, ...)
114
+ * const runInNewContext = await import('node:vm').then(
115
+ * (mod) => mod.runInNewContext
116
+ * );
117
+ * isPlainObject(runInNewContext('({})')); // ✅
118
+ *
119
+ * // ❌👇 False
120
+ *
121
+ * class Test { };
122
+ * isPlainObject(new Test()) // ❌
123
+ * isPlainObject(10); // ❌
124
+ * isPlainObject(null); // ❌
125
+ * isPlainObject('hello'); // ❌
126
+ * isPlainObject([]); // ❌
127
+ * isPlainObject(new Date()); // ❌
128
+ * isPlainObject(new Uint8Array([1])); // ❌
129
+ * isPlainObject(Buffer.from('ABC')); // ❌
130
+ * isPlainObject(Promise.resolve({})); // ❌
131
+ * isPlainObject(Object.create({})); // ❌
132
+ * isPlainObject(new (class Cls {})); // ❌
133
+ * isPlainObject(globalThis); // ❌,
134
+ * ```
135
+ */
136
+ function isPlainObject(value) {
137
+ if (!value || typeof value !== "object") return false;
138
+ const proto = Object.getPrototypeOf(value);
139
+ if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
140
+ return Object.prototype.toString.call(value) === "[object Object]";
141
+ }
142
+ //#endregion
143
+ //#region ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
144
+ /**
145
+ * Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
146
+ *
147
+ * @param value The value to compare.
148
+ * @param other The other value to compare.
149
+ * @returns Returns `true` if the values are equivalent, else `false`.
150
+ *
151
+ * @example
152
+ * eq(1, 1); // true
153
+ * eq(0, -0); // true
154
+ * eq(NaN, NaN); // true
155
+ * eq('a', Object('a')); // false
156
+ */
157
+ function eq(value, other) {
158
+ return value === other || Number.isNaN(value) && Number.isNaN(other);
159
+ }
160
+ //#endregion
161
+ //#region ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
162
+ /**
163
+ * Compares two values for equality using a custom comparison function.
164
+ *
165
+ * The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
166
+ *
167
+ * This function also uses the custom equality function to compare values inside objects,
168
+ * arrays, maps, sets, and other complex structures, ensuring a deep comparison.
169
+ *
170
+ * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
171
+ *
172
+ * The custom comparison function can take up to six parameters:
173
+ * - `x`: The value from the first object `a`.
174
+ * - `y`: The value from the second object `b`.
175
+ * - `property`: The property key used to get `x` and `y`.
176
+ * - `xParent`: The parent of the first value `x`.
177
+ * - `yParent`: The parent of the second value `y`.
178
+ * - `stack`: An internal stack (Map) to handle circular references.
179
+ *
180
+ * @param a - The first value to compare.
181
+ * @param b - The second value to compare.
182
+ * @param areValuesEqual - A function to customize the comparison.
183
+ * If it returns a boolean, that result will be used. If it returns undefined,
184
+ * the default equality comparison will be used.
185
+ * @returns `true` if the values are equal according to the customizer, otherwise `false`.
186
+ *
187
+ * @example
188
+ * const customizer = (a, b) => {
189
+ * if (typeof a === 'string' && typeof b === 'string') {
190
+ * return a.toLowerCase() === b.toLowerCase();
191
+ * }
192
+ * };
193
+ * isEqualWith('Hello', 'hello', customizer); // true
194
+ * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
195
+ * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
196
+ */
197
+ function isEqualWith(a, b, areValuesEqual) {
198
+ return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
199
+ }
200
+ function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
201
+ const result = areValuesEqual(a, b, property, aParent, bParent, stack);
202
+ if (result !== void 0) return result;
203
+ if (typeof a === typeof b) switch (typeof a) {
204
+ case "bigint":
205
+ case "string":
206
+ case "boolean":
207
+ case "symbol":
208
+ case "undefined": return a === b;
209
+ case "number": return a === b || Object.is(a, b);
210
+ case "function": return a === b;
211
+ case "object": return areObjectsEqual(a, b, stack, areValuesEqual);
212
+ }
213
+ return areObjectsEqual(a, b, stack, areValuesEqual);
214
+ }
215
+ function areObjectsEqual(a, b, stack, areValuesEqual) {
216
+ if (Object.is(a, b)) return true;
217
+ let aTag = getTag(a);
218
+ let bTag = getTag(b);
219
+ if (aTag === "[object Arguments]") aTag = objectTag;
220
+ if (bTag === "[object Arguments]") bTag = objectTag;
221
+ if (aTag !== bTag) return false;
222
+ switch (aTag) {
223
+ case stringTag: return a.toString() === b.toString();
224
+ case numberTag: return eq(a.valueOf(), b.valueOf());
225
+ case booleanTag:
226
+ case dateTag:
227
+ case symbolTag: return Object.is(a.valueOf(), b.valueOf());
228
+ case regexpTag: return a.source === b.source && a.flags === b.flags;
229
+ case functionTag: return a === b;
230
+ }
231
+ stack = stack ?? /* @__PURE__ */ new Map();
232
+ const aStack = stack.get(a);
233
+ const bStack = stack.get(b);
234
+ if (aStack != null && bStack != null) return aStack === b;
235
+ stack.set(a, b);
236
+ stack.set(b, a);
237
+ try {
238
+ switch (aTag) {
239
+ case mapTag:
240
+ if (a.size !== b.size) return false;
241
+ for (const [key, value] of a.entries()) if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) return false;
242
+ return true;
243
+ case setTag: {
244
+ if (a.size !== b.size) return false;
245
+ const aValues = Array.from(a.values());
246
+ const bValues = Array.from(b.values());
247
+ for (let i = 0; i < aValues.length; i++) {
248
+ const aValue = aValues[i];
249
+ const index = bValues.findIndex((bValue) => {
250
+ return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual);
251
+ });
252
+ if (index === -1) return false;
253
+ bValues.splice(index, 1);
254
+ }
255
+ return true;
256
+ }
257
+ case arrayTag:
258
+ case uint8ArrayTag:
259
+ case uint8ClampedArrayTag:
260
+ case uint16ArrayTag:
261
+ case uint32ArrayTag:
262
+ case bigUint64ArrayTag:
263
+ case int8ArrayTag:
264
+ case int16ArrayTag:
265
+ case int32ArrayTag:
266
+ case bigInt64ArrayTag:
267
+ case float32ArrayTag:
268
+ case float64ArrayTag:
269
+ if (isBuffer(a) !== isBuffer(b)) return false;
270
+ if (a.length !== b.length) return false;
271
+ for (let i = 0; i < a.length; i++) if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) return false;
272
+ return true;
273
+ case arrayBufferTag:
274
+ if (a.byteLength !== b.byteLength) return false;
275
+ return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
276
+ case dataViewTag:
277
+ if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) return false;
278
+ return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
279
+ case errorTag: return a.name === b.name && a.message === b.message;
280
+ case objectTag: {
281
+ if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b))) return false;
282
+ const aKeys = [...Object.keys(a), ...getSymbols(a)];
283
+ const bKeys = [...Object.keys(b), ...getSymbols(b)];
284
+ if (aKeys.length !== bKeys.length) return false;
285
+ for (let i = 0; i < aKeys.length; i++) {
286
+ const propKey = aKeys[i];
287
+ const aProp = a[propKey];
288
+ if (!Object.hasOwn(b, propKey)) return false;
289
+ const bProp = b[propKey];
290
+ if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) return false;
291
+ }
292
+ return true;
293
+ }
294
+ default: return false;
295
+ }
296
+ } finally {
297
+ stack.delete(a);
298
+ stack.delete(b);
299
+ }
300
+ }
301
+ function init_isEqualWith() {
302
+ return (init_isEqualWith = __esmMin((() => {
303
+ init_tags();
304
+ init_isBuffer();
305
+ })))();
306
+ }
307
+ //#endregion
308
+ //#region ../../node_modules/es-toolkit/dist/function/noop.mjs
309
+ /**
310
+ * A no-operation function that does nothing.
311
+ * This can be used as a placeholder or default function.
312
+ *
313
+ * @example
314
+ * noop(); // Does nothing
315
+ *
316
+ * @returns This function does not return anything.
317
+ */
318
+ function noop$1() {}
319
+ //#endregion
320
+ //#region ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
321
+ /**
322
+ * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.
323
+ *
324
+ * @param a - The first value to compare.
325
+ * @param b - The second value to compare.
326
+ * @returns `true` if the values are equal, otherwise `false`.
327
+ *
328
+ * @example
329
+ * isEqual(1, 1); // true
330
+ * isEqual({ a: 1 }, { a: 1 }); // true
331
+ * isEqual(/abc/g, /abc/g); // true
332
+ * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true
333
+ * isEqual([1, 2, 3], [1, 2, 3]); // true
334
+ */
335
+ function isEqual(a, b) {
336
+ return isEqualWith(a, b, noop$1);
337
+ }
338
+ function init_isEqual() {
339
+ return (init_isEqual = __esmMin((() => {
340
+ init_isEqualWith();
341
+ })))();
342
+ }
343
+ //#endregion
344
+ //#region ../../node_modules/clsx/dist/clsx.mjs
345
+ function r$1(e) {
346
+ var t, f, n = "";
347
+ if ("string" == typeof e || "number" == typeof e) n += e;
348
+ else if ("object" == typeof e) if (Array.isArray(e)) {
349
+ var o = e.length;
350
+ for (t = 0; t < o; t++) e[t] && (f = r$1(e[t])) && (n && (n += " "), n += f);
351
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
352
+ return n;
353
+ }
354
+ function clsx() {
355
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r$1(e)) && (n && (n += " "), n += t);
356
+ return n;
357
+ }
358
+ function init_clsx() {
359
+ return (init_clsx = __esmMin((() => {})))();
360
+ }
361
+ //#endregion
362
+ //#region ../../node_modules/es-toolkit/dist/function/debounce.mjs
363
+ /**
364
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
365
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
366
+ * method to cancel any pending execution.
367
+ *
368
+ * @template F - The type of function.
369
+ * @param func - The function to debounce.
370
+ * @param debounceMs - The number of milliseconds to delay.
371
+ * @param options - The options object
372
+ * @param options.signal - An optional AbortSignal to cancel the debounced function.
373
+ * @param options.edges - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
374
+ * @returns A new debounced function with a `cancel` method.
375
+ *
376
+ * @example
377
+ * const debouncedFunction = debounce(() => {
378
+ * console.log('Function executed');
379
+ * }, 1000);
380
+ *
381
+ * // Will log 'Function executed' after 1 second if not called again in that time
382
+ * debouncedFunction();
383
+ *
384
+ * // Will not log anything as the previous call is canceled
385
+ * debouncedFunction.cancel();
386
+ *
387
+ * // With AbortSignal
388
+ * const controller = new AbortController();
389
+ * const signal = controller.signal;
390
+ * const debouncedWithSignal = debounce(() => {
391
+ * console.log('Function executed');
392
+ * }, 1000, { signal });
393
+ *
394
+ * debouncedWithSignal();
395
+ *
396
+ * // Will cancel the debounced function call
397
+ * controller.abort();
398
+ */
399
+ function debounce$1(func, debounceMs, { signal, edges } = {}) {
400
+ let pendingThis = void 0;
401
+ let pendingArgs = null;
402
+ const leading = edges != null && edges.includes("leading");
403
+ const trailing = edges == null || edges.includes("trailing");
404
+ const invoke = () => {
405
+ if (pendingArgs !== null) {
406
+ func.apply(pendingThis, pendingArgs);
407
+ pendingThis = void 0;
408
+ pendingArgs = null;
409
+ }
410
+ };
411
+ const onTimerEnd = () => {
412
+ if (trailing) invoke();
413
+ cancel();
414
+ };
415
+ let timeoutId = null;
416
+ const schedule = () => {
417
+ if (timeoutId != null) clearTimeout(timeoutId);
418
+ timeoutId = setTimeout(() => {
419
+ timeoutId = null;
420
+ onTimerEnd();
421
+ }, debounceMs);
422
+ };
423
+ const cancelTimer = () => {
424
+ if (timeoutId !== null) {
425
+ clearTimeout(timeoutId);
426
+ timeoutId = null;
427
+ }
428
+ };
429
+ const cancel = () => {
430
+ cancelTimer();
431
+ pendingThis = void 0;
432
+ pendingArgs = null;
433
+ };
434
+ const flush = () => {
435
+ invoke();
436
+ };
437
+ const debounced = function(...args) {
438
+ if (signal?.aborted) return;
439
+ pendingThis = this;
440
+ pendingArgs = args;
441
+ const isFirstCall = timeoutId == null;
442
+ schedule();
443
+ if (leading && isFirstCall) invoke();
444
+ };
445
+ debounced.schedule = schedule;
446
+ debounced.cancel = cancel;
447
+ debounced.flush = flush;
448
+ signal?.addEventListener("abort", cancel, { once: true });
449
+ return debounced;
450
+ }
451
+ function init_debounce() {
452
+ return (init_debounce = __esmMin((() => {})))();
453
+ }
454
+ //#endregion
455
+ //#region ../../node_modules/es-toolkit/dist/function/throttle.mjs
456
+ /**
457
+ * Creates a throttled function that only invokes the provided function at most once
458
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
459
+ * within the wait time will not trigger the execution of the original function.
460
+ *
461
+ * @template F - The type of function.
462
+ * @param func - The function to throttle.
463
+ * @param throttleMs - The number of milliseconds to throttle executions to.
464
+ * @returns A new throttled function that accepts the same parameters as the original function.
465
+ *
466
+ * @example
467
+ * const throttledFunction = throttle(() => {
468
+ * console.log('Function executed');
469
+ * }, 1000);
470
+ *
471
+ * // Will log 'Function executed' immediately
472
+ * throttledFunction();
473
+ *
474
+ * // Will not log anything as it is within the throttle time
475
+ * throttledFunction();
476
+ *
477
+ * // After 1 second
478
+ * setTimeout(() => {
479
+ * throttledFunction(); // Will log 'Function executed'
480
+ * }, 1000);
481
+ */
482
+ function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
483
+ let pendingAt = null;
484
+ const debounced = debounce$1(function(...args) {
485
+ pendingAt = Date.now();
486
+ func.apply(this, args);
487
+ }, throttleMs, {
488
+ signal,
489
+ edges
490
+ });
491
+ const throttled = function(...args) {
492
+ if (pendingAt == null) pendingAt = Date.now();
493
+ if (Date.now() - pendingAt >= throttleMs) {
494
+ pendingAt = Date.now();
495
+ func.apply(this, args);
496
+ debounced.cancel();
497
+ debounced.schedule();
498
+ return;
499
+ }
500
+ debounced.apply(this, args);
501
+ };
502
+ throttled.cancel = debounced.cancel;
503
+ throttled.flush = debounced.flush;
504
+ return throttled;
505
+ }
506
+ function init_throttle() {
507
+ return (init_throttle = __esmMin((() => {})))();
508
+ }
509
+ //#endregion
510
+ //#region ../../node_modules/compute-scroll-into-view/dist/index.js
511
+ var t, e, n, o, l, r;
512
+ function init_dist() {
513
+ return (init_dist = __esmMin((() => {
514
+ t = (t) => "object" == typeof t && null != t && 1 === t.nodeType;
515
+ e = (t, e) => (!e || "hidden" !== t) && "visible" !== t && "clip" !== t;
516
+ n = (t, n) => {
517
+ if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) {
518
+ const o = getComputedStyle(t, null);
519
+ return e(o.overflowY, n) || e(o.overflowX, n) || ((t) => {
520
+ const e = ((t) => {
521
+ if (!t.ownerDocument || !t.ownerDocument.defaultView) return null;
522
+ try {
523
+ return t.ownerDocument.defaultView.frameElement;
524
+ } catch (t) {
525
+ return null;
526
+ }
527
+ })(t);
528
+ return !!e && (e.clientHeight < t.scrollHeight || e.clientWidth < t.scrollWidth);
529
+ })(t);
530
+ }
531
+ return !1;
532
+ };
533
+ o = (t, e, n, o, l, r, i, s) => r < t && i > e || r > t && i < e ? 0 : r <= t && s <= n || i >= e && s >= n ? r - t - o : i > e && s < n || r < t && s > n ? i - e + l : 0;
534
+ l = (t) => {
535
+ const e = t.parentElement;
536
+ return null == e ? t.getRootNode().host || null : e;
537
+ };
538
+ r = (e, r) => {
539
+ var i, s, d, h;
540
+ if ("undefined" == typeof document) return [];
541
+ const { scrollMode: c, block: f, inline: u, boundary: a, skipOverflowHiddenElements: g } = r, p = "function" == typeof a ? a : (t) => t !== a;
542
+ if (!t(e)) throw new TypeError("Invalid target");
543
+ const m = document.scrollingElement || document.documentElement, w = [];
544
+ let W = e;
545
+ for (; t(W) && p(W);) {
546
+ if (W = l(W), W === m) {
547
+ w.push(W);
548
+ break;
549
+ }
550
+ null != W && W === document.body && n(W) && !n(document.documentElement) || null != W && n(W, g) && w.push(W);
551
+ }
552
+ const b = null != (s = null == (i = window.visualViewport) ? void 0 : i.width) ? s : innerWidth, H = null != (h = null == (d = window.visualViewport) ? void 0 : d.height) ? h : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t) => {
553
+ const e = window.getComputedStyle(t);
554
+ return {
555
+ top: parseFloat(e.scrollMarginTop) || 0,
556
+ right: parseFloat(e.scrollMarginRight) || 0,
557
+ bottom: parseFloat(e.scrollMarginBottom) || 0,
558
+ left: parseFloat(e.scrollMarginLeft) || 0
559
+ };
560
+ })(e);
561
+ let k = "start" === f || "nearest" === f ? x - T : "end" === f ? I + F : x + v / 2 - T + F, D = "center" === u ? R + E / 2 - V + B : "end" === u ? C + B : R - V;
562
+ const L = [];
563
+ for (let t = 0; t < w.length; t++) {
564
+ const e = w[t], { height: l, width: r, top: i, right: s, bottom: d, left: h } = e.getBoundingClientRect();
565
+ if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && (e === m && !n(e) || x >= i && I <= d && R >= h && C <= s)) return L;
566
+ const a = getComputedStyle(e), g = parseInt(a.borderLeftWidth, 10), p = parseInt(a.borderTopWidth, 10), W = parseInt(a.borderRightWidth, 10), T = parseInt(a.borderBottomWidth, 10);
567
+ let B = 0, F = 0;
568
+ const V = "offsetWidth" in e ? e.offsetWidth - e.clientWidth - g - W : 0, S = "offsetHeight" in e ? e.offsetHeight - e.clientHeight - p - T : 0, X = "offsetWidth" in e ? 0 === e.offsetWidth ? 0 : r / e.offsetWidth : 0, Y = "offsetHeight" in e ? 0 === e.offsetHeight ? 0 : l / e.offsetHeight : 0;
569
+ if (m === e) B = "start" === f ? k : "end" === f ? k - H : "nearest" === f ? o(M, M + H, H, p, T, M + k, M + k + v, v) : k - H / 2, F = "start" === u ? D : "center" === u ? D - b / 2 : "end" === u ? D - b : o(y, y + b, b, g, W, y + D, y + D + E, E), B = Math.max(0, B + M), F = Math.max(0, F + y);
570
+ else {
571
+ B = "start" === f ? k - i - p : "end" === f ? k - d + T + S : "nearest" === f ? o(i, d, l, p, T + S, k, k + v, v) : k - (i + l / 2) + S / 2, F = "start" === u ? D - h - g : "center" === u ? D - (h + r / 2) + V / 2 : "end" === u ? D - s + W + V : o(h, s, r, g, W + V, D, D + E, E);
572
+ const { scrollLeft: t, scrollTop: n } = e;
573
+ B = 0 === Y ? 0 : Math.max(0, Math.min(n + B / Y, e.scrollHeight - l / Y + S)), F = 0 === X ? 0 : Math.max(0, Math.min(t + F / X, e.scrollWidth - r / X + V)), k += n - B, D += t - F;
574
+ }
575
+ L.push({
576
+ el: e,
577
+ top: B,
578
+ left: F
579
+ });
580
+ }
581
+ return L;
582
+ };
583
+ })))();
584
+ }
585
+ //#endregion
586
+ //#region ../../node_modules/downshift/dist/downshift.esm.mjs
587
+ /**
588
+ * This generates a unique ID for an instance of Downshift
589
+ * @return {string} the unique ID
590
+ */
591
+ function generateId() {
592
+ return String(idCounter++);
593
+ }
594
+ function useLatestRef(value) {
595
+ var ref = useRef(value);
596
+ useIsomorphicLayoutEffect(function() {
597
+ ref.current = value;
598
+ }, [value]);
599
+ return ref;
600
+ }
601
+ function handleRefs() {
602
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) refs[_key] = arguments[_key];
603
+ return function(node) {
604
+ refs.forEach(function(ref) {
605
+ if (typeof ref === "function") ref(node);
606
+ else if (ref) ref.current = node;
607
+ });
608
+ };
609
+ }
610
+ /**
611
+ * This is intended to be used to compose event handlers.
612
+ * They are executed in order until one of them sets
613
+ * `event.preventDownshiftDefault = true`.
614
+ * @param fns the event handler functions
615
+ * @return the event handler to add to an element
616
+ */
617
+ function callAllEventHandlers() {
618
+ for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) fns[_key] = arguments[_key];
619
+ return function(event) {
620
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
621
+ return fns.some(function(fn) {
622
+ if (fn) fn.apply(void 0, [event].concat(args));
623
+ return event.preventDownshiftDefault || event.hasOwnProperty("nativeEvent") && event.nativeEvent.preventDownshiftDefault;
624
+ });
625
+ };
626
+ }
627
+ /**
628
+ * Simple debounce implementation. Will call the given
629
+ * function once after the time given has passed since
630
+ * it was last called.
631
+ */
632
+ function debounce(fn, time) {
633
+ var timeoutId;
634
+ function cancel() {
635
+ if (timeoutId) clearTimeout(timeoutId);
636
+ }
637
+ function wrapper() {
638
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
639
+ cancel();
640
+ timeoutId = setTimeout(function() {
641
+ timeoutId = null;
642
+ fn.apply(void 0, args);
643
+ }, time);
644
+ }
645
+ wrapper.cancel = cancel;
646
+ return wrapper;
647
+ }
648
+ /**
649
+ * Get the status node or create it if it does not already exist.
650
+ */
651
+ function getStatusDiv(document) {
652
+ var statusDiv = document.getElementById("a11y-status-message");
653
+ if (statusDiv) return statusDiv;
654
+ statusDiv = document.createElement("div");
655
+ statusDiv.setAttribute("id", "a11y-status-message");
656
+ statusDiv.setAttribute("role", "status");
657
+ statusDiv.setAttribute("aria-live", "polite");
658
+ statusDiv.setAttribute("aria-relevant", "additions text");
659
+ Object.assign(statusDiv.style, {
660
+ border: "0",
661
+ clip: "rect(0 0 0 0)",
662
+ height: "1px",
663
+ margin: "-1px",
664
+ overflow: "hidden",
665
+ padding: "0",
666
+ position: "absolute",
667
+ width: "1px"
668
+ });
669
+ document.body.appendChild(statusDiv);
670
+ return statusDiv;
671
+ }
672
+ /**
673
+ * Sets aria live status to a div element that's visually hidden.
674
+ */
675
+ function setStatus(status, document) {
676
+ if (!status || !document) return;
677
+ var div = getStatusDiv(document);
678
+ div.textContent = status;
679
+ cleanupStatus(document);
680
+ }
681
+ /**
682
+ * Removes the status element from the DOM
683
+ */
684
+ function cleanupStatusDiv(document) {
685
+ var statusDiv = document == null ? void 0 : document.getElementById("a11y-status-message");
686
+ if (statusDiv) statusDiv.remove();
687
+ }
688
+ function noop() {}
689
+ /**
690
+ * This will perform a shallow merge of the given state object
691
+ * with the state coming from props
692
+ * (for the controlled component scenario)
693
+ * This is used in state updater functions so they're referencing
694
+ * the right state regardless of where it comes from.
695
+ *
696
+ * @param state The state of the component/hook.
697
+ * @param props The props that may contain controlled values.
698
+ * @returns The merged controlled state.
699
+ */
700
+ function getState(state, props) {
701
+ if (!props) return state;
702
+ return Object.keys(state).reduce(function(newState, key) {
703
+ if (props[key] !== void 0) newState[key] = props[key];
704
+ return newState;
705
+ }, _extends({}, state));
706
+ }
707
+ /**
708
+ * Scroll node into view if necessary
709
+ * @param {HTMLElement} node the element that should scroll into view
710
+ * @param {HTMLElement} menuNode the menu element of the component
711
+ */
712
+ function scrollIntoView(node, menuNode) {
713
+ if (!node) return;
714
+ r(node, {
715
+ boundary: menuNode,
716
+ block: "nearest",
717
+ scrollMode: "if-needed"
718
+ }).forEach(function(_ref) {
719
+ var el = _ref.el, top = _ref.top, left = _ref.left;
720
+ el.scrollTop = top;
721
+ el.scrollLeft = left;
722
+ });
723
+ }
724
+ /**
725
+ * Normalizes the 'key' property of a KeyboardEvent in IE/Edge
726
+ * @param event a keyboardEvent object
727
+ * @return keyboard key
728
+ */
729
+ function normalizeArrowKey(event) {
730
+ var key = event.key, keyCode = event.keyCode;
731
+ /* istanbul ignore next (ie) */
732
+ if (keyCode >= 37 && keyCode <= 40 && !key.startsWith("Arrow")) return "Arrow" + key;
733
+ return key;
734
+ }
735
+ /**
736
+ * Returns the next non-disabled highlightedIndex value.
737
+ *
738
+ * @param start The current highlightedIndex.
739
+ * @param backwards If true, it will search backwards from the start.
740
+ * @param items The items array.
741
+ * @param isItemDisabled Function that tells if an item is disabled or not.
742
+ * @param circular If the search reaches the end, if it can search again starting from the other end.
743
+ * @returns The next non-disabled index.
744
+ */
745
+ function getNonDisabledIndex(start, backwards, items, isItemDisabled, circular) {
746
+ if (circular === void 0) circular = false;
747
+ var count = items.length;
748
+ if (backwards) {
749
+ for (var index = start; index >= 0; index--) if (!isItemDisabled(items[index], index)) return index;
750
+ } else for (var _index = start; _index < count; _index++) if (!isItemDisabled(items[_index], _index)) return _index;
751
+ if (circular) return getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled);
752
+ return -1;
753
+ }
754
+ /**
755
+ * Returns the next non-disabled highlightedIndex value.
756
+ *
757
+ * @param start The current highlightedIndex.
758
+ * @param offset The offset from the current highlightedIndex to start searching.
759
+ * @param items The items array.
760
+ * @param isItemDisabled Function that tells if an item is disabled or not.
761
+ * @param circular If the search reaches the end, if it can search again starting from the other end.
762
+ * @returns The next highlightedIndex.
763
+ */
764
+ function getHighlightedIndex(start, offset, items, isItemDisabled, circular) {
765
+ if (circular === void 0) circular = false;
766
+ var count = items.length;
767
+ if (count === 0) return -1;
768
+ var itemsLastIndex = count - 1;
769
+ if (typeof start !== "number" || start < 0 || start > itemsLastIndex) start = offset > 0 ? -1 : itemsLastIndex + 1;
770
+ var current = start + offset;
771
+ if (current < 0) current = circular ? itemsLastIndex : 0;
772
+ else if (current > itemsLastIndex) current = circular ? 0 : itemsLastIndex;
773
+ var highlightedIndex = getNonDisabledIndex(current, offset < 0, items, isItemDisabled, circular);
774
+ if (highlightedIndex === -1) return start >= count ? -1 : start;
775
+ return highlightedIndex;
776
+ }
777
+ /**
778
+ * Checks if event target is within the downshift elements.
779
+ *
780
+ * @param target Target to check.
781
+ * @param downshiftElements The elements that form downshift (list, toggle button etc).
782
+ * @param environment The window context where downshift renders.
783
+ * @param checkActiveElement Whether to also check activeElement.
784
+ *
785
+ * @returns Whether or not the target is within downshift elements.
786
+ */
787
+ function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
788
+ if (checkActiveElement === void 0) checkActiveElement = true;
789
+ return !!environment && downshiftElements.some(function(contextNode) {
790
+ return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
791
+ });
792
+ }
793
+ /**
794
+ * @param parent the parent node
795
+ * @param child the child node
796
+ * @param environment The window context where downshift renders.
797
+ * @return Whether the parent is the child or the child is in the parent
798
+ */
799
+ function isOrContainsNode(parent, child, environment) {
800
+ return parent === child || child instanceof environment.Node && parent.contains(child);
801
+ }
802
+ /**
803
+ * Accepts a parameter and returns it if it's a function
804
+ * or a noop function if it's not. This allows us to
805
+ * accept a callback, but not worry about it if it's not
806
+ * passed.
807
+ * @param {Function} cb the callback
808
+ * @return {Function} a function
809
+ */
810
+ function cbToCb(cb) {
811
+ return typeof cb === "function" ? cb : noop;
812
+ }
813
+ /**
814
+ * Default implementation for status message. Only added when menu is open.
815
+ * Will specify if there are results in the list, and if so, how many,
816
+ * and what keys are relevant.
817
+ *
818
+ * @param {Object} param the downshift state and other relevant properties
819
+ * @return {String} the a11y status message
820
+ */
821
+ function getA11yStatusMessage(_ref) {
822
+ var isOpen = _ref.isOpen, resultCount = _ref.resultCount, previousResultCount = _ref.previousResultCount;
823
+ if (!isOpen) return "";
824
+ if (!resultCount) return "No results are available.";
825
+ if (resultCount !== previousResultCount) return resultCount + " result" + (resultCount === 1 ? " is" : "s are") + " available, use up and down arrow keys to navigate. Press Enter key to select.";
826
+ return "";
827
+ }
828
+ /**
829
+ * Takes an argument and if it's an array, returns the first item in the array
830
+ * otherwise returns the argument
831
+ * @param {*} arg the maybe-array
832
+ * @param {*} defaultValue the value if arg is falsey not defined
833
+ * @return {*} the arg or it's first item
834
+ */
835
+ function unwrapArray(arg, defaultValue) {
836
+ arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */ arg[0] : arg;
837
+ if (!arg && defaultValue) return defaultValue;
838
+ else return arg;
839
+ }
840
+ /**
841
+ * @param {Object} element (P)react element
842
+ * @return {Boolean} whether it's a DOM element
843
+ */
844
+ function isDOMElement(element) {
845
+ return typeof element.type === "string";
846
+ }
847
+ /**
848
+ * @param {Object} element (P)react element
849
+ * @return {Object} the props
850
+ */
851
+ function getElementProps(element) {
852
+ return element.props;
853
+ }
854
+ /**
855
+ * @param {Object} state the state object
856
+ * @return {Object} state that is relevant to downshift
857
+ */
858
+ function pickState(state) {
859
+ if (state === void 0) state = {};
860
+ var result = {};
861
+ stateKeys.forEach(function(k) {
862
+ if (state.hasOwnProperty(k)) result[k] = state[k];
863
+ });
864
+ return result;
865
+ }
866
+ function capitalizeString(string) {
867
+ return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
868
+ }
869
+ function callOnChangeProps(action, props, state, newState) {
870
+ var type = action.type;
871
+ var changes = {};
872
+ var keys = Object.keys(state);
873
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
874
+ var key = _keys[_i];
875
+ invokeOnChangeHandler(key, action, props, state, newState);
876
+ if (newState[key] !== state[key]) changes[key] = newState[key];
877
+ }
878
+ if (typeof props.onStateChange === "function" && Object.keys(changes).length) props.onStateChange(_extends({ type }, changes));
879
+ }
880
+ function invokeOnChangeHandler(key, action, props, state, newState) {
881
+ if (newState[key] === state[key]) return;
882
+ var handler = props["on" + capitalizeString(key) + "Change"];
883
+ if (typeof handler !== "function") return;
884
+ var type = action.type;
885
+ handler(_extends({ type }, newState));
886
+ }
887
+ /**
888
+ * Computes the controlled state using a the previous state, props,
889
+ * two reducers, one from downshift and an optional one from the user.
890
+ * Also calls the onChange handlers for state values that have changed.
891
+ *
892
+ * @param reducer Reducer function from downshift.
893
+ * @param props The hook props, also passed to createInitialState.
894
+ * @param createInitialState Function that returns the initial state.
895
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
896
+ * @returns An array with the state and an action dispatcher.
897
+ */
898
+ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
899
+ var prevStateRef = useRef({});
900
+ var enhancedReducer = useCallback(function(_ref, action) {
901
+ var state = _ref.state;
902
+ state = getState(state, action.props);
903
+ var changes = reducer(state, action);
904
+ var newState = action.props.stateReducer(state, _extends({}, action, { changes }));
905
+ return {
906
+ state: _extends({}, state, newState),
907
+ lastAction: action
908
+ };
909
+ }, [reducer]);
910
+ var _React$useReducer = useReducer(enhancedReducer, props, function(p) {
911
+ return {
912
+ state: createInitialState(p),
913
+ lastAction: void 0
914
+ };
915
+ }), _React$useReducer$ = _React$useReducer[0], state = _React$useReducer$.state, lastAction = _React$useReducer$.lastAction, dispatch = _React$useReducer[1];
916
+ var propsRef = useLatestRef(props);
917
+ var dispatchWithProps = useCallback(function(action) {
918
+ return dispatch(_extends({}, action, { props: propsRef.current }));
919
+ }, [propsRef]);
920
+ useEffect(function() {
921
+ if (lastAction) {
922
+ var prevState = getState(prevStateRef.current, lastAction.props);
923
+ if (!isStateEqual(prevState, state)) callOnChangeProps(lastAction, lastAction.props, prevState, state);
924
+ }
925
+ prevStateRef.current = state;
926
+ }, [
927
+ state,
928
+ lastAction,
929
+ isStateEqual
930
+ ]);
931
+ return [state, dispatchWithProps];
932
+ }
933
+ /**
934
+ * Wraps the useEnhancedReducer and applies the controlled prop values before
935
+ * returning the new state.
936
+ * @param reducer Reducer function from downshift.
937
+ * @param props The hook props, also passed to createInitialState.
938
+ * @param createInitialState Function that returns the initial state.
939
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
940
+ * @returns An array with the state and an action dispatcher.
941
+ */
942
+ function useControlledReducer$1(reducer, props, createInitialState, isStateEqual) {
943
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1];
944
+ return [getState(state, props), dispatch];
945
+ }
946
+ /**
947
+ * Returns both the item and index when both or either is passed.
948
+ *
949
+ * @param itemProp The item which could be undefined.
950
+ * @param indexProp The index which could be undefined.
951
+ * @param items The array of items to get the item based on index.
952
+ * @param errorMessage The error to be thrown if index and item could not be returned for any reason.
953
+ * @returns An array with item and index.
954
+ */
955
+ function getItemAndIndex(itemProp, indexProp, items, errorMessage) {
956
+ if (itemProp !== void 0 && indexProp !== void 0) return [itemProp, indexProp];
957
+ if (itemProp !== void 0) {
958
+ if (items.indexOf(itemProp) < 0) throw new Error(errorMessage);
959
+ return [itemProp, items.indexOf(itemProp)];
960
+ }
961
+ if (indexProp !== void 0) {
962
+ var item = items[indexProp];
963
+ if (item === void 0) throw new Error(errorMessage);
964
+ return [item, indexProp];
965
+ }
966
+ throw new Error(errorMessage);
967
+ }
968
+ /**
969
+ * Tracks if it's the first render.
970
+ */
971
+ function useIsInitialMount() {
972
+ var isInitialMountRef = useRef(true);
973
+ useEffect(function() {
974
+ isInitialMountRef.current = false;
975
+ return function() {
976
+ isInitialMountRef.current = true;
977
+ };
978
+ }, []);
979
+ return isInitialMountRef.current;
980
+ }
981
+ /**
982
+ * Returns the default value based on the defaultProp and defaultStateValue.
983
+ *
984
+ * @param defaultProp The default prop value.
985
+ * @param defaultStateValue The default state value.
986
+ * @returns The resolved default value.
987
+ */
988
+ function getDefaultValue(defaultProp, defaultStateValue) {
989
+ return defaultProp === void 0 ? defaultStateValue : defaultProp;
990
+ }
991
+ /**
992
+ * Returns the initial value for a state variable, based on the following precedence:
993
+ * 1. The controlled value (if it's not undefined)
994
+ * 2. The initialValue (if it's not undefined)
995
+ * 3. The defaultValue (if it's not undefined)
996
+ * 4. The defaultStateValue
997
+ *
998
+ * @param value The controlled value of the state variable.
999
+ * @param initialValue The initial value of the state variable.
1000
+ * @param defaultValue The default value of the state variable.
1001
+ * @param defaultStateValue The default state value to use if all other values are undefined.
1002
+ * @returns The initial value for the state variable.
1003
+ */
1004
+ function getInitialValue(value, initialValue, defaultValue, defaultStateValue) {
1005
+ if (value !== void 0) return value;
1006
+ if (initialValue !== void 0) return initialValue;
1007
+ if (defaultValue !== void 0) return defaultValue;
1008
+ return defaultStateValue;
1009
+ }
1010
+ /**
1011
+ * Adds an a11y aria live status message if getA11yStatusMessage is passed.
1012
+ * @param getA11yStatusMessage The function that builds the status message.
1013
+ * @param options The options to be passed to getA11yStatusMessage if called.
1014
+ * @param dependencyArray The dependency array that triggers the status message setter via useEffect.
1015
+ * @param environment The environment object containing the document.
1016
+ */
1017
+ function useA11yMessageStatus(getA11yStatusMessage, options, dependencyArray, environment) {
1018
+ var document = environment == null ? void 0 : environment.document;
1019
+ var isInitialMount = useIsInitialMount();
1020
+ useEffect(function() {
1021
+ if (!getA11yStatusMessage || isInitialMount || !document) return;
1022
+ updateA11yStatus(getA11yStatusMessage(options), document);
1023
+ }, dependencyArray);
1024
+ useEffect(function() {
1025
+ return function() {
1026
+ updateA11yStatus.cancel();
1027
+ cleanupStatusDiv(document);
1028
+ };
1029
+ }, [document]);
1030
+ }
1031
+ function useElementIdsR18$1(_ref) {
1032
+ var id = _ref.id, labelId = _ref.labelId, menuId = _ref.menuId, getItemId = _ref.getItemId, toggleButtonId = _ref.toggleButtonId, inputId = _ref.inputId;
1033
+ var reactId = "downshift-" + reactUseId$1();
1034
+ if (!id) id = reactId;
1035
+ return useMemo(function() {
1036
+ return {
1037
+ labelId: labelId != null ? labelId : id + "-label",
1038
+ menuId: menuId != null ? menuId : id + "-menu",
1039
+ getItemId: getItemId != null ? getItemId : function(index) {
1040
+ return id + "-item-" + index;
1041
+ },
1042
+ toggleButtonId: toggleButtonId != null ? toggleButtonId : id + "-toggle-button",
1043
+ inputId: inputId != null ? inputId : id + "-input"
1044
+ };
1045
+ }, [
1046
+ getItemId,
1047
+ id,
1048
+ inputId,
1049
+ labelId,
1050
+ menuId,
1051
+ toggleButtonId
1052
+ ]);
1053
+ }
1054
+ function useElementIdsLegacy$1(_ref2) {
1055
+ var id = _ref2.id, labelId = _ref2.labelId, menuId = _ref2.menuId, getItemId = _ref2.getItemId, toggleButtonId = _ref2.toggleButtonId, inputId = _ref2.inputId;
1056
+ var baseId = useState(function() {
1057
+ return id != null ? id : "downshift-" + generateId();
1058
+ })[0];
1059
+ return useMemo(function() {
1060
+ return {
1061
+ labelId: labelId != null ? labelId : baseId + "-label",
1062
+ menuId: menuId != null ? menuId : baseId + "-menu",
1063
+ getItemId: getItemId != null ? getItemId : function(index) {
1064
+ return baseId + "-item-" + index;
1065
+ },
1066
+ toggleButtonId: toggleButtonId != null ? toggleButtonId : baseId + "-toggle-button",
1067
+ inputId: inputId != null ? inputId : baseId + "-input"
1068
+ };
1069
+ }, [
1070
+ getItemId,
1071
+ inputId,
1072
+ labelId,
1073
+ menuId,
1074
+ toggleButtonId,
1075
+ baseId
1076
+ ]);
1077
+ }
1078
+ /**
1079
+ * Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
1080
+ *
1081
+ * @param props Props passed to the hook.
1082
+ * @returns The highlighted index.
1083
+ */
1084
+ function getDefaultHighlightedIndex(items, isItemDisabled, defaultHighlightedIndex) {
1085
+ var highlightedIndex = getDefaultValue(defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex);
1086
+ if (items[highlightedIndex] && isItemDisabled(items[highlightedIndex], highlightedIndex)) return -1;
1087
+ return highlightedIndex;
1088
+ }
1089
+ /**
1090
+ * Handles selection on Enter / Alt + ArrowUp. Closes the menu and resets the highlighted index, unless there is a highlighted.
1091
+ * In that case, selects the item and resets to defaults for open state and highlighted idex.
1092
+ *
1093
+ * @param props The Dropdown props.
1094
+ * @param highlightedIndex The index from the state.
1095
+ * @param inputValue Also return the input value for state.
1096
+ * @returns The changes for the state.
1097
+ */
1098
+ function getChangesOnSelection(items, itemToString, defaultIsOpen, defaultHighlightedIndex, highlightedIndex, inputValue) {
1099
+ var shouldSelect = items.length && highlightedIndex >= 0;
1100
+ return _extends({
1101
+ isOpen: false,
1102
+ highlightedIndex: -1
1103
+ }, shouldSelect && _extends({
1104
+ selectedItem: items[highlightedIndex],
1105
+ isOpen: getDefaultValue(defaultIsOpen, dropdownDefaultStateValues.isOpen),
1106
+ highlightedIndex: getDefaultValue(defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex)
1107
+ }, inputValue && { inputValue: itemToString(items[highlightedIndex]) }));
1108
+ }
1109
+ /**
1110
+ * Returns the highlighted index when the menu is opened.
1111
+ * Takes into account the initialHighlightedIndex, defaultHighlightedIndex,
1112
+ * selectedItem, and the open direction offset.
1113
+ *
1114
+ * @param items The list of items.
1115
+ * @param initialHighlightedIndex The initial highlighted index prop.
1116
+ * @param defaultHighlightedIndex The default highlighted index prop.
1117
+ * @param isItemDisabled Callback to determine if an item is disabled.
1118
+ * @param itemToKey Callback to get a unique key from an item.
1119
+ * @param selectedItem The currently selected item.
1120
+ * @param highlightedIndex The current highlighted index from state.
1121
+ * @param offset The direction of navigation: positive opens downward, negative opens upward.
1122
+ * @returns The new highlighted index.
1123
+ */
1124
+ function getHighlightedIndexOnOpen(items, initialHighlightedIndex, defaultHighlightedIndex, isItemDisabled, itemToKey, selectedItem, highlightedIndex, offset) {
1125
+ if (items.length === 0) return -1;
1126
+ if (initialHighlightedIndex !== void 0 && highlightedIndex === initialHighlightedIndex && (initialHighlightedIndex === -1 || items[initialHighlightedIndex] !== void 0 && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex))) return initialHighlightedIndex;
1127
+ if (defaultHighlightedIndex !== void 0 && (defaultHighlightedIndex === -1 || items[defaultHighlightedIndex] !== void 0 && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex))) return defaultHighlightedIndex;
1128
+ if (selectedItem) return items.findIndex(function(item) {
1129
+ return itemToKey(selectedItem) === itemToKey(item);
1130
+ });
1131
+ if (offset < 0 && items[items.length - 1] && !isItemDisabled(items[items.length - 1], items.length - 1)) return items.length - 1;
1132
+ if (offset > 0 && items[0] && !isItemDisabled(items[0], 0)) return 0;
1133
+ return -1;
1134
+ }
1135
+ function getInitialState$3(props) {
1136
+ var selectedItem = getInitialValue(props.selectedItem, props.initialSelectedItem, props.defaultSelectedItem, dropdownDefaultStateValues.selectedItem);
1137
+ var isOpen = getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen);
1138
+ var highlightedIndex = getInitialHighlightedIndex(props);
1139
+ var inputValue = getInitialValue(props.inputValue, props.initialInputValue, props.defaultInputValue, dropdownDefaultStateValues.inputValue);
1140
+ return {
1141
+ highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function(item) {
1142
+ return props.itemToKey(item) === props.itemToKey(selectedItem);
1143
+ }) : highlightedIndex,
1144
+ isOpen,
1145
+ selectedItem,
1146
+ inputValue
1147
+ };
1148
+ }
1149
+ /**
1150
+ * Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
1151
+ * @param props Props from useCombobox or useSelect.
1152
+ * @returns The highlighted index.
1153
+ */
1154
+ function getInitialHighlightedIndex(props) {
1155
+ var highlightedIndex = getInitialValue(props.highlightedIndex, props.initialHighlightedIndex, props.defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex);
1156
+ if (highlightedIndex > -1 && props.items[highlightedIndex] && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) return -1;
1157
+ return highlightedIndex;
1158
+ }
1159
+ /**
1160
+ * Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
1161
+ *
1162
+ * @param environment The environment to add the event listeners to, for instance window.
1163
+ * @param handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
1164
+ * @param downshiftRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
1165
+ * @returns A ref holding the mouse and touch events information. Read `.current` only inside event handlers/effects.
1166
+ */
1167
+ function useMouseAndTouchTracker(environment, handleBlur, downshiftRefs) {
1168
+ var mouseAndTouchTrackersRef = useRef({
1169
+ isMouseDown: false,
1170
+ isTouchMove: false,
1171
+ isTouchEnd: false
1172
+ });
1173
+ var getDownshiftElements = useCallback(function() {
1174
+ return downshiftRefs.map(function(ref) {
1175
+ return ref.current;
1176
+ });
1177
+ }, [downshiftRefs]);
1178
+ useEffect(function() {
1179
+ if (!environment) return noop;
1180
+ function onMouseDown() {
1181
+ mouseAndTouchTrackersRef.current.isTouchEnd = false;
1182
+ mouseAndTouchTrackersRef.current.isMouseDown = true;
1183
+ }
1184
+ function onMouseUp(event) {
1185
+ mouseAndTouchTrackersRef.current.isMouseDown = false;
1186
+ if (!targetWithinDownshift(event.target, getDownshiftElements(), environment)) handleBlur();
1187
+ }
1188
+ function onTouchStart() {
1189
+ mouseAndTouchTrackersRef.current.isTouchEnd = false;
1190
+ mouseAndTouchTrackersRef.current.isTouchMove = false;
1191
+ }
1192
+ function onTouchMove() {
1193
+ mouseAndTouchTrackersRef.current.isTouchMove = true;
1194
+ }
1195
+ function onTouchEnd(event) {
1196
+ mouseAndTouchTrackersRef.current.isTouchEnd = true;
1197
+ if (!mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, getDownshiftElements(), environment, false)) handleBlur();
1198
+ }
1199
+ environment.addEventListener("mousedown", onMouseDown);
1200
+ environment.addEventListener("mouseup", onMouseUp);
1201
+ environment.addEventListener("touchstart", onTouchStart);
1202
+ environment.addEventListener("touchmove", onTouchMove);
1203
+ environment.addEventListener("touchend", onTouchEnd);
1204
+ return function cleanup() {
1205
+ environment.removeEventListener("mousedown", onMouseDown);
1206
+ environment.removeEventListener("mouseup", onMouseUp);
1207
+ environment.removeEventListener("touchstart", onTouchStart);
1208
+ environment.removeEventListener("touchmove", onTouchMove);
1209
+ environment.removeEventListener("touchend", onTouchEnd);
1210
+ };
1211
+ }, [
1212
+ environment,
1213
+ getDownshiftElements,
1214
+ handleBlur
1215
+ ]);
1216
+ return mouseAndTouchTrackersRef;
1217
+ }
1218
+ /**
1219
+ * Utility hook that scrolls an item from a menu into view.
1220
+ * @param scrollIntoView The function that does the scroll.
1221
+ * @param highlightedIndex The index of the item that should be scrolled.
1222
+ * @param isOpen If the menu is open or not.
1223
+ * @param menuRef The ref to the menu element.
1224
+ * @param itemsRef The ref to the object containing item elements.
1225
+ * @param getItemId The function to get the item id from index.
1226
+ * @returns Function that when called prevents the scroll.
1227
+ */
1228
+ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuRef, itemsRef, getItemId) {
1229
+ var shouldScrollRef = useRef(true);
1230
+ useIsomorphicLayoutEffect(function() {
1231
+ if (highlightedIndex < 0 || !isOpen || !Object.keys(itemsRef.current).length) return;
1232
+ if (shouldScrollRef.current) {
1233
+ var itemElement = itemsRef.current[getItemId(highlightedIndex)];
1234
+ if (itemElement && menuRef.current) scrollIntoView(itemElement, menuRef.current);
1235
+ } else shouldScrollRef.current = true;
1236
+ }, [highlightedIndex]);
1237
+ return useCallback(function preventScroll() {
1238
+ shouldScrollRef.current = false;
1239
+ }, []);
1240
+ }
1241
+ /**
1242
+ * Check if a state is equal for dropdowns, by comparing isOpen, inputValue, highlightedIndex and selected item.
1243
+ * Used by useSelect and useCombobox.
1244
+ *
1245
+ * @param prevState The previous dropdown state.
1246
+ * @param newState The new dropdown state.
1247
+ * @returns Whether the states are deeply equal.
1248
+ */
1249
+ function isDropdownStateEqual(prevState, newState) {
1250
+ return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
1251
+ }
1252
+ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
1253
+ var type = action.type;
1254
+ var changes;
1255
+ switch (type) {
1256
+ case stateChangeTypes.ItemMouseMove:
1257
+ changes = { highlightedIndex: action.disabled ? -1 : action.index };
1258
+ break;
1259
+ case stateChangeTypes.MenuMouseLeave:
1260
+ changes = { highlightedIndex: -1 };
1261
+ break;
1262
+ case stateChangeTypes.ToggleButtonClick:
1263
+ case stateChangeTypes.FunctionToggleMenu:
1264
+ changes = {
1265
+ isOpen: !state.isOpen,
1266
+ highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
1267
+ };
1268
+ break;
1269
+ case stateChangeTypes.FunctionOpenMenu:
1270
+ changes = {
1271
+ isOpen: true,
1272
+ highlightedIndex: getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
1273
+ };
1274
+ break;
1275
+ case stateChangeTypes.FunctionCloseMenu:
1276
+ changes = { isOpen: false };
1277
+ break;
1278
+ case stateChangeTypes.FunctionSetHighlightedIndex:
1279
+ var highlightedIndex = action.highlightedIndex;
1280
+ changes = { highlightedIndex: props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex };
1281
+ break;
1282
+ case stateChangeTypes.FunctionSetInputValue:
1283
+ changes = { inputValue: action.inputValue };
1284
+ break;
1285
+ case stateChangeTypes.FunctionReset:
1286
+ changes = {
1287
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
1288
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
1289
+ selectedItem: getDefaultValue(props.defaultSelectedItem, dropdownDefaultStateValues.selectedItem),
1290
+ inputValue: getDefaultValue(props.defaultInputValue, dropdownDefaultStateValues.inputValue)
1291
+ };
1292
+ break;
1293
+ default: throw new Error("Reducer called without proper action type.");
1294
+ }
1295
+ return _extends({}, state, changes);
1296
+ }
1297
+ function getItemIndexByCharacterKey(_ref) {
1298
+ var keysSoFar = _ref.keysSoFar, highlightedIndex = _ref.highlightedIndex, items = _ref.items, itemToString = _ref.itemToString, isItemDisabled = _ref.isItemDisabled;
1299
+ var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
1300
+ for (var _index = 0; _index < items.length; _index++) {
1301
+ var offsetIndex = (_index + highlightedIndex + (keysSoFar.length < 2 ? 1 : 0)) % items.length;
1302
+ var _item = items[offsetIndex];
1303
+ if (_item !== void 0 && itemToString(_item).toLowerCase().startsWith(lowerCasedKeysSoFar) && !isItemDisabled(_item, offsetIndex)) return offsetIndex;
1304
+ }
1305
+ return highlightedIndex;
1306
+ }
1307
+ function downshiftSelectReducer(state, action) {
1308
+ var type = action.type, props = action.props;
1309
+ var changes;
1310
+ switch (type) {
1311
+ case ItemClick$1:
1312
+ changes = {
1313
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
1314
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
1315
+ selectedItem: props.items[action.index]
1316
+ };
1317
+ break;
1318
+ case ToggleButtonKeyDownCharacter:
1319
+ var lowercasedKey = action.key;
1320
+ var inputValue = "" + state.inputValue + lowercasedKey;
1321
+ changes = {
1322
+ inputValue,
1323
+ highlightedIndex: getItemIndexByCharacterKey({
1324
+ keysSoFar: inputValue,
1325
+ highlightedIndex: !state.isOpen && state.selectedItem ? props.items.findIndex(function(item) {
1326
+ return props.itemToKey(item) === props.itemToKey(state.selectedItem);
1327
+ }) : state.highlightedIndex,
1328
+ items: props.items,
1329
+ itemToString: props.itemToString,
1330
+ isItemDisabled: props.isItemDisabled
1331
+ }),
1332
+ isOpen: true
1333
+ };
1334
+ break;
1335
+ case ToggleButtonKeyDownArrowDown:
1336
+ var altKey = action.altKey;
1337
+ changes = {
1338
+ highlightedIndex: state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 1),
1339
+ isOpen: true
1340
+ };
1341
+ break;
1342
+ case ToggleButtonKeyDownArrowUp:
1343
+ var _altKey = action.altKey;
1344
+ if (state.isOpen && _altKey) changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, false);
1345
+ else changes = {
1346
+ highlightedIndex: state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, -1),
1347
+ isOpen: true
1348
+ };
1349
+ break;
1350
+ case ToggleButtonKeyDownEnter:
1351
+ case ToggleButtonKeyDownSpaceButton:
1352
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, false);
1353
+ break;
1354
+ case ToggleButtonKeyDownHome:
1355
+ changes = {
1356
+ highlightedIndex: getNonDisabledIndex(0, false, props.items, props.isItemDisabled),
1357
+ isOpen: true
1358
+ };
1359
+ break;
1360
+ case ToggleButtonKeyDownEnd:
1361
+ changes = {
1362
+ highlightedIndex: getNonDisabledIndex(props.items.length - 1, true, props.items, props.isItemDisabled),
1363
+ isOpen: true
1364
+ };
1365
+ break;
1366
+ case ToggleButtonKeyDownPageUp:
1367
+ changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled) };
1368
+ break;
1369
+ case ToggleButtonKeyDownPageDown:
1370
+ changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled) };
1371
+ break;
1372
+ case ToggleButtonKeyDownEscape:
1373
+ changes = {
1374
+ isOpen: false,
1375
+ highlightedIndex: -1
1376
+ };
1377
+ break;
1378
+ case ToggleButtonBlur:
1379
+ changes = _extends({
1380
+ isOpen: false,
1381
+ highlightedIndex: -1
1382
+ }, state.highlightedIndex >= 0 && props.items.length && { selectedItem: props.items[state.highlightedIndex] });
1383
+ break;
1384
+ case FunctionSelectItem$1:
1385
+ changes = { selectedItem: action.selectedItem };
1386
+ break;
1387
+ default: return downshiftCommonReducer(state, props, action, stateChangeTypes$3);
1388
+ }
1389
+ return _extends({}, state, changes);
1390
+ }
1391
+ function useSelect(userProps) {
1392
+ if (userProps === void 0) userProps = {};
1393
+ validatePropTypes$1(userProps, useSelect, propTypes$3);
1394
+ var props = _extends({}, dropdownDefaultProps, userProps);
1395
+ var items = props.items, isItemDisabled = props.isItemDisabled, scrollIntoView = props.scrollIntoView, environment = props.environment, getA11yStatusMessage = props.getA11yStatusMessage;
1396
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$3, isDropdownStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1];
1397
+ var isOpen = state.isOpen, highlightedIndex = state.highlightedIndex, selectedItem = state.selectedItem, inputValue = state.inputValue;
1398
+ var toggleButtonRef = useRef(null);
1399
+ var menuRef = useRef(null);
1400
+ var itemsRef = useRef({});
1401
+ var clearTimeoutRef = useRef(null);
1402
+ var elementIds = useElementIds$1(props);
1403
+ /**
1404
+ * Ref to read `state` in handlers to preserve referential identity.
1405
+ * Only to be used in handlers and effects.
1406
+ * **never access this in getters**
1407
+ */
1408
+ var stateRef = useLatestRef(state);
1409
+ useA11yMessageStatus(getA11yStatusMessage, state, [
1410
+ isOpen,
1411
+ highlightedIndex,
1412
+ selectedItem,
1413
+ inputValue
1414
+ ], environment);
1415
+ var preventScroll = useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuRef, itemsRef, elementIds.getItemId);
1416
+ useEffect(function() {
1417
+ clearTimeoutRef.current = debounce(function(outerDispatch) {
1418
+ outerDispatch({
1419
+ type: FunctionSetInputValue$1,
1420
+ inputValue: ""
1421
+ });
1422
+ }, 500);
1423
+ return function() {
1424
+ var _clearTimeoutRef$curr;
1425
+ (_clearTimeoutRef$curr = clearTimeoutRef.current) == null || _clearTimeoutRef$curr.cancel();
1426
+ };
1427
+ }, []);
1428
+ useEffect(function() {
1429
+ if (!inputValue) return;
1430
+ clearTimeoutRef.current == null || clearTimeoutRef.current(dispatch);
1431
+ }, [dispatch, inputValue]);
1432
+ useControlPropsValidator({
1433
+ props,
1434
+ state
1435
+ });
1436
+ useEffect(function() {
1437
+ if (getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen) && toggleButtonRef.current) toggleButtonRef.current.focus();
1438
+ }, []);
1439
+ var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function handleBlur() {
1440
+ if (stateRef.current.isOpen) dispatch({ type: ToggleButtonBlur });
1441
+ }, [dispatch, stateRef]), useMemo(function() {
1442
+ return [menuRef, toggleButtonRef];
1443
+ }, []));
1444
+ var setGetterPropCallInfo = useGetterPropsCalledChecker("getMenuProps", "getToggleButtonProps");
1445
+ useEffect(function() {
1446
+ if (!isOpen) itemsRef.current = {};
1447
+ }, [isOpen]);
1448
+ var toggleButtonKeyDownHandlers = useMemo(function() {
1449
+ return {
1450
+ ArrowDown: function ArrowDown(event) {
1451
+ event.preventDefault();
1452
+ dispatch({
1453
+ type: ToggleButtonKeyDownArrowDown,
1454
+ altKey: event.altKey
1455
+ });
1456
+ },
1457
+ ArrowUp: function ArrowUp(event) {
1458
+ event.preventDefault();
1459
+ dispatch({
1460
+ type: ToggleButtonKeyDownArrowUp,
1461
+ altKey: event.altKey
1462
+ });
1463
+ },
1464
+ Home: function Home(event) {
1465
+ event.preventDefault();
1466
+ dispatch({ type: ToggleButtonKeyDownHome });
1467
+ },
1468
+ End: function End(event) {
1469
+ event.preventDefault();
1470
+ dispatch({ type: ToggleButtonKeyDownEnd });
1471
+ },
1472
+ Escape: function Escape() {
1473
+ if (stateRef.current.isOpen) dispatch({ type: ToggleButtonKeyDownEscape });
1474
+ },
1475
+ Enter: function Enter(event) {
1476
+ event.preventDefault();
1477
+ dispatch({ type: stateRef.current.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1 });
1478
+ },
1479
+ PageUp: function PageUp(event) {
1480
+ if (stateRef.current.isOpen) {
1481
+ event.preventDefault();
1482
+ dispatch({ type: ToggleButtonKeyDownPageUp });
1483
+ }
1484
+ },
1485
+ PageDown: function PageDown(event) {
1486
+ if (stateRef.current.isOpen) {
1487
+ event.preventDefault();
1488
+ dispatch({ type: ToggleButtonKeyDownPageDown });
1489
+ }
1490
+ },
1491
+ " ": function _(event) {
1492
+ event.preventDefault();
1493
+ var currentState = stateRef.current;
1494
+ if (!currentState.isOpen) {
1495
+ dispatch({ type: ToggleButtonClick$1 });
1496
+ return;
1497
+ }
1498
+ if (currentState.inputValue) dispatch({
1499
+ type: ToggleButtonKeyDownCharacter,
1500
+ key: " "
1501
+ });
1502
+ else dispatch({ type: ToggleButtonKeyDownSpaceButton });
1503
+ }
1504
+ };
1505
+ }, [dispatch, stateRef]);
1506
+ var getLabelProps = useCallback(function(labelProps) {
1507
+ var _ref = labelProps != null ? labelProps : {}, onClick = _ref.onClick, rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
1508
+ return _extends({
1509
+ id: elementIds.labelId,
1510
+ htmlFor: elementIds.toggleButtonId,
1511
+ onClick: callAllEventHandlers(onClick, function labelHandleClick() {
1512
+ var _toggleButtonRef$curr;
1513
+ (_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
1514
+ })
1515
+ }, rest);
1516
+ }, [elementIds]);
1517
+ var getMenuProps = useCallback(function(menuProps, otherProps) {
1518
+ var _extends2;
1519
+ var _ref2 = menuProps != null ? menuProps : {}, onMouseLeave = _ref2.onMouseLeave, _ref2$refKey = _ref2.refKey, refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey, ref = _ref2.ref, ariaLabel = _ref2["aria-label"], rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$3);
1520
+ var _ref3$suppressRefErro = (otherProps != null ? otherProps : {}).suppressRefError, suppressRefError = _ref3$suppressRefErro === void 0 ? false : _ref3$suppressRefErro;
1521
+ var menuHandleMouseLeave = function menuHandleMouseLeave() {
1522
+ dispatch({ type: MenuMouseLeave$1 });
1523
+ };
1524
+ setGetterPropCallInfo("getMenuProps", suppressRefError, refKey, menuRef);
1525
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function(menuNode) {
1526
+ menuRef.current = menuNode;
1527
+ }), _extends2.id = elementIds.menuId, _extends2.role = "listbox", _extends2["aria-label"] = ariaLabel, _extends2["aria-labelledby"] = ariaLabel ? void 0 : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
1528
+ }, [
1529
+ dispatch,
1530
+ setGetterPropCallInfo,
1531
+ elementIds
1532
+ ]);
1533
+ var getToggleButtonProps = useCallback(function(toggleButtonProps, otherProps) {
1534
+ var _extends3;
1535
+ var _ref4 = toggleButtonProps != null ? toggleButtonProps : {}, onBlur = _ref4.onBlur, onClick = _ref4.onClick;
1536
+ _ref4.onPress;
1537
+ var onKeyDown = _ref4.onKeyDown, _ref4$refKey = _ref4.refKey, refKey = _ref4$refKey === void 0 ? "ref" : _ref4$refKey, ref = _ref4.ref, rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
1538
+ var _ref5$suppressRefErro = (otherProps != null ? otherProps : {}).suppressRefError, suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
1539
+ var toggleButtonHandleClick = function toggleButtonHandleClick() {
1540
+ dispatch({ type: ToggleButtonClick$1 });
1541
+ };
1542
+ var toggleButtonHandleBlur = function toggleButtonHandleBlur() {
1543
+ if (stateRef.current.isOpen && !mouseAndTouchTrackers.current.isMouseDown) dispatch({ type: ToggleButtonBlur });
1544
+ };
1545
+ var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
1546
+ var key = normalizeArrowKey(event);
1547
+ if (key && key in toggleButtonKeyDownHandlers) toggleButtonKeyDownHandlers[key](event);
1548
+ else if (/^\S{1}$/.test(key)) dispatch({
1549
+ type: ToggleButtonKeyDownCharacter,
1550
+ key
1551
+ });
1552
+ };
1553
+ var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(toggleButtonNode) {
1554
+ toggleButtonRef.current = toggleButtonNode;
1555
+ }), _extends3["aria-activedescendant"] = isOpen && highlightedIndex > -1 ? elementIds.getItemId(highlightedIndex) : "", _extends3["aria-controls"] = elementIds.menuId, _extends3["aria-expanded"] = isOpen, _extends3["aria-haspopup"] = "listbox", _extends3["aria-labelledby"] = rest["aria-label"] ? void 0 : "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = "combobox", _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
1556
+ if (!rest.disabled) Object.assign(toggleProps, {
1557
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick),
1558
+ onKeyDown: callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown)
1559
+ });
1560
+ setGetterPropCallInfo("getToggleButtonProps", suppressRefError, refKey, toggleButtonRef);
1561
+ return toggleProps;
1562
+ }, [
1563
+ dispatch,
1564
+ elementIds,
1565
+ isOpen,
1566
+ highlightedIndex,
1567
+ mouseAndTouchTrackers,
1568
+ setGetterPropCallInfo,
1569
+ toggleButtonKeyDownHandlers,
1570
+ stateRef
1571
+ ]);
1572
+ var getItemProps = useCallback(function(itemProps) {
1573
+ var _extends4;
1574
+ var _ref6 = itemProps != null ? itemProps : {}, itemProp = _ref6.item, indexProp = _ref6.index, onMouseMove = _ref6.onMouseMove, onClick = _ref6.onClick, onMouseDown = _ref6.onMouseDown;
1575
+ _ref6.onPress;
1576
+ var _ref6$refKey = _ref6.refKey, refKey = _ref6$refKey === void 0 ? "ref" : _ref6$refKey, disabledProp = _ref6.disabled, ref = _ref6.ref, rest = _objectWithoutPropertiesLoose(_ref6, _excluded4$1);
1577
+ if (disabledProp !== void 0) console.warn("Passing \"disabled\" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.");
1578
+ var _getItemAndIndex = getItemAndIndex(itemProp, indexProp, items, "Pass either item or index to getItemProps!"), item = _getItemAndIndex[0], index = _getItemAndIndex[1];
1579
+ var disabled = isItemDisabled(item, index);
1580
+ var itemHandleMouseMove = function itemHandleMouseMove() {
1581
+ if (mouseAndTouchTrackers.current.isTouchEnd || index === stateRef.current.highlightedIndex) return;
1582
+ preventScroll();
1583
+ dispatch({
1584
+ type: ItemMouseMove$1,
1585
+ index,
1586
+ disabled
1587
+ });
1588
+ };
1589
+ var itemHandleClick = function itemHandleClick() {
1590
+ dispatch({
1591
+ type: ItemClick$1,
1592
+ index
1593
+ });
1594
+ };
1595
+ var resultItemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(itemNode) {
1596
+ if (itemNode) itemsRef.current[elementIds.getItemId(index)] = itemNode;
1597
+ }), _extends4["aria-disabled"] = disabled, _extends4["aria-selected"] = item === selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = "option", _extends4.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove), _extends4.onMouseDown = callAllEventHandlers(onMouseDown, function itemHandleMouseDown(e) {
1598
+ return e.preventDefault();
1599
+ }), _extends4), rest);
1600
+ if (!disabled) Object.assign(resultItemProps, { onClick: callAllEventHandlers(onClick, itemHandleClick) });
1601
+ return resultItemProps;
1602
+ }, [
1603
+ items,
1604
+ isItemDisabled,
1605
+ selectedItem,
1606
+ elementIds,
1607
+ mouseAndTouchTrackers,
1608
+ preventScroll,
1609
+ dispatch,
1610
+ stateRef
1611
+ ]);
1612
+ var toggleMenu = useCallback(function() {
1613
+ dispatch({ type: FunctionToggleMenu$1 });
1614
+ }, [dispatch]);
1615
+ var closeMenu = useCallback(function() {
1616
+ dispatch({ type: FunctionCloseMenu$1 });
1617
+ }, [dispatch]);
1618
+ return {
1619
+ getToggleButtonProps,
1620
+ getLabelProps,
1621
+ getMenuProps,
1622
+ getItemProps,
1623
+ toggleMenu,
1624
+ openMenu: useCallback(function() {
1625
+ dispatch({ type: FunctionOpenMenu$1 });
1626
+ }, [dispatch]),
1627
+ closeMenu,
1628
+ setHighlightedIndex: useCallback(function(newHighlightedIndex) {
1629
+ dispatch({
1630
+ type: FunctionSetHighlightedIndex$1,
1631
+ highlightedIndex: newHighlightedIndex
1632
+ });
1633
+ }, [dispatch]),
1634
+ selectItem: useCallback(function(newSelectedItem) {
1635
+ dispatch({
1636
+ type: FunctionSelectItem$1,
1637
+ selectedItem: newSelectedItem
1638
+ });
1639
+ }, [dispatch]),
1640
+ reset: useCallback(function() {
1641
+ dispatch({ type: FunctionReset$2 });
1642
+ }, [dispatch]),
1643
+ setInputValue: useCallback(function(newInputValue) {
1644
+ dispatch({
1645
+ type: FunctionSetInputValue$1,
1646
+ inputValue: newInputValue
1647
+ });
1648
+ }, [dispatch]),
1649
+ highlightedIndex,
1650
+ isOpen,
1651
+ selectedItem,
1652
+ inputValue
1653
+ };
1654
+ }
1655
+ function getInitialState$2(props) {
1656
+ var initialState = getInitialState$3(props);
1657
+ var selectedItem = initialState.selectedItem;
1658
+ var inputValue = initialState.inputValue;
1659
+ if (inputValue === "" && selectedItem && props.defaultInputValue === void 0 && props.initialInputValue === void 0 && props.inputValue === void 0) inputValue = props.itemToString(selectedItem);
1660
+ return _extends({}, initialState, { inputValue });
1661
+ }
1662
+ /**
1663
+ * The useCombobox version of useControlledReducer, which also
1664
+ * checks if the controlled prop selectedItem changed between
1665
+ * renders. If so, it will also update inputValue with its
1666
+ * string equivalent. It uses the common useEnhancedReducer to
1667
+ * compute the rest of the state.
1668
+ *
1669
+ * @param reducer Reducer function from downshift.
1670
+ * @param props The hook props, also passed to createInitialState.
1671
+ * @param createInitialState Function that returns the initial state.
1672
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
1673
+ * @returns An array with the state and an action dispatcher.
1674
+ */
1675
+ function useControlledReducer(reducer, props, createInitialState, isStateEqual) {
1676
+ var previousSelectedItemRef = useRef(null);
1677
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual), state = _useEnhancedReducer[0], dispatch = _useEnhancedReducer[1];
1678
+ var isInitialMount = useIsInitialMount();
1679
+ useEffect(function() {
1680
+ if (props.selectedItem === void 0) return;
1681
+ if (!isInitialMount) {
1682
+ if (props.itemToKey(props.selectedItem) !== props.itemToKey(previousSelectedItemRef.current)) dispatch({
1683
+ type: ControlledPropUpdatedSelectedItem,
1684
+ inputValue: props.itemToString(props.selectedItem)
1685
+ });
1686
+ }
1687
+ previousSelectedItemRef.current = state.selectedItem === previousSelectedItemRef.current ? props.selectedItem : state.selectedItem;
1688
+ }, [state.selectedItem, props.selectedItem]);
1689
+ return [getState(state, props), dispatch];
1690
+ }
1691
+ function downshiftUseComboboxReducer(state, action) {
1692
+ var type = action.type, props = action.props;
1693
+ var changes;
1694
+ switch (type) {
1695
+ case ItemClick:
1696
+ changes = {
1697
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
1698
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
1699
+ selectedItem: props.items[action.index],
1700
+ inputValue: props.itemToString(props.items[action.index])
1701
+ };
1702
+ break;
1703
+ case InputKeyDownArrowDown:
1704
+ if (state.isOpen) changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled, true) };
1705
+ else changes = {
1706
+ highlightedIndex: action.altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 1),
1707
+ isOpen: props.items.length >= 0
1708
+ };
1709
+ break;
1710
+ case InputKeyDownArrowUp:
1711
+ if (state.isOpen) {
1712
+ if (action.altKey) changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, true);
1713
+ else changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled, true) };
1714
+ } else changes = {
1715
+ highlightedIndex: getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, -1),
1716
+ isOpen: props.items.length >= 0
1717
+ };
1718
+ break;
1719
+ case InputKeyDownEnter:
1720
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, true);
1721
+ break;
1722
+ case InputKeyDownEscape:
1723
+ changes = _extends({
1724
+ isOpen: false,
1725
+ highlightedIndex: -1
1726
+ }, !state.isOpen && {
1727
+ selectedItem: null,
1728
+ inputValue: ""
1729
+ });
1730
+ break;
1731
+ case InputKeyDownPageUp:
1732
+ changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled, true) };
1733
+ break;
1734
+ case InputKeyDownPageDown:
1735
+ changes = { highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled, true) };
1736
+ break;
1737
+ case InputKeyDownHome:
1738
+ changes = { highlightedIndex: getNonDisabledIndex(0, false, props.items, props.isItemDisabled) };
1739
+ break;
1740
+ case InputKeyDownEnd:
1741
+ changes = { highlightedIndex: getNonDisabledIndex(props.items.length - 1, true, props.items, props.isItemDisabled) };
1742
+ break;
1743
+ case InputBlur:
1744
+ changes = _extends({
1745
+ isOpen: false,
1746
+ highlightedIndex: -1
1747
+ }, state.highlightedIndex >= 0 && props.items.length && action.selectItem && {
1748
+ selectedItem: props.items[state.highlightedIndex],
1749
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
1750
+ });
1751
+ break;
1752
+ case InputChange:
1753
+ changes = {
1754
+ isOpen: true,
1755
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
1756
+ inputValue: action.inputValue
1757
+ };
1758
+ break;
1759
+ case InputClick:
1760
+ changes = {
1761
+ isOpen: !state.isOpen,
1762
+ highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
1763
+ };
1764
+ break;
1765
+ case FunctionSelectItem:
1766
+ changes = {
1767
+ selectedItem: action.selectedItem,
1768
+ inputValue: props.itemToString(action.selectedItem)
1769
+ };
1770
+ break;
1771
+ case ControlledPropUpdatedSelectedItem:
1772
+ changes = { inputValue: action.inputValue };
1773
+ break;
1774
+ default: return downshiftCommonReducer(state, props, action, stateChangeTypes$2);
1775
+ }
1776
+ return _extends({}, state, changes);
1777
+ }
1778
+ function useCombobox(userProps) {
1779
+ if (userProps === void 0) userProps = {};
1780
+ validatePropTypes$1(userProps, useCombobox, propTypes$2);
1781
+ var props = _extends({}, dropdownDefaultProps, userProps);
1782
+ var items = props.items, isItemDisabled = props.isItemDisabled, scrollIntoView = props.scrollIntoView, environment = props.environment, getA11yStatusMessage = props.getA11yStatusMessage;
1783
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$2, isDropdownStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1];
1784
+ var isOpen = state.isOpen, highlightedIndex = state.highlightedIndex, selectedItem = state.selectedItem, inputValue = state.inputValue;
1785
+ var menuRef = useRef(null);
1786
+ var itemsRef = useRef({});
1787
+ var inputRef = useRef(null);
1788
+ var toggleButtonRef = useRef(null);
1789
+ var isInitialMount = useIsInitialMount();
1790
+ var elementIds = useElementIds$1(props);
1791
+ var previousResultCountRef = useRef();
1792
+ /**
1793
+ * Ref to read `state` in handlers to preserve referential identity.
1794
+ * Only to be used in handlers and effects.
1795
+ * **never access this in getters**
1796
+ */
1797
+ var stateRef = useLatestRef(state);
1798
+ useA11yMessageStatus(getA11yStatusMessage, state, [
1799
+ isOpen,
1800
+ highlightedIndex,
1801
+ selectedItem,
1802
+ inputValue
1803
+ ], environment);
1804
+ var preventScroll = useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuRef, itemsRef, elementIds.getItemId);
1805
+ useControlPropsValidator({
1806
+ state,
1807
+ props
1808
+ });
1809
+ useEffect(function() {
1810
+ if (getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen) && inputRef.current) inputRef.current.focus();
1811
+ }, []);
1812
+ useEffect(function() {
1813
+ if (!isInitialMount) previousResultCountRef.current = items.length;
1814
+ });
1815
+ var mouseAndTouchTrackers = useMouseAndTouchTracker(environment, useCallback(function handleBlur() {
1816
+ if (stateRef.current.isOpen) dispatch({ type: InputBlur });
1817
+ }, [dispatch, stateRef]), useMemo(function() {
1818
+ return [
1819
+ menuRef,
1820
+ toggleButtonRef,
1821
+ inputRef
1822
+ ];
1823
+ }, []));
1824
+ var setGetterPropCallInfo = useGetterPropsCalledChecker("getInputProps", "getMenuProps");
1825
+ useEffect(function() {
1826
+ if (!isOpen) itemsRef.current = {};
1827
+ }, [isOpen]);
1828
+ useEffect(function() {
1829
+ var _inputRef$current;
1830
+ if (!isOpen || !(environment != null && environment.document) || !((_inputRef$current = inputRef.current) != null && _inputRef$current.focus)) return;
1831
+ if (environment.document.activeElement !== inputRef.current) inputRef.current.focus();
1832
+ }, [isOpen, environment]);
1833
+ var inputKeyDownHandlers = useMemo(function() {
1834
+ return {
1835
+ ArrowDown: function ArrowDown(event) {
1836
+ event.preventDefault();
1837
+ dispatch({
1838
+ type: InputKeyDownArrowDown,
1839
+ altKey: event.altKey
1840
+ });
1841
+ },
1842
+ ArrowUp: function ArrowUp(event) {
1843
+ event.preventDefault();
1844
+ dispatch({
1845
+ type: InputKeyDownArrowUp,
1846
+ altKey: event.altKey
1847
+ });
1848
+ },
1849
+ Home: function Home(event) {
1850
+ if (!stateRef.current.isOpen) return;
1851
+ event.preventDefault();
1852
+ dispatch({ type: InputKeyDownHome });
1853
+ },
1854
+ End: function End(event) {
1855
+ if (!stateRef.current.isOpen) return;
1856
+ event.preventDefault();
1857
+ dispatch({ type: InputKeyDownEnd });
1858
+ },
1859
+ Escape: function Escape(event) {
1860
+ var latestState = stateRef.current;
1861
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
1862
+ event.preventDefault();
1863
+ dispatch({ type: InputKeyDownEscape });
1864
+ }
1865
+ },
1866
+ Enter: function Enter(event) {
1867
+ if (!stateRef.current.isOpen || event.which === 229) return;
1868
+ event.preventDefault();
1869
+ dispatch({ type: InputKeyDownEnter });
1870
+ },
1871
+ PageUp: function PageUp(event) {
1872
+ if (stateRef.current.isOpen) {
1873
+ event.preventDefault();
1874
+ dispatch({ type: InputKeyDownPageUp });
1875
+ }
1876
+ },
1877
+ PageDown: function PageDown(event) {
1878
+ if (stateRef.current.isOpen) {
1879
+ event.preventDefault();
1880
+ dispatch({ type: InputKeyDownPageDown });
1881
+ }
1882
+ }
1883
+ };
1884
+ }, [dispatch, stateRef]);
1885
+ var getLabelProps = useCallback(function(labelProps) {
1886
+ return _extends({
1887
+ id: elementIds.labelId,
1888
+ htmlFor: elementIds.inputId
1889
+ }, labelProps);
1890
+ }, [elementIds]);
1891
+ var getMenuProps = useCallback(function(menuProps, otherProps) {
1892
+ var _extends2;
1893
+ var _ref = menuProps != null ? menuProps : {}, onMouseLeave = _ref.onMouseLeave, _ref$refKey = _ref.refKey, refKey = _ref$refKey === void 0 ? "ref" : _ref$refKey, ref = _ref.ref, ariaLabel = _ref["aria-label"], rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
1894
+ var _ref2$suppressRefErro = (otherProps != null ? otherProps : {}).suppressRefError;
1895
+ setGetterPropCallInfo("getMenuProps", _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro, refKey, menuRef);
1896
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function(menuNode) {
1897
+ menuRef.current = menuNode;
1898
+ }), _extends2.id = elementIds.menuId, _extends2.role = "listbox", _extends2["aria-label"] = ariaLabel, _extends2["aria-labelledby"] = ariaLabel ? void 0 : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function() {
1899
+ dispatch({ type: MenuMouseLeave });
1900
+ }), _extends2), rest);
1901
+ }, [
1902
+ dispatch,
1903
+ setGetterPropCallInfo,
1904
+ elementIds
1905
+ ]);
1906
+ var getItemProps = useCallback(function(itemProps) {
1907
+ var _extends3, _ref4;
1908
+ var _ref3 = itemProps != null ? itemProps : {}, itemProp = _ref3.item, indexProp = _ref3.index, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, ref = _ref3.ref, onMouseMove = _ref3.onMouseMove, onMouseDown = _ref3.onMouseDown, onClick = _ref3.onClick;
1909
+ _ref3.onPress;
1910
+ var disabledProp = _ref3.disabled, rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
1911
+ if (disabledProp !== void 0) console.warn("Passing \"disabled\" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.");
1912
+ var _getItemAndIndex = getItemAndIndex(itemProp, indexProp, items, "Pass either item or index to getItemProps!"), item = _getItemAndIndex[0], index = _getItemAndIndex[1];
1913
+ var disabled = isItemDisabled(item, index);
1914
+ var onSelectKey = "onClick";
1915
+ var customClickHandler = onClick;
1916
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(itemNode) {
1917
+ if (itemNode) itemsRef.current[elementIds.getItemId(index)] = itemNode;
1918
+ }), _extends3["aria-disabled"] = disabled, _extends3["aria-selected"] = index === highlightedIndex, _extends3.id = elementIds.getItemId(index), _extends3.role = "option", _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, function itemHandleClick() {
1919
+ dispatch({
1920
+ type: ItemClick,
1921
+ index
1922
+ });
1923
+ }), _ref4), {
1924
+ onMouseMove: callAllEventHandlers(onMouseMove, function itemHandleMouseMove() {
1925
+ if (mouseAndTouchTrackers.current.isTouchEnd || index === stateRef.current.highlightedIndex) return;
1926
+ preventScroll();
1927
+ dispatch({
1928
+ type: ItemMouseMove,
1929
+ index,
1930
+ disabled
1931
+ });
1932
+ }),
1933
+ onMouseDown: callAllEventHandlers(onMouseDown, function itemHandleMouseDown(e) {
1934
+ return e.preventDefault();
1935
+ })
1936
+ }, rest);
1937
+ }, [
1938
+ dispatch,
1939
+ elementIds,
1940
+ items,
1941
+ isItemDisabled,
1942
+ highlightedIndex,
1943
+ mouseAndTouchTrackers,
1944
+ preventScroll,
1945
+ stateRef
1946
+ ]);
1947
+ var getToggleButtonProps = useCallback(function(toggleButtonProps) {
1948
+ var _extends4;
1949
+ var _ref5 = toggleButtonProps != null ? toggleButtonProps : {}, onClick = _ref5.onClick;
1950
+ _ref5.onPress;
1951
+ var _ref5$refKey = _ref5.refKey, refKey = _ref5$refKey === void 0 ? "ref" : _ref5$refKey, ref = _ref5.ref, rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
1952
+ return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function(toggleButtonNode) {
1953
+ toggleButtonRef.current = toggleButtonNode;
1954
+ }), _extends4["aria-controls"] = elementIds.menuId, _extends4["aria-expanded"] = isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, { onClick: callAllEventHandlers(onClick, function toggleButtonHandleClick() {
1955
+ dispatch({ type: ToggleButtonClick });
1956
+ }) }), rest);
1957
+ }, [
1958
+ dispatch,
1959
+ isOpen,
1960
+ elementIds
1961
+ ]);
1962
+ var getInputProps = useCallback(function(inputProps, otherProps) {
1963
+ var _extends5;
1964
+ var _ref6 = inputProps != null ? inputProps : {}, ariaLabel = _ref6["aria-label"], onKeyDown = _ref6.onKeyDown, onChange = _ref6.onChange, onInput = _ref6.onInput, onBlur = _ref6.onBlur;
1965
+ _ref6.onChangeText;
1966
+ var onClick = _ref6.onClick, _ref6$refKey = _ref6.refKey, refKey = _ref6$refKey === void 0 ? "ref" : _ref6$refKey, ref = _ref6.ref, rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
1967
+ var _ref7$suppressRefErro = (otherProps != null ? otherProps : {}).suppressRefError;
1968
+ setGetterPropCallInfo("getInputProps", _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro, refKey, inputRef);
1969
+ var inputHandleKeyDown = function inputHandleKeyDown(event) {
1970
+ var key = normalizeArrowKey(event);
1971
+ if (key && key in inputKeyDownHandlers) inputKeyDownHandlers[key](event);
1972
+ };
1973
+ var inputHandleChange = function inputHandleChange(event) {
1974
+ dispatch({
1975
+ type: InputChange,
1976
+ inputValue: event.target.value
1977
+ });
1978
+ };
1979
+ var inputHandleBlur = function inputHandleBlur(event) {
1980
+ /* istanbul ignore else */
1981
+ if (environment != null && environment.document && stateRef.current.isOpen && !mouseAndTouchTrackers.current.isMouseDown) dispatch({
1982
+ type: InputBlur,
1983
+ selectItem: !(event.relatedTarget === null && environment.document.activeElement !== environment.document.body)
1984
+ });
1985
+ };
1986
+ var inputHandleClick = function inputHandleClick() {
1987
+ dispatch({ type: InputClick });
1988
+ };
1989
+ /* istanbul ignore next (preact) */
1990
+ var onChangeKey = "onChange";
1991
+ var eventHandlers = {};
1992
+ if (!rest.disabled) {
1993
+ var _eventHandlers;
1994
+ eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
1995
+ }
1996
+ return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function(inputNode) {
1997
+ inputRef.current = inputNode;
1998
+ }), _extends5["aria-activedescendant"] = isOpen && highlightedIndex > -1 ? elementIds.getItemId(highlightedIndex) : "", _extends5["aria-autocomplete"] = "list", _extends5["aria-controls"] = elementIds.menuId, _extends5["aria-expanded"] = isOpen, _extends5["aria-labelledby"] = ariaLabel ? void 0 : elementIds.labelId, _extends5["aria-label"] = ariaLabel, _extends5.autoComplete = "off", _extends5.id = elementIds.inputId, _extends5.role = "combobox", _extends5.value = inputValue, _extends5), eventHandlers, rest);
1999
+ }, [
2000
+ dispatch,
2001
+ elementIds,
2002
+ environment,
2003
+ inputKeyDownHandlers,
2004
+ isOpen,
2005
+ highlightedIndex,
2006
+ inputValue,
2007
+ mouseAndTouchTrackers,
2008
+ setGetterPropCallInfo,
2009
+ stateRef
2010
+ ]);
2011
+ var toggleMenu = useCallback(function() {
2012
+ dispatch({ type: FunctionToggleMenu });
2013
+ }, [dispatch]);
2014
+ var closeMenu = useCallback(function() {
2015
+ dispatch({ type: FunctionCloseMenu });
2016
+ }, [dispatch]);
2017
+ var openMenu = useCallback(function() {
2018
+ dispatch({ type: FunctionOpenMenu });
2019
+ }, [dispatch]);
2020
+ var setHighlightedIndex = useCallback(function(newHighlightedIndex) {
2021
+ dispatch({
2022
+ type: FunctionSetHighlightedIndex,
2023
+ highlightedIndex: newHighlightedIndex
2024
+ });
2025
+ }, [dispatch]);
2026
+ var selectItem = useCallback(function(newSelectedItem) {
2027
+ dispatch({
2028
+ type: FunctionSelectItem,
2029
+ selectedItem: newSelectedItem
2030
+ });
2031
+ }, [dispatch]);
2032
+ return {
2033
+ getItemProps,
2034
+ getLabelProps,
2035
+ getMenuProps,
2036
+ getInputProps,
2037
+ getToggleButtonProps,
2038
+ toggleMenu,
2039
+ openMenu,
2040
+ closeMenu,
2041
+ setHighlightedIndex,
2042
+ setInputValue: useCallback(function(newInputValue) {
2043
+ dispatch({
2044
+ type: FunctionSetInputValue,
2045
+ inputValue: newInputValue
2046
+ });
2047
+ }, [dispatch]),
2048
+ selectItem,
2049
+ reset: useCallback(function() {
2050
+ dispatch({ type: FunctionReset$1 });
2051
+ }, [dispatch]),
2052
+ highlightedIndex,
2053
+ isOpen,
2054
+ selectedItem,
2055
+ inputValue
2056
+ };
2057
+ }
2058
+ /**
2059
+ * Gets the initial state based on the provided props. It uses initial, default
2060
+ * and controlled props related to state in order to compute the initial value.
2061
+ *
2062
+ * @param {Object} props Props passed to the hook.
2063
+ * @returns {Object} The initial state.
2064
+ */
2065
+ function getInitialState$1(props) {
2066
+ return {
2067
+ activeIndex: getInitialValue(props.activeIndex, props.initialActiveIndex, props.defaultActiveIndex, defaultStateValues.activeIndex),
2068
+ selectedItems: getInitialValue(props.selectedItems, props.initialSelectedItems, props.defaultSelectedItems, defaultStateValues.selectedItems)
2069
+ };
2070
+ }
2071
+ /**
2072
+ * Returns true if dropdown keydown operation is permitted. Should not be
2073
+ * allowed on keydown with modifier keys (ctrl, alt, shift, meta), on
2074
+ * input element with text content that is either highlighted or selection
2075
+ * cursor is not at the starting position.
2076
+ *
2077
+ * @param {KeyboardEvent} event The event from keydown.
2078
+ * @returns {boolean} Whether the operation is allowed.
2079
+ */
2080
+ function isKeyDownOperationPermitted(event) {
2081
+ if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) return false;
2082
+ var element = event.target;
2083
+ if (element instanceof HTMLInputElement && element.value !== "" && (element.selectionStart !== 0 || element.selectionEnd !== 0)) return false;
2084
+ return true;
2085
+ }
2086
+ /**
2087
+ * Check if a state is equal for taglist, by comparing active index and selected items.
2088
+ * Used by useSelect and useCombobox.
2089
+ *
2090
+ * @param {Object} prevState
2091
+ * @param {Object} newState
2092
+ * @returns {boolean} Wheather the states are deeply equal.
2093
+ */
2094
+ function isStateEqual$1(prevState, newState) {
2095
+ return prevState.selectedItems === newState.selectedItems && prevState.activeIndex === newState.activeIndex;
2096
+ }
2097
+ function downshiftMultipleSelectionReducer(state, action) {
2098
+ var type = action.type, index = action.index, selectedItem = action.selectedItem, props = action.props;
2099
+ var activeIndex = state.activeIndex, selectedItems = state.selectedItems;
2100
+ var changes;
2101
+ switch (type) {
2102
+ case SelectedItemClick:
2103
+ changes = { activeIndex: index };
2104
+ break;
2105
+ case SelectedItemKeyDownNavigationPrevious:
2106
+ changes = { activeIndex: activeIndex - 1 < 0 ? 0 : activeIndex - 1 };
2107
+ break;
2108
+ case SelectedItemKeyDownNavigationNext:
2109
+ changes = { activeIndex: activeIndex + 1 >= selectedItems.length ? -1 : activeIndex + 1 };
2110
+ break;
2111
+ case SelectedItemKeyDownBackspace:
2112
+ case SelectedItemKeyDownDelete:
2113
+ if (activeIndex < 0) break;
2114
+ var newActiveIndex = activeIndex;
2115
+ if (selectedItems.length === 1) newActiveIndex = -1;
2116
+ else if (activeIndex === selectedItems.length - 1) newActiveIndex = selectedItems.length - 2;
2117
+ changes = _extends({ selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1)) }, { activeIndex: newActiveIndex });
2118
+ break;
2119
+ case DropdownKeyDownNavigationPrevious:
2120
+ changes = { activeIndex: selectedItems.length - 1 };
2121
+ break;
2122
+ case DropdownKeyDownBackspace:
2123
+ changes = { selectedItems: selectedItems.slice(0, selectedItems.length - 1) };
2124
+ break;
2125
+ case FunctionAddSelectedItem:
2126
+ changes = { selectedItems: [].concat(selectedItems, [selectedItem]) };
2127
+ break;
2128
+ case DropdownClick:
2129
+ changes = { activeIndex: -1 };
2130
+ break;
2131
+ case FunctionRemoveSelectedItem:
2132
+ var _newActiveIndex = activeIndex;
2133
+ var selectedItemIndex = selectedItems.findIndex(function(item) {
2134
+ return props.itemToKey(item) === props.itemToKey(selectedItem);
2135
+ });
2136
+ if (selectedItemIndex < 0) break;
2137
+ if (selectedItems.length === 1) _newActiveIndex = -1;
2138
+ else if (selectedItemIndex === selectedItems.length - 1) _newActiveIndex = selectedItems.length - 2;
2139
+ changes = {
2140
+ selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
2141
+ activeIndex: _newActiveIndex
2142
+ };
2143
+ break;
2144
+ case FunctionSetSelectedItems:
2145
+ changes = { selectedItems: action.selectedItems };
2146
+ break;
2147
+ case FunctionSetActiveIndex:
2148
+ changes = { activeIndex: action.activeIndex };
2149
+ break;
2150
+ case FunctionReset:
2151
+ changes = {
2152
+ activeIndex: getDefaultValue(props.defaultActiveIndex, defaultStateValues.activeIndex),
2153
+ selectedItems: getDefaultValue(props.defaultSelectedItems, defaultStateValues.selectedItems)
2154
+ };
2155
+ break;
2156
+ default: throw new Error("Reducer called without proper action type.");
2157
+ }
2158
+ return _extends({}, state, changes);
2159
+ }
2160
+ function useMultipleSelection(userProps) {
2161
+ if (userProps === void 0) userProps = {};
2162
+ validatePropTypes(userProps, useMultipleSelection);
2163
+ var props = _extends({}, defaultProps, userProps);
2164
+ var getA11yStatusMessage = props.getA11yStatusMessage, environment = props.environment, keyNavigationNext = props.keyNavigationNext, keyNavigationPrevious = props.keyNavigationPrevious;
2165
+ var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, props, getInitialState$1, isStateEqual$1), state = _useControlledReducer[0], dispatch = _useControlledReducer[1];
2166
+ var activeIndex = state.activeIndex, selectedItems = state.selectedItems;
2167
+ var isInitialMount = useIsInitialMount();
2168
+ var dropdownRef = useRef(null);
2169
+ var selectedItemRefs = useRef(null);
2170
+ if (selectedItemRefs.current === null) selectedItemRefs.current = /* @__PURE__ */ new Map();
2171
+ useA11yMessageStatus(getA11yStatusMessage, state, [activeIndex, selectedItems], environment);
2172
+ useEffect(function() {
2173
+ if (isInitialMount) return;
2174
+ if (activeIndex === -1 && dropdownRef.current) dropdownRef.current.focus();
2175
+ else {
2176
+ var _selectedItemRefs$cur;
2177
+ (_selectedItemRefs$cur = selectedItemRefs.current.get(activeIndex)) == null || _selectedItemRefs$cur.focus();
2178
+ }
2179
+ }, [activeIndex]);
2180
+ useControlPropsValidator({
2181
+ props,
2182
+ state
2183
+ });
2184
+ var setGetterPropCallInfo = useGetterPropsCalledChecker("getDropdownProps");
2185
+ var selectedItemKeyDownHandlers = useMemo(function() {
2186
+ var _ref = {};
2187
+ return _ref[keyNavigationPrevious] = function() {
2188
+ dispatch({ type: SelectedItemKeyDownNavigationPrevious });
2189
+ }, _ref[keyNavigationNext] = function() {
2190
+ dispatch({ type: SelectedItemKeyDownNavigationNext });
2191
+ }, _ref.Delete = function Delete() {
2192
+ dispatch({ type: SelectedItemKeyDownDelete });
2193
+ }, _ref.Backspace = function Backspace() {
2194
+ dispatch({ type: SelectedItemKeyDownBackspace });
2195
+ }, _ref;
2196
+ }, [
2197
+ dispatch,
2198
+ keyNavigationNext,
2199
+ keyNavigationPrevious
2200
+ ]);
2201
+ var dropdownKeyDownHandlers = useMemo(function() {
2202
+ var _ref2 = {};
2203
+ return _ref2[keyNavigationPrevious] = function(event) {
2204
+ if (isKeyDownOperationPermitted(event)) dispatch({ type: DropdownKeyDownNavigationPrevious });
2205
+ }, _ref2.Backspace = function Backspace(event) {
2206
+ if (isKeyDownOperationPermitted(event)) dispatch({ type: DropdownKeyDownBackspace });
2207
+ }, _ref2;
2208
+ }, [dispatch, keyNavigationPrevious]);
2209
+ return {
2210
+ getSelectedItemProps: useCallback(function(_temp) {
2211
+ var _extends2;
2212
+ var _ref3 = _temp === void 0 ? {} : _temp, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, ref = _ref3.ref, onClick = _ref3.onClick, onKeyDown = _ref3.onKeyDown, selectedItemProp = _ref3.selectedItem, indexProp = _ref3.index, rest = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
2213
+ var index = getItemAndIndex(selectedItemProp, indexProp, selectedItems, "Pass either item or index to getSelectedItemProps!")[1];
2214
+ var isFocusable = index > -1 && index === activeIndex;
2215
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function(selectedItemNode) {
2216
+ if (selectedItemNode) selectedItemRefs.current.set(index, selectedItemNode);
2217
+ else selectedItemRefs.current["delete"](index);
2218
+ }), _extends2.tabIndex = isFocusable ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, function selectedItemHandleClick() {
2219
+ dispatch({
2220
+ type: SelectedItemClick,
2221
+ index
2222
+ });
2223
+ }), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, function selectedItemHandleKeyDown(event) {
2224
+ var key = normalizeArrowKey(event);
2225
+ if (key && selectedItemKeyDownHandlers[key]) selectedItemKeyDownHandlers[key](event);
2226
+ }), _extends2), rest);
2227
+ }, [
2228
+ dispatch,
2229
+ selectedItems,
2230
+ activeIndex,
2231
+ selectedItemKeyDownHandlers
2232
+ ]),
2233
+ getDropdownProps: useCallback(function(_temp2, _temp3) {
2234
+ var _extends3;
2235
+ var _ref4 = _temp2 === void 0 ? {} : _temp2, _ref4$refKey = _ref4.refKey, refKey = _ref4$refKey === void 0 ? "ref" : _ref4$refKey, ref = _ref4.ref, onKeyDown = _ref4.onKeyDown, onClick = _ref4.onClick, _ref4$preventKeyActio = _ref4.preventKeyAction, preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio, rest = _objectWithoutPropertiesLoose(_ref4, _excluded2$1);
2236
+ var _ref5$suppressRefErro = (_temp3 === void 0 ? {} : _temp3).suppressRefError;
2237
+ setGetterPropCallInfo("getDropdownProps", _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro, refKey, dropdownRef);
2238
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function(dropdownNode) {
2239
+ if (dropdownNode) dropdownRef.current = dropdownNode;
2240
+ }), _extends3), !preventKeyAction && {
2241
+ onKeyDown: callAllEventHandlers(onKeyDown, function dropdownHandleKeyDown(event) {
2242
+ var key = normalizeArrowKey(event);
2243
+ if (key && dropdownKeyDownHandlers[key]) dropdownKeyDownHandlers[key](event);
2244
+ }),
2245
+ onClick: callAllEventHandlers(onClick, function dropdownHandleClick() {
2246
+ dispatch({ type: DropdownClick });
2247
+ })
2248
+ }, rest);
2249
+ }, [
2250
+ dispatch,
2251
+ dropdownKeyDownHandlers,
2252
+ setGetterPropCallInfo
2253
+ ]),
2254
+ addSelectedItem: useCallback(function(selectedItem) {
2255
+ dispatch({
2256
+ type: FunctionAddSelectedItem,
2257
+ selectedItem
2258
+ });
2259
+ }, [dispatch]),
2260
+ removeSelectedItem: useCallback(function(selectedItem) {
2261
+ dispatch({
2262
+ type: FunctionRemoveSelectedItem,
2263
+ selectedItem
2264
+ });
2265
+ }, [dispatch]),
2266
+ setSelectedItems: useCallback(function(newSelectedItems) {
2267
+ dispatch({
2268
+ type: FunctionSetSelectedItems,
2269
+ selectedItems: newSelectedItems
2270
+ });
2271
+ }, [dispatch]),
2272
+ setActiveIndex: useCallback(function(newActiveIndex) {
2273
+ dispatch({
2274
+ type: FunctionSetActiveIndex,
2275
+ activeIndex: newActiveIndex
2276
+ });
2277
+ }, [dispatch]),
2278
+ reset: useCallback(function() {
2279
+ dispatch({ type: FunctionReset });
2280
+ }, [dispatch]),
2281
+ selectedItems,
2282
+ activeIndex
2283
+ };
2284
+ }
2285
+ function useTagGroupReducer(state, action) {
2286
+ var type = action.type;
2287
+ var changes;
2288
+ switch (type) {
2289
+ case TagClick:
2290
+ changes = { activeIndex: action.index };
2291
+ break;
2292
+ case TagGroupKeyDownArrowLeft:
2293
+ changes = { activeIndex: state.activeIndex === 0 ? state.items.length - 1 : state.activeIndex - 1 };
2294
+ break;
2295
+ case TagGroupKeyDownArrowRight:
2296
+ changes = { activeIndex: state.activeIndex === state.items.length - 1 ? 0 : state.activeIndex + 1 };
2297
+ break;
2298
+ case TagGroupKeyDownBackspace:
2299
+ case TagGroupKeyDownDelete:
2300
+ var newItems = [].concat(state.items.slice(0, state.activeIndex), state.items.slice(state.activeIndex + 1));
2301
+ var newActiveIndex = newItems.length === 0 ? -1 : newItems.length === state.activeIndex ? state.activeIndex - 1 : state.activeIndex;
2302
+ changes = {
2303
+ items: [].concat(state.items.slice(0, state.activeIndex), state.items.slice(state.activeIndex + 1)),
2304
+ activeIndex: newActiveIndex
2305
+ };
2306
+ break;
2307
+ case TagRemoveClick:
2308
+ var _newItems = [].concat(state.items.slice(0, action.index), state.items.slice(action.index + 1));
2309
+ changes = {
2310
+ items: _newItems,
2311
+ activeIndex: _newItems.length === 0 ? -1 : _newItems.length === action.index ? action.index - 1 : action.index
2312
+ };
2313
+ break;
2314
+ case FunctionAddItem:
2315
+ var _newItems2 = [];
2316
+ if (action.index === void 0) _newItems2 = [].concat(state.items, [action.item]);
2317
+ else _newItems2 = [].concat(state.items.slice(0, action.index), [action.item], state.items.slice(action.index));
2318
+ var _newActiveIndex2 = state.activeIndex === -1 ? _newItems2.length - 1 : state.activeIndex;
2319
+ changes = {
2320
+ items: _newItems2,
2321
+ activeIndex: _newActiveIndex2
2322
+ };
2323
+ break;
2324
+ default: throw new Error("Invalid useTagGroup reducer action.");
2325
+ }
2326
+ return _extends({}, state, changes);
2327
+ }
2328
+ function useElementIdsR18(_ref) {
2329
+ var id = _ref.id, tagGroupId = _ref.tagGroupId, getTagId = _ref.getTagId;
2330
+ var reactId = "downshift-" + reactUseId();
2331
+ if (!id) id = reactId;
2332
+ return useMemo(function() {
2333
+ return {
2334
+ tagGroupId: tagGroupId != null ? tagGroupId : id + "-tag-group",
2335
+ getTagId: getTagId != null ? getTagId : function(index) {
2336
+ return id + "-tag-" + index;
2337
+ }
2338
+ };
2339
+ }, [
2340
+ getTagId,
2341
+ id,
2342
+ tagGroupId
2343
+ ]);
2344
+ }
2345
+ function useElementIdsLegacy(_ref2) {
2346
+ var id = _ref2.id, getTagId = _ref2.getTagId, tagGroupId = _ref2.tagGroupId;
2347
+ var baseId = useState(function() {
2348
+ return id != null ? id : "downshift-" + generateId();
2349
+ })[0];
2350
+ return useMemo(function() {
2351
+ return {
2352
+ tagGroupId: tagGroupId != null ? tagGroupId : baseId + "-tag-group",
2353
+ getTagId: getTagId != null ? getTagId : function(index) {
2354
+ return baseId + "-tag-" + index;
2355
+ }
2356
+ };
2357
+ }, [
2358
+ getTagId,
2359
+ baseId,
2360
+ tagGroupId
2361
+ ]);
2362
+ }
2363
+ function getInitialState(props) {
2364
+ var _ref, _props$items, _ref2, _props$activeIndex;
2365
+ var items = (_ref = (_props$items = props.items) != null ? _props$items : props.initialItems) != null ? _ref : [];
2366
+ return {
2367
+ activeIndex: (_ref2 = (_props$activeIndex = props.activeIndex) != null ? _props$activeIndex : props.initialActiveIndex) != null ? _ref2 : items.length === 0 ? -1 : 0,
2368
+ items
2369
+ };
2370
+ }
2371
+ function isStateEqual(oldState, newState) {
2372
+ return oldState.activeIndex === newState.activeIndex && oldState.items === newState.items;
2373
+ }
2374
+ function useAccessibleDescription(document, description) {
2375
+ useEffect(function() {
2376
+ if (!document) return;
2377
+ var accessibleDescriptionElement = document.createElement("div");
2378
+ accessibleDescriptionElement.setAttribute("id", A11Y_DESCRIPTION_ELEMENT_ID);
2379
+ accessibleDescriptionElement.style.display = "none";
2380
+ accessibleDescriptionElement.textContent = description;
2381
+ document.body.appendChild(accessibleDescriptionElement);
2382
+ return function() {
2383
+ accessibleDescriptionElement.remove();
2384
+ };
2385
+ }, [description, document]);
2386
+ }
2387
+ function getMergedProps(userProps) {
2388
+ return _extends({
2389
+ stateReducer: function stateReducer(_s, _ref) {
2390
+ return _ref.changes;
2391
+ },
2392
+ environment: typeof window === "undefined" || false ? void 0 : window,
2393
+ removeElementDescription: "Press Delete or Backspace to remove tag."
2394
+ }, userProps);
2395
+ }
2396
+ /**
2397
+ * Focuses the tag at activeIndex when it changes or when an item is removed.
2398
+ */
2399
+ function useRovingTagFocus(activeIndex, itemsLength, getTagId) {
2400
+ var itemRefs = useRef({});
2401
+ var previousActiveIndexRef = useRef(activeIndex);
2402
+ var previousItemsLengthRef = useRef(itemsLength);
2403
+ useEffect(function() {
2404
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === itemsLength + 1) {
2405
+ var _itemRefs$current$get;
2406
+ (_itemRefs$current$get = itemRefs.current[getTagId(activeIndex)]) == null || _itemRefs$current$get.focus();
2407
+ }
2408
+ previousActiveIndexRef.current = activeIndex;
2409
+ previousItemsLengthRef.current = itemsLength;
2410
+ }, [
2411
+ activeIndex,
2412
+ getTagId,
2413
+ itemsLength
2414
+ ]);
2415
+ return itemRefs;
2416
+ }
2417
+ var import_prop_types, unknown, mouseUp, itemMouseEnter, keyDownArrowUp, keyDownArrowDown, keyDownEscape, keyDownEnter, keyDownHome, keyDownEnd, clickItem, blurInput, changeInput, keyDownSpaceButton, clickButton, blurButton, controlledPropUpdatedSelectedItem, touchEnd, stateChangeTypes$4, idCounter, useIsomorphicLayoutEffect, cleanupStatus, validatePropTypes$1, stateKeys, _excluded$4, _excluded2$4, _excluded3$3, _excluded4$2, _excluded5, Downshift, propTypes$4, updateA11yStatus, dropdownPropTypes, dropdownDefaultProps, dropdownDefaultStateValues, reactUseId$1, useElementIds$1, useControlPropsValidator, useGetterPropsCalledChecker, propTypes$3, ToggleButtonClick$1, ToggleButtonKeyDownArrowDown, ToggleButtonKeyDownArrowUp, ToggleButtonKeyDownCharacter, ToggleButtonKeyDownEscape, ToggleButtonKeyDownHome, ToggleButtonKeyDownEnd, ToggleButtonKeyDownEnter, ToggleButtonKeyDownSpaceButton, ToggleButtonKeyDownPageUp, ToggleButtonKeyDownPageDown, ToggleButtonBlur, MenuMouseLeave$1, ItemMouseMove$1, ItemClick$1, FunctionToggleMenu$1, FunctionOpenMenu$1, FunctionCloseMenu$1, FunctionSetHighlightedIndex$1, FunctionSelectItem$1, FunctionSetInputValue$1, FunctionReset$2, stateChangeTypes$3, _excluded$3, _excluded2$3, _excluded3$2, _excluded4$1, InputKeyDownArrowDown, InputKeyDownArrowUp, InputKeyDownEscape, InputKeyDownHome, InputKeyDownEnd, InputKeyDownPageUp, InputKeyDownPageDown, InputKeyDownEnter, InputChange, InputBlur, InputClick, MenuMouseLeave, ItemMouseMove, ItemClick, ToggleButtonClick, FunctionToggleMenu, FunctionOpenMenu, FunctionCloseMenu, FunctionSetHighlightedIndex, FunctionSelectItem, FunctionSetInputValue, FunctionReset$1, ControlledPropUpdatedSelectedItem, stateChangeTypes$2, propTypes$2, _excluded$2, _excluded2$2, _excluded3$1, _excluded4, defaultStateValues, defaultProps, validatePropTypes, SelectedItemClick, SelectedItemKeyDownDelete, SelectedItemKeyDownBackspace, SelectedItemKeyDownNavigationNext, SelectedItemKeyDownNavigationPrevious, DropdownKeyDownNavigationPrevious, DropdownKeyDownBackspace, DropdownClick, FunctionAddSelectedItem, FunctionRemoveSelectedItem, FunctionSetSelectedItems, FunctionSetActiveIndex, FunctionReset, stateChangeTypes$1, _excluded$1, _excluded2$1, TagClick, TagGroupKeyDownArrowLeft, TagGroupKeyDownArrowRight, TagGroupKeyDownDelete, TagGroupKeyDownBackspace, TagRemoveClick, FunctionAddItem, stateChangeTypes, reactUseId, useElementIds, A11Y_DESCRIPTION_ELEMENT_ID, propTypes, _excluded, _excluded2, _excluded3, _useTagGroup;
2418
+ function init_downshift_esm() {
2419
+ return (init_downshift_esm = __esmMin((() => {
2420
+ init_inheritsLoose();
2421
+ import_prop_types = /* @__PURE__ */ __toESM(require_prop_types(), 1);
2422
+ init__storybook_global_react();
2423
+ require_react_is();
2424
+ init_dist();
2425
+ unknown = 0;
2426
+ mouseUp = 1;
2427
+ itemMouseEnter = 2;
2428
+ keyDownArrowUp = 3;
2429
+ keyDownArrowDown = 4;
2430
+ keyDownEscape = 5;
2431
+ keyDownEnter = 6;
2432
+ keyDownHome = 7;
2433
+ keyDownEnd = 8;
2434
+ clickItem = 9;
2435
+ blurInput = 10;
2436
+ changeInput = 11;
2437
+ keyDownSpaceButton = 12;
2438
+ clickButton = 13;
2439
+ blurButton = 14;
2440
+ controlledPropUpdatedSelectedItem = 15;
2441
+ touchEnd = 16;
2442
+ stateChangeTypes$4 = /*#__PURE__*/ Object.freeze({
2443
+ __proto__: null,
2444
+ blurButton,
2445
+ blurInput,
2446
+ changeInput,
2447
+ clickButton,
2448
+ clickItem,
2449
+ controlledPropUpdatedSelectedItem,
2450
+ itemMouseEnter,
2451
+ keyDownArrowDown,
2452
+ keyDownArrowUp,
2453
+ keyDownEnd,
2454
+ keyDownEnter,
2455
+ keyDownEscape,
2456
+ keyDownHome,
2457
+ keyDownSpaceButton,
2458
+ mouseUp,
2459
+ touchEnd,
2460
+ unknown
2461
+ });
2462
+ idCounter = 0;
2463
+ useIsomorphicLayoutEffect = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined" || false ? useLayoutEffect : useEffect;
2464
+ cleanupStatus = debounce(function(document) {
2465
+ getStatusDiv(document).textContent = "";
2466
+ }, 500);
2467
+ validatePropTypes$1 = noop;
2468
+ stateKeys = [
2469
+ "highlightedIndex",
2470
+ "inputValue",
2471
+ "isOpen",
2472
+ "selectedItem",
2473
+ "type"
2474
+ ];
2475
+ _excluded$4 = ["refKey", "ref"];
2476
+ _excluded2$4 = [
2477
+ "onClick",
2478
+ "onPress",
2479
+ "onKeyDown",
2480
+ "onKeyUp",
2481
+ "onBlur"
2482
+ ];
2483
+ _excluded3$3 = [
2484
+ "onKeyDown",
2485
+ "onBlur",
2486
+ "onChange",
2487
+ "onInput",
2488
+ "onChangeText"
2489
+ ];
2490
+ _excluded4$2 = ["refKey", "ref"];
2491
+ _excluded5 = [
2492
+ "onMouseMove",
2493
+ "onMouseDown",
2494
+ "onClick",
2495
+ "onPress",
2496
+ "index",
2497
+ "item"
2498
+ ];
2499
+ Downshift = /*#__PURE__*/ function() {
2500
+ var Downshift = /*#__PURE__*/ function(_Component) {
2501
+ function Downshift(_props) {
2502
+ var _this = _Component.call(this, _props) || this;
2503
+ _this.id = _this.props.id || "downshift-" + generateId();
2504
+ _this.menuId = _this.props.menuId || _this.id + "-menu";
2505
+ _this.labelId = _this.props.labelId || _this.id + "-label";
2506
+ _this.inputId = _this.props.inputId || _this.id + "-input";
2507
+ _this.getItemId = _this.props.getItemId || function(index) {
2508
+ return _this.id + "-item-" + index;
2509
+ };
2510
+ _this.items = [];
2511
+ _this.itemCount = null;
2512
+ _this.previousResultCount = 0;
2513
+ _this.timeoutIds = [];
2514
+ /**
2515
+ * @param {Function} fn the function to call after the time
2516
+ * @param {Number} time the time to wait
2517
+ */
2518
+ _this.internalSetTimeout = function(fn, time) {
2519
+ var id = setTimeout(function() {
2520
+ _this.timeoutIds = _this.timeoutIds.filter(function(i) {
2521
+ return i !== id;
2522
+ });
2523
+ fn();
2524
+ }, time);
2525
+ _this.timeoutIds.push(id);
2526
+ };
2527
+ _this.setItemCount = function(count) {
2528
+ _this.itemCount = count;
2529
+ };
2530
+ _this.unsetItemCount = function() {
2531
+ _this.itemCount = null;
2532
+ };
2533
+ _this.isItemDisabled = function(_item, index) {
2534
+ var currentElementNode = _this.getItemNodeFromIndex(index);
2535
+ return currentElementNode && currentElementNode.hasAttribute("disabled");
2536
+ };
2537
+ _this.setHighlightedIndex = function(highlightedIndex, otherStateToSet) {
2538
+ if (highlightedIndex === void 0) highlightedIndex = _this.props.defaultHighlightedIndex;
2539
+ if (otherStateToSet === void 0) otherStateToSet = {};
2540
+ otherStateToSet = pickState(otherStateToSet);
2541
+ _this.internalSetState(_extends({ highlightedIndex }, otherStateToSet));
2542
+ };
2543
+ _this.clearSelection = function(cb) {
2544
+ _this.internalSetState({
2545
+ selectedItem: null,
2546
+ inputValue: "",
2547
+ highlightedIndex: _this.props.defaultHighlightedIndex,
2548
+ isOpen: _this.props.defaultIsOpen
2549
+ }, cb);
2550
+ };
2551
+ _this.selectItem = function(item, otherStateToSet, cb) {
2552
+ otherStateToSet = pickState(otherStateToSet);
2553
+ _this.internalSetState(_extends({
2554
+ isOpen: _this.props.defaultIsOpen,
2555
+ highlightedIndex: _this.props.defaultHighlightedIndex,
2556
+ selectedItem: item,
2557
+ inputValue: _this.props.itemToString(item)
2558
+ }, otherStateToSet), cb);
2559
+ };
2560
+ _this.selectItemAtIndex = function(itemIndex, otherStateToSet, cb) {
2561
+ var item = _this.items[itemIndex];
2562
+ if (item == null) return;
2563
+ _this.selectItem(item, otherStateToSet, cb);
2564
+ };
2565
+ _this.selectHighlightedItem = function(otherStateToSet, cb) {
2566
+ return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
2567
+ };
2568
+ _this.internalSetState = function(stateToSet, cb) {
2569
+ var isItemSelected, onChangeArg;
2570
+ var onStateChangeArg = {};
2571
+ var isStateToSetFunction = typeof stateToSet === "function";
2572
+ if (!isStateToSetFunction && stateToSet.hasOwnProperty("inputValue")) _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
2573
+ return _this.setState(function(state) {
2574
+ var _newStateToSet;
2575
+ state = _this.getState(state);
2576
+ var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
2577
+ newStateToSet = _this.props.stateReducer(state, newStateToSet);
2578
+ isItemSelected = newStateToSet.hasOwnProperty("selectedItem");
2579
+ var nextState = {};
2580
+ if (isItemSelected && newStateToSet.selectedItem !== state.selectedItem) onChangeArg = newStateToSet.selectedItem;
2581
+ (_newStateToSet = newStateToSet).type || (_newStateToSet.type = unknown);
2582
+ Object.keys(newStateToSet).forEach(function(key) {
2583
+ if (state[key] !== newStateToSet[key]) onStateChangeArg[key] = newStateToSet[key];
2584
+ if (key === "type") return;
2585
+ newStateToSet[key];
2586
+ if (_this.props[key] === void 0) nextState[key] = newStateToSet[key];
2587
+ });
2588
+ if (isStateToSetFunction && newStateToSet.hasOwnProperty("inputValue")) _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
2589
+ return nextState;
2590
+ }, function() {
2591
+ cbToCb(cb)();
2592
+ if (Object.keys(onStateChangeArg).length > 1) _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers());
2593
+ if (isItemSelected) _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers());
2594
+ if (onChangeArg !== void 0) _this.props.onChange(onChangeArg, _this.getStateAndHelpers());
2595
+ _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
2596
+ });
2597
+ };
2598
+ _this.rootRef = function(node) {
2599
+ return _this._rootNode = node;
2600
+ };
2601
+ _this.getRootProps = function(_temp, _temp2) {
2602
+ var _extends2;
2603
+ var _ref = _temp === void 0 ? {} : _temp, _ref$refKey = _ref.refKey, refKey = _ref$refKey === void 0 ? "ref" : _ref$refKey, ref = _ref.ref, rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
2604
+ var _ref2$suppressRefErro = (_temp2 === void 0 ? {} : _temp2).suppressRefError, suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
2605
+ _this.getRootProps.called = true;
2606
+ _this.getRootProps.refKey = refKey;
2607
+ _this.getRootProps.suppressRefError = suppressRefError;
2608
+ var isOpen = _this.getState().isOpen;
2609
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = "combobox", _extends2["aria-expanded"] = isOpen, _extends2["aria-haspopup"] = "listbox", _extends2["aria-owns"] = isOpen ? _this.menuId : void 0, _extends2["aria-labelledby"] = _this.labelId, _extends2), rest);
2610
+ };
2611
+ _this.keyDownHandlers = {
2612
+ ArrowDown: function ArrowDown(event) {
2613
+ var _this2 = this;
2614
+ event.preventDefault();
2615
+ if (this.getState().isOpen) {
2616
+ var amount = event.shiftKey ? 5 : 1;
2617
+ this.moveHighlightedIndex(amount, { type: keyDownArrowDown });
2618
+ } else this.internalSetState({
2619
+ isOpen: true,
2620
+ type: keyDownArrowDown
2621
+ }, function() {
2622
+ var itemCount = _this2.getItemCount();
2623
+ if (itemCount > 0) {
2624
+ var highlightedIndex = _this2.getState().highlightedIndex;
2625
+ var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, 1, { length: itemCount }, _this2.isItemDisabled, true);
2626
+ _this2.setHighlightedIndex(nextHighlightedIndex, { type: keyDownArrowDown });
2627
+ }
2628
+ });
2629
+ },
2630
+ ArrowUp: function ArrowUp(event) {
2631
+ var _this3 = this;
2632
+ event.preventDefault();
2633
+ if (this.getState().isOpen) {
2634
+ var amount = event.shiftKey ? -5 : -1;
2635
+ this.moveHighlightedIndex(amount, { type: keyDownArrowUp });
2636
+ } else this.internalSetState({
2637
+ isOpen: true,
2638
+ type: keyDownArrowUp
2639
+ }, function() {
2640
+ var itemCount = _this3.getItemCount();
2641
+ if (itemCount > 0) {
2642
+ var highlightedIndex = _this3.getState().highlightedIndex;
2643
+ var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, -1, { length: itemCount }, _this3.isItemDisabled, true);
2644
+ _this3.setHighlightedIndex(nextHighlightedIndex, { type: keyDownArrowUp });
2645
+ }
2646
+ });
2647
+ },
2648
+ Enter: function Enter(event) {
2649
+ if (event.which === 229) return;
2650
+ var _this$getState2 = this.getState(), isOpen = _this$getState2.isOpen, highlightedIndex = _this$getState2.highlightedIndex;
2651
+ if (isOpen && highlightedIndex != null) {
2652
+ event.preventDefault();
2653
+ var item = this.items[highlightedIndex];
2654
+ var itemNode = this.getItemNodeFromIndex(highlightedIndex);
2655
+ if (item == null || itemNode && itemNode.hasAttribute("disabled")) return;
2656
+ this.selectHighlightedItem({ type: keyDownEnter });
2657
+ }
2658
+ },
2659
+ Escape: function Escape(event) {
2660
+ event.preventDefault();
2661
+ this.reset(_extends({ type: keyDownEscape }, !this.state.isOpen && {
2662
+ selectedItem: null,
2663
+ inputValue: ""
2664
+ }));
2665
+ }
2666
+ };
2667
+ _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, { " ": function _(event) {
2668
+ event.preventDefault();
2669
+ this.toggleMenu({ type: keyDownSpaceButton });
2670
+ } });
2671
+ _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
2672
+ Home: function Home(event) {
2673
+ var isOpen = this.getState().isOpen;
2674
+ if (!isOpen) return;
2675
+ event.preventDefault();
2676
+ var itemCount = this.getItemCount();
2677
+ if (itemCount <= 0 || !isOpen) return;
2678
+ var newHighlightedIndex = getNonDisabledIndex(0, false, { length: itemCount }, this.isItemDisabled);
2679
+ this.setHighlightedIndex(newHighlightedIndex, { type: keyDownHome });
2680
+ },
2681
+ End: function End(event) {
2682
+ var isOpen = this.getState().isOpen;
2683
+ if (!isOpen) return;
2684
+ event.preventDefault();
2685
+ var itemCount = this.getItemCount();
2686
+ if (itemCount <= 0 || !isOpen) return;
2687
+ var newHighlightedIndex = getNonDisabledIndex(itemCount - 1, true, { length: itemCount }, this.isItemDisabled);
2688
+ this.setHighlightedIndex(newHighlightedIndex, { type: keyDownEnd });
2689
+ }
2690
+ });
2691
+ _this.getToggleButtonProps = function(_temp3) {
2692
+ var _ref3 = _temp3 === void 0 ? {} : _temp3, onClick = _ref3.onClick;
2693
+ _ref3.onPress;
2694
+ var onKeyDown = _ref3.onKeyDown, onKeyUp = _ref3.onKeyUp, onBlur = _ref3.onBlur, rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$4);
2695
+ var isOpen = _this.getState().isOpen;
2696
+ var enabledEventHandlers = {
2697
+ onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
2698
+ onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
2699
+ onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
2700
+ onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
2701
+ };
2702
+ var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
2703
+ return _extends({
2704
+ type: "button",
2705
+ role: "button",
2706
+ "aria-label": isOpen ? "close menu" : "open menu",
2707
+ "aria-haspopup": true,
2708
+ "data-toggle": true
2709
+ }, eventHandlers, rest);
2710
+ };
2711
+ _this.buttonHandleKeyUp = function(event) {
2712
+ event.preventDefault();
2713
+ };
2714
+ _this.buttonHandleKeyDown = function(event) {
2715
+ var key = normalizeArrowKey(event);
2716
+ if (_this.buttonKeyDownHandlers[key]) _this.buttonKeyDownHandlers[key].call(_this, event);
2717
+ };
2718
+ _this.buttonHandleClick = function(event) {
2719
+ event.preventDefault();
2720
+ /* istanbul ignore if (can't reasonably test this) */
2721
+ if (_this.props.environment) {
2722
+ var _this$props$environme = _this.props.environment.document, body = _this$props$environme.body, activeElement = _this$props$environme.activeElement;
2723
+ if (body && body === activeElement) event.target.focus();
2724
+ }
2725
+ _this.internalSetTimeout(function() {
2726
+ return _this.toggleMenu({ type: clickButton });
2727
+ });
2728
+ };
2729
+ _this.buttonHandleBlur = function(event) {
2730
+ var blurTarget = event.target;
2731
+ _this.internalSetTimeout(function() {
2732
+ if (_this.isMouseDown || !_this.props.environment) return;
2733
+ var activeElement = _this.props.environment.document.activeElement;
2734
+ if ((activeElement == null || activeElement.id !== _this.inputId) && activeElement !== blurTarget) _this.reset({ type: blurButton });
2735
+ });
2736
+ };
2737
+ _this.getLabelProps = function(props) {
2738
+ return _extends({
2739
+ htmlFor: _this.inputId,
2740
+ id: _this.labelId
2741
+ }, props);
2742
+ };
2743
+ _this.getInputProps = function(_temp4) {
2744
+ var _ref4 = _temp4 === void 0 ? {} : _temp4, onKeyDown = _ref4.onKeyDown, onBlur = _ref4.onBlur, onChange = _ref4.onChange, onInput = _ref4.onInput;
2745
+ _ref4.onChangeText;
2746
+ var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$3);
2747
+ var onChangeKey;
2748
+ var eventHandlers = {};
2749
+ onChangeKey = "onChange";
2750
+ var _this$getState6 = _this.getState(), inputValue = _this$getState6.inputValue, isOpen = _this$getState6.isOpen, highlightedIndex = _this$getState6.highlightedIndex;
2751
+ if (!rest.disabled) {
2752
+ var _eventHandlers;
2753
+ eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
2754
+ }
2755
+ return _extends({
2756
+ "aria-autocomplete": "list",
2757
+ "aria-activedescendant": isOpen && typeof highlightedIndex === "number" && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : void 0,
2758
+ "aria-controls": isOpen ? _this.menuId : void 0,
2759
+ "aria-labelledby": rest && rest["aria-label"] ? void 0 : _this.labelId,
2760
+ autoComplete: "off",
2761
+ value: inputValue,
2762
+ id: _this.inputId
2763
+ }, eventHandlers, rest);
2764
+ };
2765
+ _this.inputHandleKeyDown = function(event) {
2766
+ var key = normalizeArrowKey(event);
2767
+ if (key && _this.inputKeyDownHandlers[key]) _this.inputKeyDownHandlers[key].call(_this, event);
2768
+ };
2769
+ _this.inputHandleChange = function(event) {
2770
+ _this.internalSetState({
2771
+ type: changeInput,
2772
+ isOpen: true,
2773
+ inputValue: event.target.value,
2774
+ highlightedIndex: _this.props.defaultHighlightedIndex
2775
+ });
2776
+ };
2777
+ _this.inputHandleBlur = function() {
2778
+ _this.internalSetTimeout(function() {
2779
+ var _activeElement$datase;
2780
+ if (_this.isMouseDown || !_this.props.environment) return;
2781
+ var activeElement = _this.props.environment.document.activeElement;
2782
+ if (!((activeElement == null || (_activeElement$datase = activeElement.dataset) == null ? void 0 : _activeElement$datase.toggle) && _this._rootNode && _this._rootNode.contains(activeElement))) _this.reset({ type: blurInput });
2783
+ });
2784
+ };
2785
+ _this.menuRef = function(node) {
2786
+ _this._menuNode = node;
2787
+ };
2788
+ _this.getMenuProps = function(_temp5, _temp6) {
2789
+ var _extends3;
2790
+ var _ref5 = _temp5 === void 0 ? {} : _temp5, _ref5$refKey = _ref5.refKey, refKey = _ref5$refKey === void 0 ? "ref" : _ref5$refKey, ref = _ref5.ref, props = _objectWithoutPropertiesLoose(_ref5, _excluded4$2);
2791
+ var _ref6$suppressRefErro = (_temp6 === void 0 ? {} : _temp6).suppressRefError, suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
2792
+ _this.getMenuProps.called = true;
2793
+ _this.getMenuProps.refKey = refKey;
2794
+ _this.getMenuProps.suppressRefError = suppressRefError;
2795
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = "listbox", _extends3["aria-labelledby"] = props && props["aria-label"] ? void 0 : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
2796
+ };
2797
+ _this.getItemProps = function(_temp7) {
2798
+ var _enabledEventHandlers;
2799
+ var _ref7 = _temp7 === void 0 ? {} : _temp7, onMouseMove = _ref7.onMouseMove, onMouseDown = _ref7.onMouseDown, onClick = _ref7.onClick;
2800
+ _ref7.onPress;
2801
+ var index = _ref7.index, _ref7$item = _ref7.item, item = _ref7$item === void 0 ? /* istanbul ignore next */ void 0 : _ref7$item, rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
2802
+ if (index === void 0) {
2803
+ _this.items.push(item);
2804
+ index = _this.items.indexOf(item);
2805
+ } else _this.items[index] = item;
2806
+ var onSelectKey = "onClick";
2807
+ var customClickHandler = onClick;
2808
+ var enabledEventHandlers = (_enabledEventHandlers = {
2809
+ onMouseMove: callAllEventHandlers(onMouseMove, function() {
2810
+ if (index === _this.getState().highlightedIndex) return;
2811
+ _this.setHighlightedIndex(index, { type: itemMouseEnter });
2812
+ _this.avoidScrolling = true;
2813
+ _this.internalSetTimeout(function() {
2814
+ return _this.avoidScrolling = false;
2815
+ }, 250);
2816
+ }),
2817
+ onMouseDown: callAllEventHandlers(onMouseDown, function(event) {
2818
+ event.preventDefault();
2819
+ })
2820
+ }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function() {
2821
+ _this.selectItemAtIndex(index, { type: clickItem });
2822
+ }), _enabledEventHandlers);
2823
+ var eventHandlers = rest.disabled ? { onMouseDown: enabledEventHandlers.onMouseDown } : enabledEventHandlers;
2824
+ return _extends({
2825
+ id: _this.getItemId(index),
2826
+ role: "option",
2827
+ "aria-selected": _this.getState().highlightedIndex === index
2828
+ }, eventHandlers, rest);
2829
+ };
2830
+ _this.clearItems = function() {
2831
+ _this.items = [];
2832
+ };
2833
+ _this.reset = function(otherStateToSet, cb) {
2834
+ if (otherStateToSet === void 0) otherStateToSet = {};
2835
+ otherStateToSet = pickState(otherStateToSet);
2836
+ _this.internalSetState(function(_ref8) {
2837
+ var selectedItem = _ref8.selectedItem;
2838
+ return _extends({
2839
+ isOpen: _this.props.defaultIsOpen,
2840
+ highlightedIndex: _this.props.defaultHighlightedIndex,
2841
+ inputValue: _this.props.itemToString(selectedItem)
2842
+ }, otherStateToSet);
2843
+ }, cb);
2844
+ };
2845
+ _this.toggleMenu = function(otherStateToSet, cb) {
2846
+ if (otherStateToSet === void 0) otherStateToSet = {};
2847
+ otherStateToSet = pickState(otherStateToSet);
2848
+ _this.internalSetState(function(_ref9) {
2849
+ var isOpen = _ref9.isOpen;
2850
+ return _extends({ isOpen: !isOpen }, isOpen && { highlightedIndex: _this.props.defaultHighlightedIndex }, otherStateToSet);
2851
+ }, function() {
2852
+ var _this$getState7 = _this.getState(), isOpen = _this$getState7.isOpen, highlightedIndex = _this$getState7.highlightedIndex;
2853
+ if (isOpen) {
2854
+ if (_this.getItemCount() > 0 && typeof highlightedIndex === "number") _this.setHighlightedIndex(highlightedIndex, otherStateToSet);
2855
+ }
2856
+ cbToCb(cb)();
2857
+ });
2858
+ };
2859
+ _this.openMenu = function(cb) {
2860
+ _this.internalSetState({ isOpen: true }, cb);
2861
+ };
2862
+ _this.closeMenu = function(cb) {
2863
+ _this.internalSetState({ isOpen: false }, cb);
2864
+ };
2865
+ _this.updateStatus = debounce(function() {
2866
+ var _this$props;
2867
+ if (!((_this$props = _this.props) != null && (_this$props = _this$props.environment) != null && _this$props.document)) return;
2868
+ var state = _this.getState();
2869
+ var item = _this.items[state.highlightedIndex];
2870
+ var resultCount = _this.getItemCount();
2871
+ var status = _this.props.getA11yStatusMessage(_extends({
2872
+ itemToString: _this.props.itemToString,
2873
+ previousResultCount: _this.previousResultCount,
2874
+ resultCount,
2875
+ highlightedItem: item
2876
+ }, state));
2877
+ _this.previousResultCount = resultCount;
2878
+ setStatus(status, _this.props.environment.document);
2879
+ }, 200);
2880
+ var _this$props2 = _this.props, defaultHighlightedIndex = _this$props2.defaultHighlightedIndex, _this$props2$initialH = _this$props2.initialHighlightedIndex, _highlightedIndex = _this$props2$initialH === void 0 ? defaultHighlightedIndex : _this$props2$initialH, defaultIsOpen = _this$props2.defaultIsOpen, _this$props2$initialI = _this$props2.initialIsOpen, _isOpen = _this$props2$initialI === void 0 ? defaultIsOpen : _this$props2$initialI, _this$props2$initialI2 = _this$props2.initialInputValue, _inputValue = _this$props2$initialI2 === void 0 ? "" : _this$props2$initialI2, _this$props2$initialS = _this$props2.initialSelectedItem, _selectedItem = _this$props2$initialS === void 0 ? null : _this$props2$initialS;
2881
+ var _state = _this.getState({
2882
+ highlightedIndex: _highlightedIndex,
2883
+ isOpen: _isOpen,
2884
+ inputValue: _inputValue,
2885
+ selectedItem: _selectedItem
2886
+ });
2887
+ if (_state.selectedItem != null && _this.props.initialInputValue === void 0) _state.inputValue = _this.props.itemToString(_state.selectedItem);
2888
+ _this.state = _state;
2889
+ return _this;
2890
+ }
2891
+ _inheritsLoose(Downshift, _Component);
2892
+ var _proto = Downshift.prototype;
2893
+ /**
2894
+ * Clear all running timeouts
2895
+ */
2896
+ _proto.internalClearTimeouts = function internalClearTimeouts() {
2897
+ this.timeoutIds.forEach(function(id) {
2898
+ clearTimeout(id);
2899
+ });
2900
+ this.timeoutIds = [];
2901
+ };
2902
+ _proto.getState = function getState$1(stateToMerge) {
2903
+ if (stateToMerge === void 0) stateToMerge = this.state;
2904
+ return getState(stateToMerge, this.props);
2905
+ };
2906
+ _proto.getItemCount = function getItemCount() {
2907
+ var itemCount = this.items.length;
2908
+ if (this.itemCount != null) itemCount = this.itemCount;
2909
+ else if (this.props.itemCount !== void 0) itemCount = this.props.itemCount;
2910
+ return itemCount;
2911
+ };
2912
+ _proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
2913
+ return this.props.environment ? this.props.environment.document.getElementById(this.getItemId(index)) : null;
2914
+ };
2915
+ _proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
2916
+ var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
2917
+ this.props.scrollIntoView(node, this._menuNode);
2918
+ };
2919
+ _proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
2920
+ var itemCount = this.getItemCount();
2921
+ var highlightedIndex = this.getState().highlightedIndex;
2922
+ if (itemCount > 0) {
2923
+ var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, amount, { length: itemCount }, this.isItemDisabled, true);
2924
+ this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
2925
+ }
2926
+ };
2927
+ _proto.getStateAndHelpers = function getStateAndHelpers() {
2928
+ var _this$getState9 = this.getState(), highlightedIndex = _this$getState9.highlightedIndex, inputValue = _this$getState9.inputValue, selectedItem = _this$getState9.selectedItem, isOpen = _this$getState9.isOpen;
2929
+ var itemToString = this.props.itemToString;
2930
+ var id = this.id;
2931
+ var getRootProps = this.getRootProps, getToggleButtonProps = this.getToggleButtonProps, getLabelProps = this.getLabelProps, getMenuProps = this.getMenuProps, getInputProps = this.getInputProps, getItemProps = this.getItemProps, openMenu = this.openMenu, closeMenu = this.closeMenu, toggleMenu = this.toggleMenu, selectItem = this.selectItem, selectItemAtIndex = this.selectItemAtIndex, selectHighlightedItem = this.selectHighlightedItem, setHighlightedIndex = this.setHighlightedIndex, clearSelection = this.clearSelection, clearItems = this.clearItems;
2932
+ return {
2933
+ getRootProps,
2934
+ getToggleButtonProps,
2935
+ getLabelProps,
2936
+ getMenuProps,
2937
+ getInputProps,
2938
+ getItemProps,
2939
+ reset: this.reset,
2940
+ openMenu,
2941
+ closeMenu,
2942
+ toggleMenu,
2943
+ selectItem,
2944
+ selectItemAtIndex,
2945
+ selectHighlightedItem,
2946
+ setHighlightedIndex,
2947
+ clearSelection,
2948
+ clearItems,
2949
+ setItemCount: this.setItemCount,
2950
+ unsetItemCount: this.unsetItemCount,
2951
+ setState: this.internalSetState,
2952
+ itemToString,
2953
+ id,
2954
+ highlightedIndex,
2955
+ inputValue,
2956
+ isOpen,
2957
+ selectedItem
2958
+ };
2959
+ };
2960
+ _proto.componentDidMount = function componentDidMount() {
2961
+ var _this4 = this;
2962
+ /* istanbul ignore if (react-native or SSR) */
2963
+ if (!this.props.environment) this.cleanup = function() {
2964
+ _this4.internalClearTimeouts();
2965
+ };
2966
+ else {
2967
+ var onMouseDown = function onMouseDown() {
2968
+ _this4.isMouseDown = true;
2969
+ };
2970
+ var onMouseUp = function onMouseUp(event) {
2971
+ _this4.isMouseDown = false;
2972
+ if (!targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment) && _this4.getState().isOpen) _this4.reset({ type: mouseUp }, function() {
2973
+ return _this4.props.onOuterClick(_this4.getStateAndHelpers());
2974
+ });
2975
+ };
2976
+ var onTouchStart = function onTouchStart() {
2977
+ _this4.isTouchMove = false;
2978
+ };
2979
+ var onTouchMove = function onTouchMove() {
2980
+ _this4.isTouchMove = true;
2981
+ };
2982
+ var onTouchEnd = function onTouchEnd(event) {
2983
+ var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment, false);
2984
+ if (!_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen) _this4.reset({ type: touchEnd }, function() {
2985
+ return _this4.props.onOuterClick(_this4.getStateAndHelpers());
2986
+ });
2987
+ };
2988
+ var environment = this.props.environment;
2989
+ environment.addEventListener("mousedown", onMouseDown);
2990
+ environment.addEventListener("mouseup", onMouseUp);
2991
+ environment.addEventListener("touchstart", onTouchStart);
2992
+ environment.addEventListener("touchmove", onTouchMove);
2993
+ environment.addEventListener("touchend", onTouchEnd);
2994
+ this.cleanup = function() {
2995
+ _this4.internalClearTimeouts();
2996
+ _this4.updateStatus.cancel();
2997
+ environment.removeEventListener("mousedown", onMouseDown);
2998
+ environment.removeEventListener("mouseup", onMouseUp);
2999
+ environment.removeEventListener("touchstart", onTouchStart);
3000
+ environment.removeEventListener("touchmove", onTouchMove);
3001
+ environment.removeEventListener("touchend", onTouchEnd);
3002
+ };
3003
+ }
3004
+ };
3005
+ _proto.shouldScroll = function shouldScroll(prevState, prevProps) {
3006
+ var currentHighlightedIndex = (this.props.highlightedIndex === void 0 ? this.getState() : this.props).highlightedIndex;
3007
+ var prevHighlightedIndex = (prevProps.highlightedIndex === void 0 ? prevState : prevProps).highlightedIndex;
3008
+ return currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen || currentHighlightedIndex !== prevHighlightedIndex;
3009
+ };
3010
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
3011
+ if (this.props.selectedItem !== void 0 && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem)) this.internalSetState({
3012
+ type: controlledPropUpdatedSelectedItem,
3013
+ inputValue: this.props.itemToString(this.props.selectedItem)
3014
+ });
3015
+ if (!this.avoidScrolling && this.shouldScroll(prevState, prevProps)) this.scrollHighlightedItemIntoView();
3016
+ this.updateStatus();
3017
+ };
3018
+ _proto.componentWillUnmount = function componentWillUnmount() {
3019
+ this.cleanup();
3020
+ };
3021
+ _proto.render = function render() {
3022
+ var children = unwrapArray(this.props.children, noop);
3023
+ this.clearItems();
3024
+ this.getRootProps.called = false;
3025
+ this.getRootProps.refKey = void 0;
3026
+ this.getRootProps.suppressRefError = void 0;
3027
+ this.getMenuProps.called = false;
3028
+ this.getMenuProps.refKey = void 0;
3029
+ this.getMenuProps.suppressRefError = void 0;
3030
+ this.getLabelProps.called = false;
3031
+ this.getInputProps.called = false;
3032
+ var element = unwrapArray(children(this.getStateAndHelpers()));
3033
+ if (!element) return null;
3034
+ if (this.getRootProps.called || this.props.suppressRefError) return element;
3035
+ else if (isDOMElement(element)) return /*#__PURE__*/ cloneElement(element, this.getRootProps(getElementProps(element)));
3036
+ };
3037
+ return Downshift;
3038
+ }(Component);
3039
+ Downshift.defaultProps = {
3040
+ defaultHighlightedIndex: null,
3041
+ defaultIsOpen: false,
3042
+ getA11yStatusMessage,
3043
+ itemToString: function itemToString(i) {
3044
+ if (i == null) return "";
3045
+ return String(i);
3046
+ },
3047
+ onStateChange: noop,
3048
+ onInputValueChange: noop,
3049
+ onUserAction: noop,
3050
+ onChange: noop,
3051
+ onSelect: noop,
3052
+ onOuterClick: noop,
3053
+ selectedItemChanged: function selectedItemChanged(prevItem, item) {
3054
+ return prevItem !== item;
3055
+ },
3056
+ environment: typeof window === "undefined" || false ? void 0 : window,
3057
+ stateReducer: function stateReducer(state, stateToSet) {
3058
+ return stateToSet;
3059
+ },
3060
+ suppressRefError: false,
3061
+ scrollIntoView
3062
+ };
3063
+ Downshift.stateChangeTypes = stateChangeTypes$4;
3064
+ return Downshift;
3065
+ }();
3066
+ propTypes$4 = {
3067
+ environment: import_prop_types.default.shape({
3068
+ addEventListener: import_prop_types.default.func.isRequired,
3069
+ removeEventListener: import_prop_types.default.func.isRequired,
3070
+ document: import_prop_types.default.shape({
3071
+ createElement: import_prop_types.default.func.isRequired,
3072
+ getElementById: import_prop_types.default.func.isRequired,
3073
+ activeElement: import_prop_types.default.any.isRequired,
3074
+ body: import_prop_types.default.any.isRequired
3075
+ }).isRequired,
3076
+ Node: import_prop_types.default.func.isRequired
3077
+ }),
3078
+ itemToKey: import_prop_types.default.func,
3079
+ stateReducer: import_prop_types.default.func
3080
+ };
3081
+ updateA11yStatus = debounce(function(status, document) {
3082
+ setStatus(status, document);
3083
+ }, 200);
3084
+ dropdownPropTypes = _extends({}, propTypes$4, {
3085
+ getA11yStatusMessage: import_prop_types.default.func,
3086
+ highlightedIndex: import_prop_types.default.number,
3087
+ defaultHighlightedIndex: import_prop_types.default.number,
3088
+ initialHighlightedIndex: import_prop_types.default.number,
3089
+ isOpen: import_prop_types.default.bool,
3090
+ defaultIsOpen: import_prop_types.default.bool,
3091
+ initialIsOpen: import_prop_types.default.bool,
3092
+ selectedItem: import_prop_types.default.any,
3093
+ initialSelectedItem: import_prop_types.default.any,
3094
+ defaultSelectedItem: import_prop_types.default.any,
3095
+ id: import_prop_types.default.string,
3096
+ labelId: import_prop_types.default.string,
3097
+ menuId: import_prop_types.default.string,
3098
+ getItemId: import_prop_types.default.func,
3099
+ toggleButtonId: import_prop_types.default.string,
3100
+ onSelectedItemChange: import_prop_types.default.func,
3101
+ onHighlightedIndexChange: import_prop_types.default.func,
3102
+ onStateChange: import_prop_types.default.func,
3103
+ onIsOpenChange: import_prop_types.default.func,
3104
+ scrollIntoView: import_prop_types.default.func
3105
+ });
3106
+ dropdownDefaultProps = {
3107
+ itemToString: function itemToString(item) {
3108
+ return item ? String(item) : "";
3109
+ },
3110
+ itemToKey: function itemToKey(item) {
3111
+ return item;
3112
+ },
3113
+ isItemDisabled: function isItemDisabled(_item) {
3114
+ return false;
3115
+ },
3116
+ stateReducer: function stateReducer(_state, actionAndChanges) {
3117
+ return actionAndChanges.changes;
3118
+ },
3119
+ scrollIntoView,
3120
+ environment: typeof window === "undefined" || false ? void 0 : window
3121
+ };
3122
+ dropdownDefaultStateValues = {
3123
+ highlightedIndex: -1,
3124
+ isOpen: false,
3125
+ selectedItem: null,
3126
+ inputValue: ""
3127
+ };
3128
+ reactUseId$1 = _extends({}, _storybook_global_react_exports).useId;
3129
+ useElementIds$1 = typeof reactUseId$1 === "function" ? useElementIdsR18$1 : useElementIdsLegacy$1;
3130
+ useControlPropsValidator = noop;
3131
+ useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
3132
+ return noop;
3133
+ };
3134
+ propTypes$3 = _extends({}, dropdownPropTypes, {
3135
+ items: import_prop_types.default.array.isRequired,
3136
+ isItemDisabled: import_prop_types.default.func
3137
+ });
3138
+ ToggleButtonClick$1 = 0;
3139
+ ToggleButtonKeyDownArrowDown = 1;
3140
+ ToggleButtonKeyDownArrowUp = 2;
3141
+ ToggleButtonKeyDownCharacter = 3;
3142
+ ToggleButtonKeyDownEscape = 4;
3143
+ ToggleButtonKeyDownHome = 5;
3144
+ ToggleButtonKeyDownEnd = 6;
3145
+ ToggleButtonKeyDownEnter = 7;
3146
+ ToggleButtonKeyDownSpaceButton = 8;
3147
+ ToggleButtonKeyDownPageUp = 9;
3148
+ ToggleButtonKeyDownPageDown = 10;
3149
+ ToggleButtonBlur = 11;
3150
+ MenuMouseLeave$1 = 12;
3151
+ ItemMouseMove$1 = 13;
3152
+ ItemClick$1 = 14;
3153
+ FunctionToggleMenu$1 = 15;
3154
+ FunctionOpenMenu$1 = 16;
3155
+ FunctionCloseMenu$1 = 17;
3156
+ FunctionSetHighlightedIndex$1 = 18;
3157
+ FunctionSelectItem$1 = 19;
3158
+ FunctionSetInputValue$1 = 20;
3159
+ FunctionReset$2 = 21;
3160
+ stateChangeTypes$3 = /*#__PURE__*/ Object.freeze({
3161
+ __proto__: null,
3162
+ FunctionCloseMenu: FunctionCloseMenu$1,
3163
+ FunctionOpenMenu: FunctionOpenMenu$1,
3164
+ FunctionReset: FunctionReset$2,
3165
+ FunctionSelectItem: FunctionSelectItem$1,
3166
+ FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
3167
+ FunctionSetInputValue: FunctionSetInputValue$1,
3168
+ FunctionToggleMenu: FunctionToggleMenu$1,
3169
+ ItemClick: ItemClick$1,
3170
+ ItemMouseMove: ItemMouseMove$1,
3171
+ MenuMouseLeave: MenuMouseLeave$1,
3172
+ ToggleButtonBlur,
3173
+ ToggleButtonClick: ToggleButtonClick$1,
3174
+ ToggleButtonKeyDownArrowDown,
3175
+ ToggleButtonKeyDownArrowUp,
3176
+ ToggleButtonKeyDownCharacter,
3177
+ ToggleButtonKeyDownEnd,
3178
+ ToggleButtonKeyDownEnter,
3179
+ ToggleButtonKeyDownEscape,
3180
+ ToggleButtonKeyDownHome,
3181
+ ToggleButtonKeyDownPageDown,
3182
+ ToggleButtonKeyDownPageUp,
3183
+ ToggleButtonKeyDownSpaceButton
3184
+ });
3185
+ _excluded$3 = ["onClick"];
3186
+ _excluded2$3 = [
3187
+ "onMouseLeave",
3188
+ "refKey",
3189
+ "ref",
3190
+ "aria-label"
3191
+ ];
3192
+ _excluded3$2 = [
3193
+ "onBlur",
3194
+ "onClick",
3195
+ "onPress",
3196
+ "onKeyDown",
3197
+ "refKey",
3198
+ "ref"
3199
+ ];
3200
+ _excluded4$1 = [
3201
+ "item",
3202
+ "index",
3203
+ "onMouseMove",
3204
+ "onClick",
3205
+ "onMouseDown",
3206
+ "onPress",
3207
+ "refKey",
3208
+ "disabled",
3209
+ "ref"
3210
+ ];
3211
+ useSelect.stateChangeTypes = stateChangeTypes$3;
3212
+ InputKeyDownArrowDown = 0;
3213
+ InputKeyDownArrowUp = 1;
3214
+ InputKeyDownEscape = 2;
3215
+ InputKeyDownHome = 3;
3216
+ InputKeyDownEnd = 4;
3217
+ InputKeyDownPageUp = 5;
3218
+ InputKeyDownPageDown = 6;
3219
+ InputKeyDownEnter = 7;
3220
+ InputChange = 8;
3221
+ InputBlur = 9;
3222
+ InputClick = 10;
3223
+ MenuMouseLeave = 11;
3224
+ ItemMouseMove = 12;
3225
+ ItemClick = 13;
3226
+ ToggleButtonClick = 14;
3227
+ FunctionToggleMenu = 15;
3228
+ FunctionOpenMenu = 16;
3229
+ FunctionCloseMenu = 17;
3230
+ FunctionSetHighlightedIndex = 18;
3231
+ FunctionSelectItem = 19;
3232
+ FunctionSetInputValue = 20;
3233
+ FunctionReset$1 = 21;
3234
+ ControlledPropUpdatedSelectedItem = 22;
3235
+ stateChangeTypes$2 = /*#__PURE__*/ Object.freeze({
3236
+ __proto__: null,
3237
+ ControlledPropUpdatedSelectedItem,
3238
+ FunctionCloseMenu,
3239
+ FunctionOpenMenu,
3240
+ FunctionReset: FunctionReset$1,
3241
+ FunctionSelectItem,
3242
+ FunctionSetHighlightedIndex,
3243
+ FunctionSetInputValue,
3244
+ FunctionToggleMenu,
3245
+ InputBlur,
3246
+ InputChange,
3247
+ InputClick,
3248
+ InputKeyDownArrowDown,
3249
+ InputKeyDownArrowUp,
3250
+ InputKeyDownEnd,
3251
+ InputKeyDownEnter,
3252
+ InputKeyDownEscape,
3253
+ InputKeyDownHome,
3254
+ InputKeyDownPageDown,
3255
+ InputKeyDownPageUp,
3256
+ ItemClick,
3257
+ ItemMouseMove,
3258
+ MenuMouseLeave,
3259
+ ToggleButtonClick
3260
+ });
3261
+ propTypes$2 = _extends({}, dropdownPropTypes, {
3262
+ items: import_prop_types.default.array.isRequired,
3263
+ isItemDisabled: import_prop_types.default.func,
3264
+ inputValue: import_prop_types.default.string,
3265
+ defaultInputValue: import_prop_types.default.string,
3266
+ initialInputValue: import_prop_types.default.string,
3267
+ inputId: import_prop_types.default.string,
3268
+ onInputValueChange: import_prop_types.default.func
3269
+ });
3270
+ _excluded$2 = [
3271
+ "onMouseLeave",
3272
+ "refKey",
3273
+ "ref",
3274
+ "aria-label"
3275
+ ];
3276
+ _excluded2$2 = [
3277
+ "item",
3278
+ "index",
3279
+ "refKey",
3280
+ "ref",
3281
+ "onMouseMove",
3282
+ "onMouseDown",
3283
+ "onClick",
3284
+ "onPress",
3285
+ "disabled"
3286
+ ];
3287
+ _excluded3$1 = [
3288
+ "onClick",
3289
+ "onPress",
3290
+ "refKey",
3291
+ "ref"
3292
+ ];
3293
+ _excluded4 = [
3294
+ "aria-label",
3295
+ "onKeyDown",
3296
+ "onChange",
3297
+ "onInput",
3298
+ "onBlur",
3299
+ "onChangeText",
3300
+ "onClick",
3301
+ "refKey",
3302
+ "ref"
3303
+ ];
3304
+ useCombobox.stateChangeTypes = stateChangeTypes$2;
3305
+ defaultStateValues = {
3306
+ activeIndex: -1,
3307
+ selectedItems: []
3308
+ };
3309
+ dropdownPropTypes.stateReducer, dropdownPropTypes.itemToKey, dropdownPropTypes.environment, import_prop_types.default.array, import_prop_types.default.array, import_prop_types.default.array, import_prop_types.default.func, import_prop_types.default.number, import_prop_types.default.number, import_prop_types.default.number, import_prop_types.default.func, import_prop_types.default.func, import_prop_types.default.string, import_prop_types.default.string;
3310
+ defaultProps = {
3311
+ itemToKey: dropdownDefaultProps.itemToKey,
3312
+ stateReducer: dropdownDefaultProps.stateReducer,
3313
+ environment: dropdownDefaultProps.environment,
3314
+ keyNavigationNext: "ArrowRight",
3315
+ keyNavigationPrevious: "ArrowLeft"
3316
+ };
3317
+ validatePropTypes = noop;
3318
+ SelectedItemClick = 0;
3319
+ SelectedItemKeyDownDelete = 1;
3320
+ SelectedItemKeyDownBackspace = 2;
3321
+ SelectedItemKeyDownNavigationNext = 3;
3322
+ SelectedItemKeyDownNavigationPrevious = 4;
3323
+ DropdownKeyDownNavigationPrevious = 5;
3324
+ DropdownKeyDownBackspace = 6;
3325
+ DropdownClick = 7;
3326
+ FunctionAddSelectedItem = 8;
3327
+ FunctionRemoveSelectedItem = 9;
3328
+ FunctionSetSelectedItems = 10;
3329
+ FunctionSetActiveIndex = 11;
3330
+ FunctionReset = 12;
3331
+ stateChangeTypes$1 = /*#__PURE__*/ Object.freeze({
3332
+ __proto__: null,
3333
+ DropdownClick,
3334
+ DropdownKeyDownBackspace,
3335
+ DropdownKeyDownNavigationPrevious,
3336
+ FunctionAddSelectedItem,
3337
+ FunctionRemoveSelectedItem,
3338
+ FunctionReset,
3339
+ FunctionSetActiveIndex,
3340
+ FunctionSetSelectedItems,
3341
+ SelectedItemClick,
3342
+ SelectedItemKeyDownBackspace,
3343
+ SelectedItemKeyDownDelete,
3344
+ SelectedItemKeyDownNavigationNext,
3345
+ SelectedItemKeyDownNavigationPrevious
3346
+ });
3347
+ _excluded$1 = [
3348
+ "refKey",
3349
+ "ref",
3350
+ "onClick",
3351
+ "onKeyDown",
3352
+ "selectedItem",
3353
+ "index"
3354
+ ];
3355
+ _excluded2$1 = [
3356
+ "refKey",
3357
+ "ref",
3358
+ "onKeyDown",
3359
+ "onClick",
3360
+ "preventKeyAction"
3361
+ ];
3362
+ useMultipleSelection.stateChangeTypes = stateChangeTypes$1;
3363
+ TagClick = 0;
3364
+ TagGroupKeyDownArrowLeft = 1;
3365
+ TagGroupKeyDownArrowRight = 2;
3366
+ TagGroupKeyDownDelete = 3;
3367
+ TagGroupKeyDownBackspace = 4;
3368
+ TagRemoveClick = 5;
3369
+ FunctionAddItem = 6;
3370
+ stateChangeTypes = /*#__PURE__*/ Object.freeze({
3371
+ __proto__: null,
3372
+ FunctionAddItem,
3373
+ TagClick,
3374
+ TagGroupKeyDownArrowLeft,
3375
+ TagGroupKeyDownArrowRight,
3376
+ TagGroupKeyDownBackspace,
3377
+ TagGroupKeyDownDelete,
3378
+ TagRemoveClick
3379
+ });
3380
+ reactUseId = _extends({}, _storybook_global_react_exports).useId;
3381
+ useElementIds = typeof reactUseId === "function" ? useElementIdsR18 : useElementIdsLegacy;
3382
+ A11Y_DESCRIPTION_ELEMENT_ID = "tag-group-a11y-description";
3383
+ propTypes = { isItemDisabled: import_prop_types.default.func };
3384
+ _excluded = ["onKeyDown"];
3385
+ _excluded2 = [
3386
+ "index",
3387
+ "refKey",
3388
+ "ref",
3389
+ "onClick"
3390
+ ];
3391
+ _excluded3 = ["index", "onClick"];
3392
+ _useTagGroup = function useTagGroup(userProps) {
3393
+ var _props$environment;
3394
+ if (userProps === void 0) userProps = {};
3395
+ validatePropTypes$1(userProps, _useTagGroup, propTypes);
3396
+ var props = getMergedProps(userProps);
3397
+ var _useControlledReducer = useControlledReducer$1(useTagGroupReducer, props, getInitialState, isStateEqual), state = _useControlledReducer[0], dispatch = _useControlledReducer[1];
3398
+ var activeIndex = state.activeIndex, items = state.items;
3399
+ var elementIds = useElementIds({
3400
+ getTagId: props.getTagId,
3401
+ id: props.id,
3402
+ tagGroupId: props.tagGroupId
3403
+ });
3404
+ useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
3405
+ var itemRefs = useRovingTagFocus(activeIndex, items.length, elementIds.getTagId);
3406
+ var getTagGroupProps = useCallback(function(options) {
3407
+ var _ref = options != null ? options : {}, onKeyDown = _ref.onKeyDown, rest = _objectWithoutPropertiesLoose(_ref, _excluded);
3408
+ return _extends({
3409
+ id: elementIds.tagGroupId,
3410
+ "aria-live": "polite",
3411
+ "aria-atomic": "false",
3412
+ "aria-relevant": "additions",
3413
+ role: "listbox",
3414
+ onKeyDown: callAllEventHandlers(onKeyDown, function handleKeyDown(e) {
3415
+ switch (e.key) {
3416
+ case "ArrowLeft":
3417
+ dispatch({ type: TagGroupKeyDownArrowLeft });
3418
+ break;
3419
+ case "ArrowRight":
3420
+ dispatch({ type: TagGroupKeyDownArrowRight });
3421
+ break;
3422
+ case "Delete":
3423
+ dispatch({ type: TagGroupKeyDownDelete });
3424
+ break;
3425
+ case "Backspace": dispatch({ type: TagGroupKeyDownBackspace });
3426
+ }
3427
+ })
3428
+ }, rest);
3429
+ }, [dispatch, elementIds.tagGroupId]);
3430
+ var getTagProps = useCallback(function(options) {
3431
+ var _extends2;
3432
+ var index = options.index, _options$refKey = options.refKey, refKey = _options$refKey === void 0 ? "ref" : _options$refKey, ref = options.ref, onClick = options.onClick, rest = _objectWithoutPropertiesLoose(options, _excluded2);
3433
+ if (!Number.isInteger(index) || index < 0) throw new Error("Pass correct item index to getTagProps!");
3434
+ var handleClick = function handleClick() {
3435
+ dispatch({
3436
+ type: TagClick,
3437
+ index
3438
+ });
3439
+ };
3440
+ var tagId = elementIds.getTagId(index);
3441
+ return _extends((_extends2 = { "aria-describedby": A11Y_DESCRIPTION_ELEMENT_ID }, _extends2[refKey] = handleRefs(ref, function(itemNode) {
3442
+ if (itemNode) itemRefs.current[tagId] = itemNode;
3443
+ }), _extends2["aria-labelledby"] = tagId, _extends2.role = "option", _extends2.id = tagId, _extends2.onClick = callAllEventHandlers(onClick, handleClick), _extends2.tabIndex = activeIndex === index ? 0 : -1, _extends2), rest);
3444
+ }, [
3445
+ dispatch,
3446
+ elementIds,
3447
+ activeIndex,
3448
+ itemRefs
3449
+ ]);
3450
+ var getTagRemoveProps = useCallback(function(options) {
3451
+ var index = options.index, onClick = options.onClick, rest = _objectWithoutPropertiesLoose(options, _excluded3);
3452
+ if (!Number.isInteger(index) || index < 0) throw new Error("Pass correct item index to getTagRemoveProps!");
3453
+ var handleClick = function handleClick(event) {
3454
+ event.stopPropagation();
3455
+ dispatch({
3456
+ type: TagRemoveClick,
3457
+ index
3458
+ });
3459
+ };
3460
+ var tagId = elementIds.getTagId(index);
3461
+ var tagRemoveId = tagId + "-remove";
3462
+ return _extends({
3463
+ id: tagRemoveId,
3464
+ tabIndex: -1,
3465
+ "aria-labelledby": tagRemoveId + " " + tagId,
3466
+ onClick: callAllEventHandlers(onClick, handleClick)
3467
+ }, rest);
3468
+ }, [elementIds, dispatch]);
3469
+ return {
3470
+ activeIndex,
3471
+ addItem: useCallback(function(item, index) {
3472
+ dispatch({
3473
+ type: FunctionAddItem,
3474
+ item,
3475
+ index
3476
+ });
3477
+ }, [dispatch]),
3478
+ getTagGroupProps,
3479
+ getTagProps,
3480
+ getTagRemoveProps,
3481
+ items
3482
+ };
3483
+ };
3484
+ _useTagGroup.stateChangeTypes = stateChangeTypes;
3485
+ })))();
3486
+ }
3487
+ //#endregion
3488
+ export { debounce$1 as a, init_clsx as c, throttle as i, init_isEqual as l, init_downshift_esm as n, init_debounce as o, init_throttle as r, clsx as s, Downshift as t, isEqual as u };