@fangorn-network/westmarch 0.0.19-dev → 2026.10.2-0.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (590) hide show
  1. package/README.md +33 -3
  2. package/docs/app-to-agent.md +100 -27
  3. package/package.json +9 -5
  4. package/plugin/scripts/fx.mjs +7 -9
  5. package/site/dist/assets/AccountNotFoundScreen-C4njXc69-RUyAWRzV.js +1 -0
  6. package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-ZV-LlYBe.js +31 -0
  7. package/site/dist/assets/Address-H8kD1d9O-CGQnt7Pu.js +17 -0
  8. package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-CKn2JLwq.js +6 -0
  9. package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-9oIP9fma.js +1 -0
  10. package/site/dist/assets/ArrowsRightLeftIcon-BEhBD_6N.js +1 -0
  11. package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-D1wLlSJs.js +1 -0
  12. package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-CSBbHTyz.js +1 -0
  13. package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-BsRq-xBt.js +1 -0
  14. package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-BPdhsKvN.js +103 -0
  15. package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-CEGNdrkr.js +1 -0
  16. package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-Da9P7eSx.js +68 -0
  17. package/site/dist/assets/CaptchaScreen-DbpvkIGx-BecgMnD_.js +1 -0
  18. package/site/dist/assets/CheckCircleIcon-DBiWFjO6.js +1 -0
  19. package/site/dist/assets/CheckCircleIcon-DzG2ROJZ.js +1 -0
  20. package/site/dist/assets/Checkbox-D1EDeo41-DMHcj9o_.js +52 -0
  21. package/site/dist/assets/ChevronDownIcon-2Os56gUt.js +1 -0
  22. package/site/dist/assets/Chip-CZKIKt9K-BWzs9fj5.js +26 -0
  23. package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-CFvcSiDs.js +16 -0
  24. package/site/dist/assets/ConnectEmailForm-B-VRE0MN-BozkCg8q.js +3 -0
  25. package/site/dist/assets/ConnectLedgerScreen-DWHABGot-DaCnbBzh.js +10 -0
  26. package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-DUkCLkxD.js +1 -0
  27. package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-Dv_5nMkZ.js +1 -0
  28. package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-DSGEeB3Y.js +1 -0
  29. package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-C-s4s_Lq.js +95 -0
  30. package/site/dist/assets/ConnectWalletView-DqI-PTvX-BKX7fdYr.js +74 -0
  31. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-DSoAuMFZ.js +7 -0
  32. package/site/dist/assets/CopyToClipboard-i_OQSBJr-CZTXyfV0.js +39 -0
  33. package/site/dist/assets/CopyableText-CQapvaMr-DHO818I0.js +28 -0
  34. package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-DW4nRGfz.js +1 -0
  35. package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-DH8Nnb4Y.js +22 -0
  36. package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-gfUS_uV5.js +1 -0
  37. package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-DZj9HTHc.js +1 -0
  38. package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-eHYsDK9W.js +187 -0
  39. package/site/dist/assets/DepositAddressScreen-DBLRs7aI-DK_XVgVk.js +8 -0
  40. package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-6gRZzhLe.js +1 -0
  41. package/site/dist/assets/{EmailInputForm-Cqo1mda8-B2NG3K5V.js → EmailInputForm-Cqo1mda8-CZD4r5LM.js} +11 -11
  42. package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-BZu2ae0k.js +1 -0
  43. package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-86pviemJ.js +1 -0
  44. package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-vDcvT53Y.js +23 -0
  45. package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-rNJAtSJc.js +1 -0
  46. package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-I8Q95280.js +1 -0
  47. package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-Coi7OxoI.js +1 -0
  48. package/site/dist/assets/EnrollTotp-Dibew4dp-DC7FrDgo.js +66 -0
  49. package/site/dist/assets/EnvelopeIcon-DY6ERnW7.js +1 -0
  50. package/site/dist/assets/ErrorBanner-BcpGRt0h-BvESwN99.js +21 -0
  51. package/site/dist/assets/{ErrorMessage-D8VaAP5m-CrZOnUyg.js → ErrorMessage-D8VaAP5m-oSruKN8L.js} +2 -2
  52. package/site/dist/assets/ErrorScreen-DipdTWzE-DnKGxH1Z.js +4 -0
  53. package/site/dist/assets/ExclamationCircleIcon-BZhlqH0r.js +1 -0
  54. package/site/dist/assets/ExclamationTriangleIcon-CkAOJIYV.js +1 -0
  55. package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-4pi7jooW.js +75 -0
  56. package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-z2XCMaLL.js +28 -0
  57. package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-CBVA9v1-.js +491 -0
  58. package/site/dist/assets/FingerPrintIcon-ra2dqmJO.js +1 -0
  59. package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-DwAwc6Ny.js +1 -0
  60. package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-CZszQsZf.js +1 -0
  61. package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-DfX6nvFQ.js +58 -0
  62. package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-CDS_sk_t.js +1 -0
  63. package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-CPfNQemT.js +1 -0
  64. package/site/dist/assets/GlobeAltIcon-SEUEIe_E.js +1 -0
  65. package/site/dist/assets/GooglePay-B53WnudL-aap7zwag.js +1 -0
  66. package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-DgSjCjQI.js +4 -0
  67. package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-DO4wICml.js +1 -0
  68. package/site/dist/assets/InfoBanner-Cb3p1z12-CDWt2ADo.js +22 -0
  69. package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-Ba19XoBr.js +1 -0
  70. package/site/dist/assets/InstallWalletScreen-DTA8dwLv-DGpewEch.js +1 -0
  71. package/site/dist/assets/{JsonTree-BHzNC-ic-DcNcbSoM.js → JsonTree-BHzNC-ic-pAEq1bl9.js} +3 -3
  72. package/site/dist/assets/{LabelXs-oqZNqbm_-iafrj25N.js → LabelXs-oqZNqbm_-D09YjVR4.js} +2 -2
  73. package/site/dist/assets/LandingScreen-CGWUoSUG-CUOCWUXd.js +1 -0
  74. package/site/dist/assets/{Layouts-BMRfo5hw-CeCOyCLK.js → Layouts-BMRfo5hw-D2u1-w8g.js} +16 -16
  75. package/site/dist/assets/Link-BdDilT2T-BYiP1zvW.js +40 -0
  76. package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-Tb6cAepT.js +77 -0
  77. package/site/dist/assets/LinkEmailScreen-dKo9frwc-pq0NF2JO.js +1 -0
  78. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-D9MOmDqg.js +117 -0
  79. package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-B80UJqAZ.js +1 -0
  80. package/site/dist/assets/{LoadingSkeleton-BMsgO5PV-CiEyS5PZ.js → LoadingSkeleton-BMsgO5PV-BRMh4Fv4.js} +6 -6
  81. package/site/dist/assets/LockClosedIcon-BqkoEL9J.js +1 -0
  82. package/site/dist/assets/LoginFailedScreen-CN0dJV6U-DlnOM-Kh.js +1 -0
  83. package/site/dist/assets/ManualTransferScreen-CHqcuqbs-DSShupq9.js +1 -0
  84. package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-DUPV_SLA.js +1 -0
  85. package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-D96GpzXX.js +1 -0
  86. package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-CYQDa4ND.js +1 -0
  87. package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-CJtSAXGN.js +1 -0
  88. package/site/dist/assets/ModalFooter-BCuEK_nz-D2I8KWtk.js +403 -0
  89. package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-Bx5aHy-z.js +16 -0
  90. package/site/dist/assets/OAuthStatusScreen-ufbOa-da-CS6988X2.js +1 -0
  91. package/site/dist/assets/OpenLink-CUpJ1mOr-EZWVSX2r.js +39 -0
  92. package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-BY4eK5Jh.js +1 -0
  93. package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-LXys76u9.js +6 -0
  94. package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-RczvLvmo.js +20 -0
  95. package/site/dist/assets/{PhArrowCircleDown-D97G-BOA.js → PhArrowCircleDown-BtlNV0TZ.js} +5 -5
  96. package/site/dist/assets/PhArrowClockwise-mOiWYLMV.js +14 -0
  97. package/site/dist/assets/PhArrowDown-CkoOD89h.js +14 -0
  98. package/site/dist/assets/PhArrowLeft-C0jlxVhM.js +14 -0
  99. package/site/dist/assets/PhArrowRight-BI-V03Xf.js +14 -0
  100. package/site/dist/assets/{PhArrowSquareOut-Bk2CMG3I.js → PhArrowSquareOut-DnQ7n_B4.js} +5 -5
  101. package/site/dist/assets/PhArrowUp-izKvURUW.js +14 -0
  102. package/site/dist/assets/PhArrowUpRight-Bn-JhHsY.js +14 -0
  103. package/site/dist/assets/{PhArrowsClockwise-BXRn1GEl.js → PhArrowsClockwise-Brtx2Re-.js} +5 -5
  104. package/site/dist/assets/{PhArrowsDownUp-DM09Jo_3.js → PhArrowsDownUp-PZosTqZG.js} +5 -5
  105. package/site/dist/assets/PhArrowsLeftRight-CYsRQ2qh.js +14 -0
  106. package/site/dist/assets/{PhBank-fHbgCqqZ.js → PhBank-hhPAIPVb.js} +5 -5
  107. package/site/dist/assets/PhBrowser-BjzAmrHO.js +14 -0
  108. package/site/dist/assets/PhCaretDown-ddSjwcwm.js +14 -0
  109. package/site/dist/assets/PhCaretLeft-B7YLoNEF.js +14 -0
  110. package/site/dist/assets/PhCaretRight-BY8D5MIg.js +14 -0
  111. package/site/dist/assets/PhCaretUp-BG10nSut.js +14 -0
  112. package/site/dist/assets/PhCheck-DrKd7pBC.js +14 -0
  113. package/site/dist/assets/{PhCircleHalf-MJZeRBGF.js → PhCircleHalf-Bk9C4DvT.js} +5 -5
  114. package/site/dist/assets/PhClock-Sj17weCB.js +14 -0
  115. package/site/dist/assets/{PhCompass-hYn3HhGN.js → PhCompass-Df1ugFO-.js} +5 -5
  116. package/site/dist/assets/PhCopy-rgttky8E.js +14 -0
  117. package/site/dist/assets/{PhCreditCard-Fy4pzwtt.js → PhCreditCard-CZpdid2n.js} +5 -5
  118. package/site/dist/assets/{PhCurrencyDollar-BgiaenCi.js → PhCurrencyDollar-B6IKKjue.js} +5 -5
  119. package/site/dist/assets/{PhDesktop-CxrzCSv5.js → PhDesktop-BuCDXYJj.js} +5 -5
  120. package/site/dist/assets/PhDeviceMobile-CnybhXY-.js +14 -0
  121. package/site/dist/assets/PhDotsThree-CSAEcba1.js +14 -0
  122. package/site/dist/assets/PhEnvelope-SmaNeXoQ.js +14 -0
  123. package/site/dist/assets/PhFunnelSimple-DKx35ITq.js +14 -0
  124. package/site/dist/assets/{PhGlobe-DvmSc9_A.js → PhGlobe-q1mqj65V.js} +5 -5
  125. package/site/dist/assets/{PhIdentificationCard-CfkZm-5K.js → PhIdentificationCard-BeLXJpfZ.js} +5 -5
  126. package/site/dist/assets/{PhImage-Cf0J2ZfJ.js → PhImage-BYrKfN9k.js} +5 -5
  127. package/site/dist/assets/{PhInfo-Bwi51-2X.js → PhInfo-X33f06Ej.js} +5 -5
  128. package/site/dist/assets/{PhLightbulb-C4FZV7Es.js → PhLightbulb-DMZJsowR.js} +5 -5
  129. package/site/dist/assets/PhMagnifyingGlass-B6D0sWFL.js +14 -0
  130. package/site/dist/assets/{PhPaperPlaneRight-zxQVvPLX.js → PhPaperPlaneRight-Dvo-nXr9.js} +5 -5
  131. package/site/dist/assets/PhPlus-CBvZvLax.js +14 -0
  132. package/site/dist/assets/{PhPower-CFyWDmgD.js → PhPower-D8-AcNM6.js} +5 -5
  133. package/site/dist/assets/{PhPuzzlePiece-BjoNVfST.js → PhPuzzlePiece-C-7mYqGO.js} +5 -5
  134. package/site/dist/assets/{PhQrCode-CP3tFauY.js → PhQrCode-uIXlI5ER.js} +5 -5
  135. package/site/dist/assets/{PhQuestion-wOWJBd3G.js → PhQuestion-rUoqC2sC.js} +5 -5
  136. package/site/dist/assets/{PhQuestionMark-CV0k9C0Y.js → PhQuestionMark-W55Txvvb.js} +5 -5
  137. package/site/dist/assets/{PhSealCheck-vIKzREuN.js → PhSealCheck-BeVLq9PH.js} +5 -5
  138. package/site/dist/assets/{PhSignOut-CxELV-i0.js → PhSignOut-Cq2PivQ6.js} +5 -5
  139. package/site/dist/assets/{PhSpinner-CGDmbzUd.js → PhSpinner-CZMtAFdX.js} +5 -5
  140. package/site/dist/assets/{PhTrash-C9PD0SAt.js → PhTrash-BamrmMsN.js} +5 -5
  141. package/site/dist/assets/{PhUser-0sWNXQeZ.js → PhUser-A2fxqIV0.js} +5 -5
  142. package/site/dist/assets/{PhVault-6JTskUcC.js → PhVault-B8m1usHw.js} +5 -5
  143. package/site/dist/assets/{PhWarning-CoKs3gz6.js → PhWarning-CpkID9oi.js} +5 -5
  144. package/site/dist/assets/PhWarningCircle-Cm58gXb9.js +14 -0
  145. package/site/dist/assets/PhX-C3b4cCEy.js +14 -0
  146. package/site/dist/assets/PhoneIcon-CzbssTb8.js +1 -0
  147. package/site/dist/assets/PinInput-DbZ0b1i1-1DtLWL81.js +247 -0
  148. package/site/dist/assets/QrCode-DbnZwlkH-ChwcUk_h.js +22 -0
  149. package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-C79jd345.js +1 -0
  150. package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-C9c0x-yq.js +1 -0
  151. package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-PNqHb6CI.js +7 -0
  152. package/site/dist/assets/{Screen-D30meWsY-CCeVNuWs.js → Screen-D30meWsY-DDum2qlY.js} +22 -22
  153. package/site/dist/assets/{ScreenHeader-CHmc4-Lu-DjyrH7IK.js → ScreenHeader-CHmc4-Lu-BqrAEXbV.js} +4 -4
  154. package/site/dist/assets/ScreenLayout-OwaQQcxH-B4Z8FjFp.js +1 -0
  155. package/site/dist/assets/{SelectSourceAsset-CWFog6gm-RKjBsB6m.js → SelectSourceAsset-CWFog6gm-8iXuqbAs.js} +18 -18
  156. package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-CUpQZ9wq.js +14 -0
  157. package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-ZzvPLj2s.js +15 -0
  158. package/site/dist/assets/ShieldCheckIcon-Bjwe_-PV.js +1 -0
  159. package/site/dist/assets/SignRequestScreen-BHKv32KR-0qGeNipB.js +26 -0
  160. package/site/dist/assets/{StackedContainer-B2vaEl56-eQCM2cmv.js → StackedContainer-B2vaEl56-C-ojzCoQ.js} +2 -2
  161. package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-C3lgJb68.js +20 -0
  162. package/site/dist/assets/{Subtitle-CV-2yKE4-zxWw2m1Q.js → Subtitle-CV-2yKE4-o-1FQLlX.js} +2 -2
  163. package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-l35_C2DG.js +1 -0
  164. package/site/dist/assets/{Title-BnzYV3Is-B_JpTatT.js → Title-BnzYV3Is-RX1f0RV-.js} +2 -2
  165. package/site/dist/assets/TodoList-DnyULl18-JxWWU9KA.js +36 -0
  166. package/site/dist/assets/TransactionDetails-e9nesl30-C91nJPM9.js +109 -0
  167. package/site/dist/assets/TransactionErrorView-BDBNqA_f-Cpm-4xzm.js +178 -0
  168. package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-BWCH7-Si.js +31 -0
  169. package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-BWMeJabk.js +6 -0
  170. package/site/dist/assets/TurnstileWrapper-B7sNddys-Dgr80Gih.js +1 -0
  171. package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-Clk4zk-8.js +1 -0
  172. package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-BgRsoR3B.js +1 -0
  173. package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-D-SU-vAz.js +1 -0
  174. package/site/dist/assets/{Value-DTgR824E-BRuIGiec.js → Value-DTgR824E-DZpvBCWi.js} +7 -7
  175. package/site/dist/assets/WalletCards-DH1rqayz-UuZ4i_Ze.js +1 -0
  176. package/site/dist/assets/WalletIcon-B1i03Vqc.js +1 -0
  177. package/site/dist/assets/WalletInfoCard-sq_2wgFg-TXTxmb8L.js +29 -0
  178. package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-CbrFb0ON.js +1 -0
  179. package/site/dist/assets/WalletLink-DK5LB5Ha-BYQZV7UV.js +20 -0
  180. package/site/dist/assets/WalletOverflowButton-bfCnp-9T-CNgSPnTS.js +1 -0
  181. package/site/dist/assets/WarningBanner-ZZqCEtZK-DNZUUOph.js +21 -0
  182. package/site/dist/assets/__vite-browser-external-BIHI7g3E.js +1 -0
  183. package/site/dist/assets/analytics-mkkvFRju-DOXuftJB.js +1 -0
  184. package/site/dist/assets/basic-C9wn6QoQ.js +1575 -0
  185. package/site/dist/assets/bytes-CjWw8TJh.js +1 -0
  186. package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-tV1Idewc.js +1 -0
  187. package/site/dist/assets/ccip-BhHEqVIW.js +1 -0
  188. package/site/dist/assets/check-C_DTyjLS.js +1 -0
  189. package/site/dist/assets/chevron-down-iklXXH-z.js +1 -0
  190. package/site/dist/assets/circle-alert-KEOUF48T.js +1 -0
  191. package/site/dist/assets/circle-check-big-BJ_ADwB4.js +1 -0
  192. package/site/dist/assets/circle-x-BSfWmhYk.js +1 -0
  193. package/site/dist/assets/client-BnDcP42J.js +9 -0
  194. package/site/dist/assets/client-DH86IrJA.js +125 -0
  195. package/site/dist/assets/coinbase-DCPC2L_R-2ivYfoMv.js +3 -0
  196. package/site/dist/assets/copy-sK00DOfH.js +1 -0
  197. package/site/dist/assets/core-CRE213RM.js +211 -0
  198. package/site/dist/assets/createLucideIcon-D9OK_uxG.js +1 -0
  199. package/site/dist/assets/custom-V1wex-Di.js +1 -0
  200. package/site/dist/assets/dijkstra-COg3n3zL.js +1 -0
  201. package/site/dist/assets/embed.worker-BRIYO7m8.js +1 -0
  202. package/site/dist/assets/encodePacked-DyXYq3Cc.js +1 -0
  203. package/site/dist/assets/ethers-zTjbodk5-DSYOi6tU.js +1 -0
  204. package/site/dist/assets/external-link-Cdp8NBio.js +1 -0
  205. package/site/dist/assets/fallback-DiFue5Zm.js +1 -0
  206. package/site/dist/assets/farcaster-DPlSjvF5-DP2DLoHZ.js +1 -0
  207. package/site/dist/assets/features-B6BTj_BL.js +5 -0
  208. package/site/dist/assets/fingerprint-pattern-gFJTz5e4.js +1 -0
  209. package/site/dist/assets/floating-ui.react-D9ndYqYK.js +1 -0
  210. package/site/dist/assets/floating-ui.react-dom-CNbOgOFt.js +1 -0
  211. package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-CkAr4Oc0.js +1 -0
  212. package/site/dist/assets/getChainName-DjpPdUSc-c2urPd0g.js +1 -0
  213. package/site/dist/assets/getErc20Balance-jXNpFf0N-mFQ9Iqk-.js +1 -0
  214. package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-Dx5he_uG.js +1 -0
  215. package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-C446pzMl.js +1 -0
  216. package/site/dist/assets/getTransactionCount-80UHlwAV.js +1 -0
  217. package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-FDalV59C.js +1 -0
  218. package/site/dist/assets/hashTypedData-Beq57Ogb.js +22 -0
  219. package/site/dist/assets/hooks.module-ClpaQ1Tg.js +1 -0
  220. package/site/dist/assets/hourglass-CB7z_I9H.js +1 -0
  221. package/site/dist/assets/http-BocEfKYb.js +19 -0
  222. package/site/dist/assets/index-0knDOgU9.js +1 -0
  223. package/site/dist/assets/index-9jNeS_nC.js +1 -0
  224. package/site/dist/assets/index-B--T-Fmt.js +16 -0
  225. package/site/dist/assets/index-BDkarAkX.js +2 -0
  226. package/site/dist/assets/index-BMfMy017.js +679 -0
  227. package/site/dist/assets/index-BOd8jv8-.js +1 -0
  228. package/site/dist/assets/index-BdEw5wyl-2VGMzHIs.js +1 -0
  229. package/site/dist/assets/index-C8ThRelw.js +9 -0
  230. package/site/dist/assets/{index-CWARkn2w-Cezl_uBr.js → index-CWARkn2w-D6ikWJWj.js} +7 -7
  231. package/site/dist/assets/{wui-ux-by-reown-fVu0QkI4.js → index-CztIxJB6.js} +296 -296
  232. package/site/dist/assets/index-D4LdLFDC.js +1 -0
  233. package/site/dist/assets/index-D6T-s6sR.js +1 -0
  234. package/site/dist/assets/index-D7396TWe.js +1 -0
  235. package/site/dist/assets/index-DdxtHe81.js +2 -0
  236. package/site/dist/assets/index-DvMddJcd-D7AEQrzj.js +12 -0
  237. package/site/dist/assets/index-nibyPLVP.js +1 -0
  238. package/site/dist/assets/index.browser-B6Bt5URJ.js +1 -0
  239. package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-D7xtzRqA.js +1 -0
  240. package/site/dist/assets/landmark-CMLKifhk.js +1 -0
  241. package/site/dist/assets/lock-BkyjNE8h.js +1 -0
  242. package/site/dist/assets/mail-B6-Tq9Ld.js +1 -0
  243. package/site/dist/assets/native-CJ5et6AR.js +1 -0
  244. package/site/dist/assets/nonceManager-zkW7cM66.js +1 -0
  245. package/site/dist/assets/parseEther-C7aOvuze.js +1 -0
  246. package/site/dist/assets/parseSignature-BIjcuWdB.js +1 -0
  247. package/site/dist/assets/preload-helper-PPVm8Dsz.js +1 -0
  248. package/site/dist/assets/privateKeyToAccount-CRvvpHWf.js +1 -0
  249. package/site/dist/assets/property-CnFDNXw5.js +3 -0
  250. package/site/dist/assets/react-auth_false-DedQs79w.js +1 -0
  251. package/site/dist/assets/reservoir-x-nGuZkT-DFxAFt2v.js +1 -0
  252. package/site/dist/assets/roles-DV_6FRBZ.js +1 -0
  253. package/site/dist/assets/safe-url-D7SRPu33-A8zMgOTd.js +1 -0
  254. package/site/dist/assets/serializeErc6492Signature-CeJeL3h6.js +1 -0
  255. package/site/dist/assets/serializeTransaction-L-_Ej-jW.js +8 -0
  256. package/site/dist/assets/{shared-DRZUmnL5-xqAUARWo.js → shared-DRZUmnL5-MWD-C-pp.js} +33 -33
  257. package/site/dist/assets/{shared-FM0rljBt--Avg6q2R.js → shared-FM0rljBt-c4eSjzGj.js} +6 -6
  258. package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-CF2QteTJ.js +1 -0
  259. package/site/dist/assets/simulateTransaction-CfuOrae4-BHUMPf6Q.js +1 -0
  260. package/site/dist/assets/smartphone-DAN5rY0T.js +1 -0
  261. package/site/dist/assets/stripe.esm-Dv8C3q95.js +2 -0
  262. package/site/dist/assets/styles-BsotlekN-Cjuu2SDV.js +9 -0
  263. package/site/dist/assets/{styles-Cm9H63WO-D90SsXOs.js → styles-Cm9H63WO-Cv1TbqYi.js} +17 -17
  264. package/site/dist/assets/{styles-DVyDvTdj-BTABn2K8.js → styles-DVyDvTdj-CI4xZNHp.js} +8 -8
  265. package/site/dist/assets/{styles-hslXy6xG-D-49b1rk.js → styles-hslXy6xG-DeVcFoDD.js} +23 -23
  266. package/site/dist/assets/telegram-B-JqnkqZ-DTjJLkIF.js +1 -0
  267. package/site/dist/assets/to-ui-error-DWe-qwS3-Dx3yzcV0.js +4 -0
  268. package/site/dist/assets/toAccount-Bq6rbpbI.js +1 -0
  269. package/site/dist/assets/transaction-BNTP-bFm-CrebgH-D.js +1 -0
  270. package/site/dist/assets/transactionReceipt-BwJl-gjg.js +1 -0
  271. package/site/dist/assets/transfer-6YztDh-t-DU6hH7CZ.js +1 -0
  272. package/site/dist/assets/transformers.web-BEKVh7pD.js +40 -0
  273. package/site/dist/assets/transformers.web-aWa49tv1.js +40 -0
  274. package/site/dist/assets/triangle-alert-ndoiBs4y.js +1 -0
  275. package/site/dist/assets/twitch-5IOe4sIQ-BXviIywg.js +1 -0
  276. package/site/dist/assets/useGetSolPrice-x7gfUIHJ-C7axYJ--.js +1 -0
  277. package/site/dist/assets/useGetTokenPrice-CaoUkb79-CR4CrguU.js +1 -0
  278. package/site/dist/assets/useI18n-C-5n_noF-C_t8QqBJ.js +1 -0
  279. package/site/dist/assets/useWalletBalance-CZnP5f_f-BnSHLVI_.js +1 -0
  280. package/site/dist/assets/w3m-modal-Bz5KWTQ-.js +1174 -0
  281. package/site/dist/assets/wallet-DTM31trz.js +2 -0
  282. package/site/dist/assets/wallet-UESEqPei.js +1 -0
  283. package/site/dist/assets/wallet-connect-BvJtUsDt-CnvUnFbz.js +1 -0
  284. package/site/dist/assets/walletconnect-v2-3frQFwbg-CzQk99gS.js +15 -0
  285. package/site/dist/assets/x-B2_XdOVQ.js +1 -0
  286. package/site/dist/index.html +120 -8
  287. package/site/feed.js +16 -1
  288. package/site/no-model.js +4 -0
  289. package/site/worker.js +597 -58
  290. package/src/agent/agent-card.js +20 -11
  291. package/src/agent/mcp.js +150 -316
  292. package/src/agent/view-tools.js +53 -12
  293. package/src/agent/x402.js +379 -44
  294. package/src/core/embed.js +51 -52
  295. package/src/core/embed.worker.js +1 -1
  296. package/src/core/shard.js +7 -3
  297. package/src/discover/apps.js +4 -3
  298. package/src/discover/explore.js +36 -22
  299. package/src/market/reactions.js +2 -2
  300. package/src/publish/devnet.js +95 -0
  301. package/src/publish/lint.js +2 -1
  302. package/src/publish/ship.js +517 -236
  303. package/src/publish/view-cli.js +11 -10
  304. package/src/publish/view.js +359 -206
  305. package/src/taste/taste-doc.js +3 -2
  306. package/src/taste/taste.js +2 -2
  307. package/src/taste/vault.js +3 -1
  308. package/site/dist/assets/AccountNotFoundScreen-C4njXc69-BOfmiSH1.js +0 -1
  309. package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-B6uvYyqa.js +0 -31
  310. package/site/dist/assets/Address-H8kD1d9O-DcHv7A8C.js +0 -17
  311. package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-v2wz-N-s.js +0 -6
  312. package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-DhVy9iGN.js +0 -1
  313. package/site/dist/assets/ApiController-BbhXeqTV.js +0 -5
  314. package/site/dist/assets/ArrowsRightLeftIcon-cp60yobq.js +0 -1
  315. package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-B0eT1zE6.js +0 -1
  316. package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-DL5PH-v_.js +0 -1
  317. package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-n1BsRPqc.js +0 -1
  318. package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-BVl2BJDY.js +0 -103
  319. package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-BD-OZUQb.js +0 -1
  320. package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-CaYrzRje.js +0 -68
  321. package/site/dist/assets/CaptchaScreen-DbpvkIGx-BQJ7inx1.js +0 -1
  322. package/site/dist/assets/CheckCircleIcon-BM409mGI.js +0 -1
  323. package/site/dist/assets/CheckCircleIcon-NCOQc0Gs.js +0 -1
  324. package/site/dist/assets/Checkbox-D1EDeo41-rHlvsZzP.js +0 -52
  325. package/site/dist/assets/ChevronDownIcon-CW-4MSpE.js +0 -1
  326. package/site/dist/assets/Chip-CZKIKt9K-CutJG010.js +0 -26
  327. package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-DDaMC7cl.js +0 -16
  328. package/site/dist/assets/ConnectEmailForm-B-VRE0MN-DVSf4tFJ.js +0 -3
  329. package/site/dist/assets/ConnectLedgerScreen-DWHABGot-h0uYIUi6.js +0 -10
  330. package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-DP19hJq5.js +0 -1
  331. package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-DHvijlTx.js +0 -1
  332. package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-ewmXYPTQ.js +0 -1
  333. package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-DUYdmVtr.js +0 -95
  334. package/site/dist/assets/ConnectWalletView-DqI-PTvX-RobGErVW.js +0 -74
  335. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-Bbiq3hY6.js +0 -1
  336. package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-DPkOGNWl.js +0 -7
  337. package/site/dist/assets/ConnectorUtil-BO1L6VvV.js +0 -21
  338. package/site/dist/assets/ConstantsUtil-DmLsRHAl.js +0 -198
  339. package/site/dist/assets/CopyToClipboard-i_OQSBJr-DujUHNzW.js +0 -39
  340. package/site/dist/assets/CopyableText-CQapvaMr-DMIdpDaU.js +0 -28
  341. package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-DbGy4QyA.js +0 -1
  342. package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-B3WqJZBh.js +0 -22
  343. package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-CmUDoS0C.js +0 -1
  344. package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-fcO51q5H.js +0 -1
  345. package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-ClAb_j1B.js +0 -187
  346. package/site/dist/assets/DepositAddressScreen-DBLRs7aI-CN1P_KY9.js +0 -8
  347. package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-BtDZmuEN.js +0 -1
  348. package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-D3pExuaW.js +0 -1
  349. package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-CLsJbPYQ.js +0 -1
  350. package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-DI6bu-oi.js +0 -23
  351. package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-BQ9Ygr0P.js +0 -1
  352. package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-CxrfLr5q.js +0 -1
  353. package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-DHZRGoTN.js +0 -1
  354. package/site/dist/assets/EnrollTotp-Dibew4dp-7gVtJ1Jt.js +0 -66
  355. package/site/dist/assets/EnvelopeIcon-Dh2vSVj4.js +0 -1
  356. package/site/dist/assets/ErrorBanner-BcpGRt0h-BKOYTyCi.js +0 -21
  357. package/site/dist/assets/ErrorScreen-DipdTWzE-BT8TtRTx.js +0 -4
  358. package/site/dist/assets/ErrorScreen-DipdTWzE-DAam41Xl.js +0 -1
  359. package/site/dist/assets/ExclamationCircleIcon-DUA2wMfO.js +0 -1
  360. package/site/dist/assets/ExclamationTriangleIcon-eZfaqcFq.js +0 -1
  361. package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-BPCBi37Q.js +0 -75
  362. package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-XCmWpnUd.js +0 -28
  363. package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-DJRcUh2N.js +0 -491
  364. package/site/dist/assets/FingerPrintIcon-Dm6kxmg7.js +0 -1
  365. package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-BfNVSTb1.js +0 -1
  366. package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-BQdbJ5Bb.js +0 -1
  367. package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-BfvMcHb6.js +0 -58
  368. package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-VBfbahnA.js +0 -1
  369. package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-CMuBYf64.js +0 -1
  370. package/site/dist/assets/GlobeAltIcon-vqrVV5ho.js +0 -1
  371. package/site/dist/assets/GooglePay-B53WnudL-BX5_WtCx.js +0 -1
  372. package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-D-I8j7NO.js +0 -4
  373. package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-BY3j50El.js +0 -1
  374. package/site/dist/assets/InfoBanner-Cb3p1z12-DLBl_Ywy.js +0 -22
  375. package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-DLSV_NjP.js +0 -1
  376. package/site/dist/assets/InstallWalletScreen-DTA8dwLv-CxreyXoD.js +0 -1
  377. package/site/dist/assets/LandingScreen-CGWUoSUG-Q7hgXKvM.js +0 -1
  378. package/site/dist/assets/Link-BdDilT2T-BEDEdHuS.js +0 -40
  379. package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-DK1z_v7y.js +0 -77
  380. package/site/dist/assets/LinkEmailScreen-dKo9frwc-BYYpJ5-6.js +0 -1
  381. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-uhub9C26.js +0 -1
  382. package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-uid22VTN.js +0 -117
  383. package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-CVQibNi9.js +0 -1
  384. package/site/dist/assets/Loader-UAZqxsnw-Cy7hEE2f.js +0 -62
  385. package/site/dist/assets/LockClosedIcon-BgY_5v_Z.js +0 -1
  386. package/site/dist/assets/LoginFailedScreen-CN0dJV6U-DhUMiJZJ.js +0 -1
  387. package/site/dist/assets/ManualTransferScreen-CHqcuqbs-DMygAXMU.js +0 -1
  388. package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-_1GFUSIg.js +0 -1
  389. package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-DLnBJ5b8.js +0 -1
  390. package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-BUJY1lzs.js +0 -1
  391. package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-25l5fVun.js +0 -1
  392. package/site/dist/assets/ModalFooter-BCuEK_nz-c-khvG4Y.js +0 -403
  393. package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-BRFN2eXr.js +0 -16
  394. package/site/dist/assets/OAuthStatusScreen-ufbOa-da-DL30vu07.js +0 -1
  395. package/site/dist/assets/OpenLink-CUpJ1mOr-DfAvJRyK.js +0 -39
  396. package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-DtxhRQyw.js +0 -1
  397. package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-CNfu8ujT.js +0 -6
  398. package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-BR6z6xE8.js +0 -20
  399. package/site/dist/assets/PhArrowClockwise-DVgyFuez.js +0 -14
  400. package/site/dist/assets/PhArrowDown-87b1BizM.js +0 -14
  401. package/site/dist/assets/PhArrowLeft-Da0MfnbK.js +0 -14
  402. package/site/dist/assets/PhArrowRight-AdrIL4DW.js +0 -14
  403. package/site/dist/assets/PhArrowUp-4sgyKPGx.js +0 -14
  404. package/site/dist/assets/PhArrowUpRight-BNghD2zq.js +0 -14
  405. package/site/dist/assets/PhArrowsLeftRight-MuKBLUoF.js +0 -14
  406. package/site/dist/assets/PhBrowser-2-9m-AkM.js +0 -14
  407. package/site/dist/assets/PhCaretDown-BDNabFuL.js +0 -14
  408. package/site/dist/assets/PhCaretLeft-CI460R-A.js +0 -14
  409. package/site/dist/assets/PhCaretRight-D7ZS3Ls8.js +0 -14
  410. package/site/dist/assets/PhCaretUp-C-iIfyvO.js +0 -14
  411. package/site/dist/assets/PhCheck-DxQXn57r.js +0 -14
  412. package/site/dist/assets/PhClock-x3MS3Mwi.js +0 -14
  413. package/site/dist/assets/PhCopy-CWNYcABI.js +0 -14
  414. package/site/dist/assets/PhDeviceMobile-CsyA5Goi.js +0 -14
  415. package/site/dist/assets/PhDotsThree-D-k1BiYg.js +0 -14
  416. package/site/dist/assets/PhEnvelope-D8kzeNox.js +0 -14
  417. package/site/dist/assets/PhFunnelSimple-CfQs5DAW.js +0 -14
  418. package/site/dist/assets/PhMagnifyingGlass-C9u8jSCJ.js +0 -14
  419. package/site/dist/assets/PhPlus-C4UoW-2n.js +0 -14
  420. package/site/dist/assets/PhWarningCircle-BXHw1fCt.js +0 -14
  421. package/site/dist/assets/PhX-DX0SFIqC.js +0 -14
  422. package/site/dist/assets/PhoneIcon-CvIiPwYQ.js +0 -1
  423. package/site/dist/assets/PinInput-DbZ0b1i1-CDXZBdQx.js +0 -247
  424. package/site/dist/assets/PrivyPluginContext-DA-yS5vO-CtQWBiV2.js +0 -1
  425. package/site/dist/assets/QrCode-DbnZwlkH-BymHrKY7.js +0 -22
  426. package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-Dro1btv5.js +0 -1
  427. package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-C1q1hiaN.js +0 -1
  428. package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-C21D20gD.js +0 -7
  429. package/site/dist/assets/SIWXUtil-CHZVugix.js +0 -1
  430. package/site/dist/assets/ScreenLayout-OwaQQcxH-CrQM6kvA.js +0 -1
  431. package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-BcWHJoEG.js +0 -14
  432. package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-kq1zvA7d.js +0 -11
  433. package/site/dist/assets/ShieldCheckIcon-o6RHYev1.js +0 -1
  434. package/site/dist/assets/SignRequestScreen-BHKv32KR-iQCaBkcz.js +0 -26
  435. package/site/dist/assets/SolanaWalletConnector-C7Lqk-Wz-BUdJJ0ep.js +0 -1
  436. package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-nART-xUU.js +0 -20
  437. package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-Dw9geyK3.js +0 -1
  438. package/site/dist/assets/TodoList-DnyULl18-C8Eyy28X.js +0 -36
  439. package/site/dist/assets/TransactionDetails-e9nesl30-DeEL1JQS.js +0 -109
  440. package/site/dist/assets/TransactionErrorView-BDBNqA_f-Dffuo7I4.js +0 -178
  441. package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-CWLWUiHy.js +0 -31
  442. package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-Bo-tm6wr.js +0 -6
  443. package/site/dist/assets/TurnstileWrapper-B7sNddys-Jwy1tJtm.js +0 -1
  444. package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-gFbSIUhh.js +0 -1
  445. package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-Coy4E1NQ.js +0 -1
  446. package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-D7m70C4b.js +0 -1
  447. package/site/dist/assets/WalletCards-DH1rqayz-Bgp9Fsgs.js +0 -1
  448. package/site/dist/assets/WalletIcon-gKf0gTw6.js +0 -1
  449. package/site/dist/assets/WalletInfoCard-sq_2wgFg-ISBsQt8p.js +0 -29
  450. package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-DG-RuO-F.js +0 -1
  451. package/site/dist/assets/WalletLink-DK5LB5Ha-CXBqCHf3.js +0 -20
  452. package/site/dist/assets/WalletOverflowButton-bfCnp-9T-DP0-PoZL.js +0 -1
  453. package/site/dist/assets/WarningBanner-ZZqCEtZK-2eU4Qo74.js +0 -21
  454. package/site/dist/assets/__vite-browser-external-CitKSmYk.js +0 -1
  455. package/site/dist/assets/_esm-CJe2F7LL.js +0 -7
  456. package/site/dist/assets/_esm-zhBBffjV.js +0 -1
  457. package/site/dist/assets/accounts-Bq8t1wAD.js +0 -1
  458. package/site/dist/assets/accounts-D96UKWkC.js +0 -1
  459. package/site/dist/assets/analytics-mkkvFRju-BRBcadka.js +0 -1
  460. package/site/dist/assets/baseSepolia-DX-qGsik.js +0 -1
  461. package/site/dist/assets/basic-MlZ7f4s9.js +0 -1575
  462. package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-DtOXx-2n.js +0 -1
  463. package/site/dist/assets/ccip-BI9LWBBg.js +0 -1
  464. package/site/dist/assets/ccip-C-59SNEF.js +0 -7
  465. package/site/dist/assets/ccip-y08wK9du.js +0 -1
  466. package/site/dist/assets/chain-DM3oH6Px.js +0 -8
  467. package/site/dist/assets/check-BPgcwEPP.js +0 -1
  468. package/site/dist/assets/chevron-down-BSsbXkK-.js +0 -1
  469. package/site/dist/assets/circle-alert-DWaeLZNj.js +0 -1
  470. package/site/dist/assets/circle-check-big-Chb1ivw9.js +0 -1
  471. package/site/dist/assets/circle-x-AV9Cet0R.js +0 -1
  472. package/site/dist/assets/client-D0IV9lV9.js +0 -2
  473. package/site/dist/assets/client-Dsa7_3V3.js +0 -9
  474. package/site/dist/assets/coinbase-DCPC2L_R-Rs9nVCfm.js +0 -3
  475. package/site/dist/assets/copy-Ckr0AkL6.js +0 -1
  476. package/site/dist/assets/core-zQ1tZtVZ.js +0 -12
  477. package/site/dist/assets/createLucideIcon-IPW50ckY.js +0 -1
  478. package/site/dist/assets/defineChain-CiuCXUZW.js +0 -1
  479. package/site/dist/assets/dijkstra-Drfl93V4.js +0 -1
  480. package/site/dist/assets/dist-BxQqwnue.js +0 -16
  481. package/site/dist/assets/dist-Cm7pNAtL.js +0 -1
  482. package/site/dist/assets/dist-CoS6E-3x.js +0 -1
  483. package/site/dist/assets/dist-Dl07uGq1.js +0 -1
  484. package/site/dist/assets/embed.worker-ugGhEqCV.js +0 -1
  485. package/site/dist/assets/errors-BQ3N-RVt-BLqjTPNR.js +0 -1
  486. package/site/dist/assets/esm-C3DslVJx.js +0 -1
  487. package/site/dist/assets/esm-Ci1ogKuK.js +0 -1
  488. package/site/dist/assets/esm-DXsETz3H.js +0 -1
  489. package/site/dist/assets/esm-n2lWo7kz.js +0 -1
  490. package/site/dist/assets/esm-vs5jNx_Y.js +0 -37
  491. package/site/dist/assets/ethers-zTjbodk5-B7BBFFKf.js +0 -1
  492. package/site/dist/assets/eventemitter3-CL76jPsW.js +0 -1
  493. package/site/dist/assets/external-link-D-uehwM2.js +0 -1
  494. package/site/dist/assets/farcaster-DPlSjvF5-BqTvDXBR.js +0 -1
  495. package/site/dist/assets/features-CYXRa3_m.js +0 -2
  496. package/site/dist/assets/fingerprint-pattern-D8ytA16Q.js +0 -1
  497. package/site/dist/assets/floating-ui.react-dom-DKWOL9UG.js +0 -1
  498. package/site/dist/assets/floating-ui.react-xRkl9O3u.js +0 -1
  499. package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-BVqOKQif.js +0 -1
  500. package/site/dist/assets/formatter-CVbp4SlJ.js +0 -1
  501. package/site/dist/assets/get-entropy-details-for-user-dHRH5Gpi-Dukf7_kJ.js +0 -1
  502. package/site/dist/assets/getChainName-DjpPdUSc-DUyKDrnp.js +0 -1
  503. package/site/dist/assets/getErc20Balance-jXNpFf0N-V2btxzrJ.js +0 -1
  504. package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-CtCwQuGA.js +0 -1
  505. package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-Gx4_wxON.js +0 -1
  506. package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-r2UnDeEy.js +0 -1
  507. package/site/dist/assets/guards-BIW-GiMJ-CHfXo8XI.js +0 -1
  508. package/site/dist/assets/hooks.module-BYZGfwDl.js +0 -1
  509. package/site/dist/assets/hourglass-CPG1HZmf.js +0 -1
  510. package/site/dist/assets/id-UqEwL2BI-CdKXapd-.js +0 -1
  511. package/site/dist/assets/index-BdEw5wyl-ChSJvPZk.js +0 -1
  512. package/site/dist/assets/index-CKdAF_dK.js +0 -8
  513. package/site/dist/assets/index-DvMddJcd-D-4mRLKK.js +0 -12
  514. package/site/dist/assets/index-YiCw0Y_x-BX1zsiqG.js +0 -437
  515. package/site/dist/assets/index.browser-B-i-Lj3J.js +0 -1
  516. package/site/dist/assets/index.browser-BMmUcykv.js +0 -1
  517. package/site/dist/assets/index.es-BmqyoBEM.js +0 -2
  518. package/site/dist/assets/index.es-C1v1or--.js +0 -3
  519. package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-By6r0dVB.js +0 -1
  520. package/site/dist/assets/jsx-runtime-BbDfbRii.js +0 -1
  521. package/site/dist/assets/landmark-CH6LV6F0.js +0 -1
  522. package/site/dist/assets/lib-BsS8z8Lj.js +0 -1
  523. package/site/dist/assets/localBatchGatewayRequest-5YxrERBj.js +0 -32
  524. package/site/dist/assets/lock-DcskI4Bb.js +0 -1
  525. package/site/dist/assets/logger-CsXm3oIv-B0UYpNFI.js +0 -1
  526. package/site/dist/assets/mail-Bs0r5yOi.js +0 -1
  527. package/site/dist/assets/modal-context-CwmSeFcv-DruX9J1E.js +0 -1
  528. package/site/dist/assets/native-BKj27wfc.js +0 -1
  529. package/site/dist/assets/ofetch.CWycOUEr-CHp-crOQ.js +0 -1
  530. package/site/dist/assets/parseAbi-Csg-8t59.js +0 -2
  531. package/site/dist/assets/parseAbiParameters-BWbIMYe4.js +0 -1
  532. package/site/dist/assets/parseEther-CGP3gnf2.js +0 -1
  533. package/site/dist/assets/pkce-DXF0yKjP-Bqz4wAsq.js +0 -1
  534. package/site/dist/assets/preload-helper-BaNbYf_w.js +0 -1
  535. package/site/dist/assets/privy-context-81KmsBw2-CjWGzyg7.js +0 -2
  536. package/site/dist/assets/property-DuZ9DLP4.js +0 -3
  537. package/site/dist/assets/react-DCXkXSrv.js +0 -1
  538. package/site/dist/assets/react-DQnMl2Xv.js +0 -1
  539. package/site/dist/assets/react-DrJ0MmMO.js +0 -1
  540. package/site/dist/assets/react-auth-sHnipzbS.js +0 -1
  541. package/site/dist/assets/react-dom-5dW7aKoP.js +0 -1
  542. package/site/dist/assets/reservoir-x-nGuZkT-BMX127i6.js +0 -1
  543. package/site/dist/assets/roles-32M1l9jI.js +0 -1
  544. package/site/dist/assets/roles-DKPW79Ca.js +0 -1
  545. package/site/dist/assets/rolldown-runtime-BcKkbAw3.js +0 -1
  546. package/site/dist/assets/safe-url-D7SRPu33-CkMedGro.js +0 -1
  547. package/site/dist/assets/secp256k1-C4nzcPo-.js +0 -1
  548. package/site/dist/assets/secp256k1-D92aGNnU.js +0 -1
  549. package/site/dist/assets/secp256k1-DmbwyFau.js +0 -1
  550. package/site/dist/assets/secp256k1-_MleGpqL.js +0 -1
  551. package/site/dist/assets/secp256k1-xl2og-wO.js +0 -1
  552. package/site/dist/assets/serializeAuthorizationList-CX8hGL56.js +0 -1
  553. package/site/dist/assets/serializeSignature-DfxkPnu-.js +0 -2
  554. package/site/dist/assets/sha2-BU_QyRTx.js +0 -1
  555. package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-ByFOTrQK.js +0 -1
  556. package/site/dist/assets/simulateTransaction-CfuOrae4-CMFGDgT_.js +0 -1
  557. package/site/dist/assets/smartphone-CcEZ-XAy.js +0 -1
  558. package/site/dist/assets/src-BBjkfi-Q.js +0 -1
  559. package/site/dist/assets/storage-Ufl800Ne-EalZTH9q.js +0 -9
  560. package/site/dist/assets/stringify-BlDm7tuc.js +0 -21
  561. package/site/dist/assets/stripe.esm-CZRDpc-N.js +0 -2
  562. package/site/dist/assets/styles-BsotlekN-CXEB4Ud9.js +0 -9
  563. package/site/dist/assets/telegram-B-JqnkqZ-RBoY3PLx.js +0 -1
  564. package/site/dist/assets/to-ui-error-DWe-qwS3-DgCO-Y70.js +0 -4
  565. package/site/dist/assets/toViemAccount-B5iDGq1b-DZ1MBqUW.js +0 -2
  566. package/site/dist/assets/transaction-BNTP-bFm-M5tJx8vY.js +0 -1
  567. package/site/dist/assets/transfer-6YztDh-t-BVQkTvG-.js +0 -1
  568. package/site/dist/assets/transformers.web-D4RvOP4-.js +0 -40
  569. package/site/dist/assets/transformers.web-D8W1u_I2.js +0 -49
  570. package/site/dist/assets/triangle-alert-CWjYH75H.js +0 -1
  571. package/site/dist/assets/twitch-5IOe4sIQ-lDtgk0os.js +0 -1
  572. package/site/dist/assets/types-4CuOD23i.js +0 -1
  573. package/site/dist/assets/use-headless-crypto-deposit-Yn-QRLB3-Dn6_8w-Y.js +0 -1
  574. package/site/dist/assets/use-unlink-wallet-BKK4_5Ur-DgsQ75lh.js +0 -1
  575. package/site/dist/assets/useActiveWallet-B-yZYGc6-B6JWREbk.js +0 -123
  576. package/site/dist/assets/useGetSolPrice-x7gfUIHJ-D1hmQfpA.js +0 -1
  577. package/site/dist/assets/useGetTokenPrice-CaoUkb79-ZnbuJ-vP.js +0 -1
  578. package/site/dist/assets/useI18n-C-5n_noF-BcqC76yj.js +0 -1
  579. package/site/dist/assets/useWalletBalance-CZnP5f_f-L3V0jDjL.js +0 -1
  580. package/site/dist/assets/useWallets-X1ndvJ_U-CLwUcevw.js +0 -1
  581. package/site/dist/assets/utils-BkR7EQjg.js +0 -1
  582. package/site/dist/assets/utils-DJhBNOZA.js +0 -1
  583. package/site/dist/assets/utils-DdckVfQr.js +0 -1
  584. package/site/dist/assets/w3m-modal-BMubXAoG.js +0 -1174
  585. package/site/dist/assets/wallet-Bn85Sg2W.js +0 -1
  586. package/site/dist/assets/wallet-connect-BvJtUsDt-Y03hhqFN.js +0 -1
  587. package/site/dist/assets/wallet-uSKqQsgP.js +0 -2
  588. package/site/dist/assets/walletconnect-registry-xxG8XLCb-D1SSFvMp.js +0 -1
  589. package/site/dist/assets/walletconnect-v2-3frQFwbg-Dv6JY_ko.js +0 -12
  590. package/site/dist/assets/x-rlSp9U7W.js +0 -1
@@ -0,0 +1,40 @@
1
+ var di=Object.defineProperty,Qb=Object.getOwnPropertyDescriptor,Xb=Object.getOwnPropertyNames,Yb=Object.prototype.hasOwnProperty,Jb=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),ge=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}},Zn=(e,t)=>{for(var r in t)di(e,r,{get:t[r],enumerable:!0})},Kb=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xb(t))!Yb.call(e,s)&&s!==r&&di(e,s,{get:()=>t[s],enumerable:!(n=Qb(t,s))||n.enumerable});return e},Us=e=>Kb(di({},"__esModule",{value:!0}),e),Vn,hr,Gr,kh,t_,r_=ge(()=>{"use strict";Vn=new Map,hr=[],Gr=(e,t,r)=>{if(t&&typeof t.init=="function"&&typeof t.createInferenceSessionHandler=="function"){let n=Vn.get(e);if(n===void 0)Vn.set(e,{backend:t,priority:r});else{if(n.priority>r)return;if(n.priority===r&&n.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${r}`)}if(r>=0){let s=hr.indexOf(e);s!==-1&&hr.splice(s,1);for(let a=0;a<hr.length;a++)if(Vn.get(hr[a]).priority<=r){hr.splice(a,0,e);return}hr.push(e)}return}throw new TypeError("not a valid backend")},kh=async e=>{let t=Vn.get(e);if(!t)return"backend not found.";if(t.initialized)return t.backend;if(t.aborted)return t.error;{let r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(n){return r||(t.error=`${n}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},t_=async e=>{let t=e.executionProviders||[],r=t.map(l=>typeof l=="string"?l:l.name),n=r.length===0?hr:r,s,a=[],o=new Set;for(let l of n){let u=await kh(l);typeof u=="string"?a.push({name:l,err:u}):(s||(s=u),s===u&&o.add(l))}if(!s)throw new Error(`no available backend found. ERR: ${a.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:u}of a)r.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${u}`);let i=t.filter(l=>o.has(typeof l=="string"?l:l.name));return[s,new Proxy(e,{get:(l,u)=>u==="executionProviders"?i:Reflect.get(l,u)})]}}),Zb=ge(()=>{"use strict";r_()}),n_,e0=ge(()=>{"use strict";n_="1.31.0-dev.20260911-2a43ec07e"}),uo,Je,s_=ge(()=>{"use strict";e0(),uo="warning",Je={wasm:{},webgl:{},webgpu:{},versions:{common:n_},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);uo=e}},get logLevel(){return uo}},Object.defineProperty(Je,"logLevel",{enumerable:!0})}),Be,t0=ge(()=>{"use strict";s_(),Be=Je}),a_,o_,r0=ge(()=>{"use strict";a_=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];let n=r.getContext("2d");if(n!=null){let s,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(s=e.dims[2],a=e.dims[3]):(s=e.dims[3],a=e.dims[2]);let o=t?.format!==void 0?t.format:"RGB",i=t?.norm,l,u;i===void 0||i.mean===void 0?l=[255,255,255,255]:typeof i.mean=="number"?l=[i.mean,i.mean,i.mean,i.mean]:(l=[i.mean[0],i.mean[1],i.mean[2],0],i.mean[3]!==void 0&&(l[3]=i.mean[3])),i===void 0||i.bias===void 0?u=[0,0,0,0]:typeof i.bias=="number"?u=[i.bias,i.bias,i.bias,i.bias]:(u=[i.bias[0],i.bias[1],i.bias[2],0],i.bias[3]!==void 0&&(u[3]=i.bias[3]));let h=a*s,f=0,_=h,g=h*2,w=-1;o==="RGBA"?(f=0,_=h,g=h*2,w=h*3):o==="RGB"?(f=0,_=h,g=h*2):o==="RBG"&&(f=0,g=h,_=h*2);for(let v=0;v<a;v++)for(let M=0;M<s;M++){let x=(e.data[f++]-u[0])*l[0],k=(e.data[_++]-u[1])*l[1],C=(e.data[g++]-u[2])*l[2],E=w===-1?255:(e.data[w++]-u[3])*l[3];n.fillStyle="rgba("+x+","+k+","+C+","+E+")",n.fillRect(M,v,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},o_=(e,t)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),n;if(r!=null){let s,a,o;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(s=e.dims[2],a=e.dims[1],o=e.dims[3]):(s=e.dims[3],a=e.dims[2],o=e.dims[1]);let i=t!==void 0&&t.format!==void 0?t.format:"RGB",l=t?.norm,u,h;l===void 0||l.mean===void 0?u=[255,255,255,255]:typeof l.mean=="number"?u=[l.mean,l.mean,l.mean,l.mean]:(u=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(u[3]=l.mean[3])),l===void 0||l.bias===void 0?h=[0,0,0,0]:typeof l.bias=="number"?h=[l.bias,l.bias,l.bias,l.bias]:(h=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(h[3]=l.bias[3]));let f=a*s;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!=="RGBA"||o===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let _=4,g=0,w=1,v=2,M=3,x=0,k=f,C=f*2,E=-1;i==="RGBA"?(x=0,k=f,C=f*2,E=f*3):i==="RGB"?(x=0,k=f,C=f*2):i==="RBG"&&(x=0,C=f,k=f*2),n=r.createImageData(s,a);for(let F=0;F<a*s;g+=_,w+=_,v+=_,M+=_,F++)n.data[g]=(e.data[x++]-h[0])*u[0],n.data[w]=(e.data[k++]-h[1])*u[1],n.data[v]=(e.data[C++]-h[2])*u[2],n.data[M]=E===-1?255:(e.data[E++]-h[3])*u[3]}else throw new Error("Can not access image data");return n}}),Es,i_,l_,c_,u_,d_,n0=ge(()=>{"use strict";hi(),Es=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:n}=t,s=t.norm??{mean:255,bias:0},a,o;typeof s.mean=="number"?a=[s.mean,s.mean,s.mean,s.mean]:a=[s.mean[0],s.mean[1],s.mean[2],s.mean[3]??255],typeof s.bias=="number"?o=[s.bias,s.bias,s.bias,s.bias]:o=[s.bias[0],s.bias[1],s.bias[2],s.bias[3]??0];let i=t.format!==void 0?t.format:"RGBA",l=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",u=r*n,h=l==="RGBA"?new Float32Array(u*4):new Float32Array(u*3),f=4,_=0,g=1,w=2,v=3,M=0,x=u,k=u*2,C=-1;i==="RGB"&&(f=3,_=0,g=1,w=2,v=-1),l==="RGBA"?C=u*3:l==="RBG"?(M=0,k=u,x=u*2):l==="BGR"&&(k=0,x=u,M=u*2);for(let E=0;E<u;E++,_+=f,w+=f,g+=f,v+=f)h[M++]=(e[_]+o[0])/a[0],h[x++]=(e[g]+o[1])/a[1],h[k++]=(e[w]+o[2])/a[2],C!==-1&&v!==-1&&(h[C++]=(e[v]+o[3])/a[3]);return l==="RGBA"?new mt("float32",h,[1,4,r,n]):new mt("float32",h,[1,3,r,n])},i_=async(e,t)=>{let r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,n=typeof ImageData<"u"&&e instanceof ImageData,s=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,a=typeof e=="string",o,i=t??{},l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=h=>typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement||h instanceof OffscreenCanvas?h.getContext("2d"):null;if(r){let h=l();h.width=e.width,h.height=e.height;let f=u(h);if(f!=null){let _=e.height,g=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(_=t.resizedHeight,g=t.resizedWidth),t!==void 0){if(i=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");i.tensorFormat="RGBA",i.height=_,i.width=g}else i.tensorFormat="RGBA",i.height=_,i.width=g;f.drawImage(e,0,0),o=f.getImageData(0,0,g,_).data}else throw new Error("Can not access image data")}else if(n){let h,f;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(h=t.resizedHeight,f=t.resizedWidth):(h=e.height,f=e.width),t!==void 0&&(i=t),i.format="RGBA",i.height=h,i.width=f,t!==void 0){let _=l();_.width=f,_.height=h;let g=u(_);if(g!=null)g.putImageData(e,0,0),o=g.getImageData(0,0,f,h).data;else throw new Error("Can not access image data")}else o=e.data}else if(s){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");let h=l();h.width=e.width,h.height=e.height;let f=u(h);if(f!=null){let _=e.height,g=e.width;return f.drawImage(e,0,0,g,_),o=f.getImageData(0,0,g,_).data,i.height=_,i.width=g,Es(o,i)}else throw new Error("Can not access image data")}else{if(a)return new Promise((h,f)=>{let _=l(),g=u(_);if(!e||!g)return f();let w=new Image;w.crossOrigin="Anonymous",w.src=e,w.onload=()=>{_.width=w.width,_.height=w.height,g.drawImage(w,0,0,_.width,_.height);let v=g.getImageData(0,0,_.width,_.height);i.height=_.height,i.width=_.width,h(Es(v.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(o!==void 0)return Es(o,i);throw new Error("Input data provided is not supported - aborted tensor creation")},l_=(e,t)=>{let{width:r,height:n,download:s,dispose:a}=t,o=[1,n,r,4];return new mt({location:"texture",type:"float32",texture:e,dims:o,download:s,dispose:a})},c_=(e,t)=>{let{dataType:r,dims:n,download:s,dispose:a}=t;return new mt({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:n,download:s,dispose:a})},u_=(e,t)=>{let{dataType:r,dims:n,download:s,dispose:a}=t;return new mt({location:"ml-tensor",type:r??"float32",mlTensor:e,dims:n,download:s,dispose:a})},d_=(e,t,r)=>new mt({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]})}),Br,Hn,ho,h_,s0=ge(()=>{"use strict";Br=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Hn=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ho=!1,h_=()=>{if(!ho){ho=!0;let e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,n=typeof r<"u"&&r.from;e&&(Br.set("int64",BigInt64Array),Hn.set(BigInt64Array,"int64")),t&&(Br.set("uint64",BigUint64Array),Hn.set(BigUint64Array,"uint64")),n?(Br.set("float16",r),Hn.set(r,"float16")):Br.set("float16",Uint16Array)}}}),f_,__,a0=ge(()=>{"use strict";hi(),f_=e=>{let t=1;for(let r=0;r<e.length;r++){let n=e[r];if(typeof n!="number"||!Number.isSafeInteger(n))throw new TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);t*=n}return t},__=(e,t)=>{switch(e.location){case"cpu":return new mt(e.type,e.data,t);case"cpu-pinned":return new mt({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new mt({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new mt({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new mt({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),mt,hi=ge(()=>{"use strict";r0(),n0(),s0(),a0(),mt=class{constructor(e,t,r){h_();let n,s;if(typeof e=="object"&&"location"in e)switch(this.dataLocation=e.location,n=e.type,s=e.dims,e.location){case"cpu-pinned":{let o=Br.get(n);if(!o)throw new TypeError(`unsupported type "${n}" to create tensor from pinned buffer`);if(!(e.data instanceof o))throw new TypeError(`buffer should be of type ${o.name}`);this.cpuData=e.data;break}case"texture":{if(n!=="float32")throw new TypeError(`unsupported type "${n}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break}case"gpu-buffer":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break}case"ml-tensor":{if(n!=="float32"&&n!=="float16"&&n!=="int32"&&n!=="int64"&&n!=="uint32"&&n!=="uint64"&&n!=="int8"&&n!=="uint8"&&n!=="bool"&&n!=="uint4"&&n!=="int4")throw new TypeError(`unsupported type "${n}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let o,i;if(typeof e=="string")if(n=e,i=r,e==="string"){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");o=t}else{let l=Br.get(e);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e==="float16"&&l===Uint16Array||e==="uint4"||e==="int4")throw new TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${l.name} as data.`);e==="uint64"||e==="int64"?o=l.from(t,BigInt):o=l.from(t)}else if(t instanceof l)o=t;else if(t instanceof Uint8ClampedArray)if(e==="uint8")o=Uint8Array.from(t);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(e==="float16"&&t instanceof Uint16Array&&l!==Uint16Array)o=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw new TypeError(`A ${n} tensor's data must be type of ${l}`)}else if(i=t,Array.isArray(e)){if(e.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof e[0];if(l==="string")n="string",o=e;else if(l==="boolean")n="bool",o=Uint8Array.from(e);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(e instanceof Uint8ClampedArray)n="uint8",o=Uint8Array.from(e);else{let l=Hn.get(e.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);n=l,o=e}if(i===void 0)i=[o.length];else if(!Array.isArray(i))throw new TypeError("A tensor's dims must be a number array");s=i,this.cpuData=o,this.dataLocation="cpu"}let a=f_(s);if(this.cpuData&&a!==this.cpuData.length&&!((n==="uint4"||n==="int4")&&Math.ceil(a/2)===this.cpuData.length))throw new Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=n,this.dims=s,this.size=a}static async fromImage(e,t){return i_(e,t)}static fromTexture(e,t){return l_(e,t)}static fromGpuBuffer(e,t){return c_(e,t)}static fromMLTensor(e,t){return u_(e,t)}static fromPinnedBuffer(e,t,r){return d_(e,t,r)}toDataURL(e){return a_(this,e)}toImageData(e){return o_(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw new 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 new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new 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 new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new 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 new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(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 new Error("The tensor is disposed.")}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return __(this,e)}}}),Pt,p_=ge(()=>{"use strict";hi(),Pt=mt}),Ws,fo,Vr,Ur,br,Mr,m_=ge(()=>{"use strict";s_(),Ws=(e,t)=>{(typeof Je.trace>"u"?!Je.wasm.trace:!Je.trace)||console.timeStamp(`${e}::ORT::${t}`)},fo=(e,t)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],n=!1;for(let s=0;s<r.length;s++){if(n&&!r[s].includes("TRACE_FUNC")){let a=`FUNC_${e}::${r[s].trim().split(" ")[1]}`;t&&(a+=`::${t}`),Ws("CPU",a);return}r[s].includes("TRACE_FUNC")&&(n=!0)}},Vr=e=>{(typeof Je.trace>"u"?!Je.wasm.trace:!Je.trace)||fo("BEGIN",e)},Ur=e=>{(typeof Je.trace>"u"?!Je.wasm.trace:!Je.trace)||fo("END",e)},br=e=>{(typeof Je.trace>"u"?!Je.wasm.trace:!Je.trace)||console.time(`ORT::${e}`)},Mr=e=>{(typeof Je.trace>"u"?!Je.wasm.trace:!Je.trace)||console.timeEnd(`ORT::${e}`)}}),g_,o0=ge(()=>{"use strict";r_(),p_(),m_(),g_=class w_{constructor(t){this.handler=t}async run(t,r,n){Vr(),br("InferenceSession.run");let s={},a={};if(typeof t!="object"||t===null||t instanceof Pt||Array.isArray(t))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let o=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Pt)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(r)){if(r.length===0)throw new TypeError("'fetches' cannot be an empty array.");o=!1;for(let u of r){if(typeof u!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(u)===-1)throw new RangeError(`'fetches' contains invalid output name: ${u}.`);s[u]=null}if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else{let u=!1,h=Object.getOwnPropertyNames(r);for(let f of this.outputNames)if(h.indexOf(f)!==-1){let _=r[f];(_===null||_ instanceof Pt)&&(u=!0,o=!1,s[f]=_)}if(u){if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else a=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let u of this.inputNames)if(typeof t[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(o)for(let u of this.outputNames)s[u]=null;let i=await this.handler.run(t,s,a),l={};for(let u in i)if(Object.hasOwnProperty.call(i,u)){let h=i[u];h instanceof Pt?l[u]=h:l[u]=new Pt(h.type,h.data,h.dims)}return Mr("InferenceSession.run"),Ur(),l}async release(){return this.handler.dispose()}static async create(t,r,n,s){Vr(),br("InferenceSession.create");let a,o={};if(typeof t=="string"){if(a=t,typeof r=="object"&&r!==null)o=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof Uint8Array){if(a=t,typeof r=="object"&&r!==null)o=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer){let h=t,f=0,_=t.byteLength;if(typeof r=="object"&&r!==null)o=r;else if(typeof r=="number"){if(f=r,!Number.isSafeInteger(f))throw new RangeError("'byteOffset' must be an integer.");if(f<0||f>=h.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${h.byteLength}).`);if(_=t.byteLength-f,typeof n=="number"){if(_=n,!Number.isSafeInteger(_))throw new RangeError("'byteLength' must be an integer.");if(_<=0||f+_>h.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${h.byteLength-f}].`);if(typeof s=="object"&&s!==null)o=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else if(typeof n<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");a=new Uint8Array(h,f,_)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,l]=await t_(o),u=await i.createInferenceSessionHandler(a,l);return Mr("InferenceSession.create"),Ur(),new w_(u)}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}}}),fi,i0=ge(()=>{"use strict";o0(),fi=g_}),l0=ge(()=>{"use strict"}),c0=ge(()=>{"use strict"}),u0=ge(()=>{"use strict"}),d0=ge(()=>{"use strict"}),v_={};Zn(v_,{InferenceSession:()=>fi,TRACE:()=>Ws,TRACE_EVENT_BEGIN:()=>br,TRACE_EVENT_END:()=>Mr,TRACE_FUNC_BEGIN:()=>Vr,TRACE_FUNC_END:()=>Ur,Tensor:()=>Pt,env:()=>Be,registerBackend:()=>Gr});var Wr=ge(()=>{"use strict";Zb(),t0(),i0(),p_(),l0(),c0(),m_(),u0(),d0()}),_i=ge(()=>{"use strict"}),y_={};Zn(y_,{default:()=>b_});var _o,po,b_,h0=ge(()=>{"use strict";D_(),jr(),pi(),_o="ort-wasm-proxy-worker",po=globalThis.self?.name===_o,po&&(self.onmessage=e=>{let{type:t,in:r}=e.data;try{switch(t){case"init-wasm":mi(r.wasm).then(()=>{bi(r).then(()=>{postMessage({type:t})},n=>{postMessage({type:t,err:n})})},n=>{postMessage({type:t,err:n})});break;case"init-ep":{let{epName:n,env:s}=r;Mi(s,n).then(()=>{postMessage({type:t})},a=>{postMessage({type:t,err:a})});break}case"copy-from":{let{buffer:n}=r,s=Hs(n);postMessage({type:t,out:s});break}case"create":{let{model:n,options:s}=r;xi(n,s).then(a=>{postMessage({type:t,out:a})},a=>{postMessage({type:t,err:a})});break}case"release":Ti(r),postMessage({type:t});break;case"run":{let{sessionId:n,inputIndices:s,inputs:a,outputIndices:o,options:i}=r;ki(n,s,a,o,new Array(o.length).fill(null),i).then(l=>{l.some(u=>u[3]!=="cpu")?postMessage({type:t,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:t,out:l},Ci([...a,...l]))},l=>{postMessage({type:t,err:l})});break}case"end-profiling":Ei(r),postMessage({type:t});break;default:}}catch(n){postMessage({type:t,err:n})}}),b_=po?null:e=>new Worker(e??_t,{type:"module",name:_o})}),M_={};Zn(M_,{default:()=>x_});async function Eh(e={}){var t=e,r=!!globalThis.window,n=!!globalThis.WorkerGlobalScope,s=n&&self.name?.startsWith("em-pthread");t.mountExternalData=(c,d)=>{c.startsWith("./")&&(c=c.substring(2)),(t.ed||(t.ed=new Map)).set(c,d)},t.unmountExternalData=()=>{delete t.ed,delete t.Te,delete t.Se,delete t.Ue},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let a=()=>{let c=d=>(...p)=>{let m=Rt;return p=d(...p),Rt!=m?new Promise((y,T)=>{ja={resolve:y,reject:T}}):p};(()=>{for(let d of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])t[d]=c(t[d])})(),typeof jsepRunAsync<"u"&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),a=void 0};t.asyncInit=()=>{a?.()};var o,i,l=(c,d)=>{throw d},u=import.meta.url,h="";if(r||n){try{h=new URL(".",u).href}catch{}n&&(i=c=>{var d=new XMLHttpRequest;return d.open("GET",c,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.response)}),o=async c=>{if(z(c))return new Promise((p,m)=>{var y=new XMLHttpRequest;y.open("GET",c,!0),y.responseType="arraybuffer",y.onload=()=>{y.status==200||y.status==0&&y.response?p(y.response):m(y.status)},y.onerror=m,y.send(null)});var d=await fetch(c,{credentials:"same-origin"});if(d.ok)return d.arrayBuffer();throw Error(d.status+" : "+d.url)}}var f,_,g,w,v,M,x=console.log.bind(console),k=console.error.bind(console),C=x,E=k,F=!1,z=c=>c.startsWith("file://");function b(){ur.buffer!=R.buffer&&O()}if(s){let c=function(d){try{var p=d.data,m=p.$c;if(m==="load"){let y=[];self.onmessage=T=>y.push(T),M=()=>{postMessage({$c:"loaded"});for(let T of y)c(T);self.onmessage=c};for(let T of p.ue)t[T]&&!t[T].proxy||(t[T]=(...S)=>{postMessage({$c:"callHandler",te:T,args:S})},T=="print"&&(C=t[T]),T=="printErr"&&(E=t[T]));ur=p.Me,O(),_=p.Ne,We(),ks()}else if(m==="run"){(function(y){var T=(b(),I)[y+52>>>2>>>0];y=(b(),I)[y+56>>>2>>>0],Ld(T,T-y),ee(T)})(p.Xc),no(p.Xc,0,0,1,0,0),fu(),Va(p.Xc),V||(_d(),V=!0);try{Rw(p.ze,p.kd)}catch(y){if(y!="unwind")throw y}}else p.target!=="setimmediate"&&(m==="checkMailbox"?V&&ps():m&&(E(`worker: received unknown command ${m}`),E(p)))}catch(y){throw Ad(),y}};var V=!1;self.onunhandledrejection=d=>{throw d.reason||d},self.onmessage=c}var R,H,J,X,D,I,G,Q,ce,Z,ne,L=!1;function O(){var c=ur.buffer;t.HEAP8=R=new Int8Array(c),J=new Int16Array(c),t.HEAPU8=H=new Uint8Array(c),X=new Uint16Array(c),t.HEAP32=D=new Int32Array(c),t.HEAPU32=I=new Uint32Array(c),G=new Float32Array(c),Q=new Float64Array(c),ce=new BigInt64Array(c),Z=new BigUint64Array(c)}function $(){L=!0,s?M():rr.hc()}function se(c){throw E(c="Aborted("+c+")"),F=!0,c=new WebAssembly.RuntimeError(c+". Build with -sASSERTIONS for more info."),v?.(c),c}function ae(){return{a:{qa:ib,f:$w,K:Gw,k:Vw,p:Uw,l:Ww,fa:jw,b:qw,da:Hw,gc:vu,q:Qw,ea:xu,Ua:Tu,cc:ku,ec:Eu,Va:Cu,Sa:Au,La:Su,Ra:Pu,oa:Fu,dc:Iu,ac:Lu,Ta:Ou,bc:Nu,_a:Xw,Ba:Yw,Xb:Jw,Vb:Zw,Aa:tv,O:rv,J:nv,Wb:sv,ka:dv,Yb:hv,Oa:fv,_b:pv,Ea:mv,Tb:gv,Ca:wv,Na:Va,Xa:vv,U:xv,n:Av,c:$a,qb:Sv,w:Pv,N:Fv,A:Iv,j:Lv,o:Uu,rb:Ov,H:Nv,T:Dv,g:Bv,u:zv,m:Rv,i:$v,Ia:Gv,Ja:Vv,Ka:Uv,Ga:Hu,Ha:Qu,Ub:Xu,ab:jv,Za:Hv,Z:Qv,pb:Xv,Da:Yv,Ya:qv,X:Jv,Wa:Kv,$b:Zv,G:Wv,db:ey,_:ty,pa:ys,Zb:ny,cb:ry,bb:sy,lb:gy,z:wy,sa:vy,ra:yy,nb:by,Y:My,v:xy,kb:Ty,jb:ky,ib:Ey,mb:Cy,gb:Ay,fb:Sy,eb:Py,Pa:od,Qa:id,fc:Xr,W:ld,Fa:cd,ma:ud,Ma:dd,la:hd,Fb:jb,va:Rb,Gb:Wb,wa:zb,E:kb,e:db,r:cb,x:lb,C:bb,Ib:Nb,ca:Ob,D:_b,xa:Db,aa:$b,ha:Lb,Jb:Ib,Kb:Fb,za:Cb,Lb:Sb,ya:Pb,Mb:Ab,ua:Ub,ba:Bb,d:ub,B:fb,s:hb,Eb:qb,t:mb,y:xb,F:pb,I:gb,L:Tb,Nb:Eb,R:Gb,ia:yb,$:Vb,Pb:vb,Rb:wb,Ob:Mb,h:Iy,a:ur,$a:Qr,Hb:Ly,V:Oy,M:Ny,na:Dy,Db:By,ja:zy,S:Ry,Ab:$y,Bb:Gy,vb:Vy,wb:Uy,P:Wy,xb:jy,yb:qy,ta:Hy,Sb:Qy,ob:Xy,Q:Yy,hb:Jy,Cb:Ky,sb:Zy,tb,ub:rb,ga:nb,zb:sb,Qb:ab}}}async function We(){function c(m,y){var T=rr=m.exports;m={};for(let[S,A]of Object.entries(T))typeof A=="function"?(T=yv(A),m[S]=T):m[S]=A;return rr=m,rr=(function(){var S=rr,A=U=>q=>U(q)>>>0,N=U=>()=>U()>>>0;return(S=Object.assign({},S)).ic=A(S.ic),S.Nc=N(S.Nc),S.Pc=A(S.Pc),S.Bd=(U=>(q,re)=>U(q,re)>>>0)(S.Bd),S.Gd=A(S.Gd),S.Hd=N(S.Hd),S.Ld=A(S.Ld),S})(),du.push(rr.sd),fd=(m=rr).ic,_d=m.jc,t._OrtInit=m.kc,t._OrtGetLastError=m.lc,t._OrtCreateSessionOptions=m.mc,t._OrtAppendExecutionProvider=m.nc,t._OrtAddFreeDimensionOverride=m.oc,t._OrtAddSessionConfigEntry=m.pc,t._OrtReleaseSessionOptions=m.qc,t._OrtCreateSession=m.rc,t._OrtReleaseSession=m.sc,t._OrtGetInputOutputCount=m.tc,t._OrtGetInputOutputMetadata=m.uc,t._OrtFree=m.vc,t._OrtCreateTensor=m.wc,t._OrtGetTensorData=m.xc,t._OrtReleaseTensor=m.yc,t._OrtCreateRunOptions=m.zc,t._OrtAddRunConfigEntry=m.Ac,t._OrtReleaseRunOptions=m.Bc,t._OrtCreateBinding=m.Cc,t._OrtBindInput=m.Dc,t._OrtBindOutput=m.Ec,t._OrtClearBoundOutputs=m.Fc,t._OrtReleaseBinding=m.Gc,t._OrtRunWithBinding=m.Hc,t._OrtRun=m.Ic,t._OrtEndProfiling=m.Jc,pd=t._OrtCreateWebGpuInstance=m.Kc,t._wgpuCreateInstance=m.Lc,Ja=t._OrtGetWebGpuDevice=m.Mc,xs=m.Nc,yt=t._free=m.Oc,Pr=t._malloc=m.Pc,md=t._wgpuBufferRelease=m.Qc,gd=m.Rc,wd=m.Sc,vd=m.Tc,yd=m.Uc,bd=m.Vc,Md=m.Yc,xd=m.Zc,Td=m.hd,kd=m.id,Ed=m.jd,Ka=m.ld,Za=m.md,eo=m.nd,to=m.od,Rn=m.pd,ro=m.qd,Cd=m.rd,no=m.ud,Ad=m.vd,Sd=m.wd,Pd=m.xd,so=m.yd,Fd=m.zd,Id=m.Ad,ao=m.Bd,he=m.Cd,$n=m.Dd,Ld=m.Ed,ee=m.Fd,Ts=m.Gd,te=m.Hd,Od=m.Id,oo=m.Jd,Nd=m.Kd,Dd=m.Ld,Bd=m.Md,io=m.Nd,zd=m.Od,Rd=m.Pd,$d=m.Qd,Gd=m.Rd,Vd=m.Sd,Ud=m.Td,Wd=m.Ud,jd=m.Vd,qd=m.Wd,Hd=m.Xd,Qd=m.Yd,Xd=m.Zd,Yd=m._d,Jd=m.$d,Kd=m.ae,Zd=m.be,eh=m.ce,th=m.de,rh=m.fe,nh=m.ge,sh=m.he,ah=m.ie,oh=m.je,ih=m.ke,lh=m.le,ch=m.me,uh=m.Ae,dh=m.Be,hh=m.Ce,fh=m.De,_h=m.Ee,ph=m.Fe,mh=m.Ge,gh=m.He,wh=m.Ie,vh=m.Je,yh=m.Ke,bh=m.nf,Mh=m.of,xh=m.pf,Th=m.qf,_=y,rr}var d,p=ae();return t.instantiateWasm?new Promise(m=>{t.instantiateWasm(p,(y,T)=>{m(c(y,T))})}):s?c(new WebAssembly.Instance(_,ae()),_):(ne??=t.locateFile?t.locateFile?t.locateFile("ort-wasm-simd-threaded.asyncify.wasm",h):h+"ort-wasm-simd-threaded.asyncify.wasm":new URL(""+new URL("ort-wasm-simd-threaded.asyncify-CxOG5pUO.wasm",import.meta.url).href,import.meta.url).href,d=await(async function(m){var y=ne;if(!f&&!z(y))try{var T=fetch(y,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(T,m)}catch(S){E(`wasm streaming compile failed: ${S}`),E("falling back to ArrayBuffer instantiation")}return(async function(S,A){try{var N=await(async function(U){if(!f)try{var q=await o(U);return new Uint8Array(q)}catch{}if(U==ne&&f)U=new Uint8Array(f);else{if(!i)throw"both async and sync fetching of the wasm failed";U=i(U)}return U})(S);return await WebAssembly.instantiate(N,A)}catch(U){E(`failed to asynchronously prepare wasm: ${U}`),se(U)}})(y,m)})(p),c(d.instance,d.module))}class Te{name="ExitStatus";constructor(d){this.message=`Program terminated with exit(${d})`,this.status=d}}var ke=c=>{c.terminate(),c.onmessage=()=>{}},$e=[],Fe=0,we=null,st=c=>{cr.length==0&&(pu(),_u(cr[0]));var d=cr.pop();if(!d)return 6;Bn.push(d),Cr[c.Xc]=d,d.Xc=c.Xc;var p={$c:"run",ze:c.ye,kd:c.kd,Xc:c.Xc};return d.postMessage(p,c.oe),0},be=0,Me=(c,d,...p)=>{var m,y=16*p.length,T=te(),S=Ts(y),A=S>>>3;for(m of p)typeof m=="bigint"?((b(),ce)[A++>>>0]=1n,(b(),ce)[A++>>>0]=m):((b(),ce)[A++>>>0]=0n,(b(),Q)[A++>>>0]=m);return c=Sd(c,0,y,S,d),ee(T),c};function Qr(c){if(s)return Me(0,1,c);if(g=c,!(0<be)){for(var d of Bn)ke(d);for(d of cr)ke(d);cr=[],Bn=[],Cr={},F=!0}l(0,new Te(c))}function Dn(c){if(s)return Me(1,0,c);Xr(c)}var Xr=c=>{if(g=c,s)throw Dn(c),"unwind";Qr(c)},cr=[],Bn=[],du=[],Cr={},hu=c=>{var d=c.Xc;delete Cr[d],cr.push(c),Bn.splice(Bn.indexOf(c),1),c.Xc=0,Pd(d)};function fu(){du.forEach(c=>c())}var _u=c=>new Promise(d=>{c.onmessage=y=>{var T=y.data;if(y=T.$c,T.gd&&T.gd!=xs()){var S=Cr[T.gd];S?S.postMessage(T,T.oe):E(`Internal error! Worker sent a message "${y}" to target pthread ${T.gd}, but that thread no longer exists!`)}else y==="checkMailbox"?ps():y==="spawnThread"?st(T):y==="cleanupThread"?ct(()=>{hu(Cr[T.Le])}):y==="loaded"?(c.loaded=!0,d(c)):T.target==="setimmediate"?c.postMessage(T):y==="uncaughtException"?c.onerror(T.error):y==="callHandler"?t[T.te](...T.args):y&&E(`worker sent an unknown command ${y}`)},c.onerror=y=>{throw E(`worker sent an error! ${y.filename}:${y.lineno}: ${y.message}`),y};var p,m=[];for(p of[])t.propertyIsEnumerable(p)&&m.push(p);c.postMessage({$c:"load",ue:m,Me:ur,Ne:_})});function pu(){var c=new Worker((()=>{let d=URL;return import.meta.url>"file:"&&import.meta.url<"file;"?new d("ort.webgpu.bundle.min.mjs",import.meta.url):new URL(import.meta.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});cr.push(c)}var ur,Rw=(c,d)=>{be=0,c=io(c,d),0<be?g=c:so(c)},fs=[],_s=0,Ke=c=>-9007199254740992>c||9007199254740992<c?NaN:Number(c);function $w(c){var d=new Da(c>>>=0);return(b(),R)[d.ad+12>>>0]==0&&(mu(d,!0),_s--),gu(d,!1),fs.push(d),Dd(c)}var Yr=0,Gw=()=>{he(0,0);var c=fs.pop();Od(c.td),Yr=0};function mu(c,d){d=d?1:0,(b(),R)[c.ad+12>>>0]=d}function gu(c,d){d=d?1:0,(b(),R)[c.ad+13>>>0]=d}class Da{constructor(d){this.td=d,this.ad=d-24}}var Ba=c=>{var d=Yr;if(!d)return $n(0),0;var p=new Da(d);(b(),I)[p.ad+16>>>2>>>0]=d;var m=(b(),I)[p.ad+4>>>2>>>0];if(!m)return $n(0),d;for(var y of c){if(y===0||y===m)break;if(Nd(y,m,p.ad+16))return $n(y),d}return $n(m),d};function Vw(){return Ba([])}function Uw(c){return Ba([c>>>0])}function Ww(c,d,p,m){return Ba([c>>>0,d>>>0,p>>>0,m>>>0])}var jw=()=>{var c=fs.pop();c||se("no exception to throw");var d=c.td;throw(b(),R)[c.ad+13>>>0]==0&&(fs.push(c),gu(c,!0),mu(c,!1),_s++),oo(d),Yr=d};function qw(c,d,p){var m=new Da(c>>>=0);throw d>>>=0,p>>>=0,(b(),I)[m.ad+16>>>2>>>0]=0,(b(),I)[m.ad+4>>>2>>>0]=d,(b(),I)[m.ad+8>>>2>>>0]=p,oo(c),_s++,Yr=c}var Hw=()=>_s;function wu(c,d,p,m){return s?Me(2,1,c,d,p,m):vu(c,d,p,m)}function vu(c,d,p,m){if(c>>>=0,d>>>=0,p>>>=0,m>>>=0,!globalThis.SharedArrayBuffer)return 6;var y=[];return s&&y.length===0?wu(c,d,p,m):(c={ye:p,Xc:c,kd:m,oe:y},s?(c.$c="spawnThread",postMessage(c,y),0):st(c))}function Qw(c){throw Yr||=c>>>0,Yr}var yu=globalThis.TextDecoder&&new TextDecoder,bu=(c,d,p,m)=>{if(p=d+p,m)return p;for(;c[d]&&!(d>=p);)++d;return d},Mu=(c,d=0,p,m)=>{if(16<(p=bu(c,d>>>=0,p,m))-d&&c.buffer&&yu)return yu.decode(c.buffer instanceof ArrayBuffer?c.subarray(d,p):c.slice(d,p));for(m="";d<p;){var y=c[d++];if(128&y){var T=63&c[d++];if((224&y)==192)m+=String.fromCharCode((31&y)<<6|T);else{var S=63&c[d++];65536>(y=(240&y)==224?(15&y)<<12|T<<6|S:(7&y)<<18|T<<12|S<<6|63&c[d++])?m+=String.fromCharCode(y):(y-=65536,m+=String.fromCharCode(55296|y>>10,56320|1023&y))}}else m+=String.fromCharCode(y)}return m},Jr=(c,d,p)=>(c>>>=0)?Mu((b(),H),c,d,p):"";function xu(c,d,p){return s?Me(3,1,c,d,p):0}function Tu(c,d){if(s)return Me(4,1,c,d)}function ku(c,d){if(s)return Me(5,1,c,d)}function Eu(c,d,p){if(s)return Me(6,1,c,d,p)}function Cu(c,d,p){return s?Me(7,1,c,d,p):0}function Au(c,d){if(s)return Me(8,1,c,d)}function Su(c,d,p){if(s)return Me(9,1,c,d,p)}function Pu(c,d,p,m){if(s)return Me(10,1,c,d,p,m)}function Fu(c,d,p,m){if(s)return Me(11,1,c,d,p,m)}function Iu(c,d,p,m){if(s)return Me(12,1,c,d,p,m)}function Lu(c){if(s)return Me(13,1,c)}function Ou(c,d){if(s)return Me(14,1,c,d)}function Nu(c,d,p){if(s)return Me(15,1,c,d,p)}var Xw=()=>se(""),zt=c=>{c>>>=0;for(var d="";;){var p=(b(),H)[c++>>>0];if(!p)return d;d+=String.fromCharCode(p)}},za={},Ra={},Kr=class extends Error{constructor(c){super(c),this.name="BindingError"}};function Kt(c,d,p={}){return(function(m,y,T={}){var S=y.name;if(!m)throw new Kr(`type "${S}" must have a positive integer typeid pointer`);if(Ra.hasOwnProperty(m)){if(T.ve)return;throw new Kr(`Cannot register type '${S}' twice`)}Ra[m]=y,za.hasOwnProperty(m)&&(y=za[m],delete za[m],y.forEach(A=>A()))})(c,d,p)}var Du=(c,d,p)=>{switch(d){case 1:return p?m=>(b(),R)[m>>>0]:m=>(b(),H)[m>>>0];case 2:return p?m=>(b(),J)[m>>>1>>>0]:m=>(b(),X)[m>>>1>>>0];case 4:return p?m=>(b(),D)[m>>>2>>>0]:m=>(b(),I)[m>>>2>>>0];case 8:return p?m=>(b(),ce)[m>>>3>>>0]:m=>(b(),Z)[m>>>3>>>0];default:throw new TypeError(`invalid integer width (${d}): ${c}`)}};function Yw(c,d,p,m,y){c>>>=0,p>>>=0,d=zt(d>>>0);let T=S=>S;if(m=m===0n){let S=8*p;T=A=>BigInt.asUintN(S,A),y=T(y)}Kt(c,{name:d,Wc:T,cd:(S,A)=>(typeof A=="number"&&(A=BigInt(A)),A),bd:Du(d,p,!m),dd:null})}function Jw(c,d,p,m){Kt(c>>>=0,{name:d=zt(d>>>0),Wc:function(y){return!!y},cd:function(y,T){return T?p:m},bd:function(y){return this.Wc((b(),H)[y>>>0])},dd:null})}var Bu=[],Ar=[0,1,,1,null,1,!0,1,!1,1];function $a(c){9<(c>>>=0)&&--Ar[c+1]===0&&(Ar[c]=void 0,Bu.push(c))}var vt=c=>{if(!c)throw new Kr(`Cannot use deleted val. handle = ${c}`);return Ar[c]},Ct=c=>{switch(c){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let d=Bu.pop()||Ar.length;return Ar[d]=c,Ar[d+1]=1,d}};function Ga(c){return this.Wc((b(),I)[c>>>2>>>0])}var Kw={name:"emscripten::val",Wc:c=>{var d=vt(c);return $a(c),d},cd:(c,d)=>Ct(d),bd:Ga,dd:null};function Zw(c){return Kt(c>>>0,Kw)}var ev=(c,d)=>{switch(d){case 4:return function(p){return this.Wc((b(),G)[p>>>2>>>0])};case 8:return function(p){return this.Wc((b(),Q)[p>>>3>>>0])};default:throw new TypeError(`invalid float width (${d}): ${c}`)}};function tv(c,d,p){p>>>=0,Kt(c>>>=0,{name:d=zt(d>>>0),Wc:m=>m,cd:(m,y)=>y,bd:ev(d,p),dd:null})}function rv(c,d,p,m,y){c>>>=0,p>>>=0,d=zt(d>>>0);let T=A=>A;if(m===0){var S=32-8*p;T=A=>A<<S>>>S,y=T(y)}Kt(c,{name:d,Wc:T,cd:(A,N)=>N,bd:Du(d,p,m!==0),dd:null})}function nv(c,d,p){function m(T){var S=(b(),I)[T>>>2>>>0];return T=(b(),I)[T+4>>>2>>>0],new y((b(),R).buffer,T,S)}var y=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][d];Kt(c>>>=0,{name:p=zt(p>>>0),Wc:m,bd:m},{ve:!0})}var Zt=(c,d,p)=>{var m=(b(),H);if(d>>>=0,0<p){var y=d;p=d+p-1;for(var T=0;T<c.length;++T){var S=c.codePointAt(T);if(127>=S){if(d>=p)break;m[d++>>>0]=S}else if(2047>=S){if(d+1>=p)break;m[d++>>>0]=192|S>>6,m[d++>>>0]=128|63&S}else if(65535>=S){if(d+2>=p)break;m[d++>>>0]=224|S>>12,m[d++>>>0]=128|S>>6&63,m[d++>>>0]=128|63&S}else{if(d+3>=p)break;m[d++>>>0]=240|S>>18,m[d++>>>0]=128|S>>12&63,m[d++>>>0]=128|S>>6&63,m[d++>>>0]=128|63&S,T++}}m[d>>>0]=0,c=d-y}else c=0;return c},er=c=>{for(var d=0,p=0;p<c.length;++p){var m=c.charCodeAt(p);127>=m?d++:2047>=m?d+=2:55296<=m&&57343>=m?(d+=4,++p):d+=3}return d};function sv(c,d){Kt(c>>>=0,{name:d=zt(d>>>0),Wc(p){var m=(b(),I)[p>>>2>>>0];return m=Jr(p+4,m,!0),yt(p),m},cd(p,m){m instanceof ArrayBuffer&&(m=new Uint8Array(m));var y=typeof m=="string";if(!(y||ArrayBuffer.isView(m)&&m.BYTES_PER_ELEMENT==1))throw new Kr("Cannot pass non-string to std::string");var T=y?er(m):m.length,S=Pr(4+T+1),A=S+4;return(b(),I)[S>>>2>>>0]=T,y?Zt(m,A,T+1):(b(),H).set(m,A>>>0),p!==null&&p.push(yt,S),S},bd:Ga,dd(p){yt(p)}})}var zu=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,av=(c,d,p)=>{if(c>>>=1,16<(d=bu((b(),X),c,d/2,p))-c&&zu)return zu.decode((b(),X).slice(c,d));for(p="";c<d;++c){var m=(b(),X)[c>>>0];p+=String.fromCharCode(m)}return p},ov=(c,d,p)=>{if(p??=2147483647,2>p)return 0;var m=d;p=(p-=2)<2*c.length?p/2:c.length;for(var y=0;y<p;++y){var T=c.charCodeAt(y);(b(),J)[d>>>1>>>0]=T,d+=2}return(b(),J)[d>>>1>>>0]=0,d-m},iv=c=>2*c.length,lv=(c,d,p)=>{var m="";c>>>=2;for(var y=0;!(y>=d/4);y++){var T=(b(),I)[c+y>>>0];if(!T&&!p)break;m+=String.fromCodePoint(T)}return m},cv=(c,d,p)=>{if(d>>>=0,p??=2147483647,4>p)return 0;var m=d;p=m+p-4;for(var y=0;y<c.length;++y){var T=c.codePointAt(y);if(65535<T&&y++,(b(),D)[d>>>2>>>0]=T,(d+=4)+4>p)break}return(b(),D)[d>>>2>>>0]=0,d-m},uv=c=>{for(var d=0,p=0;p<c.length;++p)65535<c.codePointAt(p)&&p++,d+=4;return d};function dv(c,d,p){if(c>>>=0,d>>>=0,p=zt(p>>>=0),d===2)var m=av,y=ov,T=iv;else m=lv,y=cv,T=uv;Kt(c,{name:p,Wc:S=>{var A=(b(),I)[S>>>2>>>0];return A=m(S+4,A*d,!0),yt(S),A},cd:(S,A)=>{if(typeof A!="string")throw new Kr(`Cannot pass non-string to C++ string type ${p}`);var N=T(A),U=Pr(4+N+d);return(b(),I)[U>>>2>>>0]=N/d,y(A,U+4,N+d),S!==null&&S.push(yt,U),U},bd:Ga,dd(S){yt(S)}})}function hv(c,d){Kt(c>>>=0,{we:!0,name:d=zt(d>>>0),Wc:()=>{},cd:()=>{}})}function fv(c){no(c>>>0,!n,1,!r,131072,!1),fu()}var ct=c=>{if(!F)try{if(c(),!(0<be))try{s?xs()&&so(g):Xr(g)}catch(d){d instanceof Te||d=="unwind"||l(0,d)}}catch(d){d instanceof Te||d=="unwind"||l(0,d)}},_v=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Va(c){c>>>=0,_v||(Atomics.waitAsync((b(),D),c>>>2,c).value.then(ps),c+=128,Atomics.store((b(),D),c>>>2,1))}var ps=()=>ct(()=>{var c=xs();c&&(Va(c),Id())});function pv(c,d){(c>>>=0)==d>>>0?setTimeout(ps):s?postMessage({gd:c,$c:"checkMailbox"}):(c=Cr[c])&&c.postMessage({$c:"checkMailbox"})}var Ua=[];function mv(c,d,p,m,y){for(d>>>=0,y>>>=0,Ua.length=0,p=y>>>3,m=y+m>>>3;p<m;){var T;T=(b(),ce)[p++>>>0]?(b(),ce)[p++>>>0]:(b(),Q)[p++>>>0],Ua.push(T)}return(d?lo[d]:ob[c])(...Ua)}var gv=()=>{be=0};function wv(c){c>>>=0,s?postMessage({$c:"cleanupThread",Le:c}):hu(Cr[c])}function vv(c){}var ms=c=>{try{c()}catch(d){se(d)}};function yv(c){var d=(...p)=>{gs.push(c);try{return c(...p)}finally{F||(gs.pop(),Rt&&dr===1&&gs.length===0&&(dr=0,be+=1,ms(Mh),typeof Fibers<"u"&&Fibers.We()))}};return Gu.set(c,d),d}var dr=0,Rt=null,Ru=0,gs=[],Wa=new Map,$u=new Map,Gu=new Map,bv=0,ja=null,Mv=[],Vu=c=>(function(d){if(!F){if(dr===0){var p=!1,m=!1;d((y=0)=>{if(!F&&(Ru=y,p=!0,m)){dr=2,ms(()=>xh(Rt)),typeof MainLoop<"u"&&MainLoop.se&&MainLoop.resume(),y=!1;try{var T=(function(){var N=(b(),D)[Rt+8>>>2>>>0];return N=$u.get(N),N=Gu.get(N),--be,N()})()}catch(N){T=N,y=!0}var S=!1;if(!Rt){var A=ja;A&&(ja=null,(y?A.reject:A.resolve)(T),S=!0)}if(y&&!S)throw T}}),m=!0,p||(dr=1,Rt=(function(){var y=Pr(65548),T=y+12;if((b(),I)[y>>>2>>>0]=T,(b(),I)[y+4>>>2>>>0]=T+65536,T=gs[0],!Wa.has(T)){var S=bv++;Wa.set(T,S),$u.set(S,T)}return T=Wa.get(T),(b(),D)[y+8>>>2>>>0]=T,y})(),typeof MainLoop<"u"&&MainLoop.se&&MainLoop.pause(),ms(()=>bh(Rt)))}else dr===2?(dr=0,ms(Th),yt(Rt),Rt=null,Mv.forEach(ct)):se(`invalid state: ${dr}`);return Ru}})(d=>{c().then(d)});function xv(c){return c>>>=0,Vu(async()=>{var d=await vt(c);return Ct(d)})}var qa=[],Tv=c=>{var d=qa.length;return qa.push(c),d},kv=(c,d)=>{for(var p=Array(c),m=0;m<c;++m){var y=m,T=(b(),I)[d+4*m>>>2>>>0],S=Ra[T];if(S===void 0)throw c=`parameter ${m}`,T=fd(T),d=zt(T),yt(T),new Kr(`${c} has unknown type ${d}`);p[y]=S}return p},Ev=(c,d,p)=>{var m=[];return c=c(m,p),m.length&&((b(),I)[d>>>2>>>0]=Ct(m)),c},Cv={},ws=c=>{var d=Cv[c];return d===void 0?zt(c):d};function Av(c,d,p){var[m,...y]=kv(c,d>>>0);d=m.cd.bind(m);var T=y.map(N=>N.bd.bind(N));c--;var S={toValue:vt};switch(c=T.map((N,U)=>{var q=`argFromPtr${U}`;return S[q]=N,`${q}(args${U?"+"+8*U:""})`}),p){case 0:var A="toValue(handle)";break;case 2:A="new (toValue(handle))";break;case 3:A="";break;case 1:S.getStringOrSymbol=ws,A="toValue(handle)[getStringOrSymbol(methodName)]"}return A+=`(${c})`,m.we||(S.toReturnWire=d,S.emval_returnValue=Ev,A=`return emval_returnValue(toReturnWire, destructorsRef, ${A})`),A=`return function (handle, methodName, destructorsRef, args) {
2
+ ${A}
3
+ }`,p=new Function(Object.keys(S),A)(...Object.values(S)),A=`methodCaller<(${y.map(N=>N.name)}) => ${m.name}>`,Tv(Object.defineProperty(p,"name",{value:A}))}function Sv(c,d){return d>>>=0,(c=vt(c>>>0))==vt(d)}function Pv(c){return(c>>>=0)?(c=ws(c),Ct(globalThis[c])):Ct(globalThis)}function Fv(c){return c=ws(c>>>0),Ct(t[c])}function Iv(c,d){return d>>>=0,c=vt(c>>>0),d=vt(d),Ct(c[d])}function Lv(c){9<(c>>>=0)&&(Ar[c+1]+=1)}function Uu(c,d,p,m,y){return qa[c>>>0](d>>>0,p>>>0,m>>>0,y>>>0)}function Ov(c,d,p,m,y){return Uu(c>>>0,d>>>0,p>>>0,m>>>0,y>>>0)}function Nv(){return Ct([])}function Dv(c){c=vt(c>>>0);for(var d=Array(c.length),p=0;p<c.length;p++)d[p]=c[p];return Ct(d)}function Bv(c){return Ct(ws(c>>>0))}function zv(){return Ct({})}function Rv(c){for(var d=vt(c>>>=0);d.length;){var p=d.pop();d.pop()(p)}$a(c)}function $v(c,d,p){d>>>=0,p>>>=0,c=vt(c>>>0),d=vt(d),p=vt(p),c[d]=p}function Gv(c,d){c=Ke(c),d>>>=0,c=new Date(1e3*c),(b(),D)[d>>>2>>>0]=c.getUTCSeconds(),(b(),D)[d+4>>>2>>>0]=c.getUTCMinutes(),(b(),D)[d+8>>>2>>>0]=c.getUTCHours(),(b(),D)[d+12>>>2>>>0]=c.getUTCDate(),(b(),D)[d+16>>>2>>>0]=c.getUTCMonth(),(b(),D)[d+20>>>2>>>0]=c.getUTCFullYear()-1900,(b(),D)[d+24>>>2>>>0]=c.getUTCDay(),c=(c.getTime()-Date.UTC(c.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(b(),D)[d+28>>>2>>>0]=c}var Wu=c=>c%4==0&&(c%100!=0||c%400==0),ju=[0,31,60,91,121,152,182,213,244,274,305,335],qu=[0,31,59,90,120,151,181,212,243,273,304,334];function Vv(c,d){c=Ke(c),d>>>=0,c=new Date(1e3*c),(b(),D)[d>>>2>>>0]=c.getSeconds(),(b(),D)[d+4>>>2>>>0]=c.getMinutes(),(b(),D)[d+8>>>2>>>0]=c.getHours(),(b(),D)[d+12>>>2>>>0]=c.getDate(),(b(),D)[d+16>>>2>>>0]=c.getMonth(),(b(),D)[d+20>>>2>>>0]=c.getFullYear()-1900,(b(),D)[d+24>>>2>>>0]=c.getDay();var p=(Wu(c.getFullYear())?ju:qu)[c.getMonth()]+c.getDate()-1|0;(b(),D)[d+28>>>2>>>0]=p,(b(),D)[d+36>>>2>>>0]=-60*c.getTimezoneOffset(),p=new Date(c.getFullYear(),6,1).getTimezoneOffset();var m=new Date(c.getFullYear(),0,1).getTimezoneOffset();c=0|(p!=m&&c.getTimezoneOffset()==Math.min(m,p)),(b(),D)[d+32>>>2>>>0]=c}function Uv(c){c>>>=0;var d=new Date((b(),D)[c+20>>>2>>>0]+1900,(b(),D)[c+16>>>2>>>0],(b(),D)[c+12>>>2>>>0],(b(),D)[c+8>>>2>>>0],(b(),D)[c+4>>>2>>>0],(b(),D)[c>>>2>>>0],0),p=(b(),D)[c+32>>>2>>>0],m=d.getTimezoneOffset(),y=new Date(d.getFullYear(),6,1).getTimezoneOffset(),T=new Date(d.getFullYear(),0,1).getTimezoneOffset(),S=Math.min(T,y);return 0>p?(b(),D)[c+32>>>2>>>0]=+(y!=T&&S==m):0<p!=(S==m)&&(y=Math.max(T,y),d.setTime(d.getTime()+6e4*((0<p?S:y)-m))),(b(),D)[c+24>>>2>>>0]=d.getDay(),p=(Wu(d.getFullYear())?ju:qu)[d.getMonth()]+d.getDate()-1|0,(b(),D)[c+28>>>2>>>0]=p,(b(),D)[c>>>2>>>0]=d.getSeconds(),(b(),D)[c+4>>>2>>>0]=d.getMinutes(),(b(),D)[c+8>>>2>>>0]=d.getHours(),(b(),D)[c+12>>>2>>>0]=d.getDate(),(b(),D)[c+16>>>2>>>0]=d.getMonth(),(b(),D)[c+20>>>2>>>0]=d.getYear(),c=d.getTime(),BigInt(isNaN(c)?-1:c/1e3)}function Hu(c,d,p,m,y,T,S){return s?Me(16,1,c,d,p,m,y,T,S):-52}function Qu(c,d,p,m,y,T){if(s)return Me(17,1,c,d,p,m,y,T)}var zn={},Wv=()=>performance.timeOrigin+performance.now();function Xu(c,d){if(s)return Me(18,1,c,d);if(zn[c]&&(clearTimeout(zn[c].id),delete zn[c]),!d)return 0;var p=setTimeout(()=>{delete zn[c],ct(()=>Fd(c,performance.timeOrigin+performance.now()))},d);return zn[c]={id:p,Ve:d},0}function jv(c,d,p,m){c>>>=0,d>>>=0,p>>>=0,m>>>=0;var y=new Date().getFullYear(),T=new Date(y,0,1).getTimezoneOffset();y=new Date(y,6,1).getTimezoneOffset();var S=Math.max(T,y);(b(),I)[c>>>2>>>0]=60*S,(b(),D)[d>>>2>>>0]=+(T!=y),c=(d=A=>{var N=Math.abs(A);return`UTC${0<=A?"-":"+"}${String(Math.floor(N/60)).padStart(2,"0")}${String(N%60).padStart(2,"0")}`})(T),d=d(y),y<T?(Zt(c,p,17),Zt(d,m,17)):(Zt(c,m,17),Zt(d,p,17))}var qv=()=>Date.now();function Hv(c,d,p){return p>>>=0,0<=c&&3>=c?(c===0?c=Date.now():c=performance.timeOrigin+performance.now(),c=Math.round(1e6*c),(b(),ce)[p>>>3>>>0]=BigInt(c),0):28}var Ha=[],Yu=(c,d)=>{Ha.length=0;for(var p;p=(b(),H)[c++>>>0];){var m=p!=105;d+=(m&=p!=112)&&d%8?4:0,Ha.push(p==112?(b(),I)[d>>>2>>>0]:p==106?(b(),ce)[d>>>3>>>0]:p==105?(b(),D)[d>>>2>>>0]:(b(),Q)[d>>>3>>>0]),d+=m?8:4}return Ha};function Qv(c,d,p){return c>>>=0,d=Yu(d>>>0,p>>>0),lo[c](...d)}function Xv(c,d,p){return c>>>=0,d=Yu(d>>>0,p>>>0),lo[c](...d)}var Yv=()=>{};function Jv(c,d){return E(Jr(c>>>0,d>>>0))}var Kv=()=>{throw be+=1,"unwind"};function Zv(){return 4294901760}var ey=()=>1,ty=()=>navigator.hardwareConcurrency,Sr={},Ju=c=>{var d=er(c)+1,p=Pr(d);return p&&Zt(c,p,d),p},vs=c=>{var d;return(d=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(c))?+d[1]:(d=/:(\d+):\d+(?:\)|$)/.exec(c))?2147483648|+d[1]:0},Ku=c=>{for(var d of c)(c=vs(d))&&(Sr[c]=d)};function ry(){var c=Error().stack.toString().split(`
4
+ `);return c[0]=="Error"&&c.shift(),Ku(c),Sr.ee=vs(c[3]),Sr.xe=c,Sr.ee}function ys(c){if(!(c=Sr[c>>>0]))return 0;var d;if(d=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(c))c=d[1];else if(d=/^\s+at (.*) \(.*\)$/.exec(c))c=d[1];else{if(!(d=/^(.+?)@/.exec(c)))return 0;c=d[1]}return yt(ys.ne??0),ys.ne=Ju(c),ys.ne}function ny(c){c>>>=0;var d=(b(),H).length;if(c<=d||4294901760<c)return!1;for(var p=1;4>=p;p*=2){var m=d*(1+.2/p);m=Math.min(m,c+100663296);e:{m=(Math.min(4294901760,65536*Math.ceil(Math.max(c,m)/65536))-ur.buffer.byteLength+65535)/65536|0;try{ur.grow(m),O();var y=1;break e}catch{}y=void 0}if(y)return!0}return!1}function sy(c,d,p){if(c>>>=0,d>>>=0,Sr.ee==c)var m=Sr.xe;else(m=Error().stack.toString().split(`
5
+ `))[0]=="Error"&&m.shift(),Ku(m);for(var y=3;m[y]&&vs(m[y])!=c;)++y;for(c=0;c<p&&m[c+y];++c)(b(),D)[d+4*c>>>2>>>0]=vs(m[c+y]);return c}var $t=c=>{var d=er(c)+1,p=Ts(d);return Zt(c,p,d),p},Zr=c=>(b(),I)[c>>>2>>>0]+4294967296*(b(),D)[c+4>>>2>>>0],Ze=[],Zu=(c,d)=>{Ze[c>>>0]=d},tr=[],bs=[],en=(c,d)=>{bs[c]=new Promise(p=>d.finally(()=>p(c)))},K=c=>{if(c)return Ze[c>>>0]},Qa=(c,d)=>{for(c=(b(),I)[c>>>2>>>0];c;c=(b(),I)[c>>>2>>>0])d[(b(),D)[c+4>>>2>>>0]](c)},Ms=(c,d,p)=>{(b(),I)[c>>>2>>>0]=d,(b(),I)[c+4>>>2>>>0]=p},ed=c=>{var d=(b(),I)[c>>>2>>>0];return c=(b(),I)[c+4>>>2>>>0],Jr(d,c)},At=c=>{var d=(b(),I)[c>>>2>>>0];return c=(b(),I)[c+4>>>2>>>0],d?Jr(d,c):c===0?"":void 0},ay=c=>{var d=At(c+4),p=(p=(b(),I)[c+12>>>2>>>0])?K(p):"auto";if(c+=16){var m=K((b(),I)[c+4>>>2>>>0]),y=(b(),I)[c+16>>>2>>>0],T=(b(),I)[c+20>>>2>>>0];if(y){for(var S={},A=0;A<y;++A){var N=T+24*A;S[ed(N+4)]=(b(),Q)[N+16>>>3>>>0]}y=S}else y=void 0;c={module:m,constants:y,entryPoint:At(c+8)}}else c=void 0;return{label:d,layout:p,compute:c}},td=(c,d)=>{function p(T,S,A,N=0){T=c[T]??N,(b(),I)[S+A>>>2>>>0]=T}function m(T,S,A,N=0){S+=A,T=c[T]??N,(b(),I)[S>>>2>>>0]=T,N=(b(),I)[S>>>2>>>0],(b(),I)[S+4>>>2>>>0]=(T-N)/4294967296}var y=(b(),I)[d>>>2>>>0];p("maxTextureDimension1D",d,4),p("maxTextureDimension2D",d,8),p("maxTextureDimension3D",d,12),p("maxTextureArrayLayers",d,16),p("maxBindGroups",d,20),p("maxBindGroupsPlusVertexBuffers",d,24),p("maxBindingsPerBindGroup",d,28),p("maxDynamicUniformBuffersPerPipelineLayout",d,32),p("maxDynamicStorageBuffersPerPipelineLayout",d,36),p("maxSampledTexturesPerShaderStage",d,40),p("maxSamplersPerShaderStage",d,44),p("maxStorageBuffersPerShaderStage",d,48),p("maxStorageTexturesPerShaderStage",d,52),p("maxUniformBuffersPerShaderStage",d,56),p("minUniformBufferOffsetAlignment",d,80),p("minStorageBufferOffsetAlignment",d,84),m("maxUniformBufferBindingSize",d,64),m("maxStorageBufferBindingSize",d,72),p("maxVertexBuffers",d,88),m("maxBufferSize",d,96),p("maxVertexAttributes",d,104),p("maxVertexBufferArrayStride",d,108),p("maxInterStageShaderVariables",d,112),p("maxColorAttachments",d,116),p("maxColorAttachmentBytesPerSample",d,120),p("maxComputeWorkgroupStorageSize",d,124),p("maxComputeInvocationsPerWorkgroup",d,128),p("maxComputeWorkgroupSizeX",d,132),p("maxComputeWorkgroupSizeY",d,136),p("maxComputeWorkgroupSizeZ",d,140),p("maxComputeWorkgroupsPerDimension",d,144),p("maxImmediateSize",d,148),y!==0&&(b(),p("maxStorageBuffersInVertexStage",y,8,c.maxStorageBuffersPerShaderStage),p("maxStorageBuffersInFragmentStage",y,16,c.maxStorageBuffersPerShaderStage),p("maxStorageTexturesInVertexStage",y,12,c.maxStorageTexturesPerShaderStage),p("maxStorageTexturesInFragmentStage",y,20,c.maxStorageTexturesPerShaderStage))},oy=(c,d)=>{(b(),I)[d+52>>>2>>>0]=c.subgroupMinSize,(b(),I)[d+56>>>2>>>0]=c.subgroupMaxSize;var p=Ju(c.vendor+c.architecture+c.device+c.description),m=er(c.vendor);Ms(d+4,p,m),p+=m,m=er(c.architecture),Ms(d+12,p,m),p+=m,m=er(c.device),Ms(d+20,p,m),p+=m,m=er(c.description),Ms(d+28,p,m),p+=m,(b(),D)[d+36>>>2>>>0]=2,p=c.isFallbackAdapter?3:4,(b(),D)[d+40>>>2>>>0]=p,(b(),I)[d+44>>>2>>>0]=0,(b(),I)[d+48>>>2>>>0]=0,Qa(d,{327739:y=>{let T=0,S=0;if(c.subgroupMatrixConfigs){T=c.subgroupMatrixConfigs.length,S=Pr(20*T);for(let[A,N]of c.subgroupMatrixConfigs.entries()){let U=S+20*A,q=nd.indexOf(N.componentType),re=nd.indexOf(N.resultComponentType);(b(),D)[U>>>2>>>0]=q,(b(),D)[U+4>>>2>>>0]=re,(b(),I)[U+8>>>2>>>0]=N.M,(b(),I)[U+12>>>2>>>0]=N.N,(b(),I)[U+16>>>2>>>0]=N.K}}(b(),I)[y+12>>>2>>>0]=S,(b(),I)[y+8>>>2>>>0]=T}})},iy=[,,"uniform","storage","read-only-storage"],ly=[,"validation","out-of-memory","internal"],cy=[,"compatibility","core"],rd={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",23:"subgroup-size-control",327692:"chromium-experimental-unorm16-texture-formats",327729:"chromium-experimental-multi-draw-indirect",327732:"chromium-experimental-subgroup-matrix"},uy=[,"low-power","high-performance"],dy=[,"occlusion","timestamp"],hy=[,,"filtering","non-filtering","comparison"],fy=[,,"write-only","read-only","read-write"],nd=[,"f32","f16","u32","i32","u8","i8"],_y=[,"r8unorm","r8snorm","r8uint","r8sint","r16unorm","r16snorm","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32float","r32uint","r32sint","rg16unorm","rg16snorm","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb10a2uint","rgb10a2unorm","rg11b10ufloat","rgb9e5ufloat","rg32float","rg32uint","rg32sint","rgba16unorm","rgba16snorm","rgba16uint","rgba16sint","rgba16float","rgba32float","rgba32uint","rgba32sint","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb","etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm","astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"],py=[,,"float","unfilterable-float","depth","sint","uint"],sd=[,"1d","2d","2d-array","cube","cube-array","3d"],my={undefined:1,unknown:1,destroyed:2};function gy(c,d,p,m,y,T){d=Ke(d),p=Ke(p),m>>>=0,y>>>=0,T>>>=0;var S=K(c>>>0);if(c={},T){var A=(b(),I)[T+12>>>2>>>0];if(A){var N=(b(),I)[T+16>>>2>>>0];c.requiredFeatures=Array.from((b(),I).subarray(N>>>2>>>0,N+4*A>>>2>>>0),q=>rd[q])}if(A=(b(),I)[T+20>>>2>>>0]){let q=function(me,Ie,Fr,Gn=!1){Ie+=Fr,(Ie=(b(),I)[Ie>>>2>>>0])==4294967295||Gn&&Ie==0||(U[me]=Ie)},re=function(me,Ie,Fr){Ie+=Fr,Fr=(b(),I)[Ie>>>2>>>0];var Gn=(b(),I)[Ie+4>>>2>>>0];Fr==4294967295&&Gn==4294967295||(U[me]=Zr(Ie))};N=(b(),I)[A>>>2>>>0];var U={};q("maxTextureDimension1D",A,4),q("maxTextureDimension2D",A,8),q("maxTextureDimension3D",A,12),q("maxTextureArrayLayers",A,16),q("maxBindGroups",A,20),q("maxBindGroupsPlusVertexBuffers",A,24),q("maxBindingsPerBindGroup",A,28),q("maxDynamicUniformBuffersPerPipelineLayout",A,32),q("maxDynamicStorageBuffersPerPipelineLayout",A,36),q("maxSampledTexturesPerShaderStage",A,40),q("maxSamplersPerShaderStage",A,44),q("maxStorageBuffersPerShaderStage",A,48),q("maxStorageTexturesPerShaderStage",A,52),q("maxUniformBuffersPerShaderStage",A,56),q("minUniformBufferOffsetAlignment",A,80),q("minStorageBufferOffsetAlignment",A,84),re("maxUniformBufferBindingSize",A,64),re("maxStorageBufferBindingSize",A,72),q("maxVertexBuffers",A,88),re("maxBufferSize",A,96),q("maxVertexAttributes",A,104),q("maxVertexBufferArrayStride",A,108),q("maxInterStageShaderVariables",A,112),q("maxColorAttachments",A,116),q("maxColorAttachmentBytesPerSample",A,120),q("maxComputeWorkgroupStorageSize",A,124),q("maxComputeInvocationsPerWorkgroup",A,128),q("maxComputeWorkgroupSizeX",A,132),q("maxComputeWorkgroupSizeY",A,136),q("maxComputeWorkgroupSizeZ",A,140),q("maxComputeWorkgroupsPerDimension",A,144),q("maxImmediateSize",A,148,!0),N!==0&&(b(),"maxStorageBuffersInVertexStage"in GPUSupportedLimits.prototype&&(q("maxStorageBuffersInVertexStage",N,8),q("maxStorageTexturesInVertexStage",N,12),q("maxStorageBuffersInFragmentStage",N,16),q("maxStorageTexturesInFragmentStage",N,20))),c.requiredLimits=U}(A=(b(),I)[T+24>>>2>>>0])&&(A={label:At(A+4)},c.defaultQueue=A),c.label=At(T+4)}be+=1,en(d,S.requestDevice(c).then(q=>{--be,ct(()=>{Ze[y>>>0]=q.queue,Ze[m>>>0]=q,be+=1,en(p,q.lost.then(re=>{ct(()=>{q.onuncapturederror=()=>{};var me=te(),Ie=$t(re.message);Za(p,my[re.reason],Ie),ee(me)}),--be})),q.onuncapturederror=re=>{var me=5;re.error instanceof GPUValidationError?me=2:re.error instanceof GPUOutOfMemoryError?me=3:re.error instanceof GPUInternalError&&(me=4);var Ie=te();re=$t(re.error.message),Cd(m,me,re),ee(Ie)},"adapterInfo"in q||(q.adapterInfo=S.info),ro(d,1,m,0)})},q=>{--be,ct(()=>{var re=te(),me=$t(q.message);ro(d,3,m,me),p&&Za(p,4,me),ee(re)})}))}function wy(c){var d=K(c>>>=0),p=tr[c];if(p){for(var m=0;m<p.length;++m)p[m]();delete tr[c]}d.destroy()}function vy(c,d,p){p>>>=0;var m=K(c>>>=0);p==4294967295&&(p=void 0);try{var y=m.getMappedRange(d>>>0,p)}catch{return 0}var T=ao(16,y.byteLength);return(b(),H).set(new Uint8Array(y),T>>>0),tr[c].push(()=>yt(T)),T}function yy(c,d,p){p>>>=0;var m=K(c>>>=0);p==4294967295&&(p=void 0);try{var y=m.getMappedRange(d>>>0,p)}catch{return 0}var T=ao(16,y.byteLength);return(b(),H).fill(0,T,y.byteLength),tr[c].push(()=>{new Uint8Array(y).set((b(),H).subarray(T>>>0,T+y.byteLength>>>0)),yt(T)}),T}function by(c,d,p,m,y){c>>>=0,d=Ke(d),p=Ke(p),y>>>=0;var T=K(c);tr[c]=[],y==4294967295&&(y=void 0),be+=1,en(d,T.mapAsync(p,m>>>0,y).then(()=>{--be,ct(()=>{eo(d,1,0)})},S=>{--be,ct(()=>{te();var A=$t(S.message);eo(d,S.name==="AbortError"?4:S.name==="OperationError"?3:0,A),delete tr[c]})}))}function My(c){var d=K(c>>>=0),p=tr[c];if(p){for(var m=0;m<p.length;++m)p[m]();delete tr[c],d.unmap()}}function xy(c){delete Ze[c>>>0]}function Ty(c,d,p){c>>>=0,d>>>=0,p>>>=0;var m=!!(b(),I)[d+32>>>2>>>0];d={label:At(d+4),usage:(b(),I)[d+16>>>2>>>0],size:Zr(d+24),mappedAtCreation:m},c=K(c);try{var y=c.createBuffer(d)}catch{return!1}return Ze[p>>>0]=y,m&&(tr[p]=[]),!0}function ky(c,d,p,m){c>>>=0,d=Ke(d),m>>>=0,p=ay(p>>>0),c=K(c),be+=1,en(d,c.createComputePipelineAsync(p).then(y=>{--be,ct(()=>{Ze[m>>>0]=y,Ka(d,1,m,0)})},y=>{--be,ct(()=>{var T=te(),S=$t(y.message);Ka(d,y.reason==="validation"?3:y.reason==="internal"?4:0,m,S),ee(T)})}))}function Ey(c,d,p){c>>>=0,d>>>=0,p>>>=0;var m=(b(),I)[d>>>2>>>0],y=(b(),D)[m+4>>>2>>>0];d={label:At(d+4),code:""},y===2&&(d.code=ed(m+8)),c=K(c).createShaderModule(d),Ze[p>>>0]=c}var Cy=c=>{(c=K(c)).onuncapturederror=null,c.destroy()};function Ay(c,d){d=Ke(d),c=K(c>>>0),be+=1,en(d,c.popErrorScope().then(p=>{--be,ct(()=>{var m=5;p?p instanceof GPUValidationError?m=2:p instanceof GPUOutOfMemoryError?m=3:p instanceof GPUInternalError&&(m=4):m=1;var y=te(),T=p?$t(p.message):0;to(d,1,m,T),ee(y)})},p=>{--be,ct(()=>{var m=te(),y=$t(p.message);to(d,1,5,y),ee(m)})}))}function Sy(c,d,p,m){if(d=Ke(d),m>>>=0,p>>>=0){var y={featureLevel:cy[(b(),D)[p+4>>>2>>>0]],powerPreference:uy[(b(),D)[p+8>>>2>>>0]],forceFallbackAdapter:!!(b(),I)[p+12>>>2>>>0]};(c=(b(),I)[p>>>2>>>0])!==0&&(b(),y.Ye=!!(b(),I)[c+8>>>2>>>0])}"gpu"in navigator?(be+=1,en(d,navigator.gpu.requestAdapter(y).then(T=>{--be,ct(()=>{if(T)Ze[m>>>0]=T,Rn(d,1,m,0);else{var S=te(),A=$t("WebGPU not available on this browser (requestAdapter returned null)");Rn(d,3,m,A),ee(S)}})},T=>{--be,ct(()=>{var S=te(),A=$t(T.message);Rn(d,4,m,A),ee(S)})}))):(y=te(),c=$t("WebGPU not available on this browser (navigator.gpu is not available)"),Rn(d,3,m,c),ee(y))}function Py(c,d,p){return c>>>=0,d>>>=0,p>>>=0,Vu(async()=>{var m=[];if(p){var y=(b(),D)[p>>>2>>>0];m.length=d+1,m[d]=new Promise(A=>setTimeout(A,y,0))}else m.length=d;for(var T=0;T<d;++T){var S=Zr(c+8*T);if(!(S in bs))return S;m[T]=bs[S]}return m=await Promise.race(m),delete bs[m],m})}var Xa,Ya={},ad=()=>{if(!Xa){var c,d={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(c in Ya)Ya[c]===void 0?delete d[c]:d[c]=Ya[c];var p=[];for(c in d)p.push(`${c}=${d[c]}`);Xa=p}return Xa};function od(c,d){if(s)return Me(19,1,c,d);c>>>=0,d>>>=0;var p,m=0,y=0;for(p of ad()){var T=d+m;(b(),I)[c+y>>>2>>>0]=T,m+=Zt(p,T,1/0)+1,y+=4}return 0}function id(c,d){if(s)return Me(20,1,c,d);c>>>=0,d>>>=0;var p=ad();for(var m of((b(),I)[c>>>2>>>0]=p.length,c=0,p))c+=er(m)+1;return(b(),I)[d>>>2>>>0]=c,0}function ld(c){return s?Me(21,1,c):52}function cd(c,d,p,m,y){return s?Me(22,1,c,d,p,m,y):52}function ud(c,d,p,m){return s?Me(23,1,c,d,p,m):52}function dd(c,d,p,m){return s?Me(24,1,c,d,p,m):70}var Fy=[null,[],[]];function hd(c,d,p,m){if(s)return Me(25,1,c,d,p,m);d>>>=0,p>>>=0,m>>>=0;for(var y=0,T=0;T<p;T++){var S=(b(),I)[d>>>2>>>0],A=(b(),I)[d+4>>>2>>>0];d+=8;for(var N=0;N<A;N++){var U=c,q=(b(),H)[S+N>>>0],re=Fy[U];q===0||q===10?((U===1?C:E)(Mu(re)),re.length=0):re.push(q)}y+=A}return(b(),I)[m>>>2>>>0]=y,0}function Iy(c){return c>>>0}function Ly(c,d){return td(K(c>>>0).limits,d>>>0),1}function Oy(c,d){return K(c>>>0).features.has(rd[d])}function Ny(c){return BigInt(K(c>>>0).size)}function Dy(c){return BigInt(K(c>>>0).usage)}function By(c,d){if(c>>>=0,d>>>=0){var p=At(d+4);p={label:p,timestampWrites:d=(d=(b(),I)[d+12>>>2>>>0])!==0?{querySet:K((b(),I)[d+4>>>2>>>0]),beginningOfPassWriteIndex:(b(),I)[d+8>>>2>>>0],endOfPassWriteIndex:(b(),I)[d+12>>>2>>>0]}:void 0}}return d=K(c),c=bd(0),p=d.beginComputePass(p),Ze[c>>>0]=p,c}function zy(c,d,p,m){p=Ke(p),(m=Ke(m))==-1&&(m=void 0),(c=K(c>>>0)).clearBuffer(K(d>>>0),p,m)}function Ry(c,d,p,m,y,T){p=Ke(p),y=Ke(y),T=Ke(T),K(c>>>0).copyBufferToBuffer(K(d>>>0),p,K(m>>>0),y,T)}function $y(c){var d=K(c>>>0);return c=vd(0),d=d.finish(),Ze[c>>>0]=d,c}function Gy(c,d,p,m,y,T){T=Ke(T),K(c>>>0).resolveQuerySet(K(d>>>0),p,m,K(y>>>0),T)}function Vy(c,d,p,m){K(c>>>0).dispatchWorkgroups(d,p,m)}function Uy(c,d,p){p=Ke(p),K(c>>>0).dispatchWorkgroupsIndirect(K(d>>>0),p)}function Wy(c){K(c>>>0).end()}function jy(c,d,p,m,y){m>>>=0,y>>>=0,c=K(c>>>0),p=K(p>>>0),m==0?c.setBindGroup(d,p):c.setBindGroup(d,p,(b(),I),y>>>2,m)}function qy(c,d){K(c>>>0).setPipeline(K(d>>>0))}function Hy(c,d,p){K(c>>>0).Xe(K(d>>>0),p)}function Qy(c,d){function p(y){var T=(b(),I)[y+8>>>2>>>0],S=(b(),I)[y+32>>>2>>>0],A=(b(),I)[y+36>>>2>>>0],N=0;return Qa(y,{14:U=>{N=(b(),I)[U+8>>>2>>>0]}}),T?((S=Zr(y+24))==-1&&(S=void 0),T={buffer:K(T),offset:Zr(y+16),size:S}):T=K(S||A||N),{binding:(b(),I)[y+4>>>2>>>0],resource:T}}c>>>=0,d={label:At((d>>>=0)+4),layout:K((b(),I)[d+12>>>2>>>0]),entries:(function(y,T){for(var S=[],A=0;A<y;++A)S.push(p(T+40*A));return S})((b(),I)[d+16>>>2>>>0],(b(),I)[d+20>>>2>>>0])},c=K(c);var m=gd(0);return Zu(m,c.createBindGroup(d)),m}function Xy(c,d){function p(N){var U=(b(),I)[N+4>>>2>>>0];if(U)return{type:iy[U],hasDynamicOffset:!!(b(),I)[N+8>>>2>>>0],minBindingSize:Zr(N+16)}}function m(N){if(N=(b(),I)[N+4>>>2>>>0])return{type:hy[N]}}function y(N){var U=(b(),I)[N+4>>>2>>>0];if(U)return{sampleType:py[U],viewDimension:sd[(b(),D)[N+8>>>2>>>0]],multisampled:!!(b(),I)[N+12>>>2>>>0]}}function T(N){var U=(b(),I)[N+4>>>2>>>0];if(U)return{access:fy[U],format:_y[(b(),D)[N+8>>>2>>>0]],viewDimension:sd[(b(),D)[N+12>>>2>>>0]]}}function S(N){var U={binding:(b(),I)[N+4>>>2>>>0],visibility:(b(),I)[N+8>>>2>>>0],buffer:p(N+24),sampler:m(N+48),texture:y(N+56),storageTexture:T(N+72)};return Qa(N,{13:()=>{U.externalTexture={}}}),U}c>>>=0,d={label:At((d>>>=0)+4),entries:(function(N,U){for(var q=[],re=0;re<N;++re)q.push(S(U+88*re));return q})((b(),I)[d+12>>>2>>>0],(b(),I)[d+16>>>2>>>0])},c=K(c);var A=wd(0);return Zu(A,c.createBindGroupLayout(d)),A}function Yy(c,d){var p;return c>>>=0,(d>>>=0)&&(p={label:At(d+4)}),d=K(c),c=yd(0),p=d.createCommandEncoder(p),Ze[c>>>0]=p,c}function Jy(c,d){c>>>=0,d>>>=0;for(var p=(b(),I)[d+12>>>2>>>0],m=(b(),I)[d+16>>>2>>>0],y=[],T=0;T<p;++T)y.push(K((b(),I)[m+4*T>>>2>>>0]));return d={label:At(d+4),bindGroupLayouts:y,immediateSize:(b(),I)[d+20>>>2>>>0]},p=K(c),c=Md(0),d=p.createPipelineLayout(d),Ze[c>>>0]=d,c}function Ky(c,d){c>>>=0,d>>>=0,d={type:dy[(b(),D)[d+12>>>2>>>0]],count:(b(),I)[d+16>>>2>>>0]};var p=K(c);return c=xd(0),d=p.createQuerySet(d),Ze[c>>>0]=d,c}function Zy(c,d){return oy(K(c>>>0).adapterInfo,d>>>0),1}var eb={"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,"subgroup-size-control":23,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729,"chromium-experimental-subgroup-matrix":327732};function tb(c,d){d>>>=0;var p=K(c>>>0);c=Pr(4*p.features.size);var m=0,y=0;for(let T of p.features)0<=(p=eb[T])&&((b(),D)[c+m>>>2>>>0]=p,m+=4,y++);(b(),I)[d+4>>>2>>>0]=c,(b(),I)[d>>>2>>>0]=y}function rb(c,d){return td(K(c>>>0).limits,d>>>0),1}function nb(c,d){K(c>>>0).pushErrorScope(ly[d])}function sb(c,d,p){d>>>=0,p>>>=0,c=K(c>>>0),d=Array.from((b(),D).subarray(p>>>2>>>0,p+4*d>>>2>>>0),m=>K(m)),c.submit(d)}function ab(c,d,p,m,y){p=Ke(p),m>>>=0,y>>>=0,c=K(c>>>0),d=K(d>>>0),m=(b(),H).subarray(m>>>0,m+y>>>0),c.writeBuffer(d,p,m,0,y)}s||(function(){for(var c=t.numThreads-1;c--;)pu();$e.push(async()=>{var d=(async function(){if(!s)return Promise.all(cr.map(_u))})();Fe++,await d,--Fe==0&&we&&(d=we,we=null,d())})})(),s||(ur=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),O()),t.wasmBinary&&(f=t.wasmBinary),t.stackSave=()=>te(),t.stackRestore=c=>ee(c),t.stackAlloc=c=>Ts(c),t.setValue=function(c,d,p="i8"){switch(p.endsWith("*")&&(p="*"),p){case"i1":case"i8":(b(),R)[c>>>0]=d;break;case"i16":(b(),J)[c>>>1>>>0]=d;break;case"i32":(b(),D)[c>>>2>>>0]=d;break;case"i64":(b(),ce)[c>>>3>>>0]=BigInt(d);break;case"float":(b(),G)[c>>>2>>>0]=d;break;case"double":(b(),Q)[c>>>3>>>0]=d;break;case"*":(b(),I)[c>>>2>>>0]=d;break;default:se(`invalid type for setValue: ${p}`)}},t.getValue=function(c,d="i8"){switch(d.endsWith("*")&&(d="*"),d){case"i1":case"i8":return(b(),R)[c>>>0];case"i16":return(b(),J)[c>>>1>>>0];case"i32":return(b(),D)[c>>>2>>>0];case"i64":return(b(),ce)[c>>>3>>>0];case"float":return(b(),G)[c>>>2>>>0];case"double":return(b(),Q)[c>>>3>>>0];case"*":return(b(),I)[c>>>2>>>0];default:se(`invalid type for getValue: ${d}`)}},t.UTF8ToString=Jr,t.stringToUTF8=Zt,t.lengthBytesUTF8=er;var fd,_d,pd,Ja,xs,yt,Pr,md,gd,wd,vd,yd,bd,Md,xd,Td,kd,Ed,Ka,Za,eo,to,Rn,ro,Cd,no,Ad,Sd,Pd,so,Fd,Id,ao,he,$n,Ld,ee,Ts,te,Od,oo,Nd,Dd,Bd,io,zd,Rd,$d,Gd,Vd,Ud,Wd,jd,qd,Hd,Qd,Xd,Yd,Jd,Kd,Zd,eh,th,rh,nh,sh,ah,oh,ih,lh,ch,uh,dh,hh,fh,_h,ph,mh,gh,wh,vh,yh,bh,Mh,xh,Th,rr,ob=[Qr,Dn,wu,xu,Tu,ku,Eu,Cu,Au,Su,Pu,Fu,Iu,Lu,Ou,Nu,Hu,Qu,Xu,od,id,ld,cd,ud,dd,hd],lo={1280444:(c,d,p,m,y)=>{if(t===void 0||!t.ed)return 1;if((c=Jr(Number(c>>>0))).startsWith("./")&&(c=c.substring(2)),!(c=t.ed.get(c)))return 2;if(d=Number(d>>>0),p=Number(p>>>0),m=Number(m>>>0),d+p>c.byteLength)return 3;try{let T=c.subarray(d,d+p);switch(y){case 0:(b(),H).set(T,m>>>0);break;case 1:t.pe?t.pe(m,T):t.Re(m,T);break;default:return 4}return 0}catch{return 4}},1281268:(c,d,p)=>{t.re(c,(b(),H).subarray(d>>>0,d+p>>>0))},1281332:()=>t.Pe(),1281374:c=>{t.qe(c)},1281411:()=>typeof wasmOffsetConverter<"u"};function ib(){return typeof wasmOffsetConverter<"u"}function lb(c,d,p,m){var y=te();try{return jd(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function cb(c,d,p){var m=te();try{return Vd(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;he(1,0)}}function ub(c){var d=te();try{zd(c)}catch(p){if(ee(d),p!==p+0)throw p;he(1,0)}}function db(c,d){var p=te();try{return io(c,d)}catch(m){if(ee(p),m!==m+0)throw m;he(1,0)}}function hb(c,d,p){var m=te();try{Bd(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;he(1,0)}}function fb(c,d){var p=te();try{qd(c,d)}catch(m){if(ee(p),m!==m+0)throw m;he(1,0)}}function _b(c,d,p,m,y,T,S){var A=te();try{return Gd(c,d,p,m,y,T,S)}catch(N){if(ee(A),N!==N+0)throw N;he(1,0)}}function pb(c,d,p,m,y,T){var S=te();try{Rd(c,d,p,m,y,T)}catch(A){if(ee(S),A!==A+0)throw A;he(1,0)}}function mb(c,d,p,m){var y=te();try{Wd(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function gb(c,d,p,m,y,T,S){var A=te();try{Qd(c,d,p,m,y,T,S)}catch(N){if(ee(A),N!==N+0)throw N;he(1,0)}}function wb(c,d,p,m,y,T,S){var A=te();try{Xd(c,d,p,m,y,T,S)}catch(N){if(ee(A),N!==N+0)throw N;he(1,0)}}function vb(c,d,p,m,y,T,S,A){var N=te();try{ah(c,d,p,m,y,T,S,A)}catch(U){if(ee(N),U!==U+0)throw U;he(1,0)}}function yb(c,d,p,m,y,T,S,A,N,U,q,re){var me=te();try{Yd(c,d,p,m,y,T,S,A,N,U,q,re)}catch(Ie){if(ee(me),Ie!==Ie+0)throw Ie;he(1,0)}}function bb(c,d,p,m,y){var T=te();try{return Hd(c,d,p,m,y)}catch(S){if(ee(T),S!==S+0)throw S;he(1,0)}}function Mb(c,d,p,m,y,T){var S=te();try{oh(c,d,p,m,y,T)}catch(A){if(ee(S),A!==A+0)throw A;he(1,0)}}function xb(c,d,p,m,y){var T=te();try{$d(c,d,p,m,y)}catch(S){if(ee(T),S!==S+0)throw S;he(1,0)}}function Tb(c,d,p,m,y,T,S,A){var N=te();try{Ud(c,d,p,m,y,T,S,A)}catch(U){if(ee(N),U!==U+0)throw U;he(1,0)}}function kb(c){var d=te();try{return ih(c)}catch(p){if(ee(d),p!==p+0)throw p;he(1,0)}}function Eb(c,d,p,m,y,T,S,A,N){var U=te();try{Kd(c,d,p,m,y,T,S,A,N)}catch(q){if(ee(U),q!==q+0)throw q;he(1,0)}}function Cb(c,d,p){var m=te();try{return lh(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;he(1,0)}}function Ab(c,d){var p=te();try{return yh(c,d)}catch(m){if(ee(p),m!==m+0)throw m;return he(1,0),0n}}function Sb(c,d,p,m){var y=te();try{return ch(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function Pb(c){var d=te();try{return Jd(c)}catch(p){if(ee(d),p!==p+0)throw p;return he(1,0),0n}}function Fb(c,d,p,m){var y=te();try{return uh(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function Ib(c,d,p,m,y){var T=te();try{return dh(c,d,p,m,y)}catch(S){if(ee(T),S!==S+0)throw S;he(1,0)}}function Lb(c,d,p,m,y,T){var S=te();try{return hh(c,d,p,m,y,T)}catch(A){if(ee(S),A!==A+0)throw A;he(1,0)}}function Ob(c,d,p,m,y,T){var S=te();try{return nh(c,d,p,m,y,T)}catch(A){if(ee(S),A!==A+0)throw A;he(1,0)}}function Nb(c,d,p,m,y,T){var S=te();try{return fh(c,d,p,m,y,T)}catch(A){if(ee(S),A!==A+0)throw A;he(1,0)}}function Db(c,d,p,m,y,T,S,A){var N=te();try{return sh(c,d,p,m,y,T,S,A)}catch(U){if(ee(N),U!==U+0)throw U;he(1,0)}}function Bb(c,d,p,m,y){var T=te();try{return _h(c,d,p,m,y)}catch(S){if(ee(T),S!==S+0)throw S;return he(1,0),0n}}function zb(c,d,p,m){var y=te();try{return ph(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function Rb(c,d,p,m){var y=te();try{return mh(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function $b(c,d,p,m,y,T,S,A,N,U,q,re){var me=te();try{return gh(c,d,p,m,y,T,S,A,N,U,q,re)}catch(Ie){if(ee(me),Ie!==Ie+0)throw Ie;he(1,0)}}function Gb(c,d,p,m,y,T,S,A,N,U,q){var re=te();try{wh(c,d,p,m,y,T,S,A,N,U,q)}catch(me){if(ee(re),me!==me+0)throw me;he(1,0)}}function Vb(c,d,p,m,y,T,S,A,N,U,q,re,me,Ie,Fr,Gn){var Hb=te();try{vh(c,d,p,m,y,T,S,A,N,U,q,re,me,Ie,Fr,Gn)}catch(co){if(ee(Hb),co!==co+0)throw co;he(1,0)}}function Ub(c,d,p){var m=te();try{return eh(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;return he(1,0),0n}}function Wb(c,d,p){var m=te();try{return Zd(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;he(1,0)}}function jb(c,d,p){var m=te();try{return th(c,d,p)}catch(y){if(ee(m),y!==y+0)throw y;he(1,0)}}function qb(c,d,p,m){var y=te();try{rh(c,d,p,m)}catch(T){if(ee(y),T!==T+0)throw T;he(1,0)}}function ks(){if(0<Fe)we=ks;else if(s)w?.(t),$();else{for(var c=$e;0<c.length;)c.shift()(t);0<Fe?we=ks:(t.calledRun=!0,F||($(),w?.(t)))}}return s||(rr=await We(),ks()),t.PTR_SIZE=4,t.webgpuInit=c=>{let d=new WeakMap,p,m,y=1;t.webgpuRegisterDevice=A=>{if(m!==void 0)throw Error("another WebGPU EP inference session is being created.");if(A){var N=d.get(A);if(!N){let U=((q,re=0)=>{var me=Ed(re);return re=kd(re,me),Ze[me>>>0]=q.queue,Ze[re>>>0]=q,re})(A,N=pd());N=[y++,N,U],d.set(A,N)}return p=A,m=N[0],N}p=void 0,m=0};let T=new Map;t.webgpuOnCreateSession=A=>{if(m!==void 0){var N=m;if(m=void 0,A){let U=Ja(N);T.set(A,U),N===0&&c(p??K(U))}p=void 0}},t.webgpuOnReleaseSession=A=>{T.delete(A)};let S=Symbol("gpuBufferMetadata");t.webgpuRegisterBuffer=(A,N,U)=>{if(U)return A[S]=[U,NaN],U;if(U=A[S])return U[1]++,U[0];if((N=T.get(N))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return N=((q,re=0)=>(q.mapState==="unmapped"||se(),re=Td(re),Ze[re>>>0]=q,re))(A,N),A[S]=[N,1],N},t.webgpuUnregisterBuffer=A=>{let N=A[S];if(!N)throw Error("Buffer is not registered");N[1]--,N[1]===0&&(md(N[0]),delete A[S])},t.webgpuGetBuffer=A=>K(A),t.webgpuCreateDownloader=(A,N,U)=>{if((U=T.get(U))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let q=K(U),re=16*Math.ceil(Number(N)/16);return async()=>{let me=q.createBuffer({size:re,usage:9});try{let Ie=q.createCommandEncoder();return Ie.copyBufferToBuffer(A,0,me,0,re),q.queue.submit([Ie.finish()]),await me.mapAsync(GPUMapMode.READ),me.getMappedRange().slice(0,N)}finally{me.destroy()}}},t.pe=(A,N)=>{var U=N.buffer;let q=N.byteOffset,re=N.byteLength;if(N=16*Math.ceil(Number(re)/16),A=K(A),!p){var me=Ja(m);p=K(me)}let Ie=(me=p.createBuffer({mappedAtCreation:!0,size:N,usage:6})).getMappedRange();new Uint8Array(Ie).set(new Uint8Array(U,q,re)),me.unmap(),(U=p.createCommandEncoder()).copyBufferToBuffer(me,0,A,0,N),p.queue.submit([U.finish()]),me.destroy()}},t.webnnInit=c=>{let d=c[0];[t.Pe,t.qe,t.webnnEnsureTensor,t.re,t.webnnDownloadTensor,t.Oe,t.webnnEnableTraceEvent]=c.slice(1),t.webnnReleaseTensorId=t.qe,t.webnnUploadTensor=t.re,t.webnnRegisterMLContext=t.Oe,t.webnnOnRunStart=p=>d.onRunStart(p),t.webnnOnRunEnd=d.onRunEnd.bind(d),t.webnnOnReleaseSession=p=>{d.onReleaseSession(p)},t.webnnCreateMLTensorDownloader=(p,m)=>d.createMLTensorDownloader(p,m),t.webnnRegisterMLTensor=(p,m,y,T)=>d.registerMLTensor(p,m,y,T),t.webnnCreateMLContext=p=>d.createMLContext(p),t.webnnRegisterGraphInput=d.registerGraphInput.bind(d),t.webnnIsGraphInput=d.isGraphInput.bind(d),t.webnnRegisterGraphOutput=d.registerGraphOutput.bind(d),t.webnnIsGraphOutput=d.isGraphOutput.bind(d),t.webnnCreateTemporaryTensor=d.createTemporaryTensor.bind(d),t.webnnIsGraphInputOutputTypeSupported=d.isGraphInputOutputTypeSupported.bind(d)},L?t:new Promise((c,d)=>{w=c,v=d})}var x_,Ch,f0=ge(()=>{"use strict";x_=Eh,Ch=globalThis.self?.name?.startsWith("em-pthread"),Ch&&Eh()}),mo,qo,Ah,_t,T_,Cs,Sh,Ph,go,Fh,wo,k_,vo,E_,pi=ge(()=>{"use strict";_i(),mo=typeof location>"u"?void 0:location.origin,qo=import.meta.url>"file:"&&import.meta.url<"file;",Ah=()=>{if(qo){let e=URL;return new URL(new e("ort.webgpu.bundle.min.mjs",import.meta.url).href,mo).href}return import.meta.url},_t=Ah(),T_=()=>{if(_t&&!_t.startsWith("blob:"))return _t.substring(0,_t.lastIndexOf("/")+1)},Cs=(e,t)=>{try{let r=t??_t;return(r?new URL(e,r):new URL(e)).origin===mo}catch{return!1}},Sh=(e,t)=>{let r=t??_t;try{return(r?new URL(e,r):new URL(e)).href}catch{return}},Ph=(e,t)=>`${t??"./"}${e}`,go=async e=>{let t=await(await fetch(e,{credentials:"same-origin"})).blob();return URL.createObjectURL(t)},Fh=async e=>(await import(e)).default,wo=(h0(),Us(y_)).default,k_=async()=>{if(!_t)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Cs(_t))return[void 0,wo()];let e=await go(_t);return[e,wo(e)]},vo=(f0(),Us(M_)).default,E_=async(e,t,r,n)=>{let s=vo&&!(e||t);if(s)if(_t)s=Cs(_t)||n&&!r;else if(n&&!r)s=!0;else throw new Error("cannot determine the script source URL.");if(s)return[void 0,vo];{let a="ort-wasm-simd-threaded.asyncify.mjs",o=e??Sh(a,t),i=r&&o&&!Cs(o,t),l=i?await go(o):o??Ph(a,t);return[i?l:void 0,await Fh(l)]}}}),yo,As,Un,bo,Ih,Lh,Oh,mi,Le,jr=ge(()=>{"use strict";pi(),As=!1,Un=!1,bo=!1,Ih=()=>{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}},Lh=()=>{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}},Oh=()=>{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}},mi=async e=>{if(As)return Promise.resolve();if(Un)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(bo)throw new Error("previous call to 'initializeWebAssembly()' failed.");Un=!0;let t=e.initTimeout,r=e.numThreads;if(e.simd!==!1){if(e.simd==="relaxed"){if(!Oh())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Lh())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let n=Ih();r>1&&!n&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+r+", 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=r=1);let s=e.wasmPaths,a=typeof s=="string"?s:void 0,o=s?.mjs,i=o?.href??o,l=s?.wasm,u=l?.href??l,h=e.wasmBinary,[f,_]=await E_(i,a,r>1,!!h||!!u),g=!1,w=[];if(t>0&&w.push(new Promise(v=>{setTimeout(()=>{g=!0,v()},t)})),w.push(new Promise((v,M)=>{let x={numThreads:r};if(h)x.wasmBinary=h,x.locateFile=k=>k;else if(u||a)x.locateFile=k=>u??a+k;else if(i&&i.indexOf("blob:")!==0)x.locateFile=k=>new URL(k,i).href;else if(f){let k=T_();k&&(x.locateFile=C=>k+C)}_(x).then(k=>{Un=!1,As=!0,yo=k,v(),f&&URL.revokeObjectURL(f)},k=>{Un=!1,bo=!0,M(k)})})),await Promise.race(w),g)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},Le=()=>{if(As&&yo)return yo;throw new Error("WebAssembly is not initialized yet.")}}),pt,js,xe,gi=ge(()=>{"use strict";jr(),pt=(e,t)=>{let r=Le(),n=r.lengthBytesUTF8(e)+1,s=r._malloc(n);return r.stringToUTF8(e,s,n),t.push(s),s},js=(e,t,r,n)=>{if(typeof e=="object"&&e!==null){if(r.has(e))throw new Error("Circular reference in options");r.add(e)}Object.entries(e).forEach(([s,a])=>{let o=t?t+s:s;if(typeof a=="object")js(a,o+".",r,n);else if(typeof a=="string"||typeof a=="number")n(o,a.toString());else if(typeof a=="boolean")n(o,a?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof a}`)})},xe=e=>{let t=Le(),r=t.stackSave();try{let n=t.PTR_SIZE,s=t.stackAlloc(2*n);t._OrtGetLastError(s,s+n);let a=Number(t.getValue(s,n===4?"i32":"i64")),o=t.getValue(s+n,"*"),i=o?t.UTF8ToString(o):"";throw new Error(`${e} ERROR_CODE: ${a}, ERROR_MESSAGE: ${i}`)}finally{t.stackRestore(r)}}}),C_,_0=ge(()=>{"use strict";jr(),gi(),C_=e=>{let t=Le(),r=0,n=[],s=e||{};try{if(e?.logSeverityLevel===void 0)s.logSeverityLevel=2;else if(typeof e.logSeverityLevel!="number"||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)s.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!="number"||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(s.terminate=!1);let a=0;return e?.tag!==void 0&&(a=pt(e.tag,n)),r=t._OrtCreateRunOptions(s.logSeverityLevel,s.logVerbosityLevel,!!s.terminate,a),r===0&&xe("Can't create run options."),e?.extra!==void 0&&js(e.extra,"",new WeakSet,(o,i)=>{let l=pt(o,n),u=pt(i,n);t._OrtAddRunConfigEntry(r,l,u)!==0&&xe(`Can't set a run config entry: ${o} - ${i}.`)}),[r,n]}catch(a){throw r!==0&&t._OrtReleaseRunOptions(r),n.forEach(o=>t._free(o)),a}}}),Nh,Dh,Bh,tn,Gt,zh,A_,p0=ge(()=>{"use strict";jr(),gi(),Nh=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 new Error(`unsupported graph optimization level: ${e}`)}},Dh=e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}},Bh=e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some(r=>(typeof r=="string"?r:r.name)==="webgpu")&&(e.enableMemPattern=!1)},tn=(e,t,r,n)=>{let s=pt(t,n),a=pt(r,n);Le()._OrtAddSessionConfigEntry(e,s,a)!==0&&xe(`Can't set a session config entry: ${t} - ${r}.`)},Gt=(e,t,r,n)=>{let s=pt(t,n),a=pt(r,n);e.push([s,a])},zh=async(e,t,r)=>{let n=t.executionProviders;for(let s of n){let a=typeof s=="string"?s:s.name,o=[];switch(a){case"webnn":if(a="WEBNN",tn(e,"session.disable_quant_qdq","1",r),tn(e,"session.disable_qdq_constant_folding","1",r),typeof s!="string"){let f=s?.deviceType;f&&tn(e,"deviceType",f,r)}break;case"webgpu":{a="WebGPU";let f;if(typeof s!="string"){let g=s;if(g.device)if(typeof GPUDevice<"u"&&g.device instanceof GPUDevice)f=g.device;else throw new Error("Invalid GPU device set in WebGPU EP options.");let{enableGraphCapture:w}=t;if(typeof w=="boolean"&&w&&Gt(o,"enableGraphCapture","1",r),typeof g.preferredLayout=="string"&&Gt(o,"preferredLayout",g.preferredLayout,r),g.forceCpuNodeNames){let v=Array.isArray(g.forceCpuNodeNames)?g.forceCpuNodeNames:[g.forceCpuNodeNames];Gt(o,"forceCpuNodeNames",v.join(`
6
+ `),r)}g.validationMode&&Gt(o,"validationMode",g.validationMode,r),typeof g.enableMatmulFp32Accumulation=="boolean"&&Gt(o,"enableMatmulFp32Accumulation",g.enableMatmulFp32Accumulation?"1":"0",r);for(let v of["storageBufferCacheMode","uniformBufferCacheMode","queryResolveBufferCacheMode","defaultBufferCacheMode"]){let M=g[v];if(M){if(M!=="disabled"&&M!=="lazyRelease"&&M!=="simple"&&M!=="bucket")throw new Error(`${v} must be one of 'disabled', 'lazyRelease', 'simple' or 'bucket': ${M}`);Gt(o,v,M,r)}}}let _=Le().webgpuRegisterDevice(f);if(_){let[g,w,v]=_;Gt(o,"deviceId",g.toString(),r),Gt(o,"webgpuInstance",w.toString(),r),Gt(o,"webgpuDevice",v.toString(),r)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${a}`)}let i=pt(a,r),l=o.length,u=0,h=0;if(l>0){u=Le()._malloc(l*Le().PTR_SIZE),r.push(u),h=Le()._malloc(l*Le().PTR_SIZE),r.push(h);for(let f=0;f<l;f++)Le().setValue(u+f*Le().PTR_SIZE,o[f][0],"*"),Le().setValue(h+f*Le().PTR_SIZE,o[f][1],"*")}await Le()._OrtAppendExecutionProvider(e,i,u,h,l)!==0&&xe(`Can't append execution provider: ${a}.`)}},A_=async e=>{let t=Le(),r=0,n=[],s=e||{};Bh(s);try{let a=Nh(s.graphOptimizationLevel??"all"),o=Dh(s.executionMode??"sequential"),i=typeof s.logId=="string"?pt(s.logId,n):0,l=s.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let u=s.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let h=typeof s.optimizedModelFilePath=="string"?pt(s.optimizedModelFilePath,n):0;if(r=t._OrtCreateSessionOptions(a,!!s.enableCpuMemArena,!!s.enableMemPattern,o,!!s.enableProfiling,0,i,l,u,h),r===0&&xe("Can't create session options."),s.executionProviders&&await zh(r,s,n),s.enableGraphCapture!==void 0){if(typeof s.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${s.enableGraphCapture}`);tn(r,"enableGraphCapture",s.enableGraphCapture.toString(),n)}if(s.freeDimensionOverrides)for(let[f,_]of Object.entries(s.freeDimensionOverrides)){if(typeof f!="string")throw new Error(`free dimension override name must be a string: ${f}`);if(typeof _!="number"||!Number.isInteger(_)||_<0)throw new Error(`free dimension override value must be a non-negative integer: ${_}`);let g=pt(f,n);t._OrtAddFreeDimensionOverride(r,g,_)!==0&&xe(`Can't set a free dimension override: ${f} - ${_}.`)}return s.extra!==void 0&&js(s.extra,"",new WeakSet,(f,_)=>{tn(r,f,_,n)}),[r,n]}catch(a){throw r!==0&&t._OrtReleaseSessionOptions(r)!==0&&xe("Can't release session options."),n.forEach(o=>t._free(o)),a}}}),zr,zs,ln,Xn,qs,wi,vi,Ho,vn=ge(()=>{"use strict";zr=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 new Error(`unsupported data type: ${e}`)}},zs=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 new Error(`unsupported data type: ${e}`)}},ln=(e,t)=>{let r=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],n=typeof t=="number"?t:t.reduce((s,a)=>s*a,1);return r>0?Math.ceil(n*r):void 0},Xn=e=>{switch(e){case"float16":return typeof Float16Array<"u"?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 new Error(`unsupported type: ${e}`)}},qs=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 new Error(`unsupported logging level: ${e}`)}},wi=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",vi=e=>e==="float32"||e==="float16"||e==="int32"||e==="int64"||e==="uint32"||e==="uint64"||e==="int8"||e==="uint8"||e==="bool"||e==="uint4"||e==="int4",Ho=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 new Error(`unsupported data location: ${e}`)}}}),yi,S_=ge(()=>{"use strict";_i(),yi=async e=>{if(typeof e=="string"){let t=await fetch(e);if(!t.ok)throw new Error(`failed to load external data file: ${e}`);let r=t.headers.get("Content-Length"),n=r?parseInt(r,10):0;if(n<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw new Error(`failed to load external data file: ${e}, no response body.`);let s=t.body.getReader(),a;try{a=new ArrayBuffer(n)}catch(i){if(i instanceof RangeError){let l=Math.ceil(n/65536);a=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw i}let o=0;for(;;){let{done:i,value:l}=await s.read();if(i)break;let u=l.byteLength;new Uint8Array(a,o,u).set(l),o+=u}return new Uint8Array(a,0,n)}}else return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),P_,m0=ge(()=>{"use strict";vn(),P_=(e,t)=>new(Xn(t))(e)}),Rh,$h,Gh,Vh,F_,Uh,ut,I_=ge(()=>{"use strict";vn(),Rh=["V","I","W","E","F"],$h=(e,t)=>{console.log(`[${Rh[e]},${new Date().toISOString()}]${t}`)},F_=(e,t)=>{Gh=e,Vh=t},Uh=(e,t)=>{let r=qs(e),n=qs(Gh);r>=n&&$h(r,typeof t=="function"?t():t)},ut=(...e)=>{Vh&&Uh(...e)}}),Mo,Wh,xo,jh,To,qh,ko,Eo,Co,Hh,L_,g0=ge(()=>{"use strict";vn(),I_(),Mo=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),Wh=(e,t)=>{if(t==="int32")return e;let r=Mo.get(t);if(!r)throw new Error(`WebNN backend does not support data type: ${t}`);let n=r/8;if(e.byteLength%n!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${n}.`);let s=e.byteLength/n,a=new(Xn(t))(e.buffer,e.byteOffset,s);switch(t){case"int64":case"uint64":{let o=new Int32Array(s);for(let i=0;i<s;i++){let l=a[i];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");o[i]=Number(l)}return new Uint8Array(o.buffer)}case"int8":case"uint8":case"uint32":{if(t==="uint32"&&a.some(i=>i>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let o=Int32Array.from(a,Number);return new Uint8Array(o.buffer)}default:throw new Error(`Unsupported data conversion from ${t} to 'int32'`)}},xo=(e,t)=>{if(t==="int32")return e;if(e.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let r=e.byteLength/4,n=new Int32Array(e.buffer,e.byteOffset,r);switch(t){case"int64":{let s=BigInt64Array.from(n,BigInt);return new Uint8Array(s.buffer)}case"uint64":{if(n.some(a=>a<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let s=BigUint64Array.from(n,BigInt);return new Uint8Array(s.buffer)}case"int8":{if(n.some(a=>a<-128||a>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let s=Int8Array.from(n,Number);return new Uint8Array(s.buffer)}case"uint8":{if(n.some(s=>s<0||s>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(n,Number)}case"uint32":{if(n.some(a=>a<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let s=Uint32Array.from(n,Number);return new Uint8Array(s.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${t}`)}},jh=1,To=()=>jh++,qh=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),ko=(e,t)=>{let r=Mo.get(e);if(!r)throw new Error(`WebNN backend does not support data type: ${e}`);return t.length>0?Math.ceil(t.reduce((n,s)=>n*s)*r/8):0},Eo=class{constructor(e){this.isDataConverted=!1;let{sessionId:t,context:r,tensor:n,dataType:s,shape:a,fallbackDataType:o}=e;this.sessionId=t,this.mlContext=r,this.mlTensor=n,this.dataType=s,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 ko(this.dataType,this.tensorShape)}destroy(){ut("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),r=xo(new Uint8Array(t),this.dataType);if(e){(e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).set(r);return}else return new Uint8Array(r).buffer}else return e?this.mlContext.readTensor(this.mlTensor,e):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(e,t,r){return this.mlContext===e&&this.dataType===t&&this.tensorShape.length===r.length&&this.tensorShape.every((n,s)=>n===r[s])}setIsDataConverted(e){this.isDataConverted=e}},Co=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,r,n){let s=this.tensorManager.getMLContext(e),a=this.tensorManager.getMLOpSupportLimits(e),o;if(!a?.input.dataTypes.includes(t)){if(o=qh.get(t),!o||!a?.input.dataTypes.includes(o))throw new Error(`WebNN backend does not support data type: ${t}`);ut("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${t} to ${o}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(s,t,r))return this.wrapper.tensor;if(n){if(this.wrapper.byteLength!==ko(t,r))throw new Error("Unable to copy data to tensor with different size.");this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let i=typeof MLTensorUsage>"u"?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(e,t,r,i,!0,!0,o),n&&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=Wh(e,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(e.byteLength===this.wrapper.byteLength){this.wrapper.write(t);return}else ut("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?xo(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 new Error("Tensor has not been created.");return e?this.wrapper.read(e):this.wrapper.read()}},Hh=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 new Error("MLContext not found for session.");return t}getMLOpSupportLimits(e){return this.backend.getMLOpSupportLimits(e)}reserveTensorId(){let e=To();return this.tensorTrackersById.set(e,new Co(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,r,n,s){ut("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${t}, dataType: ${r}, shape: ${n}, copyOld: ${s}}`);let a=this.tensorTrackersById.get(t);if(!a)throw new Error("Tensor not found.");return a.ensureTensor(e,r,n,s)}upload(e,t){let r=this.tensorTrackersById.get(e);if(!r)throw new Error("Tensor not found.");r.upload(t)}async download(e,t){ut("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${e}, dstBuffer: ${t?.byteLength}}`);let r=this.tensorTrackersById.get(e);if(!r)throw new Error("Tensor not found.");return r.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,r,n){let s=this.getMLContext(e),a=To(),o=new Eo({sessionId:e,context:s,tensor:t,dataType:r,shape:n});return this.tensorTrackersById.set(a,new Co(this,o)),this.externalTensors.add(o),a}async getCachedTensor(e,t,r,n,s,a,o){let i=this.getMLContext(e);for(let[u,h]of this.freeTensors.entries())if(h.canReuseTensor(i,t,r)){ut("verbose",()=>`[WebNN] Reusing tensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:""} shape: ${r}`);let f=this.freeTensors.splice(u,1)[0];return f.sessionId=e,f}ut("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:""} shape: ${r}}`);let l=await i.createTensor({dataType:o??t,shape:r,dimensions:r,usage:n,writable:s,readable:a});return new Eo({sessionId:e,context:i,tensor:l,dataType:t,shape:r,fallbackDataType:o})}releaseTensor(e){this.externalTensors.has(e)&&this.externalTensors.delete(e),this.freeTensors.push(e)}},L_=(...e)=>new Hh(...e)}),O_={};Zn(O_,{WebNNBackend:()=>N_});var Wn,Qh,N_,w0=ge(()=>{"use strict";vn(),jr(),m0(),g0(),I_(),Wn=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),Qh=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0)return!1;let r=Object.keys(e).sort(),n=Object.keys(t).sort();return r.length===n.length&&r.every((s,a)=>s===n[a]&&e[s]===t[s])},N_=class{constructor(e){this.tensorManager=L_(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,F_(e.logLevel,!!e.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(e){ut("verbose",()=>`[WebNN] onRunStart {sessionId: ${e}}`),this.activeSessionId=e}onRunEnd(e){ut("verbose",()=>`[WebNN] onRunEnd {sessionId: ${e}}`);let t=this.temporarySessionTensorIds.get(e);if(t){for(let r of t)ut("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${r}}`),this.tensorManager.releaseTensorId(r);this.temporarySessionTensorIds.delete(e),this.activeSessionId=void 0}}async createMLContext(e){if(e instanceof GPUDevice){let r=this.mlContextCache.findIndex(n=>n.gpuDevice===e);if(r!==-1)return this.mlContextCache[r].mlContext;{let n=await navigator.ml.createContext(e);return this.mlContextCache.push({gpuDevice:e,mlContext:n}),n}}else if(e===void 0){let r=this.mlContextCache.findIndex(n=>n.options===void 0&&n.gpuDevice===void 0);if(r!==-1)return this.mlContextCache[r].mlContext;{let n=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:n}),n}}let t=this.mlContextCache.findIndex(r=>Qh(r.options,e));if(t!==-1)return this.mlContextCache[t].mlContext;{let r=await navigator.ml.createContext(e);return this.mlContextCache.push({options:e,mlContext:r}),r}}registerMLContext(e,t){this.mlContextBySessionId.set(e,t);let r=this.sessionIdsByMLContext.get(t);r||(r=new Set,this.sessionIdsByMLContext.set(t,r)),r.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 r=this.sessionIdsByMLContext.get(t);if(r.delete(e),r.size===0){this.sessionIdsByMLContext.delete(t);let n=this.mlContextCache.findIndex(s=>s.mlContext===t);n!==-1&&this.mlContextCache.splice(n,1)}}getMLContext(e){return this.mlContextBySessionId.get(e)}getMLOpSupportLimits(e){return this.mlOpSupportLimitsBySessionId.get(e)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(e){ut("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e)}async ensureTensor(e,t,r,n,s){let a=Wn.get(r);if(!a)throw new Error(`Unsupported ONNX data type: ${r}`);return this.tensorManager.ensureTensor(e??this.currentSessionId,t,a,n,s)}async createTemporaryTensor(e,t,r){ut("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${t}, shape: ${r}}`);let n=Wn.get(t);if(!n)throw new Error(`Unsupported ONNX data type: ${t}`);let s=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(e,s,n,r,!1);let a=this.temporarySessionTensorIds.get(e);return a?a.push(s):this.temporarySessionTensorIds.set(e,[s]),s}uploadTensor(e,t){if(!Le().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");ut("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 r=await this.tensorManager.download(e);return P_(r,t)}}registerMLTensor(e,t,r,n){let s=Wn.get(r);if(!s)throw new Error(`Unsupported ONNX data type: ${r}`);let a=this.tensorManager.registerTensor(e,t,s,n);return ut("verbose",()=>`[WebNN] registerMLTensor {tensor: ${t}, dataType: ${s}, dimensions: ${n}} -> {tensorId: ${a}}`),a}registerGraphInput(e){this.temporaryGraphInputs.push(e)}registerGraphOutput(e){this.temporaryGraphOutputs.push(e)}isGraphInput(e,t){let r=this.sessionGraphInputs.get(e);return r?r.includes(t):!1}isGraphOutput(e,t){let r=this.sessionGraphOutputs.get(e);return r?r.includes(t):!1}isGraphInputOutputTypeSupported(e,t,r=!0){let n=Wn.get(zr(t)),s=this.mlOpSupportLimitsBySessionId.get(e);return typeof n>"u"?!1:r?!!s?.input.dataTypes.includes(n):!!s?.output.dataTypes.includes(n)}flush(){}}}),Xh,bi,Mi,fr,Yh,Ao,Hs,xi,Ti,So,ki,Ei,Ci,D_=ge(()=>{"use strict";Wr(),_0(),p0(),vn(),jr(),gi(),S_(),Xh=(e,t)=>{Le()._OrtInit(e,t)!==0&&xe("Can't initialize onnxruntime.")},bi=async e=>{Xh(e.wasm.numThreads,qs(e.logLevel))},Mi=async(e,t)=>{Le().asyncInit?.();let r=e.webgpu.adapter;if(t==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(r){if(typeof r.limits!="object"||typeof r.features!="object"||typeof r.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let n=e.webgpu.powerPreference;if(n!==void 0&&n!=="low-power"&&n!=="high-performance")throw new Error(`Invalid powerPreference setting: "${n}"`);let s=e.webgpu.forceFallbackAdapter;if(s!==void 0&&typeof s!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${s}"`);if(r=await navigator.gpu.requestAdapter({powerPreference:n,forceFallbackAdapter:s}),!r)throw new 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 new Error("WebNN is not supported in current environment");if(t==="webgpu"&&Le().webgpuInit(n=>{e.webgpu.device=n}),t==="webnn"){let n=new(w0(),Us(O_)).WebNNBackend(e);Le().webnnInit([n,()=>n.reserveTensorId(),s=>n.releaseTensorId(s),async(s,a,o,i,l)=>n.ensureTensor(s,a,o,i,l),(s,a)=>{n.uploadTensor(s,a)},async(s,a)=>n.downloadTensor(s,a),(s,a)=>n.registerMLContext(s,a),!!e.trace])}},fr=new Map,Yh=e=>{let t=Le(),r=t.stackSave();try{let n=t.PTR_SIZE,s=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,s,s+n)!==0&&xe("Can't get session input/output count.");let a=n===4?"i32":"i64";return[Number(t.getValue(s,a)),Number(t.getValue(s+n,a))]}finally{t.stackRestore(r)}},Ao=(e,t)=>{let r=Le(),n=r.stackSave(),s=0;try{let a=r.PTR_SIZE,o=r.stackAlloc(2*a);r._OrtGetInputOutputMetadata(e,t,o,o+a)!==0&&xe("Can't get session input/output metadata.");let i=Number(r.getValue(o,"*"));s=Number(r.getValue(o+a,"*"));let l=r.HEAP32[s/4];if(l===0)return[i,0];let u=r.HEAPU32[s/4+1],h=[];for(let f=0;f<u;f++){let _=Number(r.getValue(s+8+f*a,"*"));h.push(_!==0?r.UTF8ToString(_):Number(r.getValue(s+8+(f+u)*a,"*")))}return[i,l,h]}finally{r.stackRestore(n),s!==0&&r._OrtFree(s)}},Hs=e=>{let t=Le(),r=t._malloc(e.byteLength);if(r===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,r),[r,e.byteLength]},xi=async(e,t)=>{let r,n,s=Le();Array.isArray(e)?[r,n]=e:e.buffer===s.HEAPU8.buffer?[r,n]=[e.byteOffset,e.byteLength]:[r,n]=Hs(e);let a=0,o=0,i=0,l=[],u=[],h=[];try{if([o,l]=await A_(t),t?.externalData&&s.mountExternalData){let E=[];for(let F of t.externalData){let z=typeof F=="string"?F:F.path,b=typeof F=="string"?F:F.data;E.push(yi(b).then(V=>{s.mountExternalData(z,V)}))}await Promise.all(E)}for(let E of t?.executionProviders??[])if((typeof E=="string"?E:E.name)==="webnn"){if(s.shouldTransferToMLTensor=!1,typeof E!="string"){let F=E,z=F?.context,b=F?.gpuDevice,V=F?.deviceType,R=F?.powerPreference;z?s.currentContext=z:b?s.currentContext=await s.webnnCreateMLContext(b):s.currentContext=await s.webnnCreateMLContext({deviceType:V,powerPreference:R})}else s.currentContext=await s.webnnCreateMLContext();break}a=await s._OrtCreateSession(r,n,o),s.webgpuOnCreateSession?.(a),a===0&&xe("Can't create a session."),s.jsepOnCreateSession?.(),s.currentContext&&(s.webnnRegisterMLContext(a,s.currentContext),s.currentContext=void 0,s.shouldTransferToMLTensor=!0);let[f,_]=Yh(a),g=!!t?.enableGraphCapture,w=[],v=[],M=[],x=[],k=[];for(let E=0;E<f;E++){let[F,z,b]=Ao(a,E);F===0&&xe("Can't get an input name."),u.push(F);let V=s.UTF8ToString(F);w.push(V),M.push(z===0?{name:V,isTensor:!1}:{name:V,isTensor:!0,type:zs(z),shape:b})}for(let E=0;E<_;E++){let[F,z,b]=Ao(a,E+f);F===0&&xe("Can't get an output name."),h.push(F);let V=s.UTF8ToString(F);v.push(V),x.push(z===0?{name:V,isTensor:!1}:{name:V,isTensor:!0,type:zs(z),shape:b});{if(g&&t?.preferredOutputLocation===void 0){k.push("gpu-buffer");continue}let R=typeof t?.preferredOutputLocation=="string"?t.preferredOutputLocation:t?.preferredOutputLocation?.[V]??"cpu",H=s.webnnIsGraphOutput;if(R==="cpu"&&H&&H(a,V)){k.push("ml-tensor-cpu-output");continue}if(R!=="cpu"&&R!=="cpu-pinned"&&R!=="gpu-buffer"&&R!=="ml-tensor")throw new Error(`Not supported preferred output location: ${R}.`);if(g&&R!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${R}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);k.push(R)}}let C=null;return k.some(E=>E==="gpu-buffer"||E==="ml-tensor"||E==="ml-tensor-cpu-output")&&(i=s._OrtCreateBinding(a),i===0&&xe("Can't create IO binding."),C={handle:i,outputPreferredLocations:k,outputPreferredLocationsEncoded:k.map(E=>E==="ml-tensor-cpu-output"?"ml-tensor":E).map(E=>Ho(E))}),fr.set(a,[a,u,h,C,g,!1]),[a,w,v,M,x]}catch(f){throw u.forEach(_=>s._OrtFree(_)),h.forEach(_=>s._OrtFree(_)),i!==0&&s._OrtReleaseBinding(i)!==0&&xe("Can't release IO binding."),a!==0&&s._OrtReleaseSession(a)!==0&&xe("Can't release session."),f}finally{s._free(r),o!==0&&s._OrtReleaseSessionOptions(o)!==0&&xe("Can't release session options."),l.forEach(f=>s._free(f)),s.unmountExternalData?.()}},Ti=e=>{let t=Le(),r=fr.get(e);if(!r)throw new Error(`cannot release session. invalid session id: ${e}`);let[n,s,a,o,i]=r;o&&(i&&t._OrtClearBoundOutputs(o.handle)!==0&&xe("Can't clear bound outputs."),t._OrtReleaseBinding(o.handle)!==0&&xe("Can't release IO binding.")),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),s.forEach(l=>t._OrtFree(l)),a.forEach(l=>t._OrtFree(l)),t._OrtReleaseSession(n)!==0&&xe("Can't release session."),fr.delete(e)},So=async(e,t,r,n,s,a,o=!1)=>{if(!e){t.push(0);return}let i=Le(),l=i.PTR_SIZE,u=e[0],h=e[1],f=e[3],_=f,g,w;if(u==="string"&&(f==="gpu-buffer"||f==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(o&&f!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(f==="gpu-buffer"){let x=e[2].gpuBuffer;w=ln(zr(u),h);{let k=i.webgpuRegisterBuffer;if(!k)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');g=k(x,n)}}else if(f==="ml-tensor"){let x=e[2].mlTensor;w=ln(zr(u),h);let k=i.webnnRegisterMLTensor;if(!k)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');g=k(n,x,zr(u),h)}else{let x=e[2];if(Array.isArray(x)){w=l*x.length,g=i._malloc(w),r.push(g);for(let k=0;k<x.length;k++){if(typeof x[k]!="string")throw new TypeError(`tensor data at index ${k} is not a string`);i.setValue(g+k*l,pt(x[k],r),"*")}}else{let k=i.webnnIsGraphInput,C=i.webnnIsGraphOutput;if(u!=="string"&&k&&C){let E=i.UTF8ToString(s);if(k(n,E)||C(n,E)){let F=zr(u);w=ln(F,h),_="ml-tensor";let z=i.webnnCreateTemporaryTensor,b=i.webnnUploadTensor;if(!z||!b)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let V=await z(n,F,h);b(V,new Uint8Array(x.buffer,x.byteOffset,x.byteLength)),g=V}else w=x.byteLength,g=i._malloc(w),r.push(g),i.HEAPU8.set(new Uint8Array(x.buffer,x.byteOffset,w),g)}else w=x.byteLength,g=i._malloc(w),r.push(g),i.HEAPU8.set(new Uint8Array(x.buffer,x.byteOffset,w),g)}}let v=i.stackSave(),M=i.stackAlloc(4*h.length);try{h.forEach((k,C)=>i.setValue(M+C*l,k,l===4?"i32":"i64"));let x=i._OrtCreateTensor(zr(u),g,w,M,h.length,Ho(_));x===0&&xe(`Can't create tensor for input/output. session=${n}, index=${a}.`),t.push(x)}finally{i.stackRestore(v)}},ki=async(e,t,r,n,s,a)=>{let o=Le(),i=o.PTR_SIZE,l=fr.get(e);if(!l)throw new Error(`cannot run inference. invalid session id: ${e}`);let u=l[0],h=l[1],f=l[2],_=l[3],g=l[4],w=l[5],v=t.length,M=n.length,x=0,k=[],C=[],E=[],F=[],z=[],b=o.stackSave(),V=o.stackAlloc(v*i),R=o.stackAlloc(v*i),H=o.stackAlloc(M*i),J=o.stackAlloc(M*i);try{[x,k]=C_(a),br("wasm prepareInputOutputTensor");for(let G=0;G<v;G++)await So(r[G],C,F,e,h[t[G]],t[G],g);for(let G=0;G<M;G++)await So(s[G],E,F,e,f[n[G]],v+n[G],g);Mr("wasm prepareInputOutputTensor");for(let G=0;G<v;G++)o.setValue(V+G*i,C[G],"*"),o.setValue(R+G*i,h[t[G]],"*");for(let G=0;G<M;G++)o.setValue(H+G*i,E[G],"*"),o.setValue(J+G*i,f[n[G]],"*");if(_&&!w){let{handle:G,outputPreferredLocations:Q,outputPreferredLocationsEncoded:ce}=_;if(h.length!==v)throw new Error(`input count from feeds (${v}) is expected to be always equal to model's input count (${h.length}).`);br("wasm bindInputsOutputs");for(let Z=0;Z<v;Z++){let ne=t[Z];await o._OrtBindInput(G,h[ne],C[Z])!==0&&xe(`Can't bind input[${Z}] for session=${e}.`)}for(let Z=0;Z<M;Z++){let ne=n[Z];s[Z]?.[3]?(z.push(E[Z]),o._OrtBindOutput(G,f[ne],E[Z],0)!==0&&xe(`Can't bind pre-allocated output[${Z}] for session=${e}.`)):o._OrtBindOutput(G,f[ne],0,ce[ne])!==0&&xe(`Can't bind output[${Z}] to ${Q[Z]} for session=${e}.`)}Mr("wasm bindInputsOutputs"),fr.set(e,[u,h,f,_,g,!0])}o.jsepOnRunStart?.(u),o.webnnOnRunStart?.(u);let X;_?X=await o._OrtRunWithBinding(u,_.handle,M,H,x):X=await o._OrtRun(u,R,V,v,J,M,H,x),X!==0&&xe("failed to call OrtRun().");let D=[],I=[];br("wasm ProcessOutputTensor");for(let G=0;G<M;G++){let Q=Number(o.getValue(H+G*i,"*"));if(Q===E[G]||z.includes(E[G])){D.push(s[G]),Q!==E[G]&&o._OrtReleaseTensor(Q)!==0&&xe("Can't release tensor.");continue}let ce=o.stackSave(),Z=o.stackAlloc(4*i),ne=!1,L,O=0;try{o._OrtGetTensorData(Q,Z,Z+i,Z+2*i,Z+3*i)!==0&&xe(`Can't access output tensor data on index ${G}.`);let $=i===4?"i32":"i64",se=Number(o.getValue(Z,$));O=o.getValue(Z+i,"*");let ae=o.getValue(Z+i*2,"*"),We=Number(o.getValue(Z+i*3,$)),Te=[];for(let Fe=0;Fe<We;Fe++)Te.push(Number(o.getValue(ae+Fe*i,$)));o._OrtFree(ae)!==0&&xe("Can't free memory for tensor dims.");let ke=Te.reduce((Fe,we)=>Fe*we,1);L=zs(se);let $e=_?.outputPreferredLocations[n[G]];if(L==="string"){if($e==="gpu-buffer"||$e==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Fe=[];for(let we=0;we<ke;we++){let st=o.getValue(O+we*i,"*"),be=o.getValue(O+(we+1)*i,"*"),Me=we===ke-1?void 0:be-st;Fe.push(o.UTF8ToString(st,Me))}D.push([L,Te,Fe,"cpu"])}else if($e==="gpu-buffer"&&ke>0){let Fe=o.webgpuGetBuffer;if(!Fe)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let we=Fe(O),st=ln(se,ke);if(st===void 0||!wi(L))throw new Error(`Unsupported data type: ${L}`);ne=!0;{o.webgpuRegisterBuffer(we,e,O);let be=o.webgpuCreateDownloader(we,st,e);D.push([L,Te,{gpuBuffer:we,download:async()=>{let Me=await be();return new(Xn(L))(Me)},dispose:()=>{o._OrtReleaseTensor(Q)!==0&&xe("Can't release tensor.")}},"gpu-buffer"])}}else if($e==="ml-tensor"&&ke>0){let Fe=o.webnnEnsureTensor,we=o.webnnIsGraphInputOutputTypeSupported;if(!Fe||!we)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(ln(se,ke)===void 0||!vi(L))throw new Error(`Unsupported data type: ${L}`);if(!we(e,L,!1))throw new Error(`preferredLocation "ml-tensor" for ${L} output is not supported by current WebNN Context.`);let st=await Fe(e,O,se,Te,!1);ne=!0,D.push([L,Te,{mlTensor:st,download:o.webnnCreateMLTensorDownloader(O,L),dispose:()=>{o.webnnReleaseTensorId(O),o._OrtReleaseTensor(Q)}},"ml-tensor"])}else if($e==="ml-tensor-cpu-output"&&ke>0){let Fe=o.webnnCreateMLTensorDownloader(O,L)(),we=D.length;ne=!0,I.push((async()=>{let st=[we,await Fe];return o.webnnReleaseTensorId(O),o._OrtReleaseTensor(Q),st})()),D.push([L,Te,[],"cpu"])}else{let Fe=Xn(L),we=new Fe(ke);new Uint8Array(we.buffer,we.byteOffset,we.byteLength).set(o.HEAPU8.subarray(O,O+we.byteLength)),D.push([L,Te,we,"cpu"])}}finally{o.stackRestore(ce),L==="string"&&O&&o._free(O),ne||o._OrtReleaseTensor(Q)}}_&&!g&&(o._OrtClearBoundOutputs(_.handle)!==0&&xe("Can't clear bound outputs."),fr.set(e,[u,h,f,_,g,!1]));for(let[G,Q]of await Promise.all(I))D[G][2]=Q;return Mr("wasm ProcessOutputTensor"),D}finally{o.webnnOnRunEnd?.(u),o.stackRestore(b),r.forEach(X=>{X&&X[3]==="gpu-buffer"&&o.webgpuUnregisterBuffer(X[2].gpuBuffer)}),s.forEach(X=>{X&&X[3]==="gpu-buffer"&&o.webgpuUnregisterBuffer(X[2].gpuBuffer)}),C.forEach(X=>o._OrtReleaseTensor(X)),E.forEach(X=>o._OrtReleaseTensor(X)),F.forEach(X=>o._free(X)),x!==0&&o._OrtReleaseRunOptions(x),k.forEach(X=>o._free(X))}},Ei=e=>{let t=Le(),r=fr.get(e);if(!r)throw new Error("invalid session id");let n=r[0],s=t._OrtEndProfiling(n);s===0&&xe("Can't get an profile file name."),t._OrtFree(s)},Ci=e=>{let t=[];for(let r of e){let n=r[2];!Array.isArray(n)&&"buffer"in n&&t.push(n.buffer)}return t}}),_r,bt,rn,jn,qn,Ss,Po,Ps,Ir,Lr,Jh,B_,z_,R_,$_,G_,V_,U_,W_=ge(()=>{"use strict";Wr(),D_(),jr(),pi(),_r=()=>!!Be.wasm.proxy&&typeof document<"u",rn=!1,jn=!1,qn=!1,Ps=new Map,Ir=(e,t)=>{let r=Ps.get(e);r?r.push(t):Ps.set(e,[t])},Lr=()=>{if(rn||!jn||qn||!bt)throw new Error("worker not ready")},Jh=e=>{switch(e.data.type){case"init-wasm":rn=!1,e.data.err?(qn=!0,Po[1](e.data.err)):(jn=!0,Po[0]()),Ss&&(URL.revokeObjectURL(Ss),Ss=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let t=Ps.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}default:}},B_=async()=>{if(!jn){if(rn)throw new Error("multiple calls to 'initWasm()' detected.");if(qn)throw new Error("previous call to 'initWasm()' failed.");if(rn=!0,_r())return new Promise((e,t)=>{bt?.terminate(),k_().then(([r,n])=>{try{bt=n,bt.onerror=a=>t(a),bt.onmessage=Jh,Po=[e,t];let s={type:"init-wasm",in:Be};!s.in.wasm.wasmPaths&&(r||qo)&&(s.in.wasm.wasmPaths={wasm:new URL(""+new URL("ort-wasm-simd-threaded.asyncify-CxOG5pUO.wasm",import.meta.url).href,import.meta.url).href}),bt.postMessage(s),Ss=r}catch(s){t(s)}},t)});try{await mi(Be.wasm),await bi(Be),jn=!0}catch(e){throw qn=!0,e}finally{rn=!1}}},z_=async e=>{if(_r())return Lr(),new Promise((t,r)=>{Ir("init-ep",[t,r]);let n={type:"init-ep",in:{epName:e,env:Be}};bt.postMessage(n)});await Mi(Be,e)},R_=async e=>_r()?(Lr(),new Promise((t,r)=>{Ir("copy-from",[t,r]);let n={type:"copy-from",in:{buffer:e}};bt.postMessage(n,[e.buffer])})):Hs(e),$_=async(e,t)=>{if(_r()){if(t?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Lr(),new Promise((r,n)=>{Ir("create",[r,n]);let s={type:"create",in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),bt.postMessage(s,a)})}else return xi(e,t)},G_=async e=>{if(_r())return Lr(),new Promise((t,r)=>{Ir("release",[t,r]);let n={type:"release",in:e};bt.postMessage(n)});Ti(e)},V_=async(e,t,r,n,s,a)=>{if(_r()){if(r.some(o=>o[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(s.some(o=>o))throw new Error("pre-allocated output tensor is not supported for proxy.");return Lr(),new Promise((o,i)=>{Ir("run",[o,i]);let l=r,u={type:"run",in:{sessionId:e,inputIndices:t,inputs:l,outputIndices:n,options:a}};bt.postMessage(u,Ci(l))})}else return ki(e,t,r,n,s,a)},U_=async e=>{if(_r())return Lr(),new Promise((t,r)=>{Ir("end-profiling",[t,r]);let n={type:"end-profiling",in:e};bt.postMessage(n)});Ei(e)}}),Fo,Kh,j_,v0=ge(()=>{"use strict";Wr(),W_(),vn(),_i(),S_(),Fo=(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 new Error(`invalid data location: ${e.location} for ${t()}`)}},Kh=e=>{switch(e[3]){case"cpu":return new Pt(e[0],e[2],e[1]);case"gpu-buffer":{let t=e[0];if(!wi(t))throw new Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:r,download:n,dispose:s}=e[2];return Pt.fromGpuBuffer(r,{dataType:t,dims:e[1],download:n,dispose:s})}case"ml-tensor":{let t=e[0];if(!vi(t))throw new Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:r,download:n,dispose:s}=e[2];return Pt.fromMLTensor(r,{dataType:t,dims:e[1],download:n,dispose:s})}default:throw new Error(`invalid data location: ${e[3]}`)}},j_=class{async fetchModelAndCopyToWasmMemory(e){return R_(await yi(e))}async loadModel(e,t){Vr();let r;typeof e=="string"?r=await this.fetchModelAndCopyToWasmMemory(e):r=e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await $_(r,t),Ur()}async dispose(){return G_(this.sessionId)}async run(e,t,r){Vr();let n=[],s=[];Object.entries(e).forEach(f=>{let _=f[0],g=f[1],w=this.inputNames.indexOf(_);if(w===-1)throw new Error(`invalid input '${_}'`);n.push(g),s.push(w)});let a=[],o=[];Object.entries(t).forEach(f=>{let _=f[0],g=f[1],w=this.outputNames.indexOf(_);if(w===-1)throw new Error(`invalid output '${_}'`);a.push(g),o.push(w)});let i=n.map((f,_)=>Fo(f,()=>`input "${this.inputNames[s[_]]}"`)),l=a.map((f,_)=>f?Fo(f,()=>`output "${this.outputNames[o[_]]}"`):null),u=await V_(this.sessionId,s,i,o,l,r),h={};for(let f=0;f<u.length;f++)h[this.outputNames[o[f]]]=a[f]??Kh(u[f]);return Ur(),h}startProfiling(){}endProfiling(){U_(this.sessionId)}}}),q_={};Zn(q_,{OnnxruntimeWebAssemblyBackend:()=>Xo,initializeFlags:()=>Qo,wasmBackend:()=>H_});var Qo,Xo,H_,y0=ge(()=>{"use strict";Wr(),W_(),v0(),Qo=()=>{(typeof Be.wasm.initTimeout!="number"||Be.wasm.initTimeout<0)&&(Be.wasm.initTimeout=0);let e=Be.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.`),Be.wasm.simd=!1),typeof Be.wasm.proxy!="boolean"&&(Be.wasm.proxy=!1),typeof Be.wasm.trace!="boolean"&&(Be.wasm.trace=!1),typeof Be.wasm.numThreads!="number"||!Number.isInteger(Be.wasm.numThreads)||Be.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)Be.wasm.numThreads=1;else{let t=typeof navigator>"u"?Jb("node:os").cpus().length:navigator.hardwareConcurrency;Be.wasm.numThreads=Math.min(4,Math.ceil((t||1)/2))}},Xo=class{async init(e){Qo(),await B_(),await z_(e)}async createInferenceSessionHandler(e,t){let r=new j_;return await r.loadModel(e,t),r}},H_=new Xo});Wr();Wr();Wr();var b0="1.31.0-dev.20260914-8d85527a0",M0=v_;{let e=(y0(),Us(q_)).wasmBackend;Gr("webgpu",e,5),Gr("webnn",e,5),Gr("cpu",e,10),Gr("wasm",e,10)}Object.defineProperty(Be.versions,"web",{value:b0,enumerable:!0});const x0=Object.freeze(Object.defineProperty({__proto__:null,get InferenceSession(){return fi},get TRACE(){return Ws},get TRACE_EVENT_BEGIN(){return br},get TRACE_EVENT_END(){return Mr},get TRACE_FUNC_BEGIN(){return Vr},get TRACE_FUNC_END(){return Ur},get Tensor(){return Pt},default:M0,get env(){return Be},get registerBackend(){return Gr}},Symbol.toStringTag,{value:"Module"})),T0=(e,t)=>{const r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=e.dims[3],r.height=e.dims[2];const n=r.getContext("2d");if(n!=null){let s,a;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(s=e.dims[2],a=e.dims[3]):(s=e.dims[3],a=e.dims[2]);const o=t?.format!==void 0?t.format:"RGB",i=t?.norm;let l,u;i===void 0||i.mean===void 0?l=[255,255,255,255]:typeof i.mean=="number"?l=[i.mean,i.mean,i.mean,i.mean]:(l=[i.mean[0],i.mean[1],i.mean[2],0],i.mean[3]!==void 0&&(l[3]=i.mean[3])),i===void 0||i.bias===void 0?u=[0,0,0,0]:typeof i.bias=="number"?u=[i.bias,i.bias,i.bias,i.bias]:(u=[i.bias[0],i.bias[1],i.bias[2],0],i.bias[3]!==void 0&&(u[3]=i.bias[3]));const h=a*s;let f=0,_=h,g=h*2,w=-1;o==="RGBA"?(f=0,_=h,g=h*2,w=h*3):o==="RGB"?(f=0,_=h,g=h*2):o==="RBG"&&(f=0,g=h,_=h*2);for(let v=0;v<a;v++)for(let M=0;M<s;M++){const x=(e.data[f++]-u[0])*l[0],k=(e.data[_++]-u[1])*l[1],C=(e.data[g++]-u[2])*l[2],E=w===-1?255:(e.data[w++]-u[3])*l[3];n.fillStyle="rgba("+x+","+k+","+C+","+E+")",n.fillRect(M,v,1,1)}if("toDataURL"in r)return r.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},k0=(e,t)=>{const r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let n;if(r!=null){let s,a,o;t?.tensorLayout!==void 0&&t.tensorLayout==="NHWC"?(s=e.dims[2],a=e.dims[1],o=e.dims[3]):(s=e.dims[3],a=e.dims[2],o=e.dims[1]);const i=t!==void 0&&t.format!==void 0?t.format:"RGB",l=t?.norm;let u,h;l===void 0||l.mean===void 0?u=[255,255,255,255]:typeof l.mean=="number"?u=[l.mean,l.mean,l.mean,l.mean]:(u=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(u[3]=l.mean[3])),l===void 0||l.bias===void 0?h=[0,0,0,0]:typeof l.bias=="number"?h=[l.bias,l.bias,l.bias,l.bias]:(h=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(h[3]=l.bias[3]));const f=a*s;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!=="RGBA"||o===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const _=4;let g=0,w=1,v=2,M=3,x=0,k=f,C=f*2,E=-1;i==="RGBA"?(x=0,k=f,C=f*2,E=f*3):i==="RGB"?(x=0,k=f,C=f*2):i==="RBG"&&(x=0,C=f,k=f*2),n=r.createImageData(s,a);for(let F=0;F<a*s;g+=_,w+=_,v+=_,M+=_,F++)n.data[g]=(e.data[x++]-h[0])*u[0],n.data[w]=(e.data[k++]-h[1])*u[1],n.data[v]=(e.data[C++]-h[2])*u[2],n.data[M]=E===-1?255:(e.data[E++]-h[3])*u[3]}else throw new Error("Can not access image data");return n},Io=(e,t)=>{if(e===void 0)throw new Error("Image buffer must be defined");if(t.height===void 0||t.width===void 0)throw new Error("Image height and width must be defined");if(t.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");const{height:r,width:n}=t,s=t.norm??{mean:255,bias:0};let a,o;typeof s.mean=="number"?a=[s.mean,s.mean,s.mean,s.mean]:a=[s.mean[0],s.mean[1],s.mean[2],s.mean[3]??255],typeof s.bias=="number"?o=[s.bias,s.bias,s.bias,s.bias]:o=[s.bias[0],s.bias[1],s.bias[2],s.bias[3]??0];const i=t.format!==void 0?t.format:"RGBA",l=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:"RGB",u=r*n,h=l==="RGBA"?new Float32Array(u*4):new Float32Array(u*3);let f=4,_=0,g=1,w=2,v=3,M=0,x=u,k=u*2,C=-1;i==="RGB"&&(f=3,_=0,g=1,w=2,v=-1),l==="RGBA"?C=u*3:l==="RBG"?(M=0,k=u,x=u*2):l==="BGR"&&(k=0,x=u,M=u*2);for(let F=0;F<u;F++,_+=f,w+=f,g+=f,v+=f)h[M++]=(e[_]+o[0])/a[0],h[x++]=(e[g]+o[1])/a[1],h[k++]=(e[w]+o[2])/a[2],C!==-1&&v!==-1&&(h[C++]=(e[v]+o[3])/a[3]);return l==="RGBA"?new Tt("float32",h,[1,4,r,n]):new Tt("float32",h,[1,3,r,n])},E0=async(e,t)=>{const r=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,n=typeof ImageData<"u"&&e instanceof ImageData,s=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,a=typeof e=="string";let o,i=t??{};const l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=h=>typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement||h instanceof OffscreenCanvas?h.getContext("2d"):null;if(r){const h=l();h.width=e.width,h.height=e.height;const f=u(h);if(f!=null){let _=e.height,g=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(_=t.resizedHeight,g=t.resizedWidth),t!==void 0){if(i=t,t.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");i.tensorFormat="RGBA",i.height=_,i.width=g}else i.tensorFormat="RGBA",i.height=_,i.width=g;f.drawImage(e,0,0),o=f.getImageData(0,0,g,_).data}else throw new Error("Can not access image data")}else if(n){let h,f;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(h=t.resizedHeight,f=t.resizedWidth):(h=e.height,f=e.width),t!==void 0&&(i=t),i.format="RGBA",i.height=h,i.width=f,t!==void 0){const _=l();_.width=f,_.height=h;const g=u(_);if(g!=null)g.putImageData(e,0,0),o=g.getImageData(0,0,f,h).data;else throw new Error("Can not access image data")}else o=e.data}else if(s){if(t===void 0)throw new Error("Please provide image config with format for Imagebitmap");const h=l();h.width=e.width,h.height=e.height;const f=u(h);if(f!=null){const _=e.height,g=e.width;return f.drawImage(e,0,0,g,_),o=f.getImageData(0,0,g,_).data,i.height=_,i.width=g,Io(o,i)}else throw new Error("Can not access image data")}else{if(a)return new Promise((h,f)=>{const _=l(),g=u(_);if(!e||!g)return f();const w=new Image;w.crossOrigin="Anonymous",w.src=e,w.onload=()=>{_.width=w.width,_.height=w.height,g.drawImage(w,0,0,_.width,_.height);const v=g.getImageData(0,0,_.width,_.height);i.height=_.height,i.width=_.width,h(Io(v.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(o!==void 0)return Io(o,i);throw new Error("Input data provided is not supported - aborted tensor creation")},C0=(e,t)=>{const{width:r,height:n,download:s,dispose:a}=t,o=[1,n,r,4];return new Tt({location:"texture",type:"float32",texture:e,dims:o,download:s,dispose:a})},A0=(e,t)=>{const{dataType:r,dims:n,download:s,dispose:a}=t;return new Tt({location:"gpu-buffer",type:r??"float32",gpuBuffer:e,dims:n,download:s,dispose:a})},S0=(e,t)=>{const{dataType:r,dims:n,download:s,dispose:a}=t;return new Tt({location:"ml-tensor",type:r??"float32",mlTensor:e,dims:n,download:s,dispose:a})},P0=(e,t,r)=>new Tt({location:"cpu-pinned",type:e,data:t,dims:r??[t.length]}),un=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Rs=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let Zh=!1;const F0=()=>{if(!Zh){Zh=!0;const e=typeof BigInt64Array<"u"&&BigInt64Array.from,t=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,n=typeof r<"u"&&r.from;e&&(un.set("int64",BigInt64Array),Rs.set(BigInt64Array,"int64")),t&&(un.set("uint64",BigUint64Array),Rs.set(BigUint64Array,"uint64")),n?(un.set("float16",r),Rs.set(r,"float16")):un.set("float16",Uint16Array)}},I0=e=>{let t=1;for(let r=0;r<e.length;r++){const n=e[r];if(typeof n!="number"||!Number.isSafeInteger(n))throw new TypeError(`dims[${r}] must be an integer, got: ${n}`);if(n<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${n}`);t*=n}return t},L0=(e,t)=>{switch(e.location){case"cpu":return new Tt(e.type,e.data,t);case"cpu-pinned":return new Tt({location:"cpu-pinned",data:e.data,type:e.type,dims:t});case"texture":return new Tt({location:"texture",texture:e.texture,type:e.type,dims:t});case"gpu-buffer":return new Tt({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case"ml-tensor":return new Tt({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:t});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}};let Tt=class{constructor(t,r,n){F0();let s,a;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,s=t.type,a=t.dims,t.location){case"cpu-pinned":{const i=un.get(s);if(!i)throw new TypeError(`unsupported type "${s}" to create tensor from pinned buffer`);if(!(t.data instanceof i))throw new TypeError(`buffer should be of type ${i.name}`);this.cpuData=t.data;break}case"texture":{if(s!=="float32")throw new TypeError(`unsupported type "${s}" to create tensor from texture`);this.gpuTextureData=t.texture,this.downloader=t.download,this.disposer=t.dispose;break}case"gpu-buffer":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint8"&&s!=="bool"&&s!=="uint4"&&s!=="int4")throw new TypeError(`unsupported type "${s}" to create tensor from gpu buffer`);this.gpuBufferData=t.gpuBuffer,this.downloader=t.download,this.disposer=t.dispose;break}case"ml-tensor":{if(s!=="float32"&&s!=="float16"&&s!=="int32"&&s!=="int64"&&s!=="uint32"&&s!=="uint64"&&s!=="int8"&&s!=="uint8"&&s!=="bool"&&s!=="uint4"&&s!=="int4")throw new TypeError(`unsupported type "${s}" to create tensor from MLTensor`);this.mlTensorData=t.mlTensor,this.downloader=t.download,this.disposer=t.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let i,l;if(typeof t=="string")if(s=t,l=n,t==="string"){if(!Array.isArray(r))throw new TypeError("A string tensor's data must be a string array.");i=r}else{const u=un.get(t);if(u===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(r)){if(t==="float16"&&u===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${u.name} as data.`);t==="uint64"||t==="int64"?i=u.from(r,BigInt):i=u.from(r)}else if(r instanceof u)i=r;else if(r instanceof Uint8ClampedArray)if(t==="uint8")i=Uint8Array.from(r);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&r instanceof Uint16Array&&u!==Uint16Array)i=new globalThis.Float16Array(r.buffer,r.byteOffset,r.length);else throw new TypeError(`A ${s} tensor's data must be type of ${u}`)}else if(l=r,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const u=typeof t[0];if(u==="string")s="string",i=t;else if(u==="boolean")s="bool",i=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${u}.`)}else if(t instanceof Uint8ClampedArray)s="uint8",i=Uint8Array.from(t);else{const u=Rs.get(t.constructor);if(u===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);s=u,i=t}if(l===void 0)l=[i.length];else if(!Array.isArray(l))throw new TypeError("A tensor's dims must be a number array");a=l,this.cpuData=i,this.dataLocation="cpu"}const o=I0(a);if(this.cpuData&&o!==this.cpuData.length&&!((s==="uint4"||s==="int4")&&Math.ceil(o/2)===this.cpuData.length))throw new Error(`Tensor's size(${o}) does not match data length(${this.cpuData.length}).`);this.type=s,this.dims=a,this.size=o}static async fromImage(t,r){return E0(t,r)}static fromTexture(t,r){return C0(t,r)}static fromGpuBuffer(t,r){return A0(t,r)}static fromMLTensor(t,r){return S0(t,r)}static fromPinnedBuffer(t,r,n){return P0(t,r,n)}toDataURL(t){return T0(this,t)}toImageData(t){return k0(this,t)}get data(){if(this.ensureValid(),!this.cpuData)throw new 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 new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(t){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 new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;const r=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=r,t&&this.disposer&&(this.disposer(),this.disposer=void 0),r}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(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 new Error("The tensor is disposed.")}reshape(t){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return L0(this,t)}};const O0=Tt;var Lo={},N0=Object.defineProperty,es=(e,t)=>{for(var r in t)N0(e,r,{get:t[r],enumerable:!0})},gt={},jt={},D0={},B0="4.3.0",Ai=typeof self<"u",fn=!J_(gt),Q_=!J_(jt),Qs=Ai&&"caches"in self,z0=typeof globalThis.Deno<"u",la=z0&&Qs&&!fn,X_=typeof process<"u",Y_=X_&&process?.release?.name==="node"&&!la,Si=typeof window<"u"&&typeof window.document<"u",Pi=Ai&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),R0=Si||Pi||la,$0=Y_||typeof navigator<"u"&&"gpu"in navigator,G0=typeof navigator<"u"&&"ml"in navigator,V0=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",U0=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",W0=typeof ServiceWorkerGlobalScope<"u"&&Ai&&self instanceof ServiceWorkerGlobalScope,j0=()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgent;if(!((navigator.vendor||"").indexOf("Apple")>-1&&!e.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!e.includes("Chrome")&&!e.includes("Android")))return!1;const r=e.match(/Version\/(\d+)/);return r?parseInt(r[1],10)<26:!1},q0=j0(),_e=Object.freeze({IS_BROWSER_ENV:Si,IS_WEBWORKER_ENV:Pi,IS_WEB_ENV:R0,IS_SERVICE_WORKER_ENV:W0,IS_DENO_WEB_RUNTIME:la,IS_WEB_CACHE_AVAILABLE:Qs,IS_WEBGPU_AVAILABLE:$0,IS_WEBNN_AVAILABLE:G0,IS_SAFARI_BELOW_26:q0,IS_PROCESS_AVAILABLE:X_,IS_NODE_ENV:Y_,IS_FS_AVAILABLE:fn,IS_PATH_AVAILABLE:Q_,IS_CRYPTO_AVAILABLE:V0,IS_CHROME_AVAILABLE:U0}),Fi=fn&&Q_,Xs="./";if(Fi){const e=import.meta.url;e?Xs=jt.dirname(jt.dirname(D0.fileURLToPath(e))):typeof __dirname<"u"&&(Xs=jt.dirname(__dirname))}var H0=Fi?jt.join(Xs,"/.cache/"):null,ef="/models/",Q0=Fi?jt.join(Xs,ef):ef,X0=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,Ft=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),tf=Ft.WARNING,ve={version:B0,backends:{onnx:{}},get logLevel(){return tf},set logLevel(e){tf=e,ve.backends.onnx?.setLogLevel?.(e)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(Si||Pi||la),localModelPath:Q0,useFS:fn,useBrowserCache:Qs,useFSCache:fn,cacheDir:H0,useCustomCache:!1,customCache:null,useWasmCache:Qs||fn,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:X0};function J_(e){return Object.keys(e).length===0}var wt=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 Rr(e,t){e&&e(t)}var Yo=class extends wt{constructor(e,t){super(),this.callback=e,this.files_loading=t,this.loads=new Map}_call(e){if(e.status==="progress"){this.files_loading[e.file]={loaded:e.loaded,total:e.total};const t=Object.values(this.files_loading).reduce((s,a)=>s+a.loaded,0),r=Object.values(this.files_loading).reduce((s,a)=>s+a.total,0),n=r>0?t/r*100:0;this.callback({status:"progress_total",name:e.name,progress:n,loaded:t,total:r,files:structuredClone(this.files_loading)})}this.callback(e)}};function Y0(e){return Number.isInteger(e)||typeof e=="bigint"}function rf(e){return e==null||e===-1}function nf(e){const t=[];let r=e;for(;Array.isArray(r);)t.push(r.length),r=r[0];return t}function qt(...e){return Array.prototype.concat.apply([],e)}function Ys(e,t){return Math.abs((e+t)%(2*t)-t)}function et(e,t){return Object.assign({},...t.map(r=>{if(e[r]!==void 0)return{[r]:e[r]}}))}function J0(e,t){let r=0;for(const n of e)n===t&&++r;return r}var pe={error(...e){ve.logLevel<=Ft.ERROR&&console.error(...e)},warn(...e){ve.logLevel<=Ft.WARNING&&console.warn(...e)},info(...e){ve.logLevel<=Ft.INFO&&console.log(...e)},debug(...e){ve.logLevel<=Ft.DEBUG&&console.log(...e)},log(...e){this.info(...e)}},K0=class{constructor(e){this.trie=this._build_trie(e)}_build_trie(e){const t=Object.create(null);for(const r of e){let n=t;for(let s=0;s<r.length;++s){const a=r[s];n=n[a]??=Object.create(null)}n.end=r}return t}split(e){const t=[],r=e.length;let n=0,s=0;for(;s<r;){let a=this.trie,o=null,i=s;for(;i<r&&(a=a[e[i]]);)a.end&&(o=a.end),++i;o?(s>n&&t.push(e.slice(n,s)),t.push(o),s+=o.length,n=s):++s}return n<r&&t.push(e.slice(n)),t}},sf=K0,Z0=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}},eM=Z0,K_=(e,t)=>{try{return new RegExp(e,t)}catch(r){if(!(r instanceof SyntaxError))throw r;const n=new Map,s=e.replace(/(\\[pP])\{([^}=]+)\}/g,(a,o,i,l)=>{let u=0;for(let f=l-1;f>=0&&e[f]==="\\";--f)++u;if(u%2===1)return a;let h=n.get(i);if(h===void 0){try{new RegExp(`\\p{${i}}`,"u"),h=i}catch{h=`Script=${i}`}n.set(i,h)}return`${o}{${h}}`});if(s===e)throw r;try{return new RegExp(s,t)}catch{throw r}}},Ii=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"),ca=(e,t=!0)=>{if(e.Regex!==void 0){const r=gM(_M(e.Regex));return K_(r,"gu")}else if(e.String!==void 0){const r=wM(e.String);return new RegExp(t?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",e),null},wn="\\p{Alphabetic}\\p{M}\\p{Nd}\\p{Pc}",Z_=`${wn}\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE`,Ht=`[${Z_}]`,ep=`[^${Z_}]`,tM=`(?:(?<!${Ht})(?=${Ht})|(?<=${Ht})(?!${Ht}))`,rM=`(?:(?<!${Ht})(?!${Ht})|(?<=${Ht})(?=${Ht}))`,nM="(?:(?<![\\s\\S])|(?<=\\n))",sM="(?:(?=\\n)|(?![\\s\\S]))",Yn="0-9A-Fa-f",aM=new Map([["A","(?<![\\s\\S])"],["z","(?![\\s\\S])"],["Z","(?=\\n?(?![\\s\\S]))"],["h",`[${Yn}]`],["H",`[^${Yn}]`],["w",Ht],["W",ep],["d","\\p{Nd}"],["D","\\P{Nd}"],["s","\\p{White_Space}"],["S","\\P{White_Space}"],["b",tM],["B",rM],["a","\\x07"],["e","\\x1B"]]),oM=new Map([["h",Yn],["w",wn],["d","\\p{Nd}"],["D","\\P{Nd}"],["s","\\p{White_Space}"],["S","\\P{White_Space}"],["a","\\x07"],["e","\\x1B"]]),iM=new Map([["W",`[^${wn}]`],["H",`[^${Yn}]`]]),tp=new Map([[`
7
+ `,"\\n"],["\r","\\r"],[" ","\\t"],["\f","\\f"],["\v","\\v"]]),lM=new Map([["alpha","\\p{Alphabetic}"],["alnum","\\p{Alphabetic}\\p{Nd}"],["digit","\\p{Nd}"],["lower","\\p{Lowercase}"],["upper","\\p{Uppercase}"],["space","\\p{White_Space}"],["blank","\\t\\p{Zs}"],["punct","\\p{P}\\p{S}"],["cntrl","\\p{Cc}"],["word",wn],["xdigit",Yn]]),rp="^$\\.*+?()[]{}|/",cM=/^\(\?(?:<[=!]|<[A-Za-z_][A-Za-z0-9_]*>|[:=!>])/,np=/^\\([pPxu])\{([^}]*)\}/,uM=/^\{(\d+(?:,\d*)?|,\d+)\}/,dM=new RegExp("^\\[:(\\^?)(\\p{Alphabetic}+):\\]","u"),hM=/^\[:\^:\]/,fM=/^\[(?:\.[^\]]*\.\]|=[^\]]*=\])/,sp=/^(?:\\x[0-9A-Fa-f]{2}|\\u[0-9A-Fa-f]{4}|\\c[A-Za-z])/,ap=e=>e>="A"&&e<="Z"||e>="a"&&e<="z",Js=(e,t)=>String.fromCodePoint(e.codePointAt(t)),af=e=>{if(!/^[0-9A-Fa-f]{1,8}$/.test(e))return null;const t=Number.parseInt(e,16);if(t>127)return null;const r=String.fromCharCode(t);return ap(r)?`[${r.toLowerCase()}${r.toUpperCase()}]`:null},_M=e=>e.replace(/\[\^\(\\s\|\[([^\]]+)\]\)\]/g,"[^()|\\s$1]"),op="[\\s\\S]",of=256,lf=()=>({fragment:"",alternatives:[],tail:null,contains_complex_set:!1}),Li=e=>{throw new SyntaxError(`Unsupported range with a set-valued character-class operand at index ${e}`)},Ks=(e,t,r,n=!0)=>{e.tail==="range"&&Li(r),e.alternatives.push(t),e.tail="set",e.contains_complex_set=e.contains_complex_set||n},vr=(e,t,r=!1,n=-1)=>{if(r&&e.tail==="range"&&Li(n),e.tail==="range"){e.fragment+=t,e.tail="complete_range";return}e.fragment+=t,e.tail=r?"set":"scalar",e.contains_complex_set=e.contains_complex_set||r},pM=(e,t,r)=>{const n=np.exec(e.slice(t));if(n){const[_,g,w]=n;if(g==="P"&&w==="Word")Ks(r,`[^${wn}]`,t);else{const v=g==="x"?`\\u{${w}}`:g==="p"&&w==="Word"?wn:_;vr(r,v,g==="p"||g==="P",t)}return t+_.length}const s=sp.exec(e.slice(t));if(s)return vr(r,s[0]),t+s[0].length;if(t+1>=e.length)throw new SyntaxError(`Unterminated escape in character class at index ${t}`);const a=Js(e,t+1),o=t+1+a.length,i=tp.get(a);if(i!==void 0)return vr(r,i),o;const l=iM.get(a);if(l!==void 0)return Ks(r,l,t),o;const u=oM.get(a);let h,f=!1;return u!==void 0?(h=u,f=a!=="a"&&a!=="e"):/[A-Za-z0-9]/.test(a)?h=`\\${a}`:rp.includes(a)||a==="-"?h=`\\${a}`:h=a,vr(r,h,f,t),o},ip=e=>e.length===1?e[0]:`(?:(?=(?:${e.join("|")}))${op})`,cf=e=>{const t=e.fragment.length===0?e.alternatives:[`[${e.fragment}]`,...e.alternatives];return ip(t)},mM=e=>{const t=K_(`^(?:${e})$`,"u");let r="";for(let n=0;n<26;++n){const s=String.fromCharCode(65+n),a=String.fromCharCode(97+n),o=t.test(s),i=t.test(a);o!==i&&(r+=o?a:s)}return r},lp=(e,t,r,n=!0,s=1)=>{if(s>of)throw new SyntaxError(`Maximum character-class nesting depth of ${of} exceeded at index ${t}`);let a=t+1;const o=e[a]==="^";o&&++a;const i=a,l=[lf()];let u=l[0],h=!1;for(;a<e.length;){const f=Js(e,a);if(f==="\\"){a=pM(e,a,u);continue}if(f==="]"){if(a===i){vr(u,"\\]"),++a;continue}if(u.tail===null)throw l.length>1?new SyntaxError(`Malformed character-class intersection with an empty operand at index ${a}`):new SyntaxError(`Empty character class at index ${t}`);const _=l.some(k=>k.contains_complex_set);if(o&&l.length>1&&h)throw new SyntaxError(`Unsupported outer-negated character-class intersection with a nested negated class containing a Unicode property, POSIX class, or shorthand at index ${t}`);const g=cf(l[0]);let w=g;if(l.length>1){let k="";for(let C=1;C<l.length;++C)k+=`(?=${cf(l[C])})`;w=`(?:${k}${g})`}const v=l.length===1&&u.alternatives.length===0;let M=u.fragment;if(r&&n){const k=mM(w);k.length>0&&(v?(M+=k,w=`[${M}]`):w=ip([w,`[${k}]`]))}return{atom:o?v?`[^${M}]`:`(?:(?!${w})${op})`:w,end:a+1,negated:o,contains_complex_set:_,contains_nested_negated_complex_set:h}}if(e.startsWith("&&",a)){if(u.tail===null)throw new SyntaxError(`Malformed character-class intersection with an empty operand at index ${a}`);u=lf(),l.push(u),a+=2;continue}if(f==="["){const _=e.slice(a);if(hM.test(_))throw new SyntaxError(`Malformed empty negated POSIX character class at index ${a}`);const g=dM.exec(_);if(g){const[,v,M]=g,x=lM.get(M);if(x===void 0)throw new SyntaxError(`Unsupported POSIX character class "${M}" at index ${a}`);if(r&&v&&(M==="lower"||M==="upper"))throw new SyntaxError(`Unsupported negated POSIX ${M} class inside an inline case-insensitive group`);v?Ks(u,`[^${x}]`,a):vr(u,x,!0,a),a+=g[0].length;continue}if(fM.test(_))throw new SyntaxError(`Unsupported POSIX collating or equivalence bracket expression at index ${a}`);const w=lp(e,a,r,!1,s+1);Ks(u,w.atom,a,w.contains_complex_set),h||=w.contains_nested_negated_complex_set||w.negated&&w.contains_complex_set,a=w.end;continue}if(f==="-"){const _=e[a+1]==="]"||e.startsWith("&&",a+1);u.tail==="set"&&!_&&Li(a),u.tail===null||u.tail==="range"||u.tail==="complete_range"||_?vr(u,"\\-"):(u.fragment+="-",u.tail="range"),++a;continue}vr(u,f==="^"&&u.fragment.length===0?"\\^":f),a+=f.length}throw new SyntaxError(`${l.length>1?"Unterminated character-class intersection":"Unterminated character class"} at index ${t}`)},gM=e=>{let t="",r=-1,n=!1,s=!1;const a=[],o=i=>{r=t.length,t+=i,n=!1};for(let i=0;i<e.length;){const l=Js(e,i);if(l==="\\"){const u=np.exec(e.slice(i));if(u){const[v,M,x]=u;let k=v;if(M==="x"){const C=`\\u{${x}}`;k=s?af(x)??C:C}else x==="Word"&&(k=M==="p"?Ht:ep);o(k),i+=v.length;continue}const h=sp.exec(e.slice(i));if(h){const v=h[0],M=s&&v[1]!=="c"?af(v.slice(2))??v:v;o(M),i+=v.length;continue}if(i+1>=e.length){t+=l;break}const f=Js(e,i+1);if(i+=1+f.length,f==="G")continue;const _=tp.get(f);if(_!==void 0){o(_);continue}const g=aM.get(f);let w;g!==void 0?w=g:/[A-Za-z0-9]/.test(f)?w=`\\${f}`:rp.includes(f)?w=`\\${f}`:w=f,o(w);continue}switch(l){case"[":{const u=lp(e,i,s);o(u.atom),i=u.end;continue}case"]":o("\\]"),++i;continue;case".":o("[^\\n]"),++i;continue;case"^":o(nM),++i;continue;case"$":o(sM),++i;continue;case"(":{const u=e.startsWith("(?i:",i),h=u?"(?i:":cM.exec(e.slice(i))?.[0]??"(",f=u||h==="(?>"?"(?:":h;a.push([t.length,s]),u&&(s=!0),t+=f,n=!1,i+=h.length;continue}case")":t+=l,[r,s]=a.pop()??[-1,!1],n=!1,++i;continue;case"|":t+=l,r=-1,n=!1,++i;continue;case"{":{const u=uM.exec(e.slice(i));if(!u||r<0){o("\\{"),++i;continue}const h=u[1].startsWith(",")?`0${u[1]}`:u[1];i+=u[0].length;const f=e[i];f==="+"||f==="*"?(t=`${t.slice(0,r)}(?:${t.slice(r)}{${h}})${f}`,++i):t+=`{${h}}`,n=!0;continue}case"}":o("\\}"),++i;continue;case"+":if(n){++i;continue}t+=l,n=!0,++i;continue;case"*":case"?":t+=l,n=!0,++i;continue;default:o(s&&ap(l)?`[${l.toLowerCase()}${l.toUpperCase()}]`:l),i+=l.length;continue}}return t},wM=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),vM=(e,t,r)=>{const n=[];let s=0;for(;s<e.length;){if(n.push(e[s]),(t.get(e[s])??r)!==r){++s;continue}for(;++s<e.length&&(t.get(e[s])??r)===r;)t.get(n.at(-1))!==r&&(n[n.length-1]+=e[s])}return n},yM=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,bM=e=>Number.isInteger(e)||typeof e=="bigint",MM=e=>{let t=0;for(const r of e)++t;return t},xM=e=>cp(e.toLowerCase()),It=(...e)=>Array.prototype.concat.apply([],e),Oi=e=>new Map(Object.entries(e)),TM=(e,t)=>{const r=[];let n=0;for(const s of e.matchAll(t)){const a=s[0];n<s.index&&r.push(e.slice(n,s.index)),a.length>0&&r.push(a),n=s.index+a.length}return n<e.length&&r.push(e.slice(n)),r},cp=e=>e.replace(new RegExp("\\p{M}","gu"),""),uf=(e,t,r=[])=>{if(!e||Array.isArray(e)||typeof e!="object")return`${t} must be a valid object`;for(const n of r)if(!(n in e))return`${t} must contain a "${n}" property`;return null},kM=e=>e.match(/\S+/g)||[],EM=class{constructor(){const e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}},ts=EM,CM=class extends ts{constructor(e){super(),this.config=e}_call(e){return this.normalize(e)}},or=CM,AM=class extends or{tokenize_chinese_chars(e){const t=[];for(let r=0;r<e.length;++r){const n=e[r],s=n.charCodeAt(0);yM(s)?(t.push(" "),t.push(n),t.push(" ")):t.push(n)}return t.join("")}strip_accents(e){return e.normalize("NFD").replace(new RegExp("\\p{Mn}","gu"),"")}is_control(e){switch(e){case" ":case`
8
+ `:case"\r":return!1;default:return new RegExp("^\\p{Cc}|\\p{Cf}|\\p{Co}|\\p{Cs}$","u").test(e)}}clean_text(e){const t=[];for(const r of e){const n=r.charCodeAt(0);n===0||n===65533||this.is_control(r)||(/^\s$/.test(r)?t.push(" "):t.push(r))}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}},SM=AM,PM=class extends or{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.includes("~")?e=e.split("~").map(r=>r.normalize("NFKC")).join("~"):e=e.normalize("NFKC"),e}},FM=PM,IM=class extends or{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(t=>up(t))}normalize(e){return this.normalizers.reduce((t,r)=>r?r.normalize(t):t,e)}},LM=IM,OM=class extends or{constructor(e){super(e),this.pattern=ca(this.config.pattern??{})}normalize(e){return this.pattern===null?e:e.replaceAll(this.pattern,this.config.content??"")}},NM=OM,DM=class extends or{constructor(){super(...arguments),this.form="NFC"}normalize(e){return e=e.normalize(this.form),e}},ua=DM,BM=class extends ua{constructor(){super(...arguments),this.form="NFC"}},zM=BM,RM=class extends ua{constructor(){super(...arguments),this.form="NFD"}},$M=RM,GM=class extends ua{constructor(){super(...arguments),this.form="NFKC"}},VM=GM,UM=class extends ua{constructor(){super(...arguments),this.form="NFKD"}},WM=UM,jM=class extends or{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}},qM=jM,HM=class extends or{normalize(e){return cp(e)}},QM=HM,XM=class extends or{normalize(e){return e.toLowerCase()}},YM=XM,JM=class extends or{normalize(e){return e=this.config.prepend+e,e}},KM=JM;function ZM(e){if(e===null)return null;switch(e.type){case"BertNormalizer":return new SM(e);case"Precompiled":return new FM(e);case"Sequence":return new LM(e);case"Replace":return new NM(e);case"NFC":return new zM(e);case"NFD":return new $M(e);case"NFKC":return new VM(e);case"NFKD":return new WM(e);case"Strip":return new qM(e);case"StripAccents":return new QM(e);case"Lowercase":return new YM(e);case"Prepend":return new KM(e);default:throw new Error(`Unknown Normalizer type: ${e.type}`)}}var up=ZM,ex=class extends ts{pre_tokenize(e,t){return(Array.isArray(e)?e.map(r=>this.pre_tokenize_text(r,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},Ot=ex,dp=(()=>{const e=[...Array.from({length:94},(s,a)=>a+33),...Array.from({length:12},(s,a)=>a+161),...Array.from({length:82},(s,a)=>a+174)],t=e.slice();let r=0;for(let s=0;s<256;++s)e.includes(s)||(e.push(s),t.push(256+r),r+=1);const n=t.map(s=>String.fromCharCode(s));return Object.fromEntries(e.map((s,a)=>[s,n[a]]))})(),tx=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[r,t])),rx=tx(dp),Zs="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",nx=class extends Ot{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=new RegExp("'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+","gu"),this.byte_encoder=dp,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(n=>Array.from(this.text_encoder.encode(n),s=>this.byte_encoder[s]).join(""))}},sx=nx,ax=class extends Ot{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},ox=ax,ix=class extends Ot{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){const{section_index:r=void 0}=t??{};let n=e.replaceAll(" ",this.str_rep);return!n.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&r===0)&&(n=this.str_rep+n),[n]}},lx=ix,cx=class extends Ot{constructor(e){super(),this.config=e,this.pattern=ca(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?(e.match(this.pattern)||[]).filter(t=>t):this.config.behavior?.toLowerCase()==="removed"?e.split(this.pattern).filter(t=>t):TM(e,this.pattern)}},ux=cx,dx=class extends Ot{constructor(e){super(),this.config=e,this.pattern=new RegExp(`[^${Zs}]+|[${Zs}]+`,"gu")}pre_tokenize_text(e){return e.match(this.pattern)||[]}},hx=dx,fx=class extends Ot{constructor(e){super(),this.config=e;const t=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(t,"gu")}pre_tokenize_text(e){return e.match(this.pattern)||[]}},_x=fx,px=class extends Ot{constructor(){super(),this.pattern=new RegExp(`[^\\s${Zs}]+|[${Zs}]`,"gu")}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},mx=px,gx=class extends Ot{constructor(e){super(),this.config=e,this.pattern=ca(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??"")]}},wx=gx,vx=class extends Ot{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(t=>hp(t))}pre_tokenize_text(e,t){return this.tokenizers.reduce((r,n)=>n?n.pre_tokenize(r,t):r,[e])}},yx=vx,bx=class extends Ot{pre_tokenize_text(e){return kM(e)}},Mx=bx,xx=class extends Ot{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){const t=[];for(let r=0;r<e.length;r+=this._length)t.push(e.slice(r,r+this._length));return t}},Tx=xx;function kx(e){if(e===null)return null;switch(e.type){case"BertPreTokenizer":return new mx;case"Sequence":return new yx(e);case"Whitespace":return new ox;case"WhitespaceSplit":return new Mx;case"Metaspace":return new lx(e);case"ByteLevel":return new sx(e);case"Split":return new ux(e);case"Punctuation":return new hx(e);case"Digits":return new _x(e);case"Replace":return new wx(e);case"FixedLength":return new Tx(e);default:throw new Error(`Unknown PreTokenizer type: ${e.type}`)}}var hp=kx,Ex=class extends ts{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=vM(t,this.tokens_to_ids,this.unk_token_id)),t}},da=Ex,Cx=class extends da{constructor(e){super(e),this.max_input_chars_per_word=100,this.tokens_to_ids=Oi(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=new Array(this.tokens_to_ids.size);for(const[t,r]of this.tokens_to_ids)this.vocab[r]=t}encode(e){const t=[];for(const r of e){const n=[...r];if(n.length>this.max_input_chars_per_word){t.push(this.unk_token);continue}let s=!1,a=0;const o=[];for(;a<n.length;){let i=n.length,l=null;for(;a<i;){let u=n.slice(a,i).join("");if(a>0&&(u=this.config.continuing_subword_prefix+u),this.tokens_to_ids.has(u)){l=u;break}--i}if(l===null){s=!0;break}o.push(l),a=i}s?t.push(this.unk_token):t.push(...o)}return t}},df=Cx,hf=class fp{constructor(t,r){this.is_leaf=t,this.children=r}static default(){return new fp(!1,new Map)}},Ax=class{constructor(){this.root=hf.default()}extend(e){for(const t of e)this.push(t)}push(e){let t=this.root;for(const r of e){let n=t.children.get(r);n===void 0&&(n=hf.default(),t.children.set(r,n)),t=n}t.is_leaf=!0}*common_prefix_search(e,t=0){let r=this.root;if(r===void 0)return;let n="";for(let s=t;s<e.length;++s){const a=e[s];if(n+=a,r=r.children.get(a),r===void 0)return;r.is_leaf&&(yield n)}}},Sx=Ax,Oo=class _p{constructor(t,r,n,s,a){this.token_id=t,this.node_id=r,this.pos=n,this.length=s,this.score=a,this.prev=null,this.backtrace_score=0}clone(){const t=new _p(this.token_id,this.node_id,this.pos,this.length,this.score);return t.prev=this.prev,t.backtrace_score=this.backtrace_score,t}},Px=class{constructor(e,t,r){this.chars=Array.from(e),this.len=this.chars.length,this.bos_token_id=t,this.eos_token_id=r,this.nodes=[],this.begin_nodes=Array.from({length:this.len+1},()=>[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);const n=new Oo(this.bos_token_id??0,0,0,0,0),s=new Oo(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(n.clone()),this.nodes.push(s.clone()),this.begin_nodes[this.len].push(s),this.end_nodes[0].push(n)}insert(e,t,r,n){const s=this.nodes.length,a=new Oo(n,s,e,t,r);this.begin_nodes[e].push(a),this.end_nodes[e+t].push(a),this.nodes.push(a)}viterbi(){const e=this.len;let t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let o of this.begin_nodes[t]){o.prev=null;let i=0,l=null;for(let u of this.end_nodes[t]){const h=u.backtrace_score+o.score;(l===null||h>i)&&(l=u.clone(),i=h)}if(l!==null)o.prev=l,o.backtrace_score=i;else return[]}++t}const r=[],s=this.begin_nodes[e][0].prev;if(s===null)return[];let a=s.clone();for(;a.prev!==null;)r.push(a.clone()),a=a.clone().prev.clone();return r.reverse(),r}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join("")}tokens(){return this.viterbi().map(t=>this.piece(t))}token_ids(){return this.viterbi().map(t=>t.token_id)}},Fx=Px;function Ix(e){if(e.length===0)throw new Error("Array must not be empty");let t=e[0],r=0;for(let n=1;n<e.length;++n)e[n]<t&&(t=e[n],r=n);return[t,r]}var Lx=class extends da{constructor(e,t){super(e);const r=e.vocab.length;this.vocab=new Array(r),this.scores=new Array(r);for(let n=0;n<r;++n)[this.vocab[n],this.scores[n]]=e.vocab[n];this.unk_token_id=e.unk_id,this.unk_token=this.vocab[e.unk_id],this.tokens_to_ids=new Map(this.vocab.map((n,s)=>[n,s])),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=Ix(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new Sx,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){const t=e.chars,r=1;let n=0;for(;n<t.length;){let s=!1;const a=this.trie.common_prefix_search(t,n);for(const o of a){const i=this.tokens_to_ids.get(o),l=this.scores[i],u=MM(o);e.insert(n,u,l,i),!s&&u===r&&(s=!0)}s||e.insert(n,r,this.unk_score,this.unk_token_id),n+=r}}tokenize(e){const t=new Fx(e,this.bos_token_id,this.eos_token_id);return this.populate_nodes(t),t.tokens()}encode(e){const t=[];for(const r of e){const n=this.tokenize(r);t.push(...n)}return t}},ff=Lx,Ox=class{constructor(e=(r,n)=>r>n,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(const t of e)if(this.size<this._max_size)this._heap.push(t),this._sift_up();else{const r=this._smallest();this._comparator(t,this._heap[r])&&(this._heap[r]=t,this._sift_up_from(r))}return this.size}pop(){const e=this.peek(),t=this.size-1;return t>0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){const 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){const r=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=r}_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);){const 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}},Nx=Ox,Dx=class{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const 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()}},Bx=Dx,zx=class extends da{constructor(e){super(e),this.tokens_to_ids=Oi(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(const[r,n]of this.tokens_to_ids)this.vocab[n]=r;const t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(r=>r.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((r,n)=>[JSON.stringify(r),n])),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 Bx(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];const t=this.cache.get(e);if(t!==void 0)return t;const r=Array.from(e);this.end_of_word_suffix&&(r[r.length-1]+=this.end_of_word_suffix);let n=[];if(r.length>1){const s=new Nx((i,l)=>i.score<l.score);let a={token:r[0],bias:0,prev:null,next:null},o=a;for(let i=1;i<r.length;++i){const l={bias:i/r.length,token:r[i],prev:o,next:null};o.next=l,this.add_node(s,o),o=l}for(;!s.is_empty();){const i=s.pop();if(i.deleted||!i.next||i.next.deleted)continue;if(i.deleted=!0,i.next.deleted=!0,i.prev){const u={...i.prev};i.prev.deleted=!0,i.prev=u,u.prev?u.prev.next=u:a=u}const l={token:i.token+i.next.token,bias:i.bias,prev:i.prev,next:i.next.next};l.prev?(l.prev.next=l,this.add_node(s,l.prev)):a=l,l.next&&(l.next.prev=l,this.add_node(s,l))}for(let i=a;i!==null;i=i.next)n.push(i.token)}else n=r;if(this.continuing_subword_suffix)for(let s=0;s<n.length-1;++s)n[s]+=this.continuing_subword_suffix;return e.length<this.max_length_to_cache&&this.cache.put(e,n),n}add_node(e,t){const r=this.bpe_ranks.get(JSON.stringify([t.token,t.next.token]));r!==void 0&&(t.score=r+t.bias,e.push(t))}encode(e){const t=[];for(const r of e){if(this.ignore_merges&&this.tokens_to_ids.has(r)){t.push(r);continue}const n=this.bpe(r);for(const s of n)if(this.tokens_to_ids.has(s))t.push(s);else if(this.byte_fallback){const a=Array.from(this.text_encoder.encode(s)).map(o=>`<0x${o.toString(16).toUpperCase().padStart(2,"0")}>`);a.every(o=>this.tokens_to_ids.has(o))?t.push(...a):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},_f=zx,Rx=class extends da{constructor(e,t){super(e);const r=e.vocab;this.tokens_to_ids=Oi(t.target_lang?r[t.target_lang]:r),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=new Array(this.tokens_to_ids.size);for(const[n,s]of this.tokens_to_ids)this.vocab[s]=n}encode(e){return e}},$x=Rx;function Gx(e,t){switch(e.type){case"WordPiece":return new df(e);case"Unigram":return new ff(e,t.eos_token);case"BPE":return new _f(e);default:if(e.vocab)return Array.isArray(e.vocab)?new ff(e,t.eos_token):Object.hasOwn(e,"continuing_subword_prefix")&&Object.hasOwn(e,"unk_token")?Object.hasOwn(e,"merges")?new _f(e):new df(e):new $x(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 new Error(`Unknown TokenizerModel type: ${e?.type}`)}}var Vx=Gx,Ux=class extends ts{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},rs=Ux,Wx=class extends rs{post_process(e,t=null,r=!0){const n=t===null?this.config.single:this.config.pair;let s=[],a=[];for(const o of n)"SpecialToken"in o?r&&(s.push(o.SpecialToken.id),a.push(o.SpecialToken.type_id)):"Sequence"in o&&(o.Sequence.id==="A"?(s=It(s,e),a=It(a,new Array(e.length).fill(o.Sequence.type_id))):o.Sequence.id==="B"&&(s=It(s,t),a=It(a,new Array(t.length).fill(o.Sequence.type_id))));return{tokens:s,token_type_ids:a}}},jx=Wx,qx=class extends rs{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},Hx=qx,Qx=class extends rs{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,r=!0){r&&(e=It([this.cls[0]],e,[this.sep[0]]));let n=new Array(e.length).fill(0);if(t){const s=[],a=r?[this.sep[0]]:[];e=It(e,s,t,a),n=It(n,new Array(t.length+s.length+a.length).fill(1))}return{tokens:e,token_type_ids:n}}},Xx=Qx,Yx=class extends rs{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,r=!0){r&&(e=It([this.cls[0]],e,[this.sep[0]]));let n=new Array(e.length).fill(0);if(t){const s=r?[this.sep[0]]:[],a=r?[this.sep[0]]:[];e=It(e,s,t,a),n=It(n,new Array(t.length+s.length+a.length).fill(1))}return{tokens:e,token_type_ids:n}}},Jx=Yx,Kx=class extends rs{constructor(e){super(e),this.processors=(e.processors??[]).map(t=>pp(t))}post_process(e,t=null,r=!0){let n={tokens:e,tokens_pair:t};for(const s of this.processors)n=s.post_process(n.tokens,n.tokens_pair,r);return n}},Zx=Kx;function e1(e){if(e===null)return null;switch(e.type){case"TemplateProcessing":return new jx(e);case"ByteLevel":return new Hx(e);case"BertProcessing":return new Xx(e);case"RobertaProcessing":return new Jx(e);case"Sequence":return new Zx(e);default:throw new Error(`Unknown PostProcessor type: ${e.type}`)}}var pp=e1,t1=class extends ts{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("")}},Nt=t1,r1=class extends Nt{constructor(e){super(e),this.byte_decoder=rx,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){const t=e.join(""),r=new Uint8Array([...t].map(n=>this.byte_decoder[n]));return this.text_decoder.decode(r)}decode_chain(e){const t=[];let r=[];for(const n of e)this.added_tokens.find(s=>s.content===n)!==void 0?(r.length>0&&(t.push(this.convert_tokens_to_string(r)),r=[]),t.push(n)):r.push(n);return r.length>0&&t.push(this.convert_tokens_to_string(r)),t}},n1=r1,s1=class extends Nt{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((t,r)=>{if(r!==0){const n=this.config.prefix;n&&t.startsWith(n)?t=t.replace(n,""):t=" "+t}return this.cleanup&&(t=Ii(t)),t})}},a1=s1,o1=class extends Nt{constructor(e){super(e),this.replacement=e.replacement??"▁"}decode_chain(e){const t=[];for(let r=0;r<e.length;++r){let n=e[r].replaceAll(this.replacement," ");r==0&&n.startsWith(" ")&&(n=n.substring(1)),t.push(n)}return t}},i1=o1,l1=class extends Nt{constructor(e){super(e),this.suffix=e.suffix??""}decode_chain(e){return e.map((t,r)=>t.replaceAll(this.suffix,r===e.length-1?"":" "))}},c1=l1,u1=class extends Nt{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"";const t=[e[0]];for(let s=1;s<e.length;++s)e[s]!==t.at(-1)&&t.push(e[s]);let n=t.filter(s=>s!==this.pad_token).join("");return this.cleanup&&(n=Ii(n).replaceAll(this.word_delimiter_token," ").trim()),n}decode_chain(e){return[this.convert_tokens_to_string(e)]}},d1=u1,h1=class extends Nt{constructor(e){super(e),this.decoders=(e.decoders??[]).map(t=>mp(t))}decode_chain(e){return this.decoders.reduce((t,r)=>r.decode_chain(t),e)}},f1=h1,_1=class extends Nt{constructor(e){super(e),this.pattern=ca(this.config.pattern)}decode_chain(e){const t=this.config.content??"",r=this.pattern;return r===null?e:e.map(n=>n.replaceAll(r,t))}},p1=_1,m1=class extends Nt{decode_chain(e){return[e.join("")]}},g1=m1,w1=class extends Nt{constructor(e){super(e),this.content=e.content??"",this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(t=>{let r=0;for(let s=0;s<this.start&&t[s]===this.content;++s){r=s+1;continue}let n=t.length;for(let s=0;s<this.stop;++s){const a=t.length-s-1;if(t[a]===this.content){n=a;continue}else break}return t.slice(r,n)})}},v1=w1,y1=class extends Nt{constructor(e){super(e),this.text_decoder=new TextDecoder}decode_chain(e){const t=[];let r=[];for(const n of e){let s=null;if(n.length===6&&n.startsWith("<0x")&&n.endsWith(">")){const a=parseInt(n.slice(3,5),16);isNaN(a)||(s=a)}if(s!==null)r.push(s);else{if(r.length>0){const a=this.text_decoder.decode(Uint8Array.from(r));t.push(a),r=[]}t.push(n)}}if(r.length>0){const n=this.text_decoder.decode(Uint8Array.from(r));t.push(n),r=[]}return t}},b1=y1;function M1(e){if(e===null)return null;switch(e.type){case"ByteLevel":return new n1(e);case"WordPiece":return new a1(e);case"Metaspace":return new i1(e);case"BPEDecoder":return new c1(e);case"CTC":return new d1(e);case"Sequence":return new f1(e);case"Replace":return new p1(e);case"Fuse":return new g1(e);case"Strip":return new v1(e);case"ByteFallback":return new b1(e);default:throw new Error(`Unknown Decoder type: ${e.type}`)}}var mp=M1,x1=class{constructor(e,t){const r=uf(e,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);const n=uf(t,"Config");if(n)throw new Error(n);this.tokenizer=e,this.config=t,this.normalizer=up(this.tokenizer.normalizer),this.pre_tokenizer=hp(this.tokenizer.pre_tokenizer),this.model=Vx(this.tokenizer.model,this.config),this.post_processor=pp(this.tokenizer.post_processor),this.decoder=mp(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];const s=[],a=[];this.added_tokens_map=new Map;for(const o of this.tokenizer.added_tokens){const i=new eM(o);if(this.added_tokens.push(i),this.model.tokens_to_ids.set(i.content,i.id),this.model.vocab[i.id]=i.content,i.special&&(this.special_tokens.push(i.content),this.all_special_ids.push(i.id)),this.added_tokens_map.set(i.content,i),i.normalized&&this.normalizer!==null){const l=this.normalizer(i.content);a.push(l),this.added_tokens_map.set(l,i)}else s.push(i.content)}(this.config.additional_special_tokens??[]).forEach(o=>{this.special_tokens.includes(o)||this.special_tokens.push(o)}),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 sf(s),this.splitter_normalized=new sf(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:r=!0,return_token_type_ids:n=null}={}){const{tokens:s,token_type_ids:a}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:r}),o=s.map(l=>this.added_tokens_map.get(l)?.id??this.model.tokens_to_ids.get(l)??this.model.unk_token_id),i={ids:o,tokens:s,attention_mask:new Array(o.length).fill(1)};return n&&a&&(i.token_type_ids=a),i}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!bM(e[0]))throw Error("token_ids must be a non-empty array of integers.");let r=e.map(s=>this.model.vocab[Number(s)]??this.model.unk_token);t.skip_special_tokens&&(r=r.filter(s=>!this.special_tokens.includes(s)));let n=this.decoder?this.decoder(r):r.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(n=n.replaceAll(this.decoder.end_of_word_suffix," "),t.skip_special_tokens&&(n=n.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(n=Ii(n)),n}tokenize(e,{text_pair:t=null,add_special_tokens:r=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:r}).tokens}encode_text(e){if(e===null)return null;const t=this.splitter_unnormalized.split(e);return t.forEach((r,n)=>{const s=this.added_tokens_map.get(r);s&&(s.lstrip&&n>0&&(t[n-1]=t[n-1].trimEnd()),s.rstrip&&n<t.length-1&&(t[n+1]=t[n+1].trimStart()))}),t.flatMap((r,n)=>{if(r.length===0)return[];if(this.added_tokens_map.has(r))return[r];if(this.remove_space===!0&&(r=r.trim().split(/\s+/).join(" ")),this.do_lowercase_and_remove_accent&&(r=xM(r)),this.normalizer!==null&&(r=this.normalizer(r)),r.length===0)return[];const s=this.splitter_normalized.split(r);return s.forEach((a,o)=>{const i=this.added_tokens_map.get(a);i&&(i.lstrip&&o>0&&(s[o-1]=s[o-1].trimEnd()),i.rstrip&&o<s.length-1&&(s[o+1]=s[o+1].trimStart()))}),s.flatMap(a=>{if(a.length===0)return[];if(this.added_tokens_map.has(a))return[a];const o=this.pre_tokenizer!==null?this.pre_tokenizer(a,{section_index:n}):[a];return this.model(o)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:r=!0}){const n=this.encode_text(e),s=this.encode_text(t||null);return this.post_processor?this.post_processor(n,s,r):{tokens:It(n??[],s??[])}}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(){const e=new Map;for(const t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){const t=new Map;for(let r=0;r<this.model.vocab.length;++r){const n=this.model.vocab[r];(e||!this.added_tokens_map.has(n))&&t.set(n,r)}return t}},T1=x1,k1=Object.defineProperty,E1=(e,t,r)=>t in e?k1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,C1=(e,t,r)=>(E1(e,t+"",r),r),B=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",ExponentiationBinaryOperator:"ExponentiationBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),Mt=class{constructor(e,t){this.value=e,this.type=t}};function pf(e){return/\w/.test(e)}function Or(e){return/[0-9]/.test(e)}function mf(e){return/\s/.test(e)}var A1=[["{%",B.OpenStatement],["%}",B.CloseStatement],["{{",B.OpenExpression],["}}",B.CloseExpression],["(",B.OpenParen],[")",B.CloseParen],["{",B.OpenCurlyBracket],["}",B.CloseCurlyBracket],["[",B.OpenSquareBracket],["]",B.CloseSquareBracket],[",",B.Comma],[".",B.Dot],[":",B.Colon],["|",B.Pipe],["<=",B.ComparisonBinaryOperator],[">=",B.ComparisonBinaryOperator],["==",B.ComparisonBinaryOperator],["!=",B.ComparisonBinaryOperator],["<",B.ComparisonBinaryOperator],[">",B.ComparisonBinaryOperator],["+",B.AdditiveBinaryOperator],["-",B.AdditiveBinaryOperator],["~",B.AdditiveBinaryOperator],["**",B.ExponentiationBinaryOperator],["*",B.MultiplicativeBinaryOperator],["//",B.MultiplicativeBinaryOperator],["/",B.MultiplicativeBinaryOperator],["%",B.MultiplicativeBinaryOperator],["=",B.Equals]],S1=new Map([["n",`
9
+ `],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function P1(e,t={}){return e.endsWith(`
10
+ `)&&(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*){%(-?)\s*(?:end)?generation\s*(-?)%}(\s*)/gs,(r,n,s,a,o)=>(s?"":n)+(a?"":o))}function F1(e,t={}){const r=[],n=P1(e,t);let s=0,a=0;const o=u=>{let h="";for(;u(n[s]);){if(n[s]==="\\"){if(++s,s>=n.length)throw new SyntaxError("Unexpected end of input");const f=n[s++],_=S1.get(f);if(_===void 0)throw new SyntaxError(`Unexpected escaped character: ${f}`);h+=_;continue}if(h+=n[s++],s>=n.length)throw new SyntaxError("Unexpected end of input")}return h},i=()=>{const u=r.at(-1);u&&u.type===B.Text&&(u.value=u.value.trimEnd(),u.value===""&&r.pop())},l=()=>{for(;s<n.length&&mf(n[s]);)++s};e:for(;s<n.length;){const u=r.at(-1)?.type;if(u===void 0||u===B.CloseStatement||u===B.CloseExpression||u===B.Comment){let f="";for(;s<n.length&&!(n[s]==="{"&&(n[s+1]==="%"||n[s+1]==="{"||n[s+1]==="#"));)f+=n[s++];if(f.length>0){r.push(new Mt(f,B.Text));continue}}if(n[s]==="{"&&n[s+1]==="#"){s+=2;const f=n[s]==="-";f&&++s;let _="";for(;n[s]!=="#"||n[s+1]!=="}";){if(s+2>=n.length)throw new SyntaxError("Missing end of comment tag");_+=n[s++]}const g=_.endsWith("-");g&&(_=_.slice(0,-1)),f&&i(),r.push(new Mt(_,B.Comment)),s+=2,g&&l();continue}if(n.slice(s,s+3)==="{%-"){i(),r.push(new Mt("{%",B.OpenStatement)),s+=3;continue}if(n.slice(s,s+3)==="{{-"){i(),r.push(new Mt("{{",B.OpenExpression)),a=0,s+=3;continue}if(o(mf),n.slice(s,s+3)==="-%}"){r.push(new Mt("%}",B.CloseStatement)),s+=3,l();continue}if(n.slice(s,s+3)==="-}}"){r.push(new Mt("}}",B.CloseExpression)),s+=3,l();continue}const h=n[s];if(h==="-"||h==="+"){const f=r.at(-1)?.type;if(f===B.Text||f===void 0)throw new SyntaxError(`Unexpected character: ${h}`);switch(f){case B.Identifier:case B.NumericLiteral:case B.StringLiteral:case B.CloseParen:case B.CloseSquareBracket:break;default:{++s;let _=o(Or);if(_.length>0&&n[s]==="."&&Or(n[s+1])){++s;const g=o(Or);_=`${_}.${g}`}r.push(new Mt(`${h}${_}`,_.length>0?B.NumericLiteral:B.UnaryOperator));continue}}}for(const[f,_]of A1){if(f==="}}"&&a>0)continue;if(n.slice(s,s+f.length)===f){r.push(new Mt(f,_)),_===B.OpenExpression?a=0:_===B.OpenCurlyBracket?++a:_===B.CloseCurlyBracket&&--a,s+=f.length;continue e}}if(h==="'"||h==='"'){++s;const f=o(_=>_!==h);r.push(new Mt(f,B.StringLiteral)),++s;continue}if(Or(h)){let f=o(Or);if(r.at(-1)?.type!==B.Dot&&n[s]==="."&&Or(n[s+1])){++s;const _=o(Or);f=`${f}.${_}`}r.push(new Mt(f,B.NumericLiteral));continue}if(pf(h)){const f=o(pf);r.push(new Mt(f,B.Identifier));continue}throw new SyntaxError(`Unexpected character: ${h}`)}return r}var kt=class{type="Statement"},I1=class extends kt{constructor(e){super(),this.body=e}type="Program"},L1=class extends kt{constructor(e,t,r){super(),this.test=e,this.body=t,this.alternate=r}type="If"},O1=class extends kt{constructor(e,t,r,n){super(),this.loopvar=e,this.iterable=t,this.body=r,this.defaultBlock=n}type="For"},N1=class extends kt{type="Break"},D1=class extends kt{type="Continue"},B1=class extends kt{constructor(e,t,r){super(),this.assignee=e,this.value=t,this.body=r}type="Set"},z1=class extends kt{constructor(e,t,r){super(),this.name=e,this.args=t,this.body=r}type="Macro"},R1=class extends kt{constructor(e){super(),this.value=e}type="Comment"},ht=class extends kt{type="Expression"},$1=class extends ht{constructor(e,t,r){super(),this.object=e,this.property=t,this.computed=r}type="MemberExpression"},gf=class extends ht{constructor(e,t){super(),this.callee=e,this.args=t}type="CallExpression"},pr=class extends ht{constructor(e){super(),this.value=e}type="Identifier"},yn=class extends ht{constructor(e){super(),this.value=e}type="Literal"},G1=class extends yn{type="IntegerLiteral"},V1=class extends yn{type="FloatLiteral"},wf=class extends yn{type="StringLiteral"},U1=class extends yn{type="ArrayLiteral"},vf=class extends yn{type="TupleLiteral"},W1=class extends yn{type="ObjectLiteral"},nn=class extends ht{constructor(e,t,r){super(),this.operator=e,this.left=t,this.right=r}type="BinaryExpression"},j1=class extends ht{constructor(e,t){super(),this.operand=e,this.filter=t}type="FilterExpression"},q1=class extends kt{constructor(e,t){super(),this.filter=e,this.body=t}type="FilterStatement"},H1=class extends ht{constructor(e,t){super(),this.lhs=e,this.test=t}type="SelectExpression"},Q1=class extends ht{constructor(e,t,r){super(),this.operand=e,this.negate=t,this.test=r}type="TestExpression"},yf=class extends ht{constructor(e,t){super(),this.operator=e,this.argument=t}type="UnaryExpression"},X1=class extends ht{constructor(e=void 0,t=void 0,r=void 0){super(),this.start=e,this.stop=t,this.step=r}type="SliceExpression"},No=class extends ht{constructor(e,t){super(),this.key=e,this.value=t}type="KeywordArgumentExpression"},Y1=class extends ht{constructor(e){super(),this.argument=e}type="SpreadExpression"},J1=class extends ht{constructor(e){super(),this.argument=e}type="KeywordSpreadExpression"},K1=class extends kt{constructor(e,t,r){super(),this.call=e,this.callerArgs=t,this.body=r}type="CallStatement"},Z1=class extends ht{constructor(e,t,r){super(),this.condition=e,this.trueExpr=t,this.falseExpr=r}type="Ternary"};function eT(e){const t=new I1([]);let r=0;function n(L,O){const $=e[r++];if(!$||$.type!==L)throw new Error(`Parser Error: ${O}. ${$.type} !== ${L}.`);return $}function s(L){if(!l(L))throw new SyntaxError(`Expected ${L}`);++r}function a(){switch(e[r].type){case B.Comment:return new R1(e[r++].value);case B.Text:return u();case B.OpenStatement:return h();case B.OpenExpression:return f();default:throw new SyntaxError(`Unexpected token type: ${e[r].type}`)}}function o(...L){return r+L.length<=e.length&&L.every((O,$)=>O===e[r+$].type)}function i(...L){return e[r]?.type===B.OpenStatement&&e[r+1]?.type===B.Identifier&&L.includes(e[r+1]?.value)}function l(...L){return r+L.length<=e.length&&L.every((O,$)=>e[r+$].type==="Identifier"&&O===e[r+$].value)}function u(){return new wf(n(B.Text,"Expected text token").value)}function h(){if(n(B.OpenStatement,"Expected opening statement token"),e[r].type!==B.Identifier)throw new SyntaxError(`Unknown statement, got ${e[r].type}`);const L=e[r].value;let O;switch(L){case"set":++r,O=_();break;case"if":++r,O=g(),n(B.OpenStatement,"Expected {% token"),s("endif"),n(B.CloseStatement,"Expected %} token");break;case"macro":++r,O=w(),n(B.OpenStatement,"Expected {% token"),s("endmacro"),n(B.CloseStatement,"Expected %} token");break;case"for":++r,O=M(),n(B.OpenStatement,"Expected {% token"),s("endfor"),n(B.CloseStatement,"Expected %} token");break;case"call":{++r;let $=null;o(B.OpenParen)&&($=H("parameters"));const se=ne();if(se.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");const ae=H("call");n(B.CloseStatement,"Expected closing statement token");const We=[];for(;!i("endcall");)We.push(a());n(B.OpenStatement,"Expected '{%'"),s("endcall"),n(B.CloseStatement,"Expected closing statement token");const Te=new gf(se,ae);O=new K1(Te,$,We);break}case"break":++r,n(B.CloseStatement,"Expected closing statement token"),O=new N1;break;case"continue":++r,n(B.CloseStatement,"Expected closing statement token"),O=new D1;break;case"filter":{++r;let $=ne();$ instanceof pr&&o(B.OpenParen)&&($=R($)),n(B.CloseStatement,"Expected closing statement token");const se=[];for(;!i("endfilter");)se.push(a());n(B.OpenStatement,"Expected '{%'"),s("endfilter"),n(B.CloseStatement,"Expected '%}'"),O=new q1($,se);break}default:throw new SyntaxError(`Unknown statement type: ${L}`)}return O}function f(){n(B.OpenExpression,"Expected opening expression token");const L=x();return n(B.CloseExpression,"Expected closing expression token"),L}function _(){const L=v();let O=null;const $=[];if(o(B.Equals))++r,O=v();else{for(n(B.CloseStatement,"Expected %} token");!i("endset");)$.push(a());n(B.OpenStatement,"Expected {% token"),s("endset")}return n(B.CloseStatement,"Expected closing statement token"),new B1(L,O,$)}function g(){const L=x();n(B.CloseStatement,"Expected closing statement token");const O=[],$=[];for(;!i("elif","else","endif");)O.push(a());if(i("elif")){++r,++r;const se=g();$.push(se)}else if(i("else"))for(++r,++r,n(B.CloseStatement,"Expected closing statement token");!i("endif");)$.push(a());return new L1(L,O,$)}function w(){const L=ne();if(L.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");const O=H("parameters");n(B.CloseStatement,"Expected closing statement token");const $=[];for(;!i("endmacro");)$.push(a());return new z1(L,O,$)}function v(L=!1){const O=L?ne:x,$=[O()],se=o(B.Comma);for(;se&&(++r,$.push(O()),!!o(B.Comma)););return se?new vf($):$[0]}function M(){const L=v(!0);if(!(L instanceof pr||L instanceof vf))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${L.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;const O=x();n(B.CloseStatement,"Expected closing statement token");const $=[];for(;!i("endfor","else");)$.push(a());const se=[];if(i("else"))for(++r,++r,n(B.CloseStatement,"Expected closing statement token");!i("endfor");)se.push(a());return new O1(L,O,$,se)}function x(){return k()}function k(){const L=C();if(l("if")){++r;const O=C();if(l("else")){++r;const $=k();return new Z1(O,L,$)}else return new H1(L,O)}return L}function C(){let L=E();for(;l("or");){const O=e[r];++r;const $=E();L=new nn(O,L,$)}return L}function E(){let L=F();for(;l("and");){const O=e[r];++r;const $=F();L=new nn(O,L,$)}return L}function F(){let L;for(;l("not");){const O=e[r];++r;const $=F();L=new yf(O,$)}return L??z()}function z(){let L=b();for(;;){let O;if(l("not","in"))O=new Mt("not in",B.Identifier),r+=2;else if(l("in"))O=e[r++];else if(o(B.ComparisonBinaryOperator))O=e[r++];else break;const $=b();L=new nn(O,L,$)}return L}function b(){let L=I();for(;o(B.AdditiveBinaryOperator);){const O=e[r];++r;const $=I();L=new nn(O,L,$)}return L}function V(){const L=D(ne());return o(B.OpenParen)?R(L):L}function R(L){let O=new gf(L,H("call"));return O=D(O),o(B.OpenParen)&&(O=R(O)),O}function H(L){n(B.OpenParen,"Expected opening parenthesis for arguments list");const O=J(L);return n(B.CloseParen,"Expected closing parenthesis for arguments list"),O}function J(L){const O=[],$=new Set;let se=!1,ae=!1;for(;!o(B.CloseParen);){const We=o(B.ExponentiationBinaryOperator),Te=o(B.MultiplicativeBinaryOperator)&&e[r].value==="*";if(L==="parameters"&&(We||Te))throw new SyntaxError("Argument unpacking is not allowed in parameter declarations");if(We){if(++r,O.push(new J1(x())),o(B.Comma)&&++r,!o(B.CloseParen))throw new SyntaxError("Expected closing parenthesis: `**` must be applied to the final argument");break}let ke;if(Te){if(ae)throw new SyntaxError("Only one `*` argument unpacking is allowed");ae=!0,++r;const $e=x();ke=new Y1($e)}else{if(ke=x(),o(B.Equals)){if(++r,!(ke instanceof pr))throw new SyntaxError(L==="parameters"?"Expected identifier for parameter declaration":"Expected identifier for keyword argument");const $e=x();ke=new No(ke,$e)}if(L==="parameters"){if(!(ke instanceof pr||ke instanceof No))throw new SyntaxError("Expected identifier for parameter declaration");const $e=ke instanceof pr?ke.value:ke.key.value;if($.has($e))throw new SyntaxError(`Duplicate parameter name: ${$e}`);$.add($e)}if(ke instanceof No)se=!0;else{if(se)throw new SyntaxError(L==="call"?"Positional arguments must come before keyword arguments":"Non-default argument follows default argument");if(ae)throw new SyntaxError("Positional arguments must not follow `*` argument unpacking")}}O.push(ke),o(B.Comma)&&++r}return O}function X(){const L=[];let O=!1;for(;!o(B.CloseSquareBracket);)o(B.Colon)?(L.push(void 0),++r,O=!0):(L.push(x()),o(B.Colon)&&(++r,O=!0));if(L.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(O){if(L.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new X1(...L)}return L[0]}function D(L){for(;o(B.Dot)||o(B.OpenSquareBracket);){const O=e[r];++r;let $;const se=O.type===B.OpenSquareBracket;if(se)$=X(),n(B.CloseSquareBracket,"Expected closing square bracket");else if($=ne(),$.type!=="Identifier"&&$.type!=="IntegerLiteral")throw new SyntaxError("Expected identifier or integer following dot operator");L=new $1(L,$,se)}return L}function I(){let L=G();for(;o(B.MultiplicativeBinaryOperator);){const O=e[r++],$=G();L=new nn(O,L,$)}return L}function G(){let L=Q();for(;o(B.ExponentiationBinaryOperator);){const O=e[r++],$=Q();L=new nn(O,L,$)}return L}function Q(){let L=ce();for(;l("is");){++r;const O=l("not");O&&++r;const $=ne();if(!($ instanceof pr))throw new SyntaxError("Expected identifier for the test");L=new Q1(L,O,$)}return L}function ce(){let L=Z();for(;o(B.Pipe);){++r;let O=ne();if(!(O instanceof pr))throw new SyntaxError("Expected identifier for the filter");o(B.OpenParen)&&(O=R(O)),L=new j1(L,O)}return L}function Z(){const L=e[r];if(L&&(L.type===B.UnaryOperator||L.type===B.AdditiveBinaryOperator)&&(L.value==="-"||L.value==="+")){const O=e[r++],$=Z();return new yf(O,$)}return V()}function ne(){const L=e[r++];switch(L.type){case B.NumericLiteral:{const O=L.value;return O.includes(".")?new V1(Number(O)):new G1(Number(O))}case B.StringLiteral:{let O=L.value;for(;o(B.StringLiteral);)O+=e[r++].value;return new wf(O)}case B.Identifier:return new pr(L.value);case B.OpenParen:{const O=v();return n(B.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),O}case B.OpenSquareBracket:{const O=[];for(;!o(B.CloseSquareBracket);)O.push(x()),o(B.Comma)&&++r;return++r,new U1(O)}case B.OpenCurlyBracket:{const O=new Map;for(;!o(B.CloseCurlyBracket);){const $=x();n(B.Colon,"Expected colon between key and value in object literal");const se=x();O.set($,se),o(B.Comma)&&++r}return++r,new W1(O)}default:throw new SyntaxError(`Unexpected token: ${L.type}`)}}for(;r<e.length;)t.body.push(a());return t}function tT(e,t,r=1){if(t===void 0&&(t=e,e=0),r===0)throw new Error("range() step must not be zero");const n=[];if(r>0)for(let s=e;s<t;s+=r)n.push(s);else for(let s=e;s>t;s+=r)n.push(s);return n}function bf(e,t,r,n=1){const s=Math.sign(n);s>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),r=(r??=e.length)<0?Math.max(e.length+r,0):Math.min(r,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),r=(r??=-1)<-1?Math.max(e.length+r,-1):Math.min(r,e.length-1));const a=[];for(let o=t;s*o<s*r;o+=n)a.push(e[o]);return a}function rT(e){return e.replace(/\b\w/g,t=>t.toUpperCase())}function nT(e){return sT(new Date,e)}function sT(e,t){const r=new Intl.DateTimeFormat(void 0,{month:"long"}),n=new Intl.DateTimeFormat(void 0,{month:"short"}),s=a=>a<10?"0"+a:a.toString();return t.replace(/%[YmdbBHM%]/g,a=>{switch(a){case"%Y":return e.getFullYear().toString();case"%m":return s(e.getMonth()+1);case"%d":return s(e.getDate());case"%b":return n.format(e);case"%B":return r.format(e);case"%H":return s(e.getHours());case"%M":return s(e.getMinutes());case"%%":return"%";default:return a}})}function aT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oT(e,t,r,n){if(n===0)return e;let s=n==null||n<0?1/0:n;const a=t.length===0?new RegExp("(?=)","gu"):new RegExp(aT(t),"gu");return e.replaceAll(a,o=>s>0?(--s,r):o)}var Mf=class extends Error{},xf=class extends Error{},iT=new Map,Dt=class{type="RuntimeValue";value;get builtins(){return iT}constructor(e=void 0){this.value=e}__bool__(){return new oe(!!this.value)}toString(){return String(this.value)}},le=class extends Dt{type="IntegerValue"},Ee=class extends Dt{type="FloatValue";toString(){return Object.is(this.value,-0)?"-0.0":this.value%1===0?this.value.toFixed(1):this.value.toString()}},Y=class extends Dt{type="StringValue";_builtins;get builtins(){return this._builtins??=new Map([["upper",new Ne(()=>new Y(this.value.toUpperCase()))],["lower",new Ne(()=>new Y(this.value.toLowerCase()))],["strip",new Ne(()=>new Y(this.value.trim()))],["title",new Ne(()=>new Y(rT(this.value)))],["capitalize",new Ne(()=>new Y(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new le(this.value.length)],["rstrip",new Ne(()=>new Y(this.value.trimEnd()))],["lstrip",new Ne(()=>new Y(this.value.trimStart()))],["startswith",new Ne(e=>{if(e.length===0)throw new Error("startswith() requires at least one argument");const t=e[0];if(t instanceof Y)return new oe(this.value.startsWith(t.value));if(t instanceof fe){for(const r of t.value){if(!(r instanceof Y))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(r.value))return new oe(!0)}return new oe(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new Ne(e=>{if(e.length===0)throw new Error("endswith() requires at least one argument");const t=e[0];if(t instanceof Y)return new oe(this.value.endsWith(t.value));if(t instanceof fe){for(const r of t.value){if(!(r instanceof Y))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(r.value))return new oe(!0)}return new oe(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new Ne(e=>{const t=e[0]??new ze;if(!(t instanceof Y||t instanceof ze))throw new Error("sep argument must be a string or null");const r=e[1]??new le(-1);if(!(r instanceof le))throw new Error("maxsplit argument must be a number");let n=[];if(t instanceof ze){const s=this.value.trimStart();for(const{0:a,index:o}of s.matchAll(/\S+/g)){if(r.value!==-1&&n.length>=r.value&&o!==void 0){n.push(a+s.slice(o+a.length));break}n.push(a)}}else{if(t.value==="")throw new Error("empty separator");n=this.value.split(t.value),r.value!==-1&&n.length>r.value&&n.push(n.splice(r.value).join(t.value))}return new fe(n.map(s=>new Y(s)))})],["replace",new Ne(e=>{if(e.length<2)throw new Error("replace() requires at least two arguments");const t=e[0],r=e[1];if(!(t instanceof Y&&r instanceof Y))throw new Error("replace() arguments must be strings");let n;if(e.length>2?e[2].type==="KeywordArgumentsValue"?n=e[2].value.get("count")??new ze:n=e[2]:n=new ze,!(n instanceof le||n instanceof ze))throw new Error("replace() count argument must be a number or null");return new Y(oT(this.value,t.value,r.value,n.value))})]])}},oe=class extends Dt{type="BooleanValue"},lT=/[\x7f-\uffff]/g;function Tf(e){return e.replace(lT,t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"))}function xr(e,t={},r=0,n=!0){const{indent:s=null,ensureAscii:a=!1,separators:o=null,sortKeys:i=!1}=t;let l,u;switch(o?[l,u]=o:s?(l=",",u=": "):(l=", ",u=": "),e.type){case"NullValue":return"null";case"UndefinedValue":return n?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(e.value);case"StringValue":{let h=JSON.stringify(e.value);return a&&(h=Tf(h)),h}case"ArrayValue":case"NamespaceValue":case"ObjectValue":{const h=s?" ".repeat(s):"",f=`
11
+ `+h.repeat(r),_=f+h;if(e.type==="ArrayValue"){const g=e.value.map(w=>xr(w,t,r+1,n));return s?`[${_}${g.join(`${l}${_}`)}${f}]`:`[${g.join(l)}]`}else{let g=Array.from(e.value.entries());i&&(g=g.sort(([v],[M])=>v.localeCompare(M)));const w=g.map(([v,M])=>{let x=JSON.stringify(v);a&&(x=Tf(x));const k=`${x}${u}${xr(M,t,r+1,n)}`;return s?`${_}${k}`:k});return s?`{${w.join(l)}${f}}`:`{${w.join(l)}}`}}default:throw new Error(`Cannot convert to JSON: ${e.type}`)}}var at=class extends Dt{type="ObjectValue";_builtins;__bool__(){return new oe(this.value.size>0)}get builtins(){return this._builtins??=new Map([["get",new Ne(([e,t])=>{if(!(e instanceof Y))throw new Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new ze})],["items",new Ne(()=>this.items())],["keys",new Ne(()=>this.keys())],["values",new Ne(()=>this.values())],["dictsort",new Ne(e=>{let t=new Map;const r=e.filter(i=>i instanceof $r?(t=i.value,!1):!0),n=r.at(0)??t.get("case_sensitive")??new oe(!1);if(!(n instanceof oe))throw new Error("case_sensitive must be a boolean");const s=r.at(1)??t.get("by")??new Y("key");if(!(s instanceof Y))throw new Error("by must be a string");if(!["key","value"].includes(s.value))throw new Error("by must be either 'key' or 'value'");const a=r.at(2)??t.get("reverse")??new oe(!1);if(!(a instanceof oe))throw new Error("reverse must be a boolean");const o=Array.from(this.value.entries()).map(([i,l])=>new fe([new Y(i),l])).sort((i,l)=>{const u=s.value==="key"?0:1,h=i.value[u],f=l.value[u],_=Jo(h,f,n.value);return a.value?-_:_});return new fe(o)})]])}items(){return new fe(Array.from(this.value.entries()).map(([e,t])=>new fe([new Y(e),t])))}keys(){return new fe(Array.from(this.value.keys()).map(e=>new Y(e)))}values(){return new fe(Array.from(this.value.values()))}toString(){return xr(this,{},0,!1)}},$r=class extends at{type="KeywordArgumentsValue"},Ni=class extends Dt{type="NamespaceValue";toString(){return xr(this,{},0,!1)}},fe=class extends Dt{type="ArrayValue";_builtins;get builtins(){return this._builtins??=new Map([["length",new le(this.value.length)]])}__bool__(){return new oe(this.value.length>0)}toString(){return xr(this,{},0,!1)}},kf=class extends fe{type="TupleValue"},Ne=class extends Dt{type="FunctionValue"},ze=class extends Dt{type="NullValue"},Oe=class extends Dt{type="UndefinedValue"};function cT(e){let t;if(e instanceof fe?t=e.value:e instanceof Y&&(t=Array.from(e.value,s=>new Y(s))),!t||t.length!==2)throw new Error("namespace expected an object or an iterable of [key, value] pairs");const[r,n]=t;if(!(r instanceof Y))throw new Error("namespace keys must be strings");return[r,n]}var gp=class{constructor(e){this.parent=e}variables=new Map([["namespace",new Ne(e=>{const t=e.slice();let r;if(t.at(-1)instanceof $r&&(r=t.pop()),t.length>1)throw new Error(`namespace expected at most 1 argument, got ${t.length}`);const n=new Map;if(t.length===1){const s=t[0];if(s instanceof at)for(const[a,o]of s.value)n.set(a,o);else if(s instanceof fe)for(const a of s.value){const[o,i]=cT(a);n.set(o.value,i)}else throw new Error(`'${s.type}' object is not iterable`)}if(r)for(const[s,a]of r.value)n.set(s,a);return new Ni(n)})]]);tests=gp.TESTS;set(e,t){return this.declareVariable(e,Gs(t))}declareVariable(e,t){if(this.variables.has(e))throw new 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 new Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new Oe}catch{return new Oe}}},gr=gp;C1(gr,"TESTS",new Map([["boolean",e=>e.type==="BooleanValue"],["callable",e=>e instanceof Ne],["odd",e=>{if(!(e instanceof le))throw new Error(`cannot odd on ${e.type}`);return e.value%2!==0}],["even",e=>{if(!(e instanceof le))throw new 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 le||e instanceof Ee],["integer",e=>e instanceof le],["iterable",e=>e.type==="ArrayValue"||e.type==="StringValue"],["mapping",e=>e instanceof at],["sequence",e=>e instanceof fe||e instanceof at||e instanceof Y],["lower",e=>{const t=e.value;return e.type==="StringValue"&&t===t.toLowerCase()}],["upper",e=>{const 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]]));function uT(e){e.set("false",!1),e.set("true",!0),e.set("none",null),e.set("raise_exception",t=>{throw new Error(t)}),e.set("range",tT),e.set("strftime_now",nT),e.set("True",!0),e.set("False",!1),e.set("None",null)}function $s(e){return e instanceof at||e instanceof Ni}function ea(e){return e instanceof le||e instanceof Ee||e instanceof oe}function ta(e){return e instanceof oe?Number(e.value):e.value}function Ef(e,t){const r=t.split(".");let n=e;for(const s of r)if($s(n))n=n.value.get(s)??new Oe;else if(n instanceof fe){const a=parseInt(s,10);if(!isNaN(a)&&a>=0&&a<n.value.length)n=n.value[a];else return new Oe}else return new Oe;return n}function Jo(e,t,r=!1){if(e instanceof ze&&t instanceof ze)return 0;if(e instanceof ze||t instanceof ze)throw new Error(`Cannot compare ${e.type} with ${t.type}`);if(e instanceof Oe&&t instanceof Oe)return 0;if(e instanceof Oe||t instanceof Oe)throw new Error(`Cannot compare ${e.type} with ${t.type}`);if(ea(e)&&ea(t)){const n=ta(e),s=ta(t);return n<s?-1:n>s?1:0}if(e.type!==t.type)throw new Error(`Cannot compare different types: ${e.type} and ${t.type}`);if(e.type==="StringValue"){let n=e.value,s=t.value;return r||(n=n.toLowerCase(),s=s.toLowerCase()),n<s?-1:n>s?1:0}else throw new Error(`Cannot compare type: ${e.type}`)}function Ko(e){if(e.type==="Identifier")return{name:e.value};const t=e;return{name:t.key.value,defaultValue:t.value}}function Cf(e){return e==="kwargs"||e==="varargs"}function Af(e,t){const r=new Set,n=new Set,s=h=>{Cf(h)&&r.add(h)},a=h=>{if(h.type==="Identifier")s(h.value);else if(h.type==="TupleLiteral")for(const f of h.value)a(f)},o=h=>{s(Ko(h).name)},i=h=>{for(const f of h){const _=Ko(f);_.defaultValue&&u(_.defaultValue)}},l=h=>{h.type==="CallExpression"&&u(h.args)},u=h=>{if(Array.isArray(h)){for(const f of h)u(f);return}if(h instanceof Map){for(const[f,_]of h)u(f),u(_);return}if(h instanceof kt)switch(h.type){case"For":{const f=h;if(a(f.loopvar),f.iterable.type==="SelectExpression"){const _=f.iterable;u(_.lhs),u(f.body),u(f.defaultBlock),u(_.test);return}u(f.iterable),u(f.body),u(f.defaultBlock);return}case"Set":{const f=h;a(f.assignee),u(f.value),u(f.body);return}case"Macro":{const f=h;for(const _ of f.args)o(_);i(f.args),u(f.body);return}case"CallStatement":{const f=h;u(f.call);for(const _ of f.callerArgs??[])o(_);i(f.callerArgs??[]),u(f.body);return}case"FilterStatement":{const f=h;u(f.body),l(f.filter);return}case"Identifier":{const f=h.value;Cf(f)&&!r.has(f)&&n.add(f);return}case"MemberExpression":{const f=h;u(f.object),f.computed&&u(f.property);return}case"FilterExpression":{const f=h;u(f.operand),l(f.filter);return}case"TestExpression":u(h.operand);return;case"SelectExpression":{const f=h;u(f.test),u(f.lhs);return}case"KeywordArgumentExpression":u(h.value);return;default:for(const f of Object.values(h))u(f)}};for(const h of e)o(h);return u(t),n}var dT=class{global;constructor(e){this.global=e??new gr}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){const r=this.evaluate(e.left,t);switch(e.operator.value){case"and":return r.__bool__().value?this.evaluate(e.right,t):r;case"or":return r.__bool__().value?r:this.evaluate(e.right,t)}const n=this.evaluate(e.right,t);switch(e.operator.value){case"==":return new oe(r.value==n.value);case"!=":return new oe(r.value!=n.value)}if(r instanceof Oe||n instanceof Oe){if(n instanceof Oe&&["in","not in"].includes(e.operator.value))return new oe(e.operator.value==="not in");throw new Error(`Cannot perform operation ${e.operator.value} on undefined values`)}else{if(r instanceof ze||n instanceof ze)throw new Error("Cannot perform operation on null values");if(e.operator.value==="~")return new Y(r.value.toString()+n.value.toString());if(e.operator.value==="**"&&ea(r)&&ea(n)){const s=ta(r),a=ta(n);if(s===0&&a<0)throw new Error("0.0 cannot be raised to a negative power");const o=s**a;if(!Number.isFinite(o))throw new Error("Exponentiation result is not a finite real number");return r instanceof Ee||n instanceof Ee||a<0?new Ee(o):new le(o)}else if((r instanceof le||r instanceof Ee)&&(n instanceof le||n instanceof Ee)){const s=r.value,a=n.value;switch(e.operator.value){case"+":case"-":case"*":{const o=e.operator.value==="+"?s+a:e.operator.value==="-"?s-a:s*a;return r instanceof Ee||n instanceof Ee?new Ee(o):new le(o)}case"/":return new Ee(s/a);case"//":{const o=Math.floor(s/a);return r instanceof Ee||n instanceof Ee?new Ee(o):new le(o)}case"%":{const o=s%a;return r instanceof Ee||n instanceof Ee?new Ee(o):new le(o)}case"<":return new oe(s<a);case">":return new oe(s>a);case">=":return new oe(s>=a);case"<=":return new oe(s<=a)}}else if(r instanceof fe&&n instanceof fe){if(e.operator.value==="+")return new fe(r.value.concat(n.value))}else if(n instanceof fe){const s=n.value.find(a=>a.value===r.value)!==void 0;switch(e.operator.value){case"in":return new oe(s);case"not in":return new oe(!s)}}}if((r instanceof Y||n instanceof Y)&&e.operator.value==="+")return new Y(r.value.toString()+n.value.toString());if(r instanceof Y&&n instanceof Y)switch(e.operator.value){case"in":return new oe(n.value.includes(r.value));case"not in":return new oe(!n.value.includes(r.value))}if(r instanceof Y&&n instanceof at)switch(e.operator.value){case"in":return new oe(n.value.has(r.value));case"not in":return new oe(!n.value.has(r.value))}throw new SyntaxError(`Unknown operator "${e.operator.value}" between ${r.type} and ${n.type}`)}evaluateArguments(e,t){const r=[],n=new Map,s=(a,o)=>{if(n.has(a))throw new Error(`Got multiple values for keyword argument '${a}'`);n.set(a,o)};for(const a of e)if(a.type==="SpreadExpression"){const o=a,i=this.evaluate(o.argument,t);if(!(i instanceof fe))throw new Error(`Cannot unpack non-iterable type: ${i.type}`);for(const l of i.value)r.push(l)}else a.type!=="KeywordArgumentExpression"&&a.type!=="KeywordSpreadExpression"&&r.push(this.evaluate(a,t));for(const a of e)if(a.type==="KeywordArgumentExpression"){const o=a;s(o.key.value,this.evaluate(o.value,t))}else if(a.type==="KeywordSpreadExpression"){const o=a,i=this.evaluate(o.argument,t);if(!(i instanceof at))throw new Error(`Argument after ** must be a mapping, not ${i.type}`);for(const[l,u]of i.value)s(l,u)}return[r,n]}applyFilter(e,t,r){if(t.type==="Identifier"){const n=t;if(n.value==="safe")return e;if(n.value==="tojson")return new Y(xr(e,{}));if(e instanceof fe)switch(n.value){case"list":return e;case"first":return e.value[0];case"last":return e.value[e.value.length-1];case"length":return new le(e.value.length);case"reverse":return new fe(e.value.slice().reverse());case"sort":return new fe(e.value.slice().sort((s,a)=>Jo(s,a,!1)));case"join":return new Y(e.value.map(s=>s.value).join(""));case"string":return new Y(xr(e,{},0,!1));case"unique":{const s=new Set,a=[];for(const o of e.value)s.has(o.value)||(s.add(o.value),a.push(o));return new fe(a)}default:throw new Error(`Unknown ArrayValue filter: ${n.value}`)}else if(e instanceof Y)switch(n.value){case"length":case"upper":case"lower":case"title":case"capitalize":{const s=e.builtins.get(n.value);if(s instanceof Ne)return s.value([],r);if(s instanceof le)return s;throw new Error(`Unknown StringValue filter: ${n.value}`)}case"trim":return new Y(e.value.trim());case"indent":return new Y(e.value.split(`
12
+ `).map((s,a)=>a===0||s.length===0?s:" "+s).join(`
13
+ `));case"join":case"string":return e;case"int":{const s=parseInt(e.value,10);return new le(isNaN(s)?0:s)}case"float":{const s=parseFloat(e.value);return new Ee(isNaN(s)?0:s)}default:throw new Error(`Unknown StringValue filter: ${n.value}`)}else if(e instanceof le||e instanceof Ee)switch(n.value){case"abs":return e instanceof le?new le(Math.abs(e.value)):new Ee(Math.abs(e.value));case"int":return new le(Math.floor(e.value));case"float":return new Ee(e.value);case"string":return new Y(e.toString());default:throw new Error(`Unknown NumericValue filter: ${n.value}`)}else if(e instanceof at)switch(n.value){case"items":return new fe(Array.from(e.value.entries()).map(([s,a])=>new fe([new Y(s),a])));case"length":return new le(e.value.size);default:{const s=e.builtins.get(n.value);if(s)return s instanceof Ne?s.value([],r):s;throw new Error(`Unknown ObjectValue filter: ${n.value}`)}}else if(e instanceof oe)switch(n.value){case"bool":return new oe(e.value);case"int":return new le(e.value?1:0);case"float":return new Ee(e.value?1:0);case"string":return new Y(e.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${n.value}`)}throw new Error(`Cannot apply filter "${n.value}" to type: ${e.type}`)}else if(t.type==="CallExpression"){const n=t;if(n.callee.type!=="Identifier")throw new Error(`Unknown filter: ${n.callee.type}`);const s=n.callee.value;if(s==="tojson"){const[,a]=this.evaluateArguments(n.args,r),o=a.get("indent")??new ze;if(!(o instanceof le||o instanceof ze))throw new Error("If set, indent must be a number");const i=a.get("ensure_ascii")??new oe(!1);if(!(i instanceof oe))throw new Error("If set, ensure_ascii must be a boolean");const l=a.get("sort_keys")??new oe(!1);if(!(l instanceof oe))throw new Error("If set, sort_keys must be a boolean");const u=a.get("separators")??new ze;let h=null;if(u instanceof fe||u instanceof kf){if(u.value.length!==2)throw new Error("separators must be a tuple of two strings");const[f,_]=u.value;if(!(f instanceof Y)||!(_ instanceof Y))throw new Error("separators must be a tuple of two strings");h=[f.value,_.value]}else if(!(u instanceof ze))throw new Error("If set, separators must be a tuple of two strings");return new Y(xr(e,{indent:o.value,ensureAscii:i.value,sortKeys:l.value,separators:h}))}else if(s==="join"){let a;if(e instanceof Y)a=Array.from(e.value);else if(e instanceof fe)a=e.value.map(u=>u.value);else throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`);const[o,i]=this.evaluateArguments(n.args,r),l=o.at(0)??i.get("separator")??new Y("");if(!(l instanceof Y))throw new Error("separator must be a string");return new Y(a.join(l.value))}else if(s==="int"||s==="float"){const[a,o]=this.evaluateArguments(n.args,r),i=a.at(0)??o.get("default")??(s==="int"?new le(0):new Ee(0));if(e instanceof Y){const l=s==="int"?parseInt(e.value,10):parseFloat(e.value);return isNaN(l)?i:s==="int"?new le(l):new Ee(l)}else{if(e instanceof le||e instanceof Ee)return e;if(e instanceof oe)return s==="int"?new le(e.value?1:0):new Ee(e.value?1:0);throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`)}}else if(s==="default"){const[a,o]=this.evaluateArguments(n.args,r),i=a[0]??new Y(""),l=a[1]??o.get("boolean")??new oe(!1);if(!(l instanceof oe))throw new Error("`default` filter flag must be a boolean");return e instanceof Oe||l.value&&!e.__bool__().value?i:e}if(e instanceof fe){switch(s){case"sort":{const[a,o]=this.evaluateArguments(n.args,r),i=a.at(0)??o.get("reverse")??new oe(!1);if(!(i instanceof oe))throw new Error("reverse must be a boolean");const l=a.at(1)??o.get("case_sensitive")??new oe(!1);if(!(l instanceof oe))throw new Error("case_sensitive must be a boolean");const u=a.at(2)??o.get("attribute")??new ze;if(!(u instanceof Y||u instanceof le||u instanceof ze))throw new Error("attribute must be a string, integer, or null");const h=f=>{if(u instanceof ze)return f;const _=u instanceof le?String(u.value):u.value;return Ef(f,_)};return new fe(e.value.slice().sort((f,_)=>{const g=h(f),w=h(_),v=Jo(g,w,l.value);return i.value?-v:v}))}case"selectattr":case"rejectattr":{const a=s==="selectattr";if(e.value.some(f=>!$s(f)))throw new Error(`\`${s}\` can only be applied to array of objects`);if(n.args.some(f=>f.type!=="StringLiteral"))throw new Error(`arguments of \`${s}\` must be strings`);const[o,i,l]=n.args.map(f=>this.evaluate(f,r));let u;if(i){const f=r.tests.get(i.value);if(!f)throw new Error(`Unknown test: ${i.value}`);u=f}else u=(...f)=>f[0].__bool__().value;const h=e.value.filter(f=>{const _=f.value.get(o.value),g=_?u(_,l):!1;return a?g:!g});return new fe(h)}case"map":{const[,a]=this.evaluateArguments(n.args,r);if(a.has("attribute")){const o=a.get("attribute");if(!(o instanceof Y))throw new Error("attribute must be a string");const i=a.get("default"),l=e.value.map(u=>{if(!$s(u))throw new Error("items in map must be an object");const h=Ef(u,o.value);return h instanceof Oe?i??new Oe:h});return new fe(l)}else throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${s}`)}else if(e instanceof Y){switch(s){case"indent":{const[a,o]=this.evaluateArguments(n.args,r),i=a.at(0)??o.get("width")??new le(4);if(!(i instanceof le))throw new Error("width must be a number");const l=a.at(1)??o.get("first")??new oe(!1),u=a.at(2)??o.get("blank")??new oe(!1),h=e.value.split(`
14
+ `),f=" ".repeat(i.value),_=h.map((g,w)=>!l.value&&w===0||!u.value&&g.length===0?g:f+g);return new Y(_.join(`
15
+ `))}case"replace":{const a=e.builtins.get("replace");if(!(a instanceof Ne))throw new Error("replace filter not available");const[o,i]=this.evaluateArguments(n.args,r);return a.value([...o,new $r(i)],r)}}throw new Error(`Unknown StringValue filter: ${s}`)}else if(e instanceof at){const a=e.builtins.get(s);if(a&&a instanceof Ne){const[o,i]=this.evaluateArguments(n.args,r);return i.size>0&&o.push(new $r(i)),a.value(o,r)}throw new Error(`Unknown ObjectValue filter: ${s}`)}else throw new Error(`Cannot apply filter "${s}" to type: ${e.type}`)}throw new Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){const r=this.evaluate(e.operand,t);return this.applyFilter(r,e.filter,t)}evaluateTestExpression(e,t){const r=this.evaluate(e.operand,t),n=t.tests.get(e.test.value);if(!n)throw new Error(`Unknown test: ${e.test.value}`);const s=n(r);return new oe(e.negate?!s:s)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new Oe}evaluateUnaryExpression(e,t){const r=this.evaluate(e.argument,t);switch(e.operator.value){case"not":return new oe(!r.value);case"+":case"-":{const n=e.operator.value==="-"?-1:1;if(r instanceof le||r instanceof Ee||r instanceof oe){const s=r instanceof oe?r.value?1:0:r.value,a=n*s;return r instanceof Ee?new Ee(a):new le(a)}throw new SyntaxError(`Unknown operator "${e.operator.value}" for ${r.type}`)}default:throw new 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 r="";for(const n of e){const s=this.evaluate(n,t);s.type!=="NullValue"&&s.type!=="UndefinedValue"&&(r+=s.toString())}return new Y(r)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){const[r,n]=this.evaluateArguments(e.args,t);n.size>0&&r.push(new $r(n));const s=this.evaluate(e.callee,t);if(s.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${s.type}`);return s.value(r,t)}evaluateSliceExpression(e,t,r){if(!(e instanceof fe||e instanceof Y))throw new Error("Slice object must be an array or string");const n=this.evaluate(t.start,r),s=this.evaluate(t.stop,r),a=this.evaluate(t.step,r);if(!(n instanceof le||n instanceof Oe))throw new Error("Slice start must be numeric or undefined");if(!(s instanceof le||s instanceof Oe))throw new Error("Slice stop must be numeric or undefined");if(!(a instanceof le||a instanceof Oe))throw new Error("Slice step must be numeric or undefined");return e instanceof fe?new fe(bf(e.value,n.value,s.value,a.value)):new Y(bf(Array.from(e.value),n.value,s.value,a.value).join(""))}evaluateMemberExpression(e,t){const r=this.evaluate(e.object,t);let n;if(e.computed){if(e.property.type==="SliceExpression")return this.evaluateSliceExpression(r,e.property,t);n=this.evaluate(e.property,t)}else e.property.type==="IntegerLiteral"?n=new le(e.property.value):n=new Y(e.property.value);let s;if($s(r)){if(!(n instanceof Y))throw new Error(`Cannot access property with non-string: got ${n.type}`);s=r.value.get(n.value)??(r instanceof at?r.builtins.get(n.value):void 0)}else if(r instanceof fe||r instanceof Y)if(n instanceof le)s=r.value.at(n.value),r instanceof Y&&(s=new Y(r.value.at(n.value)));else if(n instanceof Y)s=r.builtins.get(n.value);else throw new Error(`Cannot access property with non-string/non-number: got ${n.type}`);else{if(!(n instanceof Y))throw new Error(`Cannot access property with non-string: got ${n.type}`);s=r.builtins.get(n.value)}return s instanceof Dt?s:new Oe}evaluateSet(e,t){const r=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if(e.assignee.type==="Identifier"){const n=e.assignee.value;t.setVariable(n,r)}else if(e.assignee.type==="TupleLiteral"){const n=e.assignee;if(!(r instanceof fe))throw new Error(`Cannot unpack non-iterable type in set: ${r.type}`);const s=r.value;if(s.length!==n.value.length)throw new Error(`Too ${n.value.length>s.length?"few":"many"} items to unpack in set`);for(let a=0;a<n.value.length;++a){const o=n.value[a];if(o.type!=="Identifier")throw new Error(`Cannot unpack to non-identifier in set: ${o.type}`);t.setVariable(o.value,s[a])}}else if(e.assignee.type==="MemberExpression"){const n=e.assignee,s=this.evaluate(n.object,t);if(!(s instanceof Ni))throw new Error("cannot assign attribute on non-namespace object");if(n.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");s.value.set(n.property.value,r)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(e.assignee)}`);return new ze}evaluateIf(e,t){const r=this.evaluate(e.test,t);return this.evaluateBlock(r.__bool__().value?e.body:e.alternate,t)}evaluateFor(e,t){const r=new gr(t);let n,s;if(e.iterable.type==="SelectExpression"){const u=e.iterable;s=this.evaluate(u.lhs,r),n=u.test}else s=this.evaluate(e.iterable,r);if(!(s instanceof fe||s instanceof at))throw new Error(`Expected iterable or object type in for loop: got ${s.type}`);s instanceof at&&(s=s.keys());const a=[],o=[];for(let u=0;u<s.value.length;++u){const h=new gr(r),f=s.value[u];let _;if(e.loopvar.type==="Identifier")_=g=>g.setVariable(e.loopvar.value,f);else if(e.loopvar.type==="TupleLiteral"){const g=e.loopvar;if(f.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${f.type}`);const w=f;if(g.value.length!==w.value.length)throw new Error(`Too ${g.value.length>w.value.length?"few":"many"} items to unpack`);_=v=>{for(let M=0;M<g.value.length;++M){if(g.value[M].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${g.value[M].type}`);v.setVariable(g.value[M].value,w.value[M])}}}else throw new Error(`Invalid loop variable(s): ${e.loopvar.type}`);n&&(_(h),!this.evaluate(n,h).__bool__().value)||(a.push(f),o.push(_))}let i="",l=!0;for(let u=0;u<a.length;++u){const h=new Map([["index",new le(u+1)],["index0",new le(u)],["revindex",new le(a.length-u)],["revindex0",new le(a.length-u-1)],["first",new oe(u===0)],["last",new oe(u===a.length-1)],["length",new le(a.length)],["previtem",u>0?a[u-1]:new Oe],["nextitem",u<a.length-1?a[u+1]:new Oe]]);r.setVariable("loop",new at(h)),o[u](r);try{const f=this.evaluateBlock(e.body,r);i+=f.value}catch(f){if(f instanceof xf)continue;if(f instanceof Mf)break;throw f}l=!1}if(l){const u=this.evaluateBlock(e.defaultBlock,r);i+=u.value}return new Y(i)}bindMacroArguments(e,t,r,n,s){const a=n.slice();let o=new Map;a.at(-1)instanceof $r&&(o=new Map(a.pop().value));const i=[];for(let l=0;l<t.length;++l){const{name:u,defaultValue:h}=Ko(t[l]);let f=a[l];f===void 0&&o.has(u)&&(f=o.get(u),o.delete(u)),f===void 0&&h!==void 0&&i.push([u,h]),s.setVariable(u,f??new Oe)}if(r.has("kwargs"))s.setVariable("kwargs",new at(o));else if(o.size>0)throw new Error(`macro ${e} takes no keyword argument '${o.keys().next().value}'`);if(r.has("varargs"))s.setVariable("varargs",new fe(a.slice(t.length)));else if(a.length>t.length)throw new Error(`macro ${e} takes not more than ${t.length} argument(s)`);for(const[l,u]of i)s.setVariable(l,this.evaluate(u,s))}evaluateMacro(e,t){const r=Af(e.args,e.body);return t.setVariable(e.name.value,new Ne((n,s)=>{const a=new gr(s);return this.bindMacroArguments(`'${e.name.value}'`,e.args,r,n,a),this.evaluateBlock(e.body,a)})),new ze}evaluateCallStatement(e,t){const r=e.callerArgs??[],n=Af(r,e.body),s=new Ne(u=>{const h=new gr(t);return this.bindMacroArguments("None",r,n,u,h),this.evaluateBlock(e.body,h)}),[a,o]=this.evaluateArguments(e.call.args,t);a.push(new $r(o));const i=this.evaluate(e.call.callee,t);if(i.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${i.type}`);const l=new gr(t);return l.setVariable("caller",s),i.value(a,l)}evaluateFilterStatement(e,t){const r=this.evaluateBlock(e.body,t);return this.applyFilter(r,e.filter,t)}evaluate(e,t){if(!e)return new Oe;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 Mf;case"Continue":throw new xf;case"IntegerLiteral":return new le(e.value);case"FloatLiteral":return new Ee(e.value);case"StringLiteral":return new Y(e.value);case"ArrayLiteral":return new fe(e.value.map(r=>this.evaluate(r,t)));case"TupleLiteral":return new kf(e.value.map(r=>this.evaluate(r,t)));case"ObjectLiteral":{const r=new Map;for(const[n,s]of e.value){const a=this.evaluate(n,t);if(!(a instanceof Y))throw new Error(`Object keys must be strings: got ${a.type}`);r.set(a.value,this.evaluate(s,t))}return new at(r)}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 ze;default:throw new SyntaxError(`Unknown node type: ${e.type}`)}}};function Gs(e){switch(typeof e){case"number":return Number.isInteger(e)?new le(e):new Ee(e);case"string":return new Y(e);case"boolean":return new oe(e);case"undefined":return new Oe;case"object":return e===null?new ze:Array.isArray(e)?new fe(e.map(Gs)):new at(new Map(Object.entries(e).map(([t,r])=>[t,Gs(r)])));case"function":return new Ne((t,r)=>{const n=e(...t.map(s=>s.value))??null;return Gs(n)});default:throw new Error(`Cannot convert to runtime value: ${e}`)}}var Xe=`
16
+ `,hT="{%- ",fT=" -%}",Ge=Object.freeze({CONDITIONAL:0,LOGICAL_OR:1,LOGICAL_AND:2,LOGICAL_NOT:3,COMPARISON:4,ADDITIVE:5,MULTIPLICATIVE:6,EXPONENTIATION:7,TEST:8,FILTER:9,UNARY_SIGN:10,ATOM:11});function wp(e){switch(e.operator.type){case"ExponentiationBinaryOperator":return Ge.EXPONENTIATION;case"MultiplicativeBinaryOperator":return Ge.MULTIPLICATIVE;case"AdditiveBinaryOperator":return Ge.ADDITIVE;case"ComparisonBinaryOperator":return Ge.COMPARISON;case"Identifier":return e.operator.value==="and"?Ge.LOGICAL_AND:e.operator.value==="in"||e.operator.value==="not in"?Ge.COMPARISON:Ge.LOGICAL_OR}return Ge.LOGICAL_OR}function vp(e){switch(e.type){case"SelectExpression":case"Ternary":return Ge.CONDITIONAL;case"BinaryExpression":return wp(e);case"UnaryExpression":return e.operator.value==="not"?Ge.LOGICAL_NOT:Ge.UNARY_SIGN;case"TestExpression":return Ge.TEST;case"FilterExpression":return Ge.FILTER;default:return Ge.ATOM}}function St(e,t){const r=Re(e);return vp(e)<t?`(${r})`:r}function _T(e,t=" "){const r=typeof t=="number"?" ".repeat(t):t;return Lt(e.body,0,r).replace(/\n$/,"")}function tt(...e){return hT+e.join(" ")+fT}function Lt(e,t,r){return e.map(n=>pT(n,t,r)).join(Xe)}function ra(e){return e.map(t=>Re(t)).join(", ")}function pT(e,t,r){const n=r.repeat(t);switch(e.type){case"Program":return Lt(e.body,t,r);case"If":return mT(e,t,r);case"For":return gT(e,t,r);case"Set":return wT(e,t,r);case"Macro":return vT(e,t,r);case"Break":return n+tt("break");case"Continue":return n+tt("continue");case"CallStatement":return yT(e,t,r);case"FilterStatement":return bT(e,t,r);case"Comment":return n+"{# "+e.value+" #}";default:return n+"{{- "+Re(e)+" -}}"}}function mT(e,t,r){const n=r.repeat(t),s=[];let a=e;for(;a&&(s.push({test:a.test,body:a.body}),a.alternate.length===1&&a.alternate[0].type==="If");)a=a.alternate[0];let o=n+tt("if",Re(s[0].test))+Xe+Lt(s[0].body,t+1,r);for(let i=1;i<s.length;++i)o+=Xe+n+tt("elif",Re(s[i].test))+Xe+Lt(s[i].body,t+1,r);return a&&a.alternate.length>0&&(o+=Xe+n+tt("else")+Xe+Lt(a.alternate,t+1,r)),o+=Xe+n+tt("endif"),o}function gT(e,t,r){const n=r.repeat(t);let s="";if(e.iterable.type==="SelectExpression"){const o=e.iterable;s=`${Re(o.lhs)} if ${Re(o.test)}`}else s=Re(e.iterable);let a=n+tt("for",Re(e.loopvar),"in",s)+Xe+Lt(e.body,t+1,r);return e.defaultBlock.length>0&&(a+=Xe+n+tt("else")+Xe+Lt(e.defaultBlock,t+1,r)),a+=Xe+n+tt("endfor"),a}function wT(e,t,r){const n=r.repeat(t),s=Re(e.assignee),a=e.value?Re(e.value):"",o=n+tt("set",`${s}${e.value?" = "+a:""}`);return e.body.length===0?o:o+Xe+Lt(e.body,t+1,r)+Xe+n+tt("endset")}function vT(e,t,r){const n=r.repeat(t),s=ra(e.args);return n+tt("macro",`${e.name.value}(${s})`)+Xe+Lt(e.body,t+1,r)+Xe+n+tt("endmacro")}function yT(e,t,r){const n=r.repeat(t),s=e.callerArgs&&e.callerArgs.length>0?`(${ra(e.callerArgs)})`:"",a=Re(e.call);let o=n+tt(`call${s}`,a)+Xe;return o+=Lt(e.body,t+1,r)+Xe,o+=n+tt("endcall"),o}function bT(e,t,r){const n=r.repeat(t),s=e.filter.type==="Identifier"?e.filter.value:Re(e.filter);let a=n+tt("filter",s)+Xe;return a+=Lt(e.body,t+1,r)+Xe,a+=n+tt("endfilter"),a}function Re(e){switch(e.type){case"SpreadExpression":return`*${Re(e.argument)}`;case"KeywordSpreadExpression":return`**${Re(e.argument)}`;case"Identifier":return e.value;case"IntegerLiteral":return`${e.value}`;case"FloatLiteral":{const t=e.value;return Object.is(t,-0)?"-0.0":t%1===0?t.toFixed(1):t.toString()}case"StringLiteral":return JSON.stringify(e.value);case"BinaryExpression":{const t=e,r=wp(t),n=St(t.left,r),s=St(t.right,r+1);return`${n} ${t.operator.value} ${s}`}case"UnaryExpression":{const t=e,r=t.argument.type==="UnaryExpression"?vp(t):Ge.ATOM;return t.operator.value+(t.operator.value==="not"?" ":"")+St(t.argument,r)}case"CallExpression":{const t=e,r=ra(t.args);return`${Re(t.callee)}(${r})`}case"MemberExpression":{const t=e,r=St(t.object,Ge.ATOM);let n=Re(t.property);return!t.computed&&t.property.type!=="Identifier"&&t.property.type!=="IntegerLiteral"&&(n=`(${n})`),t.computed?`${r}[${n}]`:`${r}.${n}`}case"FilterExpression":{const t=e,r=St(t.operand,Ge.FILTER);return t.filter.type==="CallExpression"?`${r} | ${Re(t.filter)}`:`${r} | ${t.filter.value}`}case"SelectExpression":{const t=e;return`${St(t.lhs,Ge.LOGICAL_OR)} if ${St(t.test,Ge.LOGICAL_OR)}`}case"TestExpression":{const t=e;return`${St(t.operand,Ge.TEST)} is${t.negate?" not":""} ${t.test.value}`}case"ArrayLiteral":case"TupleLiteral":{const t=ra(e.value),r=e.type==="ArrayLiteral"?"[]":"()";return`${r[0]}${t}${r[1]}`}case"ObjectLiteral":return`{${Array.from(e.value.entries()).map(([r,n])=>`${Re(r)}: ${Re(n)}`).join(", ")}}`;case"SliceExpression":{const t=e,r=t.start?Re(t.start):"",n=t.stop?Re(t.stop):"",s=t.step?`:${Re(t.step)}`:"";return`${r}:${n}${s}`}case"KeywordArgumentExpression":{const t=e;return`${t.key.value}=${Re(t.value)}`}case"Ternary":{const t=e;return`${St(t.trueExpr,Ge.LOGICAL_OR)} if ${St(t.condition,Ge.LOGICAL_OR)} else ${St(t.falseExpr,Ge.CONDITIONAL)}`}default:throw new Error(`Unknown expression type: ${e.type}`)}}var MT=class{parsed;constructor(e){const t=F1(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=eT(t)}render(e){const t=new gr;if(uT(t),e)for(const[s,a]of Object.entries(e))t.set(s,a);return new dT(t).run(this.parsed).value}format(e){return _T(this.parsed,e?.indent||" ")}},xT={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"},na=class yp{constructor(t){if(this.filePath=t,this.headers=new Headers,this.exists=gt.existsSync(t),this.exists){this.status=200,this.statusText="OK";let r=gt.statSync(t);this.headers.set("content-length",r.size.toString()),this.updateContentType();const n=gt.createReadStream(t);this.body=new ReadableStream({start(s){n.on("data",a=>s.enqueue(a)),n.on("end",()=>s.close()),n.on("error",a=>s.error(a))},cancel(){n.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){const t=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",xT[t]??"application/octet-stream")}clone(){let t=new yp(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 gt.promises.readFile(this.filePath)).buffer}async blob(){const t=await gt.promises.readFile(this.filePath);return new Blob([t],{type:this.headers.get("content-type")})}async text(){return await gt.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}},ha=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(_e.IS_CRYPTO_AVAILABLE){const o=new Uint32Array(1);crypto.getRandomValues(o),e=o[0]}else e=Date.now()>>>0;const t=this._mt,r=(o,i)=>Math.imul(o,i)>>>0,n=[];for(let o=e||0;o>0;o=Math.floor(o/4294967296))n.push(o&4294967295);n.length||n.push(0),t[0]=19650218;for(let o=1;o<624;++o)t[o]=r(1812433253,t[o-1]^t[o-1]>>>30)+o>>>0;let s=1,a=0;for(let o=Math.max(624,n.length);o>0;--o,++s,++a)s>=624&&(t[0]=t[623],s=1),a>=n.length&&(a=0),t[s]=(t[s]^r(t[s-1]^t[s-1]>>>30,1664525))+n[a]+a>>>0;for(let o=623;o>0;--o,++s)s>=624&&(t[0]=t[623],s=1),t[s]=(t[s]^r(t[s-1]^t[s-1]>>>30,1566083941))-s>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){const e=this._mt;if(this._idx>=624){for(let r=0;r<624;++r){const n=e[r]&2147483648|e[(r+1)%624]&2147483647;e[r]=(e[(r+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let 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 r=this._gauss_next;if(this._gauss_next=null,r===null){const n=this.random()*2*Math.PI,s=Math.sqrt(-2*Math.log(1-this.random()));r=Math.cos(n)*s,this._gauss_next=Math.sin(n)*s}return e+r*t}shuffle(e){for(let t=e.length-1;t>0;--t){const r=32-Math.clz32(t+1);let n=this._int32()>>>32-r;for(;n>t;)n=this._int32()>>>32-r;const s=e[t];e[t]=e[n],e[n]=s}}choices(e,t){return e[bp(this._random_fn,t)]}};function bp(e,t){let r=0;for(let s=0;s<t.length;++s)r+=t[s];let n=e()*r;for(let s=0;s<t.length;++s)if(n-=t[s],n<0)return s;return t.length-1}var Vt=new ha,Di=Object.freeze({Random:ha,seed:Vt.seed.bind(Vt),random:Vt.random.bind(Vt),gauss:Vt.gauss.bind(Vt),shuffle:Vt.shuffle.bind(Vt),choices:Vt.choices.bind(Vt)}),TT=e=>bp(Di.random,e),kT=new ha,Mp=class{constructor(e){this.path=e}async match(e){let t=jt.join(this.path,e),r=new na(t);if(r.exists)return r}async put(e,t,r=void 0){const n=jt.join(this.path,e),s=_e.IS_PROCESS_AVAILABLE?process.pid:Date.now(),a=kT._int32().toString(36),o=n+`.tmp.${s}.${a}`;try{const i=t.headers.get("Content-Length"),l=parseInt(i??"0");let u=0;await gt.promises.mkdir(jt.dirname(n),{recursive:!0});const h=gt.createWriteStream(o),f=t.body.getReader();for(;;){const{done:_,value:g}=await f.read();if(_)break;await new Promise((v,M)=>{h.write(g,x=>{if(x){M(x);return}v()})}),u+=g.length;const w=l?u/l*100:0;r?.({progress:w,loaded:u,total:l})}await new Promise((_,g)=>{h.close(w=>w?g(w):_())}),await gt.promises.rename(o,n)}catch(i){try{await gt.promises.unlink(o)}catch{}throw i}}async delete(e){let t=jt.join(this.path,e);try{return await gt.promises.unlink(t),!0}catch{return!1}}},ET={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"},Sf=100,CT=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function Fs(...e){return e=e.map((t,r)=>(r&&(t=t.replace(new RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(new RegExp("/$"),"")),t)),e.join("/")}function qr(e,t=null,r=null){let n;try{n=new URL(e)}catch{return!1}return!(t&&!t.includes(n.protocol)||r&&!r.includes(n.hostname))}function AT(e){return!(!CT.test(e)||e.includes("..")||e.includes("--")||e.endsWith(".git")||e.endsWith(".ipynb"))}function Bi(e,t={},...r){return JSON.stringify([e,t.revision??"main",t.cache_dir??null,t.local_files_only??!1,...r])}var Zo=class extends Error{constructor(e,{status:t=null}={}){super(e),this.name="ModelFileNotFoundError",this.status=t}},ST=new Set([401,403,404]);function xp(e,t,r){if(!r)return null;const s=`${ET[e]??`Error (${e}) occurred while trying to load file`}: "${t}".`;throw ST.has(e)?new Zo(s,{status:e}):Error(s)}async function PT(e,t,r){const n=e.headers.get("Content-Length");let s=n?parseInt(n,10):r??0;n===null&&!r&&pe.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let a=new Uint8Array(s),o=0;const i=e.body.getReader();async function l(){const{done:u,value:h}=await i.read();if(u)return;const f=o+h.length;if(f>s){s=f;const g=new Uint8Array(s);g.set(a),a=g}a.set(h,o),o=f;const _=o/s*100;return t({progress:_,loaded:o,total:s}),l()}return await l(),a}function Pf(e){return qr(e,["blob:"])}function ei(e,{allowUnresolved:t=!1}={}){let r;if(typeof location<"u"&&location.href)r=location.href;else if(typeof import.meta<"u"&&import.meta.url)r=import.meta.url;else return e;try{return new URL(e,r).href}catch(n){if(!t)throw n;return e}}var Tp="SHA-256",FT="experimental_transformers-hash-cache",Ff=e=>({algorithm:Tp,value:e}),If=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(FT),this.#t);static isAvailable=()=>typeof navigator<"u"&&"crossOriginStorage"in navigator;match=async e=>{const t=await this._getFileHash(e);if(t)try{const n=await(await navigator.crossOriginStorage.requestFileHandle(Ff(t))).getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,t)=>{const r=await this._getFileHash(e);if(r){const n=await t.blob();await this._storeBlobInCOS(n,r)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{const n=await(await navigator.crossOriginStorage.requestFileHandle(Ff(t),{create:!0,origins:"*"})).createWritable();await n.write(e),await n.close()};_processAndStore=async(e,t)=>{try{const r=[];for await(const a of t)r.push(a);const n=new Blob(r),s=await this._getBlobHash(n);await this._storeBlobInCOS(n,s);try{await(await this._getHashCache()).put(e,new Response(s))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{const t=await this._getHashCache(),r=await t.match(e);if(r)return r.text();const n=await this._getLfsFileHash(e);return n?(await t.put(e,new Response(n)),n):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes("/resolve/"))return null;const t=e.replace("/resolve/","/raw/");try{const n=(await fetch(t).then(s=>s.text())).match(/^oid sha256:([0-9a-f]+)$/m);return n?n[1]:null}catch{return null}};_getBlobHash=async e=>{const t=await e.arrayBuffer(),r=await crypto.subtle.digest(Tp,t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}};async function zi(e=null){let t=null;if(ve.useCustomCache){if(!ve.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!ve.customCache.match||!ve.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");t=ve.customCache}if(!t&&ve.experimental_useCrossOriginStorage&&If.isAvailable()&&(t=new If),!t&&ve.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{t=await caches.open(ve.cacheKey)}catch(r){pe.warn("An error occurred while opening the browser cache:",r)}}if(!t&&ve.useFSCache){if(!_e.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");t=new Mp(e??ve.cacheDir)}return t}async function IT(e,...t){for(let r of t)try{let n=await e.match(r);if(n)return n}catch{continue}}var LT=class{#t;#e;constructor(e){this.#t=e,this.#e=new Map}get(e){if(!this.#e.has(e))return;const t=this.#e.get(e);return this.#e.delete(e),this.#e.set(e,t),t}put(e,t){this.#e.has(e)&&this.#e.delete(e),this.#e.set(e,t),this.#e.size>this.#t&&this.#e.delete(this.#e.keys().next().value)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}},OT=100,Do=new LT(OT);function kp(e,t){const r=Do.get(e);if(r!==void 0)return r;const n=t().then(s=>s,s=>(Do.delete(e),Promise.reject(s)));return Do.put(e,n),n}async function NT(e){if(!qr(e,["http:","https:"]))return null;const t=Ep(e);return t.set("Range","bytes=0-0"),ve.fetch(e,{method:"GET",headers:t,cache:"no-store"})}function Ri(e,t,r={}){const n=Bi(e,r,t);return kp(n,()=>DT(e,t,r))}async function DT(e,t,r){const n=await zi(r?.cache_dir),{localPath:s,remoteURL:a,proposedCacheKey:o,validModelId:i}=Cp(e,t,r,n),l=await Ap(n,s,o);if(l!==void 0&&typeof l!="string"){const u=l.headers.get("content-length"),h=l.headers.get("content-type");return{exists:!0,size:u?parseInt(u,10):void 0,contentType:h||void 0,fromCache:!0}}if(ve.allowLocalModels&&!qr(s,["http:","https:"]))try{const h=await sa(s);if(typeof h!="string"&&h.status!==404){const f=h.headers.get("content-length"),_=h.headers.get("content-type");return{exists:!0,size:f?parseInt(f,10):void 0,contentType:_||void 0,fromCache:!1}}}catch{}if(ve.allowRemoteModels&&!r.local_files_only&&i){const u=await NT(a);if(u&&u.status>=200&&u.status<300){let h;const f=u.headers.get("content-type");if(u.status===206){const _=u.headers.get("content-range");if(_){const g=_.match(/bytes \d+-\d+\/(\d+)/);g&&(h=parseInt(g[1],10))}}else if(u.status===200)try{await u.body?.cancel()}catch{}if(h===void 0){const _=u.headers.get("content-length");h=_?parseInt(_,10):void 0}return{exists:!0,size:h,contentType:f||void 0,fromCache:!1}}u&&u.status!==404&&u.status!==416&&xp(u.status,a,!0)}return{exists:!1,fromCache:!1}}async function sa(e){return ve.useFS&&!qr(e,["http:","https:","blob:"])?new na(e instanceof URL?e.protocol==="file:"?e.pathname:e.toString():e):ve.fetch(e,{headers:Ep(e)})}function Ep(e){const t=typeof process<"u"&&process?.release?.name==="node",r=new Headers;if(t){const n=!!Lo?.TESTING_REMOTELY,s=ve.version;if(r.set("User-Agent",`transformers.js/${s}; is_ci/${n};`),qr(e,["http:","https:"],["huggingface.co","hf.co"])){const o=Lo?.HF_TOKEN??Lo?.HF_ACCESS_TOKEN;o&&r.set("Authorization",`Bearer ${o}`)}}return r}function Cp(e,t,r={},n=null){const s=r.revision??"main",a=Fs(e,t),o=AT(e),i=o?Fs(ve.localModelPath,a):a,l=Fs(ve.remoteHost,ve.remotePathTemplate.replaceAll("{model}",e).replaceAll("{revision}",encodeURIComponent(s)),t),u=n instanceof Mp?s==="main"?a:Fs(e,s,t):l;return{requestURL:a,localPath:i,remoteURL:l,proposedCacheKey:u,validModelId:o}}async function Ap(e,t,r){if(e)return await IT(e,t,r)}async function BT(e,t,r,n,s,a,o={}){if(await r.match(n)===void 0&&!(typeof Cache<"u"&&r instanceof Cache&&!qr(ei(n,{allowUnresolved:!0}),["http:","https:"])))if(a){if(typeof s!="string"){const i=new Headers(s.headers);i.set("content-length",a.byteLength.toString()),await r.put(n,new Response(a,{headers:i})).catch(l=>{pe.warn(`Unable to add response to browser cache: ${l}.`)})}}else{const i=o.progress_callback?l=>Rr(o.progress_callback,{status:"progress",name:e,file:t,...l}):void 0;await r.put(n,s,i)}}async function zT(e,t,r=!0,n={},s=!1,a=null){const{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:u,validModelId:h}=Cp(e,t,n,a);let f,_=!1,g;g=await Ap(a,i,u);const w=g!==void 0;if(w)f=u;else{if(ve.allowLocalModels)if(qr(o,["http:","https:"])){if(n.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${o}.`);if(!ve.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${o}.`)}else try{g=await sa(i),f=i}catch(k){pe.warn(`Unable to load from local path "${i}": "${k}"`)}if(g===void 0||typeof g!="string"&&g.status===404){if(n.local_files_only||!ve.allowRemoteModels){if(r)throw new Zo(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${i}".`);return null}if(!h)throw new Zo(`Local file missing at "${i}" and download aborted due to invalid model ID "${e}".`);if(g=await sa(l),g.status!==200)return xp(g.status,l,r);f=u}_=a&&typeof Response<"u"&&g instanceof Response&&g.status===200}Rr(n.progress_callback,{status:"download",name:e,file:t});let v;if(!(_e.IS_NODE_ENV&&s)){let x;if(typeof g!="string")if(!n.progress_callback)x=new Uint8Array(await g.arrayBuffer());else if(w&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))x=new Uint8Array(await g.arrayBuffer()),Rr(n.progress_callback,{status:"progress",name:e,file:t,progress:100,loaded:x.length,total:x.length});else{let k;const C=g.headers.get("content-length");if(C)k=parseInt(C,10);else try{const E=await Ri(e,t,n);E.size&&(k=E.size)}catch{}x=await PT(g,E=>{Rr(n.progress_callback,{status:"progress",name:e,file:t,...E})},k)}v=x}if(_&&f&&typeof g!="string"&&await BT(e,t,a,f,g,v,n),_e.IS_NODE_ENV&&s&&n.progress_callback&&typeof g!="string"){const x=parseInt(g.headers.get("content-length"),10)||0;Rr(n.progress_callback,{status:"progress",name:e,file:t,progress:100,loaded:x,total:x})}if(Rr(n.progress_callback,{status:"done",name:e,file:t}),v){if(!_e.IS_NODE_ENV&&s)throw new Error("Cannot return path in a browser environment.");return v}if(g instanceof na)return g.filePath;const M=await a?.match(f);if(M instanceof na)return M.filePath;if(M instanceof Response)return new Uint8Array(await M.arrayBuffer());if(typeof M=="string")return M;throw new Error("Unable to get model file path or buffer.")}var Bo=new Map;async function aa(e,t,r=!0,n={},s=!1){if(!ve.allowLocalModels){if(n.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(!ve.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}const a=Bi(e,n,t,r,s),{progress_callback:o}=n,i=o instanceof Yo?o.loads:Bo;let l=i.get(a);return l||(Rr(o,{status:"initiate",name:e,file:t}),l=zi(n.cache_dir).then(u=>zT(e,t,r,n,s,u)),i===Bo&&(l=l.finally(()=>Bo.delete(a))),i.set(a,l)),await l}async function $i(e,t,r=!0,n={}){const s=await aa(e,t,r,n,!1);return s===null?null:new TextDecoder("utf-8").decode(s)}async function ir(e,t,r=!0,n={}){const s=await $i(e,t,r,n);return s===null?{}:JSON.parse(s)}function RT(e,[t,r,n],[s,a],o="bilinear",i=!1){const l=a/n,u=s/r,h=new e.constructor(s*a*t),f=r*n,_=s*a;for(let g=0;g<s;++g)for(let w=0;w<a;++w){const v=g*a+w,M=(w+.5)/l-.5,x=(g+.5)/u-.5;let k=Math.floor(M),C=Math.floor(x);const E=Math.min(k+1,n-1),F=Math.min(C+1,r-1);k=Math.max(k,0),C=Math.max(C,0);const z=M-k,b=x-C,V=(1-z)*(1-b),R=z*(1-b),H=(1-z)*b,J=z*b,X=C*n,D=F*n,I=X+k,G=X+E,Q=D+k,ce=D+E;for(let Z=0;Z<t;++Z){const ne=Z*f;h[Z*_+v]=V*e[ne+I]+R*e[ne+G]+H*e[ne+Q]+J*e[ne+ce]}}return h}function $T(e,t,r){const n=new Array(r.length),s=new Array(r.length);for(let i=r.length-1,l=1;i>=0;--i)s[i]=l,n[i]=t[r[i]],l*=n[i];const a=r.map((i,l)=>s[r.indexOf(l)]),o=new e.constructor(e.length);for(let i=0;i<e.length;++i){let l=0;for(let u=t.length-1,h=i;u>=0;--u)l+=h%t[u]*a[u],h=Math.floor(h/t[u]);o[l]=e[i]}return[o,n]}function bn(e){const t=Ye(e)[0],r=e.map(a=>Math.exp(a-t)),n=r.reduce((a,o)=>a+o,0);return r.map(a=>a/n)}function GT(e){const t=Ye(e)[0];let r=0;for(let a=0;a<e.length;++a)r+=Math.exp(e[a]-t);const n=Math.log(r);return e.map(a=>a-t-n)}function ti(e){if(e.length===0)throw Error("Array must not be empty");let t=e[0],r=0;for(let n=1;n<e.length;++n)e[n]<t&&(t=e[n],r=n);return[t,r]}function Ye(e){if(e.length===0)throw Error("Array must not be empty");let t=e[0],r=0;for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n],r=n);return[t,r]}function Sp(e){return e>0&&(e&e-1)===0}var Pp=class{constructor(e){if(this.size=e|0,this.size<=1||!Sp(this.size))throw new Error("FFT size must be a power of two larger than 1");this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let r=0;r<this.table.length;r+=2){const n=Math.PI*r/this.size;this.table[r]=Math.cos(n),this.table[r+1]=-Math.sin(n)}let t=0;for(let r=1;this.size>r;r<<=1)++t;this._width=t%2===0?t-1:t,this._bitrev=new Int32Array(1<<this._width);for(let r=0;r<this._bitrev.length;++r){this._bitrev[r]=0;for(let n=0;n<this._width;n+=2){const s=this._width-n-2;this._bitrev[r]|=(r>>>n&3)<<s}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,t){const r=t||new Array(e.length>>>1);for(let n=0;n<e.length;n+=2)r[n>>>1]=e[n];return r}toComplexArray(e,t){const r=t||this.createComplexArray();for(let n=0;n<r.length;n+=2)r[n]=e[n>>>1],r[n+1]=0;return r}transform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw new Error("Input and output buffers must be different");this._transform4(e,t,-1);for(let r=0;r<e.length;++r)e[r]/=this.size}_transform4(e,t,r){const n=this._csize;let a=1<<this._width,o=n/a<<1,i,l;const u=this._bitrev;if(o===4)for(i=0,l=0;i<n;i+=o,++l){const f=u[l];this._singleTransform2(t,e,i,f,a)}else for(i=0,l=0;i<n;i+=o,++l){const f=u[l];this._singleTransform4(t,e,i,f,a,r)}const h=this.table;for(a>>=2;a>=2;a>>=2){o=n/a<<1;const f=o>>>2;for(i=0;i<n;i+=o){const _=i+f-1;for(let g=i,w=0;g<_;g+=2,w+=a){const v=g,M=v+f,x=M+f,k=x+f,C=e[v],E=e[v+1],F=e[M],z=e[M+1],b=e[x],V=e[x+1],R=e[k],H=e[k+1],J=h[w],X=r*h[w+1],D=F*J-z*X,I=F*X+z*J,G=h[2*w],Q=r*h[2*w+1],ce=b*G-V*Q,Z=b*Q+V*G,ne=h[3*w],L=r*h[3*w+1],O=R*ne-H*L,$=R*L+H*ne,se=C+ce,ae=E+Z,We=C-ce,Te=E-Z,ke=D+O,$e=I+$,Fe=r*(D-O),we=r*(I-$);e[v]=se+ke,e[v+1]=ae+$e,e[M]=We+we,e[M+1]=Te-Fe,e[x]=se-ke,e[x+1]=ae-$e,e[k]=We-we,e[k+1]=Te+Fe}}}}_singleTransform2(e,t,r,n,s){const a=e[n],o=e[n+1],i=e[n+s],l=e[n+s+1];t[r]=a+i,t[r+1]=o+l,t[r+2]=a-i,t[r+3]=o-l}_singleTransform4(e,t,r,n,s,a){const o=s*2,i=s*3,l=e[n],u=e[n+1],h=e[n+s],f=e[n+s+1],_=e[n+o],g=e[n+o+1],w=e[n+i],v=e[n+i+1],M=l+_,x=u+g,k=l-_,C=u-g,E=h+w,F=f+v,z=a*(h-w),b=a*(f-v);t[r]=M+E,t[r+1]=x+F,t[r+2]=k+b,t[r+3]=C-z,t[r+4]=M-E,t[r+5]=x-F,t[r+6]=k-b,t[r+7]=C+z}_realTransform4(e,t,r){const n=this._csize;let a=1<<this._width,o=n/a<<1,i,l;const u=this._bitrev;if(o===4)for(i=0,l=0;i<n;i+=o,++l){const _=u[l];this._singleRealTransform2(t,e,i,_>>>1,a>>>1)}else for(i=0,l=0;i<n;i+=o,++l){const _=u[l];this._singleRealTransform4(t,e,i,_>>>1,a>>>1,r)}const h=this.table;for(a>>=2;a>=2;a>>=2){o=n/a<<1;const _=o>>>1,g=_>>>1,w=g>>>1;for(i=0;i<n;i+=o)for(let v=0,M=0;v<=w;v+=2,M+=a){const x=i+v,k=x+g,C=k+g,E=C+g,F=e[x],z=e[x+1],b=e[k],V=e[k+1],R=e[C],H=e[C+1],J=e[E],X=e[E+1],D=F,I=z,G=h[M],Q=r*h[M+1],ce=b*G-V*Q,Z=b*Q+V*G,ne=h[2*M],L=r*h[2*M+1],O=R*ne-H*L,$=R*L+H*ne,se=h[3*M],ae=r*h[3*M+1],We=J*se-X*ae,Te=J*ae+X*se,ke=D+O,$e=I+$,Fe=D-O,we=I-$,st=ce+We,be=Z+Te,Me=r*(ce-We),Qr=r*(Z-Te);if(e[x]=ke+st,e[x+1]=$e+be,e[k]=Fe+Qr,e[k+1]=we-Me,v===0){e[C]=ke-st,e[C+1]=$e-be;continue}if(v===w)continue;const Dn=i+g-v,Xr=i+_-v;e[Dn]=Fe-r*Qr,e[Dn+1]=-we-r*Me,e[Xr]=ke-r*st,e[Xr+1]=-$e+r*be}}const f=n>>>1;for(let _=2;_<f;_+=2)e[n-_]=e[_],e[n-_+1]=-e[_+1]}_singleRealTransform2(e,t,r,n,s){const a=e[n],o=e[n+s];t[r]=a+o,t[r+1]=0,t[r+2]=a-o,t[r+3]=0}_singleRealTransform4(e,t,r,n,s,a){const o=s*2,i=s*3,l=e[n],u=e[n+s],h=e[n+o],f=e[n+i],_=l+h,g=l-h,w=u+f,v=a*(u-f);t[r]=_+w,t[r+1]=0,t[r+2]=g,t[r+3]=-v,t[r+4]=_-w,t[r+5]=0,t[r+6]=g,t[r+7]=v}},VT=class{constructor(e){const t=2*(e-1),r=2*(2*e-1),n=2**Math.ceil(Math.log2(r));this.bufferSize=n,this._a=t;const s=new Float64Array(r),a=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);const o=-2*Math.PI/e,i=Math.cos(o),l=Math.sin(o);for(let u=0;u<r>>1;++u){const h=(u+1-e)**2/2,f=Math.sqrt(i**2+l**2)**h,_=h*Math.atan2(l,i),g=2*u;s[g]=f*Math.cos(_),s[g+1]=f*Math.sin(_),a[g]=s[g],a[g+1]=-s[g+1]}this._slicedChirpBuffer=s.subarray(t,r),this._f=new Pp(n>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,r){const n=this._buffer1,s=this._buffer2,a=this._outBuffer1,o=this._outBuffer2,i=this._chirpBuffer,l=this._slicedChirpBuffer,u=this._a;if(r)for(let h=0;h<l.length;h+=2){const f=h+1,_=h>>1,g=t[_];n[h]=g*l[h],n[f]=g*l[f]}else for(let h=0;h<l.length;h+=2){const f=h+1;n[h]=t[h]*l[h]-t[f]*l[f],n[f]=t[h]*l[f]+t[f]*l[h]}this._f.transform(a,n);for(let h=0;h<i.length;h+=2){const f=h+1;s[h]=a[h]*i[h]-a[f]*i[f],s[f]=a[h]*i[f]+a[f]*i[h]}this._f.inverseTransform(o,s);for(let h=0;h<o.length;h+=2){const f=o[h+u],_=o[h+u+1],g=l[h],w=l[h+1];e[h]=f*g-_*w,e[h+1]=f*w+_*g}}transform(e,t){this._transform(e,t,!1)}realTransform(e,t){this._transform(e,t,!0)}},UT=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=Sp(e),this.isPowerOfTwo?(this.fft=new Pp(e),this.outputBufferSize=2*e):(this.fft=new VT(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,t){this.fft.realTransform(e,t)}transform(e,t){this.fft.transform(e,t)}};function WT(e,t){if(t%2===0||t<=0)throw new Error("Window size must be a positive odd number");const r=new e.constructor(e.length),n=new e.constructor(t),s=Math.floor(t/2);for(let a=0;a<e.length;++a){let o=0;for(let i=-s;i<=s;++i){let l=a+i;l<0?l=Math.abs(l):l>=e.length&&(l=2*(e.length-1)-l),n[o++]=e[l]}n.sort(),r[a]=n[s]}return r}function Is(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}function jT(e){const t=Math.round(e);return Math.abs(e)%1===.5?t%2===0?t:t-1:t}function qT(e){const t=e.length,r=e[0].length,n=[t+1,r+1],s=Array.from({length:n[0]},()=>Array(n[1]).fill(1/0));s[0][0]=0;const a=Array.from({length:n[0]},()=>Array(n[1]).fill(-1));for(let h=1;h<n[1];++h)for(let f=1;f<n[0];++f){const _=s[f-1][h-1],g=s[f-1][h],w=s[f][h-1];let v,M;_<g&&_<w?(v=_,M=0):g<_&&g<w?(v=g,M=1):(v=w,M=2),s[f][h]=e[f-1][h-1]+v,a[f][h]=M}for(let h=0;h<n[1];++h)a[0][h]=2;for(let h=0;h<n[0];++h)a[h][0]=1;let o=t,i=r,l=[],u=[];for(;o>0||i>0;)switch(l.push(o-1),u.push(i-1),a[o][i]){case 0:--o,--i;break;case 1:--o;break;case 2:--i;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${i}]. Please file a bug report.`)}return l.reverse(),u.reverse(),[l,u]}var HT=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);const a=new ArrayBuffer(4),o=new Uint32Array(a),i=new Float32Array(a);for(let l=0;l<e.length;++l){let u=0;const h=(l&32768)<<16,f=(l&31744)>>10;let _=l&1023;if(f===31)u=h|2139095040|_<<13;else if(f===0)if(_===0)u=h;else{let g=113;for(;(_&1024)===0;)_<<=1,--g;_&=-1025,u=h|g<<23|_<<13}else u=h|f+112<<23|_<<13;o[0]=u,e[l]=i[0]}}const r=t.length,n=e,s=new Float32Array(r);for(let a=0;a<r;++a)s[a]=n[t[a]];return s}})(),QT={};async function Fp(e){const t=e.split("/").pop();let r;try{if(r=await zi(),r){const s=await r.match(e);if(s)return s}}catch(s){pe.warn(`Failed to load ${t} from cache:`,s)}const n=await ve.fetch(e);if(!n.ok)throw new Error(`Failed to fetch ${t}: ${n.status} ${n.statusText}`);if(r)try{await r.put(e,n.clone())}catch(s){pe.warn(`Failed to cache ${t}:`,s)}return n}async function XT(e){const t=await Fp(e);if(!t||typeof t=="string")return null;try{return await t.arrayBuffer()}catch(r){return pe.warn("Failed to read WASM binary:",r),null}}async function YT(e){if(_e.IS_SERVICE_WORKER_ENV||_e.IS_CHROME_AVAILABLE)return e;const t=await Fp(e);if(!t||typeof t=="string")return null;try{let r=await t.text();r=r.replaceAll("globalThis.process?.versions?.node","false");const n=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(n)}catch(r){return pe.warn("Failed to read WASM factory:",r),null}}var JT=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 Ip(e){return e<=Ft.DEBUG?0:e<=Ft.INFO?2:e<=Ft.WARNING||e<=Ft.ERROR?3:4}var KT={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},xt=[],ri,_n,Lf=Symbol.for("onnxruntime");if(Lf in globalThis)_n=globalThis[Lf];else if(_e.IS_NODE_ENV){switch(_n=QT,process.platform){case"win32":xt.push("dml");break;case"linux":process.arch==="x64"&&xt.push("cuda");break;case"darwin":xt.push("coreml");break}xt.push("webgpu"),xt.push("cpu"),ri=["cpu"]}else _n=x0,_e.IS_WEBNN_AVAILABLE&&xt.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),_e.IS_WEBGPU_AVAILABLE&&xt.push("webgpu"),xt.push("wasm"),ri=["wasm"];var ZT=_n.InferenceSession;function ek(e=null){if(!e)return ri;switch(e){case"auto":return xt;case"gpu":return xt.filter(t=>["webgpu","cuda","dml","webnn-gpu"].includes(t))}if(xt.includes(e))return[JT[e]??e];throw new Error(`Unsupported device: "${e}". Should be one of: ${xt.join(", ")}.`)}var Of=Promise.resolve(),sn=null;async function tk(){if(sn)return sn;if(!(ve.useWasmCache&&typeof Qe?.wasm?.wasmPaths=="object"&&Qe?.wasm?.wasmPaths?.wasm&&Qe?.wasm?.wasmPaths?.mjs)){if(_e.IS_DENO_WEB_RUNTIME)throw new Error("env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.");return sn=Promise.resolve(),sn}return sn=(async()=>{const t=Qe.wasm.wasmPaths;let r=!1;await Promise.all([t.wasm&&!Pf(t.wasm)?(async()=>{try{const n=await XT(ei(t.wasm));n&&(Qe.wasm.wasmBinary=n,r=!0)}catch(n){pe.warn("Failed to pre-load WASM binary:",n)}})():Promise.resolve(),t.mjs&&!Pf(t.mjs)?(async()=>{try{const n=await YT(ei(t.mjs));n&&(Qe.wasm.wasmPaths.mjs=n)}catch(n){pe.warn("Failed to pre-load WASM factory:",n)}})():Promise.resolve()]),r||(Qe.wasm.wasmPaths.mjs=t.mjs)})(),sn}async function Lp(e,t,r){await tk();const n=Ip(ve.logLevel??Ft.WARNING),s=()=>ZT.create(e,{logSeverityLevel:n,...t}),a=await(_e.IS_WEB_ENV?Of=Of.then(s):s());return a.config=r,a}var Nf=Promise.resolve();async function Op(e,t){const r=()=>e.run(t);return _e.IS_WEB_ENV?Nf=Nf.then(r):r()}function Np(e){return e instanceof _n.Tensor}var Qe=_n?.env;function Gi(){return Qe?.wasm?.proxy}if(Qe){let e=function(t){const r=Ip(t);Qe.logLevel=KT[r]};if(Qe.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&Qe.versions?.web&&!Qe.wasm.wasmPaths){const t=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${Qe.versions.web}/dist/`;let r=".asyncify";_e.IS_SAFARI_BELOW_26&&!_e.IS_WEBGPU_AVAILABLE&&(r=""),Qe.wasm.wasmPaths={mjs:`${t}ort-wasm-simd-threaded${r}.mjs`,wasm:`${t}ort-wasm-simd-threaded${r}.wasm`}}Qe.wasm.proxy=!1}Qe.webgpu&&(Qe.webgpu.powerPreference="high-performance"),e(ve.logLevel??Ft.WARNING),ve.backends.onnx={...Qe,setLogLevel:e}}var mr=async(e,t,r)=>{const n=await Lp(new Uint8Array(e),t);return(async s=>{const a=Gi(),o=Object.fromEntries(Object.entries(s).map(([l,u])=>[l,(a?u.clone():u).ort_tensor])),i=await Op(n,o);return Array.isArray(r)?r.map(l=>new W(i[l])):new W(i[r])})},pn=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=mr([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,"y")),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||(this._bilinear_interpolate_4d=mr([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||(this._bicubic_interpolate_4d=mr([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,"y")),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||(this._matmul=mr([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,"c")),this._matmul}static get stft(){return this._stft||(this._stft=mr([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,"o")),this._stft}static get rfft(){return this._rfft||(this._rfft=mr([8,9,58,93,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,19,10,1,120,18,14,10,12,8,1,18,8,10,0,10,0,10,2,8,1,90,11,10,1,97,18,6,10,4,8,7,18,0,98,19,10,1,121,18,14,10,12,8,1,18,8,10,0,10,0,10,2,8,2,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=mr([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,["v","i"])),this._top_k}static get slice(){return this._slice||(this._slice=mr([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}},rk=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"}),zo=_e.IS_NODE_ENV?"cpu":"wasm";function Dp(e,t,{warn:r}={}){return e?typeof e=="string"?e:e.hasOwnProperty(t)?e[t]:(r&&r(`device not specified for "${t}". Using the default device (${zo}).`),zo):zo}var nk=(function(){let e;return async function(){if(e===void 0)if(!_e.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{e=!1}return e}})(),qe=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"}),Df=qe.fp32,Bf=Object.freeze({[rk.wasm]:qe.q8}),ni=Object.freeze({[qe.fp32]:"",[qe.fp16]:"_fp16",[qe.int8]:"_int8",[qe.uint8]:"_uint8",[qe.q8]:"_quantized",[qe.q4]:"_q4",[qe.q2]:"_q2",[qe.q1]:"_q1",[qe.q4f16]:"_q4f16",[qe.q2f16]:"_q2f16",[qe.q1f16]:"_q1f16",[qe.bnb4]:"_bnb4"});function Bp(e,t,r,{configDtype:n=null,warn:s}={}){let a,o=!1;e&&typeof e!="string"?e.hasOwnProperty(t)?a=e[t]:(a=null,o=!0):a=e;let i;if(a===qe.auto){if(n){const l=typeof n=="string"?n:n?.[t];if(l&&l!==qe.auto&&qe.hasOwnProperty(l))return l}i=Bf[r]??Df}else a&&qe.hasOwnProperty(a)?i=a:i=Bf[r]??Df;return o&&s&&s(`dtype not specified for "${t}". Using the default dtype (${i}) for this device (${r}).`),i}var Jn=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}),W=class Ue{get dims(){return this.ort_tensor.dims}set dims(t){this.ort_tensor.dims=t}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(...t){return Np(t[0])?this.ort_tensor=t[0]:this.ort_tensor=new O0(t[0],t[1],t[2]),new Proxy(this,{get:(r,n)=>{if(typeof n=="string"){let s=Number(n);if(Number.isInteger(s))return r._getitem(s)}return r[n]},set:(r,n,s)=>r[n]=s})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){const[t,...r]=this.dims;if(r.length>0){const n=r.reduce((s,a)=>s*a);for(let s=0;s<t;++s)yield this._subarray(s,n,r)}else yield*this.data}_getitem(t){const[r,...n]=this.dims;if(t=Wt(t,r),n.length>0){const s=n.reduce((a,o)=>a*o);return this._subarray(t,s,n)}else return new Ue(this.type,[this.data[t]],n)}_subarray(t,r,n){const s=t*r,a=(t+1)*r,o="subarray"in this.data?this.data.subarray(s,a):this.data.slice(s,a);return new Ue(this.type,o,n)}item(){const t=this.data;if(t.length!==1)throw new Error(`a Tensor with ${t.length} elements cannot be converted to Scalar`);return t[0]}tolist(){return sk(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){const t=this.data;for(let r=0;r<t.length;++r)t[r]=1/(1+Math.exp(-t[r]));return this}map(t){return this.clone().map_(t)}map_(t){const r=this.data;for(let n=0;n<r.length;++n)r[n]=t(r[n],n,r);return this}mul(t){return this.clone().mul_(t)}mul_(t){const r=this.data;for(let n=0;n<r.length;++n)r[n]*=t;return this}div(t){return this.clone().div_(t)}div_(t){const r=this.data;for(let n=0;n<r.length;++n)r[n]/=t;return this}add(t){return this.clone().add_(t)}add_(t){const r=this.data;for(let n=0;n<r.length;++n)r[n]+=t;return this}sub(t){return this.clone().sub_(t)}sub_(t){const r=this.data;for(let n=0;n<r.length;++n)r[n]-=t;return this}remainder(t){return this.clone().remainder_(t)}remainder_(t){const r=this.data,s=r instanceof BigInt64Array||r instanceof BigUint64Array?BigInt(t):Number(t);if((s===0||s===0n)&&(this.type.includes("int")||this.type==="bool"))throw new RangeError("Division by zero");if(s<0&&(this.type.startsWith("uint")||this.type==="bool"))throw new RangeError("Negative divisors are not supported for unsigned or boolean tensors");for(let a=0;a<r.length;++a){const o=r[a]%s,i=o<0&&s>0||o>0&&s<0;r[a]=i?o+s:o}return this}clone(){return new Ue(this.type,this.data.slice(),this.dims.slice())}slice(...t){const r=[],n=[];for(let h=0;h<this.dims.length;++h){let f=t[h];if(f==null)n.push([0,this.dims[h]]),r.push(this.dims[h]);else if(typeof f=="number")f=Wt(f,this.dims[h],h),n.push([f,f+1]);else if(Array.isArray(f)&&f.length===2){let[_,g]=f;if(_=_===null?0:Wt(_,this.dims[h],h,!1),g=g===null?this.dims[h]:Wt(g,this.dims[h],h,!1),_>g)throw new Error(`Invalid slice: ${f}`);const w=[Math.max(_,0),Math.min(g,this.dims[h])];n.push(w),r.push(w[1]-w[0])}else throw new Error(`Invalid slice: ${f}`)}const s=n.map(([h,f])=>f-h),a=s.reduce((h,f)=>h*f),o=this.data,i=new o.constructor(a),l=this.stride();let u=!0;for(let h=1;h<s.length;++h)if(n[h][0]!==0||n[h][1]!==this.dims[h]){u=!1;break}if(u){const h=n[0][0]*l[0],f=n[0][1]*l[0];if(ArrayBuffer.isView(o))i.set(o.subarray(h,f));else if(Array.isArray(o)){const _=o.slice(h,f);for(let g=0;g<_.length;++g)i[g]=_[g]}else throw new Error("Unsupported data type for slicing")}else for(let h=0;h<a;++h){let f=0;for(let _=s.length-1,g=h;_>=0;--_){const w=s[_];f+=(g%w+n[_][0])*l[_],g=Math.floor(g/w)}i[h]=o[f]}return new Ue(this.type,i,r)}permute(...t){return ak(this,t)}transpose(...t){return this.permute(...t)}sum(t=null,r=!1){return this.norm(1,t,r)}norm(t="fro",r=null,n=!1){if(t==="fro")t=2;else if(typeof t=="string")throw Error(`Unsupported norm: ${t}`);const s=this.data,a=s instanceof BigInt64Array||s instanceof BigUint64Array;if(a&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let o,i;if(a?(o=(f,_)=>f+_,i=0n):(o=(f,_)=>f+_**t,i=0),r===null){let f=s.reduce(o,i);return t!==1&&(f=f**(1/t)),new Ue(this.type,[f],[])}const[l,u,h]=Qn(o,this,r,n);if(t!==1)for(let f=0;f<u.length;++f)u[f]=u[f]**(1/t);return new Ue(l,u,h)}normalize_(t=2,r=1){r=Wt(r,this.dims.length);const n=this.norm(t,r,!0),s=this.data,a=n.data;for(let o=0;o<s.length;++o){let i=0;for(let l=this.dims.length-1,u=o,h=1;l>=0;--l){const f=this.dims[l];if(l!==r){const _=u%f;i+=_*h,h*=this.dims[l]}u=Math.floor(u/f)}s[o]/=a[i]}return this}normalize(t=2,r=1){return this.clone().normalize_(t,r)}stride(){return Ro(this.dims)}squeeze(t=null){return new Ue(this.type,this.data,zf(this.dims,t))}squeeze_(t=null){return this.dims=zf(this.dims,t),this}unsqueeze(t){return new Ue(this.type,this.data,Rf(this.dims,t))}unsqueeze_(t){return this.dims=Rf(this.dims,t),this}flatten_(t=0,r=-1){r=(r+this.dims.length)%this.dims.length;let n=this.dims.slice(0,t),s=this.dims.slice(t,r+1),a=this.dims.slice(r+1);return this.dims=[...n,s.reduce((o,i)=>o*i,1),...a],this}flatten(t=0,r=-1){return this.clone().flatten_(t,r)}view(...t){let r=-1;for(let s=0;s<t.length;++s)if(t[s]===-1){if(r!==-1)throw new Error("Only one dimension can be inferred");r=s}const n=this.data;if(r!==-1){const s=t.reduce((a,o,i)=>i!==r?a*o:a,1);t[r]=n.length/s}return new Ue(this.type,n,t)}neg_(){const t=this.data;for(let r=0;r<t.length;++r)t[r]=-t[r];return this}neg(){return this.clone().neg_()}gt(t){const r=new Uint8Array(this.data.length),n=this.data;for(let s=0;s<n.length;++s)r[s]=n[s]>t?1:0;return new Ue("bool",r,this.dims)}lt(t){const r=new Uint8Array(this.data.length),n=this.data;for(let s=0;s<n.length;++s)r[s]=n[s]<t?1:0;return new Ue("bool",r,this.dims)}clamp_(t,r){const n=this.data;for(let s=0;s<n.length;++s)n[s]=Math.min(Math.max(n[s],t),r);return this}clamp(t,r){return this.clone().clamp_(t,r)}round_(){const t=this.data;for(let r=0;r<t.length;++r)t[r]=Math.round(t[r]);return this}round(){return this.clone().round_()}mean(t=null,r=!1){return Vi(this,t,r)}min(t=null,r=!1){if(t===null){const o=ti(this.data)[0];return new Ue(this.type,[o],[])}const[n,s,a]=Qn((o,i)=>Math.min(o,i),this,t,r,1/0);return new Ue(n,s,a)}max(t=null,r=!1){if(t===null){const o=Ye(this.data)[0];return new Ue(this.type,[o],[])}const[n,s,a]=Qn((o,i)=>Math.max(o,i),this,t,r,-1/0);return new Ue(n,s,a)}argmin(t=null,r=!1){if(t!==null)throw new Error("`dim !== null` not yet implemented.");const n=ti(this.data)[1];return new Ue("int64",[BigInt(n)],[])}argmax(t=null,r=!1){if(t!==null)throw new Error("`dim !== null` not yet implemented.");const n=Ye(this.data)[1];return new Ue("int64",[BigInt(n)],[])}repeat(...t){if(t.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${t.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(t.every(h=>h===1)){if(t.length===this.dims.length)return this.clone();const h=t.length-this.dims.length,f=Array(h).fill(1).concat(this.dims);return new Ue(this.type,this.data.slice(),f)}const r=t.length-this.dims.length,n=Array(r).fill(1).concat(this.dims),s=n.map((h,f)=>h*t[f]),a=s.reduce((h,f)=>h*f,1),o=this.data,i=new o.constructor(a),l=Ro(n),u=Ro(s);for(let h=0;h<a;++h){let f=h,_=0;for(let g=0;g<s.length;++g){const w=Math.floor(f/u[g]);f=f%u[g];const v=w%n[g];_+=v*l[g]}i[h]=o[_]}return new Ue(this.type,i,s)}tile(...t){if(t.length<this.dims.length){const r=this.dims.length-t.length;t=Array(r).fill(1).concat(t)}return this.repeat(...t)}to(t){if(this.type===t)return this;if(!Jn.hasOwnProperty(t))throw new Error(`Unsupported type: ${t}`);let r;const n=["int64","uint64"].includes(this.type),s=["int64","uint64"].includes(t);if(n&&!s)r=Number;else if(!n&&s)["float16","float32","float64"].includes(this.type)?r=a=>BigInt(Math.floor(a)):r=BigInt;else if(this.type==="float16"&&t=="float32"&&this.data instanceof Uint16Array)return new Ue(t,HT(this.data),this.dims);return new Ue(t,Jn[t].from(this.data,r),this.dims)}};function sk(e,t){const r=e.length,n=t.length===0?1:t.reduce((a,o)=>a*o);if(r!==n)throw Error(`cannot reshape array of size ${r} into shape (${t})`);let s=e;for(let a=t.length-1;a>=0;a--)s=s.reduce((o,i)=>{let l=o[o.length-1];return l.length<t[a]?l.push(i):o.push([i]),o},[[]]);return s[0]}function ak(e,t){const[r,n]=$T(e.data,e.dims,t);return new W(e.type,r,n)}function zp(e,[t,r],n="bilinear",s=!1){const a=e.dims.at(-3)??1,o=e.dims.at(-2),i=e.dims.at(-1),l=RT(e.data,[a,o,i],[t,r],n,s);return new W(e.type,l,[a,t,r])}async function Qt(e,{size:t=null,mode:r="bilinear"}={}){if(e.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!t)throw new Error("`interpolate_4d` requires a `size` argument.");let n;if(t.length===2)n=[...e.dims.slice(0,2),...t];else if(t.length===3)n=[e.dims[0],...t];else if(t.length===4)n=t;else throw new Error("`size` must be of length 2, 3, or 4.");let s;if(r==="nearest")s=await pn.nearest_interpolate_4d;else if(r==="bilinear")s=await pn.bilinear_interpolate_4d;else if(r==="bicubic")s=await pn.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${r}`);const a=new W("int64",new BigInt64Array(n.map(BigInt)),[n.length]);return await s({x:e,s:a})}async function ok(e,t){return await(await pn.matmul)({a:e,b:t})}async function Rp(e,t){const r=await pn.top_k;return t==null?t=e.dims.at(-1):t=Math.min(t,e.dims.at(-1)),await r({x:e,k:new W("int64",[BigInt(t)],[1])})}var Ls=e=>new W("int64",e,[e.length]);async function $p(e,t,r,n,s){return await(await pn.slice)({x:e,s:Ls(t),e:Ls(r),a:Ls(n),t:Ls(new Array(n.length).fill(1))})}function zf(e,t){return e=e.slice(),t===null?e=e.filter(r=>r!==1):typeof t=="number"?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((r,n)=>r!==1||!t.includes(n))),e}function Rf(e,t){return t=Wt(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function Wt(e,t,r=null,n=!0){if(e<-t||e>=t){if(n)throw new Error(`IndexError: index ${e} is out of bounds for dimension${r===null?"":" "+r} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function De(e,t=0){t=Wt(t,e[0].dims.length);const r=e[0].dims.slice();r[t]=e.reduce((o,i)=>o+i.dims[t],0);const n=r.reduce((o,i)=>o*i,1),s=new e[0].data.constructor(n),a=e[0].type;if(t===0){let o=0;for(const i of e){const l=i.data;s.set(l,o),o+=l.length}}else{let o=0;for(let i=0;i<e.length;++i){const{data:l,dims:u}=e[i];for(let h=0;h<l.length;++h){let f=0;for(let _=u.length-1,g=h,w=1;_>=0;--_){const v=u[_];let M=g%v;_===t&&(M+=o),f+=M*w,w*=r[_],g=Math.floor(g/v)}s[f]=l[h]}o+=u[t]}}return new W(a,s,r)}function sr(e,t=0){return De(e.map(r=>r.unsqueeze(t)),t)}function Qn(e,t,r,n=!1,s=null){const a=t.data,o=t.dims;r=Wt(r,o.length);const i=o.slice();i[r]=1;const l=new a.constructor(a.length/o[r]);s!==null&&l.fill(s);for(let u=0;u<a.length;++u){let h=0;for(let f=o.length-1,_=u,g=1;f>=0;--f){const w=o[f];if(f!==r){const v=_%w;h+=v*g,g*=i[f]}_=Math.floor(_/w)}l[h]=e(l[h],a[u],u,h)}return n||i.splice(r,1),[t.type,l,i]}function ik(e,t=null,r=1,n=!1){const s=e.data,a=e.dims;if(t===null){const g=s.reduce((x,k)=>x+k,0)/s.length,w=Math.sqrt(s.reduce((x,k)=>x+(k-g)**2,0)/(s.length-r)),v=new W(e.type,[g],[]);return[new W(e.type,[w],[]),v]}t=Wt(t,a.length);const o=Vi(e,t,n),i=o.data,[l,u,h]=Qn((_,g,w,v)=>_+(g-i[v])**2,e,t,n);for(let _=0;_<u.length;++_)u[_]=Math.sqrt(u[_]/(a[t]-r));return[new W(l,u,h),o]}function Vi(e,t=null,r=!1){const n=e.dims,s=e.data;if(t===null){const l=s.reduce((u,h)=>u+h,0);return new W(e.type,[l/s.length],[])}t=Wt(t,n.length);const[a,o,i]=Qn((l,u)=>l+u,e,t,r);if(n[t]!==1)for(let l=0;l<o.length;++l)o[l]/=n[t];return new W(a,o,i)}function Ro(e){const t=new Array(e.length);for(let r=e.length-1,n=1;r>=0;--r)t[r]=n,n*=e[r];return t}function Ui(e,t,r,n){const s=e.reduce((a,o)=>a*o,1);return new W(r,new n(s).fill(t),e)}function ot(e,t){let r,n;if(typeof t=="number")r="float32",n=Float32Array;else if(typeof t=="bigint")r="int64",n=BigInt64Array;else if(typeof t=="boolean")r="bool",n=Uint8Array;else throw new Error(`Unsupported data type: ${typeof t}`);return Ui(e,t,r,n)}function si(e,t){return ot(e.dims,t)}function dt(e){return Ui(e,1n,"int64",BigInt64Array)}function Wi(e){return dt(e.dims)}function Gp(e){return Ui(e,0n,"int64",BigInt64Array)}function ji(e){return Gp(e.dims)}function lk(e){const t=e.reduce((r,n)=>r*n,1);return new W("float32",Float32Array.from({length:t},()=>Di.gauss()),e)}async function ck(e){if(!e)throw new Error("modelId is required for get_tokenizer_files");return(await Ri(e,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function Vp(e,t){const r=await ck(e);return await Promise.all(r.map(n=>ir(e,n,!0,t)))}function qi(e){const t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var uk=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function dk(e,t,r,n){for(const s of Object.keys(e)){const a=t-e[s].length,o=r(s),i=new Array(a).fill(o);e[s]=n==="right"?qt(e[s],i):qt(i,e[s])}}function hk(e,t){for(const r of Object.keys(e))e[r].length=t}function Nr(e,...t){for(const r of t){if(!Object.hasOwn(e,r))continue;const n=e[r];if(n)if(typeof n=="object"){if(n.__type==="AddedToken")return n.content;throw Error(`Unknown token: ${n}`)}else return n}return null}function fk(e){const t=[];for(const r of e.get_added_tokens_decoder().values())r.special&&t.push(r);return t}var ue=class extends wt{return_token_type_ids=!1;padding_side="right";constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new T1(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=Nr(t,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=Nr(t,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=Nr(t,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=Nr(t,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=Nr(t,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=Nr(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)){const n=Object.create(null);for(const{name:s,template:a}of this.chat_template){if(typeof s!="string"||typeof a!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');n[s]=a}this.chat_template=n}this._compiled_template_cache=new Map;const r=fk(this._tokenizer);this.all_special_ids=r.map(n=>n.id),this.all_special_tokens=r.map(n=>n.content)}static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:s=!1,revision:a="main"}={}){const o=await Vp(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:s,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(t=>this._tokenizer.token_to_id(t))}_call(e,t={}){const{text_pair:r=null,add_special_tokens:n=!0,padding:s=!1,return_token_type_ids:a=null}=t;let{truncation:o=null,max_length:i=null}=t;const l=t.return_tensor??!0,u=Array.isArray(e);let h;if(u){if(e.length===0)throw Error("text array must be non-empty");if(r!==null){if(Array.isArray(r)){if(e.length!==r.length)throw Error("text and text_pair must have the same length")}else throw Error("text_pair must also be an array");h=e.map((_,g)=>this._encode_plus(_,{text_pair:r[g],add_special_tokens:n,return_token_type_ids:a}))}else h=e.map(_=>this._encode_plus(_,{add_special_tokens:n,return_token_type_ids:a}))}else{if(e==null)throw Error("text may not be null or undefined");if(Array.isArray(r))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");h=[this._encode_plus(e,{text_pair:r,add_special_tokens:n,return_token_type_ids:a})]}if(i===null?i=this.model_max_length:o===null&&(s===!0?(pe.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),i=this.model_max_length):s===!1&&(pe.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)),s===!0&&(i=Math.min(Ye(h.map(_=>_.input_ids.length))[0],i??1/0)),i=Math.min(i,this.model_max_length??1/0),s||o)for(let _=0;_<h.length;++_)h[_].input_ids.length!==i&&(h[_].input_ids.length>i?o&&hk(h[_],i):s&&dk(h[_],i,g=>g==="input_ids"?this.pad_token_id:0,this.padding_side));const f={};if(l){if(!(s&&o)&&h.some(g=>{for(const w of Object.keys(g))if(g[w].length!==h[0][w]?.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.");const _=[h.length,h[0].input_ids.length];for(const g of Object.keys(h[0]))f[g]=new W("int64",BigInt64Array.from(h.flatMap(w=>w[g]).map(BigInt)),_)}else{for(const _ of Object.keys(h[0]))f[_]=h.map(g=>g[_]);if(!u)for(const _ of Object.keys(f))f[_]=f[_][0]}return f}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){const{ids:s,attention_mask:a,token_type_ids:o}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:n??this.return_token_type_ids});return{input_ids:s,attention_mask:a,...o?{token_type_ids:o}:{}}}tokenize(e,{pair:t=null,add_special_tokens:r=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:r})}encode(e,{text_pair:t=null,add_special_tokens:r=!0,return_token_type_ids:n=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:r,return_token_type_ids:n}).ids}batch_decode(e,t={}){return e instanceof W&&(e=e.tolist()),e.map(r=>this.decode(r,t))}decode(e,t={}){if(e instanceof W&&(e=qi(e)),!Array.isArray(e)||e.length===0||!Y0(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:r=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:r})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){const r=this.chat_template;if(e!==null&&Object.hasOwn(r,e))e=r[e];else if(e===null)if(t!==null&&"tool_use"in r)e=r.tool_use;else if("default"in r)e=r.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(r).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,t={}){let{tools:r=null,documents:n=null,chat_template:s=null,add_generation_prompt:a=!1,tokenize:o=!0,padding:i=!1,truncation:l=!1,max_length:u=null,return_tensor:h=!0,return_dict:f=!0,tokenizer_kwargs:_={},...g}=t;if(s=this.get_chat_template({chat_template:s,tools:r}),typeof s!="string")throw Error(`chat_template must be a string, but got ${typeof s}`);let w=this._compiled_template_cache.get(s);w===void 0&&(w=new MT(s),this._compiled_template_cache.set(s,w));const v=Object.create(null);for(const x of uk){const k=Nr(this.config,x);k&&(v[x]=k)}const M=w.render({messages:e,add_generation_prompt:a,tools:r,documents:n,...v,...g});if(o){const x=this._call(M,{add_special_tokens:!1,padding:i,truncation:l,max_length:u,return_tensor:h,..._});return f?x:x.input_ids}return M}};function Hi(e,t,r,n){if(!("language_codes"in e)||!Array.isArray(e.language_codes))throw new 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 new 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 new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");const s=n.src_lang,a=n.tgt_lang;if(!e.language_codes.includes(a))throw new Error(`Target language code "${a}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);if(s!==void 0){if(!e.language_codes.includes(s))throw new Error(`Source language code "${s}" is not valid. Must be one of: {${e.language_codes.join(", ")}}`);const o=e._tokenizer.post_processor?.config;if(o&&"single"in o){for(const i of o.single)if("SpecialToken"in i&&e.languageRegex.test(i.SpecialToken.id)){i.SpecialToken.id=e.lang_to_token(s);break}}}return n.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(a)),e._call(t,r)}var Up={};es(Up,{AlbertTokenizer:()=>_k,AutoTokenizer:()=>Se,BartTokenizer:()=>pk,BertTokenizer:()=>mk,BlenderbotSmallTokenizer:()=>gk,BlenderbotTokenizer:()=>wk,BloomTokenizer:()=>vk,CLIPTokenizer:()=>bk,CamembertTokenizer:()=>yk,CodeGenTokenizer:()=>xk,CodeLlamaTokenizer:()=>Mk,CohereAsrTokenizer:()=>kk,CohereTokenizer:()=>Tk,ConvBertTokenizer:()=>Ek,DebertaTokenizer:()=>Ak,DebertaV2Tokenizer:()=>Ck,DistilBertTokenizer:()=>Sk,ElectraTokenizer:()=>Pk,EsmTokenizer:()=>Fk,FalconTokenizer:()=>Ik,GPT2Tokenizer:()=>Nk,GPTNeoXTokenizer:()=>Ok,GemmaTokenizer:()=>Lk,HerbertTokenizer:()=>Dk,LlamaTokenizer:()=>Bk,M2M100Tokenizer:()=>zk,MBart50Tokenizer:()=>$k,MBartTokenizer:()=>Wp,MPNetTokenizer:()=>Uk,MarianTokenizer:()=>Rk,MgpstrTokenizer:()=>Gk,MobileBertTokenizer:()=>Vk,NllbTokenizer:()=>Wk,NougatTokenizer:()=>jk,PreTrainedTokenizer:()=>ue,Qwen2Tokenizer:()=>qk,RoFormerTokenizer:()=>Qk,RobertaTokenizer:()=>Hk,SiglipTokenizer:()=>Xk,SpeechT5Tokenizer:()=>Yk,SqueezeBertTokenizer:()=>Jk,T5Tokenizer:()=>Kk,TokenizersBackend:()=>ue,VitsTokenizer:()=>eE,Wav2Vec2CTCTokenizer:()=>tE,WhisperTokenizer:()=>oE,XLMRobertaTokenizer:()=>iE,XLMTokenizer:()=>lE});var _k=class extends ue{return_token_type_ids=!0},pk=class extends ue{},mk=class extends ue{return_token_type_ids=!0},gk=class extends ue{},wk=class extends ue{},vk=class extends ue{},yk=class extends ue{},bk=class extends ue{},Mk=class extends ue{},xk=class extends ue{},Tk=class extends ue{},kk=class extends ue{},Ek=class extends ue{return_token_type_ids=!0},Ck=class extends ue{return_token_type_ids=!0},Ak=class extends ue{return_token_type_ids=!0},Sk=class extends ue{},Pk=class extends ue{return_token_type_ids=!0},Fk=class extends ue{},Ik=class extends ue{},Lk=class extends ue{},Ok=class extends ue{},Nk=class extends ue{},Dk=class extends ue{return_token_type_ids=!0},Bk=class extends ue{padding_side="left"},zk=class extends ue{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r.slice(2,-2)),this.lang_to_token=r=>`__${r}__`}_build_translation_inputs(e,t,r){return Hi(this,e,t,r)}},Rk=class extends ue{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(r=>this.languageRegex.test(r)),pe.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;const[t,...r]=e.trim().split(this.languageRegex);if(r.length===0)return super._encode_text(t);if(r.length===2){const[n,s]=r;return this.supported_language_codes.includes(n)||pe.warn(`Unsupported language code "${n}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),qt([n],super._encode_text(s))}}},Wp=class extends ue{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)).map(r=>r),this.lang_to_token=r=>r}_build_translation_inputs(e,t,r){return Hi(this,e,t,r)}},$k=class extends Wp{},Gk=class extends ue{},Vk=class extends ue{return_token_type_ids=!0},Uk=class extends ue{},Wk=class extends ue{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(r=>this.languageRegex.test(r)),this.lang_to_token=r=>r}_build_translation_inputs(e,t,r){return Hi(this,e,t,r)}},jk=class extends ue{},qk=class extends ue{},Hk=class extends ue{},Qk=class extends ue{return_token_type_ids=!0},Xk=class extends ue{},Yk=class extends ue{},Jk=class extends ue{return_token_type_ids=!0},Kk=class extends ue{},Zk=class extends Nt{decode_chain(e){let t="";for(let r=1;r<e.length;r+=2)t+=e[r];return[t]}},eE=class extends ue{constructor(e,t){super(e,t),this._tokenizer.decoder=new Zk({type:"VitsDecoder"})}},tE=class extends ue{},jp=[["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"]],Vs=new Map(jp),rE=new Map([...jp.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 nE(e){e=e.toLowerCase();let t=rE.get(e);if(t===void 0){const r=e.match(/^<\|([a-z]{2})\|>$/);if(r&&(e=r[1]),Vs.has(e))t=e;else{const s=e.length===2?Vs.keys():Vs.values();throw new Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(s))}`)}}return t}var sE="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",$f=new RegExp(`^[${sE}]+$`,"gu"),aE=.1,oE=class extends ue{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:t=!1,return_language:r=!1,time_precision:n=null,force_full_sequences:s=!0}={}){if(n===null)throw Error("Must specify time_precision");let a=null;const o=t==="word";function i(){return{language:a,timestamp:[null,null],text:""}}const l=[];let u=i(),h=0;const f=this.timestamp_begin,g=f+1500;let w=[],v=[],M=!1,x=null;const k=new Set(this.all_special_ids);for(const F of e){const z=F.tokens,b=o?F.token_timestamps:null;let V=null,R=f;if("stride"in F){const[X,D,I]=F.stride;if(h-=D,x=X-I,D&&(R=D/n+f),I)for(let G=z.length-1;G>=0;--G){const Q=Number(z[G]);if(Q>=f){if(V!==null&&(Q-f)*n<x)break;V=Q}}}let H=[],J=[];for(let X=0;X<z.length;++X){const D=Number(z[X]);if(k.has(D)){const I=this.decode([D]),G=Vs.get(I.slice(2,-2));if(G!==void 0){if(a!==null&&G!==a&&!t){w.push(H);const Q=this.findLongestCommonSequence(w)[0],ce=this.decode(Q);u.text=ce,l.push(u),w=[],H=[],u=i()}a=u.language=G}}else if(D>=f&&D<=g){const I=(D-f)*n+h,G=Is(I,2);if(V!==null&&D>=V)M=!0;else if(M||w.length>0&&D<R)M=!1;else if(u.timestamp[0]===null)u.timestamp[0]=G;else if(G!==u.timestamp[0]){u.timestamp[1]=G,w.push(H),o&&v.push(J);const[Q,ce]=this.findLongestCommonSequence(w,v),Z=this.decode(Q);if(u.text=Z,o&&(u.words=this.collateWordTimestamps(Q,ce,a),u.words.length>0&&u.timestamp[1]!==null))for(const ne of u.words)ne.timestamp[1]>u.timestamp[1]&&u.timestamp[1]>=ne.timestamp[0]&&(ne.timestamp[1]=u.timestamp[1]);l.push(u),w=[],H=[],v=[],J=[],u=i()}}else if(H.push(D),o){let I=Is(b[X]+h,2),G;if(X+1<b.length){G=Is(b[X+1]+h,2);const Q=this.decode([D]);$f.test(Q)&&(G=Is(Math.min(I+n,G),2))}else G=null;J.push([I,G])}}if("stride"in F){const[X,D,I]=F.stride;h+=X-I}H.length>0?(w.push(H),o&&v.push(J)):w.every(X=>X.length===0)&&(u=i(),w=[],H=[],v=[],J=[])}if(w.length>0){if(s&&t)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");const[F,z]=this.findLongestCommonSequence(w,v),b=this.decode(F);u.text=b,o&&(u.words=this.collateWordTimestamps(F,z,a)),l.push(u)}let C=Object.create(null);const E=l.map(F=>F.text).join("");if(t||r){for(let F=0;F<l.length;++F){const z=l[F];t||delete z.timestamp,r||delete z.language}if(o){const F=[];for(const z of l)for(const b of z.words)F.push(b);C={chunks:F}}else C={chunks:l}}return[E,C]}findLongestCommonSequence(e,t=null){let r=e[0],n=r.length,s=[];const a=Array.isArray(t)&&t.length>0;let o=a?[]:null,i=a?t[0]:null;for(let l=1;l<e.length;++l){const u=e[l];let h=0,f=[n,n,0,0];const _=u.length;for(let C=1;C<n+_;++C){const E=Math.max(0,n-C),F=Math.min(n,n+_-C),z=r.slice(E,F),b=Math.max(0,C-n),V=Math.min(_,C),R=u.slice(b,V);if(z.length!==R.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let H;a?H=z.filter((D,I)=>D===R[I]&&i[E+I][0]-aE<=t[l][b+I][0]).length:H=z.filter((D,I)=>D===R[I]).length;const J=C/1e4,X=H/C+J;H>1&&X>h&&(h=X,f=[E,F,b,V])}const[g,w,v,M]=f,x=Math.floor((w+g)/2);let k=Math.floor((M+v)/2);if(a&&h===0&&n>0){const C=i[n-1][0],E=t[l].findIndex(F=>F[0]>=C);k=E===-1?u.length:E}s.push(...r.slice(0,x)),r=u.slice(k),n=r.length,a&&(o.push(...i.slice(0,x)),i=t[l].slice(k))}return s.push(...r),a?(o.push(...i),[s,o]):[s,[]]}collateWordTimestamps(e,t,r){const[n,s,a]=this.combineTokensIntoWords(e,r),o=[];for(let i=0;i<n.length;++i){const l=a[i];o.push({text:n[i],timestamp:[t[l.at(0)][0],t[l.at(-1)][1]]})}return o}combineTokensIntoWords(e,t,r=`"'“¡¿([{-`,n=`"'.。,,!!??::”)]}、`){t=t??"english";let s,a,o;return["chinese","japanese","thai","lao","myanmar"].includes(t)?[s,a,o]=this.splitTokensOnUnicode(e):[s,a,o]=this.splitTokensOnSpaces(e),this.mergePunctuations(s,a,o,r,n)}decode(e,t){let r;return t?.decode_with_timestamps?(e instanceof W&&(e=qi(e)),r=this.decodeWithTimestamps(e,t)):r=super.decode(e,t),r}decodeWithTimestamps(e,t){const r=t?.time_precision??.02,n=this.all_special_ids.at(-1)+1;let s=[[]];for(let a of e)if(a=Number(a),a>=n){const o=((a-n)*r).toFixed(2);s.push(`<|${o}|>`),s.push([])}else s[s.length-1].push(a);return s=s.map(a=>typeof a=="string"?a:super.decode(a,t)),s.join("")}splitTokensOnUnicode(e){const t=this.decode(e,{decode_with_timestamps:!0}),r="�",n=[],s=[],a=[];let o=[],i=[],l=0;for(let u=0;u<e.length;++u){const h=e[u];o.push(h),i.push(u);const f=this.decode(o,{decode_with_timestamps:!0});(!f.includes(r)||t[l+f.indexOf(r)]===r)&&(n.push(f),s.push(o),a.push(i),o=[],i=[],l+=f.length)}return[n,s,a]}splitTokensOnSpaces(e){const[t,r,n]=this.splitTokensOnUnicode(e),s=[],a=[],o=[];for(let i=0;i<t.length;++i){const l=t[i],u=r[i],h=n[i],f=u[0]>=this._tokenizer.token_to_id("<|endoftext|>"),_=l.startsWith(" "),g=l.trim(),w=$f.test(g);if(f||_||w||s.length===0)s.push(l),a.push(u),o.push(h);else{const v=s.length-1;s[v]+=l,a[v].push(...u),o[v].push(...h)}}return[s,a,o]}mergePunctuations(e,t,r,n,s){const a=structuredClone(e),o=structuredClone(t),i=structuredClone(r);let l=a.length-2,u=a.length-1;for(;l>=0;)a[l].startsWith(" ")&&n.includes(a[l].trim())?(a[u]=a[l]+a[u],o[u]=qt(o[l],o[u]),i[u]=qt(i[l],i[u]),a[l]="",o[l]=[],i[l]=[]):u=l,--l;for(l=0,u=1;u<a.length;)!a[l].endsWith(" ")&&s.includes(a[u])?(a[l]+=a[u],o[l]=qt(o[l],o[u]),i[l]=qt(i[l],i[u]),a[u]="",o[u]=[],i[u]=[]):l=u,++u;return[a.filter(h=>h),o.filter(h=>h.length>0),i.filter(h=>h.length>0)]}},iE=class extends ue{},lE=class extends ue{return_token_type_ids=!0;constructor(e,t){super(e,t),pe.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},Se=class{static async from_pretrained(e,{progress_callback:t=null,config:r=null,cache_dir:n=null,local_files_only:s=!1,revision:a="main"}={}){const[o,i]=await Vp(e,{progress_callback:t,config:r,cache_dir:n,local_files_only:s,revision:a}),l=i.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer";let u=Up[l];return u||(pe.warn(`Unknown tokenizer class "${l}", attempting to construct from base class.`),u=ue),new u(o,i)}},fa="https://github.com/huggingface/transformers.js/issues/new/choose",qp="preprocessor_config.json",Hp="preprocessor_config.json",Qp="processor_config.json",Xp="chat_template.jinja",Pe=class extends wt{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,r){super(),this.config=e,this.components=t,this.chat_template=r}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,t={}){if(!this.tokenizer)throw new Error("Unable to apply chat template without a tokenizer.");return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...t})}batch_decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw new Error("Unable to decode without a tokenizer.");return this.tokenizer.decode(...e)}async _call(e,...t){for(const r of[this.image_processor,this.feature_extractor,this.tokenizer])if(r)return r(e,...t);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,t={}){const[r,n,s]=await Promise.all([this.uses_processor_config?ir(e,Qp,!0,t):{},Promise.all(this.classes.filter(a=>a in this).map(async a=>{const o=await this[a].from_pretrained(e,t);return[a.replace(/_class$/,""),o]})).then(Object.fromEntries),this.uses_chat_template_file?$i(e,Xp,!0,t):null]);return new this(r,n,s)}},cE={};es(cE,{ChatterboxProcessor:()=>NE,CohereAsrProcessor:()=>BE,Florence2Processor:()=>z2,Gemma3Processor:()=>R2,Gemma3nProcessor:()=>$2,Gemma4Processor:()=>G2,Glm46VProcessor:()=>V2,GraniteSpeechProcessor:()=>U2,GroundingDinoProcessor:()=>j2,Idefics3Processor:()=>Hf,JinaCLIPProcessor:()=>Y2,Lfm2VlProcessor:()=>J2,LlavaProcessor:()=>K2,MgpstrProcessor:()=>Z2,MoonshineProcessor:()=>eC,OwlViTProcessor:()=>tC,PaliGemmaProcessor:()=>nC,Phi3VProcessor:()=>aC,PixtralProcessor:()=>oC,Processor:()=>Pe,PyAnnoteProcessor:()=>iC,Qwen2VLProcessor:()=>Ki,Qwen2_5_VLProcessor:()=>Cm,Qwen3VLProcessor:()=>lC,Sam2Processor:()=>Sm,Sam2VideoProcessor:()=>cC,SamProcessor:()=>Am,SmolVLMProcessor:()=>Hf,SpeechT5Processor:()=>uC,UltravoxProcessor:()=>dC,VLChatProcessor:()=>X2,VoxtralProcessor:()=>pC,VoxtralRealtimeProcessor:()=>wC,Wav2Vec2Processor:()=>vC,Wav2Vec2ProcessorWithLM:()=>yC,WhisperProcessor:()=>bC});var it=class extends wt{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){const r=await ir(e,qp,!0,t);return new this(r)}};function rt(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw new 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 \`load_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var Yp={};es(Yp,{ASTFeatureExtractor:()=>bE,ChatterboxFeatureExtractor:()=>ME,ClapFeatureExtractor:()=>xE,CohereAsrFeatureExtractor:()=>kE,DacFeatureExtractor:()=>tm,EncodecFeatureExtractor:()=>Zp,FeatureExtractor:()=>it,Gemma3nAudioFeatureExtractor:()=>rm,Gemma4AudioFeatureExtractor:()=>nm,GraniteSpeechFeatureExtractor:()=>EE,MoonshineFeatureExtractor:()=>CE,ParakeetFeatureExtractor:()=>em,PyAnnoteFeatureExtractor:()=>sm,SeamlessM4TFeatureExtractor:()=>AE,SnacFeatureExtractor:()=>SE,SpeechT5FeatureExtractor:()=>PE,VoxtralRealtimeFeatureExtractor:()=>LE,Wav2Vec2FeatureExtractor:()=>FE,WeSpeakerFeatureExtractor:()=>IE,WhisperFeatureExtractor:()=>OE});var uE=()=>{},dE=uE;async function hE(e,t){if(_e.IS_BROWSER_ENV){if(_e.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,n.click(),n.remove(),URL.revokeObjectURL(r)}else if(_e.IS_FS_AVAILABLE)t.stream(),gt.createWriteStream(e),await dE();else throw new Error("Unable to save because filesystem is disabled in this environment.")}function Jp(e,t){if(e<1)return new Float64Array;if(e===1)return new Float64Array([1]);const r=1-t,n=2*Math.PI/(e-1),s=new Float64Array(e);for(let a=0;a<e;++a)s[a]=t-r*Math.cos(a*n);return s}function Gf(e){return Jp(e,.5)}function fE(e){return Jp(e,.54)}var _E={htk:e=>2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,r=15,n=27/Math.log(6.4))=>e>=t?r+Math.log(e/t)*n:3*e/200};function $o(e,t="htk"){const r=_E[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof e=="number"?r(e):e.map(n=>r(n))}var pE={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,r=15,n=Math.log(6.4)/27)=>e>=r?t*Math.exp(n*(e-r)):200*e/3};function mE(e,t="htk"){const r=pE[t];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof e=="number"?r(e):e.map(n=>r(n))}function gE(e,t){const r=Float64Array.from({length:t.length-1},(o,i)=>t[i+1]-t[i]),n=Array.from({length:e.length},()=>new Array(t.length));for(let o=0;o<e.length;++o){const i=n[o];for(let l=0;l<t.length;++l)i[l]=t[l]-e[o]}const s=t.length-2,a=Array.from({length:s},()=>new Array(e.length));for(let o=0;o<e.length;++o){const i=n[o];for(let l=0;l<s;++l){const u=-i[l]/r[l],h=i[l+2]/r[l+1];a[l][o]=Math.max(0,Math.min(u,h))}}return a}function Vf(e,t,r){const n=(t-e)/(r-1);return Float64Array.from({length:r},(s,a)=>e+n*a)}function Xt(e,t,r,n,s,a=null,o="htk",i=!1){if(a!==null&&a!=="slaney")throw new Error('norm must be one of null or "slaney"');if(e<2)throw new Error(`Require num_frequency_bins: ${e} >= 2`);if(r>n)throw new Error(`Require min_frequency: ${r} <= max_frequency: ${n}`);const l=$o(r,o),u=$o(n,o),h=Vf(l,u,t+2);let f=mE(h,o),_;if(i){const w=s/((e-1)*2);_=$o(Float64Array.from({length:e},(v,M)=>M*w),o),f=h}else _=Vf(0,Math.floor(s/2),e);const g=gE(_,f);if(a!==null&&a==="slaney")for(let w=0;w<t;++w){const v=g[w],M=2/(f[w+2]-f[w]);for(let x=0;x<e;++x)v[x]*=M}return g}function wE(e,t,r){const n=new e.constructor(e.length+t+r),s=e.length-1;for(let a=0;a<e.length;++a)n[t+a]=e[a];for(let a=1;a<=t;++a)n[t-a]=e[Ys(a,s)];for(let a=1;a<=r;++a)n[s+t+a]=e[Ys(s-a,s)];return n}function Kp(e,t,r,n,s){if(r<=0)throw new Error("reference must be greater than zero");if(n<=0)throw new Error("min_value must be greater than zero");r=Math.max(n,r);const a=Math.log10(r);for(let o=0;o<e.length;++o)e[o]=t*Math.log10(Math.max(n,e[o])-a);if(s!==null){if(s<=0)throw new Error("db_range must be greater than zero");const o=Ye(e)[0]-s;for(let i=0;i<e.length;++i)e[i]=Math.max(e[i],o)}return e}function vE(e,t=1,r=1e-5,n=null){return Kp(e,20,t,r,n)}function yE(e,t=1,r=1e-10,n=null){return Kp(e,10,t,r,n)}async function Jt(e,t,r,n,{fft_length:s=null,power:a=1,center:o=!0,pad_mode:i="reflect",onesided:l=!0,preemphasis:u=null,preemphasis_htk_flavor:h=!0,mel_filters:f=null,mel_floor:_=1e-10,log_mel:g=null,max_log_mel:w=null,reference:v=1,min_value:M=1e-10,db_range:x=null,remove_dc_offset:k=null,min_num_frames:C=null,max_num_frames:E=null,do_pad:F=!0,transpose:z=!1,mel_offset:b=0,mel_floor_mode:V="clamp"}={}){const R=t.length;if(s===null&&(s=r),r>s)throw Error(`frame_length (${r}) may not be larger than fft_length (${s})`);if(R!==r)throw new Error(`Length of the window (${R}) must equal frame_length (${r})`);if(n<=0)throw new Error("hop_length must be greater than zero");if(a===null&&f!==null)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!h)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(o){const O=Math.floor(r/2);switch(i){case"reflect":{e=wE(e,O,O);break}case"constant":{const $=new e.constructor(e.length+2*O);$.set(e,O),e=$;break}case"semicausal":{const $=new e.constructor(e.length+O);$.set(e,O),e=$;break}default:throw new Error(`pad_mode="${i}" not implemented yet.`)}}let H=Math.floor(1+Math.floor((e.length-r)/n));C!==null&&H<C&&(H=C);const J=l?Math.floor(s/2)+1:s;let X=H,D=H;E!==null&&(E>H?F&&(D=E):D=X=E);const I=new UT(s),G=new Float64Array(s),Q=new Float64Array(I.outputBufferSize),ce=new Float32Array(J*D);for(let O=0;O<X;++O){const $=O*n,se=Math.min(e.length-$,r);se!==r&&G.fill(0,0,r);for(let ae=0;ae<se;++ae)G[ae]=e[$+ae];if(k){let ae=0;for(let Te=0;Te<se;++Te)ae+=G[Te];const We=ae/se;for(let Te=0;Te<se;++Te)G[Te]-=We}if(u!==null){for(let ae=se-1;ae>=1;--ae)G[ae]-=u*G[ae-1];G[0]*=1-u}for(let ae=0;ae<t.length;++ae)G[ae]*=t[ae];I.realTransform(Q,G);for(let ae=0;ae<J;++ae){const We=ae<<1;ce[ae*D+O]=Q[We]**2+Q[We+1]**2}}if(a!==null&&a!==2){const O=a/2;for(let $=0;$<ce.length;++$)ce[$]**=O}const Z=f.length;let ne=await ok(new W("float32",f.flat(),[Z,J]),new W("float32",ce,[J,D]));z&&(ne=ne.transpose(1,0));const L=ne.data;if(V==="add")for(let O=0;O<L.length;++O)L[O]=b+L[O]+_;else for(let O=0;O<L.length;++O)L[O]=b+Math.max(_,L[O]);if(a!==null&&g!==null){const O=Math.min(L.length,X*Z);switch(g){case"log":for(let $=0;$<O;++$)L[$]=Math.log(L[$]);break;case"log10":for(let $=0;$<O;++$)L[$]=Math.log10(L[$]);break;case"log10_max_norm":{for(let ae=0;ae<O;++ae)L[ae]=Math.log10(L[ae]);const se=(w??Ye(L)[0])-8;for(let ae=0;ae<O;++ae)L[ae]=(Math.max(L[ae],se)+4)/4;break}case"dB":if(a===1)vE(L,v,M,x);else if(a===2)yE(L,v,M,x);else throw new Error(`Cannot use log_mel option '${g}' with power ${a}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${g}'`)}}return ne}function lr(e,t,{periodic:r=!0,frame_length:n=null,center:s=!0}={}){const a=r?e+1:e;let o;switch(t){case"boxcar":o=new Float64Array(a).fill(1);break;case"hann":case"hann_window":o=Gf(a);break;case"hamming":o=fE(a);break;case"povey":o=Gf(a).map(u=>Math.pow(u,.85));break;default:throw new Error(`Unknown window type ${t}.`)}if(r&&(o=o.subarray(0,e)),n===null||e===n)return o;if(e>n)throw new Error(`Length of the window (${e}) may not be larger than frame_length (${n})`);const i=new Float64Array(n),l=s?Math.floor((n-e)/2):0;return i.set(o,l),i}var bE=class extends it{constructor(e){super(e);const t=this.config.sampling_rate,r=Xt(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=lr(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return Jt(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){rt(e,"ASTFeatureExtractor");const t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){const r=this.std*2,n=t.data;for(let s=0;s<n.length;++s)n[s]=(n[s]-this.mean)/r}return{input_values:t.unsqueeze_(0)}}},Zp=class extends it{async _call(e){rt(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));const t=this.config.feature_size;if(e.length%t!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${t}).`);const r=[1,t,e.length/t];return{input_values:new W("float32",e,r)}}},ME=class extends it{async _call(e){rt(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));const t=[1,e.length];return{input_values:new W("float32",e,t)}}},xE=class extends it{constructor(e){super(e),this.mel_filters=Xt(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=Xt(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=lr(this.config.fft_window_size,"hann")}async _get_input_mel(e,t,r,n){let s;const a=e.length-t;if(a>0)if(r==="rand_trunc"){const o=Math.floor(Di.random()*(a+1));e=e.subarray(o,o+t),s=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${r}" not implemented`);else{if(a<0){let o=new Float64Array(t);if(o.set(e),n==="repeat")for(let i=e.length;i<t;i+=e.length)o.set(e.subarray(0,Math.min(e.length,t-i)),i);else if(n==="repeatpad")for(let i=e.length;i<-a;i+=e.length)o.set(e,i);e=o}if(r==="fusion")throw new Error(`Truncation strategy "${r}" not implemented`);s=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return s.unsqueeze_(0)}async _extract_fbank_features(e,t,r=null){return Jt(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:t,log_mel:"dB",max_num_frames:r,do_pad:!1,transpose:!0})}async _call(e,{max_length:t=null}={}){return rt(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,t??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}},TE=1e-5,em=class extends it{constructor(e){super(e),this.config.mel_filters??=Xt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");const t=lr(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);const r=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(t,r)}async _extract_fbank_features(e){const 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 Jt(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){rt(e,"ParakeetFeatureExtractor");const t=await this._extract_fbank_features(e),r=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),n=t.data;n.fill(0,r*t.dims[1]);const[s,a]=t.dims,o=new Float64Array(a),i=new Float64Array(a);for(let h=0;h<r;++h){const f=h*a;for(let _=0;_<a;++_){const g=n[f+_];o[_]+=g,i[_]+=g*g}}const l=r>1?r-1:1;for(let h=0;h<a;++h){const f=o[h]/r,_=(i[h]-r*f*f)/l,w=1/(Math.sqrt(_)+TE);for(let v=0;v<r;++v){const M=v*a+h;n[M]=(n[M]-f)*w}}const u=new BigInt64Array(s);return u.fill(1n,0,r),{input_features:t.unsqueeze_(0),attention_mask:new W("int64",u,[1,s])}}},kE=class extends em{_apply_dither(e){const t=this.config.dither??0;if(t<=0)return e;const r=new ha(e.length);for(let n=0;n<e.length;++n)e[n]+=t*r.gauss();return e}split_audio(e){const t=this.config.max_audio_clip_s??35,r=this.config.overlap_chunk_second??5,n=this.config.min_energy_window_samples??1600,s=this.config.sampling_rate,a=Math.max(1,Math.round(t*s)),o=Math.max(1,Math.round(r*s));if(e.length<=a)return[e];const i=[];let l=0;const u=e.length;for(;l<u;){if(l+a>=u){i.push(e.slice(l,u));break}const h=Math.max(l,l+a-o),f=Math.min(l+a,u);let _;f<=h?_=l+a:_=this._find_split_point_energy(e,h,f,n),_=Math.max(l+1,Math.min(_,u)),i.push(e.slice(l,_)),l=_}return i}_find_split_point_energy(e,t,r,n){const s=r-t;if(s<=n)return Math.floor((t+r)/2);let a=1/0,o=t;const i=s-n;for(let l=0;l<=i;l+=n){let u=0;for(let h=0;h<n;++h){const f=e[t+l+h];u+=f*f}u=Math.sqrt(u/n),u<a&&(a=u,o=t+l)}return o}async _call(e){rt(e,"CohereAsrFeatureExtractor");const t=new Float64Array(e);return this._apply_dither(t),super._call(t)}},tm=class extends Zp{},rm=class extends it{constructor(e){super(e);const{fft_length:t,feature_size:r,min_frequency:n,max_frequency:s,sampling_rate:a,frame_length:o}=this.config,i=Xt(Math.floor(1+t/2),r,n,s,a,null,"htk",!1);this.mel_filters=i,this.window=lr(o,"hann")}async _extract_fbank_features(e,t){return Jt(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:r=!0,padding:n=!0,pad_to_multiple_of:s=128}={}){if(rt(e,"Gemma3nAudioFeatureExtractor"),r&&e.length>t&&(e=e.slice(0,t)),n&&e.length%s!==0){const i=s-e.length%s,l=new Float64Array(e.length+i);l.set(e),this.config.padding_value!==0&&l.fill(this.config.padding_value,e.length),e=l}const a=await this._extract_fbank_features(e,this.config.max_length),o=ot([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:o}}},nm=class extends rm{async _extract_fbank_features(e,t){const{frame_length:r,hop_length:n,fft_length:s}=this.config,a=Math.floor(r/2),o=Math.floor((e.length+a-(r+1))/n)+1;return Jt(e,this.window,r,n,{fft_length:s,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={}){rt(e,"Gemma4AudioFeatureExtractor");const r=e.length,n=await super._call(e,t),{input_features:s}=n,[,a,o]=s.dims,{frame_length:i,hop_length:l}=this.config,u=Math.floor(i/2),h=i+1,f=new Uint8Array(r+u+(t.pad_to_multiple_of??128));f.fill(1,u,u+r);const _=new Uint8Array(a);for(let w=0;w<a;++w)_[w]=f[w*l+h-1]?1:0;const g=s.data;for(let w=0;w<a;++w)_[w]||g.fill(0,w*o,(w+1)*o);return n.input_features_mask=new W("bool",_,[1,a]),n}},EE=class extends it{constructor(e){super(e);const{n_fft:t,win_length:r,n_mels:n,sample_rate:s}=e.melspec_kwargs;this.mel_filters=Xt(Math.floor(1+t/2),n,0,s/2,s,null,"htk");const a=lr(r,"hann");this.window=new Float64Array(t);const o=Math.floor((t-r)/2);this.window.set(a,o)}async _call(e){rt(e,"GraniteSpeechFeatureExtractor");const{n_fft:t,hop_length:r,n_mels:n}=this.config.melspec_kwargs,s=Math.floor(e.length/r)+1,a=s-s%2;return{input_features:(await Jt(e,this.window,t,r,{power:2,mel_filters:this.mel_filters,log_mel:"log10_max_norm",transpose:!0,max_num_frames:a,do_pad:!1})).view(-1,2*n).unsqueeze_(0)}}},CE=class extends it{async _call(e){rt(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));const t=[1,e.length];return{input_values:new W("float32",e,t)}}},sm=class extends it{async _call(e){rt(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));const t=[1,1,e.length];return{input_values:new W("float32",e,t)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,t){const r=t/this.samples_to_frames(t)/this.config.sampling_rate,n=[];for(const s of e.tolist()){const a=[];let o=-1;for(let i=0;i<s.length;++i){const l=bn(s[i]),[u,h]=Ye(l),[f,_]=[i,i+1];h!==o?(o=h,a.push({id:h,start:f,end:_,score:u})):(a.at(-1).end=_,a.at(-1).score+=u)}n.push(a.map(({id:i,start:l,end:u,score:h})=>({id:i,start:l*r,end:u*r,confidence:h/(u-l)})))}return n}},AE=class extends it{constructor(e){super(e);const t=this.config.sampling_rate,r=Xt(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=lr(400,"povey",{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(r=>r*32768),Jt(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:r=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:s=!0}={}){rt(e,"SeamlessM4TFeatureExtractor");let a=await this._extract_fbank_features(e,this.config.max_length);if(n){const[g,w]=a.dims,v=a.data;for(let M=0;M<w;++M){let x=0;for(let F=0;F<g;++F)x+=v[F*w+M];const k=x/g;let C=0;for(let F=0;F<g;++F)C+=(v[F*w+M]-k)**2;C/=g-1;const E=Math.sqrt(C+1e-7);for(let F=0;F<g;++F){const z=F*w+M;v[z]=(v[z]-k)/E}}}let o;if(t){const[g,w]=a.dims,v=a.data,M=g%r;if(M>0){const x=new Float32Array(w*(g+M));x.set(v),x.fill(this.config.padding_value,v.length);const k=g+M;a=new W(a.type,x,[k,w]),s&&(o=new W("int64",new BigInt64Array(k),[1,k]),o.data.fill(1n,0,g))}}const[i,l]=a.dims,u=this.config.stride;if(i%u!==0)throw new Error(`The number of frames (${i}) must be a multiple of the stride (${u}).`);const f=a.view(1,Math.floor(i/u),l*u),_={input_features:f};if(s){const g=f.dims[1],w=new BigInt64Array(g);if(o){const v=o.data;for(let M=1,x=0;M<i;M+=u,++x)w[x]=v[M]}else w.fill(1n);_.attention_mask=new W("int64",w,[1,g])}return _}},SE=class extends tm{},PE=class extends it{},FE=class extends it{_zero_mean_unit_var_norm(e){const r=e.reduce((s,a)=>s+a,0)/e.length,n=e.reduce((s,a)=>s+(a-r)**2,0)/e.length;return e.map(s=>(s-r)/Math.sqrt(n+1e-7))}async _call(e){rt(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));const r=[1,t.length];return{input_values:new W("float32",t,r),attention_mask:new W("int64",new BigInt64Array(t.length).fill(1n),r)}}},IE=class extends it{constructor(e){super(e);const t=this.config.sampling_rate,r=Xt(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,"kaldi",!0);this.mel_filters=r,this.window=lr(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(t=>t*32768),Jt(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:"log",mel_floor:1192092955078125e-22,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){rt(e,"WeSpeakerFeatureExtractor");const t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){const r=t.mean(1).data,n=t.data,[s,a,o]=t.dims;for(let i=0;i<s;++i){const l=i*a*o,u=i*o;for(let h=0;h<a;++h){const f=l+h*o;for(let _=0;_<o;++_)n[f+_]-=r[u+_]}}}return{input_features:t}}},LE=class extends it{constructor(e){super(e),this.config.mel_filters??=Xt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=lr(this.config.n_fft,"hann")}async _extract_fbank_features(e,{center:t=!0}={}){const{n_fft:r,hop_length:n,mel_filters:s,global_log_mel_max:a}=this.config,o=Math.floor(t?e.length/n:(e.length-r)/n);return await Jt(e,this.window,r,n,{power:2,mel_filters:s,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 rt(e,"VoxtralRealtimeFeatureExtractor"),{input_features:(await this._extract_fbank_features(e,{center:t})).unsqueeze_(0)}}},OE=class extends it{constructor(e){super(e),this.config.mel_filters??=Xt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=lr(this.config.n_fft,"hann")}async _extract_fbank_features(e){return await Jt(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}={}){rt(e,"WhisperFeatureExtractor");let r;const n=t??this.config.n_samples;return e.length>n?(e.length>this.config.n_samples&&pe.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),r=e.slice(0,n)):(r=new Float32Array(n),r.set(e)),{input_features:(await this._extract_fbank_features(r)).unsqueeze_(0)}}},Et=class{static async from_pretrained(e,t={}){const r=await ir(e,qp,!0,t),n=r.feature_extractor_type,s=Yp[n];if(!s)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${fa}.`);return new s(r)}},NE=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e,t=null){const r=this.tokenizer(e),n=t?await this.feature_extractor(t):{};return{...r,...n}}},DE=new Set(["ja","zh"]),BE=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;static uses_processor_config=!0;get_decoder_prompt_ids(e="en"){const 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"){const r=e.filter(a=>a&&a.trim());if(r.length===0)return"";const n=DE.has(t)?"":" ";return[r[0].trimEnd(),...r.slice(1).map(a=>a.trim())].join(n)}async _call(e){return await this.feature_extractor(e)}},ai={},Dr,am,wr;if(_e.IS_WEB_ENV)Dr=(e,t)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(e,t)},wr=self.createImageBitmap,am=self.ImageData;else if(ai)wr=async e=>{const r=(await e.metadata()).channels,{data:n,info:s}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),a=new Kn(new Uint8ClampedArray(n),s.width,s.height,s.channels);return r!==void 0&&r!==s.channels&&a.convert(r),a};else throw new Error("Unable to load image processing library.");var zE={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},RE=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),Kn=class Ut{constructor(t,r,n,s){this.data=t,this.width=r,this.height=n,this.channels=s}get size(){return[this.width,this.height]}static async read(t){if(t instanceof Ut)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 new Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!_e.IS_WEB_ENV)throw new Error("fromCanvas() is only supported in browser environments.");const n=t.getContext("2d").getImageData(0,0,t.width,t.height).data;return new Ut(n,t.width,t.height,4)}static async fromURL(t){const r=await sa(t);if(r.status!==200)throw new Error(`Unable to read image from "${t}" (${r.status} ${r.statusText})`);const n=await r.blob();return this.fromBlob(n)}static async fromBlob(t){if(_e.IS_WEB_ENV){const r=await wr(t),n=Dr(r.width,r.height).getContext("2d");return n.drawImage(r,0,0),new this(n.getImageData(0,0,r.width,r.height).data,r.width,r.height,4)}else{const r=ai(await t.arrayBuffer());return await wr(r)}}static fromTensor(t,r="CHW"){if(t.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(r==="CHW")t=t.permute(1,2,0);else if(r!=="HWC")throw new Error(`Unsupported channel format: ${r}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new Ut(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw new Error(`Unsupported number of channels: ${t.dims[2]}`)}}grayscale(){if(this.channels===1)return this;const t=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let r=0,n=0;r<this.data.length;r+=this.channels){const s=this.data[r],a=this.data[r+1],o=this.data[r+2];t[n++]=Math.round(.2989*s+.587*a+.114*o)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,1)}rgb(){if(this.channels===3)return this;const t=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let r=0,n=0;r<this.data.length;++r)t[n++]=this.data[r],t[n++]=this.data[r],t[n++]=this.data[r];break;case 4:for(let r=0,n=0;r<this.data.length;r+=4)t[n++]=this.data[r],t[n++]=this.data[r+1],t[n++]=this.data[r+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,3)}rgba(){if(this.channels===4)return this;const t=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let r=0,n=0;r<this.data.length;++r)t[n++]=this.data[r],t[n++]=this.data[r],t[n++]=this.data[r],t[n++]=255;break;case 3:for(let r=0,n=0;r<this.data.length;r+=3)t[n++]=this.data[r],t[n++]=this.data[r+1],t[n++]=this.data[r+2],t[n++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(t,this.width,this.height,4)}putAlpha(t){if(t.width!==this.width||t.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${t.width}x${t.height}`);if(t.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${t.channels}`);const r=this.data,n=t.data,s=this.width*this.height;if(this.channels===3){const a=new Uint8ClampedArray(s*4);for(let o=0,i=0,l=0;o<s;++o)a[l++]=r[i++],a[l++]=r[i++],a[l++]=r[i++],a[l++]=n[o];return this._update(a,this.width,this.height,4)}else if(this.channels===4){for(let a=0;a<s;++a)r[4*a+3]=n[a];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(t,r,{resample:n=2}={}){if(this.width===t&&this.height===r)return this;let s=zE[n]??n;const a=rf(t),o=rf(r);if(a&&o)return this;if(a?t=r/this.height*this.width:o&&(r=t/this.width*this.height),_e.IS_WEB_ENV){const i=this.channels,l=this.toCanvas(),u=Dr(t,r).getContext("2d");return u.drawImage(l,0,0,t,r),new Ut(u.getImageData(0,0,t,r).data,t,r,4).convert(i)}else{let i=this.toSharp();switch(s){case"box":case"hamming":(s==="box"||s==="hamming")&&(pe.warn(`Resampling method ${s} is not yet supported. Using bilinear instead.`),s="bilinear");case"nearest":case"bilinear":case"bicubic":i=i.affine([t/this.width,0,0,r/this.height],{interpolator:s});break;case"lanczos":i=i.resize({width:t,height:r,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${s} is not supported.`)}return await wr(i)}}async pad([t,r,n,s]){if(t=Math.max(t,0),r=Math.max(r,0),n=Math.max(n,0),s=Math.max(s,0),t===0&&r===0&&n===0&&s===0)return this;if(_e.IS_WEB_ENV){const a=this.channels,o=this.toCanvas(),i=this.width+t+r,l=this.height+n+s,u=Dr(i,l).getContext("2d");return u.drawImage(o,0,0,this.width,this.height,t,n,this.width,this.height),new Ut(u.getImageData(0,0,i,l).data,i,l,4).convert(a)}else{const a=this.toSharp().extend({left:t,right:r,top:n,bottom:s});return await wr(a)}}async crop([t,r,n,s]){if(t=Math.max(t,0),r=Math.max(r,0),n=Math.min(n,this.width-1),s=Math.min(s,this.height-1),t===0&&r===0&&n===this.width-1&&s===this.height-1)return this;const a=n-t+1,o=s-r+1;if(_e.IS_WEB_ENV){const i=this.channels,l=this.toCanvas(),u=Dr(a,o).getContext("2d");return u.drawImage(l,t,r,a,o,0,0,a,o),new Ut(u.getImageData(0,0,a,o).data,a,o,4).convert(i)}else{const i=this.toSharp().extract({left:t,top:r,width:a,height:o});return await wr(i)}}async center_crop(t,r){if(this.width===t&&this.height===r)return this;const n=(this.width-t)/2,s=(this.height-r)/2;if(_e.IS_WEB_ENV){const a=this.channels,o=this.toCanvas(),i=Dr(t,r).getContext("2d");let l=0,u=0,h=0,f=0;return n>=0?l=n:h=-n,s>=0?u=s:f=-s,i.drawImage(o,l,u,t,r,h,f,t,r),new Ut(i.getImageData(0,0,t,r).data,t,r,4).convert(a)}else{let a=this.toSharp();if(n>=0&&s>=0)a=a.extract({left:Math.floor(n),top:Math.floor(s),width:t,height:r});else if(n<=0&&s<=0){const o=Math.floor(-s),i=Math.floor(-n);a=a.extend({top:o,left:i,right:t-this.width-i,bottom:r-this.height-o})}else{let o=[0,0],i=0;s<0?(o[0]=Math.floor(-s),o[1]=r-this.height-o[0]):i=Math.floor(s);let l=[0,0],u=0;n<0?(l[0]=Math.floor(-n),l[1]=t-this.width-l[0]):u=Math.floor(n),a=a.extend({top:o[0],bottom:o[1],left:l[0],right:l[1]}).extract({left:u,top:i,width:t,height:r})}return await wr(a)}}async toBlob(t="image/png",r=1){if(!_e.IS_WEB_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:t,quality:r})}toTensor(t="CHW"){let r=new W("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(t!=="HWC")if(t==="CHW")r=r.permute(2,0,1);else throw new Error(`Unsupported channel format: ${t}`);return r}toCanvas(){if(!_e.IS_WEB_ENV)throw new Error("toCanvas() is only supported in browser environments.");const t=this.clone().rgba(),r=Dr(t.width,t.height),n=new am(t.data,t.width,t.height);return r.getContext("2d").putImageData(n,0,0),r}split(){const{data:t,width:r,height:n,channels:s}=this,a=t.constructor,o=t.length/s,i=Array.from({length:s},()=>new a(o));for(let l=0;l<o;++l){const u=s*l;for(let h=0;h<s;++h)i[h][l]=t[u+h]}return i.map(l=>new Ut(l,r,n,1))}_update(t,r,n,s=null){return this.data=t,this.width=r,this.height=n,s!==null&&(this.channels=s),this}clone(){return new Ut(this.data.slice(),this.width,this.height,this.channels)}convert(t){if(this.channels===t)return this;switch(t){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(t){if(_e.IS_WEB_ENV){if(_e.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");const r=t.split(".").pop().toLowerCase(),n=RE.get(r)??"image/png",s=await this.toBlob(n);return hE(t,s)}else if(_e.IS_FS_AVAILABLE)await this.toSharp().toFile(t);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(_e.IS_WEB_ENV)throw new Error("toSharp() is only supported in server-side environments.");return ai(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}};Kn.read.bind(Kn);function Uf(e,t,r=0,n=null){const s=e/t;let a=jT(s)*t;return n!==null&&a>n&&(a=Math.floor(s)*t),a<r&&(a=Math.ceil(s)*t),a}function Wf([e,t],r){return[Math.max(Math.floor(e/r),1)*r,Math.max(Math.floor(t/r),1)*r]}function om([e,t,r,n]){return[e-r/2,t-n/2,e+r/2,t+n/2]}function _a(e,t=.5,r=null,n=!1){const s=e.logits,a=e.pred_boxes,[o,i,l]=s.dims;if(r!==null&&r.length!==o)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let u=[];for(let h=0;h<o;++h){let f=r!==null?r[h]:null,_={boxes:[],classes:[],scores:[]},g=s[h],w=a[h];for(let v=0;v<i;++v){let M=g[v],x=[],k;if(n){k=M.sigmoid().data;for(let C=0;C<k.length;++C)k[C]>t&&x.push(C)}else{let C=Ye(M.data)[1];if(C===l-1||(k=bn(M.data),k[C]<t))continue;x.push(C)}for(const C of x){let E=w[v].data;E=om(E),f!==null&&(E=E.map((F,z)=>F*f[(z+1)%2])),_.boxes.push(E),_.classes.push(C),_.scores.push(k[C])}}u.push(_)}return u}function im(e,t=null){const r=e.logits,n=r.dims[0];if(t!==null&&t.length!==n)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");const s=[];for(let a=0;a<n;++a){const o=t!==null?t[a]:null;let i=r[a];o!==null&&(i=zp(i,o,"bilinear",!1));const[l,u]=o??i.dims.slice(-2),h=new W("int32",new Int32Array(l*u),[l,u]),f=i[0].data,_=h.data;for(let v=1;v<i.dims[0];++v){const M=i[v].data;for(let x=0;x<M.length;++x)M[x]>f[x]&&(f[x]=M[x],_[x]=v)}const g=new Array(i.dims[0]);for(let v=0;v<_.length;++v){const M=_[v];g[M]=M}const w=g.filter(v=>v!==void 0);s.push({segmentation:h,labels:w})}return s}function $E(e,t,r,n){const s=[],a=[],o=[];for(let i=0;i<e.dims[0];++i){const l=e[i],u=t[i],h=Ye(l.data)[1];if(h===n)continue;const _=bn(l.data)[h];_>r&&(s.push(u),a.push(_),o.push(h))}return[s,a,o]}function GE(e,t,r,n=.5,s=.8){const a=[];let o=0,i=0;const l=t[r].data;for(let h=0;h<e.length;++h)e[h]===r&&(a.push(h),++o),l[h]>=n&&++i;let u=o>0&&i>0;return u&&(u=o/i>s),[u,a]}function VE(e,t,r,n,s,a=null,o=null){const[i,l]=o??e[0].dims,u=new W("int32",new Int32Array(i*l),[i,l]),h=[];if(o!==null)for(let v=0;v<e.length;++v)e[v]=zp(e[v],o,"bilinear",!1);const f=new Int32Array(e[0].data.length),_=new Float32Array(e[0].data.length);for(let v=0;v<e.length;++v){let M=t[v];const x=e[v].data;for(let k=0;k<x.length;++k)x[k]*=M,x[k]>_[k]&&(f[k]=v,_[k]=x[k])}let g=0;const w=u.data;for(let v=0;v<r.length;++v){const M=r[v],[x,k]=GE(f,e,v,n,s);if(x){++g;for(const C of k)w[C]=g;h.push({id:g,label_id:M,score:t[v]})}}return[u,h]}function Qi(e,t,r=28,n=3136,s=784*1280,a=1){if(e<r||t<r){const l=Math.max(r/e,r/t);e=Math.round(e*l),t=Math.round(t*l)}if(Math.max(e,t)/Math.min(e,t)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let o=Math.round(e/r)*r,i=Math.round(t/r)*r;if(a*o*i>s){const l=Math.sqrt(a*e*t/s);o=Math.max(r,Math.floor(e/l/r)*r),i=Math.max(r,Math.floor(t/l/r)*r)}else if(a*o*i<n){const l=Math.sqrt(n/(a*e*t));o=Math.ceil(e*l/r)*r,i=Math.ceil(t*l/r)*r}return[i,o]}function lm(e,t=.5,r=.5,n=.8,s=null,a=null){s===null&&(pe.warn("`label_ids_to_fuse` unset. No instance will be fused."),s=new Set);const o=e.class_queries_logits??e.logits,l=(e.masks_queries_logits??e.pred_masks).sigmoid();let[u,h,f]=o.dims;if(f-=1,a!==null&&a.length!==u)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let _=[];for(let g=0;g<u;++g){let w=a!==null?a[g]:null,v=o[g],M=l[g],[x,k,C]=$E(v,M,t,f);if(C.length===0){let[z,b]=w??M.dims.slice(-2),V=new W("int32",new Int32Array(z*b).fill(-1),[z,b]);_.push({segmentation:V,segments_info:[]});continue}let[E,F]=VE(x,k,C,r,n,s,w);_.push({segmentation:E,segments_info:F})}return _}function cm(e,t=.5,r=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var de=class extends wt{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,r=2){const n=e.height,s=e.width,a=t.height,o=t.width;let i=Math.min(n,a),l=Math.min(s,o);return i===n&&l===s?e:(n>s?l=Math.floor(s*i/n):s>n&&(i=Math.floor(n*l/s)),await e.resize(l,i,{resample:r}))}async crop_margin(e,t=200){const r=e.clone().grayscale(),n=ti(r.data)[0],a=Ye(r.data)[0]-n;if(a===0)return e;const o=t/255;let i=r.width,l=r.height,u=0,h=0;const f=r.data;for(let _=0;_<r.height;++_){const g=_*r.width;for(let w=0;w<r.width;++w)(f[g+w]-n)/a<o&&(i=Math.min(i,w),l=Math.min(l,_),u=Math.max(u,w),h=Math.max(h,_))}return e=await e.crop([i,l,u,h]),e}pad_image(e,t,r,{mode:n="constant",center:s=!1,constant_values:a=0}={}){const[o,i,l]=t;let u,h;if(typeof r=="number"?(u=r,h=r):r==="square"?u=h=Math.max(o,i):(u=r.width,h=r.height),u!==i||h!==o){const f=new Float32Array(u*h*l);if(Array.isArray(a))for(let w=0;w<f.length;++w)f[w]=a[w%l];else a!==0&&f.fill(a);const[_,g]=s?[Math.floor((u-i)/2),Math.floor((h-o)/2)]:[0,0];for(let w=0;w<o;++w){const v=(w+g)*u,M=w*i;for(let x=0;x<i;++x){const k=(v+x+_)*l,C=(M+x)*l;for(let E=0;E<l;++E)f[k+E]=e[C+E]}}if(n==="symmetric"){if(s)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");const w=o-1,v=i-1;for(let M=0;M<h;++M){const x=M*u,k=Ys(M,w)*i;for(let C=0;C<u;++C){if(M<o&&C<i)continue;const E=(x+C)*l,F=(k+Ys(C,v))*l;for(let z=0;z<l;++z)f[E+z]=e[F+z]}}}e=f,t=[h,u,l]}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){const[r,n]=e.size;let s,a;if(this.do_thumbnail){const{height:o,width:i}=t;s=Math.min(o,i)}else Number.isInteger(t)?(s=t,a=this.config.max_size??s):t!==void 0&&(s=t.shortest_edge,a=t.longest_edge);if(s!==void 0||a!==void 0){const o=s===void 0?1:Math.max(s/r,s/n),i=r*o,l=n*o,u=a===void 0?1:Math.min(a/i,a/l);let h=Math.floor(Number((i*u).toFixed(2))),f=Math.floor(Number((l*u).toFixed(2)));return this.size_divisibility!==void 0&&([h,f]=Wf([h,f],this.size_divisibility)),[h,f]}else if(t!==void 0&&t.width!==void 0&&t.height!==void 0){let o=t.width,i=t.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let l=i/n,u=o/r;Math.abs(1-u)<Math.abs(1-l)?l=u:u=l,i=Uf(l*n,this.config.ensure_multiple_of),o=Uf(u*r,this.config.ensure_multiple_of)}return[o,i]}else{if(this.size_divisibility!==void 0)return Wf([r,n],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(t)}`)}}async resize(e){const[t,r]=this.get_resize_output_image_size(e,this.size);return await e.resize(t,r,{resample:this.resample})}async preprocess(e,{do_normalize:t=null,do_pad:r=null,do_convert_rgb:n=null,do_convert_grayscale:s=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));const[o,i]=e.size;if(n??this.do_convert_rgb?e=e.rgb():s&&(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 _,g;Number.isInteger(this.crop_size)?(_=this.crop_size,g=this.crop_size):(_=this.crop_size.width,g=this.crop_size.height),e=await e.center_crop(_,g)}const l=[e.height,e.width];let u=Float32Array.from(e.data),h=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(u),t??this.do_normalize){let _=this.image_mean;Array.isArray(this.image_mean)||(_=new Array(e.channels).fill(_));let g=this.image_std;if(Array.isArray(this.image_std)||(g=new Array(e.channels).fill(g)),_.length!==e.channels||g.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${_.length}) and \`image_std\` (${g.length}) must match the number of channels in the image (${e.channels}).`);for(let w=0;w<u.length;w+=e.channels)for(let v=0;v<e.channels;++v)u[w+v]=(u[w+v]-_[v])/g[v]}if(r??this.do_pad){if(this.pad_size)[u,h]=this.pad_image(u,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){const _=Math.ceil(h[1]/this.size_divisibility)*this.size_divisibility,g=Math.ceil(h[0]/this.size_divisibility)*this.size_divisibility;[u,h]=this.pad_image(u,h,{width:_,height:g})}}if(a??this.do_flip_channel_order){if(h[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let _=0;_<u.length;_+=3){const g=u[_];u[_]=u[_+2],u[_+2]=g}}const f=new W("float32",u,h).permute(2,0,1);return{original_size:[i,o],reshaped_input_size:l,pixel_values:f}}async _call(e,...t){Array.isArray(e)||(e=[e]);const r=await Promise.all(e.map(s=>this.preprocess(s)));return{pixel_values:sr(r.map(s=>s.pixel_values),0),original_sizes:r.map(s=>s.original_size),reshaped_input_sizes:r.map(s=>s.reshaped_input_size)}}static async from_pretrained(e,t={}){const r=await ir(e,Hp,!0,t);return new this(r)}},um={};es(um,{BeitFeatureExtractor:()=>UE,BitImageProcessor:()=>WE,CHMv2ImageProcessor:()=>qE,CLIPFeatureExtractor:()=>HE,CLIPImageProcessor:()=>dm,ChineseCLIPFeatureExtractor:()=>jE,ConvNextFeatureExtractor:()=>QE,ConvNextImageProcessor:()=>hm,DINOv3ViTImageProcessor:()=>JE,DPTFeatureExtractor:()=>ZE,DPTImageProcessor:()=>pm,DeiTFeatureExtractor:()=>XE,DeiTImageProcessor:()=>fm,DetrFeatureExtractor:()=>YE,DetrImageProcessor:()=>_m,DonutFeatureExtractor:()=>KE,DonutImageProcessor:()=>Xi,EfficientNetImageProcessor:()=>e2,GLPNFeatureExtractor:()=>a2,Gemma3ImageProcessor:()=>t2,Gemma4ImageProcessor:()=>mm,Glm46VImageProcessor:()=>s2,GroundingDinoImageProcessor:()=>o2,Idefics3ImageProcessor:()=>jf,ImageFeatureExtractor:()=>de,ImageProcessor:()=>de,JinaCLIPImageProcessor:()=>l2,Lfm2VlImageProcessor:()=>f2,LlavaOnevisionImageProcessor:()=>_2,Mask2FormerImageProcessor:()=>m2,MaskFormerFeatureExtractor:()=>p2,MaskFormerImageProcessor:()=>Yi,MobileNetV1FeatureExtractor:()=>g2,MobileNetV1ImageProcessor:()=>wm,MobileNetV2FeatureExtractor:()=>w2,MobileNetV2ImageProcessor:()=>vm,MobileNetV3FeatureExtractor:()=>v2,MobileNetV3ImageProcessor:()=>ym,MobileNetV4FeatureExtractor:()=>y2,MobileNetV4ImageProcessor:()=>bm,MobileViTFeatureExtractor:()=>b2,MobileViTImageProcessor:()=>Mm,NougatImageProcessor:()=>M2,OwlViTFeatureExtractor:()=>x2,OwlViTImageProcessor:()=>Ji,Owlv2ImageProcessor:()=>T2,Phi3VImageProcessor:()=>E2,PixtralImageProcessor:()=>C2,PvtImageProcessor:()=>A2,Qwen2VLImageProcessor:()=>gm,RTDetrImageProcessor:()=>S2,Sam2ImageProcessor:()=>Uo,Sam3ImageProcessor:()=>Uo,SamImageProcessor:()=>Uo,SapiensFeatureExtractor:()=>P2,SapiensImageProcessor:()=>xm,SegformerFeatureExtractor:()=>F2,SegformerImageProcessor:()=>Tm,SiglipImageProcessor:()=>I2,SmolVLMImageProcessor:()=>jf,Swin2SRImageProcessor:()=>L2,VLMImageProcessor:()=>i2,ViTFeatureExtractor:()=>O2,ViTImageProcessor:()=>km,VitMatteImageProcessor:()=>N2,VitPoseImageProcessor:()=>D2,YolosFeatureExtractor:()=>B2,YolosImageProcessor:()=>Em});var UE=class extends de{},WE=class extends de{},jE=class extends de{},qE=class extends de{},dm=class extends de{},HE=class extends dm{},hm=class extends de{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){const t=this.size?.shortest_edge;if(t===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(t<384){const r=Math.floor(t/this.crop_pct),[n,s]=this.get_resize_output_image_size(e,{shortest_edge:r});e=await e.resize(n,s,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},QE=class extends hm{},fm=class extends de{},XE=class extends fm{},_m=class extends de{async _call(e){const t=await super._call(e),r=[t.pixel_values.dims[0],64,64],n=ot(r,1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return _a(...e)}post_process_panoptic_segmentation(...e){return lm(...e)}post_process_instance_segmentation(...e){return cm(...e)}},YE=class extends _m{},JE=class extends de{},Xi=class extends de{pad_image(e,t,r,n={}){const[s,a,o]=t;let i=this.image_mean;Array.isArray(this.image_mean)||(i=new Array(o).fill(i));let l=this.image_std;Array.isArray(l)||(l=new Array(o).fill(i));const u=i.map((h,f)=>-h/l[f]);return super.pad_image(e,t,r,{center:!0,constant_values:u,...n})}},KE=class extends Xi{},pm=class extends de{},ZE=class extends pm{},e2=class extends de{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(t=>t*t))}},t2=class extends de{};function r2(e,t,r,n,s){const a=n*r**2,o=Math.sqrt(a/(e*t)),i=s*r;let l=Math.floor(o*e/i)*i,u=Math.floor(o*t/i)*i;if(l===0&&u===0)throw new Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${i}.`);const h=Math.floor(n/s**2)*i;return l===0?(l=i,u=Math.min(Math.floor(t/e)*i,h)):u===0&&(u=i,l=Math.min(Math.floor(e/t)*i,h)),[l,u]}function n2(e,t,r,n,s,a,o){const i=Math.floor(t/s),l=Math.floor(r/s),u=i*l,h=s*s*n,f=new Float32Array(a*h);let _=0;for(let v=0;v<i;++v)for(let M=0;M<l;++M)for(let x=0;x<s;++x){const k=(v*s+x)*r*n+M*s*n;for(let C=0;C<s;++C){const E=k+C*n;for(let F=0;F<n;++F)f[_++]=e[E+F]}}const g=new BigInt64Array(a*2).fill(-1n);let w=0;for(let v=0;v<i;++v)for(let M=0;M<l;++M)g[w++]=BigInt(M),g[w++]=BigInt(v);return{patches:new W("float32",f,[a,h]),positions:new W("int64",g,[a,2]),num_soft_tokens:Math.floor(u/o**2)}}var mm=class extends wt{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]);const{patch_size:t,pooling_kernel_size:r}=this,n=this.max_soft_tokens*r**2,s=[],a=[],o=[];for(let i of e){if(this.do_convert_rgb&&(i=i.rgb()),this.do_resize){const[_,g]=r2(i.height,i.width,t,n,r);(_!==i.height||g!==i.width)&&(i=await i.resize(g,_,{resample:this.resample}))}const l=Float32Array.from(i.data);if(this.do_rescale)for(let _=0;_<l.length;++_)l[_]*=this.rescale_factor;const{patches:u,positions:h,num_soft_tokens:f}=n2(l,i.height,i.width,i.channels,t,n,r);s.push(u),a.push(h),o.push(f)}return{pixel_values:sr(s,0),image_position_ids:sr(a,0),num_soft_tokens_per_image:o}}},gm=class extends de{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){const r=this.patch_size*this.merge_size;return Qi(e.height,e.width,r,this.min_pixels,this.max_pixels)}async _call(e,...t){const{pixel_values:r,original_sizes:n,reshaped_input_sizes:s}=await super._call(e,...t);let a=r;const{temporal_patch_size:o,merge_size:i,patch_size:l}=this.config;a.dims[0]===1&&(a=De(Array.from({length:o},()=>a),0));const u=a.dims[0]/o,h=a.dims[1],f=Math.floor(a.dims[2]/l),_=Math.floor(a.dims[3]/l),g=a.view(u,o,h,Math.floor(f/i),i,l,Math.floor(_/i),i,l).permute(0,3,6,4,7,2,1,5,8).view(u*f*_,h*o*l*l),w=new W("int64",[u,f,_],[1,3]);return{pixel_values:g,image_grid_thw:w,original_sizes:n,reshaped_input_sizes:s}}},s2=class extends gm{get_resize_output_image_size(e,t){const r=this.patch_size*this.merge_size,n=this.config.temporal_patch_size??2;return Qi(e.height,e.width,r,this.min_pixels,this.max_pixels,n)}},a2=class extends de{},o2=class extends de{async _call(e){const t=await super._call(e),r=t.pixel_values.dims,n=dt([r[0],r[2],r[3]]);return{...t,pixel_mask:n}}},jf=class extends de{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[r,n]=e.dims.slice(-2);const s=n/r;return n>=r?(n=Math.ceil(n/t)*t,r=Math.floor(n/s),r=Math.ceil(r/t)*t):(r=Math.ceil(r/t)*t,n=Math.floor(r*s),n=Math.ceil(n/t)*t),{height:r,width:n}}async _call(e,{do_image_splitting:t=null,return_row_col_info:r=!1}={}){let n;if(!Array.isArray(e))n=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?n=e:n=[e]}let s=[],a=[],o=[];const i=[],l=[];for(const M of n){let x=await Promise.all(M.map(E=>this.preprocess(E)));i.push(...x.map(E=>E.original_size)),l.push(...x.map(E=>E.reshaped_input_size)),x.forEach(E=>E.pixel_values.unsqueeze_(0));const{longest_edge:k}=this.max_image_size;let C;if(t??this.do_image_splitting){let E=new Array(x.length),F=new Array(x.length);C=await Promise.all(x.map(async(z,b)=>{const V=this.get_resize_for_vision_encoder(z.pixel_values,k),R=await Qt(z.pixel_values,{size:[V.height,V.width]}),{frames:H,num_splits_h:J,num_splits_w:X}=await this.split_image(R,this.max_image_size);return E[b]=J,F[b]=X,De(H,0)})),a.push(E),o.push(F)}else{const E=[k,k];C=await Promise.all(x.map(F=>Qt(F.pixel_values,{size:E}))),a.push(new Array(x.length).fill(0)),o.push(new Array(x.length).fill(0))}s.push(De(C,0))}const u=s.length,[h,f,_,g]=s[0].dims;let w,v;if(u===1)w=s[0].unsqueeze_(0),v=ot([u,h,_,g],!0);else{const M=Math.max(...s.map(C=>C.dims.at(0)));v=ot([u,M,_,g],!0);const x=v.data,k=M*_*g;for(let C=0;C<u;++C){const E=s[C].dims[0];if(E<M){s[C]=De([s[C],ot([M-E,f,_,g],0)],0);const F=C*k+E*_*g,z=(C+1)*k;x.fill(!1,F,z)}}w=sr(s,0)}return{pixel_values:w,pixel_attention_mask:v,original_sizes:i,reshaped_input_sizes:l,...r?{rows:a,cols:o}:{}}}async split_image(e,{longest_edge:t}){const r=t,n=t,s=[],[a,o]=e.dims.slice(-2);let i=0,l=0;if(a>r||o>n){i=Math.ceil(a/r),l=Math.ceil(o/n);const u=Math.ceil(a/i),h=Math.ceil(o/l);for(let g=0;g<i;++g)for(let w=0;w<l;++w){let v,M,x,k;g===i-1?(M=a-u,k=a):(M=g*u,k=(g+1)*u),w===l-1?(v=o-h,x=o):(v=w*h,x=(w+1)*h);const F=await $p(e,[M,v],[k,x],[2,3]);s.push(F)}const f=r,_=n;(a!==f||o!==_)&&(e=await Qt(e,{size:[f,_]}))}return s.push(e),{frames:s,num_splits_h:i,num_splits_w:l}}},i2=class extends de{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(t=>t*this.rescale_factor)}pad_image(e,t,r,n){return super.pad_image(e,t,r,{constant_values:this.constant_values,center:!0,...n})}},l2=class extends de{constructor(e){const{resize_mode:t,fill_color:r,interpolation:n,size:s,...a}=e,o=t==="squash"?{width:s,height:s}:t==="shortest"?{shortest_edge:s}:{longest_edge:s},i=n==="bicubic"?3:2;super({...a,size:o,resample:i,do_center_crop:!0,crop_size:s,do_normalize:!0})}};function qf(e,t){return Math.round(e/t)*t}function c2(e,t,r,n,s){let a=1/0,o=[1,1];const i=r*n;for(const l of t){const u=Math.abs(e-l[0]/l[1]);u<a?(a=u,o=l):u===a&&i>.5*s*s*l[0]*l[1]&&(o=l)}return o}function u2(e,t){const r=[],n=new Set;for(let s=e;s<=t;++s)for(let a=1;a<=s;++a)for(let o=1;o<=s;++o){const i=a*o;if(i>=e&&i<=t){const l=a<<16|o;n.has(l)||(n.add(l),r.push([a,o]))}}return r.sort((s,a)=>s[0]*s[1]-a[0]*a[1])}function d2(e,t){const[r,n,s,a]=e.dims,o=Math.floor(s/t),i=Math.floor(a/t),l=t*t*n,u=e.data,h=new Float32Array(r*o*i*l),f=s*a;for(let _=0;_<r;++_){const g=_*n*f,w=_*o*i*l;for(let v=0;v<o;++v)for(let M=0;M<i;++M){let x=w+(v*i+M)*l;for(let k=0;k<t;++k){const C=(v*t+k)*a+M*t;for(let E=0;E<t;++E){const F=C+E;for(let z=0;z<n;++z)h[x++]=u[g+z*f+F]}}}}return new W("float32",h,[r,o*i,l])}function h2(e,t){const[,r,n]=e.dims,s=new BigInt64Array(t);s.fill(1n,0,r);let a=e;if(r<t){const o=new Float32Array(t*n);o.set(e.data),a=new W("float32",o,[1,t,n])}return{padded:a,mask:new W("int64",s,[t])}}var f2=class extends de{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;const t=this.max_image_tokens*this.downsample_factor**2,r=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(t,r)}_is_image_too_large(e,t){const r=this.encoder_patch_size*this.downsample_factor,n=Math.max(this.encoder_patch_size,qf(e,r)),s=Math.max(this.encoder_patch_size,qf(t,r));return n*s>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){const r=u2(this.min_tiles,this.max_tiles),[n,s]=c2(t/e,r,t,e,this.tile_size);return{grid_width:n,grid_height:s,target_width:this.tile_size*n,target_height:this.tile_size*s}}async _call(e,{return_row_col_info:t=null}={}){let r;Array.isArray(e)?Array.isArray(e[0])?r=e:r=[e]:r=[[e]];const n=[],s=[],a=[],o=[],i=[],l=[];for(const h of r){const f=await Promise.all(h.map(_=>this.preprocess(_,{do_pad:!1})));for(const{pixel_values:_}of f){const[,g,w]=_.dims,v=_.unsqueeze_(0),M=this.encoder_patch_size*this.downsample_factor,x=M**2,[k,C]=Qi(Math.max(M,g),Math.max(M,w),M,this.min_image_tokens*x,this.max_image_tokens*x).map(R=>Math.max(M,R));let E,F=1,z=1;const b=this._is_image_too_large(g,w),V=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(b&&V){const{grid_width:R,grid_height:H,target_width:J,target_height:X}=this._get_grid_layout(g,w);F=H,z=R;const D=await Qt(v,{size:[X,J]});E=[];for(let I=0;I<H;++I)for(let G=0;G<R;++G){const Q=I*this.tile_size,ce=G*this.tile_size;E.push(D.slice(null,null,[Q,Q+this.tile_size],[ce,ce+this.tile_size]))}this.use_thumbnail&&R*H!==1&&E.push(await Qt(v,{size:[C,k]}))}else E=[await Qt(v,{size:[C,k]})];for(const R of E){const[,,H,J]=R.dims,X=d2(R,this.encoder_patch_size),{padded:D,mask:I}=h2(X,this.max_num_patches);n.push(D),s.push(I),a.push([Math.floor(H/this.encoder_patch_size),Math.floor(J/this.encoder_patch_size)])}o.push(F),i.push(z),l.push([C,k])}}const u={pixel_values:De(n,0),pixel_attention_mask:sr(s,0),spatial_shapes:new W("int64",BigInt64Array.from(a.flat(),BigInt),[a.length,2])};return(t??this.return_row_col_info)&&(u.image_rows=o,u.image_cols=i,u.image_sizes=l),u}},_2=class extends de{},Yi=class extends de{post_process_panoptic_segmentation(...e){return lm(...e)}post_process_instance_segmentation(...e){return cm(...e)}},p2=class extends Yi{},m2=class extends Yi{},wm=class extends de{},g2=class extends wm{},vm=class extends de{},w2=class extends vm{},ym=class extends de{},v2=class extends ym{},bm=class extends de{},y2=class extends bm{},Mm=class extends de{},b2=class extends Mm{},M2=class extends Xi{},Ji=class extends de{post_process_object_detection(...e){return _a(...e)}},x2=class extends Ji{},T2=class extends Ji{},ft=336,k2=[2,3],{ceil:Go,floor:an,sqrt:Vo}=Math,E2=class extends de{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){const{num_img_tokens:r}=this.config;return an((an(t/ft)*an(e/ft)+1)*r+1+(an(t/ft)+1)*Vo(r))}get_resize_output_image_size(e,t){const r=this._num_crops,[n,s]=e.size;let a=n/s,o=1;for(;o*Math.ceil(o/a)<=r;)o+=1;o-=1;const i=Math.floor(o*336),l=Math.floor(i/a);return[i,l]}pad_image(e,t,r,n={}){const[s,a]=t,o=ft*Go(s/ft),i=ft*Go(a/ft),l=[1,1,1].map((u,h)=>(u-this.image_mean[h])/this.image_std[h]);return super.pad_image(e,t,{width:i,height:o},{center:!0,constant_values:l,...n})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||Vo(t)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);const r=e.length,n=await Promise.all(e.map(f=>this.preprocess(f))),s=n.map(f=>f.original_size),a=n.map(f=>f.reshaped_input_size),o=[];for(const{pixel_values:f}of n){f.unsqueeze_(0);const[_,g]=f.dims.slice(-2),w=await Qt(f,{size:[ft,ft],mode:"bicubic"});if(t>0){const v=[],M=Vo(t),x=an(g/M),k=an(_/M);for(let E=0;E<M;++E)for(let F=0;F<M;++F){let z,b,V,R;E===M-1?(b=_-k,R=_):(b=E*k,R=(E+1)*k),F===M-1?(z=g-x,V=g):(z=F*x,V=(F+1)*x);const X=await $p(f,[b,z],[R,V],k2);v.push(X)}const C=await Qt(De(v,0),{size:[ft,ft],mode:"bicubic"});o.push(De([w,C],0))}else o.push(w)}const i=sr(o,0),l=a.map(f=>f.map(_=>ft*Go(_/ft))),u=new W("int64",l.flat(),[r,2]),h=l.map(([f,_])=>this.calc_num_image_tokens_from_image_size(_,f));return{pixel_values:i,original_sizes:s,reshaped_input_sizes:a,image_sizes:u,num_img_tokens:h}}},C2=class extends de{get_resize_output_image_size(e,t){const{longest_edge:r}=t;if(r===void 0)throw new Error("size must contain 'longest_edge'");const[n,s]=e.size,a=Math.max(n,s)/r;let o=n,i=s;a>1&&(o=Math.floor(n/a),i=Math.floor(s/a));const{patch_size:l,spatial_merge_size:u}=this.config;if(!u)throw new Error("config must contain 'spatial_merge_size'");const h=l*u,f=Math.floor((o-1)/h)+1,_=Math.floor((i-1)/h)+1;return[f*h,_*h]}},A2=class extends de{},S2=class extends de{post_process_object_detection(...e){return _a(...e)}},Uo=class extends de{reshape_input_points(e,t,r,n=!1){e=structuredClone(e);let s=nf(e);if(s.length===3)n||(s=[1,...s]),e=[e];else if(s.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let a=0;a<e.length;++a){const[o,i]=t[a],[l,u]=r[a],h=[u/i,l/o];for(let f=0;f<e[a].length;++f)for(let _=0;_<e[a][f].length;++_)for(let g=0;g<e[a][f][_].length;++g)e[a][f][_][g]*=h[g%2]}return new W("float32",Float32Array.from(e.flat(1/0)),s)}add_input_labels(e,t){let r=nf(e);if(r.length===2)r=[1,...r],e=[e];else if(r.length!==3)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");if(r.some((n,s)=>n!==t.dims[s]))throw Error(`The first ${r.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new W("int64",e.flat(1/0).map(BigInt),r)}async _call(e,{input_points:t=null,input_labels:r=null,input_boxes:n=null}={}){const s=await super._call(e);if(t&&(s.input_points=this.reshape_input_points(t,s.original_sizes,s.reshaped_input_sizes)),r){if(!s.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");s.input_labels=this.add_input_labels(r,s.input_points)}return n&&(s.input_boxes=this.reshape_input_points(n,s.original_sizes,s.reshaped_input_sizes,!0)),s}async post_process_masks(e,t,r,{mask_threshold:n=0,binarize:s=!0,pad_size:a=null}={}){const o=[];a=a??this.pad_size??this.size;const i=[a.height,a.width];for(let l=0;l<t.length;++l){const u=t[l],h=r[l];let f=await Qt(e[l],{mode:"bilinear",size:i});if(f=f.slice(null,null,[0,h[0]],[0,h[1]]),f=await Qt(f,{mode:"bilinear",size:u}),s){const _=f.data,g=new Uint8Array(_.length);for(let w=0;w<_.length;++w)_[w]>n&&(g[w]=1);f=new W("bool",g,f.dims)}o.push(f)}return o}generate_crop_boxes(e,t,{crop_n_layers:r=0,overlap_ratio:n=512/1500,points_per_crop:s=32,crop_n_points_downscale_factor:a=1}={}){}},xm=class extends de{post_process_semantic_segmentation(...e){return im(...e)}},P2=class extends xm{},Tm=class extends de{post_process_semantic_segmentation(...e){return im(...e)}},F2=class extends Tm{},I2=class extends de{},L2=class extends de{pad_image(e,t,r,n={}){const[s,a,o]=t;return super.pad_image(e,t,{width:a+(r-a%r)%r,height:s+(r-s%r)%r},{mode:"symmetric",center:!1,constant_values:-1,...n})}},km=class extends de{},O2=class extends km{},N2=class extends de{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);const r=await Promise.all(e.map(a=>this.preprocess(a))),n=await Promise.all(t.map(a=>this.preprocess(a,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:sr(r.map((a,o)=>De([a.pixel_values,n[o].pixel_values],0)),0),original_sizes:r.map(a=>a.original_size),reshaped_input_sizes:r.map(a=>a.reshaped_input_size)}}},D2=class extends de{post_process_pose_estimation(e,t,{threshold:r=null}={}){const n=e.tolist(),[s,a,o,i]=e.dims,l=[];for(let u=0;u<s;++u){const h=n[u],f=t[u],_=[];for(let g=0;g<f.length;++g){const w=f[g],v=[],M=[],x=[],k=w.at(-2)/i,C=w.at(-1)/o;for(let E=0;E<h.length;++E){let[F,z]=[0,0],b=0,V=-1/0;const R=h[E];for(let J=0;J<R.length;++J){const X=R[J];for(let D=0;D<X.length;++D){const I=X[D];b+=I,V=Math.max(V,I),F+=(D+.5)*I,z+=J*I}}if(r!=null&&V<r)continue;const H=[k*F/b,C*z/b];v.push(H),x.push(E),M.push(V)}_.push({bbox:w,scores:M,labels:x,keypoints:v})}l.push(_)}return l}},Em=class extends de{post_process_object_detection(...e){return _a(...e)}},B2=class extends Em{},lt=class{static async from_pretrained(e,t={}){const r=await ir(e,Hp,!0,t),n=r.image_processor_type??r.feature_extractor_type;let s=um[n?.replace(/Fast$/,"")];return s||(n!==void 0&&pe.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${fa}.`),s=de),new s(r)}},z2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;constructor(e,t,r){super(e,t,r);const{tasks_answer_post_processing_type:n,task_prompts_without_inputs:s,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(n??{})),this.task_prompts_without_inputs=new Map(Object.entries(s??{})),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]);const t=[];for(const r of e)if(this.task_prompts_without_inputs.has(r))t.push(this.task_prompts_without_inputs.get(r));else{for(const[n,s]of this.task_prompts_with_input)if(r.includes(n)){t.push(s.replaceAll("{input}",r).replaceAll(n,""));break}t.length!==e.length&&t.push(r)}return t}post_process_generation(e,t,r){const n=this.tasks_answer_post_processing_type.get(t)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let s;switch(n){case"pure_text":s=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":const a=n==="ocr"?"quad_boxes":"bboxes",o=e.matchAll(this.regexes[a]),i=[],l=[];for(const[u,h,...f]of o)i.push(h?h.trim():i.at(-1)??""),l.push(f.map((_,g)=>(Number(_)+.5)/this.size_per_bin*r[g%2]));s={labels:i,[a]:l};break;default:throw new Error(`Task "${t}" (of type "${n}") not yet implemented.`)}return{[t]:s}}async _call(e,t=null,r={}){if(!e&&!t)throw new Error("Either text or images must be provided");const n=await this.image_processor(e,r),s=t?this.tokenizer(this.construct_prompts(t),r):{};return{...n,...s}}},R2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.image_seq_length=this.config.image_seq_length;const{boi_token:n,image_token:s,eoi_token:a}=this.tokenizer.config;this.boi_token=n,this.image_token=s,this.eoi_token=a;const o=s.repeat(this.image_seq_length);this.full_image_sequence=`
17
+
18
+ ${n}${o}${a}
19
+
20
+ `}async _call(e,t=null,r={}){typeof e=="string"&&(e=[e]);let n;return t&&(n=await this.image_processor(t,r),e=e.map(a=>a.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,r),...n}}},$2=class extends Pe{static image_processor_class=lt;static feature_extractor_class=Et;static tokenizer_class=Se;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;const{audio_token_id:n,boa_token:s,audio_token:a,eoa_token:o,image_token_id:i,boi_token:l,image_token:u,eoi_token:h}=this.tokenizer.config;this.audio_token_id=n,this.boa_token=s,this.audio_token=a;const f=a.repeat(this.audio_seq_length);this.full_audio_sequence=`
21
+
22
+ ${s}${f}${o}
23
+
24
+ `,this.image_token_id=i,this.boi_token=l,this.image_token=u;const _=u.repeat(this.image_seq_length);this.full_image_sequence=`
25
+
26
+ ${l}${_}${h}
27
+
28
+ `}async _call(e,t=null,r=null,n={}){typeof e=="string"&&(e=[e]);let s;r&&(s=await this.feature_extractor(r,n),e=e.map(i=>i.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return t&&(a=await this.image_processor(t,n),e=e.map(i=>i.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,n),...a,...s}}},G2=class extends Pe{static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,r){super(e,t,r),this.audio_ms_per_token=this.config.audio_ms_per_token??40,this.audio_seq_length=this.config.audio_seq_length??750,this.image_seq_length=this.config.image_seq_length??280;const{audio_token:n,boa_token:s,eoa_token:a,image_token:o,boi_token:i,eoi_token:l}=this.tokenizer.config;this.audio_token=n,this.boa_token=s,this.eoa_token=a,this.image_token=o,this.boi_token=i,this.eoi_token=l}static async from_pretrained(e,t={}){const[r,n,s]=await Promise.all([ir(e,Qp,!0,t),Se.from_pretrained(e,t),$i(e,Xp,!1,t)]),a={tokenizer:n};return r.image_processor&&(a.image_processor=new mm(r.image_processor)),r.feature_extractor&&(a.feature_extractor=new nm(r.feature_extractor)),new this(r,a,s)}_compute_audio_num_tokens(e,t){const r=Math.round(t*20/1e3),n=Math.round(t*10/1e3),s=Math.floor(r/2);let a=Math.floor((e+s-r-1)/n)+1;if(a<=0)return 0;for(let o=0;o<2;++o)a=Math.floor((a-1)/2)+1;return Math.min(a,this.audio_seq_length)}async _call(e,t=null,r=null,n={}){typeof e=="string"&&(e=[e]);let s;if(t){s=await this.image_processor(t,n);const o=s.num_soft_tokens_per_image;let i=0;e=e.map(l=>l.replaceAll(this.image_token,()=>`
29
+
30
+ ${this.boi_token}${this.image_token.repeat(o[i++])}${this.eoi_token}
31
+
32
+ `))}let a;if(r){const o=Array.isArray(r)?r:[r];a=await this.feature_extractor(o[0],n);const i=this.feature_extractor.config.sampling_rate??16e3;let l=0;e=e.map(u=>u.replaceAll(this.audio_token,()=>`
33
+
34
+ ${this.boa_token}${this.audio_token.repeat(this._compute_audio_num_tokens(o[l++].length,i))}${this.eoa_token}
35
+
36
+ `))}return{...this.tokenizer(e,n),...s,...a}}},Ki=class extends Pe{static image_processor_class=lt;static tokenizer_class=Se;static image_token="<|image_pad|>";async _call(e,t=null,...r){Array.isArray(e)||(e=[e]);let n,s;if(t&&(n=await this.image_processor(t),s=n.image_grid_thw),s){let o=this.image_processor.config.merge_size**2,i=0;const l=this.constructor.image_token,u=s.tolist();e=e.map(h=>{for(;h.includes(l);){const f=Number(u[i++].reduce((_,g)=>_*g,1n));h=h.replace(l,"<|placeholder|>".repeat(Math.floor(f/o)))}return h.replaceAll("<|placeholder|>",l)})}return{...this.tokenizer(e),...n}}},V2=class extends Ki{static image_token="<|image|>"},U2=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;static uses_processor_config=!0;_get_num_audio_features(e){const{hop_length:t}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:r,projector_downsample_rate:n}=this.feature_extractor.config,s=Math.floor(r/n),a=Math.floor(e/t)+1,o=Math.floor(a/2);return Math.ceil(o/r)*s}async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(t){const{input_features:a}=await this.feature_extractor(t);n.input_features=a;const o=this._get_num_audio_features(t.length),i=new Uint8Array(o).fill(1);n.input_features_mask=new W("bool",i,[1,o]);const l=this.config.audio_token??"<|audio|>";if(!e.includes(l))throw new Error(`The input text does not contain the audio token ${l}.`);e=e.replaceAll(l,l.repeat(o))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}};function W2(e,t){const n=e.dims.at(-1)-1,s=e.tolist();s.fill(!1,0,1),s.fill(!1,n);const a=t.tolist();return s.map((o,i)=>o?i:null).filter(o=>o!==null).map(o=>a[o])}var j2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;async _call(e,t,r={}){const n=e?await this.image_processor(e,r):{};return{...t?this.tokenizer(t,r):{},...n}}post_process_grounded_object_detection(e,t,{box_threshold:r=.25,text_threshold:n=.25,target_sizes:s=null}={}){const{logits:a,pred_boxes:o}=e,i=a.dims[0];if(s!==null&&s.length!==i)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");const l=a.dims.at(1),u=a.sigmoid(),h=u.max(-1).tolist(),f=o.tolist().map(g=>g.map(w=>om(w))),_=[];for(let g=0;g<i;++g){const w=s!==null?s[g]:null;w!==null&&(f[g]=f[g].map(C=>C.map((E,F)=>E*w[(F+1)%2])));const v=h[g],M=[],x=[],k=[];for(let C=0;C<l;++C){const E=v[C];if(E<=r)continue;const F=f[g][C],z=u[g][C];M.push(E),k.push(F);const b=W2(z.gt(n),t[g]);x.push(b)}_.push({scores:M,boxes:k,labels:this.batch_decode(x)})}return _}};function q2(e,t,r,n,s,a){let o="";for(let i=0;i<t;++i){for(let l=0;l<r;++l)o+=n+`<row_${i+1}_col_${l+1}>`+s.repeat(e);o+=`
37
+ `}return o+=`
38
+ ${n}${a}`+s.repeat(e)+`${n}`,o}function H2(e,t,r,n){return`${t}${n}`+r.repeat(e)+`${t}`}function Q2(e,t,r,n,s,a){return e===0&&t===0?H2(r,n,s,a):q2(r,e,t,n,s,a)}var Hf=class extends Pe{static image_processor_class=lt;static tokenizer_class=Se;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,r={}){r.return_row_col_info??=!0;let n;t&&(n=await this.image_processor(t,r)),Array.isArray(e)||(e=[e]);const s=n.rows??[new Array(e.length).fill(0)],a=n.cols??[new Array(e.length).fill(0)],o=this.config.image_seq_len,i=[],l=[];for(let h=0;h<e.length;++h){const f=e[h],_=s[h],g=a[h];i.push(J0(f,this.image_token));const w=_.map((x,k)=>Q2(x,g[k],o,this.fake_image_token,this.image_token,this.global_img_token)),v=f.split(this.image_token);if(v.length===0)throw new Error("The image token should be present in the text.");let M=v[0];for(let x=0;x<w.length;++x)M+=w[x]+v[x+1];l.push(M)}return{...this.tokenizer(l),...n}}},X2=class extends Pe{static image_processor_class=lt;static tokenizer_class=Se;static uses_processor_config=!0;constructor(e,t,r){super(e,t,r),this.image_tag=this.config.image_tag,this.image_start_tag=this.config.image_start_tag,this.image_end_tag=this.config.image_end_tag,this.num_image_tokens=this.config.num_image_tokens}async _call(e,{images:t=null,chat_template:r="default"}={}){t?Array.isArray(t)||(t=[t]):t=await Promise.all(e.filter(v=>v.images).flatMap(v=>v.images).map(v=>Kn.read(v)));const n=this.tokenizer,s=n.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:r}),a=v=>n.encode(v,{add_special_tokens:!1}),o=s.split(this.image_tag),i=o.length-1;if(t.length!==i)throw new Error(`Number of images provided (${t.length}) does not match number of "${this.image_tag}" image tags (${i})`);const[l,u,h]=n.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]);let f=a(o[0]),_=new Array(f.length).fill(!1);for(let v=1;v<o.length;++v){const M=new Array(this.num_image_tokens).fill(l),x=a(o[v]);f=qt(f,[u],M,[h],x);const k=new Array(this.num_image_tokens).fill(!0);_=qt(_,[!1],k,[!1],new Array(x.length).fill(!1))}const g=[1,f.length],w={input_ids:new W("int64",f,g),attention_mask:new W("int64",new Array(f.length).fill(1),g),images_seq_mask:new W("bool",_,g),images_emb_mask:new W("bool",new Array(i*this.num_image_tokens).fill(!0),[1,i,this.num_image_tokens])};if(t&&t.length>0){const v=await this.image_processor(t);return v.pixel_values.unsqueeze_(0),{...w,...v}}return w}},Y2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;async _call(e=null,t=null,r={}){if(!e&&!t)throw new Error("Either text or images must be provided");const n=e?this.tokenizer(e,r):{},s=t?await this.image_processor(t,r):{};return{...n,...s}}},J2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;async _call(e,t=null,r={}){const{image_rows:n,image_cols:s,image_sizes:a,...o}=await this.image_processor(e,{...r,return_row_col_info:!0});if(t){const i=this.config.image_token??"<image>",{tile_size:l=512,downsample_factor:u=2,encoder_patch_size:h=16,use_thumbnail:f=!0}=this.image_processor.config,_=k=>Math.ceil(Math.floor(k/h)/u),g=_(l)**2,w=this.config.image_start_token??"<|image_start|>",v=this.config.image_end_token??"<|image_end|>",M=this.config.image_thumbnail??"<|img_thumbnail|>";Array.isArray(t)||(t=[t]);let x=0;t=t.map(k=>{const C=k.split(i);return C[0]+C.slice(1).map(E=>{const F=x++,[z,b]=a[F],V=n[F],R=s[F],H=_(z)*_(b);let J=w;if(V>1||R>1){const X=i.repeat(g);for(let D=0;D<V;++D)for(let I=0;I<R;++I)J+=`<|img_row_${D+1}_col_${I+1}|>`+X;f&&(J+=M+i.repeat(H))}else J+=i.repeat(H);return J+v+E}).join("")})}return{...o,...t?this.tokenizer(t,r):{}}}},K2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;static uses_processor_config=!0;async _call(e,t=null,r={}){const n=await this.image_processor(e,r);if(t){const[a,o]=n.pixel_values.dims.slice(-2),{image_token:i,patch_size:l,num_additional_image_tokens:u}=this.config,h=Math.floor(a/l)*Math.floor(o/l)+u;t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let f=0;f<t.length;++f)t[f]=t[f].replace(i,i.repeat(h))}const s=t?this.tokenizer(t,r):{};return{...n,...s}}},Qf={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},Z2=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;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(!Qf.hasOwnProperty(t))throw new Error(`Format ${t} is not supported.`);const[r,n]=Qf[t],s=this[r].bind(this),[a,o]=e.dims,i=[],l=[],u=e.tolist();for(let f=0;f<a;++f){const _=u[f],g=[],w=[];for(let M=1;M<o;++M){const[x,k]=Ye(bn(_[M]));if(w.push(x),k==n)break;g.push(k)}const v=w.length>0?w.reduce((M,x)=>M*x,1):0;l.push(g),i.push(v)}return[s(l),i]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(t=>t.replaceAll(" ",""))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(t=>t.replaceAll(" ",""))}batch_decode([e,t,r]){const[n,s]=this._decode_helper(e,"char"),[a,o]=this._decode_helper(t,"bpe"),[i,l]=this._decode_helper(r,"wp"),u=[],h=[];for(let f=0;f<n.length;++f){const[_,g]=Ye([s[f],o[f],l[f]]);u.push([n[f],a[f],i[f]][g]),h.push(_)}return{generated_text:u,scores:h,char_preds:n,bpe_preds:a,wp_preds:i}}static async from_pretrained(...e){const t=await super.from_pretrained(...e),r=await Se.from_pretrained("Xenova/gpt2"),n=await Se.from_pretrained("Xenova/bert-base-uncased");return t.components={image_processor:t.image_processor,char_tokenizer:t.tokenizer,bpe_tokenizer:r,wp_tokenizer:n},t}async _call(e,t=null){const r=await this.image_processor(e);return t&&(r.labels=this.tokenizer(t).input_ids),r}},eC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e){return await this.feature_extractor(e)}},tC=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt},on="<image>";function rC(e,t,r,n,s){return`${n.repeat(r*s)}${t}${e}
39
+ `}var nC=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;static uses_processor_config=!1;async _call(e,t=null,r={}){t||(pe.warn("You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."),t=""),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);const n=this.tokenizer.bos_token,s=this.image_processor.config.image_seq_length;let a;t.some(l=>l.includes(on))?a=t.map(l=>{const u=l.replaceAll(on,on.repeat(s)),h=u.lastIndexOf(on),f=h===-1?0:h+on.length;return u.slice(0,f)+n+u.slice(f)+`
40
+ `}):(pe.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(l=>rC(l,n,s,on,e.length)));const o=this.tokenizer(a,r);return{...await this.image_processor(e,r),...o}}},Xf="<|image|>",sC=/<\|image_\d+\|>/g,aC=class extends Pe{static image_processor_class=lt;static tokenizer_class=Se;async _call(e,t=null,{padding:r=!0,truncation:n=!0,num_crops:s=null}={}){Array.isArray(e)||(e=[e]);let a,o;if(t){o=await this.image_processor(t,{num_crops:s});const{num_img_tokens:i}=o,l=e.map((h,f)=>h.split(sC).join(Xf.repeat(i[f])));a=this.tokenizer(l,{padding:r,truncation:n});const u=this.tokenizer._tokenizer.token_to_id(Xf);a.input_ids.map_(h=>h==u?-h:h)}else a=this.tokenizer(e);return{...a,...o}}},oC=class extends Pe{static tokenizer_class=Se;static image_processor_class=lt;static uses_processor_config=!0;async _call(e,t=null,r={}){const n=await this.image_processor(e,r);if(t){const[a,o]=n.pixel_values.dims.slice(-2),{image_token:i,image_break_token:l,image_end_token:u,patch_size:h,spatial_merge_size:f}=this.config,_=h*f,g=Math.floor(a/_),w=Math.floor(o/_);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let v=0;v<t.length;++v){const M=i.repeat(w),x=M+l,k=M+u,C=x.repeat(g-1)+k;t[v]=t[v].replace(i,C)}}const s=t?this.tokenizer(t,r):{};return{...n,...s}}},iC=class extends Pe{static feature_extractor_class=sm;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}},Cm=class extends Ki{},lC=class extends Cm{},Am=class extends Pe{static image_processor_class=lt;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)}},Sm=class extends Am{},cC=class extends Sm{},uC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e){return await this.feature_extractor(e)}},dC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;static uses_processor_config=!0;async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(t){const a=t.length,{input_features:o}=await this.feature_extractor(t,{...r,max_length:a}),i=Math.round(a/this.config.encoder_ds_factor+1e-4),l=1+Math.ceil(i/this.config.stack_factor);n.audio_token_len=[l],n.audio_values=o;const u=this.config.audio_placeholder;if(!e.includes(u))throw new Error(`The input text does not contain the image token ${u}.`);e=e.replaceAll(u,u.repeat(l))}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}},Os="[AUDIO]",hC="[BEGIN_AUDIO]",fC=375;function _C(e,t){const r=[];for(let n=0;n<e.length;n+=t)r.push(e.subarray(n,Math.min(n+t,e.length)));return r}var pC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;static uses_processor_config=!1;async _call(e,t=null,r={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");const n={};if(t){if(!e.includes(Os))throw new Error(`The input text does not contain the audio token ${Os}.`);Array.isArray(t)||(t=[t]);const a=e.split(Os),o=a.length-1;if(o!==t.length)throw new Error(`The number of audio inputs (${t.length}) does not match the number of audio tokens in the text (${o}).`);const i=this.feature_extractor.config.n_samples,l=t.map(g=>_C(g,i)),u=l.map(g=>g.length),h=l.flat(),f=(await Promise.all(h.map(g=>this.feature_extractor(g,r)))).map(g=>g.input_features);n.audio_values=f.length>1?De(f,0):f[0];let _=a[0];for(let g=0;g<u.length;++g){_+=hC;for(let w=0;w<u[g];++w)_+=Os.repeat(fC);_+=a[g+1]}e=_}return{...this.tokenizer(e,{add_special_tokens:!1,...r}),...n}}},Yf=32,Wo=6,Ns=8,mC=10,gC=32,wC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(Wo+1)*Ns}get num_samples_first_audio_chunk(){const{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(){const{hop_length:e,n_fft:t}=this.feature_extractor.config;return Ns*e+t}get num_right_pad_tokens(){return Wo+1+mC}get audio_length_per_tok(){return Ns}get raw_audio_length_per_tok(){return Ns*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:t=!1,is_first_audio_chunk:r=!0}={}){if(rt(e,"VoxtralRealtimeProcessor"),!t&&!r)throw new Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(r)if(t){const n=Yf*this.raw_audio_length_per_tok,s=new Float32Array(n+e.length);s.set(e,n);const a=await this.feature_extractor(s,{center:!0}),i=1+(Yf+Wo),l=new BigInt64Array(i).fill(BigInt(gC));return l[0]=1n,{input_ids:new W("int64",l,[1,i]),...a}}else{const n=this.num_right_pad_tokens*this.raw_audio_length_per_tok,s=new Float32Array(e.length+n);return s.set(e),await this.feature_extractor(s,{center:!0})}else return await this.feature_extractor(e,{center:!1})}},vC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e){return await this.feature_extractor(e)}},yC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e){return await this.feature_extractor(e)}},bC=class extends Pe{static tokenizer_class=Se;static feature_extractor_class=Et;async _call(e){return await this.feature_extractor(e)}};async function MC(e,t){return await ir(e,"config.json",!0,t)}function cn(e){const t={};let r={};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":r=cn(e.text_config);break;case"moondream1":r=cn(e.phi_config);break;case"musicgen":r=cn(e.decoder);break;case"multi_modality":r=cn(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"deepseek_v4":case"glm_moe_dsa":case"mistral4":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.dim_kv=e.model_type==="deepseek_v4"?"head_dim":"qk_head_dim",t.num_attention_heads="num_attention_heads";break;case"zaya":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size",t.dim_kv="head_dim",t.num_attention_heads="num_attention_heads";break;case"hrm_text":t.num_heads="num_key_value_heads",t.num_layers="num_hidden_layers",t.hidden_size="hidden_size",t.dim_kv="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";const{num_hidden_layers:s,num_attention_heads:a,hidden_size:o}=e.encoder_config;r={num_encoder_layers:s,num_encoder_heads:a,encoder_hidden_size:o,encoder_dim_kv:e.head_dim};break;case"vision-encoder-decoder":const i=cn(e.decoder),l="num_decoder_layers"in i,u=et(e,["model_type","is_encoder_decoder"]);return l?(u.num_decoder_layers=i.num_decoder_layers,u.num_decoder_heads=i.num_decoder_heads,u.decoder_hidden_size=i.decoder_hidden_size,u.num_encoder_layers=i.num_encoder_layers,u.num_encoder_heads=i.num_encoder_heads,u.encoder_hidden_size=i.encoder_hidden_size):(u.num_layers=i.num_layers,u.num_heads=i.num_heads,u.hidden_size=i.hidden_size),u}const n={...r,...et(e,["model_type","multi_query","is_encoder_decoder"])};for(const s in t)n[s]=e[t[s]];return n}function pa(e,t){e instanceof oi||(e=new oi(e));const r=t?.prefix??"past_key_values",n=r==="present"?"present":"past",s=new Set;if(["lfm2","lfm2_moe"].includes(e.model_type)){const{layer_types:a}=e;for(let o=0;o<a.length;++o)if(a[o]==="full_attention")s.add(`${r}.${o}.key`),s.add(`${r}.${o}.value`);else if(a[o]==="conv")s.add(`${n}_conv.${o}`);else throw new Error(`Unsupported layer type: ${a[o]}`);return s}else if(["granitemoehybrid","falcon_h1","nemotron_h"].includes(e.model_type)){const a=e,o=a.layer_types??a.layers_block_type,i=a.num_hidden_layers??o?.length;for(let l=0;l<i;++l)(!o||o[l]==="mamba")&&(s.add(`${n}_conv.${l}`),s.add(`${n}_ssm.${l}`)),(!o||o[l]==="attention")&&(s.add(`${r}.${l}.key`),s.add(`${r}.${l}.value`));return s}else if(["qwen3_next","qwen3_5_text","qwen3_5_moe_text","olmo_hybrid"].includes(e.model_type)){const{layer_types:a}=e;for(let o=0;o<a.length;++o)if(a[o]==="full_attention")s.add(`${r}.${o}.key`),s.add(`${r}.${o}.value`);else if(a[o]==="linear_attention")e.model_type==="olmo_hybrid"?(s.add(`${n}_conv.${o}.key`),s.add(`${n}_conv.${o}.value`),s.add(`${n}_conv.${o}.query`)):s.add(`${n}_conv.${o}`),s.add(`${n}_recurrent.${o}`);else throw new Error(`Unsupported layer type: ${a[o]}`);return s}else if(["gemma4","gemma4_text"].includes(e.model_type)){const a=e.model_type==="gemma4"?e.text_config:e,o=a.num_hidden_layers,i=a.num_kv_shared_layers??0,l=o-i;for(let u=0;u<l;++u)s.add(`${r}.${u}.key`),s.add(`${r}.${u}.value`);return s}else if(e.model_type==="deepseek_v4"){const{layer_types:a,num_hidden_layers:o}=e;for(let i=0;i<o;++i){s.add(`${r}.${i}.key`),s.add(`${r}.${i}.value`);const l=a[i];if(l==="compressed_sparse_attention")s.add(`${n}_compressor.${i}.kv`),s.add(`${n}_compressor.${i}.gate`),s.add(`${n}_indexer.${i}.kv`),s.add(`${n}_indexer.${i}.gate`);else if(l==="heavily_compressed_attention")s.add(`${n}_compressor.${i}.kv`),s.add(`${n}_compressor.${i}.gate`);else if(l&&l!=="sliding_attention")throw new Error(`Unsupported layer type: ${l}`)}return s}else if(e.model_type==="zaya"){const{num_hidden_layers:a,cca_time1:o}=e,i=o??1;for(let l=0;l<a;l+=i)s.add(`${r}.${l}.key`),s.add(`${r}.${l}.value`),s.add(`${r}.${l}.conv_state`),s.add(`${r}.${l}.shift_state`);return s}else if(["lfm2_vl","qwen3_5","qwen3_5_moe","voxtral_realtime"].includes(e.model_type)){let a;return e.model_type==="voxtral_realtime"&&t?.session_name==="audio_encoder"?a=e.audio_config:a=e.text_config,pa(a,t)}return xC(e,{prefix:r})}function xC(e,{prefix:t="past_key_values"}={}){const r=new Set,n=e.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n)for(let s=0;s<n.num_decoder_layers;++s)r.add(`${t}.${s}.encoder.key`),r.add(`${t}.${s}.encoder.value`),r.add(`${t}.${s}.decoder.key`),r.add(`${t}.${s}.decoder.value`);else if(n.multi_query)for(let s=0;s<n.num_layers;++s)r.add(`${t}.${s}.key_value`);else for(let s=0;s<n.num_layers;++s)r.add(`${t}.${s}.key`),r.add(`${t}.${s}.value`);return r}var oi=class ii{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(t){Object.assign(this,t),this.normalized_config=cn(this)}static async from_pretrained(t,{progress_callback:r=null,config:n=null,cache_dir:s=null,local_files_only:a=!1,revision:o="main"}={}){n&&!(n instanceof ii)&&(n=new ii(n));const i=n??await MC(t,{progress_callback:r,config:n,cache_dir:s,local_files_only:a,revision:o});return new this(i)}},oa=class{static async from_pretrained(...e){return oi.from_pretrained(...e)}};function Pm(e,t,r){return e?typeof e=="object"&&e!==null?e.hasOwnProperty(t)?+e[t]:e.hasOwnProperty(r)?+e[r]:0:+e:0}function Fm(e,t){const r=[];for(let n=0;n<t;++n)r.push(`${e}_data${n===0?"":"_"+n}`);return r}async function TC(e,t,r,n){const s=`${t}${n}.onnx`,a=`${r.subfolder??""}/${s}`;return await aa(e,a,!0,r,_e.IS_NODE_ENV)}async function kC(e,t,r,n,s,a={}){const o=`${t}${r}.onnx`,i=_e.IS_NODE_ENV;let l=[];const u=Pm(s,o,t);if(u>0){if(u>Sf)throw new Error(`The number of external data chunks (${u}) exceeds the maximum allowed value (${Sf}).`);const h=Fm(o,u);for(const f of h){const _=`${n.subfolder??""}/${f}`;l.push(new Promise(async(g,w)=>{const v=await aa(e,_,!0,n,i);g(v instanceof Uint8Array?{path:f,data:v}:f)}))}}else a.externalData!==void 0&&(l=a.externalData.map(async h=>{if(typeof h.data=="string"){const f=await aa(e,h.data,!0,n);return{...h,data:f}}return h}));return Promise.all(l)}async function EC(e,t,r,n=!1,s=void 0){let a=r.config?.["transformers.js_config"]??{};const o=Dp(r.device??a.device,t,{warn:k=>pe.info(k)}),i=ek(o),l=a.device_config??{};l.hasOwnProperty(o)&&(a={...a,...l[o]});const u=Bp(r.dtype??a.dtype,t,o,{configDtype:a.dtype,warn:k=>pe.info(k)});if(ni.hasOwnProperty(u)){if(o==="webgpu"&&!_e.IS_NODE_ENV&&u===qe.fp16&&!await nk())throw new Error(`The device (${o}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${u}. Should be one of: ${Object.keys(qe).join(", ")}`);const h=ni[u],f={...r.session_options};f.executionProviders??=i;const _=a.free_dimension_overrides;_?f.freeDimensionOverrides??=_:o.startsWith("webnn")&&!f.freeDimensionOverrides&&pe.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.`);const g=TC(e,t,r,h),w=r.use_external_data_format??a.use_external_data_format,v=await kC(e,t,h,r,w,f);if(v.length>0&&(!_e.IS_NODE_ENV||v.some(k=>typeof k!="string"))&&(f.externalData=v),n&&o==="webgpu"){const k=pa(r.config,{prefix:"present",session_name:s});if(k.size>0&&!Gi()){const C={};for(const E of k)C[E]="gpu-buffer";f.preferredOutputLocation=C}}return{buffer_or_path:await g,session_options:f,session_config:{dtype:u,device:o}}}async function CC(e,t,r,n=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async s=>{const a=n?.[s]??!1,{buffer_or_path:o,session_options:i,session_config:l}=await EC(e,t[s],r,a,s),u=await Lp(o,i,l);return[s,u]})))}function Im(e){for(let t in e)Np(e[t])?e[t]=new W(e[t]):typeof e[t]=="object"&&Im(e[t]);return e}async function ye(e,t){const r=AC(e,t);try{const n=Object.fromEntries(Object.entries(r).map(([a,o])=>{const i=o.ort_tensor;return _e.IS_NODE_ENV&&typeof Float16Array<"u"&&i.cpuData instanceof Float16Array&&(i.cpuData=new Uint16Array(i.cpuData.buffer)),[a,i]})),s=await Op(e,n);return Im(s)}catch(n){const s=Object.fromEntries(Object.entries(r).map(([a,o])=>{const i={type:o.type,dims:o.dims,location:o.location};return i.location!=="gpu-buffer"&&(i.data=o.data),[a,i]}));throw pe.error(`An error occurred during model execution: "${n}".`),pe.error("Inputs given to model:",s),n}}function AC(e,t){const r=Object.create(null),n=[];for(const o of e.inputNames){const i=t[o];if(!(i instanceof W)){n.push(o);continue}r[o]=Gi()?i.clone():i}if(n.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${n.join(", ")}.`);const s=Object.keys(t).length,a=e.inputNames.length;if(s>a){let o=Object.keys(t).filter(i=>!e.inputNames.includes(i));pe.warn(`WARNING: Too many inputs were provided (${s} > ${a}). The following inputs will be ignored: "${o.join(", ")}".`)}return r}var Ve=class{},SC=class extends Ve{constructor({last_hidden_state:e,hidden_states:t=null,attentions:r=null}){super(),this.last_hidden_state=e,this.hidden_states=t,this.attentions=r}},ie=class extends Ve{constructor({logits:e,...t}){super(),this.logits=e;const r=Object.values(t);r.length>0&&(this.attentions=r)}},je=class extends Ve{constructor({logits:e}){super(),this.logits=e}},He=class extends Ve{constructor({logits:e}){super(),this.logits=e}},nt=class extends Ve{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},kr=class extends Ve{constructor({logits:e}){super(),this.logits=e}},PC=class extends Ve{constructor({logits:e,past_key_values:t}){super(),this.logits=e,this.past_key_values=t}},FC=class extends Ve{constructor({logits:e,past_key_values:t,encoder_outputs:r,decoder_attentions:n=null,cross_attentions:s=null}){super(),this.logits=e,this.past_key_values=t,this.encoder_outputs=r,this.decoder_attentions=n,this.cross_attentions=s}},Lm=class extends Ve{constructor({alphas:e}){super(),this.alphas=e}},Bt=class extends wt{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},IC=class extends wt{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},li=class extends wt{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let r=t;for(const n of this.processors)r=n(e,r);return r}[Symbol.iterator](){return this.processors.values()}},LC=class extends Bt{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===1){const n=t[r].data;n.fill(-1/0),n[this.bos_token_id]=0}return t}},OC=class extends Bt{constructor(e,t){super(),this.max_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.max_length-1){const n=t[r].data;n.fill(-1/0);for(const s of this.eos_token_id)n[s]=0}return t}},NC=class extends Bt{constructor(e){super(),this.suppress_tokens=e}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data;for(const s of this.suppress_tokens)n[s]=-1/0}return t}},Om=class extends Bt{constructor(e,t){super(),this.begin_suppress_tokens=e,this.begin_index=t}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length===this.begin_index){const n=t[r].data;for(const s of this.begin_suppress_tokens)n[s]=-1/0}return t}},DC=class extends Bt{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-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data;if(n[this.no_timestamps_token_id]=-1/0,e[r].length===this.begin_index){n.subarray(0,this.timestamp_begin).fill(-1/0);continue}const s=e[r].slice(this.begin_index),a=s.length>=1&&s[s.length-1]>=this.timestamp_begin,o=s.length<2||s[s.length-2]>=this.timestamp_begin;if(a&&(o?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[r].length===this.begin_index&&this.max_initial_timestamp_index!==null){const h=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(h+1).fill(-1/0)}const i=GT(n),l=Math.log(i.subarray(this.timestamp_begin).map(Math.exp).reduce((h,f)=>h+f)),u=Ye(i.subarray(0,this.timestamp_begin))[0];l>u&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},BC=class extends Bt{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){const t=e.length,r=[];for(let s=0;s<t+1-this.no_repeat_ngram_size;++s){const a=[];for(let o=0;o<this.no_repeat_ngram_size;++o)a.push(e[s+o]);r.push(a.map(Number))}const n=new Map;for(const s of r){const a=s.slice(0,s.length-1),o=JSON.stringify(a),i=n.get(o)??[];i.push(s[s.length-1]),n.set(o,i)}return n}getGeneratedNgrams(e,t){const r=t.slice(t.length+1-this.no_repeat_ngram_size,t.length);return e.get(JSON.stringify(r.map(Number)))??[]}calcBannedNgramTokens(e){const t=[];if(e.length+1<this.no_repeat_ngram_size)return t;{const r=this.getNgrams(e);return this.getGeneratedNgrams(r,e)}}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data,s=this.calcBannedNgramTokens(e[r]);for(const a of s)n[a]=-1/0}return t}},zC=class extends Bt{constructor(e){super(),this.penalty=e}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data;for(const s of new Set(e[r])){const a=Number(s);n[a]<0?n[a]*=this.penalty:n[a]/=this.penalty}}return t}},RC=class extends Bt{constructor(e,t){super(),this.min_length=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length<this.min_length){const n=t[r].data;for(const s of this.eos_token_id)n[s]=-1/0}return t}},$C=class extends Bt{constructor(e,t,r){super(),this.prompt_length_to_skip=e,this.min_new_tokens=t,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,t){for(let r=0;r<e.length;++r)if(e[r].length-this.prompt_length_to_skip<this.min_new_tokens){const s=t[r].data;for(const a of this.eos_token_id)s[a]=-1/0}return t}},GC=class extends Bt{constructor(e,t){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(t)?t:[t]}_call(e,t){for(let r=0;r<e.length;++r){const n=t[r].data,s=e[r];for(const a of this.bad_words_ids){if(s.length<a.length-1)continue;let o=!0;for(let i=1;i<=a.length-1;++i)if(a.at(-i-1)!=s.at(-i)){o=!1;break}o&&(n[a.at(-1)]=-1/0)}}return t}},VC=class extends Bt{constructor(e){if(super(),e<=1)throw new Error(`Require guidance scale >1 to use the classifier-free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw new Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${t.dims[0]} for the logits and ${e.length} for the input ids.`);const r=e.length,n=t.slice([0,r],null),s=t.slice([r,t.dims[0]],null);for(let a=0;a<s.data.length;++a)s.data[a]+=(n.data[a]-s.data[a])*this.guidance_scale;return s}},UC=class extends IC{constructor(e){super(),this.temperature=e}_call(e,t){const r=t.data;for(let n=0;n<r.length;++n)r[n]/=this.temperature;return t}},Nm=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,et(e,Object.getOwnPropertyNames(this)))}},ma=class extends wt{_call(e,t){throw Error("StoppingCriteria needs to be subclassed")}},Dm=class Bm extends wt{constructor(){super(),this.criteria=[]}push(t){this.criteria.push(t)}extend(t){t instanceof Bm?t=t.criteria:t instanceof ma&&(t=[t]),this.criteria.push(...t)}_call(t,r){const n=new Array(t.length).fill(!1);for(const s of this.criteria){const a=s(t,r);for(let o=0;o<n.length;++o)n[o]||=a[o]}return n}[Symbol.iterator](){return this.criteria.values()}},WC=class extends ma{constructor(e,t=null){super(),this.max_length=e,this.max_position_embeddings=t}_call(e){return e.map(t=>t.length>=this.max_length)}},jC=class extends ma{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(r=>{const n=r.at(-1);return this.eos_token_id.some(s=>n==s)})}},ga=class extends wt{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 r=e.dims.at(-1),n=e.data;if(t===-1)n=n.slice(-r);else{let s=t*r;n=n.slice(s,s+r)}return n}randomSelect(e){return TT(e)}static getSampler(e){if(e.do_sample)return new HC(e);if(e.num_beams>1)return new QC(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 qC(e)}},qC=class extends ga{async sample(e){const t=Ye(e.data)[1];return[[BigInt(t),0]]}},HC=class extends ga{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));const[r,n]=await Rp(e,t),s=bn(r.data);return Array.from({length:this.generation_config.num_beams},()=>{const a=this.randomSelect(s);return[n.data[a],Math.log(s[a])]})}},QC=class extends ga{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));const[r,n]=await Rp(e,t),s=bn(r.data);return Array.from({length:this.generation_config.num_beams},(a,o)=>[n.data[o],Math.log(s[o])])}},XC=class{constructor(e){if(e)for(const t in e){if(t in this)throw new TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);const r=e[t];if(!(r instanceof W))throw new TypeError(`Expected a Tensor for key "${t}", got ${typeof r}`);this[t]=r}}get_seq_length(){const e=this;if(Object.keys(e).length===0)return 0;for(const t in e)if(t.startsWith("past_key_values."))return e[t].dims.at(-2);throw new Error("Unable to determine sequence length from the cache.")}update(e){for(const t in e){const r=this[t],n=e[t];r&&r!==n&&r.location==="gpu-buffer"&&r.dispose(),this[t]=n}}async dispose(){const e=[];for(const t of Object.values(this))t.location==="gpu-buffer"&&e.push(t.dispose());await Promise.all(e)}},Zi=XC,j={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},yr={[j.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??"model"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[j.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??"model"})},[j.Seq2Seq]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[j.Vision2Seq]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[j.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"}},[j.EncoderDecoder]:{sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0}},[j.MaskGeneration]:{sessions:()=>({model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"})},[j.ImageTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{const n={...yr[j.ImageTextToText].text_only_sessions};return r||(n.vision_encoder="vision_encoder"),e.is_encoder_decoder&&(n.model="encoder_model"),n},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[j.AudioTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{const n={...yr[j.AudioTextToText].text_only_sessions};return r||(n.audio_encoder="audio_encoder"),n},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[j.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{const n={...yr[j.ImageAudioTextToText].text_only_sessions};return r||(n.audio_encoder="audio_encoder",n.vision_encoder="vision_encoder"),n},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[j.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"}},[j.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"}},[j.AutoEncoder]:{sessions:()=>({encoder_model:"encoder_model",decoder_model:"decoder_model"})},[j.Supertonic]:{sessions:()=>({text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"})},[j.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"}},[j.VoxtralRealtime]:{text_only_sessions:{embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"},sessions:(e,t,r)=>{const n={...yr[j.VoxtralRealtime].text_only_sessions};return r||(n.audio_encoder="audio_encoder"),n},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 YC(e,t,r={}){const n=yr[e]??yr.default;return{sessions:n.sessions(t,r,r.textOnly??!1),cache_sessions:n.cache_sessions,optional_configs:n.optional_configs}}function JC(e,{warn:t=!0}={}){const r=e.architectures||[];for(const n of r){const s=nr.get(n);if(s!==void 0)return s}if(e.model_type){const n=nr.get(e.model_type);if(n!==void 0)return n;for(const s of Object.values(dn))if(s.has(e.model_type)){const a=nr.get(s.get(e.model_type));if(a!==void 0)return a}}if(t){const n=r.length>0?r.join(", "):"(none)";pe.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${n}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${fa}`)}return j.EncoderOnly}function KC(e,{config:t=null,cache_dir:r=null,local_files_only:n=!1,revision:s="main"}={}){if(t!==null)return oa.from_pretrained(e,{config:t,cache_dir:r,local_files_only:n,revision:s});const a=Bi(e,{cache_dir:r,local_files_only:n,revision:s});return kp(a,()=>oa.from_pretrained(e,{config:t,cache_dir:r,local_files_only:n,revision:s}))}async function ZC(e,{config:t=null,dtype:r=null,device:n=null,model_file_name:s=null}={}){t=await KC(e,{config:t});const a=["config.json"],o=t["transformers.js_config"]??{},i=o.use_external_data_format,l="onnx",u=n??o.device;let h=r??o.dtype;const f=JC(t),_=(v,M=null)=>{M=M??v;const x=Dp(u,v),k=Bp(h,v,x),C=ni[k]??"",E=`${M}${C}.onnx`,F=`${l}/${E}`;a.push(F);const z=Pm(i,E,v);for(const b of Fm(E,z)){const V=`${l}/${b}`;a.push(V)}},{sessions:g,optional_configs:w}=YC(f,t,{model_file_name:s});for(const[v,M]of Object.entries(g))_(v,M);if(w)for(const v of Object.values(w))a.push(v);return a}var dn=null;function eA(e){dn=e}function ci(e){if(e instanceof W)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 W("int64",BigInt64Array.from(e.flat().map(t=>BigInt(t))),[e.length,e[0].length])}else return new W("int64",BigInt64Array.from(e.map(t=>BigInt(t))),[1,e.length])}function zm(e){return new W("bool",[e],[1])}var Jf={[j.DecoderOnly]:{can_generate:!0,forward:ar,prepare_inputs:gn},[j.DecoderOnlyWithoutHead]:{can_generate:!1,forward:ar,prepare_inputs:gn},[j.Seq2Seq]:{can_generate:!0,forward:Ds,prepare_inputs:ia},[j.Vision2Seq]:{can_generate:!0,forward:Ds,prepare_inputs:ia},[j.Musicgen]:{can_generate:!0,forward:Ds},[j.EncoderDecoder]:{can_generate:!1,forward:Ds},[j.ImageTextToText]:{can_generate:!0,forward:sA,prepare_inputs:Bs},[j.AudioTextToText]:{can_generate:!0,forward:nA,prepare_inputs:Bs},[j.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Bs},[j.Phi3V]:{can_generate:!0,prepare_inputs:Bs},[j.MultiModality]:{can_generate:!0},[j.AutoEncoder]:{can_generate:!1,forward:tA},[j.Chatterbox]:{can_generate:!0,forward:Tr},[j.VoxtralRealtime]:{can_generate:!0,prepare_inputs:gn},default:{can_generate:!1,forward:Tr}};function Kf(e,t){let r=nr.get(e),n=!1;const s=t?.architectures?.[0];if(s&&s!==e&&e?.endsWith("ForCausalLM")&&s.endsWith("ForConditionalGeneration")){const i=nr.get(s);i!==void 0&&(r=i,n=!0)}const a=Jf[r]??Jf.default,o=yr[r]??yr.default;return{typeConfig:{...a,...o},textOnly:n,modelType:r}}var nr=new Map,el=new Map,mn=new Map,P=class extends wt{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,t,r){super(),this.config=e,this.sessions=t,this.configs=r;const n=mn.get(this.constructor),{typeConfig:s}=Kf(n,e);this.can_generate=s.can_generate,this._forward=s.forward,this._prepare_inputs_for_generation=s.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){const e=[];for(const 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:r=null,cache_dir:n=null,local_files_only:s=!1,revision:a="main",model_file_name:o=null,subfolder:i="onnx",device:l=null,dtype:u=null,use_external_data_format:h=null,session_options:f={}}={}){const _={progress_callback:t,config:r,cache_dir:n,local_files_only:s,revision:a,model_file_name:o,subfolder:i,device:l,dtype:u,use_external_data_format:h,session_options:f},g=mn.get(this);r=_.config=await oa.from_pretrained(e,_);const{typeConfig:w,textOnly:v,modelType:M}=Kf(g,r);if(M===void 0){const E=g??r?.model_type;E!=="custom"&&pe.warn(`Model type for '${E}' not found, assuming encoder-only architecture. Please report this at ${fa}.`)}if(t&&!(t instanceof Yo)){const E={};try{const F=await ZC(e,{config:r,dtype:u,device:l,model_file_name:o});(await Promise.all(F.map(b=>Ri(e,b,_)))).forEach((b,V)=>{if(b.exists){const R=F[V]==="config.json";E[F[V]]={loaded:R?b.size??0:0,total:b.size??0}}})}catch(F){pe.warn(`Unable to fetch model file metadata for total progress tracking: ${F}`)}Object.keys(E).length>0&&(_.progress_callback=new Yo(t,E))}const x=w.sessions(r,_,v),k=[CC(e,x,_,w.cache_sessions)];w.optional_configs&&k.push(oA(e,w.optional_configs,_));const C=await Promise.all(k);return new this(r,...C)}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,r=null){const n=new li;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new zC(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new BC(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new GC(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new RC(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&n.push(new $C(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new LC(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new OC(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&n.push(new NC(e.suppress_tokens)),e.begin_suppress_tokens!==null){const s=t>1||e.forced_bos_token_id===null?t:t+1;n.push(new Om(e.begin_suppress_tokens,s))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new VC(e.guidance_scale)),e.temperature===0&&e.do_sample&&(pe.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&n.push(new UC(e.temperature)),r!==null&&n.extend(r),n}_prepare_generation_config(e,t,r=Nm){const n={...this.config};for(const a of["decoder","generator","text_config"])a in n&&Object.assign(n,n[a]);const s=new r(n);return Object.assign(s,this.generation_config??{}),e&&Object.assign(s,e),t&&Object.assign(s,et(t,Object.getOwnPropertyNames(s))),s}_get_stopping_criteria(e,t=null){const r=new Dm;return e.max_length!==null&&r.push(new WC(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&r.push(new jC(e.eos_token_id)),t&&r.extend(t),r}_validate_model_class(){if(!this.can_generate){const e=[dn.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,dn.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,dn.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,dn.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=mn.get(this.constructor),r=new Set,n=this.config.model_type;for(const a of e){const o=a?.get(n);o&&r.add(o)}let s=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw r.size>0&&(s+=` Please use the following class instead: ${[...r].join(", ")}`),Error(s)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:t,model_inputs:r,is_encoder_decoder:n}){return r.past_key_values=ui(t,r.past_key_values),r.input_ids=new W("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in r&&(r.decoder_attention_mask=De([r.decoder_attention_mask,dt([r.decoder_attention_mask.dims[0],1])],1)):r.attention_mask=De([r.attention_mask,dt([r.attention_mask.dims[0],1])],1),r.position_ids=null,r}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:r}){const n=et(r,this.forward_params),s=this.main_input_name;if(s in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[s]=e;return{inputs_tensor:n[s],model_inputs:n,model_input_name:s}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:r,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!t.inputs_embeds&&"_prepare_inputs_embeds"in this){const{input_ids:a,pixel_values:o,attention_mask:i,...l}=t,u=await this._prepare_inputs_embeds(t);t={...l,...et(u,["inputs_embeds","attention_mask"])}}let{last_hidden_state:s}=await Tr(this,t);if(n.guidance_scale!==null&&n.guidance_scale>1)s=De([s,si(s,0)],0),"attention_mask"in t&&(t.attention_mask=De([t.attention_mask,ji(t.attention_mask)],0));else if(t.decoder_input_ids){const a=ci(t.decoder_input_ids).dims[0];if(a!==s.dims[0]){if(s.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${s.dims[0]}) than the decoder inputs (${a}).`);s=De(Array.from({length:a},()=>s),0)}}return t.encoder_outputs=s,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:r,decoder_start_token_id:n,bos_token_id:s,generation_config:a}){let{decoder_input_ids:o,...i}=r;if(!(o instanceof W)){if(o)Array.isArray(o[0])||(o=Array.from({length:e},()=>o));else if(n??=s,this.config.model_type==="musicgen")o=Array.from({length:e*this.config.decoder.num_codebooks},()=>[n]);else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expected to have length ${e} but got ${n.length}`);o=n}else o=Array.from({length:e},()=>[n]);o=ci(o)}return i.decoder_attention_mask=Wi(o),{input_ids:o,model_inputs:i}}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:n=null,streamer:s=null,...a}){this._validate_model_class(),t=this._prepare_generation_config(t,a);let{inputs_tensor:o,model_inputs:i,model_input_name:l}=this._prepare_model_inputs({inputs:e,model_kwargs:a});const u=this.config.is_encoder_decoder;u&&("encoder_outputs"in i||(i=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:o,model_inputs:i,model_input_name:l,generation_config:t})));let h;u?{input_ids:h,model_inputs:i}=this._prepare_decoder_input_ids_for_generation({batch_size:i[l].dims.at(0),model_input_name:l,model_kwargs:i,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):h=i[l];let f=h.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=f+t.max_new_tokens);const _=this._get_logits_processor(t,f,r),g=this._get_stopping_criteria(t,n),w=i[l].dims.at(0),v=ga.getSampler(t),M=new Array(w).fill(0),x=h.tolist();s&&s.put(x);let k,C={},E={};for(;;){if(i=this.prepare_inputs_for_generation(x,i,t),k=await this.forward(i),t.return_dict_in_generate)if(t.output_attentions){const D=rA(k);for(const I in D)I in C||(C[I]=[]),C[I].push(D[I])}else this._return_dict_in_generate_keys&&Object.assign(E,et(k,this._return_dict_in_generate_keys));const R=k.logits.slice(null,-1,null).to("float32"),H=_(x,R),J=[];for(let D=0;D<H.dims.at(0);++D){const I=H[D],G=await v(I);for(const[Q,ce]of G){const Z=BigInt(Q);M[D]+=ce,x[D].push(Z),J.push([Z]);break}}if(s&&s.put(J),g(x).every(D=>D))break;i=this._update_model_kwargs_for_generation({generated_input_ids:J,outputs:k,model_inputs:i,is_encoder_decoder:u})}s&&s.end();const F=new W("int64",x.flat(),[x.length,x[0].length]),z=ui(k,i.past_key_values),b=new Set(Object.values(z));for(const R of Object.values(k))R.location==="gpu-buffer"&&!b.has(R)&&R.dispose();return"past_key_values"in a||t.return_dict_in_generate||await z.dispose(),t.return_dict_in_generate?{sequences:F,past_key_values:z,...C,...E}:F}async _encode_input(e,t,r){if(!Object.hasOwn(this.sessions,e))throw new Error(`Model does not have a ${e} session.`);const n=this.sessions[e];return(await ye(n,et(t,n.inputNames)))[r]}async encode_image(e){return this._encode_input("vision_encoder",e,"image_features")}async encode_text(e){return this._encode_input("embed_tokens",e,"inputs_embeds")}async encode_audio(e){return this._encode_input("audio_encoder",e,"audio_features")}};async function Ds(e,t){let{encoder_outputs:r,input_ids:n,decoder_input_ids:s,decoder_attention_mask:a,...o}=t;if(!r){const i=et(t,e.sessions.model.inputNames);r=(await Tr(e,i)).last_hidden_state}return o.input_ids=s,o.encoder_hidden_states=r,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 ar(e,o,!0)}async function Tr(e,t){const r=e.sessions.model,n=et(t,r.inputNames);if(r.inputNames.includes("inputs_embeds")&&!n.inputs_embeds){if(!t.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");n.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(r.inputNames.includes("token_type_ids")&&!n.token_type_ids){if(!n.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");n.token_type_ids=ji(n.input_ids)}if(r.inputNames.includes("pixel_mask")&&!n.pixel_mask){if(!n.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");const s=n.pixel_values.dims;n.pixel_mask=dt([s[0],s[2],s[3]])}return await ye(r,n)}async function tA(e,t){const r=await e.encode(t);return await e.decode(r)}function ui(e,t){const r=Object.create(null);for(const n in e)if(n.startsWith("present")){const s=n.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present_recurrent","past_recurrent").replace("present_compressor","past_compressor").replace("present_indexer","past_indexer").replace("present","past_key_values");n.includes("encoder")&&t?r[s]=t[s]:r[s]=e[n]}return t?(t.update(r),t):new Zi(r)}function rA(e){const t={};for(const r of["cross_attentions","encoder_attentions","decoder_attentions"])for(const n in e)n.startsWith(r)&&(r in t||(t[r]=[]),t[r].push(e[n]));return t}function Rm(e,t){return e.map(r=>typeof r=="number"?r:t[r]??0)}function tl(e,t,r){if(r&&Object.keys(r).length>0)return Object.assign(t,r),r;const n=e.sessions.decoder_model_merged??e.sessions.model,s=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,a=pa(e.config),o=e.config?.normalized_config?.num_heads,i={batch_size:s};typeof o=="number"&&(i["batch_size x num_heads"]=s*o);const l=Object.create(null);for(const u of n.inputMetadata){if(!a.has(u.name))continue;const h=Rm(u.shape,i),f=h.reduce((w,v)=>w*v,1),_=Jn[u.type],g=new W(u.type,new _(f),h);t[u.name]=g,l[u.name]=g}return r?(r.update(l),r):new Zi(l)}function ns(e,t,r){if(t.num_logits_to_keep)return;(e.sessions.decoder_model_merged??e.sessions.model)?.inputNames.includes("num_logits_to_keep")&&(t.num_logits_to_keep=new W("int64",[r],[]))}async function ar(e,t,r=!1){const n=e.sessions[r?"decoder_model_merged":"model"],{past_key_values:s,...a}=t;if(n.inputNames.includes("use_cache_branch")&&(a.use_cache_branch=zm(s!=null&&Object.keys(s).length>0)),n.inputNames.includes("position_ids")&&a.attention_mask&&!a.position_ids){const i=["paligemma","gemma3_text","gemma3"].includes(e.config.model_type)?1:0;a.position_ids=aA(a,s,i)}ns(e,a,0n),tl(e,a,s);const o=et(a,n.inputNames);return await ye(n,o)}async function $m(e,{encode_function:t,merge_function:r,modality_input_names:n,modality_output_name:s,input_ids:a=null,attention_mask:o=null,position_ids:i=null,inputs_embeds:l=null,past_key_values:u=null,generation_config:h=null,logits_processor:f=null,num_logits_to_keep:_=null,...g}){if(!l){l=await e.encode_text({input_ids:a,...g});const v=et(g,n);if(Object.keys(v).length>0){if(a.dims[1]!==1){const M=await t({...v,...g});({inputs_embeds:l,attention_mask:o}=r({[s]:M,inputs_embeds:l,input_ids:a,attention_mask:o}))}else if(u&&a.dims[1]===1){const M=a.dims[1],x=u.get_seq_length();o=De([dt([a.dims[0],x]),o.slice(null,[o.dims[1]-M,o.dims[1]])],1)}}}if(!i&&["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)){const{image_grid_thw:v,video_grid_thw:M}=g;[i]=e.get_rope_index(a,v,M,o)}return await ar(e,{inputs_embeds:l,past_key_values:u,attention_mask:o,position_ids:i,generation_config:h,logits_processor:f,num_logits_to_keep:_},!0)}async function nA(e,t){return await $m(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 sA(e,t){return await $m(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 Gm(e,t=0){const[r,n]=e.dims,s=e.data,a=new BigInt64Array(s.length);for(let o=0;o<r;++o){const i=o*n;let l=BigInt(t);for(let u=0;u<n;++u){const h=i+u;s[h]===0n?a[h]=BigInt(1):(a[h]=l,l+=s[h])}}return{data:a,dims:e.dims}}function aA(e,t=null,r=0){const{input_ids:n,inputs_embeds:s,attention_mask:a}=e,{data:o,dims:i}=Gm(a,r);let l=new W("int64",o,i);if(t){const u=-(n??s).dims.at(1);l=l.slice(null,[u,null])}return l}function gn(e,t,r,n){const s=r.past_key_values?r.past_key_values.get_seq_length():0;if(ns(e,r,1n),!r.attention_mask){let a;for(const o of["input_ids","inputs_embeds","position_ids"])if(r[o]){a=r[o].dims;break}if(!a)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");r.attention_mask=dt([a[0],s+a[1]])}if(r.past_key_values){const{input_ids:a,attention_mask:o}=r;o&&o.dims[1]>a.dims[1]||s<a.dims[1]&&(r.input_ids=a.slice(null,[s,null]))}return r}function ia(e,t,r,n){return r.past_key_values&&(t=t.map(s=>[s.at(-1)])),ns(e,r,1n),{...r,decoder_input_ids:ci(t)}}function Bs(e,...t){return e.config.is_encoder_decoder?ia(e,...t):gn(e,...t)}function Vm({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:n,attention_mask:s}){const a=n.tolist().map(u=>u.reduce((h,f,_)=>(f==e&&h.push(_),h),[])),o=a.reduce((u,h)=>u+h.length,0),i=r.dims[0];if(o!==i)throw new Error(`Number of tokens and features do not match: tokens: ${o}, features ${i}`);let l=0;for(let u=0;u<a.length;++u){const h=a[u],f=t[u];for(let _=0;_<h.length;++_)f[h[_]].data.set(r[l++].data)}return{inputs_embeds:t,attention_mask:s}}function rl({image_token_id:e,inputs_embeds:t,image_features:r,input_ids:n,attention_mask:s}){return Vm({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:n,attention_mask:s})}function Um({audio_token_id:e,inputs_embeds:t,audio_features:r,input_ids:n,attention_mask:s}){return Vm({modality_token_id:e,inputs_embeds:t,modality_features:r,input_ids:n,attention_mask:s})}async function oA(e,t,r){return Object.fromEntries(await Promise.all(Object.keys(t).map(async n=>{const s=await ir(e,t[n],!1,r);return[n,s]})))}var nl={};es(nl,{ASTForAudioClassification:()=>wA,ASTModel:()=>gA,ASTPreTrainedModel:()=>il,AfmoeForCausalLM:()=>_A,AfmoeModel:()=>fA,AfmoePreTrainedModel:()=>al,AlbertForMaskedLM:()=>uA,AlbertForQuestionAnswering:()=>cA,AlbertForSequenceClassification:()=>lA,AlbertModel:()=>iA,AlbertPreTrainedModel:()=>ss,ApertusForCausalLM:()=>hA,ApertusModel:()=>dA,ApertusPreTrainedModel:()=>sl,ArceeForCausalLM:()=>mA,ArceeModel:()=>pA,ArceePreTrainedModel:()=>ol,BartForConditionalGeneration:()=>yA,BartForSequenceClassification:()=>bA,BartModel:()=>vA,BartPretrainedModel:()=>wa,BaseModelOutput:()=>SC,BeitForImageClassification:()=>xA,BeitModel:()=>MA,BeitPreTrainedModel:()=>ll,BertForMaskedLM:()=>kA,BertForQuestionAnswering:()=>AA,BertForSequenceClassification:()=>EA,BertForTokenClassification:()=>CA,BertModel:()=>TA,BertPreTrainedModel:()=>Mn,BlenderbotForConditionalGeneration:()=>PA,BlenderbotModel:()=>SA,BlenderbotPreTrainedModel:()=>cl,BlenderbotSmallForConditionalGeneration:()=>IA,BlenderbotSmallModel:()=>FA,BlenderbotSmallPreTrainedModel:()=>ul,BloomForCausalLM:()=>OA,BloomModel:()=>LA,BloomPreTrainedModel:()=>dl,CHMv2ForDepthEstimation:()=>VA,CHMv2PreTrainedModel:()=>Hm,CLIPModel:()=>WA,CLIPPreTrainedModel:()=>Hr,CLIPSegForImageSegmentation:()=>XA,CLIPSegModel:()=>QA,CLIPSegPreTrainedModel:()=>hl,CLIPTextModel:()=>jA,CLIPTextModelWithProjection:()=>Ym,CLIPVisionModel:()=>qA,CLIPVisionModelWithProjection:()=>HA,CamembertForMaskedLM:()=>DA,CamembertForQuestionAnswering:()=>RA,CamembertForSequenceClassification:()=>BA,CamembertForTokenClassification:()=>zA,CamembertModel:()=>NA,CamembertPreTrainedModel:()=>xn,CausalLMOutput:()=>kr,CausalLMOutputWithPast:()=>PC,ChatterboxModel:()=>jm,ChatterboxPreTrainedModel:()=>Wm,ChineseCLIPModel:()=>GA,ChineseCLIPPreTrainedModel:()=>qm,ClapAudioModelWithProjection:()=>Xm,ClapModel:()=>UA,ClapPreTrainedModel:()=>va,ClapTextModelWithProjection:()=>Qm,CodeGenForCausalLM:()=>JA,CodeGenModel:()=>YA,CodeGenPreTrainedModel:()=>fl,Cohere2ForCausalLM:()=>tS,Cohere2Model:()=>eS,Cohere2PreTrainedModel:()=>pl,CohereAsrForConditionalGeneration:()=>nS,CohereAsrModel:()=>rS,CohereAsrPreTrainedModel:()=>ml,CohereForCausalLM:()=>ZA,CohereModel:()=>KA,CoherePreTrainedModel:()=>_l,ConvBertForMaskedLM:()=>aS,ConvBertForQuestionAnswering:()=>lS,ConvBertForSequenceClassification:()=>oS,ConvBertForTokenClassification:()=>iS,ConvBertModel:()=>sS,ConvBertPreTrainedModel:()=>Tn,ConvNextForImageClassification:()=>uS,ConvNextModel:()=>cS,ConvNextPreTrainedModel:()=>gl,ConvNextV2ForImageClassification:()=>hS,ConvNextV2Model:()=>dS,ConvNextV2PreTrainedModel:()=>wl,DFineForObjectDetection:()=>mS,DFineModel:()=>pS,DFinePreTrainedModel:()=>yl,DINOv3ConvNextModel:()=>WS,DINOv3ConvNextPreTrainedModel:()=>ag,DINOv3ViTModel:()=>jS,DINOv3ViTPreTrainedModel:()=>og,DPTForDepthEstimation:()=>ZS,DPTModel:()=>KS,DPTPreTrainedModel:()=>Cl,DacDecoderModel:()=>eg,DacDecoderOutput:()=>Km,DacEncoderModel:()=>Zm,DacEncoderOutput:()=>Jm,DacModel:()=>gS,DacPreTrainedModel:()=>ya,DebertaForMaskedLM:()=>vS,DebertaForQuestionAnswering:()=>MS,DebertaForSequenceClassification:()=>yS,DebertaForTokenClassification:()=>bS,DebertaModel:()=>wS,DebertaPreTrainedModel:()=>kn,DebertaV2ForMaskedLM:()=>AS,DebertaV2ForQuestionAnswering:()=>FS,DebertaV2ForSequenceClassification:()=>SS,DebertaV2ForTokenClassification:()=>PS,DebertaV2Model:()=>CS,DebertaV2PreTrainedModel:()=>En,DecisionTransformerModel:()=>IS,DecisionTransformerPreTrainedModel:()=>tg,DeepseekV3ForCausalLM:()=>TS,DeepseekV3Model:()=>xS,DeepseekV3PreTrainedModel:()=>bl,DeepseekV4ForCausalLM:()=>ES,DeepseekV4Model:()=>kS,DeepseekV4PreTrainedModel:()=>Ml,DeiTForImageClassification:()=>OS,DeiTModel:()=>LS,DeiTPreTrainedModel:()=>xl,DepthAnythingForDepthEstimation:()=>NS,DepthAnythingPreTrainedModel:()=>rg,DepthProForDepthEstimation:()=>DS,DepthProPreTrainedModel:()=>ng,DetrForObjectDetection:()=>zS,DetrForSegmentation:()=>RS,DetrModel:()=>BS,DetrObjectDetectionOutput:()=>Tl,DetrPreTrainedModel:()=>ba,DetrSegmentationOutput:()=>sg,Dinov2ForImageClassification:()=>GS,Dinov2Model:()=>$S,Dinov2PreTrainedModel:()=>kl,Dinov2WithRegistersForImageClassification:()=>US,Dinov2WithRegistersModel:()=>VS,Dinov2WithRegistersPreTrainedModel:()=>El,DistilBertForMaskedLM:()=>YS,DistilBertForQuestionAnswering:()=>XS,DistilBertForSequenceClassification:()=>HS,DistilBertForTokenClassification:()=>QS,DistilBertModel:()=>qS,DistilBertPreTrainedModel:()=>Cn,DonutSwinModel:()=>JS,DonutSwinPreTrainedModel:()=>ig,EdgeTamModel:()=>gO,EfficientNetForImageClassification:()=>tP,EfficientNetModel:()=>eP,EfficientNetPreTrainedModel:()=>Al,ElectraForMaskedLM:()=>nP,ElectraForQuestionAnswering:()=>oP,ElectraForSequenceClassification:()=>sP,ElectraForTokenClassification:()=>aP,ElectraModel:()=>rP,ElectraPreTrainedModel:()=>An,Ernie4_5ForCausalLM:()=>lP,Ernie4_5Model:()=>iP,Ernie4_5PretrainedModel:()=>Sl,EsmForMaskedLM:()=>uP,EsmForSequenceClassification:()=>dP,EsmForTokenClassification:()=>hP,EsmModel:()=>cP,EsmPreTrainedModel:()=>os,EuroBertForMaskedLM:()=>_P,EuroBertForSequenceClassification:()=>pP,EuroBertForTokenClassification:()=>mP,EuroBertModel:()=>fP,EuroBertPreTrainedModel:()=>is,ExaoneForCausalLM:()=>wP,ExaoneModel:()=>gP,ExaonePreTrainedModel:()=>Pl,FalconForCausalLM:()=>yP,FalconH1ForCausalLM:()=>MP,FalconH1Model:()=>bP,FalconH1PreTrainedModel:()=>Il,FalconModel:()=>vP,FalconPreTrainedModel:()=>Fl,FastViTForImageClassification:()=>TP,FastViTModel:()=>xP,FastViTPreTrainedModel:()=>Ll,Florence2ForConditionalGeneration:()=>kP,Florence2PreTrainedModel:()=>lg,GLPNForDepthEstimation:()=>VP,GLPNModel:()=>GP,GLPNPreTrainedModel:()=>Gl,GPT2LMHeadModel:()=>KP,GPT2Model:()=>JP,GPT2PreTrainedModel:()=>ql,GPTBigCodeForCausalLM:()=>WP,GPTBigCodeModel:()=>UP,GPTBigCodePreTrainedModel:()=>Vl,GPTJForCausalLM:()=>eF,GPTJModel:()=>ZP,GPTJPreTrainedModel:()=>Hl,GPTNeoForCausalLM:()=>qP,GPTNeoModel:()=>jP,GPTNeoPreTrainedModel:()=>Ul,GPTNeoXForCausalLM:()=>QP,GPTNeoXModel:()=>HP,GPTNeoXPreTrainedModel:()=>Wl,Gemma2ForCausalLM:()=>SP,Gemma2Model:()=>AP,Gemma2PreTrainedModel:()=>Nl,Gemma3ForCausalLM:()=>LP,Gemma3ForConditionalGeneration:()=>dg,Gemma3Model:()=>IP,Gemma3PreTrainedModel:()=>ug,Gemma3nForCausalLM:()=>OP,Gemma3nForConditionalGeneration:()=>Ma,Gemma3nPreTrainedModel:()=>hg,Gemma4ForCausalLM:()=>NP,Gemma4ForConditionalGeneration:()=>Dl,GemmaForCausalLM:()=>CP,GemmaModel:()=>EP,GemmaPreTrainedModel:()=>Ol,GlmForCausalLM:()=>BP,GlmModel:()=>DP,GlmMoeDsaForCausalLM:()=>RP,GlmMoeDsaModel:()=>zP,GlmMoeDsaPreTrainedModel:()=>zl,GlmOcrForConditionalGeneration:()=>$P,GlmPreTrainedModel:()=>Bl,GptOssForCausalLM:()=>YP,GptOssModel:()=>XP,GptOssPreTrainedModel:()=>jl,GraniteForCausalLM:()=>rF,GraniteModel:()=>tF,GraniteMoeHybridForCausalLM:()=>sF,GraniteMoeHybridModel:()=>nF,GraniteMoeHybridPreTrainedModel:()=>Xl,GranitePreTrainedModel:()=>Ql,GraniteSpeechForConditionalGeneration:()=>aF,GroundingDinoForObjectDetection:()=>oF,GroundingDinoPreTrainedModel:()=>gg,GroupViTModel:()=>iF,GroupViTPreTrainedModel:()=>wg,HeliumForCausalLM:()=>cF,HeliumModel:()=>lF,HeliumPreTrainedModel:()=>Jl,HieraForImageClassification:()=>dF,HieraModel:()=>uF,HieraPreTrainedModel:()=>Kl,HrmTextForCausalLM:()=>fF,HrmTextModel:()=>hF,HrmTextPreTrainedModel:()=>Zl,HubertForCTC:()=>yF,HubertForSequenceClassification:()=>bF,HubertModel:()=>vF,HubertPreTrainedModel:()=>wF,HunYuanDenseV1ForCausalLM:()=>xF,HunYuanDenseV1Model:()=>MF,HunYuanDenseV1PreTrainedModel:()=>ec,IJepaForImageClassification:()=>kF,IJepaModel:()=>TF,IJepaPreTrainedModel:()=>tc,Idefics3ForConditionalGeneration:()=>vg,ImageMattingOutput:()=>Lm,JAISLMHeadModel:()=>CF,JAISModel:()=>EF,JAISPreTrainedModel:()=>rc,JinaCLIPModel:()=>AF,JinaCLIPPreTrainedModel:()=>xa,JinaCLIPTextModel:()=>yg,JinaCLIPVisionModel:()=>SF,Lfm2ForCausalLM:()=>FF,Lfm2Model:()=>PF,Lfm2MoeForCausalLM:()=>OF,Lfm2MoeModel:()=>LF,Lfm2MoePreTrainedModel:()=>sc,Lfm2PreTrainedModel:()=>nc,Lfm2VlForConditionalGeneration:()=>NF,LightOnOcrForConditionalGeneration:()=>IF,LiteWhisperForConditionalGeneration:()=>zN,Llama4ForCausalLM:()=>zF,Llama4PreTrainedModel:()=>bg,LlamaForCausalLM:()=>BF,LlamaModel:()=>DF,LlamaPreTrainedModel:()=>ac,LlavaForConditionalGeneration:()=>Yt,LlavaOnevisionForConditionalGeneration:()=>Yt,LlavaPreTrainedModel:()=>cg,LlavaQwen2ForCausalLM:()=>FP,LongT5ForConditionalGeneration:()=>$F,LongT5Model:()=>RF,LongT5PreTrainedModel:()=>oc,M2M100ForConditionalGeneration:()=>VF,M2M100Model:()=>GF,M2M100PreTrainedModel:()=>ic,MBartForCausalLM:()=>YF,MBartForConditionalGeneration:()=>QF,MBartForSequenceClassification:()=>XF,MBartModel:()=>HF,MBartPreTrainedModel:()=>ls,MPNetForMaskedLM:()=>GI,MPNetForQuestionAnswering:()=>WI,MPNetForSequenceClassification:()=>VI,MPNetForTokenClassification:()=>UI,MPNetModel:()=>$I,MPNetPreTrainedModel:()=>Sn,MT5ForConditionalGeneration:()=>QI,MT5Model:()=>HI,MT5PreTrainedModel:()=>yc,MarianMTModel:()=>WF,MarianModel:()=>UF,MarianPreTrainedModel:()=>lc,MaskFormerForInstanceSegmentation:()=>qF,MaskFormerModel:()=>jF,MaskFormerPreTrainedModel:()=>cc,MaskedLMOutput:()=>He,Metric3DForDepthEstimation:()=>JF,Metric3DPreTrainedModel:()=>Mg,Metric3Dv2ForDepthEstimation:()=>KF,Metric3Dv2PreTrainedModel:()=>xg,MgpstrForSceneTextRecognition:()=>ZF,MgpstrModelOutput:()=>Tg,MgpstrPreTrainedModel:()=>kg,MimiDecoderModel:()=>Sg,MimiDecoderOutput:()=>Cg,MimiEncoderModel:()=>Ag,MimiEncoderOutput:()=>Eg,MimiModel:()=>eI,MimiPreTrainedModel:()=>Ta,Ministral3ForCausalLM:()=>sI,Ministral3Model:()=>nI,Ministral3PreTrainedModel:()=>dc,MinistralForCausalLM:()=>rI,MinistralModel:()=>tI,MinistralPreTrainedModel:()=>uc,Mistral3ForConditionalGeneration:()=>iI,Mistral4ForCausalLM:()=>cI,Mistral4Model:()=>lI,Mistral4PreTrainedModel:()=>fc,MistralForCausalLM:()=>oI,MistralModel:()=>aI,MistralPreTrainedModel:()=>hc,MobileBertForMaskedLM:()=>dI,MobileBertForQuestionAnswering:()=>fI,MobileBertForSequenceClassification:()=>hI,MobileBertModel:()=>uI,MobileBertPreTrainedModel:()=>cs,MobileLLMForCausalLM:()=>pI,MobileLLMModel:()=>_I,MobileLLMPreTrainedModel:()=>_c,MobileNetV1ForImageClassification:()=>gI,MobileNetV1ForSemanticSegmentation:()=>wI,MobileNetV1Model:()=>mI,MobileNetV1PreTrainedModel:()=>ka,MobileNetV2ForImageClassification:()=>yI,MobileNetV2ForSemanticSegmentation:()=>bI,MobileNetV2Model:()=>vI,MobileNetV2PreTrainedModel:()=>Ea,MobileNetV3ForImageClassification:()=>xI,MobileNetV3ForSemanticSegmentation:()=>TI,MobileNetV3Model:()=>MI,MobileNetV3PreTrainedModel:()=>Ca,MobileNetV4ForImageClassification:()=>EI,MobileNetV4ForSemanticSegmentation:()=>CI,MobileNetV4Model:()=>kI,MobileNetV4PreTrainedModel:()=>Aa,MobileViTForImageClassification:()=>SI,MobileViTModel:()=>AI,MobileViTPreTrainedModel:()=>pc,MobileViTV2ForImageClassification:()=>FI,MobileViTV2Model:()=>PI,MobileViTV2PreTrainedModel:()=>mc,ModelOutput:()=>Ve,ModernBertDecoderForCausalLM:()=>BI,ModernBertDecoderModel:()=>DI,ModernBertDecoderPreTrainedModel:()=>gc,ModernBertForMaskedLM:()=>LI,ModernBertForSequenceClassification:()=>OI,ModernBertForTokenClassification:()=>NI,ModernBertModel:()=>II,ModernBertPreTrainedModel:()=>us,Moondream1ForConditionalGeneration:()=>PP,MoonshineForConditionalGeneration:()=>RI,MoonshineModel:()=>zI,MoonshinePreTrainedModel:()=>wc,MptForCausalLM:()=>qI,MptModel:()=>jI,MptPreTrainedModel:()=>vc,MultiModalityCausalLM:()=>XI,MultiModalityPreTrainedModel:()=>Pg,MusicgenForCausalLM:()=>JI,MusicgenForConditionalGeneration:()=>Fg,MusicgenModel:()=>YI,MusicgenPreTrainedModel:()=>bc,NanoChatForCausalLM:()=>ZI,NanoChatModel:()=>KI,NanoChatPreTrainedModel:()=>Mc,NemotronHForCausalLM:()=>tL,NemotronHModel:()=>eL,NemotronHPreTrainedModel:()=>xc,NeoBertForMaskedLM:()=>nL,NeoBertForQuestionAnswering:()=>oL,NeoBertForSequenceClassification:()=>sL,NeoBertForTokenClassification:()=>aL,NeoBertModel:()=>rL,NeoBertPreTrainedModel:()=>Pn,NomicBertModel:()=>iL,NomicBertPreTrainedModel:()=>Ig,OPTForCausalLM:()=>bL,OPTModel:()=>yL,OPTPreTrainedModel:()=>Pc,Olmo2ForCausalLM:()=>dL,Olmo2Model:()=>uL,Olmo2PreTrainedModel:()=>kc,Olmo3ForCausalLM:()=>fL,Olmo3Model:()=>hL,Olmo3PreTrainedModel:()=>Ec,OlmoForCausalLM:()=>cL,OlmoHybridForCausalLM:()=>pL,OlmoHybridModel:()=>_L,OlmoHybridPreTrainedModel:()=>Cc,OlmoModel:()=>lL,OlmoPreTrainedModel:()=>Tc,OpenAIPrivacyFilterForTokenClassification:()=>gL,OpenAIPrivacyFilterModel:()=>mL,OpenAIPrivacyFilterPreTrainedModel:()=>Ac,OpenELMForCausalLM:()=>vL,OpenELMModel:()=>wL,OpenELMPreTrainedModel:()=>Sc,OwlViTForObjectDetection:()=>kL,OwlViTModel:()=>TL,OwlViTPreTrainedModel:()=>Ic,Owlv2ForObjectDetection:()=>xL,Owlv2Model:()=>ML,Owlv2PreTrainedModel:()=>Fc,PaliGemmaForConditionalGeneration:()=>EL,ParakeetForCTC:()=>CL,ParakeetPreTrainedModel:()=>Lg,PatchTSMixerForPrediction:()=>SL,PatchTSMixerModel:()=>AL,PatchTSMixerPreTrainedModel:()=>Lc,PatchTSTForPrediction:()=>FL,PatchTSTModel:()=>PL,PatchTSTPreTrainedModel:()=>Oc,Phi3ForCausalLM:()=>NL,Phi3Model:()=>OL,Phi3PreTrainedModel:()=>Dc,Phi3VForCausalLM:()=>Ng,Phi3VPreTrainedModel:()=>Og,PhiForCausalLM:()=>LL,PhiModel:()=>IL,PhiPreTrainedModel:()=>Nc,PreTrainedModel:()=>P,PvtForImageClassification:()=>BL,PvtModel:()=>DL,PvtPreTrainedModel:()=>Bc,PyAnnoteForAudioFrameClassification:()=>RL,PyAnnoteModel:()=>zL,PyAnnotePreTrainedModel:()=>zc,QuestionAnsweringModelOutput:()=>nt,Qwen2ForCausalLM:()=>GL,Qwen2Model:()=>$L,Qwen2MoeForCausalLM:()=>UL,Qwen2MoeModel:()=>VL,Qwen2MoePreTrainedModel:()=>$c,Qwen2PreTrainedModel:()=>Rc,Qwen2VLForCausalLM:()=>_g,Qwen2VLForConditionalGeneration:()=>Rl,Qwen2VLPreTrainedModel:()=>fg,Qwen2_5_VLForCausalLM:()=>pg,Qwen2_5_VLForConditionalGeneration:()=>$l,Qwen3ForCausalLM:()=>jL,Qwen3Model:()=>WL,Qwen3MoeForCausalLM:()=>HL,Qwen3MoeModel:()=>qL,Qwen3MoePreTrainedModel:()=>Vc,Qwen3NextForCausalLM:()=>XL,Qwen3NextModel:()=>QL,Qwen3NextPreTrainedModel:()=>Uc,Qwen3PreTrainedModel:()=>Gc,Qwen3VLForCausalLM:()=>Dg,Qwen3VLForConditionalGeneration:()=>Wc,Qwen3VLMoeForCausalLM:()=>JL,Qwen3VLMoeForConditionalGeneration:()=>YL,Qwen3_5ForCausalLM:()=>Bg,Qwen3_5ForConditionalGeneration:()=>jc,Qwen3_5MoeForCausalLM:()=>ZL,Qwen3_5MoeForConditionalGeneration:()=>KL,RFDetrForObjectDetection:()=>nO,RFDetrModel:()=>rO,RFDetrObjectDetectionOutput:()=>zg,RFDetrPreTrainedModel:()=>Hc,RTDetrForObjectDetection:()=>_S,RTDetrModel:()=>fS,RTDetrObjectDetectionOutput:()=>as,RTDetrPreTrainedModel:()=>vl,RTDetrV2ForObjectDetection:()=>pO,RTDetrV2Model:()=>_O,RTDetrV2ObjectDetectionOutput:()=>Rg,RTDetrV2PreTrainedModel:()=>Qc,ResNetForImageClassification:()=>tO,ResNetModel:()=>eO,ResNetPreTrainedModel:()=>qc,RoFormerForMaskedLM:()=>uO,RoFormerForQuestionAnswering:()=>fO,RoFormerForSequenceClassification:()=>dO,RoFormerForTokenClassification:()=>hO,RoFormerModel:()=>cO,RoFormerPreTrainedModel:()=>In,RobertaForMaskedLM:()=>aO,RobertaForQuestionAnswering:()=>lO,RobertaForSequenceClassification:()=>oO,RobertaForTokenClassification:()=>iO,RobertaModel:()=>sO,RobertaPreTrainedModel:()=>Fn,Sam2ImageSegmentationOutput:()=>Vg,Sam2Model:()=>Xc,Sam2PreTrainedModel:()=>Ug,Sam3TrackerModel:()=>wO,SamImageSegmentationOutput:()=>$g,SamModel:()=>mO,SamPreTrainedModel:()=>Gg,SapiensForDepthEstimation:()=>yO,SapiensForNormalEstimation:()=>bO,SapiensForSemanticSegmentation:()=>vO,SapiensPreTrainedModel:()=>Sa,SegformerForImageClassification:()=>xO,SegformerForSemanticSegmentation:()=>TO,SegformerModel:()=>MO,SegformerPreTrainedModel:()=>Pa,Seq2SeqLMOutput:()=>FC,SequenceClassifierOutput:()=>ie,SiglipModel:()=>kO,SiglipPreTrainedModel:()=>Yc,SiglipTextModel:()=>Wg,SiglipVisionModel:()=>EO,SmolLM3ForCausalLM:()=>AO,SmolLM3Model:()=>CO,SmolLM3PreTrainedModel:()=>Jc,SmolVLMForConditionalGeneration:()=>SO,SnacDecoderModel:()=>qg,SnacEncoderModel:()=>jg,SnacModel:()=>PO,SnacPreTrainedModel:()=>Fa,SolarOpenForCausalLM:()=>IO,SolarOpenModel:()=>FO,SolarOpenPreTrainedModel:()=>Kc,SpeechT5ForSpeechToText:()=>OO,SpeechT5ForTextToSpeech:()=>NO,SpeechT5HifiGan:()=>DO,SpeechT5Model:()=>LO,SpeechT5PreTrainedModel:()=>Ia,SqueezeBertForMaskedLM:()=>zO,SqueezeBertForQuestionAnswering:()=>$O,SqueezeBertForSequenceClassification:()=>RO,SqueezeBertModel:()=>BO,SqueezeBertPreTrainedModel:()=>ds,StableLmForCausalLM:()=>VO,StableLmModel:()=>GO,StableLmPreTrainedModel:()=>Zc,Starcoder2ForCausalLM:()=>WO,Starcoder2Model:()=>UO,Starcoder2PreTrainedModel:()=>eu,StyleTextToSpeech2Model:()=>jO,StyleTextToSpeech2PreTrainedModel:()=>Hg,SupertonicForConditionalGeneration:()=>Xg,SupertonicPreTrainedModel:()=>Qg,Swin2SRForImageSuperResolution:()=>YO,Swin2SRModel:()=>XO,Swin2SRPreTrainedModel:()=>tu,SwinForImageClassification:()=>HO,SwinForSemanticSegmentation:()=>QO,SwinModel:()=>qO,SwinPreTrainedModel:()=>La,T5ForConditionalGeneration:()=>KO,T5Model:()=>JO,T5PreTrainedModel:()=>ru,TableTransformerForObjectDetection:()=>eN,TableTransformerModel:()=>ZO,TableTransformerObjectDetectionOutput:()=>Yg,TableTransformerPreTrainedModel:()=>nu,TokenClassifierOutput:()=>je,TrOCRForCausalLM:()=>tN,TrOCRPreTrainedModel:()=>Jg,UltravoxModel:()=>Yl,UltravoxPreTrainedModel:()=>mg,UniSpeechForCTC:()=>nN,UniSpeechForSequenceClassification:()=>sN,UniSpeechModel:()=>rN,UniSpeechPreTrainedModel:()=>Oa,UniSpeechSatForAudioFrameClassification:()=>lN,UniSpeechSatForCTC:()=>oN,UniSpeechSatForSequenceClassification:()=>iN,UniSpeechSatModel:()=>aN,UniSpeechSatPreTrainedModel:()=>hs,VaultGemmaForCausalLM:()=>uN,VaultGemmaModel:()=>cN,VaultGemmaPreTrainedModel:()=>su,ViTForImageClassification:()=>fN,ViTMAEModel:()=>_N,ViTMAEPreTrainedModel:()=>Kg,ViTMSNForImageClassification:()=>mN,ViTMSNModel:()=>pN,ViTMSNPreTrainedModel:()=>ou,ViTModel:()=>hN,ViTPreTrainedModel:()=>au,VisionEncoderDecoderModel:()=>dN,VitMatteForImageMatting:()=>gN,VitMattePreTrainedModel:()=>Zg,VitPoseForPoseEstimation:()=>wN,VitPosePreTrainedModel:()=>ew,VitsModel:()=>vN,VitsModelOutput:()=>tw,VitsPreTrainedModel:()=>rw,VoxtralForConditionalGeneration:()=>yN,VoxtralRealtimeForConditionalGeneration:()=>sw,VoxtralRealtimePreTrainedModel:()=>nw,Wav2Vec2BertForCTC:()=>AN,Wav2Vec2BertForSequenceClassification:()=>SN,Wav2Vec2BertModel:()=>CN,Wav2Vec2BertPreTrainedModel:()=>Na,Wav2Vec2ForAudioFrameClassification:()=>gF,Wav2Vec2ForCTC:()=>pF,Wav2Vec2ForSequenceClassification:()=>mF,Wav2Vec2Model:()=>_F,Wav2Vec2PreTrainedModel:()=>Er,WavLMForAudioFrameClassification:()=>ON,WavLMForCTC:()=>FN,WavLMForSequenceClassification:()=>IN,WavLMForXVector:()=>LN,WavLMModel:()=>PN,WavLMPreTrainedModel:()=>Ln,WeSpeakerResNetModel:()=>NN,WeSpeakerResNetPreTrainedModel:()=>ow,WhisperForConditionalGeneration:()=>iw,WhisperModel:()=>BN,WhisperPreTrainedModel:()=>iu,XLMForQuestionAnswering:()=>UN,XLMForSequenceClassification:()=>GN,XLMForTokenClassification:()=>VN,XLMModel:()=>RN,XLMPreTrainedModel:()=>On,XLMRobertaForMaskedLM:()=>jN,XLMRobertaForQuestionAnswering:()=>QN,XLMRobertaForSequenceClassification:()=>qN,XLMRobertaForTokenClassification:()=>HN,XLMRobertaModel:()=>WN,XLMRobertaPreTrainedModel:()=>Nn,XLMWithLMHeadModel:()=>$N,XVectorOutput:()=>aw,YolosForObjectDetection:()=>YN,YolosModel:()=>XN,YolosObjectDetectionOutput:()=>lw,YolosPreTrainedModel:()=>lu,YoutuForCausalLM:()=>KN,YoutuModel:()=>JN,YoutuPreTrainedModel:()=>cu,ZayaForCausalLM:()=>e3,ZayaModel:()=>ZN,ZayaPreTrainedModel:()=>uu});var ss=class extends P{},iA=class extends ss{},lA=class extends ss{async _call(e){return new ie(await super._call(e))}},cA=class extends ss{async _call(e){return new nt(await super._call(e))}},uA=class extends ss{async _call(e){return new He(await super._call(e))}},sl=class extends P{},dA=class extends sl{},hA=class extends sl{},al=class extends P{},fA=class extends al{},_A=class extends al{},ol=class extends P{},pA=class extends ol{},mA=class extends ol{},il=class extends P{},gA=class extends il{},wA=class extends il{},wa=class extends P{},vA=class extends wa{},yA=class extends wa{},bA=class extends wa{async _call(e){return new ie(await super._call(e))}},ll=class extends P{},MA=class extends ll{},xA=class extends ll{async _call(e){return new ie(await super._call(e))}},Mn=class extends P{},TA=class extends Mn{},kA=class extends Mn{async _call(e){return new He(await super._call(e))}},EA=class extends Mn{async _call(e){return new ie(await super._call(e))}},CA=class extends Mn{async _call(e){return new je(await super._call(e))}},AA=class extends Mn{async _call(e){return new nt(await super._call(e))}},cl=class extends P{},SA=class extends cl{},PA=class extends cl{},ul=class extends P{},FA=class extends ul{},IA=class extends ul{},dl=class extends P{},LA=class extends dl{},OA=class extends dl{},xn=class extends P{},NA=class extends xn{},DA=class extends xn{async _call(e){return new He(await super._call(e))}},BA=class extends xn{async _call(e){return new ie(await super._call(e))}},zA=class extends xn{async _call(e){return new je(await super._call(e))}},RA=class extends xn{async _call(e){return new nt(await super._call(e))}},$A=4299n,Zf=6561n,Wm=class extends P{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"]},jm=class extends Wm{async encode_speech(e){return ye(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:r=null,exaggeration:n=null,position_ids:s=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:i=null,logits_processor:l=null,num_logits_to_keep:u=null,audio_features:h=null,audio_tokens:f=null,speaker_embeddings:_=null,speaker_features:g=null,...w}){let v;if(!a){const x=this.sessions.embed_tokens.inputNames,k={input_ids:e};if(x.includes("exaggeration")){if(!(n instanceof W)){const C=e.dims[0];if(n==null)n=ot([C],.5);else if(typeof n=="number")n=ot([C],n);else if(Array.isArray(n))n=new W("float32",n,[C]);else throw new Error("Unsupported type for `exaggeration` input")}k.exaggeration=n}if(x.includes("position_ids")&&(k.position_ids=s),{inputs_embeds:a}=await ye(this.sessions.embed_tokens,k),h&&f&&_&&g&&(v={audio_features:h,audio_tokens:f,speaker_embeddings:_,speaker_features:g}),v||r)v??=await this.encode_speech(r),a=De([v.audio_features,a],1),t=dt([a.dims[0],a.dims[1]]);else{const C=a.dims[1];if(!o||C!==1)throw new Error("Incorrect state encountered during generation.");const E=o.get_seq_length();t=dt([a.dims[0],E+C])}}return{...await ar(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,generation_config:i,logits_processor:l,num_logits_to_keep:u},!1),...v}}prepare_inputs_for_generation(e,t,r){if(!t.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(t.input_ids.dims[1]===1){const n=Array.from({length:e.length},(s,a)=>e[a].length-e[a].findLastIndex(o=>o==Zf)-1);t.position_ids=new W("int64",n,[e.length,1])}else{const s=t.input_ids.tolist().map(a=>{let o=0;return a.map(i=>i>=Zf?0:o++)});t.position_ids=new W("int64",s.flat(),t.input_ids.dims)}return 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),gn(this,e,t)}async generate(e){const t=e.past_key_values,{sequences:r,audio_tokens:n,speaker_embeddings:s,speaker_features:a,past_key_values:o}=await super.generate({...e,return_dict_in_generate:!0});try{const i=r.slice(null,[e.input_ids.dims[1],-1]),l=ot([i.dims[0],3],$A),u=De([n,i,l],1),{waveform:h}=await ye(this.sessions.conditional_decoder,{speech_tokens:u,speaker_features:a,speaker_embeddings:s});return h}finally{o!==t&&await o?.dispose()}}},qm=class extends P{},GA=class extends qm{},Hm=class extends P{},VA=class extends Hm{},va=class extends P{},UA=class extends va{},Qm=class extends va{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},Xm=class extends va{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"audio_model"})}},Hr=class extends P{},WA=class extends Hr{},jA=class extends Hr{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},Ym=class extends Hr{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},qA=class extends Hr{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},HA=class extends Hr{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},hl=class extends P{},QA=class extends hl{},XA=class extends hl{},fl=class extends P{},YA=class extends fl{},JA=class extends fl{},_l=class extends P{},KA=class extends _l{},ZA=class extends _l{},pl=class extends P{},eS=class extends pl{},tS=class extends pl{},ml=class extends P{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","decoder_input_ids","decoder_attention_mask","past_key_values"]},rS=class extends ml{},nS=class extends ml{},Tn=class extends P{},sS=class extends Tn{},aS=class extends Tn{async _call(e){return new He(await super._call(e))}},oS=class extends Tn{async _call(e){return new ie(await super._call(e))}},iS=class extends Tn{async _call(e){return new je(await super._call(e))}},lS=class extends Tn{async _call(e){return new nt(await super._call(e))}},gl=class extends P{},cS=class extends gl{},uS=class extends gl{async _call(e){return new ie(await super._call(e))}},wl=class extends P{},dS=class extends wl{},hS=class extends wl{async _call(e){return new ie(await super._call(e))}},vl=class extends P{},fS=class extends vl{},_S=class extends vl{async _call(e){return new as(await super._call(e))}},as=class extends Ve{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},yl=class extends P{},pS=class extends yl{},mS=class extends yl{async _call(e){return new as(await super._call(e))}},Jm=class extends Ve{constructor({audio_codes:e}){super(),this.audio_codes=e}},Km=class extends Ve{constructor({audio_values:e}){super(),this.audio_values=e}},ya=class extends P{main_input_name="input_values";forward_params=["input_values"]},gS=class extends ya{async encode(e){return new Jm(await ye(this.sessions.encoder_model,e))}async decode(e){return new Km(await ye(this.sessions.decoder_model,e))}},Zm=class extends ya{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},eg=class extends ya{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},kn=class extends P{},wS=class extends kn{},vS=class extends kn{async _call(e){return new He(await super._call(e))}},yS=class extends kn{async _call(e){return new ie(await super._call(e))}},bS=class extends kn{async _call(e){return new je(await super._call(e))}},MS=class extends kn{async _call(e){return new nt(await super._call(e))}},bl=class extends P{},xS=class extends bl{},TS=class extends bl{},Ml=class extends P{},kS=class extends Ml{},ES=class extends Ml{},En=class extends P{},CS=class extends En{},AS=class extends En{async _call(e){return new He(await super._call(e))}},SS=class extends En{async _call(e){return new ie(await super._call(e))}},PS=class extends En{async _call(e){return new je(await super._call(e))}},FS=class extends En{async _call(e){return new nt(await super._call(e))}},tg=class extends P{},IS=class extends tg{},xl=class extends P{},LS=class extends xl{},OS=class extends xl{async _call(e){return new ie(await super._call(e))}},rg=class extends P{},NS=class extends rg{},ng=class extends P{},DS=class extends ng{},ba=class extends P{},BS=class extends ba{},zS=class extends ba{async _call(e){return new Tl(await super._call(e))}},RS=class extends ba{async _call(e){return new sg(await super._call(e))}},Tl=class extends Ve{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},sg=class extends Ve{constructor({logits:e,pred_boxes:t,pred_masks:r}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=r}},kl=class extends P{},$S=class extends kl{},GS=class extends kl{async _call(e){return new ie(await super._call(e))}},El=class extends P{},VS=class extends El{},US=class extends El{async _call(e){return new ie(await super._call(e))}},ag=class extends P{},WS=class extends ag{},og=class extends P{},jS=class extends og{},Cn=class extends P{},qS=class extends Cn{},HS=class extends Cn{async _call(e){return new ie(await super._call(e))}},QS=class extends Cn{async _call(e){return new je(await super._call(e))}},XS=class extends Cn{async _call(e){return new nt(await super._call(e))}},YS=class extends Cn{async _call(e){return new He(await super._call(e))}},ig=class extends P{},JS=class extends ig{},Cl=class extends P{},KS=class extends Cl{},ZS=class extends Cl{},Al=class extends P{},eP=class extends Al{},tP=class extends Al{async _call(e){return new ie(await super._call(e))}},An=class extends P{},rP=class extends An{},nP=class extends An{async _call(e){return new He(await super._call(e))}},sP=class extends An{async _call(e){return new ie(await super._call(e))}},aP=class extends An{async _call(e){return new je(await super._call(e))}},oP=class extends An{async _call(e){return new nt(await super._call(e))}},Sl=class extends P{},iP=class extends Sl{},lP=class extends Sl{},os=class extends P{},cP=class extends os{},uP=class extends os{async _call(e){return new He(await super._call(e))}},dP=class extends os{async _call(e){return new ie(await super._call(e))}},hP=class extends os{async _call(e){return new je(await super._call(e))}},is=class extends P{},fP=class extends is{},_P=class extends is{async _call(e){return new He(await super._call(e))}},pP=class extends is{async _call(e){return new ie(await super._call(e))}},mP=class extends is{async _call(e){return new je(await super._call(e))}},Pl=class extends P{},gP=class extends Pl{},wP=class extends Pl{},Fl=class extends P{},vP=class extends Fl{},yP=class extends Fl{},Il=class extends P{},bP=class extends Il{},MP=class extends Il{},Ll=class extends P{},xP=class extends Ll{},TP=class extends Ll{async _call(e){return new ie(await super._call(e))}},lg=class extends P{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"},kP=class extends lg{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:r,attention_mask:n}){return{inputs_embeds:De([t,e],1),attention_mask:De([dt(t.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:r,attention_mask:n}){if(!e&&!t)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let s,a;return e&&(s=await this.encode_text({input_ids:e})),t&&(a=await this.encode_image({pixel_values:t})),s&&a?{inputs_embeds:r,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:s,image_features:a,input_ids:e,attention_mask:n}):r=s||a,{inputs_embeds:r,attention_mask:n}}async forward({input_ids:e,pixel_values:t,attention_mask:r,decoder_input_ids:n,decoder_attention_mask:s,encoder_outputs:a,past_key_values:o,inputs_embeds:i,decoder_inputs_embeds:l,num_logits_to_keep:u=null}){if(i||({inputs_embeds:i,attention_mask:r}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:i,attention_mask:r})),!a){let{last_hidden_state:f}=await Tr(this,{inputs_embeds:i,attention_mask:r});a=f}if(!l){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");l=await this.encode_text({input_ids:n})}return await ar(this,{inputs_embeds:l,attention_mask:s,encoder_attention_mask:r,encoder_hidden_states:a,past_key_values:o,num_logits_to_keep:u},!0)}},Ol=class extends P{},EP=class extends Ol{},CP=class extends Ol{},Nl=class extends P{},AP=class extends Nl{},SP=class extends Nl{},cg=class extends P{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Yt=class extends cg{_merge_input_ids_with_image_features(e){const t=e.image_features.dims.at(-1),r=e.image_features.view(-1,t);return rl({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:r})}},PP=class extends Yt{},FP=class extends Yt{},ug=class extends P{},IP=class extends ug{},dg=class extends Yt{},LP=class extends dg{},hg=class extends P{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},Ma=class extends hg{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:r=null,input_features:n=null,input_features_mask:s=null,position_ids:a=null,inputs_embeds:o=null,per_layer_inputs:i=null,past_key_values:l=null,generation_config:u=null,logits_processor:h=null,num_logits_to_keep:f=null,..._}){if((!o||!i)&&({inputs_embeds:o,per_layer_inputs:i}=await ye(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(r){const{image_features:w}=await this._encode_vision({pixel_values:r,..._});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:w,inputs_embeds:o,input_ids:e,attention_mask:t}))}if(n){const{audio_features:w}=await ye(this.sessions.audio_encoder,{input_features:n,input_features_mask:s});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:w,inputs_embeds:o,input_ids:e,attention_mask:t}))}}return await ar(this,{inputs_embeds:o,per_layer_inputs:i,past_key_values:l,attention_mask:t,position_ids:a,generation_config:u,logits_processor:h,num_logits_to_keep:f},!0)}_encode_vision(e){return ye(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){const t=e.image_features.dims.at(-1),r=e.image_features.view(-1,t);return rl({image_token_id:this.config.image_token_id,...e,image_features:r})}_merge_input_ids_with_audio_features(e){const t=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,t);return Um({audio_token_id:this.config.audio_token_id,...e,audio_features:r})}},OP=class extends Ma{},Dl=class extends Ma{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 ye(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},NP=class extends Dl{},Bl=class extends P{},DP=class extends Bl{},BP=class extends Bl{},zl=class extends P{},zP=class extends zl{},RP=class extends zl{},fg=class extends P{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},Rl=class extends fg{image_grid_thw_name="grid_thw";_get_text_only_rope_index(e,t){if(t){const{data:r,dims:n}=Gm(t),s=BigInt64Array.from({length:3*r.length},(o,i)=>r[i%r.length]),a=Array.from({length:n[0]},(o,i)=>Ye(r.subarray(n[1]*i,n[1]*(i+1)))[0]+1n+BigInt(n[1]));return[new W("int64",s,[3,...n]),new W("int64",a,[a.length,1])]}else{const[r,n]=e.dims,s=BigInt64Array.from({length:3*r*n},(a,o)=>BigInt(Math.floor(o%n/r)));return[new W("int64",s,[3,...e.dims]),Gp([r,1])]}}_reorder_and_write_positions(e,t,r,n){const s=e.reduce((l,u)=>l+u.length,0),a=new Array(s);let o=0;for(let l=0;l<3;++l)for(const u of e){const h=u.length/3;for(let f=l*h;f<(l+1)*h;++f)a[o++]=u[f]}let i=0;for(let l=0;l<t.length;++l)if(t[l]==1){for(let u=0;u<3;++u)r[u][n][l]=a[u*s/3+i];++i}return a}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:r,spatial_merge_size:n,state:s}){const{image_token_id:a,video_token_id:o,vision_start_token_id:i}=this.config,l=e,h=l.reduce((x,k,C)=>(k==i&&x.push(C),x),[]).map(x=>l[x+1]),f=h.filter(x=>x==a).length,_=h.filter(x=>x==o).length,g=[];let w=0,v=f,M=_;for(let x=0;x<h.length;++x){const k=l.findIndex((L,O)=>O>w&&L==a),C=l.findIndex((L,O)=>O>w&&L==o),E=v>0&&k!==-1?k:l.length+1,F=M>0&&C!==-1?C:l.length+1;let z,b,V,R;E<F?([b,V,R]=t[s.image_index],++s.image_index,--v,z=E):([b,V,R]=r[s.video_index],++s.video_index,--M,z=F);const[H,J,X]=[Number(b),Math.floor(Number(V)/n),Math.floor(Number(R)/n)],D=z-w,I=g.length>0?Ye(g.at(-1))[0]+1:0;g.push(Array.from({length:3*D},(L,O)=>I+O%D));const G=D+I,Q=H*J*X,ce=Array.from({length:Q},(L,O)=>G+Math.floor(O/(J*X))),Z=Array.from({length:Q},(L,O)=>G+Math.floor(O/X)%J),ne=Array.from({length:Q},(L,O)=>G+O%X);g.push([ce,Z,ne].flat()),w=z+Q}if(w<l.length){const x=g.length>0?Ye(g.at(-1))[0]+1:0,k=l.length-w;g.push(Array.from({length:3*k},(C,E)=>x+E%k))}return g}get_rope_index(e,t,r,n){const{vision_config:s}=this.config,a=s.spatial_merge_size??2;if(t||r){const o=e.tolist();n||(n=Wi(e));const i=n.tolist(),l=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),u=t?t.tolist():[],h=r?r.tolist():[],f={image_index:0,video_index:0},_=[];for(let g=0;g<o.length;++g){const w=o[g].filter((x,k)=>i[g][k]==1),v=this._get_multimodal_rope_positions({filtered_ids:w,image_grid_thw_list:u,video_grid_thw_list:h,spatial_merge_size:a,state:f}),M=this._reorder_and_write_positions(v,i[g],l,g);_.push(Ye(M)[0]+1-o[g].length)}return[new W("int64",l.flat(1/0),[3,e.dims[0],e.dims[1]]),new W("int64",_,[_.length,1])]}else return this._get_text_only_rope_index(e,n)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await ye(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return rl({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,r){if(ns(this,t,1n),!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;const s=t.past_key_values.get_seq_length();if(s<t.input_ids.dims[1]){const[a,o]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);t.rope_deltas=o,t.position_ids=a.slice(null,null,[s,null]),t.input_ids=t.input_ids.slice(null,[s,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));const a=BigInt(s),o=t.rope_deltas.map(i=>a+i);t.position_ids=sr([o,o,o],0)}}return t}},_g=class extends Rl{},$l=class extends Rl{image_grid_thw_name="image_grid_thw"},pg=class extends _g{image_grid_thw_name="image_grid_thw"},$P=class extends $l{get_vision_position_ids(e,t,r,n){const s=Math.floor(t[0]/r),a=Math.floor(t[1]/n),o=Math.floor(t[2]/n),i=a*o*s,l=Array.from({length:i},()=>e),u=Array.from({length:i},(f,_)=>e+Math.floor(_/(o*s))),h=Array.from({length:i},(f,_)=>e+_%o);return[...l,...u,...h]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:r,spatial_merge_size:n,state:s}){const{image_token_id:a}=this.config,o=[];let i=0,l=e[0]==a?1:0;for(let f=1;f<=e.length;++f){const _=f<e.length?e[f]==a?1:0:-1;_!==l&&(o.push([l,i,f]),i=f,l=_)}let u=0;const h=[];for(const[f,_,g]of o)if(f===0){const w=g-_;h.push(Array.from({length:3*w},(v,M)=>u+M%w)),u+=w}else{const w=t[s.image_index++].map(Number),v=w[0];h.push(this.get_vision_position_ids(u,w,v,n)),u+=Math.max(w[1],w[2])/n}return h}},Gl=class extends P{},GP=class extends Gl{},VP=class extends Gl{},Vl=class extends P{},UP=class extends Vl{},WP=class extends Vl{},Ul=class extends P{},jP=class extends Ul{},qP=class extends Ul{},Wl=class extends P{},HP=class extends Wl{},QP=class extends Wl{},jl=class extends P{},XP=class extends jl{},YP=class extends jl{},ql=class extends P{},JP=class extends ql{},KP=class extends ql{},Hl=class extends P{},ZP=class extends Hl{},eF=class extends Hl{},Ql=class extends P{},tF=class extends Ql{},rF=class extends Ql{},Xl=class extends P{},nF=class extends Xl{},sF=class extends Xl{},mg=class extends P{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},Yl=class extends mg{_merge_input_ids_with_audio_features(e){const t=e.audio_features.dims.at(-1),r=e.audio_features.view(-1,t);return Um({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:r})}},aF=class extends Yl{forward_params=["input_ids","attention_mask","input_features","past_key_values"]},gg=class extends P{},oF=class extends gg{},wg=class extends P{},iF=class extends wg{},Jl=class extends P{},lF=class extends Jl{},cF=class extends Jl{},Kl=class extends P{},uF=class extends Kl{},dF=class extends Kl{async _call(e){return new ie(await super._call(e))}},Zl=class extends P{},hF=class extends Zl{},fF=class extends Zl{forward_params=["input_ids","attention_mask","token_type_ids","past_key_values"];prepare_inputs_for_generation(e,t,r){const n=gn(this,e,t);return n.token_type_ids=(n.past_key_values?ji:Wi)(n.input_ids),n}},Er=class extends P{},_F=class extends Er{},pF=class extends Er{async _call(e){return new kr(await super._call(e))}},mF=class extends Er{async _call(e){return new ie(await super._call(e))}},gF=class extends Er{async _call(e){return new je(await super._call(e))}},wF=class extends P{},vF=class extends Er{},yF=class extends Er{async _call(e){return new kr(await super._call(e))}},bF=class extends Er{async _call(e){return new ie(await super._call(e))}},ec=class extends P{},MF=class extends ec{},xF=class extends ec{},vg=class extends Yt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]},tc=class extends P{},TF=class extends tc{},kF=class extends tc{async _call(e){return new ie(await super._call(e))}},rc=class extends P{},EF=class extends rc{},CF=class extends rc{},xa=class extends P{},AF=class extends xa{async forward(e){const t=!e.input_ids,r=!e.pixel_values;if(t&&r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=dt([e.pixel_values.dims[0],1])),r){const{image_size:l}=this.config.vision_config;e.pixel_values=ot([0,3,l,l],0)}const{text_embeddings:n,image_embeddings:s,l2norm_text_embeddings:a,l2norm_image_embeddings:o}=await super.forward(e),i={};return t||(i.text_embeddings=n,i.l2norm_text_embeddings=a),r||(i.image_embeddings=s,i.l2norm_image_embeddings=o),i}},yg=class extends xa{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},SF=class extends xa{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},nc=class extends P{},PF=class extends nc{},FF=class extends nc{},IF=class extends Yt{},sc=class extends P{},LF=class extends sc{},OF=class extends sc{},NF=class extends Yt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]},ac=class extends P{},DF=class extends ac{},BF=class extends ac{},bg=class extends P{},zF=class extends bg{},oc=class extends P{},RF=class extends oc{},$F=class extends oc{},ic=class extends P{},GF=class extends ic{},VF=class extends ic{},lc=class extends P{},UF=class extends lc{},WF=class extends lc{},cc=class extends P{},jF=class extends cc{},qF=class extends cc{},ls=class extends P{},HF=class extends ls{},QF=class extends ls{},XF=class extends ls{async _call(e){return new ie(await super._call(e))}},YF=class extends ls{},Mg=class extends P{},JF=class extends Mg{},xg=class extends P{},KF=class extends xg{},Tg=class extends Ve{constructor({char_logits:e,bpe_logits:t,wp_logits:r}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=r}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},kg=class extends P{},ZF=class extends kg{async _call(e){return new Tg(await super._call(e))}},Eg=class extends Ve{constructor({audio_codes:e}){super(),this.audio_codes=e}},Cg=class extends Ve{constructor({audio_values:e}){super(),this.audio_values=e}},Ta=class extends P{main_input_name="input_values";forward_params=["input_values"]},eI=class extends Ta{async encode(e){return new Eg(await ye(this.sessions.encoder_model,e))}async decode(e){return new Cg(await ye(this.sessions.decoder_model,e))}},Ag=class extends Ta{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},Sg=class extends Ta{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},uc=class extends P{},tI=class extends uc{},rI=class extends uc{},dc=class extends P{},nI=class extends dc{},sI=class extends dc{},hc=class extends P{},aI=class extends hc{},oI=class extends hc{},iI=class extends Yt{},fc=class extends P{},lI=class extends fc{},cI=class extends fc{},cs=class extends P{},uI=class extends cs{},dI=class extends cs{async _call(e){return new He(await super._call(e))}},hI=class extends cs{async _call(e){return new ie(await super._call(e))}},fI=class extends cs{async _call(e){return new nt(await super._call(e))}},_c=class extends P{},_I=class extends _c{},pI=class extends _c{},ka=class extends P{},mI=class extends ka{},gI=class extends ka{async _call(e){return new ie(await super._call(e))}},wI=class extends ka{},Ea=class extends P{},vI=class extends Ea{},yI=class extends Ea{async _call(e){return new ie(await super._call(e))}},bI=class extends Ea{},Ca=class extends P{},MI=class extends Ca{},xI=class extends Ca{async _call(e){return new ie(await super._call(e))}},TI=class extends Ca{},Aa=class extends P{},kI=class extends Aa{},EI=class extends Aa{async _call(e){return new ie(await super._call(e))}},CI=class extends Aa{},pc=class extends P{},AI=class extends pc{},SI=class extends pc{async _call(e){return new ie(await super._call(e))}},mc=class extends P{},PI=class extends mc{},FI=class extends mc{async _call(e){return new ie(await super._call(e))}},us=class extends P{},II=class extends us{},LI=class extends us{async _call(e){return new He(await super._call(e))}},OI=class extends us{async _call(e){return new ie(await super._call(e))}},NI=class extends us{async _call(e){return new je(await super._call(e))}},gc=class extends P{},DI=class extends gc{},BI=class extends gc{},wc=class extends P{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},zI=class extends wc{},RI=class extends wc{},Sn=class extends P{},$I=class extends Sn{},GI=class extends Sn{async _call(e){return new He(await super._call(e))}},VI=class extends Sn{async _call(e){return new ie(await super._call(e))}},UI=class extends Sn{async _call(e){return new je(await super._call(e))}},WI=class extends Sn{async _call(e){return new nt(await super._call(e))}},vc=class extends P{},jI=class extends vc{},qI=class extends vc{},yc=class extends P{},HI=class extends yc{},QI=class extends yc{},Pg=class extends P{},XI=class extends Pg{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){const t=this._generation_mode??"text";let r;if(t==="text"||!e.past_key_values){const i=this.sessions.prepare_inputs_embeds,l=et(e,i.inputNames);r=await ye(i,l)}else{const i=this.sessions.gen_img_embeds,l=et({image_ids:e.input_ids},i.inputNames);r=await ye(i,l)}const n={...e,...r},s=await ar(this,n),a=this.sessions[t==="text"?"lm_head":"gen_head"];if(!a)throw new Error(`Unable to find "${a}" generation head`);const o=await ye(a,et(s,a.inputNames));return{...r,...s,...o}}prepare_inputs_for_generation(e,t,r){const n=!!t.past_key_values;return ns(this,t,1n),r.guidance_scale!==null&&r.guidance_scale>1&&(n?t.input_ids=De([t.input_ids,t.input_ids],0):(t.input_ids=De([t.input_ids,si(t.input_ids,BigInt(r.pad_token_id))],0),t.attention_mask=De([t.attention_mask,si(t.attention_mask,0n)],0))),(n||!t.pixel_values)&&(t.pixel_values=ot([0,0,3,384,384],1)),n&&(t.images_seq_mask=new W("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new W("bool",new Array(0).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";const t=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[t,null]),s=this.sessions.image_decode,{decoded_image:a}=await ye(s,{generated_tokens:n}),o=a.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),i=[];for(const l of o){const u=Kn.fromTensor(l);i.push(u)}return i}},bc=class extends P{},YI=class extends bc{},JI=class extends bc{},Fg=class extends P{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){const[t,r]=e.dims,n=this.config.decoder.num_codebooks,s=r-n;let a=0;for(let l=0;l<e.size;++l){if(e.data[l]==this.config.decoder.pad_token_id)continue;const u=l%r,h=Math.floor(l/r)%n,f=u-h;f>0&&f<=s&&(e.data[a++]=e.data[l])}const o=Math.floor(t/n),i=a/(o*n);return new W(e.type,e.data.slice(0,a),[o,n,i])}prepare_inputs_for_generation(e,t,r){const n=BigInt(this.config.decoder.pad_token_id);let s=structuredClone(e);for(let a=0;a<s.length;++a)for(let o=0;o<s[a].length;++o)a%this.config.decoder.num_codebooks>=o&&(s[a][o]=n);return r.guidance_scale!==null&&r.guidance_scale>1&&(s=s.concat(s)),ia(this,s,t)}async generate(e){const t=await super.generate(e),r=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:n}=await ye(this.sessions.encodec_decode,{audio_codes:r});return n}},Mc=class extends P{},KI=class extends Mc{},ZI=class extends Mc{},xc=class extends P{},eL=class extends xc{},tL=class extends xc{},Pn=class extends P{},rL=class extends Pn{},nL=class extends Pn{async _call(e){return new He(await super._call(e))}},sL=class extends Pn{async _call(e){return new ie(await super._call(e))}},aL=class extends Pn{async _call(e){return new je(await super._call(e))}},oL=class extends Pn{async _call(e){return new nt(await super._call(e))}},Ig=class extends P{},iL=class extends Ig{},Tc=class extends P{},lL=class extends Tc{},cL=class extends Tc{},kc=class extends P{},uL=class extends kc{},dL=class extends kc{},Ec=class extends P{},hL=class extends Ec{},fL=class extends Ec{},Cc=class extends P{},_L=class extends Cc{},pL=class extends Cc{},Ac=class extends P{},mL=class extends Ac{},gL=class extends Ac{async _call(e){return new ie(await super._call(e))}},Sc=class extends P{},wL=class extends Sc{},vL=class extends Sc{},Pc=class extends P{},yL=class extends Pc{},bL=class extends Pc{},Fc=class extends P{},ML=class extends Fc{},xL=class extends Fc{},Ic=class extends P{},TL=class extends Ic{},kL=class extends Ic{},EL=class extends Yt{},Lg=class extends P{},CL=class extends Lg{async _call(e){return new kr(await super._call(e))}},Lc=class extends P{},AL=class extends Lc{},SL=class extends Lc{},Oc=class extends P{},PL=class extends Oc{},FL=class extends Oc{},Nc=class extends P{},IL=class extends Nc{},LL=class extends Nc{},Dc=class extends P{},OL=class extends Dc{},NL=class extends Dc{},Og=class extends P{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},Ng=class extends Og{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:r=null,image_sizes:n=null,position_ids:s=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:i=null,logits_processor:l=null,num_logits_to_keep:u=null,...h}){if(!a){let _;if(r&&e.dims[1]!==1){if(!n)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:_}=await ye(this.sessions.vision_encoder,{pixel_values:r,image_sizes:n}))}else{const g=this.config.normalized_config.hidden_size;_=new W("float32",[],[0,g])}({inputs_embeds:a}=await ye(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:_}))}return await ar(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,position_ids:s,generation_config:i,logits_processor:l,num_logits_to_keep:u},!1)}},Bc=class extends P{},DL=class extends Bc{},BL=class extends Bc{async _call(e){return new ie(await super._call(e))}},zc=class extends P{},zL=class extends zc{},RL=class extends zc{async _call(e){return new je(await super._call(e))}},Rc=class extends P{},$L=class extends Rc{},GL=class extends Rc{},$c=class extends P{},VL=class extends $c{},UL=class extends $c{},Gc=class extends P{},WL=class extends Gc{},jL=class extends Gc{},Vc=class extends P{},qL=class extends Vc{},HL=class extends Vc{},Uc=class extends P{},QL=class extends Uc{},XL=class extends Uc{},Wc=class extends $l{},Dg=class extends pg{},YL=class extends Wc{},JL=class extends Dg{},jc=class extends Wc{},Bg=class extends jc{},KL=class extends jc{},ZL=class extends Bg{},qc=class extends P{},eO=class extends qc{},tO=class extends qc{async _call(e){return new ie(await super._call(e))}},Hc=class extends P{},rO=class extends Hc{},nO=class extends Hc{async _call(e){return new zg(await super._call(e))}},zg=class extends as{},Fn=class extends P{},sO=class extends Fn{},aO=class extends Fn{async _call(e){return new He(await super._call(e))}},oO=class extends Fn{async _call(e){return new ie(await super._call(e))}},iO=class extends Fn{async _call(e){return new je(await super._call(e))}},lO=class extends Fn{async _call(e){return new nt(await super._call(e))}},In=class extends P{},cO=class extends In{},uO=class extends In{async _call(e){return new He(await super._call(e))}},dO=class extends In{async _call(e){return new ie(await super._call(e))}},hO=class extends In{async _call(e){return new je(await super._call(e))}},fO=class extends In{async _call(e){return new nt(await super._call(e))}},Qc=class extends P{},_O=class extends Qc{},pO=class extends Qc{async _call(e){return new Rg(await super._call(e))}},Rg=class extends as{},$g=class extends Ve{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},Gg=class extends P{},mO=class extends Gg{async get_image_embeddings({pixel_values:e}){return await Tr(this,{pixel_values:e})}async forward(e){!e.image_embeddings||!e.image_positional_embeddings?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_labels??=dt(e.input_points.dims.slice(0,-1));const 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 ye(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new $g(await super._call(e))}},Vg=class extends Ve{constructor({iou_scores:e,pred_masks:t,object_score_logits:r}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=r}},Ug=class extends P{},Xc=class extends Ug{async get_image_embeddings({pixel_values:e}){return await Tr(this,{pixel_values:e})}async forward(e){const{num_feature_levels:t}=this.config.vision_config;if(Array.from({length:t},(a,o)=>`image_embeddings.${o}`).some(a=>!e[a])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");const a=e.input_points.dims;e.input_labels??=dt(a.slice(0,-1)),e.input_boxes??=ot([a[0],0,4],0)}else if(e.input_boxes){const a=e.input_boxes.dims;e.input_labels=ot([a[0],a[1],0],-1n),e.input_points=ot([a[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");const n=this.sessions.prompt_encoder_mask_decoder,s=et(e,n.inputNames);return await ye(n,s)}async _call(e){return new Vg(await super._call(e))}},gO=class extends Xc{},wO=class extends Xc{},Sa=class extends P{},vO=class extends Sa{},yO=class extends Sa{},bO=class extends Sa{},Pa=class extends P{},MO=class extends Pa{},xO=class extends Pa{},TO=class extends Pa{},Yc=class extends P{},kO=class extends Yc{},Wg=class extends Yc{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"text_model"})}},EO=class extends Hr{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"vision_model"})}},Jc=class extends P{},CO=class extends Jc{},AO=class extends Jc{},SO=class extends vg{},Fa=class extends P{main_input_name="input_values";forward_params=["input_values"]},PO=class extends Fa{async encode(e){return await ye(this.sessions.encoder_model,e)}async decode(e){return await ye(this.sessions.decoder_model,e)}},jg=class extends Fa{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"encoder_model"})}},qg=class extends Fa{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??"decoder_model"})}},Kc=class extends P{},FO=class extends Kc{},IO=class extends Kc{},Ia=class extends P{},LO=class extends Ia{},OO=class extends Ia{},NO=class extends Ia{async generate_speech(e,t,{threshold:r=.5,minlenratio:n=0,maxlenratio:s=20,vocoder:a=null}={}){const o={input_ids:e},{encoder_outputs:i,encoder_attention_mask:l}=await Tr(this,o),u=i.dims[1]/this.config.reduction_factor,h=Math.floor(u*s),f=Math.floor(u*n),_=this.config.num_mel_bins;let g=[],w=null,v=null,M=0;for(;;){++M;const C=zm(!!v);let E;v?E=v.output_sequence_out:E=new W("float32",new Float32Array(_),[1,1,_]);let F={use_cache_branch:C,output_sequence:E,encoder_attention_mask:l,speaker_embeddings:t,encoder_hidden_states:i};tl(this,F,w),v=await ye(this.sessions.decoder_model_merged,F),w=ui(v,w);const{prob:z,spectrum:b}=v;if(g.push(b),M>=f&&(Array.from(z.data).filter(V=>V>=r).length>0||M>=h))break}const x=De(g),{waveform:k}=await ye(a.sessions.model,{spectrogram:x});return{spectrogram:x,waveform:k}}},DO=class extends P{main_input_name="spectrogram"},ds=class extends P{},BO=class extends ds{},zO=class extends ds{async _call(e){return new He(await super._call(e))}},RO=class extends ds{async _call(e){return new ie(await super._call(e))}},$O=class extends ds{async _call(e){return new nt(await super._call(e))}},Zc=class extends P{},GO=class extends Zc{},VO=class extends Zc{},eu=class extends P{},UO=class extends eu{},WO=class extends eu{},Hg=class extends P{},jO=class extends Hg{},Qg=class extends P{},Xg=class extends Qg{async generate_speech({input_ids:e,attention_mask:t,style:r,num_inference_steps:n=5,speed:s=1.05}){const{sampling_rate:a,chunk_compress_factor:o,base_chunk_size:i,latent_dim:l}=this.config,{last_hidden_state:u,durations:h}=await ye(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:r}),f=h.div(s).mul_(a),_=i*o,g=f.data,w=Int32Array.from(g,R=>Math.ceil(R/_)),v=Math.max(...w),M=e.dims[0],x=new BigInt64Array(M*v);for(let R=0;R<M;++R)x.fill(1n,R*v,R*v+w[R]);const k=new W("int64",x,[M,v]),C=l*o,E=C*v;let F=lk([M,C,v]);const z=F.data;for(let R=0;R<M;++R)if(w[R]!==v)for(let H=0;H<C;++H)z.fill(0,R*E+H*v+w[R],R*E+(H+1)*v);const b=ot([M],n);for(let R=0;R<n;++R){const H=ot([M],R);({denoised_latents:F}=await ye(this.sessions.latent_denoiser,{style:r,noisy_latents:F,latent_mask:k,encoder_outputs:u,attention_mask:t,timestep:H,num_inference_steps:b}))}const{waveform:V}=await ye(this.sessions.voice_decoder,{latents:F});return{waveform:V,durations:f}}},La=class extends P{},qO=class extends La{},HO=class extends La{async _call(e){return new ie(await super._call(e))}},QO=class extends La{},tu=class extends P{},XO=class extends tu{},YO=class extends tu{},ru=class extends P{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},JO=class extends ru{},KO=class extends ru{},nu=class extends P{},ZO=class extends nu{},eN=class extends nu{async _call(e){return new Yg(await super._call(e))}},Yg=class extends Tl{},Jg=class extends P{},tN=class extends Jg{},Oa=class extends P{},rN=class extends Oa{},nN=class extends Oa{async _call(e){return new kr(await super._call(e))}},sN=class extends Oa{async _call(e){return new ie(await super._call(e))}},hs=class extends P{},aN=class extends hs{},oN=class extends hs{async _call(e){return new kr(await super._call(e))}},iN=class extends hs{async _call(e){return new ie(await super._call(e))}},lN=class extends hs{async _call(e){return new je(await super._call(e))}},su=class extends P{},cN=class extends su{},uN=class extends su{},dN=class extends P{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]},au=class extends P{},hN=class extends au{},fN=class extends au{async _call(e){return new ie(await super._call(e))}},Kg=class extends P{},_N=class extends Kg{},ou=class extends P{},pN=class extends ou{},mN=class extends ou{async _call(e){return new ie(await super._call(e))}},Zg=class extends P{},gN=class extends Zg{async _call(e){return new Lm(await super._call(e))}},ew=class extends P{},wN=class extends ew{},tw=class extends Ve{constructor({waveform:e,spectrogram:t}){super(),this.waveform=e,this.spectrogram=t}},rw=class extends P{},vN=class extends rw{async _call(e){return new tw(await super._call(e))}},yN=class extends Yl{},e_=2,bN=1,jo=new WeakMap;function MN(e,t){const{text_config:r,audio_config:n}=e.config,s=e.sessions.audio_encoder,{num_mel_bins:a,hidden_size:o}=n,i=a+o,l=new Zi,u=pa(n),h={batch_size:1};let f="float32";for(const v of s.inputMetadata){if(v.name==="past_padding_cache"){f=v.type;continue}if(!u.has(v.name))continue;const M=Rm(v.shape,h),x=M.reduce((C,E)=>C*E,1),k=Jn[v.type];l[v.name]=new W(v.type,new k(x),M)}const _=Jn[f],g=new W(f,new _(i*e_),[1,i,e_]),w=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!w)throw new Error("input_features must be iterable or async iterable");return{encoder_session:s,enc_kv_cache:l,enc_padding_cache:g,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:w,text_hidden_size:r.hidden_size}}async function xN(e,t){const r=t.dims[2],n=Math.floor((bN+r-3)/2)+1,s=new W("int64",BigInt64Array.from({length:n},(h,f)=>BigInt(e.enc_past_seq_len+f)),[1,n]),a=e.enc_past_seq_len+n,o=dt([1,a]),{audio_embeds:i,present_padding_cache:l,...u}=await ye(e.encoder_session,{input_features:t,attention_mask:o,position_ids:s,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=l;for(const h in u)if(h.startsWith("present.")){const f=h.replace("present","past_key_values"),_=e.enc_kv_cache[f];_?.location==="gpu-buffer"&&_.dispose(),e.enc_kv_cache[f]=u[h]}return e.enc_past_seq_len=a,i}async function TN(e,t){for(;e.audio_embed_total_tokens<t&&!e.stream_exhausted;){const r=await e.chunks_iter.next();if(r.done){e.stream_exhausted=!0;break}const n=await xN(e,r.value);e.audio_embed_queue.push({data:n.data,tokens:n.dims[1]}),e.audio_embed_total_tokens+=n.dims[1]}}function kN(e,t,r){if(e.audio_embed_queue.length===0)return;const n=t.data;let s=0,a=r;for(;a>0&&e.audio_embed_queue.length>0;){const o=e.audio_embed_queue[0],i=o.tokens-e.audio_queue_offset,l=Math.min(a,i),u=e.audio_queue_offset*e.text_hidden_size;for(let h=0;h<l*e.text_hidden_size;++h)n[s*e.text_hidden_size+h]+=o.data[u+h];s+=l,a-=l,e.audio_queue_offset+=l,e.audio_queue_offset>=o.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=r-a}var EN=class extends ma{constructor(e){super(),this._s=e}_call(e){const t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},nw=class extends P{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},sw=class extends nw{async forward({input_ids:e,past_key_values:t,...r}){const n=e.dims[1],s=jo.get(this);s&&await TN(s,s.audio_consumed+n);const{inputs_embeds:a}=await ye(this.sessions.embed_tokens,{input_ids:e});s&&kN(s,a,n);const o={inputs_embeds:a,...r};tl(this,o,t);const i=this.sessions.decoder_model_merged,l=et(o,i.inputNames);return await ye(i,l)}async generate({input_features:e,stopping_criteria:t,...r}){if(!e)throw new Error("input_features (generator/iterable) must be provided");const n=MN(this,e);jo.set(this,n);const s=new Dm;s.push(new EN(n)),t&&s.extend(t);try{return await super.generate({...r,stopping_criteria:s})}finally{n.enc_kv_cache.dispose(),jo.delete(this)}}},Na=class extends P{},CN=class extends Na{},AN=class extends Na{async _call(e){return new kr(await super._call(e))}},SN=class extends Na{async _call(e){return new ie(await super._call(e))}},aw=class extends Ve{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},Ln=class extends P{},PN=class extends Ln{},FN=class extends Ln{async _call(e){return new kr(await super._call(e))}},IN=class extends Ln{async _call(e){return new ie(await super._call(e))}},LN=class extends Ln{async _call(e){return new aw(await super._call(e))}},ON=class extends Ln{async _call(e){return new je(await super._call(e))}},ow=class extends P{},NN=class extends ow{},DN=class extends Nm{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},iu=class extends P{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},BN=class extends iu{},iw=class extends iu{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,DN)}_retrieve_init_tokens(e){const t=[e.decoder_start_token_id];let r=e.language;const n=e.task;if(e.is_multilingual){r||(pe.warn("No language specified - defaulting to English (en)."),r="en");const a=`<|${nE(r)}|>`;t.push(e.lang_to_id[a]),t.push(e.task_to_id[n??"transcribe"])}else if(r||n)throw new Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&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&&(pe.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(s=>s!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:r=null,stopping_criteria:n=null,...s}){t=this._prepare_generation_config(t,s);const a=s.decoder_input_ids instanceof W?qi(s.decoder_input_ids):s.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(r??=new li,r.push(new DC(t,a))),t.begin_suppress_tokens&&(r??=new li,r.push(new Om(t.begin_suppress_tokens,a.length))),t.return_token_timestamps){if(!t.alignment_heads)throw new Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");t.task==="translate"&&pe.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&&!s.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:r,init_tokens:a,kwargs:s});const o=await super.generate({inputs:e,generation_config:t,logits_processor:r,decoder_input_ids:a,...s});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:r,init_tokens:n,kwargs:s}){const a=t.no_timestamps_token_id+1,o=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,i=t.return_token_timestamps,l=e,u=l.dims[2],h=2,f=this.config.max_source_positions,_=h*f;let g=0;const w=[],v=[];for(;g<u;){const x=Math.min(g+_,u),k=l.slice(null,null,[g,x]);let C;const E=k.dims[2];if(E<_){const Q=l.dims[1],ce=new Float32Array(Q*_),Z=k.data;for(let ne=0;ne<Q;++ne)ce.set(Z.subarray(ne*E,(ne+1)*E),ne*_);C=new W("float32",ce,[1,Q,_])}else C=k;if(r)for(const Q of r)"begin_index"in Q&&(Q.begin_index=n.length);const F=await super.generate({inputs:C,generation_config:t,logits_processor:r,decoder_input_ids:n,...s}),b=(i?F.sequences:F)[0].tolist().map(Number).slice(n.length);let V;if(i){F.token_timestamps=this._extract_token_timestamps(F,t.alignment_heads,Math.floor((x-g)/h),.02,n.length);const Q=g/h*.02;V=F.token_timestamps[0].tolist().slice(n.length).map(ce=>ce+Q)}if(b.length>0&&b.at(-1)===o&&b.pop(),b.length===0)break;const R=b.map(Q=>Q>=a),H=b.length>=2&&R[b.length-1]&&!R[b.length-2],J=[];for(let Q=0;Q<b.length-1;++Q)R[Q]&&R[Q+1]&&J.push(Q+1);let X,D=b.length;if(J.length>0)if(H)X=x-g;else{const Q=J.at(-1);X=(b[Q-1]-a)*h,D=Q}else X=x-g;const I=Math.floor(g/h),G=a+1500;for(let Q=0;Q<D;++Q)b[Q]>=a&&(b[Q]=Math.min(b[Q]+I,G));w.push(...b.slice(0,D)),V&&v.push(...V.slice(0,D)),g+=X}w.push(o);const M=[...n,...w];if(i){const x=new W("int64",M.map(BigInt),[1,M.length]),k=[...new Array(n.length).fill(0),...v,0],C=new W("float32",new Float32Array(k),[1,k.length]);return{sequences:x,token_timestamps:C}}return new W("int64",M.map(BigInt),[1,M.length])}_extract_token_timestamps(e,t,r=null,n=.02,s=0){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");r==null&&pe.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&&(pe.warn("Model config has no `median_filter_width`, using default value of 7."),a=7);const o=e.cross_attentions,i=Array.from({length:this.config.decoder_layers},(M,x)=>De(o.map(k=>k[x]),2)),l=sr(t.map(([M,x])=>{if(M>=i.length)throw new Error(`Layer index ${M} is out of bounds for cross attentions (length ${i.length}).`);return r?i[M].slice(null,x,null,[0,r]):i[M].slice(null,x)})).permute(1,0,2,3),[u,h]=ik(l,-2,0,!0),f=l.clone();for(let M=0;M<f.dims[0];++M){const x=f[M];for(let k=0;k<x.dims[0];++k){const C=x[k],E=u[M][k][0].data,F=h[M][k][0].data;for(let z=0;z<C.dims[0];++z){let b=C[z].data;for(let V=0;V<b.length;++V)b[V]=(b[V]-F[V])/E[V];b.set(WT(b,a))}}}const _=s>0?f.slice(null,null,[s,f.dims[2]],null):f,g=[Vi(_,1)],w=e.sequences.dims,v=new W("float32",new Float32Array(w[0]*w[1]),w);for(let M=0;M<w[0];++M){const x=g[M].neg().squeeze_(0),[k,C]=qT(x.tolist()),E=Array.from({length:k.length-1},(V,R)=>k[R+1]-k[R]),F=qt([1],E).map(V=>!!V),z=[];for(let V=0;V<F.length;++V)F[V]&&z.push(C[V]*n);const b=new Array(s).fill(0);b.push(...z),z.length>0&&b.push(z.at(-1)),v[M].data.set(b)}return v}},zN=class extends iw{},On=class extends P{},RN=class extends On{},$N=class extends On{async _call(e){return new He(await super._call(e))}},GN=class extends On{async _call(e){return new ie(await super._call(e))}},VN=class extends On{async _call(e){return new je(await super._call(e))}},UN=class extends On{async _call(e){return new nt(await super._call(e))}},Nn=class extends P{},WN=class extends Nn{},jN=class extends Nn{async _call(e){return new He(await super._call(e))}},qN=class extends Nn{async _call(e){return new ie(await super._call(e))}},HN=class extends Nn{async _call(e){return new je(await super._call(e))}},QN=class extends Nn{async _call(e){return new nt(await super._call(e))}},lu=class extends P{},XN=class extends lu{},YN=class extends lu{async _call(e){return new lw(await super._call(e))}},lw=class extends Ve{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},cu=class extends P{},JN=class extends cu{},KN=class extends cu{},uu=class extends P{},ZN=class extends uu{},e3=class extends uu{},t3=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"]]),r3=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"]]),n3=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),s3=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"],["deepseek_v4","DeepseekV4Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["nemotron_h","NemotronHModel"],["solar_open","SolarOpenModel"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"],["zaya","ZayaModel"],["hrm_text","HrmTextModel"]]),cw=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"],["cohere_asr","CohereAsrForConditionalGeneration"]]),uw=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),dw=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),hw=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"]]),fw=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"]]),_w=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),pw=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"],["deepseek_v4","DeepseekV4ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["nemotron_h","NemotronHForCausalLM"],["trocr","TrOCRForCausalLM"],["solar_open","SolarOpenForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["zaya","ZayaForCausalLM"],["hrm_text","HrmTextForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),a3=new Map([["multi_modality","MultiModalityCausalLM"]]),mw=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"]]),gw=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"]]),ww=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),vw=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"]]),yw=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),o3=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),bw=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"]]),Mw=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),xw=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),hn=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),Tw=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),kw=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),Ew=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),Cw=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),Aw=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),Sw=new Map([["wavlm","WavLMForXVector"]]),Pw=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),Fw=new Map([["vitmatte","VitMatteForImageMatting"]]),i3=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),Iw=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),Lw=new Map([["chmv2","CHMv2ForDepthEstimation"],["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),Ow=new Map([["sapiens","SapiensForNormalEstimation"]]),Nw=new Map([["vitpose","VitPoseForPoseEstimation"]]),Dw=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),Bw=[[t3,j.EncoderOnly],[r3,j.EncoderDecoder],[s3,j.DecoderOnlyWithoutHead],[n3,j.AutoEncoder],[hw,j.EncoderOnly],[fw,j.EncoderOnly],[_w,j.Seq2Seq],[cw,j.Seq2Seq],[pw,j.DecoderOnly],[a3,j.MultiModality],[mw,j.EncoderOnly],[gw,j.EncoderOnly],[ww,j.Vision2Seq],[vw,j.ImageTextToText],[yw,j.AudioTextToText],[bw,j.EncoderOnly],[hn,j.EncoderOnly],[kw,j.EncoderOnly],[Tw,j.EncoderOnly],[Fw,j.EncoderOnly],[i3,j.EncoderOnly],[Iw,j.EncoderOnly],[Lw,j.EncoderOnly],[Ow,j.EncoderOnly],[Nw,j.EncoderOnly],[Mw,j.EncoderOnly],[xw,j.EncoderOnly],[Ew,j.MaskGeneration],[Cw,j.EncoderOnly],[Aw,j.EncoderOnly],[uw,j.Seq2Seq],[dw,j.EncoderOnly],[Sw,j.EncoderOnly],[Pw,j.EncoderOnly],[Dw,j.EncoderOnly]];for(const[e,t]of Bw)for(const r of e.values()){nr.set(r,t);const n=nl[r];mn.set(n,r),el.set(r,n)}var l3=[["MusicgenForConditionalGeneration",Fg,j.Musicgen],["Phi3VForCausalLM",Ng,j.Phi3V],["CLIPTextModelWithProjection",Ym,j.EncoderOnly],["SiglipTextModel",Wg,j.EncoderOnly],["JinaCLIPTextModel",yg,j.EncoderOnly],["ClapTextModelWithProjection",Qm,j.EncoderOnly],["ClapAudioModelWithProjection",Xm,j.EncoderOnly],["DacEncoderModel",Zm,j.EncoderOnly],["DacDecoderModel",eg,j.EncoderOnly],["MimiEncoderModel",Ag,j.EncoderOnly],["MimiDecoderModel",Sg,j.EncoderOnly],["SnacEncoderModel",jg,j.EncoderOnly],["SnacDecoderModel",qg,j.EncoderOnly],["Gemma3nForConditionalGeneration",Ma,j.ImageAudioTextToText],["Gemma4ForConditionalGeneration",Dl,j.ImageAudioTextToText],["SupertonicForConditionalGeneration",Xg,j.Supertonic],["ChatterboxModel",jm,j.Chatterbox],["VoxtralRealtimeForConditionalGeneration",sw,j.VoxtralRealtime]];for(const[e,t,r]of l3)nr.set(e,r),mn.set(t,e),el.set(e,t);var zw=new Map([["modnet",hn],["birefnet",hn],["isnet",hn],["ben",hn]]);for(const[e,t]of zw.entries())t.set(e,"PreTrainedModel"),nr.set(e,j.EncoderOnly),el.set(e,P);var c3=new Set(zw.keys());nr.set("PreTrainedModel",j.EncoderOnly);mn.set(P,"PreTrainedModel");var Ce={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:hw,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:fw,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:uw,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:dw,MODEL_FOR_MASKED_LM_MAPPING_NAMES:mw,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:gw,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:bw,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:hn,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:Tw,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:kw,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:Mw,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:xw,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:Ew,MODEL_FOR_CTC_MAPPING_NAMES:Cw,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:Aw,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:Sw,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:Pw,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:o3,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:Fw,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:Iw,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:Lw,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:Ow,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:Nw,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:Dw,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:vw,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:yw,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:_w,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:cw,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:pw,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:ww};eA(Ce);var Ae=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(const 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:r=null,cache_dir:n=null,local_files_only:s=!1,revision:a="main",model_file_name:o=null,subfolder:i="onnx",device:l=null,dtype:u=null,use_external_data_format:h=null,session_options:f={}}={}){const _={progress_callback:t,config:r,cache_dir:n,local_files_only:s,revision:a,model_file_name:o,subfolder:i,device:l,dtype:u,use_external_data_format:h,session_options:f};if(_.config=await oa.from_pretrained(e,_),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);const{model_type:g}=_.config;for(const w of this.MODEL_CLASS_MAPPINGS){let v=w.get(g);if(!v){for(const M of w.values())if(M[0]===g){v=M;break}if(!v)continue}return await nl[v].from_pretrained(e,_)}if(this.BASE_IF_FAIL)return c3.has(g)||pe.warn(`Unknown model class "${g}", attempting to construct from base class.`),await P.from_pretrained(e,_);throw Error(`Unsupported model type: ${g}`)}},d3=class extends Ae{static MODEL_CLASS_MAPPINGS=Bw.map(e=>e[0]);static BASE_IF_FAIL=!0};(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_MASKED_LM_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_CTC_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]});(class extends Ae{static MODEL_CLASS_MAPPINGS=[Ce.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]});_e.IS_PROCESS_AVAILABLE;export{bE as ASTFeatureExtractor,wA as ASTForAudioClassification,gA as ASTModel,il as ASTPreTrainedModel,_A as AfmoeForCausalLM,fA as AfmoeModel,al as AfmoePreTrainedModel,uA as AlbertForMaskedLM,cA as AlbertForQuestionAnswering,lA as AlbertForSequenceClassification,iA as AlbertModel,ss as AlbertPreTrainedModel,_k as AlbertTokenizer,hA as ApertusForCausalLM,dA as ApertusModel,sl as ApertusPreTrainedModel,mA as ArceeForCausalLM,pA as ArceeModel,ol as ArceePreTrainedModel,oa as AutoConfig,Et as AutoFeatureExtractor,lt as AutoImageProcessor,d3 as AutoModel,Se as AutoTokenizer,yA as BartForConditionalGeneration,bA as BartForSequenceClassification,vA as BartModel,wa as BartPretrainedModel,pk as BartTokenizer,SC as BaseModelOutput,UE as BeitFeatureExtractor,xA as BeitForImageClassification,MA as BeitModel,ll as BeitPreTrainedModel,kA as BertForMaskedLM,AA as BertForQuestionAnswering,EA as BertForSequenceClassification,CA as BertForTokenClassification,TA as BertModel,Mn as BertPreTrainedModel,mk as BertTokenizer,WE as BitImageProcessor,PA as BlenderbotForConditionalGeneration,SA as BlenderbotModel,cl as BlenderbotPreTrainedModel,IA as BlenderbotSmallForConditionalGeneration,FA as BlenderbotSmallModel,ul as BlenderbotSmallPreTrainedModel,gk as BlenderbotSmallTokenizer,wk as BlenderbotTokenizer,OA as BloomForCausalLM,LA as BloomModel,dl as BloomPreTrainedModel,vk as BloomTokenizer,VA as CHMv2ForDepthEstimation,qE as CHMv2ImageProcessor,Hm as CHMv2PreTrainedModel,HE as CLIPFeatureExtractor,dm as CLIPImageProcessor,WA as CLIPModel,Hr as CLIPPreTrainedModel,XA as CLIPSegForImageSegmentation,QA as CLIPSegModel,hl as CLIPSegPreTrainedModel,jA as CLIPTextModel,Ym as CLIPTextModelWithProjection,bk as CLIPTokenizer,qA as CLIPVisionModel,HA as CLIPVisionModelWithProjection,DA as CamembertForMaskedLM,RA as CamembertForQuestionAnswering,BA as CamembertForSequenceClassification,zA as CamembertForTokenClassification,NA as CamembertModel,xn as CamembertPreTrainedModel,yk as CamembertTokenizer,kr as CausalLMOutput,PC as CausalLMOutputWithPast,ME as ChatterboxFeatureExtractor,jm as ChatterboxModel,Wm as ChatterboxPreTrainedModel,NE as ChatterboxProcessor,jE as ChineseCLIPFeatureExtractor,GA as ChineseCLIPModel,qm as ChineseCLIPPreTrainedModel,Xm as ClapAudioModelWithProjection,xE as ClapFeatureExtractor,UA as ClapModel,va as ClapPreTrainedModel,Qm as ClapTextModelWithProjection,VC as ClassifierFreeGuidanceLogitsProcessor,JA as CodeGenForCausalLM,YA as CodeGenModel,fl as CodeGenPreTrainedModel,xk as CodeGenTokenizer,Mk as CodeLlamaTokenizer,tS as Cohere2ForCausalLM,eS as Cohere2Model,pl as Cohere2PreTrainedModel,kE as CohereAsrFeatureExtractor,nS as CohereAsrForConditionalGeneration,rS as CohereAsrModel,ml as CohereAsrPreTrainedModel,BE as CohereAsrProcessor,kk as CohereAsrTokenizer,ZA as CohereForCausalLM,KA as CohereModel,_l as CoherePreTrainedModel,Tk as CohereTokenizer,aS as ConvBertForMaskedLM,lS as ConvBertForQuestionAnswering,oS as ConvBertForSequenceClassification,iS as ConvBertForTokenClassification,sS as ConvBertModel,Tn as ConvBertPreTrainedModel,Ek as ConvBertTokenizer,QE as ConvNextFeatureExtractor,uS as ConvNextForImageClassification,hm as ConvNextImageProcessor,cS as ConvNextModel,gl as ConvNextPreTrainedModel,hS as ConvNextV2ForImageClassification,dS as ConvNextV2Model,wl as ConvNextV2PreTrainedModel,mS as DFineForObjectDetection,pS as DFineModel,yl as DFinePreTrainedModel,WS as DINOv3ConvNextModel,ag as DINOv3ConvNextPreTrainedModel,JE as DINOv3ViTImageProcessor,jS as DINOv3ViTModel,og as DINOv3ViTPreTrainedModel,ZE as DPTFeatureExtractor,ZS as DPTForDepthEstimation,pm as DPTImageProcessor,KS as DPTModel,Cl as DPTPreTrainedModel,eg as DacDecoderModel,Km as DacDecoderOutput,Zm as DacEncoderModel,Jm as DacEncoderOutput,tm as DacFeatureExtractor,gS as DacModel,ya as DacPreTrainedModel,vS as DebertaForMaskedLM,MS as DebertaForQuestionAnswering,yS as DebertaForSequenceClassification,bS as DebertaForTokenClassification,wS as DebertaModel,kn as DebertaPreTrainedModel,Ak as DebertaTokenizer,AS as DebertaV2ForMaskedLM,FS as DebertaV2ForQuestionAnswering,SS as DebertaV2ForSequenceClassification,PS as DebertaV2ForTokenClassification,CS as DebertaV2Model,En as DebertaV2PreTrainedModel,Ck as DebertaV2Tokenizer,IS as DecisionTransformerModel,tg as DecisionTransformerPreTrainedModel,TS as DeepseekV3ForCausalLM,xS as DeepseekV3Model,bl as DeepseekV3PreTrainedModel,ES as DeepseekV4ForCausalLM,kS as DeepseekV4Model,Ml as DeepseekV4PreTrainedModel,XE as DeiTFeatureExtractor,OS as DeiTForImageClassification,fm as DeiTImageProcessor,LS as DeiTModel,xl as DeiTPreTrainedModel,NS as DepthAnythingForDepthEstimation,rg as DepthAnythingPreTrainedModel,DS as DepthProForDepthEstimation,ng as DepthProPreTrainedModel,YE as DetrFeatureExtractor,zS as DetrForObjectDetection,RS as DetrForSegmentation,_m as DetrImageProcessor,BS as DetrModel,Tl as DetrObjectDetectionOutput,ba as DetrPreTrainedModel,sg as DetrSegmentationOutput,GS as Dinov2ForImageClassification,$S as Dinov2Model,kl as Dinov2PreTrainedModel,US as Dinov2WithRegistersForImageClassification,VS as Dinov2WithRegistersModel,El as Dinov2WithRegistersPreTrainedModel,YS as DistilBertForMaskedLM,XS as DistilBertForQuestionAnswering,HS as DistilBertForSequenceClassification,QS as DistilBertForTokenClassification,qS as DistilBertModel,Cn as DistilBertPreTrainedModel,Sk as DistilBertTokenizer,KE as DonutFeatureExtractor,Xi as DonutImageProcessor,JS as DonutSwinModel,ig as DonutSwinPreTrainedModel,Zi as DynamicCache,gO as EdgeTamModel,tP as EfficientNetForImageClassification,e2 as EfficientNetImageProcessor,eP as EfficientNetModel,Al as EfficientNetPreTrainedModel,nP as ElectraForMaskedLM,oP as ElectraForQuestionAnswering,sP as ElectraForSequenceClassification,aP as ElectraForTokenClassification,rP as ElectraModel,An as ElectraPreTrainedModel,Pk as ElectraTokenizer,Zp as EncodecFeatureExtractor,jC as EosTokenCriteria,lP as Ernie4_5ForCausalLM,iP as Ernie4_5Model,Sl as Ernie4_5PretrainedModel,uP as EsmForMaskedLM,dP as EsmForSequenceClassification,hP as EsmForTokenClassification,cP as EsmModel,os as EsmPreTrainedModel,Fk as EsmTokenizer,_P as EuroBertForMaskedLM,pP as EuroBertForSequenceClassification,mP as EuroBertForTokenClassification,fP as EuroBertModel,is as EuroBertPreTrainedModel,wP as ExaoneForCausalLM,gP as ExaoneModel,Pl as ExaonePreTrainedModel,yP as FalconForCausalLM,MP as FalconH1ForCausalLM,bP as FalconH1Model,Il as FalconH1PreTrainedModel,vP as FalconModel,Fl as FalconPreTrainedModel,Ik as FalconTokenizer,TP as FastViTForImageClassification,xP as FastViTModel,Ll as FastViTPreTrainedModel,it as FeatureExtractor,kP as Florence2ForConditionalGeneration,lg as Florence2PreTrainedModel,z2 as Florence2Processor,LC as ForcedBOSTokenLogitsProcessor,OC as ForcedEOSTokenLogitsProcessor,a2 as GLPNFeatureExtractor,VP as GLPNForDepthEstimation,GP as GLPNModel,Gl as GLPNPreTrainedModel,KP as GPT2LMHeadModel,JP as GPT2Model,ql as GPT2PreTrainedModel,Nk as GPT2Tokenizer,WP as GPTBigCodeForCausalLM,UP as GPTBigCodeModel,Vl as GPTBigCodePreTrainedModel,eF as GPTJForCausalLM,ZP as GPTJModel,Hl as GPTJPreTrainedModel,qP as GPTNeoForCausalLM,jP as GPTNeoModel,Ul as GPTNeoPreTrainedModel,QP as GPTNeoXForCausalLM,HP as GPTNeoXModel,Wl as GPTNeoXPreTrainedModel,Ok as GPTNeoXTokenizer,SP as Gemma2ForCausalLM,AP as Gemma2Model,Nl as Gemma2PreTrainedModel,LP as Gemma3ForCausalLM,dg as Gemma3ForConditionalGeneration,t2 as Gemma3ImageProcessor,IP as Gemma3Model,ug as Gemma3PreTrainedModel,R2 as Gemma3Processor,rm as Gemma3nAudioFeatureExtractor,OP as Gemma3nForCausalLM,Ma as Gemma3nForConditionalGeneration,hg as Gemma3nPreTrainedModel,$2 as Gemma3nProcessor,nm as Gemma4AudioFeatureExtractor,NP as Gemma4ForCausalLM,Dl as Gemma4ForConditionalGeneration,mm as Gemma4ImageProcessor,G2 as Gemma4Processor,CP as GemmaForCausalLM,EP as GemmaModel,Ol as GemmaPreTrainedModel,Lk as GemmaTokenizer,Nm as GenerationConfig,s2 as Glm46VImageProcessor,V2 as Glm46VProcessor,BP as GlmForCausalLM,DP as GlmModel,RP as GlmMoeDsaForCausalLM,zP as GlmMoeDsaModel,zl as GlmMoeDsaPreTrainedModel,$P as GlmOcrForConditionalGeneration,Bl as GlmPreTrainedModel,YP as GptOssForCausalLM,XP as GptOssModel,jl as GptOssPreTrainedModel,rF as GraniteForCausalLM,tF as GraniteModel,sF as GraniteMoeHybridForCausalLM,nF as GraniteMoeHybridModel,Xl as GraniteMoeHybridPreTrainedModel,Ql as GranitePreTrainedModel,EE as GraniteSpeechFeatureExtractor,aF as GraniteSpeechForConditionalGeneration,U2 as GraniteSpeechProcessor,oF as GroundingDinoForObjectDetection,o2 as GroundingDinoImageProcessor,gg as GroundingDinoPreTrainedModel,j2 as GroundingDinoProcessor,iF as GroupViTModel,wg as GroupViTPreTrainedModel,cF as HeliumForCausalLM,lF as HeliumModel,Jl as HeliumPreTrainedModel,Dk as HerbertTokenizer,dF as HieraForImageClassification,uF as HieraModel,Kl as HieraPreTrainedModel,fF as HrmTextForCausalLM,hF as HrmTextModel,Zl as HrmTextPreTrainedModel,yF as HubertForCTC,bF as HubertForSequenceClassification,vF as HubertModel,wF as HubertPreTrainedModel,xF as HunYuanDenseV1ForCausalLM,MF as HunYuanDenseV1Model,ec as HunYuanDenseV1PreTrainedModel,kF as IJepaForImageClassification,TF as IJepaModel,tc as IJepaPreTrainedModel,vg as Idefics3ForConditionalGeneration,jf as Idefics3ImageProcessor,Hf as Idefics3Processor,de as ImageFeatureExtractor,Lm as ImageMattingOutput,de as ImageProcessor,CF as JAISLMHeadModel,EF as JAISModel,rc as JAISPreTrainedModel,l2 as JinaCLIPImageProcessor,AF as JinaCLIPModel,xa as JinaCLIPPreTrainedModel,Y2 as JinaCLIPProcessor,yg as JinaCLIPTextModel,SF as JinaCLIPVisionModel,FF as Lfm2ForCausalLM,PF as Lfm2Model,OF as Lfm2MoeForCausalLM,LF as Lfm2MoeModel,sc as Lfm2MoePreTrainedModel,nc as Lfm2PreTrainedModel,NF as Lfm2VlForConditionalGeneration,f2 as Lfm2VlImageProcessor,J2 as Lfm2VlProcessor,IF as LightOnOcrForConditionalGeneration,zN as LiteWhisperForConditionalGeneration,zF as Llama4ForCausalLM,bg as Llama4PreTrainedModel,BF as LlamaForCausalLM,DF as LlamaModel,ac as LlamaPreTrainedModel,Bk as LlamaTokenizer,Yt as LlavaForConditionalGeneration,Yt as LlavaOnevisionForConditionalGeneration,_2 as LlavaOnevisionImageProcessor,cg as LlavaPreTrainedModel,K2 as LlavaProcessor,FP as LlavaQwen2ForCausalLM,Ft as LogLevel,Bt as LogitsProcessor,li as LogitsProcessorList,IC as LogitsWarper,$F as LongT5ForConditionalGeneration,RF as LongT5Model,oc as LongT5PreTrainedModel,VF as M2M100ForConditionalGeneration,GF as M2M100Model,ic as M2M100PreTrainedModel,zk as M2M100Tokenizer,$k as MBart50Tokenizer,YF as MBartForCausalLM,QF as MBartForConditionalGeneration,XF as MBartForSequenceClassification,HF as MBartModel,ls as MBartPreTrainedModel,Wp as MBartTokenizer,GI as MPNetForMaskedLM,WI as MPNetForQuestionAnswering,VI as MPNetForSequenceClassification,UI as MPNetForTokenClassification,$I as MPNetModel,Sn as MPNetPreTrainedModel,Uk as MPNetTokenizer,QI as MT5ForConditionalGeneration,HI as MT5Model,yc as MT5PreTrainedModel,WF as MarianMTModel,UF as MarianModel,lc as MarianPreTrainedModel,Rk as MarianTokenizer,m2 as Mask2FormerImageProcessor,p2 as MaskFormerFeatureExtractor,qF as MaskFormerForInstanceSegmentation,Yi as MaskFormerImageProcessor,jF as MaskFormerModel,cc as MaskFormerPreTrainedModel,He as MaskedLMOutput,WC as MaxLengthCriteria,JF as Metric3DForDepthEstimation,Mg as Metric3DPreTrainedModel,KF as Metric3Dv2ForDepthEstimation,xg as Metric3Dv2PreTrainedModel,ZF as MgpstrForSceneTextRecognition,Tg as MgpstrModelOutput,kg as MgpstrPreTrainedModel,Z2 as MgpstrProcessor,Gk as MgpstrTokenizer,Sg as MimiDecoderModel,Cg as MimiDecoderOutput,Ag as MimiEncoderModel,Eg as MimiEncoderOutput,eI as MimiModel,Ta as MimiPreTrainedModel,RC as MinLengthLogitsProcessor,$C as MinNewTokensLengthLogitsProcessor,sI as Ministral3ForCausalLM,nI as Ministral3Model,dc as Ministral3PreTrainedModel,rI as MinistralForCausalLM,tI as MinistralModel,uc as MinistralPreTrainedModel,iI as Mistral3ForConditionalGeneration,cI as Mistral4ForCausalLM,lI as Mistral4Model,fc as Mistral4PreTrainedModel,oI as MistralForCausalLM,aI as MistralModel,hc as MistralPreTrainedModel,dI as MobileBertForMaskedLM,fI as MobileBertForQuestionAnswering,hI as MobileBertForSequenceClassification,uI as MobileBertModel,cs as MobileBertPreTrainedModel,Vk as MobileBertTokenizer,pI as MobileLLMForCausalLM,_I as MobileLLMModel,_c as MobileLLMPreTrainedModel,g2 as MobileNetV1FeatureExtractor,gI as MobileNetV1ForImageClassification,wI as MobileNetV1ForSemanticSegmentation,wm as MobileNetV1ImageProcessor,mI as MobileNetV1Model,ka as MobileNetV1PreTrainedModel,w2 as MobileNetV2FeatureExtractor,yI as MobileNetV2ForImageClassification,bI as MobileNetV2ForSemanticSegmentation,vm as MobileNetV2ImageProcessor,vI as MobileNetV2Model,Ea as MobileNetV2PreTrainedModel,v2 as MobileNetV3FeatureExtractor,xI as MobileNetV3ForImageClassification,TI as MobileNetV3ForSemanticSegmentation,ym as MobileNetV3ImageProcessor,MI as MobileNetV3Model,Ca as MobileNetV3PreTrainedModel,y2 as MobileNetV4FeatureExtractor,EI as MobileNetV4ForImageClassification,CI as MobileNetV4ForSemanticSegmentation,bm as MobileNetV4ImageProcessor,kI as MobileNetV4Model,Aa as MobileNetV4PreTrainedModel,b2 as MobileViTFeatureExtractor,SI as MobileViTForImageClassification,Mm as MobileViTImageProcessor,AI as MobileViTModel,pc as MobileViTPreTrainedModel,FI as MobileViTV2ForImageClassification,PI as MobileViTV2Model,mc as MobileViTV2PreTrainedModel,Zo as ModelFileNotFoundError,Ve as ModelOutput,BI as ModernBertDecoderForCausalLM,DI as ModernBertDecoderModel,gc as ModernBertDecoderPreTrainedModel,LI as ModernBertForMaskedLM,OI as ModernBertForSequenceClassification,NI as ModernBertForTokenClassification,II as ModernBertModel,us as ModernBertPreTrainedModel,PP as Moondream1ForConditionalGeneration,CE as MoonshineFeatureExtractor,RI as MoonshineForConditionalGeneration,zI as MoonshineModel,wc as MoonshinePreTrainedModel,eC as MoonshineProcessor,qI as MptForCausalLM,jI as MptModel,vc as MptPreTrainedModel,XI as MultiModalityCausalLM,Pg as MultiModalityPreTrainedModel,JI as MusicgenForCausalLM,Fg as MusicgenForConditionalGeneration,YI as MusicgenModel,bc as MusicgenPreTrainedModel,ZI as NanoChatForCausalLM,KI as NanoChatModel,Mc as NanoChatPreTrainedModel,tL as NemotronHForCausalLM,eL as NemotronHModel,xc as NemotronHPreTrainedModel,nL as NeoBertForMaskedLM,oL as NeoBertForQuestionAnswering,sL as NeoBertForSequenceClassification,aL as NeoBertForTokenClassification,rL as NeoBertModel,Pn as NeoBertPreTrainedModel,Wk as NllbTokenizer,GC as NoBadWordsLogitsProcessor,BC as NoRepeatNGramLogitsProcessor,iL as NomicBertModel,Ig as NomicBertPreTrainedModel,M2 as NougatImageProcessor,jk as NougatTokenizer,bL as OPTForCausalLM,yL as OPTModel,Pc as OPTPreTrainedModel,dL as Olmo2ForCausalLM,uL as Olmo2Model,kc as Olmo2PreTrainedModel,fL as Olmo3ForCausalLM,hL as Olmo3Model,Ec as Olmo3PreTrainedModel,cL as OlmoForCausalLM,pL as OlmoHybridForCausalLM,_L as OlmoHybridModel,Cc as OlmoHybridPreTrainedModel,lL as OlmoModel,Tc as OlmoPreTrainedModel,gL as OpenAIPrivacyFilterForTokenClassification,mL as OpenAIPrivacyFilterModel,Ac as OpenAIPrivacyFilterPreTrainedModel,vL as OpenELMForCausalLM,wL as OpenELMModel,Sc as OpenELMPreTrainedModel,x2 as OwlViTFeatureExtractor,kL as OwlViTForObjectDetection,Ji as OwlViTImageProcessor,TL as OwlViTModel,Ic as OwlViTPreTrainedModel,tC as OwlViTProcessor,xL as Owlv2ForObjectDetection,T2 as Owlv2ImageProcessor,ML as Owlv2Model,Fc as Owlv2PreTrainedModel,EL as PaliGemmaForConditionalGeneration,nC as PaliGemmaProcessor,em as ParakeetFeatureExtractor,CL as ParakeetForCTC,Lg as ParakeetPreTrainedModel,SL as PatchTSMixerForPrediction,AL as PatchTSMixerModel,Lc as PatchTSMixerPreTrainedModel,FL as PatchTSTForPrediction,PL as PatchTSTModel,Oc as PatchTSTPreTrainedModel,NL as Phi3ForCausalLM,OL as Phi3Model,Dc as Phi3PreTrainedModel,Ng as Phi3VForCausalLM,E2 as Phi3VImageProcessor,Og as Phi3VPreTrainedModel,aC as Phi3VProcessor,LL as PhiForCausalLM,IL as PhiModel,Nc as PhiPreTrainedModel,C2 as PixtralImageProcessor,oC as PixtralProcessor,P as PreTrainedModel,ue as PreTrainedTokenizer,oi as PretrainedConfig,Pe as Processor,BL as PvtForImageClassification,A2 as PvtImageProcessor,DL as PvtModel,Bc as PvtPreTrainedModel,sm as PyAnnoteFeatureExtractor,RL as PyAnnoteForAudioFrameClassification,zL as PyAnnoteModel,zc as PyAnnotePreTrainedModel,iC as PyAnnoteProcessor,nt as QuestionAnsweringModelOutput,GL as Qwen2ForCausalLM,$L as Qwen2Model,UL as Qwen2MoeForCausalLM,VL as Qwen2MoeModel,$c as Qwen2MoePreTrainedModel,Rc as Qwen2PreTrainedModel,qk as Qwen2Tokenizer,_g as Qwen2VLForCausalLM,Rl as Qwen2VLForConditionalGeneration,gm as Qwen2VLImageProcessor,fg as Qwen2VLPreTrainedModel,Ki as Qwen2VLProcessor,pg as Qwen2_5_VLForCausalLM,$l as Qwen2_5_VLForConditionalGeneration,Cm as Qwen2_5_VLProcessor,jL as Qwen3ForCausalLM,WL as Qwen3Model,HL as Qwen3MoeForCausalLM,qL as Qwen3MoeModel,Vc as Qwen3MoePreTrainedModel,XL as Qwen3NextForCausalLM,QL as Qwen3NextModel,Uc as Qwen3NextPreTrainedModel,Gc as Qwen3PreTrainedModel,Dg as Qwen3VLForCausalLM,Wc as Qwen3VLForConditionalGeneration,JL as Qwen3VLMoeForCausalLM,YL as Qwen3VLMoeForConditionalGeneration,lC as Qwen3VLProcessor,Bg as Qwen3_5ForCausalLM,jc as Qwen3_5ForConditionalGeneration,ZL as Qwen3_5MoeForCausalLM,KL as Qwen3_5MoeForConditionalGeneration,nO as RFDetrForObjectDetection,rO as RFDetrModel,zg as RFDetrObjectDetectionOutput,Hc as RFDetrPreTrainedModel,_S as RTDetrForObjectDetection,S2 as RTDetrImageProcessor,fS as RTDetrModel,as as RTDetrObjectDetectionOutput,vl as RTDetrPreTrainedModel,pO as RTDetrV2ForObjectDetection,_O as RTDetrV2Model,Rg as RTDetrV2ObjectDetectionOutput,Qc as RTDetrV2PreTrainedModel,Kn as RawImage,zC as RepetitionPenaltyLogitsProcessor,tO as ResNetForImageClassification,eO as ResNetModel,qc as ResNetPreTrainedModel,uO as RoFormerForMaskedLM,fO as RoFormerForQuestionAnswering,dO as RoFormerForSequenceClassification,hO as RoFormerForTokenClassification,cO as RoFormerModel,In as RoFormerPreTrainedModel,Qk as RoFormerTokenizer,aO as RobertaForMaskedLM,lO as RobertaForQuestionAnswering,oO as RobertaForSequenceClassification,iO as RobertaForTokenClassification,sO as RobertaModel,Fn as RobertaPreTrainedModel,Hk as RobertaTokenizer,Uo as Sam2ImageProcessor,Vg as Sam2ImageSegmentationOutput,Xc as Sam2Model,Ug as Sam2PreTrainedModel,Sm as Sam2Processor,cC as Sam2VideoProcessor,Uo as Sam3ImageProcessor,wO as Sam3TrackerModel,Uo as SamImageProcessor,$g as SamImageSegmentationOutput,mO as SamModel,Gg as SamPreTrainedModel,Am as SamProcessor,P2 as SapiensFeatureExtractor,yO as SapiensForDepthEstimation,bO as SapiensForNormalEstimation,vO as SapiensForSemanticSegmentation,xm as SapiensImageProcessor,Sa as SapiensPreTrainedModel,AE as SeamlessM4TFeatureExtractor,F2 as SegformerFeatureExtractor,xO as SegformerForImageClassification,TO as SegformerForSemanticSegmentation,Tm as SegformerImageProcessor,MO as SegformerModel,Pa as SegformerPreTrainedModel,FC as Seq2SeqLMOutput,ie as SequenceClassifierOutput,I2 as SiglipImageProcessor,kO as SiglipModel,Yc as SiglipPreTrainedModel,Wg as SiglipTextModel,Xk as SiglipTokenizer,EO as SiglipVisionModel,AO as SmolLM3ForCausalLM,CO as SmolLM3Model,Jc as SmolLM3PreTrainedModel,SO as SmolVLMForConditionalGeneration,jf as SmolVLMImageProcessor,Hf as SmolVLMProcessor,qg as SnacDecoderModel,jg as SnacEncoderModel,SE as SnacFeatureExtractor,PO as SnacModel,Fa as SnacPreTrainedModel,IO as SolarOpenForCausalLM,FO as SolarOpenModel,Kc as SolarOpenPreTrainedModel,PE as SpeechT5FeatureExtractor,OO as SpeechT5ForSpeechToText,NO as SpeechT5ForTextToSpeech,DO as SpeechT5HifiGan,LO as SpeechT5Model,Ia as SpeechT5PreTrainedModel,uC as SpeechT5Processor,Yk as SpeechT5Tokenizer,zO as SqueezeBertForMaskedLM,$O as SqueezeBertForQuestionAnswering,RO as SqueezeBertForSequenceClassification,BO as SqueezeBertModel,ds as SqueezeBertPreTrainedModel,Jk as SqueezeBertTokenizer,VO as StableLmForCausalLM,GO as StableLmModel,Zc as StableLmPreTrainedModel,WO as Starcoder2ForCausalLM,UO as Starcoder2Model,eu as Starcoder2PreTrainedModel,ma as StoppingCriteria,Dm as StoppingCriteriaList,jO as StyleTextToSpeech2Model,Hg as StyleTextToSpeech2PreTrainedModel,Xg as SupertonicForConditionalGeneration,Qg as SupertonicPreTrainedModel,Om as SuppressTokensAtBeginLogitsProcessor,NC as SuppressTokensLogitsProcessor,YO as Swin2SRForImageSuperResolution,L2 as Swin2SRImageProcessor,XO as Swin2SRModel,tu as Swin2SRPreTrainedModel,HO as SwinForImageClassification,QO as SwinForSemanticSegmentation,qO as SwinModel,La as SwinPreTrainedModel,KO as T5ForConditionalGeneration,JO as T5Model,ru as T5PreTrainedModel,Kk as T5Tokenizer,eN as TableTransformerForObjectDetection,ZO as TableTransformerModel,Yg as TableTransformerObjectDetectionOutput,nu as TableTransformerPreTrainedModel,UC as TemperatureLogitsWarper,W as Tensor,je as TokenClassifierOutput,ue as TokenizersBackend,tN as TrOCRForCausalLM,Jg as TrOCRPreTrainedModel,Yl as UltravoxModel,mg as UltravoxPreTrainedModel,dC as UltravoxProcessor,nN as UniSpeechForCTC,sN as UniSpeechForSequenceClassification,rN as UniSpeechModel,Oa as UniSpeechPreTrainedModel,lN as UniSpeechSatForAudioFrameClassification,oN as UniSpeechSatForCTC,iN as UniSpeechSatForSequenceClassification,aN as UniSpeechSatModel,hs as UniSpeechSatPreTrainedModel,X2 as VLChatProcessor,i2 as VLMImageProcessor,uN as VaultGemmaForCausalLM,cN as VaultGemmaModel,su as VaultGemmaPreTrainedModel,O2 as ViTFeatureExtractor,fN as ViTForImageClassification,km as ViTImageProcessor,_N as ViTMAEModel,Kg as ViTMAEPreTrainedModel,mN as ViTMSNForImageClassification,pN as ViTMSNModel,ou as ViTMSNPreTrainedModel,hN as ViTModel,au as ViTPreTrainedModel,dN as VisionEncoderDecoderModel,gN as VitMatteForImageMatting,N2 as VitMatteImageProcessor,Zg as VitMattePreTrainedModel,wN as VitPoseForPoseEstimation,D2 as VitPoseImageProcessor,ew as VitPosePreTrainedModel,vN as VitsModel,tw as VitsModelOutput,rw as VitsPreTrainedModel,eE as VitsTokenizer,yN as VoxtralForConditionalGeneration,pC as VoxtralProcessor,LE as VoxtralRealtimeFeatureExtractor,sw as VoxtralRealtimeForConditionalGeneration,nw as VoxtralRealtimePreTrainedModel,wC as VoxtralRealtimeProcessor,AN as Wav2Vec2BertForCTC,SN as Wav2Vec2BertForSequenceClassification,CN as Wav2Vec2BertModel,Na as Wav2Vec2BertPreTrainedModel,tE as Wav2Vec2CTCTokenizer,FE as Wav2Vec2FeatureExtractor,gF as Wav2Vec2ForAudioFrameClassification,pF as Wav2Vec2ForCTC,mF as Wav2Vec2ForSequenceClassification,_F as Wav2Vec2Model,Er as Wav2Vec2PreTrainedModel,vC as Wav2Vec2Processor,yC as Wav2Vec2ProcessorWithLM,ON as WavLMForAudioFrameClassification,FN as WavLMForCTC,IN as WavLMForSequenceClassification,LN as WavLMForXVector,PN as WavLMModel,Ln as WavLMPreTrainedModel,IE as WeSpeakerFeatureExtractor,NN as WeSpeakerResNetModel,ow as WeSpeakerResNetPreTrainedModel,OE as WhisperFeatureExtractor,iw as WhisperForConditionalGeneration,BN as WhisperModel,iu as WhisperPreTrainedModel,bC as WhisperProcessor,DC as WhisperTimeStampLogitsProcessor,oE as WhisperTokenizer,UN as XLMForQuestionAnswering,GN as XLMForSequenceClassification,VN as XLMForTokenClassification,RN as XLMModel,On as XLMPreTrainedModel,jN as XLMRobertaForMaskedLM,QN as XLMRobertaForQuestionAnswering,qN as XLMRobertaForSequenceClassification,HN as XLMRobertaForTokenClassification,WN as XLMRobertaModel,Nn as XLMRobertaPreTrainedModel,iE as XLMRobertaTokenizer,lE as XLMTokenizer,$N as XLMWithLMHeadModel,aw as XVectorOutput,B2 as YolosFeatureExtractor,YN as YolosForObjectDetection,Em as YolosImageProcessor,XN as YolosModel,lw as YolosObjectDetectionOutput,lu as YolosPreTrainedModel,KN as YoutuForCausalLM,JN as YoutuModel,cu as YoutuPreTrainedModel,e3 as ZayaForCausalLM,ZN as ZayaModel,uu as ZayaPreTrainedModel,De as cat,ve as env,ot as full,si as full_like,zp as interpolate,Qt as interpolate_4d,GT as log_softmax,ok as matmul,Vi as mean,dt as ones,Wi as ones_like,ak as permute,lk as randn,Di as random,$p as slice,bn as softmax,sr as stack,ik as std_mean,Rp as topk,Gp as zeros,ji as zeros_like};