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AIzM,CAAM,EAAGwP,GAA0B1Z,EAAM,IAAI,CAAC,EAC7E,QACH,CACD,IAAIma,EAAWL,GAAU9Z,EAAM,IAAI,EAC/Bma,IACAjQ,EAASyM,EAASA,EAAS,CAAE,EAAEzM,CAAM,EAAGiQ,CAAQ,GAEpD,IAAIO,EAAsCX,GAAyC/Z,EAAM,IAAI,EACzF0a,IACAxQ,EAASyM,EAASA,EAAS,CAAE,EAAEzM,CAAM,EAAGwQ,CAAmC,EAElF,CACD,OAAOxQ,CACX,CCzTO,IAAIyQ,GAAW,CAClB,MAAO,CACH,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,KACA,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,GACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,KACA,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,KACA,KACA,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,GAAM,CACF,IACA,KACA,GACH,EACD,GAAM,CACF,IACA,KACA,KACA,GACH,EACD,GAAM,CACF,IACA,IACH,EACD,GAAM,CACF,IACA,IACA,KACA,IACH,EACD,GAAM,CACF,IACA,KACA,IACA,IACH,EACD,GAAM,CACF,IACA,GACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,SAAU,CACN,IACA,KACA,KACA,GACH,EACD,QAAS,CACL,IACA,IACA,IACH,EACD,SAAU,CACN,IACA,KACA,IACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,KACA,IACH,EACD,QAAS,CACL,IACA,IACA,IACH,EACD,QAAS,CACL,IACA,IACA,IACH,EACD,QAAS,CACL,KACA,KACA,IACA,GACH,EACD,QAAS,CACL,KACA,IACA,GACH,EACD,QAAS,CACL,IACA,IACA,IACH,EACD,QAAS,CACL,IACA,IACA,IACH,EACD,QAAS,CACL,KACA,IACA,GACH,EACD,QAAS,CACL,KACA,IACA,GACH,EACD,QAAS,CACL,KACA,KACA,IACA,GACH,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Ae,IAAI,YAAY,GACpB,sBAAO,aAAcikB,CAAS,CAC/C,CAEAH,GAAsB","names":["fn","semiver","a","b","bool","HOST_URL","UPLOAD_URL","LOGIN_URL","CONFIG_URL","API_INFO_URL","RUNTIME_URL","SLEEPTIME_URL","SPACE_FETCHER_URL","QUEUE_FULL_MSG","BROKEN_CONNECTION_MSG","CONFIG_ERROR_MSG","SPACE_STATUS_ERROR_MSG","API_INFO_ERROR_MSG","SPACE_METADATA_ERROR_MSG","INVALID_URL_MSG","UNAUTHORIZED_MSG","INVALID_CREDENTIALS_MSG","MISSING_CREDENTIALS_MSG","NODEJS_FS_ERROR_MSG","ROOT_URL_ERROR_MSG","FILE_PROCESSING_ERROR_MSG","resolve_root","base_url","root_path","prioritize_base","get_jwt","space","token","cookies","map_names_to_ids","fns","apis","api_name","id","resolve_config","endpoint","headers","path","config","config_root","config_url","join_urls","response","dep","i","resolve_cookies","http_protocol","host","process_endpoint","cookie_header","get_cookie_header","e","auth","_fetch","hf_token","formData","res","determine_protocol","protocol","pathname","parse_and_set_cookies","cookie","cookie_name","cookie_value","RE_SPACE_NAME","RE_SPACE_DOMAIN","app_reference","_app_reference","_host","ws_protocol","urls","part","transform_api_info","api_info","api_map","transformed_info","category","parameters","returns","dependencyIndex","dependencyTypes","components","input","c","comp","idx","new_param","transform_type","data","component","serializer","signature_type","get_description","get_type","p","r","type","handle_message","last_status","map_data_to_params","endpoint_info","resolved_data","provided_keys","param","index","key","value","view_api","url","upload_files","root_url","files","upload_id","chunkSize","uploadResponses","chunk","file","upload_url","error_text","output","upload","file_data","max_file_size","oversized_files","f","FileData","prepare_files","is_stream","orig_name","size","blob","mime_type","alt_text","Command","command","meta","update_object","object","newValue","stack","walk_and_store_blobs","root","blob_refs","_","new_path","array_refs","skip_queue","fn_queue","post_message","message","origin","_rej","channel","handle_payload","resolved_payload","dependency","with_null_state","updated_payload","payload_index","deps","input_id","handle_blob","self","process_local_file_commands","blobRefs","file_url","name","client","recursively_process_commands","process_single_command","cmd_item","fileBuffer","fullPath","fs","__vitePreload","n","fileData","error","post_data","body","additional_headers","status","predict","data_returned","status_complete","trimmed_endpoint","resolve","reject","app","result","check_space_status","status_callback","_status","stage","space_name","discussions_enabled","check_and_wake_space","space_id","retries","max_retries","check_interval","RE_DISABLED_DISCUSSION","get_space_hardware","hardware","set_space_timeout","timeout","hardware_types","duplicate","options","_private","v","user","original_hardware","requested_hardware","Client","duplicated_space","get_space_reference","regex","match","TextLineStream","#currentLine","chars","controller","lfIndex","crIndex","endIndex","currentLine","stream","decoder","split","fallback","events","signal","iter","utils.stream","line","reader","event","field","utils.split","init","req","utils.fallback","open_stream","event_callbacks","unclosed_events","pending_stream_messages","stream_status","jwt","that","params","_data","close_stream","event_id","abort_controller","apply_diff_stream","pending_diff_streams","new_data","apply_diff","obj","diff","action","apply_edit","target","current","last_path","readable_stream","instance","submit","event_data","trigger_id","all_events","fire_event","events_to_publish","push_event","close","done","resolvers","push","values","push_error","thenable_reject","next","fetch","session_hash","fn_index","get_endpoint_info","websocket","_endpoint","payload","complete","url_params","acc","cancel","reset_request","cancel_request","resolve_heartbeat","handle_render_config","render_config","render_id","d","any_state","any_unload","t","_payload","status_code","evt","hostname","is_iframe","is_zerogpu_space","callback","msg","iterator","ws","_config","heartbeat_url","component_id","fn_name","raw_cookies","noop","identity","x","run","run_all","is_function","thing","safe_not_equal","subscribe","store","callbacks","unsub","get_store_value","split_css_unit","subscriber_queue","readable","start","writable","stop","subscribers","set","new_value","run_queue","subscriber","update","invalidate","derived","stores","initial_value","single","stores_array","auto","started","pending","cleanup","sync","unsubscribers","isMergeableObject","isNonNullObject","isSpecial","stringValue","isReactElement","canUseSymbol","REACT_ELEMENT_TYPE","emptyTarget","val","cloneUnlessOtherwiseSpecified","deepmerge","defaultArrayMerge","source","element","getMergeFunction","customMerge","getEnumerableOwnPropertySymbols","symbol","getKeys","propertyIsOnObject","property","propertyIsUnsafe","mergeObject","destination","sourceIsArray","targetIsArray","sourceAndTargetTypesMatch","array","prev","deepmerge_1","cjs","extendStatics","__extends","__","__assign","s","__rest","__spreadArray","to","from","pack","l","ar","ErrorKind","TYPE","SKELETON_TYPE","isLiteralElement","el","isArgumentElement","isNumberElement","isDateElement","isTimeElement","isSelectElement","isPluralElement","isPoundElement","isTagElement","isNumberSkeleton","isDateTimeSkeleton","SPACE_SEPARATOR_REGEX","DATE_TIME_REGEX","parseDateTimeSkeleton","skeleton","len","WHITE_SPACE_REGEX","parseNumberSkeletonFromString","stringTokens","tokens","_i","stringTokens_1","stringToken","stemAndOptions","stem","_a","options_1","option","icuUnitToEcma","unit","FRACTION_PRECISION_REGEX","SIGNIFICANT_PRECISION_REGEX","INTEGER_WIDTH_REGEX","CONCISE_INTEGER_WIDTH_REGEX","parseSignificantPrecision","str","g1","g2","parseSign","parseConciseScientificAndEngineeringStem","signDisplay","parseNotationOptions","opt","signOpts","parseNumberSkeleton","tokens_1","all","g3","g4","g5","conciseScientificAndEngineeringOpts","timeData","getBestPattern","locale","skeletonCopy","patternPos","patternChar","extraLength","hourLen","dayPeriodLen","dayPeriodChar","hourChar","getDefaultHourSymbolFromLocale","hourCycle","languageTag","regionTag","hourCycles","SPACE_SEPARATOR_START_REGEX","SPACE_SEPARATOR_END_REGEX","createLocation","end","hasNativeStartsWith","hasNativeFromCodePoint","hasNativeFromEntries","hasNativeCodePointAt","hasTrimStart","hasTrimEnd","hasNativeIsSafeInteger","isSafeInteger","REGEX_SUPPORTS_U_AND_Y","re","RE","startsWith","search","position","fromCodePoint","codePoints","elements","length","code","fromEntries","entries","entries_1","k","codePointAt","first","second","trimStart","trimEnd","flag","matchIdentifierAtIndex","IDENTIFIER_PREFIX_RE_1","_isWhiteSpace","_isPatternSyntax","Parser","nestingLevel","parentArgType","expectingCloseTag","char","_isAlpha","startPosition","tagName","childrenResult","children","endTagStartPosition","closingTagNameStartPosition","closingTagName","startOffset","_isPotentialElementNameChar","parseQuoteResult","parseUnquotedResult","parseLeftAngleResult","location","_isAlphaOrSlash","ch","openingBracePosition","startingPosition","endOffset","endPosition","typeStartPosition","argType","typeEndPosition","styleAndLocation","styleStartPosition","style","styleLocation","argCloseResult","location_1","dateTimePattern","typeEndPosition_1","identifierAndLocation","pluralOffset","optionsResult","location_2","nestedBraces","apostrophePosition","expectCloseTag","parsedFirstIdentifier","hasOtherClause","parsedSelectors","selector","selectorLocation","fragmentResult","expectNumberError","invalidNumberError","sign","hasDigits","decimal","offset","kind","prefix","pattern","currentOffset","targetOffset","nextCode","codepoint","pruneLocation","els","parse","opts","memoize","cache","cacheDefault","serializerDefault","strategy","strategyDefault","isPrimitive","monadic","arg","cacheKey","computedValue","variadic","args","assemble","context","serialize","strategyVariadic","strategyMonadic","ObjectWithoutPrototypeCache","strategies","ErrorCode","FormatError","_super","originalMessage","_this","InvalidValueError","variableId","InvalidValueTypeError","MissingValueError","PART_TYPE","mergeLiteral","parts","lastPart","isFormatXMLElementFn","formatToParts","locales","formatters","formats","currentPluralValue","els_1","varName","value_1","formatFn","chunks","rule","mergeConfig","c1","c2","mergeConfigs","defaultConfig","configs","createFastMemoizeCache","createDefaultFormatters","IntlMessageFormat","overrideFormats","parseOpts","supportedLocales","delve","fullKey","keys","partialKey","lookupCache","addToCache","lookup","refLocale","getPossibleLocales","getMessageFromDictionary","dictionary","$dictionary","getLocaleDictionary","hasLocaleDictionary","localeDictionary","getClosestAvailableLocale","relatedLocales","addMessages","partials","dictionary2","newDictionary","queue","removeLoaderFromQueue","loader","getLocaleQueue","getLocalesQueues","localeItem","localeQueue","hasLocaleQueue","loadLocaleQueue","partial","activeFlushes","flush","queues","localeName","__getOwnPropSymbols$2","__hasOwnProp$2","__propIsEnum$2","__objRest$1","exclude","prop","defaultFormats","defaultMissingKeyHandler","getCurrentLocale","defaultOptions","getOptions","rest","initialLocale","$locale","$isLoading","__defProp$1","__defProps","__getOwnPropDescs","__getOwnPropSymbols$1","__hasOwnProp$1","__propIsEnum$1","__defNormalProp$1","__spreadValues$1","__spreadProps","internalLocale","getSubLocales","arr","fallbackLocale","newLocale","loadingDelay","loadingTimer","getLocaleFromNavigator","monadicMemoize","__defProp","__getOwnPropSymbols","__hasOwnProp","__propIsEnum","__defNormalProp","__spreadValues","__objRest","getIntlFormatterOptions","createNumberFormatter","_b","format","createDateFormatter","_c","_d","createTimeFormatter","_e","_f","getNumberFormatter","_g","_h","getDateFormatter","_j","getTimeFormatter","_k","_l","getMessageFormatter","formatMessage","messageObj","defaultValue","formatTime","formatDate","formatNumber","getJSON","$format","supports_adopted_stylesheets","mount_css","base","_url","link","rej","prefix_css","string","version","style_element","stylesheet","importString","rules","css_string","gradio_css_infix","is_dark_rule","new_selector","mediaCssString","j","innerRule","langs","__vite_glob_0_0","__vite_glob_0_1","__vite_glob_0_2","__vite_glob_0_3","__vite_glob_0_4","__vite_glob_0_5","__vite_glob_0_6","__vite_glob_0_7","__vite_glob_0_8","__vite_glob_0_9","__vite_glob_0_10","__vite_glob_0_11","__vite_glob_0_12","__vite_glob_0_13","__vite_glob_0_14","__vite_glob_0_15","__vite_glob_0_16","__vite_glob_0_17","__vite_glob_0_18","__vite_glob_0_19","__vite_glob_0_20","__vite_glob_0_21","__vite_glob_0_22","__vite_glob_0_23","__vite_glob_0_24","process_langs","_langs","lang","processed_langs","setupi18n","ENTRY_CSS","FONTS","IndexComponent","_res","get_index","create_custom_element","o","svelte","GradioApp","mutations","old_val","new_val"],"ignoreList":[0,14,15,16,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"sources":["../../../../node_modules/.pnpm/semiver@1.1.0/node_modules/semiver/dist/semiver.mjs","../../../../client/js/src/constants.ts","../../../../client/js/src/helpers/init_helpers.ts","../../../../client/js/src/helpers/api_info.ts","../../../../client/js/src/utils/view_api.ts","../../../../client/js/src/utils/upload_files.ts","../../../../client/js/src/upload.ts","../../../../client/js/src/types.ts","../../../../client/js/src/helpers/data.ts","../../../../client/js/src/utils/handle_blob.ts","../../../../client/js/src/utils/post_data.ts","../../../../client/js/src/utils/predict.ts","../../../../client/js/src/helpers/spaces.ts","../../../../client/js/src/utils/duplicate.ts","../../../../node_modules/.pnpm/fetch-event-stream@0.1.5/node_modules/fetch-event-stream/esm/deps/jsr.io/@std/streams/0.221.0/text_line_stream.js","../../../../node_modules/.pnpm/fetch-event-stream@0.1.5/node_modules/fetch-event-stream/esm/utils.js","../../../../node_modules/.pnpm/fetch-event-stream@0.1.5/node_modules/fetch-event-stream/esm/mod.js","../../../../client/js/src/utils/stream.ts","../../../../client/js/src/utils/submit.ts","../../../../client/js/src/client.ts","../../../../node_modules/.pnpm/svelte@4.2.15/node_modules/svelte/src/runtime/internal/utils.js","../../../../node_modules/.pnpm/svelte@4.2.15/node_modules/svelte/src/runtime/store/index.js","../../../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js","../../../../node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.es6.mjs","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/error.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/types.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/regex.generated.js","../../../../node_modules/.pnpm/@formatjs+icu-skeleton-parser@1.8.0/node_modules/@formatjs/icu-skeleton-parser/lib/date-time.js","../../../../node_modules/.pnpm/@formatjs+icu-skeleton-parser@1.8.0/node_modules/@formatjs/icu-skeleton-parser/lib/regex.generated.js","../../../../node_modules/.pnpm/@formatjs+icu-skeleton-parser@1.8.0/node_modules/@formatjs/icu-skeleton-parser/lib/number.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/time-data.generated.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/date-time-pattern-generator.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/parser.js","../../../../node_modules/.pnpm/@formatjs+icu-messageformat-parser@2.7.6/node_modules/@formatjs/icu-messageformat-parser/lib/index.js","../../../../node_modules/.pnpm/@formatjs+fast-memoize@2.2.0/node_modules/@formatjs/fast-memoize/lib/index.js","../../../../node_modules/.pnpm/intl-messageformat@10.5.11/node_modules/intl-messageformat/lib/src/error.js","../../../../node_modules/.pnpm/intl-messageformat@10.5.11/node_modules/intl-messageformat/lib/src/formatters.js","../../../../node_modules/.pnpm/intl-messageformat@10.5.11/node_modules/intl-messageformat/lib/src/core.js","../../../../node_modules/.pnpm/svelte-i18n@4.0.0_svelte@4.2.15/node_modules/svelte-i18n/dist/runtime.js","../../../../js/core/src/css.ts","../../../../js/core/src/i18n.ts","../../../../js/spa/src/main.ts"],"sourcesContent":["var fn = new Intl.Collator(0, { numeric:1 }).compare;\n\nexport default function (a, b, bool) {\n\ta = a.split('.');\n\tb = b.split('.');\n\n\treturn fn(a[0], b[0]) || fn(a[1], b[1]) || (\n\t\tb[2] = b.slice(2).join('.'),\n\t\tbool = /[.-]/.test(a[2] = a.slice(2).join('.')),\n\t\tbool == /[.-]/.test(b[2]) ? fn(a[2], b[2]) : bool ? -1 : 1\n\t);\n}\n","// endpoints\nexport const HOST_URL = \"host\";\nexport const API_URL = \"api/predict/\";\nexport const SSE_URL_V0 = \"queue/join\";\nexport const SSE_DATA_URL_V0 = \"queue/data\";\nexport const SSE_URL = \"queue/data\";\nexport const SSE_DATA_URL = \"queue/join\";\nexport const UPLOAD_URL = \"upload\";\nexport const LOGIN_URL = \"login\";\nexport const CONFIG_URL = \"config\";\nexport const API_INFO_URL = \"info\";\nexport const RUNTIME_URL = \"runtime\";\nexport const SLEEPTIME_URL = \"sleeptime\";\nexport const RAW_API_INFO_URL = \"info?serialize=False\";\nexport const SPACE_FETCHER_URL =\n\t\"https://gradio-space-api-fetcher-v2.hf.space/api\";\nexport const RESET_URL = \"reset\";\nexport const SPACE_URL = \"https://hf.space/{}\";\n\n// messages\nexport const QUEUE_FULL_MSG =\n\t\"This application is currently busy. Please try again. \";\nexport const BROKEN_CONNECTION_MSG = \"Connection errored out. \";\nexport const CONFIG_ERROR_MSG = \"Could not resolve app config. \";\nexport const SPACE_STATUS_ERROR_MSG = \"Could not get space status. \";\nexport const API_INFO_ERROR_MSG = \"Could not get API info. \";\nexport const SPACE_METADATA_ERROR_MSG = \"Space metadata could not be loaded. \";\nexport const INVALID_URL_MSG = \"Invalid URL. A full URL path is required.\";\nexport const UNAUTHORIZED_MSG = \"Not authorized to access this space. \";\nexport const INVALID_CREDENTIALS_MSG = \"Invalid credentials. Could not login. \";\nexport const MISSING_CREDENTIALS_MSG =\n\t\"Login credentials are required to access this space.\";\nexport const NODEJS_FS_ERROR_MSG =\n\t\"File system access is only available in Node.js environments\";\nexport const ROOT_URL_ERROR_MSG = \"Root URL not found in client config\";\nexport const FILE_PROCESSING_ERROR_MSG = \"Error uploading file\";\n","import type { Config } from \"../types\";\nimport {\n\tCONFIG_ERROR_MSG,\n\tCONFIG_URL,\n\tINVALID_CREDENTIALS_MSG,\n\tLOGIN_URL,\n\tMISSING_CREDENTIALS_MSG,\n\tSPACE_METADATA_ERROR_MSG,\n\tUNAUTHORIZED_MSG\n} from \"../constants\";\nimport { Client } from \"..\";\nimport { join_urls, process_endpoint } from \"./api_info\";\n\n/**\n * This function is used to resolve the URL for making requests when the app has a root path.\n * The root path could be a path suffix like \"/app\" which is appended to the end of the base URL. Or\n * it could be a full URL like \"https://abidlabs-test-client-replica--gqf2x.hf.space\" which is used when hosting\n * Gradio apps on Hugging Face Spaces.\n * @param {string} base_url The base URL at which the Gradio server is hosted\n * @param {string} root_path The root path, which could be a path suffix (e.g. mounted in FastAPI app) or a full URL (e.g. hosted on Hugging Face Spaces)\n * @param {boolean} prioritize_base Whether to prioritize the base URL over the root path. This is used when both the base path and root paths are full URLs. For example, for fetching files the root path should be prioritized, but for making requests, the base URL should be prioritized.\n * @returns {string} the resolved URL\n */\nexport function resolve_root(\n\tbase_url: string,\n\troot_path: string,\n\tprioritize_base: boolean\n): string {\n\tif (root_path.startsWith(\"http://\") || root_path.startsWith(\"https://\")) {\n\t\treturn prioritize_base ? base_url : root_path;\n\t}\n\treturn base_url + root_path;\n}\n\nexport async function get_jwt(\n\tspace: string,\n\ttoken: `hf_${string}`,\n\tcookies?: string | null\n): Promise {\n\ttry {\n\t\tconst r = await fetch(`https://huggingface.co/api/spaces/${space}/jwt`, {\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t...(cookies ? { Cookie: cookies } : {})\n\t\t\t}\n\t\t});\n\n\t\tconst jwt = (await r.json()).token;\n\n\t\treturn jwt || false;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n\nexport function map_names_to_ids(\n\tfns: Config[\"dependencies\"]\n): Record {\n\tlet apis: Record = {};\n\n\tfns.forEach(({ api_name, id }) => {\n\t\tif (api_name) apis[api_name] = id;\n\t});\n\treturn apis;\n}\n\nexport async function resolve_config(\n\tthis: Client,\n\tendpoint: string\n): Promise {\n\tconst headers: Record = this.options.hf_token\n\t\t? { Authorization: `Bearer ${this.options.hf_token}` }\n\t\t: {};\n\n\theaders[\"Content-Type\"] = \"application/json\";\n\n\tif (\n\t\ttypeof window !== \"undefined\" &&\n\t\twindow.gradio_config &&\n\t\tlocation.origin !== \"http://localhost:9876\" &&\n\t\t!window.gradio_config.dev_mode\n\t) {\n\t\tconst path = window.gradio_config.root;\n\t\tconst config = window.gradio_config;\n\t\tlet config_root = resolve_root(endpoint, config.root, false);\n\t\tconfig.root = config_root;\n\t\treturn { ...config, path } as Config;\n\t} else if (endpoint) {\n\t\tconst config_url = join_urls(endpoint, CONFIG_URL);\n\t\tconst response = await this.fetch(config_url, {\n\t\t\theaders,\n\t\t\tcredentials: \"include\"\n\t\t});\n\n\t\tif (response?.status === 401 && !this.options.auth) {\n\t\t\tthrow new Error(MISSING_CREDENTIALS_MSG);\n\t\t} else if (response?.status === 401 && this.options.auth) {\n\t\t\tthrow new Error(INVALID_CREDENTIALS_MSG);\n\t\t}\n\t\tif (response?.status === 200) {\n\t\t\tlet config = await response.json();\n\t\t\tconfig.path = config.path ?? \"\";\n\t\t\tconfig.root = endpoint;\n\t\t\tconfig.dependencies?.forEach((dep: any, i: number) => {\n\t\t\t\tif (dep.id === undefined) {\n\t\t\t\t\tdep.id = i;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn config;\n\t\t} else if (response?.status === 401) {\n\t\t\tthrow new Error(UNAUTHORIZED_MSG);\n\t\t}\n\t\tthrow new Error(CONFIG_ERROR_MSG);\n\t}\n\n\tthrow new Error(CONFIG_ERROR_MSG);\n}\n\nexport async function resolve_cookies(this: Client): Promise {\n\tconst { http_protocol, host } = await process_endpoint(\n\t\tthis.app_reference,\n\t\tthis.options.hf_token\n\t);\n\n\ttry {\n\t\tif (this.options.auth) {\n\t\t\tconst cookie_header = await get_cookie_header(\n\t\t\t\thttp_protocol,\n\t\t\t\thost,\n\t\t\t\tthis.options.auth,\n\t\t\t\tthis.fetch,\n\t\t\t\tthis.options.hf_token\n\t\t\t);\n\n\t\t\tif (cookie_header) this.set_cookies(cookie_header);\n\t\t}\n\t} catch (e: unknown) {\n\t\tthrow Error((e as Error).message);\n\t}\n}\n\n// separating this from client-bound resolve_cookies so that it can be used in duplicate\nexport async function get_cookie_header(\n\thttp_protocol: string,\n\thost: string,\n\tauth: [string, string],\n\t_fetch: typeof fetch,\n\thf_token?: `hf_${string}`\n): Promise {\n\tconst formData = new FormData();\n\tformData.append(\"username\", auth?.[0]);\n\tformData.append(\"password\", auth?.[1]);\n\n\tlet headers: { Authorization?: string } = {};\n\n\tif (hf_token) {\n\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t}\n\n\tconst res = await _fetch(`${http_protocol}//${host}/${LOGIN_URL}`, {\n\t\theaders,\n\t\tmethod: \"POST\",\n\t\tbody: formData,\n\t\tcredentials: \"include\"\n\t});\n\n\tif (res.status === 200) {\n\t\treturn res.headers.get(\"set-cookie\");\n\t} else if (res.status === 401) {\n\t\tthrow new Error(INVALID_CREDENTIALS_MSG);\n\t} else {\n\t\tthrow new Error(SPACE_METADATA_ERROR_MSG);\n\t}\n}\n\nexport function determine_protocol(endpoint: string): {\n\tws_protocol: \"ws\" | \"wss\";\n\thttp_protocol: \"http:\" | \"https:\";\n\thost: string;\n} {\n\tif (endpoint.startsWith(\"http\")) {\n\t\tconst { protocol, host, pathname } = new URL(endpoint);\n\n\t\tif (host.endsWith(\"hf.space\")) {\n\t\t\treturn {\n\t\t\t\tws_protocol: \"wss\",\n\t\t\t\thost: host,\n\t\t\t\thttp_protocol: protocol as \"http:\" | \"https:\"\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tws_protocol: protocol === \"https:\" ? \"wss\" : \"ws\",\n\t\t\thttp_protocol: protocol as \"http:\" | \"https:\",\n\t\t\thost: host + (pathname !== \"/\" ? pathname : \"\")\n\t\t};\n\t} else if (endpoint.startsWith(\"file:\")) {\n\t\t// This case is only expected to be used for the Wasm mode (Gradio-lite),\n\t\t// where users can create a local HTML file using it and open the page in a browser directly via the `file:` protocol.\n\t\treturn {\n\t\t\tws_protocol: \"ws\",\n\t\t\thttp_protocol: \"http:\",\n\t\t\thost: \"lite.local\" // Special fake hostname only used for this case. This matches the hostname allowed in `is_self_host()` in `js/wasm/network/host.ts`.\n\t\t};\n\t}\n\n\t// default to secure if no protocol is provided\n\treturn {\n\t\tws_protocol: \"wss\",\n\t\thttp_protocol: \"https:\",\n\t\thost: endpoint\n\t};\n}\n\nexport const parse_and_set_cookies = (cookie_header: string): string[] => {\n\tlet cookies: string[] = [];\n\tconst parts = cookie_header.split(/,(?=\\s*[^\\s=;]+=[^\\s=;]+)/);\n\tparts.forEach((cookie) => {\n\t\tconst [cookie_name, cookie_value] = cookie.split(\";\")[0].split(\"=\");\n\t\tif (cookie_name && cookie_value) {\n\t\t\tcookies.push(`${cookie_name.trim()}=${cookie_value.trim()}`);\n\t\t}\n\t});\n\treturn cookies;\n};\n","import {\n\tHOST_URL,\n\tINVALID_URL_MSG,\n\tQUEUE_FULL_MSG,\n\tSPACE_METADATA_ERROR_MSG\n} from \"../constants\";\nimport type {\n\tApiData,\n\tApiInfo,\n\tConfig,\n\tJsApiData,\n\tEndpointInfo,\n\tStatus\n} from \"../types\";\nimport { determine_protocol } from \"./init_helpers\";\n\nexport const RE_SPACE_NAME = /^[a-zA-Z0-9_\\-\\.]+\\/[a-zA-Z0-9_\\-\\.]+$/;\nexport const RE_SPACE_DOMAIN = /.*hf\\.space\\/{0,1}$/;\n\nexport async function process_endpoint(\n\tapp_reference: string,\n\thf_token?: `hf_${string}`\n): Promise<{\n\tspace_id: string | false;\n\thost: string;\n\tws_protocol: \"ws\" | \"wss\";\n\thttp_protocol: \"http:\" | \"https:\";\n}> {\n\tconst headers: { Authorization?: string } = {};\n\tif (hf_token) {\n\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t}\n\n\tconst _app_reference = app_reference.trim().replace(/\\/$/, \"\");\n\n\tif (RE_SPACE_NAME.test(_app_reference)) {\n\t\t// app_reference is a HF space name\n\t\ttry {\n\t\t\tconst res = await fetch(\n\t\t\t\t`https://huggingface.co/api/spaces/${_app_reference}/${HOST_URL}`,\n\t\t\t\t{ headers }\n\t\t\t);\n\n\t\t\tconst _host = (await res.json()).host;\n\n\t\t\treturn {\n\t\t\t\tspace_id: app_reference,\n\t\t\t\t...determine_protocol(_host)\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tthrow new Error(SPACE_METADATA_ERROR_MSG);\n\t\t}\n\t}\n\n\tif (RE_SPACE_DOMAIN.test(_app_reference)) {\n\t\t// app_reference is a direct HF space domain\n\t\tconst { ws_protocol, http_protocol, host } =\n\t\t\tdetermine_protocol(_app_reference);\n\n\t\treturn {\n\t\t\tspace_id: host.replace(\".hf.space\", \"\"),\n\t\t\tws_protocol,\n\t\t\thttp_protocol,\n\t\t\thost\n\t\t};\n\t}\n\n\treturn {\n\t\tspace_id: false,\n\t\t...determine_protocol(_app_reference)\n\t};\n}\n\nexport const join_urls = (...urls: string[]): string => {\n\ttry {\n\t\treturn urls.reduce((base_url: string, part: string) => {\n\t\t\tbase_url = base_url.replace(/\\/+$/, \"\");\n\t\t\tpart = part.replace(/^\\/+/, \"\");\n\t\t\treturn new URL(part, base_url + \"/\").toString();\n\t\t});\n\t} catch (e) {\n\t\tthrow new Error(INVALID_URL_MSG);\n\t}\n};\n\nexport function transform_api_info(\n\tapi_info: ApiInfo,\n\tconfig: Config,\n\tapi_map: Record\n): ApiInfo {\n\tconst transformed_info: ApiInfo = {\n\t\tnamed_endpoints: {},\n\t\tunnamed_endpoints: {}\n\t};\n\n\tObject.keys(api_info).forEach((category) => {\n\t\tif (category === \"named_endpoints\" || category === \"unnamed_endpoints\") {\n\t\t\ttransformed_info[category] = {};\n\n\t\t\tObject.entries(api_info[category]).forEach(\n\t\t\t\t([endpoint, { parameters, returns }]) => {\n\t\t\t\t\tconst dependencyIndex =\n\t\t\t\t\t\tconfig.dependencies.find(\n\t\t\t\t\t\t\t(dep) =>\n\t\t\t\t\t\t\t\tdep.api_name === endpoint ||\n\t\t\t\t\t\t\t\tdep.api_name === endpoint.replace(\"/\", \"\")\n\t\t\t\t\t\t)?.id ||\n\t\t\t\t\t\tapi_map[endpoint.replace(\"/\", \"\")] ||\n\t\t\t\t\t\t-1;\n\n\t\t\t\t\tconst dependencyTypes =\n\t\t\t\t\t\tdependencyIndex !== -1\n\t\t\t\t\t\t\t? config.dependencies.find((dep) => dep.id == dependencyIndex)\n\t\t\t\t\t\t\t\t\t?.types\n\t\t\t\t\t\t\t: { generator: false, cancel: false };\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tdependencyIndex !== -1 &&\n\t\t\t\t\t\tconfig.dependencies.find((dep) => dep.id == dependencyIndex)?.inputs\n\t\t\t\t\t\t\t?.length !== parameters.length\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst components = config.dependencies\n\t\t\t\t\t\t\t.find((dep) => dep.id == dependencyIndex)!\n\t\t\t\t\t\t\t.inputs.map(\n\t\t\t\t\t\t\t\t(input) => config.components.find((c) => c.id === input)?.type\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcomponents.forEach((comp, idx) => {\n\t\t\t\t\t\t\t\tif (comp === \"state\") {\n\t\t\t\t\t\t\t\t\tconst new_param = {\n\t\t\t\t\t\t\t\t\t\tcomponent: \"state\",\n\t\t\t\t\t\t\t\t\t\texample: null,\n\t\t\t\t\t\t\t\t\t\tparameter_default: null,\n\t\t\t\t\t\t\t\t\t\tparameter_has_default: true,\n\t\t\t\t\t\t\t\t\t\tparameter_name: null,\n\t\t\t\t\t\t\t\t\t\thidden: true\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\t\tparameters.splice(idx, 0, new_param);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst transform_type = (\n\t\t\t\t\t\tdata: ApiData,\n\t\t\t\t\t\tcomponent: string,\n\t\t\t\t\t\tserializer: string,\n\t\t\t\t\t\tsignature_type: \"return\" | \"parameter\"\n\t\t\t\t\t): JsApiData => ({\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\tdescription: get_description(data?.type, serializer),\n\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\tget_type(data?.type, component, serializer, signature_type) || \"\"\n\t\t\t\t\t});\n\n\t\t\t\t\ttransformed_info[category][endpoint] = {\n\t\t\t\t\t\tparameters: parameters.map((p: ApiData) =>\n\t\t\t\t\t\t\ttransform_type(p, p?.component, p?.serializer, \"parameter\")\n\t\t\t\t\t\t),\n\t\t\t\t\t\treturns: returns.map((r: ApiData) =>\n\t\t\t\t\t\t\ttransform_type(r, r?.component, r?.serializer, \"return\")\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype: dependencyTypes\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t});\n\n\treturn transformed_info;\n}\n\nexport function get_type(\n\ttype: { type: any; description: string },\n\tcomponent: string,\n\tserializer: string,\n\tsignature_type: \"return\" | \"parameter\"\n): string | undefined {\n\tswitch (type?.type) {\n\t\tcase \"string\":\n\t\t\treturn \"string\";\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\t\tcase \"number\":\n\t\t\treturn \"number\";\n\t}\n\n\tif (\n\t\tserializer === \"JSONSerializable\" ||\n\t\tserializer === \"StringSerializable\"\n\t) {\n\t\treturn \"any\";\n\t} else if (serializer === \"ListStringSerializable\") {\n\t\treturn \"string[]\";\n\t} else if (component === \"Image\") {\n\t\treturn signature_type === \"parameter\" ? \"Blob | File | Buffer\" : \"string\";\n\t} else if (serializer === \"FileSerializable\") {\n\t\tif (type?.type === \"array\") {\n\t\t\treturn signature_type === \"parameter\"\n\t\t\t\t? \"(Blob | File | Buffer)[]\"\n\t\t\t\t: `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]`;\n\t\t}\n\t\treturn signature_type === \"parameter\"\n\t\t\t? \"Blob | File | Buffer\"\n\t\t\t: `{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}`;\n\t} else if (serializer === \"GallerySerializable\") {\n\t\treturn signature_type === \"parameter\"\n\t\t\t? \"[(Blob | File | Buffer), (string | null)][]\"\n\t\t\t: `[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]`;\n\t}\n}\n\nexport function get_description(\n\ttype: { type: any; description: string },\n\tserializer: string\n): string {\n\tif (serializer === \"GallerySerializable\") {\n\t\treturn \"array of [file, label] tuples\";\n\t} else if (serializer === \"ListStringSerializable\") {\n\t\treturn \"array of strings\";\n\t} else if (serializer === \"FileSerializable\") {\n\t\treturn \"array of files or single file\";\n\t}\n\treturn type?.description;\n}\n\n/* eslint-disable complexity */\nexport function handle_message(\n\tdata: any,\n\tlast_status: Status[\"stage\"]\n): {\n\ttype:\n\t\t| \"hash\"\n\t\t| \"data\"\n\t\t| \"update\"\n\t\t| \"complete\"\n\t\t| \"generating\"\n\t\t| \"log\"\n\t\t| \"none\"\n\t\t| \"heartbeat\"\n\t\t| \"unexpected_error\";\n\tdata?: any;\n\tstatus?: Status;\n} {\n\tconst queue = true;\n\tswitch (data.msg) {\n\t\tcase \"send_data\":\n\t\t\treturn { type: \"data\" };\n\t\tcase \"send_hash\":\n\t\t\treturn { type: \"hash\" };\n\t\tcase \"queue_full\":\n\t\t\treturn {\n\t\t\t\ttype: \"update\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tmessage: QUEUE_FULL_MSG,\n\t\t\t\t\tstage: \"error\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tsuccess: data.success\n\t\t\t\t}\n\t\t\t};\n\t\tcase \"heartbeat\":\n\t\t\treturn {\n\t\t\t\ttype: \"heartbeat\"\n\t\t\t};\n\t\tcase \"unexpected_error\":\n\t\t\treturn {\n\t\t\t\ttype: \"unexpected_error\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tmessage: data.message,\n\t\t\t\t\tstage: \"error\",\n\t\t\t\t\tsuccess: false\n\t\t\t\t}\n\t\t\t};\n\t\tcase \"estimation\":\n\t\t\treturn {\n\t\t\t\ttype: \"update\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tstage: last_status || \"pending\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tsize: data.queue_size,\n\t\t\t\t\tposition: data.rank,\n\t\t\t\t\teta: data.rank_eta,\n\t\t\t\t\tsuccess: data.success\n\t\t\t\t}\n\t\t\t};\n\t\tcase \"progress\":\n\t\t\treturn {\n\t\t\t\ttype: \"update\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tprogress_data: data.progress_data,\n\t\t\t\t\tsuccess: data.success\n\t\t\t\t}\n\t\t\t};\n\t\tcase \"log\":\n\t\t\treturn { type: \"log\", data: data };\n\t\tcase \"process_generating\":\n\t\t\treturn {\n\t\t\t\ttype: \"generating\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tmessage: !data.success ? data.output.error : null,\n\t\t\t\t\tstage: data.success ? \"generating\" : \"error\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tprogress_data: data.progress_data,\n\t\t\t\t\teta: data.average_duration\n\t\t\t\t},\n\t\t\t\tdata: data.success ? data.output : null\n\t\t\t};\n\t\tcase \"process_completed\":\n\t\t\tif (\"error\" in data.output) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"update\",\n\t\t\t\t\tstatus: {\n\t\t\t\t\t\tqueue,\n\t\t\t\t\t\tmessage: data.output.error as string,\n\t\t\t\t\t\tvisible: data.output.visible as boolean,\n\t\t\t\t\t\tduration: data.output.duration as number,\n\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\tcode: data.code,\n\t\t\t\t\t\tsuccess: data.success\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"complete\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tmessage: !data.success ? data.output.error : undefined,\n\t\t\t\t\tstage: data.success ? \"complete\" : \"error\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tprogress_data: data.progress_data,\n\t\t\t\t\tchanged_state_ids: data.success\n\t\t\t\t\t\t? data.output.changed_state_ids\n\t\t\t\t\t\t: undefined\n\t\t\t\t},\n\t\t\t\tdata: data.success ? data.output : null\n\t\t\t};\n\n\t\tcase \"process_starts\":\n\t\t\treturn {\n\t\t\t\ttype: \"update\",\n\t\t\t\tstatus: {\n\t\t\t\t\tqueue,\n\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\tcode: data.code,\n\t\t\t\t\tsize: data.rank,\n\t\t\t\t\tposition: 0,\n\t\t\t\t\tsuccess: data.success,\n\t\t\t\t\teta: data.eta\n\t\t\t\t}\n\t\t\t};\n\t}\n\n\treturn { type: \"none\", status: { stage: \"error\", queue } };\n}\n/* eslint-enable complexity */\n\n/**\n * Maps the provided `data` to the parameters defined by the `/info` endpoint response.\n * This allows us to support both positional and keyword arguments passed to the client\n * and ensures that all parameters are either directly provided or have default values assigned.\n *\n * @param {unknown[] | Record} data - The input data for the function,\n * which can be either an array of values for positional arguments or an object\n * with key-value pairs for keyword arguments.\n * @param {JsApiData[]} parameters - Array of parameter descriptions retrieved from the\n * `/info` endpoint.\n *\n * @returns {unknown[]} - Returns an array of resolved data where each element corresponds\n * to the expected parameter from the API. The `parameter_default` value is used where\n * a value is not provided for a parameter, and optional parameters without defaults are\n * \t\t set to `undefined`.\n *\n * @throws {Error} - Throws an error:\n * - If more arguments are provided than are defined in the parameters.\n * * - If no parameter value is provided for a required parameter and no default value is defined.\n * - If an argument is provided that does not match any defined parameter.\n */\n\nexport const map_data_to_params = (\n\tdata: unknown[] | Record = [],\n\tendpoint_info: EndpointInfo\n): unknown[] => {\n\t// Workaround for the case where the endpoint_info is undefined\n\t// See https://github.com/gradio-app/gradio/pull/8820#issuecomment-2237381761\n\tconst parameters = endpoint_info ? endpoint_info.parameters : [];\n\n\tif (Array.isArray(data)) {\n\t\tif (data.length > parameters.length) {\n\t\t\tconsole.warn(\"Too many arguments provided for the endpoint.\");\n\t\t}\n\t\treturn data;\n\t}\n\n\tconst resolved_data: unknown[] = [];\n\tconst provided_keys = Object.keys(data);\n\n\tparameters.forEach((param, index) => {\n\t\tif (data.hasOwnProperty(param.parameter_name)) {\n\t\t\tresolved_data[index] = data[param.parameter_name];\n\t\t} else if (param.parameter_has_default) {\n\t\t\tresolved_data[index] = param.parameter_default;\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`No value provided for required parameter: ${param.parameter_name}`\n\t\t\t);\n\t\t}\n\t});\n\n\tprovided_keys.forEach((key) => {\n\t\tif (!parameters.some((param) => param.parameter_name === key)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Parameter \\`${key}\\` is not a valid keyword argument. Please refer to the API for usage.`\n\t\t\t);\n\t\t}\n\t});\n\n\tresolved_data.forEach((value, idx) => {\n\t\tif (value === undefined && !parameters[idx].parameter_has_default) {\n\t\t\tthrow new Error(\n\t\t\t\t`No value provided for required parameter: ${parameters[idx].parameter_name}`\n\t\t\t);\n\t\t}\n\t});\n\n\treturn resolved_data;\n};\n","import type { ApiInfo, ApiData } from \"../types\";\nimport semiver from \"semiver\";\nimport { API_INFO_URL, BROKEN_CONNECTION_MSG } from \"../constants\";\nimport { Client } from \"../client\";\nimport { SPACE_FETCHER_URL } from \"../constants\";\nimport { join_urls, transform_api_info } from \"../helpers/api_info\";\n\nexport async function view_api(this: Client): Promise {\n\tif (this.api_info) return this.api_info;\n\n\tconst { hf_token } = this.options;\n\tconst { config } = this;\n\n\tconst headers: {\n\t\tAuthorization?: string;\n\t\t\"Content-Type\": \"application/json\";\n\t} = { \"Content-Type\": \"application/json\" };\n\n\tif (hf_token) {\n\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t}\n\n\tif (!config) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tlet response: Response;\n\t\tlet api_info: ApiInfo | { api: ApiInfo };\n\t\tif (typeof window !== \"undefined\" && window.gradio_api_info) {\n\t\t\tapi_info = window.gradio_api_info;\n\t\t} else {\n\t\t\tif (semiver(config?.version || \"2.0.0\", \"3.30\") < 0) {\n\t\t\t\tresponse = await this.fetch(SPACE_FETCHER_URL, {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tserialize: false,\n\t\t\t\t\t\tconfig: JSON.stringify(config)\n\t\t\t\t\t}),\n\t\t\t\t\theaders,\n\t\t\t\t\tcredentials: \"include\"\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst url = join_urls(config.root, API_INFO_URL);\n\t\t\t\tresponse = await this.fetch(url, {\n\t\t\t\t\theaders,\n\t\t\t\t\tcredentials: \"include\"\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(BROKEN_CONNECTION_MSG);\n\t\t\t}\n\t\t\tapi_info = await response.json();\n\t\t}\n\t\tif (\"api\" in api_info) {\n\t\t\tapi_info = api_info.api;\n\t\t}\n\n\t\tif (\n\t\t\tapi_info.named_endpoints[\"/predict\"] &&\n\t\t\t!api_info.unnamed_endpoints[\"0\"]\n\t\t) {\n\t\t\tapi_info.unnamed_endpoints[0] = api_info.named_endpoints[\"/predict\"];\n\t\t}\n\n\t\treturn transform_api_info(api_info, config, this.api_map);\n\t} catch (e) {\n\t\t\"Could not get API info. \" + (e as Error).message;\n\t}\n}\n","import type { Client } from \"..\";\nimport { BROKEN_CONNECTION_MSG, UPLOAD_URL } from \"../constants\";\nimport type { UploadResponse } from \"../types\";\n\nexport async function upload_files(\n\tthis: Client,\n\troot_url: string,\n\tfiles: (Blob | File)[],\n\tupload_id?: string\n): Promise {\n\tconst headers: {\n\t\tAuthorization?: string;\n\t} = {};\n\tif (this?.options?.hf_token) {\n\t\theaders.Authorization = `Bearer ${this.options.hf_token}`;\n\t}\n\n\tconst chunkSize = 1000;\n\tconst uploadResponses = [];\n\tlet response: Response;\n\n\tfor (let i = 0; i < files.length; i += chunkSize) {\n\t\tconst chunk = files.slice(i, i + chunkSize);\n\t\tconst formData = new FormData();\n\t\tchunk.forEach((file) => {\n\t\t\tformData.append(\"files\", file);\n\t\t});\n\t\ttry {\n\t\t\tconst upload_url = upload_id\n\t\t\t\t? `${root_url}/${UPLOAD_URL}?upload_id=${upload_id}`\n\t\t\t\t: `${root_url}/${UPLOAD_URL}`;\n\n\t\t\tresponse = await this.fetch(upload_url, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: formData,\n\t\t\t\theaders,\n\t\t\t\tcredentials: \"include\"\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tthrow new Error(BROKEN_CONNECTION_MSG + (e as Error).message);\n\t\t}\n\t\tif (!response.ok) {\n\t\t\tconst error_text = await response.text();\n\t\t\treturn { error: `HTTP ${response.status}: ${error_text}` };\n\t\t}\n\t\tconst output: UploadResponse[\"files\"] = await response.json();\n\t\tif (output) {\n\t\t\tuploadResponses.push(...output);\n\t\t}\n\t}\n\treturn { files: uploadResponses };\n}\n","import type { UploadResponse } from \"./types\";\nimport type { Client } from \"./client\";\n\nexport async function upload(\n\tthis: Client,\n\tfile_data: FileData[],\n\troot_url: string,\n\tupload_id?: string,\n\tmax_file_size?: number\n): Promise<(FileData | null)[] | null> {\n\tlet files = (Array.isArray(file_data) ? file_data : [file_data]).map(\n\t\t(file_data) => file_data.blob!\n\t);\n\n\tconst oversized_files = files.filter(\n\t\t(f) => f.size > (max_file_size ?? Infinity)\n\t);\n\tif (oversized_files.length) {\n\t\tthrow new Error(\n\t\t\t`File size exceeds the maximum allowed size of ${max_file_size} bytes: ${oversized_files\n\t\t\t\t.map((f) => f.name)\n\t\t\t\t.join(\", \")}`\n\t\t);\n\t}\n\n\treturn await Promise.all(\n\t\tawait this.upload_files(root_url, files, upload_id).then(\n\t\t\tasync (response: { files?: string[]; error?: string }) => {\n\t\t\t\tif (response.error) {\n\t\t\t\t\tthrow new Error(response.error);\n\t\t\t\t} else {\n\t\t\t\t\tif (response.files) {\n\t\t\t\t\t\treturn response.files.map((f, i) => {\n\t\t\t\t\t\t\tconst file = new FileData({\n\t\t\t\t\t\t\t\t...file_data[i],\n\t\t\t\t\t\t\t\tpath: f,\n\t\t\t\t\t\t\t\turl: root_url + \"/file=\" + f\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn file;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t}\n\t\t)\n\t);\n}\n\nexport async function prepare_files(\n\tfiles: File[],\n\tis_stream?: boolean\n): Promise {\n\treturn files.map(\n\t\t(f) =>\n\t\t\tnew FileData({\n\t\t\t\tpath: f.name,\n\t\t\t\torig_name: f.name,\n\t\t\t\tblob: f,\n\t\t\t\tsize: f.size,\n\t\t\t\tmime_type: f.type,\n\t\t\t\tis_stream\n\t\t\t})\n\t);\n}\n\nexport class FileData {\n\tpath: string;\n\turl?: string;\n\torig_name?: string;\n\tsize?: number;\n\tblob?: File;\n\tis_stream?: boolean;\n\tmime_type?: string;\n\talt_text?: string;\n\treadonly meta = { _type: \"gradio.FileData\" };\n\n\tconstructor({\n\t\tpath,\n\t\turl,\n\t\torig_name,\n\t\tsize,\n\t\tblob,\n\t\tis_stream,\n\t\tmime_type,\n\t\talt_text\n\t}: {\n\t\tpath: string;\n\t\turl?: string;\n\t\torig_name?: string;\n\t\tsize?: number;\n\t\tblob?: File;\n\t\tis_stream?: boolean;\n\t\tmime_type?: string;\n\t\talt_text?: string;\n\t}) {\n\t\tthis.path = path;\n\t\tthis.url = url;\n\t\tthis.orig_name = orig_name;\n\t\tthis.size = size;\n\t\tthis.blob = url ? undefined : blob;\n\t\tthis.is_stream = is_stream;\n\t\tthis.mime_type = mime_type;\n\t\tthis.alt_text = alt_text;\n\t}\n}\n","// API Data Types\n\nimport { hardware_types } from \"./helpers/spaces\";\nimport type { SvelteComponent } from \"svelte\";\nimport type { ComponentType } from \"svelte\";\n\nexport interface ApiData {\n\tlabel: string;\n\tparameter_name: string;\n\tparameter_default?: any;\n\tparameter_has_default?: boolean;\n\ttype: {\n\t\ttype: any;\n\t\tdescription: string;\n\t};\n\tcomponent: string;\n\texample_input?: any;\n\tpython_type: { type: string; description: string };\n\tserializer: string;\n}\n\nexport interface JsApiData {\n\tlabel: string;\n\tparameter_name: string;\n\tparameter_default?: any;\n\tparameter_has_default?: boolean;\n\ttype: string;\n\tdescription: string;\n\tcomponent: string;\n\texample_input?: any;\n\tserializer: string;\n\tpython_type: { type: string; description: string };\n}\n\nexport interface EndpointInfo {\n\tparameters: T[];\n\treturns: T[];\n\ttype?: DependencyTypes;\n}\n\nexport interface ApiInfo {\n\tnamed_endpoints: Record>;\n\tunnamed_endpoints: Record>;\n}\n\nexport interface BlobRef {\n\tpath: string[];\n\ttype: string | undefined;\n\tblob: Blob | File | false;\n}\n\nexport type DataType = string | Buffer | Record | any[];\n\n// custom class used for uploading local files\nexport class Command {\n\ttype: string;\n\tcommand: string;\n\tmeta: {\n\t\tpath: string;\n\t\tname: string;\n\t\torig_path: string;\n\t};\n\tfileData?: FileData;\n\n\tconstructor(\n\t\tcommand: string,\n\t\tmeta: { path: string; name: string; orig_path: string }\n\t) {\n\t\tthis.type = \"command\";\n\t\tthis.command = command;\n\t\tthis.meta = meta;\n\t}\n}\n\n// Function Signature Types\n\nexport type SubmitFunction = (\n\tendpoint: string | number,\n\tdata?: unknown[] | Record,\n\tevent_data?: unknown,\n\ttrigger_id?: number | null\n) => SubmitIterable;\n\nexport type PredictFunction = (\n\tendpoint: string | number,\n\tdata?: unknown[] | Record,\n\tevent_data?: unknown\n) => Promise;\n\nexport type client_return = {\n\tconfig: Config | undefined;\n\tpredict: PredictFunction;\n\tsubmit: SubmitFunction;\n\tcomponent_server: (\n\t\tcomponent_id: number,\n\t\tfn_name: string,\n\t\tdata: unknown[]\n\t) => any;\n\tview_api: (_fetch: typeof fetch) => Promise>;\n};\n\nexport interface SubmitIterable extends AsyncIterable {\n\t[Symbol.asyncIterator](): AsyncIterator;\n\tcancel: () => Promise;\n}\n\nexport type PredictReturn = {\n\ttype: EventType;\n\ttime: Date;\n\tdata: unknown;\n\tendpoint: string;\n\tfn_index: number;\n};\n\n// Space Status Types\n\nexport type SpaceStatus = SpaceStatusNormal | SpaceStatusError;\n\nexport interface SpaceStatusNormal {\n\tstatus:\n\t\t| \"sleeping\"\n\t\t| \"running\"\n\t\t| \"building\"\n\t\t| \"error\"\n\t\t| \"stopped\"\n\t\t| \"starting\";\n\tdetail:\n\t\t| \"SLEEPING\"\n\t\t| \"RUNNING\"\n\t\t| \"RUNNING_BUILDING\"\n\t\t| \"BUILDING\"\n\t\t| \"APP_STARTING\"\n\t\t| \"NOT_FOUND\";\n\tload_status: \"pending\" | \"error\" | \"complete\" | \"generating\";\n\tmessage: string;\n}\n\nexport interface SpaceStatusError {\n\tstatus: \"space_error\" | \"paused\";\n\tdetail:\n\t\t| \"NO_APP_FILE\"\n\t\t| \"CONFIG_ERROR\"\n\t\t| \"BUILD_ERROR\"\n\t\t| \"RUNTIME_ERROR\"\n\t\t| \"PAUSED\";\n\tload_status: \"error\";\n\tmessage: string;\n\tdiscussions_enabled: boolean;\n}\n\nexport type SpaceStatusCallback = (a: SpaceStatus) => void;\n\n// Configuration and Response Types\n// --------------------------------\nexport interface Config {\n\tauth_required?: true;\n\tanalytics_enabled: boolean;\n\tconnect_heartbeat: boolean;\n\tauth_message: string;\n\tcomponents: ComponentMeta[];\n\tcss: string | null;\n\tjs: string | null;\n\thead: string | null;\n\tdependencies: Dependency[];\n\tdev_mode: boolean;\n\tenable_queue: boolean;\n\tshow_error: boolean;\n\tlayout: any;\n\tmode: \"blocks\" | \"interface\";\n\troot: string;\n\troot_url?: string;\n\ttheme: string;\n\ttitle: string;\n\tversion: string;\n\tspace_id: string | null;\n\tis_space: boolean;\n\tis_colab: boolean;\n\tshow_api: boolean;\n\tstylesheets: string[];\n\tpath: string;\n\tprotocol: \"sse_v3\" | \"sse_v2.1\" | \"sse_v2\" | \"sse_v1\" | \"sse\" | \"ws\";\n\tmax_file_size?: number;\n\ttheme_hash?: number;\n\tusername: string | null;\n}\n\n// todo: DRY up types\nexport interface ComponentMeta {\n\ttype: string;\n\tid: number;\n\thas_modes: boolean;\n\tprops: SharedProps;\n\tinstance: SvelteComponent;\n\tcomponent: ComponentType;\n\tdocumentation?: Documentation;\n\tchildren?: ComponentMeta[];\n\tparent?: ComponentMeta;\n\tvalue?: any;\n\tcomponent_class_id: string;\n\tkey: string | number | null;\n\trendered_in?: number;\n}\n\ninterface SharedProps {\n\telem_id?: string;\n\telem_classes?: string[];\n\tcomponents?: string[];\n\tserver_fns?: string[];\n\tinteractive: boolean;\n\t[key: string]: unknown;\n\troot_url?: string;\n}\n\nexport interface Documentation {\n\ttype?: TypeDescription;\n\tdescription?: TypeDescription;\n\texample_data?: string;\n}\n\ninterface TypeDescription {\n\tinput_payload?: string;\n\tresponse_object?: string;\n\tpayload?: string;\n}\n\nexport interface Dependency {\n\tid: number;\n\ttargets: [number, string][];\n\tinputs: number[];\n\toutputs: number[];\n\tbackend_fn: boolean;\n\tjs: string | null;\n\tscroll_to_output: boolean;\n\ttrigger: \"click\" | \"load\" | string;\n\tmax_batch_size: number;\n\tshow_progress: \"full\" | \"minimal\" | \"hidden\";\n\tfrontend_fn: ((...args: unknown[]) => Promise) | null;\n\tstatus?: string;\n\tqueue: boolean | null;\n\tevery: number | null;\n\tbatch: boolean;\n\tapi_name: string | null;\n\tcancels: number[];\n\ttypes: DependencyTypes;\n\tcollects_event_data: boolean;\n\tpending_request?: boolean;\n\ttrigger_after?: number;\n\ttrigger_only_on_success?: boolean;\n\ttrigger_mode: \"once\" | \"multiple\" | \"always_last\";\n\tfinal_event: Payload | null;\n\tshow_api: boolean;\n\tzerogpu?: boolean;\n\trendered_in: number | null;\n}\n\nexport interface DependencyTypes {\n\tgenerator: boolean;\n\tcancel: boolean;\n}\n\nexport interface Payload {\n\tfn_index: number;\n\tdata: unknown[];\n\ttime?: Date;\n\tevent_data?: unknown;\n\ttrigger_id?: number | null;\n}\n\nexport interface PostResponse {\n\terror?: string;\n\t[x: string]: any;\n}\n\nexport interface UploadResponse {\n\terror?: string;\n\tfiles?: string[];\n}\n\n// Client and File Handling Types\n\nexport interface DuplicateOptions extends ClientOptions {\n\tprivate?: boolean;\n\thardware?: (typeof hardware_types)[number];\n\ttimeout?: number;\n}\n\nexport interface ClientOptions {\n\thf_token?: `hf_${string}`;\n\tstatus_callback?: SpaceStatusCallback | null;\n\tauth?: [string, string] | null;\n\twith_null_state?: boolean;\n\tevents?: EventType[];\n}\n\nexport interface FileData {\n\tname: string;\n\torig_name?: string;\n\tsize?: number;\n\tdata: string;\n\tblob?: File;\n\tis_file?: boolean;\n\tmime_type?: string;\n\talt_text?: string;\n}\n\n// Event and Listener Types\n\nexport type EventType = \"data\" | \"status\" | \"log\" | \"render\";\n\nexport interface EventMap {\n\tdata: PayloadMessage;\n\tstatus: StatusMessage;\n\tlog: LogMessage;\n\trender: RenderMessage;\n}\n\nexport type GradioEvent = {\n\t[P in EventType]: EventMap[P];\n}[EventType];\n\nexport interface Log {\n\tlog: string;\n\tlevel: \"warning\" | \"info\";\n}\nexport interface Render {\n\tdata: {\n\t\tcomponents: any[];\n\t\tlayout: any;\n\t\tdependencies: Dependency[];\n\t\trender_id: number;\n\t};\n}\n\nexport interface Status {\n\tqueue: boolean;\n\tcode?: string;\n\tsuccess?: boolean;\n\tstage: \"pending\" | \"error\" | \"complete\" | \"generating\";\n\tduration?: number;\n\tvisible?: boolean;\n\tbroken?: boolean;\n\tsize?: number;\n\tposition?: number;\n\teta?: number;\n\tmessage?: string;\n\tprogress_data?: {\n\t\tprogress: number | null;\n\t\tindex: number | null;\n\t\tlength: number | null;\n\t\tunit: string | null;\n\t\tdesc: string | null;\n\t}[];\n\ttime?: Date;\n\tchanged_state_ids?: number[];\n}\n\nexport interface StatusMessage extends Status {\n\ttype: \"status\";\n\tendpoint: string;\n\tfn_index: number;\n}\n\nexport interface PayloadMessage extends Payload {\n\ttype: \"data\";\n\tendpoint: string;\n\tfn_index: number;\n}\n\nexport interface LogMessage extends Log {\n\ttype: \"log\";\n\tendpoint: string;\n\tfn_index: number;\n\tduration: number | null;\n\tvisible: boolean;\n}\n\nexport interface RenderMessage extends Render {\n\ttype: \"render\";\n\tendpoint: string;\n\tfn_index: number;\n}\n","import {\n\ttype ApiData,\n\ttype BlobRef,\n\ttype Config,\n\ttype EndpointInfo,\n\ttype JsApiData,\n\ttype DataType,\n\tCommand,\n\ttype Dependency,\n\ttype ComponentMeta\n} from \"../types\";\nimport { FileData } from \"../upload\";\n\nconst is_node =\n\ttypeof process !== \"undefined\" && process.versions && process.versions.node;\n\nexport function update_object(\n\tobject: { [x: string]: any },\n\tnewValue: any,\n\tstack: (string | number)[]\n): void {\n\twhile (stack.length > 1) {\n\t\tconst key = stack.shift();\n\t\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\t\tobject = object[key];\n\t\t} else {\n\t\t\tthrow new Error(\"Invalid key type\");\n\t\t}\n\t}\n\n\tconst key = stack.shift();\n\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\tobject[key] = newValue;\n\t} else {\n\t\tthrow new Error(\"Invalid key type\");\n\t}\n}\n\nexport async function walk_and_store_blobs(\n\tdata: DataType,\n\ttype: string | undefined = undefined,\n\tpath: string[] = [],\n\troot = false,\n\tendpoint_info: EndpointInfo | undefined = undefined\n): Promise {\n\tif (Array.isArray(data)) {\n\t\tlet blob_refs: BlobRef[] = [];\n\n\t\tawait Promise.all(\n\t\t\tdata.map(async (_, index) => {\n\t\t\t\tlet new_path = path.slice();\n\t\t\t\tnew_path.push(String(index));\n\n\t\t\t\tconst array_refs = await walk_and_store_blobs(\n\t\t\t\t\tdata[index],\n\t\t\t\t\troot\n\t\t\t\t\t\t? endpoint_info?.parameters[index]?.component || undefined\n\t\t\t\t\t\t: type,\n\t\t\t\t\tnew_path,\n\t\t\t\t\tfalse,\n\t\t\t\t\tendpoint_info\n\t\t\t\t);\n\n\t\t\t\tblob_refs = blob_refs.concat(array_refs);\n\t\t\t})\n\t\t);\n\n\t\treturn blob_refs;\n\t} else if (\n\t\t(globalThis.Buffer && data instanceof globalThis.Buffer) ||\n\t\tdata instanceof Blob\n\t) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath: path,\n\t\t\t\tblob: new Blob([data]),\n\t\t\t\ttype\n\t\t\t}\n\t\t];\n\t} else if (typeof data === \"object\" && data !== null) {\n\t\tlet blob_refs: BlobRef[] = [];\n\t\tfor (const key of Object.keys(data) as (keyof typeof data)[]) {\n\t\t\tconst new_path = [...path, key];\n\t\t\tconst value = data[key];\n\n\t\t\tblob_refs = blob_refs.concat(\n\t\t\t\tawait walk_and_store_blobs(\n\t\t\t\t\tvalue,\n\t\t\t\t\tundefined,\n\t\t\t\t\tnew_path,\n\t\t\t\t\tfalse,\n\t\t\t\t\tendpoint_info\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn blob_refs;\n\t}\n\n\treturn [];\n}\n\nexport function skip_queue(id: number, config: Config): boolean {\n\tlet fn_queue = config?.dependencies?.find((dep) => dep.id == id)?.queue;\n\tif (fn_queue != null) {\n\t\treturn !fn_queue;\n\t}\n\treturn !config.enable_queue;\n}\n\n// todo: add jsdoc for this function\n\nexport function post_message(\n\tmessage: any,\n\torigin: string\n): Promise {\n\treturn new Promise((res, _rej) => {\n\t\tconst channel = new MessageChannel();\n\t\tchannel.port1.onmessage = (({ data }) => {\n\t\t\tchannel.port1.close();\n\t\t\tres(data);\n\t\t}) as (ev: MessageEvent) => void;\n\t\twindow.parent.postMessage(message, origin, [channel.port2]);\n\t});\n}\n\nexport function handle_file(\n\tfile_or_url: File | string | Blob | Buffer\n): FileData | Blob | Command {\n\tif (typeof file_or_url === \"string\") {\n\t\tif (\n\t\t\tfile_or_url.startsWith(\"http://\") ||\n\t\t\tfile_or_url.startsWith(\"https://\")\n\t\t) {\n\t\t\treturn {\n\t\t\t\tpath: file_or_url,\n\t\t\t\turl: file_or_url,\n\t\t\t\torig_name: file_or_url.split(\"/\").pop() ?? \"unknown\",\n\t\t\t\tmeta: { _type: \"gradio.FileData\" }\n\t\t\t};\n\t\t}\n\n\t\tif (is_node) {\n\t\t\t// Handle local file paths\n\t\t\treturn new Command(\"upload_file\", {\n\t\t\t\tpath: file_or_url,\n\t\t\t\tname: file_or_url,\n\t\t\t\torig_path: file_or_url\n\t\t\t});\n\t\t}\n\t} else if (typeof File !== \"undefined\" && file_or_url instanceof File) {\n\t\treturn new Blob([file_or_url]);\n\t} else if (file_or_url instanceof Buffer) {\n\t\treturn new Blob([file_or_url]);\n\t} else if (file_or_url instanceof Blob) {\n\t\treturn file_or_url;\n\t}\n\tthrow new Error(\n\t\t\"Invalid input: must be a URL, File, Blob, or Buffer object.\"\n\t);\n}\n\n/**\n * Handles the payload by filtering out state inputs and returning an array of resolved payload values.\n * We send null values for state inputs to the server, but we don't want to include them in the resolved payload.\n *\n * @param resolved_payload - The resolved payload values received from the client or the server\n * @param dependency - The dependency object.\n * @param components - The array of component metadata.\n * @param with_null_state - Optional. Specifies whether to include null values for state inputs. Default is false.\n * @returns An array of resolved payload values, filtered based on the dependency and component metadata.\n */\nexport function handle_payload(\n\tresolved_payload: unknown[],\n\tdependency: Dependency,\n\tcomponents: ComponentMeta[],\n\ttype: \"input\" | \"output\",\n\twith_null_state = false\n): unknown[] {\n\tif (type === \"input\" && !with_null_state) {\n\t\tthrow new Error(\"Invalid code path. Cannot skip state inputs for input.\");\n\t}\n\t// data comes from the server with null state values so we skip\n\tif (type === \"output\" && with_null_state) {\n\t\treturn resolved_payload;\n\t}\n\n\tlet updated_payload: unknown[] = [];\n\tlet payload_index = 0;\n\tconst deps = type === \"input\" ? dependency.inputs : dependency.outputs;\n\tfor (let i = 0; i < deps.length; i++) {\n\t\tconst input_id = deps[i];\n\t\tconst component = components.find((c) => c.id === input_id);\n\n\t\tif (component?.type === \"state\") {\n\t\t\t// input + with_null_state needs us to fill state with null values\n\t\t\tif (with_null_state) {\n\t\t\t\tif (resolved_payload.length === deps.length) {\n\t\t\t\t\tconst value = resolved_payload[payload_index];\n\t\t\t\t\tupdated_payload.push(value);\n\t\t\t\t\tpayload_index++;\n\t\t\t\t} else {\n\t\t\t\t\tupdated_payload.push(null);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// this is output & !with_null_state, we skip state inputs\n\t\t\t\t// the server payload always comes with null state values so we move along the payload index\n\t\t\t\tpayload_index++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// input & !with_null_state isn't a case we care about, server needs null\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tconst value = resolved_payload[payload_index];\n\t\t\tupdated_payload.push(value);\n\t\t\tpayload_index++;\n\t\t}\n\t}\n\n\treturn updated_payload;\n}\n","import { update_object, walk_and_store_blobs } from \"../helpers/data\";\nimport {\n\tCommand,\n\ttype ApiData,\n\ttype EndpointInfo,\n\ttype JsApiData\n} from \"../types\";\nimport { FileData } from \"../upload\";\nimport type { Client } from \"..\";\nimport {\n\tFILE_PROCESSING_ERROR_MSG,\n\tNODEJS_FS_ERROR_MSG,\n\tROOT_URL_ERROR_MSG\n} from \"../constants\";\n\nexport async function handle_blob(\n\tthis: Client,\n\tendpoint: string,\n\tdata: unknown[],\n\tapi_info: EndpointInfo\n): Promise {\n\tconst self = this;\n\n\tawait process_local_file_commands(self, data);\n\n\tconst blobRefs = await walk_and_store_blobs(\n\t\tdata,\n\t\tundefined,\n\t\t[],\n\t\ttrue,\n\t\tapi_info\n\t);\n\n\tconst results = await Promise.all(\n\t\tblobRefs.map(async ({ path, blob, type }) => {\n\t\t\tif (!blob) return { path, type };\n\n\t\t\tconst response = await self.upload_files(endpoint, [blob]);\n\t\t\tconst file_url = response.files && response.files[0];\n\t\t\treturn {\n\t\t\t\tpath,\n\t\t\t\tfile_url,\n\t\t\t\ttype,\n\t\t\t\tname:\n\t\t\t\t\ttypeof File !== \"undefined\" && blob instanceof File\n\t\t\t\t\t\t? blob?.name\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\t\t})\n\t);\n\n\tresults.forEach(({ path, file_url, type, name }) => {\n\t\tif (type === \"Gallery\") {\n\t\t\tupdate_object(data, file_url, path);\n\t\t} else if (file_url) {\n\t\t\tconst file = new FileData({ path: file_url, orig_name: name });\n\t\t\tupdate_object(data, file, path);\n\t\t}\n\t});\n\n\treturn data;\n}\n\nexport async function process_local_file_commands(\n\tclient: Client,\n\tdata: unknown[]\n): Promise {\n\tconst root = client.config?.root || client.config?.root_url;\n\n\tif (!root) {\n\t\tthrow new Error(ROOT_URL_ERROR_MSG);\n\t}\n\n\tawait recursively_process_commands(client, data);\n}\n\nasync function recursively_process_commands(\n\tclient: Client,\n\tdata: any,\n\tpath: string[] = []\n): Promise {\n\tfor (const key in data) {\n\t\tif (data[key] instanceof Command) {\n\t\t\tawait process_single_command(client, data, key);\n\t\t} else if (typeof data[key] === \"object\" && data[key] !== null) {\n\t\t\tawait recursively_process_commands(client, data[key], [...path, key]);\n\t\t}\n\t}\n}\n\nasync function process_single_command(\n\tclient: Client,\n\tdata: any,\n\tkey: string\n): Promise {\n\tlet cmd_item = data[key] as Command;\n\tconst root = client.config?.root || client.config?.root_url;\n\n\tif (!root) {\n\t\tthrow new Error(ROOT_URL_ERROR_MSG);\n\t}\n\n\ttry {\n\t\tlet fileBuffer: Buffer;\n\t\tlet fullPath: string;\n\n\t\t// check if running in a Node.js environment\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tprocess.versions &&\n\t\t\tprocess.versions.node\n\t\t) {\n\t\t\tconst fs = await import(\"fs/promises\");\n\t\t\tconst path = await import(\"path\");\n\n\t\t\tfullPath = path.resolve(process.cwd(), cmd_item.meta.path);\n\t\t\tfileBuffer = await fs.readFile(fullPath); // Read file from disk\n\t\t} else {\n\t\t\tthrow new Error(NODEJS_FS_ERROR_MSG);\n\t\t}\n\n\t\tconst file = new Blob([fileBuffer], { type: \"application/octet-stream\" });\n\n\t\tconst response = await client.upload_files(root, [file]);\n\n\t\tconst file_url = response.files && response.files[0];\n\n\t\tif (file_url) {\n\t\t\tconst fileData = new FileData({\n\t\t\t\tpath: file_url,\n\t\t\t\torig_name: cmd_item.meta.name || \"\"\n\t\t\t});\n\n\t\t\t// replace the command object with the fileData object\n\t\t\tdata[key] = fileData;\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(FILE_PROCESSING_ERROR_MSG, error);\n\t}\n}\n","import { BROKEN_CONNECTION_MSG } from \"../constants\";\nimport type { PostResponse } from \"../types\";\nimport { Client } from \"..\";\n\nexport async function post_data(\n\tthis: Client,\n\turl: string,\n\tbody: unknown,\n\tadditional_headers?: any\n): Promise<[PostResponse, number]> {\n\tconst headers: {\n\t\tAuthorization?: string;\n\t\t\"Content-Type\": \"application/json\";\n\t} = { \"Content-Type\": \"application/json\" };\n\tif (this.options.hf_token) {\n\t\theaders.Authorization = `Bearer ${this.options.hf_token}`;\n\t}\n\ttry {\n\t\tvar response = await this.fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify(body),\n\t\t\theaders: { ...headers, ...additional_headers },\n\t\t\tcredentials: \"include\"\n\t\t});\n\t} catch (e) {\n\t\treturn [{ error: BROKEN_CONNECTION_MSG }, 500];\n\t}\n\tlet output: PostResponse;\n\tlet status: number;\n\ttry {\n\t\toutput = await response.json();\n\t\tstatus = response.status;\n\t} catch (e) {\n\t\toutput = { error: `Could not parse server response: ${e}` };\n\t\tstatus = 500;\n\t}\n\treturn [output, status];\n}\n","import { Client } from \"../client\";\nimport type { Dependency, PredictReturn } from \"../types\";\n\nexport async function predict(\n\tthis: Client,\n\tendpoint: string | number,\n\tdata: unknown[] | Record = {}\n): Promise {\n\tlet data_returned = false;\n\tlet status_complete = false;\n\tlet dependency: Dependency;\n\n\tif (!this.config) {\n\t\tthrow new Error(\"Could not resolve app config\");\n\t}\n\n\tif (typeof endpoint === \"number\") {\n\t\tdependency = this.config.dependencies.find((dep) => dep.id == endpoint)!;\n\t} else {\n\t\tconst trimmed_endpoint = endpoint.replace(/^\\//, \"\");\n\t\tdependency = this.config.dependencies.find(\n\t\t\t(dep) => dep.id == this.api_map[trimmed_endpoint]\n\t\t)!;\n\t}\n\n\treturn new Promise(async (resolve, reject) => {\n\t\tconst app = this.submit(endpoint, data, null, null, true);\n\t\tlet result: unknown;\n\n\t\tfor await (const message of app) {\n\t\t\tif (message.type === \"data\") {\n\t\t\t\tif (status_complete) {\n\t\t\t\t\tresolve(result as PredictReturn);\n\t\t\t\t}\n\t\t\t\tdata_returned = true;\n\t\t\t\tresult = message;\n\t\t\t}\n\n\t\t\tif (message.type === \"status\") {\n\t\t\t\tif (message.stage === \"error\") reject(message);\n\t\t\t\tif (message.stage === \"complete\") {\n\t\t\t\t\tstatus_complete = true;\n\t\t\t\t\t// if complete message comes after data, resolve here\n\t\t\t\t\tif (data_returned) {\n\t\t\t\t\t\tresolve(result as PredictReturn);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n","import {\n\tRUNTIME_URL,\n\tSLEEPTIME_URL,\n\tSPACE_STATUS_ERROR_MSG\n} from \"../constants\";\nimport { RE_SPACE_NAME } from \"./api_info\";\nimport type { SpaceStatusCallback } from \"../types\";\n\nexport async function check_space_status(\n\tid: string,\n\ttype: \"subdomain\" | \"space_name\",\n\tstatus_callback: SpaceStatusCallback\n): Promise {\n\tlet endpoint =\n\t\ttype === \"subdomain\"\n\t\t\t? `https://huggingface.co/api/spaces/by-subdomain/${id}`\n\t\t\t: `https://huggingface.co/api/spaces/${id}`;\n\tlet response;\n\tlet _status;\n\ttry {\n\t\tresponse = await fetch(endpoint);\n\t\t_status = response.status;\n\t\tif (_status !== 200) {\n\t\t\tthrow new Error();\n\t\t}\n\t\tresponse = await response.json();\n\t} catch (e) {\n\t\tstatus_callback({\n\t\t\tstatus: \"error\",\n\t\t\tload_status: \"error\",\n\t\t\tmessage: SPACE_STATUS_ERROR_MSG,\n\t\t\tdetail: \"NOT_FOUND\"\n\t\t});\n\t\treturn;\n\t}\n\n\tif (!response || _status !== 200) return;\n\tconst {\n\t\truntime: { stage },\n\t\tid: space_name\n\t} = response;\n\n\tswitch (stage) {\n\t\tcase \"STOPPED\":\n\t\tcase \"SLEEPING\":\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"sleeping\",\n\t\t\t\tload_status: \"pending\",\n\t\t\t\tmessage: \"Space is asleep. Waking it up...\",\n\t\t\t\tdetail: stage\n\t\t\t});\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tcheck_space_status(id, type, status_callback);\n\t\t\t}, 1000); // poll for status\n\t\t\tbreak;\n\t\tcase \"PAUSED\":\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"paused\",\n\t\t\t\tload_status: \"error\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"This space has been paused by the author. If you would like to try this demo, consider duplicating the space.\",\n\t\t\t\tdetail: stage,\n\t\t\t\tdiscussions_enabled: await discussions_enabled(space_name)\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"RUNNING\":\n\t\tcase \"RUNNING_BUILDING\":\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"running\",\n\t\t\t\tload_status: \"complete\",\n\t\t\t\tmessage: \"Space is running.\",\n\t\t\t\tdetail: stage\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"BUILDING\":\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"building\",\n\t\t\t\tload_status: \"pending\",\n\t\t\t\tmessage: \"Space is building...\",\n\t\t\t\tdetail: stage\n\t\t\t});\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tcheck_space_status(id, type, status_callback);\n\t\t\t}, 1000);\n\t\t\tbreak;\n\t\tcase \"APP_STARTING\":\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"starting\",\n\t\t\t\tload_status: \"pending\",\n\t\t\t\tmessage: \"Space is starting...\",\n\t\t\t\tdetail: stage\n\t\t\t});\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tcheck_space_status(id, type, status_callback);\n\t\t\t}, 1000);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tstatus_callback({\n\t\t\t\tstatus: \"space_error\",\n\t\t\t\tload_status: \"error\",\n\t\t\t\tmessage: \"This space is experiencing an issue.\",\n\t\t\t\tdetail: stage,\n\t\t\t\tdiscussions_enabled: await discussions_enabled(space_name)\n\t\t\t});\n\t\t\tbreak;\n\t}\n}\n\nexport const check_and_wake_space = async (\n\tspace_id: string,\n\tstatus_callback: SpaceStatusCallback\n): Promise => {\n\tlet retries = 0;\n\tconst max_retries = 12;\n\tconst check_interval = 5000;\n\n\treturn new Promise((resolve) => {\n\t\tcheck_space_status(\n\t\t\tspace_id,\n\t\t\tRE_SPACE_NAME.test(space_id) ? \"space_name\" : \"subdomain\",\n\t\t\t(status) => {\n\t\t\t\tstatus_callback(status);\n\n\t\t\t\tif (status.status === \"running\") {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (\n\t\t\t\t\tstatus.status === \"error\" ||\n\t\t\t\t\tstatus.status === \"paused\" ||\n\t\t\t\t\tstatus.status === \"space_error\"\n\t\t\t\t) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (\n\t\t\t\t\tstatus.status === \"sleeping\" ||\n\t\t\t\t\tstatus.status === \"building\"\n\t\t\t\t) {\n\t\t\t\t\tif (retries < max_retries) {\n\t\t\t\t\t\tretries++;\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\tcheck_and_wake_space(space_id, status_callback).then(resolve);\n\t\t\t\t\t\t}, check_interval);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t});\n};\n\nconst RE_DISABLED_DISCUSSION =\n\t/^(?=[^]*\\b[dD]iscussions{0,1}\\b)(?=[^]*\\b[dD]isabled\\b)[^]*$/;\nexport async function discussions_enabled(space_id: string): Promise {\n\ttry {\n\t\tconst r = await fetch(\n\t\t\t`https://huggingface.co/api/spaces/${space_id}/discussions`,\n\t\t\t{\n\t\t\t\tmethod: \"HEAD\"\n\t\t\t}\n\t\t);\n\n\t\tconst error = r.headers.get(\"x-error-message\");\n\n\t\tif (!r.ok || (error && RE_DISABLED_DISCUSSION.test(error))) return false;\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n\nexport async function get_space_hardware(\n\tspace_id: string,\n\thf_token?: `hf_${string}` | undefined\n): Promise<(typeof hardware_types)[number]> {\n\tconst headers: { Authorization?: string } = {};\n\tif (hf_token) {\n\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t}\n\n\ttry {\n\t\tconst res = await fetch(\n\t\t\t`https://huggingface.co/api/spaces/${space_id}/${RUNTIME_URL}`,\n\t\t\t{ headers }\n\t\t);\n\n\t\tif (res.status !== 200)\n\t\t\tthrow new Error(\"Space hardware could not be obtained.\");\n\n\t\tconst { hardware } = await res.json();\n\n\t\treturn hardware.current;\n\t} catch (e: any) {\n\t\tthrow new Error(e.message);\n\t}\n}\n\nexport async function set_space_timeout(\n\tspace_id: string,\n\ttimeout: number,\n\thf_token?: `hf_${string}`\n): Promise {\n\tconst headers: { Authorization?: string } = {};\n\tif (hf_token) {\n\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t}\n\n\tconst body: {\n\t\tseconds?: number;\n\t} = {\n\t\tseconds: timeout\n\t};\n\n\ttry {\n\t\tconst res = await fetch(\n\t\t\t`https://huggingface.co/api/spaces/${space_id}/${SLEEPTIME_URL}`,\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\", ...headers },\n\t\t\t\tbody: JSON.stringify(body)\n\t\t\t}\n\t\t);\n\n\t\tif (res.status !== 200) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Could not set sleep timeout on duplicated Space. Please visit *ADD HF LINK TO SETTINGS* to set a timeout manually to reduce billing charges.\"\n\t\t\t);\n\t\t}\n\n\t\tconst response = await res.json();\n\t\treturn response;\n\t} catch (e: any) {\n\t\tthrow new Error(e.message);\n\t}\n}\n\nexport const hardware_types = [\n\t\"cpu-basic\",\n\t\"cpu-upgrade\",\n\t\"cpu-xl\",\n\t\"t4-small\",\n\t\"t4-medium\",\n\t\"a10g-small\",\n\t\"a10g-large\",\n\t\"a10g-largex2\",\n\t\"a10g-largex4\",\n\t\"a100-large\",\n\t\"zero-a10g\",\n\t\"h100\",\n\t\"h100x8\"\n] as const;\n","import {\n\tget_space_hardware,\n\thardware_types,\n\tset_space_timeout\n} from \"../helpers/spaces\";\nimport type { DuplicateOptions } from \"../types\";\nimport { Client } from \"../client\";\nimport { SPACE_METADATA_ERROR_MSG } from \"../constants\";\nimport {\n\tget_cookie_header,\n\tparse_and_set_cookies\n} from \"../helpers/init_helpers\";\nimport { process_endpoint } from \"../helpers/api_info\";\n\nexport async function duplicate(\n\tapp_reference: string,\n\toptions: DuplicateOptions\n): Promise {\n\tconst { hf_token, private: _private, hardware, timeout, auth } = options;\n\n\tif (hardware && !hardware_types.includes(hardware)) {\n\t\tthrow new Error(\n\t\t\t`Invalid hardware type provided. Valid types are: ${hardware_types\n\t\t\t\t.map((v) => `\"${v}\"`)\n\t\t\t\t.join(\",\")}.`\n\t\t);\n\t}\n\n\tconst { http_protocol, host } = await process_endpoint(\n\t\tapp_reference,\n\t\thf_token\n\t);\n\n\tlet cookies: string[] | null = null;\n\n\tif (auth) {\n\t\tconst cookie_header = await get_cookie_header(\n\t\t\thttp_protocol,\n\t\t\thost,\n\t\t\tauth,\n\t\t\tfetch\n\t\t);\n\n\t\tif (cookie_header) cookies = parse_and_set_cookies(cookie_header);\n\t}\n\n\tconst headers = {\n\t\tAuthorization: `Bearer ${hf_token}`,\n\t\t\"Content-Type\": \"application/json\",\n\t\t...(cookies ? { Cookie: cookies.join(\"; \") } : {})\n\t};\n\n\tconst user = (\n\t\tawait (\n\t\t\tawait fetch(`https://huggingface.co/api/whoami-v2`, {\n\t\t\t\theaders\n\t\t\t})\n\t\t).json()\n\t).name;\n\n\tconst space_name = app_reference.split(\"/\")[1];\n\tconst body: {\n\t\trepository: string;\n\t\tprivate?: boolean;\n\t\thardware?: string;\n\t} = {\n\t\trepository: `${user}/${space_name}`\n\t};\n\n\tif (_private) {\n\t\tbody.private = true;\n\t}\n\n\tlet original_hardware;\n\n\ttry {\n\t\tif (!hardware) {\n\t\t\toriginal_hardware = await get_space_hardware(app_reference, hf_token);\n\t\t}\n\t} catch (e) {\n\t\tthrow Error(SPACE_METADATA_ERROR_MSG + (e as Error).message);\n\t}\n\n\tconst requested_hardware = hardware || original_hardware || \"cpu-basic\";\n\n\tbody.hardware = requested_hardware;\n\n\ttry {\n\t\tconst response = await fetch(\n\t\t\t`https://huggingface.co/api/spaces/${app_reference}/duplicate`,\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify(body)\n\t\t\t}\n\t\t);\n\n\t\tif (response.status === 409) {\n\t\t\ttry {\n\t\t\t\tconst client = await Client.connect(`${user}/${space_name}`, options);\n\t\t\t\treturn client;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Failed to connect Client instance:\", error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else if (response.status !== 200) {\n\t\t\tthrow new Error(response.statusText);\n\t\t}\n\n\t\tconst duplicated_space = await response.json();\n\n\t\tawait set_space_timeout(`${user}/${space_name}`, timeout || 300, hf_token);\n\n\t\treturn await Client.connect(\n\t\t\tget_space_reference(duplicated_space.url),\n\t\t\toptions\n\t\t);\n\t} catch (e: any) {\n\t\tthrow new Error(e);\n\t}\n}\n\nfunction get_space_reference(url: string): any {\n\tconst regex = /https:\\/\\/huggingface.co\\/spaces\\/([^/]+\\/[^/]+)/;\n\tconst match = url.match(regex);\n\tif (match) {\n\t\treturn match[1];\n\t}\n}\n","// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.\n// This module is browser compatible.\n/**\n * Transform a stream into a stream where each chunk is divided by a newline,\n * be it `\\n` or `\\r\\n`. `\\r` can be enabled via the `allowCR` option.\n *\n * @example\n * ```ts\n * import { TextLineStream } from \"@std/streams/text-line-stream\";\n *\n * const res = await fetch(\"https://example.com\");\n * const lines = res.body!\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new TextLineStream());\n * ```\n */\nexport class TextLineStream extends TransformStream {\n #currentLine = \"\";\n /** Constructs a new instance. */\n constructor(options = { allowCR: false }) {\n super({\n transform: (chars, controller) => {\n chars = this.#currentLine + chars;\n while (true) {\n const lfIndex = chars.indexOf(\"\\n\");\n const crIndex = options.allowCR ? chars.indexOf(\"\\r\") : -1;\n if (crIndex !== -1 && crIndex !== (chars.length - 1) &&\n (lfIndex === -1 || (lfIndex - 1) > crIndex)) {\n controller.enqueue(chars.slice(0, crIndex));\n chars = chars.slice(crIndex + 1);\n continue;\n }\n if (lfIndex === -1)\n break;\n const endIndex = chars[lfIndex - 1] === \"\\r\" ? lfIndex - 1 : lfIndex;\n controller.enqueue(chars.slice(0, endIndex));\n chars = chars.slice(lfIndex + 1);\n }\n this.#currentLine = chars;\n },\n flush: (controller) => {\n if (this.#currentLine === \"\")\n return;\n const currentLine = options.allowCR && this.#currentLine.endsWith(\"\\r\")\n ? this.#currentLine.slice(0, -1)\n : this.#currentLine;\n controller.enqueue(currentLine);\n },\n });\n }\n}\n","import { TextLineStream } from './deps/jsr.io/@std/streams/0.221.0/text_line_stream.js';\nexport function stream(input) {\n let decoder = new TextDecoderStream();\n let split = new TextLineStream({ allowCR: true });\n return input.pipeThrough(decoder).pipeThrough(split);\n}\nexport function split(input) {\n let rgx = /[:]\\s*/;\n let match = rgx.exec(input);\n // \": comment\" -> index=0 -> ignore\n let idx = match && match.index;\n if (idx) {\n return [\n input.substring(0, idx),\n input.substring(idx + match[0].length),\n ];\n }\n}\nexport function fallback(headers, key, value) {\n let tmp = headers.get(key);\n if (!tmp)\n headers.set(key, value);\n}\n","import * as utils from './utils.js';\n/**\n * Convert a `Response` body containing Server Sent Events (SSE) into an Async Iterator that yields {@linkcode ServerSentEventMessage} objects.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events}\n *\n * @example\n * ```js\n * // Optional\n * let abort = new AbortController;\n *\n * // Manually fetch a Response\n * let res = await fetch('https://...', {\n * method: 'POST',\n * signal: abort.signal,\n * headers: {\n * 'api-key': 'token ',\n * 'content-type': 'application/json',\n * },\n * body: JSON.stringify({\n * stream: true, // <- hypothetical\n * // ...\n * })\n * });\n *\n * if (res.ok) {\n * let stream = events(res, abort.signal);\n * for await (let event of stream) {\n * console.log('<<', event.data);\n * }\n * }\n * ```\n */\nexport async function* events(res, signal) {\n // TODO: throw error?\n if (!res.body)\n return;\n let iter = utils.stream(res.body);\n let line, reader = iter.getReader();\n let event;\n for (;;) {\n if (signal && signal.aborted) {\n return reader.cancel();\n }\n line = await reader.read();\n if (line.done)\n return;\n if (!line.value) {\n if (event)\n yield event;\n event = undefined;\n continue;\n }\n let [field, value] = utils.split(line.value) || [];\n if (!field)\n continue; // comment or invalid\n if (field === 'data') {\n event ||= {};\n event[field] = event[field] ? (event[field] + '\\n' + value) : value;\n }\n else if (field === 'event') {\n event ||= {};\n event[field] = value;\n }\n else if (field === 'id') {\n event ||= {};\n event[field] = +value || value;\n }\n else if (field === 'retry') {\n event ||= {};\n event[field] = +value || undefined;\n }\n }\n}\n/**\n * Convenience function that will `fetch` with the given arguments and, if ok, will return the {@linkcode events} async iterator.\n *\n * If the response is not ok (status 200-299), the `Response` is thrown.\n *\n * @example\n * ```js\n * // NOTE: throws `Response` if not 2xx status\n * let events = await stream('https://api.openai.com/...', {\n * method: 'POST',\n * headers: {\n * 'Authorization': 'Bearer ',\n * 'Content-Type': 'application/json',\n * },\n * body: JSON.stringify({\n * stream: true,\n * // ...\n * })\n * });\n *\n * for await (let event of events) {\n * console.log('<<', JSON.parse(event.data));\n * }\n * ```\n */\nexport async function stream(input, init) {\n let req = new Request(input, init);\n utils.fallback(req.headers, 'Accept', 'text/event-stream');\n utils.fallback(req.headers, 'Content-Type', 'application/json');\n let r = await fetch(req);\n if (!r.ok)\n throw r;\n return events(r, req.signal);\n}\n","import { BROKEN_CONNECTION_MSG } from \"../constants\";\nimport type { Client } from \"../client\";\nimport { stream } from \"fetch-event-stream\";\n\nexport async function open_stream(this: Client): Promise {\n\tlet {\n\t\tevent_callbacks,\n\t\tunclosed_events,\n\t\tpending_stream_messages,\n\t\tstream_status,\n\t\tconfig,\n\t\tjwt\n\t} = this;\n\n\tconst that = this;\n\n\tif (!config) {\n\t\tthrow new Error(\"Could not resolve app config\");\n\t}\n\n\tstream_status.open = true;\n\n\tlet stream: EventSource | null = null;\n\tlet params = new URLSearchParams({\n\t\tsession_hash: this.session_hash\n\t}).toString();\n\n\tlet url = new URL(`${config.root}/queue/data?${params}`);\n\n\tif (jwt) {\n\t\turl.searchParams.set(\"__sign\", jwt);\n\t}\n\n\tstream = this.stream(url);\n\n\tif (!stream) {\n\t\tconsole.warn(\"Cannot connect to SSE endpoint: \" + url.toString());\n\t\treturn;\n\t}\n\n\tstream.onmessage = async function (event: MessageEvent) {\n\t\tlet _data = JSON.parse(event.data);\n\t\tif (_data.msg === \"close_stream\") {\n\t\t\tclose_stream(stream_status, that.abort_controller);\n\t\t\treturn;\n\t\t}\n\t\tconst event_id = _data.event_id;\n\t\tif (!event_id) {\n\t\t\tawait Promise.all(\n\t\t\t\tObject.keys(event_callbacks).map((event_id) =>\n\t\t\t\t\tevent_callbacks[event_id](_data)\n\t\t\t\t)\n\t\t\t);\n\t\t} else if (event_callbacks[event_id] && config) {\n\t\t\tif (\n\t\t\t\t_data.msg === \"process_completed\" &&\n\t\t\t\t[\"sse\", \"sse_v1\", \"sse_v2\", \"sse_v2.1\", \"sse_v3\"].includes(\n\t\t\t\t\tconfig.protocol\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tunclosed_events.delete(event_id);\n\t\t\t}\n\t\t\tlet fn: (data: any) => void = event_callbacks[event_id];\n\n\t\t\tif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n\t\t\t\t// fn(_data); // need to do this to put the event on the end of the event loop, so the browser can refresh between callbacks and not freeze in case of quick generations. See\n\t\t\t\tsetTimeout(fn, 0, _data); // need to do this to put the event on the end of the event loop, so the browser can refresh between callbacks and not freeze in case of quick generations. See https://github.com/gradio-app/gradio/pull/7055\n\t\t\t} else {\n\t\t\t\tfn(_data);\n\t\t\t}\n\t\t} else {\n\t\t\tif (!pending_stream_messages[event_id]) {\n\t\t\t\tpending_stream_messages[event_id] = [];\n\t\t\t}\n\t\t\tpending_stream_messages[event_id].push(_data);\n\t\t}\n\t};\n\tstream.onerror = async function () {\n\t\tawait Promise.all(\n\t\t\tObject.keys(event_callbacks).map((event_id) =>\n\t\t\t\tevent_callbacks[event_id]({\n\t\t\t\t\tmsg: \"unexpected_error\",\n\t\t\t\t\tmessage: BROKEN_CONNECTION_MSG\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t};\n}\n\nexport function close_stream(\n\tstream_status: { open: boolean },\n\tabort_controller: AbortController | null\n): void {\n\tif (stream_status) {\n\t\tstream_status.open = false;\n\t\tabort_controller?.abort();\n\t}\n}\n\nexport function apply_diff_stream(\n\tpending_diff_streams: Record,\n\tevent_id: string,\n\tdata: any\n): void {\n\tlet is_first_generation = !pending_diff_streams[event_id];\n\tif (is_first_generation) {\n\t\tpending_diff_streams[event_id] = [];\n\t\tdata.data.forEach((value: any, i: number) => {\n\t\t\tpending_diff_streams[event_id][i] = value;\n\t\t});\n\t} else {\n\t\tdata.data.forEach((value: any, i: number) => {\n\t\t\tlet new_data = apply_diff(pending_diff_streams[event_id][i], value);\n\t\t\tpending_diff_streams[event_id][i] = new_data;\n\t\t\tdata.data[i] = new_data;\n\t\t});\n\t}\n}\n\nexport function apply_diff(\n\tobj: any,\n\tdiff: [string, (number | string)[], any][]\n): any {\n\tdiff.forEach(([action, path, value]) => {\n\t\tobj = apply_edit(obj, path, action, value);\n\t});\n\n\treturn obj;\n}\n\nfunction apply_edit(\n\ttarget: any,\n\tpath: (number | string)[],\n\taction: string,\n\tvalue: any\n): any {\n\tif (path.length === 0) {\n\t\tif (action === \"replace\") {\n\t\t\treturn value;\n\t\t} else if (action === \"append\") {\n\t\t\treturn target + value;\n\t\t}\n\t\tthrow new Error(`Unsupported action: ${action}`);\n\t}\n\n\tlet current = target;\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tcurrent = current[path[i]];\n\t}\n\n\tconst last_path = path[path.length - 1];\n\tswitch (action) {\n\t\tcase \"replace\":\n\t\t\tcurrent[last_path] = value;\n\t\t\tbreak;\n\t\tcase \"append\":\n\t\t\tcurrent[last_path] += value;\n\t\t\tbreak;\n\t\tcase \"add\":\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tcurrent.splice(Number(last_path), 0, value);\n\t\t\t} else {\n\t\t\t\tcurrent[last_path] = value;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase \"delete\":\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tcurrent.splice(Number(last_path), 1);\n\t\t\t} else {\n\t\t\t\tdelete current[last_path];\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown action: ${action}`);\n\t}\n\treturn target;\n}\n\nexport function readable_stream(\n\tinput: RequestInfo | URL,\n\tinit: RequestInit = {}\n): EventSource {\n\tconst instance: EventSource & { readyState: number } = {\n\t\tclose: () => {\n\t\t\tconsole.warn(\"Method not implemented.\");\n\t\t},\n\t\tonerror: null,\n\t\tonmessage: null,\n\t\tonopen: null,\n\t\treadyState: 0,\n\t\turl: input.toString(),\n\t\twithCredentials: false,\n\t\tCONNECTING: 0,\n\t\tOPEN: 1,\n\t\tCLOSED: 2,\n\t\taddEventListener: () => {\n\t\t\tthrow new Error(\"Method not implemented.\");\n\t\t},\n\t\tdispatchEvent: () => {\n\t\t\tthrow new Error(\"Method not implemented.\");\n\t\t},\n\t\tremoveEventListener: () => {\n\t\t\tthrow new Error(\"Method not implemented.\");\n\t\t}\n\t};\n\n\tstream(input, init)\n\t\t.then(async (res) => {\n\t\t\tinstance.readyState = instance.OPEN;\n\t\t\ttry {\n\t\t\t\tfor await (const chunk of res) {\n\t\t\t\t\t//@ts-ignore\n\t\t\t\t\tinstance.onmessage && instance.onmessage(chunk);\n\t\t\t\t}\n\t\t\t\tinstance.readyState = instance.CLOSED;\n\t\t\t} catch (e) {\n\t\t\t\tinstance.onerror && instance.onerror(e as Event);\n\t\t\t\tinstance.readyState = instance.CLOSED;\n\t\t\t}\n\t\t})\n\t\t.catch((e) => {\n\t\t\tconsole.error(e);\n\t\t\tinstance.onerror && instance.onerror(e as Event);\n\t\t\tinstance.readyState = instance.CLOSED;\n\t\t});\n\n\treturn instance as EventSource;\n}\n","/* eslint-disable complexity */\nimport type {\n\tStatus,\n\tPayload,\n\tGradioEvent,\n\tJsApiData,\n\tEndpointInfo,\n\tApiInfo,\n\tConfig,\n\tDependency,\n\tSubmitIterable\n} from \"../types\";\n\nimport { skip_queue, post_message, handle_payload } from \"../helpers/data\";\nimport { resolve_root } from \"../helpers/init_helpers\";\nimport {\n\thandle_message,\n\tmap_data_to_params,\n\tprocess_endpoint\n} from \"../helpers/api_info\";\nimport semiver from \"semiver\";\nimport { BROKEN_CONNECTION_MSG, QUEUE_FULL_MSG } from \"../constants\";\nimport { apply_diff_stream, close_stream } from \"./stream\";\nimport { Client } from \"../client\";\n\nexport function submit(\n\tthis: Client,\n\tendpoint: string | number,\n\tdata: unknown[] | Record = {},\n\tevent_data?: unknown,\n\ttrigger_id?: number | null,\n\tall_events?: boolean\n): SubmitIterable {\n\ttry {\n\t\tconst { hf_token } = this.options;\n\t\tconst {\n\t\t\tfetch,\n\t\t\tapp_reference,\n\t\t\tconfig,\n\t\t\tsession_hash,\n\t\t\tapi_info,\n\t\t\tapi_map,\n\t\t\tstream_status,\n\t\t\tpending_stream_messages,\n\t\t\tpending_diff_streams,\n\t\t\tevent_callbacks,\n\t\t\tunclosed_events,\n\t\t\tpost_data,\n\t\t\toptions\n\t\t} = this;\n\n\t\tconst that = this;\n\n\t\tif (!api_info) throw new Error(\"No API found\");\n\t\tif (!config) throw new Error(\"Could not resolve app config\");\n\n\t\tlet { fn_index, endpoint_info, dependency } = get_endpoint_info(\n\t\t\tapi_info,\n\t\t\tendpoint,\n\t\t\tapi_map,\n\t\t\tconfig\n\t\t);\n\n\t\tlet resolved_data = map_data_to_params(data, endpoint_info);\n\n\t\tlet websocket: WebSocket;\n\t\tlet stream: EventSource | null;\n\t\tlet protocol = config.protocol ?? \"ws\";\n\n\t\tconst _endpoint = typeof endpoint === \"number\" ? \"/predict\" : endpoint;\n\t\tlet payload: Payload;\n\t\tlet event_id: string | null = null;\n\t\tlet complete: Status | undefined | false = false;\n\t\tlet last_status: Record = {};\n\t\tlet url_params =\n\t\t\ttypeof window !== \"undefined\" && typeof document !== \"undefined\"\n\t\t\t\t? new URLSearchParams(window.location.search).toString()\n\t\t\t\t: \"\";\n\n\t\tconst events_to_publish =\n\t\t\toptions?.events?.reduce(\n\t\t\t\t(acc, event) => {\n\t\t\t\t\tacc[event] = true;\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{} as Record\n\t\t\t) || {};\n\n\t\t// event subscription methods\n\t\tfunction fire_event(event: GradioEvent): void {\n\t\t\tif (all_events || events_to_publish[event.type]) {\n\t\t\t\tpush_event(event);\n\t\t\t}\n\t\t}\n\n\t\tasync function cancel(): Promise {\n\t\t\tconst _status: Status = {\n\t\t\t\tstage: \"complete\",\n\t\t\t\tqueue: false,\n\t\t\t\ttime: new Date()\n\t\t\t};\n\t\t\tcomplete = _status;\n\t\t\tfire_event({\n\t\t\t\t..._status,\n\t\t\t\ttype: \"status\",\n\t\t\t\tendpoint: _endpoint,\n\t\t\t\tfn_index: fn_index\n\t\t\t});\n\n\t\t\tlet reset_request = {};\n\t\t\tlet cancel_request = {};\n\t\t\tif (protocol === \"ws\") {\n\t\t\t\tif (websocket && websocket.readyState === 0) {\n\t\t\t\t\twebsocket.addEventListener(\"open\", () => {\n\t\t\t\t\t\twebsocket.close();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\twebsocket.close();\n\t\t\t\t}\n\t\t\t\treset_request = { fn_index, session_hash };\n\t\t\t} else {\n\t\t\t\tclose_stream(stream_status, that.abort_controller);\n\t\t\t\tclose();\n\t\t\t\treset_request = { event_id };\n\t\t\t\tcancel_request = { event_id, session_hash, fn_index };\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tif (!config) {\n\t\t\t\t\tthrow new Error(\"Could not resolve app config\");\n\t\t\t\t}\n\n\t\t\t\tif (\"event_id\" in cancel_request) {\n\t\t\t\t\tawait fetch(`${config.root}/cancel`, {\n\t\t\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: JSON.stringify(cancel_request)\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tawait fetch(`${config.root}/reset`, {\n\t\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: JSON.stringify(reset_request)\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable.\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst resolve_heartbeat = async (config: Config): Promise => {\n\t\t\tawait this._resolve_hearbeat(config);\n\t\t};\n\n\t\tasync function handle_render_config(render_config: any): Promise {\n\t\t\tif (!config) return;\n\t\t\tlet render_id: number = render_config.render_id;\n\t\t\tconfig.components = [\n\t\t\t\t...config.components.filter((c) => c.props.rendered_in !== render_id),\n\t\t\t\t...render_config.components\n\t\t\t];\n\t\t\tconfig.dependencies = [\n\t\t\t\t...config.dependencies.filter((d) => d.rendered_in !== render_id),\n\t\t\t\t...render_config.dependencies\n\t\t\t];\n\t\t\tconst any_state = config.components.some((c) => c.type === \"state\");\n\t\t\tconst any_unload = config.dependencies.some((d) =>\n\t\t\t\td.targets.some((t) => t[1] === \"unload\")\n\t\t\t);\n\t\t\tconfig.connect_heartbeat = any_state || any_unload;\n\t\t\tawait resolve_heartbeat(config);\n\t\t\tfire_event({\n\t\t\t\ttype: \"render\",\n\t\t\t\tdata: render_config,\n\t\t\t\tendpoint: _endpoint,\n\t\t\t\tfn_index\n\t\t\t});\n\t\t}\n\n\t\tthis.handle_blob(config.root, resolved_data, endpoint_info).then(\n\t\t\tasync (_payload) => {\n\t\t\t\tlet input_data = handle_payload(\n\t\t\t\t\t_payload,\n\t\t\t\t\tdependency,\n\t\t\t\t\tconfig.components,\n\t\t\t\t\t\"input\",\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tpayload = {\n\t\t\t\t\tdata: input_data || [],\n\t\t\t\t\tevent_data,\n\t\t\t\t\tfn_index,\n\t\t\t\t\ttrigger_id\n\t\t\t\t};\n\t\t\t\tif (skip_queue(fn_index, config)) {\n\t\t\t\t\tfire_event({\n\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\t\tqueue: false,\n\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t});\n\n\t\t\t\t\tpost_data(\n\t\t\t\t\t\t`${config.root}/run${\n\t\t\t\t\t\t\t_endpoint.startsWith(\"/\") ? _endpoint : `/${_endpoint}`\n\t\t\t\t\t\t}${url_params ? \"?\" + url_params : \"\"}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...payload,\n\t\t\t\t\t\t\tsession_hash\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t\t\t.then(([output, status_code]: any) => {\n\t\t\t\t\t\t\tconst data = output.data;\n\t\t\t\t\t\t\tif (status_code == 200) {\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\tdata: handle_payload(\n\t\t\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t\t\t\tdependency,\n\t\t\t\t\t\t\t\t\t\tconfig.components,\n\t\t\t\t\t\t\t\t\t\t\"output\",\n\t\t\t\t\t\t\t\t\t\toptions.with_null_state\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\tevent_data,\n\t\t\t\t\t\t\t\t\ttrigger_id\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (output.render_config) {\n\t\t\t\t\t\t\t\t\thandle_render_config(output.render_config);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\tstage: \"complete\",\n\t\t\t\t\t\t\t\t\teta: output.average_duration,\n\t\t\t\t\t\t\t\t\tqueue: false,\n\t\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\tmessage: output.error,\n\t\t\t\t\t\t\t\t\tqueue: false,\n\t\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((e) => {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\tmessage: e.message,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\tqueue: false,\n\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t} else if (protocol == \"ws\") {\n\t\t\t\t\tconst { ws_protocol, host } = await process_endpoint(\n\t\t\t\t\t\tapp_reference,\n\t\t\t\t\t\thf_token\n\t\t\t\t\t);\n\n\t\t\t\t\tfire_event({\n\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t});\n\n\t\t\t\t\tlet url = new URL(\n\t\t\t\t\t\t`${ws_protocol}://${resolve_root(\n\t\t\t\t\t\t\thost,\n\t\t\t\t\t\t\tconfig.path as string,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t)}/queue/join${url_params ? \"?\" + url_params : \"\"}`\n\t\t\t\t\t);\n\n\t\t\t\t\tif (this.jwt) {\n\t\t\t\t\t\turl.searchParams.set(\"__sign\", this.jwt);\n\t\t\t\t\t}\n\n\t\t\t\t\twebsocket = new WebSocket(url);\n\n\t\t\t\t\twebsocket.onclose = (evt) => {\n\t\t\t\t\t\tif (!evt.wasClean) {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\tbroken: true,\n\t\t\t\t\t\t\t\tmessage: BROKEN_CONNECTION_MSG,\n\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\twebsocket.onmessage = function (event) {\n\t\t\t\t\t\tconst _data = JSON.parse(event.data);\n\t\t\t\t\t\tconst { type, status, data } = handle_message(\n\t\t\t\t\t\t\t_data,\n\t\t\t\t\t\t\tlast_status[fn_index]\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (type === \"update\" && status && !complete) {\n\t\t\t\t\t\t\t// call 'status' listeners\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t...status\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (status.stage === \"error\") {\n\t\t\t\t\t\t\t\twebsocket.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"hash\") {\n\t\t\t\t\t\t\twebsocket.send(JSON.stringify({ fn_index, session_hash }));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} else if (type === \"data\") {\n\t\t\t\t\t\t\twebsocket.send(JSON.stringify({ ...payload, session_hash }));\n\t\t\t\t\t\t} else if (type === \"complete\") {\n\t\t\t\t\t\t\tcomplete = status;\n\t\t\t\t\t\t} else if (type === \"log\") {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"log\",\n\t\t\t\t\t\t\t\tlog: data.log,\n\t\t\t\t\t\t\t\tlevel: data.level,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\t\tvisible: data.visible,\n\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (type === \"generating\") {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t...status,\n\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (data) {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\tdata: handle_payload(\n\t\t\t\t\t\t\t\t\tdata.data,\n\t\t\t\t\t\t\t\t\tdependency,\n\t\t\t\t\t\t\t\t\tconfig.components,\n\t\t\t\t\t\t\t\t\t\"output\",\n\t\t\t\t\t\t\t\t\toptions.with_null_state\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\tevent_data,\n\t\t\t\t\t\t\t\ttrigger_id\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (complete) {\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t...complete,\n\t\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\twebsocket.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// different ws contract for gradio versions older than 3.6.0\n\t\t\t\t\t//@ts-ignore\n\t\t\t\t\tif (semiver(config.version || \"2.0.0\", \"3.6\") < 0) {\n\t\t\t\t\t\taddEventListener(\"open\", () =>\n\t\t\t\t\t\t\twebsocket.send(JSON.stringify({ hash: session_hash }))\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (protocol == \"sse\") {\n\t\t\t\t\tfire_event({\n\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t});\n\t\t\t\t\tvar params = new URLSearchParams({\n\t\t\t\t\t\tfn_index: fn_index.toString(),\n\t\t\t\t\t\tsession_hash: session_hash\n\t\t\t\t\t}).toString();\n\t\t\t\t\tlet url = new URL(\n\t\t\t\t\t\t`${config.root}/queue/join?${\n\t\t\t\t\t\t\turl_params ? url_params + \"&\" : \"\"\n\t\t\t\t\t\t}${params}`\n\t\t\t\t\t);\n\n\t\t\t\t\tif (this.jwt) {\n\t\t\t\t\t\turl.searchParams.set(\"__sign\", this.jwt);\n\t\t\t\t\t}\n\n\t\t\t\t\tstream = this.stream(url);\n\n\t\t\t\t\tif (!stream) {\n\t\t\t\t\t\treturn Promise.reject(\n\t\t\t\t\t\t\tnew Error(\"Cannot connect to SSE endpoint: \" + url.toString())\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tstream.onmessage = async function (event: MessageEvent) {\n\t\t\t\t\t\tconst _data = JSON.parse(event.data);\n\t\t\t\t\t\tconst { type, status, data } = handle_message(\n\t\t\t\t\t\t\t_data,\n\t\t\t\t\t\t\tlast_status[fn_index]\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (type === \"update\" && status && !complete) {\n\t\t\t\t\t\t\t// call 'status' listeners\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t...status\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (status.stage === \"error\") {\n\t\t\t\t\t\t\t\tstream?.close();\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"data\") {\n\t\t\t\t\t\t\tevent_id = _data.event_id as string;\n\t\t\t\t\t\t\tlet [_, status] = await post_data(`${config.root}/queue/data`, {\n\t\t\t\t\t\t\t\t...payload,\n\t\t\t\t\t\t\t\tsession_hash,\n\t\t\t\t\t\t\t\tevent_id\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (status !== 200) {\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\t\tmessage: BROKEN_CONNECTION_MSG,\n\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tstream?.close();\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (type === \"complete\") {\n\t\t\t\t\t\t\tcomplete = status;\n\t\t\t\t\t\t} else if (type === \"log\") {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"log\",\n\t\t\t\t\t\t\t\tlog: data.log,\n\t\t\t\t\t\t\t\tlevel: data.level,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\t\tvisible: data.visible,\n\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (type === \"generating\") {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t...status,\n\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (data) {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\tdata: handle_payload(\n\t\t\t\t\t\t\t\t\tdata.data,\n\t\t\t\t\t\t\t\t\tdependency,\n\t\t\t\t\t\t\t\t\tconfig.components,\n\t\t\t\t\t\t\t\t\t\"output\",\n\t\t\t\t\t\t\t\t\toptions.with_null_state\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\tevent_data,\n\t\t\t\t\t\t\t\ttrigger_id\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (complete) {\n\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t...complete,\n\t\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tstream?.close();\n\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} else if (\n\t\t\t\t\tprotocol == \"sse_v1\" ||\n\t\t\t\t\tprotocol == \"sse_v2\" ||\n\t\t\t\t\tprotocol == \"sse_v2.1\" ||\n\t\t\t\t\tprotocol == \"sse_v3\"\n\t\t\t\t) {\n\t\t\t\t\t// latest API format. v2 introduces sending diffs for intermediate outputs in generative functions, which makes payloads lighter.\n\t\t\t\t\t// v3 only closes the stream when the backend sends the close stream message.\n\t\t\t\t\tfire_event({\n\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\tstage: \"pending\",\n\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t});\n\t\t\t\t\tlet hostname = \"\";\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof window !== \"undefined\" &&\n\t\t\t\t\t\ttypeof document !== \"undefined\"\n\t\t\t\t\t) {\n\t\t\t\t\t\thostname = window?.location?.hostname;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet hfhubdev = \"dev.spaces.huggingface.tech\";\n\t\t\t\t\tconst origin = hostname.includes(\".dev.\")\n\t\t\t\t\t\t? `https://moon-${hostname.split(\".\")[1]}.${hfhubdev}`\n\t\t\t\t\t\t: `https://huggingface.co`;\n\n\t\t\t\t\tconst is_iframe =\n\t\t\t\t\t\ttypeof window !== \"undefined\" &&\n\t\t\t\t\t\ttypeof document !== \"undefined\" &&\n\t\t\t\t\t\twindow.parent != window;\n\t\t\t\t\tconst is_zerogpu_space = dependency.zerogpu && config.space_id;\n\t\t\t\t\tconst zerogpu_auth_promise =\n\t\t\t\t\t\tis_iframe && is_zerogpu_space\n\t\t\t\t\t\t\t? post_message(\"zerogpu-headers\", origin)\n\t\t\t\t\t\t\t: Promise.resolve(null);\n\t\t\t\t\tconst post_data_promise = zerogpu_auth_promise.then((headers) => {\n\t\t\t\t\t\treturn post_data(\n\t\t\t\t\t\t\t`${config.root}/queue/join?${url_params}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...payload,\n\t\t\t\t\t\t\t\tsession_hash\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\theaders\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t\tpost_data_promise.then(async ([response, status]: any) => {\n\t\t\t\t\t\tif (status === 503) {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\tmessage: QUEUE_FULL_MSG,\n\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (status !== 200) {\n\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\tmessage: BROKEN_CONNECTION_MSG,\n\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tevent_id = response.event_id as string;\n\t\t\t\t\t\t\tlet callback = async function (_data: object): Promise {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst { type, status, data } = handle_message(\n\t\t\t\t\t\t\t\t\t\t_data,\n\t\t\t\t\t\t\t\t\t\tlast_status[fn_index]\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\tif (type == \"heartbeat\") {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (type === \"update\" && status && !complete) {\n\t\t\t\t\t\t\t\t\t\t// call 'status' listeners\n\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t\t\t...status\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} else if (type === \"complete\") {\n\t\t\t\t\t\t\t\t\t\tcomplete = status;\n\t\t\t\t\t\t\t\t\t} else if (type == \"unexpected_error\") {\n\t\t\t\t\t\t\t\t\t\tconsole.error(\"Unexpected error\", status?.message);\n\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\t\tstatus?.message || \"An Unexpected Error Occurred!\",\n\t\t\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t} else if (type === \"log\") {\n\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"log\",\n\t\t\t\t\t\t\t\t\t\t\tlog: data.log,\n\t\t\t\t\t\t\t\t\t\t\tlevel: data.level,\n\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\t\t\t\t\tvisible: data.visible,\n\t\t\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t} else if (type === \"generating\") {\n\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t\t\t...status,\n\t\t\t\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\tdata &&\n\t\t\t\t\t\t\t\t\t\t\t[\"sse_v2\", \"sse_v2.1\", \"sse_v3\"].includes(protocol)\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tapply_diff_stream(pending_diff_streams, event_id!, data);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (data) {\n\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t\t\tdata: handle_payload(\n\t\t\t\t\t\t\t\t\t\t\t\tdata.data,\n\t\t\t\t\t\t\t\t\t\t\t\tdependency,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig.components,\n\t\t\t\t\t\t\t\t\t\t\t\t\"output\",\n\t\t\t\t\t\t\t\t\t\t\t\toptions.with_null_state\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tif (data.render_config) {\n\t\t\t\t\t\t\t\t\t\t\tawait handle_render_config(data.render_config);\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (complete) {\n\t\t\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\t\t\t\ttime: new Date(),\n\t\t\t\t\t\t\t\t\t\t\t\t...complete,\n\t\t\t\t\t\t\t\t\t\t\t\tstage: status?.stage!,\n\t\t\t\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\t\t\tfn_index\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tstatus?.stage === \"complete\" ||\n\t\t\t\t\t\t\t\t\t\tstatus?.stage === \"error\"\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tif (event_callbacks[event_id!]) {\n\t\t\t\t\t\t\t\t\t\t\tdelete event_callbacks[event_id!];\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (event_id! in pending_diff_streams) {\n\t\t\t\t\t\t\t\t\t\t\tdelete pending_diff_streams[event_id!];\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\t\tconsole.error(\"Unexpected client exception\", e);\n\t\t\t\t\t\t\t\t\tfire_event({\n\t\t\t\t\t\t\t\t\t\ttype: \"status\",\n\t\t\t\t\t\t\t\t\t\tstage: \"error\",\n\t\t\t\t\t\t\t\t\t\tmessage: \"An Unexpected Error Occurred!\",\n\t\t\t\t\t\t\t\t\t\tqueue: true,\n\t\t\t\t\t\t\t\t\t\tendpoint: _endpoint,\n\t\t\t\t\t\t\t\t\t\tfn_index,\n\t\t\t\t\t\t\t\t\t\ttime: new Date()\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif ([\"sse_v2\", \"sse_v2.1\", \"sse_v3\"].includes(protocol)) {\n\t\t\t\t\t\t\t\t\t\tclose_stream(stream_status, that.abort_controller);\n\t\t\t\t\t\t\t\t\t\tstream_status.open = false;\n\t\t\t\t\t\t\t\t\t\tclose();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tif (event_id in pending_stream_messages) {\n\t\t\t\t\t\t\t\tpending_stream_messages[event_id].forEach((msg) =>\n\t\t\t\t\t\t\t\t\tcallback(msg)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdelete pending_stream_messages[event_id];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tevent_callbacks[event_id] = callback;\n\t\t\t\t\t\t\tunclosed_events.add(event_id);\n\t\t\t\t\t\t\tif (!stream_status.open) {\n\t\t\t\t\t\t\t\tawait this.open_stream();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tlet done = false;\n\t\tconst values: (IteratorResult | PromiseLike)[] = [];\n\t\tconst resolvers: ((\n\t\t\tvalue: IteratorResult | PromiseLike\n\t\t) => void)[] = [];\n\n\t\tfunction close(): void {\n\t\t\tdone = true;\n\t\t\twhile (resolvers.length > 0)\n\t\t\t\t(resolvers.shift() as (typeof resolvers)[0])({\n\t\t\t\t\tvalue: undefined,\n\t\t\t\t\tdone: true\n\t\t\t\t});\n\t\t}\n\n\t\tfunction push(\n\t\t\tdata: { value: GradioEvent; done: boolean } | PromiseLike\n\t\t): void {\n\t\t\tif (done) return;\n\t\t\tif (resolvers.length > 0) {\n\t\t\t\t(resolvers.shift() as (typeof resolvers)[0])(data);\n\t\t\t} else {\n\t\t\t\tvalues.push(data);\n\t\t\t}\n\t\t}\n\n\t\tfunction push_error(error: unknown): void {\n\t\t\tpush(thenable_reject(error));\n\t\t\tclose();\n\t\t}\n\n\t\tfunction push_event(event: GradioEvent): void {\n\t\t\tpush({ value: event, done: false });\n\t\t}\n\n\t\tfunction next(): Promise> {\n\t\t\tif (values.length > 0)\n\t\t\t\treturn Promise.resolve(values.shift() as (typeof values)[0]);\n\t\t\tif (done) return Promise.resolve({ value: undefined, done: true });\n\t\t\treturn new Promise((resolve) => resolvers.push(resolve));\n\t\t}\n\n\t\tconst iterator = {\n\t\t\t[Symbol.asyncIterator]: () => iterator,\n\t\t\tnext,\n\t\t\tthrow: async (value: unknown) => {\n\t\t\t\tpush_error(value);\n\t\t\t\treturn next();\n\t\t\t},\n\t\t\treturn: async () => {\n\t\t\t\tclose();\n\t\t\t\treturn next();\n\t\t\t},\n\t\t\tcancel\n\t\t};\n\n\t\treturn iterator;\n\t} catch (error) {\n\t\tconsole.error(\"Submit function encountered an error:\", error);\n\t\tthrow error;\n\t}\n}\n\nfunction thenable_reject(error: T): PromiseLike {\n\treturn {\n\t\tthen: (\n\t\t\tresolve: (value: never) => PromiseLike,\n\t\t\treject: (error: T) => PromiseLike\n\t\t) => reject(error)\n\t};\n}\n\nfunction get_endpoint_info(\n\tapi_info: ApiInfo,\n\tendpoint: string | number,\n\tapi_map: Record,\n\tconfig: Config\n): {\n\tfn_index: number;\n\tendpoint_info: EndpointInfo;\n\tdependency: Dependency;\n} {\n\tlet fn_index: number;\n\tlet endpoint_info: EndpointInfo;\n\tlet dependency: Dependency;\n\n\tif (typeof endpoint === \"number\") {\n\t\tfn_index = endpoint;\n\t\tendpoint_info = api_info.unnamed_endpoints[fn_index];\n\t\tdependency = config.dependencies.find((dep) => dep.id == endpoint)!;\n\t} else {\n\t\tconst trimmed_endpoint = endpoint.replace(/^\\//, \"\");\n\n\t\tfn_index = api_map[trimmed_endpoint];\n\t\tendpoint_info = api_info.named_endpoints[endpoint.trim()];\n\t\tdependency = config.dependencies.find(\n\t\t\t(dep) => dep.id == api_map[trimmed_endpoint]\n\t\t)!;\n\t}\n\n\tif (typeof fn_index !== \"number\") {\n\t\tthrow new Error(\n\t\t\t\"There is no endpoint matching that name of fn_index matching that number.\"\n\t\t);\n\t}\n\treturn { fn_index, endpoint_info, dependency };\n}\n","import type {\n\tApiData,\n\tApiInfo,\n\tClientOptions,\n\tConfig,\n\tDuplicateOptions,\n\tEndpointInfo,\n\tJsApiData,\n\tPredictReturn,\n\tSpaceStatus,\n\tStatus,\n\tUploadResponse,\n\tclient_return,\n\tSubmitIterable,\n\tGradioEvent\n} from \"./types\";\nimport { view_api } from \"./utils/view_api\";\nimport { upload_files } from \"./utils/upload_files\";\nimport { upload, FileData } from \"./upload\";\nimport { handle_blob } from \"./utils/handle_blob\";\nimport { post_data } from \"./utils/post_data\";\nimport { predict } from \"./utils/predict\";\nimport { duplicate } from \"./utils/duplicate\";\nimport { submit } from \"./utils/submit\";\nimport { RE_SPACE_NAME, process_endpoint } from \"./helpers/api_info\";\nimport {\n\tmap_names_to_ids,\n\tresolve_cookies,\n\tresolve_config,\n\tget_jwt,\n\tparse_and_set_cookies\n} from \"./helpers/init_helpers\";\nimport { check_and_wake_space, check_space_status } from \"./helpers/spaces\";\nimport { open_stream, readable_stream, close_stream } from \"./utils/stream\";\nimport { API_INFO_ERROR_MSG, CONFIG_ERROR_MSG } from \"./constants\";\n\nexport class Client {\n\tapp_reference: string;\n\toptions: ClientOptions;\n\n\tconfig: Config | undefined;\n\tapi_info: ApiInfo | undefined;\n\tapi_map: Record = {};\n\tsession_hash: string = Math.random().toString(36).substring(2);\n\tjwt: string | false = false;\n\tlast_status: Record = {};\n\n\tprivate cookies: string | null = null;\n\n\t// streaming\n\tstream_status = { open: false };\n\tpending_stream_messages: Record = {};\n\tpending_diff_streams: Record = {};\n\tevent_callbacks: Record Promise> = {};\n\tunclosed_events: Set = new Set();\n\theartbeat_event: EventSource | null = null;\n\tabort_controller: AbortController | null = null;\n\tstream_instance: EventSource | null = null;\n\n\tfetch(input: RequestInfo | URL, init?: RequestInit): Promise {\n\t\tconst headers = new Headers(init?.headers || {});\n\t\tif (this && this.cookies) {\n\t\t\theaders.append(\"Cookie\", this.cookies);\n\t\t}\n\n\t\treturn fetch(input, { ...init, headers });\n\t}\n\n\tstream(url: URL): EventSource {\n\t\tconst headers = new Headers();\n\t\tif (this && this.cookies) {\n\t\t\theaders.append(\"Cookie\", this.cookies);\n\t\t}\n\n\t\tthis.abort_controller = new AbortController();\n\n\t\tthis.stream_instance = readable_stream(url.toString(), {\n\t\t\tcredentials: \"include\",\n\t\t\theaders: headers,\n\t\t\tsignal: this.abort_controller.signal\n\t\t});\n\n\t\treturn this.stream_instance;\n\t}\n\n\tview_api: () => Promise>;\n\tupload_files: (\n\t\troot_url: string,\n\t\tfiles: (Blob | File)[],\n\t\tupload_id?: string\n\t) => Promise;\n\tupload: (\n\t\tfile_data: FileData[],\n\t\troot_url: string,\n\t\tupload_id?: string,\n\t\tmax_file_size?: number\n\t) => Promise<(FileData | null)[] | null>;\n\thandle_blob: (\n\t\tendpoint: string,\n\t\tdata: unknown[],\n\t\tendpoint_info: EndpointInfo\n\t) => Promise;\n\tpost_data: (\n\t\turl: string,\n\t\tbody: unknown,\n\t\tadditional_headers?: any\n\t) => Promise;\n\tsubmit: (\n\t\tendpoint: string | number,\n\t\tdata: unknown[] | Record | undefined,\n\t\tevent_data?: unknown,\n\t\ttrigger_id?: number | null,\n\t\tall_events?: boolean\n\t) => SubmitIterable;\n\tpredict: (\n\t\tendpoint: string | number,\n\t\tdata: unknown[] | Record | undefined,\n\t\tevent_data?: unknown\n\t) => Promise;\n\topen_stream: () => Promise;\n\tprivate resolve_config: (endpoint: string) => Promise;\n\tprivate resolve_cookies: () => Promise;\n\tconstructor(\n\t\tapp_reference: string,\n\t\toptions: ClientOptions = { events: [\"data\"] }\n\t) {\n\t\tthis.app_reference = app_reference;\n\t\tif (!options.events) {\n\t\t\toptions.events = [\"data\"];\n\t\t}\n\n\t\tthis.options = options;\n\n\t\tthis.view_api = view_api.bind(this);\n\t\tthis.upload_files = upload_files.bind(this);\n\t\tthis.handle_blob = handle_blob.bind(this);\n\t\tthis.post_data = post_data.bind(this);\n\t\tthis.submit = submit.bind(this);\n\t\tthis.predict = predict.bind(this);\n\t\tthis.open_stream = open_stream.bind(this);\n\t\tthis.resolve_config = resolve_config.bind(this);\n\t\tthis.resolve_cookies = resolve_cookies.bind(this);\n\t\tthis.upload = upload.bind(this);\n\t\tthis.fetch = this.fetch.bind(this);\n\t\tthis.handle_space_success = this.handle_space_success.bind(this);\n\t\tthis.stream = this.stream.bind(this);\n\t}\n\n\tprivate async init(): Promise {\n\t\tif (\n\t\t\t(typeof window === \"undefined\" || !(\"WebSocket\" in window)) &&\n\t\t\t!global.WebSocket\n\t\t) {\n\t\t\tconst ws = await import(\"ws\");\n\t\t\tglobal.WebSocket = ws.WebSocket as unknown as typeof WebSocket;\n\t\t}\n\n\t\ttry {\n\t\t\tif (this.options.auth) {\n\t\t\t\tawait this.resolve_cookies();\n\t\t\t}\n\n\t\t\tawait this._resolve_config().then(({ config }) =>\n\t\t\t\tthis._resolve_hearbeat(config)\n\t\t\t);\n\t\t} catch (e: any) {\n\t\t\tthrow Error(e);\n\t\t}\n\n\t\tthis.api_info = await this.view_api();\n\t\tthis.api_map = map_names_to_ids(this.config?.dependencies || []);\n\t}\n\n\tasync _resolve_hearbeat(_config: Config): Promise {\n\t\tif (_config) {\n\t\t\tthis.config = _config;\n\t\t\tif (this.config && this.config.connect_heartbeat) {\n\t\t\t\tif (this.config.space_id && this.options.hf_token) {\n\t\t\t\t\tthis.jwt = await get_jwt(\n\t\t\t\t\t\tthis.config.space_id,\n\t\t\t\t\t\tthis.options.hf_token,\n\t\t\t\t\t\tthis.cookies\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (_config.space_id && this.options.hf_token) {\n\t\t\tthis.jwt = await get_jwt(_config.space_id, this.options.hf_token);\n\t\t}\n\n\t\tif (this.config && this.config.connect_heartbeat) {\n\t\t\t// connect to the heartbeat endpoint via GET request\n\t\t\tconst heartbeat_url = new URL(\n\t\t\t\t`${this.config.root}/heartbeat/${this.session_hash}`\n\t\t\t);\n\n\t\t\t// if the jwt is available, add it to the query params\n\t\t\tif (this.jwt) {\n\t\t\t\theartbeat_url.searchParams.set(\"__sign\", this.jwt);\n\t\t\t}\n\n\t\t\t// Just connect to the endpoint without parsing the response. Ref: https://github.com/gradio-app/gradio/pull/7974#discussion_r1557717540\n\t\t\tif (!this.heartbeat_event) {\n\t\t\t\tthis.heartbeat_event = this.stream(heartbeat_url);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic async connect(\n\t\tapp_reference: string,\n\t\toptions: ClientOptions = {\n\t\t\tevents: [\"data\"]\n\t\t}\n\t): Promise {\n\t\tconst client = new this(app_reference, options); // this refers to the class itself, not the instance\n\t\tawait client.init();\n\t\treturn client;\n\t}\n\n\tclose(): void {\n\t\tclose_stream(this.stream_status, this.abort_controller);\n\t}\n\n\tstatic async duplicate(\n\t\tapp_reference: string,\n\t\toptions: DuplicateOptions = {\n\t\t\tevents: [\"data\"]\n\t\t}\n\t): Promise {\n\t\treturn duplicate(app_reference, options);\n\t}\n\n\tprivate async _resolve_config(): Promise {\n\t\tconst { http_protocol, host, space_id } = await process_endpoint(\n\t\t\tthis.app_reference,\n\t\t\tthis.options.hf_token\n\t\t);\n\n\t\tconst { status_callback } = this.options;\n\n\t\tif (space_id && status_callback) {\n\t\t\tawait check_and_wake_space(space_id, status_callback);\n\t\t}\n\n\t\tlet config: Config | undefined;\n\n\t\ttry {\n\t\t\tconfig = await this.resolve_config(`${http_protocol}//${host}`);\n\n\t\t\tif (!config) {\n\t\t\t\tthrow new Error(CONFIG_ERROR_MSG);\n\t\t\t}\n\n\t\t\treturn this.config_success(config);\n\t\t} catch (e: any) {\n\t\t\tif (space_id && status_callback) {\n\t\t\t\tcheck_space_status(\n\t\t\t\t\tspace_id,\n\t\t\t\t\tRE_SPACE_NAME.test(space_id) ? \"space_name\" : \"subdomain\",\n\t\t\t\t\tthis.handle_space_success\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tif (status_callback)\n\t\t\t\t\tstatus_callback({\n\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\tmessage: \"Could not load this space.\",\n\t\t\t\t\t\tload_status: \"error\",\n\t\t\t\t\t\tdetail: \"NOT_FOUND\"\n\t\t\t\t\t});\n\t\t\t\tthrow Error(e);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async config_success(\n\t\t_config: Config\n\t): Promise {\n\t\tthis.config = _config;\n\n\t\tif (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n\t\t\tif (window.location.protocol === \"https:\") {\n\t\t\t\tthis.config.root = this.config.root.replace(\"http://\", \"https://\");\n\t\t\t}\n\t\t}\n\n\t\tif (this.config.auth_required) {\n\t\t\treturn this.prepare_return_obj();\n\t\t}\n\n\t\ttry {\n\t\t\tthis.api_info = await this.view_api();\n\t\t} catch (e) {\n\t\t\tconsole.error(API_INFO_ERROR_MSG + (e as Error).message);\n\t\t}\n\n\t\treturn this.prepare_return_obj();\n\t}\n\n\tasync handle_space_success(status: SpaceStatus): Promise {\n\t\tif (!this) {\n\t\t\tthrow new Error(CONFIG_ERROR_MSG);\n\t\t}\n\t\tconst { status_callback } = this.options;\n\t\tif (status_callback) status_callback(status);\n\t\tif (status.status === \"running\") {\n\t\t\ttry {\n\t\t\t\tthis.config = await this._resolve_config();\n\t\t\t\tif (!this.config) {\n\t\t\t\t\tthrow new Error(CONFIG_ERROR_MSG);\n\t\t\t\t}\n\n\t\t\t\tconst _config = await this.config_success(this.config);\n\n\t\t\t\treturn _config as Config;\n\t\t\t} catch (e) {\n\t\t\t\tif (status_callback) {\n\t\t\t\t\tstatus_callback({\n\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\tmessage: \"Could not load this space.\",\n\t\t\t\t\t\tload_status: \"error\",\n\t\t\t\t\t\tdetail: \"NOT_FOUND\"\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async component_server(\n\t\tcomponent_id: number,\n\t\tfn_name: string,\n\t\tdata: unknown[] | { binary: boolean; data: Record }\n\t): Promise {\n\t\tif (!this.config) {\n\t\t\tthrow new Error(CONFIG_ERROR_MSG);\n\t\t}\n\n\t\tconst headers: {\n\t\t\tAuthorization?: string;\n\t\t\t\"Content-Type\"?: \"application/json\";\n\t\t} = {};\n\n\t\tconst { hf_token } = this.options;\n\t\tconst { session_hash } = this;\n\n\t\tif (hf_token) {\n\t\t\theaders.Authorization = `Bearer ${this.options.hf_token}`;\n\t\t}\n\n\t\tlet root_url: string;\n\t\tlet component = this.config.components.find(\n\t\t\t(comp) => comp.id === component_id\n\t\t);\n\t\tif (component?.props?.root_url) {\n\t\t\troot_url = component.props.root_url;\n\t\t} else {\n\t\t\troot_url = this.config.root;\n\t\t}\n\n\t\tlet body: FormData | string;\n\n\t\tif (\"binary\" in data) {\n\t\t\tbody = new FormData();\n\t\t\tfor (const key in data.data) {\n\t\t\t\tif (key === \"binary\") continue;\n\t\t\t\tbody.append(key, data.data[key]);\n\t\t\t}\n\t\t\tbody.set(\"component_id\", component_id.toString());\n\t\t\tbody.set(\"fn_name\", fn_name);\n\t\t\tbody.set(\"session_hash\", session_hash);\n\t\t} else {\n\t\t\tbody = JSON.stringify({\n\t\t\t\tdata: data,\n\t\t\t\tcomponent_id,\n\t\t\t\tfn_name,\n\t\t\t\tsession_hash\n\t\t\t});\n\n\t\t\theaders[\"Content-Type\"] = \"application/json\";\n\t\t}\n\n\t\tif (hf_token) {\n\t\t\theaders.Authorization = `Bearer ${hf_token}`;\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.fetch(`${root_url}/component_server/`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: body,\n\t\t\t\theaders,\n\t\t\t\tcredentials: \"include\"\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Could not connect to component server: \" + response.statusText\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst output = await response.json();\n\t\t\treturn output;\n\t\t} catch (e) {\n\t\t\tconsole.warn(e);\n\t\t}\n\t}\n\n\tpublic set_cookies(raw_cookies: string): void {\n\t\tthis.cookies = parse_and_set_cookies(raw_cookies).join(\"; \");\n\t}\n\n\tprivate prepare_return_obj(): client_return {\n\t\treturn {\n\t\t\tconfig: this.config,\n\t\t\tpredict: this.predict,\n\t\t\tsubmit: this.submit,\n\t\t\tview_api: this.view_api,\n\t\t\tcomponent_server: this.component_server\n\t\t};\n\t}\n}\n\n/**\n * @deprecated This method will be removed in v1.0. Use `Client.connect()` instead.\n * Creates a client instance for interacting with Gradio apps.\n *\n * @param {string} app_reference - The reference or URL to a Gradio space or app.\n * @param {ClientOptions} options - Configuration options for the client.\n * @returns {Promise} A promise that resolves to a `Client` instance.\n */\nexport async function client(\n\tapp_reference: string,\n\toptions: ClientOptions = {\n\t\tevents: [\"data\"]\n\t}\n): Promise {\n\treturn await Client.connect(app_reference, options);\n}\n\n/**\n * @deprecated This method will be removed in v1.0. Use `Client.duplicate()` instead.\n * Creates a duplicate of a space and returns a client instance for the duplicated space.\n *\n * @param {string} app_reference - The reference or URL to a Gradio space or app to duplicate.\n * @param {DuplicateOptions} options - Configuration options for the client.\n * @returns {Promise} A promise that resolves to a `Client` instance.\n */\nexport async function duplicate_space(\n\tapp_reference: string,\n\toptions: DuplicateOptions\n): Promise {\n\treturn await Client.duplicate(app_reference, options);\n}\n\nexport type ClientInstance = Client;\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\n\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\n/**\n * @param {any} value\n * @returns {value is PromiseLike}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","import {\n\trun_all,\n\tsubscribe,\n\tnoop,\n\tsafe_not_equal,\n\tis_function,\n\tget_store_value\n} from '../internal/index.js';\n\nconst subscriber_queue = [];\n\n/**\n * Creates a `Readable` store that allows reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#readable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier} [start]\n * @returns {import('./public.js').Readable}\n */\nexport function readable(value, start) {\n\treturn {\n\t\tsubscribe: writable(value, start).subscribe\n\t};\n}\n\n/**\n * Create a `Writable` store that allows both updating and reading by subscription.\n *\n * https://svelte.dev/docs/svelte-store#writable\n * @template T\n * @param {T} [value] initial value\n * @param {import('./public.js').StartStopNotifier} [start]\n * @returns {import('./public.js').Writable}\n */\nexport function writable(value, start = noop) {\n\t/** @type {import('./public.js').Unsubscriber} */\n\tlet stop;\n\t/** @type {Set>} */\n\tconst subscribers = new Set();\n\t/** @param {T} new_value\n\t * @returns {void}\n\t */\n\tfunction set(new_value) {\n\t\tif (safe_not_equal(value, new_value)) {\n\t\t\tvalue = new_value;\n\t\t\tif (stop) {\n\t\t\t\t// store is ready\n\t\t\t\tconst run_queue = !subscriber_queue.length;\n\t\t\t\tfor (const subscriber of subscribers) {\n\t\t\t\t\tsubscriber[1]();\n\t\t\t\t\tsubscriber_queue.push(subscriber, value);\n\t\t\t\t}\n\t\t\t\tif (run_queue) {\n\t\t\t\t\tfor (let i = 0; i < subscriber_queue.length; i += 2) {\n\t\t\t\t\t\tsubscriber_queue[i][0](subscriber_queue[i + 1]);\n\t\t\t\t\t}\n\t\t\t\t\tsubscriber_queue.length = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {import('./public.js').Updater} fn\n\t * @returns {void}\n\t */\n\tfunction update(fn) {\n\t\tset(fn(value));\n\t}\n\n\t/**\n\t * @param {import('./public.js').Subscriber} run\n\t * @param {import('./private.js').Invalidator} [invalidate]\n\t * @returns {import('./public.js').Unsubscriber}\n\t */\n\tfunction subscribe(run, invalidate = noop) {\n\t\t/** @type {import('./private.js').SubscribeInvalidateTuple} */\n\t\tconst subscriber = [run, invalidate];\n\t\tsubscribers.add(subscriber);\n\t\tif (subscribers.size === 1) {\n\t\t\tstop = start(set, update) || noop;\n\t\t}\n\t\trun(value);\n\t\treturn () => {\n\t\t\tsubscribers.delete(subscriber);\n\t\t\tif (subscribers.size === 0 && stop) {\n\t\t\t\tstop();\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t};\n\t}\n\treturn { set, update, subscribe };\n}\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues, set: (value: T) => void, update: (fn: import('./public.js').Updater) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable}\n */\n\n/**\n * Derived value store by synchronizing one or more readable stores and\n * applying an aggregation function over its input values.\n *\n * https://svelte.dev/docs/svelte-store#derived\n * @template {import('./private.js').Stores} S\n * @template T\n * @overload\n * @param {S} stores - input stores\n * @param {(values: import('./private.js').StoresValues) => T} fn - function callback that aggregates the values\n * @param {T} [initial_value] - initial value\n * @returns {import('./public.js').Readable}\n */\n\n/**\n * @template {import('./private.js').Stores} S\n * @template T\n * @param {S} stores\n * @param {Function} fn\n * @param {T} [initial_value]\n * @returns {import('./public.js').Readable}\n */\nexport function derived(stores, fn, initial_value) {\n\tconst single = !Array.isArray(stores);\n\t/** @type {Array>} */\n\tconst stores_array = single ? [stores] : stores;\n\tif (!stores_array.every(Boolean)) {\n\t\tthrow new Error('derived() expects stores as input, got a falsy value');\n\t}\n\tconst auto = fn.length < 2;\n\treturn readable(initial_value, (set, update) => {\n\t\tlet started = false;\n\t\tconst values = [];\n\t\tlet pending = 0;\n\t\tlet cleanup = noop;\n\t\tconst sync = () => {\n\t\t\tif (pending) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcleanup();\n\t\t\tconst result = fn(single ? values[0] : values, set, update);\n\t\t\tif (auto) {\n\t\t\t\tset(result);\n\t\t\t} else {\n\t\t\t\tcleanup = is_function(result) ? result : noop;\n\t\t\t}\n\t\t};\n\t\tconst unsubscribers = stores_array.map((store, i) =>\n\t\t\tsubscribe(\n\t\t\t\tstore,\n\t\t\t\t(value) => {\n\t\t\t\t\tvalues[i] = value;\n\t\t\t\t\tpending &= ~(1 << i);\n\t\t\t\t\tif (started) {\n\t\t\t\t\t\tsync();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tpending |= 1 << i;\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tstarted = true;\n\t\tsync();\n\t\treturn function stop() {\n\t\t\trun_all(unsubscribers);\n\t\t\tcleanup();\n\t\t\t// We need to set this to false because callbacks can still happen despite having unsubscribed:\n\t\t\t// Callbacks might already be placed in the queue which doesn't know it should no longer\n\t\t\t// invoke this derived store.\n\t\t\tstarted = false;\n\t\t};\n\t});\n}\n\n/**\n * Takes a store and returns a new one derived from the old one that is readable.\n *\n * https://svelte.dev/docs/svelte-store#readonly\n * @template T\n * @param {import('./public.js').Readable} store - store to make readonly\n * @returns {import('./public.js').Readable}\n */\nexport function readonly(store) {\n\treturn {\n\t\tsubscribe: store.subscribe.bind(store)\n\t};\n}\n\nexport { get_store_value as get };\n","'use strict';\n\nvar isMergeableObject = function isMergeableObject(value) {\n\treturn isNonNullObject(value)\n\t\t&& !isSpecial(value)\n};\n\nfunction isNonNullObject(value) {\n\treturn !!value && typeof value === 'object'\n}\n\nfunction isSpecial(value) {\n\tvar stringValue = Object.prototype.toString.call(value);\n\n\treturn stringValue === '[object RegExp]'\n\t\t|| stringValue === '[object Date]'\n\t\t|| isReactElement(value)\n}\n\n// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25\nvar canUseSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;\n\nfunction isReactElement(value) {\n\treturn value.$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction emptyTarget(val) {\n\treturn Array.isArray(val) ? [] : {}\n}\n\nfunction cloneUnlessOtherwiseSpecified(value, options) {\n\treturn (options.clone !== false && options.isMergeableObject(value))\n\t\t? deepmerge(emptyTarget(value), value, options)\n\t\t: value\n}\n\nfunction defaultArrayMerge(target, source, options) {\n\treturn target.concat(source).map(function(element) {\n\t\treturn cloneUnlessOtherwiseSpecified(element, options)\n\t})\n}\n\nfunction getMergeFunction(key, options) {\n\tif (!options.customMerge) {\n\t\treturn deepmerge\n\t}\n\tvar customMerge = options.customMerge(key);\n\treturn typeof customMerge === 'function' ? customMerge : deepmerge\n}\n\nfunction getEnumerableOwnPropertySymbols(target) {\n\treturn Object.getOwnPropertySymbols\n\t\t? Object.getOwnPropertySymbols(target).filter(function(symbol) {\n\t\t\treturn Object.propertyIsEnumerable.call(target, symbol)\n\t\t})\n\t\t: []\n}\n\nfunction getKeys(target) {\n\treturn Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))\n}\n\nfunction propertyIsOnObject(object, property) {\n\ttry {\n\t\treturn property in object\n\t} catch(_) {\n\t\treturn false\n\t}\n}\n\n// Protects from prototype poisoning and unexpected merging up the prototype chain.\nfunction propertyIsUnsafe(target, key) {\n\treturn propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,\n\t\t&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,\n\t\t\t&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.\n}\n\nfunction mergeObject(target, source, options) {\n\tvar destination = {};\n\tif (options.isMergeableObject(target)) {\n\t\tgetKeys(target).forEach(function(key) {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n\t\t});\n\t}\n\tgetKeys(source).forEach(function(key) {\n\t\tif (propertyIsUnsafe(target, key)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {\n\t\t\tdestination[key] = getMergeFunction(key, options)(target[key], source[key], options);\n\t\t} else {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(source[key], options);\n\t\t}\n\t});\n\treturn destination\n}\n\nfunction deepmerge(target, source, options) {\n\toptions = options || {};\n\toptions.arrayMerge = options.arrayMerge || defaultArrayMerge;\n\toptions.isMergeableObject = options.isMergeableObject || isMergeableObject;\n\t// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n\t// implementations can use it. The caller may not replace it.\n\toptions.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;\n\n\tvar sourceIsArray = Array.isArray(source);\n\tvar targetIsArray = Array.isArray(target);\n\tvar sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n\tif (!sourceAndTargetTypesMatch) {\n\t\treturn cloneUnlessOtherwiseSpecified(source, options)\n\t} else if (sourceIsArray) {\n\t\treturn options.arrayMerge(target, source, options)\n\t} else {\n\t\treturn mergeObject(target, source, options)\n\t}\n}\n\ndeepmerge.all = function deepmergeAll(array, options) {\n\tif (!Array.isArray(array)) {\n\t\tthrow new Error('first argument should be an array')\n\t}\n\n\treturn array.reduce(function(prev, next) {\n\t\treturn deepmerge(prev, next, options)\n\t}, {})\n};\n\nvar deepmerge_1 = deepmerge;\n\nmodule.exports = deepmerge_1;\n","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n","export var ErrorKind;\n(function (ErrorKind) {\n /** Argument is unclosed (e.g. `{0`) */\n ErrorKind[ErrorKind[\"EXPECT_ARGUMENT_CLOSING_BRACE\"] = 1] = \"EXPECT_ARGUMENT_CLOSING_BRACE\";\n /** Argument is empty (e.g. `{}`). */\n ErrorKind[ErrorKind[\"EMPTY_ARGUMENT\"] = 2] = \"EMPTY_ARGUMENT\";\n /** Argument is malformed (e.g. `{foo!}``) */\n ErrorKind[ErrorKind[\"MALFORMED_ARGUMENT\"] = 3] = \"MALFORMED_ARGUMENT\";\n /** Expect an argument type (e.g. `{foo,}`) */\n ErrorKind[ErrorKind[\"EXPECT_ARGUMENT_TYPE\"] = 4] = \"EXPECT_ARGUMENT_TYPE\";\n /** Unsupported argument type (e.g. `{foo,foo}`) */\n ErrorKind[ErrorKind[\"INVALID_ARGUMENT_TYPE\"] = 5] = \"INVALID_ARGUMENT_TYPE\";\n /** Expect an argument style (e.g. `{foo, number, }`) */\n ErrorKind[ErrorKind[\"EXPECT_ARGUMENT_STYLE\"] = 6] = \"EXPECT_ARGUMENT_STYLE\";\n /** The number skeleton is invalid. */\n ErrorKind[ErrorKind[\"INVALID_NUMBER_SKELETON\"] = 7] = \"INVALID_NUMBER_SKELETON\";\n /** The date time skeleton is invalid. */\n ErrorKind[ErrorKind[\"INVALID_DATE_TIME_SKELETON\"] = 8] = \"INVALID_DATE_TIME_SKELETON\";\n /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */\n ErrorKind[ErrorKind[\"EXPECT_NUMBER_SKELETON\"] = 9] = \"EXPECT_NUMBER_SKELETON\";\n /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */\n ErrorKind[ErrorKind[\"EXPECT_DATE_TIME_SKELETON\"] = 10] = \"EXPECT_DATE_TIME_SKELETON\";\n /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */\n ErrorKind[ErrorKind[\"UNCLOSED_QUOTE_IN_ARGUMENT_STYLE\"] = 11] = \"UNCLOSED_QUOTE_IN_ARGUMENT_STYLE\";\n /** Missing select argument options (e.g. `{foo, select}`) */\n ErrorKind[ErrorKind[\"EXPECT_SELECT_ARGUMENT_OPTIONS\"] = 12] = \"EXPECT_SELECT_ARGUMENT_OPTIONS\";\n /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */\n ErrorKind[ErrorKind[\"EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE\"] = 13] = \"EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE\";\n /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */\n ErrorKind[ErrorKind[\"INVALID_PLURAL_ARGUMENT_OFFSET_VALUE\"] = 14] = \"INVALID_PLURAL_ARGUMENT_OFFSET_VALUE\";\n /** Expecting a selector in `select` argument (e.g `{foo, select}`) */\n ErrorKind[ErrorKind[\"EXPECT_SELECT_ARGUMENT_SELECTOR\"] = 15] = \"EXPECT_SELECT_ARGUMENT_SELECTOR\";\n /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */\n ErrorKind[ErrorKind[\"EXPECT_PLURAL_ARGUMENT_SELECTOR\"] = 16] = \"EXPECT_PLURAL_ARGUMENT_SELECTOR\";\n /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */\n ErrorKind[ErrorKind[\"EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT\"] = 17] = \"EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT\";\n /**\n * Expecting a message fragment after the `plural` or `selectordinal` selector\n * (e.g. `{foo, plural, one}`)\n */\n ErrorKind[ErrorKind[\"EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT\"] = 18] = \"EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT\";\n /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */\n ErrorKind[ErrorKind[\"INVALID_PLURAL_ARGUMENT_SELECTOR\"] = 19] = \"INVALID_PLURAL_ARGUMENT_SELECTOR\";\n /**\n * Duplicate selectors in `plural` or `selectordinal` argument.\n * (e.g. {foo, plural, one {#} one {#}})\n */\n ErrorKind[ErrorKind[\"DUPLICATE_PLURAL_ARGUMENT_SELECTOR\"] = 20] = \"DUPLICATE_PLURAL_ARGUMENT_SELECTOR\";\n /** Duplicate selectors in `select` argument.\n * (e.g. {foo, select, apple {apple} apple {apple}})\n */\n ErrorKind[ErrorKind[\"DUPLICATE_SELECT_ARGUMENT_SELECTOR\"] = 21] = \"DUPLICATE_SELECT_ARGUMENT_SELECTOR\";\n /** Plural or select argument option must have `other` clause. */\n ErrorKind[ErrorKind[\"MISSING_OTHER_CLAUSE\"] = 22] = \"MISSING_OTHER_CLAUSE\";\n /** The tag is malformed. (e.g. `foo) */\n ErrorKind[ErrorKind[\"INVALID_TAG\"] = 23] = \"INVALID_TAG\";\n /** The tag name is invalid. (e.g. `<123>foo`) */\n ErrorKind[ErrorKind[\"INVALID_TAG_NAME\"] = 25] = \"INVALID_TAG_NAME\";\n /** The closing tag does not match the opening tag. (e.g. `foo`) */\n ErrorKind[ErrorKind[\"UNMATCHED_CLOSING_TAG\"] = 26] = \"UNMATCHED_CLOSING_TAG\";\n /** The opening tag has unmatched closing tag. (e.g. `foo`) */\n ErrorKind[ErrorKind[\"UNCLOSED_TAG\"] = 27] = \"UNCLOSED_TAG\";\n})(ErrorKind || (ErrorKind = {}));\n","export var TYPE;\n(function (TYPE) {\n /**\n * Raw text\n */\n TYPE[TYPE[\"literal\"] = 0] = \"literal\";\n /**\n * Variable w/o any format, e.g `var` in `this is a {var}`\n */\n TYPE[TYPE[\"argument\"] = 1] = \"argument\";\n /**\n * Variable w/ number format\n */\n TYPE[TYPE[\"number\"] = 2] = \"number\";\n /**\n * Variable w/ date format\n */\n TYPE[TYPE[\"date\"] = 3] = \"date\";\n /**\n * Variable w/ time format\n */\n TYPE[TYPE[\"time\"] = 4] = \"time\";\n /**\n * Variable w/ select format\n */\n TYPE[TYPE[\"select\"] = 5] = \"select\";\n /**\n * Variable w/ plural format\n */\n TYPE[TYPE[\"plural\"] = 6] = \"plural\";\n /**\n * Only possible within plural argument.\n * This is the `#` symbol that will be substituted with the count.\n */\n TYPE[TYPE[\"pound\"] = 7] = \"pound\";\n /**\n * XML-like tag\n */\n TYPE[TYPE[\"tag\"] = 8] = \"tag\";\n})(TYPE || (TYPE = {}));\nexport var SKELETON_TYPE;\n(function (SKELETON_TYPE) {\n SKELETON_TYPE[SKELETON_TYPE[\"number\"] = 0] = \"number\";\n SKELETON_TYPE[SKELETON_TYPE[\"dateTime\"] = 1] = \"dateTime\";\n})(SKELETON_TYPE || (SKELETON_TYPE = {}));\n/**\n * Type Guards\n */\nexport function isLiteralElement(el) {\n return el.type === TYPE.literal;\n}\nexport function isArgumentElement(el) {\n return el.type === TYPE.argument;\n}\nexport function isNumberElement(el) {\n return el.type === TYPE.number;\n}\nexport function isDateElement(el) {\n return el.type === TYPE.date;\n}\nexport function isTimeElement(el) {\n return el.type === TYPE.time;\n}\nexport function isSelectElement(el) {\n return el.type === TYPE.select;\n}\nexport function isPluralElement(el) {\n return el.type === TYPE.plural;\n}\nexport function isPoundElement(el) {\n return el.type === TYPE.pound;\n}\nexport function isTagElement(el) {\n return el.type === TYPE.tag;\n}\nexport function isNumberSkeleton(el) {\n return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);\n}\nexport function isDateTimeSkeleton(el) {\n return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);\n}\nexport function createLiteralElement(value) {\n return {\n type: TYPE.literal,\n value: value,\n };\n}\nexport function createNumberElement(value, style) {\n return {\n type: TYPE.number,\n value: value,\n style: style,\n };\n}\n","// @generated from regex-gen.ts\nexport var SPACE_SEPARATOR_REGEX = /[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]/;\nexport var WHITE_SPACE_REGEX = /[\\t-\\r \\x85\\u200E\\u200F\\u2028\\u2029]/;\n","/**\n * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js\n * with some tweaks\n */\nvar DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;\n/**\n * Parse Date time skeleton into Intl.DateTimeFormatOptions\n * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n * @public\n * @param skeleton skeleton string\n */\nexport function parseDateTimeSkeleton(skeleton) {\n var result = {};\n skeleton.replace(DATE_TIME_REGEX, function (match) {\n var len = match.length;\n switch (match[0]) {\n // Era\n case 'G':\n result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';\n break;\n // Year\n case 'y':\n result.year = len === 2 ? '2-digit' : 'numeric';\n break;\n case 'Y':\n case 'u':\n case 'U':\n case 'r':\n throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');\n // Quarter\n case 'q':\n case 'Q':\n throw new RangeError('`q/Q` (quarter) patterns are not supported');\n // Month\n case 'M':\n case 'L':\n result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];\n break;\n // Week\n case 'w':\n case 'W':\n throw new RangeError('`w/W` (week) patterns are not supported');\n case 'd':\n result.day = ['numeric', '2-digit'][len - 1];\n break;\n case 'D':\n case 'F':\n case 'g':\n throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');\n // Weekday\n case 'E':\n result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';\n break;\n case 'e':\n if (len < 4) {\n throw new RangeError('`e..eee` (weekday) patterns are not supported');\n }\n result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];\n break;\n case 'c':\n if (len < 4) {\n throw new RangeError('`c..ccc` (weekday) patterns are not supported');\n }\n result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];\n break;\n // Period\n case 'a': // AM, PM\n result.hour12 = true;\n break;\n case 'b': // am, pm, noon, midnight\n case 'B': // flexible day periods\n throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');\n // Hour\n case 'h':\n result.hourCycle = 'h12';\n result.hour = ['numeric', '2-digit'][len - 1];\n break;\n case 'H':\n result.hourCycle = 'h23';\n result.hour = ['numeric', '2-digit'][len - 1];\n break;\n case 'K':\n result.hourCycle = 'h11';\n result.hour = ['numeric', '2-digit'][len - 1];\n break;\n case 'k':\n result.hourCycle = 'h24';\n result.hour = ['numeric', '2-digit'][len - 1];\n break;\n case 'j':\n case 'J':\n case 'C':\n throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');\n // Minute\n case 'm':\n result.minute = ['numeric', '2-digit'][len - 1];\n break;\n // Second\n case 's':\n result.second = ['numeric', '2-digit'][len - 1];\n break;\n case 'S':\n case 'A':\n throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');\n // Zone\n case 'z': // 1..3, 4: specific non-location format\n result.timeZoneName = len < 4 ? 'short' : 'long';\n break;\n case 'Z': // 1..3, 4, 5: The ISO8601 varios formats\n case 'O': // 1, 4: milliseconds in day short, long\n case 'v': // 1, 4: generic non-location format\n case 'V': // 1, 2, 3, 4: time zone ID or city\n case 'X': // 1, 2, 3, 4: The ISO8601 varios formats\n case 'x': // 1, 2, 3, 4: The ISO8601 varios formats\n throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');\n }\n return '';\n });\n return result;\n}\n","// @generated from regex-gen.ts\nexport var WHITE_SPACE_REGEX = /[\\t-\\r \\x85\\u200E\\u200F\\u2028\\u2029]/i;\n","import { __assign } from \"tslib\";\nimport { WHITE_SPACE_REGEX } from './regex.generated';\nexport function parseNumberSkeletonFromString(skeleton) {\n if (skeleton.length === 0) {\n throw new Error('Number skeleton cannot be empty');\n }\n // Parse the skeleton\n var stringTokens = skeleton\n .split(WHITE_SPACE_REGEX)\n .filter(function (x) { return x.length > 0; });\n var tokens = [];\n for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {\n var stringToken = stringTokens_1[_i];\n var stemAndOptions = stringToken.split('/');\n if (stemAndOptions.length === 0) {\n throw new Error('Invalid number skeleton');\n }\n var stem = stemAndOptions[0], options = stemAndOptions.slice(1);\n for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {\n var option = options_1[_a];\n if (option.length === 0) {\n throw new Error('Invalid number skeleton');\n }\n }\n tokens.push({ stem: stem, options: options });\n }\n return tokens;\n}\nfunction icuUnitToEcma(unit) {\n return unit.replace(/^(.*?)-/, '');\n}\nvar FRACTION_PRECISION_REGEX = /^\\.(?:(0+)(\\*)?|(#+)|(0+)(#+))$/g;\nvar SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\\+|#+)?[rs]?$/g;\nvar INTEGER_WIDTH_REGEX = /(\\*)(0+)|(#+)(0+)|(0+)/g;\nvar CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;\nfunction parseSignificantPrecision(str) {\n var result = {};\n if (str[str.length - 1] === 'r') {\n result.roundingPriority = 'morePrecision';\n }\n else if (str[str.length - 1] === 's') {\n result.roundingPriority = 'lessPrecision';\n }\n str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {\n // @@@ case\n if (typeof g2 !== 'string') {\n result.minimumSignificantDigits = g1.length;\n result.maximumSignificantDigits = g1.length;\n }\n // @@@+ case\n else if (g2 === '+') {\n result.minimumSignificantDigits = g1.length;\n }\n // .### case\n else if (g1[0] === '#') {\n result.maximumSignificantDigits = g1.length;\n }\n // .@@## or .@@@ case\n else {\n result.minimumSignificantDigits = g1.length;\n result.maximumSignificantDigits =\n g1.length + (typeof g2 === 'string' ? g2.length : 0);\n }\n return '';\n });\n return result;\n}\nfunction parseSign(str) {\n switch (str) {\n case 'sign-auto':\n return {\n signDisplay: 'auto',\n };\n case 'sign-accounting':\n case '()':\n return {\n currencySign: 'accounting',\n };\n case 'sign-always':\n case '+!':\n return {\n signDisplay: 'always',\n };\n case 'sign-accounting-always':\n case '()!':\n return {\n signDisplay: 'always',\n currencySign: 'accounting',\n };\n case 'sign-except-zero':\n case '+?':\n return {\n signDisplay: 'exceptZero',\n };\n case 'sign-accounting-except-zero':\n case '()?':\n return {\n signDisplay: 'exceptZero',\n currencySign: 'accounting',\n };\n case 'sign-never':\n case '+_':\n return {\n signDisplay: 'never',\n };\n }\n}\nfunction parseConciseScientificAndEngineeringStem(stem) {\n // Engineering\n var result;\n if (stem[0] === 'E' && stem[1] === 'E') {\n result = {\n notation: 'engineering',\n };\n stem = stem.slice(2);\n }\n else if (stem[0] === 'E') {\n result = {\n notation: 'scientific',\n };\n stem = stem.slice(1);\n }\n if (result) {\n var signDisplay = stem.slice(0, 2);\n if (signDisplay === '+!') {\n result.signDisplay = 'always';\n stem = stem.slice(2);\n }\n else if (signDisplay === '+?') {\n result.signDisplay = 'exceptZero';\n stem = stem.slice(2);\n }\n if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {\n throw new Error('Malformed concise eng/scientific notation');\n }\n result.minimumIntegerDigits = stem.length;\n }\n return result;\n}\nfunction parseNotationOptions(opt) {\n var result = {};\n var signOpts = parseSign(opt);\n if (signOpts) {\n return signOpts;\n }\n return result;\n}\n/**\n * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options\n */\nexport function parseNumberSkeleton(tokens) {\n var result = {};\n for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {\n var token = tokens_1[_i];\n switch (token.stem) {\n case 'percent':\n case '%':\n result.style = 'percent';\n continue;\n case '%x100':\n result.style = 'percent';\n result.scale = 100;\n continue;\n case 'currency':\n result.style = 'currency';\n result.currency = token.options[0];\n continue;\n case 'group-off':\n case ',_':\n result.useGrouping = false;\n continue;\n case 'precision-integer':\n case '.':\n result.maximumFractionDigits = 0;\n continue;\n case 'measure-unit':\n case 'unit':\n result.style = 'unit';\n result.unit = icuUnitToEcma(token.options[0]);\n continue;\n case 'compact-short':\n case 'K':\n result.notation = 'compact';\n result.compactDisplay = 'short';\n continue;\n case 'compact-long':\n case 'KK':\n result.notation = 'compact';\n result.compactDisplay = 'long';\n continue;\n case 'scientific':\n result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));\n continue;\n case 'engineering':\n result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));\n continue;\n case 'notation-simple':\n result.notation = 'standard';\n continue;\n // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h\n case 'unit-width-narrow':\n result.currencyDisplay = 'narrowSymbol';\n result.unitDisplay = 'narrow';\n continue;\n case 'unit-width-short':\n result.currencyDisplay = 'code';\n result.unitDisplay = 'short';\n continue;\n case 'unit-width-full-name':\n result.currencyDisplay = 'name';\n result.unitDisplay = 'long';\n continue;\n case 'unit-width-iso-code':\n result.currencyDisplay = 'symbol';\n continue;\n case 'scale':\n result.scale = parseFloat(token.options[0]);\n continue;\n case 'rounding-mode-floor':\n result.roundingMode = 'floor';\n continue;\n case 'rounding-mode-ceiling':\n result.roundingMode = 'ceil';\n continue;\n case 'rounding-mode-down':\n result.roundingMode = 'trunc';\n continue;\n case 'rounding-mode-up':\n result.roundingMode = 'expand';\n continue;\n case 'rounding-mode-half-even':\n result.roundingMode = 'halfEven';\n continue;\n case 'rounding-mode-half-down':\n result.roundingMode = 'halfTrunc';\n continue;\n case 'rounding-mode-half-up':\n result.roundingMode = 'halfExpand';\n continue;\n // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width\n case 'integer-width':\n if (token.options.length > 1) {\n throw new RangeError('integer-width stems only accept a single optional option');\n }\n token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {\n if (g1) {\n result.minimumIntegerDigits = g2.length;\n }\n else if (g3 && g4) {\n throw new Error('We currently do not support maximum integer digits');\n }\n else if (g5) {\n throw new Error('We currently do not support exact integer digits');\n }\n return '';\n });\n continue;\n }\n // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width\n if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {\n result.minimumIntegerDigits = token.stem.length;\n continue;\n }\n if (FRACTION_PRECISION_REGEX.test(token.stem)) {\n // Precision\n // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision\n // precision-integer case\n if (token.options.length > 1) {\n throw new RangeError('Fraction-precision stems only accept a single optional option');\n }\n token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {\n // .000* case (before ICU67 it was .000+)\n if (g2 === '*') {\n result.minimumFractionDigits = g1.length;\n }\n // .### case\n else if (g3 && g3[0] === '#') {\n result.maximumFractionDigits = g3.length;\n }\n // .00## case\n else if (g4 && g5) {\n result.minimumFractionDigits = g4.length;\n result.maximumFractionDigits = g4.length + g5.length;\n }\n else {\n result.minimumFractionDigits = g1.length;\n result.maximumFractionDigits = g1.length;\n }\n return '';\n });\n var opt = token.options[0];\n // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#trailing-zero-display\n if (opt === 'w') {\n result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' });\n }\n else if (opt) {\n result = __assign(__assign({}, result), parseSignificantPrecision(opt));\n }\n continue;\n }\n // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision\n if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {\n result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));\n continue;\n }\n var signOpts = parseSign(token.stem);\n if (signOpts) {\n result = __assign(__assign({}, result), signOpts);\n }\n var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);\n if (conciseScientificAndEngineeringOpts) {\n result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);\n }\n }\n return result;\n}\n","// @generated from time-data-gen.ts\n// prettier-ignore \nexport var timeData = {\n \"001\": [\n \"H\",\n \"h\"\n ],\n \"AC\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"AD\": [\n \"H\",\n \"hB\"\n ],\n \"AE\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"AF\": [\n \"H\",\n \"hb\",\n \"hB\",\n \"h\"\n ],\n \"AG\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"AI\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"AL\": [\n \"h\",\n \"H\",\n \"hB\"\n ],\n \"AM\": [\n \"H\",\n \"hB\"\n ],\n \"AO\": [\n \"H\",\n \"hB\"\n ],\n \"AR\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"AS\": [\n \"h\",\n \"H\"\n ],\n \"AT\": [\n \"H\",\n \"hB\"\n ],\n \"AU\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"AW\": [\n \"H\",\n \"hB\"\n ],\n \"AX\": [\n \"H\"\n ],\n \"AZ\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"BA\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"BB\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"BD\": [\n \"h\",\n \"hB\",\n \"H\"\n ],\n \"BE\": [\n \"H\",\n \"hB\"\n ],\n \"BF\": [\n \"H\",\n \"hB\"\n ],\n \"BG\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"BH\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"BI\": [\n \"H\",\n \"h\"\n ],\n \"BJ\": [\n \"H\",\n \"hB\"\n ],\n \"BL\": [\n \"H\",\n \"hB\"\n ],\n \"BM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"BN\": [\n \"hb\",\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"BO\": [\n \"H\",\n \"hB\",\n \"h\",\n \"hb\"\n ],\n \"BQ\": [\n \"H\"\n ],\n \"BR\": [\n \"H\",\n \"hB\"\n ],\n \"BS\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"BT\": [\n \"h\",\n \"H\"\n ],\n \"BW\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"BY\": [\n \"H\",\n \"h\"\n ],\n \"BZ\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"CA\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"CC\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"CD\": [\n \"hB\",\n \"H\"\n ],\n \"CF\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"CG\": [\n \"H\",\n \"hB\"\n ],\n \"CH\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"CI\": [\n \"H\",\n \"hB\"\n ],\n \"CK\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"CL\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"CM\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"CN\": [\n \"H\",\n \"hB\",\n \"hb\",\n \"h\"\n ],\n \"CO\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"CP\": [\n \"H\"\n ],\n \"CR\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"CU\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"CV\": [\n \"H\",\n \"hB\"\n ],\n \"CW\": [\n \"H\",\n \"hB\"\n ],\n \"CX\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"CY\": [\n \"h\",\n \"H\",\n \"hb\",\n \"hB\"\n ],\n \"CZ\": [\n \"H\"\n ],\n \"DE\": [\n \"H\",\n \"hB\"\n ],\n \"DG\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"DJ\": [\n \"h\",\n \"H\"\n ],\n \"DK\": [\n \"H\"\n ],\n \"DM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"DO\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"DZ\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"EA\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"EC\": [\n \"H\",\n \"hB\",\n \"h\",\n \"hb\"\n ],\n \"EE\": [\n \"H\",\n \"hB\"\n ],\n \"EG\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"EH\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"ER\": [\n \"h\",\n \"H\"\n ],\n \"ES\": [\n \"H\",\n \"hB\",\n \"h\",\n \"hb\"\n ],\n \"ET\": [\n \"hB\",\n \"hb\",\n \"h\",\n \"H\"\n ],\n \"FI\": [\n \"H\"\n ],\n \"FJ\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"FK\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"FM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"FO\": [\n \"H\",\n \"h\"\n ],\n \"FR\": [\n \"H\",\n \"hB\"\n ],\n \"GA\": [\n \"H\",\n \"hB\"\n ],\n \"GB\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"GD\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"GE\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"GF\": [\n \"H\",\n \"hB\"\n ],\n \"GG\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"GH\": [\n \"h\",\n \"H\"\n ],\n \"GI\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"GL\": [\n \"H\",\n \"h\"\n ],\n \"GM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"GN\": [\n \"H\",\n \"hB\"\n ],\n \"GP\": [\n \"H\",\n \"hB\"\n ],\n \"GQ\": [\n \"H\",\n \"hB\",\n \"h\",\n \"hb\"\n ],\n \"GR\": [\n \"h\",\n \"H\",\n \"hb\",\n \"hB\"\n ],\n \"GT\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"GU\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"GW\": [\n \"H\",\n \"hB\"\n ],\n \"GY\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"HK\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"HN\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"HR\": [\n \"H\",\n \"hB\"\n ],\n \"HU\": [\n \"H\",\n \"h\"\n ],\n \"IC\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"ID\": [\n \"H\"\n ],\n \"IE\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"IL\": [\n \"H\",\n \"hB\"\n ],\n \"IM\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"IN\": [\n \"h\",\n \"H\"\n ],\n \"IO\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"IQ\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"IR\": [\n \"hB\",\n \"H\"\n ],\n \"IS\": [\n \"H\"\n ],\n \"IT\": [\n \"H\",\n \"hB\"\n ],\n \"JE\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"JM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"JO\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"JP\": [\n \"H\",\n \"K\",\n \"h\"\n ],\n \"KE\": [\n \"hB\",\n \"hb\",\n \"H\",\n \"h\"\n ],\n \"KG\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"KH\": [\n \"hB\",\n \"h\",\n \"H\",\n \"hb\"\n ],\n \"KI\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"KM\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"KN\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"KP\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"KR\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"KW\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"KY\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"KZ\": [\n \"H\",\n \"hB\"\n ],\n \"LA\": [\n \"H\",\n \"hb\",\n \"hB\",\n \"h\"\n ],\n \"LB\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"LC\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"LI\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"LK\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"LR\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"LS\": [\n \"h\",\n \"H\"\n ],\n \"LT\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"LU\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"LV\": [\n \"H\",\n \"hB\",\n \"hb\",\n \"h\"\n ],\n \"LY\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"MA\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"MC\": [\n \"H\",\n \"hB\"\n ],\n \"MD\": [\n \"H\",\n \"hB\"\n ],\n \"ME\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"MF\": [\n \"H\",\n \"hB\"\n ],\n \"MG\": [\n \"H\",\n \"h\"\n ],\n \"MH\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"MK\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"ML\": [\n \"H\"\n ],\n \"MM\": [\n \"hB\",\n \"hb\",\n \"H\",\n \"h\"\n ],\n \"MN\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"MO\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"MP\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"MQ\": [\n \"H\",\n \"hB\"\n ],\n \"MR\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"MS\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"MT\": [\n \"H\",\n \"h\"\n ],\n \"MU\": [\n \"H\",\n \"h\"\n ],\n \"MV\": [\n \"H\",\n \"h\"\n ],\n \"MW\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"MX\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"MY\": [\n \"hb\",\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"MZ\": [\n \"H\",\n \"hB\"\n ],\n \"NA\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"NC\": [\n \"H\",\n \"hB\"\n ],\n \"NE\": [\n \"H\"\n ],\n \"NF\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"NG\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"NI\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"NL\": [\n \"H\",\n \"hB\"\n ],\n \"NO\": [\n \"H\",\n \"h\"\n ],\n \"NP\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"NR\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"NU\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"NZ\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"OM\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"PA\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"PE\": [\n \"H\",\n \"hB\",\n \"h\",\n \"hb\"\n ],\n \"PF\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"PG\": [\n \"h\",\n \"H\"\n ],\n \"PH\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"PK\": [\n \"h\",\n \"hB\",\n \"H\"\n ],\n \"PL\": [\n \"H\",\n \"h\"\n ],\n \"PM\": [\n \"H\",\n \"hB\"\n ],\n \"PN\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"PR\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"PS\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"PT\": [\n \"H\",\n \"hB\"\n ],\n \"PW\": [\n \"h\",\n \"H\"\n ],\n \"PY\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"QA\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"RE\": [\n \"H\",\n \"hB\"\n ],\n \"RO\": [\n \"H\",\n \"hB\"\n ],\n \"RS\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"RU\": [\n \"H\"\n ],\n \"RW\": [\n \"H\",\n \"h\"\n ],\n \"SA\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"SB\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"SC\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"SD\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"SE\": [\n \"H\"\n ],\n \"SG\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"SH\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"SI\": [\n \"H\",\n \"hB\"\n ],\n \"SJ\": [\n \"H\"\n ],\n \"SK\": [\n \"H\"\n ],\n \"SL\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"SM\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"SN\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"SO\": [\n \"h\",\n \"H\"\n ],\n \"SR\": [\n \"H\",\n \"hB\"\n ],\n \"SS\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"ST\": [\n \"H\",\n \"hB\"\n ],\n \"SV\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"SX\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"SY\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"SZ\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"TA\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"TC\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"TD\": [\n \"h\",\n \"H\",\n \"hB\"\n ],\n \"TF\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"TG\": [\n \"H\",\n \"hB\"\n ],\n \"TH\": [\n \"H\",\n \"h\"\n ],\n \"TJ\": [\n \"H\",\n \"h\"\n ],\n \"TL\": [\n \"H\",\n \"hB\",\n \"hb\",\n \"h\"\n ],\n \"TM\": [\n \"H\",\n \"h\"\n ],\n \"TN\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"TO\": [\n \"h\",\n \"H\"\n ],\n \"TR\": [\n \"H\",\n \"hB\"\n ],\n \"TT\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"TW\": [\n \"hB\",\n \"hb\",\n \"h\",\n \"H\"\n ],\n \"TZ\": [\n \"hB\",\n \"hb\",\n \"H\",\n \"h\"\n ],\n \"UA\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"UG\": [\n \"hB\",\n \"hb\",\n \"H\",\n \"h\"\n ],\n \"UM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"US\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"UY\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"UZ\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"VA\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"VC\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"VE\": [\n \"h\",\n \"H\",\n \"hB\",\n \"hb\"\n ],\n \"VG\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"VI\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"VN\": [\n \"H\",\n \"h\"\n ],\n \"VU\": [\n \"h\",\n \"H\"\n ],\n \"WF\": [\n \"H\",\n \"hB\"\n ],\n \"WS\": [\n \"h\",\n \"H\"\n ],\n \"XK\": [\n \"H\",\n \"hB\",\n \"h\"\n ],\n \"YE\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"YT\": [\n \"H\",\n \"hB\"\n ],\n \"ZA\": [\n \"H\",\n \"h\",\n \"hb\",\n \"hB\"\n ],\n \"ZM\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"ZW\": [\n \"H\",\n \"h\"\n ],\n \"af-ZA\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"ar-001\": [\n \"h\",\n \"hB\",\n \"hb\",\n \"H\"\n ],\n \"ca-ES\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"en-001\": [\n \"h\",\n \"hb\",\n \"H\",\n \"hB\"\n ],\n \"es-BO\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"es-BR\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"es-EC\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"es-ES\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"es-GQ\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"es-PE\": [\n \"H\",\n \"h\",\n \"hB\",\n \"hb\"\n ],\n \"fr-CA\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"gl-ES\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"gu-IN\": [\n \"hB\",\n \"hb\",\n \"h\",\n \"H\"\n ],\n \"hi-IN\": [\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"it-CH\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"it-IT\": [\n \"H\",\n \"h\",\n \"hB\"\n ],\n \"kn-IN\": [\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"ml-IN\": [\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"mr-IN\": [\n \"hB\",\n \"hb\",\n \"h\",\n \"H\"\n ],\n \"pa-IN\": [\n \"hB\",\n \"hb\",\n \"h\",\n \"H\"\n ],\n \"ta-IN\": [\n \"hB\",\n \"h\",\n \"hb\",\n \"H\"\n ],\n \"te-IN\": [\n \"hB\",\n \"h\",\n \"H\"\n ],\n \"zu-ZA\": [\n \"H\",\n \"hB\",\n \"hb\",\n \"h\"\n ]\n};\n","import { timeData } from './time-data.generated';\n/**\n * Returns the best matching date time pattern if a date time skeleton\n * pattern is provided with a locale. Follows the Unicode specification:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns\n * @param skeleton date time skeleton pattern that possibly includes j, J or C\n * @param locale\n */\nexport function getBestPattern(skeleton, locale) {\n var skeletonCopy = '';\n for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {\n var patternChar = skeleton.charAt(patternPos);\n if (patternChar === 'j') {\n var extraLength = 0;\n while (patternPos + 1 < skeleton.length &&\n skeleton.charAt(patternPos + 1) === patternChar) {\n extraLength++;\n patternPos++;\n }\n var hourLen = 1 + (extraLength & 1);\n var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);\n var dayPeriodChar = 'a';\n var hourChar = getDefaultHourSymbolFromLocale(locale);\n if (hourChar == 'H' || hourChar == 'k') {\n dayPeriodLen = 0;\n }\n while (dayPeriodLen-- > 0) {\n skeletonCopy += dayPeriodChar;\n }\n while (hourLen-- > 0) {\n skeletonCopy = hourChar + skeletonCopy;\n }\n }\n else if (patternChar === 'J') {\n skeletonCopy += 'H';\n }\n else {\n skeletonCopy += patternChar;\n }\n }\n return skeletonCopy;\n}\n/**\n * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)\n * of the given `locale` to the corresponding time pattern.\n * @param locale\n */\nfunction getDefaultHourSymbolFromLocale(locale) {\n var hourCycle = locale.hourCycle;\n if (hourCycle === undefined &&\n // @ts-ignore hourCycle(s) is not identified yet\n locale.hourCycles &&\n // @ts-ignore\n locale.hourCycles.length) {\n // @ts-ignore\n hourCycle = locale.hourCycles[0];\n }\n if (hourCycle) {\n switch (hourCycle) {\n case 'h24':\n return 'k';\n case 'h23':\n return 'H';\n case 'h12':\n return 'h';\n case 'h11':\n return 'K';\n default:\n throw new Error('Invalid hourCycle');\n }\n }\n // TODO: Once hourCycle is fully supported remove the following with data generation\n var languageTag = locale.language;\n var regionTag;\n if (languageTag !== 'root') {\n regionTag = locale.maximize().region;\n }\n var hourCycles = timeData[regionTag || ''] ||\n timeData[languageTag || ''] ||\n timeData[\"\".concat(languageTag, \"-001\")] ||\n timeData['001'];\n return hourCycles[0];\n}\n","var _a;\nimport { __assign } from \"tslib\";\nimport { ErrorKind } from './error';\nimport { SKELETON_TYPE, TYPE, } from './types';\nimport { SPACE_SEPARATOR_REGEX } from './regex.generated';\nimport { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';\nimport { getBestPattern } from './date-time-pattern-generator';\nvar SPACE_SEPARATOR_START_REGEX = new RegExp(\"^\".concat(SPACE_SEPARATOR_REGEX.source, \"*\"));\nvar SPACE_SEPARATOR_END_REGEX = new RegExp(\"\".concat(SPACE_SEPARATOR_REGEX.source, \"*$\"));\nfunction createLocation(start, end) {\n return { start: start, end: end };\n}\n// #region Ponyfills\n// Consolidate these variables up top for easier toggling during debugging\nvar hasNativeStartsWith = !!String.prototype.startsWith && '_a'.startsWith('a', 1);\nvar hasNativeFromCodePoint = !!String.fromCodePoint;\nvar hasNativeFromEntries = !!Object.fromEntries;\nvar hasNativeCodePointAt = !!String.prototype.codePointAt;\nvar hasTrimStart = !!String.prototype.trimStart;\nvar hasTrimEnd = !!String.prototype.trimEnd;\nvar hasNativeIsSafeInteger = !!Number.isSafeInteger;\nvar isSafeInteger = hasNativeIsSafeInteger\n ? Number.isSafeInteger\n : function (n) {\n return (typeof n === 'number' &&\n isFinite(n) &&\n Math.floor(n) === n &&\n Math.abs(n) <= 0x1fffffffffffff);\n };\n// IE11 does not support y and u.\nvar REGEX_SUPPORTS_U_AND_Y = true;\ntry {\n var re = RE('([^\\\\p{White_Space}\\\\p{Pattern_Syntax}]*)', 'yu');\n /**\n * legacy Edge or Xbox One browser\n * Unicode flag support: supported\n * Pattern_Syntax support: not supported\n * See https://github.com/formatjs/formatjs/issues/2822\n */\n REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';\n}\ncatch (_) {\n REGEX_SUPPORTS_U_AND_Y = false;\n}\nvar startsWith = hasNativeStartsWith\n ? // Native\n function startsWith(s, search, position) {\n return s.startsWith(search, position);\n }\n : // For IE11\n function startsWith(s, search, position) {\n return s.slice(position, position + search.length) === search;\n };\nvar fromCodePoint = hasNativeFromCodePoint\n ? String.fromCodePoint\n : // IE11\n function fromCodePoint() {\n var codePoints = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n codePoints[_i] = arguments[_i];\n }\n var elements = '';\n var length = codePoints.length;\n var i = 0;\n var code;\n while (length > i) {\n code = codePoints[i++];\n if (code > 0x10ffff)\n throw RangeError(code + ' is not a valid code point');\n elements +=\n code < 0x10000\n ? String.fromCharCode(code)\n : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);\n }\n return elements;\n };\nvar fromEntries = \n// native\nhasNativeFromEntries\n ? Object.fromEntries\n : // Ponyfill\n function fromEntries(entries) {\n var obj = {};\n for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {\n var _a = entries_1[_i], k = _a[0], v = _a[1];\n obj[k] = v;\n }\n return obj;\n };\nvar codePointAt = hasNativeCodePointAt\n ? // Native\n function codePointAt(s, index) {\n return s.codePointAt(index);\n }\n : // IE 11\n function codePointAt(s, index) {\n var size = s.length;\n if (index < 0 || index >= size) {\n return undefined;\n }\n var first = s.charCodeAt(index);\n var second;\n return first < 0xd800 ||\n first > 0xdbff ||\n index + 1 === size ||\n (second = s.charCodeAt(index + 1)) < 0xdc00 ||\n second > 0xdfff\n ? first\n : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;\n };\nvar trimStart = hasTrimStart\n ? // Native\n function trimStart(s) {\n return s.trimStart();\n }\n : // Ponyfill\n function trimStart(s) {\n return s.replace(SPACE_SEPARATOR_START_REGEX, '');\n };\nvar trimEnd = hasTrimEnd\n ? // Native\n function trimEnd(s) {\n return s.trimEnd();\n }\n : // Ponyfill\n function trimEnd(s) {\n return s.replace(SPACE_SEPARATOR_END_REGEX, '');\n };\n// Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.\nfunction RE(s, flag) {\n return new RegExp(s, flag);\n}\n// #endregion\nvar matchIdentifierAtIndex;\nif (REGEX_SUPPORTS_U_AND_Y) {\n // Native\n var IDENTIFIER_PREFIX_RE_1 = RE('([^\\\\p{White_Space}\\\\p{Pattern_Syntax}]*)', 'yu');\n matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {\n var _a;\n IDENTIFIER_PREFIX_RE_1.lastIndex = index;\n var match = IDENTIFIER_PREFIX_RE_1.exec(s);\n return (_a = match[1]) !== null && _a !== void 0 ? _a : '';\n };\n}\nelse {\n // IE11\n matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {\n var match = [];\n while (true) {\n var c = codePointAt(s, index);\n if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {\n break;\n }\n match.push(c);\n index += c >= 0x10000 ? 2 : 1;\n }\n return fromCodePoint.apply(void 0, match);\n };\n}\nvar Parser = /** @class */ (function () {\n function Parser(message, options) {\n if (options === void 0) { options = {}; }\n this.message = message;\n this.position = { offset: 0, line: 1, column: 1 };\n this.ignoreTag = !!options.ignoreTag;\n this.locale = options.locale;\n this.requiresOtherClause = !!options.requiresOtherClause;\n this.shouldParseSkeletons = !!options.shouldParseSkeletons;\n }\n Parser.prototype.parse = function () {\n if (this.offset() !== 0) {\n throw Error('parser can only be used once');\n }\n return this.parseMessage(0, '', false);\n };\n Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {\n var elements = [];\n while (!this.isEOF()) {\n var char = this.char();\n if (char === 123 /* `{` */) {\n var result = this.parseArgument(nestingLevel, expectingCloseTag);\n if (result.err) {\n return result;\n }\n elements.push(result.val);\n }\n else if (char === 125 /* `}` */ && nestingLevel > 0) {\n break;\n }\n else if (char === 35 /* `#` */ &&\n (parentArgType === 'plural' || parentArgType === 'selectordinal')) {\n var position = this.clonePosition();\n this.bump();\n elements.push({\n type: TYPE.pound,\n location: createLocation(position, this.clonePosition()),\n });\n }\n else if (char === 60 /* `<` */ &&\n !this.ignoreTag &&\n this.peek() === 47 // char code for '/'\n ) {\n if (expectingCloseTag) {\n break;\n }\n else {\n return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));\n }\n }\n else if (char === 60 /* `<` */ &&\n !this.ignoreTag &&\n _isAlpha(this.peek() || 0)) {\n var result = this.parseTag(nestingLevel, parentArgType);\n if (result.err) {\n return result;\n }\n elements.push(result.val);\n }\n else {\n var result = this.parseLiteral(nestingLevel, parentArgType);\n if (result.err) {\n return result;\n }\n elements.push(result.val);\n }\n }\n return { val: elements, err: null };\n };\n /**\n * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the\n * [custom element name][] except that a dash is NOT always mandatory and uppercase letters\n * are accepted:\n *\n * ```\n * tag ::= \"<\" tagName (whitespace)* \"/>\" | \"<\" tagName (whitespace)* \">\" message \"\"\n * tagName ::= [a-z] (PENChar)*\n * PENChar ::=\n * \"-\" | \".\" | [0-9] | \"_\" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |\n * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |\n * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]\n * ```\n *\n * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name\n * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do\n * since other tag-based engines like React allow it\n */\n Parser.prototype.parseTag = function (nestingLevel, parentArgType) {\n var startPosition = this.clonePosition();\n this.bump(); // `<`\n var tagName = this.parseTagName();\n this.bumpSpace();\n if (this.bumpIf('/>')) {\n // Self closing tag\n return {\n val: {\n type: TYPE.literal,\n value: \"<\".concat(tagName, \"/>\"),\n location: createLocation(startPosition, this.clonePosition()),\n },\n err: null,\n };\n }\n else if (this.bumpIf('>')) {\n var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);\n if (childrenResult.err) {\n return childrenResult;\n }\n var children = childrenResult.val;\n // Expecting a close tag\n var endTagStartPosition = this.clonePosition();\n if (this.bumpIf('')) {\n return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));\n }\n return {\n val: {\n type: TYPE.tag,\n value: tagName,\n children: children,\n location: createLocation(startPosition, this.clonePosition()),\n },\n err: null,\n };\n }\n else {\n return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));\n }\n }\n else {\n return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));\n }\n };\n /**\n * This method assumes that the caller has peeked ahead for the first tag character.\n */\n Parser.prototype.parseTagName = function () {\n var startOffset = this.offset();\n this.bump(); // the first tag name character\n while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {\n this.bump();\n }\n return this.message.slice(startOffset, this.offset());\n };\n Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {\n var start = this.clonePosition();\n var value = '';\n while (true) {\n var parseQuoteResult = this.tryParseQuote(parentArgType);\n if (parseQuoteResult) {\n value += parseQuoteResult;\n continue;\n }\n var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);\n if (parseUnquotedResult) {\n value += parseUnquotedResult;\n continue;\n }\n var parseLeftAngleResult = this.tryParseLeftAngleBracket();\n if (parseLeftAngleResult) {\n value += parseLeftAngleResult;\n continue;\n }\n break;\n }\n var location = createLocation(start, this.clonePosition());\n return {\n val: { type: TYPE.literal, value: value, location: location },\n err: null,\n };\n };\n Parser.prototype.tryParseLeftAngleBracket = function () {\n if (!this.isEOF() &&\n this.char() === 60 /* `<` */ &&\n (this.ignoreTag ||\n // If at the opening tag or closing tag position, bail.\n !_isAlphaOrSlash(this.peek() || 0))) {\n this.bump(); // `<`\n return '<';\n }\n return null;\n };\n /**\n * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes\n * a character that requires quoting (that is, \"only where needed\"), and works the same in\n * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.\n */\n Parser.prototype.tryParseQuote = function (parentArgType) {\n if (this.isEOF() || this.char() !== 39 /* `'` */) {\n return null;\n }\n // Parse escaped char following the apostrophe, or early return if there is no escaped char.\n // Check if is valid escaped character\n switch (this.peek()) {\n case 39 /* `'` */:\n // double quote, should return as a single quote.\n this.bump();\n this.bump();\n return \"'\";\n // '{', '<', '>', '}'\n case 123:\n case 60:\n case 62:\n case 125:\n break;\n case 35: // '#'\n if (parentArgType === 'plural' || parentArgType === 'selectordinal') {\n break;\n }\n return null;\n default:\n return null;\n }\n this.bump(); // apostrophe\n var codePoints = [this.char()]; // escaped char\n this.bump();\n // read chars until the optional closing apostrophe is found\n while (!this.isEOF()) {\n var ch = this.char();\n if (ch === 39 /* `'` */) {\n if (this.peek() === 39 /* `'` */) {\n codePoints.push(39);\n // Bump one more time because we need to skip 2 characters.\n this.bump();\n }\n else {\n // Optional closing apostrophe.\n this.bump();\n break;\n }\n }\n else {\n codePoints.push(ch);\n }\n this.bump();\n }\n return fromCodePoint.apply(void 0, codePoints);\n };\n Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {\n if (this.isEOF()) {\n return null;\n }\n var ch = this.char();\n if (ch === 60 /* `<` */ ||\n ch === 123 /* `{` */ ||\n (ch === 35 /* `#` */ &&\n (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||\n (ch === 125 /* `}` */ && nestingLevel > 0)) {\n return null;\n }\n else {\n this.bump();\n return fromCodePoint(ch);\n }\n };\n Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {\n var openingBracePosition = this.clonePosition();\n this.bump(); // `{`\n this.bumpSpace();\n if (this.isEOF()) {\n return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));\n }\n if (this.char() === 125 /* `}` */) {\n this.bump();\n return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));\n }\n // argument name\n var value = this.parseIdentifierIfPossible().value;\n if (!value) {\n return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));\n }\n this.bumpSpace();\n if (this.isEOF()) {\n return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));\n }\n switch (this.char()) {\n // Simple argument: `{name}`\n case 125 /* `}` */: {\n this.bump(); // `}`\n return {\n val: {\n type: TYPE.argument,\n // value does not include the opening and closing braces.\n value: value,\n location: createLocation(openingBracePosition, this.clonePosition()),\n },\n err: null,\n };\n }\n // Argument with options: `{name, format, ...}`\n case 44 /* `,` */: {\n this.bump(); // `,`\n this.bumpSpace();\n if (this.isEOF()) {\n return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));\n }\n return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);\n }\n default:\n return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));\n }\n };\n /**\n * Advance the parser until the end of the identifier, if it is currently on\n * an identifier character. Return an empty string otherwise.\n */\n Parser.prototype.parseIdentifierIfPossible = function () {\n var startingPosition = this.clonePosition();\n var startOffset = this.offset();\n var value = matchIdentifierAtIndex(this.message, startOffset);\n var endOffset = startOffset + value.length;\n this.bumpTo(endOffset);\n var endPosition = this.clonePosition();\n var location = createLocation(startingPosition, endPosition);\n return { value: value, location: location };\n };\n Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {\n var _a;\n // Parse this range:\n // {name, type, style}\n // ^---^\n var typeStartPosition = this.clonePosition();\n var argType = this.parseIdentifierIfPossible().value;\n var typeEndPosition = this.clonePosition();\n switch (argType) {\n case '':\n // Expecting a style string number, date, time, plural, selectordinal, or select.\n return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));\n case 'number':\n case 'date':\n case 'time': {\n // Parse this range:\n // {name, number, style}\n // ^-------^\n this.bumpSpace();\n var styleAndLocation = null;\n if (this.bumpIf(',')) {\n this.bumpSpace();\n var styleStartPosition = this.clonePosition();\n var result = this.parseSimpleArgStyleIfPossible();\n if (result.err) {\n return result;\n }\n var style = trimEnd(result.val);\n if (style.length === 0) {\n return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));\n }\n var styleLocation = createLocation(styleStartPosition, this.clonePosition());\n styleAndLocation = { style: style, styleLocation: styleLocation };\n }\n var argCloseResult = this.tryParseArgumentClose(openingBracePosition);\n if (argCloseResult.err) {\n return argCloseResult;\n }\n var location_1 = createLocation(openingBracePosition, this.clonePosition());\n // Extract style or skeleton\n if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {\n // Skeleton starts with `::`.\n var skeleton = trimStart(styleAndLocation.style.slice(2));\n if (argType === 'number') {\n var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);\n if (result.err) {\n return result;\n }\n return {\n val: { type: TYPE.number, value: value, location: location_1, style: result.val },\n err: null,\n };\n }\n else {\n if (skeleton.length === 0) {\n return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);\n }\n var dateTimePattern = skeleton;\n // Get \"best match\" pattern only if locale is passed, if not, let it\n // pass as-is where `parseDateTimeSkeleton()` will throw an error\n // for unsupported patterns.\n if (this.locale) {\n dateTimePattern = getBestPattern(skeleton, this.locale);\n }\n var style = {\n type: SKELETON_TYPE.dateTime,\n pattern: dateTimePattern,\n location: styleAndLocation.styleLocation,\n parsedOptions: this.shouldParseSkeletons\n ? parseDateTimeSkeleton(dateTimePattern)\n : {},\n };\n var type = argType === 'date' ? TYPE.date : TYPE.time;\n return {\n val: { type: type, value: value, location: location_1, style: style },\n err: null,\n };\n }\n }\n // Regular style or no style.\n return {\n val: {\n type: argType === 'number'\n ? TYPE.number\n : argType === 'date'\n ? TYPE.date\n : TYPE.time,\n value: value,\n location: location_1,\n style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,\n },\n err: null,\n };\n }\n case 'plural':\n case 'selectordinal':\n case 'select': {\n // Parse this range:\n // {name, plural, options}\n // ^---------^\n var typeEndPosition_1 = this.clonePosition();\n this.bumpSpace();\n if (!this.bumpIf(',')) {\n return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));\n }\n this.bumpSpace();\n // Parse offset:\n // {name, plural, offset:1, options}\n // ^-----^\n //\n // or the first option:\n //\n // {name, plural, one {...} other {...}}\n // ^--^\n var identifierAndLocation = this.parseIdentifierIfPossible();\n var pluralOffset = 0;\n if (argType !== 'select' && identifierAndLocation.value === 'offset') {\n if (!this.bumpIf(':')) {\n return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));\n }\n this.bumpSpace();\n var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);\n if (result.err) {\n return result;\n }\n // Parse another identifier for option parsing\n this.bumpSpace();\n identifierAndLocation = this.parseIdentifierIfPossible();\n pluralOffset = result.val;\n }\n var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);\n if (optionsResult.err) {\n return optionsResult;\n }\n var argCloseResult = this.tryParseArgumentClose(openingBracePosition);\n if (argCloseResult.err) {\n return argCloseResult;\n }\n var location_2 = createLocation(openingBracePosition, this.clonePosition());\n if (argType === 'select') {\n return {\n val: {\n type: TYPE.select,\n value: value,\n options: fromEntries(optionsResult.val),\n location: location_2,\n },\n err: null,\n };\n }\n else {\n return {\n val: {\n type: TYPE.plural,\n value: value,\n options: fromEntries(optionsResult.val),\n offset: pluralOffset,\n pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',\n location: location_2,\n },\n err: null,\n };\n }\n }\n default:\n return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));\n }\n };\n Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {\n // Parse: {value, number, ::currency/GBP }\n //\n if (this.isEOF() || this.char() !== 125 /* `}` */) {\n return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));\n }\n this.bump(); // `}`\n return { val: true, err: null };\n };\n /**\n * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659\n */\n Parser.prototype.parseSimpleArgStyleIfPossible = function () {\n var nestedBraces = 0;\n var startPosition = this.clonePosition();\n while (!this.isEOF()) {\n var ch = this.char();\n switch (ch) {\n case 39 /* `'` */: {\n // Treat apostrophe as quoting but include it in the style part.\n // Find the end of the quoted literal text.\n this.bump();\n var apostrophePosition = this.clonePosition();\n if (!this.bumpUntil(\"'\")) {\n return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));\n }\n this.bump();\n break;\n }\n case 123 /* `{` */: {\n nestedBraces += 1;\n this.bump();\n break;\n }\n case 125 /* `}` */: {\n if (nestedBraces > 0) {\n nestedBraces -= 1;\n }\n else {\n return {\n val: this.message.slice(startPosition.offset, this.offset()),\n err: null,\n };\n }\n break;\n }\n default:\n this.bump();\n break;\n }\n }\n return {\n val: this.message.slice(startPosition.offset, this.offset()),\n err: null,\n };\n };\n Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {\n var tokens = [];\n try {\n tokens = parseNumberSkeletonFromString(skeleton);\n }\n catch (e) {\n return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);\n }\n return {\n val: {\n type: SKELETON_TYPE.number,\n tokens: tokens,\n location: location,\n parsedOptions: this.shouldParseSkeletons\n ? parseNumberSkeleton(tokens)\n : {},\n },\n err: null,\n };\n };\n /**\n * @param nesting_level The current nesting level of messages.\n * This can be positive when parsing message fragment in select or plural argument options.\n * @param parent_arg_type The parent argument's type.\n * @param parsed_first_identifier If provided, this is the first identifier-like selector of\n * the argument. It is a by-product of a previous parsing attempt.\n * @param expecting_close_tag If true, this message is directly or indirectly nested inside\n * between a pair of opening and closing tags. The nested message will not parse beyond\n * the closing tag boundary.\n */\n Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {\n var _a;\n var hasOtherClause = false;\n var options = [];\n var parsedSelectors = new Set();\n var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;\n // Parse:\n // one {one apple}\n // ^--^\n while (true) {\n if (selector.length === 0) {\n var startPosition = this.clonePosition();\n if (parentArgType !== 'select' && this.bumpIf('=')) {\n // Try parse `={number}` selector\n var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);\n if (result.err) {\n return result;\n }\n selectorLocation = createLocation(startPosition, this.clonePosition());\n selector = this.message.slice(startPosition.offset, this.offset());\n }\n else {\n break;\n }\n }\n // Duplicate selector clauses\n if (parsedSelectors.has(selector)) {\n return this.error(parentArgType === 'select'\n ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR\n : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);\n }\n if (selector === 'other') {\n hasOtherClause = true;\n }\n // Parse:\n // one {one apple}\n // ^----------^\n this.bumpSpace();\n var openingBracePosition = this.clonePosition();\n if (!this.bumpIf('{')) {\n return this.error(parentArgType === 'select'\n ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT\n : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));\n }\n var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);\n if (fragmentResult.err) {\n return fragmentResult;\n }\n var argCloseResult = this.tryParseArgumentClose(openingBracePosition);\n if (argCloseResult.err) {\n return argCloseResult;\n }\n options.push([\n selector,\n {\n value: fragmentResult.val,\n location: createLocation(openingBracePosition, this.clonePosition()),\n },\n ]);\n // Keep track of the existing selectors\n parsedSelectors.add(selector);\n // Prep next selector clause.\n this.bumpSpace();\n (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);\n }\n if (options.length === 0) {\n return this.error(parentArgType === 'select'\n ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR\n : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));\n }\n if (this.requiresOtherClause && !hasOtherClause) {\n return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));\n }\n return { val: options, err: null };\n };\n Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {\n var sign = 1;\n var startingPosition = this.clonePosition();\n if (this.bumpIf('+')) {\n }\n else if (this.bumpIf('-')) {\n sign = -1;\n }\n var hasDigits = false;\n var decimal = 0;\n while (!this.isEOF()) {\n var ch = this.char();\n if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {\n hasDigits = true;\n decimal = decimal * 10 + (ch - 48);\n this.bump();\n }\n else {\n break;\n }\n }\n var location = createLocation(startingPosition, this.clonePosition());\n if (!hasDigits) {\n return this.error(expectNumberError, location);\n }\n decimal *= sign;\n if (!isSafeInteger(decimal)) {\n return this.error(invalidNumberError, location);\n }\n return { val: decimal, err: null };\n };\n Parser.prototype.offset = function () {\n return this.position.offset;\n };\n Parser.prototype.isEOF = function () {\n return this.offset() === this.message.length;\n };\n Parser.prototype.clonePosition = function () {\n // This is much faster than `Object.assign` or spread.\n return {\n offset: this.position.offset,\n line: this.position.line,\n column: this.position.column,\n };\n };\n /**\n * Return the code point at the current position of the parser.\n * Throws if the index is out of bound.\n */\n Parser.prototype.char = function () {\n var offset = this.position.offset;\n if (offset >= this.message.length) {\n throw Error('out of bound');\n }\n var code = codePointAt(this.message, offset);\n if (code === undefined) {\n throw Error(\"Offset \".concat(offset, \" is at invalid UTF-16 code unit boundary\"));\n }\n return code;\n };\n Parser.prototype.error = function (kind, location) {\n return {\n val: null,\n err: {\n kind: kind,\n message: this.message,\n location: location,\n },\n };\n };\n /** Bump the parser to the next UTF-16 code unit. */\n Parser.prototype.bump = function () {\n if (this.isEOF()) {\n return;\n }\n var code = this.char();\n if (code === 10 /* '\\n' */) {\n this.position.line += 1;\n this.position.column = 1;\n this.position.offset += 1;\n }\n else {\n this.position.column += 1;\n // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.\n this.position.offset += code < 0x10000 ? 1 : 2;\n }\n };\n /**\n * If the substring starting at the current position of the parser has\n * the given prefix, then bump the parser to the character immediately\n * following the prefix and return true. Otherwise, don't bump the parser\n * and return false.\n */\n Parser.prototype.bumpIf = function (prefix) {\n if (startsWith(this.message, prefix, this.offset())) {\n for (var i = 0; i < prefix.length; i++) {\n this.bump();\n }\n return true;\n }\n return false;\n };\n /**\n * Bump the parser until the pattern character is found and return `true`.\n * Otherwise bump to the end of the file and return `false`.\n */\n Parser.prototype.bumpUntil = function (pattern) {\n var currentOffset = this.offset();\n var index = this.message.indexOf(pattern, currentOffset);\n if (index >= 0) {\n this.bumpTo(index);\n return true;\n }\n else {\n this.bumpTo(this.message.length);\n return false;\n }\n };\n /**\n * Bump the parser to the target offset.\n * If target offset is beyond the end of the input, bump the parser to the end of the input.\n */\n Parser.prototype.bumpTo = function (targetOffset) {\n if (this.offset() > targetOffset) {\n throw Error(\"targetOffset \".concat(targetOffset, \" must be greater than or equal to the current offset \").concat(this.offset()));\n }\n targetOffset = Math.min(targetOffset, this.message.length);\n while (true) {\n var offset = this.offset();\n if (offset === targetOffset) {\n break;\n }\n if (offset > targetOffset) {\n throw Error(\"targetOffset \".concat(targetOffset, \" is at invalid UTF-16 code unit boundary\"));\n }\n this.bump();\n if (this.isEOF()) {\n break;\n }\n }\n };\n /** advance the parser through all whitespace to the next non-whitespace code unit. */\n Parser.prototype.bumpSpace = function () {\n while (!this.isEOF() && _isWhiteSpace(this.char())) {\n this.bump();\n }\n };\n /**\n * Peek at the *next* Unicode codepoint in the input without advancing the parser.\n * If the input has been exhausted, then this returns null.\n */\n Parser.prototype.peek = function () {\n if (this.isEOF()) {\n return null;\n }\n var code = this.char();\n var offset = this.offset();\n var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));\n return nextCode !== null && nextCode !== void 0 ? nextCode : null;\n };\n return Parser;\n}());\nexport { Parser };\n/**\n * This check if codepoint is alphabet (lower & uppercase)\n * @param codepoint\n * @returns\n */\nfunction _isAlpha(codepoint) {\n return ((codepoint >= 97 && codepoint <= 122) ||\n (codepoint >= 65 && codepoint <= 90));\n}\nfunction _isAlphaOrSlash(codepoint) {\n return _isAlpha(codepoint) || codepoint === 47; /* '/' */\n}\n/** See `parseTag` function docs. */\nfunction _isPotentialElementNameChar(c) {\n return (c === 45 /* '-' */ ||\n c === 46 /* '.' */ ||\n (c >= 48 && c <= 57) /* 0..9 */ ||\n c === 95 /* '_' */ ||\n (c >= 97 && c <= 122) /** a..z */ ||\n (c >= 65 && c <= 90) /* A..Z */ ||\n c == 0xb7 ||\n (c >= 0xc0 && c <= 0xd6) ||\n (c >= 0xd8 && c <= 0xf6) ||\n (c >= 0xf8 && c <= 0x37d) ||\n (c >= 0x37f && c <= 0x1fff) ||\n (c >= 0x200c && c <= 0x200d) ||\n (c >= 0x203f && c <= 0x2040) ||\n (c >= 0x2070 && c <= 0x218f) ||\n (c >= 0x2c00 && c <= 0x2fef) ||\n (c >= 0x3001 && c <= 0xd7ff) ||\n (c >= 0xf900 && c <= 0xfdcf) ||\n (c >= 0xfdf0 && c <= 0xfffd) ||\n (c >= 0x10000 && c <= 0xeffff));\n}\n/**\n * Code point equivalent of regex `\\p{White_Space}`.\n * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt\n */\nfunction _isWhiteSpace(c) {\n return ((c >= 0x0009 && c <= 0x000d) ||\n c === 0x0020 ||\n c === 0x0085 ||\n (c >= 0x200e && c <= 0x200f) ||\n c === 0x2028 ||\n c === 0x2029);\n}\n/**\n * Code point equivalent of regex `\\p{Pattern_Syntax}`.\n * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt\n */\nfunction _isPatternSyntax(c) {\n return ((c >= 0x0021 && c <= 0x0023) ||\n c === 0x0024 ||\n (c >= 0x0025 && c <= 0x0027) ||\n c === 0x0028 ||\n c === 0x0029 ||\n c === 0x002a ||\n c === 0x002b ||\n c === 0x002c ||\n c === 0x002d ||\n (c >= 0x002e && c <= 0x002f) ||\n (c >= 0x003a && c <= 0x003b) ||\n (c >= 0x003c && c <= 0x003e) ||\n (c >= 0x003f && c <= 0x0040) ||\n c === 0x005b ||\n c === 0x005c ||\n c === 0x005d ||\n c === 0x005e ||\n c === 0x0060 ||\n c === 0x007b ||\n c === 0x007c ||\n c === 0x007d ||\n c === 0x007e ||\n c === 0x00a1 ||\n (c >= 0x00a2 && c <= 0x00a5) ||\n c === 0x00a6 ||\n c === 0x00a7 ||\n c === 0x00a9 ||\n c === 0x00ab ||\n c === 0x00ac ||\n c === 0x00ae ||\n c === 0x00b0 ||\n c === 0x00b1 ||\n c === 0x00b6 ||\n c === 0x00bb ||\n c === 0x00bf ||\n c === 0x00d7 ||\n c === 0x00f7 ||\n (c >= 0x2010 && c <= 0x2015) ||\n (c >= 0x2016 && c <= 0x2017) ||\n c === 0x2018 ||\n c === 0x2019 ||\n c === 0x201a ||\n (c >= 0x201b && c <= 0x201c) ||\n c === 0x201d ||\n c === 0x201e ||\n c === 0x201f ||\n (c >= 0x2020 && c <= 0x2027) ||\n (c >= 0x2030 && c <= 0x2038) ||\n c === 0x2039 ||\n c === 0x203a ||\n (c >= 0x203b && c <= 0x203e) ||\n (c >= 0x2041 && c <= 0x2043) ||\n c === 0x2044 ||\n c === 0x2045 ||\n c === 0x2046 ||\n (c >= 0x2047 && c <= 0x2051) ||\n c === 0x2052 ||\n c === 0x2053 ||\n (c >= 0x2055 && c <= 0x205e) ||\n (c >= 0x2190 && c <= 0x2194) ||\n (c >= 0x2195 && c <= 0x2199) ||\n (c >= 0x219a && c <= 0x219b) ||\n (c >= 0x219c && c <= 0x219f) ||\n c === 0x21a0 ||\n (c >= 0x21a1 && c <= 0x21a2) ||\n c === 0x21a3 ||\n (c >= 0x21a4 && c <= 0x21a5) ||\n c === 0x21a6 ||\n (c >= 0x21a7 && c <= 0x21ad) ||\n c === 0x21ae ||\n (c >= 0x21af && c <= 0x21cd) ||\n (c >= 0x21ce && c <= 0x21cf) ||\n (c >= 0x21d0 && c <= 0x21d1) ||\n c === 0x21d2 ||\n c === 0x21d3 ||\n c === 0x21d4 ||\n (c >= 0x21d5 && c <= 0x21f3) ||\n (c >= 0x21f4 && c <= 0x22ff) ||\n (c >= 0x2300 && c <= 0x2307) ||\n c === 0x2308 ||\n c === 0x2309 ||\n c === 0x230a ||\n c === 0x230b ||\n (c >= 0x230c && c <= 0x231f) ||\n (c >= 0x2320 && c <= 0x2321) ||\n (c >= 0x2322 && c <= 0x2328) ||\n c === 0x2329 ||\n c === 0x232a ||\n (c >= 0x232b && c <= 0x237b) ||\n c === 0x237c ||\n (c >= 0x237d && c <= 0x239a) ||\n (c >= 0x239b && c <= 0x23b3) ||\n (c >= 0x23b4 && c <= 0x23db) ||\n (c >= 0x23dc && c <= 0x23e1) ||\n (c >= 0x23e2 && c <= 0x2426) ||\n (c >= 0x2427 && c <= 0x243f) ||\n (c >= 0x2440 && c <= 0x244a) ||\n (c >= 0x244b && c <= 0x245f) ||\n (c >= 0x2500 && c <= 0x25b6) ||\n c === 0x25b7 ||\n (c >= 0x25b8 && c <= 0x25c0) ||\n c === 0x25c1 ||\n (c >= 0x25c2 && c <= 0x25f7) ||\n (c >= 0x25f8 && c <= 0x25ff) ||\n (c >= 0x2600 && c <= 0x266e) ||\n c === 0x266f ||\n (c >= 0x2670 && c <= 0x2767) ||\n c === 0x2768 ||\n c === 0x2769 ||\n c === 0x276a ||\n c === 0x276b ||\n c === 0x276c ||\n c === 0x276d ||\n c === 0x276e ||\n c === 0x276f ||\n c === 0x2770 ||\n c === 0x2771 ||\n c === 0x2772 ||\n c === 0x2773 ||\n c === 0x2774 ||\n c === 0x2775 ||\n (c >= 0x2794 && c <= 0x27bf) ||\n (c >= 0x27c0 && c <= 0x27c4) ||\n c === 0x27c5 ||\n c === 0x27c6 ||\n (c >= 0x27c7 && c <= 0x27e5) ||\n c === 0x27e6 ||\n c === 0x27e7 ||\n c === 0x27e8 ||\n c === 0x27e9 ||\n c === 0x27ea ||\n c === 0x27eb ||\n c === 0x27ec ||\n c === 0x27ed ||\n c === 0x27ee ||\n c === 0x27ef ||\n (c >= 0x27f0 && c <= 0x27ff) ||\n (c >= 0x2800 && c <= 0x28ff) ||\n (c >= 0x2900 && c <= 0x2982) ||\n c === 0x2983 ||\n c === 0x2984 ||\n c === 0x2985 ||\n c === 0x2986 ||\n c === 0x2987 ||\n c === 0x2988 ||\n c === 0x2989 ||\n c === 0x298a ||\n c === 0x298b ||\n c === 0x298c ||\n c === 0x298d ||\n c === 0x298e ||\n c === 0x298f ||\n c === 0x2990 ||\n c === 0x2991 ||\n c === 0x2992 ||\n c === 0x2993 ||\n c === 0x2994 ||\n c === 0x2995 ||\n c === 0x2996 ||\n c === 0x2997 ||\n c === 0x2998 ||\n (c >= 0x2999 && c <= 0x29d7) ||\n c === 0x29d8 ||\n c === 0x29d9 ||\n c === 0x29da ||\n c === 0x29db ||\n (c >= 0x29dc && c <= 0x29fb) ||\n c === 0x29fc ||\n c === 0x29fd ||\n (c >= 0x29fe && c <= 0x2aff) ||\n (c >= 0x2b00 && c <= 0x2b2f) ||\n (c >= 0x2b30 && c <= 0x2b44) ||\n (c >= 0x2b45 && c <= 0x2b46) ||\n (c >= 0x2b47 && c <= 0x2b4c) ||\n (c >= 0x2b4d && c <= 0x2b73) ||\n (c >= 0x2b74 && c <= 0x2b75) ||\n (c >= 0x2b76 && c <= 0x2b95) ||\n c === 0x2b96 ||\n (c >= 0x2b97 && c <= 0x2bff) ||\n (c >= 0x2e00 && c <= 0x2e01) ||\n c === 0x2e02 ||\n c === 0x2e03 ||\n c === 0x2e04 ||\n c === 0x2e05 ||\n (c >= 0x2e06 && c <= 0x2e08) ||\n c === 0x2e09 ||\n c === 0x2e0a ||\n c === 0x2e0b ||\n c === 0x2e0c ||\n c === 0x2e0d ||\n (c >= 0x2e0e && c <= 0x2e16) ||\n c === 0x2e17 ||\n (c >= 0x2e18 && c <= 0x2e19) ||\n c === 0x2e1a ||\n c === 0x2e1b ||\n c === 0x2e1c ||\n c === 0x2e1d ||\n (c >= 0x2e1e && c <= 0x2e1f) ||\n c === 0x2e20 ||\n c === 0x2e21 ||\n c === 0x2e22 ||\n c === 0x2e23 ||\n c === 0x2e24 ||\n c === 0x2e25 ||\n c === 0x2e26 ||\n c === 0x2e27 ||\n c === 0x2e28 ||\n c === 0x2e29 ||\n (c >= 0x2e2a && c <= 0x2e2e) ||\n c === 0x2e2f ||\n (c >= 0x2e30 && c <= 0x2e39) ||\n (c >= 0x2e3a && c <= 0x2e3b) ||\n (c >= 0x2e3c && c <= 0x2e3f) ||\n c === 0x2e40 ||\n c === 0x2e41 ||\n c === 0x2e42 ||\n (c >= 0x2e43 && c <= 0x2e4f) ||\n (c >= 0x2e50 && c <= 0x2e51) ||\n c === 0x2e52 ||\n (c >= 0x2e53 && c <= 0x2e7f) ||\n (c >= 0x3001 && c <= 0x3003) ||\n c === 0x3008 ||\n c === 0x3009 ||\n c === 0x300a ||\n c === 0x300b ||\n c === 0x300c ||\n c === 0x300d ||\n c === 0x300e ||\n c === 0x300f ||\n c === 0x3010 ||\n c === 0x3011 ||\n (c >= 0x3012 && c <= 0x3013) ||\n c === 0x3014 ||\n c === 0x3015 ||\n c === 0x3016 ||\n c === 0x3017 ||\n c === 0x3018 ||\n c === 0x3019 ||\n c === 0x301a ||\n c === 0x301b ||\n c === 0x301c ||\n c === 0x301d ||\n (c >= 0x301e && c <= 0x301f) ||\n c === 0x3020 ||\n c === 0x3030 ||\n c === 0xfd3e ||\n c === 0xfd3f ||\n (c >= 0xfe45 && c <= 0xfe46));\n}\n","import { __assign } from \"tslib\";\nimport { ErrorKind } from './error';\nimport { Parser } from './parser';\nimport { isDateElement, isDateTimeSkeleton, isNumberElement, isNumberSkeleton, isPluralElement, isSelectElement, isTagElement, isTimeElement, } from './types';\nfunction pruneLocation(els) {\n els.forEach(function (el) {\n delete el.location;\n if (isSelectElement(el) || isPluralElement(el)) {\n for (var k in el.options) {\n delete el.options[k].location;\n pruneLocation(el.options[k].value);\n }\n }\n else if (isNumberElement(el) && isNumberSkeleton(el.style)) {\n delete el.style.location;\n }\n else if ((isDateElement(el) || isTimeElement(el)) &&\n isDateTimeSkeleton(el.style)) {\n delete el.style.location;\n }\n else if (isTagElement(el)) {\n pruneLocation(el.children);\n }\n });\n}\nexport function parse(message, opts) {\n if (opts === void 0) { opts = {}; }\n opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);\n var result = new Parser(message, opts).parse();\n if (result.err) {\n var error = SyntaxError(ErrorKind[result.err.kind]);\n // @ts-expect-error Assign to error object\n error.location = result.err.location;\n // @ts-expect-error Assign to error object\n error.originalMessage = result.err.message;\n throw error;\n }\n if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {\n pruneLocation(result.val);\n }\n return result.val;\n}\nexport * from './types';\n// only for testing\nexport var _Parser = Parser;\n","//\n// Main\n//\nexport function memoize(fn, options) {\n var cache = options && options.cache ? options.cache : cacheDefault;\n var serializer = options && options.serializer ? options.serializer : serializerDefault;\n var strategy = options && options.strategy ? options.strategy : strategyDefault;\n return strategy(fn, {\n cache: cache,\n serializer: serializer,\n });\n}\n//\n// Strategy\n//\nfunction isPrimitive(value) {\n return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === \"string\" 'unsafe' primitive for our needs\n}\nfunction monadic(fn, cache, serializer, arg) {\n var cacheKey = isPrimitive(arg) ? arg : serializer(arg);\n var computedValue = cache.get(cacheKey);\n if (typeof computedValue === 'undefined') {\n computedValue = fn.call(this, arg);\n cache.set(cacheKey, computedValue);\n }\n return computedValue;\n}\nfunction variadic(fn, cache, serializer) {\n var args = Array.prototype.slice.call(arguments, 3);\n var cacheKey = serializer(args);\n var computedValue = cache.get(cacheKey);\n if (typeof computedValue === 'undefined') {\n computedValue = fn.apply(this, args);\n cache.set(cacheKey, computedValue);\n }\n return computedValue;\n}\nfunction assemble(fn, context, strategy, cache, serialize) {\n return strategy.bind(context, fn, cache, serialize);\n}\nfunction strategyDefault(fn, options) {\n var strategy = fn.length === 1 ? monadic : variadic;\n return assemble(fn, this, strategy, options.cache.create(), options.serializer);\n}\nfunction strategyVariadic(fn, options) {\n return assemble(fn, this, variadic, options.cache.create(), options.serializer);\n}\nfunction strategyMonadic(fn, options) {\n return assemble(fn, this, monadic, options.cache.create(), options.serializer);\n}\n//\n// Serializer\n//\nvar serializerDefault = function () {\n return JSON.stringify(arguments);\n};\n//\n// Cache\n//\nfunction ObjectWithoutPrototypeCache() {\n this.cache = Object.create(null);\n}\nObjectWithoutPrototypeCache.prototype.get = function (key) {\n return this.cache[key];\n};\nObjectWithoutPrototypeCache.prototype.set = function (key, value) {\n this.cache[key] = value;\n};\nvar cacheDefault = {\n create: function create() {\n // @ts-ignore\n return new ObjectWithoutPrototypeCache();\n },\n};\nexport var strategies = {\n variadic: strategyVariadic,\n monadic: strategyMonadic,\n};\n","import { __extends } from \"tslib\";\nexport var ErrorCode;\n(function (ErrorCode) {\n // When we have a placeholder but no value to format\n ErrorCode[\"MISSING_VALUE\"] = \"MISSING_VALUE\";\n // When value supplied is invalid\n ErrorCode[\"INVALID_VALUE\"] = \"INVALID_VALUE\";\n // When we need specific Intl API but it's not available\n ErrorCode[\"MISSING_INTL_API\"] = \"MISSING_INTL_API\";\n})(ErrorCode || (ErrorCode = {}));\nvar FormatError = /** @class */ (function (_super) {\n __extends(FormatError, _super);\n function FormatError(msg, code, originalMessage) {\n var _this = _super.call(this, msg) || this;\n _this.code = code;\n _this.originalMessage = originalMessage;\n return _this;\n }\n FormatError.prototype.toString = function () {\n return \"[formatjs Error: \".concat(this.code, \"] \").concat(this.message);\n };\n return FormatError;\n}(Error));\nexport { FormatError };\nvar InvalidValueError = /** @class */ (function (_super) {\n __extends(InvalidValueError, _super);\n function InvalidValueError(variableId, value, options, originalMessage) {\n return _super.call(this, \"Invalid values for \\\"\".concat(variableId, \"\\\": \\\"\").concat(value, \"\\\". Options are \\\"\").concat(Object.keys(options).join('\", \"'), \"\\\"\"), ErrorCode.INVALID_VALUE, originalMessage) || this;\n }\n return InvalidValueError;\n}(FormatError));\nexport { InvalidValueError };\nvar InvalidValueTypeError = /** @class */ (function (_super) {\n __extends(InvalidValueTypeError, _super);\n function InvalidValueTypeError(value, type, originalMessage) {\n return _super.call(this, \"Value for \\\"\".concat(value, \"\\\" must be of type \").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;\n }\n return InvalidValueTypeError;\n}(FormatError));\nexport { InvalidValueTypeError };\nvar MissingValueError = /** @class */ (function (_super) {\n __extends(MissingValueError, _super);\n function MissingValueError(variableId, originalMessage) {\n return _super.call(this, \"The intl string context variable \\\"\".concat(variableId, \"\\\" was not provided to the string \\\"\").concat(originalMessage, \"\\\"\"), ErrorCode.MISSING_VALUE, originalMessage) || this;\n }\n return MissingValueError;\n}(FormatError));\nexport { MissingValueError };\n","import { isArgumentElement, isDateElement, isDateTimeSkeleton, isLiteralElement, isNumberElement, isNumberSkeleton, isPluralElement, isPoundElement, isSelectElement, isTimeElement, isTagElement, } from '@formatjs/icu-messageformat-parser';\nimport { MissingValueError, InvalidValueError, ErrorCode, FormatError, InvalidValueTypeError, } from './error';\nexport var PART_TYPE;\n(function (PART_TYPE) {\n PART_TYPE[PART_TYPE[\"literal\"] = 0] = \"literal\";\n PART_TYPE[PART_TYPE[\"object\"] = 1] = \"object\";\n})(PART_TYPE || (PART_TYPE = {}));\nfunction mergeLiteral(parts) {\n if (parts.length < 2) {\n return parts;\n }\n return parts.reduce(function (all, part) {\n var lastPart = all[all.length - 1];\n if (!lastPart ||\n lastPart.type !== PART_TYPE.literal ||\n part.type !== PART_TYPE.literal) {\n all.push(part);\n }\n else {\n lastPart.value += part.value;\n }\n return all;\n }, []);\n}\nexport function isFormatXMLElementFn(el) {\n return typeof el === 'function';\n}\n// TODO(skeleton): add skeleton support\nexport function formatToParts(els, locales, formatters, formats, values, currentPluralValue, \n// For debugging\noriginalMessage) {\n // Hot path for straight simple msg translations\n if (els.length === 1 && isLiteralElement(els[0])) {\n return [\n {\n type: PART_TYPE.literal,\n value: els[0].value,\n },\n ];\n }\n var result = [];\n for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {\n var el = els_1[_i];\n // Exit early for string parts.\n if (isLiteralElement(el)) {\n result.push({\n type: PART_TYPE.literal,\n value: el.value,\n });\n continue;\n }\n // TODO: should this part be literal type?\n // Replace `#` in plural rules with the actual numeric value.\n if (isPoundElement(el)) {\n if (typeof currentPluralValue === 'number') {\n result.push({\n type: PART_TYPE.literal,\n value: formatters.getNumberFormat(locales).format(currentPluralValue),\n });\n }\n continue;\n }\n var varName = el.value;\n // Enforce that all required values are provided by the caller.\n if (!(values && varName in values)) {\n throw new MissingValueError(varName, originalMessage);\n }\n var value = values[varName];\n if (isArgumentElement(el)) {\n if (!value || typeof value === 'string' || typeof value === 'number') {\n value =\n typeof value === 'string' || typeof value === 'number'\n ? String(value)\n : '';\n }\n result.push({\n type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,\n value: value,\n });\n continue;\n }\n // Recursively format plural and select parts' option — which can be a\n // nested pattern structure. The choosing of the option to use is\n // abstracted-by and delegated-to the part helper object.\n if (isDateElement(el)) {\n var style = typeof el.style === 'string'\n ? formats.date[el.style]\n : isDateTimeSkeleton(el.style)\n ? el.style.parsedOptions\n : undefined;\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getDateTimeFormat(locales, style)\n .format(value),\n });\n continue;\n }\n if (isTimeElement(el)) {\n var style = typeof el.style === 'string'\n ? formats.time[el.style]\n : isDateTimeSkeleton(el.style)\n ? el.style.parsedOptions\n : formats.time.medium;\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getDateTimeFormat(locales, style)\n .format(value),\n });\n continue;\n }\n if (isNumberElement(el)) {\n var style = typeof el.style === 'string'\n ? formats.number[el.style]\n : isNumberSkeleton(el.style)\n ? el.style.parsedOptions\n : undefined;\n if (style && style.scale) {\n value =\n value *\n (style.scale || 1);\n }\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getNumberFormat(locales, style)\n .format(value),\n });\n continue;\n }\n if (isTagElement(el)) {\n var children = el.children, value_1 = el.value;\n var formatFn = values[value_1];\n if (!isFormatXMLElementFn(formatFn)) {\n throw new InvalidValueTypeError(value_1, 'function', originalMessage);\n }\n var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);\n var chunks = formatFn(parts.map(function (p) { return p.value; }));\n if (!Array.isArray(chunks)) {\n chunks = [chunks];\n }\n result.push.apply(result, chunks.map(function (c) {\n return {\n type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,\n value: c,\n };\n }));\n }\n if (isSelectElement(el)) {\n var opt = el.options[value] || el.options.other;\n if (!opt) {\n throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);\n }\n result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));\n continue;\n }\n if (isPluralElement(el)) {\n var opt = el.options[\"=\".concat(value)];\n if (!opt) {\n if (!Intl.PluralRules) {\n throw new FormatError(\"Intl.PluralRules is not available in this environment.\\nTry polyfilling it using \\\"@formatjs/intl-pluralrules\\\"\\n\", ErrorCode.MISSING_INTL_API, originalMessage);\n }\n var rule = formatters\n .getPluralRules(locales, { type: el.pluralType })\n .select(value - (el.offset || 0));\n opt = el.options[rule] || el.options.other;\n }\n if (!opt) {\n throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);\n }\n result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));\n continue;\n }\n }\n return mergeLiteral(result);\n}\n","/*\nCopyright (c) 2014, Yahoo! Inc. All rights reserved.\nCopyrights licensed under the New BSD License.\nSee the accompanying LICENSE file for terms.\n*/\nimport { __assign, __rest, __spreadArray } from \"tslib\";\nimport { parse, } from '@formatjs/icu-messageformat-parser';\nimport { memoize, strategies } from '@formatjs/fast-memoize';\nimport { formatToParts, PART_TYPE, } from './formatters';\n// -- MessageFormat --------------------------------------------------------\nfunction mergeConfig(c1, c2) {\n if (!c2) {\n return c1;\n }\n return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {\n all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));\n return all;\n }, {}));\n}\nfunction mergeConfigs(defaultConfig, configs) {\n if (!configs) {\n return defaultConfig;\n }\n return Object.keys(defaultConfig).reduce(function (all, k) {\n all[k] = mergeConfig(defaultConfig[k], configs[k]);\n return all;\n }, __assign({}, defaultConfig));\n}\nfunction createFastMemoizeCache(store) {\n return {\n create: function () {\n return {\n get: function (key) {\n return store[key];\n },\n set: function (key, value) {\n store[key] = value;\n },\n };\n },\n };\n}\nfunction createDefaultFormatters(cache) {\n if (cache === void 0) { cache = {\n number: {},\n dateTime: {},\n pluralRules: {},\n }; }\n return {\n getNumberFormat: memoize(function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();\n }, {\n cache: createFastMemoizeCache(cache.number),\n strategy: strategies.variadic,\n }),\n getDateTimeFormat: memoize(function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();\n }, {\n cache: createFastMemoizeCache(cache.dateTime),\n strategy: strategies.variadic,\n }),\n getPluralRules: memoize(function () {\n var _a;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();\n }, {\n cache: createFastMemoizeCache(cache.pluralRules),\n strategy: strategies.variadic,\n }),\n };\n}\nvar IntlMessageFormat = /** @class */ (function () {\n function IntlMessageFormat(message, locales, overrideFormats, opts) {\n var _this = this;\n if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }\n this.formatterCache = {\n number: {},\n dateTime: {},\n pluralRules: {},\n };\n this.format = function (values) {\n var parts = _this.formatToParts(values);\n // Hot path for straight simple msg translations\n if (parts.length === 1) {\n return parts[0].value;\n }\n var result = parts.reduce(function (all, part) {\n if (!all.length ||\n part.type !== PART_TYPE.literal ||\n typeof all[all.length - 1] !== 'string') {\n all.push(part.value);\n }\n else {\n all[all.length - 1] += part.value;\n }\n return all;\n }, []);\n if (result.length <= 1) {\n return result[0] || '';\n }\n return result;\n };\n this.formatToParts = function (values) {\n return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);\n };\n this.resolvedOptions = function () {\n var _a;\n return ({\n locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) ||\n Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],\n });\n };\n this.getAst = function () { return _this.ast; };\n // Defined first because it's used to build the format pattern.\n this.locales = locales;\n this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);\n if (typeof message === 'string') {\n this.message = message;\n if (!IntlMessageFormat.__parse) {\n throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');\n }\n var _a = opts || {}, formatters = _a.formatters, parseOpts = __rest(_a, [\"formatters\"]);\n // Parse string messages into an AST.\n this.ast = IntlMessageFormat.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));\n }\n else {\n this.ast = message;\n }\n if (!Array.isArray(this.ast)) {\n throw new TypeError('A message must be provided as a String or AST.');\n }\n // Creates a new object with the specified `formats` merged with the default\n // formats.\n this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);\n this.formatters =\n (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);\n }\n Object.defineProperty(IntlMessageFormat, \"defaultLocale\", {\n get: function () {\n if (!IntlMessageFormat.memoizedDefaultLocale) {\n IntlMessageFormat.memoizedDefaultLocale =\n new Intl.NumberFormat().resolvedOptions().locale;\n }\n return IntlMessageFormat.memoizedDefaultLocale;\n },\n enumerable: false,\n configurable: true\n });\n IntlMessageFormat.memoizedDefaultLocale = null;\n IntlMessageFormat.resolveLocale = function (locales) {\n if (typeof Intl.Locale === 'undefined') {\n return;\n }\n var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);\n if (supportedLocales.length > 0) {\n return new Intl.Locale(supportedLocales[0]);\n }\n return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);\n };\n IntlMessageFormat.__parse = parse;\n // Default format options used as the prototype of the `formats` provided to the\n // constructor. These are used when constructing the internal Intl.NumberFormat\n // and Intl.DateTimeFormat instances.\n IntlMessageFormat.formats = {\n number: {\n integer: {\n maximumFractionDigits: 0,\n },\n currency: {\n style: 'currency',\n },\n percent: {\n style: 'percent',\n },\n },\n date: {\n short: {\n month: 'numeric',\n day: 'numeric',\n year: '2-digit',\n },\n medium: {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n },\n long: {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n },\n full: {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n },\n },\n time: {\n short: {\n hour: 'numeric',\n minute: 'numeric',\n },\n medium: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n },\n long: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n timeZoneName: 'short',\n },\n full: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n timeZoneName: 'short',\n },\n },\n };\n return IntlMessageFormat;\n}());\nexport { IntlMessageFormat };\n","import { writable, derived } from 'svelte/store';\nimport deepmerge from 'deepmerge';\nimport { IntlMessageFormat } from 'intl-messageformat';\n\nfunction delve(obj, fullKey) {\n if (fullKey == null)\n return void 0;\n if (fullKey in obj) {\n return obj[fullKey];\n }\n const keys = fullKey.split(\".\");\n let result = obj;\n for (let p = 0; p < keys.length; p++) {\n if (typeof result === \"object\") {\n if (p > 0) {\n const partialKey = keys.slice(p, keys.length).join(\".\");\n if (partialKey in result) {\n result = result[partialKey];\n break;\n }\n }\n result = result[keys[p]];\n } else {\n result = void 0;\n }\n }\n return result;\n}\n\nconst lookupCache = {};\nconst addToCache = (path, locale, message) => {\n if (!message)\n return message;\n if (!(locale in lookupCache))\n lookupCache[locale] = {};\n if (!(path in lookupCache[locale]))\n lookupCache[locale][path] = message;\n return message;\n};\nconst lookup = (path, refLocale) => {\n if (refLocale == null)\n return void 0;\n if (refLocale in lookupCache && path in lookupCache[refLocale]) {\n return lookupCache[refLocale][path];\n }\n const locales = getPossibleLocales(refLocale);\n for (let i = 0; i < locales.length; i++) {\n const locale = locales[i];\n const message = getMessageFromDictionary(locale, path);\n if (message) {\n return addToCache(path, refLocale, message);\n }\n }\n return void 0;\n};\n\nlet dictionary;\nconst $dictionary = writable({});\nfunction getLocaleDictionary(locale) {\n return dictionary[locale] || null;\n}\nfunction hasLocaleDictionary(locale) {\n return locale in dictionary;\n}\nfunction getMessageFromDictionary(locale, id) {\n if (!hasLocaleDictionary(locale)) {\n return null;\n }\n const localeDictionary = getLocaleDictionary(locale);\n const match = delve(localeDictionary, id);\n return match;\n}\nfunction getClosestAvailableLocale(refLocale) {\n if (refLocale == null)\n return void 0;\n const relatedLocales = getPossibleLocales(refLocale);\n for (let i = 0; i < relatedLocales.length; i++) {\n const locale = relatedLocales[i];\n if (hasLocaleDictionary(locale)) {\n return locale;\n }\n }\n return void 0;\n}\nfunction addMessages(locale, ...partials) {\n delete lookupCache[locale];\n $dictionary.update((d) => {\n d[locale] = deepmerge.all([d[locale] || {}, ...partials]);\n return d;\n });\n}\nconst $locales = derived(\n [$dictionary],\n ([dictionary2]) => Object.keys(dictionary2)\n);\n$dictionary.subscribe((newDictionary) => dictionary = newDictionary);\n\nconst queue = {};\nfunction createLocaleQueue(locale) {\n queue[locale] = /* @__PURE__ */ new Set();\n}\nfunction removeLoaderFromQueue(locale, loader) {\n queue[locale].delete(loader);\n if (queue[locale].size === 0) {\n delete queue[locale];\n }\n}\nfunction getLocaleQueue(locale) {\n return queue[locale];\n}\nfunction getLocalesQueues(locale) {\n return getPossibleLocales(locale).map((localeItem) => {\n const localeQueue = getLocaleQueue(localeItem);\n return [localeItem, localeQueue ? [...localeQueue] : []];\n }).filter(([, localeQueue]) => localeQueue.length > 0);\n}\nfunction hasLocaleQueue(locale) {\n if (locale == null)\n return false;\n return getPossibleLocales(locale).some(\n (localeQueue) => {\n var _a;\n return (_a = getLocaleQueue(localeQueue)) == null ? void 0 : _a.size;\n }\n );\n}\nfunction loadLocaleQueue(locale, localeQueue) {\n const allLoadersPromise = Promise.all(\n localeQueue.map((loader) => {\n removeLoaderFromQueue(locale, loader);\n return loader().then((partial) => partial.default || partial);\n })\n );\n return allLoadersPromise.then((partials) => addMessages(locale, ...partials));\n}\nconst activeFlushes = {};\nfunction flush(locale) {\n if (!hasLocaleQueue(locale)) {\n if (locale in activeFlushes) {\n return activeFlushes[locale];\n }\n return Promise.resolve();\n }\n const queues = getLocalesQueues(locale);\n activeFlushes[locale] = Promise.all(\n queues.map(\n ([localeName, localeQueue]) => loadLocaleQueue(localeName, localeQueue)\n )\n ).then(() => {\n if (hasLocaleQueue(locale)) {\n return flush(locale);\n }\n delete activeFlushes[locale];\n });\n return activeFlushes[locale];\n}\nfunction registerLocaleLoader(locale, loader) {\n if (!getLocaleQueue(locale))\n createLocaleQueue(locale);\n const localeQueue = getLocaleQueue(locale);\n if (getLocaleQueue(locale).has(loader))\n return;\n if (!hasLocaleDictionary(locale)) {\n $dictionary.update((d) => {\n d[locale] = {};\n return d;\n });\n }\n localeQueue.add(loader);\n}\n\nvar __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;\nvar __hasOwnProp$2 = Object.prototype.hasOwnProperty;\nvar __propIsEnum$2 = Object.prototype.propertyIsEnumerable;\nvar __objRest$1 = (source, exclude) => {\n var target = {};\n for (var prop in source)\n if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)\n target[prop] = source[prop];\n if (source != null && __getOwnPropSymbols$2)\n for (var prop of __getOwnPropSymbols$2(source)) {\n if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))\n target[prop] = source[prop];\n }\n return target;\n};\nconst defaultFormats = {\n number: {\n scientific: { notation: \"scientific\" },\n engineering: { notation: \"engineering\" },\n compactLong: { notation: \"compact\", compactDisplay: \"long\" },\n compactShort: { notation: \"compact\", compactDisplay: \"short\" }\n },\n date: {\n short: { month: \"numeric\", day: \"numeric\", year: \"2-digit\" },\n medium: { month: \"short\", day: \"numeric\", year: \"numeric\" },\n long: { month: \"long\", day: \"numeric\", year: \"numeric\" },\n full: { weekday: \"long\", month: \"long\", day: \"numeric\", year: \"numeric\" }\n },\n time: {\n short: { hour: \"numeric\", minute: \"numeric\" },\n medium: { hour: \"numeric\", minute: \"numeric\", second: \"numeric\" },\n long: {\n hour: \"numeric\",\n minute: \"numeric\",\n second: \"numeric\",\n timeZoneName: \"short\"\n },\n full: {\n hour: \"numeric\",\n minute: \"numeric\",\n second: \"numeric\",\n timeZoneName: \"short\"\n }\n }\n};\nfunction defaultMissingKeyHandler({ locale, id }) {\n console.warn(\n `[svelte-i18n] The message \"${id}\" was not found in \"${getPossibleLocales(\n locale\n ).join('\", \"')}\".${hasLocaleQueue(getCurrentLocale()) ? `\n\nNote: there are at least one loader still registered to this locale that wasn't executed.` : \"\"}`\n );\n}\nconst defaultOptions = {\n fallbackLocale: null,\n loadingDelay: 200,\n formats: defaultFormats,\n warnOnMissingMessages: true,\n handleMissingMessage: void 0,\n ignoreTag: true\n};\nconst options = defaultOptions;\nfunction getOptions() {\n return options;\n}\nfunction init(opts) {\n const _a = opts, { formats } = _a, rest = __objRest$1(_a, [\"formats\"]);\n let initialLocale = opts.fallbackLocale;\n if (opts.initialLocale) {\n try {\n if (IntlMessageFormat.resolveLocale(opts.initialLocale)) {\n initialLocale = opts.initialLocale;\n }\n } catch (e) {\n console.warn(\n `[svelte-i18n] The initial locale \"${opts.initialLocale}\" is not a valid locale.`\n );\n }\n }\n if (rest.warnOnMissingMessages) {\n delete rest.warnOnMissingMessages;\n if (rest.handleMissingMessage == null) {\n rest.handleMissingMessage = defaultMissingKeyHandler;\n } else {\n console.warn(\n '[svelte-i18n] The \"warnOnMissingMessages\" option is deprecated. Please use the \"handleMissingMessage\" option instead.'\n );\n }\n }\n Object.assign(options, rest, { initialLocale });\n if (formats) {\n if (\"number\" in formats) {\n Object.assign(options.formats.number, formats.number);\n }\n if (\"date\" in formats) {\n Object.assign(options.formats.date, formats.date);\n }\n if (\"time\" in formats) {\n Object.assign(options.formats.time, formats.time);\n }\n }\n return $locale.set(initialLocale);\n}\n\nconst $isLoading = writable(false);\n\nvar __defProp$1 = Object.defineProperty;\nvar __defProps = Object.defineProperties;\nvar __getOwnPropDescs = Object.getOwnPropertyDescriptors;\nvar __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;\nvar __hasOwnProp$1 = Object.prototype.hasOwnProperty;\nvar __propIsEnum$1 = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues$1 = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp$1.call(b, prop))\n __defNormalProp$1(a, prop, b[prop]);\n if (__getOwnPropSymbols$1)\n for (var prop of __getOwnPropSymbols$1(b)) {\n if (__propIsEnum$1.call(b, prop))\n __defNormalProp$1(a, prop, b[prop]);\n }\n return a;\n};\nvar __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));\nlet current;\nconst internalLocale = writable(null);\nfunction getSubLocales(refLocale) {\n return refLocale.split(\"-\").map((_, i, arr) => arr.slice(0, i + 1).join(\"-\")).reverse();\n}\nfunction getPossibleLocales(refLocale, fallbackLocale = getOptions().fallbackLocale) {\n const locales = getSubLocales(refLocale);\n if (fallbackLocale) {\n return [.../* @__PURE__ */ new Set([...locales, ...getSubLocales(fallbackLocale)])];\n }\n return locales;\n}\nfunction getCurrentLocale() {\n return current != null ? current : void 0;\n}\ninternalLocale.subscribe((newLocale) => {\n current = newLocale != null ? newLocale : void 0;\n if (typeof window !== \"undefined\" && newLocale != null) {\n document.documentElement.setAttribute(\"lang\", newLocale);\n }\n});\nconst set = (newLocale) => {\n if (newLocale && getClosestAvailableLocale(newLocale) && hasLocaleQueue(newLocale)) {\n const { loadingDelay } = getOptions();\n let loadingTimer;\n if (typeof window !== \"undefined\" && getCurrentLocale() != null && loadingDelay) {\n loadingTimer = window.setTimeout(\n () => $isLoading.set(true),\n loadingDelay\n );\n } else {\n $isLoading.set(true);\n }\n return flush(newLocale).then(() => {\n internalLocale.set(newLocale);\n }).finally(() => {\n clearTimeout(loadingTimer);\n $isLoading.set(false);\n });\n }\n return internalLocale.set(newLocale);\n};\nconst $locale = __spreadProps(__spreadValues$1({}, internalLocale), {\n set\n});\n\nconst getFromQueryString = (queryString, key) => {\n const keyVal = queryString.split(\"&\").find((i) => i.indexOf(`${key}=`) === 0);\n if (keyVal) {\n return keyVal.split(\"=\").pop();\n }\n return null;\n};\nconst getFirstMatch = (base, pattern) => {\n const match = pattern.exec(base);\n if (!match)\n return null;\n return match[1] || null;\n};\nconst getLocaleFromHostname = (hostname) => {\n if (typeof window === \"undefined\")\n return null;\n return getFirstMatch(window.location.hostname, hostname);\n};\nconst getLocaleFromPathname = (pathname) => {\n if (typeof window === \"undefined\")\n return null;\n return getFirstMatch(window.location.pathname, pathname);\n};\nconst getLocaleFromNavigator = () => {\n if (typeof window === \"undefined\")\n return null;\n return window.navigator.language || window.navigator.languages[0];\n};\nconst getLocaleFromQueryString = (search) => {\n if (typeof window === \"undefined\")\n return null;\n return getFromQueryString(window.location.search.substr(1), search);\n};\nconst getLocaleFromHash = (hash) => {\n if (typeof window === \"undefined\")\n return null;\n return getFromQueryString(window.location.hash.substr(1), hash);\n};\n\nconst monadicMemoize = (fn) => {\n const cache = /* @__PURE__ */ Object.create(null);\n const memoizedFn = (arg) => {\n const cacheKey = JSON.stringify(arg);\n if (cacheKey in cache) {\n return cache[cacheKey];\n }\n return cache[cacheKey] = fn(arg);\n };\n return memoizedFn;\n};\n\nvar __defProp = Object.defineProperty;\nvar __getOwnPropSymbols = Object.getOwnPropertySymbols;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __propIsEnum = Object.prototype.propertyIsEnumerable;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __spreadValues = (a, b) => {\n for (var prop in b || (b = {}))\n if (__hasOwnProp.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n if (__getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(b)) {\n if (__propIsEnum.call(b, prop))\n __defNormalProp(a, prop, b[prop]);\n }\n return a;\n};\nvar __objRest = (source, exclude) => {\n var target = {};\n for (var prop in source)\n if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)\n target[prop] = source[prop];\n if (source != null && __getOwnPropSymbols)\n for (var prop of __getOwnPropSymbols(source)) {\n if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))\n target[prop] = source[prop];\n }\n return target;\n};\nconst getIntlFormatterOptions = (type, name) => {\n const { formats } = getOptions();\n if (type in formats && name in formats[type]) {\n return formats[type][name];\n }\n throw new Error(`[svelte-i18n] Unknown \"${name}\" ${type} format.`);\n};\nconst createNumberFormatter = monadicMemoize(\n (_a) => {\n var _b = _a, { locale, format } = _b, options = __objRest(_b, [\"locale\", \"format\"]);\n if (locale == null) {\n throw new Error('[svelte-i18n] A \"locale\" must be set to format numbers');\n }\n if (format) {\n options = getIntlFormatterOptions(\"number\", format);\n }\n return new Intl.NumberFormat(locale, options);\n }\n);\nconst createDateFormatter = monadicMemoize(\n (_c) => {\n var _d = _c, { locale, format } = _d, options = __objRest(_d, [\"locale\", \"format\"]);\n if (locale == null) {\n throw new Error('[svelte-i18n] A \"locale\" must be set to format dates');\n }\n if (format) {\n options = getIntlFormatterOptions(\"date\", format);\n } else if (Object.keys(options).length === 0) {\n options = getIntlFormatterOptions(\"date\", \"short\");\n }\n return new Intl.DateTimeFormat(locale, options);\n }\n);\nconst createTimeFormatter = monadicMemoize(\n (_e) => {\n var _f = _e, { locale, format } = _f, options = __objRest(_f, [\"locale\", \"format\"]);\n if (locale == null) {\n throw new Error(\n '[svelte-i18n] A \"locale\" must be set to format time values'\n );\n }\n if (format) {\n options = getIntlFormatterOptions(\"time\", format);\n } else if (Object.keys(options).length === 0) {\n options = getIntlFormatterOptions(\"time\", \"short\");\n }\n return new Intl.DateTimeFormat(locale, options);\n }\n);\nconst getNumberFormatter = (_g = {}) => {\n var _h = _g, {\n locale = getCurrentLocale()\n } = _h, args = __objRest(_h, [\n \"locale\"\n ]);\n return createNumberFormatter(__spreadValues({ locale }, args));\n};\nconst getDateFormatter = (_i = {}) => {\n var _j = _i, {\n locale = getCurrentLocale()\n } = _j, args = __objRest(_j, [\n \"locale\"\n ]);\n return createDateFormatter(__spreadValues({ locale }, args));\n};\nconst getTimeFormatter = (_k = {}) => {\n var _l = _k, {\n locale = getCurrentLocale()\n } = _l, args = __objRest(_l, [\n \"locale\"\n ]);\n return createTimeFormatter(__spreadValues({ locale }, args));\n};\nconst getMessageFormatter = monadicMemoize(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (message, locale = getCurrentLocale()) => new IntlMessageFormat(message, locale, getOptions().formats, {\n ignoreTag: getOptions().ignoreTag\n })\n);\n\nconst formatMessage = (id, options = {}) => {\n var _a, _b, _c, _d;\n let messageObj = options;\n if (typeof id === \"object\") {\n messageObj = id;\n id = messageObj.id;\n }\n const {\n values,\n locale = getCurrentLocale(),\n default: defaultValue\n } = messageObj;\n if (locale == null) {\n throw new Error(\n \"[svelte-i18n] Cannot format a message without first setting the initial locale.\"\n );\n }\n let message = lookup(id, locale);\n if (!message) {\n message = (_d = (_c = (_b = (_a = getOptions()).handleMissingMessage) == null ? void 0 : _b.call(_a, { locale, id, defaultValue })) != null ? _c : defaultValue) != null ? _d : id;\n } else if (typeof message !== \"string\") {\n console.warn(\n `[svelte-i18n] Message with id \"${id}\" must be of type \"string\", found: \"${typeof message}\". Gettin its value through the \"$format\" method is deprecated; use the \"json\" method instead.`\n );\n return message;\n }\n if (!values) {\n return message;\n }\n let result = message;\n try {\n result = getMessageFormatter(message, locale).format(values);\n } catch (e) {\n if (e instanceof Error) {\n console.warn(\n `[svelte-i18n] Message \"${id}\" has syntax error:`,\n e.message\n );\n }\n }\n return result;\n};\nconst formatTime = (t, options) => {\n return getTimeFormatter(options).format(t);\n};\nconst formatDate = (d, options) => {\n return getDateFormatter(options).format(d);\n};\nconst formatNumber = (n, options) => {\n return getNumberFormatter(options).format(n);\n};\nconst getJSON = (id, locale = getCurrentLocale()) => {\n return lookup(id, locale);\n};\nconst $format = derived([$locale, $dictionary], () => formatMessage);\nconst $formatTime = derived([$locale], () => formatTime);\nconst $formatDate = derived([$locale], () => formatDate);\nconst $formatNumber = derived([$locale], () => formatNumber);\nconst $getJSON = derived([$locale, $dictionary], () => getJSON);\n\nfunction unwrapFunctionStore(store) {\n let localReference;\n const cancel = store.subscribe((value) => localReference = value);\n const fn = (...args) => localReference(...args);\n fn.freeze = cancel;\n return fn;\n}\n\nfunction defineMessages(i) {\n return i;\n}\nfunction waitLocale(locale) {\n return flush(locale || getCurrentLocale() || getOptions().initialLocale);\n}\n\nexport { $format as _, addMessages, $formatDate as date, defineMessages, $dictionary as dictionary, $format as format, getDateFormatter, getLocaleFromHash, getLocaleFromHostname, getLocaleFromNavigator, getLocaleFromPathname, getLocaleFromQueryString, getMessageFormatter, getNumberFormatter, getTimeFormatter, init, $isLoading as isLoading, $getJSON as json, $locale as locale, $locales as locales, $formatNumber as number, registerLocaleLoader as register, $format as t, $formatTime as time, unwrapFunctionStore, waitLocale };\n","let supports_adopted_stylesheets = false;\n\nif (\n\t\"attachShadow\" in Element.prototype &&\n\t\"adoptedStyleSheets\" in Document.prototype\n) {\n\t// Both Shadow DOM and adoptedStyleSheets are supported\n\tconst shadow_root_test = document\n\t\t.createElement(\"div\")\n\t\t.attachShadow({ mode: \"open\" });\n\tsupports_adopted_stylesheets = \"adoptedStyleSheets\" in shadow_root_test;\n}\n\nexport function mount_css(url: string, target: HTMLElement): Promise {\n\tconst base = new URL(import.meta.url).origin;\n\tconst _url = new URL(url, base).href;\n\tconst existing_link = document.querySelector(`link[href='${_url}']`);\n\n\tif (existing_link) return Promise.resolve();\n\n\tconst link = document.createElement(\"link\");\n\tlink.rel = \"stylesheet\";\n\tlink.href = _url;\n\n\treturn new Promise((res, rej) => {\n\t\tlink.addEventListener(\"load\", () => res());\n\t\tlink.addEventListener(\"error\", () => {\n\t\t\tconsole.error(`Unable to preload CSS for ${_url}`);\n\t\t\tres();\n\t\t});\n\t\ttarget.appendChild(link);\n\t});\n}\n\nexport function prefix_css(\n\tstring: string,\n\tversion: string,\n\tstyle_element = document.createElement(\"style\")\n): HTMLStyleElement | null {\n\tif (!supports_adopted_stylesheets) return null;\n\tstyle_element.remove();\n\n\tconst stylesheet = new CSSStyleSheet();\n\tstylesheet.replaceSync(string);\n\n\tlet importString = \"\";\n\tstring = string.replace(/@import\\s+url\\((.*?)\\);\\s*/g, (match, url) => {\n\t\timportString += `@import url(${url});\\n`;\n\t\treturn \"\"; // remove and store any @import statements from the CSS\n\t});\n\n\tconst rules = stylesheet.cssRules;\n\n\tlet css_string = \"\";\n\tlet gradio_css_infix = `gradio-app .gradio-container.gradio-container-${version} .contain `;\n\n\tfor (let i = 0; i < rules.length; i++) {\n\t\tconst rule = rules[i];\n\n\t\tlet is_dark_rule = rule.cssText.includes(\".dark\");\n\t\tif (rule instanceof CSSStyleRule) {\n\t\t\tconst selector = rule.selectorText;\n\t\t\tif (selector) {\n\t\t\t\tconst new_selector = selector\n\t\t\t\t\t.replace(\".dark\", \"\")\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(s) =>\n\t\t\t\t\t\t\t`${is_dark_rule ? \".dark\" : \"\"} ${gradio_css_infix} ${s.trim()} `\n\t\t\t\t\t)\n\t\t\t\t\t.join(\",\");\n\n\t\t\t\tcss_string += rule.cssText;\n\t\t\t\tcss_string += rule.cssText.replace(selector, new_selector);\n\t\t\t}\n\t\t} else if (rule instanceof CSSMediaRule) {\n\t\t\tlet mediaCssString = `@media ${rule.media.mediaText} {`;\n\t\t\tfor (let j = 0; j < rule.cssRules.length; j++) {\n\t\t\t\tconst innerRule = rule.cssRules[j];\n\t\t\t\tif (innerRule instanceof CSSStyleRule) {\n\t\t\t\t\tlet is_dark_rule = innerRule.cssText.includes(\".dark \");\n\t\t\t\t\tconst selector = innerRule.selectorText;\n\t\t\t\t\tconst new_selector = selector\n\t\t\t\t\t\t.replace(\".dark\", \"\")\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(s) =>\n\t\t\t\t\t\t\t\t`${\n\t\t\t\t\t\t\t\t\tis_dark_rule ? \".dark\" : \"\"\n\t\t\t\t\t\t\t\t} ${gradio_css_infix} ${s.trim()} `\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\",\");\n\t\t\t\t\tmediaCssString += innerRule.cssText.replace(selector, new_selector);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmediaCssString += \"}\";\n\t\t\tcss_string += mediaCssString;\n\t\t} else if (rule instanceof CSSKeyframesRule) {\n\t\t\tcss_string += `@keyframes ${rule.name} {`;\n\t\t\tfor (let j = 0; j < rule.cssRules.length; j++) {\n\t\t\t\tconst innerRule = rule.cssRules[j];\n\t\t\t\tif (innerRule instanceof CSSKeyframeRule) {\n\t\t\t\t\tcss_string += `${innerRule.keyText} { ${innerRule.style.cssText} }`;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcss_string += \"}\";\n\t\t} else if (rule instanceof CSSFontFaceRule) {\n\t\t\tcss_string += `@font-face { ${rule.style.cssText} }`;\n\t\t}\n\t}\n\tcss_string = importString + css_string;\n\tstyle_element.textContent = css_string;\n\n\tdocument.head.appendChild(style_element);\n\treturn style_element;\n}\n","import { addMessages, init, getLocaleFromNavigator } from \"svelte-i18n\";\n\nconst langs = import.meta.glob(\"./lang/*.json\", {\n\teager: true\n});\n\ntype LangsRecord = Record<\n\tstring,\n\t{\n\t\t[key: string]: any;\n\t}\n>;\n\nexport function process_langs(): LangsRecord {\n\tlet _langs: LangsRecord = {};\n\n\tfor (const lang in langs) {\n\t\tconst code = (lang.split(\"/\").pop() as string).split(\".\").shift() as string;\n\t\t_langs[code] = (langs[lang] as Record).default;\n\t}\n\n\treturn _langs;\n}\n\nconst processed_langs = process_langs();\n\nfor (const lang in processed_langs) {\n\taddMessages(lang, processed_langs[lang]);\n}\n\nexport async function setupi18n(): Promise {\n\tawait init({\n\t\tfallbackLocale: \"en\",\n\t\tinitialLocale: getLocaleFromNavigator()\n\t});\n}\n","import \"@gradio/theme/reset.css\";\nimport \"@gradio/theme/global.css\";\nimport \"@gradio/theme/pollen.css\";\nimport \"@gradio/theme/typography.css\";\nimport { Client } from \"@gradio/client\";\nimport { mount_css } from \"@gradio/core\";\nimport type Index from \"./Index.svelte\";\n\nimport type { ThemeMode } from \"@gradio/core\";\n\n//@ts-ignore\nimport * as svelte from \"./svelte/svelte.js\";\n\ndeclare let BUILD_MODE: string;\ndeclare let GRADIO_VERSION: string;\n\nconst ENTRY_CSS = \"__ENTRY_CSS__\";\n\nlet FONTS: string | [];\n\nFONTS = \"__FONTS_CSS__\";\n\nlet IndexComponent: typeof Index;\nlet _res: (value?: unknown) => void;\nlet pending = new Promise((res) => {\n\t_res = res;\n});\nasync function get_index(): Promise {\n\tIndexComponent = (await import(\"./Index.svelte\")).default;\n\t_res();\n}\n\nfunction create_custom_element(): void {\n\tconst o = {\n\t\tSvelteComponent: svelte.SvelteComponent\n\t};\n\tfor (const key in svelte) {\n\t\tif (key === \"SvelteComponent\") continue;\n\t\tif (key === \"SvelteComponentDev\") {\n\t\t\t//@ts-ignore\n\t\t\to[key] = o[\"SvelteComponent\"];\n\t\t} else {\n\t\t\t//@ts-ignore\n\t\t\to[key] = svelte[key];\n\t\t}\n\t}\n\t//@ts-ignore\n\twindow.__gradio__svelte__internal = o;\n\tclass GradioApp extends HTMLElement {\n\t\tcontrol_page_title: string | null;\n\t\tinitial_height: string;\n\t\tis_embed: string;\n\t\tcontainer: string;\n\t\tinfo: string | true;\n\t\tautoscroll: string | null;\n\t\teager: string | null;\n\t\ttheme_mode: ThemeMode | null;\n\t\thost: string | null;\n\t\tspace: string | null;\n\t\tsrc: string | null;\n\t\tapp?: Index;\n\t\tloading: boolean;\n\t\tupdating: { name: string; value: string } | false;\n\n\t\tconstructor() {\n\t\t\tsuper();\n\t\t\tthis.host = this.getAttribute(\"host\");\n\t\t\tthis.space = this.getAttribute(\"space\");\n\t\t\tthis.src = this.getAttribute(\"src\");\n\n\t\t\tthis.control_page_title = this.getAttribute(\"control_page_title\");\n\t\t\tthis.initial_height = this.getAttribute(\"initial_height\") ?? \"300px\"; // default: 300px\n\t\t\tthis.is_embed = this.getAttribute(\"embed\") ?? \"true\"; // default: true\n\t\t\tthis.container = this.getAttribute(\"container\") ?? \"true\"; // default: true\n\t\t\tthis.info = this.getAttribute(\"info\") ?? true; // default: true\n\t\t\tthis.autoscroll = this.getAttribute(\"autoscroll\");\n\t\t\tthis.eager = this.getAttribute(\"eager\");\n\t\t\tthis.theme_mode = this.getAttribute(\"theme_mode\") as ThemeMode | null;\n\t\t\tthis.updating = false;\n\t\t\tthis.loading = false;\n\t\t}\n\n\t\tasync connectedCallback(): Promise {\n\t\t\tawait get_index();\n\t\t\tthis.loading = true;\n\n\t\t\tif (this.app) {\n\t\t\t\tthis.app.$destroy();\n\t\t\t}\n\n\t\t\tif (typeof FONTS !== \"string\") {\n\t\t\t\tFONTS.forEach((f) => mount_css(f, document.head));\n\t\t\t}\n\n\t\t\tawait mount_css(ENTRY_CSS, document.head);\n\n\t\t\tconst event = new CustomEvent(\"domchange\", {\n\t\t\t\tbubbles: true,\n\t\t\t\tcancelable: false,\n\t\t\t\tcomposed: true\n\t\t\t});\n\n\t\t\tconst observer = new MutationObserver((mutations) => {\n\t\t\t\tthis.dispatchEvent(event);\n\t\t\t});\n\n\t\t\tobserver.observe(this, { childList: true });\n\n\t\t\tthis.app = new IndexComponent({\n\t\t\t\ttarget: this,\n\t\t\t\tprops: {\n\t\t\t\t\t// embed source\n\t\t\t\t\tspace: this.space ? this.space.trim() : this.space,\n\t\t\t\t\tsrc: this.src ? this.src.trim() : this.src,\n\t\t\t\t\thost: this.host ? this.host.trim() : this.host,\n\t\t\t\t\t// embed info\n\t\t\t\t\tinfo: this.info === \"false\" ? false : true,\n\t\t\t\t\tcontainer: this.container === \"false\" ? false : true,\n\t\t\t\t\tis_embed: this.is_embed === \"false\" ? false : true,\n\t\t\t\t\tinitial_height: this.initial_height,\n\t\t\t\t\teager: this.eager === \"true\" ? true : false,\n\t\t\t\t\t// gradio meta info\n\t\t\t\t\tversion: GRADIO_VERSION,\n\t\t\t\t\ttheme_mode: this.theme_mode,\n\t\t\t\t\t// misc global behaviour\n\t\t\t\t\tautoscroll: this.autoscroll === \"true\" ? true : false,\n\t\t\t\t\tcontrol_page_title: this.control_page_title === \"true\" ? true : false,\n\t\t\t\t\t// injectables\n\t\t\t\t\tClient,\n\t\t\t\t\t// for gradio docs\n\t\t\t\t\t// TODO: Remove -- i think this is just for autoscroll behavhiour, app vs embeds\n\t\t\t\t\tapp_mode: window.__gradio_mode__ === \"app\"\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (this.updating) {\n\t\t\t\tthis.setAttribute(this.updating.name, this.updating.value);\n\t\t\t}\n\n\t\t\tthis.loading = false;\n\t\t}\n\n\t\tstatic get observedAttributes(): [\"src\", \"space\", \"host\"] {\n\t\t\treturn [\"src\", \"space\", \"host\"];\n\t\t}\n\n\t\tasync attributeChangedCallback(\n\t\t\tname: string,\n\t\t\told_val: string,\n\t\t\tnew_val: string\n\t\t): Promise {\n\t\t\tawait pending;\n\t\t\tif (\n\t\t\t\t(name === \"host\" || name === \"space\" || name === \"src\") &&\n\t\t\t\tnew_val !== old_val\n\t\t\t) {\n\t\t\t\tthis.updating = { name, value: new_val };\n\t\t\t\tif (this.loading) return;\n\n\t\t\t\tif (this.app) {\n\t\t\t\t\tthis.app.$destroy();\n\t\t\t\t}\n\n\t\t\t\tthis.space = null;\n\t\t\t\tthis.host = null;\n\t\t\t\tthis.src = null;\n\n\t\t\t\tif (name === \"host\") {\n\t\t\t\t\tthis.host = new_val;\n\t\t\t\t} else if (name === \"space\") {\n\t\t\t\t\tthis.space = new_val;\n\t\t\t\t} else if (name === \"src\") {\n\t\t\t\t\tthis.src = new_val;\n\t\t\t\t}\n\n\t\t\t\tthis.app = new IndexComponent({\n\t\t\t\t\ttarget: this,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t// embed source\n\t\t\t\t\t\tspace: this.space ? this.space.trim() : this.space,\n\t\t\t\t\t\tsrc: this.src ? this.src.trim() : this.src,\n\t\t\t\t\t\thost: this.host ? this.host.trim() : this.host,\n\t\t\t\t\t\t// embed info\n\t\t\t\t\t\tinfo: this.info === \"false\" ? false : true,\n\t\t\t\t\t\tcontainer: this.container === \"false\" ? false : true,\n\t\t\t\t\t\tis_embed: this.is_embed === \"false\" ? false : true,\n\t\t\t\t\t\tinitial_height: this.initial_height,\n\t\t\t\t\t\teager: this.eager === \"true\" ? true : false,\n\t\t\t\t\t\t// gradio meta info\n\t\t\t\t\t\tversion: GRADIO_VERSION,\n\t\t\t\t\t\ttheme_mode: this.theme_mode,\n\t\t\t\t\t\t// misc global behaviour\n\t\t\t\t\t\tautoscroll: this.autoscroll === \"true\" ? true : false,\n\t\t\t\t\t\tcontrol_page_title:\n\t\t\t\t\t\t\tthis.control_page_title === \"true\" ? true : false,\n\t\t\t\t\t\t// injectables\n\t\t\t\t\t\tClient,\n\t\t\t\t\t\t// for gradio docs\n\t\t\t\t\t\t// TODO: Remove -- i think this is just for autoscroll behavhiour, app vs embeds\n\t\t\t\t\t\tapp_mode: window.__gradio_mode__ === \"app\"\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tthis.updating = false;\n\t\t\t}\n\t\t}\n\t}\n\tif (!customElements.get(\"gradio-app\"))\n\t\tcustomElements.define(\"gradio-app\", GradioApp);\n}\n\ncreate_custom_element();\n"],"file":"assets/index-Dk01HkZL.js"}