sliccy 5.59.1 → 5.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/assets/__vite-browser-external-DZX1xHt-.js +1 -0
- package/dist/ui/assets/account-store-BddNCTSm.js +98 -0
- package/dist/ui/assets/account-store-dvAfa3y8.js +38 -0
- package/dist/ui/assets/adobe-C0iTCwW2.js +1 -0
- package/dist/ui/assets/adobe-DC5UT0ZJ.js +2 -0
- package/dist/ui/assets/adobe-oauth-state-Csa5ciQS.js +1 -0
- package/dist/ui/assets/{adobe-oauth-state-BeQ7T3Vk.js → adobe-oauth-state-Vbbfo7gR.js} +1 -1
- package/dist/ui/assets/agent-message-to-chat-QyCEPmi8.js +7 -0
- package/dist/ui/assets/{anthropic-messages-BP_xL8Mh.js → anthropic-messages-CIsUSIzG.js} +3 -3
- package/dist/ui/assets/{anthropic-messages-BwBPoNP0.js → anthropic-messages-_fPAePlR.js} +3 -3
- package/dist/ui/assets/{apps-Bs4OZdLX.js → apps-ztx90XZQ.js} +1 -1
- package/dist/ui/assets/attachments-CByeG2Ru.js +1 -0
- package/dist/ui/assets/{azure-openai-hnPmyx7n.js → azure-openai-BKnOwPkT.js} +1 -1
- package/dist/ui/assets/{azure-openai-EZeNxE7d.js → azure-openai-Y9U14npX.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-BXDkTtSH.js → azure-openai-responses-DhzbC_tL.js} +1 -1
- package/dist/ui/assets/{azure-openai-responses-De9pJjBR.js → azure-openai-responses-bHfWNMbx.js} +1 -1
- package/dist/ui/assets/base64-DpPqYZJF.js +1 -0
- package/dist/ui/assets/bedrock-camp-BEi8MYUS.js +1 -0
- package/dist/ui/assets/bedrock-camp-CvxD6hHk.js +1 -0
- package/dist/ui/assets/bridge-launch-params-jegYRGJ6.js +1 -0
- package/dist/ui/assets/{browser-2wdq8OwU.js → browser-COVn7LPD.js} +6 -6
- package/dist/ui/assets/{cdp-Bwq6NLAx.js → cdp-7evcrxxP.js} +1 -1
- package/dist/ui/assets/cerebras-D_u7JsxU.js +1 -0
- package/dist/ui/assets/cerebras-ZAPHCT6L.js +1 -0
- package/dist/ui/assets/client-CpLUc-P8.js +4 -0
- package/dist/ui/assets/clipboard-Bd1Wp2vH.js +1 -0
- package/dist/ui/assets/compat-DyT25qXb.js +2 -0
- package/dist/ui/assets/{completionchunk-B2eUYPOo.js → completionchunk-D8ek1SQ-.js} +1 -1
- package/dist/ui/assets/{composer-speech-CgPswGW1.js → composer-speech-BWsih2Nz.js} +1 -1
- package/dist/ui/assets/{connect-surface-Ccit9qN8.js → connect-surface-YVJhSwyb.js} +1 -1
- package/dist/ui/assets/{context-compaction-LYFtS2_f.js → context-compaction-dcYYajWb.js} +6 -6
- package/dist/ui/assets/cost-command-Cpg2Em0Q.js +1613 -0
- package/dist/ui/assets/db-DjAqlQ2I.js +1 -0
- package/dist/ui/assets/db-ysOO0kLr.js +1 -0
- package/dist/ui/assets/dictation-priming-DGpw1lUV.js +1 -0
- package/dist/ui/assets/dip-BumXS1a9.js +233 -0
- package/dist/ui/assets/discovery-preference-DCtfbqw1.js +1 -0
- package/dist/ui/assets/dist-0FRaZO2z.js +12 -0
- package/dist/ui/assets/{dist-DH3_TPic.js → dist-BhEJb2Dl.js} +1 -1
- package/dist/ui/assets/{dist-DD6YY4Ks2.js → dist-Bj10RLrf.js} +1 -1
- package/dist/ui/assets/{dist-BHXb30bf.js → dist-Bq5i9FMJ.js} +4 -4
- package/dist/ui/assets/dist-CJ6ilPeJ.js +18 -0
- package/dist/ui/assets/{dist-D58cmC11.js → dist-Cc2eS9kS.js} +1 -1
- package/dist/ui/assets/{dist-CC_gNVTb.js → dist-DB-MlM2G.js} +1 -1
- package/dist/ui/assets/{dist-Bw2SRiP7.js → dist-DuLHpm2f.js} +1 -1
- package/dist/ui/assets/dist-DvjiIrEx.js +23 -0
- package/dist/ui/assets/{dist-D1pcMg_U.js → dist-d2CXjMIs.js} +3 -3
- package/dist/ui/assets/electron-overlay-route-CjT6k9Df.js +1 -0
- package/dist/ui/assets/ensure-speech-assets-D2Pclall.js +1 -0
- package/dist/ui/assets/es-CP2z28j0.js +53 -0
- package/dist/ui/assets/esp8266-CkAPDkuz.js +1 -0
- package/dist/ui/assets/esptool-operations-C0DUkD34.js +13 -0
- package/dist/ui/assets/esptool-operations-iCYPdIRA.js +12 -0
- package/dist/ui/assets/extension-bridge-transport-DHBo-K6K.js +1 -0
- package/dist/ui/assets/{follower-navigate-watcher-CRVUcrQz.js → follower-navigate-watcher-Cn5RjYxg.js} +1 -1
- package/dist/ui/assets/{fs-C4sVSIbi.js → fs-BVM9dzPP.js} +1 -1
- package/dist/ui/assets/fs-CMpdIYZs.js +2 -0
- package/dist/ui/assets/git-config-Lj0BT7Oc.js +7 -0
- package/dist/ui/assets/github-CmX1lUH3.js +2 -0
- package/dist/ui/assets/github-copilot-C9loxoyp.js +1 -0
- package/dist/ui/assets/github-copilot-JdvDIR67.js +2 -0
- package/dist/ui/assets/github-ndbvNRbv.js +1 -0
- package/dist/ui/assets/global-db-DvmmimLY.js +1 -0
- package/dist/ui/assets/{google-generative-ai-C58ldv83.js → google-generative-ai-CyS9qbzb.js} +1 -1
- package/dist/ui/assets/{google-generative-ai-Eq6eGS5h.js → google-generative-ai-DkRyuoBH.js} +1 -1
- package/dist/ui/assets/{google-shared-DQbld86Z.js → google-shared-CCJkdw81.js} +2 -2
- package/dist/ui/assets/{google-shared-DwCjfFnw.js → google-shared-p5XdfI6c.js} +3 -3
- package/dist/ui/assets/{google-vertex-C18Xl3dV.js → google-vertex-Cp9ldPyE.js} +1 -1
- package/dist/ui/assets/{google-vertex-CkkAgSFr.js → google-vertex-D7VRnbrL.js} +1 -1
- package/dist/ui/assets/{handoff-link-CLvhqfpd.js → handoff-link-CfgH86mb.js} +1 -1
- package/dist/ui/assets/hear-D7srqY_7.js +1 -0
- package/dist/ui/assets/hear-acxY6mf0.js +1 -0
- package/dist/ui/assets/hid-device-registry-DboUgvzI.js +1 -0
- package/dist/ui/assets/hid-picker-Bhoh8hxy.js +1 -0
- package/dist/ui/assets/installer-D7LGGQGy.js +3 -0
- package/dist/ui/assets/{js-realm-worker-CeYHBMC5.js → js-realm-worker-B4uCLm52.js} +3 -3
- package/dist/ui/assets/{json-parse-B51EftGA.js → json-parse-CpLf0aqK.js} +1 -1
- package/dist/ui/assets/{json-parse-C7d6hyOc.js → json-parse-rb7sUwcH.js} +1 -1
- package/dist/ui/assets/kernel-worker-DMnEeTNU.js +8759 -0
- package/dist/ui/assets/{kokoro-C-DxSDte.js → kokoro-CGDCwNNA.js} +2 -2
- package/dist/ui/assets/{kokoro-BFFlHn4y.js → kokoro-D3TYeL2z.js} +2 -2
- package/dist/ui/assets/{kokoro-engine-DENIKgTV.js → kokoro-engine-DLKTuHMR.js} +2 -2
- package/dist/ui/assets/legacy-api-aliases-BQSsmFIS.js +1 -0
- package/dist/ui/assets/legacy-api-aliases-DWJHPSiz.js +1 -0
- package/dist/ui/assets/{legacy-styles-kYboUbpI.js → legacy-styles-DcRu2WCJ.js} +1 -1
- package/dist/ui/assets/lick-manager-Ct3WOtut.js +2 -0
- package/dist/ui/assets/lick-ws-bridge-C_bJMGw6.js +1 -0
- package/dist/ui/assets/{lick-ws-bridge-DpPrSP8R.js → lick-ws-bridge-SPFIXhG2.js} +1 -1
- package/dist/ui/assets/llm-session-id-ZObKEXzb.js +1 -0
- package/dist/ui/assets/local-llm-B5vPCdpH.js +2 -0
- package/dist/ui/assets/{local-llm-wgOnNpVi.js → local-llm-DS8tu43V.js} +1 -1
- package/dist/ui/assets/magick-wasm-B-rybRPb.js +43 -0
- package/dist/ui/assets/main-D8Y-cnmF.js +22 -0
- package/dist/ui/assets/{main-cherry-d-KDlb8k.js → main-cherry-CGm5knH6.js} +1 -1
- package/dist/ui/assets/{mime-types-BqLkKWa7.js → mime-types-D7IV6i7k.js} +1 -1
- package/dist/ui/assets/mistral-conversations-CLDzxp2F.js +8 -0
- package/dist/ui/assets/mistral-conversations-DbKikZnf.js +7 -0
- package/dist/ui/assets/{models-ByRUWfA-.js → models-CzSI8IsT.js} +1 -1
- package/dist/ui/assets/{mount-C0YbhdMr.js → mount-C4XESP9i.js} +1 -1
- package/dist/ui/assets/mount-Hr9QXuwp.js +2 -0
- package/dist/ui/assets/{mount-bridge-client-0Afn2H9Y.js → mount-bridge-client-BVLVI9yX.js} +1 -1
- package/dist/ui/assets/mount-recovery-BHHDw9yC.js +2 -0
- package/dist/ui/assets/mount-table-store-CTrzlrNn.js +1 -0
- package/dist/ui/assets/navigation-watcher-BoJS9hdc.js +1 -0
- package/dist/ui/assets/new-session-u-78FCPG.js +2 -0
- package/dist/ui/assets/oauth-bootstrap-DHKASsxn.js +2 -0
- package/dist/ui/assets/{oauth-service-w5HZt7Xx.js → oauth-service-CmM0tZSO.js} +1 -1
- package/dist/ui/assets/oauth-service-DSuwOpMz.js +1 -0
- package/dist/ui/assets/{openai-BeH6aC_-.js → openai-BxFF4GUL.js} +2 -2
- package/dist/ui/assets/{openai-BvKpRLAG.js → openai-CmTnPr9N.js} +2 -2
- package/dist/ui/assets/openai-codex-Djc_-qM9.js +1 -0
- package/dist/ui/assets/openai-codex-gi-RyKX_.js +1 -0
- package/dist/ui/assets/{openai-codex-responses-BDYh8ojD.js → openai-codex-responses-B_k2rCqO.js} +1 -1
- package/dist/ui/assets/{openai-codex-responses-C7QnNmC0.js → openai-codex-responses-RviMslSH.js} +1 -1
- package/dist/ui/assets/{openai-completions-t-glszMQ.js → openai-completions-CGLtJfv2.js} +1 -1
- package/dist/ui/assets/{openai-completions-BnAjXzgN.js → openai-completions-COYKlBqA.js} +1 -1
- package/dist/ui/assets/{openai-responses-o9_kr7GP.js → openai-responses-C4mUX6jK.js} +1 -1
- package/dist/ui/assets/{openai-responses-BofM6cmY.js → openai-responses-D02gU0ey.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-79gch22X.js → openai-responses-shared-CCTyKL6A.js} +2 -2
- package/dist/ui/assets/{openai-responses-shared-DKPwc9Eh.js → openai-responses-shared-bVKJbQt9.js} +2 -2
- package/dist/ui/assets/{openrouter-images-PT0FZmkM.js → openrouter-images-BrQDTa3_.js} +1 -1
- package/dist/ui/assets/{openrouter-images-D0dgD5eX.js → openrouter-images-DtvjLeGK.js} +1 -1
- package/dist/ui/assets/otel-C1NYdIbe.js +3 -0
- package/dist/ui/assets/otel-joHgpnL_.js +3 -0
- package/dist/ui/assets/page-follower-tray-DFeLlotx.js +5 -0
- package/dist/ui/assets/panel-rpc-handlers-CTZqBsvr.js +2 -0
- package/dist/ui/assets/{pdfjs-BdCnB7P8.js → pdfjs-B1saeD0h.js} +5 -5
- package/dist/ui/assets/{port-bridge-client-Btb0CfZS.js → port-bridge-client-CdvMlimf.js} +1 -1
- package/dist/ui/assets/{port-bridge-client-BtsJUDjt.js → port-bridge-client-CsrXhMWo.js} +1 -1
- package/dist/ui/assets/preload-helper-Czpn1I53.js +1 -0
- package/dist/ui/assets/process-manager-B5dz0PkO.js +1 -0
- package/dist/ui/assets/provider-DeZ3vGbS.js +2 -0
- package/dist/ui/assets/provider-POdkeNpc.js +1 -0
- package/dist/ui/assets/provider-settings-3FoUN196.js +1 -0
- package/dist/ui/assets/provider-settings-BraIAAA7.js +2 -0
- package/dist/ui/assets/provider-store-access-B_pR-9Xx.js +2 -0
- package/dist/ui/assets/provider-store-access-BkJ_SWbe.js +1 -0
- package/dist/ui/assets/providers-B26DtTJa.js +1 -0
- package/dist/ui/assets/providers-CvODsjGm.js +2 -0
- package/dist/ui/assets/proxied-fetch-DETjVL-j.js +2 -0
- package/dist/ui/assets/proxied-fetch-sbHa3Tte.js +1 -0
- package/dist/ui/assets/{py-realm-worker-C5_FcpVv.js → py-realm-worker-VuYxvTG9.js} +2 -2
- package/dist/ui/assets/{pyodide-CVuZVKDU.js → pyodide-BahZNzwn.js} +2 -2
- package/dist/ui/assets/{quick-llm-8fakxnYS.js → quick-llm-DzhE1JW0.js} +1 -1
- package/dist/ui/assets/{readline-D4m_9EmN.js → readline-0OE_8qoR.js} +1 -1
- package/dist/ui/assets/remote-cdp-transport-DOoXIxy3.js +1 -0
- package/dist/ui/assets/{remote-terminal-view-BOSJ_t1v.js → remote-terminal-view-C7x7cM1d.js} +2 -2
- package/dist/ui/assets/runtime-mode-M-qJL9jF.js +1 -0
- package/dist/ui/assets/safe-buffer-C0pSmFaz.js +12 -0
- package/dist/ui/assets/script-catalog-BYXhqRAc.js +2 -0
- package/dist/ui/assets/{secret-env-CGjJCzwN.js → secret-env-1E2r2H5F.js} +1 -1
- package/dist/ui/assets/{secret-topology-_rfIhUjY.js → secret-topology-D2k1IxFk.js} +1 -1
- package/dist/ui/assets/{secrets-bridge-client-a5aLwwny.js → secrets-bridge-client-CONYX8PU.js} +1 -1
- package/dist/ui/assets/serial-picker-CUd91lje.js +1 -0
- package/dist/ui/assets/session-freezer-CUzeQ9yz.js +21 -0
- package/dist/ui/assets/{setup-sprinkle-exec-P2hO-taT.js → setup-sprinkle-exec-DD6jqggr.js} +1 -1
- package/dist/ui/assets/setup-sudo-cXyK0NGW.js +2 -0
- package/dist/ui/assets/{shared-Cq5Q0noX.js → shared-Dwjvg8S5.js} +1 -1
- package/dist/ui/assets/shared-X5SFnyK-.js +4 -0
- package/dist/ui/assets/skills-otSlGBFl.js +6 -0
- package/dist/ui/assets/{slicc-editor-DKckizoI.js → slicc-editor-BoIEeofq.js} +2 -2
- package/dist/ui/assets/{speak-DG2fJcBd.js → speak-WMi1eHMn.js} +3 -3
- package/dist/ui/assets/{speak-CcZ3Uni4.js → speak-YEgNUk4w.js} +1 -1
- package/dist/ui/assets/{sprinkle-bridge-C0ycYX8f.js → sprinkle-bridge-CmJpELpy.js} +1 -1
- package/dist/ui/assets/sprinkle-manager-DXrwoVHS.js +1 -0
- package/dist/ui/assets/{sprinkle-renderer-Bk_e6Kbr.js → sprinkle-renderer-B0y9_9py.js} +2 -2
- package/dist/ui/assets/{wc-shell-ChAQky0u.js → src-6TqoULh8.js} +94 -211
- package/dist/ui/assets/src-CS5gSDhT.js +1 -0
- package/dist/ui/assets/src-Dk1QVJRd.js +1 -0
- package/dist/ui/assets/store-BfzctFJC.js +1 -0
- package/dist/ui/assets/{sudo-CBMei9fD.js → sudo-LN3PJp6v.js} +1 -1
- package/dist/ui/assets/telemetry-C8rZr13D.js +3 -0
- package/dist/ui/assets/timestamp-preference-DgrTvVNx.js +2 -0
- package/dist/ui/assets/transcript-limits-D0M7bLr9.js +1 -0
- package/dist/ui/assets/{transform-messages-ZX8cvJiJ.js → transform-messages-CVIV-EgO.js} +1 -1
- package/dist/ui/assets/transform-messages-fFaW-DLG.js +1 -0
- package/dist/ui/assets/transformers-env-8w05vuhN.js +1 -0
- package/dist/ui/assets/{transformers-env-w-btTDFl.js → transformers-env-sL29_hFb.js} +1 -1
- package/dist/ui/assets/{transformers.web-C6PlPLR-.js → transformers.web-CrioJkWG.js} +4 -4
- package/dist/ui/assets/{transformers.web-DkJGoARp.js → transformers.web-D6viRW2X.js} +5 -5
- package/dist/ui/assets/tray-follower-status-CyJIKXH4.js +1 -0
- package/dist/ui/assets/tray-join-url-BIvzbiFR.js +1 -0
- package/dist/ui/assets/tray-leader-DcLymd_E.js +1 -0
- package/dist/ui/assets/tray-leave-runtime-lJcLlwtm.js +1 -0
- package/dist/ui/assets/tray-runtime-config-DJIIJaBR.js +1 -0
- package/dist/ui/assets/tray-runtime-config-DlPGhxQs.js +1 -0
- package/dist/ui/assets/tray-sync-protocol-CVdiCvfU.js +1 -0
- package/dist/ui/assets/upgrade-detection-DIIyklC5.js +1 -0
- package/dist/ui/assets/usb-device-registry-BOGfZXgp.js +1 -0
- package/dist/ui/assets/{usb-operations-D-YdmmuG.js → usb-operations-BQbhk96u.js} +1 -1
- package/dist/ui/assets/usb-picker-Cl6Cwuv9.js +1 -0
- package/dist/ui/assets/voice-reply-DHV6R4En.js +1 -0
- package/dist/ui/assets/wc-attach-DU0svqb7.js +13 -0
- package/dist/ui/assets/wc-extension-oy0LEz26.js +2 -0
- package/dist/ui/assets/{wc-float-label-CNeJqRLg.js → wc-float-label-DeQPr3pd.js} +1 -1
- package/dist/ui/assets/wc-follower-DcQtc8YB.js +17 -0
- package/dist/ui/assets/wc-live-D7BaYtR7.js +8 -0
- package/dist/ui/assets/wc-nav-BqxVwvjV.js +2 -0
- package/dist/ui/assets/wc-onboarding-D9lPUOm-.js +2 -0
- package/dist/ui/assets/{wc-permissions-CAEOwurQ.js → wc-permissions-DW60QZxV.js} +3 -3
- package/dist/ui/assets/wc-permissions-providers-DMTDytlu.js +2 -0
- package/dist/ui/assets/wc-placeholder-C0wfdFBG.js +4 -0
- package/dist/ui/assets/wc-scoop-color-CByZNEJo.js +1 -0
- package/dist/ui/assets/wc-settings-qEE2zwaO.js +51 -0
- package/dist/ui/assets/wc-shell-BHZzK20y.js +117 -0
- package/dist/ui/assets/wc-sprinkles-DlE9uQTj.js +2 -0
- package/dist/ui/assets/wc-tray-BdFq9TlZ.js +2 -0
- package/dist/ui/assets/{whisper-engine-DBy-Rgc0.js → whisper-engine-C0mT2z02.js} +1 -1
- package/dist/ui/assets/whisper-session-DvjyTCj0.js +2 -0
- package/dist/ui/assets/xai-grok-Bx0idvJc.js +1 -0
- package/dist/ui/assets/xai-grok-CemZ8tZD.js +1 -0
- package/dist/ui/assets/xterm-DX7Hb5S-.js +47 -0
- package/dist/ui/assets/xterm-U4TA8lIC.js +35 -0
- package/dist/ui/index.html +24 -15
- package/dist/ui/packages/webapp/index.html +24 -15
- package/package.json +2 -2
- package/dist/ui/assets/__vite-browser-external-s4_sx6bN.js +0 -1
- package/dist/ui/assets/account-store-B2gG-qc_.js +0 -38
- package/dist/ui/assets/account-store-HRvOCmO4.js +0 -103
- package/dist/ui/assets/adobe-CHBAf7Hs.js +0 -1
- package/dist/ui/assets/adobe-CJZTrRE1.js +0 -2
- package/dist/ui/assets/adobe-oauth-state-C9eB9J5F.js +0 -1
- package/dist/ui/assets/agent-message-to-chat-ColCoNOH.js +0 -7
- package/dist/ui/assets/bedrock-camp-CZFsedRI.js +0 -1
- package/dist/ui/assets/bedrock-camp-Czep_VHL.js +0 -1
- package/dist/ui/assets/cdp-bridge-CUqQUcaF.js +0 -1
- package/dist/ui/assets/cerebras-C2wowhxn.js +0 -1
- package/dist/ui/assets/cerebras-CPDv_lSy.js +0 -1
- package/dist/ui/assets/clipboard-B_tsQU_u.js +0 -1
- package/dist/ui/assets/compat-FrhC6T45.js +0 -2
- package/dist/ui/assets/dip-DjQjKj4G.js +0 -1
- package/dist/ui/assets/discovery-preference-ChE43Rww.js +0 -1
- package/dist/ui/assets/dist-0c-Ms6jt.js +0 -23
- package/dist/ui/assets/dist-C30gQBcj2.js +0 -12
- package/dist/ui/assets/dist-CF1SACsY.js +0 -18
- package/dist/ui/assets/ensure-speech-assets-DOfhoSLd.js +0 -1
- package/dist/ui/assets/es-kEo2Tmh4.js +0 -53
- package/dist/ui/assets/esp8266-DhxGJGHR.js +0 -1
- package/dist/ui/assets/esp8266-dt3vHImh.js +0 -1
- package/dist/ui/assets/esptool-operations-BBtDOaij.js +0 -12
- package/dist/ui/assets/esptool-operations-wGO-l9-a.js +0 -13
- package/dist/ui/assets/extension-bridge-transport-Bi9JIuzJ.js +0 -1
- package/dist/ui/assets/fs-BuwyzyMW.js +0 -2
- package/dist/ui/assets/github-Bypbpxj_.js +0 -1
- package/dist/ui/assets/github-C85Bo5sl.js +0 -2
- package/dist/ui/assets/github-copilot-Bl3DpxDS.js +0 -2
- package/dist/ui/assets/github-copilot-BzF1rbqF.js +0 -1
- package/dist/ui/assets/hear-C7y434Fx.js +0 -1
- package/dist/ui/assets/hear-tL55Pr9X.js +0 -1
- package/dist/ui/assets/hid-device-registry-6w-g8ZpF.js +0 -1
- package/dist/ui/assets/hid-picker-Cp7Sp5N-.js +0 -1
- package/dist/ui/assets/kernel-worker-BwALz4mK.js +0 -10443
- package/dist/ui/assets/lick-ws-bridge-Cu9jmlYC.js +0 -1
- package/dist/ui/assets/main-CGnZl3f-.js +0 -24
- package/dist/ui/assets/mistral-conversations-DKqvekSA.js +0 -7
- package/dist/ui/assets/mistral-conversations-szVW8BsU.js +0 -8
- package/dist/ui/assets/mount-D5pPoQkC.js +0 -2
- package/dist/ui/assets/mount-id-nJcx05eu.js +0 -1
- package/dist/ui/assets/mount-table-store-s20mtVA3.js +0 -1
- package/dist/ui/assets/navigation-watcher-DTSw-td6.js +0 -1
- package/dist/ui/assets/new-session-Bs6AOhFK.js +0 -2
- package/dist/ui/assets/oauth-bootstrap-CE5ZvKUd.js +0 -2
- package/dist/ui/assets/oauth-service-Cf0jA8F5.js +0 -1
- package/dist/ui/assets/openai-codex-8wcYifFj.js +0 -1
- package/dist/ui/assets/openai-codex-xmVYehg_.js +0 -1
- package/dist/ui/assets/otel-BvlmHUjk.js +0 -3
- package/dist/ui/assets/otel-CCT7TRJr.js +0 -3
- package/dist/ui/assets/page-follower-tray-CowMs-O6.js +0 -5
- package/dist/ui/assets/panel-rpc-handlers-D7f3wT75.js +0 -2
- package/dist/ui/assets/preload-helper-CZgWQFsJ.js +0 -1
- package/dist/ui/assets/provider-DgMyEny4.js +0 -2
- package/dist/ui/assets/provider-m3ooafCg.js +0 -1
- package/dist/ui/assets/provider-settings-DJevRg9o.js +0 -1
- package/dist/ui/assets/provider-store-access-QXzphIMd.js +0 -1
- package/dist/ui/assets/provider-store-access-ZxL11bFB.js +0 -1
- package/dist/ui/assets/providers-B3oFOoQS.js +0 -1
- package/dist/ui/assets/providers-BW6jnLVy.js +0 -2
- package/dist/ui/assets/proxied-fetch-CQqrhHlW.js +0 -1
- package/dist/ui/assets/proxied-fetch-D3wsof0i.js +0 -2
- package/dist/ui/assets/remote-cdp-transport-DspFAFy_.js +0 -1
- package/dist/ui/assets/serial-picker-bJGym01W.js +0 -1
- package/dist/ui/assets/session-freezer-jxkdAA5Q.js +0 -1
- package/dist/ui/assets/sprinkle-manager-Bvx4CxCm.js +0 -1
- package/dist/ui/assets/src-BQoW5KdD.js +0 -1
- package/dist/ui/assets/src-BvERX0WZ.js +0 -1
- package/dist/ui/assets/store-B7DeyKtl.js +0 -1
- package/dist/ui/assets/transform-messages-DwI5R8if.js +0 -1
- package/dist/ui/assets/transformers-env-BwX2ts-q.js +0 -1
- package/dist/ui/assets/tray-leader-DKj3IyXq.js +0 -1
- package/dist/ui/assets/tray-leave-runtime-CPrd1hfA.js +0 -1
- package/dist/ui/assets/upgrade-detection-B_nKAXxR.js +0 -1
- package/dist/ui/assets/usb-device-registry-k6vTKonT.js +0 -1
- package/dist/ui/assets/usb-picker-DJjZemi7.js +0 -1
- package/dist/ui/assets/voice-reply-D08ppelD.js +0 -1
- package/dist/ui/assets/wc-attach-BD0vIfkn.js +0 -13
- package/dist/ui/assets/wc-extension-B6ny75yf.js +0 -2
- package/dist/ui/assets/wc-follower-DBHiqt6g.js +0 -17
- package/dist/ui/assets/wc-live-CuefElQr.js +0 -258
- package/dist/ui/assets/wc-nav-CQU9lWdP.js +0 -2
- package/dist/ui/assets/wc-onboarding-DaQiGWxH.js +0 -2
- package/dist/ui/assets/wc-permissions-providers-CbkqRh4J.js +0 -2
- package/dist/ui/assets/wc-placeholder-DCIY4YK0.js +0 -4
- package/dist/ui/assets/wc-settings-BDh89SFJ.js +0 -51
- package/dist/ui/assets/wc-sprinkles-CxI-YvJH.js +0 -2
- package/dist/ui/assets/wc-tray-DL8LCTDP.js +0 -2
- package/dist/ui/assets/whisper-session-C8cizjJD.js +0 -2
- package/dist/ui/assets/xai-grok-BnqGjgBw.js +0 -1
- package/dist/ui/assets/xai-grok-yL8zMte6.js +0 -1
- package/dist/ui/assets/xterm-DMlKjmUi.js +0 -36
- package/dist/ui/assets/xterm-Dwh1I9AE.js +0 -48
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-CZgWQFsJ.js";var r=e({InferenceSession:()=>Ae,TRACE:()=>D,TRACE_EVENT_BEGIN:()=>Te,TRACE_EVENT_END:()=>Ee,TRACE_FUNC_BEGIN:()=>Ce,TRACE_FUNC_END:()=>we,Tensor:()=>be,default:()=>or,env:()=>C,registerBackend:()=>h}),i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e=>typeof t<`u`?t:typeof Proxy<`u`?new Proxy(e,{get:(e,n)=>(typeof t<`u`?t:e)[n]}):e)(function(e){if(typeof t<`u`)return t.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),l=(e,t)=>()=>(e&&(t=e(e=0)),t),u=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},f=e=>d(i({},`__esModule`,{value:!0}),e),p,m,h,g,_,v=l(()=>{p=new Map,m=[],h=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=p.get(e);if(r===void 0)p.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=m.indexOf(e);t!==-1&&m.splice(t,1);for(let t=0;t<m.length;t++)if(p.get(m[t]).priority<=n){m.splice(t,0,e);return}m.push(e)}return}throw TypeError(`not a valid backend`)},g=async e=>{let t=p.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},_=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?m:n,i,a=[],o=new Set;for(let e of r){let t=await g(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),y=l(()=>{v()}),b,x=l(()=>{b=`1.24.0-dev.20251116-b39e144322`}),ee,S,te=l(()=>{x(),ee=`warning`,S={wasm:{},webgl:{},webgpu:{},versions:{common:b},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);ee=e}},get logLevel(){return ee}},Object.defineProperty(S,"logLevel",{enumerable:!0})}),C,w=l(()=>{te(),C=S}),ne,re,T=l(()=>{ne=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[d++]-l[0])*c[0],a=(e.data[f++]-l[1])*c[1],o=(e.data[p++]-l[2])*c[2],s=m===-1?255:(e.data[m++]-l[3])*c[3];r.fillStyle=`rgba(`+i+`,`+a+`,`+o+`,`+s+`)`,r.fillRect(n,t,1,1)}if(`toDataURL`in n)return n.toDataURL();throw Error(`toDataURL is not supported`)}else throw Error(`Can not access image data`)},re=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t<a*i;f+=4,p+=4,m+=4,h+=4,t++)r.data[f]=(e.data[g++]-u[0])*l[0],r.data[p]=(e.data[_++]-u[1])*l[1],r.data[m]=(e.data[v++]-u[2])*l[2],r.data[h]=y===-1?255:(e.data[y++]-u[3])*l[3]}else throw Error(`Can not access image data`);return r}}),E,ie,ae,oe,se,ce,le=l(()=>{ye(),E=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t<l;t++,f+=d,m+=d,p+=d,h+=d)u[g++]=(e[f]+o[0])/a[0],u[_++]=(e[p]+o[1])/a[1],u[v++]=(e[m]+o[2])/a[2],y!==-1&&h!==-1&&(u[y++]=(e[h]+o[3])/a[3]);return c===`RGBA`?new ve(`float32`,u,[1,4,n,r]):new ve(`float32`,u,[1,3,n,r])},ie=async(e,t)=>{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,E(o,s)}else throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(E(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return E(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},ae=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new ve({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},oe=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new ve({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},se=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new ve({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},ce=(e,t,n)=>new ve({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),ue,de,fe,pe,me=l(()=>{ue=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),de=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),fe=!1,pe=()=>{if(!fe){fe=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(ue.set(`int64`,BigInt64Array),de.set(BigInt64Array,`int64`)),t&&(ue.set(`uint64`,BigUint64Array),de.set(BigUint64Array,`uint64`)),r?(ue.set(`float16`,n),de.set(n,`float16`)):ue.set(`float16`,Uint16Array)}}}),he,ge,_e=l(()=>{ye(),he=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`number`||!Number.isSafeInteger(r))throw TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},ge=(e,t)=>{switch(e.location){case`cpu`:return new ve(e.type,e.data,t);case`cpu-pinned`:return new ve({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new ve({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new ve({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new ve({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),ve,ye=l(()=>{T(),le(),me(),_e(),ve=class{constructor(e,t,n){pe();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=ue.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`)if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=ue.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray)if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`);else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=de.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=he(i);if(this.cpuData&&a!==this.cpuData.length&&!((r===`uint4`||r===`int4`)&&Math.ceil(a/2)===this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return ie(e,t)}static fromTexture(e,t){return ae(e,t)}static fromGpuBuffer(e,t){return oe(e,t)}static fromMLTensor(e,t){return se(e,t)}static fromPinnedBuffer(e,t,n){return ce(e,t,n)}toDataURL(e){return ne(this,e)}toImageData(e){return re(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return ge(this,e)}}}),be,xe=l(()=>{ye(),be=ve}),D,Se,Ce,we,Te,Ee,De=l(()=>{te(),D=(e,t)=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.timeStamp(`${e}::ORT::${t}`)},Se=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes(`TRACE_FUNC`)){let r=`FUNC_${e}::${n[i].trim().split(` `)[1]}`;t&&(r+=`::${t}`),D(`CPU`,r);return}n[i].includes(`TRACE_FUNC`)&&(r=!0)}},Ce=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||Se(`BEGIN`,e)},we=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||Se(`END`,e)},Te=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.time(`ORT::${e}`)},Ee=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.timeEnd(`ORT::${e}`)}}),Oe,ke=l(()=>{v(),xe(),De(),Oe=class e{constructor(e){this.handler=e}async run(e,t,n){Ce(),Te(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof be||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof be)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof be)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];t instanceof be?s[e]=t:s[e]=new be(t.type,t.data,t.dims)}return Ee(`InferenceSession.run`),we(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Ce(),Te(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await _(o),l=await s.createInferenceSessionHandler(a,c);return Ee(`InferenceSession.create`),we(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),Ae,je=l(()=>{ke(),Ae=Oe}),Me=l(()=>{}),Ne=l(()=>{}),Pe=l(()=>{}),Fe=l(()=>{}),Ie={};u(Ie,{InferenceSession:()=>Ae,TRACE:()=>D,TRACE_EVENT_BEGIN:()=>Te,TRACE_EVENT_END:()=>Ee,TRACE_FUNC_BEGIN:()=>Ce,TRACE_FUNC_END:()=>we,Tensor:()=>be,env:()=>C,registerBackend:()=>h});var Le=l(()=>{y(),w(),je(),xe(),Me(),Ne(),De(),Pe(),Fe()}),Re=l(()=>{}),ze={};u(ze,{default:()=>He});var Be,Ve,He,Ue=l(()=>{An(),vt(),lt(),Be=`ort-wasm-proxy-worker`,Ve=globalThis.self?.name===Be,Ve&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:_t(n.wasm).then(()=>{vn(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;yn(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Cn(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;wn(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Tn(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;Dn(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},kn([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:On(n),postMessage({type:t});break;default:}}catch(e){postMessage({type:t,err:e})}}),He=Ve?null:e=>new Worker(e??Qe,{type:`module`,name:Be})}),We={};u(We,{default:()=>Ke});async function Ge(e={}){var t=e,n=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith(`em-pthread`);t.mountExternalData=(e,n)=>{e.startsWith(`./`)&&(e=e.substring(2)),(t.Uc||=new Map).set(e,n)},t.unmountExternalData=()=>{delete t.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let a=()=>{let e=e=>(...t)=>{let n=un;return t=e(...t),un==n?t:new Promise((e,t)=>{_n={resolve:e,reject:t}})};(()=>{for(let n of[`_OrtAppendExecutionProvider`,`_OrtCreateSession`,`_OrtRun`,`_OrtRunWithBinding`,`_OrtBindInput`])t[n]=e(t[n])})(),typeof jsepRunAsync<`u`&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),a=void 0};t.asyncInit=()=>{a?.()};var o,s,c=(e,t)=>{throw t},l=import.meta.url,u=``;if(n||r){try{u=new URL(`.`,l).href}catch{}r&&(s=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),o=async e=>{if(ee(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var d,f,p,m,h,g,_=console.log.bind(console),v=console.error.bind(console),y=_,b=v,x=!1,ee=e=>e.startsWith(`file://`);function S(){Ne.buffer!=C.buffer&&ue()}if(i){let e=function(n){try{var r=n.data,i=r.Oc;if(i===`load`){let n=[];self.onmessage=e=>n.push(e),g=()=>{postMessage({Oc:`loaded`});for(let t of n)e(t);self.onmessage=e};for(let e of r.ce)t[e]&&!t[e].proxy||(t[e]=(...t)=>{postMessage({Oc:`callHandler`,be:e,args:t})},e==`print`&&(y=t[e]),e==`printErr`&&(b=t[e]));Ne=r.ie,ue(),f=r.je,me(),Lo()}else if(i===`run`){(function(e){var t=(S(),E)[e+52>>>2>>>0];e=(S(),E)[e+56>>>2>>>0],oa(t,t-e),F(t)})(r.Nc),Zi(r.Nc,0,0,1,0,0),Ae(),Qt(r.Nc),te||=(Oi(),!0);try{Pe(r.ge,r.Wc)}catch(e){if(e!=`unwind`)throw e}}else r.target!==`setimmediate`&&(i===`checkMailbox`?te&&$t():i&&(b(`worker: received unknown command ${i}`),b(r)))}catch(e){throw Qi(),e}};var te=!1;self.onunhandledrejection=e=>{throw e.reason||e},self.onmessage=e}var C,w,ne,re,T,E,ie,ae,oe,se,ce,le=!1;function ue(){var e=Ne.buffer;t.HEAP8=C=new Int8Array(e),ne=new Int16Array(e),t.HEAPU8=w=new Uint8Array(e),re=new Uint16Array(e),t.HEAP32=T=new Int32Array(e),t.HEAPU32=E=new Uint32Array(e),ie=new Float32Array(e),ae=new Float64Array(e),oe=new BigInt64Array(e),se=new BigUint64Array(e)}function de(){le=!0,i?g():Za._b()}function fe(e){throw b(e=`Aborted(`+e+`)`),x=!0,e=new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`),h?.(e),e}function pe(){return{a:{f:Re,J:Be,k:Ge,p:Ke,l:qe,sa:Je,b:Ye,ca:Xe,Ja:Qe,q:$e,da:it,Za:at,Fa:ot,Ha:st,_a:ct,Xa:lt,Qa:ut,Wa:dt,oa:ft,Ga:pt,Xb:mt,Ya:ht,Yb:gt,db:_t,Da:Ct,Sb:wt,Qb:Mt,Ca:Pt,M:Ft,I:It,Rb:zt,ja:qt,Tb:Jt,Ta:Yt,Vb:en,Ka:nn,Ob:rn,ka:an,Sa:Qt,ab:on,U:bn,n:Dn,c:Dt,rb:On,w:kn,L:An,z:jn,j:Mn,o:Nn,sb:Pn,G:Fn,T:In,h:Ln,u:Rn,m:zn,i:Bn,Na:Vn,Oa:Gn,Pa:Kn,La:qn,Ma:Jn,Pb:Zn,eb:Qn,cb:tr,Y:ir,qb:ar,la:or,bb:$n,fb:sr,$a:cr,Wb:lr,N:Xn,gb:ur,X:dr,Ub:fr,nb:Nr,C:Pr,ra:Fr,qa:Ir,pb:Lr,W:Rr,v:zr,mb:Br,lb:Vr,kb:Hr,ob:Ur,jb:Wr,ib:Gr,hb:Kr,Ua:Yr,Va:Xr,Ia:we,V:Zr,na:Qr,Ra:$r,ma:M,Cb:Fo,xa:ko,Db:Po,ya:Oo,F:_o,e:ro,s:to,x:eo,B:mo,Fb:To,ba:wo,D:oo,za:Eo,$:Ao,ga:Co,Gb:So,Hb:xo,Ba:vo,Aa:bo,Ib:yo,wa:No,aa:Do,d:no,A:ao,r:io,Bb:Io,t:co,y:ho,H:so,E:lo,K:go,R:jo,ia:po,_:Mo,Jb:fo,Kb:uo,g:ti,a:Ne,Nb:Se,Eb:ni,ha:ri,O:ii,pa:ai,Lb:oi,ta:si,Q:ci,yb:li,zb:ui,ua:di,ea:fi,P:N,Ea:pi,va:mi,Z:hi,wb:gi,Zb:_i,S:vi,Ab:yi,tb:bi,ub:Si,vb:Ci,fa:wi,xb:Ti,Mb:Ei}}}async function me(){function e(e,n){var r=Za=e.exports;e={};for(let[t,n]of Object.entries(r))typeof n==`function`?(r=cn(n),e[t]=r):e[t]=n;return Za=e,Za=function(){var e=Za,t=e=>t=>e(t)>>>0,n=e=>()=>e()>>>0;return(e=Object.assign({},e)).$b=t(e.$b),e.Cc=n(e.Cc),e.Ec=t(e.Ec),e.rd=(e=>(t,n)=>e(t,n)>>>0)(e.rd),e.wd=t(e.wd),e.xd=n(e.xd),e.Bd=t(e.Bd),e}(),De.push(Za.id),Di=(e=Za).$b,Oi=e.ac,t._OrtInit=e.bc,t._OrtGetLastError=e.cc,t._OrtCreateSessionOptions=e.dc,t._OrtAppendExecutionProvider=e.ec,t._OrtAddFreeDimensionOverride=e.fc,t._OrtAddSessionConfigEntry=e.gc,t._OrtReleaseSessionOptions=e.hc,t._OrtCreateSession=e.ic,t._OrtReleaseSession=e.jc,t._OrtGetInputOutputCount=e.kc,t._OrtGetInputOutputMetadata=e.lc,t._OrtFree=e.mc,t._OrtCreateTensor=e.nc,t._OrtGetTensorData=e.oc,t._OrtReleaseTensor=e.pc,t._OrtCreateRunOptions=e.qc,t._OrtAddRunConfigEntry=e.rc,t._OrtReleaseRunOptions=e.sc,t._OrtCreateBinding=e.tc,t._OrtBindInput=e.uc,t._OrtBindOutput=e.vc,t._OrtClearBoundOutputs=e.wc,t._OrtReleaseBinding=e.xc,t._OrtRunWithBinding=e.yc,t._OrtRun=e.zc,t._OrtEndProfiling=e.Ac,ki=t._OrtGetWebGpuDevice=e.Bc,Ai=e.Cc,ji=t._free=e.Dc,Mi=t._malloc=e.Ec,Ni=t._wgpuBufferRelease=e.Fc,Pi=t._wgpuCreateInstance=e.Gc,Fi=e.Hc,Ii=e.Ic,Li=e.Jc,Ri=e.Kc,zi=e.Lc,Bi=e.Pc,Vi=e.Zc,Hi=e._c,Ui=e.$c,Wi=e.bd,Gi=e.cd,Ki=e.dd,qi=e.ed,Ji=e.fd,Yi=e.gd,Xi=e.hd,Zi=e.kd,Qi=e.ld,$i=e.md,ea=e.nd,ta=e.od,na=e.pd,ra=e.qd,ia=e.rd,P=e.sd,aa=e.td,oa=e.ud,F=e.vd,sa=e.wd,I=e.xd,ca=e.yd,la=e.zd,ua=e.Ad,da=e.Bd,fa=e.Cd,pa=e.Dd,ma=e.Ed,ha=e.Fd,ga=e.Gd,_a=e.Hd,va=e.Id,ya=e.Jd,ba=e.Kd,xa=e.Ld,Sa=e.Md,Ca=e.Nd,wa=e.Od,Ta=e.Pd,Ea=e.Qd,Da=e.Rd,Oa=e.Td,ka=e.Ud,Aa=e.Vd,ja=e.Wd,Ma=e.Yd,Na=e.Zd,Pa=e._d,Fa=e.$d,Ia=e.ae,La=e.oe,Ra=e.pe,za=e.qe,Ba=e.re,Va=e.se,Ha=e.te,Ua=e.ue,L=e.ve,Wa=e.we,Ga=e.xe,Ka=e.ye,qa=e.Ye,Ja=e.Ze,Ya=e._e,Xa=e.$e,f=n,Za}var n,r=pe();return t.instantiateWasm?new Promise(n=>{t.instantiateWasm(r,(t,r)=>{n(e(t,r))})}):i?e(new WebAssembly.Instance(f,pe()),f):(ce??=t.locateFile?t.locateFile?t.locateFile(`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`,u):u+`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`:new URL(`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`,``+import.meta.url).href,n=await async function(e){var t=ce;if(!d&&!ee(t))try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){b(`wasm streaming compile failed: ${e}`),b(`falling back to ArrayBuffer instantiation`)}return async function(e,t){try{var n=await async function(e){if(!d)try{var t=await o(e);return new Uint8Array(t)}catch{}if(e==ce&&d)e=new Uint8Array(d);else{if(!s)throw`both async and sync fetching of the wasm failed`;e=s(e)}return e}(e);return await WebAssembly.instantiate(n,t)}catch(e){b(`failed to asynchronously prepare wasm: ${e}`),fe(e)}}(t,e)}(r),e(n.instance,n.module))}class he{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var ge=e=>{e.terminate(),e.onmessage=()=>{}},_e=[],ve=0,ye=null,be=e=>{Te.length==0&&(Me(),je(Te[0]));var t=Te.pop();if(!t)return 6;Ee.push(t),Oe[e.Nc]=t,t.Nc=e.Nc;var n={Oc:`run`,ge:e.fe,Wc:e.Wc,Nc:e.Nc};return t.postMessage(n,e.Yc),0},xe=0,D=(e,t,...n)=>{var r,i=16*n.length,a=I(),o=sa(i),s=o>>>3;for(r of n)typeof r==`bigint`?((S(),oe)[s++>>>0]=1n,(S(),oe)[s++>>>0]=r):((S(),oe)[s++>>>0]=0n,(S(),ae)[s++>>>0]=r);return e=$i(e,0,i,o,t),F(a),e};function Se(e){if(i)return D(0,1,e);if(p=e,!(0<xe)){for(var t of Ee)ge(t);for(t of Te)ge(t);Te=[],Ee=[],Oe={},x=!0}c(0,new he(e))}function Ce(e){if(i)return D(1,0,e);we(e)}var we=e=>{if(p=e,i)throw Ce(e),`unwind`;Se(e)},Te=[],Ee=[],De=[],Oe={},ke=e=>{var t=e.Nc;delete Oe[t],Te.push(e),Ee.splice(Ee.indexOf(e),1),e.Nc=0,ea(t)};function Ae(){De.forEach(e=>e())}var je=e=>new Promise(n=>{e.onmessage=r=>{var i=r.data;if(r=i.Oc,i.Vc&&i.Vc!=Ai()){var a=Oe[i.Vc];a?a.postMessage(i,i.Yc):b(`Internal error! Worker sent a message "${r}" to target pthread ${i.Vc}, but that thread no longer exists!`)}else r===`checkMailbox`?$t():r===`spawnThread`?be(i):r===`cleanupThread`?Xt(()=>{ke(Oe[i.he])}):r===`loaded`?(e.loaded=!0,n(e)):i.target===`setimmediate`?e.postMessage(i):r===`uncaughtException`?e.onerror(i.error):r===`callHandler`?t[i.be](...i.args):r&&b(`worker sent an unknown command ${r}`)},e.onerror=e=>{throw b(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e};var r,i=[];for(r of[])t.propertyIsEnumerable(r)&&i.push(r);e.postMessage({Oc:`load`,ce:i,ie:Ne,je:f})});function Me(){var e=new Worker((()=>{let e=URL;return import.meta.url>`file:`&&import.meta.url<`file;`?new e(`ort.webgpu.bundle.min.mjs`,import.meta.url):new URL(import.meta.url)})(),{type:`module`,workerData:`em-pthread`,name:`em-pthread`});Te.push(e)}var Ne,Pe=(e,t)=>{xe=0,e=pa(e,t),0<xe?p=e:ta(e)},Fe=[],Ie=0,Le=e=>-9007199254740992>e||9007199254740992<e?NaN:Number(e);function Re(e){var t=new Ue(e>>>=0);return(S(),C)[t.Qc+12>>>0]==0&&(Ve(t,!0),Ie--),He(t,!1),Fe.push(t),da(e)}var ze=0,Be=()=>{P(0,0);var e=Fe.pop();ca(e.Xc),ze=0};function Ve(e,t){t=+!!t,(S(),C)[e.Qc+12>>>0]=t}function He(e,t){t=+!!t,(S(),C)[e.Qc+13>>>0]=t}class Ue{constructor(e){this.Xc=e,this.Qc=e-24}}var We=e=>{var t=ze;if(!t)return aa(0),0;var n=new Ue(t);(S(),E)[n.Qc+16>>>2>>>0]=t;var r=(S(),E)[n.Qc+4>>>2>>>0];if(!r)return aa(0),t;for(var i of e){if(i===0||i===r)break;if(ua(i,r,n.Qc+16))return aa(i),t}return aa(r),t};function Ge(){return We([])}function Ke(e){return We([e>>>0])}function qe(e,t,n,r){return We([e>>>0,t>>>0,n>>>0,r>>>0])}var Je=()=>{var e=Fe.pop();e||fe(`no exception to throw`);var t=e.Xc;throw(S(),C)[e.Qc+13>>>0]==0&&(Fe.push(e),He(e,!0),Ve(e,!1),Ie++),la(t),ze=t};function Ye(e,t,n){var r=new Ue(e>>>=0);throw t>>>=0,n>>>=0,(S(),E)[r.Qc+16>>>2>>>0]=0,(S(),E)[r.Qc+4>>>2>>>0]=t,(S(),E)[r.Qc+8>>>2>>>0]=n,la(e),Ie++,ze=e}var Xe=()=>Ie;function Ze(e,t,n,r){return i?D(2,1,e,t,n,r):Qe(e,t,n,r)}function Qe(e,t,n,r){if(e>>>=0,t>>>=0,n>>>=0,r>>>=0,!globalThis.SharedArrayBuffer)return 6;var a=[];return i&&a.length===0?Ze(e,t,n,r):(e={fe:n,Nc:e,Wc:r,Yc:a},i?(e.Oc=`spawnThread`,postMessage(e,a),0):be(e))}function $e(e){throw ze||=e>>>0,ze}var et=globalThis.TextDecoder&&new TextDecoder,tt=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},nt=(e,t=0,n,r)=>{if(16<(n=tt(e,t>>>=0,n,r))-t&&e.buffer&&et)return et.decode(e.buffer instanceof ArrayBuffer?e.subarray(t,n):e.slice(t,n));for(r=``;t<n;){var i=e[t++];if(128&i){var a=63&e[t++];if((224&i)==192)r+=String.fromCharCode((31&i)<<6|a);else{var o=63&e[t++];65536>(i=(240&i)==224?(15&i)<<12|a<<6|o:(7&i)<<18|a<<12|o<<6|63&e[t++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r},rt=(e,t,n)=>(e>>>=0)?nt((S(),w),e,t,n):``;function it(e,t,n){return i?D(3,1,e,t,n):0}function at(e,t){if(i)return D(4,1,e,t)}function ot(e,t){if(i)return D(5,1,e,t)}function st(e,t,n){if(i)return D(6,1,e,t,n)}function ct(e,t,n){return i?D(7,1,e,t,n):0}function lt(e,t){if(i)return D(8,1,e,t)}function ut(e,t,n){if(i)return D(9,1,e,t,n)}function dt(e,t,n,r){if(i)return D(10,1,e,t,n,r)}function ft(e,t,n,r){if(i)return D(11,1,e,t,n,r)}function pt(e,t,n,r){if(i)return D(12,1,e,t,n,r)}function mt(e){if(i)return D(13,1,e)}function ht(e,t){if(i)return D(14,1,e,t)}function gt(e,t,n){if(i)return D(15,1,e,t,n)}var _t=()=>fe(``),O=e=>{e>>>=0;for(var t=``;;){var n=(S(),w)[e++>>>0];if(!n)return t;t+=String.fromCharCode(n)}},vt={},yt={},bt={},k=class extends Error{constructor(e){super(e),this.name=`BindingError`}};function xt(e,t,n={}){return function(e,t,n={}){var r=t.name;if(!e)throw new k(`type "${r}" must have a positive integer typeid pointer`);if(yt.hasOwnProperty(e)){if(n.de)return;throw new k(`Cannot register type '${r}' twice`)}yt[e]=t,delete bt[e],vt.hasOwnProperty(e)&&(t=vt[e],delete vt[e],t.forEach(e=>e()))}(e,t,n)}var St=(e,t,n)=>{switch(t){case 1:return n?e=>(S(),C)[e>>>0]:e=>(S(),w)[e>>>0];case 2:return n?e=>(S(),ne)[e>>>1>>>0]:e=>(S(),re)[e>>>1>>>0];case 4:return n?e=>(S(),T)[e>>>2>>>0]:e=>(S(),E)[e>>>2>>>0];case 8:return n?e=>(S(),oe)[e>>>3>>>0]:e=>(S(),se)[e>>>3>>>0];default:throw TypeError(`invalid integer width (${t}): ${e}`)}};function Ct(e,t,n,r,i){e>>>=0,n>>>=0,t=O(t>>>0);let a=e=>e;if(r=r===0n){let e=8*n;a=t=>BigInt.asUintN(e,t),i=a(i)}xt(e,{name:t,Mc:a,Sc:(e,t)=>(typeof t==`number`&&(t=BigInt(t)),t),Rc:St(t,n,!r),Tc:null})}function wt(e,t,n,r){xt(e>>>=0,{name:t=O(t>>>0),Mc:function(e){return!!e},Sc:function(e,t){return t?n:r},Rc:function(e){return this.Mc((S(),w)[e>>>0])},Tc:null})}var Tt=[],Et=[0,1,,1,null,1,!0,1,!1,1];function Dt(e){9<(e>>>=0)&&--Et[e+1]==0&&(Et[e]=void 0,Tt.push(e))}var Ot=e=>{if(!e)throw new k(`Cannot use deleted val. handle = ${e}`);return Et[e]},kt=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let t=Tt.pop()||Et.length;return Et[t]=e,Et[t+1]=1,t}};function At(e){return this.Mc((S(),E)[e>>>2>>>0])}var jt={name:`emscripten::val`,Mc:e=>{var t=Ot(e);return Dt(e),t},Sc:(e,t)=>kt(t),Rc:At,Tc:null};function Mt(e){return xt(e>>>0,jt)}var Nt=(e,t)=>{switch(t){case 4:return function(e){return this.Mc((S(),ie)[e>>>2>>>0])};case 8:return function(e){return this.Mc((S(),ae)[e>>>3>>>0])};default:throw TypeError(`invalid float width (${t}): ${e}`)}};function Pt(e,t,n){n>>>=0,xt(e>>>=0,{name:t=O(t>>>0),Mc:e=>e,Sc:(e,t)=>t,Rc:Nt(t,n),Tc:null})}function Ft(e,t,n,r,i){e>>>=0,n>>>=0,t=O(t>>>0);let a=e=>e;if(r===0){var o=32-8*n;a=e=>e<<o>>>o,i=a(i)}xt(e,{name:t,Mc:a,Sc:(e,t)=>t,Rc:St(t,n,r!==0),Tc:null})}function It(e,t,n){function r(e){var t=(S(),E)[e>>>2>>>0];return e=(S(),E)[e+4>>>2>>>0],new i((S(),C).buffer,e,t)}var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];xt(e>>>=0,{name:n=O(n>>>0),Mc:r,Rc:r},{de:!0})}var Lt=(e,t,n)=>{var r=(S(),w);if(t>>>=0,0<n){var i=t;n=t+n-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(127>=o){if(t>=n)break;r[t++>>>0]=o}else if(2047>=o){if(t+1>=n)break;r[t++>>>0]=192|o>>6,r[t++>>>0]=128|63&o}else if(65535>=o){if(t+2>=n)break;r[t++>>>0]=224|o>>12,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o}else{if(t+3>=n)break;r[t++>>>0]=240|o>>18,r[t++>>>0]=128|o>>12&63,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o,a++}}r[t>>>0]=0,e=t-i}else e=0;return e},Rt=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t};function zt(e,t){xt(e>>>=0,{name:t=O(t>>>0),Mc(e){var t=(S(),E)[e>>>2>>>0];return t=rt(e+4,t,!0),ji(e),t},Sc(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n=typeof t==`string`;if(!(n||ArrayBuffer.isView(t)&&t.BYTES_PER_ELEMENT==1))throw new k(`Cannot pass non-string to std::string`);var r=n?Rt(t):t.length,i=Mi(4+r+1),a=i+4;return(S(),E)[i>>>2>>>0]=r,n?Lt(t,a,r+1):(S(),w).set(t,a>>>0),e!==null&&e.push(ji,i),i},Rc:At,Tc(e){ji(e)}})}var Bt=globalThis.TextDecoder?new TextDecoder(`utf-16le`):void 0,Vt=(e,t,n)=>{if(e>>>=1,16<(t=tt((S(),re),e,t/2,n))-e&&Bt)return Bt.decode((S(),re).slice(e,t));for(n=``;e<t;++e){var r=(S(),re)[e>>>0];n+=String.fromCharCode(r)}return n},Ht=(e,t,n)=>{if(n??=2147483647,2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var i=0;i<n;++i){var a=e.charCodeAt(i);(S(),ne)[t>>>1>>>0]=a,t+=2}return(S(),ne)[t>>>1>>>0]=0,t-r},Ut=e=>2*e.length,Wt=(e,t,n)=>{var r=``;e>>>=2;for(var i=0;!(i>=t/4);i++){var a=(S(),E)[e+i>>>0];if(!a&&!n)break;r+=String.fromCodePoint(a)}return r},Gt=(e,t,n)=>{if(t>>>=0,n??=2147483647,4>n)return 0;var r=t;n=r+n-4;for(var i=0;i<e.length;++i){var a=e.codePointAt(i);if(65535<a&&i++,(S(),T)[t>>>2>>>0]=a,(t+=4)+4>n)break}return(S(),T)[t>>>2>>>0]=0,t-r},Kt=e=>{for(var t=0,n=0;n<e.length;++n)65535<e.codePointAt(n)&&n++,t+=4;return t};function qt(e,t,n){if(e>>>=0,t>>>=0,n=O(n>>>=0),t===2)var r=Vt,i=Ht,a=Ut;else r=Wt,i=Gt,a=Kt;xt(e,{name:n,Mc:e=>{var n=(S(),E)[e>>>2>>>0];return n=r(e+4,n*t,!0),ji(e),n},Sc:(e,r)=>{if(typeof r!=`string`)throw new k(`Cannot pass non-string to C++ string type ${n}`);var o=a(r),s=Mi(4+o+t);return(S(),E)[s>>>2>>>0]=o/t,i(r,s+4,o+t),e!==null&&e.push(ji,s),s},Rc:At,Tc(e){ji(e)}})}function Jt(e,t){xt(e>>>=0,{ee:!0,name:t=O(t>>>0),Mc:()=>{},Sc:()=>{}})}function Yt(e){Zi(e>>>0,!r,1,!n,131072,!1),Ae()}var Xt=e=>{if(!x)try{if(e(),!(0<xe))try{i?Ai()&&ta(p):we(p)}catch(e){e instanceof he||e==`unwind`||c(0,e)}}catch(e){e instanceof he||e==`unwind`||c(0,e)}},Zt=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Qt(e){e>>>=0,Zt||(Atomics.waitAsync((S(),T),e>>>2,e).value.then($t),e+=128,Atomics.store((S(),T),e>>>2,1))}var $t=()=>Xt(()=>{var e=Ai();e&&(Qt(e),ra())});function en(e,t){(e>>>=0)==t>>>0?setTimeout($t):i?postMessage({Vc:e,Oc:`checkMailbox`}):(e=Oe[e])&&e.postMessage({Oc:`checkMailbox`})}var tn=[];function nn(e,t,n,r,i){for(t>>>=0,i>>>=0,tn.length=0,n=i>>>3,r=i+r>>>3;n<r;){var a=(S(),oe)[n++>>>0]?(S(),oe)[n++>>>0]:(S(),ae)[n++>>>0];tn.push(a)}return(t?$a[t]:Qa[e])(...tn)}var rn=()=>{xe=0};function an(e){e>>>=0,i?postMessage({Oc:`cleanupThread`,he:e}):ke(Oe[e])}function on(e){}var sn=e=>{try{e()}catch(e){fe(e)}};function cn(e){var t=(...t)=>{fn.push(e);try{return e(...t)}finally{x||(fn.pop(),un&&ln===1&&fn.length===0&&(ln=0,xe+=1,sn(Ja),typeof Fibers<`u`&&Fibers.Be()))}};return hn.set(e,t),t}var ln=0,un=null,dn=0,fn=[],pn=new Map,mn=new Map,hn=new Map,gn=0,_n=null,vn=[],yn=e=>function(e){if(!x){if(ln===0){var t=!1,n=!1;e((e=0)=>{if(!x&&(dn=e,t=!0,n)){ln=2,sn(()=>Ya(un)),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.resume(),e=!1;try{var r=function(){var e=(S(),T)[un+8>>>2>>>0];return e=mn.get(e),e=hn.get(e),--xe,e()}()}catch(t){r=t,e=!0}var i=!1;if(!un){var a=_n;a&&(_n=null,(e?a.reject:a.resolve)(r),i=!0)}if(e&&!i)throw r}}),n=!0,t||(ln=1,un=function(){var e=Mi(65548),t=e+12;if((S(),E)[e>>>2>>>0]=t,(S(),E)[e+4>>>2>>>0]=t+65536,t=fn[0],!pn.has(t)){var n=gn++;pn.set(t,n),mn.set(n,t)}return t=pn.get(t),(S(),T)[e+8>>>2>>>0]=t,e}(),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.pause(),sn(()=>qa(un)))}else ln===2?(ln=0,sn(Xa),ji(un),un=null,vn.forEach(Xt)):fe(`invalid state: ${ln}`);return dn}}(t=>{e().then(t)});function bn(e){return e>>>=0,yn(async()=>kt(await Ot(e)))}var xn=[],Sn=e=>{var t=xn.length;return xn.push(e),t},Cn=(e,t)=>{for(var n=Array(e),r=0;r<e;++r){var i=r,a=(S(),E)[t+4*r>>>2>>>0],o=yt[a];if(o===void 0)throw e=`parameter ${r}`,a=Di(a),t=O(a),ji(a),new k(`${e} has unknown type ${t}`);n[i]=o}return n},wn=(e,t,n)=>{var r=[];return e=e(r,n),r.length&&((S(),E)[t>>>2>>>0]=kt(r)),e},Tn={},En=e=>{var t=Tn[e];return t===void 0?O(e):t};function Dn(e,t,n){var[r,...i]=Cn(e,t>>>0);t=r.Sc.bind(r);var a=i.map(e=>e.Rc.bind(e));e--;var o={toValue:Ot};switch(e=a.map((e,t)=>{var n=`argFromPtr${t}`;return o[n]=e,`${n}(args${t?`+`+8*t:``})`}),n){case 0:var s=`toValue(handle)`;break;case 2:s=`new (toValue(handle))`;break;case 3:s=``;break;case 1:o.getStringOrSymbol=En,s=`toValue(handle)[getStringOrSymbol(methodName)]`}return s+=`(${e})`,r.ee||(o.toReturnWire=t,o.emval_returnValue=wn,s=`return emval_returnValue(toReturnWire, destructorsRef, ${s})`),s=`return function (handle, methodName, destructorsRef, args) {
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./preload-helper-Czpn1I53.js";var r=e({InferenceSession:()=>Ae,TRACE:()=>D,TRACE_EVENT_BEGIN:()=>Te,TRACE_EVENT_END:()=>Ee,TRACE_FUNC_BEGIN:()=>Ce,TRACE_FUNC_END:()=>we,Tensor:()=>be,default:()=>or,env:()=>C,registerBackend:()=>h}),i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e=>typeof t<`u`?t:typeof Proxy<`u`?new Proxy(e,{get:(e,n)=>(typeof t<`u`?t:e)[n]}):e)(function(e){if(typeof t<`u`)return t.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),l=(e,t)=>()=>(e&&(t=e(e=0)),t),u=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},f=e=>d(i({},`__esModule`,{value:!0}),e),p,m,h,g,_,v=l(()=>{p=new Map,m=[],h=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=p.get(e);if(r===void 0)p.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=m.indexOf(e);t!==-1&&m.splice(t,1);for(let t=0;t<m.length;t++)if(p.get(m[t]).priority<=n){m.splice(t,0,e);return}m.push(e)}return}throw TypeError(`not a valid backend`)},g=async e=>{let t=p.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},_=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?m:n,i,a=[],o=new Set;for(let e of r){let t=await g(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),y=l(()=>{v()}),b,x=l(()=>{b=`1.24.0-dev.20251116-b39e144322`}),ee,S,te=l(()=>{x(),ee=`warning`,S={wasm:{},webgl:{},webgpu:{},versions:{common:b},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);ee=e}},get logLevel(){return ee}},Object.defineProperty(S,"logLevel",{enumerable:!0})}),C,w=l(()=>{te(),C=S}),ne,re,T=l(()=>{ne=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[d++]-l[0])*c[0],a=(e.data[f++]-l[1])*c[1],o=(e.data[p++]-l[2])*c[2],s=m===-1?255:(e.data[m++]-l[3])*c[3];r.fillStyle=`rgba(`+i+`,`+a+`,`+o+`,`+s+`)`,r.fillRect(n,t,1,1)}if(`toDataURL`in n)return n.toDataURL();throw Error(`toDataURL is not supported`)}else throw Error(`Can not access image data`)},re=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t<a*i;f+=4,p+=4,m+=4,h+=4,t++)r.data[f]=(e.data[g++]-u[0])*l[0],r.data[p]=(e.data[_++]-u[1])*l[1],r.data[m]=(e.data[v++]-u[2])*l[2],r.data[h]=y===-1?255:(e.data[y++]-u[3])*l[3]}else throw Error(`Can not access image data`);return r}}),E,ie,ae,oe,se,ce,le=l(()=>{ye(),E=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t<l;t++,f+=d,m+=d,p+=d,h+=d)u[g++]=(e[f]+o[0])/a[0],u[_++]=(e[p]+o[1])/a[1],u[v++]=(e[m]+o[2])/a[2],y!==-1&&h!==-1&&(u[y++]=(e[h]+o[3])/a[3]);return c===`RGBA`?new ve(`float32`,u,[1,4,n,r]):new ve(`float32`,u,[1,3,n,r])},ie=async(e,t)=>{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,E(o,s)}else throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(E(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return E(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},ae=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new ve({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},oe=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new ve({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},se=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new ve({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},ce=(e,t,n)=>new ve({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),ue,de,fe,pe,me=l(()=>{ue=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),de=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),fe=!1,pe=()=>{if(!fe){fe=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(ue.set(`int64`,BigInt64Array),de.set(BigInt64Array,`int64`)),t&&(ue.set(`uint64`,BigUint64Array),de.set(BigUint64Array,`uint64`)),r?(ue.set(`float16`,n),de.set(n,`float16`)):ue.set(`float16`,Uint16Array)}}}),he,ge,_e=l(()=>{ye(),he=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`number`||!Number.isSafeInteger(r))throw TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},ge=(e,t)=>{switch(e.location){case`cpu`:return new ve(e.type,e.data,t);case`cpu-pinned`:return new ve({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new ve({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new ve({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new ve({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),ve,ye=l(()=>{T(),le(),me(),_e(),ve=class{constructor(e,t,n){pe();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=ue.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`)if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=ue.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray)if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`);else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=de.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=he(i);if(this.cpuData&&a!==this.cpuData.length&&!((r===`uint4`||r===`int4`)&&Math.ceil(a/2)===this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return ie(e,t)}static fromTexture(e,t){return ae(e,t)}static fromGpuBuffer(e,t){return oe(e,t)}static fromMLTensor(e,t){return se(e,t)}static fromPinnedBuffer(e,t,n){return ce(e,t,n)}toDataURL(e){return ne(this,e)}toImageData(e){return re(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return ge(this,e)}}}),be,xe=l(()=>{ye(),be=ve}),D,Se,Ce,we,Te,Ee,De=l(()=>{te(),D=(e,t)=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.timeStamp(`${e}::ORT::${t}`)},Se=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i<n.length;i++){if(r&&!n[i].includes(`TRACE_FUNC`)){let r=`FUNC_${e}::${n[i].trim().split(` `)[1]}`;t&&(r+=`::${t}`),D(`CPU`,r);return}n[i].includes(`TRACE_FUNC`)&&(r=!0)}},Ce=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||Se(`BEGIN`,e)},we=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||Se(`END`,e)},Te=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.time(`ORT::${e}`)},Ee=e=>{(typeof S.trace>`u`?!S.wasm.trace:!S.trace)||console.timeEnd(`ORT::${e}`)}}),Oe,ke=l(()=>{v(),xe(),De(),Oe=class e{constructor(e){this.handler=e}async run(e,t,n){Ce(),Te(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof be||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof be)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof be)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];t instanceof be?s[e]=t:s[e]=new be(t.type,t.data,t.dims)}return Ee(`InferenceSession.run`),we(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Ce(),Te(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await _(o),l=await s.createInferenceSessionHandler(a,c);return Ee(`InferenceSession.create`),we(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),Ae,je=l(()=>{ke(),Ae=Oe}),Me=l(()=>{}),Ne=l(()=>{}),Pe=l(()=>{}),Fe=l(()=>{}),Ie={};u(Ie,{InferenceSession:()=>Ae,TRACE:()=>D,TRACE_EVENT_BEGIN:()=>Te,TRACE_EVENT_END:()=>Ee,TRACE_FUNC_BEGIN:()=>Ce,TRACE_FUNC_END:()=>we,Tensor:()=>be,env:()=>C,registerBackend:()=>h});var Le=l(()=>{y(),w(),je(),xe(),Me(),Ne(),De(),Pe(),Fe()}),Re=l(()=>{}),ze={};u(ze,{default:()=>He});var Be,Ve,He,Ue=l(()=>{An(),vt(),lt(),Be=`ort-wasm-proxy-worker`,Ve=globalThis.self?.name===Be,Ve&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:_t(n.wasm).then(()=>{vn(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;yn(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Cn(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;wn(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Tn(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;Dn(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},kn([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:On(n),postMessage({type:t});break;default:}}catch(e){postMessage({type:t,err:e})}}),He=Ve?null:e=>new Worker(e??Qe,{type:`module`,name:Be})}),We={};u(We,{default:()=>Ke});async function Ge(e={}){var t=e,n=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith(`em-pthread`);t.mountExternalData=(e,n)=>{e.startsWith(`./`)&&(e=e.substring(2)),(t.Uc||=new Map).set(e,n)},t.unmountExternalData=()=>{delete t.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let a=()=>{let e=e=>(...t)=>{let n=un;return t=e(...t),un==n?t:new Promise((e,t)=>{_n={resolve:e,reject:t}})};(()=>{for(let n of[`_OrtAppendExecutionProvider`,`_OrtCreateSession`,`_OrtRun`,`_OrtRunWithBinding`,`_OrtBindInput`])t[n]=e(t[n])})(),typeof jsepRunAsync<`u`&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),a=void 0};t.asyncInit=()=>{a?.()};var o,s,c=(e,t)=>{throw t},l=import.meta.url,u=``;if(n||r){try{u=new URL(`.`,l).href}catch{}r&&(s=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),o=async e=>{if(ee(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var d,f,p,m,h,g,_=console.log.bind(console),v=console.error.bind(console),y=_,b=v,x=!1,ee=e=>e.startsWith(`file://`);function S(){Ne.buffer!=C.buffer&&ue()}if(i){let e=function(n){try{var r=n.data,i=r.Oc;if(i===`load`){let n=[];self.onmessage=e=>n.push(e),g=()=>{postMessage({Oc:`loaded`});for(let t of n)e(t);self.onmessage=e};for(let e of r.ce)t[e]&&!t[e].proxy||(t[e]=(...t)=>{postMessage({Oc:`callHandler`,be:e,args:t})},e==`print`&&(y=t[e]),e==`printErr`&&(b=t[e]));Ne=r.ie,ue(),f=r.je,me(),Lo()}else if(i===`run`){(function(e){var t=(S(),E)[e+52>>>2>>>0];e=(S(),E)[e+56>>>2>>>0],oa(t,t-e),F(t)})(r.Nc),Zi(r.Nc,0,0,1,0,0),Ae(),Qt(r.Nc),te||=(Oi(),!0);try{Pe(r.ge,r.Wc)}catch(e){if(e!=`unwind`)throw e}}else r.target!==`setimmediate`&&(i===`checkMailbox`?te&&$t():i&&(b(`worker: received unknown command ${i}`),b(r)))}catch(e){throw Qi(),e}};var te=!1;self.onunhandledrejection=e=>{throw e.reason||e},self.onmessage=e}var C,w,ne,re,T,E,ie,ae,oe,se,ce,le=!1;function ue(){var e=Ne.buffer;t.HEAP8=C=new Int8Array(e),ne=new Int16Array(e),t.HEAPU8=w=new Uint8Array(e),re=new Uint16Array(e),t.HEAP32=T=new Int32Array(e),t.HEAPU32=E=new Uint32Array(e),ie=new Float32Array(e),ae=new Float64Array(e),oe=new BigInt64Array(e),se=new BigUint64Array(e)}function de(){le=!0,i?g():Za._b()}function fe(e){throw b(e=`Aborted(`+e+`)`),x=!0,e=new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`),h?.(e),e}function pe(){return{a:{f:Re,J:Be,k:Ge,p:Ke,l:qe,sa:Je,b:Ye,ca:Xe,Ja:Qe,q:$e,da:it,Za:at,Fa:ot,Ha:st,_a:ct,Xa:lt,Qa:ut,Wa:dt,oa:ft,Ga:pt,Xb:mt,Ya:ht,Yb:gt,db:_t,Da:Ct,Sb:wt,Qb:Mt,Ca:Pt,M:Ft,I:It,Rb:zt,ja:qt,Tb:Jt,Ta:Yt,Vb:en,Ka:nn,Ob:rn,ka:an,Sa:Qt,ab:on,U:bn,n:Dn,c:Dt,rb:On,w:kn,L:An,z:jn,j:Mn,o:Nn,sb:Pn,G:Fn,T:In,h:Ln,u:Rn,m:zn,i:Bn,Na:Vn,Oa:Gn,Pa:Kn,La:qn,Ma:Jn,Pb:Zn,eb:Qn,cb:tr,Y:ir,qb:ar,la:or,bb:$n,fb:sr,$a:cr,Wb:lr,N:Xn,gb:ur,X:dr,Ub:fr,nb:Nr,C:Pr,ra:Fr,qa:Ir,pb:Lr,W:Rr,v:zr,mb:Br,lb:Vr,kb:Hr,ob:Ur,jb:Wr,ib:Gr,hb:Kr,Ua:Yr,Va:Xr,Ia:we,V:Zr,na:Qr,Ra:$r,ma:M,Cb:Fo,xa:ko,Db:Po,ya:Oo,F:_o,e:ro,s:to,x:eo,B:mo,Fb:To,ba:wo,D:oo,za:Eo,$:Ao,ga:Co,Gb:So,Hb:xo,Ba:vo,Aa:bo,Ib:yo,wa:No,aa:Do,d:no,A:ao,r:io,Bb:Io,t:co,y:ho,H:so,E:lo,K:go,R:jo,ia:po,_:Mo,Jb:fo,Kb:uo,g:ti,a:Ne,Nb:Se,Eb:ni,ha:ri,O:ii,pa:ai,Lb:oi,ta:si,Q:ci,yb:li,zb:ui,ua:di,ea:fi,P:N,Ea:pi,va:mi,Z:hi,wb:gi,Zb:_i,S:vi,Ab:yi,tb:bi,ub:Si,vb:Ci,fa:wi,xb:Ti,Mb:Ei}}}async function me(){function e(e,n){var r=Za=e.exports;e={};for(let[t,n]of Object.entries(r))typeof n==`function`?(r=cn(n),e[t]=r):e[t]=n;return Za=e,Za=function(){var e=Za,t=e=>t=>e(t)>>>0,n=e=>()=>e()>>>0;return(e=Object.assign({},e)).$b=t(e.$b),e.Cc=n(e.Cc),e.Ec=t(e.Ec),e.rd=(e=>(t,n)=>e(t,n)>>>0)(e.rd),e.wd=t(e.wd),e.xd=n(e.xd),e.Bd=t(e.Bd),e}(),De.push(Za.id),Di=(e=Za).$b,Oi=e.ac,t._OrtInit=e.bc,t._OrtGetLastError=e.cc,t._OrtCreateSessionOptions=e.dc,t._OrtAppendExecutionProvider=e.ec,t._OrtAddFreeDimensionOverride=e.fc,t._OrtAddSessionConfigEntry=e.gc,t._OrtReleaseSessionOptions=e.hc,t._OrtCreateSession=e.ic,t._OrtReleaseSession=e.jc,t._OrtGetInputOutputCount=e.kc,t._OrtGetInputOutputMetadata=e.lc,t._OrtFree=e.mc,t._OrtCreateTensor=e.nc,t._OrtGetTensorData=e.oc,t._OrtReleaseTensor=e.pc,t._OrtCreateRunOptions=e.qc,t._OrtAddRunConfigEntry=e.rc,t._OrtReleaseRunOptions=e.sc,t._OrtCreateBinding=e.tc,t._OrtBindInput=e.uc,t._OrtBindOutput=e.vc,t._OrtClearBoundOutputs=e.wc,t._OrtReleaseBinding=e.xc,t._OrtRunWithBinding=e.yc,t._OrtRun=e.zc,t._OrtEndProfiling=e.Ac,ki=t._OrtGetWebGpuDevice=e.Bc,Ai=e.Cc,ji=t._free=e.Dc,Mi=t._malloc=e.Ec,Ni=t._wgpuBufferRelease=e.Fc,Pi=t._wgpuCreateInstance=e.Gc,Fi=e.Hc,Ii=e.Ic,Li=e.Jc,Ri=e.Kc,zi=e.Lc,Bi=e.Pc,Vi=e.Zc,Hi=e._c,Ui=e.$c,Wi=e.bd,Gi=e.cd,Ki=e.dd,qi=e.ed,Ji=e.fd,Yi=e.gd,Xi=e.hd,Zi=e.kd,Qi=e.ld,$i=e.md,ea=e.nd,ta=e.od,na=e.pd,ra=e.qd,ia=e.rd,P=e.sd,aa=e.td,oa=e.ud,F=e.vd,sa=e.wd,I=e.xd,ca=e.yd,la=e.zd,ua=e.Ad,da=e.Bd,fa=e.Cd,pa=e.Dd,ma=e.Ed,ha=e.Fd,ga=e.Gd,_a=e.Hd,va=e.Id,ya=e.Jd,ba=e.Kd,xa=e.Ld,Sa=e.Md,Ca=e.Nd,wa=e.Od,Ta=e.Pd,Ea=e.Qd,Da=e.Rd,Oa=e.Td,ka=e.Ud,Aa=e.Vd,ja=e.Wd,Ma=e.Yd,Na=e.Zd,Pa=e._d,Fa=e.$d,Ia=e.ae,La=e.oe,Ra=e.pe,za=e.qe,Ba=e.re,Va=e.se,Ha=e.te,Ua=e.ue,L=e.ve,Wa=e.we,Ga=e.xe,Ka=e.ye,qa=e.Ye,Ja=e.Ze,Ya=e._e,Xa=e.$e,f=n,Za}var n,r=pe();return t.instantiateWasm?new Promise(n=>{t.instantiateWasm(r,(t,r)=>{n(e(t,r))})}):i?e(new WebAssembly.Instance(f,pe()),f):(ce??=t.locateFile?t.locateFile?t.locateFile(`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`,u):u+`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`:new URL(`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`,``+import.meta.url).href,n=await async function(e){var t=ce;if(!d&&!ee(t))try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){b(`wasm streaming compile failed: ${e}`),b(`falling back to ArrayBuffer instantiation`)}return async function(e,t){try{var n=await async function(e){if(!d)try{var t=await o(e);return new Uint8Array(t)}catch{}if(e==ce&&d)e=new Uint8Array(d);else{if(!s)throw`both async and sync fetching of the wasm failed`;e=s(e)}return e}(e);return await WebAssembly.instantiate(n,t)}catch(e){b(`failed to asynchronously prepare wasm: ${e}`),fe(e)}}(t,e)}(r),e(n.instance,n.module))}class he{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var ge=e=>{e.terminate(),e.onmessage=()=>{}},_e=[],ve=0,ye=null,be=e=>{Te.length==0&&(Me(),je(Te[0]));var t=Te.pop();if(!t)return 6;Ee.push(t),Oe[e.Nc]=t,t.Nc=e.Nc;var n={Oc:`run`,ge:e.fe,Wc:e.Wc,Nc:e.Nc};return t.postMessage(n,e.Yc),0},xe=0,D=(e,t,...n)=>{var r,i=16*n.length,a=I(),o=sa(i),s=o>>>3;for(r of n)typeof r==`bigint`?((S(),oe)[s++>>>0]=1n,(S(),oe)[s++>>>0]=r):((S(),oe)[s++>>>0]=0n,(S(),ae)[s++>>>0]=r);return e=$i(e,0,i,o,t),F(a),e};function Se(e){if(i)return D(0,1,e);if(p=e,!(0<xe)){for(var t of Ee)ge(t);for(t of Te)ge(t);Te=[],Ee=[],Oe={},x=!0}c(0,new he(e))}function Ce(e){if(i)return D(1,0,e);we(e)}var we=e=>{if(p=e,i)throw Ce(e),`unwind`;Se(e)},Te=[],Ee=[],De=[],Oe={},ke=e=>{var t=e.Nc;delete Oe[t],Te.push(e),Ee.splice(Ee.indexOf(e),1),e.Nc=0,ea(t)};function Ae(){De.forEach(e=>e())}var je=e=>new Promise(n=>{e.onmessage=r=>{var i=r.data;if(r=i.Oc,i.Vc&&i.Vc!=Ai()){var a=Oe[i.Vc];a?a.postMessage(i,i.Yc):b(`Internal error! Worker sent a message "${r}" to target pthread ${i.Vc}, but that thread no longer exists!`)}else r===`checkMailbox`?$t():r===`spawnThread`?be(i):r===`cleanupThread`?Xt(()=>{ke(Oe[i.he])}):r===`loaded`?(e.loaded=!0,n(e)):i.target===`setimmediate`?e.postMessage(i):r===`uncaughtException`?e.onerror(i.error):r===`callHandler`?t[i.be](...i.args):r&&b(`worker sent an unknown command ${r}`)},e.onerror=e=>{throw b(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e};var r,i=[];for(r of[])t.propertyIsEnumerable(r)&&i.push(r);e.postMessage({Oc:`load`,ce:i,ie:Ne,je:f})});function Me(){var e=new Worker((()=>{let e=URL;return import.meta.url>`file:`&&import.meta.url<`file;`?new e(`ort.webgpu.bundle.min.mjs`,import.meta.url):new URL(import.meta.url)})(),{type:`module`,workerData:`em-pthread`,name:`em-pthread`});Te.push(e)}var Ne,Pe=(e,t)=>{xe=0,e=pa(e,t),0<xe?p=e:ta(e)},Fe=[],Ie=0,Le=e=>-9007199254740992>e||9007199254740992<e?NaN:Number(e);function Re(e){var t=new Ue(e>>>=0);return(S(),C)[t.Qc+12>>>0]==0&&(Ve(t,!0),Ie--),He(t,!1),Fe.push(t),da(e)}var ze=0,Be=()=>{P(0,0);var e=Fe.pop();ca(e.Xc),ze=0};function Ve(e,t){t=+!!t,(S(),C)[e.Qc+12>>>0]=t}function He(e,t){t=+!!t,(S(),C)[e.Qc+13>>>0]=t}class Ue{constructor(e){this.Xc=e,this.Qc=e-24}}var We=e=>{var t=ze;if(!t)return aa(0),0;var n=new Ue(t);(S(),E)[n.Qc+16>>>2>>>0]=t;var r=(S(),E)[n.Qc+4>>>2>>>0];if(!r)return aa(0),t;for(var i of e){if(i===0||i===r)break;if(ua(i,r,n.Qc+16))return aa(i),t}return aa(r),t};function Ge(){return We([])}function Ke(e){return We([e>>>0])}function qe(e,t,n,r){return We([e>>>0,t>>>0,n>>>0,r>>>0])}var Je=()=>{var e=Fe.pop();e||fe(`no exception to throw`);var t=e.Xc;throw(S(),C)[e.Qc+13>>>0]==0&&(Fe.push(e),He(e,!0),Ve(e,!1),Ie++),la(t),ze=t};function Ye(e,t,n){var r=new Ue(e>>>=0);throw t>>>=0,n>>>=0,(S(),E)[r.Qc+16>>>2>>>0]=0,(S(),E)[r.Qc+4>>>2>>>0]=t,(S(),E)[r.Qc+8>>>2>>>0]=n,la(e),Ie++,ze=e}var Xe=()=>Ie;function Ze(e,t,n,r){return i?D(2,1,e,t,n,r):Qe(e,t,n,r)}function Qe(e,t,n,r){if(e>>>=0,t>>>=0,n>>>=0,r>>>=0,!globalThis.SharedArrayBuffer)return 6;var a=[];return i&&a.length===0?Ze(e,t,n,r):(e={fe:n,Nc:e,Wc:r,Yc:a},i?(e.Oc=`spawnThread`,postMessage(e,a),0):be(e))}function $e(e){throw ze||=e>>>0,ze}var et=globalThis.TextDecoder&&new TextDecoder,tt=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},nt=(e,t=0,n,r)=>{if(16<(n=tt(e,t>>>=0,n,r))-t&&e.buffer&&et)return et.decode(e.buffer instanceof ArrayBuffer?e.subarray(t,n):e.slice(t,n));for(r=``;t<n;){var i=e[t++];if(128&i){var a=63&e[t++];if((224&i)==192)r+=String.fromCharCode((31&i)<<6|a);else{var o=63&e[t++];65536>(i=(240&i)==224?(15&i)<<12|a<<6|o:(7&i)<<18|a<<12|o<<6|63&e[t++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r},rt=(e,t,n)=>(e>>>=0)?nt((S(),w),e,t,n):``;function it(e,t,n){return i?D(3,1,e,t,n):0}function at(e,t){if(i)return D(4,1,e,t)}function ot(e,t){if(i)return D(5,1,e,t)}function st(e,t,n){if(i)return D(6,1,e,t,n)}function ct(e,t,n){return i?D(7,1,e,t,n):0}function lt(e,t){if(i)return D(8,1,e,t)}function ut(e,t,n){if(i)return D(9,1,e,t,n)}function dt(e,t,n,r){if(i)return D(10,1,e,t,n,r)}function ft(e,t,n,r){if(i)return D(11,1,e,t,n,r)}function pt(e,t,n,r){if(i)return D(12,1,e,t,n,r)}function mt(e){if(i)return D(13,1,e)}function ht(e,t){if(i)return D(14,1,e,t)}function gt(e,t,n){if(i)return D(15,1,e,t,n)}var _t=()=>fe(``),O=e=>{e>>>=0;for(var t=``;;){var n=(S(),w)[e++>>>0];if(!n)return t;t+=String.fromCharCode(n)}},vt={},yt={},bt={},k=class extends Error{constructor(e){super(e),this.name=`BindingError`}};function xt(e,t,n={}){return function(e,t,n={}){var r=t.name;if(!e)throw new k(`type "${r}" must have a positive integer typeid pointer`);if(yt.hasOwnProperty(e)){if(n.de)return;throw new k(`Cannot register type '${r}' twice`)}yt[e]=t,delete bt[e],vt.hasOwnProperty(e)&&(t=vt[e],delete vt[e],t.forEach(e=>e()))}(e,t,n)}var St=(e,t,n)=>{switch(t){case 1:return n?e=>(S(),C)[e>>>0]:e=>(S(),w)[e>>>0];case 2:return n?e=>(S(),ne)[e>>>1>>>0]:e=>(S(),re)[e>>>1>>>0];case 4:return n?e=>(S(),T)[e>>>2>>>0]:e=>(S(),E)[e>>>2>>>0];case 8:return n?e=>(S(),oe)[e>>>3>>>0]:e=>(S(),se)[e>>>3>>>0];default:throw TypeError(`invalid integer width (${t}): ${e}`)}};function Ct(e,t,n,r,i){e>>>=0,n>>>=0,t=O(t>>>0);let a=e=>e;if(r=r===0n){let e=8*n;a=t=>BigInt.asUintN(e,t),i=a(i)}xt(e,{name:t,Mc:a,Sc:(e,t)=>(typeof t==`number`&&(t=BigInt(t)),t),Rc:St(t,n,!r),Tc:null})}function wt(e,t,n,r){xt(e>>>=0,{name:t=O(t>>>0),Mc:function(e){return!!e},Sc:function(e,t){return t?n:r},Rc:function(e){return this.Mc((S(),w)[e>>>0])},Tc:null})}var Tt=[],Et=[0,1,,1,null,1,!0,1,!1,1];function Dt(e){9<(e>>>=0)&&--Et[e+1]==0&&(Et[e]=void 0,Tt.push(e))}var Ot=e=>{if(!e)throw new k(`Cannot use deleted val. handle = ${e}`);return Et[e]},kt=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let t=Tt.pop()||Et.length;return Et[t]=e,Et[t+1]=1,t}};function At(e){return this.Mc((S(),E)[e>>>2>>>0])}var jt={name:`emscripten::val`,Mc:e=>{var t=Ot(e);return Dt(e),t},Sc:(e,t)=>kt(t),Rc:At,Tc:null};function Mt(e){return xt(e>>>0,jt)}var Nt=(e,t)=>{switch(t){case 4:return function(e){return this.Mc((S(),ie)[e>>>2>>>0])};case 8:return function(e){return this.Mc((S(),ae)[e>>>3>>>0])};default:throw TypeError(`invalid float width (${t}): ${e}`)}};function Pt(e,t,n){n>>>=0,xt(e>>>=0,{name:t=O(t>>>0),Mc:e=>e,Sc:(e,t)=>t,Rc:Nt(t,n),Tc:null})}function Ft(e,t,n,r,i){e>>>=0,n>>>=0,t=O(t>>>0);let a=e=>e;if(r===0){var o=32-8*n;a=e=>e<<o>>>o,i=a(i)}xt(e,{name:t,Mc:a,Sc:(e,t)=>t,Rc:St(t,n,r!==0),Tc:null})}function It(e,t,n){function r(e){var t=(S(),E)[e>>>2>>>0];return e=(S(),E)[e+4>>>2>>>0],new i((S(),C).buffer,e,t)}var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];xt(e>>>=0,{name:n=O(n>>>0),Mc:r,Rc:r},{de:!0})}var Lt=(e,t,n)=>{var r=(S(),w);if(t>>>=0,0<n){var i=t;n=t+n-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(127>=o){if(t>=n)break;r[t++>>>0]=o}else if(2047>=o){if(t+1>=n)break;r[t++>>>0]=192|o>>6,r[t++>>>0]=128|63&o}else if(65535>=o){if(t+2>=n)break;r[t++>>>0]=224|o>>12,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o}else{if(t+3>=n)break;r[t++>>>0]=240|o>>18,r[t++>>>0]=128|o>>12&63,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o,a++}}r[t>>>0]=0,e=t-i}else e=0;return e},Rt=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t};function zt(e,t){xt(e>>>=0,{name:t=O(t>>>0),Mc(e){var t=(S(),E)[e>>>2>>>0];return t=rt(e+4,t,!0),ji(e),t},Sc(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n=typeof t==`string`;if(!(n||ArrayBuffer.isView(t)&&t.BYTES_PER_ELEMENT==1))throw new k(`Cannot pass non-string to std::string`);var r=n?Rt(t):t.length,i=Mi(4+r+1),a=i+4;return(S(),E)[i>>>2>>>0]=r,n?Lt(t,a,r+1):(S(),w).set(t,a>>>0),e!==null&&e.push(ji,i),i},Rc:At,Tc(e){ji(e)}})}var Bt=globalThis.TextDecoder?new TextDecoder(`utf-16le`):void 0,Vt=(e,t,n)=>{if(e>>>=1,16<(t=tt((S(),re),e,t/2,n))-e&&Bt)return Bt.decode((S(),re).slice(e,t));for(n=``;e<t;++e){var r=(S(),re)[e>>>0];n+=String.fromCharCode(r)}return n},Ht=(e,t,n)=>{if(n??=2147483647,2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var i=0;i<n;++i){var a=e.charCodeAt(i);(S(),ne)[t>>>1>>>0]=a,t+=2}return(S(),ne)[t>>>1>>>0]=0,t-r},Ut=e=>2*e.length,Wt=(e,t,n)=>{var r=``;e>>>=2;for(var i=0;!(i>=t/4);i++){var a=(S(),E)[e+i>>>0];if(!a&&!n)break;r+=String.fromCodePoint(a)}return r},Gt=(e,t,n)=>{if(t>>>=0,n??=2147483647,4>n)return 0;var r=t;n=r+n-4;for(var i=0;i<e.length;++i){var a=e.codePointAt(i);if(65535<a&&i++,(S(),T)[t>>>2>>>0]=a,(t+=4)+4>n)break}return(S(),T)[t>>>2>>>0]=0,t-r},Kt=e=>{for(var t=0,n=0;n<e.length;++n)65535<e.codePointAt(n)&&n++,t+=4;return t};function qt(e,t,n){if(e>>>=0,t>>>=0,n=O(n>>>=0),t===2)var r=Vt,i=Ht,a=Ut;else r=Wt,i=Gt,a=Kt;xt(e,{name:n,Mc:e=>{var n=(S(),E)[e>>>2>>>0];return n=r(e+4,n*t,!0),ji(e),n},Sc:(e,r)=>{if(typeof r!=`string`)throw new k(`Cannot pass non-string to C++ string type ${n}`);var o=a(r),s=Mi(4+o+t);return(S(),E)[s>>>2>>>0]=o/t,i(r,s+4,o+t),e!==null&&e.push(ji,s),s},Rc:At,Tc(e){ji(e)}})}function Jt(e,t){xt(e>>>=0,{ee:!0,name:t=O(t>>>0),Mc:()=>{},Sc:()=>{}})}function Yt(e){Zi(e>>>0,!r,1,!n,131072,!1),Ae()}var Xt=e=>{if(!x)try{if(e(),!(0<xe))try{i?Ai()&&ta(p):we(p)}catch(e){e instanceof he||e==`unwind`||c(0,e)}}catch(e){e instanceof he||e==`unwind`||c(0,e)}},Zt=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Qt(e){e>>>=0,Zt||(Atomics.waitAsync((S(),T),e>>>2,e).value.then($t),e+=128,Atomics.store((S(),T),e>>>2,1))}var $t=()=>Xt(()=>{var e=Ai();e&&(Qt(e),ra())});function en(e,t){(e>>>=0)==t>>>0?setTimeout($t):i?postMessage({Vc:e,Oc:`checkMailbox`}):(e=Oe[e])&&e.postMessage({Oc:`checkMailbox`})}var tn=[];function nn(e,t,n,r,i){for(t>>>=0,i>>>=0,tn.length=0,n=i>>>3,r=i+r>>>3;n<r;){var a=(S(),oe)[n++>>>0]?(S(),oe)[n++>>>0]:(S(),ae)[n++>>>0];tn.push(a)}return(t?$a[t]:Qa[e])(...tn)}var rn=()=>{xe=0};function an(e){e>>>=0,i?postMessage({Oc:`cleanupThread`,he:e}):ke(Oe[e])}function on(e){}var sn=e=>{try{e()}catch(e){fe(e)}};function cn(e){var t=(...t)=>{fn.push(e);try{return e(...t)}finally{x||(fn.pop(),un&&ln===1&&fn.length===0&&(ln=0,xe+=1,sn(Ja),typeof Fibers<`u`&&Fibers.Be()))}};return hn.set(e,t),t}var ln=0,un=null,dn=0,fn=[],pn=new Map,mn=new Map,hn=new Map,gn=0,_n=null,vn=[],yn=e=>function(e){if(!x){if(ln===0){var t=!1,n=!1;e((e=0)=>{if(!x&&(dn=e,t=!0,n)){ln=2,sn(()=>Ya(un)),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.resume(),e=!1;try{var r=function(){var e=(S(),T)[un+8>>>2>>>0];return e=mn.get(e),e=hn.get(e),--xe,e()}()}catch(t){r=t,e=!0}var i=!1;if(!un){var a=_n;a&&(_n=null,(e?a.reject:a.resolve)(r),i=!0)}if(e&&!i)throw r}}),n=!0,t||(ln=1,un=function(){var e=Mi(65548),t=e+12;if((S(),E)[e>>>2>>>0]=t,(S(),E)[e+4>>>2>>>0]=t+65536,t=fn[0],!pn.has(t)){var n=gn++;pn.set(t,n),mn.set(n,t)}return t=pn.get(t),(S(),T)[e+8>>>2>>>0]=t,e}(),typeof MainLoop<`u`&&MainLoop.Xd&&MainLoop.pause(),sn(()=>qa(un)))}else ln===2?(ln=0,sn(Xa),ji(un),un=null,vn.forEach(Xt)):fe(`invalid state: ${ln}`);return dn}}(t=>{e().then(t)});function bn(e){return e>>>=0,yn(async()=>kt(await Ot(e)))}var xn=[],Sn=e=>{var t=xn.length;return xn.push(e),t},Cn=(e,t)=>{for(var n=Array(e),r=0;r<e;++r){var i=r,a=(S(),E)[t+4*r>>>2>>>0],o=yt[a];if(o===void 0)throw e=`parameter ${r}`,a=Di(a),t=O(a),ji(a),new k(`${e} has unknown type ${t}`);n[i]=o}return n},wn=(e,t,n)=>{var r=[];return e=e(r,n),r.length&&((S(),E)[t>>>2>>>0]=kt(r)),e},Tn={},En=e=>{var t=Tn[e];return t===void 0?O(e):t};function Dn(e,t,n){var[r,...i]=Cn(e,t>>>0);t=r.Sc.bind(r);var a=i.map(e=>e.Rc.bind(e));e--;var o={toValue:Ot};switch(e=a.map((e,t)=>{var n=`argFromPtr${t}`;return o[n]=e,`${n}(args${t?`+`+8*t:``})`}),n){case 0:var s=`toValue(handle)`;break;case 2:s=`new (toValue(handle))`;break;case 3:s=``;break;case 1:o.getStringOrSymbol=En,s=`toValue(handle)[getStringOrSymbol(methodName)]`}return s+=`(${e})`,r.ee||(o.toReturnWire=t,o.emval_returnValue=wn,s=`return emval_returnValue(toReturnWire, destructorsRef, ${s})`),s=`return function (handle, methodName, destructorsRef, args) {
|
|
2
2
|
${s}
|
|
3
3
|
}`,n=Function(Object.keys(o),s)(...Object.values(o)),s=`methodCaller<(${i.map(e=>e.name)}) => ${r.name}>`,Sn(Object.defineProperty(n,"name",{value:s}))}function On(e,t){return t>>>=0,(e=Ot(e>>>0))==Ot(t)}function kn(e){return(e>>>=0)?(e=En(e),kt(globalThis[e])):kt(globalThis)}function An(e){return e=En(e>>>0),kt(t[e])}function jn(e,t){return t>>>=0,e=Ot(e>>>0),t=Ot(t),kt(e[t])}function Mn(e){9<(e>>>=0)&&(Et[e+1]+=1)}function Nn(e,t,n,r,i){return xn[e>>>0](t>>>0,n>>>0,r>>>0,i>>>0)}function Pn(e,t,n,r,i){return Nn(e>>>0,t>>>0,n>>>0,r>>>0,i>>>0)}function Fn(){return kt([])}function In(e){e=Ot(e>>>0);for(var t=Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return kt(t)}function Ln(e){return kt(En(e>>>0))}function Rn(){return kt({})}function zn(e){for(var t=Ot(e>>>=0);t.length;){var n=t.pop();t.pop()(n)}Dt(e)}function Bn(e,t,n){t>>>=0,n>>>=0,e=Ot(e>>>0),t=Ot(t),n=Ot(n),e[t]=n}function Vn(e,t){e=Le(e),t>>>=0,e=new Date(1e3*e),(S(),T)[t>>>2>>>0]=e.getUTCSeconds(),(S(),T)[t+4>>>2>>>0]=e.getUTCMinutes(),(S(),T)[t+8>>>2>>>0]=e.getUTCHours(),(S(),T)[t+12>>>2>>>0]=e.getUTCDate(),(S(),T)[t+16>>>2>>>0]=e.getUTCMonth(),(S(),T)[t+20>>>2>>>0]=e.getUTCFullYear()-1900,(S(),T)[t+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(S(),T)[t+28>>>2>>>0]=e}var Hn=e=>e%4==0&&(e%100!=0||e%400==0),Un=[0,31,60,91,121,152,182,213,244,274,305,335],Wn=[0,31,59,90,120,151,181,212,243,273,304,334];function Gn(e,t){e=Le(e),t>>>=0,e=new Date(1e3*e),(S(),T)[t>>>2>>>0]=e.getSeconds(),(S(),T)[t+4>>>2>>>0]=e.getMinutes(),(S(),T)[t+8>>>2>>>0]=e.getHours(),(S(),T)[t+12>>>2>>>0]=e.getDate(),(S(),T)[t+16>>>2>>>0]=e.getMonth(),(S(),T)[t+20>>>2>>>0]=e.getFullYear()-1900,(S(),T)[t+24>>>2>>>0]=e.getDay();var n=(Hn(e.getFullYear())?Un:Wn)[e.getMonth()]+e.getDate()-1|0;(S(),T)[t+28>>>2>>>0]=n,(S(),T)[t+36>>>2>>>0]=-60*e.getTimezoneOffset(),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n)),(S(),T)[t+32>>>2>>>0]=e}function Kn(e){e>>>=0;var t=new Date((S(),T)[e+20>>>2>>>0]+1900,(S(),T)[e+16>>>2>>>0],(S(),T)[e+12>>>2>>>0],(S(),T)[e+8>>>2>>>0],(S(),T)[e+4>>>2>>>0],(S(),T)[e>>>2>>>0],0),n=(S(),T)[e+32>>>2>>>0],r=t.getTimezoneOffset(),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=new Date(t.getFullYear(),0,1).getTimezoneOffset(),o=Math.min(a,i);return 0>n?(S(),T)[e+32>>>2>>>0]=+(i!=a&&o==r):0<n!=(o==r)&&(i=Math.max(a,i),t.setTime(t.getTime()+6e4*((0<n?o:i)-r))),(S(),T)[e+24>>>2>>>0]=t.getDay(),n=(Hn(t.getFullYear())?Un:Wn)[t.getMonth()]+t.getDate()-1|0,(S(),T)[e+28>>>2>>>0]=n,(S(),T)[e>>>2>>>0]=t.getSeconds(),(S(),T)[e+4>>>2>>>0]=t.getMinutes(),(S(),T)[e+8>>>2>>>0]=t.getHours(),(S(),T)[e+12>>>2>>>0]=t.getDate(),(S(),T)[e+16>>>2>>>0]=t.getMonth(),(S(),T)[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),BigInt(isNaN(e)?-1:e/1e3)}function qn(e,t,n,r,a,o,s){return i?D(16,1,e,t,n,r,a,o,s):-52}function Jn(e,t,n,r,a,o){if(i)return D(17,1,e,t,n,r,a,o)}var Yn={},Xn=()=>performance.timeOrigin+performance.now();function Zn(e,t){return i?D(18,1,e,t):(Yn[e]&&(clearTimeout(Yn[e].id),delete Yn[e]),t&&(Yn[e]={id:setTimeout(()=>{delete Yn[e],Xt(()=>na(e,performance.timeOrigin+performance.now()))},t),Ae:t}),0)}function Qn(e,t,n,r){e>>>=0,t>>>=0,n>>>=0,r>>>=0;var i=new Date().getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset();var o=Math.max(a,i);(S(),E)[e>>>2>>>0]=60*o,(S(),T)[t>>>2>>>0]=+(a!=i),e=(t=e=>{var t=Math.abs(e);return`UTC${0<=e?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`})(a),t=t(i),i<a?(Lt(e,n,17),Lt(t,r,17)):(Lt(e,r,17),Lt(t,n,17))}var $n=()=>Date.now(),er=1;function tr(e,t,n){if(n>>>=0,!(0<=e&&3>=e))return 28;if(e===0)e=Date.now();else{if(!er)return 52;e=performance.timeOrigin+performance.now()}return e=Math.round(1e6*e),(S(),oe)[n>>>3>>>0]=BigInt(e),0}var nr=[],rr=(e,t)=>{nr.length=0;for(var n;n=(S(),w)[e++>>>0];){var r=n!=105;t+=(r&=n!=112)&&t%8?4:0,nr.push(n==112?(S(),E)[t>>>2>>>0]:n==106?(S(),oe)[t>>>3>>>0]:n==105?(S(),T)[t>>>2>>>0]:(S(),ae)[t>>>3>>>0]),t+=r?8:4}return nr};function ir(e,t,n){return e>>>=0,t=rr(t>>>0,n>>>0),$a[e](...t)}function ar(e,t,n){return e>>>=0,t=rr(t>>>0,n>>>0),$a[e](...t)}var or=()=>{};function sr(e,t){return b(rt(e>>>0,t>>>0))}var cr=()=>{throw xe+=1,`unwind`};function lr(){return 4294901760}var ur=()=>1,dr=()=>navigator.hardwareConcurrency;function fr(e){e>>>=0;var t=(S(),w).length;if(e<=t||4294901760<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);e:{r=(Math.min(4294901760,65536*Math.ceil(Math.max(e,r)/65536))-Ne.buffer.byteLength+65535)/65536|0;try{Ne.grow(r),ue();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1}var pr=e=>{var t=Rt(e)+1,n=sa(t);return Lt(e,n,t),n},mr=(e,t)=>{(S(),E)[e>>>2>>>0]=t;var n=(S(),E)[e>>>2>>>0];(S(),E)[e+4>>>2>>>0]=(t-n)/4294967296},hr=e=>(S(),E)[e>>>2>>>0]+4294967296*(S(),T)[e+4>>>2>>>0],gr=[],_r=(e,t)=>{gr[e>>>0]=t},vr=[],yr=[],br=(e,t)=>{yr[e]=new Promise(n=>t.finally(()=>n(e)))},A=e=>{if(e)return gr[e>>>0]},xr=(e,t)=>{for(e=(S(),E)[e>>>2>>>0];e;e=(S(),E)[e>>>2>>>0])t[(S(),T)[e+4>>>2>>>0]](e)},Sr=(e,t,n)=>{(S(),E)[e>>>2>>>0]=t,(S(),E)[e+4>>>2>>>0]=n},Cr=e=>{var t=(S(),E)[e>>>2>>>0];return e=(S(),E)[e+4>>>2>>>0],rt(t,e)},wr=e=>{var t=(S(),E)[e>>>2>>>0];return e=(S(),E)[e+4>>>2>>>0],t?rt(t,e):e===0?``:void 0},Tr=e=>{var t=wr(e+4),n=(n=(S(),E)[e+12>>>2>>>0])?A(n):`auto`;if(e+=16){var r=A((S(),E)[e+4>>>2>>>0]),i=(S(),E)[e+16>>>2>>>0],a=(S(),E)[e+20>>>2>>>0];if(i){for(var o={},s=0;s<i;++s){var c=a+24*s;o[Cr(c+4)]=(S(),ae)[c+16>>>3>>>0]}i=o}else i=void 0;e={module:r,constants:i,entryPoint:wr(e+8)}}else e=void 0;return{label:t,layout:n,compute:e}},Er=(e,t)=>{function n(n,r){n=e[n],(S(),E)[t+r>>>2>>>0]=n}n(`maxTextureDimension1D`,4),n(`maxTextureDimension2D`,8),n(`maxTextureDimension3D`,12),n(`maxTextureArrayLayers`,16),n(`maxBindGroups`,20),n(`maxBindGroupsPlusVertexBuffers`,24),n(`maxBindingsPerBindGroup`,28),n(`maxDynamicUniformBuffersPerPipelineLayout`,32),n(`maxDynamicStorageBuffersPerPipelineLayout`,36),n(`maxSampledTexturesPerShaderStage`,40),n(`maxSamplersPerShaderStage`,44),n(`maxStorageBuffersPerShaderStage`,48),n(`maxStorageTexturesPerShaderStage`,52),n(`maxUniformBuffersPerShaderStage`,56),n(`minUniformBufferOffsetAlignment`,80),n(`minStorageBufferOffsetAlignment`,84),mr(t+64,e.maxUniformBufferBindingSize),mr(t+72,e.maxStorageBufferBindingSize),n(`maxVertexBuffers`,88),mr(t+96,e.maxBufferSize),n(`maxVertexAttributes`,104),n(`maxVertexBufferArrayStride`,108),n(`maxInterStageShaderVariables`,112),n(`maxColorAttachments`,116),n(`maxColorAttachmentBytesPerSample`,120),n(`maxComputeWorkgroupStorageSize`,124),n(`maxComputeInvocationsPerWorkgroup`,128),n(`maxComputeWorkgroupSizeX`,132),n(`maxComputeWorkgroupSizeY`,136),n(`maxComputeWorkgroupSizeZ`,140),n(`maxComputeWorkgroupsPerDimension`,144),e.ze!==void 0&&n(`maxImmediateSize`,148)},Dr=[,`validation`,`out-of-memory`,`internal`],Or=[,`compatibility`,`core`],kr={1:`core-features-and-limits`,2:`depth-clip-control`,3:`depth32float-stencil8`,4:`texture-compression-bc`,5:`texture-compression-bc-sliced-3d`,6:`texture-compression-etc2`,7:`texture-compression-astc`,8:`texture-compression-astc-sliced-3d`,9:`timestamp-query`,10:`indirect-first-instance`,11:`shader-f16`,12:`rg11b10ufloat-renderable`,13:`bgra8unorm-storage`,14:`float32-filterable`,15:`float32-blendable`,16:`clip-distances`,17:`dual-source-blending`,18:`subgroups`,19:`texture-formats-tier1`,20:`texture-formats-tier2`,21:`primitive-index`,22:`texture-component-swizzle`,327692:`chromium-experimental-unorm16-texture-formats`,327729:`chromium-experimental-multi-draw-indirect`},Ar=[,`low-power`,`high-performance`],jr=[,`occlusion`,`timestamp`],Mr={undefined:1,unknown:1,destroyed:2};function Nr(e,t,n,r,i,a){t=Le(t),n=Le(n),r>>>=0,i>>>=0,a>>>=0;var o=A(e>>>0);if(e={},a){var s=(S(),E)[a+12>>>2>>>0];if(s){var c=(S(),E)[a+16>>>2>>>0];e.requiredFeatures=Array.from((S(),E).subarray(c>>>2>>>0,c+4*s>>>2>>>0),e=>kr[e])}var l=(S(),E)[a+20>>>2>>>0];if(l){let t=function(e,t,n=!1){t=l+t,(t=(S(),E)[t>>>2>>>0])==4294967295||n&&t==0||(u[e]=t)},n=function(e,t){t=l+t;var n=(S(),E)[t>>>2>>>0],r=(S(),E)[t+4>>>2>>>0];n==4294967295&&r==4294967295||(u[e]=hr(t))};var u={};t(`maxTextureDimension1D`,4),t(`maxTextureDimension2D`,8),t(`maxTextureDimension3D`,12),t(`maxTextureArrayLayers`,16),t(`maxBindGroups`,20),t(`maxBindGroupsPlusVertexBuffers`,24),t(`maxDynamicUniformBuffersPerPipelineLayout`,32),t(`maxDynamicStorageBuffersPerPipelineLayout`,36),t(`maxSampledTexturesPerShaderStage`,40),t(`maxSamplersPerShaderStage`,44),t(`maxStorageBuffersPerShaderStage`,48),t(`maxStorageTexturesPerShaderStage`,52),t(`maxUniformBuffersPerShaderStage`,56),t(`minUniformBufferOffsetAlignment`,80),t(`minStorageBufferOffsetAlignment`,84),n(`maxUniformBufferBindingSize`,64),n(`maxStorageBufferBindingSize`,72),t(`maxVertexBuffers`,88),n(`maxBufferSize`,96),t(`maxVertexAttributes`,104),t(`maxVertexBufferArrayStride`,108),t(`maxInterStageShaderVariables`,112),t(`maxColorAttachments`,116),t(`maxColorAttachmentBytesPerSample`,120),t(`maxComputeWorkgroupStorageSize`,124),t(`maxComputeInvocationsPerWorkgroup`,128),t(`maxComputeWorkgroupSizeX`,132),t(`maxComputeWorkgroupSizeY`,136),t(`maxComputeWorkgroupSizeZ`,140),t(`maxComputeWorkgroupsPerDimension`,144),t(`maxImmediateSize`,148,!0),e.requiredLimits=u}(s=(S(),E)[a+24>>>2>>>0])&&(s={label:wr(s+4)},e.defaultQueue=s),e.label=wr(a+4)}xe+=1,br(t,o.requestDevice(e).then(e=>{--xe,Xt(()=>{gr[i>>>0]=e.queue,gr[r>>>0]=e,xe+=1,br(n,e.lost.then(t=>{Xt(()=>{e.onuncapturederror=()=>{};var r=I(),i=pr(t.message);Gi(n,Mr[t.reason],i),F(r)}),--xe})),e.onuncapturederror=e=>{var t=5;e.error instanceof GPUValidationError?t=2:e.error instanceof GPUOutOfMemoryError?t=3:e.error instanceof GPUInternalError&&(t=4);var n=I();e=pr(e.error.message),Xi(r,t,e),F(n)},`adapterInfo`in e||(e.adapterInfo=o.info),Yi(t,1,r,0)})},e=>{--xe,Xt(()=>{var i=I(),a=pr(e.message);Yi(t,3,r,a),n&&Gi(n,4,a),F(i)})}))}function Pr(e){var t=A(e>>>=0),n=vr[e];if(n){for(var r=0;r<n.length;++r)n[r]();delete vr[e]}t.destroy()}function Fr(e,t,n){n>>>=0;var r=A(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=ia(16,i.byteLength);return(S(),w).set(new Uint8Array(i),a>>>0),vr[e].push(()=>ji(a)),a}function Ir(e,t,n){n>>>=0;var r=A(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=ia(16,i.byteLength);return(S(),w).fill(0,a,i.byteLength),vr[e].push(()=>{new Uint8Array(i).set((S(),w).subarray(a>>>0,a+i.byteLength>>>0)),ji(a)}),a}function Lr(e,t,n,r,i){e>>>=0,t=Le(t),n=Le(n),i>>>=0;var a=A(e);vr[e]=[],i==4294967295&&(i=void 0),xe+=1,br(t,a.mapAsync(n,r>>>0,i).then(()=>{--xe,Xt(()=>{Ki(t,1,0)})},n=>{--xe,Xt(()=>{I();var r=pr(n.message);Ki(t,n.name===`AbortError`?4:n.name===`OperationError`?3:0,r),delete vr[e]})}))}function Rr(e){var t=A(e>>>=0),n=vr[e];if(n){for(var r=0;r<n.length;++r)n[r]();delete vr[e],t.unmap()}}function zr(e){delete gr[e>>>0]}function Br(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=!!(S(),E)[t+32>>>2>>>0];t={label:wr(t+4),usage:(S(),E)[t+16>>>2>>>0],size:hr(t+24),mappedAtCreation:r},e=A(e);try{var i=e.createBuffer(t)}catch{return!1}return gr[n>>>0]=i,r&&(vr[n]=[]),!0}function Vr(e,t,n,r){e>>>=0,t=Le(t),r>>>=0,n=Tr(n>>>0),e=A(e),xe+=1,br(t,e.createComputePipelineAsync(n).then(e=>{--xe,Xt(()=>{gr[r>>>0]=e,Wi(t,1,r,0)})},e=>{--xe,Xt(()=>{var n=I(),i=pr(e.message);Wi(t,e.reason===`validation`?3:e.reason===`internal`?4:0,r,i),F(n)})}))}function Hr(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=(S(),E)[t>>>2>>>0],i=(S(),T)[r+4>>>2>>>0];t={label:wr(t+4),code:``},i===2&&(t.code=Cr(r+8)),e=A(e).createShaderModule(t),gr[n>>>0]=e}var Ur=e=>{(e=A(e)).onuncapturederror=null,e.destroy()};function Wr(e,t){t=Le(t),e=A(e>>>0),xe+=1,br(t,e.popErrorScope().then(e=>{--xe,Xt(()=>{var n=5;e?e instanceof GPUValidationError?n=2:e instanceof GPUOutOfMemoryError?n=3:e instanceof GPUInternalError&&(n=4):n=1;var r=I(),i=e?pr(e.message):0;qi(t,1,n,i),F(r)})},e=>{--xe,Xt(()=>{var n=I(),r=pr(e.message);qi(t,1,5,r),F(n)})}))}function Gr(e,t,n,r){if(t=Le(t),r>>>=0,n>>>=0){var i={featureLevel:Or[(S(),T)[n+4>>>2>>>0]],powerPreference:Ar[(S(),T)[n+8>>>2>>>0]],forceFallbackAdapter:!!(S(),E)[n+12>>>2>>>0]};(e=(S(),E)[n>>>2>>>0])!==0&&(S(),i.De=!!(S(),E)[e+8>>>2>>>0])}`gpu`in navigator?(xe+=1,br(t,navigator.gpu.requestAdapter(i).then(e=>{--xe,Xt(()=>{if(e)gr[r>>>0]=e,Ji(t,1,r,0);else{var n=I(),i=pr(`WebGPU not available on this browser (requestAdapter returned null)`);Ji(t,3,r,i),F(n)}})},e=>{--xe,Xt(()=>{var n=I(),i=pr(e.message);Ji(t,4,r,i),F(n)})}))):(i=I(),e=pr(`WebGPU not available on this browser (navigator.gpu is not available)`),Ji(t,3,r,e),F(i))}function Kr(e,t,n){return e>>>=0,t>>>=0,n>>>=0,yn(async()=>{var r=[];if(n){var i=(S(),T)[n>>>2>>>0];r.length=t+1,r[t]=new Promise(e=>setTimeout(e,i,0))}else r.length=t;for(var a=0;a<t;++a){var o=hr(e+8*a);if(!(o in yr))return o;r[a]=yr[o]}return r=await Promise.race(r),delete yr[r],r})}var j,qr={},Jr=()=>{if(!j){var e,t={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:`./this.program`};for(e in qr)qr[e]===void 0?delete t[e]:t[e]=qr[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);j=n}return j};function Yr(e,t){if(i)return D(19,1,e,t);e>>>=0,t>>>=0;var n,r=0,a=0;for(n of Jr()){var o=t+r;(S(),E)[e+a>>>2>>>0]=o,r+=Lt(n,o,1/0)+1,a+=4}return 0}function Xr(e,t){if(i)return D(20,1,e,t);e>>>=0,t>>>=0;var n=Jr();for(var r of((S(),E)[e>>>2>>>0]=n.length,e=0,n))e+=Rt(r)+1;return(S(),E)[t>>>2>>>0]=e,0}function Zr(e){return i?D(21,1,e):52}function Qr(e,t,n,r){return i?D(22,1,e,t,n,r):52}function $r(e,t,n,r){return i?D(23,1,e,t,n,r):70}var ei=[null,[],[]];function M(e,t,n,r){if(i)return D(24,1,e,t,n,r);t>>>=0,n>>>=0,r>>>=0;for(var a=0,o=0;o<n;o++){var s=(S(),E)[t>>>2>>>0],c=(S(),E)[t+4>>>2>>>0];t+=8;for(var l=0;l<c;l++){var u=e,d=(S(),w)[s+l>>>0],f=ei[u];d===0||d===10?((u===1?y:b)(nt(f)),f.length=0):f.push(d)}a+=c}return(S(),E)[r>>>2>>>0]=a,0}function ti(e){return e>>>0}function ni(e,t){return Er(A(e>>>0).limits,t>>>0),1}function ri(e,t){return A(e>>>0).features.has(kr[t])}function ii(e){return BigInt(A(e>>>0).size)}function ai(e){return BigInt(A(e>>>0).usage)}function oi(e,t){if(e>>>=0,t>>>=0){var n=wr(t+4);n={label:n,timestampWrites:t=(t=(S(),E)[t+12>>>2>>>0])===0?void 0:{querySet:A((S(),E)[t+4>>>2>>>0]),beginningOfPassWriteIndex:(S(),E)[t+8>>>2>>>0],endOfPassWriteIndex:(S(),E)[t+12>>>2>>>0]}}}return t=A(e),e=zi(0),n=t.beginComputePass(n),gr[e>>>0]=n,e}function si(e,t,n,r){n=Le(n),(r=Le(r))==-1&&(r=void 0),(e=A(e>>>0)).clearBuffer(A(t>>>0),n,r)}function ci(e,t,n,r,i,a){n=Le(n),i=Le(i),a=Le(a),A(e>>>0).copyBufferToBuffer(A(t>>>0),n,A(r>>>0),i,a)}function li(e){var t=A(e>>>0);return e=Li(0),t=t.finish(),gr[e>>>0]=t,e}function ui(e,t,n,r,i,a){a=Le(a),A(e>>>0).resolveQuerySet(A(t>>>0),n,r,A(i>>>0),a)}function di(e,t,n,r){A(e>>>0).dispatchWorkgroups(t,n,r)}function fi(e,t,n){n=Le(n),A(e>>>0).dispatchWorkgroupsIndirect(A(t>>>0),n)}function N(e){A(e>>>0).end()}function pi(e,t,n,r,i){r>>>=0,i>>>=0,e=A(e>>>0),n=A(n>>>0),r==0?e.setBindGroup(t,n):e.setBindGroup(t,n,(S(),E),i>>>2,r)}function mi(e,t){A(e>>>0).setPipeline(A(t>>>0))}function hi(e,t,n){A(e>>>0).Ce(A(t>>>0),n)}function gi(e,t){var n=A(e>>>0);return e=Ii(0),t=n.getBindGroupLayout(t),gr[e>>>0]=t,e}function _i(e,t){function n(e){var t=(S(),E)[e+8>>>2>>>0],n=(S(),E)[e+32>>>2>>>0],r=(S(),E)[e+36>>>2>>>0],i=0;return xr(e,{327681:e=>{i=(S(),E)[e+8>>>2>>>0]}}),t?((n=hr(e+24))==-1&&(n=void 0),t={buffer:A(t),offset:hr(e+16),size:n}):t=A(n||r||i),{binding:(S(),E)[e+4>>>2>>>0],resource:t}}e>>>=0,t={label:wr(4+(t>>>=0)),layout:A((S(),E)[t+12>>>2>>>0]),entries:function(e,t){for(var r=[],i=0;i<e;++i)r.push(n(t+40*i));return r}((S(),E)[t+16>>>2>>>0],(S(),E)[t+20>>>2>>>0])},e=A(e);var r=Fi(0);return _r(r,e.createBindGroup(t)),r}function vi(e,t){var n;return e>>>=0,(t>>>=0)&&(n={label:wr(t+4)}),t=A(e),e=Ri(0),n=t.createCommandEncoder(n),gr[e>>>0]=n,e}function yi(e,t){e>>>=0,t>>>=0,t={type:jr[(S(),T)[t+12>>>2>>>0]],count:(S(),E)[t+16>>>2>>>0]};var n=A(e);return e=Bi(0),t=n.createQuerySet(t),gr[e>>>0]=t,e}function bi(e,t){e=A(e>>>0).adapterInfo,t>>>=0,(S(),E)[t+52>>>2>>>0]=e.subgroupMinSize,(S(),E)[t+56>>>2>>>0]=e.subgroupMaxSize;var n=e.vendor+e.architecture+e.device+e.description,r=Rt(n)+1,i=Mi(r);return i&&Lt(n,i,r),n=i,r=Rt(e.vendor),Sr(t+4,n,r),n+=r,r=Rt(e.architecture),Sr(t+12,n,r),n+=r,r=Rt(e.device),Sr(t+20,n,r),Sr(t+28,n+r,Rt(e.description)),(S(),T)[t+36>>>2>>>0]=2,e=e.isFallbackAdapter?3:4,(S(),T)[t+40>>>2>>>0]=e,(S(),E)[t+44>>>2>>>0]=0,(S(),E)[t+48>>>2>>>0]=0,1}var xi={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729};function Si(e,t){t>>>=0;var n=A(e>>>0);e=Mi(4*n.features.size);var r=0,i=0;for(let t of n.features)0<=(n=xi[t])&&((S(),T)[e+r>>>2>>>0]=n,r+=4,i++);(S(),E)[t+4>>>2>>>0]=e,(S(),E)[t>>>2>>>0]=i}function Ci(e,t){return Er(A(e>>>0).limits,t>>>0),1}function wi(e,t){A(e>>>0).pushErrorScope(Dr[t])}function Ti(e,t,n){t>>>=0,n>>>=0,e=A(e>>>0),t=Array.from((S(),T).subarray(n>>>2>>>0,n+4*t>>>2>>>0),e=>A(e)),e.submit(t)}function Ei(e,t,n,r,i){n=Le(n),r>>>=0,i>>>=0,e=A(e>>>0),t=A(t>>>0),r=(S(),w).subarray(r>>>0,r+i>>>0),e.writeBuffer(t,n,r,0,i)}i||function(){for(var e=t.numThreads-1;e--;)Me();_e.push(async()=>{var e=async function(){if(!i)return Promise.all(Te.map(je))}();ve++,await e,--ve==0&&ye&&(e=ye,ye=null,e())})}(),i||(Ne=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),ue()),t.wasmBinary&&(d=t.wasmBinary),t.stackSave=()=>I(),t.stackRestore=e=>F(e),t.stackAlloc=e=>sa(e),t.setValue=function(e,t,n=`i8`){switch(n.endsWith(`*`)&&(n=`*`),n){case`i1`:case`i8`:(S(),C)[e>>>0]=t;break;case`i16`:(S(),ne)[e>>>1>>>0]=t;break;case`i32`:(S(),T)[e>>>2>>>0]=t;break;case`i64`:(S(),oe)[e>>>3>>>0]=BigInt(t);break;case`float`:(S(),ie)[e>>>2>>>0]=t;break;case`double`:(S(),ae)[e>>>3>>>0]=t;break;case`*`:(S(),E)[e>>>2>>>0]=t;break;default:fe(`invalid type for setValue: ${n}`)}},t.getValue=function(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:case`i8`:return(S(),C)[e>>>0];case`i16`:return(S(),ne)[e>>>1>>>0];case`i32`:return(S(),T)[e>>>2>>>0];case`i64`:return(S(),oe)[e>>>3>>>0];case`float`:return(S(),ie)[e>>>2>>>0];case`double`:return(S(),ae)[e>>>3>>>0];case`*`:return(S(),E)[e>>>2>>>0];default:fe(`invalid type for getValue: ${t}`)}},t.UTF8ToString=rt,t.stringToUTF8=Lt,t.lengthBytesUTF8=Rt;var Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,P,aa,oa,F,sa,I,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,L,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa=[Se,Ce,Ze,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,ht,gt,qn,Jn,Zn,Yr,Xr,Zr,Qr,$r,M],$a={970348:(e,n,r,i,a)=>{if(t===void 0||!t.Uc)return 1;if((e=rt(Number(e>>>0))).startsWith(`./`)&&(e=e.substring(2)),!(e=t.Uc.get(e)))return 2;if(n=Number(n>>>0),r=Number(r>>>0),i=Number(i>>>0),n+r>e.byteLength)return 3;try{let o=e.subarray(n,n+r);switch(a){case 0:(S(),w).set(o,i>>>0);break;case 1:t.ad?t.ad(i,o):t.ne(i,o);break;default:return 4}return 0}catch{return 4}},971172:(e,n,r)=>{t.Sd(e,(S(),w).subarray(n>>>0,n+r>>>0))},971236:()=>t.le(),971278:e=>{t.jd(e)},971315:()=>typeof wasmOffsetConverter<`u`};function eo(e,t,n,r){var i=I();try{return xa(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function to(e,t,n){var r=I();try{return va(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;P(1,0)}}function no(e){var t=I();try{ma(e)}catch(e){if(F(t),e!==e+0)throw e;P(1,0)}}function ro(e,t){var n=I();try{return pa(e,t)}catch(e){if(F(n),e!==e+0)throw e;P(1,0)}}function io(e,t,n){var r=I();try{fa(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;P(1,0)}}function ao(e,t){var n=I();try{Sa(e,t)}catch(e){if(F(n),e!==e+0)throw e;P(1,0)}}function oo(e,t,n,r,i,a,o){var s=I();try{return _a(e,t,n,r,i,a,o)}catch(e){if(F(s),e!==e+0)throw e;P(1,0)}}function so(e,t,n,r,i,a){var o=I();try{ha(e,t,n,r,i,a)}catch(e){if(F(o),e!==e+0)throw e;P(1,0)}}function co(e,t,n,r){var i=I();try{ba(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function lo(e,t,n,r,i,a,o){var s=I();try{wa(e,t,n,r,i,a,o)}catch(e){if(F(s),e!==e+0)throw e;P(1,0)}}function uo(e,t,n,r,i,a,o){var s=I();try{Ta(e,t,n,r,i,a,o)}catch(e){if(F(s),e!==e+0)throw e;P(1,0)}}function fo(e,t,n,r,i,a,o,s){var c=I();try{Pa(e,t,n,r,i,a,o,s)}catch(e){if(F(c),e!==e+0)throw e;P(1,0)}}function po(e,t,n,r,i,a,o,s,c,l,u,d){var f=I();try{Ea(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(F(f),e!==e+0)throw e;P(1,0)}}function mo(e,t,n,r,i){var a=I();try{return Ca(e,t,n,r,i)}catch(e){if(F(a),e!==e+0)throw e;P(1,0)}}function ho(e,t,n,r,i){var a=I();try{ga(e,t,n,r,i)}catch(e){if(F(a),e!==e+0)throw e;P(1,0)}}function go(e,t,n,r,i,a,o,s){var c=I();try{ya(e,t,n,r,i,a,o,s)}catch(e){if(F(c),e!==e+0)throw e;P(1,0)}}function _o(e){var t=I();try{return Fa(e)}catch(e){if(F(t),e!==e+0)throw e;P(1,0)}}function vo(e,t,n){var r=I();try{return Ia(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;P(1,0)}}function yo(e,t){var n=I();try{return Ka(e,t)}catch(e){if(F(n),e!==e+0)throw e;return P(1,0),0n}}function bo(e){var t=I();try{return Da(e)}catch(e){if(F(t),e!==e+0)throw e;return P(1,0),0n}}function xo(e,t,n,r){var i=I();try{return La(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function So(e,t,n,r,i){var a=I();try{return Ra(e,t,n,r,i)}catch(e){if(F(a),e!==e+0)throw e;P(1,0)}}function Co(e,t,n,r,i,a){var o=I();try{return za(e,t,n,r,i,a)}catch(e){if(F(o),e!==e+0)throw e;P(1,0)}}function wo(e,t,n,r,i,a){var o=I();try{return Ma(e,t,n,r,i,a)}catch(e){if(F(o),e!==e+0)throw e;P(1,0)}}function To(e,t,n,r,i,a){var o=I();try{return Ba(e,t,n,r,i,a)}catch(e){if(F(o),e!==e+0)throw e;P(1,0)}}function Eo(e,t,n,r,i,a,o,s){var c=I();try{return Na(e,t,n,r,i,a,o,s)}catch(e){if(F(c),e!==e+0)throw e;P(1,0)}}function Do(e,t,n,r,i){var a=I();try{return Va(e,t,n,r,i)}catch(e){if(F(a),e!==e+0)throw e;return P(1,0),0n}}function Oo(e,t,n,r){var i=I();try{return Ha(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function ko(e,t,n,r){var i=I();try{return Ua(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function Ao(e,t,n,r,i,a,o,s,c,l,u,d){var f=I();try{return L(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(F(f),e!==e+0)throw e;P(1,0)}}function jo(e,t,n,r,i,a,o,s,c,l,u){var d=I();try{Wa(e,t,n,r,i,a,o,s,c,l,u)}catch(e){if(F(d),e!==e+0)throw e;P(1,0)}}function Mo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){var g=I();try{Ga(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}catch(e){if(F(g),e!==e+0)throw e;P(1,0)}}function No(e,t,n){var r=I();try{return ka(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;return P(1,0),0n}}function Po(e,t,n){var r=I();try{return Oa(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;P(1,0)}}function Fo(e,t,n){var r=I();try{return Aa(e,t,n)}catch(e){if(F(r),e!==e+0)throw e;P(1,0)}}function Io(e,t,n,r){var i=I();try{ja(e,t,n,r)}catch(e){if(F(i),e!==e+0)throw e;P(1,0)}}function Lo(){if(0<ve)ye=Lo;else if(i)m?.(t),de();else{for(var e=_e;0<e.length;)e.shift()(t);0<ve?ye=Lo:(t.calledRun=!0,x||(de(),m?.(t)))}}return i||(Za=await me(),Lo()),t.PTR_SIZE=4,t.webgpuInit=e=>{let n=new WeakMap,r,i,a=1;t.webgpuRegisterDevice=e=>{if(i!==void 0)throw Error(`another WebGPU EP inference session is being created.`);if(e){var t=n.get(e);if(!t){let r=((e,t=0)=>{var n=Ui(t);return t=Hi(t,n),gr[n>>>0]=e.queue,gr[t>>>0]=e,t})(e,t=Pi(0));t=[a++,t,r],n.set(e,t)}return r=e,i=t[0],t}r=void 0,i=0};let o=new Map;t.webgpuOnCreateSession=t=>{if(i!==void 0){var n=i;if(i=void 0,t){let i=ki(n);o.set(t,i),n===0&&e(r??A(i))}r=void 0}},t.webgpuOnReleaseSession=e=>{o.delete(e)};let s=Symbol(`gpuBufferMetadata`);t.webgpuRegisterBuffer=(e,t,n)=>{if(n)return e[s]=[n,NaN],n;if(n=e[s])return n[1]++,n[0];if((t=o.get(t))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);return t=((e,t=0)=>(e.mapState===`unmapped`||fe(),t=Vi(t),gr[t>>>0]=e,t))(e,t),e[s]=[t,1],t},t.webgpuUnregisterBuffer=e=>{let t=e[s];if(!t)throw Error(`Buffer is not registered`);t[1]--,t[1]===0&&(Ni(t[0]),delete e[s])},t.webgpuGetBuffer=e=>A(e),t.webgpuCreateDownloader=(e,t,n)=>{if((n=o.get(n))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);let r=A(n),i=16*Math.ceil(Number(t)/16);return async()=>{let n=r.createBuffer({size:i,usage:9});try{let a=r.createCommandEncoder();return a.copyBufferToBuffer(e,0,n,0,i),r.queue.submit([a.finish()]),await n.mapAsync(GPUMapMode.READ),n.getMappedRange().slice(0,t)}finally{n.destroy()}}},t.ad=(e,t)=>{var n=t.buffer;let a=t.byteOffset,o=t.byteLength;if(t=16*Math.ceil(Number(o)/16),e=A(e),!r){var s=ki(i);r=A(s)}let c=(s=r.createBuffer({mappedAtCreation:!0,size:t,usage:6})).getMappedRange();new Uint8Array(c).set(new Uint8Array(n,a,o)),s.unmap(),(n=r.createCommandEncoder()).copyBufferToBuffer(s,0,e,0,t),r.queue.submit([n.finish()]),s.destroy()}},t.webnnInit=e=>{let n=e[0];[t.le,t.jd,t.webnnEnsureTensor,t.Sd,t.webnnDownloadTensor,t.ke,t.webnnEnableTraceEvent]=e.slice(1),t.webnnReleaseTensorId=t.jd,t.webnnUploadTensor=t.Sd,t.webnnRegisterMLContext=t.ke,t.webnnOnRunStart=e=>n.onRunStart(e),t.webnnOnRunEnd=n.onRunEnd.bind(n),t.webnnOnReleaseSession=e=>{n.onReleaseSession(e)},t.webnnCreateMLTensorDownloader=(e,t)=>n.createMLTensorDownloader(e,t),t.webnnRegisterMLTensor=(e,t,r,i)=>n.registerMLTensor(e,t,r,i),t.webnnCreateMLContext=e=>n.createMLContext(e),t.webnnRegisterMLConstant=(e,r,i,a,o,s)=>n.registerMLConstant(e,r,i,a,o,t.Uc,s),t.webnnRegisterGraphInput=n.registerGraphInput.bind(n),t.webnnIsGraphInput=n.isGraphInput.bind(n),t.webnnRegisterGraphOutput=n.registerGraphOutput.bind(n),t.webnnIsGraphOutput=n.isGraphOutput.bind(n),t.webnnCreateTemporaryTensor=n.createTemporaryTensor.bind(n),t.webnnIsGraphInputOutputTypeSupported=n.isGraphInputOutputTypeSupported.bind(n)},le?t:new Promise((e,t)=>{m=e,h=t})}var Ke,qe,Je=l(()=>{Ke=Ge,qe=globalThis.self?.name?.startsWith(`em-pthread`),qe&&Ge()}),Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot,st,ct,lt=l(()=>{Re(),Ye=typeof location>`u`?void 0:location.origin,Xe=import.meta.url>`file:`&&import.meta.url<`file;`,Ze=()=>Xe?new URL(new URL(`ort.webgpu.bundle.min.mjs`,import.meta.url).href,Ye).href:import.meta.url,Qe=Ze(),$e=()=>{if(Qe&&!Qe.startsWith(`blob:`))return Qe.substring(0,Qe.lastIndexOf(`/`)+1)},et=(e,t)=>{try{let n=t??Qe;return(n?new URL(e,n):new URL(e)).origin===Ye}catch{return!1}},tt=(e,t)=>{let n=t??Qe;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},nt=(e,t)=>`${t??`./`}${e}`,rt=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},it=async e=>(await n(async()=>{let{default:t}=await import(e);return{default:t}},[])).default,at=(Ue(),f(ze)).default,ot=async()=>{if(!Qe)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(et(Qe))return[void 0,at()];let e=await rt(Qe);return[e,at(e)]},st=(Je(),f(We)).default,ct=async(e,t,n,r)=>{let i=st&&!(e||t);if(i)if(Qe)i=et(Qe)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`);if(i)return[void 0,st];{let r=`ort-wasm-simd-threaded.asyncify.mjs`,i=e??tt(r,t),a=n&&i&&!et(i,t),o=a?await rt(i):i??nt(r,t);return[a?o:void 0,await it(o)]}}}),ut,dt,ft,pt,mt,ht,gt,_t,O,vt=l(()=>{lt(),dt=!1,ft=!1,pt=!1,mt=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},ht=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},gt=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},_t=async e=>{if(dt)return Promise.resolve();if(ft)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(pt)throw Error(`previous call to 'initializeWebAssembly()' failed.`);ft=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!gt())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!ht())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=mt();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await ct(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u,r.locateFile=e=>e;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=$e();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{ft=!1,dt=!0,ut=t,e(),d&&URL.revokeObjectURL(d)},e=>{ft=!1,pt=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},O=()=>{if(dt&&ut)return ut;throw Error(`WebAssembly is not initialized yet.`)}}),yt,bt,k,xt=l(()=>{vt(),yt=(e,t)=>{let n=O(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},bt=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)bt(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},k=e=>{let t=O(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),St,Ct=l(()=>{vt(),xt(),St=e=>{let t=O(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=yt(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&k(`Can't create run options.`),e?.extra!==void 0&&bt(e.extra,``,new WeakSet,(e,i)=>{let a=yt(e,r),o=yt(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&k(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),wt,Tt,Et,Dt,Ot,kt,At,jt=l(()=>{vt(),xt(),wt=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},Tt=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},Et=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},Dt=(e,t,n,r)=>{let i=yt(t,r),a=yt(n,r);O()._OrtAddSessionConfigEntry(e,i,a)!==0&&k(`Can't set a session config entry: ${t} - ${n}.`)},Ot=(e,t,n,r)=>{let i=yt(t,r),a=yt(n,r);e.push([i,a])},kt=async(e,t,n)=>{let r=t.executionProviders;for(let i of r){let r=typeof i==`string`?i:i.name,a=[];switch(r){case`webnn`:if(r=`WEBNN`,typeof i!=`string`){let t=i?.deviceType;t&&Dt(e,`deviceType`,t,n)}break;case`webgpu`:{r=`WebGPU`;let e;if(typeof i!=`string`){let r=i;if(r.device)if(typeof GPUDevice<`u`&&r.device instanceof GPUDevice)e=r.device;else throw Error(`Invalid GPU device set in WebGPU EP options.`);let{enableGraphCapture:o}=t;if(typeof o==`boolean`&&o&&Ot(a,`enableGraphCapture`,`1`,n),typeof r.preferredLayout==`string`&&Ot(a,`preferredLayout`,r.preferredLayout,n),r.forceCpuNodeNames){let e=Array.isArray(r.forceCpuNodeNames)?r.forceCpuNodeNames:[r.forceCpuNodeNames];Ot(a,`forceCpuNodeNames`,e.join(`
|
|
4
4
|
`),n)}r.validationMode&&Ot(a,`validationMode`,r.validationMode,n)}let o=O().webgpuRegisterDevice(e);if(o){let[e,t,r]=o;Ot(a,`deviceId`,e.toString(),n),Ot(a,`webgpuInstance`,t.toString(),n),Ot(a,`webgpuDevice`,r.toString(),n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let o=yt(r,n),s=a.length,c=0,l=0;if(s>0){c=O()._malloc(s*O().PTR_SIZE),n.push(c),l=O()._malloc(s*O().PTR_SIZE),n.push(l);for(let e=0;e<s;e++)O().setValue(c+e*O().PTR_SIZE,a[e][0],`*`),O().setValue(l+e*O().PTR_SIZE,a[e][1],`*`)}await O()._OrtAppendExecutionProvider(e,o,c,l,s)!==0&&k(`Can't append execution provider: ${r}.`)}},At=async e=>{let t=O(),n=0,r=[],i=e||{};Et(i);try{let e=wt(i.graphOptimizationLevel??`all`),a=Tt(i.executionMode??`sequential`),o=typeof i.logId==`string`?yt(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?yt(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&k(`Can't create session options.`),i.executionProviders&&await kt(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);Dt(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=yt(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&k(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&bt(i.extra,``,new WeakSet,(e,t)=>{Dt(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&k(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt=l(()=>{Mt=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},Nt=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},Pt=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},Ft=e=>{switch(e){case`float16`:return typeof Float16Array<`u`&&Float16Array.from?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},It=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},Lt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Rt=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,zt=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),Vt,Ht=l(()=>{Re(),Vt=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),Ut,Wt=l(()=>{Bt(),Ut=(e,t)=>new(Ft(t))(e)}),Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt=l(()=>{Bt(),Gt=[`V`,`I`,`W`,`E`,`F`],Kt=(e,t)=>{console.log(`[${Gt[e]},${new Date().toISOString()}]${t}`)},Yt=(e,t)=>{qt=e,Jt=t},Xt=(e,t)=>{let n=It(e);n>=It(qt)&&Kt(n,typeof t==`function`?t():t)},Zt=(...e)=>{Jt&&Xt(...e)}}),$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn=l(()=>{Bt(),Qt(),$t=new Map([[`float32`,32],[`float16`,16],[`int32`,32],[`uint32`,32],[`int64`,64],[`uint64`,64],[`int8`,8],[`uint8`,8],[`int4`,4],[`uint4`,4]]),en=(e,t)=>{if(t===`int32`)return e;let n=$t.get(t);if(!n)throw Error(`WebNN backend does not support data type: ${t}`);let r=n/8;if(e.byteLength%r!==0)throw Error(`Invalid Uint8Array length - must be a multiple of ${r}.`);let i=e.byteLength/r,a=new(Ft(t))(e.buffer,e.byteOffset,i);switch(t){case`int64`:case`uint64`:{let e=new Int32Array(i);for(let t=0;t<i;t++){let n=a[t];if(n>2147483647n||n<-2147483648n)throw Error(`Can not convert int64 data to int32 - value out of range.`);e[t]=Number(n)}return new Uint8Array(e.buffer)}case`int8`:case`uint8`:case`uint32`:{if(t===`uint32`&&a.some(e=>e>2147483647))throw Error(`Can not convert uint32 data to int32 - value out of range.`);let e=Int32Array.from(a,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from ${t} to 'int32'`)}},tn=(e,t)=>{if(t===`int32`)return e;if(e.byteLength%4!=0)throw Error(`Invalid Uint8Array length - must be a multiple of 4 (int32).`);let n=e.byteLength/4,r=new Int32Array(e.buffer,e.byteOffset,n);switch(t){case`int64`:{let e=BigInt64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`uint64`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uin64 - negative value found.`);let e=BigUint64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`int8`:{if(r.some(e=>e<-128||e>127))throw Error(`Can not convert int32 data to int8 - value out of range.`);let e=Int8Array.from(r,Number);return new Uint8Array(e.buffer)}case`uint8`:if(r.some(e=>e<0||e>255))throw Error(`Can not convert int32 data to uint8 - value out of range.`);return Uint8Array.from(r,Number);case`uint32`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uint32 - negative value found.`);let e=Uint32Array.from(r,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from 'int32' to ${t}`)}},nn=1,rn=()=>nn++,an=new Map([[`int8`,`int32`],[`uint8`,`int32`],[`uint32`,`int32`],[`int64`,`int32`]]),on=(e,t)=>{let n=$t.get(e);if(!n)throw Error(`WebNN backend does not support data type: ${e}`);return t.length>0?Math.ceil(t.reduce((e,t)=>e*t)*n/8):0},sn=class{constructor(e){this.isDataConverted=!1;let{sessionId:t,context:n,tensor:r,dataType:i,shape:a,fallbackDataType:o}=e;this.sessionId=t,this.mlContext=n,this.mlTensor=r,this.dataType=i,this.tensorShape=a,this.fallbackDataType=o}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return on(this.dataType,this.tensorShape)}destroy(){Zt(`verbose`,()=>`[WebNN] TensorWrapper.destroy`),this.mlTensor.destroy()}write(e){this.mlContext.writeTensor(this.mlTensor,e)}async read(e){if(this.fallbackDataType){let t=await this.mlContext.readTensor(this.mlTensor),n=tn(new Uint8Array(t),this.dataType);if(e){(e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).set(n);return}else return n.buffer}else return e?this.mlContext.readTensor(this.mlTensor,e):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(e,t,n){return this.mlContext===e&&this.dataType===t&&this.tensorShape.length===n.length&&this.tensorShape.every((e,t)=>e===n[t])}setIsDataConverted(e){this.isDataConverted=e}},cn=class{constructor(e,t){this.tensorManager=e,this.wrapper=t}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(e,t,n,r){let i=this.tensorManager.getMLContext(e),a=this.tensorManager.getMLOpSupportLimits(e),o;if(!a?.input.dataTypes.includes(t)){if(o=an.get(t),!o||a?.input.dataTypes.includes(o))throw Error(`WebNN backend does not support data type: ${t}`);Zt(`verbose`,()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${t} to ${o}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(i,t,n))return this.wrapper.tensor;if(r){if(this.wrapper.byteLength!==on(t,n))throw Error(`Unable to copy data to tensor with different size.`);this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let s=typeof MLTensorUsage>`u`?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(e,t,n,s,!0,!0,o),r&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(e){let t=e;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType===`int32`)t=en(e,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(e.byteLength===this.wrapper.byteLength){this.wrapper.write(t);return}else Zt(`verbose`,()=>`Data size does not match tensor size. Releasing tensor.`),this.releaseTensor()}this.activeUpload?this.activeUpload.set(t):this.activeUpload=new Uint8Array(t)}async download(e){if(this.activeUpload){let t=this.wrapper?.isDataConverted?tn(this.activeUpload,this.wrapper?.type):this.activeUpload;if(e){e instanceof ArrayBuffer?new Uint8Array(e).set(t):new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t);return}else return t.buffer}if(!this.wrapper)throw Error(`Tensor has not been created.`);return e?this.wrapper.read(e):this.wrapper.read()}},ln=class{constructor(e){this.backend=e,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(e){let t=this.backend.getMLContext(e);if(!t)throw Error(`MLContext not found for session.`);return t}getMLOpSupportLimits(e){return this.backend.getMLOpSupportLimits(e)}reserveTensorId(){let e=rn();return this.tensorTrackersById.set(e,new cn(this)),e}releaseTensorId(e){let t=this.tensorTrackersById.get(e);t&&(this.tensorTrackersById.delete(e),t.tensorWrapper&&this.releaseTensor(t.tensorWrapper))}async ensureTensor(e,t,n,r,i){Zt(`verbose`,()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${t}, dataType: ${n}, shape: ${r}, copyOld: ${i}}`);let a=this.tensorTrackersById.get(t);if(!a)throw Error(`Tensor not found.`);return a.ensureTensor(e,n,r,i)}upload(e,t){let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);n.upload(t)}async download(e,t){Zt(`verbose`,()=>`[WebNN] TensorManager.download {tensorId: ${e}, dstBuffer: ${t?.byteLength}}`);let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);return n.download(t)}releaseTensorsForSession(e){for(let t of this.freeTensors)t.sessionId===e&&t.destroy();this.freeTensors=this.freeTensors.filter(t=>t.sessionId!==e)}registerTensor(e,t,n,r){let i=this.getMLContext(e),a=rn(),o=new sn({sessionId:e,context:i,tensor:t,dataType:n,shape:r});return this.tensorTrackersById.set(a,new cn(this,o)),this.externalTensors.add(o),a}async getCachedTensor(e,t,n,r,i,a,o){let s=this.getMLContext(e);for(let[r,i]of this.freeTensors.entries())if(i.canReuseTensor(s,t,n)){Zt(`verbose`,()=>`[WebNN] Reusing tensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}`);let i=this.freeTensors.splice(r,1)[0];return i.sessionId=e,i}Zt(`verbose`,()=>`[WebNN] MLContext.createTensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}}`);let c=await s.createTensor({dataType:o??t,shape:n,dimensions:n,usage:r,writable:i,readable:a});return new sn({sessionId:e,context:s,tensor:c,dataType:t,shape:n,fallbackDataType:o})}releaseTensor(e){this.externalTensors.has(e)&&this.externalTensors.delete(e),this.freeTensors.push(e)}},un=(...e)=>new ln(...e)}),fn={};u(fn,{WebNNBackend:()=>hn});var pn,mn,hn,gn=l(()=>{Bt(),vt(),Wt(),dn(),Qt(),pn=new Map([[1,`float32`],[10,`float16`],[6,`int32`],[12,`uint32`],[7,`int64`],[13,`uint64`],[22,`int4`],[21,`uint4`],[3,`int8`],[2,`uint8`],[9,`uint8`]]),mn=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((n,i)=>n===r[i]&&e[n]===t[n])},hn=class{constructor(e){this.tensorManager=un(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,Yt(e.logLevel,!!e.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw Error(`No active session`);return this.activeSessionId}onRunStart(e){Zt(`verbose`,()=>`[WebNN] onRunStart {sessionId: ${e}}`),this.activeSessionId=e}onRunEnd(e){Zt(`verbose`,()=>`[WebNN] onRunEnd {sessionId: ${e}}`);let t=this.temporarySessionTensorIds.get(e);if(t){for(let e of t)Zt(`verbose`,()=>`[WebNN] releasing temporary tensor {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e);this.temporarySessionTensorIds.delete(e),this.activeSessionId=void 0}}async createMLContext(e){if(e instanceof GPUDevice){let t=this.mlContextCache.findIndex(t=>t.gpuDevice===e);if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({gpuDevice:e,mlContext:t}),t}}else if(e===void 0){let e=this.mlContextCache.findIndex(e=>e.options===void 0&&e.gpuDevice===void 0);if(e!==-1)return this.mlContextCache[e].mlContext;{let e=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:e}),e}}let t=this.mlContextCache.findIndex(t=>mn(t.options,e));if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({options:e,mlContext:t}),t}}registerMLContext(e,t){this.mlContextBySessionId.set(e,t);let n=this.sessionIdsByMLContext.get(t);n||(n=new Set,this.sessionIdsByMLContext.set(t,n)),n.add(e),this.mlOpSupportLimitsBySessionId.has(e)||this.mlOpSupportLimitsBySessionId.set(e,t.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(e,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(e,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(e){this.sessionGraphInputs.delete(e),this.sessionGraphOutputs.delete(e);let t=this.mlContextBySessionId.get(e);if(!t)return;this.tensorManager.releaseTensorsForSession(e),this.mlContextBySessionId.delete(e),this.mlOpSupportLimitsBySessionId.delete(e);let n=this.sessionIdsByMLContext.get(t);if(n.delete(e),n.size===0){this.sessionIdsByMLContext.delete(t);let e=this.mlContextCache.findIndex(e=>e.mlContext===t);e!==-1&&this.mlContextCache.splice(e,1)}}getMLContext(e){return this.mlContextBySessionId.get(e)}getMLOpSupportLimits(e){return this.mlOpSupportLimitsBySessionId.get(e)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(e){Zt(`verbose`,()=>`[WebNN] releaseTensorId {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e)}async ensureTensor(e,t,n,r,i){let a=pn.get(n);if(!a)throw Error(`Unsupported ONNX data type: ${n}`);return this.tensorManager.ensureTensor(e??this.currentSessionId,t,a,r,i)}async createTemporaryTensor(e,t,n){Zt(`verbose`,()=>`[WebNN] createTemporaryTensor {onnxDataType: ${t}, shape: ${n}}`);let r=pn.get(t);if(!r)throw Error(`Unsupported ONNX data type: ${t}`);let i=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(e,i,r,n,!1);let a=this.temporarySessionTensorIds.get(e);return a?a.push(i):this.temporarySessionTensorIds.set(e,[i]),i}uploadTensor(e,t){if(!O().shouldTransferToMLTensor)throw Error(`Trying to upload to a MLTensor while shouldTransferToMLTensor is false`);Zt(`verbose`,()=>`[WebNN] uploadTensor {tensorId: ${e}, data: ${t.byteLength}}`),this.tensorManager.upload(e,t)}async downloadTensor(e,t){return this.tensorManager.download(e,t)}createMLTensorDownloader(e,t){return async()=>{let n=await this.tensorManager.download(e);return Ut(n,t)}}registerMLTensor(e,t,n,r){let i=pn.get(n);if(!i)throw Error(`Unsupported ONNX data type: ${n}`);let a=this.tensorManager.registerTensor(e,t,i,r);return Zt(`verbose`,()=>`[WebNN] registerMLTensor {tensor: ${t}, dataType: ${i}, dimensions: ${r}} -> {tensorId: ${a}}`),a}registerMLConstant(e,t,n,r,i,a,o=!1){if(!a)throw Error(`External mounted files are not available.`);let s=e;e.startsWith(`./`)&&(s=e.substring(2));let c=a.get(s);if(!c)throw Error(`File with name ${s} not found in preloaded files.`);if(t+n>c.byteLength)throw Error(`Out of bounds: data offset and length exceed the external file data size.`);let l=c.slice(t,t+n).buffer,u;switch(i.dataType){case`float32`:u=new Float32Array(l);break;case`float16`:u=typeof Float16Array<`u`&&Float16Array.from?new Float16Array(l):new Uint16Array(l);break;case`int32`:u=new Int32Array(l);break;case`uint32`:u=new Uint32Array(l);break;case`int64`:if(o){let e=en(new Uint8Array(l),`int64`);u=new Int32Array(e.buffer),i.dataType=`int32`}else u=new BigInt64Array(l);break;case`uint64`:u=new BigUint64Array(l);break;case`int8`:u=new Int8Array(l);break;case`int4`:case`uint4`:case`uint8`:u=new Uint8Array(l);break;default:throw Error(`Unsupported data type: ${i.dataType} in creating WebNN Constant from external data.`)}return Zt(`verbose`,()=>`[WebNN] registerMLConstant {dataType: ${i.dataType}, shape: ${i.shape}}} ${o?`(Note: it was int64 data type and registered to int32 as workaround)`:``}`),r.constant(i,u)}registerGraphInput(e){this.temporaryGraphInputs.push(e)}registerGraphOutput(e){this.temporaryGraphOutputs.push(e)}isGraphInput(e,t){let n=this.sessionGraphInputs.get(e);return n?n.includes(t):!1}isGraphOutput(e,t){let n=this.sessionGraphOutputs.get(e);return n?n.includes(t):!1}isGraphInputOutputTypeSupported(e,t,n=!0){let r=pn.get(Mt(t)),i=this.mlOpSupportLimitsBySessionId.get(e);return typeof r>`u`?!1:n?!!i?.input.dataTypes.includes(r):!!i?.output.dataTypes.includes(r)}flush(){}}}),_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An=l(()=>{Le(),Ct(),jt(),Bt(),vt(),xt(),Ht(),_n=(e,t)=>{O()._OrtInit(e,t)!==0&&k(`Can't initialize onnxruntime.`)},vn=async e=>{_n(e.wasm.numThreads,It(e.logLevel))},yn=async(e,t)=>{O().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`);if(t===`webgpu`&&O().webgpuInit(t=>{e.webgpu.device=t}),t===`webnn`){let t=new(gn(),f(fn)).WebNNBackend(e);O().webnnInit([t,()=>t.reserveTensorId(),e=>t.releaseTensorId(e),async(e,n,r,i,a)=>t.ensureTensor(e,n,r,i,a),(e,n)=>{t.uploadTensor(e,n)},async(e,n)=>t.downloadTensor(e,n),(e,n)=>t.registerMLContext(e,n),!!e.trace])}},bn=new Map,xn=e=>{let t=O(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&k(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Sn=(e,t)=>{let n=O(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&k(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e<c;e++){let t=Number(n.getValue(i+8+e*r,`*`));l.push(t===0?Number(n.getValue(i+8+(e+c)*r,`*`)):n.UTF8ToString(t))}return[o,s,l]}finally{n.stackRestore(r),i!==0&&n._OrtFree(i)}},Cn=e=>{let t=O(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},wn=async(e,t)=>{let n,r,i=O();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=Cn(e);let a=0,o=0,s=0,c=[],l=[],u=[];try{if([o,c]=await At(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path;e.push(Vt(typeof n==`string`?n:n.data).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;n?i.currentContext=n:r?i.currentContext=await i.webnnCreateMLContext(r):i.currentContext=await i.webnnCreateMLContext({deviceType:a,powerPreference:o})}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&k(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,d]=xn(a),f=!!t?.enableGraphCapture,p=[],m=[],h=[],g=[],_=[];for(let t=0;t<e;t++){let[e,n,r]=Sn(a,t);e===0&&k(`Can't get an input name.`),l.push(e);let o=i.UTF8ToString(e);p.push(o),h.push(n===0?{name:o,isTensor:!1}:{name:o,isTensor:!0,type:Nt(n),shape:r})}for(let n=0;n<d;n++){let[r,o,s]=Sn(a,n+e);r===0&&k(`Can't get an output name.`),u.push(r);let c=i.UTF8ToString(r);m.push(c),g.push(o===0?{name:c,isTensor:!1}:{name:c,isTensor:!0,type:Nt(o),shape:s});{if(f&&t?.preferredOutputLocation===void 0){_.push(`gpu-buffer`);continue}let e=typeof t?.preferredOutputLocation==`string`?t.preferredOutputLocation:t?.preferredOutputLocation?.[c]??`cpu`,n=i.webnnIsGraphOutput;if(e===`cpu`&&n&&n(a,c)){_.push(`ml-tensor-cpu-output`);continue}if(e!==`cpu`&&e!==`cpu-pinned`&&e!==`gpu-buffer`&&e!==`ml-tensor`)throw Error(`Not supported preferred output location: ${e}.`);if(f&&e!==`gpu-buffer`)throw Error(`Not supported preferred output location: ${e}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);_.push(e)}}let v=null;return _.some(e=>e===`gpu-buffer`||e===`ml-tensor`||e===`ml-tensor-cpu-output`)&&(s=i._OrtCreateBinding(a),s===0&&k(`Can't create IO binding.`),v={handle:s,outputPreferredLocations:_,outputPreferredLocationsEncoded:_.map(e=>e===`ml-tensor-cpu-output`?`ml-tensor`:e).map(e=>zt(e))}),bn.set(a,[a,l,u,v,f,!1]),[a,p,m,h,g]}catch(e){throw l.forEach(e=>i._OrtFree(e)),u.forEach(e=>i._OrtFree(e)),s!==0&&i._OrtReleaseBinding(s)!==0&&k(`Can't release IO binding.`),a!==0&&i._OrtReleaseSession(a)!==0&&k(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&k(`Can't release session options.`),c.forEach(e=>i._free(e)),i.unmountExternalData?.()}},Tn=e=>{let t=O(),n=bn.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&k(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&k(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&k(`Can't release session.`),bn.delete(e)},En=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=O(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=Pt(Mt(l),u);{let e=s.webgpuRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(t,r)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=Pt(Mt(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,Mt(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;e<t.length;e++){if(typeof t[e]!=`string`)throw TypeError(`tensor data at index ${e} is not a string`);s.setValue(p+e*c,yt(t[e],n),`*`)}}else{let e=s.webnnIsGraphInput,a=s.webnnIsGraphOutput;if(l!==`string`&&e&&a){let o=s.UTF8ToString(i);if(e(r,o)||a(r,o)){let e=Mt(l);m=Pt(e,u),f=`ml-tensor`;let n=s.webnnCreateTemporaryTensor,i=s.webnnUploadTensor;if(!n||!i)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);let a=await n(r,e,u);i(a,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),p=a}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}else m=t.byteLength,p=s._malloc(m),n.push(p),s.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,m),p)}}let h=s.stackSave(),g=s.stackAlloc(4*u.length);try{u.forEach((e,t)=>s.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(Mt(l),p,m,g,u.length,zt(f));e===0&&k(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},Dn=async(e,t,n,r,i,a)=>{let o=O(),s=o.PTR_SIZE,c=bn.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4],m=c[5],h=t.length,g=r.length,_=0,v=[],y=[],b=[],x=[],ee=[],S=o.stackSave(),te=o.stackAlloc(h*s),C=o.stackAlloc(h*s),w=o.stackAlloc(g*s),ne=o.stackAlloc(g*s);try{[_,v]=St(a),Te(`wasm prepareInputOutputTensor`);for(let r=0;r<h;r++)await En(n[r],y,x,e,u[t[r]],t[r],p);for(let t=0;t<g;t++)await En(i[t],b,x,e,d[r[t]],h+r[t],p);Ee(`wasm prepareInputOutputTensor`);for(let e=0;e<h;e++)o.setValue(te+e*s,y[e],`*`),o.setValue(C+e*s,u[t[e]],`*`);for(let e=0;e<g;e++)o.setValue(w+e*s,b[e],`*`),o.setValue(ne+e*s,d[r[e]],`*`);if(f&&!m){let{handle:n,outputPreferredLocations:a,outputPreferredLocationsEncoded:s}=f;if(u.length!==h)throw Error(`input count from feeds (${h}) is expected to be always equal to model's input count (${u.length}).`);Te(`wasm bindInputsOutputs`);for(let r=0;r<h;r++){let i=t[r];await o._OrtBindInput(n,u[i],y[r])!==0&&k(`Can't bind input[${r}] for session=${e}.`)}for(let t=0;t<g;t++){let c=r[t];i[t]?.[3]?(ee.push(b[t]),o._OrtBindOutput(n,d[c],b[t],0)!==0&&k(`Can't bind pre-allocated output[${t}] for session=${e}.`)):o._OrtBindOutput(n,d[c],0,s[c])!==0&&k(`Can't bind output[${t}] to ${a[t]} for session=${e}.`)}Ee(`wasm bindInputsOutputs`),bn.set(e,[l,u,d,f,p,!0])}o.jsepOnRunStart?.(l),o.webnnOnRunStart?.(l);let c;c=f?await o._OrtRunWithBinding(l,f.handle,g,w,_):await o._OrtRun(l,C,te,h,ne,g,w,_),c!==0&&k(`failed to call OrtRun().`);let S=[],re=[];Te(`wasm ProcessOutputTensor`);for(let t=0;t<g;t++){let n=Number(o.getValue(w+t*s,`*`));if(n===b[t]||ee.includes(b[t])){S.push(i[t]),n!==b[t]&&o._OrtReleaseTensor(n)!==0&&k(`Can't release tensor.`);continue}let a=o.stackSave(),c=o.stackAlloc(4*s),l=!1,u,d=0;try{o._OrtGetTensorData(n,c,c+s,c+2*s,c+3*s)!==0&&k(`Can't access output tensor data on index ${t}.`);let i=s===4?`i32`:`i64`,a=Number(o.getValue(c,i));d=o.getValue(c+s,`*`);let p=o.getValue(c+s*2,`*`),m=Number(o.getValue(c+s*3,i)),h=[];for(let e=0;e<m;e++)h.push(Number(o.getValue(p+e*s,i)));o._OrtFree(p)!==0&&k(`Can't free memory for tensor dims.`);let g=h.reduce((e,t)=>e*t,1);u=Nt(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t<g;t++){let n=o.getValue(d+t*s,`*`),r=o.getValue(d+(t+1)*s,`*`),i=t===g-1?void 0:r-n;e.push(o.UTF8ToString(n,i))}S.push([u,h,e,`cpu`])}else if(_===`gpu-buffer`&&g>0){let t=o.webgpuGetBuffer;if(!t)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let r=t(d),i=Pt(a,g);if(i===void 0||!Lt(u))throw Error(`Unsupported data type: ${u}`);l=!0;{o.webgpuRegisterBuffer(r,e,d);let t=o.webgpuCreateDownloader(r,i,e);S.push([u,h,{gpuBuffer:r,download:async()=>{let e=await t();return new(Ft(u))(e)},dispose:()=>{o._OrtReleaseTensor(n)!==0&&k(`Can't release tensor.`)}},`gpu-buffer`])}}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(Pt(a,g)===void 0||!Rt(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,S.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=S.length;l=!0,re.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),S.push([u,h,[],`cpu`])}else{let e=new(Ft(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),S.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&k(`Can't clear bound outputs.`),bn.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(re))S[e][2]=t;return Ee(`wasm ProcessOutputTensor`),S}finally{o.webnnOnRunEnd?.(l),o.stackRestore(S),n.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),i.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),y.forEach(e=>o._OrtReleaseTensor(e)),b.forEach(e=>o._OrtReleaseTensor(e)),x.forEach(e=>o._free(e)),_!==0&&o._OrtReleaseRunOptions(_),v.forEach(e=>o._free(e))}},On=e=>{let t=O(),n=bn.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&k(`Can't get an profile file name.`),t._OrtFree(i)},kn=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn=l(()=>{Le(),An(),vt(),lt(),jn=()=>!!C.wasm.proxy&&typeof document<`u`,Nn=!1,Pn=!1,Fn=!1,Rn=new Map,zn=(e,t)=>{let n=Rn.get(e);n?n.push(t):Rn.set(e,[t])},Bn=()=>{if(Nn||!Pn||Fn||!Mn)throw Error(`worker not ready`)},Vn=e=>{switch(e.data.type){case`init-wasm`:Nn=!1,e.data.err?(Fn=!0,Ln[1](e.data.err)):(Pn=!0,Ln[0]()),In&&=(URL.revokeObjectURL(In),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Rn.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}default:}},Hn=async()=>{if(!Pn){if(Nn)throw Error(`multiple calls to 'initWasm()' detected.`);if(Fn)throw Error(`previous call to 'initWasm()' failed.`);if(Nn=!0,jn())return new Promise((e,t)=>{Mn?.terminate(),ot().then(([n,r])=>{try{Mn=r,Mn.onerror=e=>t(e),Mn.onmessage=Vn,Ln=[e,t];let i={type:`init-wasm`,in:C};!i.in.wasm.wasmPaths&&(n||Xe)&&(i.in.wasm.wasmPaths={wasm:new URL(`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`,``+import.meta.url).href}),Mn.postMessage(i),In=n}catch(e){t(e)}},t)});try{await _t(C.wasm),await vn(C),Pn=!0}catch(e){throw Fn=!0,e}finally{Nn=!1}}},Un=async e=>{if(jn())return Bn(),new Promise((t,n)=>{zn(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:C}};Mn.postMessage(r)});await yn(C,e)},Wn=async e=>jn()?(Bn(),new Promise((t,n)=>{zn(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};Mn.postMessage(r,[e.buffer])})):Cn(e),Gn=async(e,t)=>{if(jn()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return Bn(),new Promise((n,r)=>{zn(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),Mn.postMessage(i,a)})}else return wn(e,t)},Kn=async e=>{if(jn())return Bn(),new Promise((t,n)=>{zn(`release`,[t,n]);let r={type:`release`,in:e};Mn.postMessage(r)});Tn(e)},qn=async(e,t,n,r,i,a)=>{if(jn()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return Bn(),new Promise((i,o)=>{zn(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};Mn.postMessage(c,kn(s))})}else return Dn(e,t,n,r,i,a)},Jn=async e=>{if(jn())return Bn(),new Promise((t,n)=>{zn(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};Mn.postMessage(r)});On(e)}}),Xn,Zn,Qn,$n=l(()=>{Le(),Yn(),Bt(),Re(),Ht(),Xn=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},Zn=e=>{switch(e[3]){case`cpu`:return new be(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!Lt(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return be.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!Rt(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return be.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},Qn=class{async fetchModelAndCopyToWasmMemory(e){return Wn(await Vt(e))}async loadModel(e,t){Ce();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Gn(n,t),we()}async dispose(){return Kn(this.sessionId)}async run(e,t,n){Ce();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>Xn(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?Xn(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await qn(this.sessionId,i,s,o,c,n),u={};for(let e=0;e<l.length;e++)u[this.outputNames[o[e]]]=a[e]??Zn(l[e]);return we(),u}startProfiling(){}endProfiling(){Jn(this.sessionId)}}}),er={};u(er,{OnnxruntimeWebAssemblyBackend:()=>nr,initializeFlags:()=>tr,wasmBackend:()=>rr});var tr,nr,rr,ir=l(()=>{Le(),Yn(),$n(),tr=()=>{(typeof C.wasm.initTimeout!=`number`||C.wasm.initTimeout<0)&&(C.wasm.initTimeout=0);let e=C.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),C.wasm.simd=!1),typeof C.wasm.proxy!=`boolean`&&(C.wasm.proxy=!1),typeof C.wasm.trace!=`boolean`&&(C.wasm.trace=!1),typeof C.wasm.numThreads!=`number`||!Number.isInteger(C.wasm.numThreads)||C.wasm.numThreads<=0)if(typeof self<`u`&&!self.crossOriginIsolated)C.wasm.numThreads=1;else{let e=typeof navigator>`u`?c(`node:os`).cpus().length:navigator.hardwareConcurrency;C.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},nr=class{async init(e){tr(),await Hn(),await Un(e)}async createInferenceSessionHandler(e,t){let n=new Qn;return await n.loadModel(e,t),n}},rr=new nr});Le(),Le(),Le();var ar=`1.26.0-dev.20260416-b7804b056c`,or=Ie;{let e=(ir(),f(er)).wasmBackend;h(`webgpu`,e,5),h(`webnn`,e,5),h(`cpu`,e,10),h(`wasm`,e,10)}Object.defineProperty(C.versions,"web",{value:ar,enumerable:!0});var sr=`1.24.3`,cr=`warning`;Object.defineProperty({wasm:{},webgl:{},webgpu:{},versions:{common:sr},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);cr=e}},get logLevel(){return cr}},"logLevel",{enumerable:!0});var lr=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t<a;t++)for(let n=0;n<i;n++){let i=(e.data[d++]-l[0])*c[0],a=(e.data[f++]-l[1])*c[1],o=(e.data[p++]-l[2])*c[2],s=m===-1?255:(e.data[m++]-l[3])*c[3];r.fillStyle=`rgba(`+i+`,`+a+`,`+o+`,`+s+`)`,r.fillRect(n,t,1,1)}if(`toDataURL`in n)return n.toDataURL();throw Error(`toDataURL is not supported`)}else throw Error(`Can not access image data`)},ur=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t===void 0||t.format===void 0?`RGB`:t.format,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t<a*i;f+=4,p+=4,m+=4,h+=4,t++)r.data[f]=(e.data[g++]-u[0])*l[0],r.data[p]=(e.data[_++]-u[1])*l[1],r.data[m]=(e.data[v++]-u[2])*l[2],r.data[h]=y===-1?255:(e.data[y++]-u[3])*l[3]}else throw Error(`Can not access image data`);return r},dr=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat===void 0||t.tensorFormat===void 0?`RGB`:t.tensorFormat,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t<l;t++,f+=d,m+=d,p+=d,h+=d)u[g++]=(e[f]+o[0])/a[0],u[_++]=(e[p]+o[1])/a[1],u[v++]=(e[m]+o[2])/a[2],y!==-1&&h!==-1&&(u[y++]=(e[h]+o[3])/a[3]);return c===`RGBA`?new Sr(`float32`,u,[1,4,n,r]):new Sr(`float32`,u,[1,3,n,r])},fr=async(e,t)=>{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,dr(o,s)}else throw Error(`Can not access image data`)}else if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(dr(e.data,s))}});else throw Error(`Input data provided is not supported - aborted tensor creation`);if(o!==void 0)return dr(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},pr=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new Sr({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},mr=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new Sr({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},hr=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new Sr({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},gr=(e,t,n)=>new Sr({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]}),_r=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),vr=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),yr=!1,br=()=>{if(!yr){yr=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=n!==void 0&&n.from;e&&(_r.set(`int64`,BigInt64Array),vr.set(BigInt64Array,`int64`)),t&&(_r.set(`uint64`,BigUint64Array),vr.set(BigUint64Array,`uint64`)),r?(_r.set(`float16`,n),vr.set(n,`float16`)):_r.set(`float16`,Uint16Array)}},A=e=>{let t=1;for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`number`||!Number.isSafeInteger(r))throw TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);t*=r}return t},xr=(e,t)=>{switch(e.location){case`cpu`:return new Sr(e.type,e.data,t);case`cpu-pinned`:return new Sr({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new Sr({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new Sr({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new Sr({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}},Sr=class{constructor(e,t,n){br();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=_r.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`)if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=_r.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray)if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`);else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=vr.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=A(i);if(this.cpuData&&a!==this.cpuData.length&&!((r===`uint4`||r===`int4`)&&Math.ceil(a/2)===this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return fr(e,t)}static fromTexture(e,t){return pr(e,t)}static fromGpuBuffer(e,t){return mr(e,t)}static fromMLTensor(e,t){return hr(e,t)}static fromPinnedBuffer(e,t,n){return gr(e,t,n)}toDataURL(e){return lr(this,e)}toImageData(e){return ur(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return xr(this,e)}},Cr=Sr,wr=Object.defineProperty,Tr=(e,t)=>{for(var n in t)wr(e,n,{get:t[n],enumerable:!0})},Er={},Dr={},Or={},kr=`4.2.0`,Ar=typeof self<`u`,jr=!ti(Er),Mr=!ti(Dr),Nr=Ar&&`caches`in self,Pr=globalThis.Deno!==void 0;globalThis.Bun;var Fr=Pr&&Nr&&!jr,Ir=typeof process<`u`,Lr=Ir&&process?.release?.name===`node`&&!Fr,Rr=typeof window<`u`&&window.document!==void 0,zr=Ar&&[`DedicatedWorkerGlobalScope`,`ServiceWorkerGlobalScope`,`SharedWorkerGlobalScope`].includes(self.constructor?.name),Br=Rr||zr||Fr,Vr=Lr||typeof navigator<`u`&&`gpu`in navigator,Hr=typeof navigator<`u`&&`ml`in navigator,Ur=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`,Wr=typeof chrome<`u`&&chrome.runtime!==void 0&&typeof chrome.runtime.id==`string`,Gr=typeof ServiceWorkerGlobalScope<`u`&&Ar&&self instanceof ServiceWorkerGlobalScope,Kr=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent,t=(navigator.vendor||``).indexOf(`Apple`)>-1,n=!e.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!e.includes(`Chrome`)&&!e.includes(`Android`);return t&&n})(),j=Object.freeze({IS_BROWSER_ENV:Rr,IS_WEBWORKER_ENV:zr,IS_WEB_ENV:Br,IS_SERVICE_WORKER_ENV:Gr,IS_DENO_WEB_RUNTIME:Fr,IS_WEB_CACHE_AVAILABLE:Nr,IS_WEBGPU_AVAILABLE:Vr,IS_WEBNN_AVAILABLE:Hr,IS_SAFARI:Kr,IS_PROCESS_AVAILABLE:Ir,IS_NODE_ENV:Lr,IS_FS_AVAILABLE:jr,IS_PATH_AVAILABLE:Mr,IS_CRYPTO_AVAILABLE:Ur,IS_CHROME_AVAILABLE:Wr}),qr=jr&&Mr,Jr=`./`;if(qr){let e=Object(import.meta).url;e?Jr=Dr.dirname(Dr.dirname(Or.fileURLToPath(e))):typeof __dirname<`u`&&(Jr=Dr.dirname(__dirname))}var Yr=qr?Dr.join(Jr,`/.cache/`):null,Xr=`/models/`,Zr=qr?Dr.join(Jr,Xr):Xr,Qr=typeof globalThis.fetch==`function`?globalThis.fetch.bind(globalThis):void 0,$r=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),ei=$r.WARNING,M={version:kr,backends:{onnx:{}},get logLevel(){return ei},set logLevel(e){ei=e,M.backends.onnx?.setLogLevel?.(e)},allowRemoteModels:!0,remoteHost:`https://huggingface.co/`,remotePathTemplate:`{model}/resolve/{revision}/`,allowLocalModels:!(Rr||zr||Fr),localModelPath:Zr,useFS:jr,useBrowserCache:Nr,useFSCache:jr,cacheDir:Yr,useCustomCache:!1,customCache:null,useWasmCache:Nr||jr,cacheKey:`transformers-cache`,experimental_useCrossOriginStorage:!1,fetch:Qr};function ti(e){return Object.keys(e).length===0}var ni=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}_call(...e){throw Error(`Must implement _call method in subclass`)}};function ri(e,t){e&&e(t)}var ii=class extends ni{constructor(e,t){super(),this.callback=e,this.files_loading=t}_call(e){if(e.status===`progress`){this.files_loading[e.file]={loaded:e.loaded,total:e.total};let t=Object.values(this.files_loading).reduce((e,t)=>e+t.loaded,0),n=Object.values(this.files_loading).reduce((e,t)=>e+t.total,0),r=n>0?t/n*100:0;this.callback({status:`progress_total`,name:e.name,progress:r,loaded:t,total:n,files:structuredClone(this.files_loading)})}this.callback(e)}};function ai(e){return Number.isInteger(e)||typeof e==`bigint`}function oi(e){return e==null||e===-1}function si(e){let t=[],n=e;for(;Array.isArray(n);)t.push(n.length),n=n[0];return t}function ci(...e){return Array.prototype.concat.apply([],e)}function li(...e){return e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[e,t])))}function ui(e,t){return Math.abs((e+t)%(2*t)-t)}function di(e,t){return Object.assign({},...t.map(t=>{if(e[t]!==void 0)return{[t]:e[t]}}))}function fi(e,t){let n=0;for(let r of e)r===t&&++n;return n}var N={error(...e){M.logLevel<=$r.ERROR&&console.error(...e)},warn(...e){M.logLevel<=$r.WARNING&&console.warn(...e)},info(...e){M.logLevel<=$r.INFO&&console.log(...e)},debug(...e){M.logLevel<=$r.DEBUG&&console.log(...e)},log(...e){this.info(...e)}},pi=class{constructor(e){this.trie=this._build_trie(e)}_build_trie(e){let t=Object.create(null);for(let n of e){let e=t;for(let t=0;t<n.length;++t){let r=n[t];e=e[r]??=Object.create(null)}e.end=n}return t}split(e){let t=[],n=e.length,r=0,i=0;for(;i<n;){let a=this.trie,o=null,s=i;for(;s<n&&(a=a[e[s]]);)a.end&&(o=a.end),++s;o?(i>r&&t.push(e.slice(r,i)),t.push(o),i+=o.length,r=i):++i}return r<n&&t.push(e.slice(r)),t}},mi=class{constructor(e){this.content=e.content,this.id=e.id,this.single_word=e.single_word??!1,this.lstrip=e.lstrip??!1,this.rstrip=e.rstrip??!1,this.special=e.special??!1,this.normalized=e.normalized??!this.special}},hi=(()=>{let e=[...Array.from({length:94},(e,t)=>t+33),...Array.from({length:12},(e,t)=>t+161),...Array.from({length:82},(e,t)=>t+174)],t=e.slice(),n=0;for(let r=0;r<256;++r)e.includes(r)||(e.push(r),t.push(256+n),n+=1);let r=t.map(e=>String.fromCharCode(e));return Object.fromEntries(e.map((e,t)=>[e,r[t]]))})(),gi=(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])))(hi),_i=`.,!?…。,、।۔،`,vi=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|[${_i}])]+`,` ?[^\\s${_i}]+`]]),yi=`\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E`,bi=e=>e.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`),xi=(e,t=!0)=>{if(e.Regex!==void 0){let t=e.Regex.replace(/\\([#&~])/g,`$1`);t=t.replace(/\\A/g,`^`).replace(/\\z/g,`$`).replace(/\\Z/g,`(?=\\r?\\n?$)`);for(let[e,n]of vi)t=t.replaceAll(e,n);try{return new RegExp(t,`gu`)}catch(e){if(!(e instanceof SyntaxError)||!e.message.toLowerCase().includes(`invalid property name`))throw e;let n=!1,r=t.replace(/(\\[pP])\{([^}=]+)\}/g,(e,t,r)=>{try{return RegExp(`\\p{${r}}`,`u`),`${t}{${r}}`}catch{return n=!0,`${t}{Script=${r}}`}});if(!n)throw e;try{return new RegExp(r,`gu`)}catch{throw e}}}else if(e.String!==void 0){let n=Si(e.String);return new RegExp(t?n:`(${n})`,`gu`)}else return console.warn(`Unknown pattern type:`,e),null},Si=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Ci=(e,t,n)=>{let r=[],i=0;for(;i<e.length;){if(r.push(e[i]),(t.get(e[i])??n)!==n){++i;continue}for(;++i<e.length&&(t.get(e[i])??n)===n;)t.get(r.at(-1))!==n&&(r[r.length-1]+=e[i])}return r},wi=e=>e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,Ti=e=>Number.isInteger(e)||typeof e==`bigint`,Ei=e=>{let t=0;for(let n of e)++t;return t},Di=e=>ji(e.toLowerCase()),Oi=(...e)=>Array.prototype.concat.apply([],e),ki=e=>new Map(Object.entries(e)),Ai=(e,t)=>{let n=[],r=0;for(let i of e.matchAll(t)){let t=i[0];r<i.index&&n.push(e.slice(r,i.index)),t.length>0&&n.push(t),r=i.index+t.length}return r<e.length&&n.push(e.slice(r)),n},ji=e=>e.replace(/\p{M}/gu,``),Mi=(e,t,n=[])=>{if(!e||Array.isArray(e)||typeof e!=`object`)return`${t} must be a valid object`;for(let r of n)if(!(r in e))return`${t} must contain a "${r}" property`;return null},Ni=e=>e.match(/\S+/g)||[],Pi=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}},Fi=class extends Pi{constructor(e){super(),this.config=e}_call(e){return this.normalize(e)}},Ii=class extends Fi{tokenize_chinese_chars(e){let t=[];for(let n=0;n<e.length;++n){let r=e[n];wi(r.charCodeAt(0))?(t.push(` `),t.push(r),t.push(` `)):t.push(r)}return t.join(``)}strip_accents(e){return e.normalize(`NFD`).replace(/\p{Mn}/gu,``)}is_control(e){switch(e){case` `:case`
|
|
5
|
-
`:case`\r`:return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(e)}}clean_text(e){let t=[];for(let n of e){let e=n.charCodeAt(0);e===0||e===65533||this.is_control(n)||(/^\s$/.test(n)?t.push(` `):t.push(n))}return t.join(``)}normalize(e){return this.config.clean_text&&(e=this.clean_text(e)),this.config.handle_chinese_chars&&(e=this.tokenize_chinese_chars(e)),this.config.lowercase?(e=e.toLowerCase(),this.config.strip_accents!==!1&&(e=this.strip_accents(e))):this.config.strip_accents&&(e=this.strip_accents(e)),e}},Li=class extends Fi{constructor(e){super(e),this.charsmap=e.precompiled_charsmap??null}normalize(e){return e=e.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,``),e=e.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm,` `),e=e.includes(`~`)?e.split(`~`).map(e=>e.normalize(`NFKC`)).join(`~`):e.normalize(`NFKC`),e}},Ri=class extends Fi{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(e=>Xi(e))}normalize(e){return this.normalizers.reduce((e,t)=>t?t.normalize(e):e,e)}},zi=class extends Fi{normalize(e){let t=xi(this.config.pattern??{});return t===null?e:e.replaceAll(t,this.config.content??``)}},Bi=class extends Fi{constructor(){super(...arguments),this.form=`NFC`}normalize(e){return e=e.normalize(this.form),e}},Vi=class extends Bi{constructor(){super(...arguments),this.form=`NFC`}},Hi=class extends Bi{constructor(){super(...arguments),this.form=`NFD`}},Ui=class extends Bi{constructor(){super(...arguments),this.form=`NFKC`}},Wi=class extends Bi{constructor(){super(...arguments),this.form=`NFKD`}},Gi=class extends Fi{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}},Ki=class extends Fi{normalize(e){return ji(e)}},qi=class extends Fi{normalize(e){return e.toLowerCase()}},Ji=class extends Fi{normalize(e){return e=this.config.prepend+e,e}};function Yi(e){if(e===null)return null;switch(e.type){case`BertNormalizer`:return new Ii(e);case`Precompiled`:return new Li(e);case`Sequence`:return new Ri(e);case`Replace`:return new zi(e);case`NFC`:return new Vi(e);case`NFD`:return new Hi(e);case`NFKC`:return new Ui(e);case`NFKD`:return new Wi(e);case`Strip`:return new Gi(e);case`StripAccents`:return new Ki(e);case`Lowercase`:return new qi(e);case`Prepend`:return new Ji(e);default:throw Error(`Unknown Normalizer type: ${e.type}`)}}var Xi=Yi,Zi=class extends Pi{pre_tokenize(e,t){return(Array.isArray(e)?e.map(e=>this.pre_tokenize_text(e,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},Qi=class extends Zi{constructor(e){super(),this.config=e,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=hi,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){return this.add_prefix_space&&!e.startsWith(` `)&&(e=` `+e),(this.use_regex?e.match(this.pattern)||[]:[e]).map(e=>Array.from(this.text_encoder.encode(e),e=>this.byte_encoder[e]).join(``))}},$i=class extends Zi{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},ea=class extends Zi{constructor(e){super(),this.replacement=e.replacement??`▁`,this.str_rep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??`always`}pre_tokenize_text(e,t){let{section_index:n=void 0}=t??{},r=e.replaceAll(` `,this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme===`always`||this.prepend_scheme===`first`&&n===0)&&(r=this.str_rep+r),[r]}},ta=class extends Zi{constructor(e){super(),this.config=e,this.pattern=xi(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?e.match(this.pattern)||[]:this.config.behavior?.toLowerCase()===`removed`?e.split(this.pattern).filter(e=>e):Ai(e,this.pattern)}},na=class extends Zi{constructor(e){super(),this.config=e,this.pattern=RegExp(`[^${yi}]+|[${yi}]+`,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},ra=class extends Zi{constructor(e){super(),this.config=e;let t=`[^\\d]+|\\d${this.config.individual_digits?``:`+`}`;this.pattern=new RegExp(t,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},ia=class extends Zi{constructor(){super(),this.pattern=RegExp(`[^\\s${yi}]+|[${yi}]`,`gu`)}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},P=class extends Zi{constructor(e){super(),this.config=e,this.pattern=xi(this.config.pattern??{}),this.content=this.config.content??``}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??``)]}},aa=class extends Zi{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(e=>I(e))}pre_tokenize_text(e,t){return this.tokenizers.reduce((e,n)=>n?n.pre_tokenize(e,t):e,[e])}},oa=class extends Zi{pre_tokenize_text(e){return Ni(e)}},F=class extends Zi{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){let t=[];for(let n=0;n<e.length;n+=this._length)t.push(e.slice(n,n+this._length));return t}};function sa(e){if(e===null)return null;switch(e.type){case`BertPreTokenizer`:return new ia;case`Sequence`:return new aa(e);case`Whitespace`:return new $i;case`WhitespaceSplit`:return new oa;case`Metaspace`:return new ea(e);case`ByteLevel`:return new Qi(e);case`Split`:return new ta(e);case`Punctuation`:return new na(e);case`Digits`:return new ra(e);case`Replace`:return new P(e);case`FixedLength`:return new F(e);default:throw Error(`Unknown PreTokenizer type: ${e.type}`)}}var I=sa,ca=class extends Pi{constructor(e){super(),this.config=e,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(e){let t=this.encode(e);return this.fuse_unk&&(t=Ci(t,this.tokens_to_ids,this.unk_token_id)),t}},la=class extends ca{constructor(e){super(e),this.max_input_chars_per_word=100,this.tokens_to_ids=ki(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.max_input_chars_per_word=e.max_input_chars_per_word??100,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){let t=[];for(let n of e){let e=[...n];if(e.length>this.max_input_chars_per_word){t.push(this.unk_token);continue}let r=!1,i=0,a=[];for(;i<e.length;){let t=e.length,n=null;for(;i<t;){let r=e.slice(i,t).join(``);if(i>0&&(r=this.config.continuing_subword_prefix+r),this.tokens_to_ids.has(r)){n=r;break}--t}if(n===null){r=!0;break}a.push(n),i=t}r?t.push(this.unk_token):t.push(...a)}return t}},ua=class e{constructor(e,t){this.is_leaf=e,this.children=t}static default(){return new e(!1,new Map)}},da=class{constructor(){this.root=ua.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let n of e){let e=t.children.get(n);e===void 0&&(e=ua.default(),t.children.set(n,e)),t=e}t.is_leaf=!0}*common_prefix_search(e){let t=this.root;if(t===void 0)return;let n=``;for(let r of e){if(n+=r,t=t.children.get(r),t===void 0)return;t.is_leaf&&(yield n)}}},fa=class e{constructor(e,t,n,r,i){this.token_id=e,this.node_id=t,this.pos=n,this.length=r,this.score=i,this.prev=null,this.backtrace_score=0}clone(){let t=new e(this.token_id,this.node_id,this.pos,this.length,this.score);return t.prev=this.prev,t.backtrace_score=this.backtrace_score,t}},pa=class{constructor(e,t,n){this.chars=Array.from(e),this.len=this.chars.length,this.bos_token_id=t,this.eos_token_id=n,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new fa(this.bos_token_id??0,0,0,0,0),i=new fa(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(i.clone()),this.begin_nodes[this.len].push(i),this.end_nodes[0].push(r)}insert(e,t,n,r){let i=this.nodes.length,a=new fa(r,i,e,t,n);this.begin_nodes[e].push(a),this.end_nodes[e+t].push(a),this.nodes.push(a)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let e of this.begin_nodes[t]){e.prev=null;let n=0,r=null;for(let i of this.end_nodes[t]){let t=i.backtrace_score+e.score;(r===null||t>n)&&(r=i.clone(),n=t)}if(r!==null)e.prev=r,e.backtrace_score=n;else return[]}++t}let n=[],r=this.begin_nodes[e][0].prev;if(r===null)return[];let i=r.clone();for(;i.prev!==null;)n.push(i.clone()),i=i.clone().prev.clone();return n.reverse(),n}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join(``)}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}};function ma(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]<t&&(t=e[r],n=r);return[t,n]}var ha=class extends ca{constructor(e,t){super(e);let n=e.vocab.length;this.vocab=Array(n),this.scores=Array(n);for(let t=0;t<n;++t)[this.vocab[t],this.scores[t]]=e.vocab[t];this.unk_token_id=e.unk_id,this.unk_token=this.vocab[e.unk_id],this.tokens_to_ids=new Map(this.vocab.map((e,t)=>[e,t])),this.bos_token=` `,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=ma(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new da,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){let t=e.chars,n=0;for(;n<t.length;){let r=!1,i=[],a=t.slice(n).join(``),o=this.trie.common_prefix_search(a);for(let t of o){i.push(t);let a=this.tokens_to_ids.get(t),o=this.scores[a],s=Ei(t);e.insert(n,s,o,a),!r&&s===1&&(r=!0)}r||e.insert(n,1,this.unk_score,this.unk_token_id),n+=1}}tokenize(e){let t=new pa(e,this.bos_token_id,this.eos_token_id);return this.populate_nodes(t),t.tokens()}encode(e){let t=[];for(let n of e){let e=this.tokenize(n);t.push(...e)}return t}},ga=class{constructor(e=(e,t)=>e>t,t=1/0){this._heap=[],this._comparator=e,this._max_size=t}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)if(this.size<this._max_size)this._heap.push(t),this._sift_up();else{let e=this._smallest();this._comparator(t,this._heap[e])&&(this._heap[e]=t,this._sift_up_from(e))}return this.size}pop(){let e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._sift_down(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let n=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=n}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_sift_down(){let e=0;for(;this._left(e)<this.size&&this._greater(this._left(e),e)||this._right(e)<this.size&&this._greater(this._right(e),e);){let t=this._right(e)<this.size&&this._greater(this._right(e),this._left(e))?this._right(e):this._left(e);this._swap(e,t),e=t}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},_a=class{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)&&this.cache.delete(e),this.cache.set(e,t),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},va=class extends ca{constructor(e){super(e),this.tokens_to_ids=ki(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e;let t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(e=>e.split(` `,2)),this.bpe_ranks=new Map(this.merges.map((e,t)=>[JSON.stringify(e),t])),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.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 _a(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];let t=this.cache.get(e);if(t!==void 0)return t;let n=Array.from(e);this.end_of_word_suffix&&(n[n.length-1]+=this.end_of_word_suffix);let r=[];if(n.length>1){let e=new ga((e,t)=>e.score<t.score),t={token:n[0],bias:0,prev:null,next:null},i=t;for(let t=1;t<n.length;++t){let r={bias:t/n.length,token:n[t],prev:i,next:null};i.next=r,this.add_node(e,i),i=r}for(;!e.is_empty();){let n=e.pop();if(n.deleted||!n.next||n.next.deleted)continue;if(n.deleted=!0,n.next.deleted=!0,n.prev){let e={...n.prev};n.prev.deleted=!0,n.prev=e,e.prev?e.prev.next=e:t=e}let r={token:n.token+n.next.token,bias:n.bias,prev:n.prev,next:n.next.next};r.prev?(r.prev.next=r,this.add_node(e,r.prev)):t=r,r.next&&(r.next.prev=r,this.add_node(e,r))}for(let e=t;e!==null;e=e.next)r.push(e.token)}else r=n;if(this.continuing_subword_suffix)for(let e=0;e<r.length-1;++e)r[e]+=this.continuing_subword_suffix;return e.length<this.max_length_to_cache&&this.cache.put(e,r),r}add_node(e,t){let n=this.bpe_ranks.get(JSON.stringify([t.token,t.next.token]));n!==void 0&&(t.score=n+t.bias,e.push(t))}encode(e){let t=[];for(let n of e){if(this.ignore_merges&&this.tokens_to_ids.has(n)){t.push(n);continue}let e=this.bpe(n);for(let n of e)if(this.tokens_to_ids.has(n))t.push(n);else if(this.byte_fallback){let e=Array.from(this.text_encoder.encode(n)).map(e=>`<0x${e.toString(16).toUpperCase().padStart(2,`0`)}>`);e.every(e=>this.tokens_to_ids.has(e))?t.push(...e):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},ya=class extends ca{constructor(e,t){super(e);let n=e.vocab;this.tokens_to_ids=ki(t.target_lang?n[t.target_lang]:n),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){return e}};function ba(e,t){switch(e.type){case`WordPiece`:return new la(e);case`Unigram`:return new ha(e,t.eos_token);case`BPE`:return new va(e);default:if(e.vocab)return Array.isArray(e.vocab)?new ha(e,t.eos_token):Object.hasOwn(e,`continuing_subword_prefix`)&&Object.hasOwn(e,`unk_token`)?Object.hasOwn(e,`merges`)?new va(e):new la(e):new ya(e,{target_lang:t.target_lang,bos_token:t.bos_token,eos_token:t.eos_token,pad_token:t.pad_token,unk_token:t.unk_token});throw Error(`Unknown TokenizerModel type: ${e?.type}`)}}var xa=ba,Sa=class extends Pi{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},Ca=class extends Sa{post_process(e,t=null,n=!0){let r=t===null?this.config.single:this.config.pair,i=[],a=[];for(let o of r)`SpecialToken`in o?n&&(i.push(o.SpecialToken.id),a.push(o.SpecialToken.type_id)):`Sequence`in o&&(o.Sequence.id===`A`?(i=Oi(i,e),a=Oi(a,Array(e.length).fill(o.Sequence.type_id))):o.Sequence.id===`B`&&(i=Oi(i,t),a=Oi(a,Array(t.length).fill(o.Sequence.type_id))));return{tokens:i,token_type_ids:a}}},wa=class extends Sa{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},Ta=class extends Sa{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,n=!0){n&&(e=Oi([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=[],a=n?[this.sep[0]]:[];e=Oi(e,i,t,a),r=Oi(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},Ea=class extends Sa{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,n=!0){n&&(e=Oi([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=n?[this.sep[0]]:[],a=n?[this.sep[0]]:[];e=Oi(e,i,t,a),r=Oi(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},Da=class extends Sa{constructor(e){super(e),this.processors=(e.processors??[]).map(e=>ka(e))}post_process(e,t=null,n=!0){let r={tokens:e,tokens_pair:t};for(let e of this.processors)r=e.post_process(r.tokens,r.tokens_pair,n);return r}};function Oa(e){if(e===null)return null;switch(e.type){case`TemplateProcessing`:return new Ca(e);case`ByteLevel`:return new wa(e);case`BertProcessing`:return new Ta(e);case`RobertaProcessing`:return new Ea(e);case`Sequence`:return new Da(e);default:throw Error(`Unknown PostProcessor type: ${e.type}`)}}var ka=Oa,Aa=class extends Pi{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=`trim_offsets`in e?e.trim_offsets:!1}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join(``)}},ja=class extends Aa{constructor(e){super(e),this.byte_decoder=gi,this.text_decoder=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){let t=e.join(``),n=new Uint8Array([...t].map(e=>this.byte_decoder[e]));return this.text_decoder.decode(n)}decode_chain(e){let t=[],n=[];for(let r of e)this.added_tokens.find(e=>e.content===r)===void 0?n.push(r):(n.length>0&&(t.push(this.convert_tokens_to_string(n)),n=[]),t.push(r));return n.length>0&&t.push(this.convert_tokens_to_string(n)),t}},Ma=class extends Aa{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((e,t)=>{if(t!==0){let t=this.config.prefix;e=t&&e.startsWith(t)?e.replace(t,``):` `+e}return this.cleanup&&(e=bi(e)),e})}},Na=class extends Aa{constructor(e){super(e),this.replacement=e.replacement??`▁`}decode_chain(e){let t=[];for(let n=0;n<e.length;++n){let r=e[n].replaceAll(this.replacement,` `);n==0&&r.startsWith(` `)&&(r=r.substring(1)),t.push(r)}return t}},Pa=class extends Aa{constructor(e){super(e),this.suffix=e.suffix??``}decode_chain(e){return e.map((t,n)=>t.replaceAll(this.suffix,n===e.length-1?``:` `))}},Fa=class extends Aa{constructor(e){super(e),this.pad_token=e.pad_token??``,this.word_delimiter_token=e.word_delimiter_token??``,this.cleanup=e.cleanup}convert_tokens_to_string(e){if(e.length===0)return``;let t=[e[0]];for(let n=1;n<e.length;++n)e[n]!==t.at(-1)&&t.push(e[n]);let n=t.filter(e=>e!==this.pad_token).join(``);return this.cleanup&&(n=bi(n).replaceAll(this.word_delimiter_token,` `).trim()),n}decode_chain(e){return[this.convert_tokens_to_string(e)]}},Ia=class extends Aa{constructor(e){super(e),this.decoders=(e.decoders??[]).map(e=>Ha(e))}decode_chain(e){return this.decoders.reduce((e,t)=>t.decode_chain(e),e)}},La=class extends Aa{decode_chain(e){let t=xi(this.config.pattern),n=this.config.content??``;return t===null?e:e.map(e=>e.replaceAll(t,n))}},Ra=class extends Aa{decode_chain(e){return[e.join(``)]}},za=class extends Aa{constructor(e){super(e),this.content=e.content??``,this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(e=>{let t=0;for(let n=0;n<this.start&&e[n]===this.content;++n)t=n+1;let n=e.length;for(let t=0;t<this.stop;++t){let r=e.length-t-1;if(e[r]===this.content){n=r;continue}else break}return e.slice(t,n)})}},Ba=class extends Aa{constructor(e){super(e),this.text_decoder=new TextDecoder}decode_chain(e){let t=[],n=[];for(let r of e){let e=null;if(r.length===6&&r.startsWith(`<0x`)&&r.endsWith(`>`)){let t=parseInt(r.slice(3,5),16);isNaN(t)||(e=t)}if(e!==null)n.push(e);else{if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}t.push(r)}}if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}return t}};function Va(e){if(e===null)return null;switch(e.type){case`ByteLevel`:return new ja(e);case`WordPiece`:return new Ma(e);case`Metaspace`:return new Na(e);case`BPEDecoder`:return new Pa(e);case`CTC`:return new Fa(e);case`Sequence`:return new Ia(e);case`Replace`:return new La(e);case`Fuse`:return new Ra(e);case`Strip`:return new za(e);case`ByteFallback`:return new Ba(e);default:throw Error(`Unknown Decoder type: ${e.type}`)}}var Ha=Va,Ua=class{constructor(e,t){let n=Mi(e,`Tokenizer`,[`model`,`decoder`,`post_processor`,`pre_tokenizer`,`normalizer`]);if(n)throw Error(n);let r=Mi(t,`Config`);if(r)throw Error(r);this.tokenizer=e,this.config=t,this.normalizer=Xi(this.tokenizer.normalizer),this.pre_tokenizer=I(this.tokenizer.pre_tokenizer),this.model=xa(this.tokenizer.model,this.config),this.post_processor=ka(this.tokenizer.post_processor),this.decoder=Ha(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let i=[],a=[];this.added_tokens_map=new Map;for(let e of this.tokenizer.added_tokens){let t=new mi(e);if(this.added_tokens.push(t),this.model.tokens_to_ids.set(t.content,t.id),this.model.vocab[t.id]=t.content,t.special&&(this.special_tokens.push(t.content),this.all_special_ids.push(t.id)),this.added_tokens_map.set(t.content,t),t.normalized&&this.normalizer!==null){let e=this.normalizer(t.content);a.push(e),this.added_tokens_map.set(e,t)}else i.push(t.content)}(this.config.additional_special_tokens??[]).forEach(e=>{this.special_tokens.includes(e)||this.special_tokens.push(e)}),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 pi(i),this.splitter_normalized=new pi(a),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(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{tokens:i,token_type_ids:a}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}),o=i.map(e=>this.added_tokens_map.get(e)?.id??this.model.tokens_to_ids.get(e)??this.model.unk_token_id),s={ids:o,tokens:i,attention_mask:Array(o.length).fill(1)};return r&&a&&(s.token_type_ids=a),s}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!Ti(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);let n=e.map(e=>this.model.vocab[Number(e)]??this.model.unk_token);t.skip_special_tokens&&(n=n.filter(e=>!this.special_tokens.includes(e)));let r=this.decoder?this.decoder(n):n.join(` `);return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix,` `),t.skip_special_tokens&&(r=r.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=bi(r)),r}tokenize(e,{text_pair:t=null,add_special_tokens:n=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}).tokens}encode_text(e){if(e===null)return null;let t=this.splitter_unnormalized.split(e);return t.forEach((e,n)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&n>0&&(t[n-1]=t[n-1].trimEnd()),r.rstrip&&n<t.length-1&&(t[n+1]=t[n+1].trimStart()))}),t.flatMap((e,t)=>{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];if(this.remove_space===!0&&(e=e.trim().split(/\s+/).join(` `)),this.do_lowercase_and_remove_accent&&(e=Di(e)),this.normalizer!==null&&(e=this.normalizer(e)),e.length===0)return[];let n=this.splitter_normalized.split(e);return n.forEach((e,t)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&t>0&&(n[t-1]=n[t-1].trimEnd()),r.rstrip&&t<n.length-1&&(n[t+1]=n[t+1].trimStart()))}),n.flatMap(e=>{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];let n=this.pre_tokenizer===null?[e]:this.pre_tokenizer(e,{section_index:t});return this.model(n)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:n=!0}){let r=this.encode_text(e),i=this.encode_text(t||null);return this.post_processor?this.post_processor(r,i,n):{tokens:Oi(r??[],i??[])}}token_to_id(e){return this.model.tokens_to_ids.get(e)}id_to_token(e){return this.model.vocab[e]}get_added_tokens_decoder(){let e=new Map;for(let t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){let t=new Map;for(let n=0;n<this.model.vocab.length;++n){let r=this.model.vocab[n];(e||!this.added_tokens_map.has(r))&&t.set(r,n)}return t}},L=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`}),Wa=class{constructor(e,t){this.value=e,this.type=t}};function Ga(e){return/\w/.test(e)}function Ka(e){return/[0-9]/.test(e)}function qa(e){return/\s/.test(e)}var Ja=[[`{%`,L.OpenStatement],[`%}`,L.CloseStatement],[`{{`,L.OpenExpression],[`}}`,L.CloseExpression],[`(`,L.OpenParen],[`)`,L.CloseParen],[`{`,L.OpenCurlyBracket],[`}`,L.CloseCurlyBracket],[`[`,L.OpenSquareBracket],[`]`,L.CloseSquareBracket],[`,`,L.Comma],[`.`,L.Dot],[`:`,L.Colon],[`|`,L.Pipe],[`<=`,L.ComparisonBinaryOperator],[`>=`,L.ComparisonBinaryOperator],[`==`,L.ComparisonBinaryOperator],[`!=`,L.ComparisonBinaryOperator],[`<`,L.ComparisonBinaryOperator],[`>`,L.ComparisonBinaryOperator],[`+`,L.AdditiveBinaryOperator],[`-`,L.AdditiveBinaryOperator],[`~`,L.AdditiveBinaryOperator],[`*`,L.MultiplicativeBinaryOperator],[`/`,L.MultiplicativeBinaryOperator],[`%`,L.MultiplicativeBinaryOperator],[`=`,L.Equals]],Ya=new Map([[`n`,`
|
|
5
|
+
`:case`\r`:return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(e)}}clean_text(e){let t=[];for(let n of e){let e=n.charCodeAt(0);e===0||e===65533||this.is_control(n)||(/^\s$/.test(n)?t.push(` `):t.push(n))}return t.join(``)}normalize(e){return this.config.clean_text&&(e=this.clean_text(e)),this.config.handle_chinese_chars&&(e=this.tokenize_chinese_chars(e)),this.config.lowercase?(e=e.toLowerCase(),this.config.strip_accents!==!1&&(e=this.strip_accents(e))):this.config.strip_accents&&(e=this.strip_accents(e)),e}},Li=class extends Fi{constructor(e){super(e),this.charsmap=e.precompiled_charsmap??null}normalize(e){return e=e.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,``),e=e.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm,` `),e=e.includes(`~`)?e.split(`~`).map(e=>e.normalize(`NFKC`)).join(`~`):e.normalize(`NFKC`),e}},Ri=class extends Fi{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(e=>Xi(e))}normalize(e){return this.normalizers.reduce((e,t)=>t?t.normalize(e):e,e)}},zi=class extends Fi{normalize(e){let t=xi(this.config.pattern??{});return t===null?e:e.replaceAll(t,this.config.content??``)}},Bi=class extends Fi{constructor(){super(...arguments),this.form=`NFC`}normalize(e){return e=e.normalize(this.form),e}},Vi=class extends Bi{constructor(){super(...arguments),this.form=`NFC`}},Hi=class extends Bi{constructor(){super(...arguments),this.form=`NFD`}},Ui=class extends Bi{constructor(){super(...arguments),this.form=`NFKC`}},Wi=class extends Bi{constructor(){super(...arguments),this.form=`NFKD`}},Gi=class extends Fi{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}},Ki=class extends Fi{normalize(e){return ji(e)}},qi=class extends Fi{normalize(e){return e.toLowerCase()}},Ji=class extends Fi{normalize(e){return e=this.config.prepend+e,e}};function Yi(e){if(e===null)return null;switch(e.type){case`BertNormalizer`:return new Ii(e);case`Precompiled`:return new Li(e);case`Sequence`:return new Ri(e);case`Replace`:return new zi(e);case`NFC`:return new Vi(e);case`NFD`:return new Hi(e);case`NFKC`:return new Ui(e);case`NFKD`:return new Wi(e);case`Strip`:return new Gi(e);case`StripAccents`:return new Ki(e);case`Lowercase`:return new qi(e);case`Prepend`:return new Ji(e);default:throw Error(`Unknown Normalizer type: ${e.type}`)}}var Xi=Yi,Zi=class extends Pi{pre_tokenize(e,t){return(Array.isArray(e)?e.map(e=>this.pre_tokenize_text(e,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},Qi=class extends Zi{constructor(e){super(),this.config=e,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=hi,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){return this.add_prefix_space&&!e.startsWith(` `)&&(e=` `+e),(this.use_regex?e.match(this.pattern)||[]:[e]).map(e=>Array.from(this.text_encoder.encode(e),e=>this.byte_encoder[e]).join(``))}},$i=class extends Zi{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},ea=class extends Zi{constructor(e){super(),this.replacement=e.replacement??`▁`,this.str_rep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??`always`}pre_tokenize_text(e,t){let{section_index:n=void 0}=t??{},r=e.replaceAll(` `,this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme===`always`||this.prepend_scheme===`first`&&n===0)&&(r=this.str_rep+r),[r]}},ta=class extends Zi{constructor(e){super(),this.config=e,this.pattern=xi(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?e.match(this.pattern)||[]:this.config.behavior?.toLowerCase()===`removed`?e.split(this.pattern).filter(e=>e):Ai(e,this.pattern)}},na=class extends Zi{constructor(e){super(),this.config=e,this.pattern=RegExp(`[^${yi}]+|[${yi}]+`,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},ra=class extends Zi{constructor(e){super(),this.config=e;let t=`[^\\d]+|\\d${this.config.individual_digits?``:`+`}`;this.pattern=new RegExp(t,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},ia=class extends Zi{constructor(){super(),this.pattern=RegExp(`[^\\s${yi}]+|[${yi}]`,`gu`)}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},P=class extends Zi{constructor(e){super(),this.config=e,this.pattern=xi(this.config.pattern??{}),this.content=this.config.content??``}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??``)]}},aa=class extends Zi{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(e=>I(e))}pre_tokenize_text(e,t){return this.tokenizers.reduce((e,n)=>n?n.pre_tokenize(e,t):e,[e])}},oa=class extends Zi{pre_tokenize_text(e){return Ni(e)}},F=class extends Zi{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){let t=[];for(let n=0;n<e.length;n+=this._length)t.push(e.slice(n,n+this._length));return t}};function sa(e){if(e===null)return null;switch(e.type){case`BertPreTokenizer`:return new ia;case`Sequence`:return new aa(e);case`Whitespace`:return new $i;case`WhitespaceSplit`:return new oa;case`Metaspace`:return new ea(e);case`ByteLevel`:return new Qi(e);case`Split`:return new ta(e);case`Punctuation`:return new na(e);case`Digits`:return new ra(e);case`Replace`:return new P(e);case`FixedLength`:return new F(e);default:throw Error(`Unknown PreTokenizer type: ${e.type}`)}}var I=sa,ca=class extends Pi{constructor(e){super(),this.config=e,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(e){let t=this.encode(e);return this.fuse_unk&&(t=Ci(t,this.tokens_to_ids,this.unk_token_id)),t}},la=class extends ca{constructor(e){super(e),this.max_input_chars_per_word=100,this.tokens_to_ids=ki(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.max_input_chars_per_word=e.max_input_chars_per_word??100,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){let t=[];for(let n of e){let e=[...n];if(e.length>this.max_input_chars_per_word){t.push(this.unk_token);continue}let r=!1,i=0,a=[];for(;i<e.length;){let t=e.length,n=null;for(;i<t;){let r=e.slice(i,t).join(``);if(i>0&&(r=this.config.continuing_subword_prefix+r),this.tokens_to_ids.has(r)){n=r;break}--t}if(n===null){r=!0;break}a.push(n),i=t}r?t.push(this.unk_token):t.push(...a)}return t}},ua=class e{constructor(e,t){this.is_leaf=e,this.children=t}static default(){return new e(!1,new Map)}},da=class{constructor(){this.root=ua.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let n of e){let e=t.children.get(n);e===void 0&&(e=ua.default(),t.children.set(n,e)),t=e}t.is_leaf=!0}*common_prefix_search(e){let t=this.root;if(t===void 0)return;let n=``;for(let r of e){if(n+=r,t=t.children.get(r),t===void 0)return;t.is_leaf&&(yield n)}}},fa=class e{constructor(e,t,n,r,i){this.token_id=e,this.node_id=t,this.pos=n,this.length=r,this.score=i,this.prev=null,this.backtrace_score=0}clone(){let t=new e(this.token_id,this.node_id,this.pos,this.length,this.score);return t.prev=this.prev,t.backtrace_score=this.backtrace_score,t}},pa=class{constructor(e,t,n){this.chars=Array.from(e),this.len=this.chars.length,this.bos_token_id=t,this.eos_token_id=n,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new fa(this.bos_token_id??0,0,0,0,0),i=new fa(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(i.clone()),this.begin_nodes[this.len].push(i),this.end_nodes[0].push(r)}insert(e,t,n,r){let i=this.nodes.length,a=new fa(r,i,e,t,n);this.begin_nodes[e].push(a),this.end_nodes[e+t].push(a),this.nodes.push(a)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let e of this.begin_nodes[t]){e.prev=null;let n=0,r=null;for(let i of this.end_nodes[t]){let t=i.backtrace_score+e.score;(r===null||t>n)&&(r=i.clone(),n=t)}if(r!==null)e.prev=r,e.backtrace_score=n;else return[]}++t}let n=[],r=this.begin_nodes[e][0].prev;if(r===null)return[];let i=r.clone();for(;i.prev!==null;)n.push(i.clone()),i=i.clone().prev.clone();return n.reverse(),n}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join(``)}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}};function ma(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]<t&&(t=e[r],n=r);return[t,n]}var ha=class extends ca{constructor(e,t){super(e);let n=e.vocab.length;this.vocab=Array(n),this.scores=Array(n);for(let t=0;t<n;++t)[this.vocab[t],this.scores[t]]=e.vocab[t];this.unk_token_id=e.unk_id,this.unk_token=this.vocab[e.unk_id],this.tokens_to_ids=new Map(this.vocab.map((e,t)=>[e,t])),this.bos_token=` `,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=ma(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new da,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){let t=e.chars,n=0;for(;n<t.length;){let r=!1,i=[],a=t.slice(n).join(``),o=this.trie.common_prefix_search(a);for(let t of o){i.push(t);let a=this.tokens_to_ids.get(t),o=this.scores[a],s=Ei(t);e.insert(n,s,o,a),!r&&s===1&&(r=!0)}r||e.insert(n,1,this.unk_score,this.unk_token_id),n+=1}}tokenize(e){let t=new pa(e,this.bos_token_id,this.eos_token_id);return this.populate_nodes(t),t.tokens()}encode(e){let t=[];for(let n of e){let e=this.tokenize(n);t.push(...e)}return t}},ga=class{constructor(e=(e,t)=>e>t,t=1/0){this._heap=[],this._comparator=e,this._max_size=t}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)if(this.size<this._max_size)this._heap.push(t),this._sift_up();else{let e=this._smallest();this._comparator(t,this._heap[e])&&(this._heap[e]=t,this._sift_up_from(e))}return this.size}pop(){let e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._sift_down(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let n=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=n}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_sift_down(){let e=0;for(;this._left(e)<this.size&&this._greater(this._left(e),e)||this._right(e)<this.size&&this._greater(this._right(e),e);){let t=this._right(e)<this.size&&this._greater(this._right(e),this._left(e))?this._right(e):this._left(e);this._swap(e,t),e=t}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},_a=class{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)&&this.cache.delete(e),this.cache.set(e,t),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},va=class extends ca{constructor(e){super(e),this.tokens_to_ids=ki(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e;let t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(e=>e.split(` `,2)),this.bpe_ranks=new Map(this.merges.map((e,t)=>[JSON.stringify(e),t])),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.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 _a(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];let t=this.cache.get(e);if(t!==void 0)return t;let n=Array.from(e);this.end_of_word_suffix&&(n[n.length-1]+=this.end_of_word_suffix);let r=[];if(n.length>1){let e=new ga((e,t)=>e.score<t.score),t={token:n[0],bias:0,prev:null,next:null},i=t;for(let t=1;t<n.length;++t){let r={bias:t/n.length,token:n[t],prev:i,next:null};i.next=r,this.add_node(e,i),i=r}for(;!e.is_empty();){let n=e.pop();if(n.deleted||!n.next||n.next.deleted)continue;if(n.deleted=!0,n.next.deleted=!0,n.prev){let e={...n.prev};n.prev.deleted=!0,n.prev=e,e.prev?e.prev.next=e:t=e}let r={token:n.token+n.next.token,bias:n.bias,prev:n.prev,next:n.next.next};r.prev?(r.prev.next=r,this.add_node(e,r.prev)):t=r,r.next&&(r.next.prev=r,this.add_node(e,r))}for(let e=t;e!==null;e=e.next)r.push(e.token)}else r=n;if(this.continuing_subword_suffix)for(let e=0;e<r.length-1;++e)r[e]+=this.continuing_subword_suffix;return e.length<this.max_length_to_cache&&this.cache.put(e,r),r}add_node(e,t){let n=this.bpe_ranks.get(JSON.stringify([t.token,t.next.token]));n!==void 0&&(t.score=n+t.bias,e.push(t))}encode(e){let t=[];for(let n of e){if(this.ignore_merges&&this.tokens_to_ids.has(n)){t.push(n);continue}let e=this.bpe(n);for(let n of e)if(this.tokens_to_ids.has(n))t.push(n);else if(this.byte_fallback){let e=Array.from(this.text_encoder.encode(n)).map(e=>`<0x${e.toString(16).toUpperCase().padStart(2,`0`)}>`);e.every(e=>this.tokens_to_ids.has(e))?t.push(...e):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},ya=class extends ca{constructor(e,t){super(e);let n=e.vocab;this.tokens_to_ids=ki(t.target_lang?n[t.target_lang]:n),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){return e}};function ba(e,t){switch(e.type){case`WordPiece`:return new la(e);case`Unigram`:return new ha(e,t.eos_token);case`BPE`:return new va(e);default:if(e.vocab)return Array.isArray(e.vocab)?new ha(e,t.eos_token):Object.hasOwn(e,`continuing_subword_prefix`)&&Object.hasOwn(e,`unk_token`)?Object.hasOwn(e,`merges`)?new va(e):new la(e):new ya(e,{target_lang:t.target_lang,bos_token:t.bos_token,eos_token:t.eos_token,pad_token:t.pad_token,unk_token:t.unk_token});throw Error(`Unknown TokenizerModel type: ${e?.type}`)}}var xa=ba,Sa=class extends Pi{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},Ca=class extends Sa{post_process(e,t=null,n=!0){let r=t===null?this.config.single:this.config.pair,i=[],a=[];for(let o of r)`SpecialToken`in o?n&&(i.push(o.SpecialToken.id),a.push(o.SpecialToken.type_id)):`Sequence`in o&&(o.Sequence.id===`A`?(i=Oi(i,e),a=Oi(a,Array(e.length).fill(o.Sequence.type_id))):o.Sequence.id===`B`&&(i=Oi(i,t),a=Oi(a,Array(t.length).fill(o.Sequence.type_id))));return{tokens:i,token_type_ids:a}}},wa=class extends Sa{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},Ta=class extends Sa{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,n=!0){n&&(e=Oi([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=[],a=n?[this.sep[0]]:[];e=Oi(e,i,t,a),r=Oi(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},Ea=class extends Sa{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,n=!0){n&&(e=Oi([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=n?[this.sep[0]]:[],a=n?[this.sep[0]]:[];e=Oi(e,i,t,a),r=Oi(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},Da=class extends Sa{constructor(e){super(e),this.processors=(e.processors??[]).map(e=>ka(e))}post_process(e,t=null,n=!0){let r={tokens:e,tokens_pair:t};for(let e of this.processors)r=e.post_process(r.tokens,r.tokens_pair,n);return r}};function Oa(e){if(e===null)return null;switch(e.type){case`TemplateProcessing`:return new Ca(e);case`ByteLevel`:return new wa(e);case`BertProcessing`:return new Ta(e);case`RobertaProcessing`:return new Ea(e);case`Sequence`:return new Da(e);default:throw Error(`Unknown PostProcessor type: ${e.type}`)}}var ka=Oa,Aa=class extends Pi{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=`trim_offsets`in e&&e.trim_offsets}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join(``)}},ja=class extends Aa{constructor(e){super(e),this.byte_decoder=gi,this.text_decoder=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){let t=e.join(``),n=new Uint8Array([...t].map(e=>this.byte_decoder[e]));return this.text_decoder.decode(n)}decode_chain(e){let t=[],n=[];for(let r of e)this.added_tokens.find(e=>e.content===r)===void 0?n.push(r):(n.length>0&&(t.push(this.convert_tokens_to_string(n)),n=[]),t.push(r));return n.length>0&&t.push(this.convert_tokens_to_string(n)),t}},Ma=class extends Aa{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((e,t)=>{if(t!==0){let t=this.config.prefix;e=t&&e.startsWith(t)?e.replace(t,``):` `+e}return this.cleanup&&(e=bi(e)),e})}},Na=class extends Aa{constructor(e){super(e),this.replacement=e.replacement??`▁`}decode_chain(e){let t=[];for(let n=0;n<e.length;++n){let r=e[n].replaceAll(this.replacement,` `);n==0&&r.startsWith(` `)&&(r=r.substring(1)),t.push(r)}return t}},Pa=class extends Aa{constructor(e){super(e),this.suffix=e.suffix??``}decode_chain(e){return e.map((t,n)=>t.replaceAll(this.suffix,n===e.length-1?``:` `))}},Fa=class extends Aa{constructor(e){super(e),this.pad_token=e.pad_token??``,this.word_delimiter_token=e.word_delimiter_token??``,this.cleanup=e.cleanup}convert_tokens_to_string(e){if(e.length===0)return``;let t=[e[0]];for(let n=1;n<e.length;++n)e[n]!==t.at(-1)&&t.push(e[n]);let n=t.filter(e=>e!==this.pad_token).join(``);return this.cleanup&&(n=bi(n).replaceAll(this.word_delimiter_token,` `).trim()),n}decode_chain(e){return[this.convert_tokens_to_string(e)]}},Ia=class extends Aa{constructor(e){super(e),this.decoders=(e.decoders??[]).map(e=>Ha(e))}decode_chain(e){return this.decoders.reduce((e,t)=>t.decode_chain(e),e)}},La=class extends Aa{decode_chain(e){let t=xi(this.config.pattern),n=this.config.content??``;return t===null?e:e.map(e=>e.replaceAll(t,n))}},Ra=class extends Aa{decode_chain(e){return[e.join(``)]}},za=class extends Aa{constructor(e){super(e),this.content=e.content??``,this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(e=>{let t=0;for(let n=0;n<this.start&&e[n]===this.content;++n)t=n+1;let n=e.length;for(let t=0;t<this.stop;++t){let r=e.length-t-1;if(e[r]===this.content){n=r;continue}else break}return e.slice(t,n)})}},Ba=class extends Aa{constructor(e){super(e),this.text_decoder=new TextDecoder}decode_chain(e){let t=[],n=[];for(let r of e){let e=null;if(r.length===6&&r.startsWith(`<0x`)&&r.endsWith(`>`)){let t=parseInt(r.slice(3,5),16);isNaN(t)||(e=t)}if(e!==null)n.push(e);else{if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}t.push(r)}}if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}return t}};function Va(e){if(e===null)return null;switch(e.type){case`ByteLevel`:return new ja(e);case`WordPiece`:return new Ma(e);case`Metaspace`:return new Na(e);case`BPEDecoder`:return new Pa(e);case`CTC`:return new Fa(e);case`Sequence`:return new Ia(e);case`Replace`:return new La(e);case`Fuse`:return new Ra(e);case`Strip`:return new za(e);case`ByteFallback`:return new Ba(e);default:throw Error(`Unknown Decoder type: ${e.type}`)}}var Ha=Va,Ua=class{constructor(e,t){let n=Mi(e,`Tokenizer`,[`model`,`decoder`,`post_processor`,`pre_tokenizer`,`normalizer`]);if(n)throw Error(n);let r=Mi(t,`Config`);if(r)throw Error(r);this.tokenizer=e,this.config=t,this.normalizer=Xi(this.tokenizer.normalizer),this.pre_tokenizer=I(this.tokenizer.pre_tokenizer),this.model=xa(this.tokenizer.model,this.config),this.post_processor=ka(this.tokenizer.post_processor),this.decoder=Ha(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let i=[],a=[];this.added_tokens_map=new Map;for(let e of this.tokenizer.added_tokens){let t=new mi(e);if(this.added_tokens.push(t),this.model.tokens_to_ids.set(t.content,t.id),this.model.vocab[t.id]=t.content,t.special&&(this.special_tokens.push(t.content),this.all_special_ids.push(t.id)),this.added_tokens_map.set(t.content,t),t.normalized&&this.normalizer!==null){let e=this.normalizer(t.content);a.push(e),this.added_tokens_map.set(e,t)}else i.push(t.content)}(this.config.additional_special_tokens??[]).forEach(e=>{this.special_tokens.includes(e)||this.special_tokens.push(e)}),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 pi(i),this.splitter_normalized=new pi(a),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(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{tokens:i,token_type_ids:a}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}),o=i.map(e=>this.added_tokens_map.get(e)?.id??this.model.tokens_to_ids.get(e)??this.model.unk_token_id),s={ids:o,tokens:i,attention_mask:Array(o.length).fill(1)};return r&&a&&(s.token_type_ids=a),s}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!Ti(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);let n=e.map(e=>this.model.vocab[Number(e)]??this.model.unk_token);t.skip_special_tokens&&(n=n.filter(e=>!this.special_tokens.includes(e)));let r=this.decoder?this.decoder(n):n.join(` `);return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix,` `),t.skip_special_tokens&&(r=r.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=bi(r)),r}tokenize(e,{text_pair:t=null,add_special_tokens:n=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}).tokens}encode_text(e){if(e===null)return null;let t=this.splitter_unnormalized.split(e);return t.forEach((e,n)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&n>0&&(t[n-1]=t[n-1].trimEnd()),r.rstrip&&n<t.length-1&&(t[n+1]=t[n+1].trimStart()))}),t.flatMap((e,t)=>{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];if(this.remove_space===!0&&(e=e.trim().split(/\s+/).join(` `)),this.do_lowercase_and_remove_accent&&(e=Di(e)),this.normalizer!==null&&(e=this.normalizer(e)),e.length===0)return[];let n=this.splitter_normalized.split(e);return n.forEach((e,t)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&t>0&&(n[t-1]=n[t-1].trimEnd()),r.rstrip&&t<n.length-1&&(n[t+1]=n[t+1].trimStart()))}),n.flatMap(e=>{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];let n=this.pre_tokenizer===null?[e]:this.pre_tokenizer(e,{section_index:t});return this.model(n)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:n=!0}){let r=this.encode_text(e),i=this.encode_text(t||null);return this.post_processor?this.post_processor(r,i,n):{tokens:Oi(r??[],i??[])}}token_to_id(e){return this.model.tokens_to_ids.get(e)}id_to_token(e){return this.model.vocab[e]}get_added_tokens_decoder(){let e=new Map;for(let t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){let t=new Map;for(let n=0;n<this.model.vocab.length;++n){let r=this.model.vocab[n];(e||!this.added_tokens_map.has(r))&&t.set(r,n)}return t}},L=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`}),Wa=class{constructor(e,t){this.value=e,this.type=t}};function Ga(e){return/\w/.test(e)}function Ka(e){return/[0-9]/.test(e)}function qa(e){return/\s/.test(e)}var Ja=[[`{%`,L.OpenStatement],[`%}`,L.CloseStatement],[`{{`,L.OpenExpression],[`}}`,L.CloseExpression],[`(`,L.OpenParen],[`)`,L.CloseParen],[`{`,L.OpenCurlyBracket],[`}`,L.CloseCurlyBracket],[`[`,L.OpenSquareBracket],[`]`,L.CloseSquareBracket],[`,`,L.Comma],[`.`,L.Dot],[`:`,L.Colon],[`|`,L.Pipe],[`<=`,L.ComparisonBinaryOperator],[`>=`,L.ComparisonBinaryOperator],[`==`,L.ComparisonBinaryOperator],[`!=`,L.ComparisonBinaryOperator],[`<`,L.ComparisonBinaryOperator],[`>`,L.ComparisonBinaryOperator],[`+`,L.AdditiveBinaryOperator],[`-`,L.AdditiveBinaryOperator],[`~`,L.AdditiveBinaryOperator],[`*`,L.MultiplicativeBinaryOperator],[`/`,L.MultiplicativeBinaryOperator],[`%`,L.MultiplicativeBinaryOperator],[`=`,L.Equals]],Ya=new Map([[`n`,`
|
|
6
6
|
`],[`t`,` `],[`r`,`\r`],[`b`,`\b`],[`f`,`\f`],[`v`,`\v`],[`'`,`'`],[`"`,`"`],[`\\`,`\\`]]);function Xa(e,t={}){return e.endsWith(`
|
|
7
7
|
`)&&(e=e.slice(0,-1)),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%-])/gm,`$1`)),t.trim_blocks&&(e=e.replace(/([#%-]})\n/g,`$1`)),e.replace(/{%\s*(end)?generation\s*%}/gs,``)}function Za(e,t={}){let n=[],r=Xa(e,t),i=0,a=0,o=e=>{let t=``;for(;e(r[i]);){if(r[i]===`\\`){if(++i,i>=r.length)throw SyntaxError(`Unexpected end of input`);let e=r[i++],n=Ya.get(e);if(n===void 0)throw SyntaxError(`Unexpected escaped character: ${e}`);t+=n;continue}if(t+=r[i++],i>=r.length)throw SyntaxError(`Unexpected end of input`)}return t},s=()=>{let e=n.at(-1);e&&e.type===L.Text&&(e.value=e.value.trimEnd(),e.value===``&&n.pop())},c=()=>{for(;i<r.length&&qa(r[i]);)++i};main:for(;i<r.length;){let e=n.at(-1)?.type;if(e===void 0||e===L.CloseStatement||e===L.CloseExpression||e===L.Comment){let e=``;for(;i<r.length&&!(r[i]===`{`&&(r[i+1]===`%`||r[i+1]===`{`||r[i+1]===`#`));)e+=r[i++];if(e.length>0){n.push(new Wa(e,L.Text));continue}}if(r[i]===`{`&&r[i+1]===`#`){i+=2;let e=r[i]===`-`;e&&++i;let t=``;for(;r[i]!==`#`||r[i+1]!==`}`;){if(i+2>=r.length)throw SyntaxError(`Missing end of comment tag`);t+=r[i++]}let a=t.endsWith(`-`);a&&(t=t.slice(0,-1)),e&&s(),n.push(new Wa(t,L.Comment)),i+=2,a&&c();continue}if(r.slice(i,i+3)===`{%-`){s(),n.push(new Wa(`{%`,L.OpenStatement)),i+=3;continue}if(r.slice(i,i+3)===`{{-`){s(),n.push(new Wa(`{{`,L.OpenExpression)),a=0,i+=3;continue}if(o(qa),r.slice(i,i+3)===`-%}`){n.push(new Wa(`%}`,L.CloseStatement)),i+=3,c();continue}if(r.slice(i,i+3)===`-}}`){n.push(new Wa(`}}`,L.CloseExpression)),i+=3,c();continue}let t=r[i];if(t===`-`||t===`+`){let e=n.at(-1)?.type;if(e===L.Text||e===void 0)throw SyntaxError(`Unexpected character: ${t}`);switch(e){case L.Identifier:case L.NumericLiteral:case L.StringLiteral:case L.CloseParen:case L.CloseSquareBracket:break;default:{++i;let e=o(Ka);n.push(new Wa(`${t}${e}`,e.length>0?L.NumericLiteral:L.UnaryOperator));continue}}}for(let[e,t]of Ja)if(!(e===`}}`&&a>0)&&r.slice(i,i+e.length)===e){n.push(new Wa(e,t)),t===L.OpenExpression?a=0:t===L.OpenCurlyBracket?++a:t===L.CloseCurlyBracket&&--a,i+=e.length;continue main}if(t===`'`||t===`"`){++i;let e=o(e=>e!==t);n.push(new Wa(e,L.StringLiteral)),++i;continue}if(Ka(t)){let e=o(Ka);if(r[i]===`.`&&Ka(r[i+1])){++i;let t=o(Ka);e=`${e}.${t}`}n.push(new Wa(e,L.NumericLiteral));continue}if(Ga(t)){let e=o(Ga);n.push(new Wa(e,L.Identifier));continue}throw SyntaxError(`Unexpected character: ${t}`)}return n}var Qa=class{type=`Statement`},$a=class extends Qa{constructor(e){super(),this.body=e}type=`Program`},eo=class extends Qa{constructor(e,t,n){super(),this.test=e,this.body=t,this.alternate=n}type=`If`},to=class extends Qa{constructor(e,t,n,r){super(),this.loopvar=e,this.iterable=t,this.body=n,this.defaultBlock=r}type=`For`},no=class extends Qa{type=`Break`},ro=class extends Qa{type=`Continue`},io=class extends Qa{constructor(e,t,n){super(),this.assignee=e,this.value=t,this.body=n}type=`Set`},ao=class extends Qa{constructor(e,t,n){super(),this.name=e,this.args=t,this.body=n}type=`Macro`},oo=class extends Qa{constructor(e){super(),this.value=e}type=`Comment`},so=class extends Qa{type=`Expression`},co=class extends so{constructor(e,t,n){super(),this.object=e,this.property=t,this.computed=n}type=`MemberExpression`},lo=class extends so{constructor(e,t){super(),this.callee=e,this.args=t}type=`CallExpression`},uo=class extends so{constructor(e){super(),this.value=e}type=`Identifier`},fo=class extends so{constructor(e){super(),this.value=e}type=`Literal`},po=class extends fo{type=`IntegerLiteral`},mo=class extends fo{type=`FloatLiteral`},ho=class extends fo{type=`StringLiteral`},go=class extends fo{type=`ArrayLiteral`},_o=class extends fo{type=`TupleLiteral`},vo=class extends fo{type=`ObjectLiteral`},yo=class extends so{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}type=`BinaryExpression`},bo=class extends so{constructor(e,t){super(),this.operand=e,this.filter=t}type=`FilterExpression`},xo=class extends Qa{constructor(e,t){super(),this.filter=e,this.body=t}type=`FilterStatement`},So=class extends so{constructor(e,t){super(),this.lhs=e,this.test=t}type=`SelectExpression`},Co=class extends so{constructor(e,t,n){super(),this.operand=e,this.negate=t,this.test=n}type=`TestExpression`},wo=class extends so{constructor(e,t){super(),this.operator=e,this.argument=t}type=`UnaryExpression`},To=class extends so{constructor(e=void 0,t=void 0,n=void 0){super(),this.start=e,this.stop=t,this.step=n}type=`SliceExpression`},Eo=class extends so{constructor(e,t){super(),this.key=e,this.value=t}type=`KeywordArgumentExpression`},Do=class extends so{constructor(e){super(),this.argument=e}type=`SpreadExpression`},Oo=class extends Qa{constructor(e,t,n){super(),this.call=e,this.callerArgs=t,this.body=n}type=`CallStatement`},ko=class extends so{constructor(e,t,n){super(),this.condition=e,this.trueExpr=t,this.falseExpr=n}type=`Ternary`};function Ao(e){let t=new $a([]),n=0;function r(t,r){let i=e[n++];if(!i||i.type!==t)throw Error(`Parser Error: ${r}. ${i.type} !== ${t}.`);return i}function i(e){if(!c(e))throw SyntaxError(`Expected ${e}`);++n}function a(){switch(e[n].type){case L.Comment:return new oo(e[n++].value);case L.Text:return l();case L.OpenStatement:return u();case L.OpenExpression:return d();default:throw SyntaxError(`Unexpected token type: ${e[n].type}`)}}function o(...t){return n+t.length<=e.length&&t.every((t,r)=>t===e[n+r].type)}function s(...t){return e[n]?.type===L.OpenStatement&&e[n+1]?.type===L.Identifier&&t.includes(e[n+1]?.value)}function c(...t){return n+t.length<=e.length&&t.every((t,r)=>e[n+r].type===`Identifier`&&t===e[n+r].value)}function l(){return new ho(r(L.Text,`Expected text token`).value)}function u(){if(r(L.OpenStatement,`Expected opening statement token`),e[n].type!==L.Identifier)throw SyntaxError(`Unknown statement, got ${e[n].type}`);let t=e[n].value,c;switch(t){case`set`:++n,c=f();break;case`if`:++n,c=p(),r(L.OpenStatement,`Expected {% token`),i(`endif`),r(L.CloseStatement,`Expected %} token`);break;case`macro`:++n,c=m(),r(L.OpenStatement,`Expected {% token`),i(`endmacro`),r(L.CloseStatement,`Expected %} token`);break;case`for`:++n,c=g(),r(L.OpenStatement,`Expected {% token`),i(`endfor`),r(L.CloseStatement,`Expected %} token`);break;case`call`:{++n;let e=null;o(L.OpenParen)&&(e=w());let t=oe();if(t.type!==`Identifier`)throw SyntaxError(`Expected identifier following call statement`);let l=w();r(L.CloseStatement,`Expected closing statement token`);let u=[];for(;!s(`endcall`);)u.push(a());r(L.OpenStatement,`Expected '{%'`),i(`endcall`),r(L.CloseStatement,`Expected closing statement token`),c=new Oo(new lo(t,l),e,u);break}case`break`:++n,r(L.CloseStatement,`Expected closing statement token`),c=new no;break;case`continue`:++n,r(L.CloseStatement,`Expected closing statement token`),c=new ro;break;case`filter`:{++n;let e=oe();e instanceof uo&&o(L.OpenParen)&&(e=C(e)),r(L.CloseStatement,`Expected closing statement token`);let t=[];for(;!s(`endfilter`);)t.push(a());r(L.OpenStatement,`Expected '{%'`),i(`endfilter`),r(L.CloseStatement,`Expected '%}'`),c=new xo(e,t);break}default:throw SyntaxError(`Unknown statement type: ${t}`)}return c}function d(){r(L.OpenExpression,`Expected opening expression token`);let e=_();return r(L.CloseExpression,`Expected closing expression token`),e}function f(){let e=h(),t=null,c=[];if(o(L.Equals))++n,t=h();else{for(r(L.CloseStatement,`Expected %} token`);!s(`endset`);)c.push(a());r(L.OpenStatement,`Expected {% token`),i(`endset`)}return r(L.CloseStatement,`Expected closing statement token`),new io(e,t,c)}function p(){let e=_();r(L.CloseStatement,`Expected closing statement token`);let t=[],i=[];for(;!s(`elif`,`else`,`endif`);)t.push(a());if(s(`elif`)){++n,++n;let e=p();i.push(e)}else if(s(`else`))for(++n,++n,r(L.CloseStatement,`Expected closing statement token`);!s(`endif`);)i.push(a());return new eo(e,t,i)}function m(){let e=oe();if(e.type!==`Identifier`)throw SyntaxError(`Expected identifier following macro statement`);let t=w();r(L.CloseStatement,`Expected closing statement token`);let n=[];for(;!s(`endmacro`);)n.push(a());return new ao(e,t,n)}function h(e=!1){let t=e?oe:_,r=[t()],i=o(L.Comma);for(;i&&(++n,r.push(t()),o(L.Comma)););return i?new _o(r):r[0]}function g(){let e=h(!0);if(!(e instanceof uo||e instanceof _o))throw SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);if(!c(`in`))throw SyntaxError("Expected `in` keyword following loop variable");++n;let t=_();r(L.CloseStatement,`Expected closing statement token`);let i=[];for(;!s(`endfor`,`else`);)i.push(a());let o=[];if(s(`else`))for(++n,++n,r(L.CloseStatement,`Expected closing statement token`);!s(`endfor`);)o.push(a());return new to(e,t,i,o)}function _(){return v()}function v(){let e=y();if(c(`if`)){++n;let t=y();return c(`else`)?(++n,new ko(t,e,v())):new So(e,t)}return e}function y(){let t=b();for(;c(`or`);){let r=e[n];++n;let i=b();t=new yo(r,t,i)}return t}function b(){let t=x();for(;c(`and`);){let r=e[n];++n;let i=x();t=new yo(r,t,i)}return t}function x(){let t;for(;c(`not`);){let r=e[n];++n,t=new wo(r,x())}return t??ee()}function ee(){let t=S();for(;;){let r;if(c(`not`,`in`))r=new Wa(`not in`,L.Identifier),n+=2;else if(c(`in`))r=e[n++];else if(o(L.ComparisonBinaryOperator))r=e[n++];else break;let i=S();t=new yo(r,t,i)}return t}function S(){let t=E();for(;o(L.AdditiveBinaryOperator);){let r=e[n];++n;let i=E();t=new yo(r,t,i)}return t}function te(){let e=T(oe());return o(L.OpenParen)?C(e):e}function C(e){let t=new lo(e,w());return t=T(t),o(L.OpenParen)&&(t=C(t)),t}function w(){r(L.OpenParen,`Expected opening parenthesis for arguments list`);let e=ne();return r(L.CloseParen,`Expected closing parenthesis for arguments list`),e}function ne(){let t=[];for(;!o(L.CloseParen);){let r;if(e[n].type===L.MultiplicativeBinaryOperator&&e[n].value===`*`)++n,r=new Do(_());else if(r=_(),o(L.Equals)){if(++n,!(r instanceof uo))throw SyntaxError(`Expected identifier for keyword argument`);let e=_();r=new Eo(r,e)}t.push(r),o(L.Comma)&&++n}return t}function re(){let e=[],t=!1;for(;!o(L.CloseSquareBracket);)o(L.Colon)?(e.push(void 0),++n,t=!0):(e.push(_()),o(L.Colon)&&(++n,t=!0));if(e.length===0)throw SyntaxError(`Expected at least one argument for member/slice expression`);if(t){if(e.length>3)throw SyntaxError(`Expected 0-3 arguments for slice expression`);return new To(...e)}return e[0]}function T(t){for(;o(L.Dot)||o(L.OpenSquareBracket);){let i=e[n];++n;let a,o=i.type===L.OpenSquareBracket;if(o)a=re(),r(L.CloseSquareBracket,`Expected closing square bracket`);else if(a=oe(),a.type!==`Identifier`)throw SyntaxError(`Expected identifier following dot operator`);t=new co(t,a,o)}return t}function E(){let t=ie();for(;o(L.MultiplicativeBinaryOperator);){let r=e[n++],i=ie();t=new yo(r,t,i)}return t}function ie(){let e=ae();for(;c(`is`);){++n;let t=c(`not`);t&&++n;let r=oe();if(!(r instanceof uo))throw SyntaxError(`Expected identifier for the test`);e=new Co(e,t,r)}return e}function ae(){let e=te();for(;o(L.Pipe);){++n;let t=oe();if(!(t instanceof uo))throw SyntaxError(`Expected identifier for the filter`);o(L.OpenParen)&&(t=C(t)),e=new bo(e,t)}return e}function oe(){let t=e[n++];switch(t.type){case L.NumericLiteral:{let e=t.value;return e.includes(`.`)?new mo(Number(e)):new po(Number(e))}case L.StringLiteral:{let r=t.value;for(;o(L.StringLiteral);)r+=e[n++].value;return new ho(r)}case L.Identifier:return new uo(t.value);case L.OpenParen:{let e=h();return r(L.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),e}case L.OpenSquareBracket:{let e=[];for(;!o(L.CloseSquareBracket);)e.push(_()),o(L.Comma)&&++n;return++n,new go(e)}case L.OpenCurlyBracket:{let e=new Map;for(;!o(L.CloseCurlyBracket);){let t=_();r(L.Colon,`Expected colon between key and value in object literal`);let i=_();e.set(t,i),o(L.Comma)&&++n}return++n,new vo(e)}default:throw SyntaxError(`Unexpected token: ${t.type}`)}}for(;n<e.length;)t.body.push(a());return t}function jo(e,t,n=1){if(t===void 0&&(t=e,e=0),n===0)throw Error(`range() step must not be zero`);let r=[];if(n>0)for(let i=e;i<t;i+=n)r.push(i);else for(let i=e;i>t;i+=n)r.push(i);return r}function Mo(e,t,n,r=1){let i=Math.sign(r);i>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),n=(n??=e.length)<0?Math.max(e.length+n,0):Math.min(n,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),n=(n??=-1)<-1?Math.max(e.length+n,-1):Math.min(n,e.length-1));let a=[];for(let o=t;i*o<i*n;o+=r)a.push(e[o]);return a}function No(e){return e.replace(/\b\w/g,e=>e.toUpperCase())}function Po(e){return Fo(new Date,e)}function Fo(e,t){let n=new Intl.DateTimeFormat(void 0,{month:`long`}),r=new Intl.DateTimeFormat(void 0,{month:`short`}),i=e=>e<10?`0`+e:e.toString();return t.replace(/%[YmdbBHM%]/g,t=>{switch(t){case`%Y`:return e.getFullYear().toString();case`%m`:return i(e.getMonth()+1);case`%d`:return i(e.getDate());case`%b`:return r.format(e);case`%B`:return n.format(e);case`%H`:return i(e.getHours());case`%M`:return i(e.getMinutes());case`%%`:return`%`;default:return t}})}function Io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Lo(e,t,n,r){if(r===0)return e;let i=r==null||r<0?1/0:r,a=t.length===0?RegExp(`(?=)`,`gu`):new RegExp(Io(t),`gu`);return e.replaceAll(a,e=>i>0?(--i,n):e)}var Ro=class extends Error{},zo=class extends Error{},Bo=class{type=`RuntimeValue`;value;builtins=new Map;constructor(e=void 0){this.value=e}__bool__(){return new B(!!this.value)}toString(){return String(this.value)}},R=class extends Bo{type=`IntegerValue`},Vo=class extends Bo{type=`FloatValue`;toString(){return this.value%1==0?this.value.toFixed(1):this.value.toString()}},z=class extends Bo{type=`StringValue`;builtins=new Map([[`upper`,new Jo(()=>new z(this.value.toUpperCase()))],[`lower`,new Jo(()=>new z(this.value.toLowerCase()))],[`strip`,new Jo(()=>new z(this.value.trim()))],[`title`,new Jo(()=>new z(No(this.value)))],[`capitalize`,new Jo(()=>new z(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],[`length`,new R(this.value.length)],[`rstrip`,new Jo(()=>new z(this.value.trimEnd()))],[`lstrip`,new Jo(()=>new z(this.value.trimStart()))],[`startswith`,new Jo(e=>{if(e.length===0)throw Error(`startswith() requires at least one argument`);let t=e[0];if(t instanceof z)return new B(this.value.startsWith(t.value));if(t instanceof V){for(let e of t.value){if(!(e instanceof z))throw Error(`startswith() tuple elements must be strings`);if(this.value.startsWith(e.value))return new B(!0)}return new B(!1)}throw Error(`startswith() argument must be a string or tuple of strings`)})],[`endswith`,new Jo(e=>{if(e.length===0)throw Error(`endswith() requires at least one argument`);let t=e[0];if(t instanceof z)return new B(this.value.endsWith(t.value));if(t instanceof V){for(let e of t.value){if(!(e instanceof z))throw Error(`endswith() tuple elements must be strings`);if(this.value.endsWith(e.value))return new B(!0)}return new B(!1)}throw Error(`endswith() argument must be a string or tuple of strings`)})],[`split`,new Jo(e=>{let t=e[0]??new Yo;if(!(t instanceof z||t instanceof Yo))throw Error(`sep argument must be a string or null`);let n=e[1]??new R(-1);if(!(n instanceof R))throw Error(`maxsplit argument must be a number`);let r=[];if(t instanceof Yo){let e=this.value.trimStart();for(let{0:t,index:i}of e.matchAll(/\S+/g)){if(n.value!==-1&&r.length>=n.value&&i!==void 0){r.push(t+e.slice(i+t.length));break}r.push(t)}}else{if(t.value===``)throw Error(`empty separator`);r=this.value.split(t.value),n.value!==-1&&r.length>n.value&&r.push(r.splice(n.value).join(t.value))}return new V(r.map(e=>new z(e)))})],[`replace`,new Jo(e=>{if(e.length<2)throw Error(`replace() requires at least two arguments`);let t=e[0],n=e[1];if(!(t instanceof z&&n instanceof z))throw Error(`replace() arguments must be strings`);let r;if(r=e.length>2?e[2].type===`KeywordArgumentsValue`?e[2].value.get(`count`)??new Yo:e[2]:new Yo,!(r instanceof R||r instanceof Yo))throw Error(`replace() count argument must be a number or null`);return new z(Lo(this.value,t.value,n.value,r.value))})]])},B=class extends Bo{type=`BooleanValue`},Ho=/[\x7f-\uffff]/g;function Uo(e){return e.replace(Ho,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`))}function Wo(e,t={},n=0,r=!0){let{indent:i=null,ensureAscii:a=!1,separators:o=null,sortKeys:s=!1}=t,c,l;switch(o?[c,l]=o:i?(c=`,`,l=`: `):(c=`, `,l=`: `),e.type){case`NullValue`:return`null`;case`UndefinedValue`:return r?`null`:`undefined`;case`IntegerValue`:case`FloatValue`:case`BooleanValue`:return JSON.stringify(e.value);case`StringValue`:{let t=JSON.stringify(e.value);return a&&(t=Uo(t)),t}case`ArrayValue`:case`ObjectValue`:{let o=i?` `.repeat(i):``,u=`
|
|
8
8
|
`+o.repeat(n),d=u+o;if(e.type===`ArrayValue`){let a=e.value.map(e=>Wo(e,t,n+1,r));return i?`[${d}${a.join(`${c}${d}`)}${u}]`:`[${a.join(c)}]`}else{let o=Array.from(e.value.entries());s&&(o=o.sort(([e],[t])=>e.localeCompare(t)));let f=o.map(([e,o])=>{let s=JSON.stringify(e);a&&(s=Uo(s));let c=`${s}${l}${Wo(o,t,n+1,r)}`;return i?`${d}${c}`:c});return i?`{${f.join(c)}${u}}`:`{${f.join(c)}}`}}default:throw Error(`Cannot convert to JSON: ${e.type}`)}}var Go=class extends Bo{type=`ObjectValue`;__bool__(){return new B(this.value.size>0)}builtins=new Map([[`get`,new Jo(([e,t])=>{if(!(e instanceof z))throw Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new Yo})],[`items`,new Jo(()=>this.items())],[`keys`,new Jo(()=>this.keys())],[`values`,new Jo(()=>this.values())],[`dictsort`,new Jo(e=>{let t=new Map,n=e.filter(e=>e instanceof Ko?(t=e.value,!1):!0),r=n.at(0)??t.get(`case_sensitive`)??new B(!1);if(!(r instanceof B))throw Error(`case_sensitive must be a boolean`);let i=n.at(1)??t.get(`by`)??new z(`key`);if(!(i instanceof z))throw Error(`by must be a string`);if(![`key`,`value`].includes(i.value))throw Error(`by must be either 'key' or 'value'`);let a=n.at(2)??t.get(`reverse`)??new B(!1);if(!(a instanceof B))throw Error(`reverse must be a boolean`);return new V(Array.from(this.value.entries()).map(([e,t])=>new V([new z(e),t])).sort((e,t)=>{let n=i.value===`key`?0:1,o=e.value[n],s=t.value[n],c=es(o,s,r.value);return a.value?-c:c}))})]]);items(){return new V(Array.from(this.value.entries()).map(([e,t])=>new V([new z(e),t])))}keys(){return new V(Array.from(this.value.keys()).map(e=>new z(e)))}values(){return new V(Array.from(this.value.values()))}toString(){return Wo(this,{},0,!1)}},Ko=class extends Go{type=`KeywordArgumentsValue`},V=class extends Bo{type=`ArrayValue`;builtins=new Map([[`length`,new R(this.value.length)]]);__bool__(){return new B(this.value.length>0)}toString(){return Wo(this,{},0,!1)}},qo=class extends V{type=`TupleValue`},Jo=class extends Bo{type=`FunctionValue`},Yo=class extends Bo{type=`NullValue`},Xo=class extends Bo{type=`UndefinedValue`},Zo=class{constructor(e){this.parent=e}variables=new Map([[`namespace`,new Jo(e=>{if(e.length===0)return new Go(new Map);if(e.length!==1||!(e[0]instanceof Go))throw Error("`namespace` expects either zero arguments or a single object argument");return e[0]})]]);tests=new Map([[`boolean`,e=>e.type===`BooleanValue`],[`callable`,e=>e instanceof Jo],[`odd`,e=>{if(!(e instanceof R))throw Error(`cannot odd on ${e.type}`);return e.value%2!=0}],[`even`,e=>{if(!(e instanceof R))throw Error(`cannot even on ${e.type}`);return e.value%2==0}],[`false`,e=>e.type===`BooleanValue`&&!e.value],[`true`,e=>e.type===`BooleanValue`&&e.value],[`none`,e=>e.type===`NullValue`],[`string`,e=>e.type===`StringValue`],[`number`,e=>e instanceof R||e instanceof Vo],[`integer`,e=>e instanceof R],[`iterable`,e=>e.type===`ArrayValue`||e.type===`StringValue`],[`mapping`,e=>e instanceof Go],[`sequence`,e=>e instanceof V||e instanceof Go||e instanceof z],[`lower`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toLowerCase()}],[`upper`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toUpperCase()}],[`none`,e=>e.type===`NullValue`],[`defined`,e=>e.type!==`UndefinedValue`],[`undefined`,e=>e.type===`UndefinedValue`],[`equalto`,(e,t)=>e.value===t.value],[`eq`,(e,t)=>e.value===t.value]]);set(e,t){return this.declareVariable(e,ns(t))}declareVariable(e,t){if(this.variables.has(e))throw SyntaxError(`Variable already declared: ${e}`);return this.variables.set(e,t),t}setVariable(e,t){return this.variables.set(e,t),t}resolve(e){if(this.variables.has(e))return this;if(this.parent)return this.parent.resolve(e);throw Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new Xo}catch{return new Xo}}};function Qo(e){e.set(`false`,!1),e.set(`true`,!0),e.set(`none`,null),e.set(`raise_exception`,e=>{throw Error(e)}),e.set(`range`,jo),e.set(`strftime_now`,Po),e.set(`True`,!0),e.set(`False`,!1),e.set(`None`,null)}function $o(e,t){let n=t.split(`.`),r=e;for(let e of n)if(r instanceof Go)r=r.value.get(e)??new Xo;else if(r instanceof V){let t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<r.value.length)r=r.value[t];else return new Xo}else return new Xo;return r}function es(e,t,n=!1){if(e instanceof Yo&&t instanceof Yo)return 0;if(e instanceof Yo||t instanceof Yo)throw Error(`Cannot compare ${e.type} with ${t.type}`);if(e instanceof Xo&&t instanceof Xo)return 0;if(e instanceof Xo||t instanceof Xo)throw Error(`Cannot compare ${e.type} with ${t.type}`);let r=e=>e instanceof R||e instanceof Vo||e instanceof B,i=e=>e instanceof B?+!!e.value:e.value;if(r(e)&&r(t)){let n=i(e),r=i(t);return n<r?-1:+(n>r)}if(e.type!==t.type)throw Error(`Cannot compare different types: ${e.type} and ${t.type}`);switch(e.type){case`StringValue`:{let r=e.value,i=t.value;return n||(r=r.toLowerCase(),i=i.toLowerCase()),r<i?-1:+(r>i)}default:throw Error(`Cannot compare type: ${e.type}`)}}var ts=class{global;constructor(e){this.global=e??new Zo}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){let n=this.evaluate(e.left,t);switch(e.operator.value){case`and`:return n.__bool__().value?this.evaluate(e.right,t):n;case`or`:return n.__bool__().value?n:this.evaluate(e.right,t)}let r=this.evaluate(e.right,t);switch(e.operator.value){case`==`:return new B(n.value==r.value);case`!=`:return new B(n.value!=r.value)}if(n instanceof Xo||r instanceof Xo){if(r instanceof Xo&&[`in`,`not in`].includes(e.operator.value))return new B(e.operator.value===`not in`);throw Error(`Cannot perform operation ${e.operator.value} on undefined values`)}else if(n instanceof Yo||r instanceof Yo)throw Error(`Cannot perform operation on null values`);else if(e.operator.value===`~`)return new z(n.value.toString()+r.value.toString());else if((n instanceof R||n instanceof Vo)&&(r instanceof R||r instanceof Vo)){let t=n.value,i=r.value;switch(e.operator.value){case`+`:case`-`:case`*`:{let a=e.operator.value===`+`?t+i:e.operator.value===`-`?t-i:t*i;return n instanceof Vo||r instanceof Vo?new Vo(a):new R(a)}case`/`:return new Vo(t/i);case`%`:{let e=t%i;return n instanceof Vo||r instanceof Vo?new Vo(e):new R(e)}case`<`:return new B(t<i);case`>`:return new B(t>i);case`>=`:return new B(t>=i);case`<=`:return new B(t<=i)}}else if(n instanceof V&&r instanceof V)switch(e.operator.value){case`+`:return new V(n.value.concat(r.value))}else if(r instanceof V){let t=r.value.find(e=>e.value===n.value)!==void 0;switch(e.operator.value){case`in`:return new B(t);case`not in`:return new B(!t)}}if(n instanceof z||r instanceof z)switch(e.operator.value){case`+`:return new z(n.value.toString()+r.value.toString())}if(n instanceof z&&r instanceof z)switch(e.operator.value){case`in`:return new B(r.value.includes(n.value));case`not in`:return new B(!r.value.includes(n.value))}if(n instanceof z&&r instanceof Go)switch(e.operator.value){case`in`:return new B(r.value.has(n.value));case`not in`:return new B(!r.value.has(n.value))}throw SyntaxError(`Unknown operator "${e.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(e,t){let n=[],r=new Map;for(let i of e)if(i.type===`SpreadExpression`){let e=i,r=this.evaluate(e.argument,t);if(!(r instanceof V))throw Error(`Cannot unpack non-iterable type: ${r.type}`);for(let e of r.value)n.push(e)}else if(i.type===`KeywordArgumentExpression`){let e=i;r.set(e.key.value,this.evaluate(e.value,t))}else{if(r.size>0)throw Error(`Positional arguments must come before keyword arguments`);n.push(this.evaluate(i,t))}return[n,r]}applyFilter(e,t,n){if(t.type===`Identifier`){let r=t;if(r.value===`safe`)return e;if(r.value===`tojson`)return new z(Wo(e,{}));if(e instanceof V)switch(r.value){case`list`:return e;case`first`:return e.value[0];case`last`:return e.value[e.value.length-1];case`length`:return new R(e.value.length);case`reverse`:return new V(e.value.slice().reverse());case`sort`:return new V(e.value.slice().sort((e,t)=>es(e,t,!1)));case`join`:return new z(e.value.map(e=>e.value).join(``));case`string`:return new z(Wo(e,{},0,!1));case`unique`:{let t=new Set,n=[];for(let r of e.value)t.has(r.value)||(t.add(r.value),n.push(r));return new V(n)}default:throw Error(`Unknown ArrayValue filter: ${r.value}`)}else if(e instanceof z)switch(r.value){case`length`:case`upper`:case`lower`:case`title`:case`capitalize`:{let t=e.builtins.get(r.value);if(t instanceof Jo)return t.value([],n);if(t instanceof R)return t;throw Error(`Unknown StringValue filter: ${r.value}`)}case`trim`:return new z(e.value.trim());case`indent`:return new z(e.value.split(`
|
|
@@ -10,7 +10,7 @@ import{n as e,r as t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./p
|
|
|
10
10
|
`));case`join`:case`string`:return e;case`int`:{let t=parseInt(e.value,10);return new R(isNaN(t)?0:t)}case`float`:{let t=parseFloat(e.value);return new Vo(isNaN(t)?0:t)}default:throw Error(`Unknown StringValue filter: ${r.value}`)}else if(e instanceof R||e instanceof Vo)switch(r.value){case`abs`:return e instanceof R?new R(Math.abs(e.value)):new Vo(Math.abs(e.value));case`int`:return new R(Math.floor(e.value));case`float`:return new Vo(e.value);case`string`:return new z(e.toString());default:throw Error(`Unknown NumericValue filter: ${r.value}`)}else if(e instanceof Go)switch(r.value){case`items`:return new V(Array.from(e.value.entries()).map(([e,t])=>new V([new z(e),t])));case`length`:return new R(e.value.size);default:{let t=e.builtins.get(r.value);if(t)return t instanceof Jo?t.value([],n):t;throw Error(`Unknown ObjectValue filter: ${r.value}`)}}else if(e instanceof B)switch(r.value){case`bool`:return new B(e.value);case`int`:return new R(+!!e.value);case`float`:return new Vo(+!!e.value);case`string`:return new z(e.value?`true`:`false`);default:throw Error(`Unknown BooleanValue filter: ${r.value}`)}throw Error(`Cannot apply filter "${r.value}" to type: ${e.type}`)}else if(t.type===`CallExpression`){let r=t;if(r.callee.type!==`Identifier`)throw Error(`Unknown filter: ${r.callee.type}`);let i=r.callee.value;if(i===`tojson`){let[,t]=this.evaluateArguments(r.args,n),i=t.get(`indent`)??new Yo;if(!(i instanceof R||i instanceof Yo))throw Error(`If set, indent must be a number`);let a=t.get(`ensure_ascii`)??new B(!1);if(!(a instanceof B))throw Error(`If set, ensure_ascii must be a boolean`);let o=t.get(`sort_keys`)??new B(!1);if(!(o instanceof B))throw Error(`If set, sort_keys must be a boolean`);let s=t.get(`separators`)??new Yo,c=null;if(s instanceof V||s instanceof qo){if(s.value.length!==2)throw Error(`separators must be a tuple of two strings`);let[e,t]=s.value;if(!(e instanceof z)||!(t instanceof z))throw Error(`separators must be a tuple of two strings`);c=[e.value,t.value]}else if(!(s instanceof Yo))throw Error(`If set, separators must be a tuple of two strings`);return new z(Wo(e,{indent:i.value,ensureAscii:a.value,sortKeys:o.value,separators:c}))}else if(i===`join`){let t;if(e instanceof z)t=Array.from(e.value);else if(e instanceof V)t=e.value.map(e=>e.value);else throw Error(`Cannot apply filter "${i}" to type: ${e.type}`);let[a,o]=this.evaluateArguments(r.args,n),s=a.at(0)??o.get(`separator`)??new z(``);if(!(s instanceof z))throw Error(`separator must be a string`);return new z(t.join(s.value))}else if(i===`int`||i===`float`){let[t,a]=this.evaluateArguments(r.args,n),o=t.at(0)??a.get(`default`)??(i===`int`?new R(0):new Vo(0));if(e instanceof z){let t=i===`int`?parseInt(e.value,10):parseFloat(e.value);return isNaN(t)?o:i===`int`?new R(t):new Vo(t)}else if(e instanceof R||e instanceof Vo)return e;else if(e instanceof B)return i===`int`?new R(+!!e.value):new Vo(+!!e.value);else throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}else if(i==="default"){let[t,i]=this.evaluateArguments(r.args,n),a=t[0]??new z(``),o=t[1]??i.get(`boolean`)??new B(!1);if(!(o instanceof B))throw Error("`default` filter flag must be a boolean");return e instanceof Xo||o.value&&!e.__bool__().value?a:e}if(e instanceof V){switch(i){case`sort`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`reverse`)??new B(!1);if(!(a instanceof B))throw Error(`reverse must be a boolean`);let o=t.at(1)??i.get(`case_sensitive`)??new B(!1);if(!(o instanceof B))throw Error(`case_sensitive must be a boolean`);let s=t.at(2)??i.get(`attribute`)??new Yo;if(!(s instanceof z||s instanceof R||s instanceof Yo))throw Error(`attribute must be a string, integer, or null`);let c=e=>s instanceof Yo?e:$o(e,s instanceof R?String(s.value):s.value);return new V(e.value.slice().sort((e,t)=>{let n=es(c(e),c(t),o.value);return a.value?-n:n}))}case`selectattr`:case`rejectattr`:{let t=i===`selectattr`;if(e.value.some(e=>!(e instanceof Go)))throw Error(`\`${i}\` can only be applied to array of objects`);if(r.args.some(e=>e.type!==`StringLiteral`))throw Error(`arguments of \`${i}\` must be strings`);let[a,o,s]=r.args.map(e=>this.evaluate(e,n)),c;if(o){let e=n.tests.get(o.value);if(!e)throw Error(`Unknown test: ${o.value}`);c=e}else c=(...e)=>e[0].__bool__().value;return new V(e.value.filter(e=>{let n=e.value.get(a.value),r=n?c(n,s):!1;return t?r:!r}))}case`map`:{let[,t]=this.evaluateArguments(r.args,n);if(t.has(`attribute`)){let n=t.get(`attribute`);if(!(n instanceof z))throw Error(`attribute must be a string`);let r=t.get(`default`);return new V(e.value.map(e=>{if(!(e instanceof Go))throw Error(`items in map must be an object`);let t=$o(e,n.value);return t instanceof Xo?r??new Xo:t}))}else throw Error("`map` expressions without `attribute` set are not currently supported.")}}throw Error(`Unknown ArrayValue filter: ${i}`)}else if(e instanceof z){switch(i){case`indent`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`width`)??new R(4);if(!(a instanceof R))throw Error(`width must be a number`);let o=t.at(1)??i.get(`first`)??new B(!1),s=t.at(2)??i.get(`blank`)??new B(!1),c=e.value.split(`
|
|
11
11
|
`),l=` `.repeat(a.value);return new z(c.map((e,t)=>!o.value&&t===0||!s.value&&e.length===0?e:l+e).join(`
|
|
12
12
|
`))}case`replace`:{let t=e.builtins.get(`replace`);if(!(t instanceof Jo))throw Error(`replace filter not available`);let[i,a]=this.evaluateArguments(r.args,n);return t.value([...i,new Ko(a)],n)}}throw Error(`Unknown StringValue filter: ${i}`)}else if(e instanceof Go){let t=e.builtins.get(i);if(t&&t instanceof Jo){let[e,i]=this.evaluateArguments(r.args,n);return i.size>0&&e.push(new Ko(i)),t.value(e,n)}throw Error(`Unknown ObjectValue filter: ${i}`)}else throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}throw Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){let n=this.evaluate(e.operand,t);return this.applyFilter(n,e.filter,t)}evaluateTestExpression(e,t){let n=this.evaluate(e.operand,t),r=t.tests.get(e.test.value);if(!r)throw Error(`Unknown test: ${e.test.value}`);let i=r(n);return new B(e.negate?!i:i)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new Xo}evaluateUnaryExpression(e,t){let n=this.evaluate(e.argument,t);switch(e.operator.value){case`not`:return new B(!n.value);default:throw SyntaxError(`Unknown operator: ${e.operator.value}`)}}evaluateTernaryExpression(e,t){return this.evaluate(e.condition,t).__bool__().value?this.evaluate(e.trueExpr,t):this.evaluate(e.falseExpr,t)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let n=``;for(let r of e){let e=this.evaluate(r,t);e.type!==`NullValue`&&e.type!==`UndefinedValue`&&(n+=e.toString())}return new z(n)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){let[n,r]=this.evaluateArguments(e.args,t);r.size>0&&n.push(new Ko(r));let i=this.evaluate(e.callee,t);if(i.type!==`FunctionValue`)throw Error(`Cannot call something that is not a function: got ${i.type}`);return i.value(n,t)}evaluateSliceExpression(e,t,n){if(!(e instanceof V||e instanceof z))throw Error(`Slice object must be an array or string`);let r=this.evaluate(t.start,n),i=this.evaluate(t.stop,n),a=this.evaluate(t.step,n);if(!(r instanceof R||r instanceof Xo))throw Error(`Slice start must be numeric or undefined`);if(!(i instanceof R||i instanceof Xo))throw Error(`Slice stop must be numeric or undefined`);if(!(a instanceof R||a instanceof Xo))throw Error(`Slice step must be numeric or undefined`);return e instanceof V?new V(Mo(e.value,r.value,i.value,a.value)):new z(Mo(Array.from(e.value),r.value,i.value,a.value).join(``))}evaluateMemberExpression(e,t){let n=this.evaluate(e.object,t),r;if(e.computed){if(e.property.type===`SliceExpression`)return this.evaluateSliceExpression(n,e.property,t);r=this.evaluate(e.property,t)}else r=new z(e.property.value);let i;if(n instanceof Go){if(!(r instanceof z))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.value.get(r.value)??n.builtins.get(r.value)}else if(n instanceof V||n instanceof z)if(r instanceof R)i=n.value.at(r.value),n instanceof z&&(i=new z(n.value.at(r.value)));else if(r instanceof z)i=n.builtins.get(r.value);else throw Error(`Cannot access property with non-string/non-number: got ${r.type}`);else{if(!(r instanceof z))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.builtins.get(r.value)}return i instanceof Bo?i:new Xo}evaluateSet(e,t){let n=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if(e.assignee.type===`Identifier`){let r=e.assignee.value;t.setVariable(r,n)}else if(e.assignee.type===`TupleLiteral`){let r=e.assignee;if(!(n instanceof V))throw Error(`Cannot unpack non-iterable type in set: ${n.type}`);let i=n.value;if(i.length!==r.value.length)throw Error(`Too ${r.value.length>i.length?`few`:`many`} items to unpack in set`);for(let e=0;e<r.value.length;++e){let n=r.value[e];if(n.type!==`Identifier`)throw Error(`Cannot unpack to non-identifier in set: ${n.type}`);t.setVariable(n.value,i[e])}}else if(e.assignee.type===`MemberExpression`){let r=e.assignee,i=this.evaluate(r.object,t);if(!(i instanceof Go))throw Error(`Cannot assign to member of non-object`);if(r.property.type!==`Identifier`)throw Error(`Cannot assign to member with non-identifier property`);i.value.set(r.property.value,n)}else throw Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);return new Yo}evaluateIf(e,t){let n=this.evaluate(e.test,t);return this.evaluateBlock(n.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){let n=new Zo(t),r,i;if(e.iterable.type===`SelectExpression`){let t=e.iterable;i=this.evaluate(t.lhs,n),r=t.test}else i=this.evaluate(e.iterable,n);if(!(i instanceof V||i instanceof Go))throw Error(`Expected iterable or object type in for loop: got ${i.type}`);i instanceof Go&&(i=i.keys());let a=[],o=[];for(let t=0;t<i.value.length;++t){let s=new Zo(n),c=i.value[t],l;if(e.loopvar.type===`Identifier`)l=t=>t.setVariable(e.loopvar.value,c);else if(e.loopvar.type===`TupleLiteral`){let t=e.loopvar;if(c.type!==`ArrayValue`)throw Error(`Cannot unpack non-iterable type: ${c.type}`);let n=c;if(t.value.length!==n.value.length)throw Error(`Too ${t.value.length>n.value.length?`few`:`many`} items to unpack`);l=e=>{for(let r=0;r<t.value.length;++r){if(t.value[r].type!==`Identifier`)throw Error(`Cannot unpack non-identifier type: ${t.value[r].type}`);e.setVariable(t.value[r].value,n.value[r])}}}else throw Error(`Invalid loop variable(s): ${e.loopvar.type}`);r&&(l(s),!this.evaluate(r,s).__bool__().value)||(a.push(c),o.push(l))}let s=``,c=!0;for(let t=0;t<a.length;++t){let r=new Map([[`index`,new R(t+1)],[`index0`,new R(t)],[`revindex`,new R(a.length-t)],[`revindex0`,new R(a.length-t-1)],[`first`,new B(t===0)],[`last`,new B(t===a.length-1)],[`length`,new R(a.length)],[`previtem`,t>0?a[t-1]:new Xo],[`nextitem`,t<a.length-1?a[t+1]:new Xo]]);n.setVariable(`loop`,new Go(r)),o[t](n);try{let t=this.evaluateBlock(e.body,n);s+=t.value}catch(e){if(e instanceof zo)continue;if(e instanceof Ro)break;throw e}c=!1}if(c){let t=this.evaluateBlock(e.defaultBlock,n);s+=t.value}return new z(s)}evaluateMacro(e,t){return t.setVariable(e.name.value,new Jo((t,n)=>{let r=new Zo(n);t=t.slice();let i;t.at(-1)?.type===`KeywordArgumentsValue`&&(i=t.pop());for(let n=0;n<e.args.length;++n){let a=e.args[n],o=t[n];if(a.type===`Identifier`){let e=a;if(!o)throw Error(`Missing positional argument: ${e.value}`);r.setVariable(e.value,o)}else if(a.type===`KeywordArgumentExpression`){let e=a,t=o??i?.value.get(e.key.value)??this.evaluate(e.value,r);r.setVariable(e.key.value,t)}else throw Error(`Unknown argument type: ${a.type}`)}return this.evaluateBlock(e.body,r)})),new Yo}evaluateCallStatement(e,t){let n=new Jo((t,n)=>{let r=new Zo(n);if(e.callerArgs)for(let n=0;n<e.callerArgs.length;++n){let i=e.callerArgs[n];if(i.type!==`Identifier`)throw Error(`Caller parameter must be an identifier, got ${i.type}`);r.setVariable(i.value,t[n]??new Xo)}return this.evaluateBlock(e.body,r)}),[r,i]=this.evaluateArguments(e.call.args,t);r.push(new Ko(i));let a=this.evaluate(e.call.callee,t);if(a.type!==`FunctionValue`)throw Error(`Cannot call something that is not a function: got ${a.type}`);let o=new Zo(t);return o.setVariable(`caller`,n),a.value(r,o)}evaluateFilterStatement(e,t){let n=this.evaluateBlock(e.body,t);return this.applyFilter(n,e.filter,t)}evaluate(e,t){if(!e)return new Xo;switch(e.type){case`Program`:return this.evalProgram(e,t);case`Set`:return this.evaluateSet(e,t);case`If`:return this.evaluateIf(e,t);case`For`:return this.evaluateFor(e,t);case`Macro`:return this.evaluateMacro(e,t);case`CallStatement`:return this.evaluateCallStatement(e,t);case`Break`:throw new Ro;case`Continue`:throw new zo;case`IntegerLiteral`:return new R(e.value);case`FloatLiteral`:return new Vo(e.value);case`StringLiteral`:return new z(e.value);case`ArrayLiteral`:return new V(e.value.map(e=>this.evaluate(e,t)));case`TupleLiteral`:return new qo(e.value.map(e=>this.evaluate(e,t)));case`ObjectLiteral`:{let n=new Map;for(let[r,i]of e.value){let e=this.evaluate(r,t);if(!(e instanceof z))throw Error(`Object keys must be strings: got ${e.type}`);n.set(e.value,this.evaluate(i,t))}return new Go(n)}case`Identifier`:return this.evaluateIdentifier(e,t);case`CallExpression`:return this.evaluateCallExpression(e,t);case`MemberExpression`:return this.evaluateMemberExpression(e,t);case`UnaryExpression`:return this.evaluateUnaryExpression(e,t);case`BinaryExpression`:return this.evaluateBinaryExpression(e,t);case`FilterExpression`:return this.evaluateFilterExpression(e,t);case`FilterStatement`:return this.evaluateFilterStatement(e,t);case`TestExpression`:return this.evaluateTestExpression(e,t);case`SelectExpression`:return this.evaluateSelectExpression(e,t);case`Ternary`:return this.evaluateTernaryExpression(e,t);case`Comment`:return new Yo;default:throw SyntaxError(`Unknown node type: ${e.type}`)}}};function ns(e){switch(typeof e){case`number`:return Number.isInteger(e)?new R(e):new Vo(e);case`string`:return new z(e);case`boolean`:return new B(e);case`undefined`:return new Xo;case`object`:return e===null?new Yo:Array.isArray(e)?new V(e.map(ns)):new Go(new Map(Object.entries(e).map(([e,t])=>[e,ns(t)])));case`function`:return new Jo((t,n)=>ns(e(...t.map(e=>e.value))??null));default:throw Error(`Cannot convert to runtime value: ${e}`)}}var rs=`
|
|
13
|
-
`,is=`{%- `,as=` -%}`;function os(e){switch(e.operator.type){case`MultiplicativeBinaryOperator`:return 4;case`AdditiveBinaryOperator`:return 3;case`ComparisonBinaryOperator`:return 2;case`Identifier`:return e.operator.value===`and`?1:e.operator.value===`in`||e.operator.value===`not in`?2:0}return 0}function ss(e,t=` `){let n=typeof t==`number`?` `.repeat(t):t;return ls(e.body,0,n).replace(/\n$/,``)}function cs(...e){return is+e.join(` `)+as}function ls(e,t,n){return e.map(e=>us(e,t,n)).join(rs)}function us(e,t,n){let r=n.repeat(t);switch(e.type){case`Program`:return ls(e.body,t,n);case`If`:return ds(e,t,n);case`For`:return fs(e,t,n);case`Set`:return ps(e,t,n);case`Macro`:return ms(e,t,n);case`Break`:return r+cs(`break`);case`Continue`:return r+cs(`continue`);case`CallStatement`:return hs(e,t,n);case`FilterStatement`:return gs(e,t,n);case`Comment`:return r+`{# `+e.value+` #}`;default:return r+`{{- `+H(e)+` -}}`}}function ds(e,t,n){let r=n.repeat(t),i=[],a=e;for(;a&&(i.push({test:a.test,body:a.body}),a.alternate.length===1&&a.alternate[0].type===`If`);)a=a.alternate[0];let o=r+cs(`if`,H(i[0].test))+rs+ls(i[0].body,t+1,n);for(let e=1;e<i.length;++e)o+=rs+r+cs(`elif`,H(i[e].test))+rs+ls(i[e].body,t+1,n);return a&&a.alternate.length>0&&(o+=rs+r+cs(`else`)+rs+ls(a.alternate,t+1,n)),o+=rs+r+cs(`endif`),o}function fs(e,t,n){let r=n.repeat(t),i=``;if(e.iterable.type===`SelectExpression`){let t=e.iterable;i=`${H(t.lhs)} if ${H(t.test)}`}else i=H(e.iterable);let a=r+cs(`for`,H(e.loopvar),`in`,i)+rs+ls(e.body,t+1,n);return e.defaultBlock.length>0&&(a+=rs+r+cs(`else`)+rs+ls(e.defaultBlock,t+1,n)),a+=rs+r+cs(`endfor`),a}function ps(e,t,n){let r=n.repeat(t),i=H(e.assignee),a=e.value?H(e.value):``,o=r+cs(`set`,`${i}${e.value?` = `+a:``}`);return e.body.length===0?o:o+rs+ls(e.body,t+1,n)+rs+r+cs(`endset`)}function ms(e,t,n){let r=n.repeat(t),i=e.args.map(H).join(`, `);return r+cs(`macro`,`${e.name.value}(${i})`)+rs+ls(e.body,t+1,n)+rs+r+cs(`endmacro`)}function hs(e,t,n){let r=n.repeat(t),i=e.callerArgs&&e.callerArgs.length>0?`(${e.callerArgs.map(H).join(`, `)})`:``,a=H(e.call),o=r+cs(`call${i}`,a)+rs;return o+=ls(e.body,t+1,n)+rs,o+=r+cs(`endcall`),o}function gs(e,t,n){let r=n.repeat(t),i=r+cs(`filter`,e.filter.type===`Identifier`?e.filter.value:H(e.filter))+rs;return i+=ls(e.body,t+1,n)+rs,i+=r+cs(`endfilter`),i}function H(e,t=-1){switch(e.type){case`SpreadExpression`:return`*${H(e.argument)}`;case`Identifier`:return e.value;case`IntegerLiteral`:return`${e.value}`;case`FloatLiteral`:return`${e.value}`;case`StringLiteral`:return JSON.stringify(e.value);case`BinaryExpression`:{let n=e,r=os(n),i=H(n.left,r),a=H(n.right,r+1),o=`${i} ${n.operator.value} ${a}`;return r<t?`(${o})`:o}case`UnaryExpression`:{let t=e;return t.operator.value+(t.operator.value===`not`?` `:``)+H(t.argument,1/0)}case`CallExpression`:{let t=e,n=t.args.map(H).join(`, `);return`${H(t.callee)}(${n})`}case`MemberExpression`:{let t=e,n=H(t.object);[`Identifier`,`MemberExpression`,`CallExpression`,`StringLiteral`,`IntegerLiteral`,`FloatLiteral`,`ArrayLiteral`,`TupleLiteral`,`ObjectLiteral`].includes(t.object.type)||(n=`(${n})`);let r=H(t.property);return!t.computed&&t.property.type!==`Identifier`&&(r=`(${r})`),t.computed?`${n}[${r}]`:`${n}.${r}`}case`FilterExpression`:{let t=e,n=H(t.operand,1/0);return t.filter.type===`CallExpression`?`${n} | ${H(t.filter)}`:`${n} | ${t.filter.value}`}case`SelectExpression`:{let t=e;return`${H(t.lhs)} if ${H(t.test)}`}case`TestExpression`:{let t=e;return`${H(t.operand)} is${t.negate?` not`:``} ${t.test.value}`}case`ArrayLiteral`:case`TupleLiteral`:{let t=e.value.map(H),n=e.type===`ArrayLiteral`?`[]`:`()`;return`${n[0]}${t.join(`, `)}${n[1]}`}case`ObjectLiteral`:return`{${Array.from(e.value.entries()).map(([e,t])=>`${H(e)}: ${H(t)}`).join(`, `)}}`;case`SliceExpression`:{let t=e;return`${t.start?H(t.start):``}:${t.stop?H(t.stop):``}${t.step?`:${H(t.step)}`:``}`}case`KeywordArgumentExpression`:{let t=e;return`${t.key.value}=${H(t.value)}`}case`Ternary`:{let n=e,r=`${H(n.trueExpr)} if ${H(n.condition,0)} else ${H(n.falseExpr)}`;return t>-1?`(${r})`:r}default:throw Error(`Unknown expression type: ${e.type}`)}}var _s=class{parsed;constructor(e){let t=Za(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=Ao(t)}render(e){let t=new Zo;if(Qo(t),e)for(let[n,r]of Object.entries(e))t.set(n,r);return new ts(t).run(this.parsed).value}format(e){return ss(this.parsed,e?.indent||` `)}},vs={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`},ys=class e{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Er.existsSync(e),this.exists){this.status=200,this.statusText=`OK`;let t=Er.statSync(e);this.headers.set(`content-length`,t.size.toString()),this.updateContentType();let n=Er.createReadStream(e);this.body=new ReadableStream({start(e){n.on(`data`,t=>e.enqueue(t)),n.on(`end`,()=>e.close()),n.on(`error`,t=>e.error(t))},cancel(){n.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`,vs[e]??`application/octet-stream`)}clone(){let t=new e(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await Er.promises.readFile(this.filePath)).buffer}async blob(){let e=await Er.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get(`content-type`)})}async text(){return await Er.promises.readFile(this.filePath,`utf8`)}async json(){return JSON.parse(await this.text())}},bs=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(j.IS_CRYPTO_AVAILABLE){let t=new Uint32Array(1);crypto.getRandomValues(t),e=t[0]}else e=Date.now()>>>0;let t=this._mt,n=(e,t)=>Math.imul(e,t)>>>0,r=[];for(let t=e||0;t>0;t=Math.floor(t/4294967296))r.push(t&4294967295);r.length||r.push(0),t[0]=19650218;for(let e=1;e<624;++e)t[e]=n(1812433253,t[e-1]^t[e-1]>>>30)+e>>>0;let i=1,a=0;for(let e=Math.max(624,r.length);e>0;--e,++i,++a)i>=624&&(t[0]=t[623],i=1),a>=r.length&&(a=0),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1664525))+r[a]+a>>>0;for(let e=623;e>0;--e,++i)i>=624&&(t[0]=t[623],i=1),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1566083941))-i>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let t=0;t<624;++t){let n=e[t]&2147483648|e[(t+1)%624]&2147483647;e[t]=(e[(t+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let t=e[this._idx++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,t=1){let n=this._gauss_next;if(this._gauss_next=null,n===null){let e=this.random()*2*Math.PI,t=Math.sqrt(-2*Math.log(1-this.random()));n=Math.cos(e)*t,this._gauss_next=Math.sin(e)*t}return e+n*t}shuffle(e){for(let t=e.length-1;t>0;--t){let n=32-Math.clz32(t+1),r=this._int32()>>>32-n;for(;r>t;)r=this._int32()>>>32-n;let i=e[t];e[t]=e[r],e[r]=i}}choices(e,t){return e[xs(this._random_fn,t)]}};function xs(e,t){let n=0;for(let e=0;e<t.length;++e)n+=t[e];let r=e()*n;for(let e=0;e<t.length;++e)if(r-=t[e],r<0)return e;return t.length-1}var Ss=new bs,Cs=Object.freeze({Random:bs,seed:Ss.seed.bind(Ss),random:Ss.random.bind(Ss),gauss:Ss.gauss.bind(Ss),shuffle:Ss.shuffle.bind(Ss),choices:Ss.choices.bind(Ss)}),ws=e=>xs(Cs.random,e),Ts=new bs,Es=class{constructor(e){this.path=e}async match(e){let t=new ys(Dr.join(this.path,e));if(t.exists)return t}async put(e,t,n=void 0){let r=Dr.join(this.path,e),i=r+`.tmp.${j.IS_PROCESS_AVAILABLE?process.pid:Date.now()}.${Ts._int32().toString(36)}`;try{let e=t.headers.get(`Content-Length`),a=parseInt(e??`0`),o=0;await Er.promises.mkdir(Dr.dirname(r),{recursive:!0});let s=Er.createWriteStream(i),c=t.body.getReader();for(;;){let{done:e,value:t}=await c.read();if(e)break;await new Promise((e,n)=>{s.write(t,t=>{if(t){n(t);return}e()})}),o+=t.length;let r=a?o/a*100:0;n?.({progress:r,loaded:o,total:a})}await new Promise((e,t)=>{s.close(n=>n?t(n):e())}),await Er.promises.rename(i,r)}catch(e){try{await Er.promises.unlink(i)}catch{}throw e}}async delete(e){let t=Dr.join(this.path,e);try{return await Er.promises.unlink(t),!0}catch{return!1}}},Ds={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`},Os=100,ks=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function As(...e){return e=e.map((t,n)=>(n&&(t=t.replace(RegExp(`^/`),``)),n!==e.length-1&&(t=t.replace(RegExp(`/$`),``)),t)),e.join(`/`)}function js(e,t=null,n=null){let r;try{r=new URL(e)}catch{return!1}return!(t&&!t.includes(r.protocol)||n&&!n.includes(r.hostname))}function Ms(e){return!(!ks.test(e)||e.includes(`..`)||e.includes(`--`)||e.endsWith(`.git`)||e.endsWith(`.ipynb`))}function Ns(e,t,n){if(!n)return null;let r=Ds[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${r}: "${t}".`)}async function Ps(e,t,n){let r=e.headers.get(`Content-Length`),i=r?parseInt(r,10):n??0;r===null&&!n&&N.warn(`Unable to determine content-length from response headers. Will expand buffer when needed.`);let a=new Uint8Array(i),o=0,s=e.body.getReader();async function c(){let{done:e,value:n}=await s.read();if(e)return;let r=o+n.length;if(r>i){i=r;let e=new Uint8Array(i);e.set(a),a=e}return a.set(n,o),o=r,t({progress:o/i*100,loaded:o,total:i}),c()}return await c(),a}function Fs(e){return js(e,[`blob:`])}function Is(e){let t;if(typeof location<`u`&&location.href)t=location.href;else if(import.meta.url)t=import.meta.url;else return e;return new URL(e,t).href}var Ls=`SHA-256`,Rs=`experimental_transformers-hash-cache`,zs=e=>({algorithm:Ls,value:e}),Bs=class{#e=null;_getHashCache=()=>(this.#e??=caches.open(Rs),this.#e);static isAvailable=()=>typeof navigator<`u`&&`crossOriginStorage`in navigator;match=async e=>{let t=await this._getFileHash(e);if(t)try{let[e]=await navigator.crossOriginStorage.requestFileHandles([zs(t)]),n=await e.getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,t)=>{let n=await this._getFileHash(e);if(n){let e=await t.blob();await this._storeBlobInCOS(e,n)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{let[n]=await navigator.crossOriginStorage.requestFileHandles([zs(t)],{create:!0}),r=await n.createWritable();await r.write(e),await r.close()};_processAndStore=async(e,t)=>{try{let n=[];for await(let e of t)n.push(e);let r=new Blob(n),i=await this._getBlobHash(r);await this._storeBlobInCOS(r,i);try{await(await this._getHashCache()).put(e,new Response(i))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let t=await this._getHashCache(),n=await t.match(e);if(n)return n.text();let r=await this._getLfsFileHash(e);return r?(await t.put(e,new Response(r)),r):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes(`/resolve/`))return null;let t=e.replace(`/resolve/`,`/raw/`);try{let e=(await fetch(t).then(e=>e.text())).match(/^oid sha256:([0-9a-f]+)$/m);return e?e[1]:null}catch{return null}};_getBlobHash=async e=>{let t=await e.arrayBuffer(),n=await crypto.subtle.digest(Ls,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}};async function Vs(e=null){let t=null;if(M.useCustomCache){if(!M.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!M.customCache.match||!M.customCache.put)throw 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");t=M.customCache}if(!t&&M.experimental_useCrossOriginStorage&&Bs.isAvailable()&&(t=new Bs),!t&&M.useBrowserCache){if(typeof caches>`u`)throw Error(`Browser cache is not available in this environment.`);try{t=await caches.open(M.cacheKey)}catch(e){N.warn(`An error occurred while opening the browser cache:`,e)}}if(!t&&M.useFSCache){if(!j.IS_FS_AVAILABLE)throw Error(`File System Cache is not available in this environment.`);t=new Es(e??M.cacheDir)}return t}async function Hs(e,...t){for(let n of t)try{let t=await e.match(n);if(t)return t}catch{continue}}var Us=new class{#e;#t;constructor(e){this.#e=e,this.#t=new Map}get(e){if(!this.#t.has(e))return;let t=this.#t.get(e);return this.#t.delete(e),this.#t.set(e,t),t}put(e,t){this.#t.has(e)&&this.#t.delete(e),this.#t.set(e,t),this.#t.size>this.#e&&this.#t.delete(this.#t.keys().next().value)}delete(e){return this.#t.delete(e)}clear(){this.#t.clear()}}(100);function Ws(e,t){let n=Us.get(e);if(n!==void 0)return n;let r=t().then(e=>e,t=>(Us.delete(e),Promise.reject(t)));return Us.put(e,r),r}async function Gs(e){if(!js(e,[`http:`,`https:`]))return null;let t=Ys(e);return t.set(`Range`,`bytes=0-0`),M.fetch(e,{method:`GET`,headers:t,cache:`no-store`})}function Ks(e,t,n={}){return Ws(JSON.stringify([e,t,n?.revision,n?.cache_dir,n?.local_files_only]),()=>qs(e,t,n))}async function qs(e,t,n){let r=await Vs(n?.cache_dir),{localPath:i,remoteURL:a,proposedCacheKey:o,validModelId:s}=Xs(e,t,n,r),c=await Zs(r,i,o);if(c!==void 0&&typeof c!=`string`){let e=c.headers.get(`content-length`),t=c.headers.get(`content-type`);return{exists:!0,size:e?parseInt(e,10):void 0,contentType:t||void 0,fromCache:!0}}if(M.allowLocalModels&&!js(i,[`http:`,`https:`]))try{let e=await Js(i);if(typeof e!=`string`&&e.status!==404){let t=e.headers.get(`content-length`),n=e.headers.get(`content-type`);return{exists:!0,size:t?parseInt(t,10):void 0,contentType:n||void 0,fromCache:!1}}}catch{}if(M.allowRemoteModels&&!n.local_files_only&&s)try{let e=await Gs(a);if(e&&e.status>=200&&e.status<300){let t,n=e.headers.get(`content-type`);if(e.status===206){let n=e.headers.get(`content-range`);if(n){let e=n.match(/bytes \d+-\d+\/(\d+)/);e&&(t=parseInt(e[1],10))}}else if(e.status===200)try{await e.body?.cancel()}catch{}if(t===void 0){let n=e.headers.get(`content-length`);t=n?parseInt(n,10):void 0}return{exists:!0,size:t,contentType:n||void 0,fromCache:!1}}}catch(e){N.warn(`Unable to fetch file metadata for "${a}": ${e}`)}return{exists:!1,fromCache:!1}}async function Js(e){return M.useFS&&!js(e,[`http:`,`https:`,`blob:`])?new ys(e instanceof URL?e.protocol===`file:`?e.pathname:e.toString():e):M.fetch(e,{headers:Ys(e)})}function Ys(e){let t=typeof process<`u`&&process?.release?.name===`node`,n=new Headers;if(t){let t=!!{}.TESTING_REMOTELY,r=M.version;if(n.set(`User-Agent`,`transformers.js/${r}; is_ci/${t};`),js(e,[`http:`,`https:`],[`huggingface.co`,`hf.co`])){let e={}.HF_TOKEN??{}.HF_ACCESS_TOKEN;e&&n.set(`Authorization`,`Bearer ${e}`)}}return n}function Xs(e,t,n={},r=null){let i=n.revision??`main`,a=As(e,t),o=Ms(e),s=o?As(M.localModelPath,a):a,c=As(M.remoteHost,M.remotePathTemplate.replaceAll(`{model}`,e).replaceAll(`{revision}`,encodeURIComponent(i)),t);return{requestURL:a,localPath:s,remoteURL:c,proposedCacheKey:r instanceof Es?i===`main`?a:As(e,i,t):c,validModelId:o}}async function Zs(e,t,n){if(e)return await Hs(e,t,n)}async function Qs(e,t,n,r,i,a,o={}){if(await n.match(r)===void 0){if(!a){let a=o.progress_callback?n=>ri(o.progress_callback,{status:`progress`,name:e,file:t,...n}):void 0;await n.put(r,i,a)}else if(typeof i!=`string`){let e=new Headers(i.headers);e.set(`content-length`,a.byteLength.toString()),await n.put(r,new Response(a,{headers:e})).catch(e=>{N.warn(`Unable to add response to browser cache: ${e}.`)})}}}async function $s(e,t,n=!0,r={},i=!1,a=null){let{requestURL:o,localPath:s,remoteURL:c,proposedCacheKey:l,validModelId:u}=Xs(e,t,r,a),d,f=!1,p;p=await Zs(a,s,l);let m=p!==void 0;if(m)d=l;else{if(M.allowLocalModels){if(!js(o,[`http:`,`https:`]))try{p=await Js(s),d=s}catch(e){N.warn(`Unable to load from local path "${s}": "${e}"`)}else if(r.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${o}.`);else if(!M.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${o}.`)}if(p===void 0||typeof p!=`string`&&p.status===404){if(r.local_files_only||!M.allowRemoteModels){if(n)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${s}".`);return null}if(!u)throw Error(`Local file missing at "${s}" and download aborted due to invalid model ID "${e}".`);if(p=await Js(c),p.status!==200)return Ns(p.status,c,n);d=l}f=a&&typeof Response<`u`&&p instanceof Response&&p.status===200}ri(r.progress_callback,{status:`download`,name:e,file:t});let h;if(!(j.IS_NODE_ENV&&i)){let n;if(typeof p!=`string`)if(!r.progress_callback)n=new Uint8Array(await p.arrayBuffer());else if(m&&typeof navigator<`u`&&/firefox/i.test(navigator.userAgent))n=new Uint8Array(await p.arrayBuffer()),ri(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n.length,total:n.length});else{let i,a=p.headers.get(`content-length`);if(a)i=parseInt(a,10);else try{let n=await Ks(e,t,r);n.size&&(i=n.size)}catch{}n=await Ps(p,n=>{ri(r.progress_callback,{status:`progress`,name:e,file:t,...n})},i)}h=n}if(f&&d&&typeof p!=`string`&&await Qs(e,t,a,d,p,h,r),j.IS_NODE_ENV&&i&&r.progress_callback&&typeof p!=`string`){let n=parseInt(p.headers.get(`content-length`),10)||0;ri(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n,total:n})}if(ri(r.progress_callback,{status:`done`,name:e,file:t}),h){if(!j.IS_NODE_ENV&&i)throw Error(`Cannot return path in a browser environment.`);return h}if(p instanceof ys)return p.filePath;let g=await a?.match(d);if(g instanceof ys)return g.filePath;if(g instanceof Response)return new Uint8Array(await g.arrayBuffer());if(typeof g==`string`)return g;throw Error(`Unable to get model file path or buffer.`)}var ec=new Map;async function tc(e,t,n=!0,r={},i=!1){if(!M.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(!M.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}ri(r.progress_callback,{status:`initiate`,name:e,file:t});let a=`${e}::${t}`,o=ec.get(a);return o||(o=$s(e,t,n,r,i,await Vs(r?.cache_dir)).then(e=>(ec.delete(a),e),e=>{throw ec.delete(a),e}),ec.set(a,o)),await o}async function nc(e,t,n=!0,r={}){let i=await tc(e,t,n,r,!1);return i===null?null:new TextDecoder(`utf-8`).decode(i)}async function rc(e,t,n=!0,r={}){let i=await nc(e,t,n,r);return i===null?{}:JSON.parse(i)}function ic(e,[t,n,r],[i,a],o=`bilinear`,s=!1){let c=a/r,l=i/n,u=new e.constructor(i*a*t),d=n*r,f=i*a;for(let o=0;o<i;++o)for(let i=0;i<a;++i){let s=o*a+i,p=(i+.5)/c-.5,m=(o+.5)/l-.5,h=Math.floor(p),g=Math.floor(m),_=Math.min(h+1,r-1),v=Math.min(g+1,n-1);h=Math.max(h,0),g=Math.max(g,0);let y=p-h,b=m-g,x=(1-y)*(1-b),ee=y*(1-b),S=(1-y)*b,te=y*b,C=g*r,w=v*r,ne=C+h,re=C+_,T=w+h,E=w+_;for(let n=0;n<t;++n){let t=n*d;u[n*f+s]=x*e[t+ne]+ee*e[t+re]+S*e[t+T]+te*e[t+E]}}return u}function ac(e,t,n){let r=Array(n.length),i=Array(n.length);for(let e=n.length-1,a=1;e>=0;--e)i[e]=a,r[e]=t[n[e]],a*=r[e];let a=n.map((e,t)=>i[n.indexOf(t)]),o=new e.constructor(e.length);for(let n=0;n<e.length;++n){let r=0;for(let e=t.length-1,i=n;e>=0;--e)r+=i%t[e]*a[e],i=Math.floor(i/t[e]);o[r]=e[n]}return[o,r]}function oc(e){let t=fc(e)[0],n=e.map(e=>Math.exp(e-t)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function sc(e){let t=fc(e)[0],n=0;for(let r=0;r<e.length;++r)n+=Math.exp(e[r]-t);let r=Math.log(n);return e.map(e=>e-t-r)}function cc(e,t){let n=0;for(let r=0;r<e.length;++r)n+=e[r]*t[r];return n}function lc(e,t){return cc(e,t)/(uc(e)*uc(t))}function uc(e){return Math.sqrt(e.reduce((e,t)=>e+t*t,0))}function dc(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]<t&&(t=e[r],n=r);return[t,n]}function fc(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]>t&&(t=e[r],n=r);return[t,n]}function pc(e){return e>0&&(e&e-1)==0}var mc=class{constructor(e){if(this.size=e|0,this.size<=1||!pc(this.size))throw 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 e=0;e<this.table.length;e+=2){let t=Math.PI*e/this.size;this.table[e]=Math.cos(t),this.table[e+1]=-Math.sin(t)}let t=0;for(let e=1;this.size>e;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<<this._width);for(let e=0;e<this._bitrev.length;++e){this._bitrev[e]=0;for(let t=0;t<this._width;t+=2){let n=this._width-t-2;this._bitrev[e]|=(e>>>t&3)<<n}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){let n=t||Array(e.length>>>1);for(let t=0;t<e.length;t+=2)n[t>>>1]=e[t];return n}toComplexArray(e,t){let n=t||this.createComplexArray();for(let t=0;t<n.length;t+=2)n[t]=e[t>>>1],n[t+1]=0;return n}transform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,-1);for(let t=0;t<e.length;++t)e[t]/=this.size}_transform4(e,t,n){let r=this._csize,i=1<<this._width,a=r/i<<1,o,s,c=this._bitrev;if(a===4)for(o=0,s=0;o<r;o+=a,++s){let n=c[s];this._singleTransform2(t,e,o,n,i)}else for(o=0,s=0;o<r;o+=a,++s){let r=c[s];this._singleTransform4(t,e,o,r,i,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>2;for(o=0;o<r;o+=a){let r=o+t-1;for(let a=o,s=0;a<r;a+=2,s+=i){let r=a,i=r+t,o=i+t,c=o+t,u=e[r],d=e[r+1],f=e[i],p=e[i+1],m=e[o],h=e[o+1],g=e[c],_=e[c+1],v=l[s],y=n*l[s+1],b=f*v-p*y,x=f*y+p*v,ee=l[2*s],S=n*l[2*s+1],te=m*ee-h*S,C=m*S+h*ee,w=l[3*s],ne=n*l[3*s+1],re=g*w-_*ne,T=g*ne+_*w,E=u+te,ie=d+C,ae=u-te,oe=d-C,se=b+re,ce=x+T,le=n*(b-re),ue=n*(x-T);e[r]=E+se,e[r+1]=ie+ce,e[i]=ae+ue,e[i+1]=oe-le,e[o]=E-se,e[o+1]=ie-ce,e[c]=ae-ue,e[c+1]=oe+le}}}}_singleTransform2(e,t,n,r,i){let a=e[r],o=e[r+1],s=e[r+i],c=e[r+i+1];t[n]=a+s,t[n+1]=o+c,t[n+2]=a-s,t[n+3]=o-c}_singleTransform4(e,t,n,r,i,a){let o=i*2,s=i*3,c=e[r],l=e[r+1],u=e[r+i],d=e[r+i+1],f=e[r+o],p=e[r+o+1],m=e[r+s],h=e[r+s+1],g=c+f,_=l+p,v=c-f,y=l-p,b=u+m,x=d+h,ee=a*(u-m),S=a*(d-h);t[n]=g+b,t[n+1]=_+x,t[n+2]=v+S,t[n+3]=y-ee,t[n+4]=g-b,t[n+5]=_-x,t[n+6]=v-S,t[n+7]=y+ee}_realTransform4(e,t,n){let r=this._csize,i=1<<this._width,a=r/i<<1,o,s,c=this._bitrev;if(a===4)for(o=0,s=0;o<r;o+=a,++s){let n=c[s];this._singleRealTransform2(t,e,o,n>>>1,i>>>1)}else for(o=0,s=0;o<r;o+=a,++s){let r=c[s];this._singleRealTransform4(t,e,o,r>>>1,i>>>1,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>1,s=t>>>1,c=s>>>1;for(o=0;o<r;o+=a)for(let r=0,a=0;r<=c;r+=2,a+=i){let i=o+r,u=i+s,d=u+s,f=d+s,p=e[i],m=e[i+1],h=e[u],g=e[u+1],_=e[d],v=e[d+1],y=e[f],b=e[f+1],x=p,ee=m,S=l[a],te=n*l[a+1],C=h*S-g*te,w=h*te+g*S,ne=l[2*a],re=n*l[2*a+1],T=_*ne-v*re,E=_*re+v*ne,ie=l[3*a],ae=n*l[3*a+1],oe=y*ie-b*ae,se=y*ae+b*ie,ce=x+T,le=ee+E,ue=x-T,de=ee-E,fe=C+oe,pe=w+se,me=n*(C-oe),he=n*(w-se);if(e[i]=ce+fe,e[i+1]=le+pe,e[u]=ue+he,e[u+1]=de-me,r===0){e[d]=ce-fe,e[d+1]=le-pe;continue}if(r===c)continue;let ge=o+s-r,_e=o+t-r;e[ge]=ue-n*he,e[ge+1]=-de-n*me,e[_e]=ce-n*fe,e[_e+1]=-le+n*pe}}let u=r>>>1;for(let t=2;t<u;t+=2)e[r-t]=e[t],e[r-t+1]=-e[t+1]}_singleRealTransform2(e,t,n,r,i){let a=e[r],o=e[r+i];t[n]=a+o,t[n+1]=0,t[n+2]=a-o,t[n+3]=0}_singleRealTransform4(e,t,n,r,i,a){let o=i*2,s=i*3,c=e[r],l=e[r+i],u=e[r+o],d=e[r+s],f=c+u,p=c-u,m=l+d,h=a*(l-d);t[n]=f+m,t[n+1]=0,t[n+2]=p,t[n+3]=-h,t[n+4]=f-m,t[n+5]=0,t[n+6]=p,t[n+7]=h}},hc=class{constructor(e){let t=2*(e-1),n=2*(2*e-1),r=2**Math.ceil(Math.log2(n));this.bufferSize=r,this._a=t;let i=new Float64Array(n),a=new Float64Array(r);this._chirpBuffer=new Float64Array(r),this._buffer1=new Float64Array(r),this._buffer2=new Float64Array(r),this._outBuffer1=new Float64Array(r),this._outBuffer2=new Float64Array(r);let o=-2*Math.PI/e,s=Math.cos(o),c=Math.sin(o);for(let t=0;t<n>>1;++t){let n=(t+1-e)**2/2,r=Math.sqrt(s**2+c**2)**n,o=n*Math.atan2(c,s),l=2*t;i[l]=r*Math.cos(o),i[l+1]=r*Math.sin(o),a[l]=i[l],a[l+1]=-i[l+1]}this._slicedChirpBuffer=i.subarray(t,n),this._f=new mc(r>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,n){let r=this._buffer1,i=this._buffer2,a=this._outBuffer1,o=this._outBuffer2,s=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(n)for(let e=0;e<c.length;e+=2){let n=e+1,i=t[e>>1];r[e]=i*c[e],r[n]=i*c[n]}else for(let e=0;e<c.length;e+=2){let n=e+1;r[e]=t[e]*c[e]-t[n]*c[n],r[n]=t[e]*c[n]+t[n]*c[e]}this._f.transform(a,r);for(let e=0;e<s.length;e+=2){let t=e+1;i[e]=a[e]*s[e]-a[t]*s[t],i[t]=a[e]*s[t]+a[t]*s[e]}this._f.inverseTransform(o,i);for(let t=0;t<o.length;t+=2){let n=o[t+l],r=o[t+l+1],i=c[t],a=c[t+1];e[t]=n*i-r*a,e[t+1]=n*a+r*i}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}},gc=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=pc(e),this.isPowerOfTwo?(this.fft=new mc(e),this.outputBufferSize=2*e):(this.fft=new hc(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}};function _c(e,t){if(t%2==0||t<=0)throw Error(`Window size must be a positive odd number`);let n=new e.constructor(e.length),r=new e.constructor(t),i=Math.floor(t/2);for(let t=0;t<e.length;++t){let a=0;for(let n=-i;n<=i;++n){let i=t+n;i<0?i=Math.abs(i):i>=e.length&&(i=2*(e.length-1)-i),r[a++]=e[i]}r.sort(),n[t]=r[i]}return n}function vc(e,t){let n=10**t;return Math.round(e*n)/n}function yc(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}function bc(e){let t=e.length,n=e[0].length,r=[t+1,n+1],i=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));i[0][0]=0;let a=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let t=1;t<r[1];++t)for(let n=1;n<r[0];++n){let r=i[n-1][t-1],o=i[n-1][t],s=i[n][t-1],c,l;r<o&&r<s?(c=r,l=0):o<r&&o<s?(c=o,l=1):(c=s,l=2),i[n][t]=e[n-1][t-1]+c,a[n][t]=l}for(let e=0;e<r[1];++e)a[0][e]=2;for(let e=0;e<r[0];++e)a[e][0]=1;let o=t,s=n,c=[],l=[];for(;o>0||s>0;)switch(c.push(o-1),l.push(s-1),a[o][s]){case 0:--o,--s;break;case 1:--o;break;case 2:--s;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${s}]. Please file a bug report.`)}return c.reverse(),l.reverse(),[c,l]}var xc=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);let t=new ArrayBuffer(4),n=new Uint32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;++t){let i=0,a=(t&32768)<<16,o=(t&31744)>>10,s=t&1023;if(o===31)i=a|2139095040|s<<13;else if(o===0)if(s===0)i=a;else{let e=113;for(;!(s&1024);)s<<=1,--e;s&=-1025,i=a|e<<23|s<<13}else i=a|o+112<<23|s<<13;n[0]=i,e[t]=r[0]}}let n=t.length,r=e,i=new Float32Array(n);for(let e=0;e<n;++e)i[e]=r[t[e]];return i}})(),Sc={};Tr(Sc,{default:()=>Cc});var Cc={};async function wc(e){let t=e.split(`/`).pop(),n;try{if(n=await Vs(),n){let t=await n.match(e);if(t)return t}}catch(e){N.warn(`Failed to load ${t} from cache:`,e)}let r=await M.fetch(e);if(!r.ok)throw Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}`);if(n)try{await n.put(e,r.clone())}catch(e){N.warn(`Failed to cache ${t}:`,e)}return r}async function Tc(e){let t=await wc(e);if(!t||typeof t==`string`)return null;try{return await t.arrayBuffer()}catch(e){return N.warn(`Failed to read WASM binary:`,e),null}}async function Ec(e){if(j.IS_SERVICE_WORKER_ENV||j.IS_CHROME_AVAILABLE)return e;let t=await wc(e);if(!t||typeof t==`string`)return null;try{let e=await t.text();e=e.replaceAll(`globalThis.process?.versions?.node`,`false`);let n=new Blob([e],{type:`text/javascript`});return URL.createObjectURL(n)}catch(e){return N.warn(`Failed to read WASM factory:`,e),null}}var Dc=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 Oc(e){return e<=$r.DEBUG?0:e<=$r.INFO?2:e<=$r.WARNING||e<=$r.ERROR?3:4}var kc={0:`verbose`,1:`info`,2:`warning`,3:`error`,4:`fatal`},Ac=[],jc,Mc,Nc=Symbol.for(`onnxruntime`);if(Nc in globalThis)Mc=globalThis[Nc];else if(j.IS_NODE_ENV){switch(Mc=Sc,process.platform){case`win32`:Ac.push(`dml`);break;case`linux`:process.arch===`x64`&&Ac.push(`cuda`);break;case`darwin`:Ac.push(`coreml`);break}Ac.push(`webgpu`),Ac.push(`cpu`),jc=[`cpu`]}else Mc=r,j.IS_WEBNN_AVAILABLE&&Ac.push(`webnn-npu`,`webnn-gpu`,`webnn-cpu`,`webnn`),j.IS_WEBGPU_AVAILABLE&&Ac.push(`webgpu`),Ac.push(`wasm`),jc=[`wasm`];var Pc=Mc.InferenceSession;function Fc(e=null){if(!e)return jc;switch(e){case`auto`:return Ac;case`gpu`:return Ac.filter(e=>[`webgpu`,`cuda`,`dml`,`webnn-gpu`].includes(e))}if(Ac.includes(e))return[Dc[e]??e];throw Error(`Unsupported device: "${e}". Should be one of: ${Ac.join(`, `)}.`)}var Ic=Promise.resolve(),Lc=null;async function Rc(){if(Lc)return Lc;if(!(M.useWasmCache&&typeof Uc?.wasm?.wasmPaths==`object`&&Uc?.wasm?.wasmPaths?.wasm&&Uc?.wasm?.wasmPaths?.mjs)){if(j.IS_DENO_WEB_RUNTIME)throw Error(`env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.`);return Lc=Promise.resolve(),Lc}return Lc=(async()=>{let e=Uc.wasm.wasmPaths,t=!1;await Promise.all([e.wasm&&!Fs(e.wasm)?(async()=>{try{let n=await Tc(Is(e.wasm));n&&(Uc.wasm.wasmBinary=n,t=!0)}catch(e){N.warn(`Failed to pre-load WASM binary:`,e)}})():Promise.resolve(),e.mjs&&!Fs(e.mjs)?(async()=>{try{let t=await Ec(Is(e.mjs));t&&(Uc.wasm.wasmPaths.mjs=t)}catch(e){N.warn(`Failed to pre-load WASM factory:`,e)}})():Promise.resolve()]),t||(Uc.wasm.wasmPaths.mjs=e.mjs)})(),Lc}async function zc(e,t,n){await Rc();let r=Oc(M.logLevel??$r.WARNING),i=()=>Pc.create(e,{logSeverityLevel:r,...t}),a=await(j.IS_WEB_ENV?Ic=Ic.then(i):i());return a.config=n,a}var Bc=Promise.resolve();async function Vc(e,t){let n=()=>e.run(t);return j.IS_WEB_ENV?Bc=Bc.then(n):n()}function Hc(e){return e instanceof Mc.Tensor}var Uc=Mc?.env;function Wc(){return Uc?.wasm?.proxy}if(Uc){let e=function(e){Uc.logLevel=kc[Oc(e)]};if(Uc.wasm){if(!(typeof ServiceWorkerGlobalScope<`u`&&self instanceof ServiceWorkerGlobalScope)&&Uc.versions?.web&&!Uc.wasm.wasmPaths){let e=`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@${Uc.versions.web}/dist/`;Uc.wasm.wasmPaths=j.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`}}Uc.wasm.proxy=!1}Uc.webgpu&&(Uc.webgpu.powerPreference=`high-performance`),e(M.logLevel??$r.WARNING),M.backends.onnx={...Uc,setLogLevel:e}}var Gc=async(e,t,n)=>{let r=await zc(new Uint8Array(e),t);return(async e=>{let t=Wc(),i=await Vc(r,Object.fromEntries(Object.entries(e).map(([e,n])=>[e,(t?n.clone():n).ort_tensor])));return Array.isArray(n)?n.map(e=>new U(i[e])):new U(i[n])})},Kc=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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}},qc=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`}),Jc=j.IS_NODE_ENV?`cpu`:`wasm`;function Yc(e,t,{warn:n}={}){return e?typeof e==`string`?e:e.hasOwnProperty(t)?e[t]:(n&&n(`device not specified for "${t}". Using the default device (${Jc}).`),Jc):Jc}var Xc=(function(){let e;return async function(){if(e===void 0)if(!j.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has(`shader-f16`)}catch{e=!1}return e}})(),Zc=Object.freeze({auto:`auto`,fp32:`fp32`,fp16:`fp16`,q8:`q8`,int8:`int8`,uint8:`uint8`,q4:`q4`,bnb4:`bnb4`,q4f16:`q4f16`,q2:`q2`,q2f16:`q2f16`,q1:`q1`,q1f16:`q1f16`}),Qc=Zc.fp32,$c=Object.freeze({[qc.wasm]:Zc.q8}),el=Object.freeze({[Zc.fp32]:``,[Zc.fp16]:`_fp16`,[Zc.int8]:`_int8`,[Zc.uint8]:`_uint8`,[Zc.q8]:`_quantized`,[Zc.q4]:`_q4`,[Zc.q2]:`_q2`,[Zc.q1]:`_q1`,[Zc.q4f16]:`_q4f16`,[Zc.q2f16]:`_q2f16`,[Zc.q1f16]:`_q1f16`,[Zc.bnb4]:`_bnb4`});function tl(e,t,n,{configDtype:r=null,warn:i}={}){let a,o=!1;e&&typeof e!=`string`?e.hasOwnProperty(t)?a=e[t]:(a=null,o=!0):a=e;let s;if(a===Zc.auto){if(r){let e=typeof r==`string`?r:r?.[t];if(e&&e!==Zc.auto&&Zc.hasOwnProperty(e))return e}s=$c[n]??Qc}else s=a&&Zc.hasOwnProperty(a)?a:$c[n]??Qc;return o&&i&&i(`dtype not specified for "${t}". Using the default dtype (${s}) for this device (${n}).`),s}var nl=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}),U=class e{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 Hc(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new Cr(e[0],e[1],e[2]),new Proxy(this,{get:(e,t)=>{if(typeof t==`string`){let n=Number(t);if(Number.isInteger(n))return e._getitem(n)}return e[t]},set:(e,t,n)=>e[t]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let n=t.reduce((e,t)=>e*t);for(let r=0;r<e;++r)yield this._subarray(r,n,t)}else yield*this.data}_getitem(t){let[n,...r]=this.dims;if(t=gl(t,n),r.length>0){let e=r.reduce((e,t)=>e*t);return this._subarray(t,e,r)}else return new e(this.type,[this.data[t]],r)}indexOf(e){let t=this.data;for(let n=0;n<t.length;++n)if(t[n]==e)return n;return-1}_subarray(t,n,r){let i=t*n,a=(t+1)*n,o=`subarray`in this.data?this.data.subarray(i,a):this.data.slice(i,a);return new e(this.type,o,r)}item(){let e=this.data;if(e.length!==1)throw Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return rl(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=1/(1+Math.exp(-e[t]));return this}map(e){return this.clone().map_(e)}map_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]=e(t[n],n,t);return this}mul(e){return this.clone().mul_(e)}mul_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]-=e;return this}clone(){return new e(this.type,this.data.slice(),this.dims.slice())}slice(...t){let n=[],r=[];for(let e=0;e<this.dims.length;++e){let i=t[e];if(i==null)r.push([0,this.dims[e]]),n.push(this.dims[e]);else if(typeof i==`number`)i=gl(i,this.dims[e],e),r.push([i,i+1]);else if(Array.isArray(i)&&i.length===2){let[t,a]=i;if(t=t===null?0:gl(t,this.dims[e],e,!1),a=a===null?this.dims[e]:gl(a,this.dims[e],e,!1),t>a)throw Error(`Invalid slice: ${i}`);let o=[Math.max(t,0),Math.min(a,this.dims[e])];r.push(o),n.push(o[1]-o[0])}else throw Error(`Invalid slice: ${i}`)}let i=r.map(([e,t])=>t-e),a=i.reduce((e,t)=>e*t),o=this.data,s=new o.constructor(a),c=this.stride(),l=!0;for(let e=1;e<i.length;++e)if(r[e][0]!==0||r[e][1]!==this.dims[e]){l=!1;break}if(l){let e=r[0][0]*c[0],t=r[0][1]*c[0];if(ArrayBuffer.isView(o))s.set(o.subarray(e,t));else if(Array.isArray(o)){let n=o.slice(e,t);for(let e=0;e<n.length;++e)s[e]=n[e]}else throw Error(`Unsupported data type for slicing`)}else for(let e=0;e<a;++e){let t=0;for(let n=i.length-1,a=e;n>=0;--n){let e=i[n];t+=(a%e+r[n][0])*c[n],a=Math.floor(a/e)}s[e]=o[t]}return new e(this.type,s,n)}permute(...e){return il(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(t=`fro`,n=null,r=!1){if(t===`fro`)t=2;else if(typeof t==`string`)throw Error(`Unsupported norm: ${t}`);let i=this.data,a=i instanceof BigInt64Array||i instanceof BigUint64Array;if(a&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let o,s;if(a?(o=(e,t)=>e+t,s=0n):(o=(e,n)=>e+n**t,s=0),n===null){let n=i.reduce(o,s);return t!==1&&(n**=1/t),new e(this.type,[n],[])}let[c,l,u]=yl(o,this,n,r);if(t!==1)for(let e=0;e<l.length;++e)l[e]=l[e]**(1/t);return new e(c,l,u)}normalize_(e=2,t=1){t=gl(t,this.dims.length);let n=this.norm(e,t,!0),r=this.data,i=n.data;for(let e=0;e<r.length;++e){let n=0;for(let r=this.dims.length-1,i=e,a=1;r>=0;--r){let e=this.dims[r];if(r!==t){let t=i%e;n+=t*a,a*=this.dims[r]}i=Math.floor(i/e)}r[e]/=i[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return Sl(this.dims)}squeeze(t=null){return new e(this.type,this.data,ml(this.dims,t))}squeeze_(e=null){return this.dims=ml(this.dims,e),this}unsqueeze(t){return new e(this.type,this.data,hl(this.dims,t))}unsqueeze_(e){return this.dims=hl(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let n=this.dims.slice(0,e),r=this.dims.slice(e,t+1),i=this.dims.slice(t+1);return this.dims=[...n,r.reduce((e,t)=>e*t,1),...i],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...t){let n=-1;for(let e=0;e<t.length;++e)if(t[e]===-1){if(n!==-1)throw Error(`Only one dimension can be inferred`);n=e}let r=this.data;if(n!==-1){let e=t.reduce((e,t,r)=>r===n?e:e*t,1);t[n]=r.length/e}return new e(this.type,r,t)}neg_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=-e[t];return this}neg(){return this.clone().neg_()}gt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;e<r.length;++e)n[e]=+(r[e]>t);return new e(`bool`,n,this.dims)}lt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;e<r.length;++e)n[e]=+(r[e]<t);return new e(`bool`,n,this.dims)}clamp_(e,t){let n=this.data;for(let r=0;r<n.length;++r)n[r]=Math.min(Math.max(n[r],e),t);return this}clamp(e,t){return this.clone().clamp_(e,t)}round_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=Math.round(e[t]);return this}round(){return this.clone().round_()}mean(e=null,t=!1){return xl(this,e,t)}min(t=null,n=!1){if(t===null){let t=dc(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=yl((e,t)=>Math.min(e,t),this,t,n,1/0);return new e(r,i,a)}max(t=null,n=!1){if(t===null){let t=fc(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=yl((e,t)=>Math.max(e,t),this,t,n,-1/0);return new e(r,i,a)}argmin(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=dc(this.data)[1];return new e(`int64`,[BigInt(r)],[])}argmax(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=fc(this.data)[1];return new e(`int64`,[BigInt(r)],[])}repeat(...t){if(t.length<this.dims.length)throw Error(`Number of dimensions of repeat dims (${t.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(t.every(e=>e===1)){if(t.length===this.dims.length)return this.clone();let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims);return new e(this.type,this.data.slice(),r)}let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims),i=r.map((e,n)=>e*t[n]),a=i.reduce((e,t)=>e*t,1),o=this.data,s=new o.constructor(a),c=Sl(r),l=Sl(i);for(let e=0;e<a;++e){let t=e,n=0;for(let e=0;e<i.length;++e){let i=Math.floor(t/l[e]);t%=l[e];let a=i%r[e];n+=a*c[e]}s[e]=o[n]}return new e(this.type,s,i)}tile(...e){if(e.length<this.dims.length){let t=this.dims.length-e.length;e=Array(t).fill(1).concat(e)}return this.repeat(...e)}to(t){if(this.type===t)return this;if(!nl.hasOwnProperty(t))throw Error(`Unsupported type: ${t}`);let n,r=[`int64`,`uint64`].includes(this.type),i=[`int64`,`uint64`].includes(t);if(r&&!i)n=Number;else if(!r&&i)n=[`float16`,`float32`,`float64`].includes(this.type)?e=>BigInt(Math.floor(e)):BigInt;else if(this.type===`float16`&&t==`float32`&&this.data instanceof Uint16Array)return new e(t,xc(this.data),this.dims);return new e(t,nl[t].from(this.data,n),this.dims)}};function rl(e,t){let n=e.length;if(n!==t.reduce((e,t)=>e*t))throw Error(`cannot reshape array of size ${n} into shape (${t})`);let r=e;for(let e=t.length-1;e>=0;e--)r=r.reduce((n,r)=>{let i=n[n.length-1];return i.length<t[e]?i.push(r):n.push([r]),n},[[]]);return r[0]}function il(e,t){let[n,r]=ac(e.data,e.dims,t);return new U(e.type,n,r)}function al(e,[t,n],r=`bilinear`,i=!1){let a=e.dims.at(-3)??1,o=e.dims.at(-2),s=e.dims.at(-1),c=ic(e.data,[a,o,s],[t,n],r,i);return new U(e.type,c,[a,t,n])}async function ol(e,{size:t=null,mode:n=`bilinear`}={}){if(e.dims.length!==4)throw Error("`interpolate_4d` currently only supports 4D input.");if(!t)throw Error("`interpolate_4d` requires a `size` argument.");let r;if(t.length===2)r=[...e.dims.slice(0,2),...t];else if(t.length===3)r=[e.dims[0],...t];else if(t.length===4)r=t;else throw Error("`size` must be of length 2, 3, or 4.");let i;if(n===`nearest`)i=await Kc.nearest_interpolate_4d;else if(n===`bilinear`)i=await Kc.bilinear_interpolate_4d;else if(n===`bicubic`)i=await Kc.bicubic_interpolate_4d;else throw Error(`Unsupported mode: ${n}`);let a=new U(`int64`,new BigInt64Array(r.map(BigInt)),[r.length]);return await i({x:e,s:a})}async function sl(e,t){return await(await Kc.matmul)({a:e,b:t})}async function cl(e,t){return await(await Kc.rfft)({x:e,a:t})}async function ll(e,t){let n=await Kc.top_k;return t=t==null?e.dims.at(-1):Math.min(t,e.dims.at(-1)),await n({x:e,k:new U(`int64`,[BigInt(t)],[1])})}var ul=e=>new U(`int64`,e,[e.length]);async function dl(e,t,n,r,i){return await(await Kc.slice)({x:e,s:ul(t),e:ul(n),a:ul(r),t:ul(i??Array(r.length).fill(1))})}function fl(e,t){let n=e.data,r=t.data,i=[e.dims[0],e.dims[2]],a=new n.constructor(i[0]*i[1]),[o,s,c]=e.dims,l=0;for(let e=0;e<o;++e){let t=e*c*s;for(let i=0;i<c;++i){let o=0,u=0,d=e*s,f=t+i;for(let e=0;e<s;++e){let t=Number(r[d+e]);u+=t,o+=n[f+e*c]*t}let p=o/u;a[l++]=p}}return new U(e.type,a,i)}function pl(e,t,{eps:n=1e-5}={}){if(e.dims.length!==2)throw Error("`layer_norm` currently only supports 2D input.");let[r,i]=e.dims;if(t.length!==1&&t[0]!==i)throw Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[a,o]=bl(e,1,0,!0),s=a.data,c=o.data,l=e.data,u=new l.constructor(l.length);for(let e=0;e<r;++e){let t=e*i;for(let r=0;r<i;++r){let i=t+r;u[i]=(l[i]-c[e])/(s[e]+n)}}return new U(e.type,u,e.dims)}function ml(e,t){return e=e.slice(),t===null?e=e.filter(e=>e!==1):typeof t==`number`?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((e,n)=>e!==1||!t.includes(n))),e}function hl(e,t){return t=gl(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function gl(e,t,n=null,r=!0){if(e<-t||e>=t){if(r)throw Error(`IndexError: index ${e} is out of bounds for dimension${n===null?``:` `+n} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function _l(e,t=0){t=gl(t,e[0].dims.length);let n=e[0].dims.slice();n[t]=e.reduce((e,n)=>e+n.dims[t],0);let r=n.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(r),a=e[0].type;if(t===0){let t=0;for(let n of e){let e=n.data;i.set(e,t),t+=e.length}}else{let r=0;for(let a=0;a<e.length;++a){let{data:o,dims:s}=e[a];for(let e=0;e<o.length;++e){let a=0;for(let i=s.length-1,o=e,c=1;i>=0;--i){let e=s[i],l=o%e;i===t&&(l+=r),a+=l*c,c*=n[i],o=Math.floor(o/e)}i[a]=o[e]}r+=s[t]}}return new U(a,i,n)}function vl(e,t=0){return _l(e.map(e=>e.unsqueeze(t)),t)}function yl(e,t,n,r=!1,i=null){let a=t.data,o=t.dims;n=gl(n,o.length);let s=o.slice();s[n]=1;let c=new a.constructor(a.length/o[n]);i!==null&&c.fill(i);for(let t=0;t<a.length;++t){let r=0;for(let e=o.length-1,i=t,a=1;e>=0;--e){let t=o[e];if(e!==n){let n=i%t;r+=n*a,a*=s[e]}i=Math.floor(i/t)}c[r]=e(c[r],a[t],t,r)}return r||s.splice(n,1),[t.type,c,s]}function bl(e,t=null,n=1,r=!1){let i=e.data,a=e.dims;if(t===null){let t=i.reduce((e,t)=>e+t,0)/i.length,r=Math.sqrt(i.reduce((e,n)=>e+(n-t)**2,0)/(i.length-n)),a=new U(e.type,[t],[]);return[new U(e.type,[r],[]),a]}t=gl(t,a.length);let o=xl(e,t,r),s=o.data,[c,l,u]=yl((e,t,n,r)=>e+(t-s[r])**2,e,t,r);for(let e=0;e<l.length;++e)l[e]=Math.sqrt(l[e]/(a[t]-n));return[new U(c,l,u),o]}function xl(e,t=null,n=!1){let r=e.dims,i=e.data;if(t===null){let t=i.reduce((e,t)=>e+t,0);return new U(e.type,[t/i.length],[])}t=gl(t,r.length);let[a,o,s]=yl((e,t)=>e+t,e,t,n);if(r[t]!==1)for(let e=0;e<o.length;++e)o[e]/=r[t];return new U(a,o,s)}function Sl(e){let t=Array(e.length);for(let n=e.length-1,r=1;n>=0;--n)t[n]=r,r*=e[n];return t}function Cl(e,t,n,r){return new U(n,new r(e.reduce((e,t)=>e*t,1)).fill(t),e)}function wl(e,t){let n,r;if(typeof t==`number`)n=`float32`,r=Float32Array;else if(typeof t==`bigint`)n=`int64`,r=BigInt64Array;else if(typeof t==`boolean`)n=`bool`,r=Uint8Array;else throw Error(`Unsupported data type: ${typeof t}`);return Cl(e,t,n,r)}function Tl(e,t){return wl(e.dims,t)}function El(e){return Cl(e,1n,`int64`,BigInt64Array)}function Dl(e){return El(e.dims)}function Ol(e){return Cl(e,0n,`int64`,BigInt64Array)}function kl(e){return Ol(e.dims)}function Al(e){let t=e.reduce((e,t)=>e*t,1);return new U(`float32`,Float32Array.from({length:t},()=>Cs.random()),e)}function jl(e){let t=e.reduce((e,t)=>e*t,1);return new U(`float32`,Float32Array.from({length:t},()=>Cs.gauss()),e)}function Ml(e,t){if(e.dims.length!==2)throw Error(`The tensor must have 2 dimensions`);if(e.dims.at(-1)%8!=0)throw Error(`The last dimension of the tensor must be a multiple of 8`);if(![`binary`,`ubinary`].includes(t))throw Error(`The precision must be either 'binary' or 'ubinary'`);let n=t===`binary`,r=n?`int8`:`uint8`,i=n?Int8Array:Uint8Array,a=e.data,o=new i(a.length/8);for(let e=0;e<a.length;++e){let t=+(a[e]>0),r=Math.floor(e/8),i=e%8;o[r]|=t<<7-i,n&&i===0&&(o[r]-=128)}return new U(r,o,[e.dims[0],e.dims[1]/8])}async function Nl(e){if(!e)throw Error(`modelId is required for get_tokenizer_files`);return(await Ks(e,`tokenizer_config.json`,{})).exists?[`tokenizer.json`,`tokenizer_config.json`]:[]}async function Pl(e,t){let n=await Nl(e);return await Promise.all(n.map(n=>rc(e,n,!0,t)))}function Fl(e){let t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var Il=[`bos_token`,`eos_token`,`unk_token`,`sep_token`,`pad_token`,`cls_token`,`mask_token`];function Ll(e,t,n,r){for(let i of Object.keys(e)){let a=t-e[i].length,o=n(i),s=Array(a).fill(o);e[i]=r===`right`?ci(e[i],s):ci(s,e[i])}}function Rl(e,t){for(let n of Object.keys(e))e[n].length=t}function zl(e,...t){for(let n of t){if(!Object.hasOwn(e,n))continue;let t=e[n];if(t)if(typeof t==`object`){if(t.__type===`AddedToken`)return t.content;throw Error(`Unknown token: ${t}`)}else return t}return null}function Bl(e){let t=[];for(let n of e.get_added_tokens_decoder().values())n.special&&t.push(n);return t}var W=class extends ni{return_token_type_ids=!1;padding_side=`right`;constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new Ua(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=zl(t,`mask_token`),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=zl(t,`pad_token`,`eos_token`),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=zl(t,`sep_token`),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=zl(t,`unk_token`),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=zl(t,`bos_token`),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=zl(t,`eos_token`),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){let e=Object.create(null);for(let{name:t,template:n}of this.chat_template){if(typeof t!=`string`||typeof n!=`string`)throw Error(`Chat template must be a list of objects with "name" and "template" properties`);e[t]=n}this.chat_template=e}this._compiled_template_cache=new Map;let n=Bl(this._tokenizer);this.all_special_ids=n.map(e=>e.id),this.all_special_tokens=n.map(e=>e.content)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let o=await Pl(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a});return new this(...o)}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(e=>this._tokenizer.token_to_id(e))}_call(e,t={}){let{text_pair:n=null,add_special_tokens:r=!0,padding:i=!1,return_token_type_ids:a=null}=t,{truncation:o=null,max_length:s=null}=t,c=t.return_tensor??!0,l=Array.isArray(e),u;if(l){if(e.length===0)throw Error(`text array must be non-empty`);if(n!==null){if(!Array.isArray(n))throw Error(`text_pair must also be an array`);if(e.length!==n.length)throw Error(`text and text_pair must have the same length`);u=e.map((e,t)=>this._encode_plus(e,{text_pair:n[t],add_special_tokens:r,return_token_type_ids:a}))}else u=e.map(e=>this._encode_plus(e,{add_special_tokens:r,return_token_type_ids:a}))}else{if(e==null)throw Error(`text may not be null or undefined`);if(Array.isArray(n))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:n,add_special_tokens:r,return_token_type_ids:a})]}if(s===null?s=this.model_max_length:o===null&&(i===!0?(N.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),s=this.model_max_length):i===!1&&(N.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)),i===!0&&(s=Math.min(fc(u.map(e=>e.input_ids.length))[0],s??1/0)),s=Math.min(s,this.model_max_length??1/0),i||o)for(let e=0;e<u.length;++e)if(u[e].input_ids.length===s)continue;else u[e].input_ids.length>s?o&&Rl(u[e],s):i&&Ll(u[e],s,e=>e===`input_ids`?this.pad_token_id:0,this.padding_side);let d={};if(c){if(!(i&&o)&&u.some(e=>{for(let t of Object.keys(e))if(e[t].length!==u[0][t]?.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 e=[u.length,u[0].input_ids.length];for(let t of Object.keys(u[0]))d[t]=new U(`int64`,BigInt64Array.from(u.flatMap(e=>e[t]).map(BigInt)),e)}else{for(let e of Object.keys(u[0]))d[e]=u.map(t=>t[e]);if(!l)for(let e of Object.keys(d))d[e]=d[e][0]}return d}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{ids:i,attention_mask:a,token_type_ids:o}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r??this.return_token_type_ids});return{input_ids:i,attention_mask:a,...o?{token_type_ids:o}:{}}}tokenize(e,{pair:t=null,add_special_tokens:n=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:n})}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r}).ids}batch_decode(e,t={}){return e instanceof U&&(e=e.tolist()),e.map(e=>this.decode(e,t))}decode(e,t={}){if(e instanceof U&&(e=Fl(e)),!Array.isArray(e)||e.length===0||!ai(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:n=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:n})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template==`object`){let n=this.chat_template;if(e!==null&&Object.hasOwn(n,e))e=n[e];else if(e===null)if(t!==null&&`tool_use`in n)e=n.tool_use;else if(`default`in n)e=n.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(n).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,t={}){let{tools:n=null,documents:r=null,chat_template:i=null,add_generation_prompt:a=!1,tokenize:o=!0,padding:s=!1,truncation:c=!1,max_length:l=null,return_tensor:u=!0,return_dict:d=!0,tokenizer_kwargs:f={},...p}=t;if(i=this.get_chat_template({chat_template:i,tools:n}),typeof i!=`string`)throw Error(`chat_template must be a string, but got ${typeof i}`);let m=this._compiled_template_cache.get(i);m===void 0&&(m=new _s(i),this._compiled_template_cache.set(i,m));let h=Object.create(null);for(let e of Il){let t=zl(this.config,e);t&&(h[e]=t)}let g=m.render({messages:e,add_generation_prompt:a,tools:n,documents:r,...h,...p});if(o){let e=this._call(g,{add_special_tokens:!1,padding:s,truncation:c,max_length:l,return_tensor:u,...f});return d?e:e.input_ids}return g}};function Vl(e,t,n,r){if(!(`language_codes`in e)||!Array.isArray(e.language_codes))throw Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!(`languageRegex`in e)||!(e.languageRegex instanceof RegExp))throw Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!(`lang_to_token`in e)||typeof e.lang_to_token!=`function`)throw Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let i=r.src_lang,a=r.tgt_lang;if(!e.language_codes.includes(a))throw Error(`Target language code "${a}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);if(i!==void 0){if(!e.language_codes.includes(i))throw Error(`Source language code "${i}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);for(let t of e._tokenizer.post_processor.config.single)if(`SpecialToken`in t&&e.languageRegex.test(t.SpecialToken.id)){t.SpecialToken.id=e.lang_to_token(i);break}}return r.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(a)),e._call(t,n)}var Hl={};Tr(Hl,{AlbertTokenizer:()=>Ul,AutoTokenizer:()=>G,BartTokenizer:()=>Wl,BertTokenizer:()=>Gl,BlenderbotSmallTokenizer:()=>Kl,BlenderbotTokenizer:()=>ql,BloomTokenizer:()=>Jl,CLIPTokenizer:()=>Xl,CamembertTokenizer:()=>Yl,CodeGenTokenizer:()=>Ql,CodeLlamaTokenizer:()=>Zl,CohereAsrTokenizer:()=>eu,CohereTokenizer:()=>$l,ConvBertTokenizer:()=>tu,DebertaTokenizer:()=>ru,DebertaV2Tokenizer:()=>nu,DistilBertTokenizer:()=>iu,ElectraTokenizer:()=>au,EsmTokenizer:()=>ou,FalconTokenizer:()=>su,GPT2Tokenizer:()=>uu,GPTNeoXTokenizer:()=>lu,GemmaTokenizer:()=>cu,HerbertTokenizer:()=>du,LlamaTokenizer:()=>fu,M2M100Tokenizer:()=>pu,MBart50Tokenizer:()=>gu,MBartTokenizer:()=>hu,MPNetTokenizer:()=>yu,MarianTokenizer:()=>mu,MgpstrTokenizer:()=>_u,MobileBertTokenizer:()=>vu,NllbTokenizer:()=>bu,NougatTokenizer:()=>xu,PreTrainedTokenizer:()=>W,Qwen2Tokenizer:()=>Su,RoFormerTokenizer:()=>wu,RobertaTokenizer:()=>Cu,SiglipTokenizer:()=>Tu,SpeechT5Tokenizer:()=>Eu,SqueezeBertTokenizer:()=>Du,T5Tokenizer:()=>Ou,TokenizersBackend:()=>W,VitsTokenizer:()=>Au,Wav2Vec2CTCTokenizer:()=>ju,WhisperTokenizer:()=>Ru,XLMRobertaTokenizer:()=>zu,XLMTokenizer:()=>Bu});var Ul=class extends W{return_token_type_ids=!0},Wl=class extends W{},Gl=class extends W{return_token_type_ids=!0},Kl=class extends W{},ql=class extends W{},Jl=class extends W{},Yl=class extends W{},Xl=class extends W{},Zl=class extends W{},Ql=class extends W{},$l=class extends W{},eu=class extends W{},tu=class extends W{return_token_type_ids=!0},nu=class extends W{return_token_type_ids=!0},ru=class extends W{return_token_type_ids=!0},iu=class extends W{},au=class extends W{return_token_type_ids=!0},ou=class extends W{},su=class extends W{},cu=class extends W{},lu=class extends W{},uu=class extends W{},du=class extends W{return_token_type_ids=!0},fu=class extends W{padding_side=`left`},pu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e.slice(2,-2)),this.lang_to_token=e=>`__${e}__`}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},mu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(e=>this.languageRegex.test(e)),N.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[t,...n]=e.trim().split(this.languageRegex);if(n.length===0)return super._encode_text(t);if(n.length===2){let[e,t]=n;return this.supported_language_codes.includes(e)||N.warn(`Unsupported language code "${e}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),ci([e],super._encode_text(t))}}},hu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},gu=class extends hu{},_u=class extends W{},vu=class extends W{return_token_type_ids=!0},yu=class extends W{},bu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},xu=class extends W{},Su=class extends W{},Cu=class extends W{},wu=class extends W{return_token_type_ids=!0},Tu=class extends W{},Eu=class extends W{},Du=class extends W{return_token_type_ids=!0},Ou=class extends W{},ku=class extends Aa{decode_chain(e){let t=``;for(let n=1;n<e.length;n+=2)t+=e[n];return[t]}},Au=class extends W{constructor(e,t){super(e,t),this._tokenizer.decoder=new ku({type:`VitsDecoder`})}},ju=class extends W{},Mu=[[`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`]],Nu=new Map(Mu),Pu=new Map([...Mu.map(([e,t])=>[t,e]),[`burmese`,`my`],[`valencian`,`ca`],[`flemish`,`nl`],[`haitian`,`ht`],[`letzeburgesch`,`lb`],[`pushto`,`ps`],[`panjabi`,`pa`],[`moldavian`,`ro`],[`moldovan`,`ro`],[`sinhalese`,`si`],[`castilian`,`es`]]);function Fu(e){e=e.toLowerCase();let t=Pu.get(e);if(t===void 0){let n=e.match(/^<\|([a-z]{2})\|>$/);if(n&&(e=n[1]),Nu.has(e))t=e;else{let t=e.length===2?Nu.keys():Nu.values();throw Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(t))}`)}}return t}var Iu=RegExp(`^[\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E]+$`,`gu`),Lu=.1,Ru=class extends W{get timestamp_begin(){return this._tokenizer.token_to_id(`<|notimestamps|>`)+1}_decode_asr(e,{return_timestamps:t=!1,return_language:n=!1,time_precision:r=null,force_full_sequences:i=!0}={}){if(r===null)throw Error(`Must specify time_precision`);let a=null,o=t===`word`;function s(){return{language:a,timestamp:[null,null],text:``}}let c=[],l=s(),u=0,d=this.timestamp_begin,f=d+1500,p=[],m=[],h=!1,g=null,_=new Set(this.all_special_ids);for(let n of e){let e=n.tokens,i=o?n.token_timestamps:null,v=null,y=d;if(`stride`in n){let[t,i,a]=n.stride;if(u-=i,g=t-a,i&&(y=i/r+d),a)for(let t=e.length-1;t>=0;--t){let n=Number(e[t]);if(n>=d){if(v!==null&&(n-d)*r<g)break;v=n}}}let b=[],x=[];for(let n=0;n<e.length;++n){let g=Number(e[n]);if(_.has(g)){let e=this.decode([g]),n=Nu.get(e.slice(2,-2));if(n!==void 0){if(a!==null&&n!==a&&!t){p.push(b);let e=this.findLongestCommonSequence(p)[0],t=this.decode(e);l.text=t,c.push(l),p=[],b=[],l=s()}a=l.language=n}}else if(g>=d&&g<=f){let e=vc((g-d)*r+u,2);if(v!==null&&g>=v)h=!0;else if(h||p.length>0&&g<y)h=!1;else if(l.timestamp[0]===null)l.timestamp[0]=e;else if(e!==l.timestamp[0]){l.timestamp[1]=e,p.push(b),o&&m.push(x);let[t,n]=this.findLongestCommonSequence(p,m),r=this.decode(t);if(l.text=r,o&&(l.words=this.collateWordTimestamps(t,n,a),l.words.length>0&&l.timestamp[1]!==null))for(let e of l.words)e.timestamp[1]>l.timestamp[1]&&l.timestamp[1]>=e.timestamp[0]&&(e.timestamp[1]=l.timestamp[1]);c.push(l),p=[],b=[],m=[],x=[],l=s()}}else if(b.push(g),o){let e=vc(i[n]+u,2),t;if(n+1<i.length){t=vc(i[n+1]+u,2);let a=this.decode([g]);Iu.test(a)&&(t=vc(Math.min(e+r,t),2))}else t=null;x.push([e,t])}}if(`stride`in n){let[e,t,r]=n.stride;u+=e-r}b.length>0?(p.push(b),o&&m.push(x)):p.every(e=>e.length===0)&&(l=s(),p=[],b=[],m=[],x=[])}if(p.length>0){if(i&&t)throw 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[e,n]=this.findLongestCommonSequence(p,m),r=this.decode(e);l.text=r,o&&(l.words=this.collateWordTimestamps(e,n,a)),c.push(l)}let v=Object.create(null),y=c.map(e=>e.text).join(``);if(t||n){for(let e=0;e<c.length;++e){let r=c[e];t||delete r.timestamp,n||delete r.language}if(o){let e=[];for(let t of c)for(let n of t.words)e.push(n);v={chunks:e}}else v={chunks:c}}return[y,v]}findLongestCommonSequence(e,t=null){let n=e[0],r=n.length,i=[],a=Array.isArray(t)&&t.length>0,o=a?[]:null,s=a?t[0]:null;for(let c=1;c<e.length;++c){let l=e[c],u=0,d=[r,r,0,0],f=l.length;for(let e=1;e<r+f;++e){let i=Math.max(0,r-e),o=Math.min(r,r+f-e),p=n.slice(i,o),m=Math.max(0,e-r),h=Math.min(f,e),g=l.slice(m,h);if(p.length!==g.length)throw Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let _;_=a?p.filter((e,n)=>e===g[n]&&s[i+n][0]-Lu<=t[c][m+n][0]).length:p.filter((e,t)=>e===g[t]).length;let v=e/1e4,y=_/e+v;_>1&&y>u&&(u=y,d=[i,o,m,h])}let[p,m,h,g]=d,_=Math.floor((m+p)/2),v=Math.floor((g+h)/2);if(a&&u===0&&r>0){let e=s[r-1][0],n=t[c].findIndex(t=>t[0]>=e);v=n===-1?l.length:n}i.push(...n.slice(0,_)),n=l.slice(v),r=n.length,a&&(o.push(...s.slice(0,_)),s=t[c].slice(v))}return i.push(...n),a?(o.push(...s),[i,o]):[i,[]]}collateWordTimestamps(e,t,n){let[r,i,a]=this.combineTokensIntoWords(e,n),o=[];for(let e=0;e<r.length;++e){let n=a[e];o.push({text:r[e],timestamp:[t[n.at(0)][0],t[n.at(-1)][1]]})}return o}combineTokensIntoWords(e,t,n=`"'“¡¿([{-`,r=`"'.。,,!!??::”)]}、`){t??=`english`;let i,a,o;return[`chinese`,`japanese`,`thai`,`lao`,`myanmar`].includes(t)?[i,a,o]=this.splitTokensOnUnicode(e):[i,a,o]=this.splitTokensOnSpaces(e),this.mergePunctuations(i,a,o,n,r)}decode(e,t){let n;return t?.decode_with_timestamps?(e instanceof U&&(e=Fl(e)),n=this.decodeWithTimestamps(e,t)):n=super.decode(e,t),n}decodeWithTimestamps(e,t){let n=t?.time_precision??.02,r=this.all_special_ids.at(-1)+1,i=[[]];for(let t of e)if(t=Number(t),t>=r){let e=((t-r)*n).toFixed(2);i.push(`<|${e}|>`),i.push([])}else i[i.length-1].push(t);return i=i.map(e=>typeof e==`string`?e:super.decode(e,t)),i.join(``)}splitTokensOnUnicode(e){let t=this.decode(e,{decode_with_timestamps:!0}),n=[],r=[],i=[],a=[],o=[],s=0;for(let c=0;c<e.length;++c){let l=e[c];a.push(l),o.push(c);let u=this.decode(a,{decode_with_timestamps:!0});(!u.includes(`�`)||t[s+u.indexOf(`�`)]===`�`)&&(n.push(u),r.push(a),i.push(o),a=[],o=[],s+=u.length)}return[n,r,i]}splitTokensOnSpaces(e){let[t,n,r]=this.splitTokensOnUnicode(e),i=[],a=[],o=[];for(let e=0;e<t.length;++e){let s=t[e],c=n[e],l=r[e],u=c[0]>=this._tokenizer.token_to_id(`<|endoftext|>`),d=s.startsWith(` `),f=s.trim(),p=Iu.test(f);if(u||d||p||i.length===0)i.push(s),a.push(c),o.push(l);else{let e=i.length-1;i[e]+=s,a[e].push(...c),o[e].push(...l)}}return[i,a,o]}mergePunctuations(e,t,n,r,i){let a=structuredClone(e),o=structuredClone(t),s=structuredClone(n),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(` `)&&r.includes(a[c].trim())?(a[l]=a[c]+a[l],o[l]=ci(o[c],o[l]),s[l]=ci(s[c],s[l]),a[c]=``,o[c]=[],s[c]=[]):l=c,--c;for(c=0,l=1;l<a.length;)!a[c].endsWith(` `)&&i.includes(a[l])?(a[c]+=a[l],o[c]=ci(o[c],o[l]),s[c]=ci(s[c],s[l]),a[l]=``,o[l]=[],s[l]=[]):c=l,++l;return[a.filter(e=>e),o.filter(e=>e.length>0),s.filter(e=>e.length>0)]}},zu=class extends W{},Bu=class extends W{return_token_type_ids=!0;constructor(e,t){super(e,t),N.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},G=class{static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let[o,s]=await Pl(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a}),c=s.tokenizer_class?.replace(/Fast$/,``)??`PreTrainedTokenizer`,l=Hl[c];return l||=(N.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),W),new l(o,s)}},Vu=`https://github.com/huggingface/transformers.js/issues/new/choose`,Hu=`preprocessor_config.json`,Uu=Hu,Wu=`processor_config.json`,Gu=`chat_template.jinja`,K=class extends ni{static classes=[`image_processor_class`,`tokenizer_class`,`feature_extractor_class`];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,n){super(),this.config=e,this.components=t,this.chat_template=n}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,t={}){if(!this.tokenizer)throw 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,...t})}batch_decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.decode(...e)}async _call(e,...t){for(let n of[this.image_processor,this.feature_extractor,this.tokenizer])if(n)return n(e,...t);throw Error(`No image processor, feature extractor, or tokenizer found.`)}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([this.uses_processor_config?rc(e,Wu,!0,t):{},Promise.all(this.classes.filter(e=>e in this).map(async n=>{let r=await this[n].from_pretrained(e,t);return[n.replace(/_class$/,``),r]})).then(Object.fromEntries),this.uses_chat_template_file?nc(e,Gu,!0,t):null]);return new this(n,r,i)}},Ku={};Tr(Ku,{ChatterboxProcessor:()=>Bd,CohereAsrProcessor:()=>Hd,Florence2Processor:()=>Mp,Gemma3Processor:()=>Np,Gemma3nProcessor:()=>Pp,Gemma4Processor:()=>Fp,Glm46VProcessor:()=>Lp,GraniteSpeechProcessor:()=>Rp,GroundingDinoProcessor:()=>Bp,Idefics3Processor:()=>Wp,JinaCLIPProcessor:()=>Kp,Lfm2VlProcessor:()=>qp,LlavaProcessor:()=>Jp,MgpstrProcessor:()=>Xp,MoonshineProcessor:()=>Zp,OwlViTProcessor:()=>Qp,PaliGemmaProcessor:()=>tm,Phi3VProcessor:()=>im,PixtralProcessor:()=>am,Processor:()=>K,PyAnnoteProcessor:()=>om,Qwen2VLProcessor:()=>Ip,Qwen2_5_VLProcessor:()=>sm,Qwen3VLProcessor:()=>cm,Sam2Processor:()=>um,Sam2VideoProcessor:()=>dm,SamProcessor:()=>lm,SmolVLMProcessor:()=>Wp,SpeechT5Processor:()=>fm,UltravoxProcessor:()=>pm,VLChatProcessor:()=>Gp,VoxtralProcessor:()=>vm,VoxtralRealtimeProcessor:()=>wm,Wav2Vec2Processor:()=>Tm,Wav2Vec2ProcessorWithLM:()=>Em,WhisperProcessor:()=>Dm});var qu=class extends ni{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){let n=await rc(e,Hu,!0,t);return new this(n)}};function Ju(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} 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 Yu={};Tr(Yu,{ASTFeatureExtractor:()=>yd,ChatterboxFeatureExtractor:()=>xd,ClapFeatureExtractor:()=>Sd,CohereAsrFeatureExtractor:()=>Td,DacFeatureExtractor:()=>Ed,EncodecFeatureExtractor:()=>bd,FeatureExtractor:()=>qu,Gemma3nAudioFeatureExtractor:()=>Dd,Gemma4AudioFeatureExtractor:()=>Od,GraniteSpeechFeatureExtractor:()=>kd,MoonshineFeatureExtractor:()=>Ad,ParakeetFeatureExtractor:()=>wd,PyAnnoteFeatureExtractor:()=>jd,SeamlessM4TFeatureExtractor:()=>Md,SnacFeatureExtractor:()=>Nd,SpeechT5FeatureExtractor:()=>Pd,VoxtralRealtimeFeatureExtractor:()=>Ld,Wav2Vec2FeatureExtractor:()=>Fd,WeSpeakerFeatureExtractor:()=>Id,WhisperFeatureExtractor:()=>Rd});var Xu={fromWeb:()=>{}};async function Zu(e,t){if(j.IS_BROWSER_ENV){if(j.IS_WEBWORKER_ENV)throw Error(`Unable to save a file from a Web Worker.`);let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),r.remove(),URL.revokeObjectURL(n)}else if(j.IS_FS_AVAILABLE){let n=t.stream();await(Xu.fromWeb(n),Er.createWriteStream(e),void 0)}else throw Error(`Unable to save because filesystem is disabled in this environment.`)}async function Qu(e,t){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 n=await(await Js(e)).arrayBuffer(),r=new AudioContext({sampleRate:t});t===void 0&&N.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let i=await r.decodeAudioData(n),a;if(i.numberOfChannels===2){let e=Math.sqrt(2),t=i.getChannelData(0),n=i.getChannelData(1);a=new Float32Array(t.length);for(let r=0;r<i.length;++r)a[r]=e*(t[r]+n[r])/2}else a=i.getChannelData(0);return a}var $u=Qu;function ed(e,t){if(e<1)return new Float64Array;if(e===1)return new Float64Array([1]);let n=1-t,r=2*Math.PI/(e-1),i=new Float64Array(e);for(let a=0;a<e;++a)i[a]=t-n*Math.cos(a*r);return i}function td(e){return ed(e,.5)}function nd(e){return ed(e,.54)}var rd={htk:e=>2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,n=15,r=27/Math.log(6.4))=>e>=t?n+Math.log(e/t)*r:3*e/200};function id(e,t=`htk`){let n=rd[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}var ad={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,n=15,r=Math.log(6.4)/27)=>e>=n?t*Math.exp(r*(e-n)):200*e/3};function od(e,t=`htk`){let n=ad[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}function sd(e,t){let n=Float64Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n]),r=Array.from({length:e.length},()=>Array(t.length));for(let n=0;n<e.length;++n){let i=r[n];for(let r=0;r<t.length;++r)i[r]=t[r]-e[n]}let i=t.length-2,a=Array.from({length:i},()=>Array(e.length));for(let t=0;t<e.length;++t){let e=r[t];for(let r=0;r<i;++r){let i=-e[r]/n[r],o=e[r+2]/n[r+1];a[r][t]=Math.max(0,Math.min(i,o))}}return a}function cd(e,t,n){let r=(t-e)/(n-1);return Float64Array.from({length:n},(t,n)=>e+r*n)}function ld(e,t,n,r,i,a=null,o=`htk`,s=!1){if(a!==null&&a!==`slaney`)throw Error(`norm must be one of null or "slaney"`);if(e<2)throw Error(`Require num_frequency_bins: ${e} >= 2`);if(n>r)throw Error(`Require min_frequency: ${n} <= max_frequency: ${r}`);let c=cd(id(n,o),id(r,o),t+2),l=od(c,o),u;if(s){let t=i/((e-1)*2);u=id(Float64Array.from({length:e},(e,n)=>n*t),o),l=c}else u=cd(0,Math.floor(i/2),e);let d=sd(u,l);if(a!==null&&a===`slaney`)for(let n=0;n<t;++n){let t=d[n],r=2/(l[n+2]-l[n]);for(let n=0;n<e;++n)t[n]*=r}return d}function ud(e,t,n){let r=new e.constructor(e.length+t+n),i=e.length-1;for(let n=0;n<e.length;++n)r[t+n]=e[n];for(let n=1;n<=t;++n)r[t-n]=e[ui(n,i)];for(let a=1;a<=n;++a)r[i+t+a]=e[ui(i-a,i)];return r}function dd(e,t,n,r,i){if(n<=0)throw Error(`reference must be greater than zero`);if(r<=0)throw Error(`min_value must be greater than zero`);n=Math.max(r,n);let a=Math.log10(n);for(let n=0;n<e.length;++n)e[n]=t*Math.log10(Math.max(r,e[n])-a);if(i!==null){if(i<=0)throw Error(`db_range must be greater than zero`);let t=fc(e)[0]-i;for(let n=0;n<e.length;++n)e[n]=Math.max(e[n],t)}return e}function fd(e,t=1,n=1e-5,r=null){return dd(e,20,t,n,r)}function pd(e,t=1,n=1e-10,r=null){return dd(e,10,t,n,r)}async function md(e,t,n,r,{fft_length:i=null,power:a=1,center:o=!0,pad_mode:s=`reflect`,onesided:c=!0,preemphasis:l=null,preemphasis_htk_flavor:u=!0,mel_filters:d=null,mel_floor:f=1e-10,log_mel:p=null,max_log_mel:m=null,reference:h=1,min_value:g=1e-10,db_range:_=null,remove_dc_offset:v=null,min_num_frames:y=null,max_num_frames:b=null,do_pad:x=!0,transpose:ee=!1,mel_offset:S=0,mel_floor_mode:te=`clamp`}={}){let C=t.length;if(i===null&&(i=n),n>i)throw Error(`frame_length (${n}) may not be larger than fft_length (${i})`);if(C!==n)throw Error(`Length of the window (${C}) must equal frame_length (${n})`);if(r<=0)throw Error(`hop_length must be greater than zero`);if(a===null&&d!==null)throw 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 Error("`preemphasis_htk_flavor=false` is not currently supported.");if(o){let t=Math.floor(n/2);switch(s){case`reflect`:e=ud(e,t,t);break;case`constant`:{let n=new e.constructor(e.length+2*t);n.set(e,t),e=n;break}case`semicausal`:{let n=new e.constructor(e.length+t);n.set(e,t),e=n;break}default:throw Error(`pad_mode="${s}" not implemented yet.`)}}let w=Math.floor(1+Math.floor((e.length-n)/r));y!==null&&w<y&&(w=y);let ne=c?Math.floor(i/2)+1:i,re=w,T=w;b!==null&&(b>w?x&&(T=b):T=re=b);let E=new gc(i),ie=new Float64Array(i),ae=new Float64Array(E.outputBufferSize),oe=new Float32Array(ne*T);for(let i=0;i<re;++i){let a=i*r,o=Math.min(e.length-a,n);o!==n&&ie.fill(0,0,n);for(let t=0;t<o;++t)ie[t]=e[a+t];if(v){let e=0;for(let t=0;t<o;++t)e+=ie[t];let t=e/o;for(let e=0;e<o;++e)ie[e]-=t}if(l!==null){for(let e=o-1;e>=1;--e)ie[e]-=l*ie[e-1];ie[0]*=1-l}for(let e=0;e<t.length;++e)ie[e]*=t[e];E.realTransform(ae,ie);for(let e=0;e<ne;++e){let t=e<<1;oe[e*T+i]=ae[t]**2+ae[t+1]**2}}if(a!==null&&a!==2){let e=a/2;for(let t=0;t<oe.length;++t)oe[t]**=e}let se=d.length,ce=await sl(new U(`float32`,d.flat(),[se,ne]),new U(`float32`,oe,[ne,T]));ee&&(ce=ce.transpose(1,0));let le=ce.data;if(te===`add`)for(let e=0;e<le.length;++e)le[e]=S+le[e]+f;else for(let e=0;e<le.length;++e)le[e]=S+Math.max(f,le[e]);if(a!==null&&p!==null){let e=Math.min(le.length,re*se);switch(p){case`log`:for(let t=0;t<e;++t)le[t]=Math.log(le[t]);break;case`log10`:for(let t=0;t<e;++t)le[t]=Math.log10(le[t]);break;case`log10_max_norm`:{for(let t=0;t<e;++t)le[t]=Math.log10(le[t]);let t=(m??fc(le)[0])-8;for(let n=0;n<e;++n)le[n]=(Math.max(le[n],t)+4)/4;break}case`dB`:if(a===1)fd(le,h,g,_);else if(a===2)pd(le,h,g,_);else throw Error(`Cannot use log_mel option '${p}' with power ${a}`);break;default:throw Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${p}'`)}}return ce}function hd(e,t,{periodic:n=!0,frame_length:r=null,center:i=!0}={}){let a=n?e+1:e,o;switch(t){case`boxcar`:o=new Float64Array(a).fill(1);break;case`hann`:case`hann_window`:o=td(a);break;case`hamming`:o=nd(a);break;case`povey`:o=td(a).map(e=>e**.85);break;default:throw Error(`Unknown window type ${t}.`)}if(n&&(o=o.subarray(0,e)),r===null||e===r)return o;if(e>r)throw Error(`Length of the window (${e}) may not be larger than frame_length (${r})`);let s=new Float64Array(r),c=i?Math.floor((r-e)/2):0;return s.set(o,c),s}function gd(e,t){let n=e.reduce((e,t)=>e+t.length,0),r=new ArrayBuffer(44),i=new DataView(r);return _d(i,0,`RIFF`),i.setUint32(4,36+n*4,!0),_d(i,8,`WAVE`),_d(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,3,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*4,!0),i.setUint16(32,4,!0),i.setUint16(34,32,!0),_d(i,36,`data`),i.setUint32(40,n*4,!0),new Blob([r,...e.map(e=>e.buffer)],{type:`audio/wav`})}function _d(e,t,n){for(let r=0;r<n.length;++r)e.setUint8(t+r,n.charCodeAt(r))}var vd=class{constructor(e,t){this.audio=e,this.sampling_rate=t}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array;if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((e,t)=>e+t.length,0),t=new Float32Array(e),n=0;for(let e of this.audio)t.set(e,n),n+=e.length;return t}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),gd(e,this.sampling_rate)}async save(e){return Zu(e,this.toBlob())}},yd=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`hann`,{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){Ju(e,`ASTFeatureExtractor`);let t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let e=this.std*2,n=t.data;for(let t=0;t<n.length;++t)n[t]=(n[t]-this.mean)/e}return{input_values:t.unsqueeze_(0)}}},bd=class extends qu{async _call(e){Ju(e,`EncodecFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=this.config.feature_size;if(e.length%t!==0)throw Error(`The length of the audio data must be a multiple of the number of channels (${t}).`);let n=[1,t,e.length/t];return{input_values:new U(`float32`,e,n)}}},xd=class extends qu{async _call(e){Ju(e,`ChatterboxFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new U(`float32`,e,t)}}},Sd=class extends qu{constructor(e){super(e),this.mel_filters=ld(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=ld(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=hd(this.config.fft_window_size,`hann`)}async _get_input_mel(e,t,n,r){let i,a=e.length-t;if(a>0)if(n===`rand_trunc`){let n=Math.floor(Cs.random()*(a+1));e=e.subarray(n,n+t),i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw Error(`Truncation strategy "${n}" not implemented`);else{if(a<0){let n=new Float64Array(t);if(n.set(e),r===`repeat`)for(let r=e.length;r<t;r+=e.length)n.set(e.subarray(0,Math.min(e.length,t-r)),r);else if(r===`repeatpad`)for(let t=e.length;t<-a;t+=e.length)n.set(e,t);e=n}if(n===`fusion`)throw Error(`Truncation strategy "${n}" not implemented`);i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return i.unsqueeze_(0)}async _extract_fbank_features(e,t,n=null){return md(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:t,log_mel:`dB`,max_num_frames:n,do_pad:!1,transpose:!0})}async _call(e,{max_length:t=null}={}){return Ju(e,`ClapFeatureExtractor`),{input_features:(await this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}},Cd=1e-5,wd=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(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 t=hd(this.config.win_length,`hann`,{periodic:!1});this.window=new Float64Array(this.config.n_fft);let n=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(t,n)}async _extract_fbank_features(e){let t=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=t*e[n-1];return await md(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){Ju(e,`ParakeetFeatureExtractor`);let t=await this._extract_fbank_features(e),n=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),r=t.data;r.fill(0,n*t.dims[1]);let[i,a]=t.dims,o=new Float64Array(a),s=new Float64Array(a);for(let e=0;e<n;++e){let t=e*a;for(let e=0;e<a;++e){let n=r[t+e];o[e]+=n,s[e]+=n*n}}let c=n>1?n-1:1;for(let e=0;e<a;++e){let t=o[e]/n,i=(s[e]-n*t*t)/c,l=1/(Math.sqrt(i)+Cd);for(let i=0;i<n;++i){let n=i*a+e;r[n]=(r[n]-t)*l}}let l=new BigInt64Array(i);return l.fill(1n,0,n),{input_features:t.unsqueeze_(0),attention_mask:new U(`int64`,l,[1,i])}}},Td=class extends wd{_apply_dither(e){let t=this.config.dither??0;if(t<=0)return e;let n=new bs(e.length);for(let r=0;r<e.length;++r)e[r]+=t*n.gauss();return e}split_audio(e){let t=this.config.max_audio_clip_s??35,n=this.config.overlap_chunk_second??5,r=this.config.min_energy_window_samples??1600,i=this.config.sampling_rate,a=Math.max(1,Math.round(t*i)),o=Math.max(1,Math.round(n*i));if(e.length<=a)return[e];let s=[],c=0,l=e.length;for(;c<l;){if(c+a>=l){s.push(e.slice(c,l));break}let t=Math.max(c,c+a-o),n=Math.min(c+a,l),i;i=n<=t?c+a:this._find_split_point_energy(e,t,n,r),i=Math.max(c+1,Math.min(i,l)),s.push(e.slice(c,i)),c=i}return s}_find_split_point_energy(e,t,n,r){let i=n-t;if(i<=r)return Math.floor((t+n)/2);let a=1/0,o=t,s=i-r;for(let n=0;n<=s;n+=r){let i=0;for(let a=0;a<r;++a){let r=e[t+n+a];i+=r*r}i=Math.sqrt(i/r),i<a&&(a=i,o=t+n)}return o}async _call(e){Ju(e,`CohereAsrFeatureExtractor`);let t=new Float64Array(e);return this._apply_dither(t),super._call(t)}},Ed=class extends bd{},Dd=class extends qu{constructor(e){super(e);let{fft_length:t,feature_size:n,min_frequency:r,max_frequency:i,sampling_rate:a,frame_length:o}=this.config,s=ld(Math.floor(1+t/2),n,r,i,a,null,`htk`,!1);this.mel_filters=s,this.window=hd(o,`hann`)}async _extract_fbank_features(e,t){return md(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:t=48e4,truncation:n=!0,padding:r=!0,pad_to_multiple_of:i=128}={}){if(Ju(e,`Gemma3nAudioFeatureExtractor`),n&&e.length>t&&(e=e.slice(0,t)),r&&e.length%i!==0){let t=i-e.length%i,n=new Float64Array(e.length+t);n.set(e),this.config.padding_value!==0&&n.fill(this.config.padding_value,e.length),e=n}let a=await this._extract_fbank_features(e,this.config.max_length),o=wl([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:o}}},Od=class extends Dd{async _extract_fbank_features(e,t){let{frame_length:n,hop_length:r,fft_length:i}=this.config,a=Math.floor(n/2),o=Math.floor((e.length+a-(n+1))/r)+1;return md(e,this.window,n,r,{fft_length:i,center:!0,pad_mode:`semicausal`,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,mel_floor_mode:`add`,remove_dc_offset:!1,transpose:!0,max_num_frames:o})}async _call(e,t={}){Ju(e,`Gemma4AudioFeatureExtractor`);let n=e.length,r=await super._call(e,t),{input_features:i}=r,[,a,o]=i.dims,{frame_length:s,hop_length:c}=this.config,l=Math.floor(s/2),u=s+1,d=new Uint8Array(n+l+(t.pad_to_multiple_of??128));d.fill(1,l,l+n);let f=new Uint8Array(a);for(let e=0;e<a;++e)f[e]=+!!d[e*c+u-1];let p=i.data;for(let e=0;e<a;++e)f[e]||p.fill(0,e*o,(e+1)*o);return r.input_features_mask=new U(`bool`,f,[1,a]),r}},kd=class extends qu{constructor(e){super(e);let{n_fft:t,win_length:n,n_mels:r,sample_rate:i}=e.melspec_kwargs;this.mel_filters=ld(Math.floor(1+t/2),r,0,i/2,i,null,`htk`);let a=hd(n,`hann`);this.window=new Float64Array(t);let o=Math.floor((t-n)/2);this.window.set(a,o)}async _call(e){Ju(e,`GraniteSpeechFeatureExtractor`);let{n_fft:t,hop_length:n,n_mels:r}=this.config.melspec_kwargs,i=1+Math.floor((e.length-1)/n),a=i-i%2;return{input_features:(await md(e,this.window,t,n,{power:2,mel_filters:this.mel_filters,log_mel:`log10_max_norm`,transpose:!0,max_num_frames:a,do_pad:!1})).view(-1,2*r).unsqueeze_(0)}}},Ad=class extends qu{async _call(e){Ju(e,`MoonshineFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new U(`float32`,e,t)}}},jd=class extends qu{async _call(e){Ju(e,`PyAnnoteFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,1,e.length];return{input_values:new U(`float32`,e,t)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,t){let n=t/this.samples_to_frames(t)/this.config.sampling_rate,r=[];for(let t of e.tolist()){let e=[],i=-1;for(let n=0;n<t.length;++n){let[r,a]=fc(oc(t[n])),[o,s]=[n,n+1];a===i?(e.at(-1).end=s,e.at(-1).score+=r):(i=a,e.push({id:a,start:o,end:s,score:r}))}r.push(e.map(({id:e,start:t,end:r,score:i})=>({id:e,start:t*n,end:r*n,confidence:i/(r-t)})))}return r}},Md=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`povey`,{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(e=>e*32768),md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:n=2,do_normalize_per_mel_bins:r=!0,return_attention_mask:i=!0}={}){Ju(e,`SeamlessM4TFeatureExtractor`);let a=await this._extract_fbank_features(e,this.config.max_length);if(r){let[e,t]=a.dims,n=a.data;for(let r=0;r<t;++r){let i=0;for(let a=0;a<e;++a)i+=n[a*t+r];let a=i/e,o=0;for(let i=0;i<e;++i)o+=(n[i*t+r]-a)**2;o/=e-1;let s=Math.sqrt(o+1e-7);for(let i=0;i<e;++i){let e=i*t+r;n[e]=(n[e]-a)/s}}}let o;if(t){let[e,t]=a.dims,r=a.data,s=e%n;if(s>0){let n=new Float32Array(t*(e+s));n.set(r),n.fill(this.config.padding_value,r.length);let c=e+s;a=new U(a.type,n,[c,t]),i&&(o=new U(`int64`,new BigInt64Array(c),[1,c]),o.data.fill(1n,0,e))}}let[s,c]=a.dims,l=this.config.stride;if(s%l!==0)throw Error(`The number of frames (${s}) must be a multiple of the stride (${l}).`);let u=a.view(1,Math.floor(s/l),c*l),d={input_features:u};if(i){let e=u.dims[1],t=new BigInt64Array(e);if(o){let e=o.data;for(let n=1,r=0;n<s;n+=l,++r)t[r]=e[n]}else t.fill(1n);d.attention_mask=new U(`int64`,t,[1,e])}return d}},Nd=class extends Ed{},Pd=class extends qu{},Fd=class extends qu{_zero_mean_unit_var_norm(e){let t=e.reduce((e,t)=>e+t,0)/e.length,n=e.reduce((e,n)=>e+(n-t)**2,0)/e.length;return e.map(e=>(e-t)/Math.sqrt(n+1e-7))}async _call(e){Ju(e,`Wav2Vec2FeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let n=[1,t.length];return{input_values:new U(`float32`,t,n),attention_mask:new U(`int64`,new BigInt64Array(t.length).fill(1n),n)}}},Id=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`hamming`,{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(e=>e*32768),md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){Ju(e,`WeSpeakerFeatureExtractor`);let t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let e=t.mean(1).data,n=t.data,[r,i,a]=t.dims;for(let t=0;t<r;++t){let r=t*i*a,o=t*a;for(let t=0;t<i;++t){let i=r+t*a;for(let t=0;t<a;++t)n[i+t]-=e[o+t]}}}return{input_features:t}}},Ld=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,`slaney`,`slaney`),this.window=hd(this.config.n_fft,`hann`)}async _extract_fbank_features(e,{center:t=!0}={}){let{n_fft:n,hop_length:r,mel_filters:i,global_log_mel_max:a}=this.config,o=Math.floor(t?e.length/r:(e.length-n)/r);return await md(e,this.window,n,r,{power:2,mel_filters:i,log_mel:`log10_max_norm`,max_log_mel:a,center:t,max_num_frames:o,do_pad:!1})}async _call(e,{center:t=!0}={}){return Ju(e,`VoxtralRealtimeFeatureExtractor`),{input_features:(await this._extract_fbank_features(e,{center:t})).unsqueeze_(0)}}},Rd=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,`slaney`,`slaney`),this.window=hd(this.config.n_fft,`hann`)}async _extract_fbank_features(e){return await md(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:t=null}={}){Ju(e,`WhisperFeatureExtractor`);let n,r=t??this.config.n_samples;return e.length>r?(e.length>this.config.n_samples&&N.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`."),n=e.slice(0,r)):(n=new Float32Array(r),n.set(e)),{input_features:(await this._extract_fbank_features(n)).unsqueeze_(0)}}},zd=class{static async from_pretrained(e,t={}){let n=await rc(e,Hu,!0,t),r=n.feature_extractor_type,i=Yu[r];if(!i)throw Error(`Unknown feature_extractor_type: '${r}'. Please report this at ${Vu}.`);return new i(n)}},Bd=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e,t=null){let n=this.tokenizer(e),r=t?await this.feature_extractor(t):{};return{...n,...r}}},Vd=new Set([`ja`,`zh`]),Hd=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!0;get_decoder_prompt_ids(e=`en`){let t=[`▁`,`<|startofcontext|>`,`<|startoftranscript|>`,`<|emo:undefined|>`,`<|${e}|>`,`<|${e}|>`,`<|pnc|>`,`<|noitn|>`,`<|notimestamp|>`,`<|nodiarize|>`];return this.tokenizer.convert_tokens_to_ids(t)}static join_chunks(e,t=`en`){let n=e.filter(e=>e&&e.trim());if(n.length===0)return``;let r=Vd.has(t)?``:` `;return[n[0].trimEnd(),...n.slice(1).map(e=>e.trim())].join(r)}async _call(e){return await this.feature_extractor(e)}},Ud={},Wd,Gd,Kd;if(j.IS_WEB_ENV)Wd=(e,t)=>{if(!self.OffscreenCanvas)throw Error(`OffscreenCanvas not supported by this environment.`);return new self.OffscreenCanvas(e,t)},Kd=self.createImageBitmap,Gd=self.ImageData;else if(Ud)Kd=async e=>{let t=(await e.metadata()).channels,{data:n,info:r}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),i=new Yd(new Uint8ClampedArray(n),r.width,r.height,r.channels);return t!==void 0&&t!==r.channels&&i.convert(t),i};else throw Error(`Unable to load image processing library.`);var qd={0:`nearest`,1:`lanczos`,2:`bilinear`,3:`bicubic`,4:`box`,5:`hamming`},Jd=new Map([[`png`,`image/png`],[`jpg`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`gif`,`image/gif`]]),Yd=class e{constructor(e,t,n,r){this.data=e,this.width=t,this.height=n,this.channels=r}get size(){return[this.width,this.height]}static async read(t){if(t instanceof e)return t;if(typeof t==`string`||t instanceof URL)return await this.fromURL(t);if(t instanceof Blob)return await this.fromBlob(t);if(typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas)return this.fromCanvas(t);throw Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!j.IS_WEB_ENV)throw Error(`fromCanvas() is only supported in browser environments.`);let n=t.getContext(`2d`).getImageData(0,0,t.width,t.height).data;return new e(n,t.width,t.height,4)}static async fromURL(e){let t=await Js(e);if(t.status!==200)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let n=await t.blob();return this.fromBlob(n)}static async fromBlob(e){if(j.IS_WEB_ENV){let t=await Kd(e),n=Wd(t.width,t.height).getContext(`2d`);return n.drawImage(t,0,0),new this(n.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}else{let t=Ud(await e.arrayBuffer());return await Kd(t)}}static fromTensor(t,n=`CHW`){if(t.dims.length!==3)throw Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(n===`CHW`)t=t.transpose(1,2,0);else if(n!==`HWC`)throw Error(`Unsupported channel format: ${n}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new e(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw Error(`Unsupported number of channels: ${t.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 t=0,n=0;t<this.data.length;t+=this.channels){let r=this.data[t],i=this.data[t+1],a=this.data[t+2];e[n++]=Math.round(.2989*r+.587*i+.114*a)}break;default:throw 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 t=0,n=0;t<this.data.length;++t)e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=this.data[t];break;case 4:for(let t=0,n=0;t<this.data.length;t+=4)e[n++]=this.data[t],e[n++]=this.data[t+1],e[n++]=this.data[t+2];break;default:throw 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 t=0,n=0;t<this.data.length;++t)e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=255;break;case 3:for(let t=0,n=0;t<this.data.length;t+=3)e[n++]=this.data[t],e[n++]=this.data[t+1],e[n++]=this.data[t+2],e[n++]=255;break;default:throw 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 Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw Error(`Expected mask to have 1 channel, but got ${e.channels}`);let t=this.data,n=e.data,r=this.width*this.height;if(this.channels===3){let e=new Uint8ClampedArray(r*4);for(let i=0,a=0,o=0;i<r;++i)e[o++]=t[a++],e[o++]=t[a++],e[o++]=t[a++],e[o++]=n[i];return this._update(e,this.width,this.height,4)}else if(this.channels===4){for(let e=0;e<r;++e)t[4*e+3]=n[e];return this}throw Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(t,n,{resample:r=2}={}){if(this.width===t&&this.height===n)return this;let i=qd[r]??r,a=oi(t),o=oi(n);if(a&&o)return this;if(a?t=n/this.height*this.width:o&&(n=t/this.width*this.height),j.IS_WEB_ENV){let r=this.channels,i=this.toCanvas(),a=Wd(t,n).getContext(`2d`);return a.drawImage(i,0,0,t,n),new e(a.getImageData(0,0,t,n).data,t,n,4).convert(r)}else{let e=this.toSharp();switch(i){case`box`:case`hamming`:(i===`box`||i===`hamming`)&&(N.warn(`Resampling method ${i} is not yet supported. Using bilinear instead.`),i=`bilinear`);case`nearest`:case`bilinear`:case`bicubic`:e=e.affine([t/this.width,0,0,n/this.height],{interpolator:i});break;case`lanczos`:e=e.resize({width:t,height:n,fit:`fill`,kernel:`lanczos3`});break;default:throw Error(`Resampling method ${i} is not supported.`)}return await Kd(e)}}async pad([t,n,r,i]){if(t=Math.max(t,0),n=Math.max(n,0),r=Math.max(r,0),i=Math.max(i,0),t===0&&n===0&&r===0&&i===0)return this;if(j.IS_WEB_ENV){let a=this.channels,o=this.toCanvas(),s=this.width+t+n,c=this.height+r+i,l=Wd(s,c).getContext(`2d`);return l.drawImage(o,0,0,this.width,this.height,t,r,this.width,this.height),new e(l.getImageData(0,0,s,c).data,s,c,4).convert(a)}else{let e=this.toSharp().extend({left:t,right:n,top:r,bottom:i});return await Kd(e)}}async crop([t,n,r,i]){if(t=Math.max(t,0),n=Math.max(n,0),r=Math.min(r,this.width-1),i=Math.min(i,this.height-1),t===0&&n===0&&r===this.width-1&&i===this.height-1)return this;let a=r-t+1,o=i-n+1;if(j.IS_WEB_ENV){let r=this.channels,i=this.toCanvas(),s=Wd(a,o).getContext(`2d`);return s.drawImage(i,t,n,a,o,0,0,a,o),new e(s.getImageData(0,0,a,o).data,a,o,4).convert(r)}else{let e=this.toSharp().extract({left:t,top:n,width:a,height:o});return await Kd(e)}}async center_crop(t,n){if(this.width===t&&this.height===n)return this;let r=(this.width-t)/2,i=(this.height-n)/2;if(j.IS_WEB_ENV){let a=this.channels,o=this.toCanvas(),s=Wd(t,n).getContext(`2d`),c=0,l=0,u=0,d=0;return r>=0?c=r:u=-r,i>=0?l=i:d=-i,s.drawImage(o,c,l,t,n,u,d,t,n),new e(s.getImageData(0,0,t,n).data,t,n,4).convert(a)}else{let e=this.toSharp();if(r>=0&&i>=0)e=e.extract({left:Math.floor(r),top:Math.floor(i),width:t,height:n});else if(r<=0&&i<=0){let a=Math.floor(-i),o=Math.floor(-r);e=e.extend({top:a,left:o,right:t-this.width-o,bottom:n-this.height-a})}else{let a=[0,0],o=0;i<0?(a[0]=Math.floor(-i),a[1]=n-this.height-a[0]):o=Math.floor(i);let s=[0,0],c=0;r<0?(s[0]=Math.floor(-r),s[1]=t-this.width-s[0]):c=Math.floor(r),e=e.extend({top:a[0],bottom:a[1],left:s[0],right:s[1]}).extract({left:c,top:o,width:t,height:n})}return await Kd(e)}}async toBlob(e=`image/png`,t=1){if(!j.IS_WEB_ENV)throw Error(`toBlob() is only supported in browser environments.`);return await this.toCanvas().convertToBlob({type:e,quality:t})}toTensor(e=`CHW`){let t=new U(`uint8`,new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!==`HWC`)if(e===`CHW`)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`);return t}toCanvas(){if(!j.IS_WEB_ENV)throw Error(`toCanvas() is only supported in browser environments.`);let e=this.clone().rgba(),t=Wd(e.width,e.height),n=new Gd(e.data,e.width,e.height);return t.getContext(`2d`).putImageData(n,0,0),t}split(){let{data:t,width:n,height:r,channels:i}=this,a=t.constructor,o=t.length/i,s=Array.from({length:i},()=>new a(o));for(let e=0;e<o;++e){let n=i*e;for(let r=0;r<i;++r)s[r][e]=t[n+r]}return s.map(t=>new e(t,n,r,1))}_update(e,t,n,r=null){return this.data=e,this.width=t,this.height=n,r!==null&&(this.channels=r),this}clone(){return new e(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 Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(j.IS_WEB_ENV){if(j.IS_WEBWORKER_ENV)throw Error(`Unable to save an image from a Web Worker.`);let t=e.split(`.`).pop().toLowerCase(),n=Jd.get(t)??`image/png`;return Zu(e,await this.toBlob(n))}else if(j.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw Error(`Unable to save the image because filesystem is disabled in this environment.`)}toSharp(){if(j.IS_WEB_ENV)throw Error(`toSharp() is only supported in server-side environments.`);return Ud(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},Xd=Yd.read.bind(Yd);function Zd(e,t,n=0,r=null){let i=e/t,a=yc(i)*t;return r!==null&&a>r&&(a=Math.floor(i)*t),a<n&&(a=Math.ceil(i)*t),a}function Qd([e,t],n){return[Math.max(Math.floor(e/n),1)*n,Math.max(Math.floor(t/n),1)*n]}function $d([e,t,n,r]){return[e-n/2,t-r/2,e+n/2,t+r/2]}function ef(e,t=.5,n=null,r=!1){let i=e.logits,a=e.pred_boxes,[o,s,c]=i.dims;if(n!==null&&n.length!==o)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let l=[];for(let e=0;e<o;++e){let o=n===null?null:n[e],u={boxes:[],classes:[],scores:[]},d=i[e],f=a[e];for(let e=0;e<s;++e){let n=d[e],i=[],a;if(r){a=n.sigmoid().data;for(let e=0;e<a.length;++e)a[e]>t&&i.push(e)}else{let e=fc(n.data)[1];if(e===c-1||(a=oc(n.data),a[e]<t))continue;i.push(e)}for(let t of i){let n=f[e].data;n=$d(n),o!==null&&(n=n.map((e,t)=>e*o[(t+1)%2])),u.boxes.push(n),u.classes.push(t),u.scores.push(a[t])}}l.push(u)}return l}function tf(e,t=null){let n=e.logits,r=n.dims[0];if(t!==null&&t.length!==r)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let i=[];for(let e=0;e<r;++e){let r=t===null?null:t[e],a=n[e];r!==null&&(a=al(a,r,`bilinear`,!1));let[o,s]=r??a.dims.slice(-2),c=new U(`int32`,new Int32Array(o*s),[o,s]),l=a[0].data,u=c.data;for(let e=1;e<a.dims[0];++e){let t=a[e].data;for(let n=0;n<t.length;++n)t[n]>l[n]&&(l[n]=t[n],u[n]=e)}let d=Array(a.dims[0]);for(let e=0;e<u.length;++e){let t=u[e];d[t]=t}let f=d.filter(e=>e!==void 0);i.push({segmentation:c,labels:f})}return i}function nf(e,t,n,r){let i=[],a=[],o=[];for(let s=0;s<e.dims[0];++s){let c=e[s],l=t[s],u=fc(c.data)[1];if(u===r)continue;let d=oc(c.data)[u];d>n&&(i.push(l),a.push(d),o.push(u))}return[i,a,o]}function rf(e,t,n,r=.5,i=.8){let a=[],o=0,s=0,c=t[n].data;for(let t=0;t<e.length;++t)e[t]===n&&(a.push(t),++o),c[t]>=r&&++s;let l=o>0&&s>0;return l&&=o/s>i,[l,a]}function af(e,t,n,r,i,a=null,o=null){let[s,c]=o??e[0].dims,l=new U(`int32`,new Int32Array(s*c),[s,c]),u=[];if(o!==null)for(let t=0;t<e.length;++t)e[t]=al(e[t],o,`bilinear`,!1);let d=new Int32Array(e[0].data.length),f=new Float32Array(e[0].data.length);for(let n=0;n<e.length;++n){let r=t[n],i=e[n].data;for(let e=0;e<i.length;++e)i[e]*=r,i[e]>f[e]&&(d[e]=n,f[e]=i[e])}let p=0,m=l.data;for(let a=0;a<n.length;++a){let o=n[a],[s,c]=rf(d,e,a,r,i);if(s){++p;for(let e of c)m[e]=p;u.push({id:p,label_id:o,score:t[a]})}}return[l,u]}function of(e,t,n=28,r=3136,i=784*1280,a=1){if(e<n||t<n){let r=Math.max(n/e,n/t);e=Math.round(e*r),t=Math.round(t*r)}if(Math.max(e,t)/Math.min(e,t)>200)throw Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let o=Math.round(e/n)*n,s=Math.round(t/n)*n;if(a*o*s>i){let r=Math.sqrt(a*e*t/i);o=Math.max(n,Math.floor(e/r/n)*n),s=Math.max(n,Math.floor(t/r/n)*n)}else if(a*o*s<r){let i=Math.sqrt(r/(a*e*t));o=Math.ceil(e*i/n)*n,s=Math.ceil(t*i/n)*n}return[s,o]}function sf(e,t=.5,n=.5,r=.8,i=null,a=null){i===null&&(N.warn("`label_ids_to_fuse` unset. No instance will be fused."),i=new Set);let o=e.class_queries_logits??e.logits,s=(e.masks_queries_logits??e.pred_masks).sigmoid(),[c,l,u]=o.dims;if(--u,a!==null&&a.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 e=0;e<c;++e){let c=a===null?null:a[e],l=o[e],f=s[e],[p,m,h]=nf(l,f,t,u);if(h.length===0){let[e,t]=c??f.dims.slice(-2),n=new U(`int32`,new Int32Array(e*t).fill(-1),[e,t]);d.push({segmentation:n,segments_info:[]});continue}let[g,_]=af(p,m,h,n,r,i,c);d.push({segmentation:g,segments_info:_})}return d}function cf(e,t=.5,n=null){throw Error("`post_process_instance_segmentation` is not yet implemented.")}var q=class extends ni{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,t,n=2){let r=e.height,i=e.width,a=t.height,o=t.width,s=Math.min(r,a),c=Math.min(i,o);return s===r&&c===i?e:(r>i?c=Math.floor(i*s/r):i>r&&(s=Math.floor(r*c/i)),await e.resize(c,s,{resample:n}))}async crop_margin(e,t=200){let n=e.clone().grayscale(),r=dc(n.data)[0],i=fc(n.data)[0]-r;if(i===0)return e;let a=t/255,o=n.width,s=n.height,c=0,l=0,u=n.data;for(let e=0;e<n.height;++e){let t=e*n.width;for(let d=0;d<n.width;++d)(u[t+d]-r)/i<a&&(o=Math.min(o,d),s=Math.min(s,e),c=Math.max(c,d),l=Math.max(l,e))}return e=await e.crop([o,s,c,l]),e}pad_image(e,t,n,{mode:r=`constant`,center:i=!1,constant_values:a=0}={}){let[o,s,c]=t,l,u;if(typeof n==`number`?(l=n,u=n):n===`square`?l=u=Math.max(o,s):(l=n.width,u=n.height),l!==s||u!==o){let n=new Float32Array(l*u*c);if(Array.isArray(a))for(let e=0;e<n.length;++e)n[e]=a[e%c];else a!==0&&n.fill(a);let[d,f]=i?[Math.floor((l-s)/2),Math.floor((u-o)/2)]:[0,0];for(let t=0;t<o;++t){let r=(t+f)*l,i=t*s;for(let t=0;t<s;++t){let a=(r+t+d)*c,o=(i+t)*c;for(let t=0;t<c;++t)n[a+t]=e[o+t]}}if(r===`symmetric`){if(i)throw Error("`center` padding is not supported when `mode` is set to `symmetric`.");let t=o-1,r=s-1;for(let i=0;i<u;++i){let a=i*l,u=ui(i,t)*s;for(let t=0;t<l;++t){if(i<o&&t<s)continue;let l=(a+t)*c,d=(u+ui(t,r))*c;for(let t=0;t<c;++t)n[l+t]=e[d+t]}}}e=n,t=[u,l,c]}return[e,t]}rescale(e){for(let t=0;t<e.length;++t)e[t]=this.rescale_factor*e[t]}get_resize_output_image_size(e,t){let[n,r]=e.size,i,a;if(this.do_thumbnail){let{height:e,width:n}=t;i=Math.min(e,n)}else Number.isInteger(t)?(i=t,a=this.config.max_size??i):t!==void 0&&(i=t.shortest_edge,a=t.longest_edge);if(i!==void 0||a!==void 0){let e=i===void 0?1:Math.max(i/n,i/r),t=n*e,o=r*e,s=a===void 0?1:Math.min(a/t,a/o),c=Math.floor(Number((t*s).toFixed(2))),l=Math.floor(Number((o*s).toFixed(2)));return this.size_divisibility!==void 0&&([c,l]=Qd([c,l],this.size_divisibility)),[c,l]}else if(t!==void 0&&t.width!==void 0&&t.height!==void 0){let e=t.width,i=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let t=i/r,a=e/n;Math.abs(1-a)<Math.abs(1-t)?t=a:a=t,i=Zd(t*r,this.config.ensure_multiple_of),e=Zd(a*n,this.config.ensure_multiple_of)}return[e,i]}else if(this.size_divisibility!==void 0)return Qd([n,r],this.size_divisibility);else throw Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}async resize(e){let[t,n]=this.get_resize_output_image_size(e,this.size);return await e.resize(t,n,{resample:this.resample})}async preprocess(e,{do_normalize:t=null,do_pad:n=null,do_convert_rgb:r=null,do_convert_grayscale:i=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[o,s]=e.size;if(r??this.do_convert_rgb?e=e.rgb():i&&(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 t,n;Number.isInteger(this.crop_size)?(t=this.crop_size,n=this.crop_size):(t=this.crop_size.width,n=this.crop_size.height),e=await e.center_crop(t,n)}let c=[e.height,e.width],l=Float32Array.from(e.data),u=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(l),t??this.do_normalize){let t=this.image_mean;Array.isArray(this.image_mean)||(t=Array(e.channels).fill(t));let n=this.image_std;if(Array.isArray(this.image_std)||(n=Array(e.channels).fill(n)),t.length!==e.channels||n.length!==e.channels)throw Error(`When set to arrays, the length of \`image_mean\` (${t.length}) and \`image_std\` (${n.length}) must match the number of channels in the image (${e.channels}).`);for(let r=0;r<l.length;r+=e.channels)for(let i=0;i<e.channels;++i)l[r+i]=(l[r+i]-t[i])/n[i]}if(n??this.do_pad){if(this.pad_size){let t=this.pad_image(l,[e.height,e.width,e.channels],this.pad_size);[l,u]=t}else if(this.size_divisibility){let e=Math.ceil(u[1]/this.size_divisibility)*this.size_divisibility,t=Math.ceil(u[0]/this.size_divisibility)*this.size_divisibility;[l,u]=this.pad_image(l,u,{width:e,height:t})}}if(a??this.do_flip_channel_order){if(u[2]!==3)throw Error(`Flipping channel order is only supported for RGB images.`);for(let e=0;e<l.length;e+=3){let t=l[e];l[e]=l[e+2],l[e+2]=t}}let d=new U(`float32`,l,u).permute(2,0,1);return{original_size:[s,o],reshaped_input_size:c,pixel_values:d}}async _call(e,...t){Array.isArray(e)||(e=[e]);let n=await Promise.all(e.map(e=>this.preprocess(e)));return{pixel_values:vl(n.map(e=>e.pixel_values),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t);return new this(n)}},lf={};Tr(lf,{BeitFeatureExtractor:()=>uf,BitImageProcessor:()=>df,CHMv2ImageProcessor:()=>pf,CLIPFeatureExtractor:()=>hf,CLIPImageProcessor:()=>mf,ChineseCLIPFeatureExtractor:()=>ff,ConvNextFeatureExtractor:()=>_f,ConvNextImageProcessor:()=>gf,DINOv3ViTImageProcessor:()=>Sf,DPTFeatureExtractor:()=>Ef,DPTImageProcessor:()=>Tf,DeiTFeatureExtractor:()=>yf,DeiTImageProcessor:()=>vf,DetrFeatureExtractor:()=>xf,DetrImageProcessor:()=>bf,DonutFeatureExtractor:()=>wf,DonutImageProcessor:()=>Cf,EfficientNetImageProcessor:()=>Df,GLPNFeatureExtractor:()=>Pf,Gemma3ImageProcessor:()=>Of,Gemma4ImageProcessor:()=>jf,Glm46VImageProcessor:()=>Nf,GroundingDinoImageProcessor:()=>Ff,Idefics3ImageProcessor:()=>If,ImageFeatureExtractor:()=>q,ImageProcessor:()=>q,JinaCLIPImageProcessor:()=>Rf,Lfm2VlImageProcessor:()=>Wf,LlavaOnevisionImageProcessor:()=>Gf,Mask2FormerImageProcessor:()=>Jf,MaskFormerFeatureExtractor:()=>qf,MaskFormerImageProcessor:()=>Kf,MobileNetV1FeatureExtractor:()=>Xf,MobileNetV1ImageProcessor:()=>Yf,MobileNetV2FeatureExtractor:()=>Qf,MobileNetV2ImageProcessor:()=>Zf,MobileNetV3FeatureExtractor:()=>ep,MobileNetV3ImageProcessor:()=>$f,MobileNetV4FeatureExtractor:()=>np,MobileNetV4ImageProcessor:()=>tp,MobileViTFeatureExtractor:()=>ip,MobileViTImageProcessor:()=>rp,NougatImageProcessor:()=>ap,OwlViTFeatureExtractor:()=>sp,OwlViTImageProcessor:()=>op,Owlv2ImageProcessor:()=>cp,Phi3VImageProcessor:()=>mp,PixtralImageProcessor:()=>hp,PvtImageProcessor:()=>gp,Qwen2VLImageProcessor:()=>Mf,RTDetrImageProcessor:()=>_p,Sam2ImageProcessor:()=>vp,Sam3ImageProcessor:()=>vp,SamImageProcessor:()=>vp,SapiensFeatureExtractor:()=>bp,SapiensImageProcessor:()=>yp,SegformerFeatureExtractor:()=>Sp,SegformerImageProcessor:()=>xp,SiglipImageProcessor:()=>Cp,SmolVLMImageProcessor:()=>If,Swin2SRImageProcessor:()=>wp,VLMImageProcessor:()=>Lf,ViTFeatureExtractor:()=>Ep,ViTImageProcessor:()=>Tp,VitMatteImageProcessor:()=>Dp,VitPoseImageProcessor:()=>Op,YolosFeatureExtractor:()=>Ap,YolosImageProcessor:()=>kp});var uf=class extends q{},df=class extends q{},ff=class extends q{},pf=class extends q{},mf=class extends q{},hf=class extends mf{},gf=class extends q{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let t=this.size?.shortest_edge;if(t===void 0)throw Error(`Size dictionary must contain 'shortest_edge' key.`);if(t<384){let n=Math.floor(t/this.crop_pct),[r,i]=this.get_resize_output_image_size(e,{shortest_edge:n});e=await e.resize(r,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},_f=class extends gf{},vf=class extends q{},yf=class extends vf{},bf=class extends q{async _call(e){let t=await super._call(e),n=wl([t.pixel_values.dims[0],64,64],1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return ef(...e)}post_process_panoptic_segmentation(...e){return sf(...e)}post_process_instance_segmentation(...e){return cf(...e)}},xf=class extends bf{},Sf=class extends q{},Cf=class extends q{pad_image(e,t,n,r={}){let[i,a,o]=t,s=this.image_mean;Array.isArray(this.image_mean)||(s=Array(o).fill(s));let c=this.image_std;Array.isArray(c)||(c=Array(o).fill(s));let l=s.map((e,t)=>-e/c[t]);return super.pad_image(e,t,n,{center:!0,constant_values:l,...r})}},wf=class extends Cf{},Tf=class extends q{},Ef=class extends Tf{},Df=class extends q{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(e=>e*e))}},Of=class extends q{};function kf(e,t,n,r,i){let a=r*n**2,o=Math.sqrt(a/(e*t)),s=i*n,c=Math.floor(o*e/s)*s,l=Math.floor(o*t/s)*s;if(c===0&&l===0)throw Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${s}.`);let u=Math.floor(r/i**2)*s;return c===0?(c=s,l=Math.min(Math.floor(t/e)*s,u)):l===0&&(l=s,c=Math.min(Math.floor(e/t)*s,u)),[c,l]}function Af(e,t,n,r,i,a,o){let s=Math.floor(t/i),c=Math.floor(n/i),l=s*c,u=i*i*r,d=new Float32Array(a*u),f=0;for(let t=0;t<s;++t)for(let a=0;a<c;++a)for(let o=0;o<i;++o){let s=(t*i+o)*n*r+a*i*r;for(let t=0;t<i;++t){let n=s+t*r;for(let t=0;t<r;++t)d[f++]=e[n+t]}}let p=new BigInt64Array(a*2).fill(-1n),m=0;for(let e=0;e<s;++e)for(let t=0;t<c;++t)p[m++]=BigInt(t),p[m++]=BigInt(e);return{patches:new U(`float32`,d,[a,u]),positions:new U(`int64`,p,[a,2]),num_soft_tokens:Math.floor(l/o**2)}}var jf=class extends ni{constructor(e){super(),this.config=e,this.patch_size=e.patch_size??16,this.max_soft_tokens=e.max_soft_tokens??280,this.pooling_kernel_size=e.pooling_kernel_size??3,this.resample=e.resample??3,this.rescale_factor=e.rescale_factor??1/255,this.do_rescale=e.do_rescale??!0,this.do_resize=e.do_resize??!0,this.do_convert_rgb=e.do_convert_rgb??!0}async _call(e){Array.isArray(e)||(e=[e]);let{patch_size:t,pooling_kernel_size:n}=this,r=this.max_soft_tokens*n**2,i=[],a=[],o=[];for(let s of e){if(this.do_convert_rgb&&(s=s.rgb()),this.do_resize){let[e,i]=kf(s.height,s.width,t,r,n);(e!==s.height||i!==s.width)&&(s=await s.resize(i,e,{resample:this.resample}))}let e=Float32Array.from(s.data);if(this.do_rescale)for(let t=0;t<e.length;++t)e[t]*=this.rescale_factor;let{patches:c,positions:l,num_soft_tokens:u}=Af(e,s.height,s.width,s.channels,t,r,n);i.push(c),a.push(l),o.push(u)}return{pixel_values:vl(i,0),image_position_ids:vl(a,0),num_soft_tokens_per_image:o}}},Mf=class extends q{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,t){let n=this.patch_size*this.merge_size;return of(e.height,e.width,n,this.min_pixels,this.max_pixels)}async _call(e,...t){let{pixel_values:n,original_sizes:r,reshaped_input_sizes:i}=await super._call(e,...t),a=n,{temporal_patch_size:o,merge_size:s,patch_size:c}=this.config;a.dims[0]===1&&(a=_l(Array.from({length:o},()=>a),0));let l=a.dims[0]/o,u=a.dims[1],d=Math.floor(a.dims[2]/c),f=Math.floor(a.dims[3]/c);return{pixel_values:a.view(l,o,u,Math.floor(d/s),s,c,Math.floor(f/s),s,c).permute(0,3,6,4,7,2,1,5,8).view(l*d*f,u*o*c*c),image_grid_thw:new U(`int64`,[l,d,f],[1,3]),original_sizes:r,reshaped_input_sizes:i}}},Nf=class extends Mf{get_resize_output_image_size(e,t){let n=this.patch_size*this.merge_size,r=this.config.temporal_patch_size??2;return of(e.height,e.width,n,this.min_pixels,this.max_pixels,r)}},Pf=class extends q{},Ff=class extends q{async _call(e){let t=await super._call(e),n=t.pixel_values.dims,r=El([n[0],n[2],n[3]]);return{...t,pixel_mask:r}}},If=class extends q{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,t){let[n,r]=e.dims.slice(-2),i=r/n;return r>=n?(r=Math.ceil(r/t)*t,n=Math.floor(r/i),n=Math.ceil(n/t)*t):(n=Math.ceil(n/t)*t,r=Math.floor(n*i),r=Math.ceil(r/t)*t),{height:n,width:r}}async _call(e,{do_image_splitting:t=null,return_row_col_info:n=!1}={}){let r;if(!Array.isArray(e))r=[[e]];else{if(e.length===0||!e[0])throw Error(`No images provided.`);r=Array.isArray(e[0])?e:[e]}let i=[],a=[],o=[],s=[],c=[];for(let e of r){let n=await Promise.all(e.map(e=>this.preprocess(e)));s.push(...n.map(e=>e.original_size)),c.push(...n.map(e=>e.reshaped_input_size)),n.forEach(e=>e.pixel_values.unsqueeze_(0));let{longest_edge:r}=this.max_image_size,l;if(t??this.do_image_splitting){let e=Array(n.length),t=Array(n.length);l=await Promise.all(n.map(async(n,i)=>{let a=this.get_resize_for_vision_encoder(n.pixel_values,r),o=await ol(n.pixel_values,{size:[a.height,a.width]}),{frames:s,num_splits_h:c,num_splits_w:l}=await this.split_image(o,this.max_image_size);return e[i]=c,t[i]=l,_l(s,0)})),a.push(e),o.push(t)}else{let e=[r,r];l=await Promise.all(n.map(t=>ol(t.pixel_values,{size:e}))),a.push(Array(n.length).fill(0)),o.push(Array(n.length).fill(0))}i.push(_l(l,0))}let l=i.length,[u,d,f,p]=i[0].dims,m,h;if(l===1)m=i[0].unsqueeze_(0),h=wl([l,u,f,p],!0);else{let e=Math.max(...i.map(e=>e.dims.at(0)));h=wl([l,e,f,p],!0);let t=h.data,n=e*f*p;for(let r=0;r<l;++r){let a=i[r].dims[0];if(a<e){i[r]=_l([i[r],wl([e-a,d,f,p],0)],0);let o=r*n+a*f*p,s=(r+1)*n;t.fill(!1,o,s)}}m=vl(i,0)}return{pixel_values:m,pixel_attention_mask:h,original_sizes:s,reshaped_input_sizes:c,...n?{rows:a,cols:o}:{}}}async split_image(e,{longest_edge:t}){let n=t,r=t,i=[],[a,o]=e.dims.slice(-2),s=0,c=0;if(a>n||o>r){s=Math.ceil(a/n),c=Math.ceil(o/r);let t=Math.ceil(a/s),l=Math.ceil(o/c);for(let n=0;n<s;++n)for(let r=0;r<c;++r){let u,d,f,p;n===s-1?(d=a-t,p=a):(d=n*t,p=(n+1)*t),r===c-1?(u=o-l,f=o):(u=r*l,f=(r+1)*l);let m=await dl(e,[d,u],[p,f],[2,3]);i.push(m)}let u=n,d=r;(a!==u||o!==d)&&(e=await ol(e,{size:[u,d]}))}return i.push(e),{frames:i,num_splits_h:s,num_splits_w:c}}},Lf=class extends q{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(e=>e*this.rescale_factor)}pad_image(e,t,n,r){return super.pad_image(e,t,n,{constant_values:this.constant_values,center:!0,...r})}},Rf=class extends q{constructor(e){let{resize_mode:t,fill_color:n,interpolation:r,size:i,...a}=e,o=t===`squash`?{width:i,height:i}:t===`shortest`?{shortest_edge:i}:{longest_edge:i},s=r===`bicubic`?3:2;super({...a,size:o,resample:s,do_center_crop:!0,crop_size:i,do_normalize:!0})}};function zf(e,t){return Math.round(e/t)*t}function Bf(e,t,n,r,i){let a=1/0,o=[1,1],s=n*r;for(let n of t){let t=Math.abs(e-n[0]/n[1]);t<a?(a=t,o=n):t===a&&s>.5*i*i*n[0]*n[1]&&(o=n)}return o}function Vf(e,t){let n=[],r=new Set;for(let i=e;i<=t;++i)for(let a=1;a<=i;++a)for(let o=1;o<=i;++o){let i=a*o;if(i>=e&&i<=t){let e=a<<16|o;r.has(e)||(r.add(e),n.push([a,o]))}}return n.sort((e,t)=>e[0]*e[1]-t[0]*t[1])}function Hf(e,t){let[n,r,i,a]=e.dims,o=Math.floor(i/t),s=Math.floor(a/t),c=t*t*r,l=e.data,u=new Float32Array(n*o*s*c),d=i*a;for(let e=0;e<n;++e){let n=e*r*d,i=e*o*s*c;for(let e=0;e<o;++e)for(let o=0;o<s;++o){let f=i+(e*s+o)*c;for(let i=0;i<t;++i){let s=(e*t+i)*a+o*t;for(let e=0;e<t;++e){let t=s+e;for(let e=0;e<r;++e)u[f++]=l[n+e*d+t]}}}}return new U(`float32`,u,[n,o*s,c])}function Uf(e,t){let[,n,r]=e.dims,i=new BigInt64Array(t);i.fill(1n,0,n);let a=e;if(n<t){let n=new Float32Array(t*r);n.set(e.data),a=new U(`float32`,n,[1,t,r])}return{padded:a,mask:new U(`int64`,i,[t])}}var Wf=class extends q{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 t=this.max_image_tokens*this.downsample_factor**2,n=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(t,n)}_is_image_too_large(e,t){let n=this.encoder_patch_size*this.downsample_factor;return Math.max(this.encoder_patch_size,zf(e,n))*Math.max(this.encoder_patch_size,zf(t,n))>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){let n=Vf(this.min_tiles,this.max_tiles),[r,i]=Bf(t/e,n,t,e,this.tile_size);return{grid_width:r,grid_height:i,target_width:this.tile_size*r,target_height:this.tile_size*i}}async _call(e,{return_row_col_info:t=null}={}){let n;n=Array.isArray(e)?Array.isArray(e[0])?e:[e]:[[e]];let r=[],i=[],a=[],o=[],s=[],c=[];for(let e of n){let t=await Promise.all(e.map(e=>this.preprocess(e,{do_pad:!1})));for(let{pixel_values:e}of t){let[,t,n]=e.dims,l=e.unsqueeze_(0),u=this.encoder_patch_size*this.downsample_factor,d=u**2,[f,p]=of(Math.max(u,t),Math.max(u,n),u,this.min_image_tokens*d,this.max_image_tokens*d).map(e=>Math.max(u,e)),m,h=1,g=1,_=this._is_image_too_large(t,n),v=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(_&&v){let{grid_width:e,grid_height:r,target_width:i,target_height:a}=this._get_grid_layout(t,n);h=r,g=e;let o=await ol(l,{size:[a,i]});m=[];for(let t=0;t<r;++t)for(let n=0;n<e;++n){let e=t*this.tile_size,r=n*this.tile_size;m.push(o.slice(null,null,[e,e+this.tile_size],[r,r+this.tile_size]))}this.use_thumbnail&&e*r!==1&&m.push(await ol(l,{size:[p,f]}))}else m=[await ol(l,{size:[p,f]})];for(let e of m){let[,,t,n]=e.dims,{padded:o,mask:s}=Uf(Hf(e,this.encoder_patch_size),this.max_num_patches);r.push(o),i.push(s),a.push([Math.floor(t/this.encoder_patch_size),Math.floor(n/this.encoder_patch_size)])}o.push(h),s.push(g),c.push([p,f])}}let l={pixel_values:_l(r,0),pixel_attention_mask:vl(i,0),spatial_shapes:new U(`int64`,BigInt64Array.from(a.flat(),BigInt),[a.length,2])};return(t??this.return_row_col_info)&&(l.image_rows=o,l.image_cols=s,l.image_sizes=c),l}},Gf=class extends q{},Kf=class extends q{post_process_panoptic_segmentation(...e){return sf(...e)}post_process_instance_segmentation(...e){return cf(...e)}},qf=class extends Kf{},Jf=class extends Kf{},Yf=class extends q{},Xf=class extends Yf{},Zf=class extends q{},Qf=class extends Zf{},$f=class extends q{},ep=class extends $f{},tp=class extends q{},np=class extends tp{},rp=class extends q{},ip=class extends rp{},ap=class extends Cf{},op=class extends q{post_process_object_detection(...e){return ef(...e)}},sp=class extends op{},cp=class extends op{},lp=336,up=[2,3],{ceil:dp,floor:fp,sqrt:pp}=Math,mp=class extends q{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,t){let{num_img_tokens:n}=this.config;return fp((fp(t/lp)*fp(e/lp)+1)*n+1+(fp(t/lp)+1)*pp(n))}get_resize_output_image_size(e,t){let n=this._num_crops,[r,i]=e.size,a=r/i,o=1;for(;o*Math.ceil(o/a)<=n;)o+=1;--o;let s=Math.floor(o*336);return[s,Math.floor(s/a)]}pad_image(e,t,n,r={}){let[i,a]=t,o=lp*dp(i/lp),s=lp*dp(a/lp),c=[1,1,1].map((e,t)=>(e-this.image_mean[t])/this.image_std[t]);return super.pad_image(e,t,{width:s,height:o},{center:!0,constant_values:c,...r})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||pp(t)%1!=0)throw Error(`num_crops must be a square number >= 4`);Array.isArray(e)||(e=[e]);let n=e.length,r=await Promise.all(e.map(e=>this.preprocess(e))),i=r.map(e=>e.original_size),a=r.map(e=>e.reshaped_input_size),o=[];for(let{pixel_values:e}of r){e.unsqueeze_(0);let[n,r]=e.dims.slice(-2),i=await ol(e,{size:[lp,lp],mode:`bicubic`});if(t>0){let a=[],s=pp(t),c=fp(r/s),l=fp(n/s);for(let t=0;t<s;++t)for(let i=0;i<s;++i){let o,u,d,f;t===s-1?(u=n-l,f=n):(u=t*l,f=(t+1)*l),i===s-1?(o=r-c,d=r):(o=i*c,d=(i+1)*c);let p=await dl(e,[u,o],[f,d],up);a.push(p)}let u=await ol(_l(a,0),{size:[lp,lp],mode:`bicubic`});o.push(_l([i,u],0))}else o.push(i)}let s=vl(o,0),c=a.map(e=>e.map(e=>lp*dp(e/lp)));return{pixel_values:s,original_sizes:i,reshaped_input_sizes:a,image_sizes:new U(`int64`,c.flat(),[n,2]),num_img_tokens:c.map(([e,t])=>this.calc_num_image_tokens_from_image_size(t,e))}}},hp=class extends q{get_resize_output_image_size(e,t){let{longest_edge:n}=t;if(n===void 0)throw Error(`size must contain 'longest_edge'`);let[r,i]=e.size,a=Math.max(r,i)/n,o=r,s=i;a>1&&(o=Math.floor(r/a),s=Math.floor(i/a));let{patch_size:c,spatial_merge_size:l}=this.config;if(!l)throw Error(`config must contain 'spatial_merge_size'`);let u=c*l,d=Math.floor((o-1)/u)+1,f=Math.floor((s-1)/u)+1;return[d*u,f*u]}},gp=class extends q{},_p=class extends q{post_process_object_detection(...e){return ef(...e)}},vp=class extends q{reshape_input_points(e,t,n,r=!1){e=structuredClone(e);let i=si(e);if(i.length===3)r||(i=[1,...i]),e=[e];else if(i.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 r=0;r<e.length;++r){let[i,a]=t[r],[o,s]=n[r],c=[s/a,o/i];for(let t=0;t<e[r].length;++t)for(let n=0;n<e[r][t].length;++n)for(let i=0;i<e[r][t][n].length;++i)e[r][t][n][i]*=c[i%2]}return new U(`float32`,Float32Array.from(e.flat(1/0)),i)}add_input_labels(e,t){let n=si(e);if(n.length===2)n=[1,...n],e=[e];else if(n.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(n.some((e,n)=>e!==t.dims[n]))throw Error(`The first ${n.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new U(`int64`,e.flat(1/0).map(BigInt),n)}async _call(e,{input_points:t=null,input_labels:n=null,input_boxes:r=null}={}){let i=await super._call(e);if(t&&(i.input_points=this.reshape_input_points(t,i.original_sizes,i.reshaped_input_sizes)),n){if(!i.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");i.input_labels=this.add_input_labels(n,i.input_points)}return r&&(i.input_boxes=this.reshape_input_points(r,i.original_sizes,i.reshaped_input_sizes,!0)),i}async post_process_masks(e,t,n,{mask_threshold:r=0,binarize:i=!0,pad_size:a=null}={}){let o=[];a=a??this.pad_size??this.size;let s=[a.height,a.width];for(let a=0;a<t.length;++a){let c=t[a],l=n[a],u=await ol(e[a],{mode:`bilinear`,size:s});if(u=u.slice(null,null,[0,l[0]],[0,l[1]]),u=await ol(u,{mode:`bilinear`,size:c}),i){let e=u.data,t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)e[n]>r&&(t[n]=1);u=new U(`bool`,t,u.dims)}o.push(u)}return o}generate_crop_boxes(e,t,{crop_n_layers:n=0,overlap_ratio:r=512/1500,points_per_crop:i=32,crop_n_points_downscale_factor:a=1}={}){}},yp=class extends q{post_process_semantic_segmentation(...e){return tf(...e)}},bp=class extends yp{},xp=class extends q{post_process_semantic_segmentation(...e){return tf(...e)}},Sp=class extends xp{},Cp=class extends q{},wp=class extends q{pad_image(e,t,n,r={}){let[i,a,o]=t;return super.pad_image(e,t,{width:a+(n-a%n)%n,height:i+(n-i%n)%n},{mode:`symmetric`,center:!1,constant_values:-1,...r})}},Tp=class extends q{},Ep=class extends Tp{},Dp=class extends q{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let n=await Promise.all(e.map(e=>this.preprocess(e))),r=await Promise.all(t.map(e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:vl(n.map((e,t)=>_l([e.pixel_values,r[t].pixel_values],0)),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}},Op=class extends q{post_process_pose_estimation(e,t,{threshold:n=null}={}){let r=e.tolist(),[i,a,o,s]=e.dims,c=[];for(let e=0;e<i;++e){let i=r[e],a=t[e],l=[];for(let e=0;e<a.length;++e){let t=a[e],r=[],c=[],u=[],d=t.at(-2)/s,f=t.at(-1)/o;for(let e=0;e<i.length;++e){let[t,a]=[0,0],o=0,s=-1/0,l=i[e];for(let e=0;e<l.length;++e){let n=l[e];for(let r=0;r<n.length;++r){let i=n[r];o+=i,s=Math.max(s,i),t+=(r+.5)*i,a+=e*i}}if(n!=null&&s<n)continue;let p=[d*t/o,f*a/o];r.push(p),u.push(e),c.push(s)}l.push({bbox:t,scores:c,labels:u,keypoints:r})}c.push(l)}return c}},kp=class extends q{post_process_object_detection(...e){return ef(...e)}},Ap=class extends kp{},jp=class{static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t),r=n.image_processor_type??n.feature_extractor_type,i=lf[r?.replace(/Fast$/,``)];return i||=(r!==void 0&&N.warn(`Image processor type '${r}' not found, assuming base ImageProcessor. Please report this at ${Vu}.`),q),new i(n)}},Mp=class extends K{static tokenizer_class=G;static image_processor_class=jp;constructor(e,t,n){super(e,t,n);let{tasks_answer_post_processing_type:r,task_prompts_without_inputs:i,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(r??{})),this.task_prompts_without_inputs=new Map(Object.entries(i??{})),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 t=[];for(let n of e)if(this.task_prompts_without_inputs.has(n))t.push(this.task_prompts_without_inputs.get(n));else{for(let[e,r]of this.task_prompts_with_input)if(n.includes(e)){t.push(r.replaceAll(`{input}`,n).replaceAll(e,``));break}t.length!==e.length&&t.push(n)}return t}post_process_generation(e,t,n){let r=this.tasks_answer_post_processing_type.get(t)??`pure_text`;e=e.replaceAll(`<s>`,``).replaceAll(`</s>`,``);let i;switch(r){case`pure_text`:i=e;break;case`description_with_bboxes`:case`bboxes`:case`phrase_grounding`:case`ocr`:let a=r===`ocr`?`quad_boxes`:`bboxes`,o=e.matchAll(this.regexes[a]),s=[],c=[];for(let[e,t,...r]of o)s.push(t?t.trim():s.at(-1)??``),c.push(r.map((e,t)=>(Number(e)+.5)/this.size_per_bin*n[t%2]));i={labels:s,[a]:c};break;default:throw Error(`Task "${t}" (of type "${r}") not yet implemented.`)}return{[t]:i}}async _call(e,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=await this.image_processor(e,n),i=t?this.tokenizer(this.construct_prompts(t),n):{};return{...r,...i}}},Np=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.image_seq_length=this.config.image_seq_length;let{boi_token:r,image_token:i,eoi_token:a}=this.tokenizer.config;this.boi_token=r,this.image_token=i,this.eoi_token=a;let o=i.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
13
|
+
`,is=`{%- `,as=` -%}`;function os(e){switch(e.operator.type){case`MultiplicativeBinaryOperator`:return 4;case`AdditiveBinaryOperator`:return 3;case`ComparisonBinaryOperator`:return 2;case`Identifier`:return e.operator.value===`and`?1:e.operator.value===`in`||e.operator.value===`not in`?2:0}return 0}function ss(e,t=` `){let n=typeof t==`number`?` `.repeat(t):t;return ls(e.body,0,n).replace(/\n$/,``)}function cs(...e){return is+e.join(` `)+as}function ls(e,t,n){return e.map(e=>us(e,t,n)).join(rs)}function us(e,t,n){let r=n.repeat(t);switch(e.type){case`Program`:return ls(e.body,t,n);case`If`:return ds(e,t,n);case`For`:return fs(e,t,n);case`Set`:return ps(e,t,n);case`Macro`:return ms(e,t,n);case`Break`:return r+cs(`break`);case`Continue`:return r+cs(`continue`);case`CallStatement`:return hs(e,t,n);case`FilterStatement`:return gs(e,t,n);case`Comment`:return r+`{# `+e.value+` #}`;default:return r+`{{- `+H(e)+` -}}`}}function ds(e,t,n){let r=n.repeat(t),i=[],a=e;for(;a&&(i.push({test:a.test,body:a.body}),a.alternate.length===1&&a.alternate[0].type===`If`);)a=a.alternate[0];let o=r+cs(`if`,H(i[0].test))+rs+ls(i[0].body,t+1,n);for(let e=1;e<i.length;++e)o+=rs+r+cs(`elif`,H(i[e].test))+rs+ls(i[e].body,t+1,n);return a&&a.alternate.length>0&&(o+=rs+r+cs(`else`)+rs+ls(a.alternate,t+1,n)),o+=rs+r+cs(`endif`),o}function fs(e,t,n){let r=n.repeat(t),i=``;if(e.iterable.type===`SelectExpression`){let t=e.iterable;i=`${H(t.lhs)} if ${H(t.test)}`}else i=H(e.iterable);let a=r+cs(`for`,H(e.loopvar),`in`,i)+rs+ls(e.body,t+1,n);return e.defaultBlock.length>0&&(a+=rs+r+cs(`else`)+rs+ls(e.defaultBlock,t+1,n)),a+=rs+r+cs(`endfor`),a}function ps(e,t,n){let r=n.repeat(t),i=H(e.assignee),a=e.value?H(e.value):``,o=r+cs(`set`,`${i}${e.value?` = `+a:``}`);return e.body.length===0?o:o+rs+ls(e.body,t+1,n)+rs+r+cs(`endset`)}function ms(e,t,n){let r=n.repeat(t),i=e.args.map(H).join(`, `);return r+cs(`macro`,`${e.name.value}(${i})`)+rs+ls(e.body,t+1,n)+rs+r+cs(`endmacro`)}function hs(e,t,n){let r=n.repeat(t),i=e.callerArgs&&e.callerArgs.length>0?`(${e.callerArgs.map(H).join(`, `)})`:``,a=H(e.call),o=r+cs(`call${i}`,a)+rs;return o+=ls(e.body,t+1,n)+rs,o+=r+cs(`endcall`),o}function gs(e,t,n){let r=n.repeat(t),i=r+cs(`filter`,e.filter.type===`Identifier`?e.filter.value:H(e.filter))+rs;return i+=ls(e.body,t+1,n)+rs,i+=r+cs(`endfilter`),i}function H(e,t=-1){switch(e.type){case`SpreadExpression`:return`*${H(e.argument)}`;case`Identifier`:return e.value;case`IntegerLiteral`:return`${e.value}`;case`FloatLiteral`:return`${e.value}`;case`StringLiteral`:return JSON.stringify(e.value);case`BinaryExpression`:{let n=e,r=os(n),i=H(n.left,r),a=H(n.right,r+1),o=`${i} ${n.operator.value} ${a}`;return r<t?`(${o})`:o}case`UnaryExpression`:{let t=e;return t.operator.value+(t.operator.value===`not`?` `:``)+H(t.argument,1/0)}case`CallExpression`:{let t=e,n=t.args.map(H).join(`, `);return`${H(t.callee)}(${n})`}case`MemberExpression`:{let t=e,n=H(t.object);[`Identifier`,`MemberExpression`,`CallExpression`,`StringLiteral`,`IntegerLiteral`,`FloatLiteral`,`ArrayLiteral`,`TupleLiteral`,`ObjectLiteral`].includes(t.object.type)||(n=`(${n})`);let r=H(t.property);return!t.computed&&t.property.type!==`Identifier`&&(r=`(${r})`),t.computed?`${n}[${r}]`:`${n}.${r}`}case`FilterExpression`:{let t=e,n=H(t.operand,1/0);return t.filter.type===`CallExpression`?`${n} | ${H(t.filter)}`:`${n} | ${t.filter.value}`}case`SelectExpression`:{let t=e;return`${H(t.lhs)} if ${H(t.test)}`}case`TestExpression`:{let t=e;return`${H(t.operand)} is${t.negate?` not`:``} ${t.test.value}`}case`ArrayLiteral`:case`TupleLiteral`:{let t=e.value.map(H),n=e.type===`ArrayLiteral`?`[]`:`()`;return`${n[0]}${t.join(`, `)}${n[1]}`}case`ObjectLiteral`:return`{${Array.from(e.value.entries()).map(([e,t])=>`${H(e)}: ${H(t)}`).join(`, `)}}`;case`SliceExpression`:{let t=e;return`${t.start?H(t.start):``}:${t.stop?H(t.stop):``}${t.step?`:${H(t.step)}`:``}`}case`KeywordArgumentExpression`:{let t=e;return`${t.key.value}=${H(t.value)}`}case`Ternary`:{let n=e,r=`${H(n.trueExpr)} if ${H(n.condition,0)} else ${H(n.falseExpr)}`;return t>-1?`(${r})`:r}default:throw Error(`Unknown expression type: ${e.type}`)}}var _s=class{parsed;constructor(e){let t=Za(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=Ao(t)}render(e){let t=new Zo;if(Qo(t),e)for(let[n,r]of Object.entries(e))t.set(n,r);return new ts(t).run(this.parsed).value}format(e){return ss(this.parsed,e?.indent||` `)}},vs={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`},ys=class e{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Er.existsSync(e),this.exists){this.status=200,this.statusText=`OK`;let t=Er.statSync(e);this.headers.set(`content-length`,t.size.toString()),this.updateContentType();let n=Er.createReadStream(e);this.body=new ReadableStream({start(e){n.on(`data`,t=>e.enqueue(t)),n.on(`end`,()=>e.close()),n.on(`error`,t=>e.error(t))},cancel(){n.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`,vs[e]??`application/octet-stream`)}clone(){let t=new e(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await Er.promises.readFile(this.filePath)).buffer}async blob(){let e=await Er.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get(`content-type`)})}async text(){return await Er.promises.readFile(this.filePath,`utf8`)}async json(){return JSON.parse(await this.text())}},bs=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(j.IS_CRYPTO_AVAILABLE){let t=new Uint32Array(1);crypto.getRandomValues(t),e=t[0]}else e=Date.now()>>>0;let t=this._mt,n=(e,t)=>Math.imul(e,t)>>>0,r=[];for(let t=e||0;t>0;t=Math.floor(t/4294967296))r.push(t&4294967295);r.length||r.push(0),t[0]=19650218;for(let e=1;e<624;++e)t[e]=n(1812433253,t[e-1]^t[e-1]>>>30)+e>>>0;let i=1,a=0;for(let e=Math.max(624,r.length);e>0;--e,++i,++a)i>=624&&(t[0]=t[623],i=1),a>=r.length&&(a=0),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1664525))+r[a]+a>>>0;for(let e=623;e>0;--e,++i)i>=624&&(t[0]=t[623],i=1),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1566083941))-i>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let t=0;t<624;++t){let n=e[t]&2147483648|e[(t+1)%624]&2147483647;e[t]=(e[(t+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let t=e[this._idx++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,t=1){let n=this._gauss_next;if(this._gauss_next=null,n===null){let e=this.random()*2*Math.PI,t=Math.sqrt(-2*Math.log(1-this.random()));n=Math.cos(e)*t,this._gauss_next=Math.sin(e)*t}return e+n*t}shuffle(e){for(let t=e.length-1;t>0;--t){let n=32-Math.clz32(t+1),r=this._int32()>>>32-n;for(;r>t;)r=this._int32()>>>32-n;let i=e[t];e[t]=e[r],e[r]=i}}choices(e,t){return e[xs(this._random_fn,t)]}};function xs(e,t){let n=0;for(let e=0;e<t.length;++e)n+=t[e];let r=e()*n;for(let e=0;e<t.length;++e)if(r-=t[e],r<0)return e;return t.length-1}var Ss=new bs,Cs=Object.freeze({Random:bs,seed:Ss.seed.bind(Ss),random:Ss.random.bind(Ss),gauss:Ss.gauss.bind(Ss),shuffle:Ss.shuffle.bind(Ss),choices:Ss.choices.bind(Ss)}),ws=e=>xs(Cs.random,e),Ts=new bs,Es=class{constructor(e){this.path=e}async match(e){let t=new ys(Dr.join(this.path,e));if(t.exists)return t}async put(e,t,n=void 0){let r=Dr.join(this.path,e),i=r+`.tmp.${j.IS_PROCESS_AVAILABLE?process.pid:Date.now()}.${Ts._int32().toString(36)}`;try{let e=t.headers.get(`Content-Length`),a=parseInt(e??`0`),o=0;await Er.promises.mkdir(Dr.dirname(r),{recursive:!0});let s=Er.createWriteStream(i),c=t.body.getReader();for(;;){let{done:e,value:t}=await c.read();if(e)break;await new Promise((e,n)=>{s.write(t,t=>{if(t){n(t);return}e()})}),o+=t.length;let r=a?o/a*100:0;n?.({progress:r,loaded:o,total:a})}await new Promise((e,t)=>{s.close(n=>n?t(n):e())}),await Er.promises.rename(i,r)}catch(e){try{await Er.promises.unlink(i)}catch{}throw e}}async delete(e){let t=Dr.join(this.path,e);try{return await Er.promises.unlink(t),!0}catch{return!1}}},Ds={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`},Os=100,ks=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function As(...e){return e=e.map((t,n)=>(n&&(t=t.replace(RegExp(`^/`),``)),n!==e.length-1&&(t=t.replace(RegExp(`/$`),``)),t)),e.join(`/`)}function js(e,t=null,n=null){let r;try{r=new URL(e)}catch{return!1}return!(t&&!t.includes(r.protocol)||n&&!n.includes(r.hostname))}function Ms(e){return!(!ks.test(e)||e.includes(`..`)||e.includes(`--`)||e.endsWith(`.git`)||e.endsWith(`.ipynb`))}function Ns(e,t,n){if(!n)return null;let r=Ds[e]??`Error (${e}) occurred while trying to load file`;throw Error(`${r}: "${t}".`)}async function Ps(e,t,n){let r=e.headers.get(`Content-Length`),i=r?parseInt(r,10):n??0;r===null&&!n&&N.warn(`Unable to determine content-length from response headers. Will expand buffer when needed.`);let a=new Uint8Array(i),o=0,s=e.body.getReader();async function c(){let{done:e,value:n}=await s.read();if(e)return;let r=o+n.length;if(r>i){i=r;let e=new Uint8Array(i);e.set(a),a=e}return a.set(n,o),o=r,t({progress:o/i*100,loaded:o,total:i}),c()}return await c(),a}function Fs(e){return js(e,[`blob:`])}function Is(e){let t;if(typeof location<`u`&&location.href)t=location.href;else if(import.meta.url)t=import.meta.url;else return e;return new URL(e,t).href}var Ls=`SHA-256`,Rs=`experimental_transformers-hash-cache`,zs=e=>({algorithm:Ls,value:e}),Bs=class{#e=null;_getHashCache=()=>(this.#e??=caches.open(Rs),this.#e);static isAvailable=()=>typeof navigator<`u`&&`crossOriginStorage`in navigator;match=async e=>{let t=await this._getFileHash(e);if(t)try{let[e]=await navigator.crossOriginStorage.requestFileHandles([zs(t)]),n=await e.getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,t)=>{let n=await this._getFileHash(e);if(n){let e=await t.blob();await this._storeBlobInCOS(e,n)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{let[n]=await navigator.crossOriginStorage.requestFileHandles([zs(t)],{create:!0}),r=await n.createWritable();await r.write(e),await r.close()};_processAndStore=async(e,t)=>{try{let n=[];for await(let e of t)n.push(e);let r=new Blob(n),i=await this._getBlobHash(r);await this._storeBlobInCOS(r,i);try{await(await this._getHashCache()).put(e,new Response(i))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let t=await this._getHashCache(),n=await t.match(e);if(n)return n.text();let r=await this._getLfsFileHash(e);return r?(await t.put(e,new Response(r)),r):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes(`/resolve/`))return null;let t=e.replace(`/resolve/`,`/raw/`);try{let e=(await fetch(t).then(e=>e.text())).match(/^oid sha256:([0-9a-f]+)$/m);return e?e[1]:null}catch{return null}};_getBlobHash=async e=>{let t=await e.arrayBuffer(),n=await crypto.subtle.digest(Ls,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}};async function Vs(e=null){let t=null;if(M.useCustomCache){if(!M.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!M.customCache.match||!M.customCache.put)throw 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");t=M.customCache}if(!t&&M.experimental_useCrossOriginStorage&&Bs.isAvailable()&&(t=new Bs),!t&&M.useBrowserCache){if(typeof caches>`u`)throw Error(`Browser cache is not available in this environment.`);try{t=await caches.open(M.cacheKey)}catch(e){N.warn(`An error occurred while opening the browser cache:`,e)}}if(!t&&M.useFSCache){if(!j.IS_FS_AVAILABLE)throw Error(`File System Cache is not available in this environment.`);t=new Es(e??M.cacheDir)}return t}async function Hs(e,...t){for(let n of t)try{let t=await e.match(n);if(t)return t}catch{continue}}var Us=new class{#e;#t;constructor(e){this.#e=e,this.#t=new Map}get(e){if(!this.#t.has(e))return;let t=this.#t.get(e);return this.#t.delete(e),this.#t.set(e,t),t}put(e,t){this.#t.has(e)&&this.#t.delete(e),this.#t.set(e,t),this.#t.size>this.#e&&this.#t.delete(this.#t.keys().next().value)}delete(e){return this.#t.delete(e)}clear(){this.#t.clear()}}(100);function Ws(e,t){let n=Us.get(e);if(n!==void 0)return n;let r=t().then(e=>e,t=>(Us.delete(e),Promise.reject(t)));return Us.put(e,r),r}async function Gs(e){if(!js(e,[`http:`,`https:`]))return null;let t=Ys(e);return t.set(`Range`,`bytes=0-0`),M.fetch(e,{method:`GET`,headers:t,cache:`no-store`})}function Ks(e,t,n={}){return Ws(JSON.stringify([e,t,n?.revision,n?.cache_dir,n?.local_files_only]),()=>qs(e,t,n))}async function qs(e,t,n){let r=await Vs(n?.cache_dir),{localPath:i,remoteURL:a,proposedCacheKey:o,validModelId:s}=Xs(e,t,n,r),c=await Zs(r,i,o);if(c!==void 0&&typeof c!=`string`){let e=c.headers.get(`content-length`),t=c.headers.get(`content-type`);return{exists:!0,size:e?parseInt(e,10):void 0,contentType:t||void 0,fromCache:!0}}if(M.allowLocalModels&&!js(i,[`http:`,`https:`]))try{let e=await Js(i);if(typeof e!=`string`&&e.status!==404){let t=e.headers.get(`content-length`),n=e.headers.get(`content-type`);return{exists:!0,size:t?parseInt(t,10):void 0,contentType:n||void 0,fromCache:!1}}}catch{}if(M.allowRemoteModels&&!n.local_files_only&&s)try{let e=await Gs(a);if(e&&e.status>=200&&e.status<300){let t,n=e.headers.get(`content-type`);if(e.status===206){let n=e.headers.get(`content-range`);if(n){let e=n.match(/bytes \d+-\d+\/(\d+)/);e&&(t=parseInt(e[1],10))}}else if(e.status===200)try{await e.body?.cancel()}catch{}if(t===void 0){let n=e.headers.get(`content-length`);t=n?parseInt(n,10):void 0}return{exists:!0,size:t,contentType:n||void 0,fromCache:!1}}}catch(e){N.warn(`Unable to fetch file metadata for "${a}": ${e}`)}return{exists:!1,fromCache:!1}}async function Js(e){return M.useFS&&!js(e,[`http:`,`https:`,`blob:`])?new ys(e instanceof URL?e.protocol===`file:`?e.pathname:e.toString():e):M.fetch(e,{headers:Ys(e)})}function Ys(e){let t=typeof process<`u`&&process?.release?.name===`node`,n=new Headers;if(t){let t=!!{}.TESTING_REMOTELY,r=M.version;if(n.set(`User-Agent`,`transformers.js/${r}; is_ci/${t};`),js(e,[`http:`,`https:`],[`huggingface.co`,`hf.co`])){let e={}.HF_TOKEN??{}.HF_ACCESS_TOKEN;e&&n.set(`Authorization`,`Bearer ${e}`)}}return n}function Xs(e,t,n={},r=null){let i=n.revision??`main`,a=As(e,t),o=Ms(e),s=o?As(M.localModelPath,a):a,c=As(M.remoteHost,M.remotePathTemplate.replaceAll(`{model}`,e).replaceAll(`{revision}`,encodeURIComponent(i)),t);return{requestURL:a,localPath:s,remoteURL:c,proposedCacheKey:r instanceof Es?i===`main`?a:As(e,i,t):c,validModelId:o}}async function Zs(e,t,n){if(e)return await Hs(e,t,n)}async function Qs(e,t,n,r,i,a,o={}){if(await n.match(r)===void 0){if(!a){let a=o.progress_callback?n=>ri(o.progress_callback,{status:`progress`,name:e,file:t,...n}):void 0;await n.put(r,i,a)}else if(typeof i!=`string`){let e=new Headers(i.headers);e.set(`content-length`,a.byteLength.toString()),await n.put(r,new Response(a,{headers:e})).catch(e=>{N.warn(`Unable to add response to browser cache: ${e}.`)})}}}async function $s(e,t,n=!0,r={},i=!1,a=null){let{requestURL:o,localPath:s,remoteURL:c,proposedCacheKey:l,validModelId:u}=Xs(e,t,r,a),d,f=!1,p;p=await Zs(a,s,l);let m=p!==void 0;if(m)d=l;else{if(M.allowLocalModels){if(!js(o,[`http:`,`https:`]))try{p=await Js(s),d=s}catch(e){N.warn(`Unable to load from local path "${s}": "${e}"`)}else if(r.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${o}.`);else if(!M.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${o}.`)}if(p===void 0||typeof p!=`string`&&p.status===404){if(r.local_files_only||!M.allowRemoteModels){if(n)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${s}".`);return null}if(!u)throw Error(`Local file missing at "${s}" and download aborted due to invalid model ID "${e}".`);if(p=await Js(c),p.status!==200)return Ns(p.status,c,n);d=l}f=a&&typeof Response<`u`&&p instanceof Response&&p.status===200}ri(r.progress_callback,{status:`download`,name:e,file:t});let h;if(!(j.IS_NODE_ENV&&i)){let n;if(typeof p!=`string`)if(!r.progress_callback)n=new Uint8Array(await p.arrayBuffer());else if(m&&typeof navigator<`u`&&/firefox/i.test(navigator.userAgent))n=new Uint8Array(await p.arrayBuffer()),ri(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n.length,total:n.length});else{let i,a=p.headers.get(`content-length`);if(a)i=parseInt(a,10);else try{let n=await Ks(e,t,r);n.size&&(i=n.size)}catch{}n=await Ps(p,n=>{ri(r.progress_callback,{status:`progress`,name:e,file:t,...n})},i)}h=n}if(f&&d&&typeof p!=`string`&&await Qs(e,t,a,d,p,h,r),j.IS_NODE_ENV&&i&&r.progress_callback&&typeof p!=`string`){let n=parseInt(p.headers.get(`content-length`),10)||0;ri(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n,total:n})}if(ri(r.progress_callback,{status:`done`,name:e,file:t}),h){if(!j.IS_NODE_ENV&&i)throw Error(`Cannot return path in a browser environment.`);return h}if(p instanceof ys)return p.filePath;let g=await a?.match(d);if(g instanceof ys)return g.filePath;if(g instanceof Response)return new Uint8Array(await g.arrayBuffer());if(typeof g==`string`)return g;throw Error(`Unable to get model file path or buffer.`)}var ec=new Map;async function tc(e,t,n=!0,r={},i=!1){if(!M.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(!M.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}ri(r.progress_callback,{status:`initiate`,name:e,file:t});let a=`${e}::${t}`,o=ec.get(a);return o||(o=$s(e,t,n,r,i,await Vs(r?.cache_dir)).then(e=>(ec.delete(a),e),e=>{throw ec.delete(a),e}),ec.set(a,o)),await o}async function nc(e,t,n=!0,r={}){let i=await tc(e,t,n,r,!1);return i===null?null:new TextDecoder(`utf-8`).decode(i)}async function rc(e,t,n=!0,r={}){let i=await nc(e,t,n,r);return i===null?{}:JSON.parse(i)}function ic(e,[t,n,r],[i,a],o=`bilinear`,s=!1){let c=a/r,l=i/n,u=new e.constructor(i*a*t),d=n*r,f=i*a;for(let o=0;o<i;++o)for(let i=0;i<a;++i){let s=o*a+i,p=(i+.5)/c-.5,m=(o+.5)/l-.5,h=Math.floor(p),g=Math.floor(m),_=Math.min(h+1,r-1),v=Math.min(g+1,n-1);h=Math.max(h,0),g=Math.max(g,0);let y=p-h,b=m-g,x=(1-y)*(1-b),ee=y*(1-b),S=(1-y)*b,te=y*b,C=g*r,w=v*r,ne=C+h,re=C+_,T=w+h,E=w+_;for(let n=0;n<t;++n){let t=n*d;u[n*f+s]=x*e[t+ne]+ee*e[t+re]+S*e[t+T]+te*e[t+E]}}return u}function ac(e,t,n){let r=Array(n.length),i=Array(n.length);for(let e=n.length-1,a=1;e>=0;--e)i[e]=a,r[e]=t[n[e]],a*=r[e];let a=n.map((e,t)=>i[n.indexOf(t)]),o=new e.constructor(e.length);for(let n=0;n<e.length;++n){let r=0;for(let e=t.length-1,i=n;e>=0;--e)r+=i%t[e]*a[e],i=Math.floor(i/t[e]);o[r]=e[n]}return[o,r]}function oc(e){let t=fc(e)[0],n=e.map(e=>Math.exp(e-t)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function sc(e){let t=fc(e)[0],n=0;for(let r=0;r<e.length;++r)n+=Math.exp(e[r]-t);let r=Math.log(n);return e.map(e=>e-t-r)}function cc(e,t){let n=0;for(let r=0;r<e.length;++r)n+=e[r]*t[r];return n}function lc(e,t){return cc(e,t)/(uc(e)*uc(t))}function uc(e){return Math.sqrt(e.reduce((e,t)=>e+t*t,0))}function dc(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]<t&&(t=e[r],n=r);return[t,n]}function fc(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r<e.length;++r)e[r]>t&&(t=e[r],n=r);return[t,n]}function pc(e){return e>0&&(e&e-1)==0}var mc=class{constructor(e){if(this.size=e|0,this.size<=1||!pc(this.size))throw 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 e=0;e<this.table.length;e+=2){let t=Math.PI*e/this.size;this.table[e]=Math.cos(t),this.table[e+1]=-Math.sin(t)}let t=0;for(let e=1;this.size>e;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<<this._width);for(let e=0;e<this._bitrev.length;++e){this._bitrev[e]=0;for(let t=0;t<this._width;t+=2){let n=this._width-t-2;this._bitrev[e]|=(e>>>t&3)<<n}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){let n=t||Array(e.length>>>1);for(let t=0;t<e.length;t+=2)n[t>>>1]=e[t];return n}toComplexArray(e,t){let n=t||this.createComplexArray();for(let t=0;t<n.length;t+=2)n[t]=e[t>>>1],n[t+1]=0;return n}transform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,-1);for(let t=0;t<e.length;++t)e[t]/=this.size}_transform4(e,t,n){let r=this._csize,i=1<<this._width,a=r/i<<1,o,s,c=this._bitrev;if(a===4)for(o=0,s=0;o<r;o+=a,++s){let n=c[s];this._singleTransform2(t,e,o,n,i)}else for(o=0,s=0;o<r;o+=a,++s){let r=c[s];this._singleTransform4(t,e,o,r,i,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>2;for(o=0;o<r;o+=a){let r=o+t-1;for(let a=o,s=0;a<r;a+=2,s+=i){let r=a,i=r+t,o=i+t,c=o+t,u=e[r],d=e[r+1],f=e[i],p=e[i+1],m=e[o],h=e[o+1],g=e[c],_=e[c+1],v=l[s],y=n*l[s+1],b=f*v-p*y,x=f*y+p*v,ee=l[2*s],S=n*l[2*s+1],te=m*ee-h*S,C=m*S+h*ee,w=l[3*s],ne=n*l[3*s+1],re=g*w-_*ne,T=g*ne+_*w,E=u+te,ie=d+C,ae=u-te,oe=d-C,se=b+re,ce=x+T,le=n*(b-re),ue=n*(x-T);e[r]=E+se,e[r+1]=ie+ce,e[i]=ae+ue,e[i+1]=oe-le,e[o]=E-se,e[o+1]=ie-ce,e[c]=ae-ue,e[c+1]=oe+le}}}}_singleTransform2(e,t,n,r,i){let a=e[r],o=e[r+1],s=e[r+i],c=e[r+i+1];t[n]=a+s,t[n+1]=o+c,t[n+2]=a-s,t[n+3]=o-c}_singleTransform4(e,t,n,r,i,a){let o=i*2,s=i*3,c=e[r],l=e[r+1],u=e[r+i],d=e[r+i+1],f=e[r+o],p=e[r+o+1],m=e[r+s],h=e[r+s+1],g=c+f,_=l+p,v=c-f,y=l-p,b=u+m,x=d+h,ee=a*(u-m),S=a*(d-h);t[n]=g+b,t[n+1]=_+x,t[n+2]=v+S,t[n+3]=y-ee,t[n+4]=g-b,t[n+5]=_-x,t[n+6]=v-S,t[n+7]=y+ee}_realTransform4(e,t,n){let r=this._csize,i=1<<this._width,a=r/i<<1,o,s,c=this._bitrev;if(a===4)for(o=0,s=0;o<r;o+=a,++s){let n=c[s];this._singleRealTransform2(t,e,o,n>>>1,i>>>1)}else for(o=0,s=0;o<r;o+=a,++s){let r=c[s];this._singleRealTransform4(t,e,o,r>>>1,i>>>1,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>1,s=t>>>1,c=s>>>1;for(o=0;o<r;o+=a)for(let r=0,a=0;r<=c;r+=2,a+=i){let i=o+r,u=i+s,d=u+s,f=d+s,p=e[i],m=e[i+1],h=e[u],g=e[u+1],_=e[d],v=e[d+1],y=e[f],b=e[f+1],x=p,ee=m,S=l[a],te=n*l[a+1],C=h*S-g*te,w=h*te+g*S,ne=l[2*a],re=n*l[2*a+1],T=_*ne-v*re,E=_*re+v*ne,ie=l[3*a],ae=n*l[3*a+1],oe=y*ie-b*ae,se=y*ae+b*ie,ce=x+T,le=ee+E,ue=x-T,de=ee-E,fe=C+oe,pe=w+se,me=n*(C-oe),he=n*(w-se);if(e[i]=ce+fe,e[i+1]=le+pe,e[u]=ue+he,e[u+1]=de-me,r===0){e[d]=ce-fe,e[d+1]=le-pe;continue}if(r===c)continue;let ge=o+s-r,_e=o+t-r;e[ge]=ue-n*he,e[ge+1]=-de-n*me,e[_e]=ce-n*fe,e[_e+1]=-le+n*pe}}let u=r>>>1;for(let t=2;t<u;t+=2)e[r-t]=e[t],e[r-t+1]=-e[t+1]}_singleRealTransform2(e,t,n,r,i){let a=e[r],o=e[r+i];t[n]=a+o,t[n+1]=0,t[n+2]=a-o,t[n+3]=0}_singleRealTransform4(e,t,n,r,i,a){let o=i*2,s=i*3,c=e[r],l=e[r+i],u=e[r+o],d=e[r+s],f=c+u,p=c-u,m=l+d,h=a*(l-d);t[n]=f+m,t[n+1]=0,t[n+2]=p,t[n+3]=-h,t[n+4]=f-m,t[n+5]=0,t[n+6]=p,t[n+7]=h}},hc=class{constructor(e){let t=2*(e-1),n=2*(2*e-1),r=2**Math.ceil(Math.log2(n));this.bufferSize=r,this._a=t;let i=new Float64Array(n),a=new Float64Array(r);this._chirpBuffer=new Float64Array(r),this._buffer1=new Float64Array(r),this._buffer2=new Float64Array(r),this._outBuffer1=new Float64Array(r),this._outBuffer2=new Float64Array(r);let o=-2*Math.PI/e,s=Math.cos(o),c=Math.sin(o);for(let t=0;t<n>>1;++t){let n=(t+1-e)**2/2,r=Math.sqrt(s**2+c**2)**n,o=n*Math.atan2(c,s),l=2*t;i[l]=r*Math.cos(o),i[l+1]=r*Math.sin(o),a[l]=i[l],a[l+1]=-i[l+1]}this._slicedChirpBuffer=i.subarray(t,n),this._f=new mc(r>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,n){let r=this._buffer1,i=this._buffer2,a=this._outBuffer1,o=this._outBuffer2,s=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(n)for(let e=0;e<c.length;e+=2){let n=e+1,i=t[e>>1];r[e]=i*c[e],r[n]=i*c[n]}else for(let e=0;e<c.length;e+=2){let n=e+1;r[e]=t[e]*c[e]-t[n]*c[n],r[n]=t[e]*c[n]+t[n]*c[e]}this._f.transform(a,r);for(let e=0;e<s.length;e+=2){let t=e+1;i[e]=a[e]*s[e]-a[t]*s[t],i[t]=a[e]*s[t]+a[t]*s[e]}this._f.inverseTransform(o,i);for(let t=0;t<o.length;t+=2){let n=o[t+l],r=o[t+l+1],i=c[t],a=c[t+1];e[t]=n*i-r*a,e[t+1]=n*a+r*i}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}},gc=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=pc(e),this.isPowerOfTwo?(this.fft=new mc(e),this.outputBufferSize=2*e):(this.fft=new hc(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}};function _c(e,t){if(t%2==0||t<=0)throw Error(`Window size must be a positive odd number`);let n=new e.constructor(e.length),r=new e.constructor(t),i=Math.floor(t/2);for(let t=0;t<e.length;++t){let a=0;for(let n=-i;n<=i;++n){let i=t+n;i<0?i=Math.abs(i):i>=e.length&&(i=2*(e.length-1)-i),r[a++]=e[i]}r.sort(),n[t]=r[i]}return n}function vc(e,t){let n=10**t;return Math.round(e*n)/n}function yc(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}function bc(e){let t=e.length,n=e[0].length,r=[t+1,n+1],i=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));i[0][0]=0;let a=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let t=1;t<r[1];++t)for(let n=1;n<r[0];++n){let r=i[n-1][t-1],o=i[n-1][t],s=i[n][t-1],c,l;r<o&&r<s?(c=r,l=0):o<r&&o<s?(c=o,l=1):(c=s,l=2),i[n][t]=e[n-1][t-1]+c,a[n][t]=l}for(let e=0;e<r[1];++e)a[0][e]=2;for(let e=0;e<r[0];++e)a[e][0]=1;let o=t,s=n,c=[],l=[];for(;o>0||s>0;)switch(c.push(o-1),l.push(s-1),a[o][s]){case 0:--o,--s;break;case 1:--o;break;case 2:--s;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${s}]. Please file a bug report.`)}return c.reverse(),l.reverse(),[c,l]}var xc=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);let t=new ArrayBuffer(4),n=new Uint32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;++t){let i=0,a=(t&32768)<<16,o=(t&31744)>>10,s=t&1023;if(o===31)i=a|2139095040|s<<13;else if(o===0)if(s===0)i=a;else{let e=113;for(;!(s&1024);)s<<=1,--e;s&=-1025,i=a|e<<23|s<<13}else i=a|o+112<<23|s<<13;n[0]=i,e[t]=r[0]}}let n=t.length,r=e,i=new Float32Array(n);for(let e=0;e<n;++e)i[e]=r[t[e]];return i}})(),Sc={};Tr(Sc,{default:()=>Cc});var Cc={};async function wc(e){let t=e.split(`/`).pop(),n;try{if(n=await Vs(),n){let t=await n.match(e);if(t)return t}}catch(e){N.warn(`Failed to load ${t} from cache:`,e)}let r=await M.fetch(e);if(!r.ok)throw Error(`Failed to fetch ${t}: ${r.status} ${r.statusText}`);if(n)try{await n.put(e,r.clone())}catch(e){N.warn(`Failed to cache ${t}:`,e)}return r}async function Tc(e){let t=await wc(e);if(!t||typeof t==`string`)return null;try{return await t.arrayBuffer()}catch(e){return N.warn(`Failed to read WASM binary:`,e),null}}async function Ec(e){if(j.IS_SERVICE_WORKER_ENV||j.IS_CHROME_AVAILABLE)return e;let t=await wc(e);if(!t||typeof t==`string`)return null;try{let e=await t.text();e=e.replaceAll(`globalThis.process?.versions?.node`,`false`);let n=new Blob([e],{type:`text/javascript`});return URL.createObjectURL(n)}catch(e){return N.warn(`Failed to read WASM factory:`,e),null}}var Dc=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 Oc(e){return e<=$r.DEBUG?0:e<=$r.INFO?2:e<=$r.WARNING||e<=$r.ERROR?3:4}var kc={0:`verbose`,1:`info`,2:`warning`,3:`error`,4:`fatal`},Ac=[],jc,Mc,Nc=Symbol.for(`onnxruntime`);if(Nc in globalThis)Mc=globalThis[Nc];else if(j.IS_NODE_ENV){switch(Mc=Sc,process.platform){case`win32`:Ac.push(`dml`);break;case`linux`:process.arch===`x64`&&Ac.push(`cuda`);break;case`darwin`:Ac.push(`coreml`);break}Ac.push(`webgpu`),Ac.push(`cpu`),jc=[`cpu`]}else Mc=r,j.IS_WEBNN_AVAILABLE&&Ac.push(`webnn-npu`,`webnn-gpu`,`webnn-cpu`,`webnn`),j.IS_WEBGPU_AVAILABLE&&Ac.push(`webgpu`),Ac.push(`wasm`),jc=[`wasm`];var Pc=Mc.InferenceSession;function Fc(e=null){if(!e)return jc;switch(e){case`auto`:return Ac;case`gpu`:return Ac.filter(e=>[`webgpu`,`cuda`,`dml`,`webnn-gpu`].includes(e))}if(Ac.includes(e))return[Dc[e]??e];throw Error(`Unsupported device: "${e}". Should be one of: ${Ac.join(`, `)}.`)}var Ic=Promise.resolve(),Lc=null;async function Rc(){if(Lc)return Lc;if(!(M.useWasmCache&&typeof Uc?.wasm?.wasmPaths==`object`&&Uc?.wasm?.wasmPaths?.wasm&&Uc?.wasm?.wasmPaths?.mjs)){if(j.IS_DENO_WEB_RUNTIME)throw Error(`env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.`);return Lc=Promise.resolve(),Lc}return Lc=(async()=>{let e=Uc.wasm.wasmPaths,t=!1;await Promise.all([e.wasm&&!Fs(e.wasm)?(async()=>{try{let n=await Tc(Is(e.wasm));n&&(Uc.wasm.wasmBinary=n,t=!0)}catch(e){N.warn(`Failed to pre-load WASM binary:`,e)}})():Promise.resolve(),e.mjs&&!Fs(e.mjs)?(async()=>{try{let t=await Ec(Is(e.mjs));t&&(Uc.wasm.wasmPaths.mjs=t)}catch(e){N.warn(`Failed to pre-load WASM factory:`,e)}})():Promise.resolve()]),t||(Uc.wasm.wasmPaths.mjs=e.mjs)})(),Lc}async function zc(e,t,n){await Rc();let r=Oc(M.logLevel??$r.WARNING),i=()=>Pc.create(e,{logSeverityLevel:r,...t}),a=await(j.IS_WEB_ENV?Ic=Ic.then(i):i());return a.config=n,a}var Bc=Promise.resolve();async function Vc(e,t){let n=()=>e.run(t);return j.IS_WEB_ENV?Bc=Bc.then(n):n()}function Hc(e){return e instanceof Mc.Tensor}var Uc=Mc?.env;function Wc(){return Uc?.wasm?.proxy}if(Uc){let e=function(e){Uc.logLevel=kc[Oc(e)]};if(Uc.wasm){if(!(typeof ServiceWorkerGlobalScope<`u`&&self instanceof ServiceWorkerGlobalScope)&&Uc.versions?.web&&!Uc.wasm.wasmPaths){let e=`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@${Uc.versions.web}/dist/`;Uc.wasm.wasmPaths=j.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.26.0-dev.20260416-b7804b056c/dist/ort-wasm-simd-threaded.asyncify.wasm`}}Uc.wasm.proxy=!1}Uc.webgpu&&(Uc.webgpu.powerPreference=`high-performance`),e(M.logLevel??$r.WARNING),M.backends.onnx={...Uc,setLogLevel:e}}var Gc=async(e,t,n)=>{let r=await zc(new Uint8Array(e),t);return(async e=>{let t=Wc(),i=Object.fromEntries(Object.entries(e).map(([e,n])=>[e,(t?n.clone():n).ort_tensor])),a=await Vc(r,i);return Array.isArray(n)?n.map(e=>new U(a[e])):new U(a[n])})},Kc=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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||=Gc([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}},qc=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`}),Jc=j.IS_NODE_ENV?`cpu`:`wasm`;function Yc(e,t,{warn:n}={}){return e?typeof e==`string`?e:e.hasOwnProperty(t)?e[t]:(n&&n(`device not specified for "${t}". Using the default device (${Jc}).`),Jc):Jc}var Xc=(function(){let e;return async function(){if(e===void 0)if(!j.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has(`shader-f16`)}catch{e=!1}return e}})(),Zc=Object.freeze({auto:`auto`,fp32:`fp32`,fp16:`fp16`,q8:`q8`,int8:`int8`,uint8:`uint8`,q4:`q4`,bnb4:`bnb4`,q4f16:`q4f16`,q2:`q2`,q2f16:`q2f16`,q1:`q1`,q1f16:`q1f16`}),Qc=Zc.fp32,$c=Object.freeze({[qc.wasm]:Zc.q8}),el=Object.freeze({[Zc.fp32]:``,[Zc.fp16]:`_fp16`,[Zc.int8]:`_int8`,[Zc.uint8]:`_uint8`,[Zc.q8]:`_quantized`,[Zc.q4]:`_q4`,[Zc.q2]:`_q2`,[Zc.q1]:`_q1`,[Zc.q4f16]:`_q4f16`,[Zc.q2f16]:`_q2f16`,[Zc.q1f16]:`_q1f16`,[Zc.bnb4]:`_bnb4`});function tl(e,t,n,{configDtype:r=null,warn:i}={}){let a,o=!1;e&&typeof e!=`string`?e.hasOwnProperty(t)?a=e[t]:(a=null,o=!0):a=e;let s;if(a===Zc.auto){if(r){let e=typeof r==`string`?r:r?.[t];if(e&&e!==Zc.auto&&Zc.hasOwnProperty(e))return e}s=$c[n]??Qc}else s=a&&Zc.hasOwnProperty(a)?a:$c[n]??Qc;return o&&i&&i(`dtype not specified for "${t}". Using the default dtype (${s}) for this device (${n}).`),s}var nl=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}),U=class e{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 Hc(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new Cr(e[0],e[1],e[2]),new Proxy(this,{get:(e,t)=>{if(typeof t==`string`){let n=Number(t);if(Number.isInteger(n))return e._getitem(n)}return e[t]},set:(e,t,n)=>e[t]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let n=t.reduce((e,t)=>e*t);for(let r=0;r<e;++r)yield this._subarray(r,n,t)}else yield*this.data}_getitem(t){let[n,...r]=this.dims;if(t=gl(t,n),r.length>0){let e=r.reduce((e,t)=>e*t);return this._subarray(t,e,r)}else return new e(this.type,[this.data[t]],r)}indexOf(e){let t=this.data;for(let n=0;n<t.length;++n)if(t[n]==e)return n;return-1}_subarray(t,n,r){let i=t*n,a=(t+1)*n,o=`subarray`in this.data?this.data.subarray(i,a):this.data.slice(i,a);return new e(this.type,o,r)}item(){let e=this.data;if(e.length!==1)throw Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return rl(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=1/(1+Math.exp(-e[t]));return this}map(e){return this.clone().map_(e)}map_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]=e(t[n],n,t);return this}mul(e){return this.clone().mul_(e)}mul_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let t=this.data;for(let n=0;n<t.length;++n)t[n]-=e;return this}clone(){return new e(this.type,this.data.slice(),this.dims.slice())}slice(...t){let n=[],r=[];for(let e=0;e<this.dims.length;++e){let i=t[e];if(i==null)r.push([0,this.dims[e]]),n.push(this.dims[e]);else if(typeof i==`number`)i=gl(i,this.dims[e],e),r.push([i,i+1]);else if(Array.isArray(i)&&i.length===2){let[t,a]=i;if(t=t===null?0:gl(t,this.dims[e],e,!1),a=a===null?this.dims[e]:gl(a,this.dims[e],e,!1),t>a)throw Error(`Invalid slice: ${i}`);let o=[Math.max(t,0),Math.min(a,this.dims[e])];r.push(o),n.push(o[1]-o[0])}else throw Error(`Invalid slice: ${i}`)}let i=r.map(([e,t])=>t-e),a=i.reduce((e,t)=>e*t),o=this.data,s=new o.constructor(a),c=this.stride(),l=!0;for(let e=1;e<i.length;++e)if(r[e][0]!==0||r[e][1]!==this.dims[e]){l=!1;break}if(l){let e=r[0][0]*c[0],t=r[0][1]*c[0];if(ArrayBuffer.isView(o))s.set(o.subarray(e,t));else if(Array.isArray(o)){let n=o.slice(e,t);for(let e=0;e<n.length;++e)s[e]=n[e]}else throw Error(`Unsupported data type for slicing`)}else for(let e=0;e<a;++e){let t=0;for(let n=i.length-1,a=e;n>=0;--n){let e=i[n];t+=(a%e+r[n][0])*c[n],a=Math.floor(a/e)}s[e]=o[t]}return new e(this.type,s,n)}permute(...e){return il(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(t=`fro`,n=null,r=!1){if(t===`fro`)t=2;else if(typeof t==`string`)throw Error(`Unsupported norm: ${t}`);let i=this.data,a=i instanceof BigInt64Array||i instanceof BigUint64Array;if(a&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let o,s;if(a?(o=(e,t)=>e+t,s=0n):(o=(e,n)=>e+n**t,s=0),n===null){let n=i.reduce(o,s);return t!==1&&(n**=1/t),new e(this.type,[n],[])}let[c,l,u]=yl(o,this,n,r);if(t!==1)for(let e=0;e<l.length;++e)l[e]=l[e]**(1/t);return new e(c,l,u)}normalize_(e=2,t=1){t=gl(t,this.dims.length);let n=this.norm(e,t,!0),r=this.data,i=n.data;for(let e=0;e<r.length;++e){let n=0;for(let r=this.dims.length-1,i=e,a=1;r>=0;--r){let e=this.dims[r];if(r!==t){let t=i%e;n+=t*a,a*=this.dims[r]}i=Math.floor(i/e)}r[e]/=i[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return Sl(this.dims)}squeeze(t=null){return new e(this.type,this.data,ml(this.dims,t))}squeeze_(e=null){return this.dims=ml(this.dims,e),this}unsqueeze(t){return new e(this.type,this.data,hl(this.dims,t))}unsqueeze_(e){return this.dims=hl(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let n=this.dims.slice(0,e),r=this.dims.slice(e,t+1),i=this.dims.slice(t+1);return this.dims=[...n,r.reduce((e,t)=>e*t,1),...i],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...t){let n=-1;for(let e=0;e<t.length;++e)if(t[e]===-1){if(n!==-1)throw Error(`Only one dimension can be inferred`);n=e}let r=this.data;if(n!==-1){let e=t.reduce((e,t,r)=>r===n?e:e*t,1);t[n]=r.length/e}return new e(this.type,r,t)}neg_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=-e[t];return this}neg(){return this.clone().neg_()}gt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;e<r.length;++e)n[e]=+(r[e]>t);return new e(`bool`,n,this.dims)}lt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;e<r.length;++e)n[e]=+(r[e]<t);return new e(`bool`,n,this.dims)}clamp_(e,t){let n=this.data;for(let r=0;r<n.length;++r)n[r]=Math.min(Math.max(n[r],e),t);return this}clamp(e,t){return this.clone().clamp_(e,t)}round_(){let e=this.data;for(let t=0;t<e.length;++t)e[t]=Math.round(e[t]);return this}round(){return this.clone().round_()}mean(e=null,t=!1){return xl(this,e,t)}min(t=null,n=!1){if(t===null){let t=dc(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=yl((e,t)=>Math.min(e,t),this,t,n,1/0);return new e(r,i,a)}max(t=null,n=!1){if(t===null){let t=fc(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=yl((e,t)=>Math.max(e,t),this,t,n,-1/0);return new e(r,i,a)}argmin(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=dc(this.data)[1];return new e(`int64`,[BigInt(r)],[])}argmax(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=fc(this.data)[1];return new e(`int64`,[BigInt(r)],[])}repeat(...t){if(t.length<this.dims.length)throw Error(`Number of dimensions of repeat dims (${t.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(t.every(e=>e===1)){if(t.length===this.dims.length)return this.clone();let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims);return new e(this.type,this.data.slice(),r)}let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims),i=r.map((e,n)=>e*t[n]),a=i.reduce((e,t)=>e*t,1),o=this.data,s=new o.constructor(a),c=Sl(r),l=Sl(i);for(let e=0;e<a;++e){let t=e,n=0;for(let e=0;e<i.length;++e){let i=Math.floor(t/l[e]);t%=l[e];let a=i%r[e];n+=a*c[e]}s[e]=o[n]}return new e(this.type,s,i)}tile(...e){if(e.length<this.dims.length){let t=this.dims.length-e.length;e=Array(t).fill(1).concat(e)}return this.repeat(...e)}to(t){if(this.type===t)return this;if(!nl.hasOwnProperty(t))throw Error(`Unsupported type: ${t}`);let n,r=[`int64`,`uint64`].includes(this.type),i=[`int64`,`uint64`].includes(t);if(r&&!i)n=Number;else if(!r&&i)n=[`float16`,`float32`,`float64`].includes(this.type)?e=>BigInt(Math.floor(e)):BigInt;else if(this.type===`float16`&&t==`float32`&&this.data instanceof Uint16Array)return new e(t,xc(this.data),this.dims);return new e(t,nl[t].from(this.data,n),this.dims)}};function rl(e,t){let n=e.length;if(n!==t.reduce((e,t)=>e*t))throw Error(`cannot reshape array of size ${n} into shape (${t})`);let r=e;for(let e=t.length-1;e>=0;e--)r=r.reduce((n,r)=>{let i=n[n.length-1];return i.length<t[e]?i.push(r):n.push([r]),n},[[]]);return r[0]}function il(e,t){let[n,r]=ac(e.data,e.dims,t);return new U(e.type,n,r)}function al(e,[t,n],r=`bilinear`,i=!1){let a=e.dims.at(-3)??1,o=e.dims.at(-2),s=e.dims.at(-1),c=ic(e.data,[a,o,s],[t,n],r,i);return new U(e.type,c,[a,t,n])}async function ol(e,{size:t=null,mode:n=`bilinear`}={}){if(e.dims.length!==4)throw Error("`interpolate_4d` currently only supports 4D input.");if(!t)throw Error("`interpolate_4d` requires a `size` argument.");let r;if(t.length===2)r=[...e.dims.slice(0,2),...t];else if(t.length===3)r=[e.dims[0],...t];else if(t.length===4)r=t;else throw Error("`size` must be of length 2, 3, or 4.");let i;if(n===`nearest`)i=await Kc.nearest_interpolate_4d;else if(n===`bilinear`)i=await Kc.bilinear_interpolate_4d;else if(n===`bicubic`)i=await Kc.bicubic_interpolate_4d;else throw Error(`Unsupported mode: ${n}`);let a=new U(`int64`,new BigInt64Array(r.map(BigInt)),[r.length]);return await i({x:e,s:a})}async function sl(e,t){return await(await Kc.matmul)({a:e,b:t})}async function cl(e,t){return await(await Kc.rfft)({x:e,a:t})}async function ll(e,t){let n=await Kc.top_k;return t=t==null?e.dims.at(-1):Math.min(t,e.dims.at(-1)),await n({x:e,k:new U(`int64`,[BigInt(t)],[1])})}var ul=e=>new U(`int64`,e,[e.length]);async function dl(e,t,n,r,i){return await(await Kc.slice)({x:e,s:ul(t),e:ul(n),a:ul(r),t:ul(i??Array(r.length).fill(1))})}function fl(e,t){let n=e.data,r=t.data,i=[e.dims[0],e.dims[2]],a=new n.constructor(i[0]*i[1]),[o,s,c]=e.dims,l=0;for(let e=0;e<o;++e){let t=e*c*s;for(let i=0;i<c;++i){let o=0,u=0,d=e*s,f=t+i;for(let e=0;e<s;++e){let t=Number(r[d+e]);u+=t,o+=n[f+e*c]*t}let p=o/u;a[l++]=p}}return new U(e.type,a,i)}function pl(e,t,{eps:n=1e-5}={}){if(e.dims.length!==2)throw Error("`layer_norm` currently only supports 2D input.");let[r,i]=e.dims;if(t.length!==1&&t[0]!==i)throw Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[a,o]=bl(e,1,0,!0),s=a.data,c=o.data,l=e.data,u=new l.constructor(l.length);for(let e=0;e<r;++e){let t=e*i;for(let r=0;r<i;++r){let i=t+r;u[i]=(l[i]-c[e])/(s[e]+n)}}return new U(e.type,u,e.dims)}function ml(e,t){return e=e.slice(),t===null?e=e.filter(e=>e!==1):typeof t==`number`?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((e,n)=>e!==1||!t.includes(n))),e}function hl(e,t){return t=gl(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function gl(e,t,n=null,r=!0){if(e<-t||e>=t){if(r)throw Error(`IndexError: index ${e} is out of bounds for dimension${n===null?``:` `+n} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function _l(e,t=0){t=gl(t,e[0].dims.length);let n=e[0].dims.slice();n[t]=e.reduce((e,n)=>e+n.dims[t],0);let r=n.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(r),a=e[0].type;if(t===0){let t=0;for(let n of e){let e=n.data;i.set(e,t),t+=e.length}}else{let r=0;for(let a=0;a<e.length;++a){let{data:o,dims:s}=e[a];for(let e=0;e<o.length;++e){let a=0;for(let i=s.length-1,o=e,c=1;i>=0;--i){let e=s[i],l=o%e;i===t&&(l+=r),a+=l*c,c*=n[i],o=Math.floor(o/e)}i[a]=o[e]}r+=s[t]}}return new U(a,i,n)}function vl(e,t=0){return _l(e.map(e=>e.unsqueeze(t)),t)}function yl(e,t,n,r=!1,i=null){let a=t.data,o=t.dims;n=gl(n,o.length);let s=o.slice();s[n]=1;let c=new a.constructor(a.length/o[n]);i!==null&&c.fill(i);for(let t=0;t<a.length;++t){let r=0;for(let e=o.length-1,i=t,a=1;e>=0;--e){let t=o[e];if(e!==n){let n=i%t;r+=n*a,a*=s[e]}i=Math.floor(i/t)}c[r]=e(c[r],a[t],t,r)}return r||s.splice(n,1),[t.type,c,s]}function bl(e,t=null,n=1,r=!1){let i=e.data,a=e.dims;if(t===null){let t=i.reduce((e,t)=>e+t,0)/i.length,r=Math.sqrt(i.reduce((e,n)=>e+(n-t)**2,0)/(i.length-n)),a=new U(e.type,[t],[]);return[new U(e.type,[r],[]),a]}t=gl(t,a.length);let o=xl(e,t,r),s=o.data,[c,l,u]=yl((e,t,n,r)=>e+(t-s[r])**2,e,t,r);for(let e=0;e<l.length;++e)l[e]=Math.sqrt(l[e]/(a[t]-n));return[new U(c,l,u),o]}function xl(e,t=null,n=!1){let r=e.dims,i=e.data;if(t===null){let t=i.reduce((e,t)=>e+t,0);return new U(e.type,[t/i.length],[])}t=gl(t,r.length);let[a,o,s]=yl((e,t)=>e+t,e,t,n);if(r[t]!==1)for(let e=0;e<o.length;++e)o[e]/=r[t];return new U(a,o,s)}function Sl(e){let t=Array(e.length);for(let n=e.length-1,r=1;n>=0;--n)t[n]=r,r*=e[n];return t}function Cl(e,t,n,r){return new U(n,new r(e.reduce((e,t)=>e*t,1)).fill(t),e)}function wl(e,t){let n,r;if(typeof t==`number`)n=`float32`,r=Float32Array;else if(typeof t==`bigint`)n=`int64`,r=BigInt64Array;else if(typeof t==`boolean`)n=`bool`,r=Uint8Array;else throw Error(`Unsupported data type: ${typeof t}`);return Cl(e,t,n,r)}function Tl(e,t){return wl(e.dims,t)}function El(e){return Cl(e,1n,`int64`,BigInt64Array)}function Dl(e){return El(e.dims)}function Ol(e){return Cl(e,0n,`int64`,BigInt64Array)}function kl(e){return Ol(e.dims)}function Al(e){let t=e.reduce((e,t)=>e*t,1);return new U(`float32`,Float32Array.from({length:t},()=>Cs.random()),e)}function jl(e){let t=e.reduce((e,t)=>e*t,1);return new U(`float32`,Float32Array.from({length:t},()=>Cs.gauss()),e)}function Ml(e,t){if(e.dims.length!==2)throw Error(`The tensor must have 2 dimensions`);if(e.dims.at(-1)%8!=0)throw Error(`The last dimension of the tensor must be a multiple of 8`);if(![`binary`,`ubinary`].includes(t))throw Error(`The precision must be either 'binary' or 'ubinary'`);let n=t===`binary`,r=n?`int8`:`uint8`,i=n?Int8Array:Uint8Array,a=e.data,o=new i(a.length/8);for(let e=0;e<a.length;++e){let t=+(a[e]>0),r=Math.floor(e/8),i=e%8;o[r]|=t<<7-i,n&&i===0&&(o[r]-=128)}return new U(r,o,[e.dims[0],e.dims[1]/8])}async function Nl(e){if(!e)throw Error(`modelId is required for get_tokenizer_files`);return(await Ks(e,`tokenizer_config.json`,{})).exists?[`tokenizer.json`,`tokenizer_config.json`]:[]}async function Pl(e,t){let n=await Nl(e);return await Promise.all(n.map(n=>rc(e,n,!0,t)))}function Fl(e){let t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var Il=[`bos_token`,`eos_token`,`unk_token`,`sep_token`,`pad_token`,`cls_token`,`mask_token`];function Ll(e,t,n,r){for(let i of Object.keys(e)){let a=t-e[i].length,o=n(i),s=Array(a).fill(o);e[i]=r===`right`?ci(e[i],s):ci(s,e[i])}}function Rl(e,t){for(let n of Object.keys(e))e[n].length=t}function zl(e,...t){for(let n of t){if(!Object.hasOwn(e,n))continue;let t=e[n];if(t)if(typeof t==`object`){if(t.__type===`AddedToken`)return t.content;throw Error(`Unknown token: ${t}`)}else return t}return null}function Bl(e){let t=[];for(let n of e.get_added_tokens_decoder().values())n.special&&t.push(n);return t}var W=class extends ni{return_token_type_ids=!1;padding_side=`right`;constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new Ua(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=zl(t,`mask_token`),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=zl(t,`pad_token`,`eos_token`),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=zl(t,`sep_token`),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=zl(t,`unk_token`),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=zl(t,`bos_token`),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=zl(t,`eos_token`),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){let e=Object.create(null);for(let{name:t,template:n}of this.chat_template){if(typeof t!=`string`||typeof n!=`string`)throw Error(`Chat template must be a list of objects with "name" and "template" properties`);e[t]=n}this.chat_template=e}this._compiled_template_cache=new Map;let n=Bl(this._tokenizer);this.all_special_ids=n.map(e=>e.id),this.all_special_tokens=n.map(e=>e.content)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let o=await Pl(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a});return new this(...o)}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(e=>this._tokenizer.token_to_id(e))}_call(e,t={}){let{text_pair:n=null,add_special_tokens:r=!0,padding:i=!1,return_token_type_ids:a=null}=t,{truncation:o=null,max_length:s=null}=t,c=t.return_tensor??!0,l=Array.isArray(e),u;if(l){if(e.length===0)throw Error(`text array must be non-empty`);if(n!==null){if(!Array.isArray(n))throw Error(`text_pair must also be an array`);if(e.length!==n.length)throw Error(`text and text_pair must have the same length`);u=e.map((e,t)=>this._encode_plus(e,{text_pair:n[t],add_special_tokens:r,return_token_type_ids:a}))}else u=e.map(e=>this._encode_plus(e,{add_special_tokens:r,return_token_type_ids:a}))}else{if(e==null)throw Error(`text may not be null or undefined`);if(Array.isArray(n))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:n,add_special_tokens:r,return_token_type_ids:a})]}if(s===null?s=this.model_max_length:o===null&&(i===!0?(N.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),s=this.model_max_length):i===!1&&(N.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)),i===!0&&(s=Math.min(fc(u.map(e=>e.input_ids.length))[0],s??1/0)),s=Math.min(s,this.model_max_length??1/0),i||o)for(let e=0;e<u.length;++e)if(u[e].input_ids.length===s)continue;else u[e].input_ids.length>s?o&&Rl(u[e],s):i&&Ll(u[e],s,e=>e===`input_ids`?this.pad_token_id:0,this.padding_side);let d={};if(c){if(!(i&&o)&&u.some(e=>{for(let t of Object.keys(e))if(e[t].length!==u[0][t]?.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 e=[u.length,u[0].input_ids.length];for(let t of Object.keys(u[0]))d[t]=new U(`int64`,BigInt64Array.from(u.flatMap(e=>e[t]).map(BigInt)),e)}else{for(let e of Object.keys(u[0]))d[e]=u.map(t=>t[e]);if(!l)for(let e of Object.keys(d))d[e]=d[e][0]}return d}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{ids:i,attention_mask:a,token_type_ids:o}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r??this.return_token_type_ids});return{input_ids:i,attention_mask:a,...o?{token_type_ids:o}:{}}}tokenize(e,{pair:t=null,add_special_tokens:n=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:n})}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r}).ids}batch_decode(e,t={}){return e instanceof U&&(e=e.tolist()),e.map(e=>this.decode(e,t))}decode(e,t={}){if(e instanceof U&&(e=Fl(e)),!Array.isArray(e)||e.length===0||!ai(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:n=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:n})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template==`object`){let n=this.chat_template;if(e!==null&&Object.hasOwn(n,e))e=n[e];else if(e===null)if(t!==null&&`tool_use`in n)e=n.tool_use;else if(`default`in n)e=n.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(n).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,t={}){let{tools:n=null,documents:r=null,chat_template:i=null,add_generation_prompt:a=!1,tokenize:o=!0,padding:s=!1,truncation:c=!1,max_length:l=null,return_tensor:u=!0,return_dict:d=!0,tokenizer_kwargs:f={},...p}=t;if(i=this.get_chat_template({chat_template:i,tools:n}),typeof i!=`string`)throw Error(`chat_template must be a string, but got ${typeof i}`);let m=this._compiled_template_cache.get(i);m===void 0&&(m=new _s(i),this._compiled_template_cache.set(i,m));let h=Object.create(null);for(let e of Il){let t=zl(this.config,e);t&&(h[e]=t)}let g=m.render({messages:e,add_generation_prompt:a,tools:n,documents:r,...h,...p});if(o){let e=this._call(g,{add_special_tokens:!1,padding:s,truncation:c,max_length:l,return_tensor:u,...f});return d?e:e.input_ids}return g}};function Vl(e,t,n,r){if(!(`language_codes`in e)||!Array.isArray(e.language_codes))throw Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!(`languageRegex`in e)||!(e.languageRegex instanceof RegExp))throw Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!(`lang_to_token`in e)||typeof e.lang_to_token!=`function`)throw Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let i=r.src_lang,a=r.tgt_lang;if(!e.language_codes.includes(a))throw Error(`Target language code "${a}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);if(i!==void 0){if(!e.language_codes.includes(i))throw Error(`Source language code "${i}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);for(let t of e._tokenizer.post_processor.config.single)if(`SpecialToken`in t&&e.languageRegex.test(t.SpecialToken.id)){t.SpecialToken.id=e.lang_to_token(i);break}}return r.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(a)),e._call(t,n)}var Hl={};Tr(Hl,{AlbertTokenizer:()=>Ul,AutoTokenizer:()=>G,BartTokenizer:()=>Wl,BertTokenizer:()=>Gl,BlenderbotSmallTokenizer:()=>Kl,BlenderbotTokenizer:()=>ql,BloomTokenizer:()=>Jl,CLIPTokenizer:()=>Xl,CamembertTokenizer:()=>Yl,CodeGenTokenizer:()=>Ql,CodeLlamaTokenizer:()=>Zl,CohereAsrTokenizer:()=>eu,CohereTokenizer:()=>$l,ConvBertTokenizer:()=>tu,DebertaTokenizer:()=>ru,DebertaV2Tokenizer:()=>nu,DistilBertTokenizer:()=>iu,ElectraTokenizer:()=>au,EsmTokenizer:()=>ou,FalconTokenizer:()=>su,GPT2Tokenizer:()=>uu,GPTNeoXTokenizer:()=>lu,GemmaTokenizer:()=>cu,HerbertTokenizer:()=>du,LlamaTokenizer:()=>fu,M2M100Tokenizer:()=>pu,MBart50Tokenizer:()=>gu,MBartTokenizer:()=>hu,MPNetTokenizer:()=>yu,MarianTokenizer:()=>mu,MgpstrTokenizer:()=>_u,MobileBertTokenizer:()=>vu,NllbTokenizer:()=>bu,NougatTokenizer:()=>xu,PreTrainedTokenizer:()=>W,Qwen2Tokenizer:()=>Su,RoFormerTokenizer:()=>wu,RobertaTokenizer:()=>Cu,SiglipTokenizer:()=>Tu,SpeechT5Tokenizer:()=>Eu,SqueezeBertTokenizer:()=>Du,T5Tokenizer:()=>Ou,TokenizersBackend:()=>W,VitsTokenizer:()=>Au,Wav2Vec2CTCTokenizer:()=>ju,WhisperTokenizer:()=>Ru,XLMRobertaTokenizer:()=>zu,XLMTokenizer:()=>Bu});var Ul=class extends W{return_token_type_ids=!0},Wl=class extends W{},Gl=class extends W{return_token_type_ids=!0},Kl=class extends W{},ql=class extends W{},Jl=class extends W{},Yl=class extends W{},Xl=class extends W{},Zl=class extends W{},Ql=class extends W{},$l=class extends W{},eu=class extends W{},tu=class extends W{return_token_type_ids=!0},nu=class extends W{return_token_type_ids=!0},ru=class extends W{return_token_type_ids=!0},iu=class extends W{},au=class extends W{return_token_type_ids=!0},ou=class extends W{},su=class extends W{},cu=class extends W{},lu=class extends W{},uu=class extends W{},du=class extends W{return_token_type_ids=!0},fu=class extends W{padding_side=`left`},pu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e.slice(2,-2)),this.lang_to_token=e=>`__${e}__`}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},mu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(e=>this.languageRegex.test(e)),N.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[t,...n]=e.trim().split(this.languageRegex);if(n.length===0)return super._encode_text(t);if(n.length===2){let[e,t]=n;return this.supported_language_codes.includes(e)||N.warn(`Unsupported language code "${e}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),ci([e],super._encode_text(t))}}},hu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},gu=class extends hu{},_u=class extends W{},vu=class extends W{return_token_type_ids=!0},yu=class extends W{},bu=class extends W{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Vl(this,e,t,n)}},xu=class extends W{},Su=class extends W{},Cu=class extends W{},wu=class extends W{return_token_type_ids=!0},Tu=class extends W{},Eu=class extends W{},Du=class extends W{return_token_type_ids=!0},Ou=class extends W{},ku=class extends Aa{decode_chain(e){let t=``;for(let n=1;n<e.length;n+=2)t+=e[n];return[t]}},Au=class extends W{constructor(e,t){super(e,t),this._tokenizer.decoder=new ku({type:`VitsDecoder`})}},ju=class extends W{},Mu=[[`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`]],Nu=new Map(Mu),Pu=new Map([...Mu.map(([e,t])=>[t,e]),[`burmese`,`my`],[`valencian`,`ca`],[`flemish`,`nl`],[`haitian`,`ht`],[`letzeburgesch`,`lb`],[`pushto`,`ps`],[`panjabi`,`pa`],[`moldavian`,`ro`],[`moldovan`,`ro`],[`sinhalese`,`si`],[`castilian`,`es`]]);function Fu(e){e=e.toLowerCase();let t=Pu.get(e);if(t===void 0){let n=e.match(/^<\|([a-z]{2})\|>$/);if(n&&(e=n[1]),Nu.has(e))t=e;else{let t=e.length===2?Nu.keys():Nu.values();throw Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(t))}`)}}return t}var Iu=RegExp(`^[\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E]+$`,`gu`),Lu=.1,Ru=class extends W{get timestamp_begin(){return this._tokenizer.token_to_id(`<|notimestamps|>`)+1}_decode_asr(e,{return_timestamps:t=!1,return_language:n=!1,time_precision:r=null,force_full_sequences:i=!0}={}){if(r===null)throw Error(`Must specify time_precision`);let a=null,o=t===`word`;function s(){return{language:a,timestamp:[null,null],text:``}}let c=[],l=s(),u=0,d=this.timestamp_begin,f=d+1500,p=[],m=[],h=!1,g=null,_=new Set(this.all_special_ids);for(let n of e){let e=n.tokens,i=o?n.token_timestamps:null,v=null,y=d;if(`stride`in n){let[t,i,a]=n.stride;if(u-=i,g=t-a,i&&(y=i/r+d),a)for(let t=e.length-1;t>=0;--t){let n=Number(e[t]);if(n>=d){if(v!==null&&(n-d)*r<g)break;v=n}}}let b=[],x=[];for(let n=0;n<e.length;++n){let g=Number(e[n]);if(_.has(g)){let e=this.decode([g]),n=Nu.get(e.slice(2,-2));if(n!==void 0){if(a!==null&&n!==a&&!t){p.push(b);let e=this.findLongestCommonSequence(p)[0],t=this.decode(e);l.text=t,c.push(l),p=[],b=[],l=s()}a=l.language=n}}else if(g>=d&&g<=f){let e=vc((g-d)*r+u,2);if(v!==null&&g>=v)h=!0;else if(h||p.length>0&&g<y)h=!1;else if(l.timestamp[0]===null)l.timestamp[0]=e;else if(e!==l.timestamp[0]){l.timestamp[1]=e,p.push(b),o&&m.push(x);let[t,n]=this.findLongestCommonSequence(p,m),r=this.decode(t);if(l.text=r,o&&(l.words=this.collateWordTimestamps(t,n,a),l.words.length>0&&l.timestamp[1]!==null))for(let e of l.words)e.timestamp[1]>l.timestamp[1]&&l.timestamp[1]>=e.timestamp[0]&&(e.timestamp[1]=l.timestamp[1]);c.push(l),p=[],b=[],m=[],x=[],l=s()}}else if(b.push(g),o){let e=vc(i[n]+u,2),t;if(n+1<i.length){t=vc(i[n+1]+u,2);let a=this.decode([g]);Iu.test(a)&&(t=vc(Math.min(e+r,t),2))}else t=null;x.push([e,t])}}if(`stride`in n){let[e,t,r]=n.stride;u+=e-r}b.length>0?(p.push(b),o&&m.push(x)):p.every(e=>e.length===0)&&(l=s(),p=[],b=[],m=[],x=[])}if(p.length>0){if(i&&t)throw 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[e,n]=this.findLongestCommonSequence(p,m),r=this.decode(e);l.text=r,o&&(l.words=this.collateWordTimestamps(e,n,a)),c.push(l)}let v=Object.create(null),y=c.map(e=>e.text).join(``);if(t||n){for(let e=0;e<c.length;++e){let r=c[e];t||delete r.timestamp,n||delete r.language}if(o){let e=[];for(let t of c)for(let n of t.words)e.push(n);v={chunks:e}}else v={chunks:c}}return[y,v]}findLongestCommonSequence(e,t=null){let n=e[0],r=n.length,i=[],a=Array.isArray(t)&&t.length>0,o=a?[]:null,s=a?t[0]:null;for(let c=1;c<e.length;++c){let l=e[c],u=0,d=[r,r,0,0],f=l.length;for(let e=1;e<r+f;++e){let i=Math.max(0,r-e),o=Math.min(r,r+f-e),p=n.slice(i,o),m=Math.max(0,e-r),h=Math.min(f,e),g=l.slice(m,h);if(p.length!==g.length)throw Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let _;_=a?p.filter((e,n)=>e===g[n]&&s[i+n][0]-Lu<=t[c][m+n][0]).length:p.filter((e,t)=>e===g[t]).length;let v=e/1e4,y=_/e+v;_>1&&y>u&&(u=y,d=[i,o,m,h])}let[p,m,h,g]=d,_=Math.floor((m+p)/2),v=Math.floor((g+h)/2);if(a&&u===0&&r>0){let e=s[r-1][0],n=t[c].findIndex(t=>t[0]>=e);v=n===-1?l.length:n}i.push(...n.slice(0,_)),n=l.slice(v),r=n.length,a&&(o.push(...s.slice(0,_)),s=t[c].slice(v))}return i.push(...n),a?(o.push(...s),[i,o]):[i,[]]}collateWordTimestamps(e,t,n){let[r,i,a]=this.combineTokensIntoWords(e,n),o=[];for(let e=0;e<r.length;++e){let n=a[e];o.push({text:r[e],timestamp:[t[n.at(0)][0],t[n.at(-1)][1]]})}return o}combineTokensIntoWords(e,t,n=`"'“¡¿([{-`,r=`"'.。,,!!??::”)]}、`){t??=`english`;let i,a,o;return[`chinese`,`japanese`,`thai`,`lao`,`myanmar`].includes(t)?[i,a,o]=this.splitTokensOnUnicode(e):[i,a,o]=this.splitTokensOnSpaces(e),this.mergePunctuations(i,a,o,n,r)}decode(e,t){let n;return t?.decode_with_timestamps?(e instanceof U&&(e=Fl(e)),n=this.decodeWithTimestamps(e,t)):n=super.decode(e,t),n}decodeWithTimestamps(e,t){let n=t?.time_precision??.02,r=this.all_special_ids.at(-1)+1,i=[[]];for(let t of e)if(t=Number(t),t>=r){let e=((t-r)*n).toFixed(2);i.push(`<|${e}|>`),i.push([])}else i[i.length-1].push(t);return i=i.map(e=>typeof e==`string`?e:super.decode(e,t)),i.join(``)}splitTokensOnUnicode(e){let t=this.decode(e,{decode_with_timestamps:!0}),n=[],r=[],i=[],a=[],o=[],s=0;for(let c=0;c<e.length;++c){let l=e[c];a.push(l),o.push(c);let u=this.decode(a,{decode_with_timestamps:!0});(!u.includes(`�`)||t[s+u.indexOf(`�`)]===`�`)&&(n.push(u),r.push(a),i.push(o),a=[],o=[],s+=u.length)}return[n,r,i]}splitTokensOnSpaces(e){let[t,n,r]=this.splitTokensOnUnicode(e),i=[],a=[],o=[];for(let e=0;e<t.length;++e){let s=t[e],c=n[e],l=r[e],u=c[0]>=this._tokenizer.token_to_id(`<|endoftext|>`),d=s.startsWith(` `),f=s.trim(),p=Iu.test(f);if(u||d||p||i.length===0)i.push(s),a.push(c),o.push(l);else{let e=i.length-1;i[e]+=s,a[e].push(...c),o[e].push(...l)}}return[i,a,o]}mergePunctuations(e,t,n,r,i){let a=structuredClone(e),o=structuredClone(t),s=structuredClone(n),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(` `)&&r.includes(a[c].trim())?(a[l]=a[c]+a[l],o[l]=ci(o[c],o[l]),s[l]=ci(s[c],s[l]),a[c]=``,o[c]=[],s[c]=[]):l=c,--c;for(c=0,l=1;l<a.length;)!a[c].endsWith(` `)&&i.includes(a[l])?(a[c]+=a[l],o[c]=ci(o[c],o[l]),s[c]=ci(s[c],s[l]),a[l]=``,o[l]=[],s[l]=[]):c=l,++l;return[a.filter(e=>e),o.filter(e=>e.length>0),s.filter(e=>e.length>0)]}},zu=class extends W{},Bu=class extends W{return_token_type_ids=!0;constructor(e,t){super(e,t),N.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},G=class{static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let[o,s]=await Pl(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a}),c=s.tokenizer_class?.replace(/Fast$/,``)??`PreTrainedTokenizer`,l=Hl[c];return l||=(N.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),W),new l(o,s)}},Vu=`https://github.com/huggingface/transformers.js/issues/new/choose`,Hu=`preprocessor_config.json`,Uu=Hu,Wu=`processor_config.json`,Gu=`chat_template.jinja`,K=class extends ni{static classes=[`image_processor_class`,`tokenizer_class`,`feature_extractor_class`];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,n){super(),this.config=e,this.components=t,this.chat_template=n}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,t={}){if(!this.tokenizer)throw 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,...t})}batch_decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.decode(...e)}async _call(e,...t){for(let n of[this.image_processor,this.feature_extractor,this.tokenizer])if(n)return n(e,...t);throw Error(`No image processor, feature extractor, or tokenizer found.`)}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([this.uses_processor_config?rc(e,Wu,!0,t):{},Promise.all(this.classes.filter(e=>e in this).map(async n=>{let r=await this[n].from_pretrained(e,t);return[n.replace(/_class$/,``),r]})).then(Object.fromEntries),this.uses_chat_template_file?nc(e,Gu,!0,t):null]);return new this(n,r,i)}},Ku={};Tr(Ku,{ChatterboxProcessor:()=>Bd,CohereAsrProcessor:()=>Hd,Florence2Processor:()=>Mp,Gemma3Processor:()=>Np,Gemma3nProcessor:()=>Pp,Gemma4Processor:()=>Fp,Glm46VProcessor:()=>Lp,GraniteSpeechProcessor:()=>Rp,GroundingDinoProcessor:()=>Bp,Idefics3Processor:()=>Wp,JinaCLIPProcessor:()=>Kp,Lfm2VlProcessor:()=>qp,LlavaProcessor:()=>Jp,MgpstrProcessor:()=>Xp,MoonshineProcessor:()=>Zp,OwlViTProcessor:()=>Qp,PaliGemmaProcessor:()=>tm,Phi3VProcessor:()=>im,PixtralProcessor:()=>am,Processor:()=>K,PyAnnoteProcessor:()=>om,Qwen2VLProcessor:()=>Ip,Qwen2_5_VLProcessor:()=>sm,Qwen3VLProcessor:()=>cm,Sam2Processor:()=>um,Sam2VideoProcessor:()=>dm,SamProcessor:()=>lm,SmolVLMProcessor:()=>Wp,SpeechT5Processor:()=>fm,UltravoxProcessor:()=>pm,VLChatProcessor:()=>Gp,VoxtralProcessor:()=>vm,VoxtralRealtimeProcessor:()=>wm,Wav2Vec2Processor:()=>Tm,Wav2Vec2ProcessorWithLM:()=>Em,WhisperProcessor:()=>Dm});var qu=class extends ni{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){let n=await rc(e,Hu,!0,t);return new this(n)}};function Ju(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} 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 Yu={};Tr(Yu,{ASTFeatureExtractor:()=>yd,ChatterboxFeatureExtractor:()=>xd,ClapFeatureExtractor:()=>Sd,CohereAsrFeatureExtractor:()=>Td,DacFeatureExtractor:()=>Ed,EncodecFeatureExtractor:()=>bd,FeatureExtractor:()=>qu,Gemma3nAudioFeatureExtractor:()=>Dd,Gemma4AudioFeatureExtractor:()=>Od,GraniteSpeechFeatureExtractor:()=>kd,MoonshineFeatureExtractor:()=>Ad,ParakeetFeatureExtractor:()=>wd,PyAnnoteFeatureExtractor:()=>jd,SeamlessM4TFeatureExtractor:()=>Md,SnacFeatureExtractor:()=>Nd,SpeechT5FeatureExtractor:()=>Pd,VoxtralRealtimeFeatureExtractor:()=>Ld,Wav2Vec2FeatureExtractor:()=>Fd,WeSpeakerFeatureExtractor:()=>Id,WhisperFeatureExtractor:()=>Rd});var Xu={fromWeb:()=>{}};async function Zu(e,t){if(j.IS_BROWSER_ENV){if(j.IS_WEBWORKER_ENV)throw Error(`Unable to save a file from a Web Worker.`);let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),r.remove(),URL.revokeObjectURL(n)}else if(j.IS_FS_AVAILABLE){let n=t.stream();await(Xu.fromWeb(n),Er.createWriteStream(e),void 0)}else throw Error(`Unable to save because filesystem is disabled in this environment.`)}async function Qu(e,t){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 n=await(await Js(e)).arrayBuffer(),r=new AudioContext({sampleRate:t});t===void 0&&N.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let i=await r.decodeAudioData(n),a;if(i.numberOfChannels===2){let e=Math.sqrt(2),t=i.getChannelData(0),n=i.getChannelData(1);a=new Float32Array(t.length);for(let r=0;r<i.length;++r)a[r]=e*(t[r]+n[r])/2}else a=i.getChannelData(0);return a}var $u=Qu;function ed(e,t){if(e<1)return new Float64Array;if(e===1)return new Float64Array([1]);let n=1-t,r=2*Math.PI/(e-1),i=new Float64Array(e);for(let a=0;a<e;++a)i[a]=t-n*Math.cos(a*r);return i}function td(e){return ed(e,.5)}function nd(e){return ed(e,.54)}var rd={htk:e=>2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,n=15,r=27/Math.log(6.4))=>e>=t?n+Math.log(e/t)*r:3*e/200};function id(e,t=`htk`){let n=rd[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}var ad={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,n=15,r=Math.log(6.4)/27)=>e>=n?t*Math.exp(r*(e-n)):200*e/3};function od(e,t=`htk`){let n=ad[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}function sd(e,t){let n=Float64Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n]),r=Array.from({length:e.length},()=>Array(t.length));for(let n=0;n<e.length;++n){let i=r[n];for(let r=0;r<t.length;++r)i[r]=t[r]-e[n]}let i=t.length-2,a=Array.from({length:i},()=>Array(e.length));for(let t=0;t<e.length;++t){let e=r[t];for(let r=0;r<i;++r){let i=-e[r]/n[r],o=e[r+2]/n[r+1];a[r][t]=Math.max(0,Math.min(i,o))}}return a}function cd(e,t,n){let r=(t-e)/(n-1);return Float64Array.from({length:n},(t,n)=>e+r*n)}function ld(e,t,n,r,i,a=null,o=`htk`,s=!1){if(a!==null&&a!==`slaney`)throw Error(`norm must be one of null or "slaney"`);if(e<2)throw Error(`Require num_frequency_bins: ${e} >= 2`);if(n>r)throw Error(`Require min_frequency: ${n} <= max_frequency: ${r}`);let c=cd(id(n,o),id(r,o),t+2),l=od(c,o),u;if(s){let t=i/((e-1)*2);u=id(Float64Array.from({length:e},(e,n)=>n*t),o),l=c}else u=cd(0,Math.floor(i/2),e);let d=sd(u,l);if(a!==null&&a===`slaney`)for(let n=0;n<t;++n){let t=d[n],r=2/(l[n+2]-l[n]);for(let n=0;n<e;++n)t[n]*=r}return d}function ud(e,t,n){let r=new e.constructor(e.length+t+n),i=e.length-1;for(let n=0;n<e.length;++n)r[t+n]=e[n];for(let n=1;n<=t;++n)r[t-n]=e[ui(n,i)];for(let a=1;a<=n;++a)r[i+t+a]=e[ui(i-a,i)];return r}function dd(e,t,n,r,i){if(n<=0)throw Error(`reference must be greater than zero`);if(r<=0)throw Error(`min_value must be greater than zero`);n=Math.max(r,n);let a=Math.log10(n);for(let n=0;n<e.length;++n)e[n]=t*Math.log10(Math.max(r,e[n])-a);if(i!==null){if(i<=0)throw Error(`db_range must be greater than zero`);let t=fc(e)[0]-i;for(let n=0;n<e.length;++n)e[n]=Math.max(e[n],t)}return e}function fd(e,t=1,n=1e-5,r=null){return dd(e,20,t,n,r)}function pd(e,t=1,n=1e-10,r=null){return dd(e,10,t,n,r)}async function md(e,t,n,r,{fft_length:i=null,power:a=1,center:o=!0,pad_mode:s=`reflect`,onesided:c=!0,preemphasis:l=null,preemphasis_htk_flavor:u=!0,mel_filters:d=null,mel_floor:f=1e-10,log_mel:p=null,max_log_mel:m=null,reference:h=1,min_value:g=1e-10,db_range:_=null,remove_dc_offset:v=null,min_num_frames:y=null,max_num_frames:b=null,do_pad:x=!0,transpose:ee=!1,mel_offset:S=0,mel_floor_mode:te=`clamp`}={}){let C=t.length;if(i===null&&(i=n),n>i)throw Error(`frame_length (${n}) may not be larger than fft_length (${i})`);if(C!==n)throw Error(`Length of the window (${C}) must equal frame_length (${n})`);if(r<=0)throw Error(`hop_length must be greater than zero`);if(a===null&&d!==null)throw 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 Error("`preemphasis_htk_flavor=false` is not currently supported.");if(o){let t=Math.floor(n/2);switch(s){case`reflect`:e=ud(e,t,t);break;case`constant`:{let n=new e.constructor(e.length+2*t);n.set(e,t),e=n;break}case`semicausal`:{let n=new e.constructor(e.length+t);n.set(e,t),e=n;break}default:throw Error(`pad_mode="${s}" not implemented yet.`)}}let w=Math.floor(1+Math.floor((e.length-n)/r));y!==null&&w<y&&(w=y);let ne=c?Math.floor(i/2)+1:i,re=w,T=w;b!==null&&(b>w?x&&(T=b):T=re=b);let E=new gc(i),ie=new Float64Array(i),ae=new Float64Array(E.outputBufferSize),oe=new Float32Array(ne*T);for(let i=0;i<re;++i){let a=i*r,o=Math.min(e.length-a,n);o!==n&&ie.fill(0,0,n);for(let t=0;t<o;++t)ie[t]=e[a+t];if(v){let e=0;for(let t=0;t<o;++t)e+=ie[t];let t=e/o;for(let e=0;e<o;++e)ie[e]-=t}if(l!==null){for(let e=o-1;e>=1;--e)ie[e]-=l*ie[e-1];ie[0]*=1-l}for(let e=0;e<t.length;++e)ie[e]*=t[e];E.realTransform(ae,ie);for(let e=0;e<ne;++e){let t=e<<1;oe[e*T+i]=ae[t]**2+ae[t+1]**2}}if(a!==null&&a!==2){let e=a/2;for(let t=0;t<oe.length;++t)oe[t]**=e}let se=d.length,ce=await sl(new U(`float32`,d.flat(),[se,ne]),new U(`float32`,oe,[ne,T]));ee&&(ce=ce.transpose(1,0));let le=ce.data;if(te===`add`)for(let e=0;e<le.length;++e)le[e]=S+le[e]+f;else for(let e=0;e<le.length;++e)le[e]=S+Math.max(f,le[e]);if(a!==null&&p!==null){let e=Math.min(le.length,re*se);switch(p){case`log`:for(let t=0;t<e;++t)le[t]=Math.log(le[t]);break;case`log10`:for(let t=0;t<e;++t)le[t]=Math.log10(le[t]);break;case`log10_max_norm`:{for(let t=0;t<e;++t)le[t]=Math.log10(le[t]);let t=(m??fc(le)[0])-8;for(let n=0;n<e;++n)le[n]=(Math.max(le[n],t)+4)/4;break}case`dB`:if(a===1)fd(le,h,g,_);else if(a===2)pd(le,h,g,_);else throw Error(`Cannot use log_mel option '${p}' with power ${a}`);break;default:throw Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${p}'`)}}return ce}function hd(e,t,{periodic:n=!0,frame_length:r=null,center:i=!0}={}){let a=n?e+1:e,o;switch(t){case`boxcar`:o=new Float64Array(a).fill(1);break;case`hann`:case`hann_window`:o=td(a);break;case`hamming`:o=nd(a);break;case`povey`:o=td(a).map(e=>e**.85);break;default:throw Error(`Unknown window type ${t}.`)}if(n&&(o=o.subarray(0,e)),r===null||e===r)return o;if(e>r)throw Error(`Length of the window (${e}) may not be larger than frame_length (${r})`);let s=new Float64Array(r),c=i?Math.floor((r-e)/2):0;return s.set(o,c),s}function gd(e,t){let n=e.reduce((e,t)=>e+t.length,0),r=new ArrayBuffer(44),i=new DataView(r);return _d(i,0,`RIFF`),i.setUint32(4,36+n*4,!0),_d(i,8,`WAVE`),_d(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,3,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*4,!0),i.setUint16(32,4,!0),i.setUint16(34,32,!0),_d(i,36,`data`),i.setUint32(40,n*4,!0),new Blob([r,...e.map(e=>e.buffer)],{type:`audio/wav`})}function _d(e,t,n){for(let r=0;r<n.length;++r)e.setUint8(t+r,n.charCodeAt(r))}var vd=class{constructor(e,t){this.audio=e,this.sampling_rate=t}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array;if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((e,t)=>e+t.length,0),t=new Float32Array(e),n=0;for(let e of this.audio)t.set(e,n),n+=e.length;return t}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),gd(e,this.sampling_rate)}async save(e){return Zu(e,this.toBlob())}},yd=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`hann`,{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){Ju(e,`ASTFeatureExtractor`);let t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let e=this.std*2,n=t.data;for(let t=0;t<n.length;++t)n[t]=(n[t]-this.mean)/e}return{input_values:t.unsqueeze_(0)}}},bd=class extends qu{async _call(e){Ju(e,`EncodecFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=this.config.feature_size;if(e.length%t!==0)throw Error(`The length of the audio data must be a multiple of the number of channels (${t}).`);let n=[1,t,e.length/t];return{input_values:new U(`float32`,e,n)}}},xd=class extends qu{async _call(e){Ju(e,`ChatterboxFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new U(`float32`,e,t)}}},Sd=class extends qu{constructor(e){super(e),this.mel_filters=ld(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=ld(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=hd(this.config.fft_window_size,`hann`)}async _get_input_mel(e,t,n,r){let i,a=e.length-t;if(a>0)if(n===`rand_trunc`){let n=Math.floor(Cs.random()*(a+1));e=e.subarray(n,n+t),i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw Error(`Truncation strategy "${n}" not implemented`);else{if(a<0){let n=new Float64Array(t);if(n.set(e),r===`repeat`)for(let r=e.length;r<t;r+=e.length)n.set(e.subarray(0,Math.min(e.length,t-r)),r);else if(r===`repeatpad`)for(let t=e.length;t<-a;t+=e.length)n.set(e,t);e=n}if(n===`fusion`)throw Error(`Truncation strategy "${n}" not implemented`);i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return i.unsqueeze_(0)}async _extract_fbank_features(e,t,n=null){return md(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:t,log_mel:`dB`,max_num_frames:n,do_pad:!1,transpose:!0})}async _call(e,{max_length:t=null}={}){return Ju(e,`ClapFeatureExtractor`),{input_features:(await this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}},Cd=1e-5,wd=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(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 t=hd(this.config.win_length,`hann`,{periodic:!1});this.window=new Float64Array(this.config.n_fft);let n=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(t,n)}async _extract_fbank_features(e){let t=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=t*e[n-1];return await md(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){Ju(e,`ParakeetFeatureExtractor`);let t=await this._extract_fbank_features(e),n=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),r=t.data;r.fill(0,n*t.dims[1]);let[i,a]=t.dims,o=new Float64Array(a),s=new Float64Array(a);for(let e=0;e<n;++e){let t=e*a;for(let e=0;e<a;++e){let n=r[t+e];o[e]+=n,s[e]+=n*n}}let c=n>1?n-1:1;for(let e=0;e<a;++e){let t=o[e]/n,i=(s[e]-n*t*t)/c,l=1/(Math.sqrt(i)+Cd);for(let i=0;i<n;++i){let n=i*a+e;r[n]=(r[n]-t)*l}}let l=new BigInt64Array(i);return l.fill(1n,0,n),{input_features:t.unsqueeze_(0),attention_mask:new U(`int64`,l,[1,i])}}},Td=class extends wd{_apply_dither(e){let t=this.config.dither??0;if(t<=0)return e;let n=new bs(e.length);for(let r=0;r<e.length;++r)e[r]+=t*n.gauss();return e}split_audio(e){let t=this.config.max_audio_clip_s??35,n=this.config.overlap_chunk_second??5,r=this.config.min_energy_window_samples??1600,i=this.config.sampling_rate,a=Math.max(1,Math.round(t*i)),o=Math.max(1,Math.round(n*i));if(e.length<=a)return[e];let s=[],c=0,l=e.length;for(;c<l;){if(c+a>=l){s.push(e.slice(c,l));break}let t=Math.max(c,c+a-o),n=Math.min(c+a,l),i;i=n<=t?c+a:this._find_split_point_energy(e,t,n,r),i=Math.max(c+1,Math.min(i,l)),s.push(e.slice(c,i)),c=i}return s}_find_split_point_energy(e,t,n,r){let i=n-t;if(i<=r)return Math.floor((t+n)/2);let a=1/0,o=t,s=i-r;for(let n=0;n<=s;n+=r){let i=0;for(let a=0;a<r;++a){let r=e[t+n+a];i+=r*r}i=Math.sqrt(i/r),i<a&&(a=i,o=t+n)}return o}async _call(e){Ju(e,`CohereAsrFeatureExtractor`);let t=new Float64Array(e);return this._apply_dither(t),super._call(t)}},Ed=class extends bd{},Dd=class extends qu{constructor(e){super(e);let{fft_length:t,feature_size:n,min_frequency:r,max_frequency:i,sampling_rate:a,frame_length:o}=this.config,s=ld(Math.floor(1+t/2),n,r,i,a,null,`htk`,!1);this.mel_filters=s,this.window=hd(o,`hann`)}async _extract_fbank_features(e,t){return md(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:t=48e4,truncation:n=!0,padding:r=!0,pad_to_multiple_of:i=128}={}){if(Ju(e,`Gemma3nAudioFeatureExtractor`),n&&e.length>t&&(e=e.slice(0,t)),r&&e.length%i!==0){let t=i-e.length%i,n=new Float64Array(e.length+t);n.set(e),this.config.padding_value!==0&&n.fill(this.config.padding_value,e.length),e=n}let a=await this._extract_fbank_features(e,this.config.max_length),o=wl([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:o}}},Od=class extends Dd{async _extract_fbank_features(e,t){let{frame_length:n,hop_length:r,fft_length:i}=this.config,a=Math.floor(n/2),o=Math.floor((e.length+a-(n+1))/r)+1;return md(e,this.window,n,r,{fft_length:i,center:!0,pad_mode:`semicausal`,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,mel_floor_mode:`add`,remove_dc_offset:!1,transpose:!0,max_num_frames:o})}async _call(e,t={}){Ju(e,`Gemma4AudioFeatureExtractor`);let n=e.length,r=await super._call(e,t),{input_features:i}=r,[,a,o]=i.dims,{frame_length:s,hop_length:c}=this.config,l=Math.floor(s/2),u=s+1,d=new Uint8Array(n+l+(t.pad_to_multiple_of??128));d.fill(1,l,l+n);let f=new Uint8Array(a);for(let e=0;e<a;++e)f[e]=+!!d[e*c+u-1];let p=i.data;for(let e=0;e<a;++e)f[e]||p.fill(0,e*o,(e+1)*o);return r.input_features_mask=new U(`bool`,f,[1,a]),r}},kd=class extends qu{constructor(e){super(e);let{n_fft:t,win_length:n,n_mels:r,sample_rate:i}=e.melspec_kwargs;this.mel_filters=ld(Math.floor(1+t/2),r,0,i/2,i,null,`htk`);let a=hd(n,`hann`);this.window=new Float64Array(t);let o=Math.floor((t-n)/2);this.window.set(a,o)}async _call(e){Ju(e,`GraniteSpeechFeatureExtractor`);let{n_fft:t,hop_length:n,n_mels:r}=this.config.melspec_kwargs,i=1+Math.floor((e.length-1)/n),a=i-i%2;return{input_features:(await md(e,this.window,t,n,{power:2,mel_filters:this.mel_filters,log_mel:`log10_max_norm`,transpose:!0,max_num_frames:a,do_pad:!1})).view(-1,2*r).unsqueeze_(0)}}},Ad=class extends qu{async _call(e){Ju(e,`MoonshineFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,e.length];return{input_values:new U(`float32`,e,t)}}},jd=class extends qu{async _call(e){Ju(e,`PyAnnoteFeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=[1,1,e.length];return{input_values:new U(`float32`,e,t)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,t){let n=t/this.samples_to_frames(t)/this.config.sampling_rate,r=[];for(let t of e.tolist()){let e=[],i=-1;for(let n=0;n<t.length;++n){let[r,a]=fc(oc(t[n])),[o,s]=[n,n+1];a===i?(e.at(-1).end=s,e.at(-1).score+=r):(i=a,e.push({id:a,start:o,end:s,score:r}))}r.push(e.map(({id:e,start:t,end:r,score:i})=>({id:e,start:t*n,end:r*n,confidence:i/(r-t)})))}return r}},Md=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`povey`,{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(e=>e*32768),md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:n=2,do_normalize_per_mel_bins:r=!0,return_attention_mask:i=!0}={}){Ju(e,`SeamlessM4TFeatureExtractor`);let a=await this._extract_fbank_features(e,this.config.max_length);if(r){let[e,t]=a.dims,n=a.data;for(let r=0;r<t;++r){let i=0;for(let a=0;a<e;++a)i+=n[a*t+r];let a=i/e,o=0;for(let i=0;i<e;++i)o+=(n[i*t+r]-a)**2;o/=e-1;let s=Math.sqrt(o+1e-7);for(let i=0;i<e;++i){let e=i*t+r;n[e]=(n[e]-a)/s}}}let o;if(t){let[e,t]=a.dims,r=a.data,s=e%n;if(s>0){let n=new Float32Array(t*(e+s));n.set(r),n.fill(this.config.padding_value,r.length);let c=e+s;a=new U(a.type,n,[c,t]),i&&(o=new U(`int64`,new BigInt64Array(c),[1,c]),o.data.fill(1n,0,e))}}let[s,c]=a.dims,l=this.config.stride;if(s%l!==0)throw Error(`The number of frames (${s}) must be a multiple of the stride (${l}).`);let u=a.view(1,Math.floor(s/l),c*l),d={input_features:u};if(i){let e=u.dims[1],t=new BigInt64Array(e);if(o){let e=o.data;for(let n=1,r=0;n<s;n+=l,++r)t[r]=e[n]}else t.fill(1n);d.attention_mask=new U(`int64`,t,[1,e])}return d}},Nd=class extends Ed{},Pd=class extends qu{},Fd=class extends qu{_zero_mean_unit_var_norm(e){let t=e.reduce((e,t)=>e+t,0)/e.length,n=e.reduce((e,n)=>e+(n-t)**2,0)/e.length;return e.map(e=>(e-t)/Math.sqrt(n+1e-7))}async _call(e){Ju(e,`Wav2Vec2FeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let n=[1,t.length];return{input_values:new U(`float32`,t,n),attention_mask:new U(`int64`,new BigInt64Array(t.length).fill(1n),n)}}},Id=class extends qu{constructor(e){super(e);let t=this.config.sampling_rate,n=ld(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=hd(400,`hamming`,{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(e=>e*32768),md(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){Ju(e,`WeSpeakerFeatureExtractor`);let t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let e=t.mean(1).data,n=t.data,[r,i,a]=t.dims;for(let t=0;t<r;++t){let r=t*i*a,o=t*a;for(let t=0;t<i;++t){let i=r+t*a;for(let t=0;t<a;++t)n[i+t]-=e[o+t]}}}return{input_features:t}}},Ld=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,`slaney`,`slaney`),this.window=hd(this.config.n_fft,`hann`)}async _extract_fbank_features(e,{center:t=!0}={}){let{n_fft:n,hop_length:r,mel_filters:i,global_log_mel_max:a}=this.config,o=Math.floor(t?e.length/r:(e.length-n)/r);return await md(e,this.window,n,r,{power:2,mel_filters:i,log_mel:`log10_max_norm`,max_log_mel:a,center:t,max_num_frames:o,do_pad:!1})}async _call(e,{center:t=!0}={}){return Ju(e,`VoxtralRealtimeFeatureExtractor`),{input_features:(await this._extract_fbank_features(e,{center:t})).unsqueeze_(0)}}},Rd=class extends qu{constructor(e){super(e),this.config.mel_filters??=ld(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,`slaney`,`slaney`),this.window=hd(this.config.n_fft,`hann`)}async _extract_fbank_features(e){return await md(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:t=null}={}){Ju(e,`WhisperFeatureExtractor`);let n,r=t??this.config.n_samples;return e.length>r?(e.length>this.config.n_samples&&N.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`."),n=e.slice(0,r)):(n=new Float32Array(r),n.set(e)),{input_features:(await this._extract_fbank_features(n)).unsqueeze_(0)}}},zd=class{static async from_pretrained(e,t={}){let n=await rc(e,Hu,!0,t),r=n.feature_extractor_type,i=Yu[r];if(!i)throw Error(`Unknown feature_extractor_type: '${r}'. Please report this at ${Vu}.`);return new i(n)}},Bd=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e,t=null){let n=this.tokenizer(e),r=t?await this.feature_extractor(t):{};return{...n,...r}}},Vd=new Set([`ja`,`zh`]),Hd=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!0;get_decoder_prompt_ids(e=`en`){let t=[`▁`,`<|startofcontext|>`,`<|startoftranscript|>`,`<|emo:undefined|>`,`<|${e}|>`,`<|${e}|>`,`<|pnc|>`,`<|noitn|>`,`<|notimestamp|>`,`<|nodiarize|>`];return this.tokenizer.convert_tokens_to_ids(t)}static join_chunks(e,t=`en`){let n=e.filter(e=>e&&e.trim());if(n.length===0)return``;let r=Vd.has(t)?``:` `;return[n[0].trimEnd(),...n.slice(1).map(e=>e.trim())].join(r)}async _call(e){return await this.feature_extractor(e)}},Ud={},Wd,Gd,Kd;if(j.IS_WEB_ENV)Wd=(e,t)=>{if(!self.OffscreenCanvas)throw Error(`OffscreenCanvas not supported by this environment.`);return new self.OffscreenCanvas(e,t)},Kd=self.createImageBitmap,Gd=self.ImageData;else if(Ud)Kd=async e=>{let t=(await e.metadata()).channels,{data:n,info:r}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),i=new Yd(new Uint8ClampedArray(n),r.width,r.height,r.channels);return t!==void 0&&t!==r.channels&&i.convert(t),i};else throw Error(`Unable to load image processing library.`);var qd={0:`nearest`,1:`lanczos`,2:`bilinear`,3:`bicubic`,4:`box`,5:`hamming`},Jd=new Map([[`png`,`image/png`],[`jpg`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`gif`,`image/gif`]]),Yd=class e{constructor(e,t,n,r){this.data=e,this.width=t,this.height=n,this.channels=r}get size(){return[this.width,this.height]}static async read(t){if(t instanceof e)return t;if(typeof t==`string`||t instanceof URL)return await this.fromURL(t);if(t instanceof Blob)return await this.fromBlob(t);if(typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas)return this.fromCanvas(t);throw Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!j.IS_WEB_ENV)throw Error(`fromCanvas() is only supported in browser environments.`);let n=t.getContext(`2d`).getImageData(0,0,t.width,t.height).data;return new e(n,t.width,t.height,4)}static async fromURL(e){let t=await Js(e);if(t.status!==200)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let n=await t.blob();return this.fromBlob(n)}static async fromBlob(e){if(j.IS_WEB_ENV){let t=await Kd(e),n=Wd(t.width,t.height).getContext(`2d`);return n.drawImage(t,0,0),new this(n.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}else{let t=Ud(await e.arrayBuffer());return await Kd(t)}}static fromTensor(t,n=`CHW`){if(t.dims.length!==3)throw Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(n===`CHW`)t=t.transpose(1,2,0);else if(n!==`HWC`)throw Error(`Unsupported channel format: ${n}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new e(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw Error(`Unsupported number of channels: ${t.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 t=0,n=0;t<this.data.length;t+=this.channels){let r=this.data[t],i=this.data[t+1],a=this.data[t+2];e[n++]=Math.round(.2989*r+.587*i+.114*a)}break;default:throw 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 t=0,n=0;t<this.data.length;++t)e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=this.data[t];break;case 4:for(let t=0,n=0;t<this.data.length;t+=4)e[n++]=this.data[t],e[n++]=this.data[t+1],e[n++]=this.data[t+2];break;default:throw 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 t=0,n=0;t<this.data.length;++t)e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=this.data[t],e[n++]=255;break;case 3:for(let t=0,n=0;t<this.data.length;t+=3)e[n++]=this.data[t],e[n++]=this.data[t+1],e[n++]=this.data[t+2],e[n++]=255;break;default:throw 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 Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw Error(`Expected mask to have 1 channel, but got ${e.channels}`);let t=this.data,n=e.data,r=this.width*this.height;if(this.channels===3){let e=new Uint8ClampedArray(r*4);for(let i=0,a=0,o=0;i<r;++i)e[o++]=t[a++],e[o++]=t[a++],e[o++]=t[a++],e[o++]=n[i];return this._update(e,this.width,this.height,4)}else if(this.channels===4){for(let e=0;e<r;++e)t[4*e+3]=n[e];return this}throw Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(t,n,{resample:r=2}={}){if(this.width===t&&this.height===n)return this;let i=qd[r]??r,a=oi(t),o=oi(n);if(a&&o)return this;if(a?t=n/this.height*this.width:o&&(n=t/this.width*this.height),j.IS_WEB_ENV){let r=this.channels,i=this.toCanvas(),a=Wd(t,n).getContext(`2d`);return a.drawImage(i,0,0,t,n),new e(a.getImageData(0,0,t,n).data,t,n,4).convert(r)}else{let e=this.toSharp();switch(i){case`box`:case`hamming`:(i===`box`||i===`hamming`)&&(N.warn(`Resampling method ${i} is not yet supported. Using bilinear instead.`),i=`bilinear`);case`nearest`:case`bilinear`:case`bicubic`:e=e.affine([t/this.width,0,0,n/this.height],{interpolator:i});break;case`lanczos`:e=e.resize({width:t,height:n,fit:`fill`,kernel:`lanczos3`});break;default:throw Error(`Resampling method ${i} is not supported.`)}return await Kd(e)}}async pad([t,n,r,i]){if(t=Math.max(t,0),n=Math.max(n,0),r=Math.max(r,0),i=Math.max(i,0),t===0&&n===0&&r===0&&i===0)return this;if(j.IS_WEB_ENV){let a=this.channels,o=this.toCanvas(),s=this.width+t+n,c=this.height+r+i,l=Wd(s,c).getContext(`2d`);return l.drawImage(o,0,0,this.width,this.height,t,r,this.width,this.height),new e(l.getImageData(0,0,s,c).data,s,c,4).convert(a)}else{let e=this.toSharp().extend({left:t,right:n,top:r,bottom:i});return await Kd(e)}}async crop([t,n,r,i]){if(t=Math.max(t,0),n=Math.max(n,0),r=Math.min(r,this.width-1),i=Math.min(i,this.height-1),t===0&&n===0&&r===this.width-1&&i===this.height-1)return this;let a=r-t+1,o=i-n+1;if(j.IS_WEB_ENV){let r=this.channels,i=this.toCanvas(),s=Wd(a,o).getContext(`2d`);return s.drawImage(i,t,n,a,o,0,0,a,o),new e(s.getImageData(0,0,a,o).data,a,o,4).convert(r)}else{let e=this.toSharp().extract({left:t,top:n,width:a,height:o});return await Kd(e)}}async center_crop(t,n){if(this.width===t&&this.height===n)return this;let r=(this.width-t)/2,i=(this.height-n)/2;if(j.IS_WEB_ENV){let a=this.channels,o=this.toCanvas(),s=Wd(t,n).getContext(`2d`),c=0,l=0,u=0,d=0;return r>=0?c=r:u=-r,i>=0?l=i:d=-i,s.drawImage(o,c,l,t,n,u,d,t,n),new e(s.getImageData(0,0,t,n).data,t,n,4).convert(a)}else{let e=this.toSharp();if(r>=0&&i>=0)e=e.extract({left:Math.floor(r),top:Math.floor(i),width:t,height:n});else if(r<=0&&i<=0){let a=Math.floor(-i),o=Math.floor(-r);e=e.extend({top:a,left:o,right:t-this.width-o,bottom:n-this.height-a})}else{let a=[0,0],o=0;i<0?(a[0]=Math.floor(-i),a[1]=n-this.height-a[0]):o=Math.floor(i);let s=[0,0],c=0;r<0?(s[0]=Math.floor(-r),s[1]=t-this.width-s[0]):c=Math.floor(r),e=e.extend({top:a[0],bottom:a[1],left:s[0],right:s[1]}).extract({left:c,top:o,width:t,height:n})}return await Kd(e)}}async toBlob(e=`image/png`,t=1){if(!j.IS_WEB_ENV)throw Error(`toBlob() is only supported in browser environments.`);return await this.toCanvas().convertToBlob({type:e,quality:t})}toTensor(e=`CHW`){let t=new U(`uint8`,new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!==`HWC`)if(e===`CHW`)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`);return t}toCanvas(){if(!j.IS_WEB_ENV)throw Error(`toCanvas() is only supported in browser environments.`);let e=this.clone().rgba(),t=Wd(e.width,e.height),n=new Gd(e.data,e.width,e.height);return t.getContext(`2d`).putImageData(n,0,0),t}split(){let{data:t,width:n,height:r,channels:i}=this,a=t.constructor,o=t.length/i,s=Array.from({length:i},()=>new a(o));for(let e=0;e<o;++e){let n=i*e;for(let r=0;r<i;++r)s[r][e]=t[n+r]}return s.map(t=>new e(t,n,r,1))}_update(e,t,n,r=null){return this.data=e,this.width=t,this.height=n,r!==null&&(this.channels=r),this}clone(){return new e(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 Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(j.IS_WEB_ENV){if(j.IS_WEBWORKER_ENV)throw Error(`Unable to save an image from a Web Worker.`);let t=e.split(`.`).pop().toLowerCase(),n=Jd.get(t)??`image/png`;return Zu(e,await this.toBlob(n))}else if(j.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw Error(`Unable to save the image because filesystem is disabled in this environment.`)}toSharp(){if(j.IS_WEB_ENV)throw Error(`toSharp() is only supported in server-side environments.`);return Ud(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},Xd=Yd.read.bind(Yd);function Zd(e,t,n=0,r=null){let i=e/t,a=yc(i)*t;return r!==null&&a>r&&(a=Math.floor(i)*t),a<n&&(a=Math.ceil(i)*t),a}function Qd([e,t],n){return[Math.max(Math.floor(e/n),1)*n,Math.max(Math.floor(t/n),1)*n]}function $d([e,t,n,r]){return[e-n/2,t-r/2,e+n/2,t+r/2]}function ef(e,t=.5,n=null,r=!1){let i=e.logits,a=e.pred_boxes,[o,s,c]=i.dims;if(n!==null&&n.length!==o)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let l=[];for(let e=0;e<o;++e){let o=n===null?null:n[e],u={boxes:[],classes:[],scores:[]},d=i[e],f=a[e];for(let e=0;e<s;++e){let n=d[e],i=[],a;if(r){a=n.sigmoid().data;for(let e=0;e<a.length;++e)a[e]>t&&i.push(e)}else{let e=fc(n.data)[1];if(e===c-1||(a=oc(n.data),a[e]<t))continue;i.push(e)}for(let t of i){let n=f[e].data;n=$d(n),o!==null&&(n=n.map((e,t)=>e*o[(t+1)%2])),u.boxes.push(n),u.classes.push(t),u.scores.push(a[t])}}l.push(u)}return l}function tf(e,t=null){let n=e.logits,r=n.dims[0];if(t!==null&&t.length!==r)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let i=[];for(let e=0;e<r;++e){let r=t===null?null:t[e],a=n[e];r!==null&&(a=al(a,r,`bilinear`,!1));let[o,s]=r??a.dims.slice(-2),c=new U(`int32`,new Int32Array(o*s),[o,s]),l=a[0].data,u=c.data;for(let e=1;e<a.dims[0];++e){let t=a[e].data;for(let n=0;n<t.length;++n)t[n]>l[n]&&(l[n]=t[n],u[n]=e)}let d=Array(a.dims[0]);for(let e=0;e<u.length;++e){let t=u[e];d[t]=t}let f=d.filter(e=>e!==void 0);i.push({segmentation:c,labels:f})}return i}function nf(e,t,n,r){let i=[],a=[],o=[];for(let s=0;s<e.dims[0];++s){let c=e[s],l=t[s],u=fc(c.data)[1];if(u===r)continue;let d=oc(c.data)[u];d>n&&(i.push(l),a.push(d),o.push(u))}return[i,a,o]}function rf(e,t,n,r=.5,i=.8){let a=[],o=0,s=0,c=t[n].data;for(let t=0;t<e.length;++t)e[t]===n&&(a.push(t),++o),c[t]>=r&&++s;let l=o>0&&s>0;return l&&=o/s>i,[l,a]}function af(e,t,n,r,i,a=null,o=null){let[s,c]=o??e[0].dims,l=new U(`int32`,new Int32Array(s*c),[s,c]),u=[];if(o!==null)for(let t=0;t<e.length;++t)e[t]=al(e[t],o,`bilinear`,!1);let d=new Int32Array(e[0].data.length),f=new Float32Array(e[0].data.length);for(let n=0;n<e.length;++n){let r=t[n],i=e[n].data;for(let e=0;e<i.length;++e)i[e]*=r,i[e]>f[e]&&(d[e]=n,f[e]=i[e])}let p=0,m=l.data;for(let a=0;a<n.length;++a){let o=n[a],[s,c]=rf(d,e,a,r,i);if(s){++p;for(let e of c)m[e]=p;u.push({id:p,label_id:o,score:t[a]})}}return[l,u]}function of(e,t,n=28,r=3136,i=784*1280,a=1){if(e<n||t<n){let r=Math.max(n/e,n/t);e=Math.round(e*r),t=Math.round(t*r)}if(Math.max(e,t)/Math.min(e,t)>200)throw Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let o=Math.round(e/n)*n,s=Math.round(t/n)*n;if(a*o*s>i){let r=Math.sqrt(a*e*t/i);o=Math.max(n,Math.floor(e/r/n)*n),s=Math.max(n,Math.floor(t/r/n)*n)}else if(a*o*s<r){let i=Math.sqrt(r/(a*e*t));o=Math.ceil(e*i/n)*n,s=Math.ceil(t*i/n)*n}return[s,o]}function sf(e,t=.5,n=.5,r=.8,i=null,a=null){i===null&&(N.warn("`label_ids_to_fuse` unset. No instance will be fused."),i=new Set);let o=e.class_queries_logits??e.logits,s=(e.masks_queries_logits??e.pred_masks).sigmoid(),[c,l,u]=o.dims;if(--u,a!==null&&a.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 e=0;e<c;++e){let c=a===null?null:a[e],l=o[e],f=s[e],[p,m,h]=nf(l,f,t,u);if(h.length===0){let[e,t]=c??f.dims.slice(-2),n=new U(`int32`,new Int32Array(e*t).fill(-1),[e,t]);d.push({segmentation:n,segments_info:[]});continue}let[g,_]=af(p,m,h,n,r,i,c);d.push({segmentation:g,segments_info:_})}return d}function cf(e,t=.5,n=null){throw Error("`post_process_instance_segmentation` is not yet implemented.")}var q=class extends ni{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,t,n=2){let r=e.height,i=e.width,a=t.height,o=t.width,s=Math.min(r,a),c=Math.min(i,o);return s===r&&c===i?e:(r>i?c=Math.floor(i*s/r):i>r&&(s=Math.floor(r*c/i)),await e.resize(c,s,{resample:n}))}async crop_margin(e,t=200){let n=e.clone().grayscale(),r=dc(n.data)[0],i=fc(n.data)[0]-r;if(i===0)return e;let a=t/255,o=n.width,s=n.height,c=0,l=0,u=n.data;for(let e=0;e<n.height;++e){let t=e*n.width;for(let d=0;d<n.width;++d)(u[t+d]-r)/i<a&&(o=Math.min(o,d),s=Math.min(s,e),c=Math.max(c,d),l=Math.max(l,e))}return e=await e.crop([o,s,c,l]),e}pad_image(e,t,n,{mode:r=`constant`,center:i=!1,constant_values:a=0}={}){let[o,s,c]=t,l,u;if(typeof n==`number`?(l=n,u=n):n===`square`?l=u=Math.max(o,s):(l=n.width,u=n.height),l!==s||u!==o){let n=new Float32Array(l*u*c);if(Array.isArray(a))for(let e=0;e<n.length;++e)n[e]=a[e%c];else a!==0&&n.fill(a);let[d,f]=i?[Math.floor((l-s)/2),Math.floor((u-o)/2)]:[0,0];for(let t=0;t<o;++t){let r=(t+f)*l,i=t*s;for(let t=0;t<s;++t){let a=(r+t+d)*c,o=(i+t)*c;for(let t=0;t<c;++t)n[a+t]=e[o+t]}}if(r===`symmetric`){if(i)throw Error("`center` padding is not supported when `mode` is set to `symmetric`.");let t=o-1,r=s-1;for(let i=0;i<u;++i){let a=i*l,u=ui(i,t)*s;for(let t=0;t<l;++t){if(i<o&&t<s)continue;let l=(a+t)*c,d=(u+ui(t,r))*c;for(let t=0;t<c;++t)n[l+t]=e[d+t]}}}e=n,t=[u,l,c]}return[e,t]}rescale(e){for(let t=0;t<e.length;++t)e[t]=this.rescale_factor*e[t]}get_resize_output_image_size(e,t){let[n,r]=e.size,i,a;if(this.do_thumbnail){let{height:e,width:n}=t;i=Math.min(e,n)}else Number.isInteger(t)?(i=t,a=this.config.max_size??i):t!==void 0&&(i=t.shortest_edge,a=t.longest_edge);if(i!==void 0||a!==void 0){let e=i===void 0?1:Math.max(i/n,i/r),t=n*e,o=r*e,s=a===void 0?1:Math.min(a/t,a/o),c=Math.floor(Number((t*s).toFixed(2))),l=Math.floor(Number((o*s).toFixed(2)));return this.size_divisibility!==void 0&&([c,l]=Qd([c,l],this.size_divisibility)),[c,l]}else if(t!==void 0&&t.width!==void 0&&t.height!==void 0){let e=t.width,i=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let t=i/r,a=e/n;Math.abs(1-a)<Math.abs(1-t)?t=a:a=t,i=Zd(t*r,this.config.ensure_multiple_of),e=Zd(a*n,this.config.ensure_multiple_of)}return[e,i]}else if(this.size_divisibility!==void 0)return Qd([n,r],this.size_divisibility);else throw Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}async resize(e){let[t,n]=this.get_resize_output_image_size(e,this.size);return await e.resize(t,n,{resample:this.resample})}async preprocess(e,{do_normalize:t=null,do_pad:n=null,do_convert_rgb:r=null,do_convert_grayscale:i=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[o,s]=e.size;if(r??this.do_convert_rgb?e=e.rgb():i&&(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 t,n;Number.isInteger(this.crop_size)?(t=this.crop_size,n=this.crop_size):(t=this.crop_size.width,n=this.crop_size.height),e=await e.center_crop(t,n)}let c=[e.height,e.width],l=Float32Array.from(e.data),u=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(l),t??this.do_normalize){let t=this.image_mean;Array.isArray(this.image_mean)||(t=Array(e.channels).fill(t));let n=this.image_std;if(Array.isArray(this.image_std)||(n=Array(e.channels).fill(n)),t.length!==e.channels||n.length!==e.channels)throw Error(`When set to arrays, the length of \`image_mean\` (${t.length}) and \`image_std\` (${n.length}) must match the number of channels in the image (${e.channels}).`);for(let r=0;r<l.length;r+=e.channels)for(let i=0;i<e.channels;++i)l[r+i]=(l[r+i]-t[i])/n[i]}if(n??this.do_pad){if(this.pad_size){let t=this.pad_image(l,[e.height,e.width,e.channels],this.pad_size);[l,u]=t}else if(this.size_divisibility){let e=Math.ceil(u[1]/this.size_divisibility)*this.size_divisibility,t=Math.ceil(u[0]/this.size_divisibility)*this.size_divisibility;[l,u]=this.pad_image(l,u,{width:e,height:t})}}if(a??this.do_flip_channel_order){if(u[2]!==3)throw Error(`Flipping channel order is only supported for RGB images.`);for(let e=0;e<l.length;e+=3){let t=l[e];l[e]=l[e+2],l[e+2]=t}}let d=new U(`float32`,l,u).permute(2,0,1);return{original_size:[s,o],reshaped_input_size:c,pixel_values:d}}async _call(e,...t){Array.isArray(e)||(e=[e]);let n=await Promise.all(e.map(e=>this.preprocess(e)));return{pixel_values:vl(n.map(e=>e.pixel_values),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t);return new this(n)}},lf={};Tr(lf,{BeitFeatureExtractor:()=>uf,BitImageProcessor:()=>df,CHMv2ImageProcessor:()=>pf,CLIPFeatureExtractor:()=>hf,CLIPImageProcessor:()=>mf,ChineseCLIPFeatureExtractor:()=>ff,ConvNextFeatureExtractor:()=>_f,ConvNextImageProcessor:()=>gf,DINOv3ViTImageProcessor:()=>Sf,DPTFeatureExtractor:()=>Ef,DPTImageProcessor:()=>Tf,DeiTFeatureExtractor:()=>yf,DeiTImageProcessor:()=>vf,DetrFeatureExtractor:()=>xf,DetrImageProcessor:()=>bf,DonutFeatureExtractor:()=>wf,DonutImageProcessor:()=>Cf,EfficientNetImageProcessor:()=>Df,GLPNFeatureExtractor:()=>Pf,Gemma3ImageProcessor:()=>Of,Gemma4ImageProcessor:()=>jf,Glm46VImageProcessor:()=>Nf,GroundingDinoImageProcessor:()=>Ff,Idefics3ImageProcessor:()=>If,ImageFeatureExtractor:()=>q,ImageProcessor:()=>q,JinaCLIPImageProcessor:()=>Rf,Lfm2VlImageProcessor:()=>Wf,LlavaOnevisionImageProcessor:()=>Gf,Mask2FormerImageProcessor:()=>Jf,MaskFormerFeatureExtractor:()=>qf,MaskFormerImageProcessor:()=>Kf,MobileNetV1FeatureExtractor:()=>Xf,MobileNetV1ImageProcessor:()=>Yf,MobileNetV2FeatureExtractor:()=>Qf,MobileNetV2ImageProcessor:()=>Zf,MobileNetV3FeatureExtractor:()=>ep,MobileNetV3ImageProcessor:()=>$f,MobileNetV4FeatureExtractor:()=>np,MobileNetV4ImageProcessor:()=>tp,MobileViTFeatureExtractor:()=>ip,MobileViTImageProcessor:()=>rp,NougatImageProcessor:()=>ap,OwlViTFeatureExtractor:()=>sp,OwlViTImageProcessor:()=>op,Owlv2ImageProcessor:()=>cp,Phi3VImageProcessor:()=>mp,PixtralImageProcessor:()=>hp,PvtImageProcessor:()=>gp,Qwen2VLImageProcessor:()=>Mf,RTDetrImageProcessor:()=>_p,Sam2ImageProcessor:()=>vp,Sam3ImageProcessor:()=>vp,SamImageProcessor:()=>vp,SapiensFeatureExtractor:()=>bp,SapiensImageProcessor:()=>yp,SegformerFeatureExtractor:()=>Sp,SegformerImageProcessor:()=>xp,SiglipImageProcessor:()=>Cp,SmolVLMImageProcessor:()=>If,Swin2SRImageProcessor:()=>wp,VLMImageProcessor:()=>Lf,ViTFeatureExtractor:()=>Ep,ViTImageProcessor:()=>Tp,VitMatteImageProcessor:()=>Dp,VitPoseImageProcessor:()=>Op,YolosFeatureExtractor:()=>Ap,YolosImageProcessor:()=>kp});var uf=class extends q{},df=class extends q{},ff=class extends q{},pf=class extends q{},mf=class extends q{},hf=class extends mf{},gf=class extends q{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let t=this.size?.shortest_edge;if(t===void 0)throw Error(`Size dictionary must contain 'shortest_edge' key.`);if(t<384){let n=Math.floor(t/this.crop_pct),[r,i]=this.get_resize_output_image_size(e,{shortest_edge:n});e=await e.resize(r,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},_f=class extends gf{},vf=class extends q{},yf=class extends vf{},bf=class extends q{async _call(e){let t=await super._call(e),n=wl([t.pixel_values.dims[0],64,64],1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return ef(...e)}post_process_panoptic_segmentation(...e){return sf(...e)}post_process_instance_segmentation(...e){return cf(...e)}},xf=class extends bf{},Sf=class extends q{},Cf=class extends q{pad_image(e,t,n,r={}){let[i,a,o]=t,s=this.image_mean;Array.isArray(this.image_mean)||(s=Array(o).fill(s));let c=this.image_std;Array.isArray(c)||(c=Array(o).fill(s));let l=s.map((e,t)=>-e/c[t]);return super.pad_image(e,t,n,{center:!0,constant_values:l,...r})}},wf=class extends Cf{},Tf=class extends q{},Ef=class extends Tf{},Df=class extends q{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(e=>e*e))}},Of=class extends q{};function kf(e,t,n,r,i){let a=r*n**2,o=Math.sqrt(a/(e*t)),s=i*n,c=Math.floor(o*e/s)*s,l=Math.floor(o*t/s)*s;if(c===0&&l===0)throw Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${s}.`);let u=Math.floor(r/i**2)*s;return c===0?(c=s,l=Math.min(Math.floor(t/e)*s,u)):l===0&&(l=s,c=Math.min(Math.floor(e/t)*s,u)),[c,l]}function Af(e,t,n,r,i,a,o){let s=Math.floor(t/i),c=Math.floor(n/i),l=s*c,u=i*i*r,d=new Float32Array(a*u),f=0;for(let t=0;t<s;++t)for(let a=0;a<c;++a)for(let o=0;o<i;++o){let s=(t*i+o)*n*r+a*i*r;for(let t=0;t<i;++t){let n=s+t*r;for(let t=0;t<r;++t)d[f++]=e[n+t]}}let p=new BigInt64Array(a*2).fill(-1n),m=0;for(let e=0;e<s;++e)for(let t=0;t<c;++t)p[m++]=BigInt(t),p[m++]=BigInt(e);return{patches:new U(`float32`,d,[a,u]),positions:new U(`int64`,p,[a,2]),num_soft_tokens:Math.floor(l/o**2)}}var jf=class extends ni{constructor(e){super(),this.config=e,this.patch_size=e.patch_size??16,this.max_soft_tokens=e.max_soft_tokens??280,this.pooling_kernel_size=e.pooling_kernel_size??3,this.resample=e.resample??3,this.rescale_factor=e.rescale_factor??1/255,this.do_rescale=e.do_rescale??!0,this.do_resize=e.do_resize??!0,this.do_convert_rgb=e.do_convert_rgb??!0}async _call(e){Array.isArray(e)||(e=[e]);let{patch_size:t,pooling_kernel_size:n}=this,r=this.max_soft_tokens*n**2,i=[],a=[],o=[];for(let s of e){if(this.do_convert_rgb&&(s=s.rgb()),this.do_resize){let[e,i]=kf(s.height,s.width,t,r,n);(e!==s.height||i!==s.width)&&(s=await s.resize(i,e,{resample:this.resample}))}let e=Float32Array.from(s.data);if(this.do_rescale)for(let t=0;t<e.length;++t)e[t]*=this.rescale_factor;let{patches:c,positions:l,num_soft_tokens:u}=Af(e,s.height,s.width,s.channels,t,r,n);i.push(c),a.push(l),o.push(u)}return{pixel_values:vl(i,0),image_position_ids:vl(a,0),num_soft_tokens_per_image:o}}},Mf=class extends q{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,t){let n=this.patch_size*this.merge_size;return of(e.height,e.width,n,this.min_pixels,this.max_pixels)}async _call(e,...t){let{pixel_values:n,original_sizes:r,reshaped_input_sizes:i}=await super._call(e,...t),a=n,{temporal_patch_size:o,merge_size:s,patch_size:c}=this.config;a.dims[0]===1&&(a=_l(Array.from({length:o},()=>a),0));let l=a.dims[0]/o,u=a.dims[1],d=Math.floor(a.dims[2]/c),f=Math.floor(a.dims[3]/c);return{pixel_values:a.view(l,o,u,Math.floor(d/s),s,c,Math.floor(f/s),s,c).permute(0,3,6,4,7,2,1,5,8).view(l*d*f,u*o*c*c),image_grid_thw:new U(`int64`,[l,d,f],[1,3]),original_sizes:r,reshaped_input_sizes:i}}},Nf=class extends Mf{get_resize_output_image_size(e,t){let n=this.patch_size*this.merge_size,r=this.config.temporal_patch_size??2;return of(e.height,e.width,n,this.min_pixels,this.max_pixels,r)}},Pf=class extends q{},Ff=class extends q{async _call(e){let t=await super._call(e),n=t.pixel_values.dims,r=El([n[0],n[2],n[3]]);return{...t,pixel_mask:r}}},If=class extends q{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,t){let[n,r]=e.dims.slice(-2),i=r/n;return r>=n?(r=Math.ceil(r/t)*t,n=Math.floor(r/i),n=Math.ceil(n/t)*t):(n=Math.ceil(n/t)*t,r=Math.floor(n*i),r=Math.ceil(r/t)*t),{height:n,width:r}}async _call(e,{do_image_splitting:t=null,return_row_col_info:n=!1}={}){let r;if(!Array.isArray(e))r=[[e]];else{if(e.length===0||!e[0])throw Error(`No images provided.`);r=Array.isArray(e[0])?e:[e]}let i=[],a=[],o=[],s=[],c=[];for(let e of r){let n=await Promise.all(e.map(e=>this.preprocess(e)));s.push(...n.map(e=>e.original_size)),c.push(...n.map(e=>e.reshaped_input_size)),n.forEach(e=>e.pixel_values.unsqueeze_(0));let{longest_edge:r}=this.max_image_size,l;if(t??this.do_image_splitting){let e=Array(n.length),t=Array(n.length);l=await Promise.all(n.map(async(n,i)=>{let a=this.get_resize_for_vision_encoder(n.pixel_values,r),o=await ol(n.pixel_values,{size:[a.height,a.width]}),{frames:s,num_splits_h:c,num_splits_w:l}=await this.split_image(o,this.max_image_size);return e[i]=c,t[i]=l,_l(s,0)})),a.push(e),o.push(t)}else{let e=[r,r];l=await Promise.all(n.map(t=>ol(t.pixel_values,{size:e}))),a.push(Array(n.length).fill(0)),o.push(Array(n.length).fill(0))}i.push(_l(l,0))}let l=i.length,[u,d,f,p]=i[0].dims,m,h;if(l===1)m=i[0].unsqueeze_(0),h=wl([l,u,f,p],!0);else{let e=Math.max(...i.map(e=>e.dims.at(0)));h=wl([l,e,f,p],!0);let t=h.data,n=e*f*p;for(let r=0;r<l;++r){let a=i[r].dims[0];if(a<e){i[r]=_l([i[r],wl([e-a,d,f,p],0)],0);let o=r*n+a*f*p,s=(r+1)*n;t.fill(!1,o,s)}}m=vl(i,0)}return{pixel_values:m,pixel_attention_mask:h,original_sizes:s,reshaped_input_sizes:c,...n?{rows:a,cols:o}:{}}}async split_image(e,{longest_edge:t}){let n=t,r=t,i=[],[a,o]=e.dims.slice(-2),s=0,c=0;if(a>n||o>r){s=Math.ceil(a/n),c=Math.ceil(o/r);let t=Math.ceil(a/s),l=Math.ceil(o/c);for(let n=0;n<s;++n)for(let r=0;r<c;++r){let u,d,f,p;n===s-1?(d=a-t,p=a):(d=n*t,p=(n+1)*t),r===c-1?(u=o-l,f=o):(u=r*l,f=(r+1)*l);let m=await dl(e,[d,u],[p,f],[2,3]);i.push(m)}let u=n,d=r;(a!==u||o!==d)&&(e=await ol(e,{size:[u,d]}))}return i.push(e),{frames:i,num_splits_h:s,num_splits_w:c}}},Lf=class extends q{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(e=>e*this.rescale_factor)}pad_image(e,t,n,r){return super.pad_image(e,t,n,{constant_values:this.constant_values,center:!0,...r})}},Rf=class extends q{constructor(e){let{resize_mode:t,fill_color:n,interpolation:r,size:i,...a}=e,o=t===`squash`?{width:i,height:i}:t===`shortest`?{shortest_edge:i}:{longest_edge:i},s=r===`bicubic`?3:2;super({...a,size:o,resample:s,do_center_crop:!0,crop_size:i,do_normalize:!0})}};function zf(e,t){return Math.round(e/t)*t}function Bf(e,t,n,r,i){let a=1/0,o=[1,1],s=n*r;for(let n of t){let t=Math.abs(e-n[0]/n[1]);t<a?(a=t,o=n):t===a&&s>.5*i*i*n[0]*n[1]&&(o=n)}return o}function Vf(e,t){let n=[],r=new Set;for(let i=e;i<=t;++i)for(let a=1;a<=i;++a)for(let o=1;o<=i;++o){let i=a*o;if(i>=e&&i<=t){let e=a<<16|o;r.has(e)||(r.add(e),n.push([a,o]))}}return n.sort((e,t)=>e[0]*e[1]-t[0]*t[1])}function Hf(e,t){let[n,r,i,a]=e.dims,o=Math.floor(i/t),s=Math.floor(a/t),c=t*t*r,l=e.data,u=new Float32Array(n*o*s*c),d=i*a;for(let e=0;e<n;++e){let n=e*r*d,i=e*o*s*c;for(let e=0;e<o;++e)for(let o=0;o<s;++o){let f=i+(e*s+o)*c;for(let i=0;i<t;++i){let s=(e*t+i)*a+o*t;for(let e=0;e<t;++e){let t=s+e;for(let e=0;e<r;++e)u[f++]=l[n+e*d+t]}}}}return new U(`float32`,u,[n,o*s,c])}function Uf(e,t){let[,n,r]=e.dims,i=new BigInt64Array(t);i.fill(1n,0,n);let a=e;if(n<t){let n=new Float32Array(t*r);n.set(e.data),a=new U(`float32`,n,[1,t,r])}return{padded:a,mask:new U(`int64`,i,[t])}}var Wf=class extends q{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 t=this.max_image_tokens*this.downsample_factor**2,n=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(t,n)}_is_image_too_large(e,t){let n=this.encoder_patch_size*this.downsample_factor;return Math.max(this.encoder_patch_size,zf(e,n))*Math.max(this.encoder_patch_size,zf(t,n))>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){let n=Vf(this.min_tiles,this.max_tiles),[r,i]=Bf(t/e,n,t,e,this.tile_size);return{grid_width:r,grid_height:i,target_width:this.tile_size*r,target_height:this.tile_size*i}}async _call(e,{return_row_col_info:t=null}={}){let n;n=Array.isArray(e)?Array.isArray(e[0])?e:[e]:[[e]];let r=[],i=[],a=[],o=[],s=[],c=[];for(let e of n){let t=await Promise.all(e.map(e=>this.preprocess(e,{do_pad:!1})));for(let{pixel_values:e}of t){let[,t,n]=e.dims,l=e.unsqueeze_(0),u=this.encoder_patch_size*this.downsample_factor,d=u**2,[f,p]=of(Math.max(u,t),Math.max(u,n),u,this.min_image_tokens*d,this.max_image_tokens*d).map(e=>Math.max(u,e)),m,h=1,g=1,_=this._is_image_too_large(t,n),v=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(_&&v){let{grid_width:e,grid_height:r,target_width:i,target_height:a}=this._get_grid_layout(t,n);h=r,g=e;let o=await ol(l,{size:[a,i]});m=[];for(let t=0;t<r;++t)for(let n=0;n<e;++n){let e=t*this.tile_size,r=n*this.tile_size;m.push(o.slice(null,null,[e,e+this.tile_size],[r,r+this.tile_size]))}this.use_thumbnail&&e*r!==1&&m.push(await ol(l,{size:[p,f]}))}else m=[await ol(l,{size:[p,f]})];for(let e of m){let[,,t,n]=e.dims,{padded:o,mask:s}=Uf(Hf(e,this.encoder_patch_size),this.max_num_patches);r.push(o),i.push(s),a.push([Math.floor(t/this.encoder_patch_size),Math.floor(n/this.encoder_patch_size)])}o.push(h),s.push(g),c.push([p,f])}}let l={pixel_values:_l(r,0),pixel_attention_mask:vl(i,0),spatial_shapes:new U(`int64`,BigInt64Array.from(a.flat(),BigInt),[a.length,2])};return(t??this.return_row_col_info)&&(l.image_rows=o,l.image_cols=s,l.image_sizes=c),l}},Gf=class extends q{},Kf=class extends q{post_process_panoptic_segmentation(...e){return sf(...e)}post_process_instance_segmentation(...e){return cf(...e)}},qf=class extends Kf{},Jf=class extends Kf{},Yf=class extends q{},Xf=class extends Yf{},Zf=class extends q{},Qf=class extends Zf{},$f=class extends q{},ep=class extends $f{},tp=class extends q{},np=class extends tp{},rp=class extends q{},ip=class extends rp{},ap=class extends Cf{},op=class extends q{post_process_object_detection(...e){return ef(...e)}},sp=class extends op{},cp=class extends op{},lp=336,up=[2,3],{ceil:dp,floor:fp,sqrt:pp}=Math,mp=class extends q{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,t){let{num_img_tokens:n}=this.config;return fp((fp(t/lp)*fp(e/lp)+1)*n+1+(fp(t/lp)+1)*pp(n))}get_resize_output_image_size(e,t){let n=this._num_crops,[r,i]=e.size,a=r/i,o=1;for(;o*Math.ceil(o/a)<=n;)o+=1;--o;let s=Math.floor(o*336);return[s,Math.floor(s/a)]}pad_image(e,t,n,r={}){let[i,a]=t,o=lp*dp(i/lp),s=lp*dp(a/lp),c=[1,1,1].map((e,t)=>(e-this.image_mean[t])/this.image_std[t]);return super.pad_image(e,t,{width:s,height:o},{center:!0,constant_values:c,...r})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||pp(t)%1!=0)throw Error(`num_crops must be a square number >= 4`);Array.isArray(e)||(e=[e]);let n=e.length,r=await Promise.all(e.map(e=>this.preprocess(e))),i=r.map(e=>e.original_size),a=r.map(e=>e.reshaped_input_size),o=[];for(let{pixel_values:e}of r){e.unsqueeze_(0);let[n,r]=e.dims.slice(-2),i=await ol(e,{size:[lp,lp],mode:`bicubic`});if(t>0){let a=[],s=pp(t),c=fp(r/s),l=fp(n/s);for(let t=0;t<s;++t)for(let i=0;i<s;++i){let o,u,d,f;t===s-1?(u=n-l,f=n):(u=t*l,f=(t+1)*l),i===s-1?(o=r-c,d=r):(o=i*c,d=(i+1)*c);let p=await dl(e,[u,o],[f,d],up);a.push(p)}let u=await ol(_l(a,0),{size:[lp,lp],mode:`bicubic`});o.push(_l([i,u],0))}else o.push(i)}let s=vl(o,0),c=a.map(e=>e.map(e=>lp*dp(e/lp)));return{pixel_values:s,original_sizes:i,reshaped_input_sizes:a,image_sizes:new U(`int64`,c.flat(),[n,2]),num_img_tokens:c.map(([e,t])=>this.calc_num_image_tokens_from_image_size(t,e))}}},hp=class extends q{get_resize_output_image_size(e,t){let{longest_edge:n}=t;if(n===void 0)throw Error(`size must contain 'longest_edge'`);let[r,i]=e.size,a=Math.max(r,i)/n,o=r,s=i;a>1&&(o=Math.floor(r/a),s=Math.floor(i/a));let{patch_size:c,spatial_merge_size:l}=this.config;if(!l)throw Error(`config must contain 'spatial_merge_size'`);let u=c*l,d=Math.floor((o-1)/u)+1,f=Math.floor((s-1)/u)+1;return[d*u,f*u]}},gp=class extends q{},_p=class extends q{post_process_object_detection(...e){return ef(...e)}},vp=class extends q{reshape_input_points(e,t,n,r=!1){e=structuredClone(e);let i=si(e);if(i.length===3)r||(i=[1,...i]),e=[e];else if(i.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 r=0;r<e.length;++r){let[i,a]=t[r],[o,s]=n[r],c=[s/a,o/i];for(let t=0;t<e[r].length;++t)for(let n=0;n<e[r][t].length;++n)for(let i=0;i<e[r][t][n].length;++i)e[r][t][n][i]*=c[i%2]}return new U(`float32`,Float32Array.from(e.flat(1/0)),i)}add_input_labels(e,t){let n=si(e);if(n.length===2)n=[1,...n],e=[e];else if(n.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(n.some((e,n)=>e!==t.dims[n]))throw Error(`The first ${n.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new U(`int64`,e.flat(1/0).map(BigInt),n)}async _call(e,{input_points:t=null,input_labels:n=null,input_boxes:r=null}={}){let i=await super._call(e);if(t&&(i.input_points=this.reshape_input_points(t,i.original_sizes,i.reshaped_input_sizes)),n){if(!i.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");i.input_labels=this.add_input_labels(n,i.input_points)}return r&&(i.input_boxes=this.reshape_input_points(r,i.original_sizes,i.reshaped_input_sizes,!0)),i}async post_process_masks(e,t,n,{mask_threshold:r=0,binarize:i=!0,pad_size:a=null}={}){let o=[];a=a??this.pad_size??this.size;let s=[a.height,a.width];for(let a=0;a<t.length;++a){let c=t[a],l=n[a],u=await ol(e[a],{mode:`bilinear`,size:s});if(u=u.slice(null,null,[0,l[0]],[0,l[1]]),u=await ol(u,{mode:`bilinear`,size:c}),i){let e=u.data,t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)e[n]>r&&(t[n]=1);u=new U(`bool`,t,u.dims)}o.push(u)}return o}generate_crop_boxes(e,t,{crop_n_layers:n=0,overlap_ratio:r=512/1500,points_per_crop:i=32,crop_n_points_downscale_factor:a=1}={}){}},yp=class extends q{post_process_semantic_segmentation(...e){return tf(...e)}},bp=class extends yp{},xp=class extends q{post_process_semantic_segmentation(...e){return tf(...e)}},Sp=class extends xp{},Cp=class extends q{},wp=class extends q{pad_image(e,t,n,r={}){let[i,a,o]=t;return super.pad_image(e,t,{width:a+(n-a%n)%n,height:i+(n-i%n)%n},{mode:`symmetric`,center:!1,constant_values:-1,...r})}},Tp=class extends q{},Ep=class extends Tp{},Dp=class extends q{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let n=await Promise.all(e.map(e=>this.preprocess(e))),r=await Promise.all(t.map(e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:vl(n.map((e,t)=>_l([e.pixel_values,r[t].pixel_values],0)),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}},Op=class extends q{post_process_pose_estimation(e,t,{threshold:n=null}={}){let r=e.tolist(),[i,a,o,s]=e.dims,c=[];for(let e=0;e<i;++e){let i=r[e],a=t[e],l=[];for(let e=0;e<a.length;++e){let t=a[e],r=[],c=[],u=[],d=t.at(-2)/s,f=t.at(-1)/o;for(let e=0;e<i.length;++e){let[t,a]=[0,0],o=0,s=-1/0,l=i[e];for(let e=0;e<l.length;++e){let n=l[e];for(let r=0;r<n.length;++r){let i=n[r];o+=i,s=Math.max(s,i),t+=(r+.5)*i,a+=e*i}}if(n!=null&&s<n)continue;let p=[d*t/o,f*a/o];r.push(p),u.push(e),c.push(s)}l.push({bbox:t,scores:c,labels:u,keypoints:r})}c.push(l)}return c}},kp=class extends q{post_process_object_detection(...e){return ef(...e)}},Ap=class extends kp{},jp=class{static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t),r=n.image_processor_type??n.feature_extractor_type,i=lf[r?.replace(/Fast$/,``)];return i||=(r!==void 0&&N.warn(`Image processor type '${r}' not found, assuming base ImageProcessor. Please report this at ${Vu}.`),q),new i(n)}},Mp=class extends K{static tokenizer_class=G;static image_processor_class=jp;constructor(e,t,n){super(e,t,n);let{tasks_answer_post_processing_type:r,task_prompts_without_inputs:i,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(r??{})),this.task_prompts_without_inputs=new Map(Object.entries(i??{})),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 t=[];for(let n of e)if(this.task_prompts_without_inputs.has(n))t.push(this.task_prompts_without_inputs.get(n));else{for(let[e,r]of this.task_prompts_with_input)if(n.includes(e)){t.push(r.replaceAll(`{input}`,n).replaceAll(e,``));break}t.length!==e.length&&t.push(n)}return t}post_process_generation(e,t,n){let r=this.tasks_answer_post_processing_type.get(t)??`pure_text`;e=e.replaceAll(`<s>`,``).replaceAll(`</s>`,``);let i;switch(r){case`pure_text`:i=e;break;case`description_with_bboxes`:case`bboxes`:case`phrase_grounding`:case`ocr`:let a=r===`ocr`?`quad_boxes`:`bboxes`,o=e.matchAll(this.regexes[a]),s=[],c=[];for(let[e,t,...r]of o)s.push(t?t.trim():s.at(-1)??``),c.push(r.map((e,t)=>(Number(e)+.5)/this.size_per_bin*n[t%2]));i={labels:s,[a]:c};break;default:throw Error(`Task "${t}" (of type "${r}") not yet implemented.`)}return{[t]:i}}async _call(e,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=await this.image_processor(e,n),i=t?this.tokenizer(this.construct_prompts(t),n):{};return{...r,...i}}},Np=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.image_seq_length=this.config.image_seq_length;let{boi_token:r,image_token:i,eoi_token:a}=this.tokenizer.config;this.boi_token=r,this.image_token=i,this.eoi_token=a;let o=i.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
14
14
|
|
|
15
15
|
${r}${o}${a}
|
|
16
16
|
|
|
@@ -34,6 +34,6 @@ ${this.boa_token}${this.audio_token.repeat(this._compute_audio_num_tokens(t[o++]
|
|
|
34
34
|
`}return o+=`
|
|
35
35
|
${r}${a}`+i.repeat(e)+`${r}`,o}function Hp(e,t,n,r){return`${t}${r}`+n.repeat(e)+`${t}`}function Up(e,t,n,r,i,a){return e===0&&t===0?Hp(n,r,i,a):Vp(n,e,t,r,i,a)}var Wp=class extends K{static image_processor_class=jp;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,t=null,n={}){n.return_row_col_info??=!0;let r;t&&(r=await this.image_processor(t,n)),Array.isArray(e)||(e=[e]);let i=r.rows??[Array(e.length).fill(0)],a=r.cols??[Array(e.length).fill(0)],o=this.config.image_seq_len,s=[],c=[];for(let t=0;t<e.length;++t){let n=e[t],r=i[t],l=a[t];s.push(fi(n,this.image_token));let u=r.map((e,t)=>Up(e,l[t],o,this.fake_image_token,this.image_token,this.global_img_token)),d=n.split(this.image_token);if(d.length===0)throw Error(`The image token should be present in the text.`);let f=d[0];for(let e=0;e<u.length;++e)f+=u[e]+d[e+1];c.push(f)}return{...this.tokenizer(c),...r}}},Gp=class extends K{static image_processor_class=jp;static tokenizer_class=G;static uses_processor_config=!0;constructor(e,t,n){super(e,t,n),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:t=null,chat_template:n=`default`}={}){t?Array.isArray(t)||(t=[t]):t=await Promise.all(e.filter(e=>e.images).flatMap(e=>e.images).map(e=>Yd.read(e)));let r=this.tokenizer,i=r.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:n}),a=e=>r.encode(e,{add_special_tokens:!1}),o=i.split(this.image_tag),s=o.length-1;if(t.length!==s)throw Error(`Number of images provided (${t.length}) does not match number of "${this.image_tag}" image tags (${s})`);let[c,l,u]=r.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),d=a(o[0]),f=Array(d.length).fill(!1);for(let e=1;e<o.length;++e){let t=Array(this.num_image_tokens).fill(c),n=a(o[e]);d=ci(d,[l],t,[u],n);let r=Array(this.num_image_tokens).fill(!0);f=ci(f,[!1],r,[!1],Array(n.length).fill(!1))}let p=[1,d.length],m={input_ids:new U(`int64`,d,p),attention_mask:new U(`int64`,Array(d.length).fill(1),p),images_seq_mask:new U(`bool`,f,p),images_emb_mask:new U(`bool`,Array(s*this.num_image_tokens).fill(!0),[1,s,this.num_image_tokens])};if(t&&t.length>0){let e=await this.image_processor(t);return e.pixel_values.unsqueeze_(0),{...m,...e}}return m}},Kp=class extends K{static tokenizer_class=G;static image_processor_class=jp;async _call(e=null,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=e?this.tokenizer(e,n):{},i=t?await this.image_processor(t,n):{};return{...r,...i}}},qp=class extends K{static tokenizer_class=G;static image_processor_class=jp;async _call(e,t=null,n={}){let{image_rows:r,image_cols:i,image_sizes:a,...o}=await this.image_processor(e,{...n,return_row_col_info:!0});if(t){let e=this.config.image_token??`<image>`,{tile_size:n=512,downsample_factor:o=2,encoder_patch_size:s=16,use_thumbnail:c=!0}=this.image_processor.config,l=e=>Math.ceil(Math.floor(e/s)/o),u=l(n)**2,d=this.config.image_start_token??`<|image_start|>`,f=this.config.image_end_token??`<|image_end|>`,p=this.config.image_thumbnail??`<|img_thumbnail|>`;Array.isArray(t)||(t=[t]);let m=0;t=t.map(t=>{let n=t.split(e);return n[0]+n.slice(1).map(t=>{let n=m++,[o,s]=a[n],h=r[n],g=i[n],_=l(o)*l(s),v=d;if(h>1||g>1){let t=e.repeat(u);for(let e=0;e<h;++e)for(let n=0;n<g;++n)v+=`<|img_row_${e+1}_col_${n+1}|>`+t;c&&(v+=p+e.repeat(_))}else v+=e.repeat(_);return v+f+t}).join(``)})}return{...o,...t?this.tokenizer(t,n):{}}}},Jp=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,patch_size:a,num_additional_image_tokens:o}=this.config,s=Math.floor(e/a)*Math.floor(n/a)+o;t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;++e)t[e]=t[e].replace(i,i.repeat(s))}let i=t?this.tokenizer(t,n):{};return{...r,...i}}},Yp={char:[`char_decode`,1],bpe:[`bpe_decode`,2],wp:[`wp_decode`,102]},Xp=class extends K{static tokenizer_class=G;static image_processor_class=jp;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,t){if(!Yp.hasOwnProperty(t))throw Error(`Format ${t} is not supported.`);let[n,r]=Yp[t],i=this[n].bind(this),[a,o]=e.dims,s=[],c=[],l=e.tolist();for(let e=0;e<a;++e){let t=l[e],n=[],i=[];for(let e=1;e<o;++e){let[a,o]=fc(oc(t[e]));if(i.push(a),o==r)break;n.push(o)}let a=i.length>0?i.reduce((e,t)=>e*t,1):0;c.push(n),s.push(a)}return[i(c),s]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}batch_decode([e,t,n]){let[r,i]=this._decode_helper(e,`char`),[a,o]=this._decode_helper(t,`bpe`),[s,c]=this._decode_helper(n,`wp`),l=[],u=[];for(let e=0;e<r.length;++e){let[t,n]=fc([i[e],o[e],c[e]]);l.push([r[e],a[e],s[e]][n]),u.push(t)}return{generated_text:l,scores:u,char_preds:r,bpe_preds:a,wp_preds:s}}static async from_pretrained(...e){let t=await super.from_pretrained(...e),n=await G.from_pretrained(`Xenova/gpt2`),r=await G.from_pretrained(`Xenova/bert-base-uncased`);return t.components={image_processor:t.image_processor,char_tokenizer:t.tokenizer,bpe_tokenizer:n,wp_tokenizer:r},t}async _call(e,t=null){let n=await this.image_processor(e);return t&&(n.labels=this.tokenizer(t).input_ids),n}},Zp=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Qp=class extends K{static tokenizer_class=G;static image_processor_class=jp},$p=`<image>`;function em(e,t,n,r,i){return`${r.repeat(n*i)}${t}${e}
|
|
36
36
|
`}var tm=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!1;async _call(e,t=null,n={}){t||=(N.warn(`You are using PaliGemma without a text prefix. It will perform as a picture-captioning model.`),``),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let r=this.tokenizer.bos_token,i=this.image_processor.config.image_seq_length,a;t.some(e=>e.includes($p))?a=t.map(e=>{let t=e.replaceAll($p,$p.repeat(i)),n=t.lastIndexOf($p),a=n===-1?0:n+$p.length;return t.slice(0,a)+r+t.slice(a)+`
|
|
37
|
-
`}):(N.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=t.map(t=>em(t,r,i,$p,e.length)));let o=this.tokenizer(a,n);return{...await this.image_processor(e,n),...o}}},nm=`<|image|>`,rm=/<\|image_\d+\|>/g,im=class extends K{static image_processor_class=jp;static tokenizer_class=G;async _call(e,t=null,{padding:n=!0,truncation:r=!0,num_crops:i=null}={}){Array.isArray(e)||(e=[e]);let a,o;if(t){o=await this.image_processor(t,{num_crops:i});let{num_img_tokens:s}=o,c=e.map((e,t)=>e.split(rm).join(nm.repeat(s[t])));a=this.tokenizer(c,{padding:n,truncation:r});let l=this.tokenizer._tokenizer.token_to_id(nm);a.input_ids.map_(e=>e==l?-e:e)}else a=this.tokenizer(e);return{...a,...o}}},am=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,image_break_token:a,image_end_token:o,patch_size:s,spatial_merge_size:c}=this.config,l=s*c,u=Math.floor(e/l),d=Math.floor(n/l);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;++e){let n=i.repeat(d),r=n+a,s=n+o,c=r.repeat(u-1)+s;t[e]=t[e].replace(i,c)}}let i=t?this.tokenizer(t,n):{};return{...r,...i}}},om=class extends K{static feature_extractor_class=jd;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}},sm=class extends Ip{},cm=class extends sm{},lm=class extends K{static image_processor_class=jp;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)}},um=class extends lm{},dm=class extends um{},fm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},pm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!0;async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){let i=t.length,{input_features:a}=await this.feature_extractor(t,{...n,max_length:i}),o=Math.round(i/this.config.encoder_ds_factor+1e-4),s=1+Math.ceil(o/this.config.stack_factor);r.audio_token_len=[s],r.audio_values=a;let c=this.config.audio_placeholder;if(!e.includes(c))throw Error(`The input text does not contain the image token ${c}.`);e=e.replaceAll(c,c.repeat(s))}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}},mm=`[AUDIO]`,hm=`[BEGIN_AUDIO]`,gm=375;function _m(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,Math.min(r+t,e.length)));return n}var vm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!1;async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){if(!e.includes(mm))throw Error(`The input text does not contain the audio token ${mm}.`);Array.isArray(t)||(t=[t]);let i=e.split(mm),a=i.length-1;if(a!==t.length)throw Error(`The number of audio inputs (${t.length}) does not match the number of audio tokens in the text (${a}).`);let o=this.feature_extractor.config.n_samples,s=t.map(e=>_m(e,o)),c=s.map(e=>e.length),l=s.flat(),u=(await Promise.all(l.map(e=>this.feature_extractor(e,n)))).map(e=>e.input_features);r.audio_values=u.length>1?_l(u,0):u[0];let d=i[0];for(let e=0;e<c.length;++e){d+=hm;for(let t=0;t<c[e];++t)d+=mm.repeat(gm);d+=i[e+1]}e=d}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}},ym=32,bm=6,xm=8,Sm=10,Cm=32,wm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(bm+1)*xm}get num_samples_first_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return(this.num_mel_frames_first_audio_chunk-1)*e+Math.floor(t/2)}get num_samples_per_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return xm*e+t}get num_right_pad_tokens(){return bm+1+Sm}get audio_length_per_tok(){return xm}get raw_audio_length_per_tok(){return xm*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:t=!1,is_first_audio_chunk:n=!0}={}){if(Ju(e,`VoxtralRealtimeProcessor`),!t&&!n)throw Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(n)if(t){let t=ym*this.raw_audio_length_per_tok,n=new Float32Array(t+e.length);n.set(e,t);let r=await this.feature_extractor(n,{center:!0}),i=1+(ym+bm),a=new BigInt64Array(i).fill(BigInt(Cm));return a[0]=1n,{input_ids:new U(`int64`,a,[1,i]),...r}}else{let t=this.num_right_pad_tokens*this.raw_audio_length_per_tok,n=new Float32Array(e.length+t);return n.set(e),await this.feature_extractor(n,{center:!0})}else return await this.feature_extractor(e,{center:!1})}},Tm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Em=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Dm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Om=class{static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t),{image_processor_type:r,feature_extractor_type:i,processor_class:a}=n;if(a&&Ku[a])return Ku[a].from_pretrained(e,t);if(!r&&!i)throw Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let o={};if(r){let e=lf[r.replace(/Fast$/,``)];if(!e)throw Error(`Unknown image_processor_type: '${r}'.`);o.image_processor=new e(n)}if(i){let e=lf[i];if(e)o.image_processor=new e(n);else{let e=Yu[i];if(!e)throw Error(`Unknown feature_extractor_type: '${i}'.`);o.feature_extractor=new e(n)}}return new K({},o,null)}};async function km(e,t){return await rc(e,`config.json`,!0,t)}function Am(e){let t={},n={};switch(e.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`gemma4`:case`lfm2_vl`:case`chatterbox`:case`lighton_ocr`:case`glm_ocr`:case`mistral3`:case`qwen2_5_vl`:case`qwen3_vl`:case`qwen3_vl_moe`:n=Am(e.text_config);break;case`moondream1`:n=Am(e.phi_config);break;case`musicgen`:n=Am(e.decoder);break;case`multi_modality`:n=Am(e.language_config);break;case`gpt2`:case`gptj`:case`jais`:case`codegen`:case`gpt_bigcode`:t.num_heads=`n_head`,t.num_layers=`n_layer`,t.hidden_size=`n_embd`;break;case`gpt_neox`:case`stablelm`:case`opt`:case`falcon`:case`modernbert-decoder`:t.num_heads=`num_attention_heads`,t.num_layers=`num_hidden_layers`,t.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`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.hidden_size=`hidden_size`,t.num_attention_heads=`num_attention_heads`,t.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`gemma4_text`:case`glm`:case`helium`:case`ernie4_5`:case`hunyuan_v1_dense`:case`falcon_h1`:case`nemotron_h`:case`ministral`:case`ministral3`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.dim_kv=`head_dim`;break;case`openelm`:t.num_heads=`num_kv_heads`,t.num_layers=`num_transformer_layers`,t.dim_kv=`head_dim`;break;case`gpt_neo`:case`donut-swin`:t.num_heads=`num_heads`,t.num_layers=`num_layers`,t.hidden_size=`hidden_size`;break;case`bloom`:t.num_heads=`n_head`,t.num_layers=`n_layer`,t.hidden_size=`hidden_size`;break;case`mpt`:t.num_heads=`n_heads`,t.num_layers=`n_layers`,t.hidden_size=`d_model`;break;case`exaone`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_layers`,t.dim_kv=`head_dim`,t.num_attention_heads=`num_attention_heads`;break;case`youtu`:case`deepseek_v3`:case`glm_moe_dsa`:case`mistral4`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.dim_kv=`qk_head_dim`,t.num_attention_heads=`num_attention_heads`;break;case`t5`:case`mt5`:case`longt5`:t.num_decoder_layers=`num_decoder_layers`,t.num_decoder_heads=`num_heads`,t.decoder_dim_kv=`d_kv`,t.num_encoder_layers=`num_layers`,t.num_encoder_heads=`num_heads`,t.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`:t.num_decoder_layers=`decoder_layers`,t.num_decoder_heads=`decoder_attention_heads`,t.decoder_hidden_size=`d_model`,t.num_encoder_layers=`encoder_layers`,t.num_encoder_heads=`encoder_attention_heads`,t.encoder_hidden_size=`d_model`;break;case`speecht5`:t.num_decoder_layers=`decoder_layers`,t.num_decoder_heads=`decoder_attention_heads`,t.decoder_hidden_size=`hidden_size`,t.num_encoder_layers=`encoder_layers`,t.num_encoder_heads=`encoder_attention_heads`,t.encoder_hidden_size=`hidden_size`;break;case`trocr`:t.num_encoder_layers=t.num_decoder_layers=`decoder_layers`,t.num_encoder_heads=t.num_decoder_heads=`decoder_attention_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`d_model`;break;case`musicgen_decoder`:t.num_encoder_layers=t.num_decoder_layers=`num_hidden_layers`,t.num_encoder_heads=t.num_decoder_heads=`num_attention_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`hidden_size`;break;case`moonshine`:t.num_decoder_layers=`decoder_num_hidden_layers`,t.num_decoder_heads=`decoder_num_key_value_heads`,t.num_encoder_layers=`encoder_num_hidden_layers`,t.num_encoder_heads=`encoder_num_key_value_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`hidden_size`;break;case`cohere_asr`:t.num_decoder_layers=`num_hidden_layers`,t.num_decoder_heads=`num_key_value_heads`,t.decoder_hidden_size=`hidden_size`,t.decoder_dim_kv=`head_dim`;let{num_hidden_layers:r,num_attention_heads:i,hidden_size:a}=e.encoder_config;n={num_encoder_layers:r,num_encoder_heads:i,encoder_hidden_size:a,encoder_dim_kv:e.head_dim};break;case`vision-encoder-decoder`:let o=Am(e.decoder),s=`num_decoder_layers`in o,c=di(e,[`model_type`,`is_encoder_decoder`]);return s?(c.num_decoder_layers=o.num_decoder_layers,c.num_decoder_heads=o.num_decoder_heads,c.decoder_hidden_size=o.decoder_hidden_size,c.num_encoder_layers=o.num_encoder_layers,c.num_encoder_heads=o.num_encoder_heads,c.encoder_hidden_size=o.encoder_hidden_size):(c.num_layers=o.num_layers,c.num_heads=o.num_heads,c.hidden_size=o.hidden_size),c}let r={...n,...di(e,[`model_type`,`multi_query`,`is_encoder_decoder`])};for(let n in t)r[n]=e[t[n]];return r}function jm(e,t){e instanceof Nm||(e=new Nm(e));let n=t?.prefix??`past_key_values`,r=n===`present`?`present`:`past`,i=new Set;if([`lfm2`,`lfm2_moe`].includes(e.model_type)){let{layer_types:t}=e;for(let e=0;e<t.length;++e)if(t[e]===`full_attention`)i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`);else if(t[e]===`conv`)i.add(`${r}_conv.${e}`);else throw Error(`Unsupported layer type: ${t[e]}`);return i}else if([`granitemoehybrid`,`falcon_h1`,`nemotron_h`].includes(e.model_type)){let t=e,a=t.layer_types??t.layers_block_type,o=t.num_hidden_layers??a?.length;for(let e=0;e<o;++e)(!a||a[e]===`mamba`)&&(i.add(`${r}_conv.${e}`),i.add(`${r}_ssm.${e}`)),(!a||a[e]===`attention`)&&(i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`));return i}else if([`qwen3_next`,`qwen3_5_text`,`qwen3_5_moe_text`,`olmo_hybrid`].includes(e.model_type)){let{layer_types:t}=e;for(let a=0;a<t.length;++a)if(t[a]===`full_attention`)i.add(`${n}.${a}.key`),i.add(`${n}.${a}.value`);else if(t[a]===`linear_attention`)e.model_type===`olmo_hybrid`?(i.add(`${r}_conv.${a}.key`),i.add(`${r}_conv.${a}.value`),i.add(`${r}_conv.${a}.query`)):i.add(`${r}_conv.${a}`),i.add(`${r}_recurrent.${a}`);else throw Error(`Unsupported layer type: ${t[a]}`);return i}else if([`gemma4`,`gemma4_text`].includes(e.model_type)){let t=e.model_type===`gemma4`?e.text_config:e,r=t.num_hidden_layers-(t.num_kv_shared_layers??0);for(let e=0;e<r;++e)i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`);return i}else if([`lfm2_vl`,`qwen3_5`,`qwen3_5_moe`,`voxtral_realtime`].includes(e.model_type)){let n;return n=e.model_type===`voxtral_realtime`&&t?.session_name===`audio_encoder`?e.audio_config:e.text_config,jm(n,t)}return Mm(e,{prefix:n})}function Mm(e,{prefix:t=`past_key_values`}={}){let n=new Set,r=e.normalized_config;if(r.is_encoder_decoder&&`num_encoder_heads`in r&&`num_decoder_heads`in r)for(let e=0;e<r.num_decoder_layers;++e)n.add(`${t}.${e}.encoder.key`),n.add(`${t}.${e}.encoder.value`),n.add(`${t}.${e}.decoder.key`),n.add(`${t}.${e}.decoder.value`);else if(r.multi_query)for(let e=0;e<r.num_layers;++e)n.add(`${t}.${e}.key_value`);else for(let e=0;e<r.num_layers;++e)n.add(`${t}.${e}.key`),n.add(`${t}.${e}.value`);return n}var Nm=class e{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=Am(this)}static async from_pretrained(t,{progress_callback:n=null,config:r=null,cache_dir:i=null,local_files_only:a=!1,revision:o=`main`}={}){r&&!(r instanceof e)&&(r=new e(r));let s=r??await km(t,{progress_callback:n,config:r,cache_dir:i,local_files_only:a,revision:o});return new this(s)}},Pm=class{static async from_pretrained(...e){return Nm.from_pretrained(...e)}};function Fm(e,t,n){return e?typeof e==`object`&&e?e.hasOwnProperty(t)?+e[t]:e.hasOwnProperty(n)?+e[n]:0:+e:0}function Im(e,t){let n=[];for(let r=0;r<t;++r)n.push(`${e}_data${r===0?``:`_`+r}`);return n}async function Lm(e,t,n,r){let i=`${t}${r}.onnx`;return await tc(e,`${n.subfolder??``}/${i}`,!0,n,j.IS_NODE_ENV)}async function Rm(e,t,n,r,i,a={}){let o=`${t}${n}.onnx`,s=j.IS_NODE_ENV,c=[],l=Fm(i,o,t);if(l>0){if(l>Os)throw Error(`The number of external data chunks (${l}) exceeds the maximum allowed value (${Os}).`);let t=Im(o,l);for(let n of t){let t=`${r.subfolder??``}/${n}`;c.push(new Promise(async(i,a)=>{let o=await tc(e,t,!0,r,s);i(o instanceof Uint8Array?{path:n,data:o}:n)}))}}else a.externalData!==void 0&&(c=a.externalData.map(async t=>{if(typeof t.data==`string`){let n=await tc(e,t.data,!0,r);return{...t,data:n}}return t}));return Promise.all(c)}async function zm(e,t,n,r=!1,i=void 0){let a=n.config?.[`transformers.js_config`]??{},o=Yc(n.device??a.device,t,{warn:e=>N.info(e)}),s=Fc(o),c=a.device_config??{};c.hasOwnProperty(o)&&(a={...a,...c[o]});let l=tl(n.dtype??a.dtype,t,o,{configDtype:a.dtype,warn:e=>N.info(e)});if(!el.hasOwnProperty(l))throw Error(`Invalid dtype: ${l}. Should be one of: ${Object.keys(Zc).join(`, `)}`);if(o===`webgpu`&&!j.IS_NODE_ENV&&l===Zc.fp16&&!await Xc())throw Error(`The device (${o}) does not support fp16.`);let u=el[l],d={...n.session_options};d.executionProviders??=s;let f=a.free_dimension_overrides;f?d.freeDimensionOverrides??=f:o.startsWith(`webnn`)&&!d.freeDimensionOverrides&&N.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"]["${o}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let p=Lm(e,t,n,u),m=await Rm(e,t,u,n,n.use_external_data_format??a.use_external_data_format,d);if(m.length>0&&(!j.IS_NODE_ENV||m.some(e=>typeof e!=`string`))&&(d.externalData=m),r&&o===`webgpu`){let e=jm(n.config,{prefix:`present`,session_name:i});if(e.size>0&&!Wc()){let t={};for(let n of e)t[n]=`gpu-buffer`;d.preferredOutputLocation=t}}return{buffer_or_path:await p,session_options:d,session_config:{dtype:l,device:o}}}async function Bm(e,t,n,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async i=>{let a=r?.[i]??!1,{buffer_or_path:o,session_options:s,session_config:c}=await zm(e,t[i],n,a,i);return[i,await zc(o,s,c)]})))}function Vm(e){for(let t in e)Hc(e[t])?e[t]=new U(e[t]):typeof e[t]==`object`&&Vm(e[t]);return e}async function J(e,t){let n=Hm(e,t);try{return Vm(await Vc(e,Object.fromEntries(Object.entries(n).map(([e,t])=>{let n=t.ort_tensor;return j.IS_NODE_ENV&&typeof Float16Array<`u`&&n.cpuData instanceof Float16Array&&(n.cpuData=new Uint16Array(n.cpuData.buffer)),[e,n]}))))}catch(e){let t=Object.fromEntries(Object.entries(n).map(([e,t])=>{let n={type:t.type,dims:t.dims,location:t.location};return n.location!==`gpu-buffer`&&(n.data=t.data),[e,n]}));throw N.error(`An error occurred during model execution: "${e}".`),N.error(`Inputs given to model:`,t),e}}function Hm(e,t){let n=Object.create(null),r=[];for(let i of e.inputNames){let e=t[i];if(!(e instanceof U)){r.push(i);continue}n[i]=Wc()?e.clone():e}if(r.length>0)throw Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(`, `)}.`);let i=Object.keys(t).length,a=e.inputNames.length;if(i>a){let n=Object.keys(t).filter(t=>!e.inputNames.includes(t));N.warn(`WARNING: Too many inputs were provided (${i} > ${a}). The following inputs will be ignored: "${n.join(`, `)}".`)}return n}var Um=class{},Y=class extends Um{constructor({logits:e,...t}){super(),this.logits=e;let n=Object.values(t);n.length>0&&(this.attentions=n)}},Wm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Gm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Km=class extends Um{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},qm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Jm=class extends Um{constructor({alphas:e}){super(),this.alphas=e}},Ym=class extends ni{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Xm=class extends ni{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Zm=class extends ni{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let n=t;for(let t of this.processors)n=t(e,n);return n}[Symbol.iterator](){return this.processors.values()}},Qm=class extends Ym{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===1){let e=t[n].data;e.fill(-1/0),e[this.bos_token_id]=0}return t}},$m=class extends Ym{constructor(e,t){super(),this.max_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===this.max_length-1){let e=t[n].data;e.fill(-1/0);for(let t of this.eos_token_id)e[t]=0}return t}},eh=class extends Ym{constructor(e){super(),this.suppress_tokens=e}_call(e,t){for(let n=0;n<e.length;++n){let e=t[n].data;for(let t of this.suppress_tokens)e[t]=-1/0}return t}},th=class extends Ym{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===this.begin_index){let e=t[n].data;for(let t of this.begin_suppress_tokens)e[t]=-1/0}return t}},nh=class extends Ym{constructor(e,t){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=t.length,t.at(-1)===this.no_timestamps_token_id&&--this.begin_index,this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data;if(r[this.no_timestamps_token_id]=-1/0,e[n].length===this.begin_index){r.subarray(0,this.timestamp_begin).fill(-1/0);continue}let i=e[n].slice(this.begin_index),a=i.length>=1&&i[i.length-1]>=this.timestamp_begin,o=i.length<2||i[i.length-2]>=this.timestamp_begin;if(a&&(o?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e[n].length===this.begin_index&&this.max_initial_timestamp_index!==null){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let s=sc(r);Math.log(s.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>fc(s.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},rh=class extends Ym{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,n=[];for(let r=0;r<t+1-this.no_repeat_ngram_size;++r){let t=[];for(let n=0;n<this.no_repeat_ngram_size;++n)t.push(e[r+n]);n.push(t.map(Number))}let r=new Map;for(let e of n){let t=e.slice(0,e.length-1),n=JSON.stringify(t),i=r.get(n)??[];i.push(e[e.length-1]),r.set(n,i)}return r}getGeneratedNgrams(e,t){let n=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(n.map(Number)))??[]}calcBannedNgramTokens(e){let t=[];if(e.length+1<this.no_repeat_ngram_size)return t;{let t=this.getNgrams(e);return this.getGeneratedNgrams(t,e)}}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data,i=this.calcBannedNgramTokens(e[n]);for(let e of i)r[e]=-1/0}return t}},ih=class extends Ym{constructor(e){super(),this.penalty=e}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data;for(let t of new Set(e[n])){let e=Number(t);r[e]<0?r[e]*=this.penalty:r[e]/=this.penalty}}return t}},ah=class extends Ym{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length<this.min_length){let e=t[n].data;for(let t of this.eos_token_id)e[t]=-1/0}return t}},oh=class extends Ym{constructor(e,t,n){super(),this.prompt_length_to_skip=e,this.min_new_tokens=t,this.eos_token_id=Array.isArray(n)?n:[n]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length-this.prompt_length_to_skip<this.min_new_tokens){let e=t[n].data;for(let t of this.eos_token_id)e[t]=-1/0}return t}},sh=class extends Ym{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data,i=e[n];for(let e of this.bad_words_ids){if(i.length<e.length-1)continue;let t=!0;for(let n=1;n<=e.length-1;++n)if(e.at(-n-1)!=i.at(-n)){t=!1;break}t&&(r[e.at(-1)]=-1/0)}}return t}},ch=class extends Ym{constructor(e){if(super(),e<=1)throw Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw 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 ${t.dims[0]} for the logits and ${e.length} for the input ids.`);let n=e.length,r=t.slice([0,n],null),i=t.slice([n,t.dims[0]],null);for(let e=0;e<i.data.length;++e)i.data[e]+=(r.data[e]-i.data[e])*this.guidance_scale;return i}},lh=class extends Xm{constructor(e){if(super(),typeof e!=`number`||e<=0){let t=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(t+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,t){let n=t.data;for(let e=0;e<n.length;++e)n[e]/=this.temperature;return t}},uh=class extends Xm{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:n=1}={}){if(super(),e<0||e>1)throw Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(n)||n<1)throw Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${n}`);this.top_p=e,this.filter_value=t,this.min_tokens_to_keep=n}},dh=class extends Xm{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:n=1}={}){if(super(),!Number.isInteger(e)||e<0)throw Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,n),this.filter_value=t}},fh=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,di(e,Object.getOwnPropertyNames(this)))}},ph=class extends ni{_call(e,t){throw Error(`StoppingCriteria needs to be subclassed`)}},mh=class e extends ni{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(t){t instanceof e?t=t.criteria:t instanceof ph&&(t=[t]),this.criteria.push(...t)}_call(e,t){let n=Array(e.length).fill(!1);for(let r of this.criteria){let i=r(e,t);for(let e=0;e<n.length;++e)n[e]||=i[e]}return n}[Symbol.iterator](){return this.criteria.values()}},hh=class extends ph{constructor(e,t=null){super(),this.max_length=e,this.max_position_embeddings=t}_call(e){return e.map(e=>e.length>=this.max_length)}},gh=class extends ph{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(e=>{let t=e.at(-1);return this.eos_token_id.some(e=>t==e)})}},_h=class extends ph{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,t){return Array(e.length).fill(this.interrupted)}},vh=class extends ni{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,t){let n=e.dims.at(-1),r=e.data;if(t===-1)r=r.slice(-n);else{let e=t*n;r=r.slice(e,e+n)}return r}randomSelect(e){return ws(e)}static getSampler(e){if(e.do_sample)return new bh(e);if(e.num_beams>1)return new xh(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 yh(e)}},yh=class extends vh{async sample(e){let t=fc(e.data)[1];return[[BigInt(t),0]]}},bh=class extends vh{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await ll(e,t),i=oc(n.data);return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(i);return[r.data[e],Math.log(i[e])]})}},xh=class extends vh{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await ll(e,t),i=oc(n.data);return Array.from({length:this.generation_config.num_beams},(e,t)=>[r.data[t],Math.log(i[t])])}},Sh=class{constructor(e){if(e)for(let t in e){if(t in this)throw TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);let n=e[t];if(!(n instanceof U))throw TypeError(`Expected a Tensor for key "${t}", got ${typeof n}`);this[t]=n}}get_seq_length(){let e=this;if(Object.keys(e).length===0)return 0;for(let t in e)if(t.startsWith(`past_key_values.`))return e[t].dims.at(-2);throw Error(`Unable to determine sequence length from the cache.`)}update(e){for(let t in e){let n=this[t],r=e[t];n&&n!==r&&n.location===`gpu-buffer`&&n.dispose(),this[t]=r}}async dispose(){let e=[];for(let t of Object.values(this))t.location===`gpu-buffer`&&e.push(t.dispose());await Promise.all(e)}},X={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},Ch={[X.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??`model`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[X.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??`model`})},[X.Seq2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.Vision2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.Musicgen]:{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`}},[X.EncoderDecoder]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0}},[X.MaskGeneration]:{sessions:()=>({model:`vision_encoder`,prompt_encoder_mask_decoder:`prompt_encoder_mask_decoder`})},[X.ImageTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.ImageTextToText].text_only_sessions};return n||(r.vision_encoder=`vision_encoder`),e.is_encoder_decoder&&(r.model=`encoder_model`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.AudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.AudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.ImageAudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`,r.vision_encoder=`vision_encoder`),r},optional_configs:{generation_config:`generation_config.json`}},[X.Phi3V]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`model`,vision_encoder:`vision_encoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[X.MultiModality]:{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`}},[X.AutoEncoder]:{sessions:()=>({encoder_model:`encoder_model`,decoder_model:`decoder_model`})},[X.Supertonic]:{sessions:()=>({text_encoder:`text_encoder`,latent_denoiser:`latent_denoiser`,voice_decoder:`voice_decoder`})},[X.Chatterbox]:{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`}},[X.VoxtralRealtime]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.VoxtralRealtime].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:`generation_config.json`}},default:{sessions:(e,t)=>({model:t.model_file_name??`model`})}};function wh(e){return Ch[e]?.text_only_sessions??null}function Th(e,t,n={}){let r=Ch[e]??Ch.default;return{sessions:r.sessions(t,n,n.textOnly??!1),cache_sessions:r.cache_sessions,optional_configs:r.optional_configs}}function Eh(e,{warn:t=!0}={}){let n=e.architectures||[];for(let e of n){let t=Fh.get(e);if(t!==void 0)return t}if(e.model_type){let t=Fh.get(e.model_type);if(t!==void 0)return t;for(let t of Object.values(kh))if(t.has(e.model_type)){let n=Fh.get(t.get(e.model_type));if(n!==void 0)return n}}if(t){let t=n.length>0?n.join(`, `):`(none)`;N.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${t}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${Vu}`)}return X.EncoderOnly}function Dh(e,{config:t=null,cache_dir:n=null,local_files_only:r=!1,revision:i=`main`}={}){return t===null?Ws(JSON.stringify([e,n,r,i]),()=>Pm.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})):Pm.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})}async function Oh(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null}={}){t=await Dh(e,{config:t});let a=[`config.json`],o=t[`transformers.js_config`]??{},s=o.use_external_data_format,c=`onnx`,l=r??o.device,u=n??o.dtype,d=Eh(t),f=(e,t=null)=>{t??=e;let n=el[tl(u,e,Yc(l,e))]??``,r=`${t}${n}.onnx`,i=`${c}/${r}`;a.push(i);let o=Fm(s,r,e);for(let e of Im(r,o)){let t=`${c}/${e}`;a.push(t)}},{sessions:p,optional_configs:m}=Th(d,t,{model_file_name:i});for(let[e,t]of Object.entries(p))f(e,t);if(m)for(let e of Object.values(m))a.push(e);return a}var kh=null;function Ah(e){kh=e}function jh(e){if(e instanceof U)return e;if(e.length===0)throw Error(`items must be non-empty`);if(Array.isArray(e[0])){if(e.some(t=>t.length!==e[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 U(`int64`,BigInt64Array.from(e.flat().map(e=>BigInt(e))),[e.length,e[0].length])}else return new U(`int64`,BigInt64Array.from(e.map(e=>BigInt(e))),[1,e.length])}function Mh(e){return new U(`bool`,[e],[1])}var Nh={[X.DecoderOnly]:{can_generate:!0,forward:Gh,prepare_inputs:Zh},[X.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Gh,prepare_inputs:Zh},[X.Seq2Seq]:{can_generate:!0,forward:Rh,prepare_inputs:Qh},[X.Vision2Seq]:{can_generate:!0,forward:Rh,prepare_inputs:Qh},[X.Musicgen]:{can_generate:!0,forward:Rh},[X.EncoderDecoder]:{can_generate:!1,forward:Rh},[X.ImageTextToText]:{can_generate:!0,forward:Jh,prepare_inputs:$h},[X.AudioTextToText]:{can_generate:!0,forward:qh,prepare_inputs:$h},[X.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:$h},[X.Phi3V]:{can_generate:!0,prepare_inputs:$h},[X.MultiModality]:{can_generate:!0},[X.AutoEncoder]:{can_generate:!1,forward:Bh},[X.Chatterbox]:{can_generate:!0,forward:zh},[X.VoxtralRealtime]:{can_generate:!0,prepare_inputs:Zh},default:{can_generate:!1,forward:zh}};function Ph(e,t){let n=Fh.get(e),r=!1,i=t?.architectures?.[0];if(i&&i!==e&&e?.endsWith(`ForCausalLM`)&&i.endsWith(`ForConditionalGeneration`)){let e=Fh.get(i);e!==void 0&&(n=e,r=!0)}let a=Nh[n]??Nh.default,o=Ch[n]??Ch.default;return{typeConfig:{...a,...o},textOnly:r,modelType:n}}var Fh=new Map,Ih=new Map,Lh=new Map,Z=class extends ni{main_input_name=`input_ids`;forward_params=[`input_ids`,`attention_mask`];_return_dict_in_generate_keys=null;constructor(e,t,n){super(),this.config=e,this.sessions=t,this.configs=n;let{typeConfig:r}=Ph(Lh.get(this.constructor),e);this.can_generate=r.can_generate,this._forward=r.forward,this._prepare_inputs_for_generation=r.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 t of Object.values(this.sessions))e.push(t.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d},p=Lh.get(this);n=f.config=await Pm.from_pretrained(e,f);let{typeConfig:m,textOnly:h,modelType:g}=Ph(p,n);if(g===void 0){let e=p??n?.model_type;e!==`custom`&&N.warn(`Model type for '${e}' not found, assuming encoder-only architecture. Please report this at ${Vu}.`)}if(t&&!(t instanceof ii)){let r={};try{let t=await Oh(e,{config:n,dtype:l,device:c,model_file_name:o});(await Promise.all(t.map(t=>Ks(e,t,f)))).forEach((e,n)=>{if(e.exists){let i=t[n]===`config.json`;r[t[n]]={loaded:i?e.size??0:0,total:e.size??0}}})}catch(e){N.warn(`Unable to fetch model file metadata for total progress tracking: ${e}`)}Object.keys(r).length>0&&(f.progress_callback=new ii(t,r))}let _=[Bm(e,m.sessions(n,f,h),f,m.cache_sessions)];m.optional_configs&&_.push(rg(e,m.optional_configs,f));let v=await Promise.all(_);return new this(n,...v)}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,t,n=null){let r=new Zm;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&r.push(new ih(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&r.push(new rh(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&r.push(new sh(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&r.push(new ah(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&r.push(new oh(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&r.push(new Qm(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&r.push(new $m(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&r.push(new eh(e.suppress_tokens)),e.begin_suppress_tokens!==null){let n=t>1||e.forced_bos_token_id===null?t:t+1;r.push(new th(e.begin_suppress_tokens,n))}return e.guidance_scale!==null&&e.guidance_scale>1&&r.push(new ch(e.guidance_scale)),e.temperature===0&&e.do_sample&&(N.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&&r.push(new lh(e.temperature)),n!==null&&r.extend(n),r}_prepare_generation_config(e,t,n=fh){let r={...this.config};for(let e of[`decoder`,`generator`,`text_config`])e in r&&Object.assign(r,r[e]);let i=new n(r);return Object.assign(i,this.generation_config??{}),e&&Object.assign(i,e),t&&Object.assign(i,di(t,Object.getOwnPropertyNames(i))),i}_get_stopping_criteria(e,t=null){let n=new mh;return e.max_length!==null&&n.push(new hh(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&n.push(new gh(e.eos_token_id)),t&&n.extend(t),n}_validate_model_class(){if(!this.can_generate){let e=[kh.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,kh.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,kh.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,kh.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=Lh.get(this.constructor),n=new Set,r=this.config.model_type;for(let t of e){let e=t?.get(r);e&&n.add(e)}let i=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw n.size>0&&(i+=` Please use the following class instead: ${[...n].join(`, `)}`),Error(i)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw 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:t,model_inputs:n,is_encoder_decoder:r}){return n.past_key_values=Vh(t,n.past_key_values),n.input_ids=new U(`int64`,e.flat(),[e.length,1]),r?`decoder_attention_mask`in n&&(n.decoder_attention_mask=_l([n.decoder_attention_mask,El([n.decoder_attention_mask.dims[0],1])],1)):n.attention_mask=_l([n.attention_mask,El([n.attention_mask.dims[0],1])],1),n.position_ids=null,n}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:n}){let r=di(n,this.forward_params),i=this.main_input_name;if(i in r){if(e)throw Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else r[i]=e;return{inputs_tensor:r[i],model_inputs:r,model_input_name:i}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:n,generation_config:r}){if(this.sessions.model.inputNames.includes(`inputs_embeds`)&&!t.inputs_embeds&&`_prepare_inputs_embeds`in this){let{input_ids:e,pixel_values:n,attention_mask:r,...i}=t,a=await this._prepare_inputs_embeds(t);t={...i,...di(a,[`inputs_embeds`,`attention_mask`])}}let{last_hidden_state:i}=await zh(this,t);if(r.guidance_scale!==null&&r.guidance_scale>1)i=_l([i,Tl(i,0)],0),`attention_mask`in t&&(t.attention_mask=_l([t.attention_mask,kl(t.attention_mask)],0));else if(t.decoder_input_ids){let e=jh(t.decoder_input_ids).dims[0];if(e!==i.dims[0]){if(i.dims[0]!==1)throw Error(`The encoder outputs have a different batch size (${i.dims[0]}) than the decoder inputs (${e}).`);i=_l(Array.from({length:e},()=>i),0)}}return t.encoder_outputs=i,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:n,decoder_start_token_id:r,bos_token_id:i,generation_config:a}){let{decoder_input_ids:o,...s}=n;if(!(o instanceof U)){if(o)Array.isArray(o[0])||(o=Array.from({length:e},()=>o));else if(r??=i,this.config.model_type===`musicgen`)o=Array.from({length:e*this.config.decoder.num_codebooks},()=>[r]);else if(Array.isArray(r)){if(r.length!==e)throw Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${r.length}`);o=r}else o=Array.from({length:e},()=>[r]);o=jh(o)}return s.decoder_attention_mask=Dl(o),{input_ids:o,model_inputs:s}}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,streamer:i=null,...a}){this._validate_model_class(),t=this._prepare_generation_config(t,a);let{inputs_tensor:o,model_inputs:s,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),l=this.config.is_encoder_decoder;l&&(`encoder_outputs`in s||(s=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:o,model_inputs:s,model_input_name:c,generation_config:t})));let u;l?{input_ids:u,model_inputs:s}=this._prepare_decoder_input_ids_for_generation({batch_size:s[c].dims.at(0),model_input_name:c,model_kwargs:s,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):u=s[c];let d=u.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=d+t.max_new_tokens);let f=this._get_logits_processor(t,d,n),p=this._get_stopping_criteria(t,r),m=s[c].dims.at(0),h=vh.getSampler(t),g=Array(m).fill(0),_=u.tolist();i&&i.put(_);let v,y={},b={};for(;;){if(s=this.prepare_inputs_for_generation(_,s,t),v=await this.forward(s),t.return_dict_in_generate)if(t.output_attentions){let e=Hh(v);for(let t in e)t in y||(y[t]=[]),y[t].push(e[t])}else this._return_dict_in_generate_keys&&Object.assign(b,di(v,this._return_dict_in_generate_keys));let e=f(_,v.logits.slice(null,-1,null).to(`float32`)),n=[];for(let t=0;t<e.dims.at(0);++t){let r=e[t],i=await h(r);for(let[e,r]of i){let i=BigInt(e);g[t]+=r,_[t].push(i),n.push([i]);break}}if(i&&i.put(n),p(_).every(e=>e))break;s=this._update_model_kwargs_for_generation({generated_input_ids:n,outputs:v,model_inputs:s,is_encoder_decoder:l})}i&&i.end();let x=new U(`int64`,_.flat(),[_.length,_[0].length]),ee=Vh(v,s.past_key_values),S=new Set(Object.values(ee));for(let e of Object.values(v))e.location===`gpu-buffer`&&!S.has(e)&&e.dispose();return`past_key_values`in a||t.return_dict_in_generate||await ee.dispose(),t.return_dict_in_generate?{sequences:x,past_key_values:ee,...y,...b}:x}async _encode_input(e,t,n){if(!Object.hasOwn(this.sessions,e))throw Error(`Model does not have a ${e} session.`);let r=this.sessions[e];return(await J(r,di(t,r.inputNames)))[n]}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 Rh(e,t){let{encoder_outputs:n,input_ids:r,decoder_input_ids:i,decoder_attention_mask:a,...o}=t;return n||=(await zh(e,di(t,e.sessions.model.inputNames))).last_hidden_state,o.input_ids=i,o.encoder_hidden_states=n,e.sessions.decoder_model_merged.inputNames.includes(`encoder_attention_mask`)&&(o.encoder_attention_mask=t.attention_mask),a&&!o.attention_mask&&(o.attention_mask=a),await Gh(e,o,!0)}async function zh(e,t){let n=e.sessions.model,r=di(t,n.inputNames);if(n.inputNames.includes(`inputs_embeds`)&&!r.inputs_embeds){if(!t.input_ids)throw Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(n.inputNames.includes(`token_type_ids`)&&!r.token_type_ids){if(!r.input_ids)throw Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=kl(r.input_ids)}if(n.inputNames.includes(`pixel_mask`)&&!r.pixel_mask){if(!r.pixel_values)throw Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let e=r.pixel_values.dims;r.pixel_mask=El([e[0],e[2],e[3]])}return await J(n,r)}async function Bh(e,t){let n=await e.encode(t);return await e.decode(n)}function Vh(e,t){let n=Object.create(null);for(let r in e)if(r.startsWith(`present`)){let i=r.replace(`present_ssm`,`past_ssm`).replace(`present_conv`,`past_conv`).replace(`present_recurrent`,`past_recurrent`).replace(`present`,`past_key_values`);r.includes(`encoder`)&&t?n[i]=t[i]:n[i]=e[r]}return t?(t.update(n),t):new Sh(n)}function Hh(e){let t={};for(let n of[`cross_attentions`,`encoder_attentions`,`decoder_attentions`])for(let r in e)r.startsWith(n)&&(n in t||(t[n]=[]),t[n].push(e[r]));return t}function Uh(e,t){return e.map(e=>typeof e==`number`?e:t[e]??0)}function Wh(e,t,n){if(n&&Object.keys(n).length>0)return Object.assign(t,n),n;let r=e.sessions.decoder_model_merged??e.sessions.model,i=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,a=jm(e.config),o=e.config?.normalized_config?.num_heads,s={batch_size:i};typeof o==`number`&&(s[`batch_size x num_heads`]=i*o);let c=Object.create(null);for(let e of r.inputMetadata){if(!a.has(e.name))continue;let n=Uh(e.shape,s),r=n.reduce((e,t)=>e*t,1),i=nl[e.type],o=new U(e.type,new i(r),n);t[e.name]=o,c[e.name]=o}return n?(n.update(c),n):new Sh(c)}async function Gh(e,t,n=!1){let r=e.sessions[n?`decoder_model_merged`:`model`],{past_key_values:i,...a}=t;return r.inputNames.includes(`use_cache_branch`)&&(a.use_cache_branch=Mh(i!=null&&Object.keys(i).length>0)),r.inputNames.includes(`position_ids`)&&a.attention_mask&&!a.position_ids&&(a.position_ids=Xh(a,i,+!![`paligemma`,`gemma3_text`,`gemma3`].includes(e.config.model_type))),r.inputNames.includes(`num_logits_to_keep`)&&!a.num_logits_to_keep&&(a.num_logits_to_keep=new U(`int64`,[0n],[])),Wh(e,a,i),await J(r,di(a,r.inputNames))}async function Kh(e,{encode_function:t,merge_function:n,modality_input_names:r,modality_output_name:i,input_ids:a=null,attention_mask:o=null,position_ids:s=null,inputs_embeds:c=null,past_key_values:l=null,generation_config:u=null,logits_processor:d=null,...f}){if(!c){c=await e.encode_text({input_ids:a,...f});let s=di(f,r);if(Object.keys(s).length>0){if(a.dims[1]!==1){let e=await t({...s,...f});({inputs_embeds:c,attention_mask:o}=n({[i]:e,inputs_embeds:c,input_ids:a,attention_mask:o}))}else if(l&&a.dims[1]===1){let e=a.dims[1],t=l.get_seq_length();o=_l([El([a.dims[0],t]),o.slice(null,[o.dims[1]-e,o.dims[1]])],1)}}}if(!s&&[`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(e.config.model_type)){let{image_grid_thw:t,video_grid_thw:n}=f;[s]=e.get_rope_index(a,t,n,o)}return await Gh(e,{inputs_embeds:c,past_key_values:l,attention_mask:o,position_ids:s,generation_config:u,logits_processor:d},!0)}async function qh(e,t){return await Kh(e,{...t,modality_input_names:[`audio_values`,`input_features`],modality_output_name:`audio_features`,encode_function:e.encode_audio.bind(e),merge_function:e._merge_input_ids_with_audio_features.bind(e)})}async function Jh(e,t){return await Kh(e,{...t,modality_input_names:[`pixel_values`],modality_output_name:`image_features`,encode_function:e.encode_image.bind(e),merge_function:e._merge_input_ids_with_image_features.bind(e)})}function Yh(e,t=0){let[n,r]=e.dims,i=e.data,a=new BigInt64Array(i.length);for(let e=0;e<n;++e){let n=e*r,o=BigInt(t);for(let e=0;e<r;++e){let t=n+e;i[t]===0n?a[t]=BigInt(1):(a[t]=o,o+=i[t])}}return{data:a,dims:e.dims}}function Xh(e,t=null,n=0){let{input_ids:r,inputs_embeds:i,attention_mask:a}=e,{data:o,dims:s}=Yh(a,n),c=new U(`int64`,o,s);if(t){let e=-(r??i).dims.at(1);c=c.slice(null,[e,null])}return c}function Zh(e,t,n,r){let i=n.past_key_values?n.past_key_values.get_seq_length():0;if((e.sessions.decoder_model_merged??e.sessions.model)?.inputNames.includes(`num_logits_to_keep`)&&!n.num_logits_to_keep&&(n.num_logits_to_keep=new U(`int64`,[1n],[])),!n.attention_mask){let e;for(let t of[`input_ids`,`inputs_embeds`,`position_ids`])if(n[t]){e=n[t].dims;break}if(!e)throw Error(`attention_mask is not provided, and unable to infer its shape from model inputs.`);n.attention_mask=El([e[0],i+e[1]])}if(n.past_key_values){let{input_ids:e,attention_mask:t}=n;t&&t.dims[1]>e.dims[1]||i<e.dims[1]&&(n.input_ids=e.slice(null,[i,null]))}return n}function Qh(e,t,n,r){return n.past_key_values&&(t=t.map(e=>[e.at(-1)])),{...n,decoder_input_ids:jh(t)}}function $h(e,...t){return e.config.is_encoder_decoder?Qh(e,...t):Zh(e,...t)}function eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i}){let a=r.tolist().map(t=>t.reduce((t,n,r)=>(n==e&&t.push(r),t),[])),o=a.reduce((e,t)=>e+t.length,0),s=n.dims[0];if(o!==s)throw Error(`Number of tokens and features do not match: tokens: ${o}, features ${s}`);let c=0;for(let e=0;e<a.length;++e){let r=a[e],i=t[e];for(let e=0;e<r.length;++e)i[r[e]].data.set(n[c++].data)}return{inputs_embeds:t,attention_mask:i}}function tg({image_token_id:e,inputs_embeds:t,image_features:n,input_ids:r,attention_mask:i}){return eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i})}function ng({audio_token_id:e,inputs_embeds:t,audio_features:n,input_ids:r,attention_mask:i}){return eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i})}async function rg(e,t,n){return Object.fromEntries(await Promise.all(Object.keys(t).map(async r=>[r,await rc(e,t[r],!1,n)])))}var ig={};Tr(ig,{ASTForAudioClassification:()=>xg,ASTModel:()=>bg,ASTPreTrainedModel:()=>yg,AfmoeForCausalLM:()=>hg,AfmoeModel:()=>mg,AfmoePreTrainedModel:()=>pg,AlbertForMaskedLM:()=>lg,AlbertForQuestionAnswering:()=>cg,AlbertForSequenceClassification:()=>sg,AlbertModel:()=>og,AlbertPreTrainedModel:()=>ag,ApertusForCausalLM:()=>fg,ApertusModel:()=>dg,ApertusPreTrainedModel:()=>ug,ArceeForCausalLM:()=>vg,ArceeModel:()=>_g,ArceePreTrainedModel:()=>gg,BartForConditionalGeneration:()=>wg,BartForSequenceClassification:()=>Tg,BartModel:()=>Cg,BartPretrainedModel:()=>Sg,BeitForImageClassification:()=>Og,BeitModel:()=>Dg,BeitPreTrainedModel:()=>Eg,BertForMaskedLM:()=>jg,BertForQuestionAnswering:()=>Pg,BertForSequenceClassification:()=>Mg,BertForTokenClassification:()=>Ng,BertModel:()=>Ag,BertPreTrainedModel:()=>kg,BlenderbotForConditionalGeneration:()=>Lg,BlenderbotModel:()=>Ig,BlenderbotPreTrainedModel:()=>Fg,BlenderbotSmallForConditionalGeneration:()=>Bg,BlenderbotSmallModel:()=>zg,BlenderbotSmallPreTrainedModel:()=>Rg,BloomForCausalLM:()=>Ug,BloomModel:()=>Hg,BloomPreTrainedModel:()=>Vg,CHMv2ForDepthEstimation:()=>r_,CHMv2PreTrainedModel:()=>n_,CLIPModel:()=>l_,CLIPPreTrainedModel:()=>c_,CLIPSegForImageSegmentation:()=>g_,CLIPSegModel:()=>h_,CLIPSegPreTrainedModel:()=>m_,CLIPTextModel:()=>u_,CLIPTextModelWithProjection:()=>d_,CLIPVisionModel:()=>f_,CLIPVisionModelWithProjection:()=>p_,CamembertForMaskedLM:()=>Kg,CamembertForQuestionAnswering:()=>Yg,CamembertForSequenceClassification:()=>qg,CamembertForTokenClassification:()=>Jg,CamembertModel:()=>Gg,CamembertPreTrainedModel:()=>Wg,ChatterboxModel:()=>$g,ChatterboxPreTrainedModel:()=>Qg,ChineseCLIPModel:()=>t_,ChineseCLIPPreTrainedModel:()=>e_,ClapAudioModelWithProjection:()=>s_,ClapModel:()=>a_,ClapPreTrainedModel:()=>i_,ClapTextModelWithProjection:()=>o_,CodeGenForCausalLM:()=>y_,CodeGenModel:()=>v_,CodeGenPreTrainedModel:()=>__,Cohere2ForCausalLM:()=>T_,Cohere2Model:()=>w_,Cohere2PreTrainedModel:()=>C_,CohereAsrForConditionalGeneration:()=>O_,CohereAsrModel:()=>D_,CohereAsrPreTrainedModel:()=>E_,CohereForCausalLM:()=>S_,CohereModel:()=>x_,CoherePreTrainedModel:()=>b_,ConvBertForMaskedLM:()=>j_,ConvBertForQuestionAnswering:()=>P_,ConvBertForSequenceClassification:()=>M_,ConvBertForTokenClassification:()=>N_,ConvBertModel:()=>A_,ConvBertPreTrainedModel:()=>k_,ConvNextForImageClassification:()=>L_,ConvNextModel:()=>I_,ConvNextPreTrainedModel:()=>F_,ConvNextV2ForImageClassification:()=>B_,ConvNextV2Model:()=>z_,ConvNextV2PreTrainedModel:()=>R_,DFineForObjectDetection:()=>q_,DFineModel:()=>K_,DFinePreTrainedModel:()=>G_,DINOv3ConvNextModel:()=>Lv,DINOv3ConvNextPreTrainedModel:()=>Iv,DINOv3ViTModel:()=>zv,DINOv3ViTPreTrainedModel:()=>Rv,DPTForDepthEstimation:()=>Xv,DPTModel:()=>Yv,DPTPreTrainedModel:()=>Jv,DacDecoderModel:()=>$_,DacDecoderOutput:()=>Y_,DacEncoderModel:()=>Q_,DacEncoderOutput:()=>J_,DacModel:()=>Z_,DacPreTrainedModel:()=>X_,DebertaForMaskedLM:()=>nv,DebertaForQuestionAnswering:()=>av,DebertaForSequenceClassification:()=>rv,DebertaForTokenClassification:()=>iv,DebertaModel:()=>tv,DebertaPreTrainedModel:()=>ev,DebertaV2ForMaskedLM:()=>dv,DebertaV2ForQuestionAnswering:()=>mv,DebertaV2ForSequenceClassification:()=>fv,DebertaV2ForTokenClassification:()=>pv,DebertaV2Model:()=>uv,DebertaV2PreTrainedModel:()=>lv,DecisionTransformerModel:()=>gv,DecisionTransformerPreTrainedModel:()=>hv,DeepseekV3ForCausalLM:()=>cv,DeepseekV3Model:()=>sv,DeepseekV3PreTrainedModel:()=>ov,DeiTForImageClassification:()=>yv,DeiTModel:()=>vv,DeiTPreTrainedModel:()=>_v,DepthAnythingForDepthEstimation:()=>xv,DepthAnythingPreTrainedModel:()=>bv,DepthProForDepthEstimation:()=>Cv,DepthProPreTrainedModel:()=>Sv,DetrForObjectDetection:()=>Ev,DetrForSegmentation:()=>Dv,DetrModel:()=>Tv,DetrObjectDetectionOutput:()=>Ov,DetrPreTrainedModel:()=>wv,DetrSegmentationOutput:()=>kv,Dinov2ForImageClassification:()=>Mv,Dinov2Model:()=>jv,Dinov2PreTrainedModel:()=>Av,Dinov2WithRegistersForImageClassification:()=>Fv,Dinov2WithRegistersModel:()=>Pv,Dinov2WithRegistersPreTrainedModel:()=>Nv,DistilBertForMaskedLM:()=>Gv,DistilBertForQuestionAnswering:()=>Wv,DistilBertForSequenceClassification:()=>Hv,DistilBertForTokenClassification:()=>Uv,DistilBertModel:()=>Vv,DistilBertPreTrainedModel:()=>Bv,DonutSwinModel:()=>qv,DonutSwinPreTrainedModel:()=>Kv,EdgeTamModel:()=>DT,EfficientNetForImageClassification:()=>$v,EfficientNetModel:()=>Qv,EfficientNetPreTrainedModel:()=>Zv,ElectraForMaskedLM:()=>ny,ElectraForQuestionAnswering:()=>ay,ElectraForSequenceClassification:()=>ry,ElectraForTokenClassification:()=>iy,ElectraModel:()=>ty,ElectraPreTrainedModel:()=>ey,Ernie4_5ForCausalLM:()=>cy,Ernie4_5Model:()=>sy,Ernie4_5PretrainedModel:()=>oy,EsmForMaskedLM:()=>dy,EsmForSequenceClassification:()=>fy,EsmForTokenClassification:()=>py,EsmModel:()=>uy,EsmPreTrainedModel:()=>ly,EuroBertForMaskedLM:()=>gy,EuroBertForSequenceClassification:()=>_y,EuroBertForTokenClassification:()=>vy,EuroBertModel:()=>hy,EuroBertPreTrainedModel:()=>my,ExaoneForCausalLM:()=>xy,ExaoneModel:()=>by,ExaonePreTrainedModel:()=>yy,FalconForCausalLM:()=>wy,FalconH1ForCausalLM:()=>Dy,FalconH1Model:()=>Ey,FalconH1PreTrainedModel:()=>Ty,FalconModel:()=>Cy,FalconPreTrainedModel:()=>Sy,FastViTForImageClassification:()=>Ay,FastViTModel:()=>ky,FastViTPreTrainedModel:()=>Oy,Florence2ForConditionalGeneration:()=>My,Florence2PreTrainedModel:()=>jy,GLPNForDepthEstimation:()=>fb,GLPNModel:()=>db,GLPNPreTrainedModel:()=>ub,GPT2LMHeadModel:()=>Db,GPT2Model:()=>Eb,GPT2PreTrainedModel:()=>Tb,GPTBigCodeForCausalLM:()=>hb,GPTBigCodeModel:()=>mb,GPTBigCodePreTrainedModel:()=>pb,GPTJForCausalLM:()=>Ab,GPTJModel:()=>kb,GPTJPreTrainedModel:()=>Ob,GPTNeoForCausalLM:()=>vb,GPTNeoModel:()=>_b,GPTNeoPreTrainedModel:()=>gb,GPTNeoXForCausalLM:()=>xb,GPTNeoXModel:()=>bb,GPTNeoXPreTrainedModel:()=>yb,Gemma2ForCausalLM:()=>Ry,Gemma2Model:()=>Ly,Gemma2PreTrainedModel:()=>Iy,Gemma3ForCausalLM:()=>Ky,Gemma3ForConditionalGeneration:()=>Gy,Gemma3Model:()=>Wy,Gemma3PreTrainedModel:()=>Uy,Gemma3nForCausalLM:()=>Yy,Gemma3nForConditionalGeneration:()=>Jy,Gemma3nPreTrainedModel:()=>qy,Gemma4ForCausalLM:()=>Zy,Gemma4ForConditionalGeneration:()=>Xy,GemmaForCausalLM:()=>Fy,GemmaModel:()=>Py,GemmaPreTrainedModel:()=>Ny,GlmForCausalLM:()=>eb,GlmModel:()=>$y,GlmMoeDsaForCausalLM:()=>rb,GlmMoeDsaModel:()=>nb,GlmMoeDsaPreTrainedModel:()=>tb,GlmOcrForConditionalGeneration:()=>lb,GlmPreTrainedModel:()=>Qy,GptOssForCausalLM:()=>wb,GptOssModel:()=>Cb,GptOssPreTrainedModel:()=>Sb,GraniteForCausalLM:()=>Nb,GraniteModel:()=>Mb,GraniteMoeHybridForCausalLM:()=>Ib,GraniteMoeHybridModel:()=>Fb,GraniteMoeHybridPreTrainedModel:()=>Pb,GranitePreTrainedModel:()=>jb,GraniteSpeechForConditionalGeneration:()=>zb,GroundingDinoForObjectDetection:()=>Vb,GroundingDinoPreTrainedModel:()=>Bb,GroupViTModel:()=>Ub,GroupViTPreTrainedModel:()=>Hb,HeliumForCausalLM:()=>Kb,HeliumModel:()=>Gb,HeliumPreTrainedModel:()=>Wb,HieraForImageClassification:()=>Yb,HieraModel:()=>Jb,HieraPreTrainedModel:()=>qb,HubertForCTC:()=>rx,HubertForSequenceClassification:()=>ix,HubertModel:()=>nx,HubertPreTrainedModel:()=>tx,HunYuanDenseV1ForCausalLM:()=>sx,HunYuanDenseV1Model:()=>ox,HunYuanDenseV1PreTrainedModel:()=>ax,IJepaForImageClassification:()=>dx,IJepaModel:()=>ux,IJepaPreTrainedModel:()=>lx,Idefics3ForConditionalGeneration:()=>cx,JAISLMHeadModel:()=>mx,JAISModel:()=>px,JAISPreTrainedModel:()=>fx,JinaCLIPModel:()=>gx,JinaCLIPPreTrainedModel:()=>hx,JinaCLIPTextModel:()=>_x,JinaCLIPVisionModel:()=>vx,Lfm2ForCausalLM:()=>xx,Lfm2Model:()=>bx,Lfm2MoeForCausalLM:()=>Tx,Lfm2MoeModel:()=>wx,Lfm2MoePreTrainedModel:()=>Cx,Lfm2PreTrainedModel:()=>yx,Lfm2VlForConditionalGeneration:()=>Ex,LightOnOcrForConditionalGeneration:()=>Sx,LiteWhisperForConditionalGeneration:()=>ID,Llama4ForCausalLM:()=>jx,Llama4PreTrainedModel:()=>Ax,LlamaForCausalLM:()=>kx,LlamaModel:()=>Ox,LlamaPreTrainedModel:()=>Dx,LlavaForConditionalGeneration:()=>By,LlavaOnevisionForConditionalGeneration:()=>By,LlavaPreTrainedModel:()=>zy,LlavaQwen2ForCausalLM:()=>Hy,LongT5ForConditionalGeneration:()=>Px,LongT5Model:()=>Nx,LongT5PreTrainedModel:()=>Mx,M2M100ForConditionalGeneration:()=>Lx,M2M100Model:()=>Ix,M2M100PreTrainedModel:()=>Fx,MBartForCausalLM:()=>Jx,MBartForConditionalGeneration:()=>Kx,MBartForSequenceClassification:()=>qx,MBartModel:()=>Gx,MBartPreTrainedModel:()=>Wx,MPNetForMaskedLM:()=>rC,MPNetForQuestionAnswering:()=>oC,MPNetForSequenceClassification:()=>iC,MPNetForTokenClassification:()=>aC,MPNetModel:()=>nC,MPNetPreTrainedModel:()=>tC,MT5ForConditionalGeneration:()=>fC,MT5Model:()=>dC,MT5PreTrainedModel:()=>uC,MarianMTModel:()=>Bx,MarianModel:()=>zx,MarianPreTrainedModel:()=>Rx,MaskFormerForInstanceSegmentation:()=>Ux,MaskFormerModel:()=>Hx,MaskFormerPreTrainedModel:()=>Vx,Metric3DForDepthEstimation:()=>Xx,Metric3DPreTrainedModel:()=>Yx,Metric3Dv2ForDepthEstimation:()=>Qx,Metric3Dv2PreTrainedModel:()=>Zx,MgpstrForSceneTextRecognition:()=>tS,MgpstrModelOutput:()=>$x,MgpstrPreTrainedModel:()=>eS,MimiDecoderModel:()=>sS,MimiDecoderOutput:()=>rS,MimiEncoderModel:()=>oS,MimiEncoderOutput:()=>nS,MimiModel:()=>aS,MimiPreTrainedModel:()=>iS,Mistral4ForCausalLM:()=>pS,Mistral4Model:()=>fS,Mistral4PreTrainedModel:()=>dS,MistralForCausalLM:()=>uS,MistralModel:()=>lS,MistralPreTrainedModel:()=>cS,MobileBertForMaskedLM:()=>gS,MobileBertForQuestionAnswering:()=>vS,MobileBertForSequenceClassification:()=>_S,MobileBertModel:()=>hS,MobileBertPreTrainedModel:()=>mS,MobileLLMForCausalLM:()=>xS,MobileLLMModel:()=>bS,MobileLLMPreTrainedModel:()=>yS,MobileNetV1ForImageClassification:()=>wS,MobileNetV1ForSemanticSegmentation:()=>TS,MobileNetV1Model:()=>CS,MobileNetV1PreTrainedModel:()=>SS,MobileNetV2ForImageClassification:()=>OS,MobileNetV2ForSemanticSegmentation:()=>kS,MobileNetV2Model:()=>DS,MobileNetV2PreTrainedModel:()=>ES,MobileNetV3ForImageClassification:()=>MS,MobileNetV3ForSemanticSegmentation:()=>NS,MobileNetV3Model:()=>jS,MobileNetV3PreTrainedModel:()=>AS,MobileNetV4ForImageClassification:()=>IS,MobileNetV4ForSemanticSegmentation:()=>LS,MobileNetV4Model:()=>FS,MobileNetV4PreTrainedModel:()=>PS,MobileViTForImageClassification:()=>BS,MobileViTModel:()=>zS,MobileViTPreTrainedModel:()=>RS,MobileViTV2ForImageClassification:()=>US,MobileViTV2Model:()=>HS,MobileViTV2PreTrainedModel:()=>VS,ModernBertDecoderForCausalLM:()=>ZS,ModernBertDecoderModel:()=>XS,ModernBertDecoderPreTrainedModel:()=>YS,ModernBertForMaskedLM:()=>KS,ModernBertForSequenceClassification:()=>qS,ModernBertForTokenClassification:()=>JS,ModernBertModel:()=>GS,ModernBertPreTrainedModel:()=>WS,Moondream1ForConditionalGeneration:()=>Vy,MoonshineForConditionalGeneration:()=>eC,MoonshineModel:()=>$S,MoonshinePreTrainedModel:()=>QS,MptForCausalLM:()=>lC,MptModel:()=>cC,MptPreTrainedModel:()=>sC,MultiModalityCausalLM:()=>mC,MultiModalityPreTrainedModel:()=>pC,MusicgenForCausalLM:()=>_C,MusicgenForConditionalGeneration:()=>vC,MusicgenModel:()=>gC,MusicgenPreTrainedModel:()=>hC,NanoChatForCausalLM:()=>xC,NanoChatModel:()=>bC,NanoChatPreTrainedModel:()=>yC,NemotronHForCausalLM:()=>wC,NemotronHModel:()=>CC,NemotronHPreTrainedModel:()=>SC,NeoBertForMaskedLM:()=>DC,NeoBertForQuestionAnswering:()=>AC,NeoBertForSequenceClassification:()=>OC,NeoBertForTokenClassification:()=>kC,NeoBertModel:()=>EC,NeoBertPreTrainedModel:()=>TC,NomicBertModel:()=>MC,NomicBertPreTrainedModel:()=>jC,OPTForCausalLM:()=>$C,OPTModel:()=>QC,OPTPreTrainedModel:()=>ZC,Olmo2ForCausalLM:()=>RC,Olmo2Model:()=>LC,Olmo2PreTrainedModel:()=>IC,Olmo3ForCausalLM:()=>VC,Olmo3Model:()=>BC,Olmo3PreTrainedModel:()=>zC,OlmoForCausalLM:()=>FC,OlmoHybridForCausalLM:()=>WC,OlmoHybridModel:()=>UC,OlmoHybridPreTrainedModel:()=>HC,OlmoModel:()=>PC,OlmoPreTrainedModel:()=>NC,OpenAIPrivacyFilterForTokenClassification:()=>qC,OpenAIPrivacyFilterModel:()=>KC,OpenAIPrivacyFilterPreTrainedModel:()=>GC,OpenELMForCausalLM:()=>XC,OpenELMModel:()=>YC,OpenELMPreTrainedModel:()=>JC,OwlViTForObjectDetection:()=>aw,OwlViTModel:()=>iw,OwlViTPreTrainedModel:()=>rw,Owlv2ForObjectDetection:()=>nw,Owlv2Model:()=>tw,Owlv2PreTrainedModel:()=>ew,PaliGemmaForConditionalGeneration:()=>ow,ParakeetForCTC:()=>cw,ParakeetPreTrainedModel:()=>sw,PatchTSMixerForPrediction:()=>dw,PatchTSMixerModel:()=>uw,PatchTSMixerPreTrainedModel:()=>lw,PatchTSTForPrediction:()=>mw,PatchTSTModel:()=>pw,PatchTSTPreTrainedModel:()=>fw,Phi3ForCausalLM:()=>bw,Phi3Model:()=>yw,Phi3PreTrainedModel:()=>vw,Phi3VForCausalLM:()=>Sw,Phi3VPreTrainedModel:()=>xw,PhiForCausalLM:()=>_w,PhiModel:()=>gw,PhiPreTrainedModel:()=>hw,PreTrainedModel:()=>Z,PvtForImageClassification:()=>Tw,PvtModel:()=>ww,PvtPreTrainedModel:()=>Cw,PyAnnoteForAudioFrameClassification:()=>Ow,PyAnnoteModel:()=>Dw,PyAnnotePreTrainedModel:()=>Ew,Qwen2ForCausalLM:()=>jw,Qwen2Model:()=>Aw,Qwen2MoeForCausalLM:()=>Pw,Qwen2MoeModel:()=>Nw,Qwen2MoePreTrainedModel:()=>Mw,Qwen2PreTrainedModel:()=>kw,Qwen2VLForCausalLM:()=>ob,Qwen2VLForConditionalGeneration:()=>ab,Qwen2VLPreTrainedModel:()=>ib,Qwen2_5_VLForCausalLM:()=>cb,Qwen2_5_VLForConditionalGeneration:()=>sb,Qwen3ForCausalLM:()=>Lw,Qwen3Model:()=>Iw,Qwen3MoeForCausalLM:()=>Bw,Qwen3MoeModel:()=>zw,Qwen3MoePreTrainedModel:()=>Rw,Qwen3NextForCausalLM:()=>Uw,Qwen3NextModel:()=>Hw,Qwen3NextPreTrainedModel:()=>Vw,Qwen3PreTrainedModel:()=>Fw,Qwen3VLForCausalLM:()=>Gw,Qwen3VLForConditionalGeneration:()=>Ww,Qwen3VLMoeForCausalLM:()=>qw,Qwen3VLMoeForConditionalGeneration:()=>Kw,Qwen3_5ForCausalLM:()=>Yw,Qwen3_5ForConditionalGeneration:()=>Jw,Qwen3_5MoeForCausalLM:()=>Zw,Qwen3_5MoeForConditionalGeneration:()=>Xw,RFDetrForObjectDetection:()=>rT,RFDetrModel:()=>nT,RFDetrObjectDetectionOutput:()=>iT,RFDetrPreTrainedModel:()=>tT,RTDetrForObjectDetection:()=>U_,RTDetrModel:()=>H_,RTDetrObjectDetectionOutput:()=>W_,RTDetrPreTrainedModel:()=>V_,RTDetrV2ForObjectDetection:()=>yT,RTDetrV2Model:()=>vT,RTDetrV2ObjectDetectionOutput:()=>bT,RTDetrV2PreTrainedModel:()=>_T,ResNetForImageClassification:()=>eT,ResNetModel:()=>$w,ResNetPreTrainedModel:()=>Qw,RoFormerForMaskedLM:()=>pT,RoFormerForQuestionAnswering:()=>gT,RoFormerForSequenceClassification:()=>mT,RoFormerForTokenClassification:()=>hT,RoFormerModel:()=>fT,RoFormerPreTrainedModel:()=>dT,RobertaForMaskedLM:()=>sT,RobertaForQuestionAnswering:()=>uT,RobertaForSequenceClassification:()=>cT,RobertaForTokenClassification:()=>lT,RobertaModel:()=>oT,RobertaPreTrainedModel:()=>aT,Sam2ImageSegmentationOutput:()=>wT,Sam2Model:()=>ET,Sam2PreTrainedModel:()=>TT,Sam3TrackerModel:()=>OT,SamImageSegmentationOutput:()=>xT,SamModel:()=>CT,SamPreTrainedModel:()=>ST,SapiensForDepthEstimation:()=>jT,SapiensForNormalEstimation:()=>MT,SapiensForSemanticSegmentation:()=>AT,SapiensPreTrainedModel:()=>kT,SegformerForImageClassification:()=>FT,SegformerForSemanticSegmentation:()=>IT,SegformerModel:()=>PT,SegformerPreTrainedModel:()=>NT,SiglipModel:()=>RT,SiglipPreTrainedModel:()=>LT,SiglipTextModel:()=>zT,SiglipVisionModel:()=>BT,SmolLM3ForCausalLM:()=>UT,SmolLM3Model:()=>HT,SmolLM3PreTrainedModel:()=>VT,SmolVLMForConditionalGeneration:()=>WT,SnacDecoderModel:()=>JT,SnacEncoderModel:()=>qT,SnacModel:()=>KT,SnacPreTrainedModel:()=>GT,SolarOpenForCausalLM:()=>ZT,SolarOpenModel:()=>XT,SolarOpenPreTrainedModel:()=>YT,SpeechT5ForSpeechToText:()=>eE,SpeechT5ForTextToSpeech:()=>tE,SpeechT5HifiGan:()=>nE,SpeechT5Model:()=>$T,SpeechT5PreTrainedModel:()=>QT,SqueezeBertForMaskedLM:()=>aE,SqueezeBertForQuestionAnswering:()=>sE,SqueezeBertForSequenceClassification:()=>oE,SqueezeBertModel:()=>iE,SqueezeBertPreTrainedModel:()=>rE,StableLmForCausalLM:()=>uE,StableLmModel:()=>lE,StableLmPreTrainedModel:()=>cE,Starcoder2ForCausalLM:()=>pE,Starcoder2Model:()=>fE,Starcoder2PreTrainedModel:()=>dE,StyleTextToSpeech2Model:()=>hE,StyleTextToSpeech2PreTrainedModel:()=>mE,SupertonicForConditionalGeneration:()=>_E,SupertonicPreTrainedModel:()=>gE,Swin2SRForImageSuperResolution:()=>wE,Swin2SRModel:()=>CE,Swin2SRPreTrainedModel:()=>SE,SwinForImageClassification:()=>bE,SwinForSemanticSegmentation:()=>xE,SwinModel:()=>yE,SwinPreTrainedModel:()=>vE,T5ForConditionalGeneration:()=>DE,T5Model:()=>EE,T5PreTrainedModel:()=>TE,TableTransformerForObjectDetection:()=>AE,TableTransformerModel:()=>kE,TableTransformerObjectDetectionOutput:()=>jE,TableTransformerPreTrainedModel:()=>OE,TrOCRForCausalLM:()=>NE,TrOCRPreTrainedModel:()=>ME,UltravoxModel:()=>Rb,UltravoxPreTrainedModel:()=>Lb,UniSpeechForCTC:()=>IE,UniSpeechForSequenceClassification:()=>LE,UniSpeechModel:()=>FE,UniSpeechPreTrainedModel:()=>PE,UniSpeechSatForAudioFrameClassification:()=>HE,UniSpeechSatForCTC:()=>BE,UniSpeechSatForSequenceClassification:()=>VE,UniSpeechSatModel:()=>zE,UniSpeechSatPreTrainedModel:()=>RE,VaultGemmaForCausalLM:()=>GE,VaultGemmaModel:()=>WE,VaultGemmaPreTrainedModel:()=>UE,ViTForImageClassification:()=>YE,ViTMAEModel:()=>ZE,ViTMAEPreTrainedModel:()=>XE,ViTMSNForImageClassification:()=>eD,ViTMSNModel:()=>$E,ViTMSNPreTrainedModel:()=>QE,ViTModel:()=>JE,ViTPreTrainedModel:()=>qE,VisionEncoderDecoderModel:()=>KE,VitMatteForImageMatting:()=>nD,VitMattePreTrainedModel:()=>tD,VitPoseForPoseEstimation:()=>iD,VitPosePreTrainedModel:()=>rD,VitsModel:()=>sD,VitsModelOutput:()=>aD,VitsPreTrainedModel:()=>oD,VoxtralForConditionalGeneration:()=>cD,VoxtralRealtimeForConditionalGeneration:()=>vD,VoxtralRealtimePreTrainedModel:()=>_D,Wav2Vec2BertForCTC:()=>xD,Wav2Vec2BertForSequenceClassification:()=>SD,Wav2Vec2BertModel:()=>bD,Wav2Vec2BertPreTrainedModel:()=>yD,Wav2Vec2ForAudioFrameClassification:()=>ex,Wav2Vec2ForCTC:()=>Qb,Wav2Vec2ForSequenceClassification:()=>$b,Wav2Vec2Model:()=>Zb,Wav2Vec2PreTrainedModel:()=>Xb,WavLMForAudioFrameClassification:()=>kD,WavLMForCTC:()=>ED,WavLMForSequenceClassification:()=>DD,WavLMForXVector:()=>OD,WavLMModel:()=>TD,WavLMPreTrainedModel:()=>wD,WeSpeakerResNetModel:()=>jD,WeSpeakerResNetPreTrainedModel:()=>AD,WhisperForConditionalGeneration:()=>FD,WhisperModel:()=>PD,WhisperPreTrainedModel:()=>ND,XLMForQuestionAnswering:()=>HD,XLMForSequenceClassification:()=>BD,XLMForTokenClassification:()=>VD,XLMModel:()=>RD,XLMPreTrainedModel:()=>LD,XLMRobertaForMaskedLM:()=>GD,XLMRobertaForQuestionAnswering:()=>JD,XLMRobertaForSequenceClassification:()=>KD,XLMRobertaForTokenClassification:()=>qD,XLMRobertaModel:()=>WD,XLMRobertaPreTrainedModel:()=>UD,XLMWithLMHeadModel:()=>zD,XVectorOutput:()=>CD,YolosForObjectDetection:()=>ZD,YolosModel:()=>XD,YolosObjectDetectionOutput:()=>QD,YolosPreTrainedModel:()=>YD,YoutuForCausalLM:()=>tO,YoutuModel:()=>eO,YoutuPreTrainedModel:()=>$D});var ag=class extends Z{},og=class extends ag{},sg=class extends ag{async _call(e){return new Y(await super._call(e))}},cg=class extends ag{async _call(e){return new Km(await super._call(e))}},lg=class extends ag{async _call(e){return new Gm(await super._call(e))}},ug=class extends Z{},dg=class extends ug{},fg=class extends ug{},pg=class extends Z{},mg=class extends pg{},hg=class extends pg{},gg=class extends Z{},_g=class extends gg{},vg=class extends gg{},yg=class extends Z{},bg=class extends yg{},xg=class extends yg{},Sg=class extends Z{},Cg=class extends Sg{},wg=class extends Sg{},Tg=class extends Sg{async _call(e){return new Y(await super._call(e))}},Eg=class extends Z{},Dg=class extends Eg{},Og=class extends Eg{async _call(e){return new Y(await super._call(e))}},kg=class extends Z{},Ag=class extends kg{},jg=class extends kg{async _call(e){return new Gm(await super._call(e))}},Mg=class extends kg{async _call(e){return new Y(await super._call(e))}},Ng=class extends kg{async _call(e){return new Wm(await super._call(e))}},Pg=class extends kg{async _call(e){return new Km(await super._call(e))}},Fg=class extends Z{},Ig=class extends Fg{},Lg=class extends Fg{},Rg=class extends Z{},zg=class extends Rg{},Bg=class extends Rg{},Vg=class extends Z{},Hg=class extends Vg{},Ug=class extends Vg{},Wg=class extends Z{},Gg=class extends Wg{},Kg=class extends Wg{async _call(e){return new Gm(await super._call(e))}},qg=class extends Wg{async _call(e){return new Y(await super._call(e))}},Jg=class extends Wg{async _call(e){return new Wm(await super._call(e))}},Yg=class extends Wg{async _call(e){return new Km(await super._call(e))}},Xg=4299n,Zg=6561n,Qg=class extends Z{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`]},$g=class extends Qg{async encode_speech(e){return J(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:n=null,exaggeration:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,audio_features:l=null,audio_tokens:u=null,speaker_embeddings:d=null,speaker_features:f=null,...p}){let m;if(!a){let s=this.sessions.embed_tokens.inputNames,c={input_ids:e};if(s.includes(`exaggeration`)){if(!(r instanceof U)){let t=e.dims[0];if(r==null)r=wl([t],.5);else if(typeof r==`number`)r=wl([t],r);else if(Array.isArray(r))r=new U(`float32`,r,[t]);else throw Error("Unsupported type for `exaggeration` input")}c.exaggeration=r}if(s.includes(`position_ids`)&&(c.position_ids=i),{inputs_embeds:a}=await J(this.sessions.embed_tokens,c),l&&u&&d&&f&&(m={audio_features:l,audio_tokens:u,speaker_embeddings:d,speaker_features:f}),m||n)m??=await this.encode_speech(n),a=_l([m.audio_features,a],1),t=El([a.dims[0],a.dims[1]]);else{let e=a.dims[1];if(!o||e!==1)throw Error(`Incorrect state encountered during generation.`);let n=o.get_seq_length();t=El([a.dims[0],n+e])}}return{...await Gh(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,generation_config:s,logits_processor:c},!1),...m}}prepare_inputs_for_generation(e,t,n){return!t.position_ids&&this.sessions.embed_tokens.inputNames.includes(`position_ids`)&&(t.input_ids.dims[1]===1?t.position_ids=new U(`int64`,Array.from({length:e.length},(t,n)=>e[n].length-e[n].findLastIndex(e=>e==Zg)-1),[e.length,1]):t.position_ids=new U(`int64`,t.input_ids.tolist().map(e=>{let t=0;return e.map(e=>e>=Zg?0:t++)}).flat(),t.input_ids.dims)),t.input_ids.dims[1]===1&&(delete t.audio_values,delete t.audio_features,delete t.audio_tokens,delete t.speaker_embeddings,delete t.speaker_features),Zh(this,e,t,n)}async generate(e){let{sequences:t,audio_tokens:n,speaker_embeddings:r,speaker_features:i}=await super.generate({...e,return_dict_in_generate:!0}),a=t.slice(null,[e.input_ids.dims[1],-1]),o=_l([n,a,wl([a.dims[0],3],Xg)],1),{waveform:s}=await J(this.sessions.conditional_decoder,{speech_tokens:o,speaker_features:i,speaker_embeddings:r});return s}},e_=class extends Z{},t_=class extends e_{},n_=class extends Z{},r_=class extends n_{},i_=class extends Z{},a_=class extends i_{},o_=class extends i_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},s_=class extends i_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`audio_model`})}},c_=class extends Z{},l_=class extends c_{},u_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},d_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},f_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},p_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},m_=class extends Z{},h_=class extends m_{},g_=class extends m_{},__=class extends Z{},v_=class extends __{},y_=class extends __{},b_=class extends Z{},x_=class extends b_{},S_=class extends b_{},C_=class extends Z{},w_=class extends C_{},T_=class extends C_{},E_=class extends Z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},D_=class extends E_{},O_=class extends E_{},k_=class extends Z{},A_=class extends k_{},j_=class extends k_{async _call(e){return new Gm(await super._call(e))}},M_=class extends k_{async _call(e){return new Y(await super._call(e))}},N_=class extends k_{async _call(e){return new Wm(await super._call(e))}},P_=class extends k_{async _call(e){return new Km(await super._call(e))}},F_=class extends Z{},I_=class extends F_{},L_=class extends F_{async _call(e){return new Y(await super._call(e))}},R_=class extends Z{},z_=class extends R_{},B_=class extends R_{async _call(e){return new Y(await super._call(e))}},V_=class extends Z{},H_=class extends V_{},U_=class extends V_{async _call(e){return new W_(await super._call(e))}},W_=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},G_=class extends Z{},K_=class extends G_{},q_=class extends G_{async _call(e){return new W_(await super._call(e))}},J_=class extends Um{constructor({audio_codes:e}){super(),this.audio_codes=e}},Y_=class extends Um{constructor({audio_values:e}){super(),this.audio_values=e}},X_=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},Z_=class extends X_{async encode(e){return new J_(await J(this.sessions.encoder_model,e))}async decode(e){return new Y_(await J(this.sessions.decoder_model,e))}},Q_=class extends X_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},$_=class extends X_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},ev=class extends Z{},tv=class extends ev{},nv=class extends ev{async _call(e){return new Gm(await super._call(e))}},rv=class extends ev{async _call(e){return new Y(await super._call(e))}},iv=class extends ev{async _call(e){return new Wm(await super._call(e))}},av=class extends ev{async _call(e){return new Km(await super._call(e))}},ov=class extends Z{},sv=class extends ov{},cv=class extends ov{},lv=class extends Z{},uv=class extends lv{},dv=class extends lv{async _call(e){return new Gm(await super._call(e))}},fv=class extends lv{async _call(e){return new Y(await super._call(e))}},pv=class extends lv{async _call(e){return new Wm(await super._call(e))}},mv=class extends lv{async _call(e){return new Km(await super._call(e))}},hv=class extends Z{},gv=class extends hv{},_v=class extends Z{},vv=class extends _v{},yv=class extends _v{async _call(e){return new Y(await super._call(e))}},bv=class extends Z{},xv=class extends bv{},Sv=class extends Z{},Cv=class extends Sv{},wv=class extends Z{},Tv=class extends wv{},Ev=class extends wv{async _call(e){return new Ov(await super._call(e))}},Dv=class extends wv{async _call(e){return new kv(await super._call(e))}},Ov=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},kv=class extends Um{constructor({logits:e,pred_boxes:t,pred_masks:n}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=n}},Av=class extends Z{},jv=class extends Av{},Mv=class extends Av{async _call(e){return new Y(await super._call(e))}},Nv=class extends Z{},Pv=class extends Nv{},Fv=class extends Nv{async _call(e){return new Y(await super._call(e))}},Iv=class extends Z{},Lv=class extends Iv{},Rv=class extends Z{},zv=class extends Rv{},Bv=class extends Z{},Vv=class extends Bv{},Hv=class extends Bv{async _call(e){return new Y(await super._call(e))}},Uv=class extends Bv{async _call(e){return new Wm(await super._call(e))}},Wv=class extends Bv{async _call(e){return new Km(await super._call(e))}},Gv=class extends Bv{async _call(e){return new Gm(await super._call(e))}},Kv=class extends Z{},qv=class extends Kv{},Jv=class extends Z{},Yv=class extends Jv{},Xv=class extends Jv{},Zv=class extends Z{},Qv=class extends Zv{},$v=class extends Zv{async _call(e){return new Y(await super._call(e))}},ey=class extends Z{},ty=class extends ey{},ny=class extends ey{async _call(e){return new Gm(await super._call(e))}},ry=class extends ey{async _call(e){return new Y(await super._call(e))}},iy=class extends ey{async _call(e){return new Wm(await super._call(e))}},ay=class extends ey{async _call(e){return new Km(await super._call(e))}},oy=class extends Z{},sy=class extends oy{},cy=class extends oy{},ly=class extends Z{},uy=class extends ly{},dy=class extends ly{async _call(e){return new Gm(await super._call(e))}},fy=class extends ly{async _call(e){return new Y(await super._call(e))}},py=class extends ly{async _call(e){return new Wm(await super._call(e))}},my=class extends Z{},hy=class extends my{},gy=class extends my{async _call(e){return new Gm(await super._call(e))}},_y=class extends my{async _call(e){return new Y(await super._call(e))}},vy=class extends my{async _call(e){return new Wm(await super._call(e))}},yy=class extends Z{},by=class extends yy{},xy=class extends yy{},Sy=class extends Z{},Cy=class extends Sy{},wy=class extends Sy{},Ty=class extends Z{},Ey=class extends Ty{},Dy=class extends Ty{},Oy=class extends Z{},ky=class extends Oy{},Ay=class extends Oy{async _call(e){return new Y(await super._call(e))}},jy=class extends Z{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`},My=class extends jy{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:n,attention_mask:r}){return{inputs_embeds:_l([t,e],1),attention_mask:_l([El(t.dims.slice(0,2)),r],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:n,attention_mask:r}){if(!e&&!t)throw Error("Either `input_ids` or `pixel_values` should be provided.");let i,a;return e&&(i=await this.encode_text({input_ids:e})),t&&(a=await this.encode_image({pixel_values:t})),i&&a?{inputs_embeds:n,attention_mask:r}=this._merge_input_ids_with_image_features({inputs_embeds:i,image_features:a,input_ids:e,attention_mask:r}):n=i||a,{inputs_embeds:n,attention_mask:r}}async forward({input_ids:e,pixel_values:t,attention_mask:n,decoder_input_ids:r,decoder_attention_mask:i,encoder_outputs:a,past_key_values:o,inputs_embeds:s,decoder_inputs_embeds:c}){if(s||({inputs_embeds:s,attention_mask:n}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:s,attention_mask:n})),!a){let{last_hidden_state:e}=await zh(this,{inputs_embeds:s,attention_mask:n});a=e}if(!c){if(!r)throw Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:r})}let l={inputs_embeds:c,attention_mask:i,encoder_attention_mask:n,encoder_hidden_states:a,past_key_values:o};return await Gh(this,l,!0)}},Ny=class extends Z{},Py=class extends Ny{},Fy=class extends Ny{},Iy=class extends Z{},Ly=class extends Iy{},Ry=class extends Iy{},zy=class extends Z{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`position_ids`,`past_key_values`]},By=class extends zy{_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return tg({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:n})}},Vy=class extends By{},Hy=class extends By{},Uy=class extends Z{},Wy=class extends Uy{},Gy=class extends By{},Ky=class extends Gy{},qy=class extends Z{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`input_features`,`input_features_mask`,`past_key_values`]},Jy=class extends qy{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,input_features:r=null,input_features_mask:i=null,position_ids:a=null,inputs_embeds:o=null,per_layer_inputs:s=null,past_key_values:c=null,generation_config:l=null,logits_processor:u=null,...d}){if((!o||!s)&&({inputs_embeds:o,per_layer_inputs:s}=await J(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(n){let{image_features:r}=await this._encode_vision({pixel_values:n,...d});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:r,inputs_embeds:o,input_ids:e,attention_mask:t}))}if(r){let{audio_features:n}=await J(this.sessions.audio_encoder,{input_features:r,input_features_mask:i});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:n,inputs_embeds:o,input_ids:e,attention_mask:t}))}}return await Gh(this,{inputs_embeds:o,per_layer_inputs:s,past_key_values:c,attention_mask:t,position_ids:a,generation_config:l,logits_processor:u},!0)}_encode_vision(e){return J(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return tg({image_token_id:this.config.image_token_id,...e,image_features:n})}_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return ng({audio_token_id:this.config.audio_token_id,...e,audio_features:n})}},Yy=class extends Jy{},Xy=class extends Jy{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`image_position_ids`,`input_features`,`input_features_mask`,`past_key_values`];_encode_vision(e){return J(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},Zy=class extends Xy{},Qy=class extends Z{},$y=class extends Qy{},eb=class extends Qy{},tb=class extends Z{},nb=class extends tb{},rb=class extends tb{},ib=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`,`pixel_values`,`image_grid_thw`]},ab=class extends ib{image_grid_thw_name=`grid_thw`;_get_text_only_rope_index(e,t){if(t){let{data:e,dims:n}=Yh(t),r=BigInt64Array.from({length:3*e.length},(t,n)=>e[n%e.length]),i=Array.from({length:n[0]},(t,r)=>fc(e.subarray(n[1]*r,n[1]*(r+1)))[0]+1n+BigInt(n[1]));return[new U(`int64`,r,[3,...n]),new U(`int64`,i,[i.length,1])]}else{let[t,n]=e.dims;return[new U(`int64`,BigInt64Array.from({length:3*t*n},(e,r)=>BigInt(Math.floor(r%n/t))),[3,...e.dims]),Ol([t,1])]}}_reorder_and_write_positions(e,t,n,r){let i=e.reduce((e,t)=>e+t.length,0),a=Array(i),o=0;for(let t=0;t<3;++t)for(let n of e){let e=n.length/3;for(let r=t*e;r<(t+1)*e;++r)a[o++]=n[r]}let s=0;for(let e=0;e<t.length;++e)if(t[e]==1){for(let t=0;t<3;++t)n[t][r][e]=a[t*i/3+s];++s}return a}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a,video_token_id:o,vision_start_token_id:s}=this.config,c=e,l=c.reduce((e,t,n)=>(t==s&&e.push(n),e),[]).map(e=>c[e+1]),u=l.filter(e=>e==a).length,d=l.filter(e=>e==o).length,f=[],p=0,m=u,h=d;for(let e=0;e<l.length;++e){let e=c.findIndex((e,t)=>t>p&&e==a),s=c.findIndex((e,t)=>t>p&&e==o),l=m>0&&e!==-1?e:c.length+1,u=h>0&&s!==-1?s:c.length+1,d,g,_,v;l<u?([g,_,v]=t[i.image_index],++i.image_index,--m,d=l):([g,_,v]=n[i.video_index],++i.video_index,--h,d=u);let[y,b,x]=[Number(g),Math.floor(Number(_)/r),Math.floor(Number(v)/r)],ee=d-p,S=f.length>0?fc(f.at(-1))[0]+1:0;f.push(Array.from({length:3*ee},(e,t)=>S+t%ee));let te=ee+S,C=y*b*x,w=Array.from({length:C},(e,t)=>te+Math.floor(t/(b*x))),ne=Array.from({length:C},(e,t)=>te+Math.floor(t/x)%b),re=Array.from({length:C},(e,t)=>te+t%x);f.push([w,ne,re].flat()),p=d+C}if(p<c.length){let e=f.length>0?fc(f.at(-1))[0]+1:0,t=c.length-p;f.push(Array.from({length:3*t},(n,r)=>e+r%t))}return f}get_rope_index(e,t,n,r){let{vision_config:i}=this.config,a=i.spatial_merge_size??2;if(t||n){let i=e.tolist();r||=Dl(e);let o=r.tolist(),s=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),c=t?t.tolist():[],l=n?n.tolist():[],u={image_index:0,video_index:0},d=[];for(let e=0;e<i.length;++e){let t=i[e].filter((t,n)=>o[e][n]==1),n=this._get_multimodal_rope_positions({filtered_ids:t,image_grid_thw_list:c,video_grid_thw_list:l,spatial_merge_size:a,state:u}),r=this._reorder_and_write_positions(n,o[e],s,e);d.push(fc(r)[0]+1-i[e].length)}return[new U(`int64`,s.flat(1/0),[3,e.dims[0],e.dims[1]]),new U(`int64`,d,[d.length,1])]}else return this._get_text_only_rope_index(e,r)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await J(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return tg({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,n){if(!t.attention_mask||t.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes(`position_ids`))return t;if(!t.past_key_values)[t.position_ids,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);else{t.pixel_values=null;let e=t.past_key_values.get_seq_length();if(e<t.input_ids.dims[1]){let[n,r]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);t.rope_deltas=r,t.position_ids=n.slice(null,null,[e,null]),t.input_ids=t.input_ids.slice(null,[e,null])}else{t.rope_deltas||([,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask));let n=BigInt(e),r=t.rope_deltas.map(e=>n+e);t.position_ids=vl([r,r,r],0)}}return t}},ob=class extends ab{},sb=class extends ab{image_grid_thw_name=`image_grid_thw`},cb=class extends ob{image_grid_thw_name=`image_grid_thw`},lb=class extends sb{get_vision_position_ids(e,t,n,r){let i=Math.floor(t[0]/n),a=Math.floor(t[1]/r),o=Math.floor(t[2]/r),s=a*o*i,c=Array.from({length:s},()=>e),l=Array.from({length:s},(t,n)=>e+Math.floor(n/(o*i))),u=Array.from({length:s},(t,n)=>e+n%o);return[...c,...l,...u]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a}=this.config,o=[],s=0,c=+(e[0]==a);for(let t=1;t<=e.length;++t){let n=t<e.length?+(e[t]==a):-1;n!==c&&(o.push([c,s,t]),s=t,c=n)}let l=0,u=[];for(let[e,n,a]of o)if(e===0){let e=a-n;u.push(Array.from({length:3*e},(t,n)=>l+n%e)),l+=e}else{let e=t[i.image_index++].map(Number),n=e[0];u.push(this.get_vision_position_ids(l,e,n,r)),l+=Math.max(e[1],e[2])/r}return u}},ub=class extends Z{},db=class extends ub{},fb=class extends ub{},pb=class extends Z{},mb=class extends pb{},hb=class extends pb{},gb=class extends Z{},_b=class extends gb{},vb=class extends gb{},yb=class extends Z{},bb=class extends yb{},xb=class extends yb{},Sb=class extends Z{},Cb=class extends Sb{},wb=class extends Sb{},Tb=class extends Z{},Eb=class extends Tb{},Db=class extends Tb{},Ob=class extends Z{},kb=class extends Ob{},Ab=class extends Ob{},jb=class extends Z{},Mb=class extends jb{},Nb=class extends jb{},Pb=class extends Z{},Fb=class extends Pb{},Ib=class extends Pb{},Lb=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`audio_values`,`past_key_values`]},Rb=class extends Lb{_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return ng({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:n})}},zb=class extends Rb{forward_params=[`input_ids`,`attention_mask`,`input_features`,`past_key_values`]},Bb=class extends Z{},Vb=class extends Bb{},Hb=class extends Z{},Ub=class extends Hb{},Wb=class extends Z{},Gb=class extends Wb{},Kb=class extends Wb{},qb=class extends Z{},Jb=class extends qb{},Yb=class extends qb{async _call(e){return new Y(await super._call(e))}},Xb=class extends Z{},Zb=class extends Xb{},Qb=class extends Xb{async _call(e){return new qm(await super._call(e))}},$b=class extends Xb{async _call(e){return new Y(await super._call(e))}},ex=class extends Xb{async _call(e){return new Wm(await super._call(e))}},tx=class extends Z{},nx=class extends Xb{},rx=class extends Xb{async _call(e){return new qm(await super._call(e))}},ix=class extends Xb{async _call(e){return new Y(await super._call(e))}},ax=class extends Z{},ox=class extends ax{},sx=class extends ax{},cx=class extends By{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`position_ids`,`past_key_values`]},lx=class extends Z{},ux=class extends lx{},dx=class extends lx{async _call(e){return new Y(await super._call(e))}},fx=class extends Z{},px=class extends fx{},mx=class extends fx{},hx=class extends Z{},gx=class extends hx{async forward(e){let t=!e.input_ids,n=!e.pixel_values;if(t&&n)throw Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=El([e.pixel_values.dims[0],1])),n){let{image_size:t}=this.config.vision_config;e.pixel_values=wl([0,3,t,t],0)}let{text_embeddings:r,image_embeddings:i,l2norm_text_embeddings:a,l2norm_image_embeddings:o}=await super.forward(e),s={};return t||(s.text_embeddings=r,s.l2norm_text_embeddings=a),n||(s.image_embeddings=i,s.l2norm_image_embeddings=o),s}},_x=class extends hx{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},vx=class extends hx{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},yx=class extends Z{},bx=class extends yx{},xx=class extends yx{},Sx=class extends By{},Cx=class extends Z{},wx=class extends Cx{},Tx=class extends Cx{},Ex=class extends By{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`spatial_shapes`,`position_ids`,`past_key_values`]},Dx=class extends Z{},Ox=class extends Dx{},kx=class extends Dx{},Ax=class extends Z{},jx=class extends Ax{},Mx=class extends Z{},Nx=class extends Mx{},Px=class extends Mx{},Fx=class extends Z{},Ix=class extends Fx{},Lx=class extends Fx{},Rx=class extends Z{},zx=class extends Rx{},Bx=class extends Rx{},Vx=class extends Z{},Hx=class extends Vx{},Ux=class extends Vx{},Wx=class extends Z{},Gx=class extends Wx{},Kx=class extends Wx{},qx=class extends Wx{async _call(e){return new Y(await super._call(e))}},Jx=class extends Wx{},Yx=class extends Z{},Xx=class extends Yx{},Zx=class extends Z{},Qx=class extends Zx{},$x=class extends Um{constructor({char_logits:e,bpe_logits:t,wp_logits:n}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=n}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},eS=class extends Z{},tS=class extends eS{async _call(e){return new $x(await super._call(e))}},nS=class extends Um{constructor({audio_codes:e}){super(),this.audio_codes=e}},rS=class extends Um{constructor({audio_values:e}){super(),this.audio_values=e}},iS=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},aS=class extends iS{async encode(e){return new nS(await J(this.sessions.encoder_model,e))}async decode(e){return new rS(await J(this.sessions.decoder_model,e))}},oS=class extends iS{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},sS=class extends iS{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},cS=class extends Z{},lS=class extends cS{},uS=class extends cS{},dS=class extends Z{},fS=class extends dS{},pS=class extends dS{},mS=class extends Z{},hS=class extends mS{},gS=class extends mS{async _call(e){return new Gm(await super._call(e))}},_S=class extends mS{async _call(e){return new Y(await super._call(e))}},vS=class extends mS{async _call(e){return new Km(await super._call(e))}},yS=class extends Z{},bS=class extends yS{},xS=class extends yS{},SS=class extends Z{},CS=class extends SS{},wS=class extends SS{async _call(e){return new Y(await super._call(e))}},TS=class extends SS{},ES=class extends Z{},DS=class extends ES{},OS=class extends ES{async _call(e){return new Y(await super._call(e))}},kS=class extends ES{},AS=class extends Z{},jS=class extends AS{},MS=class extends AS{async _call(e){return new Y(await super._call(e))}},NS=class extends AS{},PS=class extends Z{},FS=class extends PS{},IS=class extends PS{async _call(e){return new Y(await super._call(e))}},LS=class extends PS{},RS=class extends Z{},zS=class extends RS{},BS=class extends RS{async _call(e){return new Y(await super._call(e))}},VS=class extends Z{},HS=class extends VS{},US=class extends VS{async _call(e){return new Y(await super._call(e))}},WS=class extends Z{},GS=class extends WS{},KS=class extends WS{async _call(e){return new Gm(await super._call(e))}},qS=class extends WS{async _call(e){return new Y(await super._call(e))}},JS=class extends WS{async _call(e){return new Wm(await super._call(e))}},YS=class extends Z{},XS=class extends YS{},ZS=class extends YS{},QS=class extends Z{requires_attention_mask=!1;main_input_name=`input_values`;forward_params=[`input_values`,`decoder_input_ids`,`past_key_values`]},$S=class extends QS{},eC=class extends QS{},tC=class extends Z{},nC=class extends tC{},rC=class extends tC{async _call(e){return new Gm(await super._call(e))}},iC=class extends tC{async _call(e){return new Y(await super._call(e))}},aC=class extends tC{async _call(e){return new Wm(await super._call(e))}},oC=class extends tC{async _call(e){return new Km(await super._call(e))}},sC=class extends Z{},cC=class extends sC{},lC=class extends sC{},uC=class extends Z{},dC=class extends uC{},fC=class extends uC{},pC=class extends Z{},mC=class extends pC{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 t=this._generation_mode??`text`,n;if(t===`text`||!e.past_key_values){let t=this.sessions.prepare_inputs_embeds;n=await J(t,di(e,t.inputNames))}else{let t=this.sessions.gen_img_embeds;n=await J(t,di({image_ids:e.input_ids},t.inputNames))}let r={...e,...n},i=await Gh(this,r),a=this.sessions[t===`text`?`lm_head`:`gen_head`];if(!a)throw Error(`Unable to find "${a}" generation head`);let o=await J(a,di(i,a.inputNames));return{...n,...i,...o}}prepare_inputs_for_generation(e,t,n){let r=!!t.past_key_values;return n.guidance_scale!==null&&n.guidance_scale>1&&(r?t.input_ids=_l([t.input_ids,t.input_ids],0):(t.input_ids=_l([t.input_ids,Tl(t.input_ids,BigInt(n.pad_token_id))],0),t.attention_mask=_l([t.attention_mask,Tl(t.attention_mask,0n)],0))),(r||!t.pixel_values)&&(t.pixel_values=wl([0,0,3,384,384],1)),r&&(t.images_seq_mask=new U(`bool`,[,].fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new U(`bool`,[].fill(!1),[1,1,0])),t}async generate(e){return this._generation_mode=`text`,super.generate(e)}async generate_images(e){this._generation_mode=`image`;let t=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[t,null]),r=this.sessions.image_decode,{decoded_image:i}=await J(r,{generated_tokens:n}),a=i.add_(1).mul_(255/2).clamp_(0,255).to(`uint8`),o=[];for(let e of a){let t=Yd.fromTensor(e);o.push(t)}return o}},hC=class extends Z{},gC=class extends hC{},_C=class extends hC{},vC=class extends Z{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[t,n]=e.dims,r=this.config.decoder.num_codebooks,i=n-r,a=0;for(let t=0;t<e.size;++t){if(e.data[t]==this.config.decoder.pad_token_id)continue;let o=t%n-Math.floor(t/n)%r;o>0&&o<=i&&(e.data[a++]=e.data[t])}let o=Math.floor(t/r),s=a/(o*r);return new U(e.type,e.data.slice(0,a),[o,r,s])}prepare_inputs_for_generation(e,t,n){let r=BigInt(this.config.decoder.pad_token_id),i=structuredClone(e);for(let e=0;e<i.length;++e)for(let t=0;t<i[e].length;++t)e%this.config.decoder.num_codebooks>=t&&(i[e][t]=r);return n.guidance_scale!==null&&n.guidance_scale>1&&(i=i.concat(i)),Qh(this,i,t,n)}async generate(e){let t=await super.generate(e),n=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:r}=await J(this.sessions.encodec_decode,{audio_codes:n});return r}},yC=class extends Z{},bC=class extends yC{},xC=class extends yC{},SC=class extends Z{},CC=class extends SC{},wC=class extends SC{},TC=class extends Z{},EC=class extends TC{},DC=class extends TC{async _call(e){return new Gm(await super._call(e))}},OC=class extends TC{async _call(e){return new Y(await super._call(e))}},kC=class extends TC{async _call(e){return new Wm(await super._call(e))}},AC=class extends TC{async _call(e){return new Km(await super._call(e))}},jC=class extends Z{},MC=class extends jC{},NC=class extends Z{},PC=class extends NC{},FC=class extends NC{},IC=class extends Z{},LC=class extends IC{},RC=class extends IC{},zC=class extends Z{},BC=class extends zC{},VC=class extends zC{},HC=class extends Z{},UC=class extends HC{},WC=class extends HC{},GC=class extends Z{},KC=class extends GC{},qC=class extends GC{async _call(e){return new Y(await super._call(e))}},JC=class extends Z{},YC=class extends JC{},XC=class extends JC{},ZC=class extends Z{},QC=class extends ZC{},$C=class extends ZC{},ew=class extends Z{},tw=class extends ew{},nw=class extends ew{},rw=class extends Z{},iw=class extends rw{},aw=class extends rw{},ow=class extends By{},sw=class extends Z{},cw=class extends sw{async _call(e){return new qm(await super._call(e))}},lw=class extends Z{},uw=class extends lw{},dw=class extends lw{},fw=class extends Z{},pw=class extends fw{},mw=class extends fw{},hw=class extends Z{},gw=class extends hw{},_w=class extends hw{},vw=class extends Z{},yw=class extends vw{},bw=class extends vw{},xw=class extends Z{forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`pixel_values`,`image_sizes`,`past_key_values`]},Sw=class extends xw{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,image_sizes:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,...l}){if(!a){let t;if(n&&e.dims[1]!==1){if(!r)throw Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:t}=await J(this.sessions.vision_encoder,{pixel_values:n,image_sizes:r}))}else{let e=this.config.normalized_config.hidden_size;t=new U(`float32`,[],[0,e])}({inputs_embeds:a}=await J(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:t}))}return await Gh(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,position_ids:i,generation_config:s,logits_processor:c},!1)}},Cw=class extends Z{},ww=class extends Cw{},Tw=class extends Cw{async _call(e){return new Y(await super._call(e))}},Ew=class extends Z{},Dw=class extends Ew{},Ow=class extends Ew{async _call(e){return new Wm(await super._call(e))}},kw=class extends Z{},Aw=class extends kw{},jw=class extends kw{},Mw=class extends Z{},Nw=class extends Mw{},Pw=class extends Mw{},Fw=class extends Z{},Iw=class extends Fw{},Lw=class extends Fw{},Rw=class extends Z{},zw=class extends Rw{},Bw=class extends Rw{},Vw=class extends Z{},Hw=class extends Vw{},Uw=class extends Vw{},Ww=class extends sb{},Gw=class extends cb{},Kw=class extends Ww{},qw=class extends Gw{},Jw=class extends Ww{},Yw=class extends Jw{},Xw=class extends Jw{},Zw=class extends Yw{},Qw=class extends Z{},$w=class extends Qw{},eT=class extends Qw{async _call(e){return new Y(await super._call(e))}},tT=class extends Z{},nT=class extends tT{},rT=class extends tT{async _call(e){return new iT(await super._call(e))}},iT=class extends W_{},aT=class extends Z{},oT=class extends aT{},sT=class extends aT{async _call(e){return new Gm(await super._call(e))}},cT=class extends aT{async _call(e){return new Y(await super._call(e))}},lT=class extends aT{async _call(e){return new Wm(await super._call(e))}},uT=class extends aT{async _call(e){return new Km(await super._call(e))}},dT=class extends Z{},fT=class extends dT{},pT=class extends dT{async _call(e){return new Gm(await super._call(e))}},mT=class extends dT{async _call(e){return new Y(await super._call(e))}},hT=class extends dT{async _call(e){return new Wm(await super._call(e))}},gT=class extends dT{async _call(e){return new Km(await super._call(e))}},_T=class extends Z{},vT=class extends _T{},yT=class extends _T{async _call(e){return new bT(await super._call(e))}},bT=class extends W_{},xT=class extends Um{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},ST=class extends Z{},CT=class extends ST{async get_image_embeddings({pixel_values:e}){return await zh(this,{pixel_values:e})}async forward(e){e=!e.image_embeddings||!e.image_positional_embeddings?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_labels??=El(e.input_points.dims.slice(0,-1));let t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await J(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new xT(await super._call(e))}},wT=class extends Um{constructor({iou_scores:e,pred_masks:t,object_score_logits:n}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=n}},TT=class extends Z{},ET=class extends TT{async get_image_embeddings({pixel_values:e}){return await zh(this,{pixel_values:e})}async forward(e){let{num_feature_levels:t}=this.config.vision_config;if(e=Array.from({length:t},(e,t)=>`image_embeddings.${t}`).some(t=>!e[t])?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let t=e.input_points.dims;e.input_labels??=El(t.slice(0,-1)),e.input_boxes??=wl([t[0],0,4],0)}else if(e.input_boxes){let t=e.input_boxes.dims;e.input_labels=wl([t[0],t[1],0],-1n),e.input_points=wl([t[0],1,0,2],0)}else throw Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder;return await J(n,di(e,n.inputNames))}async _call(e){return new wT(await super._call(e))}},DT=class extends ET{},OT=class extends ET{},kT=class extends Z{},AT=class extends kT{},jT=class extends kT{},MT=class extends kT{},NT=class extends Z{},PT=class extends NT{},FT=class extends NT{},IT=class extends NT{},LT=class extends Z{},RT=class extends LT{},zT=class extends LT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},BT=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},VT=class extends Z{},HT=class extends VT{},UT=class extends VT{},WT=class extends cx{},GT=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},KT=class extends GT{async encode(e){return await J(this.sessions.encoder_model,e)}async decode(e){return await J(this.sessions.decoder_model,e)}},qT=class extends GT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},JT=class extends GT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},YT=class extends Z{},XT=class extends YT{},ZT=class extends YT{},QT=class extends Z{},$T=class extends QT{},eE=class extends QT{},tE=class extends QT{async generate_speech(e,t,{threshold:n=.5,minlenratio:r=0,maxlenratio:i=20,vocoder:a=null}={}){let o={input_ids:e},{encoder_outputs:s,encoder_attention_mask:c}=await zh(this,o),l=s.dims[1]/this.config.reduction_factor,u=Math.floor(l*i),d=Math.floor(l*r),f=this.config.num_mel_bins,p=[],m=null,h=null,g=0;for(;;){++g;let e=Mh(!!h),r;r=h?h.output_sequence_out:new U(`float32`,new Float32Array(f),[1,1,f]);let i={use_cache_branch:e,output_sequence:r,encoder_attention_mask:c,speaker_embeddings:t,encoder_hidden_states:s};Wh(this,i,m),h=await J(this.sessions.decoder_model_merged,i),m=Vh(h,m);let{prob:a,spectrum:o}=h;if(p.push(o),g>=d&&(Array.from(a.data).filter(e=>e>=n).length>0||g>=u))break}let _=_l(p),{waveform:v}=await J(a.sessions.model,{spectrogram:_});return{spectrogram:_,waveform:v}}},nE=class extends Z{main_input_name=`spectrogram`},rE=class extends Z{},iE=class extends rE{},aE=class extends rE{async _call(e){return new Gm(await super._call(e))}},oE=class extends rE{async _call(e){return new Y(await super._call(e))}},sE=class extends rE{async _call(e){return new Km(await super._call(e))}},cE=class extends Z{},lE=class extends cE{},uE=class extends cE{},dE=class extends Z{},fE=class extends dE{},pE=class extends dE{},mE=class extends Z{},hE=class extends mE{},gE=class extends Z{},_E=class extends gE{async generate_speech({input_ids:e,attention_mask:t,style:n,num_inference_steps:r=5,speed:i=1.05}){let{sampling_rate:a,chunk_compress_factor:o,base_chunk_size:s,latent_dim:c}=this.config,{last_hidden_state:l,durations:u}=await J(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:n}),d=u.div(i).mul_(a),f=s*o,p=d.data,m=Int32Array.from(p,e=>Math.ceil(e/f)),h=Math.max(...m),g=e.dims[0],_=new BigInt64Array(g*h);for(let e=0;e<g;++e)_.fill(1n,e*h,e*h+m[e]);let v=new U(`int64`,_,[g,h]),y=c*o,b=y*h,x=jl([g,y,h]),ee=x.data;for(let e=0;e<g;++e)if(m[e]!==h)for(let t=0;t<y;++t)ee.fill(0,e*b+t*h+m[e],e*b+(t+1)*h);let S=wl([g],r);for(let e=0;e<r;++e){let r=wl([g],e);({denoised_latents:x}=await J(this.sessions.latent_denoiser,{style:n,noisy_latents:x,latent_mask:v,encoder_outputs:l,attention_mask:t,timestep:r,num_inference_steps:S}))}let{waveform:te}=await J(this.sessions.voice_decoder,{latents:x});return{waveform:te,durations:d}}},vE=class extends Z{},yE=class extends vE{},bE=class extends vE{async _call(e){return new Y(await super._call(e))}},xE=class extends vE{},SE=class extends Z{},CE=class extends SE{},wE=class extends SE{},TE=class extends Z{forward_params=[`input_ids`,`attention_mask`,`encoder_outputs`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},EE=class extends TE{},DE=class extends TE{},OE=class extends Z{},kE=class extends OE{},AE=class extends OE{async _call(e){return new jE(await super._call(e))}},jE=class extends Ov{},ME=class extends Z{},NE=class extends ME{},PE=class extends Z{},FE=class extends PE{},IE=class extends PE{async _call(e){return new qm(await super._call(e))}},LE=class extends PE{async _call(e){return new Y(await super._call(e))}},RE=class extends Z{},zE=class extends RE{},BE=class extends RE{async _call(e){return new qm(await super._call(e))}},VE=class extends RE{async _call(e){return new Y(await super._call(e))}},HE=class extends RE{async _call(e){return new Wm(await super._call(e))}},UE=class extends Z{},WE=class extends UE{},GE=class extends UE{},KE=class extends Z{main_input_name=`pixel_values`;forward_params=[`pixel_values`,`decoder_input_ids`,`encoder_hidden_states`,`past_key_values`]},qE=class extends Z{},JE=class extends qE{},YE=class extends qE{async _call(e){return new Y(await super._call(e))}},XE=class extends Z{},ZE=class extends XE{},QE=class extends Z{},$E=class extends QE{},eD=class extends QE{async _call(e){return new Y(await super._call(e))}},tD=class extends Z{},nD=class extends tD{async _call(e){return new Jm(await super._call(e))}},rD=class extends Z{},iD=class extends rD{},aD=class extends Um{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}},oD=class extends Z{},sD=class extends oD{async _call(e){return new aD(await super._call(e))}},cD=class extends Rb{},lD=2,uD=1,dD=new WeakMap;function fD(e,t){let{text_config:n,audio_config:r}=e.config,i=e.sessions.audio_encoder,{num_mel_bins:a,hidden_size:o}=r,s=a+o,c=new Sh,l=jm(r),u={batch_size:1},d=`float32`;for(let e of i.inputMetadata){if(e.name===`past_padding_cache`){d=e.type;continue}if(!l.has(e.name))continue;let t=Uh(e.shape,u),n=t.reduce((e,t)=>e*t,1),r=nl[e.type];c[e.name]=new U(e.type,new r(n),t)}let f=nl[d],p=new U(d,new f(s*lD),[1,s,lD]),m=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!m)throw Error(`input_features must be iterable or async iterable`);return{encoder_session:i,enc_kv_cache:c,enc_padding_cache:p,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:m,text_hidden_size:n.hidden_size}}async function pD(e,t){let n=t.dims[2],r=Math.floor((uD+n-3)/2)+1,i=new U(`int64`,BigInt64Array.from({length:r},(t,n)=>BigInt(e.enc_past_seq_len+n)),[1,r]),a=e.enc_past_seq_len+r,o=El([1,a]),{audio_embeds:s,present_padding_cache:c,...l}=await J(e.encoder_session,{input_features:t,attention_mask:o,position_ids:i,past_padding_cache:e.enc_padding_cache,...e.enc_kv_cache});e.enc_padding_cache.location===`gpu-buffer`&&e.enc_padding_cache.dispose(),e.enc_padding_cache=c;for(let t in l)if(t.startsWith(`present.`)){let n=t.replace(`present`,`past_key_values`),r=e.enc_kv_cache[n];r?.location===`gpu-buffer`&&r.dispose(),e.enc_kv_cache[n]=l[t]}return e.enc_past_seq_len=a,s}async function mD(e,t){for(;e.audio_embed_total_tokens<t&&!e.stream_exhausted;){let t=await e.chunks_iter.next();if(t.done){e.stream_exhausted=!0;break}let n=await pD(e,t.value);e.audio_embed_queue.push({data:n.data,tokens:n.dims[1]}),e.audio_embed_total_tokens+=n.dims[1]}}function hD(e,t,n){if(e.audio_embed_queue.length===0)return;let r=t.data,i=0,a=n;for(;a>0&&e.audio_embed_queue.length>0;){let t=e.audio_embed_queue[0],n=t.tokens-e.audio_queue_offset,o=Math.min(a,n),s=e.audio_queue_offset*e.text_hidden_size;for(let n=0;n<o*e.text_hidden_size;++n)r[i*e.text_hidden_size+n]+=t.data[s+n];i+=o,a-=o,e.audio_queue_offset+=o,e.audio_queue_offset>=t.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=n-a}var gD=class extends ph{constructor(e){super(),this._s=e}_call(e){let t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},_D=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`]},vD=class extends _D{async forward({input_ids:e,past_key_values:t,...n}){let r=e.dims[1],i=dD.get(this);i&&await mD(i,i.audio_consumed+r);let{inputs_embeds:a}=await J(this.sessions.embed_tokens,{input_ids:e});i&&hD(i,a,r);let o={inputs_embeds:a,...n};Wh(this,o,t);let s=this.sessions.decoder_model_merged;return await J(s,di(o,s.inputNames))}async generate({input_features:e,stopping_criteria:t,...n}){if(!e)throw Error(`input_features (generator/iterable) must be provided`);let r=fD(this,e);dD.set(this,r);let i=new mh;i.push(new gD(r)),t&&i.extend(t);try{return await super.generate({...n,stopping_criteria:i})}finally{r.enc_kv_cache.dispose(),dD.delete(this)}}},yD=class extends Z{},bD=class extends yD{},xD=class extends yD{async _call(e){return new qm(await super._call(e))}},SD=class extends yD{async _call(e){return new Y(await super._call(e))}},CD=class extends Um{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},wD=class extends Z{},TD=class extends wD{},ED=class extends wD{async _call(e){return new qm(await super._call(e))}},DD=class extends wD{async _call(e){return new Y(await super._call(e))}},OD=class extends wD{async _call(e){return new CD(await super._call(e))}},kD=class extends wD{async _call(e){return new Wm(await super._call(e))}},AD=class extends Z{},jD=class extends AD{},MD=class extends fh{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},ND=class extends Z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`attention_mask`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},PD=class extends ND{},FD=class extends ND{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,MD)}_retrieve_init_tokens(e){let t=[e.decoder_start_token_id],n=e.language,r=e.task;if(e.is_multilingual){n||=(N.warn(`No language specified - defaulting to English (en).`),`en`);let i=`<|${Fu(n)}|>`;t.push(e.lang_to_id[i]),t.push(e.task_to_id[r??`transcribe`])}else if(n||r)throw 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&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(N.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(e=>e!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,...i}){t=this._prepare_generation_config(t,i);let a=i.decoder_input_ids instanceof U?Fl(i.decoder_input_ids):i.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(n??=new Zm,n.push(new nh(t,a))),t.begin_suppress_tokens&&(n??=new Zm,n.push(new th(t.begin_suppress_tokens,a.length))),t.return_token_timestamps){if(!t.alignment_heads)throw 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.");t.task===`translate`&&N.warn(`Token-level timestamps may not be reliable for task 'translate'.`),t.output_attentions=!0,t.return_dict_in_generate=!0}if(t.return_timestamps&&!i.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:a,kwargs:i});let o=await super.generate({inputs:e,generation_config:t,logits_processor:n,decoder_input_ids:a,...i});return t.return_token_timestamps&&(o.token_timestamps=this._extract_token_timestamps(o,t.alignment_heads,t.num_frames,.02,a.length)),o}async _generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:r,kwargs:i}){let a=t.no_timestamps_token_id+1,o=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,s=t.return_token_timestamps,c=e,l=c.dims[2],u=2*this.config.max_source_positions,d=0,f=[],p=[];for(;d<l;){let e=Math.min(d+u,l),m=c.slice(null,null,[d,e]),h,g=m.dims[2];if(g<u){let e=c.dims[1],t=new Float32Array(e*u),n=m.data;for(let r=0;r<e;++r)t.set(n.subarray(r*g,(r+1)*g),r*u);h=new U(`float32`,t,[1,e,u])}else h=m;if(n)for(let e of n)`begin_index`in e&&(e.begin_index=r.length);let _=await super.generate({inputs:h,generation_config:t,logits_processor:n,decoder_input_ids:r,...i}),v=(s?_.sequences:_)[0].tolist().map(Number).slice(r.length),y;if(s){_.token_timestamps=this._extract_token_timestamps(_,t.alignment_heads,Math.floor((e-d)/2),.02,r.length);let n=d/2*.02;y=_.token_timestamps[0].tolist().slice(r.length).map(e=>e+n)}if(v.length>0&&v.at(-1)===o&&v.pop(),v.length===0)break;let b=v.map(e=>e>=a),x=v.length>=2&&b[v.length-1]&&!b[v.length-2],ee=[];for(let e=0;e<v.length-1;++e)b[e]&&b[e+1]&&ee.push(e+1);let S,te=v.length;if(ee.length>0)if(x)S=e-d;else{let e=ee.at(-1);S=(v[e-1]-a)*2,te=e}else S=e-d;let C=Math.floor(d/2),w=a+1500;for(let e=0;e<te;++e)v[e]>=a&&(v[e]=Math.min(v[e]+C,w));f.push(...v.slice(0,te)),y&&p.push(...y.slice(0,te)),d+=S}f.push(o);let m=[...r,...f];if(s){let e=new U(`int64`,m.map(BigInt),[1,m.length]),t=[...Array(r.length).fill(0),...p,0];return{sequences:e,token_timestamps:new U(`float32`,new Float32Array(t),[1,t.length])}}return new U(`int64`,m.map(BigInt),[1,m.length])}_extract_token_timestamps(e,t,n=null,r=.02,i=0){if(!e.cross_attentions)throw Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");n??N.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 a=this.config.median_filter_width;a===void 0&&(N.warn("Model config has no `median_filter_width`, using default value of 7."),a=7);let o=e.cross_attentions,s=Array.from({length:this.config.decoder_layers},(e,t)=>_l(o.map(e=>e[t]),2)),c=vl(t.map(([e,t])=>{if(e>=s.length)throw Error(`Layer index ${e} is out of bounds for cross attentions (length ${s.length}).`);return n?s[e].slice(null,t,null,[0,n]):s[e].slice(null,t)})).transpose(1,0,2,3),[l,u]=bl(c,-2,0,!0),d=c.clone();for(let e=0;e<d.dims[0];++e){let t=d[e];for(let n=0;n<t.dims[0];++n){let r=t[n],i=l[e][n][0].data,o=u[e][n][0].data;for(let e=0;e<r.dims[0];++e){let t=r[e].data;for(let e=0;e<t.length;++e)t[e]=(t[e]-o[e])/i[e];t.set(_c(t,a))}}}let f=[xl(i>0?d.slice(null,null,[i,d.dims[2]],null):d,1)],p=e.sequences.dims,m=new U(`float32`,new Float32Array(p[0]*p[1]),p);for(let e=0;e<p[0];++e){let[t,n]=bc(f[e].neg().squeeze_(0).tolist()),a=ci([1],Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n])).map(e=>!!e),o=[];for(let e=0;e<a.length;++e)a[e]&&o.push(n[e]*r);let s=Array(i).fill(0);s.push(...o),o.length>0&&s.push(o.at(-1)),m[e].data.set(s)}return m}},ID=class extends FD{},LD=class extends Z{},RD=class extends LD{},zD=class extends LD{async _call(e){return new Gm(await super._call(e))}},BD=class extends LD{async _call(e){return new Y(await super._call(e))}},VD=class extends LD{async _call(e){return new Wm(await super._call(e))}},HD=class extends LD{async _call(e){return new Km(await super._call(e))}},UD=class extends Z{},WD=class extends UD{},GD=class extends UD{async _call(e){return new Gm(await super._call(e))}},KD=class extends UD{async _call(e){return new Y(await super._call(e))}},qD=class extends UD{async _call(e){return new Wm(await super._call(e))}},JD=class extends UD{async _call(e){return new Km(await super._call(e))}},YD=class extends Z{},XD=class extends YD{},ZD=class extends YD{async _call(e){return new QD(await super._call(e))}},QD=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},$D=class extends Z{},eO=class extends $D{},tO=class extends $D{},nO=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`],[`openai_privacy_filter`,`OpenAIPrivacyFilterModel`]]),rO=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`]]),iO=new Map([[`mimi`,`MimiModel`],[`dac`,`DacModel`],[`snac`,`SnacModel`]]),aO=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`]]),oO=new Map([[`speecht5`,`SpeechT5ForSpeechToText`],[`whisper`,`WhisperForConditionalGeneration`],[`lite-whisper`,`LiteWhisperForConditionalGeneration`],[`moonshine`,`MoonshineForConditionalGeneration`],[`cohere_asr`,`CohereAsrForConditionalGeneration`]]),sO=new Map([[`speecht5`,`SpeechT5ForTextToSpeech`]]),cO=new Map([[`vits`,`VitsModel`],[`musicgen`,`MusicgenForConditionalGeneration`],[`supertonic`,`SupertonicForConditionalGeneration`]]),lO=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`]]),uO=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`],[`openai_privacy_filter`,`OpenAIPrivacyFilterForTokenClassification`]]),dO=new Map([[`t5`,`T5ForConditionalGeneration`],[`longt5`,`LongT5ForConditionalGeneration`],[`mt5`,`MT5ForConditionalGeneration`],[`bart`,`BartForConditionalGeneration`],[`mbart`,`MBartForConditionalGeneration`],[`marian`,`MarianMTModel`],[`m2m_100`,`M2M100ForConditionalGeneration`],[`blenderbot`,`BlenderbotForConditionalGeneration`],[`blenderbot-small`,`BlenderbotSmallForConditionalGeneration`]]),fO=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`],[`gemma4`,`Gemma4ForCausalLM`],[`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`]]),pO=new Map([[`multi_modality`,`MultiModalityCausalLM`]]),mO=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`]]),hO=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`]]),gO=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`]]),_O=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`],[`gemma4`,`Gemma4ForConditionalGeneration`],[`mistral3`,`Mistral3ForConditionalGeneration`],[`lighton_ocr`,`LightOnOcrForConditionalGeneration`],[`glm_ocr`,`GlmOcrForConditionalGeneration`]]),vO=new Map([[`granite_speech`,`GraniteSpeechForConditionalGeneration`],[`ultravox`,`UltravoxModel`],[`voxtral`,`VoxtralForConditionalGeneration`],[`voxtral_realtime`,`VoxtralRealtimeForConditionalGeneration`]]),yO=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`]]),bO=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`]]),xO=new Map([[`detr`,`DetrForObjectDetection`],[`rt_detr`,`RTDetrForObjectDetection`],[`rt_detr_v2`,`RTDetrV2ForObjectDetection`],[`rf_detr`,`RFDetrForObjectDetection`],[`d_fine`,`DFineForObjectDetection`],[`table-transformer`,`TableTransformerForObjectDetection`],[`yolos`,`YolosForObjectDetection`]]),SO=new Map([[`owlvit`,`OwlViTForObjectDetection`],[`owlv2`,`Owlv2ForObjectDetection`],[`grounding-dino`,`GroundingDinoForObjectDetection`]]),CO=new Map([[`detr`,`DetrForSegmentation`],[`clipseg`,`CLIPSegForImageSegmentation`]]),wO=new Map([[`segformer`,`SegformerForSemanticSegmentation`],[`sapiens`,`SapiensForSemanticSegmentation`],[`swin`,`SwinForSemanticSegmentation`],[`mobilenet_v1`,`MobileNetV1ForSemanticSegmentation`],[`mobilenet_v2`,`MobileNetV2ForSemanticSegmentation`],[`mobilenet_v3`,`MobileNetV3ForSemanticSegmentation`],[`mobilenet_v4`,`MobileNetV4ForSemanticSegmentation`]]),TO=new Map([[`detr`,`DetrForSegmentation`],[`maskformer`,`MaskFormerForInstanceSegmentation`]]),EO=new Map([[`sam`,`SamModel`],[`sam2`,`Sam2Model`],[`edgetam`,`EdgeTamModel`],[`sam3_tracker`,`Sam3TrackerModel`]]),DO=new Map([[`wav2vec2`,`Wav2Vec2ForCTC`],[`wav2vec2-bert`,`Wav2Vec2BertForCTC`],[`unispeech`,`UniSpeechForCTC`],[`unispeech-sat`,`UniSpeechSatForCTC`],[`wavlm`,`WavLMForCTC`],[`hubert`,`HubertForCTC`],[`parakeet_ctc`,`ParakeetForCTC`]]),OO=new Map([[`wav2vec2`,`Wav2Vec2ForSequenceClassification`],[`wav2vec2-bert`,`Wav2Vec2BertForSequenceClassification`],[`unispeech`,`UniSpeechForSequenceClassification`],[`unispeech-sat`,`UniSpeechSatForSequenceClassification`],[`wavlm`,`WavLMForSequenceClassification`],[`hubert`,`HubertForSequenceClassification`],[`audio-spectrogram-transformer`,`ASTForAudioClassification`]]),kO=new Map([[`wavlm`,`WavLMForXVector`]]),AO=new Map([[`unispeech-sat`,`UniSpeechSatForAudioFrameClassification`],[`wavlm`,`WavLMForAudioFrameClassification`],[`wav2vec2`,`Wav2Vec2ForAudioFrameClassification`],[`pyannote`,`PyAnnoteForAudioFrameClassification`]]),jO=new Map([[`vitmatte`,`VitMatteForImageMatting`]]),MO=new Map([[`patchtst`,`PatchTSTForPrediction`],[`patchtsmixer`,`PatchTSMixerForPrediction`]]),NO=new Map([[`swin2sr`,`Swin2SRForImageSuperResolution`]]),PO=new Map([[`chmv2`,`CHMv2ForDepthEstimation`],[`dpt`,`DPTForDepthEstimation`],[`depth_anything`,`DepthAnythingForDepthEstimation`],[`glpn`,`GLPNForDepthEstimation`],[`sapiens`,`SapiensForDepthEstimation`],[`depth_pro`,`DepthProForDepthEstimation`],[`metric3d`,`Metric3DForDepthEstimation`],[`metric3dv2`,`Metric3Dv2ForDepthEstimation`]]),FO=new Map([[`sapiens`,`SapiensForNormalEstimation`]]),IO=new Map([[`vitpose`,`VitPoseForPoseEstimation`]]),LO=new Map([[`clip`,`CLIPVisionModelWithProjection`],[`siglip`,`SiglipVisionModel`],[`jina_clip`,`JinaCLIPVisionModel`]]),RO=[[nO,X.EncoderOnly],[rO,X.EncoderDecoder],[aO,X.DecoderOnlyWithoutHead],[iO,X.AutoEncoder],[lO,X.EncoderOnly],[uO,X.EncoderOnly],[dO,X.Seq2Seq],[oO,X.Seq2Seq],[fO,X.DecoderOnly],[pO,X.MultiModality],[mO,X.EncoderOnly],[hO,X.EncoderOnly],[gO,X.Vision2Seq],[_O,X.ImageTextToText],[vO,X.AudioTextToText],[bO,X.EncoderOnly],[CO,X.EncoderOnly],[TO,X.EncoderOnly],[wO,X.EncoderOnly],[jO,X.EncoderOnly],[MO,X.EncoderOnly],[NO,X.EncoderOnly],[PO,X.EncoderOnly],[FO,X.EncoderOnly],[IO,X.EncoderOnly],[xO,X.EncoderOnly],[SO,X.EncoderOnly],[EO,X.MaskGeneration],[DO,X.EncoderOnly],[OO,X.EncoderOnly],[sO,X.Seq2Seq],[cO,X.EncoderOnly],[kO,X.EncoderOnly],[AO,X.EncoderOnly],[LO,X.EncoderOnly]];for(let[e,t]of RO)for(let n of e.values()){Fh.set(n,t);let e=ig[n];Lh.set(e,n),Ih.set(n,e)}var zO=[[`MusicgenForConditionalGeneration`,vC,X.Musicgen],[`Phi3VForCausalLM`,Sw,X.Phi3V],[`CLIPTextModelWithProjection`,d_,X.EncoderOnly],[`SiglipTextModel`,zT,X.EncoderOnly],[`JinaCLIPTextModel`,_x,X.EncoderOnly],[`ClapTextModelWithProjection`,o_,X.EncoderOnly],[`ClapAudioModelWithProjection`,s_,X.EncoderOnly],[`DacEncoderModel`,Q_,X.EncoderOnly],[`DacDecoderModel`,$_,X.EncoderOnly],[`MimiEncoderModel`,oS,X.EncoderOnly],[`MimiDecoderModel`,sS,X.EncoderOnly],[`SnacEncoderModel`,qT,X.EncoderOnly],[`SnacDecoderModel`,JT,X.EncoderOnly],[`Gemma3nForConditionalGeneration`,Jy,X.ImageAudioTextToText],[`Gemma4ForConditionalGeneration`,Xy,X.ImageAudioTextToText],[`SupertonicForConditionalGeneration`,_E,X.Supertonic],[`ChatterboxModel`,$g,X.Chatterbox],[`VoxtralRealtimeForConditionalGeneration`,vD,X.VoxtralRealtime]];for(let[e,t,n]of zO)Fh.set(e,n),Lh.set(t,e),Ih.set(e,t);var BO=new Map([[`modnet`,CO],[`birefnet`,CO],[`isnet`,CO],[`ben`,CO]]);for(let[e,t]of BO.entries())t.set(e,`PreTrainedModel`),Fh.set(e,X.EncoderOnly),Ih.set(e,Z);var VO=new Set(BO.keys());Fh.set(`PreTrainedModel`,X.EncoderOnly),Lh.set(Z,`PreTrainedModel`);var Q={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:lO,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:uO,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:sO,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:cO,MODEL_FOR_MASKED_LM_MAPPING_NAMES:mO,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:hO,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:bO,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:CO,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:wO,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:TO,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:xO,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:SO,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:EO,MODEL_FOR_CTC_MAPPING_NAMES:DO,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:OO,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:kO,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:AO,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:yO,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:jO,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:NO,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:PO,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:FO,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:IO,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:LO,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:_O,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:vO,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:dO,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:oO,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:fO,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:gO};Ah(Q);var $=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let t of this.MODEL_CLASS_MAPPINGS)if(t.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d};if(f.config=await Pm.from_pretrained(e,f),!this.MODEL_CLASS_MAPPINGS)throw Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:p}=f.config;for(let t of this.MODEL_CLASS_MAPPINGS){let n=t.get(p);if(!n){for(let e of t.values())if(e[0]===p){n=e;break}if(!n)continue}return await ig[n].from_pretrained(e,f)}if(this.BASE_IF_FAIL)return VO.has(p)||N.warn(`Unknown model class "${p}", attempting to construct from base class.`),await Z.from_pretrained(e,f);throw Error(`Unsupported model type: ${p}`)}},HO=class extends ${static MODEL_CLASS_MAPPINGS=RO.map(e=>e[0]);static BASE_IF_FAIL=!0},UO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},WO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},GO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},KO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},qO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},JO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},YO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},XO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},ZO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},QO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},$O=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},ek=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},tk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},nk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},rk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},ik=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},ak=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},ok=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_CTC_MAPPING_NAMES]},sk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},ck=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},lk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},uk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},dk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},fk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},pk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},mk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},hk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},gk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},_k=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},vk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function yk(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>Yd.read(e)))}async function bk(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>typeof e==`string`||e instanceof URL?$u(e,t):e instanceof Float64Array?new Float32Array(e):e))}function xk(e,t){t&&(e=e.map(e=>e|0));let[n,r,i,a]=e;return{xmin:n,ymin:r,xmax:i,ymax:a}}var Sk=class extends ni{constructor({task:e,model:t,tokenizer:n=null,processor:r=null}){super(),this.task=e,this.model=t,this.tokenizer=n,this.processor=r}async dispose(){await this.model.dispose()}},Ck=class extends Sk{async _call(e,{top_k:t=1}={}){let n=this.tokenizer(e,{padding:!0,truncation:!0}),r=await this.model(n),{problem_type:i,id2label:a}=this.model.config,o=i===`multi_label_classification`?e=>e.sigmoid():e=>new U(`float32`,oc(e.data),e.dims),s=[];for(let e of r.logits){let n=await ll(o(e),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));t===1?s.push(...i):s.push(i)}return Array.isArray(e)||t===1?s:s[0]}},wk=class extends Sk{async _call(e,{ignore_labels:t=[`O`],aggregation_strategy:n=`none`}={}){if(n!==`none`&&n!==`simple`)throw Error(`Invalid aggregation_strategy: "${n}". Must be one of "none" or "simple".`);let r=Array.isArray(e),i=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),a=(await this.model(i)).logits,o=this.model.config.id2label,s=[];for(let e=0;e<a.dims[0];++e){let r=i.input_ids[e].tolist(),c=a[e],l=[];for(let e=0;e<c.dims[0];++e){let n=c[e],i=fc(n.data)[1],a=o?o[i]:`LABEL_${i}`;if(t.includes(a))continue;let s=this.tokenizer.decode([r[e]],{skip_special_tokens:!0});if(s===``)continue;let u=oc(n.data);l.push({entity:a,score:u[i],index:e,word:s})}s.push(n===`simple`?Ek(l,r,this.tokenizer):l)}return r?s:s[0]}};function Tk(e){let t=e[0];return e[1]===`-`&&(t===`B`||t===`I`||t===`E`||t===`S`)?[t,e.slice(2)]:[`I`,e]}function Ek(e,t,n){let r=[],i=null;for(let t=0;t<e.length;++t){let[n,a]=Tk(e[t].entity);i===a&&n!==`B`&&n!==`S`?(r[r.length-1].end=t+1,n===`E`&&(i=null)):(r.push({tag:a,start:t,end:t+1}),i=n===`S`?null:a)}return r.map(({tag:r,start:i,end:a})=>{let o=0,s=[];for(let n=i;n<a;++n)o+=e[n].score,s.push(t[e[n].index]);return{entity_group:r,score:o/(a-i),word:n.decode(s,{skip_special_tokens:!0})}})}var Dk=class extends Sk{async _call(e,t,{top_k:n=1}={}){let r=this.tokenizer(e,{text_pair:t,padding:!0,truncation:!0}),i=Array.isArray(e),{start_logits:a,end_logits:o}=await this.model(r),s=r.input_ids.tolist(),c=r.attention_mask.tolist(),{all_special_ids:l,sep_token_id:u}=this.tokenizer,d=[];for(let e=0;e<a.dims[0];++e){let t=s[e],r=t.findIndex(e=>e==u),i=a[e].tolist(),f=o[e].tolist();for(let n=1;n<i.length;++n)(c[e]==0||n<=r||l.findIndex(e=>e==t[n])!==-1)&&(i[n]=-1/0,f[n]=-1/0);let p=oc(i).map((e,t)=>[e,t]),m=oc(f).map((e,t)=>[e,t]);p[0][0]=0,m[0][0]=0;let h=li(p,m).filter(e=>e[0][1]<=e[1][1]).map(e=>[e[0][1],e[1][1],e[0][0]*e[1][0]]).sort((e,t)=>t[2]-e[2]),g=[];for(let e=0;e<Math.min(h.length,n);++e){let[n,r,i]=h[e],a=t.slice(n,r+1),o=this.tokenizer.decode(a,{skip_special_tokens:!0});g.push({answer:o,score:i})}n===1?d.push(...g):d.push(g)}return i?d:d[0]}},Ok=class extends Sk{async _call(e,{top_k:t=5}={}){let{mask_token_id:n,mask_token:r}=this.tokenizer,i=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:a}=await this.model(i),o=[],s=i.input_ids.tolist();for(let e=0;e<s.length;++e){let i=s[e],c=i.findIndex(e=>e==n);if(c===-1)throw Error(`Mask token (${r}) not found in text.`);let l=a[e][c],u=await ll(new U(`float32`,oc(l.data),l.dims),t),d=u[0].tolist(),f=u[1].tolist();o.push(f.map((e,t)=>{let n=i.slice();return n[c]=e,{score:d[t],token:Number(e),token_str:this.tokenizer.decode([e]),sequence:this.tokenizer.decode(n,{skip_special_tokens:!0})}}))}return Array.isArray(e)?o:o[0]}},kk=class extends Sk{_default_generation_config={max_new_tokens:256};_key=`generated_text`;async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let r=this.tokenizer,i={padding:!0,truncation:!0},a;a=this.task===`translation`&&`_build_translation_inputs`in r?r._build_translation_inputs(e,i,t):r(e,i);let o=await this.model.generate({...a,...this._default_generation_config,...t});return r.batch_decode(o,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}},Ak=class extends kk{_key=`summary_text`},jk=class extends kk{_key=`translation_text`};function Mk(e){return Array.isArray(e)&&e.every(e=>`role`in e&&`content`in e)}var Nk=class extends Sk{_default_generation_config={max_new_tokens:256};async _call(e,t={}){let{add_special_tokens:n,return_full_text:r,tools:i,documents:a,chat_template:o,tokenizer_encode_kwargs:s,...c}=t,l=!1,u=!1,d=n??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,f=s,p;if(typeof e==`string`)p=e=[e];else if(Array.isArray(e)&&e.every(e=>typeof e==`string`))l=!0,p=e;else{if(Mk(e))e=[e];else if(Array.isArray(e)&&e.every(Mk))l=!0;else throw Error(`Input must be a string, an array of strings, a Chat, or an array of Chats`);u=!0;let t={tokenize:!1,add_generation_prompt:!0,...di({tools:i,documents:a,chat_template:o},[`tools`,`documents`,`chat_template`]),...f};p=e.map(e=>this.tokenizer.apply_chat_template(e,t)),d=!1,f=void 0}let m=u?!1:r??!0;this.tokenizer.padding_side=`left`;let h=this.tokenizer(p,{add_special_tokens:d,padding:!0,truncation:!0,...f}),g=await this.model.generate({...h,...this._default_generation_config,...c}),_=this.tokenizer.batch_decode(g,{skip_special_tokens:!0}),v;!m&&h.input_ids.dims.at(-1)>0&&(v=this.tokenizer.batch_decode(h.input_ids,{skip_special_tokens:!0}).map(e=>e.length));let y=Array.from({length:e.length},e=>[]);for(let t=0;t<_.length;++t){let n=Math.floor(t/g.dims[0]*e.length);v&&(_[t]=_[t].slice(v[n])),y[n].push({generated_text:u?[...e[n],{role:`assistant`,content:_[t]}]:_[t]})}return!l&&y.length===1?y[0]:y}},Pk=class extends Sk{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([e,t])=>[e.toLowerCase(),t])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(N.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&&(N.warn(`Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id.`),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:n=`This example is {}.`,multi_label:r=!1}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let a=t.map(e=>n.replace(`{}`,e)),o=r||t.length===1,s=[];for(let n of e){let e=[];for(let t of a){let r=this.tokenizer(n,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(r);o?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let r=(o?e.map(e=>oc(e)[1]):oc(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);s.push({sequence:n,labels:r.map(e=>t[e[1]]),scores:r.map(e=>e[0])})}return i?s:s[0]}},Fk=class extends Sk{async _call(e,{top_k:t=5}={}){let n=this.processor.feature_extractor.config.sampling_rate,r=await bk(e,n),i=this.model.config.id2label,a=[];for(let e of r){let n=await this.processor(e),r=(await this.model(n)).logits[0],o=await ll(new U(`float32`,oc(r.data),r.dims),t),s=o[0].tolist(),c=o[1].tolist().map((e,t)=>({label:i?i[e]:`LABEL_${e}`,score:s[t]}));a.push(c)}return Array.isArray(e)?a:a[0]}},Ik=class extends Sk{async _call(e,t,{hypothesis_template:n=`This is a sound of {}.`}={}){let r=!Array.isArray(e);r&&(e=[e]);let i=t.map(e=>n.replace(`{}`,e)),a=this.tokenizer(i,{padding:!0,truncation:!0}),o=this.processor.feature_extractor.config.sampling_rate,s=await bk(e,o),c=[];for(let e of s){let n=await this.processor(e),r=oc((await this.model({...a,...n})).logits_per_audio.data);c.push([...r].map((e,n)=>({score:e,label:t[n]})))}return r?c[0]:c}},Lk=class extends Sk{_default_generation_config={};async _call(e,t={}){switch(t={...this._default_generation_config,...t},this.model.config.model_type){case`whisper`:case`lite-whisper`:return this._call_whisper(e,t);case`wav2vec2`:case`wav2vec2-bert`:case`unispeech`:case`unispeech-sat`:case`hubert`:case`parakeet_ctc`:return this._call_wav2vec2(e,t);case`moonshine`:return this._call_moonshine(e,t);case`cohere_asr`:return this._call_cohere_asr(e,t);default:throw Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&N.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&N.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await bk(r,i),o=[];for(let e of a){let t=await this.processor(e),n=(await this.model(t)).logits[0],r=[];for(let e of n)r.push(fc(e.data)[1]);let i=this.tokenizer.decode(r,{skip_special_tokens:!0}).trim();o.push({text:i})}return n?o[0]:o}async _call_whisper(e,t){let n=t.return_timestamps??!1,r=t.chunk_length_s??0,i=t.force_full_sequences??!1,a=t.stride_length_s??null,o={...t};n===`word`&&(o.return_token_timestamps=!0,o.return_timestamps=!0);let s=!Array.isArray(e),c=s?[e]:e,l=this.processor.feature_extractor.config,u=l.chunk_length/this.model.config.max_source_positions,d=l.hop_length,f=l.sampling_rate,p=await bk(c,f),m=[];for(let e of p){let t=[];if(r>0){if(a===null)a=r/6;else if(r<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let n=f*r,i=f*a,o=n-2*i,s=0;for(;;){let r=s+n,a=e.subarray(s,r),c=await this.processor(a),l=s===0,u=r>=e.length;if(t.push({stride:[a.length,l?0:i,u?0:i],input_features:c.input_features,is_last:u}),u)break;s+=o}}else t=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of t){o.num_frames=Math.floor(e.stride[0]/d);let t=await this.model.generate({inputs:e.input_features,...o});if(n===`word`){let n=t.sequences.tolist()[0],r=t.token_timestamps.tolist()[0],i=this.tokenizer.timestamp_begin,a=Math.max(n.findIndex(e=>Number(e)>=i),0);e.tokens=n.slice(a),e.token_timestamps=r.slice(a).map(e=>vc(e,2))}else e.tokens=t[0].tolist();e.stride=e.stride.map(e=>e/f)}let[s,c]=this.tokenizer._decode_asr(t,{time_precision:u,return_timestamps:n,force_full_sequences:i});m.push({text:s,...c})}return s?m[0]:m}async _call_moonshine(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await bk(r,i),o=[];for(let e of a){let n=await this.processor(e),r=Math.floor(e.length/i)*6,a=await this.model.generate({max_new_tokens:r,...t,...n}),s=this.processor.batch_decode(a,{skip_special_tokens:!0})[0];o.push({text:s})}return n?o[0]:o}async _call_cohere_asr(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor,a=i.config.sampling_rate,o=await bk(r,a),s=t.language??`en`,c=this.processor.get_decoder_prompt_ids(s),l=[];for(let e of o){let n=i.split_audio(e),r=[];for(let e of n){let n=await this.processor(e),i=await this.model.generate({...n,decoder_input_ids:c,...t}),a=this.tokenizer.decode(i[0].tolist(),{skip_special_tokens:!0}).trim();r.push(a)}let a=this.processor.constructor.join_chunks(r,s);l.push({text:a})}return n?l[0]:l}},Rk=class extends Sk{DEFAULT_VOCODER_ID=`Xenova/speecht5_hifigan`;constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,t){if((typeof e==`string`||e instanceof URL)&&(e=new Float32Array(await(await M.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new U(`float32`,e,[e.length]);else if(!(e instanceof U))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(t>1){if(e.dims[0]===1)e=e.repeat(t,1);else if(e.dims[0]!==t)throw Error(`Expected speaker embeddings batch size to be 1 or ${t}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,t,n,r=null){let i=t.data,[a,o]=t.dims,s=r?r.data:null,c=[];for(let e=0;e<a;++e){let t=s?Math.min(Math.ceil(s[e]),o):o,r=e*o;c.push(new vd(i.slice(r,r+t),n))}return Array.isArray(e)?c:c[0]}async _call(e,t){return this.processor?this._call_text_to_spectrogram(e,t):this.model.config.model_type===`supertonic`?this._call_supertonic(e,t):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:t,num_inference_steps:n,speed:r}){if(!t)throw Error(`Speaker embeddings must be provided for Supertonic models.`);let{sampling_rate:i,style_dim:a}=this.model.config,o=this.tokenizer(e,{padding:!0,truncation:!0}),s=o.input_ids.dims[0];t=await this._prepare_speaker_embeddings(t,s),t=t.view(s,-1,a);let{waveform:c,durations:l}=await this.model.generate_speech({...o,style:t,num_inference_steps:n,speed:r});return this._postprocess_waveform(e,c,i,l)}async _call_text_to_waveform(e){let t=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:n}=await this.model(t),r=this.model.config.sampling_rate;return this._postprocess_waveform(e,n,r)}async _call_text_to_spectrogram(e,{speaker_embeddings:t}){this.vocoder||=(N.info(`No vocoder specified, using default HifiGan vocoder.`),await HO.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:`fp32`}));let{input_ids:n}=this.tokenizer(e,{padding:!0,truncation:!0}),r=n.dims[0];t=await this._prepare_speaker_embeddings(t,r),t=t.view(r,-1);let{waveform:i}=await this.model.generate_speech(n,t,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,i,a)}},zk=class extends Sk{async _call(e,t={}){let n=Array.isArray(e),r=await yk(e),{pixel_values:i}=await this.processor(r),a=[];for(let e of i){e.dims=[1,...e.dims];let n=await this.model.generate({inputs:e,...t}),r=this.tokenizer.batch_decode(n,{skip_special_tokens:!0}).map(e=>({generated_text:e.trim()}));a.push(r)}return n?a:a[0]}},Bk=class extends Sk{async _call(e,{top_k:t=5}={}){let n=await yk(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),{id2label:a}=this.model.config,o=[];for(let e of i.logits){let n=await ll(new U(`float32`,oc(e.data),e.dims),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));o.push(i)}return Array.isArray(e)?o:o[0]}},Vk={panoptic:`post_process_panoptic_segmentation`,instance:`post_process_instance_segmentation`,semantic:`post_process_semantic_segmentation`},Hk=class extends Sk{async _call(e,{threshold:t=.5,mask_threshold:n=.5,overlap_mask_area_threshold:r=.8,label_ids_to_fuse:i=null,target_sizes:a=null,subtask:o=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error(`Image segmentation pipeline currently only supports a batch size of 1.`);let s=await yk(e),c=s.map(e=>[e.height,e.width]),l=await this.processor(s),{inputNames:u,outputNames:d}=this.model.sessions.model;if(!u.includes(`pixel_values`)){if(u.length!==1)throw Error(`Expected a single input name, but got ${u.length} inputs: ${u}.`);let e=u[0];if(e in l)throw Error(`Input name ${e} already exists in the inputs.`);l[e]=l.pixel_values}let f=await this.model(l),p=null;if(o!==null)p=Vk[o];else if(this.processor.image_processor){for(let[e,t]of Object.entries(Vk))if(t in this.processor.image_processor){p=this.processor.image_processor[t].bind(this.processor.image_processor),o=e;break}}let m=this.model.config.id2label,h=[];if(!o){let e=f[d[0]];for(let t=0;t<c.length;++t){let n=c[t],r=e[t];r.data.some(e=>e<-1e-5||e>1.00001)&&r.sigmoid_();let i=await Yd.fromTensor(r.mul_(255).to(`uint8`)).resize(n[1],n[0]);h.push({label:null,score:null,mask:i})}}else if(o===`panoptic`||o===`instance`){let e=p(f,t,n,r,i,a??c)[0],o=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(o.data.length);for(let n=0;n<o.data.length;++n)o.data[n]===t.id&&(e[n]=255);let n=new Yd(e,o.dims[1],o.dims[0],1);h.push({score:t.score,label:m[t.label_id],mask:n})}}else if(o===`semantic`){let{segmentation:e,labels:t}=p(f,a??c)[0];for(let n of t){let t=new Uint8ClampedArray(e.data.length);for(let r=0;r<e.data.length;++r)e.data[r]===n&&(t[r]=255);let r=new Yd(t,e.dims[1],e.dims[0],1);h.push({score:null,label:m[n],mask:r})}}else throw Error(`Subtask ${o} not supported.`);return h}},Uk=class extends Hk{async _call(e,t={}){let n=await yk(e),r=await super._call(e,t),i=n.map((e,t)=>{let n=e.clone();return n.putAlpha(r[t].mask),n});return Array.isArray(e)?i:i[0]}},Wk=class extends Sk{async _call(e,t,{hypothesis_template:n=`This is a photo of {}`}={}){let r=Array.isArray(e),i=await yk(e),a=t.map(e=>n.replace(`{}`,e)),o=this.tokenizer(a,{padding:this.model.config.model_type===`siglip`?`max_length`:!0,truncation:!0}),{pixel_values:s}=await this.processor(i),c=await this.model({...o,pixel_values:s}),l=this.model.config.model_type===`siglip`?e=>e.sigmoid().data:e=>oc(e.data),u=[];for(let e of c.logits_per_image){let n=[...l(e)].map((e,n)=>({score:e,label:t[n]}));n.sort((e,t)=>t.score-e.score),u.push(n)}return r?u:u[0]}},Gk=class extends Sk{async _call(e,{threshold:t=.9,percentage:n=!1}={}){let r=Array.isArray(e);if(r&&e.length!==1)throw Error(`Object detection pipeline currently only supports a batch size of 1.`);let i=await yk(e),a=n?null:i.map(e=>[e.height,e.width]),{pixel_values:o,pixel_mask:s}=await this.processor(i),c=await this.model({pixel_values:o,pixel_mask:s}),l=this.processor.image_processor.post_process_object_detection(c,t,a),{id2label:u}=this.model.config,d=l.map(e=>e.boxes.map((t,r)=>({score:e.scores[r],label:u[e.classes[r]],box:xk(t,!n)})));return r?d:d[0]}},Kk=class extends Sk{async _call(e,t,{threshold:n=.1,top_k:r=null,percentage:i=!1}={}){let a=Array.isArray(e),o=await yk(e),s=this.tokenizer(t,{padding:!0,truncation:!0}),c=await this.processor(o),l=[];for(let e=0;e<o.length;++e){let a=o[e],u=i?null:[[a.height,a.width]],d=c.pixel_values[e].unsqueeze_(0),f=await this.model({...s,pixel_values:d}),p;if(`post_process_grounded_object_detection`in this.processor){let e=this.processor.post_process_grounded_object_detection(f,s.input_ids,{box_threshold:n,text_threshold:n,target_sizes:u})[0];p=e.boxes.map((t,n)=>({score:e.scores[n],label:e.labels[n],box:xk(t,!i)}))}else{let e=this.processor.image_processor.post_process_object_detection(f,n,u,!0)[0];p=e.boxes.map((n,r)=>({score:e.scores[r],label:t[e.classes[r]],box:xk(n,!i)}))}p.sort((e,t)=>t.score-e.score),r!==null&&(p=p.slice(0,r)),l.push(p)}return a?l:l[0]}},qk=class extends Sk{_default_generation_config={max_new_tokens:256};async _call(e,t,n={}){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 r=(await yk(e))[0],{pixel_values:i}=await this.processor(r),a=`<s_docvqa><s_question>${t}</s_question><s_answer>`,o=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,s=await this.model.generate({inputs:i,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:o,...this._default_generation_config,...n}),c=this.tokenizer.batch_decode(s)[0].match(/<s_answer>(.*?)<\/s_answer>/),l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}},Jk=class extends Sk{async _call(e){let t=await yk(e),n=await this.processor(t),r=await this.model(n),i=[];for(let e of r.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to(`uint8`);i.push(Yd.fromTensor(t))}return Array.isArray(e)?i:i[0]}},Yk=class extends Sk{async _call(e){let t=await yk(e),n=await this.processor(t),{predicted_depth:r}=await this.model(n),i=[];for(let e=0;e<t.length;++e){let n=r[e],[a,o]=n.dims.slice(-2),[s,c]=t[e].size,l=(await ol(n.view(1,1,a,o),{size:[c,s],mode:`bilinear`})).view(c,s),u=l.min().item(),d=l.max().item(),f=l.sub(u).div_(d-u).mul_(255).to(`uint8`).unsqueeze(0),p=Yd.fromTensor(f);i.push({predicted_depth:l,depth:p})}return Array.isArray(e)?i:i[0]}},Xk=class extends Sk{async _call(e,{pooling:t=`none`,normalize:n=!1,quantize:r=!1,precision:i=`binary`}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),o=await this.model(a),s=o.last_hidden_state??o.logits??o.token_embeddings;switch(t){case`none`:break;case`mean`:s=fl(s,a.attention_mask);break;case`first_token`:case`cls`:s=s.slice(null,0);break;case`last_token`:case`eos`:s=s.slice(null,-1);break;default:throw Error(`Pooling method '${t}' not supported.`)}return n&&(s=s.normalize(2,-1)),r&&(s=Ml(s,i)),s}},Zk=class extends Sk{async _call(e,{pool:t=null}={}){let n=await yk(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),a;if(t){if(!(`pooler_output`in i))throw Error(`No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.`);a=i.pooler_output}else a=i.last_hidden_state??i.logits??i.image_embeds;return a}},Qk=Object.freeze({"text-classification":{pipeline:Ck,model:UO,default:{model:`Xenova/distilbert-base-uncased-finetuned-sst-2-english`},type:`text`},"token-classification":{pipeline:wk,model:WO,default:{model:`Xenova/bert-base-multilingual-cased-ner-hrl`},type:`text`},"question-answering":{pipeline:Dk,model:ZO,default:{model:`Xenova/distilbert-base-cased-distilled-squad`},type:`text`},"fill-mask":{pipeline:Ok,model:XO,default:{model:`onnx-community/ettin-encoder-32m-ONNX`,dtype:`fp32`},type:`text`},summarization:{pipeline:Ak,model:GO,default:{model:`Xenova/distilbart-cnn-6-6`},type:`text`},translation:{pipeline:jk,model:GO,default:{model:`Xenova/t5-small`},type:`text`},"text2text-generation":{pipeline:kk,model:GO,default:{model:`Xenova/flan-t5-small`},type:`text`},"text-generation":{pipeline:Nk,model:YO,default:{model:`onnx-community/Qwen3-0.6B-ONNX`,dtype:`q4`},type:`text`},"zero-shot-classification":{pipeline:Pk,model:UO,default:{model:`Xenova/distilbert-base-uncased-mnli`},type:`text`},"audio-classification":{pipeline:Fk,model:sk,default:{model:`Xenova/wav2vec2-base-superb-ks`},type:`audio`},"zero-shot-audio-classification":{pipeline:Ik,model:HO,default:{model:`Xenova/clap-htsat-unfused`},type:`multimodal`},"automatic-speech-recognition":{pipeline:Lk,model:[KO,ok],default:{model:`Xenova/whisper-tiny.en`},type:`multimodal`},"text-to-audio":{pipeline:Rk,model:[JO,qO],default:{model:`onnx-community/Supertonic-TTS-ONNX`,dtype:`fp32`},type:`text`},"image-to-text":{pipeline:zk,model:QO,default:{model:`Xenova/vit-gpt2-image-captioning`},type:`multimodal`},"image-classification":{pipeline:Bk,model:$O,default:{model:`Xenova/vit-base-patch16-224`},type:`multimodal`},"image-segmentation":{pipeline:Hk,model:[ek,tk,nk],default:{model:`Xenova/detr-resnet-50-panoptic`},type:`multimodal`},"background-removal":{pipeline:Uk,model:[ek,tk,nk],default:{model:`Xenova/modnet`},type:`image`},"zero-shot-image-classification":{pipeline:Wk,model:HO,default:{model:`Xenova/clip-vit-base-patch32`},type:`multimodal`},"object-detection":{pipeline:Gk,model:rk,default:{model:`Xenova/detr-resnet-50`},type:`multimodal`},"zero-shot-object-detection":{pipeline:Kk,model:ik,default:{model:`Xenova/owlvit-base-patch32`},type:`multimodal`},"document-question-answering":{pipeline:qk,model:uk,default:{model:`Xenova/donut-base-finetuned-docvqa`},type:`multimodal`},"image-to-image":{pipeline:Jk,model:fk,default:{model:`Xenova/swin2SR-classical-sr-x2-64`},type:`image`},"depth-estimation":{pipeline:Yk,model:pk,default:{model:`onnx-community/depth-anything-v2-small`},type:`image`},"feature-extraction":{pipeline:Xk,model:HO,default:{model:`onnx-community/all-MiniLM-L6-v2-ONNX`,dtype:`fp32`},type:`text`},"image-feature-extraction":{pipeline:Zk,model:[gk,HO],default:{model:`onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX`,dtype:`fp32`},type:`image`}}),$k=Object.freeze({"sentiment-analysis":`text-classification`,ner:`token-classification`,asr:`automatic-speech-recognition`,"text-to-speech":`text-to-audio`,embeddings:`feature-extraction`});async function eA(e){if(!e)throw Error(`modelId is required`);return(await Ks(e,Uu,{})).exists?[Uu]:[]}async function tA(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null,include_tokenizer:a=!0,include_processor:o=!0}={}){let s=await Oh(e,{config:t,dtype:n,device:r,model_file_name:i});if(a){let t=await Nl(e);s.push(...t)}if(o){let t=await eA(e);s.push(...t)}return s}async function nA(e,t,n={}){e=$k[e]??e;let r=Qk[e];if(!r)throw Error(`Unsupported pipeline task: ${e}. Must be one of [${Object.keys(Qk).join(`, `)}]`);let{type:i}=r,a=i!==`audio`&&i!==`image`,o=i!==`text`,s=await tA(t,{...n,include_tokenizer:a,include_processor:o});if(e===`text-generation`){let e=wh(Eh(await Dh(t,n)));if(e){let t=Object.values(e).map(e=>`onnx/${e}`);return s.filter(e=>!e.startsWith(`onnx/`)||t.some(t=>e.startsWith(t)))}}return s}async function rA(e,t=null,{progress_callback:n=null,config:r=null,cache_dir:i=null,local_files_only:a=!1,revision:o=`main`,device:s=null,dtype:c=null,subfolder:l=`onnx`,use_external_data_format:u=null,model_file_name:d=null,session_options:f={}}={}){e=$k[e]??e;let p=Qk[e.split(`_`,1)[0]];if(!p)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(Qk)}]`);t||(t=p.default.model,N.info(`No model specified. Using default model: "${t}".`),!c&&p.default.dtype&&(c=p.default.dtype));let m=await nA(e,t,{device:s,dtype:c}),h={};n&&(await Promise.all(m.map(async e=>Ks(t,e)))).forEach((e,t)=>{e.exists&&(h[m[t]]={loaded:0,total:e.size??0})});let g={progress_callback:n?new ii(n,h):void 0,config:r,cache_dir:i,local_files_only:a,revision:o,device:s,dtype:c,subfolder:l,use_external_data_format:u,model_file_name:d,session_options:f},_=m.includes(`tokenizer.json`),v=m.includes(`preprocessor_config.json`),y=p.model,b;if(Array.isArray(y)){let n=r??await Pm.from_pretrained(t,g),{model_type:i}=n,a=y.find(e=>e.supports(i));if(!a)throw Error(`Unsupported model type "${i}" for task "${e}". None of the candidate model classes support this type.`);b=a.from_pretrained(t,{...g,config:n})}else b=y.from_pretrained(t,g);let[x,ee,S]=await Promise.all([_?G.from_pretrained(t,g):null,v?Om.from_pretrained(t,g):null,b]),te={task:e,model:S};x&&(te.tokenizer=x),ee&&(te.processor=ee),ri(n,{status:`ready`,task:e,model:t});let C=p.pipeline;return new C(te)}var iA=e=>e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,aA=class{put(e){throw Error(`Not implemented`)}end(){throw Error(`Not implemented`)}},oA=j.IS_PROCESS_AVAILABLE?e=>process.stdout.write(e):e=>console.log(e),sA=class extends aA{constructor(e,{skip_prompt:t=!1,callback_function:n=null,token_callback_function:r=null,skip_special_tokens:i=!0,decode_kwargs:a={},...o}={}){super(),this.tokenizer=e,this.skip_prompt=t,this.callback_function=n??oA,this.token_callback_function=r,this.decode_kwargs={skip_special_tokens:i,...a,...o},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 t=this.next_tokens_are_prompt;if(t&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let n=e[0];if(this.token_callback_function?.(n),n.length===1&&this.special_ids.has(n[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(e,!1),this.token_cache=[],this.print_len=0}let e=this.tokenizer.decode(n,this.decode_kwargs);this.on_finalized_text(e,!1);return}this.token_cache=ci(this.token_cache,n);let r=this.tokenizer.decode(this.token_cache,this.decode_kwargs),i;t||r.endsWith(`
|
|
37
|
+
`}):(N.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=t.map(t=>em(t,r,i,$p,e.length)));let o=this.tokenizer(a,n);return{...await this.image_processor(e,n),...o}}},nm=`<|image|>`,rm=/<\|image_\d+\|>/g,im=class extends K{static image_processor_class=jp;static tokenizer_class=G;async _call(e,t=null,{padding:n=!0,truncation:r=!0,num_crops:i=null}={}){Array.isArray(e)||(e=[e]);let a,o;if(t){o=await this.image_processor(t,{num_crops:i});let{num_img_tokens:s}=o,c=e.map((e,t)=>e.split(rm).join(nm.repeat(s[t])));a=this.tokenizer(c,{padding:n,truncation:r});let l=this.tokenizer._tokenizer.token_to_id(nm);a.input_ids.map_(e=>e==l?-e:e)}else a=this.tokenizer(e);return{...a,...o}}},am=class extends K{static tokenizer_class=G;static image_processor_class=jp;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,image_break_token:a,image_end_token:o,patch_size:s,spatial_merge_size:c}=this.config,l=s*c,u=Math.floor(e/l),d=Math.floor(n/l);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;++e){let n=i.repeat(d),r=n+a,s=n+o,c=r.repeat(u-1)+s;t[e]=t[e].replace(i,c)}}let i=t?this.tokenizer(t,n):{};return{...r,...i}}},om=class extends K{static feature_extractor_class=jd;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}},sm=class extends Ip{},cm=class extends sm{},lm=class extends K{static image_processor_class=jp;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)}},um=class extends lm{},dm=class extends um{},fm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},pm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!0;async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){let i=t.length,{input_features:a}=await this.feature_extractor(t,{...n,max_length:i}),o=Math.round(i/this.config.encoder_ds_factor+1e-4),s=1+Math.ceil(o/this.config.stack_factor);r.audio_token_len=[s],r.audio_values=a;let c=this.config.audio_placeholder;if(!e.includes(c))throw Error(`The input text does not contain the image token ${c}.`);e=e.replaceAll(c,c.repeat(s))}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}},mm=`[AUDIO]`,hm=`[BEGIN_AUDIO]`,gm=375;function _m(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,Math.min(r+t,e.length)));return n}var vm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!1;async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){if(!e.includes(mm))throw Error(`The input text does not contain the audio token ${mm}.`);Array.isArray(t)||(t=[t]);let i=e.split(mm),a=i.length-1;if(a!==t.length)throw Error(`The number of audio inputs (${t.length}) does not match the number of audio tokens in the text (${a}).`);let o=this.feature_extractor.config.n_samples,s=t.map(e=>_m(e,o)),c=s.map(e=>e.length),l=s.flat(),u=(await Promise.all(l.map(e=>this.feature_extractor(e,n)))).map(e=>e.input_features);r.audio_values=u.length>1?_l(u,0):u[0];let d=i[0];for(let e=0;e<c.length;++e){d+=hm;for(let t=0;t<c[e];++t)d+=mm.repeat(gm);d+=i[e+1]}e=d}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}},ym=32,bm=6,xm=8,Sm=10,Cm=32,wm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(bm+1)*xm}get num_samples_first_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return(this.num_mel_frames_first_audio_chunk-1)*e+Math.floor(t/2)}get num_samples_per_audio_chunk(){let{hop_length:e,n_fft:t}=this.feature_extractor.config;return xm*e+t}get num_right_pad_tokens(){return bm+1+Sm}get audio_length_per_tok(){return xm}get raw_audio_length_per_tok(){return xm*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:t=!1,is_first_audio_chunk:n=!0}={}){if(Ju(e,`VoxtralRealtimeProcessor`),!t&&!n)throw Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(n)if(t){let t=ym*this.raw_audio_length_per_tok,n=new Float32Array(t+e.length);n.set(e,t);let r=await this.feature_extractor(n,{center:!0}),i=1+(ym+bm),a=new BigInt64Array(i).fill(BigInt(Cm));return a[0]=1n,{input_ids:new U(`int64`,a,[1,i]),...r}}else{let t=this.num_right_pad_tokens*this.raw_audio_length_per_tok,n=new Float32Array(e.length+t);return n.set(e),await this.feature_extractor(n,{center:!0})}else return await this.feature_extractor(e,{center:!1})}},Tm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Em=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Dm=class extends K{static tokenizer_class=G;static feature_extractor_class=zd;async _call(e){return await this.feature_extractor(e)}},Om=class{static async from_pretrained(e,t={}){let n=await rc(e,Uu,!0,t),{image_processor_type:r,feature_extractor_type:i,processor_class:a}=n;if(a&&Ku[a])return Ku[a].from_pretrained(e,t);if(!r&&!i)throw Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let o={};if(r){let e=lf[r.replace(/Fast$/,``)];if(!e)throw Error(`Unknown image_processor_type: '${r}'.`);o.image_processor=new e(n)}if(i){let e=lf[i];if(e)o.image_processor=new e(n);else{let e=Yu[i];if(!e)throw Error(`Unknown feature_extractor_type: '${i}'.`);o.feature_extractor=new e(n)}}return new K({},o,null)}};async function km(e,t){return await rc(e,`config.json`,!0,t)}function Am(e){let t={},n={};switch(e.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`gemma4`:case`lfm2_vl`:case`chatterbox`:case`lighton_ocr`:case`glm_ocr`:case`mistral3`:case`qwen2_5_vl`:case`qwen3_vl`:case`qwen3_vl_moe`:n=Am(e.text_config);break;case`moondream1`:n=Am(e.phi_config);break;case`musicgen`:n=Am(e.decoder);break;case`multi_modality`:n=Am(e.language_config);break;case`gpt2`:case`gptj`:case`jais`:case`codegen`:case`gpt_bigcode`:t.num_heads=`n_head`,t.num_layers=`n_layer`,t.hidden_size=`n_embd`;break;case`gpt_neox`:case`stablelm`:case`opt`:case`falcon`:case`modernbert-decoder`:t.num_heads=`num_attention_heads`,t.num_layers=`num_hidden_layers`,t.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`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.hidden_size=`hidden_size`,t.num_attention_heads=`num_attention_heads`,t.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`gemma4_text`:case`glm`:case`helium`:case`ernie4_5`:case`hunyuan_v1_dense`:case`falcon_h1`:case`nemotron_h`:case`ministral`:case`ministral3`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.dim_kv=`head_dim`;break;case`openelm`:t.num_heads=`num_kv_heads`,t.num_layers=`num_transformer_layers`,t.dim_kv=`head_dim`;break;case`gpt_neo`:case`donut-swin`:t.num_heads=`num_heads`,t.num_layers=`num_layers`,t.hidden_size=`hidden_size`;break;case`bloom`:t.num_heads=`n_head`,t.num_layers=`n_layer`,t.hidden_size=`hidden_size`;break;case`mpt`:t.num_heads=`n_heads`,t.num_layers=`n_layers`,t.hidden_size=`d_model`;break;case`exaone`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_layers`,t.dim_kv=`head_dim`,t.num_attention_heads=`num_attention_heads`;break;case`youtu`:case`deepseek_v3`:case`glm_moe_dsa`:case`mistral4`:t.num_heads=`num_key_value_heads`,t.num_layers=`num_hidden_layers`,t.dim_kv=`qk_head_dim`,t.num_attention_heads=`num_attention_heads`;break;case`t5`:case`mt5`:case`longt5`:t.num_decoder_layers=`num_decoder_layers`,t.num_decoder_heads=`num_heads`,t.decoder_dim_kv=`d_kv`,t.num_encoder_layers=`num_layers`,t.num_encoder_heads=`num_heads`,t.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`:t.num_decoder_layers=`decoder_layers`,t.num_decoder_heads=`decoder_attention_heads`,t.decoder_hidden_size=`d_model`,t.num_encoder_layers=`encoder_layers`,t.num_encoder_heads=`encoder_attention_heads`,t.encoder_hidden_size=`d_model`;break;case`speecht5`:t.num_decoder_layers=`decoder_layers`,t.num_decoder_heads=`decoder_attention_heads`,t.decoder_hidden_size=`hidden_size`,t.num_encoder_layers=`encoder_layers`,t.num_encoder_heads=`encoder_attention_heads`,t.encoder_hidden_size=`hidden_size`;break;case`trocr`:t.num_encoder_layers=t.num_decoder_layers=`decoder_layers`,t.num_encoder_heads=t.num_decoder_heads=`decoder_attention_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`d_model`;break;case`musicgen_decoder`:t.num_encoder_layers=t.num_decoder_layers=`num_hidden_layers`,t.num_encoder_heads=t.num_decoder_heads=`num_attention_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`hidden_size`;break;case`moonshine`:t.num_decoder_layers=`decoder_num_hidden_layers`,t.num_decoder_heads=`decoder_num_key_value_heads`,t.num_encoder_layers=`encoder_num_hidden_layers`,t.num_encoder_heads=`encoder_num_key_value_heads`,t.encoder_hidden_size=t.decoder_hidden_size=`hidden_size`;break;case`cohere_asr`:t.num_decoder_layers=`num_hidden_layers`,t.num_decoder_heads=`num_key_value_heads`,t.decoder_hidden_size=`hidden_size`,t.decoder_dim_kv=`head_dim`;let{num_hidden_layers:r,num_attention_heads:i,hidden_size:a}=e.encoder_config;n={num_encoder_layers:r,num_encoder_heads:i,encoder_hidden_size:a,encoder_dim_kv:e.head_dim};break;case`vision-encoder-decoder`:let o=Am(e.decoder),s=`num_decoder_layers`in o,c=di(e,[`model_type`,`is_encoder_decoder`]);return s?(c.num_decoder_layers=o.num_decoder_layers,c.num_decoder_heads=o.num_decoder_heads,c.decoder_hidden_size=o.decoder_hidden_size,c.num_encoder_layers=o.num_encoder_layers,c.num_encoder_heads=o.num_encoder_heads,c.encoder_hidden_size=o.encoder_hidden_size):(c.num_layers=o.num_layers,c.num_heads=o.num_heads,c.hidden_size=o.hidden_size),c}let r={...n,...di(e,[`model_type`,`multi_query`,`is_encoder_decoder`])};for(let n in t)r[n]=e[t[n]];return r}function jm(e,t){e instanceof Nm||(e=new Nm(e));let n=t?.prefix??`past_key_values`,r=n===`present`?`present`:`past`,i=new Set;if([`lfm2`,`lfm2_moe`].includes(e.model_type)){let{layer_types:t}=e;for(let e=0;e<t.length;++e)if(t[e]===`full_attention`)i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`);else if(t[e]===`conv`)i.add(`${r}_conv.${e}`);else throw Error(`Unsupported layer type: ${t[e]}`);return i}else if([`granitemoehybrid`,`falcon_h1`,`nemotron_h`].includes(e.model_type)){let t=e,a=t.layer_types??t.layers_block_type,o=t.num_hidden_layers??a?.length;for(let e=0;e<o;++e)(!a||a[e]===`mamba`)&&(i.add(`${r}_conv.${e}`),i.add(`${r}_ssm.${e}`)),(!a||a[e]===`attention`)&&(i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`));return i}else if([`qwen3_next`,`qwen3_5_text`,`qwen3_5_moe_text`,`olmo_hybrid`].includes(e.model_type)){let{layer_types:t}=e;for(let a=0;a<t.length;++a)if(t[a]===`full_attention`)i.add(`${n}.${a}.key`),i.add(`${n}.${a}.value`);else if(t[a]===`linear_attention`)e.model_type===`olmo_hybrid`?(i.add(`${r}_conv.${a}.key`),i.add(`${r}_conv.${a}.value`),i.add(`${r}_conv.${a}.query`)):i.add(`${r}_conv.${a}`),i.add(`${r}_recurrent.${a}`);else throw Error(`Unsupported layer type: ${t[a]}`);return i}else if([`gemma4`,`gemma4_text`].includes(e.model_type)){let t=e.model_type===`gemma4`?e.text_config:e,r=t.num_hidden_layers-(t.num_kv_shared_layers??0);for(let e=0;e<r;++e)i.add(`${n}.${e}.key`),i.add(`${n}.${e}.value`);return i}else if([`lfm2_vl`,`qwen3_5`,`qwen3_5_moe`,`voxtral_realtime`].includes(e.model_type)){let n;return n=e.model_type===`voxtral_realtime`&&t?.session_name===`audio_encoder`?e.audio_config:e.text_config,jm(n,t)}return Mm(e,{prefix:n})}function Mm(e,{prefix:t=`past_key_values`}={}){let n=new Set,r=e.normalized_config;if(r.is_encoder_decoder&&`num_encoder_heads`in r&&`num_decoder_heads`in r)for(let e=0;e<r.num_decoder_layers;++e)n.add(`${t}.${e}.encoder.key`),n.add(`${t}.${e}.encoder.value`),n.add(`${t}.${e}.decoder.key`),n.add(`${t}.${e}.decoder.value`);else if(r.multi_query)for(let e=0;e<r.num_layers;++e)n.add(`${t}.${e}.key_value`);else for(let e=0;e<r.num_layers;++e)n.add(`${t}.${e}.key`),n.add(`${t}.${e}.value`);return n}var Nm=class e{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=Am(this)}static async from_pretrained(t,{progress_callback:n=null,config:r=null,cache_dir:i=null,local_files_only:a=!1,revision:o=`main`}={}){r&&!(r instanceof e)&&(r=new e(r));let s=r??await km(t,{progress_callback:n,config:r,cache_dir:i,local_files_only:a,revision:o});return new this(s)}},Pm=class{static async from_pretrained(...e){return Nm.from_pretrained(...e)}};function Fm(e,t,n){return e?typeof e==`object`&&e?e.hasOwnProperty(t)?+e[t]:e.hasOwnProperty(n)?+e[n]:0:+e:0}function Im(e,t){let n=[];for(let r=0;r<t;++r)n.push(`${e}_data${r===0?``:`_`+r}`);return n}async function Lm(e,t,n,r){let i=`${t}${r}.onnx`;return await tc(e,`${n.subfolder??``}/${i}`,!0,n,j.IS_NODE_ENV)}async function Rm(e,t,n,r,i,a={}){let o=`${t}${n}.onnx`,s=j.IS_NODE_ENV,c=[],l=Fm(i,o,t);if(l>0){if(l>Os)throw Error(`The number of external data chunks (${l}) exceeds the maximum allowed value (${Os}).`);let t=Im(o,l);for(let n of t){let t=`${r.subfolder??``}/${n}`;c.push(new Promise(async(i,a)=>{let o=await tc(e,t,!0,r,s);i(o instanceof Uint8Array?{path:n,data:o}:n)}))}}else a.externalData!==void 0&&(c=a.externalData.map(async t=>{if(typeof t.data==`string`){let n=await tc(e,t.data,!0,r);return{...t,data:n}}return t}));return Promise.all(c)}async function zm(e,t,n,r=!1,i=void 0){let a=n.config?.[`transformers.js_config`]??{},o=Yc(n.device??a.device,t,{warn:e=>N.info(e)}),s=Fc(o),c=a.device_config??{};c.hasOwnProperty(o)&&(a={...a,...c[o]});let l=tl(n.dtype??a.dtype,t,o,{configDtype:a.dtype,warn:e=>N.info(e)});if(!el.hasOwnProperty(l))throw Error(`Invalid dtype: ${l}. Should be one of: ${Object.keys(Zc).join(`, `)}`);if(o===`webgpu`&&!j.IS_NODE_ENV&&l===Zc.fp16&&!await Xc())throw Error(`The device (${o}) does not support fp16.`);let u=el[l],d={...n.session_options};d.executionProviders??=s;let f=a.free_dimension_overrides;f?d.freeDimensionOverrides??=f:o.startsWith(`webnn`)&&!d.freeDimensionOverrides&&N.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"]["${o}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let p=Lm(e,t,n,u),m=await Rm(e,t,u,n,n.use_external_data_format??a.use_external_data_format,d);if(m.length>0&&(!j.IS_NODE_ENV||m.some(e=>typeof e!=`string`))&&(d.externalData=m),r&&o===`webgpu`){let e=jm(n.config,{prefix:`present`,session_name:i});if(e.size>0&&!Wc()){let t={};for(let n of e)t[n]=`gpu-buffer`;d.preferredOutputLocation=t}}return{buffer_or_path:await p,session_options:d,session_config:{dtype:l,device:o}}}async function Bm(e,t,n,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async i=>{let a=r?.[i]??!1,{buffer_or_path:o,session_options:s,session_config:c}=await zm(e,t[i],n,a,i);return[i,await zc(o,s,c)]})))}function Vm(e){for(let t in e)Hc(e[t])?e[t]=new U(e[t]):typeof e[t]==`object`&&Vm(e[t]);return e}async function J(e,t){let n=Hm(e,t);try{return Vm(await Vc(e,Object.fromEntries(Object.entries(n).map(([e,t])=>{let n=t.ort_tensor;return j.IS_NODE_ENV&&typeof Float16Array<`u`&&n.cpuData instanceof Float16Array&&(n.cpuData=new Uint16Array(n.cpuData.buffer)),[e,n]}))))}catch(e){let t=Object.fromEntries(Object.entries(n).map(([e,t])=>{let n={type:t.type,dims:t.dims,location:t.location};return n.location!==`gpu-buffer`&&(n.data=t.data),[e,n]}));throw N.error(`An error occurred during model execution: "${e}".`),N.error(`Inputs given to model:`,t),e}}function Hm(e,t){let n=Object.create(null),r=[];for(let i of e.inputNames){let e=t[i];if(!(e instanceof U)){r.push(i);continue}n[i]=Wc()?e.clone():e}if(r.length>0)throw Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(`, `)}.`);let i=Object.keys(t).length,a=e.inputNames.length;if(i>a){let n=Object.keys(t).filter(t=>!e.inputNames.includes(t));N.warn(`WARNING: Too many inputs were provided (${i} > ${a}). The following inputs will be ignored: "${n.join(`, `)}".`)}return n}var Um=class{},Y=class extends Um{constructor({logits:e,...t}){super(),this.logits=e;let n=Object.values(t);n.length>0&&(this.attentions=n)}},Wm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Gm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Km=class extends Um{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},qm=class extends Um{constructor({logits:e}){super(),this.logits=e}},Jm=class extends Um{constructor({alphas:e}){super(),this.alphas=e}},Ym=class extends ni{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Xm=class extends ni{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},Zm=class extends ni{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let n=t;for(let t of this.processors)n=t(e,n);return n}[Symbol.iterator](){return this.processors.values()}},Qm=class extends Ym{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===1){let e=t[n].data;e.fill(-1/0),e[this.bos_token_id]=0}return t}},$m=class extends Ym{constructor(e,t){super(),this.max_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===this.max_length-1){let e=t[n].data;e.fill(-1/0);for(let t of this.eos_token_id)e[t]=0}return t}},eh=class extends Ym{constructor(e){super(),this.suppress_tokens=e}_call(e,t){for(let n=0;n<e.length;++n){let e=t[n].data;for(let t of this.suppress_tokens)e[t]=-1/0}return t}},th=class extends Ym{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length===this.begin_index){let e=t[n].data;for(let t of this.begin_suppress_tokens)e[t]=-1/0}return t}},nh=class extends Ym{constructor(e,t){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=t.length,t.at(-1)===this.no_timestamps_token_id&&--this.begin_index,this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data;if(r[this.no_timestamps_token_id]=-1/0,e[n].length===this.begin_index){r.subarray(0,this.timestamp_begin).fill(-1/0);continue}let i=e[n].slice(this.begin_index),a=i.length>=1&&i[i.length-1]>=this.timestamp_begin,o=i.length<2||i[i.length-2]>=this.timestamp_begin;if(a&&(o?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e[n].length===this.begin_index&&this.max_initial_timestamp_index!==null){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let s=sc(r);Math.log(s.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>fc(s.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},rh=class extends Ym{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,n=[];for(let r=0;r<t+1-this.no_repeat_ngram_size;++r){let t=[];for(let n=0;n<this.no_repeat_ngram_size;++n)t.push(e[r+n]);n.push(t.map(Number))}let r=new Map;for(let e of n){let t=e.slice(0,e.length-1),n=JSON.stringify(t),i=r.get(n)??[];i.push(e[e.length-1]),r.set(n,i)}return r}getGeneratedNgrams(e,t){let n=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(n.map(Number)))??[]}calcBannedNgramTokens(e){let t=[];if(e.length+1<this.no_repeat_ngram_size)return t;{let t=this.getNgrams(e);return this.getGeneratedNgrams(t,e)}}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data,i=this.calcBannedNgramTokens(e[n]);for(let e of i)r[e]=-1/0}return t}},ih=class extends Ym{constructor(e){super(),this.penalty=e}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data;for(let t of new Set(e[n])){let e=Number(t);r[e]<0?r[e]*=this.penalty:r[e]/=this.penalty}}return t}},ah=class extends Ym{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length<this.min_length){let e=t[n].data;for(let t of this.eos_token_id)e[t]=-1/0}return t}},oh=class extends Ym{constructor(e,t,n){super(),this.prompt_length_to_skip=e,this.min_new_tokens=t,this.eos_token_id=Array.isArray(n)?n:[n]}_call(e,t){for(let n=0;n<e.length;++n)if(e[n].length-this.prompt_length_to_skip<this.min_new_tokens){let e=t[n].data;for(let t of this.eos_token_id)e[t]=-1/0}return t}},sh=class extends Ym{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let n=0;n<e.length;++n){let r=t[n].data,i=e[n];for(let e of this.bad_words_ids){if(i.length<e.length-1)continue;let t=!0;for(let n=1;n<=e.length-1;++n)if(e.at(-n-1)!=i.at(-n)){t=!1;break}t&&(r[e.at(-1)]=-1/0)}}return t}},ch=class extends Ym{constructor(e){if(super(),e<=1)throw Error(`Require guidance scale >1 to use the classifier free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw 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 ${t.dims[0]} for the logits and ${e.length} for the input ids.`);let n=e.length,r=t.slice([0,n],null),i=t.slice([n,t.dims[0]],null);for(let e=0;e<i.data.length;++e)i.data[e]+=(r.data[e]-i.data[e])*this.guidance_scale;return i}},lh=class extends Xm{constructor(e){if(super(),typeof e!=`number`||e<=0){let t=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(t+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,t){let n=t.data;for(let e=0;e<n.length;++e)n[e]/=this.temperature;return t}},uh=class extends Xm{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:n=1}={}){if(super(),e<0||e>1)throw Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(n)||n<1)throw Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${n}`);this.top_p=e,this.filter_value=t,this.min_tokens_to_keep=n}},dh=class extends Xm{constructor(e,{filter_value:t=-1/0,min_tokens_to_keep:n=1}={}){if(super(),!Number.isInteger(e)||e<0)throw Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,n),this.filter_value=t}},fh=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,di(e,Object.getOwnPropertyNames(this)))}},ph=class extends ni{_call(e,t){throw Error(`StoppingCriteria needs to be subclassed`)}},mh=class e extends ni{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(t){t instanceof e?t=t.criteria:t instanceof ph&&(t=[t]),this.criteria.push(...t)}_call(e,t){let n=Array(e.length).fill(!1);for(let r of this.criteria){let i=r(e,t);for(let e=0;e<n.length;++e)n[e]||=i[e]}return n}[Symbol.iterator](){return this.criteria.values()}},hh=class extends ph{constructor(e,t=null){super(),this.max_length=e,this.max_position_embeddings=t}_call(e){return e.map(e=>e.length>=this.max_length)}},gh=class extends ph{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(e=>{let t=e.at(-1);return this.eos_token_id.some(e=>t==e)})}},_h=class extends ph{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,t){return Array(e.length).fill(this.interrupted)}},vh=class extends ni{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,t){let n=e.dims.at(-1),r=e.data;if(t===-1)r=r.slice(-n);else{let e=t*n;r=r.slice(e,e+n)}return r}randomSelect(e){return ws(e)}static getSampler(e){if(e.do_sample)return new bh(e);if(e.num_beams>1)return new xh(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 yh(e)}},yh=class extends vh{async sample(e){let t=fc(e.data)[1];return[[BigInt(t),0]]}},bh=class extends vh{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await ll(e,t),i=oc(n.data);return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(i);return[r.data[e],Math.log(i[e])]})}},xh=class extends vh{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await ll(e,t),i=oc(n.data);return Array.from({length:this.generation_config.num_beams},(e,t)=>[r.data[t],Math.log(i[t])])}},Sh=class{constructor(e){if(e)for(let t in e){if(t in this)throw TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);let n=e[t];if(!(n instanceof U))throw TypeError(`Expected a Tensor for key "${t}", got ${typeof n}`);this[t]=n}}get_seq_length(){let e=this;if(Object.keys(e).length===0)return 0;for(let t in e)if(t.startsWith(`past_key_values.`))return e[t].dims.at(-2);throw Error(`Unable to determine sequence length from the cache.`)}update(e){for(let t in e){let n=this[t],r=e[t];n&&n!==r&&n.location===`gpu-buffer`&&n.dispose(),this[t]=r}}async dispose(){let e=[];for(let t of Object.values(this))t.location===`gpu-buffer`&&e.push(t.dispose());await Promise.all(e)}},X={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},Ch={[X.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??`model`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[X.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??`model`})},[X.Seq2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.Vision2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.Musicgen]:{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`}},[X.EncoderDecoder]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0}},[X.MaskGeneration]:{sessions:()=>({model:`vision_encoder`,prompt_encoder_mask_decoder:`prompt_encoder_mask_decoder`})},[X.ImageTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.ImageTextToText].text_only_sessions};return n||(r.vision_encoder=`vision_encoder`),e.is_encoder_decoder&&(r.model=`encoder_model`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.AudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.AudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[X.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.ImageAudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`,r.vision_encoder=`vision_encoder`),r},optional_configs:{generation_config:`generation_config.json`}},[X.Phi3V]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`model`,vision_encoder:`vision_encoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[X.MultiModality]:{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`}},[X.AutoEncoder]:{sessions:()=>({encoder_model:`encoder_model`,decoder_model:`decoder_model`})},[X.Supertonic]:{sessions:()=>({text_encoder:`text_encoder`,latent_denoiser:`latent_denoiser`,voice_decoder:`voice_decoder`})},[X.Chatterbox]:{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`}},[X.VoxtralRealtime]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Ch[X.VoxtralRealtime].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:`generation_config.json`}},default:{sessions:(e,t)=>({model:t.model_file_name??`model`})}};function wh(e){return Ch[e]?.text_only_sessions??null}function Th(e,t,n={}){let r=Ch[e]??Ch.default;return{sessions:r.sessions(t,n,n.textOnly??!1),cache_sessions:r.cache_sessions,optional_configs:r.optional_configs}}function Eh(e,{warn:t=!0}={}){let n=e.architectures||[];for(let e of n){let t=Fh.get(e);if(t!==void 0)return t}if(e.model_type){let t=Fh.get(e.model_type);if(t!==void 0)return t;for(let t of Object.values(kh))if(t.has(e.model_type)){let n=Fh.get(t.get(e.model_type));if(n!==void 0)return n}}if(t){let t=n.length>0?n.join(`, `):`(none)`;N.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${t}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${Vu}`)}return X.EncoderOnly}function Dh(e,{config:t=null,cache_dir:n=null,local_files_only:r=!1,revision:i=`main`}={}){return t===null?Ws(JSON.stringify([e,n,r,i]),()=>Pm.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})):Pm.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})}async function Oh(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null}={}){t=await Dh(e,{config:t});let a=[`config.json`],o=t[`transformers.js_config`]??{},s=o.use_external_data_format,c=`onnx`,l=r??o.device,u=n??o.dtype,d=Eh(t),f=(e,t=null)=>{t??=e;let n=Yc(l,e),r=el[tl(u,e,n)]??``,i=`${t}${r}.onnx`,o=`${c}/${i}`;a.push(o);let d=Fm(s,i,e);for(let e of Im(i,d)){let t=`${c}/${e}`;a.push(t)}},{sessions:p,optional_configs:m}=Th(d,t,{model_file_name:i});for(let[e,t]of Object.entries(p))f(e,t);if(m)for(let e of Object.values(m))a.push(e);return a}var kh=null;function Ah(e){kh=e}function jh(e){if(e instanceof U)return e;if(e.length===0)throw Error(`items must be non-empty`);if(Array.isArray(e[0])){if(e.some(t=>t.length!==e[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 U(`int64`,BigInt64Array.from(e.flat().map(e=>BigInt(e))),[e.length,e[0].length])}else return new U(`int64`,BigInt64Array.from(e.map(e=>BigInt(e))),[1,e.length])}function Mh(e){return new U(`bool`,[e],[1])}var Nh={[X.DecoderOnly]:{can_generate:!0,forward:Gh,prepare_inputs:Zh},[X.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Gh,prepare_inputs:Zh},[X.Seq2Seq]:{can_generate:!0,forward:Rh,prepare_inputs:Qh},[X.Vision2Seq]:{can_generate:!0,forward:Rh,prepare_inputs:Qh},[X.Musicgen]:{can_generate:!0,forward:Rh},[X.EncoderDecoder]:{can_generate:!1,forward:Rh},[X.ImageTextToText]:{can_generate:!0,forward:Jh,prepare_inputs:$h},[X.AudioTextToText]:{can_generate:!0,forward:qh,prepare_inputs:$h},[X.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:$h},[X.Phi3V]:{can_generate:!0,prepare_inputs:$h},[X.MultiModality]:{can_generate:!0},[X.AutoEncoder]:{can_generate:!1,forward:Bh},[X.Chatterbox]:{can_generate:!0,forward:zh},[X.VoxtralRealtime]:{can_generate:!0,prepare_inputs:Zh},default:{can_generate:!1,forward:zh}};function Ph(e,t){let n=Fh.get(e),r=!1,i=t?.architectures?.[0];if(i&&i!==e&&e?.endsWith(`ForCausalLM`)&&i.endsWith(`ForConditionalGeneration`)){let e=Fh.get(i);e!==void 0&&(n=e,r=!0)}let a=Nh[n]??Nh.default,o=Ch[n]??Ch.default;return{typeConfig:{...a,...o},textOnly:r,modelType:n}}var Fh=new Map,Ih=new Map,Lh=new Map,Z=class extends ni{main_input_name=`input_ids`;forward_params=[`input_ids`,`attention_mask`];_return_dict_in_generate_keys=null;constructor(e,t,n){super(),this.config=e,this.sessions=t,this.configs=n;let{typeConfig:r}=Ph(Lh.get(this.constructor),e);this.can_generate=r.can_generate,this._forward=r.forward,this._prepare_inputs_for_generation=r.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 t of Object.values(this.sessions))e.push(t.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d},p=Lh.get(this);n=f.config=await Pm.from_pretrained(e,f);let{typeConfig:m,textOnly:h,modelType:g}=Ph(p,n);if(g===void 0){let e=p??n?.model_type;e!==`custom`&&N.warn(`Model type for '${e}' not found, assuming encoder-only architecture. Please report this at ${Vu}.`)}if(t&&!(t instanceof ii)){let r={};try{let t=await Oh(e,{config:n,dtype:l,device:c,model_file_name:o});(await Promise.all(t.map(t=>Ks(e,t,f)))).forEach((e,n)=>{if(e.exists){let i=t[n]===`config.json`;r[t[n]]={loaded:i?e.size??0:0,total:e.size??0}}})}catch(e){N.warn(`Unable to fetch model file metadata for total progress tracking: ${e}`)}Object.keys(r).length>0&&(f.progress_callback=new ii(t,r))}let _=[Bm(e,m.sessions(n,f,h),f,m.cache_sessions)];m.optional_configs&&_.push(rg(e,m.optional_configs,f));let v=await Promise.all(_);return new this(n,...v)}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,t,n=null){let r=new Zm;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&r.push(new ih(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&r.push(new rh(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&r.push(new sh(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&r.push(new ah(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&r.push(new oh(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&r.push(new Qm(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&r.push(new $m(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&r.push(new eh(e.suppress_tokens)),e.begin_suppress_tokens!==null){let n=t>1||e.forced_bos_token_id===null?t:t+1;r.push(new th(e.begin_suppress_tokens,n))}return e.guidance_scale!==null&&e.guidance_scale>1&&r.push(new ch(e.guidance_scale)),e.temperature===0&&e.do_sample&&(N.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&&r.push(new lh(e.temperature)),n!==null&&r.extend(n),r}_prepare_generation_config(e,t,n=fh){let r={...this.config};for(let e of[`decoder`,`generator`,`text_config`])e in r&&Object.assign(r,r[e]);let i=new n(r);return Object.assign(i,this.generation_config??{}),e&&Object.assign(i,e),t&&Object.assign(i,di(t,Object.getOwnPropertyNames(i))),i}_get_stopping_criteria(e,t=null){let n=new mh;return e.max_length!==null&&n.push(new hh(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&n.push(new gh(e.eos_token_id)),t&&n.extend(t),n}_validate_model_class(){if(!this.can_generate){let e=[kh.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,kh.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,kh.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,kh.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=Lh.get(this.constructor),n=new Set,r=this.config.model_type;for(let t of e){let e=t?.get(r);e&&n.add(e)}let i=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw n.size>0&&(i+=` Please use the following class instead: ${[...n].join(`, `)}`),Error(i)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw 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:t,model_inputs:n,is_encoder_decoder:r}){return n.past_key_values=Vh(t,n.past_key_values),n.input_ids=new U(`int64`,e.flat(),[e.length,1]),r?`decoder_attention_mask`in n&&(n.decoder_attention_mask=_l([n.decoder_attention_mask,El([n.decoder_attention_mask.dims[0],1])],1)):n.attention_mask=_l([n.attention_mask,El([n.attention_mask.dims[0],1])],1),n.position_ids=null,n}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:n}){let r=di(n,this.forward_params),i=this.main_input_name;if(i in r){if(e)throw Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else r[i]=e;return{inputs_tensor:r[i],model_inputs:r,model_input_name:i}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:n,generation_config:r}){if(this.sessions.model.inputNames.includes(`inputs_embeds`)&&!t.inputs_embeds&&`_prepare_inputs_embeds`in this){let{input_ids:e,pixel_values:n,attention_mask:r,...i}=t,a=await this._prepare_inputs_embeds(t);t={...i,...di(a,[`inputs_embeds`,`attention_mask`])}}let{last_hidden_state:i}=await zh(this,t);if(r.guidance_scale!==null&&r.guidance_scale>1)i=_l([i,Tl(i,0)],0),`attention_mask`in t&&(t.attention_mask=_l([t.attention_mask,kl(t.attention_mask)],0));else if(t.decoder_input_ids){let e=jh(t.decoder_input_ids).dims[0];if(e!==i.dims[0]){if(i.dims[0]!==1)throw Error(`The encoder outputs have a different batch size (${i.dims[0]}) than the decoder inputs (${e}).`);i=_l(Array.from({length:e},()=>i),0)}}return t.encoder_outputs=i,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:n,decoder_start_token_id:r,bos_token_id:i,generation_config:a}){let{decoder_input_ids:o,...s}=n;if(!(o instanceof U)){if(o)Array.isArray(o[0])||(o=Array.from({length:e},()=>o));else if(r??=i,this.config.model_type===`musicgen`)o=Array.from({length:e*this.config.decoder.num_codebooks},()=>[r]);else if(Array.isArray(r)){if(r.length!==e)throw Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${r.length}`);o=r}else o=Array.from({length:e},()=>[r]);o=jh(o)}return s.decoder_attention_mask=Dl(o),{input_ids:o,model_inputs:s}}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,streamer:i=null,...a}){this._validate_model_class(),t=this._prepare_generation_config(t,a);let{inputs_tensor:o,model_inputs:s,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),l=this.config.is_encoder_decoder;l&&(`encoder_outputs`in s||(s=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:o,model_inputs:s,model_input_name:c,generation_config:t})));let u;l?{input_ids:u,model_inputs:s}=this._prepare_decoder_input_ids_for_generation({batch_size:s[c].dims.at(0),model_input_name:c,model_kwargs:s,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):u=s[c];let d=u.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=d+t.max_new_tokens);let f=this._get_logits_processor(t,d,n),p=this._get_stopping_criteria(t,r),m=s[c].dims.at(0),h=vh.getSampler(t),g=Array(m).fill(0),_=u.tolist();i&&i.put(_);let v,y={},b={};for(;;){if(s=this.prepare_inputs_for_generation(_,s,t),v=await this.forward(s),t.return_dict_in_generate)if(t.output_attentions){let e=Hh(v);for(let t in e)t in y||(y[t]=[]),y[t].push(e[t])}else this._return_dict_in_generate_keys&&Object.assign(b,di(v,this._return_dict_in_generate_keys));let e=f(_,v.logits.slice(null,-1,null).to(`float32`)),n=[];for(let t=0;t<e.dims.at(0);++t){let r=e[t],i=await h(r);for(let[e,r]of i){let i=BigInt(e);g[t]+=r,_[t].push(i),n.push([i]);break}}if(i&&i.put(n),p(_).every(e=>e))break;s=this._update_model_kwargs_for_generation({generated_input_ids:n,outputs:v,model_inputs:s,is_encoder_decoder:l})}i&&i.end();let x=new U(`int64`,_.flat(),[_.length,_[0].length]),ee=Vh(v,s.past_key_values),S=new Set(Object.values(ee));for(let e of Object.values(v))e.location===`gpu-buffer`&&!S.has(e)&&e.dispose();return`past_key_values`in a||t.return_dict_in_generate||await ee.dispose(),t.return_dict_in_generate?{sequences:x,past_key_values:ee,...y,...b}:x}async _encode_input(e,t,n){if(!Object.hasOwn(this.sessions,e))throw Error(`Model does not have a ${e} session.`);let r=this.sessions[e];return(await J(r,di(t,r.inputNames)))[n]}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 Rh(e,t){let{encoder_outputs:n,input_ids:r,decoder_input_ids:i,decoder_attention_mask:a,...o}=t;return n||=(await zh(e,di(t,e.sessions.model.inputNames))).last_hidden_state,o.input_ids=i,o.encoder_hidden_states=n,e.sessions.decoder_model_merged.inputNames.includes(`encoder_attention_mask`)&&(o.encoder_attention_mask=t.attention_mask),a&&!o.attention_mask&&(o.attention_mask=a),await Gh(e,o,!0)}async function zh(e,t){let n=e.sessions.model,r=di(t,n.inputNames);if(n.inputNames.includes(`inputs_embeds`)&&!r.inputs_embeds){if(!t.input_ids)throw Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(n.inputNames.includes(`token_type_ids`)&&!r.token_type_ids){if(!r.input_ids)throw Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=kl(r.input_ids)}if(n.inputNames.includes(`pixel_mask`)&&!r.pixel_mask){if(!r.pixel_values)throw Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let e=r.pixel_values.dims;r.pixel_mask=El([e[0],e[2],e[3]])}return await J(n,r)}async function Bh(e,t){let n=await e.encode(t);return await e.decode(n)}function Vh(e,t){let n=Object.create(null);for(let r in e)if(r.startsWith(`present`)){let i=r.replace(`present_ssm`,`past_ssm`).replace(`present_conv`,`past_conv`).replace(`present_recurrent`,`past_recurrent`).replace(`present`,`past_key_values`);r.includes(`encoder`)&&t?n[i]=t[i]:n[i]=e[r]}return t?(t.update(n),t):new Sh(n)}function Hh(e){let t={};for(let n of[`cross_attentions`,`encoder_attentions`,`decoder_attentions`])for(let r in e)r.startsWith(n)&&(n in t||(t[n]=[]),t[n].push(e[r]));return t}function Uh(e,t){return e.map(e=>typeof e==`number`?e:t[e]??0)}function Wh(e,t,n){if(n&&Object.keys(n).length>0)return Object.assign(t,n),n;let r=e.sessions.decoder_model_merged??e.sessions.model,i=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,a=jm(e.config),o=e.config?.normalized_config?.num_heads,s={batch_size:i};typeof o==`number`&&(s[`batch_size x num_heads`]=i*o);let c=Object.create(null);for(let e of r.inputMetadata){if(!a.has(e.name))continue;let n=Uh(e.shape,s),r=n.reduce((e,t)=>e*t,1),i=nl[e.type],o=new U(e.type,new i(r),n);t[e.name]=o,c[e.name]=o}return n?(n.update(c),n):new Sh(c)}async function Gh(e,t,n=!1){let r=e.sessions[n?`decoder_model_merged`:`model`],{past_key_values:i,...a}=t;return r.inputNames.includes(`use_cache_branch`)&&(a.use_cache_branch=Mh(i!=null&&Object.keys(i).length>0)),r.inputNames.includes(`position_ids`)&&a.attention_mask&&!a.position_ids&&(a.position_ids=Xh(a,i,+!![`paligemma`,`gemma3_text`,`gemma3`].includes(e.config.model_type))),r.inputNames.includes(`num_logits_to_keep`)&&!a.num_logits_to_keep&&(a.num_logits_to_keep=new U(`int64`,[0n],[])),Wh(e,a,i),await J(r,di(a,r.inputNames))}async function Kh(e,{encode_function:t,merge_function:n,modality_input_names:r,modality_output_name:i,input_ids:a=null,attention_mask:o=null,position_ids:s=null,inputs_embeds:c=null,past_key_values:l=null,generation_config:u=null,logits_processor:d=null,...f}){if(!c){c=await e.encode_text({input_ids:a,...f});let s=di(f,r);if(Object.keys(s).length>0){if(a.dims[1]!==1){let e=await t({...s,...f});({inputs_embeds:c,attention_mask:o}=n({[i]:e,inputs_embeds:c,input_ids:a,attention_mask:o}))}else if(l&&a.dims[1]===1){let e=a.dims[1],t=l.get_seq_length();o=_l([El([a.dims[0],t]),o.slice(null,[o.dims[1]-e,o.dims[1]])],1)}}}if(!s&&[`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(e.config.model_type)){let{image_grid_thw:t,video_grid_thw:n}=f;[s]=e.get_rope_index(a,t,n,o)}return await Gh(e,{inputs_embeds:c,past_key_values:l,attention_mask:o,position_ids:s,generation_config:u,logits_processor:d},!0)}async function qh(e,t){return await Kh(e,{...t,modality_input_names:[`audio_values`,`input_features`],modality_output_name:`audio_features`,encode_function:e.encode_audio.bind(e),merge_function:e._merge_input_ids_with_audio_features.bind(e)})}async function Jh(e,t){return await Kh(e,{...t,modality_input_names:[`pixel_values`],modality_output_name:`image_features`,encode_function:e.encode_image.bind(e),merge_function:e._merge_input_ids_with_image_features.bind(e)})}function Yh(e,t=0){let[n,r]=e.dims,i=e.data,a=new BigInt64Array(i.length);for(let e=0;e<n;++e){let n=e*r,o=BigInt(t);for(let e=0;e<r;++e){let t=n+e;i[t]===0n?a[t]=BigInt(1):(a[t]=o,o+=i[t])}}return{data:a,dims:e.dims}}function Xh(e,t=null,n=0){let{input_ids:r,inputs_embeds:i,attention_mask:a}=e,{data:o,dims:s}=Yh(a,n),c=new U(`int64`,o,s);if(t){let e=-(r??i).dims.at(1);c=c.slice(null,[e,null])}return c}function Zh(e,t,n,r){let i=n.past_key_values?n.past_key_values.get_seq_length():0;if((e.sessions.decoder_model_merged??e.sessions.model)?.inputNames.includes(`num_logits_to_keep`)&&!n.num_logits_to_keep&&(n.num_logits_to_keep=new U(`int64`,[1n],[])),!n.attention_mask){let e;for(let t of[`input_ids`,`inputs_embeds`,`position_ids`])if(n[t]){e=n[t].dims;break}if(!e)throw Error(`attention_mask is not provided, and unable to infer its shape from model inputs.`);n.attention_mask=El([e[0],i+e[1]])}if(n.past_key_values){let{input_ids:e,attention_mask:t}=n;t&&t.dims[1]>e.dims[1]||i<e.dims[1]&&(n.input_ids=e.slice(null,[i,null]))}return n}function Qh(e,t,n,r){return n.past_key_values&&(t=t.map(e=>[e.at(-1)])),{...n,decoder_input_ids:jh(t)}}function $h(e,...t){return e.config.is_encoder_decoder?Qh(e,...t):Zh(e,...t)}function eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i}){let a=r.tolist().map(t=>t.reduce((t,n,r)=>(n==e&&t.push(r),t),[])),o=a.reduce((e,t)=>e+t.length,0),s=n.dims[0];if(o!==s)throw Error(`Number of tokens and features do not match: tokens: ${o}, features ${s}`);let c=0;for(let e=0;e<a.length;++e){let r=a[e],i=t[e];for(let e=0;e<r.length;++e)i[r[e]].data.set(n[c++].data)}return{inputs_embeds:t,attention_mask:i}}function tg({image_token_id:e,inputs_embeds:t,image_features:n,input_ids:r,attention_mask:i}){return eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i})}function ng({audio_token_id:e,inputs_embeds:t,audio_features:n,input_ids:r,attention_mask:i}){return eg({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i})}async function rg(e,t,n){return Object.fromEntries(await Promise.all(Object.keys(t).map(async r=>[r,await rc(e,t[r],!1,n)])))}var ig={};Tr(ig,{ASTForAudioClassification:()=>xg,ASTModel:()=>bg,ASTPreTrainedModel:()=>yg,AfmoeForCausalLM:()=>hg,AfmoeModel:()=>mg,AfmoePreTrainedModel:()=>pg,AlbertForMaskedLM:()=>lg,AlbertForQuestionAnswering:()=>cg,AlbertForSequenceClassification:()=>sg,AlbertModel:()=>og,AlbertPreTrainedModel:()=>ag,ApertusForCausalLM:()=>fg,ApertusModel:()=>dg,ApertusPreTrainedModel:()=>ug,ArceeForCausalLM:()=>vg,ArceeModel:()=>_g,ArceePreTrainedModel:()=>gg,BartForConditionalGeneration:()=>wg,BartForSequenceClassification:()=>Tg,BartModel:()=>Cg,BartPretrainedModel:()=>Sg,BeitForImageClassification:()=>Og,BeitModel:()=>Dg,BeitPreTrainedModel:()=>Eg,BertForMaskedLM:()=>jg,BertForQuestionAnswering:()=>Pg,BertForSequenceClassification:()=>Mg,BertForTokenClassification:()=>Ng,BertModel:()=>Ag,BertPreTrainedModel:()=>kg,BlenderbotForConditionalGeneration:()=>Lg,BlenderbotModel:()=>Ig,BlenderbotPreTrainedModel:()=>Fg,BlenderbotSmallForConditionalGeneration:()=>Bg,BlenderbotSmallModel:()=>zg,BlenderbotSmallPreTrainedModel:()=>Rg,BloomForCausalLM:()=>Ug,BloomModel:()=>Hg,BloomPreTrainedModel:()=>Vg,CHMv2ForDepthEstimation:()=>r_,CHMv2PreTrainedModel:()=>n_,CLIPModel:()=>l_,CLIPPreTrainedModel:()=>c_,CLIPSegForImageSegmentation:()=>g_,CLIPSegModel:()=>h_,CLIPSegPreTrainedModel:()=>m_,CLIPTextModel:()=>u_,CLIPTextModelWithProjection:()=>d_,CLIPVisionModel:()=>f_,CLIPVisionModelWithProjection:()=>p_,CamembertForMaskedLM:()=>Kg,CamembertForQuestionAnswering:()=>Yg,CamembertForSequenceClassification:()=>qg,CamembertForTokenClassification:()=>Jg,CamembertModel:()=>Gg,CamembertPreTrainedModel:()=>Wg,ChatterboxModel:()=>$g,ChatterboxPreTrainedModel:()=>Qg,ChineseCLIPModel:()=>t_,ChineseCLIPPreTrainedModel:()=>e_,ClapAudioModelWithProjection:()=>s_,ClapModel:()=>a_,ClapPreTrainedModel:()=>i_,ClapTextModelWithProjection:()=>o_,CodeGenForCausalLM:()=>y_,CodeGenModel:()=>v_,CodeGenPreTrainedModel:()=>__,Cohere2ForCausalLM:()=>T_,Cohere2Model:()=>w_,Cohere2PreTrainedModel:()=>C_,CohereAsrForConditionalGeneration:()=>O_,CohereAsrModel:()=>D_,CohereAsrPreTrainedModel:()=>E_,CohereForCausalLM:()=>S_,CohereModel:()=>x_,CoherePreTrainedModel:()=>b_,ConvBertForMaskedLM:()=>j_,ConvBertForQuestionAnswering:()=>P_,ConvBertForSequenceClassification:()=>M_,ConvBertForTokenClassification:()=>N_,ConvBertModel:()=>A_,ConvBertPreTrainedModel:()=>k_,ConvNextForImageClassification:()=>L_,ConvNextModel:()=>I_,ConvNextPreTrainedModel:()=>F_,ConvNextV2ForImageClassification:()=>B_,ConvNextV2Model:()=>z_,ConvNextV2PreTrainedModel:()=>R_,DFineForObjectDetection:()=>q_,DFineModel:()=>K_,DFinePreTrainedModel:()=>G_,DINOv3ConvNextModel:()=>Lv,DINOv3ConvNextPreTrainedModel:()=>Iv,DINOv3ViTModel:()=>zv,DINOv3ViTPreTrainedModel:()=>Rv,DPTForDepthEstimation:()=>Xv,DPTModel:()=>Yv,DPTPreTrainedModel:()=>Jv,DacDecoderModel:()=>$_,DacDecoderOutput:()=>Y_,DacEncoderModel:()=>Q_,DacEncoderOutput:()=>J_,DacModel:()=>Z_,DacPreTrainedModel:()=>X_,DebertaForMaskedLM:()=>nv,DebertaForQuestionAnswering:()=>av,DebertaForSequenceClassification:()=>rv,DebertaForTokenClassification:()=>iv,DebertaModel:()=>tv,DebertaPreTrainedModel:()=>ev,DebertaV2ForMaskedLM:()=>dv,DebertaV2ForQuestionAnswering:()=>mv,DebertaV2ForSequenceClassification:()=>fv,DebertaV2ForTokenClassification:()=>pv,DebertaV2Model:()=>uv,DebertaV2PreTrainedModel:()=>lv,DecisionTransformerModel:()=>gv,DecisionTransformerPreTrainedModel:()=>hv,DeepseekV3ForCausalLM:()=>cv,DeepseekV3Model:()=>sv,DeepseekV3PreTrainedModel:()=>ov,DeiTForImageClassification:()=>yv,DeiTModel:()=>vv,DeiTPreTrainedModel:()=>_v,DepthAnythingForDepthEstimation:()=>xv,DepthAnythingPreTrainedModel:()=>bv,DepthProForDepthEstimation:()=>Cv,DepthProPreTrainedModel:()=>Sv,DetrForObjectDetection:()=>Ev,DetrForSegmentation:()=>Dv,DetrModel:()=>Tv,DetrObjectDetectionOutput:()=>Ov,DetrPreTrainedModel:()=>wv,DetrSegmentationOutput:()=>kv,Dinov2ForImageClassification:()=>Mv,Dinov2Model:()=>jv,Dinov2PreTrainedModel:()=>Av,Dinov2WithRegistersForImageClassification:()=>Fv,Dinov2WithRegistersModel:()=>Pv,Dinov2WithRegistersPreTrainedModel:()=>Nv,DistilBertForMaskedLM:()=>Gv,DistilBertForQuestionAnswering:()=>Wv,DistilBertForSequenceClassification:()=>Hv,DistilBertForTokenClassification:()=>Uv,DistilBertModel:()=>Vv,DistilBertPreTrainedModel:()=>Bv,DonutSwinModel:()=>qv,DonutSwinPreTrainedModel:()=>Kv,EdgeTamModel:()=>DT,EfficientNetForImageClassification:()=>$v,EfficientNetModel:()=>Qv,EfficientNetPreTrainedModel:()=>Zv,ElectraForMaskedLM:()=>ny,ElectraForQuestionAnswering:()=>ay,ElectraForSequenceClassification:()=>ry,ElectraForTokenClassification:()=>iy,ElectraModel:()=>ty,ElectraPreTrainedModel:()=>ey,Ernie4_5ForCausalLM:()=>cy,Ernie4_5Model:()=>sy,Ernie4_5PretrainedModel:()=>oy,EsmForMaskedLM:()=>dy,EsmForSequenceClassification:()=>fy,EsmForTokenClassification:()=>py,EsmModel:()=>uy,EsmPreTrainedModel:()=>ly,EuroBertForMaskedLM:()=>gy,EuroBertForSequenceClassification:()=>_y,EuroBertForTokenClassification:()=>vy,EuroBertModel:()=>hy,EuroBertPreTrainedModel:()=>my,ExaoneForCausalLM:()=>xy,ExaoneModel:()=>by,ExaonePreTrainedModel:()=>yy,FalconForCausalLM:()=>wy,FalconH1ForCausalLM:()=>Dy,FalconH1Model:()=>Ey,FalconH1PreTrainedModel:()=>Ty,FalconModel:()=>Cy,FalconPreTrainedModel:()=>Sy,FastViTForImageClassification:()=>Ay,FastViTModel:()=>ky,FastViTPreTrainedModel:()=>Oy,Florence2ForConditionalGeneration:()=>My,Florence2PreTrainedModel:()=>jy,GLPNForDepthEstimation:()=>fb,GLPNModel:()=>db,GLPNPreTrainedModel:()=>ub,GPT2LMHeadModel:()=>Db,GPT2Model:()=>Eb,GPT2PreTrainedModel:()=>Tb,GPTBigCodeForCausalLM:()=>hb,GPTBigCodeModel:()=>mb,GPTBigCodePreTrainedModel:()=>pb,GPTJForCausalLM:()=>Ab,GPTJModel:()=>kb,GPTJPreTrainedModel:()=>Ob,GPTNeoForCausalLM:()=>vb,GPTNeoModel:()=>_b,GPTNeoPreTrainedModel:()=>gb,GPTNeoXForCausalLM:()=>xb,GPTNeoXModel:()=>bb,GPTNeoXPreTrainedModel:()=>yb,Gemma2ForCausalLM:()=>Ry,Gemma2Model:()=>Ly,Gemma2PreTrainedModel:()=>Iy,Gemma3ForCausalLM:()=>Ky,Gemma3ForConditionalGeneration:()=>Gy,Gemma3Model:()=>Wy,Gemma3PreTrainedModel:()=>Uy,Gemma3nForCausalLM:()=>Yy,Gemma3nForConditionalGeneration:()=>Jy,Gemma3nPreTrainedModel:()=>qy,Gemma4ForCausalLM:()=>Zy,Gemma4ForConditionalGeneration:()=>Xy,GemmaForCausalLM:()=>Fy,GemmaModel:()=>Py,GemmaPreTrainedModel:()=>Ny,GlmForCausalLM:()=>eb,GlmModel:()=>$y,GlmMoeDsaForCausalLM:()=>rb,GlmMoeDsaModel:()=>nb,GlmMoeDsaPreTrainedModel:()=>tb,GlmOcrForConditionalGeneration:()=>lb,GlmPreTrainedModel:()=>Qy,GptOssForCausalLM:()=>wb,GptOssModel:()=>Cb,GptOssPreTrainedModel:()=>Sb,GraniteForCausalLM:()=>Nb,GraniteModel:()=>Mb,GraniteMoeHybridForCausalLM:()=>Ib,GraniteMoeHybridModel:()=>Fb,GraniteMoeHybridPreTrainedModel:()=>Pb,GranitePreTrainedModel:()=>jb,GraniteSpeechForConditionalGeneration:()=>zb,GroundingDinoForObjectDetection:()=>Vb,GroundingDinoPreTrainedModel:()=>Bb,GroupViTModel:()=>Ub,GroupViTPreTrainedModel:()=>Hb,HeliumForCausalLM:()=>Kb,HeliumModel:()=>Gb,HeliumPreTrainedModel:()=>Wb,HieraForImageClassification:()=>Yb,HieraModel:()=>Jb,HieraPreTrainedModel:()=>qb,HubertForCTC:()=>rx,HubertForSequenceClassification:()=>ix,HubertModel:()=>nx,HubertPreTrainedModel:()=>tx,HunYuanDenseV1ForCausalLM:()=>sx,HunYuanDenseV1Model:()=>ox,HunYuanDenseV1PreTrainedModel:()=>ax,IJepaForImageClassification:()=>dx,IJepaModel:()=>ux,IJepaPreTrainedModel:()=>lx,Idefics3ForConditionalGeneration:()=>cx,JAISLMHeadModel:()=>mx,JAISModel:()=>px,JAISPreTrainedModel:()=>fx,JinaCLIPModel:()=>gx,JinaCLIPPreTrainedModel:()=>hx,JinaCLIPTextModel:()=>_x,JinaCLIPVisionModel:()=>vx,Lfm2ForCausalLM:()=>xx,Lfm2Model:()=>bx,Lfm2MoeForCausalLM:()=>Tx,Lfm2MoeModel:()=>wx,Lfm2MoePreTrainedModel:()=>Cx,Lfm2PreTrainedModel:()=>yx,Lfm2VlForConditionalGeneration:()=>Ex,LightOnOcrForConditionalGeneration:()=>Sx,LiteWhisperForConditionalGeneration:()=>ID,Llama4ForCausalLM:()=>jx,Llama4PreTrainedModel:()=>Ax,LlamaForCausalLM:()=>kx,LlamaModel:()=>Ox,LlamaPreTrainedModel:()=>Dx,LlavaForConditionalGeneration:()=>By,LlavaOnevisionForConditionalGeneration:()=>By,LlavaPreTrainedModel:()=>zy,LlavaQwen2ForCausalLM:()=>Hy,LongT5ForConditionalGeneration:()=>Px,LongT5Model:()=>Nx,LongT5PreTrainedModel:()=>Mx,M2M100ForConditionalGeneration:()=>Lx,M2M100Model:()=>Ix,M2M100PreTrainedModel:()=>Fx,MBartForCausalLM:()=>Jx,MBartForConditionalGeneration:()=>Kx,MBartForSequenceClassification:()=>qx,MBartModel:()=>Gx,MBartPreTrainedModel:()=>Wx,MPNetForMaskedLM:()=>rC,MPNetForQuestionAnswering:()=>oC,MPNetForSequenceClassification:()=>iC,MPNetForTokenClassification:()=>aC,MPNetModel:()=>nC,MPNetPreTrainedModel:()=>tC,MT5ForConditionalGeneration:()=>fC,MT5Model:()=>dC,MT5PreTrainedModel:()=>uC,MarianMTModel:()=>Bx,MarianModel:()=>zx,MarianPreTrainedModel:()=>Rx,MaskFormerForInstanceSegmentation:()=>Ux,MaskFormerModel:()=>Hx,MaskFormerPreTrainedModel:()=>Vx,Metric3DForDepthEstimation:()=>Xx,Metric3DPreTrainedModel:()=>Yx,Metric3Dv2ForDepthEstimation:()=>Qx,Metric3Dv2PreTrainedModel:()=>Zx,MgpstrForSceneTextRecognition:()=>tS,MgpstrModelOutput:()=>$x,MgpstrPreTrainedModel:()=>eS,MimiDecoderModel:()=>sS,MimiDecoderOutput:()=>rS,MimiEncoderModel:()=>oS,MimiEncoderOutput:()=>nS,MimiModel:()=>aS,MimiPreTrainedModel:()=>iS,Mistral4ForCausalLM:()=>pS,Mistral4Model:()=>fS,Mistral4PreTrainedModel:()=>dS,MistralForCausalLM:()=>uS,MistralModel:()=>lS,MistralPreTrainedModel:()=>cS,MobileBertForMaskedLM:()=>gS,MobileBertForQuestionAnswering:()=>vS,MobileBertForSequenceClassification:()=>_S,MobileBertModel:()=>hS,MobileBertPreTrainedModel:()=>mS,MobileLLMForCausalLM:()=>xS,MobileLLMModel:()=>bS,MobileLLMPreTrainedModel:()=>yS,MobileNetV1ForImageClassification:()=>wS,MobileNetV1ForSemanticSegmentation:()=>TS,MobileNetV1Model:()=>CS,MobileNetV1PreTrainedModel:()=>SS,MobileNetV2ForImageClassification:()=>OS,MobileNetV2ForSemanticSegmentation:()=>kS,MobileNetV2Model:()=>DS,MobileNetV2PreTrainedModel:()=>ES,MobileNetV3ForImageClassification:()=>MS,MobileNetV3ForSemanticSegmentation:()=>NS,MobileNetV3Model:()=>jS,MobileNetV3PreTrainedModel:()=>AS,MobileNetV4ForImageClassification:()=>IS,MobileNetV4ForSemanticSegmentation:()=>LS,MobileNetV4Model:()=>FS,MobileNetV4PreTrainedModel:()=>PS,MobileViTForImageClassification:()=>BS,MobileViTModel:()=>zS,MobileViTPreTrainedModel:()=>RS,MobileViTV2ForImageClassification:()=>US,MobileViTV2Model:()=>HS,MobileViTV2PreTrainedModel:()=>VS,ModernBertDecoderForCausalLM:()=>ZS,ModernBertDecoderModel:()=>XS,ModernBertDecoderPreTrainedModel:()=>YS,ModernBertForMaskedLM:()=>KS,ModernBertForSequenceClassification:()=>qS,ModernBertForTokenClassification:()=>JS,ModernBertModel:()=>GS,ModernBertPreTrainedModel:()=>WS,Moondream1ForConditionalGeneration:()=>Vy,MoonshineForConditionalGeneration:()=>eC,MoonshineModel:()=>$S,MoonshinePreTrainedModel:()=>QS,MptForCausalLM:()=>lC,MptModel:()=>cC,MptPreTrainedModel:()=>sC,MultiModalityCausalLM:()=>mC,MultiModalityPreTrainedModel:()=>pC,MusicgenForCausalLM:()=>_C,MusicgenForConditionalGeneration:()=>vC,MusicgenModel:()=>gC,MusicgenPreTrainedModel:()=>hC,NanoChatForCausalLM:()=>xC,NanoChatModel:()=>bC,NanoChatPreTrainedModel:()=>yC,NemotronHForCausalLM:()=>wC,NemotronHModel:()=>CC,NemotronHPreTrainedModel:()=>SC,NeoBertForMaskedLM:()=>DC,NeoBertForQuestionAnswering:()=>AC,NeoBertForSequenceClassification:()=>OC,NeoBertForTokenClassification:()=>kC,NeoBertModel:()=>EC,NeoBertPreTrainedModel:()=>TC,NomicBertModel:()=>MC,NomicBertPreTrainedModel:()=>jC,OPTForCausalLM:()=>$C,OPTModel:()=>QC,OPTPreTrainedModel:()=>ZC,Olmo2ForCausalLM:()=>RC,Olmo2Model:()=>LC,Olmo2PreTrainedModel:()=>IC,Olmo3ForCausalLM:()=>VC,Olmo3Model:()=>BC,Olmo3PreTrainedModel:()=>zC,OlmoForCausalLM:()=>FC,OlmoHybridForCausalLM:()=>WC,OlmoHybridModel:()=>UC,OlmoHybridPreTrainedModel:()=>HC,OlmoModel:()=>PC,OlmoPreTrainedModel:()=>NC,OpenAIPrivacyFilterForTokenClassification:()=>qC,OpenAIPrivacyFilterModel:()=>KC,OpenAIPrivacyFilterPreTrainedModel:()=>GC,OpenELMForCausalLM:()=>XC,OpenELMModel:()=>YC,OpenELMPreTrainedModel:()=>JC,OwlViTForObjectDetection:()=>aw,OwlViTModel:()=>iw,OwlViTPreTrainedModel:()=>rw,Owlv2ForObjectDetection:()=>nw,Owlv2Model:()=>tw,Owlv2PreTrainedModel:()=>ew,PaliGemmaForConditionalGeneration:()=>ow,ParakeetForCTC:()=>cw,ParakeetPreTrainedModel:()=>sw,PatchTSMixerForPrediction:()=>dw,PatchTSMixerModel:()=>uw,PatchTSMixerPreTrainedModel:()=>lw,PatchTSTForPrediction:()=>mw,PatchTSTModel:()=>pw,PatchTSTPreTrainedModel:()=>fw,Phi3ForCausalLM:()=>bw,Phi3Model:()=>yw,Phi3PreTrainedModel:()=>vw,Phi3VForCausalLM:()=>Sw,Phi3VPreTrainedModel:()=>xw,PhiForCausalLM:()=>_w,PhiModel:()=>gw,PhiPreTrainedModel:()=>hw,PreTrainedModel:()=>Z,PvtForImageClassification:()=>Tw,PvtModel:()=>ww,PvtPreTrainedModel:()=>Cw,PyAnnoteForAudioFrameClassification:()=>Ow,PyAnnoteModel:()=>Dw,PyAnnotePreTrainedModel:()=>Ew,Qwen2ForCausalLM:()=>jw,Qwen2Model:()=>Aw,Qwen2MoeForCausalLM:()=>Pw,Qwen2MoeModel:()=>Nw,Qwen2MoePreTrainedModel:()=>Mw,Qwen2PreTrainedModel:()=>kw,Qwen2VLForCausalLM:()=>ob,Qwen2VLForConditionalGeneration:()=>ab,Qwen2VLPreTrainedModel:()=>ib,Qwen2_5_VLForCausalLM:()=>cb,Qwen2_5_VLForConditionalGeneration:()=>sb,Qwen3ForCausalLM:()=>Lw,Qwen3Model:()=>Iw,Qwen3MoeForCausalLM:()=>Bw,Qwen3MoeModel:()=>zw,Qwen3MoePreTrainedModel:()=>Rw,Qwen3NextForCausalLM:()=>Uw,Qwen3NextModel:()=>Hw,Qwen3NextPreTrainedModel:()=>Vw,Qwen3PreTrainedModel:()=>Fw,Qwen3VLForCausalLM:()=>Gw,Qwen3VLForConditionalGeneration:()=>Ww,Qwen3VLMoeForCausalLM:()=>qw,Qwen3VLMoeForConditionalGeneration:()=>Kw,Qwen3_5ForCausalLM:()=>Yw,Qwen3_5ForConditionalGeneration:()=>Jw,Qwen3_5MoeForCausalLM:()=>Zw,Qwen3_5MoeForConditionalGeneration:()=>Xw,RFDetrForObjectDetection:()=>rT,RFDetrModel:()=>nT,RFDetrObjectDetectionOutput:()=>iT,RFDetrPreTrainedModel:()=>tT,RTDetrForObjectDetection:()=>U_,RTDetrModel:()=>H_,RTDetrObjectDetectionOutput:()=>W_,RTDetrPreTrainedModel:()=>V_,RTDetrV2ForObjectDetection:()=>yT,RTDetrV2Model:()=>vT,RTDetrV2ObjectDetectionOutput:()=>bT,RTDetrV2PreTrainedModel:()=>_T,ResNetForImageClassification:()=>eT,ResNetModel:()=>$w,ResNetPreTrainedModel:()=>Qw,RoFormerForMaskedLM:()=>pT,RoFormerForQuestionAnswering:()=>gT,RoFormerForSequenceClassification:()=>mT,RoFormerForTokenClassification:()=>hT,RoFormerModel:()=>fT,RoFormerPreTrainedModel:()=>dT,RobertaForMaskedLM:()=>sT,RobertaForQuestionAnswering:()=>uT,RobertaForSequenceClassification:()=>cT,RobertaForTokenClassification:()=>lT,RobertaModel:()=>oT,RobertaPreTrainedModel:()=>aT,Sam2ImageSegmentationOutput:()=>wT,Sam2Model:()=>ET,Sam2PreTrainedModel:()=>TT,Sam3TrackerModel:()=>OT,SamImageSegmentationOutput:()=>xT,SamModel:()=>CT,SamPreTrainedModel:()=>ST,SapiensForDepthEstimation:()=>jT,SapiensForNormalEstimation:()=>MT,SapiensForSemanticSegmentation:()=>AT,SapiensPreTrainedModel:()=>kT,SegformerForImageClassification:()=>FT,SegformerForSemanticSegmentation:()=>IT,SegformerModel:()=>PT,SegformerPreTrainedModel:()=>NT,SiglipModel:()=>RT,SiglipPreTrainedModel:()=>LT,SiglipTextModel:()=>zT,SiglipVisionModel:()=>BT,SmolLM3ForCausalLM:()=>UT,SmolLM3Model:()=>HT,SmolLM3PreTrainedModel:()=>VT,SmolVLMForConditionalGeneration:()=>WT,SnacDecoderModel:()=>JT,SnacEncoderModel:()=>qT,SnacModel:()=>KT,SnacPreTrainedModel:()=>GT,SolarOpenForCausalLM:()=>ZT,SolarOpenModel:()=>XT,SolarOpenPreTrainedModel:()=>YT,SpeechT5ForSpeechToText:()=>eE,SpeechT5ForTextToSpeech:()=>tE,SpeechT5HifiGan:()=>nE,SpeechT5Model:()=>$T,SpeechT5PreTrainedModel:()=>QT,SqueezeBertForMaskedLM:()=>aE,SqueezeBertForQuestionAnswering:()=>sE,SqueezeBertForSequenceClassification:()=>oE,SqueezeBertModel:()=>iE,SqueezeBertPreTrainedModel:()=>rE,StableLmForCausalLM:()=>uE,StableLmModel:()=>lE,StableLmPreTrainedModel:()=>cE,Starcoder2ForCausalLM:()=>pE,Starcoder2Model:()=>fE,Starcoder2PreTrainedModel:()=>dE,StyleTextToSpeech2Model:()=>hE,StyleTextToSpeech2PreTrainedModel:()=>mE,SupertonicForConditionalGeneration:()=>_E,SupertonicPreTrainedModel:()=>gE,Swin2SRForImageSuperResolution:()=>wE,Swin2SRModel:()=>CE,Swin2SRPreTrainedModel:()=>SE,SwinForImageClassification:()=>bE,SwinForSemanticSegmentation:()=>xE,SwinModel:()=>yE,SwinPreTrainedModel:()=>vE,T5ForConditionalGeneration:()=>DE,T5Model:()=>EE,T5PreTrainedModel:()=>TE,TableTransformerForObjectDetection:()=>AE,TableTransformerModel:()=>kE,TableTransformerObjectDetectionOutput:()=>jE,TableTransformerPreTrainedModel:()=>OE,TrOCRForCausalLM:()=>NE,TrOCRPreTrainedModel:()=>ME,UltravoxModel:()=>Rb,UltravoxPreTrainedModel:()=>Lb,UniSpeechForCTC:()=>IE,UniSpeechForSequenceClassification:()=>LE,UniSpeechModel:()=>FE,UniSpeechPreTrainedModel:()=>PE,UniSpeechSatForAudioFrameClassification:()=>HE,UniSpeechSatForCTC:()=>BE,UniSpeechSatForSequenceClassification:()=>VE,UniSpeechSatModel:()=>zE,UniSpeechSatPreTrainedModel:()=>RE,VaultGemmaForCausalLM:()=>GE,VaultGemmaModel:()=>WE,VaultGemmaPreTrainedModel:()=>UE,ViTForImageClassification:()=>YE,ViTMAEModel:()=>ZE,ViTMAEPreTrainedModel:()=>XE,ViTMSNForImageClassification:()=>eD,ViTMSNModel:()=>$E,ViTMSNPreTrainedModel:()=>QE,ViTModel:()=>JE,ViTPreTrainedModel:()=>qE,VisionEncoderDecoderModel:()=>KE,VitMatteForImageMatting:()=>nD,VitMattePreTrainedModel:()=>tD,VitPoseForPoseEstimation:()=>iD,VitPosePreTrainedModel:()=>rD,VitsModel:()=>sD,VitsModelOutput:()=>aD,VitsPreTrainedModel:()=>oD,VoxtralForConditionalGeneration:()=>cD,VoxtralRealtimeForConditionalGeneration:()=>vD,VoxtralRealtimePreTrainedModel:()=>_D,Wav2Vec2BertForCTC:()=>xD,Wav2Vec2BertForSequenceClassification:()=>SD,Wav2Vec2BertModel:()=>bD,Wav2Vec2BertPreTrainedModel:()=>yD,Wav2Vec2ForAudioFrameClassification:()=>ex,Wav2Vec2ForCTC:()=>Qb,Wav2Vec2ForSequenceClassification:()=>$b,Wav2Vec2Model:()=>Zb,Wav2Vec2PreTrainedModel:()=>Xb,WavLMForAudioFrameClassification:()=>kD,WavLMForCTC:()=>ED,WavLMForSequenceClassification:()=>DD,WavLMForXVector:()=>OD,WavLMModel:()=>TD,WavLMPreTrainedModel:()=>wD,WeSpeakerResNetModel:()=>jD,WeSpeakerResNetPreTrainedModel:()=>AD,WhisperForConditionalGeneration:()=>FD,WhisperModel:()=>PD,WhisperPreTrainedModel:()=>ND,XLMForQuestionAnswering:()=>HD,XLMForSequenceClassification:()=>BD,XLMForTokenClassification:()=>VD,XLMModel:()=>RD,XLMPreTrainedModel:()=>LD,XLMRobertaForMaskedLM:()=>GD,XLMRobertaForQuestionAnswering:()=>JD,XLMRobertaForSequenceClassification:()=>KD,XLMRobertaForTokenClassification:()=>qD,XLMRobertaModel:()=>WD,XLMRobertaPreTrainedModel:()=>UD,XLMWithLMHeadModel:()=>zD,XVectorOutput:()=>CD,YolosForObjectDetection:()=>ZD,YolosModel:()=>XD,YolosObjectDetectionOutput:()=>QD,YolosPreTrainedModel:()=>YD,YoutuForCausalLM:()=>tO,YoutuModel:()=>eO,YoutuPreTrainedModel:()=>$D});var ag=class extends Z{},og=class extends ag{},sg=class extends ag{async _call(e){return new Y(await super._call(e))}},cg=class extends ag{async _call(e){return new Km(await super._call(e))}},lg=class extends ag{async _call(e){return new Gm(await super._call(e))}},ug=class extends Z{},dg=class extends ug{},fg=class extends ug{},pg=class extends Z{},mg=class extends pg{},hg=class extends pg{},gg=class extends Z{},_g=class extends gg{},vg=class extends gg{},yg=class extends Z{},bg=class extends yg{},xg=class extends yg{},Sg=class extends Z{},Cg=class extends Sg{},wg=class extends Sg{},Tg=class extends Sg{async _call(e){return new Y(await super._call(e))}},Eg=class extends Z{},Dg=class extends Eg{},Og=class extends Eg{async _call(e){return new Y(await super._call(e))}},kg=class extends Z{},Ag=class extends kg{},jg=class extends kg{async _call(e){return new Gm(await super._call(e))}},Mg=class extends kg{async _call(e){return new Y(await super._call(e))}},Ng=class extends kg{async _call(e){return new Wm(await super._call(e))}},Pg=class extends kg{async _call(e){return new Km(await super._call(e))}},Fg=class extends Z{},Ig=class extends Fg{},Lg=class extends Fg{},Rg=class extends Z{},zg=class extends Rg{},Bg=class extends Rg{},Vg=class extends Z{},Hg=class extends Vg{},Ug=class extends Vg{},Wg=class extends Z{},Gg=class extends Wg{},Kg=class extends Wg{async _call(e){return new Gm(await super._call(e))}},qg=class extends Wg{async _call(e){return new Y(await super._call(e))}},Jg=class extends Wg{async _call(e){return new Wm(await super._call(e))}},Yg=class extends Wg{async _call(e){return new Km(await super._call(e))}},Xg=4299n,Zg=6561n,Qg=class extends Z{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`]},$g=class extends Qg{async encode_speech(e){return J(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:n=null,exaggeration:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,audio_features:l=null,audio_tokens:u=null,speaker_embeddings:d=null,speaker_features:f=null,...p}){let m;if(!a){let s=this.sessions.embed_tokens.inputNames,c={input_ids:e};if(s.includes(`exaggeration`)){if(!(r instanceof U)){let t=e.dims[0];if(r==null)r=wl([t],.5);else if(typeof r==`number`)r=wl([t],r);else if(Array.isArray(r))r=new U(`float32`,r,[t]);else throw Error("Unsupported type for `exaggeration` input")}c.exaggeration=r}if(s.includes(`position_ids`)&&(c.position_ids=i),{inputs_embeds:a}=await J(this.sessions.embed_tokens,c),l&&u&&d&&f&&(m={audio_features:l,audio_tokens:u,speaker_embeddings:d,speaker_features:f}),m||n)m??=await this.encode_speech(n),a=_l([m.audio_features,a],1),t=El([a.dims[0],a.dims[1]]);else{let e=a.dims[1];if(!o||e!==1)throw Error(`Incorrect state encountered during generation.`);let n=o.get_seq_length();t=El([a.dims[0],n+e])}}return{...await Gh(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,generation_config:s,logits_processor:c},!1),...m}}prepare_inputs_for_generation(e,t,n){return!t.position_ids&&this.sessions.embed_tokens.inputNames.includes(`position_ids`)&&(t.input_ids.dims[1]===1?t.position_ids=new U(`int64`,Array.from({length:e.length},(t,n)=>e[n].length-e[n].findLastIndex(e=>e==Zg)-1),[e.length,1]):t.position_ids=new U(`int64`,t.input_ids.tolist().map(e=>{let t=0;return e.map(e=>e>=Zg?0:t++)}).flat(),t.input_ids.dims)),t.input_ids.dims[1]===1&&(delete t.audio_values,delete t.audio_features,delete t.audio_tokens,delete t.speaker_embeddings,delete t.speaker_features),Zh(this,e,t,n)}async generate(e){let{sequences:t,audio_tokens:n,speaker_embeddings:r,speaker_features:i}=await super.generate({...e,return_dict_in_generate:!0}),a=t.slice(null,[e.input_ids.dims[1],-1]),o=_l([n,a,wl([a.dims[0],3],Xg)],1),{waveform:s}=await J(this.sessions.conditional_decoder,{speech_tokens:o,speaker_features:i,speaker_embeddings:r});return s}},e_=class extends Z{},t_=class extends e_{},n_=class extends Z{},r_=class extends n_{},i_=class extends Z{},a_=class extends i_{},o_=class extends i_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},s_=class extends i_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`audio_model`})}},c_=class extends Z{},l_=class extends c_{},u_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},d_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},f_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},p_=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},m_=class extends Z{},h_=class extends m_{},g_=class extends m_{},__=class extends Z{},v_=class extends __{},y_=class extends __{},b_=class extends Z{},x_=class extends b_{},S_=class extends b_{},C_=class extends Z{},w_=class extends C_{},T_=class extends C_{},E_=class extends Z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},D_=class extends E_{},O_=class extends E_{},k_=class extends Z{},A_=class extends k_{},j_=class extends k_{async _call(e){return new Gm(await super._call(e))}},M_=class extends k_{async _call(e){return new Y(await super._call(e))}},N_=class extends k_{async _call(e){return new Wm(await super._call(e))}},P_=class extends k_{async _call(e){return new Km(await super._call(e))}},F_=class extends Z{},I_=class extends F_{},L_=class extends F_{async _call(e){return new Y(await super._call(e))}},R_=class extends Z{},z_=class extends R_{},B_=class extends R_{async _call(e){return new Y(await super._call(e))}},V_=class extends Z{},H_=class extends V_{},U_=class extends V_{async _call(e){return new W_(await super._call(e))}},W_=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},G_=class extends Z{},K_=class extends G_{},q_=class extends G_{async _call(e){return new W_(await super._call(e))}},J_=class extends Um{constructor({audio_codes:e}){super(),this.audio_codes=e}},Y_=class extends Um{constructor({audio_values:e}){super(),this.audio_values=e}},X_=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},Z_=class extends X_{async encode(e){return new J_(await J(this.sessions.encoder_model,e))}async decode(e){return new Y_(await J(this.sessions.decoder_model,e))}},Q_=class extends X_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},$_=class extends X_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},ev=class extends Z{},tv=class extends ev{},nv=class extends ev{async _call(e){return new Gm(await super._call(e))}},rv=class extends ev{async _call(e){return new Y(await super._call(e))}},iv=class extends ev{async _call(e){return new Wm(await super._call(e))}},av=class extends ev{async _call(e){return new Km(await super._call(e))}},ov=class extends Z{},sv=class extends ov{},cv=class extends ov{},lv=class extends Z{},uv=class extends lv{},dv=class extends lv{async _call(e){return new Gm(await super._call(e))}},fv=class extends lv{async _call(e){return new Y(await super._call(e))}},pv=class extends lv{async _call(e){return new Wm(await super._call(e))}},mv=class extends lv{async _call(e){return new Km(await super._call(e))}},hv=class extends Z{},gv=class extends hv{},_v=class extends Z{},vv=class extends _v{},yv=class extends _v{async _call(e){return new Y(await super._call(e))}},bv=class extends Z{},xv=class extends bv{},Sv=class extends Z{},Cv=class extends Sv{},wv=class extends Z{},Tv=class extends wv{},Ev=class extends wv{async _call(e){return new Ov(await super._call(e))}},Dv=class extends wv{async _call(e){return new kv(await super._call(e))}},Ov=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},kv=class extends Um{constructor({logits:e,pred_boxes:t,pred_masks:n}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=n}},Av=class extends Z{},jv=class extends Av{},Mv=class extends Av{async _call(e){return new Y(await super._call(e))}},Nv=class extends Z{},Pv=class extends Nv{},Fv=class extends Nv{async _call(e){return new Y(await super._call(e))}},Iv=class extends Z{},Lv=class extends Iv{},Rv=class extends Z{},zv=class extends Rv{},Bv=class extends Z{},Vv=class extends Bv{},Hv=class extends Bv{async _call(e){return new Y(await super._call(e))}},Uv=class extends Bv{async _call(e){return new Wm(await super._call(e))}},Wv=class extends Bv{async _call(e){return new Km(await super._call(e))}},Gv=class extends Bv{async _call(e){return new Gm(await super._call(e))}},Kv=class extends Z{},qv=class extends Kv{},Jv=class extends Z{},Yv=class extends Jv{},Xv=class extends Jv{},Zv=class extends Z{},Qv=class extends Zv{},$v=class extends Zv{async _call(e){return new Y(await super._call(e))}},ey=class extends Z{},ty=class extends ey{},ny=class extends ey{async _call(e){return new Gm(await super._call(e))}},ry=class extends ey{async _call(e){return new Y(await super._call(e))}},iy=class extends ey{async _call(e){return new Wm(await super._call(e))}},ay=class extends ey{async _call(e){return new Km(await super._call(e))}},oy=class extends Z{},sy=class extends oy{},cy=class extends oy{},ly=class extends Z{},uy=class extends ly{},dy=class extends ly{async _call(e){return new Gm(await super._call(e))}},fy=class extends ly{async _call(e){return new Y(await super._call(e))}},py=class extends ly{async _call(e){return new Wm(await super._call(e))}},my=class extends Z{},hy=class extends my{},gy=class extends my{async _call(e){return new Gm(await super._call(e))}},_y=class extends my{async _call(e){return new Y(await super._call(e))}},vy=class extends my{async _call(e){return new Wm(await super._call(e))}},yy=class extends Z{},by=class extends yy{},xy=class extends yy{},Sy=class extends Z{},Cy=class extends Sy{},wy=class extends Sy{},Ty=class extends Z{},Ey=class extends Ty{},Dy=class extends Ty{},Oy=class extends Z{},ky=class extends Oy{},Ay=class extends Oy{async _call(e){return new Y(await super._call(e))}},jy=class extends Z{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`},My=class extends jy{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:n,attention_mask:r}){return{inputs_embeds:_l([t,e],1),attention_mask:_l([El(t.dims.slice(0,2)),r],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:n,attention_mask:r}){if(!e&&!t)throw Error("Either `input_ids` or `pixel_values` should be provided.");let i,a;return e&&(i=await this.encode_text({input_ids:e})),t&&(a=await this.encode_image({pixel_values:t})),i&&a?{inputs_embeds:n,attention_mask:r}=this._merge_input_ids_with_image_features({inputs_embeds:i,image_features:a,input_ids:e,attention_mask:r}):n=i||a,{inputs_embeds:n,attention_mask:r}}async forward({input_ids:e,pixel_values:t,attention_mask:n,decoder_input_ids:r,decoder_attention_mask:i,encoder_outputs:a,past_key_values:o,inputs_embeds:s,decoder_inputs_embeds:c}){if(s||({inputs_embeds:s,attention_mask:n}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:s,attention_mask:n})),!a){let{last_hidden_state:e}=await zh(this,{inputs_embeds:s,attention_mask:n});a=e}if(!c){if(!r)throw Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:r})}let l={inputs_embeds:c,attention_mask:i,encoder_attention_mask:n,encoder_hidden_states:a,past_key_values:o};return await Gh(this,l,!0)}},Ny=class extends Z{},Py=class extends Ny{},Fy=class extends Ny{},Iy=class extends Z{},Ly=class extends Iy{},Ry=class extends Iy{},zy=class extends Z{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`position_ids`,`past_key_values`]},By=class extends zy{_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return tg({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:n})}},Vy=class extends By{},Hy=class extends By{},Uy=class extends Z{},Wy=class extends Uy{},Gy=class extends By{},Ky=class extends Gy{},qy=class extends Z{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`input_features`,`input_features_mask`,`past_key_values`]},Jy=class extends qy{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,input_features:r=null,input_features_mask:i=null,position_ids:a=null,inputs_embeds:o=null,per_layer_inputs:s=null,past_key_values:c=null,generation_config:l=null,logits_processor:u=null,...d}){if((!o||!s)&&({inputs_embeds:o,per_layer_inputs:s}=await J(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(n){let{image_features:r}=await this._encode_vision({pixel_values:n,...d});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:r,inputs_embeds:o,input_ids:e,attention_mask:t}))}if(r){let{audio_features:n}=await J(this.sessions.audio_encoder,{input_features:r,input_features_mask:i});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:n,inputs_embeds:o,input_ids:e,attention_mask:t}))}}return await Gh(this,{inputs_embeds:o,per_layer_inputs:s,past_key_values:c,attention_mask:t,position_ids:a,generation_config:l,logits_processor:u},!0)}_encode_vision(e){return J(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return tg({image_token_id:this.config.image_token_id,...e,image_features:n})}_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return ng({audio_token_id:this.config.audio_token_id,...e,audio_features:n})}},Yy=class extends Jy{},Xy=class extends Jy{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`image_position_ids`,`input_features`,`input_features_mask`,`past_key_values`];_encode_vision(e){return J(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},Zy=class extends Xy{},Qy=class extends Z{},$y=class extends Qy{},eb=class extends Qy{},tb=class extends Z{},nb=class extends tb{},rb=class extends tb{},ib=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`,`pixel_values`,`image_grid_thw`]},ab=class extends ib{image_grid_thw_name=`grid_thw`;_get_text_only_rope_index(e,t){if(t){let{data:e,dims:n}=Yh(t),r=BigInt64Array.from({length:3*e.length},(t,n)=>e[n%e.length]),i=Array.from({length:n[0]},(t,r)=>fc(e.subarray(n[1]*r,n[1]*(r+1)))[0]+1n+BigInt(n[1]));return[new U(`int64`,r,[3,...n]),new U(`int64`,i,[i.length,1])]}else{let[t,n]=e.dims;return[new U(`int64`,BigInt64Array.from({length:3*t*n},(e,r)=>BigInt(Math.floor(r%n/t))),[3,...e.dims]),Ol([t,1])]}}_reorder_and_write_positions(e,t,n,r){let i=e.reduce((e,t)=>e+t.length,0),a=Array(i),o=0;for(let t=0;t<3;++t)for(let n of e){let e=n.length/3;for(let r=t*e;r<(t+1)*e;++r)a[o++]=n[r]}let s=0;for(let e=0;e<t.length;++e)if(t[e]==1){for(let t=0;t<3;++t)n[t][r][e]=a[t*i/3+s];++s}return a}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a,video_token_id:o,vision_start_token_id:s}=this.config,c=e,l=c.reduce((e,t,n)=>(t==s&&e.push(n),e),[]).map(e=>c[e+1]),u=l.filter(e=>e==a).length,d=l.filter(e=>e==o).length,f=[],p=0,m=u,h=d;for(let e=0;e<l.length;++e){let e=c.findIndex((e,t)=>t>p&&e==a),s=c.findIndex((e,t)=>t>p&&e==o),l=m>0&&e!==-1?e:c.length+1,u=h>0&&s!==-1?s:c.length+1,d,g,_,v;l<u?([g,_,v]=t[i.image_index],++i.image_index,--m,d=l):([g,_,v]=n[i.video_index],++i.video_index,--h,d=u);let[y,b,x]=[Number(g),Math.floor(Number(_)/r),Math.floor(Number(v)/r)],ee=d-p,S=f.length>0?fc(f.at(-1))[0]+1:0;f.push(Array.from({length:3*ee},(e,t)=>S+t%ee));let te=ee+S,C=y*b*x,w=Array.from({length:C},(e,t)=>te+Math.floor(t/(b*x))),ne=Array.from({length:C},(e,t)=>te+Math.floor(t/x)%b),re=Array.from({length:C},(e,t)=>te+t%x);f.push([w,ne,re].flat()),p=d+C}if(p<c.length){let e=f.length>0?fc(f.at(-1))[0]+1:0,t=c.length-p;f.push(Array.from({length:3*t},(n,r)=>e+r%t))}return f}get_rope_index(e,t,n,r){let{vision_config:i}=this.config,a=i.spatial_merge_size??2;if(t||n){let i=e.tolist();r||=Dl(e);let o=r.tolist(),s=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),c=t?t.tolist():[],l=n?n.tolist():[],u={image_index:0,video_index:0},d=[];for(let e=0;e<i.length;++e){let t=i[e].filter((t,n)=>o[e][n]==1),n=this._get_multimodal_rope_positions({filtered_ids:t,image_grid_thw_list:c,video_grid_thw_list:l,spatial_merge_size:a,state:u}),r=this._reorder_and_write_positions(n,o[e],s,e);d.push(fc(r)[0]+1-i[e].length)}return[new U(`int64`,s.flat(1/0),[3,e.dims[0],e.dims[1]]),new U(`int64`,d,[d.length,1])]}else return this._get_text_only_rope_index(e,r)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await J(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return tg({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,n){if(!t.attention_mask||t.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes(`position_ids`))return t;if(!t.past_key_values)[t.position_ids,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);else{t.pixel_values=null;let e=t.past_key_values.get_seq_length();if(e<t.input_ids.dims[1]){let[n,r]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);t.rope_deltas=r,t.position_ids=n.slice(null,null,[e,null]),t.input_ids=t.input_ids.slice(null,[e,null])}else{t.rope_deltas||([,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask));let n=BigInt(e),r=t.rope_deltas.map(e=>n+e);t.position_ids=vl([r,r,r],0)}}return t}},ob=class extends ab{},sb=class extends ab{image_grid_thw_name=`image_grid_thw`},cb=class extends ob{image_grid_thw_name=`image_grid_thw`},lb=class extends sb{get_vision_position_ids(e,t,n,r){let i=Math.floor(t[0]/n),a=Math.floor(t[1]/r),o=Math.floor(t[2]/r),s=a*o*i,c=Array.from({length:s},()=>e),l=Array.from({length:s},(t,n)=>e+Math.floor(n/(o*i))),u=Array.from({length:s},(t,n)=>e+n%o);return[...c,...l,...u]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a}=this.config,o=[],s=0,c=+(e[0]==a);for(let t=1;t<=e.length;++t){let n=t<e.length?+(e[t]==a):-1;n!==c&&(o.push([c,s,t]),s=t,c=n)}let l=0,u=[];for(let[e,n,a]of o)if(e===0){let e=a-n;u.push(Array.from({length:3*e},(t,n)=>l+n%e)),l+=e}else{let e=t[i.image_index++].map(Number),n=e[0];u.push(this.get_vision_position_ids(l,e,n,r)),l+=Math.max(e[1],e[2])/r}return u}},ub=class extends Z{},db=class extends ub{},fb=class extends ub{},pb=class extends Z{},mb=class extends pb{},hb=class extends pb{},gb=class extends Z{},_b=class extends gb{},vb=class extends gb{},yb=class extends Z{},bb=class extends yb{},xb=class extends yb{},Sb=class extends Z{},Cb=class extends Sb{},wb=class extends Sb{},Tb=class extends Z{},Eb=class extends Tb{},Db=class extends Tb{},Ob=class extends Z{},kb=class extends Ob{},Ab=class extends Ob{},jb=class extends Z{},Mb=class extends jb{},Nb=class extends jb{},Pb=class extends Z{},Fb=class extends Pb{},Ib=class extends Pb{},Lb=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`audio_values`,`past_key_values`]},Rb=class extends Lb{_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return ng({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:n})}},zb=class extends Rb{forward_params=[`input_ids`,`attention_mask`,`input_features`,`past_key_values`]},Bb=class extends Z{},Vb=class extends Bb{},Hb=class extends Z{},Ub=class extends Hb{},Wb=class extends Z{},Gb=class extends Wb{},Kb=class extends Wb{},qb=class extends Z{},Jb=class extends qb{},Yb=class extends qb{async _call(e){return new Y(await super._call(e))}},Xb=class extends Z{},Zb=class extends Xb{},Qb=class extends Xb{async _call(e){return new qm(await super._call(e))}},$b=class extends Xb{async _call(e){return new Y(await super._call(e))}},ex=class extends Xb{async _call(e){return new Wm(await super._call(e))}},tx=class extends Z{},nx=class extends Xb{},rx=class extends Xb{async _call(e){return new qm(await super._call(e))}},ix=class extends Xb{async _call(e){return new Y(await super._call(e))}},ax=class extends Z{},ox=class extends ax{},sx=class extends ax{},cx=class extends By{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`position_ids`,`past_key_values`]},lx=class extends Z{},ux=class extends lx{},dx=class extends lx{async _call(e){return new Y(await super._call(e))}},fx=class extends Z{},px=class extends fx{},mx=class extends fx{},hx=class extends Z{},gx=class extends hx{async forward(e){let t=!e.input_ids,n=!e.pixel_values;if(t&&n)throw Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=El([e.pixel_values.dims[0],1])),n){let{image_size:t}=this.config.vision_config;e.pixel_values=wl([0,3,t,t],0)}let{text_embeddings:r,image_embeddings:i,l2norm_text_embeddings:a,l2norm_image_embeddings:o}=await super.forward(e),s={};return t||(s.text_embeddings=r,s.l2norm_text_embeddings=a),n||(s.image_embeddings=i,s.l2norm_image_embeddings=o),s}},_x=class extends hx{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},vx=class extends hx{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},yx=class extends Z{},bx=class extends yx{},xx=class extends yx{},Sx=class extends By{},Cx=class extends Z{},wx=class extends Cx{},Tx=class extends Cx{},Ex=class extends By{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`spatial_shapes`,`position_ids`,`past_key_values`]},Dx=class extends Z{},Ox=class extends Dx{},kx=class extends Dx{},Ax=class extends Z{},jx=class extends Ax{},Mx=class extends Z{},Nx=class extends Mx{},Px=class extends Mx{},Fx=class extends Z{},Ix=class extends Fx{},Lx=class extends Fx{},Rx=class extends Z{},zx=class extends Rx{},Bx=class extends Rx{},Vx=class extends Z{},Hx=class extends Vx{},Ux=class extends Vx{},Wx=class extends Z{},Gx=class extends Wx{},Kx=class extends Wx{},qx=class extends Wx{async _call(e){return new Y(await super._call(e))}},Jx=class extends Wx{},Yx=class extends Z{},Xx=class extends Yx{},Zx=class extends Z{},Qx=class extends Zx{},$x=class extends Um{constructor({char_logits:e,bpe_logits:t,wp_logits:n}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=n}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},eS=class extends Z{},tS=class extends eS{async _call(e){return new $x(await super._call(e))}},nS=class extends Um{constructor({audio_codes:e}){super(),this.audio_codes=e}},rS=class extends Um{constructor({audio_values:e}){super(),this.audio_values=e}},iS=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},aS=class extends iS{async encode(e){return new nS(await J(this.sessions.encoder_model,e))}async decode(e){return new rS(await J(this.sessions.decoder_model,e))}},oS=class extends iS{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},sS=class extends iS{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},cS=class extends Z{},lS=class extends cS{},uS=class extends cS{},dS=class extends Z{},fS=class extends dS{},pS=class extends dS{},mS=class extends Z{},hS=class extends mS{},gS=class extends mS{async _call(e){return new Gm(await super._call(e))}},_S=class extends mS{async _call(e){return new Y(await super._call(e))}},vS=class extends mS{async _call(e){return new Km(await super._call(e))}},yS=class extends Z{},bS=class extends yS{},xS=class extends yS{},SS=class extends Z{},CS=class extends SS{},wS=class extends SS{async _call(e){return new Y(await super._call(e))}},TS=class extends SS{},ES=class extends Z{},DS=class extends ES{},OS=class extends ES{async _call(e){return new Y(await super._call(e))}},kS=class extends ES{},AS=class extends Z{},jS=class extends AS{},MS=class extends AS{async _call(e){return new Y(await super._call(e))}},NS=class extends AS{},PS=class extends Z{},FS=class extends PS{},IS=class extends PS{async _call(e){return new Y(await super._call(e))}},LS=class extends PS{},RS=class extends Z{},zS=class extends RS{},BS=class extends RS{async _call(e){return new Y(await super._call(e))}},VS=class extends Z{},HS=class extends VS{},US=class extends VS{async _call(e){return new Y(await super._call(e))}},WS=class extends Z{},GS=class extends WS{},KS=class extends WS{async _call(e){return new Gm(await super._call(e))}},qS=class extends WS{async _call(e){return new Y(await super._call(e))}},JS=class extends WS{async _call(e){return new Wm(await super._call(e))}},YS=class extends Z{},XS=class extends YS{},ZS=class extends YS{},QS=class extends Z{requires_attention_mask=!1;main_input_name=`input_values`;forward_params=[`input_values`,`decoder_input_ids`,`past_key_values`]},$S=class extends QS{},eC=class extends QS{},tC=class extends Z{},nC=class extends tC{},rC=class extends tC{async _call(e){return new Gm(await super._call(e))}},iC=class extends tC{async _call(e){return new Y(await super._call(e))}},aC=class extends tC{async _call(e){return new Wm(await super._call(e))}},oC=class extends tC{async _call(e){return new Km(await super._call(e))}},sC=class extends Z{},cC=class extends sC{},lC=class extends sC{},uC=class extends Z{},dC=class extends uC{},fC=class extends uC{},pC=class extends Z{},mC=class extends pC{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 t=this._generation_mode??`text`,n;if(t===`text`||!e.past_key_values){let t=this.sessions.prepare_inputs_embeds;n=await J(t,di(e,t.inputNames))}else{let t=this.sessions.gen_img_embeds;n=await J(t,di({image_ids:e.input_ids},t.inputNames))}let r={...e,...n},i=await Gh(this,r),a=this.sessions[t===`text`?`lm_head`:`gen_head`];if(!a)throw Error(`Unable to find "${a}" generation head`);let o=await J(a,di(i,a.inputNames));return{...n,...i,...o}}prepare_inputs_for_generation(e,t,n){let r=!!t.past_key_values;return n.guidance_scale!==null&&n.guidance_scale>1&&(r?t.input_ids=_l([t.input_ids,t.input_ids],0):(t.input_ids=_l([t.input_ids,Tl(t.input_ids,BigInt(n.pad_token_id))],0),t.attention_mask=_l([t.attention_mask,Tl(t.attention_mask,0n)],0))),(r||!t.pixel_values)&&(t.pixel_values=wl([0,0,3,384,384],1)),r&&(t.images_seq_mask=new U(`bool`,[,].fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new U(`bool`,[].fill(!1),[1,1,0])),t}async generate(e){return this._generation_mode=`text`,super.generate(e)}async generate_images(e){this._generation_mode=`image`;let t=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[t,null]),r=this.sessions.image_decode,{decoded_image:i}=await J(r,{generated_tokens:n}),a=i.add_(1).mul_(255/2).clamp_(0,255).to(`uint8`),o=[];for(let e of a){let t=Yd.fromTensor(e);o.push(t)}return o}},hC=class extends Z{},gC=class extends hC{},_C=class extends hC{},vC=class extends Z{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[t,n]=e.dims,r=this.config.decoder.num_codebooks,i=n-r,a=0;for(let t=0;t<e.size;++t){if(e.data[t]==this.config.decoder.pad_token_id)continue;let o=t%n-Math.floor(t/n)%r;o>0&&o<=i&&(e.data[a++]=e.data[t])}let o=Math.floor(t/r),s=a/(o*r);return new U(e.type,e.data.slice(0,a),[o,r,s])}prepare_inputs_for_generation(e,t,n){let r=BigInt(this.config.decoder.pad_token_id),i=structuredClone(e);for(let e=0;e<i.length;++e)for(let t=0;t<i[e].length;++t)e%this.config.decoder.num_codebooks>=t&&(i[e][t]=r);return n.guidance_scale!==null&&n.guidance_scale>1&&(i=i.concat(i)),Qh(this,i,t,n)}async generate(e){let t=await super.generate(e),n=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:r}=await J(this.sessions.encodec_decode,{audio_codes:n});return r}},yC=class extends Z{},bC=class extends yC{},xC=class extends yC{},SC=class extends Z{},CC=class extends SC{},wC=class extends SC{},TC=class extends Z{},EC=class extends TC{},DC=class extends TC{async _call(e){return new Gm(await super._call(e))}},OC=class extends TC{async _call(e){return new Y(await super._call(e))}},kC=class extends TC{async _call(e){return new Wm(await super._call(e))}},AC=class extends TC{async _call(e){return new Km(await super._call(e))}},jC=class extends Z{},MC=class extends jC{},NC=class extends Z{},PC=class extends NC{},FC=class extends NC{},IC=class extends Z{},LC=class extends IC{},RC=class extends IC{},zC=class extends Z{},BC=class extends zC{},VC=class extends zC{},HC=class extends Z{},UC=class extends HC{},WC=class extends HC{},GC=class extends Z{},KC=class extends GC{},qC=class extends GC{async _call(e){return new Y(await super._call(e))}},JC=class extends Z{},YC=class extends JC{},XC=class extends JC{},ZC=class extends Z{},QC=class extends ZC{},$C=class extends ZC{},ew=class extends Z{},tw=class extends ew{},nw=class extends ew{},rw=class extends Z{},iw=class extends rw{},aw=class extends rw{},ow=class extends By{},sw=class extends Z{},cw=class extends sw{async _call(e){return new qm(await super._call(e))}},lw=class extends Z{},uw=class extends lw{},dw=class extends lw{},fw=class extends Z{},pw=class extends fw{},mw=class extends fw{},hw=class extends Z{},gw=class extends hw{},_w=class extends hw{},vw=class extends Z{},yw=class extends vw{},bw=class extends vw{},xw=class extends Z{forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`pixel_values`,`image_sizes`,`past_key_values`]},Sw=class extends xw{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,image_sizes:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,...l}){if(!a){let t;if(n&&e.dims[1]!==1){if(!r)throw Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:t}=await J(this.sessions.vision_encoder,{pixel_values:n,image_sizes:r}))}else{let e=this.config.normalized_config.hidden_size;t=new U(`float32`,[],[0,e])}({inputs_embeds:a}=await J(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:t}))}return await Gh(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,position_ids:i,generation_config:s,logits_processor:c},!1)}},Cw=class extends Z{},ww=class extends Cw{},Tw=class extends Cw{async _call(e){return new Y(await super._call(e))}},Ew=class extends Z{},Dw=class extends Ew{},Ow=class extends Ew{async _call(e){return new Wm(await super._call(e))}},kw=class extends Z{},Aw=class extends kw{},jw=class extends kw{},Mw=class extends Z{},Nw=class extends Mw{},Pw=class extends Mw{},Fw=class extends Z{},Iw=class extends Fw{},Lw=class extends Fw{},Rw=class extends Z{},zw=class extends Rw{},Bw=class extends Rw{},Vw=class extends Z{},Hw=class extends Vw{},Uw=class extends Vw{},Ww=class extends sb{},Gw=class extends cb{},Kw=class extends Ww{},qw=class extends Gw{},Jw=class extends Ww{},Yw=class extends Jw{},Xw=class extends Jw{},Zw=class extends Yw{},Qw=class extends Z{},$w=class extends Qw{},eT=class extends Qw{async _call(e){return new Y(await super._call(e))}},tT=class extends Z{},nT=class extends tT{},rT=class extends tT{async _call(e){return new iT(await super._call(e))}},iT=class extends W_{},aT=class extends Z{},oT=class extends aT{},sT=class extends aT{async _call(e){return new Gm(await super._call(e))}},cT=class extends aT{async _call(e){return new Y(await super._call(e))}},lT=class extends aT{async _call(e){return new Wm(await super._call(e))}},uT=class extends aT{async _call(e){return new Km(await super._call(e))}},dT=class extends Z{},fT=class extends dT{},pT=class extends dT{async _call(e){return new Gm(await super._call(e))}},mT=class extends dT{async _call(e){return new Y(await super._call(e))}},hT=class extends dT{async _call(e){return new Wm(await super._call(e))}},gT=class extends dT{async _call(e){return new Km(await super._call(e))}},_T=class extends Z{},vT=class extends _T{},yT=class extends _T{async _call(e){return new bT(await super._call(e))}},bT=class extends W_{},xT=class extends Um{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},ST=class extends Z{},CT=class extends ST{async get_image_embeddings({pixel_values:e}){return await zh(this,{pixel_values:e})}async forward(e){e=!e.image_embeddings||!e.image_positional_embeddings?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_labels??=El(e.input_points.dims.slice(0,-1));let t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await J(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new xT(await super._call(e))}},wT=class extends Um{constructor({iou_scores:e,pred_masks:t,object_score_logits:n}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=n}},TT=class extends Z{},ET=class extends TT{async get_image_embeddings({pixel_values:e}){return await zh(this,{pixel_values:e})}async forward(e){let{num_feature_levels:t}=this.config.vision_config;if(e=Array.from({length:t},(e,t)=>`image_embeddings.${t}`).some(t=>!e[t])?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let t=e.input_points.dims;e.input_labels??=El(t.slice(0,-1)),e.input_boxes??=wl([t[0],0,4],0)}else if(e.input_boxes){let t=e.input_boxes.dims;e.input_labels=wl([t[0],t[1],0],-1n),e.input_points=wl([t[0],1,0,2],0)}else throw Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder;return await J(n,di(e,n.inputNames))}async _call(e){return new wT(await super._call(e))}},DT=class extends ET{},OT=class extends ET{},kT=class extends Z{},AT=class extends kT{},jT=class extends kT{},MT=class extends kT{},NT=class extends Z{},PT=class extends NT{},FT=class extends NT{},IT=class extends NT{},LT=class extends Z{},RT=class extends LT{},zT=class extends LT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},BT=class extends c_{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},VT=class extends Z{},HT=class extends VT{},UT=class extends VT{},WT=class extends cx{},GT=class extends Z{main_input_name=`input_values`;forward_params=[`input_values`]},KT=class extends GT{async encode(e){return await J(this.sessions.encoder_model,e)}async decode(e){return await J(this.sessions.decoder_model,e)}},qT=class extends GT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},JT=class extends GT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},YT=class extends Z{},XT=class extends YT{},ZT=class extends YT{},QT=class extends Z{},$T=class extends QT{},eE=class extends QT{},tE=class extends QT{async generate_speech(e,t,{threshold:n=.5,minlenratio:r=0,maxlenratio:i=20,vocoder:a=null}={}){let o={input_ids:e},{encoder_outputs:s,encoder_attention_mask:c}=await zh(this,o),l=s.dims[1]/this.config.reduction_factor,u=Math.floor(l*i),d=Math.floor(l*r),f=this.config.num_mel_bins,p=[],m=null,h=null,g=0;for(;;){++g;let e=Mh(!!h),r;r=h?h.output_sequence_out:new U(`float32`,new Float32Array(f),[1,1,f]);let i={use_cache_branch:e,output_sequence:r,encoder_attention_mask:c,speaker_embeddings:t,encoder_hidden_states:s};Wh(this,i,m),h=await J(this.sessions.decoder_model_merged,i),m=Vh(h,m);let{prob:a,spectrum:o}=h;if(p.push(o),g>=d&&(Array.from(a.data).filter(e=>e>=n).length>0||g>=u))break}let _=_l(p),{waveform:v}=await J(a.sessions.model,{spectrogram:_});return{spectrogram:_,waveform:v}}},nE=class extends Z{main_input_name=`spectrogram`},rE=class extends Z{},iE=class extends rE{},aE=class extends rE{async _call(e){return new Gm(await super._call(e))}},oE=class extends rE{async _call(e){return new Y(await super._call(e))}},sE=class extends rE{async _call(e){return new Km(await super._call(e))}},cE=class extends Z{},lE=class extends cE{},uE=class extends cE{},dE=class extends Z{},fE=class extends dE{},pE=class extends dE{},mE=class extends Z{},hE=class extends mE{},gE=class extends Z{},_E=class extends gE{async generate_speech({input_ids:e,attention_mask:t,style:n,num_inference_steps:r=5,speed:i=1.05}){let{sampling_rate:a,chunk_compress_factor:o,base_chunk_size:s,latent_dim:c}=this.config,{last_hidden_state:l,durations:u}=await J(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:n}),d=u.div(i).mul_(a),f=s*o,p=d.data,m=Int32Array.from(p,e=>Math.ceil(e/f)),h=Math.max(...m),g=e.dims[0],_=new BigInt64Array(g*h);for(let e=0;e<g;++e)_.fill(1n,e*h,e*h+m[e]);let v=new U(`int64`,_,[g,h]),y=c*o,b=y*h,x=jl([g,y,h]),ee=x.data;for(let e=0;e<g;++e)if(m[e]!==h)for(let t=0;t<y;++t)ee.fill(0,e*b+t*h+m[e],e*b+(t+1)*h);let S=wl([g],r);for(let e=0;e<r;++e){let r=wl([g],e);({denoised_latents:x}=await J(this.sessions.latent_denoiser,{style:n,noisy_latents:x,latent_mask:v,encoder_outputs:l,attention_mask:t,timestep:r,num_inference_steps:S}))}let{waveform:te}=await J(this.sessions.voice_decoder,{latents:x});return{waveform:te,durations:d}}},vE=class extends Z{},yE=class extends vE{},bE=class extends vE{async _call(e){return new Y(await super._call(e))}},xE=class extends vE{},SE=class extends Z{},CE=class extends SE{},wE=class extends SE{},TE=class extends Z{forward_params=[`input_ids`,`attention_mask`,`encoder_outputs`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},EE=class extends TE{},DE=class extends TE{},OE=class extends Z{},kE=class extends OE{},AE=class extends OE{async _call(e){return new jE(await super._call(e))}},jE=class extends Ov{},ME=class extends Z{},NE=class extends ME{},PE=class extends Z{},FE=class extends PE{},IE=class extends PE{async _call(e){return new qm(await super._call(e))}},LE=class extends PE{async _call(e){return new Y(await super._call(e))}},RE=class extends Z{},zE=class extends RE{},BE=class extends RE{async _call(e){return new qm(await super._call(e))}},VE=class extends RE{async _call(e){return new Y(await super._call(e))}},HE=class extends RE{async _call(e){return new Wm(await super._call(e))}},UE=class extends Z{},WE=class extends UE{},GE=class extends UE{},KE=class extends Z{main_input_name=`pixel_values`;forward_params=[`pixel_values`,`decoder_input_ids`,`encoder_hidden_states`,`past_key_values`]},qE=class extends Z{},JE=class extends qE{},YE=class extends qE{async _call(e){return new Y(await super._call(e))}},XE=class extends Z{},ZE=class extends XE{},QE=class extends Z{},$E=class extends QE{},eD=class extends QE{async _call(e){return new Y(await super._call(e))}},tD=class extends Z{},nD=class extends tD{async _call(e){return new Jm(await super._call(e))}},rD=class extends Z{},iD=class extends rD{},aD=class extends Um{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}},oD=class extends Z{},sD=class extends oD{async _call(e){return new aD(await super._call(e))}},cD=class extends Rb{},lD=2,uD=1,dD=new WeakMap;function fD(e,t){let{text_config:n,audio_config:r}=e.config,i=e.sessions.audio_encoder,{num_mel_bins:a,hidden_size:o}=r,s=a+o,c=new Sh,l=jm(r),u={batch_size:1},d=`float32`;for(let e of i.inputMetadata){if(e.name===`past_padding_cache`){d=e.type;continue}if(!l.has(e.name))continue;let t=Uh(e.shape,u),n=t.reduce((e,t)=>e*t,1),r=nl[e.type];c[e.name]=new U(e.type,new r(n),t)}let f=nl[d],p=new U(d,new f(s*lD),[1,s,lD]),m=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!m)throw Error(`input_features must be iterable or async iterable`);return{encoder_session:i,enc_kv_cache:c,enc_padding_cache:p,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:m,text_hidden_size:n.hidden_size}}async function pD(e,t){let n=t.dims[2],r=Math.floor((uD+n-3)/2)+1,i=new U(`int64`,BigInt64Array.from({length:r},(t,n)=>BigInt(e.enc_past_seq_len+n)),[1,r]),a=e.enc_past_seq_len+r,o=El([1,a]),{audio_embeds:s,present_padding_cache:c,...l}=await J(e.encoder_session,{input_features:t,attention_mask:o,position_ids:i,past_padding_cache:e.enc_padding_cache,...e.enc_kv_cache});e.enc_padding_cache.location===`gpu-buffer`&&e.enc_padding_cache.dispose(),e.enc_padding_cache=c;for(let t in l)if(t.startsWith(`present.`)){let n=t.replace(`present`,`past_key_values`),r=e.enc_kv_cache[n];r?.location===`gpu-buffer`&&r.dispose(),e.enc_kv_cache[n]=l[t]}return e.enc_past_seq_len=a,s}async function mD(e,t){for(;e.audio_embed_total_tokens<t&&!e.stream_exhausted;){let t=await e.chunks_iter.next();if(t.done){e.stream_exhausted=!0;break}let n=await pD(e,t.value);e.audio_embed_queue.push({data:n.data,tokens:n.dims[1]}),e.audio_embed_total_tokens+=n.dims[1]}}function hD(e,t,n){if(e.audio_embed_queue.length===0)return;let r=t.data,i=0,a=n;for(;a>0&&e.audio_embed_queue.length>0;){let t=e.audio_embed_queue[0],n=t.tokens-e.audio_queue_offset,o=Math.min(a,n),s=e.audio_queue_offset*e.text_hidden_size;for(let n=0;n<o*e.text_hidden_size;++n)r[i*e.text_hidden_size+n]+=t.data[s+n];i+=o,a-=o,e.audio_queue_offset+=o,e.audio_queue_offset>=t.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=n-a}var gD=class extends ph{constructor(e){super(),this._s=e}_call(e){let t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},_D=class extends Z{forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`]},vD=class extends _D{async forward({input_ids:e,past_key_values:t,...n}){let r=e.dims[1],i=dD.get(this);i&&await mD(i,i.audio_consumed+r);let{inputs_embeds:a}=await J(this.sessions.embed_tokens,{input_ids:e});i&&hD(i,a,r);let o={inputs_embeds:a,...n};Wh(this,o,t);let s=this.sessions.decoder_model_merged;return await J(s,di(o,s.inputNames))}async generate({input_features:e,stopping_criteria:t,...n}){if(!e)throw Error(`input_features (generator/iterable) must be provided`);let r=fD(this,e);dD.set(this,r);let i=new mh;i.push(new gD(r)),t&&i.extend(t);try{return await super.generate({...n,stopping_criteria:i})}finally{r.enc_kv_cache.dispose(),dD.delete(this)}}},yD=class extends Z{},bD=class extends yD{},xD=class extends yD{async _call(e){return new qm(await super._call(e))}},SD=class extends yD{async _call(e){return new Y(await super._call(e))}},CD=class extends Um{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},wD=class extends Z{},TD=class extends wD{},ED=class extends wD{async _call(e){return new qm(await super._call(e))}},DD=class extends wD{async _call(e){return new Y(await super._call(e))}},OD=class extends wD{async _call(e){return new CD(await super._call(e))}},kD=class extends wD{async _call(e){return new Wm(await super._call(e))}},AD=class extends Z{},jD=class extends AD{},MD=class extends fh{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},ND=class extends Z{requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`attention_mask`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},PD=class extends ND{},FD=class extends ND{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,MD)}_retrieve_init_tokens(e){let t=[e.decoder_start_token_id],n=e.language,r=e.task;if(e.is_multilingual){n||=(N.warn(`No language specified - defaulting to English (en).`),`en`);let i=`<|${Fu(n)}|>`;t.push(e.lang_to_id[i]),t.push(e.task_to_id[r??`transcribe`])}else if(n||r)throw 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&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(N.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(e=>e!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,...i}){t=this._prepare_generation_config(t,i);let a=i.decoder_input_ids instanceof U?Fl(i.decoder_input_ids):i.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(n??=new Zm,n.push(new nh(t,a))),t.begin_suppress_tokens&&(n??=new Zm,n.push(new th(t.begin_suppress_tokens,a.length))),t.return_token_timestamps){if(!t.alignment_heads)throw 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.");t.task===`translate`&&N.warn(`Token-level timestamps may not be reliable for task 'translate'.`),t.output_attentions=!0,t.return_dict_in_generate=!0}if(t.return_timestamps&&!i.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:a,kwargs:i});let o=await super.generate({inputs:e,generation_config:t,logits_processor:n,decoder_input_ids:a,...i});return t.return_token_timestamps&&(o.token_timestamps=this._extract_token_timestamps(o,t.alignment_heads,t.num_frames,.02,a.length)),o}async _generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:r,kwargs:i}){let a=t.no_timestamps_token_id+1,o=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,s=t.return_token_timestamps,c=e,l=c.dims[2],u=2*this.config.max_source_positions,d=0,f=[],p=[];for(;d<l;){let e=Math.min(d+u,l),m=c.slice(null,null,[d,e]),h,g=m.dims[2];if(g<u){let e=c.dims[1],t=new Float32Array(e*u),n=m.data;for(let r=0;r<e;++r)t.set(n.subarray(r*g,(r+1)*g),r*u);h=new U(`float32`,t,[1,e,u])}else h=m;if(n)for(let e of n)`begin_index`in e&&(e.begin_index=r.length);let _=await super.generate({inputs:h,generation_config:t,logits_processor:n,decoder_input_ids:r,...i}),v=(s?_.sequences:_)[0].tolist().map(Number).slice(r.length),y;if(s){_.token_timestamps=this._extract_token_timestamps(_,t.alignment_heads,Math.floor((e-d)/2),.02,r.length);let n=d/2*.02;y=_.token_timestamps[0].tolist().slice(r.length).map(e=>e+n)}if(v.length>0&&v.at(-1)===o&&v.pop(),v.length===0)break;let b=v.map(e=>e>=a),x=v.length>=2&&b[v.length-1]&&!b[v.length-2],ee=[];for(let e=0;e<v.length-1;++e)b[e]&&b[e+1]&&ee.push(e+1);let S,te=v.length;if(ee.length>0)if(x)S=e-d;else{let e=ee.at(-1);S=(v[e-1]-a)*2,te=e}else S=e-d;let C=Math.floor(d/2),w=a+1500;for(let e=0;e<te;++e)v[e]>=a&&(v[e]=Math.min(v[e]+C,w));f.push(...v.slice(0,te)),y&&p.push(...y.slice(0,te)),d+=S}f.push(o);let m=[...r,...f];if(s){let e=new U(`int64`,m.map(BigInt),[1,m.length]),t=[...Array(r.length).fill(0),...p,0];return{sequences:e,token_timestamps:new U(`float32`,new Float32Array(t),[1,t.length])}}return new U(`int64`,m.map(BigInt),[1,m.length])}_extract_token_timestamps(e,t,n=null,r=.02,i=0){if(!e.cross_attentions)throw Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");n??N.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 a=this.config.median_filter_width;a===void 0&&(N.warn("Model config has no `median_filter_width`, using default value of 7."),a=7);let o=e.cross_attentions,s=Array.from({length:this.config.decoder_layers},(e,t)=>_l(o.map(e=>e[t]),2)),c=vl(t.map(([e,t])=>{if(e>=s.length)throw Error(`Layer index ${e} is out of bounds for cross attentions (length ${s.length}).`);return n?s[e].slice(null,t,null,[0,n]):s[e].slice(null,t)})).transpose(1,0,2,3),[l,u]=bl(c,-2,0,!0),d=c.clone();for(let e=0;e<d.dims[0];++e){let t=d[e];for(let n=0;n<t.dims[0];++n){let r=t[n],i=l[e][n][0].data,o=u[e][n][0].data;for(let e=0;e<r.dims[0];++e){let t=r[e].data;for(let e=0;e<t.length;++e)t[e]=(t[e]-o[e])/i[e];t.set(_c(t,a))}}}let f=[xl(i>0?d.slice(null,null,[i,d.dims[2]],null):d,1)],p=e.sequences.dims,m=new U(`float32`,new Float32Array(p[0]*p[1]),p);for(let e=0;e<p[0];++e){let[t,n]=bc(f[e].neg().squeeze_(0).tolist()),a=ci([1],Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n])).map(e=>!!e),o=[];for(let e=0;e<a.length;++e)a[e]&&o.push(n[e]*r);let s=Array(i).fill(0);s.push(...o),o.length>0&&s.push(o.at(-1)),m[e].data.set(s)}return m}},ID=class extends FD{},LD=class extends Z{},RD=class extends LD{},zD=class extends LD{async _call(e){return new Gm(await super._call(e))}},BD=class extends LD{async _call(e){return new Y(await super._call(e))}},VD=class extends LD{async _call(e){return new Wm(await super._call(e))}},HD=class extends LD{async _call(e){return new Km(await super._call(e))}},UD=class extends Z{},WD=class extends UD{},GD=class extends UD{async _call(e){return new Gm(await super._call(e))}},KD=class extends UD{async _call(e){return new Y(await super._call(e))}},qD=class extends UD{async _call(e){return new Wm(await super._call(e))}},JD=class extends UD{async _call(e){return new Km(await super._call(e))}},YD=class extends Z{},XD=class extends YD{},ZD=class extends YD{async _call(e){return new QD(await super._call(e))}},QD=class extends Um{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},$D=class extends Z{},eO=class extends $D{},tO=class extends $D{},nO=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`],[`openai_privacy_filter`,`OpenAIPrivacyFilterModel`]]),rO=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`]]),iO=new Map([[`mimi`,`MimiModel`],[`dac`,`DacModel`],[`snac`,`SnacModel`]]),aO=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`]]),oO=new Map([[`speecht5`,`SpeechT5ForSpeechToText`],[`whisper`,`WhisperForConditionalGeneration`],[`lite-whisper`,`LiteWhisperForConditionalGeneration`],[`moonshine`,`MoonshineForConditionalGeneration`],[`cohere_asr`,`CohereAsrForConditionalGeneration`]]),sO=new Map([[`speecht5`,`SpeechT5ForTextToSpeech`]]),cO=new Map([[`vits`,`VitsModel`],[`musicgen`,`MusicgenForConditionalGeneration`],[`supertonic`,`SupertonicForConditionalGeneration`]]),lO=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`]]),uO=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`],[`openai_privacy_filter`,`OpenAIPrivacyFilterForTokenClassification`]]),dO=new Map([[`t5`,`T5ForConditionalGeneration`],[`longt5`,`LongT5ForConditionalGeneration`],[`mt5`,`MT5ForConditionalGeneration`],[`bart`,`BartForConditionalGeneration`],[`mbart`,`MBartForConditionalGeneration`],[`marian`,`MarianMTModel`],[`m2m_100`,`M2M100ForConditionalGeneration`],[`blenderbot`,`BlenderbotForConditionalGeneration`],[`blenderbot-small`,`BlenderbotSmallForConditionalGeneration`]]),fO=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`],[`gemma4`,`Gemma4ForCausalLM`],[`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`]]),pO=new Map([[`multi_modality`,`MultiModalityCausalLM`]]),mO=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`]]),hO=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`]]),gO=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`]]),_O=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`],[`gemma4`,`Gemma4ForConditionalGeneration`],[`mistral3`,`Mistral3ForConditionalGeneration`],[`lighton_ocr`,`LightOnOcrForConditionalGeneration`],[`glm_ocr`,`GlmOcrForConditionalGeneration`]]),vO=new Map([[`granite_speech`,`GraniteSpeechForConditionalGeneration`],[`ultravox`,`UltravoxModel`],[`voxtral`,`VoxtralForConditionalGeneration`],[`voxtral_realtime`,`VoxtralRealtimeForConditionalGeneration`]]),yO=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`]]),bO=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`]]),xO=new Map([[`detr`,`DetrForObjectDetection`],[`rt_detr`,`RTDetrForObjectDetection`],[`rt_detr_v2`,`RTDetrV2ForObjectDetection`],[`rf_detr`,`RFDetrForObjectDetection`],[`d_fine`,`DFineForObjectDetection`],[`table-transformer`,`TableTransformerForObjectDetection`],[`yolos`,`YolosForObjectDetection`]]),SO=new Map([[`owlvit`,`OwlViTForObjectDetection`],[`owlv2`,`Owlv2ForObjectDetection`],[`grounding-dino`,`GroundingDinoForObjectDetection`]]),CO=new Map([[`detr`,`DetrForSegmentation`],[`clipseg`,`CLIPSegForImageSegmentation`]]),wO=new Map([[`segformer`,`SegformerForSemanticSegmentation`],[`sapiens`,`SapiensForSemanticSegmentation`],[`swin`,`SwinForSemanticSegmentation`],[`mobilenet_v1`,`MobileNetV1ForSemanticSegmentation`],[`mobilenet_v2`,`MobileNetV2ForSemanticSegmentation`],[`mobilenet_v3`,`MobileNetV3ForSemanticSegmentation`],[`mobilenet_v4`,`MobileNetV4ForSemanticSegmentation`]]),TO=new Map([[`detr`,`DetrForSegmentation`],[`maskformer`,`MaskFormerForInstanceSegmentation`]]),EO=new Map([[`sam`,`SamModel`],[`sam2`,`Sam2Model`],[`edgetam`,`EdgeTamModel`],[`sam3_tracker`,`Sam3TrackerModel`]]),DO=new Map([[`wav2vec2`,`Wav2Vec2ForCTC`],[`wav2vec2-bert`,`Wav2Vec2BertForCTC`],[`unispeech`,`UniSpeechForCTC`],[`unispeech-sat`,`UniSpeechSatForCTC`],[`wavlm`,`WavLMForCTC`],[`hubert`,`HubertForCTC`],[`parakeet_ctc`,`ParakeetForCTC`]]),OO=new Map([[`wav2vec2`,`Wav2Vec2ForSequenceClassification`],[`wav2vec2-bert`,`Wav2Vec2BertForSequenceClassification`],[`unispeech`,`UniSpeechForSequenceClassification`],[`unispeech-sat`,`UniSpeechSatForSequenceClassification`],[`wavlm`,`WavLMForSequenceClassification`],[`hubert`,`HubertForSequenceClassification`],[`audio-spectrogram-transformer`,`ASTForAudioClassification`]]),kO=new Map([[`wavlm`,`WavLMForXVector`]]),AO=new Map([[`unispeech-sat`,`UniSpeechSatForAudioFrameClassification`],[`wavlm`,`WavLMForAudioFrameClassification`],[`wav2vec2`,`Wav2Vec2ForAudioFrameClassification`],[`pyannote`,`PyAnnoteForAudioFrameClassification`]]),jO=new Map([[`vitmatte`,`VitMatteForImageMatting`]]),MO=new Map([[`patchtst`,`PatchTSTForPrediction`],[`patchtsmixer`,`PatchTSMixerForPrediction`]]),NO=new Map([[`swin2sr`,`Swin2SRForImageSuperResolution`]]),PO=new Map([[`chmv2`,`CHMv2ForDepthEstimation`],[`dpt`,`DPTForDepthEstimation`],[`depth_anything`,`DepthAnythingForDepthEstimation`],[`glpn`,`GLPNForDepthEstimation`],[`sapiens`,`SapiensForDepthEstimation`],[`depth_pro`,`DepthProForDepthEstimation`],[`metric3d`,`Metric3DForDepthEstimation`],[`metric3dv2`,`Metric3Dv2ForDepthEstimation`]]),FO=new Map([[`sapiens`,`SapiensForNormalEstimation`]]),IO=new Map([[`vitpose`,`VitPoseForPoseEstimation`]]),LO=new Map([[`clip`,`CLIPVisionModelWithProjection`],[`siglip`,`SiglipVisionModel`],[`jina_clip`,`JinaCLIPVisionModel`]]),RO=[[nO,X.EncoderOnly],[rO,X.EncoderDecoder],[aO,X.DecoderOnlyWithoutHead],[iO,X.AutoEncoder],[lO,X.EncoderOnly],[uO,X.EncoderOnly],[dO,X.Seq2Seq],[oO,X.Seq2Seq],[fO,X.DecoderOnly],[pO,X.MultiModality],[mO,X.EncoderOnly],[hO,X.EncoderOnly],[gO,X.Vision2Seq],[_O,X.ImageTextToText],[vO,X.AudioTextToText],[bO,X.EncoderOnly],[CO,X.EncoderOnly],[TO,X.EncoderOnly],[wO,X.EncoderOnly],[jO,X.EncoderOnly],[MO,X.EncoderOnly],[NO,X.EncoderOnly],[PO,X.EncoderOnly],[FO,X.EncoderOnly],[IO,X.EncoderOnly],[xO,X.EncoderOnly],[SO,X.EncoderOnly],[EO,X.MaskGeneration],[DO,X.EncoderOnly],[OO,X.EncoderOnly],[sO,X.Seq2Seq],[cO,X.EncoderOnly],[kO,X.EncoderOnly],[AO,X.EncoderOnly],[LO,X.EncoderOnly]];for(let[e,t]of RO)for(let n of e.values()){Fh.set(n,t);let e=ig[n];Lh.set(e,n),Ih.set(n,e)}var zO=[[`MusicgenForConditionalGeneration`,vC,X.Musicgen],[`Phi3VForCausalLM`,Sw,X.Phi3V],[`CLIPTextModelWithProjection`,d_,X.EncoderOnly],[`SiglipTextModel`,zT,X.EncoderOnly],[`JinaCLIPTextModel`,_x,X.EncoderOnly],[`ClapTextModelWithProjection`,o_,X.EncoderOnly],[`ClapAudioModelWithProjection`,s_,X.EncoderOnly],[`DacEncoderModel`,Q_,X.EncoderOnly],[`DacDecoderModel`,$_,X.EncoderOnly],[`MimiEncoderModel`,oS,X.EncoderOnly],[`MimiDecoderModel`,sS,X.EncoderOnly],[`SnacEncoderModel`,qT,X.EncoderOnly],[`SnacDecoderModel`,JT,X.EncoderOnly],[`Gemma3nForConditionalGeneration`,Jy,X.ImageAudioTextToText],[`Gemma4ForConditionalGeneration`,Xy,X.ImageAudioTextToText],[`SupertonicForConditionalGeneration`,_E,X.Supertonic],[`ChatterboxModel`,$g,X.Chatterbox],[`VoxtralRealtimeForConditionalGeneration`,vD,X.VoxtralRealtime]];for(let[e,t,n]of zO)Fh.set(e,n),Lh.set(t,e),Ih.set(e,t);var BO=new Map([[`modnet`,CO],[`birefnet`,CO],[`isnet`,CO],[`ben`,CO]]);for(let[e,t]of BO.entries())t.set(e,`PreTrainedModel`),Fh.set(e,X.EncoderOnly),Ih.set(e,Z);var VO=new Set(BO.keys());Fh.set(`PreTrainedModel`,X.EncoderOnly),Lh.set(Z,`PreTrainedModel`);var Q={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:lO,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:uO,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:sO,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:cO,MODEL_FOR_MASKED_LM_MAPPING_NAMES:mO,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:hO,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:bO,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:CO,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:wO,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:TO,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:xO,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:SO,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:EO,MODEL_FOR_CTC_MAPPING_NAMES:DO,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:OO,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:kO,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:AO,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:yO,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:jO,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:NO,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:PO,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:FO,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:IO,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:LO,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:_O,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:vO,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:dO,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:oO,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:fO,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:gO};Ah(Q);var $=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let t of this.MODEL_CLASS_MAPPINGS)if(t.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d};if(f.config=await Pm.from_pretrained(e,f),!this.MODEL_CLASS_MAPPINGS)throw Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:p}=f.config;for(let t of this.MODEL_CLASS_MAPPINGS){let n=t.get(p);if(!n){for(let e of t.values())if(e[0]===p){n=e;break}if(!n)continue}return await ig[n].from_pretrained(e,f)}if(this.BASE_IF_FAIL)return VO.has(p)||N.warn(`Unknown model class "${p}", attempting to construct from base class.`),await Z.from_pretrained(e,f);throw Error(`Unsupported model type: ${p}`)}},HO=class extends ${static MODEL_CLASS_MAPPINGS=RO.map(e=>e[0]);static BASE_IF_FAIL=!0},UO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},WO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},GO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},KO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},qO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},JO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},YO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},XO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},ZO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},QO=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},$O=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},ek=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},tk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},nk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},rk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},ik=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},ak=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},ok=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_CTC_MAPPING_NAMES]},sk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},ck=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},lk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},uk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},dk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},fk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},pk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},mk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},hk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},gk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},_k=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},vk=class extends ${static MODEL_CLASS_MAPPINGS=[Q.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function yk(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>Yd.read(e)))}async function bk(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>typeof e==`string`||e instanceof URL?$u(e,t):e instanceof Float64Array?new Float32Array(e):e))}function xk(e,t){t&&(e=e.map(e=>e|0));let[n,r,i,a]=e;return{xmin:n,ymin:r,xmax:i,ymax:a}}var Sk=class extends ni{constructor({task:e,model:t,tokenizer:n=null,processor:r=null}){super(),this.task=e,this.model=t,this.tokenizer=n,this.processor=r}async dispose(){await this.model.dispose()}},Ck=class extends Sk{async _call(e,{top_k:t=1}={}){let n=this.tokenizer(e,{padding:!0,truncation:!0}),r=await this.model(n),{problem_type:i,id2label:a}=this.model.config,o=i===`multi_label_classification`?e=>e.sigmoid():e=>new U(`float32`,oc(e.data),e.dims),s=[];for(let e of r.logits){let n=await ll(o(e),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));t===1?s.push(...i):s.push(i)}return Array.isArray(e)||t===1?s:s[0]}},wk=class extends Sk{async _call(e,{ignore_labels:t=[`O`],aggregation_strategy:n=`none`}={}){if(n!==`none`&&n!==`simple`)throw Error(`Invalid aggregation_strategy: "${n}". Must be one of "none" or "simple".`);let r=Array.isArray(e),i=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),a=(await this.model(i)).logits,o=this.model.config.id2label,s=[];for(let e=0;e<a.dims[0];++e){let r=i.input_ids[e].tolist(),c=a[e],l=[];for(let e=0;e<c.dims[0];++e){let n=c[e],i=fc(n.data)[1],a=o?o[i]:`LABEL_${i}`;if(t.includes(a))continue;let s=this.tokenizer.decode([r[e]],{skip_special_tokens:!0});if(s===``)continue;let u=oc(n.data);l.push({entity:a,score:u[i],index:e,word:s})}s.push(n===`simple`?Ek(l,r,this.tokenizer):l)}return r?s:s[0]}};function Tk(e){let t=e[0];return e[1]===`-`&&(t===`B`||t===`I`||t===`E`||t===`S`)?[t,e.slice(2)]:[`I`,e]}function Ek(e,t,n){let r=[],i=null;for(let t=0;t<e.length;++t){let[n,a]=Tk(e[t].entity);i===a&&n!==`B`&&n!==`S`?(r[r.length-1].end=t+1,n===`E`&&(i=null)):(r.push({tag:a,start:t,end:t+1}),i=n===`S`?null:a)}return r.map(({tag:r,start:i,end:a})=>{let o=0,s=[];for(let n=i;n<a;++n)o+=e[n].score,s.push(t[e[n].index]);return{entity_group:r,score:o/(a-i),word:n.decode(s,{skip_special_tokens:!0})}})}var Dk=class extends Sk{async _call(e,t,{top_k:n=1}={}){let r=this.tokenizer(e,{text_pair:t,padding:!0,truncation:!0}),i=Array.isArray(e),{start_logits:a,end_logits:o}=await this.model(r),s=r.input_ids.tolist(),c=r.attention_mask.tolist(),{all_special_ids:l,sep_token_id:u}=this.tokenizer,d=[];for(let e=0;e<a.dims[0];++e){let t=s[e],r=t.findIndex(e=>e==u),i=a[e].tolist(),f=o[e].tolist();for(let n=1;n<i.length;++n)(c[e]==0||n<=r||l.findIndex(e=>e==t[n])!==-1)&&(i[n]=-1/0,f[n]=-1/0);let p=oc(i).map((e,t)=>[e,t]),m=oc(f).map((e,t)=>[e,t]);p[0][0]=0,m[0][0]=0;let h=li(p,m).filter(e=>e[0][1]<=e[1][1]).map(e=>[e[0][1],e[1][1],e[0][0]*e[1][0]]).sort((e,t)=>t[2]-e[2]),g=[];for(let e=0;e<Math.min(h.length,n);++e){let[n,r,i]=h[e],a=t.slice(n,r+1),o=this.tokenizer.decode(a,{skip_special_tokens:!0});g.push({answer:o,score:i})}n===1?d.push(...g):d.push(g)}return i?d:d[0]}},Ok=class extends Sk{async _call(e,{top_k:t=5}={}){let{mask_token_id:n,mask_token:r}=this.tokenizer,i=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:a}=await this.model(i),o=[],s=i.input_ids.tolist();for(let e=0;e<s.length;++e){let i=s[e],c=i.findIndex(e=>e==n);if(c===-1)throw Error(`Mask token (${r}) not found in text.`);let l=a[e][c],u=await ll(new U(`float32`,oc(l.data),l.dims),t),d=u[0].tolist(),f=u[1].tolist();o.push(f.map((e,t)=>{let n=i.slice();return n[c]=e,{score:d[t],token:Number(e),token_str:this.tokenizer.decode([e]),sequence:this.tokenizer.decode(n,{skip_special_tokens:!0})}}))}return Array.isArray(e)?o:o[0]}},kk=class extends Sk{_default_generation_config={max_new_tokens:256};_key=`generated_text`;async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let r=this.tokenizer,i={padding:!0,truncation:!0},a;a=this.task===`translation`&&`_build_translation_inputs`in r?r._build_translation_inputs(e,i,t):r(e,i);let o=await this.model.generate({...a,...this._default_generation_config,...t});return r.batch_decode(o,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}},Ak=class extends kk{_key=`summary_text`},jk=class extends kk{_key=`translation_text`};function Mk(e){return Array.isArray(e)&&e.every(e=>`role`in e&&`content`in e)}var Nk=class extends Sk{_default_generation_config={max_new_tokens:256};async _call(e,t={}){let{add_special_tokens:n,return_full_text:r,tools:i,documents:a,chat_template:o,tokenizer_encode_kwargs:s,...c}=t,l=!1,u=!1,d=n??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,f=s,p;if(typeof e==`string`)p=e=[e];else if(Array.isArray(e)&&e.every(e=>typeof e==`string`))l=!0,p=e;else{if(Mk(e))e=[e];else if(Array.isArray(e)&&e.every(Mk))l=!0;else throw Error(`Input must be a string, an array of strings, a Chat, or an array of Chats`);u=!0;let t={tokenize:!1,add_generation_prompt:!0,...di({tools:i,documents:a,chat_template:o},[`tools`,`documents`,`chat_template`]),...f};p=e.map(e=>this.tokenizer.apply_chat_template(e,t)),d=!1,f=void 0}let m=u?!1:r??!0;this.tokenizer.padding_side=`left`;let h=this.tokenizer(p,{add_special_tokens:d,padding:!0,truncation:!0,...f}),g=await this.model.generate({...h,...this._default_generation_config,...c}),_=this.tokenizer.batch_decode(g,{skip_special_tokens:!0}),v;!m&&h.input_ids.dims.at(-1)>0&&(v=this.tokenizer.batch_decode(h.input_ids,{skip_special_tokens:!0}).map(e=>e.length));let y=Array.from({length:e.length},e=>[]);for(let t=0;t<_.length;++t){let n=Math.floor(t/g.dims[0]*e.length);v&&(_[t]=_[t].slice(v[n])),y[n].push({generated_text:u?[...e[n],{role:`assistant`,content:_[t]}]:_[t]})}return!l&&y.length===1?y[0]:y}},Pk=class extends Sk{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([e,t])=>[e.toLowerCase(),t])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(N.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&&(N.warn(`Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id.`),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:n=`This example is {}.`,multi_label:r=!1}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let a=t.map(e=>n.replace(`{}`,e)),o=r||t.length===1,s=[];for(let n of e){let e=[];for(let t of a){let r=this.tokenizer(n,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(r);o?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let r=(o?e.map(e=>oc(e)[1]):oc(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);s.push({sequence:n,labels:r.map(e=>t[e[1]]),scores:r.map(e=>e[0])})}return i?s:s[0]}},Fk=class extends Sk{async _call(e,{top_k:t=5}={}){let n=this.processor.feature_extractor.config.sampling_rate,r=await bk(e,n),i=this.model.config.id2label,a=[];for(let e of r){let n=await this.processor(e),r=(await this.model(n)).logits[0],o=await ll(new U(`float32`,oc(r.data),r.dims),t),s=o[0].tolist(),c=o[1].tolist().map((e,t)=>({label:i?i[e]:`LABEL_${e}`,score:s[t]}));a.push(c)}return Array.isArray(e)?a:a[0]}},Ik=class extends Sk{async _call(e,t,{hypothesis_template:n=`This is a sound of {}.`}={}){let r=!Array.isArray(e);r&&(e=[e]);let i=t.map(e=>n.replace(`{}`,e)),a=this.tokenizer(i,{padding:!0,truncation:!0}),o=this.processor.feature_extractor.config.sampling_rate,s=await bk(e,o),c=[];for(let e of s){let n=await this.processor(e),r=oc((await this.model({...a,...n})).logits_per_audio.data);c.push([...r].map((e,n)=>({score:e,label:t[n]})))}return r?c[0]:c}},Lk=class extends Sk{_default_generation_config={};async _call(e,t={}){switch(t={...this._default_generation_config,...t},this.model.config.model_type){case`whisper`:case`lite-whisper`:return this._call_whisper(e,t);case`wav2vec2`:case`wav2vec2-bert`:case`unispeech`:case`unispeech-sat`:case`hubert`:case`parakeet_ctc`:return this._call_wav2vec2(e,t);case`moonshine`:return this._call_moonshine(e,t);case`cohere_asr`:return this._call_cohere_asr(e,t);default:throw Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&N.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&N.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await bk(r,i),o=[];for(let e of a){let t=await this.processor(e),n=(await this.model(t)).logits[0],r=[];for(let e of n)r.push(fc(e.data)[1]);let i=this.tokenizer.decode(r,{skip_special_tokens:!0}).trim();o.push({text:i})}return n?o[0]:o}async _call_whisper(e,t){let n=t.return_timestamps??!1,r=t.chunk_length_s??0,i=t.force_full_sequences??!1,a=t.stride_length_s??null,o={...t};n===`word`&&(o.return_token_timestamps=!0,o.return_timestamps=!0);let s=!Array.isArray(e),c=s?[e]:e,l=this.processor.feature_extractor.config,u=l.chunk_length/this.model.config.max_source_positions,d=l.hop_length,f=l.sampling_rate,p=await bk(c,f),m=[];for(let e of p){let t=[];if(r>0){if(a===null)a=r/6;else if(r<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let n=f*r,i=f*a,o=n-2*i,s=0;for(;;){let r=s+n,a=e.subarray(s,r),c=await this.processor(a),l=s===0,u=r>=e.length;if(t.push({stride:[a.length,l?0:i,u?0:i],input_features:c.input_features,is_last:u}),u)break;s+=o}}else t=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of t){o.num_frames=Math.floor(e.stride[0]/d);let t=await this.model.generate({inputs:e.input_features,...o});if(n===`word`){let n=t.sequences.tolist()[0],r=t.token_timestamps.tolist()[0],i=this.tokenizer.timestamp_begin,a=Math.max(n.findIndex(e=>Number(e)>=i),0);e.tokens=n.slice(a),e.token_timestamps=r.slice(a).map(e=>vc(e,2))}else e.tokens=t[0].tolist();e.stride=e.stride.map(e=>e/f)}let[s,c]=this.tokenizer._decode_asr(t,{time_precision:u,return_timestamps:n,force_full_sequences:i});m.push({text:s,...c})}return s?m[0]:m}async _call_moonshine(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await bk(r,i),o=[];for(let e of a){let n=await this.processor(e),r=Math.floor(e.length/i)*6,a=await this.model.generate({max_new_tokens:r,...t,...n}),s=this.processor.batch_decode(a,{skip_special_tokens:!0})[0];o.push({text:s})}return n?o[0]:o}async _call_cohere_asr(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor,a=i.config.sampling_rate,o=await bk(r,a),s=t.language??`en`,c=this.processor.get_decoder_prompt_ids(s),l=[];for(let e of o){let n=i.split_audio(e),r=[];for(let e of n){let n=await this.processor(e),i=await this.model.generate({...n,decoder_input_ids:c,...t}),a=this.tokenizer.decode(i[0].tolist(),{skip_special_tokens:!0}).trim();r.push(a)}let a=this.processor.constructor.join_chunks(r,s);l.push({text:a})}return n?l[0]:l}},Rk=class extends Sk{DEFAULT_VOCODER_ID=`Xenova/speecht5_hifigan`;constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,t){if((typeof e==`string`||e instanceof URL)&&(e=new Float32Array(await(await M.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new U(`float32`,e,[e.length]);else if(!(e instanceof U))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(t>1){if(e.dims[0]===1)e=e.repeat(t,1);else if(e.dims[0]!==t)throw Error(`Expected speaker embeddings batch size to be 1 or ${t}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,t,n,r=null){let i=t.data,[a,o]=t.dims,s=r?r.data:null,c=[];for(let e=0;e<a;++e){let t=s?Math.min(Math.ceil(s[e]),o):o,r=e*o;c.push(new vd(i.slice(r,r+t),n))}return Array.isArray(e)?c:c[0]}async _call(e,t){return this.processor?this._call_text_to_spectrogram(e,t):this.model.config.model_type===`supertonic`?this._call_supertonic(e,t):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:t,num_inference_steps:n,speed:r}){if(!t)throw Error(`Speaker embeddings must be provided for Supertonic models.`);let{sampling_rate:i,style_dim:a}=this.model.config,o=this.tokenizer(e,{padding:!0,truncation:!0}),s=o.input_ids.dims[0];t=await this._prepare_speaker_embeddings(t,s),t=t.view(s,-1,a);let{waveform:c,durations:l}=await this.model.generate_speech({...o,style:t,num_inference_steps:n,speed:r});return this._postprocess_waveform(e,c,i,l)}async _call_text_to_waveform(e){let t=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:n}=await this.model(t),r=this.model.config.sampling_rate;return this._postprocess_waveform(e,n,r)}async _call_text_to_spectrogram(e,{speaker_embeddings:t}){this.vocoder||=(N.info(`No vocoder specified, using default HifiGan vocoder.`),await HO.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:`fp32`}));let{input_ids:n}=this.tokenizer(e,{padding:!0,truncation:!0}),r=n.dims[0];t=await this._prepare_speaker_embeddings(t,r),t=t.view(r,-1);let{waveform:i}=await this.model.generate_speech(n,t,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,i,a)}},zk=class extends Sk{async _call(e,t={}){let n=Array.isArray(e),r=await yk(e),{pixel_values:i}=await this.processor(r),a=[];for(let e of i){e.dims=[1,...e.dims];let n=await this.model.generate({inputs:e,...t}),r=this.tokenizer.batch_decode(n,{skip_special_tokens:!0}).map(e=>({generated_text:e.trim()}));a.push(r)}return n?a:a[0]}},Bk=class extends Sk{async _call(e,{top_k:t=5}={}){let n=await yk(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),{id2label:a}=this.model.config,o=[];for(let e of i.logits){let n=await ll(new U(`float32`,oc(e.data),e.dims),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));o.push(i)}return Array.isArray(e)?o:o[0]}},Vk={panoptic:`post_process_panoptic_segmentation`,instance:`post_process_instance_segmentation`,semantic:`post_process_semantic_segmentation`},Hk=class extends Sk{async _call(e,{threshold:t=.5,mask_threshold:n=.5,overlap_mask_area_threshold:r=.8,label_ids_to_fuse:i=null,target_sizes:a=null,subtask:o=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error(`Image segmentation pipeline currently only supports a batch size of 1.`);let s=await yk(e),c=s.map(e=>[e.height,e.width]),l=await this.processor(s),{inputNames:u,outputNames:d}=this.model.sessions.model;if(!u.includes(`pixel_values`)){if(u.length!==1)throw Error(`Expected a single input name, but got ${u.length} inputs: ${u}.`);let e=u[0];if(e in l)throw Error(`Input name ${e} already exists in the inputs.`);l[e]=l.pixel_values}let f=await this.model(l),p=null;if(o!==null)p=Vk[o];else if(this.processor.image_processor){for(let[e,t]of Object.entries(Vk))if(t in this.processor.image_processor){p=this.processor.image_processor[t].bind(this.processor.image_processor),o=e;break}}let m=this.model.config.id2label,h=[];if(!o){let e=f[d[0]];for(let t=0;t<c.length;++t){let n=c[t],r=e[t];r.data.some(e=>e<-1e-5||e>1.00001)&&r.sigmoid_();let i=await Yd.fromTensor(r.mul_(255).to(`uint8`)).resize(n[1],n[0]);h.push({label:null,score:null,mask:i})}}else if(o===`panoptic`||o===`instance`){let e=p(f,t,n,r,i,a??c)[0],o=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(o.data.length);for(let n=0;n<o.data.length;++n)o.data[n]===t.id&&(e[n]=255);let n=new Yd(e,o.dims[1],o.dims[0],1);h.push({score:t.score,label:m[t.label_id],mask:n})}}else if(o===`semantic`){let{segmentation:e,labels:t}=p(f,a??c)[0];for(let n of t){let t=new Uint8ClampedArray(e.data.length);for(let r=0;r<e.data.length;++r)e.data[r]===n&&(t[r]=255);let r=new Yd(t,e.dims[1],e.dims[0],1);h.push({score:null,label:m[n],mask:r})}}else throw Error(`Subtask ${o} not supported.`);return h}},Uk=class extends Hk{async _call(e,t={}){let n=await yk(e),r=await super._call(e,t),i=n.map((e,t)=>{let n=e.clone();return n.putAlpha(r[t].mask),n});return Array.isArray(e)?i:i[0]}},Wk=class extends Sk{async _call(e,t,{hypothesis_template:n=`This is a photo of {}`}={}){let r=Array.isArray(e),i=await yk(e),a=t.map(e=>n.replace(`{}`,e)),o=this.tokenizer(a,{padding:this.model.config.model_type!==`siglip`||`max_length`,truncation:!0}),{pixel_values:s}=await this.processor(i),c=await this.model({...o,pixel_values:s}),l=this.model.config.model_type===`siglip`?e=>e.sigmoid().data:e=>oc(e.data),u=[];for(let e of c.logits_per_image){let n=[...l(e)].map((e,n)=>({score:e,label:t[n]}));n.sort((e,t)=>t.score-e.score),u.push(n)}return r?u:u[0]}},Gk=class extends Sk{async _call(e,{threshold:t=.9,percentage:n=!1}={}){let r=Array.isArray(e);if(r&&e.length!==1)throw Error(`Object detection pipeline currently only supports a batch size of 1.`);let i=await yk(e),a=n?null:i.map(e=>[e.height,e.width]),{pixel_values:o,pixel_mask:s}=await this.processor(i),c=await this.model({pixel_values:o,pixel_mask:s}),l=this.processor.image_processor.post_process_object_detection(c,t,a),{id2label:u}=this.model.config,d=l.map(e=>e.boxes.map((t,r)=>({score:e.scores[r],label:u[e.classes[r]],box:xk(t,!n)})));return r?d:d[0]}},Kk=class extends Sk{async _call(e,t,{threshold:n=.1,top_k:r=null,percentage:i=!1}={}){let a=Array.isArray(e),o=await yk(e),s=this.tokenizer(t,{padding:!0,truncation:!0}),c=await this.processor(o),l=[];for(let e=0;e<o.length;++e){let a=o[e],u=i?null:[[a.height,a.width]],d=c.pixel_values[e].unsqueeze_(0),f=await this.model({...s,pixel_values:d}),p;if(`post_process_grounded_object_detection`in this.processor){let e=this.processor.post_process_grounded_object_detection(f,s.input_ids,{box_threshold:n,text_threshold:n,target_sizes:u})[0];p=e.boxes.map((t,n)=>({score:e.scores[n],label:e.labels[n],box:xk(t,!i)}))}else{let e=this.processor.image_processor.post_process_object_detection(f,n,u,!0)[0];p=e.boxes.map((n,r)=>({score:e.scores[r],label:t[e.classes[r]],box:xk(n,!i)}))}p.sort((e,t)=>t.score-e.score),r!==null&&(p=p.slice(0,r)),l.push(p)}return a?l:l[0]}},qk=class extends Sk{_default_generation_config={max_new_tokens:256};async _call(e,t,n={}){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 r=(await yk(e))[0],{pixel_values:i}=await this.processor(r),a=`<s_docvqa><s_question>${t}</s_question><s_answer>`,o=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,s=await this.model.generate({inputs:i,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:o,...this._default_generation_config,...n}),c=this.tokenizer.batch_decode(s)[0].match(/<s_answer>(.*?)<\/s_answer>/),l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}},Jk=class extends Sk{async _call(e){let t=await yk(e),n=await this.processor(t),r=await this.model(n),i=[];for(let e of r.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to(`uint8`);i.push(Yd.fromTensor(t))}return Array.isArray(e)?i:i[0]}},Yk=class extends Sk{async _call(e){let t=await yk(e),n=await this.processor(t),{predicted_depth:r}=await this.model(n),i=[];for(let e=0;e<t.length;++e){let n=r[e],[a,o]=n.dims.slice(-2),[s,c]=t[e].size,l=(await ol(n.view(1,1,a,o),{size:[c,s],mode:`bilinear`})).view(c,s),u=l.min().item(),d=l.max().item(),f=l.sub(u).div_(d-u).mul_(255).to(`uint8`).unsqueeze(0),p=Yd.fromTensor(f);i.push({predicted_depth:l,depth:p})}return Array.isArray(e)?i:i[0]}},Xk=class extends Sk{async _call(e,{pooling:t=`none`,normalize:n=!1,quantize:r=!1,precision:i=`binary`}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),o=await this.model(a),s=o.last_hidden_state??o.logits??o.token_embeddings;switch(t){case`none`:break;case`mean`:s=fl(s,a.attention_mask);break;case`first_token`:case`cls`:s=s.slice(null,0);break;case`last_token`:case`eos`:s=s.slice(null,-1);break;default:throw Error(`Pooling method '${t}' not supported.`)}return n&&(s=s.normalize(2,-1)),r&&(s=Ml(s,i)),s}},Zk=class extends Sk{async _call(e,{pool:t=null}={}){let n=await yk(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),a;if(t){if(!(`pooler_output`in i))throw Error(`No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.`);a=i.pooler_output}else a=i.last_hidden_state??i.logits??i.image_embeds;return a}},Qk=Object.freeze({"text-classification":{pipeline:Ck,model:UO,default:{model:`Xenova/distilbert-base-uncased-finetuned-sst-2-english`},type:`text`},"token-classification":{pipeline:wk,model:WO,default:{model:`Xenova/bert-base-multilingual-cased-ner-hrl`},type:`text`},"question-answering":{pipeline:Dk,model:ZO,default:{model:`Xenova/distilbert-base-cased-distilled-squad`},type:`text`},"fill-mask":{pipeline:Ok,model:XO,default:{model:`onnx-community/ettin-encoder-32m-ONNX`,dtype:`fp32`},type:`text`},summarization:{pipeline:Ak,model:GO,default:{model:`Xenova/distilbart-cnn-6-6`},type:`text`},translation:{pipeline:jk,model:GO,default:{model:`Xenova/t5-small`},type:`text`},"text2text-generation":{pipeline:kk,model:GO,default:{model:`Xenova/flan-t5-small`},type:`text`},"text-generation":{pipeline:Nk,model:YO,default:{model:`onnx-community/Qwen3-0.6B-ONNX`,dtype:`q4`},type:`text`},"zero-shot-classification":{pipeline:Pk,model:UO,default:{model:`Xenova/distilbert-base-uncased-mnli`},type:`text`},"audio-classification":{pipeline:Fk,model:sk,default:{model:`Xenova/wav2vec2-base-superb-ks`},type:`audio`},"zero-shot-audio-classification":{pipeline:Ik,model:HO,default:{model:`Xenova/clap-htsat-unfused`},type:`multimodal`},"automatic-speech-recognition":{pipeline:Lk,model:[KO,ok],default:{model:`Xenova/whisper-tiny.en`},type:`multimodal`},"text-to-audio":{pipeline:Rk,model:[JO,qO],default:{model:`onnx-community/Supertonic-TTS-ONNX`,dtype:`fp32`},type:`text`},"image-to-text":{pipeline:zk,model:QO,default:{model:`Xenova/vit-gpt2-image-captioning`},type:`multimodal`},"image-classification":{pipeline:Bk,model:$O,default:{model:`Xenova/vit-base-patch16-224`},type:`multimodal`},"image-segmentation":{pipeline:Hk,model:[ek,tk,nk],default:{model:`Xenova/detr-resnet-50-panoptic`},type:`multimodal`},"background-removal":{pipeline:Uk,model:[ek,tk,nk],default:{model:`Xenova/modnet`},type:`image`},"zero-shot-image-classification":{pipeline:Wk,model:HO,default:{model:`Xenova/clip-vit-base-patch32`},type:`multimodal`},"object-detection":{pipeline:Gk,model:rk,default:{model:`Xenova/detr-resnet-50`},type:`multimodal`},"zero-shot-object-detection":{pipeline:Kk,model:ik,default:{model:`Xenova/owlvit-base-patch32`},type:`multimodal`},"document-question-answering":{pipeline:qk,model:uk,default:{model:`Xenova/donut-base-finetuned-docvqa`},type:`multimodal`},"image-to-image":{pipeline:Jk,model:fk,default:{model:`Xenova/swin2SR-classical-sr-x2-64`},type:`image`},"depth-estimation":{pipeline:Yk,model:pk,default:{model:`onnx-community/depth-anything-v2-small`},type:`image`},"feature-extraction":{pipeline:Xk,model:HO,default:{model:`onnx-community/all-MiniLM-L6-v2-ONNX`,dtype:`fp32`},type:`text`},"image-feature-extraction":{pipeline:Zk,model:[gk,HO],default:{model:`onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX`,dtype:`fp32`},type:`image`}}),$k=Object.freeze({"sentiment-analysis":`text-classification`,ner:`token-classification`,asr:`automatic-speech-recognition`,"text-to-speech":`text-to-audio`,embeddings:`feature-extraction`});async function eA(e){if(!e)throw Error(`modelId is required`);return(await Ks(e,Uu,{})).exists?[Uu]:[]}async function tA(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null,include_tokenizer:a=!0,include_processor:o=!0}={}){let s=await Oh(e,{config:t,dtype:n,device:r,model_file_name:i});if(a){let t=await Nl(e);s.push(...t)}if(o){let t=await eA(e);s.push(...t)}return s}async function nA(e,t,n={}){e=$k[e]??e;let r=Qk[e];if(!r)throw Error(`Unsupported pipeline task: ${e}. Must be one of [${Object.keys(Qk).join(`, `)}]`);let{type:i}=r,a=i!==`audio`&&i!==`image`,o=i!==`text`,s=await tA(t,{...n,include_tokenizer:a,include_processor:o});if(e===`text-generation`){let e=wh(Eh(await Dh(t,n)));if(e){let t=Object.values(e).map(e=>`onnx/${e}`);return s.filter(e=>!e.startsWith(`onnx/`)||t.some(t=>e.startsWith(t)))}}return s}async function rA(e,t=null,{progress_callback:n=null,config:r=null,cache_dir:i=null,local_files_only:a=!1,revision:o=`main`,device:s=null,dtype:c=null,subfolder:l=`onnx`,use_external_data_format:u=null,model_file_name:d=null,session_options:f={}}={}){e=$k[e]??e;let p=Qk[e.split(`_`,1)[0]];if(!p)throw Error(`Unsupported pipeline: ${e}. Must be one of [${Object.keys(Qk)}]`);t||(t=p.default.model,N.info(`No model specified. Using default model: "${t}".`),!c&&p.default.dtype&&(c=p.default.dtype));let m=await nA(e,t,{device:s,dtype:c}),h={};n&&(await Promise.all(m.map(async e=>Ks(t,e)))).forEach((e,t)=>{e.exists&&(h[m[t]]={loaded:0,total:e.size??0})});let g={progress_callback:n?new ii(n,h):void 0,config:r,cache_dir:i,local_files_only:a,revision:o,device:s,dtype:c,subfolder:l,use_external_data_format:u,model_file_name:d,session_options:f},_=m.includes(`tokenizer.json`),v=m.includes(`preprocessor_config.json`),y=p.model,b;if(Array.isArray(y)){let n=r??await Pm.from_pretrained(t,g),{model_type:i}=n,a=y.find(e=>e.supports(i));if(!a)throw Error(`Unsupported model type "${i}" for task "${e}". None of the candidate model classes support this type.`);b=a.from_pretrained(t,{...g,config:n})}else b=y.from_pretrained(t,g);let[x,ee,S]=await Promise.all([_?G.from_pretrained(t,g):null,v?Om.from_pretrained(t,g):null,b]),te={task:e,model:S};x&&(te.tokenizer=x),ee&&(te.processor=ee),ri(n,{status:`ready`,task:e,model:t});let C=p.pipeline;return new C(te)}var iA=e=>e>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,aA=class{put(e){throw Error(`Not implemented`)}end(){throw Error(`Not implemented`)}},oA=j.IS_PROCESS_AVAILABLE?e=>process.stdout.write(e):e=>console.log(e),sA=class extends aA{constructor(e,{skip_prompt:t=!1,callback_function:n=null,token_callback_function:r=null,skip_special_tokens:i=!0,decode_kwargs:a={},...o}={}){super(),this.tokenizer=e,this.skip_prompt=t,this.callback_function=n??oA,this.token_callback_function=r,this.decode_kwargs={skip_special_tokens:i,...a,...o},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 t=this.next_tokens_are_prompt;if(t&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let n=e[0];if(this.token_callback_function?.(n),n.length===1&&this.special_ids.has(n[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(e,!1),this.token_cache=[],this.print_len=0}let e=this.tokenizer.decode(n,this.decode_kwargs);this.on_finalized_text(e,!1);return}this.token_cache=ci(this.token_cache,n);let r=this.tokenizer.decode(this.token_cache,this.decode_kwargs),i;t||r.endsWith(`
|
|
38
38
|
`)?(i=r.slice(this.print_len),this.token_cache=[],this.print_len=0):r.length>0&&iA(r.charCodeAt(r.length-1))?(i=r.slice(this.print_len),this.print_len+=i.length):(i=r.slice(this.print_len,r.lastIndexOf(` `)+1),this.print_len+=i.length),this.on_finalized_text(i,!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,t){e.length>0&&this.callback_function?.(e),t&&this.callback_function===oA&&j.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
|
|
39
|
-
`)}},cA=class extends sA{constructor(e,{skip_prompt:t=!1,callback_function:n=null,token_callback_function:r=null,on_chunk_start:i=null,on_chunk_end:a=null,on_finalize:o=null,time_precision:s=.02,skip_special_tokens:c=!0,decode_kwargs:l={}}={}){super(e,{skip_prompt:t,skip_special_tokens:c,callback_function:n,token_callback_function:r,decode_kwargs:l}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=i,this.on_chunk_end=a,this.on_finalize=o,this.time_precision=s,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error(`WhisperTextStreamer only supports batch size of 1`);let t=e[0];if(t.length===1){let e=Number(t[0])-this.timestamp_begin;if(e>=0){let n=e*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?.(t);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}},lA=class{constructor(e,t){this.image=e,this.timestamp=t}},uA=class{constructor(e,t){e.length>0&&e[0]instanceof Yd&&(e=e.map((n,r)=>new lA(n,(r+1)/(e.length+1)*t))),this.frames=e,this.duration=t}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 dA(e,{num_frames:t=null,fps:n=null}={}){if(!j.IS_BROWSER_ENV)throw Error("`load_video` is currently only supported in browser environments.");if(t==null&&n==null)throw Error(`Either num_frames or fps must be provided.`);let r=[],i=document.createElement(`video`);if(i.crossOrigin=`anonymous`,i.muted=!0,typeof e==`string`)i.src=e;else if(e instanceof Blob)i.src=URL.createObjectURL(e);else if(e instanceof HTMLVideoElement)i.src=e.src;else throw Error(`Invalid URL or video element provided.`);if(await new Promise(e=>i.onloadedmetadata=e),i.seekable.start(0)===i.seekable.end(0)){let e=await(await M.fetch(i.src)).blob();i.src=URL.createObjectURL(e),await new Promise(e=>i.onloadedmetadata=e)}let a=i.duration,o,s;t==null?(s=1/n,o=Math.floor(a/s)):(o=t,s=t===1?0:a/(t-1));let c=[];for(let e=0;e<o;++e)c.push(t===1?a/2:e*s);let l=document.createElement(`canvas`);l.width=i.videoWidth,l.height=i.videoHeight;let u=l.getContext(`2d`,{willReadFrequently:!0});for(let e of c){i.currentTime=e,await new Promise(e=>{i.onseeked=e}),u.drawImage(i,0,0,l.width,l.height);let t=new lA(new Yd(u.getImageData(0,0,l.width,l.height).data,l.width,l.height,4),e);r.push(t)}return i.remove(),new uA(r,a)}async function fA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return{allCached:!1,files:t.map(e=>({file:e,cached:!1}))};let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r);return{file:t,cached:!!await Zs(r,i,a)}}));return{allCached:i.every(e=>e.cached),files:i}}async function pA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return!1;let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r);return!!await Zs(r,i,a)}async function mA(e,t={}){if(!e)throw Error(`modelId is required`);return await pA(e,`config.json`,t)?(await fA(e,await tA(e,t),t)).allCached:!1}async function hA(e,t={}){if(!e)throw Error(`modelId is required`);return await fA(e,await tA(e,t),t)}async function gA(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await pA(t,`config.json`,n)?(await fA(t,await nA(e,t,n),n)).allCached:!1}async function _A(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await fA(t,await nA(e,t,n),n)}async function vA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return{filesDeleted:0,filesCached:0,files:t.map(e=>({file:e,deleted:!1,wasCached:!1}))};if(!r.delete)throw Error(`Cache does not support delete operation`);let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r),o=!!await Zs(r,i,a),s=!1;if(o){let e=await r.delete(a),t=!e&&a!==i?await r.delete(i):!1;s=e||t}return{file:t,deleted:s,wasCached:o}}));return{filesDeleted:i.filter(e=>e.deleted).length,filesCached:i.filter(e=>e.wasCached).length,files:i}}async function yA(e,t={}){if(!e)throw Error(`modelId is required`);return await vA(e,await tA(e,t),t)}async function bA(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await vA(t,await nA(e,t,n),n)}var xA=Object.keys(el);async function SA(e,{config:t=null,model_file_name:n=null,revision:r=`main`,cache_dir:i=null,local_files_only:a=!1}={}){t=await Dh(e,{config:t,cache_dir:i,local_files_only:a,revision:r});let{sessions:o}=Th(Eh(t),t,{model_file_name:n}),s=Object.values(o),c={revision:r,cache_dir:i,local_files_only:a};return(await Promise.all(xA.map(async t=>{let n=el[t]??``;return{dtype:t,available:(await Promise.all(s.map(async t=>(await Ks(e,`onnx/${t}${n}.onnx`,c)).exists))).every(Boolean)}}))).filter(e=>e.available).map(e=>e.dtype)}var CA=class{static async get_files(e,t={}){return tA(e,t)}static async get_pipeline_files(e,t,n={}){return nA(e,t,n)}static async get_model_files(e,t={}){return Oh(e,t)}static async get_tokenizer_files(e){return Nl(e)}static async get_processor_files(e){return eA(e)}static async get_available_dtypes(e,t={}){return SA(e,t)}static async is_cached(e,t={}){return mA(e,t)}static async is_cached_files(e,t={}){return hA(e,t)}static async is_pipeline_cached(e,t,n={}){return gA(e,t,n)}static async is_pipeline_cached_files(e,t,n={}){return _A(e,t,n)}static async get_file_metadata(e,t,n={}){return Ks(e,t,n)}static async clear_cache(e,t={}){return yA(e,t)}static async clear_pipeline_cache(e,t,n={}){return bA(e,t,n)}};export{yd as ASTFeatureExtractor,xg as ASTForAudioClassification,bg as ASTModel,yg as ASTPreTrainedModel,hg as AfmoeForCausalLM,mg as AfmoeModel,pg as AfmoePreTrainedModel,lg as AlbertForMaskedLM,cg as AlbertForQuestionAnswering,sg as AlbertForSequenceClassification,og as AlbertModel,ag as AlbertPreTrainedModel,Ul as AlbertTokenizer,fg as ApertusForCausalLM,dg as ApertusModel,ug as ApertusPreTrainedModel,vg as ArceeForCausalLM,_g as ArceeModel,gg as ArceePreTrainedModel,Fk as AudioClassificationPipeline,Pm as AutoConfig,zd as AutoFeatureExtractor,jp as AutoImageProcessor,HO as AutoModel,sk as AutoModelForAudioClassification,lk as AutoModelForAudioFrameClassification,vk as AutoModelForAudioTextToText,ok as AutoModelForCTC,YO as AutoModelForCausalLM,pk as AutoModelForDepthEstimation,uk as AutoModelForDocumentQuestionAnswering,$O as AutoModelForImageClassification,gk as AutoModelForImageFeatureExtraction,dk as AutoModelForImageMatting,ek as AutoModelForImageSegmentation,_k as AutoModelForImageTextToText,fk as AutoModelForImageToImage,ak as AutoModelForMaskGeneration,XO as AutoModelForMaskedLM,mk as AutoModelForNormalEstimation,rk as AutoModelForObjectDetection,hk as AutoModelForPoseEstimation,ZO as AutoModelForQuestionAnswering,tk as AutoModelForSemanticSegmentation,GO as AutoModelForSeq2SeqLM,UO as AutoModelForSequenceClassification,KO as AutoModelForSpeechSeq2Seq,qO as AutoModelForTextToSpectrogram,JO as AutoModelForTextToWaveform,WO as AutoModelForTokenClassification,nk as AutoModelForUniversalSegmentation,QO as AutoModelForVision2Seq,ck as AutoModelForXVector,ik as AutoModelForZeroShotObjectDetection,Om as AutoProcessor,G as AutoTokenizer,Lk as AutomaticSpeechRecognitionPipeline,Uk as BackgroundRemovalPipeline,wg as BartForConditionalGeneration,Tg as BartForSequenceClassification,Cg as BartModel,Sg as BartPretrainedModel,Wl as BartTokenizer,aA as BaseStreamer,uf as BeitFeatureExtractor,Og as BeitForImageClassification,Dg as BeitModel,Eg as BeitPreTrainedModel,jg as BertForMaskedLM,Pg as BertForQuestionAnswering,Mg as BertForSequenceClassification,Ng as BertForTokenClassification,Ag as BertModel,kg as BertPreTrainedModel,Gl as BertTokenizer,df as BitImageProcessor,Lg as BlenderbotForConditionalGeneration,Ig as BlenderbotModel,Fg as BlenderbotPreTrainedModel,Bg as BlenderbotSmallForConditionalGeneration,zg as BlenderbotSmallModel,Rg as BlenderbotSmallPreTrainedModel,Kl as BlenderbotSmallTokenizer,ql as BlenderbotTokenizer,Ug as BloomForCausalLM,Hg as BloomModel,Vg as BloomPreTrainedModel,Jl as BloomTokenizer,r_ as CHMv2ForDepthEstimation,pf as CHMv2ImageProcessor,n_ as CHMv2PreTrainedModel,hf as CLIPFeatureExtractor,mf as CLIPImageProcessor,l_ as CLIPModel,c_ as CLIPPreTrainedModel,g_ as CLIPSegForImageSegmentation,h_ as CLIPSegModel,m_ as CLIPSegPreTrainedModel,u_ as CLIPTextModel,d_ as CLIPTextModelWithProjection,Xl as CLIPTokenizer,f_ as CLIPVisionModel,p_ as CLIPVisionModelWithProjection,Kg as CamembertForMaskedLM,Yg as CamembertForQuestionAnswering,qg as CamembertForSequenceClassification,Jg as CamembertForTokenClassification,Gg as CamembertModel,Wg as CamembertPreTrainedModel,Yl as CamembertTokenizer,xd as ChatterboxFeatureExtractor,$g as ChatterboxModel,Qg as ChatterboxPreTrainedModel,Bd as ChatterboxProcessor,ff as ChineseCLIPFeatureExtractor,t_ as ChineseCLIPModel,e_ as ChineseCLIPPreTrainedModel,s_ as ClapAudioModelWithProjection,Sd as ClapFeatureExtractor,a_ as ClapModel,i_ as ClapPreTrainedModel,o_ as ClapTextModelWithProjection,ch as ClassifierFreeGuidanceLogitsProcessor,y_ as CodeGenForCausalLM,v_ as CodeGenModel,__ as CodeGenPreTrainedModel,Ql as CodeGenTokenizer,Zl as CodeLlamaTokenizer,T_ as Cohere2ForCausalLM,w_ as Cohere2Model,C_ as Cohere2PreTrainedModel,Td as CohereAsrFeatureExtractor,O_ as CohereAsrForConditionalGeneration,D_ as CohereAsrModel,E_ as CohereAsrPreTrainedModel,Hd as CohereAsrProcessor,eu as CohereAsrTokenizer,S_ as CohereForCausalLM,x_ as CohereModel,b_ as CoherePreTrainedModel,$l as CohereTokenizer,j_ as ConvBertForMaskedLM,P_ as ConvBertForQuestionAnswering,M_ as ConvBertForSequenceClassification,N_ as ConvBertForTokenClassification,A_ as ConvBertModel,k_ as ConvBertPreTrainedModel,tu as ConvBertTokenizer,_f as ConvNextFeatureExtractor,L_ as ConvNextForImageClassification,gf as ConvNextImageProcessor,I_ as ConvNextModel,F_ as ConvNextPreTrainedModel,B_ as ConvNextV2ForImageClassification,z_ as ConvNextV2Model,R_ as ConvNextV2PreTrainedModel,q_ as DFineForObjectDetection,K_ as DFineModel,G_ as DFinePreTrainedModel,Lv as DINOv3ConvNextModel,Iv as DINOv3ConvNextPreTrainedModel,Sf as DINOv3ViTImageProcessor,zv as DINOv3ViTModel,Rv as DINOv3ViTPreTrainedModel,Ef as DPTFeatureExtractor,Xv as DPTForDepthEstimation,Tf as DPTImageProcessor,Yv as DPTModel,Jv as DPTPreTrainedModel,$_ as DacDecoderModel,Y_ as DacDecoderOutput,Q_ as DacEncoderModel,J_ as DacEncoderOutput,Ed as DacFeatureExtractor,Z_ as DacModel,X_ as DacPreTrainedModel,nv as DebertaForMaskedLM,av as DebertaForQuestionAnswering,rv as DebertaForSequenceClassification,iv as DebertaForTokenClassification,tv as DebertaModel,ev as DebertaPreTrainedModel,ru as DebertaTokenizer,dv as DebertaV2ForMaskedLM,mv as DebertaV2ForQuestionAnswering,fv as DebertaV2ForSequenceClassification,pv as DebertaV2ForTokenClassification,uv as DebertaV2Model,lv as DebertaV2PreTrainedModel,nu as DebertaV2Tokenizer,gv as DecisionTransformerModel,hv as DecisionTransformerPreTrainedModel,cv as DeepseekV3ForCausalLM,sv as DeepseekV3Model,ov as DeepseekV3PreTrainedModel,yf as DeiTFeatureExtractor,yv as DeiTForImageClassification,vf as DeiTImageProcessor,vv as DeiTModel,_v as DeiTPreTrainedModel,xv as DepthAnythingForDepthEstimation,bv as DepthAnythingPreTrainedModel,Yk as DepthEstimationPipeline,Cv as DepthProForDepthEstimation,Sv as DepthProPreTrainedModel,xf as DetrFeatureExtractor,Ev as DetrForObjectDetection,Dv as DetrForSegmentation,bf as DetrImageProcessor,Tv as DetrModel,Ov as DetrObjectDetectionOutput,wv as DetrPreTrainedModel,kv as DetrSegmentationOutput,Mv as Dinov2ForImageClassification,jv as Dinov2Model,Av as Dinov2PreTrainedModel,Fv as Dinov2WithRegistersForImageClassification,Pv as Dinov2WithRegistersModel,Nv as Dinov2WithRegistersPreTrainedModel,Gv as DistilBertForMaskedLM,Wv as DistilBertForQuestionAnswering,Hv as DistilBertForSequenceClassification,Uv as DistilBertForTokenClassification,Vv as DistilBertModel,Bv as DistilBertPreTrainedModel,iu as DistilBertTokenizer,qk as DocumentQuestionAnsweringPipeline,wf as DonutFeatureExtractor,Cf as DonutImageProcessor,qv as DonutSwinModel,Kv as DonutSwinPreTrainedModel,Sh as DynamicCache,DT as EdgeTamModel,$v as EfficientNetForImageClassification,Df as EfficientNetImageProcessor,Qv as EfficientNetModel,Zv as EfficientNetPreTrainedModel,ny as ElectraForMaskedLM,ay as ElectraForQuestionAnswering,ry as ElectraForSequenceClassification,iy as ElectraForTokenClassification,ty as ElectraModel,ey as ElectraPreTrainedModel,au as ElectraTokenizer,bd as EncodecFeatureExtractor,gh as EosTokenCriteria,cy as Ernie4_5ForCausalLM,sy as Ernie4_5Model,oy as Ernie4_5PretrainedModel,dy as EsmForMaskedLM,fy as EsmForSequenceClassification,py as EsmForTokenClassification,uy as EsmModel,ly as EsmPreTrainedModel,ou as EsmTokenizer,gy as EuroBertForMaskedLM,_y as EuroBertForSequenceClassification,vy as EuroBertForTokenClassification,hy as EuroBertModel,my as EuroBertPreTrainedModel,xy as ExaoneForCausalLM,by as ExaoneModel,yy as ExaonePreTrainedModel,wy as FalconForCausalLM,Dy as FalconH1ForCausalLM,Ey as FalconH1Model,Ty as FalconH1PreTrainedModel,Cy as FalconModel,Sy as FalconPreTrainedModel,su as FalconTokenizer,Ay as FastViTForImageClassification,ky as FastViTModel,Oy as FastViTPreTrainedModel,Xk as FeatureExtractionPipeline,qu as FeatureExtractor,Ok as FillMaskPipeline,My as Florence2ForConditionalGeneration,jy as Florence2PreTrainedModel,Mp as Florence2Processor,Qm as ForcedBOSTokenLogitsProcessor,$m as ForcedEOSTokenLogitsProcessor,Pf as GLPNFeatureExtractor,fb as GLPNForDepthEstimation,db as GLPNModel,ub as GLPNPreTrainedModel,Db as GPT2LMHeadModel,Eb as GPT2Model,Tb as GPT2PreTrainedModel,uu as GPT2Tokenizer,hb as GPTBigCodeForCausalLM,mb as GPTBigCodeModel,pb as GPTBigCodePreTrainedModel,Ab as GPTJForCausalLM,kb as GPTJModel,Ob as GPTJPreTrainedModel,vb as GPTNeoForCausalLM,_b as GPTNeoModel,gb as GPTNeoPreTrainedModel,xb as GPTNeoXForCausalLM,bb as GPTNeoXModel,yb as GPTNeoXPreTrainedModel,lu as GPTNeoXTokenizer,Ry as Gemma2ForCausalLM,Ly as Gemma2Model,Iy as Gemma2PreTrainedModel,Ky as Gemma3ForCausalLM,Gy as Gemma3ForConditionalGeneration,Of as Gemma3ImageProcessor,Wy as Gemma3Model,Uy as Gemma3PreTrainedModel,Np as Gemma3Processor,Dd as Gemma3nAudioFeatureExtractor,Yy as Gemma3nForCausalLM,Jy as Gemma3nForConditionalGeneration,qy as Gemma3nPreTrainedModel,Pp as Gemma3nProcessor,Od as Gemma4AudioFeatureExtractor,Zy as Gemma4ForCausalLM,Xy as Gemma4ForConditionalGeneration,jf as Gemma4ImageProcessor,Fp as Gemma4Processor,Fy as GemmaForCausalLM,Py as GemmaModel,Ny as GemmaPreTrainedModel,cu as GemmaTokenizer,Nf as Glm46VImageProcessor,Lp as Glm46VProcessor,eb as GlmForCausalLM,$y as GlmModel,rb as GlmMoeDsaForCausalLM,nb as GlmMoeDsaModel,tb as GlmMoeDsaPreTrainedModel,lb as GlmOcrForConditionalGeneration,Qy as GlmPreTrainedModel,wb as GptOssForCausalLM,Cb as GptOssModel,Sb as GptOssPreTrainedModel,Nb as GraniteForCausalLM,Mb as GraniteModel,Ib as GraniteMoeHybridForCausalLM,Fb as GraniteMoeHybridModel,Pb as GraniteMoeHybridPreTrainedModel,jb as GranitePreTrainedModel,kd as GraniteSpeechFeatureExtractor,zb as GraniteSpeechForConditionalGeneration,Rp as GraniteSpeechProcessor,Vb as GroundingDinoForObjectDetection,Ff as GroundingDinoImageProcessor,Bb as GroundingDinoPreTrainedModel,Bp as GroundingDinoProcessor,Ub as GroupViTModel,Hb as GroupViTPreTrainedModel,Kb as HeliumForCausalLM,Gb as HeliumModel,Wb as HeliumPreTrainedModel,du as HerbertTokenizer,Yb as HieraForImageClassification,Jb as HieraModel,qb as HieraPreTrainedModel,rx as HubertForCTC,ix as HubertForSequenceClassification,nx as HubertModel,tx as HubertPreTrainedModel,sx as HunYuanDenseV1ForCausalLM,ox as HunYuanDenseV1Model,ax as HunYuanDenseV1PreTrainedModel,dx as IJepaForImageClassification,ux as IJepaModel,lx as IJepaPreTrainedModel,cx as Idefics3ForConditionalGeneration,If as Idefics3ImageProcessor,If as SmolVLMImageProcessor,Wp as Idefics3Processor,Wp as SmolVLMProcessor,Bk as ImageClassificationPipeline,Zk as ImageFeatureExtractionPipeline,q as ImageFeatureExtractor,q as ImageProcessor,Hk as ImageSegmentationPipeline,Jk as ImageToImagePipeline,zk as ImageToTextPipeline,_h as InterruptableStoppingCriteria,mx as JAISLMHeadModel,px as JAISModel,fx as JAISPreTrainedModel,Rf as JinaCLIPImageProcessor,gx as JinaCLIPModel,hx as JinaCLIPPreTrainedModel,Kp as JinaCLIPProcessor,_x as JinaCLIPTextModel,vx as JinaCLIPVisionModel,xx as Lfm2ForCausalLM,bx as Lfm2Model,Tx as Lfm2MoeForCausalLM,wx as Lfm2MoeModel,Cx as Lfm2MoePreTrainedModel,yx as Lfm2PreTrainedModel,Ex as Lfm2VlForConditionalGeneration,Wf as Lfm2VlImageProcessor,qp as Lfm2VlProcessor,Sx as LightOnOcrForConditionalGeneration,ID as LiteWhisperForConditionalGeneration,jx as Llama4ForCausalLM,Ax as Llama4PreTrainedModel,kx as LlamaForCausalLM,Ox as LlamaModel,Dx as LlamaPreTrainedModel,fu as LlamaTokenizer,By as LlavaForConditionalGeneration,By as LlavaOnevisionForConditionalGeneration,Gf as LlavaOnevisionImageProcessor,zy as LlavaPreTrainedModel,Jp as LlavaProcessor,Hy as LlavaQwen2ForCausalLM,$r as LogLevel,Ym as LogitsProcessor,Zm as LogitsProcessorList,Xm as LogitsWarper,Px as LongT5ForConditionalGeneration,Nx as LongT5Model,Mx as LongT5PreTrainedModel,Lx as M2M100ForConditionalGeneration,Ix as M2M100Model,Fx as M2M100PreTrainedModel,pu as M2M100Tokenizer,gu as MBart50Tokenizer,Jx as MBartForCausalLM,Kx as MBartForConditionalGeneration,qx as MBartForSequenceClassification,Gx as MBartModel,Wx as MBartPreTrainedModel,hu as MBartTokenizer,rC as MPNetForMaskedLM,oC as MPNetForQuestionAnswering,iC as MPNetForSequenceClassification,aC as MPNetForTokenClassification,nC as MPNetModel,tC as MPNetPreTrainedModel,yu as MPNetTokenizer,fC as MT5ForConditionalGeneration,dC as MT5Model,uC as MT5PreTrainedModel,Bx as MarianMTModel,zx as MarianModel,Rx as MarianPreTrainedModel,mu as MarianTokenizer,Jf as Mask2FormerImageProcessor,qf as MaskFormerFeatureExtractor,Ux as MaskFormerForInstanceSegmentation,Kf as MaskFormerImageProcessor,Hx as MaskFormerModel,Vx as MaskFormerPreTrainedModel,hh as MaxLengthCriteria,Xx as Metric3DForDepthEstimation,Yx as Metric3DPreTrainedModel,Qx as Metric3Dv2ForDepthEstimation,Zx as Metric3Dv2PreTrainedModel,tS as MgpstrForSceneTextRecognition,$x as MgpstrModelOutput,eS as MgpstrPreTrainedModel,Xp as MgpstrProcessor,_u as MgpstrTokenizer,sS as MimiDecoderModel,rS as MimiDecoderOutput,oS as MimiEncoderModel,nS as MimiEncoderOutput,aS as MimiModel,iS as MimiPreTrainedModel,ah as MinLengthLogitsProcessor,oh as MinNewTokensLengthLogitsProcessor,pS as Mistral4ForCausalLM,fS as Mistral4Model,dS as Mistral4PreTrainedModel,uS as MistralForCausalLM,lS as MistralModel,cS as MistralPreTrainedModel,gS as MobileBertForMaskedLM,vS as MobileBertForQuestionAnswering,_S as MobileBertForSequenceClassification,hS as MobileBertModel,mS as MobileBertPreTrainedModel,vu as MobileBertTokenizer,xS as MobileLLMForCausalLM,bS as MobileLLMModel,yS as MobileLLMPreTrainedModel,Xf as MobileNetV1FeatureExtractor,wS as MobileNetV1ForImageClassification,TS as MobileNetV1ForSemanticSegmentation,Yf as MobileNetV1ImageProcessor,CS as MobileNetV1Model,SS as MobileNetV1PreTrainedModel,Qf as MobileNetV2FeatureExtractor,OS as MobileNetV2ForImageClassification,kS as MobileNetV2ForSemanticSegmentation,Zf as MobileNetV2ImageProcessor,DS as MobileNetV2Model,ES as MobileNetV2PreTrainedModel,ep as MobileNetV3FeatureExtractor,MS as MobileNetV3ForImageClassification,NS as MobileNetV3ForSemanticSegmentation,$f as MobileNetV3ImageProcessor,jS as MobileNetV3Model,AS as MobileNetV3PreTrainedModel,np as MobileNetV4FeatureExtractor,IS as MobileNetV4ForImageClassification,LS as MobileNetV4ForSemanticSegmentation,tp as MobileNetV4ImageProcessor,FS as MobileNetV4Model,PS as MobileNetV4PreTrainedModel,ip as MobileViTFeatureExtractor,BS as MobileViTForImageClassification,rp as MobileViTImageProcessor,zS as MobileViTModel,RS as MobileViTPreTrainedModel,US as MobileViTV2ForImageClassification,HS as MobileViTV2Model,VS as MobileViTV2PreTrainedModel,CA as ModelRegistry,ZS as ModernBertDecoderForCausalLM,XS as ModernBertDecoderModel,YS as ModernBertDecoderPreTrainedModel,KS as ModernBertForMaskedLM,qS as ModernBertForSequenceClassification,JS as ModernBertForTokenClassification,GS as ModernBertModel,WS as ModernBertPreTrainedModel,Vy as Moondream1ForConditionalGeneration,Ad as MoonshineFeatureExtractor,eC as MoonshineForConditionalGeneration,$S as MoonshineModel,QS as MoonshinePreTrainedModel,Zp as MoonshineProcessor,lC as MptForCausalLM,cC as MptModel,sC as MptPreTrainedModel,mC as MultiModalityCausalLM,pC as MultiModalityPreTrainedModel,_C as MusicgenForCausalLM,vC as MusicgenForConditionalGeneration,gC as MusicgenModel,hC as MusicgenPreTrainedModel,xC as NanoChatForCausalLM,bC as NanoChatModel,yC as NanoChatPreTrainedModel,wC as NemotronHForCausalLM,CC as NemotronHModel,SC as NemotronHPreTrainedModel,DC as NeoBertForMaskedLM,AC as NeoBertForQuestionAnswering,OC as NeoBertForSequenceClassification,kC as NeoBertForTokenClassification,EC as NeoBertModel,TC as NeoBertPreTrainedModel,bu as NllbTokenizer,sh as NoBadWordsLogitsProcessor,rh as NoRepeatNGramLogitsProcessor,MC as NomicBertModel,jC as NomicBertPreTrainedModel,ap as NougatImageProcessor,xu as NougatTokenizer,$C as OPTForCausalLM,QC as OPTModel,ZC as OPTPreTrainedModel,Gk as ObjectDetectionPipeline,RC as Olmo2ForCausalLM,LC as Olmo2Model,IC as Olmo2PreTrainedModel,VC as Olmo3ForCausalLM,BC as Olmo3Model,zC as Olmo3PreTrainedModel,FC as OlmoForCausalLM,WC as OlmoHybridForCausalLM,UC as OlmoHybridModel,HC as OlmoHybridPreTrainedModel,PC as OlmoModel,NC as OlmoPreTrainedModel,qC as OpenAIPrivacyFilterForTokenClassification,KC as OpenAIPrivacyFilterModel,GC as OpenAIPrivacyFilterPreTrainedModel,XC as OpenELMForCausalLM,YC as OpenELMModel,JC as OpenELMPreTrainedModel,sp as OwlViTFeatureExtractor,aw as OwlViTForObjectDetection,op as OwlViTImageProcessor,iw as OwlViTModel,rw as OwlViTPreTrainedModel,Qp as OwlViTProcessor,nw as Owlv2ForObjectDetection,cp as Owlv2ImageProcessor,tw as Owlv2Model,ew as Owlv2PreTrainedModel,ow as PaliGemmaForConditionalGeneration,tm as PaliGemmaProcessor,wd as ParakeetFeatureExtractor,cw as ParakeetForCTC,sw as ParakeetPreTrainedModel,dw as PatchTSMixerForPrediction,uw as PatchTSMixerModel,lw as PatchTSMixerPreTrainedModel,mw as PatchTSTForPrediction,pw as PatchTSTModel,fw as PatchTSTPreTrainedModel,bw as Phi3ForCausalLM,yw as Phi3Model,vw as Phi3PreTrainedModel,Sw as Phi3VForCausalLM,mp as Phi3VImageProcessor,xw as Phi3VPreTrainedModel,im as Phi3VProcessor,_w as PhiForCausalLM,gw as PhiModel,hw as PhiPreTrainedModel,hp as PixtralImageProcessor,am as PixtralProcessor,Z as PreTrainedModel,W as PreTrainedTokenizer,W as TokenizersBackend,Nm as PretrainedConfig,K as Processor,Tw as PvtForImageClassification,gp as PvtImageProcessor,ww as PvtModel,Cw as PvtPreTrainedModel,jd as PyAnnoteFeatureExtractor,Ow as PyAnnoteForAudioFrameClassification,Dw as PyAnnoteModel,Ew as PyAnnotePreTrainedModel,om as PyAnnoteProcessor,Dk as QuestionAnsweringPipeline,jw as Qwen2ForCausalLM,Aw as Qwen2Model,Pw as Qwen2MoeForCausalLM,Nw as Qwen2MoeModel,Mw as Qwen2MoePreTrainedModel,kw as Qwen2PreTrainedModel,Su as Qwen2Tokenizer,ob as Qwen2VLForCausalLM,ab as Qwen2VLForConditionalGeneration,Mf as Qwen2VLImageProcessor,ib as Qwen2VLPreTrainedModel,Ip as Qwen2VLProcessor,cb as Qwen2_5_VLForCausalLM,sb as Qwen2_5_VLForConditionalGeneration,sm as Qwen2_5_VLProcessor,Lw as Qwen3ForCausalLM,Iw as Qwen3Model,Bw as Qwen3MoeForCausalLM,zw as Qwen3MoeModel,Rw as Qwen3MoePreTrainedModel,Uw as Qwen3NextForCausalLM,Hw as Qwen3NextModel,Vw as Qwen3NextPreTrainedModel,Fw as Qwen3PreTrainedModel,Gw as Qwen3VLForCausalLM,Ww as Qwen3VLForConditionalGeneration,qw as Qwen3VLMoeForCausalLM,Kw as Qwen3VLMoeForConditionalGeneration,cm as Qwen3VLProcessor,Yw as Qwen3_5ForCausalLM,Jw as Qwen3_5ForConditionalGeneration,Zw as Qwen3_5MoeForCausalLM,Xw as Qwen3_5MoeForConditionalGeneration,rT as RFDetrForObjectDetection,nT as RFDetrModel,iT as RFDetrObjectDetectionOutput,tT as RFDetrPreTrainedModel,U_ as RTDetrForObjectDetection,_p as RTDetrImageProcessor,H_ as RTDetrModel,W_ as RTDetrObjectDetectionOutput,V_ as RTDetrPreTrainedModel,yT as RTDetrV2ForObjectDetection,vT as RTDetrV2Model,bT as RTDetrV2ObjectDetectionOutput,_T as RTDetrV2PreTrainedModel,vd as RawAudio,Yd as RawImage,uA as RawVideo,lA as RawVideoFrame,ih as RepetitionPenaltyLogitsProcessor,eT as ResNetForImageClassification,$w as ResNetModel,Qw as ResNetPreTrainedModel,pT as RoFormerForMaskedLM,gT as RoFormerForQuestionAnswering,mT as RoFormerForSequenceClassification,hT as RoFormerForTokenClassification,fT as RoFormerModel,dT as RoFormerPreTrainedModel,wu as RoFormerTokenizer,sT as RobertaForMaskedLM,uT as RobertaForQuestionAnswering,cT as RobertaForSequenceClassification,lT as RobertaForTokenClassification,oT as RobertaModel,aT as RobertaPreTrainedModel,Cu as RobertaTokenizer,vp as Sam2ImageProcessor,vp as Sam3ImageProcessor,vp as SamImageProcessor,wT as Sam2ImageSegmentationOutput,ET as Sam2Model,TT as Sam2PreTrainedModel,um as Sam2Processor,dm as Sam2VideoProcessor,OT as Sam3TrackerModel,xT as SamImageSegmentationOutput,CT as SamModel,ST as SamPreTrainedModel,lm as SamProcessor,bp as SapiensFeatureExtractor,jT as SapiensForDepthEstimation,MT as SapiensForNormalEstimation,AT as SapiensForSemanticSegmentation,yp as SapiensImageProcessor,kT as SapiensPreTrainedModel,Md as SeamlessM4TFeatureExtractor,Sp as SegformerFeatureExtractor,FT as SegformerForImageClassification,IT as SegformerForSemanticSegmentation,xp as SegformerImageProcessor,PT as SegformerModel,NT as SegformerPreTrainedModel,Cp as SiglipImageProcessor,RT as SiglipModel,LT as SiglipPreTrainedModel,zT as SiglipTextModel,Tu as SiglipTokenizer,BT as SiglipVisionModel,UT as SmolLM3ForCausalLM,HT as SmolLM3Model,VT as SmolLM3PreTrainedModel,WT as SmolVLMForConditionalGeneration,JT as SnacDecoderModel,qT as SnacEncoderModel,Nd as SnacFeatureExtractor,KT as SnacModel,GT as SnacPreTrainedModel,ZT as SolarOpenForCausalLM,XT as SolarOpenModel,YT as SolarOpenPreTrainedModel,Pd as SpeechT5FeatureExtractor,eE as SpeechT5ForSpeechToText,tE as SpeechT5ForTextToSpeech,nE as SpeechT5HifiGan,$T as SpeechT5Model,QT as SpeechT5PreTrainedModel,fm as SpeechT5Processor,Eu as SpeechT5Tokenizer,aE as SqueezeBertForMaskedLM,sE as SqueezeBertForQuestionAnswering,oE as SqueezeBertForSequenceClassification,iE as SqueezeBertModel,rE as SqueezeBertPreTrainedModel,Du as SqueezeBertTokenizer,uE as StableLmForCausalLM,lE as StableLmModel,cE as StableLmPreTrainedModel,pE as Starcoder2ForCausalLM,fE as Starcoder2Model,dE as Starcoder2PreTrainedModel,ph as StoppingCriteria,mh as StoppingCriteriaList,hE as StyleTextToSpeech2Model,mE as StyleTextToSpeech2PreTrainedModel,Ak as SummarizationPipeline,_E as SupertonicForConditionalGeneration,gE as SupertonicPreTrainedModel,th as SuppressTokensAtBeginLogitsProcessor,eh as SuppressTokensLogitsProcessor,wE as Swin2SRForImageSuperResolution,wp as Swin2SRImageProcessor,CE as Swin2SRModel,SE as Swin2SRPreTrainedModel,bE as SwinForImageClassification,xE as SwinForSemanticSegmentation,yE as SwinModel,vE as SwinPreTrainedModel,DE as T5ForConditionalGeneration,EE as T5Model,TE as T5PreTrainedModel,Ou as T5Tokenizer,AE as TableTransformerForObjectDetection,kE as TableTransformerModel,jE as TableTransformerObjectDetectionOutput,OE as TableTransformerPreTrainedModel,lh as TemperatureLogitsWarper,U as Tensor,kk as Text2TextGenerationPipeline,Ck as TextClassificationPipeline,Nk as TextGenerationPipeline,sA as TextStreamer,Rk as TextToAudioPipeline,wk as TokenClassificationPipeline,dh as TopKLogitsWarper,uh as TopPLogitsWarper,NE as TrOCRForCausalLM,ME as TrOCRPreTrainedModel,jk as TranslationPipeline,Rb as UltravoxModel,Lb as UltravoxPreTrainedModel,pm as UltravoxProcessor,IE as UniSpeechForCTC,LE as UniSpeechForSequenceClassification,FE as UniSpeechModel,PE as UniSpeechPreTrainedModel,HE as UniSpeechSatForAudioFrameClassification,BE as UniSpeechSatForCTC,VE as UniSpeechSatForSequenceClassification,zE as UniSpeechSatModel,RE as UniSpeechSatPreTrainedModel,Gp as VLChatProcessor,Lf as VLMImageProcessor,GE as VaultGemmaForCausalLM,WE as VaultGemmaModel,UE as VaultGemmaPreTrainedModel,Ep as ViTFeatureExtractor,YE as ViTForImageClassification,Tp as ViTImageProcessor,ZE as ViTMAEModel,XE as ViTMAEPreTrainedModel,eD as ViTMSNForImageClassification,$E as ViTMSNModel,QE as ViTMSNPreTrainedModel,JE as ViTModel,qE as ViTPreTrainedModel,KE as VisionEncoderDecoderModel,nD as VitMatteForImageMatting,Dp as VitMatteImageProcessor,tD as VitMattePreTrainedModel,iD as VitPoseForPoseEstimation,Op as VitPoseImageProcessor,rD as VitPosePreTrainedModel,sD as VitsModel,aD as VitsModelOutput,oD as VitsPreTrainedModel,Au as VitsTokenizer,cD as VoxtralForConditionalGeneration,vm as VoxtralProcessor,Ld as VoxtralRealtimeFeatureExtractor,vD as VoxtralRealtimeForConditionalGeneration,_D as VoxtralRealtimePreTrainedModel,wm as VoxtralRealtimeProcessor,xD as Wav2Vec2BertForCTC,SD as Wav2Vec2BertForSequenceClassification,bD as Wav2Vec2BertModel,yD as Wav2Vec2BertPreTrainedModel,ju as Wav2Vec2CTCTokenizer,Fd as Wav2Vec2FeatureExtractor,ex as Wav2Vec2ForAudioFrameClassification,Qb as Wav2Vec2ForCTC,$b as Wav2Vec2ForSequenceClassification,Zb as Wav2Vec2Model,Xb as Wav2Vec2PreTrainedModel,Tm as Wav2Vec2Processor,Em as Wav2Vec2ProcessorWithLM,kD as WavLMForAudioFrameClassification,ED as WavLMForCTC,DD as WavLMForSequenceClassification,OD as WavLMForXVector,TD as WavLMModel,wD as WavLMPreTrainedModel,Id as WeSpeakerFeatureExtractor,jD as WeSpeakerResNetModel,AD as WeSpeakerResNetPreTrainedModel,Rd as WhisperFeatureExtractor,FD as WhisperForConditionalGeneration,PD as WhisperModel,ND as WhisperPreTrainedModel,Dm as WhisperProcessor,cA as WhisperTextStreamer,nh as WhisperTimeStampLogitsProcessor,Ru as WhisperTokenizer,HD as XLMForQuestionAnswering,BD as XLMForSequenceClassification,VD as XLMForTokenClassification,RD as XLMModel,LD as XLMPreTrainedModel,GD as XLMRobertaForMaskedLM,JD as XLMRobertaForQuestionAnswering,KD as XLMRobertaForSequenceClassification,qD as XLMRobertaForTokenClassification,WD as XLMRobertaModel,UD as XLMRobertaPreTrainedModel,zu as XLMRobertaTokenizer,Bu as XLMTokenizer,zD as XLMWithLMHeadModel,CD as XVectorOutput,Ap as YolosFeatureExtractor,ZD as YolosForObjectDetection,kp as YolosImageProcessor,XD as YolosModel,QD as YolosObjectDetectionOutput,YD as YolosPreTrainedModel,tO as YoutuForCausalLM,eO as YoutuModel,$D as YoutuPreTrainedModel,Ik as ZeroShotAudioClassificationPipeline,Pk as ZeroShotClassificationPipeline,Wk as ZeroShotImageClassificationPipeline,Kk as ZeroShotObjectDetectionPipeline,_l as cat,lc as cos_sim,cc as dot,M as env,wl as full,Tl as full_like,al as interpolate,ol as interpolate_4d,pl as layer_norm,Qu as load_audio,Xd as load_image,dA as load_video,sc as log_softmax,sl as matmul,xl as mean,fl as mean_pooling,El as ones,Dl as ones_like,il as permute,rA as pipeline,Ml as quantize_embeddings,Al as rand,jl as randn,Cs as random,$u as read_audio,cl as rfft,dl as slice,oc as softmax,vl as stack,bl as std_mean,ll as topk,Ol as zeros,kl as zeros_like};
|
|
39
|
+
`)}},cA=class extends sA{constructor(e,{skip_prompt:t=!1,callback_function:n=null,token_callback_function:r=null,on_chunk_start:i=null,on_chunk_end:a=null,on_finalize:o=null,time_precision:s=.02,skip_special_tokens:c=!0,decode_kwargs:l={}}={}){super(e,{skip_prompt:t,skip_special_tokens:c,callback_function:n,token_callback_function:r,decode_kwargs:l}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=i,this.on_chunk_end=a,this.on_finalize=o,this.time_precision=s,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error(`WhisperTextStreamer only supports batch size of 1`);let t=e[0];if(t.length===1){let e=Number(t[0])-this.timestamp_begin;if(e>=0){let n=e*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?.(t);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}},lA=class{constructor(e,t){this.image=e,this.timestamp=t}},uA=class{constructor(e,t){e.length>0&&e[0]instanceof Yd&&(e=e.map((n,r)=>new lA(n,(r+1)/(e.length+1)*t))),this.frames=e,this.duration=t}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 dA(e,{num_frames:t=null,fps:n=null}={}){if(!j.IS_BROWSER_ENV)throw Error("`load_video` is currently only supported in browser environments.");if(t==null&&n==null)throw Error(`Either num_frames or fps must be provided.`);let r=[],i=document.createElement(`video`);if(i.crossOrigin=`anonymous`,i.muted=!0,typeof e==`string`)i.src=e;else if(e instanceof Blob)i.src=URL.createObjectURL(e);else if(e instanceof HTMLVideoElement)i.src=e.src;else throw Error(`Invalid URL or video element provided.`);if(await new Promise(e=>i.onloadedmetadata=e),i.seekable.start(0)===i.seekable.end(0)){let e=await(await M.fetch(i.src)).blob();i.src=URL.createObjectURL(e),await new Promise(e=>i.onloadedmetadata=e)}let a=i.duration,o,s;t==null?(s=1/n,o=Math.floor(a/s)):(o=t,s=t===1?0:a/(t-1));let c=[];for(let e=0;e<o;++e)c.push(t===1?a/2:e*s);let l=document.createElement(`canvas`);l.width=i.videoWidth,l.height=i.videoHeight;let u=l.getContext(`2d`,{willReadFrequently:!0});for(let e of c){i.currentTime=e,await new Promise(e=>{i.onseeked=e}),u.drawImage(i,0,0,l.width,l.height);let t=new lA(new Yd(u.getImageData(0,0,l.width,l.height).data,l.width,l.height,4),e);r.push(t)}return i.remove(),new uA(r,a)}async function fA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return{allCached:!1,files:t.map(e=>({file:e,cached:!1}))};let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r);return{file:t,cached:!!await Zs(r,i,a)}}));return{allCached:i.every(e=>e.cached),files:i}}async function pA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return!1;let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r);return!!await Zs(r,i,a)}async function mA(e,t={}){if(!e)throw Error(`modelId is required`);return await pA(e,`config.json`,t)?(await fA(e,await tA(e,t),t)).allCached:!1}async function hA(e,t={}){if(!e)throw Error(`modelId is required`);return await fA(e,await tA(e,t),t)}async function gA(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await pA(t,`config.json`,n)?(await fA(t,await nA(e,t,n),n)).allCached:!1}async function _A(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await fA(t,await nA(e,t,n),n)}async function vA(e,t,n={}){let r=await Vs(n?.cache_dir);if(!r)return{filesDeleted:0,filesCached:0,files:t.map(e=>({file:e,deleted:!1,wasCached:!1}))};if(!r.delete)throw Error(`Cache does not support delete operation`);let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=Xs(e,t,n,r),o=!!await Zs(r,i,a),s=!1;if(o){let e=await r.delete(a),t=!e&&a!==i&&await r.delete(i);s=e||t}return{file:t,deleted:s,wasCached:o}}));return{filesDeleted:i.filter(e=>e.deleted).length,filesCached:i.filter(e=>e.wasCached).length,files:i}}async function yA(e,t={}){if(!e)throw Error(`modelId is required`);return await vA(e,await tA(e,t),t)}async function bA(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await vA(t,await nA(e,t,n),n)}var xA=Object.keys(el);async function SA(e,{config:t=null,model_file_name:n=null,revision:r=`main`,cache_dir:i=null,local_files_only:a=!1}={}){t=await Dh(e,{config:t,cache_dir:i,local_files_only:a,revision:r});let{sessions:o}=Th(Eh(t),t,{model_file_name:n}),s=Object.values(o),c={revision:r,cache_dir:i,local_files_only:a};return(await Promise.all(xA.map(async t=>{let n=el[t]??``;return{dtype:t,available:(await Promise.all(s.map(async t=>(await Ks(e,`onnx/${t}${n}.onnx`,c)).exists))).every(Boolean)}}))).filter(e=>e.available).map(e=>e.dtype)}var CA=class{static async get_files(e,t={}){return tA(e,t)}static async get_pipeline_files(e,t,n={}){return nA(e,t,n)}static async get_model_files(e,t={}){return Oh(e,t)}static async get_tokenizer_files(e){return Nl(e)}static async get_processor_files(e){return eA(e)}static async get_available_dtypes(e,t={}){return SA(e,t)}static async is_cached(e,t={}){return mA(e,t)}static async is_cached_files(e,t={}){return hA(e,t)}static async is_pipeline_cached(e,t,n={}){return gA(e,t,n)}static async is_pipeline_cached_files(e,t,n={}){return _A(e,t,n)}static async get_file_metadata(e,t,n={}){return Ks(e,t,n)}static async clear_cache(e,t={}){return yA(e,t)}static async clear_pipeline_cache(e,t,n={}){return bA(e,t,n)}};export{yd as ASTFeatureExtractor,xg as ASTForAudioClassification,bg as ASTModel,yg as ASTPreTrainedModel,hg as AfmoeForCausalLM,mg as AfmoeModel,pg as AfmoePreTrainedModel,lg as AlbertForMaskedLM,cg as AlbertForQuestionAnswering,sg as AlbertForSequenceClassification,og as AlbertModel,ag as AlbertPreTrainedModel,Ul as AlbertTokenizer,fg as ApertusForCausalLM,dg as ApertusModel,ug as ApertusPreTrainedModel,vg as ArceeForCausalLM,_g as ArceeModel,gg as ArceePreTrainedModel,Fk as AudioClassificationPipeline,Pm as AutoConfig,zd as AutoFeatureExtractor,jp as AutoImageProcessor,HO as AutoModel,sk as AutoModelForAudioClassification,lk as AutoModelForAudioFrameClassification,vk as AutoModelForAudioTextToText,ok as AutoModelForCTC,YO as AutoModelForCausalLM,pk as AutoModelForDepthEstimation,uk as AutoModelForDocumentQuestionAnswering,$O as AutoModelForImageClassification,gk as AutoModelForImageFeatureExtraction,dk as AutoModelForImageMatting,ek as AutoModelForImageSegmentation,_k as AutoModelForImageTextToText,fk as AutoModelForImageToImage,ak as AutoModelForMaskGeneration,XO as AutoModelForMaskedLM,mk as AutoModelForNormalEstimation,rk as AutoModelForObjectDetection,hk as AutoModelForPoseEstimation,ZO as AutoModelForQuestionAnswering,tk as AutoModelForSemanticSegmentation,GO as AutoModelForSeq2SeqLM,UO as AutoModelForSequenceClassification,KO as AutoModelForSpeechSeq2Seq,qO as AutoModelForTextToSpectrogram,JO as AutoModelForTextToWaveform,WO as AutoModelForTokenClassification,nk as AutoModelForUniversalSegmentation,QO as AutoModelForVision2Seq,ck as AutoModelForXVector,ik as AutoModelForZeroShotObjectDetection,Om as AutoProcessor,G as AutoTokenizer,Lk as AutomaticSpeechRecognitionPipeline,Uk as BackgroundRemovalPipeline,wg as BartForConditionalGeneration,Tg as BartForSequenceClassification,Cg as BartModel,Sg as BartPretrainedModel,Wl as BartTokenizer,aA as BaseStreamer,uf as BeitFeatureExtractor,Og as BeitForImageClassification,Dg as BeitModel,Eg as BeitPreTrainedModel,jg as BertForMaskedLM,Pg as BertForQuestionAnswering,Mg as BertForSequenceClassification,Ng as BertForTokenClassification,Ag as BertModel,kg as BertPreTrainedModel,Gl as BertTokenizer,df as BitImageProcessor,Lg as BlenderbotForConditionalGeneration,Ig as BlenderbotModel,Fg as BlenderbotPreTrainedModel,Bg as BlenderbotSmallForConditionalGeneration,zg as BlenderbotSmallModel,Rg as BlenderbotSmallPreTrainedModel,Kl as BlenderbotSmallTokenizer,ql as BlenderbotTokenizer,Ug as BloomForCausalLM,Hg as BloomModel,Vg as BloomPreTrainedModel,Jl as BloomTokenizer,r_ as CHMv2ForDepthEstimation,pf as CHMv2ImageProcessor,n_ as CHMv2PreTrainedModel,hf as CLIPFeatureExtractor,mf as CLIPImageProcessor,l_ as CLIPModel,c_ as CLIPPreTrainedModel,g_ as CLIPSegForImageSegmentation,h_ as CLIPSegModel,m_ as CLIPSegPreTrainedModel,u_ as CLIPTextModel,d_ as CLIPTextModelWithProjection,Xl as CLIPTokenizer,f_ as CLIPVisionModel,p_ as CLIPVisionModelWithProjection,Kg as CamembertForMaskedLM,Yg as CamembertForQuestionAnswering,qg as CamembertForSequenceClassification,Jg as CamembertForTokenClassification,Gg as CamembertModel,Wg as CamembertPreTrainedModel,Yl as CamembertTokenizer,xd as ChatterboxFeatureExtractor,$g as ChatterboxModel,Qg as ChatterboxPreTrainedModel,Bd as ChatterboxProcessor,ff as ChineseCLIPFeatureExtractor,t_ as ChineseCLIPModel,e_ as ChineseCLIPPreTrainedModel,s_ as ClapAudioModelWithProjection,Sd as ClapFeatureExtractor,a_ as ClapModel,i_ as ClapPreTrainedModel,o_ as ClapTextModelWithProjection,ch as ClassifierFreeGuidanceLogitsProcessor,y_ as CodeGenForCausalLM,v_ as CodeGenModel,__ as CodeGenPreTrainedModel,Ql as CodeGenTokenizer,Zl as CodeLlamaTokenizer,T_ as Cohere2ForCausalLM,w_ as Cohere2Model,C_ as Cohere2PreTrainedModel,Td as CohereAsrFeatureExtractor,O_ as CohereAsrForConditionalGeneration,D_ as CohereAsrModel,E_ as CohereAsrPreTrainedModel,Hd as CohereAsrProcessor,eu as CohereAsrTokenizer,S_ as CohereForCausalLM,x_ as CohereModel,b_ as CoherePreTrainedModel,$l as CohereTokenizer,j_ as ConvBertForMaskedLM,P_ as ConvBertForQuestionAnswering,M_ as ConvBertForSequenceClassification,N_ as ConvBertForTokenClassification,A_ as ConvBertModel,k_ as ConvBertPreTrainedModel,tu as ConvBertTokenizer,_f as ConvNextFeatureExtractor,L_ as ConvNextForImageClassification,gf as ConvNextImageProcessor,I_ as ConvNextModel,F_ as ConvNextPreTrainedModel,B_ as ConvNextV2ForImageClassification,z_ as ConvNextV2Model,R_ as ConvNextV2PreTrainedModel,q_ as DFineForObjectDetection,K_ as DFineModel,G_ as DFinePreTrainedModel,Lv as DINOv3ConvNextModel,Iv as DINOv3ConvNextPreTrainedModel,Sf as DINOv3ViTImageProcessor,zv as DINOv3ViTModel,Rv as DINOv3ViTPreTrainedModel,Ef as DPTFeatureExtractor,Xv as DPTForDepthEstimation,Tf as DPTImageProcessor,Yv as DPTModel,Jv as DPTPreTrainedModel,$_ as DacDecoderModel,Y_ as DacDecoderOutput,Q_ as DacEncoderModel,J_ as DacEncoderOutput,Ed as DacFeatureExtractor,Z_ as DacModel,X_ as DacPreTrainedModel,nv as DebertaForMaskedLM,av as DebertaForQuestionAnswering,rv as DebertaForSequenceClassification,iv as DebertaForTokenClassification,tv as DebertaModel,ev as DebertaPreTrainedModel,ru as DebertaTokenizer,dv as DebertaV2ForMaskedLM,mv as DebertaV2ForQuestionAnswering,fv as DebertaV2ForSequenceClassification,pv as DebertaV2ForTokenClassification,uv as DebertaV2Model,lv as DebertaV2PreTrainedModel,nu as DebertaV2Tokenizer,gv as DecisionTransformerModel,hv as DecisionTransformerPreTrainedModel,cv as DeepseekV3ForCausalLM,sv as DeepseekV3Model,ov as DeepseekV3PreTrainedModel,yf as DeiTFeatureExtractor,yv as DeiTForImageClassification,vf as DeiTImageProcessor,vv as DeiTModel,_v as DeiTPreTrainedModel,xv as DepthAnythingForDepthEstimation,bv as DepthAnythingPreTrainedModel,Yk as DepthEstimationPipeline,Cv as DepthProForDepthEstimation,Sv as DepthProPreTrainedModel,xf as DetrFeatureExtractor,Ev as DetrForObjectDetection,Dv as DetrForSegmentation,bf as DetrImageProcessor,Tv as DetrModel,Ov as DetrObjectDetectionOutput,wv as DetrPreTrainedModel,kv as DetrSegmentationOutput,Mv as Dinov2ForImageClassification,jv as Dinov2Model,Av as Dinov2PreTrainedModel,Fv as Dinov2WithRegistersForImageClassification,Pv as Dinov2WithRegistersModel,Nv as Dinov2WithRegistersPreTrainedModel,Gv as DistilBertForMaskedLM,Wv as DistilBertForQuestionAnswering,Hv as DistilBertForSequenceClassification,Uv as DistilBertForTokenClassification,Vv as DistilBertModel,Bv as DistilBertPreTrainedModel,iu as DistilBertTokenizer,qk as DocumentQuestionAnsweringPipeline,wf as DonutFeatureExtractor,Cf as DonutImageProcessor,qv as DonutSwinModel,Kv as DonutSwinPreTrainedModel,Sh as DynamicCache,DT as EdgeTamModel,$v as EfficientNetForImageClassification,Df as EfficientNetImageProcessor,Qv as EfficientNetModel,Zv as EfficientNetPreTrainedModel,ny as ElectraForMaskedLM,ay as ElectraForQuestionAnswering,ry as ElectraForSequenceClassification,iy as ElectraForTokenClassification,ty as ElectraModel,ey as ElectraPreTrainedModel,au as ElectraTokenizer,bd as EncodecFeatureExtractor,gh as EosTokenCriteria,cy as Ernie4_5ForCausalLM,sy as Ernie4_5Model,oy as Ernie4_5PretrainedModel,dy as EsmForMaskedLM,fy as EsmForSequenceClassification,py as EsmForTokenClassification,uy as EsmModel,ly as EsmPreTrainedModel,ou as EsmTokenizer,gy as EuroBertForMaskedLM,_y as EuroBertForSequenceClassification,vy as EuroBertForTokenClassification,hy as EuroBertModel,my as EuroBertPreTrainedModel,xy as ExaoneForCausalLM,by as ExaoneModel,yy as ExaonePreTrainedModel,wy as FalconForCausalLM,Dy as FalconH1ForCausalLM,Ey as FalconH1Model,Ty as FalconH1PreTrainedModel,Cy as FalconModel,Sy as FalconPreTrainedModel,su as FalconTokenizer,Ay as FastViTForImageClassification,ky as FastViTModel,Oy as FastViTPreTrainedModel,Xk as FeatureExtractionPipeline,qu as FeatureExtractor,Ok as FillMaskPipeline,My as Florence2ForConditionalGeneration,jy as Florence2PreTrainedModel,Mp as Florence2Processor,Qm as ForcedBOSTokenLogitsProcessor,$m as ForcedEOSTokenLogitsProcessor,Pf as GLPNFeatureExtractor,fb as GLPNForDepthEstimation,db as GLPNModel,ub as GLPNPreTrainedModel,Db as GPT2LMHeadModel,Eb as GPT2Model,Tb as GPT2PreTrainedModel,uu as GPT2Tokenizer,hb as GPTBigCodeForCausalLM,mb as GPTBigCodeModel,pb as GPTBigCodePreTrainedModel,Ab as GPTJForCausalLM,kb as GPTJModel,Ob as GPTJPreTrainedModel,vb as GPTNeoForCausalLM,_b as GPTNeoModel,gb as GPTNeoPreTrainedModel,xb as GPTNeoXForCausalLM,bb as GPTNeoXModel,yb as GPTNeoXPreTrainedModel,lu as GPTNeoXTokenizer,Ry as Gemma2ForCausalLM,Ly as Gemma2Model,Iy as Gemma2PreTrainedModel,Ky as Gemma3ForCausalLM,Gy as Gemma3ForConditionalGeneration,Of as Gemma3ImageProcessor,Wy as Gemma3Model,Uy as Gemma3PreTrainedModel,Np as Gemma3Processor,Dd as Gemma3nAudioFeatureExtractor,Yy as Gemma3nForCausalLM,Jy as Gemma3nForConditionalGeneration,qy as Gemma3nPreTrainedModel,Pp as Gemma3nProcessor,Od as Gemma4AudioFeatureExtractor,Zy as Gemma4ForCausalLM,Xy as Gemma4ForConditionalGeneration,jf as Gemma4ImageProcessor,Fp as Gemma4Processor,Fy as GemmaForCausalLM,Py as GemmaModel,Ny as GemmaPreTrainedModel,cu as GemmaTokenizer,Nf as Glm46VImageProcessor,Lp as Glm46VProcessor,eb as GlmForCausalLM,$y as GlmModel,rb as GlmMoeDsaForCausalLM,nb as GlmMoeDsaModel,tb as GlmMoeDsaPreTrainedModel,lb as GlmOcrForConditionalGeneration,Qy as GlmPreTrainedModel,wb as GptOssForCausalLM,Cb as GptOssModel,Sb as GptOssPreTrainedModel,Nb as GraniteForCausalLM,Mb as GraniteModel,Ib as GraniteMoeHybridForCausalLM,Fb as GraniteMoeHybridModel,Pb as GraniteMoeHybridPreTrainedModel,jb as GranitePreTrainedModel,kd as GraniteSpeechFeatureExtractor,zb as GraniteSpeechForConditionalGeneration,Rp as GraniteSpeechProcessor,Vb as GroundingDinoForObjectDetection,Ff as GroundingDinoImageProcessor,Bb as GroundingDinoPreTrainedModel,Bp as GroundingDinoProcessor,Ub as GroupViTModel,Hb as GroupViTPreTrainedModel,Kb as HeliumForCausalLM,Gb as HeliumModel,Wb as HeliumPreTrainedModel,du as HerbertTokenizer,Yb as HieraForImageClassification,Jb as HieraModel,qb as HieraPreTrainedModel,rx as HubertForCTC,ix as HubertForSequenceClassification,nx as HubertModel,tx as HubertPreTrainedModel,sx as HunYuanDenseV1ForCausalLM,ox as HunYuanDenseV1Model,ax as HunYuanDenseV1PreTrainedModel,dx as IJepaForImageClassification,ux as IJepaModel,lx as IJepaPreTrainedModel,cx as Idefics3ForConditionalGeneration,If as Idefics3ImageProcessor,If as SmolVLMImageProcessor,Wp as Idefics3Processor,Wp as SmolVLMProcessor,Bk as ImageClassificationPipeline,Zk as ImageFeatureExtractionPipeline,q as ImageFeatureExtractor,q as ImageProcessor,Hk as ImageSegmentationPipeline,Jk as ImageToImagePipeline,zk as ImageToTextPipeline,_h as InterruptableStoppingCriteria,mx as JAISLMHeadModel,px as JAISModel,fx as JAISPreTrainedModel,Rf as JinaCLIPImageProcessor,gx as JinaCLIPModel,hx as JinaCLIPPreTrainedModel,Kp as JinaCLIPProcessor,_x as JinaCLIPTextModel,vx as JinaCLIPVisionModel,xx as Lfm2ForCausalLM,bx as Lfm2Model,Tx as Lfm2MoeForCausalLM,wx as Lfm2MoeModel,Cx as Lfm2MoePreTrainedModel,yx as Lfm2PreTrainedModel,Ex as Lfm2VlForConditionalGeneration,Wf as Lfm2VlImageProcessor,qp as Lfm2VlProcessor,Sx as LightOnOcrForConditionalGeneration,ID as LiteWhisperForConditionalGeneration,jx as Llama4ForCausalLM,Ax as Llama4PreTrainedModel,kx as LlamaForCausalLM,Ox as LlamaModel,Dx as LlamaPreTrainedModel,fu as LlamaTokenizer,By as LlavaForConditionalGeneration,By as LlavaOnevisionForConditionalGeneration,Gf as LlavaOnevisionImageProcessor,zy as LlavaPreTrainedModel,Jp as LlavaProcessor,Hy as LlavaQwen2ForCausalLM,$r as LogLevel,Ym as LogitsProcessor,Zm as LogitsProcessorList,Xm as LogitsWarper,Px as LongT5ForConditionalGeneration,Nx as LongT5Model,Mx as LongT5PreTrainedModel,Lx as M2M100ForConditionalGeneration,Ix as M2M100Model,Fx as M2M100PreTrainedModel,pu as M2M100Tokenizer,gu as MBart50Tokenizer,Jx as MBartForCausalLM,Kx as MBartForConditionalGeneration,qx as MBartForSequenceClassification,Gx as MBartModel,Wx as MBartPreTrainedModel,hu as MBartTokenizer,rC as MPNetForMaskedLM,oC as MPNetForQuestionAnswering,iC as MPNetForSequenceClassification,aC as MPNetForTokenClassification,nC as MPNetModel,tC as MPNetPreTrainedModel,yu as MPNetTokenizer,fC as MT5ForConditionalGeneration,dC as MT5Model,uC as MT5PreTrainedModel,Bx as MarianMTModel,zx as MarianModel,Rx as MarianPreTrainedModel,mu as MarianTokenizer,Jf as Mask2FormerImageProcessor,qf as MaskFormerFeatureExtractor,Ux as MaskFormerForInstanceSegmentation,Kf as MaskFormerImageProcessor,Hx as MaskFormerModel,Vx as MaskFormerPreTrainedModel,hh as MaxLengthCriteria,Xx as Metric3DForDepthEstimation,Yx as Metric3DPreTrainedModel,Qx as Metric3Dv2ForDepthEstimation,Zx as Metric3Dv2PreTrainedModel,tS as MgpstrForSceneTextRecognition,$x as MgpstrModelOutput,eS as MgpstrPreTrainedModel,Xp as MgpstrProcessor,_u as MgpstrTokenizer,sS as MimiDecoderModel,rS as MimiDecoderOutput,oS as MimiEncoderModel,nS as MimiEncoderOutput,aS as MimiModel,iS as MimiPreTrainedModel,ah as MinLengthLogitsProcessor,oh as MinNewTokensLengthLogitsProcessor,pS as Mistral4ForCausalLM,fS as Mistral4Model,dS as Mistral4PreTrainedModel,uS as MistralForCausalLM,lS as MistralModel,cS as MistralPreTrainedModel,gS as MobileBertForMaskedLM,vS as MobileBertForQuestionAnswering,_S as MobileBertForSequenceClassification,hS as MobileBertModel,mS as MobileBertPreTrainedModel,vu as MobileBertTokenizer,xS as MobileLLMForCausalLM,bS as MobileLLMModel,yS as MobileLLMPreTrainedModel,Xf as MobileNetV1FeatureExtractor,wS as MobileNetV1ForImageClassification,TS as MobileNetV1ForSemanticSegmentation,Yf as MobileNetV1ImageProcessor,CS as MobileNetV1Model,SS as MobileNetV1PreTrainedModel,Qf as MobileNetV2FeatureExtractor,OS as MobileNetV2ForImageClassification,kS as MobileNetV2ForSemanticSegmentation,Zf as MobileNetV2ImageProcessor,DS as MobileNetV2Model,ES as MobileNetV2PreTrainedModel,ep as MobileNetV3FeatureExtractor,MS as MobileNetV3ForImageClassification,NS as MobileNetV3ForSemanticSegmentation,$f as MobileNetV3ImageProcessor,jS as MobileNetV3Model,AS as MobileNetV3PreTrainedModel,np as MobileNetV4FeatureExtractor,IS as MobileNetV4ForImageClassification,LS as MobileNetV4ForSemanticSegmentation,tp as MobileNetV4ImageProcessor,FS as MobileNetV4Model,PS as MobileNetV4PreTrainedModel,ip as MobileViTFeatureExtractor,BS as MobileViTForImageClassification,rp as MobileViTImageProcessor,zS as MobileViTModel,RS as MobileViTPreTrainedModel,US as MobileViTV2ForImageClassification,HS as MobileViTV2Model,VS as MobileViTV2PreTrainedModel,CA as ModelRegistry,ZS as ModernBertDecoderForCausalLM,XS as ModernBertDecoderModel,YS as ModernBertDecoderPreTrainedModel,KS as ModernBertForMaskedLM,qS as ModernBertForSequenceClassification,JS as ModernBertForTokenClassification,GS as ModernBertModel,WS as ModernBertPreTrainedModel,Vy as Moondream1ForConditionalGeneration,Ad as MoonshineFeatureExtractor,eC as MoonshineForConditionalGeneration,$S as MoonshineModel,QS as MoonshinePreTrainedModel,Zp as MoonshineProcessor,lC as MptForCausalLM,cC as MptModel,sC as MptPreTrainedModel,mC as MultiModalityCausalLM,pC as MultiModalityPreTrainedModel,_C as MusicgenForCausalLM,vC as MusicgenForConditionalGeneration,gC as MusicgenModel,hC as MusicgenPreTrainedModel,xC as NanoChatForCausalLM,bC as NanoChatModel,yC as NanoChatPreTrainedModel,wC as NemotronHForCausalLM,CC as NemotronHModel,SC as NemotronHPreTrainedModel,DC as NeoBertForMaskedLM,AC as NeoBertForQuestionAnswering,OC as NeoBertForSequenceClassification,kC as NeoBertForTokenClassification,EC as NeoBertModel,TC as NeoBertPreTrainedModel,bu as NllbTokenizer,sh as NoBadWordsLogitsProcessor,rh as NoRepeatNGramLogitsProcessor,MC as NomicBertModel,jC as NomicBertPreTrainedModel,ap as NougatImageProcessor,xu as NougatTokenizer,$C as OPTForCausalLM,QC as OPTModel,ZC as OPTPreTrainedModel,Gk as ObjectDetectionPipeline,RC as Olmo2ForCausalLM,LC as Olmo2Model,IC as Olmo2PreTrainedModel,VC as Olmo3ForCausalLM,BC as Olmo3Model,zC as Olmo3PreTrainedModel,FC as OlmoForCausalLM,WC as OlmoHybridForCausalLM,UC as OlmoHybridModel,HC as OlmoHybridPreTrainedModel,PC as OlmoModel,NC as OlmoPreTrainedModel,qC as OpenAIPrivacyFilterForTokenClassification,KC as OpenAIPrivacyFilterModel,GC as OpenAIPrivacyFilterPreTrainedModel,XC as OpenELMForCausalLM,YC as OpenELMModel,JC as OpenELMPreTrainedModel,sp as OwlViTFeatureExtractor,aw as OwlViTForObjectDetection,op as OwlViTImageProcessor,iw as OwlViTModel,rw as OwlViTPreTrainedModel,Qp as OwlViTProcessor,nw as Owlv2ForObjectDetection,cp as Owlv2ImageProcessor,tw as Owlv2Model,ew as Owlv2PreTrainedModel,ow as PaliGemmaForConditionalGeneration,tm as PaliGemmaProcessor,wd as ParakeetFeatureExtractor,cw as ParakeetForCTC,sw as ParakeetPreTrainedModel,dw as PatchTSMixerForPrediction,uw as PatchTSMixerModel,lw as PatchTSMixerPreTrainedModel,mw as PatchTSTForPrediction,pw as PatchTSTModel,fw as PatchTSTPreTrainedModel,bw as Phi3ForCausalLM,yw as Phi3Model,vw as Phi3PreTrainedModel,Sw as Phi3VForCausalLM,mp as Phi3VImageProcessor,xw as Phi3VPreTrainedModel,im as Phi3VProcessor,_w as PhiForCausalLM,gw as PhiModel,hw as PhiPreTrainedModel,hp as PixtralImageProcessor,am as PixtralProcessor,Z as PreTrainedModel,W as PreTrainedTokenizer,W as TokenizersBackend,Nm as PretrainedConfig,K as Processor,Tw as PvtForImageClassification,gp as PvtImageProcessor,ww as PvtModel,Cw as PvtPreTrainedModel,jd as PyAnnoteFeatureExtractor,Ow as PyAnnoteForAudioFrameClassification,Dw as PyAnnoteModel,Ew as PyAnnotePreTrainedModel,om as PyAnnoteProcessor,Dk as QuestionAnsweringPipeline,jw as Qwen2ForCausalLM,Aw as Qwen2Model,Pw as Qwen2MoeForCausalLM,Nw as Qwen2MoeModel,Mw as Qwen2MoePreTrainedModel,kw as Qwen2PreTrainedModel,Su as Qwen2Tokenizer,ob as Qwen2VLForCausalLM,ab as Qwen2VLForConditionalGeneration,Mf as Qwen2VLImageProcessor,ib as Qwen2VLPreTrainedModel,Ip as Qwen2VLProcessor,cb as Qwen2_5_VLForCausalLM,sb as Qwen2_5_VLForConditionalGeneration,sm as Qwen2_5_VLProcessor,Lw as Qwen3ForCausalLM,Iw as Qwen3Model,Bw as Qwen3MoeForCausalLM,zw as Qwen3MoeModel,Rw as Qwen3MoePreTrainedModel,Uw as Qwen3NextForCausalLM,Hw as Qwen3NextModel,Vw as Qwen3NextPreTrainedModel,Fw as Qwen3PreTrainedModel,Gw as Qwen3VLForCausalLM,Ww as Qwen3VLForConditionalGeneration,qw as Qwen3VLMoeForCausalLM,Kw as Qwen3VLMoeForConditionalGeneration,cm as Qwen3VLProcessor,Yw as Qwen3_5ForCausalLM,Jw as Qwen3_5ForConditionalGeneration,Zw as Qwen3_5MoeForCausalLM,Xw as Qwen3_5MoeForConditionalGeneration,rT as RFDetrForObjectDetection,nT as RFDetrModel,iT as RFDetrObjectDetectionOutput,tT as RFDetrPreTrainedModel,U_ as RTDetrForObjectDetection,_p as RTDetrImageProcessor,H_ as RTDetrModel,W_ as RTDetrObjectDetectionOutput,V_ as RTDetrPreTrainedModel,yT as RTDetrV2ForObjectDetection,vT as RTDetrV2Model,bT as RTDetrV2ObjectDetectionOutput,_T as RTDetrV2PreTrainedModel,vd as RawAudio,Yd as RawImage,uA as RawVideo,lA as RawVideoFrame,ih as RepetitionPenaltyLogitsProcessor,eT as ResNetForImageClassification,$w as ResNetModel,Qw as ResNetPreTrainedModel,pT as RoFormerForMaskedLM,gT as RoFormerForQuestionAnswering,mT as RoFormerForSequenceClassification,hT as RoFormerForTokenClassification,fT as RoFormerModel,dT as RoFormerPreTrainedModel,wu as RoFormerTokenizer,sT as RobertaForMaskedLM,uT as RobertaForQuestionAnswering,cT as RobertaForSequenceClassification,lT as RobertaForTokenClassification,oT as RobertaModel,aT as RobertaPreTrainedModel,Cu as RobertaTokenizer,vp as Sam2ImageProcessor,vp as Sam3ImageProcessor,vp as SamImageProcessor,wT as Sam2ImageSegmentationOutput,ET as Sam2Model,TT as Sam2PreTrainedModel,um as Sam2Processor,dm as Sam2VideoProcessor,OT as Sam3TrackerModel,xT as SamImageSegmentationOutput,CT as SamModel,ST as SamPreTrainedModel,lm as SamProcessor,bp as SapiensFeatureExtractor,jT as SapiensForDepthEstimation,MT as SapiensForNormalEstimation,AT as SapiensForSemanticSegmentation,yp as SapiensImageProcessor,kT as SapiensPreTrainedModel,Md as SeamlessM4TFeatureExtractor,Sp as SegformerFeatureExtractor,FT as SegformerForImageClassification,IT as SegformerForSemanticSegmentation,xp as SegformerImageProcessor,PT as SegformerModel,NT as SegformerPreTrainedModel,Cp as SiglipImageProcessor,RT as SiglipModel,LT as SiglipPreTrainedModel,zT as SiglipTextModel,Tu as SiglipTokenizer,BT as SiglipVisionModel,UT as SmolLM3ForCausalLM,HT as SmolLM3Model,VT as SmolLM3PreTrainedModel,WT as SmolVLMForConditionalGeneration,JT as SnacDecoderModel,qT as SnacEncoderModel,Nd as SnacFeatureExtractor,KT as SnacModel,GT as SnacPreTrainedModel,ZT as SolarOpenForCausalLM,XT as SolarOpenModel,YT as SolarOpenPreTrainedModel,Pd as SpeechT5FeatureExtractor,eE as SpeechT5ForSpeechToText,tE as SpeechT5ForTextToSpeech,nE as SpeechT5HifiGan,$T as SpeechT5Model,QT as SpeechT5PreTrainedModel,fm as SpeechT5Processor,Eu as SpeechT5Tokenizer,aE as SqueezeBertForMaskedLM,sE as SqueezeBertForQuestionAnswering,oE as SqueezeBertForSequenceClassification,iE as SqueezeBertModel,rE as SqueezeBertPreTrainedModel,Du as SqueezeBertTokenizer,uE as StableLmForCausalLM,lE as StableLmModel,cE as StableLmPreTrainedModel,pE as Starcoder2ForCausalLM,fE as Starcoder2Model,dE as Starcoder2PreTrainedModel,ph as StoppingCriteria,mh as StoppingCriteriaList,hE as StyleTextToSpeech2Model,mE as StyleTextToSpeech2PreTrainedModel,Ak as SummarizationPipeline,_E as SupertonicForConditionalGeneration,gE as SupertonicPreTrainedModel,th as SuppressTokensAtBeginLogitsProcessor,eh as SuppressTokensLogitsProcessor,wE as Swin2SRForImageSuperResolution,wp as Swin2SRImageProcessor,CE as Swin2SRModel,SE as Swin2SRPreTrainedModel,bE as SwinForImageClassification,xE as SwinForSemanticSegmentation,yE as SwinModel,vE as SwinPreTrainedModel,DE as T5ForConditionalGeneration,EE as T5Model,TE as T5PreTrainedModel,Ou as T5Tokenizer,AE as TableTransformerForObjectDetection,kE as TableTransformerModel,jE as TableTransformerObjectDetectionOutput,OE as TableTransformerPreTrainedModel,lh as TemperatureLogitsWarper,U as Tensor,kk as Text2TextGenerationPipeline,Ck as TextClassificationPipeline,Nk as TextGenerationPipeline,sA as TextStreamer,Rk as TextToAudioPipeline,wk as TokenClassificationPipeline,dh as TopKLogitsWarper,uh as TopPLogitsWarper,NE as TrOCRForCausalLM,ME as TrOCRPreTrainedModel,jk as TranslationPipeline,Rb as UltravoxModel,Lb as UltravoxPreTrainedModel,pm as UltravoxProcessor,IE as UniSpeechForCTC,LE as UniSpeechForSequenceClassification,FE as UniSpeechModel,PE as UniSpeechPreTrainedModel,HE as UniSpeechSatForAudioFrameClassification,BE as UniSpeechSatForCTC,VE as UniSpeechSatForSequenceClassification,zE as UniSpeechSatModel,RE as UniSpeechSatPreTrainedModel,Gp as VLChatProcessor,Lf as VLMImageProcessor,GE as VaultGemmaForCausalLM,WE as VaultGemmaModel,UE as VaultGemmaPreTrainedModel,Ep as ViTFeatureExtractor,YE as ViTForImageClassification,Tp as ViTImageProcessor,ZE as ViTMAEModel,XE as ViTMAEPreTrainedModel,eD as ViTMSNForImageClassification,$E as ViTMSNModel,QE as ViTMSNPreTrainedModel,JE as ViTModel,qE as ViTPreTrainedModel,KE as VisionEncoderDecoderModel,nD as VitMatteForImageMatting,Dp as VitMatteImageProcessor,tD as VitMattePreTrainedModel,iD as VitPoseForPoseEstimation,Op as VitPoseImageProcessor,rD as VitPosePreTrainedModel,sD as VitsModel,aD as VitsModelOutput,oD as VitsPreTrainedModel,Au as VitsTokenizer,cD as VoxtralForConditionalGeneration,vm as VoxtralProcessor,Ld as VoxtralRealtimeFeatureExtractor,vD as VoxtralRealtimeForConditionalGeneration,_D as VoxtralRealtimePreTrainedModel,wm as VoxtralRealtimeProcessor,xD as Wav2Vec2BertForCTC,SD as Wav2Vec2BertForSequenceClassification,bD as Wav2Vec2BertModel,yD as Wav2Vec2BertPreTrainedModel,ju as Wav2Vec2CTCTokenizer,Fd as Wav2Vec2FeatureExtractor,ex as Wav2Vec2ForAudioFrameClassification,Qb as Wav2Vec2ForCTC,$b as Wav2Vec2ForSequenceClassification,Zb as Wav2Vec2Model,Xb as Wav2Vec2PreTrainedModel,Tm as Wav2Vec2Processor,Em as Wav2Vec2ProcessorWithLM,kD as WavLMForAudioFrameClassification,ED as WavLMForCTC,DD as WavLMForSequenceClassification,OD as WavLMForXVector,TD as WavLMModel,wD as WavLMPreTrainedModel,Id as WeSpeakerFeatureExtractor,jD as WeSpeakerResNetModel,AD as WeSpeakerResNetPreTrainedModel,Rd as WhisperFeatureExtractor,FD as WhisperForConditionalGeneration,PD as WhisperModel,ND as WhisperPreTrainedModel,Dm as WhisperProcessor,cA as WhisperTextStreamer,nh as WhisperTimeStampLogitsProcessor,Ru as WhisperTokenizer,HD as XLMForQuestionAnswering,BD as XLMForSequenceClassification,VD as XLMForTokenClassification,RD as XLMModel,LD as XLMPreTrainedModel,GD as XLMRobertaForMaskedLM,JD as XLMRobertaForQuestionAnswering,KD as XLMRobertaForSequenceClassification,qD as XLMRobertaForTokenClassification,WD as XLMRobertaModel,UD as XLMRobertaPreTrainedModel,zu as XLMRobertaTokenizer,Bu as XLMTokenizer,zD as XLMWithLMHeadModel,CD as XVectorOutput,Ap as YolosFeatureExtractor,ZD as YolosForObjectDetection,kp as YolosImageProcessor,XD as YolosModel,QD as YolosObjectDetectionOutput,YD as YolosPreTrainedModel,tO as YoutuForCausalLM,eO as YoutuModel,$D as YoutuPreTrainedModel,Ik as ZeroShotAudioClassificationPipeline,Pk as ZeroShotClassificationPipeline,Wk as ZeroShotImageClassificationPipeline,Kk as ZeroShotObjectDetectionPipeline,_l as cat,lc as cos_sim,cc as dot,M as env,wl as full,Tl as full_like,al as interpolate,ol as interpolate_4d,pl as layer_norm,Qu as load_audio,Xd as load_image,dA as load_video,sc as log_softmax,sl as matmul,xl as mean,fl as mean_pooling,El as ones,Dl as ones_like,il as permute,rA as pipeline,Ml as quantize_embeddings,Al as rand,jl as randn,Cs as random,$u as read_audio,cl as rfft,dl as slice,oc as softmax,vl as stack,bl as std_mean,ll as topk,Ol as zeros,kl as zeros_like};
|