@huggingface/transformers 4.0.0-next.7 → 4.0.0-next.9
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 +13 -2
- package/dist/ort-wasm-simd-threaded.jsep.mjs +26 -26
- package/dist/transformers.js +1002 -587
- package/dist/transformers.min.js +23 -19
- package/dist/transformers.node.cjs +1030 -585
- package/dist/transformers.node.min.cjs +21 -17
- package/dist/transformers.node.min.mjs +21 -17
- package/dist/transformers.node.mjs +1000 -585
- package/dist/transformers.web.js +887 -472
- package/dist/transformers.web.min.js +21 -17
- package/package.json +3 -3
- package/src/configs.js +28 -22
- package/src/env.js +1 -1
- package/src/image_processors_utils.js +25 -15
- 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/eurobert/modeling_eurobert.js +41 -0
- package/src/models/gemma3/image_processing_gemma3.js +3 -0
- package/src/models/gemma3/modeling_gemma3.js +4 -1
- package/src/models/gemma3/processing_gemma3.js +45 -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/image_processors.js +3 -0
- package/src/models/lfm2_vl/image_processing_lfm2_vl.js +1 -1
- package/src/models/lighton_ocr/modeling_lighton_ocr.js +3 -0
- package/src/models/mistral4/modeling_mistral4.js +5 -0
- package/src/models/modeling_utils.js +48 -25
- package/src/models/models.js +10 -1
- package/src/models/nemotron_h/modeling_nemotron_h.js +5 -0
- package/src/models/processors.js +2 -0
- package/src/models/qwen2_vl/modeling_qwen2_vl.js +226 -168
- package/src/models/qwen2_vl/processing_qwen2_vl.js +5 -4
- package/src/models/registry.js +19 -8
- package/src/models/solar_open/modeling_solar_open.js +5 -0
- package/src/pipelines.js +1 -0
- package/src/utils/hub.js +4 -1
- package/src/utils/model_registry/ModelRegistry.js +36 -0
- package/src/utils/model_registry/get_available_dtypes.js +68 -0
- package/src/utils/model_registry/get_file_metadata.js +1 -0
- package/src/utils/model_registry/get_model_files.js +7 -60
- package/src/utils/model_registry/resolve_model_type.js +66 -0
- package/types/configs.d.ts.map +1 -1
- package/types/image_processors_utils.d.ts +3 -2
- 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/eurobert/modeling_eurobert.d.ts +36 -0
- package/types/models/eurobert/modeling_eurobert.d.ts.map +1 -0
- package/types/models/gemma3/image_processing_gemma3.d.ts +4 -0
- package/types/models/gemma3/image_processing_gemma3.d.ts.map +1 -0
- package/types/models/gemma3/modeling_gemma3.d.ts +4 -1
- package/types/models/gemma3/modeling_gemma3.d.ts.map +1 -1
- package/types/models/gemma3/processing_gemma3.d.ts +20 -0
- package/types/models/gemma3/processing_gemma3.d.ts.map +1 -0
- 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/image_processors.d.ts +3 -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/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 +2 -3
- package/types/models/modeling_utils.d.ts.map +1 -1
- package/types/models/models.d.ts +10 -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/processors.d.ts +2 -0
- package/types/models/qwen2_vl/modeling_qwen2_vl.d.ts +41 -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/registry.d.ts.map +1 -1
- 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/pipelines.d.ts +1 -0
- package/types/pipelines.d.ts.map +1 -1
- package/types/utils/hub.d.ts.map +1 -1
- package/types/utils/model_registry/ModelRegistry.d.ts +27 -0
- package/types/utils/model_registry/ModelRegistry.d.ts.map +1 -1
- package/types/utils/model_registry/get_available_dtypes.d.ts +26 -0
- package/types/utils/model_registry/get_available_dtypes.d.ts.map +1 -0
- package/types/utils/model_registry/get_model_files.d.ts +25 -0
- package/types/utils/model_registry/get_model_files.d.ts.map +1 -1
- package/types/utils/model_registry/resolve_model_type.d.ts +24 -0
- package/types/utils/model_registry/resolve_model_type.d.ts.map +1 -0
- package/types/models/ast/modeling_ast.d.ts.map +0 -1
- /package/src/models/{ast/modeling_ast.js → audio_spectrogram_transformer/modeling_audio_spectrogram_transformer.js} +0 -0
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
var $O=Object.create;var Lu=Object.defineProperty;var RO=Object.getOwnPropertyDescriptor;var DO=Object.getOwnPropertyNames;var FO=Object.getPrototypeOf,BO=Object.prototype.hasOwnProperty;var Os=(t,e)=>{for(var r in e)Lu(t,r,{get:e[r],enumerable:!0})},Lk=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of DO(e))!BO.call(t,n)&&n!==r&&Lu(t,n,{get:()=>e[n],enumerable:!(s=RO(e,n))||s.enumerable});return t};var vr=(t,e,r)=>(r=t!=null?$O(FO(t)):{},Lk(e||!t||!t.__esModule?Lu(r,"default",{value:t,enumerable:!0}):r,t)),UO=t=>Lk(Lu({},"__esModule",{value:!0}),t);var aN={};Os(aN,{ASTFeatureExtractor:()=>id,ASTForAudioClassification:()=>r_,ASTModel:()=>t_,ASTPreTrainedModel:()=>_o,AfmoeForCausalLM:()=>Jf,AfmoeModel:()=>Yf,AfmoePreTrainedModel:()=>po,AlbertForMaskedLM:()=>Xf,AlbertForQuestionAnswering:()=>Hf,AlbertForSequenceClassification:()=>Vf,AlbertModel:()=>Wf,AlbertPreTrainedModel:()=>us,AlbertTokenizer:()=>mp,ApertusForCausalLM:()=>Qf,ApertusModel:()=>Kf,ApertusPreTrainedModel:()=>uo,ArceeForCausalLM:()=>e_,ArceeModel:()=>Zf,ArceePreTrainedModel:()=>fo,AudioClassificationPipeline:()=>Pi,AutoConfig:()=>Rt,AutoFeatureExtractor:()=>Ve,AutoImageProcessor:()=>Oe,AutoModel:()=>_r,AutoModelForAudioClassification:()=>_u,AutoModelForAudioFrameClassification:()=>y1,AutoModelForAudioTextToText:()=>A1,AutoModelForCTC:()=>fu,AutoModelForCausalLM:()=>au,AutoModelForDepthEstimation:()=>gu,AutoModelForDocumentQuestionAnswering:()=>mu,AutoModelForImageClassification:()=>uu,AutoModelForImageFeatureExtraction:()=>wu,AutoModelForImageMatting:()=>b1,AutoModelForImageSegmentation:()=>vi,AutoModelForImageTextToText:()=>E1,AutoModelForImageToImage:()=>hu,AutoModelForMaskGeneration:()=>w1,AutoModelForMaskedLM:()=>iu,AutoModelForNormalEstimation:()=>v1,AutoModelForObjectDetection:()=>pu,AutoModelForPoseEstimation:()=>k1,AutoModelForQuestionAnswering:()=>lu,AutoModelForSemanticSegmentation:()=>ki,AutoModelForSeq2SeqLM:()=>En,AutoModelForSequenceClassification:()=>bi,AutoModelForSpeechSeq2Seq:()=>su,AutoModelForTextToSpectrogram:()=>nu,AutoModelForTextToWaveform:()=>ou,AutoModelForTokenClassification:()=>ru,AutoModelForUniversalSegmentation:()=>Ei,AutoModelForVision2Seq:()=>cu,AutoModelForXVector:()=>x1,AutoModelForZeroShotObjectDetection:()=>du,AutoProcessor:()=>Wl,AutoTokenizer:()=>oe,AutomaticSpeechRecognitionPipeline:()=>Ni,BackgroundRemovalPipeline:()=>Fi,BartForConditionalGeneration:()=>n_,BartForSequenceClassification:()=>o_,BartModel:()=>s_,BartPretrainedModel:()=>rn,BartTokenizer:()=>hp,BaseStreamer:()=>Zy,BeitFeatureExtractor:()=>Sd,BeitForImageClassification:()=>i_,BeitModel:()=>a_,BeitPreTrainedModel:()=>mo,BertForMaskedLM:()=>c_,BertForQuestionAnswering:()=>d_,BertForSequenceClassification:()=>u_,BertForTokenClassification:()=>p_,BertModel:()=>l_,BertPreTrainedModel:()=>Tr,BertTokenizer:()=>gp,BitImageProcessor:()=>Td,BlenderbotForConditionalGeneration:()=>__,BlenderbotModel:()=>f_,BlenderbotPreTrainedModel:()=>ho,BlenderbotSmallForConditionalGeneration:()=>h_,BlenderbotSmallModel:()=>m_,BlenderbotSmallPreTrainedModel:()=>go,BlenderbotSmallTokenizer:()=>wp,BlenderbotTokenizer:()=>xp,BloomForCausalLM:()=>w_,BloomModel:()=>g_,BloomPreTrainedModel:()=>wo,BloomTokenizer:()=>yp,CLIPFeatureExtractor:()=>Id,CLIPImageProcessor:()=>Tl,CLIPModel:()=>M_,CLIPPreTrainedModel:()=>nr,CLIPSegForImageSegmentation:()=>C_,CLIPSegModel:()=>I_,CLIPSegPreTrainedModel:()=>ko,CLIPTextModel:()=>S_,CLIPTextModelWithProjection:()=>vo,CLIPTokenizer:()=>vp,CLIPVisionModel:()=>T_,CLIPVisionModelWithProjection:()=>O_,CamembertForMaskedLM:()=>y_,CamembertForQuestionAnswering:()=>k_,CamembertForSequenceClassification:()=>b_,CamembertForTokenClassification:()=>v_,CamembertModel:()=>x_,CamembertPreTrainedModel:()=>Or,CamembertTokenizer:()=>bp,ChatterboxFeatureExtractor:()=>ld,ChatterboxModel:()=>xo,ChatterboxPreTrainedModel:()=>ac,ChatterboxProcessor:()=>bd,ChineseCLIPFeatureExtractor:()=>Od,ChineseCLIPModel:()=>E_,ChineseCLIPPreTrainedModel:()=>ic,ClapAudioModelWithProjection:()=>bo,ClapFeatureExtractor:()=>cd,ClapModel:()=>A_,ClapPreTrainedModel:()=>sn,ClapTextModelWithProjection:()=>yo,ClassifierFreeGuidanceLogitsProcessor:()=>ec,CodeGenForCausalLM:()=>P_,CodeGenModel:()=>L_,CodeGenPreTrainedModel:()=>Eo,CodeGenTokenizer:()=>Ep,CodeLlamaTokenizer:()=>kp,Cohere2ForCausalLM:()=>R_,Cohere2Model:()=>$_,Cohere2PreTrainedModel:()=>Mo,CohereForCausalLM:()=>N_,CohereModel:()=>z_,CoherePreTrainedModel:()=>Ao,CohereTokenizer:()=>Ap,ConvBertForMaskedLM:()=>F_,ConvBertForQuestionAnswering:()=>j_,ConvBertForSequenceClassification:()=>B_,ConvBertForTokenClassification:()=>U_,ConvBertModel:()=>D_,ConvBertPreTrainedModel:()=>Ir,ConvBertTokenizer:()=>Mp,ConvNextFeatureExtractor:()=>Cd,ConvNextForImageClassification:()=>q_,ConvNextImageProcessor:()=>Ol,ConvNextModel:()=>G_,ConvNextPreTrainedModel:()=>So,ConvNextV2ForImageClassification:()=>V_,ConvNextV2Model:()=>W_,ConvNextV2PreTrainedModel:()=>To,DFineForObjectDetection:()=>Q_,DFineModel:()=>K_,DFinePreTrainedModel:()=>Io,DINOv3ConvNextModel:()=>ym,DINOv3ConvNextPreTrainedModel:()=>_c,DINOv3ViTImageProcessor:()=>zd,DINOv3ViTModel:()=>bm,DINOv3ViTPreTrainedModel:()=>mc,DPTFeatureExtractor:()=>$d,DPTForDepthEstimation:()=>Om,DPTImageProcessor:()=>Ll,DPTModel:()=>Tm,DPTPreTrainedModel:()=>$o,DacDecoderModel:()=>Lo,DacDecoderOutput:()=>cc,DacEncoderModel:()=>Co,DacEncoderOutput:()=>lc,DacFeatureExtractor:()=>Xn,DacModel:()=>Y_,DacPreTrainedModel:()=>nn,DebertaForMaskedLM:()=>Z_,DebertaForQuestionAnswering:()=>rm,DebertaForSequenceClassification:()=>em,DebertaForTokenClassification:()=>tm,DebertaModel:()=>J_,DebertaPreTrainedModel:()=>Cr,DebertaTokenizer:()=>Tp,DebertaV2ForMaskedLM:()=>nm,DebertaV2ForQuestionAnswering:()=>im,DebertaV2ForSequenceClassification:()=>om,DebertaV2ForTokenClassification:()=>am,DebertaV2Model:()=>sm,DebertaV2PreTrainedModel:()=>Lr,DebertaV2Tokenizer:()=>Sp,DecisionTransformerModel:()=>lm,DecisionTransformerPreTrainedModel:()=>uc,DeiTFeatureExtractor:()=>Ld,DeiTForImageClassification:()=>um,DeiTImageProcessor:()=>Il,DeiTModel:()=>cm,DeiTPreTrainedModel:()=>Po,DepthAnythingForDepthEstimation:()=>pm,DepthAnythingPreTrainedModel:()=>pc,DepthEstimationPipeline:()=>Wi,DepthProForDepthEstimation:()=>dm,DepthProPreTrainedModel:()=>dc,DetrFeatureExtractor:()=>Pd,DetrForObjectDetection:()=>_m,DetrForSegmentation:()=>mm,DetrImageProcessor:()=>Cl,DetrModel:()=>fm,DetrObjectDetectionOutput:()=>an,DetrPreTrainedModel:()=>on,DetrSegmentationOutput:()=>fc,Dinov2ForImageClassification:()=>gm,Dinov2Model:()=>hm,Dinov2PreTrainedModel:()=>zo,Dinov2WithRegistersForImageClassification:()=>xm,Dinov2WithRegistersModel:()=>wm,Dinov2WithRegistersPreTrainedModel:()=>No,DistilBertForMaskedLM:()=>Mm,DistilBertForQuestionAnswering:()=>Am,DistilBertForSequenceClassification:()=>km,DistilBertForTokenClassification:()=>Em,DistilBertModel:()=>vm,DistilBertPreTrainedModel:()=>Pr,DistilBertTokenizer:()=>Op,DocumentQuestionAnsweringPipeline:()=>Gi,DonutFeatureExtractor:()=>Nd,DonutImageProcessor:()=>Vs,DonutSwinModel:()=>Sm,DonutSwinPreTrainedModel:()=>hc,DynamicCache:()=>ao,EdgeTamModel:()=>kx,EfficientNetForImageClassification:()=>Cm,EfficientNetImageProcessor:()=>Rd,EfficientNetModel:()=>Im,EfficientNetPreTrainedModel:()=>Ro,ElectraForMaskedLM:()=>Pm,ElectraForQuestionAnswering:()=>$m,ElectraForSequenceClassification:()=>zm,ElectraForTokenClassification:()=>Nm,ElectraModel:()=>Lm,ElectraPreTrainedModel:()=>zr,ElectraTokenizer:()=>Ip,EncodecFeatureExtractor:()=>Hn,EosTokenCriteria:()=>sc,Ernie4_5ForCausalLM:()=>Dm,Ernie4_5Model:()=>Rm,Ernie4_5PretrainedModel:()=>Do,EsmForMaskedLM:()=>Bm,EsmForSequenceClassification:()=>Um,EsmForTokenClassification:()=>jm,EsmModel:()=>Fm,EsmPreTrainedModel:()=>ps,EsmTokenizer:()=>Cp,ExaoneForCausalLM:()=>qm,ExaoneModel:()=>Gm,ExaonePreTrainedModel:()=>Fo,FalconForCausalLM:()=>Vm,FalconH1ForCausalLM:()=>Xm,FalconH1Model:()=>Hm,FalconH1PreTrainedModel:()=>Uo,FalconModel:()=>Wm,FalconPreTrainedModel:()=>Bo,FalconTokenizer:()=>Lp,FastViTForImageClassification:()=>Qm,FastViTModel:()=>Km,FastViTPreTrainedModel:()=>jo,FeatureExtractionPipeline:()=>Vi,FeatureExtractor:()=>Ae,FillMaskPipeline:()=>Ti,Florence2ForConditionalGeneration:()=>Ym,Florence2PreTrainedModel:()=>gc,Florence2Processor:()=>_f,ForcedBOSTokenLogitsProcessor:()=>Vl,ForcedEOSTokenLogitsProcessor:()=>Hl,GLPNFeatureExtractor:()=>Dd,GLPNForDepthEstimation:()=>ih,GLPNModel:()=>ah,GLPNPreTrainedModel:()=>Xo,GPT2LMHeadModel:()=>gh,GPT2Model:()=>hh,GPT2PreTrainedModel:()=>Zo,GPT2Tokenizer:()=>Np,GPTBigCodeForCausalLM:()=>ch,GPTBigCodeModel:()=>lh,GPTBigCodePreTrainedModel:()=>Ko,GPTJForCausalLM:()=>xh,GPTJModel:()=>wh,GPTJPreTrainedModel:()=>ea,GPTNeoForCausalLM:()=>ph,GPTNeoModel:()=>uh,GPTNeoPreTrainedModel:()=>Qo,GPTNeoXForCausalLM:()=>fh,GPTNeoXModel:()=>dh,GPTNeoXPreTrainedModel:()=>Yo,GPTNeoXTokenizer:()=>zp,Gemma2ForCausalLM:()=>th,Gemma2Model:()=>eh,Gemma2PreTrainedModel:()=>qo,Gemma3ForCausalLM:()=>sh,Gemma3Model:()=>rh,Gemma3PreTrainedModel:()=>Wo,Gemma3nAudioFeatureExtractor:()=>ud,Gemma3nForCausalLM:()=>Vo,Gemma3nForConditionalGeneration:()=>ln,Gemma3nPreTrainedModel:()=>wc,Gemma3nProcessor:()=>mf,GemmaForCausalLM:()=>Zm,GemmaModel:()=>Jm,GemmaPreTrainedModel:()=>Go,GemmaTokenizer:()=>Pp,GlmForCausalLM:()=>oh,GlmModel:()=>nh,GlmPreTrainedModel:()=>Ho,GptOssForCausalLM:()=>mh,GptOssModel:()=>_h,GptOssPreTrainedModel:()=>Jo,GraniteForCausalLM:()=>bh,GraniteModel:()=>yh,GraniteMoeHybridForCausalLM:()=>kh,GraniteMoeHybridModel:()=>vh,GraniteMoeHybridPreTrainedModel:()=>ra,GranitePreTrainedModel:()=>ta,GraniteSpeechFeatureExtractor:()=>pd,GraniteSpeechForConditionalGeneration:()=>Eh,GraniteSpeechProcessor:()=>hf,GroundingDinoForObjectDetection:()=>Ah,GroundingDinoImageProcessor:()=>Fd,GroundingDinoPreTrainedModel:()=>yc,GroundingDinoProcessor:()=>gf,GroupViTModel:()=>Mh,GroupViTPreTrainedModel:()=>bc,HeliumForCausalLM:()=>Th,HeliumModel:()=>Sh,HeliumPreTrainedModel:()=>sa,HerbertTokenizer:()=>$p,HieraForImageClassification:()=>Ih,HieraModel:()=>Oh,HieraPreTrainedModel:()=>na,HubertForCTC:()=>Rh,HubertForSequenceClassification:()=>Dh,HubertModel:()=>$h,HubertPreTrainedModel:()=>Nh,HunYuanDenseV1ForCausalLM:()=>Bh,HunYuanDenseV1Model:()=>Fh,HunYuanDenseV1PreTrainedModel:()=>oa,IJepaForImageClassification:()=>Wh,IJepaModel:()=>qh,IJepaPreTrainedModel:()=>aa,Idefics3ForConditionalGeneration:()=>Gh,Idefics3ImageProcessor:()=>Pl,Idefics3Processor:()=>Gl,ImageClassificationPipeline:()=>Di,ImageFeatureExtractionPipeline:()=>Hi,ImageFeatureExtractor:()=>X,ImageProcessor:()=>X,ImageSegmentationPipeline:()=>Es,ImageToImagePipeline:()=>qi,ImageToTextPipeline:()=>Ri,InterruptableStoppingCriteria:()=>i1,JAISLMHeadModel:()=>Hh,JAISModel:()=>Vh,JAISPreTrainedModel:()=>ia,JinaCLIPImageProcessor:()=>Ud,JinaCLIPModel:()=>Xh,JinaCLIPPreTrainedModel:()=>cn,JinaCLIPProcessor:()=>xf,JinaCLIPTextModel:()=>la,JinaCLIPVisionModel:()=>Kh,Lfm2ForCausalLM:()=>Yh,Lfm2Model:()=>Qh,Lfm2MoeForCausalLM:()=>Zh,Lfm2MoeModel:()=>Jh,Lfm2MoePreTrainedModel:()=>ua,Lfm2PreTrainedModel:()=>ca,Lfm2VlForConditionalGeneration:()=>eg,Lfm2VlImageProcessor:()=>jd,Lfm2VlProcessor:()=>yf,LiteWhisperForConditionalGeneration:()=>Ny,Llama4ForCausalLM:()=>sg,Llama4PreTrainedModel:()=>kc,LlamaForCausalLM:()=>rg,LlamaModel:()=>tg,LlamaPreTrainedModel:()=>pa,LlamaTokenizer:()=>Rp,LlavaForConditionalGeneration:()=>Ft,LlavaOnevisionForConditionalGeneration:()=>Ft,LlavaOnevisionImageProcessor:()=>Gd,LlavaPreTrainedModel:()=>vc,LlavaProcessor:()=>bf,LlavaQwen2ForCausalLM:()=>jh,LogLevel:()=>St,LogitsProcessor:()=>Dt,LogitsProcessorList:()=>cs,LogitsWarper:()=>no,LongT5ForConditionalGeneration:()=>og,LongT5Model:()=>ng,LongT5PreTrainedModel:()=>da,M2M100ForConditionalGeneration:()=>ig,M2M100Model:()=>ag,M2M100PreTrainedModel:()=>fa,M2M100Tokenizer:()=>Dp,MBart50Tokenizer:()=>Bp,MBartForCausalLM:()=>mg,MBartForConditionalGeneration:()=>fg,MBartForSequenceClassification:()=>_g,MBartModel:()=>dg,MBartPreTrainedModel:()=>fs,MBartTokenizer:()=>Wn,MPNetForMaskedLM:()=>Zg,MPNetForQuestionAnswering:()=>rw,MPNetForSequenceClassification:()=>ew,MPNetForTokenClassification:()=>tw,MPNetModel:()=>Jg,MPNetPreTrainedModel:()=>Nr,MPNetTokenizer:()=>Gp,MT5ForConditionalGeneration:()=>aw,MT5Model:()=>ow,MT5PreTrainedModel:()=>Aa,MarianMTModel:()=>cg,MarianModel:()=>lg,MarianPreTrainedModel:()=>_a,MarianTokenizer:()=>Fp,Mask2FormerImageProcessor:()=>Wd,MaskFormerFeatureExtractor:()=>qd,MaskFormerForInstanceSegmentation:()=>pg,MaskFormerImageProcessor:()=>Hs,MaskFormerModel:()=>ug,MaskFormerPreTrainedModel:()=>ma,MaxLengthCriteria:()=>rc,Metric3DForDepthEstimation:()=>hg,Metric3DPreTrainedModel:()=>Ec,Metric3Dv2ForDepthEstimation:()=>gg,Metric3Dv2PreTrainedModel:()=>Ac,MgpstrForSceneTextRecognition:()=>wg,MgpstrModelOutput:()=>Mc,MgpstrPreTrainedModel:()=>Sc,MgpstrProcessor:()=>vf,MgpstrTokenizer:()=>Up,MimiDecoderModel:()=>ga,MimiDecoderOutput:()=>Oc,MimiEncoderModel:()=>ha,MimiEncoderOutput:()=>Tc,MimiModel:()=>xg,MimiPreTrainedModel:()=>un,MinLengthLogitsProcessor:()=>Yl,MinNewTokensLengthLogitsProcessor:()=>Jl,MistralForCausalLM:()=>bg,MistralModel:()=>yg,MistralPreTrainedModel:()=>wa,MobileBertForMaskedLM:()=>kg,MobileBertForQuestionAnswering:()=>Ag,MobileBertForSequenceClassification:()=>Eg,MobileBertModel:()=>vg,MobileBertPreTrainedModel:()=>_s,MobileBertTokenizer:()=>jp,MobileLLMForCausalLM:()=>Sg,MobileLLMModel:()=>Mg,MobileLLMPreTrainedModel:()=>xa,MobileNetV1FeatureExtractor:()=>Vd,MobileNetV1ForImageClassification:()=>Og,MobileNetV1ForSemanticSegmentation:()=>Ig,MobileNetV1ImageProcessor:()=>zl,MobileNetV1Model:()=>Tg,MobileNetV1PreTrainedModel:()=>pn,MobileNetV2FeatureExtractor:()=>Hd,MobileNetV2ForImageClassification:()=>Lg,MobileNetV2ForSemanticSegmentation:()=>Pg,MobileNetV2ImageProcessor:()=>Nl,MobileNetV2Model:()=>Cg,MobileNetV2PreTrainedModel:()=>dn,MobileNetV3FeatureExtractor:()=>Xd,MobileNetV3ForImageClassification:()=>Ng,MobileNetV3ForSemanticSegmentation:()=>$g,MobileNetV3ImageProcessor:()=>$l,MobileNetV3Model:()=>zg,MobileNetV3PreTrainedModel:()=>fn,MobileNetV4FeatureExtractor:()=>Kd,MobileNetV4ForImageClassification:()=>Dg,MobileNetV4ForSemanticSegmentation:()=>Fg,MobileNetV4ImageProcessor:()=>Rl,MobileNetV4Model:()=>Rg,MobileNetV4PreTrainedModel:()=>_n,MobileViTFeatureExtractor:()=>Qd,MobileViTForImageClassification:()=>Ug,MobileViTImageProcessor:()=>Dl,MobileViTModel:()=>Bg,MobileViTPreTrainedModel:()=>ya,MobileViTV2ForImageClassification:()=>Gg,MobileViTV2Model:()=>jg,MobileViTV2PreTrainedModel:()=>ba,ModelRegistry:()=>r0,ModernBertDecoderForCausalLM:()=>Kg,ModernBertDecoderModel:()=>Xg,ModernBertDecoderPreTrainedModel:()=>va,ModernBertForMaskedLM:()=>Wg,ModernBertForSequenceClassification:()=>Vg,ModernBertForTokenClassification:()=>Hg,ModernBertModel:()=>qg,ModernBertPreTrainedModel:()=>ms,Moondream1ForConditionalGeneration:()=>Uh,MoonshineFeatureExtractor:()=>dd,MoonshineForConditionalGeneration:()=>Yg,MoonshineModel:()=>Qg,MoonshinePreTrainedModel:()=>ka,MoonshineProcessor:()=>kf,MptForCausalLM:()=>nw,MptModel:()=>sw,MptPreTrainedModel:()=>Ea,MultiModalityCausalLM:()=>iw,MultiModalityPreTrainedModel:()=>Ic,MusicgenForCausalLM:()=>cw,MusicgenForConditionalGeneration:()=>Sa,MusicgenModel:()=>lw,MusicgenPreTrainedModel:()=>Ma,NanoChatForCausalLM:()=>pw,NanoChatModel:()=>uw,NanoChatPreTrainedModel:()=>Ta,NeoBertForMaskedLM:()=>fw,NeoBertForQuestionAnswering:()=>hw,NeoBertForSequenceClassification:()=>_w,NeoBertForTokenClassification:()=>mw,NeoBertModel:()=>dw,NeoBertPreTrainedModel:()=>$r,NllbTokenizer:()=>qp,NoBadWordsLogitsProcessor:()=>Zl,NoRepeatNGramLogitsProcessor:()=>Kl,NomicBertModel:()=>gw,NomicBertPreTrainedModel:()=>Cc,NougatImageProcessor:()=>Yd,NougatTokenizer:()=>Wp,OPTForCausalLM:()=>Ow,OPTModel:()=>Tw,OPTPreTrainedModel:()=>za,ObjectDetectionPipeline:()=>Ui,Olmo2ForCausalLM:()=>bw,Olmo2Model:()=>yw,Olmo2PreTrainedModel:()=>Ia,Olmo3ForCausalLM:()=>kw,Olmo3Model:()=>vw,Olmo3PreTrainedModel:()=>Ca,OlmoForCausalLM:()=>xw,OlmoHybridForCausalLM:()=>Aw,OlmoHybridModel:()=>Ew,OlmoHybridPreTrainedModel:()=>La,OlmoModel:()=>ww,OlmoPreTrainedModel:()=>Oa,OpenELMForCausalLM:()=>Sw,OpenELMModel:()=>Mw,OpenELMPreTrainedModel:()=>Pa,OwlViTFeatureExtractor:()=>Jd,OwlViTForObjectDetection:()=>Pw,OwlViTImageProcessor:()=>Xs,OwlViTModel:()=>Lw,OwlViTPreTrainedModel:()=>$a,OwlViTProcessor:()=>Ef,Owlv2ForObjectDetection:()=>Cw,Owlv2ImageProcessor:()=>Zd,Owlv2Model:()=>Iw,Owlv2PreTrainedModel:()=>Na,PaliGemmaForConditionalGeneration:()=>zw,PaliGemmaProcessor:()=>Af,ParakeetFeatureExtractor:()=>fd,ParakeetForCTC:()=>Nw,ParakeetPreTrainedModel:()=>Lc,PatchTSMixerForPrediction:()=>Rw,PatchTSMixerModel:()=>$w,PatchTSMixerPreTrainedModel:()=>Ra,PatchTSTForPrediction:()=>Fw,PatchTSTModel:()=>Dw,PatchTSTPreTrainedModel:()=>Da,Phi3ForCausalLM:()=>Gw,Phi3Model:()=>jw,Phi3PreTrainedModel:()=>Ba,Phi3VForCausalLM:()=>Ua,Phi3VImageProcessor:()=>ef,Phi3VPreTrainedModel:()=>Pc,Phi3VProcessor:()=>Mf,PhiForCausalLM:()=>Uw,PhiModel:()=>Bw,PhiPreTrainedModel:()=>Fa,PixtralImageProcessor:()=>tf,PixtralProcessor:()=>Sf,PreTrainedModel:()=>y,PreTrainedTokenizer:()=>W,PretrainedConfig:()=>Ks,Processor:()=>re,PvtForImageClassification:()=>Ww,PvtImageProcessor:()=>rf,PvtModel:()=>qw,PvtPreTrainedModel:()=>ja,PyAnnoteFeatureExtractor:()=>Kn,PyAnnoteForAudioFrameClassification:()=>Hw,PyAnnoteModel:()=>Vw,PyAnnotePreTrainedModel:()=>Ga,PyAnnoteProcessor:()=>Tf,QuestionAnsweringPipeline:()=>Si,Qwen2ForCausalLM:()=>Kw,Qwen2Model:()=>Xw,Qwen2MoeForCausalLM:()=>Yw,Qwen2MoeModel:()=>Qw,Qwen2MoePreTrainedModel:()=>Wa,Qwen2PreTrainedModel:()=>qa,Qwen2Tokenizer:()=>Vp,Qwen2VLForCausalLM:()=>hs,Qwen2VLForConditionalGeneration:()=>mn,Qwen2VLImageProcessor:()=>sf,Qwen2VLPreTrainedModel:()=>zc,Qwen2VLProcessor:()=>eo,Qwen2_5_VLForCausalLM:()=>gs,Qwen2_5_VLForConditionalGeneration:()=>Va,Qwen2_5_VLProcessor:()=>to,Qwen3ForCausalLM:()=>Zw,Qwen3Model:()=>Jw,Qwen3MoeForCausalLM:()=>tx,Qwen3MoeModel:()=>ex,Qwen3MoePreTrainedModel:()=>Xa,Qwen3NextForCausalLM:()=>sx,Qwen3NextModel:()=>rx,Qwen3NextPreTrainedModel:()=>Ka,Qwen3PreTrainedModel:()=>Ha,Qwen3VLForCausalLM:()=>xs,Qwen3VLForConditionalGeneration:()=>ws,Qwen3VLMoeForCausalLM:()=>Qa,Qwen3VLMoeForConditionalGeneration:()=>nx,Qwen3VLProcessor:()=>Of,Qwen3_5ForCausalLM:()=>ys,Qwen3_5ForConditionalGeneration:()=>hn,Qwen3_5MoeForCausalLM:()=>Ya,Qwen3_5MoeForConditionalGeneration:()=>ox,RFDetrForObjectDetection:()=>cx,RFDetrModel:()=>lx,RFDetrObjectDetectionOutput:()=>Nc,RFDetrPreTrainedModel:()=>Za,RTDetrForObjectDetection:()=>X_,RTDetrImageProcessor:()=>nf,RTDetrModel:()=>H_,RTDetrObjectDetectionOutput:()=>or,RTDetrPreTrainedModel:()=>Oo,RTDetrV2ForObjectDetection:()=>bx,RTDetrV2Model:()=>yx,RTDetrV2ObjectDetectionOutput:()=>$c,RTDetrV2PreTrainedModel:()=>ei,RawAudio:()=>Vn,RawImage:()=>Qe,RawVideo:()=>yu,RawVideoFrame:()=>Ki,RepetitionPenaltyLogitsProcessor:()=>Ql,ResNetForImageClassification:()=>ix,ResNetModel:()=>ax,ResNetPreTrainedModel:()=>Ja,RoFormerForMaskedLM:()=>hx,RoFormerForQuestionAnswering:()=>xx,RoFormerForSequenceClassification:()=>gx,RoFormerForTokenClassification:()=>wx,RoFormerModel:()=>mx,RoFormerPreTrainedModel:()=>Dr,RoFormerTokenizer:()=>Xp,RobertaForMaskedLM:()=>px,RobertaForQuestionAnswering:()=>_x,RobertaForSequenceClassification:()=>dx,RobertaForTokenClassification:()=>fx,RobertaModel:()=>ux,RobertaPreTrainedModel:()=>Rr,RobertaTokenizer:()=>Hp,Sam2ImageProcessor:()=>Yn,Sam2ImageSegmentationOutput:()=>Fc,Sam2Model:()=>ti,Sam2PreTrainedModel:()=>Bc,Sam2Processor:()=>ql,Sam2VideoProcessor:()=>If,Sam3ImageProcessor:()=>Yn,Sam3TrackerModel:()=>Ex,SamImageProcessor:()=>Yn,SamImageSegmentationOutput:()=>Rc,SamModel:()=>vx,SamPreTrainedModel:()=>Dc,SamProcessor:()=>ro,SapiensFeatureExtractor:()=>of,SapiensForDepthEstimation:()=>Mx,SapiensForNormalEstimation:()=>Sx,SapiensForSemanticSegmentation:()=>Ax,SapiensImageProcessor:()=>Fl,SapiensPreTrainedModel:()=>gn,SeamlessM4TFeatureExtractor:()=>_d,SegformerFeatureExtractor:()=>af,SegformerForImageClassification:()=>Ox,SegformerForSemanticSegmentation:()=>Ix,SegformerImageProcessor:()=>Bl,SegformerModel:()=>Tx,SegformerPreTrainedModel:()=>wn,SiglipImageProcessor:()=>lf,SiglipModel:()=>Cx,SiglipPreTrainedModel:()=>ri,SiglipTextModel:()=>si,SiglipTokenizer:()=>Kp,SiglipVisionModel:()=>Lx,SmolLM3ForCausalLM:()=>zx,SmolLM3Model:()=>Px,SmolLM3PreTrainedModel:()=>ni,SmolVLMImageProcessor:()=>Pl,SmolVLMProcessor:()=>Gl,SnacDecoderModel:()=>ai,SnacEncoderModel:()=>oi,SnacFeatureExtractor:()=>md,SnacModel:()=>Nx,SnacPreTrainedModel:()=>xn,SpeechT5FeatureExtractor:()=>hd,SpeechT5ForSpeechToText:()=>Rx,SpeechT5ForTextToSpeech:()=>Dx,SpeechT5HifiGan:()=>Fx,SpeechT5Model:()=>$x,SpeechT5PreTrainedModel:()=>yn,SpeechT5Processor:()=>Cf,SpeechT5Tokenizer:()=>Qp,SqueezeBertForMaskedLM:()=>Ux,SqueezeBertForQuestionAnswering:()=>Gx,SqueezeBertForSequenceClassification:()=>jx,SqueezeBertModel:()=>Bx,SqueezeBertPreTrainedModel:()=>bs,SqueezeBertTokenizer:()=>Yp,StableLmForCausalLM:()=>Wx,StableLmModel:()=>qx,StableLmPreTrainedModel:()=>ii,Starcoder2ForCausalLM:()=>Hx,Starcoder2Model:()=>Vx,Starcoder2PreTrainedModel:()=>li,StoppingCriteria:()=>Sr,StoppingCriteriaList:()=>Js,StyleTextToSpeech2Model:()=>Xx,StyleTextToSpeech2PreTrainedModel:()=>Uc,SummarizationPipeline:()=>Oi,SupertonicForConditionalGeneration:()=>ci,SupertonicPreTrainedModel:()=>jc,SuppressTokensAtBeginLogitsProcessor:()=>Ys,Swin2SRForImageSuperResolution:()=>Zx,Swin2SRImageProcessor:()=>cf,Swin2SRModel:()=>Jx,Swin2SRPreTrainedModel:()=>ui,SwinForImageClassification:()=>Qx,SwinForSemanticSegmentation:()=>Yx,SwinModel:()=>Kx,SwinPreTrainedModel:()=>bn,T5ForConditionalGeneration:()=>ty,T5Model:()=>ey,T5PreTrainedModel:()=>pi,T5Tokenizer:()=>Jp,TableTransformerForObjectDetection:()=>sy,TableTransformerModel:()=>ry,TableTransformerObjectDetectionOutput:()=>Gc,TableTransformerPreTrainedModel:()=>di,TemperatureLogitsWarper:()=>tc,Tensor:()=>$,Text2TextGenerationPipeline:()=>mr,TextClassificationPipeline:()=>Ai,TextGenerationPipeline:()=>Ci,TextStreamer:()=>e0,TextToAudioPipeline:()=>$i,TokenClassificationPipeline:()=>Mi,TokenizersBackend:()=>W,TopKLogitsWarper:()=>a1,TopPLogitsWarper:()=>o1,TrOCRForCausalLM:()=>ny,TrOCRPreTrainedModel:()=>qc,TranslationPipeline:()=>Ii,UltravoxModel:()=>ds,UltravoxPreTrainedModel:()=>xc,UltravoxProcessor:()=>Lf,UniSpeechForCTC:()=>ay,UniSpeechForSequenceClassification:()=>iy,UniSpeechModel:()=>oy,UniSpeechPreTrainedModel:()=>vn,UniSpeechSatForAudioFrameClassification:()=>py,UniSpeechSatForCTC:()=>cy,UniSpeechSatForSequenceClassification:()=>uy,UniSpeechSatModel:()=>ly,UniSpeechSatPreTrainedModel:()=>vs,VLChatProcessor:()=>wf,VLMImageProcessor:()=>Bd,VaultGemmaForCausalLM:()=>fy,VaultGemmaModel:()=>dy,VaultGemmaPreTrainedModel:()=>fi,ViTFeatureExtractor:()=>uf,ViTForImageClassification:()=>hy,ViTImageProcessor:()=>Ul,ViTMAEModel:()=>gy,ViTMAEPreTrainedModel:()=>Wc,ViTMSNForImageClassification:()=>xy,ViTMSNModel:()=>wy,ViTMSNPreTrainedModel:()=>mi,ViTModel:()=>my,ViTPreTrainedModel:()=>_i,VisionEncoderDecoderModel:()=>_y,VitMatteForImageMatting:()=>yy,VitMatteImageProcessor:()=>pf,VitMattePreTrainedModel:()=>Vc,VitPoseForPoseEstimation:()=>by,VitPoseImageProcessor:()=>df,VitPosePreTrainedModel:()=>Hc,VitsModel:()=>vy,VitsModelOutput:()=>Xc,VitsPreTrainedModel:()=>Kc,VitsTokenizer:()=>Zp,VoxtralForConditionalGeneration:()=>ky,VoxtralProcessor:()=>zf,VoxtralRealtimeFeatureExtractor:()=>xd,VoxtralRealtimeForConditionalGeneration:()=>hi,VoxtralRealtimePreTrainedModel:()=>Qc,VoxtralRealtimeProcessor:()=>$f,Wav2Vec2BertForCTC:()=>Ay,Wav2Vec2BertForSequenceClassification:()=>My,Wav2Vec2BertModel:()=>Ey,Wav2Vec2BertPreTrainedModel:()=>kn,Wav2Vec2CTCTokenizer:()=>ed,Wav2Vec2FeatureExtractor:()=>gd,Wav2Vec2ForAudioFrameClassification:()=>zh,Wav2Vec2ForCTC:()=>Lh,Wav2Vec2ForSequenceClassification:()=>Ph,Wav2Vec2Model:()=>Ch,Wav2Vec2PreTrainedModel:()=>Ht,Wav2Vec2Processor:()=>Rf,Wav2Vec2ProcessorWithLM:()=>Df,WavLMForAudioFrameClassification:()=>Cy,WavLMForCTC:()=>Ty,WavLMForSequenceClassification:()=>Oy,WavLMForXVector:()=>Iy,WavLMModel:()=>Sy,WavLMPreTrainedModel:()=>Fr,WeSpeakerFeatureExtractor:()=>wd,WeSpeakerResNetModel:()=>Ly,WeSpeakerResNetPreTrainedModel:()=>Jc,WhisperFeatureExtractor:()=>yd,WhisperForConditionalGeneration:()=>Zc,WhisperModel:()=>zy,WhisperPreTrainedModel:()=>gi,WhisperProcessor:()=>Ff,WhisperTextStreamer:()=>M1,WhisperTimeStampLogitsProcessor:()=>Xl,WhisperTokenizer:()=>td,XLMForQuestionAnswering:()=>By,XLMForSequenceClassification:()=>Dy,XLMForTokenClassification:()=>Fy,XLMModel:()=>$y,XLMPreTrainedModel:()=>Br,XLMRobertaForMaskedLM:()=>jy,XLMRobertaForQuestionAnswering:()=>Wy,XLMRobertaForSequenceClassification:()=>Gy,XLMRobertaForTokenClassification:()=>qy,XLMRobertaModel:()=>Uy,XLMRobertaPreTrainedModel:()=>Ur,XLMRobertaTokenizer:()=>rd,XLMTokenizer:()=>sd,XLMWithLMHeadModel:()=>Ry,XVectorOutput:()=>Yc,YolosFeatureExtractor:()=>ff,YolosForObjectDetection:()=>Hy,YolosImageProcessor:()=>jl,YolosModel:()=>Vy,YolosObjectDetectionOutput:()=>eu,YolosPreTrainedModel:()=>wi,YoutuForCausalLM:()=>Ky,YoutuModel:()=>Xy,YoutuPreTrainedModel:()=>xi,ZeroShotAudioClassificationPipeline:()=>zi,ZeroShotClassificationPipeline:()=>Li,ZeroShotImageClassificationPipeline:()=>Bi,ZeroShotObjectDetectionPipeline:()=>ji,cat:()=>ve,cos_sim:()=>CE,dot:()=>H0,env:()=>fe,full:()=>We,full_like:()=>jn,interpolate:()=>pp,interpolate_4d:()=>bt,layer_norm:()=>QP,load_image:()=>C2,load_video:()=>SM,log_softmax:()=>Vu,matmul:()=>jb,mean:()=>kl,mean_pooling:()=>Gb,ones:()=>et,ones_like:()=>El,permute:()=>g2,pipeline:()=>nN,quantize_embeddings:()=>Vb,rand:()=>YP,randn:()=>Wb,random:()=>Xr,read_audio:()=>ad,rfft:()=>KP,slice:()=>vl,softmax:()=>Le,stack:()=>Tt,std_mean:()=>dp,topk:()=>Wt,zeros:()=>fp,zeros_like:()=>_p});module.exports=UO(aN);var Nk=vr(require("fs"),1),Is=vr(require("path"),1),$k=vr(require("url"),1),tI={},jO="4.0.0-next.7",I0=typeof self<"u",In=!Bk(Nk.default),Rk=!Bk(Is.default),Pu=I0&&"caches"in self,GO=typeof globalThis.Deno<"u",lN=typeof globalThis.Bun<"u",Nu=GO&&Pu&&!In,Dk=typeof process<"u",Fk=Dk&&process?.release?.name==="node"&&!Nu,C0=typeof window<"u"&&typeof window.document<"u",L0=I0&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),qO=C0||L0||Nu,WO=Fk||typeof navigator<"u"&&"gpu"in navigator,VO=typeof navigator<"u"&&"ml"in navigator,HO=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",XO=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",KO=typeof ServiceWorkerGlobalScope<"u"&&I0&&self instanceof ServiceWorkerGlobalScope,QO=()=>{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},YO=QO(),ie=Object.freeze({IS_BROWSER_ENV:C0,IS_WEBWORKER_ENV:L0,IS_WEB_ENV:qO,IS_SERVICE_WORKER_ENV:KO,IS_DENO_WEB_RUNTIME:Nu,IS_WEB_CACHE_AVAILABLE:Pu,IS_WEBGPU_AVAILABLE:WO,IS_WEBNN_AVAILABLE:VO,IS_SAFARI:YO,IS_PROCESS_AVAILABLE:Dk,IS_NODE_ENV:Fk,IS_FS_AVAILABLE:In,IS_PATH_AVAILABLE:Rk,IS_CRYPTO_AVAILABLE:HO,IS_CHROME_AVAILABLE:XO}),P0=In&&Rk,zu="./";if(P0){let t=Object(tI).url;t?zu=Is.default.dirname(Is.default.dirname($k.default.fileURLToPath(t))):typeof __dirname<"u"&&(zu=Is.default.dirname(__dirname))}var JO=P0?Is.default.join(zu,"/.cache/"):null,Pk="/models/",ZO=P0?Is.default.join(zu,Pk):Pk,eI=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,St=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),zk=St.WARNING,fe={version:jO,backends:{onnx:{}},get logLevel(){return zk},set logLevel(t){zk=t,fe.backends.onnx?.setLogLevel?.(t)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(C0||L0||Nu),localModelPath:ZO,useFS:In,useBrowserCache:Pu,useFSCache:In,cacheDir:JO,useCustomCache:!1,customCache:null,useWasmCache:Pu||In,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:eI};function Bk(t){return Object.keys(t).length===0}function kr(t,e){t&&t(e)}function Uk(t){return Number.isInteger(t)||typeof t=="bigint"}function z0(t){return t==null||t===-1}function N0(t){let e=[],r=t;for(;Array.isArray(r);)e.push(r.length),r=r[0];return e}function wt(...t){return Array.prototype.concat.apply([],t)}function jk(...t){return t.reduce((e,r)=>e.flatMap(s=>r.map(n=>[s,n])))}function Cn(t,e){return Math.abs((t+e)%(2*e)-e)}function Ye(t,e){return Object.assign({},...e.map(r=>{if(t[r]!==void 0)return{[r]:t[r]}}))}function Gk(t,e){let r=0;for(let s of t)s===e&&++r;return r}var Z={error(...t){fe.logLevel<=St.ERROR&&console.error(...t)},warn(...t){fe.logLevel<=St.WARNING&&console.warn(...t)},info(...t){fe.logLevel<=St.INFO&&console.log(...t)},debug(...t){fe.logLevel<=St.DEBUG&&console.log(...t)},log(...t){this.info(...t)}};var rI=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}},qk=rI,sI=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}},nI=sI,Yk=(()=>{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]]))})(),oI=t=>Object.fromEntries(Object.entries(t).map(([e,r])=>[r,e])),aI=oI(Yk),Wk=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",iI=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|[${Wk}])]+`,` ?[^\\s${Wk}]+`]]),$u="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",R0=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"),Ru=(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 iI)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=lI(t.String);return new RegExp(e?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",t),null},lI=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),cI=(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},uI=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,pI=t=>Number.isInteger(t)||typeof t=="bigint",dI=t=>{let e=0;for(let r of t)++e;return e},fI=t=>Jk(t.toLowerCase()),Qt=(...t)=>Array.prototype.concat.apply([],t),D0=t=>new Map(Object.entries(t)),_I=(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},Jk=t=>t.replace(/\p{M}/gu,""),Vk=(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},mI=t=>t.match(/\S+/g)||[],hI=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},tl=hI,gI=class extends tl{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},Er=gI,wI=class extends Er{tokenize_chinese_chars(t){let e=[];for(let r=0;r<t.length;++r){let s=t[r],n=s.charCodeAt(0);uI(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}},xI=wI,yI=class extends Er{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}},bI=yI,vI=class extends Er{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>Zk(e))}normalize(t){return this.normalizers.reduce((e,r)=>r?r.normalize(e):e,t)}},kI=vI,EI=class extends Er{normalize(t){let e=Ru(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},AI=EI,MI=class extends Er{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Du=MI,SI=class extends Du{constructor(){super(...arguments),this.form="NFC"}},TI=SI,OI=class extends Du{constructor(){super(...arguments),this.form="NFD"}},II=OI,CI=class extends Du{constructor(){super(...arguments),this.form="NFKC"}},LI=CI,PI=class extends Du{constructor(){super(...arguments),this.form="NFKD"}},zI=PI,NI=class extends Er{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}},$I=NI,RI=class extends Er{normalize(t){return Jk(t)}},DI=RI,FI=class extends Er{normalize(t){return t.toLowerCase()}},BI=FI,UI=class extends Er{normalize(t){return t=this.config.prepend+t,t}},jI=UI;function GI(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new xI(t);case"Precompiled":return new bI(t);case"Sequence":return new kI(t);case"Replace":return new AI(t);case"NFC":return new TI(t);case"NFD":return new II(t);case"NFKC":return new LI(t);case"NFKD":return new zI(t);case"Strip":return new $I(t);case"StripAccents":return new DI(t);case"Lowercase":return new BI(t);case"Prepend":return new jI(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var Zk=GI,qI=class extends tl{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)}},Yt=qI,WI=class extends Yt{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=Yk,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(""))}},VI=WI,HI=class extends Yt{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},XI=HI,KI=class extends Yt{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]}},QI=KI,YI=class extends Yt{constructor(t){super(),this.config=t,this.pattern=Ru(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):_I(t,this.pattern)}},JI=YI,ZI=class extends Yt{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${$u}]+|[${$u}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},eC=ZI,tC=class extends Yt{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)||[]}},rC=tC,sC=class extends Yt{constructor(){super(),this.pattern=new RegExp(`[^\\s${$u}]+|[${$u}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},nC=sC,oC=class extends Yt{constructor(t){super(),this.config=t,this.pattern=Ru(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},aC=oC,iC=class extends Yt{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>eE(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((r,s)=>s?s.pre_tokenize(r,e):r,[t])}},lC=iC,cC=class extends Yt{pre_tokenize_text(t){return mI(t)}},uC=cC,pC=class extends Yt{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}},dC=pC;function fC(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new nC;case"Sequence":return new lC(t);case"Whitespace":return new XI;case"WhitespaceSplit":return new uC;case"Metaspace":return new QI(t);case"ByteLevel":return new VI(t);case"Split":return new JI(t);case"Punctuation":return new eC(t);case"Digits":return new rC(t);case"Replace":return new aC(t);case"FixedLength":return new dC(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var eE=fC,_C=class extends tl{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=cI(e,this.tokens_to_ids,this.unk_token_id)),e}},Fu=_C,mC=class extends Fu{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=D0(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}},Hk=mC,Xk=class tE{constructor(e,r){this.is_leaf=e,this.children=r}static default(){return new tE(!1,new Map)}},hC=class{constructor(){this.root=Xk.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=Xk.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)}}},gC=hC,$0=class rE{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 rE(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 $0(this.bos_token_id??0,0,0,0,0),n=new $0(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 $0(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)}},xC=wC;function yC(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 bC=class extends Fu{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=yC(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new gC,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],f=dI(l);t.insert(s,f,p,c),!n&&f===r&&(n=!0)}n||t.insert(s,r,this.unk_score,this.unk_token_id),s+=r}}tokenize(t){let e=new xC(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}},Kk=bC,vC=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}},kC=vC,EC=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()}},AC=EC,MC=class extends Fu{constructor(t){super(t),this.tokens_to_ids=D0(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 AC(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 kC((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):e.push(this.unk_token)}else e.push(this.unk_token)}return e}},Qk=MC,SC=class extends Fu{constructor(t,e){super(t);let r=t.vocab;this.tokens_to_ids=D0(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}},TC=SC;function OC(t,e){switch(t.type){case"WordPiece":return new Hk(t);case"Unigram":return new Kk(t,e.eos_token);case"BPE":return new Qk(t);default:if(t.vocab)return Array.isArray(t.vocab)?new Kk(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new Qk(t):new Hk(t):new TC(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 IC=OC,CC=class extends tl{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},rl=CC,LC=class extends rl{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=Qt(n,t),o=Qt(o,new Array(t.length).fill(a.Sequence.type_id))):a.Sequence.id==="B"&&(n=Qt(n,e),o=Qt(o,new Array(e.length).fill(a.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},PC=LC,zC=class extends rl{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},NC=zC,$C=class extends rl{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,r=!0){r&&(t=Qt([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=Qt(t,n,e,o),s=Qt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},RC=$C,DC=class extends rl{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,r=!0){r&&(t=Qt([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=Qt(t,n,e,o),s=Qt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},FC=DC,BC=class extends rl{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>sE(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}},UC=BC;function jC(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new PC(t);case"ByteLevel":return new NC(t);case"BertProcessing":return new RC(t);case"RobertaProcessing":return new FC(t);case"Sequence":return new UC(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var sE=jC,GC=class extends tl{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("")}},Ut=GC,qC=class extends Ut{constructor(t){super(t),this.byte_decoder=aI,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}},WC=qC,VC=class extends Ut{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=R0(e)),e})}},HC=VC,XC=class extends Ut{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}},KC=XC,QC=class extends Ut{constructor(t){super(t),this.suffix=t.suffix??""}decode_chain(t){return t.map((e,r)=>e.replaceAll(this.suffix,r===t.length-1?"":" "))}},YC=QC,JC=class extends Ut{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=R0(s).replaceAll(this.word_delimiter_token," ").trim()),s}decode_chain(t){return[this.convert_tokens_to_string(t)]}},ZC=JC,eL=class extends Ut{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>nE(e))}decode_chain(t){return this.decoders.reduce((e,r)=>r.decode_chain(e),t)}},tL=eL,rL=class extends Ut{decode_chain(t){let e=Ru(this.config.pattern),r=this.config.content??"";return e===null?t:t.map(s=>s.replaceAll(e,r))}},sL=rL,nL=class extends Ut{decode_chain(t){return[t.join("")]}},oL=nL,aL=class extends Ut{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)})}},iL=aL,lL=class extends Ut{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}},cL=lL;function uL(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new WC(t);case"WordPiece":return new HC(t);case"Metaspace":return new KC(t);case"BPEDecoder":return new YC(t);case"CTC":return new ZC(t);case"Sequence":return new tL(t);case"Replace":return new sL(t);case"Fuse":return new oL(t);case"Strip":return new iL(t);case"ByteFallback":return new cL(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var nE=uL,pL=class{constructor(t,e){let r=Vk(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);let s=Vk(e,"Config");if(s)throw new Error(s);this.tokenizer=t,this.config=e,this.normalizer=Zk(this.tokenizer.normalizer),this.pre_tokenizer=eE(this.tokenizer.pre_tokenizer),this.model=IC(this.tokenizer.model,this.config),this.post_processor=sE(this.tokenizer.post_processor),this.decoder=nE(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 nI(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 qk(n),this.splitter_normalized=new qk(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||!pI(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=R0(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=fI(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:Qt(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}},oE=pL;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"}),jt=class{constructor(t,e){this.value=t,this.type=e}};function aE(t){return/\w/.test(t)}function sl(t){return/[0-9]/.test(t)}function iE(t){return/\s/.test(t)}var dL=[["{%",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]],fL=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 mL(t,e={}){let r=[],s=_L(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 f=s[n++],_=fL.get(f);if(_===void 0)throw new SyntaxError(`Unexpected escaped character: ${f}`);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&&iE(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 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 jt(f,D.Text));continue}}if(s[n]==="{"&&s[n+1]==="#"){n+=2;let f=s[n]==="-";f&&++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)),f&&i(),r.push(new jt(_,D.Comment)),n+=2,m&&l();continue}if(s.slice(n,n+3)==="{%-"){i(),r.push(new jt("{%",D.OpenStatement)),n+=3;continue}if(s.slice(n,n+3)==="{{-"){i(),r.push(new jt("{{",D.OpenExpression)),o=0,n+=3;continue}if(a(iE),s.slice(n,n+3)==="-%}"){r.push(new jt("%}",D.CloseStatement)),n+=3,l();continue}if(s.slice(n,n+3)==="-}}"){r.push(new jt("}}",D.CloseExpression)),n+=3,l();continue}let p=s[n];if(p==="-"||p==="+"){let f=r.at(-1)?.type;if(f===D.Text||f===void 0)throw new SyntaxError(`Unexpected character: ${p}`);switch(f){case D.Identifier:case D.NumericLiteral:case D.StringLiteral:case D.CloseParen:case D.CloseSquareBracket:break;default:{++n;let _=a(sl);r.push(new jt(`${p}${_}`,_.length>0?D.NumericLiteral:D.UnaryOperator));continue}}}for(let[f,_]of dL){if(f==="}}"&&o>0)continue;if(s.slice(n,n+f.length)===f){r.push(new jt(f,_)),_===D.OpenExpression?o=0:_===D.OpenCurlyBracket?++o:_===D.CloseCurlyBracket&&--o,n+=f.length;continue e}}if(p==="'"||p==='"'){++n;let f=a(_=>_!==p);r.push(new jt(f,D.StringLiteral)),++n;continue}if(sl(p)){let f=a(sl);if(s[n]==="."&&sl(s[n+1])){++n;let _=a(sl);f=`${f}.${_}`}r.push(new jt(f,D.NumericLiteral));continue}if(aE(p)){let f=a(aE);r.push(new jt(f,D.Identifier));continue}throw new SyntaxError(`Unexpected character: ${p}`)}return r}var Zt=class{type="Statement"},hL=class extends Zt{constructor(t){super(),this.body=t}type="Program"},gL=class extends Zt{constructor(t,e,r){super(),this.test=t,this.body=e,this.alternate=r}type="If"},wL=class extends Zt{constructor(t,e,r,s){super(),this.loopvar=t,this.iterable=e,this.body=r,this.defaultBlock=s}type="For"},xL=class extends Zt{type="Break"},yL=class extends Zt{type="Continue"},bL=class extends Zt{constructor(t,e,r){super(),this.assignee=t,this.value=e,this.body=r}type="Set"},vL=class extends Zt{constructor(t,e,r){super(),this.name=t,this.args=e,this.body=r}type="Macro"},kL=class extends Zt{constructor(t){super(),this.value=t}type="Comment"},Lt=class extends Zt{type="Expression"},EL=class extends Lt{constructor(t,e,r){super(),this.object=t,this.property=e,this.computed=r}type="MemberExpression"},lE=class extends Lt{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},Ln=class extends Lt{constructor(t){super(),this.value=t}type="Identifier"},Pn=class extends Lt{constructor(t){super(),this.value=t}type="Literal"},AL=class extends Pn{type="IntegerLiteral"},ML=class extends Pn{type="FloatLiteral"},cE=class extends Pn{type="StringLiteral"},SL=class extends Pn{type="ArrayLiteral"},uE=class extends Pn{type="TupleLiteral"},TL=class extends Pn{type="ObjectLiteral"},nl=class extends Lt{constructor(t,e,r){super(),this.operator=t,this.left=e,this.right=r}type="BinaryExpression"},OL=class extends Lt{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},IL=class extends Zt{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},CL=class extends Lt{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},LL=class extends Lt{constructor(t,e,r){super(),this.operand=t,this.negate=e,this.test=r}type="TestExpression"},PL=class extends Lt{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},zL=class extends Lt{constructor(t=void 0,e=void 0,r=void 0){super(),this.start=t,this.stop=e,this.step=r}type="SliceExpression"},NL=class extends Lt{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},$L=class extends Lt{constructor(t){super(),this.argument=t}type="SpreadExpression"},RL=class extends Zt{constructor(t,e,r){super(),this.call=t,this.callerArgs=e,this.body=r}type="CallStatement"},DL=class extends Lt{constructor(t,e,r){super(),this.condition=t,this.trueExpr=e,this.falseExpr=r}type="Ternary"};function FL(t){let e=new hL([]),r=0;function s(L,z){let R=t[r++];if(!R||R.type!==L)throw new Error(`Parser Error: ${z}. ${R.type} !== ${L}.`);return R}function n(L){if(!l(L))throw new SyntaxError(`Expected ${L}`);++r}function o(){switch(t[r].type){case D.Comment:return new kL(t[r++].value);case D.Text:return c();case D.OpenStatement:return p();case D.OpenExpression:return f();default:throw new SyntaxError(`Unexpected token type: ${t[r].type}`)}}function a(...L){return r+L.length<=t.length&&L.every((z,R)=>z===t[r+R].type)}function i(...L){return t[r]?.type===D.OpenStatement&&t[r+1]?.type===D.Identifier&&L.includes(t[r+1]?.value)}function l(...L){return r+L.length<=t.length&&L.every((z,R)=>t[r+R].type==="Identifier"&&z===t[r+R].value)}function c(){return new cE(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 L=t[r].value,z;switch(L){case"set":++r,z=_();break;case"if":++r,z=m(),s(D.OpenStatement,"Expected {% token"),n("endif"),s(D.CloseStatement,"Expected %} token");break;case"macro":++r,z=w(),s(D.OpenStatement,"Expected {% token"),n("endmacro"),s(D.CloseStatement,"Expected %} token");break;case"for":++r,z=k(),s(D.OpenStatement,"Expected {% token"),n("endfor"),s(D.CloseStatement,"Expected %} token");break;case"call":{++r;let R=null;a(D.OpenParen)&&(R=B());let J=le();if(J.type!=="Identifier")throw new SyntaxError("Expected identifier following call statement");let Ce=B();s(D.CloseStatement,"Expected closing statement token");let ae=[];for(;!i("endcall");)ae.push(o());s(D.OpenStatement,"Expected '{%'"),n("endcall"),s(D.CloseStatement,"Expected closing statement token");let Ue=new lE(J,Ce);z=new RL(Ue,R,ae);break}case"break":++r,s(D.CloseStatement,"Expected closing statement token"),z=new xL;break;case"continue":++r,s(D.CloseStatement,"Expected closing statement token"),z=new yL;break;case"filter":{++r;let R=le();R instanceof Ln&&a(D.OpenParen)&&(R=H(R)),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 '%}'"),z=new IL(R,J);break}default:throw new SyntaxError(`Unknown statement type: ${L}`)}return z}function f(){s(D.OpenExpression,"Expected opening expression token");let L=E();return s(D.CloseExpression,"Expected closing expression token"),L}function _(){let L=x(),z=null,R=[];if(a(D.Equals))++r,z=x();else{for(s(D.CloseStatement,"Expected %} token");!i("endset");)R.push(o());s(D.OpenStatement,"Expected {% token"),n("endset")}return s(D.CloseStatement,"Expected closing statement token"),new bL(L,z,R)}function m(){let L=E();s(D.CloseStatement,"Expected closing statement token");let z=[],R=[];for(;!i("elif","else","endif");)z.push(o());if(i("elif")){++r,++r;let J=m();R.push(J)}else if(i("else"))for(++r,++r,s(D.CloseStatement,"Expected closing statement token");!i("endif");)R.push(o());return new gL(L,z,R)}function w(){let L=le();if(L.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let z=B();s(D.CloseStatement,"Expected closing statement token");let R=[];for(;!i("endmacro");)R.push(o());return new vL(L,z,R)}function x(L=!1){let z=L?le:E,R=[z()],J=a(D.Comma);for(;J&&(++r,R.push(z()),!!a(D.Comma)););return J?new uE(R):R[0]}function k(){let L=x(!0);if(!(L instanceof Ln||L instanceof uE))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${L.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;let z=E();s(D.CloseStatement,"Expected closing statement token");let R=[];for(;!i("endfor","else");)R.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(L,z,R,J)}function E(){return A()}function A(){let L=T();if(l("if")){++r;let z=T();if(l("else")){++r;let R=A();return new DL(z,L,R)}else return new CL(L,z)}return L}function T(){let L=S();for(;l("or");){let z=t[r];++r;let R=S();L=new nl(z,L,R)}return L}function S(){let L=P();for(;l("and");){let z=t[r];++r;let R=P();L=new nl(z,L,R)}return L}function P(){let L;for(;l("not");){let z=t[r];++r;let R=P();L=new PL(z,R)}return L??O()}function O(){let L=v();for(;;){let z;if(l("not","in"))z=new jt("not in",D.Identifier),r+=2;else if(l("in"))z=t[r++];else if(a(D.ComparisonBinaryOperator))z=t[r++];else break;let R=v();L=new nl(z,L,R)}return L}function v(){let L=F();for(;a(D.AdditiveBinaryOperator);){let z=t[r];++r;let R=F();L=new nl(z,L,R)}return L}function j(){let L=Q(le());return a(D.OpenParen)?H(L):L}function H(L){let z=new lE(L,B());return z=Q(z),a(D.OpenParen)&&(z=H(z)),z}function B(){s(D.OpenParen,"Expected opening parenthesis for arguments list");let L=V();return s(D.CloseParen,"Expected closing parenthesis for arguments list"),L}function V(){let L=[];for(;!a(D.CloseParen);){let z;if(t[r].type===D.MultiplicativeBinaryOperator&&t[r].value==="*"){++r;let R=E();z=new $L(R)}else if(z=E(),a(D.Equals)){if(++r,!(z instanceof Ln))throw new SyntaxError("Expected identifier for keyword argument");let R=E();z=new NL(z,R)}L.push(z),a(D.Comma)&&++r}return L}function q(){let L=[],z=!1;for(;!a(D.CloseSquareBracket);)a(D.Colon)?(L.push(void 0),++r,z=!0):(L.push(E()),a(D.Colon)&&(++r,z=!0));if(L.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if(z){if(L.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new zL(...L)}return L[0]}function Q(L){for(;a(D.Dot)||a(D.OpenSquareBracket);){let z=t[r];++r;let R,J=z.type===D.OpenSquareBracket;if(J)R=q(),s(D.CloseSquareBracket,"Expected closing square bracket");else if(R=le(),R.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");L=new EL(L,R,J)}return L}function F(){let L=C();for(;a(D.MultiplicativeBinaryOperator);){let z=t[r++],R=C();L=new nl(z,L,R)}return L}function C(){let L=te();for(;l("is");){++r;let z=l("not");z&&++r;let R=le();if(!(R instanceof Ln))throw new SyntaxError("Expected identifier for the test");L=new LL(L,z,R)}return L}function te(){let L=j();for(;a(D.Pipe);){++r;let z=le();if(!(z instanceof Ln))throw new SyntaxError("Expected identifier for the filter");a(D.OpenParen)&&(z=H(z)),L=new OL(L,z)}return L}function le(){let L=t[r++];switch(L.type){case D.NumericLiteral:{let z=L.value;return z.includes(".")?new ML(Number(z)):new AL(Number(z))}case D.StringLiteral:{let z=L.value;for(;a(D.StringLiteral);)z+=t[r++].value;return new cE(z)}case D.Identifier:return new Ln(L.value);case D.OpenParen:{let z=x();return s(D.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),z}case D.OpenSquareBracket:{let z=[];for(;!a(D.CloseSquareBracket);)z.push(E()),a(D.Comma)&&++r;return++r,new SL(z)}case D.OpenCurlyBracket:{let z=new Map;for(;!a(D.CloseCurlyBracket);){let R=E();s(D.Colon,"Expected colon between key and value in object literal");let J=E();z.set(R,J),a(D.Comma)&&++r}return++r,new TL(z)}default:throw new SyntaxError(`Unexpected token: ${L.type}`)}}for(;r<t.length;)e.body.push(o());return e}function BL(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 pE(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 UL(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function jL(t){return GL(new Date,t)}function GL(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 qL(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function WL(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(qL(e),"gu");return t.replaceAll(o,a=>n>0?(--n,r):a)}var dE=class extends Error{},fE=class extends Error{},cr=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 cr{type="IntegerValue"},Ze=class extends cr{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},ee=class extends cr{type="StringValue";builtins=new Map([["upper",new qe(()=>new ee(this.value.toUpperCase()))],["lower",new qe(()=>new ee(this.value.toLowerCase()))],["strip",new qe(()=>new ee(this.value.trim()))],["title",new qe(()=>new ee(UL(this.value)))],["capitalize",new qe(()=>new ee(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],["length",new me(this.value.length)],["rstrip",new qe(()=>new ee(this.value.trimEnd()))],["lstrip",new qe(()=>new ee(this.value.trimStart()))],["startswith",new qe(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 qe(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 qe(t=>{let e=t[0]??new Xe;if(!(e instanceof ee||e instanceof Xe))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 Xe){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 qe(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 Xe:s=t[2]:s=new Xe,!(s instanceof me||s instanceof Xe))throw new Error("replace() count argument must be a number or null");return new ee(WL(this.value,e.value,r.value,s.value))})]])},pe=class extends cr{type="BooleanValue"},VL=/[\x7f-\uffff]/g;function _E(t){return t.replace(VL,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=_E(p)),p}case"ArrayValue":case"ObjectValue":{let p=n?" ".repeat(n):"",f=`
|
|
5
|
-
`+p.repeat(r),_=f+p;if(t.type==="ArrayValue"){let m=t.value.map(w=>
|
|
1
|
+
var mI=Object.create;var Ru=Object.defineProperty;var hI=Object.getOwnPropertyDescriptor;var gI=Object.getOwnPropertyNames;var wI=Object.getPrototypeOf,xI=Object.prototype.hasOwnProperty;var Ms=(t,e)=>{for(var r in e)Ru(t,r,{get:e[r],enumerable:!0})},uE=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gI(e))!xI.call(t,n)&&n!==r&&Ru(t,n,{get:()=>e[n],enumerable:!(s=hI(e,n))||s.enumerable});return t};var yr=(t,e,r)=>(r=t!=null?mI(wI(t)):{},uE(e||!t||!t.__esModule?Ru(r,"default",{value:t,enumerable:!0}):r,t)),yI=t=>uE(Ru({},"__esModule",{value:!0}),t);var BN={};Ms(BN,{ASTFeatureExtractor:()=>dd,ASTForAudioClassification:()=>f_,ASTModel:()=>d_,ASTPreTrainedModel:()=>fo,AfmoeForCausalLM:()=>c_,AfmoeModel:()=>l_,AfmoePreTrainedModel:()=>uo,AlbertForMaskedLM:()=>o_,AlbertForQuestionAnswering:()=>n_,AlbertForSequenceClassification:()=>s_,AlbertModel:()=>r_,AlbertPreTrainedModel:()=>us,AlbertTokenizer:()=>yp,ApertusForCausalLM:()=>i_,ApertusModel:()=>a_,ApertusPreTrainedModel:()=>co,ArceeForCausalLM:()=>p_,ArceeModel:()=>u_,ArceePreTrainedModel:()=>po,AudioClassificationPipeline:()=>$i,AutoConfig:()=>Nt,AutoFeatureExtractor:()=>We,AutoImageProcessor:()=>Ae,AutoModel:()=>dr,AutoModelForAudioClassification:()=>xu,AutoModelForAudioFrameClassification:()=>Q1,AutoModelForAudioTextToText:()=>rv,AutoModelForCTC:()=>wu,AutoModelForCausalLM:()=>pu,AutoModelForDepthEstimation:()=>vu,AutoModelForDocumentQuestionAnswering:()=>yu,AutoModelForImageClassification:()=>mu,AutoModelForImageFeatureExtraction:()=>ku,AutoModelForImageMatting:()=>J1,AutoModelForImageSegmentation:()=>Ai,AutoModelForImageTextToText:()=>tv,AutoModelForImageToImage:()=>bu,AutoModelForMaskGeneration:()=>K1,AutoModelForMaskedLM:()=>du,AutoModelForNormalEstimation:()=>Z1,AutoModelForObjectDetection:()=>hu,AutoModelForPoseEstimation:()=>ev,AutoModelForQuestionAnswering:()=>fu,AutoModelForSemanticSegmentation:()=>Mi,AutoModelForSeq2SeqLM:()=>bn,AutoModelForSequenceClassification:()=>Ei,AutoModelForSpeechSeq2Seq:()=>lu,AutoModelForTextToSpectrogram:()=>cu,AutoModelForTextToWaveform:()=>uu,AutoModelForTokenClassification:()=>iu,AutoModelForUniversalSegmentation:()=>Si,AutoModelForVision2Seq:()=>_u,AutoModelForXVector:()=>Y1,AutoModelForZeroShotObjectDetection:()=>gu,AutoProcessor:()=>Xl,AutoTokenizer:()=>se,AutomaticSpeechRecognitionPipeline:()=>Di,BackgroundRemovalPipeline:()=>ji,BartForConditionalGeneration:()=>m_,BartForSequenceClassification:()=>h_,BartModel:()=>__,BartPretrainedModel:()=>Zs,BartTokenizer:()=>bp,BaseStreamer:()=>C0,BeitFeatureExtractor:()=>Cd,BeitForImageClassification:()=>w_,BeitModel:()=>g_,BeitPreTrainedModel:()=>_o,BertForMaskedLM:()=>y_,BertForQuestionAnswering:()=>k_,BertForSequenceClassification:()=>b_,BertForTokenClassification:()=>v_,BertModel:()=>x_,BertPreTrainedModel:()=>Mr,BertTokenizer:()=>vp,BitImageProcessor:()=>Pd,BlenderbotForConditionalGeneration:()=>A_,BlenderbotModel:()=>E_,BlenderbotPreTrainedModel:()=>mo,BlenderbotSmallForConditionalGeneration:()=>S_,BlenderbotSmallModel:()=>M_,BlenderbotSmallPreTrainedModel:()=>ho,BlenderbotSmallTokenizer:()=>kp,BlenderbotTokenizer:()=>Ep,BloomForCausalLM:()=>O_,BloomModel:()=>T_,BloomPreTrainedModel:()=>go,BloomTokenizer:()=>Ap,CHMv2ForDepthEstimation:()=>$_,CHMv2ImageProcessor:()=>Ld,CHMv2PreTrainedModel:()=>uc,CLIPFeatureExtractor:()=>Nd,CLIPImageProcessor:()=>Cl,CLIPModel:()=>D_,CLIPPreTrainedModel:()=>rr,CLIPSegForImageSegmentation:()=>G_,CLIPSegModel:()=>j_,CLIPSegPreTrainedModel:()=>vo,CLIPTextModel:()=>U_,CLIPTextModelWithProjection:()=>bo,CLIPTokenizer:()=>Sp,CLIPVisionModel:()=>B_,CLIPVisionModelWithProjection:()=>F_,CamembertForMaskedLM:()=>C_,CamembertForQuestionAnswering:()=>L_,CamembertForSequenceClassification:()=>P_,CamembertForTokenClassification:()=>z_,CamembertModel:()=>I_,CamembertPreTrainedModel:()=>Sr,CamembertTokenizer:()=>Mp,ChatterboxFeatureExtractor:()=>fd,ChatterboxModel:()=>wo,ChatterboxPreTrainedModel:()=>lc,ChatterboxProcessor:()=>Md,ChineseCLIPFeatureExtractor:()=>zd,ChineseCLIPModel:()=>N_,ChineseCLIPPreTrainedModel:()=>cc,ClapAudioModelWithProjection:()=>yo,ClapFeatureExtractor:()=>_d,ClapModel:()=>R_,ClapPreTrainedModel:()=>en,ClapTextModelWithProjection:()=>xo,ClassifierFreeGuidanceLogitsProcessor:()=>sc,CodeGenForCausalLM:()=>W_,CodeGenModel:()=>q_,CodeGenPreTrainedModel:()=>ko,CodeGenTokenizer:()=>Op,CodeLlamaTokenizer:()=>Tp,Cohere2ForCausalLM:()=>K_,Cohere2Model:()=>X_,Cohere2PreTrainedModel:()=>Ao,CohereForCausalLM:()=>H_,CohereModel:()=>V_,CoherePreTrainedModel:()=>Eo,CohereTokenizer:()=>Ip,ConvBertForMaskedLM:()=>Q_,ConvBertForQuestionAnswering:()=>em,ConvBertForSequenceClassification:()=>J_,ConvBertForTokenClassification:()=>Z_,ConvBertModel:()=>Y_,ConvBertPreTrainedModel:()=>Tr,ConvBertTokenizer:()=>Cp,ConvNextFeatureExtractor:()=>$d,ConvNextForImageClassification:()=>rm,ConvNextImageProcessor:()=>Pl,ConvNextModel:()=>tm,ConvNextPreTrainedModel:()=>Mo,ConvNextV2ForImageClassification:()=>nm,ConvNextV2Model:()=>sm,ConvNextV2PreTrainedModel:()=>So,DFineForObjectDetection:()=>lm,DFineModel:()=>im,DFinePreTrainedModel:()=>Oo,DINOv3ConvNextModel:()=>Lm,DINOv3ConvNextPreTrainedModel:()=>gc,DINOv3ViTImageProcessor:()=>Ud,DINOv3ViTModel:()=>Nm,DINOv3ViTPreTrainedModel:()=>wc,DPTFeatureExtractor:()=>Fd,DPTForDepthEstimation:()=>Gm,DPTImageProcessor:()=>Nl,DPTModel:()=>jm,DPTPreTrainedModel:()=>$o,DacDecoderModel:()=>Co,DacDecoderOutput:()=>dc,DacEncoderModel:()=>Io,DacEncoderOutput:()=>pc,DacFeatureExtractor:()=>Hn,DacModel:()=>cm,DacPreTrainedModel:()=>tn,DebertaForMaskedLM:()=>pm,DebertaForQuestionAnswering:()=>_m,DebertaForSequenceClassification:()=>dm,DebertaForTokenClassification:()=>fm,DebertaModel:()=>um,DebertaPreTrainedModel:()=>Or,DebertaTokenizer:()=>zp,DebertaV2ForMaskedLM:()=>wm,DebertaV2ForQuestionAnswering:()=>bm,DebertaV2ForSequenceClassification:()=>xm,DebertaV2ForTokenClassification:()=>ym,DebertaV2Model:()=>gm,DebertaV2PreTrainedModel:()=>Ir,DebertaV2Tokenizer:()=>Pp,DecisionTransformerModel:()=>vm,DecisionTransformerPreTrainedModel:()=>fc,DeepseekV3ForCausalLM:()=>hm,DeepseekV3Model:()=>mm,DeepseekV3PreTrainedModel:()=>Po,DeiTFeatureExtractor:()=>Rd,DeiTForImageClassification:()=>Em,DeiTImageProcessor:()=>zl,DeiTModel:()=>km,DeiTPreTrainedModel:()=>zo,DepthAnythingForDepthEstimation:()=>Am,DepthAnythingPreTrainedModel:()=>_c,DepthEstimationPipeline:()=>Xi,DepthProForDepthEstimation:()=>Mm,DepthProPreTrainedModel:()=>mc,DetrFeatureExtractor:()=>Dd,DetrForObjectDetection:()=>Tm,DetrForSegmentation:()=>Om,DetrImageProcessor:()=>Ll,DetrModel:()=>Sm,DetrObjectDetectionOutput:()=>sn,DetrPreTrainedModel:()=>rn,DetrSegmentationOutput:()=>hc,Dinov2ForImageClassification:()=>Cm,Dinov2Model:()=>Im,Dinov2PreTrainedModel:()=>Lo,Dinov2WithRegistersForImageClassification:()=>zm,Dinov2WithRegistersModel:()=>Pm,Dinov2WithRegistersPreTrainedModel:()=>No,DistilBertForMaskedLM:()=>Bm,DistilBertForQuestionAnswering:()=>Um,DistilBertForSequenceClassification:()=>Rm,DistilBertForTokenClassification:()=>Dm,DistilBertModel:()=>$m,DistilBertPreTrainedModel:()=>Cr,DistilBertTokenizer:()=>Lp,DocumentQuestionAnsweringPipeline:()=>Vi,DonutFeatureExtractor:()=>Bd,DonutImageProcessor:()=>Gs,DonutSwinModel:()=>Fm,DonutSwinPreTrainedModel:()=>xc,DynamicCache:()=>ao,EdgeTamModel:()=>Jx,EfficientNetForImageClassification:()=>Wm,EfficientNetImageProcessor:()=>jd,EfficientNetModel:()=>qm,EfficientNetPreTrainedModel:()=>Ro,ElectraForMaskedLM:()=>Hm,ElectraForQuestionAnswering:()=>Ym,ElectraForSequenceClassification:()=>Xm,ElectraForTokenClassification:()=>Km,ElectraModel:()=>Vm,ElectraPreTrainedModel:()=>Pr,ElectraTokenizer:()=>Np,EncodecFeatureExtractor:()=>Vn,EosTokenCriteria:()=>ac,Ernie4_5ForCausalLM:()=>Jm,Ernie4_5Model:()=>Qm,Ernie4_5PretrainedModel:()=>Do,EsmForMaskedLM:()=>eh,EsmForSequenceClassification:()=>th,EsmForTokenClassification:()=>rh,EsmModel:()=>Zm,EsmPreTrainedModel:()=>ps,EsmTokenizer:()=>$p,EuroBertForMaskedLM:()=>nh,EuroBertForSequenceClassification:()=>oh,EuroBertForTokenClassification:()=>ah,EuroBertModel:()=>sh,EuroBertPreTrainedModel:()=>ds,ExaoneForCausalLM:()=>lh,ExaoneModel:()=>ih,ExaonePreTrainedModel:()=>Uo,FalconForCausalLM:()=>uh,FalconH1ForCausalLM:()=>dh,FalconH1Model:()=>ph,FalconH1PreTrainedModel:()=>Fo,FalconModel:()=>ch,FalconPreTrainedModel:()=>Bo,FalconTokenizer:()=>Rp,FastViTForImageClassification:()=>_h,FastViTModel:()=>fh,FastViTPreTrainedModel:()=>jo,FeatureExtractionPipeline:()=>Ki,FeatureExtractor:()=>Ee,FillMaskPipeline:()=>Ci,Florence2ForConditionalGeneration:()=>mh,Florence2PreTrainedModel:()=>yc,Florence2Processor:()=>yf,ForcedBOSTokenLogitsProcessor:()=>Kl,ForcedEOSTokenLogitsProcessor:()=>Yl,GLPNFeatureExtractor:()=>Wd,GLPNForDepthEstimation:()=>Ch,GLPNModel:()=>Ih,GLPNPreTrainedModel:()=>Ko,GPT2LMHeadModel:()=>Fh,GPT2Model:()=>Bh,GPT2PreTrainedModel:()=>ea,GPT2Tokenizer:()=>Bp,GPTBigCodeForCausalLM:()=>zh,GPTBigCodeModel:()=>Ph,GPTBigCodePreTrainedModel:()=>Yo,GPTJForCausalLM:()=>Gh,GPTJModel:()=>jh,GPTJPreTrainedModel:()=>ta,GPTNeoForCausalLM:()=>Nh,GPTNeoModel:()=>Lh,GPTNeoPreTrainedModel:()=>Qo,GPTNeoXForCausalLM:()=>Rh,GPTNeoXModel:()=>$h,GPTNeoXPreTrainedModel:()=>Jo,GPTNeoXTokenizer:()=>Up,Gemma2ForCausalLM:()=>xh,Gemma2Model:()=>wh,Gemma2PreTrainedModel:()=>qo,Gemma3ForCausalLM:()=>kh,Gemma3ForConditionalGeneration:()=>kc,Gemma3ImageProcessor:()=>Gd,Gemma3Model:()=>vh,Gemma3PreTrainedModel:()=>vc,Gemma3Processor:()=>bf,Gemma3nAudioFeatureExtractor:()=>md,Gemma3nForCausalLM:()=>Eh,Gemma3nForConditionalGeneration:()=>nn,Gemma3nPreTrainedModel:()=>Ec,Gemma3nProcessor:()=>vf,GemmaForCausalLM:()=>gh,GemmaModel:()=>hh,GemmaPreTrainedModel:()=>Go,GemmaTokenizer:()=>Dp,Glm46VImageProcessor:()=>qd,Glm46VProcessor:()=>kf,GlmForCausalLM:()=>Mh,GlmModel:()=>Ah,GlmMoeDsaForCausalLM:()=>Th,GlmMoeDsaModel:()=>Sh,GlmMoeDsaPreTrainedModel:()=>Vo,GlmOcrForConditionalGeneration:()=>Oh,GlmPreTrainedModel:()=>Wo,GptOssForCausalLM:()=>Uh,GptOssModel:()=>Dh,GptOssPreTrainedModel:()=>Zo,GraniteForCausalLM:()=>Wh,GraniteModel:()=>qh,GraniteMoeHybridForCausalLM:()=>Hh,GraniteMoeHybridModel:()=>Vh,GraniteMoeHybridPreTrainedModel:()=>sa,GranitePreTrainedModel:()=>ra,GraniteSpeechFeatureExtractor:()=>hd,GraniteSpeechForConditionalGeneration:()=>Xh,GraniteSpeechProcessor:()=>Ef,GroundingDinoForObjectDetection:()=>Kh,GroundingDinoImageProcessor:()=>Vd,GroundingDinoPreTrainedModel:()=>Sc,GroundingDinoProcessor:()=>Af,GroupViTModel:()=>Yh,GroupViTPreTrainedModel:()=>Tc,HeliumForCausalLM:()=>Jh,HeliumModel:()=>Qh,HeliumPreTrainedModel:()=>na,HerbertTokenizer:()=>Fp,HieraForImageClassification:()=>eg,HieraModel:()=>Zh,HieraPreTrainedModel:()=>oa,HubertForCTC:()=>ig,HubertForSequenceClassification:()=>lg,HubertModel:()=>ag,HubertPreTrainedModel:()=>og,HunYuanDenseV1ForCausalLM:()=>ug,HunYuanDenseV1Model:()=>cg,HunYuanDenseV1PreTrainedModel:()=>aa,IJepaForImageClassification:()=>fg,IJepaModel:()=>dg,IJepaPreTrainedModel:()=>ia,Idefics3ForConditionalGeneration:()=>pg,Idefics3ImageProcessor:()=>$l,Idefics3Processor:()=>Vl,ImageClassificationPipeline:()=>Fi,ImageFeatureExtractionPipeline:()=>Yi,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,ImageSegmentationPipeline:()=>vs,ImageToImagePipeline:()=>Hi,ImageToTextPipeline:()=>Bi,InterruptableStoppingCriteria:()=>D1,JAISLMHeadModel:()=>mg,JAISModel:()=>_g,JAISPreTrainedModel:()=>la,JinaCLIPImageProcessor:()=>Xd,JinaCLIPModel:()=>hg,JinaCLIPPreTrainedModel:()=>an,JinaCLIPProcessor:()=>Sf,JinaCLIPTextModel:()=>ca,JinaCLIPVisionModel:()=>gg,Lfm2ForCausalLM:()=>xg,Lfm2Model:()=>wg,Lfm2MoeForCausalLM:()=>vg,Lfm2MoeModel:()=>bg,Lfm2MoePreTrainedModel:()=>pa,Lfm2PreTrainedModel:()=>ua,Lfm2VlForConditionalGeneration:()=>kg,Lfm2VlImageProcessor:()=>Kd,Lfm2VlProcessor:()=>Tf,LightOnOcrForConditionalGeneration:()=>yg,LiteWhisperForConditionalGeneration:()=>d0,Llama4ForCausalLM:()=>Mg,Llama4PreTrainedModel:()=>Oc,LlamaForCausalLM:()=>Ag,LlamaModel:()=>Eg,LlamaPreTrainedModel:()=>da,LlamaTokenizer:()=>jp,LlavaForConditionalGeneration:()=>yt,LlavaOnevisionForConditionalGeneration:()=>yt,LlavaOnevisionImageProcessor:()=>Yd,LlavaPreTrainedModel:()=>bc,LlavaProcessor:()=>Of,LlavaQwen2ForCausalLM:()=>bh,LogLevel:()=>St,LogitsProcessor:()=>$t,LogitsProcessorList:()=>cs,LogitsWarper:()=>no,LongT5ForConditionalGeneration:()=>Tg,LongT5Model:()=>Sg,LongT5PreTrainedModel:()=>fa,M2M100ForConditionalGeneration:()=>Ig,M2M100Model:()=>Og,M2M100PreTrainedModel:()=>_a,M2M100Tokenizer:()=>Gp,MBart50Tokenizer:()=>Wp,MBartForCausalLM:()=>Dg,MBartForConditionalGeneration:()=>$g,MBartForSequenceClassification:()=>Rg,MBartModel:()=>Ng,MBartPreTrainedModel:()=>ms,MBartTokenizer:()=>qn,MPNetForMaskedLM:()=>Ew,MPNetForQuestionAnswering:()=>Sw,MPNetForSequenceClassification:()=>Aw,MPNetForTokenClassification:()=>Mw,MPNetModel:()=>kw,MPNetPreTrainedModel:()=>zr,MPNetTokenizer:()=>Xp,MT5ForConditionalGeneration:()=>Cw,MT5Model:()=>Iw,MT5PreTrainedModel:()=>Sa,MarianMTModel:()=>Pg,MarianModel:()=>Cg,MarianPreTrainedModel:()=>ma,MarianTokenizer:()=>qp,Mask2FormerImageProcessor:()=>Jd,MaskFormerFeatureExtractor:()=>Qd,MaskFormerForInstanceSegmentation:()=>Lg,MaskFormerImageProcessor:()=>qs,MaskFormerModel:()=>zg,MaskFormerPreTrainedModel:()=>ha,MaxLengthCriteria:()=>oc,Metric3DForDepthEstimation:()=>Ug,Metric3DPreTrainedModel:()=>Ic,Metric3Dv2ForDepthEstimation:()=>Bg,Metric3Dv2PreTrainedModel:()=>Cc,MgpstrForSceneTextRecognition:()=>Fg,MgpstrModelOutput:()=>Pc,MgpstrPreTrainedModel:()=>zc,MgpstrProcessor:()=>If,MgpstrTokenizer:()=>Vp,MimiDecoderModel:()=>wa,MimiDecoderOutput:()=>Nc,MimiEncoderModel:()=>ga,MimiEncoderOutput:()=>Lc,MimiModel:()=>jg,MimiPreTrainedModel:()=>ln,MinLengthLogitsProcessor:()=>ec,MinNewTokensLengthLogitsProcessor:()=>tc,Mistral4ForCausalLM:()=>Vg,Mistral4Model:()=>Wg,Mistral4PreTrainedModel:()=>ya,MistralForCausalLM:()=>qg,MistralModel:()=>Gg,MistralPreTrainedModel:()=>xa,MobileBertForMaskedLM:()=>Xg,MobileBertForQuestionAnswering:()=>Yg,MobileBertForSequenceClassification:()=>Kg,MobileBertModel:()=>Hg,MobileBertPreTrainedModel:()=>hs,MobileBertTokenizer:()=>Hp,MobileLLMForCausalLM:()=>Jg,MobileLLMModel:()=>Qg,MobileLLMPreTrainedModel:()=>ba,MobileNetV1FeatureExtractor:()=>Zd,MobileNetV1ForImageClassification:()=>ew,MobileNetV1ForSemanticSegmentation:()=>tw,MobileNetV1ImageProcessor:()=>Rl,MobileNetV1Model:()=>Zg,MobileNetV1PreTrainedModel:()=>cn,MobileNetV2FeatureExtractor:()=>ef,MobileNetV2ForImageClassification:()=>sw,MobileNetV2ForSemanticSegmentation:()=>nw,MobileNetV2ImageProcessor:()=>Dl,MobileNetV2Model:()=>rw,MobileNetV2PreTrainedModel:()=>un,MobileNetV3FeatureExtractor:()=>tf,MobileNetV3ForImageClassification:()=>aw,MobileNetV3ForSemanticSegmentation:()=>iw,MobileNetV3ImageProcessor:()=>Ul,MobileNetV3Model:()=>ow,MobileNetV3PreTrainedModel:()=>pn,MobileNetV4FeatureExtractor:()=>rf,MobileNetV4ForImageClassification:()=>cw,MobileNetV4ForSemanticSegmentation:()=>uw,MobileNetV4ImageProcessor:()=>Bl,MobileNetV4Model:()=>lw,MobileNetV4PreTrainedModel:()=>dn,MobileViTFeatureExtractor:()=>sf,MobileViTForImageClassification:()=>dw,MobileViTImageProcessor:()=>Fl,MobileViTModel:()=>pw,MobileViTPreTrainedModel:()=>va,MobileViTV2ForImageClassification:()=>_w,MobileViTV2Model:()=>fw,MobileViTV2PreTrainedModel:()=>ka,ModelRegistry:()=>L0,ModernBertDecoderForCausalLM:()=>yw,ModernBertDecoderModel:()=>xw,ModernBertDecoderPreTrainedModel:()=>Ea,ModernBertForMaskedLM:()=>hw,ModernBertForSequenceClassification:()=>gw,ModernBertForTokenClassification:()=>ww,ModernBertModel:()=>mw,ModernBertPreTrainedModel:()=>gs,Moondream1ForConditionalGeneration:()=>yh,MoonshineFeatureExtractor:()=>gd,MoonshineForConditionalGeneration:()=>vw,MoonshineModel:()=>bw,MoonshinePreTrainedModel:()=>Aa,MoonshineProcessor:()=>Cf,MptForCausalLM:()=>Ow,MptModel:()=>Tw,MptPreTrainedModel:()=>Ma,MultiModalityCausalLM:()=>Pw,MultiModalityPreTrainedModel:()=>$c,MusicgenForCausalLM:()=>Lw,MusicgenForConditionalGeneration:()=>Oa,MusicgenModel:()=>zw,MusicgenPreTrainedModel:()=>Ta,NanoChatForCausalLM:()=>$w,NanoChatModel:()=>Nw,NanoChatPreTrainedModel:()=>Ia,NemotronHForCausalLM:()=>Dw,NemotronHModel:()=>Rw,NemotronHPreTrainedModel:()=>Ca,NeoBertForMaskedLM:()=>Bw,NeoBertForQuestionAnswering:()=>Gw,NeoBertForSequenceClassification:()=>Fw,NeoBertForTokenClassification:()=>jw,NeoBertModel:()=>Uw,NeoBertPreTrainedModel:()=>Lr,NllbTokenizer:()=>Kp,NoBadWordsLogitsProcessor:()=>rc,NoRepeatNGramLogitsProcessor:()=>Jl,NomicBertModel:()=>qw,NomicBertPreTrainedModel:()=>Rc,NougatImageProcessor:()=>nf,NougatTokenizer:()=>Yp,OPTForCausalLM:()=>rx,OPTModel:()=>tx,OPTPreTrainedModel:()=>Ra,ObjectDetectionPipeline:()=>qi,Olmo2ForCausalLM:()=>Xw,Olmo2Model:()=>Hw,Olmo2PreTrainedModel:()=>za,Olmo3ForCausalLM:()=>Yw,Olmo3Model:()=>Kw,Olmo3PreTrainedModel:()=>La,OlmoForCausalLM:()=>Vw,OlmoHybridForCausalLM:()=>Jw,OlmoHybridModel:()=>Qw,OlmoHybridPreTrainedModel:()=>Na,OlmoModel:()=>Ww,OlmoPreTrainedModel:()=>Pa,OpenELMForCausalLM:()=>ex,OpenELMModel:()=>Zw,OpenELMPreTrainedModel:()=>$a,OwlViTFeatureExtractor:()=>of,OwlViTForObjectDetection:()=>ax,OwlViTImageProcessor:()=>Ws,OwlViTModel:()=>ox,OwlViTPreTrainedModel:()=>Ua,OwlViTProcessor:()=>Pf,Owlv2ForObjectDetection:()=>nx,Owlv2ImageProcessor:()=>af,Owlv2Model:()=>sx,Owlv2PreTrainedModel:()=>Da,PaliGemmaForConditionalGeneration:()=>ix,PaliGemmaProcessor:()=>zf,ParakeetFeatureExtractor:()=>wd,ParakeetForCTC:()=>lx,ParakeetPreTrainedModel:()=>Dc,PatchTSMixerForPrediction:()=>ux,PatchTSMixerModel:()=>cx,PatchTSMixerPreTrainedModel:()=>Ba,PatchTSTForPrediction:()=>dx,PatchTSTModel:()=>px,PatchTSTPreTrainedModel:()=>Fa,Phi3ForCausalLM:()=>hx,Phi3Model:()=>mx,Phi3PreTrainedModel:()=>Ga,Phi3VForCausalLM:()=>qa,Phi3VImageProcessor:()=>lf,Phi3VPreTrainedModel:()=>Uc,Phi3VProcessor:()=>Lf,PhiForCausalLM:()=>_x,PhiModel:()=>fx,PhiPreTrainedModel:()=>ja,PixtralImageProcessor:()=>cf,PixtralProcessor:()=>Nf,PreTrainedModel:()=>y,PreTrainedTokenizer:()=>q,PretrainedConfig:()=>Vs,Processor:()=>te,PvtForImageClassification:()=>wx,PvtImageProcessor:()=>uf,PvtModel:()=>gx,PvtPreTrainedModel:()=>Wa,PyAnnoteFeatureExtractor:()=>Xn,PyAnnoteForAudioFrameClassification:()=>yx,PyAnnoteModel:()=>xx,PyAnnotePreTrainedModel:()=>Va,PyAnnoteProcessor:()=>$f,QuestionAnsweringPipeline:()=>Ii,Qwen2ForCausalLM:()=>vx,Qwen2Model:()=>bx,Qwen2MoeForCausalLM:()=>Ex,Qwen2MoeModel:()=>kx,Qwen2MoePreTrainedModel:()=>Xa,Qwen2PreTrainedModel:()=>Ha,Qwen2Tokenizer:()=>Qp,Qwen2VLForCausalLM:()=>Ho,Qwen2VLForConditionalGeneration:()=>on,Qwen2VLImageProcessor:()=>Yn,Qwen2VLPreTrainedModel:()=>Ac,Qwen2VLProcessor:()=>ls,Qwen2_5_VLForCausalLM:()=>Xo,Qwen2_5_VLForConditionalGeneration:()=>fs,Qwen2_5_VLProcessor:()=>to,Qwen3ForCausalLM:()=>Mx,Qwen3Model:()=>Ax,Qwen3MoeForCausalLM:()=>Tx,Qwen3MoeModel:()=>Sx,Qwen3MoePreTrainedModel:()=>Ya,Qwen3NextForCausalLM:()=>Ix,Qwen3NextModel:()=>Ox,Qwen3NextPreTrainedModel:()=>Qa,Qwen3PreTrainedModel:()=>Ka,Qwen3VLForCausalLM:()=>Ja,Qwen3VLForConditionalGeneration:()=>ws,Qwen3VLMoeForCausalLM:()=>Px,Qwen3VLMoeForConditionalGeneration:()=>Cx,Qwen3VLProcessor:()=>Rf,Qwen3_5ForCausalLM:()=>Za,Qwen3_5ForConditionalGeneration:()=>fn,Qwen3_5MoeForCausalLM:()=>Lx,Qwen3_5MoeForConditionalGeneration:()=>zx,RFDetrForObjectDetection:()=>Dx,RFDetrModel:()=>Rx,RFDetrObjectDetectionOutput:()=>Bc,RFDetrPreTrainedModel:()=>ti,RTDetrForObjectDetection:()=>am,RTDetrImageProcessor:()=>pf,RTDetrModel:()=>om,RTDetrObjectDetectionOutput:()=>sr,RTDetrPreTrainedModel:()=>To,RTDetrV2ForObjectDetection:()=>Yx,RTDetrV2Model:()=>Kx,RTDetrV2ObjectDetectionOutput:()=>Fc,RTDetrV2PreTrainedModel:()=>ri,RawAudio:()=>Wn,RawImage:()=>Ke,RawVideo:()=>Au,RawVideoFrame:()=>Ji,RepetitionPenaltyLogitsProcessor:()=>Zl,ResNetForImageClassification:()=>$x,ResNetModel:()=>Nx,ResNetPreTrainedModel:()=>ei,RoFormerForMaskedLM:()=>Wx,RoFormerForQuestionAnswering:()=>Xx,RoFormerForSequenceClassification:()=>Vx,RoFormerForTokenClassification:()=>Hx,RoFormerModel:()=>qx,RoFormerPreTrainedModel:()=>$r,RoFormerTokenizer:()=>Zp,RobertaForMaskedLM:()=>Bx,RobertaForQuestionAnswering:()=>Gx,RobertaForSequenceClassification:()=>Fx,RobertaForTokenClassification:()=>jx,RobertaModel:()=>Ux,RobertaPreTrainedModel:()=>Nr,RobertaTokenizer:()=>Jp,Sam2ImageProcessor:()=>Jn,Sam2ImageSegmentationOutput:()=>qc,Sam2Model:()=>si,Sam2PreTrainedModel:()=>Wc,Sam2Processor:()=>Hl,Sam2VideoProcessor:()=>Df,Sam3ImageProcessor:()=>Jn,Sam3TrackerModel:()=>Zx,SamImageProcessor:()=>Jn,SamImageSegmentationOutput:()=>jc,SamModel:()=>Qx,SamPreTrainedModel:()=>Gc,SamProcessor:()=>ro,SapiensFeatureExtractor:()=>df,SapiensForDepthEstimation:()=>ty,SapiensForNormalEstimation:()=>ry,SapiensForSemanticSegmentation:()=>ey,SapiensImageProcessor:()=>jl,SapiensPreTrainedModel:()=>_n,SeamlessM4TFeatureExtractor:()=>xd,SegformerFeatureExtractor:()=>ff,SegformerForImageClassification:()=>ny,SegformerForSemanticSegmentation:()=>oy,SegformerImageProcessor:()=>Gl,SegformerModel:()=>sy,SegformerPreTrainedModel:()=>mn,SiglipImageProcessor:()=>_f,SiglipModel:()=>ay,SiglipPreTrainedModel:()=>ni,SiglipTextModel:()=>oi,SiglipTokenizer:()=>ed,SiglipVisionModel:()=>iy,SmolLM3ForCausalLM:()=>cy,SmolLM3Model:()=>ly,SmolLM3PreTrainedModel:()=>ai,SmolVLMImageProcessor:()=>$l,SmolVLMProcessor:()=>Vl,SnacDecoderModel:()=>li,SnacEncoderModel:()=>ii,SnacFeatureExtractor:()=>yd,SnacModel:()=>uy,SnacPreTrainedModel:()=>hn,SolarOpenForCausalLM:()=>dy,SolarOpenModel:()=>py,SolarOpenPreTrainedModel:()=>ci,SpeechT5FeatureExtractor:()=>bd,SpeechT5ForSpeechToText:()=>_y,SpeechT5ForTextToSpeech:()=>my,SpeechT5HifiGan:()=>hy,SpeechT5Model:()=>fy,SpeechT5PreTrainedModel:()=>gn,SpeechT5Processor:()=>Uf,SpeechT5Tokenizer:()=>td,SqueezeBertForMaskedLM:()=>wy,SqueezeBertForQuestionAnswering:()=>yy,SqueezeBertForSequenceClassification:()=>xy,SqueezeBertModel:()=>gy,SqueezeBertPreTrainedModel:()=>xs,SqueezeBertTokenizer:()=>rd,StableLmForCausalLM:()=>vy,StableLmModel:()=>by,StableLmPreTrainedModel:()=>ui,Starcoder2ForCausalLM:()=>Ey,Starcoder2Model:()=>ky,Starcoder2PreTrainedModel:()=>pi,StoppingCriteria:()=>Ar,StoppingCriteriaList:()=>Ks,StyleTextToSpeech2Model:()=>Ay,StyleTextToSpeech2PreTrainedModel:()=>Vc,SummarizationPipeline:()=>Pi,SupertonicForConditionalGeneration:()=>di,SupertonicPreTrainedModel:()=>Hc,SuppressTokensAtBeginLogitsProcessor:()=>Xs,Swin2SRForImageSuperResolution:()=>Iy,Swin2SRImageProcessor:()=>mf,Swin2SRModel:()=>Oy,Swin2SRPreTrainedModel:()=>fi,SwinForImageClassification:()=>Sy,SwinForSemanticSegmentation:()=>Ty,SwinModel:()=>My,SwinPreTrainedModel:()=>wn,T5ForConditionalGeneration:()=>Py,T5Model:()=>Cy,T5PreTrainedModel:()=>_i,T5Tokenizer:()=>sd,TableTransformerForObjectDetection:()=>Ly,TableTransformerModel:()=>zy,TableTransformerObjectDetectionOutput:()=>Xc,TableTransformerPreTrainedModel:()=>mi,TemperatureLogitsWarper:()=>nc,Tensor:()=>N,Text2TextGenerationPipeline:()=>fr,TextClassificationPipeline:()=>Ti,TextGenerationPipeline:()=>Li,TextStreamer:()=>P0,TextToAudioPipeline:()=>Ui,TokenClassificationPipeline:()=>Oi,TokenizersBackend:()=>q,TopKLogitsWarper:()=>R1,TopPLogitsWarper:()=>$1,TrOCRForCausalLM:()=>Ny,TrOCRPreTrainedModel:()=>Kc,TranslationPipeline:()=>zi,UltravoxModel:()=>_s,UltravoxPreTrainedModel:()=>Mc,UltravoxProcessor:()=>Bf,UniSpeechForCTC:()=>Ry,UniSpeechForSequenceClassification:()=>Dy,UniSpeechModel:()=>$y,UniSpeechPreTrainedModel:()=>xn,UniSpeechSatForAudioFrameClassification:()=>jy,UniSpeechSatForCTC:()=>By,UniSpeechSatForSequenceClassification:()=>Fy,UniSpeechSatModel:()=>Uy,UniSpeechSatPreTrainedModel:()=>ys,VLChatProcessor:()=>Mf,VLMImageProcessor:()=>Hd,VaultGemmaForCausalLM:()=>qy,VaultGemmaModel:()=>Gy,VaultGemmaPreTrainedModel:()=>hi,ViTFeatureExtractor:()=>hf,ViTForImageClassification:()=>Hy,ViTImageProcessor:()=>ql,ViTMAEModel:()=>Xy,ViTMAEPreTrainedModel:()=>Yc,ViTMSNForImageClassification:()=>Yy,ViTMSNModel:()=>Ky,ViTMSNPreTrainedModel:()=>wi,ViTModel:()=>Vy,ViTPreTrainedModel:()=>gi,VisionEncoderDecoderModel:()=>Wy,VitMatteForImageMatting:()=>Qy,VitMatteImageProcessor:()=>gf,VitMattePreTrainedModel:()=>Qc,VitPoseForPoseEstimation:()=>Jy,VitPoseImageProcessor:()=>wf,VitPosePreTrainedModel:()=>Jc,VitsModel:()=>Zy,VitsModelOutput:()=>Zc,VitsPreTrainedModel:()=>eu,VitsTokenizer:()=>nd,VoxtralForConditionalGeneration:()=>e0,VoxtralProcessor:()=>jf,VoxtralRealtimeFeatureExtractor:()=>Ed,VoxtralRealtimeForConditionalGeneration:()=>xi,VoxtralRealtimePreTrainedModel:()=>tu,VoxtralRealtimeProcessor:()=>qf,Wav2Vec2BertForCTC:()=>r0,Wav2Vec2BertForSequenceClassification:()=>s0,Wav2Vec2BertModel:()=>t0,Wav2Vec2BertPreTrainedModel:()=>yn,Wav2Vec2CTCTokenizer:()=>od,Wav2Vec2FeatureExtractor:()=>vd,Wav2Vec2ForAudioFrameClassification:()=>ng,Wav2Vec2ForCTC:()=>rg,Wav2Vec2ForSequenceClassification:()=>sg,Wav2Vec2Model:()=>tg,Wav2Vec2PreTrainedModel:()=>Wt,Wav2Vec2Processor:()=>Wf,Wav2Vec2ProcessorWithLM:()=>Vf,WavLMForAudioFrameClassification:()=>l0,WavLMForCTC:()=>o0,WavLMForSequenceClassification:()=>a0,WavLMForXVector:()=>i0,WavLMModel:()=>n0,WavLMPreTrainedModel:()=>Rr,WeSpeakerFeatureExtractor:()=>kd,WeSpeakerResNetModel:()=>c0,WeSpeakerResNetPreTrainedModel:()=>su,WhisperFeatureExtractor:()=>Ad,WhisperForConditionalGeneration:()=>nu,WhisperModel:()=>p0,WhisperPreTrainedModel:()=>yi,WhisperProcessor:()=>Hf,WhisperTextStreamer:()=>nv,WhisperTimeStampLogitsProcessor:()=>Ql,WhisperTokenizer:()=>ad,XLMForQuestionAnswering:()=>g0,XLMForSequenceClassification:()=>m0,XLMForTokenClassification:()=>h0,XLMModel:()=>f0,XLMPreTrainedModel:()=>Dr,XLMRobertaForMaskedLM:()=>x0,XLMRobertaForQuestionAnswering:()=>v0,XLMRobertaForSequenceClassification:()=>y0,XLMRobertaForTokenClassification:()=>b0,XLMRobertaModel:()=>w0,XLMRobertaPreTrainedModel:()=>Ur,XLMRobertaTokenizer:()=>id,XLMTokenizer:()=>ld,XLMWithLMHeadModel:()=>_0,XVectorOutput:()=>ru,YolosFeatureExtractor:()=>xf,YolosForObjectDetection:()=>E0,YolosImageProcessor:()=>Wl,YolosModel:()=>k0,YolosObjectDetectionOutput:()=>ou,YolosPreTrainedModel:()=>bi,YoutuForCausalLM:()=>M0,YoutuModel:()=>A0,YoutuPreTrainedModel:()=>vi,ZeroShotAudioClassificationPipeline:()=>Ri,ZeroShotClassificationPipeline:()=>Ni,ZeroShotImageClassificationPipeline:()=>Gi,ZeroShotObjectDetectionPipeline:()=>Wi,cat:()=>ve,cos_sim:()=>cA,dot:()=>Ab,env:()=>fe,full:()=>qe,full_like:()=>Fn,interpolate:()=>hp,interpolate_4d:()=>xt,layer_norm:()=>OL,load_image:()=>cM,load_video:()=>oS,log_softmax:()=>Qu,matmul:()=>y1,mean:()=>Ml,mean_pooling:()=>b1,ones:()=>Je,ones_like:()=>Sl,permute:()=>K2,pipeline:()=>RN,quantize_embeddings:()=>E1,rand:()=>IL,randn:()=>k1,random:()=>Vr,read_audio:()=>pd,rfft:()=>TL,slice:()=>Al,softmax:()=>Ce,stack:()=>Tt,std_mean:()=>gp,topk:()=>Gt,zeros:()=>wp,zeros_like:()=>xp});module.exports=yI(BN);var fE=yr(require("fs"),1),Ss=yr(require("path"),1),_E=yr(require("url"),1),LI={},bI="4.0.0-next.9",lb=typeof self<"u",On=!wE(fE.default),mE=!wE(Ss.default),Du=lb&&"caches"in self,vI=typeof globalThis.Deno<"u",jN=typeof globalThis.Bun<"u",Bu=vI&&Du&&!On,hE=typeof process<"u",gE=hE&&process?.release?.name==="node"&&!Bu,cb=typeof window<"u"&&typeof window.document<"u",ub=lb&&["DedicatedWorkerGlobalScope","ServiceWorkerGlobalScope","SharedWorkerGlobalScope"].includes(self.constructor?.name),kI=cb||ub||Bu,EI=gE||typeof navigator<"u"&&"gpu"in navigator,AI=typeof navigator<"u"&&"ml"in navigator,MI=typeof crypto<"u"&&typeof crypto.getRandomValues=="function",SI=typeof chrome<"u"&&typeof chrome.runtime<"u"&&typeof chrome.runtime.id=="string",TI=typeof ServiceWorkerGlobalScope<"u"&&lb&&self instanceof ServiceWorkerGlobalScope,OI=()=>{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},II=OI(),ie=Object.freeze({IS_BROWSER_ENV:cb,IS_WEBWORKER_ENV:ub,IS_WEB_ENV:kI,IS_SERVICE_WORKER_ENV:TI,IS_DENO_WEB_RUNTIME:Bu,IS_WEB_CACHE_AVAILABLE:Du,IS_WEBGPU_AVAILABLE:EI,IS_WEBNN_AVAILABLE:AI,IS_SAFARI:II,IS_PROCESS_AVAILABLE:hE,IS_NODE_ENV:gE,IS_FS_AVAILABLE:On,IS_PATH_AVAILABLE:mE,IS_CRYPTO_AVAILABLE:MI,IS_CHROME_AVAILABLE:SI}),pb=On&&mE,Uu="./";if(pb){let t=Object(LI).url;t?Uu=Ss.default.dirname(Ss.default.dirname(_E.default.fileURLToPath(t))):typeof __dirname<"u"&&(Uu=Ss.default.dirname(__dirname))}var CI=pb?Ss.default.join(Uu,"/.cache/"):null,pE="/models/",PI=pb?Ss.default.join(Uu,pE):pE,zI=typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):void 0,St=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),dE=St.WARNING,fe={version:bI,backends:{onnx:{}},get logLevel(){return dE},set logLevel(t){dE=t,fe.backends.onnx?.setLogLevel?.(t)},allowRemoteModels:!0,remoteHost:"https://huggingface.co/",remotePathTemplate:"{model}/resolve/{revision}/",allowLocalModels:!(cb||ub||Bu),localModelPath:PI,useFS:On,useBrowserCache:Du,useFSCache:On,cacheDir:CI,useCustomCache:!1,customCache:null,useWasmCache:Du||On,cacheKey:"transformers-cache",experimental_useCrossOriginStorage:!1,fetch:zI};function wE(t){return Object.keys(t).length===0}function br(t,e){t&&t(e)}function xE(t){return Number.isInteger(t)||typeof t=="bigint"}function db(t){return t==null||t===-1}function fb(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 yE(...t){return t.reduce((e,r)=>e.flatMap(s=>r.map(n=>[s,n])))}function In(t,e){return Math.abs((t+e)%(2*e)-e)}function Ye(t,e){return Object.assign({},...e.map(r=>{if(t[r]!==void 0)return{[r]:t[r]}}))}function bE(t,e){let r=0;for(let s of t)s===e&&++r;return r}var Z={error(...t){fe.logLevel<=St.ERROR&&console.error(...t)},warn(...t){fe.logLevel<=St.WARNING&&console.warn(...t)},info(...t){fe.logLevel<=St.INFO&&console.log(...t)},debug(...t){fe.logLevel<=St.DEBUG&&console.log(...t)},log(...t){this.info(...t)}};var NI=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}},vE=NI,$I=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}},RI=$I,OE=(()=>{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]]))})(),DI=t=>Object.fromEntries(Object.entries(t).map(([e,r])=>[r,e])),UI=DI(OE),kE=".,!?\u2026\u3002\uFF0C\u3001\u0964\u06D4\u060C",BI=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|[${kE}])]+`,` ?[^\\s${kE}]+`]]),Fu="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",mb=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"),ju=(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 BI)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=FI(t.String);return new RegExp(e?r:`(${r})`,"gu")}else return console.warn("Unknown pattern type:",t),null},FI=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),jI=(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},GI=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,qI=t=>Number.isInteger(t)||typeof t=="bigint",WI=t=>{let e=0;for(let r of t)++e;return e},VI=t=>IE(t.toLowerCase()),Xt=(...t)=>Array.prototype.concat.apply([],t),hb=t=>new Map(Object.entries(t)),HI=(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},IE=t=>t.replace(/\p{M}/gu,""),EE=(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},XI=t=>t.match(/\S+/g)||[],KI=class{constructor(){let t=function(...e){return t._call(...e)};return Object.setPrototypeOf(t,new.target.prototype)}},ol=KI,YI=class extends ol{constructor(t){super(),this.config=t}_call(t){return this.normalize(t)}},vr=YI,QI=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);GI(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}},JI=QI,ZI=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}},eC=ZI,tC=class extends vr{constructor(t){super(t),this.normalizers=(t.normalizers??[]).map(e=>CE(e))}normalize(t){return this.normalizers.reduce((e,r)=>r?r.normalize(e):e,t)}},rC=tC,sC=class extends vr{normalize(t){let e=ju(this.config.pattern??{});return e===null?t:t.replaceAll(e,this.config.content??"")}},nC=sC,oC=class extends vr{constructor(){super(...arguments),this.form="NFC"}normalize(t){return t=t.normalize(this.form),t}},Gu=oC,aC=class extends Gu{constructor(){super(...arguments),this.form="NFC"}},iC=aC,lC=class extends Gu{constructor(){super(...arguments),this.form="NFD"}},cC=lC,uC=class extends Gu{constructor(){super(...arguments),this.form="NFKC"}},pC=uC,dC=class extends Gu{constructor(){super(...arguments),this.form="NFKD"}},fC=dC,_C=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}},mC=_C,hC=class extends vr{normalize(t){return IE(t)}},gC=hC,wC=class extends vr{normalize(t){return t.toLowerCase()}},xC=wC,yC=class extends vr{normalize(t){return t=this.config.prepend+t,t}},bC=yC;function vC(t){if(t===null)return null;switch(t.type){case"BertNormalizer":return new JI(t);case"Precompiled":return new eC(t);case"Sequence":return new rC(t);case"Replace":return new nC(t);case"NFC":return new iC(t);case"NFD":return new cC(t);case"NFKC":return new pC(t);case"NFKD":return new fC(t);case"Strip":return new mC(t);case"StripAccents":return new gC(t);case"Lowercase":return new xC(t);case"Prepend":return new bC(t);default:throw new Error(`Unknown Normalizer type: ${t.type}`)}}var CE=vC,kC=class extends ol{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)}},Kt=kC,EC=class extends Kt{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=OE,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(""))}},AC=EC,MC=class extends Kt{pre_tokenize_text(t,e){return t.match(/\w+|[^\w\s]+/g)||[]}},SC=MC,TC=class extends Kt{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]}},OC=TC,IC=class extends Kt{constructor(t){super(),this.config=t,this.pattern=ju(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):HI(t,this.pattern)}},CC=IC,PC=class extends Kt{constructor(t){super(),this.config=t,this.pattern=new RegExp(`[^${Fu}]+|[${Fu}]+`,"gu")}pre_tokenize_text(t){return t.match(this.pattern)||[]}},zC=PC,LC=class extends Kt{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)||[]}},NC=LC,$C=class extends Kt{constructor(){super(),this.pattern=new RegExp(`[^\\s${Fu}]+|[${Fu}]`,"gu")}pre_tokenize_text(t,e){return t.trim().match(this.pattern)||[]}},RC=$C,DC=class extends Kt{constructor(t){super(),this.config=t,this.pattern=ju(this.config.pattern??{}),this.content=this.config.content??""}pre_tokenize_text(t){return this.pattern===null?[t]:[t.replaceAll(this.pattern,this.config.content??"")]}},UC=DC,BC=class extends Kt{constructor(t){super(),this.tokenizers=(t.pretokenizers??[]).map(e=>PE(e))}pre_tokenize_text(t,e){return this.tokenizers.reduce((r,s)=>s?s.pre_tokenize(r,e):r,[t])}},FC=BC,jC=class extends Kt{pre_tokenize_text(t){return XI(t)}},GC=jC,qC=class extends Kt{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}},WC=qC;function VC(t){if(t===null)return null;switch(t.type){case"BertPreTokenizer":return new RC;case"Sequence":return new FC(t);case"Whitespace":return new SC;case"WhitespaceSplit":return new GC;case"Metaspace":return new OC(t);case"ByteLevel":return new AC(t);case"Split":return new CC(t);case"Punctuation":return new zC(t);case"Digits":return new NC(t);case"Replace":return new UC(t);case"FixedLength":return new WC(t);default:throw new Error(`Unknown PreTokenizer type: ${t.type}`)}}var PE=VC,HC=class extends ol{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=jI(e,this.tokens_to_ids,this.unk_token_id)),e}},qu=HC,XC=class extends qu{constructor(t){super(t),this.max_input_chars_per_word=100,this.tokens_to_ids=hb(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}},AE=XC,ME=class zE{constructor(e,r){this.is_leaf=e,this.children=r}static default(){return new zE(!1,new Map)}},KC=class{constructor(){this.root=ME.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=ME.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)}}},YC=KC,_b=class LE{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 LE(this.token_id,this.node_id,this.pos,this.length,this.score);return e.prev=this.prev,e.backtrace_score=this.backtrace_score,e}},QC=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 _b(this.bos_token_id??0,0,0,0,0),n=new _b(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 _b(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)}},JC=QC;function ZC(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 eP=class extends qu{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=ZC(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new YC,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],f=WI(l);t.insert(s,f,p,c),!n&&f===r&&(n=!0)}n||t.insert(s,r,this.unk_score,this.unk_token_id),s+=r}}tokenize(t){let e=new JC(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}},SE=eP,tP=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}},rP=tP,sP=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()}},nP=sP,oP=class extends qu{constructor(t){super(t),this.tokens_to_ids=hb(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 nP(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 rP((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}},TE=oP,aP=class extends qu{constructor(t,e){super(t);let r=t.vocab;this.tokens_to_ids=hb(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}},iP=aP;function lP(t,e){switch(t.type){case"WordPiece":return new AE(t);case"Unigram":return new SE(t,e.eos_token);case"BPE":return new TE(t);default:if(t.vocab)return Array.isArray(t.vocab)?new SE(t,e.eos_token):Object.hasOwn(t,"continuing_subword_prefix")&&Object.hasOwn(t,"unk_token")?Object.hasOwn(t,"merges")?new TE(t):new AE(t):new iP(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 cP=lP,uP=class extends ol{constructor(t){super(),this.config=t}_call(t,...e){return this.post_process(t,...e)}},al=uP,pP=class extends al{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=Xt(n,t),o=Xt(o,new Array(t.length).fill(a.Sequence.type_id))):a.Sequence.id==="B"&&(n=Xt(n,e),o=Xt(o,new Array(e.length).fill(a.Sequence.type_id))));return{tokens:n,token_type_ids:o}}},dP=pP,fP=class extends al{post_process(t,e=null){return{tokens:t,tokens_pair:e}}},_P=fP,mP=class extends al{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e=null,r=!0){r&&(t=Xt([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=Xt(t,n,e,o),s=Xt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},hP=mP,gP=class extends al{constructor(t){super(t),this.sep=t.sep,this.cls=t.cls}post_process(t,e,r=!0){r&&(t=Xt([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=Xt(t,n,e,o),s=Xt(s,new Array(e.length+n.length+o.length).fill(1))}return{tokens:t,token_type_ids:s}}},wP=gP,xP=class extends al{constructor(t){super(t),this.processors=(t.processors??[]).map(e=>NE(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}},yP=xP;function bP(t){if(t===null)return null;switch(t.type){case"TemplateProcessing":return new dP(t);case"ByteLevel":return new _P(t);case"BertProcessing":return new hP(t);case"RobertaProcessing":return new wP(t);case"Sequence":return new yP(t);default:throw new Error(`Unknown PostProcessor type: ${t.type}`)}}var NE=bP,vP=class extends ol{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=vP,kP=class extends Dt{constructor(t){super(t),this.byte_decoder=UI,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}},EP=kP,AP=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=mb(e)),e})}},MP=AP,SP=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}},TP=SP,OP=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?"":" "))}},IP=OP,CP=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=mb(s).replaceAll(this.word_delimiter_token," ").trim()),s}decode_chain(t){return[this.convert_tokens_to_string(t)]}},PP=CP,zP=class extends Dt{constructor(t){super(t),this.decoders=(t.decoders??[]).map(e=>$E(e))}decode_chain(t){return this.decoders.reduce((e,r)=>r.decode_chain(e),t)}},LP=zP,NP=class extends Dt{decode_chain(t){let e=ju(this.config.pattern),r=this.config.content??"";return e===null?t:t.map(s=>s.replaceAll(e,r))}},$P=NP,RP=class extends Dt{decode_chain(t){return[t.join("")]}},DP=RP,UP=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)})}},BP=UP,FP=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}},jP=FP;function GP(t){if(t===null)return null;switch(t.type){case"ByteLevel":return new EP(t);case"WordPiece":return new MP(t);case"Metaspace":return new TP(t);case"BPEDecoder":return new IP(t);case"CTC":return new PP(t);case"Sequence":return new LP(t);case"Replace":return new $P(t);case"Fuse":return new DP(t);case"Strip":return new BP(t);case"ByteFallback":return new jP(t);default:throw new Error(`Unknown Decoder type: ${t.type}`)}}var $E=GP,qP=class{constructor(t,e){let r=EE(t,"Tokenizer",["model","decoder","post_processor","pre_tokenizer","normalizer"]);if(r)throw new Error(r);let s=EE(e,"Config");if(s)throw new Error(s);this.tokenizer=t,this.config=e,this.normalizer=CE(this.tokenizer.normalizer),this.pre_tokenizer=PE(this.tokenizer.pre_tokenizer),this.model=cP(this.tokenizer.model,this.config),this.post_processor=NE(this.tokenizer.post_processor),this.decoder=$E(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 RI(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 vE(n),this.splitter_normalized=new vE(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||!qI(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=mb(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=VI(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:Xt(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}},RE=qP;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"}),Ut=class{constructor(t,e){this.value=t,this.type=e}};function DE(t){return/\w/.test(t)}function il(t){return/[0-9]/.test(t)}function UE(t){return/\s/.test(t)}var WP=[["{%",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]],VP=new Map([["n",`
|
|
3
|
+
`],["t"," "],["r","\r"],["b","\b"],["f","\f"],["v","\v"],["'","'"],['"','"'],["\\","\\"]]);function HP(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 XP(t,e={}){let r=[],s=HP(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 f=s[n++],_=VP.get(f);if(_===void 0)throw new SyntaxError(`Unexpected escaped character: ${f}`);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&&UE(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 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 Ut(f,D.Text));continue}}if(s[n]==="{"&&s[n+1]==="#"){n+=2;let f=s[n]==="-";f&&++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)),f&&i(),r.push(new Ut(_,D.Comment)),n+=2,m&&l();continue}if(s.slice(n,n+3)==="{%-"){i(),r.push(new Ut("{%",D.OpenStatement)),n+=3;continue}if(s.slice(n,n+3)==="{{-"){i(),r.push(new Ut("{{",D.OpenExpression)),o=0,n+=3;continue}if(a(UE),s.slice(n,n+3)==="-%}"){r.push(new Ut("%}",D.CloseStatement)),n+=3,l();continue}if(s.slice(n,n+3)==="-}}"){r.push(new Ut("}}",D.CloseExpression)),n+=3,l();continue}let p=s[n];if(p==="-"||p==="+"){let f=r.at(-1)?.type;if(f===D.Text||f===void 0)throw new SyntaxError(`Unexpected character: ${p}`);switch(f){case D.Identifier:case D.NumericLiteral:case D.StringLiteral:case D.CloseParen:case D.CloseSquareBracket:break;default:{++n;let _=a(il);r.push(new Ut(`${p}${_}`,_.length>0?D.NumericLiteral:D.UnaryOperator));continue}}}for(let[f,_]of WP){if(f==="}}"&&o>0)continue;if(s.slice(n,n+f.length)===f){r.push(new Ut(f,_)),_===D.OpenExpression?o=0:_===D.OpenCurlyBracket?++o:_===D.CloseCurlyBracket&&--o,n+=f.length;continue e}}if(p==="'"||p==='"'){++n;let f=a(_=>_!==p);r.push(new Ut(f,D.StringLiteral)),++n;continue}if(il(p)){let f=a(il);if(s[n]==="."&&il(s[n+1])){++n;let _=a(il);f=`${f}.${_}`}r.push(new Ut(f,D.NumericLiteral));continue}if(DE(p)){let f=a(DE);r.push(new Ut(f,D.Identifier));continue}throw new SyntaxError(`Unexpected character: ${p}`)}return r}var Qt=class{type="Statement"},KP=class extends Qt{constructor(t){super(),this.body=t}type="Program"},YP=class extends Qt{constructor(t,e,r){super(),this.test=t,this.body=e,this.alternate=r}type="If"},QP=class extends Qt{constructor(t,e,r,s){super(),this.loopvar=t,this.iterable=e,this.body=r,this.defaultBlock=s}type="For"},JP=class extends Qt{type="Break"},ZP=class extends Qt{type="Continue"},ez=class extends Qt{constructor(t,e,r){super(),this.assignee=t,this.value=e,this.body=r}type="Set"},tz=class extends Qt{constructor(t,e,r){super(),this.name=t,this.args=e,this.body=r}type="Macro"},rz=class extends Qt{constructor(t){super(),this.value=t}type="Comment"},It=class extends Qt{type="Expression"},sz=class extends It{constructor(t,e,r){super(),this.object=t,this.property=e,this.computed=r}type="MemberExpression"},BE=class extends It{constructor(t,e){super(),this.callee=t,this.args=e}type="CallExpression"},Cn=class extends It{constructor(t){super(),this.value=t}type="Identifier"},Pn=class extends It{constructor(t){super(),this.value=t}type="Literal"},nz=class extends Pn{type="IntegerLiteral"},oz=class extends Pn{type="FloatLiteral"},FE=class extends Pn{type="StringLiteral"},az=class extends Pn{type="ArrayLiteral"},jE=class extends Pn{type="TupleLiteral"},iz=class extends Pn{type="ObjectLiteral"},ll=class extends It{constructor(t,e,r){super(),this.operator=t,this.left=e,this.right=r}type="BinaryExpression"},lz=class extends It{constructor(t,e){super(),this.operand=t,this.filter=e}type="FilterExpression"},cz=class extends Qt{constructor(t,e){super(),this.filter=t,this.body=e}type="FilterStatement"},uz=class extends It{constructor(t,e){super(),this.lhs=t,this.test=e}type="SelectExpression"},pz=class extends It{constructor(t,e,r){super(),this.operand=t,this.negate=e,this.test=r}type="TestExpression"},dz=class extends It{constructor(t,e){super(),this.operator=t,this.argument=e}type="UnaryExpression"},fz=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"},_z=class extends It{constructor(t,e){super(),this.key=t,this.value=e}type="KeywordArgumentExpression"},mz=class extends It{constructor(t){super(),this.argument=t}type="SpreadExpression"},hz=class extends Qt{constructor(t,e,r){super(),this.call=t,this.callerArgs=e,this.body=r}type="CallStatement"},gz=class extends It{constructor(t,e,r){super(),this.condition=t,this.trueExpr=e,this.falseExpr=r}type="Ternary"};function wz(t){let e=new KP([]),r=0;function s(z,$){let U=t[r++];if(!U||U.type!==z)throw new Error(`Parser Error: ${$}. ${U.type} !== ${z}.`);return U}function n(z){if(!l(z))throw new SyntaxError(`Expected ${z}`);++r}function o(){switch(t[r].type){case D.Comment:return new rz(t[r++].value);case D.Text:return c();case D.OpenStatement:return p();case D.OpenExpression:return f();default:throw new SyntaxError(`Unexpected token type: ${t[r].type}`)}}function a(...z){return r+z.length<=t.length&&z.every(($,U)=>$===t[r+U].type)}function i(...z){return t[r]?.type===D.OpenStatement&&t[r+1]?.type===D.Identifier&&z.includes(t[r+1]?.value)}function l(...z){return r+z.length<=t.length&&z.every(($,U)=>t[r+U].type==="Identifier"&&$===t[r+U].value)}function c(){return new FE(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 z=t[r].value,$;switch(z){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,$=k(),s(D.OpenStatement,"Expected {% token"),n("endfor"),s(D.CloseStatement,"Expected %} token");break;case"call":{++r;let U=null;a(D.OpenParen)&&(U=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 BE(J,xe);$=new hz(Ve,U,ue);break}case"break":++r,s(D.CloseStatement,"Expected closing statement token"),$=new JP;break;case"continue":++r,s(D.CloseStatement,"Expected closing statement token"),$=new ZP;break;case"filter":{++r;let U=ae();U instanceof Cn&&a(D.OpenParen)&&(U=X(U)),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 cz(U,J);break}default:throw new SyntaxError(`Unknown statement type: ${z}`)}return $}function f(){s(D.OpenExpression,"Expected opening expression token");let z=E();return s(D.CloseExpression,"Expected closing expression token"),z}function _(){let z=x(),$=null,U=[];if(a(D.Equals))++r,$=x();else{for(s(D.CloseStatement,"Expected %} token");!i("endset");)U.push(o());s(D.OpenStatement,"Expected {% token"),n("endset")}return s(D.CloseStatement,"Expected closing statement token"),new ez(z,$,U)}function m(){let z=E();s(D.CloseStatement,"Expected closing statement token");let $=[],U=[];for(;!i("elif","else","endif");)$.push(o());if(i("elif")){++r,++r;let J=m();U.push(J)}else if(i("else"))for(++r,++r,s(D.CloseStatement,"Expected closing statement token");!i("endif");)U.push(o());return new YP(z,$,U)}function w(){let z=ae();if(z.type!=="Identifier")throw new SyntaxError("Expected identifier following macro statement");let $=B();s(D.CloseStatement,"Expected closing statement token");let U=[];for(;!i("endmacro");)U.push(o());return new tz(z,$,U)}function x(z=!1){let $=z?ae:E,U=[$()],J=a(D.Comma);for(;J&&(++r,U.push($()),!!a(D.Comma)););return J?new jE(U):U[0]}function k(){let z=x(!0);if(!(z instanceof Cn||z instanceof jE))throw new SyntaxError(`Expected identifier/tuple for the loop variable, got ${z.type} instead`);if(!l("in"))throw new SyntaxError("Expected `in` keyword following loop variable");++r;let $=E();s(D.CloseStatement,"Expected closing statement token");let U=[];for(;!i("endfor","else");)U.push(o());let J=[];if(i("else"))for(++r,++r,s(D.CloseStatement,"Expected closing statement token");!i("endfor");)J.push(o());return new QP(z,$,U,J)}function E(){return A()}function A(){let z=T();if(l("if")){++r;let $=T();if(l("else")){++r;let U=A();return new gz($,z,U)}else return new uz(z,$)}return z}function T(){let z=S();for(;l("or");){let $=t[r];++r;let U=S();z=new ll($,z,U)}return z}function S(){let z=P();for(;l("and");){let $=t[r];++r;let U=P();z=new ll($,z,U)}return z}function P(){let z;for(;l("not");){let $=t[r];++r;let U=P();z=new dz($,U)}return z??O()}function O(){let z=v();for(;;){let $;if(l("not","in"))$=new Ut("not in",D.Identifier),r+=2;else if(l("in"))$=t[r++];else if(a(D.ComparisonBinaryOperator))$=t[r++];else break;let U=v();z=new ll($,z,U)}return z}function v(){let z=R();for(;a(D.AdditiveBinaryOperator);){let $=t[r];++r;let U=R();z=new ll($,z,U)}return z}function W(){let z=K(ae());return a(D.OpenParen)?X(z):z}function X(z){let $=new BE(z,B());return $=K($),a(D.OpenParen)&&($=X($)),$}function B(){s(D.OpenParen,"Expected opening parenthesis for arguments list");let z=H();return s(D.CloseParen,"Expected closing parenthesis for arguments list"),z}function H(){let z=[];for(;!a(D.CloseParen);){let $;if(t[r].type===D.MultiplicativeBinaryOperator&&t[r].value==="*"){++r;let U=E();$=new mz(U)}else if($=E(),a(D.Equals)){if(++r,!($ instanceof Cn))throw new SyntaxError("Expected identifier for keyword argument");let U=E();$=new _z($,U)}z.push($),a(D.Comma)&&++r}return z}function G(){let z=[],$=!1;for(;!a(D.CloseSquareBracket);)a(D.Colon)?(z.push(void 0),++r,$=!0):(z.push(E()),a(D.Colon)&&(++r,$=!0));if(z.length===0)throw new SyntaxError("Expected at least one argument for member/slice expression");if($){if(z.length>3)throw new SyntaxError("Expected 0-3 arguments for slice expression");return new fz(...z)}return z[0]}function K(z){for(;a(D.Dot)||a(D.OpenSquareBracket);){let $=t[r];++r;let U,J=$.type===D.OpenSquareBracket;if(J)U=G(),s(D.CloseSquareBracket,"Expected closing square bracket");else if(U=ae(),U.type!=="Identifier")throw new SyntaxError("Expected identifier following dot operator");z=new sz(z,U,J)}return z}function R(){let z=C();for(;a(D.MultiplicativeBinaryOperator);){let $=t[r++],U=C();z=new ll($,z,U)}return z}function C(){let z=re();for(;l("is");){++r;let $=l("not");$&&++r;let U=ae();if(!(U instanceof Cn))throw new SyntaxError("Expected identifier for the test");z=new pz(z,$,U)}return z}function re(){let z=W();for(;a(D.Pipe);){++r;let $=ae();if(!($ instanceof Cn))throw new SyntaxError("Expected identifier for the filter");a(D.OpenParen)&&($=X($)),z=new lz(z,$)}return z}function ae(){let z=t[r++];switch(z.type){case D.NumericLiteral:{let $=z.value;return $.includes(".")?new oz(Number($)):new nz(Number($))}case D.StringLiteral:{let $=z.value;for(;a(D.StringLiteral);)$+=t[r++].value;return new FE($)}case D.Identifier:return new Cn(z.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(E()),a(D.Comma)&&++r;return++r,new az($)}case D.OpenCurlyBracket:{let $=new Map;for(;!a(D.CloseCurlyBracket);){let U=E();s(D.Colon,"Expected colon between key and value in object literal");let J=E();$.set(U,J),a(D.Comma)&&++r}return++r,new iz($)}default:throw new SyntaxError(`Unexpected token: ${z.type}`)}}for(;r<t.length;)e.body.push(o());return e}function xz(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 GE(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 yz(t){return t.replace(/\b\w/g,e=>e.toUpperCase())}function bz(t){return vz(new Date,t)}function vz(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 kz(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ez(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(kz(e),"gu");return t.replaceAll(o,a=>n>0?(--n,r):a)}var qE=class extends Error{},WE=class extends Error{},lr=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 lr{type="IntegerValue"},Qe=class extends lr{type="FloatValue";toString(){return this.value%1===0?this.value.toFixed(1):this.value.toString()}},ee=class extends lr{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(yz(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(Ez(this.value,e.value,r.value,s.value))})]])},pe=class extends lr{type="BooleanValue"},Az=/[\x7f-\uffff]/g;function VE(t){return t.replace(Az,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0"))}function Os(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=VE(p)),p}case"ArrayValue":case"ObjectValue":{let p=n?" ".repeat(n):"",f=`
|
|
5
|
+
`+p.repeat(r),_=f+p;if(t.type==="ArrayValue"){let m=t.value.map(w=>Os(w,e,r+1,s));return n?`[${_}${m.join(`${l}${_}`)}${f}]`:`[${m.join(l)}]`}else{let m=Array.from(t.value.entries());i&&(m=m.sort(([x],[k])=>x.localeCompare(k)));let w=m.map(([x,k])=>{let E=JSON.stringify(x);o&&(E=VE(E));let A=`${E}${c}${Os(k,e,r+1,s)}`;return n?`${_}${A}`:A});return n?`{${w.join(l)}${f}}`:`{${w.join(l)}}`}}default:throw new Error(`Cannot convert to JSON: ${t.type}`)}}var ct=class extends lr{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 cl?(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],f=l.value[c],_=gb(p,f,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 Os(this,{},0,!1)}},cl=class extends ct{type="KeywordArgumentsValue"},ye=class extends lr{type="ArrayValue";builtins=new Map([["length",new me(this.value.length)]]);__bool__(){return new pe(this.value.length>0)}toString(){return Os(this,{},0,!1)}},HE=class extends ye{type="TupleValue"},Ge=class extends lr{type="FunctionValue"},He=class extends lr{type="NullValue"},je=class extends lr{type="UndefinedValue"},Ts=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 Qe],["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,Wu(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 Mz(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",xz),t.set("strftime_now",bz),t.set("True",!0),t.set("False",!1),t.set("None",null)}function XE(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 gb(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 Qe||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 Sz=class{global;constructor(t){this.global=t??new Ts}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 Qe)&&(s instanceof me||s instanceof Qe)){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 Qe||s instanceof Qe?new Qe(a):new me(a)}case"/":return new Qe(n/o);case"%":{let a=n%o;return r instanceof Qe||s instanceof Qe?new Qe(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(Os(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)=>gb(n,o,!1)));case"join":return new ee(t.value.map(n=>n.value).join(""));case"string":return new ee(Os(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 me(isNaN(n)?0:n)}case"float":{let n=parseFloat(t.value);return new
|
|
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 Qe(isNaN(n)?0:n)}default:throw new Error(`Unknown StringValue filter: ${s.value}`)}else if(t instanceof me||t instanceof Qe)switch(s.value){case"abs":return t instanceof me?new me(Math.abs(t.value)):new Qe(Math.abs(t.value));case"int":return new me(Math.floor(t.value));case"float":return new Qe(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 Qe(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 HE){if(c.value.length!==2)throw new Error("separators must be a tuple of two strings");let[f,_]=c.value;if(!(f instanceof ee)||!(_ instanceof ee))throw new Error("separators must be a tuple of two strings");p=[f.value,_.value]}else if(!(c instanceof He))throw new Error("If set, separators must be a tuple of two strings");return new ee(Os(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 Qe(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 Qe(l)}else{if(t instanceof me||t instanceof Qe)return t;if(t instanceof pe)return n==="int"?new me(t.value?1:0):new Qe(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=f=>{if(c instanceof He)return f;let _=c instanceof me?String(c.value):c.value;return XE(f,_)};return new ye(t.value.slice().sort((f,_)=>{let m=p(f),w=p(_),x=gb(m,w,l.value);return i.value?-x:x}))}case"selectattr":case"rejectattr":{let o=n==="selectattr";if(t.value.some(f=>!(f instanceof ct)))throw new Error(`\`${n}\` can only be applied to array of objects`);if(s.args.some(f=>f.type!=="StringLiteral"))throw new Error(`arguments of \`${n}\` must be strings`);let[a,i,l]=s.args.map(f=>this.evaluate(f,r)),c;if(i){let f=r.tests.get(i.value);if(!f)throw new Error(`Unknown test: ${i.value}`);c=f}else c=(...f)=>f[0].__bool__().value;let p=t.value.filter(f=>{let _=f.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=XE(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
8
|
`),f=" ".repeat(i.value),_=p.map((m,w)=>!l.value&&w===0||!c.value&&m.length===0?m:f+m);return new ee(_.join(`
|
|
9
|
-
`))}case"replace":{let o=t.builtins.get("replace");if(!(o instanceof
|
|
10
|
-
`,KL="{%- ",QL=" -%}";function YL(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 JL(t,e=" "){let r=typeof e=="number"?" ".repeat(e):e;return Jt(t.body,0,r).replace(/\n$/,"")}function xt(...t){return KL+t.join(" ")+QL}function Jt(t,e,r){return t.map(s=>ZL(s,e,r)).join(it)}function ZL(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 tP(t,e,r);case"Set":return rP(t,e,r);case"Macro":return sP(t,e,r);case"Break":return s+xt("break");case"Continue":return s+xt("continue");case"CallStatement":return nP(t,e,r);case"FilterStatement":return oP(t,e,r);case"Comment":return s+"{# "+t.value+" #}";default:return s+"{{- "+Ee(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+xt("if",Ee(n[0].test))+it+Jt(n[0].body,e+1,r);for(let i=1;i<n.length;++i)a+=it+s+xt("elif",Ee(n[i].test))+it+Jt(n[i].body,e+1,r);return o&&o.alternate.length>0&&(a+=it+s+xt("else")+it+Jt(o.alternate,e+1,r)),a+=it+s+xt("endif"),a}function tP(t,e,r){let s=r.repeat(e),n="";if(t.iterable.type==="SelectExpression"){let a=t.iterable;n=`${Ee(a.lhs)} if ${Ee(a.test)}`}else n=Ee(t.iterable);let o=s+xt("for",Ee(t.loopvar),"in",n)+it+Jt(t.body,e+1,r);return t.defaultBlock.length>0&&(o+=it+s+xt("else")+it+Jt(t.defaultBlock,e+1,r)),o+=it+s+xt("endfor"),o}function rP(t,e,r){let s=r.repeat(e),n=Ee(t.assignee),o=t.value?Ee(t.value):"",a=s+xt("set",`${n}${t.value?" = "+o:""}`);return t.body.length===0?a:a+it+Jt(t.body,e+1,r)+it+s+xt("endset")}function sP(t,e,r){let s=r.repeat(e),n=t.args.map(Ee).join(", ");return s+xt("macro",`${t.name.value}(${n})`)+it+Jt(t.body,e+1,r)+it+s+xt("endmacro")}function nP(t,e,r){let s=r.repeat(e),n=t.callerArgs&&t.callerArgs.length>0?`(${t.callerArgs.map(Ee).join(", ")})`:"",o=Ee(t.call),a=s+xt(`call${n}`,o)+it;return a+=Jt(t.body,e+1,r)+it,a+=s+xt("endcall"),a}function oP(t,e,r){let s=r.repeat(e),n=t.filter.type==="Identifier"?t.filter.value:Ee(t.filter),o=s+xt("filter",n)+it;return o+=Jt(t.body,e+1,r)+it,o+=s+xt("endfilter"),o}function Ee(t,e=-1){switch(t.type){case"SpreadExpression":return`*${Ee(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=YL(r),n=Ee(r.left,s),o=Ee(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"?" ":"")+Ee(r.argument,1/0)}case"CallExpression":{let r=t,s=r.args.map(Ee).join(", ");return`${Ee(r.callee)}(${s})`}case"MemberExpression":{let r=t,s=Ee(r.object);["Identifier","MemberExpression","CallExpression","StringLiteral","IntegerLiteral","FloatLiteral","ArrayLiteral","TupleLiteral","ObjectLiteral"].includes(r.object.type)||(s=`(${s})`);let n=Ee(r.property);return!r.computed&&r.property.type!=="Identifier"&&(n=`(${n})`),r.computed?`${s}[${n}]`:`${s}.${n}`}case"FilterExpression":{let r=t,s=Ee(r.operand,1/0);return r.filter.type==="CallExpression"?`${s} | ${Ee(r.filter)}`:`${s} | ${r.filter.value}`}case"SelectExpression":{let r=t;return`${Ee(r.lhs)} if ${Ee(r.test)}`}case"TestExpression":{let r=t;return`${Ee(r.operand)} is${r.negate?" not":""} ${r.test.value}`}case"ArrayLiteral":case"TupleLiteral":{let r=t.value.map(Ee),s=t.type==="ArrayLiteral"?"[]":"()";return`${s[0]}${r.join(", ")}${s[1]}`}case"ObjectLiteral":return`{${Array.from(t.value.entries()).map(([s,n])=>`${Ee(s)}: ${Ee(n)}`).join(", ")}}`;case"SliceExpression":{let r=t,s=r.start?Ee(r.start):"",n=r.stop?Ee(r.stop):"",o=r.step?`:${Ee(r.step)}`:"";return`${s}:${n}${o}`}case"KeywordArgumentExpression":{let r=t;return`${r.key.value}=${Ee(r.value)}`}case"Ternary":{let r=t,s=`${Ee(r.trueExpr)} if ${Ee(r.condition,0)} else ${Ee(r.falseExpr)}`;return e>-1?`(${s})`:s}default:throw new Error(`Unknown expression type: ${t.type}`)}}var gE=class{parsed;constructor(t){let e=mL(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=FL(e)}render(t){let e=new Cs;if(HL(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new XL(e).run(this.parsed).value}format(t){return JL(this.parsed,t?.indent||" ")}};var st=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=vr(require("fs"),1),aP={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=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",aP[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 Nn=vr(require("fs"),1),al=vr(require("path"),1);var zn=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[wE(this._random_fn,r)]}};function wE(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 zn,Xr=Object.freeze({Random:zn,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)}),xE=t=>wE(Xr.random,t);var iP=new zn,$n=class{constructor(e){this.path=e}async match(e){let r=al.default.join(this.path,e),s=new Hr(r);if(s.exists)return s}async put(e,r,s=void 0){let n=al.default.join(this.path,e),o=ie.IS_PROCESS_AVAILABLE?process.pid:Date.now(),a=iP._int32().toString(36),i=n+`.tmp.${o}.${a}`;try{let l=r.headers.get("Content-Length"),c=parseInt(l??"0"),p=0;await Nn.default.promises.mkdir(al.default.dirname(n),{recursive:!0});let f=Nn.default.createWriteStream(i),_=r.body.getReader();for(;;){let{done:m,value:w}=await _.read();if(m)break;await new Promise((k,E)=>{f.write(w,A=>{if(A){E(A);return}k()})}),p+=w.length;let x=c?p/c*100:0;s?.({progress:x,loaded:p,total:c})}await new Promise((m,w)=>{f.close(x=>x?w(x):m())}),await Nn.default.promises.rename(i,n)}catch(l){try{await Nn.default.promises.unlink(i)}catch{}throw l}}async delete(e){let r=al.default.join(this.path,e);try{return await Nn.default.promises.unlink(r),!0}catch{return!1}}};var yE={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"},Uu=100,bE=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;var B0={};function il(...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 vE(t){return!(!bE.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function kE(t,e,r){if(!r)return null;let s=yE[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${s}: "${e}".`)}async function EE(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 f=a+p.length;if(f>n){n=f;let m=new Uint8Array(n);m.set(o),o=m}o.set(p,a),a=f;let _=a/n*100;return e({progress:_,loaded:a,total:n}),l()}return await l(),o}function U0(t){return Kr(t,["blob:"])}function j0(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof B0<"u"&&B0.url)e=B0.url;else return t;return new URL(t,e).href}var ME="SHA-256",lP="experimental_transformers-hash-cache",AE=t=>({algorithm:ME,value:t}),ll=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(lP),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([AE(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([AE(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(ME,r);return Array.from(new Uint8Array(s)).map(o=>o.toString(16).padStart(2,"0")).join("")}};async function er(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&&ll.isAvailable()&&(e=new ll),!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 $n(t??fe.cacheDir)}return e}async function SE(t,...e){for(let r of e)try{let s=await t.match(r);if(s)return s}catch{continue}}var ju=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 cP=100,G0=new ju(cP);function Gu(t,e){let r=G0.get(t);if(r!==void 0)return r;let s=e().then(n=>n,n=>(G0.delete(t),Promise.reject(n)));return G0.put(t,s),s}async function uP(t){if(!Kr(t,["http:","https:"]))return null;let e=q0(t);return e.set("Range","bytes=0-0"),fe.fetch(t,{method:"GET",headers:e,cache:"no-store"})}function pr(t,e,r={}){let s=JSON.stringify([t,e,r?.revision,r?.cache_dir,r?.local_files_only]);return Gu(s,()=>pP(t,e,r))}async function pP(t,e,r){let s=await er(r?.cache_dir),{localPath:n,remoteURL:o,proposedCacheKey:a,validModelId:i}=Yr(t,e,r,s),l=await Jr(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&&!Kr(n,["http:","https:"]))try{let p=await Qr(n);if(typeof p!="string"&&p.status!==404){let f=p.headers.get("content-length"),_=p.headers.get("content-type");return{exists:!0,size:f?parseInt(f,10):void 0,contentType:_||void 0,fromCache:!1}}}catch{}if(fe.allowRemoteModels&&!r.local_files_only&&i)try{let c=await uP(o);if(c&&c.status>=200&&c.status<300){let p,f=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:f||void 0,fromCache:!1}}}catch(c){Z.warn(`Unable to fetch file metadata for "${o}": ${c}`)}return{exists:!1,fromCache:!1}}async function Qr(t){return fe.useFS&&!Kr(t,["http:","https:","blob:"])?new Hr(t instanceof URL?t.protocol==="file:"?t.pathname:t.toString():t):fe.fetch(t,{headers:q0(t)})}function q0(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};`),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 Yr(t,e,r={},s=null){let n=r.revision??"main",o=il(t,e),a=vE(t),i=a?il(fe.localModelPath,o):o,l=il(fe.remoteHost,fe.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),c=s instanceof $n?n==="main"?o:il(t,n,e):l;return{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:a}}async function Jr(t,e,r){if(t)return await SE(t,e,r)}async function dP(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=>{Z.warn(`Unable to add response to browser cache: ${i}.`)});else{let i=a.progress_callback?l=>kr(a.progress_callback,{status:"progress",name:t,file:e,...l}):void 0;await r.put(s,n,i)}}async function fP(t,e,r=!0,s={},n=!1,o=null){let{requestURL:a,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:p}=Yr(t,e,s,o),f,_=!1,m;m=await Jr(o,i,c);let w=m!==void 0;if(!w){if(fe.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(!fe.allowRemoteModels)throw new Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${a}.`)}else try{m=await Qr(i),f=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 Qr(l),m.status!==200)return kE(m.status,l,r);f=c}_=o&&typeof Response<"u"&&m instanceof Response&&m.status===200}kr(s.progress_callback,{status:"download",name:t,file:e});let x;if(!(ie.IS_NODE_ENV&&n)){let E;if(typeof m!="string")if(!s.progress_callback)E=new Uint8Array(await m.arrayBuffer());else if(w&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))E=new Uint8Array(await m.arrayBuffer()),kr(s.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:E.length,total:E.length});else{let A,T=m.headers.get("content-length");if(T)A=parseInt(T,10);else try{let S=await pr(t,e,s);S.size&&(A=S.size)}catch{}E=await EE(m,S=>{kr(s.progress_callback,{status:"progress",name:t,file:e,...S})},A)}x=E}if(_&&f&&typeof m!="string"&&await dP(t,e,o,f,m,x,s),kr(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 Hr)return m.filePath;let k=await o?.match(f);if(k instanceof Hr)return k.filePath;if(k instanceof Response)return new Uint8Array(await k.arrayBuffer());if(typeof k=="string")return k;throw new Error("Unable to get model file path or buffer.")}async function cl(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`.")}kr(s.progress_callback,{status:"initiate",name:t,file:e});let o=await er(s?.cache_dir);return await fP(t,e,r,s,n,o)}async function W0(t,e,r=!0,s={}){let n=await cl(t,e,r,s,!1);return n===null?null:new TextDecoder("utf-8").decode(n)}async function ft(t,e,r=!0,s={}){let n=await W0(t,e,r,s);return n===null?{}:JSON.parse(n)}function OE(t,[e,r,s],[n,o],a="bilinear",i=!1){let l=o/s,c=n/r,p=new t.constructor(n*o*e),f=r*s,_=n*o;for(let m=0;m<n;++m)for(let w=0;w<o;++w){let x=m*o+w,k=(w+.5)/l-.5,E=(m+.5)/c-.5,A=Math.floor(k),T=Math.floor(E),S=Math.min(A+1,s-1),P=Math.min(T+1,r-1);A=Math.max(A,0),T=Math.max(T,0);let O=k-A,v=E-T,j=(1-O)*(1-v),H=O*(1-v),B=(1-O)*v,V=O*v,q=T*s,Q=P*s,F=q+A,C=q+S,te=Q+A,le=Q+S;for(let L=0;L<e;++L){let z=L*f;p[L*_+x]=j*t[z+F]+H*t[z+C]+B*t[z+te]+V*t[z+le]}}return p}function IE(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 Le(t){let e=Pe(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 Vu(t){let e=Pe(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 H0(t,e){let r=0;for(let s=0;s<t.length;++s)r+=t[s]*e[s];return r}function CE(t,e){let r=H0(t,e),s=TE(t),n=TE(e);return r/(s*n)}function TE(t){return Math.sqrt(t.reduce((e,r)=>e+r*r,0))}function ul(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 Pe(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 LE(t){return t>0&&(t&t-1)===0}var qu=class{constructor(e){if(this.size=e|0,this.size<=1||!LE(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 f=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 k=w,E=k+_,A=E+_,T=A+_,S=e[k],P=e[k+1],O=e[E],v=e[E+1],j=e[A],H=e[A+1],B=e[T],V=e[T+1],q=f[x],Q=s*f[x+1],F=O*q-v*Q,C=O*Q+v*q,te=f[2*x],le=s*f[2*x+1],L=j*te-H*le,z=j*le+H*te,R=f[3*x],J=s*f[3*x+1],Ce=B*R-V*J,ae=B*J+V*R,Ue=S+L,Je=P+z,rt=S-L,nt=P-z,at=F+Ce,Se=C+ae,xe=s*(F-Ce),He=s*(C-ae);e[k]=Ue+at,e[k+1]=Je+Se,e[E]=rt+He,e[E+1]=nt-xe,e[A]=Ue-at,e[A+1]=Je-Se,e[T]=rt-He,e[T+1]=nt+xe}}}}_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],f=e[n+o],_=e[n+o+1],m=e[n+i],w=e[n+i+1],x=e[n+l],k=e[n+l+1],E=c+m,A=p+w,T=c-m,S=p-w,P=f+x,O=_+k,v=a*(f-x),j=a*(_-k);r[s]=E+P,r[s+1]=A+O,r[s+2]=T+j,r[s+3]=S-v,r[s+4]=E-P,r[s+5]=A-O,r[s+6]=T-j,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 f=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 k=0,E=0;k<=x;k+=2,E+=a){let A=l+k,T=A+w,S=T+w,P=S+w,O=e[A],v=e[A+1],j=e[T],H=e[T+1],B=e[S],V=e[S+1],q=e[P],Q=e[P+1],F=O,C=v,te=f[E],le=s*f[E+1],L=j*te-H*le,z=j*le+H*te,R=f[2*E],J=s*f[2*E+1],Ce=B*R-V*J,ae=B*J+V*R,Ue=f[3*E],Je=s*f[3*E+1],rt=q*Ue-Q*Je,nt=q*Je+Q*Ue,at=F+Ce,Se=C+ae,xe=F-Ce,He=C-ae,Ot=L+rt,ke=z+nt,De=s*(L-rt),qr=s*(z-nt);if(e[A]=at+Ot,e[A+1]=Se+ke,e[T]=xe+qr,e[T+1]=He-De,k===0){e[S]=at-Ot,e[S+1]=Se-ke;continue}if(k===x)continue;let As=l+w-k,It=l+m-k;e[As]=xe-s*qr,e[As+1]=-He-s*De,e[It]=at-s*Ot,e[It+1]=-Se+s*ke}}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],f=e[n+i],_=e[n+l],m=c+f,w=c-f,x=p+_,k=a*(p-_);r[s]=m+x,r[s+1]=0,r[s+2]=w,r[s+3]=-k,r[s+4]=m-x,r[s+5]=0,r[s+6]=w,r[s+7]=k}},V0=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 f=(p+1-e)**2/2,_=Math.sqrt(l**2+c**2)**f,m=f*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 qu(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 f=0;f<c.length;f+=2){let _=f+1,m=f>>1,w=r[m];n[f]=w*c[f],n[_]=w*c[_]}else for(let f=0;f<c.length;f+=2){let _=f+1;n[f]=r[f]*c[f]-r[_]*c[_],n[_]=r[f]*c[_]+r[_]*c[f]}this._f.transform(a,n);for(let f=0;f<l.length;f+=2){let _=f+1;o[f]=a[f]*l[f]-a[_]*l[_],o[_]=a[f]*l[_]+a[_]*l[f]}this._f.inverseTransform(i,o);for(let f=0;f<i.length;f+=2){let _=i[f+p],m=i[f+p+1],w=c[f],x=c[f+1];e[f]=_*w-m*x,e[f+1]=_*x+m*w}}transform(e,r){this._transform(e,r,!1)}realTransform(e,r){this._transform(e,r,!0)}},Wu=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=LE(e),this.isPowerOfTwo?(this.fft=new qu(e),this.outputBufferSize=2*e):(this.fft=new V0(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,r){this.fft.realTransform(e,r)}transform(e,r){this.fft.transform(e,r)}};function PE(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 zE(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function NE(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 _=n[f-1][p-1],m=n[f-1][p],w=n[f][p-1],x,k;_<m&&_<w?(x=_,k=0):m<_&&m<w?(x=m,k=1):(x=w,k=2),n[f][p]=t[f-1][p-1]+x,o[f][p]=k}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 $E=(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,f=(l&31744)>>10,_=l&1023;if(f===31)c=p|2139095040|_<<13;else if(f===0)if(_===0)c=p;else{let m=113;for(;(_&1024)===0;)_<<=1,--m;_&=-1025,c=p|m<<23|_<<13}else c=p|f+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 GP=vr(require("onnxruntime-node"),1);var Rb={};Os(Rb,{InferenceSession:()=>vb,TRACE:()=>tp,TRACE_EVENT_BEGIN:()=>ss,TRACE_EVENT_END:()=>ns,TRACE_FUNC_BEGIN:()=>Bs,TRACE_FUNC_END:()=>Us,Tensor:()=>rr,default:()=>jP,env:()=>Ke,registerBackend:()=>Fs});var tr={};var yb=Object.defineProperty,_P=Object.getOwnPropertyDescriptor,mP=Object.getOwnPropertyNames,hP=Object.prototype.hasOwnProperty,gP=(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),wl=(t,e)=>{for(var r in e)yb(t,r,{get:e[r],enumerable:!0})},wP=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of mP(e))!hP.call(t,n)&&n!==r&&yb(t,n,{get:()=>e[n],enumerable:!(s=_P(e,n))||s.enumerable});return t},ep=t=>wP(yb({},"__esModule",{value:!0}),t),pl,Zr,Fs,RE,uA,pA=be(()=>{"use strict";pl=new Map,Zr=[],Fs=(t,e,r)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let s=pl.get(t);if(s===void 0)pl.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(pl.get(Zr[o]).priority<=r){Zr.splice(o,0,t);return}Zr.push(t)}return}throw new TypeError("not a valid backend")},RE=async t=>{let e=pl.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}}},uA=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 c=await RE(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)})]}}),xP=be(()=>{"use strict";pA()}),dA,yP=be(()=>{"use strict";dA="1.24.0-dev.20251116-b39e144322"}),X0,_t,fA=be(()=>{"use strict";yP(),X0="warning",_t={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}`);X0=t}},get logLevel(){return X0}},Object.defineProperty(_t,"logLevel",{enumerable:!0})}),Ke,bP=be(()=>{"use strict";fA(),Ke=_t}),_A,mA,vP=be(()=>{"use strict";_A=(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,f=0,_=p,m=p*2,w=-1;a==="RGBA"?(f=0,_=p,m=p*2,w=p*3):a==="RGB"?(f=0,_=p,m=p*2):a==="RBG"&&(f=0,m=p,_=p*2);for(let x=0;x<o;x++)for(let k=0;k<n;k++){let E=(t.data[f++]-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("+E+","+A+","+T+","+S+")",s.fillRect(k,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")},mA=(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 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 _=4,m=0,w=1,x=2,k=3,E=0,A=f,T=f*2,S=-1;i==="RGBA"?(E=0,A=f,T=f*2,S=f*3):i==="RGB"?(E=0,A=f,T=f*2):i==="RBG"&&(E=0,T=f,A=f*2),s=r.createImageData(n,o);for(let P=0;P<o*n;m+=_,w+=_,x+=_,k+=_,P++)s.data[m]=(t.data[E++]-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[k]=S===-1?255:(t.data[S++]-p[3])*c[3]}else throw new Error("Can not access image data");return s}}),Hu,hA,gA,wA,xA,yA,kP=be(()=>{"use strict";bb(),Hu=(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),f=4,_=0,m=1,w=2,x=3,k=0,E=c,A=c*2,T=-1;i==="RGB"&&(f=3,_=0,m=1,w=2,x=-1),l==="RGBA"?T=c*3:l==="RBG"?(k=0,A=c,E=c*2):l==="BGR"&&(A=0,E=c,k=c*2);for(let S=0;S<c;S++,_+=f,w+=f,m+=f,x+=f)p[k++]=(t[_]+a[0])/o[0],p[E++]=(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 Nt("float32",p,[1,4,r,s]):new Nt("float32",p,[1,3,r,s])},hA=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 f=c(p);if(f!=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;f.drawImage(t,0,0),a=f.getImageData(0,0,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 _=l();_.width=f,_.height=p;let m=c(_);if(m!=null)m.putImageData(t,0,0),a=m.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=c(p);if(f!=null){let _=t.height,m=t.width;return f.drawImage(t,0,0,m,_),a=f.getImageData(0,0,m,_).data,i.height=_,i.width=m,Hu(a,i)}else throw new Error("Can not access image data")}else{if(o)return new Promise((p,f)=>{let _=l(),m=c(_);if(!t||!m)return f();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(Hu(x.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Hu(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 Nt({location:"texture",type:"float32",texture:t,dims:a,download:n,dispose:o})},wA=(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})},xA=(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})},yA=(t,e,r)=>new Nt({location:"cpu-pinned",type:t,data:e,dims:r??[e.length]})}),Rs,hl,K0,bA,EP=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]]),hl=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),K0=!1,bA=()=>{if(!K0){K0=!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),hl.set(BigInt64Array,"int64")),e&&(Rs.set("uint64",BigUint64Array),hl.set(BigUint64Array,"uint64")),s?(Rs.set("float16",r),hl.set(r,"float16")):Rs.set("float16",Uint16Array)}}}),vA,kA,AP=be(()=>{"use strict";bb(),vA=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 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,bb=be(()=>{"use strict";vP(),kP(),EP(),AP(),Nt=class{constructor(t,e,r){bA();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=hl.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=vA(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 hA(t,e)}static fromTexture(t,e){return gA(t,e)}static fromGpuBuffer(t,e){return wA(t,e)}static fromMLTensor(t,e){return xA(t,e)}static fromPinnedBuffer(t,e,r){return yA(t,e,r)}toDataURL(t){return _A(this,t)}toImageData(t){return mA(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)}}}),rr,EA=be(()=>{"use strict";bb(),rr=Nt}),tp,Q0,Bs,Us,ss,ns,AA=be(()=>{"use strict";fA(),tp=(t,e)=>{(typeof _t.trace>"u"?!_t.wasm.trace:!_t.trace)||console.timeStamp(`${t}::ORT::${e}`)},Q0=(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}`),tp("CPU",o);return}r[n].includes("TRACE_FUNC")&&(s=!0)}},Bs=t=>{(typeof _t.trace>"u"?!_t.wasm.trace:!_t.trace)||Q0("BEGIN",t)},Us=t=>{(typeof _t.trace>"u"?!_t.wasm.trace:!_t.trace)||Q0("END",t)},ss=t=>{(typeof _t.trace>"u"?!_t.wasm.trace:!_t.trace)||console.time(`ORT::${t}`)},ns=t=>{(typeof _t.trace>"u"?!_t.wasm.trace:!_t.trace)||console.timeEnd(`ORT::${t}`)}}),MA,MP=be(()=>{"use strict";pA(),EA(),AA(),MA=class SA{constructor(e){this.handler=e}async run(e,r,s){Bs(),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 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 f of this.outputNames)if(p.indexOf(f)!==-1){let _=r[f];(_===null||_ instanceof rr)&&(c=!0,a=!1,n[f]=_)}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 rr?l[c]=p:l[c]=new rr(p.type,p.data,p.dims)}return ns("InferenceSession.run"),Us(),l}async release(){return this.handler.dispose()}static async create(e,r,s,n){Bs(),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,_=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(_=e.byteLength-f,typeof s=="number"){if(_=s,!Number.isSafeInteger(_))throw new RangeError("'byteLength' must be an integer.");if(_<=0||f+_>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,_)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,l]=await uA(a),c=await i.createInferenceSessionHandler(o,l);return ns("InferenceSession.create"),Us(),new SA(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}}}),vb,SP=be(()=>{"use strict";MP(),vb=MA}),TP=be(()=>{"use strict"}),OP=be(()=>{"use strict"}),IP=be(()=>{"use strict"}),CP=be(()=>{"use strict"}),TA={};wl(TA,{InferenceSession:()=>vb,TRACE:()=>tp,TRACE_EVENT_BEGIN:()=>ss,TRACE_EVENT_END:()=>ns,TRACE_FUNC_BEGIN:()=>Bs,TRACE_FUNC_END:()=>Us,Tensor:()=>rr,env:()=>Ke,registerBackend:()=>Fs});var js=be(()=>{"use strict";xP(),bP(),SP(),EA(),TP(),OP(),AA(),IP(),CP()}),kb=be(()=>{"use strict"}),OA={};wl(OA,{default:()=>IA});var Y0,J0,IA,LP=be(()=>{"use strict";WA(),Gs(),Eb(),Y0="ort-wasm-proxy-worker",J0=globalThis.self?.name===Y0,J0&&(self.onmessage=t=>{let{type:e,in:r}=t.data;try{switch(e){case"init-wasm":Ab(r.wasm).then(()=>{Ib(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;Cb(n,s).then(()=>{postMessage({type:e})},o=>{postMessage({type:e,err:o})});break}case"copy-from":{let{buffer:s}=r,n=np(s);postMessage({type:e,out:n});break}case"create":{let{model:s,options:n}=r;Lb(s,n).then(o=>{postMessage({type:e,out:o})},o=>{postMessage({type:e,err:o})});break}case"release":Pb(r),postMessage({type:e});break;case"run":{let{sessionId:s,inputIndices:n,inputs:o,outputIndices:a,options:i}=r;zb(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},$b([...o,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":Nb(r),postMessage({type:e});break;default:}}catch(s){postMessage({type:e,err:s})}}),IA=J0?null:t=>new Worker(t??Pt,{type:"module",name:Y0})}),CA={};wl(CA,{default:()=>LA});async function DE(t={}){var e=t,r=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,n=s&&self.name?.startsWith("em-pthread");e.mountExternalData=(u,d)=>{u.startsWith("./")&&(u=u.substring(2)),(e.Uc||(e.Uc=new Map)).set(u,d)},e.unmountExternalData=()=>{delete e.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,Be:!0}).buffer.constructor;let o=()=>{let u=d=>(...h)=>{let g=ir;return h=d(...h),ir!=g?new Promise((b,M)=>{d0={resolve:b,reject:M}}):h};(()=>{for(let d of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[d]=u(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=(u,d)=>{throw d},c=tr.url,p="";if(r||s){try{p=new URL(".",c).href}catch{}s&&(i=u=>{var d=new XMLHttpRequest;return d.open("GET",u,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.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 d=await fetch(u,{credentials:"same-origin"});if(d.ok)return d.arrayBuffer();throw Error(d.status+" : "+d.url)}}var f,_,m,w,x,k,E=console.log.bind(console),A=console.error.bind(console),T=E,S=A,P=!1,O=u=>u.startsWith("file://");function v(){Wr.buffer!=B.buffer&&Ce()}if(n){let u=function(d){try{var h=d.data,g=h.Oc;if(g==="load"){let b=[];self.onmessage=M=>b.push(M),k=()=>{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]));Wr=h.je,Ce(),_=h.ke,rt(),Cu()}else if(g==="run"){(function(b){var M=(v(),C)[b+52>>>2>>>0];b=(v(),C)[b+56>>>2>>>0],jv(M,M-b),ce(M)})(h.Nc),E0(h.Nc,0,0,1,0,0),O1(),c0(h.Nc),H||(Ev(),H=!0);try{$M(h.he,h.Wc)}catch(b){if(b!="unwind")throw b}}else h.target!=="setimmediate"&&(g==="checkMailbox"?H&&ku():g&&(S(`worker: received unknown command ${g}`),S(h)))}catch(b){throw Rv(),b}};var j=u,H=!1;self.onunhandledrejection=d=>{throw d.reason||d},self.onmessage=u}var B,V,q,Q,F,C,te,le,L,z,R,J=!1;function Ce(){var u=Wr.buffer;e.HEAP8=B=new Int8Array(u),q=new Int16Array(u),e.HEAPU8=V=new Uint8Array(u),Q=new Uint16Array(u),e.HEAP32=F=new Int32Array(u),e.HEAPU32=C=new Uint32Array(u),te=new Float32Array(u),le=new Float64Array(u),L=new BigInt64Array(u),z=new BigUint64Array(u)}function ae(){J=!0,n?k():br._b()}function Ue(u){throw S(u="Aborted("+u+")"),P=!0,u=new WebAssembly.RuntimeError(u+". Build with -sASSERTIONS for more info."),x?.(u),u}function Je(){return{a:{f:RM,J:DM,k:FM,p:BM,l:UM,ta:jM,b:GM,ca:qM,Ka:N1,s:WM,da:F1,_a:B1,Ga:U1,Ia:j1,$a:G1,Ya:q1,Ra:W1,Xa:V1,pa:H1,Ha:X1,Yb:K1,Za:Q1,Fa:Y1,eb:VM,Da:XM,Tb:KM,Rb:YM,Ca:ZM,M:eS,I:tS,Sb:rS,ka:cS,Ub:uS,Ua:pS,Wb:fS,La:_S,Pb:mS,la:hS,Ta:c0,bb:gS,U:bS,n:MS,c:i0,sb:SS,w:TS,L:OS,z:IS,j:CS,o:ov,tb:LS,G:PS,T:zS,h:NS,u:$S,m:RS,i:DS,Oa:FS,Pa:BS,Qa:US,Ma:cv,Na:uv,Qb:pv,fb:GS,db:VS,Y:HS,rb:XS,ma:KS,cb:qS,gb:QS,ab:YS,Xb:JS,N:jS,hb:ZS,X:eT,Vb:tT,ob:uT,C:pT,sa:dT,ra:fT,qb:_T,W:mT,v:hT,nb:gT,mb:wT,lb:xT,pb:yT,kb:bT,jb:vT,ib:kT,Va:gv,Wa:wv,Ja:It,ea:xv,oa:yv,Sa:bv,na:vv,Db:PO,xa:AO,Eb:LO,ya:EO,F:_O,e:tO,r:ZT,x:JT,D:pO,Ib:bO,ba:xO,B:sO,za:vO,$:MO,ha:yO,Fb:IO,Gb:OO,Ba:mO,Aa:wO,Jb:hO,wa:CO,aa:kO,d:rO,A:nO,q:eO,Cb:zO,t:aO,y:dO,H:oO,E:iO,K:fO,S:SO,ja:uO,_:TO,Kb:cO,Lb:lO,P:gO,g:AT,a:Wr,Ob:qr,Hb:MT,ia:ST,O:TT,qa:OT,Mb:IT,Q:CT,zb:LT,Ab:PT,ua:zT,fa:NT,R:$T,Ea:RT,va:DT,Z:FT,xb:BT,Zb:UT,V:jT,Bb:GT,ub:qT,vb:VT,wb:HT,ga:XT,yb:KT,Nb:QT}}}async function rt(){function u(g,b){var M=br=g.exports;g={};for(let[I,N]of Object.entries(M))typeof N=="function"?(M=wS(N),g[I]=M):g[I]=N;return br=g,br=(function(){var I=br,N=Y=>Te=>Y(Te)>>>0,U=Y=>()=>Y()>>>0;return(I=Object.assign({},I)).$b=N(I.$b),I.Cc=U(I.Cc),I.Ec=N(I.Ec),I.rd=(Y=>(Te,$e)=>Y(Te,$e)>>>0)(I.rd),I.wd=N(I.wd),I.xd=U(I.xd),I.Bd=N(I.Bd),I})(),S1.push(br.id),kv=(g=br).$b,Ev=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,Ou=g.Cc,Kt=e._free=g.Dc,On=e._malloc=g.Ec,Av=e._wgpuBufferRelease=g.Fc,Mv=e._wgpuCreateInstance=g.Gc,Sv=g.Hc,Tv=g.Ic,Ov=g.Jc,Iv=g.Kc,Cv=g.Lc,Lv=g.Pc,Pv=g.Zc,zv=g._c,Nv=g.$c,x0=g.bd,y0=g.cd,b0=g.dd,v0=g.ed,Zi=g.fd,k0=g.gd,$v=g.hd,E0=g.kd,Rv=g.ld,Dv=g.md,Fv=g.nd,A0=g.od,Bv=g.pd,Uv=g.qd,M0=g.rd,ge=g.sd,el=g.td,jv=g.ud,ce=g.vd,Iu=g.wd,ue=g.xd,Gv=g.yd,S0=g.zd,qv=g.Ad,Wv=g.Bd,Vv=g.Cd,T0=g.Dd,Hv=g.Ed,Xv=g.Fd,Kv=g.Gd,Qv=g.Hd,Yv=g.Id,Jv=g.Jd,Zv=g.Kd,ek=g.Ld,tk=g.Md,rk=g.Nd,sk=g.Od,nk=g.Pd,ok=g.Qd,ak=g.Rd,ik=g.Td,lk=g.Ud,ck=g.Vd,uk=g.Wd,pk=g.Yd,dk=g.Zd,fk=g._d,_k=g.$d,mk=g.ae,hk=g.be,gk=g.pe,wk=g.qe,xk=g.re,yk=g.se,bk=g.te,vk=g.ue,kk=g.ve,Ek=g.we,Ak=g.xe,Mk=g.ye,Sk=g.ze,Tk=g.Xe,Ok=g.Ye,Ik=g.Ze,Ck=g._e,_=b,br}var d,h=Je();return e.instantiateWasm?new Promise(g=>{e.instantiateWasm(h,(b,M)=>{g(u(b,M))})}):n?u(new WebAssembly.Instance(_,Je()),_):(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&&!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,N){try{var U=await(async function(Y){if(!f)try{var Te=await a(Y);return new Uint8Array(Te)}catch{}if(Y==R&&f)Y=new Uint8Array(f);else{if(!i)throw"both async and sync fetching of the wasm failed";Y=i(Y)}return Y})(I);return await WebAssembly.instantiate(U,N)}catch(Y){S(`failed to asynchronously prepare wasm: ${Y}`),Ue(Y)}})(b,g)})(h),u(d.instance,d.module))}class nt{name="ExitStatus";constructor(d){this.message=`Program terminated with exit(${d})`,this.status=d}}var at=u=>{u.terminate(),u.onmessage=()=>{}},Se=[],xe=0,He=null,Ot=u=>{ot.length==0&&(C1(),I1(ot[0]));var d=ot.pop();if(!d)return 6;Qi.push(d),Ms[u.Nc]=d,d.Nc=u.Nc;var h={Oc:"run",he:u.ge,Wc:u.Wc,Nc:u.Nc};return d.postMessage(h,u.Yc),0},ke=0,De=(u,d,...h)=>{var g,b=16*h.length,M=ue(),I=Iu(b),N=I>>>3;for(g of h)typeof g=="bigint"?((v(),L)[N++>>>0]=1n,(v(),L)[N++>>>0]=g):((v(),L)[N++>>>0]=0n,(v(),le)[N++>>>0]=g);return u=Dv(u,0,b,I,d),ce(M),u};function qr(u){if(n)return De(0,1,u);if(m=u,!(0<ke)){for(var d of Qi)at(d);for(d of ot)at(d);ot=[],Qi=[],Ms={},P=!0}l(0,new nt(u))}function As(u){if(n)return De(1,0,u);It(u)}var It=u=>{if(m=u,n)throw As(u),"unwind";qr(u)},ot=[],Qi=[],S1=[],Ms={},T1=u=>{var d=u.Nc;delete Ms[d],ot.push(u),Qi.splice(Qi.indexOf(u),1),u.Nc=0,Fv(d)};function O1(){S1.forEach(u=>u())}var I1=u=>new Promise(d=>{u.onmessage=b=>{var M=b.data;if(b=M.Oc,M.Vc&&M.Vc!=Ou()){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"?ku():b==="spawnThread"?Ot(M):b==="cleanupThread"?At(()=>{T1(Ms[M.ie])}):b==="loaded"?(u.loaded=!0,d(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:Wr,ke:_})});function C1(){var u=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"});ot.push(u)}var Wr,$M=(u,d)=>{ke=0,u=T0(u,d),0<ke?m=u:A0(u)},bu=[],vu=0,Et=u=>-9007199254740992>u||9007199254740992<u?NaN:Number(u);function RM(u){var d=new s0(u>>>=0);return(v(),B)[d.Qc+12>>>0]==0&&(L1(d,!0),vu--),P1(d,!1),bu.push(d),Wv(u)}var An=0,DM=()=>{ge(0,0);var u=bu.pop();Gv(u.Xc),An=0};function L1(u,d){d=d?1:0,(v(),B)[u.Qc+12>>>0]=d}function P1(u,d){d=d?1:0,(v(),B)[u.Qc+13>>>0]=d}class s0{constructor(d){this.Xc=d,this.Qc=d-24}}var n0=u=>{var d=An;if(!d)return el(0),0;var h=new s0(d);(v(),C)[h.Qc+16>>>2>>>0]=d;var g=(v(),C)[h.Qc+4>>>2>>>0];if(!g)return el(0),d;for(var b of u){if(b===0||b===g)break;if(qv(b,g,h.Qc+16))return el(b),d}return el(g),d};function FM(){return n0([])}function BM(u){return n0([u>>>0])}function UM(u,d,h,g){return n0([u>>>0,d>>>0,h>>>0,g>>>0])}var jM=()=>{var u=bu.pop();u||Ue("no exception to throw");var d=u.Xc;throw(v(),B)[u.Qc+13>>>0]==0&&(bu.push(u),P1(u,!0),L1(u,!1),vu++),S0(d),An=d};function GM(u,d,h){var g=new s0(u>>>=0);throw d>>>=0,h>>>=0,(v(),C)[g.Qc+16>>>2>>>0]=0,(v(),C)[g.Qc+4>>>2>>>0]=d,(v(),C)[g.Qc+8>>>2>>>0]=h,S0(u),vu++,An=u}var qM=()=>vu;function z1(u,d,h,g){return n?De(2,1,u,d,h,g):N1(u,d,h,g)}function N1(u,d,h,g){if(u>>>=0,d>>>=0,h>>>=0,g>>>=0,!globalThis.SharedArrayBuffer)return 6;var b=[];return n&&b.length===0?z1(u,d,h,g):(u={ge:h,Nc:u,Wc:g,Yc:b},n?(u.Oc="spawnThread",postMessage(u,b),0):Ot(u))}function WM(u){throw An||=u>>>0,An}var $1=globalThis.TextDecoder&&new TextDecoder,R1=(u,d,h,g)=>{if(h=d+h,g)return h;for(;u[d]&&!(d>=h);)++d;return d},D1=(u,d=0,h,g)=>{if(16<(h=R1(u,d>>>=0,h,g))-d&&u.buffer&&$1)return $1.decode(u.buffer instanceof ArrayBuffer?u.subarray(d,h):u.slice(d,h));for(g="";d<h;){var b=u[d++];if(128&b){var M=63&u[d++];if((224&b)==192)g+=String.fromCharCode((31&b)<<6|M);else{var I=63&u[d++];65536>(b=(240&b)==224?(15&b)<<12|M<<6|I:(7&b)<<18|M<<12|I<<6|63&u[d++])?g+=String.fromCharCode(b):(b-=65536,g+=String.fromCharCode(55296|b>>10,56320|1023&b))}}else g+=String.fromCharCode(b)}return g},Mn=(u,d,h)=>(u>>>=0)?D1((v(),V),u,d,h):"";function F1(u,d,h){return n?De(3,1,u,d,h):0}function B1(u,d){if(n)return De(4,1,u,d)}function U1(u,d){if(n)return De(5,1,u,d)}function j1(u,d,h){if(n)return De(6,1,u,d,h)}function G1(u,d,h){return n?De(7,1,u,d,h):0}function q1(u,d){if(n)return De(8,1,u,d)}function W1(u,d,h){if(n)return De(9,1,u,d,h)}function V1(u,d,h,g){if(n)return De(10,1,u,d,h,g)}function H1(u,d,h,g){if(n)return De(11,1,u,d,h,g)}function X1(u,d,h,g){if(n)return De(12,1,u,d,h,g)}function K1(u){if(n)return De(13,1,u)}function Q1(u,d){if(n)return De(14,1,u,d)}function Y1(u,d,h){if(n)return De(15,1,u,d,h)}var VM=()=>Ue(""),ar=u=>{u>>>=0;for(var d="";;){var h=(v(),V)[u++>>>0];if(!h)return d;d+=String.fromCharCode(h)}},o0={},a0={},HM={},Sn=class extends Error{constructor(u){super(u),this.name="BindingError"}};function hr(u,d,h={}){return(function(g,b,M={}){var I=b.name;if(!g)throw new Sn(`type "${I}" must have a positive integer typeid pointer`);if(a0.hasOwnProperty(g)){if(M.ee)return;throw new Sn(`Cannot register type '${I}' twice`)}a0[g]=b,delete HM[g],o0.hasOwnProperty(g)&&(b=o0[g],delete o0[g],b.forEach(N=>N()))})(u,d,h)}var J1=(u,d,h)=>{switch(d){case 1:return h?g=>(v(),B)[g>>>0]:g=>(v(),V)[g>>>0];case 2:return h?g=>(v(),q)[g>>>1>>>0]:g=>(v(),Q)[g>>>1>>>0];case 4:return h?g=>(v(),F)[g>>>2>>>0]:g=>(v(),C)[g>>>2>>>0];case 8:return h?g=>(v(),L)[g>>>3>>>0]:g=>(v(),z)[g>>>3>>>0];default:throw new TypeError(`invalid integer width (${d}): ${u}`)}};function XM(u,d,h,g,b){u>>>=0,h>>>=0,d=ar(d>>>0);let M=I=>I;if(g=g===0n){let I=8*h;M=N=>BigInt.asUintN(I,N),b=M(b)}hr(u,{name:d,Mc:M,Sc:(I,N)=>(typeof N=="number"&&(N=BigInt(N)),N),Rc:J1(d,h,!g),Tc:null})}function KM(u,d,h,g){hr(u>>>=0,{name:d=ar(d>>>0),Mc:function(b){return!!b},Sc:function(b,M){return M?h:g},Rc:function(b){return this.Mc((v(),V)[b>>>0])},Tc:null})}var Z1=[],Ss=[0,1,,1,null,1,!0,1,!1,1];function i0(u){9<(u>>>=0)&&--Ss[u+1]==0&&(Ss[u]=void 0,Z1.push(u))}var Bt=u=>{if(!u)throw new Sn(`Cannot use deleted val. handle = ${u}`);return Ss[u]},Xt=u=>{switch(u){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let d=Z1.pop()||Ss.length;return Ss[d]=u,Ss[d+1]=1,d}};function l0(u){return this.Mc((v(),C)[u>>>2>>>0])}var QM={name:"emscripten::val",Mc:u=>{var d=Bt(u);return i0(u),d},Sc:(u,d)=>Xt(d),Rc:l0,Tc:null};function YM(u){return hr(u>>>0,QM)}var JM=(u,d)=>{switch(d){case 4:return function(h){return this.Mc((v(),te)[h>>>2>>>0])};case 8:return function(h){return this.Mc((v(),le)[h>>>3>>>0])};default:throw new TypeError(`invalid float width (${d}): ${u}`)}};function ZM(u,d,h){h>>>=0,hr(u>>>=0,{name:d=ar(d>>>0),Mc:g=>g,Sc:(g,b)=>b,Rc:JM(d,h),Tc:null})}function eS(u,d,h,g,b){u>>>=0,h>>>=0,d=ar(d>>>0);let M=N=>N;if(g===0){var I=32-8*h;M=N=>N<<I>>>I,b=M(b)}hr(u,{name:d,Mc:M,Sc:(N,U)=>U,Rc:J1(d,h,g!==0),Tc:null})}function tS(u,d,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][d];hr(u>>>=0,{name:h=ar(h>>>0),Mc:g,Rc:g},{ee:!0})}var gr=(u,d,h)=>{var g=(v(),V);if(d>>>=0,0<h){var b=d;h=d+h-1;for(var M=0;M<u.length;++M){var I=u.codePointAt(M);if(127>=I){if(d>=h)break;g[d++>>>0]=I}else if(2047>=I){if(d+1>=h)break;g[d++>>>0]=192|I>>6,g[d++>>>0]=128|63&I}else if(65535>=I){if(d+2>=h)break;g[d++>>>0]=224|I>>12,g[d++>>>0]=128|I>>6&63,g[d++>>>0]=128|63&I}else{if(d+3>=h)break;g[d++>>>0]=240|I>>18,g[d++>>>0]=128|I>>12&63,g[d++>>>0]=128|I>>6&63,g[d++>>>0]=128|63&I,M++}}g[d>>>0]=0,u=d-b}else u=0;return u},wr=u=>{for(var d=0,h=0;h<u.length;++h){var g=u.charCodeAt(h);127>=g?d++:2047>=g?d+=2:55296<=g&&57343>=g?(d+=4,++h):d+=3}return d};function rS(u,d){hr(u>>>=0,{name:d=ar(d>>>0),Mc(h){var g=(v(),C)[h>>>2>>>0];return g=Mn(h+4,g,!0),Kt(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 Sn("Cannot pass non-string to std::string");var M=b?wr(g):g.length,I=On(4+M+1),N=I+4;return(v(),C)[I>>>2>>>0]=M,b?gr(g,N,M+1):(v(),V).set(g,N>>>0),h!==null&&h.push(Kt,I),I},Rc:l0,Tc(h){Kt(h)}})}var ev=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,sS=(u,d,h)=>{if(u>>>=1,16<(d=R1((v(),Q),u,d/2,h))-u&&ev)return ev.decode((v(),Q).slice(u,d));for(h="";u<d;++u){var g=(v(),Q)[u>>>0];h+=String.fromCharCode(g)}return h},nS=(u,d,h)=>{if(h??=2147483647,2>h)return 0;var g=d;h=(h-=2)<2*u.length?h/2:u.length;for(var b=0;b<h;++b){var M=u.charCodeAt(b);(v(),q)[d>>>1>>>0]=M,d+=2}return(v(),q)[d>>>1>>>0]=0,d-g},oS=u=>2*u.length,aS=(u,d,h)=>{var g="";u>>>=2;for(var b=0;!(b>=d/4);b++){var M=(v(),C)[u+b>>>0];if(!M&&!h)break;g+=String.fromCodePoint(M)}return g},iS=(u,d,h)=>{if(d>>>=0,h??=2147483647,4>h)return 0;var g=d;h=g+h-4;for(var b=0;b<u.length;++b){var M=u.codePointAt(b);if(65535<M&&b++,(v(),F)[d>>>2>>>0]=M,(d+=4)+4>h)break}return(v(),F)[d>>>2>>>0]=0,d-g},lS=u=>{for(var d=0,h=0;h<u.length;++h)65535<u.codePointAt(h)&&h++,d+=4;return d};function cS(u,d,h){if(u>>>=0,d>>>=0,h=ar(h>>>=0),d===2)var g=sS,b=nS,M=oS;else g=aS,b=iS,M=lS;hr(u,{name:h,Mc:I=>{var N=(v(),C)[I>>>2>>>0];return N=g(I+4,N*d,!0),Kt(I),N},Sc:(I,N)=>{if(typeof N!="string")throw new Sn(`Cannot pass non-string to C++ string type ${h}`);var U=M(N),Y=On(4+U+d);return(v(),C)[Y>>>2>>>0]=U/d,b(N,Y+4,U+d),I!==null&&I.push(Kt,Y),Y},Rc:l0,Tc(I){Kt(I)}})}function uS(u,d){hr(u>>>=0,{fe:!0,name:d=ar(d>>>0),Mc:()=>{},Sc:()=>{}})}function pS(u){E0(u>>>0,!s,1,!r,131072,!1),O1()}var At=u=>{if(!P)try{if(u(),!(0<ke))try{n?Ou()&&A0(m):It(m)}catch(d){d instanceof nt||d=="unwind"||l(0,d)}}catch(d){d instanceof nt||d=="unwind"||l(0,d)}},dS=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function c0(u){u>>>=0,dS||(Atomics.waitAsync((v(),F),u>>>2,u).value.then(ku),u+=128,Atomics.store((v(),F),u>>>2,1))}var ku=()=>At(()=>{var u=Ou();u&&(c0(u),Uv())});function fS(u,d){(u>>>=0)==d>>>0?setTimeout(ku):n?postMessage({Vc:u,Oc:"checkMailbox"}):(u=Ms[u])&&u.postMessage({Oc:"checkMailbox"})}var u0=[];function _S(u,d,h,g,b){for(d>>>=0,b>>>=0,u0.length=0,h=b>>>3,g=b+g>>>3;h<g;){var M;M=(v(),L)[h++>>>0]?(v(),L)[h++>>>0]:(v(),le)[h++>>>0],u0.push(M)}return(d?O0[d]:YT[u])(...u0)}var mS=()=>{ke=0};function hS(u){u>>>=0,n?postMessage({Oc:"cleanupThread",ie:u}):T1(Ms[u])}function gS(u){}var Eu=u=>{try{u()}catch(d){Ue(d)}};function wS(u){var d=(...h)=>{Au.push(u);try{return u(...h)}finally{P||(Au.pop(),ir&&Vr===1&&Au.length===0&&(Vr=0,ke+=1,Eu(Ok),typeof Fibers<"u"&&Fibers.De()))}};return sv.set(u,d),d}var Vr=0,ir=null,tv=0,Au=[],p0=new Map,rv=new Map,sv=new Map,xS=0,d0=null,yS=[],nv=u=>(function(d){if(!P){if(Vr===0){var h=!1,g=!1;d((b=0)=>{if(!P&&(tv=b,h=!0,g)){Vr=2,Eu(()=>Ik(ir)),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.resume(),b=!1;try{var M=(function(){var U=(v(),F)[ir+8>>>2>>>0];return U=rv.get(U),U=sv.get(U),--ke,U()})()}catch(U){M=U,b=!0}var I=!1;if(!ir){var N=d0;N&&(d0=null,(b?N.reject:N.resolve)(M),I=!0)}if(b&&!I)throw M}}),g=!0,h||(Vr=1,ir=(function(){var b=On(65548),M=b+12;if((v(),C)[b>>>2>>>0]=M,(v(),C)[b+4>>>2>>>0]=M+65536,M=Au[0],!p0.has(M)){var I=xS++;p0.set(M,I),rv.set(I,M)}return M=p0.get(M),(v(),F)[b+8>>>2>>>0]=M,b})(),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.pause(),Eu(()=>Tk(ir)))}else Vr===2?(Vr=0,Eu(Ck),Kt(ir),ir=null,yS.forEach(At)):Ue(`invalid state: ${Vr}`);return tv}})(d=>{u().then(d)});function bS(u){return u>>>=0,nv(async()=>{var d=await Bt(u);return Xt(d)})}var f0=[],vS=u=>{var d=f0.length;return f0.push(u),d},kS=(u,d)=>{for(var h=Array(u),g=0;g<u;++g){var b=g,M=(v(),C)[d+4*g>>>2>>>0],I=a0[M];if(I===void 0)throw u=`parameter ${g}`,M=kv(M),d=ar(M),Kt(M),new Sn(`${u} has unknown type ${d}`);h[b]=I}return h},ES=(u,d,h)=>{var g=[];return u=u(g,h),g.length&&((v(),C)[d>>>2>>>0]=Xt(g)),u},AS={},Mu=u=>{var d=AS[u];return d===void 0?ar(u):d};function MS(u,d,h){var[g,...b]=kS(u,d>>>0);d=g.Sc.bind(g);var M=b.map(U=>U.Rc.bind(U));u--;var I={toValue:Bt};switch(u=M.map((U,Y)=>{var Te=`argFromPtr${Y}`;return I[Te]=U,`${Te}(args${Y?"+"+8*Y:""})`}),h){case 0:var N="toValue(handle)";break;case 2:N="new (toValue(handle))";break;case 3:N="";break;case 1:I.getStringOrSymbol=Mu,N="toValue(handle)[getStringOrSymbol(methodName)]"}return N+=`(${u})`,g.fe||(I.toReturnWire=d,I.emval_returnValue=ES,N=`return emval_returnValue(toReturnWire, destructorsRef, ${N})`),N=`return function (handle, methodName, destructorsRef, args) {
|
|
11
|
-
${
|
|
12
|
-
}`,h=new Function(Object.keys(I),N)(...Object.values(I)),N=`methodCaller<(${b.map(U=>U.name)}) => ${g.name}>`,vS(Object.defineProperty(h,"name",{value:N}))}function SS(u,d){return d>>>=0,(u=Bt(u>>>0))==Bt(d)}function TS(u){return(u>>>=0)?(u=Mu(u),Xt(globalThis[u])):Xt(globalThis)}function OS(u){return u=Mu(u>>>0),Xt(e[u])}function IS(u,d){return d>>>=0,u=Bt(u>>>0),d=Bt(d),Xt(u[d])}function CS(u){9<(u>>>=0)&&(Ss[u+1]+=1)}function ov(u,d,h,g,b){return f0[u>>>0](d>>>0,h>>>0,g>>>0,b>>>0)}function LS(u,d,h,g,b){return ov(u>>>0,d>>>0,h>>>0,g>>>0,b>>>0)}function PS(){return Xt([])}function zS(u){u=Bt(u>>>0);for(var d=Array(u.length),h=0;h<u.length;h++)d[h]=u[h];return Xt(d)}function NS(u){return Xt(Mu(u>>>0))}function $S(){return Xt({})}function RS(u){for(var d=Bt(u>>>=0);d.length;){var h=d.pop();d.pop()(h)}i0(u)}function DS(u,d,h){d>>>=0,h>>>=0,u=Bt(u>>>0),d=Bt(d),h=Bt(h),u[d]=h}function FS(u,d){u=Et(u),d>>>=0,u=new Date(1e3*u),(v(),F)[d>>>2>>>0]=u.getUTCSeconds(),(v(),F)[d+4>>>2>>>0]=u.getUTCMinutes(),(v(),F)[d+8>>>2>>>0]=u.getUTCHours(),(v(),F)[d+12>>>2>>>0]=u.getUTCDate(),(v(),F)[d+16>>>2>>>0]=u.getUTCMonth(),(v(),F)[d+20>>>2>>>0]=u.getUTCFullYear()-1900,(v(),F)[d+24>>>2>>>0]=u.getUTCDay(),u=(u.getTime()-Date.UTC(u.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(v(),F)[d+28>>>2>>>0]=u}var av=u=>u%4==0&&(u%100!=0||u%400==0),iv=[0,31,60,91,121,152,182,213,244,274,305,335],lv=[0,31,59,90,120,151,181,212,243,273,304,334];function BS(u,d){u=Et(u),d>>>=0,u=new Date(1e3*u),(v(),F)[d>>>2>>>0]=u.getSeconds(),(v(),F)[d+4>>>2>>>0]=u.getMinutes(),(v(),F)[d+8>>>2>>>0]=u.getHours(),(v(),F)[d+12>>>2>>>0]=u.getDate(),(v(),F)[d+16>>>2>>>0]=u.getMonth(),(v(),F)[d+20>>>2>>>0]=u.getFullYear()-1900,(v(),F)[d+24>>>2>>>0]=u.getDay();var h=(av(u.getFullYear())?iv:lv)[u.getMonth()]+u.getDate()-1|0;(v(),F)[d+28>>>2>>>0]=h,(v(),F)[d+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(),F)[d+32>>>2>>>0]=u}function US(u){u>>>=0;var d=new Date((v(),F)[u+20>>>2>>>0]+1900,(v(),F)[u+16>>>2>>>0],(v(),F)[u+12>>>2>>>0],(v(),F)[u+8>>>2>>>0],(v(),F)[u+4>>>2>>>0],(v(),F)[u>>>2>>>0],0),h=(v(),F)[u+32>>>2>>>0],g=d.getTimezoneOffset(),b=new Date(d.getFullYear(),6,1).getTimezoneOffset(),M=new Date(d.getFullYear(),0,1).getTimezoneOffset(),I=Math.min(M,b);return 0>h?(v(),F)[u+32>>>2>>>0]=+(b!=M&&I==g):0<h!=(I==g)&&(b=Math.max(M,b),d.setTime(d.getTime()+6e4*((0<h?I:b)-g))),(v(),F)[u+24>>>2>>>0]=d.getDay(),h=(av(d.getFullYear())?iv:lv)[d.getMonth()]+d.getDate()-1|0,(v(),F)[u+28>>>2>>>0]=h,(v(),F)[u>>>2>>>0]=d.getSeconds(),(v(),F)[u+4>>>2>>>0]=d.getMinutes(),(v(),F)[u+8>>>2>>>0]=d.getHours(),(v(),F)[u+12>>>2>>>0]=d.getDate(),(v(),F)[u+16>>>2>>>0]=d.getMonth(),(v(),F)[u+20>>>2>>>0]=d.getYear(),u=d.getTime(),BigInt(isNaN(u)?-1:u/1e3)}function cv(u,d,h,g,b,M,I){return n?De(16,1,u,d,h,g,b,M,I):-52}function uv(u,d,h,g,b,M){if(n)return De(17,1,u,d,h,g,b,M)}var Yi={},jS=()=>performance.timeOrigin+performance.now();function pv(u,d){if(n)return De(18,1,u,d);if(Yi[u]&&(clearTimeout(Yi[u].id),delete Yi[u]),!d)return 0;var h=setTimeout(()=>{delete Yi[u],At(()=>Bv(u,performance.timeOrigin+performance.now()))},d);return Yi[u]={id:h,Ce:d},0}function GS(u,d,h,g){u>>>=0,d>>>=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(),F)[d>>>2>>>0]=+(M!=b),u=(d=N=>{var U=Math.abs(N);return`UTC${0<=N?"-":"+"}${String(Math.floor(U/60)).padStart(2,"0")}${String(U%60).padStart(2,"0")}`})(M),d=d(b),b<M?(gr(u,h,17),gr(d,g,17)):(gr(u,g,17),gr(d,h,17))}var qS=()=>Date.now(),WS=1;function VS(u,d,h){if(h>>>=0,!(0<=u&&3>=u))return 28;if(u===0)u=Date.now();else{if(!WS)return 52;u=performance.timeOrigin+performance.now()}return u=Math.round(1e6*u),(v(),L)[h>>>3>>>0]=BigInt(u),0}var _0=[],dv=(u,d)=>{_0.length=0;for(var h;h=(v(),V)[u++>>>0];){var g=h!=105;d+=(g&=h!=112)&&d%8?4:0,_0.push(h==112?(v(),C)[d>>>2>>>0]:h==106?(v(),L)[d>>>3>>>0]:h==105?(v(),F)[d>>>2>>>0]:(v(),le)[d>>>3>>>0]),d+=g?8:4}return _0};function HS(u,d,h){return u>>>=0,d=dv(d>>>0,h>>>0),O0[u](...d)}function XS(u,d,h){return u>>>=0,d=dv(d>>>0,h>>>0),O0[u](...d)}var KS=()=>{};function QS(u,d){return S(Mn(u>>>0,d>>>0))}var YS=()=>{throw ke+=1,"unwind"};function JS(){return 4294901760}var ZS=()=>1,eT=()=>navigator.hardwareConcurrency;function tT(u){u>>>=0;var d=(v(),V).length;if(u<=d||4294901760<u)return!1;for(var h=1;4>=h;h*=2){var g=d*(1+.2/h);g=Math.min(g,u+100663296);e:{g=(Math.min(4294901760,65536*Math.ceil(Math.max(u,g)/65536))-Wr.buffer.byteLength+65535)/65536|0;try{Wr.grow(g),Ce();var b=1;break e}catch{}b=void 0}if(b)return!0}return!1}var lr=u=>{var d=wr(u)+1,h=Iu(d);return gr(u,h,d),h},m0=(u,d)=>{(v(),C)[u>>>2>>>0]=d;var h=(v(),C)[u>>>2>>>0];(v(),C)[u+4>>>2>>>0]=(d-h)/4294967296},Ji=u=>(v(),C)[u>>>2>>>0]+4294967296*(v(),F)[u+4>>>2>>>0],gt=[],rT=(u,d)=>{gt[u>>>0]=d},xr=[],Su=[],Tn=(u,d)=>{Su[u]=new Promise(h=>d.finally(()=>h(u)))},se=u=>{if(u)return gt[u>>>0]},sT=(u,d)=>{for(u=(v(),C)[u>>>2>>>0];u;u=(v(),C)[u>>>2>>>0])d[(v(),F)[u+4>>>2>>>0]](u)},Tu=(u,d,h)=>{(v(),C)[u>>>2>>>0]=d,(v(),C)[u+4>>>2>>>0]=h},fv=u=>{var d=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],Mn(d,u)},yr=u=>{var d=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],d?Mn(d,u):u===0?"":void 0},nT=u=>{var d=yr(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={},N=0;N<b;++N){var U=M+24*N;I[fv(U+4)]=(v(),le)[U+16>>>3>>>0]}b=I}else b=void 0;u={module:g,constants:b,entryPoint:yr(u+8)}}else u=void 0;return{label:d,layout:h,compute:u}},_v=(u,d)=>{function h(g,b){g=u[g],(v(),C)[d+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),m0(d+64,u.maxUniformBufferBindingSize),m0(d+72,u.maxStorageBufferBindingSize),h("maxVertexBuffers",88),m0(d+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)},oT=[,"validation","out-of-memory","internal"],aT=[,"compatibility","core"],mv={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"},iT=[,"low-power","high-performance"],lT=[,"occlusion","timestamp"],cT={undefined:1,unknown:1,destroyed:2};function uT(u,d,h,g,b,M){d=Et(d),h=Et(h),g>>>=0,b>>>=0,M>>>=0;var I=se(u>>>0);if(u={},M){var N=(v(),C)[M+12>>>2>>>0];if(N){var U=(v(),C)[M+16>>>2>>>0];u.requiredFeatures=Array.from((v(),C).subarray(U>>>2>>>0,U+4*N>>>2>>>0),ne=>mv[ne])}var Y=(v(),C)[M+20>>>2>>>0];if(Y){let ne=function(Mt,pt,Ts=!1){pt=Y+pt,(pt=(v(),C)[pt>>>2>>>0])==4294967295||Ts&&pt==0||(je[Mt]=pt)},ut=function(Mt,pt){pt=Y+pt;var Ts=(v(),C)[pt>>>2>>>0],NO=(v(),C)[pt+4>>>2>>>0];Ts==4294967295&&NO==4294967295||(je[Mt]=Ji(pt))};var Te=ne,$e=ut,je={};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),ut("maxUniformBufferBindingSize",64),ut("maxStorageBufferBindingSize",72),ne("maxVertexBuffers",88),ut("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=je}(N=(v(),C)[M+24>>>2>>>0])&&(N={label:yr(N+4)},u.defaultQueue=N),u.label=yr(M+4)}ke+=1,Tn(d,I.requestDevice(u).then(ne=>{--ke,At(()=>{gt[b>>>0]=ne.queue,gt[g>>>0]=ne,Tn(h,ne.lost.then(ut=>{At(()=>{ne.onuncapturederror=()=>{};var Mt=ue(),pt=lr(ut.message);y0(h,cT[ut.reason],pt),ce(Mt)})})),ne.onuncapturederror=ut=>{var Mt=5;ut.error instanceof GPUValidationError?Mt=2:ut.error instanceof GPUOutOfMemoryError?Mt=3:ut.error instanceof GPUInternalError&&(Mt=4);var pt=ue();ut=lr(ut.error.message),$v(g,Mt,ut),ce(pt)},"adapterInfo"in ne||(ne.adapterInfo=I.info),k0(d,1,g,0)})},ne=>{--ke,At(()=>{var ut=ue(),Mt=lr(ne.message);k0(d,3,g,Mt),h&&y0(h,4,Mt),ce(ut)})}))}function pT(u){var d=se(u>>>=0),h=xr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete xr[u]}d.destroy()}function dT(u,d,h){h>>>=0;var g=se(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(d>>>0,h)}catch{return 0}var M=M0(16,b.byteLength);return(v(),V).set(new Uint8Array(b),M>>>0),xr[u].push(()=>Kt(M)),M}function fT(u,d,h){h>>>=0;var g=se(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(d>>>0,h)}catch{return 0}var M=M0(16,b.byteLength);return(v(),V).fill(0,M,b.byteLength),xr[u].push(()=>{new Uint8Array(b).set((v(),V).subarray(M>>>0,M+b.byteLength>>>0)),Kt(M)}),M}function _T(u,d,h,g,b){u>>>=0,d=Et(d),h=Et(h),b>>>=0;var M=se(u);xr[u]=[],b==4294967295&&(b=void 0),ke+=1,Tn(d,M.mapAsync(h,g>>>0,b).then(()=>{--ke,At(()=>{b0(d,1,0)})},I=>{--ke,At(()=>{ue();var N=lr(I.message);b0(d,I.name==="AbortError"?4:I.name==="OperationError"?3:0,N),delete xr[u]})}))}function mT(u){var d=se(u>>>=0),h=xr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete xr[u],d.unmap()}}function hT(u){delete gt[u>>>0]}function gT(u,d,h){u>>>=0,d>>>=0,h>>>=0;var g=!!(v(),C)[d+32>>>2>>>0];d={label:yr(d+4),usage:(v(),C)[d+16>>>2>>>0],size:Ji(d+24),mappedAtCreation:g},u=se(u);try{var b=u.createBuffer(d)}catch{return!1}return gt[h>>>0]=b,g&&(xr[h]=[]),!0}function wT(u,d,h,g){u>>>=0,d=Et(d),g>>>=0,h=nT(h>>>0),u=se(u),ke+=1,Tn(d,u.createComputePipelineAsync(h).then(b=>{--ke,At(()=>{gt[g>>>0]=b,x0(d,1,g,0)})},b=>{--ke,At(()=>{var M=ue(),I=lr(b.message);x0(d,b.reason==="validation"?3:b.reason==="internal"?4:0,g,I),ce(M)})}))}function xT(u,d,h){u>>>=0,d>>>=0,h>>>=0;var g=(v(),C)[d>>>2>>>0],b=(v(),F)[g+4>>>2>>>0];d={label:yr(d+4),code:""},b===2&&(d.code=fv(g+8)),u=se(u).createShaderModule(d),gt[h>>>0]=u}var yT=u=>{(u=se(u)).onuncapturederror=null,u.destroy()};function bT(u,d){d=Et(d),u=se(u>>>0),ke+=1,Tn(d,u.popErrorScope().then(h=>{--ke,At(()=>{var g=5;h?h instanceof GPUValidationError?g=2:h instanceof GPUOutOfMemoryError?g=3:h instanceof GPUInternalError&&(g=4):g=1;var b=ue(),M=h?lr(h.message):0;v0(d,1,g,M),ce(b)})},h=>{--ke,At(()=>{var g=ue(),b=lr(h.message);v0(d,1,5,b),ce(g)})}))}function vT(u,d,h,g){if(d=Et(d),g>>>=0,h>>>=0){var b={featureLevel:aT[(v(),F)[h+4>>>2>>>0]],powerPreference:iT[(v(),F)[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?(ke+=1,Tn(d,navigator.gpu.requestAdapter(b).then(M=>{--ke,At(()=>{if(M)gt[g>>>0]=M,Zi(d,1,g,0);else{var I=ue(),N=lr("WebGPU not available on this browser (requestAdapter returned null)");Zi(d,3,g,N),ce(I)}})},M=>{--ke,At(()=>{var I=ue(),N=lr(M.message);Zi(d,4,g,N),ce(I)})}))):(b=ue(),u=lr("WebGPU not available on this browser (navigator.gpu is not available)"),Zi(d,3,g,u),ce(b))}function kT(u,d,h){return u>>>=0,d>>>=0,h>>>=0,nv(async()=>{var g=[];if(h){var b=(v(),F)[h>>>2>>>0];g.length=d+1,g[d]=new Promise(N=>setTimeout(N,b,0))}else g.length=d;for(var M=0;M<d;++M){var I=Ji(u+8*M);if(!(I in Su))return I;g[M]=Su[I]}return g=await Promise.race(g),delete Su[g],g})}var h0,g0={},hv=()=>{if(!h0){var u,d={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 g0)g0[u]===void 0?delete d[u]:d[u]=g0[u];var h=[];for(u in d)h.push(`${u}=${d[u]}`);h0=h}return h0};function gv(u,d){if(n)return De(19,1,u,d);u>>>=0,d>>>=0;var h,g=0,b=0;for(h of hv()){var M=d+g;(v(),C)[u+b>>>2>>>0]=M,g+=gr(h,M,1/0)+1,b+=4}return 0}function wv(u,d){if(n)return De(20,1,u,d);u>>>=0,d>>>=0;var h=hv();for(var g of((v(),C)[u>>>2>>>0]=h.length,u=0,h))u+=wr(g)+1;return(v(),C)[d>>>2>>>0]=u,0}function xv(u){return n?De(21,1,u):52}function yv(u,d,h,g){return n?De(22,1,u,d,h,g):52}function bv(u,d,h,g){return n?De(23,1,u,d,h,g):70}var ET=[null,[],[]];function vv(u,d,h,g){if(n)return De(24,1,u,d,h,g);d>>>=0,h>>>=0,g>>>=0;for(var b=0,M=0;M<h;M++){var I=(v(),C)[d>>>2>>>0],N=(v(),C)[d+4>>>2>>>0];d+=8;for(var U=0;U<N;U++){var Y=u,Te=(v(),V)[I+U>>>0],$e=ET[Y];Te===0||Te===10?((Y===1?T:S)(D1($e)),$e.length=0):$e.push(Te)}b+=N}return(v(),C)[g>>>2>>>0]=b,0}function AT(u){return u>>>0}function MT(u,d){return _v(se(u>>>0).limits,d>>>0),1}function ST(u,d){return se(u>>>0).features.has(mv[d])}function TT(u){return BigInt(se(u>>>0).size)}function OT(u){return BigInt(se(u>>>0).usage)}function IT(u,d){if(u>>>=0,d>>>=0){var h=yr(d+4);h={label:h,timestampWrites:d=(d=(v(),C)[d+12>>>2>>>0])!==0?{querySet:se((v(),C)[d+4>>>2>>>0]),beginningOfPassWriteIndex:(v(),C)[d+8>>>2>>>0],endOfPassWriteIndex:(v(),C)[d+12>>>2>>>0]}:void 0}}return d=se(u),u=Cv(0),h=d.beginComputePass(h),gt[u>>>0]=h,u}function CT(u,d,h,g,b,M){h=Et(h),b=Et(b),M=Et(M),se(u>>>0).copyBufferToBuffer(se(d>>>0),h,se(g>>>0),b,M)}function LT(u){var d=se(u>>>0);return u=Ov(0),d=d.finish(),gt[u>>>0]=d,u}function PT(u,d,h,g,b,M){M=Et(M),se(u>>>0).resolveQuerySet(se(d>>>0),h,g,se(b>>>0),M)}function zT(u,d,h,g){se(u>>>0).dispatchWorkgroups(d,h,g)}function NT(u,d,h){h=Et(h),se(u>>>0).dispatchWorkgroupsIndirect(se(d>>>0),h)}function $T(u){se(u>>>0).end()}function RT(u,d,h,g,b){g>>>=0,b>>>=0,u=se(u>>>0),h=se(h>>>0),g==0?u.setBindGroup(d,h):u.setBindGroup(d,h,(v(),C),b>>>2,g)}function DT(u,d){se(u>>>0).setPipeline(se(d>>>0))}function FT(u,d,h){se(u>>>0).Ee(se(d>>>0),h)}function BT(u,d){var h=se(u>>>0);return u=Tv(0),d=h.getBindGroupLayout(d),gt[u>>>0]=d,u}function UT(u,d){function h(b){var M=(v(),C)[b+8>>>2>>>0],I=(v(),C)[b+32>>>2>>>0],N=(v(),C)[b+36>>>2>>>0],U=0;return sT(b,{327681:Y=>{U=(v(),C)[Y+8>>>2>>>0]}}),M?((I=Ji(b+24))==-1&&(I=void 0),M={buffer:se(M),offset:Ji(b+16),size:I}):M=se(I||N||U),{binding:(v(),C)[b+4>>>2>>>0],resource:M}}u>>>=0,d={label:yr(4+(d>>>=0)),layout:se((v(),C)[d+12>>>2>>>0]),entries:(function(b,M){for(var I=[],N=0;N<b;++N)I.push(h(M+40*N));return I})((v(),C)[d+16>>>2>>>0],(v(),C)[d+20>>>2>>>0])},u=se(u);var g=Sv(0);return rT(g,u.createBindGroup(d)),g}function jT(u,d){var h;return u>>>=0,(d>>>=0)&&(h={label:yr(d+4)}),d=se(u),u=Iv(0),h=d.createCommandEncoder(h),gt[u>>>0]=h,u}function GT(u,d){u>>>=0,d>>>=0,d={type:lT[(v(),F)[d+12>>>2>>>0]],count:(v(),C)[d+16>>>2>>>0]};var h=se(u);return u=Lv(0),d=h.createQuerySet(d),gt[u>>>0]=d,u}function qT(u,d){u=se(u>>>0).adapterInfo,d>>>=0,(v(),C)[d+52>>>2>>>0]=u.subgroupMinSize,(v(),C)[d+56>>>2>>>0]=u.subgroupMaxSize;var h=u.vendor+u.architecture+u.device+u.description,g=wr(h)+1,b=On(g);return b&&gr(h,b,g),h=b,g=wr(u.vendor),Tu(d+4,h,g),h+=g,g=wr(u.architecture),Tu(d+12,h,g),h+=g,g=wr(u.device),Tu(d+20,h,g),Tu(d+28,h+g,wr(u.description)),(v(),F)[d+36>>>2>>>0]=2,u=u.isFallbackAdapter?3:4,(v(),F)[d+40>>>2>>>0]=u,(v(),C)[d+44>>>2>>>0]=0,(v(),C)[d+48>>>2>>>0]=0,1}var WT={"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 VT(u,d){d>>>=0;var h=se(u>>>0);u=On(4*h.features.size);var g=0,b=0;for(let M of h.features)0<=(h=WT[M])&&((v(),F)[u+g>>>2>>>0]=h,g+=4,b++);(v(),C)[d+4>>>2>>>0]=u,(v(),C)[d>>>2>>>0]=b}function HT(u,d){return _v(se(u>>>0).limits,d>>>0),1}function XT(u,d){se(u>>>0).pushErrorScope(oT[d])}function KT(u,d,h){d>>>=0,h>>>=0,u=se(u>>>0),d=Array.from((v(),F).subarray(h>>>2>>>0,h+4*d>>>2>>>0),g=>se(g)),u.submit(d)}function QT(u,d,h,g,b){h=Et(h),g>>>=0,b>>>=0,u=se(u>>>0),d=se(d>>>0),g=(v(),V).subarray(g>>>0,g+b>>>0),u.writeBuffer(d,h,g,0,b)}n||(function(){for(var u=e.numThreads-1;u--;)C1();Se.push(async()=>{var d=(async function(){if(!n)return Promise.all(ot.map(I1))})();xe++,await d,--xe==0&&He&&(d=He,He=null,d())})})(),n||(Wr=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),Ce()),e.wasmBinary&&(f=e.wasmBinary),e.stackSave=()=>ue(),e.stackRestore=u=>ce(u),e.stackAlloc=u=>Iu(u),e.setValue=function(u,d,h="i8"){switch(h.endsWith("*")&&(h="*"),h){case"i1":case"i8":(v(),B)[u>>>0]=d;break;case"i16":(v(),q)[u>>>1>>>0]=d;break;case"i32":(v(),F)[u>>>2>>>0]=d;break;case"i64":(v(),L)[u>>>3>>>0]=BigInt(d);break;case"float":(v(),te)[u>>>2>>>0]=d;break;case"double":(v(),le)[u>>>3>>>0]=d;break;case"*":(v(),C)[u>>>2>>>0]=d;break;default:Ue(`invalid type for setValue: ${h}`)}},e.getValue=function(u,d="i8"){switch(d.endsWith("*")&&(d="*"),d){case"i1":case"i8":return(v(),B)[u>>>0];case"i16":return(v(),q)[u>>>1>>>0];case"i32":return(v(),F)[u>>>2>>>0];case"i64":return(v(),L)[u>>>3>>>0];case"float":return(v(),te)[u>>>2>>>0];case"double":return(v(),le)[u>>>3>>>0];case"*":return(v(),C)[u>>>2>>>0];default:Ue(`invalid type for getValue: ${d}`)}},e.UTF8ToString=Mn,e.stringToUTF8=gr,e.lengthBytesUTF8=wr;var kv,Ev,w0,Ou,Kt,On,Av,Mv,Sv,Tv,Ov,Iv,Cv,Lv,Pv,zv,Nv,x0,y0,b0,v0,Zi,k0,$v,E0,Rv,Dv,Fv,A0,Bv,Uv,M0,ge,el,jv,ce,Iu,ue,Gv,S0,qv,Wv,Vv,T0,Hv,Xv,Kv,Qv,Yv,Jv,Zv,ek,tk,rk,sk,nk,ok,ak,ik,lk,ck,uk,pk,dk,fk,_k,mk,hk,gk,wk,xk,yk,bk,vk,kk,Ek,Ak,Mk,Sk,Tk,Ok,Ik,Ck,br,YT=[qr,As,z1,F1,B1,U1,j1,G1,q1,W1,V1,H1,X1,K1,Q1,Y1,cv,uv,pv,gv,wv,xv,yv,bv,vv],O0={925676:(u,d,h,g,b)=>{if(e===void 0||!e.Uc)return 1;if((u=Mn(Number(u>>>0))).startsWith("./")&&(u=u.substring(2)),!(u=e.Uc.get(u)))return 2;if(d=Number(d>>>0),h=Number(h>>>0),g=Number(g>>>0),d+h>u.byteLength)return 3;try{let M=u.subarray(d,d+h);switch(b){case 0:(v(),V).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,d,h)=>{e.Sd(u,(v(),V).subarray(d>>>0,d+h>>>0))},926564:()=>e.me(),926606:u=>{e.jd(u)},926643:()=>typeof wasmOffsetConverter<"u"};function JT(u,d,h,g){var b=ue();try{return ek(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function ZT(u,d,h){var g=ue();try{return Yv(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;ge(1,0)}}function eO(u,d,h){var g=ue();try{Vv(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;ge(1,0)}}function tO(u,d){var h=ue();try{return T0(u,d)}catch(g){if(ce(h),g!==g+0)throw g;ge(1,0)}}function rO(u){var d=ue();try{Hv(u)}catch(h){if(ce(d),h!==h+0)throw h;ge(1,0)}}function sO(u,d,h,g,b,M,I){var N=ue();try{return Qv(u,d,h,g,b,M,I)}catch(U){if(ce(N),U!==U+0)throw U;ge(1,0)}}function nO(u,d){var h=ue();try{tk(u,d)}catch(g){if(ce(h),g!==g+0)throw g;ge(1,0)}}function oO(u,d,h,g,b,M){var I=ue();try{Xv(u,d,h,g,b,M)}catch(N){if(ce(I),N!==N+0)throw N;ge(1,0)}}function aO(u,d,h,g){var b=ue();try{Zv(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function iO(u,d,h,g,b,M,I){var N=ue();try{sk(u,d,h,g,b,M,I)}catch(U){if(ce(N),U!==U+0)throw U;ge(1,0)}}function lO(u,d,h,g,b,M,I){var N=ue();try{nk(u,d,h,g,b,M,I)}catch(U){if(ce(N),U!==U+0)throw U;ge(1,0)}}function cO(u,d,h,g,b,M,I,N){var U=ue();try{fk(u,d,h,g,b,M,I,N)}catch(Y){if(ce(U),Y!==Y+0)throw Y;ge(1,0)}}function uO(u,d,h,g,b,M,I,N,U,Y,Te,$e){var je=ue();try{ok(u,d,h,g,b,M,I,N,U,Y,Te,$e)}catch(ne){if(ce(je),ne!==ne+0)throw ne;ge(1,0)}}function pO(u,d,h,g,b){var M=ue();try{return rk(u,d,h,g,b)}catch(I){if(ce(M),I!==I+0)throw I;ge(1,0)}}function dO(u,d,h,g,b){var M=ue();try{Kv(u,d,h,g,b)}catch(I){if(ce(M),I!==I+0)throw I;ge(1,0)}}function fO(u,d,h,g,b,M,I,N){var U=ue();try{Jv(u,d,h,g,b,M,I,N)}catch(Y){if(ce(U),Y!==Y+0)throw Y;ge(1,0)}}function _O(u){var d=ue();try{return _k(u)}catch(h){if(ce(d),h!==h+0)throw h;ge(1,0)}}function mO(u,d,h){var g=ue();try{return mk(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;ge(1,0)}}function hO(u,d){var h=ue();try{return Sk(u,d)}catch(g){if(ce(h),g!==g+0)throw g;return ge(1,0),0n}}function gO(u,d,h,g,b){var M=ue();try{hk(u,d,h,g,b)}catch(I){if(ce(M),I!==I+0)throw I;ge(1,0)}}function wO(u){var d=ue();try{return ak(u)}catch(h){if(ce(d),h!==h+0)throw h;return ge(1,0),0n}}function xO(u,d,h,g,b,M){var I=ue();try{return pk(u,d,h,g,b,M)}catch(N){if(ce(I),N!==N+0)throw N;ge(1,0)}}function yO(u,d,h,g,b,M){var I=ue();try{return gk(u,d,h,g,b,M)}catch(N){if(ce(I),N!==N+0)throw N;ge(1,0)}}function bO(u,d,h,g,b,M){var I=ue();try{return wk(u,d,h,g,b,M)}catch(N){if(ce(I),N!==N+0)throw N;ge(1,0)}}function vO(u,d,h,g,b,M,I,N){var U=ue();try{return dk(u,d,h,g,b,M,I,N)}catch(Y){if(ce(U),Y!==Y+0)throw Y;ge(1,0)}}function kO(u,d,h,g,b){var M=ue();try{return xk(u,d,h,g,b)}catch(I){if(ce(M),I!==I+0)throw I;return ge(1,0),0n}}function EO(u,d,h,g){var b=ue();try{return yk(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function AO(u,d,h,g){var b=ue();try{return bk(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function MO(u,d,h,g,b,M,I,N,U,Y,Te,$e){var je=ue();try{return vk(u,d,h,g,b,M,I,N,U,Y,Te,$e)}catch(ne){if(ce(je),ne!==ne+0)throw ne;ge(1,0)}}function SO(u,d,h,g,b,M,I,N,U,Y,Te){var $e=ue();try{kk(u,d,h,g,b,M,I,N,U,Y,Te)}catch(je){if(ce($e),je!==je+0)throw je;ge(1,0)}}function TO(u,d,h,g,b,M,I,N,U,Y,Te,$e,je,ne,ut,Mt){var pt=ue();try{Ek(u,d,h,g,b,M,I,N,U,Y,Te,$e,je,ne,ut,Mt)}catch(Ts){if(ce(pt),Ts!==Ts+0)throw Ts;ge(1,0)}}function OO(u,d,h,g){var b=ue();try{return Ak(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function IO(u,d,h,g,b){var M=ue();try{return Mk(u,d,h,g,b)}catch(I){if(ce(M),I!==I+0)throw I;ge(1,0)}}function CO(u,d,h){var g=ue();try{return lk(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;return ge(1,0),0n}}function LO(u,d,h){var g=ue();try{return ik(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;ge(1,0)}}function PO(u,d,h){var g=ue();try{return ck(u,d,h)}catch(b){if(ce(g),b!==b+0)throw b;ge(1,0)}}function zO(u,d,h,g){var b=ue();try{uk(u,d,h,g)}catch(M){if(ce(b),M!==M+0)throw M;ge(1,0)}}function Cu(){if(0<xe)He=Cu;else if(n)w?.(e),ae();else{for(var u=Se;0<u.length;)u.shift()(e);0<xe?He=Cu:(e.calledRun=!0,P||(ae(),w?.(e)))}}return n||(br=await rt(),Cu()),e.PTR_SIZE=4,e.webgpuInit=u=>{let d=new WeakMap,h,g,b=1;e.webgpuRegisterDevice=N=>{if(g!==void 0)throw Error("another WebGPU EP inference session is being created.");if(N){var U=d.get(N);if(!U){let Y=((Te,$e=0)=>{var je=Nv($e);return $e=zv($e,je),gt[je>>>0]=Te.queue,gt[$e>>>0]=Te,$e})(N,U=Mv(0));U=[b++,U,Y],d.set(N,U)}return h=N,g=U[0],U}h=void 0,g=0};let M=new Map;e.webgpuOnCreateSession=N=>{if(g!==void 0){var U=g;if(g=void 0,N){let Y=w0(U);M.set(N,Y),U===0&&u(h??se(Y))}h=void 0}},e.webgpuOnReleaseSession=N=>{M.delete(N)};let I=Symbol("gpuBufferMetadata");e.webgpuRegisterBuffer=(N,U,Y)=>{if(Y)return N[I]=[Y,NaN],Y;if(Y=N[I])return Y[1]++,Y[0];if((U=M.get(U))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return U=((Te,$e=0)=>(Te.mapState==="unmapped"||Ue(),$e=Pv($e),gt[$e>>>0]=Te,$e))(N,U),N[I]=[U,1],U},e.webgpuUnregisterBuffer=N=>{let U=N[I];if(!U)throw Error("Buffer is not registered");U[1]--,U[1]===0&&(Av(U[0]),delete N[I])},e.webgpuGetBuffer=N=>se(N),e.webgpuCreateDownloader=(N,U,Y)=>{if((Y=M.get(Y))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let Te=se(Y),$e=16*Math.ceil(Number(U)/16);return async()=>{let je=Te.createBuffer({size:$e,usage:9});try{let ne=Te.createCommandEncoder();return ne.copyBufferToBuffer(N,0,je,0,$e),Te.queue.submit([ne.finish()]),await je.mapAsync(GPUMapMode.READ),je.getMappedRange().slice(0,U)}finally{je.destroy()}}},e.ad=(N,U)=>{var Y=U.buffer;let Te=U.byteOffset,$e=U.byteLength;if(U=16*Math.ceil(Number($e)/16),N=se(N),!h){var je=w0(g);h=se(je)}let ne=(je=h.createBuffer({mappedAtCreation:!0,size:U,usage:6})).getMappedRange();new Uint8Array(ne).set(new Uint8Array(Y,Te,$e)),je.unmap(),(Y=h.createCommandEncoder()).copyBufferToBuffer(je,0,N,0,U),h.queue.submit([Y.finish()]),je.destroy()}},e.webnnInit=u=>{let d=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=>d.onRunStart(h),e.webnnOnRunEnd=d.onRunEnd.bind(d),e.webnnOnReleaseSession=h=>{d.onReleaseSession(h)},e.webnnCreateMLTensorDownloader=(h,g)=>d.createMLTensorDownloader(h,g),e.webnnRegisterMLTensor=(h,g,b,M)=>d.registerMLTensor(h,g,b,M),e.webnnCreateMLContext=h=>d.createMLContext(h),e.webnnRegisterMLConstant=(h,g,b,M,I,N)=>d.registerMLConstant(h,g,b,M,I,e.Uc,N),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)},J?e:new Promise((u,d)=>{w=u,x=d})}var LA,FE,PP=be(()=>{"use strict";LA=DE,FE=globalThis.self?.name?.startsWith("em-pthread"),FE&&DE()}),Z0,mb,BE,Pt,PA,Xu,UE,jE,eb,GE,tb,zA,rb,NA,Eb=be(()=>{"use strict";kb(),Z0=typeof location>"u"?void 0:location.origin,mb=tr.url>"file:"&&tr.url<"file;",BE=()=>{if(mb){let t=URL;return new URL(new t("ort.webgpu.bundle.min.mjs",tr.url).href,Z0).href}return tr.url},Pt=BE(),PA=()=>{if(Pt&&!Pt.startsWith("blob:"))return Pt.substring(0,Pt.lastIndexOf("/")+1)},Xu=(t,e)=>{try{let r=e??Pt;return(r?new URL(t,r):new URL(t)).origin===Z0}catch{return!1}},UE=(t,e)=>{let r=e??Pt;try{return(r?new URL(t,r):new URL(t)).href}catch{return}},jE=(t,e)=>`${e??"./"}${t}`,eb=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},GE=async t=>(await import(t)).default,tb=(LP(),ep(OA)).default,zA=async()=>{if(!Pt)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Xu(Pt))return[void 0,tb()];let t=await eb(Pt);return[t,tb(t)]},rb=(PP(),ep(CA)).default,NA=async(t,e,r,s)=>{let n=rb&&!(t||e);if(n)if(Pt)n=Xu(Pt)||s&&!r;else if(s&&!r)n=!0;else throw new Error("cannot determine the script source URL.");if(n)return[void 0,rb];{let o="ort-wasm-simd-threaded.asyncify.mjs",a=t??UE(o,e),i=r&&a&&!Xu(a,e),l=i?await eb(a):a??jE(o,e);return[i?l:void 0,await GE(l)]}}}),sb,Ku,dl,nb,qE,WE,VE,Ab,Be,Gs=be(()=>{"use strict";Eb(),Ku=!1,dl=!1,nb=!1,qE=()=>{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}},WE=()=>{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}},VE=()=>{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(Ku)return Promise.resolve();if(dl)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(nb)throw new Error("previous call to 'initializeWebAssembly()' failed.");dl=!0;let e=t.initTimeout,r=t.numThreads;if(t.simd!==!1){if(t.simd==="relaxed"){if(!VE())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!WE())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let s=qE();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,[f,_]=await NA(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,k)=>{let E={numThreads:r};if(p)E.wasmBinary=p,E.locateFile=A=>A;else if(c||o)E.locateFile=A=>c??o+A;else if(i&&i.indexOf("blob:")!==0)E.locateFile=A=>new URL(A,i).href;else if(f){let A=PA();A&&(E.locateFile=T=>A+T)}_(E).then(A=>{dl=!1,Ku=!0,sb=A,x(),f&&URL.revokeObjectURL(f)},A=>{dl=!1,nb=!0,k(A)})})),await Promise.race(w),m)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},Be=()=>{if(Ku&&sb)return sb;throw new Error("WebAssembly is not initialized yet.")}}),zt,rp,ze,Mb=be(()=>{"use strict";Gs(),zt=(t,e)=>{let r=Be(),s=r.lengthBytesUTF8(t)+1,n=r._malloc(s);return r.stringToUTF8(t,n,s),e.push(n),n},rp=(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")rp(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}`)})},ze=t=>{let e=Be(),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)}}}),$A,zP=be(()=>{"use strict";Gs(),Mb(),$A=t=>{let e=Be(),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=zt(t.tag,s)),r=e._OrtCreateRunOptions(n.logSeverityLevel,n.logVerbosityLevel,!!n.terminate,o),r===0&&ze("Can't create run options."),t?.extra!==void 0&&rp(t.extra,"",new WeakSet,(a,i)=>{let l=zt(a,s),c=zt(i,s);e._OrtAddRunConfigEntry(r,l,c)!==0&&ze(`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}}}),HE,XE,KE,Qu,es,QE,RA,NP=be(()=>{"use strict";Gs(),Mb(),HE=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}`)}},XE=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},KE=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)},Qu=(t,e,r,s)=>{let n=zt(e,s),o=zt(r,s);Be()._OrtAddSessionConfigEntry(t,n,o)!==0&&ze(`Can't set a session config entry: ${e} - ${r}.`)},es=(t,e,r,s)=>{let n=zt(e,s),o=zt(r,s);t.push([n,o])},QE=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&&Qu(t,"deviceType",f,r)}break;case"webgpu":{o="WebGPU";let f;if(typeof n!="string"){let m=n;if(m.device)if(typeof GPUDevice<"u"&&m.device instanceof GPUDevice)f=m.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 m.preferredLayout=="string"&&es(a,"preferredLayout",m.preferredLayout,r),m.forceCpuNodeNames){let x=Array.isArray(m.forceCpuNodeNames)?m.forceCpuNodeNames:[m.forceCpuNodeNames];es(a,"forceCpuNodeNames",x.join(`
|
|
13
|
-
`),r)}m.validationMode&&es(a,"validationMode",m.validationMode,r)}let _=Be().webgpuRegisterDevice(f);if(_){let[m,w,x]=_;es(a,"deviceId",m.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=zt(o,r),l=a.length,c=0,p=0;if(l>0){c=Be()._malloc(l*Be().PTR_SIZE),r.push(c),p=Be()._malloc(l*Be().PTR_SIZE),r.push(p);for(let f=0;f<l;f++)Be().setValue(c+f*Be().PTR_SIZE,a[f][0],"*"),Be().setValue(p+f*Be().PTR_SIZE,a[f][1],"*")}await Be()._OrtAppendExecutionProvider(t,i,c,p,l)!==0&&ze(`Can't append execution provider: ${o}.`)}},RA=async t=>{let e=Be(),r=0,s=[],n=t||{};KE(n);try{let o=HE(n.graphOptimizationLevel??"all"),a=XE(n.executionMode??"sequential"),i=typeof n.logId=="string"?zt(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"?zt(n.optimizedModelFilePath,s):0;if(r=e._OrtCreateSessionOptions(o,!!n.enableCpuMemArena,!!n.enableMemPattern,a,!!n.enableProfiling,0,i,l,c,p),r===0&&ze("Can't create session options."),n.executionProviders&&await QE(r,n,s),n.enableGraphCapture!==void 0){if(typeof n.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${n.enableGraphCapture}`);Qu(r,"enableGraphCapture",n.enableGraphCapture.toString(),s)}if(n.freeDimensionOverrides)for(let[f,_]of Object.entries(n.freeDimensionOverrides)){if(typeof f!="string")throw new Error(`free dimension override name must be a string: ${f}`);if(typeof _!="number"||!Number.isInteger(_)||_<0)throw new Error(`free dimension override value must be a non-negative integer: ${_}`);let m=zt(f,s);e._OrtAddFreeDimensionOverride(r,m,_)!==0&&ze(`Can't set a free dimension override: ${f} - ${_}.`)}return n.extra!==void 0&&rp(n.extra,"",new WeakSet,(f,_)=>{Qu(r,f,_,s)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseSessionOptions(r)!==0&&ze("Can't release session options."),s.forEach(a=>e._free(a)),o}}}),Ds,Zu,Dn,gl,sp,Sb,Tb,hb,Fn=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}`)}},Zu=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}`)}},Dn=(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},gl=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}`)}},sp=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}`)}},Sb=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",Tb=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",hb=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}`)}}}),Ob,DA=be(()=>{"use strict";kb(),Ob=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)}}),FA,$P=be(()=>{"use strict";Fn(),FA=(t,e)=>new(gl(e))(t)}),YE,JE,ZE,eA,BA,tA,vt,UA=be(()=>{"use strict";Fn(),YE=["V","I","W","E","F"],JE=(t,e)=>{console.log(`[${YE[t]},${new Date().toISOString()}]${e}`)},BA=(t,e)=>{ZE=t,eA=e},tA=(t,e)=>{let r=sp(t),s=sp(ZE);r>=s&&JE(r,typeof e=="function"?e():e)},vt=(...t)=>{eA&&tA(...t)}}),ob,gb,ab,rA,ib,sA,lb,cb,ub,nA,jA,RP=be(()=>{"use strict";Fn(),UA(),ob=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),gb=(t,e)=>{if(e==="int32")return t;let r=ob.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(gl(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'`)}},ab=(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}`)}},rA=1,ib=()=>rA++,sA=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),lb=(t,e)=>{let r=ob.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},cb=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 lb(this.dataType,this.tensorShape)}destroy(){vt("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=ab(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}},ub=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=sA.get(e),!a||o?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);vt("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!==lb(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=gb(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 vt("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?ab(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()}},nA=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=ib();return this.tensorTrackersById.set(t,new ub(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){vt("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){vt("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=ib(),a=new cb({sessionId:t,context:n,tensor:e,dataType:r,shape:s});return this.tensorTrackersById.set(o,new ub(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)){vt("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}`);let f=this.freeTensors.splice(c,1)[0];return f.sessionId=t,f}vt("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 cb({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)}},jA=(...t)=>new nA(...t)}),GA={};wl(GA,{WebNNBackend:()=>qA});var fl,oA,qA,DP=be(()=>{"use strict";Fn(),Gs(),$P(),RP(),UA(),fl=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),oA=(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])},qA=class{constructor(t){this.tensorManager=jA(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,BA(t.logLevel,!!t.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(t){vt("verbose",()=>`[WebNN] onRunStart {sessionId: ${t}}`),this.activeSessionId=t}onRunEnd(t){vt("verbose",()=>`[WebNN] onRunEnd {sessionId: ${t}}`);let e=this.temporarySessionTensorIds.get(t);if(e){for(let r of e)vt("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=>oA(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){vt("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t)}async ensureTensor(t,e,r,s,n){let o=fl.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){vt("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${r}}`);let s=fl.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(!Be().shouldTransferToMLTensor)throw new Error("Trying to upload to a MLTensor while shouldTransferToMLTensor is false");vt("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 FA(r,e)}}registerMLTensor(t,e,r,s){let n=fl.get(r);if(!n)throw new Error(`Unsupported ONNX data type: ${r}`);let o=this.tensorManager.registerTensor(t,e,n,s);return vt("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 f=gb(new Uint8Array(c),"int64");p=new Int32Array(f.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 vt("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=fl.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(){}}}),aA,Ib,Cb,ts,iA,pb,np,Lb,Pb,db,zb,Nb,$b,WA=be(()=>{"use strict";js(),zP(),NP(),Fn(),Gs(),Mb(),DA(),aA=(t,e)=>{Be()._OrtInit(t,e)!==0&&ze("Can't initialize onnxruntime.")},Ib=async t=>{aA(t.wasm.numThreads,sp(t.logLevel))},Cb=async(t,e)=>{Be().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"&&Be().webgpuInit(s=>{t.webgpu.device=s}),e==="webnn"){let s=new(DP(),ep(GA)).WebNNBackend(t);Be().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,iA=t=>{let e=Be(),r=e.stackSave();try{let s=e.PTR_SIZE,n=e.stackAlloc(2*s);e._OrtGetInputOutputCount(t,n,n+s)!==0&&ze("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)}},pb=(t,e)=>{let r=Be(),s=r.stackSave(),n=0;try{let o=r.PTR_SIZE,a=r.stackAlloc(2*o);r._OrtGetInputOutputMetadata(t,e,a,a+o)!==0&&ze("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 f=0;f<c;f++){let _=Number(r.getValue(n+8+f*o,"*"));p.push(_!==0?r.UTF8ToString(_):Number(r.getValue(n+8+(f+c)*o,"*")))}return[i,l,p]}finally{r.stackRestore(s),n!==0&&r._OrtFree(n)}},np=t=>{let e=Be(),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]},Lb=async(t,e)=>{let r,s,n=Be();Array.isArray(t)?[r,s]=t:t.buffer===n.HEAPU8.buffer?[r,s]=[t.byteOffset,t.byteLength]:[r,s]=np(t);let o=0,a=0,i=0,l=[],c=[],p=[];try{if([a,l]=await RA(e),e?.externalData&&n.mountExternalData){let S=[];for(let P of e.externalData){let O=typeof P=="string"?P:P.path;S.push(Ob(typeof P=="string"?P:P.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 P=S,O=P?.context,v=P?.gpuDevice,j=P?.deviceType,H=P?.powerPreference;O?n.currentContext=O:v?n.currentContext=await n.webnnCreateMLContext(v):n.currentContext=await n.webnnCreateMLContext({deviceType:j,powerPreference:H})}else n.currentContext=await n.webnnCreateMLContext();break}o=await n._OrtCreateSession(r,s,a),n.webgpuOnCreateSession?.(o),o===0&&ze("Can't create a session."),n.jsepOnCreateSession?.(),n.currentContext&&(n.webnnRegisterMLContext(o,n.currentContext),n.currentContext=void 0,n.shouldTransferToMLTensor=!0);let[f,_]=iA(o),m=!!e?.enableGraphCapture,w=[],x=[],k=[],E=[],A=[];for(let S=0;S<f;S++){let[P,O,v]=pb(o,S);P===0&&ze("Can't get an input name."),c.push(P);let j=n.UTF8ToString(P);w.push(j),k.push(O===0?{name:j,isTensor:!1}:{name:j,isTensor:!0,type:Zu(O),shape:v})}for(let S=0;S<_;S++){let[P,O,v]=pb(o,S+f);P===0&&ze("Can't get an output name."),p.push(P);let j=n.UTF8ToString(P);x.push(j),E.push(O===0?{name:j,isTensor:!1}:{name:j,isTensor:!0,type:Zu(O),shape:v});{if(m&&e?.preferredOutputLocation===void 0){A.push("gpu-buffer");continue}let H=typeof e?.preferredOutputLocation=="string"?e.preferredOutputLocation:e?.preferredOutputLocation?.[j]??"cpu",B=n.webnnIsGraphOutput;if(H==="cpu"&&B&&B(o,j)){A.push("ml-tensor-cpu-output");continue}if(H!=="cpu"&&H!=="cpu-pinned"&&H!=="gpu-buffer"&&H!=="ml-tensor")throw new Error(`Not supported preferred output location: ${H}.`);if(m&&H!=="gpu-buffer")throw new Error(`Not supported preferred output location: ${H}. Only 'gpu-buffer' location is supported when enableGraphCapture is true.`);A.push(H)}}let T=null;return A.some(S=>S==="gpu-buffer"||S==="ml-tensor"||S==="ml-tensor-cpu-output")&&(i=n._OrtCreateBinding(o),i===0&&ze("Can't create IO binding."),T={handle:i,outputPreferredLocations:A,outputPreferredLocationsEncoded:A.map(S=>S==="ml-tensor-cpu-output"?"ml-tensor":S).map(S=>hb(S))}),ts.set(o,[o,c,p,T,m,!1]),[o,w,x,k,E]}catch(f){throw c.forEach(_=>n._OrtFree(_)),p.forEach(_=>n._OrtFree(_)),i!==0&&n._OrtReleaseBinding(i)!==0&&ze("Can't release IO binding."),o!==0&&n._OrtReleaseSession(o)!==0&&ze("Can't release session."),f}finally{n._free(r),a!==0&&n._OrtReleaseSessionOptions(a)!==0&&ze("Can't release session options."),l.forEach(f=>n._free(f)),n.unmountExternalData?.()}},Pb=t=>{let e=Be(),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&&ze("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&ze("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&&ze("Can't release session."),ts.delete(t)},db=async(t,e,r,s,n,o,a=!1)=>{if(!t){e.push(0);return}let i=Be(),l=i.PTR_SIZE,c=t[0],p=t[1],f=t[3],_=f,m,w;if(c==="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=Dn(Ds(c),p);{let A=i.webgpuRegisterBuffer;if(!A)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');m=A(E,s)}}else if(f==="ml-tensor"){let E=t[2].mlTensor;w=Dn(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,E,Ds(c),p)}else{let E=t[2];if(Array.isArray(E)){w=l*E.length,m=i._malloc(w),r.push(m);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(m+A*l,zt(E[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 P=Ds(c);w=Dn(P,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 j=await O(s,P,p);v(j,new Uint8Array(E.buffer,E.byteOffset,E.byteLength)),m=j}else w=E.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),m)}else w=E.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),m)}}let x=i.stackSave(),k=i.stackAlloc(4*p.length);try{p.forEach((A,T)=>i.setValue(k+T*l,A,l===4?"i32":"i64"));let E=i._OrtCreateTensor(Ds(c),m,w,k,p.length,hb(_));E===0&&ze(`Can't create tensor for input/output. session=${s}, index=${o}.`),e.push(E)}finally{i.stackRestore(x)}},zb=async(t,e,r,s,n,o)=>{let a=Be(),i=a.PTR_SIZE,l=ts.get(t);if(!l)throw new Error(`cannot run inference. invalid session id: ${t}`);let c=l[0],p=l[1],f=l[2],_=l[3],m=l[4],w=l[5],x=e.length,k=s.length,E=0,A=[],T=[],S=[],P=[],O=[],v=a.stackSave(),j=a.stackAlloc(x*i),H=a.stackAlloc(x*i),B=a.stackAlloc(k*i),V=a.stackAlloc(k*i);try{[E,A]=$A(o),ss("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)await db(r[C],T,P,t,p[e[C]],e[C],m);for(let C=0;C<k;C++)await db(n[C],S,P,t,f[s[C]],x+s[C],m);ns("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)a.setValue(j+C*i,T[C],"*"),a.setValue(H+C*i,p[e[C]],"*");for(let C=0;C<k;C++)a.setValue(B+C*i,S[C],"*"),a.setValue(V+C*i,f[s[C]],"*");if(_&&!w){let{handle:C,outputPreferredLocations:te,outputPreferredLocationsEncoded:le}=_;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 L=0;L<x;L++){let z=e[L];await a._OrtBindInput(C,p[z],T[L])!==0&&ze(`Can't bind input[${L}] for session=${t}.`)}for(let L=0;L<k;L++){let z=s[L];n[L]?.[3]?(O.push(S[L]),a._OrtBindOutput(C,f[z],S[L],0)!==0&&ze(`Can't bind pre-allocated output[${L}] for session=${t}.`)):a._OrtBindOutput(C,f[z],0,le[z])!==0&&ze(`Can't bind output[${L}] to ${te[L]} for session=${t}.`)}ns("wasm bindInputsOutputs"),ts.set(t,[c,p,f,_,m,!0])}a.jsepOnRunStart?.(c),a.webnnOnRunStart?.(c);let q;_?q=await a._OrtRunWithBinding(c,_.handle,k,B,E):q=await a._OrtRun(c,H,j,x,V,k,B,E),q!==0&&ze("failed to call OrtRun().");let Q=[],F=[];ss("wasm ProcessOutputTensor");for(let C=0;C<k;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&&ze("Can't release tensor.");continue}let le=a.stackSave(),L=a.stackAlloc(4*i),z=!1,R,J=0;try{a._OrtGetTensorData(te,L,L+i,L+2*i,L+3*i)!==0&&ze(`Can't access output tensor data on index ${C}.`);let Ce=i===4?"i32":"i64",ae=Number(a.getValue(L,Ce));J=a.getValue(L+i,"*");let Ue=a.getValue(L+i*2,"*"),Je=Number(a.getValue(L+i*3,Ce)),rt=[];for(let Se=0;Se<Je;Se++)rt.push(Number(a.getValue(Ue+Se*i,Ce)));a._OrtFree(Ue)!==0&&ze("Can't free memory for tensor dims.");let nt=rt.reduce((Se,xe)=>Se*xe,1);R=Zu(ae);let at=_?.outputPreferredLocations[s[C]];if(R==="string"){if(at==="gpu-buffer"||at==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Se=[];for(let xe=0;xe<nt;xe++){let He=a.getValue(J+xe*i,"*"),Ot=a.getValue(J+(xe+1)*i,"*"),ke=xe===nt-1?void 0:Ot-He;Se.push(a.UTF8ToString(He,ke))}Q.push([R,rt,Se,"cpu"])}else if(at==="gpu-buffer"&&nt>0){let Se=a.webgpuGetBuffer;if(!Se)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let xe=Se(J),He=Dn(ae,nt);if(He===void 0||!Sb(R))throw new Error(`Unsupported data type: ${R}`);z=!0;{a.webgpuRegisterBuffer(xe,t,J);let Ot=a.webgpuCreateDownloader(xe,He,t);Q.push([R,rt,{gpuBuffer:xe,download:async()=>{let ke=await Ot();return new(gl(R))(ke)},dispose:()=>{a._OrtReleaseTensor(te)!==0&&ze("Can't release tensor.")}},"gpu-buffer"])}}else if(at==="ml-tensor"&&nt>0){let Se=a.webnnEnsureTensor,xe=a.webnnIsGraphInputOutputTypeSupported;if(!Se||!xe)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Dn(ae,nt)===void 0||!Tb(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 He=await Se(t,J,ae,rt,!1);z=!0,Q.push([R,rt,{mlTensor:He,download:a.webnnCreateMLTensorDownloader(J,R),dispose:()=>{a.webnnReleaseTensorId(J),a._OrtReleaseTensor(te)}},"ml-tensor"])}else if(at==="ml-tensor-cpu-output"&&nt>0){let Se=a.webnnCreateMLTensorDownloader(J,R)(),xe=Q.length;z=!0,F.push((async()=>{let He=[xe,await Se];return a.webnnReleaseTensorId(J),a._OrtReleaseTensor(te),He})()),Q.push([R,rt,[],"cpu"])}else{let Se=gl(R),xe=new Se(nt);new Uint8Array(xe.buffer,xe.byteOffset,xe.byteLength).set(a.HEAPU8.subarray(J,J+xe.byteLength)),Q.push([R,rt,xe,"cpu"])}}finally{a.stackRestore(le),R==="string"&&J&&a._free(J),z||a._OrtReleaseTensor(te)}}_&&!m&&(a._OrtClearBoundOutputs(_.handle)!==0&&ze("Can't clear bound outputs."),ts.set(t,[c,p,f,_,m,!1]));for(let[C,te]of await Promise.all(F))Q[C][2]=te;return ns("wasm ProcessOutputTensor"),Q}finally{a.webnnOnRunEnd?.(c),a.stackRestore(v),r.forEach(q=>{q&&q[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(q[2].gpuBuffer)}),n.forEach(q=>{q&&q[3]==="gpu-buffer"&&a.webgpuUnregisterBuffer(q[2].gpuBuffer)}),T.forEach(q=>a._OrtReleaseTensor(q)),S.forEach(q=>a._OrtReleaseTensor(q)),P.forEach(q=>a._free(q)),E!==0&&a._OrtReleaseRunOptions(E),A.forEach(q=>a._free(q))}},Nb=t=>{let e=Be(),r=ts.get(t);if(!r)throw new Error("invalid session id");let s=r[0],n=e._OrtEndProfiling(s);n===0&&ze("Can't get an profile file name."),e._OrtFree(n)},$b=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,Gt,Rn,_l,ml,Yu,fb,Ju,Ns,$s,lA,VA,HA,XA,KA,QA,YA,JA,ZA=be(()=>{"use strict";js(),WA(),Gs(),Eb(),rs=()=>!!Ke.wasm.proxy&&typeof document<"u",Rn=!1,_l=!1,ml=!1,Ju=new Map,Ns=(t,e)=>{let r=Ju.get(t);r?r.push(e):Ju.set(t,[e])},$s=()=>{if(Rn||!_l||ml||!Gt)throw new Error("worker not ready")},lA=t=>{switch(t.data.type){case"init-wasm":Rn=!1,t.data.err?(ml=!0,fb[1](t.data.err)):(_l=!0,fb[0]()),Yu&&(URL.revokeObjectURL(Yu),Yu=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:}},VA=async()=>{if(!_l){if(Rn)throw new Error("multiple calls to 'initWasm()' detected.");if(ml)throw new Error("previous call to 'initWasm()' failed.");if(Rn=!0,rs())return new Promise((t,e)=>{Gt?.terminate(),zA().then(([r,s])=>{try{Gt=s,Gt.onerror=o=>e(o),Gt.onmessage=lA,fb=[t,e];let n={type:"init-wasm",in:Ke};!n.in.wasm.wasmPaths&&(r||mb)&&(n.in.wasm.wasmPaths={wasm:new URL("ort-wasm-simd-threaded.asyncify.wasm",tr.url).href}),Gt.postMessage(n),Yu=r}catch(n){e(n)}},e)});try{await Ab(Ke.wasm),await Ib(Ke),_l=!0}catch(t){throw ml=!0,t}finally{Rn=!1}}},HA=async t=>{if(rs())return $s(),new Promise((e,r)=>{Ns("init-ep",[e,r]);let s={type:"init-ep",in:{epName:t,env:Ke}};Gt.postMessage(s)});await Cb(Ke,t)},XA=async t=>rs()?($s(),new Promise((e,r)=>{Ns("copy-from",[e,r]);let s={type:"copy-from",in:{buffer:t}};Gt.postMessage(s,[t.buffer])})):np(t),KA=async(t,e)=>{if(rs()){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),Gt.postMessage(n,o)})}else return Lb(t,e)},QA=async t=>{if(rs())return $s(),new Promise((e,r)=>{Ns("release",[e,r]);let s={type:"release",in:t};Gt.postMessage(s)});Pb(t)},YA=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 $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}};Gt.postMessage(c,$b(l))})}else return zb(t,e,r,s,n,o)},JA=async t=>{if(rs())return $s(),new Promise((e,r)=>{Ns("end-profiling",[e,r]);let s={type:"end-profiling",in:t};Gt.postMessage(s)});Nb(t)}}),_b,cA,e2,FP=be(()=>{"use strict";js(),ZA(),Fn(),kb(),DA(),_b=(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()}`)}},cA=t=>{switch(t[3]){case"cpu":return new rr(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!Sb(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(!Tb(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]}`)}},e2=class{async fetchModelAndCopyToWasmMemory(t){return XA(await Ob(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 KA(r,e),Us()}async dispose(){return QA(this.sessionId)}async run(t,e,r){Bs();let s=[],n=[];Object.entries(t).forEach(f=>{let _=f[0],m=f[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(f=>{let _=f[0],m=f[1],w=this.outputNames.indexOf(_);if(w===-1)throw new Error(`invalid output '${_}'`);o.push(m),a.push(w)});let i=s.map((f,_)=>_b(f,()=>`input "${this.inputNames[n[_]]}"`)),l=o.map((f,_)=>f?_b(f,()=>`output "${this.outputNames[a[_]]}"`):null),c=await YA(this.sessionId,n,i,a,l,r),p={};for(let f=0;f<c.length;f++)p[this.outputNames[a[f]]]=o[f]??cA(c[f]);return Us(),p}startProfiling(){}endProfiling(){JA(this.sessionId)}}}),t2={};wl(t2,{OnnxruntimeWebAssemblyBackend:()=>xb,initializeFlags:()=>wb,wasmBackend:()=>r2});var wb,xb,r2,BP=be(()=>{"use strict";js(),ZA(),FP(),wb=()=>{(typeof Ke.wasm.initTimeout!="number"||Ke.wasm.initTimeout<0)&&(Ke.wasm.initTimeout=0);let t=Ke.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.`),Ke.wasm.simd=!1),typeof Ke.wasm.proxy!="boolean"&&(Ke.wasm.proxy=!1),typeof Ke.wasm.trace!="boolean"&&(Ke.wasm.trace=!1),typeof Ke.wasm.numThreads!="number"||!Number.isInteger(Ke.wasm.numThreads)||Ke.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)Ke.wasm.numThreads=1;else{let e=typeof navigator>"u"?gP("node:os").cpus().length:navigator.hardwareConcurrency;Ke.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},xb=class{async init(t){wb(),await VA(),await HA(t)}async createInferenceSessionHandler(t,e){let r=new e2;return await r.loadModel(t,e),r}},r2=new xb});js();js();js();var UP="1.25.0-dev.20260307-d626b568e0",jP=TA;{let t=(BP(),ep(t2)).wasmBackend;Fs("webgpu",t,5),Fs("webnn",t,5),Fs("cpu",t,10),Fs("wasm",t,10)}Object.defineProperty(Ke.versions,"web",{value:UP,enumerable:!0});async function s2(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){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 n2(t){let e=await s2(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 o2(t){if(ie.IS_SERVICE_WORKER_ENV||ie.IS_CHROME_AVAILABLE)return t;let e=await s2(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 Fb=require("onnxruntime-common"),qP=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 c2(t){return t<=St.DEBUG?0:t<=St.INFO?2:t<=St.WARNING||t<=St.ERROR?3:4}var WP={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},qt=[],Db,Un,a2=Symbol.for("onnxruntime");if(a2 in globalThis)Un=globalThis[a2];else if(ie.IS_NODE_ENV){switch(Un=GP,process.platform){case"win32":qt.push("dml");break;case"linux":process.arch==="x64"&&qt.push("cuda");break;case"darwin":qt.push("coreml");break}qt.push("webgpu"),qt.push("cpu"),Db=["cpu"]}else Un=Rb,ie.IS_WEBNN_AVAILABLE&&qt.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),ie.IS_WEBGPU_AVAILABLE&&qt.push("webgpu"),qt.push("wasm"),Db=["wasm"];var VP=Un.InferenceSession;function u2(t=null){if(!t)return Db;switch(t){case"auto":return qt;case"gpu":return qt.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(qt.includes(t))return[qP[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${qt.join(", ")}.`)}var i2=Promise.resolve(),Bn=null;async function HP(){if(Bn)return Bn;if(!(fe.useWasmCache&&typeof lt?.wasm?.wasmPaths=="object"&<?.wasm?.wasmPaths?.wasm&<?.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 Bn=Promise.resolve(),Bn}return Bn=(async()=>{let e=lt.wasm.wasmPaths,r=!1;await Promise.all([e.wasm&&!U0(e.wasm)?(async()=>{try{let s=await n2(j0(e.wasm));s&&(lt.wasm.wasmBinary=s,r=!0)}catch(s){Z.warn("Failed to pre-load WASM binary:",s)}})():Promise.resolve(),e.mjs&&!U0(e.mjs)?(async()=>{try{let s=await o2(j0(e.mjs));s&&(lt.wasm.wasmPaths.mjs=s)}catch(s){Z.warn("Failed to pre-load WASM factory:",s)}})():Promise.resolve()]),r||(lt.wasm.wasmPaths.mjs=e.mjs)})(),Bn}async function op(t,e,r){await HP();let s=c2(fe.logLevel??St.WARNING),n=()=>VP.create(t,{logSeverityLevel:s,...e}),o=await(ie.IS_WEB_ENV?i2=i2.then(n):n());return o.config=r,o}var l2=Promise.resolve();async function ap(t,e){let r=()=>t.run(e);return ie.IS_WEB_ENV?l2=l2.then(r):r()}function ip(t){return t instanceof Un.Tensor}var lt=Un?.env;function xl(){return lt?.wasm?.proxy}if(lt){let t=function(e){let r=c2(e);lt.logLevel=WP[r]};if(lt.wasm){if(!(typeof ServiceWorkerGlobalScope<"u"&&self instanceof ServiceWorkerGlobalScope)&<.versions?.web&&!lt.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${lt.versions.web}/dist/`;lt.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`}}lt.wasm.proxy=!1}lt.webgpu&&(lt.webgpu.powerPreference="high-performance"),t(fe.logLevel??St.WARNING),fe.backends.onnx={...lt,setLogLevel:t}}var os=async(t,e,r)=>{let s=await op(new Uint8Array(t),e);return(async n=>{let o=xl(),a=Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(o?c.clone():c).ort_tensor])),i=await ap(s,a);return Array.isArray(r)?r.map(l=>new $(i[l])):new $(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 p2=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=ie.IS_NODE_ENV?"cpu":"wasm";function lp(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 _2=(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}})(),yt=Object.freeze({auto:"auto",fp32:"fp32",fp16:"fp16",q8:"q8",int8:"int8",uint8:"uint8",q4:"q4",bnb4:"bnb4",q4f16:"q4f16"}),d2=yt.fp32,f2=Object.freeze({[p2.wasm]:yt.q8}),yl=Object.freeze({[yt.fp32]:"",[yt.fp16]:"_fp16",[yt.int8]:"_int8",[yt.uint8]:"_uint8",[yt.q8]:"_quantized",[yt.q4]:"_q4",[yt.q4f16]:"_q4f16",[yt.bnb4]:"_bnb4"});function cp(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===yt.auto){if(s){let l=typeof s=="string"?s:s?.[e];if(l&&l!==yt.auto&&yt.hasOwnProperty(l))return l}i=f2[r]??d2}else o&&yt.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 Ar=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 $=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 ip(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new Fb.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 XP(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]=f;if(_=_===null?0:fr(_,this.dims[p],p,!1),m=m===null?this.dims[p]:fr(m,this.dims[p],p,!1),_>m)throw new Error(`Invalid slice: ${f}`);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: ${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(),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],f=s[0][1]*l[0];if(ArrayBuffer.isView(a))i.set(a.subarray(p,f));else if(Array.isArray(a)){let _=a.slice(p,f);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 f=0;for(let _=n.length-1,m=p;_>=0;--_){let w=n[_];f+=(m%w+s[_][0])*l[_],m=Math.floor(m/w)}i[p]=a[f]}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=(f,_)=>f+_,i=0n):(a=(f,_)=>f+_**e,i=0),r===null){let f=n.reduce(a,i);return e!==1&&(f=f**(1/e)),new t(this.type,[f],[])}let[l,c,p]=bl(a,this,r,s);if(e!==1)for(let f=0;f<c.length;++f)c[f]=c[f]**(1/e);return new t(l,c,p)}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,c=a,p=1;l>=0;--l){let f=this.dims[l];if(l!==r){let _=c%f;i+=_*p,p*=this.dims[l]}c=Math.floor(c/f)}n[a]/=o[i]}return this}normalize(e=2,r=1){return this.clone().normalize_(e,r)}stride(){return Ub(this.dims)}squeeze(e=null){return new t(this.type,this.data,m2(this.dims,e))}squeeze_(e=null){return this.dims=m2(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,h2(this.dims,e))}unsqueeze_(e){return this.dims=h2(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 kl(this,e,r)}min(e=null,r=!1){if(e===null){let a=ul(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=bl((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=Pe(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=bl((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=ul(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=Pe(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=Ub(s),c=Ub(n);for(let p=0;p<o;++p){let f=p,_=0;for(let m=0;m<n.length;++m){let w=Math.floor(f/c[m]);f=f%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(!Ar.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,$E(this.data),this.dims);return new t(e,Ar[e].from(this.data,r),this.dims)}};function XP(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]=IE(t.data,t.dims,e);return new $(t.type,r,s)}function pp(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=OE(t.data,[o,a,i],[e,r],s,n);return new $(t.type,l,[o,e,r])}async function bt(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 $("int64",new BigInt64Array(s.map(BigInt)),[s.length]);return await n({x:t,s:o})}async function jb(t,e){return await(await dr.matmul)({a:t,b:e})}async function KP(t,e){return await(await dr.rfft)({x:t,a:e})}async function Wt(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 $("int64",[BigInt(e)],[1])})}var up=t=>new $("int64",t,[t.length]);async function vl(t,e,r,s,n){return await(await dr.slice)({x:t,s:up(e),e:up(r),a:up(s),t:up(n??new Array(s.length).fill(1))})}function Gb(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 f=p*l*i;for(let _=0;_<l;++_){let m=0,w=0,x=p*i,k=f+_;for(let A=0;A<i;++A){let T=Number(s[x+A]);w+=T,m+=r[k+A*l]*T}let E=m/w;o[c++]=E}}return new $(t.type,o,n)}function QP(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]=dp(t,1,0,!0),i=o.data,l=a.data,c=t.data,p=new c.constructor(c.length);for(let f=0;f<s;++f){let _=f*n;for(let m=0;m<n;++m){let w=_+m;p[w]=(c[w]-l[f])/(i[f]+r)}}return new $(t.type,p,t.dims)}function m2(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 h2(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 ve(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:c}=t[i];for(let p=0;p<l.length;++p){let f=0;for(let _=c.length-1,m=p,w=1;_>=0;--_){let x=c[_],k=m%x;_===e&&(k+=a),f+=k*w,w*=r[_],m=Math.floor(m/x)}n[f]=l[p]}a+=c[e]}}return new $(o,n,r)}function Tt(t,e=0){return ve(t.map(r=>r.unsqueeze(e)),e)}function bl(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 c=0;c<o.length;++c){let p=0;for(let f=a.length-1,_=c,m=1;f>=0;--f){let w=a[f];if(f!==r){let x=_%w;p+=x*m,m*=i[f]}_=Math.floor(_/w)}l[p]=t(l[p],o[c],c,p)}return s||i.splice(r,1),[e.type,l,i]}function dp(t,e=null,r=1,s=!1){let n=t.data,o=t.dims;if(e===null){let m=n.reduce((E,A)=>E+A,0)/n.length,w=Math.sqrt(n.reduce((E,A)=>E+(A-m)**2,0)/(n.length-r)),x=new $(t.type,[m],[]);return[new $(t.type,[w],[]),x]}e=fr(e,o.length);let a=kl(t,e,s),i=a.data,[l,c,p]=bl((_,m,w,x)=>_+(m-i[x])**2,t,e,s);for(let _=0;_<c.length;++_)c[_]=Math.sqrt(c[_]/(o[e]-r));return[new $(l,c,p),a]}function kl(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 $(t.type,[l/n.length],[])}e=fr(e,s.length);let[o,a,i]=bl((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 $(o,a,i)}function Ub(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 qb(t,e,r,s){let n=t.reduce((o,a)=>o*a,1);return new $(r,new s(n).fill(e),t)}function We(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 qb(t,e,r,s)}function jn(t,e){return We(t.dims,e)}function et(t){return qb(t,1n,"int64",BigInt64Array)}function El(t){return et(t.dims)}function fp(t){return qb(t,0n,"int64",BigInt64Array)}function _p(t){return fp(t.dims)}function YP(t){let e=t.reduce((r,s)=>r*s,1);return new $("float32",Float32Array.from({length:e},()=>Xr.random()),t)}function Wb(t){let e=t.reduce((r,s)=>r*s,1);return new $("float32",Float32Array.from({length:e},()=>Xr.gauss()),t)}function Vb(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 $(s,a,[t.dims[0],t.dims[1]/8])}async function Gn(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 Hb(t,e){let r=await Gn(t);return await Promise.all(r.map(s=>ft(t,s,!0,e)))}function Xb(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 JP=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function ZP(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"?wt(t[n],i):wt(i,t[n])}}function ez(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 W=class extends st{return_token_type_ids=!1;padding_side="right";constructor(e,r){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=r,this._tokenizer=new oE(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 Hb(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(Pe(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&&ez(p[_],a):n&&ZP(p[_],a,m=>m==="input_ids"?this.pad_token_id:0,this.padding_side));let f={};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]))f[m]=new $("int64",BigInt64Array.from(p.flatMap(w=>w[m]).map(BigInt)),_)}else{for(let _ of Object.keys(p[0]))f[_]=p.map(m=>m[_]);if(!c)for(let _ of Object.keys(f))f[_]=f[_][0]}return f}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair: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 $&&(e=e.tolist()),e.map(s=>this.decode(s,r))}decode(e,r={}){if(e instanceof $&&(e=Xb(e)),!Array.isArray(e)||e.length===0||!Uk(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:f=!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 E of JP){let A=qs(this.config,E);A&&(x[E]=A)}let k=w.render({messages:e,add_generation_prompt:o,tools:r,documents:s,...x,...m});if(a){let E=this._call(k,{add_special_tokens:!1,padding:i,truncation:l,max_length:c,return_tensor:p,..._});return f?E:E.input_ids}return k}};function qn(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 Qb={};Os(Qb,{AlbertTokenizer:()=>mp,AutoTokenizer:()=>oe,BartTokenizer:()=>hp,BertTokenizer:()=>gp,BlenderbotSmallTokenizer:()=>wp,BlenderbotTokenizer:()=>xp,BloomTokenizer:()=>yp,CLIPTokenizer:()=>vp,CamembertTokenizer:()=>bp,CodeGenTokenizer:()=>Ep,CodeLlamaTokenizer:()=>kp,CohereTokenizer:()=>Ap,ConvBertTokenizer:()=>Mp,DebertaTokenizer:()=>Tp,DebertaV2Tokenizer:()=>Sp,DistilBertTokenizer:()=>Op,ElectraTokenizer:()=>Ip,EsmTokenizer:()=>Cp,FalconTokenizer:()=>Lp,GPT2Tokenizer:()=>Np,GPTNeoXTokenizer:()=>zp,GemmaTokenizer:()=>Pp,HerbertTokenizer:()=>$p,LlamaTokenizer:()=>Rp,M2M100Tokenizer:()=>Dp,MBart50Tokenizer:()=>Bp,MBartTokenizer:()=>Wn,MPNetTokenizer:()=>Gp,MarianTokenizer:()=>Fp,MgpstrTokenizer:()=>Up,MobileBertTokenizer:()=>jp,NllbTokenizer:()=>qp,NougatTokenizer:()=>Wp,PreTrainedTokenizer:()=>W,Qwen2Tokenizer:()=>Vp,RoFormerTokenizer:()=>Xp,RobertaTokenizer:()=>Hp,SiglipTokenizer:()=>Kp,SpeechT5Tokenizer:()=>Qp,SqueezeBertTokenizer:()=>Yp,T5Tokenizer:()=>Jp,TokenizersBackend:()=>W,VitsTokenizer:()=>Zp,Wav2Vec2CTCTokenizer:()=>ed,WhisperTokenizer:()=>td,XLMRobertaTokenizer:()=>rd,XLMTokenizer:()=>sd});var mp=class extends W{return_token_type_ids=!0};var hp=class extends W{};var gp=class extends W{return_token_type_ids=!0};var wp=class extends W{};var xp=class extends W{};var yp=class extends W{};var bp=class extends W{};var vp=class extends W{};var kp=class extends W{};var Ep=class extends W{};var Ap=class extends W{};var Mp=class extends W{return_token_type_ids=!0};var Sp=class extends W{return_token_type_ids=!0};var Tp=class extends W{return_token_type_ids=!0};var Op=class extends W{};var Ip=class extends W{return_token_type_ids=!0};var Cp=class extends W{};var Lp=class extends W{};var Pp=class extends W{};var zp=class extends W{};var Np=class extends W{};var $p=class extends W{return_token_type_ids=!0};var Rp=class extends W{padding_side="left"};var Dp=class extends W{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 qn(this,e,r,s)}};var Fp=class extends W{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)}`),wt([n],super._encode_text(o))}}};var Wn=class extends W{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 qn(this,e,r,s)}};var Bp=class extends Wn{};var Up=class extends W{};var jp=class extends W{return_token_type_ids=!0};var Gp=class extends W{};var qp=class extends W{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 qn(this,e,r,s)}};var Wp=class extends W{};var Vp=class extends W{};var Hp=class extends W{};var Xp=class extends W{return_token_type_ids=!0};var Kp=class extends W{};var Qp=class extends W{};var Yp=class extends W{return_token_type_ids=!0};var Jp=class extends W{};var Kb=class extends Ut{decode_chain(e){let r="";for(let s=1;s<e.length;s+=2)r+=e[s];return[r]}},Zp=class extends W{constructor(e,r){super(e,r),this._tokenizer.decoder=new Kb({type:"VitsDecoder"})}};var ed=class extends W{};var w2=[["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"]],Al=new Map(w2),rz=new Map([...w2.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 x2(t){t=t.toLowerCase();let e=rz.get(t);if(e===void 0){let r=t.match(/^<\|([a-z]{2})\|>$/);if(r&&(t=r[1]),Al.has(t))e=t;else{let n=t.length===2?Al.keys():Al.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var sz="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",y2=new RegExp(`^[${sz}]+$`,"gu"),td=class extends W{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(),f=0,_=this.timestamp_begin,w=_+1500,x=[],k=[],E=!1,A=null,T=new Set(this.all_special_ids);for(let O of e){let v=O.tokens,j=i?O.token_timestamps:null,H=null,B=_;if("stride"in O){let[Q,F,C]=O.stride;if(f-=F,A=Q-C,F&&(B=F/n+_),C)for(let te=v.length-1;te>=0;--te){let le=Number(v[te]);if(le>=_){if(H!==null&&(le-_)*n<A)break;H=le}}}let V=[],q=[];for(let Q=0;Q<v.length;++Q){let F=Number(v[Q]);if(T.has(F)){let C=this.decode([F]),te=Al.get(C.slice(2,-2));if(te!==void 0){if(a!==null&&te!==a&&!r){x.push(V);let le=this.findLongestCommonSequence(x)[0],L=this.decode(le);p.text=L,c.push(p),x=[],V=[],p=l()}a=p.language=te}}else if(F>=_&&F<=w){let C=(F-_)*n+f,te=zs(C,2);if(H!==null&&F>=H)E=!0;else if(E||x.length>0&&F<B)E=!1;else if(p.timestamp[0]===null)p.timestamp[0]=te;else if(te!==p.timestamp[0]){p.timestamp[1]=te,x.push(V),i&&k.push(q);let[le,L]=this.findLongestCommonSequence(x,k),z=this.decode(le);p.text=z,i&&(p.words=this.collateWordTimestamps(le,L,a)),c.push(p),x=[],V=[],k=[],q=[],p=l()}}else if(V.push(F),i){let C=zs(j[Q]+f,2),te;if(Q+1<j.length){te=zs(j[Q+1]+f,2);let le=this.decode([F]);y2.test(le)&&(te=zs(Math.min(C+n,te),2))}else te=null;q.push([C,te])}}if("stride"in O){let[Q,F,C]=O.stride;f+=Q-C}V.length>0?(x.push(V),i&&k.push(q)):x.every(Q=>Q.length===0)&&(p=l(),x=[],V=[],k=[],q=[])}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,k),j=this.decode(O);p.text=j,i&&(p.words=this.collateWordTimestamps(O,v,a)),c.push(p)}let S=Object.create(null),P=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 j of v.words)O.push(j);S={chunks:O}}else S={chunks:c}}return[P,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],f=0,_=[n,n,0,0],m=p.length;for(let S=1;S<n+m;++S){let P=Math.max(0,n-S),O=Math.min(n,n+m-S),v=s.slice(P,O),j=Math.max(0,S-n),H=Math.min(m,S),B=p.slice(j,H);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 V;a?V=v.filter((F,C)=>F===B[C]&&l[P+C]<=r[c][j+C]).length:V=v.filter((F,C)=>F===B[C]).length;let q=S/1e4,Q=V/S+q;V>1&&Q>f&&(f=Q,_=[P,O,j,H])}let[w,x,k,E]=_,A=Math.floor((x+w)/2),T=Math.floor((E+k)/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 $&&(e=Xb(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 f=e[p];i.push(f),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],f=n[l],_=p[0]>=this._tokenizer.token_to_id("<|endoftext|>"),m=c.startsWith(" "),w=c.trim(),x=y2.test(w);if(_||m||x||o.length===0)o.push(c),a.push(p),i.push(f);else{let k=o.length-1;o[k]+=c,a[k].push(...p),i[k].push(...f)}}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]=wt(i[c],i[p]),l[p]=wt(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]=wt(i[c],i[p]),l[c]=wt(l[c],l[p]),a[p]="",i[p]=[],l[p]=[]):c=p,++p;return[a.filter(f=>f),i.filter(f=>f.length>0),l.filter(f=>f.length>0)]}};var rd=class extends W{};var sd=class extends W{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 Hb(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",p=Qb[c];return p||(Z.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),p=W),new p(i,l)}};var as="https://github.com/huggingface/transformers.js/issues/new/choose";var Ml="preprocessor_config.json",Mr=Ml,b2="processor_config.json",v2="chat_template.jinja";var re=class extends st{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?ft(e,b2,!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?W0(e,v2,!0,r):null]);return new this(s,n,o)}};var Bf={};Os(Bf,{ChatterboxProcessor:()=>bd,Florence2Processor:()=>_f,Gemma3nProcessor:()=>mf,GraniteSpeechProcessor:()=>hf,GroundingDinoProcessor:()=>gf,Idefics3Processor:()=>Gl,JinaCLIPProcessor:()=>xf,Lfm2VlProcessor:()=>yf,LlavaProcessor:()=>bf,MgpstrProcessor:()=>vf,MoonshineProcessor:()=>kf,OwlViTProcessor:()=>Ef,PaliGemmaProcessor:()=>Af,Phi3VProcessor:()=>Mf,PixtralProcessor:()=>Sf,Processor:()=>re,PyAnnoteProcessor:()=>Tf,Qwen2VLProcessor:()=>eo,Qwen2_5_VLProcessor:()=>to,Qwen3VLProcessor:()=>Of,Sam2Processor:()=>ql,Sam2VideoProcessor:()=>If,SamProcessor:()=>ro,SmolVLMProcessor:()=>Gl,SpeechT5Processor:()=>Cf,UltravoxProcessor:()=>Lf,VLChatProcessor:()=>wf,VoxtralProcessor:()=>zf,VoxtralRealtimeProcessor:()=>$f,Wav2Vec2Processor:()=>Rf,Wav2Vec2ProcessorWithLM:()=>Df,WhisperProcessor:()=>Ff});var Ae=class extends st{constructor(e){super(),this.config=e}static async from_pretrained(e,r={}){let s=await ft(e,Ml,!0,r);return new this(s)}};function Fe(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 Sl={};Os(Sl,{ASTFeatureExtractor:()=>id,ChatterboxFeatureExtractor:()=>ld,ClapFeatureExtractor:()=>cd,DacFeatureExtractor:()=>Xn,EncodecFeatureExtractor:()=>Hn,FeatureExtractor:()=>Ae,Gemma3nAudioFeatureExtractor:()=>ud,GraniteSpeechFeatureExtractor:()=>pd,MoonshineFeatureExtractor:()=>dd,ParakeetFeatureExtractor:()=>fd,PyAnnoteFeatureExtractor:()=>Kn,SeamlessM4TFeatureExtractor:()=>_d,SnacFeatureExtractor:()=>md,SpeechT5FeatureExtractor:()=>hd,VoxtralRealtimeFeatureExtractor:()=>xd,Wav2Vec2FeatureExtractor:()=>gd,WeSpeakerFeatureExtractor:()=>wd,WhisperFeatureExtractor:()=>yd});var k2=vr(require("fs"),1),E2=require("stream"),A2=require("stream/promises");async function nd(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=E2.Readable.fromWeb(r),n=k2.default.createWriteStream(t);await(0,A2.pipeline)(s,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function ad(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 Qr(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 T2(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 M2(t){return T2(t,.5)}function nz(t){return T2(t,.54)}var oz={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 Yb(t,e="htk"){let r=oz[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 az={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 iz(t,e="htk"){let r=az[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 lz(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 S2(t,e,r){let s=(e-t)/(r-1);return Float64Array.from({length:r},(n,o)=>t+s*o)}function ct(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=Yb(r,a),c=Yb(s,a),p=S2(l,c,e+2),f=iz(p,a),_;if(i){let w=n/((t-1)*2);_=Yb(Float64Array.from({length:t},(x,k)=>k*w),a),f=p}else _=S2(0,Math.floor(n/2),t);let m=lz(_,f);if(o!==null&&o==="slaney")for(let w=0;w<e;++w){let x=m[w],k=2/(f[w+2]-f[w]);for(let E=0;E<t;++E)x[E]*=k}return m}function cz(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[Cn(o,n)];for(let o=1;o<=r;++o)s[n+e+o]=t[Cn(n-o,n)];return s}function O2(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=Pe(t)[0]-n;for(let i=0;i<t.length;++i)t[i]=Math.max(t[i],a)}return t}function uz(t,e=1,r=1e-5,s=null){return O2(t,20,e,r,s)}function pz(t,e=1,r=1e-10,s=null){return O2(t,10,e,r,s)}async function mt(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:f=null,mel_floor:_=1e-10,log_mel:m=null,max_log_mel:w=null,reference:x=1,min_value:k=1e-10,db_range:E=null,remove_dc_offset:A=null,min_num_frames:T=null,max_num_frames:S=null,do_pad:P=!0,transpose:O=!1,mel_offset:v=0}={}){let j=e.length;if(n===null&&(n=r),r>n)throw Error(`frame_length (${r}) may not be larger than fft_length (${n})`);if(j!==r)throw new Error(`Length of the window (${j}) 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 R=Math.floor((n-1)/2)+1;t=cz(t,R,R);break}case"constant":{let R=Math.floor(n/2),J=new t.constructor(t.length+2*R);J.set(t,R),t=J;break}default:throw new Error(`pad_mode="${i}" not implemented yet.`)}let H=Math.floor(1+Math.floor((t.length-r)/s));T!==null&&H<T&&(H=T);let B=l?Math.floor(n/2)+1:n,V=H,q=H;S!==null&&(S>H?P&&(q=S):q=V=S);let Q=new Wu(n),F=new Float64Array(n),C=new Float64Array(Q.outputBufferSize),te=new Float32Array(B*q);for(let R=0;R<V;++R){let J=R*s,Ce=Math.min(t.length-J,r);Ce!==r&&F.fill(0,0,r);for(let ae=0;ae<Ce;++ae)F[ae]=t[J+ae];if(A){let ae=0;for(let Je=0;Je<Ce;++Je)ae+=F[Je];let Ue=ae/Ce;for(let Je=0;Je<Ce;++Je)F[Je]-=Ue}if(c!==null){for(let ae=Ce-1;ae>=1;--ae)F[ae]-=c*F[ae-1];F[0]*=1-c}for(let ae=0;ae<e.length;++ae)F[ae]*=e[ae];Q.realTransform(C,F);for(let ae=0;ae<B;++ae){let Ue=ae<<1;te[ae*q+R]=C[Ue]**2+C[Ue+1]**2}}if(o!==null&&o!==2){let R=o/2;for(let J=0;J<te.length;++J)te[J]**=R}let le=f.length,L=await jb(new $("float32",f.flat(),[le,B]),new $("float32",te,[B,q]));O&&(L=L.transpose(1,0));let z=L.data;for(let R=0;R<z.length;++R)z[R]=v+Math.max(_,z[R]);if(o!==null&&m!==null){let R=Math.min(z.length,V*le);switch(m){case"log":for(let J=0;J<R;++J)z[J]=Math.log(z[J]);break;case"log10":for(let J=0;J<R;++J)z[J]=Math.log10(z[J]);break;case"log10_max_norm":{for(let ae=0;ae<R;++ae)z[ae]=Math.log10(z[ae]);let Ce=(w??Pe(z)[0])-8;for(let ae=0;ae<R;++ae)z[ae]=(Math.max(z[ae],Ce)+4)/4;break}case"dB":if(o===1)uz(z,x,k,E);else if(o===2)pz(z,x,k,E);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 L}function ht(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=M2(o);break;case"hamming":a=nz(o);break;case"povey":a=M2(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 dz(t,e){let r=t.reduce((o,a)=>o+a.length,0),s=new ArrayBuffer(44),n=new DataView(s);return od(n,0,"RIFF"),n.setUint32(4,36+r*4,!0),od(n,8,"WAVE"),od(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),od(n,36,"data"),n.setUint32(40,r*4,!0),new Blob([s,...t.map(o=>o.buffer)],{type:"audio/wav"})}function od(t,e,r){for(let s=0;s<r.length;++s)t.setUint8(e+s,r.charCodeAt(s))}var Vn=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]),dz(e,this.sampling_rate)}async save(e){return nd(e,this.toBlob())}};var id=class extends Ae{constructor(e){super(e);let r=this.config.sampling_rate,s=ct(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ht(400,"hann",{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,r){return mt(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){Fe(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 Hn=class extends Ae{async _call(e){Fe(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 $("float32",e,s)}}};var ld=class extends Ae{async _call(e){Fe(e,"ChatterboxFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new $("float32",e,r)}}};var cd=class extends Ae{constructor(e){super(e),this.mel_filters=ct(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=ct(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=ht(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 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 mt(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 Fe(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 Xn=class extends Hn{};var ud=class extends Ae{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=ct(Math.floor(1+r/2),s,n,o,a,null,"htk",!1);this.mel_filters=l,this.window=ht(i,"hann")}async _extract_fbank_features(e,r){return mt(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(Fe(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=We([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:i}}};var pd=class extends Ae{constructor(e){super(e);let{n_fft:r,win_length:s,n_mels:n,sample_rate:o}=e.melspec_kwargs;this.mel_filters=ct(Math.floor(1+r/2),n,0,o/2,o,null,"htk");let a=ht(s,"hann");this.window=new Float64Array(r);let i=Math.floor((r-s)/2);this.window.set(a,i)}async _call(e){Fe(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 mt(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 dd=class extends Ae{async _call(e){Fe(e,"MoonshineFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,e.length];return{input_values:new $("float32",e,r)}}};var fz=1e-5,fd=class extends Ae{constructor(e){super(e),this.config.mel_filters??=ct(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=ht(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 mt(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){Fe(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 _=f*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 f=0;f<a;++f){let _=i[f]/s,m=(l[f]-s*_*_)/c,x=1/(Math.sqrt(m)+fz);for(let k=0;k<s;++k){let E=k*a+f;n[E]=(n[E]-_)*x}}let p=new BigInt64Array(o);return p.fill(1n,0,s),{input_features:r.unsqueeze_(0),attention_mask:new $("int64",p,[1,o])}}};var Kn=class extends Ae{async _call(e){Fe(e,"PyAnnoteFeatureExtractor"),e instanceof Float64Array&&(e=new Float32Array(e));let r=[1,1,e.length];return{input_values:new $("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=Le(o[l]),[p,f]=Pe(c),[_,m]=[l,l+1];f!==i?(i=f,a.push({id:f,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:f})=>({id:l,start:c*s,end:p*s,confidence:f/(p-c)})))}return n}};var _d=class extends Ae{constructor(e){super(e);let r=this.config.sampling_rate,s=ct(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ht(400,"povey",{periodic:!1})}async _extract_fbank_features(e,r){return e=e.map(s=>s*32768),mt(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}={}){Fe(e,"SeamlessM4TFeatureExtractor");let a=await this._extract_fbank_features(e,this.config.max_length);if(n){let[w,x]=a.dims,k=a.data;for(let E=0;E<x;++E){let A=0;for(let O=0;O<w;++O)A+=k[O*x+E];let T=A/w,S=0;for(let O=0;O<w;++O)S+=(k[O*x+E]-T)**2;S/=w-1;let P=Math.sqrt(S+1e-7);for(let O=0;O<w;++O){let v=O*x+E;k[v]=(k[v]-T)/P}}}let i;if(r){let[w,x]=a.dims,k=a.data,E=w%s;if(E>0){let A=new Float32Array(x*(w+E));A.set(k),A.fill(this.config.padding_value,k.length);let T=w+E;a=new $(a.type,A,[T,x]),o&&(i=new $("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 k=i.data;for(let E=1,A=0;E<l;E+=p,++A)x[A]=k[E]}else x.fill(1n);m.attention_mask=new $("int64",x,[1,w])}return m}};var md=class extends Xn{};var hd=class extends Ae{};var gd=class extends Ae{_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){Fe(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 $("float32",r,s),attention_mask:new $("int64",new BigInt64Array(r.length).fill(1n),s)}}};var wd=class extends Ae{constructor(e){super(e);let r=this.config.sampling_rate,s=ct(257,this.config.num_mel_bins,20,Math.floor(r/2),r,null,"kaldi",!0);this.mel_filters=s,this.window=ht(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),mt(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){Fe(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 f=0;f<a;++f){let _=c+f*i;for(let m=0;m<i;++m)n[_+m]-=s[p+m]}}}return{input_features:r}}};var xd=class extends Ae{constructor(e){super(e),this.config.mel_filters??=ct(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=ht(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 mt(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 Fe(e,"VoxtralRealtimeFeatureExtractor"),{input_features:(await this._extract_fbank_features(e,{center:r})).unsqueeze_(0)}}};var yd=class extends Ae{constructor(e){super(e),this.config.mel_filters??=ct(Math.floor(1+this.config.n_fft/2),this.config.feature_size,0,8e3,this.config.sampling_rate,"slaney","slaney"),this.window=ht(this.config.n_fft,"hann")}async _extract_fbank_features(e){return await mt(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}={}){Fe(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 Ve=class{static async from_pretrained(e,r={}){let s=await ft(e,Ml,!0,r),n=s.feature_extractor_type,o=Sl[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${as}.`);return new o(s)}};var bd=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;async _call(e,r=null){let s=this.tokenizer(e),n=r?await this.feature_extractor(r):{};return{...s,...n}}};var vd=vr(require("sharp"),1);var Ws,I2,is;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)},is=self.createImageBitmap,I2=self.ImageData;else if(vd.default)is=async t=>{let r=(await t.metadata()).channels,{data:s,info:n}=await t.rotate().raw().toBuffer({resolveWithObject:!0}),o=new Qe(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 _z={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},mz=new Map([["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"]]),Qe=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 Qr(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 is(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,vd.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=_z[s]??s,o=z0(e),a=z0(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 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(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 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(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 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(ie.IS_WEB_ENV){let o=this.channels,a=this.toCanvas(),i=Ws(e,r).getContext("2d"),l=0,c=0,p=0,f=0;return s>=0?l=s:p=-s,n>=0?c=n:f=-n,i.drawImage(a,l,c,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],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 is(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 $("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 I2(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=mz.get(r)??"image/png",n=await this.toBlob(s);return nd(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,vd.default)(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},C2=Qe.read.bind(Qe);function L2(t,e,r=0,s=null){let n=t/e,o=zE(n)*e;return s!==null&&o>s&&(o=Math.floor(n)*e),o<r&&(o=Math.ceil(n)*e),o}function Jb([t,e],r){return[Math.max(Math.floor(t/r),1)*r,Math.max(Math.floor(e/r),1)*r]}function Zb([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 c=[];for(let p=0;p<a;++p){let f=r!==null?r[p]:null,_={boxes:[],classes:[],scores:[]},m=n[p],w=o[p];for(let x=0;x<i;++x){let k=m[x],E=[],A;if(s){A=k.sigmoid().data;for(let T=0;T<A.length;++T)A[T]>e&&E.push(T)}else{let T=Pe(k.data)[1];if(T===l-1||(A=Le(k.data),A[T]<e))continue;E.push(T)}for(let T of E){let S=w[x].data;S=Zb(S),f!==null&&(S=S.map((P,O)=>P*f[(O+1)%2])),_.boxes.push(S),_.classes.push(T),_.scores.push(A[T])}}c.push(_)}return c}function kd(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=pp(i,a,"bilinear",!1));let[l,c]=a??i.dims.slice(-2),p=new $("int32",new Int32Array(l*c),[l,c]),f=i[0].data,_=p.data;for(let x=1;x<i.dims[0];++x){let k=i[x].data;for(let E=0;E<k.length;++E)k[E]>f[E]&&(f[E]=k[E],_[E]=x)}let m=new Array(i.dims[0]);for(let x=0;x<_.length;++x){let k=_[x];m[k]=k}let w=m.filter(x=>x!==void 0);n.push({segmentation:p,labels:w})}return n}function hz(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=Pe(l.data)[1];if(p===s)continue;let _=Le(l.data)[p];_>r&&(n.push(c),o.push(_),a.push(p))}return[n,o,a]}function gz(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 $("int32",new Int32Array(i*l),[i,l]),p=[];if(a!==null)for(let x=0;x<t.length;++x)t[x]=pp(t[x],a,"bilinear",!1);let f=new Int32Array(t[0].data.length),_=new Float32Array(t[0].data.length);for(let x=0;x<t.length;++x){let k=e[x],E=t[x].data;for(let A=0;A<E.length;++A)E[A]*=k,E[A]>_[A]&&(f[A]=x,_[A]=E[A])}let m=0,w=c.data;for(let x=0;x<r.length;++x){let k=r[x],[E,A]=gz(f,t,x,s,n);if(E){++m;for(let T of A)w[T]=m;p.push({id:m,label_id:k,score:e[x]})}}return[c,p]}function Ed(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]}function Ad(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,f]=a.dims;if(f-=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],k=l[m],[E,A,T]=hz(x,k,e,f);if(T.length===0){let[O,v]=w??k.dims.slice(-2),j=new $("int32",new Int32Array(O*v).fill(-1),[O,v]);_.push({segmentation:j,segments_info:[]});continue}let[S,P]=wz(E,A,T,r,s,n,w);_.push({segmentation:S,segments_info:P})}return _}function Md(t,e=.5,r=null){throw new Error("`post_process_instance_segmentation` is not yet implemented.")}var X=class extends st{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),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=ul(s.data)[0],a=Pe(s.data)[0]-n;if(a===0)return e;let i=r/255,l=s.width,c=s.height,p=0,f=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),f=Math.max(f,m))}return e=await e.crop([l,c,p,f]),e}pad_image(e,r,s,{mode:n="constant",center:o=!1,constant_values:a=0}={}){let[i,l,c]=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 _=new Float32Array(p*f*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((f-i)/2)]:[0,0];for(let x=0;x<i;++x){let k=(x+w)*p,E=x*l;for(let A=0;A<l;++A){let T=(k+A+m)*c,S=(E+A)*c;for(let P=0;P<c;++P)_[T+P]=e[S+P]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let x=i-1,k=l-1;for(let E=0;E<f;++E){let A=E*p,T=Cn(E,x)*l;for(let S=0;S<p;++S){if(E<i&&S<l)continue;let P=(A+S)*c,O=(T+Cn(S,k))*c;for(let v=0;v<c;++v)_[P+v]=e[O+v]}}}e=_,r=[f,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),f=Math.floor(Number((l*p).toFixed(2))),_=Math.floor(Number((c*p).toFixed(2)));return this.size_divisibility!==void 0&&([f,_]=Jb([f,_],this.size_divisibility)),[f,_]}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=L2(c*n,this.config.ensure_multiple_of),i=L2(p*s,this.config.ensure_multiple_of)}return[i,l]}else{if(this.size_divisibility!==void 0)return Jb([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),f=[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 k=0;k<e.channels;++k)p[x+k]=(p[x+k]-m[k])/w[k]}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[m,w]=Jb([f[1],f[0]],this.size_divisibility);[p,f]=this.pad_image(p,f,{width:m,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 m=0;m<p.length;m+=3){let w=p[m];p[m]=p[m+2],p[m+2]=w}}let _=new $("float32",p,f).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:Tt(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 ft(e,Mr,!0,r);return new this(s)}};var Jn={};Os(Jn,{BeitFeatureExtractor:()=>Sd,BitImageProcessor:()=>Td,CLIPFeatureExtractor:()=>Id,CLIPImageProcessor:()=>Tl,ChineseCLIPFeatureExtractor:()=>Od,ConvNextFeatureExtractor:()=>Cd,ConvNextImageProcessor:()=>Ol,DINOv3ViTImageProcessor:()=>zd,DPTFeatureExtractor:()=>$d,DPTImageProcessor:()=>Ll,DeiTFeatureExtractor:()=>Ld,DeiTImageProcessor:()=>Il,DetrFeatureExtractor:()=>Pd,DetrImageProcessor:()=>Cl,DonutFeatureExtractor:()=>Nd,DonutImageProcessor:()=>Vs,EfficientNetImageProcessor:()=>Rd,GLPNFeatureExtractor:()=>Dd,GroundingDinoImageProcessor:()=>Fd,Idefics3ImageProcessor:()=>Pl,ImageFeatureExtractor:()=>X,ImageProcessor:()=>X,JinaCLIPImageProcessor:()=>Ud,Lfm2VlImageProcessor:()=>jd,LlavaOnevisionImageProcessor:()=>Gd,Mask2FormerImageProcessor:()=>Wd,MaskFormerFeatureExtractor:()=>qd,MaskFormerImageProcessor:()=>Hs,MobileNetV1FeatureExtractor:()=>Vd,MobileNetV1ImageProcessor:()=>zl,MobileNetV2FeatureExtractor:()=>Hd,MobileNetV2ImageProcessor:()=>Nl,MobileNetV3FeatureExtractor:()=>Xd,MobileNetV3ImageProcessor:()=>$l,MobileNetV4FeatureExtractor:()=>Kd,MobileNetV4ImageProcessor:()=>Rl,MobileViTFeatureExtractor:()=>Qd,MobileViTImageProcessor:()=>Dl,NougatImageProcessor:()=>Yd,OwlViTFeatureExtractor:()=>Jd,OwlViTImageProcessor:()=>Xs,Owlv2ImageProcessor:()=>Zd,Phi3VImageProcessor:()=>ef,PixtralImageProcessor:()=>tf,PvtImageProcessor:()=>rf,Qwen2VLImageProcessor:()=>sf,RTDetrImageProcessor:()=>nf,Sam2ImageProcessor:()=>Yn,Sam3ImageProcessor:()=>Yn,SamImageProcessor:()=>Yn,SapiensFeatureExtractor:()=>of,SapiensImageProcessor:()=>Fl,SegformerFeatureExtractor:()=>af,SegformerImageProcessor:()=>Bl,SiglipImageProcessor:()=>lf,SmolVLMImageProcessor:()=>Pl,Swin2SRImageProcessor:()=>cf,VLMImageProcessor:()=>Bd,ViTFeatureExtractor:()=>uf,ViTImageProcessor:()=>Ul,VitMatteImageProcessor:()=>pf,VitPoseImageProcessor:()=>df,YolosFeatureExtractor:()=>ff,YolosImageProcessor:()=>jl});var Sd=class extends X{};var Td=class extends X{};var Od=class extends X{};var Tl=class extends X{},Id=class extends Tl{};var Ol=class extends X{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}},Cd=class extends Ol{};var Il=class extends X{},Ld=class extends Il{};var Cl=class extends X{async _call(e){let r=await super._call(e),s=[r.pixel_values.dims[0],64,64],n=We(s,1n);return{...r,pixel_mask:n}}post_process_object_detection(...e){return ls(...e)}post_process_panoptic_segmentation(...e){return Ad(...e)}post_process_instance_segmentation(...e){return Md(...e)}},Pd=class extends Cl{};var zd=class extends X{};var Vs=class extends X{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((f,_)=>-f/c[_]);return super.pad_image(e,r,s,{center:!0,constant_values:p,...n})}},Nd=class extends Vs{};var Ll=class extends X{},$d=class extends Ll{};var Rd=class extends X{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 Dd=class extends X{};var Fd=class extends X{async _call(e){let r=await super._call(e),s=r.pixel_values.dims,n=et([s[0],s[2],s[3]]);return{...r,pixel_mask:n}}};var Pl=class extends X{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 E of n){let A=await Promise.all(E.map(P=>this.preprocess(P)));l.push(...A.map(P=>P.original_size)),c.push(...A.map(P=>P.reshaped_input_size)),A.forEach(P=>P.pixel_values.unsqueeze_(0));let{longest_edge:T}=this.max_image_size,S;if(r??this.do_image_splitting){let P=new Array(A.length),O=new Array(A.length);S=await Promise.all(A.map(async(v,j)=>{let H=this.get_resize_for_vision_encoder(v.pixel_values,T),B=await bt(v.pixel_values,{size:[H.height,H.width]}),{frames:V,num_splits_h:q,num_splits_w:Q}=await this.split_image(B,this.max_image_size);return P[j]=q,O[j]=Q,ve(V,0)})),a.push(P),i.push(O)}else{let P=[T,T];S=await Promise.all(A.map(O=>bt(O.pixel_values,{size:P}))),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,[f,_,m,w]=o[0].dims,x,k;if(p===1)x=o[0].unsqueeze_(0),k=We([p,f,m,w],!0);else{let E=Math.max(...o.map(S=>S.dims.at(0)));k=We([p,E,m,w],!0);let A=k.data,T=E*m*w;for(let S=0;S<p;++S){let P=o[S].dims[0];if(P<E){o[S]=ve([o[S],We([E-P,_,m,w],0)],0);let O=S*T+P*m*w,v=(S+1)*T;A.fill(!1,O,v)}}x=Tt(o,0)}return{pixel_values:x,pixel_attention_mask:k,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),f=Math.ceil(i/c);for(let w=0;w<l;++w)for(let x=0;x<c;++x){let k,E,A,T;w===l-1?(E=a-p,T=a):(E=w*p,T=(w+1)*p),x===c-1?(k=i-f,A=i):(k=x*f,A=(x+1)*f);let O=await vl(e,[E,k],[T,A],[2,3]);o.push(O)}let _=s,m=n;(a!==_||i!==m)&&(e=await bt(e,{size:[_,m]}))}return o.push(e),{frames:o,num_splits_h:l,num_splits_w:c}}};var Bd=class extends X{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 Ud=class extends X{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 P2(t,e){return Math.round(t/e)*e}function xz(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 yz(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 bz(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),f=n*o;for(let _=0;_<r;++_){let m=_*s*f,w=_*a*i*l;for(let x=0;x<a;++x)for(let k=0;k<i;++k){let E=w+(x*i+k)*l;for(let A=0;A<e;++A){let T=(x*e+A)*o+k*e;for(let S=0;S<e;++S){let P=T+S;for(let O=0;O<s;++O)p[E++]=c[m+O*f+P]}}}}return new $("float32",p,[r,a*i,l])}function vz(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 $("float32",a,[1,e,s])}return{padded:o,mask:new $("int64",n,[e])}}var jd=class extends X{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,P2(e,s)),o=Math.max(this.encoder_patch_size,P2(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=yz(this.min_tiles,this.max_tiles),[n,o]=xz(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 f of s){let _=await Promise.all(f.map(m=>this.preprocess(m,{do_pad:!1})));for(let{pixel_values:m}of _){let[,w,x]=m.dims,k=m.unsqueeze_(0),E=this.encoder_patch_size*this.downsample_factor,A=E**2,[T,S]=Ed(Math.max(E,w),Math.max(E,x),E,this.min_image_tokens*A,this.max_image_tokens*A).map(B=>Math.max(E,B)),P,O=1,v=1,j=this._is_image_too_large(w,x),H=this.do_image_splitting&&!(this.min_tiles===1&&this.max_tiles===1);if(j&&H){let{grid_width:B,grid_height:V,target_width:q,target_height:Q}=this._get_grid_layout(w,x);O=V,v=B;let F=await bt(k,{size:[Q,q]});P=[];for(let C=0;C<V;++C)for(let te=0;te<B;++te){let le=C*this.tile_size,L=te*this.tile_size;P.push(F.slice(null,null,[le,le+this.tile_size],[L,L+this.tile_size]))}this.use_thumbnail&&B*V!==1&&P.push(await bt(k,{size:[T,S]}))}else P=[await bt(k,{size:[T,S]})];for(let B of P){let[,,V,q]=B.dims,Q=bz(B,this.encoder_patch_size),{padded:F,mask:C}=vz(Q,this.max_num_patches);n.push(F),o.push(C),a.push([Math.floor(V/this.encoder_patch_size),Math.floor(q/this.encoder_patch_size)])}i.push(O),l.push(v),c.push([T,S])}}let p={pixel_values:ve(n,0),pixel_attention_mask:Tt(o,0),spatial_shapes:new $("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 Gd=class extends X{};var Hs=class extends X{post_process_panoptic_segmentation(...e){return Ad(...e)}post_process_instance_segmentation(...e){return Md(...e)}},qd=class extends Hs{};var Wd=class extends Hs{};var zl=class extends X{},Vd=class extends zl{};var Nl=class extends X{},Hd=class extends Nl{};var $l=class extends X{},Xd=class extends $l{};var Rl=class extends X{},Kd=class extends Rl{};var Dl=class extends X{},Qd=class extends Dl{};var Yd=class extends Vs{};var Xs=class extends X{post_process_object_detection(...e){return ls(...e)}},Jd=class extends Xs{};var Zd=class extends Xs{};var $t=336,kz=[2,3],{ceil:e1,floor:Qn,sqrt:t1}=Math,ef=class extends X{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 Qn((Qn(r/$t)*Qn(e/$t)+1)*s+1+(Qn(r/$t)+1)*t1(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=$t*e1(o/$t),l=$t*e1(a/$t),c=[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:c,...n})}async _call(e,{num_crops:r=null}={}){if(this._num_crops=r??=this.config.num_crops,r<4||t1(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 bt(_,{size:[$t,$t],mode:"bicubic"});if(r>0){let k=[],E=t1(r),A=Qn(w/E),T=Qn(m/E);for(let P=0;P<E;++P)for(let O=0;O<E;++O){let v,j,H,B;P===E-1?(j=m-T,B=m):(j=P*T,B=(P+1)*T),O===E-1?(v=w-A,H=w):(v=O*A,H=(O+1)*A);let Q=await vl(_,[j,v],[B,H],kz);k.push(Q)}let S=await bt(ve(k,0),{size:[$t,$t],mode:"bicubic"});i.push(ve([x,S],0))}else i.push(x)}let l=Tt(i,0),c=a.map(_=>_.map(m=>$t*e1(m/$t))),p=new $("int64",c.flat(),[s,2]),f=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:f}}};var tf=class extends X{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 f=c*p,_=Math.floor((i-1)/f)+1,m=Math.floor((l-1)/f)+1;return[_*f,m*f]}};var rf=class extends X{};var sf=class extends X{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 Ed(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,f=a.dims[1],_=Math.floor(a.dims[2]/c),m=Math.floor(a.dims[3]/c),w=a.view(p,i,f,Math.floor(_/l),l,c,Math.floor(m/l),l,c).permute(0,3,6,4,7,2,1,5,8).view(p*_*m,f*i*c*c),x=new $("int64",[p,_,m],[1,3]);return{pixel_values:w,image_grid_thw:x,original_sizes:n,reshaped_input_sizes:o}}};var nf=class extends X{post_process_object_detection(...e){return ls(...e)}};var Yn=class extends X{reshape_input_points(e,r,s,n=!1){e=structuredClone(e);let o=N0(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],f=[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]*=f[w%2]}return new $("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,r){let s=N0(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 $("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],f=s[c],_=await bt(e[c],{mode:"bilinear",size:l});if(_=_.slice(null,null,[0,f[0]],[0,f[1]]),_=await bt(_,{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 $("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 Fl=class extends X{post_process_semantic_segmentation(...e){return kd(...e)}},of=class extends Fl{};var Bl=class extends X{post_process_semantic_segmentation(...e){return kd(...e)}},af=class extends Bl{};var lf=class extends X{};var cf=class extends X{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 Ul=class extends X{},uf=class extends Ul{};var pf=class extends X{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:Tt(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 df=class extends X{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 f=n[p],_=r[p],m=[];for(let w=0;w<_.length;++w){let x=_[w],k=[],E=[],A=[],T=x.at(-2)/l,S=x.at(-1)/i;for(let P=0;P<f.length;++P){let[O,v]=[0,0],j=0,H=-1/0,B=f[P];for(let q=0;q<B.length;++q){let Q=B[q];for(let F=0;F<Q.length;++F){let C=Q[F];j+=C,H=Math.max(H,C),O+=(F+.5)*C,v+=q*C}}if(s!=null&&H<s)continue;let V=[T*O/j,S*v/j];k.push(V),A.push(P),E.push(H)}m.push({bbox:x,scores:E,labels:A,keypoints:k})}c.push(m)}return c}};var jl=class extends X{post_process_object_detection(...e){return ls(...e)}},ff=class extends jl{};var Oe=class{static async from_pretrained(e,r={}){let s=await ft(e,Mr,!0,r),n=s.image_processor_type??s.feature_extractor_type,o=Jn[n?.replace(/Fast$/,"")];return o||(n!==void 0&&Z.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${as}.`),o=X),new o(s)}};var _f=class extends re{static tokenizer_class=oe;static image_processor_class=Oe;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,f,..._]of i)l.push(f?f.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 mf=class extends re{static image_processor_class=Oe;static feature_extractor_class=Ve;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:f}=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=`
|
|
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 cl(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 cl(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 cl(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(GE(t.value,s.value,n.value,o.value)):new ee(GE(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 lr?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 Ts(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 Ts(r),f=n.value[c],_;if(t.loopvar.type==="Identifier")_=m=>m.setVariable(t.loopvar.value,f);else if(t.loopvar.type==="TupleLiteral"){let m=t.loopvar;if(f.type!=="ArrayValue")throw new Error(`Cannot unpack non-iterable type: ${f.type}`);let w=f;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 k=0;k<m.value.length;++k){if(m.value[k].type!=="Identifier")throw new Error(`Cannot unpack non-identifier type: ${m.value[k].type}`);x.setVariable(m.value[k].value,w.value[k])}}}else throw new Error(`Invalid loop variable(s): ${t.loopvar.type}`);s&&(_(p),!this.evaluate(s,p).__bool__().value)||(o.push(f),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 f=this.evaluateBlock(t.body,r);i+=f.value}catch(f){if(f instanceof WE)continue;if(f instanceof qE)break;throw f}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 Ts(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 Ts(l);if(t.callerArgs)for(let p=0;p<t.callerArgs.length;++p){let f=t.callerArgs[p];if(f.type!=="Identifier")throw new Error(`Caller parameter must be an identifier, got ${f.type}`);c.setVariable(f.value,i[p]??new je)}return this.evaluateBlock(t.body,c)}),[s,n]=this.evaluateArguments(t.call.args,e);s.push(new cl(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 Ts(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 qE;case"Continue":throw new WE;case"IntegerLiteral":return new me(t.value);case"FloatLiteral":return new Qe(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 HE(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 Wu(t){switch(typeof t){case"number":return Number.isInteger(t)?new me(t):new Qe(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(Wu)):new ct(new Map(Object.entries(t).map(([e,r])=>[e,Wu(r)])));case"function":return new Ge((e,r)=>{let s=t(...e.map(n=>n.value))??null;return Wu(s)});default:throw new Error(`Cannot convert to runtime value: ${t}`)}}var rt=`
|
|
10
|
+
`,Tz="{%- ",Oz=" -%}";function Iz(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 Cz(t,e=" "){let r=typeof e=="number"?" ".repeat(e):e;return Yt(t.body,0,r).replace(/\n$/,"")}function gt(...t){return Tz+t.join(" ")+Oz}function Yt(t,e,r){return t.map(s=>Pz(s,e,r)).join(rt)}function Pz(t,e,r){let s=r.repeat(e);switch(t.type){case"Program":return Yt(t.body,e,r);case"If":return zz(t,e,r);case"For":return Lz(t,e,r);case"Set":return Nz(t,e,r);case"Macro":return $z(t,e,r);case"Break":return s+gt("break");case"Continue":return s+gt("continue");case"CallStatement":return Rz(t,e,r);case"FilterStatement":return Dz(t,e,r);case"Comment":return s+"{# "+t.value+" #}";default:return s+"{{- "+ke(t)+" -}}"}}function zz(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+Yt(n[0].body,e+1,r);for(let i=1;i<n.length;++i)a+=rt+s+gt("elif",ke(n[i].test))+rt+Yt(n[i].body,e+1,r);return o&&o.alternate.length>0&&(a+=rt+s+gt("else")+rt+Yt(o.alternate,e+1,r)),a+=rt+s+gt("endif"),a}function Lz(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+Yt(t.body,e+1,r);return t.defaultBlock.length>0&&(o+=rt+s+gt("else")+rt+Yt(t.defaultBlock,e+1,r)),o+=rt+s+gt("endfor"),o}function Nz(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+Yt(t.body,e+1,r)+rt+s+gt("endset")}function $z(t,e,r){let s=r.repeat(e),n=t.args.map(ke).join(", ");return s+gt("macro",`${t.name.value}(${n})`)+rt+Yt(t.body,e+1,r)+rt+s+gt("endmacro")}function Rz(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+=Yt(t.body,e+1,r)+rt,a+=s+gt("endcall"),a}function Dz(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+=Yt(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=Iz(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 KE=class{parsed;constructor(t){let e=XP(t,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=wz(e)}render(t){let e=new Ts;if(Mz(e),t)for(let[n,o]of Object.entries(t))e.set(n,o);return new Sz(e).run(this.parsed).value}format(t){return Cz(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 Is=yr(require("fs"),1),Uz={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=Is.default.existsSync(e),this.exists){this.status=200,this.statusText="OK";let r=Is.default.statSync(e);this.headers.set("content-length",r.size.toString()),this.updateContentType();let s=Is.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",Uz[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 Is.default.promises.readFile(this.filePath)).buffer}async blob(){let e=await Is.default.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get("content-type")})}async text(){return await Is.default.promises.readFile(this.filePath,"utf8")}async json(){return JSON.parse(await this.text())}};var Ln=yr(require("fs"),1),ul=yr(require("path"),1);var zn=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[YE(this._random_fn,r)]}};function YE(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 cr=new zn,Vr=Object.freeze({Random:zn,seed:cr.seed.bind(cr),random:cr.random.bind(cr),gauss:cr.gauss.bind(cr),shuffle:cr.shuffle.bind(cr),choices:cr.choices.bind(cr)}),QE=t=>YE(Vr.random,t);var Bz=new zn,Nn=class{constructor(e){this.path=e}async match(e){let r=ul.default.join(this.path,e),s=new Wr(r);if(s.exists)return s}async put(e,r,s=void 0){let n=ul.default.join(this.path,e),o=ie.IS_PROCESS_AVAILABLE?process.pid:Date.now(),a=Bz._int32().toString(36),i=n+`.tmp.${o}.${a}`;try{let l=r.headers.get("Content-Length"),c=parseInt(l??"0"),p=0;await Ln.default.promises.mkdir(ul.default.dirname(n),{recursive:!0});let f=Ln.default.createWriteStream(i),_=r.body.getReader();for(;;){let{done:m,value:w}=await _.read();if(m)break;await new Promise((k,E)=>{f.write(w,A=>{if(A){E(A);return}k()})}),p+=w.length;let x=c?p/c*100:0;s?.({progress:x,loaded:p,total:c})}await new Promise((m,w)=>{f.close(x=>x?w(x):m())}),await Ln.default.promises.rename(i,n)}catch(l){try{await Ln.default.promises.unlink(i)}catch{}throw l}}async delete(e){let r=ul.default.join(this.path,e);try{return await Ln.default.promises.unlink(r),!0}catch{return!1}}};var JE={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"},Vu=100,ZE=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;var wb={};function pl(...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 eA(t){return!(!ZE.test(t)||t.includes("..")||t.includes("--")||t.endsWith(".git")||t.endsWith(".ipynb"))}function tA(t,e,r){if(!r)return null;let s=JE[t]??`Error (${t}) occurred while trying to load file`;throw Error(`${s}: "${e}".`)}async function rA(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 f=a+p.length;if(f>n){n=f;let m=new Uint8Array(n);m.set(o),o=m}o.set(p,a),a=f;let _=a/n*100;return e({progress:_,loaded:a,total:n}),l()}return await l(),o}function xb(t){return Hr(t,["blob:"])}function yb(t){let e;if(typeof location<"u"&&location.href)e=location.href;else if(typeof wb<"u"&&wb.url)e=wb.url;else return t;return new URL(t,e).href}var nA="SHA-256",Fz="experimental_transformers-hash-cache",sA=t=>({algorithm:nA,value:t}),dl=class{#t=null;_getHashCache=()=>(this.#t??=caches.open(Fz),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([sA(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([sA(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(nA,r);return Array.from(new Uint8Array(s)).map(o=>o.toString(16).padStart(2,"0")).join("")}};async function Jt(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&&dl.isAvailable()&&(e=new dl),!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 Nn(t??fe.cacheDir)}return e}async function oA(t,...e){for(let r of e)try{let s=await t.match(r);if(s)return s}catch{continue}}var Hu=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 jz=100,bb=new Hu(jz);function Xu(t,e){let r=bb.get(t);if(r!==void 0)return r;let s=e().then(n=>n,n=>(bb.delete(t),Promise.reject(n)));return bb.put(t,s),s}async function Gz(t){if(!Hr(t,["http:","https:"]))return null;let e=vb(t);return e.set("Range","bytes=0-0"),fe.fetch(t,{method:"GET",headers:e,cache:"no-store"})}function Bt(t,e,r={}){let s=JSON.stringify([t,e,r?.revision,r?.cache_dir,r?.local_files_only]);return Xu(s,()=>qz(t,e,r))}async function qz(t,e,r){let s=await Jt(r?.cache_dir),{localPath:n,remoteURL:o,proposedCacheKey:a,validModelId:i}=Kr(t,e,r,s),l=await Yr(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 f=p.headers.get("content-length"),_=p.headers.get("content-type");return{exists:!0,size:f?parseInt(f,10):void 0,contentType:_||void 0,fromCache:!1}}}catch{}if(fe.allowRemoteModels&&!r.local_files_only&&i)try{let c=await Gz(o);if(c&&c.status>=200&&c.status<300){let p,f=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:f||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:vb(t)})}function vb(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=pl(t,e),a=eA(t),i=a?pl(fe.localModelPath,o):o,l=pl(fe.remoteHost,fe.remotePathTemplate.replaceAll("{model}",t).replaceAll("{revision}",encodeURIComponent(n)),e),c=s instanceof Nn?n==="main"?o:pl(t,n,e):l;return{requestURL:o,localPath:i,remoteURL:l,proposedCacheKey:c,validModelId:a}}async function Yr(t,e,r){if(t)return await oA(t,e,r)}async function Wz(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 Vz(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),f,_=!1,m;m=await Yr(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),f=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 tA(m.status,l,r);f=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 E;if(typeof m!="string")if(!s.progress_callback)E=new Uint8Array(await m.arrayBuffer());else if(w&&typeof navigator<"u"&&/firefox/i.test(navigator.userAgent))E=new Uint8Array(await m.arrayBuffer()),br(s.progress_callback,{status:"progress",name:t,file:e,progress:100,loaded:E.length,total:E.length});else{let A,T=m.headers.get("content-length");if(T)A=parseInt(T,10);else try{let S=await Bt(t,e,s);S.size&&(A=S.size)}catch{}E=await rA(m,S=>{br(s.progress_callback,{status:"progress",name:t,file:e,...S})},A)}x=E}if(_&&f&&typeof m!="string"&&await Wz(t,e,o,f,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 k=await o?.match(f);if(k instanceof Wr)return k.filePath;if(k instanceof Response)return new Uint8Array(await k.arrayBuffer());if(typeof k=="string")return k;throw new Error("Unable to get model file path or buffer.")}async function fl(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 Jt(s?.cache_dir);return await Vz(t,e,r,s,n,o)}async function kb(t,e,r=!0,s={}){let n=await fl(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 kb(t,e,r,s);return n===null?{}:JSON.parse(n)}function iA(t,[e,r,s],[n,o],a="bilinear",i=!1){let l=o/s,c=n/r,p=new t.constructor(n*o*e),f=r*s,_=n*o;for(let m=0;m<n;++m)for(let w=0;w<o;++w){let x=m*o+w,k=(w+.5)/l-.5,E=(m+.5)/c-.5,A=Math.floor(k),T=Math.floor(E),S=Math.min(A+1,s-1),P=Math.min(T+1,r-1);A=Math.max(A,0),T=Math.max(T,0);let O=k-A,v=E-T,W=(1-O)*(1-v),X=O*(1-v),B=(1-O)*v,H=O*v,G=T*s,K=P*s,R=G+A,C=G+S,re=K+A,ae=K+S;for(let z=0;z<e;++z){let $=z*f;p[z*_+x]=W*t[$+R]+X*t[$+C]+B*t[$+re]+H*t[$+ae]}}return p}function lA(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 Ce(t){let e=Pe(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 Qu(t){let e=Pe(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 Ab(t,e){let r=0;for(let s=0;s<t.length;++s)r+=t[s]*e[s];return r}function cA(t,e){let r=Ab(t,e),s=aA(t),n=aA(e);return r/(s*n)}function aA(t){return Math.sqrt(t.reduce((e,r)=>e+r*r,0))}function _l(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 Pe(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 uA(t){return t>0&&(t&t-1)===0}var Ku=class{constructor(e){if(this.size=e|0,this.size<=1||!uA(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 f=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 k=w,E=k+_,A=E+_,T=A+_,S=e[k],P=e[k+1],O=e[E],v=e[E+1],W=e[A],X=e[A+1],B=e[T],H=e[T+1],G=f[x],K=s*f[x+1],R=O*G-v*K,C=O*K+v*G,re=f[2*x],ae=s*f[2*x+1],z=W*re-X*ae,$=W*ae+X*re,U=f[3*x],J=s*f[3*x+1],xe=B*U-H*J,ue=B*J+H*U,Ve=S+z,ot=P+$,_t=S-z,at=P-$,kt=R+xe,Ue=C+ue,Se=s*(R-xe),et=s*(C-ue);e[k]=Ve+kt,e[k+1]=ot+Ue,e[E]=_t+et,e[E+1]=at-Se,e[A]=Ve-kt,e[A+1]=ot-Ue,e[T]=_t-et,e[T+1]=at+Se}}}}_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],f=e[n+o],_=e[n+o+1],m=e[n+i],w=e[n+i+1],x=e[n+l],k=e[n+l+1],E=c+m,A=p+w,T=c-m,S=p-w,P=f+x,O=_+k,v=a*(f-x),W=a*(_-k);r[s]=E+P,r[s+1]=A+O,r[s+2]=T+W,r[s+3]=S-v,r[s+4]=E-P,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 f=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 k=0,E=0;k<=x;k+=2,E+=a){let A=l+k,T=A+w,S=T+w,P=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[P],K=e[P+1],R=O,C=v,re=f[E],ae=s*f[E+1],z=W*re-X*ae,$=W*ae+X*re,U=f[2*E],J=s*f[2*E+1],xe=B*U-H*J,ue=B*J+H*U,Ve=f[3*E],ot=s*f[3*E+1],_t=G*Ve-K*ot,at=G*ot+K*Ve,kt=R+xe,Ue=C+ue,Se=R-xe,et=C-ue,nr=z+_t,Te=$+at,Be=s*(z-_t),vn=s*($-at);if(e[A]=kt+nr,e[A+1]=Ue+Te,e[T]=Se+vn,e[T+1]=et-Be,k===0){e[S]=kt-nr,e[S+1]=Ue-Te;continue}if(k===x)continue;let Zi=l+w-k,kn=l+m-k;e[Zi]=Se-s*vn,e[Zi+1]=-et-s*Be,e[kn]=kt-s*nr,e[kn+1]=-Ue+s*Te}}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],f=e[n+i],_=e[n+l],m=c+f,w=c-f,x=p+_,k=a*(p-_);r[s]=m+x,r[s+1]=0,r[s+2]=w,r[s+3]=-k,r[s+4]=m-x,r[s+5]=0,r[s+6]=w,r[s+7]=k}},Eb=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 f=(p+1-e)**2/2,_=Math.sqrt(l**2+c**2)**f,m=f*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 Ku(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 f=0;f<c.length;f+=2){let _=f+1,m=f>>1,w=r[m];n[f]=w*c[f],n[_]=w*c[_]}else for(let f=0;f<c.length;f+=2){let _=f+1;n[f]=r[f]*c[f]-r[_]*c[_],n[_]=r[f]*c[_]+r[_]*c[f]}this._f.transform(a,n);for(let f=0;f<l.length;f+=2){let _=f+1;o[f]=a[f]*l[f]-a[_]*l[_],o[_]=a[f]*l[_]+a[_]*l[f]}this._f.inverseTransform(i,o);for(let f=0;f<i.length;f+=2){let _=i[f+p],m=i[f+p+1],w=c[f],x=c[f+1];e[f]=_*w-m*x,e[f+1]=_*x+m*w}}transform(e,r){this._transform(e,r,!1)}realTransform(e,r){this._transform(e,r,!0)}},Yu=class{constructor(e){this.fft_length=e,this.isPowerOfTwo=uA(e),this.isPowerOfTwo?(this.fft=new Ku(e),this.outputBufferSize=2*e):(this.fft=new Eb(e),this.outputBufferSize=this.fft.bufferSize)}realTransform(e,r){this.fft.realTransform(e,r)}transform(e,r){this.fft.transform(e,r)}};function pA(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 Cs(t,e){let r=Math.pow(10,e);return Math.round(t*r)/r}function dA(t){let e=Math.round(t);return Math.abs(t)%1===.5?e%2===0?e:e-1:e}function fA(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 _=n[f-1][p-1],m=n[f-1][p],w=n[f][p-1],x,k;_<m&&_<w?(x=_,k=0):m<_&&m<w?(x=m,k=1):(x=w,k=2),n[f][p]=t[f-1][p-1]+x,o[f][p]=k}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 _A=(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,f=(l&31744)>>10,_=l&1023;if(f===31)c=p|2139095040|_<<13;else if(f===0)if(_===0)c=p;else{let m=113;for(;(_&1024)===0;)_<<=1,--m;_&=-1025,c=p|m<<23|_<<13}else c=p|f+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 vL=yr(require("onnxruntime-node"),1);var m1={};Ms(m1,{InferenceSession:()=>e1,TRACE:()=>ap,TRACE_EVENT_BEGIN:()=>ts,TRACE_EVENT_END:()=>rs,TRACE_FUNC_BEGIN:()=>Rs,TRACE_FUNC_END:()=>Ds,Tensor:()=>er,default:()=>bL,env:()=>Xe,registerBackend:()=>$s});var Zt={};var Jb=Object.defineProperty,Hz=Object.getOwnPropertyDescriptor,Xz=Object.getOwnPropertyNames,Kz=Object.prototype.hasOwnProperty,Yz=(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),vl=(t,e)=>{for(var r in e)Jb(t,r,{get:e[r],enumerable:!0})},Qz=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xz(e))!Kz.call(t,n)&&n!==r&&Jb(t,n,{get:()=>e[n],enumerable:!(s=Hz(e,n))||s.enumerable});return t},op=t=>Qz(Jb({},"__esModule",{value:!0}),t),ml,Qr,$s,mA,jA,GA=be(()=>{"use strict";ml=new Map,Qr=[],$s=(t,e,r)=>{if(e&&typeof e.init=="function"&&typeof e.createInferenceSessionHandler=="function"){let s=ml.get(t);if(s===void 0)ml.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=Qr.indexOf(t);n!==-1&&Qr.splice(n,1);for(let o=0;o<Qr.length;o++)if(ml.get(Qr[o]).priority<=r){Qr.splice(o,0,t);return}Qr.push(t)}return}throw new TypeError("not a valid backend")},mA=async t=>{let e=ml.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}}},jA=async t=>{let e=t.executionProviders||[],r=e.map(l=>typeof l=="string"?l:l.name),s=r.length===0?Qr:r,n,o=[],a=new Set;for(let l of s){let c=await mA(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)})]}}),Jz=be(()=>{"use strict";GA()}),qA,Zz=be(()=>{"use strict";qA="1.24.0-dev.20251116-b39e144322"}),Mb,pt,WA=be(()=>{"use strict";Zz(),Mb="warning",pt={wasm:{},webgl:{},webgpu:{},versions:{common:qA},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}`);Mb=t}},get logLevel(){return Mb}},Object.defineProperty(pt,"logLevel",{enumerable:!0})}),Xe,eL=be(()=>{"use strict";WA(),Xe=pt}),VA,HA,tL=be(()=>{"use strict";VA=(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,f=0,_=p,m=p*2,w=-1;a==="RGBA"?(f=0,_=p,m=p*2,w=p*3):a==="RGB"?(f=0,_=p,m=p*2):a==="RBG"&&(f=0,m=p,_=p*2);for(let x=0;x<o;x++)for(let k=0;k<n;k++){let E=(t.data[f++]-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("+E+","+A+","+T+","+S+")",s.fillRect(k,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")},HA=(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 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 _=4,m=0,w=1,x=2,k=3,E=0,A=f,T=f*2,S=-1;i==="RGBA"?(E=0,A=f,T=f*2,S=f*3):i==="RGB"?(E=0,A=f,T=f*2):i==="RBG"&&(E=0,T=f,A=f*2),s=r.createImageData(n,o);for(let P=0;P<o*n;m+=_,w+=_,x+=_,k+=_,P++)s.data[m]=(t.data[E++]-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[k]=S===-1?255:(t.data[S++]-p[3])*c[3]}else throw new Error("Can not access image data");return s}}),Ju,XA,KA,YA,QA,JA,rL=be(()=>{"use strict";Zb(),Ju=(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),f=4,_=0,m=1,w=2,x=3,k=0,E=c,A=c*2,T=-1;i==="RGB"&&(f=3,_=0,m=1,w=2,x=-1),l==="RGBA"?T=c*3:l==="RBG"?(k=0,A=c,E=c*2):l==="BGR"&&(A=0,E=c,k=c*2);for(let S=0;S<c;S++,_+=f,w+=f,m+=f,x+=f)p[k++]=(t[_]+a[0])/o[0],p[E++]=(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 zt("float32",p,[1,4,r,s]):new zt("float32",p,[1,3,r,s])},XA=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 f=c(p);if(f!=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;f.drawImage(t,0,0),a=f.getImageData(0,0,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 _=l();_.width=f,_.height=p;let m=c(_);if(m!=null)m.putImageData(t,0,0),a=m.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=c(p);if(f!=null){let _=t.height,m=t.width;return f.drawImage(t,0,0,m,_),a=f.getImageData(0,0,m,_).data,i.height=_,i.width=m,Ju(a,i)}else throw new Error("Can not access image data")}else{if(o)return new Promise((p,f)=>{let _=l(),m=c(_);if(!t||!m)return f();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(Ju(x.data,i))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(a!==void 0)return Ju(a,i);throw new Error("Input data provided is not supported - aborted tensor creation")},KA=(t,e)=>{let{width:r,height:s,download:n,dispose:o}=e,a=[1,s,r,4];return new zt({location:"texture",type:"float32",texture:t,dims:a,download:n,dispose:o})},YA=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new zt({location:"gpu-buffer",type:r??"float32",gpuBuffer:t,dims:s,download:n,dispose:o})},QA=(t,e)=>{let{dataType:r,dims:s,download:n,dispose:o}=e;return new zt({location:"ml-tensor",type:r??"float32",mlTensor:t,dims:s,download:n,dispose:o})},JA=(t,e,r)=>new zt({location:"cpu-pinned",type:t,data:e,dims:r??[e.length]})}),Ls,yl,Sb,ZA,sL=be(()=>{"use strict";Ls=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),yl=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),Sb=!1,ZA=()=>{if(!Sb){Sb=!0;let t=typeof BigInt64Array<"u"&&BigInt64Array.from,e=typeof BigUint64Array<"u"&&BigUint64Array.from,r=globalThis.Float16Array,s=typeof r<"u"&&r.from;t&&(Ls.set("int64",BigInt64Array),yl.set(BigInt64Array,"int64")),e&&(Ls.set("uint64",BigUint64Array),yl.set(BigUint64Array,"uint64")),s?(Ls.set("float16",r),yl.set(r,"float16")):Ls.set("float16",Uint16Array)}}}),e2,t2,nL=be(()=>{"use strict";Zb(),e2=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},t2=(t,e)=>{switch(t.location){case"cpu":return new zt(t.type,t.data,e);case"cpu-pinned":return new zt({location:"cpu-pinned",data:t.data,type:t.type,dims:e});case"texture":return new zt({location:"texture",texture:t.texture,type:t.type,dims:e});case"gpu-buffer":return new zt({location:"gpu-buffer",gpuBuffer:t.gpuBuffer,type:t.type,dims:e});case"ml-tensor":return new zt({location:"ml-tensor",mlTensor:t.mlTensor,type:t.type,dims:e});default:throw new Error(`tensorReshape: tensor location ${t.location} is not supported`)}}}),zt,Zb=be(()=>{"use strict";tL(),rL(),sL(),nL(),zt=class{constructor(t,e,r){ZA();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=Ls.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=Ls.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=yl.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=e2(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 XA(t,e)}static fromTexture(t,e){return KA(t,e)}static fromGpuBuffer(t,e){return YA(t,e)}static fromMLTensor(t,e){return QA(t,e)}static fromPinnedBuffer(t,e,r){return JA(t,e,r)}toDataURL(t){return VA(this,t)}toImageData(t){return HA(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 t2(this,t)}}}),er,r2=be(()=>{"use strict";Zb(),er=zt}),ap,Tb,Rs,Ds,ts,rs,s2=be(()=>{"use strict";WA(),ap=(t,e)=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||console.timeStamp(`${t}::ORT::${e}`)},Tb=(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}`),ap("CPU",o);return}r[n].includes("TRACE_FUNC")&&(s=!0)}},Rs=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||Tb("BEGIN",t)},Ds=t=>{(typeof pt.trace>"u"?!pt.wasm.trace:!pt.trace)||Tb("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}`)}}),n2,oL=be(()=>{"use strict";GA(),r2(),s2(),n2=class o2{constructor(e){this.handler=e}async run(e,r,s){Rs(),ts("InferenceSession.run");let n={},o={};if(typeof e!="object"||e===null||e instanceof er||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 er)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 f of this.outputNames)if(p.indexOf(f)!==-1){let _=r[f];(_===null||_ instanceof er)&&(c=!0,a=!1,n[f]=_)}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 er?l[c]=p:l[c]=new er(p.type,p.data,p.dims)}return rs("InferenceSession.run"),Ds(),l}async release(){return this.handler.dispose()}static async create(e,r,s,n){Rs(),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,f=0,_=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(_=e.byteLength-f,typeof s=="number"){if(_=s,!Number.isSafeInteger(_))throw new RangeError("'byteLength' must be an integer.");if(_<=0||f+_>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,_)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[i,l]=await jA(a),c=await i.createInferenceSessionHandler(o,l);return rs("InferenceSession.create"),Ds(),new o2(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}}}),e1,aL=be(()=>{"use strict";oL(),e1=n2}),iL=be(()=>{"use strict"}),lL=be(()=>{"use strict"}),cL=be(()=>{"use strict"}),uL=be(()=>{"use strict"}),a2={};vl(a2,{InferenceSession:()=>e1,TRACE:()=>ap,TRACE_EVENT_BEGIN:()=>ts,TRACE_EVENT_END:()=>rs,TRACE_FUNC_BEGIN:()=>Rs,TRACE_FUNC_END:()=>Ds,Tensor:()=>er,env:()=>Xe,registerBackend:()=>$s});var Us=be(()=>{"use strict";Jz(),eL(),aL(),r2(),iL(),lL(),s2(),cL(),uL()}),t1=be(()=>{"use strict"}),i2={};vl(i2,{default:()=>l2});var Ob,Ib,l2,pL=be(()=>{"use strict";k2(),Bs(),r1(),Ob="ort-wasm-proxy-worker",Ib=globalThis.self?.name===Ob,Ib&&(self.onmessage=t=>{let{type:e,in:r}=t.data;try{switch(e){case"init-wasm":s1(r.wasm).then(()=>{l1(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;c1(n,s).then(()=>{postMessage({type:e})},o=>{postMessage({type:e,err:o})});break}case"copy-from":{let{buffer:s}=r,n=cp(s);postMessage({type:e,out:n});break}case"create":{let{model:s,options:n}=r;u1(s,n).then(o=>{postMessage({type:e,out:o})},o=>{postMessage({type:e,err:o})});break}case"release":p1(r),postMessage({type:e});break;case"run":{let{sessionId:s,inputIndices:n,inputs:o,outputIndices:a,options:i}=r;d1(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},_1([...o,...l]))},l=>{postMessage({type:e,err:l})});break}case"end-profiling":f1(r),postMessage({type:e});break;default:}}catch(s){postMessage({type:e,err:s})}}),l2=Ib?null:t=>new Worker(t??Ct,{type:"module",name:Ob})}),c2={};vl(c2,{default:()=>u2});async function hA(t={}){var e=t,r=!!globalThis.window,s=!!globalThis.WorkerGlobalScope,n=s&&self.name?.startsWith("em-pthread");e.mountExternalData=(u,d)=>{u.startsWith("./")&&(u=u.substring(2)),(e.Uc||(e.Uc=new Map)).set(u,d)},e.unmountExternalData=()=>{delete e.Uc},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,Be:!0}).buffer.constructor;let o=()=>{let u=d=>(...h)=>{let g=ar;return h=d(...h),ar!=g?new Promise((b,M)=>{q0={resolve:b,reject:M}}):h};(()=>{for(let d of["_OrtAppendExecutionProvider","_OrtCreateSession","_OrtRun","_OrtRunWithBinding","_OrtBindInput"])e[d]=u(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=(u,d)=>{throw d},c=Zt.url,p="";if(r||s){try{p=new URL(".",c).href}catch{}s&&(i=u=>{var d=new XMLHttpRequest;return d.open("GET",u,!1),d.responseType="arraybuffer",d.send(null),new Uint8Array(d.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 d=await fetch(u,{credentials:"same-origin"});if(d.ok)return d.arrayBuffer();throw Error(d.status+" : "+d.url)}}var f,_,m,w,x,k,E=console.log.bind(console),A=console.error.bind(console),T=E,S=A,P=!1,O=u=>u.startsWith("file://");function v(){Gr.buffer!=B.buffer&&xe()}if(n){let u=function(d){try{var h=d.data,g=h.Oc;if(g==="load"){let b=[];self.onmessage=M=>b.push(M),k=()=>{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(),$u()}else if(g==="run"){(function(b){var M=(v(),C)[b+52>>>2>>>0];b=(v(),C)[b+56>>>2>>>0],yk(M,M-b),le(M)})(h.Nc),rb(h.Nc,0,0,1,0,0),iv(),F0(h.Nc),X||(rk(),X=!0);try{mS(h.he,h.Wc)}catch(b){if(b!="unwind")throw b}}else h.target!=="setimmediate"&&(g==="checkMailbox"?X&&Tu():g&&(S(`worker: received unknown command ${g}`),S(h)))}catch(b){throw mk(),b}};var W=u,X=!1;self.onunhandledrejection=d=>{throw d.reason||d},self.onmessage=u}var B,H,G,K,R,C,re,ae,z,$,U,J=!1;function xe(){var u=Gr.buffer;e.HEAP8=B=new Int8Array(u),G=new Int16Array(u),e.HEAPU8=H=new Uint8Array(u),K=new Uint16Array(u),e.HEAP32=R=new Int32Array(u),e.HEAPU32=C=new Uint32Array(u),re=new Float32Array(u),ae=new Float64Array(u),z=new BigInt64Array(u),$=new BigUint64Array(u)}function ue(){J=!0,n?k():xr._b()}function Ve(u){throw S(u="Aborted("+u+")"),P=!0,u=new WebAssembly.RuntimeError(u+". Build with -sASSERTIONS for more info."),x?.(u),u}function ot(){return{a:{f:hS,J:gS,k:wS,p:xS,l:yS,ta:bS,b:vS,ca:kS,Ka:fv,q:ES,da:gv,_a:wv,Ga:xv,Ia:yv,$a:bv,Ya:vv,Ra:kv,Xa:Ev,pa:Av,Ha:Mv,Yb:Sv,Za:Tv,Fa:Ov,eb:AS,Da:SS,Tb:TS,Rb:IS,Ca:PS,M:zS,I:LS,Sb:NS,ka:jS,Ub:GS,Ua:qS,Wb:VS,La:HS,Pb:XS,la:KS,Ta:F0,bb:YS,U:eT,n:oT,c:U0,sb:aT,w:iT,L:lT,z:cT,j:uT,o:Rv,tb:pT,G:dT,T:fT,h:_T,u:mT,m:hT,i:gT,Oa:wT,Pa:xT,Qa:yT,Ma:Fv,Na:jv,Qb:Gv,fb:vT,db:AT,Y:MT,rb:ST,ma:TT,cb:kT,gb:OT,ab:IT,Xb:CT,N:bT,hb:PT,X:zT,Vb:LT,ob:GT,C:qT,sa:WT,ra:VT,qb:HT,W:XT,v:KT,nb:YT,mb:QT,lb:JT,pb:ZT,kb:eO,jb:tO,ib:rO,Va:Kv,Wa:Yv,Ja:kn,ea:Qv,oa:Jv,Sa:Zv,na:ek,Db:dI,xa:nI,Eb:pI,ya:sI,F:HO,e:LO,s:PO,x:CO,D:qO,Ib:eI,ba:JO,B:RO,za:tI,$:oI,ha:ZO,Fb:cI,Gb:lI,Ba:XO,Aa:QO,Jb:KO,wa:uI,aa:rI,d:zO,A:$O,r:NO,Cb:fI,t:UO,y:WO,H:DO,E:BO,K:VO,S:aI,ja:GO,_:iI,Kb:jO,Lb:FO,P:YO,g:nO,a:Gr,Ob:vn,Hb:oO,ia:aO,O:iO,qa:lO,Mb:cO,Q:uO,zb:pO,Ab:dO,ua:fO,fa:_O,R:mO,Ea:hO,va:gO,Z:wO,xb:xO,Zb:yO,V:bO,Bb:vO,ub:kO,vb:AO,wb:MO,ga:SO,yb:TO,Nb:OO}}}async function _t(){function u(g,b){var M=xr=g.exports;g={};for(let[I,L]of Object.entries(M))typeof L=="function"?(M=QS(L),g[I]=M):g[I]=L;return xr=g,xr=(function(){var I=xr,L=Y=>Oe=>Y(Oe)>>>0,F=Y=>()=>Y()>>>0;return(I=Object.assign({},I)).$b=L(I.$b),I.Cc=F(I.Cc),I.Ec=L(I.Ec),I.rd=(Y=>(Oe,Ne)=>Y(Oe,Ne)>>>0)(I.rd),I.wd=L(I.wd),I.xd=F(I.xd),I.Bd=L(I.Bd),I})(),ov.push(xr.id),tk=(g=xr).$b,rk=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,Y0=e._OrtGetWebGpuDevice=g.Bc,Lu=g.Cc,Ht=e._free=g.Dc,Tn=e._malloc=g.Ec,sk=e._wgpuBufferRelease=g.Fc,nk=e._wgpuCreateInstance=g.Gc,ok=g.Hc,ak=g.Ic,ik=g.Jc,lk=g.Kc,ck=g.Lc,uk=g.Pc,pk=g.Zc,dk=g._c,fk=g.$c,Q0=g.bd,J0=g.cd,Z0=g.dd,eb=g.ed,sl=g.fd,tb=g.gd,_k=g.hd,rb=g.kd,mk=g.ld,hk=g.md,gk=g.nd,sb=g.od,wk=g.pd,xk=g.qd,nb=g.rd,we=g.sd,nl=g.td,yk=g.ud,le=g.vd,Nu=g.wd,ce=g.xd,bk=g.yd,ob=g.zd,vk=g.Ad,kk=g.Bd,Ek=g.Cd,ab=g.Dd,Ak=g.Ed,Mk=g.Fd,Sk=g.Gd,Tk=g.Hd,Ok=g.Id,Ik=g.Jd,Ck=g.Kd,Pk=g.Ld,zk=g.Md,Lk=g.Nd,Nk=g.Od,$k=g.Pd,Rk=g.Qd,Dk=g.Rd,Uk=g.Td,Bk=g.Ud,Fk=g.Vd,jk=g.Wd,Gk=g.Yd,qk=g.Zd,Wk=g._d,Vk=g.$d,Hk=g.ae,Xk=g.be,Kk=g.pe,Yk=g.qe,Qk=g.re,Jk=g.se,Zk=g.te,eE=g.ue,tE=g.ve,rE=g.we,sE=g.xe,nE=g.ye,oE=g.ze,aE=g.Xe,iE=g.Ye,lE=g.Ze,cE=g._e,_=b,xr}var d,h=ot();return e.instantiateWasm?new Promise(g=>{e.instantiateWasm(h,(b,M)=>{g(u(b,M))})}):n?u(new WebAssembly.Instance(_,ot()),_):(U??=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",Zt.url).href,d=await(async function(g){var b=U;if(!f&&!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,L){try{var F=await(async function(Y){if(!f)try{var Oe=await a(Y);return new Uint8Array(Oe)}catch{}if(Y==U&&f)Y=new Uint8Array(f);else{if(!i)throw"both async and sync fetching of the wasm failed";Y=i(Y)}return Y})(I);return await WebAssembly.instantiate(F,L)}catch(Y){S(`failed to asynchronously prepare wasm: ${Y}`),Ve(Y)}})(b,g)})(h),u(d.instance,d.module))}class at{name="ExitStatus";constructor(d){this.message=`Program terminated with exit(${d})`,this.status=d}}var kt=u=>{u.terminate(),u.onmessage=()=>{}},Ue=[],Se=0,et=null,nr=u=>{jr.length==0&&(cv(),lv(jr[0]));var d=jr.pop();if(!d)return 6;el.push(d),ks[u.Nc]=d,d.Nc=u.Nc;var h={Oc:"run",he:u.ge,Wc:u.Wc,Nc:u.Nc};return d.postMessage(h,u.Yc),0},Te=0,Be=(u,d,...h)=>{var g,b=16*h.length,M=ce(),I=Nu(b),L=I>>>3;for(g of h)typeof g=="bigint"?((v(),z)[L++>>>0]=1n,(v(),z)[L++>>>0]=g):((v(),z)[L++>>>0]=0n,(v(),ae)[L++>>>0]=g);return u=hk(u,0,b,I,d),le(M),u};function vn(u){if(n)return Be(0,1,u);if(m=u,!(0<Te)){for(var d of el)kt(d);for(d of jr)kt(d);jr=[],el=[],ks={},P=!0}l(0,new at(u))}function Zi(u){if(n)return Be(1,0,u);kn(u)}var kn=u=>{if(m=u,n)throw Zi(u),"unwind";vn(u)},jr=[],el=[],ov=[],ks={},av=u=>{var d=u.Nc;delete ks[d],jr.push(u),el.splice(el.indexOf(u),1),u.Nc=0,gk(d)};function iv(){ov.forEach(u=>u())}var lv=u=>new Promise(d=>{u.onmessage=b=>{var M=b.data;if(b=M.Oc,M.Vc&&M.Vc!=Lu()){var I=ks[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"?Tu():b==="spawnThread"?nr(M):b==="cleanupThread"?At(()=>{av(ks[M.ie])}):b==="loaded"?(u.loaded=!0,d(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 cv(){var u=new Worker((()=>{let d=URL;return Zt.url>"file:"&&Zt.url<"file;"?new d("ort.webgpu.bundle.min.mjs",Zt.url):new URL(Zt.url)})(),{type:"module",workerData:"em-pthread",name:"em-pthread"});jr.push(u)}var Gr,mS=(u,d)=>{Te=0,u=ab(u,d),0<Te?m=u:sb(u)},Mu=[],Su=0,Et=u=>-9007199254740992>u||9007199254740992<u?NaN:Number(u);function hS(u){var d=new N0(u>>>=0);return(v(),B)[d.Qc+12>>>0]==0&&(uv(d,!0),Su--),pv(d,!1),Mu.push(d),kk(u)}var En=0,gS=()=>{we(0,0);var u=Mu.pop();bk(u.Xc),En=0};function uv(u,d){d=d?1:0,(v(),B)[u.Qc+12>>>0]=d}function pv(u,d){d=d?1:0,(v(),B)[u.Qc+13>>>0]=d}class N0{constructor(d){this.Xc=d,this.Qc=d-24}}var $0=u=>{var d=En;if(!d)return nl(0),0;var h=new N0(d);(v(),C)[h.Qc+16>>>2>>>0]=d;var g=(v(),C)[h.Qc+4>>>2>>>0];if(!g)return nl(0),d;for(var b of u){if(b===0||b===g)break;if(vk(b,g,h.Qc+16))return nl(b),d}return nl(g),d};function wS(){return $0([])}function xS(u){return $0([u>>>0])}function yS(u,d,h,g){return $0([u>>>0,d>>>0,h>>>0,g>>>0])}var bS=()=>{var u=Mu.pop();u||Ve("no exception to throw");var d=u.Xc;throw(v(),B)[u.Qc+13>>>0]==0&&(Mu.push(u),pv(u,!0),uv(u,!1),Su++),ob(d),En=d};function vS(u,d,h){var g=new N0(u>>>=0);throw d>>>=0,h>>>=0,(v(),C)[g.Qc+16>>>2>>>0]=0,(v(),C)[g.Qc+4>>>2>>>0]=d,(v(),C)[g.Qc+8>>>2>>>0]=h,ob(u),Su++,En=u}var kS=()=>Su;function dv(u,d,h,g){return n?Be(2,1,u,d,h,g):fv(u,d,h,g)}function fv(u,d,h,g){if(u>>>=0,d>>>=0,h>>>=0,g>>>=0,!globalThis.SharedArrayBuffer)return 6;var b=[];return n&&b.length===0?dv(u,d,h,g):(u={ge:h,Nc:u,Wc:g,Yc:b},n?(u.Oc="spawnThread",postMessage(u,b),0):nr(u))}function ES(u){throw En||=u>>>0,En}var _v=globalThis.TextDecoder&&new TextDecoder,mv=(u,d,h,g)=>{if(h=d+h,g)return h;for(;u[d]&&!(d>=h);)++d;return d},hv=(u,d=0,h,g)=>{if(16<(h=mv(u,d>>>=0,h,g))-d&&u.buffer&&_v)return _v.decode(u.buffer instanceof ArrayBuffer?u.subarray(d,h):u.slice(d,h));for(g="";d<h;){var b=u[d++];if(128&b){var M=63&u[d++];if((224&b)==192)g+=String.fromCharCode((31&b)<<6|M);else{var I=63&u[d++];65536>(b=(240&b)==224?(15&b)<<12|M<<6|I:(7&b)<<18|M<<12|I<<6|63&u[d++])?g+=String.fromCharCode(b):(b-=65536,g+=String.fromCharCode(55296|b>>10,56320|1023&b))}}else g+=String.fromCharCode(b)}return g},An=(u,d,h)=>(u>>>=0)?hv((v(),H),u,d,h):"";function gv(u,d,h){return n?Be(3,1,u,d,h):0}function wv(u,d){if(n)return Be(4,1,u,d)}function xv(u,d){if(n)return Be(5,1,u,d)}function yv(u,d,h){if(n)return Be(6,1,u,d,h)}function bv(u,d,h){return n?Be(7,1,u,d,h):0}function vv(u,d){if(n)return Be(8,1,u,d)}function kv(u,d,h){if(n)return Be(9,1,u,d,h)}function Ev(u,d,h,g){if(n)return Be(10,1,u,d,h,g)}function Av(u,d,h,g){if(n)return Be(11,1,u,d,h,g)}function Mv(u,d,h,g){if(n)return Be(12,1,u,d,h,g)}function Sv(u){if(n)return Be(13,1,u)}function Tv(u,d){if(n)return Be(14,1,u,d)}function Ov(u,d,h){if(n)return Be(15,1,u,d,h)}var AS=()=>Ve(""),or=u=>{u>>>=0;for(var d="";;){var h=(v(),H)[u++>>>0];if(!h)return d;d+=String.fromCharCode(h)}},R0={},D0={},MS={},Mn=class extends Error{constructor(u){super(u),this.name="BindingError"}};function _r(u,d,h={}){return(function(g,b,M={}){var I=b.name;if(!g)throw new Mn(`type "${I}" must have a positive integer typeid pointer`);if(D0.hasOwnProperty(g)){if(M.ee)return;throw new Mn(`Cannot register type '${I}' twice`)}D0[g]=b,delete MS[g],R0.hasOwnProperty(g)&&(b=R0[g],delete R0[g],b.forEach(L=>L()))})(u,d,h)}var Iv=(u,d,h)=>{switch(d){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(),K)[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(),z)[g>>>3>>>0]:g=>(v(),$)[g>>>3>>>0];default:throw new TypeError(`invalid integer width (${d}): ${u}`)}};function SS(u,d,h,g,b){u>>>=0,h>>>=0,d=or(d>>>0);let M=I=>I;if(g=g===0n){let I=8*h;M=L=>BigInt.asUintN(I,L),b=M(b)}_r(u,{name:d,Mc:M,Sc:(I,L)=>(typeof L=="number"&&(L=BigInt(L)),L),Rc:Iv(d,h,!g),Tc:null})}function TS(u,d,h,g){_r(u>>>=0,{name:d=or(d>>>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 Cv=[],Es=[0,1,,1,null,1,!0,1,!1,1];function U0(u){9<(u>>>=0)&&--Es[u+1]==0&&(Es[u]=void 0,Cv.push(u))}var Rt=u=>{if(!u)throw new Mn(`Cannot use deleted val. handle = ${u}`);return Es[u]},Vt=u=>{switch(u){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let d=Cv.pop()||Es.length;return Es[d]=u,Es[d+1]=1,d}};function B0(u){return this.Mc((v(),C)[u>>>2>>>0])}var OS={name:"emscripten::val",Mc:u=>{var d=Rt(u);return U0(u),d},Sc:(u,d)=>Vt(d),Rc:B0,Tc:null};function IS(u){return _r(u>>>0,OS)}var CS=(u,d)=>{switch(d){case 4:return function(h){return this.Mc((v(),re)[h>>>2>>>0])};case 8:return function(h){return this.Mc((v(),ae)[h>>>3>>>0])};default:throw new TypeError(`invalid float width (${d}): ${u}`)}};function PS(u,d,h){h>>>=0,_r(u>>>=0,{name:d=or(d>>>0),Mc:g=>g,Sc:(g,b)=>b,Rc:CS(d,h),Tc:null})}function zS(u,d,h,g,b){u>>>=0,h>>>=0,d=or(d>>>0);let M=L=>L;if(g===0){var I=32-8*h;M=L=>L<<I>>>I,b=M(b)}_r(u,{name:d,Mc:M,Sc:(L,F)=>F,Rc:Iv(d,h,g!==0),Tc:null})}function LS(u,d,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][d];_r(u>>>=0,{name:h=or(h>>>0),Mc:g,Rc:g},{ee:!0})}var mr=(u,d,h)=>{var g=(v(),H);if(d>>>=0,0<h){var b=d;h=d+h-1;for(var M=0;M<u.length;++M){var I=u.codePointAt(M);if(127>=I){if(d>=h)break;g[d++>>>0]=I}else if(2047>=I){if(d+1>=h)break;g[d++>>>0]=192|I>>6,g[d++>>>0]=128|63&I}else if(65535>=I){if(d+2>=h)break;g[d++>>>0]=224|I>>12,g[d++>>>0]=128|I>>6&63,g[d++>>>0]=128|63&I}else{if(d+3>=h)break;g[d++>>>0]=240|I>>18,g[d++>>>0]=128|I>>12&63,g[d++>>>0]=128|I>>6&63,g[d++>>>0]=128|63&I,M++}}g[d>>>0]=0,u=d-b}else u=0;return u},hr=u=>{for(var d=0,h=0;h<u.length;++h){var g=u.charCodeAt(h);127>=g?d++:2047>=g?d+=2:55296<=g&&57343>=g?(d+=4,++h):d+=3}return d};function NS(u,d){_r(u>>>=0,{name:d=or(d>>>0),Mc(h){var g=(v(),C)[h>>>2>>>0];return g=An(h+4,g,!0),Ht(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 Mn("Cannot pass non-string to std::string");var M=b?hr(g):g.length,I=Tn(4+M+1),L=I+4;return(v(),C)[I>>>2>>>0]=M,b?mr(g,L,M+1):(v(),H).set(g,L>>>0),h!==null&&h.push(Ht,I),I},Rc:B0,Tc(h){Ht(h)}})}var Pv=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,$S=(u,d,h)=>{if(u>>>=1,16<(d=mv((v(),K),u,d/2,h))-u&&Pv)return Pv.decode((v(),K).slice(u,d));for(h="";u<d;++u){var g=(v(),K)[u>>>0];h+=String.fromCharCode(g)}return h},RS=(u,d,h)=>{if(h??=2147483647,2>h)return 0;var g=d;h=(h-=2)<2*u.length?h/2:u.length;for(var b=0;b<h;++b){var M=u.charCodeAt(b);(v(),G)[d>>>1>>>0]=M,d+=2}return(v(),G)[d>>>1>>>0]=0,d-g},DS=u=>2*u.length,US=(u,d,h)=>{var g="";u>>>=2;for(var b=0;!(b>=d/4);b++){var M=(v(),C)[u+b>>>0];if(!M&&!h)break;g+=String.fromCodePoint(M)}return g},BS=(u,d,h)=>{if(d>>>=0,h??=2147483647,4>h)return 0;var g=d;h=g+h-4;for(var b=0;b<u.length;++b){var M=u.codePointAt(b);if(65535<M&&b++,(v(),R)[d>>>2>>>0]=M,(d+=4)+4>h)break}return(v(),R)[d>>>2>>>0]=0,d-g},FS=u=>{for(var d=0,h=0;h<u.length;++h)65535<u.codePointAt(h)&&h++,d+=4;return d};function jS(u,d,h){if(u>>>=0,d>>>=0,h=or(h>>>=0),d===2)var g=$S,b=RS,M=DS;else g=US,b=BS,M=FS;_r(u,{name:h,Mc:I=>{var L=(v(),C)[I>>>2>>>0];return L=g(I+4,L*d,!0),Ht(I),L},Sc:(I,L)=>{if(typeof L!="string")throw new Mn(`Cannot pass non-string to C++ string type ${h}`);var F=M(L),Y=Tn(4+F+d);return(v(),C)[Y>>>2>>>0]=F/d,b(L,Y+4,F+d),I!==null&&I.push(Ht,Y),Y},Rc:B0,Tc(I){Ht(I)}})}function GS(u,d){_r(u>>>=0,{fe:!0,name:d=or(d>>>0),Mc:()=>{},Sc:()=>{}})}function qS(u){rb(u>>>0,!s,1,!r,131072,!1),iv()}var At=u=>{if(!P)try{if(u(),!(0<Te))try{n?Lu()&&sb(m):kn(m)}catch(d){d instanceof at||d=="unwind"||l(0,d)}}catch(d){d instanceof at||d=="unwind"||l(0,d)}},WS=!Atomics.waitAsync||globalThis.navigator?.userAgent&&91>Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function F0(u){u>>>=0,WS||(Atomics.waitAsync((v(),R),u>>>2,u).value.then(Tu),u+=128,Atomics.store((v(),R),u>>>2,1))}var Tu=()=>At(()=>{var u=Lu();u&&(F0(u),xk())});function VS(u,d){(u>>>=0)==d>>>0?setTimeout(Tu):n?postMessage({Vc:u,Oc:"checkMailbox"}):(u=ks[u])&&u.postMessage({Oc:"checkMailbox"})}var j0=[];function HS(u,d,h,g,b){for(d>>>=0,b>>>=0,j0.length=0,h=b>>>3,g=b+g>>>3;h<g;){var M;M=(v(),z)[h++>>>0]?(v(),z)[h++>>>0]:(v(),ae)[h++>>>0],j0.push(M)}return(d?ib[d]:IO[u])(...j0)}var XS=()=>{Te=0};function KS(u){u>>>=0,n?postMessage({Oc:"cleanupThread",ie:u}):av(ks[u])}function YS(u){}var Ou=u=>{try{u()}catch(d){Ve(d)}};function QS(u){var d=(...h)=>{Iu.push(u);try{return u(...h)}finally{P||(Iu.pop(),ar&&qr===1&&Iu.length===0&&(qr=0,Te+=1,Ou(iE),typeof Fibers<"u"&&Fibers.De()))}};return Nv.set(u,d),d}var qr=0,ar=null,zv=0,Iu=[],G0=new Map,Lv=new Map,Nv=new Map,JS=0,q0=null,ZS=[],$v=u=>(function(d){if(!P){if(qr===0){var h=!1,g=!1;d((b=0)=>{if(!P&&(zv=b,h=!0,g)){qr=2,Ou(()=>lE(ar)),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.resume(),b=!1;try{var M=(function(){var F=(v(),R)[ar+8>>>2>>>0];return F=Lv.get(F),F=Nv.get(F),--Te,F()})()}catch(F){M=F,b=!0}var I=!1;if(!ar){var L=q0;L&&(q0=null,(b?L.reject:L.resolve)(M),I=!0)}if(b&&!I)throw M}}),g=!0,h||(qr=1,ar=(function(){var b=Tn(65548),M=b+12;if((v(),C)[b>>>2>>>0]=M,(v(),C)[b+4>>>2>>>0]=M+65536,M=Iu[0],!G0.has(M)){var I=JS++;G0.set(M,I),Lv.set(I,M)}return M=G0.get(M),(v(),R)[b+8>>>2>>>0]=M,b})(),typeof MainLoop<"u"&&MainLoop.Xd&&MainLoop.pause(),Ou(()=>aE(ar)))}else qr===2?(qr=0,Ou(cE),Ht(ar),ar=null,ZS.forEach(At)):Ve(`invalid state: ${qr}`);return zv}})(d=>{u().then(d)});function eT(u){return u>>>=0,$v(async()=>{var d=await Rt(u);return Vt(d)})}var W0=[],tT=u=>{var d=W0.length;return W0.push(u),d},rT=(u,d)=>{for(var h=Array(u),g=0;g<u;++g){var b=g,M=(v(),C)[d+4*g>>>2>>>0],I=D0[M];if(I===void 0)throw u=`parameter ${g}`,M=tk(M),d=or(M),Ht(M),new Mn(`${u} has unknown type ${d}`);h[b]=I}return h},sT=(u,d,h)=>{var g=[];return u=u(g,h),g.length&&((v(),C)[d>>>2>>>0]=Vt(g)),u},nT={},Cu=u=>{var d=nT[u];return d===void 0?or(u):d};function oT(u,d,h){var[g,...b]=rT(u,d>>>0);d=g.Sc.bind(g);var M=b.map(F=>F.Rc.bind(F));u--;var I={toValue:Rt};switch(u=M.map((F,Y)=>{var Oe=`argFromPtr${Y}`;return I[Oe]=F,`${Oe}(args${Y?"+"+8*Y:""})`}),h){case 0:var L="toValue(handle)";break;case 2:L="new (toValue(handle))";break;case 3:L="";break;case 1:I.getStringOrSymbol=Cu,L="toValue(handle)[getStringOrSymbol(methodName)]"}return L+=`(${u})`,g.fe||(I.toReturnWire=d,I.emval_returnValue=sT,L=`return emval_returnValue(toReturnWire, destructorsRef, ${L})`),L=`return function (handle, methodName, destructorsRef, args) {
|
|
11
|
+
${L}
|
|
12
|
+
}`,h=new Function(Object.keys(I),L)(...Object.values(I)),L=`methodCaller<(${b.map(F=>F.name)}) => ${g.name}>`,tT(Object.defineProperty(h,"name",{value:L}))}function aT(u,d){return d>>>=0,(u=Rt(u>>>0))==Rt(d)}function iT(u){return(u>>>=0)?(u=Cu(u),Vt(globalThis[u])):Vt(globalThis)}function lT(u){return u=Cu(u>>>0),Vt(e[u])}function cT(u,d){return d>>>=0,u=Rt(u>>>0),d=Rt(d),Vt(u[d])}function uT(u){9<(u>>>=0)&&(Es[u+1]+=1)}function Rv(u,d,h,g,b){return W0[u>>>0](d>>>0,h>>>0,g>>>0,b>>>0)}function pT(u,d,h,g,b){return Rv(u>>>0,d>>>0,h>>>0,g>>>0,b>>>0)}function dT(){return Vt([])}function fT(u){u=Rt(u>>>0);for(var d=Array(u.length),h=0;h<u.length;h++)d[h]=u[h];return Vt(d)}function _T(u){return Vt(Cu(u>>>0))}function mT(){return Vt({})}function hT(u){for(var d=Rt(u>>>=0);d.length;){var h=d.pop();d.pop()(h)}U0(u)}function gT(u,d,h){d>>>=0,h>>>=0,u=Rt(u>>>0),d=Rt(d),h=Rt(h),u[d]=h}function wT(u,d){u=Et(u),d>>>=0,u=new Date(1e3*u),(v(),R)[d>>>2>>>0]=u.getUTCSeconds(),(v(),R)[d+4>>>2>>>0]=u.getUTCMinutes(),(v(),R)[d+8>>>2>>>0]=u.getUTCHours(),(v(),R)[d+12>>>2>>>0]=u.getUTCDate(),(v(),R)[d+16>>>2>>>0]=u.getUTCMonth(),(v(),R)[d+20>>>2>>>0]=u.getUTCFullYear()-1900,(v(),R)[d+24>>>2>>>0]=u.getUTCDay(),u=(u.getTime()-Date.UTC(u.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(v(),R)[d+28>>>2>>>0]=u}var Dv=u=>u%4==0&&(u%100!=0||u%400==0),Uv=[0,31,60,91,121,152,182,213,244,274,305,335],Bv=[0,31,59,90,120,151,181,212,243,273,304,334];function xT(u,d){u=Et(u),d>>>=0,u=new Date(1e3*u),(v(),R)[d>>>2>>>0]=u.getSeconds(),(v(),R)[d+4>>>2>>>0]=u.getMinutes(),(v(),R)[d+8>>>2>>>0]=u.getHours(),(v(),R)[d+12>>>2>>>0]=u.getDate(),(v(),R)[d+16>>>2>>>0]=u.getMonth(),(v(),R)[d+20>>>2>>>0]=u.getFullYear()-1900,(v(),R)[d+24>>>2>>>0]=u.getDay();var h=(Dv(u.getFullYear())?Uv:Bv)[u.getMonth()]+u.getDate()-1|0;(v(),R)[d+28>>>2>>>0]=h,(v(),R)[d+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)[d+32>>>2>>>0]=u}function yT(u){u>>>=0;var d=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=d.getTimezoneOffset(),b=new Date(d.getFullYear(),6,1).getTimezoneOffset(),M=new Date(d.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),d.setTime(d.getTime()+6e4*((0<h?I:b)-g))),(v(),R)[u+24>>>2>>>0]=d.getDay(),h=(Dv(d.getFullYear())?Uv:Bv)[d.getMonth()]+d.getDate()-1|0,(v(),R)[u+28>>>2>>>0]=h,(v(),R)[u>>>2>>>0]=d.getSeconds(),(v(),R)[u+4>>>2>>>0]=d.getMinutes(),(v(),R)[u+8>>>2>>>0]=d.getHours(),(v(),R)[u+12>>>2>>>0]=d.getDate(),(v(),R)[u+16>>>2>>>0]=d.getMonth(),(v(),R)[u+20>>>2>>>0]=d.getYear(),u=d.getTime(),BigInt(isNaN(u)?-1:u/1e3)}function Fv(u,d,h,g,b,M,I){return n?Be(16,1,u,d,h,g,b,M,I):-52}function jv(u,d,h,g,b,M){if(n)return Be(17,1,u,d,h,g,b,M)}var tl={},bT=()=>performance.timeOrigin+performance.now();function Gv(u,d){if(n)return Be(18,1,u,d);if(tl[u]&&(clearTimeout(tl[u].id),delete tl[u]),!d)return 0;var h=setTimeout(()=>{delete tl[u],At(()=>wk(u,performance.timeOrigin+performance.now()))},d);return tl[u]={id:h,Ce:d},0}function vT(u,d,h,g){u>>>=0,d>>>=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)[d>>>2>>>0]=+(M!=b),u=(d=L=>{var F=Math.abs(L);return`UTC${0<=L?"-":"+"}${String(Math.floor(F/60)).padStart(2,"0")}${String(F%60).padStart(2,"0")}`})(M),d=d(b),b<M?(mr(u,h,17),mr(d,g,17)):(mr(u,g,17),mr(d,h,17))}var kT=()=>Date.now(),ET=1;function AT(u,d,h){if(h>>>=0,!(0<=u&&3>=u))return 28;if(u===0)u=Date.now();else{if(!ET)return 52;u=performance.timeOrigin+performance.now()}return u=Math.round(1e6*u),(v(),z)[h>>>3>>>0]=BigInt(u),0}var V0=[],qv=(u,d)=>{V0.length=0;for(var h;h=(v(),H)[u++>>>0];){var g=h!=105;d+=(g&=h!=112)&&d%8?4:0,V0.push(h==112?(v(),C)[d>>>2>>>0]:h==106?(v(),z)[d>>>3>>>0]:h==105?(v(),R)[d>>>2>>>0]:(v(),ae)[d>>>3>>>0]),d+=g?8:4}return V0};function MT(u,d,h){return u>>>=0,d=qv(d>>>0,h>>>0),ib[u](...d)}function ST(u,d,h){return u>>>=0,d=qv(d>>>0,h>>>0),ib[u](...d)}var TT=()=>{};function OT(u,d){return S(An(u>>>0,d>>>0))}var IT=()=>{throw Te+=1,"unwind"};function CT(){return 4294901760}var PT=()=>1,zT=()=>navigator.hardwareConcurrency;function LT(u){u>>>=0;var d=(v(),H).length;if(u<=d||4294901760<u)return!1;for(var h=1;4>=h;h*=2){var g=d*(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 ir=u=>{var d=hr(u)+1,h=Nu(d);return mr(u,h,d),h},H0=(u,d)=>{(v(),C)[u>>>2>>>0]=d;var h=(v(),C)[u>>>2>>>0];(v(),C)[u+4>>>2>>>0]=(d-h)/4294967296},rl=u=>(v(),C)[u>>>2>>>0]+4294967296*(v(),R)[u+4>>>2>>>0],mt=[],NT=(u,d)=>{mt[u>>>0]=d},gr=[],Pu=[],Sn=(u,d)=>{Pu[u]=new Promise(h=>d.finally(()=>h(u)))},ne=u=>{if(u)return mt[u>>>0]},$T=(u,d)=>{for(u=(v(),C)[u>>>2>>>0];u;u=(v(),C)[u>>>2>>>0])d[(v(),R)[u+4>>>2>>>0]](u)},zu=(u,d,h)=>{(v(),C)[u>>>2>>>0]=d,(v(),C)[u+4>>>2>>>0]=h},Wv=u=>{var d=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],An(d,u)},wr=u=>{var d=(v(),C)[u>>>2>>>0];return u=(v(),C)[u+4>>>2>>>0],d?An(d,u):u===0?"":void 0},RT=u=>{var d=wr(u+4),h=(h=(v(),C)[u+12>>>2>>>0])?ne(h):"auto";if(u+=16){var g=ne((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={},L=0;L<b;++L){var F=M+24*L;I[Wv(F+4)]=(v(),ae)[F+16>>>3>>>0]}b=I}else b=void 0;u={module:g,constants:b,entryPoint:wr(u+8)}}else u=void 0;return{label:d,layout:h,compute:u}},Vv=(u,d)=>{function h(g,b){g=u[g],(v(),C)[d+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),H0(d+64,u.maxUniformBufferBindingSize),H0(d+72,u.maxStorageBufferBindingSize),h("maxVertexBuffers",88),H0(d+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)},DT=[,"validation","out-of-memory","internal"],UT=[,"compatibility","core"],Hv={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"},BT=[,"low-power","high-performance"],FT=[,"occlusion","timestamp"],jT={undefined:1,unknown:1,destroyed:2};function GT(u,d,h,g,b,M){d=Et(d),h=Et(h),g>>>=0,b>>>=0,M>>>=0;var I=ne(u>>>0);if(u={},M){var L=(v(),C)[M+12>>>2>>>0];if(L){var F=(v(),C)[M+16>>>2>>>0];u.requiredFeatures=Array.from((v(),C).subarray(F>>>2>>>0,F+4*L>>>2>>>0),oe=>Hv[oe])}var Y=(v(),C)[M+20>>>2>>>0];if(Y){let oe=function(Mt,lt,As=!1){lt=Y+lt,(lt=(v(),C)[lt>>>2>>>0])==4294967295||As&<==0||(Fe[Mt]=lt)},it=function(Mt,lt){lt=Y+lt;var As=(v(),C)[lt>>>2>>>0],_I=(v(),C)[lt+4>>>2>>>0];As==4294967295&&_I==4294967295||(Fe[Mt]=rl(lt))};var Oe=oe,Ne=it,Fe={};oe("maxTextureDimension1D",4),oe("maxTextureDimension2D",8),oe("maxTextureDimension3D",12),oe("maxTextureArrayLayers",16),oe("maxBindGroups",20),oe("maxBindGroupsPlusVertexBuffers",24),oe("maxDynamicUniformBuffersPerPipelineLayout",32),oe("maxDynamicStorageBuffersPerPipelineLayout",36),oe("maxSampledTexturesPerShaderStage",40),oe("maxSamplersPerShaderStage",44),oe("maxStorageBuffersPerShaderStage",48),oe("maxStorageTexturesPerShaderStage",52),oe("maxUniformBuffersPerShaderStage",56),oe("minUniformBufferOffsetAlignment",80),oe("minStorageBufferOffsetAlignment",84),it("maxUniformBufferBindingSize",64),it("maxStorageBufferBindingSize",72),oe("maxVertexBuffers",88),it("maxBufferSize",96),oe("maxVertexAttributes",104),oe("maxVertexBufferArrayStride",108),oe("maxInterStageShaderVariables",112),oe("maxColorAttachments",116),oe("maxColorAttachmentBytesPerSample",120),oe("maxComputeWorkgroupStorageSize",124),oe("maxComputeInvocationsPerWorkgroup",128),oe("maxComputeWorkgroupSizeX",132),oe("maxComputeWorkgroupSizeY",136),oe("maxComputeWorkgroupSizeZ",140),oe("maxComputeWorkgroupsPerDimension",144),oe("maxImmediateSize",148,!0),u.requiredLimits=Fe}(L=(v(),C)[M+24>>>2>>>0])&&(L={label:wr(L+4)},u.defaultQueue=L),u.label=wr(M+4)}Te+=1,Sn(d,I.requestDevice(u).then(oe=>{--Te,At(()=>{mt[b>>>0]=oe.queue,mt[g>>>0]=oe,Te+=1,Sn(h,oe.lost.then(it=>{At(()=>{oe.onuncapturederror=()=>{};var Mt=ce(),lt=ir(it.message);J0(h,jT[it.reason],lt),le(Mt)}),--Te})),oe.onuncapturederror=it=>{var Mt=5;it.error instanceof GPUValidationError?Mt=2:it.error instanceof GPUOutOfMemoryError?Mt=3:it.error instanceof GPUInternalError&&(Mt=4);var lt=ce();it=ir(it.error.message),_k(g,Mt,it),le(lt)},"adapterInfo"in oe||(oe.adapterInfo=I.info),tb(d,1,g,0)})},oe=>{--Te,At(()=>{var it=ce(),Mt=ir(oe.message);tb(d,3,g,Mt),h&&J0(h,4,Mt),le(it)})}))}function qT(u){var d=ne(u>>>=0),h=gr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete gr[u]}d.destroy()}function WT(u,d,h){h>>>=0;var g=ne(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(d>>>0,h)}catch{return 0}var M=nb(16,b.byteLength);return(v(),H).set(new Uint8Array(b),M>>>0),gr[u].push(()=>Ht(M)),M}function VT(u,d,h){h>>>=0;var g=ne(u>>>=0);h==4294967295&&(h=void 0);try{var b=g.getMappedRange(d>>>0,h)}catch{return 0}var M=nb(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)),Ht(M)}),M}function HT(u,d,h,g,b){u>>>=0,d=Et(d),h=Et(h),b>>>=0;var M=ne(u);gr[u]=[],b==4294967295&&(b=void 0),Te+=1,Sn(d,M.mapAsync(h,g>>>0,b).then(()=>{--Te,At(()=>{Z0(d,1,0)})},I=>{--Te,At(()=>{ce();var L=ir(I.message);Z0(d,I.name==="AbortError"?4:I.name==="OperationError"?3:0,L),delete gr[u]})}))}function XT(u){var d=ne(u>>>=0),h=gr[u];if(h){for(var g=0;g<h.length;++g)h[g]();delete gr[u],d.unmap()}}function KT(u){delete mt[u>>>0]}function YT(u,d,h){u>>>=0,d>>>=0,h>>>=0;var g=!!(v(),C)[d+32>>>2>>>0];d={label:wr(d+4),usage:(v(),C)[d+16>>>2>>>0],size:rl(d+24),mappedAtCreation:g},u=ne(u);try{var b=u.createBuffer(d)}catch{return!1}return mt[h>>>0]=b,g&&(gr[h]=[]),!0}function QT(u,d,h,g){u>>>=0,d=Et(d),g>>>=0,h=RT(h>>>0),u=ne(u),Te+=1,Sn(d,u.createComputePipelineAsync(h).then(b=>{--Te,At(()=>{mt[g>>>0]=b,Q0(d,1,g,0)})},b=>{--Te,At(()=>{var M=ce(),I=ir(b.message);Q0(d,b.reason==="validation"?3:b.reason==="internal"?4:0,g,I),le(M)})}))}function JT(u,d,h){u>>>=0,d>>>=0,h>>>=0;var g=(v(),C)[d>>>2>>>0],b=(v(),R)[g+4>>>2>>>0];d={label:wr(d+4),code:""},b===2&&(d.code=Wv(g+8)),u=ne(u).createShaderModule(d),mt[h>>>0]=u}var ZT=u=>{(u=ne(u)).onuncapturederror=null,u.destroy()};function eO(u,d){d=Et(d),u=ne(u>>>0),Te+=1,Sn(d,u.popErrorScope().then(h=>{--Te,At(()=>{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?ir(h.message):0;eb(d,1,g,M),le(b)})},h=>{--Te,At(()=>{var g=ce(),b=ir(h.message);eb(d,1,5,b),le(g)})}))}function tO(u,d,h,g){if(d=Et(d),g>>>=0,h>>>=0){var b={featureLevel:UT[(v(),R)[h+4>>>2>>>0]],powerPreference:BT[(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?(Te+=1,Sn(d,navigator.gpu.requestAdapter(b).then(M=>{--Te,At(()=>{if(M)mt[g>>>0]=M,sl(d,1,g,0);else{var I=ce(),L=ir("WebGPU not available on this browser (requestAdapter returned null)");sl(d,3,g,L),le(I)}})},M=>{--Te,At(()=>{var I=ce(),L=ir(M.message);sl(d,4,g,L),le(I)})}))):(b=ce(),u=ir("WebGPU not available on this browser (navigator.gpu is not available)"),sl(d,3,g,u),le(b))}function rO(u,d,h){return u>>>=0,d>>>=0,h>>>=0,$v(async()=>{var g=[];if(h){var b=(v(),R)[h>>>2>>>0];g.length=d+1,g[d]=new Promise(L=>setTimeout(L,b,0))}else g.length=d;for(var M=0;M<d;++M){var I=rl(u+8*M);if(!(I in Pu))return I;g[M]=Pu[I]}return g=await Promise.race(g),delete Pu[g],g})}var X0,K0={},Xv=()=>{if(!X0){var u,d={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 K0)K0[u]===void 0?delete d[u]:d[u]=K0[u];var h=[];for(u in d)h.push(`${u}=${d[u]}`);X0=h}return X0};function Kv(u,d){if(n)return Be(19,1,u,d);u>>>=0,d>>>=0;var h,g=0,b=0;for(h of Xv()){var M=d+g;(v(),C)[u+b>>>2>>>0]=M,g+=mr(h,M,1/0)+1,b+=4}return 0}function Yv(u,d){if(n)return Be(20,1,u,d);u>>>=0,d>>>=0;var h=Xv();for(var g of((v(),C)[u>>>2>>>0]=h.length,u=0,h))u+=hr(g)+1;return(v(),C)[d>>>2>>>0]=u,0}function Qv(u){return n?Be(21,1,u):52}function Jv(u,d,h,g){return n?Be(22,1,u,d,h,g):52}function Zv(u,d,h,g){return n?Be(23,1,u,d,h,g):70}var sO=[null,[],[]];function ek(u,d,h,g){if(n)return Be(24,1,u,d,h,g);d>>>=0,h>>>=0,g>>>=0;for(var b=0,M=0;M<h;M++){var I=(v(),C)[d>>>2>>>0],L=(v(),C)[d+4>>>2>>>0];d+=8;for(var F=0;F<L;F++){var Y=u,Oe=(v(),H)[I+F>>>0],Ne=sO[Y];Oe===0||Oe===10?((Y===1?T:S)(hv(Ne)),Ne.length=0):Ne.push(Oe)}b+=L}return(v(),C)[g>>>2>>>0]=b,0}function nO(u){return u>>>0}function oO(u,d){return Vv(ne(u>>>0).limits,d>>>0),1}function aO(u,d){return ne(u>>>0).features.has(Hv[d])}function iO(u){return BigInt(ne(u>>>0).size)}function lO(u){return BigInt(ne(u>>>0).usage)}function cO(u,d){if(u>>>=0,d>>>=0){var h=wr(d+4);h={label:h,timestampWrites:d=(d=(v(),C)[d+12>>>2>>>0])!==0?{querySet:ne((v(),C)[d+4>>>2>>>0]),beginningOfPassWriteIndex:(v(),C)[d+8>>>2>>>0],endOfPassWriteIndex:(v(),C)[d+12>>>2>>>0]}:void 0}}return d=ne(u),u=ck(0),h=d.beginComputePass(h),mt[u>>>0]=h,u}function uO(u,d,h,g,b,M){h=Et(h),b=Et(b),M=Et(M),ne(u>>>0).copyBufferToBuffer(ne(d>>>0),h,ne(g>>>0),b,M)}function pO(u){var d=ne(u>>>0);return u=ik(0),d=d.finish(),mt[u>>>0]=d,u}function dO(u,d,h,g,b,M){M=Et(M),ne(u>>>0).resolveQuerySet(ne(d>>>0),h,g,ne(b>>>0),M)}function fO(u,d,h,g){ne(u>>>0).dispatchWorkgroups(d,h,g)}function _O(u,d,h){h=Et(h),ne(u>>>0).dispatchWorkgroupsIndirect(ne(d>>>0),h)}function mO(u){ne(u>>>0).end()}function hO(u,d,h,g,b){g>>>=0,b>>>=0,u=ne(u>>>0),h=ne(h>>>0),g==0?u.setBindGroup(d,h):u.setBindGroup(d,h,(v(),C),b>>>2,g)}function gO(u,d){ne(u>>>0).setPipeline(ne(d>>>0))}function wO(u,d,h){ne(u>>>0).Ee(ne(d>>>0),h)}function xO(u,d){var h=ne(u>>>0);return u=ak(0),d=h.getBindGroupLayout(d),mt[u>>>0]=d,u}function yO(u,d){function h(b){var M=(v(),C)[b+8>>>2>>>0],I=(v(),C)[b+32>>>2>>>0],L=(v(),C)[b+36>>>2>>>0],F=0;return $T(b,{327681:Y=>{F=(v(),C)[Y+8>>>2>>>0]}}),M?((I=rl(b+24))==-1&&(I=void 0),M={buffer:ne(M),offset:rl(b+16),size:I}):M=ne(I||L||F),{binding:(v(),C)[b+4>>>2>>>0],resource:M}}u>>>=0,d={label:wr(4+(d>>>=0)),layout:ne((v(),C)[d+12>>>2>>>0]),entries:(function(b,M){for(var I=[],L=0;L<b;++L)I.push(h(M+40*L));return I})((v(),C)[d+16>>>2>>>0],(v(),C)[d+20>>>2>>>0])},u=ne(u);var g=ok(0);return NT(g,u.createBindGroup(d)),g}function bO(u,d){var h;return u>>>=0,(d>>>=0)&&(h={label:wr(d+4)}),d=ne(u),u=lk(0),h=d.createCommandEncoder(h),mt[u>>>0]=h,u}function vO(u,d){u>>>=0,d>>>=0,d={type:FT[(v(),R)[d+12>>>2>>>0]],count:(v(),C)[d+16>>>2>>>0]};var h=ne(u);return u=uk(0),d=h.createQuerySet(d),mt[u>>>0]=d,u}function kO(u,d){u=ne(u>>>0).adapterInfo,d>>>=0,(v(),C)[d+52>>>2>>>0]=u.subgroupMinSize,(v(),C)[d+56>>>2>>>0]=u.subgroupMaxSize;var h=u.vendor+u.architecture+u.device+u.description,g=hr(h)+1,b=Tn(g);return b&&mr(h,b,g),h=b,g=hr(u.vendor),zu(d+4,h,g),h+=g,g=hr(u.architecture),zu(d+12,h,g),h+=g,g=hr(u.device),zu(d+20,h,g),zu(d+28,h+g,hr(u.description)),(v(),R)[d+36>>>2>>>0]=2,u=u.isFallbackAdapter?3:4,(v(),R)[d+40>>>2>>>0]=u,(v(),C)[d+44>>>2>>>0]=0,(v(),C)[d+48>>>2>>>0]=0,1}var EO={"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 AO(u,d){d>>>=0;var h=ne(u>>>0);u=Tn(4*h.features.size);var g=0,b=0;for(let M of h.features)0<=(h=EO[M])&&((v(),R)[u+g>>>2>>>0]=h,g+=4,b++);(v(),C)[d+4>>>2>>>0]=u,(v(),C)[d>>>2>>>0]=b}function MO(u,d){return Vv(ne(u>>>0).limits,d>>>0),1}function SO(u,d){ne(u>>>0).pushErrorScope(DT[d])}function TO(u,d,h){d>>>=0,h>>>=0,u=ne(u>>>0),d=Array.from((v(),R).subarray(h>>>2>>>0,h+4*d>>>2>>>0),g=>ne(g)),u.submit(d)}function OO(u,d,h,g,b){h=Et(h),g>>>=0,b>>>=0,u=ne(u>>>0),d=ne(d>>>0),g=(v(),H).subarray(g>>>0,g+b>>>0),u.writeBuffer(d,h,g,0,b)}n||(function(){for(var u=e.numThreads-1;u--;)cv();Ue.push(async()=>{var d=(async function(){if(!n)return Promise.all(jr.map(lv))})();Se++,await d,--Se==0&&et&&(d=et,et=null,d())})})(),n||(Gr=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),xe()),e.wasmBinary&&(f=e.wasmBinary),e.stackSave=()=>ce(),e.stackRestore=u=>le(u),e.stackAlloc=u=>Nu(u),e.setValue=function(u,d,h="i8"){switch(h.endsWith("*")&&(h="*"),h){case"i1":case"i8":(v(),B)[u>>>0]=d;break;case"i16":(v(),G)[u>>>1>>>0]=d;break;case"i32":(v(),R)[u>>>2>>>0]=d;break;case"i64":(v(),z)[u>>>3>>>0]=BigInt(d);break;case"float":(v(),re)[u>>>2>>>0]=d;break;case"double":(v(),ae)[u>>>3>>>0]=d;break;case"*":(v(),C)[u>>>2>>>0]=d;break;default:Ve(`invalid type for setValue: ${h}`)}},e.getValue=function(u,d="i8"){switch(d.endsWith("*")&&(d="*"),d){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(),z)[u>>>3>>>0];case"float":return(v(),re)[u>>>2>>>0];case"double":return(v(),ae)[u>>>3>>>0];case"*":return(v(),C)[u>>>2>>>0];default:Ve(`invalid type for getValue: ${d}`)}},e.UTF8ToString=An,e.stringToUTF8=mr,e.lengthBytesUTF8=hr;var tk,rk,Y0,Lu,Ht,Tn,sk,nk,ok,ak,ik,lk,ck,uk,pk,dk,fk,Q0,J0,Z0,eb,sl,tb,_k,rb,mk,hk,gk,sb,wk,xk,nb,we,nl,yk,le,Nu,ce,bk,ob,vk,kk,Ek,ab,Ak,Mk,Sk,Tk,Ok,Ik,Ck,Pk,zk,Lk,Nk,$k,Rk,Dk,Uk,Bk,Fk,jk,Gk,qk,Wk,Vk,Hk,Xk,Kk,Yk,Qk,Jk,Zk,eE,tE,rE,sE,nE,oE,aE,iE,lE,cE,xr,IO=[vn,Zi,dv,gv,wv,xv,yv,bv,vv,kv,Ev,Av,Mv,Sv,Tv,Ov,Fv,jv,Gv,Kv,Yv,Qv,Jv,Zv,ek],ib={937012:(u,d,h,g,b)=>{if(e===void 0||!e.Uc)return 1;if((u=An(Number(u>>>0))).startsWith("./")&&(u=u.substring(2)),!(u=e.Uc.get(u)))return 2;if(d=Number(d>>>0),h=Number(h>>>0),g=Number(g>>>0),d+h>u.byteLength)return 3;try{let M=u.subarray(d,d+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}},937836:(u,d,h)=>{e.Sd(u,(v(),H).subarray(d>>>0,d+h>>>0))},937900:()=>e.me(),937942:u=>{e.jd(u)},937979:()=>typeof wasmOffsetConverter<"u"};function CO(u,d,h,g){var b=ce();try{return Pk(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function PO(u,d,h){var g=ce();try{return Ok(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function zO(u){var d=ce();try{Ak(u)}catch(h){if(le(d),h!==h+0)throw h;we(1,0)}}function LO(u,d){var h=ce();try{return ab(u,d)}catch(g){if(le(h),g!==g+0)throw g;we(1,0)}}function NO(u,d,h){var g=ce();try{Ek(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function $O(u,d){var h=ce();try{zk(u,d)}catch(g){if(le(h),g!==g+0)throw g;we(1,0)}}function RO(u,d,h,g,b,M,I){var L=ce();try{return Tk(u,d,h,g,b,M,I)}catch(F){if(le(L),F!==F+0)throw F;we(1,0)}}function DO(u,d,h,g,b,M){var I=ce();try{Mk(u,d,h,g,b,M)}catch(L){if(le(I),L!==L+0)throw L;we(1,0)}}function UO(u,d,h,g){var b=ce();try{Ck(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function BO(u,d,h,g,b,M,I){var L=ce();try{Nk(u,d,h,g,b,M,I)}catch(F){if(le(L),F!==F+0)throw F;we(1,0)}}function FO(u,d,h,g,b,M,I){var L=ce();try{$k(u,d,h,g,b,M,I)}catch(F){if(le(L),F!==F+0)throw F;we(1,0)}}function jO(u,d,h,g,b,M,I,L){var F=ce();try{Wk(u,d,h,g,b,M,I,L)}catch(Y){if(le(F),Y!==Y+0)throw Y;we(1,0)}}function GO(u,d,h,g,b,M,I,L,F,Y,Oe,Ne){var Fe=ce();try{Rk(u,d,h,g,b,M,I,L,F,Y,Oe,Ne)}catch(oe){if(le(Fe),oe!==oe+0)throw oe;we(1,0)}}function qO(u,d,h,g,b){var M=ce();try{return Lk(u,d,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function WO(u,d,h,g,b){var M=ce();try{Sk(u,d,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function VO(u,d,h,g,b,M,I,L){var F=ce();try{Ik(u,d,h,g,b,M,I,L)}catch(Y){if(le(F),Y!==Y+0)throw Y;we(1,0)}}function HO(u){var d=ce();try{return Vk(u)}catch(h){if(le(d),h!==h+0)throw h;we(1,0)}}function XO(u,d,h){var g=ce();try{return Hk(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function KO(u,d){var h=ce();try{return oE(u,d)}catch(g){if(le(h),g!==g+0)throw g;return we(1,0),0n}}function YO(u,d,h,g,b){var M=ce();try{Xk(u,d,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function QO(u){var d=ce();try{return Dk(u)}catch(h){if(le(d),h!==h+0)throw h;return we(1,0),0n}}function JO(u,d,h,g,b,M){var I=ce();try{return Gk(u,d,h,g,b,M)}catch(L){if(le(I),L!==L+0)throw L;we(1,0)}}function ZO(u,d,h,g,b,M){var I=ce();try{return Kk(u,d,h,g,b,M)}catch(L){if(le(I),L!==L+0)throw L;we(1,0)}}function eI(u,d,h,g,b,M){var I=ce();try{return Yk(u,d,h,g,b,M)}catch(L){if(le(I),L!==L+0)throw L;we(1,0)}}function tI(u,d,h,g,b,M,I,L){var F=ce();try{return qk(u,d,h,g,b,M,I,L)}catch(Y){if(le(F),Y!==Y+0)throw Y;we(1,0)}}function rI(u,d,h,g,b){var M=ce();try{return Qk(u,d,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;return we(1,0),0n}}function sI(u,d,h,g){var b=ce();try{return Jk(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function nI(u,d,h,g){var b=ce();try{return Zk(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function oI(u,d,h,g,b,M,I,L,F,Y,Oe,Ne){var Fe=ce();try{return eE(u,d,h,g,b,M,I,L,F,Y,Oe,Ne)}catch(oe){if(le(Fe),oe!==oe+0)throw oe;we(1,0)}}function aI(u,d,h,g,b,M,I,L,F,Y,Oe){var Ne=ce();try{tE(u,d,h,g,b,M,I,L,F,Y,Oe)}catch(Fe){if(le(Ne),Fe!==Fe+0)throw Fe;we(1,0)}}function iI(u,d,h,g,b,M,I,L,F,Y,Oe,Ne,Fe,oe,it,Mt){var lt=ce();try{rE(u,d,h,g,b,M,I,L,F,Y,Oe,Ne,Fe,oe,it,Mt)}catch(As){if(le(lt),As!==As+0)throw As;we(1,0)}}function lI(u,d,h,g){var b=ce();try{return sE(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function cI(u,d,h,g,b){var M=ce();try{return nE(u,d,h,g,b)}catch(I){if(le(M),I!==I+0)throw I;we(1,0)}}function uI(u,d,h){var g=ce();try{return Bk(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;return we(1,0),0n}}function pI(u,d,h){var g=ce();try{return Uk(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function dI(u,d,h){var g=ce();try{return Fk(u,d,h)}catch(b){if(le(g),b!==b+0)throw b;we(1,0)}}function fI(u,d,h,g){var b=ce();try{jk(u,d,h,g)}catch(M){if(le(b),M!==M+0)throw M;we(1,0)}}function $u(){if(0<Se)et=$u;else if(n)w?.(e),ue();else{for(var u=Ue;0<u.length;)u.shift()(e);0<Se?et=$u:(e.calledRun=!0,P||(ue(),w?.(e)))}}return n||(xr=await _t(),$u()),e.PTR_SIZE=4,e.webgpuInit=u=>{let d=new WeakMap,h,g,b=1;e.webgpuRegisterDevice=L=>{if(g!==void 0)throw Error("another WebGPU EP inference session is being created.");if(L){var F=d.get(L);if(!F){let Y=((Oe,Ne=0)=>{var Fe=fk(Ne);return Ne=dk(Ne,Fe),mt[Fe>>>0]=Oe.queue,mt[Ne>>>0]=Oe,Ne})(L,F=nk(0));F=[b++,F,Y],d.set(L,F)}return h=L,g=F[0],F}h=void 0,g=0};let M=new Map;e.webgpuOnCreateSession=L=>{if(g!==void 0){var F=g;if(g=void 0,L){let Y=Y0(F);M.set(L,Y),F===0&&u(h??ne(Y))}h=void 0}},e.webgpuOnReleaseSession=L=>{M.delete(L)};let I=Symbol("gpuBufferMetadata");e.webgpuRegisterBuffer=(L,F,Y)=>{if(Y)return L[I]=[Y,NaN],Y;if(Y=L[I])return Y[1]++,Y[0];if((F=M.get(F))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");return F=((Oe,Ne=0)=>(Oe.mapState==="unmapped"||Ve(),Ne=pk(Ne),mt[Ne>>>0]=Oe,Ne))(L,F),L[I]=[F,1],F},e.webgpuUnregisterBuffer=L=>{let F=L[I];if(!F)throw Error("Buffer is not registered");F[1]--,F[1]===0&&(sk(F[0]),delete L[I])},e.webgpuGetBuffer=L=>ne(L),e.webgpuCreateDownloader=(L,F,Y)=>{if((Y=M.get(Y))===void 0)throw Error("Invalid session handle passed to webgpuRegisterBuffer");let Oe=ne(Y),Ne=16*Math.ceil(Number(F)/16);return async()=>{let Fe=Oe.createBuffer({size:Ne,usage:9});try{let oe=Oe.createCommandEncoder();return oe.copyBufferToBuffer(L,0,Fe,0,Ne),Oe.queue.submit([oe.finish()]),await Fe.mapAsync(GPUMapMode.READ),Fe.getMappedRange().slice(0,F)}finally{Fe.destroy()}}},e.ad=(L,F)=>{var Y=F.buffer;let Oe=F.byteOffset,Ne=F.byteLength;if(F=16*Math.ceil(Number(Ne)/16),L=ne(L),!h){var Fe=Y0(g);h=ne(Fe)}let oe=(Fe=h.createBuffer({mappedAtCreation:!0,size:F,usage:6})).getMappedRange();new Uint8Array(oe).set(new Uint8Array(Y,Oe,Ne)),Fe.unmap(),(Y=h.createCommandEncoder()).copyBufferToBuffer(Fe,0,L,0,F),h.queue.submit([Y.finish()]),Fe.destroy()}},e.webnnInit=u=>{let d=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=>d.onRunStart(h),e.webnnOnRunEnd=d.onRunEnd.bind(d),e.webnnOnReleaseSession=h=>{d.onReleaseSession(h)},e.webnnCreateMLTensorDownloader=(h,g)=>d.createMLTensorDownloader(h,g),e.webnnRegisterMLTensor=(h,g,b,M)=>d.registerMLTensor(h,g,b,M),e.webnnCreateMLContext=h=>d.createMLContext(h),e.webnnRegisterMLConstant=(h,g,b,M,I,L)=>d.registerMLConstant(h,g,b,M,I,e.Uc,L),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)},J?e:new Promise((u,d)=>{w=u,x=d})}var u2,gA,dL=be(()=>{"use strict";u2=hA,gA=globalThis.self?.name?.startsWith("em-pthread"),gA&&hA()}),Cb,Hb,wA,Ct,p2,Zu,xA,yA,Pb,bA,zb,d2,Lb,f2,r1=be(()=>{"use strict";t1(),Cb=typeof location>"u"?void 0:location.origin,Hb=Zt.url>"file:"&&Zt.url<"file;",wA=()=>{if(Hb){let t=URL;return new URL(new t("ort.webgpu.bundle.min.mjs",Zt.url).href,Cb).href}return Zt.url},Ct=wA(),p2=()=>{if(Ct&&!Ct.startsWith("blob:"))return Ct.substring(0,Ct.lastIndexOf("/")+1)},Zu=(t,e)=>{try{let r=e??Ct;return(r?new URL(t,r):new URL(t)).origin===Cb}catch{return!1}},xA=(t,e)=>{let r=e??Ct;try{return(r?new URL(t,r):new URL(t)).href}catch{return}},yA=(t,e)=>`${e??"./"}${t}`,Pb=async t=>{let e=await(await fetch(t,{credentials:"same-origin"})).blob();return URL.createObjectURL(e)},bA=async t=>(await import(t)).default,zb=(pL(),op(i2)).default,d2=async()=>{if(!Ct)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Zu(Ct))return[void 0,zb()];let t=await Pb(Ct);return[t,zb(t)]},Lb=(dL(),op(c2)).default,f2=async(t,e,r,s)=>{let n=Lb&&!(t||e);if(n)if(Ct)n=Zu(Ct)||s&&!r;else if(s&&!r)n=!0;else throw new Error("cannot determine the script source URL.");if(n)return[void 0,Lb];{let o="ort-wasm-simd-threaded.asyncify.mjs",a=t??xA(o,e),i=r&&a&&!Zu(a,e),l=i?await Pb(a):a??yA(o,e);return[i?l:void 0,await bA(l)]}}}),Nb,ep,hl,$b,vA,kA,EA,s1,De,Bs=be(()=>{"use strict";r1(),ep=!1,hl=!1,$b=!1,vA=()=>{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}},kA=()=>{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}},EA=()=>{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}},s1=async t=>{if(ep)return Promise.resolve();if(hl)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if($b)throw new Error("previous call to 'initializeWebAssembly()' failed.");hl=!0;let e=t.initTimeout,r=t.numThreads;if(t.simd!==!1){if(t.simd==="relaxed"){if(!EA())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!kA())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let s=vA();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,[f,_]=await f2(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,k)=>{let E={numThreads:r};if(p)E.wasmBinary=p,E.locateFile=A=>A;else if(c||o)E.locateFile=A=>c??o+A;else if(i&&i.indexOf("blob:")!==0)E.locateFile=A=>new URL(A,i).href;else if(f){let A=p2();A&&(E.locateFile=T=>A+T)}_(E).then(A=>{hl=!1,ep=!0,Nb=A,x(),f&&URL.revokeObjectURL(f)},A=>{hl=!1,$b=!0,k(A)})})),await Promise.race(w),m)throw new Error(`WebAssembly backend initializing failed due to timeout: ${e}ms`)},De=()=>{if(ep&&Nb)return Nb;throw new Error("WebAssembly is not initialized yet.")}}),Pt,ip,ze,n1=be(()=>{"use strict";Bs(),Pt=(t,e)=>{let r=De(),s=r.lengthBytesUTF8(t)+1,n=r._malloc(s);return r.stringToUTF8(t,n,s),e.push(n),n},ip=(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")ip(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}`)})},ze=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)}}}),_2,fL=be(()=>{"use strict";Bs(),n1(),_2=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=Pt(t.tag,s)),r=e._OrtCreateRunOptions(n.logSeverityLevel,n.logVerbosityLevel,!!n.terminate,o),r===0&&ze("Can't create run options."),t?.extra!==void 0&&ip(t.extra,"",new WeakSet,(a,i)=>{let l=Pt(a,s),c=Pt(i,s);e._OrtAddRunConfigEntry(r,l,c)!==0&&ze(`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}}}),AA,MA,SA,tp,Jr,TA,m2,_L=be(()=>{"use strict";Bs(),n1(),AA=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}`)}},MA=t=>{switch(t){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${t}`)}},SA=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)},tp=(t,e,r,s)=>{let n=Pt(e,s),o=Pt(r,s);De()._OrtAddSessionConfigEntry(t,n,o)!==0&&ze(`Can't set a session config entry: ${e} - ${r}.`)},Jr=(t,e,r,s)=>{let n=Pt(e,s),o=Pt(r,s);t.push([n,o])},TA=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&&tp(t,"deviceType",f,r)}break;case"webgpu":{o="WebGPU";let f;if(typeof n!="string"){let m=n;if(m.device)if(typeof GPUDevice<"u"&&m.device instanceof GPUDevice)f=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(f);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=Pt(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 f=0;f<l;f++)De().setValue(c+f*De().PTR_SIZE,a[f][0],"*"),De().setValue(p+f*De().PTR_SIZE,a[f][1],"*")}await De()._OrtAppendExecutionProvider(t,i,c,p,l)!==0&&ze(`Can't append execution provider: ${o}.`)}},m2=async t=>{let e=De(),r=0,s=[],n=t||{};SA(n);try{let o=AA(n.graphOptimizationLevel??"all"),a=MA(n.executionMode??"sequential"),i=typeof n.logId=="string"?Pt(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"?Pt(n.optimizedModelFilePath,s):0;if(r=e._OrtCreateSessionOptions(o,!!n.enableCpuMemArena,!!n.enableMemPattern,a,!!n.enableProfiling,0,i,l,c,p),r===0&&ze("Can't create session options."),n.executionProviders&&await TA(r,n,s),n.enableGraphCapture!==void 0){if(typeof n.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${n.enableGraphCapture}`);tp(r,"enableGraphCapture",n.enableGraphCapture.toString(),s)}if(n.freeDimensionOverrides)for(let[f,_]of Object.entries(n.freeDimensionOverrides)){if(typeof f!="string")throw new Error(`free dimension override name must be a string: ${f}`);if(typeof _!="number"||!Number.isInteger(_)||_<0)throw new Error(`free dimension override value must be a non-negative integer: ${_}`);let m=Pt(f,s);e._OrtAddFreeDimensionOverride(r,m,_)!==0&&ze(`Can't set a free dimension override: ${f} - ${_}.`)}return n.extra!==void 0&&ip(n.extra,"",new WeakSet,(f,_)=>{tp(r,f,_,s)}),[r,s]}catch(o){throw r!==0&&e._OrtReleaseSessionOptions(r)!==0&&ze("Can't release session options."),s.forEach(a=>e._free(a)),o}}}),Ns,np,Rn,bl,lp,o1,a1,Xb,Dn=be(()=>{"use strict";Ns=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}`)}},np=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}`)}},Rn=(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},bl=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}`)}},lp=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}`)}},o1=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",a1=t=>t==="float32"||t==="float16"||t==="int32"||t==="int64"||t==="uint32"||t==="uint64"||t==="int8"||t==="uint8"||t==="bool"||t==="uint4"||t==="int4",Xb=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}`)}}}),i1,h2=be(()=>{"use strict";t1(),i1=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)}}),g2,mL=be(()=>{"use strict";Dn(),g2=(t,e)=>new(bl(e))(t)}),OA,IA,CA,PA,w2,zA,bt,x2=be(()=>{"use strict";Dn(),OA=["V","I","W","E","F"],IA=(t,e)=>{console.log(`[${OA[t]},${new Date().toISOString()}]${e}`)},w2=(t,e)=>{CA=t,PA=e},zA=(t,e)=>{let r=lp(t),s=lp(CA);r>=s&&IA(r,typeof e=="function"?e():e)},bt=(...t)=>{PA&&zA(...t)}}),Rb,Kb,Db,LA,Ub,NA,Bb,Fb,jb,$A,y2,hL=be(()=>{"use strict";Dn(),x2(),Rb=new Map([["float32",32],["float16",16],["int32",32],["uint32",32],["int64",64],["uint64",64],["int8",8],["uint8",8],["int4",4],["uint4",4]]),Kb=(t,e)=>{if(e==="int32")return t;let r=Rb.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(bl(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'`)}},Db=(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}`)}},LA=1,Ub=()=>LA++,NA=new Map([["int8","int32"],["uint8","int32"],["uint32","int32"],["int64","int32"]]),Bb=(t,e)=>{let r=Rb.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},Fb=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 Bb(this.dataType,this.tensorShape)}destroy(){bt("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=Db(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}},jb=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=NA.get(e),!a||o?.input.dataTypes.includes(a))throw new Error(`WebNN backend does not support data type: ${e}`);bt("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!==Bb(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=Kb(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 bt("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?Db(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()}},$A=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=Ub();return this.tensorTrackersById.set(t,new jb(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){bt("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){bt("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=Ub(),a=new Fb({sessionId:t,context:n,tensor:e,dataType:r,shape:s});return this.tensorTrackersById.set(o,new jb(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)){bt("verbose",()=>`[WebNN] Reusing tensor {dataType: ${e}, ${a?`fallbackDataType: ${a},`:""} shape: ${r}`);let f=this.freeTensors.splice(c,1)[0];return f.sessionId=t,f}bt("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 Fb({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)}},y2=(...t)=>new $A(...t)}),b2={};vl(b2,{WebNNBackend:()=>v2});var gl,RA,v2,gL=be(()=>{"use strict";Dn(),Bs(),mL(),hL(),x2(),gl=new Map([[1,"float32"],[10,"float16"],[6,"int32"],[12,"uint32"],[7,"int64"],[13,"uint64"],[22,"int4"],[21,"uint4"],[3,"int8"],[2,"uint8"],[9,"uint8"]]),RA=(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])},v2=class{constructor(t){this.tensorManager=y2(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,w2(t.logLevel,!!t.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw new Error("No active session");return this.activeSessionId}onRunStart(t){bt("verbose",()=>`[WebNN] onRunStart {sessionId: ${t}}`),this.activeSessionId=t}onRunEnd(t){bt("verbose",()=>`[WebNN] onRunEnd {sessionId: ${t}}`);let e=this.temporarySessionTensorIds.get(t);if(e){for(let r of e)bt("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=>RA(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){bt("verbose",()=>`[WebNN] releaseTensorId {tensorId: ${t}}`),this.tensorManager.releaseTensorId(t)}async ensureTensor(t,e,r,s,n){let o=gl.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){bt("verbose",()=>`[WebNN] createTemporaryTensor {onnxDataType: ${e}, shape: ${r}}`);let s=gl.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");bt("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 g2(r,e)}}registerMLTensor(t,e,r,s){let n=gl.get(r);if(!n)throw new Error(`Unsupported ONNX data type: ${r}`);let o=this.tensorManager.registerTensor(t,e,n,s);return bt("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 f=Kb(new Uint8Array(c),"int64");p=new Int32Array(f.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 bt("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=gl.get(Ns(e)),n=this.mlOpSupportLimitsBySessionId.get(t);return typeof s>"u"?!1:r?!!n?.input.dataTypes.includes(s):!!n?.output.dataTypes.includes(s)}flush(){}}}),DA,l1,c1,Zr,UA,Gb,cp,u1,p1,qb,d1,f1,_1,k2=be(()=>{"use strict";Us(),fL(),_L(),Dn(),Bs(),n1(),h2(),DA=(t,e)=>{De()._OrtInit(t,e)!==0&&ze("Can't initialize onnxruntime.")},l1=async t=>{DA(t.wasm.numThreads,lp(t.logLevel))},c1=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(gL(),op(b2)).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,UA=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&&ze("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)}},Gb=(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&&ze("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 f=0;f<c;f++){let _=Number(r.getValue(n+8+f*o,"*"));p.push(_!==0?r.UTF8ToString(_):Number(r.getValue(n+8+(f+c)*o,"*")))}return[i,l,p]}finally{r.stackRestore(s),n!==0&&r._OrtFree(n)}},cp=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]},u1=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]=cp(t);let o=0,a=0,i=0,l=[],c=[],p=[];try{if([a,l]=await m2(e),e?.externalData&&n.mountExternalData){let S=[];for(let P of e.externalData){let O=typeof P=="string"?P:P.path;S.push(i1(typeof P=="string"?P:P.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 P=S,O=P?.context,v=P?.gpuDevice,W=P?.deviceType,X=P?.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&&ze("Can't create a session."),n.jsepOnCreateSession?.(),n.currentContext&&(n.webnnRegisterMLContext(o,n.currentContext),n.currentContext=void 0,n.shouldTransferToMLTensor=!0);let[f,_]=UA(o),m=!!e?.enableGraphCapture,w=[],x=[],k=[],E=[],A=[];for(let S=0;S<f;S++){let[P,O,v]=Gb(o,S);P===0&&ze("Can't get an input name."),c.push(P);let W=n.UTF8ToString(P);w.push(W),k.push(O===0?{name:W,isTensor:!1}:{name:W,isTensor:!0,type:np(O),shape:v})}for(let S=0;S<_;S++){let[P,O,v]=Gb(o,S+f);P===0&&ze("Can't get an output name."),p.push(P);let W=n.UTF8ToString(P);x.push(W),E.push(O===0?{name:W,isTensor:!1}:{name:W,isTensor:!0,type:np(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&&ze("Can't create IO binding."),T={handle:i,outputPreferredLocations:A,outputPreferredLocationsEncoded:A.map(S=>S==="ml-tensor-cpu-output"?"ml-tensor":S).map(S=>Xb(S))}),Zr.set(o,[o,c,p,T,m,!1]),[o,w,x,k,E]}catch(f){throw c.forEach(_=>n._OrtFree(_)),p.forEach(_=>n._OrtFree(_)),i!==0&&n._OrtReleaseBinding(i)!==0&&ze("Can't release IO binding."),o!==0&&n._OrtReleaseSession(o)!==0&&ze("Can't release session."),f}finally{n._free(r),a!==0&&n._OrtReleaseSessionOptions(a)!==0&&ze("Can't release session options."),l.forEach(f=>n._free(f)),n.unmountExternalData?.()}},p1=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&&ze("Can't clear bound outputs."),e._OrtReleaseBinding(a.handle)!==0&&ze("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&&ze("Can't release session."),Zr.delete(t)},qb=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],f=t[3],_=f,m,w;if(c==="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=Rn(Ns(c),p);{let A=i.webgpuRegisterBuffer;if(!A)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');m=A(E,s)}}else if(f==="ml-tensor"){let E=t[2].mlTensor;w=Rn(Ns(c),p);let A=i.webnnRegisterMLTensor;if(!A)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');m=A(s,E,Ns(c),p)}else{let E=t[2];if(Array.isArray(E)){w=l*E.length,m=i._malloc(w),r.push(m);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(m+A*l,Pt(E[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 P=Ns(c);w=Rn(P,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,P,p);v(W,new Uint8Array(E.buffer,E.byteOffset,E.byteLength)),m=W}else w=E.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),m)}else w=E.byteLength,m=i._malloc(w),r.push(m),i.HEAPU8.set(new Uint8Array(E.buffer,E.byteOffset,w),m)}}let x=i.stackSave(),k=i.stackAlloc(4*p.length);try{p.forEach((A,T)=>i.setValue(k+T*l,A,l===4?"i32":"i64"));let E=i._OrtCreateTensor(Ns(c),m,w,k,p.length,Xb(_));E===0&&ze(`Can't create tensor for input/output. session=${s}, index=${o}.`),e.push(E)}finally{i.stackRestore(x)}},d1=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],f=l[2],_=l[3],m=l[4],w=l[5],x=e.length,k=s.length,E=0,A=[],T=[],S=[],P=[],O=[],v=a.stackSave(),W=a.stackAlloc(x*i),X=a.stackAlloc(x*i),B=a.stackAlloc(k*i),H=a.stackAlloc(k*i);try{[E,A]=_2(o),ts("wasm prepareInputOutputTensor");for(let C=0;C<x;C++)await qb(r[C],T,P,t,p[e[C]],e[C],m);for(let C=0;C<k;C++)await qb(n[C],S,P,t,f[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<k;C++)a.setValue(B+C*i,S[C],"*"),a.setValue(H+C*i,f[s[C]],"*");if(_&&!w){let{handle:C,outputPreferredLocations:re,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 z=0;z<x;z++){let $=e[z];await a._OrtBindInput(C,p[$],T[z])!==0&&ze(`Can't bind input[${z}] for session=${t}.`)}for(let z=0;z<k;z++){let $=s[z];n[z]?.[3]?(O.push(S[z]),a._OrtBindOutput(C,f[$],S[z],0)!==0&&ze(`Can't bind pre-allocated output[${z}] for session=${t}.`)):a._OrtBindOutput(C,f[$],0,ae[$])!==0&&ze(`Can't bind output[${z}] to ${re[z]} for session=${t}.`)}rs("wasm bindInputsOutputs"),Zr.set(t,[c,p,f,_,m,!0])}a.jsepOnRunStart?.(c),a.webnnOnRunStart?.(c);let G;_?G=await a._OrtRunWithBinding(c,_.handle,k,B,E):G=await a._OrtRun(c,X,W,x,H,k,B,E),G!==0&&ze("failed to call OrtRun().");let K=[],R=[];ts("wasm ProcessOutputTensor");for(let C=0;C<k;C++){let re=Number(a.getValue(B+C*i,"*"));if(re===S[C]||O.includes(S[C])){K.push(n[C]),re!==S[C]&&a._OrtReleaseTensor(re)!==0&&ze("Can't release tensor.");continue}let ae=a.stackSave(),z=a.stackAlloc(4*i),$=!1,U,J=0;try{a._OrtGetTensorData(re,z,z+i,z+2*i,z+3*i)!==0&&ze(`Can't access output tensor data on index ${C}.`);let xe=i===4?"i32":"i64",ue=Number(a.getValue(z,xe));J=a.getValue(z+i,"*");let Ve=a.getValue(z+i*2,"*"),ot=Number(a.getValue(z+i*3,xe)),_t=[];for(let Ue=0;Ue<ot;Ue++)_t.push(Number(a.getValue(Ve+Ue*i,xe)));a._OrtFree(Ve)!==0&&ze("Can't free memory for tensor dims.");let at=_t.reduce((Ue,Se)=>Ue*Se,1);U=np(ue);let kt=_?.outputPreferredLocations[s[C]];if(U==="string"){if(kt==="gpu-buffer"||kt==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let Ue=[];for(let Se=0;Se<at;Se++){let et=a.getValue(J+Se*i,"*"),nr=a.getValue(J+(Se+1)*i,"*"),Te=Se===at-1?void 0:nr-et;Ue.push(a.UTF8ToString(et,Te))}K.push([U,_t,Ue,"cpu"])}else if(kt==="gpu-buffer"&&at>0){let Ue=a.webgpuGetBuffer;if(!Ue)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Se=Ue(J),et=Rn(ue,at);if(et===void 0||!o1(U))throw new Error(`Unsupported data type: ${U}`);$=!0;{a.webgpuRegisterBuffer(Se,t,J);let nr=a.webgpuCreateDownloader(Se,et,t);K.push([U,_t,{gpuBuffer:Se,download:async()=>{let Te=await nr();return new(bl(U))(Te)},dispose:()=>{a._OrtReleaseTensor(re)!==0&&ze("Can't release tensor.")}},"gpu-buffer"])}}else if(kt==="ml-tensor"&&at>0){let Ue=a.webnnEnsureTensor,Se=a.webnnIsGraphInputOutputTypeSupported;if(!Ue||!Se)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Rn(ue,at)===void 0||!a1(U))throw new Error(`Unsupported data type: ${U}`);if(!Se(t,U,!1))throw new Error(`preferredLocation "ml-tensor" for ${U} output is not supported by current WebNN Context.`);let et=await Ue(t,J,ue,_t,!1);$=!0,K.push([U,_t,{mlTensor:et,download:a.webnnCreateMLTensorDownloader(J,U),dispose:()=>{a.webnnReleaseTensorId(J),a._OrtReleaseTensor(re)}},"ml-tensor"])}else if(kt==="ml-tensor-cpu-output"&&at>0){let Ue=a.webnnCreateMLTensorDownloader(J,U)(),Se=K.length;$=!0,R.push((async()=>{let et=[Se,await Ue];return a.webnnReleaseTensorId(J),a._OrtReleaseTensor(re),et})()),K.push([U,_t,[],"cpu"])}else{let Ue=bl(U),Se=new Ue(at);new Uint8Array(Se.buffer,Se.byteOffset,Se.byteLength).set(a.HEAPU8.subarray(J,J+Se.byteLength)),K.push([U,_t,Se,"cpu"])}}finally{a.stackRestore(ae),U==="string"&&J&&a._free(J),$||a._OrtReleaseTensor(re)}}_&&!m&&(a._OrtClearBoundOutputs(_.handle)!==0&&ze("Can't clear bound outputs."),Zr.set(t,[c,p,f,_,m,!1]));for(let[C,re]of await Promise.all(R))K[C][2]=re;return rs("wasm ProcessOutputTensor"),K}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)),P.forEach(G=>a._free(G)),E!==0&&a._OrtReleaseRunOptions(E),A.forEach(G=>a._free(G))}},f1=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&&ze("Can't get an profile file name."),e._OrtFree(n)},_1=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,Ft,$n,wl,xl,rp,Wb,sp,Ps,zs,BA,E2,A2,M2,S2,T2,O2,I2,C2=be(()=>{"use strict";Us(),k2(),Bs(),r1(),es=()=>!!Xe.wasm.proxy&&typeof document<"u",$n=!1,wl=!1,xl=!1,sp=new Map,Ps=(t,e)=>{let r=sp.get(t);r?r.push(e):sp.set(t,[e])},zs=()=>{if($n||!wl||xl||!Ft)throw new Error("worker not ready")},BA=t=>{switch(t.data.type){case"init-wasm":$n=!1,t.data.err?(xl=!0,Wb[1](t.data.err)):(wl=!0,Wb[0]()),rp&&(URL.revokeObjectURL(rp),rp=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let e=sp.get(t.data.type);t.data.err?e.shift()[1](t.data.err):e.shift()[0](t.data.out);break}default:}},E2=async()=>{if(!wl){if($n)throw new Error("multiple calls to 'initWasm()' detected.");if(xl)throw new Error("previous call to 'initWasm()' failed.");if($n=!0,es())return new Promise((t,e)=>{Ft?.terminate(),d2().then(([r,s])=>{try{Ft=s,Ft.onerror=o=>e(o),Ft.onmessage=BA,Wb=[t,e];let n={type:"init-wasm",in:Xe};!n.in.wasm.wasmPaths&&(r||Hb)&&(n.in.wasm.wasmPaths={wasm:new URL("ort-wasm-simd-threaded.asyncify.wasm",Zt.url).href}),Ft.postMessage(n),rp=r}catch(n){e(n)}},e)});try{await s1(Xe.wasm),await l1(Xe),wl=!0}catch(t){throw xl=!0,t}finally{$n=!1}}},A2=async t=>{if(es())return zs(),new Promise((e,r)=>{Ps("init-ep",[e,r]);let s={type:"init-ep",in:{epName:t,env:Xe}};Ft.postMessage(s)});await c1(Xe,t)},M2=async t=>es()?(zs(),new Promise((e,r)=>{Ps("copy-from",[e,r]);let s={type:"copy-from",in:{buffer:t}};Ft.postMessage(s,[t.buffer])})):cp(t),S2=async(t,e)=>{if(es()){if(e?.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return zs(),new Promise((r,s)=>{Ps("create",[r,s]);let n={type:"create",in:{model:t,options:{...e}}},o=[];t instanceof Uint8Array&&o.push(t.buffer),Ft.postMessage(n,o)})}else return u1(t,e)},T2=async t=>{if(es())return zs(),new Promise((e,r)=>{Ps("release",[e,r]);let s={type:"release",in:t};Ft.postMessage(s)});p1(t)},O2=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 zs(),new Promise((a,i)=>{Ps("run",[a,i]);let l=r,c={type:"run",in:{sessionId:t,inputIndices:e,inputs:l,outputIndices:s,options:o}};Ft.postMessage(c,_1(l))})}else return d1(t,e,r,s,n,o)},I2=async t=>{if(es())return zs(),new Promise((e,r)=>{Ps("end-profiling",[e,r]);let s={type:"end-profiling",in:t};Ft.postMessage(s)});f1(t)}}),Vb,FA,P2,wL=be(()=>{"use strict";Us(),C2(),Dn(),t1(),h2(),Vb=(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()}`)}},FA=t=>{switch(t[3]){case"cpu":return new er(t[0],t[2],t[1]);case"gpu-buffer":{let e=t[0];if(!o1(e))throw new Error(`not supported data type: ${e} for deserializing GPU tensor`);let{gpuBuffer:r,download:s,dispose:n}=t[2];return er.fromGpuBuffer(r,{dataType:e,dims:t[1],download:s,dispose:n})}case"ml-tensor":{let e=t[0];if(!a1(e))throw new Error(`not supported data type: ${e} for deserializing MLTensor tensor`);let{mlTensor:r,download:s,dispose:n}=t[2];return er.fromMLTensor(r,{dataType:e,dims:t[1],download:s,dispose:n})}default:throw new Error(`invalid data location: ${t[3]}`)}},P2=class{async fetchModelAndCopyToWasmMemory(t){return M2(await i1(t))}async loadModel(t,e){Rs();let r;typeof t=="string"?r=await this.fetchModelAndCopyToWasmMemory(t):r=t,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await S2(r,e),Ds()}async dispose(){return T2(this.sessionId)}async run(t,e,r){Rs();let s=[],n=[];Object.entries(t).forEach(f=>{let _=f[0],m=f[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(f=>{let _=f[0],m=f[1],w=this.outputNames.indexOf(_);if(w===-1)throw new Error(`invalid output '${_}'`);o.push(m),a.push(w)});let i=s.map((f,_)=>Vb(f,()=>`input "${this.inputNames[n[_]]}"`)),l=o.map((f,_)=>f?Vb(f,()=>`output "${this.outputNames[a[_]]}"`):null),c=await O2(this.sessionId,n,i,a,l,r),p={};for(let f=0;f<c.length;f++)p[this.outputNames[a[f]]]=o[f]??FA(c[f]);return Ds(),p}startProfiling(){}endProfiling(){I2(this.sessionId)}}}),z2={};vl(z2,{OnnxruntimeWebAssemblyBackend:()=>Qb,initializeFlags:()=>Yb,wasmBackend:()=>L2});var Yb,Qb,L2,xL=be(()=>{"use strict";Us(),C2(),wL(),Yb=()=>{(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"?Yz("node:os").cpus().length:navigator.hardwareConcurrency;Xe.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},Qb=class{async init(t){Yb(),await E2(),await A2(t)}async createInferenceSessionHandler(t,e){let r=new P2;return await r.loadModel(t,e),r}},L2=new Qb});Us();Us();Us();var yL="1.25.0-dev.20260323-a99aad9d36",bL=a2;{let t=(xL(),op(z2)).wasmBackend;$s("webgpu",t,5),$s("webnn",t,5),$s("cpu",t,10),$s("wasm",t,10)}Object.defineProperty(Xe.versions,"web",{value:yL,enumerable:!0});async function N2(t){let e=t.split("/").pop(),r;try{if(r=await Jt(),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 $2(t){let e=await N2(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 R2(t){if(ie.IS_SERVICE_WORKER_ENV||ie.IS_CHROME_AVAILABLE)return t;let e=await N2(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 g1=require("onnxruntime-common"),kL=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 F2(t){return t<=St.DEBUG?0:t<=St.INFO?2:t<=St.WARNING||t<=St.ERROR?3:4}var EL={0:"verbose",1:"info",2:"warning",3:"error",4:"fatal"},jt=[],h1,Bn,D2=Symbol.for("onnxruntime");if(D2 in globalThis)Bn=globalThis[D2];else if(ie.IS_NODE_ENV){switch(Bn=vL,process.platform){case"win32":jt.push("dml");break;case"linux":process.arch==="x64"&&jt.push("cuda");break;case"darwin":jt.push("coreml");break}jt.push("webgpu"),jt.push("cpu"),h1=["cpu"]}else Bn=m1,ie.IS_WEBNN_AVAILABLE&&jt.push("webnn-npu","webnn-gpu","webnn-cpu","webnn"),ie.IS_WEBGPU_AVAILABLE&&jt.push("webgpu"),jt.push("wasm"),h1=["wasm"];var AL=Bn.InferenceSession;function j2(t=null){if(!t)return h1;switch(t){case"auto":return jt;case"gpu":return jt.filter(e=>["webgpu","cuda","dml","webnn-gpu"].includes(e))}if(jt.includes(t))return[kL[t]??t];throw new Error(`Unsupported device: "${t}". Should be one of: ${jt.join(", ")}.`)}var U2=Promise.resolve(),Un=null;async function ML(){if(Un)return Un;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 Un=Promise.resolve(),Un}return Un=(async()=>{let e=st.wasm.wasmPaths,r=!1;await Promise.all([e.wasm&&!xb(e.wasm)?(async()=>{try{let s=await $2(yb(e.wasm));s&&(st.wasm.wasmBinary=s,r=!0)}catch(s){Z.warn("Failed to pre-load WASM binary:",s)}})():Promise.resolve(),e.mjs&&!xb(e.mjs)?(async()=>{try{let s=await R2(yb(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)})(),Un}async function up(t,e,r){await ML();let s=F2(fe.logLevel??St.WARNING),n=()=>AL.create(t,{logSeverityLevel:s,...e}),o=await(ie.IS_WEB_ENV?U2=U2.then(n):n());return o.config=r,o}var B2=Promise.resolve();async function pp(t,e){let r=()=>t.run(e);return ie.IS_WEB_ENV?B2=B2.then(r):r()}function dp(t){return t instanceof Bn.Tensor}var st=Bn?.env;function kl(){return st?.wasm?.proxy}if(st){let t=function(e){let r=F2(e);st.logLevel=EL[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??St.WARNING),fe.backends.onnx={...st,setLogLevel:t}}var ss=async(t,e,r)=>{let s=await up(new Uint8Array(t),e);return(async n=>{let o=kl(),a=Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(o?c.clone():c).ort_tensor])),i=await pp(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 G2=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"}),w1=ie.IS_NODE_ENV?"cpu":"wasm";function fp(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 (${w1}).`),w1):w1}var V2=(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"}),q2=wt.fp32,W2=Object.freeze({[G2.wasm]:wt.q8}),ns=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 _p(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=W2[r]??q2}else o&&wt.hasOwnProperty(o)?i=o:i=W2[r]??q2;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 dp(e[0])?this.ort_tensor=e[0]:this.ort_tensor=new g1.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 SL(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=pr(f,this.dims[p],p),s.push([f,f+1]);else if(Array.isArray(f)&&f.length===2){let[_,m]=f;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: ${f}`);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: ${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(),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],f=s[0][1]*l[0];if(ArrayBuffer.isView(a))i.set(a.subarray(p,f));else if(Array.isArray(a)){let _=a.slice(p,f);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 f=0;for(let _=n.length-1,m=p;_>=0;--_){let w=n[_];f+=(m%w+s[_][0])*l[_],m=Math.floor(m/w)}i[p]=a[f]}return new t(this.type,i,r)}permute(...e){return K2(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=(f,_)=>f+_,i=0n):(a=(f,_)=>f+_**e,i=0),r===null){let f=n.reduce(a,i);return e!==1&&(f=f**(1/e)),new t(this.type,[f],[])}let[l,c,p]=El(a,this,r,s);if(e!==1)for(let f=0;f<c.length;++f)c[f]=c[f]**(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 f=this.dims[l];if(l!==r){let _=c%f;i+=_*p,p*=this.dims[l]}c=Math.floor(c/f)}n[a]/=o[i]}return this}normalize(e=2,r=1){return this.clone().normalize_(e,r)}stride(){return x1(this.dims)}squeeze(e=null){return new t(this.type,this.data,H2(this.dims,e))}squeeze_(e=null){return this.dims=H2(this.dims,e),this}unsqueeze(e){return new t(this.type,this.data,X2(this.dims,e))}unsqueeze_(e){return this.dims=X2(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 Ml(this,e,r)}min(e=null,r=!1){if(e===null){let a=_l(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=El((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=Pe(this.data)[0];return new t(this.type,[a],[])}let[s,n,o]=El((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=_l(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=Pe(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=x1(s),c=x1(n);for(let p=0;p<o;++p){let f=p,_=0;for(let m=0;m<n.length;++m){let w=Math.floor(f/c[m]);f=f%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,_A(this.data),this.dims);return new t(e,kr[e].from(this.data,r),this.dims)}};function SL(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 K2(t,e){let[r,s]=lA(t.data,t.dims,e);return new N(t.type,r,s)}function hp(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=iA(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 y1(t,e){return await(await ur.matmul)({a:t,b:e})}async function TL(t,e){return await(await ur.rfft)({x:t,a:e})}async function Gt(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 mp=t=>new N("int64",t,[t.length]);async function Al(t,e,r,s,n){return await(await ur.slice)({x:t,s:mp(e),e:mp(r),a:mp(s),t:mp(n??new Array(s.length).fill(1))})}function b1(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 f=p*l*i;for(let _=0;_<l;++_){let m=0,w=0,x=p*i,k=f+_;for(let A=0;A<i;++A){let T=Number(s[x+A]);w+=T,m+=r[k+A*l]*T}let E=m/w;o[c++]=E}}return new N(t.type,o,n)}function OL(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]=gp(t,1,0,!0),i=o.data,l=a.data,c=t.data,p=new c.constructor(c.length);for(let f=0;f<s;++f){let _=f*n;for(let m=0;m<n;++m){let w=_+m;p[w]=(c[w]-l[f])/(i[f]+r)}}return new N(t.type,p,t.dims)}function H2(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 X2(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 f=0;for(let _=c.length-1,m=p,w=1;_>=0;--_){let x=c[_],k=m%x;_===e&&(k+=a),f+=k*w,w*=r[_],m=Math.floor(m/x)}n[f]=l[p]}a+=c[e]}}return new N(o,n,r)}function Tt(t,e=0){return ve(t.map(r=>r.unsqueeze(e)),e)}function El(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 f=a.length-1,_=c,m=1;f>=0;--f){let w=a[f];if(f!==r){let x=_%w;p+=x*m,m*=i[f]}_=Math.floor(_/w)}l[p]=t(l[p],o[c],c,p)}return s||i.splice(r,1),[e.type,l,i]}function gp(t,e=null,r=1,s=!1){let n=t.data,o=t.dims;if(e===null){let m=n.reduce((E,A)=>E+A,0)/n.length,w=Math.sqrt(n.reduce((E,A)=>E+(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=Ml(t,e,s),i=a.data,[l,c,p]=El((_,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 Ml(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]=El((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 x1(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 v1(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 v1(t,e,r,s)}function Fn(t,e){return qe(t.dims,e)}function Je(t){return v1(t,1n,"int64",BigInt64Array)}function Sl(t){return Je(t.dims)}function wp(t){return v1(t,0n,"int64",BigInt64Array)}function xp(t){return wp(t.dims)}function IL(t){let e=t.reduce((r,s)=>r*s,1);return new N("float32",Float32Array.from({length:e},()=>Vr.random()),t)}function k1(t){let e=t.reduce((r,s)=>r*s,1);return new N("float32",Float32Array.from({length:e},()=>Vr.gauss()),t)}function E1(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 jn(t){if(!t)throw new Error("modelId is required for get_tokenizer_files");return(await Bt(t,"tokenizer_config.json",{})).exists?["tokenizer.json","tokenizer_config.json"]:[]}async function A1(t,e){let r=await jn(t);return await Promise.all(r.map(s=>ut(t,s,!0,e)))}function M1(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 CL=["bos_token","eos_token","unk_token","sep_token","pad_token","cls_token","mask_token"];function PL(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 zL(t,e){for(let r of Object.keys(t))t[r].length=e}function Fs(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 LL(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 RE(e,r),this.config=r,this.padding_side=r.padding_side??this.padding_side,this.mask_token=Fs(r,"mask_token"),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=Fs(r,"pad_token","eos_token"),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=Fs(r,"sep_token"),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=Fs(r,"unk_token"),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=Fs(r,"bos_token"),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=Fs(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=LL(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 A1(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(Pe(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&&zL(p[_],a):n&&PL(p[_],a,m=>m==="input_ids"?this.pad_token_id:0,this.padding_side));let f={};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]))f[m]=new N("int64",BigInt64Array.from(p.flatMap(w=>w[m]).map(BigInt)),_)}else{for(let _ of Object.keys(p[0]))f[_]=p.map(m=>m[_]);if(!c)for(let _ of Object.keys(f))f[_]=f[_][0]}return f}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair: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=M1(e)),!Array.isArray(e)||e.length===0||!xE(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:f=!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 KE(n),this._compiled_template_cache.set(n,w));let x=Object.create(null);for(let E of CL){let A=Fs(this.config,E);A&&(x[E]=A)}let k=w.render({messages:e,add_generation_prompt:o,tools:r,documents:s,...x,...m});if(a){let E=this._call(k,{add_special_tokens:!1,padding:i,truncation:l,max_length:c,return_tensor:p,..._});return f?E:E.input_ids}return k}};function Gn(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 T1={};Ms(T1,{AlbertTokenizer:()=>yp,AutoTokenizer:()=>se,BartTokenizer:()=>bp,BertTokenizer:()=>vp,BlenderbotSmallTokenizer:()=>kp,BlenderbotTokenizer:()=>Ep,BloomTokenizer:()=>Ap,CLIPTokenizer:()=>Sp,CamembertTokenizer:()=>Mp,CodeGenTokenizer:()=>Op,CodeLlamaTokenizer:()=>Tp,CohereTokenizer:()=>Ip,ConvBertTokenizer:()=>Cp,DebertaTokenizer:()=>zp,DebertaV2Tokenizer:()=>Pp,DistilBertTokenizer:()=>Lp,ElectraTokenizer:()=>Np,EsmTokenizer:()=>$p,FalconTokenizer:()=>Rp,GPT2Tokenizer:()=>Bp,GPTNeoXTokenizer:()=>Up,GemmaTokenizer:()=>Dp,HerbertTokenizer:()=>Fp,LlamaTokenizer:()=>jp,M2M100Tokenizer:()=>Gp,MBart50Tokenizer:()=>Wp,MBartTokenizer:()=>qn,MPNetTokenizer:()=>Xp,MarianTokenizer:()=>qp,MgpstrTokenizer:()=>Vp,MobileBertTokenizer:()=>Hp,NllbTokenizer:()=>Kp,NougatTokenizer:()=>Yp,PreTrainedTokenizer:()=>q,Qwen2Tokenizer:()=>Qp,RoFormerTokenizer:()=>Zp,RobertaTokenizer:()=>Jp,SiglipTokenizer:()=>ed,SpeechT5Tokenizer:()=>td,SqueezeBertTokenizer:()=>rd,T5Tokenizer:()=>sd,TokenizersBackend:()=>q,VitsTokenizer:()=>nd,Wav2Vec2CTCTokenizer:()=>od,WhisperTokenizer:()=>ad,XLMRobertaTokenizer:()=>id,XLMTokenizer:()=>ld});var yp=class extends q{return_token_type_ids=!0};var bp=class extends q{};var vp=class extends q{return_token_type_ids=!0};var kp=class extends q{};var Ep=class extends q{};var Ap=class extends q{};var Mp=class extends q{};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{return_token_type_ids=!0};var Pp=class extends q{return_token_type_ids=!0};var zp=class extends q{return_token_type_ids=!0};var Lp=class extends q{};var Np=class extends q{return_token_type_ids=!0};var $p=class extends q{};var Rp=class extends q{};var Dp=class extends q{};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{padding_side="left"};var Gp=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 Gn(this,e,r,s)}};var qp=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 qn=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 Gn(this,e,r,s)}};var Wp=class extends qn{};var Vp=class extends q{};var Hp=class extends q{return_token_type_ids=!0};var Xp=class extends q{};var Kp=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 Gn(this,e,r,s)}};var Yp=class extends q{};var Qp=class extends q{};var Jp=class extends q{};var Zp=class extends q{return_token_type_ids=!0};var ed=class extends q{};var td=class extends q{};var rd=class extends q{return_token_type_ids=!0};var sd=class extends q{};var S1=class extends Dt{decode_chain(e){let r="";for(let s=1;s<e.length;s+=2)r+=e[s];return[r]}},nd=class extends q{constructor(e,r){super(e,r),this._tokenizer.decoder=new S1({type:"VitsDecoder"})}};var od=class extends q{};var Y2=[["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"]],Tl=new Map(Y2),NL=new Map([...Y2.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 Q2(t){t=t.toLowerCase();let e=NL.get(t);if(e===void 0){let r=t.match(/^<\|([a-z]{2})\|>$/);if(r&&(t=r[1]),Tl.has(t))e=t;else{let n=t.length===2?Tl.keys():Tl.values();throw new Error(`Language "${t}" is not supported. Must be one of: ${JSON.stringify(Array.from(n))}`)}}return e}var $L="\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E",J2=new RegExp(`^[${$L}]+$`,"gu"),ad=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(),f=0,_=this.timestamp_begin,w=_+1500,x=[],k=[],E=!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[K,R,C]=O.stride;if(f-=R,A=K-C,R&&(B=R/n+_),C)for(let re=v.length-1;re>=0;--re){let ae=Number(v[re]);if(ae>=_){if(X!==null&&(ae-_)*n<A)break;X=ae}}}let H=[],G=[];for(let K=0;K<v.length;++K){let R=Number(v[K]);if(T.has(R)){let C=this.decode([R]),re=Tl.get(C.slice(2,-2));if(re!==void 0){if(a!==null&&re!==a&&!r){x.push(H);let ae=this.findLongestCommonSequence(x)[0],z=this.decode(ae);p.text=z,c.push(p),x=[],H=[],p=l()}a=p.language=re}}else if(R>=_&&R<=w){let C=(R-_)*n+f,re=Cs(C,2);if(X!==null&&R>=X)E=!0;else if(E||x.length>0&&R<B)E=!1;else if(p.timestamp[0]===null)p.timestamp[0]=re;else if(re!==p.timestamp[0]){p.timestamp[1]=re,x.push(H),i&&k.push(G);let[ae,z]=this.findLongestCommonSequence(x,k),$=this.decode(ae);p.text=$,i&&(p.words=this.collateWordTimestamps(ae,z,a)),c.push(p),x=[],H=[],k=[],G=[],p=l()}}else if(H.push(R),i){let C=Cs(W[K]+f,2),re;if(K+1<W.length){re=Cs(W[K+1]+f,2);let ae=this.decode([R]);J2.test(ae)&&(re=Cs(Math.min(C+n,re),2))}else re=null;G.push([C,re])}}if("stride"in O){let[K,R,C]=O.stride;f+=K-C}H.length>0?(x.push(H),i&&k.push(G)):x.every(K=>K.length===0)&&(p=l(),x=[],H=[],k=[],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,k),W=this.decode(O);p.text=W,i&&(p.words=this.collateWordTimestamps(O,v,a)),c.push(p)}let S=Object.create(null),P=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[P,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],f=0,_=[n,n,0,0],m=p.length;for(let S=1;S<n+m;++S){let P=Math.max(0,n-S),O=Math.min(n,n+m-S),v=s.slice(P,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[P+C]<=r[c][W+C]).length:H=v.filter((R,C)=>R===B[C]).length;let G=S/1e4,K=H/S+G;H>1&&K>f&&(f=K,_=[P,O,W,X])}let[w,x,k,E]=_,A=Math.floor((x+w)/2),T=Math.floor((E+k)/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=M1(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 f=e[p];i.push(f),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],f=n[l],_=p[0]>=this._tokenizer.token_to_id("<|endoftext|>"),m=c.startsWith(" "),w=c.trim(),x=J2.test(w);if(_||m||x||o.length===0)o.push(c),a.push(p),i.push(f);else{let k=o.length-1;o[k]+=c,a[k].push(...p),i[k].push(...f)}}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(f=>f),i.filter(f=>f.length>0),l.filter(f=>f.length>0)]}};var id=class extends q{};var ld=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 se=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 A1(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a}),c=l.tokenizer_class?.replace(/Fast$/,"")??"PreTrainedTokenizer",p=T1[c];return p||(Z.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),p=q),new p(i,l)}};var os="https://github.com/huggingface/transformers.js/issues/new/choose";var Ol="preprocessor_config.json",Er=Ol,Z2="processor_config.json",eM="chat_template.jinja";var te=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,Z2,!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?kb(e,eM,!0,r):null]);return new this(s,n,o)}};var Xf={};Ms(Xf,{ChatterboxProcessor:()=>Md,Florence2Processor:()=>yf,Gemma3Processor:()=>bf,Gemma3nProcessor:()=>vf,Glm46VProcessor:()=>kf,GraniteSpeechProcessor:()=>Ef,GroundingDinoProcessor:()=>Af,Idefics3Processor:()=>Vl,JinaCLIPProcessor:()=>Sf,Lfm2VlProcessor:()=>Tf,LlavaProcessor:()=>Of,MgpstrProcessor:()=>If,MoonshineProcessor:()=>Cf,OwlViTProcessor:()=>Pf,PaliGemmaProcessor:()=>zf,Phi3VProcessor:()=>Lf,PixtralProcessor:()=>Nf,Processor:()=>te,PyAnnoteProcessor:()=>$f,Qwen2VLProcessor:()=>ls,Qwen2_5_VLProcessor:()=>to,Qwen3VLProcessor:()=>Rf,Sam2Processor:()=>Hl,Sam2VideoProcessor:()=>Df,SamProcessor:()=>ro,SmolVLMProcessor:()=>Vl,SpeechT5Processor:()=>Uf,UltravoxProcessor:()=>Bf,VLChatProcessor:()=>Mf,VoxtralProcessor:()=>jf,VoxtralRealtimeProcessor:()=>qf,Wav2Vec2Processor:()=>Wf,Wav2Vec2ProcessorWithLM:()=>Vf,WhisperProcessor:()=>Hf});var Ee=class extends tt{constructor(e){super(),this.config=e}static async from_pretrained(e,r={}){let s=await ut(e,Ol,!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 Il={};Ms(Il,{ASTFeatureExtractor:()=>dd,ChatterboxFeatureExtractor:()=>fd,ClapFeatureExtractor:()=>_d,DacFeatureExtractor:()=>Hn,EncodecFeatureExtractor:()=>Vn,FeatureExtractor:()=>Ee,Gemma3nAudioFeatureExtractor:()=>md,GraniteSpeechFeatureExtractor:()=>hd,MoonshineFeatureExtractor:()=>gd,ParakeetFeatureExtractor:()=>wd,PyAnnoteFeatureExtractor:()=>Xn,SeamlessM4TFeatureExtractor:()=>xd,SnacFeatureExtractor:()=>yd,SpeechT5FeatureExtractor:()=>bd,VoxtralRealtimeFeatureExtractor:()=>Ed,Wav2Vec2FeatureExtractor:()=>vd,WeSpeakerFeatureExtractor:()=>kd,WhisperFeatureExtractor:()=>Ad});var tM=yr(require("fs"),1),rM=require("stream"),sM=require("stream/promises");async function cd(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=rM.Readable.fromWeb(r),n=tM.default.createWriteStream(t);await(0,sM.pipeline)(s,n)}else throw new Error("Unable to save because filesystem is disabled in this environment.")}async function pd(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 aM(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 nM(t){return aM(t,.5)}function RL(t){return aM(t,.54)}var DL={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 O1(t,e="htk"){let r=DL[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 UL={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 BL(t,e="htk"){let r=UL[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 FL(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 oM(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=O1(r,a),c=O1(s,a),p=oM(l,c,e+2),f=BL(p,a),_;if(i){let w=n/((t-1)*2);_=O1(Float64Array.from({length:t},(x,k)=>k*w),a),f=p}else _=oM(0,Math.floor(n/2),t);let m=FL(_,f);if(o!==null&&o==="slaney")for(let w=0;w<e;++w){let x=m[w],k=2/(f[w+2]-f[w]);for(let E=0;E<t;++E)x[E]*=k}return m}function jL(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[In(o,n)];for(let o=1;o<=r;++o)s[n+e+o]=t[In(n-o,n)];return s}function iM(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=Pe(t)[0]-n;for(let i=0;i<t.length;++i)t[i]=Math.max(t[i],a)}return t}function GL(t,e=1,r=1e-5,s=null){return iM(t,20,e,r,s)}function qL(t,e=1,r=1e-10,s=null){return iM(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:f=null,mel_floor:_=1e-10,log_mel:m=null,max_log_mel:w=null,reference:x=1,min_value:k=1e-10,db_range:E=null,remove_dc_offset:A=null,min_num_frames:T=null,max_num_frames:S=null,do_pad:P=!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&&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 U=Math.floor((n-1)/2)+1;t=jL(t,U,U);break}case"constant":{let U=Math.floor(n/2),J=new t.constructor(t.length+2*U);J.set(t,U),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?P&&(G=S):G=H=S);let K=new Yu(n),R=new Float64Array(n),C=new Float64Array(K.outputBufferSize),re=new Float32Array(B*G);for(let U=0;U<H;++U){let J=U*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];K.realTransform(C,R);for(let ue=0;ue<B;++ue){let Ve=ue<<1;re[ue*G+U]=C[Ve]**2+C[Ve+1]**2}}if(o!==null&&o!==2){let U=o/2;for(let J=0;J<re.length;++J)re[J]**=U}let ae=f.length,z=await y1(new N("float32",f.flat(),[ae,B]),new N("float32",re,[B,G]));O&&(z=z.transpose(1,0));let $=z.data;for(let U=0;U<$.length;++U)$[U]=v+Math.max(_,$[U]);if(o!==null&&m!==null){let U=Math.min($.length,H*ae);switch(m){case"log":for(let J=0;J<U;++J)$[J]=Math.log($[J]);break;case"log10":for(let J=0;J<U;++J)$[J]=Math.log10($[J]);break;case"log10_max_norm":{for(let ue=0;ue<U;++ue)$[ue]=Math.log10($[ue]);let xe=(w??Pe($)[0])-8;for(let ue=0;ue<U;++ue)$[ue]=(Math.max($[ue],xe)+4)/4;break}case"dB":if(o===1)GL($,x,k,E);else if(o===2)qL($,x,k,E);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 z}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=nM(o);break;case"hamming":a=RL(o);break;case"povey":a=nM(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 WL(t,e){let r=t.reduce((o,a)=>o+a.length,0),s=new ArrayBuffer(44),n=new DataView(s);return ud(n,0,"RIFF"),n.setUint32(4,36+r*4,!0),ud(n,8,"WAVE"),ud(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),ud(n,36,"data"),n.setUint32(40,r*4,!0),new Blob([s,...t.map(o=>o.buffer)],{type:"audio/wav"})}function ud(t,e,r){for(let s=0;s<r.length;++s)t.setUint8(e+s,r.charCodeAt(s))}var Wn=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]),WL(e,this.sampling_rate)}async save(e){return cd(e,this.toBlob())}};var dd=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 Vn=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 fd=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 _d=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 Hn=class extends Vn{};var md=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 hd=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 gd=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 VL=1e-5,wd=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 f=0;f<s;++f){let _=f*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 f=0;f<a;++f){let _=i[f]/s,m=(l[f]-s*_*_)/c,x=1/(Math.sqrt(m)+VL);for(let k=0;k<s;++k){let E=k*a+f;n[E]=(n[E]-_)*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 Xn=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=Ce(o[l]),[p,f]=Pe(c),[_,m]=[l,l+1];f!==i?(i=f,a.push({id:f,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:f})=>({id:l,start:c*s,end:p*s,confidence:f/(p-c)})))}return n}};var xd=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,k=a.data;for(let E=0;E<x;++E){let A=0;for(let O=0;O<w;++O)A+=k[O*x+E];let T=A/w,S=0;for(let O=0;O<w;++O)S+=(k[O*x+E]-T)**2;S/=w-1;let P=Math.sqrt(S+1e-7);for(let O=0;O<w;++O){let v=O*x+E;k[v]=(k[v]-T)/P}}}let i;if(r){let[w,x]=a.dims,k=a.data,E=w%s;if(E>0){let A=new Float32Array(x*(w+E));A.set(k),A.fill(this.config.padding_value,k.length);let T=w+E;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 k=i.data;for(let E=1,A=0;E<l;E+=p,++A)x[A]=k[E]}else x.fill(1n);m.attention_mask=new N("int64",x,[1,w])}return m}};var yd=class extends Hn{};var bd=class extends Ee{};var vd=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 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,"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 f=0;f<a;++f){let _=c+f*i;for(let m=0;m<i;++m)n[_+m]-=s[p+m]}}}return{input_features:r}}};var Ed=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 Ad=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,Ol,!0,r),n=s.feature_extractor_type,o=Il[n];if(!o)throw new Error(`Unknown feature_extractor_type: '${n}'. Please report this at ${os}.`);return new o(s)}};var Md=class extends te{static tokenizer_class=se;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 Sd=yr(require("sharp"),1);var js,lM,as;if(ie.IS_WEB_ENV)js=(t,e)=>{if(!self.OffscreenCanvas)throw new Error("OffscreenCanvas not supported by this environment.");return new self.OffscreenCanvas(t,e)},as=self.createImageBitmap,lM=self.ImageData;else if(Sd.default)as=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 HL={0:"nearest",1:"lanczos",2:"bilinear",3:"bicubic",4:"box",5:"hamming"},XL=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 as(e),s=js(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,Sd.default)(await e.arrayBuffer());return await as(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=HL[s]??s,o=db(e),a=db(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=js(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 as(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=js(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 as(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=js(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 as(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=js(e,r).getContext("2d"),l=0,c=0,p=0,f=0;return s>=0?l=s:p=-s,n>=0?c=n:f=-n,i.drawImage(a,l,c,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],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 as(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=js(e.width,e.height),s=new lM(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=XL.get(r)??"image/png",n=await this.toBlob(s);return cd(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,Sd.default)(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}},cM=Ke.read.bind(Ke);function uM(t,e,r=0,s=null){let n=t/e,o=dA(n)*e;return s!==null&&o>s&&(o=Math.floor(n)*e),o<r&&(o=Math.ceil(n)*e),o}function pM([t,e],r){return[Math.max(Math.floor(t/r),1)*r,Math.max(Math.floor(e/r),1)*r]}function I1([t,e,r,s]){return[t-r/2,e-s/2,t+r/2,e+s/2]}function is(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 f=r!==null?r[p]:null,_={boxes:[],classes:[],scores:[]},m=n[p],w=o[p];for(let x=0;x<i;++x){let k=m[x],E=[],A;if(s){A=k.sigmoid().data;for(let T=0;T<A.length;++T)A[T]>e&&E.push(T)}else{let T=Pe(k.data)[1];if(T===l-1||(A=Ce(k.data),A[T]<e))continue;E.push(T)}for(let T of E){let S=w[x].data;S=I1(S),f!==null&&(S=S.map((P,O)=>P*f[(O+1)%2])),_.boxes.push(S),_.classes.push(T),_.scores.push(A[T])}}c.push(_)}return c}function Td(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=hp(i,a,"bilinear",!1));let[l,c]=a??i.dims.slice(-2),p=new N("int32",new Int32Array(l*c),[l,c]),f=i[0].data,_=p.data;for(let x=1;x<i.dims[0];++x){let k=i[x].data;for(let E=0;E<k.length;++E)k[E]>f[E]&&(f[E]=k[E],_[E]=x)}let m=new Array(i.dims[0]);for(let x=0;x<_.length;++x){let k=_[x];m[k]=k}let w=m.filter(x=>x!==void 0);n.push({segmentation:p,labels:w})}return n}function KL(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=Pe(l.data)[1];if(p===s)continue;let _=Ce(l.data)[p];_>r&&(n.push(c),o.push(_),a.push(p))}return[n,o,a]}function YL(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 QL(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]=hp(t[x],a,"bilinear",!1);let f=new Int32Array(t[0].data.length),_=new Float32Array(t[0].data.length);for(let x=0;x<t.length;++x){let k=e[x],E=t[x].data;for(let A=0;A<E.length;++A)E[A]*=k,E[A]>_[A]&&(f[A]=x,_[A]=E[A])}let m=0,w=c.data;for(let x=0;x<r.length;++x){let k=r[x],[E,A]=YL(f,t,x,s,n);if(E){++m;for(let T of A)w[T]=m;p.push({id:m,label_id:k,score:e[x]})}}return[c,p]}function Kn(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 Od(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,f]=a.dims;if(f-=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],k=l[m],[E,A,T]=KL(x,k,e,f);if(T.length===0){let[O,v]=w??k.dims.slice(-2),W=new N("int32",new Int32Array(O*v).fill(-1),[O,v]);_.push({segmentation:W,segments_info:[]});continue}let[S,P]=QL(E,A,T,r,s,n,w);_.push({segmentation:S,segments_info:P})}return _}function Id(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=_l(s.data)[0],a=Pe(s.data)[0]-n;if(a===0)return e;let i=r/255,l=s.width,c=s.height,p=0,f=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),f=Math.max(f,m))}return e=await e.crop([l,c,p,f]),e}pad_image(e,r,s,{mode:n="constant",center:o=!1,constant_values:a=0}={}){let[i,l,c]=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 _=new Float32Array(p*f*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((f-i)/2)]:[0,0];for(let x=0;x<i;++x){let k=(x+w)*p,E=x*l;for(let A=0;A<l;++A){let T=(k+A+m)*c,S=(E+A)*c;for(let P=0;P<c;++P)_[T+P]=e[S+P]}}if(n==="symmetric"){if(o)throw new Error("`center` padding is not supported when `mode` is set to `symmetric`.");let x=i-1,k=l-1;for(let E=0;E<f;++E){let A=E*p,T=In(E,x)*l;for(let S=0;S<p;++S){if(E<i&&S<l)continue;let P=(A+S)*c,O=(T+In(S,k))*c;for(let v=0;v<c;++v)_[P+v]=e[O+v]}}}e=_,r=[f,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),f=Math.floor(Number((l*p).toFixed(2))),_=Math.floor(Number((c*p).toFixed(2)));return this.size_divisibility!==void 0&&([f,_]=pM([f,_],this.size_divisibility)),[f,_]}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=uM(c*n,this.config.ensure_multiple_of),i=uM(p*s,this.config.ensure_multiple_of)}return[i,l]}else{if(this.size_divisibility!==void 0)return pM([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),f=[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 k=0;k<e.channels;++k)p[x+k]=(p[x+k]-m[k])/w[k]}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 m=Math.ceil(f[1]/this.size_divisibility)*this.size_divisibility,w=Math.ceil(f[0]/this.size_divisibility)*this.size_divisibility;[p,f]=this.pad_image(p,f,{width:m,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 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,f).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:Tt(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 Zn={};Ms(Zn,{BeitFeatureExtractor:()=>Cd,BitImageProcessor:()=>Pd,CHMv2ImageProcessor:()=>Ld,CLIPFeatureExtractor:()=>Nd,CLIPImageProcessor:()=>Cl,ChineseCLIPFeatureExtractor:()=>zd,ConvNextFeatureExtractor:()=>$d,ConvNextImageProcessor:()=>Pl,DINOv3ViTImageProcessor:()=>Ud,DPTFeatureExtractor:()=>Fd,DPTImageProcessor:()=>Nl,DeiTFeatureExtractor:()=>Rd,DeiTImageProcessor:()=>zl,DetrFeatureExtractor:()=>Dd,DetrImageProcessor:()=>Ll,DonutFeatureExtractor:()=>Bd,DonutImageProcessor:()=>Gs,EfficientNetImageProcessor:()=>jd,GLPNFeatureExtractor:()=>Wd,Gemma3ImageProcessor:()=>Gd,Glm46VImageProcessor:()=>qd,GroundingDinoImageProcessor:()=>Vd,Idefics3ImageProcessor:()=>$l,ImageFeatureExtractor:()=>V,ImageProcessor:()=>V,JinaCLIPImageProcessor:()=>Xd,Lfm2VlImageProcessor:()=>Kd,LlavaOnevisionImageProcessor:()=>Yd,Mask2FormerImageProcessor:()=>Jd,MaskFormerFeatureExtractor:()=>Qd,MaskFormerImageProcessor:()=>qs,MobileNetV1FeatureExtractor:()=>Zd,MobileNetV1ImageProcessor:()=>Rl,MobileNetV2FeatureExtractor:()=>ef,MobileNetV2ImageProcessor:()=>Dl,MobileNetV3FeatureExtractor:()=>tf,MobileNetV3ImageProcessor:()=>Ul,MobileNetV4FeatureExtractor:()=>rf,MobileNetV4ImageProcessor:()=>Bl,MobileViTFeatureExtractor:()=>sf,MobileViTImageProcessor:()=>Fl,NougatImageProcessor:()=>nf,OwlViTFeatureExtractor:()=>of,OwlViTImageProcessor:()=>Ws,Owlv2ImageProcessor:()=>af,Phi3VImageProcessor:()=>lf,PixtralImageProcessor:()=>cf,PvtImageProcessor:()=>uf,Qwen2VLImageProcessor:()=>Yn,RTDetrImageProcessor:()=>pf,Sam2ImageProcessor:()=>Jn,Sam3ImageProcessor:()=>Jn,SamImageProcessor:()=>Jn,SapiensFeatureExtractor:()=>df,SapiensImageProcessor:()=>jl,SegformerFeatureExtractor:()=>ff,SegformerImageProcessor:()=>Gl,SiglipImageProcessor:()=>_f,SmolVLMImageProcessor:()=>$l,Swin2SRImageProcessor:()=>mf,VLMImageProcessor:()=>Hd,ViTFeatureExtractor:()=>hf,ViTImageProcessor:()=>ql,VitMatteImageProcessor:()=>gf,VitPoseImageProcessor:()=>wf,YolosFeatureExtractor:()=>xf,YolosImageProcessor:()=>Wl});var Cd=class extends V{};var Pd=class extends V{};var zd=class extends V{};var Ld=class extends V{};var Cl=class extends V{},Nd=class extends Cl{};var Pl=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}},$d=class extends Pl{};var zl=class extends V{},Rd=class extends zl{};var Ll=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 is(...e)}post_process_panoptic_segmentation(...e){return Od(...e)}post_process_instance_segmentation(...e){return Id(...e)}},Dd=class extends Ll{};var Ud=class extends V{};var Gs=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((f,_)=>-f/c[_]);return super.pad_image(e,r,s,{center:!0,constant_values:p,...n})}},Bd=class extends Gs{};var Nl=class extends V{},Fd=class extends Nl{};var jd=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 Gd=class extends V{};var Yn=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 Kn(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,f=a.dims[1],_=Math.floor(a.dims[2]/c),m=Math.floor(a.dims[3]/c),w=a.view(p,i,f,Math.floor(_/l),l,c,Math.floor(m/l),l,c).permute(0,3,6,4,7,2,1,5,8).view(p*_*m,f*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 qd=class extends Yn{get_resize_output_image_size(e,r){let s=this.patch_size*this.merge_size,n=this.config.temporal_patch_size??2;return Kn(e.height,e.width,s,this.min_pixels,this.max_pixels,n)}};var Wd=class extends V{};var Vd=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 $l=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 E of n){let A=await Promise.all(E.map(P=>this.preprocess(P)));l.push(...A.map(P=>P.original_size)),c.push(...A.map(P=>P.reshaped_input_size)),A.forEach(P=>P.pixel_values.unsqueeze_(0));let{longest_edge:T}=this.max_image_size,S;if(r??this.do_image_splitting){let P=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:K}=await this.split_image(B,this.max_image_size);return P[W]=G,O[W]=K,ve(H,0)})),a.push(P),i.push(O)}else{let P=[T,T];S=await Promise.all(A.map(O=>xt(O.pixel_values,{size:P}))),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,[f,_,m,w]=o[0].dims,x,k;if(p===1)x=o[0].unsqueeze_(0),k=qe([p,f,m,w],!0);else{let E=Math.max(...o.map(S=>S.dims.at(0)));k=qe([p,E,m,w],!0);let A=k.data,T=E*m*w;for(let S=0;S<p;++S){let P=o[S].dims[0];if(P<E){o[S]=ve([o[S],qe([E-P,_,m,w],0)],0);let O=S*T+P*m*w,v=(S+1)*T;A.fill(!1,O,v)}}x=Tt(o,0)}return{pixel_values:x,pixel_attention_mask:k,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),f=Math.ceil(i/c);for(let w=0;w<l;++w)for(let x=0;x<c;++x){let k,E,A,T;w===l-1?(E=a-p,T=a):(E=w*p,T=(w+1)*p),x===c-1?(k=i-f,A=i):(k=x*f,A=(x+1)*f);let O=await Al(e,[E,k],[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 Hd=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 Xd=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 dM(t,e){return Math.round(t/e)*e}function JL(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 ZL(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 eN(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),f=n*o;for(let _=0;_<r;++_){let m=_*s*f,w=_*a*i*l;for(let x=0;x<a;++x)for(let k=0;k<i;++k){let E=w+(x*i+k)*l;for(let A=0;A<e;++A){let T=(x*e+A)*o+k*e;for(let S=0;S<e;++S){let P=T+S;for(let O=0;O<s;++O)p[E++]=c[m+O*f+P]}}}}return new N("float32",p,[r,a*i,l])}function tN(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 Kd=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,dM(e,s)),o=Math.max(this.encoder_patch_size,dM(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=ZL(this.min_tiles,this.max_tiles),[n,o]=JL(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 f of s){let _=await Promise.all(f.map(m=>this.preprocess(m,{do_pad:!1})));for(let{pixel_values:m}of _){let[,w,x]=m.dims,k=m.unsqueeze_(0),E=this.encoder_patch_size*this.downsample_factor,A=E**2,[T,S]=Kn(Math.max(E,w),Math.max(E,x),E,this.min_image_tokens*A,this.max_image_tokens*A).map(B=>Math.max(E,B)),P,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:K}=this._get_grid_layout(w,x);O=H,v=B;let R=await xt(k,{size:[K,G]});P=[];for(let C=0;C<H;++C)for(let re=0;re<B;++re){let ae=C*this.tile_size,z=re*this.tile_size;P.push(R.slice(null,null,[ae,ae+this.tile_size],[z,z+this.tile_size]))}this.use_thumbnail&&B*H!==1&&P.push(await xt(k,{size:[S,T]}))}else P=[await xt(k,{size:[S,T]})];for(let B of P){let[,,H,G]=B.dims,K=eN(B,this.encoder_patch_size),{padded:R,mask:C}=tN(K,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:Tt(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 Yd=class extends V{};var qs=class extends V{post_process_panoptic_segmentation(...e){return Od(...e)}post_process_instance_segmentation(...e){return Id(...e)}},Qd=class extends qs{};var Jd=class extends qs{};var Rl=class extends V{},Zd=class extends Rl{};var Dl=class extends V{},ef=class extends Dl{};var Ul=class extends V{},tf=class extends Ul{};var Bl=class extends V{},rf=class extends Bl{};var Fl=class extends V{},sf=class extends Fl{};var nf=class extends Gs{};var Ws=class extends V{post_process_object_detection(...e){return is(...e)}},of=class extends Ws{};var af=class extends Ws{};var Lt=336,rN=[2,3],{ceil:C1,floor:Qn,sqrt:P1}=Math,lf=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 Qn((Qn(r/Lt)*Qn(e/Lt)+1)*s+1+(Qn(r/Lt)+1)*P1(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=Lt*C1(o/Lt),l=Lt*C1(a/Lt),c=[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:c,...n})}async _call(e,{num_crops:r=null}={}){if(this._num_crops=r??=this.config.num_crops,r<4||P1(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:[Lt,Lt],mode:"bicubic"});if(r>0){let k=[],E=P1(r),A=Qn(w/E),T=Qn(m/E);for(let P=0;P<E;++P)for(let O=0;O<E;++O){let v,W,X,B;P===E-1?(W=m-T,B=m):(W=P*T,B=(P+1)*T),O===E-1?(v=w-A,X=w):(v=O*A,X=(O+1)*A);let K=await Al(_,[W,v],[B,X],rN);k.push(K)}let S=await xt(ve(k,0),{size:[Lt,Lt],mode:"bicubic"});i.push(ve([x,S],0))}else i.push(x)}let l=Tt(i,0),c=a.map(_=>_.map(m=>Lt*C1(m/Lt))),p=new N("int64",c.flat(),[s,2]),f=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:f}}};var cf=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 f=c*p,_=Math.floor((i-1)/f)+1,m=Math.floor((l-1)/f)+1;return[_*f,m*f]}};var uf=class extends V{};var pf=class extends V{post_process_object_detection(...e){return is(...e)}};var Jn=class extends V{reshape_input_points(e,r,s,n=!1){e=structuredClone(e);let o=fb(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],f=[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]*=f[w%2]}return new N("float32",Float32Array.from(e.flat(1/0)),o)}add_input_labels(e,r){let s=fb(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],f=s[c],_=await xt(e[c],{mode:"bilinear",size:l});if(_=_.slice(null,null,[0,f[0]],[0,f[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 jl=class extends V{post_process_semantic_segmentation(...e){return Td(...e)}},df=class extends jl{};var Gl=class extends V{post_process_semantic_segmentation(...e){return Td(...e)}},ff=class extends Gl{};var _f=class extends V{};var mf=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 ql=class extends V{},hf=class extends ql{};var gf=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:Tt(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 wf=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 f=n[p],_=r[p],m=[];for(let w=0;w<_.length;++w){let x=_[w],k=[],E=[],A=[],T=x.at(-2)/l,S=x.at(-1)/i;for(let P=0;P<f.length;++P){let[O,v]=[0,0],W=0,X=-1/0,B=f[P];for(let G=0;G<B.length;++G){let K=B[G];for(let R=0;R<K.length;++R){let C=K[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];k.push(H),A.push(P),E.push(X)}m.push({bbox:x,scores:E,labels:A,keypoints:k})}c.push(m)}return c}};var Wl=class extends V{post_process_object_detection(...e){return is(...e)}},xf=class extends Wl{};var Ae=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=Zn[n?.replace(/Fast$/,"")];return o||(n!==void 0&&Z.warn(`Image processor type '${n}' not found, assuming base ImageProcessor. Please report this at ${os}.`),o=V),new o(s)}};var yf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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,f,..._]of i)l.push(f?f.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 bf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,r,s){super(e,r,s),this.image_seq_length=this.config.image_seq_length;let{boi_token:n,image_token:o,eoi_token:a}=this.tokenizer.config;this.boi_token=n,this.image_token=o,this.eoi_token=a;let i=o.repeat(this.image_seq_length);this.full_image_sequence=`
|
|
14
|
+
|
|
15
|
+
${n}${i}${a}
|
|
16
|
+
|
|
17
|
+
`}async _call(e,r=null,s={}){typeof e=="string"&&(e=[e]);let n;return r&&(n=await this.image_processor(r,s),e=e.map(a=>a.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,s),...n}}};var vf=class extends te{static image_processor_class=Ae;static feature_extractor_class=We;static tokenizer_class=se;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:f}=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
18
|
|
|
15
19
|
${o}${_}${i}
|
|
16
20
|
|
|
@@ -18,10 +22,10 @@ ${o}${_}${i}
|
|
|
18
22
|
|
|
19
23
|
${c}${m}${f}
|
|
20
24
|
|
|
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
|
|
25
|
+
`}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 ls=class extends te{static image_processor_class=Ae;static tokenizer_class=se;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(f=>{for(;f.includes(c);){let _=Number(p[l++].reduce((m,w)=>m*w,1n));f=f.replace(c,"<|placeholder|>".repeat(Math.floor(_/i)))}return f.replaceAll("<|placeholder|>",c)})}return{...this.tokenizer(e),...n}}};var kf=class extends ls{static image_token="<|image|>"};var Ef=class extends te{static tokenizer_class=se;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 sN(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 Af=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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(),f=p.max(-1).tolist(),_=i.tolist().map(w=>w.map(x=>I1(x))),m=[];for(let w=0;w<l;++w){let x=o!==null?o[w]:null;x!==null&&(_[w]=_[w].map(S=>S.map((P,O)=>P*x[(O+1)%2])));let k=f[w],E=[],A=[],T=[];for(let S=0;S<c;++S){let P=k[S];if(P<=s)continue;let O=_[w][S],v=p[w][S];E.push(P),T.push(O);let W=sN(v.gt(n),r[w]);A.push(W)}m.push({scores:E,boxes:T,labels:this.batch_decode(A)})}return m}};function nN(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
26
|
`}return a+=`
|
|
23
|
-
${s}${o}`+n.repeat(t)+`${s}`,a}function
|
|
24
|
-
`}var
|
|
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=>Tz(c,n,o,Zn,e.length)));let i=this.tokenizer(a,s);return{...await this.image_processor(e,s),...i}}};var N2="<|image|>",Oz=/<\|image_\d+\|>/g,Mf=class extends re{static image_processor_class=Oe;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((f,_)=>f.split(Oz).join(N2.repeat(l[_])));a=this.tokenizer(c,{padding:s,truncation:n});let p=this.tokenizer._tokenizer.token_to_id(N2);a.input_ids.map_(f=>f==p?-f:f)}else a=this.tokenizer(e);return{...a,...i}}};var Sf=class extends re{static tokenizer_class=oe;static image_processor_class=Oe;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:f,spatial_merge_size:_}=this.config,m=f*_,w=Math.floor(a/m),x=Math.floor(i/m);r=structuredClone(r),Array.isArray(r)||(r=[r]);for(let k=0;k<r.length;++k){let E=l.repeat(x),A=E+c,T=E+p,S=A.repeat(w-1)+T;r[k]=r[k].replace(l,S)}}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var Tf=class extends re{static feature_extractor_class=Kn;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 eo=class extends re{static image_processor_class=Oe;static tokenizer_class=oe;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=o.tolist();e=e.map(p=>{for(;p.includes("<|image_pad|>");){let f=Number(c[l++].reduce((_,m)=>_*m,1n));p=p.replace("<|image_pad|>","<|placeholder|>".repeat(Math.floor(f/i)))}return p.replaceAll("<|placeholder|>","<|image_pad|>")})}return{...this.tokenizer(e),...n}}};var to=class extends eo{};var Of=class extends to{};var ro=class extends re{static image_processor_class=Oe;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 ql=class extends ro{},If=class extends ql{};var Cf=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;async _call(e){return await this.feature_extractor(e)}};var Lf=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;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 Pf="[AUDIO]",Iz="[BEGIN_AUDIO]",Cz=375;function Lz(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 zf=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;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(Pf))throw new Error(`The input text does not contain the audio token ${Pf}.`);Array.isArray(r)||(r=[r]);let a=e.split(Pf),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=>Lz(w,l)),p=c.map(w=>w.length),f=c.flat(),_=(await Promise.all(f.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+=Iz;for(let x=0;x<p[w];++x)m+=Pf.repeat(Cz);m+=a[w+1]}e=m}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var $2=32,r1=6,Nf=8,Pz=10,zz=32,$f=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(r1+1)*Nf}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 Nf*e+r}get num_right_pad_tokens(){return r1+1+Pz}get audio_length_per_tok(){return Nf}get raw_audio_length_per_tok(){return Nf*this.feature_extractor.config.hop_length}async _call(e,{is_streaming:r=!1,is_first_audio_chunk:s=!0}={}){if(Fe(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=$2*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+($2+r1),c=new BigInt64Array(l).fill(BigInt(zz));return c[0]=1n,{input_ids:new $("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 Rf=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;async _call(e){return await this.feature_extractor(e)}};var Df=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;async _call(e){return await this.feature_extractor(e)}};var Ff=class extends re{static tokenizer_class=oe;static feature_extractor_class=Ve;async _call(e){return await this.feature_extractor(e)}};var Wl=class{static async from_pretrained(e,r={}){let s=await ft(e,Mr,!0,r),{image_processor_type:n,feature_extractor_type:o,processor_class:a}=s;if(a&&Bf[a])return Bf[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=Jn[n.replace(/Fast$/,"")];if(!c)throw new Error(`Unknown image_processor_type: '${n}'.`);i.image_processor=new c(s)}if(o){let c=Jn[o];if(c)i.image_processor=new c(s);else{let p=Sl[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 Nz(t,e){return await ft(t,"config.json",!0,e)}function so(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"mistral3":case"qwen2_5_vl":case"qwen3_vl":case"qwen3_vl_moe":r=so(t.text_config);break;case"moondream1":r=so(t.phi_config);break;case"musicgen":r=so(t.decoder);break;case"multi_modality":r=so(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"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=so(t.decoder),o="num_decoder_layers"in n,a=Ye(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,...Ye(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)s[n]=t[e[n]];return s}function Qs(t,e){if(t instanceof Ks||(t=new Ks(t)),["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:c}=t,p=l/a,f=e?.batch_size??1;for(let _=0;_<o.length;++_)if(o[_]==="full_attention")for(let m of["key","value"])n[`${r}.${_}.${m}`]=[f,i,0,p];else if(o[_]==="conv")n[`${s}_conv.${_}`]=[f,l,c];else throw new Error(`Unsupported layer type: ${o[_]}`);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:c,mamba_d_conv:p,mamba_n_heads:f,mamba_d_head:_,mamba_d_state:m,mamba_n_groups:w,mamba_expand:x,mamba_d_ssm:k}=t,E=c/i,A=e?.batch_size??1,T=(k??x*c)+2*w*m;for(let S=0;S<a;++S)if((!o||o[S]==="mamba")&&(n[`${s}_conv.${S}`]=[A,T,p],n[`${s}_ssm.${S}`]=[A,f,_,m]),!o||o[S]==="attention")for(let P of["key","value"])n[`${r}.${S}.${P}`]=[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:c,linear_num_value_heads:p,linear_num_key_heads:f,linear_key_head_dim:_,linear_value_head_dim:m,linear_conv_kernel_dim:w}=t,x=_*f,k=m*p,E=o??c/i,A=e?.batch_size??1;for(let T=0;T<a.length;++T)if(a[T]==="full_attention")for(let S of["key","value"])n[`${r}.${T}.${S}`]=[A,l,0,E];else if(a[T]==="linear_attention"){if(t.model_type==="olmo_hybrid")n[`${s}_conv.${T}.key`]=[A,x,w],n[`${s}_conv.${T}.value`]=[A,k,w],n[`${s}_conv.${T}.query`]=[A,x,w];else{let S=x*2+k;n[`${s}_conv.${T}`]=[A,S,w]}n[`${s}_recurrent.${T}`]=[A,p,_,m]}else throw new Error(`Unsupported layer type: ${a[T]}`);return n}else if(["lfm2_vl","qwen3_5","qwen3_5_moe","voxtral_realtime"].includes(t.model_type)){let r;return t.model_type==="voxtral_realtime"&&e?.session_name==="audio_encoder"?r=t.audio_config:r=t.text_config,Qs(r,e)}return $z(t,e)}function $z(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=so(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 Nz(e,{progress_callback:r,config:s,cache_dir:n,local_files_only:o,revision:a});return new this(i)}},Rt=class{static async from_pretrained(...e){return Ks.from_pretrained(...e)}};function s1(t,e,r){return t?typeof t=="object"&&t!==null?t.hasOwnProperty(e)?+t[e]:t.hasOwnProperty(r)?+t[r]:0:+t:0}function n1(t,e){let r=[];for(let s=0;s<e;++s)r.push(`${t}_data${s===0?"":"_"+s}`);return r}async function R2(t,e,r,s){let n=`${e}${s}.onnx`,o=`${r.subfolder??""}/${n}`;return await cl(t,o,!0,r,ie.IS_NODE_ENV)}async function D2(t,e,r,s,n,o={}){let a=`${e}${r}.onnx`,i=ie.IS_NODE_ENV,l=[],c=s1(n,a,e);if(c>0){if(c>Uu)throw new Error(`The number of external data chunks (${c}) exceeds the maximum allowed value (${Uu}).`);let p=n1(a,c);for(let f of p){let _=`${s.subfolder??""}/${f}`;l.push(new Promise(async(m,w)=>{let x=await cl(t,_,!0,s,i);m(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 cl(t,p.data,!0,s);return{...p,data:f}}return p}));return Promise.all(l)}async function Rz(t,e,r,s=!1,n=void 0){let o=r.config?.["transformers.js_config"]??{},a=lp(r.device??o.device,e,{warn:S=>Z.info(S)}),i=u2(a),l=o.device_config??{};l.hasOwnProperty(a)&&(o={...o,...l[a]});let c=cp(r.dtype??o.dtype,e,a,{configDtype:o.dtype,warn:S=>Z.info(S)});if(yl.hasOwnProperty(c)){if(a==="webgpu"&&!ie.IS_NODE_ENV&&c===yt.fp16&&!await _2())throw new Error(`The device (${a}) does not support fp16.`)}else throw new Error(`Invalid dtype: ${c}. Should be one of: ${Object.keys(yt).join(", ")}`);let p=o.kv_cache_dtype,f=p?typeof p=="string"?p:p[c]??"float32":void 0;if(f&&!["float32","float16"].includes(f))throw new Error(`Invalid kv_cache_dtype: ${f}. Should be one of: float32, float16`);let _=yl[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=R2(t,e,r,_),k=r.use_external_data_format??o.use_external_data_format,E=await D2(t,e,_,r,k,m);if(E.length>0&&!ie.IS_NODE_ENV&&(m.externalData=E),s&&a==="webgpu"&&p!==!1){let S=Qs(r.config,{prefix:"present",session_name:n});if(Object.keys(S).length>0&&!xl()){let P={};for(let O in S)P[O]="gpu-buffer";m.preferredOutputLocation=P}}return{buffer_or_path:await x,session_options:m,session_config:{dtype:c,kv_cache_dtype:f,device:a}}}async function F2(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 Rz(t,e[n],r,o,n),c=await op(a,i,l);return[n,c]})))}function B2(t){for(let e in t)ip(t[e])?t[e]=new $(t[e]):typeof t[e]=="object"&&B2(t[e]);return t}async function de(t,e){let r=Dz(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 ap(t,s);return B2(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 Dz(t,e){let r=Object.create(null),s=[];for(let a of t.inputNames){let i=e[a];if(!(i instanceof $)){s.push(a);continue}r[a]=xl()?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 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)}},he=class extends Re{constructor({logits:e}){super(),this.logits=e}},we=class extends Re{constructor({logits:e}){super(),this.logits=e}},Me=class extends Re{constructor({start_logits:e,end_logits:r}){super(),this.start_logits=e,this.end_logits=r}},kt=class extends Re{constructor({logits:e}){super(),this.logits=e}};var Uf=class extends Re{constructor({alphas:e}){super(),this.alphas=e}};var Dt=class extends st{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},no=class extends st{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},cs=class extends st{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()}},Vl=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}},Hl=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}},Ys=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}},Xl=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=Vu(n),c=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((f,_)=>f+_)),p=Pe(l.subarray(0,this.timestamp_begin))[0];c>p&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return r}},Kl=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}},Ql=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}},Yl=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}},Jl=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}},Zl=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}},ec=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}},tc=class extends no{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}},o1=class extends no{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}},a1=class extends no{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 oo=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,Ye(e,Object.getOwnPropertyNames(this)))}};var Sr=class extends st{_call(e,r){throw Error("StoppingCriteria needs to be subclassed")}},Js=class t extends st{constructor(){super(),this.criteria=[]}push(e){this.criteria.push(e)}extend(e){e instanceof t?e=e.criteria:e instanceof Sr&&(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()}},rc=class extends Sr{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)}},sc=class extends Sr{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)})}},i1=class extends Sr{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 st{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 xE(e)}static getSampler(e){if(e.do_sample)return new c1(e);if(e.num_beams>1)return new u1(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 l1(e)}},l1=class extends Zs{async sample(e){let r=Pe(e.data)[1];return[[BigInt(r),0]]}},c1=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 Wt(e,r),o=Le(s.data);return Array.from({length:this.generation_config.num_beams},()=>{let a=this.randomSelect(o);return[n.data[a],Math.log(o[a])]})}},u1=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 Wt(e,r),o=Le(s.data);return Array.from({length:this.generation_config.num_beams},(a,i)=>[n.data[i],Math.log(o[i])])}};var p1=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 $))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)}},ao=p1;var en=null;function j2(t){en=t}function d1(t){if(t instanceof $)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 $("int64",BigInt64Array.from(t.flat().map(e=>BigInt(e))),[t.length,t[0].length])}else return new $("int64",BigInt64Array.from(t.map(e=>BigInt(e))),[1,t.length])}function f1(t){return new $("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},io={[K.DecoderOnly]:{can_generate:!0,forward:Ct,prepare_inputs:lo,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:Ct,prepare_inputs:lo,sessions:(t,e)=>({model:e.model_file_name??"model"})},[K.Seq2Seq]:{can_generate:!0,forward:jf,prepare_inputs:oc,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:oc,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:U2,prepare_inputs:nc,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:Bz,prepare_inputs:nc,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:nc,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:nc,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:Fz,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:Vt,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:U2,prepare_inputs:nc,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:lo,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:Vt,sessions:(t,e)=>({model:e.model_file_name??"model"})}};function G2(t,e,r={}){let s=io[t]??io.default;return{sessions:s.sessions(e,r),cache_sessions:s.cache_sessions,optional_configs:s.optional_configs}}var sr=new Map,Gf=new Map,tn=new Map,y=class extends st{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=sr.get(n),a=io[o]??io.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:f=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:f,session_options:_},w=tn.get(this),x=sr.get(w);s=m.config=await Rt.from_pretrained(e,m);let k=io[x]??io.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 ${as}.`)}let E=k.sessions(s,m),A=[F2(e,E,m,k.cache_sessions)];k.optional_configs&&A.push(jz(e,k.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 cs;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&n.push(new Ql(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new Kl(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new Zl(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new Yl(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 Jl(r,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new Vl(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new Hl(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 ec(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 tc(e.temperature)),s!==null&&n.extend(s),n}_prepare_generation_config(e,r,s=oo){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,Ye(r,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,r=null){let s=new Js;return e.max_length!==null&&s.push(new rc(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&s.push(new sc(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 $("int64",e.flat(),[e.length,1]),n?"decoder_attention_mask"in s:s.attention_mask=ve([s.attention_mask,et([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=Ye(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,...Ye(p,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await Vt(this,r);if(n.guidance_scale!==null&&n.guidance_scale>1)o=ve([o,jn(o,0)],0),"attention_mask"in r&&(r.attention_mask=ve([r.attention_mask,_p(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 $)){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=El(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 f;p?{input_ids:f,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}):f=l[c];let _=f.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),k=Zs.getSampler(r),E=new Array(x).fill(0),A=f.tolist();o&&o.put(A);let T,S={},P={};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 q=this.getAttentions(T);for(let Q in q)Q in S||(S[Q]=[]),S[Q].push(q[Q])}else this._return_dict_in_generate_keys&&Object.assign(P,Ye(T,this._return_dict_in_generate_keys));let j=T.logits.slice(null,-1,null).to("float32"),H=m(A,j),B=[];for(let q=0;q<H.dims.at(0);++q){let Q=H[q],F=await k(Q);for(let[C,te]of F){let le=BigInt(C);E[q]+=te,A[q].push(le),B.push([le]);break}}if(o&&o.put(B),w(A).every(q=>q))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 $("int64",A.flat(),[A.length,A[0].length]);if(r.return_dict_in_generate)return{sequences:v,past_key_values:O,...S,...P};for(let j of Object.values(T))j.location==="gpu-buffer"&&j.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 ao(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"?Ar.float16:Ar.float32,i=Qs(this.config,{batch_size:n});for(let l in i){let c=i[l].reduce((p,f)=>p*f,1);e[l]=new $(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,Ye(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=Ye(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 Ct(t,o,!0)}async function Vt(t,e){let r=t.sessions.model,s=Ye(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=_p(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=et([n[0],n[2],n[3]])}return await de(r,s)}async function Fz(t,e){let r=await t.encode(e);return await t.decode(r)}async function Ct(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=Uz(o,n,i)}s.inputNames.includes("num_logits_to_keep")&&!o.num_logits_to_keep&&(o.num_logits_to_keep=new $("int64",[0n],[])),t.addPastKeyValues(o,n);let a=Ye(o,s.inputNames);return await de(s,a)}async function q2(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:f=null,..._}){if(!l){l=await t.encode_text({input_ids:o,..._});let w=Ye(_,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],k=c.get_seq_length();a=ve([et([o.dims[0],k]),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"].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 Ct(t,{inputs_embeds:l,past_key_values:c,attention_mask:a,position_ids:i,generation_config:p,logits_processor:f},!0)}async function Bz(t,e){return await q2(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 U2(t,e){return await q2(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 _1(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 Uz(t,e=null,r=0){let{input_ids:s,inputs_embeds:n,attention_mask:o}=t,{data:a,dims:i}=_1(o,r),l=new $("int64",a,i);if(e){let c=-(s??n).dims.at(1);l=l.slice(null,[c,null])}return l}function lo(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 $("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=et([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 oc(t,e,r,s){return r.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...r,decoder_input_ids:d1(e)}}function nc(t,...e){return t.config.is_encoder_decoder?oc(t,...e):lo(t,...e)}function W2({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,f,_)=>(f==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],f=e[c];for(let _=0;_<p.length;++_)f[p[_]].data.set(r[l++].data)}return{inputs_embeds:e,attention_mask:n}}function co({image_token_id:t,inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return W2({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}function qf({audio_token_id:t,inputs_embeds:e,audio_features:r,input_ids:s,attention_mask:n}){return W2({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}async function jz(t,e,r){return Object.fromEntries(await Promise.all(Object.keys(e).map(async s=>{let n=await ft(t,e[s],!1,r);return[s,n]})))}var tu={};Os(tu,{ASTForAudioClassification:()=>r_,ASTModel:()=>t_,ASTPreTrainedModel:()=>_o,AfmoeForCausalLM:()=>Jf,AfmoeModel:()=>Yf,AfmoePreTrainedModel:()=>po,AlbertForMaskedLM:()=>Xf,AlbertForQuestionAnswering:()=>Hf,AlbertForSequenceClassification:()=>Vf,AlbertModel:()=>Wf,AlbertPreTrainedModel:()=>us,ApertusForCausalLM:()=>Qf,ApertusModel:()=>Kf,ApertusPreTrainedModel:()=>uo,ArceeForCausalLM:()=>e_,ArceeModel:()=>Zf,ArceePreTrainedModel:()=>fo,BartForConditionalGeneration:()=>n_,BartForSequenceClassification:()=>o_,BartModel:()=>s_,BartPretrainedModel:()=>rn,BeitForImageClassification:()=>i_,BeitModel:()=>a_,BeitPreTrainedModel:()=>mo,BertForMaskedLM:()=>c_,BertForQuestionAnswering:()=>d_,BertForSequenceClassification:()=>u_,BertForTokenClassification:()=>p_,BertModel:()=>l_,BertPreTrainedModel:()=>Tr,BlenderbotForConditionalGeneration:()=>__,BlenderbotModel:()=>f_,BlenderbotPreTrainedModel:()=>ho,BlenderbotSmallForConditionalGeneration:()=>h_,BlenderbotSmallModel:()=>m_,BlenderbotSmallPreTrainedModel:()=>go,BloomForCausalLM:()=>w_,BloomModel:()=>g_,BloomPreTrainedModel:()=>wo,CLIPModel:()=>M_,CLIPPreTrainedModel:()=>nr,CLIPSegForImageSegmentation:()=>C_,CLIPSegModel:()=>I_,CLIPSegPreTrainedModel:()=>ko,CLIPTextModel:()=>S_,CLIPTextModelWithProjection:()=>vo,CLIPVisionModel:()=>T_,CLIPVisionModelWithProjection:()=>O_,CamembertForMaskedLM:()=>y_,CamembertForQuestionAnswering:()=>k_,CamembertForSequenceClassification:()=>b_,CamembertForTokenClassification:()=>v_,CamembertModel:()=>x_,CamembertPreTrainedModel:()=>Or,ChatterboxModel:()=>xo,ChatterboxPreTrainedModel:()=>ac,ChineseCLIPModel:()=>E_,ChineseCLIPPreTrainedModel:()=>ic,ClapAudioModelWithProjection:()=>bo,ClapModel:()=>A_,ClapPreTrainedModel:()=>sn,ClapTextModelWithProjection:()=>yo,CodeGenForCausalLM:()=>P_,CodeGenModel:()=>L_,CodeGenPreTrainedModel:()=>Eo,Cohere2ForCausalLM:()=>R_,Cohere2Model:()=>$_,Cohere2PreTrainedModel:()=>Mo,CohereForCausalLM:()=>N_,CohereModel:()=>z_,CoherePreTrainedModel:()=>Ao,ConvBertForMaskedLM:()=>F_,ConvBertForQuestionAnswering:()=>j_,ConvBertForSequenceClassification:()=>B_,ConvBertForTokenClassification:()=>U_,ConvBertModel:()=>D_,ConvBertPreTrainedModel:()=>Ir,ConvNextForImageClassification:()=>q_,ConvNextModel:()=>G_,ConvNextPreTrainedModel:()=>So,ConvNextV2ForImageClassification:()=>V_,ConvNextV2Model:()=>W_,ConvNextV2PreTrainedModel:()=>To,DFineForObjectDetection:()=>Q_,DFineModel:()=>K_,DFinePreTrainedModel:()=>Io,DINOv3ConvNextModel:()=>ym,DINOv3ConvNextPreTrainedModel:()=>_c,DINOv3ViTModel:()=>bm,DINOv3ViTPreTrainedModel:()=>mc,DPTForDepthEstimation:()=>Om,DPTModel:()=>Tm,DPTPreTrainedModel:()=>$o,DacDecoderModel:()=>Lo,DacDecoderOutput:()=>cc,DacEncoderModel:()=>Co,DacEncoderOutput:()=>lc,DacModel:()=>Y_,DacPreTrainedModel:()=>nn,DebertaForMaskedLM:()=>Z_,DebertaForQuestionAnswering:()=>rm,DebertaForSequenceClassification:()=>em,DebertaForTokenClassification:()=>tm,DebertaModel:()=>J_,DebertaPreTrainedModel:()=>Cr,DebertaV2ForMaskedLM:()=>nm,DebertaV2ForQuestionAnswering:()=>im,DebertaV2ForSequenceClassification:()=>om,DebertaV2ForTokenClassification:()=>am,DebertaV2Model:()=>sm,DebertaV2PreTrainedModel:()=>Lr,DecisionTransformerModel:()=>lm,DecisionTransformerPreTrainedModel:()=>uc,DeiTForImageClassification:()=>um,DeiTModel:()=>cm,DeiTPreTrainedModel:()=>Po,DepthAnythingForDepthEstimation:()=>pm,DepthAnythingPreTrainedModel:()=>pc,DepthProForDepthEstimation:()=>dm,DepthProPreTrainedModel:()=>dc,DetrForObjectDetection:()=>_m,DetrForSegmentation:()=>mm,DetrModel:()=>fm,DetrObjectDetectionOutput:()=>an,DetrPreTrainedModel:()=>on,DetrSegmentationOutput:()=>fc,Dinov2ForImageClassification:()=>gm,Dinov2Model:()=>hm,Dinov2PreTrainedModel:()=>zo,Dinov2WithRegistersForImageClassification:()=>xm,Dinov2WithRegistersModel:()=>wm,Dinov2WithRegistersPreTrainedModel:()=>No,DistilBertForMaskedLM:()=>Mm,DistilBertForQuestionAnswering:()=>Am,DistilBertForSequenceClassification:()=>km,DistilBertForTokenClassification:()=>Em,DistilBertModel:()=>vm,DistilBertPreTrainedModel:()=>Pr,DonutSwinModel:()=>Sm,DonutSwinPreTrainedModel:()=>hc,EdgeTamModel:()=>kx,EfficientNetForImageClassification:()=>Cm,EfficientNetModel:()=>Im,EfficientNetPreTrainedModel:()=>Ro,ElectraForMaskedLM:()=>Pm,ElectraForQuestionAnswering:()=>$m,ElectraForSequenceClassification:()=>zm,ElectraForTokenClassification:()=>Nm,ElectraModel:()=>Lm,ElectraPreTrainedModel:()=>zr,Ernie4_5ForCausalLM:()=>Dm,Ernie4_5Model:()=>Rm,Ernie4_5PretrainedModel:()=>Do,EsmForMaskedLM:()=>Bm,EsmForSequenceClassification:()=>Um,EsmForTokenClassification:()=>jm,EsmModel:()=>Fm,EsmPreTrainedModel:()=>ps,ExaoneForCausalLM:()=>qm,ExaoneModel:()=>Gm,ExaonePreTrainedModel:()=>Fo,FalconForCausalLM:()=>Vm,FalconH1ForCausalLM:()=>Xm,FalconH1Model:()=>Hm,FalconH1PreTrainedModel:()=>Uo,FalconModel:()=>Wm,FalconPreTrainedModel:()=>Bo,FastViTForImageClassification:()=>Qm,FastViTModel:()=>Km,FastViTPreTrainedModel:()=>jo,Florence2ForConditionalGeneration:()=>Ym,Florence2PreTrainedModel:()=>gc,GLPNForDepthEstimation:()=>ih,GLPNModel:()=>ah,GLPNPreTrainedModel:()=>Xo,GPT2LMHeadModel:()=>gh,GPT2Model:()=>hh,GPT2PreTrainedModel:()=>Zo,GPTBigCodeForCausalLM:()=>ch,GPTBigCodeModel:()=>lh,GPTBigCodePreTrainedModel:()=>Ko,GPTJForCausalLM:()=>xh,GPTJModel:()=>wh,GPTJPreTrainedModel:()=>ea,GPTNeoForCausalLM:()=>ph,GPTNeoModel:()=>uh,GPTNeoPreTrainedModel:()=>Qo,GPTNeoXForCausalLM:()=>fh,GPTNeoXModel:()=>dh,GPTNeoXPreTrainedModel:()=>Yo,Gemma2ForCausalLM:()=>th,Gemma2Model:()=>eh,Gemma2PreTrainedModel:()=>qo,Gemma3ForCausalLM:()=>sh,Gemma3Model:()=>rh,Gemma3PreTrainedModel:()=>Wo,Gemma3nForCausalLM:()=>Vo,Gemma3nForConditionalGeneration:()=>ln,Gemma3nPreTrainedModel:()=>wc,GemmaForCausalLM:()=>Zm,GemmaModel:()=>Jm,GemmaPreTrainedModel:()=>Go,GlmForCausalLM:()=>oh,GlmModel:()=>nh,GlmPreTrainedModel:()=>Ho,GptOssForCausalLM:()=>mh,GptOssModel:()=>_h,GptOssPreTrainedModel:()=>Jo,GraniteForCausalLM:()=>bh,GraniteModel:()=>yh,GraniteMoeHybridForCausalLM:()=>kh,GraniteMoeHybridModel:()=>vh,GraniteMoeHybridPreTrainedModel:()=>ra,GranitePreTrainedModel:()=>ta,GraniteSpeechForConditionalGeneration:()=>Eh,GroundingDinoForObjectDetection:()=>Ah,GroundingDinoPreTrainedModel:()=>yc,GroupViTModel:()=>Mh,GroupViTPreTrainedModel:()=>bc,HeliumForCausalLM:()=>Th,HeliumModel:()=>Sh,HeliumPreTrainedModel:()=>sa,HieraForImageClassification:()=>Ih,HieraModel:()=>Oh,HieraPreTrainedModel:()=>na,HubertForCTC:()=>Rh,HubertForSequenceClassification:()=>Dh,HubertModel:()=>$h,HubertPreTrainedModel:()=>Nh,HunYuanDenseV1ForCausalLM:()=>Bh,HunYuanDenseV1Model:()=>Fh,HunYuanDenseV1PreTrainedModel:()=>oa,IJepaForImageClassification:()=>Wh,IJepaModel:()=>qh,IJepaPreTrainedModel:()=>aa,Idefics3ForConditionalGeneration:()=>Gh,JAISLMHeadModel:()=>Hh,JAISModel:()=>Vh,JAISPreTrainedModel:()=>ia,JinaCLIPModel:()=>Xh,JinaCLIPPreTrainedModel:()=>cn,JinaCLIPTextModel:()=>la,JinaCLIPVisionModel:()=>Kh,Lfm2ForCausalLM:()=>Yh,Lfm2Model:()=>Qh,Lfm2MoeForCausalLM:()=>Zh,Lfm2MoeModel:()=>Jh,Lfm2MoePreTrainedModel:()=>ua,Lfm2PreTrainedModel:()=>ca,Lfm2VlForConditionalGeneration:()=>eg,LiteWhisperForConditionalGeneration:()=>Ny,Llama4ForCausalLM:()=>sg,Llama4PreTrainedModel:()=>kc,LlamaForCausalLM:()=>rg,LlamaModel:()=>tg,LlamaPreTrainedModel:()=>pa,LlavaForConditionalGeneration:()=>Ft,LlavaOnevisionForConditionalGeneration:()=>Ft,LlavaPreTrainedModel:()=>vc,LlavaQwen2ForCausalLM:()=>jh,LongT5ForConditionalGeneration:()=>og,LongT5Model:()=>ng,LongT5PreTrainedModel:()=>da,M2M100ForConditionalGeneration:()=>ig,M2M100Model:()=>ag,M2M100PreTrainedModel:()=>fa,MBartForCausalLM:()=>mg,MBartForConditionalGeneration:()=>fg,MBartForSequenceClassification:()=>_g,MBartModel:()=>dg,MBartPreTrainedModel:()=>fs,MPNetForMaskedLM:()=>Zg,MPNetForQuestionAnswering:()=>rw,MPNetForSequenceClassification:()=>ew,MPNetForTokenClassification:()=>tw,MPNetModel:()=>Jg,MPNetPreTrainedModel:()=>Nr,MT5ForConditionalGeneration:()=>aw,MT5Model:()=>ow,MT5PreTrainedModel:()=>Aa,MarianMTModel:()=>cg,MarianModel:()=>lg,MarianPreTrainedModel:()=>_a,MaskFormerForInstanceSegmentation:()=>pg,MaskFormerModel:()=>ug,MaskFormerPreTrainedModel:()=>ma,Metric3DForDepthEstimation:()=>hg,Metric3DPreTrainedModel:()=>Ec,Metric3Dv2ForDepthEstimation:()=>gg,Metric3Dv2PreTrainedModel:()=>Ac,MgpstrForSceneTextRecognition:()=>wg,MgpstrModelOutput:()=>Mc,MgpstrPreTrainedModel:()=>Sc,MimiDecoderModel:()=>ga,MimiDecoderOutput:()=>Oc,MimiEncoderModel:()=>ha,MimiEncoderOutput:()=>Tc,MimiModel:()=>xg,MimiPreTrainedModel:()=>un,MistralForCausalLM:()=>bg,MistralModel:()=>yg,MistralPreTrainedModel:()=>wa,MobileBertForMaskedLM:()=>kg,MobileBertForQuestionAnswering:()=>Ag,MobileBertForSequenceClassification:()=>Eg,MobileBertModel:()=>vg,MobileBertPreTrainedModel:()=>_s,MobileLLMForCausalLM:()=>Sg,MobileLLMModel:()=>Mg,MobileLLMPreTrainedModel:()=>xa,MobileNetV1ForImageClassification:()=>Og,MobileNetV1ForSemanticSegmentation:()=>Ig,MobileNetV1Model:()=>Tg,MobileNetV1PreTrainedModel:()=>pn,MobileNetV2ForImageClassification:()=>Lg,MobileNetV2ForSemanticSegmentation:()=>Pg,MobileNetV2Model:()=>Cg,MobileNetV2PreTrainedModel:()=>dn,MobileNetV3ForImageClassification:()=>Ng,MobileNetV3ForSemanticSegmentation:()=>$g,MobileNetV3Model:()=>zg,MobileNetV3PreTrainedModel:()=>fn,MobileNetV4ForImageClassification:()=>Dg,MobileNetV4ForSemanticSegmentation:()=>Fg,MobileNetV4Model:()=>Rg,MobileNetV4PreTrainedModel:()=>_n,MobileViTForImageClassification:()=>Ug,MobileViTModel:()=>Bg,MobileViTPreTrainedModel:()=>ya,MobileViTV2ForImageClassification:()=>Gg,MobileViTV2Model:()=>jg,MobileViTV2PreTrainedModel:()=>ba,ModernBertDecoderForCausalLM:()=>Kg,ModernBertDecoderModel:()=>Xg,ModernBertDecoderPreTrainedModel:()=>va,ModernBertForMaskedLM:()=>Wg,ModernBertForSequenceClassification:()=>Vg,ModernBertForTokenClassification:()=>Hg,ModernBertModel:()=>qg,ModernBertPreTrainedModel:()=>ms,Moondream1ForConditionalGeneration:()=>Uh,MoonshineForConditionalGeneration:()=>Yg,MoonshineModel:()=>Qg,MoonshinePreTrainedModel:()=>ka,MptForCausalLM:()=>nw,MptModel:()=>sw,MptPreTrainedModel:()=>Ea,MultiModalityCausalLM:()=>iw,MultiModalityPreTrainedModel:()=>Ic,MusicgenForCausalLM:()=>cw,MusicgenForConditionalGeneration:()=>Sa,MusicgenModel:()=>lw,MusicgenPreTrainedModel:()=>Ma,NanoChatForCausalLM:()=>pw,NanoChatModel:()=>uw,NanoChatPreTrainedModel:()=>Ta,NeoBertForMaskedLM:()=>fw,NeoBertForQuestionAnswering:()=>hw,NeoBertForSequenceClassification:()=>_w,NeoBertForTokenClassification:()=>mw,NeoBertModel:()=>dw,NeoBertPreTrainedModel:()=>$r,NomicBertModel:()=>gw,NomicBertPreTrainedModel:()=>Cc,OPTForCausalLM:()=>Ow,OPTModel:()=>Tw,OPTPreTrainedModel:()=>za,Olmo2ForCausalLM:()=>bw,Olmo2Model:()=>yw,Olmo2PreTrainedModel:()=>Ia,Olmo3ForCausalLM:()=>kw,Olmo3Model:()=>vw,Olmo3PreTrainedModel:()=>Ca,OlmoForCausalLM:()=>xw,OlmoHybridForCausalLM:()=>Aw,OlmoHybridModel:()=>Ew,OlmoHybridPreTrainedModel:()=>La,OlmoModel:()=>ww,OlmoPreTrainedModel:()=>Oa,OpenELMForCausalLM:()=>Sw,OpenELMModel:()=>Mw,OpenELMPreTrainedModel:()=>Pa,OwlViTForObjectDetection:()=>Pw,OwlViTModel:()=>Lw,OwlViTPreTrainedModel:()=>$a,Owlv2ForObjectDetection:()=>Cw,Owlv2Model:()=>Iw,Owlv2PreTrainedModel:()=>Na,PaliGemmaForConditionalGeneration:()=>zw,ParakeetForCTC:()=>Nw,ParakeetPreTrainedModel:()=>Lc,PatchTSMixerForPrediction:()=>Rw,PatchTSMixerModel:()=>$w,PatchTSMixerPreTrainedModel:()=>Ra,PatchTSTForPrediction:()=>Fw,PatchTSTModel:()=>Dw,PatchTSTPreTrainedModel:()=>Da,Phi3ForCausalLM:()=>Gw,Phi3Model:()=>jw,Phi3PreTrainedModel:()=>Ba,Phi3VForCausalLM:()=>Ua,Phi3VPreTrainedModel:()=>Pc,PhiForCausalLM:()=>Uw,PhiModel:()=>Bw,PhiPreTrainedModel:()=>Fa,PreTrainedModel:()=>y,PvtForImageClassification:()=>Ww,PvtModel:()=>qw,PvtPreTrainedModel:()=>ja,PyAnnoteForAudioFrameClassification:()=>Hw,PyAnnoteModel:()=>Vw,PyAnnotePreTrainedModel:()=>Ga,Qwen2ForCausalLM:()=>Kw,Qwen2Model:()=>Xw,Qwen2MoeForCausalLM:()=>Yw,Qwen2MoeModel:()=>Qw,Qwen2MoePreTrainedModel:()=>Wa,Qwen2PreTrainedModel:()=>qa,Qwen2VLForCausalLM:()=>hs,Qwen2VLForConditionalGeneration:()=>mn,Qwen2VLPreTrainedModel:()=>zc,Qwen2_5_VLForCausalLM:()=>gs,Qwen2_5_VLForConditionalGeneration:()=>Va,Qwen3ForCausalLM:()=>Zw,Qwen3Model:()=>Jw,Qwen3MoeForCausalLM:()=>tx,Qwen3MoeModel:()=>ex,Qwen3MoePreTrainedModel:()=>Xa,Qwen3NextForCausalLM:()=>sx,Qwen3NextModel:()=>rx,Qwen3NextPreTrainedModel:()=>Ka,Qwen3PreTrainedModel:()=>Ha,Qwen3VLForCausalLM:()=>xs,Qwen3VLForConditionalGeneration:()=>ws,Qwen3VLMoeForCausalLM:()=>Qa,Qwen3VLMoeForConditionalGeneration:()=>nx,Qwen3_5ForCausalLM:()=>ys,Qwen3_5ForConditionalGeneration:()=>hn,Qwen3_5MoeForCausalLM:()=>Ya,Qwen3_5MoeForConditionalGeneration:()=>ox,RFDetrForObjectDetection:()=>cx,RFDetrModel:()=>lx,RFDetrObjectDetectionOutput:()=>Nc,RFDetrPreTrainedModel:()=>Za,RTDetrForObjectDetection:()=>X_,RTDetrModel:()=>H_,RTDetrObjectDetectionOutput:()=>or,RTDetrPreTrainedModel:()=>Oo,RTDetrV2ForObjectDetection:()=>bx,RTDetrV2Model:()=>yx,RTDetrV2ObjectDetectionOutput:()=>$c,RTDetrV2PreTrainedModel:()=>ei,ResNetForImageClassification:()=>ix,ResNetModel:()=>ax,ResNetPreTrainedModel:()=>Ja,RoFormerForMaskedLM:()=>hx,RoFormerForQuestionAnswering:()=>xx,RoFormerForSequenceClassification:()=>gx,RoFormerForTokenClassification:()=>wx,RoFormerModel:()=>mx,RoFormerPreTrainedModel:()=>Dr,RobertaForMaskedLM:()=>px,RobertaForQuestionAnswering:()=>_x,RobertaForSequenceClassification:()=>dx,RobertaForTokenClassification:()=>fx,RobertaModel:()=>ux,RobertaPreTrainedModel:()=>Rr,Sam2ImageSegmentationOutput:()=>Fc,Sam2Model:()=>ti,Sam2PreTrainedModel:()=>Bc,Sam3TrackerModel:()=>Ex,SamImageSegmentationOutput:()=>Rc,SamModel:()=>vx,SamPreTrainedModel:()=>Dc,SapiensForDepthEstimation:()=>Mx,SapiensForNormalEstimation:()=>Sx,SapiensForSemanticSegmentation:()=>Ax,SapiensPreTrainedModel:()=>gn,SegformerForImageClassification:()=>Ox,SegformerForSemanticSegmentation:()=>Ix,SegformerModel:()=>Tx,SegformerPreTrainedModel:()=>wn,SiglipModel:()=>Cx,SiglipPreTrainedModel:()=>ri,SiglipTextModel:()=>si,SiglipVisionModel:()=>Lx,SmolLM3ForCausalLM:()=>zx,SmolLM3Model:()=>Px,SmolLM3PreTrainedModel:()=>ni,SnacDecoderModel:()=>ai,SnacEncoderModel:()=>oi,SnacModel:()=>Nx,SnacPreTrainedModel:()=>xn,SpeechT5ForSpeechToText:()=>Rx,SpeechT5ForTextToSpeech:()=>Dx,SpeechT5HifiGan:()=>Fx,SpeechT5Model:()=>$x,SpeechT5PreTrainedModel:()=>yn,SqueezeBertForMaskedLM:()=>Ux,SqueezeBertForQuestionAnswering:()=>Gx,SqueezeBertForSequenceClassification:()=>jx,SqueezeBertModel:()=>Bx,SqueezeBertPreTrainedModel:()=>bs,StableLmForCausalLM:()=>Wx,StableLmModel:()=>qx,StableLmPreTrainedModel:()=>ii,Starcoder2ForCausalLM:()=>Hx,Starcoder2Model:()=>Vx,Starcoder2PreTrainedModel:()=>li,StyleTextToSpeech2Model:()=>Xx,StyleTextToSpeech2PreTrainedModel:()=>Uc,SupertonicForConditionalGeneration:()=>ci,SupertonicPreTrainedModel:()=>jc,Swin2SRForImageSuperResolution:()=>Zx,Swin2SRModel:()=>Jx,Swin2SRPreTrainedModel:()=>ui,SwinForImageClassification:()=>Qx,SwinForSemanticSegmentation:()=>Yx,SwinModel:()=>Kx,SwinPreTrainedModel:()=>bn,T5ForConditionalGeneration:()=>ty,T5Model:()=>ey,T5PreTrainedModel:()=>pi,TableTransformerForObjectDetection:()=>sy,TableTransformerModel:()=>ry,TableTransformerObjectDetectionOutput:()=>Gc,TableTransformerPreTrainedModel:()=>di,TrOCRForCausalLM:()=>ny,TrOCRPreTrainedModel:()=>qc,UltravoxModel:()=>ds,UltravoxPreTrainedModel:()=>xc,UniSpeechForCTC:()=>ay,UniSpeechForSequenceClassification:()=>iy,UniSpeechModel:()=>oy,UniSpeechPreTrainedModel:()=>vn,UniSpeechSatForAudioFrameClassification:()=>py,UniSpeechSatForCTC:()=>cy,UniSpeechSatForSequenceClassification:()=>uy,UniSpeechSatModel:()=>ly,UniSpeechSatPreTrainedModel:()=>vs,VaultGemmaForCausalLM:()=>fy,VaultGemmaModel:()=>dy,VaultGemmaPreTrainedModel:()=>fi,ViTForImageClassification:()=>hy,ViTMAEModel:()=>gy,ViTMAEPreTrainedModel:()=>Wc,ViTMSNForImageClassification:()=>xy,ViTMSNModel:()=>wy,ViTMSNPreTrainedModel:()=>mi,ViTModel:()=>my,ViTPreTrainedModel:()=>_i,VisionEncoderDecoderModel:()=>_y,VitMatteForImageMatting:()=>yy,VitMattePreTrainedModel:()=>Vc,VitPoseForPoseEstimation:()=>by,VitPosePreTrainedModel:()=>Hc,VitsModel:()=>vy,VitsModelOutput:()=>Xc,VitsPreTrainedModel:()=>Kc,VoxtralForConditionalGeneration:()=>ky,VoxtralRealtimeForConditionalGeneration:()=>hi,VoxtralRealtimePreTrainedModel:()=>Qc,Wav2Vec2BertForCTC:()=>Ay,Wav2Vec2BertForSequenceClassification:()=>My,Wav2Vec2BertModel:()=>Ey,Wav2Vec2BertPreTrainedModel:()=>kn,Wav2Vec2ForAudioFrameClassification:()=>zh,Wav2Vec2ForCTC:()=>Lh,Wav2Vec2ForSequenceClassification:()=>Ph,Wav2Vec2Model:()=>Ch,Wav2Vec2PreTrainedModel:()=>Ht,WavLMForAudioFrameClassification:()=>Cy,WavLMForCTC:()=>Ty,WavLMForSequenceClassification:()=>Oy,WavLMForXVector:()=>Iy,WavLMModel:()=>Sy,WavLMPreTrainedModel:()=>Fr,WeSpeakerResNetModel:()=>Ly,WeSpeakerResNetPreTrainedModel:()=>Jc,WhisperForConditionalGeneration:()=>Zc,WhisperModel:()=>zy,WhisperPreTrainedModel:()=>gi,XLMForQuestionAnswering:()=>By,XLMForSequenceClassification:()=>Dy,XLMForTokenClassification:()=>Fy,XLMModel:()=>$y,XLMPreTrainedModel:()=>Br,XLMRobertaForMaskedLM:()=>jy,XLMRobertaForQuestionAnswering:()=>Wy,XLMRobertaForSequenceClassification:()=>Gy,XLMRobertaForTokenClassification:()=>qy,XLMRobertaModel:()=>Uy,XLMRobertaPreTrainedModel:()=>Ur,XLMWithLMHeadModel:()=>Ry,XVectorOutput:()=>Yc,YolosForObjectDetection:()=>Hy,YolosModel:()=>Vy,YolosObjectDetectionOutput:()=>eu,YolosPreTrainedModel:()=>wi,YoutuForCausalLM:()=>Ky,YoutuModel:()=>Xy,YoutuPreTrainedModel:()=>xi});var us=class extends y{},Wf=class extends us{},Vf=class extends us{async _call(e){return new G(await super._call(e))}},Hf=class extends us{async _call(e){return new Me(await super._call(e))}},Xf=class extends us{async _call(e){return new we(await super._call(e))}};var uo=class extends y{},Kf=class extends uo{},Qf=class extends uo{};var po=class extends y{},Yf=class extends po{},Jf=class extends po{};var fo=class extends y{},Zf=class extends fo{},e_=class extends fo{};var _o=class extends y{},t_=class extends _o{},r_=class extends _o{};var rn=class extends y{},s_=class extends rn{},n_=class extends rn{},o_=class extends rn{async _call(e){return new G(await super._call(e))}};var mo=class extends y{},a_=class extends mo{},i_=class extends mo{async _call(e){return new G(await super._call(e))}};var Tr=class extends y{},l_=class extends Tr{},c_=class extends Tr{async _call(e){return new we(await super._call(e))}},u_=class extends Tr{async _call(e){return new G(await super._call(e))}},p_=class extends Tr{async _call(e){return new he(await super._call(e))}},d_=class extends Tr{async _call(e){return new Me(await super._call(e))}};var ho=class extends y{},f_=class extends ho{},__=class extends ho{};var go=class extends y{},m_=class extends go{},h_=class extends go{};var wo=class extends y{},g_=class extends wo{},w_=class extends wo{};var Or=class extends y{},x_=class extends Or{},y_=class extends Or{async _call(e){return new we(await super._call(e))}},b_=class extends Or{async _call(e){return new G(await super._call(e))}},v_=class extends Or{async _call(e){return new he(await super._call(e))}},k_=class extends Or{async _call(e){return new Me(await super._call(e))}};var Gz=4299n,V2=6561n,ac=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"]},xo=class extends ac{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:f=null,speaker_embeddings:_=null,speaker_features:m=null,...w}){let x;if(!a){let E=this.sessions.embed_tokens.inputNames,A={input_ids:e};if(E.includes("exaggeration")){if(!(n instanceof $)){let T=e.dims[0];if(n==null)n=We([T],.5);else if(typeof n=="number")n=We([T],n);else if(Array.isArray(n))n=new $("float32",n,[T]);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 de(this.sessions.embed_tokens,A),p&&f&&_&&m&&(x={audio_features:p,audio_tokens:f,speaker_embeddings:_,speaker_features:m}),x||s)x??=await this.encode_speech(s),a=ve([x.audio_features,a],1),r=et([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=et([a.dims[0],S+T])}}return{...await Ct(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==V2)-1);r.position_ids=new $("int64",n,[e.length,1])}else{let o=r.input_ids.tolist().map(a=>{let i=0;return a.map(l=>l>=V2?0:i++)});r.position_ids=new $("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),lo(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=We([a.dims[0],3],Gz),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 ic=class extends y{},E_=class extends ic{};var sn=class extends y{},A_=class extends sn{},yo=class extends sn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},bo=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 nr=class extends y{},M_=class extends nr{},S_=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},vo=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},T_=class extends nr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}},O_=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 ko=class extends y{},I_=class extends ko{},C_=class extends ko{};var Eo=class extends y{},L_=class extends Eo{},P_=class extends Eo{};var Ao=class extends y{},z_=class extends Ao{},N_=class extends Ao{};var Mo=class extends y{},$_=class extends Mo{},R_=class extends Mo{};var Ir=class extends y{},D_=class extends Ir{},F_=class extends Ir{async _call(e){return new we(await super._call(e))}},B_=class extends Ir{async _call(e){return new G(await super._call(e))}},U_=class extends Ir{async _call(e){return new he(await super._call(e))}},j_=class extends Ir{async _call(e){return new Me(await super._call(e))}};var So=class extends y{},G_=class extends So{},q_=class extends So{async _call(e){return new G(await super._call(e))}};var To=class extends y{},W_=class extends To{},V_=class extends To{async _call(e){return new G(await super._call(e))}};var Oo=class extends y{},H_=class extends Oo{},X_=class extends Oo{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 Io=class extends y{},K_=class extends Io{},Q_=class extends Io{async _call(e){return new or(await super._call(e))}};var lc=class extends Re{constructor({audio_codes:e}){super(),this.audio_codes=e}},cc=class extends Re{constructor({audio_values:e}){super(),this.audio_values=e}},nn=class extends y{main_input_name="input_values";forward_params=["input_values"]},Y_=class extends nn{async encode(e){return new lc(await de(this.sessions.encoder_model,e))}async decode(e){return new cc(await de(this.sessions.decoder_model,e))}},Co=class extends nn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},Lo=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 Cr=class extends y{},J_=class extends Cr{},Z_=class extends Cr{async _call(e){return new we(await super._call(e))}},em=class extends Cr{async _call(e){return new G(await super._call(e))}},tm=class extends Cr{async _call(e){return new he(await super._call(e))}},rm=class extends Cr{async _call(e){return new Me(await super._call(e))}};var Lr=class extends y{},sm=class extends Lr{},nm=class extends Lr{async _call(e){return new we(await super._call(e))}},om=class extends Lr{async _call(e){return new G(await super._call(e))}},am=class extends Lr{async _call(e){return new he(await super._call(e))}},im=class extends Lr{async _call(e){return new Me(await super._call(e))}};var uc=class extends y{},lm=class extends uc{};var Po=class extends y{},cm=class extends Po{},um=class extends Po{async _call(e){return new G(await super._call(e))}};var pc=class extends y{},pm=class extends pc{};var dc=class extends y{},dm=class extends dc{};var on=class extends y{},fm=class extends on{},_m=class extends on{async _call(e){return new an(await super._call(e))}},mm=class extends on{async _call(e){return new fc(await super._call(e))}},an=class extends Re{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}},fc=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 zo=class extends y{},hm=class extends zo{},gm=class extends zo{async _call(e){return new G(await super._call(e))}};var No=class extends y{},wm=class extends No{},xm=class extends No{async _call(e){return new G(await super._call(e))}};var _c=class extends y{},ym=class extends _c{};var mc=class extends y{},bm=class extends mc{};var Pr=class extends y{},vm=class extends Pr{},km=class extends Pr{async _call(e){return new G(await super._call(e))}},Em=class extends Pr{async _call(e){return new he(await super._call(e))}},Am=class extends Pr{async _call(e){return new Me(await super._call(e))}},Mm=class extends Pr{async _call(e){return new we(await super._call(e))}};var hc=class extends y{},Sm=class extends hc{};var $o=class extends y{},Tm=class extends $o{},Om=class extends $o{};var Ro=class extends y{},Im=class extends Ro{},Cm=class extends Ro{async _call(e){return new G(await super._call(e))}};var zr=class extends y{},Lm=class extends zr{},Pm=class extends zr{async _call(e){return new we(await super._call(e))}},zm=class extends zr{async _call(e){return new G(await super._call(e))}},Nm=class extends zr{async _call(e){return new he(await super._call(e))}},$m=class extends zr{async _call(e){return new Me(await super._call(e))}};var Do=class extends y{},Rm=class extends Do{},Dm=class extends Do{};var ps=class extends y{},Fm=class extends ps{},Bm=class extends ps{async _call(e){return new we(await super._call(e))}},Um=class extends ps{async _call(e){return new G(await super._call(e))}},jm=class extends ps{async _call(e){return new he(await super._call(e))}};var Fo=class extends y{},Gm=class extends Fo{},qm=class extends Fo{};var Bo=class extends y{},Wm=class extends Bo{},Vm=class extends Bo{};var Uo=class extends y{},Hm=class extends Uo{},Xm=class extends Uo{};var jo=class extends y{},Km=class extends jo{},Qm=class extends jo{async _call(e){return new G(await super._call(e))}};var gc=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"},Ym=class extends gc{_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([et(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:f}=await Vt(this,{inputs_embeds:l,attention_mask:s});a=f}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 Ct(this,{inputs_embeds:c,attention_mask:o,encoder_attention_mask:s,encoder_hidden_states:a,past_key_values:i},!0)}};var Go=class extends y{},Jm=class extends Go{},Zm=class extends Go{};var qo=class extends y{},eh=class extends qo{},th=class extends qo{};var Wo=class extends y{},rh=class extends Wo{},sh=class extends Wo{};var wc=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 wc{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:f=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 Ct(this,{inputs_embeds:i,per_layer_inputs:l,past_key_values:c,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 co({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 qf({audio_token_id:this.config.audio_token_id,...e,audio_features:s})}},Vo=class extends ln{};var Ho=class extends y{},nh=class extends Ho{},oh=class extends Ho{};var Xo=class extends y{},ah=class extends Xo{},ih=class extends Xo{};var Ko=class extends y{},lh=class extends Ko{},ch=class extends Ko{};var Qo=class extends y{},uh=class extends Qo{},ph=class extends Qo{};var Yo=class extends y{},dh=class extends Yo{},fh=class extends Yo{};var Jo=class extends y{},_h=class extends Jo{},mh=class extends Jo{};var Zo=class extends y{},hh=class extends Zo{},gh=class extends Zo{};var ea=class extends y{},wh=class extends ea{},xh=class extends ea{};var ta=class extends y{},yh=class extends ta{},bh=class extends ta{};var ra=class extends y{},vh=class extends ra{},kh=class extends ra{};var xc=class extends y{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},ds=class extends xc{_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return qf({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:s})}};var Eh=class extends ds{forward_params=["input_ids","attention_mask","input_features","past_key_values"]};var yc=class extends y{},Ah=class extends yc{};var bc=class extends y{},Mh=class extends bc{};var sa=class extends y{},Sh=class extends sa{},Th=class extends sa{};var na=class extends y{},Oh=class extends na{},Ih=class extends na{async _call(e){return new G(await super._call(e))}};var Ht=class extends y{},Ch=class extends Ht{},Lh=class extends Ht{async _call(e){return new kt(await super._call(e))}},Ph=class extends Ht{async _call(e){return new G(await super._call(e))}},zh=class extends Ht{async _call(e){return new he(await super._call(e))}};var Nh=class extends y{},$h=class extends Ht{},Rh=class extends Ht{async _call(e){return new kt(await super._call(e))}},Dh=class extends Ht{async _call(e){return new G(await super._call(e))}};var oa=class extends y{},Fh=class extends oa{},Bh=class extends oa{};var vc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},Ft=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 co({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:s})}},Uh=class extends Ft{},jh=class extends Ft{};var Gh=class extends Ft{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]};var aa=class extends y{},qh=class extends aa{},Wh=class extends aa{async _call(e){return new G(await super._call(e))}};var ia=class extends y{},Vh=class extends ia{},Hh=class extends ia{};var cn=class extends y{},Xh=class extends cn{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=et([e.pixel_values.dims[0],1])),s){let{image_size:c}=this.config.vision_config;e.pixel_values=We([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}},la=class extends cn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},Kh=class extends cn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var ca=class extends y{},Qh=class extends ca{},Yh=class extends ca{};var ua=class extends y{},Jh=class extends ua{},Zh=class extends ua{};var eg=class extends Ft{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]};var pa=class extends y{},tg=class extends pa{},rg=class extends pa{};var kc=class extends y{},sg=class extends kc{};var da=class extends y{},ng=class extends da{},og=class extends da{};var fa=class extends y{},ag=class extends fa{},ig=class extends fa{};var _a=class extends y{},lg=class extends _a{},cg=class extends _a{};var ma=class extends y{},ug=class extends ma{},pg=class extends ma{};var fs=class extends y{},dg=class extends fs{},fg=class extends fs{},_g=class extends fs{async _call(e){return new G(await super._call(e))}},mg=class extends fs{};var Ec=class extends y{},hg=class extends Ec{};var Ac=class extends y{},gg=class extends Ac{};var Mc=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]}},Sc=class extends y{},wg=class extends Sc{async _call(e){return new Mc(await super._call(e))}};var Tc=class extends Re{constructor({audio_codes:e}){super(),this.audio_codes=e}},Oc=class extends Re{constructor({audio_values:e}){super(),this.audio_values=e}},un=class extends y{main_input_name="input_values";forward_params=["input_values"]},xg=class extends un{async encode(e){return new Tc(await de(this.sessions.encoder_model,e))}async decode(e){return new Oc(await de(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"})}},ga=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 wa=class extends y{},yg=class extends wa{},bg=class extends wa{};var _s=class extends y{},vg=class extends _s{},kg=class extends _s{async _call(e){return new we(await super._call(e))}},Eg=class extends _s{async _call(e){return new G(await super._call(e))}},Ag=class extends _s{async _call(e){return new Me(await super._call(e))}};var xa=class extends y{},Mg=class extends xa{},Sg=class extends xa{};var pn=class extends y{},Tg=class extends pn{},Og=class extends pn{async _call(e){return new G(await super._call(e))}},Ig=class extends pn{};var dn=class extends y{},Cg=class extends dn{},Lg=class extends dn{async _call(e){return new G(await super._call(e))}},Pg=class extends dn{};var fn=class extends y{},zg=class extends fn{},Ng=class extends fn{async _call(e){return new G(await super._call(e))}},$g=class extends fn{};var _n=class extends y{},Rg=class extends _n{},Dg=class extends _n{async _call(e){return new G(await super._call(e))}},Fg=class extends _n{};var ya=class extends y{},Bg=class extends ya{},Ug=class extends ya{async _call(e){return new G(await super._call(e))}};var ba=class extends y{},jg=class extends ba{},Gg=class extends ba{async _call(e){return new G(await super._call(e))}};var ms=class extends y{},qg=class extends ms{},Wg=class extends ms{async _call(e){return new we(await super._call(e))}},Vg=class extends ms{async _call(e){return new G(await super._call(e))}},Hg=class extends ms{async _call(e){return new he(await super._call(e))}};var va=class extends y{},Xg=class extends va{},Kg=class extends va{};var ka=class extends y{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},Qg=class extends ka{},Yg=class extends ka{};var Nr=class extends y{},Jg=class extends Nr{},Zg=class extends Nr{async _call(e){return new we(await super._call(e))}},ew=class extends Nr{async _call(e){return new G(await super._call(e))}},tw=class extends Nr{async _call(e){return new he(await super._call(e))}},rw=class extends Nr{async _call(e){return new Me(await super._call(e))}};var Ea=class extends y{},sw=class extends Ea{},nw=class extends Ea{};var Aa=class extends y{},ow=class extends Aa{},aw=class extends Aa{};var Ic=class extends y{},iw=class extends Ic{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=Ye(e,l.inputNames);s=await de(l,c)}else{let l=this.sessions.gen_img_embeds,c=Ye({image_ids:e.input_ids},l.inputNames);s=await de(l,c)}let n={...e,...s},o=await Ct(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,Ye(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,jn(r.input_ids,BigInt(s.pad_token_id))],0),r.attention_mask=ve([r.attention_mask,jn(r.attention_mask,0n)],0))),(n||!r.pixel_values)&&(r.pixel_values=We([0,0,3,384,384],1)),n&&(r.images_seq_mask=new $("bool",new Array(1).fill(!0).fill(!1,0,1),[1,1]),r.images_emb_mask=new $("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=Qe.fromTensor(c);l.push(p)}return l}};var Ma=class extends y{},lw=class extends Ma{},cw=class extends Ma{},Sa=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,f=Math.floor(c/s)%n,_=p-f;_>0&&_<=o&&(e.data[a++]=e.data[c])}let i=Math.floor(r/n),l=a/(i*n);return new $(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)),oc(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 Ta=class extends y{},uw=class extends Ta{},pw=class extends Ta{};var $r=class extends y{},dw=class extends $r{},fw=class extends $r{async _call(e){return new we(await super._call(e))}},_w=class extends $r{async _call(e){return new G(await super._call(e))}},mw=class extends $r{async _call(e){return new he(await super._call(e))}},hw=class extends $r{async _call(e){return new Me(await super._call(e))}};var Cc=class extends y{},gw=class extends Cc{};var Oa=class extends y{},ww=class extends Oa{},xw=class extends Oa{};var Ia=class extends y{},yw=class extends Ia{},bw=class extends Ia{};var Ca=class extends y{},vw=class extends Ca{},kw=class extends Ca{};var La=class extends y{},Ew=class extends La{},Aw=class extends La{};var Pa=class extends y{},Mw=class extends Pa{},Sw=class extends Pa{};var za=class extends y{},Tw=class extends za{},Ow=class extends za{};var Na=class extends y{},Iw=class extends Na{},Cw=class extends Na{};var $a=class extends y{},Lw=class extends $a{},Pw=class extends $a{};var zw=class extends Ft{};var Lc=class extends y{},Nw=class extends Lc{async _call(e){return new kt(await super._call(e))}};var Ra=class extends y{},$w=class extends Ra{},Rw=class extends Ra{};var Da=class extends y{},Dw=class extends Da{},Fw=class extends Da{};var Fa=class extends y{},Bw=class extends Fa{},Uw=class extends Fa{};var Ba=class extends y{},jw=class extends Ba{},Gw=class extends Ba{};var Pc=class extends y{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},Ua=class extends Pc{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 $("float32",[],[0,m])}({inputs_embeds:a}=await de(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:_}))}return await Ct(this,{inputs_embeds:a,past_key_values:i,attention_mask:r,position_ids:o,generation_config:l,logits_processor:c},!1)}};var ja=class extends y{},qw=class extends ja{},Ww=class extends ja{async _call(e){return new G(await super._call(e))}};var Ga=class extends y{},Vw=class extends Ga{},Hw=class extends Ga{async _call(e){return new he(await super._call(e))}};var qa=class extends y{},Xw=class extends qa{},Kw=class extends qa{};var Wa=class extends y{},Qw=class extends Wa{},Yw=class extends Wa{};var zc=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},mn=class extends zc{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,c=o.spatial_merge_size??2,p=[];if(r||s){let f=e.tolist();n||(n=El(e));let _=n.tolist(),m=Array.from({length:3},A=>Array.from({length:e.dims[0]},T=>Array.from({length:e.dims[1]},S=>1))),w=r?r.tolist():[],x=s?s.tolist():[],k=0,E=0;for(let A=0;A<f.length;++A){let T=f[A].filter((L,z)=>_[A][z]==1),P=T.reduce((L,z,R)=>(z==l&&L.push(R),L),[]).map(L=>T[L+1]),O=P.filter(L=>L==a).length,v=P.filter(L=>L==i).length,j=[],H=0,B=O,V=v;for(let L=0;L<P.length;++L){let z=T.findIndex((It,ot)=>ot>H&&It==a),R=T.findIndex((It,ot)=>ot>H&&It==i),J=B>0&&z!==-1?z:T.length+1,Ce=V>0&&R!==-1?R:T.length+1,ae,Ue,Je,rt;J<Ce?([Ue,Je,rt]=w[k],++k,--B,ae=J):([Ue,Je,rt]=x[E],++E,--V,ae=Ce);let[nt,at,Se]=[Number(Ue),Math.floor(Number(Je)/c),Math.floor(Number(rt)/c)],xe=ae-H,He=j.length>0?Pe(j.at(-1))[0]+1:0;j.push(Array.from({length:3*xe},(It,ot)=>He+ot%xe));let Ot=xe+He,ke=nt*at*Se,De=Array.from({length:ke},(It,ot)=>Ot+Math.floor(ot/(at*Se))),qr=Array.from({length:ke},(It,ot)=>Ot+Math.floor(ot/Se)%at),As=Array.from({length:ke},(It,ot)=>Ot+ot%Se);j.push([De,qr,As].flat()),H=ae+ke}if(H<T.length){let L=j.length>0?Pe(j.at(-1))[0]+1:0,z=T.length-H;j.push(Array.from({length:3*z},(R,J)=>L+J%z))}let q=j.reduce((L,z)=>L+z.length,0),Q=new Array(q),F=0;for(let L=0;L<3;++L)for(let z=0;z<j.length;++z){let R=j[z],J=R.length/3;for(let Ce=L*J;Ce<(L+1)*J;++Ce)Q[F++]=R[Ce]}let C=0,te=_[A];for(let L=0;L<te.length;++L)if(te[L]==1){for(let z=0;z<3;++z)m[z][A][L]=Q[z*q/3+C];++C}let le=Pe(Q)[0];p.push(le+1-f[A].length)}return[new $("int64",m.flat(1/0),[3,e.dims[0],e.dims[1]]),new $("int64",p,[p.length,1])]}else if(n){let{data:f,dims:_}=_1(n),m=BigInt64Array.from({length:3*f.length},(x,k)=>f[k%f.length]),w=Array.from({length:_[0]},(x,k)=>Pe(f.subarray(_[1]*k,_[1]*(k+1)))[0]+1n+BigInt(_[1]));return[new $("int64",m,[3,..._]),new $("int64",w,[w.length,1])]}else{let[f,_]=e.dims,m=BigInt64Array.from({length:3*f*_},(w,x)=>BigInt(Math.floor(x%_/f)));return[new $("int64",m,[3,...e.dims]),fp([f,1])]}}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 co({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=Tt([a,a,a],0)}}return r}},hs=class extends mn{};var Va=class extends mn{image_grid_thw_name="image_grid_thw"},gs=class extends hs{image_grid_thw_name="image_grid_thw"};var Ha=class extends y{},Jw=class extends Ha{},Zw=class extends Ha{};var Xa=class extends y{},ex=class extends Xa{},tx=class extends Xa{};var Ka=class extends y{},rx=class extends Ka{},sx=class extends Ka{};var ws=class extends Va{},xs=class extends gs{};var nx=class extends ws{},Qa=class extends xs{};var hn=class extends ws{},ys=class extends hn{};var ox=class extends hn{},Ya=class extends ys{};var Ja=class extends y{},ax=class extends Ja{},ix=class extends Ja{async _call(e){return new G(await super._call(e))}};var Za=class extends y{},lx=class extends Za{},cx=class extends Za{async _call(e){return new Nc(await super._call(e))}},Nc=class extends or{};var Rr=class extends y{},ux=class extends Rr{},px=class extends Rr{async _call(e){return new we(await super._call(e))}},dx=class extends Rr{async _call(e){return new G(await super._call(e))}},fx=class extends Rr{async _call(e){return new he(await super._call(e))}},_x=class extends Rr{async _call(e){return new Me(await super._call(e))}};var Dr=class extends y{},mx=class extends Dr{},hx=class extends Dr{async _call(e){return new we(await super._call(e))}},gx=class extends Dr{async _call(e){return new G(await super._call(e))}},wx=class extends Dr{async _call(e){return new he(await super._call(e))}},xx=class extends Dr{async _call(e){return new Me(await super._call(e))}};var ei=class extends y{},yx=class extends ei{},bx=class extends ei{async _call(e){return new $c(await super._call(e))}},$c=class extends or{};var Rc=class extends Re{constructor({iou_scores:e,pred_masks:r}){super(),this.iou_scores=e,this.pred_masks=r}},Dc=class extends y{},vx=class extends Dc{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??=et(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 Rc(await super._call(e))}};var Fc=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}},Bc=class extends y{},ti=class extends Bc{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??=et(a.slice(0,-1)),e.input_boxes??=We([a[0],0,4],0)}else if(e.input_boxes){let a=e.input_boxes.dims;e.input_labels=We([a[0],a[1],0],-1n),e.input_points=We([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=Ye(e,n.inputNames);return await de(n,o)}async _call(e){return new Fc(await super._call(e))}},kx=class extends ti{},Ex=class extends ti{};var gn=class extends y{},Ax=class extends gn{},Mx=class extends gn{},Sx=class extends gn{};var wn=class extends y{},Tx=class extends wn{},Ox=class extends wn{},Ix=class extends wn{};var ri=class extends y{},Cx=class extends ri{},si=class extends ri{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},Lx=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 ni=class extends y{},Px=class extends ni{},zx=class extends ni{};var xn=class extends y{main_input_name="input_values";forward_params=["input_values"]},Nx=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)}},oi=class extends xn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},ai=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 yn=class extends y{},$x=class extends yn{},Rx=class extends yn{},Dx=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 Vt(this,i),p=l.dims[1]/this.config.reduction_factor,f=Math.floor(p*o),_=Math.floor(p*n),m=this.config.num_mel_bins,w=[],x=null,k=null,E=0;for(;;){++E;let S=f1(!!k),P;k?P=k.output_sequence_out:P=new $("float32",new Float32Array(m),[1,1,m]);let O={use_cache_branch:S,output_sequence:P,encoder_attention_mask:c,speaker_embeddings:r,encoder_hidden_states:l};this.addPastKeyValues(O,x),k=await de(this.sessions.decoder_model_merged,O),x=this.getPastKeyValues(k,x);let{prob:v,spectrum:j}=k;if(w.push(j),E>=_&&(Array.from(v.data).filter(H=>H>=s).length>0||E>=f))break}let A=ve(w),{waveform:T}=await de(a.sessions.model,{spectrogram:A});return{spectrogram:A,waveform:T}}},Fx=class extends y{main_input_name="spectrogram"};var bs=class extends y{},Bx=class extends bs{},Ux=class extends bs{async _call(e){return new we(await super._call(e))}},jx=class extends bs{async _call(e){return new G(await super._call(e))}},Gx=class extends bs{async _call(e){return new Me(await super._call(e))}};var ii=class extends y{},qx=class extends ii{},Wx=class extends ii{};var li=class extends y{},Vx=class extends li{},Hx=class extends li{};var Uc=class extends y{},Xx=class extends Uc{};var jc=class extends y{},ci=class extends jc{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:f}=await de(this.sessions.text_encoder,{input_ids:e,attention_mask:r,style:s}),_=f.div(o).mul_(a),m=l*i,w=_.data,x=Int32Array.from(w,B=>Math.ceil(B/m)),k=Math.max(...x),E=e.dims[0],A=new BigInt64Array(E*k);for(let B=0;B<E;++B)A.fill(1n,B*k,B*k+x[B]);let T=new $("int64",A,[E,k]),S=c*i,P=S*k,O=Wb([E,S,k]),v=O.data;for(let B=0;B<E;++B)if(x[B]!==k)for(let V=0;V<S;++V)v.fill(0,B*P+V*k+x[B],B*P+(V+1)*k);let j=We([E],n);for(let B=0;B<n;++B){let V=We([E],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:V,num_inference_steps:j}))}let{waveform:H}=await de(this.sessions.voice_decoder,{latents:O});return{waveform:H,durations:_}}};var bn=class extends y{},Kx=class extends bn{},Qx=class extends bn{async _call(e){return new G(await super._call(e))}},Yx=class extends bn{};var ui=class extends y{},Jx=class extends ui{},Zx=class extends ui{};var pi=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},ey=class extends pi{},ty=class extends pi{};var di=class extends y{},ry=class extends di{},sy=class extends di{async _call(e){return new Gc(await super._call(e))}},Gc=class extends an{};var qc=class extends y{},ny=class extends qc{};var vn=class extends y{},oy=class extends vn{},ay=class extends vn{async _call(e){return new kt(await super._call(e))}},iy=class extends vn{async _call(e){return new G(await super._call(e))}};var vs=class extends y{},ly=class extends vs{},cy=class extends vs{async _call(e){return new kt(await super._call(e))}},uy=class extends vs{async _call(e){return new G(await super._call(e))}},py=class extends vs{async _call(e){return new he(await super._call(e))}};var fi=class extends y{},dy=class extends fi{},fy=class extends fi{};var _y=class extends y{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var _i=class extends y{},my=class extends _i{},hy=class extends _i{async _call(e){return new G(await super._call(e))}};var Wc=class extends y{},gy=class extends Wc{};var mi=class extends y{},wy=class extends mi{},xy=class extends mi{async _call(e){return new G(await super._call(e))}};var Vc=class extends y{},yy=class extends Vc{async _call(e){return new Uf(await super._call(e))}};var Hc=class extends y{},by=class extends Hc{};var Xc=class extends Re{constructor({waveform:e,spectrogram:r}){super(),this.waveform=e,this.spectrogram=r}},Kc=class extends y{},vy=class extends Kc{async _call(e){return new Xc(await super._call(e))}};var ky=class extends ds{};var H2=2,qz=1,m1=new WeakMap;function Wz(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 ao,c=n?.config?.kv_cache_dtype??"float32",p=c==="float16"?Ar.float16:Ar.float32,f=Qs(s,{batch_size:1});for(let w in f){let x=f[w].reduce((k,E)=>k*E,1);l[w]=new $(c,new p(x),f[w])}let _=new $(c,new p(i*H2),[1,i,H2]),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 Vz(t,e){let r=e.dims[2],s=Math.floor((qz+r-3)/2)+1,n=new $("int64",BigInt64Array.from({length:s},(p,f)=>BigInt(t.enc_past_seq_len+f)),[1,s]),o=t.enc_past_seq_len+s,a=et([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 f=p.replace("present","past_key_values"),_=t.enc_kv_cache[f];_?.location==="gpu-buffer"&&_.dispose(),t.enc_kv_cache[f]=c[p]}return t.enc_past_seq_len=o,i}async function Hz(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 Vz(t,r.value);t.audio_embed_queue.push({data:s.data,tokens:s.dims[1]}),t.audio_embed_total_tokens+=s.dims[1]}}function Xz(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 h1=class extends Sr{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)}},Qc=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},hi=class extends Qc{async forward({input_ids:e,past_key_values:r,...s}){let n=e.dims[1],o=m1.get(this);o&&await Hz(o,o.audio_consumed+n);let{inputs_embeds:a}=await de(this.sessions.embed_tokens,{input_ids:e});o&&Xz(o,a,n);let i={inputs_embeds:a,...s};this.addPastKeyValues(i,r);let l=this.sessions.decoder_model_merged,c=Ye(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=Wz(this,e);m1.set(this,n);let o=new Js;o.push(new h1(n)),r&&o.extend(r);try{return await super.generate({...s,stopping_criteria:o})}finally{n.enc_kv_cache.dispose(),m1.delete(this)}}};var kn=class extends y{},Ey=class extends kn{},Ay=class extends kn{async _call(e){return new kt(await super._call(e))}},My=class extends kn{async _call(e){return new G(await super._call(e))}};var Yc=class extends Re{constructor({logits:e,embeddings:r}){super(),this.logits=e,this.embeddings=r}},Fr=class extends y{},Sy=class extends Fr{},Ty=class extends Fr{async _call(e){return new kt(await super._call(e))}},Oy=class extends Fr{async _call(e){return new G(await super._call(e))}},Iy=class extends Fr{async _call(e){return new Yc(await super._call(e))}},Cy=class extends Fr{async _call(e){return new he(await super._call(e))}};var Jc=class extends y{},Ly=class extends Jc{};var Py=class extends oo{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 gi=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"]},zy=class extends gi{},Zc=class extends gi{_prepare_generation_config(e,r){return super._prepare_generation_config(e,r,Py)}_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=`<|${x2(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 cs,s.push(new Xl(r,a))),r.begin_suppress_tokens&&(s??=new cs,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,k)=>ve(a.map(E=>E[k]),2)),l=Tt(r.map(([x,k])=>{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,k,null,[0,s]):i[x].slice(null,k)})).transpose(1,0,2,3),[c,p]=dp(l,-2,0,!0),f=l.clone();for(let x=0;x<f.dims[0];++x){let k=f[x];for(let E=0;E<k.dims[0];++E){let A=k[E],T=c[x][E][0].data,S=p[x][E][0].data;for(let P=0;P<A.dims[0];++P){let O=A[P].data;for(let v=0;v<O.length;++v)O[v]=(O[v]-S[v])/T[v];O.set(PE(O,o))}}}let _=[kl(f,1)],m=e.sequences.dims,w=new $("float32",new Float32Array(m[0]*m[1]),m);for(let x=0;x<m[0];++x){let k=_[x].neg().squeeze_(0),[E,A]=NE(k.tolist()),T=Array.from({length:E.length-1},(O,v)=>E[v+1]-E[v]),S=wt([1],T).map(O=>!!O),P=[];for(let O=0;O<S.length;++O)S[O]&&P.push(A[O]*n);w[x].data.set(P,1)}return w}},Ny=class extends Zc{};var Br=class extends y{},$y=class extends Br{},Ry=class extends Br{async _call(e){return new we(await super._call(e))}},Dy=class extends Br{async _call(e){return new G(await super._call(e))}},Fy=class extends Br{async _call(e){return new he(await super._call(e))}},By=class extends Br{async _call(e){return new Me(await super._call(e))}};var Ur=class extends y{},Uy=class extends Ur{},jy=class extends Ur{async _call(e){return new we(await super._call(e))}},Gy=class extends Ur{async _call(e){return new G(await super._call(e))}},qy=class extends Ur{async _call(e){return new he(await super._call(e))}},Wy=class extends Ur{async _call(e){return new Me(await super._call(e))}};var wi=class extends y{},Vy=class extends wi{},Hy=class extends wi{async _call(e){return new eu(await super._call(e))}},eu=class extends Re{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var xi=class extends y{},Xy=class extends xi{},Ky=class extends xi{};var Kz=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"]]),Qz=new Map([["t5","T5Model"],["longt5","LongT5Model"],["mt5","MT5Model"],["bart","BartModel"],["mbart","MBartModel"],["marian","MarianModel"],["whisper","WhisperModel"],["m2m_100","M2M100Model"],["blenderbot","BlenderbotModel"],["blenderbot-small","BlenderbotSmallModel"]]),Yz=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),Jz=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"]]),X2=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"]]),K2=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),Q2=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),Y2=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"]]),J2=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"]]),Z2=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),eM=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"],["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"],["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"]]),Zz=new Map([["multi_modality","MultiModalityCausalLM"]]),tM=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"]]),rM=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"]]),sM=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),nM=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"]]),oM=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),eN=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),aM=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"]]),iM=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),lM=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),yi=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),cM=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),uM=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),pM=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),dM=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),fM=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),_M=new Map([["wavlm","WavLMForXVector"]]),mM=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),hM=new Map([["vitmatte","VitMatteForImageMatting"]]),tN=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),gM=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),wM=new Map([["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),xM=new Map([["sapiens","SapiensForNormalEstimation"]]),yM=new Map([["vitpose","VitPoseForPoseEstimation"]]),bM=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),g1=[[Kz,K.EncoderOnly],[Qz,K.EncoderDecoder],[Jz,K.DecoderOnlyWithoutHead],[Yz,K.AutoEncoder],[Y2,K.EncoderOnly],[J2,K.EncoderOnly],[Z2,K.Seq2Seq],[X2,K.Seq2Seq],[eM,K.DecoderOnly],[Zz,K.MultiModality],[tM,K.EncoderOnly],[rM,K.EncoderOnly],[sM,K.Vision2Seq],[nM,K.ImageTextToText],[oM,K.AudioTextToText],[aM,K.EncoderOnly],[yi,K.EncoderOnly],[uM,K.EncoderOnly],[cM,K.EncoderOnly],[hM,K.EncoderOnly],[tN,K.EncoderOnly],[gM,K.EncoderOnly],[wM,K.EncoderOnly],[xM,K.EncoderOnly],[yM,K.EncoderOnly],[iM,K.EncoderOnly],[lM,K.EncoderOnly],[pM,K.MaskGeneration],[dM,K.EncoderOnly],[fM,K.EncoderOnly],[K2,K.Seq2Seq],[Q2,K.EncoderOnly],[_M,K.EncoderOnly],[mM,K.EncoderOnly],[bM,K.EncoderOnly]];for(let[t,e]of g1)for(let r of t.values()){sr.set(r,e);let s=tu[r];tn.set(s,r),Gf.set(r,s)}var rN=[["MusicgenForConditionalGeneration",Sa,K.Musicgen],["Phi3VForCausalLM",Ua,K.Phi3V],["CLIPTextModelWithProjection",vo,K.EncoderOnly],["SiglipTextModel",si,K.EncoderOnly],["JinaCLIPTextModel",la,K.EncoderOnly],["ClapTextModelWithProjection",yo,K.EncoderOnly],["ClapAudioModelWithProjection",bo,K.EncoderOnly],["DacEncoderModel",Co,K.EncoderOnly],["DacDecoderModel",Lo,K.EncoderOnly],["MimiEncoderModel",ha,K.EncoderOnly],["MimiDecoderModel",ga,K.EncoderOnly],["SnacEncoderModel",oi,K.EncoderOnly],["SnacDecoderModel",ai,K.EncoderOnly],["Gemma3nForConditionalGeneration",ln,K.ImageAudioTextToText],["SupertonicForConditionalGeneration",ci,K.Supertonic],["ChatterboxModel",xo,K.Chatterbox],["Qwen2VLForCausalLM",hs,K.MultimodalLanguageModelOnly],["Qwen2_5_VLForCausalLM",gs,K.MultimodalLanguageModelOnly],["Qwen3VLForCausalLM",xs,K.MultimodalLanguageModelOnly],["Qwen3VLMoeForCausalLM",Qa,K.MultimodalLanguageModelOnly],["Qwen3_5ForCausalLM",ys,K.MultimodalLanguageModelOnly],["Qwen3_5MoeForCausalLM",Ya,K.MultimodalLanguageModelOnly],["Gemma3nForCausalLM",Vo,K.MultimodalLanguageModelOnly],["VoxtralRealtimeForConditionalGeneration",hi,K.VoxtralRealtime]];for(let[t,e,r]of rN)sr.set(t,r),tn.set(e,t),Gf.set(t,e);var vM=new Map([["modnet",yi],["birefnet",yi],["isnet",yi],["ben",yi]]);for(let[t,e]of vM.entries())e.set(t,"PreTrainedModel"),sr.set(t,K.EncoderOnly),Gf.set(t,y);var kM=new Set(vM.keys());sr.set("PreTrainedModel",K.EncoderOnly);tn.set(y,"PreTrainedModel");var Ne={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:Y2,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:J2,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:K2,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:Q2,MODEL_FOR_MASKED_LM_MAPPING_NAMES:tM,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:rM,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:aM,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:yi,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:cM,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:uM,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:iM,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:lM,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:pM,MODEL_FOR_CTC_MAPPING_NAMES:dM,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:fM,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:_M,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:mM,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:eN,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:hM,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:gM,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:wM,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:xM,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:yM,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:bM,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:nM,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:oM,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:Z2,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:X2,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:eM,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:sM};j2(Ne);var Ie=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:f=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:f,session_options:_};if(m.config=await Rt.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 k=x.get(w);if(!k){for(let E of x.values())if(E[0]===w){k=E;break}if(!k)continue}return await tu[k].from_pretrained(e,m)}if(this.BASE_IF_FAIL)return kM.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}`)}},_r=class extends Ie{static MODEL_CLASS_MAPPINGS=g1.map(e=>e[0]);static BASE_IF_FAIL=!0},bi=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},ru=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},En=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},su=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},nu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},ou=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},au=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},iu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},lu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},cu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},uu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},vi=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},ki=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},Ei=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},pu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},du=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},w1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},fu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_CTC_MAPPING_NAMES]},_u=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},x1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},y1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},mu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},b1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},hu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},gu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},v1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},k1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},wu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},E1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},A1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Ne.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function tt(t){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(e=>Qe.read(e)))}async function ks(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(r=>typeof r=="string"||r instanceof URL?ad(r,e):r instanceof Float64Array?new Float32Array(r):r))}function xu(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 st{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 Ai=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 $("float32",Le(c.data),c.dims),l=[];for(let c of n.logits){let p=i(c),f=await Wt(p,r),_=f[0].tolist(),w=f[1].tolist().map((x,k)=>({label:a?a[x]:`LABEL_${x}`,score:_[k]}));r===1?l.push(...w):l.push(w)}return Array.isArray(e)||r===1?l:l[0]}};var Mi=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],f=a[c],_=[];for(let m=0;m<f.dims[0];++m){let w=f[m],x=Pe(w.data)[1],k=i?i[x]:`LABEL_${x}`;if(r.includes(k))continue;let E=this.tokenizer.decode([p[m].item()],{skip_special_tokens:!0});if(E==="")continue;let A=Le(w.data);_.push({entity:k,score:A[x],index:m,word:E})}l.push(_)}return s?l:l[0]}};var Si=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:f}=this.tokenizer,_=[];for(let m=0;m<a.dims[0];++m){let w=l[m],x=w.findIndex(O=>O==f),k=a[m].tolist(),E=i[m].tolist();for(let O=1;O<k.length;++O)(c[m]==0||O<=x||p.findIndex(v=>v==w[O])!==-1)&&(k[O]=-1/0,E[O]=-1/0);let A=Le(k).map((O,v)=>[O,v]),T=Le(E).map((O,v)=>[O,v]);A[0][0]=0,T[0][0]=0;let S=jk(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]),P=[];for(let O=0;O<Math.min(S.length,s);++O){let[v,j,H]=S[O],B=w.slice(v,j+1),V=this.tokenizer.decode(B,{skip_special_tokens:!0});P.push({answer:V,score:H})}s===1?_.push(...P):_.push(P)}return o?_:_[0]}};var Ti=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],f=p.findIndex(k=>k==s);if(f===-1)throw Error(`Mask token (${n}) not found in text.`);let _=a[c][f],m=await Wt(new $("float32",Le(_.data),_.dims),r),w=m[0].tolist(),x=m[1].tolist();i.push(x.map((k,E)=>{let A=p.slice();return A[f]=k,{score:w[E],token:Number(k),token_str:this.tokenizer.decode([k]),sequence:this.tokenizer.decode(A,{skip_special_tokens:!0})}}))}return Array.isArray(e)?i:i[0]}};var mr=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 Oi=class extends mr{_key="summary_text"};var Ii=class extends mr{_key="translation_text"};function EM(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var Ci=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(EM(e))e=[e];else if(Array.isArray(e)&&e.every(EM))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}),f=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<f.length;++w){let x=Math.floor(w/p.dims[0]*e.length);_&&(f[w]=f[w].slice(_[x])),m[x].push({generated_text:n?[...e[x],{role:"assistant",content:f[w]}]:f[w]})}return!s&&m.length===1?m[0]:m}};var Li=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=>Le(m)[1]):Le(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 Pi=class extends _e{async _call(e,{top_k:r=5}={}){let s=this.processor.feature_extractor.config.sampling_rate,n=await ks(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 Wt(new $("float32",Le(p.data),p.dims),r),_=f[0].tolist(),w=f[1].tolist().map((x,k)=>({label:o?o[x]:`LABEL_${x}`,score:_[k]}));a.push(w)}return Array.isArray(e)?a:a[0]}};var zi=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 ks(e,i),c=[];for(let p of l){let f=await this.processor(p),_=await this.model({...a,...f}),m=Le(_.logits_per_audio.data);c.push([...m].map((w,x)=>({score:w,label:r[x]})))}return n?c[0]:c}};var Ni=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 ks(n,o),i=[];for(let l of a){let c=await this.processor(l),f=(await this.model(c)).logits[0],_=[];for(let w of f)_.push(Pe(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,f=p.chunk_length/this.model.config.max_source_positions,_=p.hop_length,m=p.sampling_rate,w=await ks(c,m),x=[];for(let k 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 S=m*n,P=m*a,O=S-2*P,v=0;for(;;){let j=v+S,H=k.subarray(v,j),B=await this.processor(H),V=v===0,q=j>=k.length;if(E.push({stride:[H.length,V?0:P,q?0:P],input_features:B.input_features,is_last:q}),q)break;v+=O}}else E=[{stride:[k.length,0,0],input_features:(await this.processor(k)).input_features,is_last:!0}];for(let S of E){i.num_frames=Math.floor(S.stride[0]/_);let P=await this.model.generate({inputs:S.input_features,...i});s==="word"?(S.tokens=P.sequences.tolist()[0],S.token_timestamps=P.token_timestamps.tolist()[0].map(O=>zs(O,2))):S.tokens=P[0].tolist(),S.stride=S.stride.map(O=>O/m)}let[A,T]=this.tokenizer._decode_asr(E,{time_precision:f,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 ks(n,o),i=[];for(let l of a){let c=await this.processor(l),p=Math.floor(l.length/o)*6,f=await this.model.generate({max_new_tokens:p,...r,...c}),_=this.processor.batch_decode(f,{skip_special_tokens:!0})[0];i.push({text:_})}return s?i[0]:i}};var $i=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 $("float32",e,[e.length]);else if(!(e instanceof $))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 f=l?Math.min(Math.ceil(l[p]),i):i,_=p*i;c.push(new Vn(o.slice(_,_+f),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 _r.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 Ri=class extends _e{async _call(e,r={}){let s=Array.isArray(e),n=await tt(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 Di=class extends _e{async _call(e,{top_k:r=5}={}){let s=await tt(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 Wt(new $("float32",Le(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 AM={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},Es=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 tt(e),p=c.map(A=>[A.height,A.width]),f=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 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=AM[i];else if(this.processor.image_processor){for(let[A,T]of Object.entries(AM))if(T in this.processor.image_processor){x=this.processor.image_processor[T].bind(this.processor.image_processor),i=A;break}}let k=this.model.config.id2label,E=[];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 P=new Uint8ClampedArray(T.data.length);for(let v=0;v<T.data.length;++v)T.data[v]===S.id&&(P[v]=255);let O=new Qe(P,T.dims[1],T.dims[0],1);E.push({score:S.score,label:k[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 P=new Uint8ClampedArray(A.data.length);for(let v=0;v<A.data.length;++v)A.data[v]===S&&(P[v]=255);let O=new Qe(P,A.dims[1],A.dims[0],1);E.push({score:null,label:k[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 P=p[S],O=T[S];O.data.some(j=>j<-1e-5||j>1+1e-5)&&O.sigmoid_();let v=await Qe.fromTensor(O.mul_(255).to("uint8")).resize(P[1],P[0]);E.push({label:null,score:null,mask:v})}}return E}};var Fi=class extends Es{async _call(e,r={}){let s=await tt(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 Bi=class extends _e{async _call(e,r,{hypothesis_template:s="This is a photo of {}"}={}){let n=Array.isArray(e),o=await tt(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:_=>Le(_.data),f=[];for(let _ of c.logits_per_image){let w=[...p(_)].map((x,k)=>({score:x,label:r[k]}));w.sort((x,k)=>k.score-x.score),f.push(w)}return n?f:f[0]}};var Ui=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 tt(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:f}=this.model.config,_=p.map(m=>m.boxes.map((w,x)=>({score:m.scores[x],label:f[m.classes[x]],box:xu(w,!s)})));return n?_:_[0]}};var ji=class extends _e{async _call(e,r,{threshold:s=.1,top_k:n=null,percentage:o=!1}={}){let a=Array.isArray(e),i=await tt(e),l=this.tokenizer(r,{padding:!0,truncation:!0}),c=await this.processor(i),p=[];for(let f=0;f<i.length;++f){let _=i[f],m=o?null:[[_.height,_.width]],w=c.pixel_values[f].unsqueeze_(0),x=await this.model({...l,pixel_values:w}),k;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:m})[0];k=E.boxes.map((A,T)=>({score:E.scores[T],label:E.labels[T],box:xu(A,!o)}))}else{let E=this.processor.image_processor.post_process_object_detection(x,s,m,!0)[0];k=E.boxes.map((A,T)=>({score:E.scores[T],label:r[E.classes[T]],box:xu(A,!o)}))}k.sort((E,A)=>A.score-E.score),n!==null&&(k=k.slice(0,n)),p.push(k)}return a?p:p[0]}};var Gi=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 tt(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 qi=class extends _e{async _call(e){let r=await tt(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(Qe.fromTensor(i))}return Array.isArray(e)?o:o[0]}};var Wi=class extends _e{async _call(e){let r=await tt(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,f]=r[a].size,_=(await bt(i.view(1,1,l,c),{size:[f,p],mode:"bilinear"})).view(f,p),m=_.min().item(),w=_.max().item(),x=_.sub(m).div_(w-m).mul_(255).to("uint8").unsqueeze(0),k=Qe.fromTensor(x);o.push({predicted_depth:_,depth:k})}return Array.isArray(e)?o:o[0]}};var Vi=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=Gb(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=Vb(l,o)),l}};var Hi=class extends _e{async _call(e,{pool:r=null}={}){let s=await tt(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 Xi=Object.freeze({"text-classification":{pipeline:Ai,model:bi,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:Mi,model:ru,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:Si,model:lu,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:Ti,model:iu,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:Oi,model:En,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:Ii,model:En,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:mr,model:En,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:Ci,model:au,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:Li,model:bi,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:Pi,model:_u,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:zi,model:_r,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:Ni,model:[su,fu],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:$i,model:[ou,nu],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:Ri,model:cu,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:Di,model:uu,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:Es,model:[vi,ki,Ei],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:Fi,model:[vi,ki,Ei],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:Bi,model:_r,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:Ui,model:pu,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:ji,model:du,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:Gi,model:mu,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:qi,model:hu,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Wi,model:gu,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:Vi,model:_r,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:Hi,model:[wu,_r],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),Qy=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});function sN(t,{config:e=null,cache_dir:r=null,local_files_only:s=!1,revision:n="main"}={}){if(e!==null)return Rt.from_pretrained(t,{config:e,cache_dir:r,local_files_only:s,revision:n});let o=JSON.stringify([t,r,s,n]);return Gu(o,()=>Rt.from_pretrained(t,{config:e,cache_dir:r,local_files_only:s,revision:n}))}async function Yy(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null}={}){e=await sN(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,f,_=e.architectures||[],m=!1;for(let E of _){let A=sr.get(E);if(A!==void 0){f=A,m=!0;break}}if(!m&&e.model_type){let E=sr.get(e.model_type);if(E!==void 0&&(f=E,m=!0),!m){for(let A of Object.values(en))if(A.has(e.model_type)){f=sr.get(A.get(e.model_type)),m=!0;break}}}if(!m){let E=_.length>0?_.join(", "):"(none)";Z.warn(`[get_model_files] Architecture(s) not found in MODEL_TYPE_MAPPING: [${E}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${as}`),f=K.EncoderOnly}let w=(E,A=null)=>{A=A??E;let T=lp(c,E),S=cp(p,E,T),P=yl[S]??"",O=`${A}${P}.onnx`,v=l?`${l}/${O}`:O;o.push(v);let j=s1(i,O,E);for(let H of n1(O,j)){let B=l?`${l}/${H}`:H;o.push(B)}},{sessions:x,optional_configs:k}=G2(f,e,{model_file_name:n});for(let[E,A]of Object.entries(x))w(E,A);if(k)for(let E of Object.values(k))o.push(E);return o}async function Jy(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 Yy(t,{config:e,dtype:r,device:s,model_file_name:n});if(o){let l=await Gn(t);i.push(...l)}if(a){let l=await Jy(t);i.push(...l)}return i}async function Gr(t,e,r={}){t=Qy[t]??t;let s=Xi[t];if(!s)throw new Error(`Unsupported pipeline task: ${t}. Must be one of [${Object.keys(Xi).join(", ")}]`);let{type:n}=s;return jr(e,{...r,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"})}async function nN(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:f=null,session_options:_={}}={}){t=Qy[t]??t;let m=Xi[t.split("_",1)[0]];if(!m)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(Xi)}]`);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 Gr(t,e,{device:i,dtype:l}),x={};r&&(await Promise.all(w.map(async V=>pr(e,V)))).forEach((V,q)=>{V.exists&&(x[w[q]]={loaded:0,total:V.size??0})});let k={progress_callback:r?B=>{if(B.status==="progress"){x[B.file]={loaded:B.loaded,total:B.total};let V=Object.values(x).reduce((F,C)=>F+C.loaded,0),q=Object.values(x).reduce((F,C)=>F+C.total,0),Q=q>0?V/q*100:0;r({status:"progress_total",name:B.name,progress:Q,loaded:V,total:q,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:f,session_options:_},E=w.includes("tokenizer.json"),A=w.includes("preprocessor_config.json"),T=m.model,S;if(Array.isArray(T)){let B=s??await Rt.from_pretrained(e,k),{model_type:V}=B,q=T.find(Q=>Q.supports(V));if(!q)throw Error(`Unsupported model type "${V}" for task "${t}". None of the candidate model classes support this type.`);S=q.from_pretrained(e,{...k,config:B})}else S=T.from_pretrained(e,k);let[P,O,v]=await Promise.all([E?oe.from_pretrained(e,k):null,A?Wl.from_pretrained(e,k):null,S]),j={task:t,model:v};P&&(j.tokenizer=P),O&&(j.processor=O),kr(r,{status:"ready",task:t,model:e});let H=m.pipeline;return new H(j)}var oN=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")}},MM=ie.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),e0=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??MM,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=wt(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
|
-
`)}},M1=class extends e0{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 Ki=class{constructor(e,r){this.image=e,this.timestamp=r}},yu=class{constructor(e,r){e.length>0&&e[0]instanceof Qe&&(e=e.map((s,n)=>new Ki(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 SM(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(f=>n.onloadedmetadata=f),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 f=0;f<a;++f)l.push(e===1?o/2:f*i);let c=document.createElement("canvas");c.width=n.videoWidth,c.height=n.videoHeight;let p=c.getContext("2d",{willReadFrequently:!0});for(let f of l){n.currentTime=f,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 Qe(_.data,c.width,c.height,4),w=new Ki(m,f);s.push(w)}return n.remove(),new yu(s,o)}async function t0(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}=Yr(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 TM(t,e,r={}){let s=await er(r?.cache_dir);if(!s)return!1;let{localPath:n,proposedCacheKey:o}=Yr(t,e,r,s);return!!await Jr(s,n,o)}async function OM(t,e={}){if(!t)throw new Error("modelId is required");if(!await TM(t,"config.json",e))return!1;let r=await jr(t,e);return(await t0(t,r,e)).allCached}async function IM(t,e={}){if(!t)throw new Error("modelId is required");let r=await jr(t,e);return await t0(t,r,e)}async function CM(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");if(!await TM(e,"config.json",r))return!1;let s=await Gr(t,e,r);return(await t0(e,s,r)).allCached}async function LM(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 t0(e,s,r)}async function PM(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}=Yr(t,o,r,s),c=!!await Jr(s,a,i),p=!1;if(c){let f=await s.delete(i),_=!f&&i!==a?await s.delete(a):!1;p=f||_}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 zM(t,e={}){if(!t)throw new Error("modelId is required");let r=await jr(t,e);return await PM(t,r,e)}async function NM(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 PM(e,s,r)}var r0=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 Yy(e,r)}static async get_tokenizer_files(e){return Gn(e)}static async get_processor_files(e){return Jy(e)}static async is_cached(e,r={}){return OM(e,r)}static async is_cached_files(e,r={}){return IM(e,r)}static async is_pipeline_cached(e,r,s={}){return CM(e,r,s)}static async is_pipeline_cached_files(e,r,s={}){return LM(e,r,s)}static async get_file_metadata(e,r,s={}){return pr(e,r,s)}static async clear_cache(e,r={}){return zM(e,r)}static async clear_pipeline_cache(e,r,s={}){return NM(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,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,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,GlmForCausalLM,GlmModel,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,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,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,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});
|
|
27
|
+
${s}${o}`+n.repeat(t)+`${s}`,a}function oN(t,e,r,s){return`${e}${s}`+r.repeat(t)+`${e}`}function aN(t,e,r,s,n,o){return t===0&&e===0?oN(r,s,n,o):nN(r,t,e,s,n,o)}var Vl=class extends te{static image_processor_class=Ae;static tokenizer_class=se;static uses_processor_config=!0;fake_image_token="<fake_token_around_image>";image_token="<image>";global_img_token="<global-img>";async _call(e,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 f=0;f<e.length;++f){let _=e[f],m=o[f],w=a[f];l.push(bE(_,this.image_token));let x=m.map((A,T)=>aN(A,w[T],i,this.fake_image_token,this.image_token,this.global_img_token)),k=_.split(this.image_token);if(k.length===0)throw new Error("The image token should be present in the text.");let E=k[0];for(let A=0;A<x.length;++A)E+=x[A]+k[A+1];c.push(E)}return{...this.tokenizer(c),...n}}};var Mf=class extends te{static image_processor_class=Ae;static tokenizer_class=se;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(k=>k.images).flatMap(k=>k.images).map(k=>Ke.read(k)));let n=this.tokenizer,o=n.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:s}),a=k=>n.encode(k,{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,f]=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 k=1;k<i.length;++k){let E=new Array(this.num_image_tokens).fill(c),A=a(i[k]);_=ht(_,[p],E,[f],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 k=await this.image_processor(r);return k.pixel_values.unsqueeze_(0),{...x,...k}}return x}};var Sf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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 Tf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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:f=16,use_thumbnail:_=!0}=this.image_processor.config,m=T=>Math.ceil(Math.floor(T/f)/p),w=m(c)**2,x=this.config.image_start_token??"<|image_start|>",k=this.config.image_end_token??"<|image_end|>",E=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(P=>{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 K=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}|>`+K;_&&(G+=E+l.repeat(H))}else G+=l.repeat(H);return G+k+P}).join("")})}return{...i,...r?this.tokenizer(r,s):{}}}};var Of=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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,f=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(f))}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var fM={char:["char_decode",1],bpe:["bpe_decode",2],wp:["wp_decode",102]},If=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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(!fM.hasOwnProperty(r))throw new Error(`Format ${r} is not supported.`);let[s,n]=fM[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 E=1;E<i;++E){let[A,T]=Pe(Ce(m[E]));if(x.push(A),T==n)break;w.push(T)}let k=x.length>0?x.reduce((E,A)=>E*A,1):0;c.push(w),l.push(k)}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=[],f=[];for(let _=0;_<n.length;++_){let[m,w]=Pe([o[_],i[_],c[_]]);p.push([n[_],a[_],l[_]][w]),f.push(m)}return{generated_text:p,scores:f,char_preds:n,bpe_preds:a,wp_preds:l}}static async from_pretrained(...e){let r=await super.from_pretrained(...e),s=await se.from_pretrained("Xenova/gpt2"),n=await se.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 Cf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Pf=class extends te{static tokenizer_class=se;static image_processor_class=Ae};var eo="<image>";function iN(t,e,r,s,n){return`${s.repeat(r*n)}${e}${t}
|
|
28
|
+
`}var zf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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(eo))?a=r.map(c=>{let p=c.replaceAll(eo,eo.repeat(o)),f=p.lastIndexOf(eo),_=f===-1?0:f+eo.length;return p.slice(0,_)+n+p.slice(_)+`
|
|
29
|
+
`}):(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=>iN(c,n,o,eo,e.length)));let i=this.tokenizer(a,s);return{...await this.image_processor(e,s),...i}}};var _M="<|image|>",lN=/<\|image_\d+\|>/g,Lf=class extends te{static image_processor_class=Ae;static tokenizer_class=se;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((f,_)=>f.split(lN).join(_M.repeat(l[_])));a=this.tokenizer(c,{padding:s,truncation:n});let p=this.tokenizer._tokenizer.token_to_id(_M);a.input_ids.map_(f=>f==p?-f:f)}else a=this.tokenizer(e);return{...a,...i}}};var Nf=class extends te{static tokenizer_class=se;static image_processor_class=Ae;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:f,spatial_merge_size:_}=this.config,m=f*_,w=Math.floor(a/m),x=Math.floor(i/m);r=structuredClone(r),Array.isArray(r)||(r=[r]);for(let k=0;k<r.length;++k){let E=l.repeat(x),A=E+c,T=E+p,S=A.repeat(w-1)+T;r[k]=r[k].replace(l,S)}}let o=r?this.tokenizer(r,s):{};return{...n,...o}}};var $f=class extends te{static feature_extractor_class=Xn;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 to=class extends ls{};var Rf=class extends to{};var ro=class extends te{static image_processor_class=Ae;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 Hl=class extends ro{},Df=class extends Hl{};var Uf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Bf=class extends te{static tokenizer_class=se;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 Ff="[AUDIO]",cN="[BEGIN_AUDIO]",uN=375;function pN(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 jf=class extends te{static tokenizer_class=se;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(Ff))throw new Error(`The input text does not contain the audio token ${Ff}.`);Array.isArray(r)||(r=[r]);let a=e.split(Ff),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=>pN(w,l)),p=c.map(w=>w.length),f=c.flat(),_=(await Promise.all(f.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+=cN;for(let x=0;x<p[w];++x)m+=Ff.repeat(uN);m+=a[w+1]}e=m}return{...this.tokenizer(e,{add_special_tokens:!1,...s}),...n}}};var mM=32,z1=6,Gf=8,dN=10,fN=32,qf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;static uses_processor_config=!1;get num_mel_frames_first_audio_chunk(){return(z1+1)*Gf}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 Gf*e+r}get num_right_pad_tokens(){return z1+1+dN}get audio_length_per_tok(){return Gf}get raw_audio_length_per_tok(){return Gf*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=mM*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+(mM+z1),c=new BigInt64Array(l).fill(BigInt(fN));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 Wf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Vf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Hf=class extends te{static tokenizer_class=se;static feature_extractor_class=We;async _call(e){return await this.feature_extractor(e)}};var Xl=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&&Xf[a])return Xf[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=Zn[n.replace(/Fast$/,"")];if(!c)throw new Error(`Unknown image_processor_type: '${n}'.`);i.image_processor=new c(s)}if(o){let c=Zn[o];if(c)i.image_processor=new c(s);else{let p=Il[o];if(!p)throw new Error(`Unknown feature_extractor_type: '${o}'.`);i.feature_extractor=new p(s)}}let l={};return new te(l,i,null)}};async function _N(t,e){return await ut(t,"config.json",!0,e)}function so(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=so(t.text_config);break;case"moondream1":r=so(t.phi_config);break;case"musicgen":r=so(t.decoder);break;case"multi_modality":r=so(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=so(t.decoder),o="num_decoder_layers"in n,a=Ye(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,...Ye(t,["model_type","multi_query","is_encoder_decoder"])};for(let n in e)s[n]=t[e[n]];return s}function Hs(t,e){t instanceof Vs||(t=new Vs(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,f=c/i;for(let _=0;_<a.length;++_)if(a[_]==="full_attention")for(let m of["key","value"])o[`${s}.${_}.${m}`]=[r,l,0,f];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,f=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,k=(o.mamba_d_ssm??(o.mamba_expand?o.mamba_expand*o.hidden_size:p*f))+2*m*_,E={};for(let A=0;A<i;++A)if((!a||a[A]==="mamba")&&(E[`${n}_conv.${A}`]=[r,k,w],E[`${n}_ssm.${A}`]=[r,p,f,_]),!a||a[A]==="attention")for(let T of["key","value"])E[`${s}.${A}.${T}`]=[r,l,0,c];return E}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:f,linear_num_key_heads:_,linear_key_head_dim:m,linear_value_head_dim:w,linear_conv_kernel_dim:x}=t,k=m*_,E=w*f,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,k,x],o[`${n}_conv.${T}.value`]=[r,E,x],o[`${n}_conv.${T}.query`]=[r,k,x];else{let S=k*2+E;o[`${n}_conv.${T}`]=[r,S,x]}o[`${n}_recurrent.${T}`]=[r,f,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,Hs(s,e)}return mN(t,e)}function mN(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 Vs=class t{model_type=null;is_encoder_decoder=!1;max_position_embeddings;"transformers.js_config";constructor(e){Object.assign(this,e),this.normalized_config=so(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 _N(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 Vs.from_pretrained(...e)}};function L1(t,e,r){return t?typeof t=="object"&&t!==null?t.hasOwnProperty(e)?+t[e]:t.hasOwnProperty(r)?+t[r]:0:+t:0}function N1(t,e){let r=[];for(let s=0;s<e;++s)r.push(`${t}_data${s===0?"":"_"+s}`);return r}async function hM(t,e,r,s){let n=`${e}${s}.onnx`,o=`${r.subfolder??""}/${n}`;return await fl(t,o,!0,r,ie.IS_NODE_ENV)}async function gM(t,e,r,s,n,o={}){let a=`${e}${r}.onnx`,i=ie.IS_NODE_ENV,l=[],c=L1(n,a,e);if(c>0){if(c>Vu)throw new Error(`The number of external data chunks (${c}) exceeds the maximum allowed value (${Vu}).`);let p=N1(a,c);for(let f of p){let _=`${s.subfolder??""}/${f}`;l.push(new Promise(async(m,w)=>{let x=await fl(t,_,!0,s,i);m(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 fl(t,p.data,!0,s);return{...p,data:f}}return p}));return Promise.all(l)}async function hN(t,e,r,s=!1,n=void 0){let o=r.config?.["transformers.js_config"]??{},a=fp(r.device??o.device,e,{warn:S=>Z.info(S)}),i=j2(a),l=o.device_config??{};l.hasOwnProperty(a)&&(o={...o,...l[a]});let c=_p(r.dtype??o.dtype,e,a,{configDtype:o.dtype,warn:S=>Z.info(S)});if(ns.hasOwnProperty(c)){if(a==="webgpu"&&!ie.IS_NODE_ENV&&c===wt.fp16&&!await V2())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,f=p?typeof p=="string"?p:p[c]??"float32":void 0;if(f&&!["float32","float16"].includes(f))throw new Error(`Invalid kv_cache_dtype: ${f}. Should be one of: float32, float16`);let _=ns[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=hM(t,e,r,_),k=r.use_external_data_format??o.use_external_data_format,E=await gM(t,e,_,r,k,m);if(E.length>0&&!ie.IS_NODE_ENV&&(m.externalData=E),s&&a==="webgpu"&&p!==!1){let S=Hs(r.config,{prefix:"present",session_name:n});if(Object.keys(S).length>0&&!kl()){let P={};for(let O in S)P[O]="gpu-buffer";m.preferredOutputLocation=P}}return{buffer_or_path:await x,session_options:m,session_config:{dtype:c,kv_cache_dtype:f,device:a}}}async function wM(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 hN(t,e[n],r,o,n),c=await up(a,i,l);return[n,c]})))}function xM(t){for(let e in t)dp(t[e])?t[e]=new N(t[e]):typeof t[e]=="object"&&xM(t[e]);return t}async function de(t,e){let r=gN(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 pp(t,s);return xM(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 gN(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]=kl()?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}},Me=class extends $e{constructor({start_logits:e,end_logits:r}){super(),this.start_logits=e,this.end_logits=r}},vt=class extends $e{constructor({logits:e}){super(),this.logits=e}};var Kf=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")}},no=class extends tt{_call(e,r){throw Error("`_call` should be implemented in a subclass")}},cs=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()}},Kl=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}},Yl=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}},Xs=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}},Ql=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 f=this.timestamp_begin+this.max_initial_timestamp_index;n.subarray(f+1).fill(-1/0)}let l=Qu(n),c=Math.log(l.subarray(this.timestamp_begin).map(Math.exp).reduce((f,_)=>f+_)),p=Pe(l.subarray(0,this.timestamp_begin))[0];c>p&&n.subarray(0,this.timestamp_begin).fill(-1/0)}return r}},Jl=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}},Zl=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}},ec=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}},tc=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}},rc=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}},sc=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}},nc=class extends no{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}},$1=class extends no{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}},R1=class extends no{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 oo=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,Ye(e,Object.getOwnPropertyNames(this)))}};var Ar=class extends tt{_call(e,r){throw Error("StoppingCriteria needs to be subclassed")}},Ks=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()}},oc=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)}},ac=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)})}},D1=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 Ys=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 QE(e)}static getSampler(e){if(e.do_sample)return new B1(e);if(e.num_beams>1)return new F1(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 U1(e)}},U1=class extends Ys{async sample(e){let r=Pe(e.data)[1];return[[BigInt(r),0]]}},B1=class extends Ys{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 Gt(e,r),o=Ce(s.data);return Array.from({length:this.generation_config.num_beams},()=>{let a=this.randomSelect(o);return[n.data[a],Math.log(o[a])]})}},F1=class extends Ys{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 Gt(e,r),o=Ce(s.data);return Array.from({length:this.generation_config.num_beams},(a,i)=>[n.data[i],Math.log(o[i])])}};var j1=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)}},ao=j1;var Qs=null;function bM(t){Qs=t}function G1(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 q1(t){return new N("bool",[t],[1])}var Q={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15,VoxtralRealtime:16},Jf={[Q.DecoderOnly]:{can_generate:!0,forward:Ot,prepare_inputs:io,sessions:(t,e)=>({model:e.model_file_name??"model"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[Q.DecoderOnlyWithoutHead]:{can_generate:!1,forward:Ot,prepare_inputs:io,sessions:(t,e)=>({model:e.model_file_name??"model"})},[Q.Seq2Seq]:{can_generate:!0,forward:Yf,prepare_inputs:ic,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[Q.Vision2Seq]:{can_generate:!0,forward:Yf,prepare_inputs:ic,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[Q.Musicgen]:{can_generate:!0,forward:Yf,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"}},[Q.EncoderDecoder]:{can_generate:!1,forward:Yf,sessions:()=>({model:"encoder_model",decoder_model_merged:"decoder_model_merged"}),cache_sessions:{decoder_model_merged:!0}},[Q.MaskGeneration]:{sessions:()=>({model:"vision_encoder",prompt_encoder_mask_decoder:"prompt_encoder_mask_decoder"})},[Q.ImageTextToText]:{can_generate:!0,forward:yN,prepare_inputs:Qf,sessions:(t,e,r)=>{let s={embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"};return r||(s.vision_encoder="vision_encoder"),t.is_encoder_decoder&&(s.model="encoder_model"),s},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:"generation_config.json"}},[Q.AudioTextToText]:{can_generate:!0,forward:xN,prepare_inputs:Qf,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"}},[Q.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:Qf,sessions:(t,e,r)=>{let s={embed_tokens:"embed_tokens",decoder_model_merged:"decoder_model_merged"};return r||(s.audio_encoder="audio_encoder",s.vision_encoder="vision_encoder"),s},optional_configs:{generation_config:"generation_config.json"}},[Q.Phi3V]:{can_generate:!0,prepare_inputs:Qf,sessions:()=>({prepare_inputs_embeds:"prepare_inputs_embeds",model:"model",vision_encoder:"vision_encoder"}),cache_sessions:{model:!0},optional_configs:{generation_config:"generation_config.json"}},[Q.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"}},[Q.AutoEncoder]:{can_generate:!1,forward:wN,sessions:()=>({encoder_model:"encoder_model",decoder_model:"decoder_model"})},[Q.Supertonic]:{sessions:()=>({text_encoder:"text_encoder",latent_denoiser:"latent_denoiser",voice_decoder:"voice_decoder"})},[Q.Chatterbox]:{can_generate:!0,forward:qt,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"}},[Q.VoxtralRealtime]:{can_generate:!0,prepare_inputs:io,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:qt,sessions:(t,e)=>({model:e.model_file_name??"model"})}};function Zf(t,e,r={}){let s=Jf[t]??Jf.default;return{sessions:s.sessions(e,r),cache_sessions:s.cache_sessions,optional_configs:s.optional_configs}}function yM(t,e){let r=tr.get(t),s=!1,n=e?.architectures?.[0];if(n&&n!==t&&t?.endsWith("ForCausalLM")&&n.endsWith("ForConditionalGeneration")){let o=tr.get(n);o!==void 0&&(r=o,s=!0)}return{typeConfig:Jf[r]??Jf.default,textOnly:s,modelType:r}}var tr=new Map,e_=new Map,Js=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=Js.get(this.constructor),{typeConfig:o}=yM(n,e);this.can_generate=o.can_generate,this._forward=o.forward,this._prepare_inputs_for_generation=o.prepare_inputs,this.can_generate&&this.forward_params.push("past_key_values"),this.custom_config=this.config["transformers.js_config"]??{}}async dispose(){let e=[];for(let 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:f=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:f,session_options:_},w=Js.get(this);s=m.config=await Nt.from_pretrained(e,m);let{typeConfig:x,textOnly:k,modelType:E}=yM(w,s);if(E===void 0){let P=w??s?.model_type;P!=="custom"&&Z.warn(`Model type for '${P}' not found, assuming encoder-only architecture. Please report this at ${os}.`)}let A=x.sessions(s,m,k),T=[wM(e,A,m,x.cache_sessions)];x.optional_configs&&T.push(vN(e,x.optional_configs,m));let S=await Promise.all(T);return new this(s,...S)}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 Zl(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&n.push(new Jl(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&n.push(new rc(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&n.push(new ec(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 tc(r,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&n.push(new Kl(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&n.push(new Yl(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 Xs(e.begin_suppress_tokens,o))}return e.guidance_scale!==null&&e.guidance_scale>1&&n.push(new sc(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 nc(e.temperature)),s!==null&&n.extend(s),n}_prepare_generation_config(e,r,s=oo){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,Ye(r,Object.getOwnPropertyNames(o))),o}_get_stopping_criteria(e,r=null){let s=new Ks;return e.max_length!==null&&s.push(new oc(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&s.push(new ac(e.eos_token_id)),r&&s.extend(r),s}_validate_model_class(){if(!this.can_generate){let e=[Qs.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,Qs.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,Qs.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,Qs.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),r=Js.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=Ye(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,...Ye(p,["inputs_embeds","attention_mask"])}}let{last_hidden_state:o}=await qt(this,r);if(n.guidance_scale!==null&&n.guidance_scale>1)o=ve([o,Fn(o,0)],0),"attention_mask"in r&&(r.attention_mask=ve([r.attention_mask,xp(r.attention_mask)],0));else if(r.decoder_input_ids){let a=G1(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=G1(i)}return s.decoder_attention_mask=Sl(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 f;p?{input_ids:f,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}):f=l[c];let _=f.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),k=Ys.getSampler(r),E=new Array(x).fill(0),A=f.tolist();o&&o.put(A);let T,S={},P={};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 K in G)K in S||(S[K]=[]),S[K].push(G[K])}else this._return_dict_in_generate_keys&&Object.assign(P,Ye(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 K=X[G],R=await k(K);for(let[C,re]of R){let ae=BigInt(C);E[G]+=re,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,...P};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 ao(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=Hs(this.config,{batch_size:n});for(let l in i){let c=i[l].reduce((p,f)=>p*f,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,Ye(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 Yf(t,e){let{encoder_outputs:r,input_ids:s,decoder_input_ids:n,...o}=e;if(!r){let a=Ye(e,t.sessions.model.inputNames);r=(await qt(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 qt(t,e){let r=t.sessions.model,s=Ye(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=xp(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 wN(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=q1(!!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=bN(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=Ye(o,s.inputNames);return await de(s,a)}async function vM(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:f=null,..._}){if(!l){l=await t.encode_text({input_ids:o,..._});let w=Ye(_,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],k=c.get_seq_length();a=ve([Je([o.dims[0],k]),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:f},!0)}async function xN(t,e){return await vM(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 yN(t,e){return await vM(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 W1(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 bN(t,e=null,r=0){let{input_ids:s,inputs_embeds:n,attention_mask:o}=t,{data:a,dims:i}=W1(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 io(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 ic(t,e,r,s){return r.past_key_values&&(e=e.map(n=>[n.at(-1)])),{...r,decoder_input_ids:G1(e)}}function Qf(t,...e){return t.config.is_encoder_decoder?ic(t,...e):io(t,...e)}function kM({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,f,_)=>(f==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],f=e[c];for(let _=0;_<p.length;++_)f[p[_]].data.set(r[l++].data)}return{inputs_embeds:e,attention_mask:n}}function lo({image_token_id:t,inputs_embeds:e,image_features:r,input_ids:s,attention_mask:n}){return kM({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}function t_({audio_token_id:t,inputs_embeds:e,audio_features:r,input_ids:s,attention_mask:n}){return kM({modality_token_id:t,inputs_embeds:e,modality_features:r,input_ids:s,attention_mask:n})}async function vN(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 au={};Ms(au,{ASTForAudioClassification:()=>f_,ASTModel:()=>d_,ASTPreTrainedModel:()=>fo,AfmoeForCausalLM:()=>c_,AfmoeModel:()=>l_,AfmoePreTrainedModel:()=>uo,AlbertForMaskedLM:()=>o_,AlbertForQuestionAnswering:()=>n_,AlbertForSequenceClassification:()=>s_,AlbertModel:()=>r_,AlbertPreTrainedModel:()=>us,ApertusForCausalLM:()=>i_,ApertusModel:()=>a_,ApertusPreTrainedModel:()=>co,ArceeForCausalLM:()=>p_,ArceeModel:()=>u_,ArceePreTrainedModel:()=>po,BartForConditionalGeneration:()=>m_,BartForSequenceClassification:()=>h_,BartModel:()=>__,BartPretrainedModel:()=>Zs,BeitForImageClassification:()=>w_,BeitModel:()=>g_,BeitPreTrainedModel:()=>_o,BertForMaskedLM:()=>y_,BertForQuestionAnswering:()=>k_,BertForSequenceClassification:()=>b_,BertForTokenClassification:()=>v_,BertModel:()=>x_,BertPreTrainedModel:()=>Mr,BlenderbotForConditionalGeneration:()=>A_,BlenderbotModel:()=>E_,BlenderbotPreTrainedModel:()=>mo,BlenderbotSmallForConditionalGeneration:()=>S_,BlenderbotSmallModel:()=>M_,BlenderbotSmallPreTrainedModel:()=>ho,BloomForCausalLM:()=>O_,BloomModel:()=>T_,BloomPreTrainedModel:()=>go,CHMv2ForDepthEstimation:()=>$_,CHMv2PreTrainedModel:()=>uc,CLIPModel:()=>D_,CLIPPreTrainedModel:()=>rr,CLIPSegForImageSegmentation:()=>G_,CLIPSegModel:()=>j_,CLIPSegPreTrainedModel:()=>vo,CLIPTextModel:()=>U_,CLIPTextModelWithProjection:()=>bo,CLIPVisionModel:()=>B_,CLIPVisionModelWithProjection:()=>F_,CamembertForMaskedLM:()=>C_,CamembertForQuestionAnswering:()=>L_,CamembertForSequenceClassification:()=>P_,CamembertForTokenClassification:()=>z_,CamembertModel:()=>I_,CamembertPreTrainedModel:()=>Sr,ChatterboxModel:()=>wo,ChatterboxPreTrainedModel:()=>lc,ChineseCLIPModel:()=>N_,ChineseCLIPPreTrainedModel:()=>cc,ClapAudioModelWithProjection:()=>yo,ClapModel:()=>R_,ClapPreTrainedModel:()=>en,ClapTextModelWithProjection:()=>xo,CodeGenForCausalLM:()=>W_,CodeGenModel:()=>q_,CodeGenPreTrainedModel:()=>ko,Cohere2ForCausalLM:()=>K_,Cohere2Model:()=>X_,Cohere2PreTrainedModel:()=>Ao,CohereForCausalLM:()=>H_,CohereModel:()=>V_,CoherePreTrainedModel:()=>Eo,ConvBertForMaskedLM:()=>Q_,ConvBertForQuestionAnswering:()=>em,ConvBertForSequenceClassification:()=>J_,ConvBertForTokenClassification:()=>Z_,ConvBertModel:()=>Y_,ConvBertPreTrainedModel:()=>Tr,ConvNextForImageClassification:()=>rm,ConvNextModel:()=>tm,ConvNextPreTrainedModel:()=>Mo,ConvNextV2ForImageClassification:()=>nm,ConvNextV2Model:()=>sm,ConvNextV2PreTrainedModel:()=>So,DFineForObjectDetection:()=>lm,DFineModel:()=>im,DFinePreTrainedModel:()=>Oo,DINOv3ConvNextModel:()=>Lm,DINOv3ConvNextPreTrainedModel:()=>gc,DINOv3ViTModel:()=>Nm,DINOv3ViTPreTrainedModel:()=>wc,DPTForDepthEstimation:()=>Gm,DPTModel:()=>jm,DPTPreTrainedModel:()=>$o,DacDecoderModel:()=>Co,DacDecoderOutput:()=>dc,DacEncoderModel:()=>Io,DacEncoderOutput:()=>pc,DacModel:()=>cm,DacPreTrainedModel:()=>tn,DebertaForMaskedLM:()=>pm,DebertaForQuestionAnswering:()=>_m,DebertaForSequenceClassification:()=>dm,DebertaForTokenClassification:()=>fm,DebertaModel:()=>um,DebertaPreTrainedModel:()=>Or,DebertaV2ForMaskedLM:()=>wm,DebertaV2ForQuestionAnswering:()=>bm,DebertaV2ForSequenceClassification:()=>xm,DebertaV2ForTokenClassification:()=>ym,DebertaV2Model:()=>gm,DebertaV2PreTrainedModel:()=>Ir,DecisionTransformerModel:()=>vm,DecisionTransformerPreTrainedModel:()=>fc,DeepseekV3ForCausalLM:()=>hm,DeepseekV3Model:()=>mm,DeepseekV3PreTrainedModel:()=>Po,DeiTForImageClassification:()=>Em,DeiTModel:()=>km,DeiTPreTrainedModel:()=>zo,DepthAnythingForDepthEstimation:()=>Am,DepthAnythingPreTrainedModel:()=>_c,DepthProForDepthEstimation:()=>Mm,DepthProPreTrainedModel:()=>mc,DetrForObjectDetection:()=>Tm,DetrForSegmentation:()=>Om,DetrModel:()=>Sm,DetrObjectDetectionOutput:()=>sn,DetrPreTrainedModel:()=>rn,DetrSegmentationOutput:()=>hc,Dinov2ForImageClassification:()=>Cm,Dinov2Model:()=>Im,Dinov2PreTrainedModel:()=>Lo,Dinov2WithRegistersForImageClassification:()=>zm,Dinov2WithRegistersModel:()=>Pm,Dinov2WithRegistersPreTrainedModel:()=>No,DistilBertForMaskedLM:()=>Bm,DistilBertForQuestionAnswering:()=>Um,DistilBertForSequenceClassification:()=>Rm,DistilBertForTokenClassification:()=>Dm,DistilBertModel:()=>$m,DistilBertPreTrainedModel:()=>Cr,DonutSwinModel:()=>Fm,DonutSwinPreTrainedModel:()=>xc,EdgeTamModel:()=>Jx,EfficientNetForImageClassification:()=>Wm,EfficientNetModel:()=>qm,EfficientNetPreTrainedModel:()=>Ro,ElectraForMaskedLM:()=>Hm,ElectraForQuestionAnswering:()=>Ym,ElectraForSequenceClassification:()=>Xm,ElectraForTokenClassification:()=>Km,ElectraModel:()=>Vm,ElectraPreTrainedModel:()=>Pr,Ernie4_5ForCausalLM:()=>Jm,Ernie4_5Model:()=>Qm,Ernie4_5PretrainedModel:()=>Do,EsmForMaskedLM:()=>eh,EsmForSequenceClassification:()=>th,EsmForTokenClassification:()=>rh,EsmModel:()=>Zm,EsmPreTrainedModel:()=>ps,EuroBertForMaskedLM:()=>nh,EuroBertForSequenceClassification:()=>oh,EuroBertForTokenClassification:()=>ah,EuroBertModel:()=>sh,EuroBertPreTrainedModel:()=>ds,ExaoneForCausalLM:()=>lh,ExaoneModel:()=>ih,ExaonePreTrainedModel:()=>Uo,FalconForCausalLM:()=>uh,FalconH1ForCausalLM:()=>dh,FalconH1Model:()=>ph,FalconH1PreTrainedModel:()=>Fo,FalconModel:()=>ch,FalconPreTrainedModel:()=>Bo,FastViTForImageClassification:()=>_h,FastViTModel:()=>fh,FastViTPreTrainedModel:()=>jo,Florence2ForConditionalGeneration:()=>mh,Florence2PreTrainedModel:()=>yc,GLPNForDepthEstimation:()=>Ch,GLPNModel:()=>Ih,GLPNPreTrainedModel:()=>Ko,GPT2LMHeadModel:()=>Fh,GPT2Model:()=>Bh,GPT2PreTrainedModel:()=>ea,GPTBigCodeForCausalLM:()=>zh,GPTBigCodeModel:()=>Ph,GPTBigCodePreTrainedModel:()=>Yo,GPTJForCausalLM:()=>Gh,GPTJModel:()=>jh,GPTJPreTrainedModel:()=>ta,GPTNeoForCausalLM:()=>Nh,GPTNeoModel:()=>Lh,GPTNeoPreTrainedModel:()=>Qo,GPTNeoXForCausalLM:()=>Rh,GPTNeoXModel:()=>$h,GPTNeoXPreTrainedModel:()=>Jo,Gemma2ForCausalLM:()=>xh,Gemma2Model:()=>wh,Gemma2PreTrainedModel:()=>qo,Gemma3ForCausalLM:()=>kh,Gemma3ForConditionalGeneration:()=>kc,Gemma3Model:()=>vh,Gemma3PreTrainedModel:()=>vc,Gemma3nForCausalLM:()=>Eh,Gemma3nForConditionalGeneration:()=>nn,Gemma3nPreTrainedModel:()=>Ec,GemmaForCausalLM:()=>gh,GemmaModel:()=>hh,GemmaPreTrainedModel:()=>Go,GlmForCausalLM:()=>Mh,GlmModel:()=>Ah,GlmMoeDsaForCausalLM:()=>Th,GlmMoeDsaModel:()=>Sh,GlmMoeDsaPreTrainedModel:()=>Vo,GlmOcrForConditionalGeneration:()=>Oh,GlmPreTrainedModel:()=>Wo,GptOssForCausalLM:()=>Uh,GptOssModel:()=>Dh,GptOssPreTrainedModel:()=>Zo,GraniteForCausalLM:()=>Wh,GraniteModel:()=>qh,GraniteMoeHybridForCausalLM:()=>Hh,GraniteMoeHybridModel:()=>Vh,GraniteMoeHybridPreTrainedModel:()=>sa,GranitePreTrainedModel:()=>ra,GraniteSpeechForConditionalGeneration:()=>Xh,GroundingDinoForObjectDetection:()=>Kh,GroundingDinoPreTrainedModel:()=>Sc,GroupViTModel:()=>Yh,GroupViTPreTrainedModel:()=>Tc,HeliumForCausalLM:()=>Jh,HeliumModel:()=>Qh,HeliumPreTrainedModel:()=>na,HieraForImageClassification:()=>eg,HieraModel:()=>Zh,HieraPreTrainedModel:()=>oa,HubertForCTC:()=>ig,HubertForSequenceClassification:()=>lg,HubertModel:()=>ag,HubertPreTrainedModel:()=>og,HunYuanDenseV1ForCausalLM:()=>ug,HunYuanDenseV1Model:()=>cg,HunYuanDenseV1PreTrainedModel:()=>aa,IJepaForImageClassification:()=>fg,IJepaModel:()=>dg,IJepaPreTrainedModel:()=>ia,Idefics3ForConditionalGeneration:()=>pg,JAISLMHeadModel:()=>mg,JAISModel:()=>_g,JAISPreTrainedModel:()=>la,JinaCLIPModel:()=>hg,JinaCLIPPreTrainedModel:()=>an,JinaCLIPTextModel:()=>ca,JinaCLIPVisionModel:()=>gg,Lfm2ForCausalLM:()=>xg,Lfm2Model:()=>wg,Lfm2MoeForCausalLM:()=>vg,Lfm2MoeModel:()=>bg,Lfm2MoePreTrainedModel:()=>pa,Lfm2PreTrainedModel:()=>ua,Lfm2VlForConditionalGeneration:()=>kg,LightOnOcrForConditionalGeneration:()=>yg,LiteWhisperForConditionalGeneration:()=>d0,Llama4ForCausalLM:()=>Mg,Llama4PreTrainedModel:()=>Oc,LlamaForCausalLM:()=>Ag,LlamaModel:()=>Eg,LlamaPreTrainedModel:()=>da,LlavaForConditionalGeneration:()=>yt,LlavaOnevisionForConditionalGeneration:()=>yt,LlavaPreTrainedModel:()=>bc,LlavaQwen2ForCausalLM:()=>bh,LongT5ForConditionalGeneration:()=>Tg,LongT5Model:()=>Sg,LongT5PreTrainedModel:()=>fa,M2M100ForConditionalGeneration:()=>Ig,M2M100Model:()=>Og,M2M100PreTrainedModel:()=>_a,MBartForCausalLM:()=>Dg,MBartForConditionalGeneration:()=>$g,MBartForSequenceClassification:()=>Rg,MBartModel:()=>Ng,MBartPreTrainedModel:()=>ms,MPNetForMaskedLM:()=>Ew,MPNetForQuestionAnswering:()=>Sw,MPNetForSequenceClassification:()=>Aw,MPNetForTokenClassification:()=>Mw,MPNetModel:()=>kw,MPNetPreTrainedModel:()=>zr,MT5ForConditionalGeneration:()=>Cw,MT5Model:()=>Iw,MT5PreTrainedModel:()=>Sa,MarianMTModel:()=>Pg,MarianModel:()=>Cg,MarianPreTrainedModel:()=>ma,MaskFormerForInstanceSegmentation:()=>Lg,MaskFormerModel:()=>zg,MaskFormerPreTrainedModel:()=>ha,Metric3DForDepthEstimation:()=>Ug,Metric3DPreTrainedModel:()=>Ic,Metric3Dv2ForDepthEstimation:()=>Bg,Metric3Dv2PreTrainedModel:()=>Cc,MgpstrForSceneTextRecognition:()=>Fg,MgpstrModelOutput:()=>Pc,MgpstrPreTrainedModel:()=>zc,MimiDecoderModel:()=>wa,MimiDecoderOutput:()=>Nc,MimiEncoderModel:()=>ga,MimiEncoderOutput:()=>Lc,MimiModel:()=>jg,MimiPreTrainedModel:()=>ln,Mistral4ForCausalLM:()=>Vg,Mistral4Model:()=>Wg,Mistral4PreTrainedModel:()=>ya,MistralForCausalLM:()=>qg,MistralModel:()=>Gg,MistralPreTrainedModel:()=>xa,MobileBertForMaskedLM:()=>Xg,MobileBertForQuestionAnswering:()=>Yg,MobileBertForSequenceClassification:()=>Kg,MobileBertModel:()=>Hg,MobileBertPreTrainedModel:()=>hs,MobileLLMForCausalLM:()=>Jg,MobileLLMModel:()=>Qg,MobileLLMPreTrainedModel:()=>ba,MobileNetV1ForImageClassification:()=>ew,MobileNetV1ForSemanticSegmentation:()=>tw,MobileNetV1Model:()=>Zg,MobileNetV1PreTrainedModel:()=>cn,MobileNetV2ForImageClassification:()=>sw,MobileNetV2ForSemanticSegmentation:()=>nw,MobileNetV2Model:()=>rw,MobileNetV2PreTrainedModel:()=>un,MobileNetV3ForImageClassification:()=>aw,MobileNetV3ForSemanticSegmentation:()=>iw,MobileNetV3Model:()=>ow,MobileNetV3PreTrainedModel:()=>pn,MobileNetV4ForImageClassification:()=>cw,MobileNetV4ForSemanticSegmentation:()=>uw,MobileNetV4Model:()=>lw,MobileNetV4PreTrainedModel:()=>dn,MobileViTForImageClassification:()=>dw,MobileViTModel:()=>pw,MobileViTPreTrainedModel:()=>va,MobileViTV2ForImageClassification:()=>_w,MobileViTV2Model:()=>fw,MobileViTV2PreTrainedModel:()=>ka,ModernBertDecoderForCausalLM:()=>yw,ModernBertDecoderModel:()=>xw,ModernBertDecoderPreTrainedModel:()=>Ea,ModernBertForMaskedLM:()=>hw,ModernBertForSequenceClassification:()=>gw,ModernBertForTokenClassification:()=>ww,ModernBertModel:()=>mw,ModernBertPreTrainedModel:()=>gs,Moondream1ForConditionalGeneration:()=>yh,MoonshineForConditionalGeneration:()=>vw,MoonshineModel:()=>bw,MoonshinePreTrainedModel:()=>Aa,MptForCausalLM:()=>Ow,MptModel:()=>Tw,MptPreTrainedModel:()=>Ma,MultiModalityCausalLM:()=>Pw,MultiModalityPreTrainedModel:()=>$c,MusicgenForCausalLM:()=>Lw,MusicgenForConditionalGeneration:()=>Oa,MusicgenModel:()=>zw,MusicgenPreTrainedModel:()=>Ta,NanoChatForCausalLM:()=>$w,NanoChatModel:()=>Nw,NanoChatPreTrainedModel:()=>Ia,NemotronHForCausalLM:()=>Dw,NemotronHModel:()=>Rw,NemotronHPreTrainedModel:()=>Ca,NeoBertForMaskedLM:()=>Bw,NeoBertForQuestionAnswering:()=>Gw,NeoBertForSequenceClassification:()=>Fw,NeoBertForTokenClassification:()=>jw,NeoBertModel:()=>Uw,NeoBertPreTrainedModel:()=>Lr,NomicBertModel:()=>qw,NomicBertPreTrainedModel:()=>Rc,OPTForCausalLM:()=>rx,OPTModel:()=>tx,OPTPreTrainedModel:()=>Ra,Olmo2ForCausalLM:()=>Xw,Olmo2Model:()=>Hw,Olmo2PreTrainedModel:()=>za,Olmo3ForCausalLM:()=>Yw,Olmo3Model:()=>Kw,Olmo3PreTrainedModel:()=>La,OlmoForCausalLM:()=>Vw,OlmoHybridForCausalLM:()=>Jw,OlmoHybridModel:()=>Qw,OlmoHybridPreTrainedModel:()=>Na,OlmoModel:()=>Ww,OlmoPreTrainedModel:()=>Pa,OpenELMForCausalLM:()=>ex,OpenELMModel:()=>Zw,OpenELMPreTrainedModel:()=>$a,OwlViTForObjectDetection:()=>ax,OwlViTModel:()=>ox,OwlViTPreTrainedModel:()=>Ua,Owlv2ForObjectDetection:()=>nx,Owlv2Model:()=>sx,Owlv2PreTrainedModel:()=>Da,PaliGemmaForConditionalGeneration:()=>ix,ParakeetForCTC:()=>lx,ParakeetPreTrainedModel:()=>Dc,PatchTSMixerForPrediction:()=>ux,PatchTSMixerModel:()=>cx,PatchTSMixerPreTrainedModel:()=>Ba,PatchTSTForPrediction:()=>dx,PatchTSTModel:()=>px,PatchTSTPreTrainedModel:()=>Fa,Phi3ForCausalLM:()=>hx,Phi3Model:()=>mx,Phi3PreTrainedModel:()=>Ga,Phi3VForCausalLM:()=>qa,Phi3VPreTrainedModel:()=>Uc,PhiForCausalLM:()=>_x,PhiModel:()=>fx,PhiPreTrainedModel:()=>ja,PreTrainedModel:()=>y,PvtForImageClassification:()=>wx,PvtModel:()=>gx,PvtPreTrainedModel:()=>Wa,PyAnnoteForAudioFrameClassification:()=>yx,PyAnnoteModel:()=>xx,PyAnnotePreTrainedModel:()=>Va,Qwen2ForCausalLM:()=>vx,Qwen2Model:()=>bx,Qwen2MoeForCausalLM:()=>Ex,Qwen2MoeModel:()=>kx,Qwen2MoePreTrainedModel:()=>Xa,Qwen2PreTrainedModel:()=>Ha,Qwen2VLForCausalLM:()=>Ho,Qwen2VLForConditionalGeneration:()=>on,Qwen2VLPreTrainedModel:()=>Ac,Qwen2_5_VLForCausalLM:()=>Xo,Qwen2_5_VLForConditionalGeneration:()=>fs,Qwen3ForCausalLM:()=>Mx,Qwen3Model:()=>Ax,Qwen3MoeForCausalLM:()=>Tx,Qwen3MoeModel:()=>Sx,Qwen3MoePreTrainedModel:()=>Ya,Qwen3NextForCausalLM:()=>Ix,Qwen3NextModel:()=>Ox,Qwen3NextPreTrainedModel:()=>Qa,Qwen3PreTrainedModel:()=>Ka,Qwen3VLForCausalLM:()=>Ja,Qwen3VLForConditionalGeneration:()=>ws,Qwen3VLMoeForCausalLM:()=>Px,Qwen3VLMoeForConditionalGeneration:()=>Cx,Qwen3_5ForCausalLM:()=>Za,Qwen3_5ForConditionalGeneration:()=>fn,Qwen3_5MoeForCausalLM:()=>Lx,Qwen3_5MoeForConditionalGeneration:()=>zx,RFDetrForObjectDetection:()=>Dx,RFDetrModel:()=>Rx,RFDetrObjectDetectionOutput:()=>Bc,RFDetrPreTrainedModel:()=>ti,RTDetrForObjectDetection:()=>am,RTDetrModel:()=>om,RTDetrObjectDetectionOutput:()=>sr,RTDetrPreTrainedModel:()=>To,RTDetrV2ForObjectDetection:()=>Yx,RTDetrV2Model:()=>Kx,RTDetrV2ObjectDetectionOutput:()=>Fc,RTDetrV2PreTrainedModel:()=>ri,ResNetForImageClassification:()=>$x,ResNetModel:()=>Nx,ResNetPreTrainedModel:()=>ei,RoFormerForMaskedLM:()=>Wx,RoFormerForQuestionAnswering:()=>Xx,RoFormerForSequenceClassification:()=>Vx,RoFormerForTokenClassification:()=>Hx,RoFormerModel:()=>qx,RoFormerPreTrainedModel:()=>$r,RobertaForMaskedLM:()=>Bx,RobertaForQuestionAnswering:()=>Gx,RobertaForSequenceClassification:()=>Fx,RobertaForTokenClassification:()=>jx,RobertaModel:()=>Ux,RobertaPreTrainedModel:()=>Nr,Sam2ImageSegmentationOutput:()=>qc,Sam2Model:()=>si,Sam2PreTrainedModel:()=>Wc,Sam3TrackerModel:()=>Zx,SamImageSegmentationOutput:()=>jc,SamModel:()=>Qx,SamPreTrainedModel:()=>Gc,SapiensForDepthEstimation:()=>ty,SapiensForNormalEstimation:()=>ry,SapiensForSemanticSegmentation:()=>ey,SapiensPreTrainedModel:()=>_n,SegformerForImageClassification:()=>ny,SegformerForSemanticSegmentation:()=>oy,SegformerModel:()=>sy,SegformerPreTrainedModel:()=>mn,SiglipModel:()=>ay,SiglipPreTrainedModel:()=>ni,SiglipTextModel:()=>oi,SiglipVisionModel:()=>iy,SmolLM3ForCausalLM:()=>cy,SmolLM3Model:()=>ly,SmolLM3PreTrainedModel:()=>ai,SnacDecoderModel:()=>li,SnacEncoderModel:()=>ii,SnacModel:()=>uy,SnacPreTrainedModel:()=>hn,SolarOpenForCausalLM:()=>dy,SolarOpenModel:()=>py,SolarOpenPreTrainedModel:()=>ci,SpeechT5ForSpeechToText:()=>_y,SpeechT5ForTextToSpeech:()=>my,SpeechT5HifiGan:()=>hy,SpeechT5Model:()=>fy,SpeechT5PreTrainedModel:()=>gn,SqueezeBertForMaskedLM:()=>wy,SqueezeBertForQuestionAnswering:()=>yy,SqueezeBertForSequenceClassification:()=>xy,SqueezeBertModel:()=>gy,SqueezeBertPreTrainedModel:()=>xs,StableLmForCausalLM:()=>vy,StableLmModel:()=>by,StableLmPreTrainedModel:()=>ui,Starcoder2ForCausalLM:()=>Ey,Starcoder2Model:()=>ky,Starcoder2PreTrainedModel:()=>pi,StyleTextToSpeech2Model:()=>Ay,StyleTextToSpeech2PreTrainedModel:()=>Vc,SupertonicForConditionalGeneration:()=>di,SupertonicPreTrainedModel:()=>Hc,Swin2SRForImageSuperResolution:()=>Iy,Swin2SRModel:()=>Oy,Swin2SRPreTrainedModel:()=>fi,SwinForImageClassification:()=>Sy,SwinForSemanticSegmentation:()=>Ty,SwinModel:()=>My,SwinPreTrainedModel:()=>wn,T5ForConditionalGeneration:()=>Py,T5Model:()=>Cy,T5PreTrainedModel:()=>_i,TableTransformerForObjectDetection:()=>Ly,TableTransformerModel:()=>zy,TableTransformerObjectDetectionOutput:()=>Xc,TableTransformerPreTrainedModel:()=>mi,TrOCRForCausalLM:()=>Ny,TrOCRPreTrainedModel:()=>Kc,UltravoxModel:()=>_s,UltravoxPreTrainedModel:()=>Mc,UniSpeechForCTC:()=>Ry,UniSpeechForSequenceClassification:()=>Dy,UniSpeechModel:()=>$y,UniSpeechPreTrainedModel:()=>xn,UniSpeechSatForAudioFrameClassification:()=>jy,UniSpeechSatForCTC:()=>By,UniSpeechSatForSequenceClassification:()=>Fy,UniSpeechSatModel:()=>Uy,UniSpeechSatPreTrainedModel:()=>ys,VaultGemmaForCausalLM:()=>qy,VaultGemmaModel:()=>Gy,VaultGemmaPreTrainedModel:()=>hi,ViTForImageClassification:()=>Hy,ViTMAEModel:()=>Xy,ViTMAEPreTrainedModel:()=>Yc,ViTMSNForImageClassification:()=>Yy,ViTMSNModel:()=>Ky,ViTMSNPreTrainedModel:()=>wi,ViTModel:()=>Vy,ViTPreTrainedModel:()=>gi,VisionEncoderDecoderModel:()=>Wy,VitMatteForImageMatting:()=>Qy,VitMattePreTrainedModel:()=>Qc,VitPoseForPoseEstimation:()=>Jy,VitPosePreTrainedModel:()=>Jc,VitsModel:()=>Zy,VitsModelOutput:()=>Zc,VitsPreTrainedModel:()=>eu,VoxtralForConditionalGeneration:()=>e0,VoxtralRealtimeForConditionalGeneration:()=>xi,VoxtralRealtimePreTrainedModel:()=>tu,Wav2Vec2BertForCTC:()=>r0,Wav2Vec2BertForSequenceClassification:()=>s0,Wav2Vec2BertModel:()=>t0,Wav2Vec2BertPreTrainedModel:()=>yn,Wav2Vec2ForAudioFrameClassification:()=>ng,Wav2Vec2ForCTC:()=>rg,Wav2Vec2ForSequenceClassification:()=>sg,Wav2Vec2Model:()=>tg,Wav2Vec2PreTrainedModel:()=>Wt,WavLMForAudioFrameClassification:()=>l0,WavLMForCTC:()=>o0,WavLMForSequenceClassification:()=>a0,WavLMForXVector:()=>i0,WavLMModel:()=>n0,WavLMPreTrainedModel:()=>Rr,WeSpeakerResNetModel:()=>c0,WeSpeakerResNetPreTrainedModel:()=>su,WhisperForConditionalGeneration:()=>nu,WhisperModel:()=>p0,WhisperPreTrainedModel:()=>yi,XLMForQuestionAnswering:()=>g0,XLMForSequenceClassification:()=>m0,XLMForTokenClassification:()=>h0,XLMModel:()=>f0,XLMPreTrainedModel:()=>Dr,XLMRobertaForMaskedLM:()=>x0,XLMRobertaForQuestionAnswering:()=>v0,XLMRobertaForSequenceClassification:()=>y0,XLMRobertaForTokenClassification:()=>b0,XLMRobertaModel:()=>w0,XLMRobertaPreTrainedModel:()=>Ur,XLMWithLMHeadModel:()=>_0,XVectorOutput:()=>ru,YolosForObjectDetection:()=>E0,YolosModel:()=>k0,YolosObjectDetectionOutput:()=>ou,YolosPreTrainedModel:()=>bi,YoutuForCausalLM:()=>M0,YoutuModel:()=>A0,YoutuPreTrainedModel:()=>vi});var us=class extends y{},r_=class extends us{},s_=class extends us{async _call(e){return new j(await super._call(e))}},n_=class extends us{async _call(e){return new Me(await super._call(e))}},o_=class extends us{async _call(e){return new ge(await super._call(e))}};var co=class extends y{},a_=class extends co{},i_=class extends co{};var uo=class extends y{},l_=class extends uo{},c_=class extends uo{};var po=class extends y{},u_=class extends po{},p_=class extends po{};var fo=class extends y{},d_=class extends fo{},f_=class extends fo{};var Zs=class extends y{},__=class extends Zs{},m_=class extends Zs{},h_=class extends Zs{async _call(e){return new j(await super._call(e))}};var _o=class extends y{},g_=class extends _o{},w_=class extends _o{async _call(e){return new j(await super._call(e))}};var Mr=class extends y{},x_=class extends Mr{},y_=class extends Mr{async _call(e){return new ge(await super._call(e))}},b_=class extends Mr{async _call(e){return new j(await super._call(e))}},v_=class extends Mr{async _call(e){return new he(await super._call(e))}},k_=class extends Mr{async _call(e){return new Me(await super._call(e))}};var mo=class extends y{},E_=class extends mo{},A_=class extends mo{};var ho=class extends y{},M_=class extends ho{},S_=class extends ho{};var go=class extends y{},T_=class extends go{},O_=class extends go{};var Sr=class extends y{},I_=class extends Sr{},C_=class extends Sr{async _call(e){return new ge(await super._call(e))}},P_=class extends Sr{async _call(e){return new j(await super._call(e))}},z_=class extends Sr{async _call(e){return new he(await super._call(e))}},L_=class extends Sr{async _call(e){return new Me(await super._call(e))}};var kN=4299n,EM=6561n,lc=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"]},wo=class extends lc{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:f=null,speaker_embeddings:_=null,speaker_features:m=null,...w}){let x;if(!a){let E=this.sessions.embed_tokens.inputNames,A={input_ids:e};if(E.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(E.includes("position_ids")&&(A.position_ids=o),{inputs_embeds:a}=await de(this.sessions.embed_tokens,A),p&&f&&_&&m&&(x={audio_features:p,audio_tokens:f,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==EM)-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>=EM?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),io(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],kN),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 cc=class extends y{},N_=class extends cc{};var uc=class extends y{},$_=class extends uc{};var en=class extends y{},R_=class extends en{},xo=class extends en{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},yo=class extends en{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"audio_model"})}};var rr=class extends y{},D_=class extends rr{},U_=class extends rr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},bo=class extends rr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},B_=class extends rr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}},F_=class extends rr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var vo=class extends y{},j_=class extends vo{},G_=class extends vo{};var ko=class extends y{},q_=class extends ko{},W_=class extends ko{};var Eo=class extends y{},V_=class extends Eo{},H_=class extends Eo{};var Ao=class extends y{},X_=class extends Ao{},K_=class extends Ao{};var Tr=class extends y{},Y_=class extends Tr{},Q_=class extends Tr{async _call(e){return new ge(await super._call(e))}},J_=class extends Tr{async _call(e){return new j(await super._call(e))}},Z_=class extends Tr{async _call(e){return new he(await super._call(e))}},em=class extends Tr{async _call(e){return new Me(await super._call(e))}};var Mo=class extends y{},tm=class extends Mo{},rm=class extends Mo{async _call(e){return new j(await super._call(e))}};var So=class extends y{},sm=class extends So{},nm=class extends So{async _call(e){return new j(await super._call(e))}};var To=class extends y{},om=class extends To{},am=class extends To{async _call(e){return new sr(await super._call(e))}},sr=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var Oo=class extends y{},im=class extends Oo{},lm=class extends Oo{async _call(e){return new sr(await super._call(e))}};var pc=class extends $e{constructor({audio_codes:e}){super(),this.audio_codes=e}},dc=class extends $e{constructor({audio_values:e}){super(),this.audio_values=e}},tn=class extends y{main_input_name="input_values";forward_params=["input_values"]},cm=class extends tn{async encode(e){return new pc(await de(this.sessions.encoder_model,e))}async decode(e){return new dc(await de(this.sessions.decoder_model,e))}},Io=class extends tn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},Co=class extends tn{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{},um=class extends Or{},pm=class extends Or{async _call(e){return new ge(await super._call(e))}},dm=class extends Or{async _call(e){return new j(await super._call(e))}},fm=class extends Or{async _call(e){return new he(await super._call(e))}},_m=class extends Or{async _call(e){return new Me(await super._call(e))}};var Po=class extends y{},mm=class extends Po{},hm=class extends Po{};var Ir=class extends y{},gm=class extends Ir{},wm=class extends Ir{async _call(e){return new ge(await super._call(e))}},xm=class extends Ir{async _call(e){return new j(await super._call(e))}},ym=class extends Ir{async _call(e){return new he(await super._call(e))}},bm=class extends Ir{async _call(e){return new Me(await super._call(e))}};var fc=class extends y{},vm=class extends fc{};var zo=class extends y{},km=class extends zo{},Em=class extends zo{async _call(e){return new j(await super._call(e))}};var _c=class extends y{},Am=class extends _c{};var mc=class extends y{},Mm=class extends mc{};var rn=class extends y{},Sm=class extends rn{},Tm=class extends rn{async _call(e){return new sn(await super._call(e))}},Om=class extends rn{async _call(e){return new hc(await super._call(e))}},sn=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}},hc=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 Lo=class extends y{},Im=class extends Lo{},Cm=class extends Lo{async _call(e){return new j(await super._call(e))}};var No=class extends y{},Pm=class extends No{},zm=class extends No{async _call(e){return new j(await super._call(e))}};var gc=class extends y{},Lm=class extends gc{};var wc=class extends y{},Nm=class extends wc{};var Cr=class extends y{},$m=class extends Cr{},Rm=class extends Cr{async _call(e){return new j(await super._call(e))}},Dm=class extends Cr{async _call(e){return new he(await super._call(e))}},Um=class extends Cr{async _call(e){return new Me(await super._call(e))}},Bm=class extends Cr{async _call(e){return new ge(await super._call(e))}};var xc=class extends y{},Fm=class extends xc{};var $o=class extends y{},jm=class extends $o{},Gm=class extends $o{};var Ro=class extends y{},qm=class extends Ro{},Wm=class extends Ro{async _call(e){return new j(await super._call(e))}};var Pr=class extends y{},Vm=class extends Pr{},Hm=class extends Pr{async _call(e){return new ge(await super._call(e))}},Xm=class extends Pr{async _call(e){return new j(await super._call(e))}},Km=class extends Pr{async _call(e){return new he(await super._call(e))}},Ym=class extends Pr{async _call(e){return new Me(await super._call(e))}};var Do=class extends y{},Qm=class extends Do{},Jm=class extends Do{};var ps=class extends y{},Zm=class extends ps{},eh=class extends ps{async _call(e){return new ge(await super._call(e))}},th=class extends ps{async _call(e){return new j(await super._call(e))}},rh=class extends ps{async _call(e){return new he(await super._call(e))}};var ds=class extends y{},sh=class extends ds{},nh=class extends ds{async _call(e){return new ge(await super._call(e))}},oh=class extends ds{async _call(e){return new j(await super._call(e))}},ah=class extends ds{async _call(e){return new he(await super._call(e))}};var Uo=class extends y{},ih=class extends Uo{},lh=class extends Uo{};var Bo=class extends y{},ch=class extends Bo{},uh=class extends Bo{};var Fo=class extends y{},ph=class extends Fo{},dh=class extends Fo{};var jo=class extends y{},fh=class extends jo{},_h=class extends jo{async _call(e){return new j(await super._call(e))}};var yc=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"},mh=class extends yc{_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:f}=await qt(this,{inputs_embeds:l,attention_mask:s});a=f}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 Go=class extends y{},hh=class extends Go{},gh=class extends Go{};var qo=class extends y{},wh=class extends qo{},xh=class extends qo{};var bc=class extends y{forward_params=["input_ids","attention_mask","pixel_values","position_ids","past_key_values"]},yt=class extends bc{_merge_input_ids_with_image_features(e){let r=e.image_features.dims.at(-1),s=e.image_features.view(-1,r);return lo({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:s})}},yh=class extends yt{},bh=class extends yt{};var vc=class extends y{},vh=class extends vc{},kc=class extends yt{},kh=class extends kc{};var Ec=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"]},nn=class extends Ec{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:f=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: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 lo({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 t_({audio_token_id:this.config.audio_token_id,...e,audio_features:s})}},Eh=class extends nn{};var Wo=class extends y{},Ah=class extends Wo{},Mh=class extends Wo{};var Vo=class extends y{},Sh=class extends Vo{},Th=class extends Vo{};var Ac=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values","pixel_values","image_grid_thw"]},on=class extends Ac{image_grid_thw_name="grid_thw";_get_text_only_rope_index(e,r){if(r){let{data:s,dims:n}=W1(r),o=BigInt64Array.from({length:3*s.length},(i,l)=>s[l%s.length]),a=Array.from({length:n[0]},(i,l)=>Pe(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]),wp([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 f=p.length/3;for(let _=c*f;_<(c+1)*f;++_)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,f=c.reduce((A,T,S)=>(T==l&&A.push(S),A),[]).map(A=>c[A+1]),_=f.filter(A=>A==a).length,m=f.filter(A=>A==i).length,w=[],x=0,k=_,E=m;for(let A=0;A<f.length;++A){let T=c.findIndex((J,xe)=>xe>x&&J==a),S=c.findIndex((J,xe)=>xe>x&&J==i),P=k>0&&T!==-1?T:c.length+1,O=E>0&&S!==-1?S:c.length+1,v,W,X,B;P<O?([W,X,B]=r[o.image_index],++o.image_index,--k,v=P):([W,X,B]=s[o.video_index],++o.video_index,--E,v=O);let[H,G,K]=[Number(W),Math.floor(Number(X)/n),Math.floor(Number(B)/n)],R=v-x,C=w.length>0?Pe(w.at(-1))[0]+1:0;w.push(Array.from({length:3*R},(J,xe)=>C+xe%R));let re=R+C,ae=H*G*K,z=Array.from({length:ae},(J,xe)=>re+Math.floor(xe/(G*K))),$=Array.from({length:ae},(J,xe)=>re+Math.floor(xe/K)%G),U=Array.from({length:ae},(J,xe)=>re+xe%K);w.push([z,$,U].flat()),x=v+ae}if(x<c.length){let A=w.length>0?Pe(w.at(-1))[0]+1:0,T=c.length-x;w.push(Array.from({length:3*T},(S,P)=>A+P%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=Sl(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():[],f=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),k=this._get_multimodal_rope_positions({filtered_ids:x,image_grid_thw_list:p,video_grid_thw_list:f,spatial_merge_size:a,state:_}),E=this._reorder_and_write_positions(k,l[w],c,w);m.push(Pe(E)[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 lo({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,r,s){if(!r.attention_mask||r.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes("position_ids"))return r;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 o=r.past_key_values.get_seq_length();if(o<r.input_ids.dims[1]){let[a,i]=this.get_rope_index(r.input_ids,r.image_grid_thw,r.video_grid_thw,r.attention_mask);r.rope_deltas=i,r.position_ids=a.slice(null,null,[o,null]),r.input_ids=r.input_ids.slice(null,[o,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 a=BigInt(o),i=r.rope_deltas.map(l=>a+l);r.position_ids=Tt([i,i,i],0)}}return r}},Ho=class extends on{};var fs=class extends on{image_grid_thw_name="image_grid_thw"},Xo=class extends Ho{image_grid_thw_name="image_grid_thw"};var Oh=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))),f=Array.from({length:l},(_,m)=>e+m%i);return[...c,...p,...f]}_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,f=[];for(let[_,m,w]of i)if(_===0){let x=w-m;f.push(Array.from({length:3*x},(k,E)=>p+E%x)),p+=x}else{let x=r[o.image_index++].map(Number),k=x[0];f.push(this.get_vision_position_ids(p,x,k,n)),p+=Math.max(x[1],x[2])/n}return f}};var Ko=class extends y{},Ih=class extends Ko{},Ch=class extends Ko{};var Yo=class extends y{},Ph=class extends Yo{},zh=class extends Yo{};var Qo=class extends y{},Lh=class extends Qo{},Nh=class extends Qo{};var Jo=class extends y{},$h=class extends Jo{},Rh=class extends Jo{};var Zo=class extends y{},Dh=class extends Zo{},Uh=class extends Zo{};var ea=class extends y{},Bh=class extends ea{},Fh=class extends ea{};var ta=class extends y{},jh=class extends ta{},Gh=class extends ta{};var ra=class extends y{},qh=class extends ra{},Wh=class extends ra{};var sa=class extends y{},Vh=class extends sa{},Hh=class extends sa{};var Mc=class extends y{forward_params=["input_ids","attention_mask","position_ids","audio_values","past_key_values"]},_s=class extends Mc{_merge_input_ids_with_audio_features(e){let r=e.audio_features.dims.at(-1),s=e.audio_features.view(-1,r);return t_({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:s})}};var Xh=class extends _s{forward_params=["input_ids","attention_mask","input_features","past_key_values"]};var Sc=class extends y{},Kh=class extends Sc{};var Tc=class extends y{},Yh=class extends Tc{};var na=class extends y{},Qh=class extends na{},Jh=class extends na{};var oa=class extends y{},Zh=class extends oa{},eg=class extends oa{async _call(e){return new j(await super._call(e))}};var Wt=class extends y{},tg=class extends Wt{},rg=class extends Wt{async _call(e){return new vt(await super._call(e))}},sg=class extends Wt{async _call(e){return new j(await super._call(e))}},ng=class extends Wt{async _call(e){return new he(await super._call(e))}};var og=class extends y{},ag=class extends Wt{},ig=class extends Wt{async _call(e){return new vt(await super._call(e))}},lg=class extends Wt{async _call(e){return new j(await super._call(e))}};var aa=class extends y{},cg=class extends aa{},ug=class extends aa{};var pg=class extends yt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","position_ids","past_key_values"]};var ia=class extends y{},dg=class extends ia{},fg=class extends ia{async _call(e){return new j(await super._call(e))}};var la=class extends y{},_g=class extends la{},mg=class extends la{};var an=class extends y{},hg=class extends an{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}},ca=class extends an{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},gg=class extends an{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var ua=class extends y{},wg=class extends ua{},xg=class extends ua{};var yg=class extends yt{};var pa=class extends y{},bg=class extends pa{},vg=class extends pa{};var kg=class extends yt{forward_params=["input_ids","attention_mask","pixel_values","pixel_attention_mask","spatial_shapes","position_ids","past_key_values"]};var da=class extends y{},Eg=class extends da{},Ag=class extends da{};var Oc=class extends y{},Mg=class extends Oc{};var fa=class extends y{},Sg=class extends fa{},Tg=class extends fa{};var _a=class extends y{},Og=class extends _a{},Ig=class extends _a{};var ma=class extends y{},Cg=class extends ma{},Pg=class extends ma{};var ha=class extends y{},zg=class extends ha{},Lg=class extends ha{};var ms=class extends y{},Ng=class extends ms{},$g=class extends ms{},Rg=class extends ms{async _call(e){return new j(await super._call(e))}},Dg=class extends ms{};var Ic=class extends y{},Ug=class extends Ic{};var Cc=class extends y{},Bg=class extends Cc{};var Pc=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]}},zc=class extends y{},Fg=class extends zc{async _call(e){return new Pc(await super._call(e))}};var Lc=class extends $e{constructor({audio_codes:e}){super(),this.audio_codes=e}},Nc=class extends $e{constructor({audio_values:e}){super(),this.audio_values=e}},ln=class extends y{main_input_name="input_values";forward_params=["input_values"]},jg=class extends ln{async encode(e){return new Lc(await de(this.sessions.encoder_model,e))}async decode(e){return new Nc(await de(this.sessions.decoder_model,e))}},ga=class extends ln{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},wa=class extends ln{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var xa=class extends y{},Gg=class extends xa{},qg=class extends xa{};var ya=class extends y{},Wg=class extends ya{},Vg=class extends ya{};var hs=class extends y{},Hg=class extends hs{},Xg=class extends hs{async _call(e){return new ge(await super._call(e))}},Kg=class extends hs{async _call(e){return new j(await super._call(e))}},Yg=class extends hs{async _call(e){return new Me(await super._call(e))}};var ba=class extends y{},Qg=class extends ba{},Jg=class extends ba{};var cn=class extends y{},Zg=class extends cn{},ew=class extends cn{async _call(e){return new j(await super._call(e))}},tw=class extends cn{};var un=class extends y{},rw=class extends un{},sw=class extends un{async _call(e){return new j(await super._call(e))}},nw=class extends un{};var pn=class extends y{},ow=class extends pn{},aw=class extends pn{async _call(e){return new j(await super._call(e))}},iw=class extends pn{};var dn=class extends y{},lw=class extends dn{},cw=class extends dn{async _call(e){return new j(await super._call(e))}},uw=class extends dn{};var va=class extends y{},pw=class extends va{},dw=class extends va{async _call(e){return new j(await super._call(e))}};var ka=class extends y{},fw=class extends ka{},_w=class extends ka{async _call(e){return new j(await super._call(e))}};var gs=class extends y{},mw=class extends gs{},hw=class extends gs{async _call(e){return new ge(await super._call(e))}},gw=class extends gs{async _call(e){return new j(await super._call(e))}},ww=class extends gs{async _call(e){return new he(await super._call(e))}};var Ea=class extends y{},xw=class extends Ea{},yw=class extends Ea{};var Aa=class extends y{requires_attention_mask=!1;main_input_name="input_values";forward_params=["input_values","decoder_input_ids","past_key_values"]},bw=class extends Aa{},vw=class extends Aa{};var zr=class extends y{},kw=class extends zr{},Ew=class extends zr{async _call(e){return new ge(await super._call(e))}},Aw=class extends zr{async _call(e){return new j(await super._call(e))}},Mw=class extends zr{async _call(e){return new he(await super._call(e))}},Sw=class extends zr{async _call(e){return new Me(await super._call(e))}};var Ma=class extends y{},Tw=class extends Ma{},Ow=class extends Ma{};var Sa=class extends y{},Iw=class extends Sa{},Cw=class extends Sa{};var $c=class extends y{},Pw=class extends $c{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=Ye(e,l.inputNames);s=await de(l,c)}else{let l=this.sessions.gen_img_embeds,c=Ye({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,Ye(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,Fn(r.input_ids,BigInt(s.pad_token_id))],0),r.attention_mask=ve([r.attention_mask,Fn(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 Ta=class extends y{},zw=class extends Ta{},Lw=class extends Ta{},Oa=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,f=Math.floor(c/s)%n,_=p-f;_>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)),ic(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 Ia=class extends y{},Nw=class extends Ia{},$w=class extends Ia{};var Ca=class extends y{},Rw=class extends Ca{},Dw=class extends Ca{};var Lr=class extends y{},Uw=class extends Lr{},Bw=class extends Lr{async _call(e){return new ge(await super._call(e))}},Fw=class extends Lr{async _call(e){return new j(await super._call(e))}},jw=class extends Lr{async _call(e){return new he(await super._call(e))}},Gw=class extends Lr{async _call(e){return new Me(await super._call(e))}};var Rc=class extends y{},qw=class extends Rc{};var Pa=class extends y{},Ww=class extends Pa{},Vw=class extends Pa{};var za=class extends y{},Hw=class extends za{},Xw=class extends za{};var La=class extends y{},Kw=class extends La{},Yw=class extends La{};var Na=class extends y{},Qw=class extends Na{},Jw=class extends Na{};var $a=class extends y{},Zw=class extends $a{},ex=class extends $a{};var Ra=class extends y{},tx=class extends Ra{},rx=class extends Ra{};var Da=class extends y{},sx=class extends Da{},nx=class extends Da{};var Ua=class extends y{},ox=class extends Ua{},ax=class extends Ua{};var ix=class extends yt{};var Dc=class extends y{},lx=class extends Dc{async _call(e){return new vt(await super._call(e))}};var Ba=class extends y{},cx=class extends Ba{},ux=class extends Ba{};var Fa=class extends y{},px=class extends Fa{},dx=class extends Fa{};var ja=class extends y{},fx=class extends ja{},_x=class extends ja{};var Ga=class extends y{},mx=class extends Ga{},hx=class extends Ga{};var Uc=class extends y{forward_params=["input_ids","inputs_embeds","attention_mask","position_ids","pixel_values","image_sizes","past_key_values"]},qa=class extends Uc{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 Wa=class extends y{},gx=class extends Wa{},wx=class extends Wa{async _call(e){return new j(await super._call(e))}};var Va=class extends y{},xx=class extends Va{},yx=class extends Va{async _call(e){return new he(await super._call(e))}};var Ha=class extends y{},bx=class extends Ha{},vx=class extends Ha{};var Xa=class extends y{},kx=class extends Xa{},Ex=class extends Xa{};var Ka=class extends y{},Ax=class extends Ka{},Mx=class extends Ka{};var Ya=class extends y{},Sx=class extends Ya{},Tx=class extends Ya{};var Qa=class extends y{},Ox=class extends Qa{},Ix=class extends Qa{};var ws=class extends fs{},Ja=class extends Xo{};var Cx=class extends ws{},Px=class extends Ja{};var fn=class extends ws{},Za=class extends fn{};var zx=class extends fn{},Lx=class extends Za{};var ei=class extends y{},Nx=class extends ei{},$x=class extends ei{async _call(e){return new j(await super._call(e))}};var ti=class extends y{},Rx=class extends ti{},Dx=class extends ti{async _call(e){return new Bc(await super._call(e))}},Bc=class extends sr{};var Nr=class extends y{},Ux=class extends Nr{},Bx=class extends Nr{async _call(e){return new ge(await super._call(e))}},Fx=class extends Nr{async _call(e){return new j(await super._call(e))}},jx=class extends Nr{async _call(e){return new he(await super._call(e))}},Gx=class extends Nr{async _call(e){return new Me(await super._call(e))}};var $r=class extends y{},qx=class extends $r{},Wx=class extends $r{async _call(e){return new ge(await super._call(e))}},Vx=class extends $r{async _call(e){return new j(await super._call(e))}},Hx=class extends $r{async _call(e){return new he(await super._call(e))}},Xx=class extends $r{async _call(e){return new Me(await super._call(e))}};var ri=class extends y{},Kx=class extends ri{},Yx=class extends ri{async _call(e){return new Fc(await super._call(e))}},Fc=class extends sr{};var jc=class extends $e{constructor({iou_scores:e,pred_masks:r}){super(),this.iou_scores=e,this.pred_masks=r}},Gc=class extends y{},Qx=class extends Gc{async get_image_embeddings({pixel_values:e}){return await qt(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 jc(await super._call(e))}};var qc=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}},Wc=class extends y{},si=class extends Wc{async get_image_embeddings({pixel_values:e}){return await qt(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=Ye(e,n.inputNames);return await de(n,o)}async _call(e){return new qc(await super._call(e))}},Jx=class extends si{},Zx=class extends si{};var _n=class extends y{},ey=class extends _n{},ty=class extends _n{},ry=class extends _n{};var mn=class extends y{},sy=class extends mn{},ny=class extends mn{},oy=class extends mn{};var ni=class extends y{},ay=class extends ni{},oi=class extends ni{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"text_model"})}},iy=class extends rr{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"vision_model"})}};var ai=class extends y{},ly=class extends ai{},cy=class extends ai{};var hn=class extends y{main_input_name="input_values";forward_params=["input_values"]},uy=class extends hn{async encode(e){return await de(this.sessions.encoder_model,e)}async decode(e){return await de(this.sessions.decoder_model,e)}},ii=class extends hn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"encoder_model"})}},li=class extends hn{static async from_pretrained(e,r={}){return super.from_pretrained(e,{...r,model_file_name:r.model_file_name??"decoder_model"})}};var ci=class extends y{},py=class extends ci{},dy=class extends ci{};var gn=class extends y{},fy=class extends gn{},_y=class extends gn{},my=class extends gn{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 qt(this,i),p=l.dims[1]/this.config.reduction_factor,f=Math.floor(p*o),_=Math.floor(p*n),m=this.config.num_mel_bins,w=[],x=null,k=null,E=0;for(;;){++E;let S=q1(!!k),P;k?P=k.output_sequence_out:P=new N("float32",new Float32Array(m),[1,1,m]);let O={use_cache_branch:S,output_sequence:P,encoder_attention_mask:c,speaker_embeddings:r,encoder_hidden_states:l};this.addPastKeyValues(O,x),k=await de(this.sessions.decoder_model_merged,O),x=this.getPastKeyValues(k,x);let{prob:v,spectrum:W}=k;if(w.push(W),E>=_&&(Array.from(v.data).filter(X=>X>=s).length>0||E>=f))break}let A=ve(w),{waveform:T}=await de(a.sessions.model,{spectrogram:A});return{spectrogram:A,waveform:T}}},hy=class extends y{main_input_name="spectrogram"};var xs=class extends y{},gy=class extends xs{},wy=class extends xs{async _call(e){return new ge(await super._call(e))}},xy=class extends xs{async _call(e){return new j(await super._call(e))}},yy=class extends xs{async _call(e){return new Me(await super._call(e))}};var ui=class extends y{},by=class extends ui{},vy=class extends ui{};var pi=class extends y{},ky=class extends pi{},Ey=class extends pi{};var Vc=class extends y{},Ay=class extends Vc{};var Hc=class extends y{},di=class extends Hc{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:f}=await de(this.sessions.text_encoder,{input_ids:e,attention_mask:r,style:s}),_=f.div(o).mul_(a),m=l*i,w=_.data,x=Int32Array.from(w,B=>Math.ceil(B/m)),k=Math.max(...x),E=e.dims[0],A=new BigInt64Array(E*k);for(let B=0;B<E;++B)A.fill(1n,B*k,B*k+x[B]);let T=new N("int64",A,[E,k]),S=c*i,P=S*k,O=k1([E,S,k]),v=O.data;for(let B=0;B<E;++B)if(x[B]!==k)for(let H=0;H<S;++H)v.fill(0,B*P+H*k+x[B],B*P+(H+1)*k);let W=qe([E],n);for(let B=0;B<n;++B){let H=qe([E],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 wn=class extends y{},My=class extends wn{},Sy=class extends wn{async _call(e){return new j(await super._call(e))}},Ty=class extends wn{};var fi=class extends y{},Oy=class extends fi{},Iy=class extends fi{};var _i=class extends y{forward_params=["input_ids","attention_mask","encoder_outputs","decoder_input_ids","decoder_attention_mask","past_key_values"]},Cy=class extends _i{},Py=class extends _i{};var mi=class extends y{},zy=class extends mi{},Ly=class extends mi{async _call(e){return new Xc(await super._call(e))}},Xc=class extends sn{};var Kc=class extends y{},Ny=class extends Kc{};var xn=class extends y{},$y=class extends xn{},Ry=class extends xn{async _call(e){return new vt(await super._call(e))}},Dy=class extends xn{async _call(e){return new j(await super._call(e))}};var ys=class extends y{},Uy=class extends ys{},By=class extends ys{async _call(e){return new vt(await super._call(e))}},Fy=class extends ys{async _call(e){return new j(await super._call(e))}},jy=class extends ys{async _call(e){return new he(await super._call(e))}};var hi=class extends y{},Gy=class extends hi{},qy=class extends hi{};var Wy=class extends y{main_input_name="pixel_values";forward_params=["pixel_values","decoder_input_ids","encoder_hidden_states","past_key_values"]};var gi=class extends y{},Vy=class extends gi{},Hy=class extends gi{async _call(e){return new j(await super._call(e))}};var Yc=class extends y{},Xy=class extends Yc{};var wi=class extends y{},Ky=class extends wi{},Yy=class extends wi{async _call(e){return new j(await super._call(e))}};var Qc=class extends y{},Qy=class extends Qc{async _call(e){return new Kf(await super._call(e))}};var Jc=class extends y{},Jy=class extends Jc{};var Zc=class extends $e{constructor({waveform:e,spectrogram:r}){super(),this.waveform=e,this.spectrogram=r}},eu=class extends y{},Zy=class extends eu{async _call(e){return new Zc(await super._call(e))}};var e0=class extends _s{};var AM=2,EN=1,V1=new WeakMap;function AN(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 ao,c=n?.config?.kv_cache_dtype??"float32",p=c==="float16"?kr.float16:kr.float32,f=Hs(s,{batch_size:1});for(let w in f){let x=f[w].reduce((k,E)=>k*E,1);l[w]=new N(c,new p(x),f[w])}let _=new N(c,new p(i*AM),[1,i,AM]),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 MN(t,e){let r=e.dims[2],s=Math.floor((EN+r-3)/2)+1,n=new N("int64",BigInt64Array.from({length:s},(p,f)=>BigInt(t.enc_past_seq_len+f)),[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 f=p.replace("present","past_key_values"),_=t.enc_kv_cache[f];_?.location==="gpu-buffer"&&_.dispose(),t.enc_kv_cache[f]=c[p]}return t.enc_past_seq_len=o,i}async function SN(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 MN(t,r.value);t.audio_embed_queue.push({data:s.data,tokens:s.dims[1]}),t.audio_embed_total_tokens+=s.dims[1]}}function TN(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 H1=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)}},tu=class extends y{forward_params=["input_ids","attention_mask","position_ids","past_key_values"]},xi=class extends tu{async forward({input_ids:e,past_key_values:r,...s}){let n=e.dims[1],o=V1.get(this);o&&await SN(o,o.audio_consumed+n);let{inputs_embeds:a}=await de(this.sessions.embed_tokens,{input_ids:e});o&&TN(o,a,n);let i={inputs_embeds:a,...s};this.addPastKeyValues(i,r);let l=this.sessions.decoder_model_merged,c=Ye(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=AN(this,e);V1.set(this,n);let o=new Ks;o.push(new H1(n)),r&&o.extend(r);try{return await super.generate({...s,stopping_criteria:o})}finally{n.enc_kv_cache.dispose(),V1.delete(this)}}};var yn=class extends y{},t0=class extends yn{},r0=class extends yn{async _call(e){return new vt(await super._call(e))}},s0=class extends yn{async _call(e){return new j(await super._call(e))}};var ru=class extends $e{constructor({logits:e,embeddings:r}){super(),this.logits=e,this.embeddings=r}},Rr=class extends y{},n0=class extends Rr{},o0=class extends Rr{async _call(e){return new vt(await super._call(e))}},a0=class extends Rr{async _call(e){return new j(await super._call(e))}},i0=class extends Rr{async _call(e){return new ru(await super._call(e))}},l0=class extends Rr{async _call(e){return new he(await super._call(e))}};var su=class extends y{},c0=class extends su{};var u0=class extends oo{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 yi=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"]},p0=class extends yi{},nu=class extends yi{_prepare_generation_config(e,r){return super._prepare_generation_config(e,r,u0)}_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=`<|${Q2(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 cs,s.push(new Ql(r,a))),r.begin_suppress_tokens&&(s??=new cs,s.push(new Xs(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,k)=>ve(a.map(E=>E[k]),2)),l=Tt(r.map(([x,k])=>{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,k,null,[0,s]):i[x].slice(null,k)})).transpose(1,0,2,3),[c,p]=gp(l,-2,0,!0),f=l.clone();for(let x=0;x<f.dims[0];++x){let k=f[x];for(let E=0;E<k.dims[0];++E){let A=k[E],T=c[x][E][0].data,S=p[x][E][0].data;for(let P=0;P<A.dims[0];++P){let O=A[P].data;for(let v=0;v<O.length;++v)O[v]=(O[v]-S[v])/T[v];O.set(pA(O,o))}}}let _=[Ml(f,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 k=_[x].neg().squeeze_(0),[E,A]=fA(k.tolist()),T=Array.from({length:E.length-1},(O,v)=>E[v+1]-E[v]),S=ht([1],T).map(O=>!!O),P=[];for(let O=0;O<S.length;++O)S[O]&&P.push(A[O]*n);w[x].data.set(P,1)}return w}},d0=class extends nu{};var Dr=class extends y{},f0=class extends Dr{},_0=class extends Dr{async _call(e){return new ge(await super._call(e))}},m0=class extends Dr{async _call(e){return new j(await super._call(e))}},h0=class extends Dr{async _call(e){return new he(await super._call(e))}},g0=class extends Dr{async _call(e){return new Me(await super._call(e))}};var Ur=class extends y{},w0=class extends Ur{},x0=class extends Ur{async _call(e){return new ge(await super._call(e))}},y0=class extends Ur{async _call(e){return new j(await super._call(e))}},b0=class extends Ur{async _call(e){return new he(await super._call(e))}},v0=class extends Ur{async _call(e){return new Me(await super._call(e))}};var bi=class extends y{},k0=class extends bi{},E0=class extends bi{async _call(e){return new ou(await super._call(e))}},ou=class extends $e{constructor({logits:e,pred_boxes:r}){super(),this.logits=e,this.pred_boxes=r}};var vi=class extends y{},A0=class extends vi{},M0=class extends vi{};var ON=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"]]),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"]]),CN=new Map([["mimi","MimiModel"],["dac","DacModel"],["snac","SnacModel"]]),PN=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"]]),MM=new Map([["speecht5","SpeechT5ForSpeechToText"],["whisper","WhisperForConditionalGeneration"],["lite-whisper","LiteWhisperForConditionalGeneration"],["moonshine","MoonshineForConditionalGeneration"]]),SM=new Map([["speecht5","SpeechT5ForTextToSpeech"]]),TM=new Map([["vits","VitsModel"],["musicgen","MusicgenForConditionalGeneration"],["supertonic","SupertonicForConditionalGeneration"]]),OM=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"]]),IM=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"]]),CM=new Map([["t5","T5ForConditionalGeneration"],["longt5","LongT5ForConditionalGeneration"],["mt5","MT5ForConditionalGeneration"],["bart","BartForConditionalGeneration"],["mbart","MBartForConditionalGeneration"],["marian","MarianMTModel"],["m2m_100","M2M100ForConditionalGeneration"],["blenderbot","BlenderbotForConditionalGeneration"],["blenderbot-small","BlenderbotSmallForConditionalGeneration"]]),PM=new Map([["bloom","BloomForCausalLM"],["gpt2","GPT2LMHeadModel"],["gpt_oss","GptOssForCausalLM"],["jais","JAISLMHeadModel"],["gptj","GPTJForCausalLM"],["gpt_bigcode","GPTBigCodeForCausalLM"],["gpt_neo","GPTNeoForCausalLM"],["gpt_neox","GPTNeoXForCausalLM"],["codegen","CodeGenForCausalLM"],["llama","LlamaForCausalLM"],["nanochat","NanoChatForCausalLM"],["apertus","ApertusForCausalLM"],["llama4_text","Llama4ForCausalLM"],["arcee","ArceeForCausalLM"],["afmoe","AfmoeForCausalLM"],["lfm2","Lfm2ForCausalLM"],["lfm2_moe","Lfm2MoeForCausalLM"],["smollm3","SmolLM3ForCausalLM"],["exaone","ExaoneForCausalLM"],["olmo","OlmoForCausalLM"],["olmo2","Olmo2ForCausalLM"],["olmo3","Olmo3ForCausalLM"],["olmo_hybrid","OlmoHybridForCausalLM"],["mobilellm","MobileLLMForCausalLM"],["granite","GraniteForCausalLM"],["granitemoehybrid","GraniteMoeHybridForCausalLM"],["cohere","CohereForCausalLM"],["cohere2","Cohere2ForCausalLM"],["gemma","GemmaForCausalLM"],["gemma2","Gemma2ForCausalLM"],["vaultgemma","VaultGemmaForCausalLM"],["gemma3_text","Gemma3ForCausalLM"],["gemma3","Gemma3ForCausalLM"],["helium","HeliumForCausalLM"],["glm","GlmForCausalLM"],["glm_moe_dsa","GlmMoeDsaForCausalLM"],["openelm","OpenELMForCausalLM"],["qwen2","Qwen2ForCausalLM"],["qwen2_moe","Qwen2MoeForCausalLM"],["qwen3","Qwen3ForCausalLM"],["qwen3_moe","Qwen3MoeForCausalLM"],["qwen3_next","Qwen3NextForCausalLM"],["qwen2_vl","Qwen2VLForCausalLM"],["qwen2_5_vl","Qwen2_5_VLForCausalLM"],["qwen3_vl","Qwen3VLForCausalLM"],["qwen3_vl_moe","Qwen3VLMoeForCausalLM"],["qwen3_5","Qwen3_5ForCausalLM"],["qwen3_5_text","Qwen3_5ForCausalLM"],["qwen3_5_moe","Qwen3_5MoeForCausalLM"],["gemma3n","Gemma3nForCausalLM"],["phi","PhiForCausalLM"],["phi3","Phi3ForCausalLM"],["mpt","MptForCausalLM"],["opt","OPTForCausalLM"],["mbart","MBartForCausalLM"],["mistral","MistralForCausalLM"],["mistral4","Mistral4ForCausalLM"],["ministral","MinistralForCausalLM"],["ministral3","Ministral3ForCausalLM"],["ernie4_5","Ernie4_5ForCausalLM"],["starcoder2","Starcoder2ForCausalLM"],["deepseek_v3","DeepseekV3ForCausalLM"],["falcon","FalconForCausalLM"],["falcon_h1","FalconH1ForCausalLM"],["nemotron_h","NemotronHForCausalLM"],["trocr","TrOCRForCausalLM"],["solar_open","SolarOpenForCausalLM"],["stablelm","StableLmForCausalLM"],["modernbert-decoder","ModernBertDecoderForCausalLM"],["hunyuan_v1_dense","HunYuanDenseV1ForCausalLM"],["youtu","YoutuForCausalLM"],["phi3_v","Phi3VForCausalLM"]]),zN=new Map([["multi_modality","MultiModalityCausalLM"]]),zM=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"]]),LM=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"]]),NM=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"]]),$M=new Map([["llava","LlavaForConditionalGeneration"],["llava_onevision","LlavaOnevisionForConditionalGeneration"],["moondream1","Moondream1ForConditionalGeneration"],["florence2","Florence2ForConditionalGeneration"],["qwen2_vl","Qwen2VLForConditionalGeneration"],["qwen2_5_vl","Qwen2_5_VLForConditionalGeneration"],["qwen3_vl","Qwen3VLForConditionalGeneration"],["qwen3_vl_moe","Qwen3VLMoeForConditionalGeneration"],["qwen3_5","Qwen3_5ForConditionalGeneration"],["qwen3_5_moe","Qwen3_5MoeForConditionalGeneration"],["lfm2_vl","Lfm2VlForConditionalGeneration"],["idefics3","Idefics3ForConditionalGeneration"],["smolvlm","SmolVLMForConditionalGeneration"],["paligemma","PaliGemmaForConditionalGeneration"],["llava_qwen2","LlavaQwen2ForCausalLM"],["gemma3","Gemma3ForConditionalGeneration"],["gemma3n","Gemma3nForConditionalGeneration"],["mistral3","Mistral3ForConditionalGeneration"],["lighton_ocr","LightOnOcrForConditionalGeneration"],["glm_ocr","GlmOcrForConditionalGeneration"]]),RM=new Map([["granite_speech","GraniteSpeechForConditionalGeneration"],["ultravox","UltravoxModel"],["voxtral","VoxtralForConditionalGeneration"],["voxtral_realtime","VoxtralRealtimeForConditionalGeneration"]]),LN=new Map([["vision-encoder-decoder","VisionEncoderDecoderModel"]]),DM=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"]]),UM=new Map([["detr","DetrForObjectDetection"],["rt_detr","RTDetrForObjectDetection"],["rt_detr_v2","RTDetrV2ForObjectDetection"],["rf_detr","RFDetrForObjectDetection"],["d_fine","DFineForObjectDetection"],["table-transformer","TableTransformerForObjectDetection"],["yolos","YolosForObjectDetection"]]),BM=new Map([["owlvit","OwlViTForObjectDetection"],["owlv2","Owlv2ForObjectDetection"],["grounding-dino","GroundingDinoForObjectDetection"]]),ki=new Map([["detr","DetrForSegmentation"],["clipseg","CLIPSegForImageSegmentation"]]),FM=new Map([["segformer","SegformerForSemanticSegmentation"],["sapiens","SapiensForSemanticSegmentation"],["swin","SwinForSemanticSegmentation"],["mobilenet_v1","MobileNetV1ForSemanticSegmentation"],["mobilenet_v2","MobileNetV2ForSemanticSegmentation"],["mobilenet_v3","MobileNetV3ForSemanticSegmentation"],["mobilenet_v4","MobileNetV4ForSemanticSegmentation"]]),jM=new Map([["detr","DetrForSegmentation"],["maskformer","MaskFormerForInstanceSegmentation"]]),GM=new Map([["sam","SamModel"],["sam2","Sam2Model"],["edgetam","EdgeTamModel"],["sam3_tracker","Sam3TrackerModel"]]),qM=new Map([["wav2vec2","Wav2Vec2ForCTC"],["wav2vec2-bert","Wav2Vec2BertForCTC"],["unispeech","UniSpeechForCTC"],["unispeech-sat","UniSpeechSatForCTC"],["wavlm","WavLMForCTC"],["hubert","HubertForCTC"],["parakeet_ctc","ParakeetForCTC"]]),WM=new Map([["wav2vec2","Wav2Vec2ForSequenceClassification"],["wav2vec2-bert","Wav2Vec2BertForSequenceClassification"],["unispeech","UniSpeechForSequenceClassification"],["unispeech-sat","UniSpeechSatForSequenceClassification"],["wavlm","WavLMForSequenceClassification"],["hubert","HubertForSequenceClassification"],["audio-spectrogram-transformer","ASTForAudioClassification"]]),VM=new Map([["wavlm","WavLMForXVector"]]),HM=new Map([["unispeech-sat","UniSpeechSatForAudioFrameClassification"],["wavlm","WavLMForAudioFrameClassification"],["wav2vec2","Wav2Vec2ForAudioFrameClassification"],["pyannote","PyAnnoteForAudioFrameClassification"]]),XM=new Map([["vitmatte","VitMatteForImageMatting"]]),NN=new Map([["patchtst","PatchTSTForPrediction"],["patchtsmixer","PatchTSMixerForPrediction"]]),KM=new Map([["swin2sr","Swin2SRForImageSuperResolution"]]),YM=new Map([["chmv2","CHMv2ForDepthEstimation"],["dpt","DPTForDepthEstimation"],["depth_anything","DepthAnythingForDepthEstimation"],["glpn","GLPNForDepthEstimation"],["sapiens","SapiensForDepthEstimation"],["depth_pro","DepthProForDepthEstimation"],["metric3d","Metric3DForDepthEstimation"],["metric3dv2","Metric3Dv2ForDepthEstimation"]]),QM=new Map([["sapiens","SapiensForNormalEstimation"]]),JM=new Map([["vitpose","VitPoseForPoseEstimation"]]),ZM=new Map([["clip","CLIPVisionModelWithProjection"],["siglip","SiglipVisionModel"],["jina_clip","JinaCLIPVisionModel"]]),X1=[[ON,Q.EncoderOnly],[IN,Q.EncoderDecoder],[PN,Q.DecoderOnlyWithoutHead],[CN,Q.AutoEncoder],[OM,Q.EncoderOnly],[IM,Q.EncoderOnly],[CM,Q.Seq2Seq],[MM,Q.Seq2Seq],[PM,Q.DecoderOnly],[zN,Q.MultiModality],[zM,Q.EncoderOnly],[LM,Q.EncoderOnly],[NM,Q.Vision2Seq],[$M,Q.ImageTextToText],[RM,Q.AudioTextToText],[DM,Q.EncoderOnly],[ki,Q.EncoderOnly],[jM,Q.EncoderOnly],[FM,Q.EncoderOnly],[XM,Q.EncoderOnly],[NN,Q.EncoderOnly],[KM,Q.EncoderOnly],[YM,Q.EncoderOnly],[QM,Q.EncoderOnly],[JM,Q.EncoderOnly],[UM,Q.EncoderOnly],[BM,Q.EncoderOnly],[GM,Q.MaskGeneration],[qM,Q.EncoderOnly],[WM,Q.EncoderOnly],[SM,Q.Seq2Seq],[TM,Q.EncoderOnly],[VM,Q.EncoderOnly],[HM,Q.EncoderOnly],[ZM,Q.EncoderOnly]];for(let[t,e]of X1)for(let r of t.values()){tr.set(r,e);let s=au[r];Js.set(s,r),e_.set(r,s)}var $N=[["MusicgenForConditionalGeneration",Oa,Q.Musicgen],["Phi3VForCausalLM",qa,Q.Phi3V],["CLIPTextModelWithProjection",bo,Q.EncoderOnly],["SiglipTextModel",oi,Q.EncoderOnly],["JinaCLIPTextModel",ca,Q.EncoderOnly],["ClapTextModelWithProjection",xo,Q.EncoderOnly],["ClapAudioModelWithProjection",yo,Q.EncoderOnly],["DacEncoderModel",Io,Q.EncoderOnly],["DacDecoderModel",Co,Q.EncoderOnly],["MimiEncoderModel",ga,Q.EncoderOnly],["MimiDecoderModel",wa,Q.EncoderOnly],["SnacEncoderModel",ii,Q.EncoderOnly],["SnacDecoderModel",li,Q.EncoderOnly],["Gemma3nForConditionalGeneration",nn,Q.ImageAudioTextToText],["SupertonicForConditionalGeneration",di,Q.Supertonic],["ChatterboxModel",wo,Q.Chatterbox],["VoxtralRealtimeForConditionalGeneration",xi,Q.VoxtralRealtime]];for(let[t,e,r]of $N)tr.set(t,r),Js.set(e,t),e_.set(t,e);var eS=new Map([["modnet",ki],["birefnet",ki],["isnet",ki],["ben",ki]]);for(let[t,e]of eS.entries())e.set(t,"PreTrainedModel"),tr.set(t,Q.EncoderOnly),e_.set(t,y);var tS=new Set(eS.keys());tr.set("PreTrainedModel",Q.EncoderOnly);Js.set(y,"PreTrainedModel");var Le={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:OM,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:IM,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:SM,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:TM,MODEL_FOR_MASKED_LM_MAPPING_NAMES:zM,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:LM,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:DM,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:ki,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:FM,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:jM,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:UM,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:BM,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:GM,MODEL_FOR_CTC_MAPPING_NAMES:qM,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:WM,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:VM,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:HM,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:LN,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:XM,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:KM,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:YM,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:QM,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:JM,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:ZM,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:$M,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:RM,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:CM,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:MM,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:PM,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:NM};bM(Le);var Ie=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:f=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:f,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 k=x.get(w);if(!k){for(let E of x.values())if(E[0]===w){k=E;break}if(!k)continue}return await au[k].from_pretrained(e,m)}if(this.BASE_IF_FAIL)return tS.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 Ie{static MODEL_CLASS_MAPPINGS=X1.map(e=>e[0]);static BASE_IF_FAIL=!0},Ei=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},iu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},bn=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},lu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},cu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},uu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},pu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},du=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},fu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},_u=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},mu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},Ai=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},Mi=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},Si=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},hu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},gu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]},K1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]},wu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_CTC_MAPPING_NAMES]},xu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]},Y1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]},Q1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]},yu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]},J1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]},bu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},vu=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]},Z1=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]},ev=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]},ku=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]},tv=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]},rv=class extends Ie{static MODEL_CLASS_MAPPINGS=[Le.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 bs(t,e){return Array.isArray(t)||(t=[t]),await Promise.all(t.map(r=>typeof r=="string"||r instanceof URL?pd(r,e):r instanceof Float64Array?new Float32Array(r):r))}function Eu(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 Ti=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",Ce(c.data),c.dims),l=[];for(let c of n.logits){let p=i(c),f=await Gt(p,r),_=f[0].tolist(),w=f[1].tolist().map((x,k)=>({label:a?a[x]:`LABEL_${x}`,score:_[k]}));r===1?l.push(...w):l.push(w)}return Array.isArray(e)||r===1?l:l[0]}};var Oi=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],f=a[c],_=[];for(let m=0;m<f.dims[0];++m){let w=f[m],x=Pe(w.data)[1],k=i?i[x]:`LABEL_${x}`;if(r.includes(k))continue;let E=this.tokenizer.decode([p[m].item()],{skip_special_tokens:!0});if(E==="")continue;let A=Ce(w.data);_.push({entity:k,score:A[x],index:m,word:E})}l.push(_)}return s?l:l[0]}};var Ii=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:f}=this.tokenizer,_=[];for(let m=0;m<a.dims[0];++m){let w=l[m],x=w.findIndex(O=>O==f),k=a[m].tolist(),E=i[m].tolist();for(let O=1;O<k.length;++O)(c[m]==0||O<=x||p.findIndex(v=>v==w[O])!==-1)&&(k[O]=-1/0,E[O]=-1/0);let A=Ce(k).map((O,v)=>[O,v]),T=Ce(E).map((O,v)=>[O,v]);A[0][0]=0,T[0][0]=0;let S=yE(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]),P=[];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});P.push({answer:H,score:X})}s===1?_.push(...P):_.push(P)}return o?_:_[0]}};var Ci=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],f=p.findIndex(k=>k==s);if(f===-1)throw Error(`Mask token (${n}) not found in text.`);let _=a[c][f],m=await Gt(new N("float32",Ce(_.data),_.dims),r),w=m[0].tolist(),x=m[1].tolist();i.push(x.map((k,E)=>{let A=p.slice();return A[f]=k,{score:w[E],token:Number(k),token_str:this.tokenizer.decode([k]),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 Pi=class extends fr{_key="summary_text"};var zi=class extends fr{_key="translation_text"};function rS(t){return Array.isArray(t)&&t.every(e=>"role"in e&&"content"in e)}var Li=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(rS(e))e=[e];else if(Array.isArray(e)&&e.every(rS))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}),f=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<f.length;++w){let x=Math.floor(w/p.dims[0]*e.length);_&&(f[w]=f[w].slice(_[x])),m[x].push({generated_text:n?[...e[x],{role:"assistant",content:f[w]}]:f[w]})}return!s&&m.length===1?m[0]:m}};var Ni=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=>Ce(m)[1]):Ce(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 $i=class extends _e{async _call(e,{top_k:r=5}={}){let s=this.processor.feature_extractor.config.sampling_rate,n=await bs(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 Gt(new N("float32",Ce(p.data),p.dims),r),_=f[0].tolist(),w=f[1].tolist().map((x,k)=>({label:o?o[x]:`LABEL_${x}`,score:_[k]}));a.push(w)}return Array.isArray(e)?a:a[0]}};var Ri=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 bs(e,i),c=[];for(let p of l){let f=await this.processor(p),_=await this.model({...a,...f}),m=Ce(_.logits_per_audio.data);c.push([...m].map((w,x)=>({score:w,label:r[x]})))}return n?c[0]:c}};var Di=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 bs(n,o),i=[];for(let l of a){let c=await this.processor(l),f=(await this.model(c)).logits[0],_=[];for(let w of f)_.push(Pe(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,f=p.chunk_length/this.model.config.max_source_positions,_=p.hop_length,m=p.sampling_rate,w=await bs(c,m),x=[];for(let k 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 S=m*n,P=m*a,O=S-2*P,v=0;for(;;){let W=v+S,X=k.subarray(v,W),B=await this.processor(X),H=v===0,G=W>=k.length;if(E.push({stride:[X.length,H?0:P,G?0:P],input_features:B.input_features,is_last:G}),G)break;v+=O}}else E=[{stride:[k.length,0,0],input_features:(await this.processor(k)).input_features,is_last:!0}];for(let S of E){i.num_frames=Math.floor(S.stride[0]/_);let P=await this.model.generate({inputs:S.input_features,...i});s==="word"?(S.tokens=P.sequences.tolist()[0],S.token_timestamps=P.token_timestamps.tolist()[0].map(O=>Cs(O,2))):S.tokens=P[0].tolist(),S.stride=S.stride.map(O=>O/m)}let[A,T]=this.tokenizer._decode_asr(E,{time_precision:f,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 bs(n,o),i=[];for(let l of a){let c=await this.processor(l),p=Math.floor(l.length/o)*6,f=await this.model.generate({max_new_tokens:p,...r,...c}),_=this.processor.batch_decode(f,{skip_special_tokens:!0})[0];i.push({text:_})}return s?i[0]:i}};var Ui=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 f=l?Math.min(Math.ceil(l[p]),i):i,_=p*i;c.push(new Wn(o.slice(_,_+f),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 Bi=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 Fi=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 Gt(new N("float32",Ce(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 sS={panoptic:"post_process_panoptic_segmentation",instance:"post_process_instance_segmentation",semantic:"post_process_semantic_segmentation"},vs=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]),f=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 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=sS[i];else if(this.processor.image_processor){for(let[A,T]of Object.entries(sS))if(T in this.processor.image_processor){x=this.processor.image_processor[T].bind(this.processor.image_processor),i=A;break}}let k=this.model.config.id2label,E=[];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 P=new Uint8ClampedArray(T.data.length);for(let v=0;v<T.data.length;++v)T.data[v]===S.id&&(P[v]=255);let O=new Ke(P,T.dims[1],T.dims[0],1);E.push({score:S.score,label:k[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 P=new Uint8ClampedArray(A.data.length);for(let v=0;v<A.data.length;++v)A.data[v]===S&&(P[v]=255);let O=new Ke(P,A.dims[1],A.dims[0],1);E.push({score:null,label:k[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 P=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(P[1],P[0]);E.push({label:null,score:null,mask:v})}}return E}};var ji=class extends vs{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 Gi=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:_=>Ce(_.data),f=[];for(let _ of c.logits_per_image){let w=[...p(_)].map((x,k)=>({score:x,label:r[k]}));w.sort((x,k)=>k.score-x.score),f.push(w)}return n?f:f[0]}};var qi=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:f}=this.model.config,_=p.map(m=>m.boxes.map((w,x)=>({score:m.scores[x],label:f[m.classes[x]],box:Eu(w,!s)})));return n?_:_[0]}};var Wi=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 f=0;f<i.length;++f){let _=i[f],m=o?null:[[_.height,_.width]],w=c.pixel_values[f].unsqueeze_(0),x=await this.model({...l,pixel_values:w}),k;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:m})[0];k=E.boxes.map((A,T)=>({score:E.scores[T],label:E.labels[T],box:Eu(A,!o)}))}else{let E=this.processor.image_processor.post_process_object_detection(x,s,m,!0)[0];k=E.boxes.map((A,T)=>({score:E.scores[T],label:r[E.classes[T]],box:Eu(A,!o)}))}k.sort((E,A)=>A.score-E.score),n!==null&&(k=k.slice(0,n)),p.push(k)}return a?p:p[0]}};var Vi=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>/),f=null;return p&&p.length>=2&&(f=p[1].trim()),[{answer:f}]}};var Hi=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 Xi=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,f]=r[a].size,_=(await xt(i.view(1,1,l,c),{size:[f,p],mode:"bilinear"})).view(f,p),m=_.min().item(),w=_.max().item(),x=_.sub(m).div_(w-m).mul_(255).to("uint8").unsqueeze(0),k=Ke.fromTensor(x);o.push({predicted_depth:_,depth:k})}return Array.isArray(e)?o:o[0]}};var Ki=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=b1(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=E1(l,o)),l}};var Yi=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 Qi=Object.freeze({"text-classification":{pipeline:Ti,model:Ei,default:{model:"Xenova/distilbert-base-uncased-finetuned-sst-2-english"},type:"text"},"token-classification":{pipeline:Oi,model:iu,default:{model:"Xenova/bert-base-multilingual-cased-ner-hrl"},type:"text"},"question-answering":{pipeline:Ii,model:fu,default:{model:"Xenova/distilbert-base-cased-distilled-squad"},type:"text"},"fill-mask":{pipeline:Ci,model:du,default:{model:"onnx-community/ettin-encoder-32m-ONNX",dtype:"fp32"},type:"text"},summarization:{pipeline:Pi,model:bn,default:{model:"Xenova/distilbart-cnn-6-6"},type:"text"},translation:{pipeline:zi,model:bn,default:{model:"Xenova/t5-small"},type:"text"},"text2text-generation":{pipeline:fr,model:bn,default:{model:"Xenova/flan-t5-small"},type:"text"},"text-generation":{pipeline:Li,model:pu,default:{model:"onnx-community/Qwen3-0.6B-ONNX",dtype:"q4"},type:"text"},"zero-shot-classification":{pipeline:Ni,model:Ei,default:{model:"Xenova/distilbert-base-uncased-mnli"},type:"text"},"audio-classification":{pipeline:$i,model:xu,default:{model:"Xenova/wav2vec2-base-superb-ks"},type:"audio"},"zero-shot-audio-classification":{pipeline:Ri,model:dr,default:{model:"Xenova/clap-htsat-unfused"},type:"multimodal"},"automatic-speech-recognition":{pipeline:Di,model:[lu,wu],default:{model:"Xenova/whisper-tiny.en"},type:"multimodal"},"text-to-audio":{pipeline:Ui,model:[uu,cu],default:{model:"onnx-community/Supertonic-TTS-ONNX",dtype:"fp32"},type:"text"},"image-to-text":{pipeline:Bi,model:_u,default:{model:"Xenova/vit-gpt2-image-captioning"},type:"multimodal"},"image-classification":{pipeline:Fi,model:mu,default:{model:"Xenova/vit-base-patch16-224"},type:"multimodal"},"image-segmentation":{pipeline:vs,model:[Ai,Mi,Si],default:{model:"Xenova/detr-resnet-50-panoptic"},type:"multimodal"},"background-removal":{pipeline:ji,model:[Ai,Mi,Si],default:{model:"Xenova/modnet"},type:"image"},"zero-shot-image-classification":{pipeline:Gi,model:dr,default:{model:"Xenova/clip-vit-base-patch32"},type:"multimodal"},"object-detection":{pipeline:qi,model:hu,default:{model:"Xenova/detr-resnet-50"},type:"multimodal"},"zero-shot-object-detection":{pipeline:Wi,model:gu,default:{model:"Xenova/owlvit-base-patch32"},type:"multimodal"},"document-question-answering":{pipeline:Vi,model:yu,default:{model:"Xenova/donut-base-finetuned-docvqa"},type:"multimodal"},"image-to-image":{pipeline:Hi,model:bu,default:{model:"Xenova/swin2SR-classical-sr-x2-64"},type:"image"},"depth-estimation":{pipeline:Xi,model:vu,default:{model:"onnx-community/depth-anything-v2-small"},type:"image"},"feature-extraction":{pipeline:Ki,model:dr,default:{model:"onnx-community/all-MiniLM-L6-v2-ONNX",dtype:"fp32"},type:"text"},"image-feature-extraction":{pipeline:Yi,model:[ku,dr],default:{model:"onnx-community/dinov3-vits16-pretrain-lvd1689m-ONNX",dtype:"fp32"},type:"image"}}),S0=Object.freeze({"sentiment-analysis":"text-classification",ner:"token-classification",asr:"automatic-speech-recognition","text-to-speech":"text-to-audio",embeddings:"feature-extraction"});function T0(t,{warn:e=!0}={}){let r=t.architectures||[];for(let s of r){let n=tr.get(s);if(n!==void 0)return n}if(t.model_type){let s=tr.get(t.model_type);if(s!==void 0)return s;for(let n of Object.values(Qs))if(n.has(t.model_type)){let o=tr.get(n.get(t.model_type));if(o!==void 0)return o}}if(e){let s=r.length>0?r.join(", "):"(none)";Z.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${s}] for model type '${t.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${os}`)}return Q.EncoderOnly}function sv(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 Xu(o,()=>Nt.from_pretrained(t,{config:e,cache_dir:r,local_files_only:s,revision:n}))}async function O0(t,{config:e=null,dtype:r=null,device:s=null,model_file_name:n=null}={}){e=await sv(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,f=T0(e),_=(x,k=null)=>{k=k??x;let E=fp(c,x),A=_p(p,x,E),T=ns[A]??"",S=`${k}${T}.onnx`,P=l?`${l}/${S}`:S;o.push(P);let O=L1(i,S,x);for(let v of N1(S,O)){let W=l?`${l}/${v}`:v;o.push(W)}},{sessions:m,optional_configs:w}=Zf(f,e,{model_file_name:n});for(let[x,k]of Object.entries(m))_(x,k);if(w)for(let x of Object.values(w))o.push(x);return o}async function I0(t){if(!t)throw new Error("modelId is required");return(await Bt(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 O0(t,{config:e,dtype:r,device:s,model_file_name:n});if(o){let l=await jn(t);i.push(...l)}if(a){let l=await I0(t);i.push(...l)}return i}async function Fr(t,e,r={}){t=S0[t]??t;let s=Qi[t];if(!s)throw new Error(`Unsupported pipeline task: ${t}. Must be one of [${Object.keys(Qi).join(", ")}]`);let{type:n}=s;return Br(e,{...r,include_tokenizer:n!=="audio"&&n!=="image",include_processor:n!=="text"})}async function RN(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:f=null,session_options:_={}}={}){t=S0[t]??t;let m=Qi[t.split("_",1)[0]];if(!m)throw Error(`Unsupported pipeline: ${t}. Must be one of [${Object.keys(Qi)}]`);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 Fr(t,e,{device:i,dtype:l}),x={};r&&(await Promise.all(w.map(async H=>Bt(e,H)))).forEach((H,G)=>{H.exists&&(x[w[G]]={loaded:0,total:H.size??0})});let k={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),K=G>0?H/G*100:0;r({status:"progress_total",name:B.name,progress:K,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:f,session_options:_},E=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,k),{model_type:H}=B,G=T.find(K=>K.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,{...k,config:B})}else S=T.from_pretrained(e,k);let[P,O,v]=await Promise.all([E?se.from_pretrained(e,k):null,A?Xl.from_pretrained(e,k):null,S]),W={task:t,model:v};P&&(W.tokenizer=P),O&&(W.processor=O),br(r,{status:"ready",task:t,model:e});let X=m.pipeline;return new X(W)}var DN=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,C0=class{put(e){throw Error("Not implemented")}end(){throw Error("Not implemented")}},nS=ie.IS_PROCESS_AVAILABLE?t=>process.stdout.write(t):t=>console.log(t),P0=class extends C0{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??nS,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(`
|
|
30
|
+
`)?(o=n.slice(this.print_len),this.token_cache=[],this.print_len=0):n.length>0&&DN(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===nS&&ie.IS_PROCESS_AVAILABLE&&this.callback_function?.(`
|
|
31
|
+
`)}},nv=class extends P0{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 Ji=class{constructor(e,r){this.image=e,this.timestamp=r}},Au=class{constructor(e,r){e.length>0&&e[0]instanceof Ke&&(e=e.map((s,n)=>new Ji(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 oS(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(f=>n.onloadedmetadata=f),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 f=0;f<a;++f)l.push(e===1?o/2:f*i);let c=document.createElement("canvas");c.width=n.videoWidth,c.height=n.videoHeight;let p=c.getContext("2d",{willReadFrequently:!0});for(let f of l){n.currentTime=f,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 Ji(m,f);s.push(w)}return n.remove(),new Au(s,o)}async function z0(t,e,r={}){let s=await Jt(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 Yr(s,a,i);return{file:o,cached:!!l}}));return{allCached:n.every(o=>o.cached),files:n}}async function aS(t,e,r={}){let s=await Jt(r?.cache_dir);if(!s)return!1;let{localPath:n,proposedCacheKey:o}=Kr(t,e,r,s);return!!await Yr(s,n,o)}async function iS(t,e={}){if(!t)throw new Error("modelId is required");if(!await aS(t,"config.json",e))return!1;let r=await Br(t,e);return(await z0(t,r,e)).allCached}async function lS(t,e={}){if(!t)throw new Error("modelId is required");let r=await Br(t,e);return await z0(t,r,e)}async function cS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");if(!await aS(e,"config.json",r))return!1;let s=await Fr(t,e,r);return(await z0(e,s,r)).allCached}async function uS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Fr(t,e,r);return await z0(e,s,r)}async function pS(t,e,r={}){let s=await Jt(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 Yr(s,a,i),p=!1;if(c){let f=await s.delete(i),_=!f&&i!==a?await s.delete(a):!1;p=f||_}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 dS(t,e={}){if(!t)throw new Error("modelId is required");let r=await Br(t,e);return await pS(t,r,e)}async function fS(t,e,r={}){if(!t)throw new Error("task is required");if(!e)throw new Error("modelId is required");let s=await Fr(t,e,r);return await pS(e,s,r)}var UN=Object.keys(ns);async function _S(t,{config:e=null,model_file_name:r=null,revision:s="main",cache_dir:n=null,local_files_only:o=!1}={}){e=await sv(t,{config:e,cache_dir:n,local_files_only:o,revision:s});let a="onnx",i=T0(e),{sessions:l}=Zf(i,e,{model_file_name:r}),c=Object.values(l),p={revision:s,cache_dir:n,local_files_only:o};return(await Promise.all(UN.map(async _=>{let m=ns[_]??"",w=await Promise.all(c.map(async x=>{let k=`${a}/${x}${m}.onnx`;return(await Bt(t,k,p)).exists}));return{dtype:_,available:w.every(Boolean)}}))).filter(_=>_.available).map(_=>_.dtype)}var L0=class{static async get_files(e,r={}){return Br(e,r)}static async get_pipeline_files(e,r,s={}){return Fr(e,r,s)}static async get_model_files(e,r={}){return O0(e,r)}static async get_tokenizer_files(e){return jn(e)}static async get_processor_files(e){return I0(e)}static async get_available_dtypes(e,r={}){return _S(e,r)}static async is_cached(e,r={}){return iS(e,r)}static async is_cached_files(e,r={}){return lS(e,r)}static async is_pipeline_cached(e,r,s={}){return cS(e,r,s)}static async is_pipeline_cached_files(e,r,s={}){return uS(e,r,s)}static async get_file_metadata(e,r,s={}){return Bt(e,r,s)}static async clear_cache(e,r={}){return dS(e,r)}static async clear_pipeline_cache(e,r,s={}){return fS(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,Gemma3ForConditionalGeneration,Gemma3ImageProcessor,Gemma3Model,Gemma3PreTrainedModel,Gemma3Processor,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});
|