@zonos/elements 1.3.274 → 1.3.276

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 (355) hide show
  1. package/dist/cjs/{cart-660e115c.js → cart-65e8da66.js} +41 -15
  2. package/dist/cjs/{cleanHtmlMarkdown-31da84b7.js → cleanHtmlMarkdown-57147de7.js} +180 -356
  3. package/dist/cjs/{collect-286a9d04.js → collect-37c177ab.js} +3 -3
  4. package/dist/cjs/{debounce-7990f5ea.js → debounce-9a712c79.js} +1 -1
  5. package/dist/cjs/{getBorderRadius-fc683d94.js → getBorderRadius-4da24d7c.js} +1 -1
  6. package/dist/cjs/{getContrastColor-d5134ef3.js → getContrastColor-2fb235b8.js} +2 -2
  7. package/dist/cjs/{hasInclusivePrice-b35e81aa.js → hasInclusivePrice-798ce42d.js} +1 -1
  8. package/dist/cjs/index.cjs.js +7 -7
  9. package/dist/cjs/{invoice-f032089f.js → invoice-96f5c802.js} +3 -3
  10. package/dist/cjs/{isContrastColor-76592c92.js → isContrastColor-ef24b7aa.js} +1 -1
  11. package/dist/cjs/{isDarkColor-5d6ca405.js → isDarkColor-ebc74b4d.js} +1 -1
  12. package/dist/cjs/{localization-f4a64f6f.js → localization-90650d7d.js} +61 -1
  13. package/dist/cjs/{paypal-125259ab.js → paypal-1952f6ec.js} +5 -5
  14. package/dist/cjs/{placeTestOrder-02001a99.js → placeTestOrder-30191a8f.js} +2 -2
  15. package/dist/cjs/{renderCheckoutCurrency-cad156a7.js → renderCheckoutCurrency-fd35b4ef.js} +2 -2
  16. package/dist/cjs/{submitGtag-4906b161.js → submitGtag-74762255.js} +1 -1
  17. package/dist/cjs/{throttle-02c2e917.js → throttle-34f7abf1.js} +2 -2
  18. package/dist/cjs/{updateCheckoutSessionAttributes-47d73942.js → updateCheckoutSessionAttributes-f595319d.js} +1 -1
  19. package/dist/cjs/zonos-address-display_8.cjs.entry.js +444 -202
  20. package/dist/cjs/zonos-address_4.cjs.entry.js +7 -7
  21. package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +7 -6
  22. package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
  23. package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
  24. package/dist/cjs/zonos-button_3.cjs.entry.js +3 -3
  25. package/dist/cjs/zonos-card_5.cjs.entry.js +9 -8
  26. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +83 -18
  27. package/dist/cjs/zonos-checkbox_2.cjs.entry.js +3 -3
  28. package/dist/cjs/zonos-checkout.cjs.entry.js +11 -10
  29. package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
  30. package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
  31. package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +12 -11
  32. package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
  33. package/dist/cjs/zonos-controller.cjs.entry.js +7 -6
  34. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  35. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1514 -1692
  36. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
  37. package/dist/cjs/zonos-hello.cjs.entry.js +3 -3
  38. package/dist/cjs/zonos-input.cjs.entry.js +2 -2
  39. package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +8 -7
  40. package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +12 -11
  41. package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
  42. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  43. package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
  44. package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +7 -6
  45. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +5 -5
  46. package/dist/cjs/zonos-stripe-input.cjs.entry.js +3 -3
  47. package/dist/cjs/zonos-text.cjs.entry.js +1 -1
  48. package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
  49. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +52 -1
  50. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +1 -1
  51. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +18 -2
  52. package/dist/collection/components/common/zonos-stripe-phone-input/zonos-stripe-phone-input.js +1 -1
  53. package/dist/collection/components/main/zonos-controller.js +1 -1
  54. package/dist/collection/components/store/checkout/cart.js +21 -11
  55. package/dist/collection/components/store/translationStore/strings.arabic.js +3 -0
  56. package/dist/collection/components/store/translationStore/strings.base.js +3 -0
  57. package/dist/collection/components/store/translationStore/strings.chinese.js +3 -0
  58. package/dist/collection/components/store/translationStore/strings.danish.js +3 -0
  59. package/dist/collection/components/store/translationStore/strings.dutch.js +3 -0
  60. package/dist/collection/components/store/translationStore/strings.french.js +3 -0
  61. package/dist/collection/components/store/translationStore/strings.german.js +3 -0
  62. package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -0
  63. package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -0
  64. package/dist/collection/components/store/translationStore/strings.italian.js +3 -0
  65. package/dist/collection/components/store/translationStore/strings.japanese.js +3 -0
  66. package/dist/collection/components/store/translationStore/strings.korean.js +3 -0
  67. package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -0
  68. package/dist/collection/components/store/translationStore/strings.polish.js +3 -0
  69. package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -0
  70. package/dist/collection/components/store/translationStore/strings.russian.js +3 -0
  71. package/dist/collection/components/store/translationStore/strings.spanish.js +3 -0
  72. package/dist/collection/components/store/translationStore/strings.swedish.js +3 -0
  73. package/dist/collection/components/store/translationStore/strings.turkish.js +3 -0
  74. package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -0
  75. package/dist/collection/components/utils/checkout/isEuDapRemittance.js +15 -0
  76. package/dist/collection/types/generated/graphql.internal.types.js +78 -0
  77. package/dist/esm/{cart-23e29950.js → cart-402dcde5.js} +41 -16
  78. package/dist/esm/{cleanHtmlMarkdown-5f7856f2.js → cleanHtmlMarkdown-87d195f6.js} +180 -356
  79. package/dist/esm/{collect-a235299d.js → collect-b88fe4ca.js} +3 -3
  80. package/dist/esm/{debounce-58e4ff3e.js → debounce-c8d67b17.js} +1 -1
  81. package/dist/esm/{getBorderRadius-d23f47a6.js → getBorderRadius-dc982fe6.js} +1 -1
  82. package/dist/esm/{getContrastColor-f0bd5b65.js → getContrastColor-af895b60.js} +2 -2
  83. package/dist/esm/{hasInclusivePrice-5e106f84.js → hasInclusivePrice-1589fef9.js} +1 -1
  84. package/dist/esm/index.js +7 -7
  85. package/dist/esm/{invoice-78f069c7.js → invoice-5eb27944.js} +3 -3
  86. package/dist/esm/{isContrastColor-fbddacb6.js → isContrastColor-089de6ac.js} +1 -1
  87. package/dist/esm/{isDarkColor-566f04c5.js → isDarkColor-039ef212.js} +1 -1
  88. package/dist/esm/{localization-17546792.js → localization-d49867ed.js} +61 -1
  89. package/dist/esm/{paypal-5bc6b0d0.js → paypal-2d4c9d01.js} +5 -5
  90. package/dist/esm/{placeTestOrder-e842854a.js → placeTestOrder-2ba7c3f2.js} +2 -2
  91. package/dist/esm/{renderCheckoutCurrency-e3953f67.js → renderCheckoutCurrency-ef71083e.js} +2 -2
  92. package/dist/esm/{submitGtag-c7ea1f2a.js → submitGtag-dc54f5b9.js} +1 -1
  93. package/dist/esm/{throttle-f09d0659.js → throttle-44bfb6b5.js} +2 -2
  94. package/dist/esm/{updateCheckoutSessionAttributes-40e301a4.js → updateCheckoutSessionAttributes-e0a282d9.js} +1 -1
  95. package/dist/esm/zonos-address-display_8.entry.js +444 -202
  96. package/dist/esm/zonos-address_4.entry.js +7 -7
  97. package/dist/esm/zonos-airwallex-payment.entry.js +7 -6
  98. package/dist/esm/zonos-badge.entry.js +1 -1
  99. package/dist/esm/zonos-banner.entry.js +1 -1
  100. package/dist/esm/zonos-button_3.entry.js +3 -3
  101. package/dist/esm/zonos-card_5.entry.js +9 -8
  102. package/dist/esm/zonos-cart-items_12.entry.js +83 -18
  103. package/dist/esm/zonos-checkbox_2.entry.js +3 -3
  104. package/dist/esm/zonos-checkout.entry.js +11 -10
  105. package/dist/esm/zonos-collapse.entry.js +1 -1
  106. package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
  107. package/dist/esm/zonos-collect-finish_6.entry.js +12 -11
  108. package/dist/esm/zonos-collect.entry.js +10 -9
  109. package/dist/esm/zonos-controller.entry.js +7 -6
  110. package/dist/esm/zonos-country-flag.entry.js +2 -2
  111. package/dist/esm/zonos-country-select_4.entry.js +1514 -1692
  112. package/dist/esm/zonos-hello-dialog.entry.js +3 -3
  113. package/dist/esm/zonos-hello.entry.js +3 -3
  114. package/dist/esm/zonos-input.entry.js +2 -2
  115. package/dist/esm/zonos-invoice-cart-items_2.entry.js +8 -7
  116. package/dist/esm/zonos-invoice-finish_5.entry.js +12 -11
  117. package/dist/esm/zonos-invoice.entry.js +10 -9
  118. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  119. package/dist/esm/zonos-logo.entry.js +1 -1
  120. package/dist/esm/zonos-policy-consent_2.entry.js +7 -6
  121. package/dist/esm/zonos-shipping-rich-radio.entry.js +5 -5
  122. package/dist/esm/zonos-stripe-input.entry.js +3 -3
  123. package/dist/esm/zonos-text.entry.js +1 -1
  124. package/dist/esm/zonos-v-stack.entry.js +1 -1
  125. package/dist/esm-es5/cart-402dcde5.js +1 -0
  126. package/dist/esm-es5/cleanHtmlMarkdown-87d195f6.js +1 -0
  127. package/dist/esm-es5/{collect-a235299d.js → collect-b88fe4ca.js} +1 -1
  128. package/dist/esm-es5/{debounce-58e4ff3e.js → debounce-c8d67b17.js} +1 -1
  129. package/dist/esm-es5/{getBorderRadius-d23f47a6.js → getBorderRadius-dc982fe6.js} +1 -1
  130. package/dist/esm-es5/{getContrastColor-f0bd5b65.js → getContrastColor-af895b60.js} +1 -1
  131. package/dist/esm-es5/{hasInclusivePrice-5e106f84.js → hasInclusivePrice-1589fef9.js} +1 -1
  132. package/dist/esm-es5/index.js +1 -1
  133. package/dist/esm-es5/{invoice-78f069c7.js → invoice-5eb27944.js} +1 -1
  134. package/dist/esm-es5/{isContrastColor-fbddacb6.js → isContrastColor-089de6ac.js} +1 -1
  135. package/dist/esm-es5/{isDarkColor-566f04c5.js → isDarkColor-039ef212.js} +1 -1
  136. package/dist/esm-es5/localization-d49867ed.js +1 -0
  137. package/dist/esm-es5/{paypal-5bc6b0d0.js → paypal-2d4c9d01.js} +1 -1
  138. package/dist/esm-es5/{placeTestOrder-e842854a.js → placeTestOrder-2ba7c3f2.js} +1 -1
  139. package/dist/esm-es5/{renderCheckoutCurrency-e3953f67.js → renderCheckoutCurrency-ef71083e.js} +1 -1
  140. package/dist/esm-es5/{submitGtag-c7ea1f2a.js → submitGtag-dc54f5b9.js} +1 -1
  141. package/dist/esm-es5/throttle-44bfb6b5.js +1 -0
  142. package/dist/esm-es5/{updateCheckoutSessionAttributes-40e301a4.js → updateCheckoutSessionAttributes-e0a282d9.js} +1 -1
  143. package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
  144. package/dist/esm-es5/zonos-address_4.entry.js +1 -1
  145. package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
  146. package/dist/esm-es5/zonos-badge.entry.js +1 -1
  147. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  148. package/dist/esm-es5/zonos-button_3.entry.js +1 -1
  149. package/dist/esm-es5/zonos-card_5.entry.js +1 -1
  150. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  151. package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
  152. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  153. package/dist/esm-es5/zonos-collapse.entry.js +1 -1
  154. package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
  155. package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
  156. package/dist/esm-es5/zonos-collect.entry.js +1 -1
  157. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  158. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  159. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  160. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  161. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  162. package/dist/esm-es5/zonos-input.entry.js +1 -1
  163. package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
  164. package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
  165. package/dist/esm-es5/zonos-invoice.entry.js +1 -1
  166. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  167. package/dist/esm-es5/zonos-logo.entry.js +1 -1
  168. package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
  169. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  170. package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
  171. package/dist/esm-es5/zonos-text.entry.js +1 -1
  172. package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
  173. package/dist/scripts/analyticsRelayOnInit.js +1 -1
  174. package/dist/scripts/blurCurrencyOnInit.js +1 -1
  175. package/dist/scripts/index.d.ts +11 -0
  176. package/dist/scripts/index.js +1 -1
  177. package/dist/scripts/loadZonos.js +1 -1
  178. package/dist/scripts/zonos.js +1 -1
  179. package/dist/types/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.d.ts +8 -0
  180. package/dist/types/components/store/checkout/cart.d.ts +2 -2
  181. package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -0
  182. package/dist/types/components/store/translationStore/strings.base.d.ts +3 -0
  183. package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -0
  184. package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -0
  185. package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -0
  186. package/dist/types/components/store/translationStore/strings.french.d.ts +3 -0
  187. package/dist/types/components/store/translationStore/strings.german.d.ts +3 -0
  188. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -0
  189. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -0
  190. package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -0
  191. package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -0
  192. package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -0
  193. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -0
  194. package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -0
  195. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -0
  196. package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -0
  197. package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -0
  198. package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -0
  199. package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -0
  200. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -0
  201. package/dist/types/components/utils/checkout/isEuDapRemittance.d.ts +15 -0
  202. package/dist/types/types/generated/graphql.internal.types.d.ts +94 -0
  203. package/dist/types/types/generated/graphql.internal.types.ts +114 -7
  204. package/dist/zonos-elements/index.esm.js +1 -1
  205. package/dist/zonos-elements/{p-ccd14aa5.entry.js → p-0745e440.entry.js} +1 -1
  206. package/dist/zonos-elements/{p-59b10526.entry.js → p-08e78d79.entry.js} +1 -1
  207. package/dist/zonos-elements/{p-c846a5f3.system.entry.js → p-0ad6a92b.system.entry.js} +1 -1
  208. package/dist/zonos-elements/p-0b321037.system.entry.js +1 -0
  209. package/dist/zonos-elements/{p-b59fc3fa.system.entry.js → p-0e1f13ff.system.entry.js} +1 -1
  210. package/dist/zonos-elements/p-10715fee.system.entry.js +1 -0
  211. package/dist/zonos-elements/p-144a380d.entry.js +1 -0
  212. package/dist/zonos-elements/{p-c6823974.system.entry.js → p-15097876.system.entry.js} +1 -1
  213. package/dist/zonos-elements/{p-9f5fb332.js → p-1735a69b.js} +1 -1
  214. package/dist/zonos-elements/p-18135660.entry.js +1 -0
  215. package/dist/zonos-elements/{p-055ef910.entry.js → p-1992fd91.entry.js} +1 -1
  216. package/dist/zonos-elements/p-1e4dcd29.entry.js +1 -0
  217. package/dist/zonos-elements/{p-daf57db3.system.entry.js → p-293183c1.system.entry.js} +1 -1
  218. package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
  219. package/dist/zonos-elements/{p-a1a05de4.system.entry.js → p-29c1703c.system.entry.js} +1 -1
  220. package/dist/zonos-elements/p-2e0d813f.system.js +1 -0
  221. package/dist/zonos-elements/{p-d25759fb.system.js → p-2ea73ca2.system.js} +1 -1
  222. package/dist/zonos-elements/p-30e9a6d7.system.js +1 -0
  223. package/dist/zonos-elements/{p-33d4be28.js → p-34d6eb83.js} +1 -1
  224. package/dist/zonos-elements/p-35fd0fdb.js +1 -0
  225. package/dist/zonos-elements/p-3b479012.js +1 -0
  226. package/dist/zonos-elements/{p-d5e66ea6.entry.js → p-3cf22558.entry.js} +1 -1
  227. package/dist/zonos-elements/p-3cfa4880.js +1 -0
  228. package/dist/zonos-elements/{p-896fb969.js → p-3d28353a.js} +1 -1
  229. package/dist/zonos-elements/{p-328fd90e.entry.js → p-3e058b4e.entry.js} +1 -1
  230. package/dist/zonos-elements/p-3feff726.entry.js +1 -0
  231. package/dist/zonos-elements/{p-0a54dae6.system.entry.js → p-429ab545.system.entry.js} +1 -1
  232. package/dist/zonos-elements/p-42ba4da5.system.entry.js +1 -0
  233. package/dist/zonos-elements/p-45535a81.js +1 -0
  234. package/dist/zonos-elements/p-48627415.system.entry.js +1 -0
  235. package/dist/zonos-elements/{p-f053975e.system.js → p-496accce.system.js} +1 -1
  236. package/dist/zonos-elements/p-4a1c9fa1.entry.js +1 -0
  237. package/dist/zonos-elements/{p-86a9f048.system.entry.js → p-4a6f9c5e.system.entry.js} +1 -1
  238. package/dist/zonos-elements/p-4b06044f.js +1 -0
  239. package/dist/zonos-elements/p-4d29dcc8.entry.js +1 -0
  240. package/dist/zonos-elements/{p-1f31f5a0.system.entry.js → p-4e6e9a3c.system.entry.js} +1 -1
  241. package/dist/zonos-elements/{p-12a05647.entry.js → p-4efd7178.entry.js} +1 -1
  242. package/dist/zonos-elements/p-521cbeea.entry.js +1 -0
  243. package/dist/zonos-elements/p-534057ad.system.entry.js +1 -0
  244. package/dist/zonos-elements/p-55195dab.entry.js +1 -0
  245. package/dist/zonos-elements/p-58b56c69.entry.js +1 -0
  246. package/dist/zonos-elements/{p-10571f94.system.entry.js → p-5aee5de5.system.entry.js} +1 -1
  247. package/dist/zonos-elements/p-5c30d04b.js +1 -0
  248. package/dist/zonos-elements/p-5ce88ef3.system.entry.js +1 -0
  249. package/dist/zonos-elements/{p-2a1247f4.system.entry.js → p-5d3ea491.system.entry.js} +1 -1
  250. package/dist/zonos-elements/{p-dcef2202.entry.js → p-5d4201d5.entry.js} +1 -1
  251. package/dist/zonos-elements/p-5e3b0ef4.entry.js +1 -0
  252. package/dist/zonos-elements/{p-80df7e0b.system.entry.js → p-6146bfaa.system.entry.js} +1 -1
  253. package/dist/zonos-elements/{p-e548b8ec.entry.js → p-62609f19.entry.js} +1 -1
  254. package/dist/zonos-elements/p-628fe742.system.entry.js +1 -0
  255. package/dist/zonos-elements/{p-91b921a4.system.js → p-647438d6.system.js} +1 -1
  256. package/dist/zonos-elements/p-67dac4e5.system.entry.js +1 -0
  257. package/dist/zonos-elements/p-684e27da.system.js +1 -0
  258. package/dist/zonos-elements/{p-14018649.system.js → p-6ad0f720.system.js} +1 -1
  259. package/dist/zonos-elements/{p-45d74be2.system.js → p-6f324051.system.js} +1 -1
  260. package/dist/zonos-elements/p-77ac8bfe.entry.js +1 -0
  261. package/dist/zonos-elements/{p-4df08fc4.js → p-7bdce9d4.js} +1 -1
  262. package/dist/zonos-elements/p-82341c15.entry.js +1 -0
  263. package/dist/zonos-elements/p-864525b4.system.entry.js +1 -0
  264. package/dist/zonos-elements/p-89befc63.system.entry.js +1 -0
  265. package/dist/zonos-elements/{p-c83bc4b3.entry.js → p-8c54aaec.entry.js} +1 -1
  266. package/dist/zonos-elements/{p-306e5499.system.entry.js → p-998f9df5.system.entry.js} +1 -1
  267. package/dist/zonos-elements/{p-3eba657b.system.entry.js → p-99e8743e.system.entry.js} +1 -1
  268. package/dist/zonos-elements/p-9fab45aa.system.js +1 -0
  269. package/dist/zonos-elements/{p-42948a52.js → p-a02ff788.js} +1 -1
  270. package/dist/zonos-elements/p-a1bd3a53.system.js +1 -0
  271. package/dist/zonos-elements/{p-e9c8a235.js → p-a3bc7e97.js} +1 -1
  272. package/dist/zonos-elements/p-a3c116d6.system.js +1 -0
  273. package/dist/zonos-elements/{p-5aa35d1c.system.entry.js → p-a3d3ce5d.system.entry.js} +1 -1
  274. package/dist/zonos-elements/{p-27e50593.system.entry.js → p-a44591f6.system.entry.js} +1 -1
  275. package/dist/zonos-elements/p-a7050d1e.system.entry.js +1 -0
  276. package/dist/zonos-elements/p-ac1b60c8.system.entry.js +1 -0
  277. package/dist/zonos-elements/{p-e8cb382e.entry.js → p-ac9b9f7d.entry.js} +1 -1
  278. package/dist/zonos-elements/{p-2197d6ab.js → p-b1c86a5b.js} +1 -1
  279. package/dist/zonos-elements/{p-cc508de8.entry.js → p-b5f67807.entry.js} +1 -1
  280. package/dist/zonos-elements/p-b7e4f1f5.entry.js +1 -0
  281. package/dist/zonos-elements/p-c209e36d.js +1 -0
  282. package/dist/zonos-elements/p-c750a2e0.system.entry.js +1 -0
  283. package/dist/zonos-elements/p-cc6ad18a.js +1 -0
  284. package/dist/zonos-elements/{p-c1463da7.entry.js → p-d1e84608.entry.js} +1 -1
  285. package/dist/zonos-elements/{p-9c3276c8.entry.js → p-d5945ddc.entry.js} +1 -1
  286. package/dist/zonos-elements/{p-5d65be06.system.js → p-d706852e.system.js} +1 -1
  287. package/dist/zonos-elements/p-d7bda14d.js +1 -0
  288. package/dist/zonos-elements/{p-df55536b.entry.js → p-daab3824.entry.js} +1 -1
  289. package/dist/zonos-elements/{p-7d9d2407.system.js → p-dab78981.system.js} +1 -1
  290. package/dist/zonos-elements/{p-990d1495.system.entry.js → p-db65c60b.system.entry.js} +1 -1
  291. package/dist/zonos-elements/{p-bc919de1.system.js → p-e977562b.system.js} +1 -1
  292. package/dist/zonos-elements/{p-abd485df.entry.js → p-ee434a71.entry.js} +1 -1
  293. package/dist/zonos-elements/{p-3dc3596b.js → p-f1aea919.js} +1 -1
  294. package/dist/zonos-elements/{p-62c68aee.system.js → p-f2768c92.system.js} +1 -1
  295. package/dist/zonos-elements/p-f29bcf8b.system.js +1 -0
  296. package/dist/zonos-elements/{p-1a4083be.system.js → p-f2d50796.system.js} +1 -1
  297. package/dist/zonos-elements/p-f3a73132.entry.js +1 -0
  298. package/dist/zonos-elements/{p-f72642de.entry.js → p-f59514e9.entry.js} +1 -1
  299. package/dist/zonos-elements/{p-52bd7be3.system.js → p-f61c0eef.system.js} +1 -1
  300. package/dist/zonos-elements/p-ffbf87c8.system.entry.js +1 -0
  301. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  302. package/package.json +12 -35
  303. package/dist/esm-es5/cart-23e29950.js +0 -1
  304. package/dist/esm-es5/cleanHtmlMarkdown-5f7856f2.js +0 -1
  305. package/dist/esm-es5/localization-17546792.js +0 -1
  306. package/dist/esm-es5/throttle-f09d0659.js +0 -1
  307. package/dist/zonos-elements/p-013575f2.entry.js +0 -1
  308. package/dist/zonos-elements/p-08b48608.entry.js +0 -1
  309. package/dist/zonos-elements/p-0b59076d.system.entry.js +0 -1
  310. package/dist/zonos-elements/p-14d6542f.system.js +0 -1
  311. package/dist/zonos-elements/p-1678d8b4.system.entry.js +0 -1
  312. package/dist/zonos-elements/p-171d0f9f.system.js +0 -1
  313. package/dist/zonos-elements/p-18af6aaa.system.js +0 -1
  314. package/dist/zonos-elements/p-1a105d6e.system.entry.js +0 -1
  315. package/dist/zonos-elements/p-31577ebd.entry.js +0 -1
  316. package/dist/zonos-elements/p-33910e8b.js +0 -1
  317. package/dist/zonos-elements/p-3b28fc76.js +0 -1
  318. package/dist/zonos-elements/p-41619f29.js +0 -1
  319. package/dist/zonos-elements/p-46e72a90.entry.js +0 -1
  320. package/dist/zonos-elements/p-49d8a10f.entry.js +0 -1
  321. package/dist/zonos-elements/p-4a960329.system.entry.js +0 -1
  322. package/dist/zonos-elements/p-4b371b65.entry.js +0 -1
  323. package/dist/zonos-elements/p-539bc46c.js +0 -1
  324. package/dist/zonos-elements/p-5dd86dd9.system.js +0 -1
  325. package/dist/zonos-elements/p-6c19310e.system.entry.js +0 -1
  326. package/dist/zonos-elements/p-7eb47eb0.entry.js +0 -1
  327. package/dist/zonos-elements/p-8af57c2a.js +0 -1
  328. package/dist/zonos-elements/p-8c4761d1.system.entry.js +0 -1
  329. package/dist/zonos-elements/p-8e77a3cd.system.entry.js +0 -1
  330. package/dist/zonos-elements/p-90d22087.system.js +0 -1
  331. package/dist/zonos-elements/p-919c5500.entry.js +0 -1
  332. package/dist/zonos-elements/p-9574695a.system.js +0 -1
  333. package/dist/zonos-elements/p-9581bffb.js +0 -1
  334. package/dist/zonos-elements/p-97917371.system.entry.js +0 -1
  335. package/dist/zonos-elements/p-9b003a15.system.entry.js +0 -1
  336. package/dist/zonos-elements/p-9cd41234.system.entry.js +0 -1
  337. package/dist/zonos-elements/p-a968ccba.entry.js +0 -1
  338. package/dist/zonos-elements/p-ac8cfdc0.js +0 -1
  339. package/dist/zonos-elements/p-ad961f5d.entry.js +0 -1
  340. package/dist/zonos-elements/p-b5c01288.system.entry.js +0 -1
  341. package/dist/zonos-elements/p-bf8c98ab.system.js +0 -1
  342. package/dist/zonos-elements/p-c13d2e3f.entry.js +0 -1
  343. package/dist/zonos-elements/p-cd34ecf2.js +0 -1
  344. package/dist/zonos-elements/p-df6fbf3f.entry.js +0 -1
  345. package/dist/zonos-elements/p-e643346a.entry.js +0 -1
  346. package/dist/zonos-elements/p-e8ec88a9.system.entry.js +0 -1
  347. package/dist/zonos-elements/p-e9afd736.system.entry.js +0 -1
  348. package/dist/zonos-elements/p-f0eb6317.system.entry.js +0 -1
  349. package/dist/zonos-elements/p-f1cc659c.js +0 -1
  350. package/dist/zonos-elements/p-f53c8a9f.entry.js +0 -1
  351. /package/dist/cjs/{zonosStore-45a87908.js → zonosStore-fee716c9.js} +0 -0
  352. /package/dist/esm/{zonosStore-8e19daff.js → zonosStore-b7d3f9b0.js} +0 -0
  353. /package/dist/esm-es5/{zonosStore-8e19daff.js → zonosStore-b7d3f9b0.js} +0 -0
  354. /package/dist/zonos-elements/{p-3e7ee89d.system.js → p-47a1d469.system.js} +0 -0
  355. /package/dist/zonos-elements/{p-701d9a7c.js → p-9a417eeb.js} +0 -0
@@ -3,1807 +3,1629 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-b1f95d96.js');
6
- const localization = require('./localization-f4a64f6f.js');
7
- const zonosStore = require('./zonosStore-45a87908.js');
6
+ const localization = require('./localization-90650d7d.js');
7
+ const zonosStore = require('./zonosStore-fee716c9.js');
8
8
  const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
9
- const isDarkColor = require('./isDarkColor-5d6ca405.js');
9
+ const isDarkColor = require('./isDarkColor-ebc74b4d.js');
10
10
  const ILanguage = require('./ILanguage-98b04442.js');
11
11
  const classes = require('./classes-b7918f56.js');
12
12
  require('./handleFetch-954f30e1.js');
13
13
  require('./VarianceTest-bec00ea8.js');
14
14
 
15
15
  /**
16
- * Fuse.js v7.1.0 - Lightweight fuzzy-search (http://fusejs.io)
16
+ * Fuse.js v7.4.2 - Lightweight fuzzy-search (http://fusejs.io)
17
17
  *
18
- * Copyright (c) 2025 Kiro Risk (http://kiro.me)
18
+ * Copyright (c) 2026 Kiro Risk (http://kiro.me)
19
19
  * All Rights Reserved. Apache Software License 2.0
20
20
  *
21
21
  * http://www.apache.org/licenses/LICENSE-2.0
22
22
  */
23
-
23
+ //#region src/helpers/typeGuards.ts
24
24
  function isArray(value) {
25
- return !Array.isArray
26
- ? getTag(value) === '[object Array]'
27
- : Array.isArray(value)
25
+ return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value);
28
26
  }
29
-
30
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
31
- const INFINITY = 1 / 0;
32
27
  function baseToString(value) {
33
- // Exit early for strings to avoid a performance hit in some environments.
34
- if (typeof value == 'string') {
35
- return value
36
- }
37
- let result = value + '';
38
- return result == '0' && 1 / value == -INFINITY ? '-0' : result
28
+ if (typeof value == "string") return value;
29
+ if (typeof value === "bigint") return value.toString();
30
+ const result = value + "";
31
+ return result == "0" && 1 / value == -Infinity ? "-0" : result;
39
32
  }
40
-
41
33
  function toString(value) {
42
- return value == null ? '' : baseToString(value)
34
+ return value == null ? "" : baseToString(value);
43
35
  }
44
-
45
36
  function isString(value) {
46
- return typeof value === 'string'
37
+ return typeof value === "string";
47
38
  }
48
-
49
39
  function isNumber(value) {
50
- return typeof value === 'number'
40
+ return typeof value === "number";
51
41
  }
52
-
53
- // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
54
42
  function isBoolean(value) {
55
- return (
56
- value === true ||
57
- value === false ||
58
- (isObjectLike(value) && getTag(value) == '[object Boolean]')
59
- )
43
+ return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]";
60
44
  }
61
-
62
45
  function isObject(value) {
63
- return typeof value === 'object'
46
+ return typeof value === "object";
64
47
  }
65
-
66
- // Checks if `value` is object-like.
67
48
  function isObjectLike(value) {
68
- return isObject(value) && value !== null
49
+ return isObject(value) && value !== null;
69
50
  }
70
-
71
51
  function isDefined(value) {
72
- return value !== undefined && value !== null
52
+ return value !== void 0 && value !== null;
73
53
  }
74
-
75
54
  function isBlank(value) {
76
- return !value.trim().length
55
+ return !value.trim().length;
77
56
  }
78
-
79
- // Gets the `toStringTag` of `value`.
80
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
81
57
  function getTag(value) {
82
- return value == null
83
- ? value === undefined
84
- ? '[object Undefined]'
85
- : '[object Null]'
86
- : Object.prototype.toString.call(value)
58
+ return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value);
87
59
  }
88
60
 
89
- const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
90
-
61
+ //#endregion
62
+ //#region src/core/errorMessages.ts
91
63
  const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
92
-
93
- const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
94
- `Invalid value for key ${key}`;
95
-
96
- const PATTERN_LENGTH_TOO_LARGE = (max) =>
97
- `Pattern length exceeds max of ${max}.`;
98
-
64
+ const INVALID_DOC_INDEX = "Invalid doc index: must be a non-negative integer within the bounds of the docs array";
65
+ const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
66
+ const PATTERN_LENGTH_TOO_LARGE = (max) => `Pattern length exceeds max of ${max}.`;
99
67
  const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
68
+ const INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
69
+ const FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED = "Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.";
100
70
 
101
- const INVALID_KEY_WEIGHT_VALUE = (key) =>
102
- `Property 'weight' in key '${key}' must be a positive integer`;
103
-
71
+ //#endregion
72
+ //#region src/tools/KeyStore.ts
104
73
  const hasOwn = Object.prototype.hasOwnProperty;
105
-
106
- class KeyStore {
107
- constructor(keys) {
108
- this._keys = [];
109
- this._keyMap = {};
110
-
111
- let totalWeight = 0;
112
-
113
- keys.forEach((key) => {
114
- let obj = createKey(key);
115
-
116
- this._keys.push(obj);
117
- this._keyMap[obj.id] = obj;
118
-
119
- totalWeight += obj.weight;
120
- });
121
-
122
- // Normalize weights so that their sum is equal to 1
123
- this._keys.forEach((key) => {
124
- key.weight /= totalWeight;
125
- });
126
- }
127
- get(keyId) {
128
- return this._keyMap[keyId]
129
- }
130
- keys() {
131
- return this._keys
132
- }
133
- toJSON() {
134
- return JSON.stringify(this._keys)
135
- }
136
- }
137
-
74
+ var KeyStore = class {
75
+ constructor(keys) {
76
+ this._keys = [];
77
+ this._keyMap = {};
78
+ let totalWeight = 0;
79
+ keys.forEach((key) => {
80
+ const obj = createKey(key);
81
+ this._keys.push(obj);
82
+ this._keyMap[obj.id] = obj;
83
+ totalWeight += obj.weight;
84
+ });
85
+ this._keys.forEach((key) => {
86
+ key.weight /= totalWeight;
87
+ });
88
+ }
89
+ get(keyId) {
90
+ return this._keyMap[keyId];
91
+ }
92
+ keys() {
93
+ return this._keys;
94
+ }
95
+ toJSON() {
96
+ return JSON.stringify(this._keys);
97
+ }
98
+ };
138
99
  function createKey(key) {
139
- let path = null;
140
- let id = null;
141
- let src = null;
142
- let weight = 1;
143
- let getFn = null;
144
-
145
- if (isString(key) || isArray(key)) {
146
- src = key;
147
- path = createKeyPath(key);
148
- id = createKeyId(key);
149
- } else {
150
- if (!hasOwn.call(key, 'name')) {
151
- throw new Error(MISSING_KEY_PROPERTY('name'))
152
- }
153
-
154
- const name = key.name;
155
- src = name;
156
-
157
- if (hasOwn.call(key, 'weight')) {
158
- weight = key.weight;
159
-
160
- if (weight <= 0) {
161
- throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
162
- }
163
- }
164
-
165
- path = createKeyPath(name);
166
- id = createKeyId(name);
167
- getFn = key.getFn;
168
- }
169
-
170
- return { path, id, weight, src, getFn }
100
+ let path = null;
101
+ let id = null;
102
+ let src = null;
103
+ let weight = 1;
104
+ let getFn = null;
105
+ if (isString(key) || isArray(key)) {
106
+ src = key;
107
+ path = createKeyPath(key);
108
+ id = createKeyId(key);
109
+ } else {
110
+ if (!hasOwn.call(key, "name")) throw new Error(MISSING_KEY_PROPERTY("name"));
111
+ const name = key.name;
112
+ src = name;
113
+ if (hasOwn.call(key, "weight") && key.weight !== void 0) {
114
+ weight = key.weight;
115
+ if (weight <= 0) throw new Error(INVALID_KEY_WEIGHT_VALUE(createKeyId(name)));
116
+ }
117
+ path = createKeyPath(name);
118
+ id = createKeyId(name);
119
+ getFn = key.getFn ?? null;
120
+ }
121
+ return {
122
+ path,
123
+ id,
124
+ weight,
125
+ src,
126
+ getFn
127
+ };
171
128
  }
172
-
173
129
  function createKeyPath(key) {
174
- return isArray(key) ? key : key.split('.')
130
+ return isArray(key) ? key : key.split(".");
175
131
  }
176
-
177
132
  function createKeyId(key) {
178
- return isArray(key) ? key.join('.') : key
133
+ return isArray(key) ? key.join(".") : key;
179
134
  }
180
135
 
136
+ //#endregion
137
+ //#region src/helpers/get.ts
181
138
  function get(obj, path) {
182
- let list = [];
183
- let arr = false;
184
-
185
- const deepGet = (obj, path, index) => {
186
- if (!isDefined(obj)) {
187
- return
188
- }
189
- if (!path[index]) {
190
- // If there's no path left, we've arrived at the object we care about.
191
- list.push(obj);
192
- } else {
193
- let key = path[index];
194
-
195
- const value = obj[key];
196
-
197
- if (!isDefined(value)) {
198
- return
199
- }
200
-
201
- // If we're at the last value in the path, and if it's a string/number/bool,
202
- // add it to the list
203
- if (
204
- index === path.length - 1 &&
205
- (isString(value) || isNumber(value) || isBoolean(value))
206
- ) {
207
- list.push(toString(value));
208
- } else if (isArray(value)) {
209
- arr = true;
210
- // Search each item in the array.
211
- for (let i = 0, len = value.length; i < len; i += 1) {
212
- deepGet(value[i], path, index + 1);
213
- }
214
- } else if (path.length) {
215
- // An object. Recurse further.
216
- deepGet(value, path, index + 1);
217
- }
218
- }
219
- };
220
-
221
- // Backwards compatibility (since path used to be a string)
222
- deepGet(obj, isString(path) ? path.split('.') : path, 0);
223
-
224
- return arr ? list : list[0]
139
+ const list = [];
140
+ let arr = false;
141
+ const deepGet = (obj, path, index, arrayIndex) => {
142
+ if (!isDefined(obj)) return;
143
+ if (!path[index]) list.push(arrayIndex !== void 0 ? {
144
+ v: obj,
145
+ i: arrayIndex
146
+ } : obj);
147
+ else {
148
+ const value = obj[path[index]];
149
+ if (!isDefined(value)) return;
150
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value) || typeof value === "bigint")) list.push(arrayIndex !== void 0 ? {
151
+ v: toString(value),
152
+ i: arrayIndex
153
+ } : toString(value));
154
+ else if (isArray(value)) {
155
+ arr = true;
156
+ for (let i = 0, len = value.length; i < len; i += 1) deepGet(value[i], path, index + 1, i);
157
+ } else if (path.length) deepGet(value, path, index + 1, arrayIndex);
158
+ }
159
+ };
160
+ deepGet(obj, isString(path) ? path.split(".") : path, 0);
161
+ return arr ? list : list[0];
225
162
  }
226
163
 
164
+ //#endregion
165
+ //#region src/core/config.ts
227
166
  const MatchOptions = {
228
- // Whether the matches should be included in the result set. When `true`, each record in the result
229
- // set will include the indices of the matched characters.
230
- // These can consequently be used for highlighting purposes.
231
- includeMatches: false,
232
- // When `true`, the matching function will continue to the end of a search pattern even if
233
- // a perfect match has already been located in the string.
234
- findAllMatches: false,
235
- // Minimum number of characters that must be matched before a result is considered a match
236
- minMatchCharLength: 1
167
+ includeMatches: false,
168
+ findAllMatches: false,
169
+ minMatchCharLength: 1
237
170
  };
238
-
239
171
  const BasicOptions = {
240
- // When `true`, the algorithm continues searching to the end of the input even if a perfect
241
- // match is found before the end of the same input.
242
- isCaseSensitive: false,
243
- // When `true`, the algorithm will ignore diacritics (accents) in comparisons
244
- ignoreDiacritics: false,
245
- // When true, the matching function will continue to the end of a search pattern even if
246
- includeScore: false,
247
- // List of properties that will be searched. This also supports nested properties.
248
- keys: [],
249
- // Whether to sort the result list, by score
250
- shouldSort: true,
251
- // Default sort function: sort by ascending score, ascending index
252
- sortFn: (a, b) =>
253
- a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
172
+ isCaseSensitive: false,
173
+ ignoreDiacritics: false,
174
+ includeScore: false,
175
+ keys: [],
176
+ shouldSort: true,
177
+ sortFn: (a, b) => a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1
254
178
  };
255
-
256
179
  const FuzzyOptions = {
257
- // Approximately where in the text is the pattern expected to be found?
258
- location: 0,
259
- // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
260
- // (of both letters and location), a threshold of '1.0' would match anything.
261
- threshold: 0.6,
262
- // Determines how close the match must be to the fuzzy location (specified above).
263
- // An exact letter match which is 'distance' characters away from the fuzzy location
264
- // would score as a complete mismatch. A distance of '0' requires the match be at
265
- // the exact location specified, a threshold of '1000' would require a perfect match
266
- // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
267
- distance: 100
180
+ location: 0,
181
+ threshold: .6,
182
+ distance: 100
268
183
  };
269
-
270
184
  const AdvancedOptions = {
271
- // When `true`, it enables the use of unix-like search commands
272
- useExtendedSearch: false,
273
- // The get function to use when fetching an object's properties.
274
- // The default will search nested paths *ie foo.bar.baz*
275
- getFn: get,
276
- // When `true`, search will ignore `location` and `distance`, so it won't matter
277
- // where in the string the pattern appears.
278
- // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
279
- ignoreLocation: false,
280
- // When `true`, the calculation for the relevance score (used for sorting) will
281
- // ignore the field-length norm.
282
- // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
283
- ignoreFieldNorm: false,
284
- // The weight to determine how much field length norm effects scoring.
285
- fieldNormWeight: 1
286
- };
287
-
288
- var Config = {
289
- ...BasicOptions,
290
- ...MatchOptions,
291
- ...FuzzyOptions,
292
- ...AdvancedOptions
185
+ useExtendedSearch: false,
186
+ useTokenSearch: false,
187
+ tokenize: void 0,
188
+ tokenMatch: "any",
189
+ getFn: get,
190
+ ignoreLocation: false,
191
+ ignoreFieldNorm: false,
192
+ fieldNormWeight: 1
293
193
  };
194
+ const Config = Object.freeze({
195
+ ...BasicOptions,
196
+ ...MatchOptions,
197
+ ...FuzzyOptions,
198
+ ...AdvancedOptions
199
+ });
294
200
 
295
- const SPACE = /[^ ]+/g;
296
-
297
- // Field-length norm: the shorter the field, the higher the weight.
298
- // Set to 3 decimals to reduce index size.
201
+ //#endregion
202
+ //#region src/tools/fieldNorm.ts
299
203
  function norm(weight = 1, mantissa = 3) {
300
- const cache = new Map();
301
- const m = Math.pow(10, mantissa);
302
-
303
- return {
304
- get(value) {
305
- const numTokens = value.match(SPACE).length;
306
-
307
- if (cache.has(numTokens)) {
308
- return cache.get(numTokens)
309
- }
310
-
311
- // Default function is 1/sqrt(x), weight makes that variable
312
- const norm = 1 / Math.pow(numTokens, 0.5 * weight);
313
-
314
- // In place of `toFixed(mantissa)`, for faster computation
315
- const n = parseFloat(Math.round(norm * m) / m);
316
-
317
- cache.set(numTokens, n);
318
-
319
- return n
320
- },
321
- clear() {
322
- cache.clear();
323
- }
324
- }
325
- }
326
-
327
- class FuseIndex {
328
- constructor({
329
- getFn = Config.getFn,
330
- fieldNormWeight = Config.fieldNormWeight
331
- } = {}) {
332
- this.norm = norm(fieldNormWeight, 3);
333
- this.getFn = getFn;
334
- this.isCreated = false;
335
-
336
- this.setIndexRecords();
337
- }
338
- setSources(docs = []) {
339
- this.docs = docs;
340
- }
341
- setIndexRecords(records = []) {
342
- this.records = records;
343
- }
344
- setKeys(keys = []) {
345
- this.keys = keys;
346
- this._keysMap = {};
347
- keys.forEach((key, idx) => {
348
- this._keysMap[key.id] = idx;
349
- });
350
- }
351
- create() {
352
- if (this.isCreated || !this.docs.length) {
353
- return
354
- }
355
-
356
- this.isCreated = true;
357
-
358
- // List is Array<String>
359
- if (isString(this.docs[0])) {
360
- this.docs.forEach((doc, docIndex) => {
361
- this._addString(doc, docIndex);
362
- });
363
- } else {
364
- // List is Array<Object>
365
- this.docs.forEach((doc, docIndex) => {
366
- this._addObject(doc, docIndex);
367
- });
368
- }
369
-
370
- this.norm.clear();
371
- }
372
- // Adds a doc to the end of the index
373
- add(doc) {
374
- const idx = this.size();
375
-
376
- if (isString(doc)) {
377
- this._addString(doc, idx);
378
- } else {
379
- this._addObject(doc, idx);
380
- }
381
- }
382
- // Removes the doc at the specified index of the index
383
- removeAt(idx) {
384
- this.records.splice(idx, 1);
385
-
386
- // Change ref index of every subsquent doc
387
- for (let i = idx, len = this.size(); i < len; i += 1) {
388
- this.records[i].i -= 1;
389
- }
390
- }
391
- getValueForItemAtKeyId(item, keyId) {
392
- return item[this._keysMap[keyId]]
393
- }
394
- size() {
395
- return this.records.length
396
- }
397
- _addString(doc, docIndex) {
398
- if (!isDefined(doc) || isBlank(doc)) {
399
- return
400
- }
401
-
402
- let record = {
403
- v: doc,
404
- i: docIndex,
405
- n: this.norm.get(doc)
406
- };
407
-
408
- this.records.push(record);
409
- }
410
- _addObject(doc, docIndex) {
411
- let record = { i: docIndex, $: {} };
412
-
413
- // Iterate over every key (i.e, path), and fetch the value at that key
414
- this.keys.forEach((key, keyIndex) => {
415
- let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
416
-
417
- if (!isDefined(value)) {
418
- return
419
- }
420
-
421
- if (isArray(value)) {
422
- let subRecords = [];
423
- const stack = [{ nestedArrIndex: -1, value }];
424
-
425
- while (stack.length) {
426
- const { nestedArrIndex, value } = stack.pop();
427
-
428
- if (!isDefined(value)) {
429
- continue
430
- }
431
-
432
- if (isString(value) && !isBlank(value)) {
433
- let subRecord = {
434
- v: value,
435
- i: nestedArrIndex,
436
- n: this.norm.get(value)
437
- };
438
-
439
- subRecords.push(subRecord);
440
- } else if (isArray(value)) {
441
- value.forEach((item, k) => {
442
- stack.push({
443
- nestedArrIndex: k,
444
- value: item
445
- });
446
- });
447
- } else ;
448
- }
449
- record.$[keyIndex] = subRecords;
450
- } else if (isString(value) && !isBlank(value)) {
451
- let subRecord = {
452
- v: value,
453
- n: this.norm.get(value)
454
- };
455
-
456
- record.$[keyIndex] = subRecord;
457
- }
458
- });
459
-
460
- this.records.push(record);
461
- }
462
- toJSON() {
463
- return {
464
- keys: this.keys,
465
- records: this.records
466
- }
467
- }
204
+ const cache = /* @__PURE__ */ new Map();
205
+ const m = Math.pow(10, mantissa);
206
+ return {
207
+ get(value) {
208
+ let numTokens = 1;
209
+ let inSpace = false;
210
+ for (let i = 0; i < value.length; i++) if (value.charCodeAt(i) === 32) {
211
+ if (!inSpace) {
212
+ numTokens++;
213
+ inSpace = true;
214
+ }
215
+ } else inSpace = false;
216
+ if (cache.has(numTokens)) return cache.get(numTokens);
217
+ const n = Math.round(m / Math.pow(numTokens, .5 * weight)) / m;
218
+ cache.set(numTokens, n);
219
+ return n;
220
+ },
221
+ clear() {
222
+ cache.clear();
223
+ }
224
+ };
468
225
  }
469
226
 
470
- function createIndex(
471
- keys,
472
- docs,
473
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
474
- ) {
475
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
476
- myIndex.setKeys(keys.map(createKey));
477
- myIndex.setSources(docs);
478
- myIndex.create();
479
- return myIndex
227
+ //#endregion
228
+ //#region src/tools/FuseIndex.ts
229
+ var FuseIndex = class {
230
+ constructor({ getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
231
+ this.norm = norm(fieldNormWeight, 3);
232
+ this.getFn = getFn;
233
+ this.isCreated = false;
234
+ this.docs = [];
235
+ this.keys = [];
236
+ this._keysMap = {};
237
+ this.setIndexRecords();
238
+ }
239
+ setSources(docs = []) {
240
+ this.docs = docs;
241
+ }
242
+ setIndexRecords(records = []) {
243
+ this.records = records;
244
+ }
245
+ setKeys(keys = []) {
246
+ this.keys = keys;
247
+ this._keysMap = {};
248
+ keys.forEach((key, idx) => {
249
+ this._keysMap[key.id] = idx;
250
+ });
251
+ }
252
+ create() {
253
+ if (this.isCreated || !this.docs.length) return;
254
+ this.isCreated = true;
255
+ const len = this.docs.length;
256
+ this.records = new Array(len);
257
+ let recordCount = 0;
258
+ if (isString(this.docs[0])) for (let i = 0; i < len; i++) {
259
+ const record = this._createStringRecord(this.docs[i], i);
260
+ if (record) this.records[recordCount++] = record;
261
+ }
262
+ else for (let i = 0; i < len; i++) this.records[recordCount++] = this._createObjectRecord(this.docs[i], i);
263
+ this.records.length = recordCount;
264
+ this.norm.clear();
265
+ }
266
+ add(doc, docIndex) {
267
+ if (!Number.isInteger(docIndex) || docIndex < 0) throw new Error(INVALID_DOC_INDEX);
268
+ if (isString(doc)) {
269
+ const record = this._createStringRecord(doc, docIndex);
270
+ if (record) this.records.push(record);
271
+ return record;
272
+ }
273
+ const record = this._createObjectRecord(doc, docIndex);
274
+ this.records.push(record);
275
+ return record;
276
+ }
277
+ removeAt(idx) {
278
+ if (!Number.isInteger(idx) || idx < 0) throw new Error(INVALID_DOC_INDEX);
279
+ for (let i = 0, len = this.records.length; i < len; i += 1) if (this.records[i].i === idx) {
280
+ this.records.splice(i, 1);
281
+ break;
282
+ }
283
+ for (let i = 0, len = this.records.length; i < len; i += 1) if (this.records[i].i > idx) this.records[i].i -= 1;
284
+ }
285
+ removeAll(indices) {
286
+ const toRemove = /* @__PURE__ */ new Set();
287
+ for (const v of indices) if (Number.isInteger(v) && v >= 0) toRemove.add(v);
288
+ if (toRemove.size === 0) return;
289
+ this.records = this.records.filter((r) => !toRemove.has(r.i));
290
+ const sorted = Array.from(toRemove).sort((a, b) => a - b);
291
+ for (const record of this.records) {
292
+ let lo = 0;
293
+ let hi = sorted.length;
294
+ while (lo < hi) {
295
+ const mid = lo + hi >>> 1;
296
+ if (sorted[mid] < record.i) lo = mid + 1;
297
+ else hi = mid;
298
+ }
299
+ record.i -= lo;
300
+ }
301
+ }
302
+ getValueForItemAtKeyId(item, keyId) {
303
+ return item[this._keysMap[keyId]];
304
+ }
305
+ size() {
306
+ return this.records.length;
307
+ }
308
+ _createStringRecord(doc, docIndex) {
309
+ if (!isDefined(doc) || isBlank(doc)) return null;
310
+ return {
311
+ v: doc,
312
+ i: docIndex,
313
+ n: this.norm.get(doc)
314
+ };
315
+ }
316
+ _createObjectRecord(doc, docIndex) {
317
+ const record = {
318
+ i: docIndex,
319
+ $: {}
320
+ };
321
+ for (let keyIndex = 0, keyLen = this.keys.length; keyIndex < keyLen; keyIndex++) {
322
+ const key = this.keys[keyIndex];
323
+ const value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
324
+ if (!isDefined(value)) continue;
325
+ if (isArray(value)) {
326
+ const subRecords = [];
327
+ for (let i = 0, len = value.length; i < len; i += 1) {
328
+ const item = value[i];
329
+ if (!isDefined(item)) continue;
330
+ if (isString(item)) {
331
+ if (!isBlank(item)) {
332
+ const subRecord = {
333
+ v: item,
334
+ i,
335
+ n: this.norm.get(item)
336
+ };
337
+ subRecords.push(subRecord);
338
+ }
339
+ } else if (isDefined(item.v)) {
340
+ const text = isString(item.v) ? item.v : toString(item.v);
341
+ if (!isBlank(text)) {
342
+ const subRecord = {
343
+ v: text,
344
+ i: item.i,
345
+ n: this.norm.get(text)
346
+ };
347
+ subRecords.push(subRecord);
348
+ }
349
+ }
350
+ }
351
+ record.$[keyIndex] = subRecords;
352
+ } else if (isString(value) && !isBlank(value)) {
353
+ const subRecord = {
354
+ v: value,
355
+ n: this.norm.get(value)
356
+ };
357
+ record.$[keyIndex] = subRecord;
358
+ }
359
+ }
360
+ return record;
361
+ }
362
+ toJSON() {
363
+ return {
364
+ keys: this.keys.map(({ getFn, ...key }) => key),
365
+ records: this.records
366
+ };
367
+ }
368
+ };
369
+ function createIndex(keys, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
370
+ const myIndex = new FuseIndex({
371
+ getFn,
372
+ fieldNormWeight
373
+ });
374
+ myIndex.setKeys(keys.map(createKey));
375
+ myIndex.setSources(docs);
376
+ myIndex.create();
377
+ return myIndex;
480
378
  }
481
-
482
- function parseIndex(
483
- data,
484
- { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
485
- ) {
486
- const { keys, records } = data;
487
- const myIndex = new FuseIndex({ getFn, fieldNormWeight });
488
- myIndex.setKeys(keys);
489
- myIndex.setIndexRecords(records);
490
- return myIndex
379
+ function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
380
+ const { keys, records } = data;
381
+ const myIndex = new FuseIndex({
382
+ getFn,
383
+ fieldNormWeight
384
+ });
385
+ myIndex.setKeys(keys);
386
+ myIndex.setIndexRecords(records);
387
+ return myIndex;
491
388
  }
492
389
 
493
- function computeScore$1(
494
- pattern,
495
- {
496
- errors = 0,
497
- currentLocation = 0,
498
- expectedLocation = 0,
499
- distance = Config.distance,
500
- ignoreLocation = Config.ignoreLocation
501
- } = {}
502
- ) {
503
- const accuracy = errors / pattern.length;
504
-
505
- if (ignoreLocation) {
506
- return accuracy
507
- }
508
-
509
- const proximity = Math.abs(expectedLocation - currentLocation);
510
-
511
- if (!distance) {
512
- // Dodge divide by zero error.
513
- return proximity ? 1.0 : accuracy
514
- }
515
-
516
- return accuracy + proximity / distance
390
+ //#endregion
391
+ //#region src/search/bitap/convertMaskToIndices.ts
392
+ function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) {
393
+ const indices = [];
394
+ let start = -1;
395
+ let end = -1;
396
+ let i = 0;
397
+ for (let len = matchmask.length; i < len; i += 1) {
398
+ const match = matchmask[i];
399
+ if (match && start === -1) start = i;
400
+ else if (!match && start !== -1) {
401
+ end = i - 1;
402
+ if (end - start + 1 >= minMatchCharLength) indices.push([start, end]);
403
+ start = -1;
404
+ }
405
+ }
406
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) indices.push([start, i - 1]);
407
+ return indices;
517
408
  }
518
409
 
519
- function convertMaskToIndices(
520
- matchmask = [],
521
- minMatchCharLength = Config.minMatchCharLength
522
- ) {
523
- let indices = [];
524
- let start = -1;
525
- let end = -1;
526
- let i = 0;
527
-
528
- for (let len = matchmask.length; i < len; i += 1) {
529
- let match = matchmask[i];
530
- if (match && start === -1) {
531
- start = i;
532
- } else if (!match && start !== -1) {
533
- end = i - 1;
534
- if (end - start + 1 >= minMatchCharLength) {
535
- indices.push([start, end]);
536
- }
537
- start = -1;
538
- }
539
- }
540
-
541
- // (i-1 - start) + 1 => i - start
542
- if (matchmask[i - 1] && i - start >= minMatchCharLength) {
543
- indices.push([start, i - 1]);
544
- }
545
-
546
- return indices
547
- }
548
-
549
- // Machine word size
550
- const MAX_BITS = 32;
551
-
552
- function search(
553
- text,
554
- pattern,
555
- patternAlphabet,
556
- {
557
- location = Config.location,
558
- distance = Config.distance,
559
- threshold = Config.threshold,
560
- findAllMatches = Config.findAllMatches,
561
- minMatchCharLength = Config.minMatchCharLength,
562
- includeMatches = Config.includeMatches,
563
- ignoreLocation = Config.ignoreLocation
564
- } = {}
565
- ) {
566
- if (pattern.length > MAX_BITS) {
567
- throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
568
- }
569
-
570
- const patternLen = pattern.length;
571
- // Set starting location at beginning text and initialize the alphabet.
572
- const textLen = text.length;
573
- // Handle the case when location > text.length
574
- const expectedLocation = Math.max(0, Math.min(location, textLen));
575
- // Highest score beyond which we give up.
576
- let currentThreshold = threshold;
577
- // Is there a nearby exact match? (speedup)
578
- let bestLocation = expectedLocation;
579
-
580
- // Performance: only computer matches when the minMatchCharLength > 1
581
- // OR if `includeMatches` is true.
582
- const computeMatches = minMatchCharLength > 1 || includeMatches;
583
- // A mask of the matches, used for building the indices
584
- const matchMask = computeMatches ? Array(textLen) : [];
585
-
586
- let index;
587
-
588
- // Get all exact matches, here for speed up
589
- while ((index = text.indexOf(pattern, bestLocation)) > -1) {
590
- let score = computeScore$1(pattern, {
591
- currentLocation: index,
592
- expectedLocation,
593
- distance,
594
- ignoreLocation
595
- });
596
-
597
- currentThreshold = Math.min(score, currentThreshold);
598
- bestLocation = index + patternLen;
599
-
600
- if (computeMatches) {
601
- let i = 0;
602
- while (i < patternLen) {
603
- matchMask[index + i] = 1;
604
- i += 1;
605
- }
606
- }
607
- }
608
-
609
- // Reset the best location
610
- bestLocation = -1;
611
-
612
- let lastBitArr = [];
613
- let finalScore = 1;
614
- let binMax = patternLen + textLen;
615
-
616
- const mask = 1 << (patternLen - 1);
617
-
618
- for (let i = 0; i < patternLen; i += 1) {
619
- // Scan for the best match; each iteration allows for one more error.
620
- // Run a binary search to determine how far from the match location we can stray
621
- // at this error level.
622
- let binMin = 0;
623
- let binMid = binMax;
624
-
625
- while (binMin < binMid) {
626
- const score = computeScore$1(pattern, {
627
- errors: i,
628
- currentLocation: expectedLocation + binMid,
629
- expectedLocation,
630
- distance,
631
- ignoreLocation
632
- });
633
-
634
- if (score <= currentThreshold) {
635
- binMin = binMid;
636
- } else {
637
- binMax = binMid;
638
- }
639
-
640
- binMid = Math.floor((binMax - binMin) / 2 + binMin);
641
- }
642
-
643
- // Use the result from this iteration as the maximum for the next.
644
- binMax = binMid;
645
-
646
- let start = Math.max(1, expectedLocation - binMid + 1);
647
- let finish = findAllMatches
648
- ? textLen
649
- : Math.min(expectedLocation + binMid, textLen) + patternLen;
650
-
651
- // Initialize the bit array
652
- let bitArr = Array(finish + 2);
653
-
654
- bitArr[finish + 1] = (1 << i) - 1;
655
-
656
- for (let j = finish; j >= start; j -= 1) {
657
- let currentLocation = j - 1;
658
- let charMatch = patternAlphabet[text.charAt(currentLocation)];
659
-
660
- if (computeMatches) {
661
- // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
662
- matchMask[currentLocation] = +!!charMatch;
663
- }
664
-
665
- // First pass: exact match
666
- bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
667
-
668
- // Subsequent passes: fuzzy match
669
- if (i) {
670
- bitArr[j] |=
671
- ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
672
- }
673
-
674
- if (bitArr[j] & mask) {
675
- finalScore = computeScore$1(pattern, {
676
- errors: i,
677
- currentLocation,
678
- expectedLocation,
679
- distance,
680
- ignoreLocation
681
- });
682
-
683
- // This match will almost certainly be better than any existing match.
684
- // But check anyway.
685
- if (finalScore <= currentThreshold) {
686
- // Indeed it is
687
- currentThreshold = finalScore;
688
- bestLocation = currentLocation;
689
-
690
- // Already passed `loc`, downhill from here on in.
691
- if (bestLocation <= expectedLocation) {
692
- break
693
- }
694
-
695
- // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
696
- start = Math.max(1, 2 * expectedLocation - bestLocation);
697
- }
698
- }
699
- }
700
-
701
- // No hope for a (better) match at greater error levels.
702
- const score = computeScore$1(pattern, {
703
- errors: i + 1,
704
- currentLocation: expectedLocation,
705
- expectedLocation,
706
- distance,
707
- ignoreLocation
708
- });
709
-
710
- if (score > currentThreshold) {
711
- break
712
- }
713
-
714
- lastBitArr = bitArr;
715
- }
716
-
717
- const result = {
718
- isMatch: bestLocation >= 0,
719
- // Count exact matches (those with a score of 0) to be "almost" exact
720
- score: Math.max(0.001, finalScore)
721
- };
722
-
723
- if (computeMatches) {
724
- const indices = convertMaskToIndices(matchMask, minMatchCharLength);
725
- if (!indices.length) {
726
- result.isMatch = false;
727
- } else if (includeMatches) {
728
- result.indices = indices;
729
- }
730
- }
731
-
732
- return result
410
+ //#endregion
411
+ //#region src/search/bitap/search.ts
412
+ function search(text, pattern, patternAlphabet, { location = Config.location, distance = Config.distance, threshold = Config.threshold, findAllMatches = Config.findAllMatches, minMatchCharLength = Config.minMatchCharLength, includeMatches = Config.includeMatches, ignoreLocation = Config.ignoreLocation } = {}) {
413
+ if (pattern.length > 32) throw new Error(PATTERN_LENGTH_TOO_LARGE(32));
414
+ const patternLen = pattern.length;
415
+ const textLen = text.length;
416
+ const expectedLocation = Math.max(0, Math.min(location, textLen));
417
+ let currentThreshold = threshold;
418
+ let bestLocation = expectedLocation;
419
+ const calcScore = (errors, currentLocation) => {
420
+ const accuracy = errors / patternLen;
421
+ if (ignoreLocation) return accuracy;
422
+ const proximity = Math.abs(expectedLocation - currentLocation);
423
+ if (!distance) return proximity ? 1 : accuracy;
424
+ return accuracy + proximity / distance;
425
+ };
426
+ const computeMatches = minMatchCharLength > 1 || includeMatches;
427
+ const matchMask = computeMatches ? Array(textLen) : [];
428
+ let index;
429
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
430
+ const score = calcScore(0, index);
431
+ currentThreshold = Math.min(score, currentThreshold);
432
+ bestLocation = index + patternLen;
433
+ if (computeMatches) {
434
+ let i = 0;
435
+ while (i < patternLen) {
436
+ matchMask[index + i] = 1;
437
+ i += 1;
438
+ }
439
+ }
440
+ }
441
+ bestLocation = -1;
442
+ let lastBitArr = [];
443
+ let finalScore = 1;
444
+ let bestErrors = 0;
445
+ let binMax = patternLen + textLen;
446
+ const mask = 1 << patternLen - 1;
447
+ for (let i = 0; i < patternLen; i += 1) {
448
+ let binMin = 0;
449
+ let binMid = binMax;
450
+ while (binMin < binMid) {
451
+ if (calcScore(i, expectedLocation + binMid) <= currentThreshold) binMin = binMid;
452
+ else binMax = binMid;
453
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
454
+ }
455
+ binMax = binMid;
456
+ let start = Math.max(1, expectedLocation - binMid + 1);
457
+ const finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
458
+ const bitArr = Array(finish + 2);
459
+ bitArr[finish + 1] = (1 << i) - 1;
460
+ for (let j = finish; j >= start; j -= 1) {
461
+ const currentLocation = j - 1;
462
+ const charMatch = patternAlphabet[text[currentLocation]];
463
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
464
+ if (i) bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
465
+ if (bitArr[j] & mask) {
466
+ finalScore = calcScore(i, currentLocation);
467
+ if (finalScore <= currentThreshold) {
468
+ currentThreshold = finalScore;
469
+ bestLocation = currentLocation;
470
+ bestErrors = i;
471
+ if (bestLocation <= expectedLocation) break;
472
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
473
+ }
474
+ }
475
+ }
476
+ if (calcScore(i + 1, expectedLocation) > currentThreshold) break;
477
+ lastBitArr = bitArr;
478
+ }
479
+ if (computeMatches && bestLocation >= 0) {
480
+ const matchEnd = Math.min(textLen - 1, bestLocation + patternLen - 1 + bestErrors);
481
+ for (let k = bestLocation; k <= matchEnd; k += 1) if (patternAlphabet[text[k]]) matchMask[k] = 1;
482
+ }
483
+ const result = {
484
+ isMatch: bestLocation >= 0,
485
+ score: Math.max(.001, finalScore)
486
+ };
487
+ if (computeMatches) {
488
+ const indices = convertMaskToIndices(matchMask, minMatchCharLength);
489
+ if (!indices.length) result.isMatch = false;
490
+ else if (includeMatches) result.indices = indices;
491
+ }
492
+ return result;
733
493
  }
734
494
 
495
+ //#endregion
496
+ //#region src/search/bitap/createPatternAlphabet.ts
735
497
  function createPatternAlphabet(pattern) {
736
- let mask = {};
737
-
738
- for (let i = 0, len = pattern.length; i < len; i += 1) {
739
- const char = pattern.charAt(i);
740
- mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
741
- }
742
-
743
- return mask
744
- }
745
-
746
- const stripDiacritics = String.prototype.normalize
747
- ? ((str) => str.normalize('NFD').replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, ''))
748
- : ((str) => str);
749
-
750
- class BitapSearch {
751
- constructor(
752
- pattern,
753
- {
754
- location = Config.location,
755
- threshold = Config.threshold,
756
- distance = Config.distance,
757
- includeMatches = Config.includeMatches,
758
- findAllMatches = Config.findAllMatches,
759
- minMatchCharLength = Config.minMatchCharLength,
760
- isCaseSensitive = Config.isCaseSensitive,
761
- ignoreDiacritics = Config.ignoreDiacritics,
762
- ignoreLocation = Config.ignoreLocation
763
- } = {}
764
- ) {
765
- this.options = {
766
- location,
767
- threshold,
768
- distance,
769
- includeMatches,
770
- findAllMatches,
771
- minMatchCharLength,
772
- isCaseSensitive,
773
- ignoreDiacritics,
774
- ignoreLocation
775
- };
776
-
777
- pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
778
- pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
779
- this.pattern = pattern;
780
-
781
- this.chunks = [];
782
-
783
- if (!this.pattern.length) {
784
- return
785
- }
786
-
787
- const addChunk = (pattern, startIndex) => {
788
- this.chunks.push({
789
- pattern,
790
- alphabet: createPatternAlphabet(pattern),
791
- startIndex
792
- });
793
- };
794
-
795
- const len = this.pattern.length;
796
-
797
- if (len > MAX_BITS) {
798
- let i = 0;
799
- const remainder = len % MAX_BITS;
800
- const end = len - remainder;
801
-
802
- while (i < end) {
803
- addChunk(this.pattern.substr(i, MAX_BITS), i);
804
- i += MAX_BITS;
805
- }
806
-
807
- if (remainder) {
808
- const startIndex = len - MAX_BITS;
809
- addChunk(this.pattern.substr(startIndex), startIndex);
810
- }
811
- } else {
812
- addChunk(this.pattern, 0);
813
- }
814
- }
815
-
816
- searchIn(text) {
817
- const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
818
-
819
- text = isCaseSensitive ? text : text.toLowerCase();
820
- text = ignoreDiacritics ? stripDiacritics(text) : text;
821
-
822
- // Exact match
823
- if (this.pattern === text) {
824
- let result = {
825
- isMatch: true,
826
- score: 0
827
- };
828
-
829
- if (includeMatches) {
830
- result.indices = [[0, text.length - 1]];
831
- }
832
-
833
- return result
834
- }
835
-
836
- // Otherwise, use Bitap algorithm
837
- const {
838
- location,
839
- distance,
840
- threshold,
841
- findAllMatches,
842
- minMatchCharLength,
843
- ignoreLocation
844
- } = this.options;
845
-
846
- let allIndices = [];
847
- let totalScore = 0;
848
- let hasMatches = false;
849
-
850
- this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
851
- const { isMatch, score, indices } = search(text, pattern, alphabet, {
852
- location: location + startIndex,
853
- distance,
854
- threshold,
855
- findAllMatches,
856
- minMatchCharLength,
857
- includeMatches,
858
- ignoreLocation
859
- });
860
-
861
- if (isMatch) {
862
- hasMatches = true;
863
- }
864
-
865
- totalScore += score;
866
-
867
- if (isMatch && indices) {
868
- allIndices = [...allIndices, ...indices];
869
- }
870
- });
871
-
872
- let result = {
873
- isMatch: hasMatches,
874
- score: hasMatches ? totalScore / this.chunks.length : 1
875
- };
876
-
877
- if (hasMatches && includeMatches) {
878
- result.indices = allIndices;
879
- }
880
-
881
- return result
882
- }
498
+ const mask = {};
499
+ for (let i = 0, len = pattern.length; i < len; i += 1) {
500
+ const char = pattern.charAt(i);
501
+ mask[char] = (mask[char] || 0) | 1 << len - i - 1;
502
+ }
503
+ return mask;
883
504
  }
884
505
 
885
- class BaseMatch {
886
- constructor(pattern) {
887
- this.pattern = pattern;
888
- }
889
- static isMultiMatch(pattern) {
890
- return getMatch(pattern, this.multiRegex)
891
- }
892
- static isSingleMatch(pattern) {
893
- return getMatch(pattern, this.singleRegex)
894
- }
895
- search(/*text*/) {}
506
+ //#endregion
507
+ //#region src/helpers/mergeIndices.ts
508
+ function mergeIndices(indices) {
509
+ if (indices.length <= 1) return indices;
510
+ indices.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
511
+ const merged = [indices[0]];
512
+ for (let i = 1, len = indices.length; i < len; i += 1) {
513
+ const last = merged[merged.length - 1];
514
+ const curr = indices[i];
515
+ if (curr[0] <= last[1] + 1) last[1] = Math.max(last[1], curr[1]);
516
+ else merged.push(curr);
517
+ }
518
+ return merged;
896
519
  }
897
520
 
898
- function getMatch(pattern, exp) {
899
- const matches = pattern.match(exp);
900
- return matches ? matches[1] : null
901
- }
902
-
903
- // Token: 'file
904
-
905
- class ExactMatch extends BaseMatch {
906
- constructor(pattern) {
907
- super(pattern);
908
- }
909
- static get type() {
910
- return 'exact'
911
- }
912
- static get multiRegex() {
913
- return /^="(.*)"$/
914
- }
915
- static get singleRegex() {
916
- return /^=(.*)$/
917
- }
918
- search(text) {
919
- const isMatch = text === this.pattern;
920
-
921
- return {
922
- isMatch,
923
- score: isMatch ? 0 : 1,
924
- indices: [0, this.pattern.length - 1]
925
- }
926
- }
927
- }
928
-
929
- // Token: !fire
930
-
931
- class InverseExactMatch extends BaseMatch {
932
- constructor(pattern) {
933
- super(pattern);
934
- }
935
- static get type() {
936
- return 'inverse-exact'
937
- }
938
- static get multiRegex() {
939
- return /^!"(.*)"$/
940
- }
941
- static get singleRegex() {
942
- return /^!(.*)$/
943
- }
944
- search(text) {
945
- const index = text.indexOf(this.pattern);
946
- const isMatch = index === -1;
947
-
948
- return {
949
- isMatch,
950
- score: isMatch ? 0 : 1,
951
- indices: [0, text.length - 1]
952
- }
953
- }
954
- }
955
-
956
- // Token: ^file
957
-
958
- class PrefixExactMatch extends BaseMatch {
959
- constructor(pattern) {
960
- super(pattern);
961
- }
962
- static get type() {
963
- return 'prefix-exact'
964
- }
965
- static get multiRegex() {
966
- return /^\^"(.*)"$/
967
- }
968
- static get singleRegex() {
969
- return /^\^(.*)$/
970
- }
971
- search(text) {
972
- const isMatch = text.startsWith(this.pattern);
973
-
974
- return {
975
- isMatch,
976
- score: isMatch ? 0 : 1,
977
- indices: [0, this.pattern.length - 1]
978
- }
979
- }
980
- }
981
-
982
- // Token: !^fire
983
-
984
- class InversePrefixExactMatch extends BaseMatch {
985
- constructor(pattern) {
986
- super(pattern);
987
- }
988
- static get type() {
989
- return 'inverse-prefix-exact'
990
- }
991
- static get multiRegex() {
992
- return /^!\^"(.*)"$/
993
- }
994
- static get singleRegex() {
995
- return /^!\^(.*)$/
996
- }
997
- search(text) {
998
- const isMatch = !text.startsWith(this.pattern);
999
-
1000
- return {
1001
- isMatch,
1002
- score: isMatch ? 0 : 1,
1003
- indices: [0, text.length - 1]
1004
- }
1005
- }
1006
- }
1007
-
1008
- // Token: .file$
1009
-
1010
- class SuffixExactMatch extends BaseMatch {
1011
- constructor(pattern) {
1012
- super(pattern);
1013
- }
1014
- static get type() {
1015
- return 'suffix-exact'
1016
- }
1017
- static get multiRegex() {
1018
- return /^"(.*)"\$$/
1019
- }
1020
- static get singleRegex() {
1021
- return /^(.*)\$$/
1022
- }
1023
- search(text) {
1024
- const isMatch = text.endsWith(this.pattern);
1025
-
1026
- return {
1027
- isMatch,
1028
- score: isMatch ? 0 : 1,
1029
- indices: [text.length - this.pattern.length, text.length - 1]
1030
- }
1031
- }
1032
- }
1033
-
1034
- // Token: !.file$
521
+ //#endregion
522
+ //#region src/helpers/diacritics.ts
523
+ const NON_DECOMPOSABLE_MAP = {
524
+ "ł": "l",
525
+ "Ł": "L",
526
+ "đ": "d",
527
+ "Đ": "D",
528
+ "ø": "o",
529
+ "Ø": "O",
530
+ "ħ": "h",
531
+ "Ħ": "H",
532
+ "ŧ": "t",
533
+ "Ŧ": "T",
534
+ "ı": "i",
535
+ "ß": "ss"
536
+ };
537
+ const NON_DECOMPOSABLE_RE = new RegExp("[" + Object.keys(NON_DECOMPOSABLE_MAP).join("") + "]", "g");
538
+ const stripDiacritics = typeof String.prototype.normalize === "function" ? (str) => str.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g, "").replace(NON_DECOMPOSABLE_RE, (ch) => NON_DECOMPOSABLE_MAP[ch]) : (str) => str;
539
+
540
+ //#endregion
541
+ //#region src/search/bitap/index.ts
542
+ var BitapSearch = class {
543
+ constructor(pattern, { location = Config.location, threshold = Config.threshold, distance = Config.distance, includeMatches = Config.includeMatches, findAllMatches = Config.findAllMatches, minMatchCharLength = Config.minMatchCharLength, isCaseSensitive = Config.isCaseSensitive, ignoreDiacritics = Config.ignoreDiacritics, ignoreLocation = Config.ignoreLocation } = {}) {
544
+ this.options = {
545
+ location,
546
+ threshold,
547
+ distance,
548
+ includeMatches,
549
+ findAllMatches,
550
+ minMatchCharLength,
551
+ isCaseSensitive,
552
+ ignoreDiacritics,
553
+ ignoreLocation
554
+ };
555
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
556
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
557
+ this.pattern = pattern;
558
+ this.chunks = [];
559
+ if (!this.pattern.length) return;
560
+ const addChunk = (pattern, startIndex) => {
561
+ this.chunks.push({
562
+ pattern,
563
+ alphabet: createPatternAlphabet(pattern),
564
+ startIndex
565
+ });
566
+ };
567
+ const len = this.pattern.length;
568
+ if (len > 32) {
569
+ let i = 0;
570
+ const remainder = len % 32;
571
+ const end = len - remainder;
572
+ while (i < end) {
573
+ addChunk(this.pattern.substr(i, 32), i);
574
+ i += 32;
575
+ }
576
+ if (remainder) {
577
+ const startIndex = len - 32;
578
+ addChunk(this.pattern.substr(startIndex), startIndex);
579
+ }
580
+ } else addChunk(this.pattern, 0);
581
+ }
582
+ searchIn(text) {
583
+ const { isCaseSensitive, ignoreDiacritics, includeMatches } = this.options;
584
+ text = isCaseSensitive ? text : text.toLowerCase();
585
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
586
+ if (this.pattern === text) {
587
+ const result = {
588
+ isMatch: true,
589
+ score: 0
590
+ };
591
+ if (includeMatches) result.indices = [[0, text.length - 1]];
592
+ return result;
593
+ }
594
+ const { location, distance, threshold, findAllMatches, minMatchCharLength, ignoreLocation } = this.options;
595
+ const allIndices = [];
596
+ let totalScore = 0;
597
+ let hasMatches = false;
598
+ this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
599
+ const { isMatch, score, indices } = search(text, pattern, alphabet, {
600
+ location: location + startIndex,
601
+ distance,
602
+ threshold,
603
+ findAllMatches,
604
+ minMatchCharLength,
605
+ includeMatches,
606
+ ignoreLocation
607
+ });
608
+ if (isMatch) hasMatches = true;
609
+ totalScore += score;
610
+ if (isMatch && indices) allIndices.push(...indices);
611
+ });
612
+ const result = {
613
+ isMatch: hasMatches,
614
+ score: hasMatches ? totalScore / this.chunks.length : 1
615
+ };
616
+ if (hasMatches && includeMatches) result.indices = mergeIndices(allIndices);
617
+ return result;
618
+ }
619
+ };
1035
620
 
1036
- class InverseSuffixExactMatch extends BaseMatch {
1037
- constructor(pattern) {
1038
- super(pattern);
1039
- }
1040
- static get type() {
1041
- return 'inverse-suffix-exact'
1042
- }
1043
- static get multiRegex() {
1044
- return /^!"(.*)"\$$/
1045
- }
1046
- static get singleRegex() {
1047
- return /^!(.*)\$$/
1048
- }
1049
- search(text) {
1050
- const isMatch = !text.endsWith(this.pattern);
1051
- return {
1052
- isMatch,
1053
- score: isMatch ? 0 : 1,
1054
- indices: [0, text.length - 1]
1055
- }
1056
- }
621
+ //#endregion
622
+ //#region src/search/extended/matchers.ts
623
+ const MULTI_MATCH_TYPES = new Set(["fuzzy", "include"]);
624
+ function isInverse(type) {
625
+ return type.startsWith("inverse");
1057
626
  }
627
+ const matchers = [
628
+ {
629
+ type: "exact",
630
+ multiRegex: /^="(.*)"$/,
631
+ singleRegex: /^=(.*)$/,
632
+ create: (pattern) => ({
633
+ type: "exact",
634
+ search(text) {
635
+ const isMatch = text === pattern;
636
+ return {
637
+ isMatch,
638
+ score: isMatch ? 0 : 1,
639
+ indices: [0, pattern.length - 1]
640
+ };
641
+ }
642
+ })
643
+ },
644
+ {
645
+ type: "include",
646
+ multiRegex: /^'"(.*)"$/,
647
+ singleRegex: /^'(.*)$/,
648
+ create: (pattern) => ({
649
+ type: "include",
650
+ search(text) {
651
+ let location = 0;
652
+ let index;
653
+ const indices = [];
654
+ const patternLen = pattern.length;
655
+ while ((index = text.indexOf(pattern, location)) > -1) {
656
+ location = index + patternLen;
657
+ indices.push([index, location - 1]);
658
+ }
659
+ const isMatch = !!indices.length;
660
+ return {
661
+ isMatch,
662
+ score: isMatch ? 0 : 1,
663
+ indices
664
+ };
665
+ }
666
+ })
667
+ },
668
+ {
669
+ type: "prefix-exact",
670
+ multiRegex: /^\^"(.*)"$/,
671
+ singleRegex: /^\^(.*)$/,
672
+ create: (pattern) => ({
673
+ type: "prefix-exact",
674
+ search(text) {
675
+ const isMatch = text.startsWith(pattern);
676
+ return {
677
+ isMatch,
678
+ score: isMatch ? 0 : 1,
679
+ indices: [0, pattern.length - 1]
680
+ };
681
+ }
682
+ })
683
+ },
684
+ {
685
+ type: "inverse-prefix-exact",
686
+ multiRegex: /^!\^"(.*)"$/,
687
+ singleRegex: /^!\^(.*)$/,
688
+ create: (pattern) => ({
689
+ type: "inverse-prefix-exact",
690
+ search(text) {
691
+ const isMatch = !text.startsWith(pattern);
692
+ return {
693
+ isMatch,
694
+ score: isMatch ? 0 : 1,
695
+ indices: [0, text.length - 1]
696
+ };
697
+ }
698
+ })
699
+ },
700
+ {
701
+ type: "inverse-suffix-exact",
702
+ multiRegex: /^!"(.*)"\$$/,
703
+ singleRegex: /^!(.*)\$$/,
704
+ create: (pattern) => ({
705
+ type: "inverse-suffix-exact",
706
+ search(text) {
707
+ const isMatch = !text.endsWith(pattern);
708
+ return {
709
+ isMatch,
710
+ score: isMatch ? 0 : 1,
711
+ indices: [0, text.length - 1]
712
+ };
713
+ }
714
+ })
715
+ },
716
+ {
717
+ type: "suffix-exact",
718
+ multiRegex: /^"(.*)"\$$/,
719
+ singleRegex: /^(.*)\$$/,
720
+ create: (pattern) => ({
721
+ type: "suffix-exact",
722
+ search(text) {
723
+ const isMatch = text.endsWith(pattern);
724
+ return {
725
+ isMatch,
726
+ score: isMatch ? 0 : 1,
727
+ indices: [text.length - pattern.length, text.length - 1]
728
+ };
729
+ }
730
+ })
731
+ },
732
+ {
733
+ type: "inverse-exact",
734
+ multiRegex: /^!"(.*)"$/,
735
+ singleRegex: /^!(.*)$/,
736
+ create: (pattern) => ({
737
+ type: "inverse-exact",
738
+ search(text) {
739
+ const isMatch = text.indexOf(pattern) === -1;
740
+ return {
741
+ isMatch,
742
+ score: isMatch ? 0 : 1,
743
+ indices: [0, text.length - 1]
744
+ };
745
+ }
746
+ })
747
+ },
748
+ {
749
+ type: "fuzzy",
750
+ multiRegex: /^"(.*)"$/,
751
+ singleRegex: /^(.*)$/,
752
+ create: (pattern, options = {}) => {
753
+ const bitap = new BitapSearch(pattern, {
754
+ location: options.location ?? Config.location,
755
+ threshold: options.threshold ?? Config.threshold,
756
+ distance: options.distance ?? Config.distance,
757
+ includeMatches: options.includeMatches ?? Config.includeMatches,
758
+ findAllMatches: options.findAllMatches ?? Config.findAllMatches,
759
+ minMatchCharLength: options.minMatchCharLength ?? Config.minMatchCharLength,
760
+ isCaseSensitive: options.isCaseSensitive ?? Config.isCaseSensitive,
761
+ ignoreDiacritics: options.ignoreDiacritics ?? Config.ignoreDiacritics,
762
+ ignoreLocation: options.ignoreLocation ?? Config.ignoreLocation
763
+ });
764
+ return {
765
+ type: "fuzzy",
766
+ search(text) {
767
+ return bitap.searchIn(text);
768
+ }
769
+ };
770
+ }
771
+ }
772
+ ];
1058
773
 
1059
- class FuzzyMatch extends BaseMatch {
1060
- constructor(
1061
- pattern,
1062
- {
1063
- location = Config.location,
1064
- threshold = Config.threshold,
1065
- distance = Config.distance,
1066
- includeMatches = Config.includeMatches,
1067
- findAllMatches = Config.findAllMatches,
1068
- minMatchCharLength = Config.minMatchCharLength,
1069
- isCaseSensitive = Config.isCaseSensitive,
1070
- ignoreDiacritics = Config.ignoreDiacritics,
1071
- ignoreLocation = Config.ignoreLocation
1072
- } = {}
1073
- ) {
1074
- super(pattern);
1075
- this._bitapSearch = new BitapSearch(pattern, {
1076
- location,
1077
- threshold,
1078
- distance,
1079
- includeMatches,
1080
- findAllMatches,
1081
- minMatchCharLength,
1082
- isCaseSensitive,
1083
- ignoreDiacritics,
1084
- ignoreLocation
1085
- });
1086
- }
1087
- static get type() {
1088
- return 'fuzzy'
1089
- }
1090
- static get multiRegex() {
1091
- return /^"(.*)"$/
1092
- }
1093
- static get singleRegex() {
1094
- return /^(.*)$/
1095
- }
1096
- search(text) {
1097
- return this._bitapSearch.searchIn(text)
1098
- }
774
+ //#endregion
775
+ //#region src/search/extended/parseQuery.ts
776
+ const matchersLen = matchers.length;
777
+ const ESCAPED_PIPE = "\0";
778
+ const OR_TOKEN = "|";
779
+ function tokenize(pattern) {
780
+ const tokens = [];
781
+ const len = pattern.length;
782
+ let i = 0;
783
+ while (i < len) {
784
+ while (i < len && pattern[i] === " ") i++;
785
+ if (i >= len) break;
786
+ let j = i;
787
+ while (j < len && pattern[j] !== " " && pattern[j] !== "\"") j++;
788
+ if (j < len && pattern[j] === "\"") {
789
+ j++;
790
+ while (j < len) {
791
+ if (pattern[j] === "\"") {
792
+ const next = j + 1;
793
+ if (next >= len || pattern[next] === " ") {
794
+ j++;
795
+ break;
796
+ }
797
+ if (pattern[next] === "$" && (next + 1 >= len || pattern[next + 1] === " ")) {
798
+ j += 2;
799
+ break;
800
+ }
801
+ }
802
+ j++;
803
+ }
804
+ tokens.push(pattern.substring(i, j));
805
+ i = j;
806
+ } else {
807
+ while (j < len && pattern[j] !== " ") j++;
808
+ tokens.push(pattern.substring(i, j));
809
+ i = j;
810
+ }
811
+ }
812
+ return tokens;
1099
813
  }
1100
-
1101
- // Token: 'file
1102
-
1103
- class IncludeMatch extends BaseMatch {
1104
- constructor(pattern) {
1105
- super(pattern);
1106
- }
1107
- static get type() {
1108
- return 'include'
1109
- }
1110
- static get multiRegex() {
1111
- return /^'"(.*)"$/
1112
- }
1113
- static get singleRegex() {
1114
- return /^'(.*)$/
1115
- }
1116
- search(text) {
1117
- let location = 0;
1118
- let index;
1119
-
1120
- const indices = [];
1121
- const patternLen = this.pattern.length;
1122
-
1123
- // Get all exact matches
1124
- while ((index = text.indexOf(this.pattern, location)) > -1) {
1125
- location = index + patternLen;
1126
- indices.push([index, location - 1]);
1127
- }
1128
-
1129
- const isMatch = !!indices.length;
1130
-
1131
- return {
1132
- isMatch,
1133
- score: isMatch ? 0 : 1,
1134
- indices
1135
- }
1136
- }
814
+ function getMatch(pattern, exp) {
815
+ const matches = pattern.match(exp);
816
+ return matches ? matches[1] : null;
1137
817
  }
1138
-
1139
- // ❗Order is important. DO NOT CHANGE.
1140
- const searchers = [
1141
- ExactMatch,
1142
- IncludeMatch,
1143
- PrefixExactMatch,
1144
- InversePrefixExactMatch,
1145
- InverseSuffixExactMatch,
1146
- SuffixExactMatch,
1147
- InverseExactMatch,
1148
- FuzzyMatch
1149
- ];
1150
-
1151
- const searchersLen = searchers.length;
1152
-
1153
- // Regex to split by spaces, but keep anything in quotes together
1154
- const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
1155
- const OR_TOKEN = '|';
1156
-
1157
- // Return a 2D array representation of the query, for simpler parsing.
1158
- // Example:
1159
- // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
1160
818
  function parseQuery(pattern, options = {}) {
1161
- return pattern.split(OR_TOKEN).map((item) => {
1162
- let query = item
1163
- .trim()
1164
- .split(SPACE_RE)
1165
- .filter((item) => item && !!item.trim());
1166
-
1167
- let results = [];
1168
- for (let i = 0, len = query.length; i < len; i += 1) {
1169
- const queryItem = query[i];
1170
-
1171
- // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
1172
- let found = false;
1173
- let idx = -1;
1174
- while (!found && ++idx < searchersLen) {
1175
- const searcher = searchers[idx];
1176
- let token = searcher.isMultiMatch(queryItem);
1177
- if (token) {
1178
- results.push(new searcher(token, options));
1179
- found = true;
1180
- }
1181
- }
1182
-
1183
- if (found) {
1184
- continue
1185
- }
1186
-
1187
- // 2. Handle single query matches (i.e, once that are *not* quoted)
1188
- idx = -1;
1189
- while (++idx < searchersLen) {
1190
- const searcher = searchers[idx];
1191
- let token = searcher.isSingleMatch(queryItem);
1192
- if (token) {
1193
- results.push(new searcher(token, options));
1194
- break
1195
- }
1196
- }
1197
- }
1198
-
1199
- return results
1200
- })
819
+ return pattern.replace(/\\\|/g, ESCAPED_PIPE).split(OR_TOKEN).map((item) => {
820
+ const query = tokenize(item.replace(/\u0000/g, "|").trim()).filter((item) => item && !!item.trim());
821
+ const results = [];
822
+ for (let i = 0, len = query.length; i < len; i += 1) {
823
+ const queryItem = query[i];
824
+ let found = false;
825
+ let idx = -1;
826
+ while (!found && ++idx < matchersLen) {
827
+ const def = matchers[idx];
828
+ const token = getMatch(queryItem, def.multiRegex);
829
+ if (token) {
830
+ results.push(def.create(token, options));
831
+ found = true;
832
+ }
833
+ }
834
+ if (found) continue;
835
+ idx = -1;
836
+ while (++idx < matchersLen) {
837
+ const def = matchers[idx];
838
+ const token = getMatch(queryItem, def.singleRegex);
839
+ if (token) {
840
+ results.push(def.create(token, options));
841
+ break;
842
+ }
843
+ }
844
+ }
845
+ return results;
846
+ });
1201
847
  }
1202
848
 
1203
- // These extended matchers can return an array of matches, as opposed
1204
- // to a singl match
1205
- const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
1206
-
1207
- /**
1208
- * Command-like searching
1209
- * ======================
1210
- *
1211
- * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
1212
- * search in a given text.
1213
- *
1214
- * Search syntax:
1215
- *
1216
- * | Token | Match type | Description |
1217
- * | ----------- | -------------------------- | -------------------------------------- |
1218
- * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
1219
- * | `=scheme` | exact-match | Items that are `scheme` |
1220
- * | `'python` | include-match | Items that include `python` |
1221
- * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
1222
- * | `^java` | prefix-exact-match | Items that start with `java` |
1223
- * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
1224
- * | `.js$` | suffix-exact-match | Items that end with `.js` |
1225
- * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
1226
- *
1227
- * A single pipe character acts as an OR operator. For example, the following
1228
- * query matches entries that start with `core` and end with either`go`, `rb`,
1229
- * or`py`.
1230
- *
1231
- * ```
1232
- * ^core go$ | rb$ | py$
1233
- * ```
1234
- */
1235
- class ExtendedSearch {
1236
- constructor(
1237
- pattern,
1238
- {
1239
- isCaseSensitive = Config.isCaseSensitive,
1240
- ignoreDiacritics = Config.ignoreDiacritics,
1241
- includeMatches = Config.includeMatches,
1242
- minMatchCharLength = Config.minMatchCharLength,
1243
- ignoreLocation = Config.ignoreLocation,
1244
- findAllMatches = Config.findAllMatches,
1245
- location = Config.location,
1246
- threshold = Config.threshold,
1247
- distance = Config.distance
1248
- } = {}
1249
- ) {
1250
- this.query = null;
1251
- this.options = {
1252
- isCaseSensitive,
1253
- ignoreDiacritics,
1254
- includeMatches,
1255
- minMatchCharLength,
1256
- findAllMatches,
1257
- ignoreLocation,
1258
- location,
1259
- threshold,
1260
- distance
1261
- };
1262
-
1263
- pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
1264
- pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
1265
- this.pattern = pattern;
1266
- this.query = parseQuery(this.pattern, this.options);
1267
- }
1268
-
1269
- static condition(_, options) {
1270
- return options.useExtendedSearch
1271
- }
1272
-
1273
- searchIn(text) {
1274
- const query = this.query;
1275
-
1276
- if (!query) {
1277
- return {
1278
- isMatch: false,
1279
- score: 1
1280
- }
1281
- }
1282
-
1283
- const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
1284
-
1285
- text = isCaseSensitive ? text : text.toLowerCase();
1286
- text = ignoreDiacritics ? stripDiacritics(text) : text;
1287
-
1288
- let numMatches = 0;
1289
- let allIndices = [];
1290
- let totalScore = 0;
1291
-
1292
- // ORs
1293
- for (let i = 0, qLen = query.length; i < qLen; i += 1) {
1294
- const searchers = query[i];
1295
-
1296
- // Reset indices
1297
- allIndices.length = 0;
1298
- numMatches = 0;
1299
-
1300
- // ANDs
1301
- for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
1302
- const searcher = searchers[j];
1303
- const { isMatch, indices, score } = searcher.search(text);
1304
-
1305
- if (isMatch) {
1306
- numMatches += 1;
1307
- totalScore += score;
1308
- if (includeMatches) {
1309
- const type = searcher.constructor.type;
1310
- if (MultiMatchSet.has(type)) {
1311
- allIndices = [...allIndices, ...indices];
1312
- } else {
1313
- allIndices.push(indices);
1314
- }
1315
- }
1316
- } else {
1317
- totalScore = 0;
1318
- numMatches = 0;
1319
- allIndices.length = 0;
1320
- break
1321
- }
1322
- }
1323
-
1324
- // OR condition, so if TRUE, return
1325
- if (numMatches) {
1326
- let result = {
1327
- isMatch: true,
1328
- score: totalScore / numMatches
1329
- };
1330
-
1331
- if (includeMatches) {
1332
- result.indices = allIndices;
1333
- }
1334
-
1335
- return result
1336
- }
1337
- }
1338
-
1339
- // Nothing was matched
1340
- return {
1341
- isMatch: false,
1342
- score: 1
1343
- }
1344
- }
1345
- }
849
+ //#endregion
850
+ //#region src/search/extended/index.ts
851
+ var ExtendedSearch = class {
852
+ constructor(pattern, { isCaseSensitive = Config.isCaseSensitive, ignoreDiacritics = Config.ignoreDiacritics, includeMatches = Config.includeMatches, minMatchCharLength = Config.minMatchCharLength, ignoreLocation = Config.ignoreLocation, findAllMatches = Config.findAllMatches, location = Config.location, threshold = Config.threshold, distance = Config.distance } = {}) {
853
+ this.query = null;
854
+ this.options = {
855
+ isCaseSensitive,
856
+ ignoreDiacritics,
857
+ includeMatches,
858
+ minMatchCharLength,
859
+ findAllMatches,
860
+ ignoreLocation,
861
+ location,
862
+ threshold,
863
+ distance
864
+ };
865
+ pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
866
+ pattern = ignoreDiacritics ? stripDiacritics(pattern) : pattern;
867
+ this.pattern = pattern;
868
+ this.query = parseQuery(this.pattern, this.options);
869
+ }
870
+ static condition(_, options) {
871
+ return options.useExtendedSearch;
872
+ }
873
+ searchIn(text) {
874
+ const query = this.query;
875
+ if (!query) return {
876
+ isMatch: false,
877
+ score: 1
878
+ };
879
+ const { includeMatches, isCaseSensitive, ignoreDiacritics } = this.options;
880
+ text = isCaseSensitive ? text : text.toLowerCase();
881
+ text = ignoreDiacritics ? stripDiacritics(text) : text;
882
+ let numMatches = 0;
883
+ const allIndices = [];
884
+ let totalScore = 0;
885
+ let hasInverse = false;
886
+ for (let i = 0, qLen = query.length; i < qLen; i += 1) {
887
+ const searchers = query[i];
888
+ allIndices.length = 0;
889
+ numMatches = 0;
890
+ hasInverse = false;
891
+ for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
892
+ const matcher = searchers[j];
893
+ const { isMatch, indices, score } = matcher.search(text);
894
+ if (isMatch) {
895
+ numMatches += 1;
896
+ totalScore += score;
897
+ if (isInverse(matcher.type)) hasInverse = true;
898
+ if (includeMatches) if (MULTI_MATCH_TYPES.has(matcher.type)) allIndices.push(...indices);
899
+ else allIndices.push(indices);
900
+ } else {
901
+ totalScore = 0;
902
+ numMatches = 0;
903
+ allIndices.length = 0;
904
+ hasInverse = false;
905
+ break;
906
+ }
907
+ }
908
+ if (numMatches) {
909
+ const result = {
910
+ isMatch: true,
911
+ score: totalScore / numMatches
912
+ };
913
+ if (hasInverse) result.hasInverse = true;
914
+ if (includeMatches) result.indices = mergeIndices(allIndices);
915
+ return result;
916
+ }
917
+ }
918
+ return {
919
+ isMatch: false,
920
+ score: 1
921
+ };
922
+ }
923
+ };
1346
924
 
925
+ //#endregion
926
+ //#region src/core/register.ts
1347
927
  const registeredSearchers = [];
1348
-
1349
928
  function register(...args) {
1350
- registeredSearchers.push(...args);
929
+ registeredSearchers.push(...args);
1351
930
  }
1352
-
1353
931
  function createSearcher(pattern, options) {
1354
- for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
1355
- let searcherClass = registeredSearchers[i];
1356
- if (searcherClass.condition(pattern, options)) {
1357
- return new searcherClass(pattern, options)
1358
- }
1359
- }
1360
-
1361
- return new BitapSearch(pattern, options)
932
+ for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
933
+ const searcherClass = registeredSearchers[i];
934
+ if (searcherClass.condition(pattern, options)) return new searcherClass(pattern, options);
935
+ }
936
+ return new BitapSearch(pattern, options);
1362
937
  }
1363
938
 
939
+ //#endregion
940
+ //#region src/core/queryParser.ts
1364
941
  const LogicalOperator = {
1365
- AND: '$and',
1366
- OR: '$or'
942
+ AND: "$and",
943
+ OR: "$or"
1367
944
  };
1368
-
1369
945
  const KeyType = {
1370
- PATH: '$path',
1371
- PATTERN: '$val'
946
+ PATH: "$path",
947
+ PATTERN: "$val"
1372
948
  };
1373
-
1374
- const isExpression = (query) =>
1375
- !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1376
-
949
+ const isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1377
950
  const isPath = (query) => !!query[KeyType.PATH];
1378
-
1379
- const isLeaf = (query) =>
1380
- !isArray(query) && isObject(query) && !isExpression(query);
1381
-
1382
- const convertToExplicit = (query) => ({
1383
- [LogicalOperator.AND]: Object.keys(query).map((key) => ({
1384
- [key]: query[key]
1385
- }))
1386
- });
1387
-
1388
- // When `auto` is `true`, the parse function will infer and initialize and add
1389
- // the appropriate `Searcher` instance
951
+ const isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query);
952
+ const convertToExplicit = (query) => ({ [LogicalOperator.AND]: Object.keys(query).map((key) => ({ [key]: query[key] })) });
1390
953
  function parse(query, options, { auto = true } = {}) {
1391
- const next = (query) => {
1392
- let keys = Object.keys(query);
1393
-
1394
- const isQueryPath = isPath(query);
1395
-
1396
- if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
1397
- return next(convertToExplicit(query))
1398
- }
1399
-
1400
- if (isLeaf(query)) {
1401
- const key = isQueryPath ? query[KeyType.PATH] : keys[0];
1402
-
1403
- const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
1404
-
1405
- if (!isString(pattern)) {
1406
- throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
1407
- }
1408
-
1409
- const obj = {
1410
- keyId: createKeyId(key),
1411
- pattern
1412
- };
1413
-
1414
- if (auto) {
1415
- obj.searcher = createSearcher(pattern, options);
1416
- }
1417
-
1418
- return obj
1419
- }
1420
-
1421
- let node = {
1422
- children: [],
1423
- operator: keys[0]
1424
- };
1425
-
1426
- keys.forEach((key) => {
1427
- const value = query[key];
1428
-
1429
- if (isArray(value)) {
1430
- value.forEach((item) => {
1431
- node.children.push(next(item));
1432
- });
1433
- }
1434
- });
1435
-
1436
- return node
1437
- };
1438
-
1439
- if (!isExpression(query)) {
1440
- query = convertToExplicit(query);
1441
- }
1442
-
1443
- return next(query)
954
+ const next = (query) => {
955
+ if (isString(query)) {
956
+ const obj = {
957
+ keyId: null,
958
+ pattern: query
959
+ };
960
+ if (auto) obj.searcher = createSearcher(query, options);
961
+ return obj;
962
+ }
963
+ const keys = Object.keys(query);
964
+ const isQueryPath = isPath(query);
965
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) return next(convertToExplicit(query));
966
+ if (isLeaf(query)) {
967
+ const key = isQueryPath ? query[KeyType.PATH] : keys[0];
968
+ const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
969
+ if (!isString(pattern)) throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
970
+ const obj = {
971
+ keyId: createKeyId(key),
972
+ pattern
973
+ };
974
+ if (auto) obj.searcher = createSearcher(pattern, options);
975
+ return obj;
976
+ }
977
+ const node = {
978
+ children: [],
979
+ operator: keys[0]
980
+ };
981
+ keys.forEach((key) => {
982
+ const value = query[key];
983
+ if (isArray(value)) value.forEach((item) => {
984
+ node.children.push(next(item));
985
+ });
986
+ });
987
+ return node;
988
+ };
989
+ if (!isExpression(query)) query = convertToExplicit(query);
990
+ return next(query);
1444
991
  }
1445
992
 
1446
- // Practical scoring function
1447
- function computeScore(
1448
- results,
1449
- { ignoreFieldNorm = Config.ignoreFieldNorm }
1450
- ) {
1451
- results.forEach((result) => {
1452
- let totalScore = 1;
1453
-
1454
- result.matches.forEach(({ key, norm, score }) => {
1455
- const weight = key ? key.weight : null;
1456
-
1457
- totalScore *= Math.pow(
1458
- score === 0 && weight ? Number.EPSILON : score,
1459
- (weight || 1) * (ignoreFieldNorm ? 1 : norm)
1460
- );
1461
- });
1462
-
1463
- result.score = totalScore;
1464
- });
993
+ //#endregion
994
+ //#region src/core/computeScore.ts
995
+ function computeScoreSingle(matches, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
996
+ let totalScore = 1;
997
+ matches.forEach(({ key, norm, score }) => {
998
+ const weight = key ? key.weight : null;
999
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
1000
+ });
1001
+ return totalScore;
1002
+ }
1003
+ function computeScore(results, { ignoreFieldNorm = Config.ignoreFieldNorm }) {
1004
+ results.forEach((result) => {
1005
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1006
+ });
1465
1007
  }
1466
1008
 
1467
- function transformMatches(result, data) {
1468
- const matches = result.matches;
1469
- data.matches = [];
1470
-
1471
- if (!isDefined(matches)) {
1472
- return
1473
- }
1474
-
1475
- matches.forEach((match) => {
1476
- if (!isDefined(match.indices) || !match.indices.length) {
1477
- return
1478
- }
1479
-
1480
- const { indices, value } = match;
1481
-
1482
- let obj = {
1483
- indices,
1484
- value
1485
- };
1486
-
1487
- if (match.key) {
1488
- obj.key = match.key.src;
1489
- }
1490
-
1491
- if (match.idx > -1) {
1492
- obj.refIndex = match.idx;
1493
- }
1009
+ //#endregion
1010
+ //#region src/tools/MaxHeap.ts
1011
+ var MaxHeap = class {
1012
+ constructor(limit) {
1013
+ this.limit = limit;
1014
+ this.heap = [];
1015
+ }
1016
+ get size() {
1017
+ return this.heap.length;
1018
+ }
1019
+ shouldInsert(score) {
1020
+ return this.size < this.limit || score < this.heap[0].score;
1021
+ }
1022
+ insert(item) {
1023
+ if (this.size < this.limit) {
1024
+ this.heap.push(item);
1025
+ this._bubbleUp(this.size - 1);
1026
+ } else if (item.score < this.heap[0].score) {
1027
+ this.heap[0] = item;
1028
+ this._sinkDown(0);
1029
+ }
1030
+ }
1031
+ extractSorted(sortFn) {
1032
+ return this.heap.sort(sortFn);
1033
+ }
1034
+ _bubbleUp(i) {
1035
+ const heap = this.heap;
1036
+ while (i > 0) {
1037
+ const parent = i - 1 >> 1;
1038
+ if (heap[i].score <= heap[parent].score) break;
1039
+ const tmp = heap[i];
1040
+ heap[i] = heap[parent];
1041
+ heap[parent] = tmp;
1042
+ i = parent;
1043
+ }
1044
+ }
1045
+ _sinkDown(i) {
1046
+ const heap = this.heap;
1047
+ const len = heap.length;
1048
+ let largest = i;
1049
+ do {
1050
+ i = largest;
1051
+ const left = 2 * i + 1;
1052
+ const right = 2 * i + 2;
1053
+ if (left < len && heap[left].score > heap[largest].score) largest = left;
1054
+ if (right < len && heap[right].score > heap[largest].score) largest = right;
1055
+ if (largest !== i) {
1056
+ const tmp = heap[i];
1057
+ heap[i] = heap[largest];
1058
+ heap[largest] = tmp;
1059
+ }
1060
+ } while (largest !== i);
1061
+ }
1062
+ };
1494
1063
 
1495
- data.matches.push(obj);
1496
- });
1064
+ //#endregion
1065
+ //#region src/core/formatMatches.ts
1066
+ function formatMatches(result) {
1067
+ const matches = [];
1068
+ result.matches.forEach((match) => {
1069
+ if (!isDefined(match.indices) || !match.indices.length) return;
1070
+ const obj = {
1071
+ indices: match.indices,
1072
+ value: match.value
1073
+ };
1074
+ if (match.key) obj.key = match.key.id;
1075
+ if (match.idx > -1) obj.refIndex = match.idx;
1076
+ matches.push(obj);
1077
+ });
1078
+ return matches;
1497
1079
  }
1498
1080
 
1499
- function transformScore(result, data) {
1500
- data.score = result.score;
1081
+ //#endregion
1082
+ //#region src/core/format.ts
1083
+ function format(results, docs, { includeMatches = Config.includeMatches, includeScore = Config.includeScore } = {}) {
1084
+ return results.map((result) => {
1085
+ const { idx } = result;
1086
+ const data = {
1087
+ item: docs[idx],
1088
+ refIndex: idx
1089
+ };
1090
+ if (includeMatches) data.matches = formatMatches(result);
1091
+ if (includeScore) data.score = result.score;
1092
+ return data;
1093
+ });
1501
1094
  }
1502
1095
 
1503
- function format(
1504
- results,
1505
- docs,
1506
- {
1507
- includeMatches = Config.includeMatches,
1508
- includeScore = Config.includeScore
1509
- } = {}
1510
- ) {
1511
- const transformers = [];
1512
-
1513
- if (includeMatches) transformers.push(transformMatches);
1514
- if (includeScore) transformers.push(transformScore);
1515
-
1516
- return results.map((result) => {
1517
- const { idx } = result;
1518
-
1519
- const data = {
1520
- item: docs[idx],
1521
- refIndex: idx
1522
- };
1523
-
1524
- if (transformers.length) {
1525
- transformers.forEach((transformer) => {
1526
- transformer(result, data);
1527
- });
1528
- }
1529
-
1530
- return data
1531
- })
1096
+ //#endregion
1097
+ //#region src/search/token/analyzer.ts
1098
+ const DEFAULT_TOKEN = /[\p{L}\p{M}\p{N}_]+/gu;
1099
+ const warned = /* @__PURE__ */ new WeakSet();
1100
+ function warnNonGlobal(regex) {
1101
+ if (!warned.has(regex)) {
1102
+ warned.add(regex);
1103
+ console.warn(`[Fuse] tokenize regex ${regex} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`);
1104
+ }
1532
1105
  }
1106
+ function resolveTokenize(tokenize) {
1107
+ if (typeof tokenize === "function") {
1108
+ let validated = false;
1109
+ return (text) => {
1110
+ const result = tokenize(text);
1111
+ if (!validated) {
1112
+ validated = true;
1113
+ if (!Array.isArray(result) || result.some((t) => typeof t !== "string")) throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(result) ? "array containing non-strings" : typeof result}.`);
1114
+ }
1115
+ return result;
1116
+ };
1117
+ }
1118
+ if (tokenize instanceof RegExp) {
1119
+ if (!tokenize.global) warnNonGlobal(tokenize);
1120
+ return (text) => text.match(tokenize) || [];
1121
+ }
1122
+ return (text) => text.match(DEFAULT_TOKEN) || [];
1123
+ }
1124
+ function createAnalyzer({ isCaseSensitive = false, ignoreDiacritics = false, tokenize } = {}) {
1125
+ const tokenizeFn = resolveTokenize(tokenize);
1126
+ return { tokenize(text) {
1127
+ if (!isCaseSensitive) text = text.toLowerCase();
1128
+ if (ignoreDiacritics) text = stripDiacritics(text);
1129
+ return tokenizeFn(text);
1130
+ } };
1131
+ }
1132
+ var TokenSearch = class {
1133
+ static condition(_, options) {
1134
+ return options.useTokenSearch;
1135
+ }
1136
+ constructor(pattern, options) {
1137
+ this.options = options;
1138
+ this.analyzer = createAnalyzer({
1139
+ isCaseSensitive: options.isCaseSensitive,
1140
+ ignoreDiacritics: options.ignoreDiacritics,
1141
+ tokenize: options.tokenize
1142
+ });
1143
+ const queryTerms = this.analyzer.tokenize(pattern);
1144
+ const { df, fieldCount } = options._invertedIndex;
1145
+ this.termSearchers = [];
1146
+ this.idfWeights = [];
1147
+ for (const term of queryTerms) {
1148
+ this.termSearchers.push(new BitapSearch(term, {
1149
+ location: options.location,
1150
+ threshold: options.threshold,
1151
+ distance: options.distance,
1152
+ includeMatches: options.includeMatches,
1153
+ findAllMatches: options.findAllMatches,
1154
+ minMatchCharLength: options.minMatchCharLength,
1155
+ isCaseSensitive: options.isCaseSensitive,
1156
+ ignoreDiacritics: options.ignoreDiacritics,
1157
+ ignoreLocation: true
1158
+ }));
1159
+ const docFreq = df.get(term) || 0;
1160
+ const idf = Math.log(1 + (fieldCount - docFreq + .5) / (docFreq + .5));
1161
+ this.idfWeights.push(idf);
1162
+ }
1163
+ this.combineAll = options.tokenMatch === "all";
1164
+ this.numTerms = this.termSearchers.length;
1165
+ this.useMask = this.numTerms <= 31;
1166
+ }
1167
+ searchIn(text) {
1168
+ if (!this.termSearchers.length) return {
1169
+ isMatch: false,
1170
+ score: 1
1171
+ };
1172
+ const allIndices = [];
1173
+ let weightedScore = 0;
1174
+ let maxPossibleScore = 0;
1175
+ let matchedCount = 0;
1176
+ let matchedMask = 0;
1177
+ const matchedTerms = this.combineAll && !this.useMask ? /* @__PURE__ */ new Set() : null;
1178
+ for (let i = 0; i < this.termSearchers.length; i++) {
1179
+ const result = this.termSearchers[i].searchIn(text);
1180
+ const idf = this.idfWeights[i];
1181
+ maxPossibleScore += idf;
1182
+ if (result.isMatch) {
1183
+ matchedCount++;
1184
+ weightedScore += idf * (1 - result.score);
1185
+ if (result.indices) allIndices.push(...result.indices);
1186
+ if (this.combineAll) if (this.useMask) matchedMask |= 1 << i;
1187
+ else matchedTerms.add(i);
1188
+ }
1189
+ }
1190
+ if (matchedCount === 0) return {
1191
+ isMatch: false,
1192
+ score: 1
1193
+ };
1194
+ const normalized = maxPossibleScore > 0 ? 1 - weightedScore / maxPossibleScore : 0;
1195
+ const searchResult = {
1196
+ isMatch: true,
1197
+ score: Math.max(.001, normalized)
1198
+ };
1199
+ if (this.options.includeMatches && allIndices.length) searchResult.indices = mergeIndices(allIndices);
1200
+ if (this.combineAll) {
1201
+ if (this.useMask) searchResult.matchedMask = matchedMask;
1202
+ else searchResult.matchedTerms = matchedTerms;
1203
+ searchResult.termCount = this.numTerms;
1204
+ }
1205
+ return searchResult;
1206
+ }
1207
+ };
1533
1208
 
1534
- class Fuse {
1535
- constructor(docs, options = {}, index) {
1536
- this.options = { ...Config, ...options };
1537
-
1538
- if (
1539
- this.options.useExtendedSearch &&
1540
- !true
1541
- ) {
1542
- throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
1543
- }
1544
-
1545
- this._keyStore = new KeyStore(this.options.keys);
1546
-
1547
- this.setCollection(docs, index);
1548
- }
1549
-
1550
- setCollection(docs, index) {
1551
- this._docs = docs;
1552
-
1553
- if (index && !(index instanceof FuseIndex)) {
1554
- throw new Error(INCORRECT_INDEX_TYPE)
1555
- }
1556
-
1557
- this._myIndex =
1558
- index ||
1559
- createIndex(this.options.keys, this._docs, {
1560
- getFn: this.options.getFn,
1561
- fieldNormWeight: this.options.fieldNormWeight
1562
- });
1563
- }
1564
-
1565
- add(doc) {
1566
- if (!isDefined(doc)) {
1567
- return
1568
- }
1569
-
1570
- this._docs.push(doc);
1571
- this._myIndex.add(doc);
1572
- }
1573
-
1574
- remove(predicate = (/* doc, idx */) => false) {
1575
- const results = [];
1576
-
1577
- for (let i = 0, len = this._docs.length; i < len; i += 1) {
1578
- const doc = this._docs[i];
1579
- if (predicate(doc, i)) {
1580
- this.removeAt(i);
1581
- i -= 1;
1582
- len -= 1;
1583
-
1584
- results.push(doc);
1585
- }
1586
- }
1587
-
1588
- return results
1589
- }
1590
-
1591
- removeAt(idx) {
1592
- this._docs.splice(idx, 1);
1593
- this._myIndex.removeAt(idx);
1594
- }
1595
-
1596
- getIndex() {
1597
- return this._myIndex
1598
- }
1599
-
1600
- search(query, { limit = -1 } = {}) {
1601
- const {
1602
- includeMatches,
1603
- includeScore,
1604
- shouldSort,
1605
- sortFn,
1606
- ignoreFieldNorm
1607
- } = this.options;
1608
-
1609
- let results = isString(query)
1610
- ? isString(this._docs[0])
1611
- ? this._searchStringList(query)
1612
- : this._searchObjectList(query)
1613
- : this._searchLogical(query);
1614
-
1615
- computeScore(results, { ignoreFieldNorm });
1616
-
1617
- if (shouldSort) {
1618
- results.sort(sortFn);
1619
- }
1620
-
1621
- if (isNumber(limit) && limit > -1) {
1622
- results = results.slice(0, limit);
1623
- }
1624
-
1625
- return format(results, this._docs, {
1626
- includeMatches,
1627
- includeScore
1628
- })
1629
- }
1630
-
1631
- _searchStringList(query) {
1632
- const searcher = createSearcher(query, this.options);
1633
- const { records } = this._myIndex;
1634
- const results = [];
1635
-
1636
- // Iterate over every string in the index
1637
- records.forEach(({ v: text, i: idx, n: norm }) => {
1638
- if (!isDefined(text)) {
1639
- return
1640
- }
1641
-
1642
- const { isMatch, score, indices } = searcher.searchIn(text);
1643
-
1644
- if (isMatch) {
1645
- results.push({
1646
- item: text,
1647
- idx,
1648
- matches: [{ score, value: text, norm, indices }]
1649
- });
1650
- }
1651
- });
1652
-
1653
- return results
1654
- }
1655
-
1656
- _searchLogical(query) {
1657
-
1658
- const expression = parse(query, this.options);
1659
-
1660
- const evaluate = (node, item, idx) => {
1661
- if (!node.children) {
1662
- const { keyId, searcher } = node;
1663
-
1664
- const matches = this._findMatches({
1665
- key: this._keyStore.get(keyId),
1666
- value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1667
- searcher
1668
- });
1669
-
1670
- if (matches && matches.length) {
1671
- return [
1672
- {
1673
- idx,
1674
- item,
1675
- matches
1676
- }
1677
- ]
1678
- }
1679
-
1680
- return []
1681
- }
1682
-
1683
- const res = [];
1684
- for (let i = 0, len = node.children.length; i < len; i += 1) {
1685
- const child = node.children[i];
1686
- const result = evaluate(child, item, idx);
1687
- if (result.length) {
1688
- res.push(...result);
1689
- } else if (node.operator === LogicalOperator.AND) {
1690
- return []
1691
- }
1692
- }
1693
- return res
1694
- };
1695
-
1696
- const records = this._myIndex.records;
1697
- const resultMap = {};
1698
- const results = [];
1699
-
1700
- records.forEach(({ $: item, i: idx }) => {
1701
- if (isDefined(item)) {
1702
- let expResults = evaluate(expression, item, idx);
1703
-
1704
- if (expResults.length) {
1705
- // Dedupe when adding
1706
- if (!resultMap[idx]) {
1707
- resultMap[idx] = { idx, item, matches: [] };
1708
- results.push(resultMap[idx]);
1709
- }
1710
- expResults.forEach(({ matches }) => {
1711
- resultMap[idx].matches.push(...matches);
1712
- });
1713
- }
1714
- }
1715
- });
1716
-
1717
- return results
1718
- }
1719
-
1720
- _searchObjectList(query) {
1721
- const searcher = createSearcher(query, this.options);
1722
- const { keys, records } = this._myIndex;
1723
- const results = [];
1724
-
1725
- // List is Array<Object>
1726
- records.forEach(({ $: item, i: idx }) => {
1727
- if (!isDefined(item)) {
1728
- return
1729
- }
1730
-
1731
- let matches = [];
1732
-
1733
- // Iterate over every key (i.e, path), and fetch the value at that key
1734
- keys.forEach((key, keyIndex) => {
1735
- matches.push(
1736
- ...this._findMatches({
1737
- key,
1738
- value: item[keyIndex],
1739
- searcher
1740
- })
1741
- );
1742
- });
1743
-
1744
- if (matches.length) {
1745
- results.push({
1746
- idx,
1747
- item,
1748
- matches
1749
- });
1750
- }
1751
- });
1752
-
1753
- return results
1754
- }
1755
- _findMatches({ key, value, searcher }) {
1756
- if (!isDefined(value)) {
1757
- return []
1758
- }
1759
-
1760
- let matches = [];
1761
-
1762
- if (isArray(value)) {
1763
- value.forEach(({ v: text, i: idx, n: norm }) => {
1764
- if (!isDefined(text)) {
1765
- return
1766
- }
1767
-
1768
- const { isMatch, score, indices } = searcher.searchIn(text);
1769
-
1770
- if (isMatch) {
1771
- matches.push({
1772
- score,
1773
- key,
1774
- value: text,
1775
- idx,
1776
- norm,
1777
- indices
1778
- });
1779
- }
1780
- });
1781
- } else {
1782
- const { v: text, n: norm } = value;
1783
-
1784
- const { isMatch, score, indices } = searcher.searchIn(text);
1785
-
1786
- if (isMatch) {
1787
- matches.push({ score, key, value: text, norm, indices });
1788
- }
1789
- }
1790
-
1791
- return matches
1792
- }
1209
+ //#endregion
1210
+ //#region src/search/token/InvertedIndex.ts
1211
+ function addField(index, text, docIdx, analyzer) {
1212
+ const tokens = analyzer.tokenize(text);
1213
+ if (!tokens.length) return;
1214
+ index.fieldCount++;
1215
+ index.docFieldCount.set(docIdx, (index.docFieldCount.get(docIdx) || 0) + 1);
1216
+ const distinctTerms = new Set(tokens);
1217
+ let perDocTerms = index.docTermFieldHits.get(docIdx);
1218
+ if (!perDocTerms) {
1219
+ perDocTerms = /* @__PURE__ */ new Map();
1220
+ index.docTermFieldHits.set(docIdx, perDocTerms);
1221
+ }
1222
+ for (const term of distinctTerms) {
1223
+ perDocTerms.set(term, (perDocTerms.get(term) || 0) + 1);
1224
+ index.df.set(term, (index.df.get(term) || 0) + 1);
1225
+ }
1226
+ }
1227
+ function ingestRecord(index, record, keyCount, analyzer) {
1228
+ const { i: docIdx, v, $: fields } = record;
1229
+ if (v !== void 0) {
1230
+ addField(index, v, docIdx, analyzer);
1231
+ return;
1232
+ }
1233
+ if (!fields) return;
1234
+ for (let keyIdx = 0; keyIdx < keyCount; keyIdx++) {
1235
+ const value = fields[keyIdx];
1236
+ if (!value) continue;
1237
+ if (Array.isArray(value)) for (const sub of value) addField(index, sub.v, docIdx, analyzer);
1238
+ else addField(index, value.v, docIdx, analyzer);
1239
+ }
1793
1240
  }
1241
+ function buildInvertedIndex(records, keyCount, analyzer) {
1242
+ const index = {
1243
+ fieldCount: 0,
1244
+ df: /* @__PURE__ */ new Map(),
1245
+ docFieldCount: /* @__PURE__ */ new Map(),
1246
+ docTermFieldHits: /* @__PURE__ */ new Map()
1247
+ };
1248
+ for (const record of records) ingestRecord(index, record, keyCount, analyzer);
1249
+ return index;
1250
+ }
1251
+ function addToInvertedIndex(index, record, keyCount, analyzer) {
1252
+ ingestRecord(index, record, keyCount, analyzer);
1253
+ }
1254
+ function removeFromInvertedIndex(index, docIdx) {
1255
+ const fieldCount = index.docFieldCount.get(docIdx);
1256
+ if (fieldCount === void 0) return;
1257
+ index.fieldCount -= fieldCount;
1258
+ index.docFieldCount.delete(docIdx);
1259
+ const perDocTerms = index.docTermFieldHits.get(docIdx);
1260
+ if (!perDocTerms) return;
1261
+ for (const [term, hits] of perDocTerms) {
1262
+ const next = (index.df.get(term) || 0) - hits;
1263
+ if (next <= 0) index.df.delete(term);
1264
+ else index.df.set(term, next);
1265
+ }
1266
+ index.docTermFieldHits.delete(docIdx);
1267
+ }
1268
+ function removeAndShiftInvertedIndex(index, removedIndices) {
1269
+ if (removedIndices.length === 0) return;
1270
+ const sorted = Array.from(new Set(removedIndices)).sort((a, b) => a - b);
1271
+ for (const idx of sorted) removeFromInvertedIndex(index, idx);
1272
+ const shift = (oldIdx) => {
1273
+ let lo = 0;
1274
+ let hi = sorted.length;
1275
+ while (lo < hi) {
1276
+ const mid = lo + hi >>> 1;
1277
+ if (sorted[mid] < oldIdx) lo = mid + 1;
1278
+ else hi = mid;
1279
+ }
1280
+ return oldIdx - lo;
1281
+ };
1282
+ const firstRemoved = sorted[0];
1283
+ const shiftedDocFieldCount = /* @__PURE__ */ new Map();
1284
+ for (const [oldKey, count] of index.docFieldCount) shiftedDocFieldCount.set(oldKey > firstRemoved ? shift(oldKey) : oldKey, count);
1285
+ index.docFieldCount = shiftedDocFieldCount;
1286
+ const shiftedDocTermFieldHits = /* @__PURE__ */ new Map();
1287
+ for (const [oldKey, terms] of index.docTermFieldHits) shiftedDocTermFieldHits.set(oldKey > firstRemoved ? shift(oldKey) : oldKey, terms);
1288
+ index.docTermFieldHits = shiftedDocTermFieldHits;
1289
+ }
1290
+
1291
+ //#endregion
1292
+ //#region src/core/index.ts
1293
+ var Fuse = class {
1294
+ constructor(docs, options, index) {
1295
+ this.options = {
1296
+ ...Config,
1297
+ ...options
1298
+ };
1299
+ this._keyStore = new KeyStore(this.options.keys);
1300
+ this._docs = docs;
1301
+ this._myIndex = null;
1302
+ this._invertedIndex = null;
1303
+ this.setCollection(docs, index);
1304
+ this._lastQuery = null;
1305
+ this._lastSearcher = null;
1306
+ }
1307
+ _getSearcher(query) {
1308
+ if (this._lastQuery === query) return this._lastSearcher;
1309
+ const searcher = createSearcher(query, this._invertedIndex ? {
1310
+ ...this.options,
1311
+ _invertedIndex: this._invertedIndex
1312
+ } : this.options);
1313
+ this._lastQuery = query;
1314
+ this._lastSearcher = searcher;
1315
+ return searcher;
1316
+ }
1317
+ setCollection(docs, index) {
1318
+ this._docs = docs;
1319
+ if (index && !(index instanceof FuseIndex)) throw new Error(INCORRECT_INDEX_TYPE);
1320
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
1321
+ getFn: this.options.getFn,
1322
+ fieldNormWeight: this.options.fieldNormWeight
1323
+ });
1324
+ if (this.options.useTokenSearch) {
1325
+ const analyzer = createAnalyzer({
1326
+ isCaseSensitive: this.options.isCaseSensitive,
1327
+ ignoreDiacritics: this.options.ignoreDiacritics,
1328
+ tokenize: this.options.tokenize
1329
+ });
1330
+ this._invertedIndex = buildInvertedIndex(this._myIndex.records, this._myIndex.keys.length, analyzer);
1331
+ }
1332
+ this._invalidateSearcherCache();
1333
+ }
1334
+ add(doc) {
1335
+ if (!isDefined(doc)) return;
1336
+ this._docs.push(doc);
1337
+ const record = this._myIndex.add(doc, this._docs.length - 1);
1338
+ if (this._invertedIndex && record) {
1339
+ const analyzer = createAnalyzer({
1340
+ isCaseSensitive: this.options.isCaseSensitive,
1341
+ ignoreDiacritics: this.options.ignoreDiacritics,
1342
+ tokenize: this.options.tokenize
1343
+ });
1344
+ addToInvertedIndex(this._invertedIndex, record, this._myIndex.keys.length, analyzer);
1345
+ }
1346
+ this._invalidateSearcherCache();
1347
+ }
1348
+ remove(predicate = () => false) {
1349
+ const results = [];
1350
+ const indicesToRemove = [];
1351
+ for (let i = 0, len = this._docs.length; i < len; i += 1) if (predicate(this._docs[i], i)) {
1352
+ results.push(this._docs[i]);
1353
+ indicesToRemove.push(i);
1354
+ }
1355
+ if (indicesToRemove.length) {
1356
+ if (this._invertedIndex) removeAndShiftInvertedIndex(this._invertedIndex, indicesToRemove);
1357
+ const toRemove = new Set(indicesToRemove);
1358
+ this._docs = this._docs.filter((_, i) => !toRemove.has(i));
1359
+ this._myIndex.removeAll(indicesToRemove);
1360
+ this._invalidateSearcherCache();
1361
+ }
1362
+ return results;
1363
+ }
1364
+ removeAt(idx) {
1365
+ if (!Number.isInteger(idx) || idx < 0 || idx >= this._docs.length) throw new Error(INVALID_DOC_INDEX);
1366
+ if (this._invertedIndex) removeAndShiftInvertedIndex(this._invertedIndex, [idx]);
1367
+ const doc = this._docs.splice(idx, 1)[0];
1368
+ this._myIndex.removeAt(idx);
1369
+ this._invalidateSearcherCache();
1370
+ return doc;
1371
+ }
1372
+ _invalidateSearcherCache() {
1373
+ this._lastQuery = null;
1374
+ this._lastSearcher = null;
1375
+ }
1376
+ getIndex() {
1377
+ return this._myIndex;
1378
+ }
1379
+ search(query, options) {
1380
+ const { limit = -1 } = options || {};
1381
+ const { includeMatches, includeScore, shouldSort, sortFn, ignoreFieldNorm } = this.options;
1382
+ if (isString(query) && !query.trim()) {
1383
+ let docs = this._docs.map((item, idx) => ({
1384
+ item,
1385
+ refIndex: idx
1386
+ }));
1387
+ if (isNumber(limit) && limit > -1) docs = docs.slice(0, limit);
1388
+ return docs;
1389
+ }
1390
+ const useHeap = isNumber(limit) && limit > 0 && isString(query);
1391
+ let results;
1392
+ if (useHeap) {
1393
+ const heap = new MaxHeap(limit);
1394
+ if (isString(this._docs[0])) this._searchStringList(query, {
1395
+ heap,
1396
+ ignoreFieldNorm
1397
+ });
1398
+ else this._searchObjectList(query, {
1399
+ heap,
1400
+ ignoreFieldNorm
1401
+ });
1402
+ results = heap.extractSorted(sortFn);
1403
+ } else {
1404
+ results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
1405
+ computeScore(results, { ignoreFieldNorm });
1406
+ if (shouldSort) results.sort(sortFn);
1407
+ if (isNumber(limit) && limit > -1) results = results.slice(0, limit);
1408
+ }
1409
+ return format(results, this._docs, {
1410
+ includeMatches,
1411
+ includeScore
1412
+ });
1413
+ }
1414
+ _searchStringList(query, { heap, ignoreFieldNorm } = {}) {
1415
+ const searcher = this._getSearcher(query);
1416
+ const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
1417
+ const { records } = this._myIndex;
1418
+ const results = heap ? null : [];
1419
+ records.forEach(({ v: text, i: idx, n: norm }) => {
1420
+ if (!isDefined(text)) return;
1421
+ const searchResult = searcher.searchIn(text);
1422
+ if (searchResult.isMatch) {
1423
+ const match = {
1424
+ score: searchResult.score,
1425
+ value: text,
1426
+ norm,
1427
+ indices: searchResult.indices
1428
+ };
1429
+ if (requireAllTokens) {
1430
+ match.matchedMask = searchResult.matchedMask;
1431
+ match.matchedTerms = searchResult.matchedTerms;
1432
+ match.termCount = searchResult.termCount;
1433
+ }
1434
+ const matches = [match];
1435
+ if (!requireAllTokens || this._coversAllTokens(matches)) {
1436
+ const result = {
1437
+ item: text,
1438
+ idx,
1439
+ matches
1440
+ };
1441
+ if (heap) {
1442
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1443
+ if (heap.shouldInsert(result.score)) heap.insert(result);
1444
+ } else results.push(result);
1445
+ }
1446
+ }
1447
+ });
1448
+ return results;
1449
+ }
1450
+ _searchLogical(query) {
1451
+ const expression = parse(query, this.options);
1452
+ const evaluate = (node, item, idx) => {
1453
+ if (!("children" in node)) {
1454
+ const { keyId, searcher } = node;
1455
+ let matches;
1456
+ if (keyId === null) {
1457
+ matches = [];
1458
+ this._myIndex.keys.forEach((key, keyIndex) => {
1459
+ matches.push(...this._findMatches({
1460
+ key,
1461
+ value: item[keyIndex],
1462
+ searcher
1463
+ }));
1464
+ });
1465
+ } else matches = this._findMatches({
1466
+ key: this._keyStore.get(keyId),
1467
+ value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1468
+ searcher
1469
+ });
1470
+ if (matches && matches.length) return [{
1471
+ idx,
1472
+ item,
1473
+ matches
1474
+ }];
1475
+ return [];
1476
+ }
1477
+ const { children, operator } = node;
1478
+ const res = [];
1479
+ for (let i = 0, len = children.length; i < len; i += 1) {
1480
+ const child = children[i];
1481
+ const result = evaluate(child, item, idx);
1482
+ if (result.length) res.push(...result);
1483
+ else if (operator === LogicalOperator.AND) return [];
1484
+ }
1485
+ return res;
1486
+ };
1487
+ const records = this._myIndex.records;
1488
+ const resultMap = /* @__PURE__ */ new Map();
1489
+ const results = [];
1490
+ records.forEach(({ $: item, i: idx }) => {
1491
+ if (isDefined(item)) {
1492
+ const expResults = evaluate(expression, item, idx);
1493
+ if (expResults.length) {
1494
+ if (!resultMap.has(idx)) {
1495
+ resultMap.set(idx, {
1496
+ idx,
1497
+ item,
1498
+ matches: []
1499
+ });
1500
+ results.push(resultMap.get(idx));
1501
+ }
1502
+ expResults.forEach(({ matches }) => {
1503
+ resultMap.get(idx).matches.push(...matches);
1504
+ });
1505
+ }
1506
+ }
1507
+ });
1508
+ return results;
1509
+ }
1510
+ _searchObjectList(query, { heap, ignoreFieldNorm } = {}) {
1511
+ const searcher = this._getSearcher(query);
1512
+ const requireAllTokens = this.options.useTokenSearch && this.options.tokenMatch === "all";
1513
+ const { keys, records } = this._myIndex;
1514
+ const results = heap ? null : [];
1515
+ records.forEach(({ $: item, i: idx }) => {
1516
+ if (!isDefined(item)) return;
1517
+ const matches = [];
1518
+ let anyKeyFailed = false;
1519
+ let hasInverse = false;
1520
+ keys.forEach((key, keyIndex) => {
1521
+ const keyMatches = this._findMatches({
1522
+ key,
1523
+ value: item[keyIndex],
1524
+ searcher
1525
+ });
1526
+ if (keyMatches.length) {
1527
+ matches.push(...keyMatches);
1528
+ if (keyMatches[0].hasInverse) hasInverse = true;
1529
+ } else anyKeyFailed = true;
1530
+ });
1531
+ if (hasInverse && anyKeyFailed) return;
1532
+ if (matches.length && (!requireAllTokens || this._coversAllTokens(matches))) {
1533
+ const result = {
1534
+ idx,
1535
+ item,
1536
+ matches
1537
+ };
1538
+ if (heap) {
1539
+ result.score = computeScoreSingle(result.matches, { ignoreFieldNorm });
1540
+ if (heap.shouldInsert(result.score)) heap.insert(result);
1541
+ } else results.push(result);
1542
+ }
1543
+ });
1544
+ return results;
1545
+ }
1546
+ _findMatches({ key, value, searcher }) {
1547
+ if (!isDefined(value)) return [];
1548
+ const matches = [];
1549
+ if (isArray(value)) value.forEach(({ v: text, i: idx, n: norm }) => {
1550
+ if (!isDefined(text)) return;
1551
+ const searchResult = searcher.searchIn(text);
1552
+ if (searchResult.isMatch) {
1553
+ const match = {
1554
+ score: searchResult.score,
1555
+ key,
1556
+ value: text,
1557
+ idx,
1558
+ norm,
1559
+ indices: searchResult.indices,
1560
+ hasInverse: searchResult.hasInverse
1561
+ };
1562
+ if (searchResult.termCount !== void 0) {
1563
+ match.matchedMask = searchResult.matchedMask;
1564
+ match.matchedTerms = searchResult.matchedTerms;
1565
+ match.termCount = searchResult.termCount;
1566
+ }
1567
+ matches.push(match);
1568
+ }
1569
+ });
1570
+ else {
1571
+ const { v: text, n: norm } = value;
1572
+ const searchResult = searcher.searchIn(text);
1573
+ if (searchResult.isMatch) {
1574
+ const match = {
1575
+ score: searchResult.score,
1576
+ key,
1577
+ value: text,
1578
+ norm,
1579
+ indices: searchResult.indices,
1580
+ hasInverse: searchResult.hasInverse
1581
+ };
1582
+ if (searchResult.termCount !== void 0) {
1583
+ match.matchedMask = searchResult.matchedMask;
1584
+ match.matchedTerms = searchResult.matchedTerms;
1585
+ match.termCount = searchResult.termCount;
1586
+ }
1587
+ matches.push(match);
1588
+ }
1589
+ }
1590
+ return matches;
1591
+ }
1592
+ _coversAllTokens(matches) {
1593
+ const termCount = matches.length ? matches[0].termCount : void 0;
1594
+ if (termCount === void 0) return true;
1595
+ if (termCount <= 31) {
1596
+ let coverage = 0;
1597
+ for (let i = 0; i < matches.length; i++) coverage |= matches[i].matchedMask || 0;
1598
+ return coverage === 2 ** termCount - 1;
1599
+ }
1600
+ const coverage = /* @__PURE__ */ new Set();
1601
+ for (let i = 0; i < matches.length; i++) {
1602
+ const terms = matches[i].matchedTerms;
1603
+ if (terms) for (const t of terms) coverage.add(t);
1604
+ }
1605
+ return coverage.size === termCount;
1606
+ }
1607
+ };
1794
1608
 
1795
- Fuse.version = '7.1.0';
1609
+ //#endregion
1610
+ //#region src/entry.ts
1611
+ Fuse.version = "7.4.2";
1796
1612
  Fuse.createIndex = createIndex;
1797
1613
  Fuse.parseIndex = parseIndex;
1798
1614
  Fuse.config = Config;
1799
-
1800
- {
1801
- Fuse.parseQuery = parse;
1802
- }
1803
-
1804
- {
1805
- register(ExtendedSearch);
1806
- }
1615
+ Fuse.match = function(pattern, text, options) {
1616
+ if (options && options.useTokenSearch) throw new Error(FUSE_MATCH_TOKEN_SEARCH_UNSUPPORTED);
1617
+ return createSearcher(pattern, {
1618
+ ...Config,
1619
+ ...options
1620
+ }).searchIn(text);
1621
+ };
1622
+ Fuse.parseQuery = parse;
1623
+ register(ExtendedSearch);
1624
+ register(TokenSearch);
1625
+ Fuse.use = function(...plugins) {
1626
+ plugins.forEach((plugin) => register(plugin));
1627
+ };
1628
+ var entry_default = Fuse;
1807
1629
 
1808
1630
  const GreenCheckDuotoneIcon = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
1809
1631
  <path d="M7.99996 2.6665C5.05444 2.6665 2.66663 5.05432 2.66663 7.99984C2.66663 10.9454 5.05444 13.3332 7.99996 13.3332C10.9455 13.3332 13.3333 10.9454 13.3333 7.99984C13.3333 5.05432 10.9455 2.6665 7.99996 2.6665Z" fill="#AFF8C3"/>
@@ -1851,7 +1673,7 @@ const ZonosCountrySelect = class {
1851
1673
  render() {
1852
1674
  const { helloCountryList } = localization.localizationStore;
1853
1675
  const countries = helloCountryList ? Object.values(helloCountryList) : [];
1854
- const fuse = new Fuse(countries, {
1676
+ const fuse = new entry_default(countries, {
1855
1677
  includeScore: true,
1856
1678
  keys: ['displayName'],
1857
1679
  threshold: 0.3,