@huggingface/transformers 4.0.0-next.1 → 4.0.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/README.md +32 -6
  2. package/dist/ort-wasm-simd-threaded.jsep.mjs +31 -31
  3. package/dist/transformers.js +6050 -3202
  4. package/dist/transformers.min.js +23 -21
  5. package/dist/transformers.node.cjs +6119 -3174
  6. package/dist/transformers.node.min.cjs +25 -23
  7. package/dist/transformers.node.min.mjs +25 -23
  8. package/dist/transformers.node.mjs +6034 -3168
  9. package/dist/transformers.web.js +4255 -1381
  10. package/dist/transformers.web.min.js +23 -19
  11. package/package.json +5 -5
  12. package/src/backends/onnx.js +128 -53
  13. package/src/backends/utils/cacheWasm.js +28 -46
  14. package/src/cache_utils.js +62 -0
  15. package/src/configs.js +123 -23
  16. package/src/env.js +100 -11
  17. package/src/generation/logits_sampler.js +3 -15
  18. package/src/generation/parameters.js +1 -1
  19. package/src/generation/streamers.js +21 -0
  20. package/src/image_processors_utils.js +29 -23
  21. package/src/models/afmoe/modeling_afmoe.js +5 -0
  22. package/src/models/auto/image_processing_auto.js +2 -1
  23. package/src/models/auto/modeling_auto.js +16 -2
  24. package/src/models/auto/tokenization_auto.js +2 -1
  25. package/src/models/chatterbox/modeling_chatterbox.js +1 -1
  26. package/src/models/chmv2/image_processing_chmv2.js +3 -0
  27. package/src/models/chmv2/modeling_chmv2.js +4 -0
  28. package/src/models/clap/feature_extraction_clap.js +2 -1
  29. package/src/models/cohere2/modeling_cohere2.js +5 -0
  30. package/src/models/cohere_asr/feature_extraction_cohere_asr.js +117 -0
  31. package/src/models/cohere_asr/modeling_cohere_asr.js +11 -0
  32. package/src/models/cohere_asr/processing_cohere_asr.js +55 -0
  33. package/src/models/cohere_asr/tokenization_cohere_asr.js +3 -0
  34. package/src/models/deepseek_v3/modeling_deepseek_v3.js +5 -0
  35. package/src/models/detr/image_processing_detr.js +1 -1
  36. package/src/models/eurobert/modeling_eurobert.js +41 -0
  37. package/src/models/feature_extractors.js +3 -0
  38. package/src/models/gemma3/image_processing_gemma3.js +3 -0
  39. package/src/models/gemma3/modeling_gemma3.js +4 -1
  40. package/src/models/gemma3/processing_gemma3.js +45 -0
  41. package/src/models/gemma3n/modeling_gemma3n.js +2 -0
  42. package/src/models/glm46v/image_processing_glm46v.js +12 -0
  43. package/src/models/glm46v/processing_glm46v.js +5 -0
  44. package/src/models/glm_moe_dsa/modeling_glm_moe_dsa.js +5 -0
  45. package/src/models/glm_ocr/modeling_glm_ocr.js +78 -0
  46. package/src/models/granite_speech/feature_extraction_granite_speech.js +58 -0
  47. package/src/models/granite_speech/modeling_granite_speech.js +5 -0
  48. package/src/models/granite_speech/processing_granite_speech.js +62 -0
  49. package/src/models/grounding_dino/image_processing_grounding_dino.js +1 -1
  50. package/src/models/idefics3/modeling_idefics3.js +5 -32
  51. package/src/models/image_processors.js +4 -0
  52. package/src/models/lfm2_vl/image_processing_lfm2_vl.js +305 -0
  53. package/src/models/lfm2_vl/modeling_lfm2_vl.js +13 -0
  54. package/src/models/lfm2_vl/processing_lfm2_vl.js +77 -0
  55. package/src/models/lighton_ocr/modeling_lighton_ocr.js +3 -0
  56. package/src/models/llava/modeling_llava.js +1 -1
  57. package/src/models/marian/tokenization_marian.js +3 -2
  58. package/src/models/mistral3/modeling_mistral3.js +2 -2
  59. package/src/models/mistral4/modeling_mistral4.js +5 -0
  60. package/src/models/modeling_utils.js +283 -300
  61. package/src/models/models.js +26 -1
  62. package/src/models/nemotron_h/modeling_nemotron_h.js +5 -0
  63. package/src/models/olmo_hybrid/modeling_olmo_hybrid.js +5 -0
  64. package/src/models/paligemma/modeling_paligemma.js +2 -25
  65. package/src/models/paligemma/processing_paligemma.js +3 -2
  66. package/src/models/processors.js +8 -0
  67. package/src/models/qwen2_5_vl/modeling_qwen2_5_vl.js +9 -0
  68. package/src/models/qwen2_5_vl/processing_qwen2_5_vl.js +3 -0
  69. package/src/models/qwen2_moe/modeling_qwen2_moe.js +5 -0
  70. package/src/models/qwen2_vl/image_processing_qwen2_vl.js +15 -1
  71. package/src/models/qwen2_vl/modeling_qwen2_vl.js +240 -143
  72. package/src/models/qwen2_vl/processing_qwen2_vl.js +5 -4
  73. package/src/models/qwen3_5/modeling_qwen3_5.js +4 -0
  74. package/src/models/qwen3_5_moe/modeling_qwen3_5_moe.js +4 -0
  75. package/src/models/qwen3_moe/modeling_qwen3_moe.js +5 -0
  76. package/src/models/qwen3_next/modeling_qwen3_next.js +5 -0
  77. package/src/models/qwen3_vl/modeling_qwen3_vl.js +4 -0
  78. package/src/models/qwen3_vl/processing_qwen3_vl.js +3 -0
  79. package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +4 -0
  80. package/src/models/registry.js +61 -5
  81. package/src/models/sam/image_processing_sam.js +1 -1
  82. package/src/models/session.js +33 -56
  83. package/src/models/smolvlm/modeling_smolvlm.js +7 -0
  84. package/src/models/solar_open/modeling_solar_open.js +5 -0
  85. package/src/models/tokenizers.js +1 -0
  86. package/src/models/ultravox/modeling_ultravox.js +1 -3
  87. package/src/models/voxtral/modeling_voxtral.js +3 -0
  88. package/src/models/voxtral_realtime/feature_extraction_voxtral_realtime.js +71 -0
  89. package/src/models/voxtral_realtime/modeling_voxtral_realtime.js +239 -0
  90. package/src/models/voxtral_realtime/processing_voxtral_realtime.js +113 -0
  91. package/src/models/whisper/feature_extraction_whisper.js +4 -13
  92. package/src/models/whisper/modeling_whisper.js +6 -5
  93. package/src/models/xlm/tokenization_xlm.js +2 -1
  94. package/src/pipelines/automatic-speech-recognition.js +47 -3
  95. package/src/pipelines/document-question-answering.js +1 -1
  96. package/src/pipelines/image-to-text.js +2 -2
  97. package/src/pipelines/index.js +313 -0
  98. package/src/pipelines/summarization.js +1 -1
  99. package/src/pipelines/text-generation.js +5 -1
  100. package/src/pipelines/text-to-audio.js +4 -2
  101. package/src/pipelines/text2text-generation.js +1 -1
  102. package/src/pipelines/translation.js +1 -1
  103. package/src/pipelines/zero-shot-classification.js +3 -2
  104. package/src/pipelines.js +140 -428
  105. package/src/tokenization_utils.js +42 -21
  106. package/src/transformers.js +10 -1
  107. package/src/utils/audio.js +20 -3
  108. package/src/utils/cache/CrossOriginStorageCache.js +251 -0
  109. package/src/utils/cache/FileCache.js +128 -0
  110. package/src/utils/cache/cross-origin-storage.d.ts +38 -0
  111. package/src/utils/cache.js +12 -4
  112. package/src/utils/core.js +23 -1
  113. package/src/utils/devices.js +22 -0
  114. package/src/utils/dtypes.js +55 -0
  115. package/src/utils/hub/{files.js → FileResponse.js} +0 -90
  116. package/src/utils/hub/utils.js +45 -5
  117. package/src/utils/hub.js +67 -23
  118. package/src/utils/image.js +14 -14
  119. package/src/utils/logger.js +67 -0
  120. package/src/utils/lru_cache.js +67 -0
  121. package/src/utils/memoize_promise.js +45 -0
  122. package/src/utils/model-loader.js +35 -17
  123. package/src/utils/model_registry/ModelRegistry.js +382 -0
  124. package/src/utils/model_registry/clear_cache.js +128 -0
  125. package/src/utils/model_registry/get_available_dtypes.js +68 -0
  126. package/src/utils/model_registry/get_file_metadata.js +162 -0
  127. package/src/utils/model_registry/get_files.js +42 -0
  128. package/src/utils/model_registry/get_model_files.js +114 -0
  129. package/src/utils/model_registry/get_pipeline_files.js +44 -0
  130. package/src/utils/model_registry/get_processor_files.js +20 -0
  131. package/src/utils/model_registry/get_tokenizer_files.js +21 -0
  132. package/src/utils/model_registry/is_cached.js +169 -0
  133. package/src/utils/model_registry/resolve_model_type.js +66 -0
  134. package/src/utils/random.js +225 -0
  135. package/src/utils/tensor.js +26 -23
  136. package/src/utils/video.js +2 -2
  137. package/types/backends/onnx.d.ts.map +1 -1
  138. package/types/backends/utils/cacheWasm.d.ts +3 -17
  139. package/types/backends/utils/cacheWasm.d.ts.map +1 -1
  140. package/types/cache_utils.d.ts +29 -0
  141. package/types/cache_utils.d.ts.map +1 -0
  142. package/types/configs.d.ts.map +1 -1
  143. package/types/env.d.ts +60 -27
  144. package/types/env.d.ts.map +1 -1
  145. package/types/generation/logits_sampler.d.ts +2 -2
  146. package/types/generation/logits_sampler.d.ts.map +1 -1
  147. package/types/generation/parameters.d.ts +1 -1
  148. package/types/generation/parameters.d.ts.map +1 -1
  149. package/types/generation/streamers.d.ts +1 -0
  150. package/types/generation/streamers.d.ts.map +1 -1
  151. package/types/image_processors_utils.d.ts +18 -1
  152. package/types/image_processors_utils.d.ts.map +1 -1
  153. package/types/models/afmoe/modeling_afmoe.d.ts +8 -0
  154. package/types/models/afmoe/modeling_afmoe.d.ts.map +1 -0
  155. package/types/models/{ast/modeling_ast.d.ts → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts} +1 -1
  156. package/types/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts.map +1 -0
  157. package/types/models/auto/image_processing_auto.d.ts.map +1 -1
  158. package/types/models/auto/modeling_auto.d.ts +6 -0
  159. package/types/models/auto/modeling_auto.d.ts.map +1 -1
  160. package/types/models/auto/tokenization_auto.d.ts.map +1 -1
  161. package/types/models/chmv2/image_processing_chmv2.d.ts +4 -0
  162. package/types/models/chmv2/image_processing_chmv2.d.ts.map +1 -0
  163. package/types/models/chmv2/modeling_chmv2.d.ts +6 -0
  164. package/types/models/chmv2/modeling_chmv2.d.ts.map +1 -0
  165. package/types/models/clap/feature_extraction_clap.d.ts.map +1 -1
  166. package/types/models/cohere2/modeling_cohere2.d.ts +8 -0
  167. package/types/models/cohere2/modeling_cohere2.d.ts.map +1 -0
  168. package/types/models/cohere_asr/feature_extraction_cohere_asr.d.ts +25 -0
  169. package/types/models/cohere_asr/feature_extraction_cohere_asr.d.ts.map +1 -0
  170. package/types/models/cohere_asr/modeling_cohere_asr.d.ts +9 -0
  171. package/types/models/cohere_asr/modeling_cohere_asr.d.ts.map +1 -0
  172. package/types/models/cohere_asr/processing_cohere_asr.d.ts +27 -0
  173. package/types/models/cohere_asr/processing_cohere_asr.d.ts.map +1 -0
  174. package/types/models/cohere_asr/tokenization_cohere_asr.d.ts +4 -0
  175. package/types/models/cohere_asr/tokenization_cohere_asr.d.ts.map +1 -0
  176. package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts +8 -0
  177. package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts.map +1 -0
  178. package/types/models/detr/image_processing_detr.d.ts +1 -1
  179. package/types/models/eurobert/modeling_eurobert.d.ts +36 -0
  180. package/types/models/eurobert/modeling_eurobert.d.ts.map +1 -0
  181. package/types/models/feature_extractors.d.ts +3 -0
  182. package/types/models/gemma3/image_processing_gemma3.d.ts +4 -0
  183. package/types/models/gemma3/image_processing_gemma3.d.ts.map +1 -0
  184. package/types/models/gemma3/modeling_gemma3.d.ts +4 -1
  185. package/types/models/gemma3/modeling_gemma3.d.ts.map +1 -1
  186. package/types/models/gemma3/processing_gemma3.d.ts +20 -0
  187. package/types/models/gemma3/processing_gemma3.d.ts.map +1 -0
  188. package/types/models/gemma3n/modeling_gemma3n.d.ts +2 -0
  189. package/types/models/gemma3n/modeling_gemma3n.d.ts.map +1 -1
  190. package/types/models/glm46v/image_processing_glm46v.d.ts +4 -0
  191. package/types/models/glm46v/image_processing_glm46v.d.ts.map +1 -0
  192. package/types/models/glm46v/processing_glm46v.d.ts +4 -0
  193. package/types/models/glm46v/processing_glm46v.d.ts.map +1 -0
  194. package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts +8 -0
  195. package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts.map +1 -0
  196. package/types/models/glm_ocr/modeling_glm_ocr.d.ts +26 -0
  197. package/types/models/glm_ocr/modeling_glm_ocr.d.ts.map +1 -0
  198. package/types/models/granite_speech/feature_extraction_granite_speech.d.ts +16 -0
  199. package/types/models/granite_speech/feature_extraction_granite_speech.d.ts.map +1 -0
  200. package/types/models/granite_speech/modeling_granite_speech.d.ts +4 -0
  201. package/types/models/granite_speech/modeling_granite_speech.d.ts.map +1 -0
  202. package/types/models/granite_speech/processing_granite_speech.d.ts +19 -0
  203. package/types/models/granite_speech/processing_granite_speech.d.ts.map +1 -0
  204. package/types/models/grounding_dino/image_processing_grounding_dino.d.ts +1 -1
  205. package/types/models/idefics3/modeling_idefics3.d.ts +2 -18
  206. package/types/models/idefics3/modeling_idefics3.d.ts.map +1 -1
  207. package/types/models/image_processors.d.ts +4 -0
  208. package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts +41 -0
  209. package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts.map +1 -0
  210. package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts +4 -0
  211. package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts.map +1 -0
  212. package/types/models/lfm2_vl/processing_lfm2_vl.d.ts +18 -0
  213. package/types/models/lfm2_vl/processing_lfm2_vl.d.ts.map +1 -0
  214. package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts +4 -0
  215. package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts.map +1 -0
  216. package/types/models/marian/tokenization_marian.d.ts.map +1 -1
  217. package/types/models/mistral3/modeling_mistral3.d.ts +2 -2
  218. package/types/models/mistral3/modeling_mistral3.d.ts.map +1 -1
  219. package/types/models/mistral4/modeling_mistral4.d.ts +8 -0
  220. package/types/models/mistral4/modeling_mistral4.d.ts.map +1 -0
  221. package/types/models/modeling_utils.d.ts +46 -27
  222. package/types/models/modeling_utils.d.ts.map +1 -1
  223. package/types/models/models.d.ts +26 -1
  224. package/types/models/nemotron_h/modeling_nemotron_h.d.ts +8 -0
  225. package/types/models/nemotron_h/modeling_nemotron_h.d.ts.map +1 -0
  226. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts +8 -0
  227. package/types/models/olmo_hybrid/modeling_olmo_hybrid.d.ts.map +1 -0
  228. package/types/models/paligemma/modeling_paligemma.d.ts +2 -8
  229. package/types/models/paligemma/modeling_paligemma.d.ts.map +1 -1
  230. package/types/models/paligemma/processing_paligemma.d.ts.map +1 -1
  231. package/types/models/processors.d.ts +8 -0
  232. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts +7 -0
  233. package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts.map +1 -0
  234. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts +4 -0
  235. package/types/models/qwen2_5_vl/processing_qwen2_5_vl.d.ts.map +1 -0
  236. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts +8 -0
  237. package/types/models/qwen2_moe/modeling_qwen2_moe.d.ts.map +1 -0
  238. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +3 -0
  239. package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts.map +1 -1
  240. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +44 -6
  241. package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
  242. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts +1 -0
  243. package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
  244. package/types/models/qwen3_5/modeling_qwen3_5.d.ts +6 -0
  245. package/types/models/qwen3_5/modeling_qwen3_5.d.ts.map +1 -0
  246. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts +7 -0
  247. package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts.map +1 -0
  248. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts +8 -0
  249. package/types/models/qwen3_moe/modeling_qwen3_moe.d.ts.map +1 -0
  250. package/types/models/qwen3_next/modeling_qwen3_next.d.ts +8 -0
  251. package/types/models/qwen3_next/modeling_qwen3_next.d.ts.map +1 -0
  252. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts +7 -0
  253. package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts.map +1 -0
  254. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts +4 -0
  255. package/types/models/qwen3_vl/processing_qwen3_vl.d.ts.map +1 -0
  256. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +7 -0
  257. package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -0
  258. package/types/models/registry.d.ts +2 -1
  259. package/types/models/registry.d.ts.map +1 -1
  260. package/types/models/sam/image_processing_sam.d.ts +1 -1
  261. package/types/models/session.d.ts +3 -2
  262. package/types/models/session.d.ts.map +1 -1
  263. package/types/models/smolvlm/modeling_smolvlm.d.ts +8 -0
  264. package/types/models/smolvlm/modeling_smolvlm.d.ts.map +1 -0
  265. package/types/models/solar_open/modeling_solar_open.d.ts +8 -0
  266. package/types/models/solar_open/modeling_solar_open.d.ts.map +1 -0
  267. package/types/models/tokenizers.d.ts +1 -0
  268. package/types/models/ultravox/modeling_ultravox.d.ts +0 -2
  269. package/types/models/ultravox/modeling_ultravox.d.ts.map +1 -1
  270. package/types/models/voxtral/modeling_voxtral.d.ts +4 -0
  271. package/types/models/voxtral/modeling_voxtral.d.ts.map +1 -0
  272. package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts +28 -0
  273. package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts.map +1 -0
  274. package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts +17 -0
  275. package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts.map +1 -0
  276. package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts +44 -0
  277. package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts.map +1 -0
  278. package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
  279. package/types/models/whisper/modeling_whisper.d.ts.map +1 -1
  280. package/types/models/xlm/tokenization_xlm.d.ts.map +1 -1
  281. package/types/pipelines/automatic-speech-recognition.d.ts +7 -2
  282. package/types/pipelines/automatic-speech-recognition.d.ts.map +1 -1
  283. package/types/pipelines/document-question-answering.d.ts +2 -2
  284. package/types/pipelines/document-question-answering.d.ts.map +1 -1
  285. package/types/pipelines/image-to-text.d.ts +4 -4
  286. package/types/pipelines/image-to-text.d.ts.map +1 -1
  287. package/types/pipelines/index.d.ts +265 -0
  288. package/types/pipelines/index.d.ts.map +1 -0
  289. package/types/pipelines/summarization.d.ts +2 -2
  290. package/types/pipelines/summarization.d.ts.map +1 -1
  291. package/types/pipelines/text-generation.d.ts +7 -3
  292. package/types/pipelines/text-generation.d.ts.map +1 -1
  293. package/types/pipelines/text-to-audio.d.ts.map +1 -1
  294. package/types/pipelines/text2text-generation.d.ts +3 -3
  295. package/types/pipelines/text2text-generation.d.ts.map +1 -1
  296. package/types/pipelines/translation.d.ts +2 -2
  297. package/types/pipelines/translation.d.ts.map +1 -1
  298. package/types/pipelines/zero-shot-classification.d.ts.map +1 -1
  299. package/types/pipelines.d.ts +51 -291
  300. package/types/pipelines.d.ts.map +1 -1
  301. package/types/tokenization_utils.d.ts +44 -26
  302. package/types/tokenization_utils.d.ts.map +1 -1
  303. package/types/transformers.d.ts +7 -1
  304. package/types/transformers.d.ts.map +1 -1
  305. package/types/utils/audio.d.ts +5 -2
  306. package/types/utils/audio.d.ts.map +1 -1
  307. package/types/utils/cache/CrossOriginStorageCache.d.ts +120 -0
  308. package/types/utils/cache/CrossOriginStorageCache.d.ts.map +1 -0
  309. package/types/utils/cache/FileCache.d.ts +39 -0
  310. package/types/utils/cache/FileCache.d.ts.map +1 -0
  311. package/types/utils/cache.d.ts +10 -4
  312. package/types/utils/cache.d.ts.map +1 -1
  313. package/types/utils/core.d.ts +59 -2
  314. package/types/utils/core.d.ts.map +1 -1
  315. package/types/utils/devices.d.ts +15 -0
  316. package/types/utils/devices.d.ts.map +1 -1
  317. package/types/utils/dtypes.d.ts +17 -1
  318. package/types/utils/dtypes.d.ts.map +1 -1
  319. package/types/utils/hub/{files.d.ts → FileResponse.d.ts} +1 -32
  320. package/types/utils/hub/FileResponse.d.ts.map +1 -0
  321. package/types/utils/hub/utils.d.ts +19 -3
  322. package/types/utils/hub/utils.d.ts.map +1 -1
  323. package/types/utils/hub.d.ts +36 -7
  324. package/types/utils/hub.d.ts.map +1 -1
  325. package/types/utils/image.d.ts +1 -1
  326. package/types/utils/logger.d.ts +28 -0
  327. package/types/utils/logger.d.ts.map +1 -0
  328. package/types/utils/lru_cache.d.ts +38 -0
  329. package/types/utils/lru_cache.d.ts.map +1 -0
  330. package/types/utils/memoize_promise.d.ts +14 -0
  331. package/types/utils/memoize_promise.d.ts.map +1 -0
  332. package/types/utils/model-loader.d.ts +15 -0
  333. package/types/utils/model-loader.d.ts.map +1 -1
  334. package/types/utils/model_registry/ModelRegistry.d.ts +298 -0
  335. package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -0
  336. package/types/utils/model_registry/clear_cache.d.ts +74 -0
  337. package/types/utils/model_registry/clear_cache.d.ts.map +1 -0
  338. package/types/utils/model_registry/get_available_dtypes.d.ts +26 -0
  339. package/types/utils/model_registry/get_available_dtypes.d.ts.map +1 -0
  340. package/types/utils/model_registry/get_file_metadata.d.ts +20 -0
  341. package/types/utils/model_registry/get_file_metadata.d.ts.map +1 -0
  342. package/types/utils/model_registry/get_files.d.ts +23 -0
  343. package/types/utils/model_registry/get_files.d.ts.map +1 -0
  344. package/types/utils/model_registry/get_model_files.d.ts +48 -0
  345. package/types/utils/model_registry/get_model_files.d.ts.map +1 -0
  346. package/types/utils/model_registry/get_pipeline_files.d.ts +22 -0
  347. package/types/utils/model_registry/get_pipeline_files.d.ts.map +1 -0
  348. package/types/utils/model_registry/get_processor_files.d.ts +9 -0
  349. package/types/utils/model_registry/get_processor_files.d.ts.map +1 -0
  350. package/types/utils/model_registry/get_tokenizer_files.d.ts +9 -0
  351. package/types/utils/model_registry/get_tokenizer_files.d.ts.map +1 -0
  352. package/types/utils/model_registry/is_cached.d.ts +105 -0
  353. package/types/utils/model_registry/is_cached.d.ts.map +1 -0
  354. package/types/utils/model_registry/resolve_model_type.d.ts +24 -0
  355. package/types/utils/model_registry/resolve_model_type.d.ts.map +1 -0
  356. package/types/utils/random.d.ts +86 -0
  357. package/types/utils/random.d.ts.map +1 -0
  358. package/types/utils/tensor.d.ts.map +1 -1
  359. package/src/utils/data-structures.js +0 -572
  360. package/types/models/ast/modeling_ast.d.ts.map +0 -1
  361. package/types/utils/data-structures.d.ts +0 -294
  362. package/types/utils/data-structures.d.ts.map +0 -1
  363. package/types/utils/hub/files.d.ts.map +0 -1
  364. /package/src/models/{ast/modeling_ast.js → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.js} +0 -0
@@ -1,24 +1,28 @@
1
- var Jy=Object.defineProperty;var us=(t,e)=>{for(var s in e)Jy(t,s,{get:e[s],enumerable:!0})};var Yy={},De=Yy;var Zy={},et=Zy;var e0={},yg=e0;var t0="4.0.0-next.1",kg=typeof process<"u",vg=kg&&process?.release?.name==="node",tr=!Sg(De),Eg=!Sg(et),s0=typeof globalThis.Deno<"u",Uv=typeof globalThis.Bun<"u",Ag=typeof window<"u"&&typeof window.document<"u",Mg=typeof self<"u"&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),Cl=typeof self<"u"&&"caches"in self,r0=vg||typeof navigator<"u"&&"gpu"in navigator,n0=typeof navigator<"u"&&"ml"in navigator,o0=()=>{if(typeof navigator>"u")return!1;let t=navigator.userAgent,s=(navigator.vendor||"").indexOf("Apple")>-1,r=!t.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!t.includes("Chrome")&&!t.includes("Android");return s&&r},a0=o0(),ee=Object.freeze({IS_BROWSER_ENV:Ag,IS_WEBWORKER_ENV:Mg,IS_WEB_CACHE_AVAILABLE:Cl,IS_WEBGPU_AVAILABLE:r0,IS_WEBNN_AVAILABLE:n0,IS_SAFARI:a0,IS_PROCESS_AVAILABLE:kg,IS_NODE_ENV:vg,IS_FS_AVAILABLE:tr,IS_PATH_AVAILABLE:Eg}),Nl=tr&&Eg,Fo="./";if(Nl){let t=Object(import.meta).url;t?Fo=et.dirname(et.dirname(yg.fileURLToPath(t))):typeof __dirname<"u"&&(Fo=et.dirname(__dirname))}var i0=Nl?et.join(Fo,"/.cache/"):null,bg="/models/",l0=Nl?et.join(Fo,bg):bg,_e={version:t0,backends:{onnx:{}},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(Ag||Mg),localModelPath:l0,useFS:tr,useBrowserCache:Cl&&!s0,useFSCache:tr,cacheDir:i0,useCustomCache:!1,customCache:null,useWasmCache:Cl||tr,cacheKey:"transformers-cache"};function Sg(t){return Object.keys(t).length===0}var c0=class{constructor(t){this.trie=this._build_trie(t)}_build_trie(t){let e=Object.create(null);for(let s of t){let r=e;for(let n=0;n<s.length;++n){let o=s[n];r=r[o]??=Object.create(null)}r.end=s}return e}split(t){let e=[],s=t.length,r=0,n=0;for(;n<s;){let o=this.trie,a=null,i=n;for(;i<s&&(o=o[t[i]]);)o.end&&(a=o.end),++i;a?(n>r&&e.push(t.slice(r,n)),e.push(a),n+=a.length,r=n):++n}return r<s&&e.push(t.slice(r)),e}},Og=c0,u0=class{constructor(t){this.content=t.content,this.id=t.id,this.single_word=t.single_word??!1,this.lstrip=t.lstrip??!1,this.rstrip=t.rstrip??!1,this.special=t.special??!1,this.normalized=t.normalized??!this.special}},p0=u0,Lg=(()=>{let t=[...Array.from({length:94},(n,o)=>o+33),...Array.from({length:12},(n,o)=>o+161),...Array.from({length:82},(n,o)=>o+174)],e=t.slice(),s=0;for(let n=0;n<256;++n)t.includes(n)||(t.push(n),e.push(256+s),s+=1);let r=e.map(n=>String.fromCharCode(n));return Object.fromEntries(t.map((n,o)=>[n,r[o]]))})(),d0=t=>Object.fromEntries(Object.entries(t).map(([e,s])=>[s,e])),_0=d0(Lg),Ig=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",f0=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"],["(?i:[sdmt]|ll|ve|re)","(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])"],["[^\\r\\n\\p{L}\\p{N}]?+","[^\\r\\n\\p{L}\\p{N}]?"],["[^\\s\\p{L}\\p{N}]++","[^\\s\\p{L}\\p{N}]+"],[` ?[^(\\s|[${Ig}])]+`,` ?[^\\s${Ig}]+`]]),Do="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",$l=t=>t.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n't/g,"n't").replace(/ 'm/g,"'m").replace(/ 's/g,"'s").replace(/ 've/g,"'ve").replace(/ 're/g,"'re"),jo=(t,e=!0)=>{if(t.Regex!==void 0){let s=t.Regex.replace(/\\([#&~])/g,"$1");for(let[r,n]of f0)s=s.replaceAll(r,n);try{return new RegExp(s,"gu")}catch(r){if(!(r instanceof SyntaxError)||!r.message.toLowerCase().includes("invalid property name"))throw r;let n=!1,o=s.replace(/(\\[pP])\{([^}=]+)\}/g,(a,i,l)=>{try{return new RegExp(`\\p{${l}}`,"u"),`${i}{${l}}`}catch{return n=!0,`${i}{Script=${l}}`}});if(!n)throw r;try{return new RegExp(o,"gu")}catch{throw r}}}else if(t.String!==void 0){let s=m0(t.String);return new RegExp(e?s:`(${s})`,"gu")}else return console.warn("Unknown pattern type:",t),null},m0=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h0=(t,e,s)=>{let r=[],n=0;for(;n<t.length;){if(r.push(t[n]),(e.get(t[n])??s)!==s){++n;continue}for(;++n<t.length&&(e.get(t[n])??s)===s;)e.get(r.at(-1))!==s&&(r[r.length-1]+=t[n])}return r},x0=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,g0=t=>Number.isInteger(t)||typeof t=="bigint",w0=t=>{let e=0;for(let s of t)++e;return e},y0=t=>$g(t.toLowerCase()),tt=(...t)=>Array.prototype.concat.apply([],t),Rl=t=>new Map(Object.entries(t)),b0=(t,e)=>{let s=[],r=0;for(let n of t.matchAll(e)){let o=n[0];r<n.index&&s.push(t.slice(r,n.index)),o.length>0&&s.push(o),r=n.index+o.length}return r<t.length&&s.push(t.slice(r)),s},$g=t=>t.replace(/\p{M}/gu,""),zg=(t,e,s=[])=>{if(!t||Array.isArray(t)||typeof t!="object")return`${e} must be a valid object`;for(let r of s)if(!(r in t))return`${e} must contain a "${r}" property`;return null},k0=t=>t.match(/\S+/g)||[],v0=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},sr=v0,E0=class extends sr{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},wt=E0,A0=class extends wt{tokenize_chinese_chars(t){let e=[];for(let s=0;s<t.length;++s){let r=t[s],n=r.charCodeAt(0);x0(n)?(e.push(" "),e.push(r),e.push(" ")):e.push(r)}return e.join("")}strip_accents(t){return t.normalize("NFD").replace(/\p{Mn}/gu,"")}is_control(t){switch(t){case" ":case`
2
- `:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(t)}}clean_text(t){let e=[];for(let s of t){let r=s.charCodeAt(0);r===0||r===65533||this.is_control(s)||(/^\s$/.test(s)?e.push(" "):e.push(s))}return e.join("")}normalize(t){return this.config.clean_text&&(t=this.clean_text(t)),this.config.handle_chinese_chars&&(t=this.tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.strip_accents(t))):this.config.strip_accents&&(t=this.strip_accents(t)),t}},M0=A0,S0=class extends wt{constructor(t){super(t),this.charsmap=t.precompiled_charsmap??null}normalize(t){return t=t.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),t=t.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," "),t.includes("\uFF5E")?t=t.split("\uFF5E").map(s=>s.normalize("NFKC")).join("\uFF5E"):t=t.normalize("NFKC"),t}},O0=S0,I0=class extends wt{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>Rg(e))}normalize(t){return this.normalizers.reduce((e,s)=>s?s.normalize(e):e,t)}},z0=I0,T0=class extends wt{normalize(t){let e=jo(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},P0=T0,C0=class extends wt{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Bo=C0,N0=class extends Bo{constructor(){super(...arguments),this.form="NFC"}},L0=N0,$0=class extends Bo{constructor(){super(...arguments),this.form="NFD"}},R0=$0,F0=class extends Bo{constructor(){super(...arguments),this.form="NFKC"}},D0=F0,j0=class extends Bo{constructor(){super(...arguments),this.form="NFKD"}},B0=j0,U0=class extends wt{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}},q0=U0,G0=class extends wt{normalize(t){return $g(t)}},W0=G0,V0=class extends wt{normalize(t){return t.toLowerCase()}},H0=V0,X0=class extends wt{normalize(t){return t=this.config.prepend+t,t}},K0=X0;function Q0(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new M0(t);case"Precompiled":return new O0(t);case"Sequence":return new z0(t);case"Replace":return new P0(t);case"NFC":return new L0(t);case"NFD":return new R0(t);case"NFKC":return new D0(t);case"NFKD":return new B0(t);case"Strip":return new q0(t);case"StripAccents":return new W0(t);case"Lowercase":return new H0(t);case"Prepend":return new K0(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var Rg=Q0,J0=class extends sr{pre_tokenize(t,e){return(Array.isArray(t)?t.map(s=>this.pre_tokenize_text(s,e)):this.pre_tokenize_text(t,e)).flat()}_call(t,e){return this.pre_tokenize(t,e)}},st=J0,Y0=class extends st{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=Lg,this.text_encoder=new TextEncoder}pre_tokenize_text(t,e){return this.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(r=>Array.from(this.text_encoder.encode(r),n=>this.byte_encoder[n]).join(""))}},Z0=Y0,eb=class extends st{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},tb=eb,sb=class extends st{constructor(t){super(),this.replacement=t.replacement??"\u2581",this.str_rep=t.str_rep||this.replacement,this.prepend_scheme=t.prepend_scheme??"always"}pre_tokenize_text(t,e){let{section_index:s=void 0}=e??{},r=t.replaceAll(" ",this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&s===0)&&(r=this.str_rep+r),[r]}},rb=sb,nb=class extends st{constructor(t){super(),this.config=t,this.pattern=jo(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:this.config.behavior?.toLowerCase()==="removed"?t.split(this.pattern).filter(e=>e):b0(t,this.pattern)}},ob=nb,ab=class extends st{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${Do}]+|[${Do}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},ib=ab,lb=class extends st{constructor(t){super(),this.config=t;let e=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(e,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},cb=lb,ub=class extends st{constructor(){super(),this.pattern=new RegExp(`[^\\s${Do}]+|[${Do}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},pb=ub,db=class extends st{constructor(t){super(),this.config=t,this.pattern=jo(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},_b=db,fb=class extends st{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>Fg(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((s,r)=>r?r.pre_tokenize(s,e):s,[t])}},mb=fb,hb=class extends st{pre_tokenize_text(t){return k0(t)}},xb=hb,gb=class extends st{constructor(t){super(),this.config=t,this._length=t.length}pre_tokenize_text(t){let e=[];for(let s=0;s<t.length;s+=this._length)e.push(t.slice(s,s+this._length));return e}},wb=gb;function yb(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new pb;case"Sequence":return new mb(t);case"Whitespace":return new tb;case"WhitespaceSplit":return new xb;case"Metaspace":return new rb(t);case"ByteLevel":return new Z0(t);case"Split":return new ob(t);case"Punctuation":return new ib(t);case"Digits":return new cb(t);case"Replace":return new _b(t);case"FixedLength":return new wb(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var Fg=yb,bb=class extends sr{constructor(t){super(),this.config=t,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}_call(t){let e=this.encode(t);return this.fuse_unk&&(e=h0(e,this.tokens_to_ids,this.unk_token_id)),e}},Uo=bb,kb=class extends Uo{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=Rl(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(let[e,s]of this.tokens_to_ids)this.vocab[s]=e}encode(t){let e=[];for(let s of t){let r=[...s];if(r.length>this.max_input_chars_per_word){e.push(this.unk_token);continue}let n=!1,o=0,a=[];for(;o<r.length;){let i=r.length,l=null;for(;o<i;){let c=r.slice(o,i).join("");if(o>0&&(c=this.config.continuing_subword_prefix+c),this.tokens_to_ids.has(c)){l=c;break}--i}if(l===null){n=!0;break}a.push(l),o=i}n?e.push(this.unk_token):e.push(...a)}return e}},Tg=kb,Pg=class Dg{constructor(e,s){this.is_leaf=e,this.children=s}static default(){return new Dg(!1,new Map)}},vb=class{constructor(){this.root=Pg.default()}extend(t){for(let e of t)this.push(e)}push(t){let e=this.root;for(let s of t){let r=e.children.get(s);r===void 0&&(r=Pg.default(),e.children.set(s,r)),e=r}e.is_leaf=!0}*common_prefix_search(t){let e=this.root;if(e===void 0)return;let s="";for(let r of t){if(s+=r,e=e.children.get(r),e===void 0)return;e.is_leaf&&(yield s)}}},Eb=vb,Ll=class jg{constructor(e,s,r,n,o){this.token_id=e,this.node_id=s,this.pos=r,this.length=n,this.score=o,this.prev=null,this.backtrace_score=0}clone(){let e=new jg(this.token_id,this.node_id,this.pos,this.length,this.score);return e.prev=this.prev,e.backtrace_score=this.backtrace_score,e}},Ab=class{constructor(t,e,s){this.chars=Array.from(t),this.len=this.chars.length,this.bos_token_id=e,this.eos_token_id=s,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new Ll(this.bos_token_id??0,0,0,0,0),n=new Ll(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(n.clone()),this.begin_nodes[this.len].push(n),this.end_nodes[0].push(r)}insert(t,e,s,r){let n=this.nodes.length,o=new Ll(r,n,t,e,s);this.begin_nodes[t].push(o),this.end_nodes[t+e].push(o),this.nodes.push(o)}viterbi(){let t=this.len,e=0;for(;e<=t;){if(this.begin_nodes[e].length==0)return[];for(let a of this.begin_nodes[e]){a.prev=null;let i=0,l=null;for(let c of this.end_nodes[e]){let u=c.backtrace_score+a.score;(l===null||u>i)&&(l=c.clone(),i=u)}if(l!==null)a.prev=l,a.backtrace_score=i;else return[]}++e}let s=[],n=this.begin_nodes[t][0].prev;if(n===null)return[];let o=n.clone();for(;o.prev!==null;)s.push(o.clone()),o=o.clone().prev.clone();return s.reverse(),s}piece(t){return this.chars.slice(t.pos,t.pos+t.length).join("")}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}},Mb=Ab;function Sb(t){if(t.length===0)throw new Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]<e&&(e=t[r],s=r);return[e,s]}var Ob=class extends Uo{constructor(t,e){super(t);let s=t.vocab.length;this.vocab=new Array(s),this.scores=new Array(s);for(let r=0;r<s;++r)[this.vocab[r],this.scores[r]]=t.vocab[r];this.unk_token_id=t.unk_id,this.unk_token=this.vocab[t.unk_id],this.tokens_to_ids=new Map(this.vocab.map((r,n)=>[r,n])),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=Sb(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new Eb,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(t){let e=t.chars,s=1,r=0;for(;r<e.length;){let n=!1,o=[],a=e.slice(r).join(""),i=this.trie.common_prefix_search(a);for(let l of i){o.push(l);let c=this.tokens_to_ids.get(l),u=this.scores[c],p=w0(l);t.insert(r,p,u,c),!n&&p===s&&(n=!0)}n||t.insert(r,s,this.unk_score,this.unk_token_id),r+=s}}tokenize(t){let e=new Mb(t,this.bos_token_id,this.eos_token_id);return this.populate_nodes(e),e.tokens()}encode(t){let e=[];for(let s of t){let r=this.tokenize(s);e.push(...r)}return e}},Cg=Ob,Ib=class{constructor(t=(s,r)=>s>r,e=1/0){this._heap=[],this._comparator=t,this._max_size=e}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(let e of t)if(this.size<this._max_size)this._heap.push(e),this._sift_up();else{let s=this._smallest();this._comparator(e,this._heap[s])&&(this._heap[s]=e,this._sift_up_from(s))}return this.size}pop(){let t=this.peek(),e=this.size-1;return e>0&&this._swap(0,e),this._heap.pop(),this._sift_down(),t}replace(t){let e=this.peek();return this._heap[0]=t,this._sift_down(),e}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,e){return this._comparator(this._heap[t],this._heap[e])}_swap(t,e){let s=this._heap[t];this._heap[t]=this._heap[e],this._heap[e]=s}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(t){for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_sift_down(){let t=0;for(;this._left(t)<this.size&&this._greater(this._left(t),t)||this._right(t)<this.size&&this._greater(this._right(t),t);){let e=this._right(t)<this.size&&this._greater(this._right(t),this._left(t))?this._right(t):this._left(t);this._swap(t,e),t=e}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},zb=Ib,Tb=class{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;let e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},Pb=Tb,Cb=class extends Uo{constructor(t){super(t),this.tokens_to_ids=Rl(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(let[s,r]of this.tokens_to_ids)this.vocab[r]=s;let e=Array.isArray(t.merges[0]);this.merges=e?t.merges:t.merges.map(s=>s.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((s,r)=>[JSON.stringify(s),r])),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new Pb(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(t){if(t.length===0)return[];let e=this.cache.get(t);if(e!==void 0)return e;let s=Array.from(t);this.end_of_word_suffix&&(s[s.length-1]+=this.end_of_word_suffix);let r=[];if(s.length>1){let n=new zb((i,l)=>i.score<l.score),o={token:s[0],bias:0,prev:null,next:null},a=o;for(let i=1;i<s.length;++i){let l={bias:i/s.length,token:s[i],prev:a,next:null};a.next=l,this.add_node(n,a),a=l}for(;!n.is_empty();){let i=n.pop();if(i.deleted||!i.next||i.next.deleted)continue;if(i.deleted=!0,i.next.deleted=!0,i.prev){let c={...i.prev};i.prev.deleted=!0,i.prev=c,c.prev?c.prev.next=c:o=c}let l={token:i.token+i.next.token,bias:i.bias,prev:i.prev,next:i.next.next};l.prev?(l.prev.next=l,this.add_node(n,l.prev)):o=l,l.next&&(l.next.prev=l,this.add_node(n,l))}for(let i=o;i!==null;i=i.next)r.push(i.token)}else r=s;if(this.continuing_subword_suffix)for(let n=0;n<r.length-1;++n)r[n]+=this.continuing_subword_suffix;return t.length<this.max_length_to_cache&&this.cache.put(t,r),r}add_node(t,e){let s=this.bpe_ranks.get(JSON.stringify([e.token,e.next.token]));s!==void 0&&(e.score=s+e.bias,t.push(e))}encode(t){let e=[];for(let s of t){if(this.ignore_merges&&this.tokens_to_ids.has(s)){e.push(s);continue}let r=this.bpe(s);for(let n of r)if(this.tokens_to_ids.has(n))e.push(n);else if(this.byte_fallback){let o=Array.from(this.text_encoder.encode(n)).map(a=>`<0x${a.toString(16).toUpperCase().padStart(2,"0")}>`);o.every(a=>this.tokens_to_ids.has(a))?e.push(...o):e.push(this.unk_token)}else e.push(this.unk_token)}return e}},Ng=Cb,Nb=class extends Uo{constructor(t,e){super(t);let s=t.vocab;this.tokens_to_ids=Rl(e.target_lang?s[e.target_lang]:s),this.bos_token=e.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=e.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=e.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(let[r,n]of this.tokens_to_ids)this.vocab[n]=r}encode(t){return t}},Lb=Nb;function $b(t,e){switch(t.type){case"WordPiece":return new Tg(t);case"Unigram":return new Cg(t,e.eos_token);case"BPE":return new Ng(t);default:if(t.vocab)return Array.isArray(t.vocab)?new Cg(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new Ng(t):new Tg(t):new Lb(t,{target_lang:e.target_lang,bos_token:e.bos_token,eos_token:e.eos_token,pad_token:e.pad_token,unk_token:e.unk_token});throw new Error(`Unknown TokenizerModel type: ${t?.type}`)}}var Rb=$b,Fb=class extends sr{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},rr=Fb,Db=class extends rr{post_process(t,e=null,s=!0){let r=e===null?this.config.single:this.config.pair,n=[],o=[];for(let a of r)"SpecialToken"in a?s&&(n.push(a.SpecialToken.id),o.push(a.SpecialToken.type_id)):"Sequence"in a&&(a.Sequence.id==="A"?(n=tt(n,t),o=tt(o,new Array(t.length).fill(a.Sequence.type_id))):a.Sequence.id==="B"&&(n=tt(n,e),o=tt(o,new Array(e.length).fill(a.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},jb=Db,Bb=class extends rr{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},Ub=Bb,qb=class extends rr{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,s=!0){s&&(t=tt([this.cls[0]],t,[this.sep[0]]));let r=new Array(t.length).fill(0);if(e){let n=[],o=s?[this.sep[0]]:[];t=tt(t,n,e,o),r=tt(r,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:r}}},Gb=qb,Wb=class extends rr{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,s=!0){s&&(t=tt([this.cls[0]],t,[this.sep[0]]));let r=new Array(t.length).fill(0);if(e){let n=s?[this.sep[0]]:[],o=s?[this.sep[0]]:[];t=tt(t,n,e,o),r=tt(r,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:r}}},Vb=Wb,Hb=class extends rr{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>Bg(e))}post_process(t,e=null,s=!0){let r={tokens:t,tokens_pair:e};for(let n of this.processors)r=n.post_process(r.tokens,r.tokens_pair,s);return r}},Xb=Hb;function Kb(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new jb(t);case"ByteLevel":return new Ub(t);case"BertProcessing":return new Gb(t);case"RobertaProcessing":return new Vb(t);case"Sequence":return new Xb(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var Bg=Kb,Qb=class extends sr{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets="trim_offsets"in t?t.trim_offsets:!1}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}},We=Qb,Jb=class extends We{constructor(t){super(t),this.byte_decoder=_0,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let e=t.join(""),s=new Uint8Array([...e].map(r=>this.byte_decoder[r]));return this.text_decoder.decode(s)}decode_chain(t){let e=[],s=[];for(let r of t)this.added_tokens.find(n=>n.content===r)!==void 0?(s.length>0&&(e.push(this.convert_tokens_to_string(s)),s=[]),e.push(r)):s.push(r);return s.length>0&&e.push(this.convert_tokens_to_string(s)),e}},Yb=Jb,Zb=class extends We{constructor(t){super(t),this.cleanup=t.cleanup}decode_chain(t){return t.map((e,s)=>{if(s!==0){let r=this.config.prefix;r&&e.startsWith(r)?e=e.replace(r,""):e=" "+e}return this.cleanup&&(e=$l(e)),e})}},e1=Zb,t1=class extends We{constructor(t){super(t),this.replacement=t.replacement??"\u2581"}decode_chain(t){let e=[];for(let s=0;s<t.length;++s){let r=t[s].replaceAll(this.replacement," ");s==0&&r.startsWith(" ")&&(r=r.substring(1)),e.push(r)}return e}},s1=t1,r1=class extends We{constructor(t){super(t),this.suffix=t.suffix??""}decode_chain(t){return t.map((e,s)=>e.replaceAll(this.suffix,s===t.length-1?"":" "))}},n1=r1,o1=class extends We{constructor(t){super(t),this.pad_token=t.pad_token??"",this.word_delimiter_token=t.word_delimiter_token??"",this.cleanup=t.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let e=[t[0]];for(let n=1;n<t.length;++n)t[n]!==e.at(-1)&&e.push(t[n]);let r=e.filter(n=>n!==this.pad_token).join("");return this.cleanup&&(r=$l(r).replaceAll(this.word_delimiter_token," ").trim()),r}decode_chain(t){return[this.convert_tokens_to_string(t)]}},a1=o1,i1=class extends We{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>Ug(e))}decode_chain(t){return this.decoders.reduce((e,s)=>s.decode_chain(e),t)}},l1=i1,c1=class extends We{decode_chain(t){let e=jo(this.config.pattern),s=this.config.content??"";return e===null?t:t.map(r=>r.replaceAll(e,s))}},u1=c1,p1=class extends We{decode_chain(t){return[t.join("")]}},d1=p1,_1=class extends We{constructor(t){super(t),this.content=t.content??"",this.start=t.start??0,this.stop=t.stop??0}decode_chain(t){return t.map(e=>{let s=0;for(let n=0;n<this.start&&e[n]===this.content;++n){s=n+1;continue}let r=e.length;for(let n=0;n<this.stop;++n){let o=e.length-n-1;if(e[o]===this.content){r=o;continue}else break}return e.slice(s,r)})}},f1=_1,m1=class extends We{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let e=[],s=[];for(let r of t){let n=null;if(r.length===6&&r.startsWith("<0x")&&r.endsWith(">")){let o=parseInt(r.slice(3,5),16);isNaN(o)||(n=o)}if(n!==null)s.push(n);else{if(s.length>0){let o=this.text_decoder.decode(Uint8Array.from(s));e.push(o),s=[]}e.push(r)}}if(s.length>0){let r=this.text_decoder.decode(Uint8Array.from(s));e.push(r),s=[]}return e}},h1=m1;function x1(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new Yb(t);case"WordPiece":return new e1(t);case"Metaspace":return new s1(t);case"BPEDecoder":return new n1(t);case"CTC":return new a1(t);case"Sequence":return new l1(t);case"Replace":return new u1(t);case"Fuse":return new d1(t);case"Strip":return new f1(t);case"ByteFallback":return new h1(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var Ug=x1,g1=class{constructor(t,e){let s=zg(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(s)throw new Error(s);let r=zg(e,"Config");if(r)throw new Error(r);this.tokenizer=t,this.config=e,this.normalizer=Rg(this.tokenizer.normalizer),this.pre_tokenizer=Fg(this.tokenizer.pre_tokenizer),this.model=Rb(this.tokenizer.model,this.config),this.post_processor=Bg(this.tokenizer.post_processor),this.decoder=Ug(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let n=[],o=[];this.added_tokens_map=new Map;for(let a of this.tokenizer.added_tokens){let i=new p0(a);if(this.added_tokens.push(i),this.model.tokens_to_ids.set(i.content,i.id),this.model.vocab[i.id]=i.content,i.special&&(this.special_tokens.push(i.content),this.all_special_ids.push(i.id)),this.added_tokens_map.set(i.content,i),i.normalized&&this.normalizer!==null){let l=this.normalizer(i.content);o.push(l),this.added_tokens_map.set(l,i)}else n.push(i.content)}(this.config.additional_special_tokens??[]).forEach(a=>{this.special_tokens.includes(a)||this.special_tokens.push(a)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new Og(n),this.splitter_normalized=new Og(o),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(t,{text_pair:e=null,add_special_tokens:s=!0,return_token_type_ids:r=null}={}){let{tokens:n,token_type_ids:o}=this.tokenize_helper(t,{text_pair:e,add_special_tokens:s}),a=n.map(l=>this.added_tokens_map.get(l)?.id??this.model.tokens_to_ids.get(l)??this.model.unk_token_id),i={ids:a,tokens:n,attention_mask:new Array(a.length).fill(1)};return r&&o&&(i.token_type_ids=o),i}decode(t,e={}){if(!Array.isArray(t)||t.length===0||!g0(t[0]))throw Error("token_ids must be a non-empty array of integers.");let s=t.map(n=>this.model.vocab[Number(n)]??this.model.unk_token);e.skip_special_tokens&&(s=s.filter(n=>!this.special_tokens.includes(n)));let r=this.decoder?this.decoder(s):s.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix," "),e.skip_special_tokens&&(r=r.trim())),(e.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=$l(r)),r}tokenize(t,{text_pair:e=null,add_special_tokens:s=!1}={}){return this.tokenize_helper(t,{text_pair:e,add_special_tokens:s}).tokens}encode_text(t){if(t===null)return null;let e=this.splitter_unnormalized.split(t);return e.forEach((s,r)=>{let n=this.added_tokens_map.get(s);n&&(n.lstrip&&r>0&&(e[r-1]=e[r-1].trimEnd()),n.rstrip&&r<e.length-1&&(e[r+1]=e[r+1].trimStart()))}),e.flatMap((s,r)=>{if(s.length===0)return[];if(this.added_tokens_map.has(s))return[s];if(this.remove_space===!0&&(s=s.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(s=y0(s)),this.normalizer!==null&&(s=this.normalizer(s)),s.length===0)return[];let n=this.splitter_normalized.split(s);return n.forEach((o,a)=>{let i=this.added_tokens_map.get(o);i&&(i.lstrip&&a>0&&(n[a-1]=n[a-1].trimEnd()),i.rstrip&&a<n.length-1&&(n[a+1]=n[a+1].trimStart()))}),n.flatMap(o=>{if(o.length===0)return[];if(this.added_tokens_map.has(o))return[o];let a=this.pre_tokenizer!==null?this.pre_tokenizer(o,{section_index:r}):[o];return this.model(a)})})}tokenize_helper(t,{text_pair:e=null,add_special_tokens:s=!0}){let r=this.encode_text(t),n=this.encode_text(e||null);return this.post_processor?this.post_processor(r,n,s):{tokens:tt(r??[],n??[])}}token_to_id(t){return this.model.tokens_to_ids.get(t)}id_to_token(t){return this.model.vocab[t]}get_added_tokens_decoder(){let t=new Map;for(let e of this.added_tokens)t.set(e.id,e);return t}get_vocab(t=!0){let e=new Map;for(let s=0;s<this.model.vocab.length;++s){let r=this.model.vocab[s];(t||!this.added_tokens_map.has(r))&&e.set(r,s)}return e}},qg=g1;var M=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),Ve=class{constructor(t,e){this.value=t,this.type=e}};function Gg(t){return/\w/.test(t)}function nr(t){return/[0-9]/.test(t)}function Wg(t){return/\s/.test(t)}var w1=[["{%",M.OpenStatement],["%}",M.CloseStatement],["{{",M.OpenExpression],["}}",M.CloseExpression],["(",M.OpenParen],[")",M.CloseParen],["{",M.OpenCurlyBracket],["}",M.CloseCurlyBracket],["[",M.OpenSquareBracket],["]",M.CloseSquareBracket],[",",M.Comma],[".",M.Dot],[":",M.Colon],["|",M.Pipe],["<=",M.ComparisonBinaryOperator],[">=",M.ComparisonBinaryOperator],["==",M.ComparisonBinaryOperator],["!=",M.ComparisonBinaryOperator],["<",M.ComparisonBinaryOperator],[">",M.ComparisonBinaryOperator],["+",M.AdditiveBinaryOperator],["-",M.AdditiveBinaryOperator],["~",M.AdditiveBinaryOperator],["*",M.MultiplicativeBinaryOperator],["/",M.MultiplicativeBinaryOperator],["%",M.MultiplicativeBinaryOperator],["=",M.Equals]],y1=new Map([["n",`
3
- `],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function b1(t,e={}){return t.endsWith(`
4
- `)&&(t=t.slice(0,-1)),e.lstrip_blocks&&(t=t.replace(/^[ \t]*({[#%-])/gm,"$1")),e.trim_blocks&&(t=t.replace(/([#%-]})\n/g,"$1")),t.replace(/{%\s*(end)?generation\s*%}/gs,"")}function k1(t,e={}){let s=[],r=b1(t,e),n=0,o=0,a=c=>{let u="";for(;c(r[n]);){if(r[n]==="\\"){if(++n,n>=r.length)throw new SyntaxError("Unexpected end of input");let p=r[n++],d=y1.get(p);if(d===void 0)throw new SyntaxError(`Unexpected escaped character: ${p}`);u+=d;continue}if(u+=r[n++],n>=r.length)throw new SyntaxError("Unexpected end of input")}return u},i=()=>{let c=s.at(-1);c&&c.type===M.Text&&(c.value=c.value.trimEnd(),c.value===""&&s.pop())},l=()=>{for(;n<r.length&&Wg(r[n]);)++n};e:for(;n<r.length;){let c=s.at(-1)?.type;if(c===void 0||c===M.CloseStatement||c===M.CloseExpression||c===M.Comment){let p="";for(;n<r.length&&!(r[n]==="{"&&(r[n+1]==="%"||r[n+1]==="{"||r[n+1]==="#"));)p+=r[n++];if(p.length>0){s.push(new Ve(p,M.Text));continue}}if(r[n]==="{"&&r[n+1]==="#"){n+=2;let p=r[n]==="-";p&&++n;let d="";for(;r[n]!=="#"||r[n+1]!=="}";){if(n+2>=r.length)throw new SyntaxError("Missing end of comment tag");d+=r[n++]}let _=d.endsWith("-");_&&(d=d.slice(0,-1)),p&&i(),s.push(new Ve(d,M.Comment)),n+=2,_&&l();continue}if(r.slice(n,n+3)==="{%-"){i(),s.push(new Ve("{%",M.OpenStatement)),n+=3;continue}if(r.slice(n,n+3)==="{{-"){i(),s.push(new Ve("{{",M.OpenExpression)),o=0,n+=3;continue}if(a(Wg),r.slice(n,n+3)==="-%}"){s.push(new Ve("%}",M.CloseStatement)),n+=3,l();continue}if(r.slice(n,n+3)==="-}}"){s.push(new Ve("}}",M.CloseExpression)),n+=3,l();continue}let u=r[n];if(u==="-"||u==="+"){let p=s.at(-1)?.type;if(p===M.Text||p===void 0)throw new SyntaxError(`Unexpected character: ${u}`);switch(p){case M.Identifier:case M.NumericLiteral:case M.StringLiteral:case M.CloseParen:case M.CloseSquareBracket:break;default:{++n;let d=a(nr);s.push(new Ve(`${u}${d}`,d.length>0?M.NumericLiteral:M.UnaryOperator));continue}}}for(let[p,d]of w1){if(p==="}}"&&o>0)continue;if(r.slice(n,n+p.length)===p){s.push(new Ve(p,d)),d===M.OpenExpression?o=0:d===M.OpenCurlyBracket?++o:d===M.CloseCurlyBracket&&--o,n+=p.length;continue e}}if(u==="'"||u==='"'){++n;let p=a(d=>d!==u);s.push(new Ve(p,M.StringLiteral)),++n;continue}if(nr(u)){let p=a(nr);if(r[n]==="."&&nr(r[n+1])){++n;let d=a(nr);p=`${p}.${d}`}s.push(new Ve(p,M.NumericLiteral));continue}if(Gg(u)){let p=a(Gg);s.push(new Ve(p,M.Identifier));continue}throw new SyntaxError(`Unexpected character: ${u}`)}return s}var nt=class{type="Statement"},v1=class extends nt{constructor(t){super(),this.body=t}type="Program"},E1=class extends nt{constructor(t,e,s){super(),this.test=t,this.body=e,this.alternate=s}type="If"},A1=class extends nt{constructor(t,e,s,r){super(),this.loopvar=t,this.iterable=e,this.body=s,this.defaultBlock=r}type="For"},M1=class extends nt{type="Break"},S1=class extends nt{type="Continue"},O1=class extends nt{constructor(t,e,s){super(),this.assignee=t,this.value=e,this.body=s}type="Set"},I1=class extends nt{constructor(t,e,s){super(),this.name=t,this.args=e,this.body=s}type="Macro"},z1=class extends nt{constructor(t){super(),this.value=t}type="Comment"},qe=class extends nt{type="Expression"},T1=class extends qe{constructor(t,e,s){super(),this.object=t,this.property=e,this.computed=s}type="MemberExpression"},Vg=class extends qe{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},ps=class extends qe{constructor(t){super(),this.value=t}type="Identifier"},ds=class extends qe{constructor(t){super(),this.value=t}type="Literal"},P1=class extends ds{type="IntegerLiteral"},C1=class extends ds{type="FloatLiteral"},Hg=class extends ds{type="StringLiteral"},N1=class extends ds{type="ArrayLiteral"},Xg=class extends ds{type="TupleLiteral"},L1=class extends ds{type="ObjectLiteral"},or=class extends qe{constructor(t,e,s){super(),this.operator=t,this.left=e,this.right=s}type="BinaryExpression"},$1=class extends qe{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},R1=class extends nt{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},F1=class extends qe{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},D1=class extends qe{constructor(t,e,s){super(),this.operand=t,this.negate=e,this.test=s}type="TestExpression"},j1=class extends qe{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},B1=class extends qe{constructor(t=void 0,e=void 0,s=void 0){super(),this.start=t,this.stop=e,this.step=s}type="SliceExpression"},U1=class extends qe{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},q1=class extends qe{constructor(t){super(),this.argument=t}type="SpreadExpression"},G1=class extends nt{constructor(t,e,s){super(),this.call=t,this.callerArgs=e,this.body=s}type="CallStatement"},W1=class extends qe{constructor(t,e,s){super(),this.condition=t,this.trueExpr=e,this.falseExpr=s}type="Ternary"};function V1(t){let e=new v1([]),s=0;function r(k,v){let I=t[s++];if(!I||I.type!==k)throw new Error(`Parser Error: ${v}. ${I.type} !== ${k}.`);return I}function n(k){if(!l(k))throw new SyntaxError(`Expected ${k}`);++s}function o(){switch(t[s].type){case M.Comment:return new z1(t[s++].value);case M.Text:return c();case M.OpenStatement:return u();case M.OpenExpression:return p();default:throw new SyntaxError(`Unexpected token type: ${t[s].type}`)}}function a(...k){return s+k.length<=t.length&&k.every((v,I)=>v===t[s+I].type)}function i(...k){return t[s]?.type===M.OpenStatement&&t[s+1]?.type===M.Identifier&&k.includes(t[s+1]?.value)}function l(...k){return s+k.length<=t.length&&k.every((v,I)=>t[s+I].type==="Identifier"&&v===t[s+I].value)}function c(){return new Hg(r(M.Text,"Expected text token").value)}function u(){if(r(M.OpenStatement,"Expected opening statement token"),t[s].type!==M.Identifier)throw new SyntaxError(`Unknown statement, got ${t[s].type}`);let k=t[s].value,v;switch(k){case"set":++s,v=d();break;case"if":++s,v=_(),r(M.OpenStatement,"Expected {% token"),n("endif"),r(M.CloseStatement,"Expected %} token");break;case"macro":++s,v=m(),r(M.OpenStatement,"Expected {% token"),n("endmacro"),r(M.CloseStatement,"Expected %} token");break;case"for":++s,v=x(),r(M.OpenStatement,"Expected {% token"),n("endfor"),r(M.CloseStatement,"Expected %} token");break;case"call":{++s;let I=null;a(M.OpenParen)&&(I=R());let Q=Y();if(Q.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let Z=R();r(M.CloseStatement,"Expected closing statement token");let Ie=[];for(;!i("endcall");)Ie.push(o());r(M.OpenStatement,"Expected '{%'"),n("endcall"),r(M.CloseStatement,"Expected closing statement token");let Ee=new Vg(Q,Z);v=new G1(Ee,I,Ie);break}case"break":++s,r(M.CloseStatement,"Expected closing statement token"),v=new M1;break;case"continue":++s,r(M.CloseStatement,"Expected closing statement token"),v=new S1;break;case"filter":{++s;let I=Y();I instanceof ps&&a(M.OpenParen)&&(I=F(I)),r(M.CloseStatement,"Expected closing statement token");let Q=[];for(;!i("endfilter");)Q.push(o());r(M.OpenStatement,"Expected '{%'"),n("endfilter"),r(M.CloseStatement,"Expected '%}'"),v=new R1(I,Q);break}default:throw new SyntaxError(`Unknown statement type: ${k}`)}return v}function p(){r(M.OpenExpression,"Expected opening expression token");let k=g();return r(M.CloseExpression,"Expected closing expression token"),k}function d(){let k=h(),v=null,I=[];if(a(M.Equals))++s,v=h();else{for(r(M.CloseStatement,"Expected %} token");!i("endset");)I.push(o());r(M.OpenStatement,"Expected {% token"),n("endset")}return r(M.CloseStatement,"Expected closing statement token"),new O1(k,v,I)}function _(){let k=g();r(M.CloseStatement,"Expected closing statement token");let v=[],I=[];for(;!i("elif","else","endif");)v.push(o());if(i("elif")){++s,++s;let Q=_();I.push(Q)}else if(i("else"))for(++s,++s,r(M.CloseStatement,"Expected closing statement token");!i("endif");)I.push(o());return new E1(k,v,I)}function m(){let k=Y();if(k.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let v=R();r(M.CloseStatement,"Expected closing statement token");let I=[];for(;!i("endmacro");)I.push(o());return new I1(k,v,I)}function h(k=!1){let v=k?Y:g,I=[v()],Q=a(M.Comma);for(;Q&&(++s,I.push(v()),!!a(M.Comma)););return Q?new Xg(I):I[0]}function x(){let k=h(!0);if(!(k instanceof ps||k instanceof Xg))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${k.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++s;let v=g();r(M.CloseStatement,"Expected closing statement token");let I=[];for(;!i("endfor","else");)I.push(o());let Q=[];if(i("else"))for(++s,++s,r(M.CloseStatement,"Expected closing statement token");!i("endfor");)Q.push(o());return new A1(k,v,I,Q)}function g(){return w()}function w(){let k=y();if(l("if")){++s;let v=y();if(l("else")){++s;let I=w();return new W1(v,k,I)}else return new F1(k,v)}return k}function y(){let k=E();for(;l("or");){let v=t[s];++s;let I=E();k=new or(v,k,I)}return k}function E(){let k=A();for(;l("and");){let v=t[s];++s;let I=A();k=new or(v,k,I)}return k}function A(){let k;for(;l("not");){let v=t[s];++s;let I=A();k=new j1(v,I)}return k??b()}function b(){let k=O();for(;;){let v;if(l("not","in"))v=new Ve("not in",M.Identifier),s+=2;else if(l("in"))v=t[s++];else if(a(M.ComparisonBinaryOperator))v=t[s++];else break;let I=O();k=new or(v,k,I)}return k}function O(){let k=X();for(;a(M.AdditiveBinaryOperator);){let v=t[s];++s;let I=X();k=new or(v,k,I)}return k}function N(){let k=D(Y());return a(M.OpenParen)?F(k):k}function F(k){let v=new Vg(k,R());return v=D(v),a(M.OpenParen)&&(v=F(v)),v}function R(){r(M.OpenParen,"Expected opening parenthesis for arguments list");let k=B();return r(M.CloseParen,"Expected closing parenthesis for arguments list"),k}function B(){let k=[];for(;!a(M.CloseParen);){let v;if(t[s].type===M.MultiplicativeBinaryOperator&&t[s].value==="*"){++s;let I=g();v=new q1(I)}else if(v=g(),a(M.Equals)){if(++s,!(v instanceof ps))throw new SyntaxError("Expected identifier for keyword argument");let I=g();v=new U1(v,I)}k.push(v),a(M.Comma)&&++s}return k}function G(){let k=[],v=!1;for(;!a(M.CloseSquareBracket);)a(M.Colon)?(k.push(void 0),++s,v=!0):(k.push(g()),a(M.Colon)&&(++s,v=!0));if(k.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(v){if(k.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new B1(...k)}return k[0]}function D(k){for(;a(M.Dot)||a(M.OpenSquareBracket);){let v=t[s];++s;let I,Q=v.type===M.OpenSquareBracket;if(Q)I=G(),r(M.CloseSquareBracket,"Expected closing square bracket");else if(I=Y(),I.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");k=new T1(k,I,Q)}return k}function X(){let k=V();for(;a(M.MultiplicativeBinaryOperator);){let v=t[s++],I=V();k=new or(v,k,I)}return k}function V(){let k=re();for(;l("is");){++s;let v=l("not");v&&++s;let I=Y();if(!(I instanceof ps))throw new SyntaxError("Expected identifier for the test");k=new D1(k,v,I)}return k}function re(){let k=N();for(;a(M.Pipe);){++s;let v=Y();if(!(v instanceof ps))throw new SyntaxError("Expected identifier for the filter");a(M.OpenParen)&&(v=F(v)),k=new $1(k,v)}return k}function Y(){let k=t[s++];switch(k.type){case M.NumericLiteral:{let v=k.value;return v.includes(".")?new C1(Number(v)):new P1(Number(v))}case M.StringLiteral:{let v=k.value;for(;a(M.StringLiteral);)v+=t[s++].value;return new Hg(v)}case M.Identifier:return new ps(k.value);case M.OpenParen:{let v=h();return r(M.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),v}case M.OpenSquareBracket:{let v=[];for(;!a(M.CloseSquareBracket);)v.push(g()),a(M.Comma)&&++s;return++s,new N1(v)}case M.OpenCurlyBracket:{let v=new Map;for(;!a(M.CloseCurlyBracket);){let I=g();r(M.Colon,"Expected colon between key and value in object literal");let Q=g();v.set(I,Q),a(M.Comma)&&++s}return++s,new L1(v)}default:throw new SyntaxError(`Unexpected token: ${k.type}`)}}for(;s<t.length;)e.body.push(o());return e}function H1(t,e,s=1){if(e===void 0&&(e=t,t=0),s===0)throw new Error("range() step must not be zero");let r=[];if(s>0)for(let n=t;n<e;n+=s)r.push(n);else for(let n=t;n>e;n+=s)r.push(n);return r}function Kg(t,e,s,r=1){let n=Math.sign(r);n>=0?(e=(e??=0)<0?Math.max(t.length+e,0):Math.min(e,t.length),s=(s??=t.length)<0?Math.max(t.length+s,0):Math.min(s,t.length)):(e=(e??=t.length-1)<0?Math.max(t.length+e,-1):Math.min(e,t.length-1),s=(s??=-1)<-1?Math.max(t.length+s,-1):Math.min(s,t.length-1));let o=[];for(let a=e;n*a<n*s;a+=r)o.push(t[a]);return o}function X1(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function K1(t){return Q1(new Date,t)}function Q1(t,e){let s=new Intl.DateTimeFormat(void 0,{month:"long"}),r=new Intl.DateTimeFormat(void 0,{month:"short"}),n=o=>o<10?"0"+o:o.toString();return e.replace(/%[YmdbBHM%]/g,o=>{switch(o){case"%Y":return t.getFullYear().toString();case"%m":return n(t.getMonth()+1);case"%d":return n(t.getDate());case"%b":return r.format(t);case"%B":return s.format(t);case"%H":return n(t.getHours());case"%M":return n(t.getMinutes());case"%%":return"%";default:return o}})}function J1(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y1(t,e,s,r){if(r===0)return t;let n=r==null||r<0?1/0:r,o=e.length===0?new RegExp("(?=)","gu"):new RegExp(J1(e),"gu");return t.replaceAll(o,a=>n>0?(--n,s):a)}var Qg=class extends Error{},Jg=class extends Error{},ut=class{type="RuntimeValue";value;builtins=new Map;constructor(t=void 0){this.value=t}__bool__(){return new U(!!this.value)}toString(){return String(this.value)}},H=class extends ut{type="IntegerValue"},ye=class extends ut{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},$=class extends ut{type="StringValue";builtins=new Map([["upper",new me(()=>new $(this.value.toUpperCase()))],["lower",new me(()=>new $(this.value.toLowerCase()))],["strip",new me(()=>new $(this.value.trim()))],["title",new me(()=>new $(X1(this.value)))],["capitalize",new me(()=>new $(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new H(this.value.length)],["rstrip",new me(()=>new $(this.value.trimEnd()))],["lstrip",new me(()=>new $(this.value.trimStart()))],["startswith",new me(t=>{if(t.length===0)throw new Error("startswith() requires at least one argument");let e=t[0];if(e instanceof $)return new U(this.value.startsWith(e.value));if(e instanceof te){for(let s of e.value){if(!(s instanceof $))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(s.value))return new U(!0)}return new U(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new me(t=>{if(t.length===0)throw new Error("endswith() requires at least one argument");let e=t[0];if(e instanceof $)return new U(this.value.endsWith(e.value));if(e instanceof te){for(let s of e.value){if(!(s instanceof $))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(s.value))return new U(!0)}return new U(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new me(t=>{let e=t[0]??new he;if(!(e instanceof $||e instanceof he))throw new Error("sep argument must be a string or null");let s=t[1]??new H(-1);if(!(s instanceof H))throw new Error("maxsplit argument must be a number");let r=[];if(e instanceof he){let n=this.value.trimStart();for(let{0:o,index:a}of n.matchAll(/\S+/g)){if(s.value!==-1&&r.length>=s.value&&a!==void 0){r.push(o+n.slice(a+o.length));break}r.push(o)}}else{if(e.value==="")throw new Error("empty separator");r=this.value.split(e.value),s.value!==-1&&r.length>s.value&&r.push(r.splice(s.value).join(e.value))}return new te(r.map(n=>new $(n)))})],["replace",new me(t=>{if(t.length<2)throw new Error("replace() requires at least two arguments");let e=t[0],s=t[1];if(!(e instanceof $&&s instanceof $))throw new Error("replace() arguments must be strings");let r;if(t.length>2?t[2].type==="KeywordArgumentsValue"?r=t[2].value.get("count")??new he:r=t[2]:r=new he,!(r instanceof H||r instanceof he))throw new Error("replace() count argument must be a number or null");return new $(Y1(this.value,e.value,s.value,r.value))})]])},U=class extends ut{type="BooleanValue"},Z1=/[\x7f-\uffff]/g;function Yg(t){return t.replace(Z1,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}function Ht(t,e={},s=0,r=!0){let{indent:n=null,ensureAscii:o=!1,separators:a=null,sortKeys:i=!1}=e,l,c;switch(a?[l,c]=a:n?(l=",",c=": "):(l=", ",c=": "),t.type){case"NullValue":return"null";case"UndefinedValue":return r?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(t.value);case"StringValue":{let u=JSON.stringify(t.value);return o&&(u=Yg(u)),u}case"ArrayValue":case"ObjectValue":{let u=n?" ".repeat(n):"",p=`
5
- `+u.repeat(s),d=p+u;if(t.type==="ArrayValue"){let _=t.value.map(m=>Ht(m,e,s+1,r));return n?`[${d}${_.join(`${l}${d}`)}${p}]`:`[${_.join(l)}]`}else{let _=Array.from(t.value.entries());i&&(_=_.sort(([h],[x])=>h.localeCompare(x)));let m=_.map(([h,x])=>{let g=JSON.stringify(h);o&&(g=Yg(g));let w=`${g}${c}${Ht(x,e,s+1,r)}`;return n?`${d}${w}`:w});return n?`{${m.join(l)}${p}}`:`{${m.join(l)}}`}}default:throw new Error(`Cannot convert to JSON: ${t.type}`)}}var Le=class extends ut{type="ObjectValue";__bool__(){return new U(this.value.size>0)}builtins=new Map([["get",new me(([t,e])=>{if(!(t instanceof $))throw new Error(`Object key must be a string: got ${t.type}`);return this.value.get(t.value)??e??new he})],["items",new me(()=>this.items())],["keys",new me(()=>this.keys())],["values",new me(()=>this.values())],["dictsort",new me(t=>{let e=new Map,s=t.filter(i=>i instanceof ar?(e=i.value,!1):!0),r=s.at(0)??e.get("case_sensitive")??new U(!1);if(!(r instanceof U))throw new Error("case_sensitive must be a boolean");let n=s.at(1)??e.get("by")??new $("key");if(!(n instanceof $))throw new Error("by must be a string");if(!["key","value"].includes(n.value))throw new Error("by must be either 'key' or 'value'");let o=s.at(2)??e.get("reverse")??new U(!1);if(!(o instanceof U))throw new Error("reverse must be a boolean");let a=Array.from(this.value.entries()).map(([i,l])=>new te([new $(i),l])).sort((i,l)=>{let c=n.value==="key"?0:1,u=i.value[c],p=l.value[c],d=Fl(u,p,r.value);return o.value?-d:d});return new te(a)})]]);items(){return new te(Array.from(this.value.entries()).map(([t,e])=>new te([new $(t),e])))}keys(){return new te(Array.from(this.value.keys()).map(t=>new $(t)))}values(){return new te(Array.from(this.value.values()))}toString(){return Ht(this,{},0,!1)}},ar=class extends Le{type="KeywordArgumentsValue"},te=class extends ut{type="ArrayValue";builtins=new Map([["length",new H(this.value.length)]]);__bool__(){return new U(this.value.length>0)}toString(){return Ht(this,{},0,!1)}},Zg=class extends te{type="TupleValue"},me=class extends ut{type="FunctionValue"},he=class extends ut{type="NullValue"},fe=class extends ut{type="UndefinedValue"},Vt=class{constructor(t){this.parent=t}variables=new Map([["namespace",new me(t=>{if(t.length===0)return new Le(new Map);if(t.length!==1||!(t[0]instanceof Le))throw new Error("`namespace` expects either zero arguments or a single object argument");return t[0]})]]);tests=new Map([["boolean",t=>t.type==="BooleanValue"],["callable",t=>t instanceof me],["odd",t=>{if(!(t instanceof H))throw new Error(`cannot odd on ${t.type}`);return t.value%2!==0}],["even",t=>{if(!(t instanceof H))throw new Error(`cannot even on ${t.type}`);return t.value%2===0}],["false",t=>t.type==="BooleanValue"&&!t.value],["true",t=>t.type==="BooleanValue"&&t.value],["none",t=>t.type==="NullValue"],["string",t=>t.type==="StringValue"],["number",t=>t instanceof H||t instanceof ye],["integer",t=>t instanceof H],["iterable",t=>t.type==="ArrayValue"||t.type==="StringValue"],["mapping",t=>t.type==="ObjectValue"],["lower",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toLowerCase()}],["upper",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toUpperCase()}],["none",t=>t.type==="NullValue"],["defined",t=>t.type!=="UndefinedValue"],["undefined",t=>t.type==="UndefinedValue"],["equalto",(t,e)=>t.value===e.value],["eq",(t,e)=>t.value===e.value]]);set(t,e){return this.declareVariable(t,qo(e))}declareVariable(t,e){if(this.variables.has(t))throw new SyntaxError(`Variable already declared: ${t}`);return this.variables.set(t,e),e}setVariable(t,e){return this.variables.set(t,e),e}resolve(t){if(this.variables.has(t))return this;if(this.parent)return this.parent.resolve(t);throw new Error(`Unknown variable: ${t}`)}lookupVariable(t){try{return this.resolve(t).variables.get(t)??new fe}catch{return new fe}}};function ek(t){t.set("false",!1),t.set("true",!0),t.set("none",null),t.set("raise_exception",e=>{throw new Error(e)}),t.set("range",H1),t.set("strftime_now",K1),t.set("True",!0),t.set("False",!1),t.set("None",null)}function ew(t,e){let s=e.split("."),r=t;for(let n of s)if(r instanceof Le)r=r.value.get(n)??new fe;else if(r instanceof te){let o=parseInt(n,10);if(!isNaN(o)&&o>=0&&o<r.value.length)r=r.value[o];else return new fe}else return new fe;return r}function Fl(t,e,s=!1){if(t instanceof he&&e instanceof he)return 0;if(t instanceof he||e instanceof he)throw new Error(`Cannot compare ${t.type} with ${e.type}`);if(t instanceof fe&&e instanceof fe)return 0;if(t instanceof fe||e instanceof fe)throw new Error(`Cannot compare ${t.type} with ${e.type}`);let r=o=>o instanceof H||o instanceof ye||o instanceof U,n=o=>o instanceof U?o.value?1:0:o.value;if(r(t)&&r(e)){let o=n(t),a=n(e);return o<a?-1:o>a?1:0}if(t.type!==e.type)throw new Error(`Cannot compare different types: ${t.type} and ${e.type}`);if(t.type==="StringValue"){let o=t.value,a=e.value;return s||(o=o.toLowerCase(),a=a.toLowerCase()),o<a?-1:o>a?1:0}else throw new Error(`Cannot compare type: ${t.type}`)}var tk=class{global;constructor(t){this.global=t??new Vt}run(t){return this.evaluate(t,this.global)}evaluateBinaryExpression(t,e){let s=this.evaluate(t.left,e);switch(t.operator.value){case"and":return s.__bool__().value?this.evaluate(t.right,e):s;case"or":return s.__bool__().value?s:this.evaluate(t.right,e)}let r=this.evaluate(t.right,e);switch(t.operator.value){case"==":return new U(s.value==r.value);case"!=":return new U(s.value!=r.value)}if(s instanceof fe||r instanceof fe){if(r instanceof fe&&["in","not in"].includes(t.operator.value))return new U(t.operator.value==="not in");throw new Error(`Cannot perform operation ${t.operator.value} on undefined values`)}else{if(s instanceof he||r instanceof he)throw new Error("Cannot perform operation on null values");if(t.operator.value==="~")return new $(s.value.toString()+r.value.toString());if((s instanceof H||s instanceof ye)&&(r instanceof H||r instanceof ye)){let n=s.value,o=r.value;switch(t.operator.value){case"+":case"-":case"*":{let a=t.operator.value==="+"?n+o:t.operator.value==="-"?n-o:n*o;return s instanceof ye||r instanceof ye?new ye(a):new H(a)}case"/":return new ye(n/o);case"%":{let a=n%o;return s instanceof ye||r instanceof ye?new ye(a):new H(a)}case"<":return new U(n<o);case">":return new U(n>o);case">=":return new U(n>=o);case"<=":return new U(n<=o)}}else if(s instanceof te&&r instanceof te){if(t.operator.value==="+")return new te(s.value.concat(r.value))}else if(r instanceof te){let n=r.value.find(o=>o.value===s.value)!==void 0;switch(t.operator.value){case"in":return new U(n);case"not in":return new U(!n)}}}if((s instanceof $||r instanceof $)&&t.operator.value==="+")return new $(s.value.toString()+r.value.toString());if(s instanceof $&&r instanceof $)switch(t.operator.value){case"in":return new U(r.value.includes(s.value));case"not in":return new U(!r.value.includes(s.value))}if(s instanceof $&&r instanceof Le)switch(t.operator.value){case"in":return new U(r.value.has(s.value));case"not in":return new U(!r.value.has(s.value))}throw new SyntaxError(`Unknown operator "${t.operator.value}" between ${s.type} and ${r.type}`)}evaluateArguments(t,e){let s=[],r=new Map;for(let n of t)if(n.type==="SpreadExpression"){let o=n,a=this.evaluate(o.argument,e);if(!(a instanceof te))throw new Error(`Cannot unpack non-iterable type: ${a.type}`);for(let i of a.value)s.push(i)}else if(n.type==="KeywordArgumentExpression"){let o=n;r.set(o.key.value,this.evaluate(o.value,e))}else{if(r.size>0)throw new Error("Positional arguments must come before keyword arguments");s.push(this.evaluate(n,e))}return[s,r]}applyFilter(t,e,s){if(e.type==="Identifier"){let r=e;if(r.value==="tojson")return new $(Ht(t,{}));if(t instanceof te)switch(r.value){case"list":return t;case"first":return t.value[0];case"last":return t.value[t.value.length-1];case"length":return new H(t.value.length);case"reverse":return new te(t.value.slice().reverse());case"sort":return new te(t.value.slice().sort((n,o)=>Fl(n,o,!1)));case"join":return new $(t.value.map(n=>n.value).join(""));case"string":return new $(Ht(t,{},0,!1));case"unique":{let n=new Set,o=[];for(let a of t.value)n.has(a.value)||(n.add(a.value),o.push(a));return new te(o)}default:throw new Error(`Unknown ArrayValue filter: ${r.value}`)}else if(t instanceof $)switch(r.value){case"length":case"upper":case"lower":case"title":case"capitalize":{let n=t.builtins.get(r.value);if(n instanceof me)return n.value([],s);if(n instanceof H)return n;throw new Error(`Unknown StringValue filter: ${r.value}`)}case"trim":return new $(t.value.trim());case"indent":return new $(t.value.split(`
1
+ var gk=Object.defineProperty;var Es=(t,e)=>{for(var s in e)gk(t,s,{get:e[s],enumerable:!0})};var Le={};var Xe={};var by={};var xk="4.0.0-next.10",Mc=typeof self<"u",As=!Sy(Le),Ey=!Sy(Xe),qi=Mc&&"caches"in self,wk=typeof globalThis.Deno<"u",xM=typeof globalThis.Bun<"u",Gi=wk&&qi&&!As,Ay=typeof process<"u",My=Ay&&process?.release?.name==="node"&&!Gi,Sc=typeof window<"u"&&typeof window.document<"u",Oc=Mc&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),yk=Sc||Oc||Gi,bk=My||typeof navigator<"u"&&"gpu"in navigator,kk=typeof navigator<"u"&&"ml"in navigator,vk=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",Ek=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",Ak=typeof ServiceWorkerGlobalScope<"u"&&Mc&&self instanceof ServiceWorkerGlobalScope,Mk=()=>{if(typeof navigator>"u")return!1;let t=navigator.userAgent,s=(navigator.vendor||"").indexOf("Apple")>-1,r=!t.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!t.includes("Chrome")&&!t.includes("Android");return s&&r},Sk=Mk(),V=Object.freeze({IS_BROWSER_ENV:Sc,IS_WEBWORKER_ENV:Oc,IS_WEB_ENV:yk,IS_SERVICE_WORKER_ENV:Ak,IS_DENO_WEB_RUNTIME:Gi,IS_WEB_CACHE_AVAILABLE:qi,IS_WEBGPU_AVAILABLE:bk,IS_WEBNN_AVAILABLE:kk,IS_SAFARI:Sk,IS_PROCESS_AVAILABLE:Ay,IS_NODE_ENV:My,IS_FS_AVAILABLE:As,IS_PATH_AVAILABLE:Ey,IS_CRYPTO_AVAILABLE:vk,IS_CHROME_AVAILABLE:Ek}),zc=As&&Ey,Ui="./";if(zc){let t=Object(import.meta).url;t?Ui=Xe.dirname(Xe.dirname(by.fileURLToPath(t))):typeof __dirname<"u"&&(Ui=Xe.dirname(__dirname))}var Ok=zc?Xe.join(Ui,"/.cache/"):null,ky="/models/",zk=zc?Xe.join(Ui,ky):ky,Ik=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,qe=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),vy=qe.WARNING,Y={version:xk,backends:{onnx:{}},get logLevel(){return vy},set logLevel(t){vy=t,Y.backends.onnx?.setLogLevel?.(t)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(Sc||Oc||Gi),localModelPath:zk,useFS:As,useBrowserCache:qi,useFSCache:As,cacheDir:Ok,useCustomCache:!1,customCache:null,useWasmCache:qi||As,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:Ik};function Sy(t){return Object.keys(t).length===0}function gt(t,e){t&&t(e)}function Oy(t){return Number.isInteger(t)||typeof t=="bigint"}function Ic(t){return t==null||t===-1}function Tc(t){let e=[],s=t;for(;Array.isArray(s);)e.push(s.length),s=s[0];return e}function $e(...t){return Array.prototype.concat.apply([],t)}function zy(...t){return t.reduce((e,s)=>e.flatMap(r=>s.map(n=>[r,n])))}function Ms(t,e){return Math.abs((t+e)%(2*e)-e)}function ke(t,e){return Object.assign({},...e.map(s=>{if(t[s]!==void 0)return{[s]:t[s]}}))}function Iy(t,e){let s=0;for(let r of t)r===e&&++s;return s}var $={error(...t){Y.logLevel<=qe.ERROR&&console.error(...t)},warn(...t){Y.logLevel<=qe.WARNING&&console.warn(...t)},info(...t){Y.logLevel<=qe.INFO&&console.log(...t)},debug(...t){Y.logLevel<=qe.DEBUG&&console.log(...t)},log(...t){this.info(...t)}};var Tk=class{constructor(t){this.trie=this._build_trie(t)}_build_trie(t){let e=Object.create(null);for(let s of t){let r=e;for(let n=0;n<s.length;++n){let o=s[n];r=r[o]??=Object.create(null)}r.end=s}return e}split(t){let e=[],s=t.length,r=0,n=0;for(;n<s;){let o=this.trie,i=null,a=n;for(;a<s&&(o=o[t[a]]);)o.end&&(i=o.end),++a;i?(n>r&&e.push(t.slice(r,n)),e.push(i),n+=i.length,r=n):++n}return r<s&&e.push(t.slice(r)),e}},Ty=Tk,Ck=class{constructor(t){this.content=t.content,this.id=t.id,this.single_word=t.single_word??!1,this.lstrip=t.lstrip??!1,this.rstrip=t.rstrip??!1,this.special=t.special??!1,this.normalized=t.normalized??!this.special}},Pk=Ck,Ry=(()=>{let t=[...Array.from({length:94},(n,o)=>o+33),...Array.from({length:12},(n,o)=>o+161),...Array.from({length:82},(n,o)=>o+174)],e=t.slice(),s=0;for(let n=0;n<256;++n)t.includes(n)||(t.push(n),e.push(256+s),s+=1);let r=e.map(n=>String.fromCharCode(n));return Object.fromEntries(t.map((n,o)=>[n,r[o]]))})(),Nk=t=>Object.fromEntries(Object.entries(t).map(([e,s])=>[s,e])),Lk=Nk(Ry),Cy=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",$k=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"],["(?i:[sdmt]|ll|ve|re)","(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])"],["[^\\r\\n\\p{L}\\p{N}]?+","[^\\r\\n\\p{L}\\p{N}]?"],["[^\\s\\p{L}\\p{N}]++","[^\\s\\p{L}\\p{N}]+"],["(?>\\p{Nd}{510})","(?:\\p{Nd}{510})"],["\\p{Nd}{3}+","(?:\\p{Nd}{3})+"],["\\G",""],[` ?[^(\\s|[${Cy}])]+`,` ?[^\\s${Cy}]+`]]),Wi="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",Pc=t=>t.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n't/g,"n't").replace(/ 'm/g,"'m").replace(/ 's/g,"'s").replace(/ 've/g,"'ve").replace(/ 're/g,"'re"),Vi=(t,e=!0)=>{if(t.Regex!==void 0){let s=t.Regex.replace(/\\([#&~])/g,"$1");s=s.replace(/\\A/g,"^").replace(/\\z/g,"$").replace(/\\Z/g,"(?=\\r?\\n?$)");for(let[r,n]of $k)s=s.replaceAll(r,n);try{return new RegExp(s,"gu")}catch(r){if(!(r instanceof SyntaxError)||!r.message.toLowerCase().includes("invalid property name"))throw r;let n=!1,o=s.replace(/(\\[pP])\{([^}=]+)\}/g,(i,a,l)=>{try{return new RegExp(`\\p{${l}}`,"u"),`${a}{${l}}`}catch{return n=!0,`${a}{Script=${l}}`}});if(!n)throw r;try{return new RegExp(o,"gu")}catch{throw r}}}else if(t.String!==void 0){let s=Fk(t.String);return new RegExp(e?s:`(${s})`,"gu")}else return console.warn("Unknown pattern type:",t),null},Fk=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Rk=(t,e,s)=>{let r=[],n=0;for(;n<t.length;){if(r.push(t[n]),(e.get(t[n])??s)!==s){++n;continue}for(;++n<t.length&&(e.get(t[n])??s)===s;)e.get(r.at(-1))!==s&&(r[r.length-1]+=t[n])}return r},Dk=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,jk=t=>Number.isInteger(t)||typeof t=="bigint",Bk=t=>{let e=0;for(let s of t)++e;return e},qk=t=>Dy(t.toLowerCase()),rt=(...t)=>Array.prototype.concat.apply([],t),Nc=t=>new Map(Object.entries(t)),Uk=(t,e)=>{let s=[],r=0;for(let n of t.matchAll(e)){let o=n[0];r<n.index&&s.push(t.slice(r,n.index)),o.length>0&&s.push(o),r=n.index+o.length}return r<t.length&&s.push(t.slice(r)),s},Dy=t=>t.replace(/\p{M}/gu,""),Py=(t,e,s=[])=>{if(!t||Array.isArray(t)||typeof t!="object")return`${e} must be a valid object`;for(let r of s)if(!(r in t))return`${e} must contain a "${r}" property`;return null},Gk=t=>t.match(/\S+/g)||[],Wk=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},kr=Wk,Vk=class extends kr{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},xt=Vk,Hk=class extends xt{tokenize_chinese_chars(t){let e=[];for(let s=0;s<t.length;++s){let r=t[s],n=r.charCodeAt(0);Dk(n)?(e.push(" "),e.push(r),e.push(" ")):e.push(r)}return e.join("")}strip_accents(t){return t.normalize("NFD").replace(/\p{Mn}/gu,"")}is_control(t){switch(t){case" ":case`
2
+ `:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(t)}}clean_text(t){let e=[];for(let s of t){let r=s.charCodeAt(0);r===0||r===65533||this.is_control(s)||(/^\s$/.test(s)?e.push(" "):e.push(s))}return e.join("")}normalize(t){return this.config.clean_text&&(t=this.clean_text(t)),this.config.handle_chinese_chars&&(t=this.tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.strip_accents(t))):this.config.strip_accents&&(t=this.strip_accents(t)),t}},Kk=Hk,Xk=class extends xt{constructor(t){super(t),this.charsmap=t.precompiled_charsmap??null}normalize(t){return t=t.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),t=t.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," "),t.includes("\uFF5E")?t=t.split("\uFF5E").map(s=>s.normalize("NFKC")).join("\uFF5E"):t=t.normalize("NFKC"),t}},Qk=Xk,Yk=class extends xt{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>jy(e))}normalize(t){return this.normalizers.reduce((e,s)=>s?s.normalize(e):e,t)}},Jk=Yk,Zk=class extends xt{normalize(t){let e=Vi(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},e1=Zk,t1=class extends xt{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Hi=t1,s1=class extends Hi{constructor(){super(...arguments),this.form="NFC"}},r1=s1,n1=class extends Hi{constructor(){super(...arguments),this.form="NFD"}},o1=n1,i1=class extends Hi{constructor(){super(...arguments),this.form="NFKC"}},a1=i1,l1=class extends Hi{constructor(){super(...arguments),this.form="NFKD"}},c1=l1,p1=class extends xt{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}},u1=p1,_1=class extends xt{normalize(t){return Dy(t)}},d1=_1,f1=class extends xt{normalize(t){return t.toLowerCase()}},m1=f1,h1=class extends xt{normalize(t){return t=this.config.prepend+t,t}},g1=h1;function x1(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new Kk(t);case"Precompiled":return new Qk(t);case"Sequence":return new Jk(t);case"Replace":return new e1(t);case"NFC":return new r1(t);case"NFD":return new o1(t);case"NFKC":return new a1(t);case"NFKD":return new c1(t);case"Strip":return new u1(t);case"StripAccents":return new d1(t);case"Lowercase":return new m1(t);case"Prepend":return new g1(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var jy=x1,w1=class extends kr{pre_tokenize(t,e){return(Array.isArray(t)?t.map(s=>this.pre_tokenize_text(s,e)):this.pre_tokenize_text(t,e)).flat()}_call(t,e){return this.pre_tokenize(t,e)}},nt=w1,y1=class extends nt{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=Ry,this.text_encoder=new TextEncoder}pre_tokenize_text(t,e){return this.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(r=>Array.from(this.text_encoder.encode(r),n=>this.byte_encoder[n]).join(""))}},b1=y1,k1=class extends nt{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},v1=k1,E1=class extends nt{constructor(t){super(),this.replacement=t.replacement??"\u2581",this.str_rep=t.str_rep||this.replacement,this.prepend_scheme=t.prepend_scheme??"always"}pre_tokenize_text(t,e){let{section_index:s=void 0}=e??{},r=t.replaceAll(" ",this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&s===0)&&(r=this.str_rep+r),[r]}},A1=E1,M1=class extends nt{constructor(t){super(),this.config=t,this.pattern=Vi(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:this.config.behavior?.toLowerCase()==="removed"?t.split(this.pattern).filter(e=>e):Uk(t,this.pattern)}},S1=M1,O1=class extends nt{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${Wi}]+|[${Wi}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},z1=O1,I1=class extends nt{constructor(t){super(),this.config=t;let e=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(e,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},T1=I1,C1=class extends nt{constructor(){super(),this.pattern=new RegExp(`[^\\s${Wi}]+|[${Wi}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},P1=C1,N1=class extends nt{constructor(t){super(),this.config=t,this.pattern=Vi(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},L1=N1,$1=class extends nt{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>By(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((s,r)=>r?r.pre_tokenize(s,e):s,[t])}},F1=$1,R1=class extends nt{pre_tokenize_text(t){return Gk(t)}},D1=R1,j1=class extends nt{constructor(t){super(),this.config=t,this._length=t.length}pre_tokenize_text(t){let e=[];for(let s=0;s<t.length;s+=this._length)e.push(t.slice(s,s+this._length));return e}},B1=j1;function q1(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new P1;case"Sequence":return new F1(t);case"Whitespace":return new v1;case"WhitespaceSplit":return new D1;case"Metaspace":return new A1(t);case"ByteLevel":return new b1(t);case"Split":return new S1(t);case"Punctuation":return new z1(t);case"Digits":return new T1(t);case"Replace":return new L1(t);case"FixedLength":return new B1(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var By=q1,U1=class extends kr{constructor(t){super(),this.config=t,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}_call(t){let e=this.encode(t);return this.fuse_unk&&(e=Rk(e,this.tokens_to_ids,this.unk_token_id)),e}},Ki=U1,G1=class extends Ki{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=Nc(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(let[e,s]of this.tokens_to_ids)this.vocab[s]=e}encode(t){let e=[];for(let s of t){let r=[...s];if(r.length>this.max_input_chars_per_word){e.push(this.unk_token);continue}let n=!1,o=0,i=[];for(;o<r.length;){let a=r.length,l=null;for(;o<a;){let c=r.slice(o,a).join("");if(o>0&&(c=this.config.continuing_subword_prefix+c),this.tokens_to_ids.has(c)){l=c;break}--a}if(l===null){n=!0;break}i.push(l),o=a}n?e.push(this.unk_token):e.push(...i)}return e}},Ny=G1,Ly=class qy{constructor(e,s){this.is_leaf=e,this.children=s}static default(){return new qy(!1,new Map)}},W1=class{constructor(){this.root=Ly.default()}extend(t){for(let e of t)this.push(e)}push(t){let e=this.root;for(let s of t){let r=e.children.get(s);r===void 0&&(r=Ly.default(),e.children.set(s,r)),e=r}e.is_leaf=!0}*common_prefix_search(t){let e=this.root;if(e===void 0)return;let s="";for(let r of t){if(s+=r,e=e.children.get(r),e===void 0)return;e.is_leaf&&(yield s)}}},V1=W1,Cc=class Uy{constructor(e,s,r,n,o){this.token_id=e,this.node_id=s,this.pos=r,this.length=n,this.score=o,this.prev=null,this.backtrace_score=0}clone(){let e=new Uy(this.token_id,this.node_id,this.pos,this.length,this.score);return e.prev=this.prev,e.backtrace_score=this.backtrace_score,e}},H1=class{constructor(t,e,s){this.chars=Array.from(t),this.len=this.chars.length,this.bos_token_id=e,this.eos_token_id=s,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new Cc(this.bos_token_id??0,0,0,0,0),n=new Cc(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(n.clone()),this.begin_nodes[this.len].push(n),this.end_nodes[0].push(r)}insert(t,e,s,r){let n=this.nodes.length,o=new Cc(r,n,t,e,s);this.begin_nodes[t].push(o),this.end_nodes[t+e].push(o),this.nodes.push(o)}viterbi(){let t=this.len,e=0;for(;e<=t;){if(this.begin_nodes[e].length==0)return[];for(let i of this.begin_nodes[e]){i.prev=null;let a=0,l=null;for(let c of this.end_nodes[e]){let p=c.backtrace_score+i.score;(l===null||p>a)&&(l=c.clone(),a=p)}if(l!==null)i.prev=l,i.backtrace_score=a;else return[]}++e}let s=[],n=this.begin_nodes[t][0].prev;if(n===null)return[];let o=n.clone();for(;o.prev!==null;)s.push(o.clone()),o=o.clone().prev.clone();return s.reverse(),s}piece(t){return this.chars.slice(t.pos,t.pos+t.length).join("")}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}},K1=H1;function X1(t){if(t.length===0)throw new Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]<e&&(e=t[r],s=r);return[e,s]}var Q1=class extends Ki{constructor(t,e){super(t);let s=t.vocab.length;this.vocab=new Array(s),this.scores=new Array(s);for(let r=0;r<s;++r)[this.vocab[r],this.scores[r]]=t.vocab[r];this.unk_token_id=t.unk_id,this.unk_token=this.vocab[t.unk_id],this.tokens_to_ids=new Map(this.vocab.map((r,n)=>[r,n])),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=X1(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new V1,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(t){let e=t.chars,s=1,r=0;for(;r<e.length;){let n=!1,o=[],i=e.slice(r).join(""),a=this.trie.common_prefix_search(i);for(let l of a){o.push(l);let c=this.tokens_to_ids.get(l),p=this.scores[c],u=Bk(l);t.insert(r,u,p,c),!n&&u===s&&(n=!0)}n||t.insert(r,s,this.unk_score,this.unk_token_id),r+=s}}tokenize(t){let e=new K1(t,this.bos_token_id,this.eos_token_id);return this.populate_nodes(e),e.tokens()}encode(t){let e=[];for(let s of t){let r=this.tokenize(s);e.push(...r)}return e}},$y=Q1,Y1=class{constructor(t=(s,r)=>s>r,e=1/0){this._heap=[],this._comparator=t,this._max_size=e}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(let e of t)if(this.size<this._max_size)this._heap.push(e),this._sift_up();else{let s=this._smallest();this._comparator(e,this._heap[s])&&(this._heap[s]=e,this._sift_up_from(s))}return this.size}pop(){let t=this.peek(),e=this.size-1;return e>0&&this._swap(0,e),this._heap.pop(),this._sift_down(),t}replace(t){let e=this.peek();return this._heap[0]=t,this._sift_down(),e}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,e){return this._comparator(this._heap[t],this._heap[e])}_swap(t,e){let s=this._heap[t];this._heap[t]=this._heap[e],this._heap[e]=s}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(t){for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_sift_down(){let t=0;for(;this._left(t)<this.size&&this._greater(this._left(t),t)||this._right(t)<this.size&&this._greater(this._right(t),t);){let e=this._right(t)<this.size&&this._greater(this._right(t),this._left(t))?this._right(t):this._left(t);this._swap(t,e),t=e}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},J1=Y1,Z1=class{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;let e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},ev=Z1,tv=class extends Ki{constructor(t){super(t),this.tokens_to_ids=Nc(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(let[s,r]of this.tokens_to_ids)this.vocab[r]=s;let e=Array.isArray(t.merges[0]);this.merges=e?t.merges:t.merges.map(s=>s.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((s,r)=>[JSON.stringify(s),r])),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new ev(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(t){if(t.length===0)return[];let e=this.cache.get(t);if(e!==void 0)return e;let s=Array.from(t);this.end_of_word_suffix&&(s[s.length-1]+=this.end_of_word_suffix);let r=[];if(s.length>1){let n=new J1((a,l)=>a.score<l.score),o={token:s[0],bias:0,prev:null,next:null},i=o;for(let a=1;a<s.length;++a){let l={bias:a/s.length,token:s[a],prev:i,next:null};i.next=l,this.add_node(n,i),i=l}for(;!n.is_empty();){let a=n.pop();if(a.deleted||!a.next||a.next.deleted)continue;if(a.deleted=!0,a.next.deleted=!0,a.prev){let c={...a.prev};a.prev.deleted=!0,a.prev=c,c.prev?c.prev.next=c:o=c}let l={token:a.token+a.next.token,bias:a.bias,prev:a.prev,next:a.next.next};l.prev?(l.prev.next=l,this.add_node(n,l.prev)):o=l,l.next&&(l.next.prev=l,this.add_node(n,l))}for(let a=o;a!==null;a=a.next)r.push(a.token)}else r=s;if(this.continuing_subword_suffix)for(let n=0;n<r.length-1;++n)r[n]+=this.continuing_subword_suffix;return t.length<this.max_length_to_cache&&this.cache.put(t,r),r}add_node(t,e){let s=this.bpe_ranks.get(JSON.stringify([e.token,e.next.token]));s!==void 0&&(e.score=s+e.bias,t.push(e))}encode(t){let e=[];for(let s of t){if(this.ignore_merges&&this.tokens_to_ids.has(s)){e.push(s);continue}let r=this.bpe(s);for(let n of r)if(this.tokens_to_ids.has(n))e.push(n);else if(this.byte_fallback){let o=Array.from(this.text_encoder.encode(n)).map(i=>`<0x${i.toString(16).toUpperCase().padStart(2,"0")}>`);o.every(i=>this.tokens_to_ids.has(i))?e.push(...o):this.unk_token!=null&&e.push(this.unk_token)}else this.unk_token!=null&&e.push(this.unk_token)}return e}},Fy=tv,sv=class extends Ki{constructor(t,e){super(t);let s=t.vocab;this.tokens_to_ids=Nc(e.target_lang?s[e.target_lang]:s),this.bos_token=e.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=e.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=e.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(let[r,n]of this.tokens_to_ids)this.vocab[n]=r}encode(t){return t}},rv=sv;function nv(t,e){switch(t.type){case"WordPiece":return new Ny(t);case"Unigram":return new $y(t,e.eos_token);case"BPE":return new Fy(t);default:if(t.vocab)return Array.isArray(t.vocab)?new $y(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new Fy(t):new Ny(t):new rv(t,{target_lang:e.target_lang,bos_token:e.bos_token,eos_token:e.eos_token,pad_token:e.pad_token,unk_token:e.unk_token});throw new Error(`Unknown TokenizerModel type: ${t?.type}`)}}var ov=nv,iv=class extends kr{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},vr=iv,av=class extends vr{post_process(t,e=null,s=!0){let r=e===null?this.config.single:this.config.pair,n=[],o=[];for(let i of r)"SpecialToken"in i?s&&(n.push(i.SpecialToken.id),o.push(i.SpecialToken.type_id)):"Sequence"in i&&(i.Sequence.id==="A"?(n=rt(n,t),o=rt(o,new Array(t.length).fill(i.Sequence.type_id))):i.Sequence.id==="B"&&(n=rt(n,e),o=rt(o,new Array(e.length).fill(i.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},lv=av,cv=class extends vr{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},pv=cv,uv=class extends vr{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,s=!0){s&&(t=rt([this.cls[0]],t,[this.sep[0]]));let r=new Array(t.length).fill(0);if(e){let n=[],o=s?[this.sep[0]]:[];t=rt(t,n,e,o),r=rt(r,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:r}}},_v=uv,dv=class extends vr{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,s=!0){s&&(t=rt([this.cls[0]],t,[this.sep[0]]));let r=new Array(t.length).fill(0);if(e){let n=s?[this.sep[0]]:[],o=s?[this.sep[0]]:[];t=rt(t,n,e,o),r=rt(r,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:r}}},fv=dv,mv=class extends vr{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>Gy(e))}post_process(t,e=null,s=!0){let r={tokens:t,tokens_pair:e};for(let n of this.processors)r=n.post_process(r.tokens,r.tokens_pair,s);return r}},hv=mv;function gv(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new lv(t);case"ByteLevel":return new pv(t);case"BertProcessing":return new _v(t);case"RobertaProcessing":return new fv(t);case"Sequence":return new hv(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var Gy=gv,xv=class extends kr{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets="trim_offsets"in t?t.trim_offsets:!1}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}},Qe=xv,wv=class extends Qe{constructor(t){super(t),this.byte_decoder=Lk,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let e=t.join(""),s=new Uint8Array([...e].map(r=>this.byte_decoder[r]));return this.text_decoder.decode(s)}decode_chain(t){let e=[],s=[];for(let r of t)this.added_tokens.find(n=>n.content===r)!==void 0?(s.length>0&&(e.push(this.convert_tokens_to_string(s)),s=[]),e.push(r)):s.push(r);return s.length>0&&e.push(this.convert_tokens_to_string(s)),e}},yv=wv,bv=class extends Qe{constructor(t){super(t),this.cleanup=t.cleanup}decode_chain(t){return t.map((e,s)=>{if(s!==0){let r=this.config.prefix;r&&e.startsWith(r)?e=e.replace(r,""):e=" "+e}return this.cleanup&&(e=Pc(e)),e})}},kv=bv,vv=class extends Qe{constructor(t){super(t),this.replacement=t.replacement??"\u2581"}decode_chain(t){let e=[];for(let s=0;s<t.length;++s){let r=t[s].replaceAll(this.replacement," ");s==0&&r.startsWith(" ")&&(r=r.substring(1)),e.push(r)}return e}},Ev=vv,Av=class extends Qe{constructor(t){super(t),this.suffix=t.suffix??""}decode_chain(t){return t.map((e,s)=>e.replaceAll(this.suffix,s===t.length-1?"":" "))}},Mv=Av,Sv=class extends Qe{constructor(t){super(t),this.pad_token=t.pad_token??"",this.word_delimiter_token=t.word_delimiter_token??"",this.cleanup=t.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let e=[t[0]];for(let n=1;n<t.length;++n)t[n]!==e.at(-1)&&e.push(t[n]);let r=e.filter(n=>n!==this.pad_token).join("");return this.cleanup&&(r=Pc(r).replaceAll(this.word_delimiter_token," ").trim()),r}decode_chain(t){return[this.convert_tokens_to_string(t)]}},Ov=Sv,zv=class extends Qe{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>Wy(e))}decode_chain(t){return this.decoders.reduce((e,s)=>s.decode_chain(e),t)}},Iv=zv,Tv=class extends Qe{decode_chain(t){let e=Vi(this.config.pattern),s=this.config.content??"";return e===null?t:t.map(r=>r.replaceAll(e,s))}},Cv=Tv,Pv=class extends Qe{decode_chain(t){return[t.join("")]}},Nv=Pv,Lv=class extends Qe{constructor(t){super(t),this.content=t.content??"",this.start=t.start??0,this.stop=t.stop??0}decode_chain(t){return t.map(e=>{let s=0;for(let n=0;n<this.start&&e[n]===this.content;++n){s=n+1;continue}let r=e.length;for(let n=0;n<this.stop;++n){let o=e.length-n-1;if(e[o]===this.content){r=o;continue}else break}return e.slice(s,r)})}},$v=Lv,Fv=class extends Qe{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let e=[],s=[];for(let r of t){let n=null;if(r.length===6&&r.startsWith("<0x")&&r.endsWith(">")){let o=parseInt(r.slice(3,5),16);isNaN(o)||(n=o)}if(n!==null)s.push(n);else{if(s.length>0){let o=this.text_decoder.decode(Uint8Array.from(s));e.push(o),s=[]}e.push(r)}}if(s.length>0){let r=this.text_decoder.decode(Uint8Array.from(s));e.push(r),s=[]}return e}},Rv=Fv;function Dv(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new yv(t);case"WordPiece":return new kv(t);case"Metaspace":return new Ev(t);case"BPEDecoder":return new Mv(t);case"CTC":return new Ov(t);case"Sequence":return new Iv(t);case"Replace":return new Cv(t);case"Fuse":return new Nv(t);case"Strip":return new $v(t);case"ByteFallback":return new Rv(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var Wy=Dv,jv=class{constructor(t,e){let s=Py(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(s)throw new Error(s);let r=Py(e,"Config");if(r)throw new Error(r);this.tokenizer=t,this.config=e,this.normalizer=jy(this.tokenizer.normalizer),this.pre_tokenizer=By(this.tokenizer.pre_tokenizer),this.model=ov(this.tokenizer.model,this.config),this.post_processor=Gy(this.tokenizer.post_processor),this.decoder=Wy(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let n=[],o=[];this.added_tokens_map=new Map;for(let i of this.tokenizer.added_tokens){let a=new Pk(i);if(this.added_tokens.push(a),this.model.tokens_to_ids.set(a.content,a.id),this.model.vocab[a.id]=a.content,a.special&&(this.special_tokens.push(a.content),this.all_special_ids.push(a.id)),this.added_tokens_map.set(a.content,a),a.normalized&&this.normalizer!==null){let l=this.normalizer(a.content);o.push(l),this.added_tokens_map.set(l,a)}else n.push(a.content)}(this.config.additional_special_tokens??[]).forEach(i=>{this.special_tokens.includes(i)||this.special_tokens.push(i)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new Ty(n),this.splitter_normalized=new Ty(o),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(t,{text_pair:e=null,add_special_tokens:s=!0,return_token_type_ids:r=null}={}){let{tokens:n,token_type_ids:o}=this.tokenize_helper(t,{text_pair:e,add_special_tokens:s}),i=n.map(l=>this.added_tokens_map.get(l)?.id??this.model.tokens_to_ids.get(l)??this.model.unk_token_id),a={ids:i,tokens:n,attention_mask:new Array(i.length).fill(1)};return r&&o&&(a.token_type_ids=o),a}decode(t,e={}){if(!Array.isArray(t)||t.length===0||!jk(t[0]))throw Error("token_ids must be a non-empty array of integers.");let s=t.map(n=>this.model.vocab[Number(n)]??this.model.unk_token);e.skip_special_tokens&&(s=s.filter(n=>!this.special_tokens.includes(n)));let r=this.decoder?this.decoder(s):s.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix," "),e.skip_special_tokens&&(r=r.trim())),(e.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=Pc(r)),r}tokenize(t,{text_pair:e=null,add_special_tokens:s=!1}={}){return this.tokenize_helper(t,{text_pair:e,add_special_tokens:s}).tokens}encode_text(t){if(t===null)return null;let e=this.splitter_unnormalized.split(t);return e.forEach((s,r)=>{let n=this.added_tokens_map.get(s);n&&(n.lstrip&&r>0&&(e[r-1]=e[r-1].trimEnd()),n.rstrip&&r<e.length-1&&(e[r+1]=e[r+1].trimStart()))}),e.flatMap((s,r)=>{if(s.length===0)return[];if(this.added_tokens_map.has(s))return[s];if(this.remove_space===!0&&(s=s.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(s=qk(s)),this.normalizer!==null&&(s=this.normalizer(s)),s.length===0)return[];let n=this.splitter_normalized.split(s);return n.forEach((o,i)=>{let a=this.added_tokens_map.get(o);a&&(a.lstrip&&i>0&&(n[i-1]=n[i-1].trimEnd()),a.rstrip&&i<n.length-1&&(n[i+1]=n[i+1].trimStart()))}),n.flatMap(o=>{if(o.length===0)return[];if(this.added_tokens_map.has(o))return[o];let i=this.pre_tokenizer!==null?this.pre_tokenizer(o,{section_index:r}):[o];return this.model(i)})})}tokenize_helper(t,{text_pair:e=null,add_special_tokens:s=!0}){let r=this.encode_text(t),n=this.encode_text(e||null);return this.post_processor?this.post_processor(r,n,s):{tokens:rt(r??[],n??[])}}token_to_id(t){return this.model.tokens_to_ids.get(t)}id_to_token(t){return this.model.vocab[t]}get_added_tokens_decoder(){let t=new Map;for(let e of this.added_tokens)t.set(e.id,e);return t}get_vocab(t=!0){let e=new Map;for(let s=0;s<this.model.vocab.length;++s){let r=this.model.vocab[s];(t||!this.added_tokens_map.has(r))&&e.set(r,s)}return e}},Vy=jv;var A=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),Ye=class{constructor(t,e){this.value=t,this.type=e}};function Hy(t){return/\w/.test(t)}function Er(t){return/[0-9]/.test(t)}function Ky(t){return/\s/.test(t)}var Bv=[["{%",A.OpenStatement],["%}",A.CloseStatement],["{{",A.OpenExpression],["}}",A.CloseExpression],["(",A.OpenParen],[")",A.CloseParen],["{",A.OpenCurlyBracket],["}",A.CloseCurlyBracket],["[",A.OpenSquareBracket],["]",A.CloseSquareBracket],[",",A.Comma],[".",A.Dot],[":",A.Colon],["|",A.Pipe],["<=",A.ComparisonBinaryOperator],[">=",A.ComparisonBinaryOperator],["==",A.ComparisonBinaryOperator],["!=",A.ComparisonBinaryOperator],["<",A.ComparisonBinaryOperator],[">",A.ComparisonBinaryOperator],["+",A.AdditiveBinaryOperator],["-",A.AdditiveBinaryOperator],["~",A.AdditiveBinaryOperator],["*",A.MultiplicativeBinaryOperator],["/",A.MultiplicativeBinaryOperator],["%",A.MultiplicativeBinaryOperator],["=",A.Equals]],qv=new Map([["n",`
3
+ `],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function Uv(t,e={}){return t.endsWith(`
4
+ `)&&(t=t.slice(0,-1)),e.lstrip_blocks&&(t=t.replace(/^[ \t]*({[#%-])/gm,"$1")),e.trim_blocks&&(t=t.replace(/([#%-]})\n/g,"$1")),t.replace(/{%\s*(end)?generation\s*%}/gs,"")}function Gv(t,e={}){let s=[],r=Uv(t,e),n=0,o=0,i=c=>{let p="";for(;c(r[n]);){if(r[n]==="\\"){if(++n,n>=r.length)throw new SyntaxError("Unexpected end of input");let u=r[n++],_=qv.get(u);if(_===void 0)throw new SyntaxError(`Unexpected escaped character: ${u}`);p+=_;continue}if(p+=r[n++],n>=r.length)throw new SyntaxError("Unexpected end of input")}return p},a=()=>{let c=s.at(-1);c&&c.type===A.Text&&(c.value=c.value.trimEnd(),c.value===""&&s.pop())},l=()=>{for(;n<r.length&&Ky(r[n]);)++n};e:for(;n<r.length;){let c=s.at(-1)?.type;if(c===void 0||c===A.CloseStatement||c===A.CloseExpression||c===A.Comment){let u="";for(;n<r.length&&!(r[n]==="{"&&(r[n+1]==="%"||r[n+1]==="{"||r[n+1]==="#"));)u+=r[n++];if(u.length>0){s.push(new Ye(u,A.Text));continue}}if(r[n]==="{"&&r[n+1]==="#"){n+=2;let u=r[n]==="-";u&&++n;let _="";for(;r[n]!=="#"||r[n+1]!=="}";){if(n+2>=r.length)throw new SyntaxError("Missing end of comment tag");_+=r[n++]}let d=_.endsWith("-");d&&(_=_.slice(0,-1)),u&&a(),s.push(new Ye(_,A.Comment)),n+=2,d&&l();continue}if(r.slice(n,n+3)==="{%-"){a(),s.push(new Ye("{%",A.OpenStatement)),n+=3;continue}if(r.slice(n,n+3)==="{{-"){a(),s.push(new Ye("{{",A.OpenExpression)),o=0,n+=3;continue}if(i(Ky),r.slice(n,n+3)==="-%}"){s.push(new Ye("%}",A.CloseStatement)),n+=3,l();continue}if(r.slice(n,n+3)==="-}}"){s.push(new Ye("}}",A.CloseExpression)),n+=3,l();continue}let p=r[n];if(p==="-"||p==="+"){let u=s.at(-1)?.type;if(u===A.Text||u===void 0)throw new SyntaxError(`Unexpected character: ${p}`);switch(u){case A.Identifier:case A.NumericLiteral:case A.StringLiteral:case A.CloseParen:case A.CloseSquareBracket:break;default:{++n;let _=i(Er);s.push(new Ye(`${p}${_}`,_.length>0?A.NumericLiteral:A.UnaryOperator));continue}}}for(let[u,_]of Bv){if(u==="}}"&&o>0)continue;if(r.slice(n,n+u.length)===u){s.push(new Ye(u,_)),_===A.OpenExpression?o=0:_===A.OpenCurlyBracket?++o:_===A.CloseCurlyBracket&&--o,n+=u.length;continue e}}if(p==="'"||p==='"'){++n;let u=i(_=>_!==p);s.push(new Ye(u,A.StringLiteral)),++n;continue}if(Er(p)){let u=i(Er);if(r[n]==="."&&Er(r[n+1])){++n;let _=i(Er);u=`${u}.${_}`}s.push(new Ye(u,A.NumericLiteral));continue}if(Hy(p)){let u=i(Hy);s.push(new Ye(u,A.Identifier));continue}throw new SyntaxError(`Unexpected character: ${p}`)}return s}var it=class{type="Statement"},Wv=class extends it{constructor(t){super(),this.body=t}type="Program"},Vv=class extends it{constructor(t,e,s){super(),this.test=t,this.body=e,this.alternate=s}type="If"},Hv=class extends it{constructor(t,e,s,r){super(),this.loopvar=t,this.iterable=e,this.body=s,this.defaultBlock=r}type="For"},Kv=class extends it{type="Break"},Xv=class extends it{type="Continue"},Qv=class extends it{constructor(t,e,s){super(),this.assignee=t,this.value=e,this.body=s}type="Set"},Yv=class extends it{constructor(t,e,s){super(),this.name=t,this.args=e,this.body=s}type="Macro"},Jv=class extends it{constructor(t){super(),this.value=t}type="Comment"},Ve=class extends it{type="Expression"},Zv=class extends Ve{constructor(t,e,s){super(),this.object=t,this.property=e,this.computed=s}type="MemberExpression"},Xy=class extends Ve{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},Ss=class extends Ve{constructor(t){super(),this.value=t}type="Identifier"},Os=class extends Ve{constructor(t){super(),this.value=t}type="Literal"},eE=class extends Os{type="IntegerLiteral"},tE=class extends Os{type="FloatLiteral"},Qy=class extends Os{type="StringLiteral"},sE=class extends Os{type="ArrayLiteral"},Yy=class extends Os{type="TupleLiteral"},rE=class extends Os{type="ObjectLiteral"},Ar=class extends Ve{constructor(t,e,s){super(),this.operator=t,this.left=e,this.right=s}type="BinaryExpression"},nE=class extends Ve{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},oE=class extends it{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},iE=class extends Ve{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},aE=class extends Ve{constructor(t,e,s){super(),this.operand=t,this.negate=e,this.test=s}type="TestExpression"},lE=class extends Ve{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},cE=class extends Ve{constructor(t=void 0,e=void 0,s=void 0){super(),this.start=t,this.stop=e,this.step=s}type="SliceExpression"},pE=class extends Ve{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},uE=class extends Ve{constructor(t){super(),this.argument=t}type="SpreadExpression"},_E=class extends it{constructor(t,e,s){super(),this.call=t,this.callerArgs=e,this.body=s}type="CallStatement"},dE=class extends Ve{constructor(t,e,s){super(),this.condition=t,this.trueExpr=e,this.falseExpr=s}type="Ternary"};function fE(t){let e=new Wv([]),s=0;function r(M,S){let T=t[s++];if(!T||T.type!==M)throw new Error(`Parser Error: ${S}. ${T.type} !== ${M}.`);return T}function n(M){if(!l(M))throw new SyntaxError(`Expected ${M}`);++s}function o(){switch(t[s].type){case A.Comment:return new Jv(t[s++].value);case A.Text:return c();case A.OpenStatement:return p();case A.OpenExpression:return u();default:throw new SyntaxError(`Unexpected token type: ${t[s].type}`)}}function i(...M){return s+M.length<=t.length&&M.every((S,T)=>S===t[s+T].type)}function a(...M){return t[s]?.type===A.OpenStatement&&t[s+1]?.type===A.Identifier&&M.includes(t[s+1]?.value)}function l(...M){return s+M.length<=t.length&&M.every((S,T)=>t[s+T].type==="Identifier"&&S===t[s+T].value)}function c(){return new Qy(r(A.Text,"Expected text token").value)}function p(){if(r(A.OpenStatement,"Expected opening statement token"),t[s].type!==A.Identifier)throw new SyntaxError(`Unknown statement, got ${t[s].type}`);let M=t[s].value,S;switch(M){case"set":++s,S=_();break;case"if":++s,S=d(),r(A.OpenStatement,"Expected {% token"),n("endif"),r(A.CloseStatement,"Expected %} token");break;case"macro":++s,S=m(),r(A.OpenStatement,"Expected {% token"),n("endmacro"),r(A.CloseStatement,"Expected %} token");break;case"for":++s,S=g(),r(A.OpenStatement,"Expected {% token"),n("endfor"),r(A.CloseStatement,"Expected %} token");break;case"call":{++s;let T=null;i(A.OpenParen)&&(T=P());let H=te();if(H.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let he=P();r(A.CloseStatement,"Expected closing statement token");let se=[];for(;!a("endcall");)se.push(o());r(A.OpenStatement,"Expected '{%'"),n("endcall"),r(A.CloseStatement,"Expected closing statement token");let Ke=new Xy(H,he);S=new _E(Ke,T,se);break}case"break":++s,r(A.CloseStatement,"Expected closing statement token"),S=new Kv;break;case"continue":++s,r(A.CloseStatement,"Expected closing statement token"),S=new Xv;break;case"filter":{++s;let T=te();T instanceof Ss&&i(A.OpenParen)&&(T=q(T)),r(A.CloseStatement,"Expected closing statement token");let H=[];for(;!a("endfilter");)H.push(o());r(A.OpenStatement,"Expected '{%'"),n("endfilter"),r(A.CloseStatement,"Expected '%}'"),S=new oE(T,H);break}default:throw new SyntaxError(`Unknown statement type: ${M}`)}return S}function u(){r(A.OpenExpression,"Expected opening expression token");let M=x();return r(A.CloseExpression,"Expected closing expression token"),M}function _(){let M=h(),S=null,T=[];if(i(A.Equals))++s,S=h();else{for(r(A.CloseStatement,"Expected %} token");!a("endset");)T.push(o());r(A.OpenStatement,"Expected {% token"),n("endset")}return r(A.CloseStatement,"Expected closing statement token"),new Qv(M,S,T)}function d(){let M=x();r(A.CloseStatement,"Expected closing statement token");let S=[],T=[];for(;!a("elif","else","endif");)S.push(o());if(a("elif")){++s,++s;let H=d();T.push(H)}else if(a("else"))for(++s,++s,r(A.CloseStatement,"Expected closing statement token");!a("endif");)T.push(o());return new Vv(M,S,T)}function m(){let M=te();if(M.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let S=P();r(A.CloseStatement,"Expected closing statement token");let T=[];for(;!a("endmacro");)T.push(o());return new Yv(M,S,T)}function h(M=!1){let S=M?te:x,T=[S()],H=i(A.Comma);for(;H&&(++s,T.push(S()),!!i(A.Comma)););return H?new Yy(T):T[0]}function g(){let M=h(!0);if(!(M instanceof Ss||M instanceof Yy))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${M.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++s;let S=x();r(A.CloseStatement,"Expected closing statement token");let T=[];for(;!a("endfor","else");)T.push(o());let H=[];if(a("else"))for(++s,++s,r(A.CloseStatement,"Expected closing statement token");!a("endfor");)H.push(o());return new Hv(M,S,T,H)}function x(){return w()}function w(){let M=y();if(l("if")){++s;let S=y();if(l("else")){++s;let T=w();return new dE(S,M,T)}else return new iE(M,S)}return M}function y(){let M=b();for(;l("or");){let S=t[s];++s;let T=b();M=new Ar(S,M,T)}return M}function b(){let M=v();for(;l("and");){let S=t[s];++s;let T=v();M=new Ar(S,M,T)}return M}function v(){let M;for(;l("not");){let S=t[s];++s;let T=v();M=new lE(S,T)}return M??k()}function k(){let M=O();for(;;){let S;if(l("not","in"))S=new Ye("not in",A.Identifier),s+=2;else if(l("in"))S=t[s++];else if(i(A.ComparisonBinaryOperator))S=t[s++];else break;let T=O();M=new Ar(S,M,T)}return M}function O(){let M=j();for(;i(A.AdditiveBinaryOperator);){let S=t[s];++s;let T=j();M=new Ar(S,M,T)}return M}function N(){let M=U(te());return i(A.OpenParen)?q(M):M}function q(M){let S=new Xy(M,P());return S=U(S),i(A.OpenParen)&&(S=q(S)),S}function P(){r(A.OpenParen,"Expected opening parenthesis for arguments list");let M=R();return r(A.CloseParen,"Expected closing parenthesis for arguments list"),M}function R(){let M=[];for(;!i(A.CloseParen);){let S;if(t[s].type===A.MultiplicativeBinaryOperator&&t[s].value==="*"){++s;let T=x();S=new uE(T)}else if(S=x(),i(A.Equals)){if(++s,!(S instanceof Ss))throw new SyntaxError("Expected identifier for keyword argument");let T=x();S=new pE(S,T)}M.push(S),i(A.Comma)&&++s}return M}function F(){let M=[],S=!1;for(;!i(A.CloseSquareBracket);)i(A.Colon)?(M.push(void 0),++s,S=!0):(M.push(x()),i(A.Colon)&&(++s,S=!0));if(M.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(S){if(M.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new cE(...M)}return M[0]}function U(M){for(;i(A.Dot)||i(A.OpenSquareBracket);){let S=t[s];++s;let T,H=S.type===A.OpenSquareBracket;if(H)T=F(),r(A.CloseSquareBracket,"Expected closing square bracket");else if(T=te(),T.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");M=new Zv(M,T,H)}return M}function j(){let M=W();for(;i(A.MultiplicativeBinaryOperator);){let S=t[s++],T=W();M=new Ar(S,M,T)}return M}function W(){let M=Z();for(;l("is");){++s;let S=l("not");S&&++s;let T=te();if(!(T instanceof Ss))throw new SyntaxError("Expected identifier for the test");M=new aE(M,S,T)}return M}function Z(){let M=N();for(;i(A.Pipe);){++s;let S=te();if(!(S instanceof Ss))throw new SyntaxError("Expected identifier for the filter");i(A.OpenParen)&&(S=q(S)),M=new nE(M,S)}return M}function te(){let M=t[s++];switch(M.type){case A.NumericLiteral:{let S=M.value;return S.includes(".")?new tE(Number(S)):new eE(Number(S))}case A.StringLiteral:{let S=M.value;for(;i(A.StringLiteral);)S+=t[s++].value;return new Qy(S)}case A.Identifier:return new Ss(M.value);case A.OpenParen:{let S=h();return r(A.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),S}case A.OpenSquareBracket:{let S=[];for(;!i(A.CloseSquareBracket);)S.push(x()),i(A.Comma)&&++s;return++s,new sE(S)}case A.OpenCurlyBracket:{let S=new Map;for(;!i(A.CloseCurlyBracket);){let T=x();r(A.Colon,"Expected colon between key and value in object literal");let H=x();S.set(T,H),i(A.Comma)&&++s}return++s,new rE(S)}default:throw new SyntaxError(`Unexpected token: ${M.type}`)}}for(;s<t.length;)e.body.push(o());return e}function mE(t,e,s=1){if(e===void 0&&(e=t,t=0),s===0)throw new Error("range() step must not be zero");let r=[];if(s>0)for(let n=t;n<e;n+=s)r.push(n);else for(let n=t;n>e;n+=s)r.push(n);return r}function Jy(t,e,s,r=1){let n=Math.sign(r);n>=0?(e=(e??=0)<0?Math.max(t.length+e,0):Math.min(e,t.length),s=(s??=t.length)<0?Math.max(t.length+s,0):Math.min(s,t.length)):(e=(e??=t.length-1)<0?Math.max(t.length+e,-1):Math.min(e,t.length-1),s=(s??=-1)<-1?Math.max(t.length+s,-1):Math.min(s,t.length-1));let o=[];for(let i=e;n*i<n*s;i+=r)o.push(t[i]);return o}function hE(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function gE(t){return xE(new Date,t)}function xE(t,e){let s=new Intl.DateTimeFormat(void 0,{month:"long"}),r=new Intl.DateTimeFormat(void 0,{month:"short"}),n=o=>o<10?"0"+o:o.toString();return e.replace(/%[YmdbBHM%]/g,o=>{switch(o){case"%Y":return t.getFullYear().toString();case"%m":return n(t.getMonth()+1);case"%d":return n(t.getDate());case"%b":return r.format(t);case"%B":return s.format(t);case"%H":return n(t.getHours());case"%M":return n(t.getMinutes());case"%%":return"%";default:return o}})}function wE(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yE(t,e,s,r){if(r===0)return t;let n=r==null||r<0?1/0:r,o=e.length===0?new RegExp("(?=)","gu"):new RegExp(wE(e),"gu");return t.replaceAll(o,i=>n>0?(--n,s):i)}var Zy=class extends Error{},e0=class extends Error{},ut=class{type="RuntimeValue";value;builtins=new Map;constructor(t=void 0){this.value=t}__bool__(){return new K(!!this.value)}toString(){return String(this.value)}},J=class extends ut{type="IntegerValue"},Ee=class extends ut{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},D=class extends ut{type="StringValue";builtins=new Map([["upper",new we(()=>new D(this.value.toUpperCase()))],["lower",new we(()=>new D(this.value.toLowerCase()))],["strip",new we(()=>new D(this.value.trim()))],["title",new we(()=>new D(hE(this.value)))],["capitalize",new we(()=>new D(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new J(this.value.length)],["rstrip",new we(()=>new D(this.value.trimEnd()))],["lstrip",new we(()=>new D(this.value.trimStart()))],["startswith",new we(t=>{if(t.length===0)throw new Error("startswith() requires at least one argument");let e=t[0];if(e instanceof D)return new K(this.value.startsWith(e.value));if(e instanceof ne){for(let s of e.value){if(!(s instanceof D))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(s.value))return new K(!0)}return new K(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new we(t=>{if(t.length===0)throw new Error("endswith() requires at least one argument");let e=t[0];if(e instanceof D)return new K(this.value.endsWith(e.value));if(e instanceof ne){for(let s of e.value){if(!(s instanceof D))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(s.value))return new K(!0)}return new K(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new we(t=>{let e=t[0]??new ye;if(!(e instanceof D||e instanceof ye))throw new Error("sep argument must be a string or null");let s=t[1]??new J(-1);if(!(s instanceof J))throw new Error("maxsplit argument must be a number");let r=[];if(e instanceof ye){let n=this.value.trimStart();for(let{0:o,index:i}of n.matchAll(/\S+/g)){if(s.value!==-1&&r.length>=s.value&&i!==void 0){r.push(o+n.slice(i+o.length));break}r.push(o)}}else{if(e.value==="")throw new Error("empty separator");r=this.value.split(e.value),s.value!==-1&&r.length>s.value&&r.push(r.splice(s.value).join(e.value))}return new ne(r.map(n=>new D(n)))})],["replace",new we(t=>{if(t.length<2)throw new Error("replace() requires at least two arguments");let e=t[0],s=t[1];if(!(e instanceof D&&s instanceof D))throw new Error("replace() arguments must be strings");let r;if(t.length>2?t[2].type==="KeywordArgumentsValue"?r=t[2].value.get("count")??new ye:r=t[2]:r=new ye,!(r instanceof J||r instanceof ye))throw new Error("replace() count argument must be a number or null");return new D(yE(this.value,e.value,s.value,r.value))})]])},K=class extends ut{type="BooleanValue"},bE=/[\x7f-\uffff]/g;function t0(t){return t.replace(bE,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}function Zt(t,e={},s=0,r=!0){let{indent:n=null,ensureAscii:o=!1,separators:i=null,sortKeys:a=!1}=e,l,c;switch(i?[l,c]=i:n?(l=",",c=": "):(l=", ",c=": "),t.type){case"NullValue":return"null";case"UndefinedValue":return r?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(t.value);case"StringValue":{let p=JSON.stringify(t.value);return o&&(p=t0(p)),p}case"ArrayValue":case"ObjectValue":{let p=n?" ".repeat(n):"",u=`
5
+ `+p.repeat(s),_=u+p;if(t.type==="ArrayValue"){let d=t.value.map(m=>Zt(m,e,s+1,r));return n?`[${_}${d.join(`${l}${_}`)}${u}]`:`[${d.join(l)}]`}else{let d=Array.from(t.value.entries());a&&(d=d.sort(([h],[g])=>h.localeCompare(g)));let m=d.map(([h,g])=>{let x=JSON.stringify(h);o&&(x=t0(x));let w=`${x}${c}${Zt(g,e,s+1,r)}`;return n?`${_}${w}`:w});return n?`{${m.join(l)}${u}}`:`{${m.join(l)}}`}}default:throw new Error(`Cannot convert to JSON: ${t.type}`)}}var Te=class extends ut{type="ObjectValue";__bool__(){return new K(this.value.size>0)}builtins=new Map([["get",new we(([t,e])=>{if(!(t instanceof D))throw new Error(`Object key must be a string: got ${t.type}`);return this.value.get(t.value)??e??new ye})],["items",new we(()=>this.items())],["keys",new we(()=>this.keys())],["values",new we(()=>this.values())],["dictsort",new we(t=>{let e=new Map,s=t.filter(a=>a instanceof Mr?(e=a.value,!1):!0),r=s.at(0)??e.get("case_sensitive")??new K(!1);if(!(r instanceof K))throw new Error("case_sensitive must be a boolean");let n=s.at(1)??e.get("by")??new D("key");if(!(n instanceof D))throw new Error("by must be a string");if(!["key","value"].includes(n.value))throw new Error("by must be either 'key' or 'value'");let o=s.at(2)??e.get("reverse")??new K(!1);if(!(o instanceof K))throw new Error("reverse must be a boolean");let i=Array.from(this.value.entries()).map(([a,l])=>new ne([new D(a),l])).sort((a,l)=>{let c=n.value==="key"?0:1,p=a.value[c],u=l.value[c],_=Lc(p,u,r.value);return o.value?-_:_});return new ne(i)})]]);items(){return new ne(Array.from(this.value.entries()).map(([t,e])=>new ne([new D(t),e])))}keys(){return new ne(Array.from(this.value.keys()).map(t=>new D(t)))}values(){return new ne(Array.from(this.value.values()))}toString(){return Zt(this,{},0,!1)}},Mr=class extends Te{type="KeywordArgumentsValue"},ne=class extends ut{type="ArrayValue";builtins=new Map([["length",new J(this.value.length)]]);__bool__(){return new K(this.value.length>0)}toString(){return Zt(this,{},0,!1)}},s0=class extends ne{type="TupleValue"},we=class extends ut{type="FunctionValue"},ye=class extends ut{type="NullValue"},xe=class extends ut{type="UndefinedValue"},Jt=class{constructor(t){this.parent=t}variables=new Map([["namespace",new we(t=>{if(t.length===0)return new Te(new Map);if(t.length!==1||!(t[0]instanceof Te))throw new Error("`namespace` expects either zero arguments or a single object argument");return t[0]})]]);tests=new Map([["boolean",t=>t.type==="BooleanValue"],["callable",t=>t instanceof we],["odd",t=>{if(!(t instanceof J))throw new Error(`cannot odd on ${t.type}`);return t.value%2!==0}],["even",t=>{if(!(t instanceof J))throw new Error(`cannot even on ${t.type}`);return t.value%2===0}],["false",t=>t.type==="BooleanValue"&&!t.value],["true",t=>t.type==="BooleanValue"&&t.value],["none",t=>t.type==="NullValue"],["string",t=>t.type==="StringValue"],["number",t=>t instanceof J||t instanceof Ee],["integer",t=>t instanceof J],["iterable",t=>t.type==="ArrayValue"||t.type==="StringValue"],["mapping",t=>t instanceof Te],["sequence",t=>t instanceof ne||t instanceof Te||t instanceof D],["lower",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toLowerCase()}],["upper",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toUpperCase()}],["none",t=>t.type==="NullValue"],["defined",t=>t.type!=="UndefinedValue"],["undefined",t=>t.type==="UndefinedValue"],["equalto",(t,e)=>t.value===e.value],["eq",(t,e)=>t.value===e.value]]);set(t,e){return this.declareVariable(t,Xi(e))}declareVariable(t,e){if(this.variables.has(t))throw new SyntaxError(`Variable already declared: ${t}`);return this.variables.set(t,e),e}setVariable(t,e){return this.variables.set(t,e),e}resolve(t){if(this.variables.has(t))return this;if(this.parent)return this.parent.resolve(t);throw new Error(`Unknown variable: ${t}`)}lookupVariable(t){try{return this.resolve(t).variables.get(t)??new xe}catch{return new xe}}};function kE(t){t.set("false",!1),t.set("true",!0),t.set("none",null),t.set("raise_exception",e=>{throw new Error(e)}),t.set("range",mE),t.set("strftime_now",gE),t.set("True",!0),t.set("False",!1),t.set("None",null)}function r0(t,e){let s=e.split("."),r=t;for(let n of s)if(r instanceof Te)r=r.value.get(n)??new xe;else if(r instanceof ne){let o=parseInt(n,10);if(!isNaN(o)&&o>=0&&o<r.value.length)r=r.value[o];else return new xe}else return new xe;return r}function Lc(t,e,s=!1){if(t instanceof ye&&e instanceof ye)return 0;if(t instanceof ye||e instanceof ye)throw new Error(`Cannot compare ${t.type} with ${e.type}`);if(t instanceof xe&&e instanceof xe)return 0;if(t instanceof xe||e instanceof xe)throw new Error(`Cannot compare ${t.type} with ${e.type}`);let r=o=>o instanceof J||o instanceof Ee||o instanceof K,n=o=>o instanceof K?o.value?1:0:o.value;if(r(t)&&r(e)){let o=n(t),i=n(e);return o<i?-1:o>i?1:0}if(t.type!==e.type)throw new Error(`Cannot compare different types: ${t.type} and ${e.type}`);if(t.type==="StringValue"){let o=t.value,i=e.value;return s||(o=o.toLowerCase(),i=i.toLowerCase()),o<i?-1:o>i?1:0}else throw new Error(`Cannot compare type: ${t.type}`)}var vE=class{global;constructor(t){this.global=t??new Jt}run(t){return this.evaluate(t,this.global)}evaluateBinaryExpression(t,e){let s=this.evaluate(t.left,e);switch(t.operator.value){case"and":return s.__bool__().value?this.evaluate(t.right,e):s;case"or":return s.__bool__().value?s:this.evaluate(t.right,e)}let r=this.evaluate(t.right,e);switch(t.operator.value){case"==":return new K(s.value==r.value);case"!=":return new K(s.value!=r.value)}if(s instanceof xe||r instanceof xe){if(r instanceof xe&&["in","not in"].includes(t.operator.value))return new K(t.operator.value==="not in");throw new Error(`Cannot perform operation ${t.operator.value} on undefined values`)}else{if(s instanceof ye||r instanceof ye)throw new Error("Cannot perform operation on null values");if(t.operator.value==="~")return new D(s.value.toString()+r.value.toString());if((s instanceof J||s instanceof Ee)&&(r instanceof J||r instanceof Ee)){let n=s.value,o=r.value;switch(t.operator.value){case"+":case"-":case"*":{let i=t.operator.value==="+"?n+o:t.operator.value==="-"?n-o:n*o;return s instanceof Ee||r instanceof Ee?new Ee(i):new J(i)}case"/":return new Ee(n/o);case"%":{let i=n%o;return s instanceof Ee||r instanceof Ee?new Ee(i):new J(i)}case"<":return new K(n<o);case">":return new K(n>o);case">=":return new K(n>=o);case"<=":return new K(n<=o)}}else if(s instanceof ne&&r instanceof ne){if(t.operator.value==="+")return new ne(s.value.concat(r.value))}else if(r instanceof ne){let n=r.value.find(o=>o.value===s.value)!==void 0;switch(t.operator.value){case"in":return new K(n);case"not in":return new K(!n)}}}if((s instanceof D||r instanceof D)&&t.operator.value==="+")return new D(s.value.toString()+r.value.toString());if(s instanceof D&&r instanceof D)switch(t.operator.value){case"in":return new K(r.value.includes(s.value));case"not in":return new K(!r.value.includes(s.value))}if(s instanceof D&&r instanceof Te)switch(t.operator.value){case"in":return new K(r.value.has(s.value));case"not in":return new K(!r.value.has(s.value))}throw new SyntaxError(`Unknown operator "${t.operator.value}" between ${s.type} and ${r.type}`)}evaluateArguments(t,e){let s=[],r=new Map;for(let n of t)if(n.type==="SpreadExpression"){let o=n,i=this.evaluate(o.argument,e);if(!(i instanceof ne))throw new Error(`Cannot unpack non-iterable type: ${i.type}`);for(let a of i.value)s.push(a)}else if(n.type==="KeywordArgumentExpression"){let o=n;r.set(o.key.value,this.evaluate(o.value,e))}else{if(r.size>0)throw new Error("Positional arguments must come before keyword arguments");s.push(this.evaluate(n,e))}return[s,r]}applyFilter(t,e,s){if(e.type==="Identifier"){let r=e;if(r.value==="safe")return t;if(r.value==="tojson")return new D(Zt(t,{}));if(t instanceof ne)switch(r.value){case"list":return t;case"first":return t.value[0];case"last":return t.value[t.value.length-1];case"length":return new J(t.value.length);case"reverse":return new ne(t.value.slice().reverse());case"sort":return new ne(t.value.slice().sort((n,o)=>Lc(n,o,!1)));case"join":return new D(t.value.map(n=>n.value).join(""));case"string":return new D(Zt(t,{},0,!1));case"unique":{let n=new Set,o=[];for(let i of t.value)n.has(i.value)||(n.add(i.value),o.push(i));return new ne(o)}default:throw new Error(`Unknown ArrayValue filter: ${r.value}`)}else if(t instanceof D)switch(r.value){case"length":case"upper":case"lower":case"title":case"capitalize":{let n=t.builtins.get(r.value);if(n instanceof we)return n.value([],s);if(n instanceof J)return n;throw new Error(`Unknown StringValue filter: ${r.value}`)}case"trim":return new D(t.value.trim());case"indent":return new D(t.value.split(`
6
6
  `).map((n,o)=>o===0||n.length===0?n:" "+n).join(`
7
- `));case"join":case"string":return t;case"int":{let n=parseInt(t.value,10);return new H(isNaN(n)?0:n)}case"float":{let n=parseFloat(t.value);return new ye(isNaN(n)?0:n)}default:throw new Error(`Unknown StringValue filter: ${r.value}`)}else if(t instanceof H||t instanceof ye)switch(r.value){case"abs":return t instanceof H?new H(Math.abs(t.value)):new ye(Math.abs(t.value));case"int":return new H(Math.floor(t.value));case"float":return new ye(t.value);default:throw new Error(`Unknown NumericValue filter: ${r.value}`)}else if(t instanceof Le)switch(r.value){case"items":return new te(Array.from(t.value.entries()).map(([n,o])=>new te([new $(n),o])));case"length":return new H(t.value.size);default:{let n=t.builtins.get(r.value);if(n)return n instanceof me?n.value([],s):n;throw new Error(`Unknown ObjectValue filter: ${r.value}`)}}else if(t instanceof U)switch(r.value){case"bool":return new U(t.value);case"int":return new H(t.value?1:0);case"float":return new ye(t.value?1:0);case"string":return new $(t.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${r.value}`)}throw new Error(`Cannot apply filter "${r.value}" to type: ${t.type}`)}else if(e.type==="CallExpression"){let r=e;if(r.callee.type!=="Identifier")throw new Error(`Unknown filter: ${r.callee.type}`);let n=r.callee.value;if(n==="tojson"){let[,o]=this.evaluateArguments(r.args,s),a=o.get("indent")??new he;if(!(a instanceof H||a instanceof he))throw new Error("If set, indent must be a number");let i=o.get("ensure_ascii")??new U(!1);if(!(i instanceof U))throw new Error("If set, ensure_ascii must be a boolean");let l=o.get("sort_keys")??new U(!1);if(!(l instanceof U))throw new Error("If set, sort_keys must be a boolean");let c=o.get("separators")??new he,u=null;if(c instanceof te||c instanceof Zg){if(c.value.length!==2)throw new Error("separators must be a tuple of two strings");let[p,d]=c.value;if(!(p instanceof $)||!(d instanceof $))throw new Error("separators must be a tuple of two strings");u=[p.value,d.value]}else if(!(c instanceof he))throw new Error("If set, separators must be a tuple of two strings");return new $(Ht(t,{indent:a.value,ensureAscii:i.value,sortKeys:l.value,separators:u}))}else if(n==="join"){let o;if(t instanceof $)o=Array.from(t.value);else if(t instanceof te)o=t.value.map(c=>c.value);else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`);let[a,i]=this.evaluateArguments(r.args,s),l=a.at(0)??i.get("separator")??new $("");if(!(l instanceof $))throw new Error("separator must be a string");return new $(o.join(l.value))}else if(n==="int"||n==="float"){let[o,a]=this.evaluateArguments(r.args,s),i=o.at(0)??a.get("default")??(n==="int"?new H(0):new ye(0));if(t instanceof $){let l=n==="int"?parseInt(t.value,10):parseFloat(t.value);return isNaN(l)?i:n==="int"?new H(l):new ye(l)}else{if(t instanceof H||t instanceof ye)return t;if(t instanceof U)return n==="int"?new H(t.value?1:0):new ye(t.value?1:0);throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}}else if(n==="default"){let[o,a]=this.evaluateArguments(r.args,s),i=o[0]??new $(""),l=o[1]??a.get("boolean")??new U(!1);if(!(l instanceof U))throw new Error("`default` filter flag must be a boolean");return t instanceof fe||l.value&&!t.__bool__().value?i:t}if(t instanceof te){switch(n){case"sort":{let[o,a]=this.evaluateArguments(r.args,s),i=o.at(0)??a.get("reverse")??new U(!1);if(!(i instanceof U))throw new Error("reverse must be a boolean");let l=o.at(1)??a.get("case_sensitive")??new U(!1);if(!(l instanceof U))throw new Error("case_sensitive must be a boolean");let c=o.at(2)??a.get("attribute")??new he;if(!(c instanceof $||c instanceof H||c instanceof he))throw new Error("attribute must be a string, integer, or null");let u=p=>{if(c instanceof he)return p;let d=c instanceof H?String(c.value):c.value;return ew(p,d)};return new te(t.value.slice().sort((p,d)=>{let _=u(p),m=u(d),h=Fl(_,m,l.value);return i.value?-h:h}))}case"selectattr":case"rejectattr":{let o=n==="selectattr";if(t.value.some(p=>!(p instanceof Le)))throw new Error(`\`${n}\` can only be applied to array of objects`);if(r.args.some(p=>p.type!=="StringLiteral"))throw new Error(`arguments of \`${n}\` must be strings`);let[a,i,l]=r.args.map(p=>this.evaluate(p,s)),c;if(i){let p=s.tests.get(i.value);if(!p)throw new Error(`Unknown test: ${i.value}`);c=p}else c=(...p)=>p[0].__bool__().value;let u=t.value.filter(p=>{let d=p.value.get(a.value),_=d?c(d,l):!1;return o?_:!_});return new te(u)}case"map":{let[,o]=this.evaluateArguments(r.args,s);if(o.has("attribute")){let a=o.get("attribute");if(!(a instanceof $))throw new Error("attribute must be a string");let i=o.get("default"),l=t.value.map(c=>{if(!(c instanceof Le))throw new Error("items in map must be an object");let u=ew(c,a.value);return u instanceof fe?i??new fe:u});return new te(l)}else throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${n}`)}else if(t instanceof $){switch(n){case"indent":{let[o,a]=this.evaluateArguments(r.args,s),i=o.at(0)??a.get("width")??new H(4);if(!(i instanceof H))throw new Error("width must be a number");let l=o.at(1)??a.get("first")??new U(!1),c=o.at(2)??a.get("blank")??new U(!1),u=t.value.split(`
8
- `),p=" ".repeat(i.value),d=u.map((_,m)=>!l.value&&m===0||!c.value&&_.length===0?_:p+_);return new $(d.join(`
9
- `))}case"replace":{let o=t.builtins.get("replace");if(!(o instanceof me))throw new Error("replace filter not available");let[a,i]=this.evaluateArguments(r.args,s);return o.value([...a,new ar(i)],s)}}throw new Error(`Unknown StringValue filter: ${n}`)}else if(t instanceof Le){let o=t.builtins.get(n);if(o&&o instanceof me){let[a,i]=this.evaluateArguments(r.args,s);return i.size>0&&a.push(new ar(i)),o.value(a,s)}throw new Error(`Unknown ObjectValue filter: ${n}`)}else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}throw new Error(`Unknown filter: ${e.type}`)}evaluateFilterExpression(t,e){let s=this.evaluate(t.operand,e);return this.applyFilter(s,t.filter,e)}evaluateTestExpression(t,e){let s=this.evaluate(t.operand,e),r=e.tests.get(t.test.value);if(!r)throw new Error(`Unknown test: ${t.test.value}`);let n=r(s);return new U(t.negate?!n:n)}evaluateSelectExpression(t,e){return this.evaluate(t.test,e).__bool__().value?this.evaluate(t.lhs,e):new fe}evaluateUnaryExpression(t,e){let s=this.evaluate(t.argument,e);if(t.operator.value==="not")return new U(!s.value);throw new SyntaxError(`Unknown operator: ${t.operator.value}`)}evaluateTernaryExpression(t,e){return this.evaluate(t.condition,e).__bool__().value?this.evaluate(t.trueExpr,e):this.evaluate(t.falseExpr,e)}evalProgram(t,e){return this.evaluateBlock(t.body,e)}evaluateBlock(t,e){let s="";for(let r of t){let n=this.evaluate(r,e);n.type!=="NullValue"&&n.type!=="UndefinedValue"&&(s+=n.toString())}return new $(s)}evaluateIdentifier(t,e){return e.lookupVariable(t.value)}evaluateCallExpression(t,e){let[s,r]=this.evaluateArguments(t.args,e);r.size>0&&s.push(new ar(r));let n=this.evaluate(t.callee,e);if(n.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${n.type}`);return n.value(s,e)}evaluateSliceExpression(t,e,s){if(!(t instanceof te||t instanceof $))throw new Error("Slice object must be an array or string");let r=this.evaluate(e.start,s),n=this.evaluate(e.stop,s),o=this.evaluate(e.step,s);if(!(r instanceof H||r instanceof fe))throw new Error("Slice start must be numeric or undefined");if(!(n instanceof H||n instanceof fe))throw new Error("Slice stop must be numeric or undefined");if(!(o instanceof H||o instanceof fe))throw new Error("Slice step must be numeric or undefined");return t instanceof te?new te(Kg(t.value,r.value,n.value,o.value)):new $(Kg(Array.from(t.value),r.value,n.value,o.value).join(""))}evaluateMemberExpression(t,e){let s=this.evaluate(t.object,e),r;if(t.computed){if(t.property.type==="SliceExpression")return this.evaluateSliceExpression(s,t.property,e);r=this.evaluate(t.property,e)}else r=new $(t.property.value);let n;if(s instanceof Le){if(!(r instanceof $))throw new Error(`Cannot access property with non-string: got ${r.type}`);n=s.value.get(r.value)??s.builtins.get(r.value)}else if(s instanceof te||s instanceof $)if(r instanceof H)n=s.value.at(r.value),s instanceof $&&(n=new $(s.value.at(r.value)));else if(r instanceof $)n=s.builtins.get(r.value);else throw new Error(`Cannot access property with non-string/non-number: got ${r.type}`);else{if(!(r instanceof $))throw new Error(`Cannot access property with non-string: got ${r.type}`);n=s.builtins.get(r.value)}return n instanceof ut?n:new fe}evaluateSet(t,e){let s=t.value?this.evaluate(t.value,e):this.evaluateBlock(t.body,e);if(t.assignee.type==="Identifier"){let r=t.assignee.value;e.setVariable(r,s)}else if(t.assignee.type==="TupleLiteral"){let r=t.assignee;if(!(s instanceof te))throw new Error(`Cannot unpack non-iterable type in set: ${s.type}`);let n=s.value;if(n.length!==r.value.length)throw new Error(`Too ${r.value.length>n.length?"few":"many"} items to unpack in set`);for(let o=0;o<r.value.length;++o){let a=r.value[o];if(a.type!=="Identifier")throw new Error(`Cannot unpack to non-identifier in set: ${a.type}`);e.setVariable(a.value,n[o])}}else if(t.assignee.type==="MemberExpression"){let r=t.assignee,n=this.evaluate(r.object,e);if(!(n instanceof Le))throw new Error("Cannot assign to member of non-object");if(r.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");n.value.set(r.property.value,s)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(t.assignee)}`);return new he}evaluateIf(t,e){let s=this.evaluate(t.test,e);return this.evaluateBlock(s.__bool__().value?t.body:t.alternate,e)}evaluateFor(t,e){let s=new Vt(e),r,n;if(t.iterable.type==="SelectExpression"){let c=t.iterable;n=this.evaluate(c.lhs,s),r=c.test}else n=this.evaluate(t.iterable,s);if(!(n instanceof te||n instanceof Le))throw new Error(`Expected iterable or object type in for loop: got ${n.type}`);n instanceof Le&&(n=n.keys());let o=[],a=[];for(let c=0;c<n.value.length;++c){let u=new Vt(s),p=n.value[c],d;if(t.loopvar.type==="Identifier")d=_=>_.setVariable(t.loopvar.value,p);else if(t.loopvar.type==="TupleLiteral"){let _=t.loopvar;if(p.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${p.type}`);let m=p;if(_.value.length!==m.value.length)throw new Error(`Too ${_.value.length>m.value.length?"few":"many"} items to unpack`);d=h=>{for(let x=0;x<_.value.length;++x){if(_.value[x].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${_.value[x].type}`);h.setVariable(_.value[x].value,m.value[x])}}}else throw new Error(`Invalid loop variable(s): ${t.loopvar.type}`);r&&(d(u),!this.evaluate(r,u).__bool__().value)||(o.push(p),a.push(d))}let i="",l=!0;for(let c=0;c<o.length;++c){let u=new Map([["index",new H(c+1)],["index0",new H(c)],["revindex",new H(o.length-c)],["revindex0",new H(o.length-c-1)],["first",new U(c===0)],["last",new U(c===o.length-1)],["length",new H(o.length)],["previtem",c>0?o[c-1]:new fe],["nextitem",c<o.length-1?o[c+1]:new fe]]);s.setVariable("loop",new Le(u)),a[c](s);try{let p=this.evaluateBlock(t.body,s);i+=p.value}catch(p){if(p instanceof Jg)continue;if(p instanceof Qg)break;throw p}l=!1}if(l){let c=this.evaluateBlock(t.defaultBlock,s);i+=c.value}return new $(i)}evaluateMacro(t,e){return e.setVariable(t.name.value,new me((s,r)=>{let n=new Vt(r);s=s.slice();let o;s.at(-1)?.type==="KeywordArgumentsValue"&&(o=s.pop());for(let a=0;a<t.args.length;++a){let i=t.args[a],l=s[a];if(i.type==="Identifier"){let c=i;if(!l)throw new Error(`Missing positional argument: ${c.value}`);n.setVariable(c.value,l)}else if(i.type==="KeywordArgumentExpression"){let c=i,u=l??o?.value.get(c.key.value)??this.evaluate(c.value,n);n.setVariable(c.key.value,u)}else throw new Error(`Unknown argument type: ${i.type}`)}return this.evaluateBlock(t.body,n)})),new he}evaluateCallStatement(t,e){let s=new me((i,l)=>{let c=new Vt(l);if(t.callerArgs)for(let u=0;u<t.callerArgs.length;++u){let p=t.callerArgs[u];if(p.type!=="Identifier")throw new Error(`Caller parameter must be an identifier, got ${p.type}`);c.setVariable(p.value,i[u]??new fe)}return this.evaluateBlock(t.body,c)}),[r,n]=this.evaluateArguments(t.call.args,e);r.push(new ar(n));let o=this.evaluate(t.call.callee,e);if(o.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${o.type}`);let a=new Vt(e);return a.setVariable("caller",s),o.value(r,a)}evaluateFilterStatement(t,e){let s=this.evaluateBlock(t.body,e);return this.applyFilter(s,t.filter,e)}evaluate(t,e){if(!t)return new fe;switch(t.type){case"Program":return this.evalProgram(t,e);case"Set":return this.evaluateSet(t,e);case"If":return this.evaluateIf(t,e);case"For":return this.evaluateFor(t,e);case"Macro":return this.evaluateMacro(t,e);case"CallStatement":return this.evaluateCallStatement(t,e);case"Break":throw new Qg;case"Continue":throw new Jg;case"IntegerLiteral":return new H(t.value);case"FloatLiteral":return new ye(t.value);case"StringLiteral":return new $(t.value);case"ArrayLiteral":return new te(t.value.map(s=>this.evaluate(s,e)));case"TupleLiteral":return new Zg(t.value.map(s=>this.evaluate(s,e)));case"ObjectLiteral":{let s=new Map;for(let[r,n]of t.value){let o=this.evaluate(r,e);if(!(o instanceof $))throw new Error(`Object keys must be strings: got ${o.type}`);s.set(o.value,this.evaluate(n,e))}return new Le(s)}case"Identifier":return this.evaluateIdentifier(t,e);case"CallExpression":return this.evaluateCallExpression(t,e);case"MemberExpression":return this.evaluateMemberExpression(t,e);case"UnaryExpression":return this.evaluateUnaryExpression(t,e);case"BinaryExpression":return this.evaluateBinaryExpression(t,e);case"FilterExpression":return this.evaluateFilterExpression(t,e);case"FilterStatement":return this.evaluateFilterStatement(t,e);case"TestExpression":return this.evaluateTestExpression(t,e);case"SelectExpression":return this.evaluateSelectExpression(t,e);case"Ternary":return this.evaluateTernaryExpression(t,e);case"Comment":return new he;default:throw new SyntaxError(`Unknown node type: ${t.type}`)}}};function qo(t){switch(typeof t){case"number":return Number.isInteger(t)?new H(t):new ye(t);case"string":return new $(t);case"boolean":return new U(t);case"undefined":return new fe;case"object":return t===null?new he:Array.isArray(t)?new te(t.map(qo)):new Le(new Map(Object.entries(t).map(([e,s])=>[e,qo(s)])));case"function":return new me((e,s)=>{let r=t(...e.map(n=>n.value))??null;return qo(r)});default:throw new Error(`Cannot convert to runtime value: ${t}`)}}var Ae=`
10
- `,sk="{%- ",rk=" -%}";function nk(t){switch(t.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return t.operator.value==="and"?1:t.operator.value==="in"||t.operator.value==="not in"?2:0}return 0}function ok(t,e=" "){let s=typeof e=="number"?" ".repeat(e):e;return rt(t.body,0,s).replace(/\n$/,"")}function Te(...t){return sk+t.join(" ")+rk}function rt(t,e,s){return t.map(r=>ak(r,e,s)).join(Ae)}function ak(t,e,s){let r=s.repeat(e);switch(t.type){case"Program":return rt(t.body,e,s);case"If":return ik(t,e,s);case"For":return lk(t,e,s);case"Set":return ck(t,e,s);case"Macro":return uk(t,e,s);case"Break":return r+Te("break");case"Continue":return r+Te("continue");case"CallStatement":return pk(t,e,s);case"FilterStatement":return dk(t,e,s);case"Comment":return r+"{# "+t.value+" #}";default:return r+"{{- "+se(t)+" -}}"}}function ik(t,e,s){let r=s.repeat(e),n=[],o=t;for(;o&&(n.push({test:o.test,body:o.body}),o.alternate.length===1&&o.alternate[0].type==="If");)o=o.alternate[0];let a=r+Te("if",se(n[0].test))+Ae+rt(n[0].body,e+1,s);for(let i=1;i<n.length;++i)a+=Ae+r+Te("elif",se(n[i].test))+Ae+rt(n[i].body,e+1,s);return o&&o.alternate.length>0&&(a+=Ae+r+Te("else")+Ae+rt(o.alternate,e+1,s)),a+=Ae+r+Te("endif"),a}function lk(t,e,s){let r=s.repeat(e),n="";if(t.iterable.type==="SelectExpression"){let a=t.iterable;n=`${se(a.lhs)} if ${se(a.test)}`}else n=se(t.iterable);let o=r+Te("for",se(t.loopvar),"in",n)+Ae+rt(t.body,e+1,s);return t.defaultBlock.length>0&&(o+=Ae+r+Te("else")+Ae+rt(t.defaultBlock,e+1,s)),o+=Ae+r+Te("endfor"),o}function ck(t,e,s){let r=s.repeat(e),n=se(t.assignee),o=t.value?se(t.value):"",a=r+Te("set",`${n}${t.value?" = "+o:""}`);return t.body.length===0?a:a+Ae+rt(t.body,e+1,s)+Ae+r+Te("endset")}function uk(t,e,s){let r=s.repeat(e),n=t.args.map(se).join(", ");return r+Te("macro",`${t.name.value}(${n})`)+Ae+rt(t.body,e+1,s)+Ae+r+Te("endmacro")}function pk(t,e,s){let r=s.repeat(e),n=t.callerArgs&&t.callerArgs.length>0?`(${t.callerArgs.map(se).join(", ")})`:"",o=se(t.call),a=r+Te(`call${n}`,o)+Ae;return a+=rt(t.body,e+1,s)+Ae,a+=r+Te("endcall"),a}function dk(t,e,s){let r=s.repeat(e),n=t.filter.type==="Identifier"?t.filter.value:se(t.filter),o=r+Te("filter",n)+Ae;return o+=rt(t.body,e+1,s)+Ae,o+=r+Te("endfilter"),o}function se(t,e=-1){switch(t.type){case"SpreadExpression":return`*${se(t.argument)}`;case"Identifier":return t.value;case"IntegerLiteral":return`${t.value}`;case"FloatLiteral":return`${t.value}`;case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":{let s=t,r=nk(s),n=se(s.left,r),o=se(s.right,r+1),a=`${n} ${s.operator.value} ${o}`;return r<e?`(${a})`:a}case"UnaryExpression":{let s=t;return s.operator.value+(s.operator.value==="not"?" ":"")+se(s.argument,1/0)}case"CallExpression":{let s=t,r=s.args.map(se).join(", ");return`${se(s.callee)}(${r})`}case"MemberExpression":{let s=t,r=se(s.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(s.object.type)||(r=`(${r})`);let n=se(s.property);return!s.computed&&s.property.type!=="Identifier"&&(n=`(${n})`),s.computed?`${r}[${n}]`:`${r}.${n}`}case"FilterExpression":{let s=t,r=se(s.operand,1/0);return s.filter.type==="CallExpression"?`${r} | ${se(s.filter)}`:`${r} | ${s.filter.value}`}case"SelectExpression":{let s=t;return`${se(s.lhs)} if ${se(s.test)}`}case"TestExpression":{let s=t;return`${se(s.operand)} is${s.negate?" not":""} ${s.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let s=t.value.map(se),r=t.type==="ArrayLiteral"?"[]":"()";return`${r[0]}${s.join(", ")}${r[1]}`}case"ObjectLiteral":return`{${Array.from(t.value.entries()).map(([r,n])=>`${se(r)}: ${se(n)}`).join(", ")}}`;case"SliceExpression":{let s=t,r=s.start?se(s.start):"",n=s.stop?se(s.stop):"",o=s.step?`:${se(s.step)}`:"";return`${r}:${n}${o}`}case"KeywordArgumentExpression":{let s=t;return`${s.key.value}=${se(s.value)}`}case"Ternary":{let s=t,r=`${se(s.trueExpr)} if ${se(s.condition,0)} else ${se(s.falseExpr)}`;return e>-1?`(${r})`:r}default:throw new Error(`Unknown expression type: ${t.type}`)}}var tw=class{parsed;constructor(t){let e=k1(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=V1(e)}render(t){let e=new Vt;if(ek(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new tk(e).run(this.parsed).value}format(t){return ok(this.parsed,t?.indent||" ")}};var ke=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}_call(...t){throw Error("Must implement _call method in subclass")}};function yt(t,e){t&&t(e)}function sw(t){return Number.isInteger(t)||typeof t=="bigint"}function Dl(t){return t==null||t===-1}function jl(t){let e=[],s=t;for(;Array.isArray(s);)e.push(s.length),s=s[0];return e}function Pe(...t){return Array.prototype.concat.apply([],t)}function rw(...t){return t.reduce((e,s)=>e.flatMap(r=>s.map(n=>[r,n])))}function _s(t,e){return Math.abs((t+e)%(2*e)-e)}function Me(t,e){return Object.assign({},...e.map(s=>{if(t[s]!==void 0)return{[s]:t[s]}}))}function nw(t,e){let s=0;for(let r of t)r===e&&++s;return s}var _k={txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"},Xt=class t{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=De.existsSync(e),this.exists){this.status=200,this.statusText="OK";let s=De.statSync(e);this.headers.set("content-length",s.size.toString()),this.updateContentType();let r=De.createReadStream(e);this.body=new ReadableStream({start(n){r.on("data",o=>n.enqueue(o)),r.on("end",()=>n.close()),r.on("error",o=>n.error(o))},cancel(){r.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",_k[e]??"application/octet-stream")}clone(){let e=new t(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await De.promises.readFile(this.filePath)).buffer}async blob(){let e=await De.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await De.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}},fs=class{constructor(e){this.path=e}async match(e){let s=et.join(this.path,e),r=new Xt(s);if(r.exists)return r}async put(e,s,r=void 0){let n=et.join(this.path,e);try{let o=s.headers.get("Content-Length"),a=parseInt(o??"0"),i=0;await De.promises.mkdir(et.dirname(n),{recursive:!0});let l=De.createWriteStream(n),c=s.body.getReader();for(;;){let{done:u,value:p}=await c.read();if(u)break;await new Promise((_,m)=>{l.write(p,h=>{if(h){m(h);return}_()})}),i+=p.length;let d=a?i/a*100:0;r?.({progress:d,loaded:i,total:a})}l.close()}catch(o){try{await De.promises.unlink(n)}catch{}throw o}}};var ow={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"},Go=100,aw=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function ir(...t){return t=t.map((e,s)=>(s&&(e=e.replace(new RegExp("^/"),"")),s!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e)),t.join("/")}function ms(t,e=null,s=null){let r;try{r=new URL(t)}catch{return!1}return!(e&&!e.includes(r.protocol)||s&&!s.includes(r.hostname))}function iw(t){return!(!aw.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function lw(t,e,s){if(!s)return null;let r=ow[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${r}: "${e}".`)}async function cw(t,e){let s=t.headers.get("Content-Length");s===null&&console.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let r=parseInt(s??"0"),n=new Uint8Array(r),o=0,a=t.body.getReader();async function i(){let{done:l,value:c}=await a.read();if(l)return;let u=o+c.length;if(u>r){r=u;let d=new Uint8Array(r);d.set(n),n=d}n.set(c,o),o=u;let p=o/r*100;return e({progress:p,loaded:o,total:r}),i()}return await i(),n}async function Wo(t=null){let e=null;if(_e.useCustomCache){if(!_e.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!_e.customCache.match||!_e.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");e=_e.customCache}if(!e&&_e.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{e=await caches.open(_e.cacheKey)}catch(s){console.warn("An error occurred while opening the browser cache:",s)}}if(!e&&_e.useFSCache){if(!ee.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");e=new fs(t??_e.cacheDir)}return e}async function uw(t,...e){for(let s of e)try{let r=await t.match(s);if(r)return r}catch{continue}}async function hs(t){if(_e.useFS&&!ms(t,["http:","https:","blob:"]))return new Xt(t instanceof URL?t.protocol==="file:"?t.pathname:t.toString():t);if(typeof process<"u"&&process?.release?.name==="node"){let e=!!process.env?.TESTING_REMOTELY,s=_e.version,r=new Headers;if(r.set("User-Agent",`transformers.js/${s}; is_ci/${e};`),ms(t,["http:","https:"],["huggingface.co","hf.co"])){let o=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;o&&r.set("Authorization",`Bearer ${o}`)}return fetch(t,{headers:r})}else return fetch(t)}function fk(t,e,s={},r=null){let n=s.revision??"main",o=ir(t,e),a=iw(t),i=a?ir(_e.localModelPath,o):o,l=ir(_e.remoteHost,_e.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),c=r instanceof fs?n==="main"?o:ir(t,n,e):l;return{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:a}}async function mk(t,e,s){if(t)return await uw(t,e,s)}async function hk(t,e,s,r,n,o,a={}){if(await s.match(r)===void 0)if(o)typeof n!="string"&&await s.put(r,new Response(o,{headers:n.headers})).catch(i=>{console.warn(`Unable to add response to browser cache: ${i}.`)});else{let i=a.progress_callback?l=>yt(a.progress_callback,{status:"progress",name:t,file:e,...l}):void 0;await s.put(r,n,i)}}async function xk(t,e,s=!0,r={},n=!1,o=null){let{requestURL:a,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:u}=fk(t,e,r,o),p,d=!1,_;_=await mk(o,i,c);let m=_!==void 0;if(!m){if(_e.allowLocalModels)if(ms(a,["http:","https:"])){if(r.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${a}.`);if(!_e.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${a}.`)}else try{_=await hs(i),p=i}catch(w){console.warn(`Unable to load from local path "${i}": "${w}"`)}if(_===void 0||typeof _!="string"&&_.status===404){if(r.local_files_only||!_e.allowRemoteModels){if(s)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${i}".`);return null}if(!u)throw Error(`Local file missing at "${i}" and download aborted due to invalid model ID "${t}".`);if(_=await hs(l),_.status!==200)return lw(_.status,l,s);p=c}d=o&&typeof Response<"u"&&_ instanceof Response&&_.status===200}yt(r.progress_callback,{status:"download",name:t,file:e});let h;if(!(ee.IS_NODE_ENV&&n)){let g;typeof _!="string"&&(r.progress_callback?m&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent)?(g=new Uint8Array(await _.arrayBuffer()),yt(r.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:g.length,total:g.length})):g=await cw(_,w=>{yt(r.progress_callback,{status:"progress",name:t,file:e,...w})}):g=new Uint8Array(await _.arrayBuffer())),h=g}if(d&&p&&typeof _!="string"&&await hk(t,e,o,p,_,h,r),yt(r.progress_callback,{status:"done",name:t,file:e}),h){if(!ee.IS_NODE_ENV&&n)throw new Error("Cannot return path in a browser environment.");return h}if(_ instanceof Xt)return _.filePath;let x=await o?.match(p);if(x instanceof Xt)return x.filePath;if(x instanceof Response)return new Uint8Array(await x.arrayBuffer());if(typeof x=="string")return x;throw new Error("Unable to get model file path or buffer.")}async function lr(t,e,s=!0,r={},n=!1){if(!_e.allowLocalModels){if(r.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");if(!_e.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}yt(r.progress_callback,{status:"initiate",name:t,file:e});let o=await Wo(r?.cache_dir);return await xk(t,e,s,r,n,o)}async function Bl(t,e,s=!0,r={}){let n=await lr(t,e,s,r,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function Se(t,e,s=!0,r={}){let n=await Bl(t,e,s,r);return n===null?{}:JSON.parse(n)}function dw(t,[e,s,r],[n,o],a="bilinear",i=!1){let l=o/r,c=n/s,u=new t.constructor(n*o*e),p=s*r,d=n*o;for(let _=0;_<n;++_)for(let m=0;m<o;++m){let h=_*o+m,x=(m+.5)/l-.5,g=(_+.5)/c-.5,w=Math.floor(x),y=Math.floor(g),E=Math.min(w+1,r-1),A=Math.min(y+1,s-1);w=Math.max(w,0),y=Math.max(y,0);let b=x-w,O=g-y,N=(1-b)*(1-O),F=b*(1-O),R=(1-b)*O,B=b*O,G=y*r,D=A*r,X=G+w,V=G+E,re=D+w,Y=D+E;for(let k=0;k<e;++k){let v=k*p;u[k*d+h]=N*t[v+X]+F*t[v+V]+R*t[v+re]+B*t[v+Y]}}return u}function _w(t,e,s){let r=new Array(s.length),n=new Array(s.length);for(let i=s.length-1,l=1;i>=0;--i)n[i]=l,r[i]=e[s[i]],l*=r[i];let o=s.map((i,l)=>n[s.indexOf(l)]),a=new t.constructor(t.length);for(let i=0;i<t.length;++i){let l=0;for(let c=e.length-1,u=i;c>=0;--c)l+=u%e[c]*o[c],u=Math.floor(u/e[c]);a[l]=t[i]}return[a,r]}function ce(t){let e=ae(t)[0],s=t.map(o=>Math.exp(o-e)),r=s.reduce((o,a)=>o+a,0);return s.map(o=>o/r)}function ql(t){let e=ae(t)[0],s=0;for(let o=0;o<t.length;++o)s+=Math.exp(t[o]-e);let r=Math.log(s);return t.map(o=>o-e-r)}function fw(t,e){let s=0;for(let r=0;r<t.length;++r)s+=t[r]*e[r];return s}function gk(t,e){let s=fw(t,e),r=pw(t),n=pw(e);return s/(r*n)}function pw(t){return Math.sqrt(t.reduce((e,s)=>e+s*s,0))}function cr(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]<e&&(e=t[r],s=r);return[e,s]}function ae(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]>e&&(e=t[r],s=r);return[e,s]}function mw(t){return t>0&&(t&t-1)===0}var Vo=class{constructor(e){if(this.size=e|0,this.size<=1||!mw(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let r=0;r<this.table.length;r+=2){let n=Math.PI*r/this.size;this.table[r]=Math.cos(n),this.table[r+1]=-Math.sin(n)}let s=0;for(let r=1;this.size>r;r<<=1)++s;this._width=s%2===0?s-1:s,this._bitrev=new Int32Array(1<<this._width);for(let r=0;r<this._bitrev.length;++r){this._bitrev[r]=0;for(let n=0;n<this._width;n+=2){let o=this._width-n-2;this._bitrev[r]|=(r>>>n&3)<<o}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,s){let r=s||new Array(e.length>>>1);for(let n=0;n<e.length;n+=2)r[n>>>1]=e[n];return r}toComplexArray(e,s){let r=s||this.createComplexArray();for(let n=0;n<r.length;n+=2)r[n]=e[n>>>1],r[n+1]=0;return r}transform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._transform4(e,s,1)}realTransform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._realTransform4(e,s,1)}inverseTransform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._transform4(e,s,-1);for(let r=0;r<e.length;++r)e[r]/=this.size}_transform4(e,s,r){let n=this._csize,a=1<<this._width,i=n/a<<1,l,c,u=this._bitrev;if(i===4)for(l=0,c=0;l<n;l+=i,++c){let d=u[c];this._singleTransform2(s,e,l,d,a)}else for(l=0,c=0;l<n;l+=i,++c){let d=u[c];this._singleTransform4(s,e,l,d,a,r)}let p=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let d=i>>>2;for(l=0;l<n;l+=i){let _=l+d-1;for(let m=l,h=0;m<_;m+=2,h+=a){let x=m,g=x+d,w=g+d,y=w+d,E=e[x],A=e[x+1],b=e[g],O=e[g+1],N=e[w],F=e[w+1],R=e[y],B=e[y+1],G=p[h],D=r*p[h+1],X=b*G-O*D,V=b*D+O*G,re=p[2*h],Y=r*p[2*h+1],k=N*re-F*Y,v=N*Y+F*re,I=p[3*h],Q=r*p[3*h+1],Z=R*I-B*Q,Ie=R*Q+B*I,Ee=E+k,ht=A+v,xt=E-k,Gt=A-v,lt=X+Z,Ye=V+Ie,gt=r*(X-Z),vt=r*(V-Ie);e[x]=Ee+lt,e[x+1]=ht+Ye,e[g]=xt+vt,e[g+1]=Gt-gt,e[w]=Ee-lt,e[w+1]=ht-Ye,e[y]=xt-vt,e[y+1]=Gt+gt}}}}_singleTransform2(e,s,r,n,o){let a=e[n],i=e[n+1],l=e[n+o],c=e[n+o+1];s[r]=a+l,s[r+1]=i+c,s[r+2]=a-l,s[r+3]=i-c}_singleTransform4(e,s,r,n,o,a){let i=o*2,l=o*3,c=e[n],u=e[n+1],p=e[n+o],d=e[n+o+1],_=e[n+i],m=e[n+i+1],h=e[n+l],x=e[n+l+1],g=c+_,w=u+m,y=c-_,E=u-m,A=p+h,b=d+x,O=a*(p-h),N=a*(d-x);s[r]=g+A,s[r+1]=w+b,s[r+2]=y+N,s[r+3]=E-O,s[r+4]=g-A,s[r+5]=w-b,s[r+6]=y-N,s[r+7]=E+O}_realTransform4(e,s,r){let n=this._csize,a=1<<this._width,i=n/a<<1,l,c,u=this._bitrev;if(i===4)for(l=0,c=0;l<n;l+=i,++c){let _=u[c];this._singleRealTransform2(s,e,l,_>>>1,a>>>1)}else for(l=0,c=0;l<n;l+=i,++c){let _=u[c];this._singleRealTransform4(s,e,l,_>>>1,a>>>1,r)}let p=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let _=i>>>1,m=_>>>1,h=m>>>1;for(l=0;l<n;l+=i)for(let x=0,g=0;x<=h;x+=2,g+=a){let w=l+x,y=w+m,E=y+m,A=E+m,b=e[w],O=e[w+1],N=e[y],F=e[y+1],R=e[E],B=e[E+1],G=e[A],D=e[A+1],X=b,V=O,re=p[g],Y=r*p[g+1],k=N*re-F*Y,v=N*Y+F*re,I=p[2*g],Q=r*p[2*g+1],Z=R*I-B*Q,Ie=R*Q+B*I,Ee=p[3*g],ht=r*p[3*g+1],xt=G*Ee-D*ht,Gt=G*ht+D*Ee,lt=X+Z,Ye=V+Ie,gt=X-Z,vt=V-Ie,Wt=k+xt,Et=v+Gt,Lo=r*(k-xt),$o=r*(v-Gt);if(e[w]=lt+Wt,e[w+1]=Ye+Et,e[y]=gt+$o,e[y+1]=vt-Lo,x===0){e[E]=lt-Wt,e[E+1]=Ye-Et;continue}if(x===h)continue;let Ro=l+m-x,ct=l+_-x;e[Ro]=gt-r*$o,e[Ro+1]=-vt-r*Lo,e[ct]=lt-r*Wt,e[ct+1]=-Ye+r*Et}}let d=n>>>1;for(let _=2;_<d;_+=2)e[n-_]=e[_],e[n-_+1]=-e[_+1]}_singleRealTransform2(e,s,r,n,o){let a=e[n],i=e[n+o];s[r]=a+i,s[r+1]=0,s[r+2]=a-i,s[r+3]=0}_singleRealTransform4(e,s,r,n,o,a){let i=o*2,l=o*3,c=e[n],u=e[n+o],p=e[n+i],d=e[n+l],_=c+p,m=c-p,h=u+d,x=a*(u-d);s[r]=_+h,s[r+1]=0,s[r+2]=m,s[r+3]=-x,s[r+4]=_-h,s[r+5]=0,s[r+6]=m,s[r+7]=x}},Ul=class{constructor(e){let s=2*(e-1),r=2*(2*e-1),n=2**Math.ceil(Math.log2(r));this.bufferSize=n,this._a=s;let o=new Float64Array(r),a=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);let i=-2*Math.PI/e,l=Math.cos(i),c=Math.sin(i);for(let u=0;u<r>>1;++u){let p=(u+1-e)**2/2,d=Math.sqrt(l**2+c**2)**p,_=p*Math.atan2(c,l),m=2*u;o[m]=d*Math.cos(_),o[m+1]=d*Math.sin(_),a[m]=o[m],a[m+1]=-o[m+1]}this._slicedChirpBuffer=o.subarray(s,r),this._f=new Vo(n>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,s,r){let n=this._buffer1,o=this._buffer2,a=this._outBuffer1,i=this._outBuffer2,l=this._chirpBuffer,c=this._slicedChirpBuffer,u=this._a;if(r)for(let p=0;p<c.length;p+=2){let d=p+1,_=p>>1,m=s[_];n[p]=m*c[p],n[d]=m*c[d]}else for(let p=0;p<c.length;p+=2){let d=p+1;n[p]=s[p]*c[p]-s[d]*c[d],n[d]=s[p]*c[d]+s[d]*c[p]}this._f.transform(a,n);for(let p=0;p<l.length;p+=2){let d=p+1;o[p]=a[p]*l[p]-a[d]*l[d],o[d]=a[p]*l[d]+a[d]*l[p]}this._f.inverseTransform(i,o);for(let p=0;p<i.length;p+=2){let d=i[p+u],_=i[p+u+1],m=c[p],h=c[p+1];e[p]=d*m-_*h,e[p+1]=d*h+_*m}}transform(e,s){this._transform(e,s,!1)}realTransform(e,s){this._transform(e,s,!0)}},Ho=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=mw(e),this.isPowerOfTwo?(this.fft=new Vo(e),this.outputBufferSize=2*e):(this.fft=new Ul(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,s){this.fft.realTransform(e,s)}transform(e,s){this.fft.transform(e,s)}};function hw(t,e){if(e%2===0||e<=0)throw new Error("Window size must be a positive odd number");let s=new t.constructor(t.length),r=new t.constructor(e),n=Math.floor(e/2);for(let o=0;o<t.length;++o){let a=0;for(let i=-n;i<=n;++i){let l=o+i;l<0?l=Math.abs(l):l>=t.length&&(l=2*(t.length-1)-l),r[a++]=t[l]}r.sort(),s[o]=r[n]}return s}function Kt(t,e){let s=Math.pow(10,e);return Math.round(t*s)/s}function xw(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function gw(t){let e=t.length,s=t[0].length,r=[e+1,s+1],n=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));n[0][0]=0;let o=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let u=1;u<r[1];++u)for(let p=1;p<r[0];++p){let d=n[p-1][u-1],_=n[p-1][u],m=n[p][u-1],h,x;d<_&&d<m?(h=d,x=0):_<d&&_<m?(h=_,x=1):(h=m,x=2),n[p][u]=t[p-1][u-1]+h,o[p][u]=x}for(let u=0;u<r[1];++u)o[0][u]=2;for(let u=0;u<r[0];++u)o[u][0]=1;let a=e,i=s,l=[],c=[];for(;a>0||i>0;)switch(l.push(a-1),c.push(i-1),o[a][i]){case 0:--a,--i;break;case 1:--a;break;case 2:--i;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${i}]. Please file a bug report.`)}return l.reverse(),c.reverse(),[l,c]}var ww=(function(){let t=null;return function(e){if(!t){t=new Float32Array(65536);let o=new ArrayBuffer(4),a=new Uint32Array(o),i=new Float32Array(o);for(let l=0;l<t.length;++l){let c=0,u=(l&32768)<<16,p=(l&31744)>>10,d=l&1023;if(p===31)c=u|2139095040|d<<13;else if(p===0)if(d===0)c=u;else{let _=113;for(;(d&1024)===0;)d<<=1,--_;d&=-1025,c=u|_<<23|d<<13}else c=u|p+112<<23|d<<13;a[0]=c,t[l]=i[0]}}let s=e.length,r=t,n=new Float32Array(s);for(let o=0;o<s;++o)n[o]=r[e[o]];return n}})();var Gl={};us(Gl,{Readable:()=>bk,createReadStream:()=>Ek,createWriteStream:()=>vk,default:()=>yk,pipeline:()=>kk});var Xo=()=>{},wk={},yk=wk,bk={fromWeb:Xo},kk=Xo,vk=Xo,Ek=Xo;import*as Ak from"onnxruntime-web/webgpu";async function yw(t){let e=t.split("/").pop(),s;try{if(s=await Wo(),s){let n=await s.match(t);if(n)return n}}catch(n){console.warn(`Failed to load ${e} from cache:`,n)}let r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);if(s)try{await s.put(t,r.clone())}catch(n){console.warn(`Failed to cache ${e}:`,n)}return r}async function bw(t){let e=await yw(t);if(!e||typeof e=="string")return null;try{return await e.arrayBuffer()}catch(s){return console.warn("Failed to read WASM binary:",s),null}}async function kw(t){let e=await yw(t);if(!e||typeof e=="string")return null;try{let s=await e.text(),r=t.split("/").slice(0,-1).join("/");s=s.replace(/import\.meta\.url/g,`"${r}"`);let n=new Blob([s],{type:"text/javascript"});return URL.createObjectURL(n)}catch(s){return console.warn("Failed to read WASM binary:",s),null}}function Wl(t){return ms(t,["blob:"])}function Vl(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof import.meta<"u"&&import.meta.url)e=import.meta.url;else return t;return new URL(t,e).href}import{Tensor as Iw}from"onnxruntime-common";var Mk=Object.freeze({auto:null,gpu:null,cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:{name:"webnn",deviceType:"cpu"},"webnn-npu":{name:"webnn",deviceType:"npu"},"webnn-gpu":{name:"webnn",deviceType:"gpu"},"webnn-cpu":{name:"webnn",deviceType:"cpu"}}),Sk=["verbose","info","warning","error","fatal"],Mw=4,He=[],Hl,gs,vw=Symbol.for("onnxruntime");if(vw in globalThis)gs=globalThis[vw];else if(ee.IS_NODE_ENV){switch(gs=Gl,process.platform){case"win32":He.push("dml");break;case"linux":process.arch==="x64"&&He.push("cuda");break;case"darwin":He.push("coreml");break}He.push("webgpu"),He.push("cpu"),Hl=["cpu"]}else gs=Ak,ee.IS_WEBNN_AVAILABLE&&He.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),ee.IS_WEBGPU_AVAILABLE&&He.push("webgpu"),He.push("wasm"),Hl=["wasm"];var Ok=gs.InferenceSession;function Sw(t=null){if(!t)return Hl;switch(t){case"auto":return He;case"gpu":return He.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(He.includes(t))return[Mk[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${He.join(", ")}.`)}var Ow=ee.IS_BROWSER_ENV||ee.IS_WEBWORKER_ENV,Ew=Promise.resolve(),xs=null;async function Ik(){return xs||(_e.useWasmCache&&typeof Ce?.wasm?.wasmPaths=="object"&&Ce?.wasm?.wasmPaths?.wasm&&Ce?.wasm?.wasmPaths?.mjs?(xs=(async()=>{let e=Ce.wasm.wasmPaths;await Promise.all([e.wasm&&!Wl(e.wasm)?(async()=>{try{let s=await bw(Vl(e.wasm));s&&(Ce.wasm.wasmBinary=s)}catch(s){console.warn("Failed to pre-load WASM binary:",s)}})():Promise.resolve(),e.mjs&&!Wl(e.mjs)?(async()=>{try{let s=await kw(Vl(e.mjs));s&&(Ce.wasm.wasmPaths.mjs=s)}catch(s){console.warn("Failed to pre-load WASM factory:",s)}})():Promise.resolve()])})(),xs):(xs=Promise.resolve(),xs))}async function Ko(t,e,s){await Ik();let r=()=>Ok.create(t,{logSeverityLevel:Mw,...e}),n=await(Ow?Ew=Ew.then(r):r());return n.config=s,n}var Aw=Promise.resolve();async function Qo(t,e){let s=()=>t.run(e);return await(Ow?Aw=Aw.then(s):s())}function Jo(t){return t instanceof gs.Tensor}var Ce=gs?.env;Ce.logLevel=Sk[Mw];if(Ce?.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&Ce.versions?.web&&!Ce.wasm.wasmPaths){let t=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${Ce.versions.web}/dist/`;Ce.wasm.wasmPaths=ee.IS_SAFARI?{mjs:`${t}ort-wasm-simd-threaded.mjs`,wasm:`${t}ort-wasm-simd-threaded.wasm`}:{mjs:`${t}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${t}ort-wasm-simd-threaded.asyncify.wasm`}}Ce.wasm.proxy=!1}Ce?.webgpu&&(Ce.webgpu.powerPreference="high-performance");function ur(){return Ce?.wasm?.proxy}_e.backends.onnx=Ce;var At=async(t,e,s)=>{let r=await Ko(new Uint8Array(t),e);return(async n=>{let o=ur(),a=Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(o?c.clone():c).ort_tensor])),i=await Qo(r,a);return Array.isArray(s)?s.map(l=>new S(i[l])):new S(i[s])})},pt=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=At([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,"y")),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||(this._bilinear_interpolate_4d=At([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||(this._bicubic_interpolate_4d=At([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||(this._matmul=At([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,"c")),this._matmul}static get stft(){return this._stft||(this._stft=At([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,"o")),this._stft}static get rfft(){return this._rfft||(this._rfft=At([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=At([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,["v","i"])),this._top_k}static get slice(){return this._slice||(this._slice=At([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,"y")),this._slice}};var zw=Object.freeze({auto:"auto",gpu:"gpu",cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:"webnn","webnn-npu":"webnn-npu","webnn-gpu":"webnn-gpu","webnn-cpu":"webnn-cpu"});var Tw=(function(){let t;return async function(){if(t===void 0)if(!ee.IS_WEBGPU_AVAILABLE)t=!1;else try{t=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{t=!1}return t}})(),Ne=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),Xl=Object.freeze({[zw.wasm]:Ne.q8}),Kl=Object.freeze({[Ne.fp32]:"",[Ne.fp16]:"_fp16",[Ne.int8]:"_int8",[Ne.uint8]:"_uint8",[Ne.q8]:"_quantized",[Ne.q4]:"_q4",[Ne.q4f16]:"_q4f16",[Ne.bnb4]:"_bnb4"}),ws=Object.freeze({float32:Float32Array,float16:typeof Float16Array<"u"?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array});var S=class t{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return Jo(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new Iw(e[0],e[1],e[2]),new Proxy(this,{get:(s,r)=>{if(typeof r=="string"){let n=Number(r);if(Number.isInteger(n))return s._getitem(n)}return s[r]},set:(s,r,n)=>s[r]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...s]=this.dims;if(s.length>0){let r=s.reduce((n,o)=>n*o);for(let n=0;n<e;++n)yield this._subarray(n,r,s)}else yield*this.data}_getitem(e){let[s,...r]=this.dims;if(e=dt(e,s),r.length>0){let n=r.reduce((o,a)=>o*a);return this._subarray(e,n,r)}else return new t(this.type,[this.data[e]],r)}indexOf(e){let s=this.data;for(let r=0;r<s.length;++r)if(s[r]==e)return r;return-1}_subarray(e,s,r){let n=e*s,o=(e+1)*s,a="subarray"in this.data?this.data.subarray(n,o):this.data.slice(n,o);return new t(this.type,a,r)}item(){let e=this.data;if(e.length!==1)throw new Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return zk(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=1/(1+Math.exp(-e[s]));return this}map(e){return this.clone().map_(e)}map_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]=e(s[r],r,s);return this}mul(e){return this.clone().mul_(e)}mul_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]-=e;return this}clone(){return new t(this.type,this.data.slice(),this.dims.slice())}slice(...e){let s=[],r=[];for(let u=0;u<this.dims.length;++u){let p=e[u];if(p==null)r.push([0,this.dims[u]]),s.push(this.dims[u]);else if(typeof p=="number")p=dt(p,this.dims[u],u),r.push([p,p+1]);else if(Array.isArray(p)&&p.length===2){let[d,_]=p;if(d=d===null?0:dt(d,this.dims[u],u,!1),_=_===null?this.dims[u]:dt(_,this.dims[u],u,!1),d>_)throw new Error(`Invalid slice: ${p}`);let m=[Math.max(d,0),Math.min(_,this.dims[u])];r.push(m),s.push(m[1]-m[0])}else throw new Error(`Invalid slice: ${p}`)}let n=r.map(([u,p])=>p-u),o=n.reduce((u,p)=>u*p),a=this.data,i=new a.constructor(o),l=this.stride(),c=!0;for(let u=1;u<n.length;++u)if(r[u][0]!==0||r[u][1]!==this.dims[u]){c=!1;break}if(c){let u=r[0][0]*l[0],p=r[0][1]*l[0];if(ArrayBuffer.isView(a))i.set(a.subarray(u,p));else if(Array.isArray(a)){let d=a.slice(u,p);for(let _=0;_<d.length;++_)i[_]=d[_]}else throw new Error("Unsupported data type for slicing")}else for(let u=0;u<o;++u){let p=0;for(let d=n.length-1,_=u;d>=0;--d){let m=n[d];p+=(_%m+r[d][0])*l[d],_=Math.floor(_/m)}i[u]=a[p]}return new t(this.type,i,s)}permute(...e){return Tk(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,s=!1){return this.norm(1,e,s)}norm(e="fro",s=null,r=!1){if(e==="fro")e=2;else if(typeof e=="string")throw Error(`Unsupported norm: ${e}`);let n=this.data,o=(c,u)=>c+u**e;if(s===null){let c=n.reduce(o,0)**(1/e);return new t(this.type,[c],[])}let[a,i,l]=pr(o,this,s,r);if(e!==1)for(let c=0;c<i.length;++c)i[c]=i[c]**(1/e);return new t(a,i,l)}normalize_(e=2,s=1){s=dt(s,this.dims.length);let r=this.norm(e,s,!0),n=this.data,o=r.data;for(let a=0;a<n.length;++a){let i=0;for(let l=this.dims.length-1,c=a,u=1;l>=0;--l){let p=this.dims[l];if(l!==s){let d=c%p;i+=d*u,u*=this.dims[l]}c=Math.floor(c/p)}n[a]/=o[i]}return this}normalize(e=2,s=1){return this.clone().normalize_(e,s)}stride(){return Ql(this.dims)}squeeze(e=null){return new t(this.type,this.data,Pw(this.dims,e))}squeeze_(e=null){return this.dims=Pw(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,Cw(this.dims,e))}unsqueeze_(e){return this.dims=Cw(this.dims,e),this}flatten_(e=0,s=-1){s=(s+this.dims.length)%this.dims.length;let r=this.dims.slice(0,e),n=this.dims.slice(e,s+1),o=this.dims.slice(s+1);return this.dims=[...r,n.reduce((a,i)=>a*i,1),...o],this}flatten(e=0,s=-1){return this.clone().flatten_(e,s)}view(...e){let s=-1;for(let n=0;n<e.length;++n)if(e[n]===-1){if(s!==-1)throw new Error("Only one dimension can be inferred");s=n}let r=this.data;if(s!==-1){let n=e.reduce((o,a,i)=>i!==s?o*a:o,1);e[s]=r.length/n}return new t(this.type,r,e)}neg_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=-e[s];return this}neg(){return this.clone().neg_()}gt(e){let s=new Uint8Array(this.data.length),r=this.data;for(let n=0;n<r.length;++n)s[n]=r[n]>e?1:0;return new t("bool",s,this.dims)}lt(e){let s=new Uint8Array(this.data.length),r=this.data;for(let n=0;n<r.length;++n)s[n]=r[n]<e?1:0;return new t("bool",s,this.dims)}clamp_(e,s){let r=this.data;for(let n=0;n<r.length;++n)r[n]=Math.min(Math.max(r[n],e),s);return this}clamp(e,s){return this.clone().clamp_(e,s)}round_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=Math.round(e[s]);return this}round(){return this.clone().round_()}mean(e=null,s=!1){return ea(this,e,s)}min(e=null,s=!1){if(e===null){let a=cr(this.data)[0];return new t(this.type,[a],[])}let[r,n,o]=pr((a,i)=>Math.min(a,i),this,e,s,1/0);return new t(r,n,o)}max(e=null,s=!1){if(e===null){let a=ae(this.data)[0];return new t(this.type,[a],[])}let[r,n,o]=pr((a,i)=>Math.max(a,i),this,e,s,-1/0);return new t(r,n,o)}argmin(e=null,s=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let r=cr(this.data)[1];return new t("int64",[BigInt(r)],[])}argmax(e=null,s=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let r=ae(this.data)[1];return new t("int64",[BigInt(r)],[])}repeat(...e){if(e.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${e.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(e.every(u=>u===1)){if(e.length===this.dims.length)return this.clone();let u=e.length-this.dims.length,p=Array(u).fill(1).concat(this.dims);return new t(this.type,this.data.slice(),p)}let s=e.length-this.dims.length,r=Array(s).fill(1).concat(this.dims),n=r.map((u,p)=>u*e[p]),o=n.reduce((u,p)=>u*p,1),a=this.data,i=new a.constructor(o),l=Ql(r),c=Ql(n);for(let u=0;u<o;++u){let p=u,d=0;for(let _=0;_<n.length;++_){let m=Math.floor(p/c[_]);p=p%c[_];let h=m%r[_];d+=h*l[_]}i[u]=a[d]}return new t(this.type,i,n)}tile(...e){if(e.length<this.dims.length){let s=this.dims.length-e.length;e=Array(s).fill(1).concat(e)}return this.repeat(...e)}to(e){if(this.type===e)return this;if(!ws.hasOwnProperty(e))throw new Error(`Unsupported type: ${e}`);let s,r=["int64","uint64"].includes(this.type),n=["int64","uint64"].includes(e);if(r&&!n)s=Number;else if(!r&&n)["float16","float32","float64"].includes(this.type)?s=o=>BigInt(Math.floor(o)):s=BigInt;else if(this.type==="float16"&&e=="float32"&&this.data instanceof Uint16Array)return new t(e,ww(this.data),this.dims);return new t(e,ws[e].from(this.data,s),this.dims)}};function zk(t,e){let s=t.length,r=e.reduce((o,a)=>o*a);if(s!==r)throw Error(`cannot reshape array of size ${s} into shape (${e})`);let n=t;for(let o=e.length-1;o>=0;o--)n=n.reduce((a,i)=>{let l=a[a.length-1];return l.length<e[o]?l.push(i):a.push([i]),a},[[]]);return n[0]}function Tk(t,e){let[s,r]=_w(t.data,t.dims,e);return new S(t.type,s,r)}function Jl(t,[e,s],r="bilinear",n=!1){let o=t.dims.at(-3)??1,a=t.dims.at(-2),i=t.dims.at(-1),l=dw(t.data,[o,a,i],[e,s],r,n);return new S(t.type,l,[o,e,s])}async function Xe(t,{size:e=null,mode:s="bilinear"}={}){if(t.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!e)throw new Error("`interpolate_4d` requires a `size` argument.");let r;if(e.length===2)r=[...t.dims.slice(0,2),...e];else if(e.length===3)r=[t.dims[0],...e];else if(e.length===4)r=e;else throw new Error("`size` must be of length 2, 3, or 4.");let n;if(s==="nearest")n=await pt.nearest_interpolate_4d;else if(s==="bilinear")n=await pt.bilinear_interpolate_4d;else if(s==="bicubic")n=await pt.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${s}`);let o=new S("int64",new BigInt64Array(r.map(BigInt)),[r.length]);return await n({x:t,s:o})}async function Nw(t,e){return await(await pt.matmul)({a:t,b:e})}async function SM(t,e){return await(await pt.rfft)({x:t,a:e})}async function ot(t,e){let s=await pt.top_k;return e==null?e=t.dims.at(-1):e=Math.min(e,t.dims.at(-1)),await s({x:t,k:new S("int64",[BigInt(e)],[1])})}var Yo=t=>new S("int64",t,[t.length]);async function Zo(t,e,s,r,n){return await(await pt.slice)({x:t,s:Yo(e),e:Yo(s),a:Yo(r),t:Yo(n??new Array(r.length).fill(1))})}function Lw(t,e){let s=t.data,r=e.data,n=[t.dims[0],t.dims[2]],o=new s.constructor(n[0]*n[1]),[a,i,l]=t.dims,c=0;for(let u=0;u<a;++u){let p=u*l*i;for(let d=0;d<l;++d){let _=0,m=0,h=u*i,x=p+d;for(let w=0;w<i;++w){let y=Number(r[h+w]);m+=y,_+=s[x+w*l]*y}let g=_/m;o[c++]=g}}return new S(t.type,o,n)}function OM(t,e,{eps:s=1e-5}={}){if(t.dims.length!==2)throw new Error("`layer_norm` currently only supports 2D input.");let[r,n]=t.dims;if(e.length!==1&&e[0]!==n)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[o,a]=Yl(t,1,0,!0),i=o.data,l=a.data,c=t.data,u=new c.constructor(c.length);for(let p=0;p<r;++p){let d=p*n;for(let _=0;_<n;++_){let m=d+_;u[m]=(c[m]-l[p])/(i[p]+s)}}return new S(t.type,u,t.dims)}function Pw(t,e){return t=t.slice(),e===null?t=t.filter(s=>s!==1):typeof e=="number"?t[e]===1&&t.splice(e,1):Array.isArray(e)&&(t=t.filter((s,r)=>s!==1||!e.includes(r))),t}function Cw(t,e){return e=dt(e,t.length+1),t=t.slice(),t.splice(e,0,1),t}function dt(t,e,s=null,r=!0){if(t<-e||t>=e){if(r)throw new Error(`IndexError: index ${t} is out of bounds for dimension${s===null?"":" "+s} with size ${e}`);return t<-e?0:e}return t<0&&(t=(t%e+e)%e),t}function ne(t,e=0){e=dt(e,t[0].dims.length);let s=t[0].dims.slice();s[e]=t.reduce((a,i)=>a+i.dims[e],0);let r=s.reduce((a,i)=>a*i,1),n=new t[0].data.constructor(r),o=t[0].type;if(e===0){let a=0;for(let i of t){let l=i.data;n.set(l,a),a+=l.length}}else{let a=0;for(let i=0;i<t.length;++i){let{data:l,dims:c}=t[i];for(let u=0;u<l.length;++u){let p=0;for(let d=c.length-1,_=u,m=1;d>=0;--d){let h=c[d],x=_%h;d===e&&(x+=a),p+=x*m,m*=s[d],_=Math.floor(_/h)}n[p]=l[u]}a+=c[e]}}return new S(o,n,s)}function Ke(t,e=0){return ne(t.map(s=>s.unsqueeze(e)),e)}function pr(t,e,s,r=!1,n=null){let o=e.data,a=e.dims;s=dt(s,a.length);let i=a.slice();i[s]=1;let l=new o.constructor(o.length/a[s]);n!==null&&l.fill(n);for(let c=0;c<o.length;++c){let u=0;for(let p=a.length-1,d=c,_=1;p>=0;--p){let m=a[p];if(p!==s){let h=d%m;u+=h*_,_*=i[p]}d=Math.floor(d/m)}l[u]=t(l[u],o[c],c,u)}return r||i.splice(s,1),[e.type,l,i]}function Yl(t,e=null,s=1,r=!1){let n=t.data,o=t.dims;if(e===null){let _=n.reduce((g,w)=>g+w,0)/n.length,m=Math.sqrt(n.reduce((g,w)=>g+(w-_)**2,0)/(n.length-s)),h=new S(t.type,[_],[]);return[new S(t.type,[m],[]),h]}e=dt(e,o.length);let a=ea(t,e,r),i=a.data,[l,c,u]=pr((d,_,m,h)=>d+(_-i[h])**2,t,e,r);for(let d=0;d<c.length;++d)c[d]=Math.sqrt(c[d]/(o[e]-s));return[new S(l,c,u),a]}function ea(t,e=null,s=!1){let r=t.dims,n=t.data;if(e===null){let l=n.reduce((c,u)=>c+u,0);return new S(t.type,[l/n.length],[])}e=dt(e,r.length);let[o,a,i]=pr((l,c)=>l+c,t,e,s);if(r[e]!==1)for(let l=0;l<a.length;++l)a[l]/=r[e];return new S(o,a,i)}function Ql(t){let e=new Array(t.length);for(let s=t.length-1,r=1;s>=0;--s)e[s]=r,r*=t[s];return e}function Zl(t,e,s,r){let n=t.reduce((o,a)=>o*a,1);return new S(s,new r(n).fill(e),t)}function xe(t,e){let s,r;if(typeof e=="number")s="float32",r=Float32Array;else if(typeof e=="bigint")s="int64",r=BigInt64Array;else if(typeof e=="boolean")s="bool",r=Uint8Array;else throw new Error(`Unsupported data type: ${typeof e}`);return Zl(t,e,s,r)}function dr(t,e){return xe(t.dims,e)}function Oe(t){return Zl(t,1n,"int64",BigInt64Array)}function ta(t){return Oe(t.dims)}function ec(t){return Zl(t,0n,"int64",BigInt64Array)}function tc(t){return ec(t.dims)}function IM(t){let e=t.reduce((s,r)=>s*r,1);return new S("float32",Float32Array.from({length:e},()=>Math.random()),t)}function $w(t){let e=t.reduce((r,n)=>r*n,1),s=new Float32Array(e);for(let r=0;r<e;r+=2){let n=1-Math.random(),o=Math.random(),a=Math.sqrt(-2*Math.log(n)),i=2*Math.PI*o;s[r]=a*Math.cos(i),r+1<e&&(s[r+1]=a*Math.sin(i))}return new S("float32",s,t)}function Rw(t,e){if(t.dims.length!==2)throw new Error("The tensor must have 2 dimensions");if(t.dims.at(-1)%8!==0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(e))throw new Error("The precision must be either 'binary' or 'ubinary'");let s=e==="binary",r=s?"int8":"uint8",n=s?Int8Array:Uint8Array,o=t.data,a=new n(o.length/8);for(let i=0;i<o.length;++i){let l=o[i]>0?1:0,c=Math.floor(i/8),u=i%8;a[c]|=l<<7-u,s&&u===0&&(a[c]-=128)}return new S(r,a,[t.dims[0],t.dims[1]/8])}async function sc(t,e){return await Promise.all([Se(t,"tokenizer.json",!0,e),Se(t,"tokenizer_config.json",!0,e)])}function rc(t){let e=t.dims;switch(e.length){case 1:return t.tolist();case 2:if(e[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return t.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${e.length}.`)}}var Pk=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function Ck(t,e,s,r){for(let n of Object.keys(t)){let o=e-t[n].length,a=s(n),i=new Array(o).fill(a);t[n]=r==="right"?Pe(t[n],i):Pe(i,t[n])}}function Nk(t,e){for(let s of Object.keys(t))t[s].length=e}function Qt(t,...e){for(let s of e){if(!Object.hasOwn(t,s))continue;let r=t[s];if(r)if(typeof r=="object"){if(r.__type==="AddedToken")return r.content;throw Error(`Unknown token: ${r}`)}else return r}return null}function Lk(t){let e=[];for(let s of t.get_added_tokens_decoder().values())s.special&&e.push(s);return e}var T=class extends ke{return_token_type_ids=!1;padding_side="right";constructor(e,s){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=s,this._tokenizer=new qg(e,s),this.config=s,this.padding_side=s.padding_side??this.padding_side,this.mask_token=Qt(s,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=Qt(s,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=Qt(s,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=Qt(s,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=Qt(s,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=Qt(s,"eos_token"),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=s.chat_template??null,Array.isArray(this.chat_template)){let n=Object.create(null);for(let{name:o,template:a}of this.chat_template){if(typeof o!="string"||typeof a!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');n[o]=a}this.chat_template=n}this._compiled_template_cache=new Map;let r=Lk(this._tokenizer);this.all_special_ids=r.map(n=>n.id),this.all_special_tokens=r.map(n=>n.content)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let i=await sc(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a});return new this(...i)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e=="string"?this._tokenizer.token_to_id(e):e.map(s=>this._tokenizer.token_to_id(s))}_call(e,{text_pair:s=null,add_special_tokens:r=!0,padding:n=!1,truncation:o=null,max_length:a=null,return_tensor:i=!0,return_token_type_ids:l=null}={}){let c=Array.isArray(e),u;if(c){if(e.length===0)throw Error("text array must be non-empty");if(s!==null){if(Array.isArray(s)){if(e.length!==s.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");u=e.map((d,_)=>this._encode_plus(d,{text_pair:s[_],add_special_tokens:r,return_token_type_ids:l}))}else u=e.map(d=>this._encode_plus(d,{add_special_tokens:r,return_token_type_ids:l}))}else{if(e==null)throw Error("text may not be null or undefined");if(Array.isArray(s))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");u=[this._encode_plus(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:l})]}if(a===null?a=this.model_max_length:o===null&&(n===!0?(console.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),a=this.model_max_length):n===!1&&(console.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),n===!0&&(a=Math.min(ae(u.map(d=>d.input_ids.length))[0],a??1/0)),a=Math.min(a,this.model_max_length??1/0),n||o)for(let d=0;d<u.length;++d)u[d].input_ids.length!==a&&(u[d].input_ids.length>a?o&&Nk(u[d],a):n&&Ck(u[d],a,_=>_==="input_ids"?this.pad_token_id:0,this.padding_side));let p={};if(i){if(!(n&&o)&&u.some(_=>{for(let m of Object.keys(_))if(_[m].length!==u[0][m]?.length)return!0;return!1}))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");let d=[u.length,u[0].input_ids.length];for(let _ of Object.keys(u[0]))p[_]=new S("int64",BigInt64Array.from(u.flatMap(m=>m[_]).map(BigInt)),d)}else{for(let d of Object.keys(u[0]))p[d]=u.map(_=>_[d]);if(!c)for(let d of Object.keys(p))p[d]=p[d][0]}return p}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:s=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){let{ids:o,attention_mask:a,token_type_ids:i}=this._tokenizer.encode(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:n??this.return_token_type_ids});return{input_ids:o,attention_mask:a,...i?{token_type_ids:i}:{}}}tokenize(e,{pair:s=null,add_special_tokens:r=!1}={}){return this._tokenizer.tokenize(e,{text_pair:s,add_special_tokens:r})}encode(e,{text_pair:s=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){return this._tokenizer.encode(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:n}).ids}batch_decode(e,s={}){return e instanceof S&&(e=e.tolist()),e.map(r=>this.decode(r,s))}decode(e,s={}){if(e instanceof S&&(e=rc(e)),!Array.isArray(e)||e.length===0||!sw(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,s)}decode_single(e,{skip_special_tokens:s=!1,clean_up_tokenization_spaces:r=null}){return this._tokenizer.decode(e,{skip_special_tokens:s,clean_up_tokenization_spaces:r})}get_chat_template({chat_template:e=null,tools:s=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){let r=this.chat_template;if(e!==null&&Object.hasOwn(r,e))e=r[e];else if(e===null)if(s!==null&&"tool_use"in r)e=r.tool_use;else if("default"in r)e=r.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(r).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,{tools:s=null,documents:r=null,chat_template:n=null,add_generation_prompt:o=!1,tokenize:a=!0,padding:i=!1,truncation:l=!1,max_length:c=null,return_tensor:u=!0,return_dict:p=!0,tokenizer_kwargs:d={},..._}={}){if(n=this.get_chat_template({chat_template:n,tools:s}),typeof n!="string")throw Error(`chat_template must be a string, but got ${typeof n}`);let m=this._compiled_template_cache.get(n);m===void 0&&(m=new tw(n),this._compiled_template_cache.set(n,m));let h=Object.create(null);for(let g of Pk){let w=Qt(this.config,g);w&&(h[g]=w)}let x=m.render({messages:e,add_generation_prompt:o,tools:s,documents:r,...h,..._});if(a){let g=this._call(x,{add_special_tokens:!1,padding:i,truncation:l,max_length:c,return_tensor:u,...d});return p?g:g.input_ids}return x}};function ys(t,e,s,r){if(!("language_codes"in t)||!Array.isArray(t.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in t)||!(t.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in t)||typeof t.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let n=r.src_lang,o=r.tgt_lang;if(!t.language_codes.includes(o))throw new Error(`Target language code "${o}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);if(n!==void 0){if(!t.language_codes.includes(n))throw new Error(`Source language code "${n}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);for(let a of t._tokenizer.post_processor.config.single)if("SpecialToken"in a&&t.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=t.lang_to_token(n);break}}return r.forced_bos_token_id=t._tokenizer.token_to_id(t.lang_to_token(o)),t._call(e,s)}var Xc={};us(Xc,{AlbertTokenizer:()=>nc,AutoTokenizer:()=>L,BartTokenizer:()=>oc,BertTokenizer:()=>ac,BlenderbotSmallTokenizer:()=>ic,BlenderbotTokenizer:()=>lc,BloomTokenizer:()=>cc,CLIPTokenizer:()=>pc,CamembertTokenizer:()=>uc,CodeGenTokenizer:()=>_c,CodeLlamaTokenizer:()=>dc,CohereTokenizer:()=>fc,ConvBertTokenizer:()=>mc,DebertaTokenizer:()=>xc,DebertaV2Tokenizer:()=>hc,DistilBertTokenizer:()=>gc,ElectraTokenizer:()=>wc,EsmTokenizer:()=>yc,FalconTokenizer:()=>bc,GPT2Tokenizer:()=>Ec,GPTNeoXTokenizer:()=>vc,GemmaTokenizer:()=>kc,HerbertTokenizer:()=>Ac,LlamaTokenizer:()=>Mc,M2M100Tokenizer:()=>Sc,MBart50Tokenizer:()=>Ic,MBartTokenizer:()=>_r,MPNetTokenizer:()=>Pc,MarianTokenizer:()=>Oc,MgpstrTokenizer:()=>zc,MobileBertTokenizer:()=>Tc,NllbTokenizer:()=>Cc,NougatTokenizer:()=>Nc,PreTrainedTokenizer:()=>T,Qwen2Tokenizer:()=>Lc,RoFormerTokenizer:()=>Rc,RobertaTokenizer:()=>$c,SiglipTokenizer:()=>Fc,SpeechT5Tokenizer:()=>Dc,SqueezeBertTokenizer:()=>jc,T5Tokenizer:()=>Bc,TokenizersBackend:()=>T,VitsTokenizer:()=>qc,Wav2Vec2CTCTokenizer:()=>Gc,WhisperTokenizer:()=>Wc,XLMRobertaTokenizer:()=>Vc,XLMTokenizer:()=>Hc});var nc=class extends T{return_token_type_ids=!0};var oc=class extends T{};var ac=class extends T{return_token_type_ids=!0};var ic=class extends T{};var lc=class extends T{};var cc=class extends T{};var uc=class extends T{};var pc=class extends T{};var dc=class extends T{};var _c=class extends T{};var fc=class extends T{};var mc=class extends T{return_token_type_ids=!0};var hc=class extends T{return_token_type_ids=!0};var xc=class extends T{return_token_type_ids=!0};var gc=class extends T{};var wc=class extends T{return_token_type_ids=!0};var yc=class extends T{};var bc=class extends T{};var kc=class extends T{};var vc=class extends T{};var Ec=class extends T{};var Ac=class extends T{return_token_type_ids=!0};var Mc=class extends T{padding_side="left"};var Sc=class extends T{constructor(e,s){super(e,s),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r.slice(2,-2)),this.lang_to_token=r=>`__${r}__`}_build_translation_inputs(e,s,r){return ys(this,e,s,r)}};var Oc=class extends T{constructor(e,s){super(e,s),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(r=>this.languageRegex.test(r)),console.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[s,...r]=e.trim().split(this.languageRegex);if(r.length===0)return super._encode_text(s);if(r.length===2){let[n,o]=r;return this.supported_language_codes.includes(n)||console.warn(`Unsupported language code "${n}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),Pe([n],super._encode_text(o))}}};var _r=class extends T{constructor(e,s){super(e,s),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r),this.lang_to_token=r=>r}_build_translation_inputs(e,s,r){return ys(this,e,s,r)}};var Ic=class extends _r{};var zc=class extends T{};var Tc=class extends T{return_token_type_ids=!0};var Pc=class extends T{};var Cc=class extends T{constructor(e,s){super(e,s),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)),this.lang_to_token=r=>r}_build_translation_inputs(e,s,r){return ys(this,e,s,r)}};var Nc=class extends T{};var Lc=class extends T{};var $c=class extends T{};var Rc=class extends T{return_token_type_ids=!0};var Fc=class extends T{};var Dc=class extends T{};var jc=class extends T{return_token_type_ids=!0};var Bc=class extends T{};var Uc=class extends We{decode_chain(e){let s="";for(let r=1;r<e.length;r+=2)s+=e[r];return[s]}},qc=class extends T{constructor(e,s){super(e,s),this._tokenizer.decoder=new Uc({type:"VitsDecoder"})}};var Gc=class extends T{};var Fw=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],fr=new Map(Fw),$k=new Map([...Fw.map(([t,e])=>[e,t]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function Dw(t){t=t.toLowerCase();let e=$k.get(t);if(e===void 0){let s=t.match(/^<\|([a-z]{2})\|>$/);if(s&&(t=s[1]),fr.has(t))e=t;else{let n=t.length===2?fr.keys():fr.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var Rk="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",jw=new RegExp(`^[${Rk}]+$`,"gu"),Wc=class extends T{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:s=!1,return_language:r=!1,time_precision:n=null,force_full_sequences:o=!0}={}){if(n===null)throw Error("Must specify time_precision");let a=null,i=s==="word";function l(){return{language:a,timestamp:[null,null],text:""}}let c=[],u=l(),p=0,d=this.timestamp_begin,m=d+1500,h=[],x=[],g=!1,w=null,y=new Set(this.all_special_ids);for(let b of e){let O=b.tokens,N=i?b.token_timestamps:null,F=null,R=d;if("stride"in b){let[D,X,V]=b.stride;if(p-=X,w=D-V,X&&(R=X/n+d),V)for(let re=O.length-1;re>=0;--re){let Y=Number(O[re]);if(Y>=d){if(F!==null&&(Y-d)*n<w)break;F=Y}}}let B=[],G=[];for(let D=0;D<O.length;++D){let X=Number(O[D]);if(y.has(X)){let V=this.decode([X]),re=fr.get(V.slice(2,-2));if(re!==void 0){if(a!==null&&re!==a&&!s){h.push(B);let Y=this.findLongestCommonSequence(h)[0],k=this.decode(Y);u.text=k,c.push(u),h=[],B=[],u=l()}a=u.language=re}}else if(X>=d&&X<=m){let V=(X-d)*n+p,re=Kt(V,2);if(F!==null&&X>=F)g=!0;else if(g||h.length>0&&X<R)g=!1;else if(u.timestamp[0]===null)u.timestamp[0]=re;else if(re!==u.timestamp[0]){u.timestamp[1]=re,h.push(B),i&&x.push(G);let[Y,k]=this.findLongestCommonSequence(h,x),v=this.decode(Y);u.text=v,i&&(u.words=this.collateWordTimestamps(Y,k,a)),c.push(u),h=[],B=[],x=[],G=[],u=l()}}else if(B.push(X),i){let V=Kt(N[D]+p,2),re;if(D+1<N.length){re=Kt(N[D+1]+p,2);let Y=this.decode([X]);jw.test(Y)&&(re=Kt(Math.min(V+n,re),2))}else re=null;G.push([V,re])}}if("stride"in b){let[D,X,V]=b.stride;p+=D-V}B.length>0?(h.push(B),i&&x.push(G)):h.every(D=>D.length===0)&&(u=l(),h=[],B=[],x=[],G=[])}if(h.length>0){if(o&&s)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");let[b,O]=this.findLongestCommonSequence(h,x),N=this.decode(b);u.text=N,i&&(u.words=this.collateWordTimestamps(b,O,a)),c.push(u)}let E=Object.create(null),A=c.map(b=>b.text).join("");if(s||r){for(let b=0;b<c.length;++b){let O=c[b];s||delete O.timestamp,r||delete O.language}if(i){let b=[];for(let O of c)for(let N of O.words)b.push(N);E={chunks:b}}else E={chunks:c}}return[A,E]}findLongestCommonSequence(e,s=null){let r=e[0],n=r.length,o=[],a=Array.isArray(s)&&s.length>0,i=a?[]:null,l=a?s[0]:null;for(let c=1;c<e.length;++c){let u=e[c],p=0,d=[n,n,0,0],_=u.length;for(let E=1;E<n+_;++E){let A=Math.max(0,n-E),b=Math.min(n,n+_-E),O=r.slice(A,b),N=Math.max(0,E-n),F=Math.min(_,E),R=u.slice(N,F);if(O.length!==R.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let B;a?B=O.filter((X,V)=>X===R[V]&&l[A+V]<=s[c][N+V]).length:B=O.filter((X,V)=>X===R[V]).length;let G=E/1e4,D=B/E+G;B>1&&D>p&&(p=D,d=[A,b,N,F])}let[m,h,x,g]=d,w=Math.floor((h+m)/2),y=Math.floor((g+x)/2);o.push(...r.slice(0,w)),r=u.slice(y),n=r.length,a&&(i.push(...l.slice(0,w)),l=s[c].slice(y))}return o.push(...r),a?(i.push(...l),[o,i]):[o,[]]}collateWordTimestamps(e,s,r){let[n,o,a]=this.combineTokensIntoWords(e,r),i=[];for(let l=0;l<n.length;++l){let c=a[l];i.push({text:n[l],timestamp:[s[c.at(0)][0],s[c.at(-1)][1]]})}return i}combineTokensIntoWords(e,s,r=`"'\u201C\xA1\xBF([{-`,n=`"'.\u3002,\uFF0C!\uFF01?\uFF1F:\uFF1A\u201D)]}\u3001`){s=s??"english";let o,a,i;return["chinese","japanese","thai","lao","myanmar"].includes(s)?[o,a,i]=this.splitTokensOnUnicode(e):[o,a,i]=this.splitTokensOnSpaces(e),this.mergePunctuations(o,a,i,r,n)}decode(e,s){let r;return s?.decode_with_timestamps?(e instanceof S&&(e=rc(e)),r=this.decodeWithTimestamps(e,s)):r=super.decode(e,s),r}decodeWithTimestamps(e,s){let r=s?.time_precision??.02,n=this.all_special_ids.at(-1)+1,o=[[]];for(let a of e)if(a=Number(a),a>=n){let i=((a-n)*r).toFixed(2);o.push(`<|${i}|>`),o.push([])}else o[o.length-1].push(a);return o=o.map(a=>typeof a=="string"?a:super.decode(a,s)),o.join("")}splitTokensOnUnicode(e){let s=this.decode(e,{decode_with_timestamps:!0}),r="\uFFFD",n=[],o=[],a=[],i=[],l=[],c=0;for(let u=0;u<e.length;++u){let p=e[u];i.push(p),l.push(u);let d=this.decode(i,{decode_with_timestamps:!0});(!d.includes(r)||s[c+d.indexOf(r)]===r)&&(n.push(d),o.push(i),a.push(l),i=[],l=[],c+=d.length)}return[n,o,a]}splitTokensOnSpaces(e){let[s,r,n]=this.splitTokensOnUnicode(e),o=[],a=[],i=[];for(let l=0;l<s.length;++l){let c=s[l],u=r[l],p=n[l],d=u[0]>=this._tokenizer.token_to_id("<|endoftext|>"),_=c.startsWith(" "),m=c.trim(),h=jw.test(m);if(d||_||h||o.length===0)o.push(c),a.push(u),i.push(p);else{let x=o.length-1;o[x]+=c,a[x].push(...u),i[x].push(...p)}}return[o,a,i]}mergePunctuations(e,s,r,n,o){let a=structuredClone(e),i=structuredClone(s),l=structuredClone(r),c=a.length-2,u=a.length-1;for(;c>=0;)a[c].startsWith(" ")&&n.includes(a[c].trim())?(a[u]=a[c]+a[u],i[u]=Pe(i[c],i[u]),l[u]=Pe(l[c],l[u]),a[c]="",i[c]=[],l[c]=[]):u=c,--c;for(c=0,u=1;u<a.length;)!a[c].endsWith(" ")&&o.includes(a[u])?(a[c]+=a[u],i[c]=Pe(i[c],i[u]),l[c]=Pe(l[c],l[u]),a[u]="",i[u]=[],l[u]=[]):c=u,++u;return[a.filter(p=>p),i.filter(p=>p.length>0),l.filter(p=>p.length>0)]}};var Vc=class extends T{};var Hc=class extends T{return_token_type_ids=!0;constructor(e,s){super(e,s),console.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}};var L=class{static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let[i,l]=await sc(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",u=Xc[c];return u||(console.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),u=T),new u(i,l)}};var bs="https://github.com/huggingface/transformers.js/issues/new/choose";var mr="preprocessor_config.json",ks=mr,Bw="processor_config.json",Uw="chat_template.jinja";var j=class extends ke{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,s,r){super(),this.config=e,this.components=s,this.chat_template=r}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,s={}){if(!this.tokenizer)throw new Error("Unable to apply chat template without a tokenizer.");return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...s})}batch_decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.decode(...e)}async _call(e,...s){for(let r of[this.image_processor,this.feature_extractor,this.tokenizer])if(r)return r(e,...s);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,s={}){let[r,n,o]=await Promise.all([this.uses_processor_config?Se(e,Bw,!0,s):{},Promise.all(this.classes.filter(a=>a in this).map(async a=>{let i=await this[a].from_pretrained(e,s);return[a.replace(/_class$/,""),i]})).then(Object.fromEntries),this.uses_chat_template_file?Bl(e,Uw,!0,s):null]);return new this(r,n,o)}};var Ma={};us(Ma,{ChatterboxProcessor:()=>cu,Florence2Processor:()=>Zu,Gemma3nProcessor:()=>ep,GroundingDinoProcessor:()=>tp,Idefics3Processor:()=>va,JinaCLIPProcessor:()=>rp,LlavaProcessor:()=>np,MgpstrProcessor:()=>op,MoonshineProcessor:()=>ap,OwlViTProcessor:()=>ip,PaliGemmaProcessor:()=>lp,Phi3VProcessor:()=>cp,PixtralProcessor:()=>up,Processor:()=>j,PyAnnoteProcessor:()=>pp,Qwen2VLProcessor:()=>dp,Sam2Processor:()=>Ea,Sam2VideoProcessor:()=>_p,SamProcessor:()=>kr,SmolVLMProcessor:()=>va,SpeechT5Processor:()=>fp,UltravoxProcessor:()=>mp,VLChatProcessor:()=>sp,VoxtralProcessor:()=>hp,Wav2Vec2Processor:()=>xp,Wav2Vec2ProcessorWithLM:()=>gp,WhisperProcessor:()=>wp});var pe=class extends ke{constructor(e){super(),this.config=e}static async from_pretrained(e,s={}){let r=await Se(e,mr,!0,s);return new this(r)}};function ge(t,e){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error(`${e} expects input to be a Float32Array or a Float64Array, but got ${t?.constructor?.name??typeof t} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var yr={};us(yr,{ASTFeatureExtractor:()=>Jc,ChatterboxFeatureExtractor:()=>Yc,ClapFeatureExtractor:()=>Zc,DacFeatureExtractor:()=>gr,EncodecFeatureExtractor:()=>xr,FeatureExtractor:()=>pe,Gemma3nAudioFeatureExtractor:()=>eu,MoonshineFeatureExtractor:()=>tu,ParakeetFeatureExtractor:()=>su,PyAnnoteFeatureExtractor:()=>wr,SeamlessM4TFeatureExtractor:()=>ru,SnacFeatureExtractor:()=>nu,SpeechT5FeatureExtractor:()=>ou,Wav2Vec2FeatureExtractor:()=>au,WeSpeakerFeatureExtractor:()=>iu,WhisperFeatureExtractor:()=>lu});var Fk=()=>{};var qw={fromWeb:Fk};var Dk=()=>{};var Gw=Dk;async function sa(t,e){if(ee.IS_BROWSER_ENV){if(ee.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");let s=URL.createObjectURL(e),r=document.createElement("a");r.href=s,r.download=t,r.click(),r.remove(),URL.revokeObjectURL(s)}else if(ee.IS_FS_AVAILABLE){let s=e.stream(),r=qw.fromWeb(s),n=De.createWriteStream(t);await Gw(r,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function Qc(t,e){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let s=await(await hs(t)).arrayBuffer(),r=new AudioContext({sampleRate:e});typeof e>"u"&&console.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let n=await r.decodeAudioData(s),o;if(n.numberOfChannels===2){let a=Math.sqrt(2),i=n.getChannelData(0),l=n.getChannelData(1);o=new Float32Array(i.length);for(let c=0;c<n.length;++c)o[c]=a*(i[c]+l[c])/2}else o=n.getChannelData(0);return o}function Hw(t,e){if(t<1)return new Float64Array;if(t===1)return new Float64Array([1]);let s=1-e,r=2*Math.PI/(t-1),n=new Float64Array(t);for(let o=0;o<t;++o)n[o]=e-s*Math.cos(o*r);return n}function Ww(t){return Hw(t,.5)}function jk(t){return Hw(t,.54)}var Bk={htk:t=>2595*Math.log10(1+t/700),kaldi:t=>1127*Math.log(1+t/700),slaney:(t,e=1e3,s=15,r=27/Math.log(6.4))=>t>=e?s+Math.log(t/e)*r:3*t/200};function Kc(t,e="htk"){let s=Bk[e];if(!s)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?s(t):t.map(r=>s(r))}var Uk={htk:t=>700*(10**(t/2595)-1),kaldi:t=>700*(Math.exp(t/1127)-1),slaney:(t,e=1e3,s=15,r=Math.log(6.4)/27)=>t>=s?e*Math.exp(r*(t-s)):200*t/3};function qk(t,e="htk"){let s=Uk[e];if(!s)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?s(t):t.map(r=>s(r))}function Gk(t,e){let s=Float64Array.from({length:e.length-1},(a,i)=>e[i+1]-e[i]),r=Array.from({length:t.length},()=>new Array(e.length));for(let a=0;a<t.length;++a){let i=r[a];for(let l=0;l<e.length;++l)i[l]=e[l]-t[a]}let n=e.length-2,o=Array.from({length:n},()=>new Array(t.length));for(let a=0;a<t.length;++a){let i=r[a];for(let l=0;l<n;++l){let c=-i[l]/s[l],u=i[l+2]/s[l+1];o[l][a]=Math.max(0,Math.min(c,u))}}return o}function Vw(t,e,s){let r=(e-t)/(s-1);return Float64Array.from({length:s},(n,o)=>t+r*o)}function Re(t,e,s,r,n,o=null,a="htk",i=!1){if(o!==null&&o!=="slaney")throw new Error('norm must be one of null or "slaney"');if(t<2)throw new Error(`Require num_frequency_bins: ${t} >= 2`);if(s>r)throw new Error(`Require min_frequency: ${s} <= max_frequency: ${r}`);let l=Kc(s,a),c=Kc(r,a),u=Vw(l,c,e+2),p=qk(u,a),d;if(i){let m=n/((t-1)*2);d=Kc(Float64Array.from({length:t},(h,x)=>x*m),a),p=u}else d=Vw(0,Math.floor(n/2),t);let _=Gk(d,p);if(o!==null&&o==="slaney")for(let m=0;m<e;++m){let h=_[m],x=2/(p[m+2]-p[m]);for(let g=0;g<t;++g)h[g]*=x}return _}function Wk(t,e,s){let r=new t.constructor(t.length+e+s),n=t.length-1;for(let o=0;o<t.length;++o)r[e+o]=t[o];for(let o=1;o<=e;++o)r[e-o]=t[_s(o,n)];for(let o=1;o<=s;++o)r[n+e+o]=t[_s(n-o,n)];return r}function Xw(t,e,s,r,n){if(s<=0)throw new Error("reference must be greater than zero");if(r<=0)throw new Error("min_value must be greater than zero");s=Math.max(r,s);let o=Math.log10(s);for(let a=0;a<t.length;++a)t[a]=e*Math.log10(Math.max(r,t[a])-o);if(n!==null){if(n<=0)throw new Error("db_range must be greater than zero");let a=ae(t)[0]-n;for(let i=0;i<t.length;++i)t[i]=Math.max(t[i],a)}return t}function Vk(t,e=1,s=1e-5,r=null){return Xw(t,20,e,s,r)}function Hk(t,e=1,s=1e-10,r=null){return Xw(t,10,e,s,r)}async function je(t,e,s,r,{fft_length:n=null,power:o=1,center:a=!0,pad_mode:i="reflect",onesided:l=!0,preemphasis:c=null,preemphasis_htk_flavor:u=!0,mel_filters:p=null,mel_floor:d=1e-10,log_mel:_=null,reference:m=1,min_value:h=1e-10,db_range:x=null,remove_dc_offset:g=null,min_num_frames:w=null,max_num_frames:y=null,do_pad:E=!0,transpose:A=!1,mel_offset:b=0}={}){let O=e.length;if(n===null&&(n=s),s>n)throw Error(`frame_length (${s}) may not be larger than fft_length (${n})`);if(O!==s)throw new Error(`Length of the window (${O}) must equal frame_length (${s})`);if(r<=0)throw new Error("hop_length must be greater than zero");if(o===null&&p!==null)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!u)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(a)switch(i){case"reflect":{let v=Math.floor((n-1)/2)+1;t=Wk(t,v,v);break}case"constant":{let v=Math.floor(n/2),I=new t.constructor(t.length+2*v);I.set(t,v),t=I;break}default:throw new Error(`pad_mode="${i}" not implemented yet.`)}let N=Math.floor(1+Math.floor((t.length-s)/r));w!==null&&N<w&&(N=w);let F=l?Math.floor(n/2)+1:n,R=N,B=N;y!==null&&(y>N?E&&(B=y):B=R=y);let G=new Ho(n),D=new Float64Array(n),X=new Float64Array(G.outputBufferSize),V=new Float32Array(F*B);for(let v=0;v<R;++v){let I=v*r,Q=Math.min(t.length-I,s);Q!==s&&D.fill(0,0,s);for(let Z=0;Z<Q;++Z)D[Z]=t[I+Z];if(g){let Z=0;for(let Ee=0;Ee<Q;++Ee)Z+=D[Ee];let Ie=Z/Q;for(let Ee=0;Ee<Q;++Ee)D[Ee]-=Ie}if(c!==null){for(let Z=Q-1;Z>=1;--Z)D[Z]-=c*D[Z-1];D[0]*=1-c}for(let Z=0;Z<e.length;++Z)D[Z]*=e[Z];G.realTransform(X,D);for(let Z=0;Z<F;++Z){let Ie=Z<<1;V[Z*B+v]=X[Ie]**2+X[Ie+1]**2}}if(o!==null&&o!==2){let v=o/2;for(let I=0;I<V.length;++I)V[I]**=v}let re=p.length,Y=await Nw(new S("float32",p.flat(),[re,F]),new S("float32",V,[F,B]));A&&(Y=Y.transpose(1,0));let k=Y.data;for(let v=0;v<k.length;++v)k[v]=b+Math.max(d,k[v]);if(o!==null&&_!==null){let v=Math.min(k.length,R*re);switch(_){case"log":for(let I=0;I<v;++I)k[I]=Math.log(k[I]);break;case"log10":for(let I=0;I<v;++I)k[I]=Math.log10(k[I]);break;case"dB":if(o===1)Vk(k,m,h,x);else if(o===2)Hk(k,m,h,x);else throw new Error(`Cannot use log_mel option '${_}' with power ${o}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10' or 'dB'. Got '${_}'`)}}return Y}function Be(t,e,{periodic:s=!0,frame_length:r=null,center:n=!0}={}){let o=s?t+1:t,a;switch(e){case"boxcar":a=new Float64Array(o).fill(1);break;case"hann":case"hann_window":a=Ww(o);break;case"hamming":a=jk(o);break;case"povey":a=Ww(o).map(i=>Math.pow(i,.85));break;default:throw new Error(`Unknown window type ${e}.`)}if(s&&(a=a.subarray(0,t)),r===null)return a;if(t>r)throw new Error(`Length of the window (${t}) may not be larger than frame_length (${r})`);return a}function Xk(t,e){let s=t.reduce((o,a)=>o+a.length,0),r=new ArrayBuffer(44),n=new DataView(r);return ra(n,0,"RIFF"),n.setUint32(4,36+s*4,!0),ra(n,8,"WAVE"),ra(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,3,!0),n.setUint16(22,1,!0),n.setUint32(24,e,!0),n.setUint32(28,e*4,!0),n.setUint16(32,4,!0),n.setUint16(34,32,!0),ra(n,36,"data"),n.setUint32(40,s*4,!0),new Blob([r,...t.map(o=>o.buffer)],{type:"audio/wav"})}function ra(t,e,s){for(let r=0;r<s.length;++r)t.setUint8(e+r,s.charCodeAt(r))}var hr=class{constructor(e,s){this.audio=e,this.sampling_rate=s}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array(0);if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((n,o)=>n+o.length,0),s=new Float32Array(e),r=0;for(let n of this.audio)s.set(n,r),r+=n.length;return s}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),Xk(e,this.sampling_rate)}async save(e){return sa(e,this.toBlob())}};var Jc=class extends pe{constructor(e){super(e);let s=this.config.sampling_rate,r=Re(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Be(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,s){return je(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:s,transpose:!0})}async _call(e){ge(e,"ASTFeatureExtractor");let s=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let r=this.std*2,n=s.data;for(let o=0;o<n.length;++o)n[o]=(n[o]-this.mean)/r}return{input_values:s.unsqueeze_(0)}}};var xr=class extends pe{async _call(e){ge(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=this.config.feature_size;if(e.length%s!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${s}).`);let r=[1,s,e.length/s];return{input_values:new S("float32",e,r)}}};var Yc=class extends pe{async _call(e){ge(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,e.length];return{input_values:new S("float32",e,s)}}};var Zc=class extends pe{constructor(e){super(e),this.mel_filters=Re(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,null,"htk"),this.mel_filters_slaney=Re(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,"slaney","slaney"),this.window=Be(this.config.fft_window_size,"hann")}async _get_input_mel(e,s,r,n){let o,a=!1,i=e.length-s;if(i>0)if(r==="rand_trunc"){a=!0;let l=Math.floor(Math.random()*(i+1));e=e.subarray(l,l+s),o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${r}" not implemented`);else{if(i<0){let l=new Float64Array(s);if(l.set(e),n==="repeat")for(let c=e.length;c<s;c+=e.length)l.set(e.subarray(0,Math.min(e.length,s-c)),c);else if(n==="repeatpad")for(let c=e.length;c<-i;c+=e.length)l.set(e,c);e=l}if(r==="fusion")throw new Error(`Truncation strategy "${r}" not implemented`);o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return o.unsqueeze_(0)}async _extract_fbank_features(e,s,r=null){return je(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:s,log_mel:"dB",max_num_frames:r,do_pad:!1,transpose:!0})}async _call(e,{max_length:s=null}={}){return ge(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,s??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}};var gr=class extends xr{};var eu=class extends pe{constructor(e){super(e);let{fft_length:s,feature_size:r,min_frequency:n,max_frequency:o,sampling_rate:a,frame_length:i}=this.config,l=Re(Math.floor(1+s/2),r,n,o,a,null,"htk",!1);this.mel_filters=l,this.window=Be(i,"hann")}async _extract_fbank_features(e,s){return je(e,this.window,this.config.frame_length,this.config.hop_length,{fft_length:this.config.fft_length,center:!1,onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:"log",mel_floor:this.config.mel_floor,remove_dc_offset:!1,transpose:!0})}async _call(e,{max_length:s=48e4,truncation:r=!0,padding:n=!0,pad_to_multiple_of:o=128}={}){if(ge(e,"Gemma3nAudioFeatureExtractor"),r&&e.length>s&&(e=e.slice(0,s)),n&&e.length%o!==0){let l=o-e.length%o,c=new Float64Array(e.length+l);c.set(e),this.config.padding_value!==0&&c.fill(this.config.padding_value,e.length),e=c}let a=await this._extract_fbank_features(e,this.config.max_length),i=xe([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:i}}};var tu=class extends pe{async _call(e){ge(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,e.length];return{input_values:new S("float32",e,s)}}};var Kk=1e-5,su=class extends pe{constructor(e){super(e),this.config.mel_filters??=Re(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");let s=Be(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);let r=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(s,r)}async _extract_fbank_features(e){let s=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=s*e[n-1];return await je(e,this.window,this.window.length,this.config.hop_length,{fft_length:this.config.n_fft,power:2,mel_filters:this.config.mel_filters,log_mel:"log",mel_floor:-1/0,pad_mode:"constant",center:!0,transpose:!0,mel_offset:2**-24})}async _call(e){ge(e,"ParakeetFeatureExtractor");let s=await this._extract_fbank_features(e),r=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),n=s.data;n.fill(0,r*s.dims[1]);let[o,a]=s.dims,i=new Float64Array(a),l=new Float64Array(a);for(let p=0;p<r;++p){let d=p*a;for(let _=0;_<a;++_){let m=n[d+_];i[_]+=m,l[_]+=m*m}}let c=r>1?r-1:1;for(let p=0;p<a;++p){let d=i[p]/r,_=(l[p]-r*d*d)/c,h=1/(Math.sqrt(_)+Kk);for(let x=0;x<r;++x){let g=x*a+p;n[g]=(n[g]-d)*h}}let u=new BigInt64Array(o);return u.fill(1n,0,r),{input_features:s.unsqueeze_(0),attention_mask:new S("int64",u,[1,o])}}};var wr=class extends pe{async _call(e){ge(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,1,e.length];return{input_values:new S("float32",e,s)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,s){let r=s/this.samples_to_frames(s)/this.config.sampling_rate,n=[];for(let o of e.tolist()){let a=[],i=-1;for(let l=0;l<o.length;++l){let c=ce(o[l]),[u,p]=ae(c),[d,_]=[l,l+1];p!==i?(i=p,a.push({id:p,start:d,end:_,score:u})):(a.at(-1).end=_,a.at(-1).score+=u)}n.push(a.map(({id:l,start:c,end:u,score:p})=>({id:l,start:c*r,end:u*r,confidence:p/(u-c)})))}return n}};var ru=class extends pe{constructor(e){super(e);let s=this.config.sampling_rate,r=Re(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Be(400,"povey",{periodic:!1})}async _extract_fbank_features(e,s){return e=e.map(r=>r*32768),je(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:s,transpose:!0})}async _call(e,{padding:s=!0,pad_to_multiple_of:r=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:o=!0}={}){ge(e,"SeamlessM4TFeatureExtractor");let a=await this._extract_fbank_features(e,this.config.max_length);if(n){let[m,h]=a.dims,x=a.data;for(let g=0;g<h;++g){let w=0;for(let b=0;b<m;++b)w+=x[b*h+g];let y=w/m,E=0;for(let b=0;b<m;++b)E+=(x[b*h+g]-y)**2;E/=m-1;let A=Math.sqrt(E+1e-7);for(let b=0;b<m;++b){let O=b*h+g;x[O]=(x[O]-y)/A}}}let i;if(s){let[m,h]=a.dims,x=a.data,g=m%r;if(g>0){let w=new Float32Array(h*(m+g));w.set(x),w.fill(this.config.padding_value,x.length);let y=m+g;a=new S(a.type,w,[y,h]),o&&(i=new S("int64",new BigInt64Array(y),[1,y]),i.data.fill(1n,0,m))}}let[l,c]=a.dims,u=this.config.stride;if(l%u!==0)throw new Error(`The number of frames (${l}) must be a multiple of the stride (${u}).`);let d=a.view(1,Math.floor(l/u),c*u),_={input_features:d};if(o){let m=d.dims[1],h=new BigInt64Array(m);if(i){let x=i.data;for(let g=1,w=0;g<l;g+=u,++w)h[w]=x[g]}else h.fill(1n);_.attention_mask=new S("int64",h,[1,m])}return _}};var nu=class extends gr{};var ou=class extends pe{};var au=class extends pe{_zero_mean_unit_var_norm(e){let r=e.reduce((o,a)=>o+a,0)/e.length,n=e.reduce((o,a)=>o+(a-r)**2,0)/e.length;return e.map(o=>(o-r)/Math.sqrt(n+1e-7))}async _call(e){ge(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=e;this.config.do_normalize&&(s=this._zero_mean_unit_var_norm(s));let r=[1,s.length];return{input_values:new S("float32",s,r),attention_mask:new S("int64",new BigInt64Array(s.length).fill(1n),r)}}};var iu=class extends pe{constructor(e){super(e);let s=this.config.sampling_rate,r=Re(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Be(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(s=>s*32768),je(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){ge(e,"WeSpeakerFeatureExtractor");let s=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let r=s.mean(1).data,n=s.data,[o,a,i]=s.dims;for(let l=0;l<o;++l){let c=l*a*i,u=l*i;for(let p=0;p<a;++p){let d=c+p*i;for(let _=0;_<i;++_)n[d+_]-=r[u+_]}}}return{input_features:s}}};var lu=class extends pe{constructor(e){super(e),this.config.mel_filters??=Re(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Be(this.config.n_fft,"hann")}async _extract_fbank_features(e){let s=await je(e,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10",max_num_frames:Math.min(Math.floor(e.length/this.config.hop_length),this.config.nb_max_frames)}),r=s.data,n=ae(r)[0];for(let o=0;o<r.length;++o)r[o]=(Math.max(r[o],n-8)+4)/4;return s}async _call(e,{max_length:s=null}={}){ge(e,"WhisperFeatureExtractor");let r,n=s??this.config.n_samples;return e.length>n?(e.length>this.config.n_samples&&console.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),r=e.slice(0,n)):(r=new Float32Array(n),r.set(e)),{input_features:(await this._extract_fbank_features(r)).unsqueeze_(0)}}};var ve=class{static async from_pretrained(e,s={}){let r=await Se(e,mr,!0,s),n=r.feature_extractor_type,o=yr[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${bs}.`);return new o(r)}};var cu=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e,s=null){let r=this.tokenizer(e),n=s?await this.feature_extractor(s):{};return{...r,...n}}};var Qk={},na=Qk;var Jt,Kw,Mt,at=ee.IS_BROWSER_ENV||ee.IS_WEBWORKER_ENV;if(at)Jt=(t,e)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this browser.");return new self.OffscreenCanvas(t,e)},Mt=self.createImageBitmap,Kw=self.ImageData;else if(na)Mt=async t=>{let s=(await t.metadata()).channels,{data:r,info:n}=await t.rotate().raw().toBuffer({resolveWithObject:!0}),o=new we(new Uint8ClampedArray(r),n.width,n.height,n.channels);return s!==void 0&&s!==n.channels&&o.convert(s),o};else throw new Error("Unable to load image processing library.");var Jk={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},Yk=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),we=class t{constructor(e,s,r,n){this.data=e,this.width=s,this.height=r,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof t)return e;if(typeof e=="string"||e instanceof URL)return await this.fromURL(e);if(e instanceof Blob)return await this.fromBlob(e);if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return this.fromCanvas(e);throw new Error(`Unsupported input type: ${typeof e}`)}static fromCanvas(e){if(!at)throw new Error("fromCanvas() is only supported in browser environments.");let r=e.getContext("2d").getImageData(0,0,e.width,e.height).data;return new t(r,e.width,e.height,4)}static async fromURL(e){let s=await hs(e);if(s.status!==200)throw new Error(`Unable to read image from "${e}" (${s.status} ${s.statusText})`);let r=await s.blob();return this.fromBlob(r)}static async fromBlob(e){if(at){let s=await Mt(e),r=Jt(s.width,s.height).getContext("2d");return r.drawImage(s,0,0),new this(r.getImageData(0,0,s.width,s.height).data,s.width,s.height,4)}else{let s=na(await e.arrayBuffer());return await Mt(s)}}static fromTensor(e,s="CHW"){if(e.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if(s==="CHW")e=e.transpose(1,2,0);else if(s!=="HWC")throw new Error(`Unsupported channel format: ${s}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new t(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw new Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let s=0,r=0;s<this.data.length;s+=this.channels){let n=this.data[s],o=this.data[s+1],a=this.data[s+2];e[r++]=Math.round(.2989*n+.587*o+.114*a)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,1)}rgb(){if(this.channels===3)return this;let e=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let s=0,r=0;s<this.data.length;++s)e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=this.data[s];break;case 4:for(let s=0,r=0;s<this.data.length;s+=4)e[r++]=this.data[s],e[r++]=this.data[s+1],e[r++]=this.data[s+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,3)}rgba(){if(this.channels===4)return this;let e=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let s=0,r=0;s<this.data.length;++s)e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=255;break;case 3:for(let s=0,r=0;s<this.data.length;s+=3)e[r++]=this.data[s],e[r++]=this.data[s+1],e[r++]=this.data[s+2],e[r++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,4)}putAlpha(e){if(e.width!==this.width||e.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${e.channels}`);let s=this.data,r=e.data,n=this.width*this.height;if(this.channels===3){let o=new Uint8ClampedArray(n*4);for(let a=0,i=0,l=0;a<n;++a)o[l++]=s[i++],o[l++]=s[i++],o[l++]=s[i++],o[l++]=r[a];return this._update(o,this.width,this.height,4)}else if(this.channels===4){for(let o=0;o<n;++o)s[4*o+3]=r[o];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(e,s,{resample:r=2}={}){if(this.width===e&&this.height===s)return this;let n=Jk[r]??r,o=Dl(e),a=Dl(s);if(o&&a)return this;if(o?e=s/this.height*this.width:a&&(s=e/this.width*this.height),at){let i=this.channels,l=this.toCanvas(),c=Jt(e,s).getContext("2d");return c.drawImage(l,0,0,e,s),new t(c.getImageData(0,0,e,s).data,e,s,4).convert(i)}else{let i=this.toSharp();switch(n){case"box":case"hamming":(n==="box"||n==="hamming")&&(console.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":i=i.affine([e/this.width,0,0,s/this.height],{interpolator:n});break;case"lanczos":i=i.resize({width:e,height:s,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await Mt(i)}}async pad([e,s,r,n]){if(e=Math.max(e,0),s=Math.max(s,0),r=Math.max(r,0),n=Math.max(n,0),e===0&&s===0&&r===0&&n===0)return this;if(at){let o=this.channels,a=this.toCanvas(),i=this.width+e+s,l=this.height+r+n,c=Jt(i,l).getContext("2d");return c.drawImage(a,0,0,this.width,this.height,e,r,this.width,this.height),new t(c.getImageData(0,0,i,l).data,i,l,4).convert(o)}else{let o=this.toSharp().extend({left:e,right:s,top:r,bottom:n});return await Mt(o)}}async crop([e,s,r,n]){if(e=Math.max(e,0),s=Math.max(s,0),r=Math.min(r,this.width-1),n=Math.min(n,this.height-1),e===0&&s===0&&r===this.width-1&&n===this.height-1)return this;let o=r-e+1,a=n-s+1;if(at){let i=this.channels,l=this.toCanvas(),c=Jt(o,a).getContext("2d");return c.drawImage(l,e,s,o,a,0,0,o,a),new t(c.getImageData(0,0,o,a).data,o,a,4).convert(i)}else{let i=this.toSharp().extract({left:e,top:s,width:o,height:a});return await Mt(i)}}async center_crop(e,s){if(this.width===e&&this.height===s)return this;let r=(this.width-e)/2,n=(this.height-s)/2;if(at){let o=this.channels,a=this.toCanvas(),i=Jt(e,s).getContext("2d"),l=0,c=0,u=0,p=0;return r>=0?l=r:u=-r,n>=0?c=n:p=-n,i.drawImage(a,l,c,e,s,u,p,e,s),new t(i.getImageData(0,0,e,s).data,e,s,4).convert(o)}else{let o=this.toSharp();if(r>=0&&n>=0)o=o.extract({left:Math.floor(r),top:Math.floor(n),width:e,height:s});else if(r<=0&&n<=0){let a=Math.floor(-n),i=Math.floor(-r);o=o.extend({top:a,left:i,right:e-this.width-i,bottom:s-this.height-a})}else{let a=[0,0],i=0;n<0?(a[0]=Math.floor(-n),a[1]=s-this.height-a[0]):i=Math.floor(n);let l=[0,0],c=0;r<0?(l[0]=Math.floor(-r),l[1]=e-this.width-l[0]):c=Math.floor(r),o=o.extend({top:a[0],bottom:a[1],left:l[0],right:l[1]}).extract({left:c,top:i,width:e,height:s})}return await Mt(o)}}async toBlob(e="image/png",s=1){if(!at)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:e,quality:s})}toTensor(e="CHW"){let s=new S("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!=="HWC")if(e==="CHW")s=s.permute(2,0,1);else throw new Error(`Unsupported channel format: ${e}`);return s}toCanvas(){if(!at)throw new Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),s=Jt(e.width,e.height),r=new Kw(e.data,e.width,e.height);return s.getContext("2d").putImageData(r,0,0),s}split(){let{data:e,width:s,height:r,channels:n}=this,o=e.constructor,a=e.length/n,i=Array.from({length:n},()=>new o(a));for(let l=0;l<a;++l){let c=n*l;for(let u=0;u<n;++u)i[u][l]=e[c+u]}return i.map(l=>new t(l,s,r,1))}_update(e,s,r,n=null){return this.data=e,this.width=s,this.height=r,n!==null&&(this.channels=n),this}clone(){return new t(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(at){if(ee.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");let s=e.split(".").pop().toLowerCase(),r=Yk.get(s)??"image/png",n=await this.toBlob(r);return sa(e,n)}else if(ee.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(at)throw new Error("toSharp() is only supported in server-side environments.");return na(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},Zk=we.read.bind(we);function Qw(t,e,s=0,r=null){let n=t/e,o=xw(n)*e;return r!==null&&o>r&&(o=Math.floor(n)*e),o<s&&(o=Math.ceil(n)*e),o}function uu([t,e],s){return[Math.max(Math.floor(t/s),1)*s,Math.max(Math.floor(e/s),1)*s]}function pu([t,e,s,r]){return[t-s/2,e-r/2,t+s/2,e+r/2]}function St(t,e=.5,s=null,r=!1){let n=t.logits,o=t.pred_boxes,[a,i,l]=n.dims;if(s!==null&&s.length!==a)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let u=0;u<a;++u){let p=s!==null?s[u]:null,d={boxes:[],classes:[],scores:[]},_=n[u],m=o[u];for(let h=0;h<i;++h){let x=_[h],g=[],w;if(r){w=x.sigmoid().data;for(let y=0;y<w.length;++y)w[y]>e&&g.push(y)}else{let y=ae(x.data)[1];if(y===l-1||(w=ce(x.data),w[y]<e))continue;g.push(y)}for(let y of g){let E=m[h].data;E=pu(E),p!==null&&(E=E.map((A,b)=>A*p[(b+1)%2])),d.boxes.push(E),d.classes.push(y),d.scores.push(w[y])}}c.push(d)}return c}function oa(t,e=null){let s=t.logits,r=s.dims[0];if(e!==null&&e.length!==r)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let n=[];for(let o=0;o<r;++o){let a=e!==null?e[o]:null,i=s[o];a!==null&&(i=Jl(i,a,"bilinear",!1));let[l,c]=a??i.dims.slice(-2),u=new S("int32",new Int32Array(l*c),[l,c]),p=i[0].data,d=u.data;for(let h=1;h<i.dims[0];++h){let x=i[h].data;for(let g=0;g<x.length;++g)x[g]>p[g]&&(p[g]=x[g],d[g]=h)}let _=new Array(i.dims[0]);for(let h=0;h<d.length;++h){let x=d[h];_[x]=x}let m=_.filter(h=>h!==void 0);n.push({segmentation:u,labels:m})}return n}function ev(t,e,s,r){let n=[],o=[],a=[];for(let i=0;i<t.dims[0];++i){let l=t[i],c=e[i],u=ae(l.data)[1];if(u===r)continue;let d=ce(l.data)[u];d>s&&(n.push(c),o.push(d),a.push(u))}return[n,o,a]}function tv(t,e,s,r=.5,n=.8){let o=[],a=0,i=0,l=e[s].data;for(let u=0;u<t.length;++u)t[u]===s&&(o.push(u),++a),l[u]>=r&&++i;let c=a>0&&i>0;return c&&(c=a/i>n),[c,o]}function sv(t,e,s,r,n,o=null,a=null){let[i,l]=a??t[0].dims,c=new S("int32",new Int32Array(i*l),[i,l]),u=[];if(a!==null)for(let h=0;h<t.length;++h)t[h]=Jl(t[h],a,"bilinear",!1);let p=new Int32Array(t[0].data.length),d=new Float32Array(t[0].data.length);for(let h=0;h<t.length;++h){let x=e[h],g=t[h].data;for(let w=0;w<g.length;++w)g[w]*=x,g[w]>d[w]&&(p[w]=h,d[w]=g[w])}let _=0,m=c.data;for(let h=0;h<s.length;++h){let x=s[h],[g,w]=tv(p,t,h,r,n);if(g){++_;for(let y of w)m[y]=_;u.push({id:_,label_id:x,score:e[h]})}}return[c,u]}function rv(t,e,s=28,r=3136,n=784*1280){if(t<s||e<s)throw new Error(`height:${t} or width:${e} must be larger than factor:${s}`);if(Math.max(t,e)/Math.min(t,e)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(t,e)/Math.min(t,e)}`);let o=Math.round(t/s)*s,a=Math.round(e/s)*s;if(o*a>n){let i=Math.sqrt(t*e/n);o=Math.floor(t/i/s)*s,a=Math.floor(e/i/s)*s}else if(o*a<r){let i=Math.sqrt(r/(t*e));o=Math.ceil(t*i/s)*s,a=Math.ceil(e*i/s)*s}return[o,a]}function aa(t,e=.5,s=.5,r=.8,n=null,o=null){n===null&&(console.warn("`label_ids_to_fuse` unset. No instance will be fused."),n=new Set);let a=t.class_queries_logits??t.logits,l=(t.masks_queries_logits??t.pred_masks).sigmoid(),[c,u,p]=a.dims;if(p-=1,o!==null&&o.length!==c)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let d=[];for(let _=0;_<c;++_){let m=o!==null?o[_]:null,h=a[_],x=l[_],[g,w,y]=ev(h,x,e,p);if(y.length===0){let[b,O]=m??x.dims.slice(-2),N=new S("int32",new Int32Array(b*O).fill(-1),[b,O]);d.push({segmentation:N,segments_info:[]});continue}let[E,A]=sv(g,w,y,s,r,n,m);d.push({segmentation:E,segments_info:A})}return d}function ia(t,e=.5,s=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var P=class extends ke{constructor(e){super(),this.image_mean=e.image_mean??e.mean,this.image_std=e.image_std??e.std,this.resample=e.resample??2,this.do_rescale=e.do_rescale??!0,this.rescale_factor=e.rescale_factor??1/255,this.do_normalize=e.do_normalize,this.do_thumbnail=e.do_thumbnail,this.size=e.size??e.image_size,this.do_resize=e.do_resize??this.size!==void 0,this.size_divisibility=e.size_divisibility??e.size_divisor,this.do_center_crop=e.do_center_crop,this.crop_size=e.crop_size,this.do_convert_rgb=e.do_convert_rgb??!0,this.do_crop_margin=e.do_crop_margin,this.pad_size=e.pad_size,this.do_pad=e.do_pad,this.min_pixels=e.min_pixels,this.max_pixels=e.max_pixels,this.do_pad&&!this.pad_size&&this.size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size),this.do_flip_channel_order=e.do_flip_channel_order??!1,this.config=e}async thumbnail(e,s,r=2){let n=e.height,o=e.width,a=s.height,i=s.width,l=Math.min(n,a),c=Math.min(o,i);return l===n&&c===o?e:(n>o?c=Math.floor(o*l/n):o>n&&(l=Math.floor(n*c/o)),await e.resize(c,l,{resample:r}))}async crop_margin(e,s=200){let r=e.clone().grayscale(),n=cr(r.data)[0],a=ae(r.data)[0]-n;if(a===0)return e;let i=s/255,l=r.width,c=r.height,u=0,p=0,d=r.data;for(let _=0;_<r.height;++_){let m=_*r.width;for(let h=0;h<r.width;++h)(d[m+h]-n)/a<i&&(l=Math.min(l,h),c=Math.min(c,_),u=Math.max(u,h),p=Math.max(p,_))}return e=await e.crop([l,c,u,p]),e}pad_image(e,s,r,{mode:n="constant",center:o=!1,constant_values:a=0}={}){let[i,l,c]=s,u,p;if(typeof r=="number"?(u=r,p=r):r==="square"?u=p=Math.max(i,l):(u=r.width,p=r.height),u!==l||p!==i){let d=new Float32Array(u*p*c);if(Array.isArray(a))for(let h=0;h<d.length;++h)d[h]=a[h%c];else a!==0&&d.fill(a);let[_,m]=o?[Math.floor((u-l)/2),Math.floor((p-i)/2)]:[0,0];for(let h=0;h<i;++h){let x=(h+m)*u,g=h*l;for(let w=0;w<l;++w){let y=(x+w+_)*c,E=(g+w)*c;for(let A=0;A<c;++A)d[y+A]=e[E+A]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let h=i-1,x=l-1;for(let g=0;g<p;++g){let w=g*u,y=_s(g,h)*l;for(let E=0;E<u;++E){if(g<i&&E<l)continue;let A=(w+E)*c,b=(y+_s(E,x))*c;for(let O=0;O<c;++O)d[A+O]=e[b+O]}}}e=d,s=[p,u,c]}return[e,s]}rescale(e){for(let s=0;s<e.length;++s)e[s]=this.rescale_factor*e[s]}get_resize_output_image_size(e,s){let[r,n]=e.size,o,a;if(this.do_thumbnail){let{height:i,width:l}=s;o=Math.min(i,l)}else Number.isInteger(s)?(o=s,a=this.config.max_size??o):s!==void 0&&(o=s.shortest_edge,a=s.longest_edge);if(o!==void 0||a!==void 0){let i=o===void 0?1:Math.max(o/r,o/n),l=r*i,c=n*i,u=a===void 0?1:Math.min(a/l,a/c),p=Math.floor(Number((l*u).toFixed(2))),d=Math.floor(Number((c*u).toFixed(2)));return this.size_divisibility!==void 0&&([p,d]=uu([p,d],this.size_divisibility)),[p,d]}else if(s!==void 0&&s.width!==void 0&&s.height!==void 0){let i=s.width,l=s.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let c=l/n,u=i/r;Math.abs(1-u)<Math.abs(1-c)?c=u:u=c,l=Qw(c*n,this.config.ensure_multiple_of),i=Qw(u*r,this.config.ensure_multiple_of)}return[i,l]}else{if(this.size_divisibility!==void 0)return uu([r,n],this.size_divisibility);if(this.min_pixels!==void 0&&this.max_pixels!==void 0){let i=this.config.patch_size*this.config.merge_size;return rv(n,r,i,this.min_pixels,this.max_pixels)}else throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(s)}`)}}async resize(e){let[s,r]=this.get_resize_output_image_size(e,this.size);return await e.resize(s,r,{resample:this.resample})}async preprocess(e,{do_normalize:s=null,do_pad:r=null,do_convert_rgb:n=null,do_convert_grayscale:o=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[i,l]=e.size;if(n??this.do_convert_rgb?e=e.rgb():o&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let _,m;Number.isInteger(this.crop_size)?(_=this.crop_size,m=this.crop_size):(_=this.crop_size.width,m=this.crop_size.height),e=await e.center_crop(_,m)}let c=[e.height,e.width],u=Float32Array.from(e.data),p=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(u),s??this.do_normalize){let _=this.image_mean;Array.isArray(this.image_mean)||(_=new Array(e.channels).fill(_));let m=this.image_std;if(Array.isArray(this.image_std)||(m=new Array(e.channels).fill(m)),_.length!==e.channels||m.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${_.length}) and \`image_std\` (${m.length}) must match the number of channels in the image (${e.channels}).`);for(let h=0;h<u.length;h+=e.channels)for(let x=0;x<e.channels;++x)u[h+x]=(u[h+x]-_[x])/m[x]}if(r??this.do_pad){if(this.pad_size)[u,p]=this.pad_image(u,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){let[_,m]=uu([p[1],p[0]],this.size_divisibility);[u,p]=this.pad_image(u,p,{width:_,height:m})}}if(a??this.do_flip_channel_order){if(p[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let _=0;_<u.length;_+=3){let m=u[_];u[_]=u[_+2],u[_+2]=m}}let d=new S("float32",u,p).permute(2,0,1);return{original_size:[l,i],reshaped_input_size:c,pixel_values:d}}async _call(e,...s){Array.isArray(e)||(e=[e]);let r=await Promise.all(e.map(o=>this.preprocess(o)));return{pixel_values:Ke(r.map(o=>o.pixel_values),0),original_sizes:r.map(o=>o.original_size),reshaped_input_sizes:r.map(o=>o.reshaped_input_size)}}static async from_pretrained(e,s={}){let r=await Se(e,ks,!0,s);return new this(r)}};var Ss={};us(Ss,{BeitFeatureExtractor:()=>du,BitImageProcessor:()=>_u,CLIPFeatureExtractor:()=>mu,CLIPImageProcessor:()=>la,ChineseCLIPFeatureExtractor:()=>fu,ConvNextFeatureExtractor:()=>hu,ConvNextImageProcessor:()=>ca,DINOv3ViTImageProcessor:()=>wu,DPTFeatureExtractor:()=>bu,DPTImageProcessor:()=>da,DeiTFeatureExtractor:()=>xu,DeiTImageProcessor:()=>ua,DetrFeatureExtractor:()=>gu,DetrImageProcessor:()=>pa,DonutFeatureExtractor:()=>yu,DonutImageProcessor:()=>vs,EfficientNetImageProcessor:()=>ku,GLPNFeatureExtractor:()=>vu,GroundingDinoImageProcessor:()=>Eu,Idefics3ImageProcessor:()=>_a,ImageFeatureExtractor:()=>P,ImageProcessor:()=>P,JinaCLIPImageProcessor:()=>Mu,LlavaOnevisionImageProcessor:()=>Su,Mask2FormerImageProcessor:()=>Iu,MaskFormerFeatureExtractor:()=>Ou,MaskFormerImageProcessor:()=>Es,MobileNetV1FeatureExtractor:()=>zu,MobileNetV1ImageProcessor:()=>fa,MobileNetV2FeatureExtractor:()=>Tu,MobileNetV2ImageProcessor:()=>ma,MobileNetV3FeatureExtractor:()=>Pu,MobileNetV3ImageProcessor:()=>ha,MobileNetV4FeatureExtractor:()=>Cu,MobileNetV4ImageProcessor:()=>xa,MobileViTFeatureExtractor:()=>Nu,MobileViTImageProcessor:()=>ga,NougatImageProcessor:()=>Lu,OwlViTFeatureExtractor:()=>$u,OwlViTImageProcessor:()=>As,Owlv2ImageProcessor:()=>Ru,Phi3VImageProcessor:()=>ju,PixtralImageProcessor:()=>Bu,PvtImageProcessor:()=>Uu,Qwen2VLImageProcessor:()=>qu,RTDetrImageProcessor:()=>Gu,Sam2ImageProcessor:()=>br,Sam3ImageProcessor:()=>br,SamImageProcessor:()=>br,SapiensFeatureExtractor:()=>Wu,SapiensImageProcessor:()=>wa,SegformerFeatureExtractor:()=>Vu,SegformerImageProcessor:()=>ya,SiglipImageProcessor:()=>Hu,SmolVLMImageProcessor:()=>_a,Swin2SRImageProcessor:()=>Xu,VLMImageProcessor:()=>Au,ViTFeatureExtractor:()=>Ku,ViTImageProcessor:()=>ba,VitMatteImageProcessor:()=>Qu,VitPoseImageProcessor:()=>Ju,YolosFeatureExtractor:()=>Yu,YolosImageProcessor:()=>ka});var du=class extends P{};var _u=class extends P{};var fu=class extends P{};var la=class extends P{},mu=class extends la{};var ca=class extends P{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let s=this.size?.shortest_edge;if(s===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(s<384){let r=Math.floor(s/this.crop_pct),[n,o]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,o,{resample:this.resample}),e=await e.center_crop(s,s)}else e=await e.resize(s,s,{resample:this.resample});return e}},hu=class extends ca{};var ua=class extends P{},xu=class extends ua{};var pa=class extends P{async _call(e){let s=await super._call(e),r=[s.pixel_values.dims[0],64,64],n=xe(r,1n);return{...s,pixel_mask:n}}post_process_object_detection(...e){return St(...e)}post_process_panoptic_segmentation(...e){return aa(...e)}post_process_instance_segmentation(...e){return ia(...e)}},gu=class extends pa{};var wu=class extends P{};var vs=class extends P{pad_image(e,s,r,n={}){let[o,a,i]=s,l=this.image_mean;Array.isArray(this.image_mean)||(l=new Array(i).fill(l));let c=this.image_std;Array.isArray(c)||(c=new Array(i).fill(l));let u=l.map((p,d)=>-p/c[d]);return super.pad_image(e,s,r,{center:!0,constant_values:u,...n})}},yu=class extends vs{};var da=class extends P{},bu=class extends da{};var ku=class extends P{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(s=>s*s))}};var vu=class extends P{};var Eu=class extends P{async _call(e){let s=await super._call(e),r=s.pixel_values.dims,n=Oe([r[0],r[2],r[3]]);return{...s,pixel_mask:n}}};var _a=class extends P{constructor(e){super(e),this.do_image_splitting=e.do_image_splitting??!0,this.max_image_size=e.max_image_size}get_resize_for_vision_encoder(e,s){let[r,n]=e.dims.slice(-2),o=n/r;return n>=r?(n=Math.ceil(n/s)*s,r=Math.floor(n/o),r=Math.ceil(r/s)*s):(r=Math.ceil(r/s)*s,n=Math.floor(r*o),n=Math.ceil(n/s)*s),{height:r,width:n}}async _call(e,{do_image_splitting:s=null,return_row_col_info:r=!1}={}){let n;if(!Array.isArray(e))n=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?n=e:n=[e]}let o=[],a=[],i=[],l=[],c=[];for(let g of n){let w=await Promise.all(g.map(A=>this.preprocess(A)));l.push(...w.map(A=>A.original_size)),c.push(...w.map(A=>A.reshaped_input_size)),w.forEach(A=>A.pixel_values.unsqueeze_(0));let{longest_edge:y}=this.max_image_size,E;if(s??this.do_image_splitting){let A=new Array(w.length),b=new Array(w.length);E=await Promise.all(w.map(async(O,N)=>{let F=this.get_resize_for_vision_encoder(O.pixel_values,y),R=await Xe(O.pixel_values,{size:[F.height,F.width]}),{frames:B,num_splits_h:G,num_splits_w:D}=await this.split_image(R,this.max_image_size);return A[N]=G,b[N]=D,ne(B,0)})),a.push(A),i.push(b)}else{let A=[y,y];E=await Promise.all(w.map(b=>Xe(b.pixel_values,{size:A}))),a.push(new Array(w.length).fill(0)),i.push(new Array(w.length).fill(0))}o.push(ne(E,0))}let u=o.length,[p,d,_,m]=o[0].dims,h,x;if(u===1)h=o[0].unsqueeze_(0),x=xe([u,p,_,m],!0);else{let g=Math.max(...o.map(E=>E.dims.at(0)));x=xe([u,g,_,m],!0);let w=x.data,y=g*_*m;for(let E=0;E<u;++E){let A=o[E].dims[0];if(A<g){o[E]=ne([o[E],xe([g-A,d,_,m],0)],0);let b=E*y+A*_*m,O=(E+1)*y;w.fill(!1,b,O)}}h=Ke(o,0)}return{pixel_values:h,pixel_attention_mask:x,original_sizes:l,reshaped_input_sizes:c,...r?{rows:a,cols:i}:{}}}async split_image(e,{longest_edge:s}){let r=s,n=s,o=[],[a,i]=e.dims.slice(-2),l=0,c=0;if(a>r||i>n){l=Math.ceil(a/r),c=Math.ceil(i/n);let u=Math.ceil(a/l),p=Math.ceil(i/c);for(let m=0;m<l;++m)for(let h=0;h<c;++h){let x,g,w,y;m===l-1?(g=a-u,y=a):(g=m*u,y=(m+1)*u),h===c-1?(x=i-p,w=i):(x=h*p,w=(h+1)*p);let b=await Zo(e,[g,x],[y,w],[2,3]);o.push(b)}let d=r,_=n;(a!==d||i!==_)&&(e=await Xe(e,{size:[d,_]}))}return o.push(e),{frames:o,num_splits_h:l,num_splits_w:c}}};var Au=class extends P{constructor(e){super({do_pad:!0,pad_size:{width:e.image_size,height:e.image_size},...e}),this.constant_values=this.config.background_color.map(s=>s*this.rescale_factor)}pad_image(e,s,r,n){return super.pad_image(e,s,r,{constant_values:this.constant_values,center:!0,...n})}};var Mu=class extends P{constructor(e){let{resize_mode:s,fill_color:r,interpolation:n,size:o,...a}=e,i=s==="squash"?{width:o,height:o}:s==="shortest"?{shortest_edge:o}:{longest_edge:o},l=n==="bicubic"?3:2;super({...a,size:i,resample:l,do_center_crop:!0,crop_size:o,do_normalize:!0})}};var Su=class extends P{};var Es=class extends P{post_process_panoptic_segmentation(...e){return aa(...e)}post_process_instance_segmentation(...e){return ia(...e)}},Ou=class extends Es{};var Iu=class extends Es{};var fa=class extends P{},zu=class extends fa{};var ma=class extends P{},Tu=class extends ma{};var ha=class extends P{},Pu=class extends ha{};var xa=class extends P{},Cu=class extends xa{};var ga=class extends P{},Nu=class extends ga{};var Lu=class extends vs{};var As=class extends P{post_process_object_detection(...e){return St(...e)}},$u=class extends As{};var Ru=class extends As{};var Ge=336,nv=[2,3],{ceil:Fu,floor:Ms,sqrt:Du}=Math,ju=class extends P{constructor(e){super({...e,do_normalize:!0,do_pad:!0,pad_size:"custom",do_convert_rgb:!0,do_resize:!0}),this._num_crops=e.num_crops}calc_num_image_tokens_from_image_size(e,s){let{num_img_tokens:r}=this.config;return Ms((Ms(s/Ge)*Ms(e/Ge)+1)*r+1+(Ms(s/Ge)+1)*Du(r))}get_resize_output_image_size(e,s){let r=this._num_crops,[n,o]=e.size,a=n/o,i=1;for(;i*Math.ceil(i/a)<=r;)i+=1;i-=1;let l=Math.floor(i*336),c=Math.floor(l/a);return[l,c]}pad_image(e,s,r,n={}){let[o,a]=s,i=Ge*Fu(o/Ge),l=Ge*Fu(a/Ge),c=[1,1,1].map((u,p)=>(u-this.image_mean[p])/this.image_std[p]);return super.pad_image(e,s,{width:l,height:i},{center:!0,constant_values:c,...n})}async _call(e,{num_crops:s=null}={}){if(this._num_crops=s??=this.config.num_crops,s<4||Du(s)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);let r=e.length,n=await Promise.all(e.map(d=>this.preprocess(d))),o=n.map(d=>d.original_size),a=n.map(d=>d.reshaped_input_size),i=[];for(let{pixel_values:d}of n){d.unsqueeze_(0);let[_,m]=d.dims.slice(-2),h=await Xe(d,{size:[Ge,Ge],mode:"bicubic"});if(s>0){let x=[],g=Du(s),w=Ms(m/g),y=Ms(_/g);for(let A=0;A<g;++A)for(let b=0;b<g;++b){let O,N,F,R;A===g-1?(N=_-y,R=_):(N=A*y,R=(A+1)*y),b===g-1?(O=m-w,F=m):(O=b*w,F=(b+1)*w);let D=await Zo(d,[N,O],[R,F],nv);x.push(D)}let E=await Xe(ne(x,0),{size:[Ge,Ge],mode:"bicubic"});i.push(ne([h,E],0))}else i.push(h)}let l=Ke(i,0),c=a.map(d=>d.map(_=>Ge*Fu(_/Ge))),u=new S("int64",c.flat(),[r,2]),p=c.map(([d,_])=>this.calc_num_image_tokens_from_image_size(_,d));return{pixel_values:l,original_sizes:o,reshaped_input_sizes:a,image_sizes:u,num_img_tokens:p}}};var Bu=class extends P{get_resize_output_image_size(e,s){let{longest_edge:r}=s;if(r===void 0)throw new Error("size must contain 'longest_edge'");let[n,o]=e.size,a=Math.max(n,o)/r,i=n,l=o;a>1&&(i=Math.floor(n/a),l=Math.floor(o/a));let{patch_size:c,spatial_merge_size:u}=this.config;if(!u)throw new Error("config must contain 'spatial_merge_size'");let p=c*u,d=Math.floor((i-1)/p)+1,_=Math.floor((l-1)/p)+1;return[d*p,_*p]}};var Uu=class extends P{};var qu=class extends P{async _call(e,...s){let{pixel_values:r,original_sizes:n,reshaped_input_sizes:o}=await super._call(e,...s),a=r,{temporal_patch_size:i,merge_size:l,patch_size:c}=this.config;a.dims[0]===1&&(a=ne(Array.from({length:i},()=>a),0));let u=a.dims[0]/i,p=a.dims[1],d=Math.floor(a.dims[2]/c),_=Math.floor(a.dims[3]/c),m=a.view(u,i,p,Math.floor(d/l),l,c,Math.floor(_/l),l,c).permute(0,3,6,4,7,2,1,5,8).view(u*d*_,p*i*c*c),h=new S("int64",[u,d,_],[1,3]);return{pixel_values:m,image_grid_thw:h,original_sizes:n,reshaped_input_sizes:o}}};var Gu=class extends P{post_process_object_detection(...e){return St(...e)}};var br=class extends P{reshape_input_points(e,s,r,n=!1){e=structuredClone(e);let o=jl(e);if(o.length===3)n||(o=[1,...o]),e=[e];else if(o.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let a=0;a<e.length;++a){let[i,l]=s[a],[c,u]=r[a],p=[u/l,c/i];for(let d=0;d<e[a].length;++d)for(let _=0;_<e[a][d].length;++_)for(let m=0;m<e[a][d][_].length;++m)e[a][d][_][m]*=p[m%2]}return new S("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,s){let r=jl(e);if(r.length===2)r=[1,...r],e=[e];else if(r.length!==3)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");if(r.some((n,o)=>n!==s.dims[o]))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new S("int64",e.flat(1/0).map(BigInt),r)}async _call(e,{input_points:s=null,input_labels:r=null,input_boxes:n=null}={}){let o=await super._call(e);if(s&&(o.input_points=this.reshape_input_points(s,o.original_sizes,o.reshaped_input_sizes)),r){if(!o.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");o.input_labels=this.add_input_labels(r,o.input_points)}return n&&(o.input_boxes=this.reshape_input_points(n,o.original_sizes,o.reshaped_input_sizes,!0)),o}async post_process_masks(e,s,r,{mask_threshold:n=0,binarize:o=!0,pad_size:a=null}={}){let i=[];a=a??this.pad_size??this.size;let l=[a.height,a.width];for(let c=0;c<s.length;++c){let u=s[c],p=r[c],d=await Xe(e[c],{mode:"bilinear",size:l});if(d=d.slice(null,null,[0,p[0]],[0,p[1]]),d=await Xe(d,{mode:"bilinear",size:u}),o){let _=d.data,m=new Uint8Array(_.length);for(let h=0;h<_.length;++h)_[h]>n&&(m[h]=1);d=new S("bool",m,d.dims)}i.push(d)}return i}generate_crop_boxes(e,s,{crop_n_layers:r=0,overlap_ratio:n=512/1500,points_per_crop:o=32,crop_n_points_downscale_factor:a=1}={}){}};var wa=class extends P{post_process_semantic_segmentation(...e){return oa(...e)}},Wu=class extends wa{};var ya=class extends P{post_process_semantic_segmentation(...e){return oa(...e)}},Vu=class extends ya{};var Hu=class extends P{};var Xu=class extends P{pad_image(e,s,r,n={}){let[o,a,i]=s;return super.pad_image(e,s,{width:a+(r-a%r)%r,height:o+(r-o%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}};var ba=class extends P{},Ku=class extends ba{};var Qu=class extends P{async _call(e,s){Array.isArray(e)||(e=[e]),Array.isArray(s)||(s=[s]);let r=await Promise.all(e.map(a=>this.preprocess(a))),n=await Promise.all(s.map(a=>this.preprocess(a,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:Ke(r.map((a,i)=>ne([a.pixel_values,n[i].pixel_values],0)),0),original_sizes:r.map(a=>a.original_size),reshaped_input_sizes:r.map(a=>a.reshaped_input_size)}}};var Ju=class extends P{post_process_pose_estimation(e,s,{threshold:r=null}={}){let n=e.tolist(),[o,a,i,l]=e.dims,c=[];for(let u=0;u<o;++u){let p=n[u],d=s[u],_=[];for(let m=0;m<d.length;++m){let h=d[m],x=[],g=[],w=[],y=h.at(-2)/l,E=h.at(-1)/i;for(let A=0;A<p.length;++A){let[b,O]=[0,0],N=0,F=-1/0,R=p[A];for(let G=0;G<R.length;++G){let D=R[G];for(let X=0;X<D.length;++X){let V=D[X];N+=V,F=Math.max(F,V),b+=(X+.5)*V,O+=G*V}}if(r!=null&&F<r)continue;let B=[y*b/N,E*O/N];x.push(B),w.push(A),g.push(F)}_.push({bbox:h,scores:g,labels:w,keypoints:x})}c.push(_)}return c}};var ka=class extends P{post_process_object_detection(...e){return St(...e)}},Yu=class extends ka{};var de=class{static async from_pretrained(e,s={}){let r=await Se(e,ks,!0,s),n=r.image_processor_type??r.feature_extractor_type,o=Ss[n?.replace(/Fast$/,"")];return o||(n!==void 0&&console.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${bs}.`),o=P),new o(r)}};var Zu=class extends j{static tokenizer_class=L;static image_processor_class=de;constructor(e,s,r){super(e,s,r);let{tasks_answer_post_processing_type:n,task_prompts_without_inputs:o,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(n??{})),this.task_prompts_without_inputs=new Map(Object.entries(o??{})),this.task_prompts_with_input=new Map(Object.entries(a??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e=="string"&&(e=[e]);let s=[];for(let r of e)if(this.task_prompts_without_inputs.has(r))s.push(this.task_prompts_without_inputs.get(r));else{for(let[n,o]of this.task_prompts_with_input)if(r.includes(n)){s.push(o.replaceAll("{input}",r).replaceAll(n,""));break}s.length!==e.length&&s.push(r)}return s}post_process_generation(e,s,r){let n=this.tasks_answer_post_processing_type.get(s)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let o;switch(n){case"pure_text":o=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":let a=n==="ocr"?"quad_boxes":"bboxes",i=e.matchAll(this.regexes[a]),l=[],c=[];for(let[u,p,...d]of i)l.push(p?p.trim():l.at(-1)??""),c.push(d.map((_,m)=>(Number(_)+.5)/this.size_per_bin*r[m%2]));o={labels:l,[a]:c};break;default:throw new Error(`Task "${s}" (of type "${n}") not yet implemented.`)}return{[s]:o}}async _call(e,s=null,r={}){if(!e&&!s)throw new Error("Either text or images must be provided");let n=await this.image_processor(e,r),o=s?this.tokenizer(this.construct_prompts(s),r):{};return{...n,...o}}};var ep=class extends j{static image_processor_class=de;static feature_extractor_class=ve;static tokenizer_class=L;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,s,r){super(e,s,r),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:n,boa_token:o,audio_token:a,eoa_token:i,image_token_id:l,boi_token:c,image_token:u,eoi_token:p}=this.tokenizer.config;this.audio_token_id=n,this.boa_token=o,this.audio_token=a;let d=a.repeat(this.audio_seq_length);this.full_audio_sequence=`
7
+ `));case"join":case"string":return t;case"int":{let n=parseInt(t.value,10);return new J(isNaN(n)?0:n)}case"float":{let n=parseFloat(t.value);return new Ee(isNaN(n)?0:n)}default:throw new Error(`Unknown StringValue filter: ${r.value}`)}else if(t instanceof J||t instanceof Ee)switch(r.value){case"abs":return t instanceof J?new J(Math.abs(t.value)):new Ee(Math.abs(t.value));case"int":return new J(Math.floor(t.value));case"float":return new Ee(t.value);case"string":return new D(t.toString());default:throw new Error(`Unknown NumericValue filter: ${r.value}`)}else if(t instanceof Te)switch(r.value){case"items":return new ne(Array.from(t.value.entries()).map(([n,o])=>new ne([new D(n),o])));case"length":return new J(t.value.size);default:{let n=t.builtins.get(r.value);if(n)return n instanceof we?n.value([],s):n;throw new Error(`Unknown ObjectValue filter: ${r.value}`)}}else if(t instanceof K)switch(r.value){case"bool":return new K(t.value);case"int":return new J(t.value?1:0);case"float":return new Ee(t.value?1:0);case"string":return new D(t.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${r.value}`)}throw new Error(`Cannot apply filter "${r.value}" to type: ${t.type}`)}else if(e.type==="CallExpression"){let r=e;if(r.callee.type!=="Identifier")throw new Error(`Unknown filter: ${r.callee.type}`);let n=r.callee.value;if(n==="tojson"){let[,o]=this.evaluateArguments(r.args,s),i=o.get("indent")??new ye;if(!(i instanceof J||i instanceof ye))throw new Error("If set, indent must be a number");let a=o.get("ensure_ascii")??new K(!1);if(!(a instanceof K))throw new Error("If set, ensure_ascii must be a boolean");let l=o.get("sort_keys")??new K(!1);if(!(l instanceof K))throw new Error("If set, sort_keys must be a boolean");let c=o.get("separators")??new ye,p=null;if(c instanceof ne||c instanceof s0){if(c.value.length!==2)throw new Error("separators must be a tuple of two strings");let[u,_]=c.value;if(!(u instanceof D)||!(_ instanceof D))throw new Error("separators must be a tuple of two strings");p=[u.value,_.value]}else if(!(c instanceof ye))throw new Error("If set, separators must be a tuple of two strings");return new D(Zt(t,{indent:i.value,ensureAscii:a.value,sortKeys:l.value,separators:p}))}else if(n==="join"){let o;if(t instanceof D)o=Array.from(t.value);else if(t instanceof ne)o=t.value.map(c=>c.value);else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`);let[i,a]=this.evaluateArguments(r.args,s),l=i.at(0)??a.get("separator")??new D("");if(!(l instanceof D))throw new Error("separator must be a string");return new D(o.join(l.value))}else if(n==="int"||n==="float"){let[o,i]=this.evaluateArguments(r.args,s),a=o.at(0)??i.get("default")??(n==="int"?new J(0):new Ee(0));if(t instanceof D){let l=n==="int"?parseInt(t.value,10):parseFloat(t.value);return isNaN(l)?a:n==="int"?new J(l):new Ee(l)}else{if(t instanceof J||t instanceof Ee)return t;if(t instanceof K)return n==="int"?new J(t.value?1:0):new Ee(t.value?1:0);throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}}else if(n==="default"){let[o,i]=this.evaluateArguments(r.args,s),a=o[0]??new D(""),l=o[1]??i.get("boolean")??new K(!1);if(!(l instanceof K))throw new Error("`default` filter flag must be a boolean");return t instanceof xe||l.value&&!t.__bool__().value?a:t}if(t instanceof ne){switch(n){case"sort":{let[o,i]=this.evaluateArguments(r.args,s),a=o.at(0)??i.get("reverse")??new K(!1);if(!(a instanceof K))throw new Error("reverse must be a boolean");let l=o.at(1)??i.get("case_sensitive")??new K(!1);if(!(l instanceof K))throw new Error("case_sensitive must be a boolean");let c=o.at(2)??i.get("attribute")??new ye;if(!(c instanceof D||c instanceof J||c instanceof ye))throw new Error("attribute must be a string, integer, or null");let p=u=>{if(c instanceof ye)return u;let _=c instanceof J?String(c.value):c.value;return r0(u,_)};return new ne(t.value.slice().sort((u,_)=>{let d=p(u),m=p(_),h=Lc(d,m,l.value);return a.value?-h:h}))}case"selectattr":case"rejectattr":{let o=n==="selectattr";if(t.value.some(u=>!(u instanceof Te)))throw new Error(`\`${n}\` can only be applied to array of objects`);if(r.args.some(u=>u.type!=="StringLiteral"))throw new Error(`arguments of \`${n}\` must be strings`);let[i,a,l]=r.args.map(u=>this.evaluate(u,s)),c;if(a){let u=s.tests.get(a.value);if(!u)throw new Error(`Unknown test: ${a.value}`);c=u}else c=(...u)=>u[0].__bool__().value;let p=t.value.filter(u=>{let _=u.value.get(i.value),d=_?c(_,l):!1;return o?d:!d});return new ne(p)}case"map":{let[,o]=this.evaluateArguments(r.args,s);if(o.has("attribute")){let i=o.get("attribute");if(!(i instanceof D))throw new Error("attribute must be a string");let a=o.get("default"),l=t.value.map(c=>{if(!(c instanceof Te))throw new Error("items in map must be an object");let p=r0(c,i.value);return p instanceof xe?a??new xe:p});return new ne(l)}else throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${n}`)}else if(t instanceof D){switch(n){case"indent":{let[o,i]=this.evaluateArguments(r.args,s),a=o.at(0)??i.get("width")??new J(4);if(!(a instanceof J))throw new Error("width must be a number");let l=o.at(1)??i.get("first")??new K(!1),c=o.at(2)??i.get("blank")??new K(!1),p=t.value.split(`
8
+ `),u=" ".repeat(a.value),_=p.map((d,m)=>!l.value&&m===0||!c.value&&d.length===0?d:u+d);return new D(_.join(`
9
+ `))}case"replace":{let o=t.builtins.get("replace");if(!(o instanceof we))throw new Error("replace filter not available");let[i,a]=this.evaluateArguments(r.args,s);return o.value([...i,new Mr(a)],s)}}throw new Error(`Unknown StringValue filter: ${n}`)}else if(t instanceof Te){let o=t.builtins.get(n);if(o&&o instanceof we){let[i,a]=this.evaluateArguments(r.args,s);return a.size>0&&i.push(new Mr(a)),o.value(i,s)}throw new Error(`Unknown ObjectValue filter: ${n}`)}else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}throw new Error(`Unknown filter: ${e.type}`)}evaluateFilterExpression(t,e){let s=this.evaluate(t.operand,e);return this.applyFilter(s,t.filter,e)}evaluateTestExpression(t,e){let s=this.evaluate(t.operand,e),r=e.tests.get(t.test.value);if(!r)throw new Error(`Unknown test: ${t.test.value}`);let n=r(s);return new K(t.negate?!n:n)}evaluateSelectExpression(t,e){return this.evaluate(t.test,e).__bool__().value?this.evaluate(t.lhs,e):new xe}evaluateUnaryExpression(t,e){let s=this.evaluate(t.argument,e);if(t.operator.value==="not")return new K(!s.value);throw new SyntaxError(`Unknown operator: ${t.operator.value}`)}evaluateTernaryExpression(t,e){return this.evaluate(t.condition,e).__bool__().value?this.evaluate(t.trueExpr,e):this.evaluate(t.falseExpr,e)}evalProgram(t,e){return this.evaluateBlock(t.body,e)}evaluateBlock(t,e){let s="";for(let r of t){let n=this.evaluate(r,e);n.type!=="NullValue"&&n.type!=="UndefinedValue"&&(s+=n.toString())}return new D(s)}evaluateIdentifier(t,e){return e.lookupVariable(t.value)}evaluateCallExpression(t,e){let[s,r]=this.evaluateArguments(t.args,e);r.size>0&&s.push(new Mr(r));let n=this.evaluate(t.callee,e);if(n.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${n.type}`);return n.value(s,e)}evaluateSliceExpression(t,e,s){if(!(t instanceof ne||t instanceof D))throw new Error("Slice object must be an array or string");let r=this.evaluate(e.start,s),n=this.evaluate(e.stop,s),o=this.evaluate(e.step,s);if(!(r instanceof J||r instanceof xe))throw new Error("Slice start must be numeric or undefined");if(!(n instanceof J||n instanceof xe))throw new Error("Slice stop must be numeric or undefined");if(!(o instanceof J||o instanceof xe))throw new Error("Slice step must be numeric or undefined");return t instanceof ne?new ne(Jy(t.value,r.value,n.value,o.value)):new D(Jy(Array.from(t.value),r.value,n.value,o.value).join(""))}evaluateMemberExpression(t,e){let s=this.evaluate(t.object,e),r;if(t.computed){if(t.property.type==="SliceExpression")return this.evaluateSliceExpression(s,t.property,e);r=this.evaluate(t.property,e)}else r=new D(t.property.value);let n;if(s instanceof Te){if(!(r instanceof D))throw new Error(`Cannot access property with non-string: got ${r.type}`);n=s.value.get(r.value)??s.builtins.get(r.value)}else if(s instanceof ne||s instanceof D)if(r instanceof J)n=s.value.at(r.value),s instanceof D&&(n=new D(s.value.at(r.value)));else if(r instanceof D)n=s.builtins.get(r.value);else throw new Error(`Cannot access property with non-string/non-number: got ${r.type}`);else{if(!(r instanceof D))throw new Error(`Cannot access property with non-string: got ${r.type}`);n=s.builtins.get(r.value)}return n instanceof ut?n:new xe}evaluateSet(t,e){let s=t.value?this.evaluate(t.value,e):this.evaluateBlock(t.body,e);if(t.assignee.type==="Identifier"){let r=t.assignee.value;e.setVariable(r,s)}else if(t.assignee.type==="TupleLiteral"){let r=t.assignee;if(!(s instanceof ne))throw new Error(`Cannot unpack non-iterable type in set: ${s.type}`);let n=s.value;if(n.length!==r.value.length)throw new Error(`Too ${r.value.length>n.length?"few":"many"} items to unpack in set`);for(let o=0;o<r.value.length;++o){let i=r.value[o];if(i.type!=="Identifier")throw new Error(`Cannot unpack to non-identifier in set: ${i.type}`);e.setVariable(i.value,n[o])}}else if(t.assignee.type==="MemberExpression"){let r=t.assignee,n=this.evaluate(r.object,e);if(!(n instanceof Te))throw new Error("Cannot assign to member of non-object");if(r.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");n.value.set(r.property.value,s)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(t.assignee)}`);return new ye}evaluateIf(t,e){let s=this.evaluate(t.test,e);return this.evaluateBlock(s.__bool__().value?t.body:t.alternate,e)}evaluateFor(t,e){let s=new Jt(e),r,n;if(t.iterable.type==="SelectExpression"){let c=t.iterable;n=this.evaluate(c.lhs,s),r=c.test}else n=this.evaluate(t.iterable,s);if(!(n instanceof ne||n instanceof Te))throw new Error(`Expected iterable or object type in for loop: got ${n.type}`);n instanceof Te&&(n=n.keys());let o=[],i=[];for(let c=0;c<n.value.length;++c){let p=new Jt(s),u=n.value[c],_;if(t.loopvar.type==="Identifier")_=d=>d.setVariable(t.loopvar.value,u);else if(t.loopvar.type==="TupleLiteral"){let d=t.loopvar;if(u.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${u.type}`);let m=u;if(d.value.length!==m.value.length)throw new Error(`Too ${d.value.length>m.value.length?"few":"many"} items to unpack`);_=h=>{for(let g=0;g<d.value.length;++g){if(d.value[g].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${d.value[g].type}`);h.setVariable(d.value[g].value,m.value[g])}}}else throw new Error(`Invalid loop variable(s): ${t.loopvar.type}`);r&&(_(p),!this.evaluate(r,p).__bool__().value)||(o.push(u),i.push(_))}let a="",l=!0;for(let c=0;c<o.length;++c){let p=new Map([["index",new J(c+1)],["index0",new J(c)],["revindex",new J(o.length-c)],["revindex0",new J(o.length-c-1)],["first",new K(c===0)],["last",new K(c===o.length-1)],["length",new J(o.length)],["previtem",c>0?o[c-1]:new xe],["nextitem",c<o.length-1?o[c+1]:new xe]]);s.setVariable("loop",new Te(p)),i[c](s);try{let u=this.evaluateBlock(t.body,s);a+=u.value}catch(u){if(u instanceof e0)continue;if(u instanceof Zy)break;throw u}l=!1}if(l){let c=this.evaluateBlock(t.defaultBlock,s);a+=c.value}return new D(a)}evaluateMacro(t,e){return e.setVariable(t.name.value,new we((s,r)=>{let n=new Jt(r);s=s.slice();let o;s.at(-1)?.type==="KeywordArgumentsValue"&&(o=s.pop());for(let i=0;i<t.args.length;++i){let a=t.args[i],l=s[i];if(a.type==="Identifier"){let c=a;if(!l)throw new Error(`Missing positional argument: ${c.value}`);n.setVariable(c.value,l)}else if(a.type==="KeywordArgumentExpression"){let c=a,p=l??o?.value.get(c.key.value)??this.evaluate(c.value,n);n.setVariable(c.key.value,p)}else throw new Error(`Unknown argument type: ${a.type}`)}return this.evaluateBlock(t.body,n)})),new ye}evaluateCallStatement(t,e){let s=new we((a,l)=>{let c=new Jt(l);if(t.callerArgs)for(let p=0;p<t.callerArgs.length;++p){let u=t.callerArgs[p];if(u.type!=="Identifier")throw new Error(`Caller parameter must be an identifier, got ${u.type}`);c.setVariable(u.value,a[p]??new xe)}return this.evaluateBlock(t.body,c)}),[r,n]=this.evaluateArguments(t.call.args,e);r.push(new Mr(n));let o=this.evaluate(t.call.callee,e);if(o.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${o.type}`);let i=new Jt(e);return i.setVariable("caller",s),o.value(r,i)}evaluateFilterStatement(t,e){let s=this.evaluateBlock(t.body,e);return this.applyFilter(s,t.filter,e)}evaluate(t,e){if(!t)return new xe;switch(t.type){case"Program":return this.evalProgram(t,e);case"Set":return this.evaluateSet(t,e);case"If":return this.evaluateIf(t,e);case"For":return this.evaluateFor(t,e);case"Macro":return this.evaluateMacro(t,e);case"CallStatement":return this.evaluateCallStatement(t,e);case"Break":throw new Zy;case"Continue":throw new e0;case"IntegerLiteral":return new J(t.value);case"FloatLiteral":return new Ee(t.value);case"StringLiteral":return new D(t.value);case"ArrayLiteral":return new ne(t.value.map(s=>this.evaluate(s,e)));case"TupleLiteral":return new s0(t.value.map(s=>this.evaluate(s,e)));case"ObjectLiteral":{let s=new Map;for(let[r,n]of t.value){let o=this.evaluate(r,e);if(!(o instanceof D))throw new Error(`Object keys must be strings: got ${o.type}`);s.set(o.value,this.evaluate(n,e))}return new Te(s)}case"Identifier":return this.evaluateIdentifier(t,e);case"CallExpression":return this.evaluateCallExpression(t,e);case"MemberExpression":return this.evaluateMemberExpression(t,e);case"UnaryExpression":return this.evaluateUnaryExpression(t,e);case"BinaryExpression":return this.evaluateBinaryExpression(t,e);case"FilterExpression":return this.evaluateFilterExpression(t,e);case"FilterStatement":return this.evaluateFilterStatement(t,e);case"TestExpression":return this.evaluateTestExpression(t,e);case"SelectExpression":return this.evaluateSelectExpression(t,e);case"Ternary":return this.evaluateTernaryExpression(t,e);case"Comment":return new ye;default:throw new SyntaxError(`Unknown node type: ${t.type}`)}}};function Xi(t){switch(typeof t){case"number":return Number.isInteger(t)?new J(t):new Ee(t);case"string":return new D(t);case"boolean":return new K(t);case"undefined":return new xe;case"object":return t===null?new ye:Array.isArray(t)?new ne(t.map(Xi)):new Te(new Map(Object.entries(t).map(([e,s])=>[e,Xi(s)])));case"function":return new we((e,s)=>{let r=t(...e.map(n=>n.value))??null;return Xi(r)});default:throw new Error(`Cannot convert to runtime value: ${t}`)}}var Oe=`
10
+ `,EE="{%- ",AE=" -%}";function ME(t){switch(t.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return t.operator.value==="and"?1:t.operator.value==="in"||t.operator.value==="not in"?2:0}return 0}function SE(t,e=" "){let s=typeof e=="number"?" ".repeat(e):e;return ot(t.body,0,s).replace(/\n$/,"")}function Fe(...t){return EE+t.join(" ")+AE}function ot(t,e,s){return t.map(r=>OE(r,e,s)).join(Oe)}function OE(t,e,s){let r=s.repeat(e);switch(t.type){case"Program":return ot(t.body,e,s);case"If":return zE(t,e,s);case"For":return IE(t,e,s);case"Set":return TE(t,e,s);case"Macro":return CE(t,e,s);case"Break":return r+Fe("break");case"Continue":return r+Fe("continue");case"CallStatement":return PE(t,e,s);case"FilterStatement":return NE(t,e,s);case"Comment":return r+"{# "+t.value+" #}";default:return r+"{{- "+ie(t)+" -}}"}}function zE(t,e,s){let r=s.repeat(e),n=[],o=t;for(;o&&(n.push({test:o.test,body:o.body}),o.alternate.length===1&&o.alternate[0].type==="If");)o=o.alternate[0];let i=r+Fe("if",ie(n[0].test))+Oe+ot(n[0].body,e+1,s);for(let a=1;a<n.length;++a)i+=Oe+r+Fe("elif",ie(n[a].test))+Oe+ot(n[a].body,e+1,s);return o&&o.alternate.length>0&&(i+=Oe+r+Fe("else")+Oe+ot(o.alternate,e+1,s)),i+=Oe+r+Fe("endif"),i}function IE(t,e,s){let r=s.repeat(e),n="";if(t.iterable.type==="SelectExpression"){let i=t.iterable;n=`${ie(i.lhs)} if ${ie(i.test)}`}else n=ie(t.iterable);let o=r+Fe("for",ie(t.loopvar),"in",n)+Oe+ot(t.body,e+1,s);return t.defaultBlock.length>0&&(o+=Oe+r+Fe("else")+Oe+ot(t.defaultBlock,e+1,s)),o+=Oe+r+Fe("endfor"),o}function TE(t,e,s){let r=s.repeat(e),n=ie(t.assignee),o=t.value?ie(t.value):"",i=r+Fe("set",`${n}${t.value?" = "+o:""}`);return t.body.length===0?i:i+Oe+ot(t.body,e+1,s)+Oe+r+Fe("endset")}function CE(t,e,s){let r=s.repeat(e),n=t.args.map(ie).join(", ");return r+Fe("macro",`${t.name.value}(${n})`)+Oe+ot(t.body,e+1,s)+Oe+r+Fe("endmacro")}function PE(t,e,s){let r=s.repeat(e),n=t.callerArgs&&t.callerArgs.length>0?`(${t.callerArgs.map(ie).join(", ")})`:"",o=ie(t.call),i=r+Fe(`call${n}`,o)+Oe;return i+=ot(t.body,e+1,s)+Oe,i+=r+Fe("endcall"),i}function NE(t,e,s){let r=s.repeat(e),n=t.filter.type==="Identifier"?t.filter.value:ie(t.filter),o=r+Fe("filter",n)+Oe;return o+=ot(t.body,e+1,s)+Oe,o+=r+Fe("endfilter"),o}function ie(t,e=-1){switch(t.type){case"SpreadExpression":return`*${ie(t.argument)}`;case"Identifier":return t.value;case"IntegerLiteral":return`${t.value}`;case"FloatLiteral":return`${t.value}`;case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":{let s=t,r=ME(s),n=ie(s.left,r),o=ie(s.right,r+1),i=`${n} ${s.operator.value} ${o}`;return r<e?`(${i})`:i}case"UnaryExpression":{let s=t;return s.operator.value+(s.operator.value==="not"?" ":"")+ie(s.argument,1/0)}case"CallExpression":{let s=t,r=s.args.map(ie).join(", ");return`${ie(s.callee)}(${r})`}case"MemberExpression":{let s=t,r=ie(s.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(s.object.type)||(r=`(${r})`);let n=ie(s.property);return!s.computed&&s.property.type!=="Identifier"&&(n=`(${n})`),s.computed?`${r}[${n}]`:`${r}.${n}`}case"FilterExpression":{let s=t,r=ie(s.operand,1/0);return s.filter.type==="CallExpression"?`${r} | ${ie(s.filter)}`:`${r} | ${s.filter.value}`}case"SelectExpression":{let s=t;return`${ie(s.lhs)} if ${ie(s.test)}`}case"TestExpression":{let s=t;return`${ie(s.operand)} is${s.negate?" not":""} ${s.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let s=t.value.map(ie),r=t.type==="ArrayLiteral"?"[]":"()";return`${r[0]}${s.join(", ")}${r[1]}`}case"ObjectLiteral":return`{${Array.from(t.value.entries()).map(([r,n])=>`${ie(r)}: ${ie(n)}`).join(", ")}}`;case"SliceExpression":{let s=t,r=s.start?ie(s.start):"",n=s.stop?ie(s.stop):"",o=s.step?`:${ie(s.step)}`:"";return`${r}:${n}${o}`}case"KeywordArgumentExpression":{let s=t;return`${s.key.value}=${ie(s.value)}`}case"Ternary":{let s=t,r=`${ie(s.trueExpr)} if ${ie(s.condition,0)} else ${ie(s.falseExpr)}`;return e>-1?`(${r})`:r}default:throw new Error(`Unknown expression type: ${t.type}`)}}var n0=class{parsed;constructor(t){let e=Gv(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=fE(e)}render(t){let e=new Jt;if(kE(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new vE(e).run(this.parsed).value}format(t){return SE(this.parsed,t?.indent||" ")}};var Se=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}_call(...t){throw Error("Must implement _call method in subclass")}};var LE={txt:"text/plain",html:"text/html",css:"text/css",js:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif"},Mt=class t{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Le.existsSync(e),this.exists){this.status=200,this.statusText="OK";let s=Le.statSync(e);this.headers.set("content-length",s.size.toString()),this.updateContentType();let r=Le.createReadStream(e);this.body=new ReadableStream({start(n){r.on("data",o=>n.enqueue(o)),r.on("end",()=>n.close()),r.on("error",o=>n.error(o))},cancel(){r.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",LE[e]??"application/octet-stream")}clone(){let e=new t(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await Le.promises.readFile(this.filePath)).buffer}async blob(){let e=await Le.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await Le.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}};var St=class{constructor(e){this._mt=new Uint32Array(624),this._idx=625,this._gauss_next=null,this._random_fn=this.random.bind(this),this.seed(e)}seed(e){if(e==null)if(V.IS_CRYPTO_AVAILABLE){let a=new Uint32Array(1);crypto.getRandomValues(a),e=a[0]}else e=Date.now()>>>0;let s=this._mt,r=(a,l)=>Math.imul(a,l)>>>0,n=[];for(let a=e||0;a>0;a=Math.floor(a/4294967296))n.push(a&4294967295);n.length||n.push(0),s[0]=19650218;for(let a=1;a<624;++a)s[a]=r(1812433253,s[a-1]^s[a-1]>>>30)+a>>>0;let o=1,i=0;for(let a=Math.max(624,n.length);a>0;--a,++o,++i)o>=624&&(s[0]=s[623],o=1),i>=n.length&&(i=0),s[o]=(s[o]^r(s[o-1]^s[o-1]>>>30,1664525))+n[i]+i>>>0;for(let a=623;a>0;--a,++o)o>=624&&(s[0]=s[623],o=1),s[o]=(s[o]^r(s[o-1]^s[o-1]>>>30,1566083941))-o>>>0;s[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let r=0;r<624;++r){let n=e[r]&2147483648|e[(r+1)%624]&2147483647;e[r]=(e[(r+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let s=e[this._idx++];return s^=s>>>11,s^=s<<7&2636928640,s^=s<<15&4022730752,s^=s>>>18,s>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,s=1){let r=this._gauss_next;if(this._gauss_next=null,r===null){let n=this.random()*2*Math.PI,o=Math.sqrt(-2*Math.log(1-this.random()));r=Math.cos(n)*o,this._gauss_next=Math.sin(n)*o}return e+r*s}shuffle(e){for(let s=e.length-1;s>0;--s){let r=32-Math.clz32(s+1),n=this._int32()>>>32-r;for(;n>s;)n=this._int32()>>>32-r;let o=e[s];e[s]=e[n],e[n]=o}}choices(e,s){return e[o0(this._random_fn,s)]}};function o0(t,e){let s=0;for(let n=0;n<e.length;++n)s+=e[n];let r=t()*s;for(let n=0;n<e.length;++n)if(r-=e[n],r<0)return n;return e.length-1}var _t=new St,es=Object.freeze({Random:St,seed:_t.seed.bind(_t),random:_t.random.bind(_t),gauss:_t.gauss.bind(_t),shuffle:_t.shuffle.bind(_t),choices:_t.choices.bind(_t)}),i0=t=>o0(es.random,t);var $E=new St,zs=class{constructor(e){this.path=e}async match(e){let s=Xe.join(this.path,e),r=new Mt(s);if(r.exists)return r}async put(e,s,r=void 0){let n=Xe.join(this.path,e),o=V.IS_PROCESS_AVAILABLE?process.pid:Date.now(),i=$E._int32().toString(36),a=n+`.tmp.${o}.${i}`;try{let l=s.headers.get("Content-Length"),c=parseInt(l??"0"),p=0;await Le.promises.mkdir(Xe.dirname(n),{recursive:!0});let u=Le.createWriteStream(a),_=s.body.getReader();for(;;){let{done:d,value:m}=await _.read();if(d)break;await new Promise((g,x)=>{u.write(m,w=>{if(w){x(w);return}g()})}),p+=m.length;let h=c?p/c*100:0;r?.({progress:h,loaded:p,total:c})}await new Promise((d,m)=>{u.close(h=>h?m(h):d())}),await Le.promises.rename(a,n)}catch(l){try{await Le.promises.unlink(a)}catch{}throw l}}async delete(e){let s=Xe.join(this.path,e);try{return await Le.promises.unlink(s),!0}catch{return!1}}};var a0={400:"Bad request error occurred while trying to load file",401:"Unauthorized access to file",403:"Forbidden access to file",404:"Could not locate file",408:"Request timeout error occurred while trying to load file",500:"Internal server error error occurred while trying to load file",502:"Bad gateway error occurred while trying to load file",503:"Service unavailable error occurred while trying to load file",504:"Gateway timeout error occurred while trying to load file"},Qi=100,l0=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function Sr(...t){return t=t.map((e,s)=>(s&&(e=e.replace(new RegExp("^/"),"")),s!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e)),t.join("/")}function Ot(t,e=null,s=null){let r;try{r=new URL(t)}catch{return!1}return!(e&&!e.includes(r.protocol)||s&&!s.includes(r.hostname))}function c0(t){return!(!l0.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function p0(t,e,s){if(!s)return null;let r=a0[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${r}: "${e}".`)}async function u0(t,e,s){let r=t.headers.get("Content-Length"),n=r?parseInt(r,10):s??0;r===null&&!s&&$.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let o=new Uint8Array(n),i=0,a=t.body.getReader();async function l(){let{done:c,value:p}=await a.read();if(c)return;let u=i+p.length;if(u>n){n=u;let d=new Uint8Array(n);d.set(o),o=d}o.set(p,i),i=u;let _=i/n*100;return e({progress:_,loaded:i,total:n}),l()}return await l(),o}function $c(t){return Ot(t,["blob:"])}function Fc(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof import.meta<"u"&&import.meta.url)e=import.meta.url;else return t;return new URL(t,e).href}var d0="SHA-256",FE="experimental_transformers-hash-cache",_0=t=>({algorithm:d0,value:t}),Or=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(FE),this.#t);static isAvailable=()=>typeof navigator<"u"&&"crossOriginStorage"in navigator;match=async e=>{let s=await this._getFileHash(e);if(s)try{let[r]=await navigator.crossOriginStorage.requestFileHandles([_0(s)]),n=await r.getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,s)=>{let r=await this._getFileHash(e);if(r){let n=await s.blob();await this._storeBlobInCOS(n,r)}else this._processAndStore(e,s.body)};_storeBlobInCOS=async(e,s)=>{let[r]=await navigator.crossOriginStorage.requestFileHandles([_0(s)],{create:!0}),n=await r.createWritable();await n.write(e),await n.close()};_processAndStore=async(e,s)=>{try{let r=[];for await(let i of s)r.push(i);let n=new Blob(r),o=await this._getBlobHash(n);await this._storeBlobInCOS(n,o);try{await(await this._getHashCache()).put(e,new Response(o))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let s=await this._getHashCache(),r=await s.match(e);if(r)return r.text();let n=await this._getLfsFileHash(e);return n?(await s.put(e,new Response(n)),n):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes("/resolve/"))return null;let s=e.replace("/resolve/","/raw/");try{let n=(await fetch(s).then(o=>o.text())).match(/^oid sha256:([0-9a-f]+)$/m);return n?n[1]:null}catch{return null}};_getBlobHash=async e=>{let s=await e.arrayBuffer(),r=await crypto.subtle.digest(d0,s);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}};async function at(t=null){let e=null;if(Y.useCustomCache){if(!Y.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!Y.customCache.match||!Y.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");e=Y.customCache}if(!e&&Y.experimental_useCrossOriginStorage&&Or.isAvailable()&&(e=new Or),!e&&Y.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{e=await caches.open(Y.cacheKey)}catch(s){$.warn("An error occurred while opening the browser cache:",s)}}if(!e&&Y.useFSCache){if(!V.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");e=new zs(t??Y.cacheDir)}return e}async function f0(t,...e){for(let s of e)try{let r=await t.match(s);if(r)return r}catch{continue}}var Yi=class{#t;#e;constructor(e){this.#t=e,this.#e=new Map}get(e){if(!this.#e.has(e))return;let s=this.#e.get(e);return this.#e.delete(e),this.#e.set(e,s),s}put(e,s){this.#e.has(e)&&this.#e.delete(e),this.#e.set(e,s),this.#e.size>this.#t&&this.#e.delete(this.#e.keys().next().value)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}};var RE=100,Rc=new Yi(RE);function Ji(t,e){let s=Rc.get(t);if(s!==void 0)return s;let r=e().then(n=>n,n=>(Rc.delete(t),Promise.reject(n)));return Rc.put(t,r),r}async function DE(t){if(!Ot(t,["http:","https:"]))return null;let e=Dc(t);return e.set("Range","bytes=0-0"),Y.fetch(t,{method:"GET",headers:e,cache:"no-store"})}function Je(t,e,s={}){let r=JSON.stringify([t,e,s?.revision,s?.cache_dir,s?.local_files_only]);return Ji(r,()=>jE(t,e,s))}async function jE(t,e,s){let r=await at(s?.cache_dir),{localPath:n,remoteURL:o,proposedCacheKey:i,validModelId:a}=It(t,e,s,r),l=await Tt(r,n,i);if(l!==void 0&&typeof l!="string"){let c=l.headers.get("content-length"),p=l.headers.get("content-type");return{exists:!0,size:c?parseInt(c,10):void 0,contentType:p||void 0,fromCache:!0}}if(Y.allowLocalModels&&!Ot(n,["http:","https:"]))try{let p=await zt(n);if(typeof p!="string"&&p.status!==404){let u=p.headers.get("content-length"),_=p.headers.get("content-type");return{exists:!0,size:u?parseInt(u,10):void 0,contentType:_||void 0,fromCache:!1}}}catch{}if(Y.allowRemoteModels&&!s.local_files_only&&a)try{let c=await DE(o);if(c&&c.status>=200&&c.status<300){let p,u=c.headers.get("content-type");if(c.status===206){let _=c.headers.get("content-range");if(_){let d=_.match(/bytes \d+-\d+\/(\d+)/);d&&(p=parseInt(d[1],10))}}else if(c.status===200)try{await c.body?.cancel()}catch{}if(p===void 0){let _=c.headers.get("content-length");p=_?parseInt(_,10):void 0}return{exists:!0,size:p,contentType:u||void 0,fromCache:!1}}}catch(c){$.warn(`Unable to fetch file metadata for "${o}": ${c}`)}return{exists:!1,fromCache:!1}}async function zt(t){return Y.useFS&&!Ot(t,["http:","https:","blob:"])?new Mt(t instanceof URL?t.protocol==="file:"?t.pathname:t.toString():t):Y.fetch(t,{headers:Dc(t)})}function Dc(t){let e=typeof process<"u"&&process?.release?.name==="node",s=new Headers;if(e){let r=!!process.env?.TESTING_REMOTELY,n=Y.version;if(s.set("User-Agent",`transformers.js/${n}; is_ci/${r};`),Ot(t,["http:","https:"],["huggingface.co","hf.co"])){let i=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;i&&s.set("Authorization",`Bearer ${i}`)}}return s}function It(t,e,s={},r=null){let n=s.revision??"main",o=Sr(t,e),i=c0(t),a=i?Sr(Y.localModelPath,o):o,l=Sr(Y.remoteHost,Y.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),c=r instanceof zs?n==="main"?o:Sr(t,n,e):l;return{requestURL:o,localPath:a,remoteURL:l,proposedCacheKey:c,validModelId:i}}async function Tt(t,e,s){if(t)return await f0(t,e,s)}async function BE(t,e,s,r,n,o,i={}){if(await s.match(r)===void 0)if(o){if(typeof n!="string"){let a=new Headers(n.headers);a.set("content-length",o.byteLength.toString()),await s.put(r,new Response(o,{headers:a})).catch(l=>{$.warn(`Unable to add response to browser cache: ${l}.`)})}}else{let a=i.progress_callback?l=>gt(i.progress_callback,{status:"progress",name:t,file:e,...l}):void 0;await s.put(r,n,a)}}async function qE(t,e,s=!0,r={},n=!1,o=null){let{requestURL:i,localPath:a,remoteURL:l,proposedCacheKey:c,validModelId:p}=It(t,e,r,o),u,_=!1,d;d=await Tt(o,a,c);let m=d!==void 0;if(!m){if(Y.allowLocalModels)if(Ot(i,["http:","https:"])){if(r.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${i}.`);if(!Y.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${i}.`)}else try{d=await zt(a),u=a}catch(w){$.warn(`Unable to load from local path "${a}": "${w}"`)}if(d===void 0||typeof d!="string"&&d.status===404){if(r.local_files_only||!Y.allowRemoteModels){if(s)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${a}".`);return null}if(!p)throw Error(`Local file missing at "${a}" and download aborted due to invalid model ID "${t}".`);if(d=await zt(l),d.status!==200)return p0(d.status,l,s);u=c}_=o&&typeof Response<"u"&&d instanceof Response&&d.status===200}gt(r.progress_callback,{status:"download",name:t,file:e});let h;if(!(V.IS_NODE_ENV&&n)){let x;if(typeof d!="string")if(!r.progress_callback)x=new Uint8Array(await d.arrayBuffer());else if(m&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))x=new Uint8Array(await d.arrayBuffer()),gt(r.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:x.length,total:x.length});else{let w,y=d.headers.get("content-length");if(y)w=parseInt(y,10);else try{let b=await Je(t,e,r);b.size&&(w=b.size)}catch{}x=await u0(d,b=>{gt(r.progress_callback,{status:"progress",name:t,file:e,...b})},w)}h=x}if(_&&u&&typeof d!="string"&&await BE(t,e,o,u,d,h,r),gt(r.progress_callback,{status:"done",name:t,file:e}),h){if(!V.IS_NODE_ENV&&n)throw new Error("Cannot return path in a browser environment.");return h}if(d instanceof Mt)return d.filePath;let g=await o?.match(u);if(g instanceof Mt)return g.filePath;if(g instanceof Response)return new Uint8Array(await g.arrayBuffer());if(typeof g=="string")return g;throw new Error("Unable to get model file path or buffer.")}async function zr(t,e,s=!0,r={},n=!1){if(!Y.allowLocalModels){if(r.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");if(!Y.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}gt(r.progress_callback,{status:"initiate",name:t,file:e});let o=await at(r?.cache_dir);return await qE(t,e,s,r,n,o)}async function jc(t,e,s=!0,r={}){let n=await zr(t,e,s,r,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function Ce(t,e,s=!0,r={}){let n=await jc(t,e,s,r);return n===null?{}:JSON.parse(n)}function h0(t,[e,s,r],[n,o],i="bilinear",a=!1){let l=o/r,c=n/s,p=new t.constructor(n*o*e),u=s*r,_=n*o;for(let d=0;d<n;++d)for(let m=0;m<o;++m){let h=d*o+m,g=(m+.5)/l-.5,x=(d+.5)/c-.5,w=Math.floor(g),y=Math.floor(x),b=Math.min(w+1,r-1),v=Math.min(y+1,s-1);w=Math.max(w,0),y=Math.max(y,0);let k=g-w,O=x-y,N=(1-k)*(1-O),q=k*(1-O),P=(1-k)*O,R=k*O,F=y*r,U=v*r,j=F+w,W=F+b,Z=U+w,te=U+b;for(let M=0;M<e;++M){let S=M*u;p[M*_+h]=N*t[S+j]+q*t[S+W]+P*t[S+Z]+R*t[S+te]}}return p}function g0(t,e,s){let r=new Array(s.length),n=new Array(s.length);for(let a=s.length-1,l=1;a>=0;--a)n[a]=l,r[a]=e[s[a]],l*=r[a];let o=s.map((a,l)=>n[s.indexOf(l)]),i=new t.constructor(t.length);for(let a=0;a<t.length;++a){let l=0;for(let c=e.length-1,p=a;c>=0;--c)l+=p%e[c]*o[c],p=Math.floor(p/e[c]);i[l]=t[a]}return[i,r]}function fe(t){let e=ue(t)[0],s=t.map(o=>Math.exp(o-e)),r=s.reduce((o,i)=>o+i,0);return s.map(o=>o/r)}function qc(t){let e=ue(t)[0],s=0;for(let o=0;o<t.length;++o)s+=Math.exp(t[o]-e);let r=Math.log(s);return t.map(o=>o-e-r)}function x0(t,e){let s=0;for(let r=0;r<t.length;++r)s+=t[r]*e[r];return s}function UE(t,e){let s=x0(t,e),r=m0(t),n=m0(e);return s/(r*n)}function m0(t){return Math.sqrt(t.reduce((e,s)=>e+s*s,0))}function Ir(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]<e&&(e=t[r],s=r);return[e,s]}function ue(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],s=0;for(let r=1;r<t.length;++r)t[r]>e&&(e=t[r],s=r);return[e,s]}function w0(t){return t>0&&(t&t-1)===0}var Zi=class{constructor(e){if(this.size=e|0,this.size<=1||!w0(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let r=0;r<this.table.length;r+=2){let n=Math.PI*r/this.size;this.table[r]=Math.cos(n),this.table[r+1]=-Math.sin(n)}let s=0;for(let r=1;this.size>r;r<<=1)++s;this._width=s%2===0?s-1:s,this._bitrev=new Int32Array(1<<this._width);for(let r=0;r<this._bitrev.length;++r){this._bitrev[r]=0;for(let n=0;n<this._width;n+=2){let o=this._width-n-2;this._bitrev[r]|=(r>>>n&3)<<o}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,s){let r=s||new Array(e.length>>>1);for(let n=0;n<e.length;n+=2)r[n>>>1]=e[n];return r}toComplexArray(e,s){let r=s||this.createComplexArray();for(let n=0;n<r.length;n+=2)r[n]=e[n>>>1],r[n+1]=0;return r}transform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._transform4(e,s,1)}realTransform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._realTransform4(e,s,1)}inverseTransform(e,s){if(e===s)throw new Error("Input and output buffers must be different");this._transform4(e,s,-1);for(let r=0;r<e.length;++r)e[r]/=this.size}_transform4(e,s,r){let n=this._csize,i=1<<this._width,a=n/i<<1,l,c,p=this._bitrev;if(a===4)for(l=0,c=0;l<n;l+=a,++c){let _=p[c];this._singleTransform2(s,e,l,_,i)}else for(l=0,c=0;l<n;l+=a,++c){let _=p[c];this._singleTransform4(s,e,l,_,i,r)}let u=this.table;for(i>>=2;i>=2;i>>=2){a=n/i<<1;let _=a>>>2;for(l=0;l<n;l+=a){let d=l+_-1;for(let m=l,h=0;m<d;m+=2,h+=i){let g=m,x=g+_,w=x+_,y=w+_,b=e[g],v=e[g+1],k=e[x],O=e[x+1],N=e[w],q=e[w+1],P=e[y],R=e[y+1],F=u[h],U=r*u[h+1],j=k*F-O*U,W=k*U+O*F,Z=u[2*h],te=r*u[2*h+1],M=N*Z-q*te,S=N*te+q*Z,T=u[3*h],H=r*u[3*h+1],he=P*T-R*H,se=P*H+R*T,Ke=b+M,We=v+S,xr=b-M,wr=v-S,ks=j+he,vs=W+se,yr=r*(j-he),br=r*(W-se);e[g]=Ke+ks,e[g+1]=We+vs,e[x]=xr+br,e[x+1]=wr-yr,e[w]=Ke-ks,e[w+1]=We-vs,e[y]=xr-br,e[y+1]=wr+yr}}}}_singleTransform2(e,s,r,n,o){let i=e[n],a=e[n+1],l=e[n+o],c=e[n+o+1];s[r]=i+l,s[r+1]=a+c,s[r+2]=i-l,s[r+3]=a-c}_singleTransform4(e,s,r,n,o,i){let a=o*2,l=o*3,c=e[n],p=e[n+1],u=e[n+o],_=e[n+o+1],d=e[n+a],m=e[n+a+1],h=e[n+l],g=e[n+l+1],x=c+d,w=p+m,y=c-d,b=p-m,v=u+h,k=_+g,O=i*(u-h),N=i*(_-g);s[r]=x+v,s[r+1]=w+k,s[r+2]=y+N,s[r+3]=b-O,s[r+4]=x-v,s[r+5]=w-k,s[r+6]=y-N,s[r+7]=b+O}_realTransform4(e,s,r){let n=this._csize,i=1<<this._width,a=n/i<<1,l,c,p=this._bitrev;if(a===4)for(l=0,c=0;l<n;l+=a,++c){let d=p[c];this._singleRealTransform2(s,e,l,d>>>1,i>>>1)}else for(l=0,c=0;l<n;l+=a,++c){let d=p[c];this._singleRealTransform4(s,e,l,d>>>1,i>>>1,r)}let u=this.table;for(i>>=2;i>=2;i>>=2){a=n/i<<1;let d=a>>>1,m=d>>>1,h=m>>>1;for(l=0;l<n;l+=a)for(let g=0,x=0;g<=h;g+=2,x+=i){let w=l+g,y=w+m,b=y+m,v=b+m,k=e[w],O=e[w+1],N=e[y],q=e[y+1],P=e[b],R=e[b+1],F=e[v],U=e[v+1],j=k,W=O,Z=u[x],te=r*u[x+1],M=N*Z-q*te,S=N*te+q*Z,T=u[2*x],H=r*u[2*x+1],he=P*T-R*H,se=P*H+R*T,Ke=u[3*x],We=r*u[3*x+1],xr=F*Ke-U*We,wr=F*We+U*Ke,ks=j+he,vs=W+se,yr=j-he,br=W-se,Ec=M+xr,Ac=S+wr,gy=r*(M-xr),xy=r*(S-wr);if(e[w]=ks+Ec,e[w+1]=vs+Ac,e[y]=yr+xy,e[y+1]=br-gy,g===0){e[b]=ks-Ec,e[b+1]=vs-Ac;continue}if(g===h)continue;let wy=l+m-g,yy=l+d-g;e[wy]=yr-r*xy,e[wy+1]=-br-r*gy,e[yy]=ks-r*Ec,e[yy+1]=-vs+r*Ac}}let _=n>>>1;for(let d=2;d<_;d+=2)e[n-d]=e[d],e[n-d+1]=-e[d+1]}_singleRealTransform2(e,s,r,n,o){let i=e[n],a=e[n+o];s[r]=i+a,s[r+1]=0,s[r+2]=i-a,s[r+3]=0}_singleRealTransform4(e,s,r,n,o,i){let a=o*2,l=o*3,c=e[n],p=e[n+o],u=e[n+a],_=e[n+l],d=c+u,m=c-u,h=p+_,g=i*(p-_);s[r]=d+h,s[r+1]=0,s[r+2]=m,s[r+3]=-g,s[r+4]=d-h,s[r+5]=0,s[r+6]=m,s[r+7]=g}},Bc=class{constructor(e){let s=2*(e-1),r=2*(2*e-1),n=2**Math.ceil(Math.log2(r));this.bufferSize=n,this._a=s;let o=new Float64Array(r),i=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);let a=-2*Math.PI/e,l=Math.cos(a),c=Math.sin(a);for(let p=0;p<r>>1;++p){let u=(p+1-e)**2/2,_=Math.sqrt(l**2+c**2)**u,d=u*Math.atan2(c,l),m=2*p;o[m]=_*Math.cos(d),o[m+1]=_*Math.sin(d),i[m]=o[m],i[m+1]=-o[m+1]}this._slicedChirpBuffer=o.subarray(s,r),this._f=new Zi(n>>1),this._f.transform(this._chirpBuffer,i)}_transform(e,s,r){let n=this._buffer1,o=this._buffer2,i=this._outBuffer1,a=this._outBuffer2,l=this._chirpBuffer,c=this._slicedChirpBuffer,p=this._a;if(r)for(let u=0;u<c.length;u+=2){let _=u+1,d=u>>1,m=s[d];n[u]=m*c[u],n[_]=m*c[_]}else for(let u=0;u<c.length;u+=2){let _=u+1;n[u]=s[u]*c[u]-s[_]*c[_],n[_]=s[u]*c[_]+s[_]*c[u]}this._f.transform(i,n);for(let u=0;u<l.length;u+=2){let _=u+1;o[u]=i[u]*l[u]-i[_]*l[_],o[_]=i[u]*l[_]+i[_]*l[u]}this._f.inverseTransform(a,o);for(let u=0;u<a.length;u+=2){let _=a[u+p],d=a[u+p+1],m=c[u],h=c[u+1];e[u]=_*m-d*h,e[u+1]=_*h+d*m}}transform(e,s){this._transform(e,s,!1)}realTransform(e,s){this._transform(e,s,!0)}},ea=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=w0(e),this.isPowerOfTwo?(this.fft=new Zi(e),this.outputBufferSize=2*e):(this.fft=new Bc(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,s){this.fft.realTransform(e,s)}transform(e,s){this.fft.transform(e,s)}};function y0(t,e){if(e%2===0||e<=0)throw new Error("Window size must be a positive odd number");let s=new t.constructor(t.length),r=new t.constructor(e),n=Math.floor(e/2);for(let o=0;o<t.length;++o){let i=0;for(let a=-n;a<=n;++a){let l=o+a;l<0?l=Math.abs(l):l>=t.length&&(l=2*(t.length-1)-l),r[i++]=t[l]}r.sort(),s[o]=r[n]}return s}function ts(t,e){let s=Math.pow(10,e);return Math.round(t*s)/s}function b0(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function k0(t){let e=t.length,s=t[0].length,r=[e+1,s+1],n=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));n[0][0]=0;let o=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let p=1;p<r[1];++p)for(let u=1;u<r[0];++u){let _=n[u-1][p-1],d=n[u-1][p],m=n[u][p-1],h,g;_<d&&_<m?(h=_,g=0):d<_&&d<m?(h=d,g=1):(h=m,g=2),n[u][p]=t[u-1][p-1]+h,o[u][p]=g}for(let p=0;p<r[1];++p)o[0][p]=2;for(let p=0;p<r[0];++p)o[p][0]=1;let i=e,a=s,l=[],c=[];for(;i>0||a>0;)switch(l.push(i-1),c.push(a-1),o[i][a]){case 0:--i,--a;break;case 1:--i;break;case 2:--a;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${i}, ${a}]. Please file a bug report.`)}return l.reverse(),c.reverse(),[l,c]}var v0=(function(){let t=null;return function(e){if(!t){t=new Float32Array(65536);let o=new ArrayBuffer(4),i=new Uint32Array(o),a=new Float32Array(o);for(let l=0;l<t.length;++l){let c=0,p=(l&32768)<<16,u=(l&31744)>>10,_=l&1023;if(u===31)c=p|2139095040|_<<13;else if(u===0)if(_===0)c=p;else{let d=113;for(;(_&1024)===0;)_<<=1,--d;_&=-1025,c=p|d<<23|_<<13}else c=p|u+112<<23|_<<13;i[0]=c,t[l]=a[0]}}let s=e.length,r=t,n=new Float32Array(s);for(let o=0;o<s;++o)n[o]=r[e[o]];return n}})();var Uc={};Es(Uc,{default:()=>GE});var GE={};import*as WE from"onnxruntime-web/webgpu";async function E0(t){let e=t.split("/").pop(),s;try{if(s=await at(),s){let n=await s.match(t);if(n)return n}}catch(n){$.warn(`Failed to load ${e} from cache:`,n)}let r=await Y.fetch(t);if(!r.ok)throw new Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);if(s)try{await s.put(t,r.clone())}catch(n){$.warn(`Failed to cache ${e}:`,n)}return r}async function A0(t){let e=await E0(t);if(!e||typeof e=="string")return null;try{return await e.arrayBuffer()}catch(s){return $.warn("Failed to read WASM binary:",s),null}}async function M0(t){if(V.IS_SERVICE_WORKER_ENV||V.IS_CHROME_AVAILABLE)return t;let e=await E0(t);if(!e||typeof e=="string")return null;try{let s=await e.text();s=s.replaceAll("globalThis.process?.versions?.node","false");let r=new Blob([s],{type:"text/javascript"});return URL.createObjectURL(r)}catch(s){return $.warn("Failed to read WASM factory:",s),null}}import{Tensor as C0}from"onnxruntime-common";var VE=Object.freeze({auto:null,gpu:null,cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:{name:"webnn",deviceType:"cpu"},"webnn-npu":{name:"webnn",deviceType:"npu"},"webnn-gpu":{name:"webnn",deviceType:"gpu"},"webnn-cpu":{name:"webnn",deviceType:"cpu"}});function I0(t){return t<=qe.DEBUG?0:t<=qe.INFO?2:t<=qe.WARNING||t<=qe.ERROR?3:4}var HE={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},Ze=[],Gc,Ts,S0=Symbol.for("onnxruntime");if(S0 in globalThis)Ts=globalThis[S0];else if(V.IS_NODE_ENV){switch(Ts=Uc,process.platform){case"win32":Ze.push("dml");break;case"linux":process.arch==="x64"&&Ze.push("cuda");break;case"darwin":Ze.push("coreml");break}Ze.push("webgpu"),Ze.push("cpu"),Gc=["cpu"]}else Ts=WE,V.IS_WEBNN_AVAILABLE&&Ze.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),V.IS_WEBGPU_AVAILABLE&&Ze.push("webgpu"),Ze.push("wasm"),Gc=["wasm"];var KE=Ts.InferenceSession;function T0(t=null){if(!t)return Gc;switch(t){case"auto":return Ze;case"gpu":return Ze.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(Ze.includes(t))return[VE[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${Ze.join(", ")}.`)}var O0=Promise.resolve(),Is=null;async function XE(){if(Is)return Is;if(!(Y.useWasmCache&&typeof ze?.wasm?.wasmPaths=="object"&&ze?.wasm?.wasmPaths?.wasm&&ze?.wasm?.wasmPaths?.mjs)){if(V.IS_DENO_WEB_RUNTIME)throw new Error("env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.");return Is=Promise.resolve(),Is}return Is=(async()=>{let e=ze.wasm.wasmPaths,s=!1;await Promise.all([e.wasm&&!$c(e.wasm)?(async()=>{try{let r=await A0(Fc(e.wasm));r&&(ze.wasm.wasmBinary=r,s=!0)}catch(r){$.warn("Failed to pre-load WASM binary:",r)}})():Promise.resolve(),e.mjs&&!$c(e.mjs)?(async()=>{try{let r=await M0(Fc(e.mjs));r&&(ze.wasm.wasmPaths.mjs=r)}catch(r){$.warn("Failed to pre-load WASM factory:",r)}})():Promise.resolve()]),s||(ze.wasm.wasmPaths.mjs=e.mjs)})(),Is}async function ta(t,e,s){await XE();let r=I0(Y.logLevel??qe.WARNING),n=()=>KE.create(t,{logSeverityLevel:r,...e}),o=await(V.IS_WEB_ENV?O0=O0.then(n):n());return o.config=s,o}var z0=Promise.resolve();async function sa(t,e){let s=()=>t.run(e);return V.IS_WEB_ENV?z0=z0.then(s):s()}function ra(t){return t instanceof Ts.Tensor}var ze=Ts?.env;function Tr(){return ze?.wasm?.proxy}if(ze){let t=function(e){let s=I0(e);ze.logLevel=HE[s]};if(ze.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&ze.versions?.web&&!ze.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${ze.versions.web}/dist/`;ze.wasm.wasmPaths=V.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`${e}ort-wasm-simd-threaded.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${e}ort-wasm-simd-threaded.asyncify.wasm`}}ze.wasm.proxy=!1}ze.webgpu&&(ze.webgpu.powerPreference="high-performance"),t(Y.logLevel??qe.WARNING),Y.backends.onnx={...ze,setLogLevel:t}}var Ct=async(t,e,s)=>{let r=await ta(new Uint8Array(t),e);return(async n=>{let o=Tr(),i=Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(o?c.clone():c).ort_tensor])),a=await sa(r,i);return Array.isArray(s)?s.map(l=>new E(a[l])):new E(a[s])})},dt=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=Ct([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,"y")),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||(this._bilinear_interpolate_4d=Ct([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||(this._bicubic_interpolate_4d=Ct([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||(this._matmul=Ct([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,"c")),this._matmul}static get stft(){return this._stft||(this._stft=Ct([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,"o")),this._stft}static get rfft(){return this._rfft||(this._rfft=Ct([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=Ct([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,["v","i"])),this._top_k}static get slice(){return this._slice||(this._slice=Ct([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,"y")),this._slice}};var P0=Object.freeze({auto:"auto",gpu:"gpu",cpu:"cpu",wasm:"wasm",webgpu:"webgpu",cuda:"cuda",dml:"dml",coreml:"coreml",webnn:"webnn","webnn-npu":"webnn-npu","webnn-gpu":"webnn-gpu","webnn-cpu":"webnn-cpu"}),Wc=V.IS_NODE_ENV?"cpu":"wasm";function na(t,e,{warn:s}={}){return t?typeof t=="string"?t:t.hasOwnProperty(e)?t[e]:(s&&s(`device not specified for "${e}". Using the default device (${Wc}).`),Wc):Wc}var $0=(function(){let t;return async function(){if(t===void 0)if(!V.IS_WEBGPU_AVAILABLE)t=!1;else try{t=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{t=!1}return t}})(),Re=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),N0=Re.fp32,L0=Object.freeze({[P0.wasm]:Re.q8}),Pt=Object.freeze({[Re.fp32]:"",[Re.fp16]:"_fp16",[Re.int8]:"_int8",[Re.uint8]:"_uint8",[Re.q8]:"_quantized",[Re.q4]:"_q4",[Re.q4f16]:"_q4f16",[Re.bnb4]:"_bnb4"});function oa(t,e,s,{configDtype:r=null,warn:n}={}){let o,i=!1;t&&typeof t!="string"?t.hasOwnProperty(e)?o=t[e]:(o=null,i=!0):o=t;let a;if(o===Re.auto){if(r){let l=typeof r=="string"?r:r?.[e];if(l&&l!==Re.auto&&Re.hasOwnProperty(l))return l}a=L0[s]??N0}else o&&Re.hasOwnProperty(o)?a=o:a=L0[s]??N0;return i&&n&&n(`dtype not specified for "${e}". Using the default dtype (${a}) for this device (${s}).`),a}var wt=Object.freeze({float32:Float32Array,float16:typeof Float16Array<"u"?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array});var E=class t{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return ra(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new C0(e[0],e[1],e[2]),new Proxy(this,{get:(s,r)=>{if(typeof r=="string"){let n=Number(r);if(Number.isInteger(n))return s._getitem(n)}return s[r]},set:(s,r,n)=>s[r]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...s]=this.dims;if(s.length>0){let r=s.reduce((n,o)=>n*o);for(let n=0;n<e;++n)yield this._subarray(n,r,s)}else yield*this.data}_getitem(e){let[s,...r]=this.dims;if(e=ft(e,s),r.length>0){let n=r.reduce((o,i)=>o*i);return this._subarray(e,n,r)}else return new t(this.type,[this.data[e]],r)}indexOf(e){let s=this.data;for(let r=0;r<s.length;++r)if(s[r]==e)return r;return-1}_subarray(e,s,r){let n=e*s,o=(e+1)*s,i="subarray"in this.data?this.data.subarray(n,o):this.data.slice(n,o);return new t(this.type,i,r)}item(){let e=this.data;if(e.length!==1)throw new Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return QE(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=1/(1+Math.exp(-e[s]));return this}map(e){return this.clone().map_(e)}map_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]=e(s[r],r,s);return this}mul(e){return this.clone().mul_(e)}mul_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let s=this.data;for(let r=0;r<s.length;++r)s[r]-=e;return this}clone(){return new t(this.type,this.data.slice(),this.dims.slice())}slice(...e){let s=[],r=[];for(let p=0;p<this.dims.length;++p){let u=e[p];if(u==null)r.push([0,this.dims[p]]),s.push(this.dims[p]);else if(typeof u=="number")u=ft(u,this.dims[p],p),r.push([u,u+1]);else if(Array.isArray(u)&&u.length===2){let[_,d]=u;if(_=_===null?0:ft(_,this.dims[p],p,!1),d=d===null?this.dims[p]:ft(d,this.dims[p],p,!1),_>d)throw new Error(`Invalid slice: ${u}`);let m=[Math.max(_,0),Math.min(d,this.dims[p])];r.push(m),s.push(m[1]-m[0])}else throw new Error(`Invalid slice: ${u}`)}let n=r.map(([p,u])=>u-p),o=n.reduce((p,u)=>p*u),i=this.data,a=new i.constructor(o),l=this.stride(),c=!0;for(let p=1;p<n.length;++p)if(r[p][0]!==0||r[p][1]!==this.dims[p]){c=!1;break}if(c){let p=r[0][0]*l[0],u=r[0][1]*l[0];if(ArrayBuffer.isView(i))a.set(i.subarray(p,u));else if(Array.isArray(i)){let _=i.slice(p,u);for(let d=0;d<_.length;++d)a[d]=_[d]}else throw new Error("Unsupported data type for slicing")}else for(let p=0;p<o;++p){let u=0;for(let _=n.length-1,d=p;_>=0;--_){let m=n[_];u+=(d%m+r[_][0])*l[_],d=Math.floor(d/m)}a[p]=i[u]}return new t(this.type,a,s)}permute(...e){return YE(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,s=!1){return this.norm(1,e,s)}norm(e="fro",s=null,r=!1){if(e==="fro")e=2;else if(typeof e=="string")throw Error(`Unsupported norm: ${e}`);let n=this.data,o=n instanceof BigInt64Array||n instanceof BigUint64Array;if(o&&e!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let i,a;if(o?(i=(u,_)=>u+_,a=0n):(i=(u,_)=>u+_**e,a=0),s===null){let u=n.reduce(i,a);return e!==1&&(u=u**(1/e)),new t(this.type,[u],[])}let[l,c,p]=Cr(i,this,s,r);if(e!==1)for(let u=0;u<c.length;++u)c[u]=c[u]**(1/e);return new t(l,c,p)}normalize_(e=2,s=1){s=ft(s,this.dims.length);let r=this.norm(e,s,!0),n=this.data,o=r.data;for(let i=0;i<n.length;++i){let a=0;for(let l=this.dims.length-1,c=i,p=1;l>=0;--l){let u=this.dims[l];if(l!==s){let _=c%u;a+=_*p,p*=this.dims[l]}c=Math.floor(c/u)}n[i]/=o[a]}return this}normalize(e=2,s=1){return this.clone().normalize_(e,s)}stride(){return Vc(this.dims)}squeeze(e=null){return new t(this.type,this.data,F0(this.dims,e))}squeeze_(e=null){return this.dims=F0(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,R0(this.dims,e))}unsqueeze_(e){return this.dims=R0(this.dims,e),this}flatten_(e=0,s=-1){s=(s+this.dims.length)%this.dims.length;let r=this.dims.slice(0,e),n=this.dims.slice(e,s+1),o=this.dims.slice(s+1);return this.dims=[...r,n.reduce((i,a)=>i*a,1),...o],this}flatten(e=0,s=-1){return this.clone().flatten_(e,s)}view(...e){let s=-1;for(let n=0;n<e.length;++n)if(e[n]===-1){if(s!==-1)throw new Error("Only one dimension can be inferred");s=n}let r=this.data;if(s!==-1){let n=e.reduce((o,i,a)=>a!==s?o*i:o,1);e[s]=r.length/n}return new t(this.type,r,e)}neg_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=-e[s];return this}neg(){return this.clone().neg_()}gt(e){let s=new Uint8Array(this.data.length),r=this.data;for(let n=0;n<r.length;++n)s[n]=r[n]>e?1:0;return new t("bool",s,this.dims)}lt(e){let s=new Uint8Array(this.data.length),r=this.data;for(let n=0;n<r.length;++n)s[n]=r[n]<e?1:0;return new t("bool",s,this.dims)}clamp_(e,s){let r=this.data;for(let n=0;n<r.length;++n)r[n]=Math.min(Math.max(r[n],e),s);return this}clamp(e,s){return this.clone().clamp_(e,s)}round_(){let e=this.data;for(let s=0;s<e.length;++s)e[s]=Math.round(e[s]);return this}round(){return this.clone().round_()}mean(e=null,s=!1){return la(this,e,s)}min(e=null,s=!1){if(e===null){let i=Ir(this.data)[0];return new t(this.type,[i],[])}let[r,n,o]=Cr((i,a)=>Math.min(i,a),this,e,s,1/0);return new t(r,n,o)}max(e=null,s=!1){if(e===null){let i=ue(this.data)[0];return new t(this.type,[i],[])}let[r,n,o]=Cr((i,a)=>Math.max(i,a),this,e,s,-1/0);return new t(r,n,o)}argmin(e=null,s=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let r=Ir(this.data)[1];return new t("int64",[BigInt(r)],[])}argmax(e=null,s=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let r=ue(this.data)[1];return new t("int64",[BigInt(r)],[])}repeat(...e){if(e.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${e.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(e.every(p=>p===1)){if(e.length===this.dims.length)return this.clone();let p=e.length-this.dims.length,u=Array(p).fill(1).concat(this.dims);return new t(this.type,this.data.slice(),u)}let s=e.length-this.dims.length,r=Array(s).fill(1).concat(this.dims),n=r.map((p,u)=>p*e[u]),o=n.reduce((p,u)=>p*u,1),i=this.data,a=new i.constructor(o),l=Vc(r),c=Vc(n);for(let p=0;p<o;++p){let u=p,_=0;for(let d=0;d<n.length;++d){let m=Math.floor(u/c[d]);u=u%c[d];let h=m%r[d];_+=h*l[d]}a[p]=i[_]}return new t(this.type,a,n)}tile(...e){if(e.length<this.dims.length){let s=this.dims.length-e.length;e=Array(s).fill(1).concat(e)}return this.repeat(...e)}to(e){if(this.type===e)return this;if(!wt.hasOwnProperty(e))throw new Error(`Unsupported type: ${e}`);let s,r=["int64","uint64"].includes(this.type),n=["int64","uint64"].includes(e);if(r&&!n)s=Number;else if(!r&&n)["float16","float32","float64"].includes(this.type)?s=o=>BigInt(Math.floor(o)):s=BigInt;else if(this.type==="float16"&&e=="float32"&&this.data instanceof Uint16Array)return new t(e,v0(this.data),this.dims);return new t(e,wt[e].from(this.data,s),this.dims)}};function QE(t,e){let s=t.length,r=e.reduce((o,i)=>o*i);if(s!==r)throw Error(`cannot reshape array of size ${s} into shape (${e})`);let n=t;for(let o=e.length-1;o>=0;o--)n=n.reduce((i,a)=>{let l=i[i.length-1];return l.length<e[o]?l.push(a):i.push([a]),i},[[]]);return n[0]}function YE(t,e){let[s,r]=g0(t.data,t.dims,e);return new E(t.type,s,r)}function Hc(t,[e,s],r="bilinear",n=!1){let o=t.dims.at(-3)??1,i=t.dims.at(-2),a=t.dims.at(-1),l=h0(t.data,[o,i,a],[e,s],r,n);return new E(t.type,l,[o,e,s])}async function De(t,{size:e=null,mode:s="bilinear"}={}){if(t.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!e)throw new Error("`interpolate_4d` requires a `size` argument.");let r;if(e.length===2)r=[...t.dims.slice(0,2),...e];else if(e.length===3)r=[t.dims[0],...e];else if(e.length===4)r=e;else throw new Error("`size` must be of length 2, 3, or 4.");let n;if(s==="nearest")n=await dt.nearest_interpolate_4d;else if(s==="bilinear")n=await dt.bilinear_interpolate_4d;else if(s==="bicubic")n=await dt.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${s}`);let o=new E("int64",new BigInt64Array(r.map(BigInt)),[r.length]);return await n({x:t,s:o})}async function D0(t,e){return await(await dt.matmul)({a:t,b:e})}async function N2(t,e){return await(await dt.rfft)({x:t,a:e})}async function lt(t,e){let s=await dt.top_k;return e==null?e=t.dims.at(-1):e=Math.min(e,t.dims.at(-1)),await s({x:t,k:new E("int64",[BigInt(e)],[1])})}var ia=t=>new E("int64",t,[t.length]);async function aa(t,e,s,r,n){return await(await dt.slice)({x:t,s:ia(e),e:ia(s),a:ia(r),t:ia(n??new Array(r.length).fill(1))})}function j0(t,e){let s=t.data,r=e.data,n=[t.dims[0],t.dims[2]],o=new s.constructor(n[0]*n[1]),[i,a,l]=t.dims,c=0;for(let p=0;p<i;++p){let u=p*l*a;for(let _=0;_<l;++_){let d=0,m=0,h=p*a,g=u+_;for(let w=0;w<a;++w){let y=Number(r[h+w]);m+=y,d+=s[g+w*l]*y}let x=d/m;o[c++]=x}}return new E(t.type,o,n)}function L2(t,e,{eps:s=1e-5}={}){if(t.dims.length!==2)throw new Error("`layer_norm` currently only supports 2D input.");let[r,n]=t.dims;if(e.length!==1&&e[0]!==n)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[o,i]=Kc(t,1,0,!0),a=o.data,l=i.data,c=t.data,p=new c.constructor(c.length);for(let u=0;u<r;++u){let _=u*n;for(let d=0;d<n;++d){let m=_+d;p[m]=(c[m]-l[u])/(a[u]+s)}}return new E(t.type,p,t.dims)}function F0(t,e){return t=t.slice(),e===null?t=t.filter(s=>s!==1):typeof e=="number"?t[e]===1&&t.splice(e,1):Array.isArray(e)&&(t=t.filter((s,r)=>s!==1||!e.includes(r))),t}function R0(t,e){return e=ft(e,t.length+1),t=t.slice(),t.splice(e,0,1),t}function ft(t,e,s=null,r=!0){if(t<-e||t>=e){if(r)throw new Error(`IndexError: index ${t} is out of bounds for dimension${s===null?"":" "+s} with size ${e}`);return t<-e?0:e}return t<0&&(t=(t%e+e)%e),t}function oe(t,e=0){e=ft(e,t[0].dims.length);let s=t[0].dims.slice();s[e]=t.reduce((i,a)=>i+a.dims[e],0);let r=s.reduce((i,a)=>i*a,1),n=new t[0].data.constructor(r),o=t[0].type;if(e===0){let i=0;for(let a of t){let l=a.data;n.set(l,i),i+=l.length}}else{let i=0;for(let a=0;a<t.length;++a){let{data:l,dims:c}=t[a];for(let p=0;p<l.length;++p){let u=0;for(let _=c.length-1,d=p,m=1;_>=0;--_){let h=c[_],g=d%h;_===e&&(g+=i),u+=g*m,m*=s[_],d=Math.floor(d/h)}n[u]=l[p]}i+=c[e]}}return new E(o,n,s)}function Ue(t,e=0){return oe(t.map(s=>s.unsqueeze(e)),e)}function Cr(t,e,s,r=!1,n=null){let o=e.data,i=e.dims;s=ft(s,i.length);let a=i.slice();a[s]=1;let l=new o.constructor(o.length/i[s]);n!==null&&l.fill(n);for(let c=0;c<o.length;++c){let p=0;for(let u=i.length-1,_=c,d=1;u>=0;--u){let m=i[u];if(u!==s){let h=_%m;p+=h*d,d*=a[u]}_=Math.floor(_/m)}l[p]=t(l[p],o[c],c,p)}return r||a.splice(s,1),[e.type,l,a]}function Kc(t,e=null,s=1,r=!1){let n=t.data,o=t.dims;if(e===null){let d=n.reduce((x,w)=>x+w,0)/n.length,m=Math.sqrt(n.reduce((x,w)=>x+(w-d)**2,0)/(n.length-s)),h=new E(t.type,[d],[]);return[new E(t.type,[m],[]),h]}e=ft(e,o.length);let i=la(t,e,r),a=i.data,[l,c,p]=Cr((_,d,m,h)=>_+(d-a[h])**2,t,e,r);for(let _=0;_<c.length;++_)c[_]=Math.sqrt(c[_]/(o[e]-s));return[new E(l,c,p),i]}function la(t,e=null,s=!1){let r=t.dims,n=t.data;if(e===null){let l=n.reduce((c,p)=>c+p,0);return new E(t.type,[l/n.length],[])}e=ft(e,r.length);let[o,i,a]=Cr((l,c)=>l+c,t,e,s);if(r[e]!==1)for(let l=0;l<i.length;++l)i[l]/=r[e];return new E(o,i,a)}function Vc(t){let e=new Array(t.length);for(let s=t.length-1,r=1;s>=0;--s)e[s]=r,r*=t[s];return e}function Xc(t,e,s,r){let n=t.reduce((o,i)=>o*i,1);return new E(s,new r(n).fill(e),t)}function be(t,e){let s,r;if(typeof e=="number")s="float32",r=Float32Array;else if(typeof e=="bigint")s="int64",r=BigInt64Array;else if(typeof e=="boolean")s="bool",r=Uint8Array;else throw new Error(`Unsupported data type: ${typeof e}`);return Xc(t,e,s,r)}function Pr(t,e){return be(t.dims,e)}function Ae(t){return Xc(t,1n,"int64",BigInt64Array)}function ca(t){return Ae(t.dims)}function Qc(t){return Xc(t,0n,"int64",BigInt64Array)}function Yc(t){return Qc(t.dims)}function $2(t){let e=t.reduce((s,r)=>s*r,1);return new E("float32",Float32Array.from({length:e},()=>es.random()),t)}function B0(t){let e=t.reduce((s,r)=>s*r,1);return new E("float32",Float32Array.from({length:e},()=>es.gauss()),t)}function q0(t,e){if(t.dims.length!==2)throw new Error("The tensor must have 2 dimensions");if(t.dims.at(-1)%8!==0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(e))throw new Error("The precision must be either 'binary' or 'ubinary'");let s=e==="binary",r=s?"int8":"uint8",n=s?Int8Array:Uint8Array,o=t.data,i=new n(o.length/8);for(let a=0;a<o.length;++a){let l=o[a]>0?1:0,c=Math.floor(a/8),p=a%8;i[c]|=l<<7-p,s&&p===0&&(i[c]-=128)}return new E(r,i,[t.dims[0],t.dims[1]/8])}async function Cs(t){if(!t)throw new Error("modelId is required for get_tokenizer_files");return(await Je(t,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function Jc(t,e){let s=await Cs(t);return await Promise.all(s.map(r=>Ce(t,r,!0,e)))}function Zc(t){let e=t.dims;switch(e.length){case 1:return t.tolist();case 2:if(e[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return t.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${e.length}.`)}}var JE=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function ZE(t,e,s,r){for(let n of Object.keys(t)){let o=e-t[n].length,i=s(n),a=new Array(o).fill(i);t[n]=r==="right"?$e(t[n],a):$e(a,t[n])}}function eA(t,e){for(let s of Object.keys(t))t[s].length=e}function ss(t,...e){for(let s of e){if(!Object.hasOwn(t,s))continue;let r=t[s];if(r)if(typeof r=="object"){if(r.__type==="AddedToken")return r.content;throw Error(`Unknown token: ${r}`)}else return r}return null}function tA(t){let e=[];for(let s of t.get_added_tokens_decoder().values())s.special&&e.push(s);return e}var I=class extends Se{return_token_type_ids=!1;padding_side="right";constructor(e,s){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=s,this._tokenizer=new Vy(e,s),this.config=s,this.padding_side=s.padding_side??this.padding_side,this.mask_token=ss(s,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=ss(s,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=ss(s,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=ss(s,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=ss(s,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=ss(s,"eos_token"),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=s.chat_template??null,Array.isArray(this.chat_template)){let n=Object.create(null);for(let{name:o,template:i}of this.chat_template){if(typeof o!="string"||typeof i!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');n[o]=i}this.chat_template=n}this._compiled_template_cache=new Map;let r=tA(this._tokenizer);this.all_special_ids=r.map(n=>n.id),this.all_special_tokens=r.map(n=>n.content)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main"}={}){let a=await Jc(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:i});return new this(...a)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e=="string"?this._tokenizer.token_to_id(e):e.map(s=>this._tokenizer.token_to_id(s))}_call(e,{text_pair:s=null,add_special_tokens:r=!0,padding:n=!1,truncation:o=null,max_length:i=null,return_tensor:a=!0,return_token_type_ids:l=null}={}){let c=Array.isArray(e),p;if(c){if(e.length===0)throw Error("text array must be non-empty");if(s!==null){if(Array.isArray(s)){if(e.length!==s.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");p=e.map((_,d)=>this._encode_plus(_,{text_pair:s[d],add_special_tokens:r,return_token_type_ids:l}))}else p=e.map(_=>this._encode_plus(_,{add_special_tokens:r,return_token_type_ids:l}))}else{if(e==null)throw Error("text may not be null or undefined");if(Array.isArray(s))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");p=[this._encode_plus(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:l})]}if(i===null?i=this.model_max_length:o===null&&(n===!0?($.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),i=this.model_max_length):n===!1&&($.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),n===!0&&(i=Math.min(ue(p.map(_=>_.input_ids.length))[0],i??1/0)),i=Math.min(i,this.model_max_length??1/0),n||o)for(let _=0;_<p.length;++_)p[_].input_ids.length!==i&&(p[_].input_ids.length>i?o&&eA(p[_],i):n&&ZE(p[_],i,d=>d==="input_ids"?this.pad_token_id:0,this.padding_side));let u={};if(a){if(!(n&&o)&&p.some(d=>{for(let m of Object.keys(d))if(d[m].length!==p[0][m]?.length)return!0;return!1}))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.");let _=[p.length,p[0].input_ids.length];for(let d of Object.keys(p[0]))u[d]=new E("int64",BigInt64Array.from(p.flatMap(m=>m[d]).map(BigInt)),_)}else{for(let _ of Object.keys(p[0]))u[_]=p.map(d=>d[_]);if(!c)for(let _ of Object.keys(u))u[_]=u[_][0]}return u}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:s=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){let{ids:o,attention_mask:i,token_type_ids:a}=this._tokenizer.encode(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:n??this.return_token_type_ids});return{input_ids:o,attention_mask:i,...a?{token_type_ids:a}:{}}}tokenize(e,{pair:s=null,add_special_tokens:r=!1}={}){return this._tokenizer.tokenize(e,{text_pair:s,add_special_tokens:r})}encode(e,{text_pair:s=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){return this._tokenizer.encode(e,{text_pair:s,add_special_tokens:r,return_token_type_ids:n}).ids}batch_decode(e,s={}){return e instanceof E&&(e=e.tolist()),e.map(r=>this.decode(r,s))}decode(e,s={}){if(e instanceof E&&(e=Zc(e)),!Array.isArray(e)||e.length===0||!Oy(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,s)}decode_single(e,{skip_special_tokens:s=!1,clean_up_tokenization_spaces:r=null}){return this._tokenizer.decode(e,{skip_special_tokens:s,clean_up_tokenization_spaces:r})}get_chat_template({chat_template:e=null,tools:s=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){let r=this.chat_template;if(e!==null&&Object.hasOwn(r,e))e=r[e];else if(e===null)if(s!==null&&"tool_use"in r)e=r.tool_use;else if("default"in r)e=r.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(r).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,{tools:s=null,documents:r=null,chat_template:n=null,add_generation_prompt:o=!1,tokenize:i=!0,padding:a=!1,truncation:l=!1,max_length:c=null,return_tensor:p=!0,return_dict:u=!0,tokenizer_kwargs:_={},...d}={}){if(n=this.get_chat_template({chat_template:n,tools:s}),typeof n!="string")throw Error(`chat_template must be a string, but got ${typeof n}`);let m=this._compiled_template_cache.get(n);m===void 0&&(m=new n0(n),this._compiled_template_cache.set(n,m));let h=Object.create(null);for(let x of JE){let w=ss(this.config,x);w&&(h[x]=w)}let g=m.render({messages:e,add_generation_prompt:o,tools:s,documents:r,...h,...d});if(i){let x=this._call(g,{add_special_tokens:!1,padding:a,truncation:l,max_length:c,return_tensor:p,..._});return u?x:x.input_ids}return g}};function Ps(t,e,s,r){if(!("language_codes"in t)||!Array.isArray(t.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in t)||!(t.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in t)||typeof t.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let n=r.src_lang,o=r.tgt_lang;if(!t.language_codes.includes(o))throw new Error(`Target language code "${o}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);if(n!==void 0){if(!t.language_codes.includes(n))throw new Error(`Source language code "${n}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);for(let i of t._tokenizer.post_processor.config.single)if("SpecialToken"in i&&t.languageRegex.test(i.SpecialToken.id)){i.SpecialToken.id=t.lang_to_token(n);break}}return r.forced_bos_token_id=t._tokenizer.token_to_id(t.lang_to_token(o)),t._call(e,s)}var Wp={};Es(Wp,{AlbertTokenizer:()=>ep,AutoTokenizer:()=>G,BartTokenizer:()=>tp,BertTokenizer:()=>sp,BlenderbotSmallTokenizer:()=>rp,BlenderbotTokenizer:()=>np,BloomTokenizer:()=>op,CLIPTokenizer:()=>ap,CamembertTokenizer:()=>ip,CodeGenTokenizer:()=>cp,CodeLlamaTokenizer:()=>lp,CohereAsrTokenizer:()=>up,CohereTokenizer:()=>pp,ConvBertTokenizer:()=>_p,DebertaTokenizer:()=>fp,DebertaV2Tokenizer:()=>dp,DistilBertTokenizer:()=>mp,ElectraTokenizer:()=>hp,EsmTokenizer:()=>gp,FalconTokenizer:()=>xp,GPT2Tokenizer:()=>bp,GPTNeoXTokenizer:()=>yp,GemmaTokenizer:()=>wp,HerbertTokenizer:()=>kp,LlamaTokenizer:()=>vp,M2M100Tokenizer:()=>Ep,MBart50Tokenizer:()=>Mp,MBartTokenizer:()=>Nr,MPNetTokenizer:()=>zp,MarianTokenizer:()=>Ap,MgpstrTokenizer:()=>Sp,MobileBertTokenizer:()=>Op,NllbTokenizer:()=>Ip,NougatTokenizer:()=>Tp,PreTrainedTokenizer:()=>I,Qwen2Tokenizer:()=>Cp,RoFormerTokenizer:()=>Np,RobertaTokenizer:()=>Pp,SiglipTokenizer:()=>Lp,SpeechT5Tokenizer:()=>$p,SqueezeBertTokenizer:()=>Fp,T5Tokenizer:()=>Rp,TokenizersBackend:()=>I,VitsTokenizer:()=>jp,Wav2Vec2CTCTokenizer:()=>Bp,WhisperTokenizer:()=>qp,XLMRobertaTokenizer:()=>Up,XLMTokenizer:()=>Gp});var ep=class extends I{return_token_type_ids=!0};var tp=class extends I{};var sp=class extends I{return_token_type_ids=!0};var rp=class extends I{};var np=class extends I{};var op=class extends I{};var ip=class extends I{};var ap=class extends I{};var lp=class extends I{};var cp=class extends I{};var pp=class extends I{};var up=class extends I{};var _p=class extends I{return_token_type_ids=!0};var dp=class extends I{return_token_type_ids=!0};var fp=class extends I{return_token_type_ids=!0};var mp=class extends I{};var hp=class extends I{return_token_type_ids=!0};var gp=class extends I{};var xp=class extends I{};var wp=class extends I{};var yp=class extends I{};var bp=class extends I{};var kp=class extends I{return_token_type_ids=!0};var vp=class extends I{padding_side="left"};var Ep=class extends I{constructor(e,s){super(e,s),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r.slice(2,-2)),this.lang_to_token=r=>`__${r}__`}_build_translation_inputs(e,s,r){return Ps(this,e,s,r)}};var Ap=class extends I{constructor(e,s){super(e,s),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(r=>this.languageRegex.test(r)),$.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[s,...r]=e.trim().split(this.languageRegex);if(r.length===0)return super._encode_text(s);if(r.length===2){let[n,o]=r;return this.supported_language_codes.includes(n)||$.warn(`Unsupported language code "${n}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),$e([n],super._encode_text(o))}}};var Nr=class extends I{constructor(e,s){super(e,s),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r),this.lang_to_token=r=>r}_build_translation_inputs(e,s,r){return Ps(this,e,s,r)}};var Mp=class extends Nr{};var Sp=class extends I{};var Op=class extends I{return_token_type_ids=!0};var zp=class extends I{};var Ip=class extends I{constructor(e,s){super(e,s),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)),this.lang_to_token=r=>r}_build_translation_inputs(e,s,r){return Ps(this,e,s,r)}};var Tp=class extends I{};var Cp=class extends I{};var Pp=class extends I{};var Np=class extends I{return_token_type_ids=!0};var Lp=class extends I{};var $p=class extends I{};var Fp=class extends I{return_token_type_ids=!0};var Rp=class extends I{};var Dp=class extends Qe{decode_chain(e){let s="";for(let r=1;r<e.length;r+=2)s+=e[r];return[s]}},jp=class extends I{constructor(e,s){super(e,s),this._tokenizer.decoder=new Dp({type:"VitsDecoder"})}};var Bp=class extends I{};var U0=[["en","english"],["zh","chinese"],["de","german"],["es","spanish"],["ru","russian"],["ko","korean"],["fr","french"],["ja","japanese"],["pt","portuguese"],["tr","turkish"],["pl","polish"],["ca","catalan"],["nl","dutch"],["ar","arabic"],["sv","swedish"],["it","italian"],["id","indonesian"],["hi","hindi"],["fi","finnish"],["vi","vietnamese"],["he","hebrew"],["uk","ukrainian"],["el","greek"],["ms","malay"],["cs","czech"],["ro","romanian"],["da","danish"],["hu","hungarian"],["ta","tamil"],["no","norwegian"],["th","thai"],["ur","urdu"],["hr","croatian"],["bg","bulgarian"],["lt","lithuanian"],["la","latin"],["mi","maori"],["ml","malayalam"],["cy","welsh"],["sk","slovak"],["te","telugu"],["fa","persian"],["lv","latvian"],["bn","bengali"],["sr","serbian"],["az","azerbaijani"],["sl","slovenian"],["kn","kannada"],["et","estonian"],["mk","macedonian"],["br","breton"],["eu","basque"],["is","icelandic"],["hy","armenian"],["ne","nepali"],["mn","mongolian"],["bs","bosnian"],["kk","kazakh"],["sq","albanian"],["sw","swahili"],["gl","galician"],["mr","marathi"],["pa","punjabi"],["si","sinhala"],["km","khmer"],["sn","shona"],["yo","yoruba"],["so","somali"],["af","afrikaans"],["oc","occitan"],["ka","georgian"],["be","belarusian"],["tg","tajik"],["sd","sindhi"],["gu","gujarati"],["am","amharic"],["yi","yiddish"],["lo","lao"],["uz","uzbek"],["fo","faroese"],["ht","haitian creole"],["ps","pashto"],["tk","turkmen"],["nn","nynorsk"],["mt","maltese"],["sa","sanskrit"],["lb","luxembourgish"],["my","myanmar"],["bo","tibetan"],["tl","tagalog"],["mg","malagasy"],["as","assamese"],["tt","tatar"],["haw","hawaiian"],["ln","lingala"],["ha","hausa"],["ba","bashkir"],["jw","javanese"],["su","sundanese"]],Lr=new Map(U0),sA=new Map([...U0.map(([t,e])=>[e,t]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function G0(t){t=t.toLowerCase();let e=sA.get(t);if(e===void 0){let s=t.match(/^<\|([a-z]{2})\|>$/);if(s&&(t=s[1]),Lr.has(t))e=t;else{let n=t.length===2?Lr.keys():Lr.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var rA="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",W0=new RegExp(`^[${rA}]+$`,"gu"),qp=class extends I{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:s=!1,return_language:r=!1,time_precision:n=null,force_full_sequences:o=!0}={}){if(n===null)throw Error("Must specify time_precision");let i=null,a=s==="word";function l(){return{language:i,timestamp:[null,null],text:""}}let c=[],p=l(),u=0,_=this.timestamp_begin,m=_+1500,h=[],g=[],x=!1,w=null,y=new Set(this.all_special_ids);for(let k of e){let O=k.tokens,N=a?k.token_timestamps:null,q=null,P=_;if("stride"in k){let[U,j,W]=k.stride;if(u-=j,w=U-W,j&&(P=j/n+_),W)for(let Z=O.length-1;Z>=0;--Z){let te=Number(O[Z]);if(te>=_){if(q!==null&&(te-_)*n<w)break;q=te}}}let R=[],F=[];for(let U=0;U<O.length;++U){let j=Number(O[U]);if(y.has(j)){let W=this.decode([j]),Z=Lr.get(W.slice(2,-2));if(Z!==void 0){if(i!==null&&Z!==i&&!s){h.push(R);let te=this.findLongestCommonSequence(h)[0],M=this.decode(te);p.text=M,c.push(p),h=[],R=[],p=l()}i=p.language=Z}}else if(j>=_&&j<=m){let W=(j-_)*n+u,Z=ts(W,2);if(q!==null&&j>=q)x=!0;else if(x||h.length>0&&j<P)x=!1;else if(p.timestamp[0]===null)p.timestamp[0]=Z;else if(Z!==p.timestamp[0]){p.timestamp[1]=Z,h.push(R),a&&g.push(F);let[te,M]=this.findLongestCommonSequence(h,g),S=this.decode(te);p.text=S,a&&(p.words=this.collateWordTimestamps(te,M,i)),c.push(p),h=[],R=[],g=[],F=[],p=l()}}else if(R.push(j),a){let W=ts(N[U]+u,2),Z;if(U+1<N.length){Z=ts(N[U+1]+u,2);let te=this.decode([j]);W0.test(te)&&(Z=ts(Math.min(W+n,Z),2))}else Z=null;F.push([W,Z])}}if("stride"in k){let[U,j,W]=k.stride;u+=U-W}R.length>0?(h.push(R),a&&g.push(F)):h.every(U=>U.length===0)&&(p=l(),h=[],R=[],g=[],F=[])}if(h.length>0){if(o&&s)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");let[k,O]=this.findLongestCommonSequence(h,g),N=this.decode(k);p.text=N,a&&(p.words=this.collateWordTimestamps(k,O,i)),c.push(p)}let b=Object.create(null),v=c.map(k=>k.text).join("");if(s||r){for(let k=0;k<c.length;++k){let O=c[k];s||delete O.timestamp,r||delete O.language}if(a){let k=[];for(let O of c)for(let N of O.words)k.push(N);b={chunks:k}}else b={chunks:c}}return[v,b]}findLongestCommonSequence(e,s=null){let r=e[0],n=r.length,o=[],i=Array.isArray(s)&&s.length>0,a=i?[]:null,l=i?s[0]:null;for(let c=1;c<e.length;++c){let p=e[c],u=0,_=[n,n,0,0],d=p.length;for(let b=1;b<n+d;++b){let v=Math.max(0,n-b),k=Math.min(n,n+d-b),O=r.slice(v,k),N=Math.max(0,b-n),q=Math.min(d,b),P=p.slice(N,q);if(O.length!==P.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let R;i?R=O.filter((j,W)=>j===P[W]&&l[v+W]<=s[c][N+W]).length:R=O.filter((j,W)=>j===P[W]).length;let F=b/1e4,U=R/b+F;R>1&&U>u&&(u=U,_=[v,k,N,q])}let[m,h,g,x]=_,w=Math.floor((h+m)/2),y=Math.floor((x+g)/2);o.push(...r.slice(0,w)),r=p.slice(y),n=r.length,i&&(a.push(...l.slice(0,w)),l=s[c].slice(y))}return o.push(...r),i?(a.push(...l),[o,a]):[o,[]]}collateWordTimestamps(e,s,r){let[n,o,i]=this.combineTokensIntoWords(e,r),a=[];for(let l=0;l<n.length;++l){let c=i[l];a.push({text:n[l],timestamp:[s[c.at(0)][0],s[c.at(-1)][1]]})}return a}combineTokensIntoWords(e,s,r=`"'\u201C\xA1\xBF([{-`,n=`"'.\u3002,\uFF0C!\uFF01?\uFF1F:\uFF1A\u201D)]}\u3001`){s=s??"english";let o,i,a;return["chinese","japanese","thai","lao","myanmar"].includes(s)?[o,i,a]=this.splitTokensOnUnicode(e):[o,i,a]=this.splitTokensOnSpaces(e),this.mergePunctuations(o,i,a,r,n)}decode(e,s){let r;return s?.decode_with_timestamps?(e instanceof E&&(e=Zc(e)),r=this.decodeWithTimestamps(e,s)):r=super.decode(e,s),r}decodeWithTimestamps(e,s){let r=s?.time_precision??.02,n=this.all_special_ids.at(-1)+1,o=[[]];for(let i of e)if(i=Number(i),i>=n){let a=((i-n)*r).toFixed(2);o.push(`<|${a}|>`),o.push([])}else o[o.length-1].push(i);return o=o.map(i=>typeof i=="string"?i:super.decode(i,s)),o.join("")}splitTokensOnUnicode(e){let s=this.decode(e,{decode_with_timestamps:!0}),r="\uFFFD",n=[],o=[],i=[],a=[],l=[],c=0;for(let p=0;p<e.length;++p){let u=e[p];a.push(u),l.push(p);let _=this.decode(a,{decode_with_timestamps:!0});(!_.includes(r)||s[c+_.indexOf(r)]===r)&&(n.push(_),o.push(a),i.push(l),a=[],l=[],c+=_.length)}return[n,o,i]}splitTokensOnSpaces(e){let[s,r,n]=this.splitTokensOnUnicode(e),o=[],i=[],a=[];for(let l=0;l<s.length;++l){let c=s[l],p=r[l],u=n[l],_=p[0]>=this._tokenizer.token_to_id("<|endoftext|>"),d=c.startsWith(" "),m=c.trim(),h=W0.test(m);if(_||d||h||o.length===0)o.push(c),i.push(p),a.push(u);else{let g=o.length-1;o[g]+=c,i[g].push(...p),a[g].push(...u)}}return[o,i,a]}mergePunctuations(e,s,r,n,o){let i=structuredClone(e),a=structuredClone(s),l=structuredClone(r),c=i.length-2,p=i.length-1;for(;c>=0;)i[c].startsWith(" ")&&n.includes(i[c].trim())?(i[p]=i[c]+i[p],a[p]=$e(a[c],a[p]),l[p]=$e(l[c],l[p]),i[c]="",a[c]=[],l[c]=[]):p=c,--c;for(c=0,p=1;p<i.length;)!i[c].endsWith(" ")&&o.includes(i[p])?(i[c]+=i[p],a[c]=$e(a[c],a[p]),l[c]=$e(l[c],l[p]),i[p]="",a[p]=[],l[p]=[]):c=p,++p;return[i.filter(u=>u),a.filter(u=>u.length>0),l.filter(u=>u.length>0)]}};var Up=class extends I{};var Gp=class extends I{return_token_type_ids=!0;constructor(e,s){super(e,s),$.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}};var G=class{static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main"}={}){let[a,l]=await Jc(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:i}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",p=Wp[c];return p||($.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),p=I),new p(a,l)}};var Nt="https://github.com/huggingface/transformers.js/issues/new/choose";var $r="preprocessor_config.json",yt=$r,V0="processor_config.json",H0="chat_template.jinja";var B=class extends Se{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,s,r){super(),this.config=e,this.components=s,this.chat_template=r}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,s={}){if(!this.tokenizer)throw new Error("Unable to apply chat template without a tokenizer.");return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...s})}batch_decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.decode(...e)}async _call(e,...s){for(let r of[this.image_processor,this.feature_extractor,this.tokenizer])if(r)return r(e,...s);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,s={}){let[r,n,o]=await Promise.all([this.uses_processor_config?Ce(e,V0,!0,s):{},Promise.all(this.classes.filter(i=>i in this).map(async i=>{let a=await this[i].from_pretrained(e,s);return[i.replace(/_class$/,""),a]})).then(Object.fromEntries),this.uses_chat_template_file?jc(e,H0,!0,s):null]);return new this(r,n,o)}};var La={};Es(La,{ChatterboxProcessor:()=>lu,CohereAsrProcessor:()=>cu,Florence2Processor:()=>t_,Gemma3Processor:()=>s_,Gemma3nProcessor:()=>r_,Glm46VProcessor:()=>n_,GraniteSpeechProcessor:()=>o_,GroundingDinoProcessor:()=>i_,Idefics3Processor:()=>Ta,JinaCLIPProcessor:()=>l_,Lfm2VlProcessor:()=>c_,LlavaProcessor:()=>p_,MgpstrProcessor:()=>u_,MoonshineProcessor:()=>__,OwlViTProcessor:()=>d_,PaliGemmaProcessor:()=>f_,Phi3VProcessor:()=>m_,PixtralProcessor:()=>h_,Processor:()=>B,PyAnnoteProcessor:()=>g_,Qwen2VLProcessor:()=>ns,Qwen2_5_VLProcessor:()=>Wr,Qwen3VLProcessor:()=>x_,Sam2Processor:()=>Ca,Sam2VideoProcessor:()=>w_,SamProcessor:()=>Vr,SmolVLMProcessor:()=>Ta,SpeechT5Processor:()=>y_,UltravoxProcessor:()=>b_,VLChatProcessor:()=>a_,VoxtralProcessor:()=>k_,VoxtralRealtimeProcessor:()=>E_,Wav2Vec2Processor:()=>A_,Wav2Vec2ProcessorWithLM:()=>M_,WhisperProcessor:()=>S_});var ae=class extends Se{constructor(e){super(),this.config=e}static async from_pretrained(e,s={}){let r=await Ce(e,$r,!0,s);return new this(r)}};function _e(t,e){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error(`${e} expects input to be a Float32Array or a Float64Array, but got ${t?.constructor?.name??typeof t} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var qr={};Es(qr,{ASTFeatureExtractor:()=>Kp,ChatterboxFeatureExtractor:()=>Xp,ClapFeatureExtractor:()=>Qp,CohereAsrFeatureExtractor:()=>Yp,DacFeatureExtractor:()=>jr,EncodecFeatureExtractor:()=>Rr,FeatureExtractor:()=>ae,Gemma3nAudioFeatureExtractor:()=>Jp,GraniteSpeechFeatureExtractor:()=>Zp,MoonshineFeatureExtractor:()=>eu,ParakeetFeatureExtractor:()=>Dr,PyAnnoteFeatureExtractor:()=>Br,SeamlessM4TFeatureExtractor:()=>tu,SnacFeatureExtractor:()=>su,SpeechT5FeatureExtractor:()=>ru,VoxtralRealtimeFeatureExtractor:()=>iu,Wav2Vec2FeatureExtractor:()=>nu,WeSpeakerFeatureExtractor:()=>ou,WhisperFeatureExtractor:()=>au});var nA=()=>{};var K0={fromWeb:nA};var oA=()=>{};var X0=oA;async function pa(t,e){if(V.IS_BROWSER_ENV){if(V.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");let s=URL.createObjectURL(e),r=document.createElement("a");r.href=s,r.download=t,r.click(),r.remove(),URL.revokeObjectURL(s)}else if(V.IS_FS_AVAILABLE){let s=e.stream(),r=K0.fromWeb(s),n=Le.createWriteStream(t);await X0(r,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function Hp(t,e){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let s=await(await zt(t)).arrayBuffer(),r=new AudioContext({sampleRate:e});typeof e>"u"&&$.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let n=await r.decodeAudioData(s),o;if(n.numberOfChannels===2){let i=Math.sqrt(2),a=n.getChannelData(0),l=n.getChannelData(1);o=new Float32Array(a.length);for(let c=0;c<n.length;++c)o[c]=i*(a[c]+l[c])/2}else o=n.getChannelData(0);return o}function J0(t,e){if(t<1)return new Float64Array;if(t===1)return new Float64Array([1]);let s=1-e,r=2*Math.PI/(t-1),n=new Float64Array(t);for(let o=0;o<t;++o)n[o]=e-s*Math.cos(o*r);return n}function Q0(t){return J0(t,.5)}function iA(t){return J0(t,.54)}var aA={htk:t=>2595*Math.log10(1+t/700),kaldi:t=>1127*Math.log(1+t/700),slaney:(t,e=1e3,s=15,r=27/Math.log(6.4))=>t>=e?s+Math.log(t/e)*r:3*t/200};function Vp(t,e="htk"){let s=aA[e];if(!s)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?s(t):t.map(r=>s(r))}var lA={htk:t=>700*(10**(t/2595)-1),kaldi:t=>700*(Math.exp(t/1127)-1),slaney:(t,e=1e3,s=15,r=Math.log(6.4)/27)=>t>=s?e*Math.exp(r*(t-s)):200*t/3};function cA(t,e="htk"){let s=lA[e];if(!s)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?s(t):t.map(r=>s(r))}function pA(t,e){let s=Float64Array.from({length:e.length-1},(i,a)=>e[a+1]-e[a]),r=Array.from({length:t.length},()=>new Array(e.length));for(let i=0;i<t.length;++i){let a=r[i];for(let l=0;l<e.length;++l)a[l]=e[l]-t[i]}let n=e.length-2,o=Array.from({length:n},()=>new Array(t.length));for(let i=0;i<t.length;++i){let a=r[i];for(let l=0;l<n;++l){let c=-a[l]/s[l],p=a[l+2]/s[l+1];o[l][i]=Math.max(0,Math.min(c,p))}}return o}function Y0(t,e,s){let r=(e-t)/(s-1);return Float64Array.from({length:s},(n,o)=>t+r*o)}function Ie(t,e,s,r,n,o=null,i="htk",a=!1){if(o!==null&&o!=="slaney")throw new Error('norm must be one of null or "slaney"');if(t<2)throw new Error(`Require num_frequency_bins: ${t} >= 2`);if(s>r)throw new Error(`Require min_frequency: ${s} <= max_frequency: ${r}`);let l=Vp(s,i),c=Vp(r,i),p=Y0(l,c,e+2),u=cA(p,i),_;if(a){let m=n/((t-1)*2);_=Vp(Float64Array.from({length:t},(h,g)=>g*m),i),u=p}else _=Y0(0,Math.floor(n/2),t);let d=pA(_,u);if(o!==null&&o==="slaney")for(let m=0;m<e;++m){let h=d[m],g=2/(u[m+2]-u[m]);for(let x=0;x<t;++x)h[x]*=g}return d}function uA(t,e,s){let r=new t.constructor(t.length+e+s),n=t.length-1;for(let o=0;o<t.length;++o)r[e+o]=t[o];for(let o=1;o<=e;++o)r[e-o]=t[Ms(o,n)];for(let o=1;o<=s;++o)r[n+e+o]=t[Ms(n-o,n)];return r}function Z0(t,e,s,r,n){if(s<=0)throw new Error("reference must be greater than zero");if(r<=0)throw new Error("min_value must be greater than zero");s=Math.max(r,s);let o=Math.log10(s);for(let i=0;i<t.length;++i)t[i]=e*Math.log10(Math.max(r,t[i])-o);if(n!==null){if(n<=0)throw new Error("db_range must be greater than zero");let i=ue(t)[0]-n;for(let a=0;a<t.length;++a)t[a]=Math.max(t[a],i)}return t}function _A(t,e=1,s=1e-5,r=null){return Z0(t,20,e,s,r)}function dA(t,e=1,s=1e-10,r=null){return Z0(t,10,e,s,r)}async function Pe(t,e,s,r,{fft_length:n=null,power:o=1,center:i=!0,pad_mode:a="reflect",onesided:l=!0,preemphasis:c=null,preemphasis_htk_flavor:p=!0,mel_filters:u=null,mel_floor:_=1e-10,log_mel:d=null,max_log_mel:m=null,reference:h=1,min_value:g=1e-10,db_range:x=null,remove_dc_offset:w=null,min_num_frames:y=null,max_num_frames:b=null,do_pad:v=!0,transpose:k=!1,mel_offset:O=0}={}){let N=e.length;if(n===null&&(n=s),s>n)throw Error(`frame_length (${s}) may not be larger than fft_length (${n})`);if(N!==s)throw new Error(`Length of the window (${N}) must equal frame_length (${s})`);if(r<=0)throw new Error("hop_length must be greater than zero");if(o===null&&u!==null)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!p)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(i)switch(a){case"reflect":{let T=Math.floor((n-1)/2)+1;t=uA(t,T,T);break}case"constant":{let T=Math.floor(n/2),H=new t.constructor(t.length+2*T);H.set(t,T),t=H;break}default:throw new Error(`pad_mode="${a}" not implemented yet.`)}let q=Math.floor(1+Math.floor((t.length-s)/r));y!==null&&q<y&&(q=y);let P=l?Math.floor(n/2)+1:n,R=q,F=q;b!==null&&(b>q?v&&(F=b):F=R=b);let U=new ea(n),j=new Float64Array(n),W=new Float64Array(U.outputBufferSize),Z=new Float32Array(P*F);for(let T=0;T<R;++T){let H=T*r,he=Math.min(t.length-H,s);he!==s&&j.fill(0,0,s);for(let se=0;se<he;++se)j[se]=t[H+se];if(w){let se=0;for(let We=0;We<he;++We)se+=j[We];let Ke=se/he;for(let We=0;We<he;++We)j[We]-=Ke}if(c!==null){for(let se=he-1;se>=1;--se)j[se]-=c*j[se-1];j[0]*=1-c}for(let se=0;se<e.length;++se)j[se]*=e[se];U.realTransform(W,j);for(let se=0;se<P;++se){let Ke=se<<1;Z[se*F+T]=W[Ke]**2+W[Ke+1]**2}}if(o!==null&&o!==2){let T=o/2;for(let H=0;H<Z.length;++H)Z[H]**=T}let te=u.length,M=await D0(new E("float32",u.flat(),[te,P]),new E("float32",Z,[P,F]));k&&(M=M.transpose(1,0));let S=M.data;for(let T=0;T<S.length;++T)S[T]=O+Math.max(_,S[T]);if(o!==null&&d!==null){let T=Math.min(S.length,R*te);switch(d){case"log":for(let H=0;H<T;++H)S[H]=Math.log(S[H]);break;case"log10":for(let H=0;H<T;++H)S[H]=Math.log10(S[H]);break;case"log10_max_norm":{for(let se=0;se<T;++se)S[se]=Math.log10(S[se]);let he=(m??ue(S)[0])-8;for(let se=0;se<T;++se)S[se]=(Math.max(S[se],he)+4)/4;break}case"dB":if(o===1)_A(S,h,g,x);else if(o===2)dA(S,h,g,x);else throw new Error(`Cannot use log_mel option '${d}' with power ${o}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${d}'`)}}return M}function Ne(t,e,{periodic:s=!0,frame_length:r=null,center:n=!0}={}){let o=s?t+1:t,i;switch(e){case"boxcar":i=new Float64Array(o).fill(1);break;case"hann":case"hann_window":i=Q0(o);break;case"hamming":i=iA(o);break;case"povey":i=Q0(o).map(a=>Math.pow(a,.85));break;default:throw new Error(`Unknown window type ${e}.`)}if(s&&(i=i.subarray(0,t)),r===null)return i;if(t>r)throw new Error(`Length of the window (${t}) may not be larger than frame_length (${r})`);return i}function fA(t,e){let s=t.reduce((o,i)=>o+i.length,0),r=new ArrayBuffer(44),n=new DataView(r);return ua(n,0,"RIFF"),n.setUint32(4,36+s*4,!0),ua(n,8,"WAVE"),ua(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,3,!0),n.setUint16(22,1,!0),n.setUint32(24,e,!0),n.setUint32(28,e*4,!0),n.setUint16(32,4,!0),n.setUint16(34,32,!0),ua(n,36,"data"),n.setUint32(40,s*4,!0),new Blob([r,...t.map(o=>o.buffer)],{type:"audio/wav"})}function ua(t,e,s){for(let r=0;r<s.length;++r)t.setUint8(e+r,s.charCodeAt(r))}var Fr=class{constructor(e,s){this.audio=e,this.sampling_rate=s}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array(0);if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((n,o)=>n+o.length,0),s=new Float32Array(e),r=0;for(let n of this.audio)s.set(n,r),r+=n.length;return s}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),fA(e,this.sampling_rate)}async save(e){return pa(e,this.toBlob())}};var Kp=class extends ae{constructor(e){super(e);let s=this.config.sampling_rate,r=Ie(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Ne(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,s){return Pe(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:s,transpose:!0})}async _call(e){_e(e,"ASTFeatureExtractor");let s=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let r=this.std*2,n=s.data;for(let o=0;o<n.length;++o)n[o]=(n[o]-this.mean)/r}return{input_values:s.unsqueeze_(0)}}};var Rr=class extends ae{async _call(e){_e(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=this.config.feature_size;if(e.length%s!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${s}).`);let r=[1,s,e.length/s];return{input_values:new E("float32",e,r)}}};var Xp=class extends ae{async _call(e){_e(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,e.length];return{input_values:new E("float32",e,s)}}};var Qp=class extends ae{constructor(e){super(e),this.mel_filters=Ie(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,null,"htk"),this.mel_filters_slaney=Ie(this.config.nb_frequency_bins,this.config.feature_size,this.config.frequency_min,this.config.frequency_max,this.config.sampling_rate,"slaney","slaney"),this.window=Ne(this.config.fft_window_size,"hann")}async _get_input_mel(e,s,r,n){let o,i=!1,a=e.length-s;if(a>0)if(r==="rand_trunc"){i=!0;let l=Math.floor(es.random()*(a+1));e=e.subarray(l,l+s),o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${r}" not implemented`);else{if(a<0){let l=new Float64Array(s);if(l.set(e),n==="repeat")for(let c=e.length;c<s;c+=e.length)l.set(e.subarray(0,Math.min(e.length,s-c)),c);else if(n==="repeatpad")for(let c=e.length;c<-a;c+=e.length)l.set(e,c);e=l}if(r==="fusion")throw new Error(`Truncation strategy "${r}" not implemented`);o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return o.unsqueeze_(0)}async _extract_fbank_features(e,s,r=null){return Pe(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:s,log_mel:"dB",max_num_frames:r,do_pad:!1,transpose:!0})}async _call(e,{max_length:s=null}={}){return _e(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,s??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}};var mA=1e-5,Dr=class extends ae{constructor(e){super(e),this.config.mel_filters??=Ie(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");let s=Ne(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);let r=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(s,r)}async _extract_fbank_features(e){let s=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=s*e[n-1];return await Pe(e,this.window,this.window.length,this.config.hop_length,{fft_length:this.config.n_fft,power:2,mel_filters:this.config.mel_filters,log_mel:"log",mel_floor:-1/0,pad_mode:"constant",center:!0,transpose:!0,mel_offset:2**-24})}async _call(e){_e(e,"ParakeetFeatureExtractor");let s=await this._extract_fbank_features(e),r=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),n=s.data;n.fill(0,r*s.dims[1]);let[o,i]=s.dims,a=new Float64Array(i),l=new Float64Array(i);for(let u=0;u<r;++u){let _=u*i;for(let d=0;d<i;++d){let m=n[_+d];a[d]+=m,l[d]+=m*m}}let c=r>1?r-1:1;for(let u=0;u<i;++u){let _=a[u]/r,d=(l[u]-r*_*_)/c,h=1/(Math.sqrt(d)+mA);for(let g=0;g<r;++g){let x=g*i+u;n[x]=(n[x]-_)*h}}let p=new BigInt64Array(o);return p.fill(1n,0,r),{input_features:s.unsqueeze_(0),attention_mask:new E("int64",p,[1,o])}}};var Yp=class extends Dr{_apply_dither(e){let s=this.config.dither??0;if(s<=0)return e;let r=new St(e.length);for(let n=0;n<e.length;++n)e[n]+=s*r.gauss();return e}split_audio(e){let s=this.config.max_audio_clip_s??35,r=this.config.overlap_chunk_second??5,n=this.config.min_energy_window_samples??1600,o=this.config.sampling_rate,i=Math.max(1,Math.round(s*o)),a=Math.max(1,Math.round(r*o));if(e.length<=i)return[e];let l=[],c=0,p=e.length;for(;c<p;){if(c+i>=p){l.push(e.slice(c,p));break}let u=Math.max(c,c+i-a),_=Math.min(c+i,p),d;_<=u?d=c+i:d=this._find_split_point_energy(e,u,_,n),d=Math.max(c+1,Math.min(d,p)),l.push(e.slice(c,d)),c=d}return l}_find_split_point_energy(e,s,r,n){let o=r-s;if(o<=n)return Math.floor((s+r)/2);let i=1/0,a=s,l=o-n;for(let c=0;c<=l;c+=n){let p=0;for(let u=0;u<n;++u){let _=e[s+c+u];p+=_*_}p=Math.sqrt(p/n),p<i&&(i=p,a=s+c)}return a}async _call(e){_e(e,"CohereAsrFeatureExtractor");let s=new Float64Array(e);return this._apply_dither(s),super._call(s)}};var jr=class extends Rr{};var Jp=class extends ae{constructor(e){super(e);let{fft_length:s,feature_size:r,min_frequency:n,max_frequency:o,sampling_rate:i,frame_length:a}=this.config,l=Ie(Math.floor(1+s/2),r,n,o,i,null,"htk",!1);this.mel_filters=l,this.window=Ne(a,"hann")}async _extract_fbank_features(e,s){return Pe(e,this.window,this.config.frame_length,this.config.hop_length,{fft_length:this.config.fft_length,center:!1,onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:"log",mel_floor:this.config.mel_floor,remove_dc_offset:!1,transpose:!0})}async _call(e,{max_length:s=48e4,truncation:r=!0,padding:n=!0,pad_to_multiple_of:o=128}={}){if(_e(e,"Gemma3nAudioFeatureExtractor"),r&&e.length>s&&(e=e.slice(0,s)),n&&e.length%o!==0){let l=o-e.length%o,c=new Float64Array(e.length+l);c.set(e),this.config.padding_value!==0&&c.fill(this.config.padding_value,e.length),e=c}let i=await this._extract_fbank_features(e,this.config.max_length),a=be([1,i.dims[0]],!0);return{input_features:i.unsqueeze_(0),input_features_mask:a}}};var Zp=class extends ae{constructor(e){super(e);let{n_fft:s,win_length:r,n_mels:n,sample_rate:o}=e.melspec_kwargs;this.mel_filters=Ie(Math.floor(1+s/2),n,0,o/2,o,null,"htk");let i=Ne(r,"hann");this.window=new Float64Array(s);let a=Math.floor((s-r)/2);this.window.set(i,a)}async _call(e){_e(e,"GraniteSpeechFeatureExtractor");let{n_fft:s,hop_length:r,n_mels:n}=this.config.melspec_kwargs,o=1+Math.floor((e.length-1)/r),i=o-o%2;return{input_features:(await Pe(e,this.window,s,r,{power:2,mel_filters:this.mel_filters,log_mel:"log10_max_norm",transpose:!0,max_num_frames:i,do_pad:!1})).view(-1,2*n).unsqueeze_(0)}}};var eu=class extends ae{async _call(e){_e(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,e.length];return{input_values:new E("float32",e,s)}}};var Br=class extends ae{async _call(e){_e(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=[1,1,e.length];return{input_values:new E("float32",e,s)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,s){let r=s/this.samples_to_frames(s)/this.config.sampling_rate,n=[];for(let o of e.tolist()){let i=[],a=-1;for(let l=0;l<o.length;++l){let c=fe(o[l]),[p,u]=ue(c),[_,d]=[l,l+1];u!==a?(a=u,i.push({id:u,start:_,end:d,score:p})):(i.at(-1).end=d,i.at(-1).score+=p)}n.push(i.map(({id:l,start:c,end:p,score:u})=>({id:l,start:c*r,end:p*r,confidence:u/(p-c)})))}return n}};var tu=class extends ae{constructor(e){super(e);let s=this.config.sampling_rate,r=Ie(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Ne(400,"povey",{periodic:!1})}async _extract_fbank_features(e,s){return e=e.map(r=>r*32768),Pe(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:s,transpose:!0})}async _call(e,{padding:s=!0,pad_to_multiple_of:r=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:o=!0}={}){_e(e,"SeamlessM4TFeatureExtractor");let i=await this._extract_fbank_features(e,this.config.max_length);if(n){let[m,h]=i.dims,g=i.data;for(let x=0;x<h;++x){let w=0;for(let k=0;k<m;++k)w+=g[k*h+x];let y=w/m,b=0;for(let k=0;k<m;++k)b+=(g[k*h+x]-y)**2;b/=m-1;let v=Math.sqrt(b+1e-7);for(let k=0;k<m;++k){let O=k*h+x;g[O]=(g[O]-y)/v}}}let a;if(s){let[m,h]=i.dims,g=i.data,x=m%r;if(x>0){let w=new Float32Array(h*(m+x));w.set(g),w.fill(this.config.padding_value,g.length);let y=m+x;i=new E(i.type,w,[y,h]),o&&(a=new E("int64",new BigInt64Array(y),[1,y]),a.data.fill(1n,0,m))}}let[l,c]=i.dims,p=this.config.stride;if(l%p!==0)throw new Error(`The number of frames (${l}) must be a multiple of the stride (${p}).`);let _=i.view(1,Math.floor(l/p),c*p),d={input_features:_};if(o){let m=_.dims[1],h=new BigInt64Array(m);if(a){let g=a.data;for(let x=1,w=0;x<l;x+=p,++w)h[w]=g[x]}else h.fill(1n);d.attention_mask=new E("int64",h,[1,m])}return d}};var su=class extends jr{};var ru=class extends ae{};var nu=class extends ae{_zero_mean_unit_var_norm(e){let r=e.reduce((o,i)=>o+i,0)/e.length,n=e.reduce((o,i)=>o+(i-r)**2,0)/e.length;return e.map(o=>(o-r)/Math.sqrt(n+1e-7))}async _call(e){_e(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let s=e;this.config.do_normalize&&(s=this._zero_mean_unit_var_norm(s));let r=[1,s.length];return{input_values:new E("float32",s,r),attention_mask:new E("int64",new BigInt64Array(s.length).fill(1n),r)}}};var ou=class extends ae{constructor(e){super(e);let s=this.config.sampling_rate,r=Ie(257,this.config.num_mel_bins,20,Math.floor(s/2),s,null,"kaldi",!0);this.mel_filters=r,this.window=Ne(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(s=>s*32768),Pe(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){_e(e,"WeSpeakerFeatureExtractor");let s=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let r=s.mean(1).data,n=s.data,[o,i,a]=s.dims;for(let l=0;l<o;++l){let c=l*i*a,p=l*a;for(let u=0;u<i;++u){let _=c+u*a;for(let d=0;d<a;++d)n[_+d]-=r[p+d]}}}return{input_features:s}}};var iu=class extends ae{constructor(e){super(e),this.config.mel_filters??=Ie(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Ne(this.config.n_fft,"hann")}async _extract_fbank_features(e,{center:s=!0}={}){let{n_fft:r,hop_length:n,mel_filters:o,global_log_mel_max:i}=this.config,a=Math.floor(s?e.length/n:(e.length-r)/n);return await Pe(e,this.window,r,n,{power:2,mel_filters:o,log_mel:"log10_max_norm",max_log_mel:i,center:s,max_num_frames:a,do_pad:!1})}async _call(e,{center:s=!0}={}){return _e(e,"VoxtralRealtimeFeatureExtractor"),{input_features:(await this._extract_fbank_features(e,{center:s})).unsqueeze_(0)}}};var au=class extends ae{constructor(e){super(e),this.config.mel_filters??=Ie(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Ne(this.config.n_fft,"hann")}async _extract_fbank_features(e){return await Pe(e,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10_max_norm",max_num_frames:Math.min(Math.floor(e.length/this.config.hop_length),this.config.nb_max_frames)})}async _call(e,{max_length:s=null}={}){_e(e,"WhisperFeatureExtractor");let r,n=s??this.config.n_samples;return e.length>n?(e.length>this.config.n_samples&&$.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),r=e.slice(0,n)):(r=new Float32Array(n),r.set(e)),{input_features:(await this._extract_fbank_features(r)).unsqueeze_(0)}}};var ge=class{static async from_pretrained(e,s={}){let r=await Ce(e,$r,!0,s),n=r.feature_extractor_type,o=qr[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${Nt}.`);return new o(r)}};var lu=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e,s=null){let r=this.tokenizer(e),n=s?await this.feature_extractor(s):{};return{...r,...n}}};var hA=new Set(["ja","zh"]),cu=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;static uses_processor_config=!0;get_decoder_prompt_ids(e="en"){let s=["\u2581","<|startofcontext|>","<|startoftranscript|>","<|emo:undefined|>",`<|${e}|>`,`<|${e}|>`,"<|pnc|>","<|noitn|>","<|notimestamp|>","<|nodiarize|>"];return this.tokenizer.convert_tokens_to_ids(s)}static join_chunks(e,s="en"){let r=e.filter(i=>i&&i.trim());if(r.length===0)return"";let n=hA.has(s)?"":" ";return[r[0].trimEnd(),...r.slice(1).map(i=>i.trim())].join(n)}async _call(e){return await this.feature_extractor(e)}};var _a={};var rs,eb,Lt;if(V.IS_WEB_ENV)rs=(t,e)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(t,e)},Lt=self.createImageBitmap,eb=self.ImageData;else if(_a)Lt=async t=>{let s=(await t.metadata()).channels,{data:r,info:n}=await t.rotate().raw().toBuffer({resolveWithObject:!0}),o=new ve(new Uint8ClampedArray(r),n.width,n.height,n.channels);return s!==void 0&&s!==n.channels&&o.convert(s),o};else throw new Error("Unable to load image processing library.");var gA={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},xA=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),ve=class t{constructor(e,s,r,n){this.data=e,this.width=s,this.height=r,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof t)return e;if(typeof e=="string"||e instanceof URL)return await this.fromURL(e);if(e instanceof Blob)return await this.fromBlob(e);if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return this.fromCanvas(e);throw new Error(`Unsupported input type: ${typeof e}`)}static fromCanvas(e){if(!V.IS_WEB_ENV)throw new Error("fromCanvas() is only supported in browser environments.");let r=e.getContext("2d").getImageData(0,0,e.width,e.height).data;return new t(r,e.width,e.height,4)}static async fromURL(e){let s=await zt(e);if(s.status!==200)throw new Error(`Unable to read image from "${e}" (${s.status} ${s.statusText})`);let r=await s.blob();return this.fromBlob(r)}static async fromBlob(e){if(V.IS_WEB_ENV){let s=await Lt(e),r=rs(s.width,s.height).getContext("2d");return r.drawImage(s,0,0),new this(r.getImageData(0,0,s.width,s.height).data,s.width,s.height,4)}else{let s=_a(await e.arrayBuffer());return await Lt(s)}}static fromTensor(e,s="CHW"){if(e.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if(s==="CHW")e=e.transpose(1,2,0);else if(s!=="HWC")throw new Error(`Unsupported channel format: ${s}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new t(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw new Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let s=0,r=0;s<this.data.length;s+=this.channels){let n=this.data[s],o=this.data[s+1],i=this.data[s+2];e[r++]=Math.round(.2989*n+.587*o+.114*i)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,1)}rgb(){if(this.channels===3)return this;let e=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let s=0,r=0;s<this.data.length;++s)e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=this.data[s];break;case 4:for(let s=0,r=0;s<this.data.length;s+=4)e[r++]=this.data[s],e[r++]=this.data[s+1],e[r++]=this.data[s+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,3)}rgba(){if(this.channels===4)return this;let e=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let s=0,r=0;s<this.data.length;++s)e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=this.data[s],e[r++]=255;break;case 3:for(let s=0,r=0;s<this.data.length;s+=3)e[r++]=this.data[s],e[r++]=this.data[s+1],e[r++]=this.data[s+2],e[r++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,4)}putAlpha(e){if(e.width!==this.width||e.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${e.channels}`);let s=this.data,r=e.data,n=this.width*this.height;if(this.channels===3){let o=new Uint8ClampedArray(n*4);for(let i=0,a=0,l=0;i<n;++i)o[l++]=s[a++],o[l++]=s[a++],o[l++]=s[a++],o[l++]=r[i];return this._update(o,this.width,this.height,4)}else if(this.channels===4){for(let o=0;o<n;++o)s[4*o+3]=r[o];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(e,s,{resample:r=2}={}){if(this.width===e&&this.height===s)return this;let n=gA[r]??r,o=Ic(e),i=Ic(s);if(o&&i)return this;if(o?e=s/this.height*this.width:i&&(s=e/this.width*this.height),V.IS_WEB_ENV){let a=this.channels,l=this.toCanvas(),c=rs(e,s).getContext("2d");return c.drawImage(l,0,0,e,s),new t(c.getImageData(0,0,e,s).data,e,s,4).convert(a)}else{let a=this.toSharp();switch(n){case"box":case"hamming":(n==="box"||n==="hamming")&&($.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":a=a.affine([e/this.width,0,0,s/this.height],{interpolator:n});break;case"lanczos":a=a.resize({width:e,height:s,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await Lt(a)}}async pad([e,s,r,n]){if(e=Math.max(e,0),s=Math.max(s,0),r=Math.max(r,0),n=Math.max(n,0),e===0&&s===0&&r===0&&n===0)return this;if(V.IS_WEB_ENV){let o=this.channels,i=this.toCanvas(),a=this.width+e+s,l=this.height+r+n,c=rs(a,l).getContext("2d");return c.drawImage(i,0,0,this.width,this.height,e,r,this.width,this.height),new t(c.getImageData(0,0,a,l).data,a,l,4).convert(o)}else{let o=this.toSharp().extend({left:e,right:s,top:r,bottom:n});return await Lt(o)}}async crop([e,s,r,n]){if(e=Math.max(e,0),s=Math.max(s,0),r=Math.min(r,this.width-1),n=Math.min(n,this.height-1),e===0&&s===0&&r===this.width-1&&n===this.height-1)return this;let o=r-e+1,i=n-s+1;if(V.IS_WEB_ENV){let a=this.channels,l=this.toCanvas(),c=rs(o,i).getContext("2d");return c.drawImage(l,e,s,o,i,0,0,o,i),new t(c.getImageData(0,0,o,i).data,o,i,4).convert(a)}else{let a=this.toSharp().extract({left:e,top:s,width:o,height:i});return await Lt(a)}}async center_crop(e,s){if(this.width===e&&this.height===s)return this;let r=(this.width-e)/2,n=(this.height-s)/2;if(V.IS_WEB_ENV){let o=this.channels,i=this.toCanvas(),a=rs(e,s).getContext("2d"),l=0,c=0,p=0,u=0;return r>=0?l=r:p=-r,n>=0?c=n:u=-n,a.drawImage(i,l,c,e,s,p,u,e,s),new t(a.getImageData(0,0,e,s).data,e,s,4).convert(o)}else{let o=this.toSharp();if(r>=0&&n>=0)o=o.extract({left:Math.floor(r),top:Math.floor(n),width:e,height:s});else if(r<=0&&n<=0){let i=Math.floor(-n),a=Math.floor(-r);o=o.extend({top:i,left:a,right:e-this.width-a,bottom:s-this.height-i})}else{let i=[0,0],a=0;n<0?(i[0]=Math.floor(-n),i[1]=s-this.height-i[0]):a=Math.floor(n);let l=[0,0],c=0;r<0?(l[0]=Math.floor(-r),l[1]=e-this.width-l[0]):c=Math.floor(r),o=o.extend({top:i[0],bottom:i[1],left:l[0],right:l[1]}).extract({left:c,top:a,width:e,height:s})}return await Lt(o)}}async toBlob(e="image/png",s=1){if(!V.IS_WEB_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:e,quality:s})}toTensor(e="CHW"){let s=new E("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!=="HWC")if(e==="CHW")s=s.permute(2,0,1);else throw new Error(`Unsupported channel format: ${e}`);return s}toCanvas(){if(!V.IS_WEB_ENV)throw new Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),s=rs(e.width,e.height),r=new eb(e.data,e.width,e.height);return s.getContext("2d").putImageData(r,0,0),s}split(){let{data:e,width:s,height:r,channels:n}=this,o=e.constructor,i=e.length/n,a=Array.from({length:n},()=>new o(i));for(let l=0;l<i;++l){let c=n*l;for(let p=0;p<n;++p)a[p][l]=e[c+p]}return a.map(l=>new t(l,s,r,1))}_update(e,s,r,n=null){return this.data=e,this.width=s,this.height=r,n!==null&&(this.channels=n),this}clone(){return new t(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(V.IS_WEB_ENV){if(V.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");let s=e.split(".").pop().toLowerCase(),r=xA.get(s)??"image/png",n=await this.toBlob(r);return pa(e,n)}else if(V.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(V.IS_WEB_ENV)throw new Error("toSharp() is only supported in server-side environments.");return _a(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},wA=ve.read.bind(ve);function tb(t,e,s=0,r=null){let n=t/e,o=b0(n)*e;return r!==null&&o>r&&(o=Math.floor(n)*e),o<s&&(o=Math.ceil(n)*e),o}function sb([t,e],s){return[Math.max(Math.floor(t/s),1)*s,Math.max(Math.floor(e/s),1)*s]}function pu([t,e,s,r]){return[t-s/2,e-r/2,t+s/2,e+r/2]}function $t(t,e=.5,s=null,r=!1){let n=t.logits,o=t.pred_boxes,[i,a,l]=n.dims;if(s!==null&&s.length!==i)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let p=0;p<i;++p){let u=s!==null?s[p]:null,_={boxes:[],classes:[],scores:[]},d=n[p],m=o[p];for(let h=0;h<a;++h){let g=d[h],x=[],w;if(r){w=g.sigmoid().data;for(let y=0;y<w.length;++y)w[y]>e&&x.push(y)}else{let y=ue(g.data)[1];if(y===l-1||(w=fe(g.data),w[y]<e))continue;x.push(y)}for(let y of x){let b=m[h].data;b=pu(b),u!==null&&(b=b.map((v,k)=>v*u[(k+1)%2])),_.boxes.push(b),_.classes.push(y),_.scores.push(w[y])}}c.push(_)}return c}function da(t,e=null){let s=t.logits,r=s.dims[0];if(e!==null&&e.length!==r)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let n=[];for(let o=0;o<r;++o){let i=e!==null?e[o]:null,a=s[o];i!==null&&(a=Hc(a,i,"bilinear",!1));let[l,c]=i??a.dims.slice(-2),p=new E("int32",new Int32Array(l*c),[l,c]),u=a[0].data,_=p.data;for(let h=1;h<a.dims[0];++h){let g=a[h].data;for(let x=0;x<g.length;++x)g[x]>u[x]&&(u[x]=g[x],_[x]=h)}let d=new Array(a.dims[0]);for(let h=0;h<_.length;++h){let g=_[h];d[g]=g}let m=d.filter(h=>h!==void 0);n.push({segmentation:p,labels:m})}return n}function yA(t,e,s,r){let n=[],o=[],i=[];for(let a=0;a<t.dims[0];++a){let l=t[a],c=e[a],p=ue(l.data)[1];if(p===r)continue;let _=fe(l.data)[p];_>s&&(n.push(c),o.push(_),i.push(p))}return[n,o,i]}function bA(t,e,s,r=.5,n=.8){let o=[],i=0,a=0,l=e[s].data;for(let p=0;p<t.length;++p)t[p]===s&&(o.push(p),++i),l[p]>=r&&++a;let c=i>0&&a>0;return c&&(c=i/a>n),[c,o]}function kA(t,e,s,r,n,o=null,i=null){let[a,l]=i??t[0].dims,c=new E("int32",new Int32Array(a*l),[a,l]),p=[];if(i!==null)for(let h=0;h<t.length;++h)t[h]=Hc(t[h],i,"bilinear",!1);let u=new Int32Array(t[0].data.length),_=new Float32Array(t[0].data.length);for(let h=0;h<t.length;++h){let g=e[h],x=t[h].data;for(let w=0;w<x.length;++w)x[w]*=g,x[w]>_[w]&&(u[w]=h,_[w]=x[w])}let d=0,m=c.data;for(let h=0;h<s.length;++h){let g=s[h],[x,w]=bA(u,t,h,r,n);if(x){++d;for(let y of w)m[y]=d;p.push({id:d,label_id:g,score:e[h]})}}return[c,p]}function Ns(t,e,s=28,r=3136,n=784*1280,o=1){if(t<s||e<s){let l=Math.max(s/t,s/e);t=Math.round(t*l),e=Math.round(e*l)}if(Math.max(t,e)/Math.min(t,e)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(t,e)/Math.min(t,e)}`);let i=Math.round(t/s)*s,a=Math.round(e/s)*s;if(o*i*a>n){let l=Math.sqrt(o*t*e/n);i=Math.max(s,Math.floor(t/l/s)*s),a=Math.max(s,Math.floor(e/l/s)*s)}else if(o*i*a<r){let l=Math.sqrt(r/(o*t*e));i=Math.ceil(t*l/s)*s,a=Math.ceil(e*l/s)*s}return[a,i]}function fa(t,e=.5,s=.5,r=.8,n=null,o=null){n===null&&($.warn("`label_ids_to_fuse` unset. No instance will be fused."),n=new Set);let i=t.class_queries_logits??t.logits,l=(t.masks_queries_logits??t.pred_masks).sigmoid(),[c,p,u]=i.dims;if(u-=1,o!==null&&o.length!==c)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let _=[];for(let d=0;d<c;++d){let m=o!==null?o[d]:null,h=i[d],g=l[d],[x,w,y]=yA(h,g,e,u);if(y.length===0){let[k,O]=m??g.dims.slice(-2),N=new E("int32",new Int32Array(k*O).fill(-1),[k,O]);_.push({segmentation:N,segments_info:[]});continue}let[b,v]=kA(x,w,y,s,r,n,m);_.push({segmentation:b,segments_info:v})}return _}function ma(t,e=.5,s=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var C=class extends Se{constructor(e){super(),this.image_mean=e.image_mean??e.mean,this.image_std=e.image_std??e.std,this.resample=e.resample??2,this.do_rescale=e.do_rescale??!0,this.rescale_factor=e.rescale_factor??1/255,this.do_normalize=e.do_normalize,this.do_thumbnail=e.do_thumbnail,this.size=e.size??e.image_size,this.do_resize=e.do_resize??this.size!==void 0,this.size_divisibility=e.size_divisibility??e.size_divisor,this.do_center_crop=e.do_center_crop,this.crop_size=e.crop_size,this.do_convert_rgb=e.do_convert_rgb??!0,this.do_crop_margin=e.do_crop_margin,this.pad_size=e.pad_size,this.do_pad=e.do_pad,this.min_pixels=e.min_pixels,this.max_pixels=e.max_pixels,this.do_pad&&!this.pad_size&&!this.size_divisibility&&this.size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size),this.do_flip_channel_order=e.do_flip_channel_order??!1,this.config=e}async thumbnail(e,s,r=2){let n=e.height,o=e.width,i=s.height,a=s.width,l=Math.min(n,i),c=Math.min(o,a);return l===n&&c===o?e:(n>o?c=Math.floor(o*l/n):o>n&&(l=Math.floor(n*c/o)),await e.resize(c,l,{resample:r}))}async crop_margin(e,s=200){let r=e.clone().grayscale(),n=Ir(r.data)[0],i=ue(r.data)[0]-n;if(i===0)return e;let a=s/255,l=r.width,c=r.height,p=0,u=0,_=r.data;for(let d=0;d<r.height;++d){let m=d*r.width;for(let h=0;h<r.width;++h)(_[m+h]-n)/i<a&&(l=Math.min(l,h),c=Math.min(c,d),p=Math.max(p,h),u=Math.max(u,d))}return e=await e.crop([l,c,p,u]),e}pad_image(e,s,r,{mode:n="constant",center:o=!1,constant_values:i=0}={}){let[a,l,c]=s,p,u;if(typeof r=="number"?(p=r,u=r):r==="square"?p=u=Math.max(a,l):(p=r.width,u=r.height),p!==l||u!==a){let _=new Float32Array(p*u*c);if(Array.isArray(i))for(let h=0;h<_.length;++h)_[h]=i[h%c];else i!==0&&_.fill(i);let[d,m]=o?[Math.floor((p-l)/2),Math.floor((u-a)/2)]:[0,0];for(let h=0;h<a;++h){let g=(h+m)*p,x=h*l;for(let w=0;w<l;++w){let y=(g+w+d)*c,b=(x+w)*c;for(let v=0;v<c;++v)_[y+v]=e[b+v]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let h=a-1,g=l-1;for(let x=0;x<u;++x){let w=x*p,y=Ms(x,h)*l;for(let b=0;b<p;++b){if(x<a&&b<l)continue;let v=(w+b)*c,k=(y+Ms(b,g))*c;for(let O=0;O<c;++O)_[v+O]=e[k+O]}}}e=_,s=[u,p,c]}return[e,s]}rescale(e){for(let s=0;s<e.length;++s)e[s]=this.rescale_factor*e[s]}get_resize_output_image_size(e,s){let[r,n]=e.size,o,i;if(this.do_thumbnail){let{height:a,width:l}=s;o=Math.min(a,l)}else Number.isInteger(s)?(o=s,i=this.config.max_size??o):s!==void 0&&(o=s.shortest_edge,i=s.longest_edge);if(o!==void 0||i!==void 0){let a=o===void 0?1:Math.max(o/r,o/n),l=r*a,c=n*a,p=i===void 0?1:Math.min(i/l,i/c),u=Math.floor(Number((l*p).toFixed(2))),_=Math.floor(Number((c*p).toFixed(2)));return this.size_divisibility!==void 0&&([u,_]=sb([u,_],this.size_divisibility)),[u,_]}else if(s!==void 0&&s.width!==void 0&&s.height!==void 0){let a=s.width,l=s.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let c=l/n,p=a/r;Math.abs(1-p)<Math.abs(1-c)?c=p:p=c,l=tb(c*n,this.config.ensure_multiple_of),a=tb(p*r,this.config.ensure_multiple_of)}return[a,l]}else{if(this.size_divisibility!==void 0)return sb([r,n],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(s)}`)}}async resize(e){let[s,r]=this.get_resize_output_image_size(e,this.size);return await e.resize(s,r,{resample:this.resample})}async preprocess(e,{do_normalize:s=null,do_pad:r=null,do_convert_rgb:n=null,do_convert_grayscale:o=null,do_flip_channel_order:i=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[a,l]=e.size;if(n??this.do_convert_rgb?e=e.rgb():o&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let d,m;Number.isInteger(this.crop_size)?(d=this.crop_size,m=this.crop_size):(d=this.crop_size.width,m=this.crop_size.height),e=await e.center_crop(d,m)}let c=[e.height,e.width],p=Float32Array.from(e.data),u=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(p),s??this.do_normalize){let d=this.image_mean;Array.isArray(this.image_mean)||(d=new Array(e.channels).fill(d));let m=this.image_std;if(Array.isArray(this.image_std)||(m=new Array(e.channels).fill(m)),d.length!==e.channels||m.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${d.length}) and \`image_std\` (${m.length}) must match the number of channels in the image (${e.channels}).`);for(let h=0;h<p.length;h+=e.channels)for(let g=0;g<e.channels;++g)p[h+g]=(p[h+g]-d[g])/m[g]}if(r??this.do_pad){if(this.pad_size)[p,u]=this.pad_image(p,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){let d=Math.ceil(u[1]/this.size_divisibility)*this.size_divisibility,m=Math.ceil(u[0]/this.size_divisibility)*this.size_divisibility;[p,u]=this.pad_image(p,u,{width:d,height:m})}}if(i??this.do_flip_channel_order){if(u[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let d=0;d<p.length;d+=3){let m=p[d];p[d]=p[d+2],p[d+2]=m}}let _=new E("float32",p,u).permute(2,0,1);return{original_size:[l,a],reshaped_input_size:c,pixel_values:_}}async _call(e,...s){Array.isArray(e)||(e=[e]);let r=await Promise.all(e.map(o=>this.preprocess(o)));return{pixel_values:Ue(r.map(o=>o.pixel_values),0),original_sizes:r.map(o=>o.original_size),reshaped_input_sizes:r.map(o=>o.reshaped_input_size)}}static async from_pretrained(e,s={}){let r=await Ce(e,yt,!0,s);return new this(r)}};var Ds={};Es(Ds,{BeitFeatureExtractor:()=>uu,BitImageProcessor:()=>_u,CHMv2ImageProcessor:()=>fu,CLIPFeatureExtractor:()=>mu,CLIPImageProcessor:()=>ha,ChineseCLIPFeatureExtractor:()=>du,ConvNextFeatureExtractor:()=>hu,ConvNextImageProcessor:()=>ga,DINOv3ViTImageProcessor:()=>wu,DPTFeatureExtractor:()=>bu,DPTImageProcessor:()=>ya,DeiTFeatureExtractor:()=>gu,DeiTImageProcessor:()=>xa,DetrFeatureExtractor:()=>xu,DetrImageProcessor:()=>wa,DonutFeatureExtractor:()=>yu,DonutImageProcessor:()=>Ls,EfficientNetImageProcessor:()=>ku,GLPNFeatureExtractor:()=>Au,Gemma3ImageProcessor:()=>vu,Glm46VImageProcessor:()=>Eu,GroundingDinoImageProcessor:()=>Mu,Idefics3ImageProcessor:()=>ba,ImageFeatureExtractor:()=>C,ImageProcessor:()=>C,JinaCLIPImageProcessor:()=>Ou,Lfm2VlImageProcessor:()=>zu,LlavaOnevisionImageProcessor:()=>Iu,Mask2FormerImageProcessor:()=>Cu,MaskFormerFeatureExtractor:()=>Tu,MaskFormerImageProcessor:()=>$s,MobileNetV1FeatureExtractor:()=>Pu,MobileNetV1ImageProcessor:()=>ka,MobileNetV2FeatureExtractor:()=>Nu,MobileNetV2ImageProcessor:()=>va,MobileNetV3FeatureExtractor:()=>Lu,MobileNetV3ImageProcessor:()=>Ea,MobileNetV4FeatureExtractor:()=>$u,MobileNetV4ImageProcessor:()=>Aa,MobileViTFeatureExtractor:()=>Fu,MobileViTImageProcessor:()=>Ma,NougatImageProcessor:()=>Ru,OwlViTFeatureExtractor:()=>Du,OwlViTImageProcessor:()=>Fs,Owlv2ImageProcessor:()=>ju,Phi3VImageProcessor:()=>Uu,PixtralImageProcessor:()=>Gu,PvtImageProcessor:()=>Wu,Qwen2VLImageProcessor:()=>Ur,RTDetrImageProcessor:()=>Vu,Sam2ImageProcessor:()=>Gr,Sam3ImageProcessor:()=>Gr,SamImageProcessor:()=>Gr,SapiensFeatureExtractor:()=>Hu,SapiensImageProcessor:()=>Sa,SegformerFeatureExtractor:()=>Ku,SegformerImageProcessor:()=>Oa,SiglipImageProcessor:()=>Xu,SmolVLMImageProcessor:()=>ba,Swin2SRImageProcessor:()=>Qu,VLMImageProcessor:()=>Su,ViTFeatureExtractor:()=>Yu,ViTImageProcessor:()=>za,VitMatteImageProcessor:()=>Ju,VitPoseImageProcessor:()=>Zu,YolosFeatureExtractor:()=>e_,YolosImageProcessor:()=>Ia});var uu=class extends C{};var _u=class extends C{};var du=class extends C{};var fu=class extends C{};var ha=class extends C{},mu=class extends ha{};var ga=class extends C{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let s=this.size?.shortest_edge;if(s===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(s<384){let r=Math.floor(s/this.crop_pct),[n,o]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,o,{resample:this.resample}),e=await e.center_crop(s,s)}else e=await e.resize(s,s,{resample:this.resample});return e}},hu=class extends ga{};var xa=class extends C{},gu=class extends xa{};var wa=class extends C{async _call(e){let s=await super._call(e),r=[s.pixel_values.dims[0],64,64],n=be(r,1n);return{...s,pixel_mask:n}}post_process_object_detection(...e){return $t(...e)}post_process_panoptic_segmentation(...e){return fa(...e)}post_process_instance_segmentation(...e){return ma(...e)}},xu=class extends wa{};var wu=class extends C{};var Ls=class extends C{pad_image(e,s,r,n={}){let[o,i,a]=s,l=this.image_mean;Array.isArray(this.image_mean)||(l=new Array(a).fill(l));let c=this.image_std;Array.isArray(c)||(c=new Array(a).fill(l));let p=l.map((u,_)=>-u/c[_]);return super.pad_image(e,s,r,{center:!0,constant_values:p,...n})}},yu=class extends Ls{};var ya=class extends C{},bu=class extends ya{};var ku=class extends C{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(s=>s*s))}};var vu=class extends C{};var Ur=class extends C{constructor(e){super(e),this.min_pixels=e.min_pixels??e.size?.shortest_edge,this.max_pixels=e.max_pixels??e.size?.longest_edge,this.patch_size=e.patch_size,this.merge_size=e.merge_size}get_resize_output_image_size(e,s){let r=this.patch_size*this.merge_size;return Ns(e.height,e.width,r,this.min_pixels,this.max_pixels)}async _call(e,...s){let{pixel_values:r,original_sizes:n,reshaped_input_sizes:o}=await super._call(e,...s),i=r,{temporal_patch_size:a,merge_size:l,patch_size:c}=this.config;i.dims[0]===1&&(i=oe(Array.from({length:a},()=>i),0));let p=i.dims[0]/a,u=i.dims[1],_=Math.floor(i.dims[2]/c),d=Math.floor(i.dims[3]/c),m=i.view(p,a,u,Math.floor(_/l),l,c,Math.floor(d/l),l,c).permute(0,3,6,4,7,2,1,5,8).view(p*_*d,u*a*c*c),h=new E("int64",[p,_,d],[1,3]);return{pixel_values:m,image_grid_thw:h,original_sizes:n,reshaped_input_sizes:o}}};var Eu=class extends Ur{get_resize_output_image_size(e,s){let r=this.patch_size*this.merge_size,n=this.config.temporal_patch_size??2;return Ns(e.height,e.width,r,this.min_pixels,this.max_pixels,n)}};var Au=class extends C{};var Mu=class extends C{async _call(e){let s=await super._call(e),r=s.pixel_values.dims,n=Ae([r[0],r[2],r[3]]);return{...s,pixel_mask:n}}};var ba=class extends C{constructor(e){super(e),this.do_image_splitting=e.do_image_splitting??!0,this.max_image_size=e.max_image_size}get_resize_for_vision_encoder(e,s){let[r,n]=e.dims.slice(-2),o=n/r;return n>=r?(n=Math.ceil(n/s)*s,r=Math.floor(n/o),r=Math.ceil(r/s)*s):(r=Math.ceil(r/s)*s,n=Math.floor(r*o),n=Math.ceil(n/s)*s),{height:r,width:n}}async _call(e,{do_image_splitting:s=null,return_row_col_info:r=!1}={}){let n;if(!Array.isArray(e))n=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?n=e:n=[e]}let o=[],i=[],a=[],l=[],c=[];for(let x of n){let w=await Promise.all(x.map(v=>this.preprocess(v)));l.push(...w.map(v=>v.original_size)),c.push(...w.map(v=>v.reshaped_input_size)),w.forEach(v=>v.pixel_values.unsqueeze_(0));let{longest_edge:y}=this.max_image_size,b;if(s??this.do_image_splitting){let v=new Array(w.length),k=new Array(w.length);b=await Promise.all(w.map(async(O,N)=>{let q=this.get_resize_for_vision_encoder(O.pixel_values,y),P=await De(O.pixel_values,{size:[q.height,q.width]}),{frames:R,num_splits_h:F,num_splits_w:U}=await this.split_image(P,this.max_image_size);return v[N]=F,k[N]=U,oe(R,0)})),i.push(v),a.push(k)}else{let v=[y,y];b=await Promise.all(w.map(k=>De(k.pixel_values,{size:v}))),i.push(new Array(w.length).fill(0)),a.push(new Array(w.length).fill(0))}o.push(oe(b,0))}let p=o.length,[u,_,d,m]=o[0].dims,h,g;if(p===1)h=o[0].unsqueeze_(0),g=be([p,u,d,m],!0);else{let x=Math.max(...o.map(b=>b.dims.at(0)));g=be([p,x,d,m],!0);let w=g.data,y=x*d*m;for(let b=0;b<p;++b){let v=o[b].dims[0];if(v<x){o[b]=oe([o[b],be([x-v,_,d,m],0)],0);let k=b*y+v*d*m,O=(b+1)*y;w.fill(!1,k,O)}}h=Ue(o,0)}return{pixel_values:h,pixel_attention_mask:g,original_sizes:l,reshaped_input_sizes:c,...r?{rows:i,cols:a}:{}}}async split_image(e,{longest_edge:s}){let r=s,n=s,o=[],[i,a]=e.dims.slice(-2),l=0,c=0;if(i>r||a>n){l=Math.ceil(i/r),c=Math.ceil(a/n);let p=Math.ceil(i/l),u=Math.ceil(a/c);for(let m=0;m<l;++m)for(let h=0;h<c;++h){let g,x,w,y;m===l-1?(x=i-p,y=i):(x=m*p,y=(m+1)*p),h===c-1?(g=a-u,w=a):(g=h*u,w=(h+1)*u);let k=await aa(e,[x,g],[y,w],[2,3]);o.push(k)}let _=r,d=n;(i!==_||a!==d)&&(e=await De(e,{size:[_,d]}))}return o.push(e),{frames:o,num_splits_h:l,num_splits_w:c}}};var Su=class extends C{constructor(e){super({do_pad:!0,pad_size:{width:e.image_size,height:e.image_size},...e}),this.constant_values=this.config.background_color.map(s=>s*this.rescale_factor)}pad_image(e,s,r,n){return super.pad_image(e,s,r,{constant_values:this.constant_values,center:!0,...n})}};var Ou=class extends C{constructor(e){let{resize_mode:s,fill_color:r,interpolation:n,size:o,...i}=e,a=s==="squash"?{width:o,height:o}:s==="shortest"?{shortest_edge:o}:{longest_edge:o},l=n==="bicubic"?3:2;super({...i,size:a,resample:l,do_center_crop:!0,crop_size:o,do_normalize:!0})}};function rb(t,e){return Math.round(t/e)*e}function vA(t,e,s,r,n){let o=1/0,i=[1,1],a=s*r;for(let l of e){let c=Math.abs(t-l[0]/l[1]);c<o?(o=c,i=l):c===o&&a>.5*n*n*l[0]*l[1]&&(i=l)}return i}function EA(t,e){let s=[],r=new Set;for(let n=t;n<=e;++n)for(let o=1;o<=n;++o)for(let i=1;i<=n;++i){let a=o*i;if(a>=t&&a<=e){let l=o<<16|i;r.has(l)||(r.add(l),s.push([o,i]))}}return s.sort((n,o)=>n[0]*n[1]-o[0]*o[1])}function AA(t,e){let[s,r,n,o]=t.dims,i=Math.floor(n/e),a=Math.floor(o/e),l=e*e*r,c=t.data,p=new Float32Array(s*i*a*l),u=n*o;for(let _=0;_<s;++_){let d=_*r*u,m=_*i*a*l;for(let h=0;h<i;++h)for(let g=0;g<a;++g){let x=m+(h*a+g)*l;for(let w=0;w<e;++w){let y=(h*e+w)*o+g*e;for(let b=0;b<e;++b){let v=y+b;for(let k=0;k<r;++k)p[x++]=c[d+k*u+v]}}}}return new E("float32",p,[s,i*a,l])}function MA(t,e){let[,s,r]=t.dims,n=new BigInt64Array(e);n.fill(1n,0,s);let o=t;if(s<e){let i=new Float32Array(e*r);i.set(t.data),o=new E("float32",i,[1,e,r])}return{padded:o,mask:new E("int64",n,[e])}}var zu=class extends C{constructor(e){super(e),this.downsample_factor=e.downsample_factor??2,this.do_image_splitting=e.do_image_splitting??!0,this.min_tiles=e.min_tiles??2,this.max_tiles=e.max_tiles??10,this.use_thumbnail=e.use_thumbnail??!0,this.min_image_tokens=e.min_image_tokens??64,this.max_image_tokens=e.max_image_tokens??256,this.encoder_patch_size=e.encoder_patch_size??e.patch_size??16,this.tile_size=e.tile_size??512,this.max_pixels_tolerance=e.max_pixels_tolerance??2,this.return_row_col_info=e.return_row_col_info??!1;let s=this.max_image_tokens*this.downsample_factor**2,r=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(s,r)}_is_image_too_large(e,s){let r=this.encoder_patch_size*this.downsample_factor,n=Math.max(this.encoder_patch_size,rb(e,r)),o=Math.max(this.encoder_patch_size,rb(s,r));return n*o>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,s){let r=EA(this.min_tiles,this.max_tiles),[n,o]=vA(s/e,r,s,e,this.tile_size);return{grid_width:n,grid_height:o,target_width:this.tile_size*n,target_height:this.tile_size*o}}async _call(e,{return_row_col_info:s=null}={}){let r;Array.isArray(e)?Array.isArray(e[0])?r=e:r=[e]:r=[[e]];let n=[],o=[],i=[],a=[],l=[],c=[];for(let u of r){let _=await Promise.all(u.map(d=>this.preprocess(d,{do_pad:!1})));for(let{pixel_values:d}of _){let[,m,h]=d.dims,g=d.unsqueeze_(0),x=this.encoder_patch_size*this.downsample_factor,w=x**2,[y,b]=Ns(Math.max(x,m),Math.max(x,h),x,this.min_image_tokens*w,this.max_image_tokens*w).map(P=>Math.max(x,P)),v,k=1,O=1,N=this._is_image_too_large(m,h),q=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(N&&q){let{grid_width:P,grid_height:R,target_width:F,target_height:U}=this._get_grid_layout(m,h);k=R,O=P;let j=await De(g,{size:[U,F]});v=[];for(let W=0;W<R;++W)for(let Z=0;Z<P;++Z){let te=W*this.tile_size,M=Z*this.tile_size;v.push(j.slice(null,null,[te,te+this.tile_size],[M,M+this.tile_size]))}this.use_thumbnail&&P*R!==1&&v.push(await De(g,{size:[b,y]}))}else v=[await De(g,{size:[b,y]})];for(let P of v){let[,,R,F]=P.dims,U=AA(P,this.encoder_patch_size),{padded:j,mask:W}=MA(U,this.max_num_patches);n.push(j),o.push(W),i.push([Math.floor(R/this.encoder_patch_size),Math.floor(F/this.encoder_patch_size)])}a.push(k),l.push(O),c.push([b,y])}}let p={pixel_values:oe(n,0),pixel_attention_mask:Ue(o,0),spatial_shapes:new E("int64",BigInt64Array.from(i.flat(),BigInt),[i.length,2])};return(s??this.return_row_col_info)&&(p.image_rows=a,p.image_cols=l,p.image_sizes=c),p}};var Iu=class extends C{};var $s=class extends C{post_process_panoptic_segmentation(...e){return fa(...e)}post_process_instance_segmentation(...e){return ma(...e)}},Tu=class extends $s{};var Cu=class extends $s{};var ka=class extends C{},Pu=class extends ka{};var va=class extends C{},Nu=class extends va{};var Ea=class extends C{},Lu=class extends Ea{};var Aa=class extends C{},$u=class extends Aa{};var Ma=class extends C{},Fu=class extends Ma{};var Ru=class extends Ls{};var Fs=class extends C{post_process_object_detection(...e){return $t(...e)}},Du=class extends Fs{};var ju=class extends Fs{};var He=336,SA=[2,3],{ceil:Bu,floor:Rs,sqrt:qu}=Math,Uu=class extends C{constructor(e){super({...e,do_normalize:!0,do_pad:!0,pad_size:"custom",do_convert_rgb:!0,do_resize:!0}),this._num_crops=e.num_crops}calc_num_image_tokens_from_image_size(e,s){let{num_img_tokens:r}=this.config;return Rs((Rs(s/He)*Rs(e/He)+1)*r+1+(Rs(s/He)+1)*qu(r))}get_resize_output_image_size(e,s){let r=this._num_crops,[n,o]=e.size,i=n/o,a=1;for(;a*Math.ceil(a/i)<=r;)a+=1;a-=1;let l=Math.floor(a*336),c=Math.floor(l/i);return[l,c]}pad_image(e,s,r,n={}){let[o,i]=s,a=He*Bu(o/He),l=He*Bu(i/He),c=[1,1,1].map((p,u)=>(p-this.image_mean[u])/this.image_std[u]);return super.pad_image(e,s,{width:l,height:a},{center:!0,constant_values:c,...n})}async _call(e,{num_crops:s=null}={}){if(this._num_crops=s??=this.config.num_crops,s<4||qu(s)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);let r=e.length,n=await Promise.all(e.map(_=>this.preprocess(_))),o=n.map(_=>_.original_size),i=n.map(_=>_.reshaped_input_size),a=[];for(let{pixel_values:_}of n){_.unsqueeze_(0);let[d,m]=_.dims.slice(-2),h=await De(_,{size:[He,He],mode:"bicubic"});if(s>0){let g=[],x=qu(s),w=Rs(m/x),y=Rs(d/x);for(let v=0;v<x;++v)for(let k=0;k<x;++k){let O,N,q,P;v===x-1?(N=d-y,P=d):(N=v*y,P=(v+1)*y),k===x-1?(O=m-w,q=m):(O=k*w,q=(k+1)*w);let U=await aa(_,[N,O],[P,q],SA);g.push(U)}let b=await De(oe(g,0),{size:[He,He],mode:"bicubic"});a.push(oe([h,b],0))}else a.push(h)}let l=Ue(a,0),c=i.map(_=>_.map(d=>He*Bu(d/He))),p=new E("int64",c.flat(),[r,2]),u=c.map(([_,d])=>this.calc_num_image_tokens_from_image_size(d,_));return{pixel_values:l,original_sizes:o,reshaped_input_sizes:i,image_sizes:p,num_img_tokens:u}}};var Gu=class extends C{get_resize_output_image_size(e,s){let{longest_edge:r}=s;if(r===void 0)throw new Error("size must contain 'longest_edge'");let[n,o]=e.size,i=Math.max(n,o)/r,a=n,l=o;i>1&&(a=Math.floor(n/i),l=Math.floor(o/i));let{patch_size:c,spatial_merge_size:p}=this.config;if(!p)throw new Error("config must contain 'spatial_merge_size'");let u=c*p,_=Math.floor((a-1)/u)+1,d=Math.floor((l-1)/u)+1;return[_*u,d*u]}};var Wu=class extends C{};var Vu=class extends C{post_process_object_detection(...e){return $t(...e)}};var Gr=class extends C{reshape_input_points(e,s,r,n=!1){e=structuredClone(e);let o=Tc(e);if(o.length===3)n||(o=[1,...o]),e=[e];else if(o.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let i=0;i<e.length;++i){let[a,l]=s[i],[c,p]=r[i],u=[p/l,c/a];for(let _=0;_<e[i].length;++_)for(let d=0;d<e[i][_].length;++d)for(let m=0;m<e[i][_][d].length;++m)e[i][_][d][m]*=u[m%2]}return new E("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,s){let r=Tc(e);if(r.length===2)r=[1,...r],e=[e];else if(r.length!==3)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");if(r.some((n,o)=>n!==s.dims[o]))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new E("int64",e.flat(1/0).map(BigInt),r)}async _call(e,{input_points:s=null,input_labels:r=null,input_boxes:n=null}={}){let o=await super._call(e);if(s&&(o.input_points=this.reshape_input_points(s,o.original_sizes,o.reshaped_input_sizes)),r){if(!o.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");o.input_labels=this.add_input_labels(r,o.input_points)}return n&&(o.input_boxes=this.reshape_input_points(n,o.original_sizes,o.reshaped_input_sizes,!0)),o}async post_process_masks(e,s,r,{mask_threshold:n=0,binarize:o=!0,pad_size:i=null}={}){let a=[];i=i??this.pad_size??this.size;let l=[i.height,i.width];for(let c=0;c<s.length;++c){let p=s[c],u=r[c],_=await De(e[c],{mode:"bilinear",size:l});if(_=_.slice(null,null,[0,u[0]],[0,u[1]]),_=await De(_,{mode:"bilinear",size:p}),o){let d=_.data,m=new Uint8Array(d.length);for(let h=0;h<d.length;++h)d[h]>n&&(m[h]=1);_=new E("bool",m,_.dims)}a.push(_)}return a}generate_crop_boxes(e,s,{crop_n_layers:r=0,overlap_ratio:n=512/1500,points_per_crop:o=32,crop_n_points_downscale_factor:i=1}={}){}};var Sa=class extends C{post_process_semantic_segmentation(...e){return da(...e)}},Hu=class extends Sa{};var Oa=class extends C{post_process_semantic_segmentation(...e){return da(...e)}},Ku=class extends Oa{};var Xu=class extends C{};var Qu=class extends C{pad_image(e,s,r,n={}){let[o,i,a]=s;return super.pad_image(e,s,{width:i+(r-i%r)%r,height:o+(r-o%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}};var za=class extends C{},Yu=class extends za{};var Ju=class extends C{async _call(e,s){Array.isArray(e)||(e=[e]),Array.isArray(s)||(s=[s]);let r=await Promise.all(e.map(i=>this.preprocess(i))),n=await Promise.all(s.map(i=>this.preprocess(i,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:Ue(r.map((i,a)=>oe([i.pixel_values,n[a].pixel_values],0)),0),original_sizes:r.map(i=>i.original_size),reshaped_input_sizes:r.map(i=>i.reshaped_input_size)}}};var Zu=class extends C{post_process_pose_estimation(e,s,{threshold:r=null}={}){let n=e.tolist(),[o,i,a,l]=e.dims,c=[];for(let p=0;p<o;++p){let u=n[p],_=s[p],d=[];for(let m=0;m<_.length;++m){let h=_[m],g=[],x=[],w=[],y=h.at(-2)/l,b=h.at(-1)/a;for(let v=0;v<u.length;++v){let[k,O]=[0,0],N=0,q=-1/0,P=u[v];for(let F=0;F<P.length;++F){let U=P[F];for(let j=0;j<U.length;++j){let W=U[j];N+=W,q=Math.max(q,W),k+=(j+.5)*W,O+=F*W}}if(r!=null&&q<r)continue;let R=[y*k/N,b*O/N];g.push(R),w.push(v),x.push(q)}d.push({bbox:h,scores:x,labels:w,keypoints:g})}c.push(d)}return c}};var Ia=class extends C{post_process_object_detection(...e){return $t(...e)}},e_=class extends Ia{};var le=class{static async from_pretrained(e,s={}){let r=await Ce(e,yt,!0,s),n=r.image_processor_type??r.feature_extractor_type,o=Ds[n?.replace(/Fast$/,"")];return o||(n!==void 0&&$.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${Nt}.`),o=C),new o(r)}};var t_=class extends B{static tokenizer_class=G;static image_processor_class=le;constructor(e,s,r){super(e,s,r);let{tasks_answer_post_processing_type:n,task_prompts_without_inputs:o,task_prompts_with_input:i}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(n??{})),this.task_prompts_without_inputs=new Map(Object.entries(o??{})),this.task_prompts_with_input=new Map(Object.entries(i??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e=="string"&&(e=[e]);let s=[];for(let r of e)if(this.task_prompts_without_inputs.has(r))s.push(this.task_prompts_without_inputs.get(r));else{for(let[n,o]of this.task_prompts_with_input)if(r.includes(n)){s.push(o.replaceAll("{input}",r).replaceAll(n,""));break}s.length!==e.length&&s.push(r)}return s}post_process_generation(e,s,r){let n=this.tasks_answer_post_processing_type.get(s)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let o;switch(n){case"pure_text":o=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":let i=n==="ocr"?"quad_boxes":"bboxes",a=e.matchAll(this.regexes[i]),l=[],c=[];for(let[p,u,..._]of a)l.push(u?u.trim():l.at(-1)??""),c.push(_.map((d,m)=>(Number(d)+.5)/this.size_per_bin*r[m%2]));o={labels:l,[i]:c};break;default:throw new Error(`Task "${s}" (of type "${n}") not yet implemented.`)}return{[s]:o}}async _call(e,s=null,r={}){if(!e&&!s)throw new Error("Either text or images must be provided");let n=await this.image_processor(e,r),o=s?this.tokenizer(this.construct_prompts(s),r):{};return{...n,...o}}};var s_=class extends B{static tokenizer_class=G;static image_processor_class=le;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,s,r){super(e,s,r),this.image_seq_length=this.config.image_seq_length;let{boi_token:n,image_token:o,eoi_token:i}=this.tokenizer.config;this.boi_token=n,this.image_token=o,this.eoi_token=i;let a=o.repeat(this.image_seq_length);this.full_image_sequence=`
11
11
 
12
- ${o}${d}${i}
12
+ ${n}${a}${i}
13
13
 
14
- `,this.image_token_id=l,this.boi_token=c,this.image_token=u;let _=u.repeat(this.image_seq_length);this.full_image_sequence=`
14
+ `}async _call(e,s=null,r={}){typeof e=="string"&&(e=[e]);let n;return s&&(n=await this.image_processor(s,r),e=e.map(i=>i.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,r),...n}}};var r_=class extends B{static image_processor_class=le;static feature_extractor_class=ge;static tokenizer_class=G;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,s,r){super(e,s,r),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:n,boa_token:o,audio_token:i,eoa_token:a,image_token_id:l,boi_token:c,image_token:p,eoi_token:u}=this.tokenizer.config;this.audio_token_id=n,this.boa_token=o,this.audio_token=i;let _=i.repeat(this.audio_seq_length);this.full_audio_sequence=`
15
15
 
16
- ${c}${_}${p}
16
+ ${o}${_}${a}
17
17
 
18
- `}async _call(e,s=null,r=null,n={}){typeof e=="string"&&(e=[e]);let o;r&&(o=await this.feature_extractor(r,n),e=e.map(l=>l.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return s&&(a=await this.image_processor(s,n),e=e.map(l=>l.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,n),...a,...o}}};function ov(t,e){let r=t.dims.at(-1)-1,n=t.tolist();n.fill(!1,0,1),n.fill(!1,r);let o=e.tolist();return n.map((a,i)=>a?i:null).filter(a=>a!==null).map(a=>o[a])}var tp=class extends j{static tokenizer_class=L;static image_processor_class=de;async _call(e,s,r={}){let n=e?await this.image_processor(e,r):{};return{...s?this.tokenizer(s,r):{},...n}}post_process_grounded_object_detection(e,s,{box_threshold:r=.25,text_threshold:n=.25,target_sizes:o=null}={}){let{logits:a,pred_boxes:i}=e,l=a.dims[0];if(o!==null&&o.length!==l)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=a.dims.at(1),u=a.sigmoid(),p=u.max(-1).tolist(),d=i.tolist().map(m=>m.map(h=>pu(h))),_=[];for(let m=0;m<l;++m){let h=o!==null?o[m]:null;h!==null&&(d[m]=d[m].map(E=>E.map((A,b)=>A*h[(b+1)%2])));let x=p[m],g=[],w=[],y=[];for(let E=0;E<c;++E){let A=x[E];if(A<=r)continue;let b=d[m][E],O=u[m][E];g.push(A),y.push(b);let N=ov(O.gt(n),s[m]);w.push(N)}_.push({scores:g,boxes:y,labels:this.batch_decode(w)})}return _}};function av(t,e,s,r,n,o){let a="";for(let i=0;i<e;++i){for(let l=0;l<s;++l)a+=r+`<row_${i+1}_col_${l+1}>`+n.repeat(t);a+=`
19
- `}return a+=`
20
- ${r}${o}`+n.repeat(t)+`${r}`,a}function iv(t,e,s,r){return`${e}${r}`+s.repeat(t)+`${e}`}function lv(t,e,s,r,n,o){return t===0&&e===0?iv(s,r,n,o):av(s,t,e,r,n,o)}var va=class extends j{static image_processor_class=de;static tokenizer_class=L;static uses_processor_config=!0;fake_image_token="<fake_token_around_image>";image_token="<image>";global_img_token="<global-img>";async _call(e,s=null,r={}){r.return_row_col_info??=!0;let n;s&&(n=await this.image_processor(s,r)),Array.isArray(e)||(e=[e]);let o=n.rows??[new Array(e.length).fill(0)],a=n.cols??[new Array(e.length).fill(0)],i=this.config.image_seq_len,l=[],c=[];for(let p=0;p<e.length;++p){let d=e[p],_=o[p],m=a[p];l.push(nw(d,this.image_token));let h=_.map((w,y)=>lv(w,m[y],i,this.fake_image_token,this.image_token,this.global_img_token)),x=d.split(this.image_token);if(x.length===0)throw new Error("The image token should be present in the text.");let g=x[0];for(let w=0;w<h.length;++w)g+=h[w]+x[w+1];c.push(g)}return{...this.tokenizer(c),...n}}};var sp=class extends j{static image_processor_class=de;static tokenizer_class=L;static uses_processor_config=!0;constructor(e,s,r){super(e,s,r),this.image_tag=this.config.image_tag,this.image_start_tag=this.config.image_start_tag,this.image_end_tag=this.config.image_end_tag,this.num_image_tokens=this.config.num_image_tokens}async _call(e,{images:s=null,chat_template:r="default"}={}){s?Array.isArray(s)||(s=[s]):s=await Promise.all(e.filter(x=>x.images).flatMap(x=>x.images).map(x=>we.read(x)));let n=this.tokenizer,o=n.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:r}),a=x=>n.encode(x,{add_special_tokens:!1}),i=o.split(this.image_tag),l=i.length-1;if(s.length!==l)throw new Error(`Number of images provided (${s.length}) does not match number of "${this.image_tag}" image tags (${l})`);let[c,u,p]=n.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),d=a(i[0]),_=new Array(d.length).fill(!1);for(let x=1;x<i.length;++x){let g=new Array(this.num_image_tokens).fill(c),w=a(i[x]);d=Pe(d,[u],g,[p],w);let y=new Array(this.num_image_tokens).fill(!0);_=Pe(_,[!1],y,[!1],new Array(w.length).fill(!1))}let m=[1,d.length],h={input_ids:new S("int64",d,m),attention_mask:new S("int64",new Array(d.length).fill(1),m),images_seq_mask:new S("bool",_,m),images_emb_mask:new S("bool",new Array(l*this.num_image_tokens).fill(!0),[1,l,this.num_image_tokens])};if(s&&s.length>0){let x=await this.image_processor(s);return x.pixel_values.unsqueeze_(0),{...h,...x}}return h}};var rp=class extends j{static tokenizer_class=L;static image_processor_class=de;async _call(e=null,s=null,r={}){if(!e&&!s)throw new Error("Either text or images must be provided");let n=e?this.tokenizer(e,r):{},o=s?await this.image_processor(s,r):{};return{...n,...o}}};var np=class extends j{static tokenizer_class=L;static image_processor_class=de;static uses_processor_config=!0;async _call(e,s=null,r={}){let n=await this.image_processor(e,r);if(s){let[a,i]=n.pixel_values.dims.slice(-2),{image_token:l,patch_size:c,num_additional_image_tokens:u}=this.config,p=Math.floor(a/c)*Math.floor(i/c)+u;s=structuredClone(s),Array.isArray(s)||(s=[s]);for(let d=0;d<s.length;++d)s[d]=s[d].replace(l,l.repeat(p))}let o=s?this.tokenizer(s,r):{};return{...n,...o}}};var Jw={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},op=class extends j{static tokenizer_class=L;static image_processor_class=de;get char_tokenizer(){return this.components.char_tokenizer}get bpe_tokenizer(){return this.components.bpe_tokenizer}get wp_tokenizer(){return this.components.wp_tokenizer}_decode_helper(e,s){if(!Jw.hasOwnProperty(s))throw new Error(`Format ${s} is not supported.`);let[r,n]=Jw[s],o=this[r].bind(this),[a,i]=e.dims,l=[],c=[],u=e.tolist();for(let d=0;d<a;++d){let _=u[d],m=[],h=[];for(let g=1;g<i;++g){let[w,y]=ae(ce(_[g]));if(h.push(w),y==n)break;m.push(y)}let x=h.length>0?h.reduce((g,w)=>g*w,1):0;c.push(m),l.push(x)}return[o(c),l]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(s=>s.replaceAll(" ",""))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(s=>s.replaceAll(" ",""))}batch_decode([e,s,r]){let[n,o]=this._decode_helper(e,"char"),[a,i]=this._decode_helper(s,"bpe"),[l,c]=this._decode_helper(r,"wp"),u=[],p=[];for(let d=0;d<n.length;++d){let[_,m]=ae([o[d],i[d],c[d]]);u.push([n[d],a[d],l[d]][m]),p.push(_)}return{generated_text:u,scores:p,char_preds:n,bpe_preds:a,wp_preds:l}}static async from_pretrained(...e){let s=await super.from_pretrained(...e),r=await L.from_pretrained("Xenova/gpt2"),n=await L.from_pretrained("Xenova/bert-base-uncased");return s.components={image_processor:s.image_processor,char_tokenizer:s.tokenizer,bpe_tokenizer:r,wp_tokenizer:n},s}async _call(e,s=null){let r=await this.image_processor(e);return s&&(r.labels=this.tokenizer(s).input_ids),r}};var ap=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e){return await this.feature_extractor(e)}};var ip=class extends j{static tokenizer_class=L;static image_processor_class=de};var Os="<image>";function cv(t,e,s,r,n){return`${r.repeat(s*n)}${e}${t}
21
- `}var lp=class extends j{static tokenizer_class=L;static image_processor_class=de;static uses_processor_config=!1;async _call(e,s=null,r={}){s||(console.warn("You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."),s=""),Array.isArray(e)||(e=[e]),Array.isArray(s)||(s=[s]);let n=this.tokenizer.bos_token,o=this.image_processor.config.image_seq_length,a;s.some(c=>c.includes(Os))?a=s.map(c=>{let u=c.replaceAll(Os,Os.repeat(o)),p=u.lastIndexOf(Os),d=p===-1?0:p+Os.length;return u.slice(0,d)+n+u.slice(d)+`
22
- `}):(console.warn("You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special image tokens in the text, as many tokens as there are images per each text. It is recommended to add `<image>` tokens in the very beginning of your text. For this call, we will infer how many images each text has and add special tokens."),a=s.map(c=>cv(c,n,o,Os,e.length)));let i=this.tokenizer(a,r);return{...await this.image_processor(e,r),...i}}};var Yw="<|image|>",uv=/<\|image_\d+\|>/g,cp=class extends j{static image_processor_class=de;static tokenizer_class=L;async _call(e,s=null,{padding:r=!0,truncation:n=!0,num_crops:o=null}={}){Array.isArray(e)||(e=[e]);let a,i;if(s){i=await this.image_processor(s,{num_crops:o});let{num_img_tokens:l}=i,c=e.map((p,d)=>p.split(uv).join(Yw.repeat(l[d])));a=this.tokenizer(c,{padding:r,truncation:n});let u=this.tokenizer._tokenizer.token_to_id(Yw);a.input_ids.map_(p=>p==u?-p:p)}else a=this.tokenizer(e);return{...a,...i}}};var up=class extends j{static tokenizer_class=L;static image_processor_class=de;static uses_processor_config=!0;async _call(e,s=null,r={}){let n=await this.image_processor(e,r);if(s){let[a,i]=n.pixel_values.dims.slice(-2),{image_token:l,image_break_token:c,image_end_token:u,patch_size:p,spatial_merge_size:d}=this.config,_=p*d,m=Math.floor(a/_),h=Math.floor(i/_);s=structuredClone(s),Array.isArray(s)||(s=[s]);for(let x=0;x<s.length;++x){let g=l.repeat(h),w=g+c,y=g+u,E=w.repeat(m-1)+y;s[x]=s[x].replace(l,E)}}let o=s?this.tokenizer(s,r):{};return{...n,...o}}};var pp=class extends j{static feature_extractor_class=wr;async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}get sampling_rate(){return this.feature_extractor.config.sampling_rate}};var dp=class extends j{static image_processor_class=de;static tokenizer_class=L;async _call(e,s=null,...r){Array.isArray(e)||(e=[e]);let n,o;if(s&&(n=await this.image_processor(s),o=n.image_grid_thw),o){let i=this.image_processor.config.merge_size**2,l=0,c=o.tolist();e=e.map(u=>{for(;u.includes("<|image_pad|>");){let p=Number(c[l++].reduce((d,_)=>d*_,1n));u=u.replace("<|image_pad|>","<|placeholder|>".repeat(Math.floor(p/i)))}return u.replaceAll("<|placeholder|>","<|image_pad|>")})}return{...this.tokenizer(e),...n}}};var kr=class extends j{static image_processor_class=de;async _call(...e){return await this.image_processor(...e)}post_process_masks(...e){return this.image_processor.post_process_masks(...e)}reshape_input_points(...e){return this.image_processor.reshape_input_points(...e)}};var Ea=class extends kr{},_p=class extends Ea{};var fp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e){return await this.feature_extractor(e)}};var mp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;static uses_processor_config=!0;async _call(e,s=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(s){let a=s.length,{input_features:i}=await this.feature_extractor(s,{...r,max_length:a}),l=Math.round(a/this.config.encoder_ds_factor+1e-4),c=1+Math.ceil(l/this.config.stack_factor);n.audio_token_len=[c],n.audio_values=i;let u=this.config.audio_placeholder;if(!e.includes(u))throw new Error(`The input text does not contain the image token ${u}.`);e=e.replaceAll(u,u.repeat(c))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};var Aa="[AUDIO]",pv="[BEGIN_AUDIO]",dv=375;function _v(t,e){let s=[];for(let r=0;r<t.length;r+=e)s.push(t.subarray(r,Math.min(r+e,t.length)));return s}var hp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;static uses_processor_config=!1;async _call(e,s=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(s){if(!e.includes(Aa))throw new Error(`The input text does not contain the audio token ${Aa}.`);Array.isArray(s)||(s=[s]);let a=e.split(Aa),i=a.length-1;if(i!==s.length)throw new Error(`The number of audio inputs (${s.length}) does not match the number of audio tokens in the text (${i}).`);let l=this.feature_extractor.config.n_samples,c=s.map(m=>_v(m,l)),u=c.map(m=>m.length),p=c.flat(),d=(await Promise.all(p.map(m=>this.feature_extractor(m,r)))).map(m=>m.input_features);n.audio_values=d.length>1?ne(d,0):d[0];let _=a[0];for(let m=0;m<u.length;++m){_+=pv;for(let h=0;h<u[m];++h)_+=Aa.repeat(dv);_+=a[m+1]}e=_}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};var xp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e){return await this.feature_extractor(e)}};var gp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e){return await this.feature_extractor(e)}};var wp=class extends j{static tokenizer_class=L;static feature_extractor_class=ve;async _call(e){return await this.feature_extractor(e)}};var ze=class{static async from_pretrained(e,s={}){let r=await Se(e,ks,!0,s),{image_processor_type:n,feature_extractor_type:o,processor_class:a}=r;if(a&&Ma[a])return Ma[a].from_pretrained(e,s);if(!n&&!o)throw new Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let i={};if(n){let c=Ss[n.replace(/Fast$/,"")];if(!c)throw new Error(`Unknown image_processor_type: '${n}'.`);i.image_processor=new c(r)}if(o){let c=Ss[o];if(c)i.image_processor=new c(r);else{let u=yr[o];if(!u)throw new Error(`Unknown feature_extractor_type: '${o}'.`);i.feature_extractor=new u(r)}}let l={};return new j(l,i,null)}};async function fv(t,e){return await Se(t,"config.json",!0,e)}function Is(t){let e={},s={};switch(t.model_type){case"llava":case"paligemma":case"gemma3":case"florence2":case"llava_onevision":case"idefics3":case"ultravox":case"voxtral":case"smolvlm":case"gemma3n":case"chatterbox":case"mistral3":s=Is(t.text_config);break;case"moondream1":s=Is(t.phi_config);break;case"musicgen":s=Is(t.decoder);break;case"multi_modality":s=Is(t.language_config);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"falcon":case"modernbert-decoder":e.num_heads="num_attention_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size";break;case"gpt_oss":case"llama":case"llama4_text":case"nanochat":case"apertus":case"arcee":case"lfm2":case"lfm2_moe":case"smollm3":case"olmo":case"olmo2":case"olmo3":case"mobilellm":case"granite":case"granitemoehybrid":case"cohere":case"mistral":case"starcoder2":case"qwen2":case"qwen2_vl":case"phi":case"phi3":case"phi3_v":case"llava_qwen2":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size",e.num_attention_heads="num_attention_heads",e.dim_kv="head_dim";break;case"qwen3":case"gemma":case"gemma2":case"vaultgemma":case"gemma3_text":case"gemma3n_text":case"glm":case"helium":case"ernie4_5":case"hunyuan_v1_dense":case"falcon_h1":case"ministral":case"ministral3":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="head_dim";break;case"openelm":e.num_heads="num_kv_heads",e.num_layers="num_transformer_layers",e.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":e.num_heads="num_heads",e.num_layers="num_layers",e.hidden_size="hidden_size";break;case"bloom":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="hidden_size";break;case"mpt":e.num_heads="n_heads",e.num_layers="n_layers",e.hidden_size="d_model";break;case"exaone":e.num_heads="num_key_value_heads",e.num_layers="num_layers",e.dim_kv="head_dim",e.num_attention_heads="num_attention_heads";break;case"youtu":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="qk_head_dim",e.num_attention_heads="num_attention_heads";break;case"t5":case"mt5":case"longt5":e.num_decoder_layers="num_decoder_layers",e.num_decoder_heads="num_heads",e.decoder_dim_kv="d_kv",e.num_encoder_layers="num_layers",e.num_encoder_heads="num_heads",e.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"lite-whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="d_model",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="d_model";break;case"speecht5":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="hidden_size",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="hidden_size";break;case"trocr":e.num_encoder_layers=e.num_decoder_layers="decoder_layers",e.num_encoder_heads=e.num_decoder_heads="decoder_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="d_model";break;case"musicgen_decoder":e.num_encoder_layers=e.num_decoder_layers="num_hidden_layers",e.num_encoder_heads=e.num_decoder_heads="num_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"moonshine":e.num_decoder_layers="decoder_num_hidden_layers",e.num_decoder_heads="decoder_num_key_value_heads",e.num_encoder_layers="encoder_num_hidden_layers",e.num_encoder_heads="encoder_num_key_value_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"vision-encoder-decoder":let n=Is(t.decoder),o="num_decoder_layers"in n,a=Me(t,["model_type","is_encoder_decoder"]);return o?(a.num_decoder_layers=n.num_decoder_layers,a.num_decoder_heads=n.num_decoder_heads,a.decoder_hidden_size=n.decoder_hidden_size,a.num_encoder_layers=n.num_encoder_layers,a.num_encoder_heads=n.num_encoder_heads,a.encoder_hidden_size=n.encoder_hidden_size):(a.num_layers=n.num_layers,a.num_heads=n.num_heads,a.hidden_size=n.hidden_size),a}let r={...s,...Me(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)r[n]=t[e[n]];return r}function Oa(t,e){if(["lfm2","lfm2_moe"].includes(t.model_type)){let s=e?.prefix??"past_key_values",r=s==="present"?"present":"past",n={},{layer_types:o,num_attention_heads:a,num_key_value_heads:i,hidden_size:l,conv_L_cache:c}=t,u=l/a,p=e?.batch_size??1;for(let d=0;d<o.length;++d)if(o[d]==="full_attention")for(let _ of["key","value"])n[`${s}.${d}.${_}`]=[p,i,0,u];else if(o[d]==="conv")n[`${r}_conv.${d}`]=[p,l,c];else throw new Error(`Unsupported layer type: ${o[d]}`);return n}else if(["granitemoehybrid","falcon_h1"].includes(t.model_type)){let s=e?.prefix??"past_key_values",r=s==="present"?"present":"past",n={},{layer_types:o,num_hidden_layers:a,num_attention_heads:i,num_key_value_heads:l,hidden_size:c,mamba_d_conv:u,mamba_n_heads:p,mamba_d_head:d,mamba_d_state:_,mamba_n_groups:m,mamba_expand:h,mamba_d_ssm:x}=t,g=c/i,w=e?.batch_size??1,y=(x??h*c)+2*m*_;for(let E=0;E<a;++E)if((!o||o[E]==="mamba")&&(n[`${r}_conv.${E}`]=[w,y,u],n[`${r}_ssm.${E}`]=[w,p,d,_]),!o||o[E]==="attention")for(let A of["key","value"])n[`${s}.${E}.${A}`]=[w,l,0,g];return n}return mv(t,e)}function mv(t,{prefix:e="past_key_values",batch_size:s=1}={}){let r={},n=t.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n){let o=n.encoder_dim_kv??n.encoder_hidden_size/n.num_encoder_heads,a=n.decoder_dim_kv??n.decoder_hidden_size/n.num_decoder_heads,i=[s,n.num_encoder_heads,0,o],l=[s,n.num_decoder_heads,0,a];for(let c=0;c<n.num_decoder_layers;++c)r[`${e}.${c}.encoder.key`]=i,r[`${e}.${c}.encoder.value`]=i,r[`${e}.${c}.decoder.key`]=l,r[`${e}.${c}.decoder.value`]=l}else{let o=n.num_heads,a=n.num_layers,i=n.dim_kv??n.hidden_size/(n.num_attention_heads??o);if(n.model_type==="falcon"){let l=[s*o,0,i];for(let c=0;c<a;++c)r[`${e}.${c}.key`]=l,r[`${e}.${c}.value`]=l}else if(n.multi_query){let l=[s*o,0,2*i];for(let c=0;c<a;++c)r[`${e}.${c}.key_value`]=l}else if(n.model_type==="bloom"){let l=[s*o,i,0],c=[s*o,0,i];for(let u=0;u<a;++u)r[`${e}.${u}.key`]=l,r[`${e}.${u}.value`]=c}else if(n.model_type==="openelm")for(let l=0;l<a;++l){let c=[s,o[l],0,i];r[`${e}.${l}.key`]=c,r[`${e}.${l}.value`]=c}else{let l=[s,o,0,i];for(let c=0;c<a;++c)r[`${e}.${c}.key`]=l,r[`${e}.${c}.value`]=l}}return r}var Sa=class t{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=Is(this)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){r&&!(r instanceof t)&&(r=new t(r));let i=r??await fv(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a});return new this(i)}},Yt=class{static async from_pretrained(...e){return Sa.from_pretrained(...e)}};async function Zw(t,e,s,r){let n=`${e}${r}.onnx`,o=`${s.subfolder??""}/${n}`;return await lr(t,o,!0,s,ee.IS_NODE_ENV)}async function ey(t,e,s,r,n,o={}){let a=`${e}${s}.onnx`,i=ee.IS_NODE_ENV,l=[];if(n){let c;typeof n=="object"?n.hasOwnProperty(a)?c=n[a]:n.hasOwnProperty(e)?c=n[e]:c=!1:c=n;let u=+c;if(u>Go)throw new Error(`The number of external data chunks (${u}) exceeds the maximum allowed value (${Go}).`);for(let p=0;p<u;++p){let d=`${a}_data${p===0?"":"_"+p}`,_=`${r.subfolder??""}/${d}`;l.push(new Promise(async(m,h)=>{let x=await lr(t,_,!0,r,i);m(x instanceof Uint8Array?{path:d,data:x}:d)}))}}else o.externalData!==void 0&&(l=o.externalData.map(async c=>{if(typeof c.data=="string"){let u=await lr(t,c.data,!0,r);return{...c,data:u}}return c}));return Promise.all(l)}async function hv(t,e,s,r=!1){let n=s.config?.["transformers.js_config"]??{},o=s.device??n.device;o&&typeof o!="string"&&(o.hasOwnProperty(e)?o=o[e]:(console.warn(`device not specified for "${e}". Using the default device.`),o=null));let a=o??(ee.IS_NODE_ENV?"cpu":"wasm"),i=Sw(a),l=n.device_config??{};l.hasOwnProperty(a)&&(n={...n,...l[a]});let c=s.dtype??n.dtype;if(typeof c!="string"&&(c&&c.hasOwnProperty(e)?c=c[e]:(c=Xl[a]??Ne.fp32,console.warn(`dtype not specified for "${e}". Using the default dtype (${c}) for this device (${a}).`))),c===Ne.auto){let A=n.dtype;typeof A!="string"&&(A=A?.[e]),A&&A!==Ne.auto&&Ne.hasOwnProperty(A)?c=A:c=Xl[a]??Ne.fp32}let u=c;if(Kl.hasOwnProperty(u)){if(a==="webgpu"&&!ee.IS_NODE_ENV&&u===Ne.fp16&&!await Tw())throw new Error(`The device (${a}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${u}. Should be one of: ${Object.keys(Ne).join(", ")}`);let p=n.kv_cache_dtype,d=p?typeof p=="string"?p:p[u]??"float32":void 0;if(d&&!["float32","float16"].includes(d))throw new Error(`Invalid kv_cache_dtype: ${d}. Should be one of: float32, float16`);let _=Kl[u],m={...s.session_options};m.executionProviders??=i;let h=n.free_dimension_overrides;h?m.freeDimensionOverrides??=h:a.startsWith("webnn")&&!m.freeDimensionOverrides&&console.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${a}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let x=Zw(t,e,s,_),g=s.use_external_data_format??n.use_external_data_format,w=await ey(t,e,_,s,g,m);if(w.length>0&&!ee.IS_NODE_ENV&&(m.externalData=w),r&&a==="webgpu"&&p!==!1){let A=Oa(s.config,{prefix:"present"});if(Object.keys(A).length>0&&!ur()){let b={};for(let O in A)b[O]="gpu-buffer";m.preferredOutputLocation=b}}return{buffer_or_path:await x,session_options:m,session_config:{dtype:u,kv_cache_dtype:d,device:a}}}async function Fe(t,e,s,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(e).map(async n=>{let{buffer_or_path:o,session_options:a,session_config:i}=await hv(t,e[n],s,n===r),l=await Ko(o,a,i);return[n,l]})))}function ty(t){for(let e in t)Jo(t[e])?t[e]=new S(t[e]):typeof t[e]=="object"&&ty(t[e]);return t}async function q(t,e){let s=xv(t,e);try{let r=Object.fromEntries(Object.entries(s).map(([o,a])=>{let i=a.ort_tensor;return ee.IS_NODE_ENV&&typeof Float16Array<"u"&&i.cpuData instanceof Float16Array&&(i.cpuData=new Uint16Array(i.cpuData.buffer)),[o,i]})),n=await Qo(t,r);return ty(n)}catch(r){let n=Object.fromEntries(Object.entries(s).map(([o,a])=>{let i={type:a.type,dims:a.dims,location:a.location};return i.location!=="gpu-buffer"&&(i.data=a.data),[o,i]}));throw console.error(`An error occurred during model execution: "${r}".`),console.error("Inputs given to model:",n),r}}function xv(t,e){let s=Object.create(null),r=[];for(let a of t.inputNames){let i=e[a];if(!(i instanceof S)){r.push(a);continue}s[a]=ur()?i.clone():i}if(r.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(", ")}.`);let n=Object.keys(e).length,o=t.inputNames.length;if(n>o){let a=Object.keys(e).filter(i=>!t.inputNames.includes(i));console.warn(`WARNING: Too many inputs were provided (${n} > ${o}). The following inputs will be ignored: "${a.join(", ")}".`)}return s}var ue=class{};var z=class extends ue{constructor({logits:e,...s}){super(),this.logits=e;let r=Object.values(s);r.length>0&&(this.attentions=r)}},K=class extends ue{constructor({logits:e}){super(),this.logits=e}},J=class extends ue{constructor({logits:e}){super(),this.logits=e}},oe=class extends ue{constructor({start_logits:e,end_logits:s}){super(),this.start_logits=e,this.end_logits=s}},$e=class extends ue{constructor({logits:e}){super(),this.logits=e}};var Ia=class extends ue{constructor({alphas:e}){super(),this.alphas=e}};var Qe=class extends ke{_call(e,s){throw Error("`_call` should be implemented in a subclass")}},vr=class extends ke{_call(e,s){throw Error("`_call` should be implemented in a subclass")}},Zt=class extends ke{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,s){let r=s;for(let n of this.processors)r=n(e,r);return r}[Symbol.iterator](){return this.processors.values()}},za=class extends Qe{constructor(e){super(),this.bos_token_id=e}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===1){let n=s[r].data;n.fill(-1/0),n[this.bos_token_id]=0}return s}},Ta=class extends Qe{constructor(e,s){super(),this.max_length=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===this.max_length-1){let n=s[r].data;n.fill(-1/0);for(let o of this.eos_token_id)n[o]=0}return s}},zs=class extends Qe{constructor(e,s){super(),this.begin_suppress_tokens=e,this.begin_index=s}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===this.begin_index){let n=s[r].data;for(let o of this.begin_suppress_tokens)n[o]=-1/0}return s}},Pa=class extends Qe{constructor(e,s){super(),this.eos_token_id=Array.isArray(e.eos_token_id)?e.eos_token_id[0]:e.eos_token_id,this.no_timestamps_token_id=e.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=s.length,s.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data;if(n[this.no_timestamps_token_id]=-1/0,e[r].length===this.begin_index-1){n.fill(-1/0),n[this.timestamp_begin]=0;continue}let o=e[r].slice(this.begin_index),a=o.length>=1&&o[o.length-1]>=this.timestamp_begin,i=o.length<2||o[o.length-2]>=this.timestamp_begin;if(a&&(i?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[r].length===this.begin_index&&this.max_initial_timestamp_index!==null){let p=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(p+1).fill(-1/0)}let l=ql(n),c=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((p,d)=>p+d)),u=ae(l.subarray(0,this.timestamp_begin))[0];c>u&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return s}},Ca=class extends Qe{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let s=e.length,r=[];for(let o=0;o<s+1-this.no_repeat_ngram_size;++o){let a=[];for(let i=0;i<this.no_repeat_ngram_size;++i)a.push(e[o+i]);r.push(a.map(Number))}let n=new Map;for(let o of r){let a=o.slice(0,o.length-1),i=JSON.stringify(a),l=n.get(i)??[];l.push(o[o.length-1]),n.set(i,l)}return n}getGeneratedNgrams(e,s){let r=s.slice(s.length+1-this.no_repeat_ngram_size,s.length);return e.get(JSON.stringify(r.map(Number)))??[]}calcBannedNgramTokens(e){let s=[];if(e.length+1<this.no_repeat_ngram_size)return s;{let r=this.getNgrams(e);return this.getGeneratedNgrams(r,e)}}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data,o=this.calcBannedNgramTokens(e[r]);for(let a of o)n[a]=-1/0}return s}},Na=class extends Qe{constructor(e){super(),this.penalty=e}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data;for(let o of new Set(e[r])){let a=Number(o);n[a]<0?n[a]*=this.penalty:n[a]/=this.penalty}}return s}},La=class extends Qe{constructor(e,s){super(),this.min_length=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length<this.min_length){let n=s[r].data;for(let o of this.eos_token_id)n[o]=-1/0}return s}},$a=class extends Qe{constructor(e,s,r){super(),this.prompt_length_to_skip=e,this.min_new_tokens=s,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length-this.prompt_length_to_skip<this.min_new_tokens){let o=s[r].data;for(let a of this.eos_token_id)o[a]=-1/0}return s}},Ra=class extends Qe{constructor(e,s){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data,o=e[r];for(let a of this.bad_words_ids){if(o.length<a.length-1)continue;let i=!0;for(let l=1;l<=a.length-1;++l)if(a.at(-l-1)!=o.at(-l)){i=!1;break}i&&(n[a.at(-1)]=-1/0)}}return s}},Fa=class extends Qe{constructor(e){if(super(),e<=1)throw new Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,s){if(s.dims[0]!==2*e.length)throw new Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${s.dims[0]} for the logits and ${e.length} for the input ids.`);let r=e.length,n=s.slice([0,r],null),o=s.slice([r,s.dims[0]],null);for(let a=0;a<o.data.length;++a)o.data[a]+=(n.data[a]-o.data[a])*this.guidance_scale;return o}},Da=class extends vr{constructor(e){if(super(),typeof e!="number"||e<=0){let s=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(s+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,s){let r=s.data;for(let n=0;n<r.length;++n)r[n]/=this.temperature;return s}},sy=class extends vr{constructor(e,{filter_value:s=-1/0,min_tokens_to_keep:r=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(r)||r<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${r}`);this.top_p=e,this.filter_value=s,this.min_tokens_to_keep=r}},ry=class extends vr{constructor(e,{filter_value:s=-1/0,min_tokens_to_keep:r=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,r),this.filter_value=s}};var Ts=class{max_length=20;max_new_tokens=null;min_length=0;min_new_tokens=null;early_stopping=!1;max_time=null;do_sample=!1;num_beams=1;num_beam_groups=1;penalty_alpha=null;use_cache=!0;temperature=1;top_k=50;top_p=1;typical_p=1;epsilon_cutoff=0;eta_cutoff=0;diversity_penalty=0;repetition_penalty=1;encoder_repetition_penalty=1;length_penalty=1;no_repeat_ngram_size=0;bad_words_ids=null;force_words_ids=null;renormalize_logits=!1;constraints=null;forced_bos_token_id=null;forced_eos_token_id=null;remove_invalid_values=!1;exponential_decay_length_penalty=null;suppress_tokens=null;streamer=null;begin_suppress_tokens=null;forced_decoder_ids=null;guidance_scale=null;num_return_sequences=1;output_attentions=!1;output_hidden_states=!1;output_scores=!1;return_dict_in_generate=!1;pad_token_id=null;bos_token_id=null;eos_token_id=null;encoder_no_repeat_ngram_size=0;decoder_start_token_id=null;generation_kwargs={};constructor(e){Object.assign(this,Me(e,Object.getOwnPropertyNames(this)))}};var Ps=class extends ke{_call(e,s){throw Error("StoppingCriteria needs to be subclassed")}},ja=class t extends ke{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof t?e=e.criteria:e instanceof Ps&&(e=[e]),this.criteria.push(...e)}_call(e,s){let r=new Array(e.length).fill(!1);for(let n of this.criteria){let o=n(e,s);for(let a=0;a<r.length;++a)r[a]||=o[a]}return r}[Symbol.iterator](){return this.criteria.values()}},Ba=class extends Ps{constructor(e,s=null){super(),this.max_length=e,this.max_position_embeddings=s}_call(e){return e.map(s=>s.length>=this.max_length)}},Ua=class extends Ps{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,s){return e.map(r=>{let n=r.at(-1);return this.eos_token_id.some(o=>n==o)})}},ny=class extends Ps{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,s){return new Array(e.length).fill(this.interrupted)}};var es=class extends ke{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error("sample should be implemented in subclasses.")}getLogits(e,s){let r=e.dims.at(-1),n=e.data;if(s===-1)n=n.slice(-r);else{let o=s*r;n=n.slice(o,o+r)}return n}randomSelect(e){let s=0;for(let n=0;n<e.length;++n)s+=e[n];let r=Math.random()*s;for(let n=0;n<e.length;++n)if(r-=e[n],r<=0)return n;return 0}static getSampler(e){if(e.do_sample)return new bp(e);if(e.num_beams>1)return new kp(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new yp(e)}},yp=class extends es{async sample(e){let s=ae(e.data)[1];return[[BigInt(s),0]]}},bp=class extends es{async sample(e){let s=e.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));let[r,n]=await ot(e,s),o=ce(r.data);return Array.from({length:this.generation_config.num_beams},()=>{let a=this.randomSelect(o);return[n.data[a],Math.log(o[a])]})}},kp=class extends es{async sample(e){let s=e.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));let[r,n]=await ot(e,s),o=ce(r.data);return Array.from({length:this.generation_config.num_beams},(a,i)=>[n.data[i],Math.log(o[i])])}};var Er=null;function ay(t){Er=t}function vp(t){if(t instanceof S)return t;if(t.length===0)throw Error("items must be non-empty");if(Array.isArray(t[0])){if(t.some(e=>e.length!==t[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new S("int64",BigInt64Array.from(t.flat().map(e=>BigInt(e))),[t.length,t[0].length])}else return new S("int64",BigInt64Array.from(t.map(e=>BigInt(e))),[1,t.length])}function Ep(t){return new S("bool",[t],[1])}var C={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15},oy={[C.DecoderOnly]:{can_generate:!0,forward:Ue,prepare_inputs:Ar},[C.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Ue,prepare_inputs:Ar},[C.Seq2Seq]:{can_generate:!0,forward:qa,prepare_inputs:Mr},[C.Vision2Seq]:{can_generate:!0,forward:qa,prepare_inputs:Mr},[C.Musicgen]:{can_generate:!0,forward:qa},[C.EncoderDecoder]:{can_generate:!1,forward:qa},[C.ImageTextToText]:{can_generate:!0,forward:yv,prepare_inputs:Ga},[C.AudioTextToText]:{can_generate:!0,forward:wv,prepare_inputs:Ga},[C.Phi3V]:{can_generate:!0,prepare_inputs:Ga},[C.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Ga},[C.MultiModality]:{can_generate:!0},[C.AutoEncoder]:{can_generate:!1,forward:gv},[C.Chatterbox]:{can_generate:!0,forward:Je},default:{can_generate:!1,forward:Je}},ss=new Map,Wa=new Map,ts=new Map,f=class extends ke{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,s,r){super(),this.config=e,this.sessions=s,this.configs=r;let n=ts.get(this.constructor),o=ss.get(n),a=oy[o]??oy.default;this.can_generate=a.can_generate,this._forward=a.forward,this._prepare_inputs_for_generation=a.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let s of Object.values(this.sessions))e.push(s.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:c=null,dtype:u=null,use_external_data_format:p=null,session_options:d={}}={}){let _={progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:c,dtype:u,use_external_data_format:p,session_options:d},m=ts.get(this),h=ss.get(m);r=_.config=await Yt.from_pretrained(e,_);let x;if(h===C.DecoderOnly)x=await Promise.all([Fe(e,{model:_.model_file_name??"model"},_,"model"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.Seq2Seq||h===C.Vision2Seq)x=await Promise.all([Fe(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},_,"decoder_model_merged"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.MaskGeneration)x=await Promise.all([Fe(e,{model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"},_)]);else if(h===C.EncoderDecoder)x=await Promise.all([Fe(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},_,"decoder_model_merged")]);else if(h===C.ImageTextToText){let g={embed_tokens:"embed_tokens",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};r.is_encoder_decoder&&(g.model="encoder_model"),x=await Promise.all([Fe(e,g,_,"decoder_model_merged"),bt(e,{generation_config:"generation_config.json"},_)])}else if(h===C.AudioTextToText){let g={embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"};x=await Promise.all([Fe(e,g,_,"decoder_model_merged"),bt(e,{generation_config:"generation_config.json"},_)])}else if(h===C.ImageAudioTextToText){let g={embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};x=await Promise.all([Fe(e,g,_),bt(e,{generation_config:"generation_config.json"},_)])}else if(h===C.Musicgen)x=await Promise.all([Fe(e,{model:"text_encoder",decoder_model_merged:"decoder_model_merged",encodec_decode:"encodec_decode"},_,"decoder_model_merged"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.MultiModality)x=await Promise.all([Fe(e,{prepare_inputs_embeds:"prepare_inputs_embeds",model:"language_model",lm_head:"lm_head",gen_head:"gen_head",gen_img_embeds:"gen_img_embeds",image_decode:"image_decode"},_,"model"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.Phi3V)x=await Promise.all([Fe(e,{prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"},_,"model"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.Chatterbox)x=await Promise.all([Fe(e,{embed_tokens:"embed_tokens",speech_encoder:"speech_encoder",model:"language_model",conditional_decoder:"conditional_decoder"},_,"model"),bt(e,{generation_config:"generation_config.json"},_)]);else if(h===C.AutoEncoder)x=await Promise.all([Fe(e,{encoder_model:"encoder_model",decoder_model:"decoder_model"},_)]);else if(h===C.Supertonic)x=await Promise.all([Fe(e,{text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"},_)]);else{if(h===void 0){let g=m??r?.model_type;g!=="custom"&&console.warn(`Model type for '${g}' not found, assuming encoder-only architecture. Please report this at ${bs}.`)}x=await Promise.all([Fe(e,{model:_.model_file_name??"model"},_)])}return new this(r,...x)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,s,r=null){let n=new Zt;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new Na(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new Ca(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new Ra(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new La(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&n.push(new $a(s,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new za(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new Ta(e.max_length,e.forced_eos_token_id)),e.begin_suppress_tokens!==null){let o=s>1||e.forced_bos_token_id===null?s:s+1;n.push(new zs(e.begin_suppress_tokens,o))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new Fa(e.guidance_scale)),e.temperature===0&&e.do_sample&&(console.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&n.push(new Da(e.temperature)),r!==null&&n.extend(r),n}_prepare_generation_config(e,s,r=Ts){let n={...this.config};for(let a of["decoder","generator","text_config"])a in n&&Object.assign(n,n[a]);let o=new r(n);return Object.assign(o,this.generation_config??{}),e&&Object.assign(o,e),s&&Object.assign(o,Me(s,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,s=null){let r=new ja;return e.max_length!==null&&r.push(new Ba(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&r.push(new Ua(e.eos_token_id)),s&&r.extend(s),r}_validate_model_class(){if(!this.can_generate){let e=[Er.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,Er.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,Er.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,Er.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),s=ts.get(this.constructor),r=new Set,n=this.config.model_type;for(let a of e){let i=a?.get(n);i&&r.add(i)}let o=`The current model class (${s}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw r.size>0&&(o+=` Please use the following class instead: ${[...r].join(", ")}`),Error(o)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:s,model_inputs:r,is_encoder_decoder:n}){return r.past_key_values=this.getPastKeyValues(s,r.past_key_values),r.input_ids=new S("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in r:r.attention_mask=ne([r.attention_mask,Oe([r.attention_mask.dims[0],1])],1),r.position_ids=null,r}_prepare_model_inputs({inputs:e,bos_token_id:s,model_kwargs:r}){let n=Me(r,this.forward_params),o=this.main_input_name;if(o in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[o]=e;return{inputs_tensor:n[o],model_inputs:n,model_input_name:o}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:s,model_input_name:r,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!s.inputs_embeds&&"_prepare_inputs_embeds"in this){let{input_ids:a,pixel_values:i,attention_mask:l,...c}=s,u=await this._prepare_inputs_embeds(s);s={...c,...Me(u,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await Je(this,s);if(n.guidance_scale!==null&&n.guidance_scale>1)o=ne([o,dr(o,0)],0),"attention_mask"in s&&(s.attention_mask=ne([s.attention_mask,tc(s.attention_mask)],0));else if(s.decoder_input_ids){let a=vp(s.decoder_input_ids).dims[0];if(a!==o.dims[0]){if(o.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${o.dims[0]}) than the decoder inputs (${a}).`);o=ne(Array.from({length:a},()=>o),0)}}return s.encoder_outputs=o,s}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:s,model_kwargs:r,decoder_start_token_id:n,bos_token_id:o,generation_config:a}){let{decoder_input_ids:i,...l}=r;if(!(i instanceof S)){if(i)Array.isArray(i[0])||(i=Array.from({length:e},()=>i));else if(n??=o,this.config.model_type==="musicgen")i=Array.from({length:e*this.config.decoder.num_codebooks},()=>[n]);else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${n.length}`);i=n}else i=Array.from({length:e},()=>[n]);i=vp(i)}return r.decoder_attention_mask=ta(i),{input_ids:i,model_inputs:l}}async generate({inputs:e=null,generation_config:s=null,logits_processor:r=null,stopping_criteria:n=null,streamer:o=null,...a}){this._validate_model_class(),s=this._prepare_generation_config(s,a);let{inputs_tensor:i,model_inputs:l,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),u=this.config.is_encoder_decoder;u&&("encoder_outputs"in l||(l=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:i,model_inputs:l,model_input_name:c,generation_config:s})));let p;u?{input_ids:p,model_inputs:l}=this._prepare_decoder_input_ids_for_generation({batch_size:l[c].dims.at(0),model_input_name:c,model_kwargs:l,decoder_start_token_id:s.decoder_start_token_id,bos_token_id:s.bos_token_id,generation_config:s}):p=l[c];let d=p.dims.at(-1);s.max_new_tokens!==null&&(s.max_length=d+s.max_new_tokens);let _=this._get_logits_processor(s,d,r),m=this._get_stopping_criteria(s,n),h=l[c].dims.at(0),x=es.getSampler(s),g=new Array(h).fill(0),w=p.tolist();o&&o.put(w);let y,E={},A={};for(;;){if(l=this.prepare_inputs_for_generation(w,l,s),y=await this.forward(l),s.return_dict_in_generate)if(s.output_attentions){let G=this.getAttentions(y);for(let D in G)D in E||(E[D]=[]),E[D].push(G[D])}else this._return_dict_in_generate_keys&&Object.assign(A,Me(y,this._return_dict_in_generate_keys));let N=y.logits.slice(null,-1,null).to("float32"),F=_(w,N),R=[];for(let G=0;G<F.dims.at(0);++G){let D=F[G],X=await x(D);for(let[V,re]of X){let Y=BigInt(V);g[G]+=re,w[G].push(Y),R.push([Y]);break}}if(o&&o.put(R),m(w).every(G=>G))break;l=this._update_model_kwargs_for_generation({generated_input_ids:R,outputs:y,model_inputs:l,is_encoder_decoder:u})}o&&o.end();let b=this.getPastKeyValues(y,l.past_key_values,!0),O=new S("int64",w.flat(),[w.length,w[0].length]);if(s.return_dict_in_generate)return{sequences:O,past_key_values:b,...E,...A};for(let N of Object.values(y))N.location==="gpu-buffer"&&N.dispose();return O}getPastKeyValues(e,s,r=!1){let n=Object.create(null);for(let o in e)if(o.startsWith("present")){let a=o.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present","past_key_values"),i=o.includes("encoder");if(i&&s?n[a]=s[a]:n[a]=e[o],s&&(!i||r)){let l=s[a];l.location==="gpu-buffer"&&l.dispose()}}return n}getAttentions(e){let s={};for(let r of["cross_attentions","encoder_attentions","decoder_attentions"])for(let n in e)n.startsWith(r)&&(r in s||(s[r]=[]),s[r].push(e[n]));return s}addPastKeyValues(e,s){if(s)Object.assign(e,s);else{let r=this.sessions.decoder_model_merged??this.sessions.model,n=(e[this.main_input_name]??e.attention_mask)?.dims?.[0]??1,o=r?.config?.kv_cache_dtype??"float32",a=o==="float16"?ws.float16:ws.float32,i=Oa(this.config,{batch_size:n});for(let l in i){let c=i[l].reduce((u,p)=>u*p,1);e[l]=new S(o,new a(c),i[l])}}}async encode_image({pixel_values:e}){return(await q(this.sessions.vision_encoder,{pixel_values:e})).image_features}async encode_text({input_ids:e}){return(await q(this.sessions.embed_tokens,{input_ids:e})).inputs_embeds}async encode_audio({audio_values:e}){return(await q(this.sessions.audio_encoder,{audio_values:e})).audio_features}};async function qa(t,e){let{encoder_outputs:s,input_ids:r,decoder_input_ids:n,...o}=e;if(!s){let a=Me(e,t.sessions.model.inputNames);s=(await Je(t,a)).last_hidden_state}return o.input_ids=n,o.encoder_hidden_states=s,t.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(o.encoder_attention_mask=e.attention_mask),await Ue(t,o,!0)}async function Je(t,e){let s=t.sessions.model,r=Me(e,s.inputNames);if(s.inputNames.includes("inputs_embeds")&&!r.inputs_embeds){if(!e.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await t.encode_text({input_ids:e.input_ids})}if(s.inputNames.includes("token_type_ids")&&!r.token_type_ids){if(!r.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=tc(r.input_ids)}if(s.inputNames.includes("pixel_mask")&&!r.pixel_mask){if(!r.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let n=r.pixel_values.dims;r.pixel_mask=Oe([n[0],n[2],n[3]])}return await q(s,r)}async function gv(t,e){let s=await t.encode(e);return await t.decode(s)}async function Ue(t,e,s=!1){let r=t.sessions[s?"decoder_model_merged":"model"],{past_key_values:n,...o}=e;if(r.inputNames.includes("use_cache_branch")&&(o.use_cache_branch=Ep(!!n)),r.inputNames.includes("position_ids")&&o.attention_mask&&!o.position_ids){let i=["paligemma","gemma3_text","gemma3"].includes(t.config.model_type)?1:0;o.position_ids=bv(o,n,i)}t.addPastKeyValues(o,n);let a=Me(o,r.inputNames);return await q(r,a)}async function iy(t,{encode_function:e,merge_function:s,modality_input_name:r,modality_output_name:n,input_ids:o=null,attention_mask:a=null,position_ids:i=null,inputs_embeds:l=null,past_key_values:c=null,generation_config:u=null,logits_processor:p=null,...d}){let _=d[r];if(!l){if(l=await t.encode_text({input_ids:o,...d}),_&&o.dims[1]!==1){let h=await e({[r]:_,...d});({inputs_embeds:l,attention_mask:a}=s({[n]:h,inputs_embeds:l,input_ids:o,attention_mask:a}))}else if(c&&_&&o.dims[1]===1){let h=o.dims[1],x=Object.values(c)[0].dims.at(-2);a=ne([Oe([o.dims[0],x]),a.slice(null,[a.dims[1]-h,a.dims[1]])],1)}}if(!i&&t.config.model_type==="qwen2_vl"){let{image_grid_thw:h,video_grid_thw:x}=d;[i]=t.get_rope_index(o,h,x,a)}return await Ue(t,{inputs_embeds:l,past_key_values:c,attention_mask:a,position_ids:i,generation_config:u,logits_processor:p},!0)}async function wv(t,e){return await iy(t,{...e,modality_input_name:"audio_values",modality_output_name:"audio_features",encode_function:t.encode_audio.bind(t),merge_function:t._merge_input_ids_with_audio_features.bind(t)})}async function yv(t,e){return await iy(t,{...e,modality_input_name:"pixel_values",modality_output_name:"image_features",encode_function:t.encode_image.bind(t),merge_function:t._merge_input_ids_with_image_features.bind(t)})}function Ap(t,e=0){let[s,r]=t.dims,n=t.data,o=new BigInt64Array(n.length);for(let a=0;a<s;++a){let i=a*r,l=BigInt(e);for(let c=0;c<r;++c){let u=i+c;n[u]===0n?o[u]=BigInt(1):(o[u]=l,l+=n[u])}}return{data:o,dims:t.dims}}function bv(t,e=null,s=0){let{input_ids:r,inputs_embeds:n,attention_mask:o}=t,{data:a,dims:i}=Ap(o,s),l=new S("int64",a,i);if(e){let c=-(r??n).dims.at(1);l=l.slice(null,[c,null])}return l}function Ar(t,e,s,r){let n=s.past_key_values?Object.values(s.past_key_values)[0].dims.at(-2):0;if(!s.attention_mask){let o;for(let a of["input_ids","inputs_embeds","position_ids"])if(s[a]){o=s[a].dims;break}if(!o)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");s.attention_mask=Oe([o[0],n+o[1]])}if(s.past_key_values){let{input_ids:o,attention_mask:a}=s;a&&a.dims[1]>o.dims[1]||n<o.dims[1]&&(s.input_ids=o.slice(null,[n,null]))}return s}function Mr(t,e,s,r){return s.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...s,decoder_input_ids:vp(e)}}function Ga(t,...e){return t.config.is_encoder_decoder?Mr(t,...e):Ar(t,...e)}function ly({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n}){let o=r.tolist().map(c=>c.reduce((u,p,d)=>(p==t&&u.push(d),u),[])),a=o.reduce((c,u)=>c+u.length,0),i=s.dims[0];if(a!==i)throw new Error(`Number of tokens and features do not match: tokens: ${a}, features ${i}`);let l=0;for(let c=0;c<o.length;++c){let u=o[c],p=e[c];for(let d=0;d<u.length;++d)p[u[d]].data.set(s[l++].data)}return{inputs_embeds:e,attention_mask:n}}function _t({image_token_id:t,inputs_embeds:e,image_features:s,input_ids:r,attention_mask:n}){return ly({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n})}function Va({audio_token_id:t,inputs_embeds:e,audio_features:s,input_ids:r,attention_mask:n}){return ly({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n})}async function bt(t,e,s){return Object.fromEntries(await Promise.all(Object.keys(e).map(async r=>{let n=await Se(t,e[r],!1,s);return[r,n]})))}var Oo={};us(Oo,{ASTForAudioClassification:()=>Lp,ASTModel:()=>Np,ASTPreTrainedModel:()=>Ir,AlbertForMaskedLM:()=>Ip,AlbertForQuestionAnswering:()=>Op,AlbertForSequenceClassification:()=>Sp,AlbertModel:()=>Mp,AlbertPreTrainedModel:()=>rs,ApertusForCausalLM:()=>Tp,ApertusModel:()=>zp,ApertusPreTrainedModel:()=>Sr,ArceeForCausalLM:()=>Cp,ArceeModel:()=>Pp,ArceePreTrainedModel:()=>Or,BartForConditionalGeneration:()=>Rp,BartForSequenceClassification:()=>Fp,BartModel:()=>$p,BartPretrainedModel:()=>Cs,BeitForImageClassification:()=>jp,BeitModel:()=>Dp,BeitPreTrainedModel:()=>zr,BertForMaskedLM:()=>Up,BertForQuestionAnswering:()=>Wp,BertForSequenceClassification:()=>qp,BertForTokenClassification:()=>Gp,BertModel:()=>Bp,BertPreTrainedModel:()=>Ot,BlenderbotForConditionalGeneration:()=>Hp,BlenderbotModel:()=>Vp,BlenderbotPreTrainedModel:()=>Tr,BlenderbotSmallForConditionalGeneration:()=>Kp,BlenderbotSmallModel:()=>Xp,BlenderbotSmallPreTrainedModel:()=>Pr,BloomForCausalLM:()=>Jp,BloomModel:()=>Qp,BloomPreTrainedModel:()=>Cr,CLIPModel:()=>od,CLIPPreTrainedModel:()=>ft,CLIPSegForImageSegmentation:()=>ud,CLIPSegModel:()=>cd,CLIPSegPreTrainedModel:()=>Fr,CLIPTextModel:()=>ad,CLIPTextModelWithProjection:()=>Rr,CLIPVisionModel:()=>id,CLIPVisionModelWithProjection:()=>ld,CamembertForMaskedLM:()=>Zp,CamembertForQuestionAnswering:()=>sd,CamembertForSequenceClassification:()=>ed,CamembertForTokenClassification:()=>td,CamembertModel:()=>Yp,CamembertPreTrainedModel:()=>It,ChatterboxModel:()=>Nr,ChatterboxPreTrainedModel:()=>Ha,ChineseCLIPModel:()=>rd,ChineseCLIPPreTrainedModel:()=>Xa,ClapAudioModelWithProjection:()=>$r,ClapModel:()=>nd,ClapPreTrainedModel:()=>Ns,ClapTextModelWithProjection:()=>Lr,CodeGenForCausalLM:()=>dd,CodeGenModel:()=>pd,CodeGenPreTrainedModel:()=>Dr,CohereForCausalLM:()=>fd,CohereModel:()=>_d,CoherePreTrainedModel:()=>jr,ConvBertForMaskedLM:()=>hd,ConvBertForQuestionAnswering:()=>wd,ConvBertForSequenceClassification:()=>xd,ConvBertForTokenClassification:()=>gd,ConvBertModel:()=>md,ConvBertPreTrainedModel:()=>zt,ConvNextForImageClassification:()=>bd,ConvNextModel:()=>yd,ConvNextPreTrainedModel:()=>Br,ConvNextV2ForImageClassification:()=>vd,ConvNextV2Model:()=>kd,ConvNextV2PreTrainedModel:()=>Ur,DFineForObjectDetection:()=>Sd,DFineModel:()=>Md,DFinePreTrainedModel:()=>Gr,DINOv3ConvNextModel:()=>Jd,DINOv3ConvNextPreTrainedModel:()=>ti,DINOv3ViTModel:()=>Yd,DINOv3ViTPreTrainedModel:()=>si,DPTForDepthEstimation:()=>a_,DPTModel:()=>o_,DPTPreTrainedModel:()=>Qr,DacDecoderModel:()=>Vr,DacDecoderOutput:()=>Qa,DacEncoderModel:()=>Wr,DacEncoderOutput:()=>Ka,DacModel:()=>Od,DacPreTrainedModel:()=>Ls,DebertaForMaskedLM:()=>zd,DebertaForQuestionAnswering:()=>Cd,DebertaForSequenceClassification:()=>Td,DebertaForTokenClassification:()=>Pd,DebertaModel:()=>Id,DebertaPreTrainedModel:()=>Tt,DebertaV2ForMaskedLM:()=>Ld,DebertaV2ForQuestionAnswering:()=>Fd,DebertaV2ForSequenceClassification:()=>$d,DebertaV2ForTokenClassification:()=>Rd,DebertaV2Model:()=>Nd,DebertaV2PreTrainedModel:()=>Pt,DecisionTransformerModel:()=>Dd,DecisionTransformerPreTrainedModel:()=>Ja,DeiTForImageClassification:()=>Bd,DeiTModel:()=>jd,DeiTPreTrainedModel:()=>Hr,DepthAnythingForDepthEstimation:()=>Ud,DepthAnythingPreTrainedModel:()=>Ya,DepthProForDepthEstimation:()=>qd,DepthProPreTrainedModel:()=>Za,DetrForObjectDetection:()=>Wd,DetrForSegmentation:()=>Vd,DetrModel:()=>Gd,DetrObjectDetectionOutput:()=>Rs,DetrPreTrainedModel:()=>$s,DetrSegmentationOutput:()=>ei,Dinov2ForImageClassification:()=>Xd,Dinov2Model:()=>Hd,Dinov2PreTrainedModel:()=>Xr,Dinov2WithRegistersForImageClassification:()=>Qd,Dinov2WithRegistersModel:()=>Kd,Dinov2WithRegistersPreTrainedModel:()=>Kr,DistilBertForMaskedLM:()=>r_,DistilBertForQuestionAnswering:()=>s_,DistilBertForSequenceClassification:()=>e_,DistilBertForTokenClassification:()=>t_,DistilBertModel:()=>Zd,DistilBertPreTrainedModel:()=>Ct,DonutSwinModel:()=>n_,DonutSwinPreTrainedModel:()=>ri,EdgeTamModel:()=>Gh,EfficientNetForImageClassification:()=>l_,EfficientNetModel:()=>i_,EfficientNetPreTrainedModel:()=>Jr,ElectraForMaskedLM:()=>u_,ElectraForQuestionAnswering:()=>__,ElectraForSequenceClassification:()=>p_,ElectraForTokenClassification:()=>d_,ElectraModel:()=>c_,ElectraPreTrainedModel:()=>Nt,Ernie4_5ForCausalLM:()=>m_,Ernie4_5Model:()=>f_,Ernie4_5PretrainedModel:()=>Yr,EsmForMaskedLM:()=>x_,EsmForSequenceClassification:()=>g_,EsmForTokenClassification:()=>w_,EsmModel:()=>h_,EsmPreTrainedModel:()=>ns,ExaoneForCausalLM:()=>b_,ExaoneModel:()=>y_,ExaonePreTrainedModel:()=>Zr,FalconForCausalLM:()=>v_,FalconH1ForCausalLM:()=>A_,FalconH1Model:()=>E_,FalconH1PreTrainedModel:()=>tn,FalconModel:()=>k_,FalconPreTrainedModel:()=>en,FastViTForImageClassification:()=>S_,FastViTModel:()=>M_,FastViTPreTrainedModel:()=>sn,Florence2ForConditionalGeneration:()=>O_,Florence2PreTrainedModel:()=>ni,GLPNForDepthEstimation:()=>F_,GLPNModel:()=>R_,GLPNPreTrainedModel:()=>cn,GPT2LMHeadModel:()=>X_,GPT2Model:()=>H_,GPT2PreTrainedModel:()=>fn,GPTBigCodeForCausalLM:()=>j_,GPTBigCodeModel:()=>D_,GPTBigCodePreTrainedModel:()=>un,GPTJForCausalLM:()=>Q_,GPTJModel:()=>K_,GPTJPreTrainedModel:()=>mn,GPTNeoForCausalLM:()=>U_,GPTNeoModel:()=>B_,GPTNeoPreTrainedModel:()=>pn,GPTNeoXForCausalLM:()=>G_,GPTNeoXModel:()=>q_,GPTNeoXPreTrainedModel:()=>dn,Gemma2ForCausalLM:()=>P_,Gemma2Model:()=>T_,Gemma2PreTrainedModel:()=>nn,Gemma3ForCausalLM:()=>N_,Gemma3Model:()=>C_,Gemma3PreTrainedModel:()=>on,Gemma3nForConditionalGeneration:()=>an,Gemma3nPreTrainedModel:()=>oi,GemmaForCausalLM:()=>z_,GemmaModel:()=>I_,GemmaPreTrainedModel:()=>rn,GlmForCausalLM:()=>$_,GlmModel:()=>L_,GlmPreTrainedModel:()=>ln,GptOssForCausalLM:()=>V_,GptOssModel:()=>W_,GptOssPreTrainedModel:()=>_n,GraniteForCausalLM:()=>Y_,GraniteModel:()=>J_,GraniteMoeHybridForCausalLM:()=>ef,GraniteMoeHybridModel:()=>Z_,GraniteMoeHybridPreTrainedModel:()=>xn,GranitePreTrainedModel:()=>hn,GroundingDinoForObjectDetection:()=>tf,GroundingDinoPreTrainedModel:()=>ai,GroupViTModel:()=>sf,GroupViTPreTrainedModel:()=>ii,HeliumForCausalLM:()=>nf,HeliumModel:()=>rf,HeliumPreTrainedModel:()=>gn,HieraForImageClassification:()=>af,HieraModel:()=>of,HieraPreTrainedModel:()=>wn,HubertForCTC:()=>ff,HubertForSequenceClassification:()=>mf,HubertModel:()=>_f,HubertPreTrainedModel:()=>df,HunYuanDenseV1ForCausalLM:()=>xf,HunYuanDenseV1Model:()=>hf,HunYuanDenseV1PreTrainedModel:()=>yn,IJepaForImageClassification:()=>yf,IJepaModel:()=>wf,IJepaPreTrainedModel:()=>bn,Idefics3ForConditionalGeneration:()=>ci,Idefics3PreTrainedModel:()=>li,JAISLMHeadModel:()=>kf,JAISModel:()=>bf,JAISPreTrainedModel:()=>kn,JinaCLIPModel:()=>vf,JinaCLIPPreTrainedModel:()=>Fs,JinaCLIPTextModel:()=>vn,JinaCLIPVisionModel:()=>Ef,Lfm2ForCausalLM:()=>Mf,Lfm2Model:()=>Af,Lfm2MoeForCausalLM:()=>Of,Lfm2MoeModel:()=>Sf,Lfm2MoePreTrainedModel:()=>An,Lfm2PreTrainedModel:()=>En,LiteWhisperForConditionalGeneration:()=>tg,Llama4ForCausalLM:()=>Tf,Llama4PreTrainedModel:()=>ui,LlamaForCausalLM:()=>zf,LlamaModel:()=>If,LlamaPreTrainedModel:()=>Mn,LlavaForConditionalGeneration:()=>Ds,LlavaOnevisionForConditionalGeneration:()=>Ds,LlavaPreTrainedModel:()=>pi,LlavaQwen2ForCausalLM:()=>Cf,LongT5ForConditionalGeneration:()=>Lf,LongT5Model:()=>Nf,LongT5PreTrainedModel:()=>Sn,M2M100ForConditionalGeneration:()=>Rf,M2M100Model:()=>$f,M2M100PreTrainedModel:()=>On,MBartForCausalLM:()=>Wf,MBartForConditionalGeneration:()=>qf,MBartForSequenceClassification:()=>Gf,MBartModel:()=>Uf,MBartPreTrainedModel:()=>os,MPNetForMaskedLM:()=>Im,MPNetForQuestionAnswering:()=>Pm,MPNetForSequenceClassification:()=>zm,MPNetForTokenClassification:()=>Tm,MPNetModel:()=>Om,MPNetPreTrainedModel:()=>Lt,MT5ForConditionalGeneration:()=>$m,MT5Model:()=>Lm,MT5PreTrainedModel:()=>jn,MarianMTModel:()=>Df,MarianModel:()=>Ff,MarianPreTrainedModel:()=>In,MaskFormerForInstanceSegmentation:()=>Bf,MaskFormerModel:()=>jf,MaskFormerPreTrainedModel:()=>zn,Metric3DForDepthEstimation:()=>Vf,Metric3DPreTrainedModel:()=>di,Metric3Dv2ForDepthEstimation:()=>Hf,Metric3Dv2PreTrainedModel:()=>_i,MgpstrForSceneTextRecognition:()=>Xf,MgpstrModelOutput:()=>fi,MgpstrPreTrainedModel:()=>mi,MimiDecoderModel:()=>Pn,MimiDecoderOutput:()=>xi,MimiEncoderModel:()=>Tn,MimiEncoderOutput:()=>hi,MimiModel:()=>Kf,MimiPreTrainedModel:()=>js,MistralForCausalLM:()=>Jf,MistralModel:()=>Qf,MistralPreTrainedModel:()=>Cn,MobileBertForMaskedLM:()=>Zf,MobileBertForQuestionAnswering:()=>tm,MobileBertForSequenceClassification:()=>em,MobileBertModel:()=>Yf,MobileBertPreTrainedModel:()=>as,MobileLLMForCausalLM:()=>rm,MobileLLMModel:()=>sm,MobileLLMPreTrainedModel:()=>Nn,MobileNetV1ForImageClassification:()=>om,MobileNetV1ForSemanticSegmentation:()=>am,MobileNetV1Model:()=>nm,MobileNetV1PreTrainedModel:()=>Bs,MobileNetV2ForImageClassification:()=>lm,MobileNetV2ForSemanticSegmentation:()=>cm,MobileNetV2Model:()=>im,MobileNetV2PreTrainedModel:()=>Us,MobileNetV3ForImageClassification:()=>pm,MobileNetV3ForSemanticSegmentation:()=>dm,MobileNetV3Model:()=>um,MobileNetV3PreTrainedModel:()=>qs,MobileNetV4ForImageClassification:()=>fm,MobileNetV4ForSemanticSegmentation:()=>mm,MobileNetV4Model:()=>_m,MobileNetV4PreTrainedModel:()=>Gs,MobileViTForImageClassification:()=>xm,MobileViTModel:()=>hm,MobileViTPreTrainedModel:()=>Ln,MobileViTV2ForImageClassification:()=>wm,MobileViTV2Model:()=>gm,MobileViTV2PreTrainedModel:()=>$n,ModernBertDecoderForCausalLM:()=>Am,ModernBertDecoderModel:()=>Em,ModernBertDecoderPreTrainedModel:()=>Rn,ModernBertForMaskedLM:()=>bm,ModernBertForSequenceClassification:()=>km,ModernBertForTokenClassification:()=>vm,ModernBertModel:()=>ym,ModernBertPreTrainedModel:()=>is,Moondream1ForConditionalGeneration:()=>Pf,MoonshineForConditionalGeneration:()=>Sm,MoonshineModel:()=>Mm,MoonshinePreTrainedModel:()=>Fn,MptForCausalLM:()=>Nm,MptModel:()=>Cm,MptPreTrainedModel:()=>Dn,MultiModalityCausalLM:()=>Rm,MultiModalityPreTrainedModel:()=>gi,MusicgenForCausalLM:()=>Dm,MusicgenForConditionalGeneration:()=>Un,MusicgenModel:()=>Fm,MusicgenPreTrainedModel:()=>Bn,NanoChatForCausalLM:()=>Bm,NanoChatModel:()=>jm,NanoChatPreTrainedModel:()=>qn,NeoBertForMaskedLM:()=>qm,NeoBertForQuestionAnswering:()=>Vm,NeoBertForSequenceClassification:()=>Gm,NeoBertForTokenClassification:()=>Wm,NeoBertModel:()=>Um,NeoBertPreTrainedModel:()=>$t,NomicBertModel:()=>Hm,NomicBertPreTrainedModel:()=>wi,OPTForCausalLM:()=>rh,OPTModel:()=>sh,OPTPreTrainedModel:()=>Xn,Olmo2ForCausalLM:()=>Jm,Olmo2Model:()=>Qm,Olmo2PreTrainedModel:()=>Wn,Olmo3ForCausalLM:()=>Zm,Olmo3Model:()=>Ym,Olmo3PreTrainedModel:()=>Vn,OlmoForCausalLM:()=>Km,OlmoModel:()=>Xm,OlmoPreTrainedModel:()=>Gn,OpenELMForCausalLM:()=>th,OpenELMModel:()=>eh,OpenELMPreTrainedModel:()=>Hn,OwlViTForObjectDetection:()=>ih,OwlViTModel:()=>ah,OwlViTPreTrainedModel:()=>Qn,Owlv2ForObjectDetection:()=>oh,Owlv2Model:()=>nh,Owlv2PreTrainedModel:()=>Kn,PaliGemmaForConditionalGeneration:()=>lh,PaliGemmaPreTrainedModel:()=>yi,ParakeetForCTC:()=>ch,ParakeetPreTrainedModel:()=>bi,PatchTSMixerForPrediction:()=>ph,PatchTSMixerModel:()=>uh,PatchTSMixerPreTrainedModel:()=>Jn,PatchTSTForPrediction:()=>_h,PatchTSTModel:()=>dh,PatchTSTPreTrainedModel:()=>Yn,Phi3ForCausalLM:()=>xh,Phi3Model:()=>hh,Phi3PreTrainedModel:()=>eo,Phi3VForCausalLM:()=>to,Phi3VPreTrainedModel:()=>ki,PhiForCausalLM:()=>mh,PhiModel:()=>fh,PhiPreTrainedModel:()=>Zn,PreTrainedModel:()=>f,PvtForImageClassification:()=>wh,PvtModel:()=>gh,PvtPreTrainedModel:()=>so,PyAnnoteForAudioFrameClassification:()=>bh,PyAnnoteModel:()=>yh,PyAnnotePreTrainedModel:()=>ro,Qwen2ForCausalLM:()=>vh,Qwen2Model:()=>kh,Qwen2PreTrainedModel:()=>no,Qwen2VLForConditionalGeneration:()=>Eh,Qwen2VLPreTrainedModel:()=>vi,Qwen3ForCausalLM:()=>Mh,Qwen3Model:()=>Ah,Qwen3PreTrainedModel:()=>oo,RFDetrForObjectDetection:()=>zh,RFDetrModel:()=>Ih,RFDetrObjectDetectionOutput:()=>Ei,RFDetrPreTrainedModel:()=>io,RTDetrForObjectDetection:()=>Ad,RTDetrModel:()=>Ed,RTDetrObjectDetectionOutput:()=>mt,RTDetrPreTrainedModel:()=>qr,RTDetrV2ForObjectDetection:()=>Uh,RTDetrV2Model:()=>Bh,RTDetrV2ObjectDetectionOutput:()=>Ai,RTDetrV2PreTrainedModel:()=>lo,ResNetForImageClassification:()=>Oh,ResNetModel:()=>Sh,ResNetPreTrainedModel:()=>ao,RoFormerForMaskedLM:()=>Rh,RoFormerForQuestionAnswering:()=>jh,RoFormerForSequenceClassification:()=>Fh,RoFormerForTokenClassification:()=>Dh,RoFormerModel:()=>$h,RoFormerPreTrainedModel:()=>Ft,RobertaForMaskedLM:()=>Ph,RobertaForQuestionAnswering:()=>Lh,RobertaForSequenceClassification:()=>Ch,RobertaForTokenClassification:()=>Nh,RobertaModel:()=>Th,RobertaPreTrainedModel:()=>Rt,Sam2ImageSegmentationOutput:()=>Oi,Sam2Model:()=>co,Sam2PreTrainedModel:()=>Ii,Sam3TrackerModel:()=>Wh,SamImageSegmentationOutput:()=>Mi,SamModel:()=>qh,SamPreTrainedModel:()=>Si,SapiensForDepthEstimation:()=>Hh,SapiensForNormalEstimation:()=>Xh,SapiensForSemanticSegmentation:()=>Vh,SapiensPreTrainedModel:()=>Ws,SegformerForImageClassification:()=>Qh,SegformerForSemanticSegmentation:()=>Jh,SegformerModel:()=>Kh,SegformerPreTrainedModel:()=>Vs,SiglipModel:()=>Yh,SiglipPreTrainedModel:()=>uo,SiglipTextModel:()=>po,SiglipVisionModel:()=>Zh,SmolLM3ForCausalLM:()=>tx,SmolLM3Model:()=>ex,SmolLM3PreTrainedModel:()=>_o,SmolVLMForConditionalGeneration:()=>gf,SnacDecoderModel:()=>mo,SnacEncoderModel:()=>fo,SnacModel:()=>sx,SnacPreTrainedModel:()=>Hs,SpeechT5ForSpeechToText:()=>nx,SpeechT5ForTextToSpeech:()=>ox,SpeechT5HifiGan:()=>ax,SpeechT5Model:()=>rx,SpeechT5PreTrainedModel:()=>Xs,SqueezeBertForMaskedLM:()=>lx,SqueezeBertForQuestionAnswering:()=>ux,SqueezeBertForSequenceClassification:()=>cx,SqueezeBertModel:()=>ix,SqueezeBertPreTrainedModel:()=>ls,StableLmForCausalLM:()=>dx,StableLmModel:()=>px,StableLmPreTrainedModel:()=>ho,Starcoder2ForCausalLM:()=>fx,Starcoder2Model:()=>_x,Starcoder2PreTrainedModel:()=>xo,StyleTextToSpeech2Model:()=>mx,StyleTextToSpeech2PreTrainedModel:()=>zi,SupertonicForConditionalGeneration:()=>go,SupertonicPreTrainedModel:()=>Ti,Swin2SRForImageSuperResolution:()=>yx,Swin2SRModel:()=>wx,Swin2SRPreTrainedModel:()=>wo,SwinForImageClassification:()=>xx,SwinForSemanticSegmentation:()=>gx,SwinModel:()=>hx,SwinPreTrainedModel:()=>Ks,T5ForConditionalGeneration:()=>kx,T5Model:()=>bx,T5PreTrainedModel:()=>yo,TableTransformerForObjectDetection:()=>Ex,TableTransformerModel:()=>vx,TableTransformerObjectDetectionOutput:()=>Pi,TableTransformerPreTrainedModel:()=>bo,TrOCRForCausalLM:()=>Ax,TrOCRPreTrainedModel:()=>Ci,UltravoxModel:()=>Li,UltravoxPreTrainedModel:()=>Ni,UniSpeechForCTC:()=>Ox,UniSpeechForSequenceClassification:()=>Ix,UniSpeechModel:()=>Sx,UniSpeechPreTrainedModel:()=>Qs,UniSpeechSatForAudioFrameClassification:()=>Cx,UniSpeechSatForCTC:()=>Tx,UniSpeechSatForSequenceClassification:()=>Px,UniSpeechSatModel:()=>zx,UniSpeechSatPreTrainedModel:()=>cs,VaultGemmaForCausalLM:()=>Lx,VaultGemmaModel:()=>Nx,VaultGemmaPreTrainedModel:()=>ko,ViTForImageClassification:()=>Fx,ViTMAEModel:()=>Dx,ViTMAEPreTrainedModel:()=>$i,ViTMSNForImageClassification:()=>Bx,ViTMSNModel:()=>jx,ViTMSNPreTrainedModel:()=>Eo,ViTModel:()=>Rx,ViTPreTrainedModel:()=>vo,VisionEncoderDecoderModel:()=>$x,VitMatteForImageMatting:()=>Ux,VitMattePreTrainedModel:()=>Ri,VitPoseForPoseEstimation:()=>qx,VitPosePreTrainedModel:()=>Fi,VitsModel:()=>Gx,VitsModelOutput:()=>Di,VitsPreTrainedModel:()=>ji,VoxtralForConditionalGeneration:()=>Mx,Wav2Vec2BertForCTC:()=>Vx,Wav2Vec2BertForSequenceClassification:()=>Hx,Wav2Vec2BertModel:()=>Wx,Wav2Vec2BertPreTrainedModel:()=>Js,Wav2Vec2ForAudioFrameClassification:()=>pf,Wav2Vec2ForCTC:()=>cf,Wav2Vec2ForSequenceClassification:()=>uf,Wav2Vec2Model:()=>lf,Wav2Vec2PreTrainedModel:()=>it,WavLMForAudioFrameClassification:()=>Yx,WavLMForCTC:()=>Kx,WavLMForSequenceClassification:()=>Qx,WavLMForXVector:()=>Jx,WavLMModel:()=>Xx,WavLMPreTrainedModel:()=>Dt,WeSpeakerResNetModel:()=>Zx,WeSpeakerResNetPreTrainedModel:()=>Ui,WhisperForConditionalGeneration:()=>Gi,WhisperModel:()=>eg,WhisperPreTrainedModel:()=>Ao,XLMForQuestionAnswering:()=>ag,XLMForSequenceClassification:()=>ng,XLMForTokenClassification:()=>og,XLMModel:()=>sg,XLMPreTrainedModel:()=>jt,XLMRobertaForMaskedLM:()=>lg,XLMRobertaForQuestionAnswering:()=>pg,XLMRobertaForSequenceClassification:()=>cg,XLMRobertaForTokenClassification:()=>ug,XLMRobertaModel:()=>ig,XLMRobertaPreTrainedModel:()=>Bt,XLMWithLMHeadModel:()=>rg,XVectorOutput:()=>Bi,YolosForObjectDetection:()=>_g,YolosModel:()=>dg,YolosObjectDetectionOutput:()=>Wi,YolosPreTrainedModel:()=>Mo,YoutuForCausalLM:()=>mg,YoutuModel:()=>fg,YoutuPreTrainedModel:()=>So});var rs=class extends f{},Mp=class extends rs{},Sp=class extends rs{async _call(e){return new z(await super._call(e))}},Op=class extends rs{async _call(e){return new oe(await super._call(e))}},Ip=class extends rs{async _call(e){return new J(await super._call(e))}};var Sr=class extends f{},zp=class extends Sr{},Tp=class extends Sr{};var Or=class extends f{},Pp=class extends Or{},Cp=class extends Or{};var Ir=class extends f{},Np=class extends Ir{},Lp=class extends Ir{};var Cs=class extends f{},$p=class extends Cs{},Rp=class extends Cs{},Fp=class extends Cs{async _call(e){return new z(await super._call(e))}};var zr=class extends f{},Dp=class extends zr{},jp=class extends zr{async _call(e){return new z(await super._call(e))}};var Ot=class extends f{},Bp=class extends Ot{},Up=class extends Ot{async _call(e){return new J(await super._call(e))}},qp=class extends Ot{async _call(e){return new z(await super._call(e))}},Gp=class extends Ot{async _call(e){return new K(await super._call(e))}},Wp=class extends Ot{async _call(e){return new oe(await super._call(e))}};var Tr=class extends f{},Vp=class extends Tr{},Hp=class extends Tr{};var Pr=class extends f{},Xp=class extends Pr{},Kp=class extends Pr{};var Cr=class extends f{},Qp=class extends Cr{},Jp=class extends Cr{};var It=class extends f{},Yp=class extends It{},Zp=class extends It{async _call(e){return new J(await super._call(e))}},ed=class extends It{async _call(e){return new z(await super._call(e))}},td=class extends It{async _call(e){return new K(await super._call(e))}},sd=class extends It{async _call(e){return new oe(await super._call(e))}};var kv=4299n,cy=6561n,Ha=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","audio_values","exaggeration","audio_features","audio_tokens","speaker_embeddings","speaker_features","past_key_values"];main_input_name="input_ids";_return_dict_in_generate_keys=["audio_tokens","speaker_embeddings","speaker_features"]},Nr=class extends Ha{async encode_speech(e){return q(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:s=null,audio_values:r=null,exaggeration:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:c=null,audio_features:u=null,audio_tokens:p=null,speaker_embeddings:d=null,speaker_features:_=null,...m}){let h;if(!a){let g=this.sessions.embed_tokens.inputNames,w={input_ids:e};if(g.includes("exaggeration")){if(!(n instanceof S)){let y=e.dims[0];if(n==null)n=xe([y],.5);else if(typeof n=="number")n=xe([y],n);else if(Array.isArray(n))n=new S("float32",n,[y]);else throw new Error("Unsupported type for `exaggeration` input")}w.exaggeration=n}if(g.includes("position_ids")&&(w.position_ids=o),{inputs_embeds:a}=await q(this.sessions.embed_tokens,w),u&&p&&d&&_&&(h={audio_features:u,audio_tokens:p,speaker_embeddings:d,speaker_features:_}),h||r)h??=await this.encode_speech(r),a=ne([h.audio_features,a],1),s=Oe([a.dims[0],a.dims[1]]);else{let y=a.dims[1];if(!i||y!==1)throw new Error("Incorrect state encountered during generation.");let E=Object.values(i)[0].dims.at(-2);s=Oe([a.dims[0],E+y])}}return{...await Ue(this,{inputs_embeds:a,past_key_values:i,attention_mask:s,generation_config:l,logits_processor:c},!1),...h}}prepare_inputs_for_generation(e,s,r){if(!s.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(s.input_ids.dims[1]===1){let n=Array.from({length:e.length},(o,a)=>e[a].length-e[a].findLastIndex(i=>i==cy)-1);s.position_ids=new S("int64",n,[e.length,1])}else{let o=s.input_ids.tolist().map(a=>{let i=0;return a.map(l=>l>=cy?0:i++)});s.position_ids=new S("int64",o.flat(),s.input_ids.dims)}return s.input_ids.dims[1]===1&&(delete s.audio_values,delete s.audio_features,delete s.audio_tokens,delete s.speaker_embeddings,delete s.speaker_features),Ar(this,e,s,r)}async generate(e){let{sequences:s,audio_tokens:r,speaker_embeddings:n,speaker_features:o}=await super.generate({...e,return_dict_in_generate:!0}),a=s.slice(null,[e.input_ids.dims[1],-1]),i=xe([a.dims[0],3],kv),l=ne([r,a,i],1),{waveform:c}=await q(this.sessions.conditional_decoder,{speech_tokens:l,speaker_features:o,speaker_embeddings:n});return c}};var Xa=class extends f{},rd=class extends Xa{};var Ns=class extends f{},nd=class extends Ns{},Lr=class extends Ns{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},$r=class extends Ns{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"audio_model"})}};var ft=class extends f{},od=class extends ft{},ad=class extends ft{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},Rr=class extends ft{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},id=class extends ft{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}},ld=class extends ft{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var Fr=class extends f{},cd=class extends Fr{},ud=class extends Fr{};var Dr=class extends f{},pd=class extends Dr{},dd=class extends Dr{};var jr=class extends f{},_d=class extends jr{},fd=class extends jr{};var zt=class extends f{},md=class extends zt{},hd=class extends zt{async _call(e){return new J(await super._call(e))}},xd=class extends zt{async _call(e){return new z(await super._call(e))}},gd=class extends zt{async _call(e){return new K(await super._call(e))}},wd=class extends zt{async _call(e){return new oe(await super._call(e))}};var Br=class extends f{},yd=class extends Br{},bd=class extends Br{async _call(e){return new z(await super._call(e))}};var Ur=class extends f{},kd=class extends Ur{},vd=class extends Ur{async _call(e){return new z(await super._call(e))}};var qr=class extends f{},Ed=class extends qr{},Ad=class extends qr{async _call(e){return new mt(await super._call(e))}},mt=class extends ue{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}};var Gr=class extends f{},Md=class extends Gr{},Sd=class extends Gr{async _call(e){return new mt(await super._call(e))}};var Ka=class extends ue{constructor({audio_codes:e}){super(),this.audio_codes=e}},Qa=class extends ue{constructor({audio_values:e}){super(),this.audio_values=e}},Ls=class extends f{main_input_name="input_values";forward_params=["input_values"]},Od=class extends Ls{async encode(e){return new Ka(await q(this.sessions.encoder_model,e))}async decode(e){return new Qa(await q(this.sessions.decoder_model,e))}},Wr=class extends Ls{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},Vr=class extends Ls{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var Tt=class extends f{},Id=class extends Tt{},zd=class extends Tt{async _call(e){return new J(await super._call(e))}},Td=class extends Tt{async _call(e){return new z(await super._call(e))}},Pd=class extends Tt{async _call(e){return new K(await super._call(e))}},Cd=class extends Tt{async _call(e){return new oe(await super._call(e))}};var Pt=class extends f{},Nd=class extends Pt{},Ld=class extends Pt{async _call(e){return new J(await super._call(e))}},$d=class extends Pt{async _call(e){return new z(await super._call(e))}},Rd=class extends Pt{async _call(e){return new K(await super._call(e))}},Fd=class extends Pt{async _call(e){return new oe(await super._call(e))}};var Ja=class extends f{},Dd=class extends Ja{};var Hr=class extends f{},jd=class extends Hr{},Bd=class extends Hr{async _call(e){return new z(await super._call(e))}};var Ya=class extends f{},Ud=class extends Ya{};var Za=class extends f{},qd=class extends Za{};var $s=class extends f{},Gd=class extends $s{},Wd=class extends $s{async _call(e){return new Rs(await super._call(e))}},Vd=class extends $s{async _call(e){return new ei(await super._call(e))}},Rs=class extends ue{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}},ei=class extends ue{constructor({logits:e,pred_boxes:s,pred_masks:r}){super(),this.logits=e,this.pred_boxes=s,this.pred_masks=r}};var Xr=class extends f{},Hd=class extends Xr{},Xd=class extends Xr{async _call(e){return new z(await super._call(e))}};var Kr=class extends f{},Kd=class extends Kr{},Qd=class extends Kr{async _call(e){return new z(await super._call(e))}};var ti=class extends f{},Jd=class extends ti{};var si=class extends f{},Yd=class extends si{};var Ct=class extends f{},Zd=class extends Ct{},e_=class extends Ct{async _call(e){return new z(await super._call(e))}},t_=class extends Ct{async _call(e){return new K(await super._call(e))}},s_=class extends Ct{async _call(e){return new oe(await super._call(e))}},r_=class extends Ct{async _call(e){return new J(await super._call(e))}};var ri=class extends f{},n_=class extends ri{};var Qr=class extends f{},o_=class extends Qr{},a_=class extends Qr{};var Jr=class extends f{},i_=class extends Jr{},l_=class extends Jr{async _call(e){return new z(await super._call(e))}};var Nt=class extends f{},c_=class extends Nt{},u_=class extends Nt{async _call(e){return new J(await super._call(e))}},p_=class extends Nt{async _call(e){return new z(await super._call(e))}},d_=class extends Nt{async _call(e){return new K(await super._call(e))}},__=class extends Nt{async _call(e){return new oe(await super._call(e))}};var Yr=class extends f{},f_=class extends Yr{},m_=class extends Yr{};var ns=class extends f{},h_=class extends ns{},x_=class extends ns{async _call(e){return new J(await super._call(e))}},g_=class extends ns{async _call(e){return new z(await super._call(e))}},w_=class extends ns{async _call(e){return new K(await super._call(e))}};var Zr=class extends f{},y_=class extends Zr{},b_=class extends Zr{};var en=class extends f{},k_=class extends en{},v_=class extends en{};var tn=class extends f{},E_=class extends tn{},A_=class extends tn{};var sn=class extends f{},M_=class extends sn{},S_=class extends sn{async _call(e){return new z(await super._call(e))}};var ni=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","pixel_values","encoder_outputs","decoder_input_ids","decoder_inputs_embeds","decoder_attention_mask","past_key_values"];main_input_name="inputs_embeds"},O_=class extends ni{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:s,input_ids:r,attention_mask:n}){return{inputs_embeds:ne([s,e],1),attention_mask:ne([Oe(s.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:s,inputs_embeds:r,attention_mask:n}){if(!e&&!s)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let o,a;return e&&(o=await this.encode_text({input_ids:e})),s&&(a=await this.encode_image({pixel_values:s})),o&&a?{inputs_embeds:r,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:o,image_features:a,input_ids:e,attention_mask:n}):r=o||a,{inputs_embeds:r,attention_mask:n}}async forward({input_ids:e,pixel_values:s,attention_mask:r,decoder_input_ids:n,decoder_attention_mask:o,encoder_outputs:a,past_key_values:i,inputs_embeds:l,decoder_inputs_embeds:c}){if(l||({inputs_embeds:l,attention_mask:r}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:s,inputs_embeds:l,attention_mask:r})),!a){let{last_hidden_state:p}=await Je(this,{inputs_embeds:l,attention_mask:r});a=p}if(!c){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:n})}return await Ue(this,{inputs_embeds:c,attention_mask:o,encoder_attention_mask:r,encoder_hidden_states:a,past_key_values:i},!0)}};var rn=class extends f{},I_=class extends rn{},z_=class extends rn{};var nn=class extends f{},T_=class extends nn{},P_=class extends nn{};var on=class extends f{},C_=class extends on{},N_=class extends on{};var oi=class extends f{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},an=class extends oi{async forward({input_ids:e=null,attention_mask:s=null,pixel_values:r=null,input_features:n=null,input_features_mask:o=null,position_ids:a=null,inputs_embeds:i=null,per_layer_inputs:l=null,past_key_values:c=null,generation_config:u=null,logits_processor:p=null,...d}){if((!i||!l)&&({inputs_embeds:i,per_layer_inputs:l}=await q(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(r){let{image_features:m}=await q(this.sessions.vision_encoder,{pixel_values:r});({inputs_embeds:i,attention_mask:s}=this._merge_input_ids_with_image_features({image_features:m,inputs_embeds:i,input_ids:e,attention_mask:s}))}if(n){let{audio_features:m}=await q(this.sessions.audio_encoder,{input_features:n,input_features_mask:o});({inputs_embeds:i,attention_mask:s}=this._merge_input_ids_with_audio_features({audio_features:m,inputs_embeds:i,input_ids:e,attention_mask:s}))}}return await Ue(this,{inputs_embeds:i,per_layer_inputs:l,past_key_values:c,attention_mask:s,position_ids:a,generation_config:u,logits_processor:p},!0)}_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return _t({image_token_id:this.config.image_token_id,...e,image_features:r})}_merge_input_ids_with_audio_features(e){let s=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,s);return Va({audio_token_id:this.config.audio_token_id,...e,audio_features:r})}};var ln=class extends f{},L_=class extends ln{},$_=class extends ln{};var cn=class extends f{},R_=class extends cn{},F_=class extends cn{};var un=class extends f{},D_=class extends un{},j_=class extends un{};var pn=class extends f{},B_=class extends pn{},U_=class extends pn{};var dn=class extends f{},q_=class extends dn{},G_=class extends dn{};var _n=class extends f{},W_=class extends _n{},V_=class extends _n{};var fn=class extends f{},H_=class extends fn{},X_=class extends fn{};var mn=class extends f{},K_=class extends mn{},Q_=class extends mn{};var hn=class extends f{},J_=class extends hn{},Y_=class extends hn{};var xn=class extends f{},Z_=class extends xn{},ef=class extends xn{};var ai=class extends f{},tf=class extends ai{};var ii=class extends f{},sf=class extends ii{};var gn=class extends f{},rf=class extends gn{},nf=class extends gn{};var wn=class extends f{},of=class extends wn{},af=class extends wn{async _call(e){return new z(await super._call(e))}};var it=class extends f{},lf=class extends it{},cf=class extends it{async _call(e){return new $e(await super._call(e))}},uf=class extends it{async _call(e){return new z(await super._call(e))}},pf=class extends it{async _call(e){return new K(await super._call(e))}};var df=class extends f{},_f=class extends it{},ff=class extends it{async _call(e){return new $e(await super._call(e))}},mf=class extends it{async _call(e){return new z(await super._call(e))}};var yn=class extends f{},hf=class extends yn{},xf=class extends yn{};var li=class extends f{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]},ci=class extends li{async encode_image({pixel_values:e,pixel_attention_mask:s}){return(await q(this.sessions.vision_encoder,{pixel_values:e,pixel_attention_mask:s})).image_features}_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return _t({image_token_id:this.config.image_token_id,...e,image_features:r})}},gf=class extends ci{};var bn=class extends f{},wf=class extends bn{},yf=class extends bn{async _call(e){return new z(await super._call(e))}};var kn=class extends f{},bf=class extends kn{},kf=class extends kn{};var Fs=class extends f{},vf=class extends Fs{async forward(e){let s=!e.input_ids,r=!e.pixel_values;if(s&&r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(s&&(e.input_ids=Oe([e.pixel_values.dims[0],1])),r){let{image_size:c}=this.config.vision_config;e.pixel_values=xe([0,3,c,c],0)}let{text_embeddings:n,image_embeddings:o,l2norm_text_embeddings:a,l2norm_image_embeddings:i}=await super.forward(e),l={};return s||(l.text_embeddings=n,l.l2norm_text_embeddings=a),r||(l.image_embeddings=o,l.l2norm_image_embeddings=i),l}},vn=class extends Fs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},Ef=class extends Fs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var En=class extends f{},Af=class extends En{},Mf=class extends En{};var An=class extends f{},Sf=class extends An{},Of=class extends An{};var Mn=class extends f{},If=class extends Mn{},zf=class extends Mn{};var ui=class extends f{},Tf=class extends ui{};var pi=class extends f{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Ds=class extends pi{_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return _t({image_token_id:this.config.image_token_index,...e,image_features:r})}},Pf=class extends Ds{},Cf=class extends Ds{};var Sn=class extends f{},Nf=class extends Sn{},Lf=class extends Sn{};var On=class extends f{},$f=class extends On{},Rf=class extends On{};var In=class extends f{},Ff=class extends In{},Df=class extends In{};var zn=class extends f{},jf=class extends zn{},Bf=class extends zn{};var os=class extends f{},Uf=class extends os{},qf=class extends os{},Gf=class extends os{async _call(e){return new z(await super._call(e))}},Wf=class extends os{};var di=class extends f{},Vf=class extends di{};var _i=class extends f{},Hf=class extends _i{};var fi=class extends ue{constructor({char_logits:e,bpe_logits:s,wp_logits:r}){super(),this.char_logits=e,this.bpe_logits=s,this.wp_logits=r}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},mi=class extends f{},Xf=class extends mi{async _call(e){return new fi(await super._call(e))}};var hi=class extends ue{constructor({audio_codes:e}){super(),this.audio_codes=e}},xi=class extends ue{constructor({audio_values:e}){super(),this.audio_values=e}},js=class extends f{main_input_name="input_values";forward_params=["input_values"]},Kf=class extends js{async encode(e){return new hi(await q(this.sessions.encoder_model,e))}async decode(e){return new xi(await q(this.sessions.decoder_model,e))}},Tn=class extends js{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},Pn=class extends js{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var Cn=class extends f{},Qf=class extends Cn{},Jf=class extends Cn{};var as=class extends f{},Yf=class extends as{},Zf=class extends as{async _call(e){return new J(await super._call(e))}},em=class extends as{async _call(e){return new z(await super._call(e))}},tm=class extends as{async _call(e){return new oe(await super._call(e))}};var Nn=class extends f{},sm=class extends Nn{},rm=class extends Nn{};var Bs=class extends f{},nm=class extends Bs{},om=class extends Bs{async _call(e){return new z(await super._call(e))}},am=class extends Bs{};var Us=class extends f{},im=class extends Us{},lm=class extends Us{async _call(e){return new z(await super._call(e))}},cm=class extends Us{};var qs=class extends f{},um=class extends qs{},pm=class extends qs{async _call(e){return new z(await super._call(e))}},dm=class extends qs{};var Gs=class extends f{},_m=class extends Gs{},fm=class extends Gs{async _call(e){return new z(await super._call(e))}},mm=class extends Gs{};var Ln=class extends f{},hm=class extends Ln{},xm=class extends Ln{async _call(e){return new z(await super._call(e))}};var $n=class extends f{},gm=class extends $n{},wm=class extends $n{async _call(e){return new z(await super._call(e))}};var is=class extends f{},ym=class extends is{},bm=class extends is{async _call(e){return new J(await super._call(e))}},km=class extends is{async _call(e){return new z(await super._call(e))}},vm=class extends is{async _call(e){return new K(await super._call(e))}};var Rn=class extends f{},Em=class extends Rn{},Am=class extends Rn{};var Fn=class extends f{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},Mm=class extends Fn{},Sm=class extends Fn{};var Lt=class extends f{},Om=class extends Lt{},Im=class extends Lt{async _call(e){return new J(await super._call(e))}},zm=class extends Lt{async _call(e){return new z(await super._call(e))}},Tm=class extends Lt{async _call(e){return new K(await super._call(e))}},Pm=class extends Lt{async _call(e){return new oe(await super._call(e))}};var Dn=class extends f{},Cm=class extends Dn{},Nm=class extends Dn{};var jn=class extends f{},Lm=class extends jn{},$m=class extends jn{};var gi=class extends f{},Rm=class extends gi{forward_params=["input_ids","pixel_values","images_seq_mask","images_emb_mask","attention_mask","position_ids","past_key_values"];constructor(...e){super(...e),this._generation_mode="text"}async forward(e){let s=this._generation_mode??"text",r;if(s==="text"||!e.past_key_values){let l=this.sessions.prepare_inputs_embeds,c=Me(e,l.inputNames);r=await q(l,c)}else{let l=this.sessions.gen_img_embeds,c=Me({image_ids:e.input_ids},l.inputNames);r=await q(l,c)}let n={...e,...r},o=await Ue(this,n),a=this.sessions[s==="text"?"lm_head":"gen_head"];if(!a)throw new Error(`Unable to find "${a}" generation head`);let i=await q(a,Me(o,a.inputNames));return{...r,...o,...i}}prepare_inputs_for_generation(e,s,r){let n=!!s.past_key_values;return r.guidance_scale!==null&&r.guidance_scale>1&&(n?s.input_ids=ne([s.input_ids,s.input_ids],0):(s.input_ids=ne([s.input_ids,dr(s.input_ids,BigInt(r.pad_token_id))],0),s.attention_mask=ne([s.attention_mask,dr(s.attention_mask,0n)],0))),(n||!s.pixel_values)&&(s.pixel_values=xe([0,0,3,384,384],1)),n&&(s.images_seq_mask=new S("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),s.images_emb_mask=new S("bool",new Array(0).fill(!1),[1,1,0])),s}async generate(e){return this._generation_mode="text",super.generate(e)}async generate_images(e){this._generation_mode="image";let s=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[s,null]),o=this.sessions.image_decode,{decoded_image:a}=await q(o,{generated_tokens:n}),i=a.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),l=[];for(let c of i){let u=we.fromTensor(c);l.push(u)}return l}};var Bn=class extends f{},Fm=class extends Bn{},Dm=class extends Bn{},Un=class extends f{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];_apply_and_filter_by_delay_pattern_mask(e){let[s,r]=e.dims,n=this.config.decoder.num_codebooks,o=r-n,a=0;for(let c=0;c<e.size;++c){if(e.data[c]==this.config.decoder.pad_token_id)continue;let u=c%r,p=Math.floor(c/r)%n,d=u-p;d>0&&d<=o&&(e.data[a++]=e.data[c])}let i=Math.floor(s/n),l=a/(i*n);return new S(e.type,e.data.slice(0,a),[i,n,l])}prepare_inputs_for_generation(e,s,r){let n=BigInt(this.config.decoder.pad_token_id),o=structuredClone(e);for(let a=0;a<o.length;++a)for(let i=0;i<o[a].length;++i)a%this.config.decoder.num_codebooks>=i&&(o[a][i]=n);return r.guidance_scale!==null&&r.guidance_scale>1&&(o=o.concat(o)),Mr(this,o,s,r)}async generate(e){let s=await super.generate(e),r=this._apply_and_filter_by_delay_pattern_mask(s).unsqueeze_(0),{audio_values:n}=await q(this.sessions.encodec_decode,{audio_codes:r});return n}};var qn=class extends f{},jm=class extends qn{},Bm=class extends qn{};var $t=class extends f{},Um=class extends $t{},qm=class extends $t{async _call(e){return new J(await super._call(e))}},Gm=class extends $t{async _call(e){return new z(await super._call(e))}},Wm=class extends $t{async _call(e){return new K(await super._call(e))}},Vm=class extends $t{async _call(e){return new oe(await super._call(e))}};var wi=class extends f{},Hm=class extends wi{};var Gn=class extends f{},Xm=class extends Gn{},Km=class extends Gn{};var Wn=class extends f{},Qm=class extends Wn{},Jm=class extends Wn{};var Vn=class extends f{},Ym=class extends Vn{},Zm=class extends Vn{};var Hn=class extends f{},eh=class extends Hn{},th=class extends Hn{};var Xn=class extends f{},sh=class extends Xn{},rh=class extends Xn{};var Kn=class extends f{},nh=class extends Kn{},oh=class extends Kn{};var Qn=class extends f{},ah=class extends Qn{},ih=class extends Qn{};var yi=class extends f{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},lh=class extends yi{_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return _t({image_token_id:this.config.image_token_index,...e,image_features:r})}};var bi=class extends f{},ch=class extends bi{async _call(e){return new $e(await super._call(e))}};var Jn=class extends f{},uh=class extends Jn{},ph=class extends Jn{};var Yn=class extends f{},dh=class extends Yn{},_h=class extends Yn{};var Zn=class extends f{},fh=class extends Zn{},mh=class extends Zn{};var eo=class extends f{},hh=class extends eo{},xh=class extends eo{};var ki=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},to=class extends ki{async forward({input_ids:e=null,attention_mask:s=null,pixel_values:r=null,image_sizes:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:c=null,...u}){if(!a){let d;if(r&&e.dims[1]!==1){if(!n)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:d}=await q(this.sessions.vision_encoder,{pixel_values:r,image_sizes:n}))}else{let _=this.config.normalized_config.hidden_size;d=new S("float32",[],[0,_])}({inputs_embeds:a}=await q(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:d}))}return await Ue(this,{inputs_embeds:a,past_key_values:i,attention_mask:s,position_ids:o,generation_config:l,logits_processor:c},!1)}};var so=class extends f{},gh=class extends so{},wh=class extends so{async _call(e){return new z(await super._call(e))}};var ro=class extends f{},yh=class extends ro{},bh=class extends ro{async _call(e){return new K(await super._call(e))}};var no=class extends f{},kh=class extends no{},vh=class extends no{};var vi=class extends f{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},Eh=class extends vi{get_rope_index(e,s,r,n){let{vision_config:o,image_token_id:a,video_token_id:i,vision_start_token_id:l}=this.config,c=o.spatial_merge_size??2,u=[];if(s||r){let p=e.tolist();n||(n=ta(e));let d=n.tolist(),_=Array.from({length:3},w=>Array.from({length:e.dims[0]},y=>Array.from({length:e.dims[1]},E=>1))),m=s?s.tolist():[],h=r?r.tolist():[],x=0,g=0;for(let w=0;w<p.length;++w){let y=p[w].filter((k,v)=>d[w][v]==1),A=y.reduce((k,v,I)=>(v==l&&k.push(I),k),[]).map(k=>y[k+1]),b=A.filter(k=>k==a).length,O=A.filter(k=>k==i).length,N=[],F=0,R=b,B=O;for(let k=0;k<A.length;++k){let v=y.findIndex((ct,Ze)=>Ze>F&&ct==a),I=y.findIndex((ct,Ze)=>Ze>F&&ct==i),Q=R>0&&v!==-1?v:y.length+1,Z=B>0&&I!==-1?I:y.length+1,Ie,Ee,ht,xt;Q<Z?([Ee,ht,xt]=m[x],++x,--R,Ie=Q):([Ee,ht,xt]=h[g],++g,--B,Ie=Z);let[Gt,lt,Ye]=[Number(Ee),Math.floor(Number(ht)/c),Math.floor(Number(xt)/c)],gt=Ie-F,vt=N.length>0?ae(N.at(-1))[0]+1:0;N.push(Array.from({length:3*gt},(ct,Ze)=>vt+Ze%gt));let Wt=gt+vt,Et=Gt*lt*Ye,Lo=Array.from({length:Et},(ct,Ze)=>Wt+Math.floor(Ze/(lt*Ye))),$o=Array.from({length:Et},(ct,Ze)=>Wt+Math.floor(Ze/Ye)%lt),Ro=Array.from({length:Et},(ct,Ze)=>Wt+Ze%Ye);N.push([Lo,$o,Ro].flat()),F=Ie+Et}if(F<y.length){let k=N.length>0?ae(N.at(-1))[0]+1:0,v=y.length-F;N.push(Array.from({length:3*v},(I,Q)=>k+Q%v))}let G=N.reduce((k,v)=>k+v.length,0),D=new Array(G),X=0;for(let k=0;k<3;++k)for(let v=0;v<N.length;++v){let I=N[v],Q=I.length/3;for(let Z=k*Q;Z<(k+1)*Q;++Z)D[X++]=I[Z]}let V=0,re=d[w];for(let k=0;k<re.length;++k)if(re[k]==1){for(let v=0;v<3;++v)_[v][w][k]=D[v*G/3+V];++V}let Y=ae(D)[0];u.push(Y+1-p[w].length)}return[new S("int64",_.flat(1/0),[3,e.dims[0],e.dims[1]]),new S("int64",u,[u.length,1])]}else if(n){let{data:p,dims:d}=Ap(n),_=BigInt64Array.from({length:3*p.length},(h,x)=>p[x%p.length]),m=Array.from({length:d[0]},(h,x)=>ae(p.subarray(d[1]*x,d[1]*(x+1)))[0]+1n+BigInt(d[1]));return[new S("int64",_,[3,...d]),new S("int64",m,[m.length,1])]}else{let[p,d]=e.dims,_=BigInt64Array.from({length:3*p*d},(m,h)=>BigInt(Math.floor(h%d/p)));return[new S("int64",_,[3,...e.dims]),ec([p,1])]}}async encode_image({pixel_values:e,image_grid_thw:s}){return(await q(this.sessions.vision_encoder,{pixel_values:e,grid_thw:s})).image_features}_merge_input_ids_with_image_features(e){return _t({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,s,r){if(s.attention_mask&&!s.position_ids)if(!s.past_key_values)[s.position_ids,s.rope_deltas]=this.get_rope_index(s.input_ids,s.image_grid_thw,s.video_grid_thw,s.attention_mask);else{s.pixel_values=null;let n=BigInt(Object.values(s.past_key_values)[0].dims.at(-2)),o=s.rope_deltas.map(a=>n+a);s.position_ids=Ke([o,o,o],0)}return s}};var oo=class extends f{},Ah=class extends oo{},Mh=class extends oo{};var ao=class extends f{},Sh=class extends ao{},Oh=class extends ao{async _call(e){return new z(await super._call(e))}};var io=class extends f{},Ih=class extends io{},zh=class extends io{async _call(e){return new Ei(await super._call(e))}},Ei=class extends mt{};var Rt=class extends f{},Th=class extends Rt{},Ph=class extends Rt{async _call(e){return new J(await super._call(e))}},Ch=class extends Rt{async _call(e){return new z(await super._call(e))}},Nh=class extends Rt{async _call(e){return new K(await super._call(e))}},Lh=class extends Rt{async _call(e){return new oe(await super._call(e))}};var Ft=class extends f{},$h=class extends Ft{},Rh=class extends Ft{async _call(e){return new J(await super._call(e))}},Fh=class extends Ft{async _call(e){return new z(await super._call(e))}},Dh=class extends Ft{async _call(e){return new K(await super._call(e))}},jh=class extends Ft{async _call(e){return new oe(await super._call(e))}};var lo=class extends f{},Bh=class extends lo{},Uh=class extends lo{async _call(e){return new Ai(await super._call(e))}},Ai=class extends mt{};var Mi=class extends ue{constructor({iou_scores:e,pred_masks:s}){super(),this.iou_scores=e,this.pred_masks=s}},Si=class extends f{},qh=class extends Si{async get_image_embeddings({pixel_values:e}){return await Je(this,{pixel_values:e})}async forward(e){!e.image_embeddings||!e.image_positional_embeddings?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_labels??=Oe(e.input_points.dims.slice(0,-1));let s={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(s.input_points=e.input_points),e.input_labels&&(s.input_labels=e.input_labels),e.input_boxes&&(s.input_boxes=e.input_boxes),await q(this.sessions.prompt_encoder_mask_decoder,s)}async _call(e){return new Mi(await super._call(e))}};var Oi=class extends ue{constructor({iou_scores:e,pred_masks:s,object_score_logits:r}){super(),this.iou_scores=e,this.pred_masks=s,this.object_score_logits=r}},Ii=class extends f{},co=class extends Ii{async get_image_embeddings({pixel_values:e}){return await Je(this,{pixel_values:e})}async forward(e){let{num_feature_levels:s}=this.config.vision_config;if(Array.from({length:s},(a,i)=>`image_embeddings.${i}`).some(a=>!e[a])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let a=e.input_points.dims;e.input_labels??=Oe(a.slice(0,-1)),e.input_boxes??=xe([a[0],0,4],0)}else if(e.input_boxes){let a=e.input_boxes.dims;e.input_labels=xe([a[0],a[1],0],-1n),e.input_points=xe([a[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder,o=Me(e,n.inputNames);return await q(n,o)}async _call(e){return new Oi(await super._call(e))}},Gh=class extends co{},Wh=class extends co{};var Ws=class extends f{},Vh=class extends Ws{},Hh=class extends Ws{},Xh=class extends Ws{};var Vs=class extends f{},Kh=class extends Vs{},Qh=class extends Vs{},Jh=class extends Vs{};var uo=class extends f{},Yh=class extends uo{},po=class extends uo{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},Zh=class extends ft{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var _o=class extends f{},ex=class extends _o{},tx=class extends _o{};var Hs=class extends f{main_input_name="input_values";forward_params=["input_values"]},sx=class extends Hs{async encode(e){return await q(this.sessions.encoder_model,e)}async decode(e){return await q(this.sessions.decoder_model,e)}},fo=class extends Hs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},mo=class extends Hs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var Xs=class extends f{},rx=class extends Xs{},nx=class extends Xs{},ox=class extends Xs{async generate_speech(e,s,{threshold:r=.5,minlenratio:n=0,maxlenratio:o=20,vocoder:a=null}={}){let i={input_ids:e},{encoder_outputs:l,encoder_attention_mask:c}=await Je(this,i),u=l.dims[1]/this.config.reduction_factor,p=Math.floor(u*o),d=Math.floor(u*n),_=this.config.num_mel_bins,m=[],h=null,x=null,g=0;for(;;){++g;let E=Ep(!!x),A;x?A=x.output_sequence_out:A=new S("float32",new Float32Array(_),[1,1,_]);let b={use_cache_branch:E,output_sequence:A,encoder_attention_mask:c,speaker_embeddings:s,encoder_hidden_states:l};this.addPastKeyValues(b,h),x=await q(this.sessions.decoder_model_merged,b),h=this.getPastKeyValues(x,h);let{prob:O,spectrum:N}=x;if(m.push(N),g>=d&&(Array.from(O.data).filter(F=>F>=r).length>0||g>=p))break}let w=ne(m),{waveform:y}=await q(a.sessions.model,{spectrogram:w});return{spectrogram:w,waveform:y}}},ax=class extends f{main_input_name="spectrogram"};var ls=class extends f{},ix=class extends ls{},lx=class extends ls{async _call(e){return new J(await super._call(e))}},cx=class extends ls{async _call(e){return new z(await super._call(e))}},ux=class extends ls{async _call(e){return new oe(await super._call(e))}};var ho=class extends f{},px=class extends ho{},dx=class extends ho{};var xo=class extends f{},_x=class extends xo{},fx=class extends xo{};var zi=class extends f{},mx=class extends zi{};var Ti=class extends f{},go=class extends Ti{async generate_speech({input_ids:e,attention_mask:s,style:r,num_inference_steps:n=5,speed:o=1.05}){let{sampling_rate:a,chunk_compress_factor:i,base_chunk_size:l,latent_dim:c}=this.config,{last_hidden_state:u,durations:p}=await q(this.sessions.text_encoder,{input_ids:e,attention_mask:s,style:r}),d=p.div(o).mul_(a),_=l*i,m=d.data,h=Int32Array.from(m,R=>Math.ceil(R/_)),x=Math.max(...h),g=e.dims[0],w=new BigInt64Array(g*x);for(let R=0;R<g;++R)w.fill(1n,R*x,R*x+h[R]);let y=new S("int64",w,[g,x]),E=c*i,A=E*x,b=$w([g,E,x]),O=b.data;for(let R=0;R<g;++R)if(h[R]!==x)for(let B=0;B<E;++B)O.fill(0,R*A+B*x+h[R],R*A+(B+1)*x);let N=xe([g],n);for(let R=0;R<n;++R){let B=xe([g],R);({denoised_latents:b}=await q(this.sessions.latent_denoiser,{style:r,noisy_latents:b,latent_mask:y,encoder_outputs:u,attention_mask:s,timestep:B,num_inference_steps:N}))}let{waveform:F}=await q(this.sessions.voice_decoder,{latents:b});return{waveform:F,durations:d}}};var Ks=class extends f{},hx=class extends Ks{},xx=class extends Ks{async _call(e){return new z(await super._call(e))}},gx=class extends Ks{};var wo=class extends f{},wx=class extends wo{},yx=class extends wo{};var yo=class extends f{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},bx=class extends yo{},kx=class extends yo{};var bo=class extends f{},vx=class extends bo{},Ex=class extends bo{async _call(e){return new Pi(await super._call(e))}},Pi=class extends Rs{};var Ci=class extends f{},Ax=class extends Ci{};var Ni=class extends f{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},Li=class extends Ni{_merge_input_ids_with_audio_features(e){let s=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,s);return Va({audio_token_id:this.config.ignore_index??this.config.audio_token_id,...e,audio_features:r})}},Mx=class extends Li{};var Qs=class extends f{},Sx=class extends Qs{},Ox=class extends Qs{async _call(e){return new $e(await super._call(e))}},Ix=class extends Qs{async _call(e){return new z(await super._call(e))}};var cs=class extends f{},zx=class extends cs{},Tx=class extends cs{async _call(e){return new $e(await super._call(e))}},Px=class extends cs{async _call(e){return new z(await super._call(e))}},Cx=class extends cs{async _call(e){return new K(await super._call(e))}};var ko=class extends f{},Nx=class extends ko{},Lx=class extends ko{};var $x=class extends f{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var vo=class extends f{},Rx=class extends vo{},Fx=class extends vo{async _call(e){return new z(await super._call(e))}};var $i=class extends f{},Dx=class extends $i{};var Eo=class extends f{},jx=class extends Eo{},Bx=class extends Eo{async _call(e){return new z(await super._call(e))}};var Ri=class extends f{},Ux=class extends Ri{async _call(e){return new Ia(await super._call(e))}};var Fi=class extends f{},qx=class extends Fi{};var Di=class extends ue{constructor({waveform:e,spectrogram:s}){super(),this.waveform=e,this.spectrogram=s}},ji=class extends f{},Gx=class extends ji{async _call(e){return new Di(await super._call(e))}};var Js=class extends f{},Wx=class extends Js{},Vx=class extends Js{async _call(e){return new $e(await super._call(e))}},Hx=class extends Js{async _call(e){return new z(await super._call(e))}};var Bi=class extends ue{constructor({logits:e,embeddings:s}){super(),this.logits=e,this.embeddings=s}},Dt=class extends f{},Xx=class extends Dt{},Kx=class extends Dt{async _call(e){return new $e(await super._call(e))}},Qx=class extends Dt{async _call(e){return new z(await super._call(e))}},Jx=class extends Dt{async _call(e){return new Bi(await super._call(e))}},Yx=class extends Dt{async _call(e){return new K(await super._call(e))}};var Ui=class extends f{},Zx=class extends Ui{};var qi=class extends Ts{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1};var Ao=class extends f{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},eg=class extends Ao{},Gi=class extends Ao{_prepare_generation_config(e,s){return super._prepare_generation_config(e,s,qi)}_retrieve_init_tokens(e){let s=[e.decoder_start_token_id],r=e.language,n=e.task;if(e.is_multilingual){r||(console.warn("No language specified - defaulting to English (en)."),r="en");let a=`<|${Dw(r)}|>`;s.push(e.lang_to_id[a]),s.push(e.task_to_id[n??"transcribe"])}else if(r||n)throw new Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&s.at(-1)!==e.no_timestamps_token_id?s.push(e.no_timestamps_token_id):e.return_timestamps&&s.at(-1)===e.no_timestamps_token_id&&(console.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),s.pop()),s.filter(o=>o!=null)}async generate({inputs:e=null,generation_config:s=null,logits_processor:r=null,stopping_criteria:n=null,...o}){s=this._prepare_generation_config(s,o);let a=o.decoder_input_ids??this._retrieve_init_tokens(s);if(s.return_timestamps&&(r??=new Zt,r.push(new Pa(s,a))),s.begin_suppress_tokens&&(r??=new Zt,r.push(new zs(s.begin_suppress_tokens,a.length))),s.return_token_timestamps){if(!s.alignment_heads)throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");s.task==="translate"&&console.warn("Token-level timestamps may not be reliable for task 'translate'."),s.output_attentions=!0,s.return_dict_in_generate=!0}let i=await super.generate({inputs:e,generation_config:s,logits_processor:r,decoder_input_ids:a,...o});return s.return_token_timestamps&&(i.token_timestamps=this._extract_token_timestamps(i,s.alignment_heads,s.num_frames)),i}_extract_token_timestamps(e,s,r=null,n=.02){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");r==null&&console.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let o=this.config.median_filter_width;o===void 0&&(console.warn("Model config has no `median_filter_width`, using default value of 7."),o=7);let a=e.cross_attentions,i=Array.from({length:this.config.decoder_layers},(h,x)=>ne(a.map(g=>g[x]),2)),l=Ke(s.map(([h,x])=>{if(h>=i.length)throw new Error(`Layer index ${h} is out of bounds for cross attentions (length ${i.length}).`);return r?i[h].slice(null,x,null,[0,r]):i[h].slice(null,x)})).transpose(1,0,2,3),[c,u]=Yl(l,-2,0,!0),p=l.clone();for(let h=0;h<p.dims[0];++h){let x=p[h];for(let g=0;g<x.dims[0];++g){let w=x[g],y=c[h][g][0].data,E=u[h][g][0].data;for(let A=0;A<w.dims[0];++A){let b=w[A].data;for(let O=0;O<b.length;++O)b[O]=(b[O]-E[O])/y[O];b.set(hw(b,o))}}}let d=[ea(p,1)],_=e.sequences.dims,m=new S("float32",new Float32Array(_[0]*_[1]),_);for(let h=0;h<_[0];++h){let x=d[h].neg().squeeze_(0),[g,w]=gw(x.tolist()),y=Array.from({length:g.length-1},(b,O)=>g[O+1]-g[O]),E=Pe([1],y).map(b=>!!b),A=[];for(let b=0;b<E.length;++b)E[b]&&A.push(w[b]*n);m[h].data.set(A,1)}return m}},tg=class extends Gi{};var jt=class extends f{},sg=class extends jt{},rg=class extends jt{async _call(e){return new J(await super._call(e))}},ng=class extends jt{async _call(e){return new z(await super._call(e))}},og=class extends jt{async _call(e){return new K(await super._call(e))}},ag=class extends jt{async _call(e){return new oe(await super._call(e))}};var Bt=class extends f{},ig=class extends Bt{},lg=class extends Bt{async _call(e){return new J(await super._call(e))}},cg=class extends Bt{async _call(e){return new z(await super._call(e))}},ug=class extends Bt{async _call(e){return new K(await super._call(e))}},pg=class extends Bt{async _call(e){return new oe(await super._call(e))}};var Mo=class extends f{},dg=class extends Mo{},_g=class extends Mo{async _call(e){return new Wi(await super._call(e))}},Wi=class extends ue{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}};var So=class extends f{},fg=class extends So{},mg=class extends So{};var vv=new Map([["bert","BertModel"],["neobert","NeoBertModel"],["modernbert","ModernBertModel"],["nomic_bert","NomicBertModel"],["roformer","RoFormerModel"],["electra","ElectraModel"],["esm","EsmModel"],["convbert","ConvBertModel"],["camembert","CamembertModel"],["deberta","DebertaModel"],["deberta-v2","DebertaV2Model"],["mpnet","MPNetModel"],["albert","AlbertModel"],["distilbert","DistilBertModel"],["roberta","RobertaModel"],["xlm","XLMModel"],["xlm-roberta","XLMRobertaModel"],["clap","ClapModel"],["clip","CLIPModel"],["clipseg","CLIPSegModel"],["chinese_clip","ChineseCLIPModel"],["siglip","SiglipModel"],["jina_clip","JinaCLIPModel"],["mobilebert","MobileBertModel"],["squeezebert","SqueezeBertModel"],["wav2vec2","Wav2Vec2Model"],["wav2vec2-bert","Wav2Vec2BertModel"],["unispeech","UniSpeechModel"],["unispeech-sat","UniSpeechSatModel"],["hubert","HubertModel"],["wavlm","WavLMModel"],["audio-spectrogram-transformer","ASTModel"],["vits","VitsModel"],["pyannote","PyAnnoteModel"],["wespeaker-resnet","WeSpeakerResNetModel"],["detr","DetrModel"],["rt_detr","RTDetrModel"],["rt_detr_v2","RTDetrV2Model"],["rf_detr","RFDetrModel"],["d_fine","DFineModel"],["table-transformer","TableTransformerModel"],["vit","ViTModel"],["ijepa","IJepaModel"],["pvt","PvtModel"],["vit_msn","ViTMSNModel"],["vit_mae","ViTMAEModel"],["groupvit","GroupViTModel"],["fastvit","FastViTModel"],["mobilevit","MobileViTModel"],["mobilevitv2","MobileViTV2Model"],["owlvit","OwlViTModel"],["owlv2","Owlv2Model"],["beit","BeitModel"],["deit","DeiTModel"],["hiera","HieraModel"],["convnext","ConvNextModel"],["convnextv2","ConvNextV2Model"],["dinov2","Dinov2Model"],["dinov2_with_registers","Dinov2WithRegistersModel"],["dinov3_vit","DINOv3ViTModel"],["dinov3_convnext","DINOv3ConvNextModel"],["resnet","ResNetModel"],["swin","SwinModel"],["swin2sr","Swin2SRModel"],["donut-swin","DonutSwinModel"],["yolos","YolosModel"],["dpt","DPTModel"],["glpn","GLPNModel"],["hifigan","SpeechT5HifiGan"],["efficientnet","EfficientNetModel"],["decision_transformer","DecisionTransformerModel"],["patchtst","PatchTSTModel"],["patchtsmixer","PatchTSMixerModel"],["mobilenet_v1","MobileNetV1Model"],["mobilenet_v2","MobileNetV2Model"],["mobilenet_v3","MobileNetV3Model"],["mobilenet_v4","MobileNetV4Model"],["maskformer","MaskFormerModel"],["mgp-str","MgpstrForSceneTextRecognition"],["style_text_to_speech_2","StyleTextToSpeech2Model"]]),Ev=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),Av=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),Mv=new Map([["bloom","BloomModel"],["jais","JAISModel"],["gpt2","GPT2Model"],["gpt_oss","GptOssModel"],["gptj","GPTJModel"],["gpt_bigcode","GPTBigCodeModel"],["gpt_neo","GPTNeoModel"],["gpt_neox","GPTNeoXModel"],["codegen","CodeGenModel"],["llama","LlamaModel"],["apertus","ApertusModel"],["nanochat","NanoChatModel"],["arcee","ArceeModel"],["lfm2","Lfm2Model"],["lfm2_moe","Lfm2MoeModel"],["smollm3","SmolLM3Model"],["exaone","ExaoneModel"],["olmo","OlmoModel"],["olmo2","Olmo2Model"],["olmo3","Olmo3Model"],["mobilellm","MobileLLMModel"],["granite","GraniteModel"],["granitemoehybrid","GraniteMoeHybridModel"],["cohere","CohereModel"],["gemma","GemmaModel"],["gemma2","Gemma2Model"],["vaultgemma","VaultGemmaModel"],["gemma3_text","Gemma3Model"],["helium","HeliumModel"],["glm","GlmModel"],["openelm","OpenELMModel"],["qwen2","Qwen2Model"],["qwen3","Qwen3Model"],["phi","PhiModel"],["phi3","Phi3Model"],["mpt","MptModel"],["opt","OPTModel"],["mistral","MistralModel"],["ministral","MinistralModel"],["ministral3","Ministral3Model"],["ernie4_5","Ernie4_5_Model"],["starcoder2","Starcoder2Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"]]),uy=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"]]),py=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),dy=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),_y=new Map([["bert","BertForSequenceClassification"],["neobert","NeoBertForSequenceClassification"],["modernbert","ModernBertForSequenceClassification"],["roformer","RoFormerForSequenceClassification"],["electra","ElectraForSequenceClassification"],["esm","EsmForSequenceClassification"],["convbert","ConvBertForSequenceClassification"],["camembert","CamembertForSequenceClassification"],["deberta","DebertaForSequenceClassification"],["deberta-v2","DebertaV2ForSequenceClassification"],["mpnet","MPNetForSequenceClassification"],["albert","AlbertForSequenceClassification"],["distilbert","DistilBertForSequenceClassification"],["roberta","RobertaForSequenceClassification"],["xlm","XLMForSequenceClassification"],["xlm-roberta","XLMRobertaForSequenceClassification"],["bart","BartForSequenceClassification"],["mbart","MBartForSequenceClassification"],["mobilebert","MobileBertForSequenceClassification"],["squeezebert","SqueezeBertForSequenceClassification"]]),fy=new Map([["bert","BertForTokenClassification"],["neobert","NeoBertForTokenClassification"],["modernbert","ModernBertForTokenClassification"],["roformer","RoFormerForTokenClassification"],["electra","ElectraForTokenClassification"],["esm","EsmForTokenClassification"],["convbert","ConvBertForTokenClassification"],["camembert","CamembertForTokenClassification"],["deberta","DebertaForTokenClassification"],["deberta-v2","DebertaV2ForTokenClassification"],["mpnet","MPNetForTokenClassification"],["distilbert","DistilBertForTokenClassification"],["roberta","RobertaForTokenClassification"],["xlm","XLMForTokenClassification"],["xlm-roberta","XLMRobertaForTokenClassification"]]),my=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),hy=new Map([["bloom","BloomForCausalLM"],["gpt2","GPT2LMHeadModel"],["gpt_oss","GptOssForCausalLM"],["jais","JAISLMHeadModel"],["gptj","GPTJForCausalLM"],["gpt_bigcode","GPTBigCodeForCausalLM"],["gpt_neo","GPTNeoForCausalLM"],["gpt_neox","GPTNeoXForCausalLM"],["codegen","CodeGenForCausalLM"],["llama","LlamaForCausalLM"],["nanochat","NanoChatForCausalLM"],["apertus","ApertusForCausalLM"],["llama4_text","Llama4ForCausalLM"],["arcee","ArceeForCausalLM"],["lfm2","Lfm2ForCausalLM"],["lfm2_moe","Lfm2MoeForCausalLM"],["smollm3","SmolLM3ForCausalLM"],["exaone","ExaoneForCausalLM"],["olmo","OlmoForCausalLM"],["olmo2","Olmo2ForCausalLM"],["olmo3","Olmo3ForCausalLM"],["mobilellm","MobileLLMForCausalLM"],["granite","GraniteForCausalLM"],["granitemoehybrid","GraniteMoeHybridForCausalLM"],["cohere","CohereForCausalLM"],["gemma","GemmaForCausalLM"],["gemma2","Gemma2ForCausalLM"],["vaultgemma","VaultGemmaForCausalLM"],["gemma3_text","Gemma3ForCausalLM"],["helium","HeliumForCausalLM"],["glm","GlmForCausalLM"],["openelm","OpenELMForCausalLM"],["qwen2","Qwen2ForCausalLM"],["qwen3","Qwen3ForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5_ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["trocr","TrOCRForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),Sv=new Map([["multi_modality","MultiModalityCausalLM"]]),xy=new Map([["bert","BertForMaskedLM"],["neobert","NeoBertForMaskedLM"],["modernbert","ModernBertForMaskedLM"],["roformer","RoFormerForMaskedLM"],["electra","ElectraForMaskedLM"],["esm","EsmForMaskedLM"],["convbert","ConvBertForMaskedLM"],["camembert","CamembertForMaskedLM"],["deberta","DebertaForMaskedLM"],["deberta-v2","DebertaV2ForMaskedLM"],["mpnet","MPNetForMaskedLM"],["albert","AlbertForMaskedLM"],["distilbert","DistilBertForMaskedLM"],["roberta","RobertaForMaskedLM"],["xlm","XLMWithLMHeadModel"],["xlm-roberta","XLMRobertaForMaskedLM"],["mobilebert","MobileBertForMaskedLM"],["squeezebert","SqueezeBertForMaskedLM"]]),gy=new Map([["bert","BertForQuestionAnswering"],["neobert","NeoBertForQuestionAnswering"],["roformer","RoFormerForQuestionAnswering"],["electra","ElectraForQuestionAnswering"],["convbert","ConvBertForQuestionAnswering"],["camembert","CamembertForQuestionAnswering"],["deberta","DebertaForQuestionAnswering"],["deberta-v2","DebertaV2ForQuestionAnswering"],["mpnet","MPNetForQuestionAnswering"],["albert","AlbertForQuestionAnswering"],["distilbert","DistilBertForQuestionAnswering"],["roberta","RobertaForQuestionAnswering"],["xlm","XLMForQuestionAnswering"],["xlm-roberta","XLMRobertaForQuestionAnswering"],["mobilebert","MobileBertForQuestionAnswering"],["squeezebert","SqueezeBertForQuestionAnswering"]]),wy=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),yy=new Map([["llava","LlavaForConditionalGeneration"],["llava_onevision","LlavaOnevisionForConditionalGeneration"],["moondream1","Moondream1ForConditionalGeneration"],["florence2","Florence2ForConditionalGeneration"],["qwen2-vl","Qwen2VLForConditionalGeneration"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"],["paligemma","PaliGemmaForConditionalGeneration"],["llava_qwen2","LlavaQwen2ForCausalLM"],["gemma3n","Gemma3nForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"]]),by=new Map([["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"]]),Ov=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),ky=new Map([["vit","ViTForImageClassification"],["ijepa","IJepaForImageClassification"],["pvt","PvtForImageClassification"],["vit_msn","ViTMSNForImageClassification"],["fastvit","FastViTForImageClassification"],["mobilevit","MobileViTForImageClassification"],["mobilevitv2","MobileViTV2ForImageClassification"],["beit","BeitForImageClassification"],["deit","DeiTForImageClassification"],["hiera","HieraForImageClassification"],["convnext","ConvNextForImageClassification"],["convnextv2","ConvNextV2ForImageClassification"],["dinov2","Dinov2ForImageClassification"],["dinov2_with_registers","Dinov2WithRegistersForImageClassification"],["resnet","ResNetForImageClassification"],["swin","SwinForImageClassification"],["segformer","SegformerForImageClassification"],["efficientnet","EfficientNetForImageClassification"],["mobilenet_v1","MobileNetV1ForImageClassification"],["mobilenet_v2","MobileNetV2ForImageClassification"],["mobilenet_v3","MobileNetV3ForImageClassification"],["mobilenet_v4","MobileNetV4ForImageClassification"]]),vy=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),Ey=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),Ys=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),Ay=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),My=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),Sy=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),Oy=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),Iy=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),zy=new Map([["wavlm","WavLMForXVector"]]),Ty=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),Py=new Map([["vitmatte","VitMatteForImageMatting"]]),Iv=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),Cy=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),Ny=new Map([["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),Ly=new Map([["sapiens","SapiensForNormalEstimation"]]),$y=new Map([["vitpose","VitPoseForPoseEstimation"]]),Ry=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),hg=[[vv,C.EncoderOnly],[Ev,C.EncoderDecoder],[Mv,C.DecoderOnlyWithoutHead],[Av,C.AutoEncoder],[_y,C.EncoderOnly],[fy,C.EncoderOnly],[my,C.Seq2Seq],[uy,C.Seq2Seq],[hy,C.DecoderOnly],[Sv,C.MultiModality],[xy,C.EncoderOnly],[gy,C.EncoderOnly],[wy,C.Vision2Seq],[yy,C.ImageTextToText],[by,C.AudioTextToText],[ky,C.EncoderOnly],[Ys,C.EncoderOnly],[My,C.EncoderOnly],[Ay,C.EncoderOnly],[Py,C.EncoderOnly],[Iv,C.EncoderOnly],[Cy,C.EncoderOnly],[Ny,C.EncoderOnly],[Ly,C.EncoderOnly],[$y,C.EncoderOnly],[vy,C.EncoderOnly],[Ey,C.EncoderOnly],[Sy,C.MaskGeneration],[Oy,C.EncoderOnly],[Iy,C.EncoderOnly],[py,C.Seq2Seq],[dy,C.EncoderOnly],[zy,C.EncoderOnly],[Ty,C.EncoderOnly],[Ry,C.EncoderOnly]];for(let[t,e]of hg)for(let s of t.values()){ss.set(s,e);let r=Oo[s];ts.set(r,s),Wa.set(s,r)}var zv=[["MusicgenForConditionalGeneration",Un,C.Musicgen],["Phi3VForCausalLM",to,C.Phi3V],["CLIPTextModelWithProjection",Rr,C.EncoderOnly],["SiglipTextModel",po,C.EncoderOnly],["JinaCLIPTextModel",vn,C.EncoderOnly],["ClapTextModelWithProjection",Lr,C.EncoderOnly],["ClapAudioModelWithProjection",$r,C.EncoderOnly],["DacEncoderModel",Wr,C.EncoderOnly],["DacDecoderModel",Vr,C.EncoderOnly],["MimiEncoderModel",Tn,C.EncoderOnly],["MimiDecoderModel",Pn,C.EncoderOnly],["SnacEncoderModel",fo,C.EncoderOnly],["SnacDecoderModel",mo,C.EncoderOnly],["Gemma3nForConditionalGeneration",an,C.ImageAudioTextToText],["SupertonicForConditionalGeneration",go,C.Supertonic],["ChatterboxModel",Nr,C.Chatterbox]];for(let[t,e,s]of zv)ss.set(t,s),ts.set(e,t),Wa.set(t,e);var xg=new Map([["modnet",Ys],["birefnet",Ys],["isnet",Ys],["ben",Ys]]);for(let[t,e]of xg.entries())e.set(t,"PreTrainedModel"),ss.set(t,C.EncoderOnly),Wa.set(t,f);ss.set("PreTrainedModel",C.EncoderOnly);ts.set(f,"PreTrainedModel");var le={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:_y,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:fy,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:py,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:dy,MODEL_FOR_MASKED_LM_MAPPING_NAMES:xy,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:gy,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:ky,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:Ys,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:Ay,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:My,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:vy,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:Ey,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:Sy,MODEL_FOR_CTC_MAPPING_NAMES:Oy,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:Iy,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:zy,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:Ty,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:Ov,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:Py,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:Cy,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:Ny,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:Ly,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:$y,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:Ry,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:yy,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:by,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:my,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:uy,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:hy,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:wy};ay(le);var ie=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:c=null,dtype:u=null,use_external_data_format:p=null,session_options:d={}}={}){let _={progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:c,dtype:u,use_external_data_format:p,session_options:d};if(_.config=await Yt.from_pretrained(e,_),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let m=_.config.model_type;for(let h of this.MODEL_CLASS_MAPPINGS){let x=h.get(m);if(!x){for(let g of h.values())if(g[0]===m){x=g;break}if(!x)continue}return await Oo[x].from_pretrained(e,_)}if(this.BASE_IF_FAIL)return xg.has(m)||console.warn(`Unknown model class "${m}", attempting to construct from base class.`),await f.from_pretrained(e,_);throw Error(`Unsupported model type: ${m}`)}},kt=class extends ie{static MODEL_CLASS_MAPPINGS=hg.map(e=>e[0]);static BASE_IF_FAIL=!0},Io=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},Vi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},Zs=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},Hi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},Xi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},Ki=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},Qi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},Ji=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},Yi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},Zi=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},el=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},zo=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},To=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},Po=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},tl=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},sl=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},Fy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},rl=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_CTC_MAPPING_NAMES]},nl=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},Dy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},jy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},ol=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},By=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},al=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},il=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},Uy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},qy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},ll=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},Gy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},Wy=class extends ie{static MODEL_CLASS_MAPPINGS=[le.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function be(t){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(e=>we.read(e)))}async function Ut(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(s=>typeof s=="string"||s instanceof URL?Qc(s,e):s instanceof Float64Array?new Float32Array(s):s))}function Co(t,e){e&&(t=t.map(a=>a|0));let[s,r,n,o]=t;return{xmin:s,ymin:r,xmax:n,ymax:o}}var W=class extends ke{constructor({task:e,model:s,tokenizer:r=null,processor:n=null}){super(),this.task=e,this.model=s,this.tokenizer=r,this.processor=n}async dispose(){await this.model.dispose()}};var cl=class extends W{async _call(e,{top_k:s=1}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),{problem_type:o,id2label:a}=this.model.config,i=o==="multi_label_classification"?c=>c.sigmoid():c=>new S("float32",ce(c.data),c.dims),l=[];for(let c of n.logits){let u=i(c),p=await ot(u,s),d=p[0].tolist(),m=p[1].tolist().map((h,x)=>({label:a?a[h]:`LABEL_${h}`,score:d[x]}));s===1?l.push(...m):l.push(m)}return Array.isArray(e)||s===1?l:l[0]}};var ul=class extends W{async _call(e,{ignore_labels:s=["O"]}={}){let r=Array.isArray(e),n=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),a=(await this.model(n)).logits,i=this.model.config.id2label,l=[];for(let c=0;c<a.dims[0];++c){let u=n.input_ids[c],p=a[c],d=[];for(let _=0;_<p.dims[0];++_){let m=p[_],h=ae(m.data)[1],x=i?i[h]:`LABEL_${h}`;if(s.includes(x))continue;let g=this.tokenizer.decode([u[_].item()],{skip_special_tokens:!0});if(g==="")continue;let w=ce(m.data);d.push({entity:x,score:w[h],index:_,word:g})}l.push(d)}return r?l:l[0]}};var pl=class extends W{async _call(e,s,{top_k:r=1}={}){let n=this.tokenizer(e,{text_pair:s,padding:!0,truncation:!0}),o=Array.isArray(e),{start_logits:a,end_logits:i}=await this.model(n),l=n.input_ids.tolist(),c=n.attention_mask.tolist(),{all_special_ids:u,sep_token_id:p}=this.tokenizer,d=[];for(let _=0;_<a.dims[0];++_){let m=l[_],h=m.findIndex(b=>b==p),x=a[_].tolist(),g=i[_].tolist();for(let b=1;b<x.length;++b)(c[_]==0||b<=h||u.findIndex(O=>O==m[b])!==-1)&&(x[b]=-1/0,g[b]=-1/0);let w=ce(x).map((b,O)=>[b,O]),y=ce(g).map((b,O)=>[b,O]);w[0][0]=0,y[0][0]=0;let E=rw(w,y).filter(b=>b[0][1]<=b[1][1]).map(b=>[b[0][1],b[1][1],b[0][0]*b[1][0]]).sort((b,O)=>O[2]-b[2]),A=[];for(let b=0;b<Math.min(E.length,r);++b){let[O,N,F]=E[b],R=m.slice(O,N+1),B=this.tokenizer.decode(R,{skip_special_tokens:!0});A.push({answer:B,score:F})}r===1?d.push(...A):d.push(A)}return o?d:d[0]}};var dl=class extends W{async _call(e,{top_k:s=5}={}){let{mask_token_id:r,mask_token:n}=this.tokenizer,o=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:a}=await this.model(o),i=[],l=o.input_ids.tolist();for(let c=0;c<l.length;++c){let u=l[c],p=u.findIndex(x=>x==r);if(p===-1)throw Error(`Mask token (${n}) not found in text.`);let d=a[c][p],_=await ot(new S("float32",ce(d.data),d.dims),s),m=_[0].tolist(),h=_[1].tolist();i.push(h.map((x,g)=>{let w=u.slice();return w[p]=x,{score:m[g],token:Number(x),token_str:this.tokenizer.decode([x]),sequence:this.tokenizer.decode(w,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}};var qt=class extends W{_key="generated_text";async _call(e,s={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(l=>this.model.config.prefix+l));let r=this.model.config.task_specific_params;r&&r[this.task]&&r[this.task].prefix&&(e=e.map(l=>r[this.task].prefix+l));let n=this.tokenizer,o={padding:!0,truncation:!0},a;this.task==="translation"&&"_build_translation_inputs"in n?a=n._build_translation_inputs(e,o,s):a=n(e,o);let i=await this.model.generate({...a,...s});return n.batch_decode(i,{skip_special_tokens:!0}).map(l=>({[this._key]:l}))}};var _l=class extends qt{_key="summary_text"};var fl=class extends qt{_key="translation_text"};function Vy(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var ml=class extends W{async _call(e,s={}){let r=!1,n=!1,o=s.add_special_tokens??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,a=s.tokenizer_encode_kwargs,i;if(typeof e=="string")i=e=[e];else if(Array.isArray(e)&&e.every(m=>typeof m=="string"))r=!0,i=e;else{if(Vy(e))e=[e];else if(Array.isArray(e)&&e.every(Vy))r=!0;else throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");n=!0,i=e.map(m=>this.tokenizer.apply_chat_template(m,{tokenize:!1,add_generation_prompt:!0,...a})),o=!1,a=void 0}let l=n?!1:s.return_full_text??!0;this.tokenizer.padding_side="left";let c=this.tokenizer(i,{add_special_tokens:o,padding:!0,truncation:!0,...a}),u=await this.model.generate({...c,...s}),p=this.tokenizer.batch_decode(u,{skip_special_tokens:!0}),d;!l&&c.input_ids.dims.at(-1)>0&&(d=this.tokenizer.batch_decode(c.input_ids,{skip_special_tokens:!0}).map(m=>m.length));let _=Array.from({length:e.length},m=>[]);for(let m=0;m<p.length;++m){let h=Math.floor(m/u.dims[0]*e.length);d&&(p[m]=p[m].slice(d[h])),_[h].push({generated_text:n?[...e[h],{role:"assistant",content:p[m]}]:p[m]})}return!r&&_.length===1?_[0]:_}};var hl=class extends W{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([s,r])=>[s.toLowerCase(),r])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(console.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(console.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,s,{hypothesis_template:r="This example is {}.",multi_label:n=!1}={}){let o=Array.isArray(e);o||(e=[e]),Array.isArray(s)||(s=[s]);let a=s.map(c=>r.replace("{}",c)),i=n||s.length===1,l=[];for(let c of e){let u=[];for(let _ of a){let m=this.tokenizer(c,{text_pair:_,padding:!0,truncation:!0}),h=await this.model(m);i?u.push([h.logits.data[this.contradiction_id],h.logits.data[this.entailment_id]]):u.push(h.logits.data[this.entailment_id])}let d=(i?u.map(_=>ce(_)[1]):ce(u)).map((_,m)=>[_,m]).sort((_,m)=>m[0]-_[0]);l.push({sequence:c,labels:d.map(_=>s[_[1]]),scores:d.map(_=>_[0])})}return o?l:l[0]}};var xl=class extends W{async _call(e,{top_k:s=5}={}){let r=this.processor.feature_extractor.config.sampling_rate,n=await Ut(e,r),o=this.model.config.id2label,a=[];for(let i of n){let l=await this.processor(i),u=(await this.model(l)).logits[0],p=await ot(new S("float32",ce(u.data),u.dims),s),d=p[0].tolist(),m=p[1].tolist().map((h,x)=>({label:o?o[h]:`LABEL_${h}`,score:d[x]}));a.push(m)}return Array.isArray(e)?a:a[0]}};var gl=class extends W{async _call(e,s,{hypothesis_template:r="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let o=s.map(u=>r.replace("{}",u)),a=this.tokenizer(o,{padding:!0,truncation:!0}),i=this.processor.feature_extractor.config.sampling_rate,l=await Ut(e,i),c=[];for(let u of l){let p=await this.processor(u),d=await this.model({...a,...p}),_=ce(d.logits_per_audio.data);c.push([..._].map((m,h)=>({score:m,label:s[h]})))}return n?c[0]:c}};var wl=class extends W{async _call(e,s={}){switch(this.model.config.model_type){case"whisper":case"lite-whisper":return this._call_whisper(e,s);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":case"parakeet_ctc":return this._call_wav2vec2(e,s);case"moonshine":return this._call_moonshine(e,s);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,s){s.language&&console.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),s.task&&console.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let r=!Array.isArray(e),n=r?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await Ut(n,o),i=[];for(let l of a){let c=await this.processor(l),p=(await this.model(c)).logits[0],d=[];for(let m of p)d.push(ae(m.data)[1]);let _=this.tokenizer.decode(d,{skip_special_tokens:!0}).trim();i.push({text:_})}return r?i[0]:i}async _call_whisper(e,s){let r=s.return_timestamps??!1,n=s.chunk_length_s??0,o=s.force_full_sequences??!1,a=s.stride_length_s??null,i={...s};r==="word"&&(i.return_token_timestamps=!0,i.return_timestamps=!1);let l=!Array.isArray(e),c=l?[e]:e,u=this.processor.feature_extractor.config,p=u.chunk_length/this.model.config.max_source_positions,d=u.hop_length,_=u.sampling_rate,m=await Ut(c,_),h=[];for(let x of m){let g=[];if(n>0){if(a===null)a=n/6;else if(n<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let E=_*n,A=_*a,b=E-2*A,O=0;for(;;){let N=O+E,F=x.subarray(O,N),R=await this.processor(F),B=O===0,G=N>=x.length;if(g.push({stride:[F.length,B?0:A,G?0:A],input_features:R.input_features,is_last:G}),G)break;O+=b}}else g=[{stride:[x.length,0,0],input_features:(await this.processor(x)).input_features,is_last:!0}];for(let E of g){i.num_frames=Math.floor(E.stride[0]/d);let A=await this.model.generate({inputs:E.input_features,...i});r==="word"?(E.tokens=A.sequences.tolist()[0],E.token_timestamps=A.token_timestamps.tolist()[0].map(b=>Kt(b,2))):E.tokens=A[0].tolist(),E.stride=E.stride.map(b=>b/_)}let[w,y]=this.tokenizer._decode_asr(g,{time_precision:p,return_timestamps:r,force_full_sequences:o});h.push({text:w,...y})}return l?h[0]:h}async _call_moonshine(e,s){let r=!Array.isArray(e),n=r?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await Ut(n,o),i=[];for(let l of a){let c=await this.processor(l),u=Math.floor(l.length/o)*6,p=await this.model.generate({max_new_tokens:u,...s,...c}),d=this.processor.batch_decode(p,{skip_special_tokens:!0})[0];i.push({text:d})}return r?i[0]:i}};var yl=class extends W{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,s){if((typeof e=="string"||e instanceof URL)&&(e=new Float32Array(await(await fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new S("float32",e,[e.length]);else if(!(e instanceof S))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(s>1){if(e.dims[0]===1)e=e.repeat(s,1);else if(e.dims[0]!==s)throw new Error(`Expected speaker embeddings batch size to be 1 or ${s}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,s,r,n=null){let o=s.data,[a,i]=s.dims,l=n?n.data:null,c=[];for(let u=0;u<a;++u){let p=l?Math.min(Math.ceil(l[u]),i):i,d=u*i;c.push(new hr(o.slice(d,d+p),r))}return Array.isArray(e)?c:c[0]}async _call(e,s){return this.processor?this._call_text_to_spectrogram(e,s):this.model.config.model_type==="supertonic"?this._call_supertonic(e,s):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:s,num_inference_steps:r,speed:n}){if(!s)throw new Error("Speaker embeddings must be provided for Supertonic models.");let{sampling_rate:o,style_dim:a}=this.model.config,i=this.tokenizer(e,{padding:!0,truncation:!0}),l=i.input_ids.dims[0];s=await this._prepare_speaker_embeddings(s,l),s=s.view(l,-1,a);let{waveform:c,durations:u}=await this.model.generate_speech({...i,style:s,num_inference_steps:r,speed:n});return this._postprocess_waveform(e,c,o,u)}async _call_text_to_waveform(e){let s=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:r}=await this.model(s),n=this.model.config.sampling_rate;return this._postprocess_waveform(e,r,n)}async _call_text_to_spectrogram(e,{speaker_embeddings:s}){this.vocoder||(console.log("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await kt.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"}));let{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),n=r.dims[0];s=await this._prepare_speaker_embeddings(s,n),s=s.view(n,-1);let{waveform:o}=await this.model.generate_speech(r,s,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,o,a)}};var bl=class extends W{async _call(e,s={}){let r=Array.isArray(e),n=await be(e),{pixel_values:o}=await this.processor(n),a=[];for(let i of o){i.dims=[1,...i.dims];let l=await this.model.generate({inputs:i,...s}),c=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(u=>({generated_text:u.trim()}));a.push(c)}return r?a:a[0]}};var kl=class extends W{async _call(e,{top_k:s=5}={}){let r=await be(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n}),{id2label:a}=this.model.config,i=[];for(let l of o.logits){let c=await ot(new S("float32",ce(l.data),l.dims),s),u=c[0].tolist(),d=c[1].tolist().map((_,m)=>({label:a?a[_]:`LABEL_${_}`,score:u[m]}));i.push(d)}return Array.isArray(e)?i:i[0]}};var Hy={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},er=class extends W{async _call(e,{threshold:s=.5,mask_threshold:r=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:o=null,target_sizes:a=null,subtask:i=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let c=await be(e),u=c.map(w=>[w.height,w.width]),p=await this.processor(c),{inputNames:d,outputNames:_}=this.model.sessions.model;if(!d.includes("pixel_values")){if(d.length!==1)throw Error(`Expected a single input name, but got ${d.length} inputs: ${d}.`);let w=d[0];if(w in p)throw Error(`Input name ${w} already exists in the inputs.`);p[w]=p.pixel_values}let m=await this.model(p),h=null;if(i!==null)h=Hy[i];else if(this.processor.image_processor){for(let[w,y]of Object.entries(Hy))if(y in this.processor.image_processor){h=this.processor.image_processor[y].bind(this.processor.image_processor),i=w;break}}let x=this.model.config.id2label,g=[];if(i)if(i==="panoptic"||i==="instance"){let w=h(m,s,r,n,o,a??u)[0],y=w.segmentation;for(let E of w.segments_info){let A=new Uint8ClampedArray(y.data.length);for(let O=0;O<y.data.length;++O)y.data[O]===E.id&&(A[O]=255);let b=new we(A,y.dims[1],y.dims[0],1);g.push({score:E.score,label:x[E.label_id],mask:b})}}else if(i==="semantic"){let{segmentation:w,labels:y}=h(m,a??u)[0];for(let E of y){let A=new Uint8ClampedArray(w.data.length);for(let O=0;O<w.data.length;++O)w.data[O]===E&&(A[O]=255);let b=new we(A,w.dims[1],w.dims[0],1);g.push({score:null,label:x[E],mask:b})}}else throw Error(`Subtask ${i} not supported.`);else{let y=m[_[0]];for(let E=0;E<u.length;++E){let A=u[E],b=y[E];b.data.some(N=>N<-1e-5||N>1+1e-5)&&b.sigmoid_();let O=await we.fromTensor(b.mul_(255).to("uint8")).resize(A[1],A[0]);g.push({label:null,score:null,mask:O})}}return g}};var vl=class extends er{async _call(e,s={}){let r=await be(e),n=await super._call(e,s),o=r.map((a,i)=>{let l=a.clone();return l.putAlpha(n[i].mask),l});return Array.isArray(e)?o:o[0]}};var El=class extends W{async _call(e,s,{hypothesis_template:r="This is a photo of {}"}={}){let n=Array.isArray(e),o=await be(e),a=s.map(d=>r.replace("{}",d)),i=this.tokenizer(a,{padding:this.model.config.model_type==="siglip"?"max_length":!0,truncation:!0}),{pixel_values:l}=await this.processor(o),c=await this.model({...i,pixel_values:l}),u=this.model.config.model_type==="siglip"?d=>d.sigmoid().data:d=>ce(d.data),p=[];for(let d of c.logits_per_image){let m=[...u(d)].map((h,x)=>({score:h,label:s[x]}));m.sort((h,x)=>x.score-h.score),p.push(m)}return n?p:p[0]}};var Al=class extends W{async _call(e,{threshold:s=.9,percentage:r=!1}={}){let n=Array.isArray(e);if(n&&e.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");let o=await be(e),a=r?null:o.map(_=>[_.height,_.width]),{pixel_values:i,pixel_mask:l}=await this.processor(o),c=await this.model({pixel_values:i,pixel_mask:l}),u=this.processor.image_processor.post_process_object_detection(c,s,a),{id2label:p}=this.model.config,d=u.map(_=>_.boxes.map((m,h)=>({score:_.scores[h],label:p[_.classes[h]],box:Co(m,!r)})));return n?d:d[0]}};var Ml=class extends W{async _call(e,s,{threshold:r=.1,top_k:n=null,percentage:o=!1}={}){let a=Array.isArray(e),i=await be(e),l=this.tokenizer(s,{padding:!0,truncation:!0}),c=await this.processor(i),u=[];for(let p=0;p<i.length;++p){let d=i[p],_=o?null:[[d.height,d.width]],m=c.pixel_values[p].unsqueeze_(0),h=await this.model({...l,pixel_values:m}),x;if("post_process_grounded_object_detection"in this.processor){let g=this.processor.post_process_grounded_object_detection(h,l.input_ids,{box_threshold:r,text_threshold:r,target_sizes:_})[0];x=g.boxes.map((w,y)=>({score:g.scores[y],label:g.labels[y],box:Co(w,!o)}))}else{let g=this.processor.image_processor.post_process_object_detection(h,r,_,!0)[0];x=g.boxes.map((w,y)=>({score:g.scores[y],label:s[g.classes[y]],box:Co(w,!o)}))}x.sort((g,w)=>w.score-g.score),n!==null&&(x=x.slice(0,n)),u.push(x)}return a?u:u[0]}};var Sl=class extends W{async _call(e,s,r={}){if(Array.isArray(e)){if(e.length!==1)throw Error("Document Question Answering pipeline currently only supports a batch size of 1.");e=e[0]}let n=(await be(e))[0],{pixel_values:o}=await this.processor(n),a=`<s_docvqa><s_question>${s}</s_question><s_answer>`,i=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,l=await this.model.generate({inputs:o,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:i,...r}),u=this.tokenizer.batch_decode(l)[0].match(/<s_answer>(.*?)<\/s_answer>/),p=null;return u&&u.length>=2&&(p=u[1].trim()),[{answer:p}]}};var Ol=class extends W{async _call(e){let s=await be(e),r=await this.processor(s),n=await this.model(r),o=[];for(let a of n.reconstruction){let i=a.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");o.push(we.fromTensor(i))}return Array.isArray(e)?o:o[0]}};var Il=class extends W{async _call(e){let s=await be(e),r=await this.processor(s),{predicted_depth:n}=await this.model(r),o=[];for(let a=0;a<s.length;++a){let i=n[a],[l,c]=i.dims.slice(-2),[u,p]=s[a].size,d=(await Xe(i.view(1,1,l,c),{size:[p,u],mode:"bilinear"})).view(p,u),_=d.min().item(),m=d.max().item(),h=d.sub(_).div_(m-_).mul_(255).to("uint8").unsqueeze(0),x=we.fromTensor(h);o.push({predicted_depth:d,depth:x})}return Array.isArray(e)?o:o[0]}};var zl=class extends W{async _call(e,{pooling:s="none",normalize:r=!1,quantize:n=!1,precision:o="binary"}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),i=await this.model(a),l=i.last_hidden_state??i.logits??i.token_embeddings;switch(s){case"none":break;case"mean":l=Lw(l,a.attention_mask);break;case"first_token":case"cls":l=l.slice(null,0);break;case"last_token":case"eos":l=l.slice(null,-1);break;default:throw Error(`Pooling method '${s}' not supported.`)}return r&&(l=l.normalize(2,-1)),n&&(l=Rw(l,o)),l}};var Tl=class extends W{async _call(e,{pool:s=null}={}){let r=await be(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n}),a;if(s){if(!("pooler_output"in o))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");a=o.pooler_output}else a=o.last_hidden_state??o.logits??o.image_embeds;return a}};var Xy=Object.freeze({"text-classification":{tokenizer:L,pipeline:cl,model:Io,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{tokenizer:L,pipeline:ul,model:Vi,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{tokenizer:L,pipeline:pl,model:Yi,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{tokenizer:L,pipeline:dl,model:Ji,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{tokenizer:L,pipeline:_l,model:Zs,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{tokenizer:L,pipeline:fl,model:Zs,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{tokenizer:L,pipeline:qt,model:Zs,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{tokenizer:L,pipeline:ml,model:Qi,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{tokenizer:L,pipeline:hl,model:Io,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:xl,model:nl,processor:ze,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{tokenizer:L,pipeline:gl,model:kt,processor:ze,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{tokenizer:L,pipeline:wl,model:[Hi,rl],processor:ze,default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{tokenizer:L,pipeline:yl,model:[Ki,Xi],processor:[ze,null],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{tokenizer:L,pipeline:bl,model:Zi,processor:ze,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:kl,model:el,processor:ze,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:er,model:[zo,To,Po],processor:ze,default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:vl,model:[zo,To,Po],processor:ze,default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{tokenizer:L,pipeline:El,model:kt,processor:ze,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:Al,model:tl,processor:ze,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{tokenizer:L,pipeline:Ml,model:sl,processor:ze,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{tokenizer:L,pipeline:Sl,model:ol,processor:ze,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Ol,model:al,processor:ze,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Il,model:il,processor:ze,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{tokenizer:L,pipeline:zl,model:kt,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{processor:ze,pipeline:Tl,model:[ll,kt],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),Tv=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function r9(t,e=null,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",device:i=null,dtype:l=null,subfolder:c="onnx",use_external_data_format:u=null,model_file_name:p=null,session_options:d={}}={}){t=Tv[t]??t;let _=Xy[t.split("_",1)[0]];if(!_)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(Xy)}]`);e||(e=_.default.model,console.log(`No model specified. Using default model: "${e}".`),!l&&_.default.dtype&&(l=_.default.dtype));let m={progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:a,device:i,dtype:l,subfolder:c,use_external_data_format:u,model_file_name:p,session_options:d},h=new Map([["tokenizer",_.tokenizer],["model",_.model],["processor",_.processor]]),x=await Pv(h,e,m);x.task=t,yt(s,{status:"ready",task:t,model:e});let g=_.pipeline;return new g(x)}async function Pv(t,e,s){let r=Object.create(null),n=[];for(let[o,a]of t.entries()){if(!a)continue;let i;Array.isArray(a)?i=new Promise(async(l,c)=>{let u;for(let p of a){if(p===null){l(null);return}try{l(await p.from_pretrained(e,s));return}catch(d){if(d.message?.includes("Unsupported model type"))u=d;else if(d.message?.includes("Could not locate file"))u=d;else{c(d);return}}}c(u)}):i=a.from_pretrained(e,s),r[o]=i,n.push(i)}await Promise.all(n);for(let[o,a]of Object.entries(r))r[o]=await a;return r}var Cv=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,gg=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},Ky=ee.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),wg=class extends gg{constructor(e,{skip_prompt:s=!1,callback_function:r=null,token_callback_function:n=null,skip_special_tokens:o=!0,decode_kwargs:a={},...i}={}){super(),this.tokenizer=e,this.skip_prompt=s,this.callback_function=r??Ky,this.token_callback_function=n,this.decode_kwargs={skip_special_tokens:o,...a,...i},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");let s=this.next_tokens_are_prompt;if(s&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let r=e[0];this.token_callback_function?.(r),this.token_cache=Pe(this.token_cache,r);let n=this.tokenizer.decode(this.token_cache,this.decode_kwargs),o;s||n.endsWith(`
23
- `)?(o=n.slice(this.print_len),this.token_cache=[],this.print_len=0):n.length>0&&Cv(n.charCodeAt(n.length-1))?(o=n.slice(this.print_len),this.print_len+=o.length):(o=n.slice(this.print_len,n.lastIndexOf(" ")+1),this.print_len+=o.length),this.on_finalized_text(o,!1)}end(){let e;this.token_cache.length>0?(e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0):e="",this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,s){e.length>0&&this.callback_function?.(e),s&&this.callback_function===Ky&&ee.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
24
- `)}},Qy=class extends wg{constructor(e,{skip_prompt:s=!1,callback_function:r=null,token_callback_function:n=null,on_chunk_start:o=null,on_chunk_end:a=null,on_finalize:i=null,time_precision:l=.02,skip_special_tokens:c=!0,decode_kwargs:u={}}={}){super(e,{skip_prompt:s,skip_special_tokens:c,callback_function:r,token_callback_function:n,decode_kwargs:u}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=o,this.on_chunk_end=a,this.on_finalize=i,this.time_precision=l,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");let s=e[0];if(s.length===1){let r=Number(s[0])-this.timestamp_begin;if(r>=0){let n=r*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(n):this.on_chunk_start?.(n),this.waiting_for_timestamp=!this.waiting_for_timestamp,this.token_callback_function?.(s);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}};var No=class{constructor(e,s){this.image=e,this.timestamp=s}},Pl=class{constructor(e,s){e.length>0&&e[0]instanceof we&&(e=e.map((r,n)=>new No(r,(n+1)/(e.length+1)*s))),this.frames=e,this.duration=s}get width(){return this.frames[0].image.width}get height(){return this.frames[0].image.height}get fps(){return this.frames.length/this.duration}};async function Nv(t,{num_frames:e=null,fps:s=null}={}){if(!ee.IS_BROWSER_ENV)throw new Error("`load_video` is currently only supported in browser environments.");if(e==null&&s==null)throw new Error("Either num_frames or fps must be provided.");let r=[],n=document.createElement("video");if(n.crossOrigin="anonymous",n.muted=!0,typeof t=="string")n.src=t;else if(t instanceof Blob)n.src=URL.createObjectURL(t);else if(t instanceof HTMLVideoElement)n.src=t.src;else throw new Error("Invalid URL or video element provided.");if(await new Promise(p=>n.onloadedmetadata=p),n.seekable.start(0)===n.seekable.end(0)){let d=await(await fetch(n.src)).blob();n.src=URL.createObjectURL(d),await new Promise(_=>n.onloadedmetadata=_)}let o=n.duration,a,i;e!=null?(a=e,i=e===1?0:o/(e-1)):(i=1/s,a=Math.floor(o/i));let l=[];for(let p=0;p<a;++p)l.push(e===1?o/2:p*i);let c=document.createElement("canvas");c.width=n.videoWidth,c.height=n.videoHeight;let u=c.getContext("2d",{willReadFrequently:!0});for(let p of l){n.currentTime=p,await new Promise(h=>{n.onseeked=h}),u.drawImage(n,0,0,c.width,c.height);let d=u.getImageData(0,0,c.width,c.height),_=new we(d.data,c.width,c.height,4),m=new No(_,p);r.push(m)}return n.remove(),new Pl(r,o)}export{Jc as ASTFeatureExtractor,Lp as ASTForAudioClassification,Np as ASTModel,Ir as ASTPreTrainedModel,Ip as AlbertForMaskedLM,Op as AlbertForQuestionAnswering,Sp as AlbertForSequenceClassification,Mp as AlbertModel,rs as AlbertPreTrainedModel,nc as AlbertTokenizer,Tp as ApertusForCausalLM,zp as ApertusModel,Sr as ApertusPreTrainedModel,Cp as ArceeForCausalLM,Pp as ArceeModel,Or as ArceePreTrainedModel,xl as AudioClassificationPipeline,Yt as AutoConfig,ve as AutoFeatureExtractor,de as AutoImageProcessor,kt as AutoModel,nl as AutoModelForAudioClassification,jy as AutoModelForAudioFrameClassification,Wy as AutoModelForAudioTextToText,rl as AutoModelForCTC,Qi as AutoModelForCausalLM,il as AutoModelForDepthEstimation,ol as AutoModelForDocumentQuestionAnswering,el as AutoModelForImageClassification,ll as AutoModelForImageFeatureExtraction,By as AutoModelForImageMatting,zo as AutoModelForImageSegmentation,Gy as AutoModelForImageTextToText,al as AutoModelForImageToImage,Fy as AutoModelForMaskGeneration,Ji as AutoModelForMaskedLM,Uy as AutoModelForNormalEstimation,tl as AutoModelForObjectDetection,qy as AutoModelForPoseEstimation,Yi as AutoModelForQuestionAnswering,To as AutoModelForSemanticSegmentation,Zs as AutoModelForSeq2SeqLM,Io as AutoModelForSequenceClassification,Hi as AutoModelForSpeechSeq2Seq,Xi as AutoModelForTextToSpectrogram,Ki as AutoModelForTextToWaveform,Vi as AutoModelForTokenClassification,Po as AutoModelForUniversalSegmentation,Zi as AutoModelForVision2Seq,Dy as AutoModelForXVector,sl as AutoModelForZeroShotObjectDetection,ze as AutoProcessor,L as AutoTokenizer,wl as AutomaticSpeechRecognitionPipeline,vl as BackgroundRemovalPipeline,Rp as BartForConditionalGeneration,Fp as BartForSequenceClassification,$p as BartModel,Cs as BartPretrainedModel,oc as BartTokenizer,gg as BaseStreamer,du as BeitFeatureExtractor,jp as BeitForImageClassification,Dp as BeitModel,zr as BeitPreTrainedModel,Up as BertForMaskedLM,Wp as BertForQuestionAnswering,qp as BertForSequenceClassification,Gp as BertForTokenClassification,Bp as BertModel,Ot as BertPreTrainedModel,ac as BertTokenizer,_u as BitImageProcessor,Hp as BlenderbotForConditionalGeneration,Vp as BlenderbotModel,Tr as BlenderbotPreTrainedModel,Kp as BlenderbotSmallForConditionalGeneration,Xp as BlenderbotSmallModel,Pr as BlenderbotSmallPreTrainedModel,ic as BlenderbotSmallTokenizer,lc as BlenderbotTokenizer,Jp as BloomForCausalLM,Qp as BloomModel,Cr as BloomPreTrainedModel,cc as BloomTokenizer,mu as CLIPFeatureExtractor,la as CLIPImageProcessor,od as CLIPModel,ft as CLIPPreTrainedModel,ud as CLIPSegForImageSegmentation,cd as CLIPSegModel,Fr as CLIPSegPreTrainedModel,ad as CLIPTextModel,Rr as CLIPTextModelWithProjection,pc as CLIPTokenizer,id as CLIPVisionModel,ld as CLIPVisionModelWithProjection,Zp as CamembertForMaskedLM,sd as CamembertForQuestionAnswering,ed as CamembertForSequenceClassification,td as CamembertForTokenClassification,Yp as CamembertModel,It as CamembertPreTrainedModel,uc as CamembertTokenizer,Yc as ChatterboxFeatureExtractor,Nr as ChatterboxModel,Ha as ChatterboxPreTrainedModel,cu as ChatterboxProcessor,fu as ChineseCLIPFeatureExtractor,rd as ChineseCLIPModel,Xa as ChineseCLIPPreTrainedModel,$r as ClapAudioModelWithProjection,Zc as ClapFeatureExtractor,nd as ClapModel,Ns as ClapPreTrainedModel,Lr as ClapTextModelWithProjection,Fa as ClassifierFreeGuidanceLogitsProcessor,dd as CodeGenForCausalLM,pd as CodeGenModel,Dr as CodeGenPreTrainedModel,_c as CodeGenTokenizer,dc as CodeLlamaTokenizer,fd as CohereForCausalLM,_d as CohereModel,jr as CoherePreTrainedModel,fc as CohereTokenizer,hd as ConvBertForMaskedLM,wd as ConvBertForQuestionAnswering,xd as ConvBertForSequenceClassification,gd as ConvBertForTokenClassification,md as ConvBertModel,zt as ConvBertPreTrainedModel,mc as ConvBertTokenizer,hu as ConvNextFeatureExtractor,bd as ConvNextForImageClassification,ca as ConvNextImageProcessor,yd as ConvNextModel,Br as ConvNextPreTrainedModel,vd as ConvNextV2ForImageClassification,kd as ConvNextV2Model,Ur as ConvNextV2PreTrainedModel,Sd as DFineForObjectDetection,Md as DFineModel,Gr as DFinePreTrainedModel,Jd as DINOv3ConvNextModel,ti as DINOv3ConvNextPreTrainedModel,wu as DINOv3ViTImageProcessor,Yd as DINOv3ViTModel,si as DINOv3ViTPreTrainedModel,bu as DPTFeatureExtractor,a_ as DPTForDepthEstimation,da as DPTImageProcessor,o_ as DPTModel,Qr as DPTPreTrainedModel,Vr as DacDecoderModel,Qa as DacDecoderOutput,Wr as DacEncoderModel,Ka as DacEncoderOutput,gr as DacFeatureExtractor,Od as DacModel,Ls as DacPreTrainedModel,zd as DebertaForMaskedLM,Cd as DebertaForQuestionAnswering,Td as DebertaForSequenceClassification,Pd as DebertaForTokenClassification,Id as DebertaModel,Tt as DebertaPreTrainedModel,xc as DebertaTokenizer,Ld as DebertaV2ForMaskedLM,Fd as DebertaV2ForQuestionAnswering,$d as DebertaV2ForSequenceClassification,Rd as DebertaV2ForTokenClassification,Nd as DebertaV2Model,Pt as DebertaV2PreTrainedModel,hc as DebertaV2Tokenizer,Dd as DecisionTransformerModel,Ja as DecisionTransformerPreTrainedModel,xu as DeiTFeatureExtractor,Bd as DeiTForImageClassification,ua as DeiTImageProcessor,jd as DeiTModel,Hr as DeiTPreTrainedModel,Ud as DepthAnythingForDepthEstimation,Ya as DepthAnythingPreTrainedModel,Il as DepthEstimationPipeline,qd as DepthProForDepthEstimation,Za as DepthProPreTrainedModel,gu as DetrFeatureExtractor,Wd as DetrForObjectDetection,Vd as DetrForSegmentation,pa as DetrImageProcessor,Gd as DetrModel,Rs as DetrObjectDetectionOutput,$s as DetrPreTrainedModel,ei as DetrSegmentationOutput,Xd as Dinov2ForImageClassification,Hd as Dinov2Model,Xr as Dinov2PreTrainedModel,Qd as Dinov2WithRegistersForImageClassification,Kd as Dinov2WithRegistersModel,Kr as Dinov2WithRegistersPreTrainedModel,r_ as DistilBertForMaskedLM,s_ as DistilBertForQuestionAnswering,e_ as DistilBertForSequenceClassification,t_ as DistilBertForTokenClassification,Zd as DistilBertModel,Ct as DistilBertPreTrainedModel,gc as DistilBertTokenizer,Sl as DocumentQuestionAnsweringPipeline,yu as DonutFeatureExtractor,vs as DonutImageProcessor,n_ as DonutSwinModel,ri as DonutSwinPreTrainedModel,Gh as EdgeTamModel,l_ as EfficientNetForImageClassification,ku as EfficientNetImageProcessor,i_ as EfficientNetModel,Jr as EfficientNetPreTrainedModel,u_ as ElectraForMaskedLM,__ as ElectraForQuestionAnswering,p_ as ElectraForSequenceClassification,d_ as ElectraForTokenClassification,c_ as ElectraModel,Nt as ElectraPreTrainedModel,wc as ElectraTokenizer,xr as EncodecFeatureExtractor,Ua as EosTokenCriteria,m_ as Ernie4_5ForCausalLM,f_ as Ernie4_5Model,Yr as Ernie4_5PretrainedModel,x_ as EsmForMaskedLM,g_ as EsmForSequenceClassification,w_ as EsmForTokenClassification,h_ as EsmModel,ns as EsmPreTrainedModel,yc as EsmTokenizer,b_ as ExaoneForCausalLM,y_ as ExaoneModel,Zr as ExaonePreTrainedModel,v_ as FalconForCausalLM,A_ as FalconH1ForCausalLM,E_ as FalconH1Model,tn as FalconH1PreTrainedModel,k_ as FalconModel,en as FalconPreTrainedModel,bc as FalconTokenizer,S_ as FastViTForImageClassification,M_ as FastViTModel,sn as FastViTPreTrainedModel,zl as FeatureExtractionPipeline,pe as FeatureExtractor,dl as FillMaskPipeline,O_ as Florence2ForConditionalGeneration,ni as Florence2PreTrainedModel,Zu as Florence2Processor,za as ForcedBOSTokenLogitsProcessor,Ta as ForcedEOSTokenLogitsProcessor,vu as GLPNFeatureExtractor,F_ as GLPNForDepthEstimation,R_ as GLPNModel,cn as GLPNPreTrainedModel,X_ as GPT2LMHeadModel,H_ as GPT2Model,fn as GPT2PreTrainedModel,Ec as GPT2Tokenizer,j_ as GPTBigCodeForCausalLM,D_ as GPTBigCodeModel,un as GPTBigCodePreTrainedModel,Q_ as GPTJForCausalLM,K_ as GPTJModel,mn as GPTJPreTrainedModel,U_ as GPTNeoForCausalLM,B_ as GPTNeoModel,pn as GPTNeoPreTrainedModel,G_ as GPTNeoXForCausalLM,q_ as GPTNeoXModel,dn as GPTNeoXPreTrainedModel,vc as GPTNeoXTokenizer,P_ as Gemma2ForCausalLM,T_ as Gemma2Model,nn as Gemma2PreTrainedModel,N_ as Gemma3ForCausalLM,C_ as Gemma3Model,on as Gemma3PreTrainedModel,eu as Gemma3nAudioFeatureExtractor,an as Gemma3nForConditionalGeneration,oi as Gemma3nPreTrainedModel,ep as Gemma3nProcessor,z_ as GemmaForCausalLM,I_ as GemmaModel,rn as GemmaPreTrainedModel,kc as GemmaTokenizer,$_ as GlmForCausalLM,L_ as GlmModel,ln as GlmPreTrainedModel,V_ as GptOssForCausalLM,W_ as GptOssModel,_n as GptOssPreTrainedModel,Y_ as GraniteForCausalLM,J_ as GraniteModel,ef as GraniteMoeHybridForCausalLM,Z_ as GraniteMoeHybridModel,xn as GraniteMoeHybridPreTrainedModel,hn as GranitePreTrainedModel,tf as GroundingDinoForObjectDetection,Eu as GroundingDinoImageProcessor,ai as GroundingDinoPreTrainedModel,tp as GroundingDinoProcessor,sf as GroupViTModel,ii as GroupViTPreTrainedModel,nf as HeliumForCausalLM,rf as HeliumModel,gn as HeliumPreTrainedModel,Ac as HerbertTokenizer,af as HieraForImageClassification,of as HieraModel,wn as HieraPreTrainedModel,ff as HubertForCTC,mf as HubertForSequenceClassification,_f as HubertModel,df as HubertPreTrainedModel,xf as HunYuanDenseV1ForCausalLM,hf as HunYuanDenseV1Model,yn as HunYuanDenseV1PreTrainedModel,yf as IJepaForImageClassification,wf as IJepaModel,bn as IJepaPreTrainedModel,ci as Idefics3ForConditionalGeneration,_a as Idefics3ImageProcessor,li as Idefics3PreTrainedModel,va as Idefics3Processor,kl as ImageClassificationPipeline,Tl as ImageFeatureExtractionPipeline,P as ImageFeatureExtractor,P as ImageProcessor,er as ImageSegmentationPipeline,Ol as ImageToImagePipeline,bl as ImageToTextPipeline,ny as InterruptableStoppingCriteria,kf as JAISLMHeadModel,bf as JAISModel,kn as JAISPreTrainedModel,Mu as JinaCLIPImageProcessor,vf as JinaCLIPModel,Fs as JinaCLIPPreTrainedModel,rp as JinaCLIPProcessor,vn as JinaCLIPTextModel,Ef as JinaCLIPVisionModel,Mf as Lfm2ForCausalLM,Af as Lfm2Model,Of as Lfm2MoeForCausalLM,Sf as Lfm2MoeModel,An as Lfm2MoePreTrainedModel,En as Lfm2PreTrainedModel,tg as LiteWhisperForConditionalGeneration,Tf as Llama4ForCausalLM,ui as Llama4PreTrainedModel,zf as LlamaForCausalLM,If as LlamaModel,Mn as LlamaPreTrainedModel,Mc as LlamaTokenizer,Ds as LlavaForConditionalGeneration,Ds as LlavaOnevisionForConditionalGeneration,Su as LlavaOnevisionImageProcessor,pi as LlavaPreTrainedModel,np as LlavaProcessor,Cf as LlavaQwen2ForCausalLM,Qe as LogitsProcessor,Zt as LogitsProcessorList,vr as LogitsWarper,Lf as LongT5ForConditionalGeneration,Nf as LongT5Model,Sn as LongT5PreTrainedModel,Rf as M2M100ForConditionalGeneration,$f as M2M100Model,On as M2M100PreTrainedModel,Sc as M2M100Tokenizer,Ic as MBart50Tokenizer,Wf as MBartForCausalLM,qf as MBartForConditionalGeneration,Gf as MBartForSequenceClassification,Uf as MBartModel,os as MBartPreTrainedModel,_r as MBartTokenizer,Im as MPNetForMaskedLM,Pm as MPNetForQuestionAnswering,zm as MPNetForSequenceClassification,Tm as MPNetForTokenClassification,Om as MPNetModel,Lt as MPNetPreTrainedModel,Pc as MPNetTokenizer,$m as MT5ForConditionalGeneration,Lm as MT5Model,jn as MT5PreTrainedModel,Df as MarianMTModel,Ff as MarianModel,In as MarianPreTrainedModel,Oc as MarianTokenizer,Iu as Mask2FormerImageProcessor,Ou as MaskFormerFeatureExtractor,Bf as MaskFormerForInstanceSegmentation,Es as MaskFormerImageProcessor,jf as MaskFormerModel,zn as MaskFormerPreTrainedModel,Ba as MaxLengthCriteria,Vf as Metric3DForDepthEstimation,di as Metric3DPreTrainedModel,Hf as Metric3Dv2ForDepthEstimation,_i as Metric3Dv2PreTrainedModel,Xf as MgpstrForSceneTextRecognition,fi as MgpstrModelOutput,mi as MgpstrPreTrainedModel,op as MgpstrProcessor,zc as MgpstrTokenizer,Pn as MimiDecoderModel,xi as MimiDecoderOutput,Tn as MimiEncoderModel,hi as MimiEncoderOutput,Kf as MimiModel,js as MimiPreTrainedModel,La as MinLengthLogitsProcessor,$a as MinNewTokensLengthLogitsProcessor,Jf as MistralForCausalLM,Qf as MistralModel,Cn as MistralPreTrainedModel,Zf as MobileBertForMaskedLM,tm as MobileBertForQuestionAnswering,em as MobileBertForSequenceClassification,Yf as MobileBertModel,as as MobileBertPreTrainedModel,Tc as MobileBertTokenizer,rm as MobileLLMForCausalLM,sm as MobileLLMModel,Nn as MobileLLMPreTrainedModel,zu as MobileNetV1FeatureExtractor,om as MobileNetV1ForImageClassification,am as MobileNetV1ForSemanticSegmentation,fa as MobileNetV1ImageProcessor,nm as MobileNetV1Model,Bs as MobileNetV1PreTrainedModel,Tu as MobileNetV2FeatureExtractor,lm as MobileNetV2ForImageClassification,cm as MobileNetV2ForSemanticSegmentation,ma as MobileNetV2ImageProcessor,im as MobileNetV2Model,Us as MobileNetV2PreTrainedModel,Pu as MobileNetV3FeatureExtractor,pm as MobileNetV3ForImageClassification,dm as MobileNetV3ForSemanticSegmentation,ha as MobileNetV3ImageProcessor,um as MobileNetV3Model,qs as MobileNetV3PreTrainedModel,Cu as MobileNetV4FeatureExtractor,fm as MobileNetV4ForImageClassification,mm as MobileNetV4ForSemanticSegmentation,xa as MobileNetV4ImageProcessor,_m as MobileNetV4Model,Gs as MobileNetV4PreTrainedModel,Nu as MobileViTFeatureExtractor,xm as MobileViTForImageClassification,ga as MobileViTImageProcessor,hm as MobileViTModel,Ln as MobileViTPreTrainedModel,wm as MobileViTV2ForImageClassification,gm as MobileViTV2Model,$n as MobileViTV2PreTrainedModel,Am as ModernBertDecoderForCausalLM,Em as ModernBertDecoderModel,Rn as ModernBertDecoderPreTrainedModel,bm as ModernBertForMaskedLM,km as ModernBertForSequenceClassification,vm as ModernBertForTokenClassification,ym as ModernBertModel,is as ModernBertPreTrainedModel,Pf as Moondream1ForConditionalGeneration,tu as MoonshineFeatureExtractor,Sm as MoonshineForConditionalGeneration,Mm as MoonshineModel,Fn as MoonshinePreTrainedModel,ap as MoonshineProcessor,Nm as MptForCausalLM,Cm as MptModel,Dn as MptPreTrainedModel,Rm as MultiModalityCausalLM,gi as MultiModalityPreTrainedModel,Dm as MusicgenForCausalLM,Un as MusicgenForConditionalGeneration,Fm as MusicgenModel,Bn as MusicgenPreTrainedModel,Bm as NanoChatForCausalLM,jm as NanoChatModel,qn as NanoChatPreTrainedModel,qm as NeoBertForMaskedLM,Vm as NeoBertForQuestionAnswering,Gm as NeoBertForSequenceClassification,Wm as NeoBertForTokenClassification,Um as NeoBertModel,$t as NeoBertPreTrainedModel,Cc as NllbTokenizer,Ra as NoBadWordsLogitsProcessor,Ca as NoRepeatNGramLogitsProcessor,Hm as NomicBertModel,wi as NomicBertPreTrainedModel,Lu as NougatImageProcessor,Nc as NougatTokenizer,rh as OPTForCausalLM,sh as OPTModel,Xn as OPTPreTrainedModel,Al as ObjectDetectionPipeline,Jm as Olmo2ForCausalLM,Qm as Olmo2Model,Wn as Olmo2PreTrainedModel,Zm as Olmo3ForCausalLM,Ym as Olmo3Model,Vn as Olmo3PreTrainedModel,Km as OlmoForCausalLM,Xm as OlmoModel,Gn as OlmoPreTrainedModel,th as OpenELMForCausalLM,eh as OpenELMModel,Hn as OpenELMPreTrainedModel,$u as OwlViTFeatureExtractor,ih as OwlViTForObjectDetection,As as OwlViTImageProcessor,ah as OwlViTModel,Qn as OwlViTPreTrainedModel,ip as OwlViTProcessor,oh as Owlv2ForObjectDetection,Ru as Owlv2ImageProcessor,nh as Owlv2Model,Kn as Owlv2PreTrainedModel,lh as PaliGemmaForConditionalGeneration,yi as PaliGemmaPreTrainedModel,lp as PaliGemmaProcessor,su as ParakeetFeatureExtractor,ch as ParakeetForCTC,bi as ParakeetPreTrainedModel,ph as PatchTSMixerForPrediction,uh as PatchTSMixerModel,Jn as PatchTSMixerPreTrainedModel,_h as PatchTSTForPrediction,dh as PatchTSTModel,Yn as PatchTSTPreTrainedModel,xh as Phi3ForCausalLM,hh as Phi3Model,eo as Phi3PreTrainedModel,to as Phi3VForCausalLM,ju as Phi3VImageProcessor,ki as Phi3VPreTrainedModel,cp as Phi3VProcessor,mh as PhiForCausalLM,fh as PhiModel,Zn as PhiPreTrainedModel,Bu as PixtralImageProcessor,up as PixtralProcessor,f as PreTrainedModel,T as PreTrainedTokenizer,Sa as PretrainedConfig,j as Processor,wh as PvtForImageClassification,Uu as PvtImageProcessor,gh as PvtModel,so as PvtPreTrainedModel,wr as PyAnnoteFeatureExtractor,bh as PyAnnoteForAudioFrameClassification,yh as PyAnnoteModel,ro as PyAnnotePreTrainedModel,pp as PyAnnoteProcessor,pl as QuestionAnsweringPipeline,vh as Qwen2ForCausalLM,kh as Qwen2Model,no as Qwen2PreTrainedModel,Lc as Qwen2Tokenizer,Eh as Qwen2VLForConditionalGeneration,qu as Qwen2VLImageProcessor,vi as Qwen2VLPreTrainedModel,dp as Qwen2VLProcessor,Mh as Qwen3ForCausalLM,Ah as Qwen3Model,oo as Qwen3PreTrainedModel,zh as RFDetrForObjectDetection,Ih as RFDetrModel,Ei as RFDetrObjectDetectionOutput,io as RFDetrPreTrainedModel,Ad as RTDetrForObjectDetection,Gu as RTDetrImageProcessor,Ed as RTDetrModel,mt as RTDetrObjectDetectionOutput,qr as RTDetrPreTrainedModel,Uh as RTDetrV2ForObjectDetection,Bh as RTDetrV2Model,Ai as RTDetrV2ObjectDetectionOutput,lo as RTDetrV2PreTrainedModel,hr as RawAudio,we as RawImage,Pl as RawVideo,No as RawVideoFrame,Na as RepetitionPenaltyLogitsProcessor,Oh as ResNetForImageClassification,Sh as ResNetModel,ao as ResNetPreTrainedModel,Rh as RoFormerForMaskedLM,jh as RoFormerForQuestionAnswering,Fh as RoFormerForSequenceClassification,Dh as RoFormerForTokenClassification,$h as RoFormerModel,Ft as RoFormerPreTrainedModel,Rc as RoFormerTokenizer,Ph as RobertaForMaskedLM,Lh as RobertaForQuestionAnswering,Ch as RobertaForSequenceClassification,Nh as RobertaForTokenClassification,Th as RobertaModel,Rt as RobertaPreTrainedModel,$c as RobertaTokenizer,br as Sam2ImageProcessor,Oi as Sam2ImageSegmentationOutput,co as Sam2Model,Ii as Sam2PreTrainedModel,Ea as Sam2Processor,_p as Sam2VideoProcessor,br as Sam3ImageProcessor,Wh as Sam3TrackerModel,br as SamImageProcessor,Mi as SamImageSegmentationOutput,qh as SamModel,Si as SamPreTrainedModel,kr as SamProcessor,Wu as SapiensFeatureExtractor,Hh as SapiensForDepthEstimation,Xh as SapiensForNormalEstimation,Vh as SapiensForSemanticSegmentation,wa as SapiensImageProcessor,Ws as SapiensPreTrainedModel,ru as SeamlessM4TFeatureExtractor,Vu as SegformerFeatureExtractor,Qh as SegformerForImageClassification,Jh as SegformerForSemanticSegmentation,ya as SegformerImageProcessor,Kh as SegformerModel,Vs as SegformerPreTrainedModel,Hu as SiglipImageProcessor,Yh as SiglipModel,uo as SiglipPreTrainedModel,po as SiglipTextModel,Fc as SiglipTokenizer,Zh as SiglipVisionModel,tx as SmolLM3ForCausalLM,ex as SmolLM3Model,_o as SmolLM3PreTrainedModel,gf as SmolVLMForConditionalGeneration,_a as SmolVLMImageProcessor,va as SmolVLMProcessor,mo as SnacDecoderModel,fo as SnacEncoderModel,nu as SnacFeatureExtractor,sx as SnacModel,Hs as SnacPreTrainedModel,ou as SpeechT5FeatureExtractor,nx as SpeechT5ForSpeechToText,ox as SpeechT5ForTextToSpeech,ax as SpeechT5HifiGan,rx as SpeechT5Model,Xs as SpeechT5PreTrainedModel,fp as SpeechT5Processor,Dc as SpeechT5Tokenizer,lx as SqueezeBertForMaskedLM,ux as SqueezeBertForQuestionAnswering,cx as SqueezeBertForSequenceClassification,ix as SqueezeBertModel,ls as SqueezeBertPreTrainedModel,jc as SqueezeBertTokenizer,dx as StableLmForCausalLM,px as StableLmModel,ho as StableLmPreTrainedModel,fx as Starcoder2ForCausalLM,_x as Starcoder2Model,xo as Starcoder2PreTrainedModel,Ps as StoppingCriteria,ja as StoppingCriteriaList,mx as StyleTextToSpeech2Model,zi as StyleTextToSpeech2PreTrainedModel,_l as SummarizationPipeline,go as SupertonicForConditionalGeneration,Ti as SupertonicPreTrainedModel,zs as SuppressTokensAtBeginLogitsProcessor,yx as Swin2SRForImageSuperResolution,Xu as Swin2SRImageProcessor,wx as Swin2SRModel,wo as Swin2SRPreTrainedModel,xx as SwinForImageClassification,gx as SwinForSemanticSegmentation,hx as SwinModel,Ks as SwinPreTrainedModel,kx as T5ForConditionalGeneration,bx as T5Model,yo as T5PreTrainedModel,Bc as T5Tokenizer,Ex as TableTransformerForObjectDetection,vx as TableTransformerModel,Pi as TableTransformerObjectDetectionOutput,bo as TableTransformerPreTrainedModel,Da as TemperatureLogitsWarper,S as Tensor,qt as Text2TextGenerationPipeline,cl as TextClassificationPipeline,ml as TextGenerationPipeline,wg as TextStreamer,yl as TextToAudioPipeline,ul as TokenClassificationPipeline,T as TokenizersBackend,ry as TopKLogitsWarper,sy as TopPLogitsWarper,Ax as TrOCRForCausalLM,Ci as TrOCRPreTrainedModel,fl as TranslationPipeline,Li as UltravoxModel,Ni as UltravoxPreTrainedModel,mp as UltravoxProcessor,Ox as UniSpeechForCTC,Ix as UniSpeechForSequenceClassification,Sx as UniSpeechModel,Qs as UniSpeechPreTrainedModel,Cx as UniSpeechSatForAudioFrameClassification,Tx as UniSpeechSatForCTC,Px as UniSpeechSatForSequenceClassification,zx as UniSpeechSatModel,cs as UniSpeechSatPreTrainedModel,sp as VLChatProcessor,Au as VLMImageProcessor,Lx as VaultGemmaForCausalLM,Nx as VaultGemmaModel,ko as VaultGemmaPreTrainedModel,Ku as ViTFeatureExtractor,Fx as ViTForImageClassification,ba as ViTImageProcessor,Dx as ViTMAEModel,$i as ViTMAEPreTrainedModel,Bx as ViTMSNForImageClassification,jx as ViTMSNModel,Eo as ViTMSNPreTrainedModel,Rx as ViTModel,vo as ViTPreTrainedModel,$x as VisionEncoderDecoderModel,Ux as VitMatteForImageMatting,Qu as VitMatteImageProcessor,Ri as VitMattePreTrainedModel,qx as VitPoseForPoseEstimation,Ju as VitPoseImageProcessor,Fi as VitPosePreTrainedModel,Gx as VitsModel,Di as VitsModelOutput,ji as VitsPreTrainedModel,qc as VitsTokenizer,Mx as VoxtralForConditionalGeneration,hp as VoxtralProcessor,Vx as Wav2Vec2BertForCTC,Hx as Wav2Vec2BertForSequenceClassification,Wx as Wav2Vec2BertModel,Js as Wav2Vec2BertPreTrainedModel,Gc as Wav2Vec2CTCTokenizer,au as Wav2Vec2FeatureExtractor,pf as Wav2Vec2ForAudioFrameClassification,cf as Wav2Vec2ForCTC,uf as Wav2Vec2ForSequenceClassification,lf as Wav2Vec2Model,it as Wav2Vec2PreTrainedModel,xp as Wav2Vec2Processor,gp as Wav2Vec2ProcessorWithLM,Yx as WavLMForAudioFrameClassification,Kx as WavLMForCTC,Qx as WavLMForSequenceClassification,Jx as WavLMForXVector,Xx as WavLMModel,Dt as WavLMPreTrainedModel,iu as WeSpeakerFeatureExtractor,Zx as WeSpeakerResNetModel,Ui as WeSpeakerResNetPreTrainedModel,lu as WhisperFeatureExtractor,Gi as WhisperForConditionalGeneration,eg as WhisperModel,Ao as WhisperPreTrainedModel,wp as WhisperProcessor,Qy as WhisperTextStreamer,Pa as WhisperTimeStampLogitsProcessor,Wc as WhisperTokenizer,ag as XLMForQuestionAnswering,ng as XLMForSequenceClassification,og as XLMForTokenClassification,sg as XLMModel,jt as XLMPreTrainedModel,lg as XLMRobertaForMaskedLM,pg as XLMRobertaForQuestionAnswering,cg as XLMRobertaForSequenceClassification,ug as XLMRobertaForTokenClassification,ig as XLMRobertaModel,Bt as XLMRobertaPreTrainedModel,Vc as XLMRobertaTokenizer,Hc as XLMTokenizer,rg as XLMWithLMHeadModel,Bi as XVectorOutput,Yu as YolosFeatureExtractor,_g as YolosForObjectDetection,ka as YolosImageProcessor,dg as YolosModel,Wi as YolosObjectDetectionOutput,Mo as YolosPreTrainedModel,mg as YoutuForCausalLM,fg as YoutuModel,So as YoutuPreTrainedModel,gl as ZeroShotAudioClassificationPipeline,hl as ZeroShotClassificationPipeline,El as ZeroShotImageClassificationPipeline,Ml as ZeroShotObjectDetectionPipeline,ne as cat,gk as cos_sim,fw as dot,_e as env,xe as full,dr as full_like,Jl as interpolate,Xe as interpolate_4d,OM as layer_norm,Zk as load_image,Nv as load_video,ql as log_softmax,Nw as matmul,ea as mean,Lw as mean_pooling,Oe as ones,ta as ones_like,Tk as permute,r9 as pipeline,Rw as quantize_embeddings,IM as rand,$w as randn,Qc as read_audio,SM as rfft,Zo as slice,ce as softmax,Ke as stack,Yl as std_mean,ot as topk,ec as zeros,tc as zeros_like};
18
+ `,this.image_token_id=l,this.boi_token=c,this.image_token=p;let d=p.repeat(this.image_seq_length);this.full_image_sequence=`
19
+
20
+ ${c}${d}${u}
21
+
22
+ `}async _call(e,s=null,r=null,n={}){typeof e=="string"&&(e=[e]);let o;r&&(o=await this.feature_extractor(r,n),e=e.map(l=>l.replaceAll(this.audio_token,this.full_audio_sequence)));let i;return s&&(i=await this.image_processor(s,n),e=e.map(l=>l.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,n),...i,...o}}};var ns=class extends B{static image_processor_class=le;static tokenizer_class=G;static image_token="<|image_pad|>";async _call(e,s=null,...r){Array.isArray(e)||(e=[e]);let n,o;if(s&&(n=await this.image_processor(s),o=n.image_grid_thw),o){let a=this.image_processor.config.merge_size**2,l=0,c=this.constructor.image_token,p=o.tolist();e=e.map(u=>{for(;u.includes(c);){let _=Number(p[l++].reduce((d,m)=>d*m,1n));u=u.replace(c,"<|placeholder|>".repeat(Math.floor(_/a)))}return u.replaceAll("<|placeholder|>",c)})}return{...this.tokenizer(e),...n}}};var n_=class extends ns{static image_token="<|image|>"};var o_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;static uses_processor_config=!0;_get_num_audio_features(e){let{hop_length:s}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:r,projector_downsample_rate:n}=this.feature_extractor.config,o=Math.floor(r/n),i=Math.floor(e/s)+1,a=Math.floor(i/2);return Math.ceil(a/r)*o}async _call(e,s=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(s){let{input_features:i}=await this.feature_extractor(s);n.input_features=i;let a=this._get_num_audio_features(s.length),l=new Uint8Array(a).fill(1);n.input_features_mask=new E("bool",l,[1,a]);let c=this.config.audio_token??"<|audio|>";if(!e.includes(c))throw new Error(`The input text does not contain the audio token ${c}.`);e=e.replaceAll(c,c.repeat(a))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};function OA(t,e){let r=t.dims.at(-1)-1,n=t.tolist();n.fill(!1,0,1),n.fill(!1,r);let o=e.tolist();return n.map((i,a)=>i?a:null).filter(i=>i!==null).map(i=>o[i])}var i_=class extends B{static tokenizer_class=G;static image_processor_class=le;async _call(e,s,r={}){let n=e?await this.image_processor(e,r):{};return{...s?this.tokenizer(s,r):{},...n}}post_process_grounded_object_detection(e,s,{box_threshold:r=.25,text_threshold:n=.25,target_sizes:o=null}={}){let{logits:i,pred_boxes:a}=e,l=i.dims[0];if(o!==null&&o.length!==l)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=i.dims.at(1),p=i.sigmoid(),u=p.max(-1).tolist(),_=a.tolist().map(m=>m.map(h=>pu(h))),d=[];for(let m=0;m<l;++m){let h=o!==null?o[m]:null;h!==null&&(_[m]=_[m].map(b=>b.map((v,k)=>v*h[(k+1)%2])));let g=u[m],x=[],w=[],y=[];for(let b=0;b<c;++b){let v=g[b];if(v<=r)continue;let k=_[m][b],O=p[m][b];x.push(v),y.push(k);let N=OA(O.gt(n),s[m]);w.push(N)}d.push({scores:x,boxes:y,labels:this.batch_decode(w)})}return d}};function zA(t,e,s,r,n,o){let i="";for(let a=0;a<e;++a){for(let l=0;l<s;++l)i+=r+`<row_${a+1}_col_${l+1}>`+n.repeat(t);i+=`
23
+ `}return i+=`
24
+ ${r}${o}`+n.repeat(t)+`${r}`,i}function IA(t,e,s,r){return`${e}${r}`+s.repeat(t)+`${e}`}function TA(t,e,s,r,n,o){return t===0&&e===0?IA(s,r,n,o):zA(s,t,e,r,n,o)}var Ta=class extends B{static image_processor_class=le;static tokenizer_class=G;static uses_processor_config=!0;fake_image_token="<fake_token_around_image>";image_token="<image>";global_img_token="<global-img>";async _call(e,s=null,r={}){r.return_row_col_info??=!0;let n;s&&(n=await this.image_processor(s,r)),Array.isArray(e)||(e=[e]);let o=n.rows??[new Array(e.length).fill(0)],i=n.cols??[new Array(e.length).fill(0)],a=this.config.image_seq_len,l=[],c=[];for(let u=0;u<e.length;++u){let _=e[u],d=o[u],m=i[u];l.push(Iy(_,this.image_token));let h=d.map((w,y)=>TA(w,m[y],a,this.fake_image_token,this.image_token,this.global_img_token)),g=_.split(this.image_token);if(g.length===0)throw new Error("The image token should be present in the text.");let x=g[0];for(let w=0;w<h.length;++w)x+=h[w]+g[w+1];c.push(x)}return{...this.tokenizer(c),...n}}};var a_=class extends B{static image_processor_class=le;static tokenizer_class=G;static uses_processor_config=!0;constructor(e,s,r){super(e,s,r),this.image_tag=this.config.image_tag,this.image_start_tag=this.config.image_start_tag,this.image_end_tag=this.config.image_end_tag,this.num_image_tokens=this.config.num_image_tokens}async _call(e,{images:s=null,chat_template:r="default"}={}){s?Array.isArray(s)||(s=[s]):s=await Promise.all(e.filter(g=>g.images).flatMap(g=>g.images).map(g=>ve.read(g)));let n=this.tokenizer,o=n.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:r}),i=g=>n.encode(g,{add_special_tokens:!1}),a=o.split(this.image_tag),l=a.length-1;if(s.length!==l)throw new Error(`Number of images provided (${s.length}) does not match number of "${this.image_tag}" image tags (${l})`);let[c,p,u]=n.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),_=i(a[0]),d=new Array(_.length).fill(!1);for(let g=1;g<a.length;++g){let x=new Array(this.num_image_tokens).fill(c),w=i(a[g]);_=$e(_,[p],x,[u],w);let y=new Array(this.num_image_tokens).fill(!0);d=$e(d,[!1],y,[!1],new Array(w.length).fill(!1))}let m=[1,_.length],h={input_ids:new E("int64",_,m),attention_mask:new E("int64",new Array(_.length).fill(1),m),images_seq_mask:new E("bool",d,m),images_emb_mask:new E("bool",new Array(l*this.num_image_tokens).fill(!0),[1,l,this.num_image_tokens])};if(s&&s.length>0){let g=await this.image_processor(s);return g.pixel_values.unsqueeze_(0),{...h,...g}}return h}};var l_=class extends B{static tokenizer_class=G;static image_processor_class=le;async _call(e=null,s=null,r={}){if(!e&&!s)throw new Error("Either text or images must be provided");let n=e?this.tokenizer(e,r):{},o=s?await this.image_processor(s,r):{};return{...n,...o}}};var c_=class extends B{static tokenizer_class=G;static image_processor_class=le;async _call(e,s=null,r={}){let{image_rows:n,image_cols:o,image_sizes:i,...a}=await this.image_processor(e,{...r,return_row_col_info:!0});if(s){let l=this.config.image_token??"<image>",{tile_size:c=512,downsample_factor:p=2,encoder_patch_size:u=16,use_thumbnail:_=!0}=this.image_processor.config,d=y=>Math.ceil(Math.floor(y/u)/p),m=d(c)**2,h=this.config.image_start_token??"<|image_start|>",g=this.config.image_end_token??"<|image_end|>",x=this.config.image_thumbnail??"<|img_thumbnail|>";Array.isArray(s)||(s=[s]);let w=0;s=s.map(y=>{let b=y.split(l);return b[0]+b.slice(1).map(v=>{let k=w++,[O,N]=i[k],q=n[k],P=o[k],R=d(O)*d(N),F=h;if(q>1||P>1){let U=l.repeat(m);for(let j=0;j<q;++j)for(let W=0;W<P;++W)F+=`<|img_row_${j+1}_col_${W+1}|>`+U;_&&(F+=x+l.repeat(R))}else F+=l.repeat(R);return F+g+v}).join("")})}return{...a,...s?this.tokenizer(s,r):{}}}};var p_=class extends B{static tokenizer_class=G;static image_processor_class=le;static uses_processor_config=!0;async _call(e,s=null,r={}){let n=await this.image_processor(e,r);if(s){let[i,a]=n.pixel_values.dims.slice(-2),{image_token:l,patch_size:c,num_additional_image_tokens:p}=this.config,u=Math.floor(i/c)*Math.floor(a/c)+p;s=structuredClone(s),Array.isArray(s)||(s=[s]);for(let _=0;_<s.length;++_)s[_]=s[_].replace(l,l.repeat(u))}let o=s?this.tokenizer(s,r):{};return{...n,...o}}};var nb={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},u_=class extends B{static tokenizer_class=G;static image_processor_class=le;get char_tokenizer(){return this.components.char_tokenizer}get bpe_tokenizer(){return this.components.bpe_tokenizer}get wp_tokenizer(){return this.components.wp_tokenizer}_decode_helper(e,s){if(!nb.hasOwnProperty(s))throw new Error(`Format ${s} is not supported.`);let[r,n]=nb[s],o=this[r].bind(this),[i,a]=e.dims,l=[],c=[],p=e.tolist();for(let _=0;_<i;++_){let d=p[_],m=[],h=[];for(let x=1;x<a;++x){let[w,y]=ue(fe(d[x]));if(h.push(w),y==n)break;m.push(y)}let g=h.length>0?h.reduce((x,w)=>x*w,1):0;c.push(m),l.push(g)}return[o(c),l]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(s=>s.replaceAll(" ",""))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(s=>s.replaceAll(" ",""))}batch_decode([e,s,r]){let[n,o]=this._decode_helper(e,"char"),[i,a]=this._decode_helper(s,"bpe"),[l,c]=this._decode_helper(r,"wp"),p=[],u=[];for(let _=0;_<n.length;++_){let[d,m]=ue([o[_],a[_],c[_]]);p.push([n[_],i[_],l[_]][m]),u.push(d)}return{generated_text:p,scores:u,char_preds:n,bpe_preds:i,wp_preds:l}}static async from_pretrained(...e){let s=await super.from_pretrained(...e),r=await G.from_pretrained("Xenova/gpt2"),n=await G.from_pretrained("Xenova/bert-base-uncased");return s.components={image_processor:s.image_processor,char_tokenizer:s.tokenizer,bpe_tokenizer:r,wp_tokenizer:n},s}async _call(e,s=null){let r=await this.image_processor(e);return s&&(r.labels=this.tokenizer(s).input_ids),r}};var __=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e){return await this.feature_extractor(e)}};var d_=class extends B{static tokenizer_class=G;static image_processor_class=le};var js="<image>";function CA(t,e,s,r,n){return`${r.repeat(s*n)}${e}${t}
25
+ `}var f_=class extends B{static tokenizer_class=G;static image_processor_class=le;static uses_processor_config=!1;async _call(e,s=null,r={}){s||($.warn("You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."),s=""),Array.isArray(e)||(e=[e]),Array.isArray(s)||(s=[s]);let n=this.tokenizer.bos_token,o=this.image_processor.config.image_seq_length,i;s.some(c=>c.includes(js))?i=s.map(c=>{let p=c.replaceAll(js,js.repeat(o)),u=p.lastIndexOf(js),_=u===-1?0:u+js.length;return p.slice(0,_)+n+p.slice(_)+`
26
+ `}):($.warn("You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special image tokens in the text, as many tokens as there are images per each text. It is recommended to add `<image>` tokens in the very beginning of your text. For this call, we will infer how many images each text has and add special tokens."),i=s.map(c=>CA(c,n,o,js,e.length)));let a=this.tokenizer(i,r);return{...await this.image_processor(e,r),...a}}};var ob="<|image|>",PA=/<\|image_\d+\|>/g,m_=class extends B{static image_processor_class=le;static tokenizer_class=G;async _call(e,s=null,{padding:r=!0,truncation:n=!0,num_crops:o=null}={}){Array.isArray(e)||(e=[e]);let i,a;if(s){a=await this.image_processor(s,{num_crops:o});let{num_img_tokens:l}=a,c=e.map((u,_)=>u.split(PA).join(ob.repeat(l[_])));i=this.tokenizer(c,{padding:r,truncation:n});let p=this.tokenizer._tokenizer.token_to_id(ob);i.input_ids.map_(u=>u==p?-u:u)}else i=this.tokenizer(e);return{...i,...a}}};var h_=class extends B{static tokenizer_class=G;static image_processor_class=le;static uses_processor_config=!0;async _call(e,s=null,r={}){let n=await this.image_processor(e,r);if(s){let[i,a]=n.pixel_values.dims.slice(-2),{image_token:l,image_break_token:c,image_end_token:p,patch_size:u,spatial_merge_size:_}=this.config,d=u*_,m=Math.floor(i/d),h=Math.floor(a/d);s=structuredClone(s),Array.isArray(s)||(s=[s]);for(let g=0;g<s.length;++g){let x=l.repeat(h),w=x+c,y=x+p,b=w.repeat(m-1)+y;s[g]=s[g].replace(l,b)}}let o=s?this.tokenizer(s,r):{};return{...n,...o}}};var g_=class extends B{static feature_extractor_class=Br;async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}get sampling_rate(){return this.feature_extractor.config.sampling_rate}};var Wr=class extends ns{};var x_=class extends Wr{};var Vr=class extends B{static image_processor_class=le;async _call(...e){return await this.image_processor(...e)}post_process_masks(...e){return this.image_processor.post_process_masks(...e)}reshape_input_points(...e){return this.image_processor.reshape_input_points(...e)}};var Ca=class extends Vr{},w_=class extends Ca{};var y_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e){return await this.feature_extractor(e)}};var b_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;static uses_processor_config=!0;async _call(e,s=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(s){let i=s.length,{input_features:a}=await this.feature_extractor(s,{...r,max_length:i}),l=Math.round(i/this.config.encoder_ds_factor+1e-4),c=1+Math.ceil(l/this.config.stack_factor);n.audio_token_len=[c],n.audio_values=a;let p=this.config.audio_placeholder;if(!e.includes(p))throw new Error(`The input text does not contain the image token ${p}.`);e=e.replaceAll(p,p.repeat(c))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};var Pa="[AUDIO]",NA="[BEGIN_AUDIO]",LA=375;function $A(t,e){let s=[];for(let r=0;r<t.length;r+=e)s.push(t.subarray(r,Math.min(r+e,t.length)));return s}var k_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;static uses_processor_config=!1;async _call(e,s=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(s){if(!e.includes(Pa))throw new Error(`The input text does not contain the audio token ${Pa}.`);Array.isArray(s)||(s=[s]);let i=e.split(Pa),a=i.length-1;if(a!==s.length)throw new Error(`The number of audio inputs (${s.length}) does not match the number of audio tokens in the text (${a}).`);let l=this.feature_extractor.config.n_samples,c=s.map(m=>$A(m,l)),p=c.map(m=>m.length),u=c.flat(),_=(await Promise.all(u.map(m=>this.feature_extractor(m,r)))).map(m=>m.input_features);n.audio_values=_.length>1?oe(_,0):_[0];let d=i[0];for(let m=0;m<p.length;++m){d+=NA;for(let h=0;h<p[m];++h)d+=Pa.repeat(LA);d+=i[m+1]}e=d}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};var ib=32,v_=6,Na=8,FA=10,RA=32,E_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(v_+1)*Na}get num_samples_first_audio_chunk(){let{hop_length:e,n_fft:s}=this.feature_extractor.config;return(this.num_mel_frames_first_audio_chunk-1)*e+Math.floor(s/2)}get num_samples_per_audio_chunk(){let{hop_length:e,n_fft:s}=this.feature_extractor.config;return Na*e+s}get num_right_pad_tokens(){return v_+1+FA}get audio_length_per_tok(){return Na}get raw_audio_length_per_tok(){return Na*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:s=!1,is_first_audio_chunk:r=!0}={}){if(_e(e,"VoxtralRealtimeProcessor"),!s&&!r)throw new Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(r)if(s){let n=ib*this.raw_audio_length_per_tok,o=new Float32Array(n+e.length);o.set(e,n);let i=await this.feature_extractor(o,{center:!0}),l=1+(ib+v_),c=new BigInt64Array(l).fill(BigInt(RA));return c[0]=1n,{input_ids:new E("int64",c,[1,l]),...i}}else{let n=this.num_right_pad_tokens*this.raw_audio_length_per_tok,o=new Float32Array(e.length+n);return o.set(e),await this.feature_extractor(o,{center:!0})}else return await this.feature_extractor(e,{center:!1})}};var A_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e){return await this.feature_extractor(e)}};var M_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e){return await this.feature_extractor(e)}};var S_=class extends B{static tokenizer_class=G;static feature_extractor_class=ge;async _call(e){return await this.feature_extractor(e)}};var $a=class{static async from_pretrained(e,s={}){let r=await Ce(e,yt,!0,s),{image_processor_type:n,feature_extractor_type:o,processor_class:i}=r;if(i&&La[i])return La[i].from_pretrained(e,s);if(!n&&!o)throw new Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let a={};if(n){let c=Ds[n.replace(/Fast$/,"")];if(!c)throw new Error(`Unknown image_processor_type: '${n}'.`);a.image_processor=new c(r)}if(o){let c=Ds[o];if(c)a.image_processor=new c(r);else{let p=qr[o];if(!p)throw new Error(`Unknown feature_extractor_type: '${o}'.`);a.feature_extractor=new p(r)}}let l={};return new B(l,a,null)}};async function DA(t,e){return await Ce(t,"config.json",!0,e)}function Bs(t){let e={},s={};switch(t.model_type){case"llava":case"paligemma":case"gemma3":case"florence2":case"llava_onevision":case"idefics3":case"granite_speech":case"ultravox":case"voxtral":case"voxtral_realtime":case"smolvlm":case"gemma3n":case"lfm2_vl":case"chatterbox":case"lighton_ocr":case"glm_ocr":case"mistral3":case"qwen2_5_vl":case"qwen3_vl":case"qwen3_vl_moe":s=Bs(t.text_config);break;case"moondream1":s=Bs(t.phi_config);break;case"musicgen":s=Bs(t.decoder);break;case"multi_modality":s=Bs(t.language_config);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"falcon":case"modernbert-decoder":e.num_heads="num_attention_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size";break;case"gpt_oss":case"llama":case"llama4_text":case"nanochat":case"apertus":case"arcee":case"afmoe":case"lfm2":case"lfm2_moe":case"smollm3":case"olmo":case"olmo2":case"olmo3":case"mobilellm":case"granite":case"granitemoehybrid":case"cohere":case"cohere2":case"mistral":case"voxtral_realtime_text":case"voxtral_realtime_encoder":case"starcoder2":case"qwen2":case"qwen2_moe":case"qwen2_vl":case"qwen2_vl_text":case"qwen2_5_vl_text":case"qwen3_moe":case"qwen3_vl_text":case"qwen3_vl_moe_text":case"phi":case"phi3":case"phi3_v":case"llava_qwen2":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size",e.num_attention_heads="num_attention_heads",e.dim_kv="head_dim";break;case"qwen3":case"solar_open":case"glm_ocr_text":case"gemma":case"gemma2":case"vaultgemma":case"gemma3_text":case"gemma3n_text":case"glm":case"helium":case"ernie4_5":case"hunyuan_v1_dense":case"falcon_h1":case"nemotron_h":case"ministral":case"ministral3":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="head_dim";break;case"openelm":e.num_heads="num_kv_heads",e.num_layers="num_transformer_layers",e.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":e.num_heads="num_heads",e.num_layers="num_layers",e.hidden_size="hidden_size";break;case"bloom":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="hidden_size";break;case"mpt":e.num_heads="n_heads",e.num_layers="n_layers",e.hidden_size="d_model";break;case"exaone":e.num_heads="num_key_value_heads",e.num_layers="num_layers",e.dim_kv="head_dim",e.num_attention_heads="num_attention_heads";break;case"youtu":case"deepseek_v3":case"glm_moe_dsa":case"mistral4":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="qk_head_dim",e.num_attention_heads="num_attention_heads";break;case"t5":case"mt5":case"longt5":e.num_decoder_layers="num_decoder_layers",e.num_decoder_heads="num_heads",e.decoder_dim_kv="d_kv",e.num_encoder_layers="num_layers",e.num_encoder_heads="num_heads",e.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"lite-whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="d_model",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="d_model";break;case"speecht5":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="hidden_size",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="hidden_size";break;case"trocr":e.num_encoder_layers=e.num_decoder_layers="decoder_layers",e.num_encoder_heads=e.num_decoder_heads="decoder_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="d_model";break;case"musicgen_decoder":e.num_encoder_layers=e.num_decoder_layers="num_hidden_layers",e.num_encoder_heads=e.num_decoder_heads="num_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"moonshine":e.num_decoder_layers="decoder_num_hidden_layers",e.num_decoder_heads="decoder_num_key_value_heads",e.num_encoder_layers="encoder_num_hidden_layers",e.num_encoder_heads="encoder_num_key_value_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"cohere_asr":e.num_decoder_layers="num_hidden_layers",e.num_decoder_heads="num_key_value_heads",e.decoder_hidden_size="hidden_size",e.decoder_dim_kv="head_dim";let{num_hidden_layers:n,num_attention_heads:o,hidden_size:i}=t.encoder_config;s={num_encoder_layers:n,num_encoder_heads:o,encoder_hidden_size:i,encoder_dim_kv:t.head_dim};break;case"vision-encoder-decoder":let a=Bs(t.decoder),l="num_decoder_layers"in a,c=ke(t,["model_type","is_encoder_decoder"]);return l?(c.num_decoder_layers=a.num_decoder_layers,c.num_decoder_heads=a.num_decoder_heads,c.decoder_hidden_size=a.decoder_hidden_size,c.num_encoder_layers=a.num_encoder_layers,c.num_encoder_heads=a.num_encoder_heads,c.encoder_hidden_size=a.encoder_hidden_size):(c.num_layers=a.num_layers,c.num_heads=a.num_heads,c.hidden_size=a.hidden_size),c}let r={...s,...ke(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)r[n]=t[e[n]];return r}function os(t,e){t instanceof qs||(t=new qs(t));let s=e?.batch_size??1;if(["lfm2","lfm2_moe"].includes(t.model_type)){let r=e?.prefix??"past_key_values",n=r==="present"?"present":"past",o={},{layer_types:i,num_attention_heads:a,num_key_value_heads:l,hidden_size:c,conv_L_cache:p}=t,u=c/a;for(let _=0;_<i.length;++_)if(i[_]==="full_attention")for(let d of["key","value"])o[`${r}.${_}.${d}`]=[s,l,0,u];else if(i[_]==="conv")o[`${n}_conv.${_}`]=[s,c,p];else throw new Error(`Unsupported layer type: ${i[_]}`);return o}else if(["granitemoehybrid","falcon_h1","nemotron_h"].includes(t.model_type)){let r=e?.prefix??"past_key_values",n=r==="present"?"present":"past",o=t,i=o.layer_types??o.layers_block_type,a=o.num_hidden_layers??i?.length,l=o.num_key_value_heads,c=o.head_dim??o.hidden_size/o.num_attention_heads,p=o.mamba_n_heads??o.mamba_num_heads,u=o.mamba_d_head??o.mamba_head_dim,_=o.mamba_d_state??o.ssm_state_size,d=o.mamba_n_groups??o.n_groups,m=o.mamba_d_conv??o.conv_kernel,g=(o.mamba_d_ssm??(o.mamba_expand?o.mamba_expand*o.hidden_size:p*u))+2*d*_,x={};for(let w=0;w<a;++w)if((!i||i[w]==="mamba")&&(x[`${n}_conv.${w}`]=[s,g,m],x[`${n}_ssm.${w}`]=[s,p,u,_]),!i||i[w]==="attention")for(let y of["key","value"])x[`${r}.${w}.${y}`]=[s,l,0,c];return x}else if(["qwen3_next","qwen3_5_text","qwen3_5_moe_text","olmo_hybrid"].includes(t.model_type)){let r=e?.prefix??"past_key_values",n=r==="present"?"present":"past",o={},{head_dim:i,layer_types:a,num_attention_heads:l,num_key_value_heads:c,hidden_size:p,linear_num_value_heads:u,linear_num_key_heads:_,linear_key_head_dim:d,linear_value_head_dim:m,linear_conv_kernel_dim:h}=t,g=d*_,x=m*u,w=i??p/l;for(let y=0;y<a.length;++y)if(a[y]==="full_attention")for(let b of["key","value"])o[`${r}.${y}.${b}`]=[s,c,0,w];else if(a[y]==="linear_attention"){if(t.model_type==="olmo_hybrid")o[`${n}_conv.${y}.key`]=[s,g,h],o[`${n}_conv.${y}.value`]=[s,x,h],o[`${n}_conv.${y}.query`]=[s,g,h];else{let b=g*2+x;o[`${n}_conv.${y}`]=[s,b,h]}o[`${n}_recurrent.${y}`]=[s,u,d,m]}else throw new Error(`Unsupported layer type: ${a[y]}`);return o}else if(["lfm2_vl","qwen3_5","qwen3_5_moe","voxtral_realtime"].includes(t.model_type)){let r;return t.model_type==="voxtral_realtime"&&e?.session_name==="audio_encoder"?r=t.audio_config:r=t.text_config,os(r,e)}return jA(t,e)}function jA(t,{prefix:e="past_key_values",batch_size:s=1}={}){let r={},n=t.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n){let o=n.encoder_dim_kv??n.encoder_hidden_size/n.num_encoder_heads,i=n.decoder_dim_kv??n.decoder_hidden_size/n.num_decoder_heads,a=[s,n.num_encoder_heads,0,o],l=[s,n.num_decoder_heads,0,i];for(let c=0;c<n.num_decoder_layers;++c)r[`${e}.${c}.encoder.key`]=a,r[`${e}.${c}.encoder.value`]=a,r[`${e}.${c}.decoder.key`]=l,r[`${e}.${c}.decoder.value`]=l}else{let o=n.num_heads,i=n.num_layers,a=n.dim_kv??n.hidden_size/(n.num_attention_heads??o);if(n.model_type==="falcon"){let l=[s*o,0,a];for(let c=0;c<i;++c)r[`${e}.${c}.key`]=l,r[`${e}.${c}.value`]=l}else if(n.multi_query){let l=[s*o,0,2*a];for(let c=0;c<i;++c)r[`${e}.${c}.key_value`]=l}else if(n.model_type==="bloom"){let l=[s*o,a,0],c=[s*o,0,a];for(let p=0;p<i;++p)r[`${e}.${p}.key`]=l,r[`${e}.${p}.value`]=c}else if(n.model_type==="openelm")for(let l=0;l<i;++l){let c=[s,o[l],0,a];r[`${e}.${l}.key`]=c,r[`${e}.${l}.value`]=c}else{let l=[s,o,0,a];for(let c=0;c<i;++c)r[`${e}.${c}.key`]=l,r[`${e}.${c}.value`]=l}}return r}var qs=class t{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=Bs(this)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main"}={}){r&&!(r instanceof t)&&(r=new t(r));let a=r??await DA(e,{progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:i});return new this(a)}},et=class{static async from_pretrained(...e){return qs.from_pretrained(...e)}};function O_(t,e,s){return t?typeof t=="object"&&t!==null?t.hasOwnProperty(e)?+t[e]:t.hasOwnProperty(s)?+t[s]:0:+t:0}function z_(t,e){let s=[];for(let r=0;r<e;++r)s.push(`${t}_data${r===0?"":"_"+r}`);return s}async function ab(t,e,s,r){let n=`${e}${r}.onnx`,o=`${s.subfolder??""}/${n}`;return await zr(t,o,!0,s,V.IS_NODE_ENV)}async function lb(t,e,s,r,n,o={}){let i=`${e}${s}.onnx`,a=V.IS_NODE_ENV,l=[],c=O_(n,i,e);if(c>0){if(c>Qi)throw new Error(`The number of external data chunks (${c}) exceeds the maximum allowed value (${Qi}).`);let p=z_(i,c);for(let u of p){let _=`${r.subfolder??""}/${u}`;l.push(new Promise(async(d,m)=>{let h=await zr(t,_,!0,r,a);d(h instanceof Uint8Array?{path:u,data:h}:u)}))}}else o.externalData!==void 0&&(l=o.externalData.map(async p=>{if(typeof p.data=="string"){let u=await zr(t,p.data,!0,r);return{...p,data:u}}return p}));return Promise.all(l)}async function BA(t,e,s,r=!1,n=void 0){let o=s.config?.["transformers.js_config"]??{},i=na(s.device??o.device,e,{warn:b=>$.info(b)}),a=T0(i),l=o.device_config??{};l.hasOwnProperty(i)&&(o={...o,...l[i]});let c=oa(s.dtype??o.dtype,e,i,{configDtype:o.dtype,warn:b=>$.info(b)});if(Pt.hasOwnProperty(c)){if(i==="webgpu"&&!V.IS_NODE_ENV&&c===Re.fp16&&!await $0())throw new Error(`The device (${i}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${c}. Should be one of: ${Object.keys(Re).join(", ")}`);let p=o.kv_cache_dtype,u=p?typeof p=="string"?p:p[c]??"float32":void 0;if(u&&!["float32","float16"].includes(u))throw new Error(`Invalid kv_cache_dtype: ${u}. Should be one of: float32, float16`);let _=Pt[c],d={...s.session_options};d.executionProviders??=a;let m=o.free_dimension_overrides;m?d.freeDimensionOverrides??=m:i.startsWith("webnn")&&!d.freeDimensionOverrides&&$.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${i}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let h=ab(t,e,s,_),g=s.use_external_data_format??o.use_external_data_format,x=await lb(t,e,_,s,g,d);if(x.length>0&&!V.IS_NODE_ENV&&(d.externalData=x),r&&i==="webgpu"&&p!==!1){let b=os(s.config,{prefix:"present",session_name:n});if(Object.keys(b).length>0&&!Tr()){let v={};for(let k in b)v[k]="gpu-buffer";d.preferredOutputLocation=v}}return{buffer_or_path:await h,session_options:d,session_config:{dtype:c,kv_cache_dtype:u,device:i}}}async function cb(t,e,s,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(e).map(async n=>{let o=r?.[n]??!1,{buffer_or_path:i,session_options:a,session_config:l}=await BA(t,e[n],s,o,n),c=await ta(i,a,l);return[n,c]})))}function pb(t){for(let e in t)ra(t[e])?t[e]=new E(t[e]):typeof t[e]=="object"&&pb(t[e]);return t}async function X(t,e){let s=qA(t,e);try{let r=Object.fromEntries(Object.entries(s).map(([o,i])=>{let a=i.ort_tensor;return V.IS_NODE_ENV&&typeof Float16Array<"u"&&a.cpuData instanceof Float16Array&&(a.cpuData=new Uint16Array(a.cpuData.buffer)),[o,a]})),n=await sa(t,r);return pb(n)}catch(r){let n=Object.fromEntries(Object.entries(s).map(([o,i])=>{let a={type:i.type,dims:i.dims,location:i.location};return a.location!=="gpu-buffer"&&(a.data=i.data),[o,a]}));throw $.error(`An error occurred during model execution: "${r}".`),$.error("Inputs given to model:",n),r}}function qA(t,e){let s=Object.create(null),r=[];for(let i of t.inputNames){let a=e[i];if(!(a instanceof E)){r.push(i);continue}s[i]=Tr()?a.clone():a}if(r.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(", ")}.`);let n=Object.keys(e).length,o=t.inputNames.length;if(n>o){let i=Object.keys(e).filter(a=>!t.inputNames.includes(a));$.warn(`WARNING: Too many inputs were provided (${n} > ${o}). The following inputs will be ignored: "${i.join(", ")}".`)}return s}var me=class{};var z=class extends me{constructor({logits:e,...s}){super(),this.logits=e;let r=Object.values(s);r.length>0&&(this.attentions=r)}},ee=class extends me{constructor({logits:e}){super(),this.logits=e}},re=class extends me{constructor({logits:e}){super(),this.logits=e}},ce=class extends me{constructor({start_logits:e,end_logits:s}){super(),this.start_logits=e,this.end_logits=s}},je=class extends me{constructor({logits:e}){super(),this.logits=e}};var Fa=class extends me{constructor({alphas:e}){super(),this.alphas=e}};var tt=class extends Se{_call(e,s){throw Error("`_call` should be implemented in a subclass")}},Hr=class extends Se{_call(e,s){throw Error("`_call` should be implemented in a subclass")}},is=class extends Se{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,s){let r=s;for(let n of this.processors)r=n(e,r);return r}[Symbol.iterator](){return this.processors.values()}},Ra=class extends tt{constructor(e){super(),this.bos_token_id=e}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===1){let n=s[r].data;n.fill(-1/0),n[this.bos_token_id]=0}return s}},Da=class extends tt{constructor(e,s){super(),this.max_length=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===this.max_length-1){let n=s[r].data;n.fill(-1/0);for(let o of this.eos_token_id)n[o]=0}return s}},Us=class extends tt{constructor(e,s){super(),this.begin_suppress_tokens=e,this.begin_index=s}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length===this.begin_index){let n=s[r].data;for(let o of this.begin_suppress_tokens)n[o]=-1/0}return s}},ja=class extends tt{constructor(e,s){super(),this.eos_token_id=Array.isArray(e.eos_token_id)?e.eos_token_id[0]:e.eos_token_id,this.no_timestamps_token_id=e.no_timestamps_token_id,this.timestamp_begin=this.no_timestamps_token_id+1,this.begin_index=s.length,s.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data;if(n[this.no_timestamps_token_id]=-1/0,e[r].length===this.begin_index-1){n.fill(-1/0),n[this.timestamp_begin]=0;continue}let o=e[r].slice(this.begin_index),i=o.length>=1&&o[o.length-1]>=this.timestamp_begin,a=o.length<2||o[o.length-2]>=this.timestamp_begin;if(i&&(a?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[r].length===this.begin_index&&this.max_initial_timestamp_index!==null){let u=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(u+1).fill(-1/0)}let l=qc(n),c=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((u,_)=>u+_)),p=ue(l.subarray(0,this.timestamp_begin))[0];c>p&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return s}},Ba=class extends tt{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let s=e.length,r=[];for(let o=0;o<s+1-this.no_repeat_ngram_size;++o){let i=[];for(let a=0;a<this.no_repeat_ngram_size;++a)i.push(e[o+a]);r.push(i.map(Number))}let n=new Map;for(let o of r){let i=o.slice(0,o.length-1),a=JSON.stringify(i),l=n.get(a)??[];l.push(o[o.length-1]),n.set(a,l)}return n}getGeneratedNgrams(e,s){let r=s.slice(s.length+1-this.no_repeat_ngram_size,s.length);return e.get(JSON.stringify(r.map(Number)))??[]}calcBannedNgramTokens(e){let s=[];if(e.length+1<this.no_repeat_ngram_size)return s;{let r=this.getNgrams(e);return this.getGeneratedNgrams(r,e)}}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data,o=this.calcBannedNgramTokens(e[r]);for(let i of o)n[i]=-1/0}return s}},qa=class extends tt{constructor(e){super(),this.penalty=e}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data;for(let o of new Set(e[r])){let i=Number(o);n[i]<0?n[i]*=this.penalty:n[i]/=this.penalty}}return s}},Ua=class extends tt{constructor(e,s){super(),this.min_length=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length<this.min_length){let n=s[r].data;for(let o of this.eos_token_id)n[o]=-1/0}return s}},Ga=class extends tt{constructor(e,s,r){super(),this.prompt_length_to_skip=e,this.min_new_tokens=s,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,s){for(let r=0;r<e.length;++r)if(e[r].length-this.prompt_length_to_skip<this.min_new_tokens){let o=s[r].data;for(let i of this.eos_token_id)o[i]=-1/0}return s}},Wa=class extends tt{constructor(e,s){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,s){for(let r=0;r<e.length;++r){let n=s[r].data,o=e[r];for(let i of this.bad_words_ids){if(o.length<i.length-1)continue;let a=!0;for(let l=1;l<=i.length-1;++l)if(i.at(-l-1)!=o.at(-l)){a=!1;break}a&&(n[i.at(-1)]=-1/0)}}return s}},Va=class extends tt{constructor(e){if(super(),e<=1)throw new Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,s){if(s.dims[0]!==2*e.length)throw new Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${s.dims[0]} for the logits and ${e.length} for the input ids.`);let r=e.length,n=s.slice([0,r],null),o=s.slice([r,s.dims[0]],null);for(let i=0;i<o.data.length;++i)o.data[i]+=(n.data[i]-o.data[i])*this.guidance_scale;return o}},Ha=class extends Hr{constructor(e){if(super(),typeof e!="number"||e<=0){let s=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(s+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,s){let r=s.data;for(let n=0;n<r.length;++n)r[n]/=this.temperature;return s}},ub=class extends Hr{constructor(e,{filter_value:s=-1/0,min_tokens_to_keep:r=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(r)||r<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${r}`);this.top_p=e,this.filter_value=s,this.min_tokens_to_keep=r}},_b=class extends Hr{constructor(e,{filter_value:s=-1/0,min_tokens_to_keep:r=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,r),this.filter_value=s}};var Gs=class{max_length=20;max_new_tokens=null;min_length=0;min_new_tokens=null;early_stopping=!1;max_time=null;do_sample=!1;num_beams=1;num_beam_groups=1;penalty_alpha=null;use_cache=!0;temperature=1;top_k=50;top_p=1;typical_p=1;epsilon_cutoff=0;eta_cutoff=0;diversity_penalty=0;repetition_penalty=1;encoder_repetition_penalty=1;length_penalty=1;no_repeat_ngram_size=0;bad_words_ids=null;force_words_ids=null;renormalize_logits=!1;constraints=null;forced_bos_token_id=null;forced_eos_token_id=null;remove_invalid_values=!1;exponential_decay_length_penalty=null;suppress_tokens=null;streamer=null;begin_suppress_tokens=null;forced_decoder_ids=null;guidance_scale=null;num_return_sequences=1;output_attentions=!1;output_hidden_states=!1;output_scores=!1;return_dict_in_generate=!1;pad_token_id=null;bos_token_id=null;eos_token_id=null;encoder_no_repeat_ngram_size=0;decoder_start_token_id=null;generation_kwargs={};constructor(e){Object.assign(this,ke(e,Object.getOwnPropertyNames(this)))}};var Ft=class extends Se{_call(e,s){throw Error("StoppingCriteria needs to be subclassed")}},Ws=class t extends Se{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof t?e=e.criteria:e instanceof Ft&&(e=[e]),this.criteria.push(...e)}_call(e,s){let r=new Array(e.length).fill(!1);for(let n of this.criteria){let o=n(e,s);for(let i=0;i<r.length;++i)r[i]||=o[i]}return r}[Symbol.iterator](){return this.criteria.values()}},Ka=class extends Ft{constructor(e,s=null){super(),this.max_length=e,this.max_position_embeddings=s}_call(e){return e.map(s=>s.length>=this.max_length)}},Xa=class extends Ft{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,s){return e.map(r=>{let n=r.at(-1);return this.eos_token_id.some(o=>n==o)})}},db=class extends Ft{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,s){return new Array(e.length).fill(this.interrupted)}};var as=class extends Se{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error("sample should be implemented in subclasses.")}getLogits(e,s){let r=e.dims.at(-1),n=e.data;if(s===-1)n=n.slice(-r);else{let o=s*r;n=n.slice(o,o+r)}return n}randomSelect(e){return i0(e)}static getSampler(e){if(e.do_sample)return new T_(e);if(e.num_beams>1)return new C_(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new I_(e)}},I_=class extends as{async sample(e){let s=ue(e.data)[1];return[[BigInt(s),0]]}},T_=class extends as{async sample(e){let s=e.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));let[r,n]=await lt(e,s),o=fe(r.data);return Array.from({length:this.generation_config.num_beams},()=>{let i=this.randomSelect(o);return[n.data[i],Math.log(o[i])]})}},C_=class extends as{async sample(e){let s=e.dims.at(-1);this.generation_config.top_k>0&&(s=Math.min(this.generation_config.top_k,s));let[r,n]=await lt(e,s),o=fe(r.data);return Array.from({length:this.generation_config.num_beams},(i,a)=>[n.data[a],Math.log(o[a])])}};var P_=class{constructor(e){if(e)for(let s in e){if(s in this)throw new TypeError(`Key "${s}" conflicts with an existing property on DynamicCache`);let r=e[s];if(!(r instanceof E))throw new TypeError(`Expected a Tensor for key "${s}", got ${typeof r}`);this[s]=r}}get_seq_length(){let e=this;for(let s in e)if(s.startsWith("past_key_values."))return e[s].dims.at(-2);throw new Error("Unable to determine sequence length from the cache.")}async dispose(){let e=[];for(let s of Object.values(this))s.location==="gpu-buffer"&&e.push(s.dispose());await Promise.all(e)}},Kr=P_;var ls=null;function mb(t){ls=t}function N_(t){if(t instanceof E)return t;if(t.length===0)throw Error("items must be non-empty");if(Array.isArray(t[0])){if(t.some(e=>e.length!==t[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new E("int64",BigInt64Array.from(t.flat().map(e=>BigInt(e))),[t.length,t[0].length])}else return new E("int64",BigInt64Array.from(t.map(e=>BigInt(e))),[1,t.length])}function L_(t){return new E("bool",[t],[1])}var L={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15,VoxtralRealtime:16},Ja={[L.DecoderOnly]:{can_generate:!0,forward:Ge,prepare_inputs:Vs,sessions:(t,e)=>({model:e.model_file_name??"model"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[L.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Ge,prepare_inputs:Vs,sessions:(t,e)=>({model:e.model_file_name??"model"})},[L.Seq2Seq]:{can_generate:!0,forward:Qa,prepare_inputs:Xr,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[L.Vision2Seq]:{can_generate:!0,forward:Qa,prepare_inputs:Xr,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[L.Musicgen]:{can_generate:!0,forward:Qa,sessions:()=>({model:"text_encoder",decoder_model_merged:"decoder_model_merged",encodec_decode:"encodec_decode"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[L.EncoderDecoder]:{can_generate:!1,forward:Qa,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0}},[L.MaskGeneration]:{sessions:()=>({model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"})},[L.ImageTextToText]:{can_generate:!0,forward:WA,prepare_inputs:Ya,sessions:(t,e,s)=>{let r={embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"};return s||(r.vision_encoder="vision_encoder"),t.is_encoder_decoder&&(r.model="encoder_model"),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[L.AudioTextToText]:{can_generate:!0,forward:GA,prepare_inputs:Ya,sessions:()=>({embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[L.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Ya,sessions:(t,e,s)=>{let r={embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"};return s||(r.audio_encoder="audio_encoder",r.vision_encoder="vision_encoder"),r},optional_configs:{generation_config:"generation_config.json"}},[L.Phi3V]:{can_generate:!0,prepare_inputs:Ya,sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[L.MultiModality]:{can_generate:!0,sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"language_model",lm_head:"lm_head",gen_head:"gen_head",gen_img_embeds:"gen_img_embeds",image_decode:"image_decode"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[L.AutoEncoder]:{can_generate:!1,forward:UA,sessions:()=>({encoder_model:"encoder_model",decoder_model:"decoder_model"})},[L.Supertonic]:{sessions:()=>({text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"})},[L.Chatterbox]:{can_generate:!0,forward:st,sessions:()=>({embed_tokens:"embed_tokens",speech_encoder:"speech_encoder",model:"language_model",conditional_decoder:"conditional_decoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[L.VoxtralRealtime]:{can_generate:!0,prepare_inputs:Vs,sessions:()=>({embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:"generation_config.json"}},default:{can_generate:!1,forward:st,sessions:(t,e)=>({model:e.model_file_name??"model"})}};function Za(t,e,s={}){let r=Ja[t]??Ja.default;return{sessions:r.sessions(e,s),cache_sessions:r.cache_sessions,optional_configs:r.optional_configs}}function fb(t,e){let s=ct.get(t),r=!1,n=e?.architectures?.[0];if(n&&n!==t&&t?.endsWith("ForCausalLM")&&n.endsWith("ForConditionalGeneration")){let o=ct.get(n);o!==void 0&&(s=o,r=!0)}return{typeConfig:Ja[s]??Ja.default,textOnly:r,modelType:s}}var ct=new Map,el=new Map,cs=new Map,f=class extends Se{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,s,r){super(),this.config=e,this.sessions=s,this.configs=r;let n=cs.get(this.constructor),{typeConfig:o}=fb(n,e);this.can_generate=o.can_generate,this._forward=o.forward,this._prepare_inputs_for_generation=o.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let s of Object.values(this.sessions))e.push(s.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main",model_file_name:a=null,subfolder:l="onnx",device:c=null,dtype:p=null,use_external_data_format:u=null,session_options:_={}}={}){let d={progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:i,model_file_name:a,subfolder:l,device:c,dtype:p,use_external_data_format:u,session_options:_},m=cs.get(this);r=d.config=await et.from_pretrained(e,d);let{typeConfig:h,textOnly:g,modelType:x}=fb(m,r);if(x===void 0){let v=m??r?.model_type;v!=="custom"&&$.warn(`Model type for '${v}' not found, assuming encoder-only architecture. Please report this at ${Nt}.`)}let w=h.sessions(r,d,g),y=[cb(e,w,d,h.cache_sessions)];h.optional_configs&&y.push(HA(e,h.optional_configs,d));let b=await Promise.all(y);return new this(r,...b)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,s,r=null){let n=new is;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new qa(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new Ba(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new Wa(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new Ua(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&n.push(new Ga(s,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new Ra(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new Da(e.max_length,e.forced_eos_token_id)),e.begin_suppress_tokens!==null){let o=s>1||e.forced_bos_token_id===null?s:s+1;n.push(new Us(e.begin_suppress_tokens,o))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new Va(e.guidance_scale)),e.temperature===0&&e.do_sample&&($.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&n.push(new Ha(e.temperature)),r!==null&&n.extend(r),n}_prepare_generation_config(e,s,r=Gs){let n={...this.config};for(let i of["decoder","generator","text_config"])i in n&&Object.assign(n,n[i]);let o=new r(n);return Object.assign(o,this.generation_config??{}),e&&Object.assign(o,e),s&&Object.assign(o,ke(s,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,s=null){let r=new Ws;return e.max_length!==null&&r.push(new Ka(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&r.push(new Xa(e.eos_token_id)),s&&r.extend(s),r}_validate_model_class(){if(!this.can_generate){let e=[ls.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,ls.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,ls.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,ls.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),s=cs.get(this.constructor),r=new Set,n=this.config.model_type;for(let i of e){let a=i?.get(n);a&&r.add(a)}let o=`The current model class (${s}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw r.size>0&&(o+=` Please use the following class instead: ${[...r].join(", ")}`),Error(o)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:s,model_inputs:r,is_encoder_decoder:n}){return r.past_key_values=this.getPastKeyValues(s,r.past_key_values),r.input_ids=new E("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in r&&(r.decoder_attention_mask=oe([r.decoder_attention_mask,Ae([r.decoder_attention_mask.dims[0],1])],1)):r.attention_mask=oe([r.attention_mask,Ae([r.attention_mask.dims[0],1])],1),r.position_ids=null,r}_prepare_model_inputs({inputs:e,bos_token_id:s,model_kwargs:r}){let n=ke(r,this.forward_params),o=this.main_input_name;if(o in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[o]=e;return{inputs_tensor:n[o],model_inputs:n,model_input_name:o}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:s,model_input_name:r,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!s.inputs_embeds&&"_prepare_inputs_embeds"in this){let{input_ids:i,pixel_values:a,attention_mask:l,...c}=s,p=await this._prepare_inputs_embeds(s);s={...c,...ke(p,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await st(this,s);if(n.guidance_scale!==null&&n.guidance_scale>1)o=oe([o,Pr(o,0)],0),"attention_mask"in s&&(s.attention_mask=oe([s.attention_mask,Yc(s.attention_mask)],0));else if(s.decoder_input_ids){let i=N_(s.decoder_input_ids).dims[0];if(i!==o.dims[0]){if(o.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${o.dims[0]}) than the decoder inputs (${i}).`);o=oe(Array.from({length:i},()=>o),0)}}return s.encoder_outputs=o,s}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:s,model_kwargs:r,decoder_start_token_id:n,bos_token_id:o,generation_config:i}){let{decoder_input_ids:a,...l}=r;if(!(a instanceof E)){if(a)Array.isArray(a[0])||(a=Array.from({length:e},()=>a));else if(n??=o,this.config.model_type==="musicgen")a=Array.from({length:e*this.config.decoder.num_codebooks},()=>[n]);else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${n.length}`);a=n}else a=Array.from({length:e},()=>[n]);a=N_(a)}return l.decoder_attention_mask=ca(a),{input_ids:a,model_inputs:l}}async generate({inputs:e=null,generation_config:s=null,logits_processor:r=null,stopping_criteria:n=null,streamer:o=null,...i}){this._validate_model_class(),s=this._prepare_generation_config(s,i);let{inputs_tensor:a,model_inputs:l,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:i}),p=this.config.is_encoder_decoder;p&&("encoder_outputs"in l||(l=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:a,model_inputs:l,model_input_name:c,generation_config:s})));let u;p?{input_ids:u,model_inputs:l}=this._prepare_decoder_input_ids_for_generation({batch_size:l[c].dims.at(0),model_input_name:c,model_kwargs:l,decoder_start_token_id:s.decoder_start_token_id,bos_token_id:s.bos_token_id,generation_config:s}):u=l[c];let _=u.dims.at(-1);s.max_new_tokens!==null&&(s.max_length=_+s.max_new_tokens);let d=this._get_logits_processor(s,_,r),m=this._get_stopping_criteria(s,n),h=l[c].dims.at(0),g=as.getSampler(s),x=new Array(h).fill(0),w=u.tolist();o&&o.put(w);let y,b={},v={};for(;;){if(l=this.prepare_inputs_for_generation(w,l,s),y=await this.forward(l),s.return_dict_in_generate)if(s.output_attentions){let F=this.getAttentions(y);for(let U in F)U in b||(b[U]=[]),b[U].push(F[U])}else this._return_dict_in_generate_keys&&Object.assign(v,ke(y,this._return_dict_in_generate_keys));let N=y.logits.slice(null,-1,null).to("float32"),q=d(w,N),P=[];for(let F=0;F<q.dims.at(0);++F){let U=q[F],j=await g(U);for(let[W,Z]of j){let te=BigInt(W);x[F]+=Z,w[F].push(te),P.push([te]);break}}if(o&&o.put(P),m(w).every(F=>F))break;l=this._update_model_kwargs_for_generation({generated_input_ids:P,outputs:y,model_inputs:l,is_encoder_decoder:p})}o&&o.end();let k=this.getPastKeyValues(y,l.past_key_values,!0),O=new E("int64",w.flat(),[w.length,w[0].length]);if(s.return_dict_in_generate)return{sequences:O,past_key_values:k,...b,...v};for(let N of Object.values(y))N.location==="gpu-buffer"&&N.dispose();return O}getPastKeyValues(e,s,r=!1){let n=Object.create(null);for(let o in e)if(o.startsWith("present")){let i=o.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present_recurrent","past_recurrent").replace("present","past_key_values"),a=o.includes("encoder");if(a&&s?n[i]=s[i]:n[i]=e[o],s&&(!a||r)){let l=s[i];l.location==="gpu-buffer"&&l.dispose()}}return new Kr(n)}getAttentions(e){let s={};for(let r of["cross_attentions","encoder_attentions","decoder_attentions"])for(let n in e)n.startsWith(r)&&(r in s||(s[r]=[]),s[r].push(e[n]));return s}addPastKeyValues(e,s){if(s)Object.assign(e,s);else{let r=this.sessions.decoder_model_merged??this.sessions.model,n=(e[this.main_input_name]??e.attention_mask)?.dims?.[0]??1,o=r?.config?.kv_cache_dtype??"float32",i=o==="float16"?wt.float16:wt.float32,a=os(this.config,{batch_size:n});for(let l in a){let c=a[l].reduce((p,u)=>p*u,1);e[l]=new E(o,new i(c),a[l])}}}async _encode_input(e,s,r){if(!Object.hasOwn(this.sessions,e))throw new Error(`Model does not have a ${e} session.`);let n=this.sessions[e];return(await X(n,ke(s,n.inputNames)))[r]}async encode_image(e){return this._encode_input("vision_encoder",e,"image_features")}async encode_text(e){return this._encode_input("embed_tokens",e,"inputs_embeds")}async encode_audio(e){return this._encode_input("audio_encoder",e,"audio_features")}};async function Qa(t,e){let{encoder_outputs:s,input_ids:r,decoder_input_ids:n,decoder_attention_mask:o,...i}=e;if(!s){let a=ke(e,t.sessions.model.inputNames);s=(await st(t,a)).last_hidden_state}return i.input_ids=n,i.encoder_hidden_states=s,t.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(i.encoder_attention_mask=e.attention_mask),o&&!i.attention_mask&&(i.attention_mask=o),await Ge(t,i,!0)}async function st(t,e){let s=t.sessions.model,r=ke(e,s.inputNames);if(s.inputNames.includes("inputs_embeds")&&!r.inputs_embeds){if(!e.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await t.encode_text({input_ids:e.input_ids})}if(s.inputNames.includes("token_type_ids")&&!r.token_type_ids){if(!r.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=Yc(r.input_ids)}if(s.inputNames.includes("pixel_mask")&&!r.pixel_mask){if(!r.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let n=r.pixel_values.dims;r.pixel_mask=Ae([n[0],n[2],n[3]])}return await X(s,r)}async function UA(t,e){let s=await t.encode(e);return await t.decode(s)}async function Ge(t,e,s=!1){let r=t.sessions[s?"decoder_model_merged":"model"],{past_key_values:n,...o}=e;if(r.inputNames.includes("use_cache_branch")&&(o.use_cache_branch=L_(!!n)),r.inputNames.includes("position_ids")&&o.attention_mask&&!o.position_ids){let a=["paligemma","gemma3_text","gemma3"].includes(t.config.model_type)?1:0;o.position_ids=VA(o,n,a)}r.inputNames.includes("num_logits_to_keep")&&!o.num_logits_to_keep&&(o.num_logits_to_keep=new E("int64",[0n],[])),t.addPastKeyValues(o,n);let i=ke(o,r.inputNames);return await X(r,i)}async function hb(t,{encode_function:e,merge_function:s,modality_input_names:r,modality_output_name:n,input_ids:o=null,attention_mask:i=null,position_ids:a=null,inputs_embeds:l=null,past_key_values:c=null,generation_config:p=null,logits_processor:u=null,..._}){if(!l){l=await t.encode_text({input_ids:o,..._});let m=ke(_,r);if(Object.keys(m).length>0){if(o.dims[1]!==1){let h=await e({...m,..._});({inputs_embeds:l,attention_mask:i}=s({[n]:h,inputs_embeds:l,input_ids:o,attention_mask:i}))}else if(c&&o.dims[1]===1){let h=o.dims[1],g=c.get_seq_length();i=oe([Ae([o.dims[0],g]),i.slice(null,[i.dims[1]-h,i.dims[1]])],1)}}}if(!a&&["qwen2_vl","qwen2_vl_text","qwen2_5_vl","qwen2_5_vl_text","qwen3_vl","qwen3_vl_text","qwen3_vl_moe","qwen3_vl_moe_text","qwen3_5","qwen3_5_text","qwen3_5_moe","qwen3_5_moe_text","glm_ocr","glm_ocr_text"].includes(t.config.model_type)){let{image_grid_thw:m,video_grid_thw:h}=_;[a]=t.get_rope_index(o,m,h,i)}return await Ge(t,{inputs_embeds:l,past_key_values:c,attention_mask:i,position_ids:a,generation_config:p,logits_processor:u},!0)}async function GA(t,e){return await hb(t,{...e,modality_input_names:["audio_values","input_features"],modality_output_name:"audio_features",encode_function:t.encode_audio.bind(t),merge_function:t._merge_input_ids_with_audio_features.bind(t)})}async function WA(t,e){return await hb(t,{...e,modality_input_names:["pixel_values"],modality_output_name:"image_features",encode_function:t.encode_image.bind(t),merge_function:t._merge_input_ids_with_image_features.bind(t)})}function $_(t,e=0){let[s,r]=t.dims,n=t.data,o=new BigInt64Array(n.length);for(let i=0;i<s;++i){let a=i*r,l=BigInt(e);for(let c=0;c<r;++c){let p=a+c;n[p]===0n?o[p]=BigInt(1):(o[p]=l,l+=n[p])}}return{data:o,dims:t.dims}}function VA(t,e=null,s=0){let{input_ids:r,inputs_embeds:n,attention_mask:o}=t,{data:i,dims:a}=$_(o,s),l=new E("int64",i,a);if(e){let c=-(r??n).dims.at(1);l=l.slice(null,[c,null])}return l}function Vs(t,e,s,r){let n=s.past_key_values?s.past_key_values.get_seq_length():0;if((t.sessions.decoder_model_merged??t.sessions.model)?.inputNames.includes("num_logits_to_keep")&&!s.num_logits_to_keep&&(s.num_logits_to_keep=new E("int64",[1n],[])),!s.attention_mask){let i;for(let a of["input_ids","inputs_embeds","position_ids"])if(s[a]){i=s[a].dims;break}if(!i)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");s.attention_mask=Ae([i[0],n+i[1]])}if(s.past_key_values){let{input_ids:i,attention_mask:a}=s;a&&a.dims[1]>i.dims[1]||n<i.dims[1]&&(s.input_ids=i.slice(null,[n,null]))}return s}function Xr(t,e,s,r){return s.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...s,decoder_input_ids:N_(e)}}function Ya(t,...e){return t.config.is_encoder_decoder?Xr(t,...e):Vs(t,...e)}function gb({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n}){let o=r.tolist().map(c=>c.reduce((p,u,_)=>(u==t&&p.push(_),p),[])),i=o.reduce((c,p)=>c+p.length,0),a=s.dims[0];if(i!==a)throw new Error(`Number of tokens and features do not match: tokens: ${i}, features ${a}`);let l=0;for(let c=0;c<o.length;++c){let p=o[c],u=e[c];for(let _=0;_<p.length;++_)u[p[_]].data.set(s[l++].data)}return{inputs_embeds:e,attention_mask:n}}function Hs({image_token_id:t,inputs_embeds:e,image_features:s,input_ids:r,attention_mask:n}){return gb({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n})}function tl({audio_token_id:t,inputs_embeds:e,audio_features:s,input_ids:r,attention_mask:n}){return gb({modality_token_id:t,inputs_embeds:e,modality_features:s,input_ids:r,attention_mask:n})}async function HA(t,e,s){return Object.fromEntries(await Promise.all(Object.keys(e).map(async r=>{let n=await Ce(t,e[r],!1,s);return[r,n]})))}var _i={};Es(_i,{ASTForAudioClassification:()=>K_,ASTModel:()=>H_,ASTPreTrainedModel:()=>Zr,AfmoeForCausalLM:()=>G_,AfmoeModel:()=>U_,AfmoePreTrainedModel:()=>Yr,AlbertForMaskedLM:()=>j_,AlbertForQuestionAnswering:()=>D_,AlbertForSequenceClassification:()=>R_,AlbertModel:()=>F_,AlbertPreTrainedModel:()=>ps,ApertusForCausalLM:()=>q_,ApertusModel:()=>B_,ApertusPreTrainedModel:()=>Qr,ArceeForCausalLM:()=>V_,ArceeModel:()=>W_,ArceePreTrainedModel:()=>Jr,BartForConditionalGeneration:()=>Q_,BartForSequenceClassification:()=>Y_,BartModel:()=>X_,BartPretrainedModel:()=>Ks,BeitForImageClassification:()=>Z_,BeitModel:()=>J_,BeitPreTrainedModel:()=>en,BertForMaskedLM:()=>td,BertForQuestionAnswering:()=>nd,BertForSequenceClassification:()=>sd,BertForTokenClassification:()=>rd,BertModel:()=>ed,BertPreTrainedModel:()=>Rt,BlenderbotForConditionalGeneration:()=>id,BlenderbotModel:()=>od,BlenderbotPreTrainedModel:()=>tn,BlenderbotSmallForConditionalGeneration:()=>ld,BlenderbotSmallModel:()=>ad,BlenderbotSmallPreTrainedModel:()=>sn,BloomForCausalLM:()=>pd,BloomModel:()=>cd,BloomPreTrainedModel:()=>rn,CHMv2ForDepthEstimation:()=>gd,CHMv2PreTrainedModel:()=>nl,CLIPModel:()=>wd,CLIPPreTrainedModel:()=>mt,CLIPSegForImageSegmentation:()=>Ed,CLIPSegModel:()=>vd,CLIPSegPreTrainedModel:()=>cn,CLIPTextModel:()=>yd,CLIPTextModelWithProjection:()=>ln,CLIPVisionModel:()=>bd,CLIPVisionModelWithProjection:()=>kd,CamembertForMaskedLM:()=>_d,CamembertForQuestionAnswering:()=>md,CamembertForSequenceClassification:()=>dd,CamembertForTokenClassification:()=>fd,CamembertModel:()=>ud,CamembertPreTrainedModel:()=>Dt,ChatterboxModel:()=>nn,ChatterboxPreTrainedModel:()=>sl,ChineseCLIPModel:()=>hd,ChineseCLIPPreTrainedModel:()=>rl,ClapAudioModelWithProjection:()=>an,ClapModel:()=>xd,ClapPreTrainedModel:()=>Xs,ClapTextModelWithProjection:()=>on,CodeGenForCausalLM:()=>Md,CodeGenModel:()=>Ad,CodeGenPreTrainedModel:()=>pn,Cohere2ForCausalLM:()=>Id,Cohere2Model:()=>zd,Cohere2PreTrainedModel:()=>_n,CohereAsrForConditionalGeneration:()=>Cd,CohereAsrModel:()=>Td,CohereAsrPreTrainedModel:()=>dn,CohereForCausalLM:()=>Od,CohereModel:()=>Sd,CoherePreTrainedModel:()=>un,ConvBertForMaskedLM:()=>Nd,ConvBertForQuestionAnswering:()=>Fd,ConvBertForSequenceClassification:()=>Ld,ConvBertForTokenClassification:()=>$d,ConvBertModel:()=>Pd,ConvBertPreTrainedModel:()=>jt,ConvNextForImageClassification:()=>Dd,ConvNextModel:()=>Rd,ConvNextPreTrainedModel:()=>fn,ConvNextV2ForImageClassification:()=>Bd,ConvNextV2Model:()=>jd,ConvNextV2PreTrainedModel:()=>mn,DFineForObjectDetection:()=>Wd,DFineModel:()=>Gd,DFinePreTrainedModel:()=>gn,DINOv3ConvNextModel:()=>xf,DINOv3ConvNextPreTrainedModel:()=>ul,DINOv3ViTModel:()=>wf,DINOv3ViTPreTrainedModel:()=>_l,DPTForDepthEstimation:()=>Sf,DPTModel:()=>Mf,DPTPreTrainedModel:()=>En,DacDecoderModel:()=>wn,DacDecoderOutput:()=>il,DacEncoderModel:()=>xn,DacEncoderOutput:()=>ol,DacModel:()=>Vd,DacPreTrainedModel:()=>Qs,DebertaForMaskedLM:()=>Kd,DebertaForQuestionAnswering:()=>Yd,DebertaForSequenceClassification:()=>Xd,DebertaForTokenClassification:()=>Qd,DebertaModel:()=>Hd,DebertaPreTrainedModel:()=>Bt,DebertaV2ForMaskedLM:()=>tf,DebertaV2ForQuestionAnswering:()=>nf,DebertaV2ForSequenceClassification:()=>sf,DebertaV2ForTokenClassification:()=>rf,DebertaV2Model:()=>ef,DebertaV2PreTrainedModel:()=>qt,DecisionTransformerModel:()=>of,DecisionTransformerPreTrainedModel:()=>al,DeepseekV3ForCausalLM:()=>Zd,DeepseekV3Model:()=>Jd,DeepseekV3PreTrainedModel:()=>yn,DeiTForImageClassification:()=>lf,DeiTModel:()=>af,DeiTPreTrainedModel:()=>bn,DepthAnythingForDepthEstimation:()=>cf,DepthAnythingPreTrainedModel:()=>ll,DepthProForDepthEstimation:()=>pf,DepthProPreTrainedModel:()=>cl,DetrForObjectDetection:()=>_f,DetrForSegmentation:()=>df,DetrModel:()=>uf,DetrObjectDetectionOutput:()=>Js,DetrPreTrainedModel:()=>Ys,DetrSegmentationOutput:()=>pl,Dinov2ForImageClassification:()=>mf,Dinov2Model:()=>ff,Dinov2PreTrainedModel:()=>kn,Dinov2WithRegistersForImageClassification:()=>gf,Dinov2WithRegistersModel:()=>hf,Dinov2WithRegistersPreTrainedModel:()=>vn,DistilBertForMaskedLM:()=>Ef,DistilBertForQuestionAnswering:()=>vf,DistilBertForSequenceClassification:()=>bf,DistilBertForTokenClassification:()=>kf,DistilBertModel:()=>yf,DistilBertPreTrainedModel:()=>Ut,DonutSwinModel:()=>Af,DonutSwinPreTrainedModel:()=>dl,EdgeTamModel:()=>$x,EfficientNetForImageClassification:()=>zf,EfficientNetModel:()=>Of,EfficientNetPreTrainedModel:()=>An,ElectraForMaskedLM:()=>Tf,ElectraForQuestionAnswering:()=>Nf,ElectraForSequenceClassification:()=>Cf,ElectraForTokenClassification:()=>Pf,ElectraModel:()=>If,ElectraPreTrainedModel:()=>Gt,Ernie4_5ForCausalLM:()=>$f,Ernie4_5Model:()=>Lf,Ernie4_5PretrainedModel:()=>Mn,EsmForMaskedLM:()=>Rf,EsmForSequenceClassification:()=>Df,EsmForTokenClassification:()=>jf,EsmModel:()=>Ff,EsmPreTrainedModel:()=>us,EuroBertForMaskedLM:()=>qf,EuroBertForSequenceClassification:()=>Uf,EuroBertForTokenClassification:()=>Gf,EuroBertModel:()=>Bf,EuroBertPreTrainedModel:()=>_s,ExaoneForCausalLM:()=>Vf,ExaoneModel:()=>Wf,ExaonePreTrainedModel:()=>Sn,FalconForCausalLM:()=>Kf,FalconH1ForCausalLM:()=>Qf,FalconH1Model:()=>Xf,FalconH1PreTrainedModel:()=>zn,FalconModel:()=>Hf,FalconPreTrainedModel:()=>On,FastViTForImageClassification:()=>Jf,FastViTModel:()=>Yf,FastViTPreTrainedModel:()=>In,Florence2ForConditionalGeneration:()=>Zf,Florence2PreTrainedModel:()=>fl,GLPNForDepthEstimation:()=>mm,GLPNModel:()=>fm,GLPNPreTrainedModel:()=>Fn,GPT2LMHeadModel:()=>Am,GPT2Model:()=>Em,GPT2PreTrainedModel:()=>qn,GPTBigCodeForCausalLM:()=>gm,GPTBigCodeModel:()=>hm,GPTBigCodePreTrainedModel:()=>Rn,GPTJForCausalLM:()=>Sm,GPTJModel:()=>Mm,GPTJPreTrainedModel:()=>Un,GPTNeoForCausalLM:()=>wm,GPTNeoModel:()=>xm,GPTNeoPreTrainedModel:()=>Dn,GPTNeoXForCausalLM:()=>bm,GPTNeoXModel:()=>ym,GPTNeoXPreTrainedModel:()=>jn,Gemma2ForCausalLM:()=>rm,Gemma2Model:()=>sm,Gemma2PreTrainedModel:()=>Cn,Gemma3ForCausalLM:()=>am,Gemma3ForConditionalGeneration:()=>gl,Gemma3Model:()=>im,Gemma3PreTrainedModel:()=>hl,Gemma3nForCausalLM:()=>lm,Gemma3nForConditionalGeneration:()=>Zs,Gemma3nPreTrainedModel:()=>xl,GemmaForCausalLM:()=>tm,GemmaModel:()=>em,GemmaPreTrainedModel:()=>Tn,GlmForCausalLM:()=>pm,GlmModel:()=>cm,GlmMoeDsaForCausalLM:()=>_m,GlmMoeDsaModel:()=>um,GlmMoeDsaPreTrainedModel:()=>Nn,GlmOcrForConditionalGeneration:()=>dm,GlmPreTrainedModel:()=>Pn,GptOssForCausalLM:()=>vm,GptOssModel:()=>km,GptOssPreTrainedModel:()=>Bn,GraniteForCausalLM:()=>zm,GraniteModel:()=>Om,GraniteMoeHybridForCausalLM:()=>Tm,GraniteMoeHybridModel:()=>Im,GraniteMoeHybridPreTrainedModel:()=>Wn,GranitePreTrainedModel:()=>Gn,GraniteSpeechForConditionalGeneration:()=>Cm,GroundingDinoForObjectDetection:()=>Pm,GroundingDinoPreTrainedModel:()=>bl,GroupViTModel:()=>Nm,GroupViTPreTrainedModel:()=>kl,HeliumForCausalLM:()=>$m,HeliumModel:()=>Lm,HeliumPreTrainedModel:()=>Vn,HieraForImageClassification:()=>Rm,HieraModel:()=>Fm,HieraPreTrainedModel:()=>Hn,HubertForCTC:()=>Wm,HubertForSequenceClassification:()=>Vm,HubertModel:()=>Gm,HubertPreTrainedModel:()=>Um,HunYuanDenseV1ForCausalLM:()=>Km,HunYuanDenseV1Model:()=>Hm,HunYuanDenseV1PreTrainedModel:()=>Kn,IJepaForImageClassification:()=>Ym,IJepaModel:()=>Qm,IJepaPreTrainedModel:()=>Xn,Idefics3ForConditionalGeneration:()=>Xm,JAISLMHeadModel:()=>Zm,JAISModel:()=>Jm,JAISPreTrainedModel:()=>Qn,JinaCLIPModel:()=>eh,JinaCLIPPreTrainedModel:()=>tr,JinaCLIPTextModel:()=>Yn,JinaCLIPVisionModel:()=>th,Lfm2ForCausalLM:()=>rh,Lfm2Model:()=>sh,Lfm2MoeForCausalLM:()=>ih,Lfm2MoeModel:()=>oh,Lfm2MoePreTrainedModel:()=>Zn,Lfm2PreTrainedModel:()=>Jn,Lfm2VlForConditionalGeneration:()=>ah,LightOnOcrForConditionalGeneration:()=>nh,LiteWhisperForConditionalGeneration:()=>Yw,Llama4ForCausalLM:()=>ph,Llama4PreTrainedModel:()=>vl,LlamaForCausalLM:()=>ch,LlamaModel:()=>lh,LlamaPreTrainedModel:()=>eo,LlavaForConditionalGeneration:()=>Be,LlavaOnevisionForConditionalGeneration:()=>Be,LlavaPreTrainedModel:()=>ml,LlavaQwen2ForCausalLM:()=>om,LongT5ForConditionalGeneration:()=>_h,LongT5Model:()=>uh,LongT5PreTrainedModel:()=>to,M2M100ForConditionalGeneration:()=>fh,M2M100Model:()=>dh,M2M100PreTrainedModel:()=>so,MBartForCausalLM:()=>kh,MBartForConditionalGeneration:()=>yh,MBartForSequenceClassification:()=>bh,MBartModel:()=>wh,MBartPreTrainedModel:()=>ms,MPNetForMaskedLM:()=>lg,MPNetForQuestionAnswering:()=>ug,MPNetForSequenceClassification:()=>cg,MPNetForTokenClassification:()=>pg,MPNetModel:()=>ag,MPNetPreTrainedModel:()=>Wt,MT5ForConditionalGeneration:()=>mg,MT5Model:()=>fg,MT5PreTrainedModel:()=>ho,MarianMTModel:()=>hh,MarianModel:()=>mh,MarianPreTrainedModel:()=>ro,MaskFormerForInstanceSegmentation:()=>xh,MaskFormerModel:()=>gh,MaskFormerPreTrainedModel:()=>no,Metric3DForDepthEstimation:()=>vh,Metric3DPreTrainedModel:()=>El,Metric3Dv2ForDepthEstimation:()=>Eh,Metric3Dv2PreTrainedModel:()=>Al,MgpstrForSceneTextRecognition:()=>Ah,MgpstrModelOutput:()=>Ml,MgpstrPreTrainedModel:()=>Sl,MimiDecoderModel:()=>io,MimiDecoderOutput:()=>zl,MimiEncoderModel:()=>oo,MimiEncoderOutput:()=>Ol,MimiModel:()=>Mh,MimiPreTrainedModel:()=>sr,Mistral4ForCausalLM:()=>Ih,Mistral4Model:()=>zh,Mistral4PreTrainedModel:()=>lo,MistralForCausalLM:()=>Oh,MistralModel:()=>Sh,MistralPreTrainedModel:()=>ao,MobileBertForMaskedLM:()=>Ch,MobileBertForQuestionAnswering:()=>Nh,MobileBertForSequenceClassification:()=>Ph,MobileBertModel:()=>Th,MobileBertPreTrainedModel:()=>hs,MobileLLMForCausalLM:()=>$h,MobileLLMModel:()=>Lh,MobileLLMPreTrainedModel:()=>co,MobileNetV1ForImageClassification:()=>Rh,MobileNetV1ForSemanticSegmentation:()=>Dh,MobileNetV1Model:()=>Fh,MobileNetV1PreTrainedModel:()=>rr,MobileNetV2ForImageClassification:()=>Bh,MobileNetV2ForSemanticSegmentation:()=>qh,MobileNetV2Model:()=>jh,MobileNetV2PreTrainedModel:()=>nr,MobileNetV3ForImageClassification:()=>Gh,MobileNetV3ForSemanticSegmentation:()=>Wh,MobileNetV3Model:()=>Uh,MobileNetV3PreTrainedModel:()=>or,MobileNetV4ForImageClassification:()=>Hh,MobileNetV4ForSemanticSegmentation:()=>Kh,MobileNetV4Model:()=>Vh,MobileNetV4PreTrainedModel:()=>ir,MobileViTForImageClassification:()=>Qh,MobileViTModel:()=>Xh,MobileViTPreTrainedModel:()=>po,MobileViTV2ForImageClassification:()=>Jh,MobileViTV2Model:()=>Yh,MobileViTV2PreTrainedModel:()=>uo,ModernBertDecoderForCausalLM:()=>ng,ModernBertDecoderModel:()=>rg,ModernBertDecoderPreTrainedModel:()=>_o,ModernBertForMaskedLM:()=>eg,ModernBertForSequenceClassification:()=>tg,ModernBertForTokenClassification:()=>sg,ModernBertModel:()=>Zh,ModernBertPreTrainedModel:()=>gs,Moondream1ForConditionalGeneration:()=>nm,MoonshineForConditionalGeneration:()=>ig,MoonshineModel:()=>og,MoonshinePreTrainedModel:()=>fo,MptForCausalLM:()=>dg,MptModel:()=>_g,MptPreTrainedModel:()=>mo,MultiModalityCausalLM:()=>hg,MultiModalityPreTrainedModel:()=>Il,MusicgenForCausalLM:()=>xg,MusicgenForConditionalGeneration:()=>xo,MusicgenModel:()=>gg,MusicgenPreTrainedModel:()=>go,NanoChatForCausalLM:()=>yg,NanoChatModel:()=>wg,NanoChatPreTrainedModel:()=>wo,NemotronHForCausalLM:()=>kg,NemotronHModel:()=>bg,NemotronHPreTrainedModel:()=>yo,NeoBertForMaskedLM:()=>Eg,NeoBertForQuestionAnswering:()=>Sg,NeoBertForSequenceClassification:()=>Ag,NeoBertForTokenClassification:()=>Mg,NeoBertModel:()=>vg,NeoBertPreTrainedModel:()=>Vt,NomicBertModel:()=>Og,NomicBertPreTrainedModel:()=>Tl,OPTForCausalLM:()=>jg,OPTModel:()=>Dg,OPTPreTrainedModel:()=>Mo,Olmo2ForCausalLM:()=>Cg,Olmo2Model:()=>Tg,Olmo2PreTrainedModel:()=>ko,Olmo3ForCausalLM:()=>Ng,Olmo3Model:()=>Pg,Olmo3PreTrainedModel:()=>vo,OlmoForCausalLM:()=>Ig,OlmoHybridForCausalLM:()=>$g,OlmoHybridModel:()=>Lg,OlmoHybridPreTrainedModel:()=>Eo,OlmoModel:()=>zg,OlmoPreTrainedModel:()=>bo,OpenELMForCausalLM:()=>Rg,OpenELMModel:()=>Fg,OpenELMPreTrainedModel:()=>Ao,OwlViTForObjectDetection:()=>Gg,OwlViTModel:()=>Ug,OwlViTPreTrainedModel:()=>Oo,Owlv2ForObjectDetection:()=>qg,Owlv2Model:()=>Bg,Owlv2PreTrainedModel:()=>So,PaliGemmaForConditionalGeneration:()=>Wg,ParakeetForCTC:()=>Vg,ParakeetPreTrainedModel:()=>Cl,PatchTSMixerForPrediction:()=>Kg,PatchTSMixerModel:()=>Hg,PatchTSMixerPreTrainedModel:()=>zo,PatchTSTForPrediction:()=>Qg,PatchTSTModel:()=>Xg,PatchTSTPreTrainedModel:()=>Io,Phi3ForCausalLM:()=>ex,Phi3Model:()=>Zg,Phi3PreTrainedModel:()=>Co,Phi3VForCausalLM:()=>Po,Phi3VPreTrainedModel:()=>Pl,PhiForCausalLM:()=>Jg,PhiModel:()=>Yg,PhiPreTrainedModel:()=>To,PreTrainedModel:()=>f,PvtForImageClassification:()=>sx,PvtModel:()=>tx,PvtPreTrainedModel:()=>No,PyAnnoteForAudioFrameClassification:()=>nx,PyAnnoteModel:()=>rx,PyAnnotePreTrainedModel:()=>Lo,Qwen2ForCausalLM:()=>ix,Qwen2Model:()=>ox,Qwen2MoeForCausalLM:()=>lx,Qwen2MoeModel:()=>ax,Qwen2MoePreTrainedModel:()=>Fo,Qwen2PreTrainedModel:()=>$o,Qwen2VLForCausalLM:()=>Ln,Qwen2VLForConditionalGeneration:()=>er,Qwen2VLPreTrainedModel:()=>wl,Qwen2_5_VLForCausalLM:()=>$n,Qwen2_5_VLForConditionalGeneration:()=>ds,Qwen3ForCausalLM:()=>px,Qwen3Model:()=>cx,Qwen3MoeForCausalLM:()=>_x,Qwen3MoeModel:()=>ux,Qwen3MoePreTrainedModel:()=>Do,Qwen3NextForCausalLM:()=>fx,Qwen3NextModel:()=>dx,Qwen3NextPreTrainedModel:()=>jo,Qwen3PreTrainedModel:()=>Ro,Qwen3VLForCausalLM:()=>Bo,Qwen3VLForConditionalGeneration:()=>xs,Qwen3VLMoeForCausalLM:()=>hx,Qwen3VLMoeForConditionalGeneration:()=>mx,Qwen3_5ForCausalLM:()=>qo,Qwen3_5ForConditionalGeneration:()=>ar,Qwen3_5MoeForCausalLM:()=>xx,Qwen3_5MoeForConditionalGeneration:()=>gx,RFDetrForObjectDetection:()=>kx,RFDetrModel:()=>bx,RFDetrObjectDetectionOutput:()=>Nl,RFDetrPreTrainedModel:()=>Go,RTDetrForObjectDetection:()=>Ud,RTDetrModel:()=>qd,RTDetrObjectDetectionOutput:()=>ht,RTDetrPreTrainedModel:()=>hn,RTDetrV2ForObjectDetection:()=>Nx,RTDetrV2Model:()=>Px,RTDetrV2ObjectDetectionOutput:()=>Ll,RTDetrV2PreTrainedModel:()=>Wo,ResNetForImageClassification:()=>yx,ResNetModel:()=>wx,ResNetPreTrainedModel:()=>Uo,RoFormerForMaskedLM:()=>zx,RoFormerForQuestionAnswering:()=>Cx,RoFormerForSequenceClassification:()=>Ix,RoFormerForTokenClassification:()=>Tx,RoFormerModel:()=>Ox,RoFormerPreTrainedModel:()=>Kt,RobertaForMaskedLM:()=>Ex,RobertaForQuestionAnswering:()=>Sx,RobertaForSequenceClassification:()=>Ax,RobertaForTokenClassification:()=>Mx,RobertaModel:()=>vx,RobertaPreTrainedModel:()=>Ht,Sam2ImageSegmentationOutput:()=>Rl,Sam2Model:()=>Vo,Sam2PreTrainedModel:()=>Dl,Sam3TrackerModel:()=>Fx,SamImageSegmentationOutput:()=>$l,SamModel:()=>Lx,SamPreTrainedModel:()=>Fl,SapiensForDepthEstimation:()=>Dx,SapiensForNormalEstimation:()=>jx,SapiensForSemanticSegmentation:()=>Rx,SapiensPreTrainedModel:()=>lr,SegformerForImageClassification:()=>qx,SegformerForSemanticSegmentation:()=>Ux,SegformerModel:()=>Bx,SegformerPreTrainedModel:()=>cr,SiglipModel:()=>Gx,SiglipPreTrainedModel:()=>Ho,SiglipTextModel:()=>Ko,SiglipVisionModel:()=>Wx,SmolLM3ForCausalLM:()=>Hx,SmolLM3Model:()=>Vx,SmolLM3PreTrainedModel:()=>Xo,SnacDecoderModel:()=>Yo,SnacEncoderModel:()=>Qo,SnacModel:()=>Kx,SnacPreTrainedModel:()=>pr,SolarOpenForCausalLM:()=>Qx,SolarOpenModel:()=>Xx,SolarOpenPreTrainedModel:()=>Jo,SpeechT5ForSpeechToText:()=>Jx,SpeechT5ForTextToSpeech:()=>Zx,SpeechT5HifiGan:()=>ew,SpeechT5Model:()=>Yx,SpeechT5PreTrainedModel:()=>ur,SqueezeBertForMaskedLM:()=>sw,SqueezeBertForQuestionAnswering:()=>nw,SqueezeBertForSequenceClassification:()=>rw,SqueezeBertModel:()=>tw,SqueezeBertPreTrainedModel:()=>ws,StableLmForCausalLM:()=>iw,StableLmModel:()=>ow,StableLmPreTrainedModel:()=>Zo,Starcoder2ForCausalLM:()=>lw,Starcoder2Model:()=>aw,Starcoder2PreTrainedModel:()=>ei,StyleTextToSpeech2Model:()=>cw,StyleTextToSpeech2PreTrainedModel:()=>jl,SupertonicForConditionalGeneration:()=>ti,SupertonicPreTrainedModel:()=>Bl,Swin2SRForImageSuperResolution:()=>fw,Swin2SRModel:()=>dw,Swin2SRPreTrainedModel:()=>si,SwinForImageClassification:()=>uw,SwinForSemanticSegmentation:()=>_w,SwinModel:()=>pw,SwinPreTrainedModel:()=>_r,T5ForConditionalGeneration:()=>hw,T5Model:()=>mw,T5PreTrainedModel:()=>ri,TableTransformerForObjectDetection:()=>xw,TableTransformerModel:()=>gw,TableTransformerObjectDetectionOutput:()=>ql,TableTransformerPreTrainedModel:()=>ni,TrOCRForCausalLM:()=>ww,TrOCRPreTrainedModel:()=>Ul,UltravoxModel:()=>fs,UltravoxPreTrainedModel:()=>yl,UniSpeechForCTC:()=>bw,UniSpeechForSequenceClassification:()=>kw,UniSpeechModel:()=>yw,UniSpeechPreTrainedModel:()=>dr,UniSpeechSatForAudioFrameClassification:()=>Mw,UniSpeechSatForCTC:()=>Ew,UniSpeechSatForSequenceClassification:()=>Aw,UniSpeechSatModel:()=>vw,UniSpeechSatPreTrainedModel:()=>ys,VaultGemmaForCausalLM:()=>Ow,VaultGemmaModel:()=>Sw,VaultGemmaPreTrainedModel:()=>oi,ViTForImageClassification:()=>Tw,ViTMAEModel:()=>Cw,ViTMAEPreTrainedModel:()=>Gl,ViTMSNForImageClassification:()=>Nw,ViTMSNModel:()=>Pw,ViTMSNPreTrainedModel:()=>ai,ViTModel:()=>Iw,ViTPreTrainedModel:()=>ii,VisionEncoderDecoderModel:()=>zw,VitMatteForImageMatting:()=>Lw,VitMattePreTrainedModel:()=>Wl,VitPoseForPoseEstimation:()=>$w,VitPosePreTrainedModel:()=>Vl,VitsModel:()=>Fw,VitsModelOutput:()=>Hl,VitsPreTrainedModel:()=>Kl,VoxtralForConditionalGeneration:()=>Rw,VoxtralRealtimeForConditionalGeneration:()=>li,VoxtralRealtimePreTrainedModel:()=>Xl,Wav2Vec2BertForCTC:()=>qw,Wav2Vec2BertForSequenceClassification:()=>Uw,Wav2Vec2BertModel:()=>Bw,Wav2Vec2BertPreTrainedModel:()=>fr,Wav2Vec2ForAudioFrameClassification:()=>qm,Wav2Vec2ForCTC:()=>jm,Wav2Vec2ForSequenceClassification:()=>Bm,Wav2Vec2Model:()=>Dm,Wav2Vec2PreTrainedModel:()=>pt,WavLMForAudioFrameClassification:()=>Kw,WavLMForCTC:()=>Ww,WavLMForSequenceClassification:()=>Vw,WavLMForXVector:()=>Hw,WavLMModel:()=>Gw,WavLMPreTrainedModel:()=>Xt,WeSpeakerResNetModel:()=>Xw,WeSpeakerResNetPreTrainedModel:()=>Yl,WhisperForConditionalGeneration:()=>Zl,WhisperModel:()=>Qw,WhisperPreTrainedModel:()=>ci,XLMForQuestionAnswering:()=>sy,XLMForSequenceClassification:()=>ey,XLMForTokenClassification:()=>ty,XLMModel:()=>Jw,XLMPreTrainedModel:()=>Qt,XLMRobertaForMaskedLM:()=>ny,XLMRobertaForQuestionAnswering:()=>ay,XLMRobertaForSequenceClassification:()=>oy,XLMRobertaForTokenClassification:()=>iy,XLMRobertaModel:()=>ry,XLMRobertaPreTrainedModel:()=>Yt,XLMWithLMHeadModel:()=>Zw,XVectorOutput:()=>Ql,YolosForObjectDetection:()=>cy,YolosModel:()=>ly,YolosObjectDetectionOutput:()=>ec,YolosPreTrainedModel:()=>pi,YoutuForCausalLM:()=>uy,YoutuModel:()=>py,YoutuPreTrainedModel:()=>ui});var ps=class extends f{},F_=class extends ps{},R_=class extends ps{async _call(e){return new z(await super._call(e))}},D_=class extends ps{async _call(e){return new ce(await super._call(e))}},j_=class extends ps{async _call(e){return new re(await super._call(e))}};var Qr=class extends f{},B_=class extends Qr{},q_=class extends Qr{};var Yr=class extends f{},U_=class extends Yr{},G_=class extends Yr{};var Jr=class extends f{},W_=class extends Jr{},V_=class extends Jr{};var Zr=class extends f{},H_=class extends Zr{},K_=class extends Zr{};var Ks=class extends f{},X_=class extends Ks{},Q_=class extends Ks{},Y_=class extends Ks{async _call(e){return new z(await super._call(e))}};var en=class extends f{},J_=class extends en{},Z_=class extends en{async _call(e){return new z(await super._call(e))}};var Rt=class extends f{},ed=class extends Rt{},td=class extends Rt{async _call(e){return new re(await super._call(e))}},sd=class extends Rt{async _call(e){return new z(await super._call(e))}},rd=class extends Rt{async _call(e){return new ee(await super._call(e))}},nd=class extends Rt{async _call(e){return new ce(await super._call(e))}};var tn=class extends f{},od=class extends tn{},id=class extends tn{};var sn=class extends f{},ad=class extends sn{},ld=class extends sn{};var rn=class extends f{},cd=class extends rn{},pd=class extends rn{};var Dt=class extends f{},ud=class extends Dt{},_d=class extends Dt{async _call(e){return new re(await super._call(e))}},dd=class extends Dt{async _call(e){return new z(await super._call(e))}},fd=class extends Dt{async _call(e){return new ee(await super._call(e))}},md=class extends Dt{async _call(e){return new ce(await super._call(e))}};var KA=4299n,xb=6561n,sl=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","audio_values","exaggeration","audio_features","audio_tokens","speaker_embeddings","speaker_features","past_key_values"];main_input_name="input_ids";_return_dict_in_generate_keys=["audio_tokens","speaker_embeddings","speaker_features"]},nn=class extends sl{async encode_speech(e){return X(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:s=null,audio_values:r=null,exaggeration:n=null,position_ids:o=null,inputs_embeds:i=null,past_key_values:a=null,generation_config:l=null,logits_processor:c=null,audio_features:p=null,audio_tokens:u=null,speaker_embeddings:_=null,speaker_features:d=null,...m}){let h;if(!i){let x=this.sessions.embed_tokens.inputNames,w={input_ids:e};if(x.includes("exaggeration")){if(!(n instanceof E)){let y=e.dims[0];if(n==null)n=be([y],.5);else if(typeof n=="number")n=be([y],n);else if(Array.isArray(n))n=new E("float32",n,[y]);else throw new Error("Unsupported type for `exaggeration` input")}w.exaggeration=n}if(x.includes("position_ids")&&(w.position_ids=o),{inputs_embeds:i}=await X(this.sessions.embed_tokens,w),p&&u&&_&&d&&(h={audio_features:p,audio_tokens:u,speaker_embeddings:_,speaker_features:d}),h||r)h??=await this.encode_speech(r),i=oe([h.audio_features,i],1),s=Ae([i.dims[0],i.dims[1]]);else{let y=i.dims[1];if(!a||y!==1)throw new Error("Incorrect state encountered during generation.");let b=a.get_seq_length();s=Ae([i.dims[0],b+y])}}return{...await Ge(this,{inputs_embeds:i,past_key_values:a,attention_mask:s,generation_config:l,logits_processor:c},!1),...h}}prepare_inputs_for_generation(e,s,r){if(!s.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(s.input_ids.dims[1]===1){let n=Array.from({length:e.length},(o,i)=>e[i].length-e[i].findLastIndex(a=>a==xb)-1);s.position_ids=new E("int64",n,[e.length,1])}else{let o=s.input_ids.tolist().map(i=>{let a=0;return i.map(l=>l>=xb?0:a++)});s.position_ids=new E("int64",o.flat(),s.input_ids.dims)}return s.input_ids.dims[1]===1&&(delete s.audio_values,delete s.audio_features,delete s.audio_tokens,delete s.speaker_embeddings,delete s.speaker_features),Vs(this,e,s,r)}async generate(e){let{sequences:s,audio_tokens:r,speaker_embeddings:n,speaker_features:o}=await super.generate({...e,return_dict_in_generate:!0}),i=s.slice(null,[e.input_ids.dims[1],-1]),a=be([i.dims[0],3],KA),l=oe([r,i,a],1),{waveform:c}=await X(this.sessions.conditional_decoder,{speech_tokens:l,speaker_features:o,speaker_embeddings:n});return c}};var rl=class extends f{},hd=class extends rl{};var nl=class extends f{},gd=class extends nl{};var Xs=class extends f{},xd=class extends Xs{},on=class extends Xs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},an=class extends Xs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"audio_model"})}};var mt=class extends f{},wd=class extends mt{},yd=class extends mt{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},ln=class extends mt{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},bd=class extends mt{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}},kd=class extends mt{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var cn=class extends f{},vd=class extends cn{},Ed=class extends cn{};var pn=class extends f{},Ad=class extends pn{},Md=class extends pn{};var un=class extends f{},Sd=class extends un{},Od=class extends un{};var _n=class extends f{},zd=class extends _n{},Id=class extends _n{};var dn=class extends f{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","decoder_input_ids","decoder_attention_mask","past_key_values"]},Td=class extends dn{},Cd=class extends dn{};var jt=class extends f{},Pd=class extends jt{},Nd=class extends jt{async _call(e){return new re(await super._call(e))}},Ld=class extends jt{async _call(e){return new z(await super._call(e))}},$d=class extends jt{async _call(e){return new ee(await super._call(e))}},Fd=class extends jt{async _call(e){return new ce(await super._call(e))}};var fn=class extends f{},Rd=class extends fn{},Dd=class extends fn{async _call(e){return new z(await super._call(e))}};var mn=class extends f{},jd=class extends mn{},Bd=class extends mn{async _call(e){return new z(await super._call(e))}};var hn=class extends f{},qd=class extends hn{},Ud=class extends hn{async _call(e){return new ht(await super._call(e))}},ht=class extends me{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}};var gn=class extends f{},Gd=class extends gn{},Wd=class extends gn{async _call(e){return new ht(await super._call(e))}};var ol=class extends me{constructor({audio_codes:e}){super(),this.audio_codes=e}},il=class extends me{constructor({audio_values:e}){super(),this.audio_values=e}},Qs=class extends f{main_input_name="input_values";forward_params=["input_values"]},Vd=class extends Qs{async encode(e){return new ol(await X(this.sessions.encoder_model,e))}async decode(e){return new il(await X(this.sessions.decoder_model,e))}},xn=class extends Qs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},wn=class extends Qs{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var Bt=class extends f{},Hd=class extends Bt{},Kd=class extends Bt{async _call(e){return new re(await super._call(e))}},Xd=class extends Bt{async _call(e){return new z(await super._call(e))}},Qd=class extends Bt{async _call(e){return new ee(await super._call(e))}},Yd=class extends Bt{async _call(e){return new ce(await super._call(e))}};var yn=class extends f{},Jd=class extends yn{},Zd=class extends yn{};var qt=class extends f{},ef=class extends qt{},tf=class extends qt{async _call(e){return new re(await super._call(e))}},sf=class extends qt{async _call(e){return new z(await super._call(e))}},rf=class extends qt{async _call(e){return new ee(await super._call(e))}},nf=class extends qt{async _call(e){return new ce(await super._call(e))}};var al=class extends f{},of=class extends al{};var bn=class extends f{},af=class extends bn{},lf=class extends bn{async _call(e){return new z(await super._call(e))}};var ll=class extends f{},cf=class extends ll{};var cl=class extends f{},pf=class extends cl{};var Ys=class extends f{},uf=class extends Ys{},_f=class extends Ys{async _call(e){return new Js(await super._call(e))}},df=class extends Ys{async _call(e){return new pl(await super._call(e))}},Js=class extends me{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}},pl=class extends me{constructor({logits:e,pred_boxes:s,pred_masks:r}){super(),this.logits=e,this.pred_boxes=s,this.pred_masks=r}};var kn=class extends f{},ff=class extends kn{},mf=class extends kn{async _call(e){return new z(await super._call(e))}};var vn=class extends f{},hf=class extends vn{},gf=class extends vn{async _call(e){return new z(await super._call(e))}};var ul=class extends f{},xf=class extends ul{};var _l=class extends f{},wf=class extends _l{};var Ut=class extends f{},yf=class extends Ut{},bf=class extends Ut{async _call(e){return new z(await super._call(e))}},kf=class extends Ut{async _call(e){return new ee(await super._call(e))}},vf=class extends Ut{async _call(e){return new ce(await super._call(e))}},Ef=class extends Ut{async _call(e){return new re(await super._call(e))}};var dl=class extends f{},Af=class extends dl{};var En=class extends f{},Mf=class extends En{},Sf=class extends En{};var An=class extends f{},Of=class extends An{},zf=class extends An{async _call(e){return new z(await super._call(e))}};var Gt=class extends f{},If=class extends Gt{},Tf=class extends Gt{async _call(e){return new re(await super._call(e))}},Cf=class extends Gt{async _call(e){return new z(await super._call(e))}},Pf=class extends Gt{async _call(e){return new ee(await super._call(e))}},Nf=class extends Gt{async _call(e){return new ce(await super._call(e))}};var Mn=class extends f{},Lf=class extends Mn{},$f=class extends Mn{};var us=class extends f{},Ff=class extends us{},Rf=class extends us{async _call(e){return new re(await super._call(e))}},Df=class extends us{async _call(e){return new z(await super._call(e))}},jf=class extends us{async _call(e){return new ee(await super._call(e))}};var _s=class extends f{},Bf=class extends _s{},qf=class extends _s{async _call(e){return new re(await super._call(e))}},Uf=class extends _s{async _call(e){return new z(await super._call(e))}},Gf=class extends _s{async _call(e){return new ee(await super._call(e))}};var Sn=class extends f{},Wf=class extends Sn{},Vf=class extends Sn{};var On=class extends f{},Hf=class extends On{},Kf=class extends On{};var zn=class extends f{},Xf=class extends zn{},Qf=class extends zn{};var In=class extends f{},Yf=class extends In{},Jf=class extends In{async _call(e){return new z(await super._call(e))}};var fl=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","pixel_values","encoder_outputs","decoder_input_ids","decoder_inputs_embeds","decoder_attention_mask","past_key_values"];main_input_name="inputs_embeds"},Zf=class extends fl{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:s,input_ids:r,attention_mask:n}){return{inputs_embeds:oe([s,e],1),attention_mask:oe([Ae(s.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:s,inputs_embeds:r,attention_mask:n}){if(!e&&!s)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let o,i;return e&&(o=await this.encode_text({input_ids:e})),s&&(i=await this.encode_image({pixel_values:s})),o&&i?{inputs_embeds:r,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:o,image_features:i,input_ids:e,attention_mask:n}):r=o||i,{inputs_embeds:r,attention_mask:n}}async forward({input_ids:e,pixel_values:s,attention_mask:r,decoder_input_ids:n,decoder_attention_mask:o,encoder_outputs:i,past_key_values:a,inputs_embeds:l,decoder_inputs_embeds:c}){if(l||({inputs_embeds:l,attention_mask:r}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:s,inputs_embeds:l,attention_mask:r})),!i){let{last_hidden_state:u}=await st(this,{inputs_embeds:l,attention_mask:r});i=u}if(!c){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:n})}return await Ge(this,{inputs_embeds:c,attention_mask:o,encoder_attention_mask:r,encoder_hidden_states:i,past_key_values:a},!0)}};var Tn=class extends f{},em=class extends Tn{},tm=class extends Tn{};var Cn=class extends f{},sm=class extends Cn{},rm=class extends Cn{};var ml=class extends f{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Be=class extends ml{_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return Hs({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:r})}},nm=class extends Be{},om=class extends Be{};var hl=class extends f{},im=class extends hl{},gl=class extends Be{},am=class extends gl{};var xl=class extends f{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},Zs=class extends xl{async forward({input_ids:e=null,attention_mask:s=null,pixel_values:r=null,input_features:n=null,input_features_mask:o=null,position_ids:i=null,inputs_embeds:a=null,per_layer_inputs:l=null,past_key_values:c=null,generation_config:p=null,logits_processor:u=null,..._}){if((!a||!l)&&({inputs_embeds:a,per_layer_inputs:l}=await X(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(r){let{image_features:m}=await X(this.sessions.vision_encoder,{pixel_values:r});({inputs_embeds:a,attention_mask:s}=this._merge_input_ids_with_image_features({image_features:m,inputs_embeds:a,input_ids:e,attention_mask:s}))}if(n){let{audio_features:m}=await X(this.sessions.audio_encoder,{input_features:n,input_features_mask:o});({inputs_embeds:a,attention_mask:s}=this._merge_input_ids_with_audio_features({audio_features:m,inputs_embeds:a,input_ids:e,attention_mask:s}))}}return await Ge(this,{inputs_embeds:a,per_layer_inputs:l,past_key_values:c,attention_mask:s,position_ids:i,generation_config:p,logits_processor:u},!0)}_merge_input_ids_with_image_features(e){let s=e.image_features.dims.at(-1),r=e.image_features.view(-1,s);return Hs({image_token_id:this.config.image_token_id,...e,image_features:r})}_merge_input_ids_with_audio_features(e){let s=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,s);return tl({audio_token_id:this.config.audio_token_id,...e,audio_features:r})}},lm=class extends Zs{};var Pn=class extends f{},cm=class extends Pn{},pm=class extends Pn{};var Nn=class extends f{},um=class extends Nn{},_m=class extends Nn{};var wl=class extends f{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},er=class extends wl{image_grid_thw_name="grid_thw";_get_text_only_rope_index(e,s){if(s){let{data:r,dims:n}=$_(s),o=BigInt64Array.from({length:3*r.length},(a,l)=>r[l%r.length]),i=Array.from({length:n[0]},(a,l)=>ue(r.subarray(n[1]*l,n[1]*(l+1)))[0]+1n+BigInt(n[1]));return[new E("int64",o,[3,...n]),new E("int64",i,[i.length,1])]}else{let[r,n]=e.dims,o=BigInt64Array.from({length:3*r*n},(i,a)=>BigInt(Math.floor(a%n/r)));return[new E("int64",o,[3,...e.dims]),Qc([r,1])]}}_reorder_and_write_positions(e,s,r,n){let o=e.reduce((c,p)=>c+p.length,0),i=new Array(o),a=0;for(let c=0;c<3;++c)for(let p of e){let u=p.length/3;for(let _=c*u;_<(c+1)*u;++_)i[a++]=p[_]}let l=0;for(let c=0;c<s.length;++c)if(s[c]==1){for(let p=0;p<3;++p)r[p][n][c]=i[p*o/3+l];++l}return i}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:s,video_grid_thw_list:r,spatial_merge_size:n,state:o}){let{image_token_id:i,video_token_id:a,vision_start_token_id:l}=this.config,c=e,u=c.reduce((w,y,b)=>(y==l&&w.push(b),w),[]).map(w=>c[w+1]),_=u.filter(w=>w==i).length,d=u.filter(w=>w==a).length,m=[],h=0,g=_,x=d;for(let w=0;w<u.length;++w){let y=c.findIndex((H,he)=>he>h&&H==i),b=c.findIndex((H,he)=>he>h&&H==a),v=g>0&&y!==-1?y:c.length+1,k=x>0&&b!==-1?b:c.length+1,O,N,q,P;v<k?([N,q,P]=s[o.image_index],++o.image_index,--g,O=v):([N,q,P]=r[o.video_index],++o.video_index,--x,O=k);let[R,F,U]=[Number(N),Math.floor(Number(q)/n),Math.floor(Number(P)/n)],j=O-h,W=m.length>0?ue(m.at(-1))[0]+1:0;m.push(Array.from({length:3*j},(H,he)=>W+he%j));let Z=j+W,te=R*F*U,M=Array.from({length:te},(H,he)=>Z+Math.floor(he/(F*U))),S=Array.from({length:te},(H,he)=>Z+Math.floor(he/U)%F),T=Array.from({length:te},(H,he)=>Z+he%U);m.push([M,S,T].flat()),h=O+te}if(h<c.length){let w=m.length>0?ue(m.at(-1))[0]+1:0,y=c.length-h;m.push(Array.from({length:3*y},(b,v)=>w+v%y))}return m}get_rope_index(e,s,r,n){let{vision_config:o}=this.config,i=o.spatial_merge_size??2;if(s||r){let a=e.tolist();n||(n=ca(e));let l=n.tolist(),c=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),p=s?s.tolist():[],u=r?r.tolist():[],_={image_index:0,video_index:0},d=[];for(let m=0;m<a.length;++m){let h=a[m].filter((w,y)=>l[m][y]==1),g=this._get_multimodal_rope_positions({filtered_ids:h,image_grid_thw_list:p,video_grid_thw_list:u,spatial_merge_size:i,state:_}),x=this._reorder_and_write_positions(g,l[m],c,m);d.push(ue(x)[0]+1-a[m].length)}return[new E("int64",c.flat(1/0),[3,e.dims[0],e.dims[1]]),new E("int64",d,[d.length,1])]}else return this._get_text_only_rope_index(e,n)}async encode_image({pixel_values:e,image_grid_thw:s}){return(await X(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:s})).image_features}_merge_input_ids_with_image_features(e){return Hs({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,s,r){if(!s.attention_mask||s.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes("position_ids"))return s;if(!s.past_key_values)[s.position_ids,s.rope_deltas]=this.get_rope_index(s.input_ids,s.image_grid_thw,s.video_grid_thw,s.attention_mask);else{s.pixel_values=null;let o=s.past_key_values.get_seq_length();if(o<s.input_ids.dims[1]){let[i,a]=this.get_rope_index(s.input_ids,s.image_grid_thw,s.video_grid_thw,s.attention_mask);s.rope_deltas=a,s.position_ids=i.slice(null,null,[o,null]),s.input_ids=s.input_ids.slice(null,[o,null])}else{s.rope_deltas||([,s.rope_deltas]=this.get_rope_index(s.input_ids,s.image_grid_thw,s.video_grid_thw,s.attention_mask));let i=BigInt(o),a=s.rope_deltas.map(l=>i+l);s.position_ids=Ue([a,a,a],0)}}return s}},Ln=class extends er{};var ds=class extends er{image_grid_thw_name="image_grid_thw"},$n=class extends Ln{image_grid_thw_name="image_grid_thw"};var dm=class extends ds{get_vision_position_ids(e,s,r,n){let o=Math.floor(s[0]/r),i=Math.floor(s[1]/n),a=Math.floor(s[2]/n),l=i*a*o,c=Array.from({length:l},()=>e),p=Array.from({length:l},(_,d)=>e+Math.floor(d/(a*o))),u=Array.from({length:l},(_,d)=>e+d%a);return[...c,...p,...u]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:s,video_grid_thw_list:r,spatial_merge_size:n,state:o}){let{image_token_id:i}=this.config,a=[],l=0,c=e[0]==i?1:0;for(let _=1;_<=e.length;++_){let d=_<e.length?e[_]==i?1:0:-1;d!==c&&(a.push([c,l,_]),l=_,c=d)}let p=0,u=[];for(let[_,d,m]of a)if(_===0){let h=m-d;u.push(Array.from({length:3*h},(g,x)=>p+x%h)),p+=h}else{let h=s[o.image_index++].map(Number),g=h[0];u.push(this.get_vision_position_ids(p,h,g,n)),p+=Math.max(h[1],h[2])/n}return u}};var Fn=class extends f{},fm=class extends Fn{},mm=class extends Fn{};var Rn=class extends f{},hm=class extends Rn{},gm=class extends Rn{};var Dn=class extends f{},xm=class extends Dn{},wm=class extends Dn{};var jn=class extends f{},ym=class extends jn{},bm=class extends jn{};var Bn=class extends f{},km=class extends Bn{},vm=class extends Bn{};var qn=class extends f{},Em=class extends qn{},Am=class extends qn{};var Un=class extends f{},Mm=class extends Un{},Sm=class extends Un{};var Gn=class extends f{},Om=class extends Gn{},zm=class extends Gn{};var Wn=class extends f{},Im=class extends Wn{},Tm=class extends Wn{};var yl=class extends f{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},fs=class extends yl{_merge_input_ids_with_audio_features(e){let s=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,s);return tl({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:r})}};var Cm=class extends fs{forward_params=["input_ids","attention_mask","input_features","past_key_values"]};var bl=class extends f{},Pm=class extends bl{};var kl=class extends f{},Nm=class extends kl{};var Vn=class extends f{},Lm=class extends Vn{},$m=class extends Vn{};var Hn=class extends f{},Fm=class extends Hn{},Rm=class extends Hn{async _call(e){return new z(await super._call(e))}};var pt=class extends f{},Dm=class extends pt{},jm=class extends pt{async _call(e){return new je(await super._call(e))}},Bm=class extends pt{async _call(e){return new z(await super._call(e))}},qm=class extends pt{async _call(e){return new ee(await super._call(e))}};var Um=class extends f{},Gm=class extends pt{},Wm=class extends pt{async _call(e){return new je(await super._call(e))}},Vm=class extends pt{async _call(e){return new z(await super._call(e))}};var Kn=class extends f{},Hm=class extends Kn{},Km=class extends Kn{};var Xm=class extends Be{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]};var Xn=class extends f{},Qm=class extends Xn{},Ym=class extends Xn{async _call(e){return new z(await super._call(e))}};var Qn=class extends f{},Jm=class extends Qn{},Zm=class extends Qn{};var tr=class extends f{},eh=class extends tr{async forward(e){let s=!e.input_ids,r=!e.pixel_values;if(s&&r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(s&&(e.input_ids=Ae([e.pixel_values.dims[0],1])),r){let{image_size:c}=this.config.vision_config;e.pixel_values=be([0,3,c,c],0)}let{text_embeddings:n,image_embeddings:o,l2norm_text_embeddings:i,l2norm_image_embeddings:a}=await super.forward(e),l={};return s||(l.text_embeddings=n,l.l2norm_text_embeddings=i),r||(l.image_embeddings=o,l.l2norm_image_embeddings=a),l}},Yn=class extends tr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},th=class extends tr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var Jn=class extends f{},sh=class extends Jn{},rh=class extends Jn{};var nh=class extends Be{};var Zn=class extends f{},oh=class extends Zn{},ih=class extends Zn{};var ah=class extends Be{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]};var eo=class extends f{},lh=class extends eo{},ch=class extends eo{};var vl=class extends f{},ph=class extends vl{};var to=class extends f{},uh=class extends to{},_h=class extends to{};var so=class extends f{},dh=class extends so{},fh=class extends so{};var ro=class extends f{},mh=class extends ro{},hh=class extends ro{};var no=class extends f{},gh=class extends no{},xh=class extends no{};var ms=class extends f{},wh=class extends ms{},yh=class extends ms{},bh=class extends ms{async _call(e){return new z(await super._call(e))}},kh=class extends ms{};var El=class extends f{},vh=class extends El{};var Al=class extends f{},Eh=class extends Al{};var Ml=class extends me{constructor({char_logits:e,bpe_logits:s,wp_logits:r}){super(),this.char_logits=e,this.bpe_logits=s,this.wp_logits=r}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},Sl=class extends f{},Ah=class extends Sl{async _call(e){return new Ml(await super._call(e))}};var Ol=class extends me{constructor({audio_codes:e}){super(),this.audio_codes=e}},zl=class extends me{constructor({audio_values:e}){super(),this.audio_values=e}},sr=class extends f{main_input_name="input_values";forward_params=["input_values"]},Mh=class extends sr{async encode(e){return new Ol(await X(this.sessions.encoder_model,e))}async decode(e){return new zl(await X(this.sessions.decoder_model,e))}},oo=class extends sr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},io=class extends sr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var ao=class extends f{},Sh=class extends ao{},Oh=class extends ao{};var lo=class extends f{},zh=class extends lo{},Ih=class extends lo{};var hs=class extends f{},Th=class extends hs{},Ch=class extends hs{async _call(e){return new re(await super._call(e))}},Ph=class extends hs{async _call(e){return new z(await super._call(e))}},Nh=class extends hs{async _call(e){return new ce(await super._call(e))}};var co=class extends f{},Lh=class extends co{},$h=class extends co{};var rr=class extends f{},Fh=class extends rr{},Rh=class extends rr{async _call(e){return new z(await super._call(e))}},Dh=class extends rr{};var nr=class extends f{},jh=class extends nr{},Bh=class extends nr{async _call(e){return new z(await super._call(e))}},qh=class extends nr{};var or=class extends f{},Uh=class extends or{},Gh=class extends or{async _call(e){return new z(await super._call(e))}},Wh=class extends or{};var ir=class extends f{},Vh=class extends ir{},Hh=class extends ir{async _call(e){return new z(await super._call(e))}},Kh=class extends ir{};var po=class extends f{},Xh=class extends po{},Qh=class extends po{async _call(e){return new z(await super._call(e))}};var uo=class extends f{},Yh=class extends uo{},Jh=class extends uo{async _call(e){return new z(await super._call(e))}};var gs=class extends f{},Zh=class extends gs{},eg=class extends gs{async _call(e){return new re(await super._call(e))}},tg=class extends gs{async _call(e){return new z(await super._call(e))}},sg=class extends gs{async _call(e){return new ee(await super._call(e))}};var _o=class extends f{},rg=class extends _o{},ng=class extends _o{};var fo=class extends f{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},og=class extends fo{},ig=class extends fo{};var Wt=class extends f{},ag=class extends Wt{},lg=class extends Wt{async _call(e){return new re(await super._call(e))}},cg=class extends Wt{async _call(e){return new z(await super._call(e))}},pg=class extends Wt{async _call(e){return new ee(await super._call(e))}},ug=class extends Wt{async _call(e){return new ce(await super._call(e))}};var mo=class extends f{},_g=class extends mo{},dg=class extends mo{};var ho=class extends f{},fg=class extends ho{},mg=class extends ho{};var Il=class extends f{},hg=class extends Il{forward_params=["input_ids","pixel_values","images_seq_mask","images_emb_mask","attention_mask","position_ids","past_key_values"];constructor(...e){super(...e),this._generation_mode="text"}async forward(e){let s=this._generation_mode??"text",r;if(s==="text"||!e.past_key_values){let l=this.sessions.prepare_inputs_embeds,c=ke(e,l.inputNames);r=await X(l,c)}else{let l=this.sessions.gen_img_embeds,c=ke({image_ids:e.input_ids},l.inputNames);r=await X(l,c)}let n={...e,...r},o=await Ge(this,n),i=this.sessions[s==="text"?"lm_head":"gen_head"];if(!i)throw new Error(`Unable to find "${i}" generation head`);let a=await X(i,ke(o,i.inputNames));return{...r,...o,...a}}prepare_inputs_for_generation(e,s,r){let n=!!s.past_key_values;return r.guidance_scale!==null&&r.guidance_scale>1&&(n?s.input_ids=oe([s.input_ids,s.input_ids],0):(s.input_ids=oe([s.input_ids,Pr(s.input_ids,BigInt(r.pad_token_id))],0),s.attention_mask=oe([s.attention_mask,Pr(s.attention_mask,0n)],0))),(n||!s.pixel_values)&&(s.pixel_values=be([0,0,3,384,384],1)),n&&(s.images_seq_mask=new E("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),s.images_emb_mask=new E("bool",new Array(0).fill(!1),[1,1,0])),s}async generate(e){return this._generation_mode="text",super.generate(e)}async generate_images(e){this._generation_mode="image";let s=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[s,null]),o=this.sessions.image_decode,{decoded_image:i}=await X(o,{generated_tokens:n}),a=i.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),l=[];for(let c of a){let p=ve.fromTensor(c);l.push(p)}return l}};var go=class extends f{},gg=class extends go{},xg=class extends go{},xo=class extends f{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];_apply_and_filter_by_delay_pattern_mask(e){let[s,r]=e.dims,n=this.config.decoder.num_codebooks,o=r-n,i=0;for(let c=0;c<e.size;++c){if(e.data[c]==this.config.decoder.pad_token_id)continue;let p=c%r,u=Math.floor(c/r)%n,_=p-u;_>0&&_<=o&&(e.data[i++]=e.data[c])}let a=Math.floor(s/n),l=i/(a*n);return new E(e.type,e.data.slice(0,i),[a,n,l])}prepare_inputs_for_generation(e,s,r){let n=BigInt(this.config.decoder.pad_token_id),o=structuredClone(e);for(let i=0;i<o.length;++i)for(let a=0;a<o[i].length;++a)i%this.config.decoder.num_codebooks>=a&&(o[i][a]=n);return r.guidance_scale!==null&&r.guidance_scale>1&&(o=o.concat(o)),Xr(this,o,s,r)}async generate(e){let s=await super.generate(e),r=this._apply_and_filter_by_delay_pattern_mask(s).unsqueeze_(0),{audio_values:n}=await X(this.sessions.encodec_decode,{audio_codes:r});return n}};var wo=class extends f{},wg=class extends wo{},yg=class extends wo{};var yo=class extends f{},bg=class extends yo{},kg=class extends yo{};var Vt=class extends f{},vg=class extends Vt{},Eg=class extends Vt{async _call(e){return new re(await super._call(e))}},Ag=class extends Vt{async _call(e){return new z(await super._call(e))}},Mg=class extends Vt{async _call(e){return new ee(await super._call(e))}},Sg=class extends Vt{async _call(e){return new ce(await super._call(e))}};var Tl=class extends f{},Og=class extends Tl{};var bo=class extends f{},zg=class extends bo{},Ig=class extends bo{};var ko=class extends f{},Tg=class extends ko{},Cg=class extends ko{};var vo=class extends f{},Pg=class extends vo{},Ng=class extends vo{};var Eo=class extends f{},Lg=class extends Eo{},$g=class extends Eo{};var Ao=class extends f{},Fg=class extends Ao{},Rg=class extends Ao{};var Mo=class extends f{},Dg=class extends Mo{},jg=class extends Mo{};var So=class extends f{},Bg=class extends So{},qg=class extends So{};var Oo=class extends f{},Ug=class extends Oo{},Gg=class extends Oo{};var Wg=class extends Be{};var Cl=class extends f{},Vg=class extends Cl{async _call(e){return new je(await super._call(e))}};var zo=class extends f{},Hg=class extends zo{},Kg=class extends zo{};var Io=class extends f{},Xg=class extends Io{},Qg=class extends Io{};var To=class extends f{},Yg=class extends To{},Jg=class extends To{};var Co=class extends f{},Zg=class extends Co{},ex=class extends Co{};var Pl=class extends f{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},Po=class extends Pl{async forward({input_ids:e=null,attention_mask:s=null,pixel_values:r=null,image_sizes:n=null,position_ids:o=null,inputs_embeds:i=null,past_key_values:a=null,generation_config:l=null,logits_processor:c=null,...p}){if(!i){let _;if(r&&e.dims[1]!==1){if(!n)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:_}=await X(this.sessions.vision_encoder,{pixel_values:r,image_sizes:n}))}else{let d=this.config.normalized_config.hidden_size;_=new E("float32",[],[0,d])}({inputs_embeds:i}=await X(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:_}))}return await Ge(this,{inputs_embeds:i,past_key_values:a,attention_mask:s,position_ids:o,generation_config:l,logits_processor:c},!1)}};var No=class extends f{},tx=class extends No{},sx=class extends No{async _call(e){return new z(await super._call(e))}};var Lo=class extends f{},rx=class extends Lo{},nx=class extends Lo{async _call(e){return new ee(await super._call(e))}};var $o=class extends f{},ox=class extends $o{},ix=class extends $o{};var Fo=class extends f{},ax=class extends Fo{},lx=class extends Fo{};var Ro=class extends f{},cx=class extends Ro{},px=class extends Ro{};var Do=class extends f{},ux=class extends Do{},_x=class extends Do{};var jo=class extends f{},dx=class extends jo{},fx=class extends jo{};var xs=class extends ds{},Bo=class extends $n{};var mx=class extends xs{},hx=class extends Bo{};var ar=class extends xs{},qo=class extends ar{};var gx=class extends ar{},xx=class extends qo{};var Uo=class extends f{},wx=class extends Uo{},yx=class extends Uo{async _call(e){return new z(await super._call(e))}};var Go=class extends f{},bx=class extends Go{},kx=class extends Go{async _call(e){return new Nl(await super._call(e))}},Nl=class extends ht{};var Ht=class extends f{},vx=class extends Ht{},Ex=class extends Ht{async _call(e){return new re(await super._call(e))}},Ax=class extends Ht{async _call(e){return new z(await super._call(e))}},Mx=class extends Ht{async _call(e){return new ee(await super._call(e))}},Sx=class extends Ht{async _call(e){return new ce(await super._call(e))}};var Kt=class extends f{},Ox=class extends Kt{},zx=class extends Kt{async _call(e){return new re(await super._call(e))}},Ix=class extends Kt{async _call(e){return new z(await super._call(e))}},Tx=class extends Kt{async _call(e){return new ee(await super._call(e))}},Cx=class extends Kt{async _call(e){return new ce(await super._call(e))}};var Wo=class extends f{},Px=class extends Wo{},Nx=class extends Wo{async _call(e){return new Ll(await super._call(e))}},Ll=class extends ht{};var $l=class extends me{constructor({iou_scores:e,pred_masks:s}){super(),this.iou_scores=e,this.pred_masks=s}},Fl=class extends f{},Lx=class extends Fl{async get_image_embeddings({pixel_values:e}){return await st(this,{pixel_values:e})}async forward(e){!e.image_embeddings||!e.image_positional_embeddings?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_labels??=Ae(e.input_points.dims.slice(0,-1));let s={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(s.input_points=e.input_points),e.input_labels&&(s.input_labels=e.input_labels),e.input_boxes&&(s.input_boxes=e.input_boxes),await X(this.sessions.prompt_encoder_mask_decoder,s)}async _call(e){return new $l(await super._call(e))}};var Rl=class extends me{constructor({iou_scores:e,pred_masks:s,object_score_logits:r}){super(),this.iou_scores=e,this.pred_masks=s,this.object_score_logits=r}},Dl=class extends f{},Vo=class extends Dl{async get_image_embeddings({pixel_values:e}){return await st(this,{pixel_values:e})}async forward(e){let{num_feature_levels:s}=this.config.vision_config;if(Array.from({length:s},(i,a)=>`image_embeddings.${a}`).some(i=>!e[i])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let i=e.input_points.dims;e.input_labels??=Ae(i.slice(0,-1)),e.input_boxes??=be([i[0],0,4],0)}else if(e.input_boxes){let i=e.input_boxes.dims;e.input_labels=be([i[0],i[1],0],-1n),e.input_points=be([i[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder,o=ke(e,n.inputNames);return await X(n,o)}async _call(e){return new Rl(await super._call(e))}},$x=class extends Vo{},Fx=class extends Vo{};var lr=class extends f{},Rx=class extends lr{},Dx=class extends lr{},jx=class extends lr{};var cr=class extends f{},Bx=class extends cr{},qx=class extends cr{},Ux=class extends cr{};var Ho=class extends f{},Gx=class extends Ho{},Ko=class extends Ho{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"text_model"})}},Wx=class extends mt{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"vision_model"})}};var Xo=class extends f{},Vx=class extends Xo{},Hx=class extends Xo{};var pr=class extends f{main_input_name="input_values";forward_params=["input_values"]},Kx=class extends pr{async encode(e){return await X(this.sessions.encoder_model,e)}async decode(e){return await X(this.sessions.decoder_model,e)}},Qo=class extends pr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"encoder_model"})}},Yo=class extends pr{static async from_pretrained(e,s={}){return super.from_pretrained(e,{...s,model_file_name:s.model_file_name??"decoder_model"})}};var Jo=class extends f{},Xx=class extends Jo{},Qx=class extends Jo{};var ur=class extends f{},Yx=class extends ur{},Jx=class extends ur{},Zx=class extends ur{async generate_speech(e,s,{threshold:r=.5,minlenratio:n=0,maxlenratio:o=20,vocoder:i=null}={}){let a={input_ids:e},{encoder_outputs:l,encoder_attention_mask:c}=await st(this,a),p=l.dims[1]/this.config.reduction_factor,u=Math.floor(p*o),_=Math.floor(p*n),d=this.config.num_mel_bins,m=[],h=null,g=null,x=0;for(;;){++x;let b=L_(!!g),v;g?v=g.output_sequence_out:v=new E("float32",new Float32Array(d),[1,1,d]);let k={use_cache_branch:b,output_sequence:v,encoder_attention_mask:c,speaker_embeddings:s,encoder_hidden_states:l};this.addPastKeyValues(k,h),g=await X(this.sessions.decoder_model_merged,k),h=this.getPastKeyValues(g,h);let{prob:O,spectrum:N}=g;if(m.push(N),x>=_&&(Array.from(O.data).filter(q=>q>=r).length>0||x>=u))break}let w=oe(m),{waveform:y}=await X(i.sessions.model,{spectrogram:w});return{spectrogram:w,waveform:y}}},ew=class extends f{main_input_name="spectrogram"};var ws=class extends f{},tw=class extends ws{},sw=class extends ws{async _call(e){return new re(await super._call(e))}},rw=class extends ws{async _call(e){return new z(await super._call(e))}},nw=class extends ws{async _call(e){return new ce(await super._call(e))}};var Zo=class extends f{},ow=class extends Zo{},iw=class extends Zo{};var ei=class extends f{},aw=class extends ei{},lw=class extends ei{};var jl=class extends f{},cw=class extends jl{};var Bl=class extends f{},ti=class extends Bl{async generate_speech({input_ids:e,attention_mask:s,style:r,num_inference_steps:n=5,speed:o=1.05}){let{sampling_rate:i,chunk_compress_factor:a,base_chunk_size:l,latent_dim:c}=this.config,{last_hidden_state:p,durations:u}=await X(this.sessions.text_encoder,{input_ids:e,attention_mask:s,style:r}),_=u.div(o).mul_(i),d=l*a,m=_.data,h=Int32Array.from(m,P=>Math.ceil(P/d)),g=Math.max(...h),x=e.dims[0],w=new BigInt64Array(x*g);for(let P=0;P<x;++P)w.fill(1n,P*g,P*g+h[P]);let y=new E("int64",w,[x,g]),b=c*a,v=b*g,k=B0([x,b,g]),O=k.data;for(let P=0;P<x;++P)if(h[P]!==g)for(let R=0;R<b;++R)O.fill(0,P*v+R*g+h[P],P*v+(R+1)*g);let N=be([x],n);for(let P=0;P<n;++P){let R=be([x],P);({denoised_latents:k}=await X(this.sessions.latent_denoiser,{style:r,noisy_latents:k,latent_mask:y,encoder_outputs:p,attention_mask:s,timestep:R,num_inference_steps:N}))}let{waveform:q}=await X(this.sessions.voice_decoder,{latents:k});return{waveform:q,durations:_}}};var _r=class extends f{},pw=class extends _r{},uw=class extends _r{async _call(e){return new z(await super._call(e))}},_w=class extends _r{};var si=class extends f{},dw=class extends si{},fw=class extends si{};var ri=class extends f{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},mw=class extends ri{},hw=class extends ri{};var ni=class extends f{},gw=class extends ni{},xw=class extends ni{async _call(e){return new ql(await super._call(e))}},ql=class extends Js{};var Ul=class extends f{},ww=class extends Ul{};var dr=class extends f{},yw=class extends dr{},bw=class extends dr{async _call(e){return new je(await super._call(e))}},kw=class extends dr{async _call(e){return new z(await super._call(e))}};var ys=class extends f{},vw=class extends ys{},Ew=class extends ys{async _call(e){return new je(await super._call(e))}},Aw=class extends ys{async _call(e){return new z(await super._call(e))}},Mw=class extends ys{async _call(e){return new ee(await super._call(e))}};var oi=class extends f{},Sw=class extends oi{},Ow=class extends oi{};var zw=class extends f{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var ii=class extends f{},Iw=class extends ii{},Tw=class extends ii{async _call(e){return new z(await super._call(e))}};var Gl=class extends f{},Cw=class extends Gl{};var ai=class extends f{},Pw=class extends ai{},Nw=class extends ai{async _call(e){return new z(await super._call(e))}};var Wl=class extends f{},Lw=class extends Wl{async _call(e){return new Fa(await super._call(e))}};var Vl=class extends f{},$w=class extends Vl{};var Hl=class extends me{constructor({waveform:e,spectrogram:s}){super(),this.waveform=e,this.spectrogram=s}},Kl=class extends f{},Fw=class extends Kl{async _call(e){return new Hl(await super._call(e))}};var Rw=class extends fs{};var wb=2,XA=1,Dw=new WeakMap;function QA(t,e){let{text_config:s,audio_config:r}=t.config,n=t.sessions.audio_encoder,{num_mel_bins:o,hidden_size:i}=r,a=o+i,l=new Kr,c=n?.config?.kv_cache_dtype??"float32",p=c==="float16"?wt.float16:wt.float32,u=os(r,{batch_size:1});for(let m in u){let h=u[m].reduce((g,x)=>g*x,1);l[m]=new E(c,new p(h),u[m])}let _=new E(c,new p(a*wb),[1,a,wb]),d=e[Symbol.asyncIterator]?.()??e[Symbol.iterator]?.();if(!d)throw new Error("input_features must be iterable or async iterable");return{encoder_session:n,enc_kv_cache:l,enc_padding_cache:_,enc_past_seq_len:0,audio_embed_queue:[],audio_embed_total_tokens:0,audio_queue_offset:0,audio_consumed:0,stream_exhausted:!1,chunks_iter:d,text_hidden_size:s.hidden_size}}async function YA(t,e){let s=e.dims[2],r=Math.floor((XA+s-3)/2)+1,n=new E("int64",BigInt64Array.from({length:r},(p,u)=>BigInt(t.enc_past_seq_len+u)),[1,r]),o=t.enc_past_seq_len+r,i=Ae([1,o]),{audio_embeds:a,present_padding_cache:l,...c}=await X(t.encoder_session,{input_features:e,attention_mask:i,position_ids:n,past_padding_cache:t.enc_padding_cache,...t.enc_kv_cache});t.enc_padding_cache.location==="gpu-buffer"&&t.enc_padding_cache.dispose(),t.enc_padding_cache=l;for(let p in c)if(p.startsWith("present.")){let u=p.replace("present","past_key_values"),_=t.enc_kv_cache[u];_?.location==="gpu-buffer"&&_.dispose(),t.enc_kv_cache[u]=c[p]}return t.enc_past_seq_len=o,a}async function JA(t,e){for(;t.audio_embed_total_tokens<e&&!t.stream_exhausted;){let s=await t.chunks_iter.next();if(s.done){t.stream_exhausted=!0;break}let r=await YA(t,s.value);t.audio_embed_queue.push({data:r.data,tokens:r.dims[1]}),t.audio_embed_total_tokens+=r.dims[1]}}function ZA(t,e,s){if(t.audio_embed_queue.length===0)return;let r=e.data,n=0,o=s;for(;o>0&&t.audio_embed_queue.length>0;){let i=t.audio_embed_queue[0],a=i.tokens-t.audio_queue_offset,l=Math.min(o,a),c=t.audio_queue_offset*t.text_hidden_size;for(let p=0;p<l*t.text_hidden_size;++p)r[n*t.text_hidden_size+p]+=i.data[c+p];n+=l,o-=l,t.audio_queue_offset+=l,t.audio_queue_offset>=i.tokens&&(t.audio_embed_queue.shift(),t.audio_queue_offset=0)}t.audio_consumed+=s-o}var jw=class extends Ft{constructor(e){super(),this._s=e}_call(e){let s=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>s)}},Xl=class extends f{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},li=class extends Xl{async forward({input_ids:e,past_key_values:s,...r}){let n=e.dims[1],o=Dw.get(this);o&&await JA(o,o.audio_consumed+n);let{inputs_embeds:i}=await X(this.sessions.embed_tokens,{input_ids:e});o&&ZA(o,i,n);let a={inputs_embeds:i,...r};this.addPastKeyValues(a,s);let l=this.sessions.decoder_model_merged,c=ke(a,l.inputNames);return await X(l,c)}async generate({input_features:e,stopping_criteria:s,...r}){if(!e)throw new Error("input_features (generator/iterable) must be provided");let n=QA(this,e);Dw.set(this,n);let o=new Ws;o.push(new jw(n)),s&&o.extend(s);try{return await super.generate({...r,stopping_criteria:o})}finally{n.enc_kv_cache.dispose(),Dw.delete(this)}}};var fr=class extends f{},Bw=class extends fr{},qw=class extends fr{async _call(e){return new je(await super._call(e))}},Uw=class extends fr{async _call(e){return new z(await super._call(e))}};var Ql=class extends me{constructor({logits:e,embeddings:s}){super(),this.logits=e,this.embeddings=s}},Xt=class extends f{},Gw=class extends Xt{},Ww=class extends Xt{async _call(e){return new je(await super._call(e))}},Vw=class extends Xt{async _call(e){return new z(await super._call(e))}},Hw=class extends Xt{async _call(e){return new Ql(await super._call(e))}},Kw=class extends Xt{async _call(e){return new ee(await super._call(e))}};var Yl=class extends f{},Xw=class extends Yl{};var Jl=class extends Gs{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1};var ci=class extends f{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},Qw=class extends ci{},Zl=class extends ci{_prepare_generation_config(e,s){return super._prepare_generation_config(e,s,Jl)}_retrieve_init_tokens(e){let s=[e.decoder_start_token_id],r=e.language,n=e.task;if(e.is_multilingual){r||($.warn("No language specified - defaulting to English (en)."),r="en");let i=`<|${G0(r)}|>`;s.push(e.lang_to_id[i]),s.push(e.task_to_id[n??"transcribe"])}else if(r||n)throw new Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&s.at(-1)!==e.no_timestamps_token_id?s.push(e.no_timestamps_token_id):e.return_timestamps&&s.at(-1)===e.no_timestamps_token_id&&($.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),s.pop()),s.filter(o=>o!=null)}async generate({inputs:e=null,generation_config:s=null,logits_processor:r=null,stopping_criteria:n=null,...o}){s=this._prepare_generation_config(s,o);let i=o.decoder_input_ids??this._retrieve_init_tokens(s);if(s.return_timestamps&&(r??=new is,r.push(new ja(s,i))),s.begin_suppress_tokens&&(r??=new is,r.push(new Us(s.begin_suppress_tokens,i.length))),s.return_token_timestamps){if(!s.alignment_heads)throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");s.task==="translate"&&$.warn("Token-level timestamps may not be reliable for task 'translate'."),s.output_attentions=!0,s.return_dict_in_generate=!0}let a=await super.generate({inputs:e,generation_config:s,logits_processor:r,decoder_input_ids:i,...o});return s.return_token_timestamps&&(a.token_timestamps=this._extract_token_timestamps(a,s.alignment_heads,s.num_frames)),a}_extract_token_timestamps(e,s,r=null,n=.02){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");r==null&&$.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let o=this.config.median_filter_width;o===void 0&&($.warn("Model config has no `median_filter_width`, using default value of 7."),o=7);let i=e.cross_attentions,a=Array.from({length:this.config.decoder_layers},(h,g)=>oe(i.map(x=>x[g]),2)),l=Ue(s.map(([h,g])=>{if(h>=a.length)throw new Error(`Layer index ${h} is out of bounds for cross attentions (length ${a.length}).`);return r?a[h].slice(null,g,null,[0,r]):a[h].slice(null,g)})).transpose(1,0,2,3),[c,p]=Kc(l,-2,0,!0),u=l.clone();for(let h=0;h<u.dims[0];++h){let g=u[h];for(let x=0;x<g.dims[0];++x){let w=g[x],y=c[h][x][0].data,b=p[h][x][0].data;for(let v=0;v<w.dims[0];++v){let k=w[v].data;for(let O=0;O<k.length;++O)k[O]=(k[O]-b[O])/y[O];k.set(y0(k,o))}}}let _=[la(u,1)],d=e.sequences.dims,m=new E("float32",new Float32Array(d[0]*d[1]),d);for(let h=0;h<d[0];++h){let g=_[h].neg().squeeze_(0),[x,w]=k0(g.tolist()),y=Array.from({length:x.length-1},(k,O)=>x[O+1]-x[O]),b=$e([1],y).map(k=>!!k),v=[];for(let k=0;k<b.length;++k)b[k]&&v.push(w[k]*n);m[h].data.set(v,1)}return m}},Yw=class extends Zl{};var Qt=class extends f{},Jw=class extends Qt{},Zw=class extends Qt{async _call(e){return new re(await super._call(e))}},ey=class extends Qt{async _call(e){return new z(await super._call(e))}},ty=class extends Qt{async _call(e){return new ee(await super._call(e))}},sy=class extends Qt{async _call(e){return new ce(await super._call(e))}};var Yt=class extends f{},ry=class extends Yt{},ny=class extends Yt{async _call(e){return new re(await super._call(e))}},oy=class extends Yt{async _call(e){return new z(await super._call(e))}},iy=class extends Yt{async _call(e){return new ee(await super._call(e))}},ay=class extends Yt{async _call(e){return new ce(await super._call(e))}};var pi=class extends f{},ly=class extends pi{},cy=class extends pi{async _call(e){return new ec(await super._call(e))}},ec=class extends me{constructor({logits:e,pred_boxes:s}){super(),this.logits=e,this.pred_boxes=s}};var ui=class extends f{},py=class extends ui{},uy=class extends ui{};var eM=new Map([["bert","BertModel"],["eurobert","EuroBertModel"],["neobert","NeoBertModel"],["modernbert","ModernBertModel"],["nomic_bert","NomicBertModel"],["roformer","RoFormerModel"],["electra","ElectraModel"],["esm","EsmModel"],["convbert","ConvBertModel"],["camembert","CamembertModel"],["deberta","DebertaModel"],["deberta-v2","DebertaV2Model"],["mpnet","MPNetModel"],["albert","AlbertModel"],["distilbert","DistilBertModel"],["roberta","RobertaModel"],["xlm","XLMModel"],["xlm-roberta","XLMRobertaModel"],["clap","ClapModel"],["clip","CLIPModel"],["clipseg","CLIPSegModel"],["chinese_clip","ChineseCLIPModel"],["siglip","SiglipModel"],["jina_clip","JinaCLIPModel"],["mobilebert","MobileBertModel"],["squeezebert","SqueezeBertModel"],["wav2vec2","Wav2Vec2Model"],["wav2vec2-bert","Wav2Vec2BertModel"],["unispeech","UniSpeechModel"],["unispeech-sat","UniSpeechSatModel"],["hubert","HubertModel"],["wavlm","WavLMModel"],["audio-spectrogram-transformer","ASTModel"],["vits","VitsModel"],["pyannote","PyAnnoteModel"],["wespeaker-resnet","WeSpeakerResNetModel"],["detr","DetrModel"],["rt_detr","RTDetrModel"],["rt_detr_v2","RTDetrV2Model"],["rf_detr","RFDetrModel"],["d_fine","DFineModel"],["table-transformer","TableTransformerModel"],["vit","ViTModel"],["ijepa","IJepaModel"],["pvt","PvtModel"],["vit_msn","ViTMSNModel"],["vit_mae","ViTMAEModel"],["groupvit","GroupViTModel"],["fastvit","FastViTModel"],["mobilevit","MobileViTModel"],["mobilevitv2","MobileViTV2Model"],["owlvit","OwlViTModel"],["owlv2","Owlv2Model"],["beit","BeitModel"],["deit","DeiTModel"],["hiera","HieraModel"],["convnext","ConvNextModel"],["convnextv2","ConvNextV2Model"],["dinov2","Dinov2Model"],["dinov2_with_registers","Dinov2WithRegistersModel"],["dinov3_vit","DINOv3ViTModel"],["dinov3_convnext","DINOv3ConvNextModel"],["resnet","ResNetModel"],["swin","SwinModel"],["swin2sr","Swin2SRModel"],["donut-swin","DonutSwinModel"],["yolos","YolosModel"],["dpt","DPTModel"],["glpn","GLPNModel"],["hifigan","SpeechT5HifiGan"],["efficientnet","EfficientNetModel"],["decision_transformer","DecisionTransformerModel"],["patchtst","PatchTSTModel"],["patchtsmixer","PatchTSMixerModel"],["mobilenet_v1","MobileNetV1Model"],["mobilenet_v2","MobileNetV2Model"],["mobilenet_v3","MobileNetV3Model"],["mobilenet_v4","MobileNetV4Model"],["maskformer","MaskFormerModel"],["mgp-str","MgpstrForSceneTextRecognition"],["style_text_to_speech_2","StyleTextToSpeech2Model"]]),tM=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["cohere_asr","CohereAsrModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),sM=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),rM=new Map([["bloom","BloomModel"],["jais","JAISModel"],["gpt2","GPT2Model"],["gpt_oss","GptOssModel"],["gptj","GPTJModel"],["gpt_bigcode","GPTBigCodeModel"],["gpt_neo","GPTNeoModel"],["gpt_neox","GPTNeoXModel"],["codegen","CodeGenModel"],["llama","LlamaModel"],["apertus","ApertusModel"],["nanochat","NanoChatModel"],["arcee","ArceeModel"],["afmoe","AfmoeModel"],["lfm2","Lfm2Model"],["lfm2_moe","Lfm2MoeModel"],["smollm3","SmolLM3Model"],["exaone","ExaoneModel"],["olmo","OlmoModel"],["olmo2","Olmo2Model"],["olmo3","Olmo3Model"],["olmo_hybrid","OlmoHybridModel"],["mobilellm","MobileLLMModel"],["granite","GraniteModel"],["granitemoehybrid","GraniteMoeHybridModel"],["cohere","CohereModel"],["cohere2","Cohere2Model"],["gemma","GemmaModel"],["gemma2","Gemma2Model"],["vaultgemma","VaultGemmaModel"],["gemma3_text","Gemma3Model"],["helium","HeliumModel"],["glm","GlmModel"],["glm_moe_dsa","GlmMoeDsaModel"],["openelm","OpenELMModel"],["qwen2","Qwen2Model"],["qwen2_moe","Qwen2MoeModel"],["qwen3","Qwen3Model"],["qwen3_moe","Qwen3MoeModel"],["qwen3_next","Qwen3NextModel"],["phi","PhiModel"],["phi3","Phi3Model"],["mpt","MptModel"],["opt","OPTModel"],["mistral","MistralModel"],["mistral4","Mistral4Model"],["ministral","MinistralModel"],["ministral3","Ministral3Model"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2Model"],["deepseek_v3","DeepseekV3Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["nemotron_h","NemotronHModel"],["solar_open","SolarOpenModel"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"]]),yb=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"],["cohere_asr","CohereAsrForConditionalGeneration"]]),bb=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),kb=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),vb=new Map([["bert","BertForSequenceClassification"],["eurobert","EuroBertForSequenceClassification"],["neobert","NeoBertForSequenceClassification"],["modernbert","ModernBertForSequenceClassification"],["roformer","RoFormerForSequenceClassification"],["electra","ElectraForSequenceClassification"],["esm","EsmForSequenceClassification"],["convbert","ConvBertForSequenceClassification"],["camembert","CamembertForSequenceClassification"],["deberta","DebertaForSequenceClassification"],["deberta-v2","DebertaV2ForSequenceClassification"],["mpnet","MPNetForSequenceClassification"],["albert","AlbertForSequenceClassification"],["distilbert","DistilBertForSequenceClassification"],["roberta","RobertaForSequenceClassification"],["xlm","XLMForSequenceClassification"],["xlm-roberta","XLMRobertaForSequenceClassification"],["bart","BartForSequenceClassification"],["mbart","MBartForSequenceClassification"],["mobilebert","MobileBertForSequenceClassification"],["squeezebert","SqueezeBertForSequenceClassification"]]),Eb=new Map([["bert","BertForTokenClassification"],["eurobert","EuroBertForTokenClassification"],["neobert","NeoBertForTokenClassification"],["modernbert","ModernBertForTokenClassification"],["roformer","RoFormerForTokenClassification"],["electra","ElectraForTokenClassification"],["esm","EsmForTokenClassification"],["convbert","ConvBertForTokenClassification"],["camembert","CamembertForTokenClassification"],["deberta","DebertaForTokenClassification"],["deberta-v2","DebertaV2ForTokenClassification"],["mpnet","MPNetForTokenClassification"],["distilbert","DistilBertForTokenClassification"],["roberta","RobertaForTokenClassification"],["xlm","XLMForTokenClassification"],["xlm-roberta","XLMRobertaForTokenClassification"]]),Ab=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),Mb=new Map([["bloom","BloomForCausalLM"],["gpt2","GPT2LMHeadModel"],["gpt_oss","GptOssForCausalLM"],["jais","JAISLMHeadModel"],["gptj","GPTJForCausalLM"],["gpt_bigcode","GPTBigCodeForCausalLM"],["gpt_neo","GPTNeoForCausalLM"],["gpt_neox","GPTNeoXForCausalLM"],["codegen","CodeGenForCausalLM"],["llama","LlamaForCausalLM"],["nanochat","NanoChatForCausalLM"],["apertus","ApertusForCausalLM"],["llama4_text","Llama4ForCausalLM"],["arcee","ArceeForCausalLM"],["afmoe","AfmoeForCausalLM"],["lfm2","Lfm2ForCausalLM"],["lfm2_moe","Lfm2MoeForCausalLM"],["smollm3","SmolLM3ForCausalLM"],["exaone","ExaoneForCausalLM"],["olmo","OlmoForCausalLM"],["olmo2","Olmo2ForCausalLM"],["olmo3","Olmo3ForCausalLM"],["olmo_hybrid","OlmoHybridForCausalLM"],["mobilellm","MobileLLMForCausalLM"],["granite","GraniteForCausalLM"],["granitemoehybrid","GraniteMoeHybridForCausalLM"],["cohere","CohereForCausalLM"],["cohere2","Cohere2ForCausalLM"],["gemma","GemmaForCausalLM"],["gemma2","Gemma2ForCausalLM"],["vaultgemma","VaultGemmaForCausalLM"],["gemma3_text","Gemma3ForCausalLM"],["gemma3","Gemma3ForCausalLM"],["helium","HeliumForCausalLM"],["glm","GlmForCausalLM"],["glm_moe_dsa","GlmMoeDsaForCausalLM"],["openelm","OpenELMForCausalLM"],["qwen2","Qwen2ForCausalLM"],["qwen2_moe","Qwen2MoeForCausalLM"],["qwen3","Qwen3ForCausalLM"],["qwen3_moe","Qwen3MoeForCausalLM"],["qwen3_next","Qwen3NextForCausalLM"],["qwen2_vl","Qwen2VLForCausalLM"],["qwen2_5_vl","Qwen2_5_VLForCausalLM"],["qwen3_vl","Qwen3VLForCausalLM"],["qwen3_vl_moe","Qwen3VLMoeForCausalLM"],["qwen3_5","Qwen3_5ForCausalLM"],["qwen3_5_text","Qwen3_5ForCausalLM"],["qwen3_5_moe","Qwen3_5MoeForCausalLM"],["gemma3n","Gemma3nForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["mistral4","Mistral4ForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["deepseek_v3","DeepseekV3ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["nemotron_h","NemotronHForCausalLM"],["trocr","TrOCRForCausalLM"],["solar_open","SolarOpenForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),nM=new Map([["multi_modality","MultiModalityCausalLM"]]),Sb=new Map([["bert","BertForMaskedLM"],["eurobert","EuroBertForMaskedLM"],["neobert","NeoBertForMaskedLM"],["modernbert","ModernBertForMaskedLM"],["roformer","RoFormerForMaskedLM"],["electra","ElectraForMaskedLM"],["esm","EsmForMaskedLM"],["convbert","ConvBertForMaskedLM"],["camembert","CamembertForMaskedLM"],["deberta","DebertaForMaskedLM"],["deberta-v2","DebertaV2ForMaskedLM"],["mpnet","MPNetForMaskedLM"],["albert","AlbertForMaskedLM"],["distilbert","DistilBertForMaskedLM"],["roberta","RobertaForMaskedLM"],["xlm","XLMWithLMHeadModel"],["xlm-roberta","XLMRobertaForMaskedLM"],["mobilebert","MobileBertForMaskedLM"],["squeezebert","SqueezeBertForMaskedLM"]]),Ob=new Map([["bert","BertForQuestionAnswering"],["neobert","NeoBertForQuestionAnswering"],["roformer","RoFormerForQuestionAnswering"],["electra","ElectraForQuestionAnswering"],["convbert","ConvBertForQuestionAnswering"],["camembert","CamembertForQuestionAnswering"],["deberta","DebertaForQuestionAnswering"],["deberta-v2","DebertaV2ForQuestionAnswering"],["mpnet","MPNetForQuestionAnswering"],["albert","AlbertForQuestionAnswering"],["distilbert","DistilBertForQuestionAnswering"],["roberta","RobertaForQuestionAnswering"],["xlm","XLMForQuestionAnswering"],["xlm-roberta","XLMRobertaForQuestionAnswering"],["mobilebert","MobileBertForQuestionAnswering"],["squeezebert","SqueezeBertForQuestionAnswering"]]),zb=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),Ib=new Map([["llava","LlavaForConditionalGeneration"],["llava_onevision","LlavaOnevisionForConditionalGeneration"],["moondream1","Moondream1ForConditionalGeneration"],["florence2","Florence2ForConditionalGeneration"],["qwen2_vl","Qwen2VLForConditionalGeneration"],["qwen2_5_vl","Qwen2_5_VLForConditionalGeneration"],["qwen3_vl","Qwen3VLForConditionalGeneration"],["qwen3_vl_moe","Qwen3VLMoeForConditionalGeneration"],["qwen3_5","Qwen3_5ForConditionalGeneration"],["qwen3_5_moe","Qwen3_5MoeForConditionalGeneration"],["lfm2_vl","Lfm2VlForConditionalGeneration"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"],["paligemma","PaliGemmaForConditionalGeneration"],["llava_qwen2","LlavaQwen2ForCausalLM"],["gemma3","Gemma3ForConditionalGeneration"],["gemma3n","Gemma3nForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"],["lighton_ocr","LightOnOcrForConditionalGeneration"],["glm_ocr","GlmOcrForConditionalGeneration"]]),Tb=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),oM=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),Cb=new Map([["vit","ViTForImageClassification"],["ijepa","IJepaForImageClassification"],["pvt","PvtForImageClassification"],["vit_msn","ViTMSNForImageClassification"],["fastvit","FastViTForImageClassification"],["mobilevit","MobileViTForImageClassification"],["mobilevitv2","MobileViTV2ForImageClassification"],["beit","BeitForImageClassification"],["deit","DeiTForImageClassification"],["hiera","HieraForImageClassification"],["convnext","ConvNextForImageClassification"],["convnextv2","ConvNextV2ForImageClassification"],["dinov2","Dinov2ForImageClassification"],["dinov2_with_registers","Dinov2WithRegistersForImageClassification"],["resnet","ResNetForImageClassification"],["swin","SwinForImageClassification"],["segformer","SegformerForImageClassification"],["efficientnet","EfficientNetForImageClassification"],["mobilenet_v1","MobileNetV1ForImageClassification"],["mobilenet_v2","MobileNetV2ForImageClassification"],["mobilenet_v3","MobileNetV3ForImageClassification"],["mobilenet_v4","MobileNetV4ForImageClassification"]]),Pb=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),Nb=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),mr=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),Lb=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),$b=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),Fb=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),Rb=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),Db=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),jb=new Map([["wavlm","WavLMForXVector"]]),Bb=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),qb=new Map([["vitmatte","VitMatteForImageMatting"]]),iM=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),Ub=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),Gb=new Map([["chmv2","CHMv2ForDepthEstimation"],["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),Wb=new Map([["sapiens","SapiensForNormalEstimation"]]),Vb=new Map([["vitpose","VitPoseForPoseEstimation"]]),Hb=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),_y=[[eM,L.EncoderOnly],[tM,L.EncoderDecoder],[rM,L.DecoderOnlyWithoutHead],[sM,L.AutoEncoder],[vb,L.EncoderOnly],[Eb,L.EncoderOnly],[Ab,L.Seq2Seq],[yb,L.Seq2Seq],[Mb,L.DecoderOnly],[nM,L.MultiModality],[Sb,L.EncoderOnly],[Ob,L.EncoderOnly],[zb,L.Vision2Seq],[Ib,L.ImageTextToText],[Tb,L.AudioTextToText],[Cb,L.EncoderOnly],[mr,L.EncoderOnly],[$b,L.EncoderOnly],[Lb,L.EncoderOnly],[qb,L.EncoderOnly],[iM,L.EncoderOnly],[Ub,L.EncoderOnly],[Gb,L.EncoderOnly],[Wb,L.EncoderOnly],[Vb,L.EncoderOnly],[Pb,L.EncoderOnly],[Nb,L.EncoderOnly],[Fb,L.MaskGeneration],[Rb,L.EncoderOnly],[Db,L.EncoderOnly],[bb,L.Seq2Seq],[kb,L.EncoderOnly],[jb,L.EncoderOnly],[Bb,L.EncoderOnly],[Hb,L.EncoderOnly]];for(let[t,e]of _y)for(let s of t.values()){ct.set(s,e);let r=_i[s];cs.set(r,s),el.set(s,r)}var aM=[["MusicgenForConditionalGeneration",xo,L.Musicgen],["Phi3VForCausalLM",Po,L.Phi3V],["CLIPTextModelWithProjection",ln,L.EncoderOnly],["SiglipTextModel",Ko,L.EncoderOnly],["JinaCLIPTextModel",Yn,L.EncoderOnly],["ClapTextModelWithProjection",on,L.EncoderOnly],["ClapAudioModelWithProjection",an,L.EncoderOnly],["DacEncoderModel",xn,L.EncoderOnly],["DacDecoderModel",wn,L.EncoderOnly],["MimiEncoderModel",oo,L.EncoderOnly],["MimiDecoderModel",io,L.EncoderOnly],["SnacEncoderModel",Qo,L.EncoderOnly],["SnacDecoderModel",Yo,L.EncoderOnly],["Gemma3nForConditionalGeneration",Zs,L.ImageAudioTextToText],["SupertonicForConditionalGeneration",ti,L.Supertonic],["ChatterboxModel",nn,L.Chatterbox],["VoxtralRealtimeForConditionalGeneration",li,L.VoxtralRealtime]];for(let[t,e,s]of aM)ct.set(t,s),cs.set(e,t),el.set(t,e);var Kb=new Map([["modnet",mr],["birefnet",mr],["isnet",mr],["ben",mr]]);for(let[t,e]of Kb.entries())e.set(t,"PreTrainedModel"),ct.set(t,L.EncoderOnly),el.set(t,f);var Xb=new Set(Kb.keys());ct.set("PreTrainedModel",L.EncoderOnly);cs.set(f,"PreTrainedModel");var de={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:vb,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:Eb,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:bb,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:kb,MODEL_FOR_MASKED_LM_MAPPING_NAMES:Sb,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:Ob,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:Cb,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:mr,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:Lb,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:$b,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:Pb,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:Nb,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:Fb,MODEL_FOR_CTC_MAPPING_NAMES:Rb,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:Db,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:jb,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:Bb,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:oM,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:qb,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:Ub,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:Gb,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:Wb,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:Vb,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:Hb,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:Ib,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:Tb,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:Ab,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:yb,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:Mb,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:zb};mb(de);var pe=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let s of this.MODEL_CLASS_MAPPINGS)if(s.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main",model_file_name:a=null,subfolder:l="onnx",device:c=null,dtype:p=null,use_external_data_format:u=null,session_options:_={}}={}){let d={progress_callback:s,config:r,cache_dir:n,local_files_only:o,revision:i,model_file_name:a,subfolder:l,device:c,dtype:p,use_external_data_format:u,session_options:_};if(d.config=await et.from_pretrained(e,d),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:m}=d.config;for(let h of this.MODEL_CLASS_MAPPINGS){let g=h.get(m);if(!g){for(let x of h.values())if(x[0]===m){g=x;break}if(!g)continue}return await _i[g].from_pretrained(e,d)}if(this.BASE_IF_FAIL)return Xb.has(m)||$.warn(`Unknown model class "${m}", attempting to construct from base class.`),await f.from_pretrained(e,d);throw Error(`Unsupported model type: ${m}`)}},bt=class extends pe{static MODEL_CLASS_MAPPINGS=_y.map(e=>e[0]);static BASE_IF_FAIL=!0},di=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},tc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},hr=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},sc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},rc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},nc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},oc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},ic=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},ac=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},lc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},cc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},fi=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},mi=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},hi=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},pc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},uc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},Qb=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},_c=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_CTC_MAPPING_NAMES]},dc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},Yb=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},Jb=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},fc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},Zb=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},mc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},hc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},ek=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},tk=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},gc=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},sk=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},rk=class extends pe{static MODEL_CLASS_MAPPINGS=[de.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function Me(t){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(e=>ve.read(e)))}async function kt(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(s=>typeof s=="string"||s instanceof URL?Hp(s,e):s instanceof Float64Array?new Float32Array(s):s))}function gi(t,e){e&&(t=t.map(i=>i|0));let[s,r,n,o]=t;return{xmin:s,ymin:r,xmax:n,ymax:o}}var Q=class extends Se{constructor({task:e,model:s,tokenizer:r=null,processor:n=null}){super(),this.task=e,this.model=s,this.tokenizer=r,this.processor=n}async dispose(){await this.model.dispose()}};var xi=class extends Q{async _call(e,{top_k:s=1}={}){let r=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(r),{problem_type:o,id2label:i}=this.model.config,a=o==="multi_label_classification"?c=>c.sigmoid():c=>new E("float32",fe(c.data),c.dims),l=[];for(let c of n.logits){let p=a(c),u=await lt(p,s),_=u[0].tolist(),m=u[1].tolist().map((h,g)=>({label:i?i[h]:`LABEL_${h}`,score:_[g]}));s===1?l.push(...m):l.push(m)}return Array.isArray(e)||s===1?l:l[0]}};var wi=class extends Q{async _call(e,{ignore_labels:s=["O"]}={}){let r=Array.isArray(e),n=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),i=(await this.model(n)).logits,a=this.model.config.id2label,l=[];for(let c=0;c<i.dims[0];++c){let p=n.input_ids[c],u=i[c],_=[];for(let d=0;d<u.dims[0];++d){let m=u[d],h=ue(m.data)[1],g=a?a[h]:`LABEL_${h}`;if(s.includes(g))continue;let x=this.tokenizer.decode([p[d].item()],{skip_special_tokens:!0});if(x==="")continue;let w=fe(m.data);_.push({entity:g,score:w[h],index:d,word:x})}l.push(_)}return r?l:l[0]}};var yi=class extends Q{async _call(e,s,{top_k:r=1}={}){let n=this.tokenizer(e,{text_pair:s,padding:!0,truncation:!0}),o=Array.isArray(e),{start_logits:i,end_logits:a}=await this.model(n),l=n.input_ids.tolist(),c=n.attention_mask.tolist(),{all_special_ids:p,sep_token_id:u}=this.tokenizer,_=[];for(let d=0;d<i.dims[0];++d){let m=l[d],h=m.findIndex(k=>k==u),g=i[d].tolist(),x=a[d].tolist();for(let k=1;k<g.length;++k)(c[d]==0||k<=h||p.findIndex(O=>O==m[k])!==-1)&&(g[k]=-1/0,x[k]=-1/0);let w=fe(g).map((k,O)=>[k,O]),y=fe(x).map((k,O)=>[k,O]);w[0][0]=0,y[0][0]=0;let b=zy(w,y).filter(k=>k[0][1]<=k[1][1]).map(k=>[k[0][1],k[1][1],k[0][0]*k[1][0]]).sort((k,O)=>O[2]-k[2]),v=[];for(let k=0;k<Math.min(b.length,r);++k){let[O,N,q]=b[k],P=m.slice(O,N+1),R=this.tokenizer.decode(P,{skip_special_tokens:!0});v.push({answer:R,score:q})}r===1?_.push(...v):_.push(v)}return o?_:_[0]}};var bi=class extends Q{async _call(e,{top_k:s=5}={}){let{mask_token_id:r,mask_token:n}=this.tokenizer,o=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:i}=await this.model(o),a=[],l=o.input_ids.tolist();for(let c=0;c<l.length;++c){let p=l[c],u=p.findIndex(g=>g==r);if(u===-1)throw Error(`Mask token (${n}) not found in text.`);let _=i[c][u],d=await lt(new E("float32",fe(_.data),_.dims),s),m=d[0].tolist(),h=d[1].tolist();a.push(h.map((g,x)=>{let w=p.slice();return w[u]=g,{score:m[x],token:Number(g),token_str:this.tokenizer.decode([g]),sequence:this.tokenizer.decode(w,{skip_special_tokens:!0})}}))}return Array.isArray(e)?a:a[0]}};var vt=class extends Q{_key="generated_text";async _call(e,s={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(l=>this.model.config.prefix+l));let r=this.model.config.task_specific_params;r&&r[this.task]&&r[this.task].prefix&&(e=e.map(l=>r[this.task].prefix+l));let n=this.tokenizer,o={padding:!0,truncation:!0},i;this.task==="translation"&&"_build_translation_inputs"in n?i=n._build_translation_inputs(e,o,s):i=n(e,o);let a=await this.model.generate({...i,...s});return n.batch_decode(a,{skip_special_tokens:!0}).map(l=>({[this._key]:l}))}};var ki=class extends vt{_key="summary_text"};var vi=class extends vt{_key="translation_text"};function nk(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var Ei=class extends Q{async _call(e,s={}){let r=!1,n=!1,o=s.add_special_tokens??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,i=s.tokenizer_encode_kwargs,a;if(typeof e=="string")a=e=[e];else if(Array.isArray(e)&&e.every(m=>typeof m=="string"))r=!0,a=e;else{if(nk(e))e=[e];else if(Array.isArray(e)&&e.every(nk))r=!0;else throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");n=!0,a=e.map(m=>this.tokenizer.apply_chat_template(m,{tokenize:!1,add_generation_prompt:!0,...i})),o=!1,i=void 0}let l=n?!1:s.return_full_text??!0;this.tokenizer.padding_side="left";let c=this.tokenizer(a,{add_special_tokens:o,padding:!0,truncation:!0,...i}),p=await this.model.generate({...c,...s}),u=this.tokenizer.batch_decode(p,{skip_special_tokens:!0}),_;!l&&c.input_ids.dims.at(-1)>0&&(_=this.tokenizer.batch_decode(c.input_ids,{skip_special_tokens:!0}).map(m=>m.length));let d=Array.from({length:e.length},m=>[]);for(let m=0;m<u.length;++m){let h=Math.floor(m/p.dims[0]*e.length);_&&(u[m]=u[m].slice(_[h])),d[h].push({generated_text:n?[...e[h],{role:"assistant",content:u[m]}]:u[m]})}return!r&&d.length===1?d[0]:d}};var Ai=class extends Q{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([s,r])=>[s.toLowerCase(),r])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&($.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&($.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,s,{hypothesis_template:r="This example is {}.",multi_label:n=!1}={}){let o=Array.isArray(e);o||(e=[e]),Array.isArray(s)||(s=[s]);let i=s.map(c=>r.replace("{}",c)),a=n||s.length===1,l=[];for(let c of e){let p=[];for(let d of i){let m=this.tokenizer(c,{text_pair:d,padding:!0,truncation:!0}),h=await this.model(m);a?p.push([h.logits.data[this.contradiction_id],h.logits.data[this.entailment_id]]):p.push(h.logits.data[this.entailment_id])}let _=(a?p.map(d=>fe(d)[1]):fe(p)).map((d,m)=>[d,m]).sort((d,m)=>m[0]-d[0]);l.push({sequence:c,labels:_.map(d=>s[d[1]]),scores:_.map(d=>d[0])})}return o?l:l[0]}};var Mi=class extends Q{async _call(e,{top_k:s=5}={}){let r=this.processor.feature_extractor.config.sampling_rate,n=await kt(e,r),o=this.model.config.id2label,i=[];for(let a of n){let l=await this.processor(a),p=(await this.model(l)).logits[0],u=await lt(new E("float32",fe(p.data),p.dims),s),_=u[0].tolist(),m=u[1].tolist().map((h,g)=>({label:o?o[h]:`LABEL_${h}`,score:_[g]}));i.push(m)}return Array.isArray(e)?i:i[0]}};var Si=class extends Q{async _call(e,s,{hypothesis_template:r="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let o=s.map(p=>r.replace("{}",p)),i=this.tokenizer(o,{padding:!0,truncation:!0}),a=this.processor.feature_extractor.config.sampling_rate,l=await kt(e,a),c=[];for(let p of l){let u=await this.processor(p),_=await this.model({...i,...u}),d=fe(_.logits_per_audio.data);c.push([...d].map((m,h)=>({score:m,label:s[h]})))}return n?c[0]:c}};var Oi=class extends Q{async _call(e,s={}){switch(this.model.config.model_type){case"whisper":case"lite-whisper":return this._call_whisper(e,s);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":case"parakeet_ctc":return this._call_wav2vec2(e,s);case"moonshine":return this._call_moonshine(e,s);case"cohere_asr":return this._call_cohere_asr(e,s);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,s){s.language&&$.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),s.task&&$.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let r=!Array.isArray(e),n=r?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,i=await kt(n,o),a=[];for(let l of i){let c=await this.processor(l),u=(await this.model(c)).logits[0],_=[];for(let m of u)_.push(ue(m.data)[1]);let d=this.tokenizer.decode(_,{skip_special_tokens:!0}).trim();a.push({text:d})}return r?a[0]:a}async _call_whisper(e,s){let r=s.return_timestamps??!1,n=s.chunk_length_s??0,o=s.force_full_sequences??!1,i=s.stride_length_s??null,a={...s};r==="word"&&(a.return_token_timestamps=!0,a.return_timestamps=!1);let l=!Array.isArray(e),c=l?[e]:e,p=this.processor.feature_extractor.config,u=p.chunk_length/this.model.config.max_source_positions,_=p.hop_length,d=p.sampling_rate,m=await kt(c,d),h=[];for(let g of m){let x=[];if(n>0){if(i===null)i=n/6;else if(n<=i)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let b=d*n,v=d*i,k=b-2*v,O=0;for(;;){let N=O+b,q=g.subarray(O,N),P=await this.processor(q),R=O===0,F=N>=g.length;if(x.push({stride:[q.length,R?0:v,F?0:v],input_features:P.input_features,is_last:F}),F)break;O+=k}}else x=[{stride:[g.length,0,0],input_features:(await this.processor(g)).input_features,is_last:!0}];for(let b of x){a.num_frames=Math.floor(b.stride[0]/_);let v=await this.model.generate({inputs:b.input_features,...a});r==="word"?(b.tokens=v.sequences.tolist()[0],b.token_timestamps=v.token_timestamps.tolist()[0].map(k=>ts(k,2))):b.tokens=v[0].tolist(),b.stride=b.stride.map(k=>k/d)}let[w,y]=this.tokenizer._decode_asr(x,{time_precision:u,return_timestamps:r,force_full_sequences:o});h.push({text:w,...y})}return l?h[0]:h}async _call_moonshine(e,s){let r=!Array.isArray(e),n=r?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,i=await kt(n,o),a=[];for(let l of i){let c=await this.processor(l),p=Math.floor(l.length/o)*6,u=await this.model.generate({max_new_tokens:p,...s,...c}),_=this.processor.batch_decode(u,{skip_special_tokens:!0})[0];a.push({text:_})}return r?a[0]:a}async _call_cohere_asr(e,s){let r=!Array.isArray(e),n=r?[e]:e,o=this.processor.feature_extractor,i=o.config.sampling_rate,a=await kt(n,i),l=s.language??"en",c=this.processor.get_decoder_prompt_ids(l),p=[];for(let u of a){let _=o.split_audio(u),d=[];for(let h of _){let g=await this.processor(h),x=await this.model.generate({...g,decoder_input_ids:c,...s}),w=this.tokenizer.decode(x[0].tolist(),{skip_special_tokens:!0}).trim();d.push(w)}let m=this.processor.constructor.join_chunks(d,l);p.push({text:m})}return r?p[0]:p}};var zi=class extends Q{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,s){if((typeof e=="string"||e instanceof URL)&&(e=new Float32Array(await(await Y.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new E("float32",e,[e.length]);else if(!(e instanceof E))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(s>1){if(e.dims[0]===1)e=e.repeat(s,1);else if(e.dims[0]!==s)throw new Error(`Expected speaker embeddings batch size to be 1 or ${s}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,s,r,n=null){let o=s.data,[i,a]=s.dims,l=n?n.data:null,c=[];for(let p=0;p<i;++p){let u=l?Math.min(Math.ceil(l[p]),a):a,_=p*a;c.push(new Fr(o.slice(_,_+u),r))}return Array.isArray(e)?c:c[0]}async _call(e,s){return this.processor?this._call_text_to_spectrogram(e,s):this.model.config.model_type==="supertonic"?this._call_supertonic(e,s):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:s,num_inference_steps:r,speed:n}){if(!s)throw new Error("Speaker embeddings must be provided for Supertonic models.");let{sampling_rate:o,style_dim:i}=this.model.config,a=this.tokenizer(e,{padding:!0,truncation:!0}),l=a.input_ids.dims[0];s=await this._prepare_speaker_embeddings(s,l),s=s.view(l,-1,i);let{waveform:c,durations:p}=await this.model.generate_speech({...a,style:s,num_inference_steps:r,speed:n});return this._postprocess_waveform(e,c,o,p)}async _call_text_to_waveform(e){let s=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:r}=await this.model(s),n=this.model.config.sampling_rate;return this._postprocess_waveform(e,r,n)}async _call_text_to_spectrogram(e,{speaker_embeddings:s}){this.vocoder||($.info("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await bt.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"}));let{input_ids:r}=this.tokenizer(e,{padding:!0,truncation:!0}),n=r.dims[0];s=await this._prepare_speaker_embeddings(s,n),s=s.view(n,-1);let{waveform:o}=await this.model.generate_speech(r,s,{vocoder:this.vocoder}),i=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,o,i)}};var Ii=class extends Q{async _call(e,s={}){let r=Array.isArray(e),n=await Me(e),{pixel_values:o}=await this.processor(n),i=[];for(let a of o){a.dims=[1,...a.dims];let l=await this.model.generate({inputs:a,...s}),c=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(p=>({generated_text:p.trim()}));i.push(c)}return r?i:i[0]}};var Ti=class extends Q{async _call(e,{top_k:s=5}={}){let r=await Me(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n}),{id2label:i}=this.model.config,a=[];for(let l of o.logits){let c=await lt(new E("float32",fe(l.data),l.dims),s),p=c[0].tolist(),_=c[1].tolist().map((d,m)=>({label:i?i[d]:`LABEL_${d}`,score:p[m]}));a.push(_)}return Array.isArray(e)?a:a[0]}};var ok={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},bs=class extends Q{async _call(e,{threshold:s=.5,mask_threshold:r=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:o=null,target_sizes:i=null,subtask:a=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let c=await Me(e),p=c.map(w=>[w.height,w.width]),u=await this.processor(c),{inputNames:_,outputNames:d}=this.model.sessions.model;if(!_.includes("pixel_values")){if(_.length!==1)throw Error(`Expected a single input name, but got ${_.length} inputs: ${_}.`);let w=_[0];if(w in u)throw Error(`Input name ${w} already exists in the inputs.`);u[w]=u.pixel_values}let m=await this.model(u),h=null;if(a!==null)h=ok[a];else if(this.processor.image_processor){for(let[w,y]of Object.entries(ok))if(y in this.processor.image_processor){h=this.processor.image_processor[y].bind(this.processor.image_processor),a=w;break}}let g=this.model.config.id2label,x=[];if(a)if(a==="panoptic"||a==="instance"){let w=h(m,s,r,n,o,i??p)[0],y=w.segmentation;for(let b of w.segments_info){let v=new Uint8ClampedArray(y.data.length);for(let O=0;O<y.data.length;++O)y.data[O]===b.id&&(v[O]=255);let k=new ve(v,y.dims[1],y.dims[0],1);x.push({score:b.score,label:g[b.label_id],mask:k})}}else if(a==="semantic"){let{segmentation:w,labels:y}=h(m,i??p)[0];for(let b of y){let v=new Uint8ClampedArray(w.data.length);for(let O=0;O<w.data.length;++O)w.data[O]===b&&(v[O]=255);let k=new ve(v,w.dims[1],w.dims[0],1);x.push({score:null,label:g[b],mask:k})}}else throw Error(`Subtask ${a} not supported.`);else{let y=m[d[0]];for(let b=0;b<p.length;++b){let v=p[b],k=y[b];k.data.some(N=>N<-1e-5||N>1+1e-5)&&k.sigmoid_();let O=await ve.fromTensor(k.mul_(255).to("uint8")).resize(v[1],v[0]);x.push({label:null,score:null,mask:O})}}return x}};var Ci=class extends bs{async _call(e,s={}){let r=await Me(e),n=await super._call(e,s),o=r.map((i,a)=>{let l=i.clone();return l.putAlpha(n[a].mask),l});return Array.isArray(e)?o:o[0]}};var Pi=class extends Q{async _call(e,s,{hypothesis_template:r="This is a photo of {}"}={}){let n=Array.isArray(e),o=await Me(e),i=s.map(_=>r.replace("{}",_)),a=this.tokenizer(i,{padding:this.model.config.model_type==="siglip"?"max_length":!0,truncation:!0}),{pixel_values:l}=await this.processor(o),c=await this.model({...a,pixel_values:l}),p=this.model.config.model_type==="siglip"?_=>_.sigmoid().data:_=>fe(_.data),u=[];for(let _ of c.logits_per_image){let m=[...p(_)].map((h,g)=>({score:h,label:s[g]}));m.sort((h,g)=>g.score-h.score),u.push(m)}return n?u:u[0]}};var Ni=class extends Q{async _call(e,{threshold:s=.9,percentage:r=!1}={}){let n=Array.isArray(e);if(n&&e.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");let o=await Me(e),i=r?null:o.map(d=>[d.height,d.width]),{pixel_values:a,pixel_mask:l}=await this.processor(o),c=await this.model({pixel_values:a,pixel_mask:l}),p=this.processor.image_processor.post_process_object_detection(c,s,i),{id2label:u}=this.model.config,_=p.map(d=>d.boxes.map((m,h)=>({score:d.scores[h],label:u[d.classes[h]],box:gi(m,!r)})));return n?_:_[0]}};var Li=class extends Q{async _call(e,s,{threshold:r=.1,top_k:n=null,percentage:o=!1}={}){let i=Array.isArray(e),a=await Me(e),l=this.tokenizer(s,{padding:!0,truncation:!0}),c=await this.processor(a),p=[];for(let u=0;u<a.length;++u){let _=a[u],d=o?null:[[_.height,_.width]],m=c.pixel_values[u].unsqueeze_(0),h=await this.model({...l,pixel_values:m}),g;if("post_process_grounded_object_detection"in this.processor){let x=this.processor.post_process_grounded_object_detection(h,l.input_ids,{box_threshold:r,text_threshold:r,target_sizes:d})[0];g=x.boxes.map((w,y)=>({score:x.scores[y],label:x.labels[y],box:gi(w,!o)}))}else{let x=this.processor.image_processor.post_process_object_detection(h,r,d,!0)[0];g=x.boxes.map((w,y)=>({score:x.scores[y],label:s[x.classes[y]],box:gi(w,!o)}))}g.sort((x,w)=>w.score-x.score),n!==null&&(g=g.slice(0,n)),p.push(g)}return i?p:p[0]}};var $i=class extends Q{async _call(e,s,r={}){if(Array.isArray(e)){if(e.length!==1)throw Error("Document Question Answering pipeline currently only supports a batch size of 1.");e=e[0]}let n=(await Me(e))[0],{pixel_values:o}=await this.processor(n),i=`<s_docvqa><s_question>${s}</s_question><s_answer>`,a=this.tokenizer(i,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,l=await this.model.generate({inputs:o,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:a,...r}),p=this.tokenizer.batch_decode(l)[0].match(/<s_answer>(.*?)<\/s_answer>/),u=null;return p&&p.length>=2&&(u=p[1].trim()),[{answer:u}]}};var Fi=class extends Q{async _call(e){let s=await Me(e),r=await this.processor(s),n=await this.model(r),o=[];for(let i of n.reconstruction){let a=i.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");o.push(ve.fromTensor(a))}return Array.isArray(e)?o:o[0]}};var Ri=class extends Q{async _call(e){let s=await Me(e),r=await this.processor(s),{predicted_depth:n}=await this.model(r),o=[];for(let i=0;i<s.length;++i){let a=n[i],[l,c]=a.dims.slice(-2),[p,u]=s[i].size,_=(await De(a.view(1,1,l,c),{size:[u,p],mode:"bilinear"})).view(u,p),d=_.min().item(),m=_.max().item(),h=_.sub(d).div_(m-d).mul_(255).to("uint8").unsqueeze(0),g=ve.fromTensor(h);o.push({predicted_depth:_,depth:g})}return Array.isArray(e)?o:o[0]}};var Di=class extends Q{async _call(e,{pooling:s="none",normalize:r=!1,quantize:n=!1,precision:o="binary"}={}){let i=this.tokenizer(e,{padding:!0,truncation:!0}),a=await this.model(i),l=a.last_hidden_state??a.logits??a.token_embeddings;switch(s){case"none":break;case"mean":l=j0(l,i.attention_mask);break;case"first_token":case"cls":l=l.slice(null,0);break;case"last_token":case"eos":l=l.slice(null,-1);break;default:throw Error(`Pooling method '${s}' not supported.`)}return r&&(l=l.normalize(2,-1)),n&&(l=q0(l,o)),l}};var ji=class extends Q{async _call(e,{pool:s=null}={}){let r=await Me(e),{pixel_values:n}=await this.processor(r),o=await this.model({pixel_values:n}),i;if(s){if(!("pooler_output"in o))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");i=o.pooler_output}else i=o.last_hidden_state??o.logits??o.image_embeds;return i}};var gr=Object.freeze({"text-classification":{pipeline:xi,model:di,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:wi,model:tc,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:yi,model:ac,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:bi,model:ic,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:ki,model:hr,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:vi,model:hr,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:vt,model:hr,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:Ei,model:oc,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:Ai,model:di,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:Mi,model:dc,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:Si,model:bt,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:Oi,model:[sc,_c],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:zi,model:[nc,rc],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:Ii,model:lc,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:Ti,model:cc,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:bs,model:[fi,mi,hi],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:Ci,model:[fi,mi,hi],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:Pi,model:bt,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:Ni,model:pc,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:Li,model:uc,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:$i,model:fc,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Fi,model:mc,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Ri,model:hc,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:Di,model:bt,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:ji,model:[gc,bt],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),xc=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});function wc(t,{warn:e=!0}={}){let s=t.architectures||[];for(let r of s){let n=ct.get(r);if(n!==void 0)return n}if(t.model_type){let r=ct.get(t.model_type);if(r!==void 0)return r;for(let n of Object.values(ls))if(n.has(t.model_type)){let o=ct.get(n.get(t.model_type));if(o!==void 0)return o}}if(e){let r=s.length>0?s.join(", "):"(none)";$.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${r}] for model type '${t.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${Nt}`)}return L.EncoderOnly}function dy(t,{config:e=null,cache_dir:s=null,local_files_only:r=!1,revision:n="main"}={}){if(e!==null)return et.from_pretrained(t,{config:e,cache_dir:s,local_files_only:r,revision:n});let o=JSON.stringify([t,s,r,n]);return Ji(o,()=>et.from_pretrained(t,{config:e,cache_dir:s,local_files_only:r,revision:n}))}async function yc(t,{config:e=null,dtype:s=null,device:r=null,model_file_name:n=null}={}){e=await dy(t,{config:e});let o=["config.json"],i=e["transformers.js_config"]??{},a=i.use_external_data_format,l="onnx",c=r??i.device,p=s??i.dtype,u=wc(e),_=(h,g=null)=>{g=g??h;let x=na(c,h),w=oa(p,h,x),y=Pt[w]??"",b=`${g}${y}.onnx`,v=l?`${l}/${b}`:b;o.push(v);let k=O_(a,b,h);for(let O of z_(b,k)){let N=l?`${l}/${O}`:O;o.push(N)}},{sessions:d,optional_configs:m}=Za(u,e,{model_file_name:n});for(let[h,g]of Object.entries(d))_(h,g);if(m)for(let h of Object.values(m))o.push(h);return o}async function bc(t){if(!t)throw new Error("modelId is required");return(await Je(t,yt,{})).exists?[yt]:[]}async function Et(t,{config:e=null,dtype:s=null,device:r=null,model_file_name:n=null,include_tokenizer:o=!0,include_processor:i=!0}={}){let a=await yc(t,{config:e,dtype:s,device:r,model_file_name:n});if(o){let l=await Cs(t);a.push(...l)}if(i){let l=await bc(t);a.push(...l)}return a}async function At(t,e,s={}){t=xc[t]??t;let r=gr[t];if(!r)throw new Error(`Unsupported pipeline task: ${t}. Must be one of [${Object.keys(gr).join(", ")}]`);let{type:n}=r;return Et(e,{...s,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"})}async function eY(t,e=null,{progress_callback:s=null,config:r=null,cache_dir:n=null,local_files_only:o=!1,revision:i="main",device:a=null,dtype:l=null,subfolder:c="onnx",use_external_data_format:p=null,model_file_name:u=null,session_options:_={}}={}){t=xc[t]??t;let d=gr[t.split("_",1)[0]];if(!d)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(gr)}]`);e||(e=d.default.model,$.info(`No model specified. Using default model: "${e}".`),!l&&d.default.dtype&&(l=d.default.dtype));let m=await At(t,e,{device:a,dtype:l}),h={};s&&(await Promise.all(m.map(async R=>Je(e,R)))).forEach((R,F)=>{R.exists&&(h[m[F]]={loaded:0,total:R.size??0})});let g={progress_callback:s?P=>{if(P.status==="progress"){h[P.file]={loaded:P.loaded,total:P.total};let R=Object.values(h).reduce((j,W)=>j+W.loaded,0),F=Object.values(h).reduce((j,W)=>j+W.total,0),U=F>0?R/F*100:0;s({status:"progress_total",name:P.name,progress:U,loaded:R,total:F,files:structuredClone(h)})}s(P)}:void 0,config:r,cache_dir:n,local_files_only:o,revision:i,device:a,dtype:l,subfolder:c,use_external_data_format:p,model_file_name:u,session_options:_},x=m.includes("tokenizer.json"),w=m.includes("preprocessor_config.json"),y=d.model,b;if(Array.isArray(y)){let P=r??await et.from_pretrained(e,g),{model_type:R}=P,F=y.find(U=>U.supports(R));if(!F)throw Error(`Unsupported model type "${R}" for task "${t}". None of the candidate model classes support this type.`);b=F.from_pretrained(e,{...g,config:P})}else b=y.from_pretrained(e,g);let[v,k,O]=await Promise.all([x?G.from_pretrained(e,g):null,w?$a.from_pretrained(e,g):null,b]),N={task:t,model:O};v&&(N.tokenizer=v),k&&(N.processor=k),gt(s,{status:"ready",task:t,model:e});let q=d.pipeline;return new q(N)}var lM=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,fy=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},ik=V.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),my=class extends fy{constructor(e,{skip_prompt:s=!1,callback_function:r=null,token_callback_function:n=null,skip_special_tokens:o=!0,decode_kwargs:i={},...a}={}){super(),this.tokenizer=e,this.skip_prompt=s,this.callback_function=r??ik,this.token_callback_function=n,this.decode_kwargs={skip_special_tokens:o,...i,...a},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0,this.special_ids=new Set(this.tokenizer.all_special_ids.map(BigInt))}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");let s=this.next_tokens_are_prompt;if(s&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let r=e[0];if(this.token_callback_function?.(r),r.length===1&&this.special_ids.has(r[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let l=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(l,!1),this.token_cache=[],this.print_len=0}let i=this.tokenizer.decode(r,this.decode_kwargs);this.on_finalized_text(i,!1);return}this.token_cache=$e(this.token_cache,r);let n=this.tokenizer.decode(this.token_cache,this.decode_kwargs),o;s||n.endsWith(`
27
+ `)?(o=n.slice(this.print_len),this.token_cache=[],this.print_len=0):n.length>0&&lM(n.charCodeAt(n.length-1))?(o=n.slice(this.print_len),this.print_len+=o.length):(o=n.slice(this.print_len,n.lastIndexOf(" ")+1),this.print_len+=o.length),this.on_finalized_text(o,!1)}end(){let e;this.token_cache.length>0?(e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0):e="",this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,s){e.length>0&&this.callback_function?.(e),s&&this.callback_function===ik&&V.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
28
+ `)}},ak=class extends my{constructor(e,{skip_prompt:s=!1,callback_function:r=null,token_callback_function:n=null,on_chunk_start:o=null,on_chunk_end:i=null,on_finalize:a=null,time_precision:l=.02,skip_special_tokens:c=!0,decode_kwargs:p={}}={}){super(e,{skip_prompt:s,skip_special_tokens:c,callback_function:r,token_callback_function:n,decode_kwargs:p}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=o,this.on_chunk_end=i,this.on_finalize=a,this.time_precision=l,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");let s=e[0];if(s.length===1){let r=Number(s[0])-this.timestamp_begin;if(r>=0){let n=r*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(n):this.on_chunk_start?.(n),this.waiting_for_timestamp=!this.waiting_for_timestamp,this.token_callback_function?.(s);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}};var Bi=class{constructor(e,s){this.image=e,this.timestamp=s}},kc=class{constructor(e,s){e.length>0&&e[0]instanceof ve&&(e=e.map((r,n)=>new Bi(r,(n+1)/(e.length+1)*s))),this.frames=e,this.duration=s}get width(){return this.frames[0].image.width}get height(){return this.frames[0].image.height}get fps(){return this.frames.length/this.duration}};async function cM(t,{num_frames:e=null,fps:s=null}={}){if(!V.IS_BROWSER_ENV)throw new Error("`load_video` is currently only supported in browser environments.");if(e==null&&s==null)throw new Error("Either num_frames or fps must be provided.");let r=[],n=document.createElement("video");if(n.crossOrigin="anonymous",n.muted=!0,typeof t=="string")n.src=t;else if(t instanceof Blob)n.src=URL.createObjectURL(t);else if(t instanceof HTMLVideoElement)n.src=t.src;else throw new Error("Invalid URL or video element provided.");if(await new Promise(u=>n.onloadedmetadata=u),n.seekable.start(0)===n.seekable.end(0)){let _=await(await Y.fetch(n.src)).blob();n.src=URL.createObjectURL(_),await new Promise(d=>n.onloadedmetadata=d)}let o=n.duration,i,a;e!=null?(i=e,a=e===1?0:o/(e-1)):(a=1/s,i=Math.floor(o/a));let l=[];for(let u=0;u<i;++u)l.push(e===1?o/2:u*a);let c=document.createElement("canvas");c.width=n.videoWidth,c.height=n.videoHeight;let p=c.getContext("2d",{willReadFrequently:!0});for(let u of l){n.currentTime=u,await new Promise(h=>{n.onseeked=h}),p.drawImage(n,0,0,c.width,c.height);let _=p.getImageData(0,0,c.width,c.height),d=new ve(_.data,c.width,c.height,4),m=new Bi(d,u);r.push(m)}return n.remove(),new kc(r,o)}async function vc(t,e,s={}){let r=await at(s?.cache_dir);if(!r)return{allCached:!1,files:e.map(i=>({file:i,cached:!1}))};let n=await Promise.all(e.map(async o=>{let{localPath:i,proposedCacheKey:a}=It(t,o,s,r),l=await Tt(r,i,a);return{file:o,cached:!!l}}));return{allCached:n.every(o=>o.cached),files:n}}async function lk(t,e,s={}){let r=await at(s?.cache_dir);if(!r)return!1;let{localPath:n,proposedCacheKey:o}=It(t,e,s,r);return!!await Tt(r,n,o)}async function ck(t,e={}){if(!t)throw new Error("modelId is required");if(!await lk(t,"config.json",e))return!1;let s=await Et(t,e);return(await vc(t,s,e)).allCached}async function pk(t,e={}){if(!t)throw new Error("modelId is required");let s=await Et(t,e);return await vc(t,s,e)}async function uk(t,e,s={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");if(!await lk(e,"config.json",s))return!1;let r=await At(t,e,s);return(await vc(e,r,s)).allCached}async function _k(t,e,s={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let r=await At(t,e,s);return await vc(e,r,s)}async function dk(t,e,s={}){let r=await at(s?.cache_dir);if(!r)return{filesDeleted:0,filesCached:0,files:e.map(o=>({file:o,deleted:!1,wasCached:!1}))};if(!r.delete)throw new Error("Cache does not support delete operation");let n=await Promise.all(e.map(async o=>{let{localPath:i,proposedCacheKey:a}=It(t,o,s,r),c=!!await Tt(r,i,a),p=!1;if(c){let u=await r.delete(a),_=!u&&a!==i?await r.delete(i):!1;p=u||_}return{file:o,deleted:p,wasCached:c}}));return{filesDeleted:n.filter(o=>o.deleted).length,filesCached:n.filter(o=>o.wasCached).length,files:n}}async function fk(t,e={}){if(!t)throw new Error("modelId is required");let s=await Et(t,e);return await dk(t,s,e)}async function mk(t,e,s={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let r=await At(t,e,s);return await dk(e,r,s)}var pM=Object.keys(Pt);async function hk(t,{config:e=null,model_file_name:s=null,revision:r="main",cache_dir:n=null,local_files_only:o=!1}={}){e=await dy(t,{config:e,cache_dir:n,local_files_only:o,revision:r});let i="onnx",a=wc(e),{sessions:l}=Za(a,e,{model_file_name:s}),c=Object.values(l),p={revision:r,cache_dir:n,local_files_only:o};return(await Promise.all(pM.map(async _=>{let d=Pt[_]??"",m=await Promise.all(c.map(async h=>{let g=`${i}/${h}${d}.onnx`;return(await Je(t,g,p)).exists}));return{dtype:_,available:m.every(Boolean)}}))).filter(_=>_.available).map(_=>_.dtype)}var hy=class{static async get_files(e,s={}){return Et(e,s)}static async get_pipeline_files(e,s,r={}){return At(e,s,r)}static async get_model_files(e,s={}){return yc(e,s)}static async get_tokenizer_files(e){return Cs(e)}static async get_processor_files(e){return bc(e)}static async get_available_dtypes(e,s={}){return hk(e,s)}static async is_cached(e,s={}){return ck(e,s)}static async is_cached_files(e,s={}){return pk(e,s)}static async is_pipeline_cached(e,s,r={}){return uk(e,s,r)}static async is_pipeline_cached_files(e,s,r={}){return _k(e,s,r)}static async get_file_metadata(e,s,r={}){return Je(e,s,r)}static async clear_cache(e,s={}){return fk(e,s)}static async clear_pipeline_cache(e,s,r={}){return mk(e,s,r)}};export{Kp as ASTFeatureExtractor,K_ as ASTForAudioClassification,H_ as ASTModel,Zr as ASTPreTrainedModel,G_ as AfmoeForCausalLM,U_ as AfmoeModel,Yr as AfmoePreTrainedModel,j_ as AlbertForMaskedLM,D_ as AlbertForQuestionAnswering,R_ as AlbertForSequenceClassification,F_ as AlbertModel,ps as AlbertPreTrainedModel,ep as AlbertTokenizer,q_ as ApertusForCausalLM,B_ as ApertusModel,Qr as ApertusPreTrainedModel,V_ as ArceeForCausalLM,W_ as ArceeModel,Jr as ArceePreTrainedModel,Mi as AudioClassificationPipeline,et as AutoConfig,ge as AutoFeatureExtractor,le as AutoImageProcessor,bt as AutoModel,dc as AutoModelForAudioClassification,Jb as AutoModelForAudioFrameClassification,rk as AutoModelForAudioTextToText,_c as AutoModelForCTC,oc as AutoModelForCausalLM,hc as AutoModelForDepthEstimation,fc as AutoModelForDocumentQuestionAnswering,cc as AutoModelForImageClassification,gc as AutoModelForImageFeatureExtraction,Zb as AutoModelForImageMatting,fi as AutoModelForImageSegmentation,sk as AutoModelForImageTextToText,mc as AutoModelForImageToImage,Qb as AutoModelForMaskGeneration,ic as AutoModelForMaskedLM,ek as AutoModelForNormalEstimation,pc as AutoModelForObjectDetection,tk as AutoModelForPoseEstimation,ac as AutoModelForQuestionAnswering,mi as AutoModelForSemanticSegmentation,hr as AutoModelForSeq2SeqLM,di as AutoModelForSequenceClassification,sc as AutoModelForSpeechSeq2Seq,rc as AutoModelForTextToSpectrogram,nc as AutoModelForTextToWaveform,tc as AutoModelForTokenClassification,hi as AutoModelForUniversalSegmentation,lc as AutoModelForVision2Seq,Yb as AutoModelForXVector,uc as AutoModelForZeroShotObjectDetection,$a as AutoProcessor,G as AutoTokenizer,Oi as AutomaticSpeechRecognitionPipeline,Ci as BackgroundRemovalPipeline,Q_ as BartForConditionalGeneration,Y_ as BartForSequenceClassification,X_ as BartModel,Ks as BartPretrainedModel,tp as BartTokenizer,fy as BaseStreamer,uu as BeitFeatureExtractor,Z_ as BeitForImageClassification,J_ as BeitModel,en as BeitPreTrainedModel,td as BertForMaskedLM,nd as BertForQuestionAnswering,sd as BertForSequenceClassification,rd as BertForTokenClassification,ed as BertModel,Rt as BertPreTrainedModel,sp as BertTokenizer,_u as BitImageProcessor,id as BlenderbotForConditionalGeneration,od as BlenderbotModel,tn as BlenderbotPreTrainedModel,ld as BlenderbotSmallForConditionalGeneration,ad as BlenderbotSmallModel,sn as BlenderbotSmallPreTrainedModel,rp as BlenderbotSmallTokenizer,np as BlenderbotTokenizer,pd as BloomForCausalLM,cd as BloomModel,rn as BloomPreTrainedModel,op as BloomTokenizer,gd as CHMv2ForDepthEstimation,fu as CHMv2ImageProcessor,nl as CHMv2PreTrainedModel,mu as CLIPFeatureExtractor,ha as CLIPImageProcessor,wd as CLIPModel,mt as CLIPPreTrainedModel,Ed as CLIPSegForImageSegmentation,vd as CLIPSegModel,cn as CLIPSegPreTrainedModel,yd as CLIPTextModel,ln as CLIPTextModelWithProjection,ap as CLIPTokenizer,bd as CLIPVisionModel,kd as CLIPVisionModelWithProjection,_d as CamembertForMaskedLM,md as CamembertForQuestionAnswering,dd as CamembertForSequenceClassification,fd as CamembertForTokenClassification,ud as CamembertModel,Dt as CamembertPreTrainedModel,ip as CamembertTokenizer,Xp as ChatterboxFeatureExtractor,nn as ChatterboxModel,sl as ChatterboxPreTrainedModel,lu as ChatterboxProcessor,du as ChineseCLIPFeatureExtractor,hd as ChineseCLIPModel,rl as ChineseCLIPPreTrainedModel,an as ClapAudioModelWithProjection,Qp as ClapFeatureExtractor,xd as ClapModel,Xs as ClapPreTrainedModel,on as ClapTextModelWithProjection,Va as ClassifierFreeGuidanceLogitsProcessor,Md as CodeGenForCausalLM,Ad as CodeGenModel,pn as CodeGenPreTrainedModel,cp as CodeGenTokenizer,lp as CodeLlamaTokenizer,Id as Cohere2ForCausalLM,zd as Cohere2Model,_n as Cohere2PreTrainedModel,Yp as CohereAsrFeatureExtractor,Cd as CohereAsrForConditionalGeneration,Td as CohereAsrModel,dn as CohereAsrPreTrainedModel,cu as CohereAsrProcessor,up as CohereAsrTokenizer,Od as CohereForCausalLM,Sd as CohereModel,un as CoherePreTrainedModel,pp as CohereTokenizer,Nd as ConvBertForMaskedLM,Fd as ConvBertForQuestionAnswering,Ld as ConvBertForSequenceClassification,$d as ConvBertForTokenClassification,Pd as ConvBertModel,jt as ConvBertPreTrainedModel,_p as ConvBertTokenizer,hu as ConvNextFeatureExtractor,Dd as ConvNextForImageClassification,ga as ConvNextImageProcessor,Rd as ConvNextModel,fn as ConvNextPreTrainedModel,Bd as ConvNextV2ForImageClassification,jd as ConvNextV2Model,mn as ConvNextV2PreTrainedModel,Wd as DFineForObjectDetection,Gd as DFineModel,gn as DFinePreTrainedModel,xf as DINOv3ConvNextModel,ul as DINOv3ConvNextPreTrainedModel,wu as DINOv3ViTImageProcessor,wf as DINOv3ViTModel,_l as DINOv3ViTPreTrainedModel,bu as DPTFeatureExtractor,Sf as DPTForDepthEstimation,ya as DPTImageProcessor,Mf as DPTModel,En as DPTPreTrainedModel,wn as DacDecoderModel,il as DacDecoderOutput,xn as DacEncoderModel,ol as DacEncoderOutput,jr as DacFeatureExtractor,Vd as DacModel,Qs as DacPreTrainedModel,Kd as DebertaForMaskedLM,Yd as DebertaForQuestionAnswering,Xd as DebertaForSequenceClassification,Qd as DebertaForTokenClassification,Hd as DebertaModel,Bt as DebertaPreTrainedModel,fp as DebertaTokenizer,tf as DebertaV2ForMaskedLM,nf as DebertaV2ForQuestionAnswering,sf as DebertaV2ForSequenceClassification,rf as DebertaV2ForTokenClassification,ef as DebertaV2Model,qt as DebertaV2PreTrainedModel,dp as DebertaV2Tokenizer,of as DecisionTransformerModel,al as DecisionTransformerPreTrainedModel,Zd as DeepseekV3ForCausalLM,Jd as DeepseekV3Model,yn as DeepseekV3PreTrainedModel,gu as DeiTFeatureExtractor,lf as DeiTForImageClassification,xa as DeiTImageProcessor,af as DeiTModel,bn as DeiTPreTrainedModel,cf as DepthAnythingForDepthEstimation,ll as DepthAnythingPreTrainedModel,Ri as DepthEstimationPipeline,pf as DepthProForDepthEstimation,cl as DepthProPreTrainedModel,xu as DetrFeatureExtractor,_f as DetrForObjectDetection,df as DetrForSegmentation,wa as DetrImageProcessor,uf as DetrModel,Js as DetrObjectDetectionOutput,Ys as DetrPreTrainedModel,pl as DetrSegmentationOutput,mf as Dinov2ForImageClassification,ff as Dinov2Model,kn as Dinov2PreTrainedModel,gf as Dinov2WithRegistersForImageClassification,hf as Dinov2WithRegistersModel,vn as Dinov2WithRegistersPreTrainedModel,Ef as DistilBertForMaskedLM,vf as DistilBertForQuestionAnswering,bf as DistilBertForSequenceClassification,kf as DistilBertForTokenClassification,yf as DistilBertModel,Ut as DistilBertPreTrainedModel,mp as DistilBertTokenizer,$i as DocumentQuestionAnsweringPipeline,yu as DonutFeatureExtractor,Ls as DonutImageProcessor,Af as DonutSwinModel,dl as DonutSwinPreTrainedModel,Kr as DynamicCache,$x as EdgeTamModel,zf as EfficientNetForImageClassification,ku as EfficientNetImageProcessor,Of as EfficientNetModel,An as EfficientNetPreTrainedModel,Tf as ElectraForMaskedLM,Nf as ElectraForQuestionAnswering,Cf as ElectraForSequenceClassification,Pf as ElectraForTokenClassification,If as ElectraModel,Gt as ElectraPreTrainedModel,hp as ElectraTokenizer,Rr as EncodecFeatureExtractor,Xa as EosTokenCriteria,$f as Ernie4_5ForCausalLM,Lf as Ernie4_5Model,Mn as Ernie4_5PretrainedModel,Rf as EsmForMaskedLM,Df as EsmForSequenceClassification,jf as EsmForTokenClassification,Ff as EsmModel,us as EsmPreTrainedModel,gp as EsmTokenizer,qf as EuroBertForMaskedLM,Uf as EuroBertForSequenceClassification,Gf as EuroBertForTokenClassification,Bf as EuroBertModel,_s as EuroBertPreTrainedModel,Vf as ExaoneForCausalLM,Wf as ExaoneModel,Sn as ExaonePreTrainedModel,Kf as FalconForCausalLM,Qf as FalconH1ForCausalLM,Xf as FalconH1Model,zn as FalconH1PreTrainedModel,Hf as FalconModel,On as FalconPreTrainedModel,xp as FalconTokenizer,Jf as FastViTForImageClassification,Yf as FastViTModel,In as FastViTPreTrainedModel,Di as FeatureExtractionPipeline,ae as FeatureExtractor,bi as FillMaskPipeline,Zf as Florence2ForConditionalGeneration,fl as Florence2PreTrainedModel,t_ as Florence2Processor,Ra as ForcedBOSTokenLogitsProcessor,Da as ForcedEOSTokenLogitsProcessor,Au as GLPNFeatureExtractor,mm as GLPNForDepthEstimation,fm as GLPNModel,Fn as GLPNPreTrainedModel,Am as GPT2LMHeadModel,Em as GPT2Model,qn as GPT2PreTrainedModel,bp as GPT2Tokenizer,gm as GPTBigCodeForCausalLM,hm as GPTBigCodeModel,Rn as GPTBigCodePreTrainedModel,Sm as GPTJForCausalLM,Mm as GPTJModel,Un as GPTJPreTrainedModel,wm as GPTNeoForCausalLM,xm as GPTNeoModel,Dn as GPTNeoPreTrainedModel,bm as GPTNeoXForCausalLM,ym as GPTNeoXModel,jn as GPTNeoXPreTrainedModel,yp as GPTNeoXTokenizer,rm as Gemma2ForCausalLM,sm as Gemma2Model,Cn as Gemma2PreTrainedModel,am as Gemma3ForCausalLM,gl as Gemma3ForConditionalGeneration,vu as Gemma3ImageProcessor,im as Gemma3Model,hl as Gemma3PreTrainedModel,s_ as Gemma3Processor,Jp as Gemma3nAudioFeatureExtractor,lm as Gemma3nForCausalLM,Zs as Gemma3nForConditionalGeneration,xl as Gemma3nPreTrainedModel,r_ as Gemma3nProcessor,tm as GemmaForCausalLM,em as GemmaModel,Tn as GemmaPreTrainedModel,wp as GemmaTokenizer,Eu as Glm46VImageProcessor,n_ as Glm46VProcessor,pm as GlmForCausalLM,cm as GlmModel,_m as GlmMoeDsaForCausalLM,um as GlmMoeDsaModel,Nn as GlmMoeDsaPreTrainedModel,dm as GlmOcrForConditionalGeneration,Pn as GlmPreTrainedModel,vm as GptOssForCausalLM,km as GptOssModel,Bn as GptOssPreTrainedModel,zm as GraniteForCausalLM,Om as GraniteModel,Tm as GraniteMoeHybridForCausalLM,Im as GraniteMoeHybridModel,Wn as GraniteMoeHybridPreTrainedModel,Gn as GranitePreTrainedModel,Zp as GraniteSpeechFeatureExtractor,Cm as GraniteSpeechForConditionalGeneration,o_ as GraniteSpeechProcessor,Pm as GroundingDinoForObjectDetection,Mu as GroundingDinoImageProcessor,bl as GroundingDinoPreTrainedModel,i_ as GroundingDinoProcessor,Nm as GroupViTModel,kl as GroupViTPreTrainedModel,$m as HeliumForCausalLM,Lm as HeliumModel,Vn as HeliumPreTrainedModel,kp as HerbertTokenizer,Rm as HieraForImageClassification,Fm as HieraModel,Hn as HieraPreTrainedModel,Wm as HubertForCTC,Vm as HubertForSequenceClassification,Gm as HubertModel,Um as HubertPreTrainedModel,Km as HunYuanDenseV1ForCausalLM,Hm as HunYuanDenseV1Model,Kn as HunYuanDenseV1PreTrainedModel,Ym as IJepaForImageClassification,Qm as IJepaModel,Xn as IJepaPreTrainedModel,Xm as Idefics3ForConditionalGeneration,ba as Idefics3ImageProcessor,Ta as Idefics3Processor,Ti as ImageClassificationPipeline,ji as ImageFeatureExtractionPipeline,C as ImageFeatureExtractor,C as ImageProcessor,bs as ImageSegmentationPipeline,Fi as ImageToImagePipeline,Ii as ImageToTextPipeline,db as InterruptableStoppingCriteria,Zm as JAISLMHeadModel,Jm as JAISModel,Qn as JAISPreTrainedModel,Ou as JinaCLIPImageProcessor,eh as JinaCLIPModel,tr as JinaCLIPPreTrainedModel,l_ as JinaCLIPProcessor,Yn as JinaCLIPTextModel,th as JinaCLIPVisionModel,rh as Lfm2ForCausalLM,sh as Lfm2Model,ih as Lfm2MoeForCausalLM,oh as Lfm2MoeModel,Zn as Lfm2MoePreTrainedModel,Jn as Lfm2PreTrainedModel,ah as Lfm2VlForConditionalGeneration,zu as Lfm2VlImageProcessor,c_ as Lfm2VlProcessor,nh as LightOnOcrForConditionalGeneration,Yw as LiteWhisperForConditionalGeneration,ph as Llama4ForCausalLM,vl as Llama4PreTrainedModel,ch as LlamaForCausalLM,lh as LlamaModel,eo as LlamaPreTrainedModel,vp as LlamaTokenizer,Be as LlavaForConditionalGeneration,Be as LlavaOnevisionForConditionalGeneration,Iu as LlavaOnevisionImageProcessor,ml as LlavaPreTrainedModel,p_ as LlavaProcessor,om as LlavaQwen2ForCausalLM,qe as LogLevel,tt as LogitsProcessor,is as LogitsProcessorList,Hr as LogitsWarper,_h as LongT5ForConditionalGeneration,uh as LongT5Model,to as LongT5PreTrainedModel,fh as M2M100ForConditionalGeneration,dh as M2M100Model,so as M2M100PreTrainedModel,Ep as M2M100Tokenizer,Mp as MBart50Tokenizer,kh as MBartForCausalLM,yh as MBartForConditionalGeneration,bh as MBartForSequenceClassification,wh as MBartModel,ms as MBartPreTrainedModel,Nr as MBartTokenizer,lg as MPNetForMaskedLM,ug as MPNetForQuestionAnswering,cg as MPNetForSequenceClassification,pg as MPNetForTokenClassification,ag as MPNetModel,Wt as MPNetPreTrainedModel,zp as MPNetTokenizer,mg as MT5ForConditionalGeneration,fg as MT5Model,ho as MT5PreTrainedModel,hh as MarianMTModel,mh as MarianModel,ro as MarianPreTrainedModel,Ap as MarianTokenizer,Cu as Mask2FormerImageProcessor,Tu as MaskFormerFeatureExtractor,xh as MaskFormerForInstanceSegmentation,$s as MaskFormerImageProcessor,gh as MaskFormerModel,no as MaskFormerPreTrainedModel,Ka as MaxLengthCriteria,vh as Metric3DForDepthEstimation,El as Metric3DPreTrainedModel,Eh as Metric3Dv2ForDepthEstimation,Al as Metric3Dv2PreTrainedModel,Ah as MgpstrForSceneTextRecognition,Ml as MgpstrModelOutput,Sl as MgpstrPreTrainedModel,u_ as MgpstrProcessor,Sp as MgpstrTokenizer,io as MimiDecoderModel,zl as MimiDecoderOutput,oo as MimiEncoderModel,Ol as MimiEncoderOutput,Mh as MimiModel,sr as MimiPreTrainedModel,Ua as MinLengthLogitsProcessor,Ga as MinNewTokensLengthLogitsProcessor,Ih as Mistral4ForCausalLM,zh as Mistral4Model,lo as Mistral4PreTrainedModel,Oh as MistralForCausalLM,Sh as MistralModel,ao as MistralPreTrainedModel,Ch as MobileBertForMaskedLM,Nh as MobileBertForQuestionAnswering,Ph as MobileBertForSequenceClassification,Th as MobileBertModel,hs as MobileBertPreTrainedModel,Op as MobileBertTokenizer,$h as MobileLLMForCausalLM,Lh as MobileLLMModel,co as MobileLLMPreTrainedModel,Pu as MobileNetV1FeatureExtractor,Rh as MobileNetV1ForImageClassification,Dh as MobileNetV1ForSemanticSegmentation,ka as MobileNetV1ImageProcessor,Fh as MobileNetV1Model,rr as MobileNetV1PreTrainedModel,Nu as MobileNetV2FeatureExtractor,Bh as MobileNetV2ForImageClassification,qh as MobileNetV2ForSemanticSegmentation,va as MobileNetV2ImageProcessor,jh as MobileNetV2Model,nr as MobileNetV2PreTrainedModel,Lu as MobileNetV3FeatureExtractor,Gh as MobileNetV3ForImageClassification,Wh as MobileNetV3ForSemanticSegmentation,Ea as MobileNetV3ImageProcessor,Uh as MobileNetV3Model,or as MobileNetV3PreTrainedModel,$u as MobileNetV4FeatureExtractor,Hh as MobileNetV4ForImageClassification,Kh as MobileNetV4ForSemanticSegmentation,Aa as MobileNetV4ImageProcessor,Vh as MobileNetV4Model,ir as MobileNetV4PreTrainedModel,Fu as MobileViTFeatureExtractor,Qh as MobileViTForImageClassification,Ma as MobileViTImageProcessor,Xh as MobileViTModel,po as MobileViTPreTrainedModel,Jh as MobileViTV2ForImageClassification,Yh as MobileViTV2Model,uo as MobileViTV2PreTrainedModel,hy as ModelRegistry,ng as ModernBertDecoderForCausalLM,rg as ModernBertDecoderModel,_o as ModernBertDecoderPreTrainedModel,eg as ModernBertForMaskedLM,tg as ModernBertForSequenceClassification,sg as ModernBertForTokenClassification,Zh as ModernBertModel,gs as ModernBertPreTrainedModel,nm as Moondream1ForConditionalGeneration,eu as MoonshineFeatureExtractor,ig as MoonshineForConditionalGeneration,og as MoonshineModel,fo as MoonshinePreTrainedModel,__ as MoonshineProcessor,dg as MptForCausalLM,_g as MptModel,mo as MptPreTrainedModel,hg as MultiModalityCausalLM,Il as MultiModalityPreTrainedModel,xg as MusicgenForCausalLM,xo as MusicgenForConditionalGeneration,gg as MusicgenModel,go as MusicgenPreTrainedModel,yg as NanoChatForCausalLM,wg as NanoChatModel,wo as NanoChatPreTrainedModel,kg as NemotronHForCausalLM,bg as NemotronHModel,yo as NemotronHPreTrainedModel,Eg as NeoBertForMaskedLM,Sg as NeoBertForQuestionAnswering,Ag as NeoBertForSequenceClassification,Mg as NeoBertForTokenClassification,vg as NeoBertModel,Vt as NeoBertPreTrainedModel,Ip as NllbTokenizer,Wa as NoBadWordsLogitsProcessor,Ba as NoRepeatNGramLogitsProcessor,Og as NomicBertModel,Tl as NomicBertPreTrainedModel,Ru as NougatImageProcessor,Tp as NougatTokenizer,jg as OPTForCausalLM,Dg as OPTModel,Mo as OPTPreTrainedModel,Ni as ObjectDetectionPipeline,Cg as Olmo2ForCausalLM,Tg as Olmo2Model,ko as Olmo2PreTrainedModel,Ng as Olmo3ForCausalLM,Pg as Olmo3Model,vo as Olmo3PreTrainedModel,Ig as OlmoForCausalLM,$g as OlmoHybridForCausalLM,Lg as OlmoHybridModel,Eo as OlmoHybridPreTrainedModel,zg as OlmoModel,bo as OlmoPreTrainedModel,Rg as OpenELMForCausalLM,Fg as OpenELMModel,Ao as OpenELMPreTrainedModel,Du as OwlViTFeatureExtractor,Gg as OwlViTForObjectDetection,Fs as OwlViTImageProcessor,Ug as OwlViTModel,Oo as OwlViTPreTrainedModel,d_ as OwlViTProcessor,qg as Owlv2ForObjectDetection,ju as Owlv2ImageProcessor,Bg as Owlv2Model,So as Owlv2PreTrainedModel,Wg as PaliGemmaForConditionalGeneration,f_ as PaliGemmaProcessor,Dr as ParakeetFeatureExtractor,Vg as ParakeetForCTC,Cl as ParakeetPreTrainedModel,Kg as PatchTSMixerForPrediction,Hg as PatchTSMixerModel,zo as PatchTSMixerPreTrainedModel,Qg as PatchTSTForPrediction,Xg as PatchTSTModel,Io as PatchTSTPreTrainedModel,ex as Phi3ForCausalLM,Zg as Phi3Model,Co as Phi3PreTrainedModel,Po as Phi3VForCausalLM,Uu as Phi3VImageProcessor,Pl as Phi3VPreTrainedModel,m_ as Phi3VProcessor,Jg as PhiForCausalLM,Yg as PhiModel,To as PhiPreTrainedModel,Gu as PixtralImageProcessor,h_ as PixtralProcessor,f as PreTrainedModel,I as PreTrainedTokenizer,qs as PretrainedConfig,B as Processor,sx as PvtForImageClassification,Wu as PvtImageProcessor,tx as PvtModel,No as PvtPreTrainedModel,Br as PyAnnoteFeatureExtractor,nx as PyAnnoteForAudioFrameClassification,rx as PyAnnoteModel,Lo as PyAnnotePreTrainedModel,g_ as PyAnnoteProcessor,yi as QuestionAnsweringPipeline,ix as Qwen2ForCausalLM,ox as Qwen2Model,lx as Qwen2MoeForCausalLM,ax as Qwen2MoeModel,Fo as Qwen2MoePreTrainedModel,$o as Qwen2PreTrainedModel,Cp as Qwen2Tokenizer,Ln as Qwen2VLForCausalLM,er as Qwen2VLForConditionalGeneration,Ur as Qwen2VLImageProcessor,wl as Qwen2VLPreTrainedModel,ns as Qwen2VLProcessor,$n as Qwen2_5_VLForCausalLM,ds as Qwen2_5_VLForConditionalGeneration,Wr as Qwen2_5_VLProcessor,px as Qwen3ForCausalLM,cx as Qwen3Model,_x as Qwen3MoeForCausalLM,ux as Qwen3MoeModel,Do as Qwen3MoePreTrainedModel,fx as Qwen3NextForCausalLM,dx as Qwen3NextModel,jo as Qwen3NextPreTrainedModel,Ro as Qwen3PreTrainedModel,Bo as Qwen3VLForCausalLM,xs as Qwen3VLForConditionalGeneration,hx as Qwen3VLMoeForCausalLM,mx as Qwen3VLMoeForConditionalGeneration,x_ as Qwen3VLProcessor,qo as Qwen3_5ForCausalLM,ar as Qwen3_5ForConditionalGeneration,xx as Qwen3_5MoeForCausalLM,gx as Qwen3_5MoeForConditionalGeneration,kx as RFDetrForObjectDetection,bx as RFDetrModel,Nl as RFDetrObjectDetectionOutput,Go as RFDetrPreTrainedModel,Ud as RTDetrForObjectDetection,Vu as RTDetrImageProcessor,qd as RTDetrModel,ht as RTDetrObjectDetectionOutput,hn as RTDetrPreTrainedModel,Nx as RTDetrV2ForObjectDetection,Px as RTDetrV2Model,Ll as RTDetrV2ObjectDetectionOutput,Wo as RTDetrV2PreTrainedModel,Fr as RawAudio,ve as RawImage,kc as RawVideo,Bi as RawVideoFrame,qa as RepetitionPenaltyLogitsProcessor,yx as ResNetForImageClassification,wx as ResNetModel,Uo as ResNetPreTrainedModel,zx as RoFormerForMaskedLM,Cx as RoFormerForQuestionAnswering,Ix as RoFormerForSequenceClassification,Tx as RoFormerForTokenClassification,Ox as RoFormerModel,Kt as RoFormerPreTrainedModel,Np as RoFormerTokenizer,Ex as RobertaForMaskedLM,Sx as RobertaForQuestionAnswering,Ax as RobertaForSequenceClassification,Mx as RobertaForTokenClassification,vx as RobertaModel,Ht as RobertaPreTrainedModel,Pp as RobertaTokenizer,Gr as Sam2ImageProcessor,Rl as Sam2ImageSegmentationOutput,Vo as Sam2Model,Dl as Sam2PreTrainedModel,Ca as Sam2Processor,w_ as Sam2VideoProcessor,Gr as Sam3ImageProcessor,Fx as Sam3TrackerModel,Gr as SamImageProcessor,$l as SamImageSegmentationOutput,Lx as SamModel,Fl as SamPreTrainedModel,Vr as SamProcessor,Hu as SapiensFeatureExtractor,Dx as SapiensForDepthEstimation,jx as SapiensForNormalEstimation,Rx as SapiensForSemanticSegmentation,Sa as SapiensImageProcessor,lr as SapiensPreTrainedModel,tu as SeamlessM4TFeatureExtractor,Ku as SegformerFeatureExtractor,qx as SegformerForImageClassification,Ux as SegformerForSemanticSegmentation,Oa as SegformerImageProcessor,Bx as SegformerModel,cr as SegformerPreTrainedModel,Xu as SiglipImageProcessor,Gx as SiglipModel,Ho as SiglipPreTrainedModel,Ko as SiglipTextModel,Lp as SiglipTokenizer,Wx as SiglipVisionModel,Hx as SmolLM3ForCausalLM,Vx as SmolLM3Model,Xo as SmolLM3PreTrainedModel,ba as SmolVLMImageProcessor,Ta as SmolVLMProcessor,Yo as SnacDecoderModel,Qo as SnacEncoderModel,su as SnacFeatureExtractor,Kx as SnacModel,pr as SnacPreTrainedModel,Qx as SolarOpenForCausalLM,Xx as SolarOpenModel,Jo as SolarOpenPreTrainedModel,ru as SpeechT5FeatureExtractor,Jx as SpeechT5ForSpeechToText,Zx as SpeechT5ForTextToSpeech,ew as SpeechT5HifiGan,Yx as SpeechT5Model,ur as SpeechT5PreTrainedModel,y_ as SpeechT5Processor,$p as SpeechT5Tokenizer,sw as SqueezeBertForMaskedLM,nw as SqueezeBertForQuestionAnswering,rw as SqueezeBertForSequenceClassification,tw as SqueezeBertModel,ws as SqueezeBertPreTrainedModel,Fp as SqueezeBertTokenizer,iw as StableLmForCausalLM,ow as StableLmModel,Zo as StableLmPreTrainedModel,lw as Starcoder2ForCausalLM,aw as Starcoder2Model,ei as Starcoder2PreTrainedModel,Ft as StoppingCriteria,Ws as StoppingCriteriaList,cw as StyleTextToSpeech2Model,jl as StyleTextToSpeech2PreTrainedModel,ki as SummarizationPipeline,ti as SupertonicForConditionalGeneration,Bl as SupertonicPreTrainedModel,Us as SuppressTokensAtBeginLogitsProcessor,fw as Swin2SRForImageSuperResolution,Qu as Swin2SRImageProcessor,dw as Swin2SRModel,si as Swin2SRPreTrainedModel,uw as SwinForImageClassification,_w as SwinForSemanticSegmentation,pw as SwinModel,_r as SwinPreTrainedModel,hw as T5ForConditionalGeneration,mw as T5Model,ri as T5PreTrainedModel,Rp as T5Tokenizer,xw as TableTransformerForObjectDetection,gw as TableTransformerModel,ql as TableTransformerObjectDetectionOutput,ni as TableTransformerPreTrainedModel,Ha as TemperatureLogitsWarper,E as Tensor,vt as Text2TextGenerationPipeline,xi as TextClassificationPipeline,Ei as TextGenerationPipeline,my as TextStreamer,zi as TextToAudioPipeline,wi as TokenClassificationPipeline,I as TokenizersBackend,_b as TopKLogitsWarper,ub as TopPLogitsWarper,ww as TrOCRForCausalLM,Ul as TrOCRPreTrainedModel,vi as TranslationPipeline,fs as UltravoxModel,yl as UltravoxPreTrainedModel,b_ as UltravoxProcessor,bw as UniSpeechForCTC,kw as UniSpeechForSequenceClassification,yw as UniSpeechModel,dr as UniSpeechPreTrainedModel,Mw as UniSpeechSatForAudioFrameClassification,Ew as UniSpeechSatForCTC,Aw as UniSpeechSatForSequenceClassification,vw as UniSpeechSatModel,ys as UniSpeechSatPreTrainedModel,a_ as VLChatProcessor,Su as VLMImageProcessor,Ow as VaultGemmaForCausalLM,Sw as VaultGemmaModel,oi as VaultGemmaPreTrainedModel,Yu as ViTFeatureExtractor,Tw as ViTForImageClassification,za as ViTImageProcessor,Cw as ViTMAEModel,Gl as ViTMAEPreTrainedModel,Nw as ViTMSNForImageClassification,Pw as ViTMSNModel,ai as ViTMSNPreTrainedModel,Iw as ViTModel,ii as ViTPreTrainedModel,zw as VisionEncoderDecoderModel,Lw as VitMatteForImageMatting,Ju as VitMatteImageProcessor,Wl as VitMattePreTrainedModel,$w as VitPoseForPoseEstimation,Zu as VitPoseImageProcessor,Vl as VitPosePreTrainedModel,Fw as VitsModel,Hl as VitsModelOutput,Kl as VitsPreTrainedModel,jp as VitsTokenizer,Rw as VoxtralForConditionalGeneration,k_ as VoxtralProcessor,iu as VoxtralRealtimeFeatureExtractor,li as VoxtralRealtimeForConditionalGeneration,Xl as VoxtralRealtimePreTrainedModel,E_ as VoxtralRealtimeProcessor,qw as Wav2Vec2BertForCTC,Uw as Wav2Vec2BertForSequenceClassification,Bw as Wav2Vec2BertModel,fr as Wav2Vec2BertPreTrainedModel,Bp as Wav2Vec2CTCTokenizer,nu as Wav2Vec2FeatureExtractor,qm as Wav2Vec2ForAudioFrameClassification,jm as Wav2Vec2ForCTC,Bm as Wav2Vec2ForSequenceClassification,Dm as Wav2Vec2Model,pt as Wav2Vec2PreTrainedModel,A_ as Wav2Vec2Processor,M_ as Wav2Vec2ProcessorWithLM,Kw as WavLMForAudioFrameClassification,Ww as WavLMForCTC,Vw as WavLMForSequenceClassification,Hw as WavLMForXVector,Gw as WavLMModel,Xt as WavLMPreTrainedModel,ou as WeSpeakerFeatureExtractor,Xw as WeSpeakerResNetModel,Yl as WeSpeakerResNetPreTrainedModel,au as WhisperFeatureExtractor,Zl as WhisperForConditionalGeneration,Qw as WhisperModel,ci as WhisperPreTrainedModel,S_ as WhisperProcessor,ak as WhisperTextStreamer,ja as WhisperTimeStampLogitsProcessor,qp as WhisperTokenizer,sy as XLMForQuestionAnswering,ey as XLMForSequenceClassification,ty as XLMForTokenClassification,Jw as XLMModel,Qt as XLMPreTrainedModel,ny as XLMRobertaForMaskedLM,ay as XLMRobertaForQuestionAnswering,oy as XLMRobertaForSequenceClassification,iy as XLMRobertaForTokenClassification,ry as XLMRobertaModel,Yt as XLMRobertaPreTrainedModel,Up as XLMRobertaTokenizer,Gp as XLMTokenizer,Zw as XLMWithLMHeadModel,Ql as XVectorOutput,e_ as YolosFeatureExtractor,cy as YolosForObjectDetection,Ia as YolosImageProcessor,ly as YolosModel,ec as YolosObjectDetectionOutput,pi as YolosPreTrainedModel,uy as YoutuForCausalLM,py as YoutuModel,ui as YoutuPreTrainedModel,Si as ZeroShotAudioClassificationPipeline,Ai as ZeroShotClassificationPipeline,Pi as ZeroShotImageClassificationPipeline,Li as ZeroShotObjectDetectionPipeline,oe as cat,UE as cos_sim,x0 as dot,Y as env,be as full,Pr as full_like,Hc as interpolate,De as interpolate_4d,L2 as layer_norm,wA as load_image,cM as load_video,qc as log_softmax,D0 as matmul,la as mean,j0 as mean_pooling,Ae as ones,ca as ones_like,YE as permute,eY as pipeline,q0 as quantize_embeddings,$2 as rand,B0 as randn,es as random,Hp as read_audio,N2 as rfft,aa as slice,fe as softmax,Ue as stack,Kc as std_mean,lt as topk,Qc as zeros,Yc as zeros_like};