@huggingface/transformers 4.0.0-next.6 → 4.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/dist/ort-wasm-simd-threaded.jsep.mjs +24 -24
- package/dist/transformers.js +2255 -931
- package/dist/transformers.min.js +19 -19
- package/dist/transformers.node.cjs +2300 -934
- package/dist/transformers.node.min.cjs +20 -20
- package/dist/transformers.node.min.mjs +20 -20
- package/dist/transformers.node.mjs +2336 -1012
- package/dist/transformers.web.js +2327 -1003
- package/dist/transformers.web.min.js +17 -17
- package/package.json +4 -4
- package/src/cache_utils.js +62 -0
- package/src/configs.js +45 -24
- package/src/env.js +8 -1
- package/src/image_processors_utils.js +27 -17
- package/src/models/chatterbox/modeling_chatterbox.js +1 -1
- package/src/models/chmv2/image_processing_chmv2.js +3 -0
- package/src/models/chmv2/modeling_chmv2.js +4 -0
- package/src/models/deepseek_v3/modeling_deepseek_v3.js +5 -0
- package/src/models/detr/image_processing_detr.js +1 -1
- package/src/models/eurobert/modeling_eurobert.js +41 -0
- package/src/models/feature_extractors.js +2 -0
- package/src/models/gemma3n/modeling_gemma3n.js +2 -0
- package/src/models/glm46v/image_processing_glm46v.js +12 -0
- package/src/models/glm46v/processing_glm46v.js +5 -0
- package/src/models/glm_moe_dsa/modeling_glm_moe_dsa.js +5 -0
- package/src/models/glm_ocr/modeling_glm_ocr.js +78 -0
- package/src/models/granite_speech/feature_extraction_granite_speech.js +58 -0
- package/src/models/granite_speech/modeling_granite_speech.js +5 -0
- package/src/models/granite_speech/processing_granite_speech.js +62 -0
- package/src/models/grounding_dino/image_processing_grounding_dino.js +1 -1
- package/src/models/idefics3/modeling_idefics3.js +5 -32
- package/src/models/image_processors.js +3 -0
- package/src/models/lfm2_vl/image_processing_lfm2_vl.js +305 -0
- package/src/models/lfm2_vl/modeling_lfm2_vl.js +13 -0
- package/src/models/lfm2_vl/processing_lfm2_vl.js +77 -0
- package/src/models/lighton_ocr/modeling_lighton_ocr.js +3 -0
- package/src/models/llava/modeling_llava.js +1 -1
- package/src/models/mistral3/modeling_mistral3.js +2 -2
- package/src/models/mistral4/modeling_mistral4.js +5 -0
- package/src/models/modeling_utils.js +224 -308
- package/src/models/models.js +14 -1
- package/src/models/nemotron_h/modeling_nemotron_h.js +5 -0
- package/src/models/paligemma/modeling_paligemma.js +2 -25
- package/src/models/processors.js +4 -0
- package/src/models/qwen2_5_vl/modeling_qwen2_5_vl.js +5 -1
- package/src/models/qwen2_vl/image_processing_qwen2_vl.js +1 -41
- package/src/models/qwen2_vl/modeling_qwen2_vl.js +194 -143
- package/src/models/qwen2_vl/processing_qwen2_vl.js +5 -4
- package/src/models/qwen3_5/modeling_qwen3_5.js +1 -0
- package/src/models/qwen3_5_moe/modeling_qwen3_5_moe.js +2 -1
- package/src/models/qwen3_vl/modeling_qwen3_vl.js +2 -1
- package/src/models/qwen3_vl_moe/modeling_qwen3_vl_moe.js +2 -1
- package/src/models/registry.js +42 -0
- package/src/models/sam/image_processing_sam.js +1 -1
- package/src/models/session.js +17 -6
- package/src/models/smolvlm/modeling_smolvlm.js +7 -0
- package/src/models/solar_open/modeling_solar_open.js +5 -0
- package/src/models/ultravox/modeling_ultravox.js +1 -3
- package/src/models/voxtral/modeling_voxtral.js +3 -0
- package/src/models/voxtral_realtime/feature_extraction_voxtral_realtime.js +71 -0
- package/src/models/voxtral_realtime/modeling_voxtral_realtime.js +239 -0
- package/src/models/voxtral_realtime/processing_voxtral_realtime.js +113 -0
- package/src/models/whisper/feature_extraction_whisper.js +2 -12
- package/src/pipelines.js +1 -0
- package/src/transformers.js +2 -0
- package/src/utils/audio.js +18 -2
- package/src/utils/cache/CrossOriginStorageCache.js +251 -0
- package/src/utils/cache/cross-origin-storage.d.ts +38 -0
- package/src/utils/cache.js +5 -0
- package/src/utils/hub.js +4 -1
- package/src/utils/lru_cache.js +67 -0
- package/src/utils/memoize_promise.js +45 -0
- package/src/utils/model_registry/get_file_metadata.js +15 -2
- package/src/utils/model_registry/get_model_files.js +52 -78
- package/src/utils/tensor.js +18 -2
- package/types/cache_utils.d.ts +29 -0
- package/types/cache_utils.d.ts.map +1 -0
- package/types/configs.d.ts.map +1 -1
- package/types/env.d.ts +8 -0
- package/types/env.d.ts.map +1 -1
- package/types/image_processors_utils.d.ts +18 -1
- package/types/image_processors_utils.d.ts.map +1 -1
- package/types/models/{ast/modeling_ast.d.ts → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts} +1 -1
- package/types/models/audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.d.ts.map +1 -0
- package/types/models/chmv2/image_processing_chmv2.d.ts +4 -0
- package/types/models/chmv2/image_processing_chmv2.d.ts.map +1 -0
- package/types/models/chmv2/modeling_chmv2.d.ts +6 -0
- package/types/models/chmv2/modeling_chmv2.d.ts.map +1 -0
- package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts +8 -0
- package/types/models/deepseek_v3/modeling_deepseek_v3.d.ts.map +1 -0
- package/types/models/detr/image_processing_detr.d.ts +1 -1
- package/types/models/eurobert/modeling_eurobert.d.ts +36 -0
- package/types/models/eurobert/modeling_eurobert.d.ts.map +1 -0
- package/types/models/feature_extractors.d.ts +2 -0
- package/types/models/gemma3n/modeling_gemma3n.d.ts +2 -0
- package/types/models/gemma3n/modeling_gemma3n.d.ts.map +1 -1
- package/types/models/glm46v/image_processing_glm46v.d.ts +4 -0
- package/types/models/glm46v/image_processing_glm46v.d.ts.map +1 -0
- package/types/models/glm46v/processing_glm46v.d.ts +4 -0
- package/types/models/glm46v/processing_glm46v.d.ts.map +1 -0
- package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts +8 -0
- package/types/models/glm_moe_dsa/modeling_glm_moe_dsa.d.ts.map +1 -0
- package/types/models/glm_ocr/modeling_glm_ocr.d.ts +26 -0
- package/types/models/glm_ocr/modeling_glm_ocr.d.ts.map +1 -0
- package/types/models/granite_speech/feature_extraction_granite_speech.d.ts +16 -0
- package/types/models/granite_speech/feature_extraction_granite_speech.d.ts.map +1 -0
- package/types/models/granite_speech/modeling_granite_speech.d.ts +4 -0
- package/types/models/granite_speech/modeling_granite_speech.d.ts.map +1 -0
- package/types/models/granite_speech/processing_granite_speech.d.ts +19 -0
- package/types/models/granite_speech/processing_granite_speech.d.ts.map +1 -0
- package/types/models/grounding_dino/image_processing_grounding_dino.d.ts +1 -1
- package/types/models/idefics3/modeling_idefics3.d.ts +2 -18
- package/types/models/idefics3/modeling_idefics3.d.ts.map +1 -1
- package/types/models/image_processors.d.ts +3 -0
- package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts +41 -0
- package/types/models/lfm2_vl/image_processing_lfm2_vl.d.ts.map +1 -0
- package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts +4 -0
- package/types/models/lfm2_vl/modeling_lfm2_vl.d.ts.map +1 -0
- package/types/models/lfm2_vl/processing_lfm2_vl.d.ts +18 -0
- package/types/models/lfm2_vl/processing_lfm2_vl.d.ts.map +1 -0
- package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts +4 -0
- package/types/models/lighton_ocr/modeling_lighton_ocr.d.ts.map +1 -0
- package/types/models/mistral3/modeling_mistral3.d.ts +2 -2
- package/types/models/mistral3/modeling_mistral3.d.ts.map +1 -1
- package/types/models/mistral4/modeling_mistral4.d.ts +8 -0
- package/types/models/mistral4/modeling_mistral4.d.ts.map +1 -0
- package/types/models/modeling_utils.d.ts +44 -35
- package/types/models/modeling_utils.d.ts.map +1 -1
- package/types/models/models.d.ts +14 -1
- package/types/models/nemotron_h/modeling_nemotron_h.d.ts +8 -0
- package/types/models/nemotron_h/modeling_nemotron_h.d.ts.map +1 -0
- package/types/models/paligemma/modeling_paligemma.d.ts +2 -8
- package/types/models/paligemma/modeling_paligemma.d.ts.map +1 -1
- package/types/models/processors.d.ts +4 -0
- package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts +3 -0
- package/types/models/qwen2_5_vl/modeling_qwen2_5_vl.d.ts.map +1 -1
- package/types/models/qwen2_vl/image_processing_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +43 -6
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen2_vl/processing_qwen2_vl.d.ts +1 -0
- package/types/models/qwen2_vl/processing_qwen2_vl.d.ts.map +1 -1
- package/types/models/qwen3_5/modeling_qwen3_5.d.ts +2 -0
- package/types/models/qwen3_5/modeling_qwen3_5.d.ts.map +1 -1
- package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts +3 -0
- package/types/models/qwen3_5_moe/modeling_qwen3_5_moe.d.ts.map +1 -1
- package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts +3 -0
- package/types/models/qwen3_vl/modeling_qwen3_vl.d.ts.map +1 -1
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts +3 -0
- package/types/models/qwen3_vl_moe/modeling_qwen3_vl_moe.d.ts.map +1 -1
- package/types/models/registry.d.ts.map +1 -1
- package/types/models/sam/image_processing_sam.d.ts +1 -1
- package/types/models/session.d.ts +3 -2
- package/types/models/session.d.ts.map +1 -1
- package/types/models/smolvlm/modeling_smolvlm.d.ts +8 -0
- package/types/models/smolvlm/modeling_smolvlm.d.ts.map +1 -0
- package/types/models/solar_open/modeling_solar_open.d.ts +8 -0
- package/types/models/solar_open/modeling_solar_open.d.ts.map +1 -0
- package/types/models/ultravox/modeling_ultravox.d.ts +0 -2
- package/types/models/ultravox/modeling_ultravox.d.ts.map +1 -1
- package/types/models/voxtral/modeling_voxtral.d.ts +4 -0
- package/types/models/voxtral/modeling_voxtral.d.ts.map +1 -0
- package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts +28 -0
- package/types/models/voxtral_realtime/feature_extraction_voxtral_realtime.d.ts.map +1 -0
- package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts +17 -0
- package/types/models/voxtral_realtime/modeling_voxtral_realtime.d.ts.map +1 -0
- package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts +44 -0
- package/types/models/voxtral_realtime/processing_voxtral_realtime.d.ts.map +1 -0
- package/types/models/whisper/feature_extraction_whisper.d.ts.map +1 -1
- package/types/pipelines.d.ts +1 -0
- package/types/pipelines.d.ts.map +1 -1
- package/types/transformers.d.ts +1 -0
- package/types/transformers.d.ts.map +1 -1
- package/types/utils/audio.d.ts +5 -2
- package/types/utils/audio.d.ts.map +1 -1
- package/types/utils/cache/CrossOriginStorageCache.d.ts +120 -0
- package/types/utils/cache/CrossOriginStorageCache.d.ts.map +1 -0
- package/types/utils/cache.d.ts.map +1 -1
- package/types/utils/dtypes.d.ts +1 -1
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/image.d.ts +1 -1
- package/types/utils/lru_cache.d.ts +38 -0
- package/types/utils/lru_cache.d.ts.map +1 -0
- package/types/utils/memoize_promise.d.ts +14 -0
- package/types/utils/memoize_promise.d.ts.map +1 -0
- package/types/utils/model_registry/get_file_metadata.d.ts.map +1 -1
- package/types/utils/model_registry/get_model_files.d.ts +1 -0
- package/types/utils/model_registry/get_model_files.d.ts.map +1 -1
- package/types/utils/tensor.d.ts.map +1 -1
- package/src/utils/data-structures.js +0 -572
- package/types/models/ast/modeling_ast.d.ts.map +0 -1
- package/types/utils/data-structures.d.ts +0 -294
- package/types/utils/data-structures.d.ts.map +0 -1
- /package/src/models/{ast/modeling_ast.js → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.js} +0 -0
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var aO=Object.create;var Eu=Object.defineProperty;var iO=Object.getOwnPropertyDescriptor;var lO=Object.getOwnPropertyNames;var cO=Object.getPrototypeOf,uO=Object.prototype.hasOwnProperty;var Es=(t,e)=>{for(var r in e)Eu(t,r,{get:e[r],enumerable:!0})},ck=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lO(e))!uO.call(t,n)&&n!==r&&Eu(t,n,{get:()=>e[n],enumerable:!(s=iO(e,n))||s.enumerable});return t};var kr=(t,e,r)=>(r=t!=null?aO(cO(t)):{},ck(e||!t||!t.__esModule?Eu(r,"default",{value:t,enumerable:!0}):r,t)),pO=t=>ck(Eu({},"__esModule",{value:!0}),t);var _N={};Es(_N,{ASTFeatureExtractor:()=>Qp,ASTForAudioClassification:()=>Bf,ASTModel:()=>Uf,ASTPreTrainedModel:()=>to,AfmoeForCausalLM:()=>$f,AfmoeModel:()=>zf,AfmoePreTrainedModel:()=>Zn,AlbertForMaskedLM:()=>Pf,AlbertForQuestionAnswering:()=>Cf,AlbertForSequenceClassification:()=>If,AlbertModel:()=>Of,AlbertPreTrainedModel:()=>us,AlbertTokenizer:()=>op,ApertusForCausalLM:()=>Nf,ApertusModel:()=>Lf,ApertusPreTrainedModel:()=>Jn,ArceeForCausalLM:()=>Df,ArceeModel:()=>Rf,ArceePreTrainedModel:()=>eo,AudioClassificationPipeline:()=>yi,AutoConfig:()=>Wt,AutoFeatureExtractor:()=>et,AutoImageProcessor:()=>$e,AutoModel:()=>hr,AutoModelForAudioClassification:()=>au,AutoModelForAudioFrameClassification:()=>Qb,AutoModelForAudioTextToText:()=>r1,AutoModelForCTC:()=>ou,AutoModelForCausalLM:()=>Jc,AutoModelForDepthEstimation:()=>cu,AutoModelForDocumentQuestionAnswering:()=>iu,AutoModelForImageClassification:()=>ru,AutoModelForImageFeatureExtraction:()=>uu,AutoModelForImageMatting:()=>Jb,AutoModelForImageSegmentation:()=>ci,AutoModelForImageTextToText:()=>t1,AutoModelForImageToImage:()=>lu,AutoModelForMaskGeneration:()=>Kb,AutoModelForMaskedLM:()=>Zc,AutoModelForNormalEstimation:()=>Zb,AutoModelForObjectDetection:()=>su,AutoModelForPoseEstimation:()=>e1,AutoModelForQuestionAnswering:()=>eu,AutoModelForSemanticSegmentation:()=>ui,AutoModelForSeq2SeqLM:()=>hn,AutoModelForSequenceClassification:()=>li,AutoModelForSpeechSeq2Seq:()=>Kc,AutoModelForTextToSpectrogram:()=>Yc,AutoModelForTextToWaveform:()=>Qc,AutoModelForTokenClassification:()=>Xc,AutoModelForUniversalSegmentation:()=>pi,AutoModelForVision2Seq:()=>tu,AutoModelForXVector:()=>Yb,AutoModelForZeroShotObjectDetection:()=>nu,AutoProcessor:()=>Cl,AutoTokenizer:()=>ce,AutomaticSpeechRecognitionPipeline:()=>vi,BackgroundRemovalPipeline:()=>Mi,BartForConditionalGeneration:()=>jf,BartForSequenceClassification:()=>Gf,BartModel:()=>Ff,BartPretrainedModel:()=>Ks,BartTokenizer:()=>ap,BaseStreamer:()=>zy,BeitFeatureExtractor:()=>md,BeitForImageClassification:()=>Wf,BeitModel:()=>qf,BeitPreTrainedModel:()=>ro,BertForMaskedLM:()=>Hf,BertForQuestionAnswering:()=>Yf,BertForSequenceClassification:()=>Xf,BertForTokenClassification:()=>Kf,BertModel:()=>Vf,BertPreTrainedModel:()=>Sr,BertTokenizer:()=>ip,BitImageProcessor:()=>hd,BlenderbotForConditionalGeneration:()=>Jf,BlenderbotModel:()=>Qf,BlenderbotPreTrainedModel:()=>so,BlenderbotSmallForConditionalGeneration:()=>em,BlenderbotSmallModel:()=>Zf,BlenderbotSmallPreTrainedModel:()=>no,BlenderbotSmallTokenizer:()=>lp,BlenderbotTokenizer:()=>cp,BloomForCausalLM:()=>rm,BloomModel:()=>tm,BloomPreTrainedModel:()=>oo,BloomTokenizer:()=>up,CLIPFeatureExtractor:()=>gd,CLIPImageProcessor:()=>ml,CLIPModel:()=>um,CLIPPreTrainedModel:()=>nr,CLIPSegForImageSegmentation:()=>hm,CLIPSegModel:()=>mm,CLIPSegPreTrainedModel:()=>uo,CLIPTextModel:()=>pm,CLIPTextModelWithProjection:()=>co,CLIPTokenizer:()=>dp,CLIPVisionModel:()=>dm,CLIPVisionModelWithProjection:()=>fm,CamembertForMaskedLM:()=>nm,CamembertForQuestionAnswering:()=>im,CamembertForSequenceClassification:()=>om,CamembertForTokenClassification:()=>am,CamembertModel:()=>sm,CamembertPreTrainedModel:()=>Or,CamembertTokenizer:()=>pp,ChatterboxFeatureExtractor:()=>Jp,ChatterboxModel:()=>ao,ChatterboxPreTrainedModel:()=>Kl,ChatterboxProcessor:()=>cd,ChineseCLIPFeatureExtractor:()=>_d,ChineseCLIPModel:()=>lm,ChineseCLIPPreTrainedModel:()=>Yl,ClapAudioModelWithProjection:()=>lo,ClapFeatureExtractor:()=>Zp,ClapModel:()=>cm,ClapPreTrainedModel:()=>Ys,ClapTextModelWithProjection:()=>io,ClassifierFreeGuidanceLogitsProcessor:()=>jl,CodeGenForCausalLM:()=>gm,CodeGenModel:()=>_m,CodeGenPreTrainedModel:()=>po,CodeGenTokenizer:()=>mp,CodeLlamaTokenizer:()=>fp,Cohere2ForCausalLM:()=>bm,Cohere2Model:()=>ym,Cohere2PreTrainedModel:()=>mo,CohereForCausalLM:()=>xm,CohereModel:()=>wm,CoherePreTrainedModel:()=>fo,CohereTokenizer:()=>hp,ConvBertForMaskedLM:()=>km,ConvBertForQuestionAnswering:()=>Mm,ConvBertForSequenceClassification:()=>Em,ConvBertForTokenClassification:()=>Am,ConvBertModel:()=>vm,ConvBertPreTrainedModel:()=>Ir,ConvBertTokenizer:()=>_p,ConvNextFeatureExtractor:()=>wd,ConvNextForImageClassification:()=>Sm,ConvNextImageProcessor:()=>hl,ConvNextModel:()=>Tm,ConvNextPreTrainedModel:()=>ho,ConvNextV2ForImageClassification:()=>Im,ConvNextV2Model:()=>Om,ConvNextV2PreTrainedModel:()=>_o,DFineForObjectDetection:()=>Nm,DFineModel:()=>Lm,DFinePreTrainedModel:()=>wo,DINOv3ConvNextModel:()=>nh,DINOv3ConvNextPreTrainedModel:()=>sc,DINOv3ViTImageProcessor:()=>bd,DINOv3ViTModel:()=>oh,DINOv3ViTPreTrainedModel:()=>nc,DPTFeatureExtractor:()=>kd,DPTForDepthEstimation:()=>fh,DPTImageProcessor:()=>wl,DPTModel:()=>dh,DPTPreTrainedModel:()=>Eo,DacDecoderModel:()=>yo,DacDecoderOutput:()=>Jl,DacEncoderModel:()=>xo,DacEncoderOutput:()=>Ql,DacFeatureExtractor:()=>Bn,DacModel:()=>zm,DacPreTrainedModel:()=>Qs,DebertaForMaskedLM:()=>Rm,DebertaForQuestionAnswering:()=>Bm,DebertaForSequenceClassification:()=>Dm,DebertaForTokenClassification:()=>Um,DebertaModel:()=>$m,DebertaPreTrainedModel:()=>Cr,DebertaTokenizer:()=>wp,DebertaV2ForMaskedLM:()=>jm,DebertaV2ForQuestionAnswering:()=>Wm,DebertaV2ForSequenceClassification:()=>Gm,DebertaV2ForTokenClassification:()=>qm,DebertaV2Model:()=>Fm,DebertaV2PreTrainedModel:()=>Pr,DebertaV2Tokenizer:()=>gp,DecisionTransformerModel:()=>Vm,DecisionTransformerPreTrainedModel:()=>Zl,DeiTFeatureExtractor:()=>xd,DeiTForImageClassification:()=>Xm,DeiTImageProcessor:()=>_l,DeiTModel:()=>Hm,DeiTPreTrainedModel:()=>bo,DepthAnythingForDepthEstimation:()=>Km,DepthAnythingPreTrainedModel:()=>ec,DepthEstimationPipeline:()=>Pi,DepthProForDepthEstimation:()=>Ym,DepthProPreTrainedModel:()=>tc,DetrFeatureExtractor:()=>yd,DetrForObjectDetection:()=>Jm,DetrForSegmentation:()=>Zm,DetrImageProcessor:()=>gl,DetrModel:()=>Qm,DetrObjectDetectionOutput:()=>Zs,DetrPreTrainedModel:()=>Js,DetrSegmentationOutput:()=>rc,Dinov2ForImageClassification:()=>th,Dinov2Model:()=>eh,Dinov2PreTrainedModel:()=>vo,Dinov2WithRegistersForImageClassification:()=>sh,Dinov2WithRegistersModel:()=>rh,Dinov2WithRegistersPreTrainedModel:()=>ko,DistilBertForMaskedLM:()=>uh,DistilBertForQuestionAnswering:()=>ch,DistilBertForSequenceClassification:()=>ih,DistilBertForTokenClassification:()=>lh,DistilBertModel:()=>ah,DistilBertPreTrainedModel:()=>Lr,DistilBertTokenizer:()=>xp,DocumentQuestionAnsweringPipeline:()=>Ii,DonutFeatureExtractor:()=>vd,DonutImageProcessor:()=>Fs,DonutSwinModel:()=>ph,DonutSwinPreTrainedModel:()=>oc,EdgeTamModel:()=>ox,EfficientNetForImageClassification:()=>hh,EfficientNetImageProcessor:()=>Ed,EfficientNetModel:()=>mh,EfficientNetPreTrainedModel:()=>Ao,ElectraForMaskedLM:()=>gh,ElectraForQuestionAnswering:()=>yh,ElectraForSequenceClassification:()=>wh,ElectraForTokenClassification:()=>xh,ElectraModel:()=>_h,ElectraPreTrainedModel:()=>Nr,ElectraTokenizer:()=>yp,EncodecFeatureExtractor:()=>Un,EosTokenCriteria:()=>Vl,Ernie4_5ForCausalLM:()=>vh,Ernie4_5Model:()=>bh,Ernie4_5PretrainedModel:()=>Mo,EsmForMaskedLM:()=>Eh,EsmForSequenceClassification:()=>Ah,EsmForTokenClassification:()=>Mh,EsmModel:()=>kh,EsmPreTrainedModel:()=>ps,EsmTokenizer:()=>bp,ExaoneForCausalLM:()=>Sh,ExaoneModel:()=>Th,ExaonePreTrainedModel:()=>To,FalconForCausalLM:()=>Ih,FalconH1ForCausalLM:()=>Ph,FalconH1Model:()=>Ch,FalconH1PreTrainedModel:()=>Oo,FalconModel:()=>Oh,FalconPreTrainedModel:()=>So,FalconTokenizer:()=>vp,FastViTForImageClassification:()=>Nh,FastViTModel:()=>Lh,FastViTPreTrainedModel:()=>Io,FeatureExtractionPipeline:()=>Li,FeatureExtractor:()=>ze,FillMaskPipeline:()=>hi,Florence2ForConditionalGeneration:()=>zh,Florence2PreTrainedModel:()=>ac,Florence2Processor:()=>Zd,ForcedBOSTokenLogitsProcessor:()=>Nl,ForcedEOSTokenLogitsProcessor:()=>zl,GLPNFeatureExtractor:()=>Ad,GLPNForDepthEstimation:()=>Wh,GLPNModel:()=>qh,GLPNPreTrainedModel:()=>$o,GPT2LMHeadModel:()=>t_,GPT2Model:()=>e_,GPT2PreTrainedModel:()=>Fo,GPT2Tokenizer:()=>Ap,GPTBigCodeForCausalLM:()=>Hh,GPTBigCodeModel:()=>Vh,GPTBigCodePreTrainedModel:()=>Ro,GPTJForCausalLM:()=>s_,GPTJModel:()=>r_,GPTJPreTrainedModel:()=>jo,GPTNeoForCausalLM:()=>Kh,GPTNeoModel:()=>Xh,GPTNeoPreTrainedModel:()=>Do,GPTNeoXForCausalLM:()=>Qh,GPTNeoXModel:()=>Yh,GPTNeoXPreTrainedModel:()=>Uo,GPTNeoXTokenizer:()=>Ep,Gemma2ForCausalLM:()=>Uh,Gemma2Model:()=>Dh,Gemma2PreTrainedModel:()=>Po,Gemma3ForCausalLM:()=>Fh,Gemma3Model:()=>Bh,Gemma3PreTrainedModel:()=>Lo,Gemma3nAudioFeatureExtractor:()=>ed,Gemma3nForConditionalGeneration:()=>No,Gemma3nPreTrainedModel:()=>ic,Gemma3nProcessor:()=>ef,GemmaForCausalLM:()=>Rh,GemmaModel:()=>$h,GemmaPreTrainedModel:()=>Co,GemmaTokenizer:()=>kp,GlmForCausalLM:()=>Gh,GlmModel:()=>jh,GlmPreTrainedModel:()=>zo,GptOssForCausalLM:()=>Zh,GptOssModel:()=>Jh,GptOssPreTrainedModel:()=>Bo,GraniteForCausalLM:()=>o_,GraniteModel:()=>n_,GraniteMoeHybridForCausalLM:()=>i_,GraniteMoeHybridModel:()=>a_,GraniteMoeHybridPreTrainedModel:()=>qo,GranitePreTrainedModel:()=>Go,GroundingDinoForObjectDetection:()=>l_,GroundingDinoImageProcessor:()=>Md,GroundingDinoPreTrainedModel:()=>lc,GroundingDinoProcessor:()=>tf,GroupViTModel:()=>c_,GroupViTPreTrainedModel:()=>cc,HeliumForCausalLM:()=>p_,HeliumModel:()=>u_,HeliumPreTrainedModel:()=>Wo,HerbertTokenizer:()=>Mp,HieraForImageClassification:()=>f_,HieraModel:()=>d_,HieraPreTrainedModel:()=>Vo,HubertForCTC:()=>y_,HubertForSequenceClassification:()=>b_,HubertModel:()=>x_,HubertPreTrainedModel:()=>w_,HunYuanDenseV1ForCausalLM:()=>k_,HunYuanDenseV1Model:()=>v_,HunYuanDenseV1PreTrainedModel:()=>Ho,IJepaForImageClassification:()=>M_,IJepaModel:()=>A_,IJepaPreTrainedModel:()=>Xo,Idefics3ForConditionalGeneration:()=>pc,Idefics3ImageProcessor:()=>xl,Idefics3PreTrainedModel:()=>uc,Idefics3Processor:()=>Ol,ImageClassificationPipeline:()=>Ai,ImageFeatureExtractionPipeline:()=>Ni,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,ImageSegmentationPipeline:()=>xs,ImageToImagePipeline:()=>Ci,ImageToTextPipeline:()=>Ei,InterruptableStoppingCriteria:()=>Fb,JAISLMHeadModel:()=>S_,JAISModel:()=>T_,JAISPreTrainedModel:()=>Ko,JinaCLIPImageProcessor:()=>Sd,JinaCLIPModel:()=>O_,JinaCLIPPreTrainedModel:()=>en,JinaCLIPProcessor:()=>sf,JinaCLIPTextModel:()=>Yo,JinaCLIPVisionModel:()=>I_,Lfm2ForCausalLM:()=>P_,Lfm2Model:()=>C_,Lfm2MoeForCausalLM:()=>N_,Lfm2MoeModel:()=>L_,Lfm2MoePreTrainedModel:()=>Jo,Lfm2PreTrainedModel:()=>Qo,LiteWhisperForConditionalGeneration:()=>gy,Llama4ForCausalLM:()=>R_,Llama4PreTrainedModel:()=>dc,LlamaForCausalLM:()=>$_,LlamaModel:()=>z_,LlamaPreTrainedModel:()=>Zo,LlamaTokenizer:()=>Tp,LlavaForConditionalGeneration:()=>tn,LlavaOnevisionForConditionalGeneration:()=>tn,LlavaOnevisionImageProcessor:()=>Od,LlavaPreTrainedModel:()=>fc,LlavaProcessor:()=>nf,LlavaQwen2ForCausalLM:()=>U_,LogLevel:()=>vt,LogitsProcessor:()=>Dt,LogitsProcessorList:()=>cs,LogitsWarper:()=>Yn,LongT5ForConditionalGeneration:()=>F_,LongT5Model:()=>B_,LongT5PreTrainedModel:()=>ea,M2M100ForConditionalGeneration:()=>G_,M2M100Model:()=>j_,M2M100PreTrainedModel:()=>ta,M2M100Tokenizer:()=>Sp,MBart50Tokenizer:()=>Ip,MBartForCausalLM:()=>Q_,MBartForConditionalGeneration:()=>K_,MBartForSequenceClassification:()=>Y_,MBartModel:()=>X_,MBartPreTrainedModel:()=>ds,MBartTokenizer:()=>Rn,MPNetForMaskedLM:()=>zg,MPNetForQuestionAnswering:()=>Dg,MPNetForSequenceClassification:()=>$g,MPNetForTokenClassification:()=>Rg,MPNetModel:()=>Ng,MPNetPreTrainedModel:()=>zr,MPNetTokenizer:()=>Lp,MT5ForConditionalGeneration:()=>jg,MT5Model:()=>Fg,MT5PreTrainedModel:()=>fa,MarianMTModel:()=>W_,MarianModel:()=>q_,MarianPreTrainedModel:()=>ra,MarianTokenizer:()=>Op,Mask2FormerImageProcessor:()=>Cd,MaskFormerFeatureExtractor:()=>Id,MaskFormerForInstanceSegmentation:()=>H_,MaskFormerImageProcessor:()=>js,MaskFormerModel:()=>V_,MaskFormerPreTrainedModel:()=>sa,MaxLengthCriteria:()=>Wl,Metric3DForDepthEstimation:()=>J_,Metric3DPreTrainedModel:()=>mc,Metric3Dv2ForDepthEstimation:()=>Z_,Metric3Dv2PreTrainedModel:()=>hc,MgpstrForSceneTextRecognition:()=>eg,MgpstrModelOutput:()=>_c,MgpstrPreTrainedModel:()=>gc,MgpstrProcessor:()=>of,MgpstrTokenizer:()=>Cp,MimiDecoderModel:()=>oa,MimiDecoderOutput:()=>xc,MimiEncoderModel:()=>na,MimiEncoderOutput:()=>wc,MimiModel:()=>tg,MimiPreTrainedModel:()=>rn,MinLengthLogitsProcessor:()=>Ul,MinNewTokensLengthLogitsProcessor:()=>Bl,MistralForCausalLM:()=>sg,MistralModel:()=>rg,MistralPreTrainedModel:()=>aa,MobileBertForMaskedLM:()=>og,MobileBertForQuestionAnswering:()=>ig,MobileBertForSequenceClassification:()=>ag,MobileBertModel:()=>ng,MobileBertPreTrainedModel:()=>fs,MobileBertTokenizer:()=>Pp,MobileLLMForCausalLM:()=>cg,MobileLLMModel:()=>lg,MobileLLMPreTrainedModel:()=>ia,MobileNetV1FeatureExtractor:()=>Pd,MobileNetV1ForImageClassification:()=>pg,MobileNetV1ForSemanticSegmentation:()=>dg,MobileNetV1ImageProcessor:()=>yl,MobileNetV1Model:()=>ug,MobileNetV1PreTrainedModel:()=>sn,MobileNetV2FeatureExtractor:()=>Ld,MobileNetV2ForImageClassification:()=>mg,MobileNetV2ForSemanticSegmentation:()=>hg,MobileNetV2ImageProcessor:()=>bl,MobileNetV2Model:()=>fg,MobileNetV2PreTrainedModel:()=>nn,MobileNetV3FeatureExtractor:()=>Nd,MobileNetV3ForImageClassification:()=>gg,MobileNetV3ForSemanticSegmentation:()=>wg,MobileNetV3ImageProcessor:()=>vl,MobileNetV3Model:()=>_g,MobileNetV3PreTrainedModel:()=>on,MobileNetV4FeatureExtractor:()=>zd,MobileNetV4ForImageClassification:()=>yg,MobileNetV4ForSemanticSegmentation:()=>bg,MobileNetV4ImageProcessor:()=>kl,MobileNetV4Model:()=>xg,MobileNetV4PreTrainedModel:()=>an,MobileViTFeatureExtractor:()=>$d,MobileViTForImageClassification:()=>kg,MobileViTImageProcessor:()=>El,MobileViTModel:()=>vg,MobileViTPreTrainedModel:()=>la,MobileViTV2ForImageClassification:()=>Ag,MobileViTV2Model:()=>Eg,MobileViTV2PreTrainedModel:()=>ca,ModelRegistry:()=>Dy,ModernBertDecoderForCausalLM:()=>Cg,ModernBertDecoderModel:()=>Ig,ModernBertDecoderPreTrainedModel:()=>ua,ModernBertForMaskedLM:()=>Tg,ModernBertForSequenceClassification:()=>Sg,ModernBertForTokenClassification:()=>Og,ModernBertModel:()=>Mg,ModernBertPreTrainedModel:()=>ms,Moondream1ForConditionalGeneration:()=>D_,MoonshineFeatureExtractor:()=>td,MoonshineForConditionalGeneration:()=>Lg,MoonshineModel:()=>Pg,MoonshinePreTrainedModel:()=>pa,MoonshineProcessor:()=>af,MptForCausalLM:()=>Bg,MptModel:()=>Ug,MptPreTrainedModel:()=>da,MultiModalityCausalLM:()=>Gg,MultiModalityPreTrainedModel:()=>yc,MusicgenForCausalLM:()=>Wg,MusicgenForConditionalGeneration:()=>ha,MusicgenModel:()=>qg,MusicgenPreTrainedModel:()=>ma,NanoChatForCausalLM:()=>Hg,NanoChatModel:()=>Vg,NanoChatPreTrainedModel:()=>_a,NeoBertForMaskedLM:()=>Kg,NeoBertForQuestionAnswering:()=>Jg,NeoBertForSequenceClassification:()=>Yg,NeoBertForTokenClassification:()=>Qg,NeoBertModel:()=>Xg,NeoBertPreTrainedModel:()=>$r,NllbTokenizer:()=>Np,NoBadWordsLogitsProcessor:()=>Fl,NoRepeatNGramLogitsProcessor:()=>Rl,NomicBertModel:()=>Zg,NomicBertPreTrainedModel:()=>bc,NougatImageProcessor:()=>Rd,NougatTokenizer:()=>zp,OPTForCausalLM:()=>pw,OPTModel:()=>uw,OPTPreTrainedModel:()=>va,ObjectDetectionPipeline:()=>Si,Olmo2ForCausalLM:()=>sw,Olmo2Model:()=>rw,Olmo2PreTrainedModel:()=>wa,Olmo3ForCausalLM:()=>ow,Olmo3Model:()=>nw,Olmo3PreTrainedModel:()=>xa,OlmoForCausalLM:()=>tw,OlmoHybridForCausalLM:()=>iw,OlmoHybridModel:()=>aw,OlmoHybridPreTrainedModel:()=>ya,OlmoModel:()=>ew,OlmoPreTrainedModel:()=>ga,OpenELMForCausalLM:()=>cw,OpenELMModel:()=>lw,OpenELMPreTrainedModel:()=>ba,OwlViTFeatureExtractor:()=>Dd,OwlViTForObjectDetection:()=>hw,OwlViTImageProcessor:()=>Gs,OwlViTModel:()=>mw,OwlViTPreTrainedModel:()=>Ea,OwlViTProcessor:()=>lf,Owlv2ForObjectDetection:()=>fw,Owlv2ImageProcessor:()=>Ud,Owlv2Model:()=>dw,Owlv2PreTrainedModel:()=>ka,PaliGemmaForConditionalGeneration:()=>_w,PaliGemmaPreTrainedModel:()=>vc,PaliGemmaProcessor:()=>cf,ParakeetFeatureExtractor:()=>rd,ParakeetForCTC:()=>gw,ParakeetPreTrainedModel:()=>kc,PatchTSMixerForPrediction:()=>xw,PatchTSMixerModel:()=>ww,PatchTSMixerPreTrainedModel:()=>Aa,PatchTSTForPrediction:()=>bw,PatchTSTModel:()=>yw,PatchTSTPreTrainedModel:()=>Ma,Phi3ForCausalLM:()=>Aw,Phi3Model:()=>Ew,Phi3PreTrainedModel:()=>Sa,Phi3VForCausalLM:()=>Oa,Phi3VImageProcessor:()=>Bd,Phi3VPreTrainedModel:()=>Ec,Phi3VProcessor:()=>uf,PhiForCausalLM:()=>kw,PhiModel:()=>vw,PhiPreTrainedModel:()=>Ta,PixtralImageProcessor:()=>Fd,PixtralProcessor:()=>pf,PreTrainedModel:()=>y,PreTrainedTokenizer:()=>q,PretrainedConfig:()=>Pl,Processor:()=>oe,PvtForImageClassification:()=>Tw,PvtImageProcessor:()=>jd,PvtModel:()=>Mw,PvtPreTrainedModel:()=>Ia,PyAnnoteFeatureExtractor:()=>Fn,PyAnnoteForAudioFrameClassification:()=>Ow,PyAnnoteModel:()=>Sw,PyAnnotePreTrainedModel:()=>Ca,PyAnnoteProcessor:()=>df,QuestionAnsweringPipeline:()=>mi,Qwen2ForCausalLM:()=>Cw,Qwen2Model:()=>Iw,Qwen2MoeForCausalLM:()=>Lw,Qwen2MoeModel:()=>Pw,Qwen2MoePreTrainedModel:()=>La,Qwen2PreTrainedModel:()=>Pa,Qwen2Tokenizer:()=>$p,Qwen2VLForConditionalGeneration:()=>Na,Qwen2VLImageProcessor:()=>Gd,Qwen2VLPreTrainedModel:()=>Ac,Qwen2VLProcessor:()=>Vn,Qwen2_5_VLForConditionalGeneration:()=>za,Qwen2_5_VLProcessor:()=>Hn,Qwen3ForCausalLM:()=>zw,Qwen3Model:()=>Nw,Qwen3MoeForCausalLM:()=>Rw,Qwen3MoeModel:()=>$w,Qwen3MoePreTrainedModel:()=>Ra,Qwen3NextForCausalLM:()=>Uw,Qwen3NextModel:()=>Dw,Qwen3NextPreTrainedModel:()=>Da,Qwen3PreTrainedModel:()=>$a,Qwen3VLForConditionalGeneration:()=>hs,Qwen3VLMoeForConditionalGeneration:()=>Bw,Qwen3VLProcessor:()=>ff,Qwen3_5ForConditionalGeneration:()=>Ua,Qwen3_5MoeForConditionalGeneration:()=>Fw,RFDetrForObjectDetection:()=>Ww,RFDetrModel:()=>qw,RFDetrObjectDetectionOutput:()=>Mc,RFDetrPreTrainedModel:()=>Fa,RTDetrForObjectDetection:()=>Pm,RTDetrImageProcessor:()=>qd,RTDetrModel:()=>Cm,RTDetrObjectDetectionOutput:()=>or,RTDetrPreTrainedModel:()=>go,RTDetrV2ForObjectDetection:()=>sx,RTDetrV2Model:()=>rx,RTDetrV2ObjectDetectionOutput:()=>Tc,RTDetrV2PreTrainedModel:()=>ja,RawAudio:()=>Dn,RawImage:()=>Ke,RawVideo:()=>du,RawVideoFrame:()=>$i,RepetitionPenaltyLogitsProcessor:()=>Dl,ResNetForImageClassification:()=>Gw,ResNetModel:()=>jw,ResNetPreTrainedModel:()=>Ba,RoFormerForMaskedLM:()=>Jw,RoFormerForQuestionAnswering:()=>tx,RoFormerForSequenceClassification:()=>Zw,RoFormerForTokenClassification:()=>ex,RoFormerModel:()=>Qw,RoFormerPreTrainedModel:()=>Dr,RoFormerTokenizer:()=>Dp,RobertaForMaskedLM:()=>Hw,RobertaForQuestionAnswering:()=>Yw,RobertaForSequenceClassification:()=>Xw,RobertaForTokenClassification:()=>Kw,RobertaModel:()=>Vw,RobertaPreTrainedModel:()=>Rr,RobertaTokenizer:()=>Rp,Sam2ImageProcessor:()=>Gn,Sam2ImageSegmentationOutput:()=>Ic,Sam2Model:()=>Ga,Sam2PreTrainedModel:()=>Cc,Sam2Processor:()=>Il,Sam2VideoProcessor:()=>mf,Sam3ImageProcessor:()=>Gn,Sam3TrackerModel:()=>ax,SamImageProcessor:()=>Gn,SamImageSegmentationOutput:()=>Sc,SamModel:()=>nx,SamPreTrainedModel:()=>Oc,SamProcessor:()=>Xn,SapiensFeatureExtractor:()=>Wd,SapiensForDepthEstimation:()=>lx,SapiensForNormalEstimation:()=>cx,SapiensForSemanticSegmentation:()=>ix,SapiensImageProcessor:()=>Al,SapiensPreTrainedModel:()=>ln,SeamlessM4TFeatureExtractor:()=>sd,SegformerFeatureExtractor:()=>Vd,SegformerForImageClassification:()=>px,SegformerForSemanticSegmentation:()=>dx,SegformerImageProcessor:()=>Ml,SegformerModel:()=>ux,SegformerPreTrainedModel:()=>cn,SiglipImageProcessor:()=>Hd,SiglipModel:()=>fx,SiglipPreTrainedModel:()=>qa,SiglipTextModel:()=>Wa,SiglipTokenizer:()=>Up,SiglipVisionModel:()=>mx,SmolLM3ForCausalLM:()=>_x,SmolLM3Model:()=>hx,SmolLM3PreTrainedModel:()=>Va,SmolVLMForConditionalGeneration:()=>E_,SmolVLMImageProcessor:()=>xl,SmolVLMProcessor:()=>Ol,SnacDecoderModel:()=>Xa,SnacEncoderModel:()=>Ha,SnacFeatureExtractor:()=>nd,SnacModel:()=>gx,SnacPreTrainedModel:()=>un,SpeechT5FeatureExtractor:()=>od,SpeechT5ForSpeechToText:()=>xx,SpeechT5ForTextToSpeech:()=>yx,SpeechT5HifiGan:()=>bx,SpeechT5Model:()=>wx,SpeechT5PreTrainedModel:()=>pn,SpeechT5Processor:()=>hf,SpeechT5Tokenizer:()=>Bp,SqueezeBertForMaskedLM:()=>kx,SqueezeBertForQuestionAnswering:()=>Ax,SqueezeBertForSequenceClassification:()=>Ex,SqueezeBertModel:()=>vx,SqueezeBertPreTrainedModel:()=>_s,SqueezeBertTokenizer:()=>Fp,StableLmForCausalLM:()=>Tx,StableLmModel:()=>Mx,StableLmPreTrainedModel:()=>Ka,Starcoder2ForCausalLM:()=>Ox,Starcoder2Model:()=>Sx,Starcoder2PreTrainedModel:()=>Ya,StoppingCriteria:()=>Ws,StoppingCriteriaList:()=>ql,StyleTextToSpeech2Model:()=>Ix,StyleTextToSpeech2PreTrainedModel:()=>Pc,SummarizationPipeline:()=>_i,SupertonicForConditionalGeneration:()=>Qa,SupertonicPreTrainedModel:()=>Lc,SuppressTokensAtBeginLogitsProcessor:()=>qs,Swin2SRForImageSuperResolution:()=>zx,Swin2SRImageProcessor:()=>Xd,Swin2SRModel:()=>Nx,Swin2SRPreTrainedModel:()=>Ja,SwinForImageClassification:()=>Px,SwinForSemanticSegmentation:()=>Lx,SwinModel:()=>Cx,SwinPreTrainedModel:()=>dn,T5ForConditionalGeneration:()=>Rx,T5Model:()=>$x,T5PreTrainedModel:()=>Za,T5Tokenizer:()=>jp,TableTransformerForObjectDetection:()=>Ux,TableTransformerModel:()=>Dx,TableTransformerObjectDetectionOutput:()=>Nc,TableTransformerPreTrainedModel:()=>ei,TemperatureLogitsWarper:()=>Gl,Tensor:()=>D,Text2TextGenerationPipeline:()=>_r,TextClassificationPipeline:()=>di,TextGenerationPipeline:()=>wi,TextStreamer:()=>$y,TextToAudioPipeline:()=>ki,TokenClassificationPipeline:()=>fi,TokenizersBackend:()=>q,TopKLogitsWarper:()=>Bb,TopPLogitsWarper:()=>Ub,TrOCRForCausalLM:()=>Bx,TrOCRPreTrainedModel:()=>zc,TranslationPipeline:()=>gi,UltravoxModel:()=>Rc,UltravoxPreTrainedModel:()=>$c,UltravoxProcessor:()=>_f,UniSpeechForCTC:()=>Gx,UniSpeechForSequenceClassification:()=>qx,UniSpeechModel:()=>jx,UniSpeechPreTrainedModel:()=>fn,UniSpeechSatForAudioFrameClassification:()=>Xx,UniSpeechSatForCTC:()=>Vx,UniSpeechSatForSequenceClassification:()=>Hx,UniSpeechSatModel:()=>Wx,UniSpeechSatPreTrainedModel:()=>gs,VLChatProcessor:()=>rf,VLMImageProcessor:()=>Td,VaultGemmaForCausalLM:()=>Yx,VaultGemmaModel:()=>Kx,VaultGemmaPreTrainedModel:()=>ti,ViTFeatureExtractor:()=>Kd,ViTForImageClassification:()=>Zx,ViTImageProcessor:()=>Tl,ViTMAEModel:()=>ey,ViTMAEPreTrainedModel:()=>Dc,ViTMSNForImageClassification:()=>ry,ViTMSNModel:()=>ty,ViTMSNPreTrainedModel:()=>si,ViTModel:()=>Jx,ViTPreTrainedModel:()=>ri,VisionEncoderDecoderModel:()=>Qx,VitMatteForImageMatting:()=>sy,VitMatteImageProcessor:()=>Yd,VitMattePreTrainedModel:()=>Uc,VitPoseForPoseEstimation:()=>ny,VitPoseImageProcessor:()=>Qd,VitPosePreTrainedModel:()=>Bc,VitsModel:()=>oy,VitsModelOutput:()=>Fc,VitsPreTrainedModel:()=>jc,VitsTokenizer:()=>Gp,VoxtralForConditionalGeneration:()=>Fx,VoxtralProcessor:()=>wf,Wav2Vec2BertForCTC:()=>iy,Wav2Vec2BertForSequenceClassification:()=>ly,Wav2Vec2BertModel:()=>ay,Wav2Vec2BertPreTrainedModel:()=>mn,Wav2Vec2CTCTokenizer:()=>qp,Wav2Vec2FeatureExtractor:()=>ad,Wav2Vec2ForAudioFrameClassification:()=>g_,Wav2Vec2ForCTC:()=>h_,Wav2Vec2ForSequenceClassification:()=>__,Wav2Vec2Model:()=>m_,Wav2Vec2PreTrainedModel:()=>Ht,Wav2Vec2Processor:()=>xf,Wav2Vec2ProcessorWithLM:()=>yf,WavLMForAudioFrameClassification:()=>fy,WavLMForCTC:()=>uy,WavLMForSequenceClassification:()=>py,WavLMForXVector:()=>dy,WavLMModel:()=>cy,WavLMPreTrainedModel:()=>Ur,WeSpeakerFeatureExtractor:()=>id,WeSpeakerResNetModel:()=>my,WeSpeakerResNetPreTrainedModel:()=>qc,WhisperFeatureExtractor:()=>ld,WhisperForConditionalGeneration:()=>Wc,WhisperModel:()=>_y,WhisperPreTrainedModel:()=>ni,WhisperProcessor:()=>bf,WhisperTextStreamer:()=>s1,WhisperTimeStampLogitsProcessor:()=>$l,WhisperTokenizer:()=>Wp,XLMForQuestionAnswering:()=>vy,XLMForSequenceClassification:()=>yy,XLMForTokenClassification:()=>by,XLMModel:()=>wy,XLMPreTrainedModel:()=>Br,XLMRobertaForMaskedLM:()=>Ey,XLMRobertaForQuestionAnswering:()=>Ty,XLMRobertaForSequenceClassification:()=>Ay,XLMRobertaForTokenClassification:()=>My,XLMRobertaModel:()=>ky,XLMRobertaPreTrainedModel:()=>Fr,XLMRobertaTokenizer:()=>Vp,XLMTokenizer:()=>Hp,XLMWithLMHeadModel:()=>xy,XVectorOutput:()=>Gc,YolosFeatureExtractor:()=>Jd,YolosForObjectDetection:()=>Oy,YolosImageProcessor:()=>Sl,YolosModel:()=>Sy,YolosObjectDetectionOutput:()=>Vc,YolosPreTrainedModel:()=>oi,YoutuForCausalLM:()=>Cy,YoutuModel:()=>Iy,YoutuPreTrainedModel:()=>ai,ZeroShotAudioClassificationPipeline:()=>bi,ZeroShotClassificationPipeline:()=>xi,ZeroShotImageClassificationPipeline:()=>Ti,ZeroShotObjectDetectionPipeline:()=>Oi,cat:()=>Ee,cos_sim:()=>aE,dot:()=>S0,env:()=>me,full:()=>qe,full_like:()=>Nn,interpolate:()=>tp,interpolate_4d:()=>zt,layer_norm:()=>gL,load_image:()=>a2,load_video:()=>Q2,log_softmax:()=>$u,matmul:()=>kb,mean:()=>cl,mean_pooling:()=>Eb,ones:()=>st,ones_like:()=>ul,permute:()=>VA,pipeline:()=>mN,quantize_embeddings:()=>Tb,rand:()=>wL,randn:()=>Mb,random:()=>Xr,read_audio:()=>Yp,rfft:()=>_L,slice:()=>ll,softmax:()=>Ie,stack:()=>$t,std_mean:()=>rp,topk:()=>qt,zeros:()=>sp,zeros_like:()=>np});module.exports=pO(_N);var dk=kr(require("fs"),1),As=kr(require("path"),1),fk=kr(require("url"),1),AO={},dO="4.0.0-next.6",d0=typeof self<"u",bn=!gk(dk.default),mk=!gk(As.default),Au=d0&&"caches"in self,fO=typeof globalThis.Deno<"u",wN=typeof globalThis.Bun<"u",Tu=fO&&Au&&!bn,hk=typeof process<"u",_k=hk&&process?.release?.name==="node"&&!Tu,f0=typeof window<"u"&&typeof window.document<"u",m0=d0&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),mO=f0||m0||Tu,hO=_k||typeof navigator<"u"&&"gpu"in navigator,_O=typeof navigator<"u"&&"ml"in navigator,gO=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",wO=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",xO=typeof ServiceWorkerGlobalScope<"u"&&d0&&self instanceof ServiceWorkerGlobalScope,yO=()=>{if(typeof navigator>"u")return!1;let t=navigator.userAgent,r=(navigator.vendor||"").indexOf("Apple")>-1,s=!t.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!t.includes("Chrome")&&!t.includes("Android");return r&&s},bO=yO(),se=Object.freeze({IS_BROWSER_ENV:f0,IS_WEBWORKER_ENV:m0,IS_WEB_ENV:mO,IS_SERVICE_WORKER_ENV:xO,IS_DENO_WEB_RUNTIME:Tu,IS_WEB_CACHE_AVAILABLE:Au,IS_WEBGPU_AVAILABLE:hO,IS_WEBNN_AVAILABLE:_O,IS_SAFARI:bO,IS_PROCESS_AVAILABLE:hk,IS_NODE_ENV:_k,IS_FS_AVAILABLE:bn,IS_PATH_AVAILABLE:mk,IS_CRYPTO_AVAILABLE:gO,IS_CHROME_AVAILABLE:wO}),h0=bn&&mk,Mu="./";if(h0){let t=Object(AO).url;t?Mu=As.default.dirname(As.default.dirname(fk.default.fileURLToPath(t))):typeof __dirname<"u"&&(Mu=As.default.dirname(__dirname))}var vO=h0?As.default.join(Mu,"/.cache/"):null,uk="/models/",kO=h0?As.default.join(Mu,uk):uk,EO=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,vt=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),pk=vt.WARNING,me={version:dO,backends:{onnx:{}},get logLevel(){return pk},set logLevel(t){pk=t,me.backends.onnx?.setLogLevel?.(t)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(f0||m0||Tu),localModelPath:kO,useFS:bn,useBrowserCache:Au,useFSCache:bn,cacheDir:vO,useCustomCache:!1,customCache:null,useWasmCache:Au||bn,cacheKey:"transformers-cache",fetch:EO};function gk(t){return Object.keys(t).length===0}function Er(t,e){t&&t(e)}function wk(t){return Number.isInteger(t)||typeof t=="bigint"}function _0(t){return t==null||t===-1}function g0(t){let e=[],r=t;for(;Array.isArray(r);)e.push(r.length),r=r[0];return e}function ft(...t){return Array.prototype.concat.apply([],t)}function xk(...t){return t.reduce((e,r)=>e.flatMap(s=>r.map(n=>[s,n])))}function vn(t,e){return Math.abs((t+e)%(2*e)-e)}function ot(t,e){return Object.assign({},...e.map(r=>{if(t[r]!==void 0)return{[r]:t[r]}}))}function yk(t,e){let r=0;for(let s of t)s===e&&++r;return r}var J={error(...t){me.logLevel<=vt.ERROR&&console.error(...t)},warn(...t){me.logLevel<=vt.WARNING&&console.warn(...t)},info(...t){me.logLevel<=vt.INFO&&console.log(...t)},debug(...t){me.logLevel<=vt.DEBUG&&console.log(...t)},log(...t){this.info(...t)}};var MO=class{constructor(t){this.trie=this._build_trie(t)}_build_trie(t){let e=Object.create(null);for(let r of t){let s=e;for(let n=0;n<r.length;++n){let o=r[n];s=s[o]??=Object.create(null)}s.end=r}return e}split(t){let e=[],r=t.length,s=0,n=0;for(;n<r;){let o=this.trie,a=null,i=n;for(;i<r&&(o=o[t[i]]);)o.end&&(a=o.end),++i;a?(n>s&&e.push(t.slice(s,n)),e.push(a),n+=a.length,s=n):++n}return s<r&&e.push(t.slice(s)),e}},bk=MO,TO=class{constructor(t){this.content=t.content,this.id=t.id,this.single_word=t.single_word??!1,this.lstrip=t.lstrip??!1,this.rstrip=t.rstrip??!1,this.special=t.special??!1,this.normalized=t.normalized??!this.special}},SO=TO,Sk=(()=>{let t=[...Array.from({length:94},(n,o)=>o+33),...Array.from({length:12},(n,o)=>o+161),...Array.from({length:82},(n,o)=>o+174)],e=t.slice(),r=0;for(let n=0;n<256;++n)t.includes(n)||(t.push(n),e.push(256+r),r+=1);let s=e.map(n=>String.fromCharCode(n));return Object.fromEntries(t.map((n,o)=>[n,s[o]]))})(),OO=t=>Object.fromEntries(Object.entries(t).map(([e,r])=>[r,e])),IO=OO(Sk),vk=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",CO=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"],["(?i:[sdmt]|ll|ve|re)","(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])"],["[^\\r\\n\\p{L}\\p{N}]?+","[^\\r\\n\\p{L}\\p{N}]?"],["[^\\s\\p{L}\\p{N}]++","[^\\s\\p{L}\\p{N}]+"],["(?>\\p{Nd}{510})","(?:\\p{Nd}{510})"],["\\p{Nd}{3}+","(?:\\p{Nd}{3})+"],["\\G",""],[` ?[^(\\s|[${vk}])]+`,` ?[^\\s${vk}]+`]]),Su="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",x0=t=>t.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n't/g,"n't").replace(/ 'm/g,"'m").replace(/ 's/g,"'s").replace(/ 've/g,"'ve").replace(/ 're/g,"'re"),Ou=(t,e=!0)=>{if(t.Regex!==void 0){let r=t.Regex.replace(/\\([#&~])/g,"$1");r=r.replace(/\\A/g,"^").replace(/\\z/g,"$").replace(/\\Z/g,"(?=\\r?\\n?$)");for(let[s,n]of CO)r=r.replaceAll(s,n);try{return new RegExp(r,"gu")}catch(s){if(!(s instanceof SyntaxError)||!s.message.toLowerCase().includes("invalid property name"))throw s;let n=!1,o=r.replace(/(\\[pP])\{([^}=]+)\}/g,(a,i,l)=>{try{return new RegExp(`\\p{${l}}`,"u"),`${i}{${l}}`}catch{return n=!0,`${i}{Script=${l}}`}});if(!n)throw s;try{return new RegExp(o,"gu")}catch{throw s}}}else if(t.String!==void 0){let r=PO(t.String);return new RegExp(e?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",t),null},PO=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),LO=(t,e,r)=>{let s=[],n=0;for(;n<t.length;){if(s.push(t[n]),(e.get(t[n])??r)!==r){++n;continue}for(;++n<t.length&&(e.get(t[n])??r)===r;)e.get(s.at(-1))!==r&&(s[s.length-1]+=t[n])}return s},NO=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,zO=t=>Number.isInteger(t)||typeof t=="bigint",$O=t=>{let e=0;for(let r of t)++e;return e},RO=t=>Ok(t.toLowerCase()),Yt=(...t)=>Array.prototype.concat.apply([],t),y0=t=>new Map(Object.entries(t)),DO=(t,e)=>{let r=[],s=0;for(let n of t.matchAll(e)){let o=n[0];s<n.index&&r.push(t.slice(s,n.index)),o.length>0&&r.push(o),s=n.index+o.length}return s<t.length&&r.push(t.slice(s)),r},Ok=t=>t.replace(/\p{M}/gu,""),kk=(t,e,r=[])=>{if(!t||Array.isArray(t)||typeof t!="object")return`${e} must be a valid object`;for(let s of r)if(!(s in t))return`${e} must contain a "${s}" property`;return null},UO=t=>t.match(/\S+/g)||[],BO=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},ji=BO,FO=class extends ji{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},Ar=FO,jO=class extends Ar{tokenize_chinese_chars(t){let e=[];for(let r=0;r<t.length;++r){let s=t[r],n=s.charCodeAt(0);NO(n)?(e.push(" "),e.push(s),e.push(" ")):e.push(s)}return e.join("")}strip_accents(t){return t.normalize("NFD").replace(/\p{Mn}/gu,"")}is_control(t){switch(t){case" ":case`
|
|
2
|
-
`:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(t)}}clean_text(t){let e=[];for(let r of t){let s=r.charCodeAt(0);s===0||s===65533||this.is_control(r)||(/^\s$/.test(r)?e.push(" "):e.push(r))}return e.join("")}normalize(t){return this.config.clean_text&&(t=this.clean_text(t)),this.config.handle_chinese_chars&&(t=this.tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.strip_accents(t))):this.config.strip_accents&&(t=this.strip_accents(t)),t}},GO=jO,qO=class extends Ar{constructor(t){super(t),this.charsmap=t.precompiled_charsmap??null}normalize(t){return t=t.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),t=t.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," "),t.includes("\uFF5E")?t=t.split("\uFF5E").map(r=>r.normalize("NFKC")).join("\uFF5E"):t=t.normalize("NFKC"),t}},WO=qO,VO=class extends Ar{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>Ik(e))}normalize(t){return this.normalizers.reduce((e,r)=>r?r.normalize(e):e,t)}},HO=VO,XO=class extends Ar{normalize(t){let e=Ou(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},KO=XO,YO=class extends Ar{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Iu=YO,QO=class extends Iu{constructor(){super(...arguments),this.form="NFC"}},JO=QO,ZO=class extends Iu{constructor(){super(...arguments),this.form="NFD"}},eI=ZO,tI=class extends Iu{constructor(){super(...arguments),this.form="NFKC"}},rI=tI,sI=class extends Iu{constructor(){super(...arguments),this.form="NFKD"}},nI=sI,oI=class extends Ar{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}},aI=oI,iI=class extends Ar{normalize(t){return Ok(t)}},lI=iI,cI=class extends Ar{normalize(t){return t.toLowerCase()}},uI=cI,pI=class extends Ar{normalize(t){return t=this.config.prepend+t,t}},dI=pI;function fI(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new GO(t);case"Precompiled":return new WO(t);case"Sequence":return new HO(t);case"Replace":return new KO(t);case"NFC":return new JO(t);case"NFD":return new eI(t);case"NFKC":return new rI(t);case"NFKD":return new nI(t);case"Strip":return new aI(t);case"StripAccents":return new lI(t);case"Lowercase":return new uI(t);case"Prepend":return new dI(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var Ik=fI,mI=class extends ji{pre_tokenize(t,e){return(Array.isArray(t)?t.map(r=>this.pre_tokenize_text(r,e)):this.pre_tokenize_text(t,e)).flat()}_call(t,e){return this.pre_tokenize(t,e)}},Qt=mI,hI=class extends Qt{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=Sk,this.text_encoder=new TextEncoder}pre_tokenize_text(t,e){return this.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(s=>Array.from(this.text_encoder.encode(s),n=>this.byte_encoder[n]).join(""))}},_I=hI,gI=class extends Qt{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},wI=gI,xI=class extends Qt{constructor(t){super(),this.replacement=t.replacement??"\u2581",this.str_rep=t.str_rep||this.replacement,this.prepend_scheme=t.prepend_scheme??"always"}pre_tokenize_text(t,e){let{section_index:r=void 0}=e??{},s=t.replaceAll(" ",this.str_rep);return!s.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&r===0)&&(s=this.str_rep+s),[s]}},yI=xI,bI=class extends Qt{constructor(t){super(),this.config=t,this.pattern=Ou(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:this.config.behavior?.toLowerCase()==="removed"?t.split(this.pattern).filter(e=>e):DO(t,this.pattern)}},vI=bI,kI=class extends Qt{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${Su}]+|[${Su}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},EI=kI,AI=class extends Qt{constructor(t){super(),this.config=t;let e=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(e,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},MI=AI,TI=class extends Qt{constructor(){super(),this.pattern=new RegExp(`[^\\s${Su}]+|[${Su}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},SI=TI,OI=class extends Qt{constructor(t){super(),this.config=t,this.pattern=Ou(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},II=OI,CI=class extends Qt{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>Ck(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((r,s)=>s?s.pre_tokenize(r,e):r,[t])}},PI=CI,LI=class extends Qt{pre_tokenize_text(t){return UO(t)}},NI=LI,zI=class extends Qt{constructor(t){super(),this.config=t,this._length=t.length}pre_tokenize_text(t){let e=[];for(let r=0;r<t.length;r+=this._length)e.push(t.slice(r,r+this._length));return e}},$I=zI;function RI(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new SI;case"Sequence":return new PI(t);case"Whitespace":return new wI;case"WhitespaceSplit":return new NI;case"Metaspace":return new yI(t);case"ByteLevel":return new _I(t);case"Split":return new vI(t);case"Punctuation":return new EI(t);case"Digits":return new MI(t);case"Replace":return new II(t);case"FixedLength":return new $I(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var Ck=RI,DI=class extends ji{constructor(t){super(),this.config=t,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}_call(t){let e=this.encode(t);return this.fuse_unk&&(e=LO(e,this.tokens_to_ids,this.unk_token_id)),e}},Cu=DI,UI=class extends Cu{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=y0(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(let[e,r]of this.tokens_to_ids)this.vocab[r]=e}encode(t){let e=[];for(let r of t){let s=[...r];if(s.length>this.max_input_chars_per_word){e.push(this.unk_token);continue}let n=!1,o=0,a=[];for(;o<s.length;){let i=s.length,l=null;for(;o<i;){let u=s.slice(o,i).join("");if(o>0&&(u=this.config.continuing_subword_prefix+u),this.tokens_to_ids.has(u)){l=u;break}--i}if(l===null){n=!0;break}a.push(l),o=i}n?e.push(this.unk_token):e.push(...a)}return e}},Ek=UI,Ak=class Pk{constructor(e,r){this.is_leaf=e,this.children=r}static default(){return new Pk(!1,new Map)}},BI=class{constructor(){this.root=Ak.default()}extend(t){for(let e of t)this.push(e)}push(t){let e=this.root;for(let r of t){let s=e.children.get(r);s===void 0&&(s=Ak.default(),e.children.set(r,s)),e=s}e.is_leaf=!0}*common_prefix_search(t){let e=this.root;if(e===void 0)return;let r="";for(let s of t){if(r+=s,e=e.children.get(s),e===void 0)return;e.is_leaf&&(yield r)}}},FI=BI,w0=class Lk{constructor(e,r,s,n,o){this.token_id=e,this.node_id=r,this.pos=s,this.length=n,this.score=o,this.prev=null,this.backtrace_score=0}clone(){let e=new Lk(this.token_id,this.node_id,this.pos,this.length,this.score);return e.prev=this.prev,e.backtrace_score=this.backtrace_score,e}},jI=class{constructor(t,e,r){this.chars=Array.from(t),this.len=this.chars.length,this.bos_token_id=e,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},()=>[]);let s=new w0(this.bos_token_id??0,0,0,0,0),n=new w0(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(s.clone()),this.nodes.push(n.clone()),this.begin_nodes[this.len].push(n),this.end_nodes[0].push(s)}insert(t,e,r,s){let n=this.nodes.length,o=new w0(s,n,t,e,r);this.begin_nodes[t].push(o),this.end_nodes[t+e].push(o),this.nodes.push(o)}viterbi(){let t=this.len,e=0;for(;e<=t;){if(this.begin_nodes[e].length==0)return[];for(let a of this.begin_nodes[e]){a.prev=null;let i=0,l=null;for(let u of this.end_nodes[e]){let p=u.backtrace_score+a.score;(l===null||p>i)&&(l=u.clone(),i=p)}if(l!==null)a.prev=l,a.backtrace_score=i;else return[]}++e}let r=[],n=this.begin_nodes[t][0].prev;if(n===null)return[];let o=n.clone();for(;o.prev!==null;)r.push(o.clone()),o=o.clone().prev.clone();return r.reverse(),r}piece(t){return this.chars.slice(t.pos,t.pos+t.length).join("")}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}},GI=jI;function qI(t){if(t.length===0)throw new Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]<e&&(e=t[s],r=s);return[e,r]}var WI=class extends Cu{constructor(t,e){super(t);let r=t.vocab.length;this.vocab=new Array(r),this.scores=new Array(r);for(let s=0;s<r;++s)[this.vocab[s],this.scores[s]]=t.vocab[s];this.unk_token_id=t.unk_id,this.unk_token=this.vocab[t.unk_id],this.tokens_to_ids=new Map(this.vocab.map((s,n)=>[s,n])),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=qI(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new FI,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(t){let e=t.chars,r=1,s=0;for(;s<e.length;){let n=!1,o=[],a=e.slice(s).join(""),i=this.trie.common_prefix_search(a);for(let l of i){o.push(l);let u=this.tokens_to_ids.get(l),p=this.scores[u],f=$O(l);t.insert(s,f,p,u),!n&&f===r&&(n=!0)}n||t.insert(s,r,this.unk_score,this.unk_token_id),s+=r}}tokenize(t){let e=new GI(t,this.bos_token_id,this.eos_token_id);return this.populate_nodes(e),e.tokens()}encode(t){let e=[];for(let r of t){let s=this.tokenize(r);e.push(...s)}return e}},Mk=WI,VI=class{constructor(t=(r,s)=>r>s,e=1/0){this._heap=[],this._comparator=t,this._max_size=e}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(let e of t)if(this.size<this._max_size)this._heap.push(e),this._sift_up();else{let r=this._smallest();this._comparator(e,this._heap[r])&&(this._heap[r]=e,this._sift_up_from(r))}return this.size}pop(){let t=this.peek(),e=this.size-1;return e>0&&this._swap(0,e),this._heap.pop(),this._sift_down(),t}replace(t){let e=this.peek();return this._heap[0]=t,this._sift_down(),e}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,e){return this._comparator(this._heap[t],this._heap[e])}_swap(t,e){let r=this._heap[t];this._heap[t]=this._heap[e],this._heap[e]=r}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(t){for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_sift_down(){let t=0;for(;this._left(t)<this.size&&this._greater(this._left(t),t)||this._right(t)<this.size&&this._greater(this._right(t),t);){let e=this._right(t)<this.size&&this._greater(this._right(t),this._left(t))?this._right(t):this._left(t);this._swap(t,e),t=e}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},HI=VI,XI=class{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;let e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},KI=XI,YI=class extends Cu{constructor(t){super(t),this.tokens_to_ids=y0(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(let[r,s]of this.tokens_to_ids)this.vocab[s]=r;let e=Array.isArray(t.merges[0]);this.merges=e?t.merges:t.merges.map(r=>r.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((r,s)=>[JSON.stringify(r),s])),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new KI(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(t){if(t.length===0)return[];let e=this.cache.get(t);if(e!==void 0)return e;let r=Array.from(t);this.end_of_word_suffix&&(r[r.length-1]+=this.end_of_word_suffix);let s=[];if(r.length>1){let n=new HI((i,l)=>i.score<l.score),o={token:r[0],bias:0,prev:null,next:null},a=o;for(let i=1;i<r.length;++i){let l={bias:i/r.length,token:r[i],prev:a,next:null};a.next=l,this.add_node(n,a),a=l}for(;!n.is_empty();){let i=n.pop();if(i.deleted||!i.next||i.next.deleted)continue;if(i.deleted=!0,i.next.deleted=!0,i.prev){let u={...i.prev};i.prev.deleted=!0,i.prev=u,u.prev?u.prev.next=u:o=u}let l={token:i.token+i.next.token,bias:i.bias,prev:i.prev,next:i.next.next};l.prev?(l.prev.next=l,this.add_node(n,l.prev)):o=l,l.next&&(l.next.prev=l,this.add_node(n,l))}for(let i=o;i!==null;i=i.next)s.push(i.token)}else s=r;if(this.continuing_subword_suffix)for(let n=0;n<s.length-1;++n)s[n]+=this.continuing_subword_suffix;return t.length<this.max_length_to_cache&&this.cache.put(t,s),s}add_node(t,e){let r=this.bpe_ranks.get(JSON.stringify([e.token,e.next.token]));r!==void 0&&(e.score=r+e.bias,t.push(e))}encode(t){let e=[];for(let r of t){if(this.ignore_merges&&this.tokens_to_ids.has(r)){e.push(r);continue}let s=this.bpe(r);for(let n of s)if(this.tokens_to_ids.has(n))e.push(n);else if(this.byte_fallback){let o=Array.from(this.text_encoder.encode(n)).map(a=>`<0x${a.toString(16).toUpperCase().padStart(2,"0")}>`);o.every(a=>this.tokens_to_ids.has(a))?e.push(...o):e.push(this.unk_token)}else e.push(this.unk_token)}return e}},Tk=YI,QI=class extends Cu{constructor(t,e){super(t);let r=t.vocab;this.tokens_to_ids=y0(e.target_lang?r[e.target_lang]:r),this.bos_token=e.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=e.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=e.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(let[s,n]of this.tokens_to_ids)this.vocab[n]=s}encode(t){return t}},JI=QI;function ZI(t,e){switch(t.type){case"WordPiece":return new Ek(t);case"Unigram":return new Mk(t,e.eos_token);case"BPE":return new Tk(t);default:if(t.vocab)return Array.isArray(t.vocab)?new Mk(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new Tk(t):new Ek(t):new JI(t,{target_lang:e.target_lang,bos_token:e.bos_token,eos_token:e.eos_token,pad_token:e.pad_token,unk_token:e.unk_token});throw new Error(`Unknown TokenizerModel type: ${t?.type}`)}}var eC=ZI,tC=class extends ji{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},Gi=tC,rC=class extends Gi{post_process(t,e=null,r=!0){let s=e===null?this.config.single:this.config.pair,n=[],o=[];for(let a of s)"SpecialToken"in a?r&&(n.push(a.SpecialToken.id),o.push(a.SpecialToken.type_id)):"Sequence"in a&&(a.Sequence.id==="A"?(n=Yt(n,t),o=Yt(o,new Array(t.length).fill(a.Sequence.type_id))):a.Sequence.id==="B"&&(n=Yt(n,e),o=Yt(o,new Array(e.length).fill(a.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},sC=rC,nC=class extends Gi{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},oC=nC,aC=class extends Gi{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,r=!0){r&&(t=Yt([this.cls[0]],t,[this.sep[0]]));let s=new Array(t.length).fill(0);if(e){let n=[],o=r?[this.sep[0]]:[];t=Yt(t,n,e,o),s=Yt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},iC=aC,lC=class extends Gi{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,r=!0){r&&(t=Yt([this.cls[0]],t,[this.sep[0]]));let s=new Array(t.length).fill(0);if(e){let n=r?[this.sep[0]]:[],o=r?[this.sep[0]]:[];t=Yt(t,n,e,o),s=Yt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},cC=lC,uC=class extends Gi{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>Nk(e))}post_process(t,e=null,r=!0){let s={tokens:t,tokens_pair:e};for(let n of this.processors)s=n.post_process(s.tokens,s.tokens_pair,r);return s}},pC=uC;function dC(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new sC(t);case"ByteLevel":return new oC(t);case"BertProcessing":return new iC(t);case"RobertaProcessing":return new cC(t);case"Sequence":return new pC(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var Nk=dC,fC=class extends ji{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets="trim_offsets"in t?t.trim_offsets:!1}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}},Bt=fC,mC=class extends Bt{constructor(t){super(t),this.byte_decoder=IO,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let e=t.join(""),r=new Uint8Array([...e].map(s=>this.byte_decoder[s]));return this.text_decoder.decode(r)}decode_chain(t){let e=[],r=[];for(let s of t)this.added_tokens.find(n=>n.content===s)!==void 0?(r.length>0&&(e.push(this.convert_tokens_to_string(r)),r=[]),e.push(s)):r.push(s);return r.length>0&&e.push(this.convert_tokens_to_string(r)),e}},hC=mC,_C=class extends Bt{constructor(t){super(t),this.cleanup=t.cleanup}decode_chain(t){return t.map((e,r)=>{if(r!==0){let s=this.config.prefix;s&&e.startsWith(s)?e=e.replace(s,""):e=" "+e}return this.cleanup&&(e=x0(e)),e})}},gC=_C,wC=class extends Bt{constructor(t){super(t),this.replacement=t.replacement??"\u2581"}decode_chain(t){let e=[];for(let r=0;r<t.length;++r){let s=t[r].replaceAll(this.replacement," ");r==0&&s.startsWith(" ")&&(s=s.substring(1)),e.push(s)}return e}},xC=wC,yC=class extends Bt{constructor(t){super(t),this.suffix=t.suffix??""}decode_chain(t){return t.map((e,r)=>e.replaceAll(this.suffix,r===t.length-1?"":" "))}},bC=yC,vC=class extends Bt{constructor(t){super(t),this.pad_token=t.pad_token??"",this.word_delimiter_token=t.word_delimiter_token??"",this.cleanup=t.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let e=[t[0]];for(let n=1;n<t.length;++n)t[n]!==e.at(-1)&&e.push(t[n]);let s=e.filter(n=>n!==this.pad_token).join("");return this.cleanup&&(s=x0(s).replaceAll(this.word_delimiter_token," ").trim()),s}decode_chain(t){return[this.convert_tokens_to_string(t)]}},kC=vC,EC=class extends Bt{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>zk(e))}decode_chain(t){return this.decoders.reduce((e,r)=>r.decode_chain(e),t)}},AC=EC,MC=class extends Bt{decode_chain(t){let e=Ou(this.config.pattern),r=this.config.content??"";return e===null?t:t.map(s=>s.replaceAll(e,r))}},TC=MC,SC=class extends Bt{decode_chain(t){return[t.join("")]}},OC=SC,IC=class extends Bt{constructor(t){super(t),this.content=t.content??"",this.start=t.start??0,this.stop=t.stop??0}decode_chain(t){return t.map(e=>{let r=0;for(let n=0;n<this.start&&e[n]===this.content;++n){r=n+1;continue}let s=e.length;for(let n=0;n<this.stop;++n){let o=e.length-n-1;if(e[o]===this.content){s=o;continue}else break}return e.slice(r,s)})}},CC=IC,PC=class extends Bt{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let e=[],r=[];for(let s of t){let n=null;if(s.length===6&&s.startsWith("<0x")&&s.endsWith(">")){let o=parseInt(s.slice(3,5),16);isNaN(o)||(n=o)}if(n!==null)r.push(n);else{if(r.length>0){let o=this.text_decoder.decode(Uint8Array.from(r));e.push(o),r=[]}e.push(s)}}if(r.length>0){let s=this.text_decoder.decode(Uint8Array.from(r));e.push(s),r=[]}return e}},LC=PC;function NC(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new hC(t);case"WordPiece":return new gC(t);case"Metaspace":return new xC(t);case"BPEDecoder":return new bC(t);case"CTC":return new kC(t);case"Sequence":return new AC(t);case"Replace":return new TC(t);case"Fuse":return new OC(t);case"Strip":return new CC(t);case"ByteFallback":return new LC(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var zk=NC,zC=class{constructor(t,e){let r=kk(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);let s=kk(e,"Config");if(s)throw new Error(s);this.tokenizer=t,this.config=e,this.normalizer=Ik(this.tokenizer.normalizer),this.pre_tokenizer=Ck(this.tokenizer.pre_tokenizer),this.model=eC(this.tokenizer.model,this.config),this.post_processor=Nk(this.tokenizer.post_processor),this.decoder=zk(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let n=[],o=[];this.added_tokens_map=new Map;for(let a of this.tokenizer.added_tokens){let i=new SO(a);if(this.added_tokens.push(i),this.model.tokens_to_ids.set(i.content,i.id),this.model.vocab[i.id]=i.content,i.special&&(this.special_tokens.push(i.content),this.all_special_ids.push(i.id)),this.added_tokens_map.set(i.content,i),i.normalized&&this.normalizer!==null){let l=this.normalizer(i.content);o.push(l),this.added_tokens_map.set(l,i)}else n.push(i.content)}(this.config.additional_special_tokens??[]).forEach(a=>{this.special_tokens.includes(a)||this.special_tokens.push(a)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new bk(n),this.splitter_normalized=new bk(o),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(t,{text_pair:e=null,add_special_tokens:r=!0,return_token_type_ids:s=null}={}){let{tokens:n,token_type_ids:o}=this.tokenize_helper(t,{text_pair:e,add_special_tokens:r}),a=n.map(l=>this.added_tokens_map.get(l)?.id??this.model.tokens_to_ids.get(l)??this.model.unk_token_id),i={ids:a,tokens:n,attention_mask:new Array(a.length).fill(1)};return s&&o&&(i.token_type_ids=o),i}decode(t,e={}){if(!Array.isArray(t)||t.length===0||!zO(t[0]))throw Error("token_ids must be a non-empty array of integers.");let r=t.map(n=>this.model.vocab[Number(n)]??this.model.unk_token);e.skip_special_tokens&&(r=r.filter(n=>!this.special_tokens.includes(n)));let s=this.decoder?this.decoder(r):r.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(s=s.replaceAll(this.decoder.end_of_word_suffix," "),e.skip_special_tokens&&(s=s.trim())),(e.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(s=x0(s)),s}tokenize(t,{text_pair:e=null,add_special_tokens:r=!1}={}){return this.tokenize_helper(t,{text_pair:e,add_special_tokens:r}).tokens}encode_text(t){if(t===null)return null;let e=this.splitter_unnormalized.split(t);return e.forEach((r,s)=>{let n=this.added_tokens_map.get(r);n&&(n.lstrip&&s>0&&(e[s-1]=e[s-1].trimEnd()),n.rstrip&&s<e.length-1&&(e[s+1]=e[s+1].trimStart()))}),e.flatMap((r,s)=>{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=RO(r)),this.normalizer!==null&&(r=this.normalizer(r)),r.length===0)return[];let n=this.splitter_normalized.split(r);return n.forEach((o,a)=>{let i=this.added_tokens_map.get(o);i&&(i.lstrip&&a>0&&(n[a-1]=n[a-1].trimEnd()),i.rstrip&&a<n.length-1&&(n[a+1]=n[a+1].trimStart()))}),n.flatMap(o=>{if(o.length===0)return[];if(this.added_tokens_map.has(o))return[o];let a=this.pre_tokenizer!==null?this.pre_tokenizer(o,{section_index:s}):[o];return this.model(a)})})}tokenize_helper(t,{text_pair:e=null,add_special_tokens:r=!0}){let s=this.encode_text(t),n=this.encode_text(e||null);return this.post_processor?this.post_processor(s,n,r):{tokens:Yt(s??[],n??[])}}token_to_id(t){return this.model.tokens_to_ids.get(t)}id_to_token(t){return this.model.vocab[t]}get_added_tokens_decoder(){let t=new Map;for(let e of this.added_tokens)t.set(e.id,e);return t}get_vocab(t=!0){let e=new Map;for(let r=0;r<this.model.vocab.length;++r){let s=this.model.vocab[r];(t||!this.added_tokens_map.has(s))&&e.set(s,r)}return e}},$k=zC;var $=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),Ft=class{constructor(t,e){this.value=t,this.type=e}};function Rk(t){return/\w/.test(t)}function qi(t){return/[0-9]/.test(t)}function Dk(t){return/\s/.test(t)}var $C=[["{%",$.OpenStatement],["%}",$.CloseStatement],["{{",$.OpenExpression],["}}",$.CloseExpression],["(",$.OpenParen],[")",$.CloseParen],["{",$.OpenCurlyBracket],["}",$.CloseCurlyBracket],["[",$.OpenSquareBracket],["]",$.CloseSquareBracket],[",",$.Comma],[".",$.Dot],[":",$.Colon],["|",$.Pipe],["<=",$.ComparisonBinaryOperator],[">=",$.ComparisonBinaryOperator],["==",$.ComparisonBinaryOperator],["!=",$.ComparisonBinaryOperator],["<",$.ComparisonBinaryOperator],[">",$.ComparisonBinaryOperator],["+",$.AdditiveBinaryOperator],["-",$.AdditiveBinaryOperator],["~",$.AdditiveBinaryOperator],["*",$.MultiplicativeBinaryOperator],["/",$.MultiplicativeBinaryOperator],["%",$.MultiplicativeBinaryOperator],["=",$.Equals]],RC=new Map([["n",`
|
|
3
|
-
`],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function
|
|
4
|
-
`)&&(t=t.slice(0,-1)),e.lstrip_blocks&&(t=t.replace(/^[ \t]*({[#%-])/gm,"$1")),e.trim_blocks&&(t=t.replace(/([#%-]})\n/g,"$1")),t.replace(/{%\s*(end)?generation\s*%}/gs,"")}function UC(t,e={}){let r=[],s=DC(t,e),n=0,o=0,a=u=>{let p="";for(;u(s[n]);){if(s[n]==="\\"){if(++n,n>=s.length)throw new SyntaxError("Unexpected end of input");let f=s[n++],m=RC.get(f);if(m===void 0)throw new SyntaxError(`Unexpected escaped character: ${f}`);p+=m;continue}if(p+=s[n++],n>=s.length)throw new SyntaxError("Unexpected end of input")}return p},i=()=>{let u=r.at(-1);u&&u.type===$.Text&&(u.value=u.value.trimEnd(),u.value===""&&r.pop())},l=()=>{for(;n<s.length&&Dk(s[n]);)++n};e:for(;n<s.length;){let u=r.at(-1)?.type;if(u===void 0||u===$.CloseStatement||u===$.CloseExpression||u===$.Comment){let f="";for(;n<s.length&&!(s[n]==="{"&&(s[n+1]==="%"||s[n+1]==="{"||s[n+1]==="#"));)f+=s[n++];if(f.length>0){r.push(new Ft(f,$.Text));continue}}if(s[n]==="{"&&s[n+1]==="#"){n+=2;let f=s[n]==="-";f&&++n;let m="";for(;s[n]!=="#"||s[n+1]!=="}";){if(n+2>=s.length)throw new SyntaxError("Missing end of comment tag");m+=s[n++]}let h=m.endsWith("-");h&&(m=m.slice(0,-1)),f&&i(),r.push(new Ft(m,$.Comment)),n+=2,h&&l();continue}if(s.slice(n,n+3)==="{%-"){i(),r.push(new Ft("{%",$.OpenStatement)),n+=3;continue}if(s.slice(n,n+3)==="{{-"){i(),r.push(new Ft("{{",$.OpenExpression)),o=0,n+=3;continue}if(a(Dk),s.slice(n,n+3)==="-%}"){r.push(new Ft("%}",$.CloseStatement)),n+=3,l();continue}if(s.slice(n,n+3)==="-}}"){r.push(new Ft("}}",$.CloseExpression)),n+=3,l();continue}let p=s[n];if(p==="-"||p==="+"){let f=r.at(-1)?.type;if(f===$.Text||f===void 0)throw new SyntaxError(`Unexpected character: ${p}`);switch(f){case $.Identifier:case $.NumericLiteral:case $.StringLiteral:case $.CloseParen:case $.CloseSquareBracket:break;default:{++n;let m=a(qi);r.push(new Ft(`${p}${m}`,m.length>0?$.NumericLiteral:$.UnaryOperator));continue}}}for(let[f,m]of $C){if(f==="}}"&&o>0)continue;if(s.slice(n,n+f.length)===f){r.push(new Ft(f,m)),m===$.OpenExpression?o=0:m===$.OpenCurlyBracket?++o:m===$.CloseCurlyBracket&&--o,n+=f.length;continue e}}if(p==="'"||p==='"'){++n;let f=a(m=>m!==p);r.push(new Ft(f,$.StringLiteral)),++n;continue}if(qi(p)){let f=a(qi);if(s[n]==="."&&qi(s[n+1])){++n;let m=a(qi);f=`${f}.${m}`}r.push(new Ft(f,$.NumericLiteral));continue}if(Rk(p)){let f=a(Rk);r.push(new Ft(f,$.Identifier));continue}throw new SyntaxError(`Unexpected character: ${p}`)}return r}var Zt=class{type="Statement"},BC=class extends Zt{constructor(t){super(),this.body=t}type="Program"},FC=class extends Zt{constructor(t,e,r){super(),this.test=t,this.body=e,this.alternate=r}type="If"},jC=class extends Zt{constructor(t,e,r,s){super(),this.loopvar=t,this.iterable=e,this.body=r,this.defaultBlock=s}type="For"},GC=class extends Zt{type="Break"},qC=class extends Zt{type="Continue"},WC=class extends Zt{constructor(t,e,r){super(),this.assignee=t,this.value=e,this.body=r}type="Set"},VC=class extends Zt{constructor(t,e,r){super(),this.name=t,this.args=e,this.body=r}type="Macro"},HC=class extends Zt{constructor(t){super(),this.value=t}type="Comment"},Ct=class extends Zt{type="Expression"},XC=class extends Ct{constructor(t,e,r){super(),this.object=t,this.property=e,this.computed=r}type="MemberExpression"},Uk=class extends Ct{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},kn=class extends Ct{constructor(t){super(),this.value=t}type="Identifier"},En=class extends Ct{constructor(t){super(),this.value=t}type="Literal"},KC=class extends En{type="IntegerLiteral"},YC=class extends En{type="FloatLiteral"},Bk=class extends En{type="StringLiteral"},QC=class extends En{type="ArrayLiteral"},Fk=class extends En{type="TupleLiteral"},JC=class extends En{type="ObjectLiteral"},Wi=class extends Ct{constructor(t,e,r){super(),this.operator=t,this.left=e,this.right=r}type="BinaryExpression"},ZC=class extends Ct{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},eP=class extends Zt{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},tP=class extends Ct{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},rP=class extends Ct{constructor(t,e,r){super(),this.operand=t,this.negate=e,this.test=r}type="TestExpression"},sP=class extends Ct{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},nP=class extends Ct{constructor(t=void 0,e=void 0,r=void 0){super(),this.start=t,this.stop=e,this.step=r}type="SliceExpression"},oP=class extends Ct{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},aP=class extends Ct{constructor(t){super(),this.argument=t}type="SpreadExpression"},iP=class extends Zt{constructor(t,e,r){super(),this.call=t,this.callerArgs=e,this.body=r}type="CallStatement"},lP=class extends Ct{constructor(t,e,r){super(),this.condition=t,this.trueExpr=e,this.falseExpr=r}type="Ternary"};function cP(t){let e=new BC([]),r=0;function s(I,N){let R=t[r++];if(!R||R.type!==I)throw new Error(`Parser Error: ${N}. ${R.type} !== ${I}.`);return R}function n(I){if(!l(I))throw new SyntaxError(`Expected ${I}`);++r}function o(){switch(t[r].type){case $.Comment:return new HC(t[r++].value);case $.Text:return u();case $.OpenStatement:return p();case $.OpenExpression:return f();default:throw new SyntaxError(`Unexpected token type: ${t[r].type}`)}}function a(...I){return r+I.length<=t.length&&I.every((N,R)=>N===t[r+R].type)}function i(...I){return t[r]?.type===$.OpenStatement&&t[r+1]?.type===$.Identifier&&I.includes(t[r+1]?.value)}function l(...I){return r+I.length<=t.length&&I.every((N,R)=>t[r+R].type==="Identifier"&&N===t[r+R].value)}function u(){return new Bk(s($.Text,"Expected text token").value)}function p(){if(s($.OpenStatement,"Expected opening statement token"),t[r].type!==$.Identifier)throw new SyntaxError(`Unknown statement, got ${t[r].type}`);let I=t[r].value,N;switch(I){case"set":++r,N=m();break;case"if":++r,N=h(),s($.OpenStatement,"Expected {% token"),n("endif"),s($.CloseStatement,"Expected %} token");break;case"macro":++r,N=w(),s($.OpenStatement,"Expected {% token"),n("endmacro"),s($.CloseStatement,"Expected %} token");break;case"for":++r,N=v(),s($.OpenStatement,"Expected {% token"),n("endfor"),s($.CloseStatement,"Expected %} token");break;case"call":{++r;let R=null;a($.OpenParen)&&(R=W());let ee=ae();if(ee.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let de=W();s($.CloseStatement,"Expected closing statement token");let Fe=[];for(;!i("endcall");)Fe.push(o());s($.OpenStatement,"Expected '{%'"),n("endcall"),s($.CloseStatement,"Expected closing statement token");let Le=new Uk(ee,de);N=new iP(Le,R,Fe);break}case"break":++r,s($.CloseStatement,"Expected closing statement token"),N=new GC;break;case"continue":++r,s($.CloseStatement,"Expected closing statement token"),N=new qC;break;case"filter":{++r;let R=ae();R instanceof kn&&a($.OpenParen)&&(R=K(R)),s($.CloseStatement,"Expected closing statement token");let ee=[];for(;!i("endfilter");)ee.push(o());s($.OpenStatement,"Expected '{%'"),n("endfilter"),s($.CloseStatement,"Expected '%}'"),N=new eP(R,ee);break}default:throw new SyntaxError(`Unknown statement type: ${I}`)}return N}function f(){s($.OpenExpression,"Expected opening expression token");let I=E();return s($.CloseExpression,"Expected closing expression token"),I}function m(){let I=x(),N=null,R=[];if(a($.Equals))++r,N=x();else{for(s($.CloseStatement,"Expected %} token");!i("endset");)R.push(o());s($.OpenStatement,"Expected {% token"),n("endset")}return s($.CloseStatement,"Expected closing statement token"),new WC(I,N,R)}function h(){let I=E();s($.CloseStatement,"Expected closing statement token");let N=[],R=[];for(;!i("elif","else","endif");)N.push(o());if(i("elif")){++r,++r;let ee=h();R.push(ee)}else if(i("else"))for(++r,++r,s($.CloseStatement,"Expected closing statement token");!i("endif");)R.push(o());return new FC(I,N,R)}function w(){let I=ae();if(I.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let N=W();s($.CloseStatement,"Expected closing statement token");let R=[];for(;!i("endmacro");)R.push(o());return new VC(I,N,R)}function x(I=!1){let N=I?ae:E,R=[N()],ee=a($.Comma);for(;ee&&(++r,R.push(N()),!!a($.Comma)););return ee?new Fk(R):R[0]}function v(){let I=x(!0);if(!(I instanceof kn||I instanceof Fk))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${I.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;let N=E();s($.CloseStatement,"Expected closing statement token");let R=[];for(;!i("endfor","else");)R.push(o());let ee=[];if(i("else"))for(++r,++r,s($.CloseStatement,"Expected closing statement token");!i("endfor");)ee.push(o());return new jC(I,N,R,ee)}function E(){return A()}function A(){let I=S();if(l("if")){++r;let N=S();if(l("else")){++r;let R=A();return new lP(N,I,R)}else return new tP(I,N)}return I}function S(){let I=T();for(;l("or");){let N=t[r];++r;let R=T();I=new Wi(N,I,R)}return I}function T(){let I=L();for(;l("and");){let N=t[r];++r;let R=L();I=new Wi(N,I,R)}return I}function L(){let I;for(;l("not");){let N=t[r];++r;let R=L();I=new sP(N,R)}return I??P()}function P(){let I=k();for(;;){let N;if(l("not","in"))N=new Ft("not in",$.Identifier),r+=2;else if(l("in"))N=t[r++];else if(a($.ComparisonBinaryOperator))N=t[r++];else break;let R=k();I=new Wi(N,I,R)}return I}function k(){let I=U();for(;a($.AdditiveBinaryOperator);){let N=t[r];++r;let R=U();I=new Wi(N,I,R)}return I}function F(){let I=Y(ae());return a($.OpenParen)?K(I):I}function K(I){let N=new Uk(I,W());return N=Y(N),a($.OpenParen)&&(N=K(N)),N}function W(){s($.OpenParen,"Expected opening parenthesis for arguments list");let I=X();return s($.CloseParen,"Expected closing parenthesis for arguments list"),I}function X(){let I=[];for(;!a($.CloseParen);){let N;if(t[r].type===$.MultiplicativeBinaryOperator&&t[r].value==="*"){++r;let R=E();N=new aP(R)}else if(N=E(),a($.Equals)){if(++r,!(N instanceof kn))throw new SyntaxError("Expected identifier for keyword argument");let R=E();N=new oP(N,R)}I.push(N),a($.Comma)&&++r}return I}function H(){let I=[],N=!1;for(;!a($.CloseSquareBracket);)a($.Colon)?(I.push(void 0),++r,N=!0):(I.push(E()),a($.Colon)&&(++r,N=!0));if(I.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(N){if(I.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new nP(...I)}return I[0]}function Y(I){for(;a($.Dot)||a($.OpenSquareBracket);){let N=t[r];++r;let R,ee=N.type===$.OpenSquareBracket;if(ee)R=H(),s($.CloseSquareBracket,"Expected closing square bracket");else if(R=ae(),R.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");I=new XC(I,R,ee)}return I}function U(){let I=C();for(;a($.MultiplicativeBinaryOperator);){let N=t[r++],R=C();I=new Wi(N,I,R)}return I}function C(){let I=ne();for(;l("is");){++r;let N=l("not");N&&++r;let R=ae();if(!(R instanceof kn))throw new SyntaxError("Expected identifier for the test");I=new rP(I,N,R)}return I}function ne(){let I=F();for(;a($.Pipe);){++r;let N=ae();if(!(N instanceof kn))throw new SyntaxError("Expected identifier for the filter");a($.OpenParen)&&(N=K(N)),I=new ZC(I,N)}return I}function ae(){let I=t[r++];switch(I.type){case $.NumericLiteral:{let N=I.value;return N.includes(".")?new YC(Number(N)):new KC(Number(N))}case $.StringLiteral:{let N=I.value;for(;a($.StringLiteral);)N+=t[r++].value;return new Bk(N)}case $.Identifier:return new kn(I.value);case $.OpenParen:{let N=x();return s($.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),N}case $.OpenSquareBracket:{let N=[];for(;!a($.CloseSquareBracket);)N.push(E()),a($.Comma)&&++r;return++r,new QC(N)}case $.OpenCurlyBracket:{let N=new Map;for(;!a($.CloseCurlyBracket);){let R=E();s($.Colon,"Expected colon between key and value in object literal");let ee=E();N.set(R,ee),a($.Comma)&&++r}return++r,new JC(N)}default:throw new SyntaxError(`Unexpected token: ${I.type}`)}}for(;r<t.length;)e.body.push(o());return e}function uP(t,e,r=1){if(e===void 0&&(e=t,t=0),r===0)throw new Error("range() step must not be zero");let s=[];if(r>0)for(let n=t;n<e;n+=r)s.push(n);else for(let n=t;n>e;n+=r)s.push(n);return s}function jk(t,e,r,s=1){let n=Math.sign(s);n>=0?(e=(e??=0)<0?Math.max(t.length+e,0):Math.min(e,t.length),r=(r??=t.length)<0?Math.max(t.length+r,0):Math.min(r,t.length)):(e=(e??=t.length-1)<0?Math.max(t.length+e,-1):Math.min(e,t.length-1),r=(r??=-1)<-1?Math.max(t.length+r,-1):Math.min(r,t.length-1));let o=[];for(let a=e;n*a<n*r;a+=s)o.push(t[a]);return o}function pP(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function dP(t){return fP(new Date,t)}function fP(t,e){let r=new Intl.DateTimeFormat(void 0,{month:"long"}),s=new Intl.DateTimeFormat(void 0,{month:"short"}),n=o=>o<10?"0"+o:o.toString();return e.replace(/%[YmdbBHM%]/g,o=>{switch(o){case"%Y":return t.getFullYear().toString();case"%m":return n(t.getMonth()+1);case"%d":return n(t.getDate());case"%b":return s.format(t);case"%B":return r.format(t);case"%H":return n(t.getHours());case"%M":return n(t.getMinutes());case"%%":return"%";default:return o}})}function mP(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hP(t,e,r,s){if(s===0)return t;let n=s==null||s<0?1/0:s,o=e.length===0?new RegExp("(?=)","gu"):new RegExp(mP(e),"gu");return t.replaceAll(o,a=>n>0?(--n,r):a)}var Gk=class extends Error{},qk=class extends Error{},cr=class{type="RuntimeValue";value;builtins=new Map;constructor(t=void 0){this.value=t}__bool__(){return new ue(!!this.value)}toString(){return String(this.value)}},he=class extends cr{type="IntegerValue"},Ye=class extends cr{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},Z=class extends cr{type="StringValue";builtins=new Map([["upper",new Ge(()=>new Z(this.value.toUpperCase()))],["lower",new Ge(()=>new Z(this.value.toLowerCase()))],["strip",new Ge(()=>new Z(this.value.trim()))],["title",new Ge(()=>new Z(pP(this.value)))],["capitalize",new Ge(()=>new Z(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new he(this.value.length)],["rstrip",new Ge(()=>new Z(this.value.trimEnd()))],["lstrip",new Ge(()=>new Z(this.value.trimStart()))],["startswith",new Ge(t=>{if(t.length===0)throw new Error("startswith() requires at least one argument");let e=t[0];if(e instanceof Z)return new ue(this.value.startsWith(e.value));if(e instanceof ve){for(let r of e.value){if(!(r instanceof Z))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(r.value))return new ue(!0)}return new ue(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new Ge(t=>{if(t.length===0)throw new Error("endswith() requires at least one argument");let e=t[0];if(e instanceof Z)return new ue(this.value.endsWith(e.value));if(e instanceof ve){for(let r of e.value){if(!(r instanceof Z))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(r.value))return new ue(!0)}return new ue(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new Ge(t=>{let e=t[0]??new Ve;if(!(e instanceof Z||e instanceof Ve))throw new Error("sep argument must be a string or null");let r=t[1]??new he(-1);if(!(r instanceof he))throw new Error("maxsplit argument must be a number");let s=[];if(e instanceof Ve){let n=this.value.trimStart();for(let{0:o,index:a}of n.matchAll(/\S+/g)){if(r.value!==-1&&s.length>=r.value&&a!==void 0){s.push(o+n.slice(a+o.length));break}s.push(o)}}else{if(e.value==="")throw new Error("empty separator");s=this.value.split(e.value),r.value!==-1&&s.length>r.value&&s.push(s.splice(r.value).join(e.value))}return new ve(s.map(n=>new Z(n)))})],["replace",new Ge(t=>{if(t.length<2)throw new Error("replace() requires at least two arguments");let e=t[0],r=t[1];if(!(e instanceof Z&&r instanceof Z))throw new Error("replace() arguments must be strings");let s;if(t.length>2?t[2].type==="KeywordArgumentsValue"?s=t[2].value.get("count")??new Ve:s=t[2]:s=new Ve,!(s instanceof he||s instanceof Ve))throw new Error("replace() count argument must be a number or null");return new Z(hP(this.value,e.value,r.value,s.value))})]])},ue=class extends cr{type="BooleanValue"},_P=/[\x7f-\uffff]/g;function Wk(t){return t.replace(_P,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}function Ts(t,e={},r=0,s=!0){let{indent:n=null,ensureAscii:o=!1,separators:a=null,sortKeys:i=!1}=e,l,u;switch(a?[l,u]=a:n?(l=",",u=": "):(l=", ",u=": "),t.type){case"NullValue":return"null";case"UndefinedValue":return s?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(t.value);case"StringValue":{let p=JSON.stringify(t.value);return o&&(p=Wk(p)),p}case"ArrayValue":case"ObjectValue":{let p=n?" ".repeat(n):"",f=`
|
|
5
|
-
`+p.repeat(r),
|
|
1
|
+
var cI=Object.create;var Uu=Object.defineProperty;var uI=Object.getOwnPropertyDescriptor;var pI=Object.getOwnPropertyNames;var dI=Object.getPrototypeOf,fI=Object.prototype.hasOwnProperty;var Os=(t,e)=>{for(var r in e)Uu(t,r,{get:e[r],enumerable:!0})},nE=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pI(e))!fI.call(t,n)&&n!==r&&Uu(t,n,{get:()=>e[n],enumerable:!(s=uI(e,n))||s.enumerable});return t};var yr=(t,e,r)=>(r=t!=null?cI(dI(t)):{},nE(e||!t||!t.__esModule?Uu(r,"default",{value:t,enumerable:!0}):r,t)),_I=t=>nE(Uu({},"__esModule",{value:!0}),t);var PN={};Os(PN,{ASTFeatureExtractor:()=>hd,ASTForAudioClassification:()=>d_,ASTModel:()=>p_,ASTPreTrainedModel:()=>go,AfmoeForCausalLM:()=>l_,AfmoeModel:()=>i_,AfmoePreTrainedModel:()=>mo,AlbertForMaskedLM:()=>n_,AlbertForQuestionAnswering:()=>s_,AlbertForSequenceClassification:()=>r_,AlbertModel:()=>t_,AlbertPreTrainedModel:()=>cs,AlbertTokenizer:()=>Ep,ApertusForCausalLM:()=>a_,ApertusModel:()=>o_,ApertusPreTrainedModel:()=>_o,ArceeForCausalLM:()=>u_,ArceeModel:()=>c_,ArceePreTrainedModel:()=>ho,AudioClassificationPipeline:()=>Bi,AutoConfig:()=>Nt,AutoFeatureExtractor:()=>We,AutoImageProcessor:()=>Te,AutoModel:()=>dr,AutoModelForAudioClassification:()=>ku,AutoModelForAudioFrameClassification:()=>V1,AutoModelForAudioTextToText:()=>Y1,AutoModelForCTC:()=>vu,AutoModelForCausalLM:()=>mu,AutoModelForDepthEstimation:()=>Mu,AutoModelForDocumentQuestionAnswering:()=>Eu,AutoModelForImageClassification:()=>xu,AutoModelForImageFeatureExtraction:()=>Su,AutoModelForImageMatting:()=>H1,AutoModelForImageSegmentation:()=>Oi,AutoModelForImageTextToText:()=>Q1,AutoModelForImageToImage:()=>Au,AutoModelForMaskGeneration:()=>q1,AutoModelForMaskedLM:()=>hu,AutoModelForNormalEstimation:()=>X1,AutoModelForObjectDetection:()=>yu,AutoModelForPoseEstimation:()=>K1,AutoModelForQuestionAnswering:()=>gu,AutoModelForSemanticSegmentation:()=>Ii,AutoModelForSeq2SeqLM:()=>En,AutoModelForSequenceClassification:()=>Ti,AutoModelForSpeechSeq2Seq:()=>du,AutoModelForTextToSpectrogram:()=>fu,AutoModelForTextToWaveform:()=>_u,AutoModelForTokenClassification:()=>pu,AutoModelForUniversalSegmentation:()=>Ci,AutoModelForVision2Seq:()=>wu,AutoModelForXVector:()=>W1,AutoModelForZeroShotObjectDetection:()=>bu,AutoProcessor:()=>Zl,AutoTokenizer:()=>oe,AutomaticSpeechRecognitionPipeline:()=>ji,BackgroundRemovalPipeline:()=>Vi,BartForConditionalGeneration:()=>__,BartForSequenceClassification:()=>m_,BartModel:()=>f_,BartPretrainedModel:()=>rn,BartTokenizer:()=>Ap,BaseStreamer:()=>M0,BeitFeatureExtractor:()=>Nd,BeitForImageClassification:()=>g_,BeitModel:()=>h_,BeitPreTrainedModel:()=>wo,BertForMaskedLM:()=>x_,BertForQuestionAnswering:()=>v_,BertForSequenceClassification:()=>y_,BertForTokenClassification:()=>b_,BertModel:()=>w_,BertPreTrainedModel:()=>Mr,BertTokenizer:()=>Mp,BitImageProcessor:()=>$d,BlenderbotForConditionalGeneration:()=>E_,BlenderbotModel:()=>k_,BlenderbotPreTrainedModel:()=>xo,BlenderbotSmallForConditionalGeneration:()=>M_,BlenderbotSmallModel:()=>A_,BlenderbotSmallPreTrainedModel:()=>yo,BlenderbotSmallTokenizer:()=>Sp,BlenderbotTokenizer:()=>Tp,BloomForCausalLM:()=>T_,BloomModel:()=>S_,BloomPreTrainedModel:()=>bo,BloomTokenizer:()=>Op,CHMv2ForDepthEstimation:()=>N_,CHMv2ImageProcessor:()=>Dd,CHMv2PreTrainedModel:()=>hc,CLIPFeatureExtractor:()=>Fd,CLIPImageProcessor:()=>$l,CLIPModel:()=>R_,CLIPPreTrainedModel:()=>tr,CLIPSegForImageSegmentation:()=>j_,CLIPSegModel:()=>U_,CLIPSegPreTrainedModel:()=>Mo,CLIPTextModel:()=>D_,CLIPTextModelWithProjection:()=>Ao,CLIPTokenizer:()=>Cp,CLIPVisionModel:()=>F_,CLIPVisionModelWithProjection:()=>B_,CamembertForMaskedLM:()=>I_,CamembertForQuestionAnswering:()=>P_,CamembertForSequenceClassification:()=>C_,CamembertForTokenClassification:()=>L_,CamembertModel:()=>O_,CamembertPreTrainedModel:()=>Sr,CamembertTokenizer:()=>Ip,ChatterboxFeatureExtractor:()=>gd,ChatterboxModel:()=>vo,ChatterboxPreTrainedModel:()=>_c,ChatterboxProcessor:()=>Id,ChineseCLIPFeatureExtractor:()=>Rd,ChineseCLIPModel:()=>z_,ChineseCLIPPreTrainedModel:()=>mc,ClapAudioModelWithProjection:()=>Eo,ClapFeatureExtractor:()=>wd,ClapModel:()=>$_,ClapPreTrainedModel:()=>sn,ClapTextModelWithProjection:()=>ko,ClassifierFreeGuidanceLogitsProcessor:()=>lc,CodeGenForCausalLM:()=>q_,CodeGenModel:()=>G_,CodeGenPreTrainedModel:()=>So,CodeGenTokenizer:()=>Pp,CodeLlamaTokenizer:()=>Lp,Cohere2ForCausalLM:()=>X_,Cohere2Model:()=>H_,Cohere2PreTrainedModel:()=>Oo,CohereForCausalLM:()=>V_,CohereModel:()=>W_,CoherePreTrainedModel:()=>To,CohereTokenizer:()=>zp,ConvBertForMaskedLM:()=>Q_,ConvBertForQuestionAnswering:()=>Z_,ConvBertForSequenceClassification:()=>Y_,ConvBertForTokenClassification:()=>J_,ConvBertModel:()=>K_,ConvBertPreTrainedModel:()=>Tr,ConvBertTokenizer:()=>Np,ConvNextFeatureExtractor:()=>Bd,ConvNextForImageClassification:()=>tm,ConvNextImageProcessor:()=>Rl,ConvNextModel:()=>em,ConvNextPreTrainedModel:()=>Io,ConvNextV2ForImageClassification:()=>sm,ConvNextV2Model:()=>rm,ConvNextV2PreTrainedModel:()=>Co,DFineForObjectDetection:()=>im,DFineModel:()=>am,DFinePreTrainedModel:()=>Po,DINOv3ConvNextModel:()=>Pm,DINOv3ConvNextPreTrainedModel:()=>kc,DINOv3ViTImageProcessor:()=>Gd,DINOv3ViTModel:()=>zm,DINOv3ViTPreTrainedModel:()=>Ec,DPTFeatureExtractor:()=>Wd,DPTForDepthEstimation:()=>jm,DPTImageProcessor:()=>Bl,DPTModel:()=>Um,DPTPreTrainedModel:()=>Bo,DacDecoderModel:()=>No,DacDecoderOutput:()=>wc,DacEncoderModel:()=>zo,DacEncoderOutput:()=>gc,DacFeatureExtractor:()=>Qn,DacModel:()=>lm,DacPreTrainedModel:()=>nn,DebertaForMaskedLM:()=>um,DebertaForQuestionAnswering:()=>fm,DebertaForSequenceClassification:()=>pm,DebertaForTokenClassification:()=>dm,DebertaModel:()=>cm,DebertaPreTrainedModel:()=>Or,DebertaTokenizer:()=>Rp,DebertaV2ForMaskedLM:()=>gm,DebertaV2ForQuestionAnswering:()=>ym,DebertaV2ForSequenceClassification:()=>wm,DebertaV2ForTokenClassification:()=>xm,DebertaV2Model:()=>hm,DebertaV2PreTrainedModel:()=>Ir,DebertaV2Tokenizer:()=>$p,DecisionTransformerModel:()=>bm,DecisionTransformerPreTrainedModel:()=>xc,DeepseekV3ForCausalLM:()=>mm,DeepseekV3Model:()=>_m,DeepseekV3PreTrainedModel:()=>$o,DeiTFeatureExtractor:()=>Ud,DeiTForImageClassification:()=>km,DeiTImageProcessor:()=>Dl,DeiTModel:()=>vm,DeiTPreTrainedModel:()=>Ro,DepthAnythingForDepthEstimation:()=>Em,DepthAnythingPreTrainedModel:()=>yc,DepthEstimationPipeline:()=>Ji,DepthProForDepthEstimation:()=>Am,DepthProPreTrainedModel:()=>bc,DetrFeatureExtractor:()=>jd,DetrForObjectDetection:()=>Sm,DetrForSegmentation:()=>Tm,DetrImageProcessor:()=>Fl,DetrModel:()=>Mm,DetrObjectDetectionOutput:()=>an,DetrPreTrainedModel:()=>on,DetrSegmentationOutput:()=>vc,Dinov2ForImageClassification:()=>Im,Dinov2Model:()=>Om,Dinov2PreTrainedModel:()=>Do,Dinov2WithRegistersForImageClassification:()=>Lm,Dinov2WithRegistersModel:()=>Cm,Dinov2WithRegistersPreTrainedModel:()=>Fo,DistilBertForMaskedLM:()=>Fm,DistilBertForQuestionAnswering:()=>Dm,DistilBertForSequenceClassification:()=>$m,DistilBertForTokenClassification:()=>Rm,DistilBertModel:()=>Nm,DistilBertPreTrainedModel:()=>Cr,DistilBertTokenizer:()=>Dp,DocumentQuestionAnsweringPipeline:()=>Qi,DonutFeatureExtractor:()=>qd,DonutImageProcessor:()=>Vs,DonutSwinModel:()=>Bm,DonutSwinPreTrainedModel:()=>Ac,DynamicCache:()=>co,EdgeTamModel:()=>Xx,EfficientNetForImageClassification:()=>qm,EfficientNetImageProcessor:()=>Vd,EfficientNetModel:()=>Gm,EfficientNetPreTrainedModel:()=>Uo,ElectraForMaskedLM:()=>Vm,ElectraForQuestionAnswering:()=>Km,ElectraForSequenceClassification:()=>Hm,ElectraForTokenClassification:()=>Xm,ElectraModel:()=>Wm,ElectraPreTrainedModel:()=>Lr,ElectraTokenizer:()=>Fp,EncodecFeatureExtractor:()=>Kn,EosTokenCriteria:()=>pc,Ernie4_5ForCausalLM:()=>Ym,Ernie4_5Model:()=>Qm,Ernie4_5PretrainedModel:()=>jo,EsmForMaskedLM:()=>Zm,EsmForSequenceClassification:()=>eh,EsmForTokenClassification:()=>th,EsmModel:()=>Jm,EsmPreTrainedModel:()=>us,EsmTokenizer:()=>Bp,EuroBertForMaskedLM:()=>sh,EuroBertForSequenceClassification:()=>nh,EuroBertForTokenClassification:()=>oh,EuroBertModel:()=>rh,EuroBertPreTrainedModel:()=>ps,ExaoneForCausalLM:()=>ih,ExaoneModel:()=>ah,ExaonePreTrainedModel:()=>Go,FalconForCausalLM:()=>ch,FalconH1ForCausalLM:()=>ph,FalconH1Model:()=>uh,FalconH1PreTrainedModel:()=>Wo,FalconModel:()=>lh,FalconPreTrainedModel:()=>qo,FalconTokenizer:()=>Up,FastViTForImageClassification:()=>fh,FastViTModel:()=>dh,FastViTPreTrainedModel:()=>Vo,FeatureExtractionPipeline:()=>Zi,FeatureExtractor:()=>Ee,FillMaskPipeline:()=>Ni,Florence2ForConditionalGeneration:()=>_h,Florence2PreTrainedModel:()=>Mc,Florence2Processor:()=>kf,ForcedBOSTokenLogitsProcessor:()=>ec,ForcedEOSTokenLogitsProcessor:()=>tc,GLPNFeatureExtractor:()=>Xd,GLPNForDepthEstimation:()=>Sh,GLPNModel:()=>Mh,GLPNPreTrainedModel:()=>Zo,GPT2LMHeadModel:()=>Rh,GPT2Model:()=>$h,GPT2PreTrainedModel:()=>na,GPT2Tokenizer:()=>qp,GPTBigCodeForCausalLM:()=>Oh,GPTBigCodeModel:()=>Th,GPTBigCodePreTrainedModel:()=>ea,GPTJForCausalLM:()=>Fh,GPTJModel:()=>Dh,GPTJPreTrainedModel:()=>oa,GPTNeoForCausalLM:()=>Ch,GPTNeoModel:()=>Ih,GPTNeoPreTrainedModel:()=>ta,GPTNeoXForCausalLM:()=>Ph,GPTNeoXModel:()=>Lh,GPTNeoXPreTrainedModel:()=>ra,GPTNeoXTokenizer:()=>Gp,Gemma2ForCausalLM:()=>wh,Gemma2Model:()=>gh,Gemma2PreTrainedModel:()=>Xo,Gemma3ForCausalLM:()=>yh,Gemma3Model:()=>xh,Gemma3PreTrainedModel:()=>Ko,Gemma3nAudioFeatureExtractor:()=>xd,Gemma3nForCausalLM:()=>Qo,Gemma3nForConditionalGeneration:()=>ln,Gemma3nPreTrainedModel:()=>Sc,Gemma3nProcessor:()=>Ef,GemmaForCausalLM:()=>hh,GemmaModel:()=>mh,GemmaPreTrainedModel:()=>Ho,GemmaTokenizer:()=>jp,Glm46VImageProcessor:()=>Hd,Glm46VProcessor:()=>Af,GlmForCausalLM:()=>vh,GlmModel:()=>bh,GlmMoeDsaForCausalLM:()=>Eh,GlmMoeDsaModel:()=>kh,GlmMoeDsaPreTrainedModel:()=>Jo,GlmOcrForConditionalGeneration:()=>Ah,GlmPreTrainedModel:()=>Yo,GptOssForCausalLM:()=>Nh,GptOssModel:()=>zh,GptOssPreTrainedModel:()=>sa,GraniteForCausalLM:()=>Uh,GraniteModel:()=>Bh,GraniteMoeHybridForCausalLM:()=>Gh,GraniteMoeHybridModel:()=>jh,GraniteMoeHybridPreTrainedModel:()=>ia,GranitePreTrainedModel:()=>aa,GraniteSpeechFeatureExtractor:()=>yd,GraniteSpeechForConditionalGeneration:()=>qh,GraniteSpeechProcessor:()=>Mf,GroundingDinoForObjectDetection:()=>Wh,GroundingDinoImageProcessor:()=>Kd,GroundingDinoPreTrainedModel:()=>Ic,GroundingDinoProcessor:()=>Sf,GroupViTModel:()=>Vh,GroupViTPreTrainedModel:()=>Cc,HeliumForCausalLM:()=>Xh,HeliumModel:()=>Hh,HeliumPreTrainedModel:()=>la,HerbertTokenizer:()=>Wp,HieraForImageClassification:()=>Qh,HieraModel:()=>Kh,HieraPreTrainedModel:()=>ca,HubertForCTC:()=>sg,HubertForSequenceClassification:()=>ng,HubertModel:()=>rg,HubertPreTrainedModel:()=>tg,HunYuanDenseV1ForCausalLM:()=>ag,HunYuanDenseV1Model:()=>og,HunYuanDenseV1PreTrainedModel:()=>ua,IJepaForImageClassification:()=>pg,IJepaModel:()=>ug,IJepaPreTrainedModel:()=>pa,Idefics3ForConditionalGeneration:()=>cg,Idefics3ImageProcessor:()=>Ul,Idefics3Processor:()=>Yl,ImageClassificationPipeline:()=>Wi,ImageFeatureExtractionPipeline:()=>el,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,ImageSegmentationPipeline:()=>As,ImageToImagePipeline:()=>Yi,ImageToTextPipeline:()=>qi,InterruptableStoppingCriteria:()=>P1,JAISLMHeadModel:()=>fg,JAISModel:()=>dg,JAISPreTrainedModel:()=>da,JinaCLIPImageProcessor:()=>Yd,JinaCLIPModel:()=>_g,JinaCLIPPreTrainedModel:()=>un,JinaCLIPProcessor:()=>Of,JinaCLIPTextModel:()=>fa,JinaCLIPVisionModel:()=>mg,Lfm2ForCausalLM:()=>gg,Lfm2Model:()=>hg,Lfm2MoeForCausalLM:()=>yg,Lfm2MoeModel:()=>xg,Lfm2MoePreTrainedModel:()=>ma,Lfm2PreTrainedModel:()=>_a,Lfm2VlForConditionalGeneration:()=>bg,Lfm2VlImageProcessor:()=>Jd,Lfm2VlProcessor:()=>If,LightOnOcrForConditionalGeneration:()=>wg,LiteWhisperForConditionalGeneration:()=>l0,Llama4ForCausalLM:()=>Eg,Llama4PreTrainedModel:()=>Pc,LlamaForCausalLM:()=>kg,LlamaModel:()=>vg,LlamaPreTrainedModel:()=>ha,LlamaTokenizer:()=>Vp,LlavaForConditionalGeneration:()=>Tt,LlavaOnevisionForConditionalGeneration:()=>Tt,LlavaOnevisionImageProcessor:()=>Zd,LlavaPreTrainedModel:()=>Lc,LlavaProcessor:()=>Cf,LlavaQwen2ForCausalLM:()=>lg,LogLevel:()=>Mt,LogitsProcessor:()=>$t,LogitsProcessorList:()=>ls,LogitsWarper:()=>io,LongT5ForConditionalGeneration:()=>Mg,LongT5Model:()=>Ag,LongT5PreTrainedModel:()=>ga,M2M100ForConditionalGeneration:()=>Tg,M2M100Model:()=>Sg,M2M100PreTrainedModel:()=>wa,M2M100Tokenizer:()=>Hp,MBart50Tokenizer:()=>Kp,MBartForCausalLM:()=>$g,MBartForConditionalGeneration:()=>zg,MBartForSequenceClassification:()=>Ng,MBartModel:()=>Pg,MBartPreTrainedModel:()=>hs,MBartTokenizer:()=>Hn,MPNetForMaskedLM:()=>vw,MPNetForQuestionAnswering:()=>Aw,MPNetForSequenceClassification:()=>kw,MPNetForTokenClassification:()=>Ew,MPNetModel:()=>bw,MPNetPreTrainedModel:()=>Pr,MPNetTokenizer:()=>Jp,MT5ForConditionalGeneration:()=>Ow,MT5Model:()=>Tw,MT5PreTrainedModel:()=>Ca,MarianMTModel:()=>Ig,MarianModel:()=>Og,MarianPreTrainedModel:()=>xa,MarianTokenizer:()=>Xp,Mask2FormerImageProcessor:()=>tf,MaskFormerFeatureExtractor:()=>ef,MaskFormerForInstanceSegmentation:()=>Lg,MaskFormerImageProcessor:()=>Hs,MaskFormerModel:()=>Cg,MaskFormerPreTrainedModel:()=>ya,MaxLengthCriteria:()=>uc,Metric3DForDepthEstimation:()=>Rg,Metric3DPreTrainedModel:()=>zc,Metric3Dv2ForDepthEstimation:()=>Dg,Metric3Dv2PreTrainedModel:()=>Nc,MgpstrForSceneTextRecognition:()=>Fg,MgpstrModelOutput:()=>$c,MgpstrPreTrainedModel:()=>Rc,MgpstrProcessor:()=>Lf,MgpstrTokenizer:()=>Qp,MimiDecoderModel:()=>va,MimiDecoderOutput:()=>Fc,MimiEncoderModel:()=>ba,MimiEncoderOutput:()=>Dc,MimiModel:()=>Bg,MimiPreTrainedModel:()=>pn,MinLengthLogitsProcessor:()=>oc,MinNewTokensLengthLogitsProcessor:()=>ac,Mistral4ForCausalLM:()=>qg,Mistral4Model:()=>Gg,Mistral4PreTrainedModel:()=>Ea,MistralForCausalLM:()=>jg,MistralModel:()=>Ug,MistralPreTrainedModel:()=>ka,MobileBertForMaskedLM:()=>Vg,MobileBertForQuestionAnswering:()=>Xg,MobileBertForSequenceClassification:()=>Hg,MobileBertModel:()=>Wg,MobileBertPreTrainedModel:()=>gs,MobileBertTokenizer:()=>Yp,MobileLLMForCausalLM:()=>Qg,MobileLLMModel:()=>Kg,MobileLLMPreTrainedModel:()=>Aa,MobileNetV1FeatureExtractor:()=>rf,MobileNetV1ForImageClassification:()=>Jg,MobileNetV1ForSemanticSegmentation:()=>Zg,MobileNetV1ImageProcessor:()=>jl,MobileNetV1Model:()=>Yg,MobileNetV1PreTrainedModel:()=>dn,MobileNetV2FeatureExtractor:()=>sf,MobileNetV2ForImageClassification:()=>tw,MobileNetV2ForSemanticSegmentation:()=>rw,MobileNetV2ImageProcessor:()=>Gl,MobileNetV2Model:()=>ew,MobileNetV2PreTrainedModel:()=>fn,MobileNetV3FeatureExtractor:()=>nf,MobileNetV3ForImageClassification:()=>nw,MobileNetV3ForSemanticSegmentation:()=>ow,MobileNetV3ImageProcessor:()=>ql,MobileNetV3Model:()=>sw,MobileNetV3PreTrainedModel:()=>_n,MobileNetV4FeatureExtractor:()=>of,MobileNetV4ForImageClassification:()=>iw,MobileNetV4ForSemanticSegmentation:()=>lw,MobileNetV4ImageProcessor:()=>Wl,MobileNetV4Model:()=>aw,MobileNetV4PreTrainedModel:()=>mn,MobileViTFeatureExtractor:()=>af,MobileViTForImageClassification:()=>uw,MobileViTImageProcessor:()=>Vl,MobileViTModel:()=>cw,MobileViTPreTrainedModel:()=>Ma,MobileViTV2ForImageClassification:()=>dw,MobileViTV2Model:()=>pw,MobileViTV2PreTrainedModel:()=>Sa,ModelRegistry:()=>O0,ModernBertDecoderForCausalLM:()=>ww,ModernBertDecoderModel:()=>gw,ModernBertDecoderPreTrainedModel:()=>Ta,ModernBertForMaskedLM:()=>_w,ModernBertForSequenceClassification:()=>mw,ModernBertForTokenClassification:()=>hw,ModernBertModel:()=>fw,ModernBertPreTrainedModel:()=>ws,Moondream1ForConditionalGeneration:()=>ig,MoonshineFeatureExtractor:()=>bd,MoonshineForConditionalGeneration:()=>yw,MoonshineModel:()=>xw,MoonshinePreTrainedModel:()=>Oa,MoonshineProcessor:()=>Pf,MptForCausalLM:()=>Sw,MptModel:()=>Mw,MptPreTrainedModel:()=>Ia,MultiModalityCausalLM:()=>Iw,MultiModalityPreTrainedModel:()=>Bc,MusicgenForCausalLM:()=>Lw,MusicgenForConditionalGeneration:()=>Pa,MusicgenModel:()=>Cw,MusicgenPreTrainedModel:()=>La,NanoChatForCausalLM:()=>zw,NanoChatModel:()=>Pw,NanoChatPreTrainedModel:()=>za,NemotronHForCausalLM:()=>$w,NemotronHModel:()=>Nw,NemotronHPreTrainedModel:()=>Na,NeoBertForMaskedLM:()=>Dw,NeoBertForQuestionAnswering:()=>Uw,NeoBertForSequenceClassification:()=>Fw,NeoBertForTokenClassification:()=>Bw,NeoBertModel:()=>Rw,NeoBertPreTrainedModel:()=>zr,NllbTokenizer:()=>Zp,NoBadWordsLogitsProcessor:()=>ic,NoRepeatNGramLogitsProcessor:()=>sc,NomicBertModel:()=>jw,NomicBertPreTrainedModel:()=>Uc,NougatImageProcessor:()=>lf,NougatTokenizer:()=>ed,OPTForCausalLM:()=>ex,OPTModel:()=>Zw,OPTPreTrainedModel:()=>Ua,ObjectDetectionPipeline:()=>Xi,Olmo2ForCausalLM:()=>Vw,Olmo2Model:()=>Ww,Olmo2PreTrainedModel:()=>Ra,Olmo3ForCausalLM:()=>Xw,Olmo3Model:()=>Hw,Olmo3PreTrainedModel:()=>Da,OlmoForCausalLM:()=>qw,OlmoHybridForCausalLM:()=>Qw,OlmoHybridModel:()=>Kw,OlmoHybridPreTrainedModel:()=>Fa,OlmoModel:()=>Gw,OlmoPreTrainedModel:()=>$a,OpenELMForCausalLM:()=>Jw,OpenELMModel:()=>Yw,OpenELMPreTrainedModel:()=>Ba,OwlViTFeatureExtractor:()=>cf,OwlViTForObjectDetection:()=>nx,OwlViTImageProcessor:()=>Xs,OwlViTModel:()=>sx,OwlViTPreTrainedModel:()=>Ga,OwlViTProcessor:()=>zf,Owlv2ForObjectDetection:()=>rx,Owlv2ImageProcessor:()=>uf,Owlv2Model:()=>tx,Owlv2PreTrainedModel:()=>ja,PaliGemmaForConditionalGeneration:()=>ox,PaliGemmaProcessor:()=>Nf,ParakeetFeatureExtractor:()=>vd,ParakeetForCTC:()=>ax,ParakeetPreTrainedModel:()=>jc,PatchTSMixerForPrediction:()=>lx,PatchTSMixerModel:()=>ix,PatchTSMixerPreTrainedModel:()=>qa,PatchTSTForPrediction:()=>ux,PatchTSTModel:()=>cx,PatchTSTPreTrainedModel:()=>Wa,Phi3ForCausalLM:()=>_x,Phi3Model:()=>fx,Phi3PreTrainedModel:()=>Ha,Phi3VForCausalLM:()=>Xa,Phi3VImageProcessor:()=>pf,Phi3VPreTrainedModel:()=>Gc,Phi3VProcessor:()=>$f,PhiForCausalLM:()=>dx,PhiModel:()=>px,PhiPreTrainedModel:()=>Va,PixtralImageProcessor:()=>df,PixtralProcessor:()=>Rf,PreTrainedModel:()=>y,PreTrainedTokenizer:()=>q,PretrainedConfig:()=>Ks,Processor:()=>re,PvtForImageClassification:()=>hx,PvtImageProcessor:()=>ff,PvtModel:()=>mx,PvtPreTrainedModel:()=>Ka,PyAnnoteFeatureExtractor:()=>Yn,PyAnnoteForAudioFrameClassification:()=>wx,PyAnnoteModel:()=>gx,PyAnnotePreTrainedModel:()=>Qa,PyAnnoteProcessor:()=>Df,QuestionAnsweringPipeline:()=>zi,Qwen2ForCausalLM:()=>yx,Qwen2Model:()=>xx,Qwen2MoeForCausalLM:()=>vx,Qwen2MoeModel:()=>bx,Qwen2MoePreTrainedModel:()=>Ja,Qwen2PreTrainedModel:()=>Ya,Qwen2Tokenizer:()=>td,Qwen2VLForCausalLM:()=>ds,Qwen2VLForConditionalGeneration:()=>cn,Qwen2VLImageProcessor:()=>Zn,Qwen2VLPreTrainedModel:()=>Tc,Qwen2VLProcessor:()=>is,Qwen2_5_VLForCausalLM:()=>_s,Qwen2_5_VLForConditionalGeneration:()=>fs,Qwen2_5_VLProcessor:()=>no,Qwen3ForCausalLM:()=>Ex,Qwen3Model:()=>kx,Qwen3MoeForCausalLM:()=>Mx,Qwen3MoeModel:()=>Ax,Qwen3MoePreTrainedModel:()=>ei,Qwen3NextForCausalLM:()=>Tx,Qwen3NextModel:()=>Sx,Qwen3NextPreTrainedModel:()=>ti,Qwen3PreTrainedModel:()=>Za,Qwen3VLForCausalLM:()=>ys,Qwen3VLForConditionalGeneration:()=>xs,Qwen3VLMoeForCausalLM:()=>ri,Qwen3VLMoeForConditionalGeneration:()=>Ox,Qwen3VLProcessor:()=>Ff,Qwen3_5ForCausalLM:()=>bs,Qwen3_5ForConditionalGeneration:()=>hn,Qwen3_5MoeForCausalLM:()=>si,Qwen3_5MoeForConditionalGeneration:()=>Ix,RFDetrForObjectDetection:()=>zx,RFDetrModel:()=>Px,RFDetrObjectDetectionOutput:()=>qc,RFDetrPreTrainedModel:()=>oi,RTDetrForObjectDetection:()=>om,RTDetrImageProcessor:()=>_f,RTDetrModel:()=>nm,RTDetrObjectDetectionOutput:()=>rr,RTDetrPreTrainedModel:()=>Lo,RTDetrV2ForObjectDetection:()=>Vx,RTDetrV2Model:()=>Wx,RTDetrV2ObjectDetectionOutput:()=>Wc,RTDetrV2PreTrainedModel:()=>ai,RawAudio:()=>Xn,RawImage:()=>Ke,RawVideo:()=>Ou,RawVideoFrame:()=>rl,RepetitionPenaltyLogitsProcessor:()=>nc,ResNetForImageClassification:()=>Lx,ResNetModel:()=>Cx,ResNetPreTrainedModel:()=>ni,RoFormerForMaskedLM:()=>Ux,RoFormerForQuestionAnswering:()=>qx,RoFormerForSequenceClassification:()=>jx,RoFormerForTokenClassification:()=>Gx,RoFormerModel:()=>Bx,RoFormerPreTrainedModel:()=>$r,RoFormerTokenizer:()=>sd,RobertaForMaskedLM:()=>$x,RobertaForQuestionAnswering:()=>Fx,RobertaForSequenceClassification:()=>Rx,RobertaForTokenClassification:()=>Dx,RobertaModel:()=>Nx,RobertaPreTrainedModel:()=>Nr,RobertaTokenizer:()=>rd,Sam2ImageProcessor:()=>to,Sam2ImageSegmentationOutput:()=>Xc,Sam2Model:()=>ii,Sam2PreTrainedModel:()=>Kc,Sam2Processor:()=>Jl,Sam2VideoProcessor:()=>Bf,Sam3ImageProcessor:()=>to,Sam3TrackerModel:()=>Kx,SamImageProcessor:()=>to,SamImageSegmentationOutput:()=>Vc,SamModel:()=>Hx,SamPreTrainedModel:()=>Hc,SamProcessor:()=>oo,SapiensFeatureExtractor:()=>mf,SapiensForDepthEstimation:()=>Yx,SapiensForNormalEstimation:()=>Jx,SapiensForSemanticSegmentation:()=>Qx,SapiensImageProcessor:()=>Hl,SapiensPreTrainedModel:()=>gn,SeamlessM4TFeatureExtractor:()=>kd,SegformerFeatureExtractor:()=>hf,SegformerForImageClassification:()=>ey,SegformerForSemanticSegmentation:()=>ty,SegformerImageProcessor:()=>Xl,SegformerModel:()=>Zx,SegformerPreTrainedModel:()=>wn,SiglipImageProcessor:()=>gf,SiglipModel:()=>ry,SiglipPreTrainedModel:()=>li,SiglipTextModel:()=>ci,SiglipTokenizer:()=>nd,SiglipVisionModel:()=>sy,SmolLM3ForCausalLM:()=>oy,SmolLM3Model:()=>ny,SmolLM3PreTrainedModel:()=>ui,SmolVLMImageProcessor:()=>Ul,SmolVLMProcessor:()=>Yl,SnacDecoderModel:()=>di,SnacEncoderModel:()=>pi,SnacFeatureExtractor:()=>Ed,SnacModel:()=>ay,SnacPreTrainedModel:()=>xn,SolarOpenForCausalLM:()=>ly,SolarOpenModel:()=>iy,SolarOpenPreTrainedModel:()=>fi,SpeechT5FeatureExtractor:()=>Ad,SpeechT5ForSpeechToText:()=>uy,SpeechT5ForTextToSpeech:()=>py,SpeechT5HifiGan:()=>dy,SpeechT5Model:()=>cy,SpeechT5PreTrainedModel:()=>yn,SpeechT5Processor:()=>Uf,SpeechT5Tokenizer:()=>od,SqueezeBertForMaskedLM:()=>_y,SqueezeBertForQuestionAnswering:()=>hy,SqueezeBertForSequenceClassification:()=>my,SqueezeBertModel:()=>fy,SqueezeBertPreTrainedModel:()=>vs,SqueezeBertTokenizer:()=>ad,StableLmForCausalLM:()=>wy,StableLmModel:()=>gy,StableLmPreTrainedModel:()=>_i,Starcoder2ForCausalLM:()=>yy,Starcoder2Model:()=>xy,Starcoder2PreTrainedModel:()=>mi,StoppingCriteria:()=>Ar,StoppingCriteriaList:()=>Js,StyleTextToSpeech2Model:()=>by,StyleTextToSpeech2PreTrainedModel:()=>Qc,SummarizationPipeline:()=>$i,SupertonicForConditionalGeneration:()=>hi,SupertonicPreTrainedModel:()=>Yc,SuppressTokensAtBeginLogitsProcessor:()=>Ys,Swin2SRForImageSuperResolution:()=>My,Swin2SRImageProcessor:()=>wf,Swin2SRModel:()=>Ay,Swin2SRPreTrainedModel:()=>gi,SwinForImageClassification:()=>ky,SwinForSemanticSegmentation:()=>Ey,SwinModel:()=>vy,SwinPreTrainedModel:()=>bn,T5ForConditionalGeneration:()=>Ty,T5Model:()=>Sy,T5PreTrainedModel:()=>wi,T5Tokenizer:()=>id,TableTransformerForObjectDetection:()=>Iy,TableTransformerModel:()=>Oy,TableTransformerObjectDetectionOutput:()=>Jc,TableTransformerPreTrainedModel:()=>xi,TemperatureLogitsWarper:()=>cc,Tensor:()=>N,Text2TextGenerationPipeline:()=>fr,TextClassificationPipeline:()=>Li,TextGenerationPipeline:()=>Di,TextStreamer:()=>S0,TextToAudioPipeline:()=>Gi,TokenClassificationPipeline:()=>Pi,TokenizersBackend:()=>q,TopKLogitsWarper:()=>L1,TopPLogitsWarper:()=>C1,TrOCRForCausalLM:()=>Cy,TrOCRPreTrainedModel:()=>Zc,TranslationPipeline:()=>Ri,UltravoxModel:()=>ms,UltravoxPreTrainedModel:()=>Oc,UltravoxProcessor:()=>jf,UniSpeechForCTC:()=>Py,UniSpeechForSequenceClassification:()=>zy,UniSpeechModel:()=>Ly,UniSpeechPreTrainedModel:()=>vn,UniSpeechSatForAudioFrameClassification:()=>Dy,UniSpeechSatForCTC:()=>$y,UniSpeechSatForSequenceClassification:()=>Ry,UniSpeechSatModel:()=>Ny,UniSpeechSatPreTrainedModel:()=>ks,VLChatProcessor:()=>Tf,VLMImageProcessor:()=>Qd,VaultGemmaForCausalLM:()=>By,VaultGemmaModel:()=>Fy,VaultGemmaPreTrainedModel:()=>yi,ViTFeatureExtractor:()=>xf,ViTForImageClassification:()=>Gy,ViTImageProcessor:()=>Kl,ViTMAEModel:()=>qy,ViTMAEPreTrainedModel:()=>eu,ViTMSNForImageClassification:()=>Vy,ViTMSNModel:()=>Wy,ViTMSNPreTrainedModel:()=>vi,ViTModel:()=>jy,ViTPreTrainedModel:()=>bi,VisionEncoderDecoderModel:()=>Uy,VitMatteForImageMatting:()=>Hy,VitMatteImageProcessor:()=>yf,VitMattePreTrainedModel:()=>tu,VitPoseForPoseEstimation:()=>Xy,VitPoseImageProcessor:()=>bf,VitPosePreTrainedModel:()=>ru,VitsModel:()=>Ky,VitsModelOutput:()=>su,VitsPreTrainedModel:()=>nu,VitsTokenizer:()=>ld,VoxtralForConditionalGeneration:()=>Qy,VoxtralProcessor:()=>qf,VoxtralRealtimeFeatureExtractor:()=>Td,VoxtralRealtimeForConditionalGeneration:()=>ki,VoxtralRealtimePreTrainedModel:()=>ou,VoxtralRealtimeProcessor:()=>Vf,Wav2Vec2BertForCTC:()=>Jy,Wav2Vec2BertForSequenceClassification:()=>Zy,Wav2Vec2BertModel:()=>Yy,Wav2Vec2BertPreTrainedModel:()=>kn,Wav2Vec2CTCTokenizer:()=>cd,Wav2Vec2FeatureExtractor:()=>Md,Wav2Vec2ForAudioFrameClassification:()=>eg,Wav2Vec2ForCTC:()=>Jh,Wav2Vec2ForSequenceClassification:()=>Zh,Wav2Vec2Model:()=>Yh,Wav2Vec2PreTrainedModel:()=>qt,Wav2Vec2Processor:()=>Hf,Wav2Vec2ProcessorWithLM:()=>Xf,WavLMForAudioFrameClassification:()=>n0,WavLMForCTC:()=>t0,WavLMForSequenceClassification:()=>r0,WavLMForXVector:()=>s0,WavLMModel:()=>e0,WavLMPreTrainedModel:()=>Rr,WeSpeakerFeatureExtractor:()=>Sd,WeSpeakerResNetModel:()=>o0,WeSpeakerResNetPreTrainedModel:()=>iu,WhisperFeatureExtractor:()=>Od,WhisperForConditionalGeneration:()=>lu,WhisperModel:()=>i0,WhisperPreTrainedModel:()=>Ei,WhisperProcessor:()=>Kf,WhisperTextStreamer:()=>J1,WhisperTimeStampLogitsProcessor:()=>rc,WhisperTokenizer:()=>ud,XLMForQuestionAnswering:()=>f0,XLMForSequenceClassification:()=>p0,XLMForTokenClassification:()=>d0,XLMModel:()=>c0,XLMPreTrainedModel:()=>Dr,XLMRobertaForMaskedLM:()=>m0,XLMRobertaForQuestionAnswering:()=>w0,XLMRobertaForSequenceClassification:()=>h0,XLMRobertaForTokenClassification:()=>g0,XLMRobertaModel:()=>_0,XLMRobertaPreTrainedModel:()=>Fr,XLMRobertaTokenizer:()=>pd,XLMTokenizer:()=>dd,XLMWithLMHeadModel:()=>u0,XVectorOutput:()=>au,YolosFeatureExtractor:()=>vf,YolosForObjectDetection:()=>y0,YolosImageProcessor:()=>Ql,YolosModel:()=>x0,YolosObjectDetectionOutput:()=>cu,YolosPreTrainedModel:()=>Ai,YoutuForCausalLM:()=>v0,YoutuModel:()=>b0,YoutuPreTrainedModel:()=>Mi,ZeroShotAudioClassificationPipeline:()=>Ui,ZeroShotClassificationPipeline:()=>Fi,ZeroShotImageClassificationPipeline:()=>Hi,ZeroShotObjectDetectionPipeline:()=>Ki,cat:()=>ve,cos_sim:()=>sA,dot:()=>yb,env:()=>fe,full:()=>qe,full_like:()=>qn,interpolate:()=>yp,interpolate_4d:()=>xt,layer_norm:()=>kz,load_image:()=>sM,load_video:()=>eS,log_softmax:()=>tp,matmul:()=>m1,mean:()=>Cl,mean_pooling:()=>h1,ones:()=>Je,ones_like:()=>Ll,permute:()=>G2,pipeline:()=>CN,quantize_embeddings:()=>x1,rand:()=>Ez,randn:()=>w1,random:()=>Vr,read_audio:()=>md,rfft:()=>vz,slice:()=>Il,softmax:()=>Ie,stack:()=>St,std_mean:()=>bp,topk:()=>jt,zeros:()=>vp,zeros_like:()=>kp});module.exports=_I(PN);var iE=yr(require("fs"),1),Is=yr(require("path"),1),lE=yr(require("url"),1),TI={},mI="4.0.0-next.8",sb=typeof self<"u",Ln=!dE(iE.default),cE=!dE(Is.default),ju=sb&&"caches"in self,hI=typeof globalThis.Deno<"u",NN=typeof globalThis.Bun<"u",qu=hI&&ju&&!Ln,uE=typeof process<"u",pE=uE&&process?.release?.name==="node"&&!qu,nb=typeof window<"u"&&typeof window.document<"u",ob=sb&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),gI=nb||ob||qu,wI=pE||typeof navigator<"u"&&"gpu"in navigator,xI=typeof navigator<"u"&&"ml"in navigator,yI=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",bI=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",vI=typeof ServiceWorkerGlobalScope<"u"&&sb&&self instanceof ServiceWorkerGlobalScope,kI=()=>{if(typeof navigator>"u")return!1;let t=navigator.userAgent,r=(navigator.vendor||"").indexOf("Apple")>-1,s=!t.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!t.includes("Chrome")&&!t.includes("Android");return r&&s},EI=kI(),ie=Object.freeze({IS_BROWSER_ENV:nb,IS_WEBWORKER_ENV:ob,IS_WEB_ENV:gI,IS_SERVICE_WORKER_ENV:vI,IS_DENO_WEB_RUNTIME:qu,IS_WEB_CACHE_AVAILABLE:ju,IS_WEBGPU_AVAILABLE:wI,IS_WEBNN_AVAILABLE:xI,IS_SAFARI:EI,IS_PROCESS_AVAILABLE:uE,IS_NODE_ENV:pE,IS_FS_AVAILABLE:Ln,IS_PATH_AVAILABLE:cE,IS_CRYPTO_AVAILABLE:yI,IS_CHROME_AVAILABLE:bI}),ab=Ln&&cE,Gu="./";if(ab){let t=Object(TI).url;t?Gu=Is.default.dirname(Is.default.dirname(lE.default.fileURLToPath(t))):typeof __dirname<"u"&&(Gu=Is.default.dirname(__dirname))}var AI=ab?Is.default.join(Gu,"/.cache/"):null,oE="/models/",MI=ab?Is.default.join(Gu,oE):oE,SI=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,Mt=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),aE=Mt.WARNING,fe={version:mI,backends:{onnx:{}},get logLevel(){return aE},set logLevel(t){aE=t,fe.backends.onnx?.setLogLevel?.(t)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(nb||ob||qu),localModelPath:MI,useFS:Ln,useBrowserCache:ju,useFSCache:Ln,cacheDir:AI,useCustomCache:!1,customCache:null,useWasmCache:ju||Ln,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:SI};function dE(t){return Object.keys(t).length===0}function br(t,e){t&&t(e)}function fE(t){return Number.isInteger(t)||typeof t=="bigint"}function ib(t){return t==null||t===-1}function lb(t){let e=[],r=t;for(;Array.isArray(r);)e.push(r.length),r=r[0];return e}function ht(...t){return Array.prototype.concat.apply([],t)}function _E(...t){return t.reduce((e,r)=>e.flatMap(s=>r.map(n=>[s,n])))}function Pn(t,e){return Math.abs((t+e)%(2*e)-e)}function Qe(t,e){return Object.assign({},...e.map(r=>{if(t[r]!==void 0)return{[r]:t[r]}}))}function mE(t,e){let r=0;for(let s of t)s===e&&++r;return r}var Z={error(...t){fe.logLevel<=Mt.ERROR&&console.error(...t)},warn(...t){fe.logLevel<=Mt.WARNING&&console.warn(...t)},info(...t){fe.logLevel<=Mt.INFO&&console.log(...t)},debug(...t){fe.logLevel<=Mt.DEBUG&&console.log(...t)},log(...t){this.info(...t)}};var OI=class{constructor(t){this.trie=this._build_trie(t)}_build_trie(t){let e=Object.create(null);for(let r of t){let s=e;for(let n=0;n<r.length;++n){let o=r[n];s=s[o]??=Object.create(null)}s.end=r}return e}split(t){let e=[],r=t.length,s=0,n=0;for(;n<r;){let o=this.trie,a=null,i=n;for(;i<r&&(o=o[t[i]]);)o.end&&(a=o.end),++i;a?(n>s&&e.push(t.slice(s,n)),e.push(a),n+=a.length,s=n):++n}return s<r&&e.push(t.slice(s)),e}},hE=OI,II=class{constructor(t){this.content=t.content,this.id=t.id,this.single_word=t.single_word??!1,this.lstrip=t.lstrip??!1,this.rstrip=t.rstrip??!1,this.special=t.special??!1,this.normalized=t.normalized??!this.special}},CI=II,kE=(()=>{let t=[...Array.from({length:94},(n,o)=>o+33),...Array.from({length:12},(n,o)=>o+161),...Array.from({length:82},(n,o)=>o+174)],e=t.slice(),r=0;for(let n=0;n<256;++n)t.includes(n)||(t.push(n),e.push(256+r),r+=1);let s=e.map(n=>String.fromCharCode(n));return Object.fromEntries(t.map((n,o)=>[n,s[o]]))})(),LI=t=>Object.fromEntries(Object.entries(t).map(([e,r])=>[r,e])),PI=LI(kE),gE=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",zI=new Map([["(?i:'s|'t|'re|'ve|'m|'ll|'d)","(?:'([sS]|[tT]|[rR][eE]|[vV][eE]|[mM]|[lL][lL]|[dD]))"],["(?i:[sdmt]|ll|ve|re)","(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])"],["[^\\r\\n\\p{L}\\p{N}]?+","[^\\r\\n\\p{L}\\p{N}]?"],["[^\\s\\p{L}\\p{N}]++","[^\\s\\p{L}\\p{N}]+"],["(?>\\p{Nd}{510})","(?:\\p{Nd}{510})"],["\\p{Nd}{3}+","(?:\\p{Nd}{3})+"],["\\G",""],[` ?[^(\\s|[${gE}])]+`,` ?[^\\s${gE}]+`]]),Wu="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",ub=t=>t.replace(/ \./g,".").replace(/ \?/g,"?").replace(/ \!/g,"!").replace(/ ,/g,",").replace(/ \' /g,"'").replace(/ n't/g,"n't").replace(/ 'm/g,"'m").replace(/ 's/g,"'s").replace(/ 've/g,"'ve").replace(/ 're/g,"'re"),Vu=(t,e=!0)=>{if(t.Regex!==void 0){let r=t.Regex.replace(/\\([#&~])/g,"$1");r=r.replace(/\\A/g,"^").replace(/\\z/g,"$").replace(/\\Z/g,"(?=\\r?\\n?$)");for(let[s,n]of zI)r=r.replaceAll(s,n);try{return new RegExp(r,"gu")}catch(s){if(!(s instanceof SyntaxError)||!s.message.toLowerCase().includes("invalid property name"))throw s;let n=!1,o=r.replace(/(\\[pP])\{([^}=]+)\}/g,(a,i,l)=>{try{return new RegExp(`\\p{${l}}`,"u"),`${i}{${l}}`}catch{return n=!0,`${i}{Script=${l}}`}});if(!n)throw s;try{return new RegExp(o,"gu")}catch{throw s}}}else if(t.String!==void 0){let r=NI(t.String);return new RegExp(e?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",t),null},NI=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$I=(t,e,r)=>{let s=[],n=0;for(;n<t.length;){if(s.push(t[n]),(e.get(t[n])??r)!==r){++n;continue}for(;++n<t.length&&(e.get(t[n])??r)===r;)e.get(s.at(-1))!==r&&(s[s.length-1]+=t[n])}return s},RI=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,DI=t=>Number.isInteger(t)||typeof t=="bigint",FI=t=>{let e=0;for(let r of t)++e;return e},BI=t=>EE(t.toLowerCase()),Ht=(...t)=>Array.prototype.concat.apply([],t),pb=t=>new Map(Object.entries(t)),UI=(t,e)=>{let r=[],s=0;for(let n of t.matchAll(e)){let o=n[0];s<n.index&&r.push(t.slice(s,n.index)),o.length>0&&r.push(o),s=n.index+o.length}return s<t.length&&r.push(t.slice(s)),r},EE=t=>t.replace(/\p{M}/gu,""),wE=(t,e,r=[])=>{if(!t||Array.isArray(t)||typeof t!="object")return`${e} must be a valid object`;for(let s of r)if(!(s in t))return`${e} must contain a "${s}" property`;return null},jI=t=>t.match(/\S+/g)||[],GI=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},cl=GI,qI=class extends cl{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},vr=qI,WI=class extends vr{tokenize_chinese_chars(t){let e=[];for(let r=0;r<t.length;++r){let s=t[r],n=s.charCodeAt(0);RI(n)?(e.push(" "),e.push(s),e.push(" ")):e.push(s)}return e.join("")}strip_accents(t){return t.normalize("NFD").replace(/\p{Mn}/gu,"")}is_control(t){switch(t){case" ":case`
|
|
2
|
+
`:case"\r":return!1;default:return/^\p{Cc}|\p{Cf}|\p{Co}|\p{Cs}$/u.test(t)}}clean_text(t){let e=[];for(let r of t){let s=r.charCodeAt(0);s===0||s===65533||this.is_control(r)||(/^\s$/.test(r)?e.push(" "):e.push(r))}return e.join("")}normalize(t){return this.config.clean_text&&(t=this.clean_text(t)),this.config.handle_chinese_chars&&(t=this.tokenize_chinese_chars(t)),this.config.lowercase?(t=t.toLowerCase(),this.config.strip_accents!==!1&&(t=this.strip_accents(t))):this.config.strip_accents&&(t=this.strip_accents(t)),t}},VI=WI,HI=class extends vr{constructor(t){super(t),this.charsmap=t.precompiled_charsmap??null}normalize(t){return t=t.replace(/[\u0001-\u0008\u000B\u000E-\u001F\u007F\u008F\u009F]/gm,""),t=t.replace(/[\u0009\u000A\u000C\u000D\u00A0\u1680\u2000-\u200F\u2028\u2029\u202F\u205F\u2581\u3000\uFEFF\uFFFD]/gm," "),t.includes("\uFF5E")?t=t.split("\uFF5E").map(r=>r.normalize("NFKC")).join("\uFF5E"):t=t.normalize("NFKC"),t}},XI=HI,KI=class extends vr{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>AE(e))}normalize(t){return this.normalizers.reduce((e,r)=>r?r.normalize(e):e,t)}},QI=KI,YI=class extends vr{normalize(t){let e=Vu(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},JI=YI,ZI=class extends vr{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Hu=ZI,eC=class extends Hu{constructor(){super(...arguments),this.form="NFC"}},tC=eC,rC=class extends Hu{constructor(){super(...arguments),this.form="NFD"}},sC=rC,nC=class extends Hu{constructor(){super(...arguments),this.form="NFKC"}},oC=nC,aC=class extends Hu{constructor(){super(...arguments),this.form="NFKD"}},iC=aC,lC=class extends vr{normalize(t){return this.config.strip_left&&this.config.strip_right?t=t.trim():(this.config.strip_left&&(t=t.trimStart()),this.config.strip_right&&(t=t.trimEnd())),t}},cC=lC,uC=class extends vr{normalize(t){return EE(t)}},pC=uC,dC=class extends vr{normalize(t){return t.toLowerCase()}},fC=dC,_C=class extends vr{normalize(t){return t=this.config.prepend+t,t}},mC=_C;function hC(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new VI(t);case"Precompiled":return new XI(t);case"Sequence":return new QI(t);case"Replace":return new JI(t);case"NFC":return new tC(t);case"NFD":return new sC(t);case"NFKC":return new oC(t);case"NFKD":return new iC(t);case"Strip":return new cC(t);case"StripAccents":return new pC(t);case"Lowercase":return new fC(t);case"Prepend":return new mC(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var AE=hC,gC=class extends cl{pre_tokenize(t,e){return(Array.isArray(t)?t.map(r=>this.pre_tokenize_text(r,e)):this.pre_tokenize_text(t,e)).flat()}_call(t,e){return this.pre_tokenize(t,e)}},Xt=gC,wC=class extends Xt{constructor(t){super(),this.config=t,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=kE,this.text_encoder=new TextEncoder}pre_tokenize_text(t,e){return this.add_prefix_space&&!t.startsWith(" ")&&(t=" "+t),(this.use_regex?t.match(this.pattern)||[]:[t]).map(s=>Array.from(this.text_encoder.encode(s),n=>this.byte_encoder[n]).join(""))}},xC=wC,yC=class extends Xt{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},bC=yC,vC=class extends Xt{constructor(t){super(),this.replacement=t.replacement??"\u2581",this.str_rep=t.str_rep||this.replacement,this.prepend_scheme=t.prepend_scheme??"always"}pre_tokenize_text(t,e){let{section_index:r=void 0}=e??{},s=t.replaceAll(" ",this.str_rep);return!s.startsWith(this.replacement)&&(this.prepend_scheme==="always"||this.prepend_scheme==="first"&&r===0)&&(s=this.str_rep+s),[s]}},kC=vC,EC=class extends Xt{constructor(t){super(),this.config=t,this.pattern=Vu(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(t){return this.pattern===null?[]:this.config.invert?t.match(this.pattern)||[]:this.config.behavior?.toLowerCase()==="removed"?t.split(this.pattern).filter(e=>e):UI(t,this.pattern)}},AC=EC,MC=class extends Xt{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${Wu}]+|[${Wu}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},SC=MC,TC=class extends Xt{constructor(t){super(),this.config=t;let e=`[^\\d]+|\\d${this.config.individual_digits?"":"+"}`;this.pattern=new RegExp(e,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},OC=TC,IC=class extends Xt{constructor(){super(),this.pattern=new RegExp(`[^\\s${Wu}]+|[${Wu}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},CC=IC,LC=class extends Xt{constructor(t){super(),this.config=t,this.pattern=Vu(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},PC=LC,zC=class extends Xt{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>ME(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((r,s)=>s?s.pre_tokenize(r,e):r,[t])}},NC=zC,$C=class extends Xt{pre_tokenize_text(t){return jI(t)}},RC=$C,DC=class extends Xt{constructor(t){super(),this.config=t,this._length=t.length}pre_tokenize_text(t){let e=[];for(let r=0;r<t.length;r+=this._length)e.push(t.slice(r,r+this._length));return e}},FC=DC;function BC(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new CC;case"Sequence":return new NC(t);case"Whitespace":return new bC;case"WhitespaceSplit":return new RC;case"Metaspace":return new kC(t);case"ByteLevel":return new xC(t);case"Split":return new AC(t);case"Punctuation":return new SC(t);case"Digits":return new OC(t);case"Replace":return new PC(t);case"FixedLength":return new FC(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var ME=BC,UC=class extends cl{constructor(t){super(),this.config=t,this.vocab=[],this.tokens_to_ids=new Map,this.unk_token_id=void 0,this.unk_token=void 0,this.end_of_word_suffix=void 0,this.fuse_unk=this.config.fuse_unk??!1}_call(t){let e=this.encode(t);return this.fuse_unk&&(e=$I(e,this.tokens_to_ids,this.unk_token_id)),e}},Xu=UC,jC=class extends Xu{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=pb(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.max_input_chars_per_word=t.max_input_chars_per_word??100,this.vocab=new Array(this.tokens_to_ids.size);for(let[e,r]of this.tokens_to_ids)this.vocab[r]=e}encode(t){let e=[];for(let r of t){let s=[...r];if(s.length>this.max_input_chars_per_word){e.push(this.unk_token);continue}let n=!1,o=0,a=[];for(;o<s.length;){let i=s.length,l=null;for(;o<i;){let c=s.slice(o,i).join("");if(o>0&&(c=this.config.continuing_subword_prefix+c),this.tokens_to_ids.has(c)){l=c;break}--i}if(l===null){n=!0;break}a.push(l),o=i}n?e.push(this.unk_token):e.push(...a)}return e}},xE=jC,yE=class SE{constructor(e,r){this.is_leaf=e,this.children=r}static default(){return new SE(!1,new Map)}},GC=class{constructor(){this.root=yE.default()}extend(t){for(let e of t)this.push(e)}push(t){let e=this.root;for(let r of t){let s=e.children.get(r);s===void 0&&(s=yE.default(),e.children.set(r,s)),e=s}e.is_leaf=!0}*common_prefix_search(t){let e=this.root;if(e===void 0)return;let r="";for(let s of t){if(r+=s,e=e.children.get(s),e===void 0)return;e.is_leaf&&(yield r)}}},qC=GC,cb=class TE{constructor(e,r,s,n,o){this.token_id=e,this.node_id=r,this.pos=s,this.length=n,this.score=o,this.prev=null,this.backtrace_score=0}clone(){let e=new TE(this.token_id,this.node_id,this.pos,this.length,this.score);return e.prev=this.prev,e.backtrace_score=this.backtrace_score,e}},WC=class{constructor(t,e,r){this.chars=Array.from(t),this.len=this.chars.length,this.bos_token_id=e,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},()=>[]);let s=new cb(this.bos_token_id??0,0,0,0,0),n=new cb(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(s.clone()),this.nodes.push(n.clone()),this.begin_nodes[this.len].push(n),this.end_nodes[0].push(s)}insert(t,e,r,s){let n=this.nodes.length,o=new cb(s,n,t,e,r);this.begin_nodes[t].push(o),this.end_nodes[t+e].push(o),this.nodes.push(o)}viterbi(){let t=this.len,e=0;for(;e<=t;){if(this.begin_nodes[e].length==0)return[];for(let a of this.begin_nodes[e]){a.prev=null;let i=0,l=null;for(let c of this.end_nodes[e]){let p=c.backtrace_score+a.score;(l===null||p>i)&&(l=c.clone(),i=p)}if(l!==null)a.prev=l,a.backtrace_score=i;else return[]}++e}let r=[],n=this.begin_nodes[t][0].prev;if(n===null)return[];let o=n.clone();for(;o.prev!==null;)r.push(o.clone()),o=o.clone().prev.clone();return r.reverse(),r}piece(t){return this.chars.slice(t.pos,t.pos+t.length).join("")}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}},VC=WC;function HC(t){if(t.length===0)throw new Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]<e&&(e=t[s],r=s);return[e,r]}var XC=class extends Xu{constructor(t,e){super(t);let r=t.vocab.length;this.vocab=new Array(r),this.scores=new Array(r);for(let s=0;s<r;++s)[this.vocab[s],this.scores[s]]=t.vocab[s];this.unk_token_id=t.unk_id,this.unk_token=this.vocab[t.unk_id],this.tokens_to_ids=new Map(this.vocab.map((s,n)=>[s,n])),this.bos_token=" ",this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=HC(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new qC,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(t){let e=t.chars,r=1,s=0;for(;s<e.length;){let n=!1,o=[],a=e.slice(s).join(""),i=this.trie.common_prefix_search(a);for(let l of i){o.push(l);let c=this.tokens_to_ids.get(l),p=this.scores[c],d=FI(l);t.insert(s,d,p,c),!n&&d===r&&(n=!0)}n||t.insert(s,r,this.unk_score,this.unk_token_id),s+=r}}tokenize(t){let e=new VC(t,this.bos_token_id,this.eos_token_id);return this.populate_nodes(e),e.tokens()}encode(t){let e=[];for(let r of t){let s=this.tokenize(r);e.push(...s)}return e}},bE=XC,KC=class{constructor(t=(r,s)=>r>s,e=1/0){this._heap=[],this._comparator=t,this._max_size=e}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...t){return this.extend(t)}extend(t){for(let e of t)if(this.size<this._max_size)this._heap.push(e),this._sift_up();else{let r=this._smallest();this._comparator(e,this._heap[r])&&(this._heap[r]=e,this._sift_up_from(r))}return this.size}pop(){let t=this.peek(),e=this.size-1;return e>0&&this._swap(0,e),this._heap.pop(),this._sift_down(),t}replace(t){let e=this.peek();return this._heap[0]=t,this._sift_down(),e}_parent(t){return(t+1>>>1)-1}_left(t){return(t<<1)+1}_right(t){return t+1<<1}_greater(t,e){return this._comparator(this._heap[t],this._heap[e])}_swap(t,e){let r=this._heap[t];this._heap[t]=this._heap[e],this._heap[e]=r}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(t){for(;t>0&&this._greater(t,this._parent(t));)this._swap(t,this._parent(t)),t=this._parent(t)}_sift_down(){let t=0;for(;this._left(t)<this.size&&this._greater(this._left(t),t)||this._right(t)<this.size&&this._greater(this._right(t),t);){let e=this._right(t)<this.size&&this._greater(this._right(t),this._left(t))?this._right(t):this._left(t);this._swap(t,e),t=e}}_smallest(){return 2**Math.floor(Math.log2(this.size))-1}},QC=KC,YC=class{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;let e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},JC=YC,ZC=class extends Xu{constructor(t){super(t),this.tokens_to_ids=pb(t.vocab),this.unk_token_id=this.tokens_to_ids.get(t.unk_token),this.unk_token=t.unk_token,this.vocab=new Array(this.tokens_to_ids.size);for(let[r,s]of this.tokens_to_ids)this.vocab[s]=r;let e=Array.isArray(t.merges[0]);this.merges=e?t.merges:t.merges.map(r=>r.split(" ",2)),this.bpe_ranks=new Map(this.merges.map((r,s)=>[JSON.stringify(r),s])),this.end_of_word_suffix=t.end_of_word_suffix,this.continuing_subword_suffix=t.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new JC(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(t){if(t.length===0)return[];let e=this.cache.get(t);if(e!==void 0)return e;let r=Array.from(t);this.end_of_word_suffix&&(r[r.length-1]+=this.end_of_word_suffix);let s=[];if(r.length>1){let n=new QC((i,l)=>i.score<l.score),o={token:r[0],bias:0,prev:null,next:null},a=o;for(let i=1;i<r.length;++i){let l={bias:i/r.length,token:r[i],prev:a,next:null};a.next=l,this.add_node(n,a),a=l}for(;!n.is_empty();){let i=n.pop();if(i.deleted||!i.next||i.next.deleted)continue;if(i.deleted=!0,i.next.deleted=!0,i.prev){let c={...i.prev};i.prev.deleted=!0,i.prev=c,c.prev?c.prev.next=c:o=c}let l={token:i.token+i.next.token,bias:i.bias,prev:i.prev,next:i.next.next};l.prev?(l.prev.next=l,this.add_node(n,l.prev)):o=l,l.next&&(l.next.prev=l,this.add_node(n,l))}for(let i=o;i!==null;i=i.next)s.push(i.token)}else s=r;if(this.continuing_subword_suffix)for(let n=0;n<s.length-1;++n)s[n]+=this.continuing_subword_suffix;return t.length<this.max_length_to_cache&&this.cache.put(t,s),s}add_node(t,e){let r=this.bpe_ranks.get(JSON.stringify([e.token,e.next.token]));r!==void 0&&(e.score=r+e.bias,t.push(e))}encode(t){let e=[];for(let r of t){if(this.ignore_merges&&this.tokens_to_ids.has(r)){e.push(r);continue}let s=this.bpe(r);for(let n of s)if(this.tokens_to_ids.has(n))e.push(n);else if(this.byte_fallback){let o=Array.from(this.text_encoder.encode(n)).map(a=>`<0x${a.toString(16).toUpperCase().padStart(2,"0")}>`);o.every(a=>this.tokens_to_ids.has(a))?e.push(...o):this.unk_token!=null&&e.push(this.unk_token)}else this.unk_token!=null&&e.push(this.unk_token)}return e}},vE=ZC,eL=class extends Xu{constructor(t,e){super(t);let r=t.vocab;this.tokens_to_ids=pb(e.target_lang?r[e.target_lang]:r),this.bos_token=e.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=e.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=e.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=e.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=new Array(this.tokens_to_ids.size);for(let[s,n]of this.tokens_to_ids)this.vocab[n]=s}encode(t){return t}},tL=eL;function rL(t,e){switch(t.type){case"WordPiece":return new xE(t);case"Unigram":return new bE(t,e.eos_token);case"BPE":return new vE(t);default:if(t.vocab)return Array.isArray(t.vocab)?new bE(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new vE(t):new xE(t):new tL(t,{target_lang:e.target_lang,bos_token:e.bos_token,eos_token:e.eos_token,pad_token:e.pad_token,unk_token:e.unk_token});throw new Error(`Unknown TokenizerModel type: ${t?.type}`)}}var sL=rL,nL=class extends cl{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},ul=nL,oL=class extends ul{post_process(t,e=null,r=!0){let s=e===null?this.config.single:this.config.pair,n=[],o=[];for(let a of s)"SpecialToken"in a?r&&(n.push(a.SpecialToken.id),o.push(a.SpecialToken.type_id)):"Sequence"in a&&(a.Sequence.id==="A"?(n=Ht(n,t),o=Ht(o,new Array(t.length).fill(a.Sequence.type_id))):a.Sequence.id==="B"&&(n=Ht(n,e),o=Ht(o,new Array(e.length).fill(a.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},aL=oL,iL=class extends ul{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},lL=iL,cL=class extends ul{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,r=!0){r&&(t=Ht([this.cls[0]],t,[this.sep[0]]));let s=new Array(t.length).fill(0);if(e){let n=[],o=r?[this.sep[0]]:[];t=Ht(t,n,e,o),s=Ht(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},uL=cL,pL=class extends ul{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,r=!0){r&&(t=Ht([this.cls[0]],t,[this.sep[0]]));let s=new Array(t.length).fill(0);if(e){let n=r?[this.sep[0]]:[],o=r?[this.sep[0]]:[];t=Ht(t,n,e,o),s=Ht(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},dL=pL,fL=class extends ul{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>OE(e))}post_process(t,e=null,r=!0){let s={tokens:t,tokens_pair:e};for(let n of this.processors)s=n.post_process(s.tokens,s.tokens_pair,r);return s}},_L=fL;function mL(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new aL(t);case"ByteLevel":return new lL(t);case"BertProcessing":return new uL(t);case"RobertaProcessing":return new dL(t);case"Sequence":return new _L(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var OE=mL,hL=class extends cl{constructor(t){super(),this.config=t,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets="trim_offsets"in t?t.trim_offsets:!1}_call(t){return this.decode(t)}decode(t){return this.decode_chain(t).join("")}},Dt=hL,gL=class extends Dt{constructor(t){super(t),this.byte_decoder=PI,this.text_decoder=new TextDecoder("utf-8",{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(t){let e=t.join(""),r=new Uint8Array([...e].map(s=>this.byte_decoder[s]));return this.text_decoder.decode(r)}decode_chain(t){let e=[],r=[];for(let s of t)this.added_tokens.find(n=>n.content===s)!==void 0?(r.length>0&&(e.push(this.convert_tokens_to_string(r)),r=[]),e.push(s)):r.push(s);return r.length>0&&e.push(this.convert_tokens_to_string(r)),e}},wL=gL,xL=class extends Dt{constructor(t){super(t),this.cleanup=t.cleanup}decode_chain(t){return t.map((e,r)=>{if(r!==0){let s=this.config.prefix;s&&e.startsWith(s)?e=e.replace(s,""):e=" "+e}return this.cleanup&&(e=ub(e)),e})}},yL=xL,bL=class extends Dt{constructor(t){super(t),this.replacement=t.replacement??"\u2581"}decode_chain(t){let e=[];for(let r=0;r<t.length;++r){let s=t[r].replaceAll(this.replacement," ");r==0&&s.startsWith(" ")&&(s=s.substring(1)),e.push(s)}return e}},vL=bL,kL=class extends Dt{constructor(t){super(t),this.suffix=t.suffix??""}decode_chain(t){return t.map((e,r)=>e.replaceAll(this.suffix,r===t.length-1?"":" "))}},EL=kL,AL=class extends Dt{constructor(t){super(t),this.pad_token=t.pad_token??"",this.word_delimiter_token=t.word_delimiter_token??"",this.cleanup=t.cleanup}convert_tokens_to_string(t){if(t.length===0)return"";let e=[t[0]];for(let n=1;n<t.length;++n)t[n]!==e.at(-1)&&e.push(t[n]);let s=e.filter(n=>n!==this.pad_token).join("");return this.cleanup&&(s=ub(s).replaceAll(this.word_delimiter_token," ").trim()),s}decode_chain(t){return[this.convert_tokens_to_string(t)]}},ML=AL,SL=class extends Dt{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>IE(e))}decode_chain(t){return this.decoders.reduce((e,r)=>r.decode_chain(e),t)}},TL=SL,OL=class extends Dt{decode_chain(t){let e=Vu(this.config.pattern),r=this.config.content??"";return e===null?t:t.map(s=>s.replaceAll(e,r))}},IL=OL,CL=class extends Dt{decode_chain(t){return[t.join("")]}},LL=CL,PL=class extends Dt{constructor(t){super(t),this.content=t.content??"",this.start=t.start??0,this.stop=t.stop??0}decode_chain(t){return t.map(e=>{let r=0;for(let n=0;n<this.start&&e[n]===this.content;++n){r=n+1;continue}let s=e.length;for(let n=0;n<this.stop;++n){let o=e.length-n-1;if(e[o]===this.content){s=o;continue}else break}return e.slice(r,s)})}},zL=PL,NL=class extends Dt{constructor(t){super(t),this.text_decoder=new TextDecoder}decode_chain(t){let e=[],r=[];for(let s of t){let n=null;if(s.length===6&&s.startsWith("<0x")&&s.endsWith(">")){let o=parseInt(s.slice(3,5),16);isNaN(o)||(n=o)}if(n!==null)r.push(n);else{if(r.length>0){let o=this.text_decoder.decode(Uint8Array.from(r));e.push(o),r=[]}e.push(s)}}if(r.length>0){let s=this.text_decoder.decode(Uint8Array.from(r));e.push(s),r=[]}return e}},$L=NL;function RL(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new wL(t);case"WordPiece":return new yL(t);case"Metaspace":return new vL(t);case"BPEDecoder":return new EL(t);case"CTC":return new ML(t);case"Sequence":return new TL(t);case"Replace":return new IL(t);case"Fuse":return new LL(t);case"Strip":return new zL(t);case"ByteFallback":return new $L(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var IE=RL,DL=class{constructor(t,e){let r=wE(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);let s=wE(e,"Config");if(s)throw new Error(s);this.tokenizer=t,this.config=e,this.normalizer=AE(this.tokenizer.normalizer),this.pre_tokenizer=ME(this.tokenizer.pre_tokenizer),this.model=sL(this.tokenizer.model,this.config),this.post_processor=OE(this.tokenizer.post_processor),this.decoder=IE(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let n=[],o=[];this.added_tokens_map=new Map;for(let a of this.tokenizer.added_tokens){let i=new CI(a);if(this.added_tokens.push(i),this.model.tokens_to_ids.set(i.content,i.id),this.model.vocab[i.id]=i.content,i.special&&(this.special_tokens.push(i.content),this.all_special_ids.push(i.id)),this.added_tokens_map.set(i.content,i),i.normalized&&this.normalizer!==null){let l=this.normalizer(i.content);o.push(l),this.added_tokens_map.set(l,i)}else n.push(i.content)}(this.config.additional_special_tokens??[]).forEach(a=>{this.special_tokens.includes(a)||this.special_tokens.push(a)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new hE(n),this.splitter_normalized=new hE(o),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(t,{text_pair:e=null,add_special_tokens:r=!0,return_token_type_ids:s=null}={}){let{tokens:n,token_type_ids:o}=this.tokenize_helper(t,{text_pair:e,add_special_tokens:r}),a=n.map(l=>this.added_tokens_map.get(l)?.id??this.model.tokens_to_ids.get(l)??this.model.unk_token_id),i={ids:a,tokens:n,attention_mask:new Array(a.length).fill(1)};return s&&o&&(i.token_type_ids=o),i}decode(t,e={}){if(!Array.isArray(t)||t.length===0||!DI(t[0]))throw Error("token_ids must be a non-empty array of integers.");let r=t.map(n=>this.model.vocab[Number(n)]??this.model.unk_token);e.skip_special_tokens&&(r=r.filter(n=>!this.special_tokens.includes(n)));let s=this.decoder?this.decoder(r):r.join(" ");return this.decoder&&this.decoder.end_of_word_suffix&&(s=s.replaceAll(this.decoder.end_of_word_suffix," "),e.skip_special_tokens&&(s=s.trim())),(e.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(s=ub(s)),s}tokenize(t,{text_pair:e=null,add_special_tokens:r=!1}={}){return this.tokenize_helper(t,{text_pair:e,add_special_tokens:r}).tokens}encode_text(t){if(t===null)return null;let e=this.splitter_unnormalized.split(t);return e.forEach((r,s)=>{let n=this.added_tokens_map.get(r);n&&(n.lstrip&&s>0&&(e[s-1]=e[s-1].trimEnd()),n.rstrip&&s<e.length-1&&(e[s+1]=e[s+1].trimStart()))}),e.flatMap((r,s)=>{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=BI(r)),this.normalizer!==null&&(r=this.normalizer(r)),r.length===0)return[];let n=this.splitter_normalized.split(r);return n.forEach((o,a)=>{let i=this.added_tokens_map.get(o);i&&(i.lstrip&&a>0&&(n[a-1]=n[a-1].trimEnd()),i.rstrip&&a<n.length-1&&(n[a+1]=n[a+1].trimStart()))}),n.flatMap(o=>{if(o.length===0)return[];if(this.added_tokens_map.has(o))return[o];let a=this.pre_tokenizer!==null?this.pre_tokenizer(o,{section_index:s}):[o];return this.model(a)})})}tokenize_helper(t,{text_pair:e=null,add_special_tokens:r=!0}){let s=this.encode_text(t),n=this.encode_text(e||null);return this.post_processor?this.post_processor(s,n,r):{tokens:Ht(s??[],n??[])}}token_to_id(t){return this.model.tokens_to_ids.get(t)}id_to_token(t){return this.model.vocab[t]}get_added_tokens_decoder(){let t=new Map;for(let e of this.added_tokens)t.set(e.id,e);return t}get_vocab(t=!0){let e=new Map;for(let r=0;r<this.model.vocab.length;++r){let s=this.model.vocab[r];(t||!this.added_tokens_map.has(s))&&e.set(s,r)}return e}},CE=DL;var D=Object.freeze({Text:"Text",NumericLiteral:"NumericLiteral",StringLiteral:"StringLiteral",Identifier:"Identifier",Equals:"Equals",OpenParen:"OpenParen",CloseParen:"CloseParen",OpenStatement:"OpenStatement",CloseStatement:"CloseStatement",OpenExpression:"OpenExpression",CloseExpression:"CloseExpression",OpenSquareBracket:"OpenSquareBracket",CloseSquareBracket:"CloseSquareBracket",OpenCurlyBracket:"OpenCurlyBracket",CloseCurlyBracket:"CloseCurlyBracket",Comma:"Comma",Dot:"Dot",Colon:"Colon",Pipe:"Pipe",CallOperator:"CallOperator",AdditiveBinaryOperator:"AdditiveBinaryOperator",MultiplicativeBinaryOperator:"MultiplicativeBinaryOperator",ComparisonBinaryOperator:"ComparisonBinaryOperator",UnaryOperator:"UnaryOperator",Comment:"Comment"}),Ft=class{constructor(t,e){this.value=t,this.type=e}};function LE(t){return/\w/.test(t)}function pl(t){return/[0-9]/.test(t)}function PE(t){return/\s/.test(t)}var FL=[["{%",D.OpenStatement],["%}",D.CloseStatement],["{{",D.OpenExpression],["}}",D.CloseExpression],["(",D.OpenParen],[")",D.CloseParen],["{",D.OpenCurlyBracket],["}",D.CloseCurlyBracket],["[",D.OpenSquareBracket],["]",D.CloseSquareBracket],[",",D.Comma],[".",D.Dot],[":",D.Colon],["|",D.Pipe],["<=",D.ComparisonBinaryOperator],[">=",D.ComparisonBinaryOperator],["==",D.ComparisonBinaryOperator],["!=",D.ComparisonBinaryOperator],["<",D.ComparisonBinaryOperator],[">",D.ComparisonBinaryOperator],["+",D.AdditiveBinaryOperator],["-",D.AdditiveBinaryOperator],["~",D.AdditiveBinaryOperator],["*",D.MultiplicativeBinaryOperator],["/",D.MultiplicativeBinaryOperator],["%",D.MultiplicativeBinaryOperator],["=",D.Equals]],BL=new Map([["n",`
|
|
3
|
+
`],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function UL(t,e={}){return t.endsWith(`
|
|
4
|
+
`)&&(t=t.slice(0,-1)),e.lstrip_blocks&&(t=t.replace(/^[ \t]*({[#%-])/gm,"$1")),e.trim_blocks&&(t=t.replace(/([#%-]})\n/g,"$1")),t.replace(/{%\s*(end)?generation\s*%}/gs,"")}function jL(t,e={}){let r=[],s=UL(t,e),n=0,o=0,a=c=>{let p="";for(;c(s[n]);){if(s[n]==="\\"){if(++n,n>=s.length)throw new SyntaxError("Unexpected end of input");let d=s[n++],_=BL.get(d);if(_===void 0)throw new SyntaxError(`Unexpected escaped character: ${d}`);p+=_;continue}if(p+=s[n++],n>=s.length)throw new SyntaxError("Unexpected end of input")}return p},i=()=>{let c=r.at(-1);c&&c.type===D.Text&&(c.value=c.value.trimEnd(),c.value===""&&r.pop())},l=()=>{for(;n<s.length&&PE(s[n]);)++n};e:for(;n<s.length;){let c=r.at(-1)?.type;if(c===void 0||c===D.CloseStatement||c===D.CloseExpression||c===D.Comment){let d="";for(;n<s.length&&!(s[n]==="{"&&(s[n+1]==="%"||s[n+1]==="{"||s[n+1]==="#"));)d+=s[n++];if(d.length>0){r.push(new Ft(d,D.Text));continue}}if(s[n]==="{"&&s[n+1]==="#"){n+=2;let d=s[n]==="-";d&&++n;let _="";for(;s[n]!=="#"||s[n+1]!=="}";){if(n+2>=s.length)throw new SyntaxError("Missing end of comment tag");_+=s[n++]}let m=_.endsWith("-");m&&(_=_.slice(0,-1)),d&&i(),r.push(new Ft(_,D.Comment)),n+=2,m&&l();continue}if(s.slice(n,n+3)==="{%-"){i(),r.push(new Ft("{%",D.OpenStatement)),n+=3;continue}if(s.slice(n,n+3)==="{{-"){i(),r.push(new Ft("{{",D.OpenExpression)),o=0,n+=3;continue}if(a(PE),s.slice(n,n+3)==="-%}"){r.push(new Ft("%}",D.CloseStatement)),n+=3,l();continue}if(s.slice(n,n+3)==="-}}"){r.push(new Ft("}}",D.CloseExpression)),n+=3,l();continue}let p=s[n];if(p==="-"||p==="+"){let d=r.at(-1)?.type;if(d===D.Text||d===void 0)throw new SyntaxError(`Unexpected character: ${p}`);switch(d){case D.Identifier:case D.NumericLiteral:case D.StringLiteral:case D.CloseParen:case D.CloseSquareBracket:break;default:{++n;let _=a(pl);r.push(new Ft(`${p}${_}`,_.length>0?D.NumericLiteral:D.UnaryOperator));continue}}}for(let[d,_]of FL){if(d==="}}"&&o>0)continue;if(s.slice(n,n+d.length)===d){r.push(new Ft(d,_)),_===D.OpenExpression?o=0:_===D.OpenCurlyBracket?++o:_===D.CloseCurlyBracket&&--o,n+=d.length;continue e}}if(p==="'"||p==='"'){++n;let d=a(_=>_!==p);r.push(new Ft(d,D.StringLiteral)),++n;continue}if(pl(p)){let d=a(pl);if(s[n]==="."&&pl(s[n+1])){++n;let _=a(pl);d=`${d}.${_}`}r.push(new Ft(d,D.NumericLiteral));continue}if(LE(p)){let d=a(LE);r.push(new Ft(d,D.Identifier));continue}throw new SyntaxError(`Unexpected character: ${p}`)}return r}var Qt=class{type="Statement"},GL=class extends Qt{constructor(t){super(),this.body=t}type="Program"},qL=class extends Qt{constructor(t,e,r){super(),this.test=t,this.body=e,this.alternate=r}type="If"},WL=class extends Qt{constructor(t,e,r,s){super(),this.loopvar=t,this.iterable=e,this.body=r,this.defaultBlock=s}type="For"},VL=class extends Qt{type="Break"},HL=class extends Qt{type="Continue"},XL=class extends Qt{constructor(t,e,r){super(),this.assignee=t,this.value=e,this.body=r}type="Set"},KL=class extends Qt{constructor(t,e,r){super(),this.name=t,this.args=e,this.body=r}type="Macro"},QL=class extends Qt{constructor(t){super(),this.value=t}type="Comment"},It=class extends Qt{type="Expression"},YL=class extends It{constructor(t,e,r){super(),this.object=t,this.property=e,this.computed=r}type="MemberExpression"},zE=class extends It{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},zn=class extends It{constructor(t){super(),this.value=t}type="Identifier"},Nn=class extends It{constructor(t){super(),this.value=t}type="Literal"},JL=class extends Nn{type="IntegerLiteral"},ZL=class extends Nn{type="FloatLiteral"},NE=class extends Nn{type="StringLiteral"},eP=class extends Nn{type="ArrayLiteral"},$E=class extends Nn{type="TupleLiteral"},tP=class extends Nn{type="ObjectLiteral"},dl=class extends It{constructor(t,e,r){super(),this.operator=t,this.left=e,this.right=r}type="BinaryExpression"},rP=class extends It{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},sP=class extends Qt{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},nP=class extends It{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},oP=class extends It{constructor(t,e,r){super(),this.operand=t,this.negate=e,this.test=r}type="TestExpression"},aP=class extends It{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},iP=class extends It{constructor(t=void 0,e=void 0,r=void 0){super(),this.start=t,this.stop=e,this.step=r}type="SliceExpression"},lP=class extends It{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},cP=class extends It{constructor(t){super(),this.argument=t}type="SpreadExpression"},uP=class extends Qt{constructor(t,e,r){super(),this.call=t,this.callerArgs=e,this.body=r}type="CallStatement"},pP=class extends It{constructor(t,e,r){super(),this.condition=t,this.trueExpr=e,this.falseExpr=r}type="Ternary"};function dP(t){let e=new GL([]),r=0;function s(P,$){let F=t[r++];if(!F||F.type!==P)throw new Error(`Parser Error: ${$}. ${F.type} !== ${P}.`);return F}function n(P){if(!l(P))throw new SyntaxError(`Expected ${P}`);++r}function o(){switch(t[r].type){case D.Comment:return new QL(t[r++].value);case D.Text:return c();case D.OpenStatement:return p();case D.OpenExpression:return d();default:throw new SyntaxError(`Unexpected token type: ${t[r].type}`)}}function a(...P){return r+P.length<=t.length&&P.every(($,F)=>$===t[r+F].type)}function i(...P){return t[r]?.type===D.OpenStatement&&t[r+1]?.type===D.Identifier&&P.includes(t[r+1]?.value)}function l(...P){return r+P.length<=t.length&&P.every(($,F)=>t[r+F].type==="Identifier"&&$===t[r+F].value)}function c(){return new NE(s(D.Text,"Expected text token").value)}function p(){if(s(D.OpenStatement,"Expected opening statement token"),t[r].type!==D.Identifier)throw new SyntaxError(`Unknown statement, got ${t[r].type}`);let P=t[r].value,$;switch(P){case"set":++r,$=_();break;case"if":++r,$=m(),s(D.OpenStatement,"Expected {% token"),n("endif"),s(D.CloseStatement,"Expected %} token");break;case"macro":++r,$=w(),s(D.OpenStatement,"Expected {% token"),n("endmacro"),s(D.CloseStatement,"Expected %} token");break;case"for":++r,$=E(),s(D.OpenStatement,"Expected {% token"),n("endfor"),s(D.CloseStatement,"Expected %} token");break;case"call":{++r;let F=null;a(D.OpenParen)&&(F=B());let J=ae();if(J.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let xe=B();s(D.CloseStatement,"Expected closing statement token");let ue=[];for(;!i("endcall");)ue.push(o());s(D.OpenStatement,"Expected '{%'"),n("endcall"),s(D.CloseStatement,"Expected closing statement token");let Ve=new zE(J,xe);$=new uP(Ve,F,ue);break}case"break":++r,s(D.CloseStatement,"Expected closing statement token"),$=new VL;break;case"continue":++r,s(D.CloseStatement,"Expected closing statement token"),$=new HL;break;case"filter":{++r;let F=ae();F instanceof zn&&a(D.OpenParen)&&(F=X(F)),s(D.CloseStatement,"Expected closing statement token");let J=[];for(;!i("endfilter");)J.push(o());s(D.OpenStatement,"Expected '{%'"),n("endfilter"),s(D.CloseStatement,"Expected '%}'"),$=new sP(F,J);break}default:throw new SyntaxError(`Unknown statement type: ${P}`)}return $}function d(){s(D.OpenExpression,"Expected opening expression token");let P=k();return s(D.CloseExpression,"Expected closing expression token"),P}function _(){let P=x(),$=null,F=[];if(a(D.Equals))++r,$=x();else{for(s(D.CloseStatement,"Expected %} token");!i("endset");)F.push(o());s(D.OpenStatement,"Expected {% token"),n("endset")}return s(D.CloseStatement,"Expected closing statement token"),new XL(P,$,F)}function m(){let P=k();s(D.CloseStatement,"Expected closing statement token");let $=[],F=[];for(;!i("elif","else","endif");)$.push(o());if(i("elif")){++r,++r;let J=m();F.push(J)}else if(i("else"))for(++r,++r,s(D.CloseStatement,"Expected closing statement token");!i("endif");)F.push(o());return new qL(P,$,F)}function w(){let P=ae();if(P.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let $=B();s(D.CloseStatement,"Expected closing statement token");let F=[];for(;!i("endmacro");)F.push(o());return new KL(P,$,F)}function x(P=!1){let $=P?ae:k,F=[$()],J=a(D.Comma);for(;J&&(++r,F.push($()),!!a(D.Comma)););return J?new $E(F):F[0]}function E(){let P=x(!0);if(!(P instanceof zn||P instanceof $E))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${P.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;let $=k();s(D.CloseStatement,"Expected closing statement token");let F=[];for(;!i("endfor","else");)F.push(o());let J=[];if(i("else"))for(++r,++r,s(D.CloseStatement,"Expected closing statement token");!i("endfor");)J.push(o());return new WL(P,$,F,J)}function k(){return A()}function A(){let P=T();if(l("if")){++r;let $=T();if(l("else")){++r;let F=A();return new pP($,P,F)}else return new nP(P,$)}return P}function T(){let P=S();for(;l("or");){let $=t[r];++r;let F=S();P=new dl($,P,F)}return P}function S(){let P=L();for(;l("and");){let $=t[r];++r;let F=L();P=new dl($,P,F)}return P}function L(){let P;for(;l("not");){let $=t[r];++r;let F=L();P=new aP($,F)}return P??O()}function O(){let P=v();for(;;){let $;if(l("not","in"))$=new Ft("not in",D.Identifier),r+=2;else if(l("in"))$=t[r++];else if(a(D.ComparisonBinaryOperator))$=t[r++];else break;let F=v();P=new dl($,P,F)}return P}function v(){let P=R();for(;a(D.AdditiveBinaryOperator);){let $=t[r];++r;let F=R();P=new dl($,P,F)}return P}function W(){let P=Q(ae());return a(D.OpenParen)?X(P):P}function X(P){let $=new zE(P,B());return $=Q($),a(D.OpenParen)&&($=X($)),$}function B(){s(D.OpenParen,"Expected opening parenthesis for arguments list");let P=H();return s(D.CloseParen,"Expected closing parenthesis for arguments list"),P}function H(){let P=[];for(;!a(D.CloseParen);){let $;if(t[r].type===D.MultiplicativeBinaryOperator&&t[r].value==="*"){++r;let F=k();$=new cP(F)}else if($=k(),a(D.Equals)){if(++r,!($ instanceof zn))throw new SyntaxError("Expected identifier for keyword argument");let F=k();$=new lP($,F)}P.push($),a(D.Comma)&&++r}return P}function G(){let P=[],$=!1;for(;!a(D.CloseSquareBracket);)a(D.Colon)?(P.push(void 0),++r,$=!0):(P.push(k()),a(D.Colon)&&(++r,$=!0));if(P.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if($){if(P.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new iP(...P)}return P[0]}function Q(P){for(;a(D.Dot)||a(D.OpenSquareBracket);){let $=t[r];++r;let F,J=$.type===D.OpenSquareBracket;if(J)F=G(),s(D.CloseSquareBracket,"Expected closing square bracket");else if(F=ae(),F.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");P=new YL(P,F,J)}return P}function R(){let P=C();for(;a(D.MultiplicativeBinaryOperator);){let $=t[r++],F=C();P=new dl($,P,F)}return P}function C(){let P=te();for(;l("is");){++r;let $=l("not");$&&++r;let F=ae();if(!(F instanceof zn))throw new SyntaxError("Expected identifier for the test");P=new oP(P,$,F)}return P}function te(){let P=W();for(;a(D.Pipe);){++r;let $=ae();if(!($ instanceof zn))throw new SyntaxError("Expected identifier for the filter");a(D.OpenParen)&&($=X($)),P=new rP(P,$)}return P}function ae(){let P=t[r++];switch(P.type){case D.NumericLiteral:{let $=P.value;return $.includes(".")?new ZL(Number($)):new JL(Number($))}case D.StringLiteral:{let $=P.value;for(;a(D.StringLiteral);)$+=t[r++].value;return new NE($)}case D.Identifier:return new zn(P.value);case D.OpenParen:{let $=x();return s(D.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),$}case D.OpenSquareBracket:{let $=[];for(;!a(D.CloseSquareBracket);)$.push(k()),a(D.Comma)&&++r;return++r,new eP($)}case D.OpenCurlyBracket:{let $=new Map;for(;!a(D.CloseCurlyBracket);){let F=k();s(D.Colon,"Expected colon between key and value in object literal");let J=k();$.set(F,J),a(D.Comma)&&++r}return++r,new tP($)}default:throw new SyntaxError(`Unexpected token: ${P.type}`)}}for(;r<t.length;)e.body.push(o());return e}function fP(t,e,r=1){if(e===void 0&&(e=t,t=0),r===0)throw new Error("range() step must not be zero");let s=[];if(r>0)for(let n=t;n<e;n+=r)s.push(n);else for(let n=t;n>e;n+=r)s.push(n);return s}function RE(t,e,r,s=1){let n=Math.sign(s);n>=0?(e=(e??=0)<0?Math.max(t.length+e,0):Math.min(e,t.length),r=(r??=t.length)<0?Math.max(t.length+r,0):Math.min(r,t.length)):(e=(e??=t.length-1)<0?Math.max(t.length+e,-1):Math.min(e,t.length-1),r=(r??=-1)<-1?Math.max(t.length+r,-1):Math.min(r,t.length-1));let o=[];for(let a=e;n*a<n*r;a+=s)o.push(t[a]);return o}function _P(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function mP(t){return hP(new Date,t)}function hP(t,e){let r=new Intl.DateTimeFormat(void 0,{month:"long"}),s=new Intl.DateTimeFormat(void 0,{month:"short"}),n=o=>o<10?"0"+o:o.toString();return e.replace(/%[YmdbBHM%]/g,o=>{switch(o){case"%Y":return t.getFullYear().toString();case"%m":return n(t.getMonth()+1);case"%d":return n(t.getDate());case"%b":return s.format(t);case"%B":return r.format(t);case"%H":return n(t.getHours());case"%M":return n(t.getMinutes());case"%%":return"%";default:return o}})}function gP(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wP(t,e,r,s){if(s===0)return t;let n=s==null||s<0?1/0:s,o=e.length===0?new RegExp("(?=)","gu"):new RegExp(gP(e),"gu");return t.replaceAll(o,a=>n>0?(--n,r):a)}var DE=class extends Error{},FE=class extends Error{},ir=class{type="RuntimeValue";value;builtins=new Map;constructor(t=void 0){this.value=t}__bool__(){return new pe(!!this.value)}toString(){return String(this.value)}},me=class extends ir{type="IntegerValue"},Ye=class extends ir{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},ee=class extends ir{type="StringValue";builtins=new Map([["upper",new Ge(()=>new ee(this.value.toUpperCase()))],["lower",new Ge(()=>new ee(this.value.toLowerCase()))],["strip",new Ge(()=>new ee(this.value.trim()))],["title",new Ge(()=>new ee(_P(this.value)))],["capitalize",new Ge(()=>new ee(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new me(this.value.length)],["rstrip",new Ge(()=>new ee(this.value.trimEnd()))],["lstrip",new Ge(()=>new ee(this.value.trimStart()))],["startswith",new Ge(t=>{if(t.length===0)throw new Error("startswith() requires at least one argument");let e=t[0];if(e instanceof ee)return new pe(this.value.startsWith(e.value));if(e instanceof ye){for(let r of e.value){if(!(r instanceof ee))throw new Error("startswith() tuple elements must be strings");if(this.value.startsWith(r.value))return new pe(!0)}return new pe(!1)}throw new Error("startswith() argument must be a string or tuple of strings")})],["endswith",new Ge(t=>{if(t.length===0)throw new Error("endswith() requires at least one argument");let e=t[0];if(e instanceof ee)return new pe(this.value.endsWith(e.value));if(e instanceof ye){for(let r of e.value){if(!(r instanceof ee))throw new Error("endswith() tuple elements must be strings");if(this.value.endsWith(r.value))return new pe(!0)}return new pe(!1)}throw new Error("endswith() argument must be a string or tuple of strings")})],["split",new Ge(t=>{let e=t[0]??new He;if(!(e instanceof ee||e instanceof He))throw new Error("sep argument must be a string or null");let r=t[1]??new me(-1);if(!(r instanceof me))throw new Error("maxsplit argument must be a number");let s=[];if(e instanceof He){let n=this.value.trimStart();for(let{0:o,index:a}of n.matchAll(/\S+/g)){if(r.value!==-1&&s.length>=r.value&&a!==void 0){s.push(o+n.slice(a+o.length));break}s.push(o)}}else{if(e.value==="")throw new Error("empty separator");s=this.value.split(e.value),r.value!==-1&&s.length>r.value&&s.push(s.splice(r.value).join(e.value))}return new ye(s.map(n=>new ee(n)))})],["replace",new Ge(t=>{if(t.length<2)throw new Error("replace() requires at least two arguments");let e=t[0],r=t[1];if(!(e instanceof ee&&r instanceof ee))throw new Error("replace() arguments must be strings");let s;if(t.length>2?t[2].type==="KeywordArgumentsValue"?s=t[2].value.get("count")??new He:s=t[2]:s=new He,!(s instanceof me||s instanceof He))throw new Error("replace() count argument must be a number or null");return new ee(wP(this.value,e.value,r.value,s.value))})]])},pe=class extends ir{type="BooleanValue"},xP=/[\x7f-\uffff]/g;function BE(t){return t.replace(xP,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}function Ls(t,e={},r=0,s=!0){let{indent:n=null,ensureAscii:o=!1,separators:a=null,sortKeys:i=!1}=e,l,c;switch(a?[l,c]=a:n?(l=",",c=": "):(l=", ",c=": "),t.type){case"NullValue":return"null";case"UndefinedValue":return s?"null":"undefined";case"IntegerValue":case"FloatValue":case"BooleanValue":return JSON.stringify(t.value);case"StringValue":{let p=JSON.stringify(t.value);return o&&(p=BE(p)),p}case"ArrayValue":case"ObjectValue":{let p=n?" ".repeat(n):"",d=`
|
|
5
|
+
`+p.repeat(r),_=d+p;if(t.type==="ArrayValue"){let m=t.value.map(w=>Ls(w,e,r+1,s));return n?`[${_}${m.join(`${l}${_}`)}${d}]`:`[${m.join(l)}]`}else{let m=Array.from(t.value.entries());i&&(m=m.sort(([x],[E])=>x.localeCompare(E)));let w=m.map(([x,E])=>{let k=JSON.stringify(x);o&&(k=BE(k));let A=`${k}${c}${Ls(E,e,r+1,s)}`;return n?`${_}${A}`:A});return n?`{${w.join(l)}${d}}`:`{${w.join(l)}}`}}default:throw new Error(`Cannot convert to JSON: ${t.type}`)}}var ct=class extends ir{type="ObjectValue";__bool__(){return new pe(this.value.size>0)}builtins=new Map([["get",new Ge(([t,e])=>{if(!(t instanceof ee))throw new Error(`Object key must be a string: got ${t.type}`);return this.value.get(t.value)??e??new He})],["items",new Ge(()=>this.items())],["keys",new Ge(()=>this.keys())],["values",new Ge(()=>this.values())],["dictsort",new Ge(t=>{let e=new Map,r=t.filter(i=>i instanceof fl?(e=i.value,!1):!0),s=r.at(0)??e.get("case_sensitive")??new pe(!1);if(!(s instanceof pe))throw new Error("case_sensitive must be a boolean");let n=r.at(1)??e.get("by")??new ee("key");if(!(n instanceof ee))throw new Error("by must be a string");if(!["key","value"].includes(n.value))throw new Error("by must be either 'key' or 'value'");let o=r.at(2)??e.get("reverse")??new pe(!1);if(!(o instanceof pe))throw new Error("reverse must be a boolean");let a=Array.from(this.value.entries()).map(([i,l])=>new ye([new ee(i),l])).sort((i,l)=>{let c=n.value==="key"?0:1,p=i.value[c],d=l.value[c],_=db(p,d,s.value);return o.value?-_:_});return new ye(a)})]]);items(){return new ye(Array.from(this.value.entries()).map(([t,e])=>new ye([new ee(t),e])))}keys(){return new ye(Array.from(this.value.keys()).map(t=>new ee(t)))}values(){return new ye(Array.from(this.value.values()))}toString(){return Ls(this,{},0,!1)}},fl=class extends ct{type="KeywordArgumentsValue"},ye=class extends ir{type="ArrayValue";builtins=new Map([["length",new me(this.value.length)]]);__bool__(){return new pe(this.value.length>0)}toString(){return Ls(this,{},0,!1)}},UE=class extends ye{type="TupleValue"},Ge=class extends ir{type="FunctionValue"},He=class extends ir{type="NullValue"},je=class extends ir{type="UndefinedValue"},Cs=class{constructor(t){this.parent=t}variables=new Map([["namespace",new Ge(t=>{if(t.length===0)return new ct(new Map);if(t.length!==1||!(t[0]instanceof ct))throw new Error("`namespace` expects either zero arguments or a single object argument");return t[0]})]]);tests=new Map([["boolean",t=>t.type==="BooleanValue"],["callable",t=>t instanceof Ge],["odd",t=>{if(!(t instanceof me))throw new Error(`cannot odd on ${t.type}`);return t.value%2!==0}],["even",t=>{if(!(t instanceof me))throw new Error(`cannot even on ${t.type}`);return t.value%2===0}],["false",t=>t.type==="BooleanValue"&&!t.value],["true",t=>t.type==="BooleanValue"&&t.value],["none",t=>t.type==="NullValue"],["string",t=>t.type==="StringValue"],["number",t=>t instanceof me||t instanceof Ye],["integer",t=>t instanceof me],["iterable",t=>t.type==="ArrayValue"||t.type==="StringValue"],["mapping",t=>t instanceof ct],["sequence",t=>t instanceof ye||t instanceof ct||t instanceof ee],["lower",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toLowerCase()}],["upper",t=>{let e=t.value;return t.type==="StringValue"&&e===e.toUpperCase()}],["none",t=>t.type==="NullValue"],["defined",t=>t.type!=="UndefinedValue"],["undefined",t=>t.type==="UndefinedValue"],["equalto",(t,e)=>t.value===e.value],["eq",(t,e)=>t.value===e.value]]);set(t,e){return this.declareVariable(t,Ku(e))}declareVariable(t,e){if(this.variables.has(t))throw new SyntaxError(`Variable already declared: ${t}`);return this.variables.set(t,e),e}setVariable(t,e){return this.variables.set(t,e),e}resolve(t){if(this.variables.has(t))return this;if(this.parent)return this.parent.resolve(t);throw new Error(`Unknown variable: ${t}`)}lookupVariable(t){try{return this.resolve(t).variables.get(t)??new je}catch{return new je}}};function yP(t){t.set("false",!1),t.set("true",!0),t.set("none",null),t.set("raise_exception",e=>{throw new Error(e)}),t.set("range",fP),t.set("strftime_now",mP),t.set("True",!0),t.set("False",!1),t.set("None",null)}function jE(t,e){let r=e.split("."),s=t;for(let n of r)if(s instanceof ct)s=s.value.get(n)??new je;else if(s instanceof ye){let o=parseInt(n,10);if(!isNaN(o)&&o>=0&&o<s.value.length)s=s.value[o];else return new je}else return new je;return s}function db(t,e,r=!1){if(t instanceof He&&e instanceof He)return 0;if(t instanceof He||e instanceof He)throw new Error(`Cannot compare ${t.type} with ${e.type}`);if(t instanceof je&&e instanceof je)return 0;if(t instanceof je||e instanceof je)throw new Error(`Cannot compare ${t.type} with ${e.type}`);let s=o=>o instanceof me||o instanceof Ye||o instanceof pe,n=o=>o instanceof pe?o.value?1:0:o.value;if(s(t)&&s(e)){let o=n(t),a=n(e);return o<a?-1:o>a?1:0}if(t.type!==e.type)throw new Error(`Cannot compare different types: ${t.type} and ${e.type}`);if(t.type==="StringValue"){let o=t.value,a=e.value;return r||(o=o.toLowerCase(),a=a.toLowerCase()),o<a?-1:o>a?1:0}else throw new Error(`Cannot compare type: ${t.type}`)}var bP=class{global;constructor(t){this.global=t??new Cs}run(t){return this.evaluate(t,this.global)}evaluateBinaryExpression(t,e){let r=this.evaluate(t.left,e);switch(t.operator.value){case"and":return r.__bool__().value?this.evaluate(t.right,e):r;case"or":return r.__bool__().value?r:this.evaluate(t.right,e)}let s=this.evaluate(t.right,e);switch(t.operator.value){case"==":return new pe(r.value==s.value);case"!=":return new pe(r.value!=s.value)}if(r instanceof je||s instanceof je){if(s instanceof je&&["in","not in"].includes(t.operator.value))return new pe(t.operator.value==="not in");throw new Error(`Cannot perform operation ${t.operator.value} on undefined values`)}else{if(r instanceof He||s instanceof He)throw new Error("Cannot perform operation on null values");if(t.operator.value==="~")return new ee(r.value.toString()+s.value.toString());if((r instanceof me||r instanceof Ye)&&(s instanceof me||s instanceof Ye)){let n=r.value,o=s.value;switch(t.operator.value){case"+":case"-":case"*":{let a=t.operator.value==="+"?n+o:t.operator.value==="-"?n-o:n*o;return r instanceof Ye||s instanceof Ye?new Ye(a):new me(a)}case"/":return new Ye(n/o);case"%":{let a=n%o;return r instanceof Ye||s instanceof Ye?new Ye(a):new me(a)}case"<":return new pe(n<o);case">":return new pe(n>o);case">=":return new pe(n>=o);case"<=":return new pe(n<=o)}}else if(r instanceof ye&&s instanceof ye){if(t.operator.value==="+")return new ye(r.value.concat(s.value))}else if(s instanceof ye){let n=s.value.find(o=>o.value===r.value)!==void 0;switch(t.operator.value){case"in":return new pe(n);case"not in":return new pe(!n)}}}if((r instanceof ee||s instanceof ee)&&t.operator.value==="+")return new ee(r.value.toString()+s.value.toString());if(r instanceof ee&&s instanceof ee)switch(t.operator.value){case"in":return new pe(s.value.includes(r.value));case"not in":return new pe(!s.value.includes(r.value))}if(r instanceof ee&&s instanceof ct)switch(t.operator.value){case"in":return new pe(s.value.has(r.value));case"not in":return new pe(!s.value.has(r.value))}throw new SyntaxError(`Unknown operator "${t.operator.value}" between ${r.type} and ${s.type}`)}evaluateArguments(t,e){let r=[],s=new Map;for(let n of t)if(n.type==="SpreadExpression"){let o=n,a=this.evaluate(o.argument,e);if(!(a instanceof ye))throw new Error(`Cannot unpack non-iterable type: ${a.type}`);for(let i of a.value)r.push(i)}else if(n.type==="KeywordArgumentExpression"){let o=n;s.set(o.key.value,this.evaluate(o.value,e))}else{if(s.size>0)throw new Error("Positional arguments must come before keyword arguments");r.push(this.evaluate(n,e))}return[r,s]}applyFilter(t,e,r){if(e.type==="Identifier"){let s=e;if(s.value==="safe")return t;if(s.value==="tojson")return new ee(Ls(t,{}));if(t instanceof ye)switch(s.value){case"list":return t;case"first":return t.value[0];case"last":return t.value[t.value.length-1];case"length":return new me(t.value.length);case"reverse":return new ye(t.value.slice().reverse());case"sort":return new ye(t.value.slice().sort((n,o)=>db(n,o,!1)));case"join":return new ee(t.value.map(n=>n.value).join(""));case"string":return new ee(Ls(t,{},0,!1));case"unique":{let n=new Set,o=[];for(let a of t.value)n.has(a.value)||(n.add(a.value),o.push(a));return new ye(o)}default:throw new Error(`Unknown ArrayValue filter: ${s.value}`)}else if(t instanceof ee)switch(s.value){case"length":case"upper":case"lower":case"title":case"capitalize":{let n=t.builtins.get(s.value);if(n instanceof Ge)return n.value([],r);if(n instanceof me)return n;throw new Error(`Unknown StringValue filter: ${s.value}`)}case"trim":return new ee(t.value.trim());case"indent":return new ee(t.value.split(`
|
|
6
6
|
`).map((n,o)=>o===0||n.length===0?n:" "+n).join(`
|
|
7
|
-
`));case"join":case"string":return t;case"int":{let n=parseInt(t.value,10);return new
|
|
8
|
-
`),
|
|
9
|
-
`))}case"replace":{let o=t.builtins.get("replace");if(!(o instanceof Ge))throw new Error("replace filter not available");let[a,i]=this.evaluateArguments(s.args,r);return o.value([...a,new
|
|
10
|
-
`,xP="{%- ",yP=" -%}";function bP(t){switch(t.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return t.operator.value==="and"?1:t.operator.value==="in"||t.operator.value==="not in"?2:0}return 0}function vP(t,e=" "){let r=typeof e=="number"?" ".repeat(e):e;return Jt(t.body,0,r).replace(/\n$/,"")}function mt(...t){return xP+t.join(" ")+yP}function Jt(t,e,r){return t.map(s=>kP(s,e,r)).join(at)}function kP(t,e,r){let s=r.repeat(e);switch(t.type){case"Program":return Jt(t.body,e,r);case"If":return EP(t,e,r);case"For":return AP(t,e,r);case"Set":return MP(t,e,r);case"Macro":return TP(t,e,r);case"Break":return s+mt("break");case"Continue":return s+mt("continue");case"CallStatement":return SP(t,e,r);case"FilterStatement":return OP(t,e,r);case"Comment":return s+"{# "+t.value+" #}";default:return s+"{{- "+ke(t)+" -}}"}}function EP(t,e,r){let s=r.repeat(e),n=[],o=t;for(;o&&(n.push({test:o.test,body:o.body}),o.alternate.length===1&&o.alternate[0].type==="If");)o=o.alternate[0];let a=s+mt("if",ke(n[0].test))+at+Jt(n[0].body,e+1,r);for(let i=1;i<n.length;++i)a+=at+s+mt("elif",ke(n[i].test))+at+Jt(n[i].body,e+1,r);return o&&o.alternate.length>0&&(a+=at+s+mt("else")+at+Jt(o.alternate,e+1,r)),a+=at+s+mt("endif"),a}function AP(t,e,r){let s=r.repeat(e),n="";if(t.iterable.type==="SelectExpression"){let a=t.iterable;n=`${ke(a.lhs)} if ${ke(a.test)}`}else n=ke(t.iterable);let o=s+mt("for",ke(t.loopvar),"in",n)+at+Jt(t.body,e+1,r);return t.defaultBlock.length>0&&(o+=at+s+mt("else")+at+Jt(t.defaultBlock,e+1,r)),o+=at+s+mt("endfor"),o}function MP(t,e,r){let s=r.repeat(e),n=ke(t.assignee),o=t.value?ke(t.value):"",a=s+mt("set",`${n}${t.value?" = "+o:""}`);return t.body.length===0?a:a+at+Jt(t.body,e+1,r)+at+s+mt("endset")}function TP(t,e,r){let s=r.repeat(e),n=t.args.map(ke).join(", ");return s+mt("macro",`${t.name.value}(${n})`)+at+Jt(t.body,e+1,r)+at+s+mt("endmacro")}function SP(t,e,r){let s=r.repeat(e),n=t.callerArgs&&t.callerArgs.length>0?`(${t.callerArgs.map(ke).join(", ")})`:"",o=ke(t.call),a=s+mt(`call${n}`,o)+at;return a+=Jt(t.body,e+1,r)+at,a+=s+mt("endcall"),a}function OP(t,e,r){let s=r.repeat(e),n=t.filter.type==="Identifier"?t.filter.value:ke(t.filter),o=s+mt("filter",n)+at;return o+=Jt(t.body,e+1,r)+at,o+=s+mt("endfilter"),o}function ke(t,e=-1){switch(t.type){case"SpreadExpression":return`*${ke(t.argument)}`;case"Identifier":return t.value;case"IntegerLiteral":return`${t.value}`;case"FloatLiteral":return`${t.value}`;case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":{let r=t,s=bP(r),n=ke(r.left,s),o=ke(r.right,s+1),a=`${n} ${r.operator.value} ${o}`;return s<e?`(${a})`:a}case"UnaryExpression":{let r=t;return r.operator.value+(r.operator.value==="not"?" ":"")+ke(r.argument,1/0)}case"CallExpression":{let r=t,s=r.args.map(ke).join(", ");return`${ke(r.callee)}(${s})`}case"MemberExpression":{let r=t,s=ke(r.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(r.object.type)||(s=`(${s})`);let n=ke(r.property);return!r.computed&&r.property.type!=="Identifier"&&(n=`(${n})`),r.computed?`${s}[${n}]`:`${s}.${n}`}case"FilterExpression":{let r=t,s=ke(r.operand,1/0);return r.filter.type==="CallExpression"?`${s} | ${ke(r.filter)}`:`${s} | ${r.filter.value}`}case"SelectExpression":{let r=t;return`${ke(r.lhs)} if ${ke(r.test)}`}case"TestExpression":{let r=t;return`${ke(r.operand)} is${r.negate?" not":""} ${r.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let r=t.value.map(ke),s=t.type==="ArrayLiteral"?"[]":"()";return`${s[0]}${r.join(", ")}${s[1]}`}case"ObjectLiteral":return`{${Array.from(t.value.entries()).map(([s,n])=>`${ke(s)}: ${ke(n)}`).join(", ")}}`;case"SliceExpression":{let r=t,s=r.start?ke(r.start):"",n=r.stop?ke(r.stop):"",o=r.step?`:${ke(r.step)}`:"";return`${s}:${n}${o}`}case"KeywordArgumentExpression":{let r=t;return`${r.key.value}=${ke(r.value)}`}case"Ternary":{let r=t,s=`${ke(r.trueExpr)} if ${ke(r.condition,0)} else ${ke(r.falseExpr)}`;return e>-1?`(${s})`:s}default:throw new Error(`Unknown expression type: ${t.type}`)}}var Xk=class{parsed;constructor(t){let e=UC(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=cP(e)}render(t){let e=new Ms;if(gP(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new wP(e).run(this.parsed).value}format(t){return vP(this.parsed,t?.indent||" ")}};var Ze=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}_call(...t){throw Error("Must implement _call method in subclass")}};var Ss=kr(require("fs"),1),IP={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"},Hr=class t{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Ss.default.existsSync(e),this.exists){this.status=200,this.statusText="OK";let r=Ss.default.statSync(e);this.headers.set("content-length",r.size.toString()),this.updateContentType();let s=Ss.default.createReadStream(e);this.body=new ReadableStream({start(n){s.on("data",o=>n.enqueue(o)),s.on("end",()=>n.close()),s.on("error",o=>n.error(o))},cancel(){s.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",IP[e]??"application/octet-stream")}clone(){let e=new t(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await Ss.default.promises.readFile(this.filePath)).buffer}async blob(){let e=await Ss.default.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await Ss.default.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}};var Mn=kr(require("fs"),1),Hi=kr(require("path"),1);var An=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(se.IS_CRYPTO_AVAILABLE){let i=new Uint32Array(1);crypto.getRandomValues(i),e=i[0]}else e=Date.now()>>>0;let r=this._mt,s=(i,l)=>Math.imul(i,l)>>>0,n=[];for(let i=e||0;i>0;i=Math.floor(i/4294967296))n.push(i&4294967295);n.length||n.push(0),r[0]=19650218;for(let i=1;i<624;++i)r[i]=s(1812433253,r[i-1]^r[i-1]>>>30)+i>>>0;let o=1,a=0;for(let i=Math.max(624,n.length);i>0;--i,++o,++a)o>=624&&(r[0]=r[623],o=1),a>=n.length&&(a=0),r[o]=(r[o]^s(r[o-1]^r[o-1]>>>30,1664525))+n[a]+a>>>0;for(let i=623;i>0;--i,++o)o>=624&&(r[0]=r[623],o=1),r[o]=(r[o]^s(r[o-1]^r[o-1]>>>30,1566083941))-o>>>0;r[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let s=0;s<624;++s){let n=e[s]&2147483648|e[(s+1)%624]&2147483647;e[s]=(e[(s+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let r=e[this._idx++];return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^=r>>>18,r>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,r=1){let s=this._gauss_next;if(this._gauss_next=null,s===null){let n=this.random()*2*Math.PI,o=Math.sqrt(-2*Math.log(1-this.random()));s=Math.cos(n)*o,this._gauss_next=Math.sin(n)*o}return e+s*r}shuffle(e){for(let r=e.length-1;r>0;--r){let s=32-Math.clz32(r+1),n=this._int32()>>>32-s;for(;n>r;)n=this._int32()>>>32-s;let o=e[r];e[r]=e[n],e[n]=o}}choices(e,r){return e[Kk(this._random_fn,r)]}};function Kk(t,e){let r=0;for(let n=0;n<e.length;++n)r+=e[n];let s=t()*r;for(let n=0;n<e.length;++n)if(s-=e[n],s<0)return n;return e.length-1}var ur=new An,Xr=Object.freeze({Random:An,seed:ur.seed.bind(ur),random:ur.random.bind(ur),gauss:ur.gauss.bind(ur),shuffle:ur.shuffle.bind(ur),choices:ur.choices.bind(ur)}),Yk=t=>Kk(Xr.random,t);var CP=new An,Tn=class{constructor(e){this.path=e}async match(e){let r=Hi.default.join(this.path,e),s=new Hr(r);if(s.exists)return s}async put(e,r,s=void 0){let n=Hi.default.join(this.path,e),o=se.IS_PROCESS_AVAILABLE?process.pid:Date.now(),a=CP._int32().toString(36),i=n+`.tmp.${o}.${a}`;try{let l=r.headers.get("Content-Length"),u=parseInt(l??"0"),p=0;await Mn.default.promises.mkdir(Hi.default.dirname(n),{recursive:!0});let f=Mn.default.createWriteStream(i),m=r.body.getReader();for(;;){let{done:h,value:w}=await m.read();if(h)break;await new Promise((v,E)=>{f.write(w,A=>{if(A){E(A);return}v()})}),p+=w.length;let x=u?p/u*100:0;s?.({progress:x,loaded:p,total:u})}await new Promise((h,w)=>{f.close(x=>x?w(x):h())}),await Mn.default.promises.rename(i,n)}catch(l){try{await Mn.default.promises.unlink(i)}catch{}throw l}}async delete(e){let r=Hi.default.join(this.path,e);try{return await Mn.default.promises.unlink(r),!0}catch{return!1}}};var Qk={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"},Lu=100,Jk=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;var v0={};function Xi(...t){return t=t.map((e,r)=>(r&&(e=e.replace(new RegExp("^/"),"")),r!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e)),t.join("/")}function Kr(t,e=null,r=null){let s;try{s=new URL(t)}catch{return!1}return!(e&&!e.includes(s.protocol)||r&&!r.includes(s.hostname))}function Zk(t){return!(!Jk.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function eE(t,e,r){if(!r)return null;let s=Qk[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${s}: "${e}".`)}async function tE(t,e,r){let s=t.headers.get("Content-Length"),n=s?parseInt(s,10):r??0;s===null&&!r&&J.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let o=new Uint8Array(n),a=0,i=t.body.getReader();async function l(){let{done:u,value:p}=await i.read();if(u)return;let f=a+p.length;if(f>n){n=f;let h=new Uint8Array(n);h.set(o),o=h}o.set(p,a),a=f;let m=a/n*100;return e({progress:m,loaded:a,total:n}),l()}return await l(),o}function k0(t){return Kr(t,["blob:"])}function E0(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof v0<"u"&&v0.url)e=v0.url;else return t;return new URL(t,e).href}async function er(t=null){let e=null;if(me.useCustomCache){if(!me.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!me.customCache.match||!me.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");e=me.customCache}if(!e&&me.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{e=await caches.open(me.cacheKey)}catch(r){J.warn("An error occurred while opening the browser cache:",r)}}if(!e&&me.useFSCache){if(!se.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");e=new Tn(t??me.cacheDir)}return e}async function rE(t,...e){for(let r of e)try{let s=await t.match(r);if(s)return s}catch{continue}}async function PP(t){if(!Kr(t,["http:","https:"]))return null;let e=A0(t);return e.set("Range","bytes=0-0"),me.fetch(t,{method:"GET",headers:e})}async function pr(t,e,r={}){let s=await er(r?.cache_dir),{localPath:n,remoteURL:o,proposedCacheKey:a,validModelId:i}=Qr(t,e,r,s),l=await Jr(s,n,a);if(l!==void 0&&typeof l!="string"){let u=l.headers.get("content-length"),p=l.headers.get("content-type");return{exists:!0,size:u?parseInt(u,10):void 0,contentType:p||void 0,fromCache:!0}}if(me.allowLocalModels&&!Kr(n,["http:","https:"]))try{let p=await Yr(n);if(typeof p!="string"&&p.status!==404){let f=p.headers.get("content-length"),m=p.headers.get("content-type");return{exists:!0,size:f?parseInt(f,10):void 0,contentType:m||void 0,fromCache:!1}}}catch{}if(me.allowRemoteModels&&!r.local_files_only&&i)try{let u=await PP(o);if(u&&u.status>=200&&u.status<300){let p,f=u.headers.get("content-type");if(u.status===206){let m=u.headers.get("content-range");if(m){let h=m.match(/bytes \d+-\d+\/(\d+)/);h&&(p=parseInt(h[1],10))}}else if(u.status===200)try{await u.body?.cancel()}catch{}if(p===void 0){let m=u.headers.get("content-length");p=m?parseInt(m,10):void 0}return{exists:!0,size:p,contentType:f||void 0,fromCache:!1}}}catch(u){J.warn(`Unable to fetch file metadata for "${o}": ${u}`)}return{exists:!1,fromCache:!1}}async function Yr(t){return me.useFS&&!Kr(t,["http:","https:","blob:"])?new Hr(t instanceof URL?t.protocol==="file:"?t.pathname:t.toString():t):me.fetch(t,{headers:A0(t)})}function A0(t){let e=typeof process<"u"&&process?.release?.name==="node",r=new Headers;if(e){let s=!!process.env?.TESTING_REMOTELY,n=me.version;if(r.set("User-Agent",`transformers.js/${n}; is_ci/${s};`),Kr(t,["http:","https:"],["huggingface.co","hf.co"])){let a=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;a&&r.set("Authorization",`Bearer ${a}`)}}return r}function Qr(t,e,r={},s=null){let n=r.revision??"main",o=Xi(t,e),a=Zk(t),i=a?Xi(me.localModelPath,o):o,l=Xi(me.remoteHost,me.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),u=s instanceof Tn?n==="main"?o:Xi(t,n,e):l;return{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:u,validModelId:a}}async function Jr(t,e,r){if(t)return await rE(t,e,r)}async function LP(t,e,r,s,n,o,a={}){if(await r.match(s)===void 0)if(o)typeof n!="string"&&await r.put(s,new Response(o,{headers:n.headers})).catch(i=>{J.warn(`Unable to add response to browser cache: ${i}.`)});else{let i=a.progress_callback?l=>Er(a.progress_callback,{status:"progress",name:t,file:e,...l}):void 0;await r.put(s,n,i)}}async function NP(t,e,r=!0,s={},n=!1,o=null){let{requestURL:a,localPath:i,remoteURL:l,proposedCacheKey:u,validModelId:p}=Qr(t,e,s,o),f,m=!1,h;h=await Jr(o,i,u);let w=h!==void 0;if(!w){if(me.allowLocalModels)if(Kr(a,["http:","https:"])){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${a}.`);if(!me.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${a}.`)}else try{h=await Yr(i),f=i}catch(A){J.warn(`Unable to load from local path "${i}": "${A}"`)}if(h===void 0||typeof h!="string"&&h.status===404){if(s.local_files_only||!me.allowRemoteModels){if(r)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${i}".`);return null}if(!p)throw Error(`Local file missing at "${i}" and download aborted due to invalid model ID "${t}".`);if(h=await Yr(l),h.status!==200)return eE(h.status,l,r);f=u}m=o&&typeof Response<"u"&&h instanceof Response&&h.status===200}Er(s.progress_callback,{status:"download",name:t,file:e});let x;if(!(se.IS_NODE_ENV&&n)){let E;if(typeof h!="string")if(!s.progress_callback)E=new Uint8Array(await h.arrayBuffer());else if(w&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))E=new Uint8Array(await h.arrayBuffer()),Er(s.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:E.length,total:E.length});else{let A,S=h.headers.get("content-length");if(S)A=parseInt(S,10);else try{let T=await pr(t,e,s);T.size&&(A=T.size)}catch{}E=await tE(h,T=>{Er(s.progress_callback,{status:"progress",name:t,file:e,...T})},A)}x=E}if(m&&f&&typeof h!="string"&&await LP(t,e,o,f,h,x,s),Er(s.progress_callback,{status:"done",name:t,file:e}),x){if(!se.IS_NODE_ENV&&n)throw new Error("Cannot return path in a browser environment.");return x}if(h instanceof Hr)return h.filePath;let v=await o?.match(f);if(v instanceof Hr)return v.filePath;if(v instanceof Response)return new Uint8Array(await v.arrayBuffer());if(typeof v=="string")return v;throw new Error("Unable to get model file path or buffer.")}async function Ki(t,e,r=!0,s={},n=!1){if(!me.allowLocalModels){if(s.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(!me.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}Er(s.progress_callback,{status:"initiate",name:t,file:e});let o=await er(s?.cache_dir);return await NP(t,e,r,s,n,o)}async function M0(t,e,r=!0,s={}){let n=await Ki(t,e,r,s,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function ut(t,e,r=!0,s={}){let n=await M0(t,e,r,s);return n===null?{}:JSON.parse(n)}function nE(t,[e,r,s],[n,o],a="bilinear",i=!1){let l=o/s,u=n/r,p=new t.constructor(n*o*e),f=r*s,m=n*o;for(let h=0;h<n;++h)for(let w=0;w<o;++w){let x=h*o+w,v=(w+.5)/l-.5,E=(h+.5)/u-.5,A=Math.floor(v),S=Math.floor(E),T=Math.min(A+1,s-1),L=Math.min(S+1,r-1);A=Math.max(A,0),S=Math.max(S,0);let P=v-A,k=E-S,F=(1-P)*(1-k),K=P*(1-k),W=(1-P)*k,X=P*k,H=S*s,Y=L*s,U=H+A,C=H+T,ne=Y+A,ae=Y+T;for(let I=0;I<e;++I){let N=I*f;p[I*m+x]=F*t[N+U]+K*t[N+C]+W*t[N+ne]+X*t[N+ae]}}return p}function oE(t,e,r){let s=new Array(r.length),n=new Array(r.length);for(let i=r.length-1,l=1;i>=0;--i)n[i]=l,s[i]=e[r[i]],l*=s[i];let o=r.map((i,l)=>n[r.indexOf(l)]),a=new t.constructor(t.length);for(let i=0;i<t.length;++i){let l=0;for(let u=e.length-1,p=i;u>=0;--u)l+=p%e[u]*o[u],p=Math.floor(p/e[u]);a[l]=t[i]}return[a,s]}function Ie(t){let e=Se(t)[0],r=t.map(o=>Math.exp(o-e)),s=r.reduce((o,a)=>o+a,0);return r.map(o=>o/s)}function $u(t){let e=Se(t)[0],r=0;for(let o=0;o<t.length;++o)r+=Math.exp(t[o]-e);let s=Math.log(r);return t.map(o=>o-e-s)}function S0(t,e){let r=0;for(let s=0;s<t.length;++s)r+=t[s]*e[s];return r}function aE(t,e){let r=S0(t,e),s=sE(t),n=sE(e);return r/(s*n)}function sE(t){return Math.sqrt(t.reduce((e,r)=>e+r*r,0))}function Yi(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]<e&&(e=t[s],r=s);return[e,r]}function Se(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]>e&&(e=t[s],r=s);return[e,r]}function iE(t){return t>0&&(t&t-1)===0}var Nu=class{constructor(e){if(this.size=e|0,this.size<=1||!iE(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 s=0;s<this.table.length;s+=2){let n=Math.PI*s/this.size;this.table[s]=Math.cos(n),this.table[s+1]=-Math.sin(n)}let r=0;for(let s=1;this.size>s;s<<=1)++r;this._width=r%2===0?r-1:r,this._bitrev=new Int32Array(1<<this._width);for(let s=0;s<this._bitrev.length;++s){this._bitrev[s]=0;for(let n=0;n<this._width;n+=2){let o=this._width-n-2;this._bitrev[s]|=(s>>>n&3)<<o}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,r){let s=r||new Array(e.length>>>1);for(let n=0;n<e.length;n+=2)s[n>>>1]=e[n];return s}toComplexArray(e,r){let s=r||this.createComplexArray();for(let n=0;n<s.length;n+=2)s[n]=e[n>>>1],s[n+1]=0;return s}transform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._transform4(e,r,1)}realTransform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._realTransform4(e,r,1)}inverseTransform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._transform4(e,r,-1);for(let s=0;s<e.length;++s)e[s]/=this.size}_transform4(e,r,s){let n=this._csize,a=1<<this._width,i=n/a<<1,l,u,p=this._bitrev;if(i===4)for(l=0,u=0;l<n;l+=i,++u){let m=p[u];this._singleTransform2(r,e,l,m,a)}else for(l=0,u=0;l<n;l+=i,++u){let m=p[u];this._singleTransform4(r,e,l,m,a,s)}let f=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let m=i>>>2;for(l=0;l<n;l+=i){let h=l+m-1;for(let w=l,x=0;w<h;w+=2,x+=a){let v=w,E=v+m,A=E+m,S=A+m,T=e[v],L=e[v+1],P=e[E],k=e[E+1],F=e[A],K=e[A+1],W=e[S],X=e[S+1],H=f[x],Y=s*f[x+1],U=P*H-k*Y,C=P*Y+k*H,ne=f[2*x],ae=s*f[2*x+1],I=F*ne-K*ae,N=F*ae+K*ne,R=f[3*x],ee=s*f[3*x+1],de=W*R-X*ee,Fe=W*ee+X*R,Le=T+I,At=L+N,Je=T-I,tt=L-N,nt=U+de,Me=C+Fe,xe=s*(U-de),We=s*(C-Fe);e[v]=Le+nt,e[v+1]=At+Me,e[E]=Je+We,e[E+1]=tt-xe,e[A]=Le-nt,e[A+1]=At-Me,e[S]=Je-We,e[S+1]=tt+xe}}}}_singleTransform2(e,r,s,n,o){let a=e[n],i=e[n+1],l=e[n+o],u=e[n+o+1];r[s]=a+l,r[s+1]=i+u,r[s+2]=a-l,r[s+3]=i-u}_singleTransform4(e,r,s,n,o,a){let i=o*2,l=o*3,u=e[n],p=e[n+1],f=e[n+o],m=e[n+o+1],h=e[n+i],w=e[n+i+1],x=e[n+l],v=e[n+l+1],E=u+h,A=p+w,S=u-h,T=p-w,L=f+x,P=m+v,k=a*(f-x),F=a*(m-v);r[s]=E+L,r[s+1]=A+P,r[s+2]=S+F,r[s+3]=T-k,r[s+4]=E-L,r[s+5]=A-P,r[s+6]=S-F,r[s+7]=T+k}_realTransform4(e,r,s){let n=this._csize,a=1<<this._width,i=n/a<<1,l,u,p=this._bitrev;if(i===4)for(l=0,u=0;l<n;l+=i,++u){let h=p[u];this._singleRealTransform2(r,e,l,h>>>1,a>>>1)}else for(l=0,u=0;l<n;l+=i,++u){let h=p[u];this._singleRealTransform4(r,e,l,h>>>1,a>>>1,s)}let f=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let h=i>>>1,w=h>>>1,x=w>>>1;for(l=0;l<n;l+=i)for(let v=0,E=0;v<=x;v+=2,E+=a){let A=l+v,S=A+w,T=S+w,L=T+w,P=e[A],k=e[A+1],F=e[S],K=e[S+1],W=e[T],X=e[T+1],H=e[L],Y=e[L+1],U=P,C=k,ne=f[E],ae=s*f[E+1],I=F*ne-K*ae,N=F*ae+K*ne,R=f[2*E],ee=s*f[2*E+1],de=W*R-X*ee,Fe=W*ee+X*R,Le=f[3*E],At=s*f[3*E+1],Je=H*Le-Y*At,tt=H*At+Y*Le,nt=U+de,Me=C+Fe,xe=U-de,We=C-Fe,Mt=I+Je,be=N+tt,De=s*(I-Je),qr=s*(N-tt);if(e[A]=nt+Mt,e[A+1]=Me+be,e[S]=xe+qr,e[S+1]=We-De,v===0){e[T]=nt-Mt,e[T+1]=Me-be;continue}if(v===x)continue;let ys=l+w-v,Tt=l+h-v;e[ys]=xe-s*qr,e[ys+1]=-We-s*De,e[Tt]=nt-s*Mt,e[Tt+1]=-Me+s*be}}let m=n>>>1;for(let h=2;h<m;h+=2)e[n-h]=e[h],e[n-h+1]=-e[h+1]}_singleRealTransform2(e,r,s,n,o){let a=e[n],i=e[n+o];r[s]=a+i,r[s+1]=0,r[s+2]=a-i,r[s+3]=0}_singleRealTransform4(e,r,s,n,o,a){let i=o*2,l=o*3,u=e[n],p=e[n+o],f=e[n+i],m=e[n+l],h=u+f,w=u-f,x=p+m,v=a*(p-m);r[s]=h+x,r[s+1]=0,r[s+2]=w,r[s+3]=-v,r[s+4]=h-x,r[s+5]=0,r[s+6]=w,r[s+7]=v}},T0=class{constructor(e){let r=2*(e-1),s=2*(2*e-1),n=2**Math.ceil(Math.log2(s));this.bufferSize=n,this._a=r;let o=new Float64Array(s),a=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);let i=-2*Math.PI/e,l=Math.cos(i),u=Math.sin(i);for(let p=0;p<s>>1;++p){let f=(p+1-e)**2/2,m=Math.sqrt(l**2+u**2)**f,h=f*Math.atan2(u,l),w=2*p;o[w]=m*Math.cos(h),o[w+1]=m*Math.sin(h),a[w]=o[w],a[w+1]=-o[w+1]}this._slicedChirpBuffer=o.subarray(r,s),this._f=new Nu(n>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,r,s){let n=this._buffer1,o=this._buffer2,a=this._outBuffer1,i=this._outBuffer2,l=this._chirpBuffer,u=this._slicedChirpBuffer,p=this._a;if(s)for(let f=0;f<u.length;f+=2){let m=f+1,h=f>>1,w=r[h];n[f]=w*u[f],n[m]=w*u[m]}else for(let f=0;f<u.length;f+=2){let m=f+1;n[f]=r[f]*u[f]-r[m]*u[m],n[m]=r[f]*u[m]+r[m]*u[f]}this._f.transform(a,n);for(let f=0;f<l.length;f+=2){let m=f+1;o[f]=a[f]*l[f]-a[m]*l[m],o[m]=a[f]*l[m]+a[m]*l[f]}this._f.inverseTransform(i,o);for(let f=0;f<i.length;f+=2){let m=i[f+p],h=i[f+p+1],w=u[f],x=u[f+1];e[f]=m*w-h*x,e[f+1]=m*x+h*w}}transform(e,r){this._transform(e,r,!1)}realTransform(e,r){this._transform(e,r,!0)}},zu=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=iE(e),this.isPowerOfTwo?(this.fft=new Nu(e),this.outputBufferSize=2*e):(this.fft=new T0(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,r){this.fft.realTransform(e,r)}transform(e,r){this.fft.transform(e,r)}};function lE(t,e){if(e%2===0||e<=0)throw new Error("Window size must be a positive odd number");let r=new t.constructor(t.length),s=new t.constructor(e),n=Math.floor(e/2);for(let o=0;o<t.length;++o){let a=0;for(let i=-n;i<=n;++i){let l=o+i;l<0?l=Math.abs(l):l>=t.length&&(l=2*(t.length-1)-l),s[a++]=t[l]}s.sort(),r[o]=s[n]}return r}function Os(t,e){let r=Math.pow(10,e);return Math.round(t*r)/r}function cE(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function uE(t){let e=t.length,r=t[0].length,s=[e+1,r+1],n=Array.from({length:s[0]},()=>Array(s[1]).fill(1/0));n[0][0]=0;let o=Array.from({length:s[0]},()=>Array(s[1]).fill(-1));for(let p=1;p<s[1];++p)for(let f=1;f<s[0];++f){let m=n[f-1][p-1],h=n[f-1][p],w=n[f][p-1],x,v;m<h&&m<w?(x=m,v=0):h<m&&h<w?(x=h,v=1):(x=w,v=2),n[f][p]=t[f-1][p-1]+x,o[f][p]=v}for(let p=0;p<s[1];++p)o[0][p]=2;for(let p=0;p<s[0];++p)o[p][0]=1;let a=e,i=r,l=[],u=[];for(;a>0||i>0;)switch(l.push(a-1),u.push(i-1),o[a][i]){case 0:--a,--i;break;case 1:--a;break;case 2:--i;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${i}]. Please file a bug report.`)}return l.reverse(),u.reverse(),[l,u]}var pE=(function(){let t=null;return function(e){if(!t){t=new Float32Array(65536);let o=new ArrayBuffer(4),a=new Uint32Array(o),i=new Float32Array(o);for(let l=0;l<t.length;++l){let u=0,p=(l&32768)<<16,f=(l&31744)>>10,m=l&1023;if(f===31)u=p|2139095040|m<<13;else if(f===0)if(m===0)u=p;else{let h=113;for(;(m&1024)===0;)m<<=1,--h;m&=-1025,u=p|h<<23|m<<13}else u=p|f+112<<23|m<<13;a[0]=u,t[l]=i[0]}}let r=e.length,s=t,n=new Float32Array(r);for(let o=0;o<r;++o)n[o]=s[e[o]];return n}})();var uL=kr(require("onnxruntime-node"),1);var wb={};Es(wb,{InferenceSession:()=>sb,TRACE:()=>Wu,TRACE_EVENT_BEGIN:()=>ss,TRACE_EVENT_END:()=>ns,TRACE_FUNC_BEGIN:()=>zs,TRACE_FUNC_END:()=>$s,Tensor:()=>rr,default:()=>cL,env:()=>He,registerBackend:()=>Ns});var tr={};var tb=Object.defineProperty,zP=Object.getOwnPropertyDescriptor,$P=Object.getOwnPropertyNames,RP=Object.prototype.hasOwnProperty,DP=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),ye=(t,e)=>()=>(t&&(e=t(t=0)),e),nl=(t,e)=>{for(var r in e)tb(t,r,{get:e[r],enumerable:!0})},UP=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $P(e))!RP.call(t,n)&&n!==r&&tb(t,n,{get:()=>e[n],enumerable:!(s=zP(e,n))||s.enumerable});return t},qu=t=>UP(tb({},"__esModule",{value:!0}),t),Qi,Zr,Ns,dE,UE,BE=ye(()=>{"use strict";Qi=new Map,Zr=[],Ns=(t,e,r)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let s=Qi.get(t);if(s===void 0)Qi.set(t,{backend:e,priority:r});else{if(s.priority>r)return;if(s.priority===r&&s.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${r}`)}if(r>=0){let n=Zr.indexOf(t);n!==-1&&Zr.splice(n,1);for(let o=0;o<Zr.length;o++)if(Qi.get(Zr[o]).priority<=r){Zr.splice(o,0,t);return}Zr.push(t)}return}throw new TypeError("not a valid backend")},dE=async t=>{let e=Qi.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let r=!!e.initPromise;try{return r||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(s){return r||(e.error=`${s}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},UE=async t=>{let e=t.executionProviders||[],r=e.map(l=>typeof l=="string"?l:l.name),s=r.length===0?Zr:r,n,o=[],a=new Set;for(let l of s){let u=await dE(l);typeof u=="string"?o.push({name:l,err:u}):(n||(n=u),n===u&&a.add(l))}if(!n)throw new Error(`no available backend found. ERR: ${o.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:u}of o)r.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${u}`);let i=e.filter(l=>a.has(typeof l=="string"?l:l.name));return[n,new Proxy(t,{get:(l,u)=>u==="executionProviders"?i:Reflect.get(l,u)})]}}),BP=ye(()=>{"use strict";BE()}),FE,FP=ye(()=>{"use strict";FE="1.24.0-dev.20251116-b39e144322"}),O0,pt,jE=ye(()=>{"use strict";FP(),O0="warning",pt={wasm:{},webgl:{},webgpu:{},versions:{common:FE},set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);O0=t}},get logLevel(){return O0}},Object.defineProperty(pt,"logLevel",{enumerable:!0})}),He,jP=ye(()=>{"use strict";jE(),He=pt}),GE,qE,GP=ye(()=>{"use strict";GE=(t,e)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=t.dims[3],r.height=t.dims[2];let s=r.getContext("2d");if(s!=null){let n,o;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(n=t.dims[2],o=t.dims[3]):(n=t.dims[3],o=t.dims[2]);let a=e?.format!==void 0?e.format:"RGB",i=e?.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 p=o*n,f=0,m=p,h=p*2,w=-1;a==="RGBA"?(f=0,m=p,h=p*2,w=p*3):a==="RGB"?(f=0,m=p,h=p*2):a==="RBG"&&(f=0,h=p,m=p*2);for(let x=0;x<o;x++)for(let v=0;v<n;v++){let E=(t.data[f++]-u[0])*l[0],A=(t.data[m++]-u[1])*l[1],S=(t.data[h++]-u[2])*l[2],T=w===-1?255:(t.data[w++]-u[3])*l[3];s.fillStyle="rgba("+E+","+A+","+S+","+T+")",s.fillRect(v,x,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")},qE=(t,e)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),s;if(r!=null){let n,o,a;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(n=t.dims[2],o=t.dims[1],a=t.dims[3]):(n=t.dims[3],o=t.dims[2],a=t.dims[1]);let i=e!==void 0&&e.format!==void 0?e.format:"RGB",l=e?.norm,u,p;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?p=[0,0,0,0]:typeof l.bias=="number"?p=[l.bias,l.bias,l.bias,l.bias]:(p=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(p[3]=l.bias[3]));let f=o*n;if(e!==void 0&&(e.format!==void 0&&a===4&&e.format!=="RGBA"||a===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let m=4,h=0,w=1,x=2,v=3,E=0,A=f,S=f*2,T=-1;i==="RGBA"?(E=0,A=f,S=f*2,T=f*3):i==="RGB"?(E=0,A=f,S=f*2):i==="RBG"&&(E=0,S=f,A=f*2),s=r.createImageData(n,o);for(let L=0;L<o*n;h+=m,w+=m,x+=m,v+=m,L++)s.data[h]=(t.data[E++]-p[0])*u[0],s.data[w]=(t.data[A++]-p[1])*u[1],s.data[x]=(t.data[S++]-p[2])*u[2],s.data[v]=T===-1?255:(t.data[T++]-p[3])*u[3]}else throw new Error("Can not access image data");return s}}),Ru,WE,VE,HE,XE,KE,qP=ye(()=>{"use strict";rb(),Ru=(t,e)=>{if(t===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:s}=e,n=e.norm??{mean:255,bias:0},o,a;typeof n.mean=="number"?o=[n.mean,n.mean,n.mean,n.mean]:o=[n.mean[0],n.mean[1],n.mean[2],n.mean[3]??255],typeof n.bias=="number"?a=[n.bias,n.bias,n.bias,n.bias]:a=[n.bias[0],n.bias[1],n.bias[2],n.bias[3]??0];let i=e.format!==void 0?e.format:"RGBA",l=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",u=r*s,p=l==="RGBA"?new Float32Array(u*4):new Float32Array(u*3),f=4,m=0,h=1,w=2,x=3,v=0,E=u,A=u*2,S=-1;i==="RGB"&&(f=3,m=0,h=1,w=2,x=-1),l==="RGBA"?S=u*3:l==="RBG"?(v=0,A=u,E=u*2):l==="BGR"&&(A=0,E=u,v=u*2);for(let T=0;T<u;T++,m+=f,w+=f,h+=f,x+=f)p[v++]=(t[m]+a[0])/o[0],p[E++]=(t[h]+a[1])/o[1],p[A++]=(t[w]+a[2])/o[2],S!==-1&&x!==-1&&(p[S++]=(t[x]+a[3])/o[3]);return l==="RGBA"?new Nt("float32",p,[1,4,r,s]):new Nt("float32",p,[1,3,r,s])},WE=async(t,e)=>{let r=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,s=typeof ImageData<"u"&&t instanceof ImageData,n=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,o=typeof t=="string",a,i=e??{},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=p=>typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||p instanceof OffscreenCanvas?p.getContext("2d"):null;if(r){let p=l();p.width=t.width,p.height=t.height;let f=u(p);if(f!=null){let m=t.height,h=t.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(m=e.resizedHeight,h=e.resizedWidth),e!==void 0){if(i=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");i.tensorFormat="RGBA",i.height=m,i.width=h}else i.tensorFormat="RGBA",i.height=m,i.width=h;f.drawImage(t,0,0),a=f.getImageData(0,0,h,m).data}else throw new Error("Can not access image data")}else if(s){let p,f;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(p=e.resizedHeight,f=e.resizedWidth):(p=t.height,f=t.width),e!==void 0&&(i=e),i.format="RGBA",i.height=p,i.width=f,e!==void 0){let m=l();m.width=f,m.height=p;let h=u(m);if(h!=null)h.putImageData(t,0,0),a=h.getImageData(0,0,f,p).data;else throw new Error("Can not access image data")}else a=t.data}else if(n){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let p=l();p.width=t.width,p.height=t.height;let f=u(p);if(f!=null){let m=t.height,h=t.width;return f.drawImage(t,0,0,h,m),a=f.getImageData(0,0,h,m).data,i.height=m,i.width=h,Ru(a,i)}else throw new Error("Can not access image data")}else{if(o)return new Promise((p,f)=>{let m=l(),h=u(m);if(!t||!h)return f();let w=new Image;w.crossOrigin="Anonymous",w.src=t,w.onload=()=>{m.width=w.width,m.height=w.height,h.drawImage(w,0,0,m.width,m.height);let x=h.getImageData(0,0,m.width,m.height);i.height=m.height,i.width=m.width,p(Ru(x.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Ru(a,i);throw new Error("Input data provided is not supported - aborted tensor creation")},VE=(t,e)=>{let{width:r,height:s,download:n,dispose:o}=e,a=[1,s,r,4];return new Nt({location:"texture",type:"float32",texture:t,dims:a,download:n,dispose:o})},HE=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new Nt({location:"gpu-buffer",type:r??"float32",gpuBuffer:t,dims:s,download:n,dispose:o})},XE=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new Nt({location:"ml-tensor",type:r??"float32",mlTensor:t,dims:s,download:n,dispose:o})},KE=(t,e,r)=>new Nt({location:"cpu-pinned",type:t,data:e,dims:r??[e.length]})}),Ps,rl,I0,YE,WP=ye(()=>{"use strict";Ps=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),rl=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),I0=!1,YE=()=>{if(!I0){I0=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,s=typeof r<"u"&&r.from;t&&(Ps.set("int64",BigInt64Array),rl.set(BigInt64Array,"int64")),e&&(Ps.set("uint64",BigUint64Array),rl.set(BigUint64Array,"uint64")),s?(Ps.set("float16",r),rl.set(r,"float16")):Ps.set("float16",Uint16Array)}}}),QE,JE,VP=ye(()=>{"use strict";rb(),QE=t=>{let e=1;for(let r=0;r<t.length;r++){let s=t[r];if(typeof s!="number"||!Number.isSafeInteger(s))throw new TypeError(`dims[${r}] must be an integer, got: ${s}`);if(s<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${s}`);e*=s}return e},JE=(t,e)=>{switch(t.location){case"cpu":return new Nt(t.type,t.data,e);case"cpu-pinned":return new Nt({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new Nt({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new Nt({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new Nt({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),Nt,rb=ye(()=>{"use strict";GP(),qP(),WP(),VP(),Nt=class{constructor(t,e,r){YE();let s,n;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,s=t.type,n=t.dims,t.location){case"cpu-pinned":{let a=Ps.get(s);if(!a)throw new TypeError(`unsupported type "${s}" to create tensor from pinned buffer`);if(!(t.data instanceof a))throw new TypeError(`buffer should be of type ${a.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 a,i;if(typeof t=="string")if(s=t,i=r,t==="string"){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");a=e}else{let l=Ps.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if(t==="float16"&&l===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${l.name} as data.`);t==="uint64"||t==="int64"?a=l.from(e,BigInt):a=l.from(e)}else if(e instanceof l)a=e;else if(e instanceof Uint8ClampedArray)if(t==="uint8")a=Uint8Array.from(e);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&e instanceof Uint16Array&&l!==Uint16Array)a=new globalThis.Float16Array(e.buffer,e.byteOffset,e.length);else throw new TypeError(`A ${s} tensor's data must be type of ${l}`)}else if(i=e,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof t[0];if(l==="string")s="string",a=t;else if(l==="boolean")s="bool",a=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)s="uint8",a=Uint8Array.from(t);else{let l=rl.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);s=l,a=t}if(i===void 0)i=[a.length];else if(!Array.isArray(i))throw new TypeError("A tensor's dims must be a number array");n=i,this.cpuData=a,this.dataLocation="cpu"}let o=QE(n);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=n,this.size=o}static async fromImage(t,e){return WE(t,e)}static fromTexture(t,e){return VE(t,e)}static fromGpuBuffer(t,e){return HE(t,e)}static fromMLTensor(t,e){return XE(t,e)}static fromPinnedBuffer(t,e,r){return KE(t,e,r)}toDataURL(t){return GE(this,t)}toImageData(t){return qE(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;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}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 JE(this,t)}}}),rr,ZE=ye(()=>{"use strict";rb(),rr=Nt}),Wu,C0,zs,$s,ss,ns,eA=ye(()=>{"use strict";jE(),Wu=(t,e)=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.timeStamp(`${t}::ORT::${e}`)},C0=(t,e)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],s=!1;for(let n=0;n<r.length;n++){if(s&&!r[n].includes("TRACE_FUNC")){let o=`FUNC_${t}::${r[n].trim().split(" ")[1]}`;e&&(o+=`::${e}`),Wu("CPU",o);return}r[n].includes("TRACE_FUNC")&&(s=!0)}},zs=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||C0("BEGIN",t)},$s=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||C0("END",t)},ss=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.time(`ORT::${t}`)},ns=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.timeEnd(`ORT::${t}`)}}),tA,HP=ye(()=>{"use strict";BE(),ZE(),eA(),tA=class rA{constructor(e){this.handler=e}async run(e,r,s){zs(),ss("InferenceSession.run");let n={},o={};if(typeof e!="object"||e===null||e instanceof rr||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof rr)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.");a=!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}.`);n[u]=null}if(typeof s=="object"&&s!==null)o=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let u=!1,p=Object.getOwnPropertyNames(r);for(let f of this.outputNames)if(p.indexOf(f)!==-1){let m=r[f];(m===null||m instanceof rr)&&(u=!0,a=!1,n[f]=m)}if(u){if(typeof s=="object"&&s!==null)o=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else o=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 e[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(a)for(let u of this.outputNames)n[u]=null;let i=await this.handler.run(e,n,o),l={};for(let u in i)if(Object.hasOwnProperty.call(i,u)){let p=i[u];p instanceof rr?l[u]=p:l[u]=new rr(p.type,p.data,p.dims)}return ns("InferenceSession.run"),$s(),l}async release(){return this.handler.dispose()}static async create(e,r,s,n){zs(),ss("InferenceSession.create");let o,a={};if(typeof e=="string"){if(o=e,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(o=e,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let p=e,f=0,m=e.byteLength;if(typeof r=="object"&&r!==null)a=r;else if(typeof r=="number"){if(f=r,!Number.isSafeInteger(f))throw new RangeError("'byteOffset' must be an integer.");if(f<0||f>=p.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${p.byteLength}).`);if(m=e.byteLength-f,typeof s=="number"){if(m=s,!Number.isSafeInteger(m))throw new RangeError("'byteLength' must be an integer.");if(m<=0||f+m>p.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${p.byteLength-f}].`);if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(p,f,m)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,l]=await UE(a),u=await i.createInferenceSessionHandler(o,l);return ns("InferenceSession.create"),$s(),new rA(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}}}),sb,XP=ye(()=>{"use strict";HP(),sb=tA}),KP=ye(()=>{"use strict"}),YP=ye(()=>{"use strict"}),QP=ye(()=>{"use strict"}),JP=ye(()=>{"use strict"}),sA={};nl(sA,{InferenceSession:()=>sb,TRACE:()=>Wu,TRACE_EVENT_BEGIN:()=>ss,TRACE_EVENT_END:()=>ns,TRACE_FUNC_BEGIN:()=>zs,TRACE_FUNC_END:()=>$s,Tensor:()=>rr,env:()=>He,registerBackend:()=>Ns});var Rs=ye(()=>{"use strict";BP(),jP(),XP(),ZE(),KP(),YP(),eA(),QP(),JP()}),nb=ye(()=>{"use strict"}),nA={};nl(nA,{default:()=>oA});var P0,L0,oA,ZP=ye(()=>{"use strict";yA(),Ds(),ob(),P0="ort-wasm-proxy-worker",L0=globalThis.self?.name===P0,L0&&(self.onmessage=t=>{let{type:e,in:r}=t.data;try{switch(e){case"init-wasm":ab(r.wasm).then(()=>{pb(r).then(()=>{postMessage({type:e})},s=>{postMessage({type:e,err:s})})},s=>{postMessage({type:e,err:s})});break;case"init-ep":{let{epName:s,env:n}=r;db(n,s).then(()=>{postMessage({type:e})},o=>{postMessage({type:e,err:o})});break}case"copy-from":{let{buffer:s}=r,n=Xu(s);postMessage({type:e,out:n});break}case"create":{let{model:s,options:n}=r;fb(s,n).then(o=>{postMessage({type:e,out:o})},o=>{postMessage({type:e,err:o})});break}case"release":mb(r),postMessage({type:e});break;case"run":{let{sessionId:s,inputIndices:n,inputs:o,outputIndices:a,options:i}=r;hb(s,n,o,a,new Array(a.length).fill(null),i).then(l=>{l.some(u=>u[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:l},gb([...o,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":_b(r),postMessage({type:e});break;default:}}catch(s){postMessage({type:e,err:s})}}),oA=L0?null:t=>new Worker(t??Pt,{type:"module",name:P0})}),aA={};nl(aA,{default:()=>iA});async function fE(t={}){var e=t,r=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,n=s&&self.name?.startsWith("em-pthread");e.mountExternalData=(c,d)=>{c.startsWith("./")&&(c=c.substring(2)),(e.Uc||(e.Uc=new Map)).set(c,d)},e.unmountExternalData=()=>{delete e.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,Be:!0}).buffer.constructor;let o=()=>{let c=d=>(..._)=>{let g=ir;return _=d(..._),ir!=g?new Promise((b,M)=>{Xy={resolve:b,reject:M}}):_};(()=>{for(let d of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[d]=c(e[d])})(),typeof jsepRunAsync<"u"&&(e._OrtRun=jsepRunAsync(e._OrtRun),e._OrtRunWithBinding=jsepRunAsync(e._OrtRunWithBinding)),o=void 0};e.asyncInit=()=>{o?.()};var a,i,l=(c,d)=>{throw d},u=tr.url,p="";if(r||s){try{p=new URL(".",u).href}catch{}s&&(i=c=>{var d=new XMLHttpRequest;return d.open("GET",c,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.response)}),a=async c=>{if(P(c))return new Promise((_,g)=>{var b=new XMLHttpRequest;b.open("GET",c,!0),b.responseType="arraybuffer",b.onload=()=>{b.status==200||b.status==0&&b.response?_(b.response):g(b.status)},b.onerror=g,b.send(null)});var d=await fetch(c,{credentials:"same-origin"});if(d.ok)return d.arrayBuffer();throw Error(d.status+" : "+d.url)}}var f,m,h,w,x,v,E=console.log.bind(console),A=console.error.bind(console),S=E,T=A,L=!1,P=c=>c.startsWith("file://");function k(){Wr.buffer!=W.buffer&&de()}if(n){let c=function(d){try{var _=d.data,g=_.Oc;if(g==="load"){let b=[];self.onmessage=M=>b.push(M),v=()=>{postMessage({Oc:"loaded"});for(let M of b)c(M);self.onmessage=c};for(let M of _.de)e[M]&&!e[M].proxy||(e[M]=(...O)=>{postMessage({Oc:"callHandler",ce:M,args:O})},M=="print"&&(S=e[M]),M=="printErr"&&(T=e[M]));Wr=_.je,de(),m=_.ke,Je(),ku()}else if(g==="run"){(function(b){var M=(k(),C)[b+52>>>2>>>0];b=(k(),C)[b+56>>>2>>>0],xv(M,M-b),ie(M)})(_.Nc),a0(_.Nc,0,0,1,0,0),a1(),Wy(_.Nc),K||(tv(),K=!0);try{aM(_.he,_.Wc)}catch(b){if(b!="unwind")throw b}}else _.target!=="setimmediate"&&(g==="checkMailbox"?K&&hu():g&&(T(`worker: received unknown command ${g}`),T(_)))}catch(b){throw mv(),b}};var F=c,K=!1;self.onunhandledrejection=d=>{throw d.reason||d},self.onmessage=c}var W,X,H,Y,U,C,ne,ae,I,N,R,ee=!1;function de(){var c=Wr.buffer;e.HEAP8=W=new Int8Array(c),H=new Int16Array(c),e.HEAPU8=X=new Uint8Array(c),Y=new Uint16Array(c),e.HEAP32=U=new Int32Array(c),e.HEAPU32=C=new Uint32Array(c),ne=new Float32Array(c),ae=new Float64Array(c),I=new BigInt64Array(c),N=new BigUint64Array(c)}function Fe(){ee=!0,n?v():vr._b()}function Le(c){throw T(c="Aborted("+c+")"),L=!0,c=new WebAssembly.RuntimeError(c+". Build with -sASSERTIONS for more info."),x?.(c),c}function At(){return{a:{f:iM,J:lM,k:cM,p:uM,l:pM,ta:dM,b:fM,ca:mM,Ka:d1,s:hM,da:_1,_a:g1,Ga:w1,Ia:x1,$a:y1,Ya:b1,Ra:v1,Xa:k1,pa:E1,Ha:A1,Yb:M1,Za:T1,Fa:S1,eb:_M,Da:wM,Tb:xM,Rb:bM,Ca:kM,M:EM,H:AM,Sb:MM,ka:LM,Ub:NM,Ua:zM,Wb:RM,La:DM,Pb:UM,la:BM,Ta:Wy,bb:FM,U:WM,n:YM,c:Gy,sb:QM,w:JM,L:ZM,z:eT,j:tT,o:$1,tb:rT,G:sT,T:nT,g:oT,u:aT,m:iT,i:lT,Oa:cT,Pa:uT,Qa:pT,Ma:B1,Na:F1,Qb:j1,fb:fT,db:_T,Y:gT,rb:wT,ma:xT,cb:mT,gb:yT,ab:bT,Xb:vT,N:dT,hb:kT,X:ET,Vb:AT,ob:NT,C:zT,sa:$T,ra:RT,qb:DT,W:UT,v:BT,nb:FT,mb:jT,lb:GT,pb:qT,kb:WT,jb:VT,ib:HT,Va:X1,Wa:K1,Ja:Tt,ea:Y1,oa:Q1,Sa:J1,na:Z1,Db:sO,xa:KS,Eb:rO,ya:XS,F:DS,e:AS,r:kS,x:vS,D:zS,Ib:WS,ba:GS,B:TS,za:VS,$:YS,ha:qS,Fb:eO,Gb:ZS,Ba:US,Aa:jS,Jb:BS,wa:tO,aa:HS,d:MS,A:SS,q:ES,Cb:nO,t:IS,y:$S,I:OS,E:CS,K:RS,S:QS,ja:NS,_:JS,Kb:LS,Lb:PS,P:FS,h:KT,a:Wr,Ob:qr,Hb:YT,ia:QT,O:JT,qa:ZT,Mb:eS,Q:tS,zb:rS,Ab:sS,ua:nS,fa:oS,R:aS,Ea:iS,va:lS,Z:cS,xb:uS,Zb:pS,V:dS,Bb:fS,ub:mS,vb:_S,wb:gS,ga:wS,yb:xS,Nb:yS}}}async function Je(){function c(g,b){var M=vr=g.exports;g={};for(let[O,z]of Object.entries(M))typeof z=="function"?(M=jM(z),g[O]=M):g[O]=z;return vr=g,vr=(function(){var O=vr,z=Q=>Te=>Q(Te)>>>0,B=Q=>()=>Q()>>>0;return(O=Object.assign({},O)).$b=z(O.$b),O.Cc=B(O.Cc),O.Ec=z(O.Ec),O.rd=(Q=>(Te,Ne)=>Q(Te,Ne)>>>0)(O.rd),O.wd=z(O.wd),O.xd=B(O.xd),O.Bd=z(O.Bd),O})(),n1.push(vr.id),ev=(g=vr).$b,tv=g.ac,e._OrtInit=g.bc,e._OrtGetLastError=g.cc,e._OrtCreateSessionOptions=g.dc,e._OrtAppendExecutionProvider=g.ec,e._OrtAddFreeDimensionOverride=g.fc,e._OrtAddSessionConfigEntry=g.gc,e._OrtReleaseSessionOptions=g.hc,e._OrtCreateSession=g.ic,e._OrtReleaseSession=g.jc,e._OrtGetInputOutputCount=g.kc,e._OrtGetInputOutputMetadata=g.lc,e._OrtFree=g.mc,e._OrtCreateTensor=g.nc,e._OrtGetTensorData=g.oc,e._OrtReleaseTensor=g.pc,e._OrtCreateRunOptions=g.qc,e._OrtAddRunConfigEntry=g.rc,e._OrtReleaseRunOptions=g.sc,e._OrtCreateBinding=g.tc,e._OrtBindInput=g.uc,e._OrtBindOutput=g.vc,e._OrtClearBoundOutputs=g.wc,e._OrtReleaseBinding=g.xc,e._OrtRunWithBinding=g.yc,e._OrtRun=g.zc,e._OrtEndProfiling=g.Ac,e0=e._OrtGetWebGpuDevice=g.Bc,bu=g.Cc,Kt=e._free=g.Dc,yn=e._malloc=g.Ec,rv=e._wgpuBufferRelease=g.Fc,sv=e._wgpuCreateInstance=g.Gc,nv=g.Hc,ov=g.Ic,av=g.Jc,iv=g.Kc,lv=g.Lc,cv=g.Pc,uv=g.Zc,pv=g._c,dv=g.$c,t0=g.bd,r0=g.cd,s0=g.dd,n0=g.ed,Bi=g.fd,o0=g.gd,fv=g.hd,a0=g.kd,mv=g.ld,hv=g.md,_v=g.nd,i0=g.od,gv=g.pd,wv=g.qd,l0=g.rd,ge=g.sd,Fi=g.td,xv=g.ud,ie=g.vd,vu=g.wd,le=g.xd,yv=g.yd,c0=g.zd,bv=g.Ad,vv=g.Bd,kv=g.Cd,u0=g.Dd,Ev=g.Ed,Av=g.Fd,Mv=g.Gd,Tv=g.Hd,Sv=g.Id,Ov=g.Jd,Iv=g.Kd,Cv=g.Ld,Pv=g.Md,Lv=g.Nd,Nv=g.Od,zv=g.Pd,$v=g.Qd,Rv=g.Rd,Dv=g.Td,Uv=g.Ud,Bv=g.Vd,Fv=g.Wd,jv=g.Yd,Gv=g.Zd,qv=g._d,Wv=g.$d,Vv=g.ae,Hv=g.be,Xv=g.pe,Kv=g.qe,Yv=g.re,Qv=g.se,Jv=g.te,Zv=g.ue,ek=g.ve,tk=g.we,rk=g.xe,sk=g.ye,nk=g.ze,ok=g.Xe,ak=g.Ye,ik=g.Ze,lk=g._e,m=b,vr}var d,_=At();return e.instantiateWasm?new Promise(g=>{e.instantiateWasm(_,(b,M)=>{g(c(b,M))})}):n?c(new WebAssembly.Instance(m,At()),m):(R??=e.locateFile?e.locateFile?e.locateFile("ort-wasm-simd-threaded.asyncify.wasm",p):p+"ort-wasm-simd-threaded.asyncify.wasm":new URL("ort-wasm-simd-threaded.asyncify.wasm",tr.url).href,d=await(async function(g){var b=R;if(!f&&!P(b))try{var M=fetch(b,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(M,g)}catch(O){T(`wasm streaming compile failed: ${O}`),T("falling back to ArrayBuffer instantiation")}return(async function(O,z){try{var B=await(async function(Q){if(!f)try{var Te=await a(Q);return new Uint8Array(Te)}catch{}if(Q==R&&f)Q=new Uint8Array(f);else{if(!i)throw"both async and sync fetching of the wasm failed";Q=i(Q)}return Q})(O);return await WebAssembly.instantiate(B,z)}catch(Q){T(`failed to asynchronously prepare wasm: ${Q}`),Le(Q)}})(b,g)})(_),c(d.instance,d.module))}class tt{name="ExitStatus";constructor(d){this.message=`Program terminated with exit(${d})`,this.status=d}}var nt=c=>{c.terminate(),c.onmessage=()=>{}},Me=[],xe=0,We=null,Mt=c=>{rt.length==0&&(l1(),i1(rt[0]));var d=rt.pop();if(!d)return 6;Ri.push(d),bs[c.Nc]=d,d.Nc=c.Nc;var _={Oc:"run",he:c.ge,Wc:c.Wc,Nc:c.Nc};return d.postMessage(_,c.Yc),0},be=0,De=(c,d,..._)=>{var g,b=16*_.length,M=le(),O=vu(b),z=O>>>3;for(g of _)typeof g=="bigint"?((k(),I)[z++>>>0]=1n,(k(),I)[z++>>>0]=g):((k(),I)[z++>>>0]=0n,(k(),ae)[z++>>>0]=g);return c=hv(c,0,b,O,d),ie(M),c};function qr(c){if(n)return De(0,1,c);if(h=c,!(0<be)){for(var d of Ri)nt(d);for(d of rt)nt(d);rt=[],Ri=[],bs={},L=!0}l(0,new tt(c))}function ys(c){if(n)return De(1,0,c);Tt(c)}var Tt=c=>{if(h=c,n)throw ys(c),"unwind";qr(c)},rt=[],Ri=[],n1=[],bs={},o1=c=>{var d=c.Nc;delete bs[d],rt.push(c),Ri.splice(Ri.indexOf(c),1),c.Nc=0,_v(d)};function a1(){n1.forEach(c=>c())}var i1=c=>new Promise(d=>{c.onmessage=b=>{var M=b.data;if(b=M.Oc,M.Vc&&M.Vc!=bu()){var O=bs[M.Vc];O?O.postMessage(M,M.Yc):T(`Internal error! Worker sent a message "${b}" to target pthread ${M.Vc}, but that thread no longer exists!`)}else b==="checkMailbox"?hu():b==="spawnThread"?Mt(M):b==="cleanupThread"?yt(()=>{o1(bs[M.ie])}):b==="loaded"?(c.loaded=!0,d(c)):M.target==="setimmediate"?c.postMessage(M):b==="uncaughtException"?c.onerror(M.error):b==="callHandler"?e[M.ce](...M.args):b&&T(`worker sent an unknown command ${b}`)},c.onerror=b=>{throw T(`worker sent an error! ${b.filename}:${b.lineno}: ${b.message}`),b};var _,g=[];for(_ of[])e.propertyIsEnumerable(_)&&g.push(_);c.postMessage({Oc:"load",de:g,je:Wr,ke:m})});function l1(){var c=new Worker((()=>{let d=URL;return tr.url>"file:"&&tr.url<"file;"?new d("ort.webgpu.bundle.min.mjs",tr.url):new URL(tr.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});rt.push(c)}var Wr,aM=(c,d)=>{be=0,c=u0(c,d),0<be?h=c:i0(c)},fu=[],mu=0,xt=c=>-9007199254740992>c||9007199254740992<c?NaN:Number(c);function iM(c){var d=new Uy(c>>>=0);return(k(),W)[d.Qc+12>>>0]==0&&(c1(d,!0),mu--),u1(d,!1),fu.push(d),vv(c)}var _n=0,lM=()=>{ge(0,0);var c=fu.pop();yv(c.Xc),_n=0};function c1(c,d){d=d?1:0,(k(),W)[c.Qc+12>>>0]=d}function u1(c,d){d=d?1:0,(k(),W)[c.Qc+13>>>0]=d}class Uy{constructor(d){this.Xc=d,this.Qc=d-24}}var By=c=>{var d=_n;if(!d)return Fi(0),0;var _=new Uy(d);(k(),C)[_.Qc+16>>>2>>>0]=d;var g=(k(),C)[_.Qc+4>>>2>>>0];if(!g)return Fi(0),d;for(var b of c){if(b===0||b===g)break;if(bv(b,g,_.Qc+16))return Fi(b),d}return Fi(g),d};function cM(){return By([])}function uM(c){return By([c>>>0])}function pM(c,d,_,g){return By([c>>>0,d>>>0,_>>>0,g>>>0])}var dM=()=>{var c=fu.pop();c||Le("no exception to throw");var d=c.Xc;throw(k(),W)[c.Qc+13>>>0]==0&&(fu.push(c),u1(c,!0),c1(c,!1),mu++),c0(d),_n=d};function fM(c,d,_){var g=new Uy(c>>>=0);throw d>>>=0,_>>>=0,(k(),C)[g.Qc+16>>>2>>>0]=0,(k(),C)[g.Qc+4>>>2>>>0]=d,(k(),C)[g.Qc+8>>>2>>>0]=_,c0(c),mu++,_n=c}var mM=()=>mu;function p1(c,d,_,g){return n?De(2,1,c,d,_,g):d1(c,d,_,g)}function d1(c,d,_,g){if(c>>>=0,d>>>=0,_>>>=0,g>>>=0,!globalThis.SharedArrayBuffer)return 6;var b=[];return n&&b.length===0?p1(c,d,_,g):(c={ge:_,Nc:c,Wc:g,Yc:b},n?(c.Oc="spawnThread",postMessage(c,b),0):Mt(c))}function hM(c){throw _n||=c>>>0,_n}var f1=globalThis.TextDecoder&&new TextDecoder,m1=(c,d,_,g)=>{if(_=d+_,g)return _;for(;c[d]&&!(d>=_);)++d;return d},h1=(c,d=0,_,g)=>{if(16<(_=m1(c,d>>>=0,_,g))-d&&c.buffer&&f1)return f1.decode(c.buffer instanceof ArrayBuffer?c.subarray(d,_):c.slice(d,_));for(g="";d<_;){var b=c[d++];if(128&b){var M=63&c[d++];if((224&b)==192)g+=String.fromCharCode((31&b)<<6|M);else{var O=63&c[d++];65536>(b=(240&b)==224?(15&b)<<12|M<<6|O:(7&b)<<18|M<<12|O<<6|63&c[d++])?g+=String.fromCharCode(b):(b-=65536,g+=String.fromCharCode(55296|b>>10,56320|1023&b))}}else g+=String.fromCharCode(b)}return g},gn=(c,d,_)=>(c>>>=0)?h1((k(),X),c,d,_):"";function _1(c,d,_){return n?De(3,1,c,d,_):0}function g1(c,d){if(n)return De(4,1,c,d)}function w1(c,d){if(n)return De(5,1,c,d)}function x1(c,d,_){if(n)return De(6,1,c,d,_)}function y1(c,d,_){return n?De(7,1,c,d,_):0}function b1(c,d){if(n)return De(8,1,c,d)}function v1(c,d,_){if(n)return De(9,1,c,d,_)}function k1(c,d,_,g){if(n)return De(10,1,c,d,_,g)}function E1(c,d,_,g){if(n)return De(11,1,c,d,_,g)}function A1(c,d,_,g){if(n)return De(12,1,c,d,_,g)}function M1(c){if(n)return De(13,1,c)}function T1(c,d){if(n)return De(14,1,c,d)}function S1(c,d,_){if(n)return De(15,1,c,d,_)}var _M=()=>Le(""),ar=c=>{c>>>=0;for(var d="";;){var _=(k(),X)[c++>>>0];if(!_)return d;d+=String.fromCharCode(_)}},Fy={},jy={},gM={},wn=class extends Error{constructor(c){super(c),this.name="BindingError"}};function gr(c,d,_={}){return(function(g,b,M={}){var O=b.name;if(!g)throw new wn(`type "${O}" must have a positive integer typeid pointer`);if(jy.hasOwnProperty(g)){if(M.ee)return;throw new wn(`Cannot register type '${O}' twice`)}jy[g]=b,delete gM[g],Fy.hasOwnProperty(g)&&(b=Fy[g],delete Fy[g],b.forEach(z=>z()))})(c,d,_)}var O1=(c,d,_)=>{switch(d){case 1:return _?g=>(k(),W)[g>>>0]:g=>(k(),X)[g>>>0];case 2:return _?g=>(k(),H)[g>>>1>>>0]:g=>(k(),Y)[g>>>1>>>0];case 4:return _?g=>(k(),U)[g>>>2>>>0]:g=>(k(),C)[g>>>2>>>0];case 8:return _?g=>(k(),I)[g>>>3>>>0]:g=>(k(),N)[g>>>3>>>0];default:throw new TypeError(`invalid integer width (${d}): ${c}`)}};function wM(c,d,_,g,b){c>>>=0,_>>>=0,d=ar(d>>>0);let M=O=>O;if(g=g===0n){let O=8*_;M=z=>BigInt.asUintN(O,z),b=M(b)}gr(c,{name:d,Mc:M,Sc:(O,z)=>(typeof z=="number"&&(z=BigInt(z)),z),Rc:O1(d,_,!g),Tc:null})}function xM(c,d,_,g){gr(c>>>=0,{name:d=ar(d>>>0),Mc:function(b){return!!b},Sc:function(b,M){return M?_:g},Rc:function(b){return this.Mc((k(),X)[b>>>0])},Tc:null})}var I1=[],vs=[0,1,,1,null,1,!0,1,!1,1];function Gy(c){9<(c>>>=0)&&--vs[c+1]==0&&(vs[c]=void 0,I1.push(c))}var Ut=c=>{if(!c)throw new wn(`Cannot use deleted val. handle = ${c}`);return vs[c]},Xt=c=>{switch(c){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let d=I1.pop()||vs.length;return vs[d]=c,vs[d+1]=1,d}};function qy(c){return this.Mc((k(),C)[c>>>2>>>0])}var yM={name:"emscripten::val",Mc:c=>{var d=Ut(c);return Gy(c),d},Sc:(c,d)=>Xt(d),Rc:qy,Tc:null};function bM(c){return gr(c>>>0,yM)}var vM=(c,d)=>{switch(d){case 4:return function(_){return this.Mc((k(),ne)[_>>>2>>>0])};case 8:return function(_){return this.Mc((k(),ae)[_>>>3>>>0])};default:throw new TypeError(`invalid float width (${d}): ${c}`)}};function kM(c,d,_){_>>>=0,gr(c>>>=0,{name:d=ar(d>>>0),Mc:g=>g,Sc:(g,b)=>b,Rc:vM(d,_),Tc:null})}function EM(c,d,_,g,b){c>>>=0,_>>>=0,d=ar(d>>>0);let M=z=>z;if(g===0){var O=32-8*_;M=z=>z<<O>>>O,b=M(b)}gr(c,{name:d,Mc:M,Sc:(z,B)=>B,Rc:O1(d,_,g!==0),Tc:null})}function AM(c,d,_){function g(M){var O=(k(),C)[M>>>2>>>0];return M=(k(),C)[M+4>>>2>>>0],new b((k(),W).buffer,M,O)}var b=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][d];gr(c>>>=0,{name:_=ar(_>>>0),Mc:g,Rc:g},{ee:!0})}var wr=(c,d,_)=>{var g=(k(),X);if(d>>>=0,0<_){var b=d;_=d+_-1;for(var M=0;M<c.length;++M){var O=c.codePointAt(M);if(127>=O){if(d>=_)break;g[d++>>>0]=O}else if(2047>=O){if(d+1>=_)break;g[d++>>>0]=192|O>>6,g[d++>>>0]=128|63&O}else if(65535>=O){if(d+2>=_)break;g[d++>>>0]=224|O>>12,g[d++>>>0]=128|O>>6&63,g[d++>>>0]=128|63&O}else{if(d+3>=_)break;g[d++>>>0]=240|O>>18,g[d++>>>0]=128|O>>12&63,g[d++>>>0]=128|O>>6&63,g[d++>>>0]=128|63&O,M++}}g[d>>>0]=0,c=d-b}else c=0;return c},xr=c=>{for(var d=0,_=0;_<c.length;++_){var g=c.charCodeAt(_);127>=g?d++:2047>=g?d+=2:55296<=g&&57343>=g?(d+=4,++_):d+=3}return d};function MM(c,d){gr(c>>>=0,{name:d=ar(d>>>0),Mc(_){var g=(k(),C)[_>>>2>>>0];return g=gn(_+4,g,!0),Kt(_),g},Sc(_,g){g instanceof ArrayBuffer&&(g=new Uint8Array(g));var b=typeof g=="string";if(!(b||ArrayBuffer.isView(g)&&g.BYTES_PER_ELEMENT==1))throw new wn("Cannot pass non-string to std::string");var M=b?xr(g):g.length,O=yn(4+M+1),z=O+4;return(k(),C)[O>>>2>>>0]=M,b?wr(g,z,M+1):(k(),X).set(g,z>>>0),_!==null&&_.push(Kt,O),O},Rc:qy,Tc(_){Kt(_)}})}var C1=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,TM=(c,d,_)=>{if(c>>>=1,16<(d=m1((k(),Y),c,d/2,_))-c&&C1)return C1.decode((k(),Y).slice(c,d));for(_="";c<d;++c){var g=(k(),Y)[c>>>0];_+=String.fromCharCode(g)}return _},SM=(c,d,_)=>{if(_??=2147483647,2>_)return 0;var g=d;_=(_-=2)<2*c.length?_/2:c.length;for(var b=0;b<_;++b){var M=c.charCodeAt(b);(k(),H)[d>>>1>>>0]=M,d+=2}return(k(),H)[d>>>1>>>0]=0,d-g},OM=c=>2*c.length,IM=(c,d,_)=>{var g="";c>>>=2;for(var b=0;!(b>=d/4);b++){var M=(k(),C)[c+b>>>0];if(!M&&!_)break;g+=String.fromCodePoint(M)}return g},CM=(c,d,_)=>{if(d>>>=0,_??=2147483647,4>_)return 0;var g=d;_=g+_-4;for(var b=0;b<c.length;++b){var M=c.codePointAt(b);if(65535<M&&b++,(k(),U)[d>>>2>>>0]=M,(d+=4)+4>_)break}return(k(),U)[d>>>2>>>0]=0,d-g},PM=c=>{for(var d=0,_=0;_<c.length;++_)65535<c.codePointAt(_)&&_++,d+=4;return d};function LM(c,d,_){if(c>>>=0,d>>>=0,_=ar(_>>>=0),d===2)var g=TM,b=SM,M=OM;else g=IM,b=CM,M=PM;gr(c,{name:_,Mc:O=>{var z=(k(),C)[O>>>2>>>0];return z=g(O+4,z*d,!0),Kt(O),z},Sc:(O,z)=>{if(typeof z!="string")throw new wn(`Cannot pass non-string to C++ string type ${_}`);var B=M(z),Q=yn(4+B+d);return(k(),C)[Q>>>2>>>0]=B/d,b(z,Q+4,B+d),O!==null&&O.push(Kt,Q),Q},Rc:qy,Tc(O){Kt(O)}})}function NM(c,d){gr(c>>>=0,{fe:!0,name:d=ar(d>>>0),Mc:()=>{},Sc:()=>{}})}function zM(c){a0(c>>>0,!s,1,!r,131072,!1),a1()}var yt=c=>{if(!L)try{if(c(),!(0<be))try{n?bu()&&i0(h):Tt(h)}catch(d){d instanceof tt||d=="unwind"||l(0,d)}}catch(d){d instanceof tt||d=="unwind"||l(0,d)}},$M=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Wy(c){c>>>=0,$M||(Atomics.waitAsync((k(),U),c>>>2,c).value.then(hu),c+=128,Atomics.store((k(),U),c>>>2,1))}var hu=()=>yt(()=>{var c=bu();c&&(Wy(c),wv())});function RM(c,d){(c>>>=0)==d>>>0?setTimeout(hu):n?postMessage({Vc:c,Oc:"checkMailbox"}):(c=bs[c])&&c.postMessage({Oc:"checkMailbox"})}var Vy=[];function DM(c,d,_,g,b){for(d>>>=0,b>>>=0,Vy.length=0,_=b>>>3,g=b+g>>>3;_<g;){var M;M=(k(),I)[_++>>>0]?(k(),I)[_++>>>0]:(k(),ae)[_++>>>0],Vy.push(M)}return(d?p0[d]:bS[c])(...Vy)}var UM=()=>{be=0};function BM(c){c>>>=0,n?postMessage({Oc:"cleanupThread",ie:c}):o1(bs[c])}function FM(c){}var _u=c=>{try{c()}catch(d){Le(d)}};function jM(c){var d=(..._)=>{gu.push(c);try{return c(..._)}finally{L||(gu.pop(),ir&&Vr===1&&gu.length===0&&(Vr=0,be+=1,_u(ak),typeof Fibers<"u"&&Fibers.De()))}};return N1.set(c,d),d}var Vr=0,ir=null,P1=0,gu=[],Hy=new Map,L1=new Map,N1=new Map,GM=0,Xy=null,qM=[],z1=c=>(function(d){if(!L){if(Vr===0){var _=!1,g=!1;d((b=0)=>{if(!L&&(P1=b,_=!0,g)){Vr=2,_u(()=>ik(ir)),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.resume(),b=!1;try{var M=(function(){var B=(k(),U)[ir+8>>>2>>>0];return B=L1.get(B),B=N1.get(B),--be,B()})()}catch(B){M=B,b=!0}var O=!1;if(!ir){var z=Xy;z&&(Xy=null,(b?z.reject:z.resolve)(M),O=!0)}if(b&&!O)throw M}}),g=!0,_||(Vr=1,ir=(function(){var b=yn(65548),M=b+12;if((k(),C)[b>>>2>>>0]=M,(k(),C)[b+4>>>2>>>0]=M+65536,M=gu[0],!Hy.has(M)){var O=GM++;Hy.set(M,O),L1.set(O,M)}return M=Hy.get(M),(k(),U)[b+8>>>2>>>0]=M,b})(),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.pause(),_u(()=>ok(ir)))}else Vr===2?(Vr=0,_u(lk),Kt(ir),ir=null,qM.forEach(yt)):Le(`invalid state: ${Vr}`);return P1}})(d=>{c().then(d)});function WM(c){return c>>>=0,z1(async()=>{var d=await Ut(c);return Xt(d)})}var Ky=[],VM=c=>{var d=Ky.length;return Ky.push(c),d},HM=(c,d)=>{for(var _=Array(c),g=0;g<c;++g){var b=g,M=(k(),C)[d+4*g>>>2>>>0],O=jy[M];if(O===void 0)throw c=`parameter ${g}`,M=ev(M),d=ar(M),Kt(M),new wn(`${c} has unknown type ${d}`);_[b]=O}return _},XM=(c,d,_)=>{var g=[];return c=c(g,_),g.length&&((k(),C)[d>>>2>>>0]=Xt(g)),c},KM={},wu=c=>{var d=KM[c];return d===void 0?ar(c):d};function YM(c,d,_){var[g,...b]=HM(c,d>>>0);d=g.Sc.bind(g);var M=b.map(B=>B.Rc.bind(B));c--;var O={toValue:Ut};switch(c=M.map((B,Q)=>{var Te=`argFromPtr${Q}`;return O[Te]=B,`${Te}(args${Q?"+"+8*Q:""})`}),_){case 0:var z="toValue(handle)";break;case 2:z="new (toValue(handle))";break;case 3:z="";break;case 1:O.getStringOrSymbol=wu,z="toValue(handle)[getStringOrSymbol(methodName)]"}return z+=`(${c})`,g.fe||(O.toReturnWire=d,O.emval_returnValue=XM,z=`return emval_returnValue(toReturnWire, destructorsRef, ${z})`),z=`return function (handle, methodName, destructorsRef, args) {
|
|
7
|
+
`));case"join":case"string":return t;case"int":{let n=parseInt(t.value,10);return new me(isNaN(n)?0:n)}case"float":{let n=parseFloat(t.value);return new Ye(isNaN(n)?0:n)}default:throw new Error(`Unknown StringValue filter: ${s.value}`)}else if(t instanceof me||t instanceof Ye)switch(s.value){case"abs":return t instanceof me?new me(Math.abs(t.value)):new Ye(Math.abs(t.value));case"int":return new me(Math.floor(t.value));case"float":return new Ye(t.value);case"string":return new ee(t.toString());default:throw new Error(`Unknown NumericValue filter: ${s.value}`)}else if(t instanceof ct)switch(s.value){case"items":return new ye(Array.from(t.value.entries()).map(([n,o])=>new ye([new ee(n),o])));case"length":return new me(t.value.size);default:{let n=t.builtins.get(s.value);if(n)return n instanceof Ge?n.value([],r):n;throw new Error(`Unknown ObjectValue filter: ${s.value}`)}}else if(t instanceof pe)switch(s.value){case"bool":return new pe(t.value);case"int":return new me(t.value?1:0);case"float":return new Ye(t.value?1:0);case"string":return new ee(t.value?"true":"false");default:throw new Error(`Unknown BooleanValue filter: ${s.value}`)}throw new Error(`Cannot apply filter "${s.value}" to type: ${t.type}`)}else if(e.type==="CallExpression"){let s=e;if(s.callee.type!=="Identifier")throw new Error(`Unknown filter: ${s.callee.type}`);let n=s.callee.value;if(n==="tojson"){let[,o]=this.evaluateArguments(s.args,r),a=o.get("indent")??new He;if(!(a instanceof me||a instanceof He))throw new Error("If set, indent must be a number");let i=o.get("ensure_ascii")??new pe(!1);if(!(i instanceof pe))throw new Error("If set, ensure_ascii must be a boolean");let l=o.get("sort_keys")??new pe(!1);if(!(l instanceof pe))throw new Error("If set, sort_keys must be a boolean");let c=o.get("separators")??new He,p=null;if(c instanceof ye||c instanceof UE){if(c.value.length!==2)throw new Error("separators must be a tuple of two strings");let[d,_]=c.value;if(!(d instanceof ee)||!(_ instanceof ee))throw new Error("separators must be a tuple of two strings");p=[d.value,_.value]}else if(!(c instanceof He))throw new Error("If set, separators must be a tuple of two strings");return new ee(Ls(t,{indent:a.value,ensureAscii:i.value,sortKeys:l.value,separators:p}))}else if(n==="join"){let o;if(t instanceof ee)o=Array.from(t.value);else if(t instanceof ye)o=t.value.map(c=>c.value);else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`);let[a,i]=this.evaluateArguments(s.args,r),l=a.at(0)??i.get("separator")??new ee("");if(!(l instanceof ee))throw new Error("separator must be a string");return new ee(o.join(l.value))}else if(n==="int"||n==="float"){let[o,a]=this.evaluateArguments(s.args,r),i=o.at(0)??a.get("default")??(n==="int"?new me(0):new Ye(0));if(t instanceof ee){let l=n==="int"?parseInt(t.value,10):parseFloat(t.value);return isNaN(l)?i:n==="int"?new me(l):new Ye(l)}else{if(t instanceof me||t instanceof Ye)return t;if(t instanceof pe)return n==="int"?new me(t.value?1:0):new Ye(t.value?1:0);throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}}else if(n==="default"){let[o,a]=this.evaluateArguments(s.args,r),i=o[0]??new ee(""),l=o[1]??a.get("boolean")??new pe(!1);if(!(l instanceof pe))throw new Error("`default` filter flag must be a boolean");return t instanceof je||l.value&&!t.__bool__().value?i:t}if(t instanceof ye){switch(n){case"sort":{let[o,a]=this.evaluateArguments(s.args,r),i=o.at(0)??a.get("reverse")??new pe(!1);if(!(i instanceof pe))throw new Error("reverse must be a boolean");let l=o.at(1)??a.get("case_sensitive")??new pe(!1);if(!(l instanceof pe))throw new Error("case_sensitive must be a boolean");let c=o.at(2)??a.get("attribute")??new He;if(!(c instanceof ee||c instanceof me||c instanceof He))throw new Error("attribute must be a string, integer, or null");let p=d=>{if(c instanceof He)return d;let _=c instanceof me?String(c.value):c.value;return jE(d,_)};return new ye(t.value.slice().sort((d,_)=>{let m=p(d),w=p(_),x=db(m,w,l.value);return i.value?-x:x}))}case"selectattr":case"rejectattr":{let o=n==="selectattr";if(t.value.some(d=>!(d instanceof ct)))throw new Error(`\`${n}\` can only be applied to array of objects`);if(s.args.some(d=>d.type!=="StringLiteral"))throw new Error(`arguments of \`${n}\` must be strings`);let[a,i,l]=s.args.map(d=>this.evaluate(d,r)),c;if(i){let d=r.tests.get(i.value);if(!d)throw new Error(`Unknown test: ${i.value}`);c=d}else c=(...d)=>d[0].__bool__().value;let p=t.value.filter(d=>{let _=d.value.get(a.value),m=_?c(_,l):!1;return o?m:!m});return new ye(p)}case"map":{let[,o]=this.evaluateArguments(s.args,r);if(o.has("attribute")){let a=o.get("attribute");if(!(a instanceof ee))throw new Error("attribute must be a string");let i=o.get("default"),l=t.value.map(c=>{if(!(c instanceof ct))throw new Error("items in map must be an object");let p=jE(c,a.value);return p instanceof je?i??new je:p});return new ye(l)}else throw new Error("`map` expressions without `attribute` set are not currently supported.")}}throw new Error(`Unknown ArrayValue filter: ${n}`)}else if(t instanceof ee){switch(n){case"indent":{let[o,a]=this.evaluateArguments(s.args,r),i=o.at(0)??a.get("width")??new me(4);if(!(i instanceof me))throw new Error("width must be a number");let l=o.at(1)??a.get("first")??new pe(!1),c=o.at(2)??a.get("blank")??new pe(!1),p=t.value.split(`
|
|
8
|
+
`),d=" ".repeat(i.value),_=p.map((m,w)=>!l.value&&w===0||!c.value&&m.length===0?m:d+m);return new ee(_.join(`
|
|
9
|
+
`))}case"replace":{let o=t.builtins.get("replace");if(!(o instanceof Ge))throw new Error("replace filter not available");let[a,i]=this.evaluateArguments(s.args,r);return o.value([...a,new fl(i)],r)}}throw new Error(`Unknown StringValue filter: ${n}`)}else if(t instanceof ct){let o=t.builtins.get(n);if(o&&o instanceof Ge){let[a,i]=this.evaluateArguments(s.args,r);return i.size>0&&a.push(new fl(i)),o.value(a,r)}throw new Error(`Unknown ObjectValue filter: ${n}`)}else throw new Error(`Cannot apply filter "${n}" to type: ${t.type}`)}throw new Error(`Unknown filter: ${e.type}`)}evaluateFilterExpression(t,e){let r=this.evaluate(t.operand,e);return this.applyFilter(r,t.filter,e)}evaluateTestExpression(t,e){let r=this.evaluate(t.operand,e),s=e.tests.get(t.test.value);if(!s)throw new Error(`Unknown test: ${t.test.value}`);let n=s(r);return new pe(t.negate?!n:n)}evaluateSelectExpression(t,e){return this.evaluate(t.test,e).__bool__().value?this.evaluate(t.lhs,e):new je}evaluateUnaryExpression(t,e){let r=this.evaluate(t.argument,e);if(t.operator.value==="not")return new pe(!r.value);throw new SyntaxError(`Unknown operator: ${t.operator.value}`)}evaluateTernaryExpression(t,e){return this.evaluate(t.condition,e).__bool__().value?this.evaluate(t.trueExpr,e):this.evaluate(t.falseExpr,e)}evalProgram(t,e){return this.evaluateBlock(t.body,e)}evaluateBlock(t,e){let r="";for(let s of t){let n=this.evaluate(s,e);n.type!=="NullValue"&&n.type!=="UndefinedValue"&&(r+=n.toString())}return new ee(r)}evaluateIdentifier(t,e){return e.lookupVariable(t.value)}evaluateCallExpression(t,e){let[r,s]=this.evaluateArguments(t.args,e);s.size>0&&r.push(new fl(s));let n=this.evaluate(t.callee,e);if(n.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${n.type}`);return n.value(r,e)}evaluateSliceExpression(t,e,r){if(!(t instanceof ye||t instanceof ee))throw new Error("Slice object must be an array or string");let s=this.evaluate(e.start,r),n=this.evaluate(e.stop,r),o=this.evaluate(e.step,r);if(!(s instanceof me||s instanceof je))throw new Error("Slice start must be numeric or undefined");if(!(n instanceof me||n instanceof je))throw new Error("Slice stop must be numeric or undefined");if(!(o instanceof me||o instanceof je))throw new Error("Slice step must be numeric or undefined");return t instanceof ye?new ye(RE(t.value,s.value,n.value,o.value)):new ee(RE(Array.from(t.value),s.value,n.value,o.value).join(""))}evaluateMemberExpression(t,e){let r=this.evaluate(t.object,e),s;if(t.computed){if(t.property.type==="SliceExpression")return this.evaluateSliceExpression(r,t.property,e);s=this.evaluate(t.property,e)}else s=new ee(t.property.value);let n;if(r instanceof ct){if(!(s instanceof ee))throw new Error(`Cannot access property with non-string: got ${s.type}`);n=r.value.get(s.value)??r.builtins.get(s.value)}else if(r instanceof ye||r instanceof ee)if(s instanceof me)n=r.value.at(s.value),r instanceof ee&&(n=new ee(r.value.at(s.value)));else if(s instanceof ee)n=r.builtins.get(s.value);else throw new Error(`Cannot access property with non-string/non-number: got ${s.type}`);else{if(!(s instanceof ee))throw new Error(`Cannot access property with non-string: got ${s.type}`);n=r.builtins.get(s.value)}return n instanceof ir?n:new je}evaluateSet(t,e){let r=t.value?this.evaluate(t.value,e):this.evaluateBlock(t.body,e);if(t.assignee.type==="Identifier"){let s=t.assignee.value;e.setVariable(s,r)}else if(t.assignee.type==="TupleLiteral"){let s=t.assignee;if(!(r instanceof ye))throw new Error(`Cannot unpack non-iterable type in set: ${r.type}`);let n=r.value;if(n.length!==s.value.length)throw new Error(`Too ${s.value.length>n.length?"few":"many"} items to unpack in set`);for(let o=0;o<s.value.length;++o){let a=s.value[o];if(a.type!=="Identifier")throw new Error(`Cannot unpack to non-identifier in set: ${a.type}`);e.setVariable(a.value,n[o])}}else if(t.assignee.type==="MemberExpression"){let s=t.assignee,n=this.evaluate(s.object,e);if(!(n instanceof ct))throw new Error("Cannot assign to member of non-object");if(s.property.type!=="Identifier")throw new Error("Cannot assign to member with non-identifier property");n.value.set(s.property.value,r)}else throw new Error(`Invalid LHS inside assignment expression: ${JSON.stringify(t.assignee)}`);return new He}evaluateIf(t,e){let r=this.evaluate(t.test,e);return this.evaluateBlock(r.__bool__().value?t.body:t.alternate,e)}evaluateFor(t,e){let r=new Cs(e),s,n;if(t.iterable.type==="SelectExpression"){let c=t.iterable;n=this.evaluate(c.lhs,r),s=c.test}else n=this.evaluate(t.iterable,r);if(!(n instanceof ye||n instanceof ct))throw new Error(`Expected iterable or object type in for loop: got ${n.type}`);n instanceof ct&&(n=n.keys());let o=[],a=[];for(let c=0;c<n.value.length;++c){let p=new Cs(r),d=n.value[c],_;if(t.loopvar.type==="Identifier")_=m=>m.setVariable(t.loopvar.value,d);else if(t.loopvar.type==="TupleLiteral"){let m=t.loopvar;if(d.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${d.type}`);let w=d;if(m.value.length!==w.value.length)throw new Error(`Too ${m.value.length>w.value.length?"few":"many"} items to unpack`);_=x=>{for(let E=0;E<m.value.length;++E){if(m.value[E].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${m.value[E].type}`);x.setVariable(m.value[E].value,w.value[E])}}}else throw new Error(`Invalid loop variable(s): ${t.loopvar.type}`);s&&(_(p),!this.evaluate(s,p).__bool__().value)||(o.push(d),a.push(_))}let i="",l=!0;for(let c=0;c<o.length;++c){let p=new Map([["index",new me(c+1)],["index0",new me(c)],["revindex",new me(o.length-c)],["revindex0",new me(o.length-c-1)],["first",new pe(c===0)],["last",new pe(c===o.length-1)],["length",new me(o.length)],["previtem",c>0?o[c-1]:new je],["nextitem",c<o.length-1?o[c+1]:new je]]);r.setVariable("loop",new ct(p)),a[c](r);try{let d=this.evaluateBlock(t.body,r);i+=d.value}catch(d){if(d instanceof FE)continue;if(d instanceof DE)break;throw d}l=!1}if(l){let c=this.evaluateBlock(t.defaultBlock,r);i+=c.value}return new ee(i)}evaluateMacro(t,e){return e.setVariable(t.name.value,new Ge((r,s)=>{let n=new Cs(s);r=r.slice();let o;r.at(-1)?.type==="KeywordArgumentsValue"&&(o=r.pop());for(let a=0;a<t.args.length;++a){let i=t.args[a],l=r[a];if(i.type==="Identifier"){let c=i;if(!l)throw new Error(`Missing positional argument: ${c.value}`);n.setVariable(c.value,l)}else if(i.type==="KeywordArgumentExpression"){let c=i,p=l??o?.value.get(c.key.value)??this.evaluate(c.value,n);n.setVariable(c.key.value,p)}else throw new Error(`Unknown argument type: ${i.type}`)}return this.evaluateBlock(t.body,n)})),new He}evaluateCallStatement(t,e){let r=new Ge((i,l)=>{let c=new Cs(l);if(t.callerArgs)for(let p=0;p<t.callerArgs.length;++p){let d=t.callerArgs[p];if(d.type!=="Identifier")throw new Error(`Caller parameter must be an identifier, got ${d.type}`);c.setVariable(d.value,i[p]??new je)}return this.evaluateBlock(t.body,c)}),[s,n]=this.evaluateArguments(t.call.args,e);s.push(new fl(n));let o=this.evaluate(t.call.callee,e);if(o.type!=="FunctionValue")throw new Error(`Cannot call something that is not a function: got ${o.type}`);let a=new Cs(e);return a.setVariable("caller",r),o.value(s,a)}evaluateFilterStatement(t,e){let r=this.evaluateBlock(t.body,e);return this.applyFilter(r,t.filter,e)}evaluate(t,e){if(!t)return new je;switch(t.type){case"Program":return this.evalProgram(t,e);case"Set":return this.evaluateSet(t,e);case"If":return this.evaluateIf(t,e);case"For":return this.evaluateFor(t,e);case"Macro":return this.evaluateMacro(t,e);case"CallStatement":return this.evaluateCallStatement(t,e);case"Break":throw new DE;case"Continue":throw new FE;case"IntegerLiteral":return new me(t.value);case"FloatLiteral":return new Ye(t.value);case"StringLiteral":return new ee(t.value);case"ArrayLiteral":return new ye(t.value.map(r=>this.evaluate(r,e)));case"TupleLiteral":return new UE(t.value.map(r=>this.evaluate(r,e)));case"ObjectLiteral":{let r=new Map;for(let[s,n]of t.value){let o=this.evaluate(s,e);if(!(o instanceof ee))throw new Error(`Object keys must be strings: got ${o.type}`);r.set(o.value,this.evaluate(n,e))}return new ct(r)}case"Identifier":return this.evaluateIdentifier(t,e);case"CallExpression":return this.evaluateCallExpression(t,e);case"MemberExpression":return this.evaluateMemberExpression(t,e);case"UnaryExpression":return this.evaluateUnaryExpression(t,e);case"BinaryExpression":return this.evaluateBinaryExpression(t,e);case"FilterExpression":return this.evaluateFilterExpression(t,e);case"FilterStatement":return this.evaluateFilterStatement(t,e);case"TestExpression":return this.evaluateTestExpression(t,e);case"SelectExpression":return this.evaluateSelectExpression(t,e);case"Ternary":return this.evaluateTernaryExpression(t,e);case"Comment":return new He;default:throw new SyntaxError(`Unknown node type: ${t.type}`)}}};function Ku(t){switch(typeof t){case"number":return Number.isInteger(t)?new me(t):new Ye(t);case"string":return new ee(t);case"boolean":return new pe(t);case"undefined":return new je;case"object":return t===null?new He:Array.isArray(t)?new ye(t.map(Ku)):new ct(new Map(Object.entries(t).map(([e,r])=>[e,Ku(r)])));case"function":return new Ge((e,r)=>{let s=t(...e.map(n=>n.value))??null;return Ku(s)});default:throw new Error(`Cannot convert to runtime value: ${t}`)}}var rt=`
|
|
10
|
+
`,vP="{%- ",kP=" -%}";function EP(t){switch(t.operator.type){case"MultiplicativeBinaryOperator":return 4;case"AdditiveBinaryOperator":return 3;case"ComparisonBinaryOperator":return 2;case"Identifier":return t.operator.value==="and"?1:t.operator.value==="in"||t.operator.value==="not in"?2:0}return 0}function AP(t,e=" "){let r=typeof e=="number"?" ".repeat(e):e;return Kt(t.body,0,r).replace(/\n$/,"")}function gt(...t){return vP+t.join(" ")+kP}function Kt(t,e,r){return t.map(s=>MP(s,e,r)).join(rt)}function MP(t,e,r){let s=r.repeat(e);switch(t.type){case"Program":return Kt(t.body,e,r);case"If":return SP(t,e,r);case"For":return TP(t,e,r);case"Set":return OP(t,e,r);case"Macro":return IP(t,e,r);case"Break":return s+gt("break");case"Continue":return s+gt("continue");case"CallStatement":return CP(t,e,r);case"FilterStatement":return LP(t,e,r);case"Comment":return s+"{# "+t.value+" #}";default:return s+"{{- "+ke(t)+" -}}"}}function SP(t,e,r){let s=r.repeat(e),n=[],o=t;for(;o&&(n.push({test:o.test,body:o.body}),o.alternate.length===1&&o.alternate[0].type==="If");)o=o.alternate[0];let a=s+gt("if",ke(n[0].test))+rt+Kt(n[0].body,e+1,r);for(let i=1;i<n.length;++i)a+=rt+s+gt("elif",ke(n[i].test))+rt+Kt(n[i].body,e+1,r);return o&&o.alternate.length>0&&(a+=rt+s+gt("else")+rt+Kt(o.alternate,e+1,r)),a+=rt+s+gt("endif"),a}function TP(t,e,r){let s=r.repeat(e),n="";if(t.iterable.type==="SelectExpression"){let a=t.iterable;n=`${ke(a.lhs)} if ${ke(a.test)}`}else n=ke(t.iterable);let o=s+gt("for",ke(t.loopvar),"in",n)+rt+Kt(t.body,e+1,r);return t.defaultBlock.length>0&&(o+=rt+s+gt("else")+rt+Kt(t.defaultBlock,e+1,r)),o+=rt+s+gt("endfor"),o}function OP(t,e,r){let s=r.repeat(e),n=ke(t.assignee),o=t.value?ke(t.value):"",a=s+gt("set",`${n}${t.value?" = "+o:""}`);return t.body.length===0?a:a+rt+Kt(t.body,e+1,r)+rt+s+gt("endset")}function IP(t,e,r){let s=r.repeat(e),n=t.args.map(ke).join(", ");return s+gt("macro",`${t.name.value}(${n})`)+rt+Kt(t.body,e+1,r)+rt+s+gt("endmacro")}function CP(t,e,r){let s=r.repeat(e),n=t.callerArgs&&t.callerArgs.length>0?`(${t.callerArgs.map(ke).join(", ")})`:"",o=ke(t.call),a=s+gt(`call${n}`,o)+rt;return a+=Kt(t.body,e+1,r)+rt,a+=s+gt("endcall"),a}function LP(t,e,r){let s=r.repeat(e),n=t.filter.type==="Identifier"?t.filter.value:ke(t.filter),o=s+gt("filter",n)+rt;return o+=Kt(t.body,e+1,r)+rt,o+=s+gt("endfilter"),o}function ke(t,e=-1){switch(t.type){case"SpreadExpression":return`*${ke(t.argument)}`;case"Identifier":return t.value;case"IntegerLiteral":return`${t.value}`;case"FloatLiteral":return`${t.value}`;case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":{let r=t,s=EP(r),n=ke(r.left,s),o=ke(r.right,s+1),a=`${n} ${r.operator.value} ${o}`;return s<e?`(${a})`:a}case"UnaryExpression":{let r=t;return r.operator.value+(r.operator.value==="not"?" ":"")+ke(r.argument,1/0)}case"CallExpression":{let r=t,s=r.args.map(ke).join(", ");return`${ke(r.callee)}(${s})`}case"MemberExpression":{let r=t,s=ke(r.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(r.object.type)||(s=`(${s})`);let n=ke(r.property);return!r.computed&&r.property.type!=="Identifier"&&(n=`(${n})`),r.computed?`${s}[${n}]`:`${s}.${n}`}case"FilterExpression":{let r=t,s=ke(r.operand,1/0);return r.filter.type==="CallExpression"?`${s} | ${ke(r.filter)}`:`${s} | ${r.filter.value}`}case"SelectExpression":{let r=t;return`${ke(r.lhs)} if ${ke(r.test)}`}case"TestExpression":{let r=t;return`${ke(r.operand)} is${r.negate?" not":""} ${r.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let r=t.value.map(ke),s=t.type==="ArrayLiteral"?"[]":"()";return`${s[0]}${r.join(", ")}${s[1]}`}case"ObjectLiteral":return`{${Array.from(t.value.entries()).map(([s,n])=>`${ke(s)}: ${ke(n)}`).join(", ")}}`;case"SliceExpression":{let r=t,s=r.start?ke(r.start):"",n=r.stop?ke(r.stop):"",o=r.step?`:${ke(r.step)}`:"";return`${s}:${n}${o}`}case"KeywordArgumentExpression":{let r=t;return`${r.key.value}=${ke(r.value)}`}case"Ternary":{let r=t,s=`${ke(r.trueExpr)} if ${ke(r.condition,0)} else ${ke(r.falseExpr)}`;return e>-1?`(${s})`:s}default:throw new Error(`Unknown expression type: ${t.type}`)}}var GE=class{parsed;constructor(t){let e=jL(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=dP(e)}render(t){let e=new Cs;if(yP(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new bP(e).run(this.parsed).value}format(t){return AP(this.parsed,t?.indent||" ")}};var tt=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}_call(...t){throw Error("Must implement _call method in subclass")}};var Ps=yr(require("fs"),1),PP={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"},Wr=class t{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Ps.default.existsSync(e),this.exists){this.status=200,this.statusText="OK";let r=Ps.default.statSync(e);this.headers.set("content-length",r.size.toString()),this.updateContentType();let s=Ps.default.createReadStream(e);this.body=new ReadableStream({start(n){s.on("data",o=>n.enqueue(o)),s.on("end",()=>n.close()),s.on("error",o=>n.error(o))},cancel(){s.destroy()}})}else this.status=404,this.statusText="Not Found",this.body=null}updateContentType(){let e=this.filePath.toString().split(".").pop().toLowerCase();this.headers.set("content-type",PP[e]??"application/octet-stream")}clone(){let e=new t(this.filePath);return e.exists=this.exists,e.status=this.status,e.statusText=this.statusText,e.headers=new Headers(this.headers),e}async arrayBuffer(){return(await Ps.default.promises.readFile(this.filePath)).buffer}async blob(){let e=await Ps.default.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await Ps.default.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}};var Rn=yr(require("fs"),1),_l=yr(require("path"),1);var $n=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(ie.IS_CRYPTO_AVAILABLE){let i=new Uint32Array(1);crypto.getRandomValues(i),e=i[0]}else e=Date.now()>>>0;let r=this._mt,s=(i,l)=>Math.imul(i,l)>>>0,n=[];for(let i=e||0;i>0;i=Math.floor(i/4294967296))n.push(i&4294967295);n.length||n.push(0),r[0]=19650218;for(let i=1;i<624;++i)r[i]=s(1812433253,r[i-1]^r[i-1]>>>30)+i>>>0;let o=1,a=0;for(let i=Math.max(624,n.length);i>0;--i,++o,++a)o>=624&&(r[0]=r[623],o=1),a>=n.length&&(a=0),r[o]=(r[o]^s(r[o-1]^r[o-1]>>>30,1664525))+n[a]+a>>>0;for(let i=623;i>0;--i,++o)o>=624&&(r[0]=r[623],o=1),r[o]=(r[o]^s(r[o-1]^r[o-1]>>>30,1566083941))-o>>>0;r[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let s=0;s<624;++s){let n=e[s]&2147483648|e[(s+1)%624]&2147483647;e[s]=(e[(s+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let r=e[this._idx++];return r^=r>>>11,r^=r<<7&2636928640,r^=r<<15&4022730752,r^=r>>>18,r>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,r=1){let s=this._gauss_next;if(this._gauss_next=null,s===null){let n=this.random()*2*Math.PI,o=Math.sqrt(-2*Math.log(1-this.random()));s=Math.cos(n)*o,this._gauss_next=Math.sin(n)*o}return e+s*r}shuffle(e){for(let r=e.length-1;r>0;--r){let s=32-Math.clz32(r+1),n=this._int32()>>>32-s;for(;n>r;)n=this._int32()>>>32-s;let o=e[r];e[r]=e[n],e[n]=o}}choices(e,r){return e[qE(this._random_fn,r)]}};function qE(t,e){let r=0;for(let n=0;n<e.length;++n)r+=e[n];let s=t()*r;for(let n=0;n<e.length;++n)if(s-=e[n],s<0)return n;return e.length-1}var lr=new $n,Vr=Object.freeze({Random:$n,seed:lr.seed.bind(lr),random:lr.random.bind(lr),gauss:lr.gauss.bind(lr),shuffle:lr.shuffle.bind(lr),choices:lr.choices.bind(lr)}),WE=t=>qE(Vr.random,t);var zP=new $n,Dn=class{constructor(e){this.path=e}async match(e){let r=_l.default.join(this.path,e),s=new Wr(r);if(s.exists)return s}async put(e,r,s=void 0){let n=_l.default.join(this.path,e),o=ie.IS_PROCESS_AVAILABLE?process.pid:Date.now(),a=zP._int32().toString(36),i=n+`.tmp.${o}.${a}`;try{let l=r.headers.get("Content-Length"),c=parseInt(l??"0"),p=0;await Rn.default.promises.mkdir(_l.default.dirname(n),{recursive:!0});let d=Rn.default.createWriteStream(i),_=r.body.getReader();for(;;){let{done:m,value:w}=await _.read();if(m)break;await new Promise((E,k)=>{d.write(w,A=>{if(A){k(A);return}E()})}),p+=w.length;let x=c?p/c*100:0;s?.({progress:x,loaded:p,total:c})}await new Promise((m,w)=>{d.close(x=>x?w(x):m())}),await Rn.default.promises.rename(i,n)}catch(l){try{await Rn.default.promises.unlink(i)}catch{}throw l}}async delete(e){let r=_l.default.join(this.path,e);try{return await Rn.default.promises.unlink(r),!0}catch{return!1}}};var VE={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"},Qu=100,HE=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;var fb={};function ml(...t){return t=t.map((e,r)=>(r&&(e=e.replace(new RegExp("^/"),"")),r!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e)),t.join("/")}function Hr(t,e=null,r=null){let s;try{s=new URL(t)}catch{return!1}return!(e&&!e.includes(s.protocol)||r&&!r.includes(s.hostname))}function XE(t){return!(!HE.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function KE(t,e,r){if(!r)return null;let s=VE[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${s}: "${e}".`)}async function QE(t,e,r){let s=t.headers.get("Content-Length"),n=s?parseInt(s,10):r??0;s===null&&!r&&Z.warn("Unable to determine content-length from response headers. Will expand buffer when needed.");let o=new Uint8Array(n),a=0,i=t.body.getReader();async function l(){let{done:c,value:p}=await i.read();if(c)return;let d=a+p.length;if(d>n){n=d;let m=new Uint8Array(n);m.set(o),o=m}o.set(p,a),a=d;let _=a/n*100;return e({progress:_,loaded:a,total:n}),l()}return await l(),o}function _b(t){return Hr(t,["blob:"])}function mb(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof fb<"u"&&fb.url)e=fb.url;else return t;return new URL(t,e).href}var JE="SHA-256",NP="experimental_transformers-hash-cache",YE=t=>({algorithm:JE,value:t}),hl=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(NP),this.#t);static isAvailable=()=>typeof navigator<"u"&&"crossOriginStorage"in navigator;match=async e=>{let r=await this._getFileHash(e);if(r)try{let[s]=await navigator.crossOriginStorage.requestFileHandles([YE(r)]),n=await s.getFile();return new Response(n,{headers:{"Content-Length":String(n.size)}})}catch{return}};put=async(e,r)=>{let s=await this._getFileHash(e);if(s){let n=await r.blob();await this._storeBlobInCOS(n,s)}else this._processAndStore(e,r.body)};_storeBlobInCOS=async(e,r)=>{let[s]=await navigator.crossOriginStorage.requestFileHandles([YE(r)],{create:!0}),n=await s.createWritable();await n.write(e),await n.close()};_processAndStore=async(e,r)=>{try{let s=[];for await(let a of r)s.push(a);let n=new Blob(s),o=await this._getBlobHash(n);await this._storeBlobInCOS(n,o);try{await(await this._getHashCache()).put(e,new Response(o))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let r=await this._getHashCache(),s=await r.match(e);if(s)return s.text();let n=await this._getLfsFileHash(e);return n?(await r.put(e,new Response(n)),n):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes("/resolve/"))return null;let r=e.replace("/resolve/","/raw/");try{let n=(await fetch(r).then(o=>o.text())).match(/^oid sha256:([0-9a-f]+)$/m);return n?n[1]:null}catch{return null}};_getBlobHash=async e=>{let r=await e.arrayBuffer(),s=await crypto.subtle.digest(JE,r);return Array.from(new Uint8Array(s)).map(o=>o.toString(16).padStart(2,"0")).join("")}};async function Yt(t=null){let e=null;if(fe.useCustomCache){if(!fe.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!fe.customCache.match||!fe.customCache.put)throw new Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");e=fe.customCache}if(!e&&fe.experimental_useCrossOriginStorage&&hl.isAvailable()&&(e=new hl),!e&&fe.useBrowserCache){if(typeof caches>"u")throw Error("Browser cache is not available in this environment.");try{e=await caches.open(fe.cacheKey)}catch(r){Z.warn("An error occurred while opening the browser cache:",r)}}if(!e&&fe.useFSCache){if(!ie.IS_FS_AVAILABLE)throw Error("File System Cache is not available in this environment.");e=new Dn(t??fe.cacheDir)}return e}async function ZE(t,...e){for(let r of e)try{let s=await t.match(r);if(s)return s}catch{continue}}var Yu=class{#t;#e;constructor(e){this.#t=e,this.#e=new Map}get(e){if(!this.#e.has(e))return;let r=this.#e.get(e);return this.#e.delete(e),this.#e.set(e,r),r}put(e,r){this.#e.has(e)&&this.#e.delete(e),this.#e.set(e,r),this.#e.size>this.#t&&this.#e.delete(this.#e.keys().next().value)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}};var $P=100,hb=new Yu($P);function Ju(t,e){let r=hb.get(t);if(r!==void 0)return r;let s=e().then(n=>n,n=>(hb.delete(t),Promise.reject(n)));return hb.put(t,s),s}async function RP(t){if(!Hr(t,["http:","https:"]))return null;let e=gb(t);return e.set("Range","bytes=0-0"),fe.fetch(t,{method:"GET",headers:e,cache:"no-store"})}function cr(t,e,r={}){let s=JSON.stringify([t,e,r?.revision,r?.cache_dir,r?.local_files_only]);return Ju(s,()=>DP(t,e,r))}async function DP(t,e,r){let s=await Yt(r?.cache_dir),{localPath:n,remoteURL:o,proposedCacheKey:a,validModelId:i}=Kr(t,e,r,s),l=await Qr(s,n,a);if(l!==void 0&&typeof l!="string"){let c=l.headers.get("content-length"),p=l.headers.get("content-type");return{exists:!0,size:c?parseInt(c,10):void 0,contentType:p||void 0,fromCache:!0}}if(fe.allowLocalModels&&!Hr(n,["http:","https:"]))try{let p=await Xr(n);if(typeof p!="string"&&p.status!==404){let d=p.headers.get("content-length"),_=p.headers.get("content-type");return{exists:!0,size:d?parseInt(d,10):void 0,contentType:_||void 0,fromCache:!1}}}catch{}if(fe.allowRemoteModels&&!r.local_files_only&&i)try{let c=await RP(o);if(c&&c.status>=200&&c.status<300){let p,d=c.headers.get("content-type");if(c.status===206){let _=c.headers.get("content-range");if(_){let m=_.match(/bytes \d+-\d+\/(\d+)/);m&&(p=parseInt(m[1],10))}}else if(c.status===200)try{await c.body?.cancel()}catch{}if(p===void 0){let _=c.headers.get("content-length");p=_?parseInt(_,10):void 0}return{exists:!0,size:p,contentType:d||void 0,fromCache:!1}}}catch(c){Z.warn(`Unable to fetch file metadata for "${o}": ${c}`)}return{exists:!1,fromCache:!1}}async function Xr(t){return fe.useFS&&!Hr(t,["http:","https:","blob:"])?new Wr(t instanceof URL?t.protocol==="file:"?t.pathname:t.toString():t):fe.fetch(t,{headers:gb(t)})}function gb(t){let e=typeof process<"u"&&process?.release?.name==="node",r=new Headers;if(e){let s=!!process.env?.TESTING_REMOTELY,n=fe.version;if(r.set("User-Agent",`transformers.js/${n}; is_ci/${s};`),Hr(t,["http:","https:"],["huggingface.co","hf.co"])){let a=process.env?.HF_TOKEN??process.env?.HF_ACCESS_TOKEN;a&&r.set("Authorization",`Bearer ${a}`)}}return r}function Kr(t,e,r={},s=null){let n=r.revision??"main",o=ml(t,e),a=XE(t),i=a?ml(fe.localModelPath,o):o,l=ml(fe.remoteHost,fe.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),c=s instanceof Dn?n==="main"?o:ml(t,n,e):l;return{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:a}}async function Qr(t,e,r){if(t)return await ZE(t,e,r)}async function FP(t,e,r,s,n,o,a={}){if(await r.match(s)===void 0)if(o){if(typeof n!="string"){let i=new Headers(n.headers);i.set("content-length",o.byteLength.toString()),await r.put(s,new Response(o,{headers:i})).catch(l=>{Z.warn(`Unable to add response to browser cache: ${l}.`)})}}else{let i=a.progress_callback?l=>br(a.progress_callback,{status:"progress",name:t,file:e,...l}):void 0;await r.put(s,n,i)}}async function BP(t,e,r=!0,s={},n=!1,o=null){let{requestURL:a,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:p}=Kr(t,e,s,o),d,_=!1,m;m=await Qr(o,i,c);let w=m!==void 0;if(!w){if(fe.allowLocalModels)if(Hr(a,["http:","https:"])){if(s.local_files_only)throw new Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${a}.`);if(!fe.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${a}.`)}else try{m=await Xr(i),d=i}catch(A){Z.warn(`Unable to load from local path "${i}": "${A}"`)}if(m===void 0||typeof m!="string"&&m.status===404){if(s.local_files_only||!fe.allowRemoteModels){if(r)throw Error(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${i}".`);return null}if(!p)throw Error(`Local file missing at "${i}" and download aborted due to invalid model ID "${t}".`);if(m=await Xr(l),m.status!==200)return KE(m.status,l,r);d=c}_=o&&typeof Response<"u"&&m instanceof Response&&m.status===200}br(s.progress_callback,{status:"download",name:t,file:e});let x;if(!(ie.IS_NODE_ENV&&n)){let k;if(typeof m!="string")if(!s.progress_callback)k=new Uint8Array(await m.arrayBuffer());else if(w&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))k=new Uint8Array(await m.arrayBuffer()),br(s.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:k.length,total:k.length});else{let A,T=m.headers.get("content-length");if(T)A=parseInt(T,10);else try{let S=await cr(t,e,s);S.size&&(A=S.size)}catch{}k=await QE(m,S=>{br(s.progress_callback,{status:"progress",name:t,file:e,...S})},A)}x=k}if(_&&d&&typeof m!="string"&&await FP(t,e,o,d,m,x,s),br(s.progress_callback,{status:"done",name:t,file:e}),x){if(!ie.IS_NODE_ENV&&n)throw new Error("Cannot return path in a browser environment.");return x}if(m instanceof Wr)return m.filePath;let E=await o?.match(d);if(E instanceof Wr)return E.filePath;if(E instanceof Response)return new Uint8Array(await E.arrayBuffer());if(typeof E=="string")return E;throw new Error("Unable to get model file path or buffer.")}async function gl(t,e,r=!0,s={},n=!1){if(!fe.allowLocalModels){if(s.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(!fe.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}br(s.progress_callback,{status:"initiate",name:t,file:e});let o=await Yt(s?.cache_dir);return await BP(t,e,r,s,n,o)}async function wb(t,e,r=!0,s={}){let n=await gl(t,e,r,s,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function ut(t,e,r=!0,s={}){let n=await wb(t,e,r,s);return n===null?{}:JSON.parse(n)}function tA(t,[e,r,s],[n,o],a="bilinear",i=!1){let l=o/s,c=n/r,p=new t.constructor(n*o*e),d=r*s,_=n*o;for(let m=0;m<n;++m)for(let w=0;w<o;++w){let x=m*o+w,E=(w+.5)/l-.5,k=(m+.5)/c-.5,A=Math.floor(E),T=Math.floor(k),S=Math.min(A+1,s-1),L=Math.min(T+1,r-1);A=Math.max(A,0),T=Math.max(T,0);let O=E-A,v=k-T,W=(1-O)*(1-v),X=O*(1-v),B=(1-O)*v,H=O*v,G=T*s,Q=L*s,R=G+A,C=G+S,te=Q+A,ae=Q+S;for(let P=0;P<e;++P){let $=P*d;p[P*_+x]=W*t[$+R]+X*t[$+C]+B*t[$+te]+H*t[$+ae]}}return p}function rA(t,e,r){let s=new Array(r.length),n=new Array(r.length);for(let i=r.length-1,l=1;i>=0;--i)n[i]=l,s[i]=e[r[i]],l*=s[i];let o=r.map((i,l)=>n[r.indexOf(l)]),a=new t.constructor(t.length);for(let i=0;i<t.length;++i){let l=0;for(let c=e.length-1,p=i;c>=0;--c)l+=p%e[c]*o[c],p=Math.floor(p/e[c]);a[l]=t[i]}return[a,s]}function Ie(t){let e=Ce(t)[0],r=t.map(o=>Math.exp(o-e)),s=r.reduce((o,a)=>o+a,0);return r.map(o=>o/s)}function tp(t){let e=Ce(t)[0],r=0;for(let o=0;o<t.length;++o)r+=Math.exp(t[o]-e);let s=Math.log(r);return t.map(o=>o-e-s)}function yb(t,e){let r=0;for(let s=0;s<t.length;++s)r+=t[s]*e[s];return r}function sA(t,e){let r=yb(t,e),s=eA(t),n=eA(e);return r/(s*n)}function eA(t){return Math.sqrt(t.reduce((e,r)=>e+r*r,0))}function wl(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]<e&&(e=t[s],r=s);return[e,r]}function Ce(t){if(t.length===0)throw Error("Array must not be empty");let e=t[0],r=0;for(let s=1;s<t.length;++s)t[s]>e&&(e=t[s],r=s);return[e,r]}function nA(t){return t>0&&(t&t-1)===0}var Zu=class{constructor(e){if(this.size=e|0,this.size<=1||!nA(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 s=0;s<this.table.length;s+=2){let n=Math.PI*s/this.size;this.table[s]=Math.cos(n),this.table[s+1]=-Math.sin(n)}let r=0;for(let s=1;this.size>s;s<<=1)++r;this._width=r%2===0?r-1:r,this._bitrev=new Int32Array(1<<this._width);for(let s=0;s<this._bitrev.length;++s){this._bitrev[s]=0;for(let n=0;n<this._width;n+=2){let o=this._width-n-2;this._bitrev[s]|=(s>>>n&3)<<o}}}createComplexArray(){return new Float64Array(this._csize)}fromComplexArray(e,r){let s=r||new Array(e.length>>>1);for(let n=0;n<e.length;n+=2)s[n>>>1]=e[n];return s}toComplexArray(e,r){let s=r||this.createComplexArray();for(let n=0;n<s.length;n+=2)s[n]=e[n>>>1],s[n+1]=0;return s}transform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._transform4(e,r,1)}realTransform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._realTransform4(e,r,1)}inverseTransform(e,r){if(e===r)throw new Error("Input and output buffers must be different");this._transform4(e,r,-1);for(let s=0;s<e.length;++s)e[s]/=this.size}_transform4(e,r,s){let n=this._csize,a=1<<this._width,i=n/a<<1,l,c,p=this._bitrev;if(i===4)for(l=0,c=0;l<n;l+=i,++c){let _=p[c];this._singleTransform2(r,e,l,_,a)}else for(l=0,c=0;l<n;l+=i,++c){let _=p[c];this._singleTransform4(r,e,l,_,a,s)}let d=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let _=i>>>2;for(l=0;l<n;l+=i){let m=l+_-1;for(let w=l,x=0;w<m;w+=2,x+=a){let E=w,k=E+_,A=k+_,T=A+_,S=e[E],L=e[E+1],O=e[k],v=e[k+1],W=e[A],X=e[A+1],B=e[T],H=e[T+1],G=d[x],Q=s*d[x+1],R=O*G-v*Q,C=O*Q+v*G,te=d[2*x],ae=s*d[2*x+1],P=W*te-X*ae,$=W*ae+X*te,F=d[3*x],J=s*d[3*x+1],xe=B*F-H*J,ue=B*J+H*F,Ve=S+P,ot=L+$,_t=S-P,at=L-$,vt=R+xe,Fe=C+ue,Me=s*(R-xe),et=s*(C-ue);e[E]=Ve+vt,e[E+1]=ot+Fe,e[k]=_t+et,e[k+1]=at-Me,e[A]=Ve-vt,e[A+1]=ot-Fe,e[T]=_t-et,e[T+1]=at+Me}}}}_singleTransform2(e,r,s,n,o){let a=e[n],i=e[n+1],l=e[n+o],c=e[n+o+1];r[s]=a+l,r[s+1]=i+c,r[s+2]=a-l,r[s+3]=i-c}_singleTransform4(e,r,s,n,o,a){let i=o*2,l=o*3,c=e[n],p=e[n+1],d=e[n+o],_=e[n+o+1],m=e[n+i],w=e[n+i+1],x=e[n+l],E=e[n+l+1],k=c+m,A=p+w,T=c-m,S=p-w,L=d+x,O=_+E,v=a*(d-x),W=a*(_-E);r[s]=k+L,r[s+1]=A+O,r[s+2]=T+W,r[s+3]=S-v,r[s+4]=k-L,r[s+5]=A-O,r[s+6]=T-W,r[s+7]=S+v}_realTransform4(e,r,s){let n=this._csize,a=1<<this._width,i=n/a<<1,l,c,p=this._bitrev;if(i===4)for(l=0,c=0;l<n;l+=i,++c){let m=p[c];this._singleRealTransform2(r,e,l,m>>>1,a>>>1)}else for(l=0,c=0;l<n;l+=i,++c){let m=p[c];this._singleRealTransform4(r,e,l,m>>>1,a>>>1,s)}let d=this.table;for(a>>=2;a>=2;a>>=2){i=n/a<<1;let m=i>>>1,w=m>>>1,x=w>>>1;for(l=0;l<n;l+=i)for(let E=0,k=0;E<=x;E+=2,k+=a){let A=l+E,T=A+w,S=T+w,L=S+w,O=e[A],v=e[A+1],W=e[T],X=e[T+1],B=e[S],H=e[S+1],G=e[L],Q=e[L+1],R=O,C=v,te=d[k],ae=s*d[k+1],P=W*te-X*ae,$=W*ae+X*te,F=d[2*k],J=s*d[2*k+1],xe=B*F-H*J,ue=B*J+H*F,Ve=d[3*k],ot=s*d[3*k+1],_t=G*Ve-Q*ot,at=G*ot+Q*Ve,vt=R+xe,Fe=C+ue,Me=R-xe,et=C-ue,sr=P+_t,ze=$+at,Be=s*(P-_t),An=s*($-at);if(e[A]=vt+sr,e[A+1]=Fe+ze,e[T]=Me+An,e[T+1]=et-Be,E===0){e[S]=vt-sr,e[S+1]=Fe-ze;continue}if(E===x)continue;let sl=l+w-E,Mn=l+m-E;e[sl]=Me-s*An,e[sl+1]=-et-s*Be,e[Mn]=vt-s*sr,e[Mn+1]=-Fe+s*ze}}let _=n>>>1;for(let m=2;m<_;m+=2)e[n-m]=e[m],e[n-m+1]=-e[m+1]}_singleRealTransform2(e,r,s,n,o){let a=e[n],i=e[n+o];r[s]=a+i,r[s+1]=0,r[s+2]=a-i,r[s+3]=0}_singleRealTransform4(e,r,s,n,o,a){let i=o*2,l=o*3,c=e[n],p=e[n+o],d=e[n+i],_=e[n+l],m=c+d,w=c-d,x=p+_,E=a*(p-_);r[s]=m+x,r[s+1]=0,r[s+2]=w,r[s+3]=-E,r[s+4]=m-x,r[s+5]=0,r[s+6]=w,r[s+7]=E}},xb=class{constructor(e){let r=2*(e-1),s=2*(2*e-1),n=2**Math.ceil(Math.log2(s));this.bufferSize=n,this._a=r;let o=new Float64Array(s),a=new Float64Array(n);this._chirpBuffer=new Float64Array(n),this._buffer1=new Float64Array(n),this._buffer2=new Float64Array(n),this._outBuffer1=new Float64Array(n),this._outBuffer2=new Float64Array(n);let i=-2*Math.PI/e,l=Math.cos(i),c=Math.sin(i);for(let p=0;p<s>>1;++p){let d=(p+1-e)**2/2,_=Math.sqrt(l**2+c**2)**d,m=d*Math.atan2(c,l),w=2*p;o[w]=_*Math.cos(m),o[w+1]=_*Math.sin(m),a[w]=o[w],a[w+1]=-o[w+1]}this._slicedChirpBuffer=o.subarray(r,s),this._f=new Zu(n>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,r,s){let n=this._buffer1,o=this._buffer2,a=this._outBuffer1,i=this._outBuffer2,l=this._chirpBuffer,c=this._slicedChirpBuffer,p=this._a;if(s)for(let d=0;d<c.length;d+=2){let _=d+1,m=d>>1,w=r[m];n[d]=w*c[d],n[_]=w*c[_]}else for(let d=0;d<c.length;d+=2){let _=d+1;n[d]=r[d]*c[d]-r[_]*c[_],n[_]=r[d]*c[_]+r[_]*c[d]}this._f.transform(a,n);for(let d=0;d<l.length;d+=2){let _=d+1;o[d]=a[d]*l[d]-a[_]*l[_],o[_]=a[d]*l[_]+a[_]*l[d]}this._f.inverseTransform(i,o);for(let d=0;d<i.length;d+=2){let _=i[d+p],m=i[d+p+1],w=c[d],x=c[d+1];e[d]=_*w-m*x,e[d+1]=_*x+m*w}}transform(e,r){this._transform(e,r,!1)}realTransform(e,r){this._transform(e,r,!0)}},ep=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=nA(e),this.isPowerOfTwo?(this.fft=new Zu(e),this.outputBufferSize=2*e):(this.fft=new xb(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,r){this.fft.realTransform(e,r)}transform(e,r){this.fft.transform(e,r)}};function oA(t,e){if(e%2===0||e<=0)throw new Error("Window size must be a positive odd number");let r=new t.constructor(t.length),s=new t.constructor(e),n=Math.floor(e/2);for(let o=0;o<t.length;++o){let a=0;for(let i=-n;i<=n;++i){let l=o+i;l<0?l=Math.abs(l):l>=t.length&&(l=2*(t.length-1)-l),s[a++]=t[l]}s.sort(),r[o]=s[n]}return r}function zs(t,e){let r=Math.pow(10,e);return Math.round(t*r)/r}function aA(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function iA(t){let e=t.length,r=t[0].length,s=[e+1,r+1],n=Array.from({length:s[0]},()=>Array(s[1]).fill(1/0));n[0][0]=0;let o=Array.from({length:s[0]},()=>Array(s[1]).fill(-1));for(let p=1;p<s[1];++p)for(let d=1;d<s[0];++d){let _=n[d-1][p-1],m=n[d-1][p],w=n[d][p-1],x,E;_<m&&_<w?(x=_,E=0):m<_&&m<w?(x=m,E=1):(x=w,E=2),n[d][p]=t[d-1][p-1]+x,o[d][p]=E}for(let p=0;p<s[1];++p)o[0][p]=2;for(let p=0;p<s[0];++p)o[p][0]=1;let a=e,i=r,l=[],c=[];for(;a>0||i>0;)switch(l.push(a-1),c.push(i-1),o[a][i]){case 0:--a,--i;break;case 1:--a;break;case 2:--i;break;default:throw new Error(`Internal error in dynamic time warping. Unexpected trace[${a}, ${i}]. Please file a bug report.`)}return l.reverse(),c.reverse(),[l,c]}var lA=(function(){let t=null;return function(e){if(!t){t=new Float32Array(65536);let o=new ArrayBuffer(4),a=new Uint32Array(o),i=new Float32Array(o);for(let l=0;l<t.length;++l){let c=0,p=(l&32768)<<16,d=(l&31744)>>10,_=l&1023;if(d===31)c=p|2139095040|_<<13;else if(d===0)if(_===0)c=p;else{let m=113;for(;(_&1024)===0;)_<<=1,--m;_&=-1025,c=p|m<<23|_<<13}else c=p|d+112<<23|_<<13;a[0]=c,t[l]=i[0]}}let r=e.length,s=t,n=new Float32Array(r);for(let o=0;o<r;++o)n[o]=s[e[o]];return n}})();var hz=yr(require("onnxruntime-node"),1);var u1={};Os(u1,{InferenceSession:()=>Kb,TRACE:()=>up,TRACE_EVENT_BEGIN:()=>ts,TRACE_EVENT_END:()=>rs,TRACE_FUNC_BEGIN:()=>Bs,TRACE_FUNC_END:()=>Us,Tensor:()=>Zt,default:()=>mz,env:()=>Xe,registerBackend:()=>Fs});var Jt={};var Hb=Object.defineProperty,UP=Object.getOwnPropertyDescriptor,jP=Object.getOwnPropertyNames,GP=Object.prototype.hasOwnProperty,qP=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),be=(t,e)=>()=>(t&&(e=t(t=0)),e),Ml=(t,e)=>{for(var r in e)Hb(t,r,{get:e[r],enumerable:!0})},WP=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jP(e))!GP.call(t,n)&&n!==r&&Hb(t,n,{get:()=>e[n],enumerable:!(s=UP(e,n))||s.enumerable});return t},cp=t=>WP(Hb({},"__esModule",{value:!0}),t),xl,Yr,Fs,cA,$A,RA=be(()=>{"use strict";xl=new Map,Yr=[],Fs=(t,e,r)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let s=xl.get(t);if(s===void 0)xl.set(t,{backend:e,priority:r});else{if(s.priority>r)return;if(s.priority===r&&s.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${r}`)}if(r>=0){let n=Yr.indexOf(t);n!==-1&&Yr.splice(n,1);for(let o=0;o<Yr.length;o++)if(xl.get(Yr[o]).priority<=r){Yr.splice(o,0,t);return}Yr.push(t)}return}throw new TypeError("not a valid backend")},cA=async t=>{let e=xl.get(t);if(!e)return"backend not found.";if(e.initialized)return e.backend;if(e.aborted)return e.error;{let r=!!e.initPromise;try{return r||(e.initPromise=e.backend.init(t)),await e.initPromise,e.initialized=!0,e.backend}catch(s){return r||(e.error=`${s}`,e.aborted=!0),e.error}finally{delete e.initPromise}}},$A=async t=>{let e=t.executionProviders||[],r=e.map(l=>typeof l=="string"?l:l.name),s=r.length===0?Yr:r,n,o=[],a=new Set;for(let l of s){let c=await cA(l);typeof c=="string"?o.push({name:l,err:c}):(n||(n=c),n===c&&a.add(l))}if(!n)throw new Error(`no available backend found. ERR: ${o.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(let{name:l,err:c}of o)r.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${c}`);let i=e.filter(l=>a.has(typeof l=="string"?l:l.name));return[n,new Proxy(t,{get:(l,c)=>c==="executionProviders"?i:Reflect.get(l,c)})]}}),VP=be(()=>{"use strict";RA()}),DA,HP=be(()=>{"use strict";DA="1.24.0-dev.20251116-b39e144322"}),bb,pt,FA=be(()=>{"use strict";HP(),bb="warning",pt={wasm:{},webgl:{},webgpu:{},versions:{common:DA},set logLevel(t){if(t!==void 0){if(typeof t!="string"||["verbose","info","warning","error","fatal"].indexOf(t)===-1)throw new Error(`Unsupported logging level: ${t}`);bb=t}},get logLevel(){return bb}},Object.defineProperty(pt,"logLevel",{enumerable:!0})}),Xe,XP=be(()=>{"use strict";FA(),Xe=pt}),BA,UA,KP=be(()=>{"use strict";BA=(t,e)=>{let r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);r.width=t.dims[3],r.height=t.dims[2];let s=r.getContext("2d");if(s!=null){let n,o;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(n=t.dims[2],o=t.dims[3]):(n=t.dims[3],o=t.dims[2]);let a=e?.format!==void 0?e.format:"RGB",i=e?.norm,l,c;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?c=[0,0,0,0]:typeof i.bias=="number"?c=[i.bias,i.bias,i.bias,i.bias]:(c=[i.bias[0],i.bias[1],i.bias[2],0],i.bias[3]!==void 0&&(c[3]=i.bias[3]));let p=o*n,d=0,_=p,m=p*2,w=-1;a==="RGBA"?(d=0,_=p,m=p*2,w=p*3):a==="RGB"?(d=0,_=p,m=p*2):a==="RBG"&&(d=0,m=p,_=p*2);for(let x=0;x<o;x++)for(let E=0;E<n;E++){let k=(t.data[d++]-c[0])*l[0],A=(t.data[_++]-c[1])*l[1],T=(t.data[m++]-c[2])*l[2],S=w===-1?255:(t.data[w++]-c[3])*l[3];s.fillStyle="rgba("+k+","+A+","+T+","+S+")",s.fillRect(E,x,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")},UA=(t,e)=>{let r=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),s;if(r!=null){let n,o,a;e?.tensorLayout!==void 0&&e.tensorLayout==="NHWC"?(n=t.dims[2],o=t.dims[1],a=t.dims[3]):(n=t.dims[3],o=t.dims[2],a=t.dims[1]);let i=e!==void 0&&e.format!==void 0?e.format:"RGB",l=e?.norm,c,p;l===void 0||l.mean===void 0?c=[255,255,255,255]:typeof l.mean=="number"?c=[l.mean,l.mean,l.mean,l.mean]:(c=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(c[3]=l.mean[3])),l===void 0||l.bias===void 0?p=[0,0,0,0]:typeof l.bias=="number"?p=[l.bias,l.bias,l.bias,l.bias]:(p=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(p[3]=l.bias[3]));let d=o*n;if(e!==void 0&&(e.format!==void 0&&a===4&&e.format!=="RGBA"||a===3&&e.format!=="RGB"&&e.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let _=4,m=0,w=1,x=2,E=3,k=0,A=d,T=d*2,S=-1;i==="RGBA"?(k=0,A=d,T=d*2,S=d*3):i==="RGB"?(k=0,A=d,T=d*2):i==="RBG"&&(k=0,T=d,A=d*2),s=r.createImageData(n,o);for(let L=0;L<o*n;m+=_,w+=_,x+=_,E+=_,L++)s.data[m]=(t.data[k++]-p[0])*c[0],s.data[w]=(t.data[A++]-p[1])*c[1],s.data[x]=(t.data[T++]-p[2])*c[2],s.data[E]=S===-1?255:(t.data[S++]-p[3])*c[3]}else throw new Error("Can not access image data");return s}}),rp,jA,GA,qA,WA,VA,QP=be(()=>{"use strict";Xb(),rp=(t,e)=>{if(t===void 0)throw new Error("Image buffer must be defined");if(e.height===void 0||e.width===void 0)throw new Error("Image height and width must be defined");if(e.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:r,width:s}=e,n=e.norm??{mean:255,bias:0},o,a;typeof n.mean=="number"?o=[n.mean,n.mean,n.mean,n.mean]:o=[n.mean[0],n.mean[1],n.mean[2],n.mean[3]??255],typeof n.bias=="number"?a=[n.bias,n.bias,n.bias,n.bias]:a=[n.bias[0],n.bias[1],n.bias[2],n.bias[3]??0];let i=e.format!==void 0?e.format:"RGBA",l=e.tensorFormat!==void 0&&e.tensorFormat!==void 0?e.tensorFormat:"RGB",c=r*s,p=l==="RGBA"?new Float32Array(c*4):new Float32Array(c*3),d=4,_=0,m=1,w=2,x=3,E=0,k=c,A=c*2,T=-1;i==="RGB"&&(d=3,_=0,m=1,w=2,x=-1),l==="RGBA"?T=c*3:l==="RBG"?(E=0,A=c,k=c*2):l==="BGR"&&(A=0,k=c,E=c*2);for(let S=0;S<c;S++,_+=d,w+=d,m+=d,x+=d)p[E++]=(t[_]+a[0])/o[0],p[k++]=(t[m]+a[1])/o[1],p[A++]=(t[w]+a[2])/o[2],T!==-1&&x!==-1&&(p[T++]=(t[x]+a[3])/o[3]);return l==="RGBA"?new Pt("float32",p,[1,4,r,s]):new Pt("float32",p,[1,3,r,s])},jA=async(t,e)=>{let r=typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement,s=typeof ImageData<"u"&&t instanceof ImageData,n=typeof ImageBitmap<"u"&&t instanceof ImageBitmap,o=typeof t=="string",a,i=e??{},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")},c=p=>typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||p instanceof OffscreenCanvas?p.getContext("2d"):null;if(r){let p=l();p.width=t.width,p.height=t.height;let d=c(p);if(d!=null){let _=t.height,m=t.width;if(e!==void 0&&e.resizedHeight!==void 0&&e.resizedWidth!==void 0&&(_=e.resizedHeight,m=e.resizedWidth),e!==void 0){if(i=e,e.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");i.tensorFormat="RGBA",i.height=_,i.width=m}else i.tensorFormat="RGBA",i.height=_,i.width=m;d.drawImage(t,0,0),a=d.getImageData(0,0,m,_).data}else throw new Error("Can not access image data")}else if(s){let p,d;if(e!==void 0&&e.resizedWidth!==void 0&&e.resizedHeight!==void 0?(p=e.resizedHeight,d=e.resizedWidth):(p=t.height,d=t.width),e!==void 0&&(i=e),i.format="RGBA",i.height=p,i.width=d,e!==void 0){let _=l();_.width=d,_.height=p;let m=c(_);if(m!=null)m.putImageData(t,0,0),a=m.getImageData(0,0,d,p).data;else throw new Error("Can not access image data")}else a=t.data}else if(n){if(e===void 0)throw new Error("Please provide image config with format for Imagebitmap");let p=l();p.width=t.width,p.height=t.height;let d=c(p);if(d!=null){let _=t.height,m=t.width;return d.drawImage(t,0,0,m,_),a=d.getImageData(0,0,m,_).data,i.height=_,i.width=m,rp(a,i)}else throw new Error("Can not access image data")}else{if(o)return new Promise((p,d)=>{let _=l(),m=c(_);if(!t||!m)return d();let w=new Image;w.crossOrigin="Anonymous",w.src=t,w.onload=()=>{_.width=w.width,_.height=w.height,m.drawImage(w,0,0,_.width,_.height);let x=m.getImageData(0,0,_.width,_.height);i.height=_.height,i.width=_.width,p(rp(x.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return rp(a,i);throw new Error("Input data provided is not supported - aborted tensor creation")},GA=(t,e)=>{let{width:r,height:s,download:n,dispose:o}=e,a=[1,s,r,4];return new Pt({location:"texture",type:"float32",texture:t,dims:a,download:n,dispose:o})},qA=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new Pt({location:"gpu-buffer",type:r??"float32",gpuBuffer:t,dims:s,download:n,dispose:o})},WA=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new Pt({location:"ml-tensor",type:r??"float32",mlTensor:t,dims:s,download:n,dispose:o})},VA=(t,e,r)=>new Pt({location:"cpu-pinned",type:t,data:e,dims:r??[e.length]})}),Rs,El,vb,HA,YP=be(()=>{"use strict";Rs=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),El=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),vb=!1,HA=()=>{if(!vb){vb=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,s=typeof r<"u"&&r.from;t&&(Rs.set("int64",BigInt64Array),El.set(BigInt64Array,"int64")),e&&(Rs.set("uint64",BigUint64Array),El.set(BigUint64Array,"uint64")),s?(Rs.set("float16",r),El.set(r,"float16")):Rs.set("float16",Uint16Array)}}}),XA,KA,JP=be(()=>{"use strict";Xb(),XA=t=>{let e=1;for(let r=0;r<t.length;r++){let s=t[r];if(typeof s!="number"||!Number.isSafeInteger(s))throw new TypeError(`dims[${r}] must be an integer, got: ${s}`);if(s<0)throw new RangeError(`dims[${r}] must be a non-negative integer, got: ${s}`);e*=s}return e},KA=(t,e)=>{switch(t.location){case"cpu":return new Pt(t.type,t.data,e);case"cpu-pinned":return new Pt({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new Pt({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new Pt({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new Pt({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),Pt,Xb=be(()=>{"use strict";KP(),QP(),YP(),JP(),Pt=class{constructor(t,e,r){HA();let s,n;if(typeof t=="object"&&"location"in t)switch(this.dataLocation=t.location,s=t.type,n=t.dims,t.location){case"cpu-pinned":{let a=Rs.get(s);if(!a)throw new TypeError(`unsupported type "${s}" to create tensor from pinned buffer`);if(!(t.data instanceof a))throw new TypeError(`buffer should be of type ${a.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 a,i;if(typeof t=="string")if(s=t,i=r,t==="string"){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");a=e}else{let l=Rs.get(t);if(l===void 0)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e)){if(t==="float16"&&l===Uint16Array||t==="uint4"||t==="int4")throw new TypeError(`Creating a ${t} tensor from number array is not supported. Please use ${l.name} as data.`);t==="uint64"||t==="int64"?a=l.from(e,BigInt):a=l.from(e)}else if(e instanceof l)a=e;else if(e instanceof Uint8ClampedArray)if(t==="uint8")a=Uint8Array.from(e);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(t==="float16"&&e instanceof Uint16Array&&l!==Uint16Array)a=new globalThis.Float16Array(e.buffer,e.byteOffset,e.length);else throw new TypeError(`A ${s} tensor's data must be type of ${l}`)}else if(i=e,Array.isArray(t)){if(t.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let l=typeof t[0];if(l==="string")s="string",a=t;else if(l==="boolean")s="bool",a=Uint8Array.from(t);else throw new TypeError(`Invalid element type of data array: ${l}.`)}else if(t instanceof Uint8ClampedArray)s="uint8",a=Uint8Array.from(t);else{let l=El.get(t.constructor);if(l===void 0)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);s=l,a=t}if(i===void 0)i=[a.length];else if(!Array.isArray(i))throw new TypeError("A tensor's dims must be a number array");n=i,this.cpuData=a,this.dataLocation="cpu"}let o=XA(n);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=n,this.size=o}static async fromImage(t,e){return jA(t,e)}static fromTexture(t,e){return GA(t,e)}static fromGpuBuffer(t,e){return qA(t,e)}static fromMLTensor(t,e){return WA(t,e)}static fromPinnedBuffer(t,e,r){return VA(t,e,r)}toDataURL(t){return BA(this,t)}toImageData(t){return UA(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;let e=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=e,t&&this.disposer&&(this.disposer(),this.disposer=void 0),e}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 KA(this,t)}}}),Zt,QA=be(()=>{"use strict";Xb(),Zt=Pt}),up,kb,Bs,Us,ts,rs,YA=be(()=>{"use strict";FA(),up=(t,e)=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.timeStamp(`${t}::ORT::${e}`)},kb=(t,e)=>{let r=new Error().stack?.split(/\r\n|\r|\n/g)||[],s=!1;for(let n=0;n<r.length;n++){if(s&&!r[n].includes("TRACE_FUNC")){let o=`FUNC_${t}::${r[n].trim().split(" ")[1]}`;e&&(o+=`::${e}`),up("CPU",o);return}r[n].includes("TRACE_FUNC")&&(s=!0)}},Bs=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||kb("BEGIN",t)},Us=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||kb("END",t)},ts=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.time(`ORT::${t}`)},rs=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.timeEnd(`ORT::${t}`)}}),JA,ZP=be(()=>{"use strict";RA(),QA(),YA(),JA=class ZA{constructor(e){this.handler=e}async run(e,r,s){Bs(),ts("InferenceSession.run");let n={},o={};if(typeof e!="object"||e===null||e instanceof Zt||Array.isArray(e))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let a=!0;if(typeof r=="object"){if(r===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(r instanceof Zt)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.");a=!1;for(let c of r){if(typeof c!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(c)===-1)throw new RangeError(`'fetches' contains invalid output name: ${c}.`);n[c]=null}if(typeof s=="object"&&s!==null)o=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let c=!1,p=Object.getOwnPropertyNames(r);for(let d of this.outputNames)if(p.indexOf(d)!==-1){let _=r[d];(_===null||_ instanceof Zt)&&(c=!0,a=!1,n[d]=_)}if(c){if(typeof s=="object"&&s!==null)o=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else o=r}}else if(typeof r<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let c of this.inputNames)if(typeof e[c]>"u")throw new Error(`input '${c}' is missing in 'feeds'.`);if(a)for(let c of this.outputNames)n[c]=null;let i=await this.handler.run(e,n,o),l={};for(let c in i)if(Object.hasOwnProperty.call(i,c)){let p=i[c];p instanceof Zt?l[c]=p:l[c]=new Zt(p.type,p.data,p.dims)}return rs("InferenceSession.run"),Us(),l}async release(){return this.handler.dispose()}static async create(e,r,s,n){Bs(),ts("InferenceSession.create");let o,a={};if(typeof e=="string"){if(o=e,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof Uint8Array){if(o=e,typeof r=="object"&&r!==null)a=r;else if(typeof r<"u")throw new TypeError("'options' must be an object.")}else if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer){let p=e,d=0,_=e.byteLength;if(typeof r=="object"&&r!==null)a=r;else if(typeof r=="number"){if(d=r,!Number.isSafeInteger(d))throw new RangeError("'byteOffset' must be an integer.");if(d<0||d>=p.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${p.byteLength}).`);if(_=e.byteLength-d,typeof s=="number"){if(_=s,!Number.isSafeInteger(_))throw new RangeError("'byteLength' must be an integer.");if(_<=0||d+_>p.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${p.byteLength-d}].`);if(typeof n=="object"&&n!==null)a=n;else if(typeof n<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof r<"u")throw new TypeError("'options' must be an object.");o=new Uint8Array(p,d,_)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,l]=await $A(a),c=await i.createInferenceSessionHandler(o,l);return rs("InferenceSession.create"),Us(),new ZA(c)}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}}}),Kb,ez=be(()=>{"use strict";ZP(),Kb=JA}),tz=be(()=>{"use strict"}),rz=be(()=>{"use strict"}),sz=be(()=>{"use strict"}),nz=be(()=>{"use strict"}),e2={};Ml(e2,{InferenceSession:()=>Kb,TRACE:()=>up,TRACE_EVENT_BEGIN:()=>ts,TRACE_EVENT_END:()=>rs,TRACE_FUNC_BEGIN:()=>Bs,TRACE_FUNC_END:()=>Us,Tensor:()=>Zt,env:()=>Xe,registerBackend:()=>Fs});var js=be(()=>{"use strict";VP(),XP(),ez(),QA(),tz(),rz(),YA(),sz(),nz()}),Qb=be(()=>{"use strict"}),t2={};Ml(t2,{default:()=>r2});var Eb,Ab,r2,oz=be(()=>{"use strict";g2(),Gs(),Yb(),Eb="ort-wasm-proxy-worker",Ab=globalThis.self?.name===Eb,Ab&&(self.onmessage=t=>{let{type:e,in:r}=t.data;try{switch(e){case"init-wasm":Jb(r.wasm).then(()=>{s1(r).then(()=>{postMessage({type:e})},s=>{postMessage({type:e,err:s})})},s=>{postMessage({type:e,err:s})});break;case"init-ep":{let{epName:s,env:n}=r;n1(n,s).then(()=>{postMessage({type:e})},o=>{postMessage({type:e,err:o})});break}case"copy-from":{let{buffer:s}=r,n=fp(s);postMessage({type:e,out:n});break}case"create":{let{model:s,options:n}=r;o1(s,n).then(o=>{postMessage({type:e,out:o})},o=>{postMessage({type:e,err:o})});break}case"release":a1(r),postMessage({type:e});break;case"run":{let{sessionId:s,inputIndices:n,inputs:o,outputIndices:a,options:i}=r;i1(s,n,o,a,new Array(a.length).fill(null),i).then(l=>{l.some(c=>c[3]!=="cpu")?postMessage({type:e,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:e,out:l},c1([...o,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":l1(r),postMessage({type:e});break;default:}}catch(s){postMessage({type:e,err:s})}}),r2=Ab?null:t=>new Worker(t??Ct,{type:"module",name:Eb})}),s2={};Ml(s2,{default:()=>n2});async function uA(t={}){var e=t,r=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,n=s&&self.name?.startsWith("em-pthread");e.mountExternalData=(u,f)=>{u.startsWith("./")&&(u=u.substring(2)),(e.Uc||(e.Uc=new Map)).set(u,f)},e.unmountExternalData=()=>{delete e.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,Be:!0}).buffer.constructor;let o=()=>{let u=f=>(...h)=>{let g=or;return h=f(...h),or!=g?new Promise((b,M)=>{F0={resolve:b,reject:M}}):h};(()=>{for(let f of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[f]=u(e[f])})(),typeof jsepRunAsync<"u"&&(e._OrtRun=jsepRunAsync(e._OrtRun),e._OrtRunWithBinding=jsepRunAsync(e._OrtRunWithBinding)),o=void 0};e.asyncInit=()=>{o?.()};var a,i,l=(u,f)=>{throw f},c=Jt.url,p="";if(r||s){try{p=new URL(".",c).href}catch{}s&&(i=u=>{var f=new XMLHttpRequest;return f.open("GET",u,!1),f.responseType="arraybuffer",f.send(null),new Uint8Array(f.response)}),a=async u=>{if(O(u))return new Promise((h,g)=>{var b=new XMLHttpRequest;b.open("GET",u,!0),b.responseType="arraybuffer",b.onload=()=>{b.status==200||b.status==0&&b.response?h(b.response):g(b.status)},b.onerror=g,b.send(null)});var f=await fetch(u,{credentials:"same-origin"});if(f.ok)return f.arrayBuffer();throw Error(f.status+" : "+f.url)}}var d,_,m,w,x,E,k=console.log.bind(console),A=console.error.bind(console),T=k,S=A,L=!1,O=u=>u.startsWith("file://");function v(){Gr.buffer!=B.buffer&&xe()}if(n){let u=function(f){try{var h=f.data,g=h.Oc;if(g==="load"){let b=[];self.onmessage=M=>b.push(M),E=()=>{postMessage({Oc:"loaded"});for(let M of b)u(M);self.onmessage=u};for(let M of h.de)e[M]&&!e[M].proxy||(e[M]=(...I)=>{postMessage({Oc:"callHandler",ce:M,args:I})},M=="print"&&(T=e[M]),M=="printErr"&&(S=e[M]));Gr=h.je,xe(),_=h.ke,_t(),Bu()}else if(g==="run"){(function(b){var M=(v(),C)[b+52>>>2>>>0];b=(v(),C)[b+56>>>2>>>0],_k(M,M-b),le(M)})(h.Nc),Y0(h.Nc,0,0,1,0,0),tv(),$0(h.Nc),X||(Qv(),X=!0);try{cS(h.he,h.Wc)}catch(b){if(b!="unwind")throw b}}else h.target!=="setimmediate"&&(g==="checkMailbox"?X&&Lu():g&&(S(`worker: received unknown command ${g}`),S(h)))}catch(b){throw ck(),b}};var W=u,X=!1;self.onunhandledrejection=f=>{throw f.reason||f},self.onmessage=u}var B,H,G,Q,R,C,te,ae,P,$,F,J=!1;function xe(){var u=Gr.buffer;e.HEAP8=B=new Int8Array(u),G=new Int16Array(u),e.HEAPU8=H=new Uint8Array(u),Q=new Uint16Array(u),e.HEAP32=R=new Int32Array(u),e.HEAPU32=C=new Uint32Array(u),te=new Float32Array(u),ae=new Float64Array(u),P=new BigInt64Array(u),$=new BigUint64Array(u)}function ue(){J=!0,n?E():xr._b()}function Ve(u){throw S(u="Aborted("+u+")"),L=!0,u=new WebAssembly.RuntimeError(u+". Build with -sASSERTIONS for more info."),x?.(u),u}function ot(){return{a:{f:uS,J:pS,k:dS,p:fS,l:_S,ta:mS,b:hS,ca:gS,Ka:iv,s:wS,da:pv,_a:dv,Ga:fv,Ia:_v,$a:mv,Ya:hv,Ra:gv,Xa:wv,pa:xv,Ha:yv,Yb:bv,Za:vv,Fa:kv,eb:xS,Da:bS,Tb:vS,Rb:ES,Ca:MS,M:SS,I:TS,Sb:OS,ka:$S,Ub:RS,Ua:DS,Wb:BS,La:US,Pb:jS,la:GS,Ta:$0,bb:qS,U:XS,n:ZS,c:z0,sb:eT,w:tT,L:rT,z:sT,j:nT,o:Cv,tb:oT,G:aT,T:iT,h:lT,u:cT,m:uT,i:pT,Oa:dT,Pa:fT,Qa:_T,Ma:Nv,Na:$v,Qb:Rv,fb:hT,db:xT,Y:yT,rb:bT,ma:vT,cb:gT,gb:kT,ab:ET,Xb:AT,N:mT,hb:MT,X:ST,Vb:TT,ob:RT,C:DT,sa:FT,ra:BT,qb:UT,W:jT,v:GT,nb:qT,mb:WT,lb:VT,pb:HT,kb:XT,jb:KT,ib:QT,Va:Gv,Wa:qv,Ja:Mn,ea:Wv,oa:Vv,Sa:Hv,na:Xv,Db:aI,xa:JO,Eb:oI,ya:YO,F:UO,e:TO,r:MO,x:AO,D:DO,Ib:XO,ba:VO,B:IO,za:KO,$:ZO,ha:HO,Fb:sI,Gb:rI,Ba:jO,Aa:WO,Jb:GO,wa:nI,aa:QO,d:OO,A:CO,q:SO,Cb:iI,t:PO,y:FO,H:LO,E:zO,K:BO,S:eI,ja:RO,_:tI,Kb:$O,Lb:NO,P:qO,g:JT,a:Gr,Ob:An,Hb:ZT,ia:eO,O:tO,qa:rO,Mb:sO,Q:nO,zb:oO,Ab:aO,ua:iO,fa:lO,R:cO,Ea:uO,va:pO,Z:dO,xb:fO,Zb:_O,V:mO,Bb:hO,ub:gO,vb:xO,wb:yO,ga:bO,yb:vO,Nb:kO}}}async function _t(){function u(g,b){var M=xr=g.exports;g={};for(let[I,z]of Object.entries(M))typeof z=="function"?(M=WS(z),g[I]=M):g[I]=z;return xr=g,xr=(function(){var I=xr,z=Y=>Se=>Y(Se)>>>0,U=Y=>()=>Y()>>>0;return(I=Object.assign({},I)).$b=z(I.$b),I.Cc=U(I.Cc),I.Ec=z(I.Ec),I.rd=(Y=>(Se,Ne)=>Y(Se,Ne)>>>0)(I.rd),I.wd=z(I.wd),I.xd=U(I.xd),I.Bd=z(I.Bd),I})(),Z1.push(xr.id),Kv=(g=xr).$b,Qv=g.ac,e._OrtInit=g.bc,e._OrtGetLastError=g.cc,e._OrtCreateSessionOptions=g.dc,e._OrtAppendExecutionProvider=g.ec,e._OrtAddFreeDimensionOverride=g.fc,e._OrtAddSessionConfigEntry=g.gc,e._OrtReleaseSessionOptions=g.hc,e._OrtCreateSession=g.ic,e._OrtReleaseSession=g.jc,e._OrtGetInputOutputCount=g.kc,e._OrtGetInputOutputMetadata=g.lc,e._OrtFree=g.mc,e._OrtCreateTensor=g.nc,e._OrtGetTensorData=g.oc,e._OrtReleaseTensor=g.pc,e._OrtCreateRunOptions=g.qc,e._OrtAddRunConfigEntry=g.rc,e._OrtReleaseRunOptions=g.sc,e._OrtCreateBinding=g.tc,e._OrtBindInput=g.uc,e._OrtBindOutput=g.vc,e._OrtClearBoundOutputs=g.wc,e._OrtReleaseBinding=g.xc,e._OrtRunWithBinding=g.yc,e._OrtRun=g.zc,e._OrtEndProfiling=g.Ac,W0=e._OrtGetWebGpuDevice=g.Bc,Du=g.Cc,Vt=e._free=g.Dc,Cn=e._malloc=g.Ec,Yv=e._wgpuBufferRelease=g.Fc,Jv=e._wgpuCreateInstance=g.Gc,Zv=g.Hc,ek=g.Ic,tk=g.Jc,rk=g.Kc,sk=g.Lc,nk=g.Pc,ok=g.Zc,ak=g._c,ik=g.$c,V0=g.bd,H0=g.cd,X0=g.dd,K0=g.ed,il=g.fd,Q0=g.gd,lk=g.hd,Y0=g.kd,ck=g.ld,uk=g.md,pk=g.nd,J0=g.od,dk=g.pd,fk=g.qd,Z0=g.rd,we=g.sd,ll=g.td,_k=g.ud,le=g.vd,Fu=g.wd,ce=g.xd,mk=g.yd,eb=g.zd,hk=g.Ad,gk=g.Bd,wk=g.Cd,tb=g.Dd,xk=g.Ed,yk=g.Fd,bk=g.Gd,vk=g.Hd,kk=g.Id,Ek=g.Jd,Ak=g.Kd,Mk=g.Ld,Sk=g.Md,Tk=g.Nd,Ok=g.Od,Ik=g.Pd,Ck=g.Qd,Lk=g.Rd,Pk=g.Td,zk=g.Ud,Nk=g.Vd,$k=g.Wd,Rk=g.Yd,Dk=g.Zd,Fk=g._d,Bk=g.$d,Uk=g.ae,jk=g.be,Gk=g.pe,qk=g.qe,Wk=g.re,Vk=g.se,Hk=g.te,Xk=g.ue,Kk=g.ve,Qk=g.we,Yk=g.xe,Jk=g.ye,Zk=g.ze,eE=g.Xe,tE=g.Ye,rE=g.Ze,sE=g._e,_=b,xr}var f,h=ot();return e.instantiateWasm?new Promise(g=>{e.instantiateWasm(h,(b,M)=>{g(u(b,M))})}):n?u(new WebAssembly.Instance(_,ot()),_):(F??=e.locateFile?e.locateFile?e.locateFile("ort-wasm-simd-threaded.asyncify.wasm",p):p+"ort-wasm-simd-threaded.asyncify.wasm":new URL("ort-wasm-simd-threaded.asyncify.wasm",Jt.url).href,f=await(async function(g){var b=F;if(!d&&!O(b))try{var M=fetch(b,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(M,g)}catch(I){S(`wasm streaming compile failed: ${I}`),S("falling back to ArrayBuffer instantiation")}return(async function(I,z){try{var U=await(async function(Y){if(!d)try{var Se=await a(Y);return new Uint8Array(Se)}catch{}if(Y==F&&d)Y=new Uint8Array(d);else{if(!i)throw"both async and sync fetching of the wasm failed";Y=i(Y)}return Y})(I);return await WebAssembly.instantiate(U,z)}catch(Y){S(`failed to asynchronously prepare wasm: ${Y}`),Ve(Y)}})(b,g)})(h),u(f.instance,f.module))}class at{name="ExitStatus";constructor(f){this.message=`Program terminated with exit(${f})`,this.status=f}}var vt=u=>{u.terminate(),u.onmessage=()=>{}},Fe=[],Me=0,et=null,sr=u=>{jr.length==0&&(sv(),rv(jr[0]));var f=jr.pop();if(!f)return 6;nl.push(f),Ms[u.Nc]=f,f.Nc=u.Nc;var h={Oc:"run",he:u.ge,Wc:u.Wc,Nc:u.Nc};return f.postMessage(h,u.Yc),0},ze=0,Be=(u,f,...h)=>{var g,b=16*h.length,M=ce(),I=Fu(b),z=I>>>3;for(g of h)typeof g=="bigint"?((v(),P)[z++>>>0]=1n,(v(),P)[z++>>>0]=g):((v(),P)[z++>>>0]=0n,(v(),ae)[z++>>>0]=g);return u=uk(u,0,b,I,f),le(M),u};function An(u){if(n)return Be(0,1,u);if(m=u,!(0<ze)){for(var f of nl)vt(f);for(f of jr)vt(f);jr=[],nl=[],Ms={},L=!0}l(0,new at(u))}function sl(u){if(n)return Be(1,0,u);Mn(u)}var Mn=u=>{if(m=u,n)throw sl(u),"unwind";An(u)},jr=[],nl=[],Z1=[],Ms={},ev=u=>{var f=u.Nc;delete Ms[f],jr.push(u),nl.splice(nl.indexOf(u),1),u.Nc=0,pk(f)};function tv(){Z1.forEach(u=>u())}var rv=u=>new Promise(f=>{u.onmessage=b=>{var M=b.data;if(b=M.Oc,M.Vc&&M.Vc!=Du()){var I=Ms[M.Vc];I?I.postMessage(M,M.Yc):S(`Internal error! Worker sent a message "${b}" to target pthread ${M.Vc}, but that thread no longer exists!`)}else b==="checkMailbox"?Lu():b==="spawnThread"?sr(M):b==="cleanupThread"?Et(()=>{ev(Ms[M.ie])}):b==="loaded"?(u.loaded=!0,f(u)):M.target==="setimmediate"?u.postMessage(M):b==="uncaughtException"?u.onerror(M.error):b==="callHandler"?e[M.ce](...M.args):b&&S(`worker sent an unknown command ${b}`)},u.onerror=b=>{throw S(`worker sent an error! ${b.filename}:${b.lineno}: ${b.message}`),b};var h,g=[];for(h of[])e.propertyIsEnumerable(h)&&g.push(h);u.postMessage({Oc:"load",de:g,je:Gr,ke:_})});function sv(){var u=new Worker((()=>{let f=URL;return Jt.url>"file:"&&Jt.url<"file;"?new f("ort.webgpu.bundle.min.mjs",Jt.url):new URL(Jt.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});jr.push(u)}var Gr,cS=(u,f)=>{ze=0,u=tb(u,f),0<ze?m=u:J0(u)},Iu=[],Cu=0,kt=u=>-9007199254740992>u||9007199254740992<u?NaN:Number(u);function uS(u){var f=new I0(u>>>=0);return(v(),B)[f.Qc+12>>>0]==0&&(nv(f,!0),Cu--),ov(f,!1),Iu.push(f),gk(u)}var Sn=0,pS=()=>{we(0,0);var u=Iu.pop();mk(u.Xc),Sn=0};function nv(u,f){f=f?1:0,(v(),B)[u.Qc+12>>>0]=f}function ov(u,f){f=f?1:0,(v(),B)[u.Qc+13>>>0]=f}class I0{constructor(f){this.Xc=f,this.Qc=f-24}}var C0=u=>{var f=Sn;if(!f)return ll(0),0;var h=new I0(f);(v(),C)[h.Qc+16>>>2>>>0]=f;var g=(v(),C)[h.Qc+4>>>2>>>0];if(!g)return ll(0),f;for(var b of u){if(b===0||b===g)break;if(hk(b,g,h.Qc+16))return ll(b),f}return ll(g),f};function dS(){return C0([])}function fS(u){return C0([u>>>0])}function _S(u,f,h,g){return C0([u>>>0,f>>>0,h>>>0,g>>>0])}var mS=()=>{var u=Iu.pop();u||Ve("no exception to throw");var f=u.Xc;throw(v(),B)[u.Qc+13>>>0]==0&&(Iu.push(u),ov(u,!0),nv(u,!1),Cu++),eb(f),Sn=f};function hS(u,f,h){var g=new I0(u>>>=0);throw f>>>=0,h>>>=0,(v(),C)[g.Qc+16>>>2>>>0]=0,(v(),C)[g.Qc+4>>>2>>>0]=f,(v(),C)[g.Qc+8>>>2>>>0]=h,eb(u),Cu++,Sn=u}var gS=()=>Cu;function av(u,f,h,g){return n?Be(2,1,u,f,h,g):iv(u,f,h,g)}function iv(u,f,h,g){if(u>>>=0,f>>>=0,h>>>=0,g>>>=0,!globalThis.SharedArrayBuffer)return 6;var b=[];return n&&b.length===0?av(u,f,h,g):(u={ge:h,Nc:u,Wc:g,Yc:b},n?(u.Oc="spawnThread",postMessage(u,b),0):sr(u))}function wS(u){throw Sn||=u>>>0,Sn}var lv=globalThis.TextDecoder&&new TextDecoder,cv=(u,f,h,g)=>{if(h=f+h,g)return h;for(;u[f]&&!(f>=h);)++f;return f},uv=(u,f=0,h,g)=>{if(16<(h=cv(u,f>>>=0,h,g))-f&&u.buffer&&lv)return lv.decode(u.buffer instanceof ArrayBuffer?u.subarray(f,h):u.slice(f,h));for(g="";f<h;){var b=u[f++];if(128&b){var M=63&u[f++];if((224&b)==192)g+=String.fromCharCode((31&b)<<6|M);else{var I=63&u[f++];65536>(b=(240&b)==224?(15&b)<<12|M<<6|I:(7&b)<<18|M<<12|I<<6|63&u[f++])?g+=String.fromCharCode(b):(b-=65536,g+=String.fromCharCode(55296|b>>10,56320|1023&b))}}else g+=String.fromCharCode(b)}return g},Tn=(u,f,h)=>(u>>>=0)?uv((v(),H),u,f,h):"";function pv(u,f,h){return n?Be(3,1,u,f,h):0}function dv(u,f){if(n)return Be(4,1,u,f)}function fv(u,f){if(n)return Be(5,1,u,f)}function _v(u,f,h){if(n)return Be(6,1,u,f,h)}function mv(u,f,h){return n?Be(7,1,u,f,h):0}function hv(u,f){if(n)return Be(8,1,u,f)}function gv(u,f,h){if(n)return Be(9,1,u,f,h)}function wv(u,f,h,g){if(n)return Be(10,1,u,f,h,g)}function xv(u,f,h,g){if(n)return Be(11,1,u,f,h,g)}function yv(u,f,h,g){if(n)return Be(12,1,u,f,h,g)}function bv(u){if(n)return Be(13,1,u)}function vv(u,f){if(n)return Be(14,1,u,f)}function kv(u,f,h){if(n)return Be(15,1,u,f,h)}var xS=()=>Ve(""),nr=u=>{u>>>=0;for(var f="";;){var h=(v(),H)[u++>>>0];if(!h)return f;f+=String.fromCharCode(h)}},L0={},P0={},yS={},On=class extends Error{constructor(u){super(u),this.name="BindingError"}};function _r(u,f,h={}){return(function(g,b,M={}){var I=b.name;if(!g)throw new On(`type "${I}" must have a positive integer typeid pointer`);if(P0.hasOwnProperty(g)){if(M.ee)return;throw new On(`Cannot register type '${I}' twice`)}P0[g]=b,delete yS[g],L0.hasOwnProperty(g)&&(b=L0[g],delete L0[g],b.forEach(z=>z()))})(u,f,h)}var Ev=(u,f,h)=>{switch(f){case 1:return h?g=>(v(),B)[g>>>0]:g=>(v(),H)[g>>>0];case 2:return h?g=>(v(),G)[g>>>1>>>0]:g=>(v(),Q)[g>>>1>>>0];case 4:return h?g=>(v(),R)[g>>>2>>>0]:g=>(v(),C)[g>>>2>>>0];case 8:return h?g=>(v(),P)[g>>>3>>>0]:g=>(v(),$)[g>>>3>>>0];default:throw new TypeError(`invalid integer width (${f}): ${u}`)}};function bS(u,f,h,g,b){u>>>=0,h>>>=0,f=nr(f>>>0);let M=I=>I;if(g=g===0n){let I=8*h;M=z=>BigInt.asUintN(I,z),b=M(b)}_r(u,{name:f,Mc:M,Sc:(I,z)=>(typeof z=="number"&&(z=BigInt(z)),z),Rc:Ev(f,h,!g),Tc:null})}function vS(u,f,h,g){_r(u>>>=0,{name:f=nr(f>>>0),Mc:function(b){return!!b},Sc:function(b,M){return M?h:g},Rc:function(b){return this.Mc((v(),H)[b>>>0])},Tc:null})}var Av=[],Ss=[0,1,,1,null,1,!0,1,!1,1];function z0(u){9<(u>>>=0)&&--Ss[u+1]==0&&(Ss[u]=void 0,Av.push(u))}var Rt=u=>{if(!u)throw new On(`Cannot use deleted val. handle = ${u}`);return Ss[u]},Wt=u=>{switch(u){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let f=Av.pop()||Ss.length;return Ss[f]=u,Ss[f+1]=1,f}};function N0(u){return this.Mc((v(),C)[u>>>2>>>0])}var kS={name:"emscripten::val",Mc:u=>{var f=Rt(u);return z0(u),f},Sc:(u,f)=>Wt(f),Rc:N0,Tc:null};function ES(u){return _r(u>>>0,kS)}var AS=(u,f)=>{switch(f){case 4:return function(h){return this.Mc((v(),te)[h>>>2>>>0])};case 8:return function(h){return this.Mc((v(),ae)[h>>>3>>>0])};default:throw new TypeError(`invalid float width (${f}): ${u}`)}};function MS(u,f,h){h>>>=0,_r(u>>>=0,{name:f=nr(f>>>0),Mc:g=>g,Sc:(g,b)=>b,Rc:AS(f,h),Tc:null})}function SS(u,f,h,g,b){u>>>=0,h>>>=0,f=nr(f>>>0);let M=z=>z;if(g===0){var I=32-8*h;M=z=>z<<I>>>I,b=M(b)}_r(u,{name:f,Mc:M,Sc:(z,U)=>U,Rc:Ev(f,h,g!==0),Tc:null})}function TS(u,f,h){function g(M){var I=(v(),C)[M>>>2>>>0];return M=(v(),C)[M+4>>>2>>>0],new b((v(),B).buffer,M,I)}var b=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][f];_r(u>>>=0,{name:h=nr(h>>>0),Mc:g,Rc:g},{ee:!0})}var mr=(u,f,h)=>{var g=(v(),H);if(f>>>=0,0<h){var b=f;h=f+h-1;for(var M=0;M<u.length;++M){var I=u.codePointAt(M);if(127>=I){if(f>=h)break;g[f++>>>0]=I}else if(2047>=I){if(f+1>=h)break;g[f++>>>0]=192|I>>6,g[f++>>>0]=128|63&I}else if(65535>=I){if(f+2>=h)break;g[f++>>>0]=224|I>>12,g[f++>>>0]=128|I>>6&63,g[f++>>>0]=128|63&I}else{if(f+3>=h)break;g[f++>>>0]=240|I>>18,g[f++>>>0]=128|I>>12&63,g[f++>>>0]=128|I>>6&63,g[f++>>>0]=128|63&I,M++}}g[f>>>0]=0,u=f-b}else u=0;return u},hr=u=>{for(var f=0,h=0;h<u.length;++h){var g=u.charCodeAt(h);127>=g?f++:2047>=g?f+=2:55296<=g&&57343>=g?(f+=4,++h):f+=3}return f};function OS(u,f){_r(u>>>=0,{name:f=nr(f>>>0),Mc(h){var g=(v(),C)[h>>>2>>>0];return g=Tn(h+4,g,!0),Vt(h),g},Sc(h,g){g instanceof ArrayBuffer&&(g=new Uint8Array(g));var b=typeof g=="string";if(!(b||ArrayBuffer.isView(g)&&g.BYTES_PER_ELEMENT==1))throw new On("Cannot pass non-string to std::string");var M=b?hr(g):g.length,I=Cn(4+M+1),z=I+4;return(v(),C)[I>>>2>>>0]=M,b?mr(g,z,M+1):(v(),H).set(g,z>>>0),h!==null&&h.push(Vt,I),I},Rc:N0,Tc(h){Vt(h)}})}var Mv=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,IS=(u,f,h)=>{if(u>>>=1,16<(f=cv((v(),Q),u,f/2,h))-u&&Mv)return Mv.decode((v(),Q).slice(u,f));for(h="";u<f;++u){var g=(v(),Q)[u>>>0];h+=String.fromCharCode(g)}return h},CS=(u,f,h)=>{if(h??=2147483647,2>h)return 0;var g=f;h=(h-=2)<2*u.length?h/2:u.length;for(var b=0;b<h;++b){var M=u.charCodeAt(b);(v(),G)[f>>>1>>>0]=M,f+=2}return(v(),G)[f>>>1>>>0]=0,f-g},LS=u=>2*u.length,PS=(u,f,h)=>{var g="";u>>>=2;for(var b=0;!(b>=f/4);b++){var M=(v(),C)[u+b>>>0];if(!M&&!h)break;g+=String.fromCodePoint(M)}return g},zS=(u,f,h)=>{if(f>>>=0,h??=2147483647,4>h)return 0;var g=f;h=g+h-4;for(var b=0;b<u.length;++b){var M=u.codePointAt(b);if(65535<M&&b++,(v(),R)[f>>>2>>>0]=M,(f+=4)+4>h)break}return(v(),R)[f>>>2>>>0]=0,f-g},NS=u=>{for(var f=0,h=0;h<u.length;++h)65535<u.codePointAt(h)&&h++,f+=4;return f};function $S(u,f,h){if(u>>>=0,f>>>=0,h=nr(h>>>=0),f===2)var g=IS,b=CS,M=LS;else g=PS,b=zS,M=NS;_r(u,{name:h,Mc:I=>{var z=(v(),C)[I>>>2>>>0];return z=g(I+4,z*f,!0),Vt(I),z},Sc:(I,z)=>{if(typeof z!="string")throw new On(`Cannot pass non-string to C++ string type ${h}`);var U=M(z),Y=Cn(4+U+f);return(v(),C)[Y>>>2>>>0]=U/f,b(z,Y+4,U+f),I!==null&&I.push(Vt,Y),Y},Rc:N0,Tc(I){Vt(I)}})}function RS(u,f){_r(u>>>=0,{fe:!0,name:f=nr(f>>>0),Mc:()=>{},Sc:()=>{}})}function DS(u){Y0(u>>>0,!s,1,!r,131072,!1),tv()}var Et=u=>{if(!L)try{if(u(),!(0<ze))try{n?Du()&&J0(m):Mn(m)}catch(f){f instanceof at||f=="unwind"||l(0,f)}}catch(f){f instanceof at||f=="unwind"||l(0,f)}},FS=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function $0(u){u>>>=0,FS||(Atomics.waitAsync((v(),R),u>>>2,u).value.then(Lu),u+=128,Atomics.store((v(),R),u>>>2,1))}var Lu=()=>Et(()=>{var u=Du();u&&($0(u),fk())});function BS(u,f){(u>>>=0)==f>>>0?setTimeout(Lu):n?postMessage({Vc:u,Oc:"checkMailbox"}):(u=Ms[u])&&u.postMessage({Oc:"checkMailbox"})}var R0=[];function US(u,f,h,g,b){for(f>>>=0,b>>>=0,R0.length=0,h=b>>>3,g=b+g>>>3;h<g;){var M;M=(v(),P)[h++>>>0]?(v(),P)[h++>>>0]:(v(),ae)[h++>>>0],R0.push(M)}return(f?rb[f]:EO[u])(...R0)}var jS=()=>{ze=0};function GS(u){u>>>=0,n?postMessage({Oc:"cleanupThread",ie:u}):ev(Ms[u])}function qS(u){}var Pu=u=>{try{u()}catch(f){Ve(f)}};function WS(u){var f=(...h)=>{zu.push(u);try{return u(...h)}finally{L||(zu.pop(),or&&qr===1&&zu.length===0&&(qr=0,ze+=1,Pu(tE),typeof Fibers<"u"&&Fibers.De()))}};return Ov.set(u,f),f}var qr=0,or=null,Sv=0,zu=[],D0=new Map,Tv=new Map,Ov=new Map,VS=0,F0=null,HS=[],Iv=u=>(function(f){if(!L){if(qr===0){var h=!1,g=!1;f((b=0)=>{if(!L&&(Sv=b,h=!0,g)){qr=2,Pu(()=>rE(or)),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.resume(),b=!1;try{var M=(function(){var U=(v(),R)[or+8>>>2>>>0];return U=Tv.get(U),U=Ov.get(U),--ze,U()})()}catch(U){M=U,b=!0}var I=!1;if(!or){var z=F0;z&&(F0=null,(b?z.reject:z.resolve)(M),I=!0)}if(b&&!I)throw M}}),g=!0,h||(qr=1,or=(function(){var b=Cn(65548),M=b+12;if((v(),C)[b>>>2>>>0]=M,(v(),C)[b+4>>>2>>>0]=M+65536,M=zu[0],!D0.has(M)){var I=VS++;D0.set(M,I),Tv.set(I,M)}return M=D0.get(M),(v(),R)[b+8>>>2>>>0]=M,b})(),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.pause(),Pu(()=>eE(or)))}else qr===2?(qr=0,Pu(sE),Vt(or),or=null,HS.forEach(Et)):Ve(`invalid state: ${qr}`);return Sv}})(f=>{u().then(f)});function XS(u){return u>>>=0,Iv(async()=>{var f=await Rt(u);return Wt(f)})}var B0=[],KS=u=>{var f=B0.length;return B0.push(u),f},QS=(u,f)=>{for(var h=Array(u),g=0;g<u;++g){var b=g,M=(v(),C)[f+4*g>>>2>>>0],I=P0[M];if(I===void 0)throw u=`parameter ${g}`,M=Kv(M),f=nr(M),Vt(M),new On(`${u} has unknown type ${f}`);h[b]=I}return h},YS=(u,f,h)=>{var g=[];return u=u(g,h),g.length&&((v(),C)[f>>>2>>>0]=Wt(g)),u},JS={},Nu=u=>{var f=JS[u];return f===void 0?nr(u):f};function ZS(u,f,h){var[g,...b]=QS(u,f>>>0);f=g.Sc.bind(g);var M=b.map(U=>U.Rc.bind(U));u--;var I={toValue:Rt};switch(u=M.map((U,Y)=>{var Se=`argFromPtr${Y}`;return I[Se]=U,`${Se}(args${Y?"+"+8*Y:""})`}),h){case 0:var z="toValue(handle)";break;case 2:z="new (toValue(handle))";break;case 3:z="";break;case 1:I.getStringOrSymbol=Nu,z="toValue(handle)[getStringOrSymbol(methodName)]"}return z+=`(${u})`,g.fe||(I.toReturnWire=f,I.emval_returnValue=YS,z=`return emval_returnValue(toReturnWire, destructorsRef, ${z})`),z=`return function (handle, methodName, destructorsRef, args) {
|
|
11
11
|
${z}
|
|
12
|
-
}`,_=new Function(Object.keys(O),z)(...Object.values(O)),z=`methodCaller<(${b.map(B=>B.name)}) => ${g.name}>`,VM(Object.defineProperty(_,"name",{value:z}))}function QM(c,d){return d>>>=0,(c=Ut(c>>>0))==Ut(d)}function JM(c){return(c>>>=0)?(c=wu(c),Xt(globalThis[c])):Xt(globalThis)}function ZM(c){return c=wu(c>>>0),Xt(e[c])}function eT(c,d){return d>>>=0,c=Ut(c>>>0),d=Ut(d),Xt(c[d])}function tT(c){9<(c>>>=0)&&(vs[c+1]+=1)}function $1(c,d,_,g,b){return Ky[c>>>0](d>>>0,_>>>0,g>>>0,b>>>0)}function rT(c,d,_,g,b){return $1(c>>>0,d>>>0,_>>>0,g>>>0,b>>>0)}function sT(){return Xt([])}function nT(c){c=Ut(c>>>0);for(var d=Array(c.length),_=0;_<c.length;_++)d[_]=c[_];return Xt(d)}function oT(c){return Xt(wu(c>>>0))}function aT(){return Xt({})}function iT(c){for(var d=Ut(c>>>=0);d.length;){var _=d.pop();d.pop()(_)}Gy(c)}function lT(c,d,_){d>>>=0,_>>>=0,c=Ut(c>>>0),d=Ut(d),_=Ut(_),c[d]=_}function cT(c,d){c=xt(c),d>>>=0,c=new Date(1e3*c),(k(),U)[d>>>2>>>0]=c.getUTCSeconds(),(k(),U)[d+4>>>2>>>0]=c.getUTCMinutes(),(k(),U)[d+8>>>2>>>0]=c.getUTCHours(),(k(),U)[d+12>>>2>>>0]=c.getUTCDate(),(k(),U)[d+16>>>2>>>0]=c.getUTCMonth(),(k(),U)[d+20>>>2>>>0]=c.getUTCFullYear()-1900,(k(),U)[d+24>>>2>>>0]=c.getUTCDay(),c=(c.getTime()-Date.UTC(c.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(k(),U)[d+28>>>2>>>0]=c}var R1=c=>c%4==0&&(c%100!=0||c%400==0),D1=[0,31,60,91,121,152,182,213,244,274,305,335],U1=[0,31,59,90,120,151,181,212,243,273,304,334];function uT(c,d){c=xt(c),d>>>=0,c=new Date(1e3*c),(k(),U)[d>>>2>>>0]=c.getSeconds(),(k(),U)[d+4>>>2>>>0]=c.getMinutes(),(k(),U)[d+8>>>2>>>0]=c.getHours(),(k(),U)[d+12>>>2>>>0]=c.getDate(),(k(),U)[d+16>>>2>>>0]=c.getMonth(),(k(),U)[d+20>>>2>>>0]=c.getFullYear()-1900,(k(),U)[d+24>>>2>>>0]=c.getDay();var _=(R1(c.getFullYear())?D1:U1)[c.getMonth()]+c.getDate()-1|0;(k(),U)[d+28>>>2>>>0]=_,(k(),U)[d+36>>>2>>>0]=-60*c.getTimezoneOffset(),_=new Date(c.getFullYear(),6,1).getTimezoneOffset();var g=new Date(c.getFullYear(),0,1).getTimezoneOffset();c=0|(_!=g&&c.getTimezoneOffset()==Math.min(g,_)),(k(),U)[d+32>>>2>>>0]=c}function pT(c){c>>>=0;var d=new Date((k(),U)[c+20>>>2>>>0]+1900,(k(),U)[c+16>>>2>>>0],(k(),U)[c+12>>>2>>>0],(k(),U)[c+8>>>2>>>0],(k(),U)[c+4>>>2>>>0],(k(),U)[c>>>2>>>0],0),_=(k(),U)[c+32>>>2>>>0],g=d.getTimezoneOffset(),b=new Date(d.getFullYear(),6,1).getTimezoneOffset(),M=new Date(d.getFullYear(),0,1).getTimezoneOffset(),O=Math.min(M,b);return 0>_?(k(),U)[c+32>>>2>>>0]=+(b!=M&&O==g):0<_!=(O==g)&&(b=Math.max(M,b),d.setTime(d.getTime()+6e4*((0<_?O:b)-g))),(k(),U)[c+24>>>2>>>0]=d.getDay(),_=(R1(d.getFullYear())?D1:U1)[d.getMonth()]+d.getDate()-1|0,(k(),U)[c+28>>>2>>>0]=_,(k(),U)[c>>>2>>>0]=d.getSeconds(),(k(),U)[c+4>>>2>>>0]=d.getMinutes(),(k(),U)[c+8>>>2>>>0]=d.getHours(),(k(),U)[c+12>>>2>>>0]=d.getDate(),(k(),U)[c+16>>>2>>>0]=d.getMonth(),(k(),U)[c+20>>>2>>>0]=d.getYear(),c=d.getTime(),BigInt(isNaN(c)?-1:c/1e3)}function B1(c,d,_,g,b,M,O){return n?De(16,1,c,d,_,g,b,M,O):-52}function F1(c,d,_,g,b,M){if(n)return De(17,1,c,d,_,g,b,M)}var Di={},dT=()=>performance.timeOrigin+performance.now();function j1(c,d){if(n)return De(18,1,c,d);if(Di[c]&&(clearTimeout(Di[c].id),delete Di[c]),!d)return 0;var _=setTimeout(()=>{delete Di[c],yt(()=>gv(c,performance.timeOrigin+performance.now()))},d);return Di[c]={id:_,Ce:d},0}function fT(c,d,_,g){c>>>=0,d>>>=0,_>>>=0,g>>>=0;var b=new Date().getFullYear(),M=new Date(b,0,1).getTimezoneOffset();b=new Date(b,6,1).getTimezoneOffset();var O=Math.max(M,b);(k(),C)[c>>>2>>>0]=60*O,(k(),U)[d>>>2>>>0]=+(M!=b),c=(d=z=>{var B=Math.abs(z);return`UTC${0<=z?"-":"+"}${String(Math.floor(B/60)).padStart(2,"0")}${String(B%60).padStart(2,"0")}`})(M),d=d(b),b<M?(wr(c,_,17),wr(d,g,17)):(wr(c,g,17),wr(d,_,17))}var mT=()=>Date.now(),hT=1;function _T(c,d,_){if(_>>>=0,!(0<=c&&3>=c))return 28;if(c===0)c=Date.now();else{if(!hT)return 52;c=performance.timeOrigin+performance.now()}return c=Math.round(1e6*c),(k(),I)[_>>>3>>>0]=BigInt(c),0}var Yy=[],G1=(c,d)=>{Yy.length=0;for(var _;_=(k(),X)[c++>>>0];){var g=_!=105;d+=(g&=_!=112)&&d%8?4:0,Yy.push(_==112?(k(),C)[d>>>2>>>0]:_==106?(k(),I)[d>>>3>>>0]:_==105?(k(),U)[d>>>2>>>0]:(k(),ae)[d>>>3>>>0]),d+=g?8:4}return Yy};function gT(c,d,_){return c>>>=0,d=G1(d>>>0,_>>>0),p0[c](...d)}function wT(c,d,_){return c>>>=0,d=G1(d>>>0,_>>>0),p0[c](...d)}var xT=()=>{};function yT(c,d){return T(gn(c>>>0,d>>>0))}var bT=()=>{throw be+=1,"unwind"};function vT(){return 4294901760}var kT=()=>1,ET=()=>navigator.hardwareConcurrency;function AT(c){c>>>=0;var d=(k(),X).length;if(c<=d||4294901760<c)return!1;for(var _=1;4>=_;_*=2){var g=d*(1+.2/_);g=Math.min(g,c+100663296);e:{g=(Math.min(4294901760,65536*Math.ceil(Math.max(c,g)/65536))-Wr.buffer.byteLength+65535)/65536|0;try{Wr.grow(g),de();var b=1;break e}catch{}b=void 0}if(b)return!0}return!1}var lr=c=>{var d=xr(c)+1,_=vu(d);return wr(c,_,d),_},Qy=(c,d)=>{(k(),C)[c>>>2>>>0]=d;var _=(k(),C)[c>>>2>>>0];(k(),C)[c+4>>>2>>>0]=(d-_)/4294967296},Ui=c=>(k(),C)[c>>>2>>>0]+4294967296*(k(),U)[c+4>>>2>>>0],dt=[],MT=(c,d)=>{dt[c>>>0]=d},yr=[],xu=[],xn=(c,d)=>{xu[c]=new Promise(_=>d.finally(()=>_(c)))},te=c=>{if(c)return dt[c>>>0]},TT=(c,d)=>{for(c=(k(),C)[c>>>2>>>0];c;c=(k(),C)[c>>>2>>>0])d[(k(),U)[c+4>>>2>>>0]](c)},yu=(c,d,_)=>{(k(),C)[c>>>2>>>0]=d,(k(),C)[c+4>>>2>>>0]=_},q1=c=>{var d=(k(),C)[c>>>2>>>0];return c=(k(),C)[c+4>>>2>>>0],gn(d,c)},br=c=>{var d=(k(),C)[c>>>2>>>0];return c=(k(),C)[c+4>>>2>>>0],d?gn(d,c):c===0?"":void 0},ST=c=>{var d=br(c+4),_=(_=(k(),C)[c+12>>>2>>>0])?te(_):"auto";if(c+=16){var g=te((k(),C)[c+4>>>2>>>0]),b=(k(),C)[c+16>>>2>>>0],M=(k(),C)[c+20>>>2>>>0];if(b){for(var O={},z=0;z<b;++z){var B=M+24*z;O[q1(B+4)]=(k(),ae)[B+16>>>3>>>0]}b=O}else b=void 0;c={module:g,constants:b,entryPoint:br(c+8)}}else c=void 0;return{label:d,layout:_,compute:c}},W1=(c,d)=>{function _(g,b){g=c[g],(k(),C)[d+b>>>2>>>0]=g}_("maxTextureDimension1D",4),_("maxTextureDimension2D",8),_("maxTextureDimension3D",12),_("maxTextureArrayLayers",16),_("maxBindGroups",20),_("maxBindGroupsPlusVertexBuffers",24),_("maxBindingsPerBindGroup",28),_("maxDynamicUniformBuffersPerPipelineLayout",32),_("maxDynamicStorageBuffersPerPipelineLayout",36),_("maxSampledTexturesPerShaderStage",40),_("maxSamplersPerShaderStage",44),_("maxStorageBuffersPerShaderStage",48),_("maxStorageTexturesPerShaderStage",52),_("maxUniformBuffersPerShaderStage",56),_("minUniformBufferOffsetAlignment",80),_("minStorageBufferOffsetAlignment",84),Qy(d+64,c.maxUniformBufferBindingSize),Qy(d+72,c.maxStorageBufferBindingSize),_("maxVertexBuffers",88),Qy(d+96,c.maxBufferSize),_("maxVertexAttributes",104),_("maxVertexBufferArrayStride",108),_("maxInterStageShaderVariables",112),_("maxColorAttachments",116),_("maxColorAttachmentBytesPerSample",120),_("maxComputeWorkgroupStorageSize",124),_("maxComputeInvocationsPerWorkgroup",128),_("maxComputeWorkgroupSizeX",132),_("maxComputeWorkgroupSizeY",136),_("maxComputeWorkgroupSizeZ",140),_("maxComputeWorkgroupsPerDimension",144),c.Ae!==void 0&&_("maxImmediateSize",148)},OT=[,"validation","out-of-memory","internal"],IT=[,"compatibility","core"],V1={1:"core-features-and-limits",2:"depth-clip-control",3:"depth32float-stencil8",4:"texture-compression-bc",5:"texture-compression-bc-sliced-3d",6:"texture-compression-etc2",7:"texture-compression-astc",8:"texture-compression-astc-sliced-3d",9:"timestamp-query",10:"indirect-first-instance",11:"shader-f16",12:"rg11b10ufloat-renderable",13:"bgra8unorm-storage",14:"float32-filterable",15:"float32-blendable",16:"clip-distances",17:"dual-source-blending",18:"subgroups",19:"texture-formats-tier1",20:"texture-formats-tier2",21:"primitive-index",22:"texture-component-swizzle",327692:"chromium-experimental-unorm16-texture-formats",327729:"chromium-experimental-multi-draw-indirect"},CT=[,"low-power","high-performance"],PT=[,"occlusion","timestamp"],LT={undefined:1,unknown:1,destroyed:2};function NT(c,d,_,g,b,M){d=xt(d),_=xt(_),g>>>=0,b>>>=0,M>>>=0;var O=te(c>>>0);if(c={},M){var z=(k(),C)[M+12>>>2>>>0];if(z){var B=(k(),C)[M+16>>>2>>>0];c.requiredFeatures=Array.from((k(),C).subarray(B>>>2>>>0,B+4*z>>>2>>>0),re=>V1[re])}var Q=(k(),C)[M+20>>>2>>>0];if(Q){let re=function(bt,ct,ks=!1){ct=Q+ct,(ct=(k(),C)[ct>>>2>>>0])==4294967295||ks&&ct==0||(Be[bt]=ct)},lt=function(bt,ct){ct=Q+ct;var ks=(k(),C)[ct>>>2>>>0],oO=(k(),C)[ct+4>>>2>>>0];ks==4294967295&&oO==4294967295||(Be[bt]=Ui(ct))};var Te=re,Ne=lt,Be={};re("maxTextureDimension1D",4),re("maxTextureDimension2D",8),re("maxTextureDimension3D",12),re("maxTextureArrayLayers",16),re("maxBindGroups",20),re("maxBindGroupsPlusVertexBuffers",24),re("maxDynamicUniformBuffersPerPipelineLayout",32),re("maxDynamicStorageBuffersPerPipelineLayout",36),re("maxSampledTexturesPerShaderStage",40),re("maxSamplersPerShaderStage",44),re("maxStorageBuffersPerShaderStage",48),re("maxStorageTexturesPerShaderStage",52),re("maxUniformBuffersPerShaderStage",56),re("minUniformBufferOffsetAlignment",80),re("minStorageBufferOffsetAlignment",84),lt("maxUniformBufferBindingSize",64),lt("maxStorageBufferBindingSize",72),re("maxVertexBuffers",88),lt("maxBufferSize",96),re("maxVertexAttributes",104),re("maxVertexBufferArrayStride",108),re("maxInterStageShaderVariables",112),re("maxColorAttachments",116),re("maxColorAttachmentBytesPerSample",120),re("maxComputeWorkgroupStorageSize",124),re("maxComputeInvocationsPerWorkgroup",128),re("maxComputeWorkgroupSizeX",132),re("maxComputeWorkgroupSizeY",136),re("maxComputeWorkgroupSizeZ",140),re("maxComputeWorkgroupsPerDimension",144),re("maxImmediateSize",148,!0),c.requiredLimits=Be}(z=(k(),C)[M+24>>>2>>>0])&&(z={label:br(z+4)},c.defaultQueue=z),c.label=br(M+4)}be+=1,xn(d,O.requestDevice(c).then(re=>{--be,yt(()=>{dt[b>>>0]=re.queue,dt[g>>>0]=re,xn(_,re.lost.then(lt=>{yt(()=>{re.onuncapturederror=()=>{};var bt=le(),ct=lr(lt.message);r0(_,LT[lt.reason],ct),ie(bt)})})),re.onuncapturederror=lt=>{var bt=5;lt.error instanceof GPUValidationError?bt=2:lt.error instanceof GPUOutOfMemoryError?bt=3:lt.error instanceof GPUInternalError&&(bt=4);var ct=le();lt=lr(lt.error.message),fv(g,bt,lt),ie(ct)},"adapterInfo"in re||(re.adapterInfo=O.info),o0(d,1,g,0)})},re=>{--be,yt(()=>{var lt=le(),bt=lr(re.message);o0(d,3,g,bt),_&&r0(_,4,bt),ie(lt)})}))}function zT(c){var d=te(c>>>=0),_=yr[c];if(_){for(var g=0;g<_.length;++g)_[g]();delete yr[c]}d.destroy()}function $T(c,d,_){_>>>=0;var g=te(c>>>=0);_==4294967295&&(_=void 0);try{var b=g.getMappedRange(d>>>0,_)}catch{return 0}var M=l0(16,b.byteLength);return(k(),X).set(new Uint8Array(b),M>>>0),yr[c].push(()=>Kt(M)),M}function RT(c,d,_){_>>>=0;var g=te(c>>>=0);_==4294967295&&(_=void 0);try{var b=g.getMappedRange(d>>>0,_)}catch{return 0}var M=l0(16,b.byteLength);return(k(),X).fill(0,M,b.byteLength),yr[c].push(()=>{new Uint8Array(b).set((k(),X).subarray(M>>>0,M+b.byteLength>>>0)),Kt(M)}),M}function DT(c,d,_,g,b){c>>>=0,d=xt(d),_=xt(_),b>>>=0;var M=te(c);yr[c]=[],b==4294967295&&(b=void 0),be+=1,xn(d,M.mapAsync(_,g>>>0,b).then(()=>{--be,yt(()=>{s0(d,1,0)})},O=>{--be,yt(()=>{le();var z=lr(O.message);s0(d,O.name==="AbortError"?4:O.name==="OperationError"?3:0,z),delete yr[c]})}))}function UT(c){var d=te(c>>>=0),_=yr[c];if(_){for(var g=0;g<_.length;++g)_[g]();delete yr[c],d.unmap()}}function BT(c){delete dt[c>>>0]}function FT(c,d,_){c>>>=0,d>>>=0,_>>>=0;var g=!!(k(),C)[d+32>>>2>>>0];d={label:br(d+4),usage:(k(),C)[d+16>>>2>>>0],size:Ui(d+24),mappedAtCreation:g},c=te(c);try{var b=c.createBuffer(d)}catch{return!1}return dt[_>>>0]=b,g&&(yr[_]=[]),!0}function jT(c,d,_,g){c>>>=0,d=xt(d),g>>>=0,_=ST(_>>>0),c=te(c),be+=1,xn(d,c.createComputePipelineAsync(_).then(b=>{--be,yt(()=>{dt[g>>>0]=b,t0(d,1,g,0)})},b=>{--be,yt(()=>{var M=le(),O=lr(b.message);t0(d,b.reason==="validation"?3:b.reason==="internal"?4:0,g,O),ie(M)})}))}function GT(c,d,_){c>>>=0,d>>>=0,_>>>=0;var g=(k(),C)[d>>>2>>>0],b=(k(),U)[g+4>>>2>>>0];d={label:br(d+4),code:""},b===2&&(d.code=q1(g+8)),c=te(c).createShaderModule(d),dt[_>>>0]=c}var qT=c=>{(c=te(c)).onuncapturederror=null,c.destroy()};function WT(c,d){d=xt(d),c=te(c>>>0),be+=1,xn(d,c.popErrorScope().then(_=>{--be,yt(()=>{var g=5;_?_ instanceof GPUValidationError?g=2:_ instanceof GPUOutOfMemoryError?g=3:_ instanceof GPUInternalError&&(g=4):g=1;var b=le(),M=_?lr(_.message):0;n0(d,1,g,M),ie(b)})},_=>{--be,yt(()=>{var g=le(),b=lr(_.message);n0(d,1,5,b),ie(g)})}))}function VT(c,d,_,g){if(d=xt(d),g>>>=0,_>>>=0){var b={featureLevel:IT[(k(),U)[_+4>>>2>>>0]],powerPreference:CT[(k(),U)[_+8>>>2>>>0]],forceFallbackAdapter:!!(k(),C)[_+12>>>2>>>0]};(c=(k(),C)[_>>>2>>>0])!==0&&(k(),b.Fe=!!(k(),C)[c+8>>>2>>>0])}"gpu"in navigator?(be+=1,xn(d,navigator.gpu.requestAdapter(b).then(M=>{--be,yt(()=>{if(M)dt[g>>>0]=M,Bi(d,1,g,0);else{var O=le(),z=lr("WebGPU not available on this browser (requestAdapter returned null)");Bi(d,3,g,z),ie(O)}})},M=>{--be,yt(()=>{var O=le(),z=lr(M.message);Bi(d,4,g,z),ie(O)})}))):(b=le(),c=lr("WebGPU not available on this browser (navigator.gpu is not available)"),Bi(d,3,g,c),ie(b))}function HT(c,d,_){return c>>>=0,d>>>=0,_>>>=0,z1(async()=>{var g=[];if(_){var b=(k(),U)[_>>>2>>>0];g.length=d+1,g[d]=new Promise(z=>setTimeout(z,b,0))}else g.length=d;for(var M=0;M<d;++M){var O=Ui(c+8*M);if(!(O in xu))return O;g[M]=xu[O]}return g=await Promise.race(g),delete xu[g],g})}var Jy,Zy={},H1=()=>{if(!Jy){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 Zy)Zy[c]===void 0?delete d[c]:d[c]=Zy[c];var _=[];for(c in d)_.push(`${c}=${d[c]}`);Jy=_}return Jy};function X1(c,d){if(n)return De(19,1,c,d);c>>>=0,d>>>=0;var _,g=0,b=0;for(_ of H1()){var M=d+g;(k(),C)[c+b>>>2>>>0]=M,g+=wr(_,M,1/0)+1,b+=4}return 0}function K1(c,d){if(n)return De(20,1,c,d);c>>>=0,d>>>=0;var _=H1();for(var g of((k(),C)[c>>>2>>>0]=_.length,c=0,_))c+=xr(g)+1;return(k(),C)[d>>>2>>>0]=c,0}function Y1(c){return n?De(21,1,c):52}function Q1(c,d,_,g){return n?De(22,1,c,d,_,g):52}function J1(c,d,_,g){return n?De(23,1,c,d,_,g):70}var XT=[null,[],[]];function Z1(c,d,_,g){if(n)return De(24,1,c,d,_,g);d>>>=0,_>>>=0,g>>>=0;for(var b=0,M=0;M<_;M++){var O=(k(),C)[d>>>2>>>0],z=(k(),C)[d+4>>>2>>>0];d+=8;for(var B=0;B<z;B++){var Q=c,Te=(k(),X)[O+B>>>0],Ne=XT[Q];Te===0||Te===10?((Q===1?S:T)(h1(Ne)),Ne.length=0):Ne.push(Te)}b+=z}return(k(),C)[g>>>2>>>0]=b,0}function KT(c){return c>>>0}function YT(c,d){return W1(te(c>>>0).limits,d>>>0),1}function QT(c,d){return te(c>>>0).features.has(V1[d])}function JT(c){return BigInt(te(c>>>0).size)}function ZT(c){return BigInt(te(c>>>0).usage)}function eS(c,d){if(c>>>=0,d>>>=0){var _=br(d+4);_={label:_,timestampWrites:d=(d=(k(),C)[d+12>>>2>>>0])!==0?{querySet:te((k(),C)[d+4>>>2>>>0]),beginningOfPassWriteIndex:(k(),C)[d+8>>>2>>>0],endOfPassWriteIndex:(k(),C)[d+12>>>2>>>0]}:void 0}}return d=te(c),c=lv(0),_=d.beginComputePass(_),dt[c>>>0]=_,c}function tS(c,d,_,g,b,M){_=xt(_),b=xt(b),M=xt(M),te(c>>>0).copyBufferToBuffer(te(d>>>0),_,te(g>>>0),b,M)}function rS(c){var d=te(c>>>0);return c=av(0),d=d.finish(),dt[c>>>0]=d,c}function sS(c,d,_,g,b,M){M=xt(M),te(c>>>0).resolveQuerySet(te(d>>>0),_,g,te(b>>>0),M)}function nS(c,d,_,g){te(c>>>0).dispatchWorkgroups(d,_,g)}function oS(c,d,_){_=xt(_),te(c>>>0).dispatchWorkgroupsIndirect(te(d>>>0),_)}function aS(c){te(c>>>0).end()}function iS(c,d,_,g,b){g>>>=0,b>>>=0,c=te(c>>>0),_=te(_>>>0),g==0?c.setBindGroup(d,_):c.setBindGroup(d,_,(k(),C),b>>>2,g)}function lS(c,d){te(c>>>0).setPipeline(te(d>>>0))}function cS(c,d,_){te(c>>>0).Ee(te(d>>>0),_)}function uS(c,d){var _=te(c>>>0);return c=ov(0),d=_.getBindGroupLayout(d),dt[c>>>0]=d,c}function pS(c,d){function _(b){var M=(k(),C)[b+8>>>2>>>0],O=(k(),C)[b+32>>>2>>>0],z=(k(),C)[b+36>>>2>>>0],B=0;return TT(b,{327681:Q=>{B=(k(),C)[Q+8>>>2>>>0]}}),M?((O=Ui(b+24))==-1&&(O=void 0),M={buffer:te(M),offset:Ui(b+16),size:O}):M=te(O||z||B),{binding:(k(),C)[b+4>>>2>>>0],resource:M}}c>>>=0,d={label:br(4+(d>>>=0)),layout:te((k(),C)[d+12>>>2>>>0]),entries:(function(b,M){for(var O=[],z=0;z<b;++z)O.push(_(M+40*z));return O})((k(),C)[d+16>>>2>>>0],(k(),C)[d+20>>>2>>>0])},c=te(c);var g=nv(0);return MT(g,c.createBindGroup(d)),g}function dS(c,d){var _;return c>>>=0,(d>>>=0)&&(_={label:br(d+4)}),d=te(c),c=iv(0),_=d.createCommandEncoder(_),dt[c>>>0]=_,c}function fS(c,d){c>>>=0,d>>>=0,d={type:PT[(k(),U)[d+12>>>2>>>0]],count:(k(),C)[d+16>>>2>>>0]};var _=te(c);return c=cv(0),d=_.createQuerySet(d),dt[c>>>0]=d,c}function mS(c,d){c=te(c>>>0).adapterInfo,d>>>=0,(k(),C)[d+52>>>2>>>0]=c.subgroupMinSize,(k(),C)[d+56>>>2>>>0]=c.subgroupMaxSize;var _=c.vendor+c.architecture+c.device+c.description,g=xr(_)+1,b=yn(g);return b&&wr(_,b,g),_=b,g=xr(c.vendor),yu(d+4,_,g),_+=g,g=xr(c.architecture),yu(d+12,_,g),_+=g,g=xr(c.device),yu(d+20,_,g),yu(d+28,_+g,xr(c.description)),(k(),U)[d+36>>>2>>>0]=2,c=c.isFallbackAdapter?3:4,(k(),U)[d+40>>>2>>>0]=c,(k(),C)[d+44>>>2>>>0]=0,(k(),C)[d+48>>>2>>>0]=0,1}var hS={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729};function _S(c,d){d>>>=0;var _=te(c>>>0);c=yn(4*_.features.size);var g=0,b=0;for(let M of _.features)0<=(_=hS[M])&&((k(),U)[c+g>>>2>>>0]=_,g+=4,b++);(k(),C)[d+4>>>2>>>0]=c,(k(),C)[d>>>2>>>0]=b}function gS(c,d){return W1(te(c>>>0).limits,d>>>0),1}function wS(c,d){te(c>>>0).pushErrorScope(OT[d])}function xS(c,d,_){d>>>=0,_>>>=0,c=te(c>>>0),d=Array.from((k(),U).subarray(_>>>2>>>0,_+4*d>>>2>>>0),g=>te(g)),c.submit(d)}function yS(c,d,_,g,b){_=xt(_),g>>>=0,b>>>=0,c=te(c>>>0),d=te(d>>>0),g=(k(),X).subarray(g>>>0,g+b>>>0),c.writeBuffer(d,_,g,0,b)}n||(function(){for(var c=e.numThreads-1;c--;)l1();Me.push(async()=>{var d=(async function(){if(!n)return Promise.all(rt.map(i1))})();xe++,await d,--xe==0&&We&&(d=We,We=null,d())})})(),n||(Wr=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),de()),e.wasmBinary&&(f=e.wasmBinary),e.stackSave=()=>le(),e.stackRestore=c=>ie(c),e.stackAlloc=c=>vu(c),e.setValue=function(c,d,_="i8"){switch(_.endsWith("*")&&(_="*"),_){case"i1":case"i8":(k(),W)[c>>>0]=d;break;case"i16":(k(),H)[c>>>1>>>0]=d;break;case"i32":(k(),U)[c>>>2>>>0]=d;break;case"i64":(k(),I)[c>>>3>>>0]=BigInt(d);break;case"float":(k(),ne)[c>>>2>>>0]=d;break;case"double":(k(),ae)[c>>>3>>>0]=d;break;case"*":(k(),C)[c>>>2>>>0]=d;break;default:Le(`invalid type for setValue: ${_}`)}},e.getValue=function(c,d="i8"){switch(d.endsWith("*")&&(d="*"),d){case"i1":case"i8":return(k(),W)[c>>>0];case"i16":return(k(),H)[c>>>1>>>0];case"i32":return(k(),U)[c>>>2>>>0];case"i64":return(k(),I)[c>>>3>>>0];case"float":return(k(),ne)[c>>>2>>>0];case"double":return(k(),ae)[c>>>3>>>0];case"*":return(k(),C)[c>>>2>>>0];default:Le(`invalid type for getValue: ${d}`)}},e.UTF8ToString=gn,e.stringToUTF8=wr,e.lengthBytesUTF8=xr;var ev,tv,e0,bu,Kt,yn,rv,sv,nv,ov,av,iv,lv,cv,uv,pv,dv,t0,r0,s0,n0,Bi,o0,fv,a0,mv,hv,_v,i0,gv,wv,l0,ge,Fi,xv,ie,vu,le,yv,c0,bv,vv,kv,u0,Ev,Av,Mv,Tv,Sv,Ov,Iv,Cv,Pv,Lv,Nv,zv,$v,Rv,Dv,Uv,Bv,Fv,jv,Gv,qv,Wv,Vv,Hv,Xv,Kv,Yv,Qv,Jv,Zv,ek,tk,rk,sk,nk,ok,ak,ik,lk,vr,bS=[qr,ys,p1,_1,g1,w1,x1,y1,b1,v1,k1,E1,A1,M1,T1,S1,B1,F1,j1,X1,K1,Y1,Q1,J1,Z1],p0={923180:(c,d,_,g,b)=>{if(e===void 0||!e.Uc)return 1;if((c=gn(Number(c>>>0))).startsWith("./")&&(c=c.substring(2)),!(c=e.Uc.get(c)))return 2;if(d=Number(d>>>0),_=Number(_>>>0),g=Number(g>>>0),d+_>c.byteLength)return 3;try{let M=c.subarray(d,d+_);switch(b){case 0:(k(),X).set(M,g>>>0);break;case 1:e.ad?e.ad(g,M):e.oe(g,M);break;default:return 4}return 0}catch{return 4}},924004:(c,d,_)=>{e.Sd(c,(k(),X).subarray(d>>>0,d+_>>>0))},924068:()=>e.me(),924110:c=>{e.jd(c)},924147:()=>typeof wasmOffsetConverter<"u"};function vS(c,d,_,g){var b=le();try{return Cv(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function kS(c,d,_){var g=le();try{return Sv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;ge(1,0)}}function ES(c,d,_){var g=le();try{kv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;ge(1,0)}}function AS(c,d){var _=le();try{return u0(c,d)}catch(g){if(ie(_),g!==g+0)throw g;ge(1,0)}}function MS(c){var d=le();try{Ev(c)}catch(_){if(ie(d),_!==_+0)throw _;ge(1,0)}}function TS(c,d,_,g,b,M,O){var z=le();try{return Tv(c,d,_,g,b,M,O)}catch(B){if(ie(z),B!==B+0)throw B;ge(1,0)}}function SS(c,d){var _=le();try{Pv(c,d)}catch(g){if(ie(_),g!==g+0)throw g;ge(1,0)}}function OS(c,d,_,g,b,M){var O=le();try{Av(c,d,_,g,b,M)}catch(z){if(ie(O),z!==z+0)throw z;ge(1,0)}}function IS(c,d,_,g){var b=le();try{Iv(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function CS(c,d,_,g,b,M,O){var z=le();try{Nv(c,d,_,g,b,M,O)}catch(B){if(ie(z),B!==B+0)throw B;ge(1,0)}}function PS(c,d,_,g,b,M,O){var z=le();try{zv(c,d,_,g,b,M,O)}catch(B){if(ie(z),B!==B+0)throw B;ge(1,0)}}function LS(c,d,_,g,b,M,O,z){var B=le();try{qv(c,d,_,g,b,M,O,z)}catch(Q){if(ie(B),Q!==Q+0)throw Q;ge(1,0)}}function NS(c,d,_,g,b,M,O,z,B,Q,Te,Ne){var Be=le();try{$v(c,d,_,g,b,M,O,z,B,Q,Te,Ne)}catch(re){if(ie(Be),re!==re+0)throw re;ge(1,0)}}function zS(c,d,_,g,b){var M=le();try{return Lv(c,d,_,g,b)}catch(O){if(ie(M),O!==O+0)throw O;ge(1,0)}}function $S(c,d,_,g,b){var M=le();try{Mv(c,d,_,g,b)}catch(O){if(ie(M),O!==O+0)throw O;ge(1,0)}}function RS(c,d,_,g,b,M,O,z){var B=le();try{Ov(c,d,_,g,b,M,O,z)}catch(Q){if(ie(B),Q!==Q+0)throw Q;ge(1,0)}}function DS(c){var d=le();try{return Wv(c)}catch(_){if(ie(d),_!==_+0)throw _;ge(1,0)}}function US(c,d,_){var g=le();try{return Vv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;ge(1,0)}}function BS(c,d){var _=le();try{return nk(c,d)}catch(g){if(ie(_),g!==g+0)throw g;return ge(1,0),0n}}function FS(c,d,_,g,b){var M=le();try{Hv(c,d,_,g,b)}catch(O){if(ie(M),O!==O+0)throw O;ge(1,0)}}function jS(c){var d=le();try{return Rv(c)}catch(_){if(ie(d),_!==_+0)throw _;return ge(1,0),0n}}function GS(c,d,_,g,b,M){var O=le();try{return jv(c,d,_,g,b,M)}catch(z){if(ie(O),z!==z+0)throw z;ge(1,0)}}function qS(c,d,_,g,b,M){var O=le();try{return Xv(c,d,_,g,b,M)}catch(z){if(ie(O),z!==z+0)throw z;ge(1,0)}}function WS(c,d,_,g,b,M){var O=le();try{return Kv(c,d,_,g,b,M)}catch(z){if(ie(O),z!==z+0)throw z;ge(1,0)}}function VS(c,d,_,g,b,M,O,z){var B=le();try{return Gv(c,d,_,g,b,M,O,z)}catch(Q){if(ie(B),Q!==Q+0)throw Q;ge(1,0)}}function HS(c,d,_,g,b){var M=le();try{return Yv(c,d,_,g,b)}catch(O){if(ie(M),O!==O+0)throw O;return ge(1,0),0n}}function XS(c,d,_,g){var b=le();try{return Qv(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function KS(c,d,_,g){var b=le();try{return Jv(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function YS(c,d,_,g,b,M,O,z,B,Q,Te,Ne){var Be=le();try{return Zv(c,d,_,g,b,M,O,z,B,Q,Te,Ne)}catch(re){if(ie(Be),re!==re+0)throw re;ge(1,0)}}function QS(c,d,_,g,b,M,O,z,B,Q,Te){var Ne=le();try{ek(c,d,_,g,b,M,O,z,B,Q,Te)}catch(Be){if(ie(Ne),Be!==Be+0)throw Be;ge(1,0)}}function JS(c,d,_,g,b,M,O,z,B,Q,Te,Ne,Be,re,lt,bt){var ct=le();try{tk(c,d,_,g,b,M,O,z,B,Q,Te,Ne,Be,re,lt,bt)}catch(ks){if(ie(ct),ks!==ks+0)throw ks;ge(1,0)}}function ZS(c,d,_,g){var b=le();try{return rk(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function eO(c,d,_,g,b){var M=le();try{return sk(c,d,_,g,b)}catch(O){if(ie(M),O!==O+0)throw O;ge(1,0)}}function tO(c,d,_){var g=le();try{return Uv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;return ge(1,0),0n}}function rO(c,d,_){var g=le();try{return Dv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;ge(1,0)}}function sO(c,d,_){var g=le();try{return Bv(c,d,_)}catch(b){if(ie(g),b!==b+0)throw b;ge(1,0)}}function nO(c,d,_,g){var b=le();try{Fv(c,d,_,g)}catch(M){if(ie(b),M!==M+0)throw M;ge(1,0)}}function ku(){if(0<xe)We=ku;else if(n)w?.(e),Fe();else{for(var c=Me;0<c.length;)c.shift()(e);0<xe?We=ku:(e.calledRun=!0,L||(Fe(),w?.(e)))}}return n||(vr=await Je(),ku()),e.PTR_SIZE=4,e.webgpuInit=c=>{let d=new WeakMap,_,g,b=1;e.webgpuRegisterDevice=z=>{if(g!==void 0)throw Error("another WebGPU EP inference session is being created.");if(z){var B=d.get(z);if(!B){let Q=((Te,Ne=0)=>{var Be=dv(Ne);return Ne=pv(Ne,Be),dt[Be>>>0]=Te.queue,dt[Ne>>>0]=Te,Ne})(z,B=sv(0));B=[b++,B,Q],d.set(z,B)}return _=z,g=B[0],B}_=void 0,g=0};let M=new Map;e.webgpuOnCreateSession=z=>{if(g!==void 0){var B=g;if(g=void 0,z){let Q=e0(B);M.set(z,Q),B===0&&c(_??te(Q))}_=void 0}},e.webgpuOnReleaseSession=z=>{M.delete(z)};let O=Symbol("gpuBufferMetadata");e.webgpuRegisterBuffer=(z,B,Q)=>{if(Q)return z[O]=[Q,NaN],Q;if(Q=z[O])return Q[1]++,Q[0];if((B=M.get(B))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return B=((Te,Ne=0)=>(Te.mapState==="unmapped"||Le(),Ne=uv(Ne),dt[Ne>>>0]=Te,Ne))(z,B),z[O]=[B,1],B},e.webgpuUnregisterBuffer=z=>{let B=z[O];if(!B)throw Error("Buffer is not registered");B[1]--,B[1]===0&&(rv(B[0]),delete z[O])},e.webgpuGetBuffer=z=>te(z),e.webgpuCreateDownloader=(z,B,Q)=>{if((Q=M.get(Q))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let Te=te(Q),Ne=16*Math.ceil(Number(B)/16);return async()=>{let Be=Te.createBuffer({size:Ne,usage:9});try{let re=Te.createCommandEncoder();return re.copyBufferToBuffer(z,0,Be,0,Ne),Te.queue.submit([re.finish()]),await Be.mapAsync(GPUMapMode.READ),Be.getMappedRange().slice(0,B)}finally{Be.destroy()}}},e.ad=(z,B)=>{var Q=B.buffer;let Te=B.byteOffset,Ne=B.byteLength;if(B=16*Math.ceil(Number(Ne)/16),z=te(z),!_){var Be=e0(g);_=te(Be)}let re=(Be=_.createBuffer({mappedAtCreation:!0,size:B,usage:6})).getMappedRange();new Uint8Array(re).set(new Uint8Array(Q,Te,Ne)),Be.unmap(),(Q=_.createCommandEncoder()).copyBufferToBuffer(Be,0,z,0,B),_.queue.submit([Q.finish()]),Be.destroy()}},e.webnnInit=c=>{let d=c[0];[e.me,e.jd,e.webnnEnsureTensor,e.Sd,e.webnnDownloadTensor,e.le,e.webnnEnableTraceEvent]=c.slice(1),e.webnnReleaseTensorId=e.jd,e.webnnUploadTensor=e.Sd,e.webnnRegisterMLContext=e.le,e.webnnOnRunStart=_=>d.onRunStart(_),e.webnnOnRunEnd=d.onRunEnd.bind(d),e.webnnOnReleaseSession=_=>{d.onReleaseSession(_)},e.webnnCreateMLTensorDownloader=(_,g)=>d.createMLTensorDownloader(_,g),e.webnnRegisterMLTensor=(_,g,b,M)=>d.registerMLTensor(_,g,b,M),e.webnnCreateMLContext=_=>d.createMLContext(_),e.webnnRegisterMLConstant=(_,g,b,M,O,z)=>d.registerMLConstant(_,g,b,M,O,e.Uc,z),e.webnnRegisterGraphInput=d.registerGraphInput.bind(d),e.webnnIsGraphInput=d.isGraphInput.bind(d),e.webnnRegisterGraphOutput=d.registerGraphOutput.bind(d),e.webnnIsGraphOutput=d.isGraphOutput.bind(d),e.webnnCreateTemporaryTensor=d.createTemporaryTensor.bind(d),e.webnnIsGraphInputOutputTypeSupported=d.isGraphInputOutputTypeSupported.bind(d)},ee?e:new Promise((c,d)=>{w=c,x=d})}var iA,mE,eL=ye(()=>{"use strict";iA=fE,mE=globalThis.self?.name?.startsWith("em-pthread"),mE&&fE()}),N0,Y0,hE,Pt,lA,Du,_E,gE,z0,wE,$0,cA,R0,uA,ob=ye(()=>{"use strict";nb(),N0=typeof location>"u"?void 0:location.origin,Y0=tr.url>"file:"&&tr.url<"file;",hE=()=>{if(Y0){let t=URL;return new URL(new t("ort.webgpu.bundle.min.mjs",tr.url).href,N0).href}return tr.url},Pt=hE(),lA=()=>{if(Pt&&!Pt.startsWith("blob:"))return Pt.substring(0,Pt.lastIndexOf("/")+1)},Du=(t,e)=>{try{let r=e??Pt;return(r?new URL(t,r):new URL(t)).origin===N0}catch{return!1}},_E=(t,e)=>{let r=e??Pt;try{return(r?new URL(t,r):new URL(t)).href}catch{return}},gE=(t,e)=>`${e??"./"}${t}`,z0=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},wE=async t=>(await import(t)).default,$0=(ZP(),qu(nA)).default,cA=async()=>{if(!Pt)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Du(Pt))return[void 0,$0()];let t=await z0(Pt);return[t,$0(t)]},R0=(eL(),qu(aA)).default,uA=async(t,e,r,s)=>{let n=R0&&!(t||e);if(n)if(Pt)n=Du(Pt)||s&&!r;else if(s&&!r)n=!0;else throw new Error("cannot determine the script source URL.");if(n)return[void 0,R0];{let o="ort-wasm-simd-threaded.asyncify.mjs",a=t??_E(o,e),i=r&&a&&!Du(a,e),l=i?await z0(a):a??gE(o,e);return[i?l:void 0,await wE(l)]}}}),D0,Uu,Ji,U0,xE,yE,bE,ab,Ue,Ds=ye(()=>{"use strict";ob(),Uu=!1,Ji=!1,U0=!1,xE=()=>{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}},yE=()=>{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}},bE=()=>{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}},ab=async t=>{if(Uu)return Promise.resolve();if(Ji)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(U0)throw new Error("previous call to 'initializeWebAssembly()' failed.");Ji=!0;let e=t.initTimeout,r=t.numThreads;if(t.simd!==!1){if(t.simd==="relaxed"){if(!bE())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!yE())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let s=xE();r>1&&!s&&(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."),t.numThreads=r=1);let n=t.wasmPaths,o=typeof n=="string"?n:void 0,a=n?.mjs,i=a?.href??a,l=n?.wasm,u=l?.href??l,p=t.wasmBinary,[f,m]=await uA(i,o,r>1,!!p||!!u),h=!1,w=[];if(e>0&&w.push(new Promise(x=>{setTimeout(()=>{h=!0,x()},e)})),w.push(new Promise((x,v)=>{let E={numThreads:r};if(p)E.wasmBinary=p,E.locateFile=A=>A;else if(u||o)E.locateFile=A=>u??o+A;else if(i&&i.indexOf("blob:")!==0)E.locateFile=A=>new URL(A,i).href;else if(f){let A=lA();A&&(E.locateFile=S=>A+S)}m(E).then(A=>{Ji=!1,Uu=!0,D0=A,x(),f&&URL.revokeObjectURL(f)},A=>{Ji=!1,U0=!0,v(A)})})),await Promise.race(w),h)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},Ue=()=>{if(Uu&&D0)return D0;throw new Error("WebAssembly is not initialized yet.")}}),Lt,Vu,Ce,ib=ye(()=>{"use strict";Ds(),Lt=(t,e)=>{let r=Ue(),s=r.lengthBytesUTF8(t)+1,n=r._malloc(s);return r.stringToUTF8(t,n,s),e.push(n),n},Vu=(t,e,r,s)=>{if(typeof t=="object"&&t!==null){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach(([n,o])=>{let a=e?e+n:n;if(typeof o=="object")Vu(o,a+".",r,s);else if(typeof o=="string"||typeof o=="number")s(a,o.toString());else if(typeof o=="boolean")s(a,o?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof o}`)})},Ce=t=>{let e=Ue(),r=e.stackSave();try{let s=e.PTR_SIZE,n=e.stackAlloc(2*s);e._OrtGetLastError(n,n+s);let o=Number(e.getValue(n,s===4?"i32":"i64")),a=e.getValue(n+s,"*"),i=a?e.UTF8ToString(a):"";throw new Error(`${t} ERROR_CODE: ${o}, ERROR_MESSAGE: ${i}`)}finally{e.stackRestore(r)}}}),pA,tL=ye(()=>{"use strict";Ds(),ib(),pA=t=>{let e=Ue(),r=0,s=[],n=t||{};try{if(t?.logSeverityLevel===void 0)n.logSeverityLevel=2;else if(typeof t.logSeverityLevel!="number"||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${t.logSeverityLevel}`);if(t?.logVerbosityLevel===void 0)n.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);t?.terminate===void 0&&(n.terminate=!1);let o=0;return t?.tag!==void 0&&(o=Lt(t.tag,s)),r=e._OrtCreateRunOptions(n.logSeverityLevel,n.logVerbosityLevel,!!n.terminate,o),r===0&&Ce("Can't create run options."),t?.extra!==void 0&&Vu(t.extra,"",new WeakSet,(a,i)=>{let l=Lt(a,s),u=Lt(i,s);e._OrtAddRunConfigEntry(r,l,u)!==0&&Ce(`Can't set a run config entry: ${a} - ${i}.`)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseRunOptions(r),s.forEach(a=>e._free(a)),o}}}),vE,kE,EE,Bu,es,AE,dA,rL=ye(()=>{"use strict";Ds(),ib(),vE=t=>{switch(t){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: ${t}`)}},kE=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},EE=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(r=>(typeof r=="string"?r:r.name)==="webgpu")&&(t.enableMemPattern=!1)},Bu=(t,e,r,s)=>{let n=Lt(e,s),o=Lt(r,s);Ue()._OrtAddSessionConfigEntry(t,n,o)!==0&&Ce(`Can't set a session config entry: ${e} - ${r}.`)},es=(t,e,r,s)=>{let n=Lt(e,s),o=Lt(r,s);t.push([n,o])},AE=async(t,e,r)=>{let s=e.executionProviders;for(let n of s){let o=typeof n=="string"?n:n.name,a=[];switch(o){case"webnn":if(o="WEBNN",typeof n!="string"){let f=n?.deviceType;f&&Bu(t,"deviceType",f,r)}break;case"webgpu":{o="WebGPU";let f;if(typeof n!="string"){let h=n;if(h.device)if(typeof GPUDevice<"u"&&h.device instanceof GPUDevice)f=h.device;else throw new Error("Invalid GPU device set in WebGPU EP options.");let{enableGraphCapture:w}=e;if(typeof w=="boolean"&&w&&es(a,"enableGraphCapture","1",r),typeof h.preferredLayout=="string"&&es(a,"preferredLayout",h.preferredLayout,r),h.forceCpuNodeNames){let x=Array.isArray(h.forceCpuNodeNames)?h.forceCpuNodeNames:[h.forceCpuNodeNames];es(a,"forceCpuNodeNames",x.join(`
|
|
13
|
-
`),r)}h.validationMode&&es(a,"validationMode",h.validationMode,r)}let m=Ue().webgpuRegisterDevice(f);if(m){let[h,w,x]=m;es(a,"deviceId",h.toString(),r),es(a,"webgpuInstance",w.toString(),r),es(a,"webgpuDevice",x.toString(),r)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${o}`)}let i=Lt(o,r),l=a.length,u=0,p=0;if(l>0){u=Ue()._malloc(l*Ue().PTR_SIZE),r.push(u),p=Ue()._malloc(l*Ue().PTR_SIZE),r.push(p);for(let f=0;f<l;f++)Ue().setValue(u+f*Ue().PTR_SIZE,a[f][0],"*"),Ue().setValue(p+f*Ue().PTR_SIZE,a[f][1],"*")}await Ue()._OrtAppendExecutionProvider(t,i,u,p,l)!==0&&Ce(`Can't append execution provider: ${o}.`)}},dA=async t=>{let e=Ue(),r=0,s=[],n=t||{};EE(n);try{let o=vE(n.graphOptimizationLevel??"all"),a=kE(n.executionMode??"sequential"),i=typeof n.logId=="string"?Lt(n.logId,s):0,l=n.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let u=n.logVerbosityLevel??0;if(!Number.isInteger(u)||u<0||u>4)throw new Error(`log verbosity level is not valid: ${u}`);let p=typeof n.optimizedModelFilePath=="string"?Lt(n.optimizedModelFilePath,s):0;if(r=e._OrtCreateSessionOptions(o,!!n.enableCpuMemArena,!!n.enableMemPattern,a,!!n.enableProfiling,0,i,l,u,p),r===0&&Ce("Can't create session options."),n.executionProviders&&await AE(r,n,s),n.enableGraphCapture!==void 0){if(typeof n.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${n.enableGraphCapture}`);Bu(r,"enableGraphCapture",n.enableGraphCapture.toString(),s)}if(n.freeDimensionOverrides)for(let[f,m]of Object.entries(n.freeDimensionOverrides)){if(typeof f!="string")throw new Error(`free dimension override name must be a string: ${f}`);if(typeof m!="number"||!Number.isInteger(m)||m<0)throw new Error(`free dimension override value must be a non-negative integer: ${m}`);let h=Lt(f,s);e._OrtAddFreeDimensionOverride(r,h,m)!==0&&Ce(`Can't set a free dimension override: ${f} - ${m}.`)}return n.extra!==void 0&&Vu(n.extra,"",new WeakSet,(f,m)=>{Bu(r,f,m,s)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseSessionOptions(r)!==0&&Ce("Can't release session options."),s.forEach(a=>e._free(a)),o}}}),Ls,Gu,On,sl,Hu,lb,cb,Q0,In=ye(()=>{"use strict";Ls=t=>{switch(t){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: ${t}`)}},Gu=t=>{switch(t){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: ${t}`)}},On=(t,e)=>{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][t],s=typeof e=="number"?e:e.reduce((n,o)=>n*o,1);return r>0?Math.ceil(s*r):void 0},sl=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}},Hu=t=>{switch(t){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: ${t}`)}},lb=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",cb=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",Q0=t=>{switch(t){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: ${t}`)}}}),ub,fA=ye(()=>{"use strict";nb(),ub=async t=>{if(typeof t=="string"){let e=await fetch(t);if(!e.ok)throw new Error(`failed to load external data file: ${t}`);let r=e.headers.get("Content-Length"),s=r?parseInt(r,10):0;if(s<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let n=e.body.getReader(),o;try{o=new ArrayBuffer(s)}catch(i){if(i instanceof RangeError){let l=Math.ceil(s/65536);o=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw i}let a=0;for(;;){let{done:i,value:l}=await n.read();if(i)break;let u=l.byteLength;new Uint8Array(o,a,u).set(l),a+=u}return new Uint8Array(o,0,s)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),mA,sL=ye(()=>{"use strict";In(),mA=(t,e)=>new(sl(e))(t)}),ME,TE,SE,OE,hA,IE,gt,_A=ye(()=>{"use strict";In(),ME=["V","I","W","E","F"],TE=(t,e)=>{console.log(`[${ME[t]},${new Date().toISOString()}]${e}`)},hA=(t,e)=>{SE=t,OE=e},IE=(t,e)=>{let r=Hu(t),s=Hu(SE);r>=s&&TE(r,typeof e=="function"?e():e)},gt=(...t)=>{OE&&IE(...t)}}),B0,J0,F0,CE,j0,PE,G0,q0,W0,LE,gA,nL=ye(()=>{"use strict";In(),_A(),B0=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),J0=(t,e)=>{if(e==="int32")return t;let r=B0.get(e);if(!r)throw new Error(`WebNN backend does not support data type: ${e}`);let s=r/8;if(t.byteLength%s!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${s}.`);let n=t.byteLength/s,o=new(sl(e))(t.buffer,t.byteOffset,n);switch(e){case"int64":case"uint64":{let a=new Int32Array(n);for(let i=0;i<n;i++){let l=o[i];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");a[i]=Number(l)}return new Uint8Array(a.buffer)}case"int8":case"uint8":case"uint32":{if(e==="uint32"&&o.some(i=>i>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let a=Int32Array.from(o,Number);return new Uint8Array(a.buffer)}default:throw new Error(`Unsupported data conversion from ${e} to 'int32'`)}},F0=(t,e)=>{if(e==="int32")return t;if(t.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let r=t.byteLength/4,s=new Int32Array(t.buffer,t.byteOffset,r);switch(e){case"int64":{let n=BigInt64Array.from(s,BigInt);return new Uint8Array(n.buffer)}case"uint64":{if(s.some(o=>o<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let n=BigUint64Array.from(s,BigInt);return new Uint8Array(n.buffer)}case"int8":{if(s.some(o=>o<-128||o>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let n=Int8Array.from(s,Number);return new Uint8Array(n.buffer)}case"uint8":{if(s.some(n=>n<0||n>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(s,Number)}case"uint32":{if(s.some(o=>o<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let n=Uint32Array.from(s,Number);return new Uint8Array(n.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${e}`)}},CE=1,j0=()=>CE++,PE=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),G0=(t,e)=>{let r=B0.get(t);if(!r)throw new Error(`WebNN backend does not support data type: ${t}`);return e.length>0?Math.ceil(e.reduce((s,n)=>s*n)*r/8):0},q0=class{constructor(t){this.isDataConverted=!1;let{sessionId:e,context:r,tensor:s,dataType:n,shape:o,fallbackDataType:a}=t;this.sessionId=e,this.mlContext=r,this.mlTensor=s,this.dataType=n,this.tensorShape=o,this.fallbackDataType=a}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return G0(this.dataType,this.tensorShape)}destroy(){gt("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(t){this.mlContext.writeTensor(this.mlTensor,t)}async read(t){if(this.fallbackDataType){let e=await this.mlContext.readTensor(this.mlTensor),r=F0(new Uint8Array(e),this.dataType);if(t){(t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)).set(r);return}else return r.buffer}else return t?this.mlContext.readTensor(this.mlTensor,t):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(t,e,r){return this.mlContext===t&&this.dataType===e&&this.tensorShape.length===r.length&&this.tensorShape.every((s,n)=>s===r[n])}setIsDataConverted(t){this.isDataConverted=t}},W0=class{constructor(t,e){this.tensorManager=t,this.wrapper=e}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(t,e,r,s){let n=this.tensorManager.getMLContext(t),o=this.tensorManager.getMLOpSupportLimits(t),a;if(!o?.input.dataTypes.includes(e)){if(a=PE.get(e),!a||o?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);gt("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${e} to ${a}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(n,e,r))return this.wrapper.tensor;if(s){if(this.wrapper.byteLength!==G0(e,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(t,e,r,i,!0,!0,a),s&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(t){let e=t;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")e=J0(t,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(t.byteLength===this.wrapper.byteLength){this.wrapper.write(e);return}else gt("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(e):this.activeUpload=new Uint8Array(e)}async download(t){if(this.activeUpload){let e=this.wrapper?.isDataConverted?F0(this.activeUpload,this.wrapper?.type):this.activeUpload;if(t){t instanceof ArrayBuffer?new Uint8Array(t).set(e):new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(e);return}else return e.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return t?this.wrapper.read(t):this.wrapper.read()}},LE=class{constructor(t){this.backend=t,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(t){let e=this.backend.getMLContext(t);if(!e)throw new Error("MLContext not found for session.");return e}getMLOpSupportLimits(t){return this.backend.getMLOpSupportLimits(t)}reserveTensorId(){let t=j0();return this.tensorTrackersById.set(t,new W0(this)),t}releaseTensorId(t){let e=this.tensorTrackersById.get(t);e&&(this.tensorTrackersById.delete(t),e.tensorWrapper&&this.releaseTensor(e.tensorWrapper))}async ensureTensor(t,e,r,s,n){gt("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${e}, dataType: ${r}, shape: ${s}, copyOld: ${n}}`);let o=this.tensorTrackersById.get(e);if(!o)throw new Error("Tensor not found.");return o.ensureTensor(t,r,s,n)}upload(t,e){let r=this.tensorTrackersById.get(t);if(!r)throw new Error("Tensor not found.");r.upload(e)}async download(t,e){gt("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${t}, dstBuffer: ${e?.byteLength}}`);let r=this.tensorTrackersById.get(t);if(!r)throw new Error("Tensor not found.");return r.download(e)}releaseTensorsForSession(t){for(let e of this.freeTensors)e.sessionId===t&&e.destroy();this.freeTensors=this.freeTensors.filter(e=>e.sessionId!==t)}registerTensor(t,e,r,s){let n=this.getMLContext(t),o=j0(),a=new q0({sessionId:t,context:n,tensor:e,dataType:r,shape:s});return this.tensorTrackersById.set(o,new W0(this,a)),this.externalTensors.add(a),o}async getCachedTensor(t,e,r,s,n,o,a){let i=this.getMLContext(t);for(let[u,p]of this.freeTensors.entries())if(p.canReuseTensor(i,e,r)){gt("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}`);let f=this.freeTensors.splice(u,1)[0];return f.sessionId=t,f}gt("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}}`);let l=await i.createTensor({dataType:a??e,shape:r,dimensions:r,usage:s,writable:n,readable:o});return new q0({sessionId:t,context:i,tensor:l,dataType:e,shape:r,fallbackDataType:a})}releaseTensor(t){this.externalTensors.has(t)&&this.externalTensors.delete(t),this.freeTensors.push(t)}},gA=(...t)=>new LE(...t)}),wA={};nl(wA,{WebNNBackend:()=>xA});var Zi,NE,xA,oL=ye(()=>{"use strict";In(),Ds(),sL(),nL(),_A(),Zi=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),NE=(t,e)=>{if(t===e)return!0;if(t===void 0||e===void 0)return!1;let r=Object.keys(t).sort(),s=Object.keys(e).sort();return r.length===s.length&&r.every((n,o)=>n===s[o]&&t[n]===e[n])},xA=class{constructor(t){this.tensorManager=gA(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,hA(t.logLevel,!!t.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(t){gt("verbose",()=>`[WebNN] onRunStart {sessionId: ${t}}`),this.activeSessionId=t}onRunEnd(t){gt("verbose",()=>`[WebNN] onRunEnd {sessionId: ${t}}`);let e=this.temporarySessionTensorIds.get(t);if(e){for(let r of e)gt("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${r}}`),this.tensorManager.releaseTensorId(r);this.temporarySessionTensorIds.delete(t),this.activeSessionId=void 0}}async createMLContext(t){if(t instanceof GPUDevice){let r=this.mlContextCache.findIndex(s=>s.gpuDevice===t);if(r!==-1)return this.mlContextCache[r].mlContext;{let s=await navigator.ml.createContext(t);return this.mlContextCache.push({gpuDevice:t,mlContext:s}),s}}else if(t===void 0){let r=this.mlContextCache.findIndex(s=>s.options===void 0&&s.gpuDevice===void 0);if(r!==-1)return this.mlContextCache[r].mlContext;{let s=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:s}),s}}let e=this.mlContextCache.findIndex(r=>NE(r.options,t));if(e!==-1)return this.mlContextCache[e].mlContext;{let r=await navigator.ml.createContext(t);return this.mlContextCache.push({options:t,mlContext:r}),r}}registerMLContext(t,e){this.mlContextBySessionId.set(t,e);let r=this.sessionIdsByMLContext.get(e);r||(r=new Set,this.sessionIdsByMLContext.set(e,r)),r.add(t),this.mlOpSupportLimitsBySessionId.has(t)||this.mlOpSupportLimitsBySessionId.set(t,e.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(t,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(t,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(t){this.sessionGraphInputs.delete(t),this.sessionGraphOutputs.delete(t);let e=this.mlContextBySessionId.get(t);if(!e)return;this.tensorManager.releaseTensorsForSession(t),this.mlContextBySessionId.delete(t),this.mlOpSupportLimitsBySessionId.delete(t);let r=this.sessionIdsByMLContext.get(e);if(r.delete(t),r.size===0){this.sessionIdsByMLContext.delete(e);let s=this.mlContextCache.findIndex(n=>n.mlContext===e);s!==-1&&this.mlContextCache.splice(s,1)}}getMLContext(t){return this.mlContextBySessionId.get(t)}getMLOpSupportLimits(t){return this.mlOpSupportLimitsBySessionId.get(t)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(t){gt("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t)}async ensureTensor(t,e,r,s,n){let o=Zi.get(r);if(!o)throw new Error(`Unsupported ONNX data type: ${r}`);return this.tensorManager.ensureTensor(t??this.currentSessionId,e,o,s,n)}async createTemporaryTensor(t,e,r){gt("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${r}}`);let s=Zi.get(e);if(!s)throw new Error(`Unsupported ONNX data type: ${e}`);let n=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(t,n,s,r,!1);let o=this.temporarySessionTensorIds.get(t);return o?o.push(n):this.temporarySessionTensorIds.set(t,[n]),n}uploadTensor(t,e){if(!Ue().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");gt("verbose",()=>`[WebNN] uploadTensor {tensorId: ${t}, data: ${e.byteLength}}`),this.tensorManager.upload(t,e)}async downloadTensor(t,e){return this.tensorManager.download(t,e)}createMLTensorDownloader(t,e){return async()=>{let r=await this.tensorManager.download(t);return mA(r,e)}}registerMLTensor(t,e,r,s){let n=Zi.get(r);if(!n)throw new Error(`Unsupported ONNX data type: ${r}`);let o=this.tensorManager.registerTensor(t,e,n,s);return gt("verbose",()=>`[WebNN] registerMLTensor {tensor: ${e}, dataType: ${n}, dimensions: ${s}} -> {tensorId: ${o}}`),o}registerMLConstant(t,e,r,s,n,o,a=!1){if(!o)throw new Error("External mounted files are not available.");let i=t;t.startsWith("./")&&(i=t.substring(2));let l=o.get(i);if(!l)throw new Error(`File with name ${i} not found in preloaded files.`);if(e+r>l.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let u=l.slice(e,e+r).buffer,p;switch(n.dataType){case"float32":p=new Float32Array(u);break;case"float16":p=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(u):new Uint16Array(u);break;case"int32":p=new Int32Array(u);break;case"uint32":p=new Uint32Array(u);break;case"int64":if(a){let f=J0(new Uint8Array(u),"int64");p=new Int32Array(f.buffer),n.dataType="int32"}else p=new BigInt64Array(u);break;case"uint64":p=new BigUint64Array(u);break;case"int8":p=new Int8Array(u);break;case"int4":case"uint4":case"uint8":p=new Uint8Array(u);break;default:throw new Error(`Unsupported data type: ${n.dataType} in creating WebNN Constant from external data.`)}return gt("verbose",()=>`[WebNN] registerMLConstant {dataType: ${n.dataType}, shape: ${n.shape}}} ${a?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),s.constant(n,p)}registerGraphInput(t){this.temporaryGraphInputs.push(t)}registerGraphOutput(t){this.temporaryGraphOutputs.push(t)}isGraphInput(t,e){let r=this.sessionGraphInputs.get(t);return r?r.includes(e):!1}isGraphOutput(t,e){let r=this.sessionGraphOutputs.get(t);return r?r.includes(e):!1}isGraphInputOutputTypeSupported(t,e,r=!0){let s=Zi.get(Ls(e)),n=this.mlOpSupportLimitsBySessionId.get(t);return typeof s>"u"?!1:r?!!n?.input.dataTypes.includes(s):!!n?.output.dataTypes.includes(s)}flush(){}}}),zE,pb,db,ts,$E,V0,Xu,fb,mb,H0,hb,_b,gb,yA=ye(()=>{"use strict";Rs(),tL(),rL(),In(),Ds(),ib(),fA(),zE=(t,e)=>{Ue()._OrtInit(t,e)!==0&&Ce("Can't initialize onnxruntime.")},pb=async t=>{zE(t.wasm.numThreads,Hu(t.logLevel))},db=async(t,e)=>{Ue().asyncInit?.();let r=t.webgpu.adapter;if(e==="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 s=t.webgpu.powerPreference;if(s!==void 0&&s!=="low-power"&&s!=="high-performance")throw new Error(`Invalid powerPreference setting: "${s}"`);let n=t.webgpu.forceFallbackAdapter;if(n!==void 0&&typeof n!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${n}"`);if(r=await navigator.gpu.requestAdapter({powerPreference:s,forceFallbackAdapter:n}),!r)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(e==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");if(e==="webgpu"&&Ue().webgpuInit(s=>{t.webgpu.device=s}),e==="webnn"){let s=new(oL(),qu(wA)).WebNNBackend(t);Ue().webnnInit([s,()=>s.reserveTensorId(),n=>s.releaseTensorId(n),async(n,o,a,i,l)=>s.ensureTensor(n,o,a,i,l),(n,o)=>{s.uploadTensor(n,o)},async(n,o)=>s.downloadTensor(n,o),(n,o)=>s.registerMLContext(n,o),!!t.trace])}},ts=new Map,$E=t=>{let e=Ue(),r=e.stackSave();try{let s=e.PTR_SIZE,n=e.stackAlloc(2*s);e._OrtGetInputOutputCount(t,n,n+s)!==0&&Ce("Can't get session input/output count.");let o=s===4?"i32":"i64";return[Number(e.getValue(n,o)),Number(e.getValue(n+s,o))]}finally{e.stackRestore(r)}},V0=(t,e)=>{let r=Ue(),s=r.stackSave(),n=0;try{let o=r.PTR_SIZE,a=r.stackAlloc(2*o);r._OrtGetInputOutputMetadata(t,e,a,a+o)!==0&&Ce("Can't get session input/output metadata.");let i=Number(r.getValue(a,"*"));n=Number(r.getValue(a+o,"*"));let l=r.HEAP32[n/4];if(l===0)return[i,0];let u=r.HEAPU32[n/4+1],p=[];for(let f=0;f<u;f++){let m=Number(r.getValue(n+8+f*o,"*"));p.push(m!==0?r.UTF8ToString(m):Number(r.getValue(n+8+(f+u)*o,"*")))}return[i,l,p]}finally{r.stackRestore(s),n!==0&&r._OrtFree(n)}},Xu=t=>{let e=Ue(),r=e._malloc(t.byteLength);if(r===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,r),[r,t.byteLength]},fb=async(t,e)=>{let r,s,n=Ue();Array.isArray(t)?[r,s]=t:t.buffer===n.HEAPU8.buffer?[r,s]=[t.byteOffset,t.byteLength]:[r,s]=Xu(t);let o=0,a=0,i=0,l=[],u=[],p=[];try{if([a,l]=await dA(e),e?.externalData&&n.mountExternalData){let T=[];for(let L of e.externalData){let P=typeof L=="string"?L:L.path;T.push(ub(typeof L=="string"?L:L.data).then(k=>{n.mountExternalData(P,k)}))}await Promise.all(T)}for(let T of e?.executionProviders??[])if((typeof T=="string"?T:T.name)==="webnn"){if(n.shouldTransferToMLTensor=!1,typeof T!="string"){let L=T,P=L?.context,k=L?.gpuDevice,F=L?.deviceType,K=L?.powerPreference;P?n.currentContext=P:k?n.currentContext=await n.webnnCreateMLContext(k):n.currentContext=await n.webnnCreateMLContext({deviceType:F,powerPreference:K})}else n.currentContext=await n.webnnCreateMLContext();break}o=await n._OrtCreateSession(r,s,a),n.webgpuOnCreateSession?.(o),o===0&&Ce("Can't create a session."),n.jsepOnCreateSession?.(),n.currentContext&&(n.webnnRegisterMLContext(o,n.currentContext),n.currentContext=void 0,n.shouldTransferToMLTensor=!0);let[f,m]=$E(o),h=!!e?.enableGraphCapture,w=[],x=[],v=[],E=[],A=[];for(let T=0;T<f;T++){let[L,P,k]=V0(o,T);L===0&&Ce("Can't get an input name."),u.push(L);let F=n.UTF8ToString(L);w.push(F),v.push(P===0?{name:F,isTensor:!1}:{name:F,isTensor:!0,type:Gu(P),shape:k})}for(let T=0;T<m;T++){let[L,P,k]=V0(o,T+f);L===0&&Ce("Can't get an output name."),p.push(L);let F=n.UTF8ToString(L);x.push(F),E.push(P===0?{name:F,isTensor:!1}:{name:F,isTensor:!0,type:Gu(P),shape:k});{if(h&&e?.preferredOutputLocation===void 0){A.push("gpu-buffer");continue}let K=typeof e?.preferredOutputLocation=="string"?e.preferredOutputLocation:e?.preferredOutputLocation?.[F]??"cpu",W=n.webnnIsGraphOutput;if(K==="cpu"&&W&&W(o,F)){A.push("ml-tensor-cpu-output");continue}if(K!=="cpu"&&K!=="cpu-pinned"&&K!=="gpu-buffer"&&K!=="ml-tensor")throw new Error(`Not supported preferred output location: ${K}.`);if(h&&K!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${K}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);A.push(K)}}let S=null;return A.some(T=>T==="gpu-buffer"||T==="ml-tensor"||T==="ml-tensor-cpu-output")&&(i=n._OrtCreateBinding(o),i===0&&Ce("Can't create IO binding."),S={handle:i,outputPreferredLocations:A,outputPreferredLocationsEncoded:A.map(T=>T==="ml-tensor-cpu-output"?"ml-tensor":T).map(T=>Q0(T))}),ts.set(o,[o,u,p,S,h,!1]),[o,w,x,v,E]}catch(f){throw u.forEach(m=>n._OrtFree(m)),p.forEach(m=>n._OrtFree(m)),i!==0&&n._OrtReleaseBinding(i)!==0&&Ce("Can't release IO binding."),o!==0&&n._OrtReleaseSession(o)!==0&&Ce("Can't release session."),f}finally{n._free(r),a!==0&&n._OrtReleaseSessionOptions(a)!==0&&Ce("Can't release session options."),l.forEach(f=>n._free(f)),n.unmountExternalData?.()}},mb=t=>{let e=Ue(),r=ts.get(t);if(!r)throw new Error(`cannot release session. invalid session id: ${t}`);let[s,n,o,a,i]=r;a&&(i&&e._OrtClearBoundOutputs(a.handle)!==0&&Ce("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&Ce("Can't release IO binding.")),e.jsepOnReleaseSession?.(t),e.webnnOnReleaseSession?.(t),e.webgpuOnReleaseSession?.(t),n.forEach(l=>e._OrtFree(l)),o.forEach(l=>e._OrtFree(l)),e._OrtReleaseSession(s)!==0&&Ce("Can't release session."),ts.delete(t)},H0=async(t,e,r,s,n,o,a=!1)=>{if(!t){e.push(0);return}let i=Ue(),l=i.PTR_SIZE,u=t[0],p=t[1],f=t[3],m=f,h,w;if(u==="string"&&(f==="gpu-buffer"||f==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(a&&f!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${o} when enableGraphCapture is true.`);if(f==="gpu-buffer"){let E=t[2].gpuBuffer;w=On(Ls(u),p);{let A=i.webgpuRegisterBuffer;if(!A)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');h=A(E,s)}}else if(f==="ml-tensor"){let E=t[2].mlTensor;w=On(Ls(u),p);let A=i.webnnRegisterMLTensor;if(!A)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');h=A(s,E,Ls(u),p)}else{let E=t[2];if(Array.isArray(E)){w=l*E.length,h=i._malloc(w),r.push(h);for(let A=0;A<E.length;A++){if(typeof E[A]!="string")throw new TypeError(`tensor data at index ${A} is not a string`);i.setValue(h+A*l,Lt(E[A],r),"*")}}else{let A=i.webnnIsGraphInput,S=i.webnnIsGraphOutput;if(u!=="string"&&A&&S){let T=i.UTF8ToString(n);if(A(s,T)||S(s,T)){let L=Ls(u);w=On(L,p),m="ml-tensor";let P=i.webnnCreateTemporaryTensor,k=i.webnnUploadTensor;if(!P||!k)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let F=await P(s,L,p);k(F,new Uint8Array(E.buffer,E.byteOffset,E.byteLength)),h=F}else w=E.byteLength,h=i._malloc(w),r.push(h),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),h)}else w=E.byteLength,h=i._malloc(w),r.push(h),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),h)}}let x=i.stackSave(),v=i.stackAlloc(4*p.length);try{p.forEach((A,S)=>i.setValue(v+S*l,A,l===4?"i32":"i64"));let E=i._OrtCreateTensor(Ls(u),h,w,v,p.length,Q0(m));E===0&&Ce(`Can't create tensor for input/output. session=${s}, index=${o}.`),e.push(E)}finally{i.stackRestore(x)}},hb=async(t,e,r,s,n,o)=>{let a=Ue(),i=a.PTR_SIZE,l=ts.get(t);if(!l)throw new Error(`cannot run inference. invalid session id: ${t}`);let u=l[0],p=l[1],f=l[2],m=l[3],h=l[4],w=l[5],x=e.length,v=s.length,E=0,A=[],S=[],T=[],L=[],P=[],k=a.stackSave(),F=a.stackAlloc(x*i),K=a.stackAlloc(x*i),W=a.stackAlloc(v*i),X=a.stackAlloc(v*i);try{[E,A]=pA(o),ss("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)await H0(r[C],S,L,t,p[e[C]],e[C],h);for(let C=0;C<v;C++)await H0(n[C],T,L,t,f[s[C]],x+s[C],h);ns("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)a.setValue(F+C*i,S[C],"*"),a.setValue(K+C*i,p[e[C]],"*");for(let C=0;C<v;C++)a.setValue(W+C*i,T[C],"*"),a.setValue(X+C*i,f[s[C]],"*");if(m&&!w){let{handle:C,outputPreferredLocations:ne,outputPreferredLocationsEncoded:ae}=m;if(p.length!==x)throw new Error(`input count from feeds (${x}) is expected to be always equal to model's input count (${p.length}).`);ss("wasm bindInputsOutputs");for(let I=0;I<x;I++){let N=e[I];await a._OrtBindInput(C,p[N],S[I])!==0&&Ce(`Can't bind input[${I}] for session=${t}.`)}for(let I=0;I<v;I++){let N=s[I];n[I]?.[3]?(P.push(T[I]),a._OrtBindOutput(C,f[N],T[I],0)!==0&&Ce(`Can't bind pre-allocated output[${I}] for session=${t}.`)):a._OrtBindOutput(C,f[N],0,ae[N])!==0&&Ce(`Can't bind output[${I}] to ${ne[I]} for session=${t}.`)}ns("wasm bindInputsOutputs"),ts.set(t,[u,p,f,m,h,!0])}a.jsepOnRunStart?.(u),a.webnnOnRunStart?.(u);let H;m?H=await a._OrtRunWithBinding(u,m.handle,v,W,E):H=await a._OrtRun(u,K,F,x,X,v,W,E),H!==0&&Ce("failed to call OrtRun().");let Y=[],U=[];ss("wasm ProcessOutputTensor");for(let C=0;C<v;C++){let ne=Number(a.getValue(W+C*i,"*"));if(ne===T[C]||P.includes(T[C])){Y.push(n[C]),ne!==T[C]&&a._OrtReleaseTensor(ne)!==0&&Ce("Can't release tensor.");continue}let ae=a.stackSave(),I=a.stackAlloc(4*i),N=!1,R,ee=0;try{a._OrtGetTensorData(ne,I,I+i,I+2*i,I+3*i)!==0&&Ce(`Can't access output tensor data on index ${C}.`);let de=i===4?"i32":"i64",Fe=Number(a.getValue(I,de));ee=a.getValue(I+i,"*");let Le=a.getValue(I+i*2,"*"),At=Number(a.getValue(I+i*3,de)),Je=[];for(let Me=0;Me<At;Me++)Je.push(Number(a.getValue(Le+Me*i,de)));a._OrtFree(Le)!==0&&Ce("Can't free memory for tensor dims.");let tt=Je.reduce((Me,xe)=>Me*xe,1);R=Gu(Fe);let nt=m?.outputPreferredLocations[s[C]];if(R==="string"){if(nt==="gpu-buffer"||nt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Me=[];for(let xe=0;xe<tt;xe++){let We=a.getValue(ee+xe*i,"*"),Mt=a.getValue(ee+(xe+1)*i,"*"),be=xe===tt-1?void 0:Mt-We;Me.push(a.UTF8ToString(We,be))}Y.push([R,Je,Me,"cpu"])}else if(nt==="gpu-buffer"&&tt>0){let Me=a.webgpuGetBuffer;if(!Me)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let xe=Me(ee),We=On(Fe,tt);if(We===void 0||!lb(R))throw new Error(`Unsupported data type: ${R}`);N=!0;{a.webgpuRegisterBuffer(xe,t,ee);let Mt=a.webgpuCreateDownloader(xe,We,t);Y.push([R,Je,{gpuBuffer:xe,download:async()=>{let be=await Mt();return new(sl(R))(be)},dispose:()=>{a._OrtReleaseTensor(ne)!==0&&Ce("Can't release tensor.")}},"gpu-buffer"])}}else if(nt==="ml-tensor"&&tt>0){let Me=a.webnnEnsureTensor,xe=a.webnnIsGraphInputOutputTypeSupported;if(!Me||!xe)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(On(Fe,tt)===void 0||!cb(R))throw new Error(`Unsupported data type: ${R}`);if(!xe(t,R,!1))throw new Error(`preferredLocation "ml-tensor" for ${R} output is not supported by current WebNN Context.`);let We=await Me(t,ee,Fe,Je,!1);N=!0,Y.push([R,Je,{mlTensor:We,download:a.webnnCreateMLTensorDownloader(ee,R),dispose:()=>{a.webnnReleaseTensorId(ee),a._OrtReleaseTensor(ne)}},"ml-tensor"])}else if(nt==="ml-tensor-cpu-output"&&tt>0){let Me=a.webnnCreateMLTensorDownloader(ee,R)(),xe=Y.length;N=!0,U.push((async()=>{let We=[xe,await Me];return a.webnnReleaseTensorId(ee),a._OrtReleaseTensor(ne),We})()),Y.push([R,Je,[],"cpu"])}else{let Me=sl(R),xe=new Me(tt);new Uint8Array(xe.buffer,xe.byteOffset,xe.byteLength).set(a.HEAPU8.subarray(ee,ee+xe.byteLength)),Y.push([R,Je,xe,"cpu"])}}finally{a.stackRestore(ae),R==="string"&&ee&&a._free(ee),N||a._OrtReleaseTensor(ne)}}m&&!h&&(a._OrtClearBoundOutputs(m.handle)!==0&&Ce("Can't clear bound outputs."),ts.set(t,[u,p,f,m,h,!1]));for(let[C,ne]of await Promise.all(U))Y[C][2]=ne;return ns("wasm ProcessOutputTensor"),Y}finally{a.webnnOnRunEnd?.(u),a.stackRestore(k),r.forEach(H=>{H&&H[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(H[2].gpuBuffer)}),n.forEach(H=>{H&&H[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(H[2].gpuBuffer)}),S.forEach(H=>a._OrtReleaseTensor(H)),T.forEach(H=>a._OrtReleaseTensor(H)),L.forEach(H=>a._free(H)),E!==0&&a._OrtReleaseRunOptions(E),A.forEach(H=>a._free(H))}},_b=t=>{let e=Ue(),r=ts.get(t);if(!r)throw new Error("invalid session id");let s=r[0],n=e._OrtEndProfiling(s);n===0&&Ce("Can't get an profile file name."),e._OrtFree(n)},gb=t=>{let e=[];for(let r of t){let s=r[2];!Array.isArray(s)&&"buffer"in s&&e.push(s.buffer)}return e}}),rs,jt,Sn,el,tl,Fu,X0,ju,Is,Cs,RE,bA,vA,kA,EA,AA,MA,TA,SA=ye(()=>{"use strict";Rs(),yA(),Ds(),ob(),rs=()=>!!He.wasm.proxy&&typeof document<"u",Sn=!1,el=!1,tl=!1,ju=new Map,Is=(t,e)=>{let r=ju.get(t);r?r.push(e):ju.set(t,[e])},Cs=()=>{if(Sn||!el||tl||!jt)throw new Error("worker not ready")},RE=t=>{switch(t.data.type){case"init-wasm":Sn=!1,t.data.err?(tl=!0,X0[1](t.data.err)):(el=!0,X0[0]()),Fu&&(URL.revokeObjectURL(Fu),Fu=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=ju.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}default:}},bA=async()=>{if(!el){if(Sn)throw new Error("multiple calls to 'initWasm()' detected.");if(tl)throw new Error("previous call to 'initWasm()' failed.");if(Sn=!0,rs())return new Promise((t,e)=>{jt?.terminate(),cA().then(([r,s])=>{try{jt=s,jt.onerror=o=>e(o),jt.onmessage=RE,X0=[t,e];let n={type:"init-wasm",in:He};!n.in.wasm.wasmPaths&&(r||Y0)&&(n.in.wasm.wasmPaths={wasm:new URL("ort-wasm-simd-threaded.asyncify.wasm",tr.url).href}),jt.postMessage(n),Fu=r}catch(n){e(n)}},e)});try{await ab(He.wasm),await pb(He),el=!0}catch(t){throw tl=!0,t}finally{Sn=!1}}},vA=async t=>{if(rs())return Cs(),new Promise((e,r)=>{Is("init-ep",[e,r]);let s={type:"init-ep",in:{epName:t,env:He}};jt.postMessage(s)});await db(He,t)},kA=async t=>rs()?(Cs(),new Promise((e,r)=>{Is("copy-from",[e,r]);let s={type:"copy-from",in:{buffer:t}};jt.postMessage(s,[t.buffer])})):Xu(t),EA=async(t,e)=>{if(rs()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Cs(),new Promise((r,s)=>{Is("create",[r,s]);let n={type:"create",in:{model:t,options:{...e}}},o=[];t instanceof Uint8Array&&o.push(t.buffer),jt.postMessage(n,o)})}else return fb(t,e)},AA=async t=>{if(rs())return Cs(),new Promise((e,r)=>{Is("release",[e,r]);let s={type:"release",in:t};jt.postMessage(s)});mb(t)},MA=async(t,e,r,s,n,o)=>{if(rs()){if(r.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(n.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return Cs(),new Promise((a,i)=>{Is("run",[a,i]);let l=r,u={type:"run",in:{sessionId:t,inputIndices:e,inputs:l,outputIndices:s,options:o}};jt.postMessage(u,gb(l))})}else return hb(t,e,r,s,n,o)},TA=async t=>{if(rs())return Cs(),new Promise((e,r)=>{Is("end-profiling",[e,r]);let s={type:"end-profiling",in:t};jt.postMessage(s)});_b(t)}}),K0,DE,OA,aL=ye(()=>{"use strict";Rs(),SA(),In(),nb(),fA(),K0=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},DE=t=>{switch(t[3]){case"cpu":return new rr(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!lb(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:r,download:s,dispose:n}=t[2];return rr.fromGpuBuffer(r,{dataType:e,dims:t[1],download:s,dispose:n})}case"ml-tensor":{let e=t[0];if(!cb(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:r,download:s,dispose:n}=t[2];return rr.fromMLTensor(r,{dataType:e,dims:t[1],download:s,dispose:n})}default:throw new Error(`invalid data location: ${t[3]}`)}},OA=class{async fetchModelAndCopyToWasmMemory(t){return kA(await ub(t))}async loadModel(t,e){zs();let r;typeof t=="string"?r=await this.fetchModelAndCopyToWasmMemory(t):r=t,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await EA(r,e),$s()}async dispose(){return AA(this.sessionId)}async run(t,e,r){zs();let s=[],n=[];Object.entries(t).forEach(f=>{let m=f[0],h=f[1],w=this.inputNames.indexOf(m);if(w===-1)throw new Error(`invalid input '${m}'`);s.push(h),n.push(w)});let o=[],a=[];Object.entries(e).forEach(f=>{let m=f[0],h=f[1],w=this.outputNames.indexOf(m);if(w===-1)throw new Error(`invalid output '${m}'`);o.push(h),a.push(w)});let i=s.map((f,m)=>K0(f,()=>`input "${this.inputNames[n[m]]}"`)),l=o.map((f,m)=>f?K0(f,()=>`output "${this.outputNames[a[m]]}"`):null),u=await MA(this.sessionId,n,i,a,l,r),p={};for(let f=0;f<u.length;f++)p[this.outputNames[a[f]]]=o[f]??DE(u[f]);return $s(),p}startProfiling(){}endProfiling(){TA(this.sessionId)}}}),IA={};nl(IA,{OnnxruntimeWebAssemblyBackend:()=>eb,initializeFlags:()=>Z0,wasmBackend:()=>CA});var Z0,eb,CA,iL=ye(()=>{"use strict";Rs(),SA(),aL(),Z0=()=>{(typeof He.wasm.initTimeout!="number"||He.wasm.initTimeout<0)&&(He.wasm.initTimeout=0);let t=He.wasm.simd;if(typeof t!="boolean"&&t!==void 0&&t!=="fixed"&&t!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${t}". Reset it to \`false\` and ignore SIMD feature checking.`),He.wasm.simd=!1),typeof He.wasm.proxy!="boolean"&&(He.wasm.proxy=!1),typeof He.wasm.trace!="boolean"&&(He.wasm.trace=!1),typeof He.wasm.numThreads!="number"||!Number.isInteger(He.wasm.numThreads)||He.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)He.wasm.numThreads=1;else{let e=typeof navigator>"u"?DP("node:os").cpus().length:navigator.hardwareConcurrency;He.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},eb=class{async init(t){Z0(),await bA(),await vA(t)}async createInferenceSessionHandler(t,e){let r=new OA;return await r.loadModel(t,e),r}},CA=new eb});Rs();Rs();Rs();var lL="1.25.0-dev.20260303-e7e64dc112",cL=sA;{let t=(iL(),qu(IA)).wasmBackend;Ns("webgpu",t,5),Ns("webnn",t,5),Ns("cpu",t,10),Ns("wasm",t,10)}Object.defineProperty(He.versions,"web",{value:lL,enumerable:!0});async function PA(t){let e=t.split("/").pop(),r;try{if(r=await er(),r){let n=await r.match(t);if(n)return n}}catch(n){J.warn(`Failed to load ${e} from cache:`,n)}let s=await me.fetch(t);if(!s.ok)throw new Error(`Failed to fetch ${e}: ${s.status} ${s.statusText}`);if(r)try{await r.put(t,s.clone())}catch(n){J.warn(`Failed to cache ${e}:`,n)}return s}async function LA(t){let e=await PA(t);if(!e||typeof e=="string")return null;try{return await e.arrayBuffer()}catch(r){return J.warn("Failed to read WASM binary:",r),null}}async function NA(t){if(se.IS_SERVICE_WORKER_ENV||se.IS_CHROME_AVAILABLE)return t;let e=await PA(t);if(!e||typeof e=="string")return null;try{let r=await e.text();r=r.replaceAll("globalThis.process?.versions?.node","false");let s=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(s)}catch(r){return J.warn("Failed to read WASM factory:",r),null}}var yb=require("onnxruntime-common"),pL=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 DA(t){return t<=vt.DEBUG?0:t<=vt.INFO?2:t<=vt.WARNING||t<=vt.ERROR?3:4}var dL={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},Gt=[],xb,Pn,zA=Symbol.for("onnxruntime");if(zA in globalThis)Pn=globalThis[zA];else if(se.IS_NODE_ENV){switch(Pn=uL,process.platform){case"win32":Gt.push("dml");break;case"linux":process.arch==="x64"&&Gt.push("cuda");break;case"darwin":Gt.push("coreml");break}Gt.push("webgpu"),Gt.push("cpu"),xb=["cpu"]}else Pn=wb,se.IS_WEBNN_AVAILABLE&&Gt.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),se.IS_WEBGPU_AVAILABLE&&Gt.push("webgpu"),Gt.push("wasm"),xb=["wasm"];var fL=Pn.InferenceSession;function UA(t=null){if(!t)return xb;switch(t){case"auto":return Gt;case"gpu":return Gt.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(Gt.includes(t))return[pL[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${Gt.join(", ")}.`)}var $A=Promise.resolve(),Cn=null;async function mL(){if(Cn)return Cn;if(!(me.useWasmCache&&typeof it?.wasm?.wasmPaths=="object"&&it?.wasm?.wasmPaths?.wasm&&it?.wasm?.wasmPaths?.mjs)){if(se.IS_DENO_WEB_RUNTIME)throw new Error("env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.");return Cn=Promise.resolve(),Cn}return Cn=(async()=>{let e=it.wasm.wasmPaths,r=!1;await Promise.all([e.wasm&&!k0(e.wasm)?(async()=>{try{let s=await LA(E0(e.wasm));s&&(it.wasm.wasmBinary=s,r=!0)}catch(s){J.warn("Failed to pre-load WASM binary:",s)}})():Promise.resolve(),e.mjs&&!k0(e.mjs)?(async()=>{try{let s=await NA(E0(e.mjs));s&&(it.wasm.wasmPaths.mjs=s)}catch(s){J.warn("Failed to pre-load WASM factory:",s)}})():Promise.resolve()]),r||(it.wasm.wasmPaths.mjs=e.mjs)})(),Cn}async function Ku(t,e,r){await mL();let s=DA(me.logLevel??vt.WARNING),n=()=>fL.create(t,{logSeverityLevel:s,...e}),o=await(se.IS_WEB_ENV?$A=$A.then(n):n());return o.config=r,o}var RA=Promise.resolve();async function Yu(t,e){let r=()=>t.run(e);return se.IS_WEB_ENV?RA=RA.then(r):r()}function Qu(t){return t instanceof Pn.Tensor}var it=Pn?.env;function ol(){return it?.wasm?.proxy}if(it){let t=function(e){let r=DA(e);it.logLevel=dL[r]};if(it.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&it.versions?.web&&!it.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${it.versions.web}/dist/`;it.wasm.wasmPaths=se.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`${e}ort-wasm-simd-threaded.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${e}ort-wasm-simd-threaded.asyncify.wasm`}}it.wasm.proxy=!1}it.webgpu&&(it.webgpu.powerPreference="high-performance"),t(me.logLevel??vt.WARNING),me.backends.onnx={...it,setLogLevel:t}}var os=async(t,e,r)=>{let s=await Ku(new Uint8Array(t),e);return(async n=>{let o=ol(),a=Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(o?u.clone():u).ort_tensor])),i=await Yu(s,a);return Array.isArray(r)?r.map(l=>new D(i[l])):new D(i[r])})},dr=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=os([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=os([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=os([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=os([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=os([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=os([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=os([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=os([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,"y")),this._slice}};var BA=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"}),bb=se.IS_NODE_ENV?"cpu":"wasm";function Ju(t,e,{warn:r}={}){return t?typeof t=="string"?t:t.hasOwnProperty(e)?t[e]:(r&&r(`device not specified for "${e}". Using the default device (${bb}).`),bb):bb}var GA=(function(){let t;return async function(){if(t===void 0)if(!se.IS_WEBGPU_AVAILABLE)t=!1;else try{t=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{t=!1}return t}})(),ht=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),FA=ht.fp32,jA=Object.freeze({[BA.wasm]:ht.q8}),al=Object.freeze({[ht.fp32]:"",[ht.fp16]:"_fp16",[ht.int8]:"_int8",[ht.uint8]:"_uint8",[ht.q8]:"_quantized",[ht.q4]:"_q4",[ht.q4f16]:"_q4f16",[ht.bnb4]:"_bnb4"});function Zu(t,e,r,{configDtype:s=null,warn:n}={}){let o,a=!1;t&&typeof t!="string"?t.hasOwnProperty(e)?o=t[e]:(o=null,a=!0):o=t;let i;if(o===ht.auto){if(s){let l=typeof s=="string"?s:s?.[e];if(l&&l!==ht.auto&&ht.hasOwnProperty(l))return l}i=jA[r]??FA}else o&&ht.hasOwnProperty(o)?i=o:i=jA[r]??FA;return a&&n&&n(`dtype not specified for "${e}". Using the default dtype (${i}) for this device (${r}).`),i}var Ln=Object.freeze({float32:Float32Array,float16:typeof Float16Array<"u"?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array});var D=class t{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return Qu(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new yb.Tensor(e[0],e[1],e[2]),new Proxy(this,{get:(r,s)=>{if(typeof s=="string"){let n=Number(s);if(Number.isInteger(n))return r._getitem(n)}return r[s]},set:(r,s,n)=>r[s]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...r]=this.dims;if(r.length>0){let s=r.reduce((n,o)=>n*o);for(let n=0;n<e;++n)yield this._subarray(n,s,r)}else yield*this.data}_getitem(e){let[r,...s]=this.dims;if(e=fr(e,r),s.length>0){let n=s.reduce((o,a)=>o*a);return this._subarray(e,n,s)}else return new t(this.type,[this.data[e]],s)}indexOf(e){let r=this.data;for(let s=0;s<r.length;++s)if(r[s]==e)return s;return-1}_subarray(e,r,s){let n=e*r,o=(e+1)*r,a="subarray"in this.data?this.data.subarray(n,o):this.data.slice(n,o);return new t(this.type,a,s)}item(){let e=this.data;if(e.length!==1)throw new Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return hL(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=1/(1+Math.exp(-e[r]));return this}map(e){return this.clone().map_(e)}map_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]=e(r[s],s,r);return this}mul(e){return this.clone().mul_(e)}mul_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]-=e;return this}clone(){return new t(this.type,this.data.slice(),this.dims.slice())}slice(...e){let r=[],s=[];for(let p=0;p<this.dims.length;++p){let f=e[p];if(f==null)s.push([0,this.dims[p]]),r.push(this.dims[p]);else if(typeof f=="number")f=fr(f,this.dims[p],p),s.push([f,f+1]);else if(Array.isArray(f)&&f.length===2){let[m,h]=f;if(m=m===null?0:fr(m,this.dims[p],p,!1),h=h===null?this.dims[p]:fr(h,this.dims[p],p,!1),m>h)throw new Error(`Invalid slice: ${f}`);let w=[Math.max(m,0),Math.min(h,this.dims[p])];s.push(w),r.push(w[1]-w[0])}else throw new Error(`Invalid slice: ${f}`)}let n=s.map(([p,f])=>f-p),o=n.reduce((p,f)=>p*f),a=this.data,i=new a.constructor(o),l=this.stride(),u=!0;for(let p=1;p<n.length;++p)if(s[p][0]!==0||s[p][1]!==this.dims[p]){u=!1;break}if(u){let p=s[0][0]*l[0],f=s[0][1]*l[0];if(ArrayBuffer.isView(a))i.set(a.subarray(p,f));else if(Array.isArray(a)){let m=a.slice(p,f);for(let h=0;h<m.length;++h)i[h]=m[h]}else throw new Error("Unsupported data type for slicing")}else for(let p=0;p<o;++p){let f=0;for(let m=n.length-1,h=p;m>=0;--m){let w=n[m];f+=(h%w+s[m][0])*l[m],h=Math.floor(h/w)}i[p]=a[f]}return new t(this.type,i,r)}permute(...e){return VA(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,r=!1){return this.norm(1,e,r)}norm(e="fro",r=null,s=!1){if(e==="fro")e=2;else if(typeof e=="string")throw Error(`Unsupported norm: ${e}`);let n=this.data,o=(u,p)=>u+p**e;if(r===null){let u=n.reduce(o,0)**(1/e);return new t(this.type,[u],[])}let[a,i,l]=il(o,this,r,s);if(e!==1)for(let u=0;u<i.length;++u)i[u]=i[u]**(1/e);return new t(a,i,l)}normalize_(e=2,r=1){r=fr(r,this.dims.length);let s=this.norm(e,r,!0),n=this.data,o=s.data;for(let a=0;a<n.length;++a){let i=0;for(let l=this.dims.length-1,u=a,p=1;l>=0;--l){let f=this.dims[l];if(l!==r){let m=u%f;i+=m*p,p*=this.dims[l]}u=Math.floor(u/f)}n[a]/=o[i]}return this}normalize(e=2,r=1){return this.clone().normalize_(e,r)}stride(){return vb(this.dims)}squeeze(e=null){return new t(this.type,this.data,qA(this.dims,e))}squeeze_(e=null){return this.dims=qA(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,WA(this.dims,e))}unsqueeze_(e){return this.dims=WA(this.dims,e),this}flatten_(e=0,r=-1){r=(r+this.dims.length)%this.dims.length;let s=this.dims.slice(0,e),n=this.dims.slice(e,r+1),o=this.dims.slice(r+1);return this.dims=[...s,n.reduce((a,i)=>a*i,1),...o],this}flatten(e=0,r=-1){return this.clone().flatten_(e,r)}view(...e){let r=-1;for(let n=0;n<e.length;++n)if(e[n]===-1){if(r!==-1)throw new Error("Only one dimension can be inferred");r=n}let s=this.data;if(r!==-1){let n=e.reduce((o,a,i)=>i!==r?o*a:o,1);e[r]=s.length/n}return new t(this.type,s,e)}neg_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=-e[r];return this}neg(){return this.clone().neg_()}gt(e){let r=new Uint8Array(this.data.length),s=this.data;for(let n=0;n<s.length;++n)r[n]=s[n]>e?1:0;return new t("bool",r,this.dims)}lt(e){let r=new Uint8Array(this.data.length),s=this.data;for(let n=0;n<s.length;++n)r[n]=s[n]<e?1:0;return new t("bool",r,this.dims)}clamp_(e,r){let s=this.data;for(let n=0;n<s.length;++n)s[n]=Math.min(Math.max(s[n],e),r);return this}clamp(e,r){return this.clone().clamp_(e,r)}round_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=Math.round(e[r]);return this}round(){return this.clone().round_()}mean(e=null,r=!1){return cl(this,e,r)}min(e=null,r=!1){if(e===null){let a=Yi(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=il((a,i)=>Math.min(a,i),this,e,r,1/0);return new t(s,n,o)}max(e=null,r=!1){if(e===null){let a=Se(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=il((a,i)=>Math.max(a,i),this,e,r,-1/0);return new t(s,n,o)}argmin(e=null,r=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let s=Yi(this.data)[1];return new t("int64",[BigInt(s)],[])}argmax(e=null,r=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let s=Se(this.data)[1];return new t("int64",[BigInt(s)],[])}repeat(...e){if(e.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${e.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(e.every(p=>p===1)){if(e.length===this.dims.length)return this.clone();let p=e.length-this.dims.length,f=Array(p).fill(1).concat(this.dims);return new t(this.type,this.data.slice(),f)}let r=e.length-this.dims.length,s=Array(r).fill(1).concat(this.dims),n=s.map((p,f)=>p*e[f]),o=n.reduce((p,f)=>p*f,1),a=this.data,i=new a.constructor(o),l=vb(s),u=vb(n);for(let p=0;p<o;++p){let f=p,m=0;for(let h=0;h<n.length;++h){let w=Math.floor(f/u[h]);f=f%u[h];let x=w%s[h];m+=x*l[h]}i[p]=a[m]}return new t(this.type,i,n)}tile(...e){if(e.length<this.dims.length){let r=this.dims.length-e.length;e=Array(r).fill(1).concat(e)}return this.repeat(...e)}to(e){if(this.type===e)return this;if(!Ln.hasOwnProperty(e))throw new Error(`Unsupported type: ${e}`);let r,s=["int64","uint64"].includes(this.type),n=["int64","uint64"].includes(e);if(s&&!n)r=Number;else if(!s&&n)["float16","float32","float64"].includes(this.type)?r=o=>BigInt(Math.floor(o)):r=BigInt;else if(this.type==="float16"&&e=="float32"&&this.data instanceof Uint16Array)return new t(e,pE(this.data),this.dims);return new t(e,Ln[e].from(this.data,r),this.dims)}};function hL(t,e){let r=t.length,s=e.reduce((o,a)=>o*a);if(r!==s)throw Error(`cannot reshape array of size ${r} into shape (${e})`);let n=t;for(let o=e.length-1;o>=0;o--)n=n.reduce((a,i)=>{let l=a[a.length-1];return l.length<e[o]?l.push(i):a.push([i]),a},[[]]);return n[0]}function VA(t,e){let[r,s]=oE(t.data,t.dims,e);return new D(t.type,r,s)}function tp(t,[e,r],s="bilinear",n=!1){let o=t.dims.at(-3)??1,a=t.dims.at(-2),i=t.dims.at(-1),l=nE(t.data,[o,a,i],[e,r],s,n);return new D(t.type,l,[o,e,r])}async function zt(t,{size:e=null,mode:r="bilinear"}={}){if(t.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!e)throw new Error("`interpolate_4d` requires a `size` argument.");let s;if(e.length===2)s=[...t.dims.slice(0,2),...e];else if(e.length===3)s=[t.dims[0],...e];else if(e.length===4)s=e;else throw new Error("`size` must be of length 2, 3, or 4.");let n;if(r==="nearest")n=await dr.nearest_interpolate_4d;else if(r==="bilinear")n=await dr.bilinear_interpolate_4d;else if(r==="bicubic")n=await dr.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${r}`);let o=new D("int64",new BigInt64Array(s.map(BigInt)),[s.length]);return await n({x:t,s:o})}async function kb(t,e){return await(await dr.matmul)({a:t,b:e})}async function _L(t,e){return await(await dr.rfft)({x:t,a:e})}async function qt(t,e){let r=await dr.top_k;return e==null?e=t.dims.at(-1):e=Math.min(e,t.dims.at(-1)),await r({x:t,k:new D("int64",[BigInt(e)],[1])})}var ep=t=>new D("int64",t,[t.length]);async function ll(t,e,r,s,n){return await(await dr.slice)({x:t,s:ep(e),e:ep(r),a:ep(s),t:ep(n??new Array(s.length).fill(1))})}function Eb(t,e){let r=t.data,s=e.data,n=[t.dims[0],t.dims[2]],o=new r.constructor(n[0]*n[1]),[a,i,l]=t.dims,u=0;for(let p=0;p<a;++p){let f=p*l*i;for(let m=0;m<l;++m){let h=0,w=0,x=p*i,v=f+m;for(let A=0;A<i;++A){let S=Number(s[x+A]);w+=S,h+=r[v+A*l]*S}let E=h/w;o[u++]=E}}return new D(t.type,o,n)}function gL(t,e,{eps:r=1e-5}={}){if(t.dims.length!==2)throw new Error("`layer_norm` currently only supports 2D input.");let[s,n]=t.dims;if(e.length!==1&&e[0]!==n)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[o,a]=rp(t,1,0,!0),i=o.data,l=a.data,u=t.data,p=new u.constructor(u.length);for(let f=0;f<s;++f){let m=f*n;for(let h=0;h<n;++h){let w=m+h;p[w]=(u[w]-l[f])/(i[f]+r)}}return new D(t.type,p,t.dims)}function qA(t,e){return t=t.slice(),e===null?t=t.filter(r=>r!==1):typeof e=="number"?t[e]===1&&t.splice(e,1):Array.isArray(e)&&(t=t.filter((r,s)=>r!==1||!e.includes(s))),t}function WA(t,e){return e=fr(e,t.length+1),t=t.slice(),t.splice(e,0,1),t}function fr(t,e,r=null,s=!0){if(t<-e||t>=e){if(s)throw new Error(`IndexError: index ${t} is out of bounds for dimension${r===null?"":" "+r} with size ${e}`);return t<-e?0:e}return t<0&&(t=(t%e+e)%e),t}function Ee(t,e=0){e=fr(e,t[0].dims.length);let r=t[0].dims.slice();r[e]=t.reduce((a,i)=>a+i.dims[e],0);let s=r.reduce((a,i)=>a*i,1),n=new t[0].data.constructor(s),o=t[0].type;if(e===0){let a=0;for(let i of t){let l=i.data;n.set(l,a),a+=l.length}}else{let a=0;for(let i=0;i<t.length;++i){let{data:l,dims:u}=t[i];for(let p=0;p<l.length;++p){let f=0;for(let m=u.length-1,h=p,w=1;m>=0;--m){let x=u[m],v=h%x;m===e&&(v+=a),f+=v*w,w*=r[m],h=Math.floor(h/x)}n[f]=l[p]}a+=u[e]}}return new D(o,n,r)}function $t(t,e=0){return Ee(t.map(r=>r.unsqueeze(e)),e)}function il(t,e,r,s=!1,n=null){let o=e.data,a=e.dims;r=fr(r,a.length);let i=a.slice();i[r]=1;let l=new o.constructor(o.length/a[r]);n!==null&&l.fill(n);for(let u=0;u<o.length;++u){let p=0;for(let f=a.length-1,m=u,h=1;f>=0;--f){let w=a[f];if(f!==r){let x=m%w;p+=x*h,h*=i[f]}m=Math.floor(m/w)}l[p]=t(l[p],o[u],u,p)}return s||i.splice(r,1),[e.type,l,i]}function rp(t,e=null,r=1,s=!1){let n=t.data,o=t.dims;if(e===null){let h=n.reduce((E,A)=>E+A,0)/n.length,w=Math.sqrt(n.reduce((E,A)=>E+(A-h)**2,0)/(n.length-r)),x=new D(t.type,[h],[]);return[new D(t.type,[w],[]),x]}e=fr(e,o.length);let a=cl(t,e,s),i=a.data,[l,u,p]=il((m,h,w,x)=>m+(h-i[x])**2,t,e,s);for(let m=0;m<u.length;++m)u[m]=Math.sqrt(u[m]/(o[e]-r));return[new D(l,u,p),a]}function cl(t,e=null,r=!1){let s=t.dims,n=t.data;if(e===null){let l=n.reduce((u,p)=>u+p,0);return new D(t.type,[l/n.length],[])}e=fr(e,s.length);let[o,a,i]=il((l,u)=>l+u,t,e,r);if(s[e]!==1)for(let l=0;l<a.length;++l)a[l]/=s[e];return new D(o,a,i)}function vb(t){let e=new Array(t.length);for(let r=t.length-1,s=1;r>=0;--r)e[r]=s,s*=t[r];return e}function Ab(t,e,r,s){let n=t.reduce((o,a)=>o*a,1);return new D(r,new s(n).fill(e),t)}function qe(t,e){let r,s;if(typeof e=="number")r="float32",s=Float32Array;else if(typeof e=="bigint")r="int64",s=BigInt64Array;else if(typeof e=="boolean")r="bool",s=Uint8Array;else throw new Error(`Unsupported data type: ${typeof e}`);return Ab(t,e,r,s)}function Nn(t,e){return qe(t.dims,e)}function st(t){return Ab(t,1n,"int64",BigInt64Array)}function ul(t){return st(t.dims)}function sp(t){return Ab(t,0n,"int64",BigInt64Array)}function np(t){return sp(t.dims)}function wL(t){let e=t.reduce((r,s)=>r*s,1);return new D("float32",Float32Array.from({length:e},()=>Xr.random()),t)}function Mb(t){let e=t.reduce((r,s)=>r*s,1);return new D("float32",Float32Array.from({length:e},()=>Xr.gauss()),t)}function Tb(t,e){if(t.dims.length!==2)throw new Error("The tensor must have 2 dimensions");if(t.dims.at(-1)%8!==0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(e))throw new Error("The precision must be either 'binary' or 'ubinary'");let r=e==="binary",s=r?"int8":"uint8",n=r?Int8Array:Uint8Array,o=t.data,a=new n(o.length/8);for(let i=0;i<o.length;++i){let l=o[i]>0?1:0,u=Math.floor(i/8),p=i%8;a[u]|=l<<7-p,r&&p===0&&(a[u]-=128)}return new D(s,a,[t.dims[0],t.dims[1]/8])}async function zn(t){if(!t)throw new Error("modelId is required for get_tokenizer_files");return(await pr(t,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function Sb(t,e){let r=await zn(t);return await Promise.all(r.map(s=>ut(t,s,!0,e)))}function Ob(t){let e=t.dims;switch(e.length){case 1:return t.tolist();case 2:if(e[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return t.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${e.length}.`)}}var xL=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function yL(t,e,r,s){for(let n of Object.keys(t)){let o=e-t[n].length,a=r(n),i=new Array(o).fill(a);t[n]=s==="right"?ft(t[n],i):ft(i,t[n])}}function bL(t,e){for(let r of Object.keys(t))t[r].length=e}function Us(t,...e){for(let r of e){if(!Object.hasOwn(t,r))continue;let s=t[r];if(s)if(typeof s=="object"){if(s.__type==="AddedToken")return s.content;throw Error(`Unknown token: ${s}`)}else return s}return null}function vL(t){let e=[];for(let r of t.get_added_tokens_decoder().values())r.special&&e.push(r);return e}var q=class extends Ze{return_token_type_ids=!1;padding_side="right";constructor(e,r){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=r,this._tokenizer=new $k(e,r),this.config=r,this.padding_side=r.padding_side??this.padding_side,this.mask_token=Us(r,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=Us(r,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=Us(r,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=Us(r,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=Us(r,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=Us(r,"eos_token"),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=r.chat_template??null,Array.isArray(this.chat_template)){let n=Object.create(null);for(let{name:o,template:a}of this.chat_template){if(typeof o!="string"||typeof a!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');n[o]=a}this.chat_template=n}this._compiled_template_cache=new Map;let s=vL(this._tokenizer);this.all_special_ids=s.map(n=>n.id),this.all_special_tokens=s.map(n=>n.content)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let i=await Sb(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a});return new this(...i)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e=="string"?this._tokenizer.token_to_id(e):e.map(r=>this._tokenizer.token_to_id(r))}_call(e,{text_pair:r=null,add_special_tokens:s=!0,padding:n=!1,truncation:o=null,max_length:a=null,return_tensor:i=!0,return_token_type_ids:l=null}={}){let u=Array.isArray(e),p;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");p=e.map((m,h)=>this._encode_plus(m,{text_pair:r[h],add_special_tokens:s,return_token_type_ids:l}))}else p=e.map(m=>this._encode_plus(m,{add_special_tokens:s,return_token_type_ids:l}))}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).");p=[this._encode_plus(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:l})]}if(a===null?a=this.model_max_length:o===null&&(n===!0?(J.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),a=this.model_max_length):n===!1&&(J.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),n===!0&&(a=Math.min(Se(p.map(m=>m.input_ids.length))[0],a??1/0)),a=Math.min(a,this.model_max_length??1/0),n||o)for(let m=0;m<p.length;++m)p[m].input_ids.length!==a&&(p[m].input_ids.length>a?o&&bL(p[m],a):n&&yL(p[m],a,h=>h==="input_ids"?this.pad_token_id:0,this.padding_side));let f={};if(i){if(!(n&&o)&&p.some(h=>{for(let w of Object.keys(h))if(h[w].length!==p[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.");let m=[p.length,p[0].input_ids.length];for(let h of Object.keys(p[0]))f[h]=new D("int64",BigInt64Array.from(p.flatMap(w=>w[h]).map(BigInt)),m)}else{for(let m of Object.keys(p[0]))f[m]=p.map(h=>h[m]);if(!u)for(let m of Object.keys(f))f[m]=f[m][0]}return f}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:r=null,add_special_tokens:s=!0,return_token_type_ids:n=null}={}){let{ids:o,attention_mask:a,token_type_ids:i}=this._tokenizer.encode(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:n??this.return_token_type_ids});return{input_ids:o,attention_mask:a,...i?{token_type_ids:i}:{}}}tokenize(e,{pair:r=null,add_special_tokens:s=!1}={}){return this._tokenizer.tokenize(e,{text_pair:r,add_special_tokens:s})}encode(e,{text_pair:r=null,add_special_tokens:s=!0,return_token_type_ids:n=null}={}){return this._tokenizer.encode(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:n}).ids}batch_decode(e,r={}){return e instanceof D&&(e=e.tolist()),e.map(s=>this.decode(s,r))}decode(e,r={}){if(e instanceof D&&(e=Ob(e)),!Array.isArray(e)||e.length===0||!wk(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,r)}decode_single(e,{skip_special_tokens:r=!1,clean_up_tokenization_spaces:s=null}){return this._tokenizer.decode(e,{skip_special_tokens:r,clean_up_tokenization_spaces:s})}get_chat_template({chat_template:e=null,tools:r=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){let s=this.chat_template;if(e!==null&&Object.hasOwn(s,e))e=s[e];else if(e===null)if(r!==null&&"tool_use"in s)e=s.tool_use;else if("default"in s)e=s.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(s).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,{tools:r=null,documents:s=null,chat_template:n=null,add_generation_prompt:o=!1,tokenize:a=!0,padding:i=!1,truncation:l=!1,max_length:u=null,return_tensor:p=!0,return_dict:f=!0,tokenizer_kwargs:m={},...h}={}){if(n=this.get_chat_template({chat_template:n,tools:r}),typeof n!="string")throw Error(`chat_template must be a string, but got ${typeof n}`);let w=this._compiled_template_cache.get(n);w===void 0&&(w=new Xk(n),this._compiled_template_cache.set(n,w));let x=Object.create(null);for(let E of xL){let A=Us(this.config,E);A&&(x[E]=A)}let v=w.render({messages:e,add_generation_prompt:o,tools:r,documents:s,...x,...h});if(a){let E=this._call(v,{add_special_tokens:!1,padding:i,truncation:l,max_length:u,return_tensor:p,...m});return f?E:E.input_ids}return v}};function $n(t,e,r,s){if(!("language_codes"in t)||!Array.isArray(t.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in t)||!(t.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in t)||typeof t.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let n=s.src_lang,o=s.tgt_lang;if(!t.language_codes.includes(o))throw new Error(`Target language code "${o}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);if(n!==void 0){if(!t.language_codes.includes(n))throw new Error(`Source language code "${n}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);for(let a of t._tokenizer.post_processor.config.single)if("SpecialToken"in a&&t.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=t.lang_to_token(n);break}}return s.forced_bos_token_id=t._tokenizer.token_to_id(t.lang_to_token(o)),t._call(e,r)}var Cb={};Es(Cb,{AlbertTokenizer:()=>op,AutoTokenizer:()=>ce,BartTokenizer:()=>ap,BertTokenizer:()=>ip,BlenderbotSmallTokenizer:()=>lp,BlenderbotTokenizer:()=>cp,BloomTokenizer:()=>up,CLIPTokenizer:()=>dp,CamembertTokenizer:()=>pp,CodeGenTokenizer:()=>mp,CodeLlamaTokenizer:()=>fp,CohereTokenizer:()=>hp,ConvBertTokenizer:()=>_p,DebertaTokenizer:()=>wp,DebertaV2Tokenizer:()=>gp,DistilBertTokenizer:()=>xp,ElectraTokenizer:()=>yp,EsmTokenizer:()=>bp,FalconTokenizer:()=>vp,GPT2Tokenizer:()=>Ap,GPTNeoXTokenizer:()=>Ep,GemmaTokenizer:()=>kp,HerbertTokenizer:()=>Mp,LlamaTokenizer:()=>Tp,M2M100Tokenizer:()=>Sp,MBart50Tokenizer:()=>Ip,MBartTokenizer:()=>Rn,MPNetTokenizer:()=>Lp,MarianTokenizer:()=>Op,MgpstrTokenizer:()=>Cp,MobileBertTokenizer:()=>Pp,NllbTokenizer:()=>Np,NougatTokenizer:()=>zp,PreTrainedTokenizer:()=>q,Qwen2Tokenizer:()=>$p,RoFormerTokenizer:()=>Dp,RobertaTokenizer:()=>Rp,SiglipTokenizer:()=>Up,SpeechT5Tokenizer:()=>Bp,SqueezeBertTokenizer:()=>Fp,T5Tokenizer:()=>jp,TokenizersBackend:()=>q,VitsTokenizer:()=>Gp,Wav2Vec2CTCTokenizer:()=>qp,WhisperTokenizer:()=>Wp,XLMRobertaTokenizer:()=>Vp,XLMTokenizer:()=>Hp});var op=class extends q{return_token_type_ids=!0};var ap=class extends q{};var ip=class extends q{return_token_type_ids=!0};var lp=class extends q{};var cp=class extends q{};var up=class extends q{};var pp=class extends q{};var dp=class extends q{};var fp=class extends q{};var mp=class extends q{};var hp=class extends q{};var _p=class extends q{return_token_type_ids=!0};var gp=class extends q{return_token_type_ids=!0};var wp=class extends q{return_token_type_ids=!0};var xp=class extends q{};var yp=class extends q{return_token_type_ids=!0};var bp=class extends q{};var vp=class extends q{};var kp=class extends q{};var Ep=class extends q{};var Ap=class extends q{};var Mp=class extends q{return_token_type_ids=!0};var Tp=class extends q{padding_side="left"};var Sp=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s.slice(2,-2)),this.lang_to_token=s=>`__${s}__`}_build_translation_inputs(e,r,s){return $n(this,e,r,s)}};var Op=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(s=>this.languageRegex.test(s)),J.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[r,...s]=e.trim().split(this.languageRegex);if(s.length===0)return super._encode_text(r);if(s.length===2){let[n,o]=s;return this.supported_language_codes.includes(n)||J.warn(`Unsupported language code "${n}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),ft([n],super._encode_text(o))}}};var Rn=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s),this.lang_to_token=s=>s}_build_translation_inputs(e,r,s){return $n(this,e,r,s)}};var Ip=class extends Rn{};var Cp=class extends q{};var Pp=class extends q{return_token_type_ids=!0};var Lp=class extends q{};var Np=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(e,r,s){return $n(this,e,r,s)}};var zp=class extends q{};var $p=class extends q{};var Rp=class extends q{};var Dp=class extends q{return_token_type_ids=!0};var Up=class extends q{};var Bp=class extends q{};var Fp=class extends q{return_token_type_ids=!0};var jp=class extends q{};var Ib=class extends Bt{decode_chain(e){let r="";for(let s=1;s<e.length;s+=2)r+=e[s];return[r]}},Gp=class extends q{constructor(e,r){super(e,r),this._tokenizer.decoder=new Ib({type:"VitsDecoder"})}};var qp=class extends q{};var HA=[["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"]],pl=new Map(HA),kL=new Map([...HA.map(([t,e])=>[e,t]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function XA(t){t=t.toLowerCase();let e=kL.get(t);if(e===void 0){let r=t.match(/^<\|([a-z]{2})\|>$/);if(r&&(t=r[1]),pl.has(t))e=t;else{let n=t.length===2?pl.keys():pl.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var EL="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",KA=new RegExp(`^[${EL}]+$`,"gu"),Wp=class extends q{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:r=!1,return_language:s=!1,time_precision:n=null,force_full_sequences:o=!0}={}){if(n===null)throw Error("Must specify time_precision");let a=null,i=r==="word";function l(){return{language:a,timestamp:[null,null],text:""}}let u=[],p=l(),f=0,m=this.timestamp_begin,w=m+1500,x=[],v=[],E=!1,A=null,S=new Set(this.all_special_ids);for(let P of e){let k=P.tokens,F=i?P.token_timestamps:null,K=null,W=m;if("stride"in P){let[Y,U,C]=P.stride;if(f-=U,A=Y-C,U&&(W=U/n+m),C)for(let ne=k.length-1;ne>=0;--ne){let ae=Number(k[ne]);if(ae>=m){if(K!==null&&(ae-m)*n<A)break;K=ae}}}let X=[],H=[];for(let Y=0;Y<k.length;++Y){let U=Number(k[Y]);if(S.has(U)){let C=this.decode([U]),ne=pl.get(C.slice(2,-2));if(ne!==void 0){if(a!==null&&ne!==a&&!r){x.push(X);let ae=this.findLongestCommonSequence(x)[0],I=this.decode(ae);p.text=I,u.push(p),x=[],X=[],p=l()}a=p.language=ne}}else if(U>=m&&U<=w){let C=(U-m)*n+f,ne=Os(C,2);if(K!==null&&U>=K)E=!0;else if(E||x.length>0&&U<W)E=!1;else if(p.timestamp[0]===null)p.timestamp[0]=ne;else if(ne!==p.timestamp[0]){p.timestamp[1]=ne,x.push(X),i&&v.push(H);let[ae,I]=this.findLongestCommonSequence(x,v),N=this.decode(ae);p.text=N,i&&(p.words=this.collateWordTimestamps(ae,I,a)),u.push(p),x=[],X=[],v=[],H=[],p=l()}}else if(X.push(U),i){let C=Os(F[Y]+f,2),ne;if(Y+1<F.length){ne=Os(F[Y+1]+f,2);let ae=this.decode([U]);KA.test(ae)&&(ne=Os(Math.min(C+n,ne),2))}else ne=null;H.push([C,ne])}}if("stride"in P){let[Y,U,C]=P.stride;f+=Y-C}X.length>0?(x.push(X),i&&v.push(H)):x.every(Y=>Y.length===0)&&(p=l(),x=[],X=[],v=[],H=[])}if(x.length>0){if(o&&r)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");let[P,k]=this.findLongestCommonSequence(x,v),F=this.decode(P);p.text=F,i&&(p.words=this.collateWordTimestamps(P,k,a)),u.push(p)}let T=Object.create(null),L=u.map(P=>P.text).join("");if(r||s){for(let P=0;P<u.length;++P){let k=u[P];r||delete k.timestamp,s||delete k.language}if(i){let P=[];for(let k of u)for(let F of k.words)P.push(F);T={chunks:P}}else T={chunks:u}}return[L,T]}findLongestCommonSequence(e,r=null){let s=e[0],n=s.length,o=[],a=Array.isArray(r)&&r.length>0,i=a?[]:null,l=a?r[0]:null;for(let u=1;u<e.length;++u){let p=e[u],f=0,m=[n,n,0,0],h=p.length;for(let T=1;T<n+h;++T){let L=Math.max(0,n-T),P=Math.min(n,n+h-T),k=s.slice(L,P),F=Math.max(0,T-n),K=Math.min(h,T),W=p.slice(F,K);if(k.length!==W.length)throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");let X;a?X=k.filter((U,C)=>U===W[C]&&l[L+C]<=r[u][F+C]).length:X=k.filter((U,C)=>U===W[C]).length;let H=T/1e4,Y=X/T+H;X>1&&Y>f&&(f=Y,m=[L,P,F,K])}let[w,x,v,E]=m,A=Math.floor((x+w)/2),S=Math.floor((E+v)/2);o.push(...s.slice(0,A)),s=p.slice(S),n=s.length,a&&(i.push(...l.slice(0,A)),l=r[u].slice(S))}return o.push(...s),a?(i.push(...l),[o,i]):[o,[]]}collateWordTimestamps(e,r,s){let[n,o,a]=this.combineTokensIntoWords(e,s),i=[];for(let l=0;l<n.length;++l){let u=a[l];i.push({text:n[l],timestamp:[r[u.at(0)][0],r[u.at(-1)][1]]})}return i}combineTokensIntoWords(e,r,s=`"'\u201C\xA1\xBF([{-`,n=`"'.\u3002,\uFF0C!\uFF01?\uFF1F:\uFF1A\u201D)]}\u3001`){r=r??"english";let o,a,i;return["chinese","japanese","thai","lao","myanmar"].includes(r)?[o,a,i]=this.splitTokensOnUnicode(e):[o,a,i]=this.splitTokensOnSpaces(e),this.mergePunctuations(o,a,i,s,n)}decode(e,r){let s;return r?.decode_with_timestamps?(e instanceof D&&(e=Ob(e)),s=this.decodeWithTimestamps(e,r)):s=super.decode(e,r),s}decodeWithTimestamps(e,r){let s=r?.time_precision??.02,n=this.all_special_ids.at(-1)+1,o=[[]];for(let a of e)if(a=Number(a),a>=n){let i=((a-n)*s).toFixed(2);o.push(`<|${i}|>`),o.push([])}else o[o.length-1].push(a);return o=o.map(a=>typeof a=="string"?a:super.decode(a,r)),o.join("")}splitTokensOnUnicode(e){let r=this.decode(e,{decode_with_timestamps:!0}),s="\uFFFD",n=[],o=[],a=[],i=[],l=[],u=0;for(let p=0;p<e.length;++p){let f=e[p];i.push(f),l.push(p);let m=this.decode(i,{decode_with_timestamps:!0});(!m.includes(s)||r[u+m.indexOf(s)]===s)&&(n.push(m),o.push(i),a.push(l),i=[],l=[],u+=m.length)}return[n,o,a]}splitTokensOnSpaces(e){let[r,s,n]=this.splitTokensOnUnicode(e),o=[],a=[],i=[];for(let l=0;l<r.length;++l){let u=r[l],p=s[l],f=n[l],m=p[0]>=this._tokenizer.token_to_id("<|endoftext|>"),h=u.startsWith(" "),w=u.trim(),x=KA.test(w);if(m||h||x||o.length===0)o.push(u),a.push(p),i.push(f);else{let v=o.length-1;o[v]+=u,a[v].push(...p),i[v].push(...f)}}return[o,a,i]}mergePunctuations(e,r,s,n,o){let a=structuredClone(e),i=structuredClone(r),l=structuredClone(s),u=a.length-2,p=a.length-1;for(;u>=0;)a[u].startsWith(" ")&&n.includes(a[u].trim())?(a[p]=a[u]+a[p],i[p]=ft(i[u],i[p]),l[p]=ft(l[u],l[p]),a[u]="",i[u]=[],l[u]=[]):p=u,--u;for(u=0,p=1;p<a.length;)!a[u].endsWith(" ")&&o.includes(a[p])?(a[u]+=a[p],i[u]=ft(i[u],i[p]),l[u]=ft(l[u],l[p]),a[p]="",i[p]=[],l[p]=[]):u=p,++p;return[a.filter(f=>f),i.filter(f=>f.length>0),l.filter(f=>f.length>0)]}};var Vp=class extends q{};var Hp=class extends q{return_token_type_ids=!0;constructor(e,r){super(e,r),J.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}};var ce=class{static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let[i,l]=await Sb(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a}),u=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",p=Cb[u];return p||(J.warn(`Unknown tokenizer class "${u}", attempting to construct from base class.`),p=q),new p(i,l)}};var as="https://github.com/huggingface/transformers.js/issues/new/choose";var dl="preprocessor_config.json",Mr=dl,YA="processor_config.json",QA="chat_template.jinja";var oe=class extends Ze{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,r,s){super(),this.config=e,this.components=r,this.chat_template=s}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,r={}){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,...r})}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,...r){for(let s of[this.image_processor,this.feature_extractor,this.tokenizer])if(s)return s(e,...r);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,r={}){let[s,n,o]=await Promise.all([this.uses_processor_config?ut(e,YA,!0,r):{},Promise.all(this.classes.filter(a=>a in this).map(async a=>{let i=await this[a].from_pretrained(e,r);return[a.replace(/_class$/,""),i]})).then(Object.fromEntries),this.uses_chat_template_file?M0(e,QA,!0,r):null]);return new this(s,n,o)}};var vf={};Es(vf,{ChatterboxProcessor:()=>cd,Florence2Processor:()=>Zd,Gemma3nProcessor:()=>ef,GroundingDinoProcessor:()=>tf,Idefics3Processor:()=>Ol,JinaCLIPProcessor:()=>sf,LlavaProcessor:()=>nf,MgpstrProcessor:()=>of,MoonshineProcessor:()=>af,OwlViTProcessor:()=>lf,PaliGemmaProcessor:()=>cf,Phi3VProcessor:()=>uf,PixtralProcessor:()=>pf,Processor:()=>oe,PyAnnoteProcessor:()=>df,Qwen2VLProcessor:()=>Vn,Qwen2_5_VLProcessor:()=>Hn,Qwen3VLProcessor:()=>ff,Sam2Processor:()=>Il,Sam2VideoProcessor:()=>mf,SamProcessor:()=>Xn,SmolVLMProcessor:()=>Ol,SpeechT5Processor:()=>hf,UltravoxProcessor:()=>_f,VLChatProcessor:()=>rf,VoxtralProcessor:()=>wf,Wav2Vec2Processor:()=>xf,Wav2Vec2ProcessorWithLM:()=>yf,WhisperProcessor:()=>bf});var ze=class extends Ze{constructor(e){super(),this.config=e}static async from_pretrained(e,r={}){let s=await ut(e,dl,!0,r);return new this(s)}};function Xe(t,e){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error(`${e} expects input to be a Float32Array or a Float64Array, but got ${t?.constructor?.name??typeof t} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var fl={};Es(fl,{ASTFeatureExtractor:()=>Qp,ChatterboxFeatureExtractor:()=>Jp,ClapFeatureExtractor:()=>Zp,DacFeatureExtractor:()=>Bn,EncodecFeatureExtractor:()=>Un,FeatureExtractor:()=>ze,Gemma3nAudioFeatureExtractor:()=>ed,MoonshineFeatureExtractor:()=>td,ParakeetFeatureExtractor:()=>rd,PyAnnoteFeatureExtractor:()=>Fn,SeamlessM4TFeatureExtractor:()=>sd,SnacFeatureExtractor:()=>nd,SpeechT5FeatureExtractor:()=>od,Wav2Vec2FeatureExtractor:()=>ad,WeSpeakerFeatureExtractor:()=>id,WhisperFeatureExtractor:()=>ld});var JA=kr(require("fs"),1),ZA=require("stream"),e2=require("stream/promises");async function Xp(t,e){if(se.IS_BROWSER_ENV){if(se.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");let r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=t,s.click(),s.remove(),URL.revokeObjectURL(r)}else if(se.IS_FS_AVAILABLE){let r=e.stream(),s=ZA.Readable.fromWeb(r),n=JA.default.createWriteStream(t);await(0,e2.pipeline)(s,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function Yp(t,e){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let r=await(await Yr(t)).arrayBuffer(),s=new AudioContext({sampleRate:e});typeof e>"u"&&J.warn(`No sampling rate provided, using default of ${s.sampleRate}Hz.`);let n=await s.decodeAudioData(r),o;if(n.numberOfChannels===2){let a=Math.sqrt(2),i=n.getChannelData(0),l=n.getChannelData(1);o=new Float32Array(i.length);for(let u=0;u<n.length;++u)o[u]=a*(i[u]+l[u])/2}else o=n.getChannelData(0);return o}function s2(t,e){if(t<1)return new Float64Array;if(t===1)return new Float64Array([1]);let r=1-e,s=2*Math.PI/(t-1),n=new Float64Array(t);for(let o=0;o<t;++o)n[o]=e-r*Math.cos(o*s);return n}function t2(t){return s2(t,.5)}function AL(t){return s2(t,.54)}var ML={htk:t=>2595*Math.log10(1+t/700),kaldi:t=>1127*Math.log(1+t/700),slaney:(t,e=1e3,r=15,s=27/Math.log(6.4))=>t>=e?r+Math.log(t/e)*s:3*t/200};function Pb(t,e="htk"){let r=ML[e];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?r(t):t.map(s=>r(s))}var TL={htk:t=>700*(10**(t/2595)-1),kaldi:t=>700*(Math.exp(t/1127)-1),slaney:(t,e=1e3,r=15,s=Math.log(6.4)/27)=>t>=r?e*Math.exp(s*(t-r)):200*t/3};function SL(t,e="htk"){let r=TL[e];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?r(t):t.map(s=>r(s))}function OL(t,e){let r=Float64Array.from({length:e.length-1},(a,i)=>e[i+1]-e[i]),s=Array.from({length:t.length},()=>new Array(e.length));for(let a=0;a<t.length;++a){let i=s[a];for(let l=0;l<e.length;++l)i[l]=e[l]-t[a]}let n=e.length-2,o=Array.from({length:n},()=>new Array(t.length));for(let a=0;a<t.length;++a){let i=s[a];for(let l=0;l<n;++l){let u=-i[l]/r[l],p=i[l+2]/r[l+1];o[l][a]=Math.max(0,Math.min(u,p))}}return o}function r2(t,e,r){let s=(e-t)/(r-1);return Float64Array.from({length:r},(n,o)=>t+s*o)}function kt(t,e,r,s,n,o=null,a="htk",i=!1){if(o!==null&&o!=="slaney")throw new Error('norm must be one of null or "slaney"');if(t<2)throw new Error(`Require num_frequency_bins: ${t} >= 2`);if(r>s)throw new Error(`Require min_frequency: ${r} <= max_frequency: ${s}`);let l=Pb(r,a),u=Pb(s,a),p=r2(l,u,e+2),f=SL(p,a),m;if(i){let w=n/((t-1)*2);m=Pb(Float64Array.from({length:t},(x,v)=>v*w),a),f=p}else m=r2(0,Math.floor(n/2),t);let h=OL(m,f);if(o!==null&&o==="slaney")for(let w=0;w<e;++w){let x=h[w],v=2/(f[w+2]-f[w]);for(let E=0;E<t;++E)x[E]*=v}return h}function IL(t,e,r){let s=new t.constructor(t.length+e+r),n=t.length-1;for(let o=0;o<t.length;++o)s[e+o]=t[o];for(let o=1;o<=e;++o)s[e-o]=t[vn(o,n)];for(let o=1;o<=r;++o)s[n+e+o]=t[vn(n-o,n)];return s}function n2(t,e,r,s,n){if(r<=0)throw new Error("reference must be greater than zero");if(s<=0)throw new Error("min_value must be greater than zero");r=Math.max(s,r);let o=Math.log10(r);for(let a=0;a<t.length;++a)t[a]=e*Math.log10(Math.max(s,t[a])-o);if(n!==null){if(n<=0)throw new Error("db_range must be greater than zero");let a=Se(t)[0]-n;for(let i=0;i<t.length;++i)t[i]=Math.max(t[i],a)}return t}function CL(t,e=1,r=1e-5,s=null){return n2(t,20,e,r,s)}function PL(t,e=1,r=1e-10,s=null){return n2(t,10,e,r,s)}async function St(t,e,r,s,{fft_length:n=null,power:o=1,center:a=!0,pad_mode:i="reflect",onesided:l=!0,preemphasis:u=null,preemphasis_htk_flavor:p=!0,mel_filters:f=null,mel_floor:m=1e-10,log_mel:h=null,reference:w=1,min_value:x=1e-10,db_range:v=null,remove_dc_offset:E=null,min_num_frames:A=null,max_num_frames:S=null,do_pad:T=!0,transpose:L=!1,mel_offset:P=0}={}){let k=e.length;if(n===null&&(n=r),r>n)throw Error(`frame_length (${r}) may not be larger than fft_length (${n})`);if(k!==r)throw new Error(`Length of the window (${k}) must equal frame_length (${r})`);if(s<=0)throw new Error("hop_length must be greater than zero");if(o===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(!p)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(a)switch(i){case"reflect":{let N=Math.floor((n-1)/2)+1;t=IL(t,N,N);break}case"constant":{let N=Math.floor(n/2),R=new t.constructor(t.length+2*N);R.set(t,N),t=R;break}default:throw new Error(`pad_mode="${i}" not implemented yet.`)}let F=Math.floor(1+Math.floor((t.length-r)/s));A!==null&&F<A&&(F=A);let K=l?Math.floor(n/2)+1:n,W=F,X=F;S!==null&&(S>F?T&&(X=S):X=W=S);let H=new zu(n),Y=new Float64Array(n),U=new Float64Array(H.outputBufferSize),C=new Float32Array(K*X);for(let N=0;N<W;++N){let R=N*s,ee=Math.min(t.length-R,r);ee!==r&&Y.fill(0,0,r);for(let de=0;de<ee;++de)Y[de]=t[R+de];if(E){let de=0;for(let Le=0;Le<ee;++Le)de+=Y[Le];let Fe=de/ee;for(let Le=0;Le<ee;++Le)Y[Le]-=Fe}if(u!==null){for(let de=ee-1;de>=1;--de)Y[de]-=u*Y[de-1];Y[0]*=1-u}for(let de=0;de<e.length;++de)Y[de]*=e[de];H.realTransform(U,Y);for(let de=0;de<K;++de){let Fe=de<<1;C[de*X+N]=U[Fe]**2+U[Fe+1]**2}}if(o!==null&&o!==2){let N=o/2;for(let R=0;R<C.length;++R)C[R]**=N}let ne=f.length,ae=await kb(new D("float32",f.flat(),[ne,K]),new D("float32",C,[K,X]));L&&(ae=ae.transpose(1,0));let I=ae.data;for(let N=0;N<I.length;++N)I[N]=P+Math.max(m,I[N]);if(o!==null&&h!==null){let N=Math.min(I.length,W*ne);switch(h){case"log":for(let R=0;R<N;++R)I[R]=Math.log(I[R]);break;case"log10":for(let R=0;R<N;++R)I[R]=Math.log10(I[R]);break;case"dB":if(o===1)CL(I,w,x,v);else if(o===2)PL(I,w,x,v);else throw new Error(`Cannot use log_mel option '${h}' with power ${o}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10' or 'dB'. Got '${h}'`)}}return ae}function Ot(t,e,{periodic:r=!0,frame_length:s=null,center:n=!0}={}){let o=r?t+1:t,a;switch(e){case"boxcar":a=new Float64Array(o).fill(1);break;case"hann":case"hann_window":a=t2(o);break;case"hamming":a=AL(o);break;case"povey":a=t2(o).map(i=>Math.pow(i,.85));break;default:throw new Error(`Unknown window type ${e}.`)}if(r&&(a=a.subarray(0,t)),s===null)return a;if(t>s)throw new Error(`Length of the window (${t}) may not be larger than frame_length (${s})`);return a}function LL(t,e){let r=t.reduce((o,a)=>o+a.length,0),s=new ArrayBuffer(44),n=new DataView(s);return Kp(n,0,"RIFF"),n.setUint32(4,36+r*4,!0),Kp(n,8,"WAVE"),Kp(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,3,!0),n.setUint16(22,1,!0),n.setUint32(24,e,!0),n.setUint32(28,e*4,!0),n.setUint16(32,4,!0),n.setUint16(34,32,!0),Kp(n,36,"data"),n.setUint32(40,r*4,!0),new Blob([s,...t.map(o=>o.buffer)],{type:"audio/wav"})}function Kp(t,e,r){for(let s=0;s<r.length;++s)t.setUint8(e+s,r.charCodeAt(s))}var Dn=class{constructor(e,r){this.audio=e,this.sampling_rate=r}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array(0);if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((n,o)=>n+o.length,0),r=new Float32Array(e),s=0;for(let n of this.audio)r.set(n,s),s+=n.length;return r}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),LL(e,this.sampling_rate)}async save(e){return Xp(e,this.toBlob())}};var Qp=class extends ze{constructor(e){super(e);let r=this.config.sampling_rate,s=kt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=Ot(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,r){return St(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:r,transpose:!0})}async _call(e){Xe(e,"ASTFeatureExtractor");let r=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let s=this.std*2,n=r.data;for(let o=0;o<n.length;++o)n[o]=(n[o]-this.mean)/s}return{input_values:r.unsqueeze_(0)}}};var Un=class extends ze{async _call(e){Xe(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=this.config.feature_size;if(e.length%r!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${r}).`);let s=[1,r,e.length/r];return{input_values:new D("float32",e,s)}}};var Jp=class extends ze{async _call(e){Xe(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new D("float32",e,r)}}};var Zp=class extends ze{constructor(e){super(e),this.mel_filters=kt(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=kt(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=Ot(this.config.fft_window_size,"hann")}async _get_input_mel(e,r,s,n){let o,a=!1,i=e.length-r;if(i>0)if(s==="rand_trunc"){a=!0;let l=Math.floor(Xr.random()*(i+1));e=e.subarray(l,l+r),o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${s}" not implemented`);else{if(i<0){let l=new Float64Array(r);if(l.set(e),n==="repeat")for(let u=e.length;u<r;u+=e.length)l.set(e.subarray(0,Math.min(e.length,r-u)),u);else if(n==="repeatpad")for(let u=e.length;u<-i;u+=e.length)l.set(e,u);e=l}if(s==="fusion")throw new Error(`Truncation strategy "${s}" not implemented`);o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return o.unsqueeze_(0)}async _extract_fbank_features(e,r,s=null){return St(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:r,log_mel:"dB",max_num_frames:s,do_pad:!1,transpose:!0})}async _call(e,{max_length:r=null}={}){return Xe(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,r??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}};var Bn=class extends Un{};var ed=class extends ze{constructor(e){super(e);let{fft_length:r,feature_size:s,min_frequency:n,max_frequency:o,sampling_rate:a,frame_length:i}=this.config,l=kt(Math.floor(1+r/2),s,n,o,a,null,"htk",!1);this.mel_filters=l,this.window=Ot(i,"hann")}async _extract_fbank_features(e,r){return St(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:r=48e4,truncation:s=!0,padding:n=!0,pad_to_multiple_of:o=128}={}){if(Xe(e,"Gemma3nAudioFeatureExtractor"),s&&e.length>r&&(e=e.slice(0,r)),n&&e.length%o!==0){let l=o-e.length%o,u=new Float64Array(e.length+l);u.set(e),this.config.padding_value!==0&&u.fill(this.config.padding_value,e.length),e=u}let a=await this._extract_fbank_features(e,this.config.max_length),i=qe([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:i}}};var td=class extends ze{async _call(e){Xe(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new D("float32",e,r)}}};var NL=1e-5,rd=class extends ze{constructor(e){super(e),this.config.mel_filters??=kt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");let r=Ot(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);let s=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(r,s)}async _extract_fbank_features(e){let r=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=r*e[n-1];return await St(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){Xe(e,"ParakeetFeatureExtractor");let r=await this._extract_fbank_features(e),s=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),n=r.data;n.fill(0,s*r.dims[1]);let[o,a]=r.dims,i=new Float64Array(a),l=new Float64Array(a);for(let f=0;f<s;++f){let m=f*a;for(let h=0;h<a;++h){let w=n[m+h];i[h]+=w,l[h]+=w*w}}let u=s>1?s-1:1;for(let f=0;f<a;++f){let m=i[f]/s,h=(l[f]-s*m*m)/u,x=1/(Math.sqrt(h)+NL);for(let v=0;v<s;++v){let E=v*a+f;n[E]=(n[E]-m)*x}}let p=new BigInt64Array(o);return p.fill(1n,0,s),{input_features:r.unsqueeze_(0),attention_mask:new D("int64",p,[1,o])}}};var Fn=class extends ze{async _call(e){Xe(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,1,e.length];return{input_values:new D("float32",e,r)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,r){let s=r/this.samples_to_frames(r)/this.config.sampling_rate,n=[];for(let o of e.tolist()){let a=[],i=-1;for(let l=0;l<o.length;++l){let u=Ie(o[l]),[p,f]=Se(u),[m,h]=[l,l+1];f!==i?(i=f,a.push({id:f,start:m,end:h,score:p})):(a.at(-1).end=h,a.at(-1).score+=p)}n.push(a.map(({id:l,start:u,end:p,score:f})=>({id:l,start:u*s,end:p*s,confidence:f/(p-u)})))}return n}};var sd=class extends ze{constructor(e){super(e);let r=this.config.sampling_rate,s=kt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=Ot(400,"povey",{periodic:!1})}async _extract_fbank_features(e,r){return e=e.map(s=>s*32768),St(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:r,transpose:!0})}async _call(e,{padding:r=!0,pad_to_multiple_of:s=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:o=!0}={}){Xe(e,"SeamlessM4TFeatureExtractor");let a=await this._extract_fbank_features(e,this.config.max_length);if(n){let[w,x]=a.dims,v=a.data;for(let E=0;E<x;++E){let A=0;for(let P=0;P<w;++P)A+=v[P*x+E];let S=A/w,T=0;for(let P=0;P<w;++P)T+=(v[P*x+E]-S)**2;T/=w-1;let L=Math.sqrt(T+1e-7);for(let P=0;P<w;++P){let k=P*x+E;v[k]=(v[k]-S)/L}}}let i;if(r){let[w,x]=a.dims,v=a.data,E=w%s;if(E>0){let A=new Float32Array(x*(w+E));A.set(v),A.fill(this.config.padding_value,v.length);let S=w+E;a=new D(a.type,A,[S,x]),o&&(i=new D("int64",new BigInt64Array(S),[1,S]),i.data.fill(1n,0,w))}}let[l,u]=a.dims,p=this.config.stride;if(l%p!==0)throw new Error(`The number of frames (${l}) must be a multiple of the stride (${p}).`);let m=a.view(1,Math.floor(l/p),u*p),h={input_features:m};if(o){let w=m.dims[1],x=new BigInt64Array(w);if(i){let v=i.data;for(let E=1,A=0;E<l;E+=p,++A)x[A]=v[E]}else x.fill(1n);h.attention_mask=new D("int64",x,[1,w])}return h}};var nd=class extends Bn{};var od=class extends ze{};var ad=class extends ze{_zero_mean_unit_var_norm(e){let s=e.reduce((o,a)=>o+a,0)/e.length,n=e.reduce((o,a)=>o+(a-s)**2,0)/e.length;return e.map(o=>(o-s)/Math.sqrt(n+1e-7))}async _call(e){Xe(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=e;this.config.do_normalize&&(r=this._zero_mean_unit_var_norm(r));let s=[1,r.length];return{input_values:new D("float32",r,s),attention_mask:new D("int64",new BigInt64Array(r.length).fill(1n),s)}}};var id=class extends ze{constructor(e){super(e);let r=this.config.sampling_rate,s=kt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=Ot(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(r=>r*32768),St(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){Xe(e,"WeSpeakerFeatureExtractor");let r=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let s=r.mean(1).data,n=r.data,[o,a,i]=r.dims;for(let l=0;l<o;++l){let u=l*a*i,p=l*i;for(let f=0;f<a;++f){let m=u+f*i;for(let h=0;h<i;++h)n[m+h]-=s[p+h]}}}return{input_features:r}}};var ld=class extends ze{constructor(e){super(e),this.config.mel_filters??=kt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=Ot(this.config.n_fft,"hann")}async _extract_fbank_features(e){let r=await St(e,this.window,this.config.n_fft,this.config.hop_length,{power:2,mel_filters:this.config.mel_filters,log_mel:"log10",max_num_frames:Math.min(Math.floor(e.length/this.config.hop_length),this.config.nb_max_frames)}),s=r.data,n=Se(s)[0];for(let o=0;o<s.length;++o)s[o]=(Math.max(s[o],n-8)+4)/4;return r}async _call(e,{max_length:r=null}={}){Xe(e,"WhisperFeatureExtractor");let s,n=r??this.config.n_samples;return e.length>n?(e.length>this.config.n_samples&&J.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`."),s=e.slice(0,n)):(s=new Float32Array(n),s.set(e)),{input_features:(await this._extract_fbank_features(s)).unsqueeze_(0)}}};var et=class{static async from_pretrained(e,r={}){let s=await ut(e,dl,!0,r),n=s.feature_extractor_type,o=fl[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${as}.`);return new o(s)}};var cd=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;async _call(e,r=null){let s=this.tokenizer(e),n=r?await this.feature_extractor(r):{};return{...s,...n}}};var ud=kr(require("sharp"),1);var Bs,o2,is;if(se.IS_WEB_ENV)Bs=(t,e)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(t,e)},is=self.createImageBitmap,o2=self.ImageData;else if(ud.default)is=async t=>{let r=(await t.metadata()).channels,{data:s,info:n}=await t.rotate().raw().toBuffer({resolveWithObject:!0}),o=new Ke(new Uint8ClampedArray(s),n.width,n.height,n.channels);return r!==void 0&&r!==n.channels&&o.convert(r),o};else throw new Error("Unable to load image processing library.");var zL={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},$L=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),Ke=class t{constructor(e,r,s,n){this.data=e,this.width=r,this.height=s,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof t)return e;if(typeof e=="string"||e instanceof URL)return await this.fromURL(e);if(e instanceof Blob)return await this.fromBlob(e);if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return this.fromCanvas(e);throw new Error(`Unsupported input type: ${typeof e}`)}static fromCanvas(e){if(!se.IS_WEB_ENV)throw new Error("fromCanvas() is only supported in browser environments.");let s=e.getContext("2d").getImageData(0,0,e.width,e.height).data;return new t(s,e.width,e.height,4)}static async fromURL(e){let r=await Yr(e);if(r.status!==200)throw new Error(`Unable to read image from "${e}" (${r.status} ${r.statusText})`);let s=await r.blob();return this.fromBlob(s)}static async fromBlob(e){if(se.IS_WEB_ENV){let r=await is(e),s=Bs(r.width,r.height).getContext("2d");return s.drawImage(r,0,0),new this(s.getImageData(0,0,r.width,r.height).data,r.width,r.height,4)}else{let r=(0,ud.default)(await e.arrayBuffer());return await is(r)}}static fromTensor(e,r="CHW"){if(e.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if(r==="CHW")e=e.transpose(1,2,0);else if(r!=="HWC")throw new Error(`Unsupported channel format: ${r}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new t(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw new Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let r=0,s=0;r<this.data.length;r+=this.channels){let n=this.data[r],o=this.data[r+1],a=this.data[r+2];e[s++]=Math.round(.2989*n+.587*o+.114*a)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,1)}rgb(){if(this.channels===3)return this;let e=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let r=0,s=0;r<this.data.length;++r)e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=this.data[r];break;case 4:for(let r=0,s=0;r<this.data.length;r+=4)e[s++]=this.data[r],e[s++]=this.data[r+1],e[s++]=this.data[r+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,3)}rgba(){if(this.channels===4)return this;let e=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let r=0,s=0;r<this.data.length;++r)e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=255;break;case 3:for(let r=0,s=0;r<this.data.length;r+=3)e[s++]=this.data[r],e[s++]=this.data[r+1],e[s++]=this.data[r+2],e[s++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,4)}putAlpha(e){if(e.width!==this.width||e.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${e.channels}`);let r=this.data,s=e.data,n=this.width*this.height;if(this.channels===3){let o=new Uint8ClampedArray(n*4);for(let a=0,i=0,l=0;a<n;++a)o[l++]=r[i++],o[l++]=r[i++],o[l++]=r[i++],o[l++]=s[a];return this._update(o,this.width,this.height,4)}else if(this.channels===4){for(let o=0;o<n;++o)r[4*o+3]=s[o];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(e,r,{resample:s=2}={}){if(this.width===e&&this.height===r)return this;let n=zL[s]??s,o=_0(e),a=_0(r);if(o&&a)return this;if(o?e=r/this.height*this.width:a&&(r=e/this.width*this.height),se.IS_WEB_ENV){let i=this.channels,l=this.toCanvas(),u=Bs(e,r).getContext("2d");return u.drawImage(l,0,0,e,r),new t(u.getImageData(0,0,e,r).data,e,r,4).convert(i)}else{let i=this.toSharp();switch(n){case"box":case"hamming":(n==="box"||n==="hamming")&&(J.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":i=i.affine([e/this.width,0,0,r/this.height],{interpolator:n});break;case"lanczos":i=i.resize({width:e,height:r,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await is(i)}}async pad([e,r,s,n]){if(e=Math.max(e,0),r=Math.max(r,0),s=Math.max(s,0),n=Math.max(n,0),e===0&&r===0&&s===0&&n===0)return this;if(se.IS_WEB_ENV){let o=this.channels,a=this.toCanvas(),i=this.width+e+r,l=this.height+s+n,u=Bs(i,l).getContext("2d");return u.drawImage(a,0,0,this.width,this.height,e,s,this.width,this.height),new t(u.getImageData(0,0,i,l).data,i,l,4).convert(o)}else{let o=this.toSharp().extend({left:e,right:r,top:s,bottom:n});return await is(o)}}async crop([e,r,s,n]){if(e=Math.max(e,0),r=Math.max(r,0),s=Math.min(s,this.width-1),n=Math.min(n,this.height-1),e===0&&r===0&&s===this.width-1&&n===this.height-1)return this;let o=s-e+1,a=n-r+1;if(se.IS_WEB_ENV){let i=this.channels,l=this.toCanvas(),u=Bs(o,a).getContext("2d");return u.drawImage(l,e,r,o,a,0,0,o,a),new t(u.getImageData(0,0,o,a).data,o,a,4).convert(i)}else{let i=this.toSharp().extract({left:e,top:r,width:o,height:a});return await is(i)}}async center_crop(e,r){if(this.width===e&&this.height===r)return this;let s=(this.width-e)/2,n=(this.height-r)/2;if(se.IS_WEB_ENV){let o=this.channels,a=this.toCanvas(),i=Bs(e,r).getContext("2d"),l=0,u=0,p=0,f=0;return s>=0?l=s:p=-s,n>=0?u=n:f=-n,i.drawImage(a,l,u,e,r,p,f,e,r),new t(i.getImageData(0,0,e,r).data,e,r,4).convert(o)}else{let o=this.toSharp();if(s>=0&&n>=0)o=o.extract({left:Math.floor(s),top:Math.floor(n),width:e,height:r});else if(s<=0&&n<=0){let a=Math.floor(-n),i=Math.floor(-s);o=o.extend({top:a,left:i,right:e-this.width-i,bottom:r-this.height-a})}else{let a=[0,0],i=0;n<0?(a[0]=Math.floor(-n),a[1]=r-this.height-a[0]):i=Math.floor(n);let l=[0,0],u=0;s<0?(l[0]=Math.floor(-s),l[1]=e-this.width-l[0]):u=Math.floor(s),o=o.extend({top:a[0],bottom:a[1],left:l[0],right:l[1]}).extract({left:u,top:i,width:e,height:r})}return await is(o)}}async toBlob(e="image/png",r=1){if(!se.IS_WEB_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:e,quality:r})}toTensor(e="CHW"){let r=new D("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!=="HWC")if(e==="CHW")r=r.permute(2,0,1);else throw new Error(`Unsupported channel format: ${e}`);return r}toCanvas(){if(!se.IS_WEB_ENV)throw new Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),r=Bs(e.width,e.height),s=new o2(e.data,e.width,e.height);return r.getContext("2d").putImageData(s,0,0),r}split(){let{data:e,width:r,height:s,channels:n}=this,o=e.constructor,a=e.length/n,i=Array.from({length:n},()=>new o(a));for(let l=0;l<a;++l){let u=n*l;for(let p=0;p<n;++p)i[p][l]=e[u+p]}return i.map(l=>new t(l,r,s,1))}_update(e,r,s,n=null){return this.data=e,this.width=r,this.height=s,n!==null&&(this.channels=n),this}clone(){return new t(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(se.IS_WEB_ENV){if(se.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");let r=e.split(".").pop().toLowerCase(),s=$L.get(r)??"image/png",n=await this.toBlob(s);return Xp(e,n)}else if(se.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(se.IS_WEB_ENV)throw new Error("toSharp() is only supported in server-side environments.");return(0,ud.default)(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},a2=Ke.read.bind(Ke);function i2(t,e,r=0,s=null){let n=t/e,o=cE(n)*e;return s!==null&&o>s&&(o=Math.floor(n)*e),o<r&&(o=Math.ceil(n)*e),o}function Lb([t,e],r){return[Math.max(Math.floor(t/r),1)*r,Math.max(Math.floor(e/r),1)*r]}function Nb([t,e,r,s]){return[t-r/2,e-s/2,t+r/2,e+s/2]}function ls(t,e=.5,r=null,s=!1){let n=t.logits,o=t.pred_boxes,[a,i,l]=n.dims;if(r!==null&&r.length!==a)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let u=[];for(let p=0;p<a;++p){let f=r!==null?r[p]:null,m={boxes:[],classes:[],scores:[]},h=n[p],w=o[p];for(let x=0;x<i;++x){let v=h[x],E=[],A;if(s){A=v.sigmoid().data;for(let S=0;S<A.length;++S)A[S]>e&&E.push(S)}else{let S=Se(v.data)[1];if(S===l-1||(A=Ie(v.data),A[S]<e))continue;E.push(S)}for(let S of E){let T=w[x].data;T=Nb(T),f!==null&&(T=T.map((L,P)=>L*f[(P+1)%2])),m.boxes.push(T),m.classes.push(S),m.scores.push(A[S])}}u.push(m)}return u}function pd(t,e=null){let r=t.logits,s=r.dims[0];if(e!==null&&e.length!==s)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let n=[];for(let o=0;o<s;++o){let a=e!==null?e[o]:null,i=r[o];a!==null&&(i=tp(i,a,"bilinear",!1));let[l,u]=a??i.dims.slice(-2),p=new D("int32",new Int32Array(l*u),[l,u]),f=i[0].data,m=p.data;for(let x=1;x<i.dims[0];++x){let v=i[x].data;for(let E=0;E<v.length;++E)v[E]>f[E]&&(f[E]=v[E],m[E]=x)}let h=new Array(i.dims[0]);for(let x=0;x<m.length;++x){let v=m[x];h[v]=v}let w=h.filter(x=>x!==void 0);n.push({segmentation:p,labels:w})}return n}function RL(t,e,r,s){let n=[],o=[],a=[];for(let i=0;i<t.dims[0];++i){let l=t[i],u=e[i],p=Se(l.data)[1];if(p===s)continue;let m=Ie(l.data)[p];m>r&&(n.push(u),o.push(m),a.push(p))}return[n,o,a]}function DL(t,e,r,s=.5,n=.8){let o=[],a=0,i=0,l=e[r].data;for(let p=0;p<t.length;++p)t[p]===r&&(o.push(p),++a),l[p]>=s&&++i;let u=a>0&&i>0;return u&&(u=a/i>n),[u,o]}function UL(t,e,r,s,n,o=null,a=null){let[i,l]=a??t[0].dims,u=new D("int32",new Int32Array(i*l),[i,l]),p=[];if(a!==null)for(let x=0;x<t.length;++x)t[x]=tp(t[x],a,"bilinear",!1);let f=new Int32Array(t[0].data.length),m=new Float32Array(t[0].data.length);for(let x=0;x<t.length;++x){let v=e[x],E=t[x].data;for(let A=0;A<E.length;++A)E[A]*=v,E[A]>m[A]&&(f[A]=x,m[A]=E[A])}let h=0,w=u.data;for(let x=0;x<r.length;++x){let v=r[x],[E,A]=DL(f,t,x,s,n);if(E){++h;for(let S of A)w[S]=h;p.push({id:h,label_id:v,score:e[x]})}}return[u,p]}function dd(t,e=.5,r=.5,s=.8,n=null,o=null){n===null&&(J.warn("`label_ids_to_fuse` unset. No instance will be fused."),n=new Set);let a=t.class_queries_logits??t.logits,l=(t.masks_queries_logits??t.pred_masks).sigmoid(),[u,p,f]=a.dims;if(f-=1,o!==null&&o.length!==u)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let m=[];for(let h=0;h<u;++h){let w=o!==null?o[h]:null,x=a[h],v=l[h],[E,A,S]=RL(x,v,e,f);if(S.length===0){let[P,k]=w??v.dims.slice(-2),F=new D("int32",new Int32Array(P*k).fill(-1),[P,k]);m.push({segmentation:F,segments_info:[]});continue}let[T,L]=UL(E,A,S,r,s,n,w);m.push({segmentation:T,segments_info:L})}return m}function fd(t,e=.5,r=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var V=class extends Ze{constructor(e){super(),this.image_mean=e.image_mean??e.mean,this.image_std=e.image_std??e.std,this.resample=e.resample??2,this.do_rescale=e.do_rescale??!0,this.rescale_factor=e.rescale_factor??1/255,this.do_normalize=e.do_normalize,this.do_thumbnail=e.do_thumbnail,this.size=e.size??e.image_size,this.do_resize=e.do_resize??this.size!==void 0,this.size_divisibility=e.size_divisibility??e.size_divisor,this.do_center_crop=e.do_center_crop,this.crop_size=e.crop_size,this.do_convert_rgb=e.do_convert_rgb??!0,this.do_crop_margin=e.do_crop_margin,this.pad_size=e.pad_size,this.do_pad=e.do_pad,this.min_pixels=e.min_pixels,this.max_pixels=e.max_pixels,this.do_pad&&!this.pad_size&&this.size&&this.size.width!==void 0&&this.size.height!==void 0&&(this.pad_size=this.size),this.do_flip_channel_order=e.do_flip_channel_order??!1,this.config=e}async thumbnail(e,r,s=2){let n=e.height,o=e.width,a=r.height,i=r.width,l=Math.min(n,a),u=Math.min(o,i);return l===n&&u===o?e:(n>o?u=Math.floor(o*l/n):o>n&&(l=Math.floor(n*u/o)),await e.resize(u,l,{resample:s}))}async crop_margin(e,r=200){let s=e.clone().grayscale(),n=Yi(s.data)[0],a=Se(s.data)[0]-n;if(a===0)return e;let i=r/255,l=s.width,u=s.height,p=0,f=0,m=s.data;for(let h=0;h<s.height;++h){let w=h*s.width;for(let x=0;x<s.width;++x)(m[w+x]-n)/a<i&&(l=Math.min(l,x),u=Math.min(u,h),p=Math.max(p,x),f=Math.max(f,h))}return e=await e.crop([l,u,p,f]),e}pad_image(e,r,s,{mode:n="constant",center:o=!1,constant_values:a=0}={}){let[i,l,u]=r,p,f;if(typeof s=="number"?(p=s,f=s):s==="square"?p=f=Math.max(i,l):(p=s.width,f=s.height),p!==l||f!==i){let m=new Float32Array(p*f*u);if(Array.isArray(a))for(let x=0;x<m.length;++x)m[x]=a[x%u];else a!==0&&m.fill(a);let[h,w]=o?[Math.floor((p-l)/2),Math.floor((f-i)/2)]:[0,0];for(let x=0;x<i;++x){let v=(x+w)*p,E=x*l;for(let A=0;A<l;++A){let S=(v+A+h)*u,T=(E+A)*u;for(let L=0;L<u;++L)m[S+L]=e[T+L]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let x=i-1,v=l-1;for(let E=0;E<f;++E){let A=E*p,S=vn(E,x)*l;for(let T=0;T<p;++T){if(E<i&&T<l)continue;let L=(A+T)*u,P=(S+vn(T,v))*u;for(let k=0;k<u;++k)m[L+k]=e[P+k]}}}e=m,r=[f,p,u]}return[e,r]}rescale(e){for(let r=0;r<e.length;++r)e[r]=this.rescale_factor*e[r]}get_resize_output_image_size(e,r){let[s,n]=e.size,o,a;if(this.do_thumbnail){let{height:i,width:l}=r;o=Math.min(i,l)}else Number.isInteger(r)?(o=r,a=this.config.max_size??o):r!==void 0&&(o=r.shortest_edge,a=r.longest_edge);if(o!==void 0||a!==void 0){let i=o===void 0?1:Math.max(o/s,o/n),l=s*i,u=n*i,p=a===void 0?1:Math.min(a/l,a/u),f=Math.floor(Number((l*p).toFixed(2))),m=Math.floor(Number((u*p).toFixed(2)));return this.size_divisibility!==void 0&&([f,m]=Lb([f,m],this.size_divisibility)),[f,m]}else if(r!==void 0&&r.width!==void 0&&r.height!==void 0){let i=r.width,l=r.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let u=l/n,p=i/s;Math.abs(1-p)<Math.abs(1-u)?u=p:p=u,l=i2(u*n,this.config.ensure_multiple_of),i=i2(p*s,this.config.ensure_multiple_of)}return[i,l]}else{if(this.size_divisibility!==void 0)return Lb([s,n],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(r)}`)}}async resize(e){let[r,s]=this.get_resize_output_image_size(e,this.size);return await e.resize(r,s,{resample:this.resample})}async preprocess(e,{do_normalize:r=null,do_pad:s=null,do_convert_rgb:n=null,do_convert_grayscale:o=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[i,l]=e.size;if(n??this.do_convert_rgb?e=e.rgb():o&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let h,w;Number.isInteger(this.crop_size)?(h=this.crop_size,w=this.crop_size):(h=this.crop_size.width,w=this.crop_size.height),e=await e.center_crop(h,w)}let u=[e.height,e.width],p=Float32Array.from(e.data),f=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(p),r??this.do_normalize){let h=this.image_mean;Array.isArray(this.image_mean)||(h=new Array(e.channels).fill(h));let w=this.image_std;if(Array.isArray(this.image_std)||(w=new Array(e.channels).fill(w)),h.length!==e.channels||w.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${h.length}) and \`image_std\` (${w.length}) must match the number of channels in the image (${e.channels}).`);for(let x=0;x<p.length;x+=e.channels)for(let v=0;v<e.channels;++v)p[x+v]=(p[x+v]-h[v])/w[v]}if(s??this.do_pad){if(this.pad_size)[p,f]=this.pad_image(p,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){let[h,w]=Lb([f[1],f[0]],this.size_divisibility);[p,f]=this.pad_image(p,f,{width:h,height:w})}}if(a??this.do_flip_channel_order){if(f[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let h=0;h<p.length;h+=3){let w=p[h];p[h]=p[h+2],p[h+2]=w}}let m=new D("float32",p,f).permute(2,0,1);return{original_size:[l,i],reshaped_input_size:u,pixel_values:m}}async _call(e,...r){Array.isArray(e)||(e=[e]);let s=await Promise.all(e.map(o=>this.preprocess(o)));return{pixel_values:$t(s.map(o=>o.pixel_values),0),original_sizes:s.map(o=>o.original_size),reshaped_input_sizes:s.map(o=>o.reshaped_input_size)}}static async from_pretrained(e,r={}){let s=await ut(e,Mr,!0,r);return new this(s)}};var qn={};Es(qn,{BeitFeatureExtractor:()=>md,BitImageProcessor:()=>hd,CLIPFeatureExtractor:()=>gd,CLIPImageProcessor:()=>ml,ChineseCLIPFeatureExtractor:()=>_d,ConvNextFeatureExtractor:()=>wd,ConvNextImageProcessor:()=>hl,DINOv3ViTImageProcessor:()=>bd,DPTFeatureExtractor:()=>kd,DPTImageProcessor:()=>wl,DeiTFeatureExtractor:()=>xd,DeiTImageProcessor:()=>_l,DetrFeatureExtractor:()=>yd,DetrImageProcessor:()=>gl,DonutFeatureExtractor:()=>vd,DonutImageProcessor:()=>Fs,EfficientNetImageProcessor:()=>Ed,GLPNFeatureExtractor:()=>Ad,GroundingDinoImageProcessor:()=>Md,Idefics3ImageProcessor:()=>xl,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,JinaCLIPImageProcessor:()=>Sd,LlavaOnevisionImageProcessor:()=>Od,Mask2FormerImageProcessor:()=>Cd,MaskFormerFeatureExtractor:()=>Id,MaskFormerImageProcessor:()=>js,MobileNetV1FeatureExtractor:()=>Pd,MobileNetV1ImageProcessor:()=>yl,MobileNetV2FeatureExtractor:()=>Ld,MobileNetV2ImageProcessor:()=>bl,MobileNetV3FeatureExtractor:()=>Nd,MobileNetV3ImageProcessor:()=>vl,MobileNetV4FeatureExtractor:()=>zd,MobileNetV4ImageProcessor:()=>kl,MobileViTFeatureExtractor:()=>$d,MobileViTImageProcessor:()=>El,NougatImageProcessor:()=>Rd,OwlViTFeatureExtractor:()=>Dd,OwlViTImageProcessor:()=>Gs,Owlv2ImageProcessor:()=>Ud,Phi3VImageProcessor:()=>Bd,PixtralImageProcessor:()=>Fd,PvtImageProcessor:()=>jd,Qwen2VLImageProcessor:()=>Gd,RTDetrImageProcessor:()=>qd,Sam2ImageProcessor:()=>Gn,Sam3ImageProcessor:()=>Gn,SamImageProcessor:()=>Gn,SapiensFeatureExtractor:()=>Wd,SapiensImageProcessor:()=>Al,SegformerFeatureExtractor:()=>Vd,SegformerImageProcessor:()=>Ml,SiglipImageProcessor:()=>Hd,SmolVLMImageProcessor:()=>xl,Swin2SRImageProcessor:()=>Xd,VLMImageProcessor:()=>Td,ViTFeatureExtractor:()=>Kd,ViTImageProcessor:()=>Tl,VitMatteImageProcessor:()=>Yd,VitPoseImageProcessor:()=>Qd,YolosFeatureExtractor:()=>Jd,YolosImageProcessor:()=>Sl});var md=class extends V{};var hd=class extends V{};var _d=class extends V{};var ml=class extends V{},gd=class extends ml{};var hl=class extends V{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let r=this.size?.shortest_edge;if(r===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(r<384){let s=Math.floor(r/this.crop_pct),[n,o]=this.get_resize_output_image_size(e,{shortest_edge:s});e=await e.resize(n,o,{resample:this.resample}),e=await e.center_crop(r,r)}else e=await e.resize(r,r,{resample:this.resample});return e}},wd=class extends hl{};var _l=class extends V{},xd=class extends _l{};var gl=class extends V{async _call(e){let r=await super._call(e),s=[r.pixel_values.dims[0],64,64],n=qe(s,1n);return{...r,pixel_mask:n}}post_process_object_detection(...e){return ls(...e)}post_process_panoptic_segmentation(...e){return dd(...e)}post_process_instance_segmentation(...e){return fd(...e)}},yd=class extends gl{};var bd=class extends V{};var Fs=class extends V{pad_image(e,r,s,n={}){let[o,a,i]=r,l=this.image_mean;Array.isArray(this.image_mean)||(l=new Array(i).fill(l));let u=this.image_std;Array.isArray(u)||(u=new Array(i).fill(l));let p=l.map((f,m)=>-f/u[m]);return super.pad_image(e,r,s,{center:!0,constant_values:p,...n})}},vd=class extends Fs{};var wl=class extends V{},kd=class extends wl{};var Ed=class extends V{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(r=>r*r))}};var Ad=class extends V{};var Md=class extends V{async _call(e){let r=await super._call(e),s=r.pixel_values.dims,n=st([s[0],s[2],s[3]]);return{...r,pixel_mask:n}}};var xl=class extends V{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,r){let[s,n]=e.dims.slice(-2),o=n/s;return n>=s?(n=Math.ceil(n/r)*r,s=Math.floor(n/o),s=Math.ceil(s/r)*r):(s=Math.ceil(s/r)*r,n=Math.floor(s*o),n=Math.ceil(n/r)*r),{height:s,width:n}}async _call(e,{do_image_splitting:r=null,return_row_col_info:s=!1}={}){let n;if(!Array.isArray(e))n=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?n=e:n=[e]}let o=[],a=[],i=[],l=[],u=[];for(let E of n){let A=await Promise.all(E.map(L=>this.preprocess(L)));l.push(...A.map(L=>L.original_size)),u.push(...A.map(L=>L.reshaped_input_size)),A.forEach(L=>L.pixel_values.unsqueeze_(0));let{longest_edge:S}=this.max_image_size,T;if(r??this.do_image_splitting){let L=new Array(A.length),P=new Array(A.length);T=await Promise.all(A.map(async(k,F)=>{let K=this.get_resize_for_vision_encoder(k.pixel_values,S),W=await zt(k.pixel_values,{size:[K.height,K.width]}),{frames:X,num_splits_h:H,num_splits_w:Y}=await this.split_image(W,this.max_image_size);return L[F]=H,P[F]=Y,Ee(X,0)})),a.push(L),i.push(P)}else{let L=[S,S];T=await Promise.all(A.map(P=>zt(P.pixel_values,{size:L}))),a.push(new Array(A.length).fill(0)),i.push(new Array(A.length).fill(0))}o.push(Ee(T,0))}let p=o.length,[f,m,h,w]=o[0].dims,x,v;if(p===1)x=o[0].unsqueeze_(0),v=qe([p,f,h,w],!0);else{let E=Math.max(...o.map(T=>T.dims.at(0)));v=qe([p,E,h,w],!0);let A=v.data,S=E*h*w;for(let T=0;T<p;++T){let L=o[T].dims[0];if(L<E){o[T]=Ee([o[T],qe([E-L,m,h,w],0)],0);let P=T*S+L*h*w,k=(T+1)*S;A.fill(!1,P,k)}}x=$t(o,0)}return{pixel_values:x,pixel_attention_mask:v,original_sizes:l,reshaped_input_sizes:u,...s?{rows:a,cols:i}:{}}}async split_image(e,{longest_edge:r}){let s=r,n=r,o=[],[a,i]=e.dims.slice(-2),l=0,u=0;if(a>s||i>n){l=Math.ceil(a/s),u=Math.ceil(i/n);let p=Math.ceil(a/l),f=Math.ceil(i/u);for(let w=0;w<l;++w)for(let x=0;x<u;++x){let v,E,A,S;w===l-1?(E=a-p,S=a):(E=w*p,S=(w+1)*p),x===u-1?(v=i-f,A=i):(v=x*f,A=(x+1)*f);let P=await ll(e,[E,v],[S,A],[2,3]);o.push(P)}let m=s,h=n;(a!==m||i!==h)&&(e=await zt(e,{size:[m,h]}))}return o.push(e),{frames:o,num_splits_h:l,num_splits_w:u}}};var Td=class extends V{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(r=>r*this.rescale_factor)}pad_image(e,r,s,n){return super.pad_image(e,r,s,{constant_values:this.constant_values,center:!0,...n})}};var Sd=class extends V{constructor(e){let{resize_mode:r,fill_color:s,interpolation:n,size:o,...a}=e,i=r==="squash"?{width:o,height:o}:r==="shortest"?{shortest_edge:o}:{longest_edge:o},l=n==="bicubic"?3:2;super({...a,size:i,resample:l,do_center_crop:!0,crop_size:o,do_normalize:!0})}};var Od=class extends V{};var js=class extends V{post_process_panoptic_segmentation(...e){return dd(...e)}post_process_instance_segmentation(...e){return fd(...e)}},Id=class extends js{};var Cd=class extends js{};var yl=class extends V{},Pd=class extends yl{};var bl=class extends V{},Ld=class extends bl{};var vl=class extends V{},Nd=class extends vl{};var kl=class extends V{},zd=class extends kl{};var El=class extends V{},$d=class extends El{};var Rd=class extends Fs{};var Gs=class extends V{post_process_object_detection(...e){return ls(...e)}},Dd=class extends Gs{};var Ud=class extends Gs{};var Rt=336,BL=[2,3],{ceil:zb,floor:jn,sqrt:$b}=Math,Bd=class extends V{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,r){let{num_img_tokens:s}=this.config;return jn((jn(r/Rt)*jn(e/Rt)+1)*s+1+(jn(r/Rt)+1)*$b(s))}get_resize_output_image_size(e,r){let s=this._num_crops,[n,o]=e.size,a=n/o,i=1;for(;i*Math.ceil(i/a)<=s;)i+=1;i-=1;let l=Math.floor(i*336),u=Math.floor(l/a);return[l,u]}pad_image(e,r,s,n={}){let[o,a]=r,i=Rt*zb(o/Rt),l=Rt*zb(a/Rt),u=[1,1,1].map((p,f)=>(p-this.image_mean[f])/this.image_std[f]);return super.pad_image(e,r,{width:l,height:i},{center:!0,constant_values:u,...n})}async _call(e,{num_crops:r=null}={}){if(this._num_crops=r??=this.config.num_crops,r<4||$b(r)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);let s=e.length,n=await Promise.all(e.map(m=>this.preprocess(m))),o=n.map(m=>m.original_size),a=n.map(m=>m.reshaped_input_size),i=[];for(let{pixel_values:m}of n){m.unsqueeze_(0);let[h,w]=m.dims.slice(-2),x=await zt(m,{size:[Rt,Rt],mode:"bicubic"});if(r>0){let v=[],E=$b(r),A=jn(w/E),S=jn(h/E);for(let L=0;L<E;++L)for(let P=0;P<E;++P){let k,F,K,W;L===E-1?(F=h-S,W=h):(F=L*S,W=(L+1)*S),P===E-1?(k=w-A,K=w):(k=P*A,K=(P+1)*A);let Y=await ll(m,[F,k],[W,K],BL);v.push(Y)}let T=await zt(Ee(v,0),{size:[Rt,Rt],mode:"bicubic"});i.push(Ee([x,T],0))}else i.push(x)}let l=$t(i,0),u=a.map(m=>m.map(h=>Rt*zb(h/Rt))),p=new D("int64",u.flat(),[s,2]),f=u.map(([m,h])=>this.calc_num_image_tokens_from_image_size(h,m));return{pixel_values:l,original_sizes:o,reshaped_input_sizes:a,image_sizes:p,num_img_tokens:f}}};var Fd=class extends V{get_resize_output_image_size(e,r){let{longest_edge:s}=r;if(s===void 0)throw new Error("size must contain 'longest_edge'");let[n,o]=e.size,a=Math.max(n,o)/s,i=n,l=o;a>1&&(i=Math.floor(n/a),l=Math.floor(o/a));let{patch_size:u,spatial_merge_size:p}=this.config;if(!p)throw new Error("config must contain 'spatial_merge_size'");let f=u*p,m=Math.floor((i-1)/f)+1,h=Math.floor((l-1)/f)+1;return[m*f,h*f]}};var jd=class extends V{};function FL(t,e,r=28,s=3136,n=784*1280){if(t<r||e<r)throw new Error(`height:${t} or width:${e} must be larger than factor:${r}`);if(Math.max(t,e)/Math.min(t,e)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(t,e)/Math.min(t,e)}`);let o=Math.round(t/r)*r,a=Math.round(e/r)*r;if(o*a>n){let i=Math.sqrt(t*e/n);o=Math.floor(t/i/r)*r,a=Math.floor(e/i/r)*r}else if(o*a<s){let i=Math.sqrt(s/(t*e));o=Math.ceil(t*i/r)*r,a=Math.ceil(e*i/r)*r}return[o,a]}var Gd=class extends V{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,r){let s=this.patch_size*this.merge_size;return FL(e.height,e.width,s,this.min_pixels,this.max_pixels)}async _call(e,...r){let{pixel_values:s,original_sizes:n,reshaped_input_sizes:o}=await super._call(e,...r),a=s,{temporal_patch_size:i,merge_size:l,patch_size:u}=this.config;a.dims[0]===1&&(a=Ee(Array.from({length:i},()=>a),0));let p=a.dims[0]/i,f=a.dims[1],m=Math.floor(a.dims[2]/u),h=Math.floor(a.dims[3]/u),w=a.view(p,i,f,Math.floor(m/l),l,u,Math.floor(h/l),l,u).permute(0,3,6,4,7,2,1,5,8).view(p*m*h,f*i*u*u),x=new D("int64",[p,m,h],[1,3]);return{pixel_values:w,image_grid_thw:x,original_sizes:n,reshaped_input_sizes:o}}};var qd=class extends V{post_process_object_detection(...e){return ls(...e)}};var Gn=class extends V{reshape_input_points(e,r,s,n=!1){e=structuredClone(e);let o=g0(e);if(o.length===3)n||(o=[1,...o]),e=[e];else if(o.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let a=0;a<e.length;++a){let[i,l]=r[a],[u,p]=s[a],f=[p/l,u/i];for(let m=0;m<e[a].length;++m)for(let h=0;h<e[a][m].length;++h)for(let w=0;w<e[a][m][h].length;++w)e[a][m][h][w]*=f[w%2]}return new D("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,r){let s=g0(e);if(s.length===2)s=[1,...s],e=[e];else if(s.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(s.some((n,o)=>n!==r.dims[o]))throw Error(`The first ${s.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new D("int64",e.flat(1/0).map(BigInt),s)}async _call(e,{input_points:r=null,input_labels:s=null,input_boxes:n=null}={}){let o=await super._call(e);if(r&&(o.input_points=this.reshape_input_points(r,o.original_sizes,o.reshaped_input_sizes)),s){if(!o.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");o.input_labels=this.add_input_labels(s,o.input_points)}return n&&(o.input_boxes=this.reshape_input_points(n,o.original_sizes,o.reshaped_input_sizes,!0)),o}async post_process_masks(e,r,s,{mask_threshold:n=0,binarize:o=!0,pad_size:a=null}={}){let i=[];a=a??this.pad_size??this.size;let l=[a.height,a.width];for(let u=0;u<r.length;++u){let p=r[u],f=s[u],m=await zt(e[u],{mode:"bilinear",size:l});if(m=m.slice(null,null,[0,f[0]],[0,f[1]]),m=await zt(m,{mode:"bilinear",size:p}),o){let h=m.data,w=new Uint8Array(h.length);for(let x=0;x<h.length;++x)h[x]>n&&(w[x]=1);m=new D("bool",w,m.dims)}i.push(m)}return i}generate_crop_boxes(e,r,{crop_n_layers:s=0,overlap_ratio:n=512/1500,points_per_crop:o=32,crop_n_points_downscale_factor:a=1}={}){}};var Al=class extends V{post_process_semantic_segmentation(...e){return pd(...e)}},Wd=class extends Al{};var Ml=class extends V{post_process_semantic_segmentation(...e){return pd(...e)}},Vd=class extends Ml{};var Hd=class extends V{};var Xd=class extends V{pad_image(e,r,s,n={}){let[o,a,i]=r;return super.pad_image(e,r,{width:a+(s-a%s)%s,height:o+(s-o%s)%s},{mode:"symmetric",center:!1,constant_values:-1,...n})}};var Tl=class extends V{},Kd=class extends Tl{};var Yd=class extends V{async _call(e,r){Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]);let s=await Promise.all(e.map(a=>this.preprocess(a))),n=await Promise.all(r.map(a=>this.preprocess(a,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:$t(s.map((a,i)=>Ee([a.pixel_values,n[i].pixel_values],0)),0),original_sizes:s.map(a=>a.original_size),reshaped_input_sizes:s.map(a=>a.reshaped_input_size)}}};var Qd=class extends V{post_process_pose_estimation(e,r,{threshold:s=null}={}){let n=e.tolist(),[o,a,i,l]=e.dims,u=[];for(let p=0;p<o;++p){let f=n[p],m=r[p],h=[];for(let w=0;w<m.length;++w){let x=m[w],v=[],E=[],A=[],S=x.at(-2)/l,T=x.at(-1)/i;for(let L=0;L<f.length;++L){let[P,k]=[0,0],F=0,K=-1/0,W=f[L];for(let H=0;H<W.length;++H){let Y=W[H];for(let U=0;U<Y.length;++U){let C=Y[U];F+=C,K=Math.max(K,C),P+=(U+.5)*C,k+=H*C}}if(s!=null&&K<s)continue;let X=[S*P/F,T*k/F];v.push(X),A.push(L),E.push(K)}h.push({bbox:x,scores:E,labels:A,keypoints:v})}u.push(h)}return u}};var Sl=class extends V{post_process_object_detection(...e){return ls(...e)}},Jd=class extends Sl{};var $e=class{static async from_pretrained(e,r={}){let s=await ut(e,Mr,!0,r),n=s.image_processor_type??s.feature_extractor_type,o=qn[n?.replace(/Fast$/,"")];return o||(n!==void 0&&J.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${as}.`),o=V),new o(s)}};var Zd=class extends oe{static tokenizer_class=ce;static image_processor_class=$e;constructor(e,r,s){super(e,r,s);let{tasks_answer_post_processing_type:n,task_prompts_without_inputs:o,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(n??{})),this.task_prompts_without_inputs=new Map(Object.entries(o??{})),this.task_prompts_with_input=new Map(Object.entries(a??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e=="string"&&(e=[e]);let r=[];for(let s of e)if(this.task_prompts_without_inputs.has(s))r.push(this.task_prompts_without_inputs.get(s));else{for(let[n,o]of this.task_prompts_with_input)if(s.includes(n)){r.push(o.replaceAll("{input}",s).replaceAll(n,""));break}r.length!==e.length&&r.push(s)}return r}post_process_generation(e,r,s){let n=this.tasks_answer_post_processing_type.get(r)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let o;switch(n){case"pure_text":o=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":let a=n==="ocr"?"quad_boxes":"bboxes",i=e.matchAll(this.regexes[a]),l=[],u=[];for(let[p,f,...m]of i)l.push(f?f.trim():l.at(-1)??""),u.push(m.map((h,w)=>(Number(h)+.5)/this.size_per_bin*s[w%2]));o={labels:l,[a]:u};break;default:throw new Error(`Task "${r}" (of type "${n}") not yet implemented.`)}return{[r]:o}}async _call(e,r=null,s={}){if(!e&&!r)throw new Error("Either text or images must be provided");let n=await this.image_processor(e,s),o=r?this.tokenizer(this.construct_prompts(r),s):{};return{...n,...o}}};var ef=class extends oe{static image_processor_class=$e;static feature_extractor_class=et;static tokenizer_class=ce;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,r,s){super(e,r,s),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:n,boa_token:o,audio_token:a,eoa_token:i,image_token_id:l,boi_token:u,image_token:p,eoi_token:f}=this.tokenizer.config;this.audio_token_id=n,this.boa_token=o,this.audio_token=a;let m=a.repeat(this.audio_seq_length);this.full_audio_sequence=`
|
|
12
|
+
}`,h=new Function(Object.keys(I),z)(...Object.values(I)),z=`methodCaller<(${b.map(U=>U.name)}) => ${g.name}>`,KS(Object.defineProperty(h,"name",{value:z}))}function eT(u,f){return f>>>=0,(u=Rt(u>>>0))==Rt(f)}function tT(u){return(u>>>=0)?(u=Nu(u),Wt(globalThis[u])):Wt(globalThis)}function rT(u){return u=Nu(u>>>0),Wt(e[u])}function sT(u,f){return f>>>=0,u=Rt(u>>>0),f=Rt(f),Wt(u[f])}function nT(u){9<(u>>>=0)&&(Ss[u+1]+=1)}function Cv(u,f,h,g,b){return B0[u>>>0](f>>>0,h>>>0,g>>>0,b>>>0)}function oT(u,f,h,g,b){return Cv(u>>>0,f>>>0,h>>>0,g>>>0,b>>>0)}function aT(){return Wt([])}function iT(u){u=Rt(u>>>0);for(var f=Array(u.length),h=0;h<u.length;h++)f[h]=u[h];return Wt(f)}function lT(u){return Wt(Nu(u>>>0))}function cT(){return Wt({})}function uT(u){for(var f=Rt(u>>>=0);f.length;){var h=f.pop();f.pop()(h)}z0(u)}function pT(u,f,h){f>>>=0,h>>>=0,u=Rt(u>>>0),f=Rt(f),h=Rt(h),u[f]=h}function dT(u,f){u=kt(u),f>>>=0,u=new Date(1e3*u),(v(),R)[f>>>2>>>0]=u.getUTCSeconds(),(v(),R)[f+4>>>2>>>0]=u.getUTCMinutes(),(v(),R)[f+8>>>2>>>0]=u.getUTCHours(),(v(),R)[f+12>>>2>>>0]=u.getUTCDate(),(v(),R)[f+16>>>2>>>0]=u.getUTCMonth(),(v(),R)[f+20>>>2>>>0]=u.getUTCFullYear()-1900,(v(),R)[f+24>>>2>>>0]=u.getUTCDay(),u=(u.getTime()-Date.UTC(u.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(v(),R)[f+28>>>2>>>0]=u}var Lv=u=>u%4==0&&(u%100!=0||u%400==0),Pv=[0,31,60,91,121,152,182,213,244,274,305,335],zv=[0,31,59,90,120,151,181,212,243,273,304,334];function fT(u,f){u=kt(u),f>>>=0,u=new Date(1e3*u),(v(),R)[f>>>2>>>0]=u.getSeconds(),(v(),R)[f+4>>>2>>>0]=u.getMinutes(),(v(),R)[f+8>>>2>>>0]=u.getHours(),(v(),R)[f+12>>>2>>>0]=u.getDate(),(v(),R)[f+16>>>2>>>0]=u.getMonth(),(v(),R)[f+20>>>2>>>0]=u.getFullYear()-1900,(v(),R)[f+24>>>2>>>0]=u.getDay();var h=(Lv(u.getFullYear())?Pv:zv)[u.getMonth()]+u.getDate()-1|0;(v(),R)[f+28>>>2>>>0]=h,(v(),R)[f+36>>>2>>>0]=-60*u.getTimezoneOffset(),h=new Date(u.getFullYear(),6,1).getTimezoneOffset();var g=new Date(u.getFullYear(),0,1).getTimezoneOffset();u=0|(h!=g&&u.getTimezoneOffset()==Math.min(g,h)),(v(),R)[f+32>>>2>>>0]=u}function _T(u){u>>>=0;var f=new Date((v(),R)[u+20>>>2>>>0]+1900,(v(),R)[u+16>>>2>>>0],(v(),R)[u+12>>>2>>>0],(v(),R)[u+8>>>2>>>0],(v(),R)[u+4>>>2>>>0],(v(),R)[u>>>2>>>0],0),h=(v(),R)[u+32>>>2>>>0],g=f.getTimezoneOffset(),b=new Date(f.getFullYear(),6,1).getTimezoneOffset(),M=new Date(f.getFullYear(),0,1).getTimezoneOffset(),I=Math.min(M,b);return 0>h?(v(),R)[u+32>>>2>>>0]=+(b!=M&&I==g):0<h!=(I==g)&&(b=Math.max(M,b),f.setTime(f.getTime()+6e4*((0<h?I:b)-g))),(v(),R)[u+24>>>2>>>0]=f.getDay(),h=(Lv(f.getFullYear())?Pv:zv)[f.getMonth()]+f.getDate()-1|0,(v(),R)[u+28>>>2>>>0]=h,(v(),R)[u>>>2>>>0]=f.getSeconds(),(v(),R)[u+4>>>2>>>0]=f.getMinutes(),(v(),R)[u+8>>>2>>>0]=f.getHours(),(v(),R)[u+12>>>2>>>0]=f.getDate(),(v(),R)[u+16>>>2>>>0]=f.getMonth(),(v(),R)[u+20>>>2>>>0]=f.getYear(),u=f.getTime(),BigInt(isNaN(u)?-1:u/1e3)}function Nv(u,f,h,g,b,M,I){return n?Be(16,1,u,f,h,g,b,M,I):-52}function $v(u,f,h,g,b,M){if(n)return Be(17,1,u,f,h,g,b,M)}var ol={},mT=()=>performance.timeOrigin+performance.now();function Rv(u,f){if(n)return Be(18,1,u,f);if(ol[u]&&(clearTimeout(ol[u].id),delete ol[u]),!f)return 0;var h=setTimeout(()=>{delete ol[u],Et(()=>dk(u,performance.timeOrigin+performance.now()))},f);return ol[u]={id:h,Ce:f},0}function hT(u,f,h,g){u>>>=0,f>>>=0,h>>>=0,g>>>=0;var b=new Date().getFullYear(),M=new Date(b,0,1).getTimezoneOffset();b=new Date(b,6,1).getTimezoneOffset();var I=Math.max(M,b);(v(),C)[u>>>2>>>0]=60*I,(v(),R)[f>>>2>>>0]=+(M!=b),u=(f=z=>{var U=Math.abs(z);return`UTC${0<=z?"-":"+"}${String(Math.floor(U/60)).padStart(2,"0")}${String(U%60).padStart(2,"0")}`})(M),f=f(b),b<M?(mr(u,h,17),mr(f,g,17)):(mr(u,g,17),mr(f,h,17))}var gT=()=>Date.now(),wT=1;function xT(u,f,h){if(h>>>=0,!(0<=u&&3>=u))return 28;if(u===0)u=Date.now();else{if(!wT)return 52;u=performance.timeOrigin+performance.now()}return u=Math.round(1e6*u),(v(),P)[h>>>3>>>0]=BigInt(u),0}var U0=[],Dv=(u,f)=>{U0.length=0;for(var h;h=(v(),H)[u++>>>0];){var g=h!=105;f+=(g&=h!=112)&&f%8?4:0,U0.push(h==112?(v(),C)[f>>>2>>>0]:h==106?(v(),P)[f>>>3>>>0]:h==105?(v(),R)[f>>>2>>>0]:(v(),ae)[f>>>3>>>0]),f+=g?8:4}return U0};function yT(u,f,h){return u>>>=0,f=Dv(f>>>0,h>>>0),rb[u](...f)}function bT(u,f,h){return u>>>=0,f=Dv(f>>>0,h>>>0),rb[u](...f)}var vT=()=>{};function kT(u,f){return S(Tn(u>>>0,f>>>0))}var ET=()=>{throw ze+=1,"unwind"};function AT(){return 4294901760}var MT=()=>1,ST=()=>navigator.hardwareConcurrency;function TT(u){u>>>=0;var f=(v(),H).length;if(u<=f||4294901760<u)return!1;for(var h=1;4>=h;h*=2){var g=f*(1+.2/h);g=Math.min(g,u+100663296);e:{g=(Math.min(4294901760,65536*Math.ceil(Math.max(u,g)/65536))-Gr.buffer.byteLength+65535)/65536|0;try{Gr.grow(g),xe();var b=1;break e}catch{}b=void 0}if(b)return!0}return!1}var ar=u=>{var f=hr(u)+1,h=Fu(f);return mr(u,h,f),h},j0=(u,f)=>{(v(),C)[u>>>2>>>0]=f;var h=(v(),C)[u>>>2>>>0];(v(),C)[u+4>>>2>>>0]=(f-h)/4294967296},al=u=>(v(),C)[u>>>2>>>0]+4294967296*(v(),R)[u+4>>>2>>>0],mt=[],OT=(u,f)=>{mt[u>>>0]=f},gr=[],$u=[],In=(u,f)=>{$u[u]=new Promise(h=>f.finally(()=>h(u)))},se=u=>{if(u)return mt[u>>>0]},IT=(u,f)=>{for(u=(v(),C)[u>>>2>>>0];u;u=(v(),C)[u>>>2>>>0])f[(v(),R)[u+4>>>2>>>0]](u)},Ru=(u,f,h)=>{(v(),C)[u>>>2>>>0]=f,(v(),C)[u+4>>>2>>>0]=h},Fv=u=>{var f=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],Tn(f,u)},wr=u=>{var f=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],f?Tn(f,u):u===0?"":void 0},CT=u=>{var f=wr(u+4),h=(h=(v(),C)[u+12>>>2>>>0])?se(h):"auto";if(u+=16){var g=se((v(),C)[u+4>>>2>>>0]),b=(v(),C)[u+16>>>2>>>0],M=(v(),C)[u+20>>>2>>>0];if(b){for(var I={},z=0;z<b;++z){var U=M+24*z;I[Fv(U+4)]=(v(),ae)[U+16>>>3>>>0]}b=I}else b=void 0;u={module:g,constants:b,entryPoint:wr(u+8)}}else u=void 0;return{label:f,layout:h,compute:u}},Bv=(u,f)=>{function h(g,b){g=u[g],(v(),C)[f+b>>>2>>>0]=g}h("maxTextureDimension1D",4),h("maxTextureDimension2D",8),h("maxTextureDimension3D",12),h("maxTextureArrayLayers",16),h("maxBindGroups",20),h("maxBindGroupsPlusVertexBuffers",24),h("maxBindingsPerBindGroup",28),h("maxDynamicUniformBuffersPerPipelineLayout",32),h("maxDynamicStorageBuffersPerPipelineLayout",36),h("maxSampledTexturesPerShaderStage",40),h("maxSamplersPerShaderStage",44),h("maxStorageBuffersPerShaderStage",48),h("maxStorageTexturesPerShaderStage",52),h("maxUniformBuffersPerShaderStage",56),h("minUniformBufferOffsetAlignment",80),h("minStorageBufferOffsetAlignment",84),j0(f+64,u.maxUniformBufferBindingSize),j0(f+72,u.maxStorageBufferBindingSize),h("maxVertexBuffers",88),j0(f+96,u.maxBufferSize),h("maxVertexAttributes",104),h("maxVertexBufferArrayStride",108),h("maxInterStageShaderVariables",112),h("maxColorAttachments",116),h("maxColorAttachmentBytesPerSample",120),h("maxComputeWorkgroupStorageSize",124),h("maxComputeInvocationsPerWorkgroup",128),h("maxComputeWorkgroupSizeX",132),h("maxComputeWorkgroupSizeY",136),h("maxComputeWorkgroupSizeZ",140),h("maxComputeWorkgroupsPerDimension",144),u.Ae!==void 0&&h("maxImmediateSize",148)},LT=[,"validation","out-of-memory","internal"],PT=[,"compatibility","core"],Uv={1:"core-features-and-limits",2:"depth-clip-control",3:"depth32float-stencil8",4:"texture-compression-bc",5:"texture-compression-bc-sliced-3d",6:"texture-compression-etc2",7:"texture-compression-astc",8:"texture-compression-astc-sliced-3d",9:"timestamp-query",10:"indirect-first-instance",11:"shader-f16",12:"rg11b10ufloat-renderable",13:"bgra8unorm-storage",14:"float32-filterable",15:"float32-blendable",16:"clip-distances",17:"dual-source-blending",18:"subgroups",19:"texture-formats-tier1",20:"texture-formats-tier2",21:"primitive-index",22:"texture-component-swizzle",327692:"chromium-experimental-unorm16-texture-formats",327729:"chromium-experimental-multi-draw-indirect"},zT=[,"low-power","high-performance"],NT=[,"occlusion","timestamp"],$T={undefined:1,unknown:1,destroyed:2};function RT(u,f,h,g,b,M){f=kt(f),h=kt(h),g>>>=0,b>>>=0,M>>>=0;var I=se(u>>>0);if(u={},M){var z=(v(),C)[M+12>>>2>>>0];if(z){var U=(v(),C)[M+16>>>2>>>0];u.requiredFeatures=Array.from((v(),C).subarray(U>>>2>>>0,U+4*z>>>2>>>0),ne=>Uv[ne])}var Y=(v(),C)[M+20>>>2>>>0];if(Y){let ne=function(At,lt,Ts=!1){lt=Y+lt,(lt=(v(),C)[lt>>>2>>>0])==4294967295||Ts&<==0||(Ue[At]=lt)},it=function(At,lt){lt=Y+lt;var Ts=(v(),C)[lt>>>2>>>0],lI=(v(),C)[lt+4>>>2>>>0];Ts==4294967295&&lI==4294967295||(Ue[At]=al(lt))};var Se=ne,Ne=it,Ue={};ne("maxTextureDimension1D",4),ne("maxTextureDimension2D",8),ne("maxTextureDimension3D",12),ne("maxTextureArrayLayers",16),ne("maxBindGroups",20),ne("maxBindGroupsPlusVertexBuffers",24),ne("maxDynamicUniformBuffersPerPipelineLayout",32),ne("maxDynamicStorageBuffersPerPipelineLayout",36),ne("maxSampledTexturesPerShaderStage",40),ne("maxSamplersPerShaderStage",44),ne("maxStorageBuffersPerShaderStage",48),ne("maxStorageTexturesPerShaderStage",52),ne("maxUniformBuffersPerShaderStage",56),ne("minUniformBufferOffsetAlignment",80),ne("minStorageBufferOffsetAlignment",84),it("maxUniformBufferBindingSize",64),it("maxStorageBufferBindingSize",72),ne("maxVertexBuffers",88),it("maxBufferSize",96),ne("maxVertexAttributes",104),ne("maxVertexBufferArrayStride",108),ne("maxInterStageShaderVariables",112),ne("maxColorAttachments",116),ne("maxColorAttachmentBytesPerSample",120),ne("maxComputeWorkgroupStorageSize",124),ne("maxComputeInvocationsPerWorkgroup",128),ne("maxComputeWorkgroupSizeX",132),ne("maxComputeWorkgroupSizeY",136),ne("maxComputeWorkgroupSizeZ",140),ne("maxComputeWorkgroupsPerDimension",144),ne("maxImmediateSize",148,!0),u.requiredLimits=Ue}(z=(v(),C)[M+24>>>2>>>0])&&(z={label:wr(z+4)},u.defaultQueue=z),u.label=wr(M+4)}ze+=1,In(f,I.requestDevice(u).then(ne=>{--ze,Et(()=>{mt[b>>>0]=ne.queue,mt[g>>>0]=ne,In(h,ne.lost.then(it=>{Et(()=>{ne.onuncapturederror=()=>{};var At=ce(),lt=ar(it.message);H0(h,$T[it.reason],lt),le(At)})})),ne.onuncapturederror=it=>{var At=5;it.error instanceof GPUValidationError?At=2:it.error instanceof GPUOutOfMemoryError?At=3:it.error instanceof GPUInternalError&&(At=4);var lt=ce();it=ar(it.error.message),lk(g,At,it),le(lt)},"adapterInfo"in ne||(ne.adapterInfo=I.info),Q0(f,1,g,0)})},ne=>{--ze,Et(()=>{var it=ce(),At=ar(ne.message);Q0(f,3,g,At),h&&H0(h,4,At),le(it)})}))}function DT(u){var f=se(u>>>=0),h=gr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete gr[u]}f.destroy()}function FT(u,f,h){h>>>=0;var g=se(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(f>>>0,h)}catch{return 0}var M=Z0(16,b.byteLength);return(v(),H).set(new Uint8Array(b),M>>>0),gr[u].push(()=>Vt(M)),M}function BT(u,f,h){h>>>=0;var g=se(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(f>>>0,h)}catch{return 0}var M=Z0(16,b.byteLength);return(v(),H).fill(0,M,b.byteLength),gr[u].push(()=>{new Uint8Array(b).set((v(),H).subarray(M>>>0,M+b.byteLength>>>0)),Vt(M)}),M}function UT(u,f,h,g,b){u>>>=0,f=kt(f),h=kt(h),b>>>=0;var M=se(u);gr[u]=[],b==4294967295&&(b=void 0),ze+=1,In(f,M.mapAsync(h,g>>>0,b).then(()=>{--ze,Et(()=>{X0(f,1,0)})},I=>{--ze,Et(()=>{ce();var z=ar(I.message);X0(f,I.name==="AbortError"?4:I.name==="OperationError"?3:0,z),delete gr[u]})}))}function jT(u){var f=se(u>>>=0),h=gr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete gr[u],f.unmap()}}function GT(u){delete mt[u>>>0]}function qT(u,f,h){u>>>=0,f>>>=0,h>>>=0;var g=!!(v(),C)[f+32>>>2>>>0];f={label:wr(f+4),usage:(v(),C)[f+16>>>2>>>0],size:al(f+24),mappedAtCreation:g},u=se(u);try{var b=u.createBuffer(f)}catch{return!1}return mt[h>>>0]=b,g&&(gr[h]=[]),!0}function WT(u,f,h,g){u>>>=0,f=kt(f),g>>>=0,h=CT(h>>>0),u=se(u),ze+=1,In(f,u.createComputePipelineAsync(h).then(b=>{--ze,Et(()=>{mt[g>>>0]=b,V0(f,1,g,0)})},b=>{--ze,Et(()=>{var M=ce(),I=ar(b.message);V0(f,b.reason==="validation"?3:b.reason==="internal"?4:0,g,I),le(M)})}))}function VT(u,f,h){u>>>=0,f>>>=0,h>>>=0;var g=(v(),C)[f>>>2>>>0],b=(v(),R)[g+4>>>2>>>0];f={label:wr(f+4),code:""},b===2&&(f.code=Fv(g+8)),u=se(u).createShaderModule(f),mt[h>>>0]=u}var HT=u=>{(u=se(u)).onuncapturederror=null,u.destroy()};function XT(u,f){f=kt(f),u=se(u>>>0),ze+=1,In(f,u.popErrorScope().then(h=>{--ze,Et(()=>{var g=5;h?h instanceof GPUValidationError?g=2:h instanceof GPUOutOfMemoryError?g=3:h instanceof GPUInternalError&&(g=4):g=1;var b=ce(),M=h?ar(h.message):0;K0(f,1,g,M),le(b)})},h=>{--ze,Et(()=>{var g=ce(),b=ar(h.message);K0(f,1,5,b),le(g)})}))}function KT(u,f,h,g){if(f=kt(f),g>>>=0,h>>>=0){var b={featureLevel:PT[(v(),R)[h+4>>>2>>>0]],powerPreference:zT[(v(),R)[h+8>>>2>>>0]],forceFallbackAdapter:!!(v(),C)[h+12>>>2>>>0]};(u=(v(),C)[h>>>2>>>0])!==0&&(v(),b.Fe=!!(v(),C)[u+8>>>2>>>0])}"gpu"in navigator?(ze+=1,In(f,navigator.gpu.requestAdapter(b).then(M=>{--ze,Et(()=>{if(M)mt[g>>>0]=M,il(f,1,g,0);else{var I=ce(),z=ar("WebGPU not available on this browser (requestAdapter returned null)");il(f,3,g,z),le(I)}})},M=>{--ze,Et(()=>{var I=ce(),z=ar(M.message);il(f,4,g,z),le(I)})}))):(b=ce(),u=ar("WebGPU not available on this browser (navigator.gpu is not available)"),il(f,3,g,u),le(b))}function QT(u,f,h){return u>>>=0,f>>>=0,h>>>=0,Iv(async()=>{var g=[];if(h){var b=(v(),R)[h>>>2>>>0];g.length=f+1,g[f]=new Promise(z=>setTimeout(z,b,0))}else g.length=f;for(var M=0;M<f;++M){var I=al(u+8*M);if(!(I in $u))return I;g[M]=$u[I]}return g=await Promise.race(g),delete $u[g],g})}var G0,q0={},jv=()=>{if(!G0){var u,f={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:"./this.program"};for(u in q0)q0[u]===void 0?delete f[u]:f[u]=q0[u];var h=[];for(u in f)h.push(`${u}=${f[u]}`);G0=h}return G0};function Gv(u,f){if(n)return Be(19,1,u,f);u>>>=0,f>>>=0;var h,g=0,b=0;for(h of jv()){var M=f+g;(v(),C)[u+b>>>2>>>0]=M,g+=mr(h,M,1/0)+1,b+=4}return 0}function qv(u,f){if(n)return Be(20,1,u,f);u>>>=0,f>>>=0;var h=jv();for(var g of((v(),C)[u>>>2>>>0]=h.length,u=0,h))u+=hr(g)+1;return(v(),C)[f>>>2>>>0]=u,0}function Wv(u){return n?Be(21,1,u):52}function Vv(u,f,h,g){return n?Be(22,1,u,f,h,g):52}function Hv(u,f,h,g){return n?Be(23,1,u,f,h,g):70}var YT=[null,[],[]];function Xv(u,f,h,g){if(n)return Be(24,1,u,f,h,g);f>>>=0,h>>>=0,g>>>=0;for(var b=0,M=0;M<h;M++){var I=(v(),C)[f>>>2>>>0],z=(v(),C)[f+4>>>2>>>0];f+=8;for(var U=0;U<z;U++){var Y=u,Se=(v(),H)[I+U>>>0],Ne=YT[Y];Se===0||Se===10?((Y===1?T:S)(uv(Ne)),Ne.length=0):Ne.push(Se)}b+=z}return(v(),C)[g>>>2>>>0]=b,0}function JT(u){return u>>>0}function ZT(u,f){return Bv(se(u>>>0).limits,f>>>0),1}function eO(u,f){return se(u>>>0).features.has(Uv[f])}function tO(u){return BigInt(se(u>>>0).size)}function rO(u){return BigInt(se(u>>>0).usage)}function sO(u,f){if(u>>>=0,f>>>=0){var h=wr(f+4);h={label:h,timestampWrites:f=(f=(v(),C)[f+12>>>2>>>0])!==0?{querySet:se((v(),C)[f+4>>>2>>>0]),beginningOfPassWriteIndex:(v(),C)[f+8>>>2>>>0],endOfPassWriteIndex:(v(),C)[f+12>>>2>>>0]}:void 0}}return f=se(u),u=sk(0),h=f.beginComputePass(h),mt[u>>>0]=h,u}function nO(u,f,h,g,b,M){h=kt(h),b=kt(b),M=kt(M),se(u>>>0).copyBufferToBuffer(se(f>>>0),h,se(g>>>0),b,M)}function oO(u){var f=se(u>>>0);return u=tk(0),f=f.finish(),mt[u>>>0]=f,u}function aO(u,f,h,g,b,M){M=kt(M),se(u>>>0).resolveQuerySet(se(f>>>0),h,g,se(b>>>0),M)}function iO(u,f,h,g){se(u>>>0).dispatchWorkgroups(f,h,g)}function lO(u,f,h){h=kt(h),se(u>>>0).dispatchWorkgroupsIndirect(se(f>>>0),h)}function cO(u){se(u>>>0).end()}function uO(u,f,h,g,b){g>>>=0,b>>>=0,u=se(u>>>0),h=se(h>>>0),g==0?u.setBindGroup(f,h):u.setBindGroup(f,h,(v(),C),b>>>2,g)}function pO(u,f){se(u>>>0).setPipeline(se(f>>>0))}function dO(u,f,h){se(u>>>0).Ee(se(f>>>0),h)}function fO(u,f){var h=se(u>>>0);return u=ek(0),f=h.getBindGroupLayout(f),mt[u>>>0]=f,u}function _O(u,f){function h(b){var M=(v(),C)[b+8>>>2>>>0],I=(v(),C)[b+32>>>2>>>0],z=(v(),C)[b+36>>>2>>>0],U=0;return IT(b,{327681:Y=>{U=(v(),C)[Y+8>>>2>>>0]}}),M?((I=al(b+24))==-1&&(I=void 0),M={buffer:se(M),offset:al(b+16),size:I}):M=se(I||z||U),{binding:(v(),C)[b+4>>>2>>>0],resource:M}}u>>>=0,f={label:wr(4+(f>>>=0)),layout:se((v(),C)[f+12>>>2>>>0]),entries:(function(b,M){for(var I=[],z=0;z<b;++z)I.push(h(M+40*z));return I})((v(),C)[f+16>>>2>>>0],(v(),C)[f+20>>>2>>>0])},u=se(u);var g=Zv(0);return OT(g,u.createBindGroup(f)),g}function mO(u,f){var h;return u>>>=0,(f>>>=0)&&(h={label:wr(f+4)}),f=se(u),u=rk(0),h=f.createCommandEncoder(h),mt[u>>>0]=h,u}function hO(u,f){u>>>=0,f>>>=0,f={type:NT[(v(),R)[f+12>>>2>>>0]],count:(v(),C)[f+16>>>2>>>0]};var h=se(u);return u=nk(0),f=h.createQuerySet(f),mt[u>>>0]=f,u}function gO(u,f){u=se(u>>>0).adapterInfo,f>>>=0,(v(),C)[f+52>>>2>>>0]=u.subgroupMinSize,(v(),C)[f+56>>>2>>>0]=u.subgroupMaxSize;var h=u.vendor+u.architecture+u.device+u.description,g=hr(h)+1,b=Cn(g);return b&&mr(h,b,g),h=b,g=hr(u.vendor),Ru(f+4,h,g),h+=g,g=hr(u.architecture),Ru(f+12,h,g),h+=g,g=hr(u.device),Ru(f+20,h,g),Ru(f+28,h+g,hr(u.description)),(v(),R)[f+36>>>2>>>0]=2,u=u.isFallbackAdapter?3:4,(v(),R)[f+40>>>2>>>0]=u,(v(),C)[f+44>>>2>>>0]=0,(v(),C)[f+48>>>2>>>0]=0,1}var wO={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729};function xO(u,f){f>>>=0;var h=se(u>>>0);u=Cn(4*h.features.size);var g=0,b=0;for(let M of h.features)0<=(h=wO[M])&&((v(),R)[u+g>>>2>>>0]=h,g+=4,b++);(v(),C)[f+4>>>2>>>0]=u,(v(),C)[f>>>2>>>0]=b}function yO(u,f){return Bv(se(u>>>0).limits,f>>>0),1}function bO(u,f){se(u>>>0).pushErrorScope(LT[f])}function vO(u,f,h){f>>>=0,h>>>=0,u=se(u>>>0),f=Array.from((v(),R).subarray(h>>>2>>>0,h+4*f>>>2>>>0),g=>se(g)),u.submit(f)}function kO(u,f,h,g,b){h=kt(h),g>>>=0,b>>>=0,u=se(u>>>0),f=se(f>>>0),g=(v(),H).subarray(g>>>0,g+b>>>0),u.writeBuffer(f,h,g,0,b)}n||(function(){for(var u=e.numThreads-1;u--;)sv();Fe.push(async()=>{var f=(async function(){if(!n)return Promise.all(jr.map(rv))})();Me++,await f,--Me==0&&et&&(f=et,et=null,f())})})(),n||(Gr=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),xe()),e.wasmBinary&&(d=e.wasmBinary),e.stackSave=()=>ce(),e.stackRestore=u=>le(u),e.stackAlloc=u=>Fu(u),e.setValue=function(u,f,h="i8"){switch(h.endsWith("*")&&(h="*"),h){case"i1":case"i8":(v(),B)[u>>>0]=f;break;case"i16":(v(),G)[u>>>1>>>0]=f;break;case"i32":(v(),R)[u>>>2>>>0]=f;break;case"i64":(v(),P)[u>>>3>>>0]=BigInt(f);break;case"float":(v(),te)[u>>>2>>>0]=f;break;case"double":(v(),ae)[u>>>3>>>0]=f;break;case"*":(v(),C)[u>>>2>>>0]=f;break;default:Ve(`invalid type for setValue: ${h}`)}},e.getValue=function(u,f="i8"){switch(f.endsWith("*")&&(f="*"),f){case"i1":case"i8":return(v(),B)[u>>>0];case"i16":return(v(),G)[u>>>1>>>0];case"i32":return(v(),R)[u>>>2>>>0];case"i64":return(v(),P)[u>>>3>>>0];case"float":return(v(),te)[u>>>2>>>0];case"double":return(v(),ae)[u>>>3>>>0];case"*":return(v(),C)[u>>>2>>>0];default:Ve(`invalid type for getValue: ${f}`)}},e.UTF8ToString=Tn,e.stringToUTF8=mr,e.lengthBytesUTF8=hr;var Kv,Qv,W0,Du,Vt,Cn,Yv,Jv,Zv,ek,tk,rk,sk,nk,ok,ak,ik,V0,H0,X0,K0,il,Q0,lk,Y0,ck,uk,pk,J0,dk,fk,Z0,we,ll,_k,le,Fu,ce,mk,eb,hk,gk,wk,tb,xk,yk,bk,vk,kk,Ek,Ak,Mk,Sk,Tk,Ok,Ik,Ck,Lk,Pk,zk,Nk,$k,Rk,Dk,Fk,Bk,Uk,jk,Gk,qk,Wk,Vk,Hk,Xk,Kk,Qk,Yk,Jk,Zk,eE,tE,rE,sE,xr,EO=[An,sl,av,pv,dv,fv,_v,mv,hv,gv,wv,xv,yv,bv,vv,kv,Nv,$v,Rv,Gv,qv,Wv,Vv,Hv,Xv],rb={925676:(u,f,h,g,b)=>{if(e===void 0||!e.Uc)return 1;if((u=Tn(Number(u>>>0))).startsWith("./")&&(u=u.substring(2)),!(u=e.Uc.get(u)))return 2;if(f=Number(f>>>0),h=Number(h>>>0),g=Number(g>>>0),f+h>u.byteLength)return 3;try{let M=u.subarray(f,f+h);switch(b){case 0:(v(),H).set(M,g>>>0);break;case 1:e.ad?e.ad(g,M):e.oe(g,M);break;default:return 4}return 0}catch{return 4}},926500:(u,f,h)=>{e.Sd(u,(v(),H).subarray(f>>>0,f+h>>>0))},926564:()=>e.me(),926606:u=>{e.jd(u)},926643:()=>typeof wasmOffsetConverter<"u"};function AO(u,f,h,g){var b=ce();try{return Mk(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function MO(u,f,h){var g=ce();try{return kk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function SO(u,f,h){var g=ce();try{wk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function TO(u,f){var h=ce();try{return tb(u,f)}catch(g){if(le(h),g!==g+0)throw g;we(1,0)}}function OO(u){var f=ce();try{xk(u)}catch(h){if(le(f),h!==h+0)throw h;we(1,0)}}function IO(u,f,h,g,b,M,I){var z=ce();try{return vk(u,f,h,g,b,M,I)}catch(U){if(le(z),U!==U+0)throw U;we(1,0)}}function CO(u,f){var h=ce();try{Sk(u,f)}catch(g){if(le(h),g!==g+0)throw g;we(1,0)}}function LO(u,f,h,g,b,M){var I=ce();try{yk(u,f,h,g,b,M)}catch(z){if(le(I),z!==z+0)throw z;we(1,0)}}function PO(u,f,h,g){var b=ce();try{Ak(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function zO(u,f,h,g,b,M,I){var z=ce();try{Ok(u,f,h,g,b,M,I)}catch(U){if(le(z),U!==U+0)throw U;we(1,0)}}function NO(u,f,h,g,b,M,I){var z=ce();try{Ik(u,f,h,g,b,M,I)}catch(U){if(le(z),U!==U+0)throw U;we(1,0)}}function $O(u,f,h,g,b,M,I,z){var U=ce();try{Fk(u,f,h,g,b,M,I,z)}catch(Y){if(le(U),Y!==Y+0)throw Y;we(1,0)}}function RO(u,f,h,g,b,M,I,z,U,Y,Se,Ne){var Ue=ce();try{Ck(u,f,h,g,b,M,I,z,U,Y,Se,Ne)}catch(ne){if(le(Ue),ne!==ne+0)throw ne;we(1,0)}}function DO(u,f,h,g,b){var M=ce();try{return Tk(u,f,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function FO(u,f,h,g,b){var M=ce();try{bk(u,f,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function BO(u,f,h,g,b,M,I,z){var U=ce();try{Ek(u,f,h,g,b,M,I,z)}catch(Y){if(le(U),Y!==Y+0)throw Y;we(1,0)}}function UO(u){var f=ce();try{return Bk(u)}catch(h){if(le(f),h!==h+0)throw h;we(1,0)}}function jO(u,f,h){var g=ce();try{return Uk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function GO(u,f){var h=ce();try{return Zk(u,f)}catch(g){if(le(h),g!==g+0)throw g;return we(1,0),0n}}function qO(u,f,h,g,b){var M=ce();try{jk(u,f,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function WO(u){var f=ce();try{return Lk(u)}catch(h){if(le(f),h!==h+0)throw h;return we(1,0),0n}}function VO(u,f,h,g,b,M){var I=ce();try{return Rk(u,f,h,g,b,M)}catch(z){if(le(I),z!==z+0)throw z;we(1,0)}}function HO(u,f,h,g,b,M){var I=ce();try{return Gk(u,f,h,g,b,M)}catch(z){if(le(I),z!==z+0)throw z;we(1,0)}}function XO(u,f,h,g,b,M){var I=ce();try{return qk(u,f,h,g,b,M)}catch(z){if(le(I),z!==z+0)throw z;we(1,0)}}function KO(u,f,h,g,b,M,I,z){var U=ce();try{return Dk(u,f,h,g,b,M,I,z)}catch(Y){if(le(U),Y!==Y+0)throw Y;we(1,0)}}function QO(u,f,h,g,b){var M=ce();try{return Wk(u,f,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;return we(1,0),0n}}function YO(u,f,h,g){var b=ce();try{return Vk(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function JO(u,f,h,g){var b=ce();try{return Hk(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function ZO(u,f,h,g,b,M,I,z,U,Y,Se,Ne){var Ue=ce();try{return Xk(u,f,h,g,b,M,I,z,U,Y,Se,Ne)}catch(ne){if(le(Ue),ne!==ne+0)throw ne;we(1,0)}}function eI(u,f,h,g,b,M,I,z,U,Y,Se){var Ne=ce();try{Kk(u,f,h,g,b,M,I,z,U,Y,Se)}catch(Ue){if(le(Ne),Ue!==Ue+0)throw Ue;we(1,0)}}function tI(u,f,h,g,b,M,I,z,U,Y,Se,Ne,Ue,ne,it,At){var lt=ce();try{Qk(u,f,h,g,b,M,I,z,U,Y,Se,Ne,Ue,ne,it,At)}catch(Ts){if(le(lt),Ts!==Ts+0)throw Ts;we(1,0)}}function rI(u,f,h,g){var b=ce();try{return Yk(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function sI(u,f,h,g,b){var M=ce();try{return Jk(u,f,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function nI(u,f,h){var g=ce();try{return zk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;return we(1,0),0n}}function oI(u,f,h){var g=ce();try{return Pk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function aI(u,f,h){var g=ce();try{return Nk(u,f,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function iI(u,f,h,g){var b=ce();try{$k(u,f,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function Bu(){if(0<Me)et=Bu;else if(n)w?.(e),ue();else{for(var u=Fe;0<u.length;)u.shift()(e);0<Me?et=Bu:(e.calledRun=!0,L||(ue(),w?.(e)))}}return n||(xr=await _t(),Bu()),e.PTR_SIZE=4,e.webgpuInit=u=>{let f=new WeakMap,h,g,b=1;e.webgpuRegisterDevice=z=>{if(g!==void 0)throw Error("another WebGPU EP inference session is being created.");if(z){var U=f.get(z);if(!U){let Y=((Se,Ne=0)=>{var Ue=ik(Ne);return Ne=ak(Ne,Ue),mt[Ue>>>0]=Se.queue,mt[Ne>>>0]=Se,Ne})(z,U=Jv(0));U=[b++,U,Y],f.set(z,U)}return h=z,g=U[0],U}h=void 0,g=0};let M=new Map;e.webgpuOnCreateSession=z=>{if(g!==void 0){var U=g;if(g=void 0,z){let Y=W0(U);M.set(z,Y),U===0&&u(h??se(Y))}h=void 0}},e.webgpuOnReleaseSession=z=>{M.delete(z)};let I=Symbol("gpuBufferMetadata");e.webgpuRegisterBuffer=(z,U,Y)=>{if(Y)return z[I]=[Y,NaN],Y;if(Y=z[I])return Y[1]++,Y[0];if((U=M.get(U))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return U=((Se,Ne=0)=>(Se.mapState==="unmapped"||Ve(),Ne=ok(Ne),mt[Ne>>>0]=Se,Ne))(z,U),z[I]=[U,1],U},e.webgpuUnregisterBuffer=z=>{let U=z[I];if(!U)throw Error("Buffer is not registered");U[1]--,U[1]===0&&(Yv(U[0]),delete z[I])},e.webgpuGetBuffer=z=>se(z),e.webgpuCreateDownloader=(z,U,Y)=>{if((Y=M.get(Y))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let Se=se(Y),Ne=16*Math.ceil(Number(U)/16);return async()=>{let Ue=Se.createBuffer({size:Ne,usage:9});try{let ne=Se.createCommandEncoder();return ne.copyBufferToBuffer(z,0,Ue,0,Ne),Se.queue.submit([ne.finish()]),await Ue.mapAsync(GPUMapMode.READ),Ue.getMappedRange().slice(0,U)}finally{Ue.destroy()}}},e.ad=(z,U)=>{var Y=U.buffer;let Se=U.byteOffset,Ne=U.byteLength;if(U=16*Math.ceil(Number(Ne)/16),z=se(z),!h){var Ue=W0(g);h=se(Ue)}let ne=(Ue=h.createBuffer({mappedAtCreation:!0,size:U,usage:6})).getMappedRange();new Uint8Array(ne).set(new Uint8Array(Y,Se,Ne)),Ue.unmap(),(Y=h.createCommandEncoder()).copyBufferToBuffer(Ue,0,z,0,U),h.queue.submit([Y.finish()]),Ue.destroy()}},e.webnnInit=u=>{let f=u[0];[e.me,e.jd,e.webnnEnsureTensor,e.Sd,e.webnnDownloadTensor,e.le,e.webnnEnableTraceEvent]=u.slice(1),e.webnnReleaseTensorId=e.jd,e.webnnUploadTensor=e.Sd,e.webnnRegisterMLContext=e.le,e.webnnOnRunStart=h=>f.onRunStart(h),e.webnnOnRunEnd=f.onRunEnd.bind(f),e.webnnOnReleaseSession=h=>{f.onReleaseSession(h)},e.webnnCreateMLTensorDownloader=(h,g)=>f.createMLTensorDownloader(h,g),e.webnnRegisterMLTensor=(h,g,b,M)=>f.registerMLTensor(h,g,b,M),e.webnnCreateMLContext=h=>f.createMLContext(h),e.webnnRegisterMLConstant=(h,g,b,M,I,z)=>f.registerMLConstant(h,g,b,M,I,e.Uc,z),e.webnnRegisterGraphInput=f.registerGraphInput.bind(f),e.webnnIsGraphInput=f.isGraphInput.bind(f),e.webnnRegisterGraphOutput=f.registerGraphOutput.bind(f),e.webnnIsGraphOutput=f.isGraphOutput.bind(f),e.webnnCreateTemporaryTensor=f.createTemporaryTensor.bind(f),e.webnnIsGraphInputOutputTypeSupported=f.isGraphInputOutputTypeSupported.bind(f)},J?e:new Promise((u,f)=>{w=u,x=f})}var n2,pA,az=be(()=>{"use strict";n2=uA,pA=globalThis.self?.name?.startsWith("em-pthread"),pA&&uA()}),Mb,jb,dA,Ct,o2,sp,fA,_A,Sb,mA,Tb,a2,Ob,i2,Yb=be(()=>{"use strict";Qb(),Mb=typeof location>"u"?void 0:location.origin,jb=Jt.url>"file:"&&Jt.url<"file;",dA=()=>{if(jb){let t=URL;return new URL(new t("ort.webgpu.bundle.min.mjs",Jt.url).href,Mb).href}return Jt.url},Ct=dA(),o2=()=>{if(Ct&&!Ct.startsWith("blob:"))return Ct.substring(0,Ct.lastIndexOf("/")+1)},sp=(t,e)=>{try{let r=e??Ct;return(r?new URL(t,r):new URL(t)).origin===Mb}catch{return!1}},fA=(t,e)=>{let r=e??Ct;try{return(r?new URL(t,r):new URL(t)).href}catch{return}},_A=(t,e)=>`${e??"./"}${t}`,Sb=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},mA=async t=>(await import(t)).default,Tb=(oz(),cp(t2)).default,a2=async()=>{if(!Ct)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(sp(Ct))return[void 0,Tb()];let t=await Sb(Ct);return[t,Tb(t)]},Ob=(az(),cp(s2)).default,i2=async(t,e,r,s)=>{let n=Ob&&!(t||e);if(n)if(Ct)n=sp(Ct)||s&&!r;else if(s&&!r)n=!0;else throw new Error("cannot determine the script source URL.");if(n)return[void 0,Ob];{let o="ort-wasm-simd-threaded.asyncify.mjs",a=t??fA(o,e),i=r&&a&&!sp(a,e),l=i?await Sb(a):a??_A(o,e);return[i?l:void 0,await mA(l)]}}}),Ib,np,yl,Cb,hA,gA,wA,Jb,De,Gs=be(()=>{"use strict";Yb(),np=!1,yl=!1,Cb=!1,hA=()=>{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}},gA=()=>{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}},wA=()=>{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}},Jb=async t=>{if(np)return Promise.resolve();if(yl)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Cb)throw new Error("previous call to 'initializeWebAssembly()' failed.");yl=!0;let e=t.initTimeout,r=t.numThreads;if(t.simd!==!1){if(t.simd==="relaxed"){if(!wA())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!gA())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let s=hA();r>1&&!s&&(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."),t.numThreads=r=1);let n=t.wasmPaths,o=typeof n=="string"?n:void 0,a=n?.mjs,i=a?.href??a,l=n?.wasm,c=l?.href??l,p=t.wasmBinary,[d,_]=await i2(i,o,r>1,!!p||!!c),m=!1,w=[];if(e>0&&w.push(new Promise(x=>{setTimeout(()=>{m=!0,x()},e)})),w.push(new Promise((x,E)=>{let k={numThreads:r};if(p)k.wasmBinary=p,k.locateFile=A=>A;else if(c||o)k.locateFile=A=>c??o+A;else if(i&&i.indexOf("blob:")!==0)k.locateFile=A=>new URL(A,i).href;else if(d){let A=o2();A&&(k.locateFile=T=>A+T)}_(k).then(A=>{yl=!1,np=!0,Ib=A,x(),d&&URL.revokeObjectURL(d)},A=>{yl=!1,Cb=!0,E(A)})})),await Promise.race(w),m)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},De=()=>{if(np&&Ib)return Ib;throw new Error("WebAssembly is not initialized yet.")}}),Lt,pp,Le,Zb=be(()=>{"use strict";Gs(),Lt=(t,e)=>{let r=De(),s=r.lengthBytesUTF8(t)+1,n=r._malloc(s);return r.stringToUTF8(t,n,s),e.push(n),n},pp=(t,e,r,s)=>{if(typeof t=="object"&&t!==null){if(r.has(t))throw new Error("Circular reference in options");r.add(t)}Object.entries(t).forEach(([n,o])=>{let a=e?e+n:n;if(typeof o=="object")pp(o,a+".",r,s);else if(typeof o=="string"||typeof o=="number")s(a,o.toString());else if(typeof o=="boolean")s(a,o?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof o}`)})},Le=t=>{let e=De(),r=e.stackSave();try{let s=e.PTR_SIZE,n=e.stackAlloc(2*s);e._OrtGetLastError(n,n+s);let o=Number(e.getValue(n,s===4?"i32":"i64")),a=e.getValue(n+s,"*"),i=a?e.UTF8ToString(a):"";throw new Error(`${t} ERROR_CODE: ${o}, ERROR_MESSAGE: ${i}`)}finally{e.stackRestore(r)}}}),l2,iz=be(()=>{"use strict";Gs(),Zb(),l2=t=>{let e=De(),r=0,s=[],n=t||{};try{if(t?.logSeverityLevel===void 0)n.logSeverityLevel=2;else if(typeof t.logSeverityLevel!="number"||!Number.isInteger(t.logSeverityLevel)||t.logSeverityLevel<0||t.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${t.logSeverityLevel}`);if(t?.logVerbosityLevel===void 0)n.logVerbosityLevel=0;else if(typeof t.logVerbosityLevel!="number"||!Number.isInteger(t.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${t.logVerbosityLevel}`);t?.terminate===void 0&&(n.terminate=!1);let o=0;return t?.tag!==void 0&&(o=Lt(t.tag,s)),r=e._OrtCreateRunOptions(n.logSeverityLevel,n.logVerbosityLevel,!!n.terminate,o),r===0&&Le("Can't create run options."),t?.extra!==void 0&&pp(t.extra,"",new WeakSet,(a,i)=>{let l=Lt(a,s),c=Lt(i,s);e._OrtAddRunConfigEntry(r,l,c)!==0&&Le(`Can't set a run config entry: ${a} - ${i}.`)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseRunOptions(r),s.forEach(a=>e._free(a)),o}}}),xA,yA,bA,op,Jr,vA,c2,lz=be(()=>{"use strict";Gs(),Zb(),xA=t=>{switch(t){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: ${t}`)}},yA=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},bA=t=>{t.extra||(t.extra={}),t.extra.session||(t.extra.session={});let e=t.extra.session;e.use_ort_model_bytes_directly||(e.use_ort_model_bytes_directly="1"),t.executionProviders&&t.executionProviders.some(r=>(typeof r=="string"?r:r.name)==="webgpu")&&(t.enableMemPattern=!1)},op=(t,e,r,s)=>{let n=Lt(e,s),o=Lt(r,s);De()._OrtAddSessionConfigEntry(t,n,o)!==0&&Le(`Can't set a session config entry: ${e} - ${r}.`)},Jr=(t,e,r,s)=>{let n=Lt(e,s),o=Lt(r,s);t.push([n,o])},vA=async(t,e,r)=>{let s=e.executionProviders;for(let n of s){let o=typeof n=="string"?n:n.name,a=[];switch(o){case"webnn":if(o="WEBNN",typeof n!="string"){let d=n?.deviceType;d&&op(t,"deviceType",d,r)}break;case"webgpu":{o="WebGPU";let d;if(typeof n!="string"){let m=n;if(m.device)if(typeof GPUDevice<"u"&&m.device instanceof GPUDevice)d=m.device;else throw new Error("Invalid GPU device set in WebGPU EP options.");let{enableGraphCapture:w}=e;if(typeof w=="boolean"&&w&&Jr(a,"enableGraphCapture","1",r),typeof m.preferredLayout=="string"&&Jr(a,"preferredLayout",m.preferredLayout,r),m.forceCpuNodeNames){let x=Array.isArray(m.forceCpuNodeNames)?m.forceCpuNodeNames:[m.forceCpuNodeNames];Jr(a,"forceCpuNodeNames",x.join(`
|
|
13
|
+
`),r)}m.validationMode&&Jr(a,"validationMode",m.validationMode,r)}let _=De().webgpuRegisterDevice(d);if(_){let[m,w,x]=_;Jr(a,"deviceId",m.toString(),r),Jr(a,"webgpuInstance",w.toString(),r),Jr(a,"webgpuDevice",x.toString(),r)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${o}`)}let i=Lt(o,r),l=a.length,c=0,p=0;if(l>0){c=De()._malloc(l*De().PTR_SIZE),r.push(c),p=De()._malloc(l*De().PTR_SIZE),r.push(p);for(let d=0;d<l;d++)De().setValue(c+d*De().PTR_SIZE,a[d][0],"*"),De().setValue(p+d*De().PTR_SIZE,a[d][1],"*")}await De()._OrtAppendExecutionProvider(t,i,c,p,l)!==0&&Le(`Can't append execution provider: ${o}.`)}},c2=async t=>{let e=De(),r=0,s=[],n=t||{};bA(n);try{let o=xA(n.graphOptimizationLevel??"all"),a=yA(n.executionMode??"sequential"),i=typeof n.logId=="string"?Lt(n.logId,s):0,l=n.logSeverityLevel??2;if(!Number.isInteger(l)||l<0||l>4)throw new Error(`log severity level is not valid: ${l}`);let c=n.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw new Error(`log verbosity level is not valid: ${c}`);let p=typeof n.optimizedModelFilePath=="string"?Lt(n.optimizedModelFilePath,s):0;if(r=e._OrtCreateSessionOptions(o,!!n.enableCpuMemArena,!!n.enableMemPattern,a,!!n.enableProfiling,0,i,l,c,p),r===0&&Le("Can't create session options."),n.executionProviders&&await vA(r,n,s),n.enableGraphCapture!==void 0){if(typeof n.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${n.enableGraphCapture}`);op(r,"enableGraphCapture",n.enableGraphCapture.toString(),s)}if(n.freeDimensionOverrides)for(let[d,_]of Object.entries(n.freeDimensionOverrides)){if(typeof d!="string")throw new Error(`free dimension override name must be a string: ${d}`);if(typeof _!="number"||!Number.isInteger(_)||_<0)throw new Error(`free dimension override value must be a non-negative integer: ${_}`);let m=Lt(d,s);e._OrtAddFreeDimensionOverride(r,m,_)!==0&&Le(`Can't set a free dimension override: ${d} - ${_}.`)}return n.extra!==void 0&&pp(n.extra,"",new WeakSet,(d,_)=>{op(r,d,_,s)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseSessionOptions(r)!==0&&Le("Can't release session options."),s.forEach(a=>e._free(a)),o}}}),Ds,lp,Bn,Al,dp,e1,t1,Gb,Un=be(()=>{"use strict";Ds=t=>{switch(t){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: ${t}`)}},lp=t=>{switch(t){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: ${t}`)}},Bn=(t,e)=>{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][t],s=typeof e=="number"?e:e.reduce((n,o)=>n*o,1);return r>0?Math.ceil(s*r):void 0},Al=t=>{switch(t){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${t}`)}},dp=t=>{switch(t){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: ${t}`)}},e1=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",t1=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",Gb=t=>{switch(t){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: ${t}`)}}}),r1,u2=be(()=>{"use strict";Qb(),r1=async t=>{if(typeof t=="string"){let e=await fetch(t);if(!e.ok)throw new Error(`failed to load external data file: ${t}`);let r=e.headers.get("Content-Length"),s=r?parseInt(r,10):0;if(s<1073741824)return new Uint8Array(await e.arrayBuffer());{if(!e.body)throw new Error(`failed to load external data file: ${t}, no response body.`);let n=e.body.getReader(),o;try{o=new ArrayBuffer(s)}catch(i){if(i instanceof RangeError){let l=Math.ceil(s/65536);o=new WebAssembly.Memory({initial:l,maximum:l}).buffer}else throw i}let a=0;for(;;){let{done:i,value:l}=await n.read();if(i)break;let c=l.byteLength;new Uint8Array(o,a,c).set(l),a+=c}return new Uint8Array(o,0,s)}}else return t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t instanceof Uint8Array?t:new Uint8Array(t)}}),p2,cz=be(()=>{"use strict";Un(),p2=(t,e)=>new(Al(e))(t)}),kA,EA,AA,MA,d2,SA,yt,f2=be(()=>{"use strict";Un(),kA=["V","I","W","E","F"],EA=(t,e)=>{console.log(`[${kA[t]},${new Date().toISOString()}]${e}`)},d2=(t,e)=>{AA=t,MA=e},SA=(t,e)=>{let r=dp(t),s=dp(AA);r>=s&&EA(r,typeof e=="function"?e():e)},yt=(...t)=>{MA&&SA(...t)}}),Lb,qb,Pb,TA,zb,OA,Nb,$b,Rb,IA,_2,uz=be(()=>{"use strict";Un(),f2(),Lb=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),qb=(t,e)=>{if(e==="int32")return t;let r=Lb.get(e);if(!r)throw new Error(`WebNN backend does not support data type: ${e}`);let s=r/8;if(t.byteLength%s!==0)throw new Error(`Invalid Uint8Array length - must be a multiple of ${s}.`);let n=t.byteLength/s,o=new(Al(e))(t.buffer,t.byteOffset,n);switch(e){case"int64":case"uint64":{let a=new Int32Array(n);for(let i=0;i<n;i++){let l=o[i];if(l>2147483647n||l<-2147483648n)throw new Error("Can not convert int64 data to int32 - value out of range.");a[i]=Number(l)}return new Uint8Array(a.buffer)}case"int8":case"uint8":case"uint32":{if(e==="uint32"&&o.some(i=>i>2147483647))throw new Error("Can not convert uint32 data to int32 - value out of range.");let a=Int32Array.from(o,Number);return new Uint8Array(a.buffer)}default:throw new Error(`Unsupported data conversion from ${e} to 'int32'`)}},Pb=(t,e)=>{if(e==="int32")return t;if(t.byteLength%4!==0)throw new Error("Invalid Uint8Array length - must be a multiple of 4 (int32).");let r=t.byteLength/4,s=new Int32Array(t.buffer,t.byteOffset,r);switch(e){case"int64":{let n=BigInt64Array.from(s,BigInt);return new Uint8Array(n.buffer)}case"uint64":{if(s.some(o=>o<0))throw new Error("Can not convert int32 data to uin64 - negative value found.");let n=BigUint64Array.from(s,BigInt);return new Uint8Array(n.buffer)}case"int8":{if(s.some(o=>o<-128||o>127))throw new Error("Can not convert int32 data to int8 - value out of range.");let n=Int8Array.from(s,Number);return new Uint8Array(n.buffer)}case"uint8":{if(s.some(n=>n<0||n>255))throw new Error("Can not convert int32 data to uint8 - value out of range.");return Uint8Array.from(s,Number)}case"uint32":{if(s.some(o=>o<0))throw new Error("Can not convert int32 data to uint32 - negative value found.");let n=Uint32Array.from(s,Number);return new Uint8Array(n.buffer)}default:throw new Error(`Unsupported data conversion from 'int32' to ${e}`)}},TA=1,zb=()=>TA++,OA=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),Nb=(t,e)=>{let r=Lb.get(t);if(!r)throw new Error(`WebNN backend does not support data type: ${t}`);return e.length>0?Math.ceil(e.reduce((s,n)=>s*n)*r/8):0},$b=class{constructor(t){this.isDataConverted=!1;let{sessionId:e,context:r,tensor:s,dataType:n,shape:o,fallbackDataType:a}=t;this.sessionId=e,this.mlContext=r,this.mlTensor=s,this.dataType=n,this.tensorShape=o,this.fallbackDataType=a}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return Nb(this.dataType,this.tensorShape)}destroy(){yt("verbose",()=>"[WebNN] TensorWrapper.destroy"),this.mlTensor.destroy()}write(t){this.mlContext.writeTensor(this.mlTensor,t)}async read(t){if(this.fallbackDataType){let e=await this.mlContext.readTensor(this.mlTensor),r=Pb(new Uint8Array(e),this.dataType);if(t){(t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)).set(r);return}else return r.buffer}else return t?this.mlContext.readTensor(this.mlTensor,t):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(t,e,r){return this.mlContext===t&&this.dataType===e&&this.tensorShape.length===r.length&&this.tensorShape.every((s,n)=>s===r[n])}setIsDataConverted(t){this.isDataConverted=t}},Rb=class{constructor(t,e){this.tensorManager=t,this.wrapper=e}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(t,e,r,s){let n=this.tensorManager.getMLContext(t),o=this.tensorManager.getMLOpSupportLimits(t),a;if(!o?.input.dataTypes.includes(e)){if(a=OA.get(e),!a||o?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);yt("verbose",()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${e} to ${a}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(n,e,r))return this.wrapper.tensor;if(s){if(this.wrapper.byteLength!==Nb(e,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(t,e,r,i,!0,!0,a),s&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(t){let e=t;if(this.wrapper){if(this.wrapper.fallbackType)if(this.wrapper.fallbackType==="int32")e=qb(t,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw new Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`);if(t.byteLength===this.wrapper.byteLength){this.wrapper.write(e);return}else yt("verbose",()=>"Data size does not match tensor size. Releasing tensor."),this.releaseTensor()}this.activeUpload?this.activeUpload.set(e):this.activeUpload=new Uint8Array(e)}async download(t){if(this.activeUpload){let e=this.wrapper?.isDataConverted?Pb(this.activeUpload,this.wrapper?.type):this.activeUpload;if(t){t instanceof ArrayBuffer?new Uint8Array(t).set(e):new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(e);return}else return e.buffer}if(!this.wrapper)throw new Error("Tensor has not been created.");return t?this.wrapper.read(t):this.wrapper.read()}},IA=class{constructor(t){this.backend=t,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(t){let e=this.backend.getMLContext(t);if(!e)throw new Error("MLContext not found for session.");return e}getMLOpSupportLimits(t){return this.backend.getMLOpSupportLimits(t)}reserveTensorId(){let t=zb();return this.tensorTrackersById.set(t,new Rb(this)),t}releaseTensorId(t){let e=this.tensorTrackersById.get(t);e&&(this.tensorTrackersById.delete(t),e.tensorWrapper&&this.releaseTensor(e.tensorWrapper))}async ensureTensor(t,e,r,s,n){yt("verbose",()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${e}, dataType: ${r}, shape: ${s}, copyOld: ${n}}`);let o=this.tensorTrackersById.get(e);if(!o)throw new Error("Tensor not found.");return o.ensureTensor(t,r,s,n)}upload(t,e){let r=this.tensorTrackersById.get(t);if(!r)throw new Error("Tensor not found.");r.upload(e)}async download(t,e){yt("verbose",()=>`[WebNN] TensorManager.download {tensorId: ${t}, dstBuffer: ${e?.byteLength}}`);let r=this.tensorTrackersById.get(t);if(!r)throw new Error("Tensor not found.");return r.download(e)}releaseTensorsForSession(t){for(let e of this.freeTensors)e.sessionId===t&&e.destroy();this.freeTensors=this.freeTensors.filter(e=>e.sessionId!==t)}registerTensor(t,e,r,s){let n=this.getMLContext(t),o=zb(),a=new $b({sessionId:t,context:n,tensor:e,dataType:r,shape:s});return this.tensorTrackersById.set(o,new Rb(this,a)),this.externalTensors.add(a),o}async getCachedTensor(t,e,r,s,n,o,a){let i=this.getMLContext(t);for(let[c,p]of this.freeTensors.entries())if(p.canReuseTensor(i,e,r)){yt("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}`);let d=this.freeTensors.splice(c,1)[0];return d.sessionId=t,d}yt("verbose",()=>`[WebNN] MLContext.createTensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}}`);let l=await i.createTensor({dataType:a??e,shape:r,dimensions:r,usage:s,writable:n,readable:o});return new $b({sessionId:t,context:i,tensor:l,dataType:e,shape:r,fallbackDataType:a})}releaseTensor(t){this.externalTensors.has(t)&&this.externalTensors.delete(t),this.freeTensors.push(t)}},_2=(...t)=>new IA(...t)}),m2={};Ml(m2,{WebNNBackend:()=>h2});var bl,CA,h2,pz=be(()=>{"use strict";Un(),Gs(),cz(),uz(),f2(),bl=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),CA=(t,e)=>{if(t===e)return!0;if(t===void 0||e===void 0)return!1;let r=Object.keys(t).sort(),s=Object.keys(e).sort();return r.length===s.length&&r.every((n,o)=>n===s[o]&&t[n]===e[n])},h2=class{constructor(t){this.tensorManager=_2(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,d2(t.logLevel,!!t.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(t){yt("verbose",()=>`[WebNN] onRunStart {sessionId: ${t}}`),this.activeSessionId=t}onRunEnd(t){yt("verbose",()=>`[WebNN] onRunEnd {sessionId: ${t}}`);let e=this.temporarySessionTensorIds.get(t);if(e){for(let r of e)yt("verbose",()=>`[WebNN] releasing temporary tensor {tensorId: ${r}}`),this.tensorManager.releaseTensorId(r);this.temporarySessionTensorIds.delete(t),this.activeSessionId=void 0}}async createMLContext(t){if(t instanceof GPUDevice){let r=this.mlContextCache.findIndex(s=>s.gpuDevice===t);if(r!==-1)return this.mlContextCache[r].mlContext;{let s=await navigator.ml.createContext(t);return this.mlContextCache.push({gpuDevice:t,mlContext:s}),s}}else if(t===void 0){let r=this.mlContextCache.findIndex(s=>s.options===void 0&&s.gpuDevice===void 0);if(r!==-1)return this.mlContextCache[r].mlContext;{let s=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:s}),s}}let e=this.mlContextCache.findIndex(r=>CA(r.options,t));if(e!==-1)return this.mlContextCache[e].mlContext;{let r=await navigator.ml.createContext(t);return this.mlContextCache.push({options:t,mlContext:r}),r}}registerMLContext(t,e){this.mlContextBySessionId.set(t,e);let r=this.sessionIdsByMLContext.get(e);r||(r=new Set,this.sessionIdsByMLContext.set(e,r)),r.add(t),this.mlOpSupportLimitsBySessionId.has(t)||this.mlOpSupportLimitsBySessionId.set(t,e.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(t,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(t,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(t){this.sessionGraphInputs.delete(t),this.sessionGraphOutputs.delete(t);let e=this.mlContextBySessionId.get(t);if(!e)return;this.tensorManager.releaseTensorsForSession(t),this.mlContextBySessionId.delete(t),this.mlOpSupportLimitsBySessionId.delete(t);let r=this.sessionIdsByMLContext.get(e);if(r.delete(t),r.size===0){this.sessionIdsByMLContext.delete(e);let s=this.mlContextCache.findIndex(n=>n.mlContext===e);s!==-1&&this.mlContextCache.splice(s,1)}}getMLContext(t){return this.mlContextBySessionId.get(t)}getMLOpSupportLimits(t){return this.mlOpSupportLimitsBySessionId.get(t)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(t){yt("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t)}async ensureTensor(t,e,r,s,n){let o=bl.get(r);if(!o)throw new Error(`Unsupported ONNX data type: ${r}`);return this.tensorManager.ensureTensor(t??this.currentSessionId,e,o,s,n)}async createTemporaryTensor(t,e,r){yt("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${r}}`);let s=bl.get(e);if(!s)throw new Error(`Unsupported ONNX data type: ${e}`);let n=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(t,n,s,r,!1);let o=this.temporarySessionTensorIds.get(t);return o?o.push(n):this.temporarySessionTensorIds.set(t,[n]),n}uploadTensor(t,e){if(!De().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");yt("verbose",()=>`[WebNN] uploadTensor {tensorId: ${t}, data: ${e.byteLength}}`),this.tensorManager.upload(t,e)}async downloadTensor(t,e){return this.tensorManager.download(t,e)}createMLTensorDownloader(t,e){return async()=>{let r=await this.tensorManager.download(t);return p2(r,e)}}registerMLTensor(t,e,r,s){let n=bl.get(r);if(!n)throw new Error(`Unsupported ONNX data type: ${r}`);let o=this.tensorManager.registerTensor(t,e,n,s);return yt("verbose",()=>`[WebNN] registerMLTensor {tensor: ${e}, dataType: ${n}, dimensions: ${s}} -> {tensorId: ${o}}`),o}registerMLConstant(t,e,r,s,n,o,a=!1){if(!o)throw new Error("External mounted files are not available.");let i=t;t.startsWith("./")&&(i=t.substring(2));let l=o.get(i);if(!l)throw new Error(`File with name ${i} not found in preloaded files.`);if(e+r>l.byteLength)throw new Error("Out of bounds: data offset and length exceed the external file data size.");let c=l.slice(e,e+r).buffer,p;switch(n.dataType){case"float32":p=new Float32Array(c);break;case"float16":p=typeof Float16Array<"u"&&Float16Array.from?new Float16Array(c):new Uint16Array(c);break;case"int32":p=new Int32Array(c);break;case"uint32":p=new Uint32Array(c);break;case"int64":if(a){let d=qb(new Uint8Array(c),"int64");p=new Int32Array(d.buffer),n.dataType="int32"}else p=new BigInt64Array(c);break;case"uint64":p=new BigUint64Array(c);break;case"int8":p=new Int8Array(c);break;case"int4":case"uint4":case"uint8":p=new Uint8Array(c);break;default:throw new Error(`Unsupported data type: ${n.dataType} in creating WebNN Constant from external data.`)}return yt("verbose",()=>`[WebNN] registerMLConstant {dataType: ${n.dataType}, shape: ${n.shape}}} ${a?"(Note: it was int64 data type and registered to int32 as workaround)":""}`),s.constant(n,p)}registerGraphInput(t){this.temporaryGraphInputs.push(t)}registerGraphOutput(t){this.temporaryGraphOutputs.push(t)}isGraphInput(t,e){let r=this.sessionGraphInputs.get(t);return r?r.includes(e):!1}isGraphOutput(t,e){let r=this.sessionGraphOutputs.get(t);return r?r.includes(e):!1}isGraphInputOutputTypeSupported(t,e,r=!0){let s=bl.get(Ds(e)),n=this.mlOpSupportLimitsBySessionId.get(t);return typeof s>"u"?!1:r?!!n?.input.dataTypes.includes(s):!!n?.output.dataTypes.includes(s)}flush(){}}}),LA,s1,n1,Zr,PA,Db,fp,o1,a1,Fb,i1,l1,c1,g2=be(()=>{"use strict";js(),iz(),lz(),Un(),Gs(),Zb(),u2(),LA=(t,e)=>{De()._OrtInit(t,e)!==0&&Le("Can't initialize onnxruntime.")},s1=async t=>{LA(t.wasm.numThreads,dp(t.logLevel))},n1=async(t,e)=>{De().asyncInit?.();let r=t.webgpu.adapter;if(e==="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 s=t.webgpu.powerPreference;if(s!==void 0&&s!=="low-power"&&s!=="high-performance")throw new Error(`Invalid powerPreference setting: "${s}"`);let n=t.webgpu.forceFallbackAdapter;if(n!==void 0&&typeof n!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${n}"`);if(r=await navigator.gpu.requestAdapter({powerPreference:s,forceFallbackAdapter:n}),!r)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(e==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment");if(e==="webgpu"&&De().webgpuInit(s=>{t.webgpu.device=s}),e==="webnn"){let s=new(pz(),cp(m2)).WebNNBackend(t);De().webnnInit([s,()=>s.reserveTensorId(),n=>s.releaseTensorId(n),async(n,o,a,i,l)=>s.ensureTensor(n,o,a,i,l),(n,o)=>{s.uploadTensor(n,o)},async(n,o)=>s.downloadTensor(n,o),(n,o)=>s.registerMLContext(n,o),!!t.trace])}},Zr=new Map,PA=t=>{let e=De(),r=e.stackSave();try{let s=e.PTR_SIZE,n=e.stackAlloc(2*s);e._OrtGetInputOutputCount(t,n,n+s)!==0&&Le("Can't get session input/output count.");let o=s===4?"i32":"i64";return[Number(e.getValue(n,o)),Number(e.getValue(n+s,o))]}finally{e.stackRestore(r)}},Db=(t,e)=>{let r=De(),s=r.stackSave(),n=0;try{let o=r.PTR_SIZE,a=r.stackAlloc(2*o);r._OrtGetInputOutputMetadata(t,e,a,a+o)!==0&&Le("Can't get session input/output metadata.");let i=Number(r.getValue(a,"*"));n=Number(r.getValue(a+o,"*"));let l=r.HEAP32[n/4];if(l===0)return[i,0];let c=r.HEAPU32[n/4+1],p=[];for(let d=0;d<c;d++){let _=Number(r.getValue(n+8+d*o,"*"));p.push(_!==0?r.UTF8ToString(_):Number(r.getValue(n+8+(d+c)*o,"*")))}return[i,l,p]}finally{r.stackRestore(s),n!==0&&r._OrtFree(n)}},fp=t=>{let e=De(),r=e._malloc(t.byteLength);if(r===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${t.byteLength}.`);return e.HEAPU8.set(t,r),[r,t.byteLength]},o1=async(t,e)=>{let r,s,n=De();Array.isArray(t)?[r,s]=t:t.buffer===n.HEAPU8.buffer?[r,s]=[t.byteOffset,t.byteLength]:[r,s]=fp(t);let o=0,a=0,i=0,l=[],c=[],p=[];try{if([a,l]=await c2(e),e?.externalData&&n.mountExternalData){let S=[];for(let L of e.externalData){let O=typeof L=="string"?L:L.path;S.push(r1(typeof L=="string"?L:L.data).then(v=>{n.mountExternalData(O,v)}))}await Promise.all(S)}for(let S of e?.executionProviders??[])if((typeof S=="string"?S:S.name)==="webnn"){if(n.shouldTransferToMLTensor=!1,typeof S!="string"){let L=S,O=L?.context,v=L?.gpuDevice,W=L?.deviceType,X=L?.powerPreference;O?n.currentContext=O:v?n.currentContext=await n.webnnCreateMLContext(v):n.currentContext=await n.webnnCreateMLContext({deviceType:W,powerPreference:X})}else n.currentContext=await n.webnnCreateMLContext();break}o=await n._OrtCreateSession(r,s,a),n.webgpuOnCreateSession?.(o),o===0&&Le("Can't create a session."),n.jsepOnCreateSession?.(),n.currentContext&&(n.webnnRegisterMLContext(o,n.currentContext),n.currentContext=void 0,n.shouldTransferToMLTensor=!0);let[d,_]=PA(o),m=!!e?.enableGraphCapture,w=[],x=[],E=[],k=[],A=[];for(let S=0;S<d;S++){let[L,O,v]=Db(o,S);L===0&&Le("Can't get an input name."),c.push(L);let W=n.UTF8ToString(L);w.push(W),E.push(O===0?{name:W,isTensor:!1}:{name:W,isTensor:!0,type:lp(O),shape:v})}for(let S=0;S<_;S++){let[L,O,v]=Db(o,S+d);L===0&&Le("Can't get an output name."),p.push(L);let W=n.UTF8ToString(L);x.push(W),k.push(O===0?{name:W,isTensor:!1}:{name:W,isTensor:!0,type:lp(O),shape:v});{if(m&&e?.preferredOutputLocation===void 0){A.push("gpu-buffer");continue}let X=typeof e?.preferredOutputLocation=="string"?e.preferredOutputLocation:e?.preferredOutputLocation?.[W]??"cpu",B=n.webnnIsGraphOutput;if(X==="cpu"&&B&&B(o,W)){A.push("ml-tensor-cpu-output");continue}if(X!=="cpu"&&X!=="cpu-pinned"&&X!=="gpu-buffer"&&X!=="ml-tensor")throw new Error(`Not supported preferred output location: ${X}.`);if(m&&X!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${X}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);A.push(X)}}let T=null;return A.some(S=>S==="gpu-buffer"||S==="ml-tensor"||S==="ml-tensor-cpu-output")&&(i=n._OrtCreateBinding(o),i===0&&Le("Can't create IO binding."),T={handle:i,outputPreferredLocations:A,outputPreferredLocationsEncoded:A.map(S=>S==="ml-tensor-cpu-output"?"ml-tensor":S).map(S=>Gb(S))}),Zr.set(o,[o,c,p,T,m,!1]),[o,w,x,E,k]}catch(d){throw c.forEach(_=>n._OrtFree(_)),p.forEach(_=>n._OrtFree(_)),i!==0&&n._OrtReleaseBinding(i)!==0&&Le("Can't release IO binding."),o!==0&&n._OrtReleaseSession(o)!==0&&Le("Can't release session."),d}finally{n._free(r),a!==0&&n._OrtReleaseSessionOptions(a)!==0&&Le("Can't release session options."),l.forEach(d=>n._free(d)),n.unmountExternalData?.()}},a1=t=>{let e=De(),r=Zr.get(t);if(!r)throw new Error(`cannot release session. invalid session id: ${t}`);let[s,n,o,a,i]=r;a&&(i&&e._OrtClearBoundOutputs(a.handle)!==0&&Le("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&Le("Can't release IO binding.")),e.jsepOnReleaseSession?.(t),e.webnnOnReleaseSession?.(t),e.webgpuOnReleaseSession?.(t),n.forEach(l=>e._OrtFree(l)),o.forEach(l=>e._OrtFree(l)),e._OrtReleaseSession(s)!==0&&Le("Can't release session."),Zr.delete(t)},Fb=async(t,e,r,s,n,o,a=!1)=>{if(!t){e.push(0);return}let i=De(),l=i.PTR_SIZE,c=t[0],p=t[1],d=t[3],_=d,m,w;if(c==="string"&&(d==="gpu-buffer"||d==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(a&&d!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${o} when enableGraphCapture is true.`);if(d==="gpu-buffer"){let k=t[2].gpuBuffer;w=Bn(Ds(c),p);{let A=i.webgpuRegisterBuffer;if(!A)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');m=A(k,s)}}else if(d==="ml-tensor"){let k=t[2].mlTensor;w=Bn(Ds(c),p);let A=i.webnnRegisterMLTensor;if(!A)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');m=A(s,k,Ds(c),p)}else{let k=t[2];if(Array.isArray(k)){w=l*k.length,m=i._malloc(w),r.push(m);for(let A=0;A<k.length;A++){if(typeof k[A]!="string")throw new TypeError(`tensor data at index ${A} is not a string`);i.setValue(m+A*l,Lt(k[A],r),"*")}}else{let A=i.webnnIsGraphInput,T=i.webnnIsGraphOutput;if(c!=="string"&&A&&T){let S=i.UTF8ToString(n);if(A(s,S)||T(s,S)){let L=Ds(c);w=Bn(L,p),_="ml-tensor";let O=i.webnnCreateTemporaryTensor,v=i.webnnUploadTensor;if(!O||!v)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let W=await O(s,L,p);v(W,new Uint8Array(k.buffer,k.byteOffset,k.byteLength)),m=W}else w=k.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(k.buffer,k.byteOffset,w),m)}else w=k.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(k.buffer,k.byteOffset,w),m)}}let x=i.stackSave(),E=i.stackAlloc(4*p.length);try{p.forEach((A,T)=>i.setValue(E+T*l,A,l===4?"i32":"i64"));let k=i._OrtCreateTensor(Ds(c),m,w,E,p.length,Gb(_));k===0&&Le(`Can't create tensor for input/output. session=${s}, index=${o}.`),e.push(k)}finally{i.stackRestore(x)}},i1=async(t,e,r,s,n,o)=>{let a=De(),i=a.PTR_SIZE,l=Zr.get(t);if(!l)throw new Error(`cannot run inference. invalid session id: ${t}`);let c=l[0],p=l[1],d=l[2],_=l[3],m=l[4],w=l[5],x=e.length,E=s.length,k=0,A=[],T=[],S=[],L=[],O=[],v=a.stackSave(),W=a.stackAlloc(x*i),X=a.stackAlloc(x*i),B=a.stackAlloc(E*i),H=a.stackAlloc(E*i);try{[k,A]=l2(o),ts("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)await Fb(r[C],T,L,t,p[e[C]],e[C],m);for(let C=0;C<E;C++)await Fb(n[C],S,L,t,d[s[C]],x+s[C],m);rs("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)a.setValue(W+C*i,T[C],"*"),a.setValue(X+C*i,p[e[C]],"*");for(let C=0;C<E;C++)a.setValue(B+C*i,S[C],"*"),a.setValue(H+C*i,d[s[C]],"*");if(_&&!w){let{handle:C,outputPreferredLocations:te,outputPreferredLocationsEncoded:ae}=_;if(p.length!==x)throw new Error(`input count from feeds (${x}) is expected to be always equal to model's input count (${p.length}).`);ts("wasm bindInputsOutputs");for(let P=0;P<x;P++){let $=e[P];await a._OrtBindInput(C,p[$],T[P])!==0&&Le(`Can't bind input[${P}] for session=${t}.`)}for(let P=0;P<E;P++){let $=s[P];n[P]?.[3]?(O.push(S[P]),a._OrtBindOutput(C,d[$],S[P],0)!==0&&Le(`Can't bind pre-allocated output[${P}] for session=${t}.`)):a._OrtBindOutput(C,d[$],0,ae[$])!==0&&Le(`Can't bind output[${P}] to ${te[P]} for session=${t}.`)}rs("wasm bindInputsOutputs"),Zr.set(t,[c,p,d,_,m,!0])}a.jsepOnRunStart?.(c),a.webnnOnRunStart?.(c);let G;_?G=await a._OrtRunWithBinding(c,_.handle,E,B,k):G=await a._OrtRun(c,X,W,x,H,E,B,k),G!==0&&Le("failed to call OrtRun().");let Q=[],R=[];ts("wasm ProcessOutputTensor");for(let C=0;C<E;C++){let te=Number(a.getValue(B+C*i,"*"));if(te===S[C]||O.includes(S[C])){Q.push(n[C]),te!==S[C]&&a._OrtReleaseTensor(te)!==0&&Le("Can't release tensor.");continue}let ae=a.stackSave(),P=a.stackAlloc(4*i),$=!1,F,J=0;try{a._OrtGetTensorData(te,P,P+i,P+2*i,P+3*i)!==0&&Le(`Can't access output tensor data on index ${C}.`);let xe=i===4?"i32":"i64",ue=Number(a.getValue(P,xe));J=a.getValue(P+i,"*");let Ve=a.getValue(P+i*2,"*"),ot=Number(a.getValue(P+i*3,xe)),_t=[];for(let Fe=0;Fe<ot;Fe++)_t.push(Number(a.getValue(Ve+Fe*i,xe)));a._OrtFree(Ve)!==0&&Le("Can't free memory for tensor dims.");let at=_t.reduce((Fe,Me)=>Fe*Me,1);F=lp(ue);let vt=_?.outputPreferredLocations[s[C]];if(F==="string"){if(vt==="gpu-buffer"||vt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Fe=[];for(let Me=0;Me<at;Me++){let et=a.getValue(J+Me*i,"*"),sr=a.getValue(J+(Me+1)*i,"*"),ze=Me===at-1?void 0:sr-et;Fe.push(a.UTF8ToString(et,ze))}Q.push([F,_t,Fe,"cpu"])}else if(vt==="gpu-buffer"&&at>0){let Fe=a.webgpuGetBuffer;if(!Fe)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Me=Fe(J),et=Bn(ue,at);if(et===void 0||!e1(F))throw new Error(`Unsupported data type: ${F}`);$=!0;{a.webgpuRegisterBuffer(Me,t,J);let sr=a.webgpuCreateDownloader(Me,et,t);Q.push([F,_t,{gpuBuffer:Me,download:async()=>{let ze=await sr();return new(Al(F))(ze)},dispose:()=>{a._OrtReleaseTensor(te)!==0&&Le("Can't release tensor.")}},"gpu-buffer"])}}else if(vt==="ml-tensor"&&at>0){let Fe=a.webnnEnsureTensor,Me=a.webnnIsGraphInputOutputTypeSupported;if(!Fe||!Me)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Bn(ue,at)===void 0||!t1(F))throw new Error(`Unsupported data type: ${F}`);if(!Me(t,F,!1))throw new Error(`preferredLocation "ml-tensor" for ${F} output is not supported by current WebNN Context.`);let et=await Fe(t,J,ue,_t,!1);$=!0,Q.push([F,_t,{mlTensor:et,download:a.webnnCreateMLTensorDownloader(J,F),dispose:()=>{a.webnnReleaseTensorId(J),a._OrtReleaseTensor(te)}},"ml-tensor"])}else if(vt==="ml-tensor-cpu-output"&&at>0){let Fe=a.webnnCreateMLTensorDownloader(J,F)(),Me=Q.length;$=!0,R.push((async()=>{let et=[Me,await Fe];return a.webnnReleaseTensorId(J),a._OrtReleaseTensor(te),et})()),Q.push([F,_t,[],"cpu"])}else{let Fe=Al(F),Me=new Fe(at);new Uint8Array(Me.buffer,Me.byteOffset,Me.byteLength).set(a.HEAPU8.subarray(J,J+Me.byteLength)),Q.push([F,_t,Me,"cpu"])}}finally{a.stackRestore(ae),F==="string"&&J&&a._free(J),$||a._OrtReleaseTensor(te)}}_&&!m&&(a._OrtClearBoundOutputs(_.handle)!==0&&Le("Can't clear bound outputs."),Zr.set(t,[c,p,d,_,m,!1]));for(let[C,te]of await Promise.all(R))Q[C][2]=te;return rs("wasm ProcessOutputTensor"),Q}finally{a.webnnOnRunEnd?.(c),a.stackRestore(v),r.forEach(G=>{G&&G[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(G[2].gpuBuffer)}),n.forEach(G=>{G&&G[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(G[2].gpuBuffer)}),T.forEach(G=>a._OrtReleaseTensor(G)),S.forEach(G=>a._OrtReleaseTensor(G)),L.forEach(G=>a._free(G)),k!==0&&a._OrtReleaseRunOptions(k),A.forEach(G=>a._free(G))}},l1=t=>{let e=De(),r=Zr.get(t);if(!r)throw new Error("invalid session id");let s=r[0],n=e._OrtEndProfiling(s);n===0&&Le("Can't get an profile file name."),e._OrtFree(n)},c1=t=>{let e=[];for(let r of t){let s=r[2];!Array.isArray(s)&&"buffer"in s&&e.push(s.buffer)}return e}}),es,Bt,Fn,vl,kl,ap,Bb,ip,Ns,$s,zA,w2,x2,y2,b2,v2,k2,E2,A2=be(()=>{"use strict";js(),g2(),Gs(),Yb(),es=()=>!!Xe.wasm.proxy&&typeof document<"u",Fn=!1,vl=!1,kl=!1,ip=new Map,Ns=(t,e)=>{let r=ip.get(t);r?r.push(e):ip.set(t,[e])},$s=()=>{if(Fn||!vl||kl||!Bt)throw new Error("worker not ready")},zA=t=>{switch(t.data.type){case"init-wasm":Fn=!1,t.data.err?(kl=!0,Bb[1](t.data.err)):(vl=!0,Bb[0]()),ap&&(URL.revokeObjectURL(ap),ap=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=ip.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}default:}},w2=async()=>{if(!vl){if(Fn)throw new Error("multiple calls to 'initWasm()' detected.");if(kl)throw new Error("previous call to 'initWasm()' failed.");if(Fn=!0,es())return new Promise((t,e)=>{Bt?.terminate(),a2().then(([r,s])=>{try{Bt=s,Bt.onerror=o=>e(o),Bt.onmessage=zA,Bb=[t,e];let n={type:"init-wasm",in:Xe};!n.in.wasm.wasmPaths&&(r||jb)&&(n.in.wasm.wasmPaths={wasm:new URL("ort-wasm-simd-threaded.asyncify.wasm",Jt.url).href}),Bt.postMessage(n),ap=r}catch(n){e(n)}},e)});try{await Jb(Xe.wasm),await s1(Xe),vl=!0}catch(t){throw kl=!0,t}finally{Fn=!1}}},x2=async t=>{if(es())return $s(),new Promise((e,r)=>{Ns("init-ep",[e,r]);let s={type:"init-ep",in:{epName:t,env:Xe}};Bt.postMessage(s)});await n1(Xe,t)},y2=async t=>es()?($s(),new Promise((e,r)=>{Ns("copy-from",[e,r]);let s={type:"copy-from",in:{buffer:t}};Bt.postMessage(s,[t.buffer])})):fp(t),b2=async(t,e)=>{if(es()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return $s(),new Promise((r,s)=>{Ns("create",[r,s]);let n={type:"create",in:{model:t,options:{...e}}},o=[];t instanceof Uint8Array&&o.push(t.buffer),Bt.postMessage(n,o)})}else return o1(t,e)},v2=async t=>{if(es())return $s(),new Promise((e,r)=>{Ns("release",[e,r]);let s={type:"release",in:t};Bt.postMessage(s)});a1(t)},k2=async(t,e,r,s,n,o)=>{if(es()){if(r.some(a=>a[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(n.some(a=>a))throw new Error("pre-allocated output tensor is not supported for proxy.");return $s(),new Promise((a,i)=>{Ns("run",[a,i]);let l=r,c={type:"run",in:{sessionId:t,inputIndices:e,inputs:l,outputIndices:s,options:o}};Bt.postMessage(c,c1(l))})}else return i1(t,e,r,s,n,o)},E2=async t=>{if(es())return $s(),new Promise((e,r)=>{Ns("end-profiling",[e,r]);let s={type:"end-profiling",in:t};Bt.postMessage(s)});l1(t)}}),Ub,NA,M2,dz=be(()=>{"use strict";js(),A2(),Un(),Qb(),u2(),Ub=(t,e)=>{switch(t.location){case"cpu":return[t.type,t.dims,t.data,"cpu"];case"gpu-buffer":return[t.type,t.dims,{gpuBuffer:t.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[t.type,t.dims,{mlTensor:t.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${t.location} for ${e()}`)}},NA=t=>{switch(t[3]){case"cpu":return new Zt(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!e1(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:r,download:s,dispose:n}=t[2];return Zt.fromGpuBuffer(r,{dataType:e,dims:t[1],download:s,dispose:n})}case"ml-tensor":{let e=t[0];if(!t1(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:r,download:s,dispose:n}=t[2];return Zt.fromMLTensor(r,{dataType:e,dims:t[1],download:s,dispose:n})}default:throw new Error(`invalid data location: ${t[3]}`)}},M2=class{async fetchModelAndCopyToWasmMemory(t){return y2(await r1(t))}async loadModel(t,e){Bs();let r;typeof t=="string"?r=await this.fetchModelAndCopyToWasmMemory(t):r=t,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await b2(r,e),Us()}async dispose(){return v2(this.sessionId)}async run(t,e,r){Bs();let s=[],n=[];Object.entries(t).forEach(d=>{let _=d[0],m=d[1],w=this.inputNames.indexOf(_);if(w===-1)throw new Error(`invalid input '${_}'`);s.push(m),n.push(w)});let o=[],a=[];Object.entries(e).forEach(d=>{let _=d[0],m=d[1],w=this.outputNames.indexOf(_);if(w===-1)throw new Error(`invalid output '${_}'`);o.push(m),a.push(w)});let i=s.map((d,_)=>Ub(d,()=>`input "${this.inputNames[n[_]]}"`)),l=o.map((d,_)=>d?Ub(d,()=>`output "${this.outputNames[a[_]]}"`):null),c=await k2(this.sessionId,n,i,a,l,r),p={};for(let d=0;d<c.length;d++)p[this.outputNames[a[d]]]=o[d]??NA(c[d]);return Us(),p}startProfiling(){}endProfiling(){E2(this.sessionId)}}}),S2={};Ml(S2,{OnnxruntimeWebAssemblyBackend:()=>Vb,initializeFlags:()=>Wb,wasmBackend:()=>T2});var Wb,Vb,T2,fz=be(()=>{"use strict";js(),A2(),dz(),Wb=()=>{(typeof Xe.wasm.initTimeout!="number"||Xe.wasm.initTimeout<0)&&(Xe.wasm.initTimeout=0);let t=Xe.wasm.simd;if(typeof t!="boolean"&&t!==void 0&&t!=="fixed"&&t!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${t}". Reset it to \`false\` and ignore SIMD feature checking.`),Xe.wasm.simd=!1),typeof Xe.wasm.proxy!="boolean"&&(Xe.wasm.proxy=!1),typeof Xe.wasm.trace!="boolean"&&(Xe.wasm.trace=!1),typeof Xe.wasm.numThreads!="number"||!Number.isInteger(Xe.wasm.numThreads)||Xe.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)Xe.wasm.numThreads=1;else{let e=typeof navigator>"u"?qP("node:os").cpus().length:navigator.hardwareConcurrency;Xe.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},Vb=class{async init(t){Wb(),await w2(),await x2(t)}async createInferenceSessionHandler(t,e){let r=new M2;return await r.loadModel(t,e),r}},T2=new Vb});js();js();js();var _z="1.25.0-dev.20260307-d626b568e0",mz=e2;{let t=(fz(),cp(S2)).wasmBackend;Fs("webgpu",t,5),Fs("webnn",t,5),Fs("cpu",t,10),Fs("wasm",t,10)}Object.defineProperty(Xe.versions,"web",{value:_z,enumerable:!0});async function O2(t){let e=t.split("/").pop(),r;try{if(r=await Yt(),r){let n=await r.match(t);if(n)return n}}catch(n){Z.warn(`Failed to load ${e} from cache:`,n)}let s=await fe.fetch(t);if(!s.ok)throw new Error(`Failed to fetch ${e}: ${s.status} ${s.statusText}`);if(r)try{await r.put(t,s.clone())}catch(n){Z.warn(`Failed to cache ${e}:`,n)}return s}async function I2(t){let e=await O2(t);if(!e||typeof e=="string")return null;try{return await e.arrayBuffer()}catch(r){return Z.warn("Failed to read WASM binary:",r),null}}async function C2(t){if(ie.IS_SERVICE_WORKER_ENV||ie.IS_CHROME_AVAILABLE)return t;let e=await O2(t);if(!e||typeof e=="string")return null;try{let r=await e.text();r=r.replaceAll("globalThis.process?.versions?.node","false");let s=new Blob([r],{type:"text/javascript"});return URL.createObjectURL(s)}catch(r){return Z.warn("Failed to read WASM factory:",r),null}}var d1=require("onnxruntime-common"),gz=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 N2(t){return t<=Mt.DEBUG?0:t<=Mt.INFO?2:t<=Mt.WARNING||t<=Mt.ERROR?3:4}var wz={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},Ut=[],p1,Gn,L2=Symbol.for("onnxruntime");if(L2 in globalThis)Gn=globalThis[L2];else if(ie.IS_NODE_ENV){switch(Gn=hz,process.platform){case"win32":Ut.push("dml");break;case"linux":process.arch==="x64"&&Ut.push("cuda");break;case"darwin":Ut.push("coreml");break}Ut.push("webgpu"),Ut.push("cpu"),p1=["cpu"]}else Gn=u1,ie.IS_WEBNN_AVAILABLE&&Ut.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),ie.IS_WEBGPU_AVAILABLE&&Ut.push("webgpu"),Ut.push("wasm"),p1=["wasm"];var xz=Gn.InferenceSession;function $2(t=null){if(!t)return p1;switch(t){case"auto":return Ut;case"gpu":return Ut.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(Ut.includes(t))return[gz[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${Ut.join(", ")}.`)}var P2=Promise.resolve(),jn=null;async function yz(){if(jn)return jn;if(!(fe.useWasmCache&&typeof st?.wasm?.wasmPaths=="object"&&st?.wasm?.wasmPaths?.wasm&&st?.wasm?.wasmPaths?.mjs)){if(ie.IS_DENO_WEB_RUNTIME)throw new Error("env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.");return jn=Promise.resolve(),jn}return jn=(async()=>{let e=st.wasm.wasmPaths,r=!1;await Promise.all([e.wasm&&!_b(e.wasm)?(async()=>{try{let s=await I2(mb(e.wasm));s&&(st.wasm.wasmBinary=s,r=!0)}catch(s){Z.warn("Failed to pre-load WASM binary:",s)}})():Promise.resolve(),e.mjs&&!_b(e.mjs)?(async()=>{try{let s=await C2(mb(e.mjs));s&&(st.wasm.wasmPaths.mjs=s)}catch(s){Z.warn("Failed to pre-load WASM factory:",s)}})():Promise.resolve()]),r||(st.wasm.wasmPaths.mjs=e.mjs)})(),jn}async function _p(t,e,r){await yz();let s=N2(fe.logLevel??Mt.WARNING),n=()=>xz.create(t,{logSeverityLevel:s,...e}),o=await(ie.IS_WEB_ENV?P2=P2.then(n):n());return o.config=r,o}var z2=Promise.resolve();async function mp(t,e){let r=()=>t.run(e);return ie.IS_WEB_ENV?z2=z2.then(r):r()}function hp(t){return t instanceof Gn.Tensor}var st=Gn?.env;function Sl(){return st?.wasm?.proxy}if(st){let t=function(e){let r=N2(e);st.logLevel=wz[r]};if(st.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&&st.versions?.web&&!st.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${st.versions.web}/dist/`;st.wasm.wasmPaths=ie.IS_SAFARI?{mjs:`${e}ort-wasm-simd-threaded.mjs`,wasm:`${e}ort-wasm-simd-threaded.wasm`}:{mjs:`${e}ort-wasm-simd-threaded.asyncify.mjs`,wasm:`${e}ort-wasm-simd-threaded.asyncify.wasm`}}st.wasm.proxy=!1}st.webgpu&&(st.webgpu.powerPreference="high-performance"),t(fe.logLevel??Mt.WARNING),fe.backends.onnx={...st,setLogLevel:t}}var ss=async(t,e,r)=>{let s=await _p(new Uint8Array(t),e);return(async n=>{let o=Sl(),a=Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(o?c.clone():c).ort_tensor])),i=await mp(s,a);return Array.isArray(r)?r.map(l=>new N(i[l])):new N(i[r])})},ur=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||(this._nearest_interpolate_4d=ss([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=ss([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=ss([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=ss([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=ss([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=ss([8,9,18,0,58,97,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,21,10,1,120,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,90,11,10,1,97,18,6,10,4,8,7,18,0,98,21,10,1,121,18,16,10,14,8,1,18,10,10,3,18,1,115,10,3,18,1,99,66,2,16,20],this.session_options,"y")),this._rfft}static get top_k(){return this._top_k||(this._top_k=ss([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=ss([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,"y")),this._slice}};var R2=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"}),f1=ie.IS_NODE_ENV?"cpu":"wasm";function gp(t,e,{warn:r}={}){return t?typeof t=="string"?t:t.hasOwnProperty(e)?t[e]:(r&&r(`device not specified for "${e}". Using the default device (${f1}).`),f1):f1}var B2=(function(){let t;return async function(){if(t===void 0)if(!ie.IS_WEBGPU_AVAILABLE)t=!1;else try{t=(await navigator.gpu.requestAdapter()).features.has("shader-f16")}catch{t=!1}return t}})(),wt=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),D2=wt.fp32,F2=Object.freeze({[R2.wasm]:wt.q8}),Tl=Object.freeze({[wt.fp32]:"",[wt.fp16]:"_fp16",[wt.int8]:"_int8",[wt.uint8]:"_uint8",[wt.q8]:"_quantized",[wt.q4]:"_q4",[wt.q4f16]:"_q4f16",[wt.bnb4]:"_bnb4"});function wp(t,e,r,{configDtype:s=null,warn:n}={}){let o,a=!1;t&&typeof t!="string"?t.hasOwnProperty(e)?o=t[e]:(o=null,a=!0):o=t;let i;if(o===wt.auto){if(s){let l=typeof s=="string"?s:s?.[e];if(l&&l!==wt.auto&&wt.hasOwnProperty(l))return l}i=F2[r]??D2}else o&&wt.hasOwnProperty(o)?i=o:i=F2[r]??D2;return a&&n&&n(`dtype not specified for "${e}". Using the default dtype (${i}) for this device (${r}).`),i}var kr=Object.freeze({float32:Float32Array,float16:typeof Float16Array<"u"?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array});var N=class t{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return hp(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new d1.Tensor(e[0],e[1],e[2]),new Proxy(this,{get:(r,s)=>{if(typeof s=="string"){let n=Number(s);if(Number.isInteger(n))return r._getitem(n)}return r[s]},set:(r,s,n)=>r[s]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...r]=this.dims;if(r.length>0){let s=r.reduce((n,o)=>n*o);for(let n=0;n<e;++n)yield this._subarray(n,s,r)}else yield*this.data}_getitem(e){let[r,...s]=this.dims;if(e=pr(e,r),s.length>0){let n=s.reduce((o,a)=>o*a);return this._subarray(e,n,s)}else return new t(this.type,[this.data[e]],s)}indexOf(e){let r=this.data;for(let s=0;s<r.length;++s)if(r[s]==e)return s;return-1}_subarray(e,r,s){let n=e*r,o=(e+1)*r,a="subarray"in this.data?this.data.subarray(n,o):this.data.slice(n,o);return new t(this.type,a,s)}item(){let e=this.data;if(e.length!==1)throw new Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return bz(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=1/(1+Math.exp(-e[r]));return this}map(e){return this.clone().map_(e)}map_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]=e(r[s],s,r);return this}mul(e){return this.clone().mul_(e)}mul_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]*=e;return this}div(e){return this.clone().div_(e)}div_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]/=e;return this}add(e){return this.clone().add_(e)}add_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]+=e;return this}sub(e){return this.clone().sub_(e)}sub_(e){let r=this.data;for(let s=0;s<r.length;++s)r[s]-=e;return this}clone(){return new t(this.type,this.data.slice(),this.dims.slice())}slice(...e){let r=[],s=[];for(let p=0;p<this.dims.length;++p){let d=e[p];if(d==null)s.push([0,this.dims[p]]),r.push(this.dims[p]);else if(typeof d=="number")d=pr(d,this.dims[p],p),s.push([d,d+1]);else if(Array.isArray(d)&&d.length===2){let[_,m]=d;if(_=_===null?0:pr(_,this.dims[p],p,!1),m=m===null?this.dims[p]:pr(m,this.dims[p],p,!1),_>m)throw new Error(`Invalid slice: ${d}`);let w=[Math.max(_,0),Math.min(m,this.dims[p])];s.push(w),r.push(w[1]-w[0])}else throw new Error(`Invalid slice: ${d}`)}let n=s.map(([p,d])=>d-p),o=n.reduce((p,d)=>p*d),a=this.data,i=new a.constructor(o),l=this.stride(),c=!0;for(let p=1;p<n.length;++p)if(s[p][0]!==0||s[p][1]!==this.dims[p]){c=!1;break}if(c){let p=s[0][0]*l[0],d=s[0][1]*l[0];if(ArrayBuffer.isView(a))i.set(a.subarray(p,d));else if(Array.isArray(a)){let _=a.slice(p,d);for(let m=0;m<_.length;++m)i[m]=_[m]}else throw new Error("Unsupported data type for slicing")}else for(let p=0;p<o;++p){let d=0;for(let _=n.length-1,m=p;_>=0;--_){let w=n[_];d+=(m%w+s[_][0])*l[_],m=Math.floor(m/w)}i[p]=a[d]}return new t(this.type,i,r)}permute(...e){return G2(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,r=!1){return this.norm(1,e,r)}norm(e="fro",r=null,s=!1){if(e==="fro")e=2;else if(typeof e=="string")throw Error(`Unsupported norm: ${e}`);let n=this.data,o=n instanceof BigInt64Array||n instanceof BigUint64Array;if(o&&e!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let a,i;if(o?(a=(d,_)=>d+_,i=0n):(a=(d,_)=>d+_**e,i=0),r===null){let d=n.reduce(a,i);return e!==1&&(d=d**(1/e)),new t(this.type,[d],[])}let[l,c,p]=Ol(a,this,r,s);if(e!==1)for(let d=0;d<c.length;++d)c[d]=c[d]**(1/e);return new t(l,c,p)}normalize_(e=2,r=1){r=pr(r,this.dims.length);let s=this.norm(e,r,!0),n=this.data,o=s.data;for(let a=0;a<n.length;++a){let i=0;for(let l=this.dims.length-1,c=a,p=1;l>=0;--l){let d=this.dims[l];if(l!==r){let _=c%d;i+=_*p,p*=this.dims[l]}c=Math.floor(c/d)}n[a]/=o[i]}return this}normalize(e=2,r=1){return this.clone().normalize_(e,r)}stride(){return _1(this.dims)}squeeze(e=null){return new t(this.type,this.data,U2(this.dims,e))}squeeze_(e=null){return this.dims=U2(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,j2(this.dims,e))}unsqueeze_(e){return this.dims=j2(this.dims,e),this}flatten_(e=0,r=-1){r=(r+this.dims.length)%this.dims.length;let s=this.dims.slice(0,e),n=this.dims.slice(e,r+1),o=this.dims.slice(r+1);return this.dims=[...s,n.reduce((a,i)=>a*i,1),...o],this}flatten(e=0,r=-1){return this.clone().flatten_(e,r)}view(...e){let r=-1;for(let n=0;n<e.length;++n)if(e[n]===-1){if(r!==-1)throw new Error("Only one dimension can be inferred");r=n}let s=this.data;if(r!==-1){let n=e.reduce((o,a,i)=>i!==r?o*a:o,1);e[r]=s.length/n}return new t(this.type,s,e)}neg_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=-e[r];return this}neg(){return this.clone().neg_()}gt(e){let r=new Uint8Array(this.data.length),s=this.data;for(let n=0;n<s.length;++n)r[n]=s[n]>e?1:0;return new t("bool",r,this.dims)}lt(e){let r=new Uint8Array(this.data.length),s=this.data;for(let n=0;n<s.length;++n)r[n]=s[n]<e?1:0;return new t("bool",r,this.dims)}clamp_(e,r){let s=this.data;for(let n=0;n<s.length;++n)s[n]=Math.min(Math.max(s[n],e),r);return this}clamp(e,r){return this.clone().clamp_(e,r)}round_(){let e=this.data;for(let r=0;r<e.length;++r)e[r]=Math.round(e[r]);return this}round(){return this.clone().round_()}mean(e=null,r=!1){return Cl(this,e,r)}min(e=null,r=!1){if(e===null){let a=wl(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=Ol((a,i)=>Math.min(a,i),this,e,r,1/0);return new t(s,n,o)}max(e=null,r=!1){if(e===null){let a=Ce(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=Ol((a,i)=>Math.max(a,i),this,e,r,-1/0);return new t(s,n,o)}argmin(e=null,r=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let s=wl(this.data)[1];return new t("int64",[BigInt(s)],[])}argmax(e=null,r=!1){if(e!==null)throw new Error("`dim !== null` not yet implemented.");let s=Ce(this.data)[1];return new t("int64",[BigInt(s)],[])}repeat(...e){if(e.length<this.dims.length)throw new Error(`Number of dimensions of repeat dims (${e.length}) cannot be smaller than number of dimensions of tensor (${this.dims.length})`);if(e.every(p=>p===1)){if(e.length===this.dims.length)return this.clone();let p=e.length-this.dims.length,d=Array(p).fill(1).concat(this.dims);return new t(this.type,this.data.slice(),d)}let r=e.length-this.dims.length,s=Array(r).fill(1).concat(this.dims),n=s.map((p,d)=>p*e[d]),o=n.reduce((p,d)=>p*d,1),a=this.data,i=new a.constructor(o),l=_1(s),c=_1(n);for(let p=0;p<o;++p){let d=p,_=0;for(let m=0;m<n.length;++m){let w=Math.floor(d/c[m]);d=d%c[m];let x=w%s[m];_+=x*l[m]}i[p]=a[_]}return new t(this.type,i,n)}tile(...e){if(e.length<this.dims.length){let r=this.dims.length-e.length;e=Array(r).fill(1).concat(e)}return this.repeat(...e)}to(e){if(this.type===e)return this;if(!kr.hasOwnProperty(e))throw new Error(`Unsupported type: ${e}`);let r,s=["int64","uint64"].includes(this.type),n=["int64","uint64"].includes(e);if(s&&!n)r=Number;else if(!s&&n)["float16","float32","float64"].includes(this.type)?r=o=>BigInt(Math.floor(o)):r=BigInt;else if(this.type==="float16"&&e=="float32"&&this.data instanceof Uint16Array)return new t(e,lA(this.data),this.dims);return new t(e,kr[e].from(this.data,r),this.dims)}};function bz(t,e){let r=t.length,s=e.reduce((o,a)=>o*a);if(r!==s)throw Error(`cannot reshape array of size ${r} into shape (${e})`);let n=t;for(let o=e.length-1;o>=0;o--)n=n.reduce((a,i)=>{let l=a[a.length-1];return l.length<e[o]?l.push(i):a.push([i]),a},[[]]);return n[0]}function G2(t,e){let[r,s]=rA(t.data,t.dims,e);return new N(t.type,r,s)}function yp(t,[e,r],s="bilinear",n=!1){let o=t.dims.at(-3)??1,a=t.dims.at(-2),i=t.dims.at(-1),l=tA(t.data,[o,a,i],[e,r],s,n);return new N(t.type,l,[o,e,r])}async function xt(t,{size:e=null,mode:r="bilinear"}={}){if(t.dims.length!==4)throw new Error("`interpolate_4d` currently only supports 4D input.");if(!e)throw new Error("`interpolate_4d` requires a `size` argument.");let s;if(e.length===2)s=[...t.dims.slice(0,2),...e];else if(e.length===3)s=[t.dims[0],...e];else if(e.length===4)s=e;else throw new Error("`size` must be of length 2, 3, or 4.");let n;if(r==="nearest")n=await ur.nearest_interpolate_4d;else if(r==="bilinear")n=await ur.bilinear_interpolate_4d;else if(r==="bicubic")n=await ur.bicubic_interpolate_4d;else throw new Error(`Unsupported mode: ${r}`);let o=new N("int64",new BigInt64Array(s.map(BigInt)),[s.length]);return await n({x:t,s:o})}async function m1(t,e){return await(await ur.matmul)({a:t,b:e})}async function vz(t,e){return await(await ur.rfft)({x:t,a:e})}async function jt(t,e){let r=await ur.top_k;return e==null?e=t.dims.at(-1):e=Math.min(e,t.dims.at(-1)),await r({x:t,k:new N("int64",[BigInt(e)],[1])})}var xp=t=>new N("int64",t,[t.length]);async function Il(t,e,r,s,n){return await(await ur.slice)({x:t,s:xp(e),e:xp(r),a:xp(s),t:xp(n??new Array(s.length).fill(1))})}function h1(t,e){let r=t.data,s=e.data,n=[t.dims[0],t.dims[2]],o=new r.constructor(n[0]*n[1]),[a,i,l]=t.dims,c=0;for(let p=0;p<a;++p){let d=p*l*i;for(let _=0;_<l;++_){let m=0,w=0,x=p*i,E=d+_;for(let A=0;A<i;++A){let T=Number(s[x+A]);w+=T,m+=r[E+A*l]*T}let k=m/w;o[c++]=k}}return new N(t.type,o,n)}function kz(t,e,{eps:r=1e-5}={}){if(t.dims.length!==2)throw new Error("`layer_norm` currently only supports 2D input.");let[s,n]=t.dims;if(e.length!==1&&e[0]!==n)throw new Error("`normalized_shape` must be a 1D array with shape `[input.dims[1]]`.");let[o,a]=bp(t,1,0,!0),i=o.data,l=a.data,c=t.data,p=new c.constructor(c.length);for(let d=0;d<s;++d){let _=d*n;for(let m=0;m<n;++m){let w=_+m;p[w]=(c[w]-l[d])/(i[d]+r)}}return new N(t.type,p,t.dims)}function U2(t,e){return t=t.slice(),e===null?t=t.filter(r=>r!==1):typeof e=="number"?t[e]===1&&t.splice(e,1):Array.isArray(e)&&(t=t.filter((r,s)=>r!==1||!e.includes(s))),t}function j2(t,e){return e=pr(e,t.length+1),t=t.slice(),t.splice(e,0,1),t}function pr(t,e,r=null,s=!0){if(t<-e||t>=e){if(s)throw new Error(`IndexError: index ${t} is out of bounds for dimension${r===null?"":" "+r} with size ${e}`);return t<-e?0:e}return t<0&&(t=(t%e+e)%e),t}function ve(t,e=0){e=pr(e,t[0].dims.length);let r=t[0].dims.slice();r[e]=t.reduce((a,i)=>a+i.dims[e],0);let s=r.reduce((a,i)=>a*i,1),n=new t[0].data.constructor(s),o=t[0].type;if(e===0){let a=0;for(let i of t){let l=i.data;n.set(l,a),a+=l.length}}else{let a=0;for(let i=0;i<t.length;++i){let{data:l,dims:c}=t[i];for(let p=0;p<l.length;++p){let d=0;for(let _=c.length-1,m=p,w=1;_>=0;--_){let x=c[_],E=m%x;_===e&&(E+=a),d+=E*w,w*=r[_],m=Math.floor(m/x)}n[d]=l[p]}a+=c[e]}}return new N(o,n,r)}function St(t,e=0){return ve(t.map(r=>r.unsqueeze(e)),e)}function Ol(t,e,r,s=!1,n=null){let o=e.data,a=e.dims;r=pr(r,a.length);let i=a.slice();i[r]=1;let l=new o.constructor(o.length/a[r]);n!==null&&l.fill(n);for(let c=0;c<o.length;++c){let p=0;for(let d=a.length-1,_=c,m=1;d>=0;--d){let w=a[d];if(d!==r){let x=_%w;p+=x*m,m*=i[d]}_=Math.floor(_/w)}l[p]=t(l[p],o[c],c,p)}return s||i.splice(r,1),[e.type,l,i]}function bp(t,e=null,r=1,s=!1){let n=t.data,o=t.dims;if(e===null){let m=n.reduce((k,A)=>k+A,0)/n.length,w=Math.sqrt(n.reduce((k,A)=>k+(A-m)**2,0)/(n.length-r)),x=new N(t.type,[m],[]);return[new N(t.type,[w],[]),x]}e=pr(e,o.length);let a=Cl(t,e,s),i=a.data,[l,c,p]=Ol((_,m,w,x)=>_+(m-i[x])**2,t,e,s);for(let _=0;_<c.length;++_)c[_]=Math.sqrt(c[_]/(o[e]-r));return[new N(l,c,p),a]}function Cl(t,e=null,r=!1){let s=t.dims,n=t.data;if(e===null){let l=n.reduce((c,p)=>c+p,0);return new N(t.type,[l/n.length],[])}e=pr(e,s.length);let[o,a,i]=Ol((l,c)=>l+c,t,e,r);if(s[e]!==1)for(let l=0;l<a.length;++l)a[l]/=s[e];return new N(o,a,i)}function _1(t){let e=new Array(t.length);for(let r=t.length-1,s=1;r>=0;--r)e[r]=s,s*=t[r];return e}function g1(t,e,r,s){let n=t.reduce((o,a)=>o*a,1);return new N(r,new s(n).fill(e),t)}function qe(t,e){let r,s;if(typeof e=="number")r="float32",s=Float32Array;else if(typeof e=="bigint")r="int64",s=BigInt64Array;else if(typeof e=="boolean")r="bool",s=Uint8Array;else throw new Error(`Unsupported data type: ${typeof e}`);return g1(t,e,r,s)}function qn(t,e){return qe(t.dims,e)}function Je(t){return g1(t,1n,"int64",BigInt64Array)}function Ll(t){return Je(t.dims)}function vp(t){return g1(t,0n,"int64",BigInt64Array)}function kp(t){return vp(t.dims)}function Ez(t){let e=t.reduce((r,s)=>r*s,1);return new N("float32",Float32Array.from({length:e},()=>Vr.random()),t)}function w1(t){let e=t.reduce((r,s)=>r*s,1);return new N("float32",Float32Array.from({length:e},()=>Vr.gauss()),t)}function x1(t,e){if(t.dims.length!==2)throw new Error("The tensor must have 2 dimensions");if(t.dims.at(-1)%8!==0)throw new Error("The last dimension of the tensor must be a multiple of 8");if(!["binary","ubinary"].includes(e))throw new Error("The precision must be either 'binary' or 'ubinary'");let r=e==="binary",s=r?"int8":"uint8",n=r?Int8Array:Uint8Array,o=t.data,a=new n(o.length/8);for(let i=0;i<o.length;++i){let l=o[i]>0?1:0,c=Math.floor(i/8),p=i%8;a[c]|=l<<7-p,r&&p===0&&(a[c]-=128)}return new N(s,a,[t.dims[0],t.dims[1]/8])}async function Wn(t){if(!t)throw new Error("modelId is required for get_tokenizer_files");return(await cr(t,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function y1(t,e){let r=await Wn(t);return await Promise.all(r.map(s=>ut(t,s,!0,e)))}function b1(t){let e=t.dims;switch(e.length){case 1:return t.tolist();case 2:if(e[0]!==1)throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return t.tolist()[0];default:throw new Error(`Expected tensor to have 1-2 dimensions, got ${e.length}.`)}}var Az=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function Mz(t,e,r,s){for(let n of Object.keys(t)){let o=e-t[n].length,a=r(n),i=new Array(o).fill(a);t[n]=s==="right"?ht(t[n],i):ht(i,t[n])}}function Sz(t,e){for(let r of Object.keys(t))t[r].length=e}function qs(t,...e){for(let r of e){if(!Object.hasOwn(t,r))continue;let s=t[r];if(s)if(typeof s=="object"){if(s.__type==="AddedToken")return s.content;throw Error(`Unknown token: ${s}`)}else return s}return null}function Tz(t){let e=[];for(let r of t.get_added_tokens_decoder().values())r.special&&e.push(r);return e}var q=class extends tt{return_token_type_ids=!1;padding_side="right";constructor(e,r){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=r,this._tokenizer=new CE(e,r),this.config=r,this.padding_side=r.padding_side??this.padding_side,this.mask_token=qs(r,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=qs(r,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=qs(r,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=qs(r,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=qs(r,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=qs(r,"eos_token"),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=r.chat_template??null,Array.isArray(this.chat_template)){let n=Object.create(null);for(let{name:o,template:a}of this.chat_template){if(typeof o!="string"||typeof a!="string")throw new Error('Chat template must be a list of objects with "name" and "template" properties');n[o]=a}this.chat_template=n}this._compiled_template_cache=new Map;let s=Tz(this._tokenizer);this.all_special_ids=s.map(n=>n.id),this.all_special_tokens=s.map(n=>n.content)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let i=await y1(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a});return new this(...i)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e=="string"?this._tokenizer.token_to_id(e):e.map(r=>this._tokenizer.token_to_id(r))}_call(e,{text_pair:r=null,add_special_tokens:s=!0,padding:n=!1,truncation:o=null,max_length:a=null,return_tensor:i=!0,return_token_type_ids:l=null}={}){let c=Array.isArray(e),p;if(c){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");p=e.map((_,m)=>this._encode_plus(_,{text_pair:r[m],add_special_tokens:s,return_token_type_ids:l}))}else p=e.map(_=>this._encode_plus(_,{add_special_tokens:s,return_token_type_ids:l}))}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).");p=[this._encode_plus(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:l})]}if(a===null?a=this.model_max_length:o===null&&(n===!0?(Z.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),a=this.model_max_length):n===!1&&(Z.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),n===!0&&(a=Math.min(Ce(p.map(_=>_.input_ids.length))[0],a??1/0)),a=Math.min(a,this.model_max_length??1/0),n||o)for(let _=0;_<p.length;++_)p[_].input_ids.length!==a&&(p[_].input_ids.length>a?o&&Sz(p[_],a):n&&Mz(p[_],a,m=>m==="input_ids"?this.pad_token_id:0,this.padding_side));let d={};if(i){if(!(n&&o)&&p.some(m=>{for(let w of Object.keys(m))if(m[w].length!==p[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.");let _=[p.length,p[0].input_ids.length];for(let m of Object.keys(p[0]))d[m]=new N("int64",BigInt64Array.from(p.flatMap(w=>w[m]).map(BigInt)),_)}else{for(let _ of Object.keys(p[0]))d[_]=p.map(m=>m[_]);if(!c)for(let _ of Object.keys(d))d[_]=d[_][0]}return d}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:r=null,add_special_tokens:s=!0,return_token_type_ids:n=null}={}){let{ids:o,attention_mask:a,token_type_ids:i}=this._tokenizer.encode(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:n??this.return_token_type_ids});return{input_ids:o,attention_mask:a,...i?{token_type_ids:i}:{}}}tokenize(e,{pair:r=null,add_special_tokens:s=!1}={}){return this._tokenizer.tokenize(e,{text_pair:r,add_special_tokens:s})}encode(e,{text_pair:r=null,add_special_tokens:s=!0,return_token_type_ids:n=null}={}){return this._tokenizer.encode(e,{text_pair:r,add_special_tokens:s,return_token_type_ids:n}).ids}batch_decode(e,r={}){return e instanceof N&&(e=e.tolist()),e.map(s=>this.decode(s,r))}decode(e,r={}){if(e instanceof N&&(e=b1(e)),!Array.isArray(e)||e.length===0||!fE(e[0]))throw Error("token_ids must be a non-empty array of integers.");return this.decode_single(e,r)}decode_single(e,{skip_special_tokens:r=!1,clean_up_tokenization_spaces:s=null}){return this._tokenizer.decode(e,{skip_special_tokens:r,clean_up_tokenization_spaces:s})}get_chat_template({chat_template:e=null,tools:r=null}={}){if(this.chat_template&&typeof this.chat_template=="object"){let s=this.chat_template;if(e!==null&&Object.hasOwn(s,e))e=s[e];else if(e===null)if(r!==null&&"tool_use"in s)e=s.tool_use;else if("default"in s)e=s.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(s).sort()}.`)}else if(e===null)if(this.chat_template)e=this.chat_template;else throw Error("Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating");return e}apply_chat_template(e,{tools:r=null,documents:s=null,chat_template:n=null,add_generation_prompt:o=!1,tokenize:a=!0,padding:i=!1,truncation:l=!1,max_length:c=null,return_tensor:p=!0,return_dict:d=!0,tokenizer_kwargs:_={},...m}={}){if(n=this.get_chat_template({chat_template:n,tools:r}),typeof n!="string")throw Error(`chat_template must be a string, but got ${typeof n}`);let w=this._compiled_template_cache.get(n);w===void 0&&(w=new GE(n),this._compiled_template_cache.set(n,w));let x=Object.create(null);for(let k of Az){let A=qs(this.config,k);A&&(x[k]=A)}let E=w.render({messages:e,add_generation_prompt:o,tools:r,documents:s,...x,...m});if(a){let k=this._call(E,{add_special_tokens:!1,padding:i,truncation:l,max_length:c,return_tensor:p,..._});return d?k:k.input_ids}return E}};function Vn(t,e,r,s){if(!("language_codes"in t)||!Array.isArray(t.language_codes))throw new Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!("languageRegex"in t)||!(t.languageRegex instanceof RegExp))throw new Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!("lang_to_token"in t)||typeof t.lang_to_token!="function")throw new Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let n=s.src_lang,o=s.tgt_lang;if(!t.language_codes.includes(o))throw new Error(`Target language code "${o}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);if(n!==void 0){if(!t.language_codes.includes(n))throw new Error(`Source language code "${n}" is not valid. Must be one of: {${t.language_codes.join(", ")}}`);for(let a of t._tokenizer.post_processor.config.single)if("SpecialToken"in a&&t.languageRegex.test(a.SpecialToken.id)){a.SpecialToken.id=t.lang_to_token(n);break}}return s.forced_bos_token_id=t._tokenizer.token_to_id(t.lang_to_token(o)),t._call(e,r)}var k1={};Os(k1,{AlbertTokenizer:()=>Ep,AutoTokenizer:()=>oe,BartTokenizer:()=>Ap,BertTokenizer:()=>Mp,BlenderbotSmallTokenizer:()=>Sp,BlenderbotTokenizer:()=>Tp,BloomTokenizer:()=>Op,CLIPTokenizer:()=>Cp,CamembertTokenizer:()=>Ip,CodeGenTokenizer:()=>Pp,CodeLlamaTokenizer:()=>Lp,CohereTokenizer:()=>zp,ConvBertTokenizer:()=>Np,DebertaTokenizer:()=>Rp,DebertaV2Tokenizer:()=>$p,DistilBertTokenizer:()=>Dp,ElectraTokenizer:()=>Fp,EsmTokenizer:()=>Bp,FalconTokenizer:()=>Up,GPT2Tokenizer:()=>qp,GPTNeoXTokenizer:()=>Gp,GemmaTokenizer:()=>jp,HerbertTokenizer:()=>Wp,LlamaTokenizer:()=>Vp,M2M100Tokenizer:()=>Hp,MBart50Tokenizer:()=>Kp,MBartTokenizer:()=>Hn,MPNetTokenizer:()=>Jp,MarianTokenizer:()=>Xp,MgpstrTokenizer:()=>Qp,MobileBertTokenizer:()=>Yp,NllbTokenizer:()=>Zp,NougatTokenizer:()=>ed,PreTrainedTokenizer:()=>q,Qwen2Tokenizer:()=>td,RoFormerTokenizer:()=>sd,RobertaTokenizer:()=>rd,SiglipTokenizer:()=>nd,SpeechT5Tokenizer:()=>od,SqueezeBertTokenizer:()=>ad,T5Tokenizer:()=>id,TokenizersBackend:()=>q,VitsTokenizer:()=>ld,Wav2Vec2CTCTokenizer:()=>cd,WhisperTokenizer:()=>ud,XLMRobertaTokenizer:()=>pd,XLMTokenizer:()=>dd});var Ep=class extends q{return_token_type_ids=!0};var Ap=class extends q{};var Mp=class extends q{return_token_type_ids=!0};var Sp=class extends q{};var Tp=class extends q{};var Op=class extends q{};var Ip=class extends q{};var Cp=class extends q{};var Lp=class extends q{};var Pp=class extends q{};var zp=class extends q{};var Np=class extends q{return_token_type_ids=!0};var $p=class extends q{return_token_type_ids=!0};var Rp=class extends q{return_token_type_ids=!0};var Dp=class extends q{};var Fp=class extends q{return_token_type_ids=!0};var Bp=class extends q{};var Up=class extends q{};var jp=class extends q{};var Gp=class extends q{};var qp=class extends q{};var Wp=class extends q{return_token_type_ids=!0};var Vp=class extends q{padding_side="left"};var Hp=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s.slice(2,-2)),this.lang_to_token=s=>`__${s}__`}_build_translation_inputs(e,r,s){return Vn(this,e,r,s)}};var Xp=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(s=>this.languageRegex.test(s)),Z.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[r,...s]=e.trim().split(this.languageRegex);if(s.length===0)return super._encode_text(r);if(s.length===2){let[n,o]=s;return this.supported_language_codes.includes(n)||Z.warn(`Unsupported language code "${n}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),ht([n],super._encode_text(o))}}};var Hn=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)).map(s=>s),this.lang_to_token=s=>s}_build_translation_inputs(e,r,s){return Vn(this,e,r,s)}};var Kp=class extends Hn{};var Qp=class extends q{};var Yp=class extends q{return_token_type_ids=!0};var Jp=class extends q{};var Zp=class extends q{constructor(e,r){super(e,r),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(s=>this.languageRegex.test(s)),this.lang_to_token=s=>s}_build_translation_inputs(e,r,s){return Vn(this,e,r,s)}};var ed=class extends q{};var td=class extends q{};var rd=class extends q{};var sd=class extends q{return_token_type_ids=!0};var nd=class extends q{};var od=class extends q{};var ad=class extends q{return_token_type_ids=!0};var id=class extends q{};var v1=class extends Dt{decode_chain(e){let r="";for(let s=1;s<e.length;s+=2)r+=e[s];return[r]}},ld=class extends q{constructor(e,r){super(e,r),this._tokenizer.decoder=new v1({type:"VitsDecoder"})}};var cd=class extends q{};var q2=[["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"]],Pl=new Map(q2),Oz=new Map([...q2.map(([t,e])=>[e,t]),["burmese","my"],["valencian","ca"],["flemish","nl"],["haitian","ht"],["letzeburgesch","lb"],["pushto","ps"],["panjabi","pa"],["moldavian","ro"],["moldovan","ro"],["sinhalese","si"],["castilian","es"]]);function W2(t){t=t.toLowerCase();let e=Oz.get(t);if(e===void 0){let r=t.match(/^<\|([a-z]{2})\|>$/);if(r&&(t=r[1]),Pl.has(t))e=t;else{let n=t.length===2?Pl.keys():Pl.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var Iz="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",V2=new RegExp(`^[${Iz}]+$`,"gu"),ud=class extends q{get timestamp_begin(){return this._tokenizer.token_to_id("<|notimestamps|>")+1}_decode_asr(e,{return_timestamps:r=!1,return_language:s=!1,time_precision:n=null,force_full_sequences:o=!0}={}){if(n===null)throw Error("Must specify time_precision");let a=null,i=r==="word";function l(){return{language:a,timestamp:[null,null],text:""}}let c=[],p=l(),d=0,_=this.timestamp_begin,w=_+1500,x=[],E=[],k=!1,A=null,T=new Set(this.all_special_ids);for(let O of e){let v=O.tokens,W=i?O.token_timestamps:null,X=null,B=_;if("stride"in O){let[Q,R,C]=O.stride;if(d-=R,A=Q-C,R&&(B=R/n+_),C)for(let te=v.length-1;te>=0;--te){let ae=Number(v[te]);if(ae>=_){if(X!==null&&(ae-_)*n<A)break;X=ae}}}let H=[],G=[];for(let Q=0;Q<v.length;++Q){let R=Number(v[Q]);if(T.has(R)){let C=this.decode([R]),te=Pl.get(C.slice(2,-2));if(te!==void 0){if(a!==null&&te!==a&&!r){x.push(H);let ae=this.findLongestCommonSequence(x)[0],P=this.decode(ae);p.text=P,c.push(p),x=[],H=[],p=l()}a=p.language=te}}else if(R>=_&&R<=w){let C=(R-_)*n+d,te=zs(C,2);if(X!==null&&R>=X)k=!0;else if(k||x.length>0&&R<B)k=!1;else if(p.timestamp[0]===null)p.timestamp[0]=te;else if(te!==p.timestamp[0]){p.timestamp[1]=te,x.push(H),i&&E.push(G);let[ae,P]=this.findLongestCommonSequence(x,E),$=this.decode(ae);p.text=$,i&&(p.words=this.collateWordTimestamps(ae,P,a)),c.push(p),x=[],H=[],E=[],G=[],p=l()}}else if(H.push(R),i){let C=zs(W[Q]+d,2),te;if(Q+1<W.length){te=zs(W[Q+1]+d,2);let ae=this.decode([R]);V2.test(ae)&&(te=zs(Math.min(C+n,te),2))}else te=null;G.push([C,te])}}if("stride"in O){let[Q,R,C]=O.stride;d+=Q-C}H.length>0?(x.push(H),i&&E.push(G)):x.every(Q=>Q.length===0)&&(p=l(),x=[],H=[],E=[],G=[])}if(x.length>0){if(o&&r)throw new Error("Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.");let[O,v]=this.findLongestCommonSequence(x,E),W=this.decode(O);p.text=W,i&&(p.words=this.collateWordTimestamps(O,v,a)),c.push(p)}let S=Object.create(null),L=c.map(O=>O.text).join("");if(r||s){for(let O=0;O<c.length;++O){let v=c[O];r||delete v.timestamp,s||delete v.language}if(i){let O=[];for(let v of c)for(let W of v.words)O.push(W);S={chunks:O}}else S={chunks:c}}return[L,S]}findLongestCommonSequence(e,r=null){let s=e[0],n=s.length,o=[],a=Array.isArray(r)&&r.length>0,i=a?[]:null,l=a?r[0]:null;for(let c=1;c<e.length;++c){let p=e[c],d=0,_=[n,n,0,0],m=p.length;for(let S=1;S<n+m;++S){let L=Math.max(0,n-S),O=Math.min(n,n+m-S),v=s.slice(L,O),W=Math.max(0,S-n),X=Math.min(m,S),B=p.slice(W,X);if(v.length!==B.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=v.filter((R,C)=>R===B[C]&&l[L+C]<=r[c][W+C]).length:H=v.filter((R,C)=>R===B[C]).length;let G=S/1e4,Q=H/S+G;H>1&&Q>d&&(d=Q,_=[L,O,W,X])}let[w,x,E,k]=_,A=Math.floor((x+w)/2),T=Math.floor((k+E)/2);o.push(...s.slice(0,A)),s=p.slice(T),n=s.length,a&&(i.push(...l.slice(0,A)),l=r[c].slice(T))}return o.push(...s),a?(i.push(...l),[o,i]):[o,[]]}collateWordTimestamps(e,r,s){let[n,o,a]=this.combineTokensIntoWords(e,s),i=[];for(let l=0;l<n.length;++l){let c=a[l];i.push({text:n[l],timestamp:[r[c.at(0)][0],r[c.at(-1)][1]]})}return i}combineTokensIntoWords(e,r,s=`"'\u201C\xA1\xBF([{-`,n=`"'.\u3002,\uFF0C!\uFF01?\uFF1F:\uFF1A\u201D)]}\u3001`){r=r??"english";let o,a,i;return["chinese","japanese","thai","lao","myanmar"].includes(r)?[o,a,i]=this.splitTokensOnUnicode(e):[o,a,i]=this.splitTokensOnSpaces(e),this.mergePunctuations(o,a,i,s,n)}decode(e,r){let s;return r?.decode_with_timestamps?(e instanceof N&&(e=b1(e)),s=this.decodeWithTimestamps(e,r)):s=super.decode(e,r),s}decodeWithTimestamps(e,r){let s=r?.time_precision??.02,n=this.all_special_ids.at(-1)+1,o=[[]];for(let a of e)if(a=Number(a),a>=n){let i=((a-n)*s).toFixed(2);o.push(`<|${i}|>`),o.push([])}else o[o.length-1].push(a);return o=o.map(a=>typeof a=="string"?a:super.decode(a,r)),o.join("")}splitTokensOnUnicode(e){let r=this.decode(e,{decode_with_timestamps:!0}),s="\uFFFD",n=[],o=[],a=[],i=[],l=[],c=0;for(let p=0;p<e.length;++p){let d=e[p];i.push(d),l.push(p);let _=this.decode(i,{decode_with_timestamps:!0});(!_.includes(s)||r[c+_.indexOf(s)]===s)&&(n.push(_),o.push(i),a.push(l),i=[],l=[],c+=_.length)}return[n,o,a]}splitTokensOnSpaces(e){let[r,s,n]=this.splitTokensOnUnicode(e),o=[],a=[],i=[];for(let l=0;l<r.length;++l){let c=r[l],p=s[l],d=n[l],_=p[0]>=this._tokenizer.token_to_id("<|endoftext|>"),m=c.startsWith(" "),w=c.trim(),x=V2.test(w);if(_||m||x||o.length===0)o.push(c),a.push(p),i.push(d);else{let E=o.length-1;o[E]+=c,a[E].push(...p),i[E].push(...d)}}return[o,a,i]}mergePunctuations(e,r,s,n,o){let a=structuredClone(e),i=structuredClone(r),l=structuredClone(s),c=a.length-2,p=a.length-1;for(;c>=0;)a[c].startsWith(" ")&&n.includes(a[c].trim())?(a[p]=a[c]+a[p],i[p]=ht(i[c],i[p]),l[p]=ht(l[c],l[p]),a[c]="",i[c]=[],l[c]=[]):p=c,--c;for(c=0,p=1;p<a.length;)!a[c].endsWith(" ")&&o.includes(a[p])?(a[c]+=a[p],i[c]=ht(i[c],i[p]),l[c]=ht(l[c],l[p]),a[p]="",i[p]=[],l[p]=[]):c=p,++p;return[a.filter(d=>d),i.filter(d=>d.length>0),l.filter(d=>d.length>0)]}};var pd=class extends q{};var dd=class extends q{return_token_type_ids=!0;constructor(e,r){super(e,r),Z.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}};var oe=class{static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){let[i,l]=await y1(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",p=k1[c];return p||(Z.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),p=q),new p(i,l)}};var ns="https://github.com/huggingface/transformers.js/issues/new/choose";var zl="preprocessor_config.json",Er=zl,H2="processor_config.json",X2="chat_template.jinja";var re=class extends tt{static classes=["image_processor_class","tokenizer_class","feature_extractor_class"];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,r,s){super(),this.config=e,this.components=r,this.chat_template=s}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,r={}){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,...r})}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,...r){for(let s of[this.image_processor,this.feature_extractor,this.tokenizer])if(s)return s(e,...r);throw new Error("No image processor, feature extractor, or tokenizer found.")}static async from_pretrained(e,r={}){let[s,n,o]=await Promise.all([this.uses_processor_config?ut(e,H2,!0,r):{},Promise.all(this.classes.filter(a=>a in this).map(async a=>{let i=await this[a].from_pretrained(e,r);return[a.replace(/_class$/,""),i]})).then(Object.fromEntries),this.uses_chat_template_file?wb(e,X2,!0,r):null]);return new this(s,n,o)}};var Qf={};Os(Qf,{ChatterboxProcessor:()=>Id,Florence2Processor:()=>kf,Gemma3nProcessor:()=>Ef,Glm46VProcessor:()=>Af,GraniteSpeechProcessor:()=>Mf,GroundingDinoProcessor:()=>Sf,Idefics3Processor:()=>Yl,JinaCLIPProcessor:()=>Of,Lfm2VlProcessor:()=>If,LlavaProcessor:()=>Cf,MgpstrProcessor:()=>Lf,MoonshineProcessor:()=>Pf,OwlViTProcessor:()=>zf,PaliGemmaProcessor:()=>Nf,Phi3VProcessor:()=>$f,PixtralProcessor:()=>Rf,Processor:()=>re,PyAnnoteProcessor:()=>Df,Qwen2VLProcessor:()=>is,Qwen2_5_VLProcessor:()=>no,Qwen3VLProcessor:()=>Ff,Sam2Processor:()=>Jl,Sam2VideoProcessor:()=>Bf,SamProcessor:()=>oo,SmolVLMProcessor:()=>Yl,SpeechT5Processor:()=>Uf,UltravoxProcessor:()=>jf,VLChatProcessor:()=>Tf,VoxtralProcessor:()=>qf,VoxtralRealtimeProcessor:()=>Vf,Wav2Vec2Processor:()=>Hf,Wav2Vec2ProcessorWithLM:()=>Xf,WhisperProcessor:()=>Kf});var Ee=class extends tt{constructor(e){super(),this.config=e}static async from_pretrained(e,r={}){let s=await ut(e,zl,!0,r);return new this(s)}};function Re(t,e){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error(`${e} expects input to be a Float32Array or a Float64Array, but got ${t?.constructor?.name??typeof t} instead. If using the feature extractor directly, remember to use \`read_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var Nl={};Os(Nl,{ASTFeatureExtractor:()=>hd,ChatterboxFeatureExtractor:()=>gd,ClapFeatureExtractor:()=>wd,DacFeatureExtractor:()=>Qn,EncodecFeatureExtractor:()=>Kn,FeatureExtractor:()=>Ee,Gemma3nAudioFeatureExtractor:()=>xd,GraniteSpeechFeatureExtractor:()=>yd,MoonshineFeatureExtractor:()=>bd,ParakeetFeatureExtractor:()=>vd,PyAnnoteFeatureExtractor:()=>Yn,SeamlessM4TFeatureExtractor:()=>kd,SnacFeatureExtractor:()=>Ed,SpeechT5FeatureExtractor:()=>Ad,VoxtralRealtimeFeatureExtractor:()=>Td,Wav2Vec2FeatureExtractor:()=>Md,WeSpeakerFeatureExtractor:()=>Sd,WhisperFeatureExtractor:()=>Od});var K2=yr(require("fs"),1),Q2=require("stream"),Y2=require("stream/promises");async function fd(t,e){if(ie.IS_BROWSER_ENV){if(ie.IS_WEBWORKER_ENV)throw new Error("Unable to save a file from a Web Worker.");let r=URL.createObjectURL(e),s=document.createElement("a");s.href=r,s.download=t,s.click(),s.remove(),URL.revokeObjectURL(r)}else if(ie.IS_FS_AVAILABLE){let r=e.stream(),s=Q2.Readable.fromWeb(r),n=K2.default.createWriteStream(t);await(0,Y2.pipeline)(s,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function md(t,e){if(typeof AudioContext>"u")throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let r=await(await Xr(t)).arrayBuffer(),s=new AudioContext({sampleRate:e});typeof e>"u"&&Z.warn(`No sampling rate provided, using default of ${s.sampleRate}Hz.`);let n=await s.decodeAudioData(r),o;if(n.numberOfChannels===2){let a=Math.sqrt(2),i=n.getChannelData(0),l=n.getChannelData(1);o=new Float32Array(i.length);for(let c=0;c<n.length;++c)o[c]=a*(i[c]+l[c])/2}else o=n.getChannelData(0);return o}function eM(t,e){if(t<1)return new Float64Array;if(t===1)return new Float64Array([1]);let r=1-e,s=2*Math.PI/(t-1),n=new Float64Array(t);for(let o=0;o<t;++o)n[o]=e-r*Math.cos(o*s);return n}function J2(t){return eM(t,.5)}function Cz(t){return eM(t,.54)}var Lz={htk:t=>2595*Math.log10(1+t/700),kaldi:t=>1127*Math.log(1+t/700),slaney:(t,e=1e3,r=15,s=27/Math.log(6.4))=>t>=e?r+Math.log(t/e)*s:3*t/200};function E1(t,e="htk"){let r=Lz[e];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?r(t):t.map(s=>r(s))}var Pz={htk:t=>700*(10**(t/2595)-1),kaldi:t=>700*(Math.exp(t/1127)-1),slaney:(t,e=1e3,r=15,s=Math.log(6.4)/27)=>t>=r?e*Math.exp(s*(t-r)):200*t/3};function zz(t,e="htk"){let r=Pz[e];if(!r)throw new Error('mel_scale should be one of "htk", "slaney" or "kaldi".');return typeof t=="number"?r(t):t.map(s=>r(s))}function Nz(t,e){let r=Float64Array.from({length:e.length-1},(a,i)=>e[i+1]-e[i]),s=Array.from({length:t.length},()=>new Array(e.length));for(let a=0;a<t.length;++a){let i=s[a];for(let l=0;l<e.length;++l)i[l]=e[l]-t[a]}let n=e.length-2,o=Array.from({length:n},()=>new Array(t.length));for(let a=0;a<t.length;++a){let i=s[a];for(let l=0;l<n;++l){let c=-i[l]/r[l],p=i[l+2]/r[l+1];o[l][a]=Math.max(0,Math.min(c,p))}}return o}function Z2(t,e,r){let s=(e-t)/(r-1);return Float64Array.from({length:r},(n,o)=>t+s*o)}function nt(t,e,r,s,n,o=null,a="htk",i=!1){if(o!==null&&o!=="slaney")throw new Error('norm must be one of null or "slaney"');if(t<2)throw new Error(`Require num_frequency_bins: ${t} >= 2`);if(r>s)throw new Error(`Require min_frequency: ${r} <= max_frequency: ${s}`);let l=E1(r,a),c=E1(s,a),p=Z2(l,c,e+2),d=zz(p,a),_;if(i){let w=n/((t-1)*2);_=E1(Float64Array.from({length:t},(x,E)=>E*w),a),d=p}else _=Z2(0,Math.floor(n/2),t);let m=Nz(_,d);if(o!==null&&o==="slaney")for(let w=0;w<e;++w){let x=m[w],E=2/(d[w+2]-d[w]);for(let k=0;k<t;++k)x[k]*=E}return m}function $z(t,e,r){let s=new t.constructor(t.length+e+r),n=t.length-1;for(let o=0;o<t.length;++o)s[e+o]=t[o];for(let o=1;o<=e;++o)s[e-o]=t[Pn(o,n)];for(let o=1;o<=r;++o)s[n+e+o]=t[Pn(n-o,n)];return s}function tM(t,e,r,s,n){if(r<=0)throw new Error("reference must be greater than zero");if(s<=0)throw new Error("min_value must be greater than zero");r=Math.max(s,r);let o=Math.log10(r);for(let a=0;a<t.length;++a)t[a]=e*Math.log10(Math.max(s,t[a])-o);if(n!==null){if(n<=0)throw new Error("db_range must be greater than zero");let a=Ce(t)[0]-n;for(let i=0;i<t.length;++i)t[i]=Math.max(t[i],a)}return t}function Rz(t,e=1,r=1e-5,s=null){return tM(t,20,e,r,s)}function Dz(t,e=1,r=1e-10,s=null){return tM(t,10,e,r,s)}async function dt(t,e,r,s,{fft_length:n=null,power:o=1,center:a=!0,pad_mode:i="reflect",onesided:l=!0,preemphasis:c=null,preemphasis_htk_flavor:p=!0,mel_filters:d=null,mel_floor:_=1e-10,log_mel:m=null,max_log_mel:w=null,reference:x=1,min_value:E=1e-10,db_range:k=null,remove_dc_offset:A=null,min_num_frames:T=null,max_num_frames:S=null,do_pad:L=!0,transpose:O=!1,mel_offset:v=0}={}){let W=e.length;if(n===null&&(n=r),r>n)throw Error(`frame_length (${r}) may not be larger than fft_length (${n})`);if(W!==r)throw new Error(`Length of the window (${W}) must equal frame_length (${r})`);if(s<=0)throw new Error("hop_length must be greater than zero");if(o===null&&d!==null)throw new Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!p)throw new Error("`preemphasis_htk_flavor=false` is not currently supported.");if(a)switch(i){case"reflect":{let F=Math.floor((n-1)/2)+1;t=$z(t,F,F);break}case"constant":{let F=Math.floor(n/2),J=new t.constructor(t.length+2*F);J.set(t,F),t=J;break}default:throw new Error(`pad_mode="${i}" not implemented yet.`)}let X=Math.floor(1+Math.floor((t.length-r)/s));T!==null&&X<T&&(X=T);let B=l?Math.floor(n/2)+1:n,H=X,G=X;S!==null&&(S>X?L&&(G=S):G=H=S);let Q=new ep(n),R=new Float64Array(n),C=new Float64Array(Q.outputBufferSize),te=new Float32Array(B*G);for(let F=0;F<H;++F){let J=F*s,xe=Math.min(t.length-J,r);xe!==r&&R.fill(0,0,r);for(let ue=0;ue<xe;++ue)R[ue]=t[J+ue];if(A){let ue=0;for(let ot=0;ot<xe;++ot)ue+=R[ot];let Ve=ue/xe;for(let ot=0;ot<xe;++ot)R[ot]-=Ve}if(c!==null){for(let ue=xe-1;ue>=1;--ue)R[ue]-=c*R[ue-1];R[0]*=1-c}for(let ue=0;ue<e.length;++ue)R[ue]*=e[ue];Q.realTransform(C,R);for(let ue=0;ue<B;++ue){let Ve=ue<<1;te[ue*G+F]=C[Ve]**2+C[Ve+1]**2}}if(o!==null&&o!==2){let F=o/2;for(let J=0;J<te.length;++J)te[J]**=F}let ae=d.length,P=await m1(new N("float32",d.flat(),[ae,B]),new N("float32",te,[B,G]));O&&(P=P.transpose(1,0));let $=P.data;for(let F=0;F<$.length;++F)$[F]=v+Math.max(_,$[F]);if(o!==null&&m!==null){let F=Math.min($.length,H*ae);switch(m){case"log":for(let J=0;J<F;++J)$[J]=Math.log($[J]);break;case"log10":for(let J=0;J<F;++J)$[J]=Math.log10($[J]);break;case"log10_max_norm":{for(let ue=0;ue<F;++ue)$[ue]=Math.log10($[ue]);let xe=(w??Ce($)[0])-8;for(let ue=0;ue<F;++ue)$[ue]=(Math.max($[ue],xe)+4)/4;break}case"dB":if(o===1)Rz($,x,E,k);else if(o===2)Dz($,x,E,k);else throw new Error(`Cannot use log_mel option '${m}' with power ${o}`);break;default:throw new Error(`log_mel must be one of null, 'log', 'log10', 'log10_max_norm', or 'dB'. Got '${m}'`)}}return P}function ft(t,e,{periodic:r=!0,frame_length:s=null,center:n=!0}={}){let o=r?t+1:t,a;switch(e){case"boxcar":a=new Float64Array(o).fill(1);break;case"hann":case"hann_window":a=J2(o);break;case"hamming":a=Cz(o);break;case"povey":a=J2(o).map(i=>Math.pow(i,.85));break;default:throw new Error(`Unknown window type ${e}.`)}if(r&&(a=a.subarray(0,t)),s===null)return a;if(t>s)throw new Error(`Length of the window (${t}) may not be larger than frame_length (${s})`);return a}function Fz(t,e){let r=t.reduce((o,a)=>o+a.length,0),s=new ArrayBuffer(44),n=new DataView(s);return _d(n,0,"RIFF"),n.setUint32(4,36+r*4,!0),_d(n,8,"WAVE"),_d(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,3,!0),n.setUint16(22,1,!0),n.setUint32(24,e,!0),n.setUint32(28,e*4,!0),n.setUint16(32,4,!0),n.setUint16(34,32,!0),_d(n,36,"data"),n.setUint32(40,r*4,!0),new Blob([s,...t.map(o=>o.buffer)],{type:"audio/wav"})}function _d(t,e,r){for(let s=0;s<r.length;++s)t.setUint8(e+s,r.charCodeAt(s))}var Xn=class{constructor(e,r){this.audio=e,this.sampling_rate=r}get data(){if(Array.isArray(this.audio)){if(this.audio.length===0)return new Float32Array(0);if(this.audio.length===1)return this.audio[0];let e=this.audio.reduce((n,o)=>n+o.length,0),r=new Float32Array(e),s=0;for(let n of this.audio)r.set(n,s),s+=n.length;return r}else return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),Fz(e,this.sampling_rate)}async save(e){return fd(e,this.toBlob())}};var hd=class extends Ee{constructor(e){super(e);let r=this.config.sampling_rate,s=nt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ft(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,r){return dt(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:r,transpose:!0})}async _call(e){Re(e,"ASTFeatureExtractor");let r=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let s=this.std*2,n=r.data;for(let o=0;o<n.length;++o)n[o]=(n[o]-this.mean)/s}return{input_values:r.unsqueeze_(0)}}};var Kn=class extends Ee{async _call(e){Re(e,"EncodecFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=this.config.feature_size;if(e.length%r!==0)throw new Error(`The length of the audio data must be a multiple of the number of channels (${r}).`);let s=[1,r,e.length/r];return{input_values:new N("float32",e,s)}}};var gd=class extends Ee{async _call(e){Re(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new N("float32",e,r)}}};var wd=class extends Ee{constructor(e){super(e),this.mel_filters=nt(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=nt(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=ft(this.config.fft_window_size,"hann")}async _get_input_mel(e,r,s,n){let o,a=!1,i=e.length-r;if(i>0)if(s==="rand_trunc"){a=!0;let l=Math.floor(Vr.random()*(i+1));e=e.subarray(l,l+r),o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw new Error(`Truncation strategy "${s}" not implemented`);else{if(i<0){let l=new Float64Array(r);if(l.set(e),n==="repeat")for(let c=e.length;c<r;c+=e.length)l.set(e.subarray(0,Math.min(e.length,r-c)),c);else if(n==="repeatpad")for(let c=e.length;c<-i;c+=e.length)l.set(e,c);e=l}if(s==="fusion")throw new Error(`Truncation strategy "${s}" not implemented`);o=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}return o.unsqueeze_(0)}async _extract_fbank_features(e,r,s=null){return dt(e,this.window,this.config.fft_window_size,this.config.hop_length,{power:2,mel_filters:r,log_mel:"dB",max_num_frames:s,do_pad:!1,transpose:!0})}async _call(e,{max_length:r=null}={}){return Re(e,"ClapFeatureExtractor"),{input_features:(await this._get_input_mel(e,r??this.config.nb_max_samples,this.config.truncation,this.config.padding)).unsqueeze_(0)}}};var Qn=class extends Kn{};var xd=class extends Ee{constructor(e){super(e);let{fft_length:r,feature_size:s,min_frequency:n,max_frequency:o,sampling_rate:a,frame_length:i}=this.config,l=nt(Math.floor(1+r/2),s,n,o,a,null,"htk",!1);this.mel_filters=l,this.window=ft(i,"hann")}async _extract_fbank_features(e,r){return dt(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:r=48e4,truncation:s=!0,padding:n=!0,pad_to_multiple_of:o=128}={}){if(Re(e,"Gemma3nAudioFeatureExtractor"),s&&e.length>r&&(e=e.slice(0,r)),n&&e.length%o!==0){let l=o-e.length%o,c=new Float64Array(e.length+l);c.set(e),this.config.padding_value!==0&&c.fill(this.config.padding_value,e.length),e=c}let a=await this._extract_fbank_features(e,this.config.max_length),i=qe([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:i}}};var yd=class extends Ee{constructor(e){super(e);let{n_fft:r,win_length:s,n_mels:n,sample_rate:o}=e.melspec_kwargs;this.mel_filters=nt(Math.floor(1+r/2),n,0,o/2,o,null,"htk");let a=ft(s,"hann");this.window=new Float64Array(r);let i=Math.floor((r-s)/2);this.window.set(a,i)}async _call(e){Re(e,"GraniteSpeechFeatureExtractor");let{n_fft:r,hop_length:s,n_mels:n}=this.config.melspec_kwargs,o=1+Math.floor((e.length-1)/s),a=o-o%2;return{input_features:(await dt(e,this.window,r,s,{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)}}};var bd=class extends Ee{async _call(e){Re(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new N("float32",e,r)}}};var Bz=1e-5,vd=class extends Ee{constructor(e){super(e),this.config.mel_filters??=nt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,this.config.sampling_rate/2,this.config.sampling_rate,"slaney","slaney");let r=ft(this.config.win_length,"hann",{periodic:!1});this.window=new Float64Array(this.config.n_fft);let s=Math.floor((this.config.n_fft-this.config.win_length)/2);this.window.set(r,s)}async _extract_fbank_features(e){let r=this.config.preemphasis;e=new Float64Array(e);for(let n=e.length-1;n>=1;--n)e[n]-=r*e[n-1];return await dt(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){Re(e,"ParakeetFeatureExtractor");let r=await this._extract_fbank_features(e),s=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),n=r.data;n.fill(0,s*r.dims[1]);let[o,a]=r.dims,i=new Float64Array(a),l=new Float64Array(a);for(let d=0;d<s;++d){let _=d*a;for(let m=0;m<a;++m){let w=n[_+m];i[m]+=w,l[m]+=w*w}}let c=s>1?s-1:1;for(let d=0;d<a;++d){let _=i[d]/s,m=(l[d]-s*_*_)/c,x=1/(Math.sqrt(m)+Bz);for(let E=0;E<s;++E){let k=E*a+d;n[k]=(n[k]-_)*x}}let p=new BigInt64Array(o);return p.fill(1n,0,s),{input_features:r.unsqueeze_(0),attention_mask:new N("int64",p,[1,o])}}};var Yn=class extends Ee{async _call(e){Re(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,1,e.length];return{input_values:new N("float32",e,r)}}samples_to_frames(e){return(e-this.config.offset)/this.config.step}post_process_speaker_diarization(e,r){let s=r/this.samples_to_frames(r)/this.config.sampling_rate,n=[];for(let o of e.tolist()){let a=[],i=-1;for(let l=0;l<o.length;++l){let c=Ie(o[l]),[p,d]=Ce(c),[_,m]=[l,l+1];d!==i?(i=d,a.push({id:d,start:_,end:m,score:p})):(a.at(-1).end=m,a.at(-1).score+=p)}n.push(a.map(({id:l,start:c,end:p,score:d})=>({id:l,start:c*s,end:p*s,confidence:d/(p-c)})))}return n}};var kd=class extends Ee{constructor(e){super(e);let r=this.config.sampling_rate,s=nt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ft(400,"povey",{periodic:!1})}async _extract_fbank_features(e,r){return e=e.map(s=>s*32768),dt(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:r,transpose:!0})}async _call(e,{padding:r=!0,pad_to_multiple_of:s=2,do_normalize_per_mel_bins:n=!0,return_attention_mask:o=!0}={}){Re(e,"SeamlessM4TFeatureExtractor");let a=await this._extract_fbank_features(e,this.config.max_length);if(n){let[w,x]=a.dims,E=a.data;for(let k=0;k<x;++k){let A=0;for(let O=0;O<w;++O)A+=E[O*x+k];let T=A/w,S=0;for(let O=0;O<w;++O)S+=(E[O*x+k]-T)**2;S/=w-1;let L=Math.sqrt(S+1e-7);for(let O=0;O<w;++O){let v=O*x+k;E[v]=(E[v]-T)/L}}}let i;if(r){let[w,x]=a.dims,E=a.data,k=w%s;if(k>0){let A=new Float32Array(x*(w+k));A.set(E),A.fill(this.config.padding_value,E.length);let T=w+k;a=new N(a.type,A,[T,x]),o&&(i=new N("int64",new BigInt64Array(T),[1,T]),i.data.fill(1n,0,w))}}let[l,c]=a.dims,p=this.config.stride;if(l%p!==0)throw new Error(`The number of frames (${l}) must be a multiple of the stride (${p}).`);let _=a.view(1,Math.floor(l/p),c*p),m={input_features:_};if(o){let w=_.dims[1],x=new BigInt64Array(w);if(i){let E=i.data;for(let k=1,A=0;k<l;k+=p,++A)x[A]=E[k]}else x.fill(1n);m.attention_mask=new N("int64",x,[1,w])}return m}};var Ed=class extends Qn{};var Ad=class extends Ee{};var Md=class extends Ee{_zero_mean_unit_var_norm(e){let s=e.reduce((o,a)=>o+a,0)/e.length,n=e.reduce((o,a)=>o+(a-s)**2,0)/e.length;return e.map(o=>(o-s)/Math.sqrt(n+1e-7))}async _call(e){Re(e,"Wav2Vec2FeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=e;this.config.do_normalize&&(r=this._zero_mean_unit_var_norm(r));let s=[1,r.length];return{input_values:new N("float32",r,s),attention_mask:new N("int64",new BigInt64Array(r.length).fill(1n),s)}}};var Sd=class extends Ee{constructor(e){super(e);let r=this.config.sampling_rate,s=nt(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ft(400,"hamming",{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(r=>r*32768),dt(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){Re(e,"WeSpeakerFeatureExtractor");let r=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let s=r.mean(1).data,n=r.data,[o,a,i]=r.dims;for(let l=0;l<o;++l){let c=l*a*i,p=l*i;for(let d=0;d<a;++d){let _=c+d*i;for(let m=0;m<i;++m)n[_+m]-=s[p+m]}}}return{input_features:r}}};var Td=class extends Ee{constructor(e){super(e),this.config.mel_filters??=nt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=ft(this.config.n_fft,"hann")}async _extract_fbank_features(e,{center:r=!0}={}){let{n_fft:s,hop_length:n,mel_filters:o,global_log_mel_max:a}=this.config,i=Math.floor(r?e.length/n:(e.length-s)/n);return await dt(e,this.window,s,n,{power:2,mel_filters:o,log_mel:"log10_max_norm",max_log_mel:a,center:r,max_num_frames:i,do_pad:!1})}async _call(e,{center:r=!0}={}){return Re(e,"VoxtralRealtimeFeatureExtractor"),{input_features:(await this._extract_fbank_features(e,{center:r})).unsqueeze_(0)}}};var Od=class extends Ee{constructor(e){super(e),this.config.mel_filters??=nt(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=ft(this.config.n_fft,"hann")}async _extract_fbank_features(e){return await dt(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:r=null}={}){Re(e,"WhisperFeatureExtractor");let s,n=r??this.config.n_samples;return e.length>n?(e.length>this.config.n_samples&&Z.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`."),s=e.slice(0,n)):(s=new Float32Array(n),s.set(e)),{input_features:(await this._extract_fbank_features(s)).unsqueeze_(0)}}};var We=class{static async from_pretrained(e,r={}){let s=await ut(e,zl,!0,r),n=s.feature_extractor_type,o=Nl[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${ns}.`);return new o(s)}};var Id=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e,r=null){let s=this.tokenizer(e),n=r?await this.feature_extractor(r):{};return{...s,...n}}};var Cd=yr(require("sharp"),1);var Ws,rM,os;if(ie.IS_WEB_ENV)Ws=(t,e)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(t,e)},os=self.createImageBitmap,rM=self.ImageData;else if(Cd.default)os=async t=>{let r=(await t.metadata()).channels,{data:s,info:n}=await t.rotate().raw().toBuffer({resolveWithObject:!0}),o=new Ke(new Uint8ClampedArray(s),n.width,n.height,n.channels);return r!==void 0&&r!==n.channels&&o.convert(r),o};else throw new Error("Unable to load image processing library.");var Uz={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},jz=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),Ke=class t{constructor(e,r,s,n){this.data=e,this.width=r,this.height=s,this.channels=n}get size(){return[this.width,this.height]}static async read(e){if(e instanceof t)return e;if(typeof e=="string"||e instanceof URL)return await this.fromURL(e);if(e instanceof Blob)return await this.fromBlob(e);if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)return this.fromCanvas(e);throw new Error(`Unsupported input type: ${typeof e}`)}static fromCanvas(e){if(!ie.IS_WEB_ENV)throw new Error("fromCanvas() is only supported in browser environments.");let s=e.getContext("2d").getImageData(0,0,e.width,e.height).data;return new t(s,e.width,e.height,4)}static async fromURL(e){let r=await Xr(e);if(r.status!==200)throw new Error(`Unable to read image from "${e}" (${r.status} ${r.statusText})`);let s=await r.blob();return this.fromBlob(s)}static async fromBlob(e){if(ie.IS_WEB_ENV){let r=await os(e),s=Ws(r.width,r.height).getContext("2d");return s.drawImage(r,0,0),new this(s.getImageData(0,0,r.width,r.height).data,r.width,r.height,4)}else{let r=(0,Cd.default)(await e.arrayBuffer());return await os(r)}}static fromTensor(e,r="CHW"){if(e.dims.length!==3)throw new Error(`Tensor should have 3 dimensions, but has ${e.dims.length} dimensions.`);if(r==="CHW")e=e.transpose(1,2,0);else if(r!=="HWC")throw new Error(`Unsupported channel format: ${r}`);if(!(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array))throw new Error(`Unsupported tensor type: ${e.type}`);switch(e.dims[2]){case 1:case 2:case 3:case 4:return new t(e.data,e.dims[1],e.dims[0],e.dims[2]);default:throw new Error(`Unsupported number of channels: ${e.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let r=0,s=0;r<this.data.length;r+=this.channels){let n=this.data[r],o=this.data[r+1],a=this.data[r+2];e[s++]=Math.round(.2989*n+.587*o+.114*a)}break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,1)}rgb(){if(this.channels===3)return this;let e=new Uint8ClampedArray(this.width*this.height*3);switch(this.channels){case 1:for(let r=0,s=0;r<this.data.length;++r)e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=this.data[r];break;case 4:for(let r=0,s=0;r<this.data.length;r+=4)e[s++]=this.data[r],e[s++]=this.data[r+1],e[s++]=this.data[r+2];break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,3)}rgba(){if(this.channels===4)return this;let e=new Uint8ClampedArray(this.width*this.height*4);switch(this.channels){case 1:for(let r=0,s=0;r<this.data.length;++r)e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=this.data[r],e[s++]=255;break;case 3:for(let r=0,s=0;r<this.data.length;r+=3)e[s++]=this.data[r],e[s++]=this.data[r+1],e[s++]=this.data[r+2],e[s++]=255;break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this._update(e,this.width,this.height,4)}putAlpha(e){if(e.width!==this.width||e.height!==this.height)throw new Error(`Expected mask size to be ${this.width}x${this.height}, but got ${e.width}x${e.height}`);if(e.channels!==1)throw new Error(`Expected mask to have 1 channel, but got ${e.channels}`);let r=this.data,s=e.data,n=this.width*this.height;if(this.channels===3){let o=new Uint8ClampedArray(n*4);for(let a=0,i=0,l=0;a<n;++a)o[l++]=r[i++],o[l++]=r[i++],o[l++]=r[i++],o[l++]=s[a];return this._update(o,this.width,this.height,4)}else if(this.channels===4){for(let o=0;o<n;++o)r[4*o+3]=s[o];return this}throw new Error(`Expected image to have 3 or 4 channels, but got ${this.channels}`)}async resize(e,r,{resample:s=2}={}){if(this.width===e&&this.height===r)return this;let n=Uz[s]??s,o=ib(e),a=ib(r);if(o&&a)return this;if(o?e=r/this.height*this.width:a&&(r=e/this.width*this.height),ie.IS_WEB_ENV){let i=this.channels,l=this.toCanvas(),c=Ws(e,r).getContext("2d");return c.drawImage(l,0,0,e,r),new t(c.getImageData(0,0,e,r).data,e,r,4).convert(i)}else{let i=this.toSharp();switch(n){case"box":case"hamming":(n==="box"||n==="hamming")&&(Z.warn(`Resampling method ${n} is not yet supported. Using bilinear instead.`),n="bilinear");case"nearest":case"bilinear":case"bicubic":i=i.affine([e/this.width,0,0,r/this.height],{interpolator:n});break;case"lanczos":i=i.resize({width:e,height:r,fit:"fill",kernel:"lanczos3"});break;default:throw new Error(`Resampling method ${n} is not supported.`)}return await os(i)}}async pad([e,r,s,n]){if(e=Math.max(e,0),r=Math.max(r,0),s=Math.max(s,0),n=Math.max(n,0),e===0&&r===0&&s===0&&n===0)return this;if(ie.IS_WEB_ENV){let o=this.channels,a=this.toCanvas(),i=this.width+e+r,l=this.height+s+n,c=Ws(i,l).getContext("2d");return c.drawImage(a,0,0,this.width,this.height,e,s,this.width,this.height),new t(c.getImageData(0,0,i,l).data,i,l,4).convert(o)}else{let o=this.toSharp().extend({left:e,right:r,top:s,bottom:n});return await os(o)}}async crop([e,r,s,n]){if(e=Math.max(e,0),r=Math.max(r,0),s=Math.min(s,this.width-1),n=Math.min(n,this.height-1),e===0&&r===0&&s===this.width-1&&n===this.height-1)return this;let o=s-e+1,a=n-r+1;if(ie.IS_WEB_ENV){let i=this.channels,l=this.toCanvas(),c=Ws(o,a).getContext("2d");return c.drawImage(l,e,r,o,a,0,0,o,a),new t(c.getImageData(0,0,o,a).data,o,a,4).convert(i)}else{let i=this.toSharp().extract({left:e,top:r,width:o,height:a});return await os(i)}}async center_crop(e,r){if(this.width===e&&this.height===r)return this;let s=(this.width-e)/2,n=(this.height-r)/2;if(ie.IS_WEB_ENV){let o=this.channels,a=this.toCanvas(),i=Ws(e,r).getContext("2d"),l=0,c=0,p=0,d=0;return s>=0?l=s:p=-s,n>=0?c=n:d=-n,i.drawImage(a,l,c,e,r,p,d,e,r),new t(i.getImageData(0,0,e,r).data,e,r,4).convert(o)}else{let o=this.toSharp();if(s>=0&&n>=0)o=o.extract({left:Math.floor(s),top:Math.floor(n),width:e,height:r});else if(s<=0&&n<=0){let a=Math.floor(-n),i=Math.floor(-s);o=o.extend({top:a,left:i,right:e-this.width-i,bottom:r-this.height-a})}else{let a=[0,0],i=0;n<0?(a[0]=Math.floor(-n),a[1]=r-this.height-a[0]):i=Math.floor(n);let l=[0,0],c=0;s<0?(l[0]=Math.floor(-s),l[1]=e-this.width-l[0]):c=Math.floor(s),o=o.extend({top:a[0],bottom:a[1],left:l[0],right:l[1]}).extract({left:c,top:i,width:e,height:r})}return await os(o)}}async toBlob(e="image/png",r=1){if(!ie.IS_WEB_ENV)throw new Error("toBlob() is only supported in browser environments.");return await this.toCanvas().convertToBlob({type:e,quality:r})}toTensor(e="CHW"){let r=new N("uint8",new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!=="HWC")if(e==="CHW")r=r.permute(2,0,1);else throw new Error(`Unsupported channel format: ${e}`);return r}toCanvas(){if(!ie.IS_WEB_ENV)throw new Error("toCanvas() is only supported in browser environments.");let e=this.clone().rgba(),r=Ws(e.width,e.height),s=new rM(e.data,e.width,e.height);return r.getContext("2d").putImageData(s,0,0),r}split(){let{data:e,width:r,height:s,channels:n}=this,o=e.constructor,a=e.length/n,i=Array.from({length:n},()=>new o(a));for(let l=0;l<a;++l){let c=n*l;for(let p=0;p<n;++p)i[p][l]=e[c+p]}return i.map(l=>new t(l,r,s,1))}_update(e,r,s,n=null){return this.data=e,this.width=r,this.height=s,n!==null&&(this.channels=n),this}clone(){return new t(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw new Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(ie.IS_WEB_ENV){if(ie.IS_WEBWORKER_ENV)throw new Error("Unable to save an image from a Web Worker.");let r=e.split(".").pop().toLowerCase(),s=jz.get(r)??"image/png",n=await this.toBlob(s);return fd(e,n)}else if(ie.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw new Error("Unable to save the image because filesystem is disabled in this environment.")}toSharp(){if(ie.IS_WEB_ENV)throw new Error("toSharp() is only supported in server-side environments.");return(0,Cd.default)(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},sM=Ke.read.bind(Ke);function nM(t,e,r=0,s=null){let n=t/e,o=aA(n)*e;return s!==null&&o>s&&(o=Math.floor(n)*e),o<r&&(o=Math.ceil(n)*e),o}function oM([t,e],r){return[Math.max(Math.floor(t/r),1)*r,Math.max(Math.floor(e/r),1)*r]}function A1([t,e,r,s]){return[t-r/2,e-s/2,t+r/2,e+s/2]}function as(t,e=.5,r=null,s=!1){let n=t.logits,o=t.pred_boxes,[a,i,l]=n.dims;if(r!==null&&r.length!==a)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=[];for(let p=0;p<a;++p){let d=r!==null?r[p]:null,_={boxes:[],classes:[],scores:[]},m=n[p],w=o[p];for(let x=0;x<i;++x){let E=m[x],k=[],A;if(s){A=E.sigmoid().data;for(let T=0;T<A.length;++T)A[T]>e&&k.push(T)}else{let T=Ce(E.data)[1];if(T===l-1||(A=Ie(E.data),A[T]<e))continue;k.push(T)}for(let T of k){let S=w[x].data;S=A1(S),d!==null&&(S=S.map((L,O)=>L*d[(O+1)%2])),_.boxes.push(S),_.classes.push(T),_.scores.push(A[T])}}c.push(_)}return c}function Ld(t,e=null){let r=t.logits,s=r.dims[0];if(e!==null&&e.length!==s)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let n=[];for(let o=0;o<s;++o){let a=e!==null?e[o]:null,i=r[o];a!==null&&(i=yp(i,a,"bilinear",!1));let[l,c]=a??i.dims.slice(-2),p=new N("int32",new Int32Array(l*c),[l,c]),d=i[0].data,_=p.data;for(let x=1;x<i.dims[0];++x){let E=i[x].data;for(let k=0;k<E.length;++k)E[k]>d[k]&&(d[k]=E[k],_[k]=x)}let m=new Array(i.dims[0]);for(let x=0;x<_.length;++x){let E=_[x];m[E]=E}let w=m.filter(x=>x!==void 0);n.push({segmentation:p,labels:w})}return n}function Gz(t,e,r,s){let n=[],o=[],a=[];for(let i=0;i<t.dims[0];++i){let l=t[i],c=e[i],p=Ce(l.data)[1];if(p===s)continue;let _=Ie(l.data)[p];_>r&&(n.push(c),o.push(_),a.push(p))}return[n,o,a]}function qz(t,e,r,s=.5,n=.8){let o=[],a=0,i=0,l=e[r].data;for(let p=0;p<t.length;++p)t[p]===r&&(o.push(p),++a),l[p]>=s&&++i;let c=a>0&&i>0;return c&&(c=a/i>n),[c,o]}function Wz(t,e,r,s,n,o=null,a=null){let[i,l]=a??t[0].dims,c=new N("int32",new Int32Array(i*l),[i,l]),p=[];if(a!==null)for(let x=0;x<t.length;++x)t[x]=yp(t[x],a,"bilinear",!1);let d=new Int32Array(t[0].data.length),_=new Float32Array(t[0].data.length);for(let x=0;x<t.length;++x){let E=e[x],k=t[x].data;for(let A=0;A<k.length;++A)k[A]*=E,k[A]>_[A]&&(d[A]=x,_[A]=k[A])}let m=0,w=c.data;for(let x=0;x<r.length;++x){let E=r[x],[k,A]=qz(d,t,x,s,n);if(k){++m;for(let T of A)w[T]=m;p.push({id:m,label_id:E,score:e[x]})}}return[c,p]}function Jn(t,e,r=28,s=3136,n=784*1280,o=1){if(t<r||e<r){let l=Math.max(r/t,r/e);t=Math.round(t*l),e=Math.round(e*l)}if(Math.max(t,e)/Math.min(t,e)>200)throw new Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(t,e)/Math.min(t,e)}`);let a=Math.round(t/r)*r,i=Math.round(e/r)*r;if(o*a*i>n){let l=Math.sqrt(o*t*e/n);a=Math.max(r,Math.floor(t/l/r)*r),i=Math.max(r,Math.floor(e/l/r)*r)}else if(o*a*i<s){let l=Math.sqrt(s/(o*t*e));a=Math.ceil(t*l/r)*r,i=Math.ceil(e*l/r)*r}return[i,a]}function Pd(t,e=.5,r=.5,s=.8,n=null,o=null){n===null&&(Z.warn("`label_ids_to_fuse` unset. No instance will be fused."),n=new Set);let a=t.class_queries_logits??t.logits,l=(t.masks_queries_logits??t.pred_masks).sigmoid(),[c,p,d]=a.dims;if(d-=1,o!==null&&o.length!==c)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let _=[];for(let m=0;m<c;++m){let w=o!==null?o[m]:null,x=a[m],E=l[m],[k,A,T]=Gz(x,E,e,d);if(T.length===0){let[O,v]=w??E.dims.slice(-2),W=new N("int32",new Int32Array(O*v).fill(-1),[O,v]);_.push({segmentation:W,segments_info:[]});continue}let[S,L]=Wz(k,A,T,r,s,n,w);_.push({segmentation:S,segments_info:L})}return _}function zd(t,e=.5,r=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var V=class extends tt{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,r,s=2){let n=e.height,o=e.width,a=r.height,i=r.width,l=Math.min(n,a),c=Math.min(o,i);return l===n&&c===o?e:(n>o?c=Math.floor(o*l/n):o>n&&(l=Math.floor(n*c/o)),await e.resize(c,l,{resample:s}))}async crop_margin(e,r=200){let s=e.clone().grayscale(),n=wl(s.data)[0],a=Ce(s.data)[0]-n;if(a===0)return e;let i=r/255,l=s.width,c=s.height,p=0,d=0,_=s.data;for(let m=0;m<s.height;++m){let w=m*s.width;for(let x=0;x<s.width;++x)(_[w+x]-n)/a<i&&(l=Math.min(l,x),c=Math.min(c,m),p=Math.max(p,x),d=Math.max(d,m))}return e=await e.crop([l,c,p,d]),e}pad_image(e,r,s,{mode:n="constant",center:o=!1,constant_values:a=0}={}){let[i,l,c]=r,p,d;if(typeof s=="number"?(p=s,d=s):s==="square"?p=d=Math.max(i,l):(p=s.width,d=s.height),p!==l||d!==i){let _=new Float32Array(p*d*c);if(Array.isArray(a))for(let x=0;x<_.length;++x)_[x]=a[x%c];else a!==0&&_.fill(a);let[m,w]=o?[Math.floor((p-l)/2),Math.floor((d-i)/2)]:[0,0];for(let x=0;x<i;++x){let E=(x+w)*p,k=x*l;for(let A=0;A<l;++A){let T=(E+A+m)*c,S=(k+A)*c;for(let L=0;L<c;++L)_[T+L]=e[S+L]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let x=i-1,E=l-1;for(let k=0;k<d;++k){let A=k*p,T=Pn(k,x)*l;for(let S=0;S<p;++S){if(k<i&&S<l)continue;let L=(A+S)*c,O=(T+Pn(S,E))*c;for(let v=0;v<c;++v)_[L+v]=e[O+v]}}}e=_,r=[d,p,c]}return[e,r]}rescale(e){for(let r=0;r<e.length;++r)e[r]=this.rescale_factor*e[r]}get_resize_output_image_size(e,r){let[s,n]=e.size,o,a;if(this.do_thumbnail){let{height:i,width:l}=r;o=Math.min(i,l)}else Number.isInteger(r)?(o=r,a=this.config.max_size??o):r!==void 0&&(o=r.shortest_edge,a=r.longest_edge);if(o!==void 0||a!==void 0){let i=o===void 0?1:Math.max(o/s,o/n),l=s*i,c=n*i,p=a===void 0?1:Math.min(a/l,a/c),d=Math.floor(Number((l*p).toFixed(2))),_=Math.floor(Number((c*p).toFixed(2)));return this.size_divisibility!==void 0&&([d,_]=oM([d,_],this.size_divisibility)),[d,_]}else if(r!==void 0&&r.width!==void 0&&r.height!==void 0){let i=r.width,l=r.height;if(this.config.keep_aspect_ratio&&this.config.ensure_multiple_of){let c=l/n,p=i/s;Math.abs(1-p)<Math.abs(1-c)?c=p:p=c,l=nM(c*n,this.config.ensure_multiple_of),i=nM(p*s,this.config.ensure_multiple_of)}return[i,l]}else{if(this.size_divisibility!==void 0)return oM([s,n],this.size_divisibility);throw new Error(`Could not resize image due to unsupported \`this.size\` option in config: ${JSON.stringify(r)}`)}}async resize(e){let[r,s]=this.get_resize_output_image_size(e,this.size);return await e.resize(r,s,{resample:this.resample})}async preprocess(e,{do_normalize:r=null,do_pad:s=null,do_convert_rgb:n=null,do_convert_grayscale:o=null,do_flip_channel_order:a=null}={}){this.do_crop_margin&&(e=await this.crop_margin(e));let[i,l]=e.size;if(n??this.do_convert_rgb?e=e.rgb():o&&(e=e.grayscale()),this.do_resize&&(e=await this.resize(e)),this.do_thumbnail&&(e=await this.thumbnail(e,this.size,this.resample)),this.do_center_crop){let m,w;Number.isInteger(this.crop_size)?(m=this.crop_size,w=this.crop_size):(m=this.crop_size.width,w=this.crop_size.height),e=await e.center_crop(m,w)}let c=[e.height,e.width],p=Float32Array.from(e.data),d=[e.height,e.width,e.channels];if(this.do_rescale&&this.rescale(p),r??this.do_normalize){let m=this.image_mean;Array.isArray(this.image_mean)||(m=new Array(e.channels).fill(m));let w=this.image_std;if(Array.isArray(this.image_std)||(w=new Array(e.channels).fill(w)),m.length!==e.channels||w.length!==e.channels)throw new Error(`When set to arrays, the length of \`image_mean\` (${m.length}) and \`image_std\` (${w.length}) must match the number of channels in the image (${e.channels}).`);for(let x=0;x<p.length;x+=e.channels)for(let E=0;E<e.channels;++E)p[x+E]=(p[x+E]-m[E])/w[E]}if(s??this.do_pad){if(this.pad_size)[p,d]=this.pad_image(p,[e.height,e.width,e.channels],this.pad_size);else if(this.size_divisibility){let m=Math.ceil(d[1]/this.size_divisibility)*this.size_divisibility,w=Math.ceil(d[0]/this.size_divisibility)*this.size_divisibility;[p,d]=this.pad_image(p,d,{width:m,height:w})}}if(a??this.do_flip_channel_order){if(d[2]!==3)throw new Error("Flipping channel order is only supported for RGB images.");for(let m=0;m<p.length;m+=3){let w=p[m];p[m]=p[m+2],p[m+2]=w}}let _=new N("float32",p,d).permute(2,0,1);return{original_size:[l,i],reshaped_input_size:c,pixel_values:_}}async _call(e,...r){Array.isArray(e)||(e=[e]);let s=await Promise.all(e.map(o=>this.preprocess(o)));return{pixel_values:St(s.map(o=>o.pixel_values),0),original_sizes:s.map(o=>o.original_size),reshaped_input_sizes:s.map(o=>o.reshaped_input_size)}}static async from_pretrained(e,r={}){let s=await ut(e,Er,!0,r);return new this(s)}};var ro={};Os(ro,{BeitFeatureExtractor:()=>Nd,BitImageProcessor:()=>$d,CHMv2ImageProcessor:()=>Dd,CLIPFeatureExtractor:()=>Fd,CLIPImageProcessor:()=>$l,ChineseCLIPFeatureExtractor:()=>Rd,ConvNextFeatureExtractor:()=>Bd,ConvNextImageProcessor:()=>Rl,DINOv3ViTImageProcessor:()=>Gd,DPTFeatureExtractor:()=>Wd,DPTImageProcessor:()=>Bl,DeiTFeatureExtractor:()=>Ud,DeiTImageProcessor:()=>Dl,DetrFeatureExtractor:()=>jd,DetrImageProcessor:()=>Fl,DonutFeatureExtractor:()=>qd,DonutImageProcessor:()=>Vs,EfficientNetImageProcessor:()=>Vd,GLPNFeatureExtractor:()=>Xd,Glm46VImageProcessor:()=>Hd,GroundingDinoImageProcessor:()=>Kd,Idefics3ImageProcessor:()=>Ul,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,JinaCLIPImageProcessor:()=>Yd,Lfm2VlImageProcessor:()=>Jd,LlavaOnevisionImageProcessor:()=>Zd,Mask2FormerImageProcessor:()=>tf,MaskFormerFeatureExtractor:()=>ef,MaskFormerImageProcessor:()=>Hs,MobileNetV1FeatureExtractor:()=>rf,MobileNetV1ImageProcessor:()=>jl,MobileNetV2FeatureExtractor:()=>sf,MobileNetV2ImageProcessor:()=>Gl,MobileNetV3FeatureExtractor:()=>nf,MobileNetV3ImageProcessor:()=>ql,MobileNetV4FeatureExtractor:()=>of,MobileNetV4ImageProcessor:()=>Wl,MobileViTFeatureExtractor:()=>af,MobileViTImageProcessor:()=>Vl,NougatImageProcessor:()=>lf,OwlViTFeatureExtractor:()=>cf,OwlViTImageProcessor:()=>Xs,Owlv2ImageProcessor:()=>uf,Phi3VImageProcessor:()=>pf,PixtralImageProcessor:()=>df,PvtImageProcessor:()=>ff,Qwen2VLImageProcessor:()=>Zn,RTDetrImageProcessor:()=>_f,Sam2ImageProcessor:()=>to,Sam3ImageProcessor:()=>to,SamImageProcessor:()=>to,SapiensFeatureExtractor:()=>mf,SapiensImageProcessor:()=>Hl,SegformerFeatureExtractor:()=>hf,SegformerImageProcessor:()=>Xl,SiglipImageProcessor:()=>gf,SmolVLMImageProcessor:()=>Ul,Swin2SRImageProcessor:()=>wf,VLMImageProcessor:()=>Qd,ViTFeatureExtractor:()=>xf,ViTImageProcessor:()=>Kl,VitMatteImageProcessor:()=>yf,VitPoseImageProcessor:()=>bf,YolosFeatureExtractor:()=>vf,YolosImageProcessor:()=>Ql});var Nd=class extends V{};var $d=class extends V{};var Rd=class extends V{};var Dd=class extends V{};var $l=class extends V{},Fd=class extends $l{};var Rl=class extends V{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let r=this.size?.shortest_edge;if(r===void 0)throw new Error("Size dictionary must contain 'shortest_edge' key.");if(r<384){let s=Math.floor(r/this.crop_pct),[n,o]=this.get_resize_output_image_size(e,{shortest_edge:s});e=await e.resize(n,o,{resample:this.resample}),e=await e.center_crop(r,r)}else e=await e.resize(r,r,{resample:this.resample});return e}},Bd=class extends Rl{};var Dl=class extends V{},Ud=class extends Dl{};var Fl=class extends V{async _call(e){let r=await super._call(e),s=[r.pixel_values.dims[0],64,64],n=qe(s,1n);return{...r,pixel_mask:n}}post_process_object_detection(...e){return as(...e)}post_process_panoptic_segmentation(...e){return Pd(...e)}post_process_instance_segmentation(...e){return zd(...e)}},jd=class extends Fl{};var Gd=class extends V{};var Vs=class extends V{pad_image(e,r,s,n={}){let[o,a,i]=r,l=this.image_mean;Array.isArray(this.image_mean)||(l=new Array(i).fill(l));let c=this.image_std;Array.isArray(c)||(c=new Array(i).fill(l));let p=l.map((d,_)=>-d/c[_]);return super.pad_image(e,r,s,{center:!0,constant_values:p,...n})}},qd=class extends Vs{};var Bl=class extends V{},Wd=class extends Bl{};var Vd=class extends V{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(r=>r*r))}};var Zn=class extends V{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,r){let s=this.patch_size*this.merge_size;return Jn(e.height,e.width,s,this.min_pixels,this.max_pixels)}async _call(e,...r){let{pixel_values:s,original_sizes:n,reshaped_input_sizes:o}=await super._call(e,...r),a=s,{temporal_patch_size:i,merge_size:l,patch_size:c}=this.config;a.dims[0]===1&&(a=ve(Array.from({length:i},()=>a),0));let p=a.dims[0]/i,d=a.dims[1],_=Math.floor(a.dims[2]/c),m=Math.floor(a.dims[3]/c),w=a.view(p,i,d,Math.floor(_/l),l,c,Math.floor(m/l),l,c).permute(0,3,6,4,7,2,1,5,8).view(p*_*m,d*i*c*c),x=new N("int64",[p,_,m],[1,3]);return{pixel_values:w,image_grid_thw:x,original_sizes:n,reshaped_input_sizes:o}}};var Hd=class extends Zn{get_resize_output_image_size(e,r){let s=this.patch_size*this.merge_size,n=this.config.temporal_patch_size??2;return Jn(e.height,e.width,s,this.min_pixels,this.max_pixels,n)}};var Xd=class extends V{};var Kd=class extends V{async _call(e){let r=await super._call(e),s=r.pixel_values.dims,n=Je([s[0],s[2],s[3]]);return{...r,pixel_mask:n}}};var Ul=class extends V{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,r){let[s,n]=e.dims.slice(-2),o=n/s;return n>=s?(n=Math.ceil(n/r)*r,s=Math.floor(n/o),s=Math.ceil(s/r)*r):(s=Math.ceil(s/r)*r,n=Math.floor(s*o),n=Math.ceil(n/r)*r),{height:s,width:n}}async _call(e,{do_image_splitting:r=null,return_row_col_info:s=!1}={}){let n;if(!Array.isArray(e))n=[[e]];else{if(e.length===0||!e[0])throw new Error("No images provided.");Array.isArray(e[0])?n=e:n=[e]}let o=[],a=[],i=[],l=[],c=[];for(let k of n){let A=await Promise.all(k.map(L=>this.preprocess(L)));l.push(...A.map(L=>L.original_size)),c.push(...A.map(L=>L.reshaped_input_size)),A.forEach(L=>L.pixel_values.unsqueeze_(0));let{longest_edge:T}=this.max_image_size,S;if(r??this.do_image_splitting){let L=new Array(A.length),O=new Array(A.length);S=await Promise.all(A.map(async(v,W)=>{let X=this.get_resize_for_vision_encoder(v.pixel_values,T),B=await xt(v.pixel_values,{size:[X.height,X.width]}),{frames:H,num_splits_h:G,num_splits_w:Q}=await this.split_image(B,this.max_image_size);return L[W]=G,O[W]=Q,ve(H,0)})),a.push(L),i.push(O)}else{let L=[T,T];S=await Promise.all(A.map(O=>xt(O.pixel_values,{size:L}))),a.push(new Array(A.length).fill(0)),i.push(new Array(A.length).fill(0))}o.push(ve(S,0))}let p=o.length,[d,_,m,w]=o[0].dims,x,E;if(p===1)x=o[0].unsqueeze_(0),E=qe([p,d,m,w],!0);else{let k=Math.max(...o.map(S=>S.dims.at(0)));E=qe([p,k,m,w],!0);let A=E.data,T=k*m*w;for(let S=0;S<p;++S){let L=o[S].dims[0];if(L<k){o[S]=ve([o[S],qe([k-L,_,m,w],0)],0);let O=S*T+L*m*w,v=(S+1)*T;A.fill(!1,O,v)}}x=St(o,0)}return{pixel_values:x,pixel_attention_mask:E,original_sizes:l,reshaped_input_sizes:c,...s?{rows:a,cols:i}:{}}}async split_image(e,{longest_edge:r}){let s=r,n=r,o=[],[a,i]=e.dims.slice(-2),l=0,c=0;if(a>s||i>n){l=Math.ceil(a/s),c=Math.ceil(i/n);let p=Math.ceil(a/l),d=Math.ceil(i/c);for(let w=0;w<l;++w)for(let x=0;x<c;++x){let E,k,A,T;w===l-1?(k=a-p,T=a):(k=w*p,T=(w+1)*p),x===c-1?(E=i-d,A=i):(E=x*d,A=(x+1)*d);let O=await Il(e,[k,E],[T,A],[2,3]);o.push(O)}let _=s,m=n;(a!==_||i!==m)&&(e=await xt(e,{size:[_,m]}))}return o.push(e),{frames:o,num_splits_h:l,num_splits_w:c}}};var Qd=class extends V{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(r=>r*this.rescale_factor)}pad_image(e,r,s,n){return super.pad_image(e,r,s,{constant_values:this.constant_values,center:!0,...n})}};var Yd=class extends V{constructor(e){let{resize_mode:r,fill_color:s,interpolation:n,size:o,...a}=e,i=r==="squash"?{width:o,height:o}:r==="shortest"?{shortest_edge:o}:{longest_edge:o},l=n==="bicubic"?3:2;super({...a,size:i,resample:l,do_center_crop:!0,crop_size:o,do_normalize:!0})}};function aM(t,e){return Math.round(t/e)*e}function Vz(t,e,r,s,n){let o=1/0,a=[1,1],i=r*s;for(let l of e){let c=Math.abs(t-l[0]/l[1]);c<o?(o=c,a=l):c===o&&i>.5*n*n*l[0]*l[1]&&(a=l)}return a}function Hz(t,e){let r=[],s=new Set;for(let n=t;n<=e;++n)for(let o=1;o<=n;++o)for(let a=1;a<=n;++a){let i=o*a;if(i>=t&&i<=e){let l=o<<16|a;s.has(l)||(s.add(l),r.push([o,a]))}}return r.sort((n,o)=>n[0]*n[1]-o[0]*o[1])}function Xz(t,e){let[r,s,n,o]=t.dims,a=Math.floor(n/e),i=Math.floor(o/e),l=e*e*s,c=t.data,p=new Float32Array(r*a*i*l),d=n*o;for(let _=0;_<r;++_){let m=_*s*d,w=_*a*i*l;for(let x=0;x<a;++x)for(let E=0;E<i;++E){let k=w+(x*i+E)*l;for(let A=0;A<e;++A){let T=(x*e+A)*o+E*e;for(let S=0;S<e;++S){let L=T+S;for(let O=0;O<s;++O)p[k++]=c[m+O*d+L]}}}}return new N("float32",p,[r,a*i,l])}function Kz(t,e){let[,r,s]=t.dims,n=new BigInt64Array(e);n.fill(1n,0,r);let o=t;if(r<e){let a=new Float32Array(e*s);a.set(t.data),o=new N("float32",a,[1,e,s])}return{padded:o,mask:new N("int64",n,[e])}}var Jd=class extends V{constructor(e){super(e),this.downsample_factor=e.downsample_factor??2,this.do_image_splitting=e.do_image_splitting??!0,this.min_tiles=e.min_tiles??2,this.max_tiles=e.max_tiles??10,this.use_thumbnail=e.use_thumbnail??!0,this.min_image_tokens=e.min_image_tokens??64,this.max_image_tokens=e.max_image_tokens??256,this.encoder_patch_size=e.encoder_patch_size??e.patch_size??16,this.tile_size=e.tile_size??512,this.max_pixels_tolerance=e.max_pixels_tolerance??2,this.return_row_col_info=e.return_row_col_info??!1;let r=this.max_image_tokens*this.downsample_factor**2,s=this.do_image_splitting?(this.tile_size/this.encoder_patch_size)**2:0;this.max_num_patches=Math.max(r,s)}_is_image_too_large(e,r){let s=this.encoder_patch_size*this.downsample_factor,n=Math.max(this.encoder_patch_size,aM(e,s)),o=Math.max(this.encoder_patch_size,aM(r,s));return n*o>this.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,r){let s=Hz(this.min_tiles,this.max_tiles),[n,o]=Vz(r/e,s,r,e,this.tile_size);return{grid_width:n,grid_height:o,target_width:this.tile_size*n,target_height:this.tile_size*o}}async _call(e,{return_row_col_info:r=null}={}){let s;Array.isArray(e)?Array.isArray(e[0])?s=e:s=[e]:s=[[e]];let n=[],o=[],a=[],i=[],l=[],c=[];for(let d of s){let _=await Promise.all(d.map(m=>this.preprocess(m,{do_pad:!1})));for(let{pixel_values:m}of _){let[,w,x]=m.dims,E=m.unsqueeze_(0),k=this.encoder_patch_size*this.downsample_factor,A=k**2,[T,S]=Jn(Math.max(k,w),Math.max(k,x),k,this.min_image_tokens*A,this.max_image_tokens*A).map(B=>Math.max(k,B)),L,O=1,v=1,W=this._is_image_too_large(w,x),X=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(W&&X){let{grid_width:B,grid_height:H,target_width:G,target_height:Q}=this._get_grid_layout(w,x);O=H,v=B;let R=await xt(E,{size:[Q,G]});L=[];for(let C=0;C<H;++C)for(let te=0;te<B;++te){let ae=C*this.tile_size,P=te*this.tile_size;L.push(R.slice(null,null,[ae,ae+this.tile_size],[P,P+this.tile_size]))}this.use_thumbnail&&B*H!==1&&L.push(await xt(E,{size:[S,T]}))}else L=[await xt(E,{size:[S,T]})];for(let B of L){let[,,H,G]=B.dims,Q=Xz(B,this.encoder_patch_size),{padded:R,mask:C}=Kz(Q,this.max_num_patches);n.push(R),o.push(C),a.push([Math.floor(H/this.encoder_patch_size),Math.floor(G/this.encoder_patch_size)])}i.push(O),l.push(v),c.push([S,T])}}let p={pixel_values:ve(n,0),pixel_attention_mask:St(o,0),spatial_shapes:new N("int64",BigInt64Array.from(a.flat(),BigInt),[a.length,2])};return(r??this.return_row_col_info)&&(p.image_rows=i,p.image_cols=l,p.image_sizes=c),p}};var Zd=class extends V{};var Hs=class extends V{post_process_panoptic_segmentation(...e){return Pd(...e)}post_process_instance_segmentation(...e){return zd(...e)}},ef=class extends Hs{};var tf=class extends Hs{};var jl=class extends V{},rf=class extends jl{};var Gl=class extends V{},sf=class extends Gl{};var ql=class extends V{},nf=class extends ql{};var Wl=class extends V{},of=class extends Wl{};var Vl=class extends V{},af=class extends Vl{};var lf=class extends Vs{};var Xs=class extends V{post_process_object_detection(...e){return as(...e)}},cf=class extends Xs{};var uf=class extends Xs{};var zt=336,Qz=[2,3],{ceil:M1,floor:eo,sqrt:S1}=Math,pf=class extends V{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,r){let{num_img_tokens:s}=this.config;return eo((eo(r/zt)*eo(e/zt)+1)*s+1+(eo(r/zt)+1)*S1(s))}get_resize_output_image_size(e,r){let s=this._num_crops,[n,o]=e.size,a=n/o,i=1;for(;i*Math.ceil(i/a)<=s;)i+=1;i-=1;let l=Math.floor(i*336),c=Math.floor(l/a);return[l,c]}pad_image(e,r,s,n={}){let[o,a]=r,i=zt*M1(o/zt),l=zt*M1(a/zt),c=[1,1,1].map((p,d)=>(p-this.image_mean[d])/this.image_std[d]);return super.pad_image(e,r,{width:l,height:i},{center:!0,constant_values:c,...n})}async _call(e,{num_crops:r=null}={}){if(this._num_crops=r??=this.config.num_crops,r<4||S1(r)%1!==0)throw new Error("num_crops must be a square number >= 4");Array.isArray(e)||(e=[e]);let s=e.length,n=await Promise.all(e.map(_=>this.preprocess(_))),o=n.map(_=>_.original_size),a=n.map(_=>_.reshaped_input_size),i=[];for(let{pixel_values:_}of n){_.unsqueeze_(0);let[m,w]=_.dims.slice(-2),x=await xt(_,{size:[zt,zt],mode:"bicubic"});if(r>0){let E=[],k=S1(r),A=eo(w/k),T=eo(m/k);for(let L=0;L<k;++L)for(let O=0;O<k;++O){let v,W,X,B;L===k-1?(W=m-T,B=m):(W=L*T,B=(L+1)*T),O===k-1?(v=w-A,X=w):(v=O*A,X=(O+1)*A);let Q=await Il(_,[W,v],[B,X],Qz);E.push(Q)}let S=await xt(ve(E,0),{size:[zt,zt],mode:"bicubic"});i.push(ve([x,S],0))}else i.push(x)}let l=St(i,0),c=a.map(_=>_.map(m=>zt*M1(m/zt))),p=new N("int64",c.flat(),[s,2]),d=c.map(([_,m])=>this.calc_num_image_tokens_from_image_size(m,_));return{pixel_values:l,original_sizes:o,reshaped_input_sizes:a,image_sizes:p,num_img_tokens:d}}};var df=class extends V{get_resize_output_image_size(e,r){let{longest_edge:s}=r;if(s===void 0)throw new Error("size must contain 'longest_edge'");let[n,o]=e.size,a=Math.max(n,o)/s,i=n,l=o;a>1&&(i=Math.floor(n/a),l=Math.floor(o/a));let{patch_size:c,spatial_merge_size:p}=this.config;if(!p)throw new Error("config must contain 'spatial_merge_size'");let d=c*p,_=Math.floor((i-1)/d)+1,m=Math.floor((l-1)/d)+1;return[_*d,m*d]}};var ff=class extends V{};var _f=class extends V{post_process_object_detection(...e){return as(...e)}};var to=class extends V{reshape_input_points(e,r,s,n=!1){e=structuredClone(e);let o=lb(e);if(o.length===3)n||(o=[1,...o]),e=[e];else if(o.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let a=0;a<e.length;++a){let[i,l]=r[a],[c,p]=s[a],d=[p/l,c/i];for(let _=0;_<e[a].length;++_)for(let m=0;m<e[a][_].length;++m)for(let w=0;w<e[a][_][m].length;++w)e[a][_][m][w]*=d[w%2]}return new N("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,r){let s=lb(e);if(s.length===2)s=[1,...s],e=[e];else if(s.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(s.some((n,o)=>n!==r.dims[o]))throw Error(`The first ${s.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new N("int64",e.flat(1/0).map(BigInt),s)}async _call(e,{input_points:r=null,input_labels:s=null,input_boxes:n=null}={}){let o=await super._call(e);if(r&&(o.input_points=this.reshape_input_points(r,o.original_sizes,o.reshaped_input_sizes)),s){if(!o.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");o.input_labels=this.add_input_labels(s,o.input_points)}return n&&(o.input_boxes=this.reshape_input_points(n,o.original_sizes,o.reshaped_input_sizes,!0)),o}async post_process_masks(e,r,s,{mask_threshold:n=0,binarize:o=!0,pad_size:a=null}={}){let i=[];a=a??this.pad_size??this.size;let l=[a.height,a.width];for(let c=0;c<r.length;++c){let p=r[c],d=s[c],_=await xt(e[c],{mode:"bilinear",size:l});if(_=_.slice(null,null,[0,d[0]],[0,d[1]]),_=await xt(_,{mode:"bilinear",size:p}),o){let m=_.data,w=new Uint8Array(m.length);for(let x=0;x<m.length;++x)m[x]>n&&(w[x]=1);_=new N("bool",w,_.dims)}i.push(_)}return i}generate_crop_boxes(e,r,{crop_n_layers:s=0,overlap_ratio:n=512/1500,points_per_crop:o=32,crop_n_points_downscale_factor:a=1}={}){}};var Hl=class extends V{post_process_semantic_segmentation(...e){return Ld(...e)}},mf=class extends Hl{};var Xl=class extends V{post_process_semantic_segmentation(...e){return Ld(...e)}},hf=class extends Xl{};var gf=class extends V{};var wf=class extends V{pad_image(e,r,s,n={}){let[o,a,i]=r;return super.pad_image(e,r,{width:a+(s-a%s)%s,height:o+(s-o%s)%s},{mode:"symmetric",center:!1,constant_values:-1,...n})}};var Kl=class extends V{},xf=class extends Kl{};var yf=class extends V{async _call(e,r){Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]);let s=await Promise.all(e.map(a=>this.preprocess(a))),n=await Promise.all(r.map(a=>this.preprocess(a,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:St(s.map((a,i)=>ve([a.pixel_values,n[i].pixel_values],0)),0),original_sizes:s.map(a=>a.original_size),reshaped_input_sizes:s.map(a=>a.reshaped_input_size)}}};var bf=class extends V{post_process_pose_estimation(e,r,{threshold:s=null}={}){let n=e.tolist(),[o,a,i,l]=e.dims,c=[];for(let p=0;p<o;++p){let d=n[p],_=r[p],m=[];for(let w=0;w<_.length;++w){let x=_[w],E=[],k=[],A=[],T=x.at(-2)/l,S=x.at(-1)/i;for(let L=0;L<d.length;++L){let[O,v]=[0,0],W=0,X=-1/0,B=d[L];for(let G=0;G<B.length;++G){let Q=B[G];for(let R=0;R<Q.length;++R){let C=Q[R];W+=C,X=Math.max(X,C),O+=(R+.5)*C,v+=G*C}}if(s!=null&&X<s)continue;let H=[T*O/W,S*v/W];E.push(H),A.push(L),k.push(X)}m.push({bbox:x,scores:k,labels:A,keypoints:E})}c.push(m)}return c}};var Ql=class extends V{post_process_object_detection(...e){return as(...e)}},vf=class extends Ql{};var Te=class{static async from_pretrained(e,r={}){let s=await ut(e,Er,!0,r),n=s.image_processor_type??s.feature_extractor_type,o=ro[n?.replace(/Fast$/,"")];return o||(n!==void 0&&Z.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${ns}.`),o=V),new o(s)}};var kf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;constructor(e,r,s){super(e,r,s);let{tasks_answer_post_processing_type:n,task_prompts_without_inputs:o,task_prompts_with_input:a}=this.image_processor.config;this.tasks_answer_post_processing_type=new Map(Object.entries(n??{})),this.task_prompts_without_inputs=new Map(Object.entries(o??{})),this.task_prompts_with_input=new Map(Object.entries(a??{})),this.regexes={quad_boxes:/(.+?)<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm,bboxes:/([^<]+)?<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e=="string"&&(e=[e]);let r=[];for(let s of e)if(this.task_prompts_without_inputs.has(s))r.push(this.task_prompts_without_inputs.get(s));else{for(let[n,o]of this.task_prompts_with_input)if(s.includes(n)){r.push(o.replaceAll("{input}",s).replaceAll(n,""));break}r.length!==e.length&&r.push(s)}return r}post_process_generation(e,r,s){let n=this.tasks_answer_post_processing_type.get(r)??"pure_text";e=e.replaceAll("<s>","").replaceAll("</s>","");let o;switch(n){case"pure_text":o=e;break;case"description_with_bboxes":case"bboxes":case"phrase_grounding":case"ocr":let a=n==="ocr"?"quad_boxes":"bboxes",i=e.matchAll(this.regexes[a]),l=[],c=[];for(let[p,d,..._]of i)l.push(d?d.trim():l.at(-1)??""),c.push(_.map((m,w)=>(Number(m)+.5)/this.size_per_bin*s[w%2]));o={labels:l,[a]:c};break;default:throw new Error(`Task "${r}" (of type "${n}") not yet implemented.`)}return{[r]:o}}async _call(e,r=null,s={}){if(!e&&!r)throw new Error("Either text or images must be provided");let n=await this.image_processor(e,s),o=r?this.tokenizer(this.construct_prompts(r),s):{};return{...n,...o}}};var Ef=class extends re{static image_processor_class=Te;static feature_extractor_class=We;static tokenizer_class=oe;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,r,s){super(e,r,s),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:n,boa_token:o,audio_token:a,eoa_token:i,image_token_id:l,boi_token:c,image_token:p,eoi_token:d}=this.tokenizer.config;this.audio_token_id=n,this.boa_token=o,this.audio_token=a;let _=a.repeat(this.audio_seq_length);this.full_audio_sequence=`
|
|
14
14
|
|
|
15
|
-
${o}${
|
|
15
|
+
${o}${_}${i}
|
|
16
16
|
|
|
17
|
-
`,this.image_token_id=l,this.boi_token=
|
|
17
|
+
`,this.image_token_id=l,this.boi_token=c,this.image_token=p;let m=p.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
18
18
|
|
|
19
|
-
${
|
|
19
|
+
${c}${m}${d}
|
|
20
20
|
|
|
21
|
-
`}async _call(e,r=null,s=null,n={}){typeof e=="string"&&(e=[e]);let o;s&&(o=await this.feature_extractor(s,n),e=e.map(l=>l.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return r&&(a=await this.image_processor(r,n),e=e.map(l=>l.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,n),...a,...o}}};function
|
|
21
|
+
`}async _call(e,r=null,s=null,n={}){typeof e=="string"&&(e=[e]);let o;s&&(o=await this.feature_extractor(s,n),e=e.map(l=>l.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return r&&(a=await this.image_processor(r,n),e=e.map(l=>l.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,n),...a,...o}}};var is=class extends re{static image_processor_class=Te;static tokenizer_class=oe;static image_token="<|image_pad|>";async _call(e,r=null,...s){Array.isArray(e)||(e=[e]);let n,o;if(r&&(n=await this.image_processor(r),o=n.image_grid_thw),o){let i=this.image_processor.config.merge_size**2,l=0,c=this.constructor.image_token,p=o.tolist();e=e.map(d=>{for(;d.includes(c);){let _=Number(p[l++].reduce((m,w)=>m*w,1n));d=d.replace(c,"<|placeholder|>".repeat(Math.floor(_/i)))}return d.replaceAll("<|placeholder|>",c)})}return{...this.tokenizer(e),...n}}};var Af=class extends is{static image_token="<|image|>"};var Mf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;static uses_processor_config=!0;_get_num_audio_features(e){let{hop_length:r}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:s,projector_downsample_rate:n}=this.feature_extractor.config,o=Math.floor(s/n),a=Math.floor(e/r)+1,i=Math.floor(a/2);return Math.ceil(i/s)*o}async _call(e,r=null,s={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(r){let{input_features:a}=await this.feature_extractor(r);n.input_features=a;let i=this._get_num_audio_features(r.length),l=new Uint8Array(i).fill(1);n.input_features_mask=new N("bool",l,[1,i]);let c=this.config.audio_token??"<|audio|>";if(!e.includes(c))throw new Error(`The input text does not contain the audio token ${c}.`);e=e.replaceAll(c,c.repeat(i))}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};function Yz(t,e){let s=t.dims.at(-1)-1,n=t.tolist();n.fill(!1,0,1),n.fill(!1,s);let o=e.tolist();return n.map((a,i)=>a?i:null).filter(a=>a!==null).map(a=>o[a])}var Sf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;async _call(e,r,s={}){let n=e?await this.image_processor(e,s):{};return{...r?this.tokenizer(r,s):{},...n}}post_process_grounded_object_detection(e,r,{box_threshold:s=.25,text_threshold:n=.25,target_sizes:o=null}={}){let{logits:a,pred_boxes:i}=e,l=a.dims[0];if(o!==null&&o.length!==l)throw Error("Make sure that you pass in as many target sizes as the batch dimension of the logits");let c=a.dims.at(1),p=a.sigmoid(),d=p.max(-1).tolist(),_=i.tolist().map(w=>w.map(x=>A1(x))),m=[];for(let w=0;w<l;++w){let x=o!==null?o[w]:null;x!==null&&(_[w]=_[w].map(S=>S.map((L,O)=>L*x[(O+1)%2])));let E=d[w],k=[],A=[],T=[];for(let S=0;S<c;++S){let L=E[S];if(L<=s)continue;let O=_[w][S],v=p[w][S];k.push(L),T.push(O);let W=Yz(v.gt(n),r[w]);A.push(W)}m.push({scores:k,boxes:T,labels:this.batch_decode(A)})}return m}};function Jz(t,e,r,s,n,o){let a="";for(let i=0;i<e;++i){for(let l=0;l<r;++l)a+=s+`<row_${i+1}_col_${l+1}>`+n.repeat(t);a+=`
|
|
22
22
|
`}return a+=`
|
|
23
|
-
${s}${o}`+n.repeat(t)+`${s}`,a}function
|
|
24
|
-
`}var
|
|
25
|
-
`}):(J.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=r.map(u=>VL(u,n,o,Wn,e.length)));let i=this.tokenizer(a,s);return{...await this.image_processor(e,s),...i}}};var c2="<|image|>",HL=/<\|image_\d+\|>/g,uf=class extends oe{static image_processor_class=$e;static tokenizer_class=ce;async _call(e,r=null,{padding:s=!0,truncation:n=!0,num_crops:o=null}={}){Array.isArray(e)||(e=[e]);let a,i;if(r){i=await this.image_processor(r,{num_crops:o});let{num_img_tokens:l}=i,u=e.map((f,m)=>f.split(HL).join(c2.repeat(l[m])));a=this.tokenizer(u,{padding:s,truncation:n});let p=this.tokenizer._tokenizer.token_to_id(c2);a.input_ids.map_(f=>f==p?-f:f)}else a=this.tokenizer(e);return{...a,...i}}};var pf=class extends oe{static tokenizer_class=ce;static image_processor_class=$e;static uses_processor_config=!0;async _call(e,r=null,s={}){let n=await this.image_processor(e,s);if(r){let[a,i]=n.pixel_values.dims.slice(-2),{image_token:l,image_break_token:u,image_end_token:p,patch_size:f,spatial_merge_size:m}=this.config,h=f*m,w=Math.floor(a/h),x=Math.floor(i/h);r=structuredClone(r),Array.isArray(r)||(r=[r]);for(let v=0;v<r.length;++v){let E=l.repeat(x),A=E+u,S=E+p,T=A.repeat(w-1)+S;r[v]=r[v].replace(l,T)}}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var df=class extends oe{static feature_extractor_class=Fn;async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}get sampling_rate(){return this.feature_extractor.config.sampling_rate}};var Vn=class extends oe{static image_processor_class=$e;static tokenizer_class=ce;async _call(e,r=null,...s){Array.isArray(e)||(e=[e]);let n,o;if(r&&(n=await this.image_processor(r),o=n.image_grid_thw),o){let i=this.image_processor.config.merge_size**2,l=0,u=o.tolist();e=e.map(p=>{for(;p.includes("<|image_pad|>");){let f=Number(u[l++].reduce((m,h)=>m*h,1n));p=p.replace("<|image_pad|>","<|placeholder|>".repeat(Math.floor(f/i)))}return p.replaceAll("<|placeholder|>","<|image_pad|>")})}return{...this.tokenizer(e),...n}}};var Hn=class extends Vn{};var ff=class extends Hn{};var Xn=class extends oe{static image_processor_class=$e;async _call(...e){return await this.image_processor(...e)}post_process_masks(...e){return this.image_processor.post_process_masks(...e)}reshape_input_points(...e){return this.image_processor.reshape_input_points(...e)}};var Il=class extends Xn{},mf=class extends Il{};var hf=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;async _call(e){return await this.feature_extractor(e)}};var _f=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;static uses_processor_config=!0;async _call(e,r=null,s={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(r){let a=r.length,{input_features:i}=await this.feature_extractor(r,{...s,max_length:a}),l=Math.round(a/this.config.encoder_ds_factor+1e-4),u=1+Math.ceil(l/this.config.stack_factor);n.audio_token_len=[u],n.audio_values=i;let p=this.config.audio_placeholder;if(!e.includes(p))throw new Error(`The input text does not contain the image token ${p}.`);e=e.replaceAll(p,p.repeat(u))}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var gf="[AUDIO]",XL="[BEGIN_AUDIO]",KL=375;function YL(t,e){let r=[];for(let s=0;s<t.length;s+=e)r.push(t.subarray(s,Math.min(s+e,t.length)));return r}var wf=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;static uses_processor_config=!1;async _call(e,r=null,s={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(r){if(!e.includes(gf))throw new Error(`The input text does not contain the audio token ${gf}.`);Array.isArray(r)||(r=[r]);let a=e.split(gf),i=a.length-1;if(i!==r.length)throw new Error(`The number of audio inputs (${r.length}) does not match the number of audio tokens in the text (${i}).`);let l=this.feature_extractor.config.n_samples,u=r.map(w=>YL(w,l)),p=u.map(w=>w.length),f=u.flat(),m=(await Promise.all(f.map(w=>this.feature_extractor(w,s)))).map(w=>w.input_features);n.audio_values=m.length>1?Ee(m,0):m[0];let h=a[0];for(let w=0;w<p.length;++w){h+=XL;for(let x=0;x<p[w];++x)h+=gf.repeat(KL);h+=a[w+1]}e=h}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var xf=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;async _call(e){return await this.feature_extractor(e)}};var yf=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;async _call(e){return await this.feature_extractor(e)}};var bf=class extends oe{static tokenizer_class=ce;static feature_extractor_class=et;async _call(e){return await this.feature_extractor(e)}};var Cl=class{static async from_pretrained(e,r={}){let s=await ut(e,Mr,!0,r),{image_processor_type:n,feature_extractor_type:o,processor_class:a}=s;if(a&&vf[a])return vf[a].from_pretrained(e,r);if(!n&&!o)throw new Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let i={};if(n){let u=qn[n.replace(/Fast$/,"")];if(!u)throw new Error(`Unknown image_processor_type: '${n}'.`);i.image_processor=new u(s)}if(o){let u=qn[o];if(u)i.image_processor=new u(s);else{let p=fl[o];if(!p)throw new Error(`Unknown feature_extractor_type: '${o}'.`);i.feature_extractor=new p(s)}}let l={};return new oe(l,i,null)}};async function QL(t,e){return await ut(t,"config.json",!0,e)}function Kn(t){let e={},r={};switch(t.model_type){case"llava":case"paligemma":case"gemma3":case"florence2":case"llava_onevision":case"idefics3":case"ultravox":case"voxtral":case"smolvlm":case"gemma3n":case"chatterbox":case"mistral3":case"qwen2_5_vl":case"qwen3_vl":case"qwen3_vl_moe":r=Kn(t.text_config);break;case"moondream1":r=Kn(t.phi_config);break;case"musicgen":r=Kn(t.decoder);break;case"multi_modality":r=Kn(t.language_config);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"falcon":case"modernbert-decoder":e.num_heads="num_attention_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size";break;case"gpt_oss":case"llama":case"llama4_text":case"nanochat":case"apertus":case"arcee":case"afmoe":case"lfm2":case"lfm2_moe":case"smollm3":case"olmo":case"olmo2":case"olmo3":case"mobilellm":case"granite":case"granitemoehybrid":case"cohere":case"cohere2":case"mistral":case"starcoder2":case"qwen2":case"qwen2_moe":case"qwen2_vl":case"qwen2_5_vl_text":case"qwen3_moe":case"qwen3_vl_text":case"qwen3_vl_moe_text":case"phi":case"phi3":case"phi3_v":case"llava_qwen2":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size",e.num_attention_heads="num_attention_heads",e.dim_kv="head_dim";break;case"qwen3":case"gemma":case"gemma2":case"vaultgemma":case"gemma3_text":case"gemma3n_text":case"glm":case"helium":case"ernie4_5":case"hunyuan_v1_dense":case"falcon_h1":case"ministral":case"ministral3":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="head_dim";break;case"openelm":e.num_heads="num_kv_heads",e.num_layers="num_transformer_layers",e.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":e.num_heads="num_heads",e.num_layers="num_layers",e.hidden_size="hidden_size";break;case"bloom":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="hidden_size";break;case"mpt":e.num_heads="n_heads",e.num_layers="n_layers",e.hidden_size="d_model";break;case"exaone":e.num_heads="num_key_value_heads",e.num_layers="num_layers",e.dim_kv="head_dim",e.num_attention_heads="num_attention_heads";break;case"youtu":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="qk_head_dim",e.num_attention_heads="num_attention_heads";break;case"t5":case"mt5":case"longt5":e.num_decoder_layers="num_decoder_layers",e.num_decoder_heads="num_heads",e.decoder_dim_kv="d_kv",e.num_encoder_layers="num_layers",e.num_encoder_heads="num_heads",e.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"lite-whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="d_model",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="d_model";break;case"speecht5":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="hidden_size",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="hidden_size";break;case"trocr":e.num_encoder_layers=e.num_decoder_layers="decoder_layers",e.num_encoder_heads=e.num_decoder_heads="decoder_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="d_model";break;case"musicgen_decoder":e.num_encoder_layers=e.num_decoder_layers="num_hidden_layers",e.num_encoder_heads=e.num_decoder_heads="num_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"moonshine":e.num_decoder_layers="decoder_num_hidden_layers",e.num_decoder_heads="decoder_num_key_value_heads",e.num_encoder_layers="encoder_num_hidden_layers",e.num_encoder_heads="encoder_num_key_value_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"vision-encoder-decoder":let n=Kn(t.decoder),o="num_decoder_layers"in n,a=ot(t,["model_type","is_encoder_decoder"]);return o?(a.num_decoder_layers=n.num_decoder_layers,a.num_decoder_heads=n.num_decoder_heads,a.decoder_hidden_size=n.decoder_hidden_size,a.num_encoder_layers=n.num_encoder_layers,a.num_encoder_heads=n.num_encoder_heads,a.encoder_hidden_size=n.encoder_hidden_size):(a.num_layers=n.num_layers,a.num_heads=n.num_heads,a.hidden_size=n.hidden_size),a}let s={...r,...ot(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)s[n]=t[e[n]];return s}function Ll(t,e){if(["lfm2","lfm2_moe"].includes(t.model_type)){let r=e?.prefix??"past_key_values",s=r==="present"?"present":"past",n={},{layer_types:o,num_attention_heads:a,num_key_value_heads:i,hidden_size:l,conv_L_cache:u}=t,p=l/a,f=e?.batch_size??1;for(let m=0;m<o.length;++m)if(o[m]==="full_attention")for(let h of["key","value"])n[`${r}.${m}.${h}`]=[f,i,0,p];else if(o[m]==="conv")n[`${s}_conv.${m}`]=[f,l,u];else throw new Error(`Unsupported layer type: ${o[m]}`);return n}else if(["granitemoehybrid","falcon_h1"].includes(t.model_type)){let r=e?.prefix??"past_key_values",s=r==="present"?"present":"past",n={},{layer_types:o,num_hidden_layers:a,num_attention_heads:i,num_key_value_heads:l,hidden_size:u,mamba_d_conv:p,mamba_n_heads:f,mamba_d_head:m,mamba_d_state:h,mamba_n_groups:w,mamba_expand:x,mamba_d_ssm:v}=t,E=u/i,A=e?.batch_size??1,S=(v??x*u)+2*w*h;for(let T=0;T<a;++T)if((!o||o[T]==="mamba")&&(n[`${s}_conv.${T}`]=[A,S,p],n[`${s}_ssm.${T}`]=[A,f,m,h]),!o||o[T]==="attention")for(let L of["key","value"])n[`${r}.${T}.${L}`]=[A,l,0,E];return n}else if(["qwen3_next","qwen3_5_text","qwen3_5_moe_text","olmo_hybrid"].includes(t.model_type)){let r=e?.prefix??"past_key_values",s=r==="present"?"present":"past",n={},{head_dim:o,layer_types:a,num_attention_heads:i,num_key_value_heads:l,hidden_size:u,linear_num_value_heads:p,linear_num_key_heads:f,linear_key_head_dim:m,linear_value_head_dim:h,linear_conv_kernel_dim:w}=t,x=m*f,v=h*p,E=o??u/i,A=e?.batch_size??1;for(let S=0;S<a.length;++S)if(a[S]==="full_attention")for(let T of["key","value"])n[`${r}.${S}.${T}`]=[A,l,0,E];else if(a[S]==="linear_attention"){if(t.model_type==="olmo_hybrid")n[`${s}_conv.${S}.key`]=[A,x,w],n[`${s}_conv.${S}.value`]=[A,v,w],n[`${s}_conv.${S}.query`]=[A,x,w];else{let T=x*2+v;n[`${s}_conv.${S}`]=[A,T,w]}n[`${s}_recurrent.${S}`]=[A,p,m,h]}else throw new Error(`Unsupported layer type: ${a[S]}`);return n}else if(["qwen3_5","qwen3_5_moe"].includes(t.model_type))return Ll(t.text_config,e);return JL(t,e)}function JL(t,{prefix:e="past_key_values",batch_size:r=1}={}){let s={},n=t.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n){let o=n.encoder_dim_kv??n.encoder_hidden_size/n.num_encoder_heads,a=n.decoder_dim_kv??n.decoder_hidden_size/n.num_decoder_heads,i=[r,n.num_encoder_heads,0,o],l=[r,n.num_decoder_heads,0,a];for(let u=0;u<n.num_decoder_layers;++u)s[`${e}.${u}.encoder.key`]=i,s[`${e}.${u}.encoder.value`]=i,s[`${e}.${u}.decoder.key`]=l,s[`${e}.${u}.decoder.value`]=l}else{let o=n.num_heads,a=n.num_layers,i=n.dim_kv??n.hidden_size/(n.num_attention_heads??o);if(n.model_type==="falcon"){let l=[r*o,0,i];for(let u=0;u<a;++u)s[`${e}.${u}.key`]=l,s[`${e}.${u}.value`]=l}else if(n.multi_query){let l=[r*o,0,2*i];for(let u=0;u<a;++u)s[`${e}.${u}.key_value`]=l}else if(n.model_type==="bloom"){let l=[r*o,i,0],u=[r*o,0,i];for(let p=0;p<a;++p)s[`${e}.${p}.key`]=l,s[`${e}.${p}.value`]=u}else if(n.model_type==="openelm")for(let l=0;l<a;++l){let u=[r,o[l],0,i];s[`${e}.${l}.key`]=u,s[`${e}.${l}.value`]=u}else{let l=[r,o,0,i];for(let u=0;u<a;++u)s[`${e}.${u}.key`]=l,s[`${e}.${u}.value`]=l}}return s}var Pl=class t{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=Kn(this)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){s&&!(s instanceof t)&&(s=new t(s));let i=s??await QL(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a});return new this(i)}},Wt=class{static async from_pretrained(...e){return Pl.from_pretrained(...e)}};function Rb(t,e,r){return t?typeof t=="object"&&t!==null?t.hasOwnProperty(e)?+t[e]:t.hasOwnProperty(r)?+t[r]:0:+t:0}function Db(t,e){let r=[];for(let s=0;s<e;++s)r.push(`${t}_data${s===0?"":"_"+s}`);return r}async function u2(t,e,r,s){let n=`${e}${s}.onnx`,o=`${r.subfolder??""}/${n}`;return await Ki(t,o,!0,r,se.IS_NODE_ENV)}async function p2(t,e,r,s,n,o={}){let a=`${e}${r}.onnx`,i=se.IS_NODE_ENV,l=[],u=Rb(n,a,e);if(u>0){if(u>Lu)throw new Error(`The number of external data chunks (${u}) exceeds the maximum allowed value (${Lu}).`);let p=Db(a,u);for(let f of p){let m=`${s.subfolder??""}/${f}`;l.push(new Promise(async(h,w)=>{let x=await Ki(t,m,!0,s,i);h(x instanceof Uint8Array?{path:f,data:x}:f)}))}}else o.externalData!==void 0&&(l=o.externalData.map(async p=>{if(typeof p.data=="string"){let f=await Ki(t,p.data,!0,s);return{...p,data:f}}return p}));return Promise.all(l)}async function ZL(t,e,r,s=!1){let n=r.config?.["transformers.js_config"]??{},o=Ju(r.device??n.device,e,{warn:S=>J.info(S)}),a=UA(o),i=n.device_config??{};i.hasOwnProperty(o)&&(n={...n,...i[o]});let l=Zu(r.dtype??n.dtype,e,o,{configDtype:n.dtype,warn:S=>J.info(S)});if(al.hasOwnProperty(l)){if(o==="webgpu"&&!se.IS_NODE_ENV&&l===ht.fp16&&!await GA())throw new Error(`The device (${o}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${l}. Should be one of: ${Object.keys(ht).join(", ")}`);let u=n.kv_cache_dtype,p=u?typeof u=="string"?u:u[l]??"float32":void 0;if(p&&!["float32","float16"].includes(p))throw new Error(`Invalid kv_cache_dtype: ${p}. Should be one of: float32, float16`);let f=al[l],m={...r.session_options};m.executionProviders??=a;let h=n.free_dimension_overrides;h?m.freeDimensionOverrides??=h:o.startsWith("webnn")&&!m.freeDimensionOverrides&&J.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${o}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let w=u2(t,e,r,f),x=r.use_external_data_format??n.use_external_data_format,v=await p2(t,e,f,r,x,m);if(v.length>0&&!se.IS_NODE_ENV&&(m.externalData=v),s&&o==="webgpu"&&u!==!1){let S=Ll(r.config,{prefix:"present"});if(Object.keys(S).length>0&&!ol()){let T={};for(let L in S)T[L]="gpu-buffer";m.preferredOutputLocation=T}}return{buffer_or_path:await w,session_options:m,session_config:{dtype:l,kv_cache_dtype:p,device:o}}}async function Et(t,e,r,s=void 0){return Object.fromEntries(await Promise.all(Object.keys(e).map(async n=>{let{buffer_or_path:o,session_options:a,session_config:i}=await ZL(t,e[n],r,n===s),l=await Ku(o,a,i);return[n,l]})))}function d2(t){for(let e in t)Qu(t[e])?t[e]=new D(t[e]):typeof t[e]=="object"&&d2(t[e]);return t}async function pe(t,e){let r=eN(t,e);try{let s=Object.fromEntries(Object.entries(r).map(([o,a])=>{let i=a.ort_tensor;return se.IS_NODE_ENV&&typeof Float16Array<"u"&&i.cpuData instanceof Float16Array&&(i.cpuData=new Uint16Array(i.cpuData.buffer)),[o,i]})),n=await Yu(t,s);return d2(n)}catch(s){let n=Object.fromEntries(Object.entries(r).map(([o,a])=>{let i={type:a.type,dims:a.dims,location:a.location};return i.location!=="gpu-buffer"&&(i.data=a.data),[o,i]}));throw J.error(`An error occurred during model execution: "${s}".`),J.error("Inputs given to model:",n),s}}function eN(t,e){let r=Object.create(null),s=[];for(let a of t.inputNames){let i=e[a];if(!(i instanceof D)){s.push(a);continue}r[a]=ol()?i.clone():i}if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);let n=Object.keys(e).length,o=t.inputNames.length;if(n>o){let a=Object.keys(e).filter(i=>!t.inputNames.includes(i));J.warn(`WARNING: Too many inputs were provided (${n} > ${o}). The following inputs will be ignored: "${a.join(", ")}".`)}return r}var Re=class{};var G=class extends Re{constructor({logits:e,...r}){super(),this.logits=e;let s=Object.values(r);s.length>0&&(this.attentions=s)}},_e=class extends Re{constructor({logits:e}){super(),this.logits=e}},we=class extends Re{constructor({logits:e}){super(),this.logits=e}},Ae=class extends Re{constructor({start_logits:e,end_logits:r}){super(),this.start_logits=e,this.end_logits=r}},wt=class extends Re{constructor({logits:e}){super(),this.logits=e}};var kf=class extends Re{constructor({alphas:e}){super(),this.alphas=e}};var Dt=class extends Ze{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},Yn=class extends Ze{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},cs=class extends Ze{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,r){let s=r;for(let n of this.processors)s=n(e,s);return s}[Symbol.iterator](){return this.processors.values()}},Nl=class extends Dt{constructor(e){super(),this.bos_token_id=e}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===1){let n=r[s].data;n.fill(-1/0),n[this.bos_token_id]=0}return r}},zl=class extends Dt{constructor(e,r){super(),this.max_length=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===this.max_length-1){let n=r[s].data;n.fill(-1/0);for(let o of this.eos_token_id)n[o]=0}return r}},qs=class extends Dt{constructor(e,r){super(),this.begin_suppress_tokens=e,this.begin_index=r}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===this.begin_index){let n=r[s].data;for(let o of this.begin_suppress_tokens)n[o]=-1/0}return r}},$l=class extends Dt{constructor(e,r){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=r.length,r.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data;if(n[this.no_timestamps_token_id]=-1/0,e[s].length===this.begin_index-1){n.fill(-1/0),n[this.timestamp_begin]=0;continue}let o=e[s].slice(this.begin_index),a=o.length>=1&&o[o.length-1]>=this.timestamp_begin,i=o.length<2||o[o.length-2]>=this.timestamp_begin;if(a&&(i?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[s].length===this.begin_index&&this.max_initial_timestamp_index!==null){let f=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(f+1).fill(-1/0)}let l=$u(n),u=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((f,m)=>f+m)),p=Se(l.subarray(0,this.timestamp_begin))[0];u>p&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return r}},Rl=class extends Dt{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let r=e.length,s=[];for(let o=0;o<r+1-this.no_repeat_ngram_size;++o){let a=[];for(let i=0;i<this.no_repeat_ngram_size;++i)a.push(e[o+i]);s.push(a.map(Number))}let n=new Map;for(let o of s){let a=o.slice(0,o.length-1),i=JSON.stringify(a),l=n.get(i)??[];l.push(o[o.length-1]),n.set(i,l)}return n}getGeneratedNgrams(e,r){let s=r.slice(r.length+1-this.no_repeat_ngram_size,r.length);return e.get(JSON.stringify(s.map(Number)))??[]}calcBannedNgramTokens(e){let r=[];if(e.length+1<this.no_repeat_ngram_size)return r;{let s=this.getNgrams(e);return this.getGeneratedNgrams(s,e)}}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data,o=this.calcBannedNgramTokens(e[s]);for(let a of o)n[a]=-1/0}return r}},Dl=class extends Dt{constructor(e){super(),this.penalty=e}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data;for(let o of new Set(e[s])){let a=Number(o);n[a]<0?n[a]*=this.penalty:n[a]/=this.penalty}}return r}},Ul=class extends Dt{constructor(e,r){super(),this.min_length=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length<this.min_length){let n=r[s].data;for(let o of this.eos_token_id)n[o]=-1/0}return r}},Bl=class extends Dt{constructor(e,r,s){super(),this.prompt_length_to_skip=e,this.min_new_tokens=r,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length-this.prompt_length_to_skip<this.min_new_tokens){let o=r[s].data;for(let a of this.eos_token_id)o[a]=-1/0}return r}},Fl=class extends Dt{constructor(e,r){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data,o=e[s];for(let a of this.bad_words_ids){if(o.length<a.length-1)continue;let i=!0;for(let l=1;l<=a.length-1;++l)if(a.at(-l-1)!=o.at(-l)){i=!1;break}i&&(n[a.at(-1)]=-1/0)}}return r}},jl=class extends Dt{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,r){if(r.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 ${r.dims[0]} for the logits and ${e.length} for the input ids.`);let s=e.length,n=r.slice([0,s],null),o=r.slice([s,r.dims[0]],null);for(let a=0;a<o.data.length;++a)o.data[a]+=(n.data[a]-o.data[a])*this.guidance_scale;return o}},Gl=class extends Yn{constructor(e){if(super(),typeof e!="number"||e<=0){let r=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(r+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,r){let s=r.data;for(let n=0;n<s.length;++n)s[n]/=this.temperature;return r}},Ub=class extends Yn{constructor(e,{filter_value:r=-1/0,min_tokens_to_keep:s=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(s)||s<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${s}`);this.top_p=e,this.filter_value=r,this.min_tokens_to_keep=s}},Bb=class extends Yn{constructor(e,{filter_value:r=-1/0,min_tokens_to_keep:s=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,s),this.filter_value=r}};var Qn=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,ot(e,Object.getOwnPropertyNames(this)))}};var Ws=class extends Ze{_call(e,r){throw Error("StoppingCriteria needs to be subclassed")}},ql=class t extends Ze{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof t?e=e.criteria:e instanceof Ws&&(e=[e]),this.criteria.push(...e)}_call(e,r){let s=new Array(e.length).fill(!1);for(let n of this.criteria){let o=n(e,r);for(let a=0;a<s.length;++a)s[a]||=o[a]}return s}[Symbol.iterator](){return this.criteria.values()}},Wl=class extends Ws{constructor(e,r=null){super(),this.max_length=e,this.max_position_embeddings=r}_call(e){return e.map(r=>r.length>=this.max_length)}},Vl=class extends Ws{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,r){return e.map(s=>{let n=s.at(-1);return this.eos_token_id.some(o=>n==o)})}},Fb=class extends Ws{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,r){return new Array(e.length).fill(this.interrupted)}};var Vs=class extends Ze{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,r){let s=e.dims.at(-1),n=e.data;if(r===-1)n=n.slice(-s);else{let o=r*s;n=n.slice(o,o+s)}return n}randomSelect(e){return Yk(e)}static getSampler(e){if(e.do_sample)return new Gb(e);if(e.num_beams>1)return new qb(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 jb(e)}},jb=class extends Vs{async sample(e){let r=Se(e.data)[1];return[[BigInt(r),0]]}},Gb=class extends Vs{async sample(e){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let[s,n]=await qt(e,r),o=Ie(s.data);return Array.from({length:this.generation_config.num_beams},()=>{let a=this.randomSelect(o);return[n.data[a],Math.log(o[a])]})}},qb=class extends Vs{async sample(e){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let[s,n]=await qt(e,r),o=Ie(s.data);return Array.from({length:this.generation_config.num_beams},(a,i)=>[n.data[i],Math.log(o[i])])}};var Hs=null;function m2(t){Hs=t}function Mf(t){for(let e in t)if(e.startsWith("past_key_values."))return t[e].dims.at(-2);return Object.values(t)[0].dims.at(-2)}function Wb(t){if(t instanceof D)return t;if(t.length===0)throw Error("items must be non-empty");if(Array.isArray(t[0])){if(t.some(e=>e.length!==t[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new D("int64",BigInt64Array.from(t.flat().map(e=>BigInt(e))),[t.length,t[0].length])}else return new D("int64",BigInt64Array.from(t.map(e=>BigInt(e))),[1,t.length])}function Vb(t){return new D("bool",[t],[1])}var 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},f2={[j.DecoderOnly]:{can_generate:!0,forward:It,prepare_inputs:Hl},[j.DecoderOnlyWithoutHead]:{can_generate:!1,forward:It,prepare_inputs:Hl},[j.Seq2Seq]:{can_generate:!0,forward:Ef,prepare_inputs:Xl},[j.Vision2Seq]:{can_generate:!0,forward:Ef,prepare_inputs:Xl},[j.Musicgen]:{can_generate:!0,forward:Ef},[j.EncoderDecoder]:{can_generate:!1,forward:Ef},[j.ImageTextToText]:{can_generate:!0,forward:sN,prepare_inputs:Af},[j.AudioTextToText]:{can_generate:!0,forward:rN,prepare_inputs:Af},[j.Phi3V]:{can_generate:!0,prepare_inputs:Af},[j.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Af},[j.MultiModality]:{can_generate:!0},[j.AutoEncoder]:{can_generate:!1,forward:tN},[j.Chatterbox]:{can_generate:!0,forward:Vt},default:{can_generate:!1,forward:Vt}},sr=new Map,Tf=new Map,Xs=new Map,y=class extends Ze{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,r,s){super(),this.config=e,this.sessions=r,this.configs=s;let n=Xs.get(this.constructor),o=sr.get(n),a=f2[o]??f2.default;this.can_generate=a.can_generate,this._forward=a.forward,this._prepare_inputs_for_generation=a.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let r of Object.values(this.sessions))e.push(r.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:u=null,dtype:p=null,use_external_data_format:f=null,session_options:m={}}={}){let h={progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:u,dtype:p,use_external_data_format:f,session_options:m},w=Xs.get(this),x=sr.get(w);s=h.config=await Wt.from_pretrained(e,h);let v;if(x===j.DecoderOnly)v=await Promise.all([Et(e,{model:h.model_file_name??"model"},h,"model"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.Seq2Seq||x===j.Vision2Seq)v=await Promise.all([Et(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},h,"decoder_model_merged"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.MaskGeneration)v=await Promise.all([Et(e,{model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"},h)]);else if(x===j.EncoderDecoder)v=await Promise.all([Et(e,{model:"encoder_model",decoder_model_merged:"decoder_model_merged"},h,"decoder_model_merged")]);else if(x===j.ImageTextToText){let E={embed_tokens:"embed_tokens",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};s.is_encoder_decoder&&(E.model="encoder_model"),v=await Promise.all([Et(e,E,h,"decoder_model_merged"),Tr(e,{generation_config:"generation_config.json"},h)])}else if(x===j.AudioTextToText){let E={embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"};v=await Promise.all([Et(e,E,h,"decoder_model_merged"),Tr(e,{generation_config:"generation_config.json"},h)])}else if(x===j.ImageAudioTextToText){let E={embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};v=await Promise.all([Et(e,E,h),Tr(e,{generation_config:"generation_config.json"},h)])}else if(x===j.Musicgen)v=await Promise.all([Et(e,{model:"text_encoder",decoder_model_merged:"decoder_model_merged",encodec_decode:"encodec_decode"},h,"decoder_model_merged"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.MultiModality)v=await Promise.all([Et(e,{prepare_inputs_embeds:"prepare_inputs_embeds",model:"language_model",lm_head:"lm_head",gen_head:"gen_head",gen_img_embeds:"gen_img_embeds",image_decode:"image_decode"},h,"model"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.Phi3V)v=await Promise.all([Et(e,{prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"},h,"model"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.Chatterbox)v=await Promise.all([Et(e,{embed_tokens:"embed_tokens",speech_encoder:"speech_encoder",model:"language_model",conditional_decoder:"conditional_decoder"},h,"model"),Tr(e,{generation_config:"generation_config.json"},h)]);else if(x===j.AutoEncoder)v=await Promise.all([Et(e,{encoder_model:"encoder_model",decoder_model:"decoder_model"},h)]);else if(x===j.Supertonic)v=await Promise.all([Et(e,{text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"},h)]);else{if(x===void 0){let E=w??s?.model_type;E!=="custom"&&J.warn(`Model type for '${E}' not found, assuming encoder-only architecture. Please report this at ${as}.`)}v=await Promise.all([Et(e,{model:h.model_file_name??"model"},h)])}return new this(s,...v)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,r,s=null){let n=new cs;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new Dl(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new Rl(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new Fl(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new Ul(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 Bl(r,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new Nl(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new zl(e.max_length,e.forced_eos_token_id)),e.begin_suppress_tokens!==null){let o=r>1||e.forced_bos_token_id===null?r:r+1;n.push(new qs(e.begin_suppress_tokens,o))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new jl(e.guidance_scale)),e.temperature===0&&e.do_sample&&(J.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 Gl(e.temperature)),s!==null&&n.extend(s),n}_prepare_generation_config(e,r,s=Qn){let n={...this.config};for(let a of["decoder","generator","text_config"])a in n&&Object.assign(n,n[a]);let o=new s(n);return Object.assign(o,this.generation_config??{}),e&&Object.assign(o,e),r&&Object.assign(o,ot(r,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,r=null){let s=new ql;return e.max_length!==null&&s.push(new Wl(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&s.push(new Vl(e.eos_token_id)),r&&s.extend(r),s}_validate_model_class(){if(!this.can_generate){let e=[Hs.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,Hs.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,Hs.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,Hs.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),r=Xs.get(this.constructor),s=new Set,n=this.config.model_type;for(let a of e){let i=a?.get(n);i&&s.add(i)}let o=`The current model class (${r}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw s.size>0&&(o+=` Please use the following class instead: ${[...s].join(", ")}`),Error(o)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:r,model_inputs:s,is_encoder_decoder:n}){return s.past_key_values=this.getPastKeyValues(r,s.past_key_values),s.input_ids=new D("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in s:s.attention_mask=Ee([s.attention_mask,st([s.attention_mask.dims[0],1])],1),s.position_ids=null,s}_prepare_model_inputs({inputs:e,bos_token_id:r,model_kwargs:s}){let n=ot(s,this.forward_params),o=this.main_input_name;if(o in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[o]=e;return{inputs_tensor:n[o],model_inputs:n,model_input_name:o}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:r,model_input_name:s,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!r.inputs_embeds&&"_prepare_inputs_embeds"in this){let{input_ids:a,pixel_values:i,attention_mask:l,...u}=r,p=await this._prepare_inputs_embeds(r);r={...u,...ot(p,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await Vt(this,r);if(n.guidance_scale!==null&&n.guidance_scale>1)o=Ee([o,Nn(o,0)],0),"attention_mask"in r&&(r.attention_mask=Ee([r.attention_mask,np(r.attention_mask)],0));else if(r.decoder_input_ids){let a=Wb(r.decoder_input_ids).dims[0];if(a!==o.dims[0]){if(o.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${o.dims[0]}) than the decoder inputs (${a}).`);o=Ee(Array.from({length:a},()=>o),0)}}return r.encoder_outputs=o,r}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:r,model_kwargs:s,decoder_start_token_id:n,bos_token_id:o,generation_config:a}){let{decoder_input_ids:i,...l}=s;if(!(i instanceof D)){if(i)Array.isArray(i[0])||(i=Array.from({length:e},()=>i));else if(n??=o,this.config.model_type==="musicgen")i=Array.from({length:e*this.config.decoder.num_codebooks},()=>[n]);else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${n.length}`);i=n}else i=Array.from({length:e},()=>[n]);i=Wb(i)}return s.decoder_attention_mask=ul(i),{input_ids:i,model_inputs:l}}async generate({inputs:e=null,generation_config:r=null,logits_processor:s=null,stopping_criteria:n=null,streamer:o=null,...a}){this._validate_model_class(),r=this._prepare_generation_config(r,a);let{inputs_tensor:i,model_inputs:l,model_input_name:u}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),p=this.config.is_encoder_decoder;p&&("encoder_outputs"in l||(l=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:i,model_inputs:l,model_input_name:u,generation_config:r})));let f;p?{input_ids:f,model_inputs:l}=this._prepare_decoder_input_ids_for_generation({batch_size:l[u].dims.at(0),model_input_name:u,model_kwargs:l,decoder_start_token_id:r.decoder_start_token_id,bos_token_id:r.bos_token_id,generation_config:r}):f=l[u];let m=f.dims.at(-1);r.max_new_tokens!==null&&(r.max_length=m+r.max_new_tokens);let h=this._get_logits_processor(r,m,s),w=this._get_stopping_criteria(r,n),x=l[u].dims.at(0),v=Vs.getSampler(r),E=new Array(x).fill(0),A=f.tolist();o&&o.put(A);let S,T={},L={};for(;;){if(l=this.prepare_inputs_for_generation(A,l,r),S=await this.forward(l),r.return_dict_in_generate)if(r.output_attentions){let H=this.getAttentions(S);for(let Y in H)Y in T||(T[Y]=[]),T[Y].push(H[Y])}else this._return_dict_in_generate_keys&&Object.assign(L,ot(S,this._return_dict_in_generate_keys));let F=S.logits.slice(null,-1,null).to("float32"),K=h(A,F),W=[];for(let H=0;H<K.dims.at(0);++H){let Y=K[H],U=await v(Y);for(let[C,ne]of U){let ae=BigInt(C);E[H]+=ne,A[H].push(ae),W.push([ae]);break}}if(o&&o.put(W),w(A).every(H=>H))break;l=this._update_model_kwargs_for_generation({generated_input_ids:W,outputs:S,model_inputs:l,is_encoder_decoder:p})}o&&o.end();let P=this.getPastKeyValues(S,l.past_key_values,!0),k=new D("int64",A.flat(),[A.length,A[0].length]);if(r.return_dict_in_generate)return{sequences:k,past_key_values:P,...T,...L};for(let F of Object.values(S))F.location==="gpu-buffer"&&F.dispose();return k}getPastKeyValues(e,r,s=!1){let n=Object.create(null);for(let o in e)if(o.startsWith("present")){let a=o.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present_recurrent","past_recurrent").replace("present","past_key_values"),i=o.includes("encoder");if(i&&r?n[a]=r[a]:n[a]=e[o],r&&(!i||s)){let l=r[a];l.location==="gpu-buffer"&&l.dispose()}}return n}getAttentions(e){let r={};for(let s of["cross_attentions","encoder_attentions","decoder_attentions"])for(let n in e)n.startsWith(s)&&(s in r||(r[s]=[]),r[s].push(e[n]));return r}addPastKeyValues(e,r){if(r)Object.assign(e,r);else{let s=this.sessions.decoder_model_merged??this.sessions.model,n=(e[this.main_input_name]??e.attention_mask)?.dims?.[0]??1,o=s?.config?.kv_cache_dtype??"float32",a=o==="float16"?Ln.float16:Ln.float32,i=Ll(this.config,{batch_size:n});for(let l in i){let u=i[l].reduce((p,f)=>p*f,1);e[l]=new D(o,new a(u),i[l])}}}async encode_image({pixel_values:e}){return(await pe(this.sessions.vision_encoder,{pixel_values:e})).image_features}async encode_text({input_ids:e}){return(await pe(this.sessions.embed_tokens,{input_ids:e})).inputs_embeds}async encode_audio({audio_values:e}){return(await pe(this.sessions.audio_encoder,{audio_values:e})).audio_features}};async function Ef(t,e){let{encoder_outputs:r,input_ids:s,decoder_input_ids:n,...o}=e;if(!r){let a=ot(e,t.sessions.model.inputNames);r=(await Vt(t,a)).last_hidden_state}return o.input_ids=n,o.encoder_hidden_states=r,t.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(o.encoder_attention_mask=e.attention_mask),await It(t,o,!0)}async function Vt(t,e){let r=t.sessions.model,s=ot(e,r.inputNames);if(r.inputNames.includes("inputs_embeds")&&!s.inputs_embeds){if(!e.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");s.inputs_embeds=await t.encode_text({input_ids:e.input_ids})}if(r.inputNames.includes("token_type_ids")&&!s.token_type_ids){if(!s.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");s.token_type_ids=np(s.input_ids)}if(r.inputNames.includes("pixel_mask")&&!s.pixel_mask){if(!s.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let n=s.pixel_values.dims;s.pixel_mask=st([n[0],n[2],n[3]])}return await pe(r,s)}async function tN(t,e){let r=await t.encode(e);return await t.decode(r)}async function It(t,e,r=!1){let s=t.sessions[r?"decoder_model_merged":"model"],{past_key_values:n,...o}=e;if(s.inputNames.includes("use_cache_branch")&&(o.use_cache_branch=Vb(!!n)),s.inputNames.includes("position_ids")&&o.attention_mask&&!o.position_ids){let i=["paligemma","gemma3_text","gemma3"].includes(t.config.model_type)?1:0;o.position_ids=nN(o,n,i)}t.addPastKeyValues(o,n);let a=ot(o,s.inputNames);return await pe(s,a)}async function h2(t,{encode_function:e,merge_function:r,modality_input_name:s,modality_output_name:n,input_ids:o=null,attention_mask:a=null,position_ids:i=null,inputs_embeds:l=null,past_key_values:u=null,generation_config:p=null,logits_processor:f=null,...m}){let h=m[s];if(!l){if(l=await t.encode_text({input_ids:o,...m}),h&&o.dims[1]!==1){let x=await e({[s]:h,...m});({inputs_embeds:l,attention_mask:a}=r({[n]:x,inputs_embeds:l,input_ids:o,attention_mask:a}))}else if(u&&h&&o.dims[1]===1){let x=o.dims[1],v=Mf(u);a=Ee([st([o.dims[0],v]),a.slice(null,[a.dims[1]-x,a.dims[1]])],1)}}if(!i&&["qwen2_vl","qwen2_5_vl","qwen2_5_vl_text","qwen3_vl","qwen3_vl_text","qwen3_5","qwen3_5_text","qwen3_5_moe","qwen3_5_moe_text"].includes(t.config.model_type)){let{image_grid_thw:x,video_grid_thw:v}=m;[i]=t.get_rope_index(o,x,v,a)}return await It(t,{inputs_embeds:l,past_key_values:u,attention_mask:a,position_ids:i,generation_config:p,logits_processor:f},!0)}async function rN(t,e){return await h2(t,{...e,modality_input_name:"audio_values",modality_output_name:"audio_features",encode_function:t.encode_audio.bind(t),merge_function:t._merge_input_ids_with_audio_features.bind(t)})}async function sN(t,e){return await h2(t,{...e,modality_input_name:"pixel_values",modality_output_name:"image_features",encode_function:t.encode_image.bind(t),merge_function:t._merge_input_ids_with_image_features.bind(t)})}function Hb(t,e=0){let[r,s]=t.dims,n=t.data,o=new BigInt64Array(n.length);for(let a=0;a<r;++a){let i=a*s,l=BigInt(e);for(let u=0;u<s;++u){let p=i+u;n[p]===0n?o[p]=BigInt(1):(o[p]=l,l+=n[p])}}return{data:o,dims:t.dims}}function nN(t,e=null,r=0){let{input_ids:s,inputs_embeds:n,attention_mask:o}=t,{data:a,dims:i}=Hb(o,r),l=new D("int64",a,i);if(e){let u=-(s??n).dims.at(1);l=l.slice(null,[u,null])}return l}function Hl(t,e,r,s){let n=r.past_key_values?Mf(r.past_key_values):0;if(!r.attention_mask){let o;for(let a of["input_ids","inputs_embeds","position_ids"])if(r[a]){o=r[a].dims;break}if(!o)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");r.attention_mask=st([o[0],n+o[1]])}if(r.past_key_values){let{input_ids:o,attention_mask:a}=r;a&&a.dims[1]>o.dims[1]||n<o.dims[1]&&(r.input_ids=o.slice(null,[n,null]))}return r}function Xl(t,e,r,s){return r.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...r,decoder_input_ids:Wb(e)}}function Af(t,...e){return t.config.is_encoder_decoder?Xl(t,...e):Hl(t,...e)}function _2({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n}){let o=s.tolist().map(u=>u.reduce((p,f,m)=>(f==t&&p.push(m),p),[])),a=o.reduce((u,p)=>u+p.length,0),i=r.dims[0];if(a!==i)throw new Error(`Number of tokens and features do not match: tokens: ${a}, features ${i}`);let l=0;for(let u=0;u<o.length;++u){let p=o[u],f=e[u];for(let m=0;m<p.length;++m)f[p[m]].data.set(r[l++].data)}return{inputs_embeds:e,attention_mask:n}}function mr({image_token_id:t,inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return _2({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}function Sf({audio_token_id:t,inputs_embeds:e,audio_features:r,input_ids:s,attention_mask:n}){return _2({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}async function Tr(t,e,r){return Object.fromEntries(await Promise.all(Object.keys(e).map(async s=>{let n=await ut(t,e[s],!1,r);return[s,n]})))}var Hc={};Es(Hc,{ASTForAudioClassification:()=>Bf,ASTModel:()=>Uf,ASTPreTrainedModel:()=>to,AfmoeForCausalLM:()=>$f,AfmoeModel:()=>zf,AfmoePreTrainedModel:()=>Zn,AlbertForMaskedLM:()=>Pf,AlbertForQuestionAnswering:()=>Cf,AlbertForSequenceClassification:()=>If,AlbertModel:()=>Of,AlbertPreTrainedModel:()=>us,ApertusForCausalLM:()=>Nf,ApertusModel:()=>Lf,ApertusPreTrainedModel:()=>Jn,ArceeForCausalLM:()=>Df,ArceeModel:()=>Rf,ArceePreTrainedModel:()=>eo,BartForConditionalGeneration:()=>jf,BartForSequenceClassification:()=>Gf,BartModel:()=>Ff,BartPretrainedModel:()=>Ks,BeitForImageClassification:()=>Wf,BeitModel:()=>qf,BeitPreTrainedModel:()=>ro,BertForMaskedLM:()=>Hf,BertForQuestionAnswering:()=>Yf,BertForSequenceClassification:()=>Xf,BertForTokenClassification:()=>Kf,BertModel:()=>Vf,BertPreTrainedModel:()=>Sr,BlenderbotForConditionalGeneration:()=>Jf,BlenderbotModel:()=>Qf,BlenderbotPreTrainedModel:()=>so,BlenderbotSmallForConditionalGeneration:()=>em,BlenderbotSmallModel:()=>Zf,BlenderbotSmallPreTrainedModel:()=>no,BloomForCausalLM:()=>rm,BloomModel:()=>tm,BloomPreTrainedModel:()=>oo,CLIPModel:()=>um,CLIPPreTrainedModel:()=>nr,CLIPSegForImageSegmentation:()=>hm,CLIPSegModel:()=>mm,CLIPSegPreTrainedModel:()=>uo,CLIPTextModel:()=>pm,CLIPTextModelWithProjection:()=>co,CLIPVisionModel:()=>dm,CLIPVisionModelWithProjection:()=>fm,CamembertForMaskedLM:()=>nm,CamembertForQuestionAnswering:()=>im,CamembertForSequenceClassification:()=>om,CamembertForTokenClassification:()=>am,CamembertModel:()=>sm,CamembertPreTrainedModel:()=>Or,ChatterboxModel:()=>ao,ChatterboxPreTrainedModel:()=>Kl,ChineseCLIPModel:()=>lm,ChineseCLIPPreTrainedModel:()=>Yl,ClapAudioModelWithProjection:()=>lo,ClapModel:()=>cm,ClapPreTrainedModel:()=>Ys,ClapTextModelWithProjection:()=>io,CodeGenForCausalLM:()=>gm,CodeGenModel:()=>_m,CodeGenPreTrainedModel:()=>po,Cohere2ForCausalLM:()=>bm,Cohere2Model:()=>ym,Cohere2PreTrainedModel:()=>mo,CohereForCausalLM:()=>xm,CohereModel:()=>wm,CoherePreTrainedModel:()=>fo,ConvBertForMaskedLM:()=>km,ConvBertForQuestionAnswering:()=>Mm,ConvBertForSequenceClassification:()=>Em,ConvBertForTokenClassification:()=>Am,ConvBertModel:()=>vm,ConvBertPreTrainedModel:()=>Ir,ConvNextForImageClassification:()=>Sm,ConvNextModel:()=>Tm,ConvNextPreTrainedModel:()=>ho,ConvNextV2ForImageClassification:()=>Im,ConvNextV2Model:()=>Om,ConvNextV2PreTrainedModel:()=>_o,DFineForObjectDetection:()=>Nm,DFineModel:()=>Lm,DFinePreTrainedModel:()=>wo,DINOv3ConvNextModel:()=>nh,DINOv3ConvNextPreTrainedModel:()=>sc,DINOv3ViTModel:()=>oh,DINOv3ViTPreTrainedModel:()=>nc,DPTForDepthEstimation:()=>fh,DPTModel:()=>dh,DPTPreTrainedModel:()=>Eo,DacDecoderModel:()=>yo,DacDecoderOutput:()=>Jl,DacEncoderModel:()=>xo,DacEncoderOutput:()=>Ql,DacModel:()=>zm,DacPreTrainedModel:()=>Qs,DebertaForMaskedLM:()=>Rm,DebertaForQuestionAnswering:()=>Bm,DebertaForSequenceClassification:()=>Dm,DebertaForTokenClassification:()=>Um,DebertaModel:()=>$m,DebertaPreTrainedModel:()=>Cr,DebertaV2ForMaskedLM:()=>jm,DebertaV2ForQuestionAnswering:()=>Wm,DebertaV2ForSequenceClassification:()=>Gm,DebertaV2ForTokenClassification:()=>qm,DebertaV2Model:()=>Fm,DebertaV2PreTrainedModel:()=>Pr,DecisionTransformerModel:()=>Vm,DecisionTransformerPreTrainedModel:()=>Zl,DeiTForImageClassification:()=>Xm,DeiTModel:()=>Hm,DeiTPreTrainedModel:()=>bo,DepthAnythingForDepthEstimation:()=>Km,DepthAnythingPreTrainedModel:()=>ec,DepthProForDepthEstimation:()=>Ym,DepthProPreTrainedModel:()=>tc,DetrForObjectDetection:()=>Jm,DetrForSegmentation:()=>Zm,DetrModel:()=>Qm,DetrObjectDetectionOutput:()=>Zs,DetrPreTrainedModel:()=>Js,DetrSegmentationOutput:()=>rc,Dinov2ForImageClassification:()=>th,Dinov2Model:()=>eh,Dinov2PreTrainedModel:()=>vo,Dinov2WithRegistersForImageClassification:()=>sh,Dinov2WithRegistersModel:()=>rh,Dinov2WithRegistersPreTrainedModel:()=>ko,DistilBertForMaskedLM:()=>uh,DistilBertForQuestionAnswering:()=>ch,DistilBertForSequenceClassification:()=>ih,DistilBertForTokenClassification:()=>lh,DistilBertModel:()=>ah,DistilBertPreTrainedModel:()=>Lr,DonutSwinModel:()=>ph,DonutSwinPreTrainedModel:()=>oc,EdgeTamModel:()=>ox,EfficientNetForImageClassification:()=>hh,EfficientNetModel:()=>mh,EfficientNetPreTrainedModel:()=>Ao,ElectraForMaskedLM:()=>gh,ElectraForQuestionAnswering:()=>yh,ElectraForSequenceClassification:()=>wh,ElectraForTokenClassification:()=>xh,ElectraModel:()=>_h,ElectraPreTrainedModel:()=>Nr,Ernie4_5ForCausalLM:()=>vh,Ernie4_5Model:()=>bh,Ernie4_5PretrainedModel:()=>Mo,EsmForMaskedLM:()=>Eh,EsmForSequenceClassification:()=>Ah,EsmForTokenClassification:()=>Mh,EsmModel:()=>kh,EsmPreTrainedModel:()=>ps,ExaoneForCausalLM:()=>Sh,ExaoneModel:()=>Th,ExaonePreTrainedModel:()=>To,FalconForCausalLM:()=>Ih,FalconH1ForCausalLM:()=>Ph,FalconH1Model:()=>Ch,FalconH1PreTrainedModel:()=>Oo,FalconModel:()=>Oh,FalconPreTrainedModel:()=>So,FastViTForImageClassification:()=>Nh,FastViTModel:()=>Lh,FastViTPreTrainedModel:()=>Io,Florence2ForConditionalGeneration:()=>zh,Florence2PreTrainedModel:()=>ac,GLPNForDepthEstimation:()=>Wh,GLPNModel:()=>qh,GLPNPreTrainedModel:()=>$o,GPT2LMHeadModel:()=>t_,GPT2Model:()=>e_,GPT2PreTrainedModel:()=>Fo,GPTBigCodeForCausalLM:()=>Hh,GPTBigCodeModel:()=>Vh,GPTBigCodePreTrainedModel:()=>Ro,GPTJForCausalLM:()=>s_,GPTJModel:()=>r_,GPTJPreTrainedModel:()=>jo,GPTNeoForCausalLM:()=>Kh,GPTNeoModel:()=>Xh,GPTNeoPreTrainedModel:()=>Do,GPTNeoXForCausalLM:()=>Qh,GPTNeoXModel:()=>Yh,GPTNeoXPreTrainedModel:()=>Uo,Gemma2ForCausalLM:()=>Uh,Gemma2Model:()=>Dh,Gemma2PreTrainedModel:()=>Po,Gemma3ForCausalLM:()=>Fh,Gemma3Model:()=>Bh,Gemma3PreTrainedModel:()=>Lo,Gemma3nForConditionalGeneration:()=>No,Gemma3nPreTrainedModel:()=>ic,GemmaForCausalLM:()=>Rh,GemmaModel:()=>$h,GemmaPreTrainedModel:()=>Co,GlmForCausalLM:()=>Gh,GlmModel:()=>jh,GlmPreTrainedModel:()=>zo,GptOssForCausalLM:()=>Zh,GptOssModel:()=>Jh,GptOssPreTrainedModel:()=>Bo,GraniteForCausalLM:()=>o_,GraniteModel:()=>n_,GraniteMoeHybridForCausalLM:()=>i_,GraniteMoeHybridModel:()=>a_,GraniteMoeHybridPreTrainedModel:()=>qo,GranitePreTrainedModel:()=>Go,GroundingDinoForObjectDetection:()=>l_,GroundingDinoPreTrainedModel:()=>lc,GroupViTModel:()=>c_,GroupViTPreTrainedModel:()=>cc,HeliumForCausalLM:()=>p_,HeliumModel:()=>u_,HeliumPreTrainedModel:()=>Wo,HieraForImageClassification:()=>f_,HieraModel:()=>d_,HieraPreTrainedModel:()=>Vo,HubertForCTC:()=>y_,HubertForSequenceClassification:()=>b_,HubertModel:()=>x_,HubertPreTrainedModel:()=>w_,HunYuanDenseV1ForCausalLM:()=>k_,HunYuanDenseV1Model:()=>v_,HunYuanDenseV1PreTrainedModel:()=>Ho,IJepaForImageClassification:()=>M_,IJepaModel:()=>A_,IJepaPreTrainedModel:()=>Xo,Idefics3ForConditionalGeneration:()=>pc,Idefics3PreTrainedModel:()=>uc,JAISLMHeadModel:()=>S_,JAISModel:()=>T_,JAISPreTrainedModel:()=>Ko,JinaCLIPModel:()=>O_,JinaCLIPPreTrainedModel:()=>en,JinaCLIPTextModel:()=>Yo,JinaCLIPVisionModel:()=>I_,Lfm2ForCausalLM:()=>P_,Lfm2Model:()=>C_,Lfm2MoeForCausalLM:()=>N_,Lfm2MoeModel:()=>L_,Lfm2MoePreTrainedModel:()=>Jo,Lfm2PreTrainedModel:()=>Qo,LiteWhisperForConditionalGeneration:()=>gy,Llama4ForCausalLM:()=>R_,Llama4PreTrainedModel:()=>dc,LlamaForCausalLM:()=>$_,LlamaModel:()=>z_,LlamaPreTrainedModel:()=>Zo,LlavaForConditionalGeneration:()=>tn,LlavaOnevisionForConditionalGeneration:()=>tn,LlavaPreTrainedModel:()=>fc,LlavaQwen2ForCausalLM:()=>U_,LongT5ForConditionalGeneration:()=>F_,LongT5Model:()=>B_,LongT5PreTrainedModel:()=>ea,M2M100ForConditionalGeneration:()=>G_,M2M100Model:()=>j_,M2M100PreTrainedModel:()=>ta,MBartForCausalLM:()=>Q_,MBartForConditionalGeneration:()=>K_,MBartForSequenceClassification:()=>Y_,MBartModel:()=>X_,MBartPreTrainedModel:()=>ds,MPNetForMaskedLM:()=>zg,MPNetForQuestionAnswering:()=>Dg,MPNetForSequenceClassification:()=>$g,MPNetForTokenClassification:()=>Rg,MPNetModel:()=>Ng,MPNetPreTrainedModel:()=>zr,MT5ForConditionalGeneration:()=>jg,MT5Model:()=>Fg,MT5PreTrainedModel:()=>fa,MarianMTModel:()=>W_,MarianModel:()=>q_,MarianPreTrainedModel:()=>ra,MaskFormerForInstanceSegmentation:()=>H_,MaskFormerModel:()=>V_,MaskFormerPreTrainedModel:()=>sa,Metric3DForDepthEstimation:()=>J_,Metric3DPreTrainedModel:()=>mc,Metric3Dv2ForDepthEstimation:()=>Z_,Metric3Dv2PreTrainedModel:()=>hc,MgpstrForSceneTextRecognition:()=>eg,MgpstrModelOutput:()=>_c,MgpstrPreTrainedModel:()=>gc,MimiDecoderModel:()=>oa,MimiDecoderOutput:()=>xc,MimiEncoderModel:()=>na,MimiEncoderOutput:()=>wc,MimiModel:()=>tg,MimiPreTrainedModel:()=>rn,MistralForCausalLM:()=>sg,MistralModel:()=>rg,MistralPreTrainedModel:()=>aa,MobileBertForMaskedLM:()=>og,MobileBertForQuestionAnswering:()=>ig,MobileBertForSequenceClassification:()=>ag,MobileBertModel:()=>ng,MobileBertPreTrainedModel:()=>fs,MobileLLMForCausalLM:()=>cg,MobileLLMModel:()=>lg,MobileLLMPreTrainedModel:()=>ia,MobileNetV1ForImageClassification:()=>pg,MobileNetV1ForSemanticSegmentation:()=>dg,MobileNetV1Model:()=>ug,MobileNetV1PreTrainedModel:()=>sn,MobileNetV2ForImageClassification:()=>mg,MobileNetV2ForSemanticSegmentation:()=>hg,MobileNetV2Model:()=>fg,MobileNetV2PreTrainedModel:()=>nn,MobileNetV3ForImageClassification:()=>gg,MobileNetV3ForSemanticSegmentation:()=>wg,MobileNetV3Model:()=>_g,MobileNetV3PreTrainedModel:()=>on,MobileNetV4ForImageClassification:()=>yg,MobileNetV4ForSemanticSegmentation:()=>bg,MobileNetV4Model:()=>xg,MobileNetV4PreTrainedModel:()=>an,MobileViTForImageClassification:()=>kg,MobileViTModel:()=>vg,MobileViTPreTrainedModel:()=>la,MobileViTV2ForImageClassification:()=>Ag,MobileViTV2Model:()=>Eg,MobileViTV2PreTrainedModel:()=>ca,ModernBertDecoderForCausalLM:()=>Cg,ModernBertDecoderModel:()=>Ig,ModernBertDecoderPreTrainedModel:()=>ua,ModernBertForMaskedLM:()=>Tg,ModernBertForSequenceClassification:()=>Sg,ModernBertForTokenClassification:()=>Og,ModernBertModel:()=>Mg,ModernBertPreTrainedModel:()=>ms,Moondream1ForConditionalGeneration:()=>D_,MoonshineForConditionalGeneration:()=>Lg,MoonshineModel:()=>Pg,MoonshinePreTrainedModel:()=>pa,MptForCausalLM:()=>Bg,MptModel:()=>Ug,MptPreTrainedModel:()=>da,MultiModalityCausalLM:()=>Gg,MultiModalityPreTrainedModel:()=>yc,MusicgenForCausalLM:()=>Wg,MusicgenForConditionalGeneration:()=>ha,MusicgenModel:()=>qg,MusicgenPreTrainedModel:()=>ma,NanoChatForCausalLM:()=>Hg,NanoChatModel:()=>Vg,NanoChatPreTrainedModel:()=>_a,NeoBertForMaskedLM:()=>Kg,NeoBertForQuestionAnswering:()=>Jg,NeoBertForSequenceClassification:()=>Yg,NeoBertForTokenClassification:()=>Qg,NeoBertModel:()=>Xg,NeoBertPreTrainedModel:()=>$r,NomicBertModel:()=>Zg,NomicBertPreTrainedModel:()=>bc,OPTForCausalLM:()=>pw,OPTModel:()=>uw,OPTPreTrainedModel:()=>va,Olmo2ForCausalLM:()=>sw,Olmo2Model:()=>rw,Olmo2PreTrainedModel:()=>wa,Olmo3ForCausalLM:()=>ow,Olmo3Model:()=>nw,Olmo3PreTrainedModel:()=>xa,OlmoForCausalLM:()=>tw,OlmoHybridForCausalLM:()=>iw,OlmoHybridModel:()=>aw,OlmoHybridPreTrainedModel:()=>ya,OlmoModel:()=>ew,OlmoPreTrainedModel:()=>ga,OpenELMForCausalLM:()=>cw,OpenELMModel:()=>lw,OpenELMPreTrainedModel:()=>ba,OwlViTForObjectDetection:()=>hw,OwlViTModel:()=>mw,OwlViTPreTrainedModel:()=>Ea,Owlv2ForObjectDetection:()=>fw,Owlv2Model:()=>dw,Owlv2PreTrainedModel:()=>ka,PaliGemmaForConditionalGeneration:()=>_w,PaliGemmaPreTrainedModel:()=>vc,ParakeetForCTC:()=>gw,ParakeetPreTrainedModel:()=>kc,PatchTSMixerForPrediction:()=>xw,PatchTSMixerModel:()=>ww,PatchTSMixerPreTrainedModel:()=>Aa,PatchTSTForPrediction:()=>bw,PatchTSTModel:()=>yw,PatchTSTPreTrainedModel:()=>Ma,Phi3ForCausalLM:()=>Aw,Phi3Model:()=>Ew,Phi3PreTrainedModel:()=>Sa,Phi3VForCausalLM:()=>Oa,Phi3VPreTrainedModel:()=>Ec,PhiForCausalLM:()=>kw,PhiModel:()=>vw,PhiPreTrainedModel:()=>Ta,PreTrainedModel:()=>y,PvtForImageClassification:()=>Tw,PvtModel:()=>Mw,PvtPreTrainedModel:()=>Ia,PyAnnoteForAudioFrameClassification:()=>Ow,PyAnnoteModel:()=>Sw,PyAnnotePreTrainedModel:()=>Ca,Qwen2ForCausalLM:()=>Cw,Qwen2Model:()=>Iw,Qwen2MoeForCausalLM:()=>Lw,Qwen2MoeModel:()=>Pw,Qwen2MoePreTrainedModel:()=>La,Qwen2PreTrainedModel:()=>Pa,Qwen2VLForConditionalGeneration:()=>Na,Qwen2VLPreTrainedModel:()=>Ac,Qwen2_5_VLForConditionalGeneration:()=>za,Qwen3ForCausalLM:()=>zw,Qwen3Model:()=>Nw,Qwen3MoeForCausalLM:()=>Rw,Qwen3MoeModel:()=>$w,Qwen3MoePreTrainedModel:()=>Ra,Qwen3NextForCausalLM:()=>Uw,Qwen3NextModel:()=>Dw,Qwen3NextPreTrainedModel:()=>Da,Qwen3PreTrainedModel:()=>$a,Qwen3VLForConditionalGeneration:()=>hs,Qwen3VLMoeForConditionalGeneration:()=>Bw,Qwen3_5ForConditionalGeneration:()=>Ua,Qwen3_5MoeForConditionalGeneration:()=>Fw,RFDetrForObjectDetection:()=>Ww,RFDetrModel:()=>qw,RFDetrObjectDetectionOutput:()=>Mc,RFDetrPreTrainedModel:()=>Fa,RTDetrForObjectDetection:()=>Pm,RTDetrModel:()=>Cm,RTDetrObjectDetectionOutput:()=>or,RTDetrPreTrainedModel:()=>go,RTDetrV2ForObjectDetection:()=>sx,RTDetrV2Model:()=>rx,RTDetrV2ObjectDetectionOutput:()=>Tc,RTDetrV2PreTrainedModel:()=>ja,ResNetForImageClassification:()=>Gw,ResNetModel:()=>jw,ResNetPreTrainedModel:()=>Ba,RoFormerForMaskedLM:()=>Jw,RoFormerForQuestionAnswering:()=>tx,RoFormerForSequenceClassification:()=>Zw,RoFormerForTokenClassification:()=>ex,RoFormerModel:()=>Qw,RoFormerPreTrainedModel:()=>Dr,RobertaForMaskedLM:()=>Hw,RobertaForQuestionAnswering:()=>Yw,RobertaForSequenceClassification:()=>Xw,RobertaForTokenClassification:()=>Kw,RobertaModel:()=>Vw,RobertaPreTrainedModel:()=>Rr,Sam2ImageSegmentationOutput:()=>Ic,Sam2Model:()=>Ga,Sam2PreTrainedModel:()=>Cc,Sam3TrackerModel:()=>ax,SamImageSegmentationOutput:()=>Sc,SamModel:()=>nx,SamPreTrainedModel:()=>Oc,SapiensForDepthEstimation:()=>lx,SapiensForNormalEstimation:()=>cx,SapiensForSemanticSegmentation:()=>ix,SapiensPreTrainedModel:()=>ln,SegformerForImageClassification:()=>px,SegformerForSemanticSegmentation:()=>dx,SegformerModel:()=>ux,SegformerPreTrainedModel:()=>cn,SiglipModel:()=>fx,SiglipPreTrainedModel:()=>qa,SiglipTextModel:()=>Wa,SiglipVisionModel:()=>mx,SmolLM3ForCausalLM:()=>_x,SmolLM3Model:()=>hx,SmolLM3PreTrainedModel:()=>Va,SmolVLMForConditionalGeneration:()=>E_,SnacDecoderModel:()=>Xa,SnacEncoderModel:()=>Ha,SnacModel:()=>gx,SnacPreTrainedModel:()=>un,SpeechT5ForSpeechToText:()=>xx,SpeechT5ForTextToSpeech:()=>yx,SpeechT5HifiGan:()=>bx,SpeechT5Model:()=>wx,SpeechT5PreTrainedModel:()=>pn,SqueezeBertForMaskedLM:()=>kx,SqueezeBertForQuestionAnswering:()=>Ax,SqueezeBertForSequenceClassification:()=>Ex,SqueezeBertModel:()=>vx,SqueezeBertPreTrainedModel:()=>_s,StableLmForCausalLM:()=>Tx,StableLmModel:()=>Mx,StableLmPreTrainedModel:()=>Ka,Starcoder2ForCausalLM:()=>Ox,Starcoder2Model:()=>Sx,Starcoder2PreTrainedModel:()=>Ya,StyleTextToSpeech2Model:()=>Ix,StyleTextToSpeech2PreTrainedModel:()=>Pc,SupertonicForConditionalGeneration:()=>Qa,SupertonicPreTrainedModel:()=>Lc,Swin2SRForImageSuperResolution:()=>zx,Swin2SRModel:()=>Nx,Swin2SRPreTrainedModel:()=>Ja,SwinForImageClassification:()=>Px,SwinForSemanticSegmentation:()=>Lx,SwinModel:()=>Cx,SwinPreTrainedModel:()=>dn,T5ForConditionalGeneration:()=>Rx,T5Model:()=>$x,T5PreTrainedModel:()=>Za,TableTransformerForObjectDetection:()=>Ux,TableTransformerModel:()=>Dx,TableTransformerObjectDetectionOutput:()=>Nc,TableTransformerPreTrainedModel:()=>ei,TrOCRForCausalLM:()=>Bx,TrOCRPreTrainedModel:()=>zc,UltravoxModel:()=>Rc,UltravoxPreTrainedModel:()=>$c,UniSpeechForCTC:()=>Gx,UniSpeechForSequenceClassification:()=>qx,UniSpeechModel:()=>jx,UniSpeechPreTrainedModel:()=>fn,UniSpeechSatForAudioFrameClassification:()=>Xx,UniSpeechSatForCTC:()=>Vx,UniSpeechSatForSequenceClassification:()=>Hx,UniSpeechSatModel:()=>Wx,UniSpeechSatPreTrainedModel:()=>gs,VaultGemmaForCausalLM:()=>Yx,VaultGemmaModel:()=>Kx,VaultGemmaPreTrainedModel:()=>ti,ViTForImageClassification:()=>Zx,ViTMAEModel:()=>ey,ViTMAEPreTrainedModel:()=>Dc,ViTMSNForImageClassification:()=>ry,ViTMSNModel:()=>ty,ViTMSNPreTrainedModel:()=>si,ViTModel:()=>Jx,ViTPreTrainedModel:()=>ri,VisionEncoderDecoderModel:()=>Qx,VitMatteForImageMatting:()=>sy,VitMattePreTrainedModel:()=>Uc,VitPoseForPoseEstimation:()=>ny,VitPosePreTrainedModel:()=>Bc,VitsModel:()=>oy,VitsModelOutput:()=>Fc,VitsPreTrainedModel:()=>jc,VoxtralForConditionalGeneration:()=>Fx,Wav2Vec2BertForCTC:()=>iy,Wav2Vec2BertForSequenceClassification:()=>ly,Wav2Vec2BertModel:()=>ay,Wav2Vec2BertPreTrainedModel:()=>mn,Wav2Vec2ForAudioFrameClassification:()=>g_,Wav2Vec2ForCTC:()=>h_,Wav2Vec2ForSequenceClassification:()=>__,Wav2Vec2Model:()=>m_,Wav2Vec2PreTrainedModel:()=>Ht,WavLMForAudioFrameClassification:()=>fy,WavLMForCTC:()=>uy,WavLMForSequenceClassification:()=>py,WavLMForXVector:()=>dy,WavLMModel:()=>cy,WavLMPreTrainedModel:()=>Ur,WeSpeakerResNetModel:()=>my,WeSpeakerResNetPreTrainedModel:()=>qc,WhisperForConditionalGeneration:()=>Wc,WhisperModel:()=>_y,WhisperPreTrainedModel:()=>ni,XLMForQuestionAnswering:()=>vy,XLMForSequenceClassification:()=>yy,XLMForTokenClassification:()=>by,XLMModel:()=>wy,XLMPreTrainedModel:()=>Br,XLMRobertaForMaskedLM:()=>Ey,XLMRobertaForQuestionAnswering:()=>Ty,XLMRobertaForSequenceClassification:()=>Ay,XLMRobertaForTokenClassification:()=>My,XLMRobertaModel:()=>ky,XLMRobertaPreTrainedModel:()=>Fr,XLMWithLMHeadModel:()=>xy,XVectorOutput:()=>Gc,YolosForObjectDetection:()=>Oy,YolosModel:()=>Sy,YolosObjectDetectionOutput:()=>Vc,YolosPreTrainedModel:()=>oi,YoutuForCausalLM:()=>Cy,YoutuModel:()=>Iy,YoutuPreTrainedModel:()=>ai});var us=class extends y{},Of=class extends us{},If=class extends us{async _call(e){return new G(await super._call(e))}},Cf=class extends us{async _call(e){return new Ae(await super._call(e))}},Pf=class extends us{async _call(e){return new we(await super._call(e))}};var Jn=class extends y{},Lf=class extends Jn{},Nf=class extends Jn{};var Zn=class extends y{},zf=class extends Zn{},$f=class extends Zn{};var eo=class extends y{},Rf=class extends eo{},Df=class extends eo{};var to=class extends y{},Uf=class extends to{},Bf=class extends to{};var Ks=class extends y{},Ff=class extends Ks{},jf=class extends Ks{},Gf=class extends Ks{async _call(e){return new G(await super._call(e))}};var ro=class extends y{},qf=class extends ro{},Wf=class extends ro{async _call(e){return new G(await super._call(e))}};var Sr=class extends y{},Vf=class extends Sr{},Hf=class extends Sr{async _call(e){return new we(await super._call(e))}},Xf=class extends Sr{async _call(e){return new G(await super._call(e))}},Kf=class extends Sr{async _call(e){return new _e(await super._call(e))}},Yf=class extends Sr{async _call(e){return new Ae(await super._call(e))}};var so=class extends y{},Qf=class extends so{},Jf=class extends so{};var no=class extends y{},Zf=class extends no{},em=class extends no{};var oo=class extends y{},tm=class extends oo{},rm=class extends oo{};var Or=class extends y{},sm=class extends Or{},nm=class extends Or{async _call(e){return new we(await super._call(e))}},om=class extends Or{async _call(e){return new G(await super._call(e))}},am=class extends Or{async _call(e){return new _e(await super._call(e))}},im=class extends Or{async _call(e){return new Ae(await super._call(e))}};var oN=4299n,g2=6561n,Kl=class extends y{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"]},ao=class extends Kl{async encode_speech(e){return pe(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:r=null,audio_values:s=null,exaggeration:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:u=null,audio_features:p=null,audio_tokens:f=null,speaker_embeddings:m=null,speaker_features:h=null,...w}){let x;if(!a){let E=this.sessions.embed_tokens.inputNames,A={input_ids:e};if(E.includes("exaggeration")){if(!(n instanceof D)){let S=e.dims[0];if(n==null)n=qe([S],.5);else if(typeof n=="number")n=qe([S],n);else if(Array.isArray(n))n=new D("float32",n,[S]);else throw new Error("Unsupported type for `exaggeration` input")}A.exaggeration=n}if(E.includes("position_ids")&&(A.position_ids=o),{inputs_embeds:a}=await pe(this.sessions.embed_tokens,A),p&&f&&m&&h&&(x={audio_features:p,audio_tokens:f,speaker_embeddings:m,speaker_features:h}),x||s)x??=await this.encode_speech(s),a=Ee([x.audio_features,a],1),r=st([a.dims[0],a.dims[1]]);else{let S=a.dims[1];if(!i||S!==1)throw new Error("Incorrect state encountered during generation.");let T=Object.values(i)[0].dims.at(-2);r=st([a.dims[0],T+S])}}return{...await It(this,{inputs_embeds:a,past_key_values:i,attention_mask:r,generation_config:l,logits_processor:u},!1),...x}}prepare_inputs_for_generation(e,r,s){if(!r.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(r.input_ids.dims[1]===1){let n=Array.from({length:e.length},(o,a)=>e[a].length-e[a].findLastIndex(i=>i==g2)-1);r.position_ids=new D("int64",n,[e.length,1])}else{let o=r.input_ids.tolist().map(a=>{let i=0;return a.map(l=>l>=g2?0:i++)});r.position_ids=new D("int64",o.flat(),r.input_ids.dims)}return r.input_ids.dims[1]===1&&(delete r.audio_values,delete r.audio_features,delete r.audio_tokens,delete r.speaker_embeddings,delete r.speaker_features),Hl(this,e,r,s)}async generate(e){let{sequences:r,audio_tokens:s,speaker_embeddings:n,speaker_features:o}=await super.generate({...e,return_dict_in_generate:!0}),a=r.slice(null,[e.input_ids.dims[1],-1]),i=qe([a.dims[0],3],oN),l=Ee([s,a,i],1),{waveform:u}=await pe(this.sessions.conditional_decoder,{speech_tokens:l,speaker_features:o,speaker_embeddings:n});return u}};var Yl=class extends y{},lm=class extends Yl{};var Ys=class extends y{},cm=class extends Ys{},io=class extends Ys{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},lo=class extends Ys{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"audio_model"})}};var nr=class extends y{},um=class extends nr{},pm=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},co=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},dm=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}},fm=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var uo=class extends y{},mm=class extends uo{},hm=class extends uo{};var po=class extends y{},_m=class extends po{},gm=class extends po{};var fo=class extends y{},wm=class extends fo{},xm=class extends fo{};var mo=class extends y{},ym=class extends mo{},bm=class extends mo{};var Ir=class extends y{},vm=class extends Ir{},km=class extends Ir{async _call(e){return new we(await super._call(e))}},Em=class extends Ir{async _call(e){return new G(await super._call(e))}},Am=class extends Ir{async _call(e){return new _e(await super._call(e))}},Mm=class extends Ir{async _call(e){return new Ae(await super._call(e))}};var ho=class extends y{},Tm=class extends ho{},Sm=class extends ho{async _call(e){return new G(await super._call(e))}};var _o=class extends y{},Om=class extends _o{},Im=class extends _o{async _call(e){return new G(await super._call(e))}};var go=class extends y{},Cm=class extends go{},Pm=class extends go{async _call(e){return new or(await super._call(e))}},or=class extends Re{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var wo=class extends y{},Lm=class extends wo{},Nm=class extends wo{async _call(e){return new or(await super._call(e))}};var Ql=class extends Re{constructor({audio_codes:e}){super(),this.audio_codes=e}},Jl=class extends Re{constructor({audio_values:e}){super(),this.audio_values=e}},Qs=class extends y{main_input_name="input_values";forward_params=["input_values"]},zm=class extends Qs{async encode(e){return new Ql(await pe(this.sessions.encoder_model,e))}async decode(e){return new Jl(await pe(this.sessions.decoder_model,e))}},xo=class extends Qs{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},yo=class extends Qs{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var Cr=class extends y{},$m=class extends Cr{},Rm=class extends Cr{async _call(e){return new we(await super._call(e))}},Dm=class extends Cr{async _call(e){return new G(await super._call(e))}},Um=class extends Cr{async _call(e){return new _e(await super._call(e))}},Bm=class extends Cr{async _call(e){return new Ae(await super._call(e))}};var Pr=class extends y{},Fm=class extends Pr{},jm=class extends Pr{async _call(e){return new we(await super._call(e))}},Gm=class extends Pr{async _call(e){return new G(await super._call(e))}},qm=class extends Pr{async _call(e){return new _e(await super._call(e))}},Wm=class extends Pr{async _call(e){return new Ae(await super._call(e))}};var Zl=class extends y{},Vm=class extends Zl{};var bo=class extends y{},Hm=class extends bo{},Xm=class extends bo{async _call(e){return new G(await super._call(e))}};var ec=class extends y{},Km=class extends ec{};var tc=class extends y{},Ym=class extends tc{};var Js=class extends y{},Qm=class extends Js{},Jm=class extends Js{async _call(e){return new Zs(await super._call(e))}},Zm=class extends Js{async _call(e){return new rc(await super._call(e))}},Zs=class extends Re{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}},rc=class extends Re{constructor({logits:e,pred_boxes:r,pred_masks:s}){super(),this.logits=e,this.pred_boxes=r,this.pred_masks=s}};var vo=class extends y{},eh=class extends vo{},th=class extends vo{async _call(e){return new G(await super._call(e))}};var ko=class extends y{},rh=class extends ko{},sh=class extends ko{async _call(e){return new G(await super._call(e))}};var sc=class extends y{},nh=class extends sc{};var nc=class extends y{},oh=class extends nc{};var Lr=class extends y{},ah=class extends Lr{},ih=class extends Lr{async _call(e){return new G(await super._call(e))}},lh=class extends Lr{async _call(e){return new _e(await super._call(e))}},ch=class extends Lr{async _call(e){return new Ae(await super._call(e))}},uh=class extends Lr{async _call(e){return new we(await super._call(e))}};var oc=class extends y{},ph=class extends oc{};var Eo=class extends y{},dh=class extends Eo{},fh=class extends Eo{};var Ao=class extends y{},mh=class extends Ao{},hh=class extends Ao{async _call(e){return new G(await super._call(e))}};var Nr=class extends y{},_h=class extends Nr{},gh=class extends Nr{async _call(e){return new we(await super._call(e))}},wh=class extends Nr{async _call(e){return new G(await super._call(e))}},xh=class extends Nr{async _call(e){return new _e(await super._call(e))}},yh=class extends Nr{async _call(e){return new Ae(await super._call(e))}};var Mo=class extends y{},bh=class extends Mo{},vh=class extends Mo{};var ps=class extends y{},kh=class extends ps{},Eh=class extends ps{async _call(e){return new we(await super._call(e))}},Ah=class extends ps{async _call(e){return new G(await super._call(e))}},Mh=class extends ps{async _call(e){return new _e(await super._call(e))}};var To=class extends y{},Th=class extends To{},Sh=class extends To{};var So=class extends y{},Oh=class extends So{},Ih=class extends So{};var Oo=class extends y{},Ch=class extends Oo{},Ph=class extends Oo{};var Io=class extends y{},Lh=class extends Io{},Nh=class extends Io{async _call(e){return new G(await super._call(e))}};var ac=class extends y{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"},zh=class extends ac{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return{inputs_embeds:Ee([r,e],1),attention_mask:Ee([st(r.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:r,inputs_embeds:s,attention_mask:n}){if(!e&&!r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let o,a;return e&&(o=await this.encode_text({input_ids:e})),r&&(a=await this.encode_image({pixel_values:r})),o&&a?{inputs_embeds:s,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:o,image_features:a,input_ids:e,attention_mask:n}):s=o||a,{inputs_embeds:s,attention_mask:n}}async forward({input_ids:e,pixel_values:r,attention_mask:s,decoder_input_ids:n,decoder_attention_mask:o,encoder_outputs:a,past_key_values:i,inputs_embeds:l,decoder_inputs_embeds:u}){if(l||({inputs_embeds:l,attention_mask:s}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:r,inputs_embeds:l,attention_mask:s})),!a){let{last_hidden_state:f}=await Vt(this,{inputs_embeds:l,attention_mask:s});a=f}if(!u){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");u=await this.encode_text({input_ids:n})}return await It(this,{inputs_embeds:u,attention_mask:o,encoder_attention_mask:s,encoder_hidden_states:a,past_key_values:i},!0)}};var Co=class extends y{},$h=class extends Co{},Rh=class extends Co{};var Po=class extends y{},Dh=class extends Po{},Uh=class extends Po{};var Lo=class extends y{},Bh=class extends Lo{},Fh=class extends Lo{};var ic=class extends y{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},No=class extends ic{async forward({input_ids:e=null,attention_mask:r=null,pixel_values:s=null,input_features:n=null,input_features_mask:o=null,position_ids:a=null,inputs_embeds:i=null,per_layer_inputs:l=null,past_key_values:u=null,generation_config:p=null,logits_processor:f=null,...m}){if((!i||!l)&&({inputs_embeds:i,per_layer_inputs:l}=await pe(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(s){let{image_features:w}=await pe(this.sessions.vision_encoder,{pixel_values:s});({inputs_embeds:i,attention_mask:r}=this._merge_input_ids_with_image_features({image_features:w,inputs_embeds:i,input_ids:e,attention_mask:r}))}if(n){let{audio_features:w}=await pe(this.sessions.audio_encoder,{input_features:n,input_features_mask:o});({inputs_embeds:i,attention_mask:r}=this._merge_input_ids_with_audio_features({audio_features:w,inputs_embeds:i,input_ids:e,attention_mask:r}))}}return await It(this,{inputs_embeds:i,per_layer_inputs:l,past_key_values:u,attention_mask:r,position_ids:a,generation_config:p,logits_processor:f},!0)}_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return mr({image_token_id:this.config.image_token_id,...e,image_features:s})}_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return Sf({audio_token_id:this.config.audio_token_id,...e,audio_features:s})}};var zo=class extends y{},jh=class extends zo{},Gh=class extends zo{};var $o=class extends y{},qh=class extends $o{},Wh=class extends $o{};var Ro=class extends y{},Vh=class extends Ro{},Hh=class extends Ro{};var Do=class extends y{},Xh=class extends Do{},Kh=class extends Do{};var Uo=class extends y{},Yh=class extends Uo{},Qh=class extends Uo{};var Bo=class extends y{},Jh=class extends Bo{},Zh=class extends Bo{};var Fo=class extends y{},e_=class extends Fo{},t_=class extends Fo{};var jo=class extends y{},r_=class extends jo{},s_=class extends jo{};var Go=class extends y{},n_=class extends Go{},o_=class extends Go{};var qo=class extends y{},a_=class extends qo{},i_=class extends qo{};var lc=class extends y{},l_=class extends lc{};var cc=class extends y{},c_=class extends cc{};var Wo=class extends y{},u_=class extends Wo{},p_=class extends Wo{};var Vo=class extends y{},d_=class extends Vo{},f_=class extends Vo{async _call(e){return new G(await super._call(e))}};var Ht=class extends y{},m_=class extends Ht{},h_=class extends Ht{async _call(e){return new wt(await super._call(e))}},__=class extends Ht{async _call(e){return new G(await super._call(e))}},g_=class extends Ht{async _call(e){return new _e(await super._call(e))}};var w_=class extends y{},x_=class extends Ht{},y_=class extends Ht{async _call(e){return new wt(await super._call(e))}},b_=class extends Ht{async _call(e){return new G(await super._call(e))}};var Ho=class extends y{},v_=class extends Ho{},k_=class extends Ho{};var uc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]},pc=class extends uc{async encode_image({pixel_values:e,pixel_attention_mask:r}){return(await pe(this.sessions.vision_encoder,{pixel_values:e,pixel_attention_mask:r})).image_features}_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return mr({image_token_id:this.config.image_token_id,...e,image_features:s})}},E_=class extends pc{};var Xo=class extends y{},A_=class extends Xo{},M_=class extends Xo{async _call(e){return new G(await super._call(e))}};var Ko=class extends y{},T_=class extends Ko{},S_=class extends Ko{};var en=class extends y{},O_=class extends en{async forward(e){let r=!e.input_ids,s=!e.pixel_values;if(r&&s)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(r&&(e.input_ids=st([e.pixel_values.dims[0],1])),s){let{image_size:u}=this.config.vision_config;e.pixel_values=qe([0,3,u,u],0)}let{text_embeddings:n,image_embeddings:o,l2norm_text_embeddings:a,l2norm_image_embeddings:i}=await super.forward(e),l={};return r||(l.text_embeddings=n,l.l2norm_text_embeddings=a),s||(l.image_embeddings=o,l.l2norm_image_embeddings=i),l}},Yo=class extends en{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},I_=class extends en{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var Qo=class extends y{},C_=class extends Qo{},P_=class extends Qo{};var Jo=class extends y{},L_=class extends Jo{},N_=class extends Jo{};var Zo=class extends y{},z_=class extends Zo{},$_=class extends Zo{};var dc=class extends y{},R_=class extends dc{};var fc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},tn=class extends fc{_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return mr({image_token_id:this.config.image_token_index,...e,image_features:s})}},D_=class extends tn{},U_=class extends tn{};var ea=class extends y{},B_=class extends ea{},F_=class extends ea{};var ta=class extends y{},j_=class extends ta{},G_=class extends ta{};var ra=class extends y{},q_=class extends ra{},W_=class extends ra{};var sa=class extends y{},V_=class extends sa{},H_=class extends sa{};var ds=class extends y{},X_=class extends ds{},K_=class extends ds{},Y_=class extends ds{async _call(e){return new G(await super._call(e))}},Q_=class extends ds{};var mc=class extends y{},J_=class extends mc{};var hc=class extends y{},Z_=class extends hc{};var _c=class extends Re{constructor({char_logits:e,bpe_logits:r,wp_logits:s}){super(),this.char_logits=e,this.bpe_logits=r,this.wp_logits=s}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},gc=class extends y{},eg=class extends gc{async _call(e){return new _c(await super._call(e))}};var wc=class extends Re{constructor({audio_codes:e}){super(),this.audio_codes=e}},xc=class extends Re{constructor({audio_values:e}){super(),this.audio_values=e}},rn=class extends y{main_input_name="input_values";forward_params=["input_values"]},tg=class extends rn{async encode(e){return new wc(await pe(this.sessions.encoder_model,e))}async decode(e){return new xc(await pe(this.sessions.decoder_model,e))}},na=class extends rn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},oa=class extends rn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var aa=class extends y{},rg=class extends aa{},sg=class extends aa{};var fs=class extends y{},ng=class extends fs{},og=class extends fs{async _call(e){return new we(await super._call(e))}},ag=class extends fs{async _call(e){return new G(await super._call(e))}},ig=class extends fs{async _call(e){return new Ae(await super._call(e))}};var ia=class extends y{},lg=class extends ia{},cg=class extends ia{};var sn=class extends y{},ug=class extends sn{},pg=class extends sn{async _call(e){return new G(await super._call(e))}},dg=class extends sn{};var nn=class extends y{},fg=class extends nn{},mg=class extends nn{async _call(e){return new G(await super._call(e))}},hg=class extends nn{};var on=class extends y{},_g=class extends on{},gg=class extends on{async _call(e){return new G(await super._call(e))}},wg=class extends on{};var an=class extends y{},xg=class extends an{},yg=class extends an{async _call(e){return new G(await super._call(e))}},bg=class extends an{};var la=class extends y{},vg=class extends la{},kg=class extends la{async _call(e){return new G(await super._call(e))}};var ca=class extends y{},Eg=class extends ca{},Ag=class extends ca{async _call(e){return new G(await super._call(e))}};var ms=class extends y{},Mg=class extends ms{},Tg=class extends ms{async _call(e){return new we(await super._call(e))}},Sg=class extends ms{async _call(e){return new G(await super._call(e))}},Og=class extends ms{async _call(e){return new _e(await super._call(e))}};var ua=class extends y{},Ig=class extends ua{},Cg=class extends ua{};var pa=class extends y{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},Pg=class extends pa{},Lg=class extends pa{};var zr=class extends y{},Ng=class extends zr{},zg=class extends zr{async _call(e){return new we(await super._call(e))}},$g=class extends zr{async _call(e){return new G(await super._call(e))}},Rg=class extends zr{async _call(e){return new _e(await super._call(e))}},Dg=class extends zr{async _call(e){return new Ae(await super._call(e))}};var da=class extends y{},Ug=class extends da{},Bg=class extends da{};var fa=class extends y{},Fg=class extends fa{},jg=class extends fa{};var yc=class extends y{},Gg=class extends yc{forward_params=["input_ids","pixel_values","images_seq_mask","images_emb_mask","attention_mask","position_ids","past_key_values"];constructor(...e){super(...e),this._generation_mode="text"}async forward(e){let r=this._generation_mode??"text",s;if(r==="text"||!e.past_key_values){let l=this.sessions.prepare_inputs_embeds,u=ot(e,l.inputNames);s=await pe(l,u)}else{let l=this.sessions.gen_img_embeds,u=ot({image_ids:e.input_ids},l.inputNames);s=await pe(l,u)}let n={...e,...s},o=await It(this,n),a=this.sessions[r==="text"?"lm_head":"gen_head"];if(!a)throw new Error(`Unable to find "${a}" generation head`);let i=await pe(a,ot(o,a.inputNames));return{...s,...o,...i}}prepare_inputs_for_generation(e,r,s){let n=!!r.past_key_values;return s.guidance_scale!==null&&s.guidance_scale>1&&(n?r.input_ids=Ee([r.input_ids,r.input_ids],0):(r.input_ids=Ee([r.input_ids,Nn(r.input_ids,BigInt(s.pad_token_id))],0),r.attention_mask=Ee([r.attention_mask,Nn(r.attention_mask,0n)],0))),(n||!r.pixel_values)&&(r.pixel_values=qe([0,0,3,384,384],1)),n&&(r.images_seq_mask=new D("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),r.images_emb_mask=new D("bool",new Array(0).fill(!1),[1,1,0])),r}async generate(e){return this._generation_mode="text",super.generate(e)}async generate_images(e){this._generation_mode="image";let r=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[r,null]),o=this.sessions.image_decode,{decoded_image:a}=await pe(o,{generated_tokens:n}),i=a.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),l=[];for(let u of i){let p=Ke.fromTensor(u);l.push(p)}return l}};var ma=class extends y{},qg=class extends ma{},Wg=class extends ma{},ha=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];_apply_and_filter_by_delay_pattern_mask(e){let[r,s]=e.dims,n=this.config.decoder.num_codebooks,o=s-n,a=0;for(let u=0;u<e.size;++u){if(e.data[u]==this.config.decoder.pad_token_id)continue;let p=u%s,f=Math.floor(u/s)%n,m=p-f;m>0&&m<=o&&(e.data[a++]=e.data[u])}let i=Math.floor(r/n),l=a/(i*n);return new D(e.type,e.data.slice(0,a),[i,n,l])}prepare_inputs_for_generation(e,r,s){let n=BigInt(this.config.decoder.pad_token_id),o=structuredClone(e);for(let a=0;a<o.length;++a)for(let i=0;i<o[a].length;++i)a%this.config.decoder.num_codebooks>=i&&(o[a][i]=n);return s.guidance_scale!==null&&s.guidance_scale>1&&(o=o.concat(o)),Xl(this,o,r,s)}async generate(e){let r=await super.generate(e),s=this._apply_and_filter_by_delay_pattern_mask(r).unsqueeze_(0),{audio_values:n}=await pe(this.sessions.encodec_decode,{audio_codes:s});return n}};var _a=class extends y{},Vg=class extends _a{},Hg=class extends _a{};var $r=class extends y{},Xg=class extends $r{},Kg=class extends $r{async _call(e){return new we(await super._call(e))}},Yg=class extends $r{async _call(e){return new G(await super._call(e))}},Qg=class extends $r{async _call(e){return new _e(await super._call(e))}},Jg=class extends $r{async _call(e){return new Ae(await super._call(e))}};var bc=class extends y{},Zg=class extends bc{};var ga=class extends y{},ew=class extends ga{},tw=class extends ga{};var wa=class extends y{},rw=class extends wa{},sw=class extends wa{};var xa=class extends y{},nw=class extends xa{},ow=class extends xa{};var ya=class extends y{},aw=class extends ya{},iw=class extends ya{};var ba=class extends y{},lw=class extends ba{},cw=class extends ba{};var va=class extends y{},uw=class extends va{},pw=class extends va{};var ka=class extends y{},dw=class extends ka{},fw=class extends ka{};var Ea=class extends y{},mw=class extends Ea{},hw=class extends Ea{};var vc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},_w=class extends vc{_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return mr({image_token_id:this.config.image_token_index,...e,image_features:s})}};var kc=class extends y{},gw=class extends kc{async _call(e){return new wt(await super._call(e))}};var Aa=class extends y{},ww=class extends Aa{},xw=class extends Aa{};var Ma=class extends y{},yw=class extends Ma{},bw=class extends Ma{};var Ta=class extends y{},vw=class extends Ta{},kw=class extends Ta{};var Sa=class extends y{},Ew=class extends Sa{},Aw=class extends Sa{};var Ec=class extends y{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},Oa=class extends Ec{async forward({input_ids:e=null,attention_mask:r=null,pixel_values:s=null,image_sizes:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:u=null,...p}){if(!a){let m;if(s&&e.dims[1]!==1){if(!n)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:m}=await pe(this.sessions.vision_encoder,{pixel_values:s,image_sizes:n}))}else{let h=this.config.normalized_config.hidden_size;m=new D("float32",[],[0,h])}({inputs_embeds:a}=await pe(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:m}))}return await It(this,{inputs_embeds:a,past_key_values:i,attention_mask:r,position_ids:o,generation_config:l,logits_processor:u},!1)}};var Ia=class extends y{},Mw=class extends Ia{},Tw=class extends Ia{async _call(e){return new G(await super._call(e))}};var Ca=class extends y{},Sw=class extends Ca{},Ow=class extends Ca{async _call(e){return new _e(await super._call(e))}};var Pa=class extends y{},Iw=class extends Pa{},Cw=class extends Pa{};var La=class extends y{},Pw=class extends La{},Lw=class extends La{};var Ac=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},Na=class extends Ac{image_grid_thw_name="grid_thw";get_rope_index(e,r,s,n){let{vision_config:o,image_token_id:a,video_token_id:i,vision_start_token_id:l}=this.config,u=o.spatial_merge_size??2,p=[];if(r||s){let f=e.tolist();n||(n=ul(e));let m=n.tolist(),h=Array.from({length:3},A=>Array.from({length:e.dims[0]},S=>Array.from({length:e.dims[1]},T=>1))),w=r?r.tolist():[],x=s?s.tolist():[],v=0,E=0;for(let A=0;A<f.length;++A){let S=f[A].filter((I,N)=>m[A][N]==1),L=S.reduce((I,N,R)=>(N==l&&I.push(R),I),[]).map(I=>S[I+1]),P=L.filter(I=>I==a).length,k=L.filter(I=>I==i).length,F=[],K=0,W=P,X=k;for(let I=0;I<L.length;++I){let N=S.findIndex((Tt,rt)=>rt>K&&Tt==a),R=S.findIndex((Tt,rt)=>rt>K&&Tt==i),ee=W>0&&N!==-1?N:S.length+1,de=X>0&&R!==-1?R:S.length+1,Fe,Le,At,Je;ee<de?([Le,At,Je]=w[v],++v,--W,Fe=ee):([Le,At,Je]=x[E],++E,--X,Fe=de);let[tt,nt,Me]=[Number(Le),Math.floor(Number(At)/u),Math.floor(Number(Je)/u)],xe=Fe-K,We=F.length>0?Se(F.at(-1))[0]+1:0;F.push(Array.from({length:3*xe},(Tt,rt)=>We+rt%xe));let Mt=xe+We,be=tt*nt*Me,De=Array.from({length:be},(Tt,rt)=>Mt+Math.floor(rt/(nt*Me))),qr=Array.from({length:be},(Tt,rt)=>Mt+Math.floor(rt/Me)%nt),ys=Array.from({length:be},(Tt,rt)=>Mt+rt%Me);F.push([De,qr,ys].flat()),K=Fe+be}if(K<S.length){let I=F.length>0?Se(F.at(-1))[0]+1:0,N=S.length-K;F.push(Array.from({length:3*N},(R,ee)=>I+ee%N))}let H=F.reduce((I,N)=>I+N.length,0),Y=new Array(H),U=0;for(let I=0;I<3;++I)for(let N=0;N<F.length;++N){let R=F[N],ee=R.length/3;for(let de=I*ee;de<(I+1)*ee;++de)Y[U++]=R[de]}let C=0,ne=m[A];for(let I=0;I<ne.length;++I)if(ne[I]==1){for(let N=0;N<3;++N)h[N][A][I]=Y[N*H/3+C];++C}let ae=Se(Y)[0];p.push(ae+1-f[A].length)}return[new D("int64",h.flat(1/0),[3,e.dims[0],e.dims[1]]),new D("int64",p,[p.length,1])]}else if(n){let{data:f,dims:m}=Hb(n),h=BigInt64Array.from({length:3*f.length},(x,v)=>f[v%f.length]),w=Array.from({length:m[0]},(x,v)=>Se(f.subarray(m[1]*v,m[1]*(v+1)))[0]+1n+BigInt(m[1]));return[new D("int64",h,[3,...m]),new D("int64",w,[w.length,1])]}else{let[f,m]=e.dims,h=BigInt64Array.from({length:3*f*m},(w,x)=>BigInt(Math.floor(x%m/f)));return[new D("int64",h,[3,...e.dims]),sp([f,1])]}}async encode_image({pixel_values:e,image_grid_thw:r}){return(await pe(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:r})).image_features}_merge_input_ids_with_image_features(e){return mr({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,r,s){if(r.attention_mask&&!r.position_ids)if(!r.past_key_values)[r.position_ids,r.rope_deltas]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask);else{r.pixel_values=null;let n=Mf(r.past_key_values);if(n<r.input_ids.dims[1]){let[o,a]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask);r.rope_deltas=a,r.position_ids=o.slice(null,null,[n,null]),r.input_ids=r.input_ids.slice(null,[n,null])}else{r.rope_deltas||([,r.rope_deltas]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask));let o=BigInt(n),a=r.rope_deltas.map(i=>o+i);r.position_ids=$t([a,a,a],0)}}return r}};var za=class extends Na{image_grid_thw_name="image_grid_thw"};var $a=class extends y{},Nw=class extends $a{},zw=class extends $a{};var Ra=class extends y{},$w=class extends Ra{},Rw=class extends Ra{};var Da=class extends y{},Dw=class extends Da{},Uw=class extends Da{};var hs=class extends za{};var Bw=class extends hs{};var Ua=class extends hs{};var Fw=class extends Ua{};var Ba=class extends y{},jw=class extends Ba{},Gw=class extends Ba{async _call(e){return new G(await super._call(e))}};var Fa=class extends y{},qw=class extends Fa{},Ww=class extends Fa{async _call(e){return new Mc(await super._call(e))}},Mc=class extends or{};var Rr=class extends y{},Vw=class extends Rr{},Hw=class extends Rr{async _call(e){return new we(await super._call(e))}},Xw=class extends Rr{async _call(e){return new G(await super._call(e))}},Kw=class extends Rr{async _call(e){return new _e(await super._call(e))}},Yw=class extends Rr{async _call(e){return new Ae(await super._call(e))}};var Dr=class extends y{},Qw=class extends Dr{},Jw=class extends Dr{async _call(e){return new we(await super._call(e))}},Zw=class extends Dr{async _call(e){return new G(await super._call(e))}},ex=class extends Dr{async _call(e){return new _e(await super._call(e))}},tx=class extends Dr{async _call(e){return new Ae(await super._call(e))}};var ja=class extends y{},rx=class extends ja{},sx=class extends ja{async _call(e){return new Tc(await super._call(e))}},Tc=class extends or{};var Sc=class extends Re{constructor({iou_scores:e,pred_masks:r}){super(),this.iou_scores=e,this.pred_masks=r}},Oc=class extends y{},nx=class extends Oc{async get_image_embeddings({pixel_values:e}){return await Vt(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??=st(e.input_points.dims.slice(0,-1));let r={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(r.input_points=e.input_points),e.input_labels&&(r.input_labels=e.input_labels),e.input_boxes&&(r.input_boxes=e.input_boxes),await pe(this.sessions.prompt_encoder_mask_decoder,r)}async _call(e){return new Sc(await super._call(e))}};var Ic=class extends Re{constructor({iou_scores:e,pred_masks:r,object_score_logits:s}){super(),this.iou_scores=e,this.pred_masks=r,this.object_score_logits=s}},Cc=class extends y{},Ga=class extends Cc{async get_image_embeddings({pixel_values:e}){return await Vt(this,{pixel_values:e})}async forward(e){let{num_feature_levels:r}=this.config.vision_config;if(Array.from({length:r},(a,i)=>`image_embeddings.${i}`).some(a=>!e[a])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let a=e.input_points.dims;e.input_labels??=st(a.slice(0,-1)),e.input_boxes??=qe([a[0],0,4],0)}else if(e.input_boxes){let a=e.input_boxes.dims;e.input_labels=qe([a[0],a[1],0],-1n),e.input_points=qe([a[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder,o=ot(e,n.inputNames);return await pe(n,o)}async _call(e){return new Ic(await super._call(e))}},ox=class extends Ga{},ax=class extends Ga{};var ln=class extends y{},ix=class extends ln{},lx=class extends ln{},cx=class extends ln{};var cn=class extends y{},ux=class extends cn{},px=class extends cn{},dx=class extends cn{};var qa=class extends y{},fx=class extends qa{},Wa=class extends qa{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},mx=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var Va=class extends y{},hx=class extends Va{},_x=class extends Va{};var un=class extends y{main_input_name="input_values";forward_params=["input_values"]},gx=class extends un{async encode(e){return await pe(this.sessions.encoder_model,e)}async decode(e){return await pe(this.sessions.decoder_model,e)}},Ha=class extends un{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},Xa=class extends un{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var pn=class extends y{},wx=class extends pn{},xx=class extends pn{},yx=class extends pn{async generate_speech(e,r,{threshold:s=.5,minlenratio:n=0,maxlenratio:o=20,vocoder:a=null}={}){let i={input_ids:e},{encoder_outputs:l,encoder_attention_mask:u}=await Vt(this,i),p=l.dims[1]/this.config.reduction_factor,f=Math.floor(p*o),m=Math.floor(p*n),h=this.config.num_mel_bins,w=[],x=null,v=null,E=0;for(;;){++E;let T=Vb(!!v),L;v?L=v.output_sequence_out:L=new D("float32",new Float32Array(h),[1,1,h]);let P={use_cache_branch:T,output_sequence:L,encoder_attention_mask:u,speaker_embeddings:r,encoder_hidden_states:l};this.addPastKeyValues(P,x),v=await pe(this.sessions.decoder_model_merged,P),x=this.getPastKeyValues(v,x);let{prob:k,spectrum:F}=v;if(w.push(F),E>=m&&(Array.from(k.data).filter(K=>K>=s).length>0||E>=f))break}let A=Ee(w),{waveform:S}=await pe(a.sessions.model,{spectrogram:A});return{spectrogram:A,waveform:S}}},bx=class extends y{main_input_name="spectrogram"};var _s=class extends y{},vx=class extends _s{},kx=class extends _s{async _call(e){return new we(await super._call(e))}},Ex=class extends _s{async _call(e){return new G(await super._call(e))}},Ax=class extends _s{async _call(e){return new Ae(await super._call(e))}};var Ka=class extends y{},Mx=class extends Ka{},Tx=class extends Ka{};var Ya=class extends y{},Sx=class extends Ya{},Ox=class extends Ya{};var Pc=class extends y{},Ix=class extends Pc{};var Lc=class extends y{},Qa=class extends Lc{async generate_speech({input_ids:e,attention_mask:r,style:s,num_inference_steps:n=5,speed:o=1.05}){let{sampling_rate:a,chunk_compress_factor:i,base_chunk_size:l,latent_dim:u}=this.config,{last_hidden_state:p,durations:f}=await pe(this.sessions.text_encoder,{input_ids:e,attention_mask:r,style:s}),m=f.div(o).mul_(a),h=l*i,w=m.data,x=Int32Array.from(w,W=>Math.ceil(W/h)),v=Math.max(...x),E=e.dims[0],A=new BigInt64Array(E*v);for(let W=0;W<E;++W)A.fill(1n,W*v,W*v+x[W]);let S=new D("int64",A,[E,v]),T=u*i,L=T*v,P=Mb([E,T,v]),k=P.data;for(let W=0;W<E;++W)if(x[W]!==v)for(let X=0;X<T;++X)k.fill(0,W*L+X*v+x[W],W*L+(X+1)*v);let F=qe([E],n);for(let W=0;W<n;++W){let X=qe([E],W);({denoised_latents:P}=await pe(this.sessions.latent_denoiser,{style:s,noisy_latents:P,latent_mask:S,encoder_outputs:p,attention_mask:r,timestep:X,num_inference_steps:F}))}let{waveform:K}=await pe(this.sessions.voice_decoder,{latents:P});return{waveform:K,durations:m}}};var dn=class extends y{},Cx=class extends dn{},Px=class extends dn{async _call(e){return new G(await super._call(e))}},Lx=class extends dn{};var Ja=class extends y{},Nx=class extends Ja{},zx=class extends Ja{};var Za=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},$x=class extends Za{},Rx=class extends Za{};var ei=class extends y{},Dx=class extends ei{},Ux=class extends ei{async _call(e){return new Nc(await super._call(e))}},Nc=class extends Zs{};var zc=class extends y{},Bx=class extends zc{};var $c=class extends y{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},Rc=class extends $c{_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return Sf({audio_token_id:this.config.ignore_index??this.config.audio_token_id,...e,audio_features:s})}},Fx=class extends Rc{};var fn=class extends y{},jx=class extends fn{},Gx=class extends fn{async _call(e){return new wt(await super._call(e))}},qx=class extends fn{async _call(e){return new G(await super._call(e))}};var gs=class extends y{},Wx=class extends gs{},Vx=class extends gs{async _call(e){return new wt(await super._call(e))}},Hx=class extends gs{async _call(e){return new G(await super._call(e))}},Xx=class extends gs{async _call(e){return new _e(await super._call(e))}};var ti=class extends y{},Kx=class extends ti{},Yx=class extends ti{};var Qx=class extends y{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var ri=class extends y{},Jx=class extends ri{},Zx=class extends ri{async _call(e){return new G(await super._call(e))}};var Dc=class extends y{},ey=class extends Dc{};var si=class extends y{},ty=class extends si{},ry=class extends si{async _call(e){return new G(await super._call(e))}};var Uc=class extends y{},sy=class extends Uc{async _call(e){return new kf(await super._call(e))}};var Bc=class extends y{},ny=class extends Bc{};var Fc=class extends Re{constructor({waveform:e,spectrogram:r}){super(),this.waveform=e,this.spectrogram=r}},jc=class extends y{},oy=class extends jc{async _call(e){return new Fc(await super._call(e))}};var mn=class extends y{},ay=class extends mn{},iy=class extends mn{async _call(e){return new wt(await super._call(e))}},ly=class extends mn{async _call(e){return new G(await super._call(e))}};var Gc=class extends Re{constructor({logits:e,embeddings:r}){super(),this.logits=e,this.embeddings=r}},Ur=class extends y{},cy=class extends Ur{},uy=class extends Ur{async _call(e){return new wt(await super._call(e))}},py=class extends Ur{async _call(e){return new G(await super._call(e))}},dy=class extends Ur{async _call(e){return new Gc(await super._call(e))}},fy=class extends Ur{async _call(e){return new _e(await super._call(e))}};var qc=class extends y{},my=class extends qc{};var hy=class extends Qn{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1};var ni=class extends y{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},_y=class extends ni{},Wc=class extends ni{_prepare_generation_config(e,r){return super._prepare_generation_config(e,r,hy)}_retrieve_init_tokens(e){let r=[e.decoder_start_token_id],s=e.language,n=e.task;if(e.is_multilingual){s||(J.warn("No language specified - defaulting to English (en)."),s="en");let a=`<|${XA(s)}|>`;r.push(e.lang_to_id[a]),r.push(e.task_to_id[n??"transcribe"])}else if(s||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&&r.at(-1)!==e.no_timestamps_token_id?r.push(e.no_timestamps_token_id):e.return_timestamps&&r.at(-1)===e.no_timestamps_token_id&&(J.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),r.pop()),r.filter(o=>o!=null)}async generate({inputs:e=null,generation_config:r=null,logits_processor:s=null,stopping_criteria:n=null,...o}){r=this._prepare_generation_config(r,o);let a=o.decoder_input_ids??this._retrieve_init_tokens(r);if(r.return_timestamps&&(s??=new cs,s.push(new $l(r,a))),r.begin_suppress_tokens&&(s??=new cs,s.push(new qs(r.begin_suppress_tokens,a.length))),r.return_token_timestamps){if(!r.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.");r.task==="translate"&&J.warn("Token-level timestamps may not be reliable for task 'translate'."),r.output_attentions=!0,r.return_dict_in_generate=!0}let i=await super.generate({inputs:e,generation_config:r,logits_processor:s,decoder_input_ids:a,...o});return r.return_token_timestamps&&(i.token_timestamps=this._extract_token_timestamps(i,r.alignment_heads,r.num_frames)),i}_extract_token_timestamps(e,r,s=null,n=.02){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");s==null&&J.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let o=this.config.median_filter_width;o===void 0&&(J.warn("Model config has no `median_filter_width`, using default value of 7."),o=7);let a=e.cross_attentions,i=Array.from({length:this.config.decoder_layers},(x,v)=>Ee(a.map(E=>E[v]),2)),l=$t(r.map(([x,v])=>{if(x>=i.length)throw new Error(`Layer index ${x} is out of bounds for cross attentions (length ${i.length}).`);return s?i[x].slice(null,v,null,[0,s]):i[x].slice(null,v)})).transpose(1,0,2,3),[u,p]=rp(l,-2,0,!0),f=l.clone();for(let x=0;x<f.dims[0];++x){let v=f[x];for(let E=0;E<v.dims[0];++E){let A=v[E],S=u[x][E][0].data,T=p[x][E][0].data;for(let L=0;L<A.dims[0];++L){let P=A[L].data;for(let k=0;k<P.length;++k)P[k]=(P[k]-T[k])/S[k];P.set(lE(P,o))}}}let m=[cl(f,1)],h=e.sequences.dims,w=new D("float32",new Float32Array(h[0]*h[1]),h);for(let x=0;x<h[0];++x){let v=m[x].neg().squeeze_(0),[E,A]=uE(v.tolist()),S=Array.from({length:E.length-1},(P,k)=>E[k+1]-E[k]),T=ft([1],S).map(P=>!!P),L=[];for(let P=0;P<T.length;++P)T[P]&&L.push(A[P]*n);w[x].data.set(L,1)}return w}},gy=class extends Wc{};var Br=class extends y{},wy=class extends Br{},xy=class extends Br{async _call(e){return new we(await super._call(e))}},yy=class extends Br{async _call(e){return new G(await super._call(e))}},by=class extends Br{async _call(e){return new _e(await super._call(e))}},vy=class extends Br{async _call(e){return new Ae(await super._call(e))}};var Fr=class extends y{},ky=class extends Fr{},Ey=class extends Fr{async _call(e){return new we(await super._call(e))}},Ay=class extends Fr{async _call(e){return new G(await super._call(e))}},My=class extends Fr{async _call(e){return new _e(await super._call(e))}},Ty=class extends Fr{async _call(e){return new Ae(await super._call(e))}};var oi=class extends y{},Sy=class extends oi{},Oy=class extends oi{async _call(e){return new Vc(await super._call(e))}},Vc=class extends Re{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var ai=class extends y{},Iy=class extends ai{},Cy=class extends ai{};var aN=new Map([["bert","BertModel"],["neobert","NeoBertModel"],["modernbert","ModernBertModel"],["nomic_bert","NomicBertModel"],["roformer","RoFormerModel"],["electra","ElectraModel"],["esm","EsmModel"],["convbert","ConvBertModel"],["camembert","CamembertModel"],["deberta","DebertaModel"],["deberta-v2","DebertaV2Model"],["mpnet","MPNetModel"],["albert","AlbertModel"],["distilbert","DistilBertModel"],["roberta","RobertaModel"],["xlm","XLMModel"],["xlm-roberta","XLMRobertaModel"],["clap","ClapModel"],["clip","CLIPModel"],["clipseg","CLIPSegModel"],["chinese_clip","ChineseCLIPModel"],["siglip","SiglipModel"],["jina_clip","JinaCLIPModel"],["mobilebert","MobileBertModel"],["squeezebert","SqueezeBertModel"],["wav2vec2","Wav2Vec2Model"],["wav2vec2-bert","Wav2Vec2BertModel"],["unispeech","UniSpeechModel"],["unispeech-sat","UniSpeechSatModel"],["hubert","HubertModel"],["wavlm","WavLMModel"],["audio-spectrogram-transformer","ASTModel"],["vits","VitsModel"],["pyannote","PyAnnoteModel"],["wespeaker-resnet","WeSpeakerResNetModel"],["detr","DetrModel"],["rt_detr","RTDetrModel"],["rt_detr_v2","RTDetrV2Model"],["rf_detr","RFDetrModel"],["d_fine","DFineModel"],["table-transformer","TableTransformerModel"],["vit","ViTModel"],["ijepa","IJepaModel"],["pvt","PvtModel"],["vit_msn","ViTMSNModel"],["vit_mae","ViTMAEModel"],["groupvit","GroupViTModel"],["fastvit","FastViTModel"],["mobilevit","MobileViTModel"],["mobilevitv2","MobileViTV2Model"],["owlvit","OwlViTModel"],["owlv2","Owlv2Model"],["beit","BeitModel"],["deit","DeiTModel"],["hiera","HieraModel"],["convnext","ConvNextModel"],["convnextv2","ConvNextV2Model"],["dinov2","Dinov2Model"],["dinov2_with_registers","Dinov2WithRegistersModel"],["dinov3_vit","DINOv3ViTModel"],["dinov3_convnext","DINOv3ConvNextModel"],["resnet","ResNetModel"],["swin","SwinModel"],["swin2sr","Swin2SRModel"],["donut-swin","DonutSwinModel"],["yolos","YolosModel"],["dpt","DPTModel"],["glpn","GLPNModel"],["hifigan","SpeechT5HifiGan"],["efficientnet","EfficientNetModel"],["decision_transformer","DecisionTransformerModel"],["patchtst","PatchTSTModel"],["patchtsmixer","PatchTSMixerModel"],["mobilenet_v1","MobileNetV1Model"],["mobilenet_v2","MobileNetV2Model"],["mobilenet_v3","MobileNetV3Model"],["mobilenet_v4","MobileNetV4Model"],["maskformer","MaskFormerModel"],["mgp-str","MgpstrForSceneTextRecognition"],["style_text_to_speech_2","StyleTextToSpeech2Model"]]),iN=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),lN=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),cN=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"],["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"],["ministral","MinistralModel"],["ministral3","Ministral3Model"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"]]),w2=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"]]),x2=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),y2=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),b2=new Map([["bert","BertForSequenceClassification"],["neobert","NeoBertForSequenceClassification"],["modernbert","ModernBertForSequenceClassification"],["roformer","RoFormerForSequenceClassification"],["electra","ElectraForSequenceClassification"],["esm","EsmForSequenceClassification"],["convbert","ConvBertForSequenceClassification"],["camembert","CamembertForSequenceClassification"],["deberta","DebertaForSequenceClassification"],["deberta-v2","DebertaV2ForSequenceClassification"],["mpnet","MPNetForSequenceClassification"],["albert","AlbertForSequenceClassification"],["distilbert","DistilBertForSequenceClassification"],["roberta","RobertaForSequenceClassification"],["xlm","XLMForSequenceClassification"],["xlm-roberta","XLMRobertaForSequenceClassification"],["bart","BartForSequenceClassification"],["mbart","MBartForSequenceClassification"],["mobilebert","MobileBertForSequenceClassification"],["squeezebert","SqueezeBertForSequenceClassification"]]),v2=new Map([["bert","BertForTokenClassification"],["neobert","NeoBertForTokenClassification"],["modernbert","ModernBertForTokenClassification"],["roformer","RoFormerForTokenClassification"],["electra","ElectraForTokenClassification"],["esm","EsmForTokenClassification"],["convbert","ConvBertForTokenClassification"],["camembert","CamembertForTokenClassification"],["deberta","DebertaForTokenClassification"],["deberta-v2","DebertaV2ForTokenClassification"],["mpnet","MPNetForTokenClassification"],["distilbert","DistilBertForTokenClassification"],["roberta","RobertaForTokenClassification"],["xlm","XLMForTokenClassification"],["xlm-roberta","XLMRobertaForTokenClassification"]]),k2=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),E2=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"],["helium","HeliumForCausalLM"],["glm","GlmForCausalLM"],["openelm","OpenELMForCausalLM"],["qwen2","Qwen2ForCausalLM"],["qwen2_moe","Qwen2MoeForCausalLM"],["qwen3","Qwen3ForCausalLM"],["qwen3_moe","Qwen3MoeForCausalLM"],["qwen3_next","Qwen3NextForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["trocr","TrOCRForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),uN=new Map([["multi_modality","MultiModalityCausalLM"]]),A2=new Map([["bert","BertForMaskedLM"],["neobert","NeoBertForMaskedLM"],["modernbert","ModernBertForMaskedLM"],["roformer","RoFormerForMaskedLM"],["electra","ElectraForMaskedLM"],["esm","EsmForMaskedLM"],["convbert","ConvBertForMaskedLM"],["camembert","CamembertForMaskedLM"],["deberta","DebertaForMaskedLM"],["deberta-v2","DebertaV2ForMaskedLM"],["mpnet","MPNetForMaskedLM"],["albert","AlbertForMaskedLM"],["distilbert","DistilBertForMaskedLM"],["roberta","RobertaForMaskedLM"],["xlm","XLMWithLMHeadModel"],["xlm-roberta","XLMRobertaForMaskedLM"],["mobilebert","MobileBertForMaskedLM"],["squeezebert","SqueezeBertForMaskedLM"]]),M2=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"]]),T2=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),S2=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"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"],["paligemma","PaliGemmaForConditionalGeneration"],["llava_qwen2","LlavaQwen2ForCausalLM"],["gemma3n","Gemma3nForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"]]),O2=new Map([["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"]]),pN=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),I2=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"]]),C2=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),P2=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),ii=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),L2=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),N2=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),z2=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),$2=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),R2=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),D2=new Map([["wavlm","WavLMForXVector"]]),U2=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),B2=new Map([["vitmatte","VitMatteForImageMatting"]]),dN=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),F2=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),j2=new Map([["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),G2=new Map([["sapiens","SapiensForNormalEstimation"]]),q2=new Map([["vitpose","VitPoseForPoseEstimation"]]),W2=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),Xb=[[aN,j.EncoderOnly],[iN,j.EncoderDecoder],[cN,j.DecoderOnlyWithoutHead],[lN,j.AutoEncoder],[b2,j.EncoderOnly],[v2,j.EncoderOnly],[k2,j.Seq2Seq],[w2,j.Seq2Seq],[E2,j.DecoderOnly],[uN,j.MultiModality],[A2,j.EncoderOnly],[M2,j.EncoderOnly],[T2,j.Vision2Seq],[S2,j.ImageTextToText],[O2,j.AudioTextToText],[I2,j.EncoderOnly],[ii,j.EncoderOnly],[N2,j.EncoderOnly],[L2,j.EncoderOnly],[B2,j.EncoderOnly],[dN,j.EncoderOnly],[F2,j.EncoderOnly],[j2,j.EncoderOnly],[G2,j.EncoderOnly],[q2,j.EncoderOnly],[C2,j.EncoderOnly],[P2,j.EncoderOnly],[z2,j.MaskGeneration],[$2,j.EncoderOnly],[R2,j.EncoderOnly],[x2,j.Seq2Seq],[y2,j.EncoderOnly],[D2,j.EncoderOnly],[U2,j.EncoderOnly],[W2,j.EncoderOnly]];for(let[t,e]of Xb)for(let r of t.values()){sr.set(r,e);let s=Hc[r];Xs.set(s,r),Tf.set(r,s)}var fN=[["MusicgenForConditionalGeneration",ha,j.Musicgen],["Phi3VForCausalLM",Oa,j.Phi3V],["CLIPTextModelWithProjection",co,j.EncoderOnly],["SiglipTextModel",Wa,j.EncoderOnly],["JinaCLIPTextModel",Yo,j.EncoderOnly],["ClapTextModelWithProjection",io,j.EncoderOnly],["ClapAudioModelWithProjection",lo,j.EncoderOnly],["DacEncoderModel",xo,j.EncoderOnly],["DacDecoderModel",yo,j.EncoderOnly],["MimiEncoderModel",na,j.EncoderOnly],["MimiDecoderModel",oa,j.EncoderOnly],["SnacEncoderModel",Ha,j.EncoderOnly],["SnacDecoderModel",Xa,j.EncoderOnly],["Gemma3nForConditionalGeneration",No,j.ImageAudioTextToText],["SupertonicForConditionalGeneration",Qa,j.Supertonic],["ChatterboxModel",ao,j.Chatterbox]];for(let[t,e,r]of fN)sr.set(t,r),Xs.set(e,t),Tf.set(t,e);var V2=new Map([["modnet",ii],["birefnet",ii],["isnet",ii],["ben",ii]]);for(let[t,e]of V2.entries())e.set(t,"PreTrainedModel"),sr.set(t,j.EncoderOnly),Tf.set(t,y);var H2=new Set(V2.keys());sr.set("PreTrainedModel",j.EncoderOnly);Xs.set(y,"PreTrainedModel");var Pe={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:b2,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:v2,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:x2,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:y2,MODEL_FOR_MASKED_LM_MAPPING_NAMES:A2,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:M2,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:I2,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:ii,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:L2,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:N2,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:C2,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:P2,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:z2,MODEL_FOR_CTC_MAPPING_NAMES:$2,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:R2,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:D2,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:U2,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:pN,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:B2,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:F2,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:j2,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:G2,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:q2,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:W2,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:S2,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:O2,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:k2,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:w2,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:E2,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:T2};m2(Pe);var Oe=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let r of this.MODEL_CLASS_MAPPINGS)if(r.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:u=null,dtype:p=null,use_external_data_format:f=null,session_options:m={}}={}){let h={progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:u,dtype:p,use_external_data_format:f,session_options:m};if(h.config=await Wt.from_pretrained(e,h),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:w}=h.config;for(let x of this.MODEL_CLASS_MAPPINGS){let v=x.get(w);if(!v){for(let E of x.values())if(E[0]===w){v=E;break}if(!v)continue}return await Hc[v].from_pretrained(e,h)}if(this.BASE_IF_FAIL)return H2.has(w)||J.warn(`Unknown model class "${w}", attempting to construct from base class.`),await y.from_pretrained(e,h);throw Error(`Unsupported model type: ${w}`)}},hr=class extends Oe{static MODEL_CLASS_MAPPINGS=Xb.map(e=>e[0]);static BASE_IF_FAIL=!0},li=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},Xc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},hn=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},Kc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},Yc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},Qc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},Jc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},Zc=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},eu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},tu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},ru=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},ci=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},ui=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},pi=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},su=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},nu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},Kb=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},ou=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_CTC_MAPPING_NAMES]},au=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},Yb=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},Qb=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},iu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},Jb=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},lu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},cu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},Zb=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},e1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},uu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},t1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},r1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function Qe(t){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(e=>Ke.read(e)))}async function ws(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(r=>typeof r=="string"||r instanceof URL?Yp(r,e):r instanceof Float64Array?new Float32Array(r):r))}function pu(t,e){e&&(t=t.map(a=>a|0));let[r,s,n,o]=t;return{xmin:r,ymin:s,xmax:n,ymax:o}}var fe=class extends Ze{constructor({task:e,model:r,tokenizer:s=null,processor:n=null}){super(),this.task=e,this.model=r,this.tokenizer=s,this.processor=n}async dispose(){await this.model.dispose()}};var di=class extends fe{async _call(e,{top_k:r=1}={}){let s=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(s),{problem_type:o,id2label:a}=this.model.config,i=o==="multi_label_classification"?u=>u.sigmoid():u=>new D("float32",Ie(u.data),u.dims),l=[];for(let u of n.logits){let p=i(u),f=await qt(p,r),m=f[0].tolist(),w=f[1].tolist().map((x,v)=>({label:a?a[x]:`LABEL_${x}`,score:m[v]}));r===1?l.push(...w):l.push(w)}return Array.isArray(e)||r===1?l:l[0]}};var fi=class extends fe{async _call(e,{ignore_labels:r=["O"]}={}){let s=Array.isArray(e),n=this.tokenizer(s?e:[e],{padding:!0,truncation:!0}),a=(await this.model(n)).logits,i=this.model.config.id2label,l=[];for(let u=0;u<a.dims[0];++u){let p=n.input_ids[u],f=a[u],m=[];for(let h=0;h<f.dims[0];++h){let w=f[h],x=Se(w.data)[1],v=i?i[x]:`LABEL_${x}`;if(r.includes(v))continue;let E=this.tokenizer.decode([p[h].item()],{skip_special_tokens:!0});if(E==="")continue;let A=Ie(w.data);m.push({entity:v,score:A[x],index:h,word:E})}l.push(m)}return s?l:l[0]}};var mi=class extends fe{async _call(e,r,{top_k:s=1}={}){let n=this.tokenizer(e,{text_pair:r,padding:!0,truncation:!0}),o=Array.isArray(e),{start_logits:a,end_logits:i}=await this.model(n),l=n.input_ids.tolist(),u=n.attention_mask.tolist(),{all_special_ids:p,sep_token_id:f}=this.tokenizer,m=[];for(let h=0;h<a.dims[0];++h){let w=l[h],x=w.findIndex(P=>P==f),v=a[h].tolist(),E=i[h].tolist();for(let P=1;P<v.length;++P)(u[h]==0||P<=x||p.findIndex(k=>k==w[P])!==-1)&&(v[P]=-1/0,E[P]=-1/0);let A=Ie(v).map((P,k)=>[P,k]),S=Ie(E).map((P,k)=>[P,k]);A[0][0]=0,S[0][0]=0;let T=xk(A,S).filter(P=>P[0][1]<=P[1][1]).map(P=>[P[0][1],P[1][1],P[0][0]*P[1][0]]).sort((P,k)=>k[2]-P[2]),L=[];for(let P=0;P<Math.min(T.length,s);++P){let[k,F,K]=T[P],W=w.slice(k,F+1),X=this.tokenizer.decode(W,{skip_special_tokens:!0});L.push({answer:X,score:K})}s===1?m.push(...L):m.push(L)}return o?m:m[0]}};var hi=class extends fe{async _call(e,{top_k:r=5}={}){let{mask_token_id:s,mask_token:n}=this.tokenizer,o=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:a}=await this.model(o),i=[],l=o.input_ids.tolist();for(let u=0;u<l.length;++u){let p=l[u],f=p.findIndex(v=>v==s);if(f===-1)throw Error(`Mask token (${n}) not found in text.`);let m=a[u][f],h=await qt(new D("float32",Ie(m.data),m.dims),r),w=h[0].tolist(),x=h[1].tolist();i.push(x.map((v,E)=>{let A=p.slice();return A[f]=v,{score:w[E],token:Number(v),token_str:this.tokenizer.decode([v]),sequence:this.tokenizer.decode(A,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}};var _r=class extends fe{_key="generated_text";async _call(e,r={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(l=>this.model.config.prefix+l));let s=this.model.config.task_specific_params;s&&s[this.task]&&s[this.task].prefix&&(e=e.map(l=>s[this.task].prefix+l));let n=this.tokenizer,o={padding:!0,truncation:!0},a;this.task==="translation"&&"_build_translation_inputs"in n?a=n._build_translation_inputs(e,o,r):a=n(e,o);let i=await this.model.generate({...a,...r});return n.batch_decode(i,{skip_special_tokens:!0}).map(l=>({[this._key]:l}))}};var _i=class extends _r{_key="summary_text"};var gi=class extends _r{_key="translation_text"};function X2(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var wi=class extends fe{async _call(e,r={}){let s=!1,n=!1,o=r.add_special_tokens??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,a=r.tokenizer_encode_kwargs,i;if(typeof e=="string")i=e=[e];else if(Array.isArray(e)&&e.every(w=>typeof w=="string"))s=!0,i=e;else{if(X2(e))e=[e];else if(Array.isArray(e)&&e.every(X2))s=!0;else throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");n=!0,i=e.map(w=>this.tokenizer.apply_chat_template(w,{tokenize:!1,add_generation_prompt:!0,...a})),o=!1,a=void 0}let l=n?!1:r.return_full_text??!0;this.tokenizer.padding_side="left";let u=this.tokenizer(i,{add_special_tokens:o,padding:!0,truncation:!0,...a}),p=await this.model.generate({...u,...r}),f=this.tokenizer.batch_decode(p,{skip_special_tokens:!0}),m;!l&&u.input_ids.dims.at(-1)>0&&(m=this.tokenizer.batch_decode(u.input_ids,{skip_special_tokens:!0}).map(w=>w.length));let h=Array.from({length:e.length},w=>[]);for(let w=0;w<f.length;++w){let x=Math.floor(w/p.dims[0]*e.length);m&&(f[w]=f[w].slice(m[x])),h[x].push({generated_text:n?[...e[x],{role:"assistant",content:f[w]}]:f[w]})}return!s&&h.length===1?h[0]:h}};var xi=class extends fe{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([r,s])=>[r.toLowerCase(),s])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(J.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(J.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,r,{hypothesis_template:s="This example is {}.",multi_label:n=!1}={}){let o=Array.isArray(e);o||(e=[e]),Array.isArray(r)||(r=[r]);let a=r.map(u=>s.replace("{}",u)),i=n||r.length===1,l=[];for(let u of e){let p=[];for(let h of a){let w=this.tokenizer(u,{text_pair:h,padding:!0,truncation:!0}),x=await this.model(w);i?p.push([x.logits.data[this.contradiction_id],x.logits.data[this.entailment_id]]):p.push(x.logits.data[this.entailment_id])}let m=(i?p.map(h=>Ie(h)[1]):Ie(p)).map((h,w)=>[h,w]).sort((h,w)=>w[0]-h[0]);l.push({sequence:u,labels:m.map(h=>r[h[1]]),scores:m.map(h=>h[0])})}return o?l:l[0]}};var yi=class extends fe{async _call(e,{top_k:r=5}={}){let s=this.processor.feature_extractor.config.sampling_rate,n=await ws(e,s),o=this.model.config.id2label,a=[];for(let i of n){let l=await this.processor(i),p=(await this.model(l)).logits[0],f=await qt(new D("float32",Ie(p.data),p.dims),r),m=f[0].tolist(),w=f[1].tolist().map((x,v)=>({label:o?o[x]:`LABEL_${x}`,score:m[v]}));a.push(w)}return Array.isArray(e)?a:a[0]}};var bi=class extends fe{async _call(e,r,{hypothesis_template:s="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let o=r.map(p=>s.replace("{}",p)),a=this.tokenizer(o,{padding:!0,truncation:!0}),i=this.processor.feature_extractor.config.sampling_rate,l=await ws(e,i),u=[];for(let p of l){let f=await this.processor(p),m=await this.model({...a,...f}),h=Ie(m.logits_per_audio.data);u.push([...h].map((w,x)=>({score:w,label:r[x]})))}return n?u[0]:u}};var vi=class extends fe{async _call(e,r={}){switch(this.model.config.model_type){case"whisper":case"lite-whisper":return this._call_whisper(e,r);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":case"parakeet_ctc":return this._call_wav2vec2(e,r);case"moonshine":return this._call_moonshine(e,r);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,r){r.language&&J.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),r.task&&J.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let s=!Array.isArray(e),n=s?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await ws(n,o),i=[];for(let l of a){let u=await this.processor(l),f=(await this.model(u)).logits[0],m=[];for(let w of f)m.push(Se(w.data)[1]);let h=this.tokenizer.decode(m,{skip_special_tokens:!0}).trim();i.push({text:h})}return s?i[0]:i}async _call_whisper(e,r){let s=r.return_timestamps??!1,n=r.chunk_length_s??0,o=r.force_full_sequences??!1,a=r.stride_length_s??null,i={...r};s==="word"&&(i.return_token_timestamps=!0,i.return_timestamps=!1);let l=!Array.isArray(e),u=l?[e]:e,p=this.processor.feature_extractor.config,f=p.chunk_length/this.model.config.max_source_positions,m=p.hop_length,h=p.sampling_rate,w=await ws(u,h),x=[];for(let v of w){let E=[];if(n>0){if(a===null)a=n/6;else if(n<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let T=h*n,L=h*a,P=T-2*L,k=0;for(;;){let F=k+T,K=v.subarray(k,F),W=await this.processor(K),X=k===0,H=F>=v.length;if(E.push({stride:[K.length,X?0:L,H?0:L],input_features:W.input_features,is_last:H}),H)break;k+=P}}else E=[{stride:[v.length,0,0],input_features:(await this.processor(v)).input_features,is_last:!0}];for(let T of E){i.num_frames=Math.floor(T.stride[0]/m);let L=await this.model.generate({inputs:T.input_features,...i});s==="word"?(T.tokens=L.sequences.tolist()[0],T.token_timestamps=L.token_timestamps.tolist()[0].map(P=>Os(P,2))):T.tokens=L[0].tolist(),T.stride=T.stride.map(P=>P/h)}let[A,S]=this.tokenizer._decode_asr(E,{time_precision:f,return_timestamps:s,force_full_sequences:o});x.push({text:A,...S})}return l?x[0]:x}async _call_moonshine(e,r){let s=!Array.isArray(e),n=s?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await ws(n,o),i=[];for(let l of a){let u=await this.processor(l),p=Math.floor(l.length/o)*6,f=await this.model.generate({max_new_tokens:p,...r,...u}),m=this.processor.batch_decode(f,{skip_special_tokens:!0})[0];i.push({text:m})}return s?i[0]:i}};var ki=class extends fe{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,r){if((typeof e=="string"||e instanceof URL)&&(e=new Float32Array(await(await me.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new D("float32",e,[e.length]);else if(!(e instanceof D))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(r>1){if(e.dims[0]===1)e=e.repeat(r,1);else if(e.dims[0]!==r)throw new Error(`Expected speaker embeddings batch size to be 1 or ${r}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,r,s,n=null){let o=r.data,[a,i]=r.dims,l=n?n.data:null,u=[];for(let p=0;p<a;++p){let f=l?Math.min(Math.ceil(l[p]),i):i,m=p*i;u.push(new Dn(o.slice(m,m+f),s))}return Array.isArray(e)?u:u[0]}async _call(e,r){return this.processor?this._call_text_to_spectrogram(e,r):this.model.config.model_type==="supertonic"?this._call_supertonic(e,r):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:r,num_inference_steps:s,speed:n}){if(!r)throw new Error("Speaker embeddings must be provided for Supertonic models.");let{sampling_rate:o,style_dim:a}=this.model.config,i=this.tokenizer(e,{padding:!0,truncation:!0}),l=i.input_ids.dims[0];r=await this._prepare_speaker_embeddings(r,l),r=r.view(l,-1,a);let{waveform:u,durations:p}=await this.model.generate_speech({...i,style:r,num_inference_steps:s,speed:n});return this._postprocess_waveform(e,u,o,p)}async _call_text_to_waveform(e){let r=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:s}=await this.model(r),n=this.model.config.sampling_rate;return this._postprocess_waveform(e,s,n)}async _call_text_to_spectrogram(e,{speaker_embeddings:r}){this.vocoder||(J.info("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await hr.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"}));let{input_ids:s}=this.tokenizer(e,{padding:!0,truncation:!0}),n=s.dims[0];r=await this._prepare_speaker_embeddings(r,n),r=r.view(n,-1);let{waveform:o}=await this.model.generate_speech(s,r,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,o,a)}};var Ei=class extends fe{async _call(e,r={}){let s=Array.isArray(e),n=await Qe(e),{pixel_values:o}=await this.processor(n),a=[];for(let i of o){i.dims=[1,...i.dims];let l=await this.model.generate({inputs:i,...r}),u=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(p=>({generated_text:p.trim()}));a.push(u)}return s?a:a[0]}};var Ai=class extends fe{async _call(e,{top_k:r=5}={}){let s=await Qe(e),{pixel_values:n}=await this.processor(s),o=await this.model({pixel_values:n}),{id2label:a}=this.model.config,i=[];for(let l of o.logits){let u=await qt(new D("float32",Ie(l.data),l.dims),r),p=u[0].tolist(),m=u[1].tolist().map((h,w)=>({label:a?a[h]:`LABEL_${h}`,score:p[w]}));i.push(m)}return Array.isArray(e)?i:i[0]}};var K2={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},xs=class extends fe{async _call(e,{threshold:r=.5,mask_threshold:s=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:o=null,target_sizes:a=null,subtask:i=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let u=await Qe(e),p=u.map(A=>[A.height,A.width]),f=await this.processor(u),{inputNames:m,outputNames:h}=this.model.sessions.model;if(!m.includes("pixel_values")){if(m.length!==1)throw Error(`Expected a single input name, but got ${m.length} inputs: ${m}.`);let A=m[0];if(A in f)throw Error(`Input name ${A} already exists in the inputs.`);f[A]=f.pixel_values}let w=await this.model(f),x=null;if(i!==null)x=K2[i];else if(this.processor.image_processor){for(let[A,S]of Object.entries(K2))if(S in this.processor.image_processor){x=this.processor.image_processor[S].bind(this.processor.image_processor),i=A;break}}let v=this.model.config.id2label,E=[];if(i)if(i==="panoptic"||i==="instance"){let A=x(w,r,s,n,o,a??p)[0],S=A.segmentation;for(let T of A.segments_info){let L=new Uint8ClampedArray(S.data.length);for(let k=0;k<S.data.length;++k)S.data[k]===T.id&&(L[k]=255);let P=new Ke(L,S.dims[1],S.dims[0],1);E.push({score:T.score,label:v[T.label_id],mask:P})}}else if(i==="semantic"){let{segmentation:A,labels:S}=x(w,a??p)[0];for(let T of S){let L=new Uint8ClampedArray(A.data.length);for(let k=0;k<A.data.length;++k)A.data[k]===T&&(L[k]=255);let P=new Ke(L,A.dims[1],A.dims[0],1);E.push({score:null,label:v[T],mask:P})}}else throw Error(`Subtask ${i} not supported.`);else{let S=w[h[0]];for(let T=0;T<p.length;++T){let L=p[T],P=S[T];P.data.some(F=>F<-1e-5||F>1+1e-5)&&P.sigmoid_();let k=await Ke.fromTensor(P.mul_(255).to("uint8")).resize(L[1],L[0]);E.push({label:null,score:null,mask:k})}}return E}};var Mi=class extends xs{async _call(e,r={}){let s=await Qe(e),n=await super._call(e,r),o=s.map((a,i)=>{let l=a.clone();return l.putAlpha(n[i].mask),l});return Array.isArray(e)?o:o[0]}};var Ti=class extends fe{async _call(e,r,{hypothesis_template:s="This is a photo of {}"}={}){let n=Array.isArray(e),o=await Qe(e),a=r.map(m=>s.replace("{}",m)),i=this.tokenizer(a,{padding:this.model.config.model_type==="siglip"?"max_length":!0,truncation:!0}),{pixel_values:l}=await this.processor(o),u=await this.model({...i,pixel_values:l}),p=this.model.config.model_type==="siglip"?m=>m.sigmoid().data:m=>Ie(m.data),f=[];for(let m of u.logits_per_image){let w=[...p(m)].map((x,v)=>({score:x,label:r[v]}));w.sort((x,v)=>v.score-x.score),f.push(w)}return n?f:f[0]}};var Si=class extends fe{async _call(e,{threshold:r=.9,percentage:s=!1}={}){let n=Array.isArray(e);if(n&&e.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");let o=await Qe(e),a=s?null:o.map(h=>[h.height,h.width]),{pixel_values:i,pixel_mask:l}=await this.processor(o),u=await this.model({pixel_values:i,pixel_mask:l}),p=this.processor.image_processor.post_process_object_detection(u,r,a),{id2label:f}=this.model.config,m=p.map(h=>h.boxes.map((w,x)=>({score:h.scores[x],label:f[h.classes[x]],box:pu(w,!s)})));return n?m:m[0]}};var Oi=class extends fe{async _call(e,r,{threshold:s=.1,top_k:n=null,percentage:o=!1}={}){let a=Array.isArray(e),i=await Qe(e),l=this.tokenizer(r,{padding:!0,truncation:!0}),u=await this.processor(i),p=[];for(let f=0;f<i.length;++f){let m=i[f],h=o?null:[[m.height,m.width]],w=u.pixel_values[f].unsqueeze_(0),x=await this.model({...l,pixel_values:w}),v;if("post_process_grounded_object_detection"in this.processor){let E=this.processor.post_process_grounded_object_detection(x,l.input_ids,{box_threshold:s,text_threshold:s,target_sizes:h})[0];v=E.boxes.map((A,S)=>({score:E.scores[S],label:E.labels[S],box:pu(A,!o)}))}else{let E=this.processor.image_processor.post_process_object_detection(x,s,h,!0)[0];v=E.boxes.map((A,S)=>({score:E.scores[S],label:r[E.classes[S]],box:pu(A,!o)}))}v.sort((E,A)=>A.score-E.score),n!==null&&(v=v.slice(0,n)),p.push(v)}return a?p:p[0]}};var Ii=class extends fe{async _call(e,r,s={}){if(Array.isArray(e)){if(e.length!==1)throw Error("Document Question Answering pipeline currently only supports a batch size of 1.");e=e[0]}let n=(await Qe(e))[0],{pixel_values:o}=await this.processor(n),a=`<s_docvqa><s_question>${r}</s_question><s_answer>`,i=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,l=await this.model.generate({inputs:o,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:i,...s}),p=this.tokenizer.batch_decode(l)[0].match(/<s_answer>(.*?)<\/s_answer>/),f=null;return p&&p.length>=2&&(f=p[1].trim()),[{answer:f}]}};var Ci=class extends fe{async _call(e){let r=await Qe(e),s=await this.processor(r),n=await this.model(s),o=[];for(let a of n.reconstruction){let i=a.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");o.push(Ke.fromTensor(i))}return Array.isArray(e)?o:o[0]}};var Pi=class extends fe{async _call(e){let r=await Qe(e),s=await this.processor(r),{predicted_depth:n}=await this.model(s),o=[];for(let a=0;a<r.length;++a){let i=n[a],[l,u]=i.dims.slice(-2),[p,f]=r[a].size,m=(await zt(i.view(1,1,l,u),{size:[f,p],mode:"bilinear"})).view(f,p),h=m.min().item(),w=m.max().item(),x=m.sub(h).div_(w-h).mul_(255).to("uint8").unsqueeze(0),v=Ke.fromTensor(x);o.push({predicted_depth:m,depth:v})}return Array.isArray(e)?o:o[0]}};var Li=class extends fe{async _call(e,{pooling:r="none",normalize:s=!1,quantize:n=!1,precision:o="binary"}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),i=await this.model(a),l=i.last_hidden_state??i.logits??i.token_embeddings;switch(r){case"none":break;case"mean":l=Eb(l,a.attention_mask);break;case"first_token":case"cls":l=l.slice(null,0);break;case"last_token":case"eos":l=l.slice(null,-1);break;default:throw Error(`Pooling method '${r}' not supported.`)}return s&&(l=l.normalize(2,-1)),n&&(l=Tb(l,o)),l}};var Ni=class extends fe{async _call(e,{pool:r=null}={}){let s=await Qe(e),{pixel_values:n}=await this.processor(s),o=await this.model({pixel_values:n}),a;if(r){if(!("pooler_output"in o))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");a=o.pooler_output}else a=o.last_hidden_state??o.logits??o.image_embeds;return a}};var zi=Object.freeze({"text-classification":{pipeline:di,model:li,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:fi,model:Xc,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:mi,model:eu,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:hi,model:Zc,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:_i,model:hn,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:gi,model:hn,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:_r,model:hn,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:wi,model:Jc,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:xi,model:li,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:yi,model:au,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:bi,model:hr,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:vi,model:[Kc,ou],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:ki,model:[Qc,Yc],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:Ei,model:tu,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:Ai,model:ru,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:xs,model:[ci,ui,pi],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:Mi,model:[ci,ui,pi],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:Ti,model:hr,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:Si,model:su,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:Oi,model:nu,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:Ii,model:iu,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Ci,model:lu,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Pi,model:cu,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:Li,model:hr,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:Ni,model:[uu,hr],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),Py=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});async function Ly(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null}={}){e=await Wt.from_pretrained(t,{config:e});let o=["config.json"],a=e["transformers.js_config"]??{},i=a.use_external_data_format,l="onnx",u=s??a.device,p=r??a.dtype,f,m=e.architectures||[],h=!1;for(let v of m){let E=sr.get(v);if(E!==void 0){f=E,h=!0;break}}if(!h&&e.model_type){let v=sr.get(e.model_type);if(v!==void 0&&(f=v,h=!0),!h){for(let E of Object.values(Hs))if(E.has(e.model_type)){f=sr.get(E.get(e.model_type)),h=!0;break}}}if(!h){let v=m.length>0?m.join(", "):"(none)";J.warn(`[get_model_files] Architecture(s) not found in MODEL_TYPE_MAPPING: [${v}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${as}`),f=j.EncoderOnly}let w=(v,E=null)=>{E=E??v;let A=Ju(u,v),S=Zu(p,v,A),T=al[S]??"",L=`${E}${T}.onnx`,P=l?`${l}/${L}`:L;o.push(P);let k=Rb(i,L,v);for(let F of Db(L,k)){let K=l?`${l}/${F}`:F;o.push(K)}},x=n??"model";return f===j.DecoderOnly?(w("model",x),o.push("generation_config.json")):f===j.DecoderOnlyWithoutHead?w("model",x):f===j.Seq2Seq||f===j.Vision2Seq?(w("model","encoder_model"),w("decoder_model_merged"),o.push("generation_config.json")):f===j.MaskGeneration?(w("model","vision_encoder"),w("prompt_encoder_mask_decoder")):f===j.EncoderDecoder?(w("model","encoder_model"),w("decoder_model_merged")):f===j.ImageTextToText?(w("embed_tokens"),w("vision_encoder"),w("decoder_model_merged"),e.is_encoder_decoder&&w("model","encoder_model"),o.push("generation_config.json")):f===j.AudioTextToText?(w("embed_tokens"),w("audio_encoder"),w("decoder_model_merged"),o.push("generation_config.json")):f===j.ImageAudioTextToText?(w("embed_tokens"),w("audio_encoder"),w("vision_encoder"),w("decoder_model_merged"),o.push("generation_config.json")):f===j.Musicgen?(w("model","text_encoder"),w("decoder_model_merged"),w("encodec_decode"),o.push("generation_config.json")):f===j.MultiModality?(w("prepare_inputs_embeds"),w("model","language_model"),w("lm_head"),w("gen_head"),w("gen_img_embeds"),w("image_decode"),o.push("generation_config.json")):f===j.Phi3V?(w("prepare_inputs_embeds"),w("model"),w("vision_encoder"),o.push("generation_config.json")):f===j.Chatterbox?(w("embed_tokens"),w("speech_encoder"),w("model","language_model"),w("conditional_decoder"),o.push("generation_config.json")):f===j.AutoEncoder?(w("encoder_model"),w("decoder_model")):f===j.Supertonic?(w("text_encoder"),w("latent_denoiser"),w("voice_decoder")):w("model",x),o}async function Ny(t){if(!t)throw new Error("modelId is required");return(await pr(t,Mr,{})).exists?[Mr]:[]}async function jr(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null,include_tokenizer:o=!0,include_processor:a=!0}={}){let i=await Ly(t,{config:e,dtype:r,device:s,model_file_name:n});if(o){let l=await zn(t);i.push(...l)}if(a){let l=await Ny(t);i.push(...l)}return i}async function Gr(t,e,r={}){t=Py[t]??t;let s=zi[t];if(!s)throw new Error(`Unsupported pipeline task: ${t}. Must be one of [${Object.keys(zi).join(", ")}]`);let{type:n}=s;return jr(e,{...r,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"})}async function mN(t,e=null,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",device:i=null,dtype:l=null,subfolder:u="onnx",use_external_data_format:p=null,model_file_name:f=null,session_options:m={}}={}){t=Py[t]??t;let h=zi[t.split("_",1)[0]];if(!h)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(zi)}]`);e||(e=h.default.model,J.info(`No model specified. Using default model: "${e}".`),!l&&h.default.dtype&&(l=h.default.dtype));let w=await Gr(t,e,{device:i,dtype:l}),x={};r&&(await Promise.all(w.map(async X=>pr(e,X)))).forEach((X,H)=>{X.exists&&(x[w[H]]={loaded:0,total:X.size??0})});let v={progress_callback:r?W=>{if(W.status==="progress"){x[W.file]={loaded:W.loaded,total:W.total};let X=Object.values(x).reduce((U,C)=>U+C.loaded,0),H=Object.values(x).reduce((U,C)=>U+C.total,0),Y=H>0?X/H*100:0;r({status:"progress_total",name:W.name,progress:Y,loaded:X,total:H,files:structuredClone(x)})}r(W)}:void 0,config:s,cache_dir:n,local_files_only:o,revision:a,device:i,dtype:l,subfolder:u,use_external_data_format:p,model_file_name:f,session_options:m},E=w.includes("tokenizer.json"),A=w.includes("preprocessor_config.json"),S=h.model,T;if(Array.isArray(S)){let W=s??await Wt.from_pretrained(e,v),{model_type:X}=W,H=S.find(Y=>Y.supports(X));if(!H)throw Error(`Unsupported model type "${X}" for task "${t}". None of the candidate model classes support this type.`);T=H.from_pretrained(e,{...v,config:W})}else T=S.from_pretrained(e,v);let[L,P,k]=await Promise.all([E?ce.from_pretrained(e,v):null,A?Cl.from_pretrained(e,v):null,T]),F={task:t,model:k};L&&(F.tokenizer=L),P&&(F.processor=P),Er(r,{status:"ready",task:t,model:e});let K=h.pipeline;return new K(F)}var hN=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,zy=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},Y2=se.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),$y=class extends zy{constructor(e,{skip_prompt:r=!1,callback_function:s=null,token_callback_function:n=null,skip_special_tokens:o=!0,decode_kwargs:a={},...i}={}){super(),this.tokenizer=e,this.skip_prompt=r,this.callback_function=s??Y2,this.token_callback_function=n,this.decode_kwargs={skip_special_tokens:o,...a,...i},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0,this.special_ids=new Set(this.tokenizer.all_special_ids.map(BigInt))}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");let r=this.next_tokens_are_prompt;if(r&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let s=e[0];if(this.token_callback_function?.(s),s.length===1&&this.special_ids.has(s[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let l=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(l,!1),this.token_cache=[],this.print_len=0}let a=this.tokenizer.decode(s,this.decode_kwargs);this.on_finalized_text(a,!1);return}this.token_cache=ft(this.token_cache,s);let n=this.tokenizer.decode(this.token_cache,this.decode_kwargs),o;r||n.endsWith(`
|
|
26
|
-
`)?(o=n.slice(this.print_len),this.token_cache=[],this.print_len=0):n.length>0&&
|
|
27
|
-
`)}},s1=class extends $y{constructor(e,{skip_prompt:r=!1,callback_function:s=null,token_callback_function:n=null,on_chunk_start:o=null,on_chunk_end:a=null,on_finalize:i=null,time_precision:l=.02,skip_special_tokens:u=!0,decode_kwargs:p={}}={}){super(e,{skip_prompt:r,skip_special_tokens:u,callback_function:s,token_callback_function:n,decode_kwargs:p}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=o,this.on_chunk_end=a,this.on_finalize=i,this.time_precision=l,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");let r=e[0];if(r.length===1){let s=Number(r[0])-this.timestamp_begin;if(s>=0){let n=s*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(n):this.on_chunk_start?.(n),this.waiting_for_timestamp=!this.waiting_for_timestamp,this.token_callback_function?.(r);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}};var $i=class{constructor(e,r){this.image=e,this.timestamp=r}},du=class{constructor(e,r){e.length>0&&e[0]instanceof Ke&&(e=e.map((s,n)=>new $i(s,(n+1)/(e.length+1)*r))),this.frames=e,this.duration=r}get width(){return this.frames[0].image.width}get height(){return this.frames[0].image.height}get fps(){return this.frames.length/this.duration}};async function Q2(t,{num_frames:e=null,fps:r=null}={}){if(!se.IS_BROWSER_ENV)throw new Error("`load_video` is currently only supported in browser environments.");if(e==null&&r==null)throw new Error("Either num_frames or fps must be provided.");let s=[],n=document.createElement("video");if(n.crossOrigin="anonymous",n.muted=!0,typeof t=="string")n.src=t;else if(t instanceof Blob)n.src=URL.createObjectURL(t);else if(t instanceof HTMLVideoElement)n.src=t.src;else throw new Error("Invalid URL or video element provided.");if(await new Promise(f=>n.onloadedmetadata=f),n.seekable.start(0)===n.seekable.end(0)){let m=await(await me.fetch(n.src)).blob();n.src=URL.createObjectURL(m),await new Promise(h=>n.onloadedmetadata=h)}let o=n.duration,a,i;e!=null?(a=e,i=e===1?0:o/(e-1)):(i=1/r,a=Math.floor(o/i));let l=[];for(let f=0;f<a;++f)l.push(e===1?o/2:f*i);let u=document.createElement("canvas");u.width=n.videoWidth,u.height=n.videoHeight;let p=u.getContext("2d",{willReadFrequently:!0});for(let f of l){n.currentTime=f,await new Promise(x=>{n.onseeked=x}),p.drawImage(n,0,0,u.width,u.height);let m=p.getImageData(0,0,u.width,u.height),h=new Ke(m.data,u.width,u.height,4),w=new $i(h,f);s.push(w)}return n.remove(),new du(s,o)}async function Ry(t,e,r={}){let s=await er(r?.cache_dir);if(!s)return{allCached:!1,files:e.map(a=>({file:a,cached:!1}))};let n=await Promise.all(e.map(async o=>{let{localPath:a,proposedCacheKey:i}=Qr(t,o,r,s),l=await Jr(s,a,i);return{file:o,cached:!!l}}));return{allCached:n.every(o=>o.cached),files:n}}async function J2(t,e,r={}){let s=await er(r?.cache_dir);if(!s)return!1;let{localPath:n,proposedCacheKey:o}=Qr(t,e,r,s);return!!await Jr(s,n,o)}async function Z2(t,e={}){if(!t)throw new Error("modelId is required");if(!await J2(t,"config.json",e))return!1;let r=await jr(t,e);return(await Ry(t,r,e)).allCached}async function eM(t,e={}){if(!t)throw new Error("modelId is required");let r=await jr(t,e);return await Ry(t,r,e)}async function tM(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");if(!await J2(e,"config.json",r))return!1;let s=await Gr(t,e,r);return(await Ry(e,s,r)).allCached}async function rM(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Gr(t,e,r);return await Ry(e,s,r)}async function sM(t,e,r={}){let s=await er(r?.cache_dir);if(!s)return{filesDeleted:0,filesCached:0,files:e.map(o=>({file:o,deleted:!1,wasCached:!1}))};if(!s.delete)throw new Error("Cache does not support delete operation");let n=await Promise.all(e.map(async o=>{let{localPath:a,proposedCacheKey:i}=Qr(t,o,r,s),u=!!await Jr(s,a,i),p=!1;if(u){let f=await s.delete(i),m=!f&&i!==a?await s.delete(a):!1;p=f||m}return{file:o,deleted:p,wasCached:u}}));return{filesDeleted:n.filter(o=>o.deleted).length,filesCached:n.filter(o=>o.wasCached).length,files:n}}async function nM(t,e={}){if(!t)throw new Error("modelId is required");let r=await jr(t,e);return await sM(t,r,e)}async function oM(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Gr(t,e,r);return await sM(e,s,r)}var Dy=class{static async get_files(e,r={}){return jr(e,r)}static async get_pipeline_files(e,r,s={}){return Gr(e,r,s)}static async get_model_files(e,r={}){return Ly(e,r)}static async get_tokenizer_files(e){return zn(e)}static async get_processor_files(e){return Ny(e)}static async is_cached(e,r={}){return Z2(e,r)}static async is_cached_files(e,r={}){return eM(e,r)}static async is_pipeline_cached(e,r,s={}){return tM(e,r,s)}static async is_pipeline_cached_files(e,r,s={}){return rM(e,r,s)}static async get_file_metadata(e,r,s={}){return pr(e,r,s)}static async clear_cache(e,r={}){return nM(e,r)}static async clear_pipeline_cache(e,r,s={}){return oM(e,r,s)}};0&&(module.exports={ASTFeatureExtractor,ASTForAudioClassification,ASTModel,ASTPreTrainedModel,AfmoeForCausalLM,AfmoeModel,AfmoePreTrainedModel,AlbertForMaskedLM,AlbertForQuestionAnswering,AlbertForSequenceClassification,AlbertModel,AlbertPreTrainedModel,AlbertTokenizer,ApertusForCausalLM,ApertusModel,ApertusPreTrainedModel,ArceeForCausalLM,ArceeModel,ArceePreTrainedModel,AudioClassificationPipeline,AutoConfig,AutoFeatureExtractor,AutoImageProcessor,AutoModel,AutoModelForAudioClassification,AutoModelForAudioFrameClassification,AutoModelForAudioTextToText,AutoModelForCTC,AutoModelForCausalLM,AutoModelForDepthEstimation,AutoModelForDocumentQuestionAnswering,AutoModelForImageClassification,AutoModelForImageFeatureExtraction,AutoModelForImageMatting,AutoModelForImageSegmentation,AutoModelForImageTextToText,AutoModelForImageToImage,AutoModelForMaskGeneration,AutoModelForMaskedLM,AutoModelForNormalEstimation,AutoModelForObjectDetection,AutoModelForPoseEstimation,AutoModelForQuestionAnswering,AutoModelForSemanticSegmentation,AutoModelForSeq2SeqLM,AutoModelForSequenceClassification,AutoModelForSpeechSeq2Seq,AutoModelForTextToSpectrogram,AutoModelForTextToWaveform,AutoModelForTokenClassification,AutoModelForUniversalSegmentation,AutoModelForVision2Seq,AutoModelForXVector,AutoModelForZeroShotObjectDetection,AutoProcessor,AutoTokenizer,AutomaticSpeechRecognitionPipeline,BackgroundRemovalPipeline,BartForConditionalGeneration,BartForSequenceClassification,BartModel,BartPretrainedModel,BartTokenizer,BaseStreamer,BeitFeatureExtractor,BeitForImageClassification,BeitModel,BeitPreTrainedModel,BertForMaskedLM,BertForQuestionAnswering,BertForSequenceClassification,BertForTokenClassification,BertModel,BertPreTrainedModel,BertTokenizer,BitImageProcessor,BlenderbotForConditionalGeneration,BlenderbotModel,BlenderbotPreTrainedModel,BlenderbotSmallForConditionalGeneration,BlenderbotSmallModel,BlenderbotSmallPreTrainedModel,BlenderbotSmallTokenizer,BlenderbotTokenizer,BloomForCausalLM,BloomModel,BloomPreTrainedModel,BloomTokenizer,CLIPFeatureExtractor,CLIPImageProcessor,CLIPModel,CLIPPreTrainedModel,CLIPSegForImageSegmentation,CLIPSegModel,CLIPSegPreTrainedModel,CLIPTextModel,CLIPTextModelWithProjection,CLIPTokenizer,CLIPVisionModel,CLIPVisionModelWithProjection,CamembertForMaskedLM,CamembertForQuestionAnswering,CamembertForSequenceClassification,CamembertForTokenClassification,CamembertModel,CamembertPreTrainedModel,CamembertTokenizer,ChatterboxFeatureExtractor,ChatterboxModel,ChatterboxPreTrainedModel,ChatterboxProcessor,ChineseCLIPFeatureExtractor,ChineseCLIPModel,ChineseCLIPPreTrainedModel,ClapAudioModelWithProjection,ClapFeatureExtractor,ClapModel,ClapPreTrainedModel,ClapTextModelWithProjection,ClassifierFreeGuidanceLogitsProcessor,CodeGenForCausalLM,CodeGenModel,CodeGenPreTrainedModel,CodeGenTokenizer,CodeLlamaTokenizer,Cohere2ForCausalLM,Cohere2Model,Cohere2PreTrainedModel,CohereForCausalLM,CohereModel,CoherePreTrainedModel,CohereTokenizer,ConvBertForMaskedLM,ConvBertForQuestionAnswering,ConvBertForSequenceClassification,ConvBertForTokenClassification,ConvBertModel,ConvBertPreTrainedModel,ConvBertTokenizer,ConvNextFeatureExtractor,ConvNextForImageClassification,ConvNextImageProcessor,ConvNextModel,ConvNextPreTrainedModel,ConvNextV2ForImageClassification,ConvNextV2Model,ConvNextV2PreTrainedModel,DFineForObjectDetection,DFineModel,DFinePreTrainedModel,DINOv3ConvNextModel,DINOv3ConvNextPreTrainedModel,DINOv3ViTImageProcessor,DINOv3ViTModel,DINOv3ViTPreTrainedModel,DPTFeatureExtractor,DPTForDepthEstimation,DPTImageProcessor,DPTModel,DPTPreTrainedModel,DacDecoderModel,DacDecoderOutput,DacEncoderModel,DacEncoderOutput,DacFeatureExtractor,DacModel,DacPreTrainedModel,DebertaForMaskedLM,DebertaForQuestionAnswering,DebertaForSequenceClassification,DebertaForTokenClassification,DebertaModel,DebertaPreTrainedModel,DebertaTokenizer,DebertaV2ForMaskedLM,DebertaV2ForQuestionAnswering,DebertaV2ForSequenceClassification,DebertaV2ForTokenClassification,DebertaV2Model,DebertaV2PreTrainedModel,DebertaV2Tokenizer,DecisionTransformerModel,DecisionTransformerPreTrainedModel,DeiTFeatureExtractor,DeiTForImageClassification,DeiTImageProcessor,DeiTModel,DeiTPreTrainedModel,DepthAnythingForDepthEstimation,DepthAnythingPreTrainedModel,DepthEstimationPipeline,DepthProForDepthEstimation,DepthProPreTrainedModel,DetrFeatureExtractor,DetrForObjectDetection,DetrForSegmentation,DetrImageProcessor,DetrModel,DetrObjectDetectionOutput,DetrPreTrainedModel,DetrSegmentationOutput,Dinov2ForImageClassification,Dinov2Model,Dinov2PreTrainedModel,Dinov2WithRegistersForImageClassification,Dinov2WithRegistersModel,Dinov2WithRegistersPreTrainedModel,DistilBertForMaskedLM,DistilBertForQuestionAnswering,DistilBertForSequenceClassification,DistilBertForTokenClassification,DistilBertModel,DistilBertPreTrainedModel,DistilBertTokenizer,DocumentQuestionAnsweringPipeline,DonutFeatureExtractor,DonutImageProcessor,DonutSwinModel,DonutSwinPreTrainedModel,EdgeTamModel,EfficientNetForImageClassification,EfficientNetImageProcessor,EfficientNetModel,EfficientNetPreTrainedModel,ElectraForMaskedLM,ElectraForQuestionAnswering,ElectraForSequenceClassification,ElectraForTokenClassification,ElectraModel,ElectraPreTrainedModel,ElectraTokenizer,EncodecFeatureExtractor,EosTokenCriteria,Ernie4_5ForCausalLM,Ernie4_5Model,Ernie4_5PretrainedModel,EsmForMaskedLM,EsmForSequenceClassification,EsmForTokenClassification,EsmModel,EsmPreTrainedModel,EsmTokenizer,ExaoneForCausalLM,ExaoneModel,ExaonePreTrainedModel,FalconForCausalLM,FalconH1ForCausalLM,FalconH1Model,FalconH1PreTrainedModel,FalconModel,FalconPreTrainedModel,FalconTokenizer,FastViTForImageClassification,FastViTModel,FastViTPreTrainedModel,FeatureExtractionPipeline,FeatureExtractor,FillMaskPipeline,Florence2ForConditionalGeneration,Florence2PreTrainedModel,Florence2Processor,ForcedBOSTokenLogitsProcessor,ForcedEOSTokenLogitsProcessor,GLPNFeatureExtractor,GLPNForDepthEstimation,GLPNModel,GLPNPreTrainedModel,GPT2LMHeadModel,GPT2Model,GPT2PreTrainedModel,GPT2Tokenizer,GPTBigCodeForCausalLM,GPTBigCodeModel,GPTBigCodePreTrainedModel,GPTJForCausalLM,GPTJModel,GPTJPreTrainedModel,GPTNeoForCausalLM,GPTNeoModel,GPTNeoPreTrainedModel,GPTNeoXForCausalLM,GPTNeoXModel,GPTNeoXPreTrainedModel,GPTNeoXTokenizer,Gemma2ForCausalLM,Gemma2Model,Gemma2PreTrainedModel,Gemma3ForCausalLM,Gemma3Model,Gemma3PreTrainedModel,Gemma3nAudioFeatureExtractor,Gemma3nForConditionalGeneration,Gemma3nPreTrainedModel,Gemma3nProcessor,GemmaForCausalLM,GemmaModel,GemmaPreTrainedModel,GemmaTokenizer,GlmForCausalLM,GlmModel,GlmPreTrainedModel,GptOssForCausalLM,GptOssModel,GptOssPreTrainedModel,GraniteForCausalLM,GraniteModel,GraniteMoeHybridForCausalLM,GraniteMoeHybridModel,GraniteMoeHybridPreTrainedModel,GranitePreTrainedModel,GroundingDinoForObjectDetection,GroundingDinoImageProcessor,GroundingDinoPreTrainedModel,GroundingDinoProcessor,GroupViTModel,GroupViTPreTrainedModel,HeliumForCausalLM,HeliumModel,HeliumPreTrainedModel,HerbertTokenizer,HieraForImageClassification,HieraModel,HieraPreTrainedModel,HubertForCTC,HubertForSequenceClassification,HubertModel,HubertPreTrainedModel,HunYuanDenseV1ForCausalLM,HunYuanDenseV1Model,HunYuanDenseV1PreTrainedModel,IJepaForImageClassification,IJepaModel,IJepaPreTrainedModel,Idefics3ForConditionalGeneration,Idefics3ImageProcessor,Idefics3PreTrainedModel,Idefics3Processor,ImageClassificationPipeline,ImageFeatureExtractionPipeline,ImageFeatureExtractor,ImageProcessor,ImageSegmentationPipeline,ImageToImagePipeline,ImageToTextPipeline,InterruptableStoppingCriteria,JAISLMHeadModel,JAISModel,JAISPreTrainedModel,JinaCLIPImageProcessor,JinaCLIPModel,JinaCLIPPreTrainedModel,JinaCLIPProcessor,JinaCLIPTextModel,JinaCLIPVisionModel,Lfm2ForCausalLM,Lfm2Model,Lfm2MoeForCausalLM,Lfm2MoeModel,Lfm2MoePreTrainedModel,Lfm2PreTrainedModel,LiteWhisperForConditionalGeneration,Llama4ForCausalLM,Llama4PreTrainedModel,LlamaForCausalLM,LlamaModel,LlamaPreTrainedModel,LlamaTokenizer,LlavaForConditionalGeneration,LlavaOnevisionForConditionalGeneration,LlavaOnevisionImageProcessor,LlavaPreTrainedModel,LlavaProcessor,LlavaQwen2ForCausalLM,LogLevel,LogitsProcessor,LogitsProcessorList,LogitsWarper,LongT5ForConditionalGeneration,LongT5Model,LongT5PreTrainedModel,M2M100ForConditionalGeneration,M2M100Model,M2M100PreTrainedModel,M2M100Tokenizer,MBart50Tokenizer,MBartForCausalLM,MBartForConditionalGeneration,MBartForSequenceClassification,MBartModel,MBartPreTrainedModel,MBartTokenizer,MPNetForMaskedLM,MPNetForQuestionAnswering,MPNetForSequenceClassification,MPNetForTokenClassification,MPNetModel,MPNetPreTrainedModel,MPNetTokenizer,MT5ForConditionalGeneration,MT5Model,MT5PreTrainedModel,MarianMTModel,MarianModel,MarianPreTrainedModel,MarianTokenizer,Mask2FormerImageProcessor,MaskFormerFeatureExtractor,MaskFormerForInstanceSegmentation,MaskFormerImageProcessor,MaskFormerModel,MaskFormerPreTrainedModel,MaxLengthCriteria,Metric3DForDepthEstimation,Metric3DPreTrainedModel,Metric3Dv2ForDepthEstimation,Metric3Dv2PreTrainedModel,MgpstrForSceneTextRecognition,MgpstrModelOutput,MgpstrPreTrainedModel,MgpstrProcessor,MgpstrTokenizer,MimiDecoderModel,MimiDecoderOutput,MimiEncoderModel,MimiEncoderOutput,MimiModel,MimiPreTrainedModel,MinLengthLogitsProcessor,MinNewTokensLengthLogitsProcessor,MistralForCausalLM,MistralModel,MistralPreTrainedModel,MobileBertForMaskedLM,MobileBertForQuestionAnswering,MobileBertForSequenceClassification,MobileBertModel,MobileBertPreTrainedModel,MobileBertTokenizer,MobileLLMForCausalLM,MobileLLMModel,MobileLLMPreTrainedModel,MobileNetV1FeatureExtractor,MobileNetV1ForImageClassification,MobileNetV1ForSemanticSegmentation,MobileNetV1ImageProcessor,MobileNetV1Model,MobileNetV1PreTrainedModel,MobileNetV2FeatureExtractor,MobileNetV2ForImageClassification,MobileNetV2ForSemanticSegmentation,MobileNetV2ImageProcessor,MobileNetV2Model,MobileNetV2PreTrainedModel,MobileNetV3FeatureExtractor,MobileNetV3ForImageClassification,MobileNetV3ForSemanticSegmentation,MobileNetV3ImageProcessor,MobileNetV3Model,MobileNetV3PreTrainedModel,MobileNetV4FeatureExtractor,MobileNetV4ForImageClassification,MobileNetV4ForSemanticSegmentation,MobileNetV4ImageProcessor,MobileNetV4Model,MobileNetV4PreTrainedModel,MobileViTFeatureExtractor,MobileViTForImageClassification,MobileViTImageProcessor,MobileViTModel,MobileViTPreTrainedModel,MobileViTV2ForImageClassification,MobileViTV2Model,MobileViTV2PreTrainedModel,ModelRegistry,ModernBertDecoderForCausalLM,ModernBertDecoderModel,ModernBertDecoderPreTrainedModel,ModernBertForMaskedLM,ModernBertForSequenceClassification,ModernBertForTokenClassification,ModernBertModel,ModernBertPreTrainedModel,Moondream1ForConditionalGeneration,MoonshineFeatureExtractor,MoonshineForConditionalGeneration,MoonshineModel,MoonshinePreTrainedModel,MoonshineProcessor,MptForCausalLM,MptModel,MptPreTrainedModel,MultiModalityCausalLM,MultiModalityPreTrainedModel,MusicgenForCausalLM,MusicgenForConditionalGeneration,MusicgenModel,MusicgenPreTrainedModel,NanoChatForCausalLM,NanoChatModel,NanoChatPreTrainedModel,NeoBertForMaskedLM,NeoBertForQuestionAnswering,NeoBertForSequenceClassification,NeoBertForTokenClassification,NeoBertModel,NeoBertPreTrainedModel,NllbTokenizer,NoBadWordsLogitsProcessor,NoRepeatNGramLogitsProcessor,NomicBertModel,NomicBertPreTrainedModel,NougatImageProcessor,NougatTokenizer,OPTForCausalLM,OPTModel,OPTPreTrainedModel,ObjectDetectionPipeline,Olmo2ForCausalLM,Olmo2Model,Olmo2PreTrainedModel,Olmo3ForCausalLM,Olmo3Model,Olmo3PreTrainedModel,OlmoForCausalLM,OlmoHybridForCausalLM,OlmoHybridModel,OlmoHybridPreTrainedModel,OlmoModel,OlmoPreTrainedModel,OpenELMForCausalLM,OpenELMModel,OpenELMPreTrainedModel,OwlViTFeatureExtractor,OwlViTForObjectDetection,OwlViTImageProcessor,OwlViTModel,OwlViTPreTrainedModel,OwlViTProcessor,Owlv2ForObjectDetection,Owlv2ImageProcessor,Owlv2Model,Owlv2PreTrainedModel,PaliGemmaForConditionalGeneration,PaliGemmaPreTrainedModel,PaliGemmaProcessor,ParakeetFeatureExtractor,ParakeetForCTC,ParakeetPreTrainedModel,PatchTSMixerForPrediction,PatchTSMixerModel,PatchTSMixerPreTrainedModel,PatchTSTForPrediction,PatchTSTModel,PatchTSTPreTrainedModel,Phi3ForCausalLM,Phi3Model,Phi3PreTrainedModel,Phi3VForCausalLM,Phi3VImageProcessor,Phi3VPreTrainedModel,Phi3VProcessor,PhiForCausalLM,PhiModel,PhiPreTrainedModel,PixtralImageProcessor,PixtralProcessor,PreTrainedModel,PreTrainedTokenizer,PretrainedConfig,Processor,PvtForImageClassification,PvtImageProcessor,PvtModel,PvtPreTrainedModel,PyAnnoteFeatureExtractor,PyAnnoteForAudioFrameClassification,PyAnnoteModel,PyAnnotePreTrainedModel,PyAnnoteProcessor,QuestionAnsweringPipeline,Qwen2ForCausalLM,Qwen2Model,Qwen2MoeForCausalLM,Qwen2MoeModel,Qwen2MoePreTrainedModel,Qwen2PreTrainedModel,Qwen2Tokenizer,Qwen2VLForConditionalGeneration,Qwen2VLImageProcessor,Qwen2VLPreTrainedModel,Qwen2VLProcessor,Qwen2_5_VLForConditionalGeneration,Qwen2_5_VLProcessor,Qwen3ForCausalLM,Qwen3Model,Qwen3MoeForCausalLM,Qwen3MoeModel,Qwen3MoePreTrainedModel,Qwen3NextForCausalLM,Qwen3NextModel,Qwen3NextPreTrainedModel,Qwen3PreTrainedModel,Qwen3VLForConditionalGeneration,Qwen3VLMoeForConditionalGeneration,Qwen3VLProcessor,Qwen3_5ForConditionalGeneration,Qwen3_5MoeForConditionalGeneration,RFDetrForObjectDetection,RFDetrModel,RFDetrObjectDetectionOutput,RFDetrPreTrainedModel,RTDetrForObjectDetection,RTDetrImageProcessor,RTDetrModel,RTDetrObjectDetectionOutput,RTDetrPreTrainedModel,RTDetrV2ForObjectDetection,RTDetrV2Model,RTDetrV2ObjectDetectionOutput,RTDetrV2PreTrainedModel,RawAudio,RawImage,RawVideo,RawVideoFrame,RepetitionPenaltyLogitsProcessor,ResNetForImageClassification,ResNetModel,ResNetPreTrainedModel,RoFormerForMaskedLM,RoFormerForQuestionAnswering,RoFormerForSequenceClassification,RoFormerForTokenClassification,RoFormerModel,RoFormerPreTrainedModel,RoFormerTokenizer,RobertaForMaskedLM,RobertaForQuestionAnswering,RobertaForSequenceClassification,RobertaForTokenClassification,RobertaModel,RobertaPreTrainedModel,RobertaTokenizer,Sam2ImageProcessor,Sam2ImageSegmentationOutput,Sam2Model,Sam2PreTrainedModel,Sam2Processor,Sam2VideoProcessor,Sam3ImageProcessor,Sam3TrackerModel,SamImageProcessor,SamImageSegmentationOutput,SamModel,SamPreTrainedModel,SamProcessor,SapiensFeatureExtractor,SapiensForDepthEstimation,SapiensForNormalEstimation,SapiensForSemanticSegmentation,SapiensImageProcessor,SapiensPreTrainedModel,SeamlessM4TFeatureExtractor,SegformerFeatureExtractor,SegformerForImageClassification,SegformerForSemanticSegmentation,SegformerImageProcessor,SegformerModel,SegformerPreTrainedModel,SiglipImageProcessor,SiglipModel,SiglipPreTrainedModel,SiglipTextModel,SiglipTokenizer,SiglipVisionModel,SmolLM3ForCausalLM,SmolLM3Model,SmolLM3PreTrainedModel,SmolVLMForConditionalGeneration,SmolVLMImageProcessor,SmolVLMProcessor,SnacDecoderModel,SnacEncoderModel,SnacFeatureExtractor,SnacModel,SnacPreTrainedModel,SpeechT5FeatureExtractor,SpeechT5ForSpeechToText,SpeechT5ForTextToSpeech,SpeechT5HifiGan,SpeechT5Model,SpeechT5PreTrainedModel,SpeechT5Processor,SpeechT5Tokenizer,SqueezeBertForMaskedLM,SqueezeBertForQuestionAnswering,SqueezeBertForSequenceClassification,SqueezeBertModel,SqueezeBertPreTrainedModel,SqueezeBertTokenizer,StableLmForCausalLM,StableLmModel,StableLmPreTrainedModel,Starcoder2ForCausalLM,Starcoder2Model,Starcoder2PreTrainedModel,StoppingCriteria,StoppingCriteriaList,StyleTextToSpeech2Model,StyleTextToSpeech2PreTrainedModel,SummarizationPipeline,SupertonicForConditionalGeneration,SupertonicPreTrainedModel,SuppressTokensAtBeginLogitsProcessor,Swin2SRForImageSuperResolution,Swin2SRImageProcessor,Swin2SRModel,Swin2SRPreTrainedModel,SwinForImageClassification,SwinForSemanticSegmentation,SwinModel,SwinPreTrainedModel,T5ForConditionalGeneration,T5Model,T5PreTrainedModel,T5Tokenizer,TableTransformerForObjectDetection,TableTransformerModel,TableTransformerObjectDetectionOutput,TableTransformerPreTrainedModel,TemperatureLogitsWarper,Tensor,Text2TextGenerationPipeline,TextClassificationPipeline,TextGenerationPipeline,TextStreamer,TextToAudioPipeline,TokenClassificationPipeline,TokenizersBackend,TopKLogitsWarper,TopPLogitsWarper,TrOCRForCausalLM,TrOCRPreTrainedModel,TranslationPipeline,UltravoxModel,UltravoxPreTrainedModel,UltravoxProcessor,UniSpeechForCTC,UniSpeechForSequenceClassification,UniSpeechModel,UniSpeechPreTrainedModel,UniSpeechSatForAudioFrameClassification,UniSpeechSatForCTC,UniSpeechSatForSequenceClassification,UniSpeechSatModel,UniSpeechSatPreTrainedModel,VLChatProcessor,VLMImageProcessor,VaultGemmaForCausalLM,VaultGemmaModel,VaultGemmaPreTrainedModel,ViTFeatureExtractor,ViTForImageClassification,ViTImageProcessor,ViTMAEModel,ViTMAEPreTrainedModel,ViTMSNForImageClassification,ViTMSNModel,ViTMSNPreTrainedModel,ViTModel,ViTPreTrainedModel,VisionEncoderDecoderModel,VitMatteForImageMatting,VitMatteImageProcessor,VitMattePreTrainedModel,VitPoseForPoseEstimation,VitPoseImageProcessor,VitPosePreTrainedModel,VitsModel,VitsModelOutput,VitsPreTrainedModel,VitsTokenizer,VoxtralForConditionalGeneration,VoxtralProcessor,Wav2Vec2BertForCTC,Wav2Vec2BertForSequenceClassification,Wav2Vec2BertModel,Wav2Vec2BertPreTrainedModel,Wav2Vec2CTCTokenizer,Wav2Vec2FeatureExtractor,Wav2Vec2ForAudioFrameClassification,Wav2Vec2ForCTC,Wav2Vec2ForSequenceClassification,Wav2Vec2Model,Wav2Vec2PreTrainedModel,Wav2Vec2Processor,Wav2Vec2ProcessorWithLM,WavLMForAudioFrameClassification,WavLMForCTC,WavLMForSequenceClassification,WavLMForXVector,WavLMModel,WavLMPreTrainedModel,WeSpeakerFeatureExtractor,WeSpeakerResNetModel,WeSpeakerResNetPreTrainedModel,WhisperFeatureExtractor,WhisperForConditionalGeneration,WhisperModel,WhisperPreTrainedModel,WhisperProcessor,WhisperTextStreamer,WhisperTimeStampLogitsProcessor,WhisperTokenizer,XLMForQuestionAnswering,XLMForSequenceClassification,XLMForTokenClassification,XLMModel,XLMPreTrainedModel,XLMRobertaForMaskedLM,XLMRobertaForQuestionAnswering,XLMRobertaForSequenceClassification,XLMRobertaForTokenClassification,XLMRobertaModel,XLMRobertaPreTrainedModel,XLMRobertaTokenizer,XLMTokenizer,XLMWithLMHeadModel,XVectorOutput,YolosFeatureExtractor,YolosForObjectDetection,YolosImageProcessor,YolosModel,YolosObjectDetectionOutput,YolosPreTrainedModel,YoutuForCausalLM,YoutuModel,YoutuPreTrainedModel,ZeroShotAudioClassificationPipeline,ZeroShotClassificationPipeline,ZeroShotImageClassificationPipeline,ZeroShotObjectDetectionPipeline,cat,cos_sim,dot,env,full,full_like,interpolate,interpolate_4d,layer_norm,load_image,load_video,log_softmax,matmul,mean,mean_pooling,ones,ones_like,permute,pipeline,quantize_embeddings,rand,randn,random,read_audio,rfft,slice,softmax,stack,std_mean,topk,zeros,zeros_like});
|
|
23
|
+
${s}${o}`+n.repeat(t)+`${s}`,a}function Zz(t,e,r,s){return`${e}${s}`+r.repeat(t)+`${e}`}function eN(t,e,r,s,n,o){return t===0&&e===0?Zz(r,s,n,o):Jz(r,t,e,s,n,o)}var Yl=class extends re{static image_processor_class=Te;static tokenizer_class=oe;static uses_processor_config=!0;fake_image_token="<fake_token_around_image>";image_token="<image>";global_img_token="<global-img>";async _call(e,r=null,s={}){s.return_row_col_info??=!0;let n;r&&(n=await this.image_processor(r,s)),Array.isArray(e)||(e=[e]);let o=n.rows??[new Array(e.length).fill(0)],a=n.cols??[new Array(e.length).fill(0)],i=this.config.image_seq_len,l=[],c=[];for(let d=0;d<e.length;++d){let _=e[d],m=o[d],w=a[d];l.push(mE(_,this.image_token));let x=m.map((A,T)=>eN(A,w[T],i,this.fake_image_token,this.image_token,this.global_img_token)),E=_.split(this.image_token);if(E.length===0)throw new Error("The image token should be present in the text.");let k=E[0];for(let A=0;A<x.length;++A)k+=x[A]+E[A+1];c.push(k)}return{...this.tokenizer(c),...n}}};var Tf=class extends re{static image_processor_class=Te;static tokenizer_class=oe;static uses_processor_config=!0;constructor(e,r,s){super(e,r,s),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:r=null,chat_template:s="default"}={}){r?Array.isArray(r)||(r=[r]):r=await Promise.all(e.filter(E=>E.images).flatMap(E=>E.images).map(E=>Ke.read(E)));let n=this.tokenizer,o=n.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:s}),a=E=>n.encode(E,{add_special_tokens:!1}),i=o.split(this.image_tag),l=i.length-1;if(r.length!==l)throw new Error(`Number of images provided (${r.length}) does not match number of "${this.image_tag}" image tags (${l})`);let[c,p,d]=n.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),_=a(i[0]),m=new Array(_.length).fill(!1);for(let E=1;E<i.length;++E){let k=new Array(this.num_image_tokens).fill(c),A=a(i[E]);_=ht(_,[p],k,[d],A);let T=new Array(this.num_image_tokens).fill(!0);m=ht(m,[!1],T,[!1],new Array(A.length).fill(!1))}let w=[1,_.length],x={input_ids:new N("int64",_,w),attention_mask:new N("int64",new Array(_.length).fill(1),w),images_seq_mask:new N("bool",m,w),images_emb_mask:new N("bool",new Array(l*this.num_image_tokens).fill(!0),[1,l,this.num_image_tokens])};if(r&&r.length>0){let E=await this.image_processor(r);return E.pixel_values.unsqueeze_(0),{...x,...E}}return x}};var Of=class extends re{static tokenizer_class=oe;static image_processor_class=Te;async _call(e=null,r=null,s={}){if(!e&&!r)throw new Error("Either text or images must be provided");let n=e?this.tokenizer(e,s):{},o=r?await this.image_processor(r,s):{};return{...n,...o}}};var If=class extends re{static tokenizer_class=oe;static image_processor_class=Te;async _call(e,r=null,s={}){let{image_rows:n,image_cols:o,image_sizes:a,...i}=await this.image_processor(e,{...s,return_row_col_info:!0});if(r){let l=this.config.image_token??"<image>",{tile_size:c=512,downsample_factor:p=2,encoder_patch_size:d=16,use_thumbnail:_=!0}=this.image_processor.config,m=T=>Math.ceil(Math.floor(T/d)/p),w=m(c)**2,x=this.config.image_start_token??"<|image_start|>",E=this.config.image_end_token??"<|image_end|>",k=this.config.image_thumbnail??"<|img_thumbnail|>";Array.isArray(r)||(r=[r]);let A=0;r=r.map(T=>{let S=T.split(l);return S[0]+S.slice(1).map(L=>{let O=A++,[v,W]=a[O],X=n[O],B=o[O],H=m(v)*m(W),G=x;if(X>1||B>1){let Q=l.repeat(w);for(let R=0;R<X;++R)for(let C=0;C<B;++C)G+=`<|img_row_${R+1}_col_${C+1}|>`+Q;_&&(G+=k+l.repeat(H))}else G+=l.repeat(H);return G+E+L}).join("")})}return{...i,...r?this.tokenizer(r,s):{}}}};var Cf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;static uses_processor_config=!0;async _call(e,r=null,s={}){let n=await this.image_processor(e,s);if(r){let[a,i]=n.pixel_values.dims.slice(-2),{image_token:l,patch_size:c,num_additional_image_tokens:p}=this.config,d=Math.floor(a/c)*Math.floor(i/c)+p;r=structuredClone(r),Array.isArray(r)||(r=[r]);for(let _=0;_<r.length;++_)r[_]=r[_].replace(l,l.repeat(d))}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var iM={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},Lf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;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,r){if(!iM.hasOwnProperty(r))throw new Error(`Format ${r} is not supported.`);let[s,n]=iM[r],o=this[s].bind(this),[a,i]=e.dims,l=[],c=[],p=e.tolist();for(let _=0;_<a;++_){let m=p[_],w=[],x=[];for(let k=1;k<i;++k){let[A,T]=Ce(Ie(m[k]));if(x.push(A),T==n)break;w.push(T)}let E=x.length>0?x.reduce((k,A)=>k*A,1):0;c.push(w),l.push(E)}return[o(c),l]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(r=>r.replaceAll(" ",""))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(r=>r.replaceAll(" ",""))}batch_decode([e,r,s]){let[n,o]=this._decode_helper(e,"char"),[a,i]=this._decode_helper(r,"bpe"),[l,c]=this._decode_helper(s,"wp"),p=[],d=[];for(let _=0;_<n.length;++_){let[m,w]=Ce([o[_],i[_],c[_]]);p.push([n[_],a[_],l[_]][w]),d.push(m)}return{generated_text:p,scores:d,char_preds:n,bpe_preds:a,wp_preds:l}}static async from_pretrained(...e){let r=await super.from_pretrained(...e),s=await oe.from_pretrained("Xenova/gpt2"),n=await oe.from_pretrained("Xenova/bert-base-uncased");return r.components={image_processor:r.image_processor,char_tokenizer:r.tokenizer,bpe_tokenizer:s,wp_tokenizer:n},r}async _call(e,r=null){let s=await this.image_processor(e);return r&&(s.labels=this.tokenizer(r).input_ids),s}};var Pf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var zf=class extends re{static tokenizer_class=oe;static image_processor_class=Te};var so="<image>";function tN(t,e,r,s,n){return`${s.repeat(r*n)}${e}${t}
|
|
24
|
+
`}var Nf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;static uses_processor_config=!1;async _call(e,r=null,s={}){r||(Z.warn("You are using PaliGemma without a text prefix. It will perform as a picture-captioning model."),r=""),Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]);let n=this.tokenizer.bos_token,o=this.image_processor.config.image_seq_length,a;r.some(c=>c.includes(so))?a=r.map(c=>{let p=c.replaceAll(so,so.repeat(o)),d=p.lastIndexOf(so),_=d===-1?0:d+so.length;return p.slice(0,_)+n+p.slice(_)+`
|
|
25
|
+
`}):(Z.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=r.map(c=>tN(c,n,o,so,e.length)));let i=this.tokenizer(a,s);return{...await this.image_processor(e,s),...i}}};var lM="<|image|>",rN=/<\|image_\d+\|>/g,$f=class extends re{static image_processor_class=Te;static tokenizer_class=oe;async _call(e,r=null,{padding:s=!0,truncation:n=!0,num_crops:o=null}={}){Array.isArray(e)||(e=[e]);let a,i;if(r){i=await this.image_processor(r,{num_crops:o});let{num_img_tokens:l}=i,c=e.map((d,_)=>d.split(rN).join(lM.repeat(l[_])));a=this.tokenizer(c,{padding:s,truncation:n});let p=this.tokenizer._tokenizer.token_to_id(lM);a.input_ids.map_(d=>d==p?-d:d)}else a=this.tokenizer(e);return{...a,...i}}};var Rf=class extends re{static tokenizer_class=oe;static image_processor_class=Te;static uses_processor_config=!0;async _call(e,r=null,s={}){let n=await this.image_processor(e,s);if(r){let[a,i]=n.pixel_values.dims.slice(-2),{image_token:l,image_break_token:c,image_end_token:p,patch_size:d,spatial_merge_size:_}=this.config,m=d*_,w=Math.floor(a/m),x=Math.floor(i/m);r=structuredClone(r),Array.isArray(r)||(r=[r]);for(let E=0;E<r.length;++E){let k=l.repeat(x),A=k+c,T=k+p,S=A.repeat(w-1)+T;r[E]=r[E].replace(l,S)}}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var Df=class extends re{static feature_extractor_class=Yn;async _call(e){return await this.feature_extractor(e)}post_process_speaker_diarization(...e){return this.feature_extractor.post_process_speaker_diarization(...e)}get sampling_rate(){return this.feature_extractor.config.sampling_rate}};var no=class extends is{};var Ff=class extends no{};var oo=class extends re{static image_processor_class=Te;async _call(...e){return await this.image_processor(...e)}post_process_masks(...e){return this.image_processor.post_process_masks(...e)}reshape_input_points(...e){return this.image_processor.reshape_input_points(...e)}};var Jl=class extends oo{},Bf=class extends Jl{};var Uf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var jf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;static uses_processor_config=!0;async _call(e,r=null,s={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(r){let a=r.length,{input_features:i}=await this.feature_extractor(r,{...s,max_length:a}),l=Math.round(a/this.config.encoder_ds_factor+1e-4),c=1+Math.ceil(l/this.config.stack_factor);n.audio_token_len=[c],n.audio_values=i;let p=this.config.audio_placeholder;if(!e.includes(p))throw new Error(`The input text does not contain the image token ${p}.`);e=e.replaceAll(p,p.repeat(c))}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var Gf="[AUDIO]",sN="[BEGIN_AUDIO]",nN=375;function oN(t,e){let r=[];for(let s=0;s<t.length;s+=e)r.push(t.subarray(s,Math.min(s+e,t.length)));return r}var qf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;static uses_processor_config=!1;async _call(e,r=null,s={}){if(Array.isArray(e))throw new Error("Batched inputs are not supported yet.");let n={};if(r){if(!e.includes(Gf))throw new Error(`The input text does not contain the audio token ${Gf}.`);Array.isArray(r)||(r=[r]);let a=e.split(Gf),i=a.length-1;if(i!==r.length)throw new Error(`The number of audio inputs (${r.length}) does not match the number of audio tokens in the text (${i}).`);let l=this.feature_extractor.config.n_samples,c=r.map(w=>oN(w,l)),p=c.map(w=>w.length),d=c.flat(),_=(await Promise.all(d.map(w=>this.feature_extractor(w,s)))).map(w=>w.input_features);n.audio_values=_.length>1?ve(_,0):_[0];let m=a[0];for(let w=0;w<p.length;++w){m+=sN;for(let x=0;x<p[w];++x)m+=Gf.repeat(nN);m+=a[w+1]}e=m}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var cM=32,T1=6,Wf=8,aN=10,iN=32,Vf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(T1+1)*Wf}get num_samples_first_audio_chunk(){let{hop_length:e,n_fft:r}=this.feature_extractor.config;return(this.num_mel_frames_first_audio_chunk-1)*e+Math.floor(r/2)}get num_samples_per_audio_chunk(){let{hop_length:e,n_fft:r}=this.feature_extractor.config;return Wf*e+r}get num_right_pad_tokens(){return T1+1+aN}get audio_length_per_tok(){return Wf}get raw_audio_length_per_tok(){return Wf*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:r=!1,is_first_audio_chunk:s=!0}={}){if(Re(e,"VoxtralRealtimeProcessor"),!r&&!s)throw new Error("In non-streaming mode (`is_streaming=false`), `is_first_audio_chunk` must be `true`.");if(s)if(r){let n=cM*this.raw_audio_length_per_tok,o=new Float32Array(n+e.length);o.set(e,n);let a=await this.feature_extractor(o,{center:!0}),l=1+(cM+T1),c=new BigInt64Array(l).fill(BigInt(iN));return c[0]=1n,{input_ids:new N("int64",c,[1,l]),...a}}else{let n=this.num_right_pad_tokens*this.raw_audio_length_per_tok,o=new Float32Array(e.length+n);return o.set(e),await this.feature_extractor(o,{center:!0})}else return await this.feature_extractor(e,{center:!1})}};var Hf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Xf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Kf=class extends re{static tokenizer_class=oe;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Zl=class{static async from_pretrained(e,r={}){let s=await ut(e,Er,!0,r),{image_processor_type:n,feature_extractor_type:o,processor_class:a}=s;if(a&&Qf[a])return Qf[a].from_pretrained(e,r);if(!n&&!o)throw new Error("No `image_processor_type` or `feature_extractor_type` found in the config.");let i={};if(n){let c=ro[n.replace(/Fast$/,"")];if(!c)throw new Error(`Unknown image_processor_type: '${n}'.`);i.image_processor=new c(s)}if(o){let c=ro[o];if(c)i.image_processor=new c(s);else{let p=Nl[o];if(!p)throw new Error(`Unknown feature_extractor_type: '${o}'.`);i.feature_extractor=new p(s)}}let l={};return new re(l,i,null)}};async function lN(t,e){return await ut(t,"config.json",!0,e)}function ao(t){let e={},r={};switch(t.model_type){case"llava":case"paligemma":case"gemma3":case"florence2":case"llava_onevision":case"idefics3":case"granite_speech":case"ultravox":case"voxtral":case"voxtral_realtime":case"smolvlm":case"gemma3n":case"lfm2_vl":case"chatterbox":case"lighton_ocr":case"glm_ocr":case"mistral3":case"qwen2_5_vl":case"qwen3_vl":case"qwen3_vl_moe":r=ao(t.text_config);break;case"moondream1":r=ao(t.phi_config);break;case"musicgen":r=ao(t.decoder);break;case"multi_modality":r=ao(t.language_config);break;case"gpt2":case"gptj":case"jais":case"codegen":case"gpt_bigcode":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="n_embd";break;case"gpt_neox":case"stablelm":case"opt":case"falcon":case"modernbert-decoder":e.num_heads="num_attention_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size";break;case"gpt_oss":case"llama":case"llama4_text":case"nanochat":case"apertus":case"arcee":case"afmoe":case"lfm2":case"lfm2_moe":case"smollm3":case"olmo":case"olmo2":case"olmo3":case"mobilellm":case"granite":case"granitemoehybrid":case"cohere":case"cohere2":case"mistral":case"voxtral_realtime_text":case"voxtral_realtime_encoder":case"starcoder2":case"qwen2":case"qwen2_moe":case"qwen2_vl":case"qwen2_vl_text":case"qwen2_5_vl_text":case"qwen3_moe":case"qwen3_vl_text":case"qwen3_vl_moe_text":case"phi":case"phi3":case"phi3_v":case"llava_qwen2":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.hidden_size="hidden_size",e.num_attention_heads="num_attention_heads",e.dim_kv="head_dim";break;case"qwen3":case"solar_open":case"glm_ocr_text":case"gemma":case"gemma2":case"vaultgemma":case"gemma3_text":case"gemma3n_text":case"glm":case"helium":case"ernie4_5":case"hunyuan_v1_dense":case"falcon_h1":case"nemotron_h":case"ministral":case"ministral3":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="head_dim";break;case"openelm":e.num_heads="num_kv_heads",e.num_layers="num_transformer_layers",e.dim_kv="head_dim";break;case"gpt_neo":case"donut-swin":e.num_heads="num_heads",e.num_layers="num_layers",e.hidden_size="hidden_size";break;case"bloom":e.num_heads="n_head",e.num_layers="n_layer",e.hidden_size="hidden_size";break;case"mpt":e.num_heads="n_heads",e.num_layers="n_layers",e.hidden_size="d_model";break;case"exaone":e.num_heads="num_key_value_heads",e.num_layers="num_layers",e.dim_kv="head_dim",e.num_attention_heads="num_attention_heads";break;case"youtu":case"deepseek_v3":case"glm_moe_dsa":case"mistral4":e.num_heads="num_key_value_heads",e.num_layers="num_hidden_layers",e.dim_kv="qk_head_dim",e.num_attention_heads="num_attention_heads";break;case"t5":case"mt5":case"longt5":e.num_decoder_layers="num_decoder_layers",e.num_decoder_heads="num_heads",e.decoder_dim_kv="d_kv",e.num_encoder_layers="num_layers",e.num_encoder_heads="num_heads",e.encoder_dim_kv="d_kv";break;case"bart":case"mbart":case"marian":case"whisper":case"lite-whisper":case"m2m_100":case"blenderbot":case"blenderbot-small":case"florence2_language":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="d_model",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="d_model";break;case"speecht5":e.num_decoder_layers="decoder_layers",e.num_decoder_heads="decoder_attention_heads",e.decoder_hidden_size="hidden_size",e.num_encoder_layers="encoder_layers",e.num_encoder_heads="encoder_attention_heads",e.encoder_hidden_size="hidden_size";break;case"trocr":e.num_encoder_layers=e.num_decoder_layers="decoder_layers",e.num_encoder_heads=e.num_decoder_heads="decoder_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="d_model";break;case"musicgen_decoder":e.num_encoder_layers=e.num_decoder_layers="num_hidden_layers",e.num_encoder_heads=e.num_decoder_heads="num_attention_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"moonshine":e.num_decoder_layers="decoder_num_hidden_layers",e.num_decoder_heads="decoder_num_key_value_heads",e.num_encoder_layers="encoder_num_hidden_layers",e.num_encoder_heads="encoder_num_key_value_heads",e.encoder_hidden_size=e.decoder_hidden_size="hidden_size";break;case"vision-encoder-decoder":let n=ao(t.decoder),o="num_decoder_layers"in n,a=Qe(t,["model_type","is_encoder_decoder"]);return o?(a.num_decoder_layers=n.num_decoder_layers,a.num_decoder_heads=n.num_decoder_heads,a.decoder_hidden_size=n.decoder_hidden_size,a.num_encoder_layers=n.num_encoder_layers,a.num_encoder_heads=n.num_encoder_heads,a.encoder_hidden_size=n.encoder_hidden_size):(a.num_layers=n.num_layers,a.num_heads=n.num_heads,a.hidden_size=n.hidden_size),a}let s={...r,...Qe(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)s[n]=t[e[n]];return s}function Qs(t,e){t instanceof Ks||(t=new Ks(t));let r=e?.batch_size??1;if(["lfm2","lfm2_moe"].includes(t.model_type)){let s=e?.prefix??"past_key_values",n=s==="present"?"present":"past",o={},{layer_types:a,num_attention_heads:i,num_key_value_heads:l,hidden_size:c,conv_L_cache:p}=t,d=c/i;for(let _=0;_<a.length;++_)if(a[_]==="full_attention")for(let m of["key","value"])o[`${s}.${_}.${m}`]=[r,l,0,d];else if(a[_]==="conv")o[`${n}_conv.${_}`]=[r,c,p];else throw new Error(`Unsupported layer type: ${a[_]}`);return o}else if(["granitemoehybrid","falcon_h1","nemotron_h"].includes(t.model_type)){let s=e?.prefix??"past_key_values",n=s==="present"?"present":"past",o=t,a=o.layer_types??o.layers_block_type,i=o.num_hidden_layers??a?.length,l=o.num_key_value_heads,c=o.head_dim??o.hidden_size/o.num_attention_heads,p=o.mamba_n_heads??o.mamba_num_heads,d=o.mamba_d_head??o.mamba_head_dim,_=o.mamba_d_state??o.ssm_state_size,m=o.mamba_n_groups??o.n_groups,w=o.mamba_d_conv??o.conv_kernel,E=(o.mamba_d_ssm??(o.mamba_expand?o.mamba_expand*o.hidden_size:p*d))+2*m*_,k={};for(let A=0;A<i;++A)if((!a||a[A]==="mamba")&&(k[`${n}_conv.${A}`]=[r,E,w],k[`${n}_ssm.${A}`]=[r,p,d,_]),!a||a[A]==="attention")for(let T of["key","value"])k[`${s}.${A}.${T}`]=[r,l,0,c];return k}else if(["qwen3_next","qwen3_5_text","qwen3_5_moe_text","olmo_hybrid"].includes(t.model_type)){let s=e?.prefix??"past_key_values",n=s==="present"?"present":"past",o={},{head_dim:a,layer_types:i,num_attention_heads:l,num_key_value_heads:c,hidden_size:p,linear_num_value_heads:d,linear_num_key_heads:_,linear_key_head_dim:m,linear_value_head_dim:w,linear_conv_kernel_dim:x}=t,E=m*_,k=w*d,A=a??p/l;for(let T=0;T<i.length;++T)if(i[T]==="full_attention")for(let S of["key","value"])o[`${s}.${T}.${S}`]=[r,c,0,A];else if(i[T]==="linear_attention"){if(t.model_type==="olmo_hybrid")o[`${n}_conv.${T}.key`]=[r,E,x],o[`${n}_conv.${T}.value`]=[r,k,x],o[`${n}_conv.${T}.query`]=[r,E,x];else{let S=E*2+k;o[`${n}_conv.${T}`]=[r,S,x]}o[`${n}_recurrent.${T}`]=[r,d,m,w]}else throw new Error(`Unsupported layer type: ${i[T]}`);return o}else if(["lfm2_vl","qwen3_5","qwen3_5_moe","voxtral_realtime"].includes(t.model_type)){let s;return t.model_type==="voxtral_realtime"&&e?.session_name==="audio_encoder"?s=t.audio_config:s=t.text_config,Qs(s,e)}return cN(t,e)}function cN(t,{prefix:e="past_key_values",batch_size:r=1}={}){let s={},n=t.normalized_config;if(n.is_encoder_decoder&&"num_encoder_heads"in n&&"num_decoder_heads"in n){let o=n.encoder_dim_kv??n.encoder_hidden_size/n.num_encoder_heads,a=n.decoder_dim_kv??n.decoder_hidden_size/n.num_decoder_heads,i=[r,n.num_encoder_heads,0,o],l=[r,n.num_decoder_heads,0,a];for(let c=0;c<n.num_decoder_layers;++c)s[`${e}.${c}.encoder.key`]=i,s[`${e}.${c}.encoder.value`]=i,s[`${e}.${c}.decoder.key`]=l,s[`${e}.${c}.decoder.value`]=l}else{let o=n.num_heads,a=n.num_layers,i=n.dim_kv??n.hidden_size/(n.num_attention_heads??o);if(n.model_type==="falcon"){let l=[r*o,0,i];for(let c=0;c<a;++c)s[`${e}.${c}.key`]=l,s[`${e}.${c}.value`]=l}else if(n.multi_query){let l=[r*o,0,2*i];for(let c=0;c<a;++c)s[`${e}.${c}.key_value`]=l}else if(n.model_type==="bloom"){let l=[r*o,i,0],c=[r*o,0,i];for(let p=0;p<a;++p)s[`${e}.${p}.key`]=l,s[`${e}.${p}.value`]=c}else if(n.model_type==="openelm")for(let l=0;l<a;++l){let c=[r,o[l],0,i];s[`${e}.${l}.key`]=c,s[`${e}.${l}.value`]=c}else{let l=[r,o,0,i];for(let c=0;c<a;++c)s[`${e}.${c}.key`]=l,s[`${e}.${c}.value`]=l}}return s}var Ks=class t{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=ao(this)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main"}={}){s&&!(s instanceof t)&&(s=new t(s));let i=s??await lN(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a});return new this(i)}},Nt=class{static async from_pretrained(...e){return Ks.from_pretrained(...e)}};function O1(t,e,r){return t?typeof t=="object"&&t!==null?t.hasOwnProperty(e)?+t[e]:t.hasOwnProperty(r)?+t[r]:0:+t:0}function I1(t,e){let r=[];for(let s=0;s<e;++s)r.push(`${t}_data${s===0?"":"_"+s}`);return r}async function uM(t,e,r,s){let n=`${e}${s}.onnx`,o=`${r.subfolder??""}/${n}`;return await gl(t,o,!0,r,ie.IS_NODE_ENV)}async function pM(t,e,r,s,n,o={}){let a=`${e}${r}.onnx`,i=ie.IS_NODE_ENV,l=[],c=O1(n,a,e);if(c>0){if(c>Qu)throw new Error(`The number of external data chunks (${c}) exceeds the maximum allowed value (${Qu}).`);let p=I1(a,c);for(let d of p){let _=`${s.subfolder??""}/${d}`;l.push(new Promise(async(m,w)=>{let x=await gl(t,_,!0,s,i);m(x instanceof Uint8Array?{path:d,data:x}:d)}))}}else o.externalData!==void 0&&(l=o.externalData.map(async p=>{if(typeof p.data=="string"){let d=await gl(t,p.data,!0,s);return{...p,data:d}}return p}));return Promise.all(l)}async function uN(t,e,r,s=!1,n=void 0){let o=r.config?.["transformers.js_config"]??{},a=gp(r.device??o.device,e,{warn:S=>Z.info(S)}),i=$2(a),l=o.device_config??{};l.hasOwnProperty(a)&&(o={...o,...l[a]});let c=wp(r.dtype??o.dtype,e,a,{configDtype:o.dtype,warn:S=>Z.info(S)});if(Tl.hasOwnProperty(c)){if(a==="webgpu"&&!ie.IS_NODE_ENV&&c===wt.fp16&&!await B2())throw new Error(`The device (${a}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${c}. Should be one of: ${Object.keys(wt).join(", ")}`);let p=o.kv_cache_dtype,d=p?typeof p=="string"?p:p[c]??"float32":void 0;if(d&&!["float32","float16"].includes(d))throw new Error(`Invalid kv_cache_dtype: ${d}. Should be one of: float32, float16`);let _=Tl[c],m={...r.session_options};m.executionProviders??=i;let w=o.free_dimension_overrides;w?m.freeDimensionOverrides??=w:a.startsWith("webnn")&&!m.freeDimensionOverrides&&Z.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${a}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let x=uM(t,e,r,_),E=r.use_external_data_format??o.use_external_data_format,k=await pM(t,e,_,r,E,m);if(k.length>0&&!ie.IS_NODE_ENV&&(m.externalData=k),s&&a==="webgpu"&&p!==!1){let S=Qs(r.config,{prefix:"present",session_name:n});if(Object.keys(S).length>0&&!Sl()){let L={};for(let O in S)L[O]="gpu-buffer";m.preferredOutputLocation=L}}return{buffer_or_path:await x,session_options:m,session_config:{dtype:c,kv_cache_dtype:d,device:a}}}async function dM(t,e,r,s=void 0){return Object.fromEntries(await Promise.all(Object.keys(e).map(async n=>{let o=s?.[n]??!1,{buffer_or_path:a,session_options:i,session_config:l}=await uN(t,e[n],r,o,n),c=await _p(a,i,l);return[n,c]})))}function fM(t){for(let e in t)hp(t[e])?t[e]=new N(t[e]):typeof t[e]=="object"&&fM(t[e]);return t}async function de(t,e){let r=pN(t,e);try{let s=Object.fromEntries(Object.entries(r).map(([o,a])=>{let i=a.ort_tensor;return ie.IS_NODE_ENV&&typeof Float16Array<"u"&&i.cpuData instanceof Float16Array&&(i.cpuData=new Uint16Array(i.cpuData.buffer)),[o,i]})),n=await mp(t,s);return fM(n)}catch(s){let n=Object.fromEntries(Object.entries(r).map(([o,a])=>{let i={type:a.type,dims:a.dims,location:a.location};return i.location!=="gpu-buffer"&&(i.data=a.data),[o,i]}));throw Z.error(`An error occurred during model execution: "${s}".`),Z.error("Inputs given to model:",n),s}}function pN(t,e){let r=Object.create(null),s=[];for(let a of t.inputNames){let i=e[a];if(!(i instanceof N)){s.push(a);continue}r[a]=Sl()?i.clone():i}if(s.length>0)throw new Error(`An error occurred during model execution: "Missing the following inputs: ${s.join(", ")}.`);let n=Object.keys(e).length,o=t.inputNames.length;if(n>o){let a=Object.keys(e).filter(i=>!t.inputNames.includes(i));Z.warn(`WARNING: Too many inputs were provided (${n} > ${o}). The following inputs will be ignored: "${a.join(", ")}".`)}return r}var $e=class{};var j=class extends $e{constructor({logits:e,...r}){super(),this.logits=e;let s=Object.values(r);s.length>0&&(this.attentions=s)}},he=class extends $e{constructor({logits:e}){super(),this.logits=e}},ge=class extends $e{constructor({logits:e}){super(),this.logits=e}},Ae=class extends $e{constructor({start_logits:e,end_logits:r}){super(),this.start_logits=e,this.end_logits=r}},bt=class extends $e{constructor({logits:e}){super(),this.logits=e}};var Yf=class extends $e{constructor({alphas:e}){super(),this.alphas=e}};var $t=class extends tt{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},io=class extends tt{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},ls=class extends tt{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,r){let s=r;for(let n of this.processors)s=n(e,s);return s}[Symbol.iterator](){return this.processors.values()}},ec=class extends $t{constructor(e){super(),this.bos_token_id=e}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===1){let n=r[s].data;n.fill(-1/0),n[this.bos_token_id]=0}return r}},tc=class extends $t{constructor(e,r){super(),this.max_length=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===this.max_length-1){let n=r[s].data;n.fill(-1/0);for(let o of this.eos_token_id)n[o]=0}return r}},Ys=class extends $t{constructor(e,r){super(),this.begin_suppress_tokens=e,this.begin_index=r}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length===this.begin_index){let n=r[s].data;for(let o of this.begin_suppress_tokens)n[o]=-1/0}return r}},rc=class extends $t{constructor(e,r){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=r.length,r.at(-1)===this.no_timestamps_token_id&&(this.begin_index-=1),this.max_initial_timestamp_index=e.max_initial_timestamp_index}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data;if(n[this.no_timestamps_token_id]=-1/0,e[s].length===this.begin_index-1){n.fill(-1/0),n[this.timestamp_begin]=0;continue}let o=e[s].slice(this.begin_index),a=o.length>=1&&o[o.length-1]>=this.timestamp_begin,i=o.length<2||o[o.length-2]>=this.timestamp_begin;if(a&&(i?n.subarray(this.timestamp_begin).fill(-1/0):n.subarray(0,this.eos_token_id).fill(-1/0)),e[s].length===this.begin_index&&this.max_initial_timestamp_index!==null){let d=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(d+1).fill(-1/0)}let l=tp(n),c=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((d,_)=>d+_)),p=Ce(l.subarray(0,this.timestamp_begin))[0];c>p&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return r}},sc=class extends $t{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let r=e.length,s=[];for(let o=0;o<r+1-this.no_repeat_ngram_size;++o){let a=[];for(let i=0;i<this.no_repeat_ngram_size;++i)a.push(e[o+i]);s.push(a.map(Number))}let n=new Map;for(let o of s){let a=o.slice(0,o.length-1),i=JSON.stringify(a),l=n.get(i)??[];l.push(o[o.length-1]),n.set(i,l)}return n}getGeneratedNgrams(e,r){let s=r.slice(r.length+1-this.no_repeat_ngram_size,r.length);return e.get(JSON.stringify(s.map(Number)))??[]}calcBannedNgramTokens(e){let r=[];if(e.length+1<this.no_repeat_ngram_size)return r;{let s=this.getNgrams(e);return this.getGeneratedNgrams(s,e)}}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data,o=this.calcBannedNgramTokens(e[s]);for(let a of o)n[a]=-1/0}return r}},nc=class extends $t{constructor(e){super(),this.penalty=e}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data;for(let o of new Set(e[s])){let a=Number(o);n[a]<0?n[a]*=this.penalty:n[a]/=this.penalty}}return r}},oc=class extends $t{constructor(e,r){super(),this.min_length=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length<this.min_length){let n=r[s].data;for(let o of this.eos_token_id)n[o]=-1/0}return r}},ac=class extends $t{constructor(e,r,s){super(),this.prompt_length_to_skip=e,this.min_new_tokens=r,this.eos_token_id=Array.isArray(s)?s:[s]}_call(e,r){for(let s=0;s<e.length;++s)if(e[s].length-this.prompt_length_to_skip<this.min_new_tokens){let o=r[s].data;for(let a of this.eos_token_id)o[a]=-1/0}return r}},ic=class extends $t{constructor(e,r){super(),this.bad_words_ids=e,this.eos_token_id=Array.isArray(r)?r:[r]}_call(e,r){for(let s=0;s<e.length;++s){let n=r[s].data,o=e[s];for(let a of this.bad_words_ids){if(o.length<a.length-1)continue;let i=!0;for(let l=1;l<=a.length-1;++l)if(a.at(-l-1)!=o.at(-l)){i=!1;break}i&&(n[a.at(-1)]=-1/0)}}return r}},lc=class extends $t{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,r){if(r.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 ${r.dims[0]} for the logits and ${e.length} for the input ids.`);let s=e.length,n=r.slice([0,s],null),o=r.slice([s,r.dims[0]],null);for(let a=0;a<o.data.length;++a)o.data[a]+=(n.data[a]-o.data[a])*this.guidance_scale;return o}},cc=class extends io{constructor(e){if(super(),typeof e!="number"||e<=0){let r=`\`temperature\` (=${e}) must be a strictly positive float, otherwise your next token scores will be invalid.`;e===0&&(r+=" If you're looking for greedy decoding strategies, set `do_sample=false`.")}this.temperature=e}_call(e,r){let s=r.data;for(let n=0;n<s.length;++n)s[n]/=this.temperature;return r}},C1=class extends io{constructor(e,{filter_value:r=-1/0,min_tokens_to_keep:s=1}={}){if(super(),e<0||e>1)throw new Error(`\`top_p\` must be a float > 0 and < 1, but is ${e}`);if(!Number.isInteger(s)||s<1)throw new Error(`\`min_tokens_to_keep\` must be a positive integer, but is ${s}`);this.top_p=e,this.filter_value=r,this.min_tokens_to_keep=s}},L1=class extends io{constructor(e,{filter_value:r=-1/0,min_tokens_to_keep:s=1}={}){if(super(),!Number.isInteger(e)||e<0)throw new Error(`\`top_k\` must be a positive integer, but is ${e}`);this.top_k=Math.max(e,s),this.filter_value=r}};var lo=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,Qe(e,Object.getOwnPropertyNames(this)))}};var Ar=class extends tt{_call(e,r){throw Error("StoppingCriteria needs to be subclassed")}},Js=class t extends tt{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof t?e=e.criteria:e instanceof Ar&&(e=[e]),this.criteria.push(...e)}_call(e,r){let s=new Array(e.length).fill(!1);for(let n of this.criteria){let o=n(e,r);for(let a=0;a<s.length;++a)s[a]||=o[a]}return s}[Symbol.iterator](){return this.criteria.values()}},uc=class extends Ar{constructor(e,r=null){super(),this.max_length=e,this.max_position_embeddings=r}_call(e){return e.map(r=>r.length>=this.max_length)}},pc=class extends Ar{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,r){return e.map(s=>{let n=s.at(-1);return this.eos_token_id.some(o=>n==o)})}},P1=class extends Ar{constructor(){super(),this.interrupted=!1}interrupt(){this.interrupted=!0}reset(){this.interrupted=!1}_call(e,r){return new Array(e.length).fill(this.interrupted)}};var Zs=class extends tt{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,r){let s=e.dims.at(-1),n=e.data;if(r===-1)n=n.slice(-s);else{let o=r*s;n=n.slice(o,o+s)}return n}randomSelect(e){return WE(e)}static getSampler(e){if(e.do_sample)return new N1(e);if(e.num_beams>1)return new $1(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 z1(e)}},z1=class extends Zs{async sample(e){let r=Ce(e.data)[1];return[[BigInt(r),0]]}},N1=class extends Zs{async sample(e){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let[s,n]=await jt(e,r),o=Ie(s.data);return Array.from({length:this.generation_config.num_beams},()=>{let a=this.randomSelect(o);return[n.data[a],Math.log(o[a])]})}},$1=class extends Zs{async sample(e){let r=e.dims.at(-1);this.generation_config.top_k>0&&(r=Math.min(this.generation_config.top_k,r));let[s,n]=await jt(e,r),o=Ie(s.data);return Array.from({length:this.generation_config.num_beams},(a,i)=>[n.data[i],Math.log(o[i])])}};var R1=class{constructor(e){if(e)for(let r in e){if(r in this)throw new TypeError(`Key "${r}" conflicts with an existing property on DynamicCache`);let s=e[r];if(!(s instanceof N))throw new TypeError(`Expected a Tensor for key "${r}", got ${typeof s}`);this[r]=s}}get_seq_length(){let e=this;for(let r in e)if(r.startsWith("past_key_values."))return e[r].dims.at(-2);throw new Error("Unable to determine sequence length from the cache.")}async dispose(){let e=[];for(let r of Object.values(this))r.location==="gpu-buffer"&&e.push(r.dispose());await Promise.all(e)}},co=R1;var en=null;function mM(t){en=t}function D1(t){if(t instanceof N)return t;if(t.length===0)throw Error("items must be non-empty");if(Array.isArray(t[0])){if(t.some(e=>e.length!==t[0].length))throw Error("Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.");return new N("int64",BigInt64Array.from(t.flat().map(e=>BigInt(e))),[t.length,t[0].length])}else return new N("int64",BigInt64Array.from(t.map(e=>BigInt(e))),[1,t.length])}function F1(t){return new N("bool",[t],[1])}var K={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,MultimodalLanguageModelOnly:16,VoxtralRealtime:17},uo={[K.DecoderOnly]:{can_generate:!0,forward:Ot,prepare_inputs:po,sessions:(t,e)=>({model:e.model_file_name??"model"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[K.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Ot,prepare_inputs:po,sessions:(t,e)=>({model:e.model_file_name??"model"})},[K.Seq2Seq]:{can_generate:!0,forward:Jf,prepare_inputs:fc,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[K.Vision2Seq]:{can_generate:!0,forward:Jf,prepare_inputs:fc,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[K.Musicgen]:{can_generate:!0,forward:Jf,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"}},[K.EncoderDecoder]:{can_generate:!1,forward:Jf,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0}},[K.MaskGeneration]:{sessions:()=>({model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"})},[K.ImageTextToText]:{can_generate:!0,forward:_M,prepare_inputs:dc,sessions:t=>{let e={embed_tokens:"embed_tokens",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"};return t.is_encoder_decoder&&(e.model="encoder_model"),e},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[K.AudioTextToText]:{can_generate:!0,forward:fN,prepare_inputs:dc,sessions:()=>({embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[K.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:dc,sessions:()=>({embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",vision_encoder:"vision_encoder",decoder_model_merged:"decoder_model_merged"}),optional_configs:{generation_config:"generation_config.json"}},[K.Phi3V]:{can_generate:!0,prepare_inputs:dc,sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[K.MultiModality]:{can_generate:!0,sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"language_model",lm_head:"lm_head",gen_head:"gen_head",gen_img_embeds:"gen_img_embeds",image_decode:"image_decode"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[K.AutoEncoder]:{can_generate:!1,forward:dN,sessions:()=>({encoder_model:"encoder_model",decoder_model:"decoder_model"})},[K.Supertonic]:{sessions:()=>({text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"})},[K.Chatterbox]:{can_generate:!0,forward:Gt,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"}},[K.MultimodalLanguageModelOnly]:{can_generate:!0,forward:_M,prepare_inputs:dc,sessions:()=>({embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[K.VoxtralRealtime]:{can_generate:!0,prepare_inputs:po,sessions:()=>({embed_tokens:"embed_tokens",audio_encoder:"audio_encoder",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:"generation_config.json"}},default:{can_generate:!1,forward:Gt,sessions:(t,e)=>({model:e.model_file_name??"model"})}};function hM(t,e,r={}){let s=uo[t]??uo.default;return{sessions:s.sessions(e,r),cache_sessions:s.cache_sessions,optional_configs:s.optional_configs}}var er=new Map,Zf=new Map,tn=new Map,y=class extends tt{main_input_name="input_ids";forward_params=["input_ids","attention_mask"];_return_dict_in_generate_keys=null;constructor(e,r,s){super(),this.config=e,this.sessions=r,this.configs=s;let n=tn.get(this.constructor),o=er.get(n),a=uo[o]??uo.default;this.can_generate=a.can_generate,this._forward=a.forward,this._prepare_inputs_for_generation=a.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let r of Object.values(this.sessions))e.push(r.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:c=null,dtype:p=null,use_external_data_format:d=null,session_options:_={}}={}){let m={progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:c,dtype:p,use_external_data_format:d,session_options:_},w=tn.get(this),x=er.get(w);s=m.config=await Nt.from_pretrained(e,m);let E=uo[x]??uo.default;if(x===void 0){let S=w??s?.model_type;S!=="custom"&&Z.warn(`Model type for '${S}' not found, assuming encoder-only architecture. Please report this at ${ns}.`)}let k=E.sessions(s,m),A=[dM(e,k,m,E.cache_sessions)];E.optional_configs&&A.push(mN(e,E.optional_configs,m));let T=await Promise.all(A);return new this(s,...T)}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,r,s=null){let n=new ls;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new nc(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new sc(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new ic(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new oc(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 ac(r,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new ec(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new tc(e.max_length,e.forced_eos_token_id)),e.begin_suppress_tokens!==null){let o=r>1||e.forced_bos_token_id===null?r:r+1;n.push(new Ys(e.begin_suppress_tokens,o))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new lc(e.guidance_scale)),e.temperature===0&&e.do_sample&&(Z.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 cc(e.temperature)),s!==null&&n.extend(s),n}_prepare_generation_config(e,r,s=lo){let n={...this.config};for(let a of["decoder","generator","text_config"])a in n&&Object.assign(n,n[a]);let o=new s(n);return Object.assign(o,this.generation_config??{}),e&&Object.assign(o,e),r&&Object.assign(o,Qe(r,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,r=null){let s=new Js;return e.max_length!==null&&s.push(new uc(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&s.push(new pc(e.eos_token_id)),r&&s.extend(r),s}_validate_model_class(){if(!this.can_generate){let e=[en.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,en.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,en.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,en.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),r=tn.get(this.constructor),s=new Set,n=this.config.model_type;for(let a of e){let i=a?.get(n);i&&s.add(i)}let o=`The current model class (${r}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw s.size>0&&(o+=` Please use the following class instead: ${[...s].join(", ")}`),Error(o)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw new Error("prepare_inputs_for_generation is not implemented for this model.");return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:r,model_inputs:s,is_encoder_decoder:n}){return s.past_key_values=this.getPastKeyValues(r,s.past_key_values),s.input_ids=new N("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in s:s.attention_mask=ve([s.attention_mask,Je([s.attention_mask.dims[0],1])],1),s.position_ids=null,s}_prepare_model_inputs({inputs:e,bos_token_id:r,model_kwargs:s}){let n=Qe(s,this.forward_params),o=this.main_input_name;if(o in n){if(e)throw new Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else n[o]=e;return{inputs_tensor:n[o],model_inputs:n,model_input_name:o}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:r,model_input_name:s,generation_config:n}){if(this.sessions.model.inputNames.includes("inputs_embeds")&&!r.inputs_embeds&&"_prepare_inputs_embeds"in this){let{input_ids:a,pixel_values:i,attention_mask:l,...c}=r,p=await this._prepare_inputs_embeds(r);r={...c,...Qe(p,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await Gt(this,r);if(n.guidance_scale!==null&&n.guidance_scale>1)o=ve([o,qn(o,0)],0),"attention_mask"in r&&(r.attention_mask=ve([r.attention_mask,kp(r.attention_mask)],0));else if(r.decoder_input_ids){let a=D1(r.decoder_input_ids).dims[0];if(a!==o.dims[0]){if(o.dims[0]!==1)throw new Error(`The encoder outputs have a different batch size (${o.dims[0]}) than the decoder inputs (${a}).`);o=ve(Array.from({length:a},()=>o),0)}}return r.encoder_outputs=o,r}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:r,model_kwargs:s,decoder_start_token_id:n,bos_token_id:o,generation_config:a}){let{decoder_input_ids:i,...l}=s;if(!(i instanceof N)){if(i)Array.isArray(i[0])||(i=Array.from({length:e},()=>i));else if(n??=o,this.config.model_type==="musicgen")i=Array.from({length:e*this.config.decoder.num_codebooks},()=>[n]);else if(Array.isArray(n)){if(n.length!==e)throw new Error(`\`decoder_start_token_id\` expcted to have length ${e} but got ${n.length}`);i=n}else i=Array.from({length:e},()=>[n]);i=D1(i)}return s.decoder_attention_mask=Ll(i),{input_ids:i,model_inputs:l}}async generate({inputs:e=null,generation_config:r=null,logits_processor:s=null,stopping_criteria:n=null,streamer:o=null,...a}){this._validate_model_class(),r=this._prepare_generation_config(r,a);let{inputs_tensor:i,model_inputs:l,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),p=this.config.is_encoder_decoder;p&&("encoder_outputs"in l||(l=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:i,model_inputs:l,model_input_name:c,generation_config:r})));let d;p?{input_ids:d,model_inputs:l}=this._prepare_decoder_input_ids_for_generation({batch_size:l[c].dims.at(0),model_input_name:c,model_kwargs:l,decoder_start_token_id:r.decoder_start_token_id,bos_token_id:r.bos_token_id,generation_config:r}):d=l[c];let _=d.dims.at(-1);r.max_new_tokens!==null&&(r.max_length=_+r.max_new_tokens);let m=this._get_logits_processor(r,_,s),w=this._get_stopping_criteria(r,n),x=l[c].dims.at(0),E=Zs.getSampler(r),k=new Array(x).fill(0),A=d.tolist();o&&o.put(A);let T,S={},L={};for(;;){if(l=this.prepare_inputs_for_generation(A,l,r),T=await this.forward(l),r.return_dict_in_generate)if(r.output_attentions){let G=this.getAttentions(T);for(let Q in G)Q in S||(S[Q]=[]),S[Q].push(G[Q])}else this._return_dict_in_generate_keys&&Object.assign(L,Qe(T,this._return_dict_in_generate_keys));let W=T.logits.slice(null,-1,null).to("float32"),X=m(A,W),B=[];for(let G=0;G<X.dims.at(0);++G){let Q=X[G],R=await E(Q);for(let[C,te]of R){let ae=BigInt(C);k[G]+=te,A[G].push(ae),B.push([ae]);break}}if(o&&o.put(B),w(A).every(G=>G))break;l=this._update_model_kwargs_for_generation({generated_input_ids:B,outputs:T,model_inputs:l,is_encoder_decoder:p})}o&&o.end();let O=this.getPastKeyValues(T,l.past_key_values,!0),v=new N("int64",A.flat(),[A.length,A[0].length]);if(r.return_dict_in_generate)return{sequences:v,past_key_values:O,...S,...L};for(let W of Object.values(T))W.location==="gpu-buffer"&&W.dispose();return v}getPastKeyValues(e,r,s=!1){let n=Object.create(null);for(let o in e)if(o.startsWith("present")){let a=o.replace("present_ssm","past_ssm").replace("present_conv","past_conv").replace("present_recurrent","past_recurrent").replace("present","past_key_values"),i=o.includes("encoder");if(i&&r?n[a]=r[a]:n[a]=e[o],r&&(!i||s)){let l=r[a];l.location==="gpu-buffer"&&l.dispose()}}return new co(n)}getAttentions(e){let r={};for(let s of["cross_attentions","encoder_attentions","decoder_attentions"])for(let n in e)n.startsWith(s)&&(s in r||(r[s]=[]),r[s].push(e[n]));return r}addPastKeyValues(e,r){if(r)Object.assign(e,r);else{let s=this.sessions.decoder_model_merged??this.sessions.model,n=(e[this.main_input_name]??e.attention_mask)?.dims?.[0]??1,o=s?.config?.kv_cache_dtype??"float32",a=o==="float16"?kr.float16:kr.float32,i=Qs(this.config,{batch_size:n});for(let l in i){let c=i[l].reduce((p,d)=>p*d,1);e[l]=new N(o,new a(c),i[l])}}}async _encode_input(e,r,s){if(!Object.hasOwn(this.sessions,e))throw new Error(`Model does not have a ${e} session.`);let n=this.sessions[e];return(await de(n,Qe(r,n.inputNames)))[s]}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 Jf(t,e){let{encoder_outputs:r,input_ids:s,decoder_input_ids:n,...o}=e;if(!r){let a=Qe(e,t.sessions.model.inputNames);r=(await Gt(t,a)).last_hidden_state}return o.input_ids=n,o.encoder_hidden_states=r,t.sessions.decoder_model_merged.inputNames.includes("encoder_attention_mask")&&(o.encoder_attention_mask=e.attention_mask),await Ot(t,o,!0)}async function Gt(t,e){let r=t.sessions.model,s=Qe(e,r.inputNames);if(r.inputNames.includes("inputs_embeds")&&!s.inputs_embeds){if(!e.input_ids)throw new Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");s.inputs_embeds=await t.encode_text({input_ids:e.input_ids})}if(r.inputNames.includes("token_type_ids")&&!s.token_type_ids){if(!s.input_ids)throw new Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");s.token_type_ids=kp(s.input_ids)}if(r.inputNames.includes("pixel_mask")&&!s.pixel_mask){if(!s.pixel_values)throw new Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let n=s.pixel_values.dims;s.pixel_mask=Je([n[0],n[2],n[3]])}return await de(r,s)}async function dN(t,e){let r=await t.encode(e);return await t.decode(r)}async function Ot(t,e,r=!1){let s=t.sessions[r?"decoder_model_merged":"model"],{past_key_values:n,...o}=e;if(s.inputNames.includes("use_cache_branch")&&(o.use_cache_branch=F1(!!n)),s.inputNames.includes("position_ids")&&o.attention_mask&&!o.position_ids){let i=["paligemma","gemma3_text","gemma3"].includes(t.config.model_type)?1:0;o.position_ids=_N(o,n,i)}s.inputNames.includes("num_logits_to_keep")&&!o.num_logits_to_keep&&(o.num_logits_to_keep=new N("int64",[0n],[])),t.addPastKeyValues(o,n);let a=Qe(o,s.inputNames);return await de(s,a)}async function gM(t,{encode_function:e,merge_function:r,modality_input_names:s,modality_output_name:n,input_ids:o=null,attention_mask:a=null,position_ids:i=null,inputs_embeds:l=null,past_key_values:c=null,generation_config:p=null,logits_processor:d=null,..._}){if(!l){l=await t.encode_text({input_ids:o,..._});let w=Qe(_,s);if(Object.keys(w).length>0){if(o.dims[1]!==1){let x=await e({...w,..._});({inputs_embeds:l,attention_mask:a}=r({[n]:x,inputs_embeds:l,input_ids:o,attention_mask:a}))}else if(c&&o.dims[1]===1){let x=o.dims[1],E=c.get_seq_length();a=ve([Je([o.dims[0],E]),a.slice(null,[a.dims[1]-x,a.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(t.config.model_type)){let{image_grid_thw:w,video_grid_thw:x}=_;[i]=t.get_rope_index(o,w,x,a)}return await Ot(t,{inputs_embeds:l,past_key_values:c,attention_mask:a,position_ids:i,generation_config:p,logits_processor:d},!0)}async function fN(t,e){return await gM(t,{...e,modality_input_names:["audio_values","input_features"],modality_output_name:"audio_features",encode_function:t.encode_audio.bind(t),merge_function:t._merge_input_ids_with_audio_features.bind(t)})}async function _M(t,e){return await gM(t,{...e,modality_input_names:["pixel_values"],modality_output_name:"image_features",encode_function:t.encode_image.bind(t),merge_function:t._merge_input_ids_with_image_features.bind(t)})}function B1(t,e=0){let[r,s]=t.dims,n=t.data,o=new BigInt64Array(n.length);for(let a=0;a<r;++a){let i=a*s,l=BigInt(e);for(let c=0;c<s;++c){let p=i+c;n[p]===0n?o[p]=BigInt(1):(o[p]=l,l+=n[p])}}return{data:o,dims:t.dims}}function _N(t,e=null,r=0){let{input_ids:s,inputs_embeds:n,attention_mask:o}=t,{data:a,dims:i}=B1(o,r),l=new N("int64",a,i);if(e){let c=-(s??n).dims.at(1);l=l.slice(null,[c,null])}return l}function po(t,e,r,s){let n=r.past_key_values?r.past_key_values.get_seq_length():0;if((t.sessions.decoder_model_merged??t.sessions.model)?.inputNames.includes("num_logits_to_keep")&&!r.num_logits_to_keep&&(r.num_logits_to_keep=new N("int64",[1n],[])),!r.attention_mask){let a;for(let i of["input_ids","inputs_embeds","position_ids"])if(r[i]){a=r[i].dims;break}if(!a)throw new Error("attention_mask is not provided, and unable to infer its shape from model inputs.");r.attention_mask=Je([a[0],n+a[1]])}if(r.past_key_values){let{input_ids:a,attention_mask:i}=r;i&&i.dims[1]>a.dims[1]||n<a.dims[1]&&(r.input_ids=a.slice(null,[n,null]))}return r}function fc(t,e,r,s){return r.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...r,decoder_input_ids:D1(e)}}function dc(t,...e){return t.config.is_encoder_decoder?fc(t,...e):po(t,...e)}function wM({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n}){let o=s.tolist().map(c=>c.reduce((p,d,_)=>(d==t&&p.push(_),p),[])),a=o.reduce((c,p)=>c+p.length,0),i=r.dims[0];if(a!==i)throw new Error(`Number of tokens and features do not match: tokens: ${a}, features ${i}`);let l=0;for(let c=0;c<o.length;++c){let p=o[c],d=e[c];for(let _=0;_<p.length;++_)d[p[_]].data.set(r[l++].data)}return{inputs_embeds:e,attention_mask:n}}function fo({image_token_id:t,inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return wM({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}function e_({audio_token_id:t,inputs_embeds:e,audio_features:r,input_ids:s,attention_mask:n}){return wM({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}async function mN(t,e,r){return Object.fromEntries(await Promise.all(Object.keys(e).map(async s=>{let n=await ut(t,e[s],!1,r);return[s,n]})))}var uu={};Os(uu,{ASTForAudioClassification:()=>d_,ASTModel:()=>p_,ASTPreTrainedModel:()=>go,AfmoeForCausalLM:()=>l_,AfmoeModel:()=>i_,AfmoePreTrainedModel:()=>mo,AlbertForMaskedLM:()=>n_,AlbertForQuestionAnswering:()=>s_,AlbertForSequenceClassification:()=>r_,AlbertModel:()=>t_,AlbertPreTrainedModel:()=>cs,ApertusForCausalLM:()=>a_,ApertusModel:()=>o_,ApertusPreTrainedModel:()=>_o,ArceeForCausalLM:()=>u_,ArceeModel:()=>c_,ArceePreTrainedModel:()=>ho,BartForConditionalGeneration:()=>__,BartForSequenceClassification:()=>m_,BartModel:()=>f_,BartPretrainedModel:()=>rn,BeitForImageClassification:()=>g_,BeitModel:()=>h_,BeitPreTrainedModel:()=>wo,BertForMaskedLM:()=>x_,BertForQuestionAnswering:()=>v_,BertForSequenceClassification:()=>y_,BertForTokenClassification:()=>b_,BertModel:()=>w_,BertPreTrainedModel:()=>Mr,BlenderbotForConditionalGeneration:()=>E_,BlenderbotModel:()=>k_,BlenderbotPreTrainedModel:()=>xo,BlenderbotSmallForConditionalGeneration:()=>M_,BlenderbotSmallModel:()=>A_,BlenderbotSmallPreTrainedModel:()=>yo,BloomForCausalLM:()=>T_,BloomModel:()=>S_,BloomPreTrainedModel:()=>bo,CHMv2ForDepthEstimation:()=>N_,CHMv2PreTrainedModel:()=>hc,CLIPModel:()=>R_,CLIPPreTrainedModel:()=>tr,CLIPSegForImageSegmentation:()=>j_,CLIPSegModel:()=>U_,CLIPSegPreTrainedModel:()=>Mo,CLIPTextModel:()=>D_,CLIPTextModelWithProjection:()=>Ao,CLIPVisionModel:()=>F_,CLIPVisionModelWithProjection:()=>B_,CamembertForMaskedLM:()=>I_,CamembertForQuestionAnswering:()=>P_,CamembertForSequenceClassification:()=>C_,CamembertForTokenClassification:()=>L_,CamembertModel:()=>O_,CamembertPreTrainedModel:()=>Sr,ChatterboxModel:()=>vo,ChatterboxPreTrainedModel:()=>_c,ChineseCLIPModel:()=>z_,ChineseCLIPPreTrainedModel:()=>mc,ClapAudioModelWithProjection:()=>Eo,ClapModel:()=>$_,ClapPreTrainedModel:()=>sn,ClapTextModelWithProjection:()=>ko,CodeGenForCausalLM:()=>q_,CodeGenModel:()=>G_,CodeGenPreTrainedModel:()=>So,Cohere2ForCausalLM:()=>X_,Cohere2Model:()=>H_,Cohere2PreTrainedModel:()=>Oo,CohereForCausalLM:()=>V_,CohereModel:()=>W_,CoherePreTrainedModel:()=>To,ConvBertForMaskedLM:()=>Q_,ConvBertForQuestionAnswering:()=>Z_,ConvBertForSequenceClassification:()=>Y_,ConvBertForTokenClassification:()=>J_,ConvBertModel:()=>K_,ConvBertPreTrainedModel:()=>Tr,ConvNextForImageClassification:()=>tm,ConvNextModel:()=>em,ConvNextPreTrainedModel:()=>Io,ConvNextV2ForImageClassification:()=>sm,ConvNextV2Model:()=>rm,ConvNextV2PreTrainedModel:()=>Co,DFineForObjectDetection:()=>im,DFineModel:()=>am,DFinePreTrainedModel:()=>Po,DINOv3ConvNextModel:()=>Pm,DINOv3ConvNextPreTrainedModel:()=>kc,DINOv3ViTModel:()=>zm,DINOv3ViTPreTrainedModel:()=>Ec,DPTForDepthEstimation:()=>jm,DPTModel:()=>Um,DPTPreTrainedModel:()=>Bo,DacDecoderModel:()=>No,DacDecoderOutput:()=>wc,DacEncoderModel:()=>zo,DacEncoderOutput:()=>gc,DacModel:()=>lm,DacPreTrainedModel:()=>nn,DebertaForMaskedLM:()=>um,DebertaForQuestionAnswering:()=>fm,DebertaForSequenceClassification:()=>pm,DebertaForTokenClassification:()=>dm,DebertaModel:()=>cm,DebertaPreTrainedModel:()=>Or,DebertaV2ForMaskedLM:()=>gm,DebertaV2ForQuestionAnswering:()=>ym,DebertaV2ForSequenceClassification:()=>wm,DebertaV2ForTokenClassification:()=>xm,DebertaV2Model:()=>hm,DebertaV2PreTrainedModel:()=>Ir,DecisionTransformerModel:()=>bm,DecisionTransformerPreTrainedModel:()=>xc,DeepseekV3ForCausalLM:()=>mm,DeepseekV3Model:()=>_m,DeepseekV3PreTrainedModel:()=>$o,DeiTForImageClassification:()=>km,DeiTModel:()=>vm,DeiTPreTrainedModel:()=>Ro,DepthAnythingForDepthEstimation:()=>Em,DepthAnythingPreTrainedModel:()=>yc,DepthProForDepthEstimation:()=>Am,DepthProPreTrainedModel:()=>bc,DetrForObjectDetection:()=>Sm,DetrForSegmentation:()=>Tm,DetrModel:()=>Mm,DetrObjectDetectionOutput:()=>an,DetrPreTrainedModel:()=>on,DetrSegmentationOutput:()=>vc,Dinov2ForImageClassification:()=>Im,Dinov2Model:()=>Om,Dinov2PreTrainedModel:()=>Do,Dinov2WithRegistersForImageClassification:()=>Lm,Dinov2WithRegistersModel:()=>Cm,Dinov2WithRegistersPreTrainedModel:()=>Fo,DistilBertForMaskedLM:()=>Fm,DistilBertForQuestionAnswering:()=>Dm,DistilBertForSequenceClassification:()=>$m,DistilBertForTokenClassification:()=>Rm,DistilBertModel:()=>Nm,DistilBertPreTrainedModel:()=>Cr,DonutSwinModel:()=>Bm,DonutSwinPreTrainedModel:()=>Ac,EdgeTamModel:()=>Xx,EfficientNetForImageClassification:()=>qm,EfficientNetModel:()=>Gm,EfficientNetPreTrainedModel:()=>Uo,ElectraForMaskedLM:()=>Vm,ElectraForQuestionAnswering:()=>Km,ElectraForSequenceClassification:()=>Hm,ElectraForTokenClassification:()=>Xm,ElectraModel:()=>Wm,ElectraPreTrainedModel:()=>Lr,Ernie4_5ForCausalLM:()=>Ym,Ernie4_5Model:()=>Qm,Ernie4_5PretrainedModel:()=>jo,EsmForMaskedLM:()=>Zm,EsmForSequenceClassification:()=>eh,EsmForTokenClassification:()=>th,EsmModel:()=>Jm,EsmPreTrainedModel:()=>us,EuroBertForMaskedLM:()=>sh,EuroBertForSequenceClassification:()=>nh,EuroBertForTokenClassification:()=>oh,EuroBertModel:()=>rh,EuroBertPreTrainedModel:()=>ps,ExaoneForCausalLM:()=>ih,ExaoneModel:()=>ah,ExaonePreTrainedModel:()=>Go,FalconForCausalLM:()=>ch,FalconH1ForCausalLM:()=>ph,FalconH1Model:()=>uh,FalconH1PreTrainedModel:()=>Wo,FalconModel:()=>lh,FalconPreTrainedModel:()=>qo,FastViTForImageClassification:()=>fh,FastViTModel:()=>dh,FastViTPreTrainedModel:()=>Vo,Florence2ForConditionalGeneration:()=>_h,Florence2PreTrainedModel:()=>Mc,GLPNForDepthEstimation:()=>Sh,GLPNModel:()=>Mh,GLPNPreTrainedModel:()=>Zo,GPT2LMHeadModel:()=>Rh,GPT2Model:()=>$h,GPT2PreTrainedModel:()=>na,GPTBigCodeForCausalLM:()=>Oh,GPTBigCodeModel:()=>Th,GPTBigCodePreTrainedModel:()=>ea,GPTJForCausalLM:()=>Fh,GPTJModel:()=>Dh,GPTJPreTrainedModel:()=>oa,GPTNeoForCausalLM:()=>Ch,GPTNeoModel:()=>Ih,GPTNeoPreTrainedModel:()=>ta,GPTNeoXForCausalLM:()=>Ph,GPTNeoXModel:()=>Lh,GPTNeoXPreTrainedModel:()=>ra,Gemma2ForCausalLM:()=>wh,Gemma2Model:()=>gh,Gemma2PreTrainedModel:()=>Xo,Gemma3ForCausalLM:()=>yh,Gemma3Model:()=>xh,Gemma3PreTrainedModel:()=>Ko,Gemma3nForCausalLM:()=>Qo,Gemma3nForConditionalGeneration:()=>ln,Gemma3nPreTrainedModel:()=>Sc,GemmaForCausalLM:()=>hh,GemmaModel:()=>mh,GemmaPreTrainedModel:()=>Ho,GlmForCausalLM:()=>vh,GlmModel:()=>bh,GlmMoeDsaForCausalLM:()=>Eh,GlmMoeDsaModel:()=>kh,GlmMoeDsaPreTrainedModel:()=>Jo,GlmOcrForConditionalGeneration:()=>Ah,GlmPreTrainedModel:()=>Yo,GptOssForCausalLM:()=>Nh,GptOssModel:()=>zh,GptOssPreTrainedModel:()=>sa,GraniteForCausalLM:()=>Uh,GraniteModel:()=>Bh,GraniteMoeHybridForCausalLM:()=>Gh,GraniteMoeHybridModel:()=>jh,GraniteMoeHybridPreTrainedModel:()=>ia,GranitePreTrainedModel:()=>aa,GraniteSpeechForConditionalGeneration:()=>qh,GroundingDinoForObjectDetection:()=>Wh,GroundingDinoPreTrainedModel:()=>Ic,GroupViTModel:()=>Vh,GroupViTPreTrainedModel:()=>Cc,HeliumForCausalLM:()=>Xh,HeliumModel:()=>Hh,HeliumPreTrainedModel:()=>la,HieraForImageClassification:()=>Qh,HieraModel:()=>Kh,HieraPreTrainedModel:()=>ca,HubertForCTC:()=>sg,HubertForSequenceClassification:()=>ng,HubertModel:()=>rg,HubertPreTrainedModel:()=>tg,HunYuanDenseV1ForCausalLM:()=>ag,HunYuanDenseV1Model:()=>og,HunYuanDenseV1PreTrainedModel:()=>ua,IJepaForImageClassification:()=>pg,IJepaModel:()=>ug,IJepaPreTrainedModel:()=>pa,Idefics3ForConditionalGeneration:()=>cg,JAISLMHeadModel:()=>fg,JAISModel:()=>dg,JAISPreTrainedModel:()=>da,JinaCLIPModel:()=>_g,JinaCLIPPreTrainedModel:()=>un,JinaCLIPTextModel:()=>fa,JinaCLIPVisionModel:()=>mg,Lfm2ForCausalLM:()=>gg,Lfm2Model:()=>hg,Lfm2MoeForCausalLM:()=>yg,Lfm2MoeModel:()=>xg,Lfm2MoePreTrainedModel:()=>ma,Lfm2PreTrainedModel:()=>_a,Lfm2VlForConditionalGeneration:()=>bg,LightOnOcrForConditionalGeneration:()=>wg,LiteWhisperForConditionalGeneration:()=>l0,Llama4ForCausalLM:()=>Eg,Llama4PreTrainedModel:()=>Pc,LlamaForCausalLM:()=>kg,LlamaModel:()=>vg,LlamaPreTrainedModel:()=>ha,LlavaForConditionalGeneration:()=>Tt,LlavaOnevisionForConditionalGeneration:()=>Tt,LlavaPreTrainedModel:()=>Lc,LlavaQwen2ForCausalLM:()=>lg,LongT5ForConditionalGeneration:()=>Mg,LongT5Model:()=>Ag,LongT5PreTrainedModel:()=>ga,M2M100ForConditionalGeneration:()=>Tg,M2M100Model:()=>Sg,M2M100PreTrainedModel:()=>wa,MBartForCausalLM:()=>$g,MBartForConditionalGeneration:()=>zg,MBartForSequenceClassification:()=>Ng,MBartModel:()=>Pg,MBartPreTrainedModel:()=>hs,MPNetForMaskedLM:()=>vw,MPNetForQuestionAnswering:()=>Aw,MPNetForSequenceClassification:()=>kw,MPNetForTokenClassification:()=>Ew,MPNetModel:()=>bw,MPNetPreTrainedModel:()=>Pr,MT5ForConditionalGeneration:()=>Ow,MT5Model:()=>Tw,MT5PreTrainedModel:()=>Ca,MarianMTModel:()=>Ig,MarianModel:()=>Og,MarianPreTrainedModel:()=>xa,MaskFormerForInstanceSegmentation:()=>Lg,MaskFormerModel:()=>Cg,MaskFormerPreTrainedModel:()=>ya,Metric3DForDepthEstimation:()=>Rg,Metric3DPreTrainedModel:()=>zc,Metric3Dv2ForDepthEstimation:()=>Dg,Metric3Dv2PreTrainedModel:()=>Nc,MgpstrForSceneTextRecognition:()=>Fg,MgpstrModelOutput:()=>$c,MgpstrPreTrainedModel:()=>Rc,MimiDecoderModel:()=>va,MimiDecoderOutput:()=>Fc,MimiEncoderModel:()=>ba,MimiEncoderOutput:()=>Dc,MimiModel:()=>Bg,MimiPreTrainedModel:()=>pn,Mistral4ForCausalLM:()=>qg,Mistral4Model:()=>Gg,Mistral4PreTrainedModel:()=>Ea,MistralForCausalLM:()=>jg,MistralModel:()=>Ug,MistralPreTrainedModel:()=>ka,MobileBertForMaskedLM:()=>Vg,MobileBertForQuestionAnswering:()=>Xg,MobileBertForSequenceClassification:()=>Hg,MobileBertModel:()=>Wg,MobileBertPreTrainedModel:()=>gs,MobileLLMForCausalLM:()=>Qg,MobileLLMModel:()=>Kg,MobileLLMPreTrainedModel:()=>Aa,MobileNetV1ForImageClassification:()=>Jg,MobileNetV1ForSemanticSegmentation:()=>Zg,MobileNetV1Model:()=>Yg,MobileNetV1PreTrainedModel:()=>dn,MobileNetV2ForImageClassification:()=>tw,MobileNetV2ForSemanticSegmentation:()=>rw,MobileNetV2Model:()=>ew,MobileNetV2PreTrainedModel:()=>fn,MobileNetV3ForImageClassification:()=>nw,MobileNetV3ForSemanticSegmentation:()=>ow,MobileNetV3Model:()=>sw,MobileNetV3PreTrainedModel:()=>_n,MobileNetV4ForImageClassification:()=>iw,MobileNetV4ForSemanticSegmentation:()=>lw,MobileNetV4Model:()=>aw,MobileNetV4PreTrainedModel:()=>mn,MobileViTForImageClassification:()=>uw,MobileViTModel:()=>cw,MobileViTPreTrainedModel:()=>Ma,MobileViTV2ForImageClassification:()=>dw,MobileViTV2Model:()=>pw,MobileViTV2PreTrainedModel:()=>Sa,ModernBertDecoderForCausalLM:()=>ww,ModernBertDecoderModel:()=>gw,ModernBertDecoderPreTrainedModel:()=>Ta,ModernBertForMaskedLM:()=>_w,ModernBertForSequenceClassification:()=>mw,ModernBertForTokenClassification:()=>hw,ModernBertModel:()=>fw,ModernBertPreTrainedModel:()=>ws,Moondream1ForConditionalGeneration:()=>ig,MoonshineForConditionalGeneration:()=>yw,MoonshineModel:()=>xw,MoonshinePreTrainedModel:()=>Oa,MptForCausalLM:()=>Sw,MptModel:()=>Mw,MptPreTrainedModel:()=>Ia,MultiModalityCausalLM:()=>Iw,MultiModalityPreTrainedModel:()=>Bc,MusicgenForCausalLM:()=>Lw,MusicgenForConditionalGeneration:()=>Pa,MusicgenModel:()=>Cw,MusicgenPreTrainedModel:()=>La,NanoChatForCausalLM:()=>zw,NanoChatModel:()=>Pw,NanoChatPreTrainedModel:()=>za,NemotronHForCausalLM:()=>$w,NemotronHModel:()=>Nw,NemotronHPreTrainedModel:()=>Na,NeoBertForMaskedLM:()=>Dw,NeoBertForQuestionAnswering:()=>Uw,NeoBertForSequenceClassification:()=>Fw,NeoBertForTokenClassification:()=>Bw,NeoBertModel:()=>Rw,NeoBertPreTrainedModel:()=>zr,NomicBertModel:()=>jw,NomicBertPreTrainedModel:()=>Uc,OPTForCausalLM:()=>ex,OPTModel:()=>Zw,OPTPreTrainedModel:()=>Ua,Olmo2ForCausalLM:()=>Vw,Olmo2Model:()=>Ww,Olmo2PreTrainedModel:()=>Ra,Olmo3ForCausalLM:()=>Xw,Olmo3Model:()=>Hw,Olmo3PreTrainedModel:()=>Da,OlmoForCausalLM:()=>qw,OlmoHybridForCausalLM:()=>Qw,OlmoHybridModel:()=>Kw,OlmoHybridPreTrainedModel:()=>Fa,OlmoModel:()=>Gw,OlmoPreTrainedModel:()=>$a,OpenELMForCausalLM:()=>Jw,OpenELMModel:()=>Yw,OpenELMPreTrainedModel:()=>Ba,OwlViTForObjectDetection:()=>nx,OwlViTModel:()=>sx,OwlViTPreTrainedModel:()=>Ga,Owlv2ForObjectDetection:()=>rx,Owlv2Model:()=>tx,Owlv2PreTrainedModel:()=>ja,PaliGemmaForConditionalGeneration:()=>ox,ParakeetForCTC:()=>ax,ParakeetPreTrainedModel:()=>jc,PatchTSMixerForPrediction:()=>lx,PatchTSMixerModel:()=>ix,PatchTSMixerPreTrainedModel:()=>qa,PatchTSTForPrediction:()=>ux,PatchTSTModel:()=>cx,PatchTSTPreTrainedModel:()=>Wa,Phi3ForCausalLM:()=>_x,Phi3Model:()=>fx,Phi3PreTrainedModel:()=>Ha,Phi3VForCausalLM:()=>Xa,Phi3VPreTrainedModel:()=>Gc,PhiForCausalLM:()=>dx,PhiModel:()=>px,PhiPreTrainedModel:()=>Va,PreTrainedModel:()=>y,PvtForImageClassification:()=>hx,PvtModel:()=>mx,PvtPreTrainedModel:()=>Ka,PyAnnoteForAudioFrameClassification:()=>wx,PyAnnoteModel:()=>gx,PyAnnotePreTrainedModel:()=>Qa,Qwen2ForCausalLM:()=>yx,Qwen2Model:()=>xx,Qwen2MoeForCausalLM:()=>vx,Qwen2MoeModel:()=>bx,Qwen2MoePreTrainedModel:()=>Ja,Qwen2PreTrainedModel:()=>Ya,Qwen2VLForCausalLM:()=>ds,Qwen2VLForConditionalGeneration:()=>cn,Qwen2VLPreTrainedModel:()=>Tc,Qwen2_5_VLForCausalLM:()=>_s,Qwen2_5_VLForConditionalGeneration:()=>fs,Qwen3ForCausalLM:()=>Ex,Qwen3Model:()=>kx,Qwen3MoeForCausalLM:()=>Mx,Qwen3MoeModel:()=>Ax,Qwen3MoePreTrainedModel:()=>ei,Qwen3NextForCausalLM:()=>Tx,Qwen3NextModel:()=>Sx,Qwen3NextPreTrainedModel:()=>ti,Qwen3PreTrainedModel:()=>Za,Qwen3VLForCausalLM:()=>ys,Qwen3VLForConditionalGeneration:()=>xs,Qwen3VLMoeForCausalLM:()=>ri,Qwen3VLMoeForConditionalGeneration:()=>Ox,Qwen3_5ForCausalLM:()=>bs,Qwen3_5ForConditionalGeneration:()=>hn,Qwen3_5MoeForCausalLM:()=>si,Qwen3_5MoeForConditionalGeneration:()=>Ix,RFDetrForObjectDetection:()=>zx,RFDetrModel:()=>Px,RFDetrObjectDetectionOutput:()=>qc,RFDetrPreTrainedModel:()=>oi,RTDetrForObjectDetection:()=>om,RTDetrModel:()=>nm,RTDetrObjectDetectionOutput:()=>rr,RTDetrPreTrainedModel:()=>Lo,RTDetrV2ForObjectDetection:()=>Vx,RTDetrV2Model:()=>Wx,RTDetrV2ObjectDetectionOutput:()=>Wc,RTDetrV2PreTrainedModel:()=>ai,ResNetForImageClassification:()=>Lx,ResNetModel:()=>Cx,ResNetPreTrainedModel:()=>ni,RoFormerForMaskedLM:()=>Ux,RoFormerForQuestionAnswering:()=>qx,RoFormerForSequenceClassification:()=>jx,RoFormerForTokenClassification:()=>Gx,RoFormerModel:()=>Bx,RoFormerPreTrainedModel:()=>$r,RobertaForMaskedLM:()=>$x,RobertaForQuestionAnswering:()=>Fx,RobertaForSequenceClassification:()=>Rx,RobertaForTokenClassification:()=>Dx,RobertaModel:()=>Nx,RobertaPreTrainedModel:()=>Nr,Sam2ImageSegmentationOutput:()=>Xc,Sam2Model:()=>ii,Sam2PreTrainedModel:()=>Kc,Sam3TrackerModel:()=>Kx,SamImageSegmentationOutput:()=>Vc,SamModel:()=>Hx,SamPreTrainedModel:()=>Hc,SapiensForDepthEstimation:()=>Yx,SapiensForNormalEstimation:()=>Jx,SapiensForSemanticSegmentation:()=>Qx,SapiensPreTrainedModel:()=>gn,SegformerForImageClassification:()=>ey,SegformerForSemanticSegmentation:()=>ty,SegformerModel:()=>Zx,SegformerPreTrainedModel:()=>wn,SiglipModel:()=>ry,SiglipPreTrainedModel:()=>li,SiglipTextModel:()=>ci,SiglipVisionModel:()=>sy,SmolLM3ForCausalLM:()=>oy,SmolLM3Model:()=>ny,SmolLM3PreTrainedModel:()=>ui,SnacDecoderModel:()=>di,SnacEncoderModel:()=>pi,SnacModel:()=>ay,SnacPreTrainedModel:()=>xn,SolarOpenForCausalLM:()=>ly,SolarOpenModel:()=>iy,SolarOpenPreTrainedModel:()=>fi,SpeechT5ForSpeechToText:()=>uy,SpeechT5ForTextToSpeech:()=>py,SpeechT5HifiGan:()=>dy,SpeechT5Model:()=>cy,SpeechT5PreTrainedModel:()=>yn,SqueezeBertForMaskedLM:()=>_y,SqueezeBertForQuestionAnswering:()=>hy,SqueezeBertForSequenceClassification:()=>my,SqueezeBertModel:()=>fy,SqueezeBertPreTrainedModel:()=>vs,StableLmForCausalLM:()=>wy,StableLmModel:()=>gy,StableLmPreTrainedModel:()=>_i,Starcoder2ForCausalLM:()=>yy,Starcoder2Model:()=>xy,Starcoder2PreTrainedModel:()=>mi,StyleTextToSpeech2Model:()=>by,StyleTextToSpeech2PreTrainedModel:()=>Qc,SupertonicForConditionalGeneration:()=>hi,SupertonicPreTrainedModel:()=>Yc,Swin2SRForImageSuperResolution:()=>My,Swin2SRModel:()=>Ay,Swin2SRPreTrainedModel:()=>gi,SwinForImageClassification:()=>ky,SwinForSemanticSegmentation:()=>Ey,SwinModel:()=>vy,SwinPreTrainedModel:()=>bn,T5ForConditionalGeneration:()=>Ty,T5Model:()=>Sy,T5PreTrainedModel:()=>wi,TableTransformerForObjectDetection:()=>Iy,TableTransformerModel:()=>Oy,TableTransformerObjectDetectionOutput:()=>Jc,TableTransformerPreTrainedModel:()=>xi,TrOCRForCausalLM:()=>Cy,TrOCRPreTrainedModel:()=>Zc,UltravoxModel:()=>ms,UltravoxPreTrainedModel:()=>Oc,UniSpeechForCTC:()=>Py,UniSpeechForSequenceClassification:()=>zy,UniSpeechModel:()=>Ly,UniSpeechPreTrainedModel:()=>vn,UniSpeechSatForAudioFrameClassification:()=>Dy,UniSpeechSatForCTC:()=>$y,UniSpeechSatForSequenceClassification:()=>Ry,UniSpeechSatModel:()=>Ny,UniSpeechSatPreTrainedModel:()=>ks,VaultGemmaForCausalLM:()=>By,VaultGemmaModel:()=>Fy,VaultGemmaPreTrainedModel:()=>yi,ViTForImageClassification:()=>Gy,ViTMAEModel:()=>qy,ViTMAEPreTrainedModel:()=>eu,ViTMSNForImageClassification:()=>Vy,ViTMSNModel:()=>Wy,ViTMSNPreTrainedModel:()=>vi,ViTModel:()=>jy,ViTPreTrainedModel:()=>bi,VisionEncoderDecoderModel:()=>Uy,VitMatteForImageMatting:()=>Hy,VitMattePreTrainedModel:()=>tu,VitPoseForPoseEstimation:()=>Xy,VitPosePreTrainedModel:()=>ru,VitsModel:()=>Ky,VitsModelOutput:()=>su,VitsPreTrainedModel:()=>nu,VoxtralForConditionalGeneration:()=>Qy,VoxtralRealtimeForConditionalGeneration:()=>ki,VoxtralRealtimePreTrainedModel:()=>ou,Wav2Vec2BertForCTC:()=>Jy,Wav2Vec2BertForSequenceClassification:()=>Zy,Wav2Vec2BertModel:()=>Yy,Wav2Vec2BertPreTrainedModel:()=>kn,Wav2Vec2ForAudioFrameClassification:()=>eg,Wav2Vec2ForCTC:()=>Jh,Wav2Vec2ForSequenceClassification:()=>Zh,Wav2Vec2Model:()=>Yh,Wav2Vec2PreTrainedModel:()=>qt,WavLMForAudioFrameClassification:()=>n0,WavLMForCTC:()=>t0,WavLMForSequenceClassification:()=>r0,WavLMForXVector:()=>s0,WavLMModel:()=>e0,WavLMPreTrainedModel:()=>Rr,WeSpeakerResNetModel:()=>o0,WeSpeakerResNetPreTrainedModel:()=>iu,WhisperForConditionalGeneration:()=>lu,WhisperModel:()=>i0,WhisperPreTrainedModel:()=>Ei,XLMForQuestionAnswering:()=>f0,XLMForSequenceClassification:()=>p0,XLMForTokenClassification:()=>d0,XLMModel:()=>c0,XLMPreTrainedModel:()=>Dr,XLMRobertaForMaskedLM:()=>m0,XLMRobertaForQuestionAnswering:()=>w0,XLMRobertaForSequenceClassification:()=>h0,XLMRobertaForTokenClassification:()=>g0,XLMRobertaModel:()=>_0,XLMRobertaPreTrainedModel:()=>Fr,XLMWithLMHeadModel:()=>u0,XVectorOutput:()=>au,YolosForObjectDetection:()=>y0,YolosModel:()=>x0,YolosObjectDetectionOutput:()=>cu,YolosPreTrainedModel:()=>Ai,YoutuForCausalLM:()=>v0,YoutuModel:()=>b0,YoutuPreTrainedModel:()=>Mi});var cs=class extends y{},t_=class extends cs{},r_=class extends cs{async _call(e){return new j(await super._call(e))}},s_=class extends cs{async _call(e){return new Ae(await super._call(e))}},n_=class extends cs{async _call(e){return new ge(await super._call(e))}};var _o=class extends y{},o_=class extends _o{},a_=class extends _o{};var mo=class extends y{},i_=class extends mo{},l_=class extends mo{};var ho=class extends y{},c_=class extends ho{},u_=class extends ho{};var go=class extends y{},p_=class extends go{},d_=class extends go{};var rn=class extends y{},f_=class extends rn{},__=class extends rn{},m_=class extends rn{async _call(e){return new j(await super._call(e))}};var wo=class extends y{},h_=class extends wo{},g_=class extends wo{async _call(e){return new j(await super._call(e))}};var Mr=class extends y{},w_=class extends Mr{},x_=class extends Mr{async _call(e){return new ge(await super._call(e))}},y_=class extends Mr{async _call(e){return new j(await super._call(e))}},b_=class extends Mr{async _call(e){return new he(await super._call(e))}},v_=class extends Mr{async _call(e){return new Ae(await super._call(e))}};var xo=class extends y{},k_=class extends xo{},E_=class extends xo{};var yo=class extends y{},A_=class extends yo{},M_=class extends yo{};var bo=class extends y{},S_=class extends bo{},T_=class extends bo{};var Sr=class extends y{},O_=class extends Sr{},I_=class extends Sr{async _call(e){return new ge(await super._call(e))}},C_=class extends Sr{async _call(e){return new j(await super._call(e))}},L_=class extends Sr{async _call(e){return new he(await super._call(e))}},P_=class extends Sr{async _call(e){return new Ae(await super._call(e))}};var hN=4299n,xM=6561n,_c=class extends y{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"]},vo=class extends _c{async encode_speech(e){return de(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:r=null,audio_values:s=null,exaggeration:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:c=null,audio_features:p=null,audio_tokens:d=null,speaker_embeddings:_=null,speaker_features:m=null,...w}){let x;if(!a){let k=this.sessions.embed_tokens.inputNames,A={input_ids:e};if(k.includes("exaggeration")){if(!(n instanceof N)){let T=e.dims[0];if(n==null)n=qe([T],.5);else if(typeof n=="number")n=qe([T],n);else if(Array.isArray(n))n=new N("float32",n,[T]);else throw new Error("Unsupported type for `exaggeration` input")}A.exaggeration=n}if(k.includes("position_ids")&&(A.position_ids=o),{inputs_embeds:a}=await de(this.sessions.embed_tokens,A),p&&d&&_&&m&&(x={audio_features:p,audio_tokens:d,speaker_embeddings:_,speaker_features:m}),x||s)x??=await this.encode_speech(s),a=ve([x.audio_features,a],1),r=Je([a.dims[0],a.dims[1]]);else{let T=a.dims[1];if(!i||T!==1)throw new Error("Incorrect state encountered during generation.");let S=i.get_seq_length();r=Je([a.dims[0],S+T])}}return{...await Ot(this,{inputs_embeds:a,past_key_values:i,attention_mask:r,generation_config:l,logits_processor:c},!1),...x}}prepare_inputs_for_generation(e,r,s){if(!r.position_ids&&this.sessions.embed_tokens.inputNames.includes("position_ids"))if(r.input_ids.dims[1]===1){let n=Array.from({length:e.length},(o,a)=>e[a].length-e[a].findLastIndex(i=>i==xM)-1);r.position_ids=new N("int64",n,[e.length,1])}else{let o=r.input_ids.tolist().map(a=>{let i=0;return a.map(l=>l>=xM?0:i++)});r.position_ids=new N("int64",o.flat(),r.input_ids.dims)}return r.input_ids.dims[1]===1&&(delete r.audio_values,delete r.audio_features,delete r.audio_tokens,delete r.speaker_embeddings,delete r.speaker_features),po(this,e,r,s)}async generate(e){let{sequences:r,audio_tokens:s,speaker_embeddings:n,speaker_features:o}=await super.generate({...e,return_dict_in_generate:!0}),a=r.slice(null,[e.input_ids.dims[1],-1]),i=qe([a.dims[0],3],hN),l=ve([s,a,i],1),{waveform:c}=await de(this.sessions.conditional_decoder,{speech_tokens:l,speaker_features:o,speaker_embeddings:n});return c}};var mc=class extends y{},z_=class extends mc{};var hc=class extends y{},N_=class extends hc{};var sn=class extends y{},$_=class extends sn{},ko=class extends sn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},Eo=class extends sn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"audio_model"})}};var tr=class extends y{},R_=class extends tr{},D_=class extends tr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},Ao=class extends tr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},F_=class extends tr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}},B_=class extends tr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var Mo=class extends y{},U_=class extends Mo{},j_=class extends Mo{};var So=class extends y{},G_=class extends So{},q_=class extends So{};var To=class extends y{},W_=class extends To{},V_=class extends To{};var Oo=class extends y{},H_=class extends Oo{},X_=class extends Oo{};var Tr=class extends y{},K_=class extends Tr{},Q_=class extends Tr{async _call(e){return new ge(await super._call(e))}},Y_=class extends Tr{async _call(e){return new j(await super._call(e))}},J_=class extends Tr{async _call(e){return new he(await super._call(e))}},Z_=class extends Tr{async _call(e){return new Ae(await super._call(e))}};var Io=class extends y{},em=class extends Io{},tm=class extends Io{async _call(e){return new j(await super._call(e))}};var Co=class extends y{},rm=class extends Co{},sm=class extends Co{async _call(e){return new j(await super._call(e))}};var Lo=class extends y{},nm=class extends Lo{},om=class extends Lo{async _call(e){return new rr(await super._call(e))}},rr=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var Po=class extends y{},am=class extends Po{},im=class extends Po{async _call(e){return new rr(await super._call(e))}};var gc=class extends $e{constructor({audio_codes:e}){super(),this.audio_codes=e}},wc=class extends $e{constructor({audio_values:e}){super(),this.audio_values=e}},nn=class extends y{main_input_name="input_values";forward_params=["input_values"]},lm=class extends nn{async encode(e){return new gc(await de(this.sessions.encoder_model,e))}async decode(e){return new wc(await de(this.sessions.decoder_model,e))}},zo=class extends nn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},No=class extends nn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var Or=class extends y{},cm=class extends Or{},um=class extends Or{async _call(e){return new ge(await super._call(e))}},pm=class extends Or{async _call(e){return new j(await super._call(e))}},dm=class extends Or{async _call(e){return new he(await super._call(e))}},fm=class extends Or{async _call(e){return new Ae(await super._call(e))}};var $o=class extends y{},_m=class extends $o{},mm=class extends $o{};var Ir=class extends y{},hm=class extends Ir{},gm=class extends Ir{async _call(e){return new ge(await super._call(e))}},wm=class extends Ir{async _call(e){return new j(await super._call(e))}},xm=class extends Ir{async _call(e){return new he(await super._call(e))}},ym=class extends Ir{async _call(e){return new Ae(await super._call(e))}};var xc=class extends y{},bm=class extends xc{};var Ro=class extends y{},vm=class extends Ro{},km=class extends Ro{async _call(e){return new j(await super._call(e))}};var yc=class extends y{},Em=class extends yc{};var bc=class extends y{},Am=class extends bc{};var on=class extends y{},Mm=class extends on{},Sm=class extends on{async _call(e){return new an(await super._call(e))}},Tm=class extends on{async _call(e){return new vc(await super._call(e))}},an=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}},vc=class extends $e{constructor({logits:e,pred_boxes:r,pred_masks:s}){super(),this.logits=e,this.pred_boxes=r,this.pred_masks=s}};var Do=class extends y{},Om=class extends Do{},Im=class extends Do{async _call(e){return new j(await super._call(e))}};var Fo=class extends y{},Cm=class extends Fo{},Lm=class extends Fo{async _call(e){return new j(await super._call(e))}};var kc=class extends y{},Pm=class extends kc{};var Ec=class extends y{},zm=class extends Ec{};var Cr=class extends y{},Nm=class extends Cr{},$m=class extends Cr{async _call(e){return new j(await super._call(e))}},Rm=class extends Cr{async _call(e){return new he(await super._call(e))}},Dm=class extends Cr{async _call(e){return new Ae(await super._call(e))}},Fm=class extends Cr{async _call(e){return new ge(await super._call(e))}};var Ac=class extends y{},Bm=class extends Ac{};var Bo=class extends y{},Um=class extends Bo{},jm=class extends Bo{};var Uo=class extends y{},Gm=class extends Uo{},qm=class extends Uo{async _call(e){return new j(await super._call(e))}};var Lr=class extends y{},Wm=class extends Lr{},Vm=class extends Lr{async _call(e){return new ge(await super._call(e))}},Hm=class extends Lr{async _call(e){return new j(await super._call(e))}},Xm=class extends Lr{async _call(e){return new he(await super._call(e))}},Km=class extends Lr{async _call(e){return new Ae(await super._call(e))}};var jo=class extends y{},Qm=class extends jo{},Ym=class extends jo{};var us=class extends y{},Jm=class extends us{},Zm=class extends us{async _call(e){return new ge(await super._call(e))}},eh=class extends us{async _call(e){return new j(await super._call(e))}},th=class extends us{async _call(e){return new he(await super._call(e))}};var ps=class extends y{},rh=class extends ps{},sh=class extends ps{async _call(e){return new ge(await super._call(e))}},nh=class extends ps{async _call(e){return new j(await super._call(e))}},oh=class extends ps{async _call(e){return new he(await super._call(e))}};var Go=class extends y{},ah=class extends Go{},ih=class extends Go{};var qo=class extends y{},lh=class extends qo{},ch=class extends qo{};var Wo=class extends y{},uh=class extends Wo{},ph=class extends Wo{};var Vo=class extends y{},dh=class extends Vo{},fh=class extends Vo{async _call(e){return new j(await super._call(e))}};var Mc=class extends y{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"},_h=class extends Mc{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return{inputs_embeds:ve([r,e],1),attention_mask:ve([Je(r.dims.slice(0,2)),n],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:r,inputs_embeds:s,attention_mask:n}){if(!e&&!r)throw new Error("Either `input_ids` or `pixel_values` should be provided.");let o,a;return e&&(o=await this.encode_text({input_ids:e})),r&&(a=await this.encode_image({pixel_values:r})),o&&a?{inputs_embeds:s,attention_mask:n}=this._merge_input_ids_with_image_features({inputs_embeds:o,image_features:a,input_ids:e,attention_mask:n}):s=o||a,{inputs_embeds:s,attention_mask:n}}async forward({input_ids:e,pixel_values:r,attention_mask:s,decoder_input_ids:n,decoder_attention_mask:o,encoder_outputs:a,past_key_values:i,inputs_embeds:l,decoder_inputs_embeds:c}){if(l||({inputs_embeds:l,attention_mask:s}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:r,inputs_embeds:l,attention_mask:s})),!a){let{last_hidden_state:d}=await Gt(this,{inputs_embeds:l,attention_mask:s});a=d}if(!c){if(!n)throw new Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:n})}return await Ot(this,{inputs_embeds:c,attention_mask:o,encoder_attention_mask:s,encoder_hidden_states:a,past_key_values:i},!0)}};var Ho=class extends y{},mh=class extends Ho{},hh=class extends Ho{};var Xo=class extends y{},gh=class extends Xo{},wh=class extends Xo{};var Ko=class extends y{},xh=class extends Ko{},yh=class extends Ko{};var Sc=class extends y{forward_params=["input_ids","attention_mask","inputs_embeds","per_layer_inputs","position_ids","pixel_values","input_features","input_features_mask","past_key_values"]},ln=class extends Sc{async forward({input_ids:e=null,attention_mask:r=null,pixel_values:s=null,input_features:n=null,input_features_mask:o=null,position_ids:a=null,inputs_embeds:i=null,per_layer_inputs:l=null,past_key_values:c=null,generation_config:p=null,logits_processor:d=null,..._}){if((!i||!l)&&({inputs_embeds:i,per_layer_inputs:l}=await de(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(s){let{image_features:w}=await de(this.sessions.vision_encoder,{pixel_values:s});({inputs_embeds:i,attention_mask:r}=this._merge_input_ids_with_image_features({image_features:w,inputs_embeds:i,input_ids:e,attention_mask:r}))}if(n){let{audio_features:w}=await de(this.sessions.audio_encoder,{input_features:n,input_features_mask:o});({inputs_embeds:i,attention_mask:r}=this._merge_input_ids_with_audio_features({audio_features:w,inputs_embeds:i,input_ids:e,attention_mask:r}))}}return await Ot(this,{inputs_embeds:i,per_layer_inputs:l,past_key_values:c,attention_mask:r,position_ids:a,generation_config:p,logits_processor:d},!0)}_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return fo({image_token_id:this.config.image_token_id,...e,image_features:s})}_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return e_({audio_token_id:this.config.audio_token_id,...e,audio_features:s})}},Qo=class extends ln{};var Yo=class extends y{},bh=class extends Yo{},vh=class extends Yo{};var Jo=class extends y{},kh=class extends Jo{},Eh=class extends Jo{};var Tc=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},cn=class extends Tc{image_grid_thw_name="grid_thw";_get_text_only_rope_index(e,r){if(r){let{data:s,dims:n}=B1(r),o=BigInt64Array.from({length:3*s.length},(i,l)=>s[l%s.length]),a=Array.from({length:n[0]},(i,l)=>Ce(s.subarray(n[1]*l,n[1]*(l+1)))[0]+1n+BigInt(n[1]));return[new N("int64",o,[3,...n]),new N("int64",a,[a.length,1])]}else{let[s,n]=e.dims,o=BigInt64Array.from({length:3*s*n},(a,i)=>BigInt(Math.floor(i%n/s)));return[new N("int64",o,[3,...e.dims]),vp([s,1])]}}_reorder_and_write_positions(e,r,s,n){let o=e.reduce((c,p)=>c+p.length,0),a=new Array(o),i=0;for(let c=0;c<3;++c)for(let p of e){let d=p.length/3;for(let _=c*d;_<(c+1)*d;++_)a[i++]=p[_]}let l=0;for(let c=0;c<r.length;++c)if(r[c]==1){for(let p=0;p<3;++p)s[p][n][c]=a[p*o/3+l];++l}return a}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:r,video_grid_thw_list:s,spatial_merge_size:n,state:o}){let{image_token_id:a,video_token_id:i,vision_start_token_id:l}=this.config,c=e,d=c.reduce((A,T,S)=>(T==l&&A.push(S),A),[]).map(A=>c[A+1]),_=d.filter(A=>A==a).length,m=d.filter(A=>A==i).length,w=[],x=0,E=_,k=m;for(let A=0;A<d.length;++A){let T=c.findIndex((J,xe)=>xe>x&&J==a),S=c.findIndex((J,xe)=>xe>x&&J==i),L=E>0&&T!==-1?T:c.length+1,O=k>0&&S!==-1?S:c.length+1,v,W,X,B;L<O?([W,X,B]=r[o.image_index],++o.image_index,--E,v=L):([W,X,B]=s[o.video_index],++o.video_index,--k,v=O);let[H,G,Q]=[Number(W),Math.floor(Number(X)/n),Math.floor(Number(B)/n)],R=v-x,C=w.length>0?Ce(w.at(-1))[0]+1:0;w.push(Array.from({length:3*R},(J,xe)=>C+xe%R));let te=R+C,ae=H*G*Q,P=Array.from({length:ae},(J,xe)=>te+Math.floor(xe/(G*Q))),$=Array.from({length:ae},(J,xe)=>te+Math.floor(xe/Q)%G),F=Array.from({length:ae},(J,xe)=>te+xe%Q);w.push([P,$,F].flat()),x=v+ae}if(x<c.length){let A=w.length>0?Ce(w.at(-1))[0]+1:0,T=c.length-x;w.push(Array.from({length:3*T},(S,L)=>A+L%T))}return w}get_rope_index(e,r,s,n){let{vision_config:o}=this.config,a=o.spatial_merge_size??2;if(r||s){let i=e.tolist();n||(n=Ll(e));let l=n.tolist(),c=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),p=r?r.tolist():[],d=s?s.tolist():[],_={image_index:0,video_index:0},m=[];for(let w=0;w<i.length;++w){let x=i[w].filter((A,T)=>l[w][T]==1),E=this._get_multimodal_rope_positions({filtered_ids:x,image_grid_thw_list:p,video_grid_thw_list:d,spatial_merge_size:a,state:_}),k=this._reorder_and_write_positions(E,l[w],c,w);m.push(Ce(k)[0]+1-i[w].length)}return[new N("int64",c.flat(1/0),[3,e.dims[0],e.dims[1]]),new N("int64",m,[m.length,1])]}else return this._get_text_only_rope_index(e,n)}async encode_image({pixel_values:e,image_grid_thw:r}){return(await de(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:r})).image_features}_merge_input_ids_with_image_features(e){return fo({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,r,s){if(r.attention_mask&&!r.position_ids)if(!r.past_key_values)[r.position_ids,r.rope_deltas]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask);else{r.pixel_values=null;let n=r.past_key_values.get_seq_length();if(n<r.input_ids.dims[1]){let[o,a]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask);r.rope_deltas=a,r.position_ids=o.slice(null,null,[n,null]),r.input_ids=r.input_ids.slice(null,[n,null])}else{r.rope_deltas||([,r.rope_deltas]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask));let o=BigInt(n),a=r.rope_deltas.map(i=>o+i);r.position_ids=St([a,a,a],0)}}return r}},ds=class extends cn{};var fs=class extends cn{image_grid_thw_name="image_grid_thw"},_s=class extends ds{image_grid_thw_name="image_grid_thw"};var Ah=class extends fs{get_vision_position_ids(e,r,s,n){let o=Math.floor(r[0]/s),a=Math.floor(r[1]/n),i=Math.floor(r[2]/n),l=a*i*o,c=Array.from({length:l},()=>e),p=Array.from({length:l},(_,m)=>e+Math.floor(m/(i*o))),d=Array.from({length:l},(_,m)=>e+m%i);return[...c,...p,...d]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:r,video_grid_thw_list:s,spatial_merge_size:n,state:o}){let{image_token_id:a}=this.config,i=[],l=0,c=e[0]==a?1:0;for(let _=1;_<=e.length;++_){let m=_<e.length?e[_]==a?1:0:-1;m!==c&&(i.push([c,l,_]),l=_,c=m)}let p=0,d=[];for(let[_,m,w]of i)if(_===0){let x=w-m;d.push(Array.from({length:3*x},(E,k)=>p+k%x)),p+=x}else{let x=r[o.image_index++].map(Number),E=x[0];d.push(this.get_vision_position_ids(p,x,E,n)),p+=Math.max(x[1],x[2])/n}return d}};var Zo=class extends y{},Mh=class extends Zo{},Sh=class extends Zo{};var ea=class extends y{},Th=class extends ea{},Oh=class extends ea{};var ta=class extends y{},Ih=class extends ta{},Ch=class extends ta{};var ra=class extends y{},Lh=class extends ra{},Ph=class extends ra{};var sa=class extends y{},zh=class extends sa{},Nh=class extends sa{};var na=class extends y{},$h=class extends na{},Rh=class extends na{};var oa=class extends y{},Dh=class extends oa{},Fh=class extends oa{};var aa=class extends y{},Bh=class extends aa{},Uh=class extends aa{};var ia=class extends y{},jh=class extends ia{},Gh=class extends ia{};var Oc=class extends y{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},ms=class extends Oc{_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return e_({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:s})}};var qh=class extends ms{forward_params=["input_ids","attention_mask","input_features","past_key_values"]};var Ic=class extends y{},Wh=class extends Ic{};var Cc=class extends y{},Vh=class extends Cc{};var la=class extends y{},Hh=class extends la{},Xh=class extends la{};var ca=class extends y{},Kh=class extends ca{},Qh=class extends ca{async _call(e){return new j(await super._call(e))}};var qt=class extends y{},Yh=class extends qt{},Jh=class extends qt{async _call(e){return new bt(await super._call(e))}},Zh=class extends qt{async _call(e){return new j(await super._call(e))}},eg=class extends qt{async _call(e){return new he(await super._call(e))}};var tg=class extends y{},rg=class extends qt{},sg=class extends qt{async _call(e){return new bt(await super._call(e))}},ng=class extends qt{async _call(e){return new j(await super._call(e))}};var ua=class extends y{},og=class extends ua{},ag=class extends ua{};var Lc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Tt=class extends Lc{_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return fo({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:s})}},ig=class extends Tt{},lg=class extends Tt{};var cg=class extends Tt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]};var pa=class extends y{},ug=class extends pa{},pg=class extends pa{async _call(e){return new j(await super._call(e))}};var da=class extends y{},dg=class extends da{},fg=class extends da{};var un=class extends y{},_g=class extends un{async forward(e){let r=!e.input_ids,s=!e.pixel_values;if(r&&s)throw new Error("Either `input_ids` or `pixel_values` should be provided.");if(r&&(e.input_ids=Je([e.pixel_values.dims[0],1])),s){let{image_size:c}=this.config.vision_config;e.pixel_values=qe([0,3,c,c],0)}let{text_embeddings:n,image_embeddings:o,l2norm_text_embeddings:a,l2norm_image_embeddings:i}=await super.forward(e),l={};return r||(l.text_embeddings=n,l.l2norm_text_embeddings=a),s||(l.image_embeddings=o,l.l2norm_image_embeddings=i),l}},fa=class extends un{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},mg=class extends un{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var _a=class extends y{},hg=class extends _a{},gg=class extends _a{};var wg=class extends Tt{};var ma=class extends y{},xg=class extends ma{},yg=class extends ma{};var bg=class extends Tt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]};var ha=class extends y{},vg=class extends ha{},kg=class extends ha{};var Pc=class extends y{},Eg=class extends Pc{};var ga=class extends y{},Ag=class extends ga{},Mg=class extends ga{};var wa=class extends y{},Sg=class extends wa{},Tg=class extends wa{};var xa=class extends y{},Og=class extends xa{},Ig=class extends xa{};var ya=class extends y{},Cg=class extends ya{},Lg=class extends ya{};var hs=class extends y{},Pg=class extends hs{},zg=class extends hs{},Ng=class extends hs{async _call(e){return new j(await super._call(e))}},$g=class extends hs{};var zc=class extends y{},Rg=class extends zc{};var Nc=class extends y{},Dg=class extends Nc{};var $c=class extends $e{constructor({char_logits:e,bpe_logits:r,wp_logits:s}){super(),this.char_logits=e,this.bpe_logits=r,this.wp_logits=s}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},Rc=class extends y{},Fg=class extends Rc{async _call(e){return new $c(await super._call(e))}};var Dc=class extends $e{constructor({audio_codes:e}){super(),this.audio_codes=e}},Fc=class extends $e{constructor({audio_values:e}){super(),this.audio_values=e}},pn=class extends y{main_input_name="input_values";forward_params=["input_values"]},Bg=class extends pn{async encode(e){return new Dc(await de(this.sessions.encoder_model,e))}async decode(e){return new Fc(await de(this.sessions.decoder_model,e))}},ba=class extends pn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},va=class extends pn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var ka=class extends y{},Ug=class extends ka{},jg=class extends ka{};var Ea=class extends y{},Gg=class extends Ea{},qg=class extends Ea{};var gs=class extends y{},Wg=class extends gs{},Vg=class extends gs{async _call(e){return new ge(await super._call(e))}},Hg=class extends gs{async _call(e){return new j(await super._call(e))}},Xg=class extends gs{async _call(e){return new Ae(await super._call(e))}};var Aa=class extends y{},Kg=class extends Aa{},Qg=class extends Aa{};var dn=class extends y{},Yg=class extends dn{},Jg=class extends dn{async _call(e){return new j(await super._call(e))}},Zg=class extends dn{};var fn=class extends y{},ew=class extends fn{},tw=class extends fn{async _call(e){return new j(await super._call(e))}},rw=class extends fn{};var _n=class extends y{},sw=class extends _n{},nw=class extends _n{async _call(e){return new j(await super._call(e))}},ow=class extends _n{};var mn=class extends y{},aw=class extends mn{},iw=class extends mn{async _call(e){return new j(await super._call(e))}},lw=class extends mn{};var Ma=class extends y{},cw=class extends Ma{},uw=class extends Ma{async _call(e){return new j(await super._call(e))}};var Sa=class extends y{},pw=class extends Sa{},dw=class extends Sa{async _call(e){return new j(await super._call(e))}};var ws=class extends y{},fw=class extends ws{},_w=class extends ws{async _call(e){return new ge(await super._call(e))}},mw=class extends ws{async _call(e){return new j(await super._call(e))}},hw=class extends ws{async _call(e){return new he(await super._call(e))}};var Ta=class extends y{},gw=class extends Ta{},ww=class extends Ta{};var Oa=class extends y{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},xw=class extends Oa{},yw=class extends Oa{};var Pr=class extends y{},bw=class extends Pr{},vw=class extends Pr{async _call(e){return new ge(await super._call(e))}},kw=class extends Pr{async _call(e){return new j(await super._call(e))}},Ew=class extends Pr{async _call(e){return new he(await super._call(e))}},Aw=class extends Pr{async _call(e){return new Ae(await super._call(e))}};var Ia=class extends y{},Mw=class extends Ia{},Sw=class extends Ia{};var Ca=class extends y{},Tw=class extends Ca{},Ow=class extends Ca{};var Bc=class extends y{},Iw=class extends Bc{forward_params=["input_ids","pixel_values","images_seq_mask","images_emb_mask","attention_mask","position_ids","past_key_values"];constructor(...e){super(...e),this._generation_mode="text"}async forward(e){let r=this._generation_mode??"text",s;if(r==="text"||!e.past_key_values){let l=this.sessions.prepare_inputs_embeds,c=Qe(e,l.inputNames);s=await de(l,c)}else{let l=this.sessions.gen_img_embeds,c=Qe({image_ids:e.input_ids},l.inputNames);s=await de(l,c)}let n={...e,...s},o=await Ot(this,n),a=this.sessions[r==="text"?"lm_head":"gen_head"];if(!a)throw new Error(`Unable to find "${a}" generation head`);let i=await de(a,Qe(o,a.inputNames));return{...s,...o,...i}}prepare_inputs_for_generation(e,r,s){let n=!!r.past_key_values;return s.guidance_scale!==null&&s.guidance_scale>1&&(n?r.input_ids=ve([r.input_ids,r.input_ids],0):(r.input_ids=ve([r.input_ids,qn(r.input_ids,BigInt(s.pad_token_id))],0),r.attention_mask=ve([r.attention_mask,qn(r.attention_mask,0n)],0))),(n||!r.pixel_values)&&(r.pixel_values=qe([0,0,3,384,384],1)),n&&(r.images_seq_mask=new N("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),r.images_emb_mask=new N("bool",new Array(0).fill(!1),[1,1,0])),r}async generate(e){return this._generation_mode="text",super.generate(e)}async generate_images(e){this._generation_mode="image";let r=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[r,null]),o=this.sessions.image_decode,{decoded_image:a}=await de(o,{generated_tokens:n}),i=a.add_(1).mul_(255/2).clamp_(0,255).to("uint8"),l=[];for(let c of i){let p=Ke.fromTensor(c);l.push(p)}return l}};var La=class extends y{},Cw=class extends La{},Lw=class extends La{},Pa=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"];_apply_and_filter_by_delay_pattern_mask(e){let[r,s]=e.dims,n=this.config.decoder.num_codebooks,o=s-n,a=0;for(let c=0;c<e.size;++c){if(e.data[c]==this.config.decoder.pad_token_id)continue;let p=c%s,d=Math.floor(c/s)%n,_=p-d;_>0&&_<=o&&(e.data[a++]=e.data[c])}let i=Math.floor(r/n),l=a/(i*n);return new N(e.type,e.data.slice(0,a),[i,n,l])}prepare_inputs_for_generation(e,r,s){let n=BigInt(this.config.decoder.pad_token_id),o=structuredClone(e);for(let a=0;a<o.length;++a)for(let i=0;i<o[a].length;++i)a%this.config.decoder.num_codebooks>=i&&(o[a][i]=n);return s.guidance_scale!==null&&s.guidance_scale>1&&(o=o.concat(o)),fc(this,o,r,s)}async generate(e){let r=await super.generate(e),s=this._apply_and_filter_by_delay_pattern_mask(r).unsqueeze_(0),{audio_values:n}=await de(this.sessions.encodec_decode,{audio_codes:s});return n}};var za=class extends y{},Pw=class extends za{},zw=class extends za{};var Na=class extends y{},Nw=class extends Na{},$w=class extends Na{};var zr=class extends y{},Rw=class extends zr{},Dw=class extends zr{async _call(e){return new ge(await super._call(e))}},Fw=class extends zr{async _call(e){return new j(await super._call(e))}},Bw=class extends zr{async _call(e){return new he(await super._call(e))}},Uw=class extends zr{async _call(e){return new Ae(await super._call(e))}};var Uc=class extends y{},jw=class extends Uc{};var $a=class extends y{},Gw=class extends $a{},qw=class extends $a{};var Ra=class extends y{},Ww=class extends Ra{},Vw=class extends Ra{};var Da=class extends y{},Hw=class extends Da{},Xw=class extends Da{};var Fa=class extends y{},Kw=class extends Fa{},Qw=class extends Fa{};var Ba=class extends y{},Yw=class extends Ba{},Jw=class extends Ba{};var Ua=class extends y{},Zw=class extends Ua{},ex=class extends Ua{};var ja=class extends y{},tx=class extends ja{},rx=class extends ja{};var Ga=class extends y{},sx=class extends Ga{},nx=class extends Ga{};var ox=class extends Tt{};var jc=class extends y{},ax=class extends jc{async _call(e){return new bt(await super._call(e))}};var qa=class extends y{},ix=class extends qa{},lx=class extends qa{};var Wa=class extends y{},cx=class extends Wa{},ux=class extends Wa{};var Va=class extends y{},px=class extends Va{},dx=class extends Va{};var Ha=class extends y{},fx=class extends Ha{},_x=class extends Ha{};var Gc=class extends y{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},Xa=class extends Gc{async forward({input_ids:e=null,attention_mask:r=null,pixel_values:s=null,image_sizes:n=null,position_ids:o=null,inputs_embeds:a=null,past_key_values:i=null,generation_config:l=null,logits_processor:c=null,...p}){if(!a){let _;if(s&&e.dims[1]!==1){if(!n)throw new Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:_}=await de(this.sessions.vision_encoder,{pixel_values:s,image_sizes:n}))}else{let m=this.config.normalized_config.hidden_size;_=new N("float32",[],[0,m])}({inputs_embeds:a}=await de(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:_}))}return await Ot(this,{inputs_embeds:a,past_key_values:i,attention_mask:r,position_ids:o,generation_config:l,logits_processor:c},!1)}};var Ka=class extends y{},mx=class extends Ka{},hx=class extends Ka{async _call(e){return new j(await super._call(e))}};var Qa=class extends y{},gx=class extends Qa{},wx=class extends Qa{async _call(e){return new he(await super._call(e))}};var Ya=class extends y{},xx=class extends Ya{},yx=class extends Ya{};var Ja=class extends y{},bx=class extends Ja{},vx=class extends Ja{};var Za=class extends y{},kx=class extends Za{},Ex=class extends Za{};var ei=class extends y{},Ax=class extends ei{},Mx=class extends ei{};var ti=class extends y{},Sx=class extends ti{},Tx=class extends ti{};var xs=class extends fs{},ys=class extends _s{};var Ox=class extends xs{},ri=class extends ys{};var hn=class extends xs{},bs=class extends hn{};var Ix=class extends hn{},si=class extends bs{};var ni=class extends y{},Cx=class extends ni{},Lx=class extends ni{async _call(e){return new j(await super._call(e))}};var oi=class extends y{},Px=class extends oi{},zx=class extends oi{async _call(e){return new qc(await super._call(e))}},qc=class extends rr{};var Nr=class extends y{},Nx=class extends Nr{},$x=class extends Nr{async _call(e){return new ge(await super._call(e))}},Rx=class extends Nr{async _call(e){return new j(await super._call(e))}},Dx=class extends Nr{async _call(e){return new he(await super._call(e))}},Fx=class extends Nr{async _call(e){return new Ae(await super._call(e))}};var $r=class extends y{},Bx=class extends $r{},Ux=class extends $r{async _call(e){return new ge(await super._call(e))}},jx=class extends $r{async _call(e){return new j(await super._call(e))}},Gx=class extends $r{async _call(e){return new he(await super._call(e))}},qx=class extends $r{async _call(e){return new Ae(await super._call(e))}};var ai=class extends y{},Wx=class extends ai{},Vx=class extends ai{async _call(e){return new Wc(await super._call(e))}},Wc=class extends rr{};var Vc=class extends $e{constructor({iou_scores:e,pred_masks:r}){super(),this.iou_scores=e,this.pred_masks=r}},Hc=class extends y{},Hx=class extends Hc{async get_image_embeddings({pixel_values:e}){return await Gt(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??=Je(e.input_points.dims.slice(0,-1));let r={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(r.input_points=e.input_points),e.input_labels&&(r.input_labels=e.input_labels),e.input_boxes&&(r.input_boxes=e.input_boxes),await de(this.sessions.prompt_encoder_mask_decoder,r)}async _call(e){return new Vc(await super._call(e))}};var Xc=class extends $e{constructor({iou_scores:e,pred_masks:r,object_score_logits:s}){super(),this.iou_scores=e,this.pred_masks=r,this.object_score_logits=s}},Kc=class extends y{},ii=class extends Kc{async get_image_embeddings({pixel_values:e}){return await Gt(this,{pixel_values:e})}async forward(e){let{num_feature_levels:r}=this.config.vision_config;if(Array.from({length:r},(a,i)=>`image_embeddings.${i}`).some(a=>!e[a])?e={...e,...await this.get_image_embeddings(e)}:e={...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw new Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let a=e.input_points.dims;e.input_labels??=Je(a.slice(0,-1)),e.input_boxes??=qe([a[0],0,4],0)}else if(e.input_boxes){let a=e.input_boxes.dims;e.input_labels=qe([a[0],a[1],0],-1n),e.input_points=qe([a[0],1,0,2],0)}else throw new Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder,o=Qe(e,n.inputNames);return await de(n,o)}async _call(e){return new Xc(await super._call(e))}},Xx=class extends ii{},Kx=class extends ii{};var gn=class extends y{},Qx=class extends gn{},Yx=class extends gn{},Jx=class extends gn{};var wn=class extends y{},Zx=class extends wn{},ey=class extends wn{},ty=class extends wn{};var li=class extends y{},ry=class extends li{},ci=class extends li{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},sy=class extends tr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var ui=class extends y{},ny=class extends ui{},oy=class extends ui{};var xn=class extends y{main_input_name="input_values";forward_params=["input_values"]},ay=class extends xn{async encode(e){return await de(this.sessions.encoder_model,e)}async decode(e){return await de(this.sessions.decoder_model,e)}},pi=class extends xn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},di=class extends xn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var fi=class extends y{},iy=class extends fi{},ly=class extends fi{};var yn=class extends y{},cy=class extends yn{},uy=class extends yn{},py=class extends yn{async generate_speech(e,r,{threshold:s=.5,minlenratio:n=0,maxlenratio:o=20,vocoder:a=null}={}){let i={input_ids:e},{encoder_outputs:l,encoder_attention_mask:c}=await Gt(this,i),p=l.dims[1]/this.config.reduction_factor,d=Math.floor(p*o),_=Math.floor(p*n),m=this.config.num_mel_bins,w=[],x=null,E=null,k=0;for(;;){++k;let S=F1(!!E),L;E?L=E.output_sequence_out:L=new N("float32",new Float32Array(m),[1,1,m]);let O={use_cache_branch:S,output_sequence:L,encoder_attention_mask:c,speaker_embeddings:r,encoder_hidden_states:l};this.addPastKeyValues(O,x),E=await de(this.sessions.decoder_model_merged,O),x=this.getPastKeyValues(E,x);let{prob:v,spectrum:W}=E;if(w.push(W),k>=_&&(Array.from(v.data).filter(X=>X>=s).length>0||k>=d))break}let A=ve(w),{waveform:T}=await de(a.sessions.model,{spectrogram:A});return{spectrogram:A,waveform:T}}},dy=class extends y{main_input_name="spectrogram"};var vs=class extends y{},fy=class extends vs{},_y=class extends vs{async _call(e){return new ge(await super._call(e))}},my=class extends vs{async _call(e){return new j(await super._call(e))}},hy=class extends vs{async _call(e){return new Ae(await super._call(e))}};var _i=class extends y{},gy=class extends _i{},wy=class extends _i{};var mi=class extends y{},xy=class extends mi{},yy=class extends mi{};var Qc=class extends y{},by=class extends Qc{};var Yc=class extends y{},hi=class extends Yc{async generate_speech({input_ids:e,attention_mask:r,style:s,num_inference_steps:n=5,speed:o=1.05}){let{sampling_rate:a,chunk_compress_factor:i,base_chunk_size:l,latent_dim:c}=this.config,{last_hidden_state:p,durations:d}=await de(this.sessions.text_encoder,{input_ids:e,attention_mask:r,style:s}),_=d.div(o).mul_(a),m=l*i,w=_.data,x=Int32Array.from(w,B=>Math.ceil(B/m)),E=Math.max(...x),k=e.dims[0],A=new BigInt64Array(k*E);for(let B=0;B<k;++B)A.fill(1n,B*E,B*E+x[B]);let T=new N("int64",A,[k,E]),S=c*i,L=S*E,O=w1([k,S,E]),v=O.data;for(let B=0;B<k;++B)if(x[B]!==E)for(let H=0;H<S;++H)v.fill(0,B*L+H*E+x[B],B*L+(H+1)*E);let W=qe([k],n);for(let B=0;B<n;++B){let H=qe([k],B);({denoised_latents:O}=await de(this.sessions.latent_denoiser,{style:s,noisy_latents:O,latent_mask:T,encoder_outputs:p,attention_mask:r,timestep:H,num_inference_steps:W}))}let{waveform:X}=await de(this.sessions.voice_decoder,{latents:O});return{waveform:X,durations:_}}};var bn=class extends y{},vy=class extends bn{},ky=class extends bn{async _call(e){return new j(await super._call(e))}},Ey=class extends bn{};var gi=class extends y{},Ay=class extends gi{},My=class extends gi{};var wi=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},Sy=class extends wi{},Ty=class extends wi{};var xi=class extends y{},Oy=class extends xi{},Iy=class extends xi{async _call(e){return new Jc(await super._call(e))}},Jc=class extends an{};var Zc=class extends y{},Cy=class extends Zc{};var vn=class extends y{},Ly=class extends vn{},Py=class extends vn{async _call(e){return new bt(await super._call(e))}},zy=class extends vn{async _call(e){return new j(await super._call(e))}};var ks=class extends y{},Ny=class extends ks{},$y=class extends ks{async _call(e){return new bt(await super._call(e))}},Ry=class extends ks{async _call(e){return new j(await super._call(e))}},Dy=class extends ks{async _call(e){return new he(await super._call(e))}};var yi=class extends y{},Fy=class extends yi{},By=class extends yi{};var Uy=class extends y{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var bi=class extends y{},jy=class extends bi{},Gy=class extends bi{async _call(e){return new j(await super._call(e))}};var eu=class extends y{},qy=class extends eu{};var vi=class extends y{},Wy=class extends vi{},Vy=class extends vi{async _call(e){return new j(await super._call(e))}};var tu=class extends y{},Hy=class extends tu{async _call(e){return new Yf(await super._call(e))}};var ru=class extends y{},Xy=class extends ru{};var su=class extends $e{constructor({waveform:e,spectrogram:r}){super(),this.waveform=e,this.spectrogram=r}},nu=class extends y{},Ky=class extends nu{async _call(e){return new su(await super._call(e))}};var Qy=class extends ms{};var yM=2,gN=1,U1=new WeakMap;function wN(t,e){let{text_config:r,audio_config:s}=t.config,n=t.sessions.audio_encoder,{num_mel_bins:o,hidden_size:a}=s,i=o+a,l=new co,c=n?.config?.kv_cache_dtype??"float32",p=c==="float16"?kr.float16:kr.float32,d=Qs(s,{batch_size:1});for(let w in d){let x=d[w].reduce((E,k)=>E*k,1);l[w]=new N(c,new p(x),d[w])}let _=new N(c,new p(i*yM),[1,i,yM]),m=e[Symbol.asyncIterator]?.()??e[Symbol.iterator]?.();if(!m)throw new Error("input_features must be iterable or async iterable");return{encoder_session:n,enc_kv_cache:l,enc_padding_cache:_,enc_past_seq_len:0,audio_embed_queue:[],audio_embed_total_tokens:0,audio_queue_offset:0,audio_consumed:0,stream_exhausted:!1,chunks_iter:m,text_hidden_size:r.hidden_size}}async function xN(t,e){let r=e.dims[2],s=Math.floor((gN+r-3)/2)+1,n=new N("int64",BigInt64Array.from({length:s},(p,d)=>BigInt(t.enc_past_seq_len+d)),[1,s]),o=t.enc_past_seq_len+s,a=Je([1,o]),{audio_embeds:i,present_padding_cache:l,...c}=await de(t.encoder_session,{input_features:e,attention_mask:a,position_ids:n,past_padding_cache:t.enc_padding_cache,...t.enc_kv_cache});t.enc_padding_cache.location==="gpu-buffer"&&t.enc_padding_cache.dispose(),t.enc_padding_cache=l;for(let p in c)if(p.startsWith("present.")){let d=p.replace("present","past_key_values"),_=t.enc_kv_cache[d];_?.location==="gpu-buffer"&&_.dispose(),t.enc_kv_cache[d]=c[p]}return t.enc_past_seq_len=o,i}async function yN(t,e){for(;t.audio_embed_total_tokens<e&&!t.stream_exhausted;){let r=await t.chunks_iter.next();if(r.done){t.stream_exhausted=!0;break}let s=await xN(t,r.value);t.audio_embed_queue.push({data:s.data,tokens:s.dims[1]}),t.audio_embed_total_tokens+=s.dims[1]}}function bN(t,e,r){if(t.audio_embed_queue.length===0)return;let s=e.data,n=0,o=r;for(;o>0&&t.audio_embed_queue.length>0;){let a=t.audio_embed_queue[0],i=a.tokens-t.audio_queue_offset,l=Math.min(o,i),c=t.audio_queue_offset*t.text_hidden_size;for(let p=0;p<l*t.text_hidden_size;++p)s[n*t.text_hidden_size+p]+=a.data[c+p];n+=l,o-=l,t.audio_queue_offset+=l,t.audio_queue_offset>=a.tokens&&(t.audio_embed_queue.shift(),t.audio_queue_offset=0)}t.audio_consumed+=r-o}var j1=class extends Ar{constructor(e){super(),this._s=e}_call(e){let r=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>r)}},ou=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},ki=class extends ou{async forward({input_ids:e,past_key_values:r,...s}){let n=e.dims[1],o=U1.get(this);o&&await yN(o,o.audio_consumed+n);let{inputs_embeds:a}=await de(this.sessions.embed_tokens,{input_ids:e});o&&bN(o,a,n);let i={inputs_embeds:a,...s};this.addPastKeyValues(i,r);let l=this.sessions.decoder_model_merged,c=Qe(i,l.inputNames);return await de(l,c)}async generate({input_features:e,stopping_criteria:r,...s}){if(!e)throw new Error("input_features (generator/iterable) must be provided");let n=wN(this,e);U1.set(this,n);let o=new Js;o.push(new j1(n)),r&&o.extend(r);try{return await super.generate({...s,stopping_criteria:o})}finally{n.enc_kv_cache.dispose(),U1.delete(this)}}};var kn=class extends y{},Yy=class extends kn{},Jy=class extends kn{async _call(e){return new bt(await super._call(e))}},Zy=class extends kn{async _call(e){return new j(await super._call(e))}};var au=class extends $e{constructor({logits:e,embeddings:r}){super(),this.logits=e,this.embeddings=r}},Rr=class extends y{},e0=class extends Rr{},t0=class extends Rr{async _call(e){return new bt(await super._call(e))}},r0=class extends Rr{async _call(e){return new j(await super._call(e))}},s0=class extends Rr{async _call(e){return new au(await super._call(e))}},n0=class extends Rr{async _call(e){return new he(await super._call(e))}};var iu=class extends y{},o0=class extends iu{};var a0=class extends lo{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1};var Ei=class extends y{requires_attention_mask=!1;main_input_name="input_features";forward_params=["input_features","attention_mask","decoder_input_ids","decoder_attention_mask","past_key_values"]},i0=class extends Ei{},lu=class extends Ei{_prepare_generation_config(e,r){return super._prepare_generation_config(e,r,a0)}_retrieve_init_tokens(e){let r=[e.decoder_start_token_id],s=e.language,n=e.task;if(e.is_multilingual){s||(Z.warn("No language specified - defaulting to English (en)."),s="en");let a=`<|${W2(s)}|>`;r.push(e.lang_to_id[a]),r.push(e.task_to_id[n??"transcribe"])}else if(s||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&&r.at(-1)!==e.no_timestamps_token_id?r.push(e.no_timestamps_token_id):e.return_timestamps&&r.at(-1)===e.no_timestamps_token_id&&(Z.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),r.pop()),r.filter(o=>o!=null)}async generate({inputs:e=null,generation_config:r=null,logits_processor:s=null,stopping_criteria:n=null,...o}){r=this._prepare_generation_config(r,o);let a=o.decoder_input_ids??this._retrieve_init_tokens(r);if(r.return_timestamps&&(s??=new ls,s.push(new rc(r,a))),r.begin_suppress_tokens&&(s??=new ls,s.push(new Ys(r.begin_suppress_tokens,a.length))),r.return_token_timestamps){if(!r.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.");r.task==="translate"&&Z.warn("Token-level timestamps may not be reliable for task 'translate'."),r.output_attentions=!0,r.return_dict_in_generate=!0}let i=await super.generate({inputs:e,generation_config:r,logits_processor:s,decoder_input_ids:a,...o});return r.return_token_timestamps&&(i.token_timestamps=this._extract_token_timestamps(i,r.alignment_heads,r.num_frames)),i}_extract_token_timestamps(e,r,s=null,n=.02){if(!e.cross_attentions)throw new Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");s==null&&Z.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let o=this.config.median_filter_width;o===void 0&&(Z.warn("Model config has no `median_filter_width`, using default value of 7."),o=7);let a=e.cross_attentions,i=Array.from({length:this.config.decoder_layers},(x,E)=>ve(a.map(k=>k[E]),2)),l=St(r.map(([x,E])=>{if(x>=i.length)throw new Error(`Layer index ${x} is out of bounds for cross attentions (length ${i.length}).`);return s?i[x].slice(null,E,null,[0,s]):i[x].slice(null,E)})).transpose(1,0,2,3),[c,p]=bp(l,-2,0,!0),d=l.clone();for(let x=0;x<d.dims[0];++x){let E=d[x];for(let k=0;k<E.dims[0];++k){let A=E[k],T=c[x][k][0].data,S=p[x][k][0].data;for(let L=0;L<A.dims[0];++L){let O=A[L].data;for(let v=0;v<O.length;++v)O[v]=(O[v]-S[v])/T[v];O.set(oA(O,o))}}}let _=[Cl(d,1)],m=e.sequences.dims,w=new N("float32",new Float32Array(m[0]*m[1]),m);for(let x=0;x<m[0];++x){let E=_[x].neg().squeeze_(0),[k,A]=iA(E.tolist()),T=Array.from({length:k.length-1},(O,v)=>k[v+1]-k[v]),S=ht([1],T).map(O=>!!O),L=[];for(let O=0;O<S.length;++O)S[O]&&L.push(A[O]*n);w[x].data.set(L,1)}return w}},l0=class extends lu{};var Dr=class extends y{},c0=class extends Dr{},u0=class extends Dr{async _call(e){return new ge(await super._call(e))}},p0=class extends Dr{async _call(e){return new j(await super._call(e))}},d0=class extends Dr{async _call(e){return new he(await super._call(e))}},f0=class extends Dr{async _call(e){return new Ae(await super._call(e))}};var Fr=class extends y{},_0=class extends Fr{},m0=class extends Fr{async _call(e){return new ge(await super._call(e))}},h0=class extends Fr{async _call(e){return new j(await super._call(e))}},g0=class extends Fr{async _call(e){return new he(await super._call(e))}},w0=class extends Fr{async _call(e){return new Ae(await super._call(e))}};var Ai=class extends y{},x0=class extends Ai{},y0=class extends Ai{async _call(e){return new cu(await super._call(e))}},cu=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var Mi=class extends y{},b0=class extends Mi{},v0=class extends Mi{};var vN=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"]]),kN=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),EN=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),AN=new Map([["bloom","BloomModel"],["jais","JAISModel"],["gpt2","GPT2Model"],["gpt_oss","GptOssModel"],["gptj","GPTJModel"],["gpt_bigcode","GPTBigCodeModel"],["gpt_neo","GPTNeoModel"],["gpt_neox","GPTNeoXModel"],["codegen","CodeGenModel"],["llama","LlamaModel"],["apertus","ApertusModel"],["nanochat","NanoChatModel"],["arcee","ArceeModel"],["afmoe","AfmoeModel"],["lfm2","Lfm2Model"],["lfm2_moe","Lfm2MoeModel"],["smollm3","SmolLM3Model"],["exaone","ExaoneModel"],["olmo","OlmoModel"],["olmo2","Olmo2Model"],["olmo3","Olmo3Model"],["olmo_hybrid","OlmoHybridModel"],["mobilellm","MobileLLMModel"],["granite","GraniteModel"],["granitemoehybrid","GraniteMoeHybridModel"],["cohere","CohereModel"],["cohere2","Cohere2Model"],["gemma","GemmaModel"],["gemma2","Gemma2Model"],["vaultgemma","VaultGemmaModel"],["gemma3_text","Gemma3Model"],["helium","HeliumModel"],["glm","GlmModel"],["glm_moe_dsa","GlmMoeDsaModel"],["openelm","OpenELMModel"],["qwen2","Qwen2Model"],["qwen2_moe","Qwen2MoeModel"],["qwen3","Qwen3Model"],["qwen3_moe","Qwen3MoeModel"],["qwen3_next","Qwen3NextModel"],["phi","PhiModel"],["phi3","Phi3Model"],["mpt","MptModel"],["opt","OPTModel"],["mistral","MistralModel"],["mistral4","Mistral4Model"],["ministral","MinistralModel"],["ministral3","Ministral3Model"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2Model"],["deepseek_v3","DeepseekV3Model"],["falcon","FalconModel"],["falcon_h1","FalconH1Model"],["nemotron_h","NemotronHModel"],["solar_open","SolarOpenModel"],["stablelm","StableLmModel"],["modernbert-decoder","ModernBertDecoderModel"],["hunyuan_v1_dense","HunYuanDenseV1Model"],["youtu","YoutuModel"]]),bM=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"]]),vM=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),kM=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),EM=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"]]),AM=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"]]),MM=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),SM=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_moe","Qwen3_5MoeForCausalLM"],["gemma3n","Gemma3nForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["mistral4","Mistral4ForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["deepseek_v3","DeepseekV3ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["nemotron_h","NemotronHForCausalLM"],["trocr","TrOCRForCausalLM"],["solar_open","SolarOpenForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),MN=new Map([["multi_modality","MultiModalityCausalLM"]]),TM=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"]]),OM=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"]]),IM=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),CM=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"],["gemma3n","Gemma3nForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"],["lighton_ocr","LightOnOcrForConditionalGeneration"],["glm_ocr","GlmOcrForConditionalGeneration"]]),LM=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),SN=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),PM=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"]]),zM=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),NM=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),Si=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),$M=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),RM=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),DM=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),FM=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),BM=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),UM=new Map([["wavlm","WavLMForXVector"]]),jM=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),GM=new Map([["vitmatte","VitMatteForImageMatting"]]),TN=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),qM=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),WM=new Map([["chmv2","CHMv2ForDepthEstimation"],["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),VM=new Map([["sapiens","SapiensForNormalEstimation"]]),HM=new Map([["vitpose","VitPoseForPoseEstimation"]]),XM=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),G1=[[vN,K.EncoderOnly],[kN,K.EncoderDecoder],[AN,K.DecoderOnlyWithoutHead],[EN,K.AutoEncoder],[EM,K.EncoderOnly],[AM,K.EncoderOnly],[MM,K.Seq2Seq],[bM,K.Seq2Seq],[SM,K.DecoderOnly],[MN,K.MultiModality],[TM,K.EncoderOnly],[OM,K.EncoderOnly],[IM,K.Vision2Seq],[CM,K.ImageTextToText],[LM,K.AudioTextToText],[PM,K.EncoderOnly],[Si,K.EncoderOnly],[RM,K.EncoderOnly],[$M,K.EncoderOnly],[GM,K.EncoderOnly],[TN,K.EncoderOnly],[qM,K.EncoderOnly],[WM,K.EncoderOnly],[VM,K.EncoderOnly],[HM,K.EncoderOnly],[zM,K.EncoderOnly],[NM,K.EncoderOnly],[DM,K.MaskGeneration],[FM,K.EncoderOnly],[BM,K.EncoderOnly],[vM,K.Seq2Seq],[kM,K.EncoderOnly],[UM,K.EncoderOnly],[jM,K.EncoderOnly],[XM,K.EncoderOnly]];for(let[t,e]of G1)for(let r of t.values()){er.set(r,e);let s=uu[r];tn.set(s,r),Zf.set(r,s)}var ON=[["MusicgenForConditionalGeneration",Pa,K.Musicgen],["Phi3VForCausalLM",Xa,K.Phi3V],["CLIPTextModelWithProjection",Ao,K.EncoderOnly],["SiglipTextModel",ci,K.EncoderOnly],["JinaCLIPTextModel",fa,K.EncoderOnly],["ClapTextModelWithProjection",ko,K.EncoderOnly],["ClapAudioModelWithProjection",Eo,K.EncoderOnly],["DacEncoderModel",zo,K.EncoderOnly],["DacDecoderModel",No,K.EncoderOnly],["MimiEncoderModel",ba,K.EncoderOnly],["MimiDecoderModel",va,K.EncoderOnly],["SnacEncoderModel",pi,K.EncoderOnly],["SnacDecoderModel",di,K.EncoderOnly],["Gemma3nForConditionalGeneration",ln,K.ImageAudioTextToText],["SupertonicForConditionalGeneration",hi,K.Supertonic],["ChatterboxModel",vo,K.Chatterbox],["Qwen2VLForCausalLM",ds,K.MultimodalLanguageModelOnly],["Qwen2_5_VLForCausalLM",_s,K.MultimodalLanguageModelOnly],["Qwen3VLForCausalLM",ys,K.MultimodalLanguageModelOnly],["Qwen3VLMoeForCausalLM",ri,K.MultimodalLanguageModelOnly],["Qwen3_5ForCausalLM",bs,K.MultimodalLanguageModelOnly],["Qwen3_5MoeForCausalLM",si,K.MultimodalLanguageModelOnly],["Gemma3nForCausalLM",Qo,K.MultimodalLanguageModelOnly],["VoxtralRealtimeForConditionalGeneration",ki,K.VoxtralRealtime]];for(let[t,e,r]of ON)er.set(t,r),tn.set(e,t),Zf.set(t,e);var KM=new Map([["modnet",Si],["birefnet",Si],["isnet",Si],["ben",Si]]);for(let[t,e]of KM.entries())e.set(t,"PreTrainedModel"),er.set(t,K.EncoderOnly),Zf.set(t,y);var QM=new Set(KM.keys());er.set("PreTrainedModel",K.EncoderOnly);tn.set(y,"PreTrainedModel");var Pe={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:EM,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:AM,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:vM,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:kM,MODEL_FOR_MASKED_LM_MAPPING_NAMES:TM,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:OM,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:PM,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:Si,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:$M,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:RM,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:zM,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:NM,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:DM,MODEL_FOR_CTC_MAPPING_NAMES:FM,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:BM,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:UM,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:jM,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:SN,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:GM,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:qM,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:WM,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:VM,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:HM,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:XM,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:CM,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:LM,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:MM,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:bM,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:SM,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:IM};mM(Pe);var Oe=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let r of this.MODEL_CLASS_MAPPINGS)if(r.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",model_file_name:i=null,subfolder:l="onnx",device:c=null,dtype:p=null,use_external_data_format:d=null,session_options:_={}}={}){let m={progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a,model_file_name:i,subfolder:l,device:c,dtype:p,use_external_data_format:d,session_options:_};if(m.config=await Nt.from_pretrained(e,m),!this.MODEL_CLASS_MAPPINGS)throw new Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:w}=m.config;for(let x of this.MODEL_CLASS_MAPPINGS){let E=x.get(w);if(!E){for(let k of x.values())if(k[0]===w){E=k;break}if(!E)continue}return await uu[E].from_pretrained(e,m)}if(this.BASE_IF_FAIL)return QM.has(w)||Z.warn(`Unknown model class "${w}", attempting to construct from base class.`),await y.from_pretrained(e,m);throw Error(`Unsupported model type: ${w}`)}},dr=class extends Oe{static MODEL_CLASS_MAPPINGS=G1.map(e=>e[0]);static BASE_IF_FAIL=!0},Ti=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},pu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},En=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},du=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},fu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},_u=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},mu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},hu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},gu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},wu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},xu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},Oi=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},Ii=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},Ci=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},yu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},bu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},q1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},vu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_CTC_MAPPING_NAMES]},ku=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},W1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},V1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},Eu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},H1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},Au=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},Mu=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},X1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},K1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},Su=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},Q1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},Y1=class extends Oe{static MODEL_CLASS_MAPPINGS=[Pe.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function Ze(t){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(e=>Ke.read(e)))}async function Es(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(r=>typeof r=="string"||r instanceof URL?md(r,e):r instanceof Float64Array?new Float32Array(r):r))}function Tu(t,e){e&&(t=t.map(a=>a|0));let[r,s,n,o]=t;return{xmin:r,ymin:s,xmax:n,ymax:o}}var _e=class extends tt{constructor({task:e,model:r,tokenizer:s=null,processor:n=null}){super(),this.task=e,this.model=r,this.tokenizer=s,this.processor=n}async dispose(){await this.model.dispose()}};var Li=class extends _e{async _call(e,{top_k:r=1}={}){let s=this.tokenizer(e,{padding:!0,truncation:!0}),n=await this.model(s),{problem_type:o,id2label:a}=this.model.config,i=o==="multi_label_classification"?c=>c.sigmoid():c=>new N("float32",Ie(c.data),c.dims),l=[];for(let c of n.logits){let p=i(c),d=await jt(p,r),_=d[0].tolist(),w=d[1].tolist().map((x,E)=>({label:a?a[x]:`LABEL_${x}`,score:_[E]}));r===1?l.push(...w):l.push(w)}return Array.isArray(e)||r===1?l:l[0]}};var Pi=class extends _e{async _call(e,{ignore_labels:r=["O"]}={}){let s=Array.isArray(e),n=this.tokenizer(s?e:[e],{padding:!0,truncation:!0}),a=(await this.model(n)).logits,i=this.model.config.id2label,l=[];for(let c=0;c<a.dims[0];++c){let p=n.input_ids[c],d=a[c],_=[];for(let m=0;m<d.dims[0];++m){let w=d[m],x=Ce(w.data)[1],E=i?i[x]:`LABEL_${x}`;if(r.includes(E))continue;let k=this.tokenizer.decode([p[m].item()],{skip_special_tokens:!0});if(k==="")continue;let A=Ie(w.data);_.push({entity:E,score:A[x],index:m,word:k})}l.push(_)}return s?l:l[0]}};var zi=class extends _e{async _call(e,r,{top_k:s=1}={}){let n=this.tokenizer(e,{text_pair:r,padding:!0,truncation:!0}),o=Array.isArray(e),{start_logits:a,end_logits:i}=await this.model(n),l=n.input_ids.tolist(),c=n.attention_mask.tolist(),{all_special_ids:p,sep_token_id:d}=this.tokenizer,_=[];for(let m=0;m<a.dims[0];++m){let w=l[m],x=w.findIndex(O=>O==d),E=a[m].tolist(),k=i[m].tolist();for(let O=1;O<E.length;++O)(c[m]==0||O<=x||p.findIndex(v=>v==w[O])!==-1)&&(E[O]=-1/0,k[O]=-1/0);let A=Ie(E).map((O,v)=>[O,v]),T=Ie(k).map((O,v)=>[O,v]);A[0][0]=0,T[0][0]=0;let S=_E(A,T).filter(O=>O[0][1]<=O[1][1]).map(O=>[O[0][1],O[1][1],O[0][0]*O[1][0]]).sort((O,v)=>v[2]-O[2]),L=[];for(let O=0;O<Math.min(S.length,s);++O){let[v,W,X]=S[O],B=w.slice(v,W+1),H=this.tokenizer.decode(B,{skip_special_tokens:!0});L.push({answer:H,score:X})}s===1?_.push(...L):_.push(L)}return o?_:_[0]}};var Ni=class extends _e{async _call(e,{top_k:r=5}={}){let{mask_token_id:s,mask_token:n}=this.tokenizer,o=this.tokenizer(e,{padding:!0,truncation:!0}),{logits:a}=await this.model(o),i=[],l=o.input_ids.tolist();for(let c=0;c<l.length;++c){let p=l[c],d=p.findIndex(E=>E==s);if(d===-1)throw Error(`Mask token (${n}) not found in text.`);let _=a[c][d],m=await jt(new N("float32",Ie(_.data),_.dims),r),w=m[0].tolist(),x=m[1].tolist();i.push(x.map((E,k)=>{let A=p.slice();return A[d]=E,{score:w[k],token:Number(E),token_str:this.tokenizer.decode([E]),sequence:this.tokenizer.decode(A,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}};var fr=class extends _e{_key="generated_text";async _call(e,r={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(l=>this.model.config.prefix+l));let s=this.model.config.task_specific_params;s&&s[this.task]&&s[this.task].prefix&&(e=e.map(l=>s[this.task].prefix+l));let n=this.tokenizer,o={padding:!0,truncation:!0},a;this.task==="translation"&&"_build_translation_inputs"in n?a=n._build_translation_inputs(e,o,r):a=n(e,o);let i=await this.model.generate({...a,...r});return n.batch_decode(i,{skip_special_tokens:!0}).map(l=>({[this._key]:l}))}};var $i=class extends fr{_key="summary_text"};var Ri=class extends fr{_key="translation_text"};function YM(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var Di=class extends _e{async _call(e,r={}){let s=!1,n=!1,o=r.add_special_tokens??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,a=r.tokenizer_encode_kwargs,i;if(typeof e=="string")i=e=[e];else if(Array.isArray(e)&&e.every(w=>typeof w=="string"))s=!0,i=e;else{if(YM(e))e=[e];else if(Array.isArray(e)&&e.every(YM))s=!0;else throw new Error("Input must be a string, an array of strings, a Chat, or an array of Chats");n=!0,i=e.map(w=>this.tokenizer.apply_chat_template(w,{tokenize:!1,add_generation_prompt:!0,...a})),o=!1,a=void 0}let l=n?!1:r.return_full_text??!0;this.tokenizer.padding_side="left";let c=this.tokenizer(i,{add_special_tokens:o,padding:!0,truncation:!0,...a}),p=await this.model.generate({...c,...r}),d=this.tokenizer.batch_decode(p,{skip_special_tokens:!0}),_;!l&&c.input_ids.dims.at(-1)>0&&(_=this.tokenizer.batch_decode(c.input_ids,{skip_special_tokens:!0}).map(w=>w.length));let m=Array.from({length:e.length},w=>[]);for(let w=0;w<d.length;++w){let x=Math.floor(w/p.dims[0]*e.length);_&&(d[w]=d[w].slice(_[x])),m[x].push({generated_text:n?[...e[x],{role:"assistant",content:d[w]}]:d[w]})}return!s&&m.length===1?m[0]:m}};var Fi=class extends _e{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([r,s])=>[r.toLowerCase(),s])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(Z.warn("Could not find 'entailment' in label2id mapping. Using 2 as entailment_id."),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(Z.warn("Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id."),this.contradiction_id=0)}async _call(e,r,{hypothesis_template:s="This example is {}.",multi_label:n=!1}={}){let o=Array.isArray(e);o||(e=[e]),Array.isArray(r)||(r=[r]);let a=r.map(c=>s.replace("{}",c)),i=n||r.length===1,l=[];for(let c of e){let p=[];for(let m of a){let w=this.tokenizer(c,{text_pair:m,padding:!0,truncation:!0}),x=await this.model(w);i?p.push([x.logits.data[this.contradiction_id],x.logits.data[this.entailment_id]]):p.push(x.logits.data[this.entailment_id])}let _=(i?p.map(m=>Ie(m)[1]):Ie(p)).map((m,w)=>[m,w]).sort((m,w)=>w[0]-m[0]);l.push({sequence:c,labels:_.map(m=>r[m[1]]),scores:_.map(m=>m[0])})}return o?l:l[0]}};var Bi=class extends _e{async _call(e,{top_k:r=5}={}){let s=this.processor.feature_extractor.config.sampling_rate,n=await Es(e,s),o=this.model.config.id2label,a=[];for(let i of n){let l=await this.processor(i),p=(await this.model(l)).logits[0],d=await jt(new N("float32",Ie(p.data),p.dims),r),_=d[0].tolist(),w=d[1].tolist().map((x,E)=>({label:o?o[x]:`LABEL_${x}`,score:_[E]}));a.push(w)}return Array.isArray(e)?a:a[0]}};var Ui=class extends _e{async _call(e,r,{hypothesis_template:s="This is a sound of {}."}={}){let n=!Array.isArray(e);n&&(e=[e]);let o=r.map(p=>s.replace("{}",p)),a=this.tokenizer(o,{padding:!0,truncation:!0}),i=this.processor.feature_extractor.config.sampling_rate,l=await Es(e,i),c=[];for(let p of l){let d=await this.processor(p),_=await this.model({...a,...d}),m=Ie(_.logits_per_audio.data);c.push([...m].map((w,x)=>({score:w,label:r[x]})))}return n?c[0]:c}};var ji=class extends _e{async _call(e,r={}){switch(this.model.config.model_type){case"whisper":case"lite-whisper":return this._call_whisper(e,r);case"wav2vec2":case"wav2vec2-bert":case"unispeech":case"unispeech-sat":case"hubert":case"parakeet_ctc":return this._call_wav2vec2(e,r);case"moonshine":return this._call_moonshine(e,r);default:throw new Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,r){r.language&&Z.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),r.task&&Z.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let s=!Array.isArray(e),n=s?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await Es(n,o),i=[];for(let l of a){let c=await this.processor(l),d=(await this.model(c)).logits[0],_=[];for(let w of d)_.push(Ce(w.data)[1]);let m=this.tokenizer.decode(_,{skip_special_tokens:!0}).trim();i.push({text:m})}return s?i[0]:i}async _call_whisper(e,r){let s=r.return_timestamps??!1,n=r.chunk_length_s??0,o=r.force_full_sequences??!1,a=r.stride_length_s??null,i={...r};s==="word"&&(i.return_token_timestamps=!0,i.return_timestamps=!1);let l=!Array.isArray(e),c=l?[e]:e,p=this.processor.feature_extractor.config,d=p.chunk_length/this.model.config.max_source_positions,_=p.hop_length,m=p.sampling_rate,w=await Es(c,m),x=[];for(let E of w){let k=[];if(n>0){if(a===null)a=n/6;else if(n<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let S=m*n,L=m*a,O=S-2*L,v=0;for(;;){let W=v+S,X=E.subarray(v,W),B=await this.processor(X),H=v===0,G=W>=E.length;if(k.push({stride:[X.length,H?0:L,G?0:L],input_features:B.input_features,is_last:G}),G)break;v+=O}}else k=[{stride:[E.length,0,0],input_features:(await this.processor(E)).input_features,is_last:!0}];for(let S of k){i.num_frames=Math.floor(S.stride[0]/_);let L=await this.model.generate({inputs:S.input_features,...i});s==="word"?(S.tokens=L.sequences.tolist()[0],S.token_timestamps=L.token_timestamps.tolist()[0].map(O=>zs(O,2))):S.tokens=L[0].tolist(),S.stride=S.stride.map(O=>O/m)}let[A,T]=this.tokenizer._decode_asr(k,{time_precision:d,return_timestamps:s,force_full_sequences:o});x.push({text:A,...T})}return l?x[0]:x}async _call_moonshine(e,r){let s=!Array.isArray(e),n=s?[e]:e,o=this.processor.feature_extractor.config.sampling_rate,a=await Es(n,o),i=[];for(let l of a){let c=await this.processor(l),p=Math.floor(l.length/o)*6,d=await this.model.generate({max_new_tokens:p,...r,...c}),_=this.processor.batch_decode(d,{skip_special_tokens:!0})[0];i.push({text:_})}return s?i[0]:i}};var Gi=class extends _e{DEFAULT_VOCODER_ID="Xenova/speecht5_hifigan";constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,r){if((typeof e=="string"||e instanceof URL)&&(e=new Float32Array(await(await fe.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new N("float32",e,[e.length]);else if(!(e instanceof N))throw new Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(r>1){if(e.dims[0]===1)e=e.repeat(r,1);else if(e.dims[0]!==r)throw new Error(`Expected speaker embeddings batch size to be 1 or ${r}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,r,s,n=null){let o=r.data,[a,i]=r.dims,l=n?n.data:null,c=[];for(let p=0;p<a;++p){let d=l?Math.min(Math.ceil(l[p]),i):i,_=p*i;c.push(new Xn(o.slice(_,_+d),s))}return Array.isArray(e)?c:c[0]}async _call(e,r){return this.processor?this._call_text_to_spectrogram(e,r):this.model.config.model_type==="supertonic"?this._call_supertonic(e,r):this._call_text_to_waveform(e)}async _call_supertonic(e,{speaker_embeddings:r,num_inference_steps:s,speed:n}){if(!r)throw new Error("Speaker embeddings must be provided for Supertonic models.");let{sampling_rate:o,style_dim:a}=this.model.config,i=this.tokenizer(e,{padding:!0,truncation:!0}),l=i.input_ids.dims[0];r=await this._prepare_speaker_embeddings(r,l),r=r.view(l,-1,a);let{waveform:c,durations:p}=await this.model.generate_speech({...i,style:r,num_inference_steps:s,speed:n});return this._postprocess_waveform(e,c,o,p)}async _call_text_to_waveform(e){let r=this.tokenizer(e,{padding:!0,truncation:!0}),{waveform:s}=await this.model(r),n=this.model.config.sampling_rate;return this._postprocess_waveform(e,s,n)}async _call_text_to_spectrogram(e,{speaker_embeddings:r}){this.vocoder||(Z.info("No vocoder specified, using default HifiGan vocoder."),this.vocoder=await dr.from_pretrained(this.DEFAULT_VOCODER_ID,{dtype:"fp32"}));let{input_ids:s}=this.tokenizer(e,{padding:!0,truncation:!0}),n=s.dims[0];r=await this._prepare_speaker_embeddings(r,n),r=r.view(n,-1);let{waveform:o}=await this.model.generate_speech(s,r,{vocoder:this.vocoder}),a=this.processor.feature_extractor.config.sampling_rate;return this._postprocess_waveform(e,o,a)}};var qi=class extends _e{async _call(e,r={}){let s=Array.isArray(e),n=await Ze(e),{pixel_values:o}=await this.processor(n),a=[];for(let i of o){i.dims=[1,...i.dims];let l=await this.model.generate({inputs:i,...r}),c=this.tokenizer.batch_decode(l,{skip_special_tokens:!0}).map(p=>({generated_text:p.trim()}));a.push(c)}return s?a:a[0]}};var Wi=class extends _e{async _call(e,{top_k:r=5}={}){let s=await Ze(e),{pixel_values:n}=await this.processor(s),o=await this.model({pixel_values:n}),{id2label:a}=this.model.config,i=[];for(let l of o.logits){let c=await jt(new N("float32",Ie(l.data),l.dims),r),p=c[0].tolist(),_=c[1].tolist().map((m,w)=>({label:a?a[m]:`LABEL_${m}`,score:p[w]}));i.push(_)}return Array.isArray(e)?i:i[0]}};var JM={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},As=class extends _e{async _call(e,{threshold:r=.5,mask_threshold:s=.5,overlap_mask_area_threshold:n=.8,label_ids_to_fuse:o=null,target_sizes:a=null,subtask:i=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error("Image segmentation pipeline currently only supports a batch size of 1.");let c=await Ze(e),p=c.map(A=>[A.height,A.width]),d=await this.processor(c),{inputNames:_,outputNames:m}=this.model.sessions.model;if(!_.includes("pixel_values")){if(_.length!==1)throw Error(`Expected a single input name, but got ${_.length} inputs: ${_}.`);let A=_[0];if(A in d)throw Error(`Input name ${A} already exists in the inputs.`);d[A]=d.pixel_values}let w=await this.model(d),x=null;if(i!==null)x=JM[i];else if(this.processor.image_processor){for(let[A,T]of Object.entries(JM))if(T in this.processor.image_processor){x=this.processor.image_processor[T].bind(this.processor.image_processor),i=A;break}}let E=this.model.config.id2label,k=[];if(i)if(i==="panoptic"||i==="instance"){let A=x(w,r,s,n,o,a??p)[0],T=A.segmentation;for(let S of A.segments_info){let L=new Uint8ClampedArray(T.data.length);for(let v=0;v<T.data.length;++v)T.data[v]===S.id&&(L[v]=255);let O=new Ke(L,T.dims[1],T.dims[0],1);k.push({score:S.score,label:E[S.label_id],mask:O})}}else if(i==="semantic"){let{segmentation:A,labels:T}=x(w,a??p)[0];for(let S of T){let L=new Uint8ClampedArray(A.data.length);for(let v=0;v<A.data.length;++v)A.data[v]===S&&(L[v]=255);let O=new Ke(L,A.dims[1],A.dims[0],1);k.push({score:null,label:E[S],mask:O})}}else throw Error(`Subtask ${i} not supported.`);else{let T=w[m[0]];for(let S=0;S<p.length;++S){let L=p[S],O=T[S];O.data.some(W=>W<-1e-5||W>1+1e-5)&&O.sigmoid_();let v=await Ke.fromTensor(O.mul_(255).to("uint8")).resize(L[1],L[0]);k.push({label:null,score:null,mask:v})}}return k}};var Vi=class extends As{async _call(e,r={}){let s=await Ze(e),n=await super._call(e,r),o=s.map((a,i)=>{let l=a.clone();return l.putAlpha(n[i].mask),l});return Array.isArray(e)?o:o[0]}};var Hi=class extends _e{async _call(e,r,{hypothesis_template:s="This is a photo of {}"}={}){let n=Array.isArray(e),o=await Ze(e),a=r.map(_=>s.replace("{}",_)),i=this.tokenizer(a,{padding:this.model.config.model_type==="siglip"?"max_length":!0,truncation:!0}),{pixel_values:l}=await this.processor(o),c=await this.model({...i,pixel_values:l}),p=this.model.config.model_type==="siglip"?_=>_.sigmoid().data:_=>Ie(_.data),d=[];for(let _ of c.logits_per_image){let w=[...p(_)].map((x,E)=>({score:x,label:r[E]}));w.sort((x,E)=>E.score-x.score),d.push(w)}return n?d:d[0]}};var Xi=class extends _e{async _call(e,{threshold:r=.9,percentage:s=!1}={}){let n=Array.isArray(e);if(n&&e.length!==1)throw Error("Object detection pipeline currently only supports a batch size of 1.");let o=await Ze(e),a=s?null:o.map(m=>[m.height,m.width]),{pixel_values:i,pixel_mask:l}=await this.processor(o),c=await this.model({pixel_values:i,pixel_mask:l}),p=this.processor.image_processor.post_process_object_detection(c,r,a),{id2label:d}=this.model.config,_=p.map(m=>m.boxes.map((w,x)=>({score:m.scores[x],label:d[m.classes[x]],box:Tu(w,!s)})));return n?_:_[0]}};var Ki=class extends _e{async _call(e,r,{threshold:s=.1,top_k:n=null,percentage:o=!1}={}){let a=Array.isArray(e),i=await Ze(e),l=this.tokenizer(r,{padding:!0,truncation:!0}),c=await this.processor(i),p=[];for(let d=0;d<i.length;++d){let _=i[d],m=o?null:[[_.height,_.width]],w=c.pixel_values[d].unsqueeze_(0),x=await this.model({...l,pixel_values:w}),E;if("post_process_grounded_object_detection"in this.processor){let k=this.processor.post_process_grounded_object_detection(x,l.input_ids,{box_threshold:s,text_threshold:s,target_sizes:m})[0];E=k.boxes.map((A,T)=>({score:k.scores[T],label:k.labels[T],box:Tu(A,!o)}))}else{let k=this.processor.image_processor.post_process_object_detection(x,s,m,!0)[0];E=k.boxes.map((A,T)=>({score:k.scores[T],label:r[k.classes[T]],box:Tu(A,!o)}))}E.sort((k,A)=>A.score-k.score),n!==null&&(E=E.slice(0,n)),p.push(E)}return a?p:p[0]}};var Qi=class extends _e{async _call(e,r,s={}){if(Array.isArray(e)){if(e.length!==1)throw Error("Document Question Answering pipeline currently only supports a batch size of 1.");e=e[0]}let n=(await Ze(e))[0],{pixel_values:o}=await this.processor(n),a=`<s_docvqa><s_question>${r}</s_question><s_answer>`,i=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,l=await this.model.generate({inputs:o,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:i,...s}),p=this.tokenizer.batch_decode(l)[0].match(/<s_answer>(.*?)<\/s_answer>/),d=null;return p&&p.length>=2&&(d=p[1].trim()),[{answer:d}]}};var Yi=class extends _e{async _call(e){let r=await Ze(e),s=await this.processor(r),n=await this.model(s),o=[];for(let a of n.reconstruction){let i=a.squeeze().clamp_(0,1).mul_(255).round_().to("uint8");o.push(Ke.fromTensor(i))}return Array.isArray(e)?o:o[0]}};var Ji=class extends _e{async _call(e){let r=await Ze(e),s=await this.processor(r),{predicted_depth:n}=await this.model(s),o=[];for(let a=0;a<r.length;++a){let i=n[a],[l,c]=i.dims.slice(-2),[p,d]=r[a].size,_=(await xt(i.view(1,1,l,c),{size:[d,p],mode:"bilinear"})).view(d,p),m=_.min().item(),w=_.max().item(),x=_.sub(m).div_(w-m).mul_(255).to("uint8").unsqueeze(0),E=Ke.fromTensor(x);o.push({predicted_depth:_,depth:E})}return Array.isArray(e)?o:o[0]}};var Zi=class extends _e{async _call(e,{pooling:r="none",normalize:s=!1,quantize:n=!1,precision:o="binary"}={}){let a=this.tokenizer(e,{padding:!0,truncation:!0}),i=await this.model(a),l=i.last_hidden_state??i.logits??i.token_embeddings;switch(r){case"none":break;case"mean":l=h1(l,a.attention_mask);break;case"first_token":case"cls":l=l.slice(null,0);break;case"last_token":case"eos":l=l.slice(null,-1);break;default:throw Error(`Pooling method '${r}' not supported.`)}return s&&(l=l.normalize(2,-1)),n&&(l=x1(l,o)),l}};var el=class extends _e{async _call(e,{pool:r=null}={}){let s=await Ze(e),{pixel_values:n}=await this.processor(s),o=await this.model({pixel_values:n}),a;if(r){if(!("pooler_output"in o))throw Error("No pooled output was returned. Make sure the model has a 'pooler' layer when using the 'pool' option.");a=o.pooler_output}else a=o.last_hidden_state??o.logits??o.image_embeds;return a}};var tl=Object.freeze({"text-classification":{pipeline:Li,model:Ti,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:Pi,model:pu,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:zi,model:gu,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:Ni,model:hu,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:$i,model:En,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:Ri,model:En,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:fr,model:En,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:Di,model:mu,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:Fi,model:Ti,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:Bi,model:ku,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:Ui,model:dr,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:ji,model:[du,vu],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:Gi,model:[_u,fu],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:qi,model:wu,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:Wi,model:xu,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:As,model:[Oi,Ii,Ci],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:Vi,model:[Oi,Ii,Ci],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:Hi,model:dr,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:Xi,model:yu,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:Ki,model:bu,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:Qi,model:Eu,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Yi,model:Au,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Ji,model:Mu,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:Zi,model:dr,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:el,model:[Su,dr],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),k0=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});function IN(t,{config:e=null,cache_dir:r=null,local_files_only:s=!1,revision:n="main"}={}){if(e!==null)return Nt.from_pretrained(t,{config:e,cache_dir:r,local_files_only:s,revision:n});let o=JSON.stringify([t,r,s,n]);return Ju(o,()=>Nt.from_pretrained(t,{config:e,cache_dir:r,local_files_only:s,revision:n}))}async function E0(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null}={}){e=await IN(t,{config:e});let o=["config.json"],a=e["transformers.js_config"]??{},i=a.use_external_data_format,l="onnx",c=s??a.device,p=r??a.dtype,d,_=e.architectures||[],m=!1;for(let k of _){let A=er.get(k);if(A!==void 0){d=A,m=!0;break}}if(!m&&e.model_type){let k=er.get(e.model_type);if(k!==void 0&&(d=k,m=!0),!m){for(let A of Object.values(en))if(A.has(e.model_type)){d=er.get(A.get(e.model_type)),m=!0;break}}}if(!m){let k=_.length>0?_.join(", "):"(none)";Z.warn(`[get_model_files] Architecture(s) not found in MODEL_TYPE_MAPPING: [${k}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${ns}`),d=K.EncoderOnly}let w=(k,A=null)=>{A=A??k;let T=gp(c,k),S=wp(p,k,T),L=Tl[S]??"",O=`${A}${L}.onnx`,v=l?`${l}/${O}`:O;o.push(v);let W=O1(i,O,k);for(let X of I1(O,W)){let B=l?`${l}/${X}`:X;o.push(B)}},{sessions:x,optional_configs:E}=hM(d,e,{model_file_name:n});for(let[k,A]of Object.entries(x))w(k,A);if(E)for(let k of Object.values(E))o.push(k);return o}async function A0(t){if(!t)throw new Error("modelId is required");return(await cr(t,Er,{})).exists?[Er]:[]}async function Br(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null,include_tokenizer:o=!0,include_processor:a=!0}={}){let i=await E0(t,{config:e,dtype:r,device:s,model_file_name:n});if(o){let l=await Wn(t);i.push(...l)}if(a){let l=await A0(t);i.push(...l)}return i}async function Ur(t,e,r={}){t=k0[t]??t;let s=tl[t];if(!s)throw new Error(`Unsupported pipeline task: ${t}. Must be one of [${Object.keys(tl).join(", ")}]`);let{type:n}=s;return Br(e,{...r,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"})}async function CN(t,e=null,{progress_callback:r=null,config:s=null,cache_dir:n=null,local_files_only:o=!1,revision:a="main",device:i=null,dtype:l=null,subfolder:c="onnx",use_external_data_format:p=null,model_file_name:d=null,session_options:_={}}={}){t=k0[t]??t;let m=tl[t.split("_",1)[0]];if(!m)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(tl)}]`);e||(e=m.default.model,Z.info(`No model specified. Using default model: "${e}".`),!l&&m.default.dtype&&(l=m.default.dtype));let w=await Ur(t,e,{device:i,dtype:l}),x={};r&&(await Promise.all(w.map(async H=>cr(e,H)))).forEach((H,G)=>{H.exists&&(x[w[G]]={loaded:0,total:H.size??0})});let E={progress_callback:r?B=>{if(B.status==="progress"){x[B.file]={loaded:B.loaded,total:B.total};let H=Object.values(x).reduce((R,C)=>R+C.loaded,0),G=Object.values(x).reduce((R,C)=>R+C.total,0),Q=G>0?H/G*100:0;r({status:"progress_total",name:B.name,progress:Q,loaded:H,total:G,files:structuredClone(x)})}r(B)}:void 0,config:s,cache_dir:n,local_files_only:o,revision:a,device:i,dtype:l,subfolder:c,use_external_data_format:p,model_file_name:d,session_options:_},k=w.includes("tokenizer.json"),A=w.includes("preprocessor_config.json"),T=m.model,S;if(Array.isArray(T)){let B=s??await Nt.from_pretrained(e,E),{model_type:H}=B,G=T.find(Q=>Q.supports(H));if(!G)throw Error(`Unsupported model type "${H}" for task "${t}". None of the candidate model classes support this type.`);S=G.from_pretrained(e,{...E,config:B})}else S=T.from_pretrained(e,E);let[L,O,v]=await Promise.all([k?oe.from_pretrained(e,E):null,A?Zl.from_pretrained(e,E):null,S]),W={task:t,model:v};L&&(W.tokenizer=L),O&&(W.processor=O),br(r,{status:"ready",task:t,model:e});let X=m.pipeline;return new X(W)}var LN=t=>t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=173791||t>=173824&&t<=177983||t>=177984&&t<=178207||t>=178208&&t<=183983||t>=63744&&t<=64255||t>=194560&&t<=195103,M0=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},ZM=ie.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),S0=class extends M0{constructor(e,{skip_prompt:r=!1,callback_function:s=null,token_callback_function:n=null,skip_special_tokens:o=!0,decode_kwargs:a={},...i}={}){super(),this.tokenizer=e,this.skip_prompt=r,this.callback_function=s??ZM,this.token_callback_function=n,this.decode_kwargs={skip_special_tokens:o,...a,...i},this.token_cache=[],this.print_len=0,this.next_tokens_are_prompt=!0,this.special_ids=new Set(this.tokenizer.all_special_ids.map(BigInt))}put(e){if(e.length>1)throw Error("TextStreamer only supports batch size of 1");let r=this.next_tokens_are_prompt;if(r&&(this.next_tokens_are_prompt=!1,this.skip_prompt))return;let s=e[0];if(this.token_callback_function?.(s),s.length===1&&this.special_ids.has(s[0])){if(this.decode_kwargs.skip_special_tokens)return;if(this.token_cache.length>0){let l=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len);this.on_finalized_text(l,!1),this.token_cache=[],this.print_len=0}let a=this.tokenizer.decode(s,this.decode_kwargs);this.on_finalized_text(a,!1);return}this.token_cache=ht(this.token_cache,s);let n=this.tokenizer.decode(this.token_cache,this.decode_kwargs),o;r||n.endsWith(`
|
|
26
|
+
`)?(o=n.slice(this.print_len),this.token_cache=[],this.print_len=0):n.length>0&&LN(n.charCodeAt(n.length-1))?(o=n.slice(this.print_len),this.print_len+=o.length):(o=n.slice(this.print_len,n.lastIndexOf(" ")+1),this.print_len+=o.length),this.on_finalized_text(o,!1)}end(){let e;this.token_cache.length>0?(e=this.tokenizer.decode(this.token_cache,this.decode_kwargs).slice(this.print_len),this.token_cache=[],this.print_len=0):e="",this.next_tokens_are_prompt=!0,this.on_finalized_text(e,!0)}on_finalized_text(e,r){e.length>0&&this.callback_function?.(e),r&&this.callback_function===ZM&&ie.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
|
|
27
|
+
`)}},J1=class extends S0{constructor(e,{skip_prompt:r=!1,callback_function:s=null,token_callback_function:n=null,on_chunk_start:o=null,on_chunk_end:a=null,on_finalize:i=null,time_precision:l=.02,skip_special_tokens:c=!0,decode_kwargs:p={}}={}){super(e,{skip_prompt:r,skip_special_tokens:c,callback_function:s,token_callback_function:n,decode_kwargs:p}),this.timestamp_begin=e.timestamp_begin,this.on_chunk_start=o,this.on_chunk_end=a,this.on_finalize=i,this.time_precision=l,this.waiting_for_timestamp=!1}put(e){if(e.length>1)throw Error("WhisperTextStreamer only supports batch size of 1");let r=e[0];if(r.length===1){let s=Number(r[0])-this.timestamp_begin;if(s>=0){let n=s*this.time_precision;this.waiting_for_timestamp?this.on_chunk_end?.(n):this.on_chunk_start?.(n),this.waiting_for_timestamp=!this.waiting_for_timestamp,this.token_callback_function?.(r);return}}return super.put(e)}end(){super.end(),this.on_finalize?.()}};var rl=class{constructor(e,r){this.image=e,this.timestamp=r}},Ou=class{constructor(e,r){e.length>0&&e[0]instanceof Ke&&(e=e.map((s,n)=>new rl(s,(n+1)/(e.length+1)*r))),this.frames=e,this.duration=r}get width(){return this.frames[0].image.width}get height(){return this.frames[0].image.height}get fps(){return this.frames.length/this.duration}};async function eS(t,{num_frames:e=null,fps:r=null}={}){if(!ie.IS_BROWSER_ENV)throw new Error("`load_video` is currently only supported in browser environments.");if(e==null&&r==null)throw new Error("Either num_frames or fps must be provided.");let s=[],n=document.createElement("video");if(n.crossOrigin="anonymous",n.muted=!0,typeof t=="string")n.src=t;else if(t instanceof Blob)n.src=URL.createObjectURL(t);else if(t instanceof HTMLVideoElement)n.src=t.src;else throw new Error("Invalid URL or video element provided.");if(await new Promise(d=>n.onloadedmetadata=d),n.seekable.start(0)===n.seekable.end(0)){let _=await(await fe.fetch(n.src)).blob();n.src=URL.createObjectURL(_),await new Promise(m=>n.onloadedmetadata=m)}let o=n.duration,a,i;e!=null?(a=e,i=e===1?0:o/(e-1)):(i=1/r,a=Math.floor(o/i));let l=[];for(let d=0;d<a;++d)l.push(e===1?o/2:d*i);let c=document.createElement("canvas");c.width=n.videoWidth,c.height=n.videoHeight;let p=c.getContext("2d",{willReadFrequently:!0});for(let d of l){n.currentTime=d,await new Promise(x=>{n.onseeked=x}),p.drawImage(n,0,0,c.width,c.height);let _=p.getImageData(0,0,c.width,c.height),m=new Ke(_.data,c.width,c.height,4),w=new rl(m,d);s.push(w)}return n.remove(),new Ou(s,o)}async function T0(t,e,r={}){let s=await Yt(r?.cache_dir);if(!s)return{allCached:!1,files:e.map(a=>({file:a,cached:!1}))};let n=await Promise.all(e.map(async o=>{let{localPath:a,proposedCacheKey:i}=Kr(t,o,r,s),l=await Qr(s,a,i);return{file:o,cached:!!l}}));return{allCached:n.every(o=>o.cached),files:n}}async function tS(t,e,r={}){let s=await Yt(r?.cache_dir);if(!s)return!1;let{localPath:n,proposedCacheKey:o}=Kr(t,e,r,s);return!!await Qr(s,n,o)}async function rS(t,e={}){if(!t)throw new Error("modelId is required");if(!await tS(t,"config.json",e))return!1;let r=await Br(t,e);return(await T0(t,r,e)).allCached}async function sS(t,e={}){if(!t)throw new Error("modelId is required");let r=await Br(t,e);return await T0(t,r,e)}async function nS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");if(!await tS(e,"config.json",r))return!1;let s=await Ur(t,e,r);return(await T0(e,s,r)).allCached}async function oS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Ur(t,e,r);return await T0(e,s,r)}async function aS(t,e,r={}){let s=await Yt(r?.cache_dir);if(!s)return{filesDeleted:0,filesCached:0,files:e.map(o=>({file:o,deleted:!1,wasCached:!1}))};if(!s.delete)throw new Error("Cache does not support delete operation");let n=await Promise.all(e.map(async o=>{let{localPath:a,proposedCacheKey:i}=Kr(t,o,r,s),c=!!await Qr(s,a,i),p=!1;if(c){let d=await s.delete(i),_=!d&&i!==a?await s.delete(a):!1;p=d||_}return{file:o,deleted:p,wasCached:c}}));return{filesDeleted:n.filter(o=>o.deleted).length,filesCached:n.filter(o=>o.wasCached).length,files:n}}async function iS(t,e={}){if(!t)throw new Error("modelId is required");let r=await Br(t,e);return await aS(t,r,e)}async function lS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Ur(t,e,r);return await aS(e,s,r)}var O0=class{static async get_files(e,r={}){return Br(e,r)}static async get_pipeline_files(e,r,s={}){return Ur(e,r,s)}static async get_model_files(e,r={}){return E0(e,r)}static async get_tokenizer_files(e){return Wn(e)}static async get_processor_files(e){return A0(e)}static async is_cached(e,r={}){return rS(e,r)}static async is_cached_files(e,r={}){return sS(e,r)}static async is_pipeline_cached(e,r,s={}){return nS(e,r,s)}static async is_pipeline_cached_files(e,r,s={}){return oS(e,r,s)}static async get_file_metadata(e,r,s={}){return cr(e,r,s)}static async clear_cache(e,r={}){return iS(e,r)}static async clear_pipeline_cache(e,r,s={}){return lS(e,r,s)}};0&&(module.exports={ASTFeatureExtractor,ASTForAudioClassification,ASTModel,ASTPreTrainedModel,AfmoeForCausalLM,AfmoeModel,AfmoePreTrainedModel,AlbertForMaskedLM,AlbertForQuestionAnswering,AlbertForSequenceClassification,AlbertModel,AlbertPreTrainedModel,AlbertTokenizer,ApertusForCausalLM,ApertusModel,ApertusPreTrainedModel,ArceeForCausalLM,ArceeModel,ArceePreTrainedModel,AudioClassificationPipeline,AutoConfig,AutoFeatureExtractor,AutoImageProcessor,AutoModel,AutoModelForAudioClassification,AutoModelForAudioFrameClassification,AutoModelForAudioTextToText,AutoModelForCTC,AutoModelForCausalLM,AutoModelForDepthEstimation,AutoModelForDocumentQuestionAnswering,AutoModelForImageClassification,AutoModelForImageFeatureExtraction,AutoModelForImageMatting,AutoModelForImageSegmentation,AutoModelForImageTextToText,AutoModelForImageToImage,AutoModelForMaskGeneration,AutoModelForMaskedLM,AutoModelForNormalEstimation,AutoModelForObjectDetection,AutoModelForPoseEstimation,AutoModelForQuestionAnswering,AutoModelForSemanticSegmentation,AutoModelForSeq2SeqLM,AutoModelForSequenceClassification,AutoModelForSpeechSeq2Seq,AutoModelForTextToSpectrogram,AutoModelForTextToWaveform,AutoModelForTokenClassification,AutoModelForUniversalSegmentation,AutoModelForVision2Seq,AutoModelForXVector,AutoModelForZeroShotObjectDetection,AutoProcessor,AutoTokenizer,AutomaticSpeechRecognitionPipeline,BackgroundRemovalPipeline,BartForConditionalGeneration,BartForSequenceClassification,BartModel,BartPretrainedModel,BartTokenizer,BaseStreamer,BeitFeatureExtractor,BeitForImageClassification,BeitModel,BeitPreTrainedModel,BertForMaskedLM,BertForQuestionAnswering,BertForSequenceClassification,BertForTokenClassification,BertModel,BertPreTrainedModel,BertTokenizer,BitImageProcessor,BlenderbotForConditionalGeneration,BlenderbotModel,BlenderbotPreTrainedModel,BlenderbotSmallForConditionalGeneration,BlenderbotSmallModel,BlenderbotSmallPreTrainedModel,BlenderbotSmallTokenizer,BlenderbotTokenizer,BloomForCausalLM,BloomModel,BloomPreTrainedModel,BloomTokenizer,CHMv2ForDepthEstimation,CHMv2ImageProcessor,CHMv2PreTrainedModel,CLIPFeatureExtractor,CLIPImageProcessor,CLIPModel,CLIPPreTrainedModel,CLIPSegForImageSegmentation,CLIPSegModel,CLIPSegPreTrainedModel,CLIPTextModel,CLIPTextModelWithProjection,CLIPTokenizer,CLIPVisionModel,CLIPVisionModelWithProjection,CamembertForMaskedLM,CamembertForQuestionAnswering,CamembertForSequenceClassification,CamembertForTokenClassification,CamembertModel,CamembertPreTrainedModel,CamembertTokenizer,ChatterboxFeatureExtractor,ChatterboxModel,ChatterboxPreTrainedModel,ChatterboxProcessor,ChineseCLIPFeatureExtractor,ChineseCLIPModel,ChineseCLIPPreTrainedModel,ClapAudioModelWithProjection,ClapFeatureExtractor,ClapModel,ClapPreTrainedModel,ClapTextModelWithProjection,ClassifierFreeGuidanceLogitsProcessor,CodeGenForCausalLM,CodeGenModel,CodeGenPreTrainedModel,CodeGenTokenizer,CodeLlamaTokenizer,Cohere2ForCausalLM,Cohere2Model,Cohere2PreTrainedModel,CohereForCausalLM,CohereModel,CoherePreTrainedModel,CohereTokenizer,ConvBertForMaskedLM,ConvBertForQuestionAnswering,ConvBertForSequenceClassification,ConvBertForTokenClassification,ConvBertModel,ConvBertPreTrainedModel,ConvBertTokenizer,ConvNextFeatureExtractor,ConvNextForImageClassification,ConvNextImageProcessor,ConvNextModel,ConvNextPreTrainedModel,ConvNextV2ForImageClassification,ConvNextV2Model,ConvNextV2PreTrainedModel,DFineForObjectDetection,DFineModel,DFinePreTrainedModel,DINOv3ConvNextModel,DINOv3ConvNextPreTrainedModel,DINOv3ViTImageProcessor,DINOv3ViTModel,DINOv3ViTPreTrainedModel,DPTFeatureExtractor,DPTForDepthEstimation,DPTImageProcessor,DPTModel,DPTPreTrainedModel,DacDecoderModel,DacDecoderOutput,DacEncoderModel,DacEncoderOutput,DacFeatureExtractor,DacModel,DacPreTrainedModel,DebertaForMaskedLM,DebertaForQuestionAnswering,DebertaForSequenceClassification,DebertaForTokenClassification,DebertaModel,DebertaPreTrainedModel,DebertaTokenizer,DebertaV2ForMaskedLM,DebertaV2ForQuestionAnswering,DebertaV2ForSequenceClassification,DebertaV2ForTokenClassification,DebertaV2Model,DebertaV2PreTrainedModel,DebertaV2Tokenizer,DecisionTransformerModel,DecisionTransformerPreTrainedModel,DeepseekV3ForCausalLM,DeepseekV3Model,DeepseekV3PreTrainedModel,DeiTFeatureExtractor,DeiTForImageClassification,DeiTImageProcessor,DeiTModel,DeiTPreTrainedModel,DepthAnythingForDepthEstimation,DepthAnythingPreTrainedModel,DepthEstimationPipeline,DepthProForDepthEstimation,DepthProPreTrainedModel,DetrFeatureExtractor,DetrForObjectDetection,DetrForSegmentation,DetrImageProcessor,DetrModel,DetrObjectDetectionOutput,DetrPreTrainedModel,DetrSegmentationOutput,Dinov2ForImageClassification,Dinov2Model,Dinov2PreTrainedModel,Dinov2WithRegistersForImageClassification,Dinov2WithRegistersModel,Dinov2WithRegistersPreTrainedModel,DistilBertForMaskedLM,DistilBertForQuestionAnswering,DistilBertForSequenceClassification,DistilBertForTokenClassification,DistilBertModel,DistilBertPreTrainedModel,DistilBertTokenizer,DocumentQuestionAnsweringPipeline,DonutFeatureExtractor,DonutImageProcessor,DonutSwinModel,DonutSwinPreTrainedModel,DynamicCache,EdgeTamModel,EfficientNetForImageClassification,EfficientNetImageProcessor,EfficientNetModel,EfficientNetPreTrainedModel,ElectraForMaskedLM,ElectraForQuestionAnswering,ElectraForSequenceClassification,ElectraForTokenClassification,ElectraModel,ElectraPreTrainedModel,ElectraTokenizer,EncodecFeatureExtractor,EosTokenCriteria,Ernie4_5ForCausalLM,Ernie4_5Model,Ernie4_5PretrainedModel,EsmForMaskedLM,EsmForSequenceClassification,EsmForTokenClassification,EsmModel,EsmPreTrainedModel,EsmTokenizer,EuroBertForMaskedLM,EuroBertForSequenceClassification,EuroBertForTokenClassification,EuroBertModel,EuroBertPreTrainedModel,ExaoneForCausalLM,ExaoneModel,ExaonePreTrainedModel,FalconForCausalLM,FalconH1ForCausalLM,FalconH1Model,FalconH1PreTrainedModel,FalconModel,FalconPreTrainedModel,FalconTokenizer,FastViTForImageClassification,FastViTModel,FastViTPreTrainedModel,FeatureExtractionPipeline,FeatureExtractor,FillMaskPipeline,Florence2ForConditionalGeneration,Florence2PreTrainedModel,Florence2Processor,ForcedBOSTokenLogitsProcessor,ForcedEOSTokenLogitsProcessor,GLPNFeatureExtractor,GLPNForDepthEstimation,GLPNModel,GLPNPreTrainedModel,GPT2LMHeadModel,GPT2Model,GPT2PreTrainedModel,GPT2Tokenizer,GPTBigCodeForCausalLM,GPTBigCodeModel,GPTBigCodePreTrainedModel,GPTJForCausalLM,GPTJModel,GPTJPreTrainedModel,GPTNeoForCausalLM,GPTNeoModel,GPTNeoPreTrainedModel,GPTNeoXForCausalLM,GPTNeoXModel,GPTNeoXPreTrainedModel,GPTNeoXTokenizer,Gemma2ForCausalLM,Gemma2Model,Gemma2PreTrainedModel,Gemma3ForCausalLM,Gemma3Model,Gemma3PreTrainedModel,Gemma3nAudioFeatureExtractor,Gemma3nForCausalLM,Gemma3nForConditionalGeneration,Gemma3nPreTrainedModel,Gemma3nProcessor,GemmaForCausalLM,GemmaModel,GemmaPreTrainedModel,GemmaTokenizer,Glm46VImageProcessor,Glm46VProcessor,GlmForCausalLM,GlmModel,GlmMoeDsaForCausalLM,GlmMoeDsaModel,GlmMoeDsaPreTrainedModel,GlmOcrForConditionalGeneration,GlmPreTrainedModel,GptOssForCausalLM,GptOssModel,GptOssPreTrainedModel,GraniteForCausalLM,GraniteModel,GraniteMoeHybridForCausalLM,GraniteMoeHybridModel,GraniteMoeHybridPreTrainedModel,GranitePreTrainedModel,GraniteSpeechFeatureExtractor,GraniteSpeechForConditionalGeneration,GraniteSpeechProcessor,GroundingDinoForObjectDetection,GroundingDinoImageProcessor,GroundingDinoPreTrainedModel,GroundingDinoProcessor,GroupViTModel,GroupViTPreTrainedModel,HeliumForCausalLM,HeliumModel,HeliumPreTrainedModel,HerbertTokenizer,HieraForImageClassification,HieraModel,HieraPreTrainedModel,HubertForCTC,HubertForSequenceClassification,HubertModel,HubertPreTrainedModel,HunYuanDenseV1ForCausalLM,HunYuanDenseV1Model,HunYuanDenseV1PreTrainedModel,IJepaForImageClassification,IJepaModel,IJepaPreTrainedModel,Idefics3ForConditionalGeneration,Idefics3ImageProcessor,Idefics3Processor,ImageClassificationPipeline,ImageFeatureExtractionPipeline,ImageFeatureExtractor,ImageProcessor,ImageSegmentationPipeline,ImageToImagePipeline,ImageToTextPipeline,InterruptableStoppingCriteria,JAISLMHeadModel,JAISModel,JAISPreTrainedModel,JinaCLIPImageProcessor,JinaCLIPModel,JinaCLIPPreTrainedModel,JinaCLIPProcessor,JinaCLIPTextModel,JinaCLIPVisionModel,Lfm2ForCausalLM,Lfm2Model,Lfm2MoeForCausalLM,Lfm2MoeModel,Lfm2MoePreTrainedModel,Lfm2PreTrainedModel,Lfm2VlForConditionalGeneration,Lfm2VlImageProcessor,Lfm2VlProcessor,LightOnOcrForConditionalGeneration,LiteWhisperForConditionalGeneration,Llama4ForCausalLM,Llama4PreTrainedModel,LlamaForCausalLM,LlamaModel,LlamaPreTrainedModel,LlamaTokenizer,LlavaForConditionalGeneration,LlavaOnevisionForConditionalGeneration,LlavaOnevisionImageProcessor,LlavaPreTrainedModel,LlavaProcessor,LlavaQwen2ForCausalLM,LogLevel,LogitsProcessor,LogitsProcessorList,LogitsWarper,LongT5ForConditionalGeneration,LongT5Model,LongT5PreTrainedModel,M2M100ForConditionalGeneration,M2M100Model,M2M100PreTrainedModel,M2M100Tokenizer,MBart50Tokenizer,MBartForCausalLM,MBartForConditionalGeneration,MBartForSequenceClassification,MBartModel,MBartPreTrainedModel,MBartTokenizer,MPNetForMaskedLM,MPNetForQuestionAnswering,MPNetForSequenceClassification,MPNetForTokenClassification,MPNetModel,MPNetPreTrainedModel,MPNetTokenizer,MT5ForConditionalGeneration,MT5Model,MT5PreTrainedModel,MarianMTModel,MarianModel,MarianPreTrainedModel,MarianTokenizer,Mask2FormerImageProcessor,MaskFormerFeatureExtractor,MaskFormerForInstanceSegmentation,MaskFormerImageProcessor,MaskFormerModel,MaskFormerPreTrainedModel,MaxLengthCriteria,Metric3DForDepthEstimation,Metric3DPreTrainedModel,Metric3Dv2ForDepthEstimation,Metric3Dv2PreTrainedModel,MgpstrForSceneTextRecognition,MgpstrModelOutput,MgpstrPreTrainedModel,MgpstrProcessor,MgpstrTokenizer,MimiDecoderModel,MimiDecoderOutput,MimiEncoderModel,MimiEncoderOutput,MimiModel,MimiPreTrainedModel,MinLengthLogitsProcessor,MinNewTokensLengthLogitsProcessor,Mistral4ForCausalLM,Mistral4Model,Mistral4PreTrainedModel,MistralForCausalLM,MistralModel,MistralPreTrainedModel,MobileBertForMaskedLM,MobileBertForQuestionAnswering,MobileBertForSequenceClassification,MobileBertModel,MobileBertPreTrainedModel,MobileBertTokenizer,MobileLLMForCausalLM,MobileLLMModel,MobileLLMPreTrainedModel,MobileNetV1FeatureExtractor,MobileNetV1ForImageClassification,MobileNetV1ForSemanticSegmentation,MobileNetV1ImageProcessor,MobileNetV1Model,MobileNetV1PreTrainedModel,MobileNetV2FeatureExtractor,MobileNetV2ForImageClassification,MobileNetV2ForSemanticSegmentation,MobileNetV2ImageProcessor,MobileNetV2Model,MobileNetV2PreTrainedModel,MobileNetV3FeatureExtractor,MobileNetV3ForImageClassification,MobileNetV3ForSemanticSegmentation,MobileNetV3ImageProcessor,MobileNetV3Model,MobileNetV3PreTrainedModel,MobileNetV4FeatureExtractor,MobileNetV4ForImageClassification,MobileNetV4ForSemanticSegmentation,MobileNetV4ImageProcessor,MobileNetV4Model,MobileNetV4PreTrainedModel,MobileViTFeatureExtractor,MobileViTForImageClassification,MobileViTImageProcessor,MobileViTModel,MobileViTPreTrainedModel,MobileViTV2ForImageClassification,MobileViTV2Model,MobileViTV2PreTrainedModel,ModelRegistry,ModernBertDecoderForCausalLM,ModernBertDecoderModel,ModernBertDecoderPreTrainedModel,ModernBertForMaskedLM,ModernBertForSequenceClassification,ModernBertForTokenClassification,ModernBertModel,ModernBertPreTrainedModel,Moondream1ForConditionalGeneration,MoonshineFeatureExtractor,MoonshineForConditionalGeneration,MoonshineModel,MoonshinePreTrainedModel,MoonshineProcessor,MptForCausalLM,MptModel,MptPreTrainedModel,MultiModalityCausalLM,MultiModalityPreTrainedModel,MusicgenForCausalLM,MusicgenForConditionalGeneration,MusicgenModel,MusicgenPreTrainedModel,NanoChatForCausalLM,NanoChatModel,NanoChatPreTrainedModel,NemotronHForCausalLM,NemotronHModel,NemotronHPreTrainedModel,NeoBertForMaskedLM,NeoBertForQuestionAnswering,NeoBertForSequenceClassification,NeoBertForTokenClassification,NeoBertModel,NeoBertPreTrainedModel,NllbTokenizer,NoBadWordsLogitsProcessor,NoRepeatNGramLogitsProcessor,NomicBertModel,NomicBertPreTrainedModel,NougatImageProcessor,NougatTokenizer,OPTForCausalLM,OPTModel,OPTPreTrainedModel,ObjectDetectionPipeline,Olmo2ForCausalLM,Olmo2Model,Olmo2PreTrainedModel,Olmo3ForCausalLM,Olmo3Model,Olmo3PreTrainedModel,OlmoForCausalLM,OlmoHybridForCausalLM,OlmoHybridModel,OlmoHybridPreTrainedModel,OlmoModel,OlmoPreTrainedModel,OpenELMForCausalLM,OpenELMModel,OpenELMPreTrainedModel,OwlViTFeatureExtractor,OwlViTForObjectDetection,OwlViTImageProcessor,OwlViTModel,OwlViTPreTrainedModel,OwlViTProcessor,Owlv2ForObjectDetection,Owlv2ImageProcessor,Owlv2Model,Owlv2PreTrainedModel,PaliGemmaForConditionalGeneration,PaliGemmaProcessor,ParakeetFeatureExtractor,ParakeetForCTC,ParakeetPreTrainedModel,PatchTSMixerForPrediction,PatchTSMixerModel,PatchTSMixerPreTrainedModel,PatchTSTForPrediction,PatchTSTModel,PatchTSTPreTrainedModel,Phi3ForCausalLM,Phi3Model,Phi3PreTrainedModel,Phi3VForCausalLM,Phi3VImageProcessor,Phi3VPreTrainedModel,Phi3VProcessor,PhiForCausalLM,PhiModel,PhiPreTrainedModel,PixtralImageProcessor,PixtralProcessor,PreTrainedModel,PreTrainedTokenizer,PretrainedConfig,Processor,PvtForImageClassification,PvtImageProcessor,PvtModel,PvtPreTrainedModel,PyAnnoteFeatureExtractor,PyAnnoteForAudioFrameClassification,PyAnnoteModel,PyAnnotePreTrainedModel,PyAnnoteProcessor,QuestionAnsweringPipeline,Qwen2ForCausalLM,Qwen2Model,Qwen2MoeForCausalLM,Qwen2MoeModel,Qwen2MoePreTrainedModel,Qwen2PreTrainedModel,Qwen2Tokenizer,Qwen2VLForCausalLM,Qwen2VLForConditionalGeneration,Qwen2VLImageProcessor,Qwen2VLPreTrainedModel,Qwen2VLProcessor,Qwen2_5_VLForCausalLM,Qwen2_5_VLForConditionalGeneration,Qwen2_5_VLProcessor,Qwen3ForCausalLM,Qwen3Model,Qwen3MoeForCausalLM,Qwen3MoeModel,Qwen3MoePreTrainedModel,Qwen3NextForCausalLM,Qwen3NextModel,Qwen3NextPreTrainedModel,Qwen3PreTrainedModel,Qwen3VLForCausalLM,Qwen3VLForConditionalGeneration,Qwen3VLMoeForCausalLM,Qwen3VLMoeForConditionalGeneration,Qwen3VLProcessor,Qwen3_5ForCausalLM,Qwen3_5ForConditionalGeneration,Qwen3_5MoeForCausalLM,Qwen3_5MoeForConditionalGeneration,RFDetrForObjectDetection,RFDetrModel,RFDetrObjectDetectionOutput,RFDetrPreTrainedModel,RTDetrForObjectDetection,RTDetrImageProcessor,RTDetrModel,RTDetrObjectDetectionOutput,RTDetrPreTrainedModel,RTDetrV2ForObjectDetection,RTDetrV2Model,RTDetrV2ObjectDetectionOutput,RTDetrV2PreTrainedModel,RawAudio,RawImage,RawVideo,RawVideoFrame,RepetitionPenaltyLogitsProcessor,ResNetForImageClassification,ResNetModel,ResNetPreTrainedModel,RoFormerForMaskedLM,RoFormerForQuestionAnswering,RoFormerForSequenceClassification,RoFormerForTokenClassification,RoFormerModel,RoFormerPreTrainedModel,RoFormerTokenizer,RobertaForMaskedLM,RobertaForQuestionAnswering,RobertaForSequenceClassification,RobertaForTokenClassification,RobertaModel,RobertaPreTrainedModel,RobertaTokenizer,Sam2ImageProcessor,Sam2ImageSegmentationOutput,Sam2Model,Sam2PreTrainedModel,Sam2Processor,Sam2VideoProcessor,Sam3ImageProcessor,Sam3TrackerModel,SamImageProcessor,SamImageSegmentationOutput,SamModel,SamPreTrainedModel,SamProcessor,SapiensFeatureExtractor,SapiensForDepthEstimation,SapiensForNormalEstimation,SapiensForSemanticSegmentation,SapiensImageProcessor,SapiensPreTrainedModel,SeamlessM4TFeatureExtractor,SegformerFeatureExtractor,SegformerForImageClassification,SegformerForSemanticSegmentation,SegformerImageProcessor,SegformerModel,SegformerPreTrainedModel,SiglipImageProcessor,SiglipModel,SiglipPreTrainedModel,SiglipTextModel,SiglipTokenizer,SiglipVisionModel,SmolLM3ForCausalLM,SmolLM3Model,SmolLM3PreTrainedModel,SmolVLMImageProcessor,SmolVLMProcessor,SnacDecoderModel,SnacEncoderModel,SnacFeatureExtractor,SnacModel,SnacPreTrainedModel,SolarOpenForCausalLM,SolarOpenModel,SolarOpenPreTrainedModel,SpeechT5FeatureExtractor,SpeechT5ForSpeechToText,SpeechT5ForTextToSpeech,SpeechT5HifiGan,SpeechT5Model,SpeechT5PreTrainedModel,SpeechT5Processor,SpeechT5Tokenizer,SqueezeBertForMaskedLM,SqueezeBertForQuestionAnswering,SqueezeBertForSequenceClassification,SqueezeBertModel,SqueezeBertPreTrainedModel,SqueezeBertTokenizer,StableLmForCausalLM,StableLmModel,StableLmPreTrainedModel,Starcoder2ForCausalLM,Starcoder2Model,Starcoder2PreTrainedModel,StoppingCriteria,StoppingCriteriaList,StyleTextToSpeech2Model,StyleTextToSpeech2PreTrainedModel,SummarizationPipeline,SupertonicForConditionalGeneration,SupertonicPreTrainedModel,SuppressTokensAtBeginLogitsProcessor,Swin2SRForImageSuperResolution,Swin2SRImageProcessor,Swin2SRModel,Swin2SRPreTrainedModel,SwinForImageClassification,SwinForSemanticSegmentation,SwinModel,SwinPreTrainedModel,T5ForConditionalGeneration,T5Model,T5PreTrainedModel,T5Tokenizer,TableTransformerForObjectDetection,TableTransformerModel,TableTransformerObjectDetectionOutput,TableTransformerPreTrainedModel,TemperatureLogitsWarper,Tensor,Text2TextGenerationPipeline,TextClassificationPipeline,TextGenerationPipeline,TextStreamer,TextToAudioPipeline,TokenClassificationPipeline,TokenizersBackend,TopKLogitsWarper,TopPLogitsWarper,TrOCRForCausalLM,TrOCRPreTrainedModel,TranslationPipeline,UltravoxModel,UltravoxPreTrainedModel,UltravoxProcessor,UniSpeechForCTC,UniSpeechForSequenceClassification,UniSpeechModel,UniSpeechPreTrainedModel,UniSpeechSatForAudioFrameClassification,UniSpeechSatForCTC,UniSpeechSatForSequenceClassification,UniSpeechSatModel,UniSpeechSatPreTrainedModel,VLChatProcessor,VLMImageProcessor,VaultGemmaForCausalLM,VaultGemmaModel,VaultGemmaPreTrainedModel,ViTFeatureExtractor,ViTForImageClassification,ViTImageProcessor,ViTMAEModel,ViTMAEPreTrainedModel,ViTMSNForImageClassification,ViTMSNModel,ViTMSNPreTrainedModel,ViTModel,ViTPreTrainedModel,VisionEncoderDecoderModel,VitMatteForImageMatting,VitMatteImageProcessor,VitMattePreTrainedModel,VitPoseForPoseEstimation,VitPoseImageProcessor,VitPosePreTrainedModel,VitsModel,VitsModelOutput,VitsPreTrainedModel,VitsTokenizer,VoxtralForConditionalGeneration,VoxtralProcessor,VoxtralRealtimeFeatureExtractor,VoxtralRealtimeForConditionalGeneration,VoxtralRealtimePreTrainedModel,VoxtralRealtimeProcessor,Wav2Vec2BertForCTC,Wav2Vec2BertForSequenceClassification,Wav2Vec2BertModel,Wav2Vec2BertPreTrainedModel,Wav2Vec2CTCTokenizer,Wav2Vec2FeatureExtractor,Wav2Vec2ForAudioFrameClassification,Wav2Vec2ForCTC,Wav2Vec2ForSequenceClassification,Wav2Vec2Model,Wav2Vec2PreTrainedModel,Wav2Vec2Processor,Wav2Vec2ProcessorWithLM,WavLMForAudioFrameClassification,WavLMForCTC,WavLMForSequenceClassification,WavLMForXVector,WavLMModel,WavLMPreTrainedModel,WeSpeakerFeatureExtractor,WeSpeakerResNetModel,WeSpeakerResNetPreTrainedModel,WhisperFeatureExtractor,WhisperForConditionalGeneration,WhisperModel,WhisperPreTrainedModel,WhisperProcessor,WhisperTextStreamer,WhisperTimeStampLogitsProcessor,WhisperTokenizer,XLMForQuestionAnswering,XLMForSequenceClassification,XLMForTokenClassification,XLMModel,XLMPreTrainedModel,XLMRobertaForMaskedLM,XLMRobertaForQuestionAnswering,XLMRobertaForSequenceClassification,XLMRobertaForTokenClassification,XLMRobertaModel,XLMRobertaPreTrainedModel,XLMRobertaTokenizer,XLMTokenizer,XLMWithLMHeadModel,XVectorOutput,YolosFeatureExtractor,YolosForObjectDetection,YolosImageProcessor,YolosModel,YolosObjectDetectionOutput,YolosPreTrainedModel,YoutuForCausalLM,YoutuModel,YoutuPreTrainedModel,ZeroShotAudioClassificationPipeline,ZeroShotClassificationPipeline,ZeroShotImageClassificationPipeline,ZeroShotObjectDetectionPipeline,cat,cos_sim,dot,env,full,full_like,interpolate,interpolate_4d,layer_norm,load_image,load_video,log_softmax,matmul,mean,mean_pooling,ones,ones_like,permute,pipeline,quantize_embeddings,rand,randn,random,read_audio,rfft,slice,softmax,stack,std_mean,topk,zeros,zeros_like});
|