import { B as Block } from './Button-723db480.js';
import { B as BlockLabel } from './BlockLabel-7be36365.js';
import { E as Empty } from './Empty-ee9cf9c4.js';
import { S as Static } from './Index-f62c49f9.js';
import { F as File$1 } from './File-e96cd7d6.js';
import { U as Upload } from './Upload-8319436b.js';
import { M as ModifyUpload } from './ModifyUpload-6f4d1a92.js';
import { n as normalise_file } from './index-b5b16a51.js';
import { U as UploadText } from './UploadText-3896a06d.js';
export { default as BaseExample } from './Example-d9b38e6f.js';
/* empty css                                                     */import './IconButton-34156fe0.js';
import './Clear-9760deed.js';
import './svelte/svelte.js';

const prettyBytes = (bytes) => {
  let units = ["B", "KB", "MB", "GB", "PB"];
  let i = 0;
  while (bytes > 1024) {
    bytes /= 1024;
    i++;
  }
  let unit = units[i];
  return bytes.toFixed(1) + "&nbsp;" + unit;
};
const display_file_name = (value) => {
  var str;
  str = value.orig_name;
  const max_length = 30;
  if (str.length > max_length) {
    const truncated_name = str.substring(0, max_length);
    const file_extension_index = str.lastIndexOf(".");
    if (file_extension_index !== -1) {
      const file_extension = str.slice(file_extension_index);
      return `${truncated_name}..${file_extension}`;
    }
    return truncated_name;
  }
  return str;
};
const display_file_size = (value) => {
  var total_size = 0;
  if (Array.isArray(value)) {
    for (var file of value) {
      if (file.size !== void 0)
        total_size += file.size;
    }
  } else {
    total_size = value.size || 0;
  }
  return prettyBytes(total_size);
};

const FilePreview_svelte_svelte_type_style_lang = '';

/* home/runner/work/gradio/gradio/js/file/shared/FilePreview.svelte generated by Svelte v4.2.2 */
const {
	HtmlTag,
	SvelteComponent: SvelteComponent$3,
	append,
	attr,
	destroy_each,
	detach: detach$3,
	element,
	ensure_array_like,
	init: init$3,
	insert: insert$3,
	listen,
	noop,
	safe_not_equal: safe_not_equal$3,
	set_data,
	set_style,
	space: space$3,
	text,
	toggle_class
} = window.__gradio__svelte__internal;const { createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal;
function get_each_context(ctx, list, i) {
	const child_ctx = ctx.slice();
	child_ctx[6] = list[i];
	child_ctx[8] = i;
	return child_ctx;
}

// (39:6) {:else}
function create_else_block$3(ctx) {
	let t_value = /*i18n*/ ctx[3]("file.uploading") + "";
	let t;

	return {
		c() {
			t = text(t_value);
		},
		m(target, anchor) {
			insert$3(target, t, anchor);
		},
		p(ctx, dirty) {
			if (dirty & /*i18n*/ 8 && t_value !== (t_value = /*i18n*/ ctx[3]("file.uploading") + "")) set_data(t, t_value);
		},
		d(detaching) {
			if (detaching) {
				detach$3(t);
			}
		}
	};
}

// (31:6) {#if file.url}
function create_if_block$3(ctx) {
	let a;
	let html_tag;
	let raw_value = display_file_size(/*file*/ ctx[6]) + "";
	let t;
	let a_href_value;
	let a_download_value;

	return {
		c() {
			a = element("a");
			html_tag = new HtmlTag(false);
			t = text(" ⇣");
			html_tag.a = t;
			attr(a, "href", a_href_value = /*file*/ ctx[6].url);
			attr(a, "target", "_blank");
			attr(a, "download", a_download_value = window.__is_colab__ ? null : /*file*/ ctx[6].orig_name);
			attr(a, "class", "svelte-1lop6bc");
		},
		m(target, anchor) {
			insert$3(target, a, anchor);
			html_tag.m(raw_value, a);
			append(a, t);
		},
		p(ctx, dirty) {
			if (dirty & /*value*/ 1 && raw_value !== (raw_value = display_file_size(/*file*/ ctx[6]) + "")) html_tag.p(raw_value);

			if (dirty & /*value*/ 1 && a_href_value !== (a_href_value = /*file*/ ctx[6].url)) {
				attr(a, "href", a_href_value);
			}

			if (dirty & /*value*/ 1 && a_download_value !== (a_download_value = window.__is_colab__ ? null : /*file*/ ctx[6].orig_name)) {
				attr(a, "download", a_download_value);
			}
		},
		d(detaching) {
			if (detaching) {
				detach$3(a);
			}
		}
	};
}

// (16:3) {#each Array.isArray(value) ? value : [value] as file, i}
function create_each_block(ctx) {
	let tr;
	let td0;
	let t0_value = display_file_name(/*file*/ ctx[6]) + "";
	let t0;
	let t1;
	let td1;
	let t2;
	let mounted;
	let dispose;

	function select_block_type(ctx, dirty) {
		if (/*file*/ ctx[6].url) return create_if_block$3;
		return create_else_block$3;
	}

	let current_block_type = select_block_type(ctx);
	let if_block = current_block_type(ctx);

	function click_handler() {
		return /*click_handler*/ ctx[5](/*file*/ ctx[6], /*i*/ ctx[8]);
	}

	return {
		c() {
			tr = element("tr");
			td0 = element("td");
			t0 = text(t0_value);
			t1 = space$3();
			td1 = element("td");
			if_block.c();
			t2 = space$3();
			attr(td0, "class", "svelte-1lop6bc");
			attr(td1, "class", "download svelte-1lop6bc");
			attr(tr, "class", "file svelte-1lop6bc");
			toggle_class(tr, "selectable", /*selectable*/ ctx[1]);
		},
		m(target, anchor) {
			insert$3(target, tr, anchor);
			append(tr, td0);
			append(td0, t0);
			append(tr, t1);
			append(tr, td1);
			if_block.m(td1, null);
			append(tr, t2);

			if (!mounted) {
				dispose = listen(tr, "click", click_handler);
				mounted = true;
			}
		},
		p(new_ctx, dirty) {
			ctx = new_ctx;
			if (dirty & /*value*/ 1 && t0_value !== (t0_value = display_file_name(/*file*/ ctx[6]) + "")) set_data(t0, t0_value);

			if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
				if_block.p(ctx, dirty);
			} else {
				if_block.d(1);
				if_block = current_block_type(ctx);

				if (if_block) {
					if_block.c();
					if_block.m(td1, null);
				}
			}

			if (dirty & /*selectable*/ 2) {
				toggle_class(tr, "selectable", /*selectable*/ ctx[1]);
			}
		},
		d(detaching) {
			if (detaching) {
				detach$3(tr);
			}

			if_block.d();
			mounted = false;
			dispose();
		}
	};
}

function create_fragment$3(ctx) {
	let div;
	let table;
	let tbody;

	let each_value = ensure_array_like(Array.isArray(/*value*/ ctx[0])
	? /*value*/ ctx[0]
	: [/*value*/ ctx[0]]);

	let each_blocks = [];

	for (let i = 0; i < each_value.length; i += 1) {
		each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
	}

	return {
		c() {
			div = element("div");
			table = element("table");
			tbody = element("tbody");

			for (let i = 0; i < each_blocks.length; i += 1) {
				each_blocks[i].c();
			}

			attr(tbody, "class", "svelte-1lop6bc");
			attr(table, "class", "file-preview svelte-1lop6bc");
			attr(div, "class", "file-preview-holder svelte-1lop6bc");

			set_style(div, "max-height", typeof /*height*/ ctx[2] === undefined
			? 'auto'
			: /*height*/ ctx[2] + 'px');
		},
		m(target, anchor) {
			insert$3(target, div, anchor);
			append(div, table);
			append(table, tbody);

			for (let i = 0; i < each_blocks.length; i += 1) {
				if (each_blocks[i]) {
					each_blocks[i].m(tbody, null);
				}
			}
		},
		p(ctx, [dirty]) {
			if (dirty & /*selectable, dispatch, Array, value, window, i18n*/ 27) {
				each_value = ensure_array_like(Array.isArray(/*value*/ ctx[0])
				? /*value*/ ctx[0]
				: [/*value*/ ctx[0]]);

				let i;

				for (i = 0; i < each_value.length; i += 1) {
					const child_ctx = get_each_context(ctx, each_value, i);

					if (each_blocks[i]) {
						each_blocks[i].p(child_ctx, dirty);
					} else {
						each_blocks[i] = create_each_block(child_ctx);
						each_blocks[i].c();
						each_blocks[i].m(tbody, null);
					}
				}

				for (; i < each_blocks.length; i += 1) {
					each_blocks[i].d(1);
				}

				each_blocks.length = each_value.length;
			}

			if (dirty & /*height*/ 4) {
				set_style(div, "max-height", typeof /*height*/ ctx[2] === undefined
				? 'auto'
				: /*height*/ ctx[2] + 'px');
			}
		},
		i: noop,
		o: noop,
		d(detaching) {
			if (detaching) {
				detach$3(div);
			}

			destroy_each(each_blocks, detaching);
		}
	};
}

function instance$3($$self, $$props, $$invalidate) {
	const dispatch = createEventDispatcher$1();
	let { value } = $$props;
	let { selectable = false } = $$props;
	let { height = undefined } = $$props;
	let { i18n } = $$props;
	const click_handler = (file, i) => dispatch("select", { value: file.orig_name, index: i });

	$$self.$$set = $$props => {
		if ('value' in $$props) $$invalidate(0, value = $$props.value);
		if ('selectable' in $$props) $$invalidate(1, selectable = $$props.selectable);
		if ('height' in $$props) $$invalidate(2, height = $$props.height);
		if ('i18n' in $$props) $$invalidate(3, i18n = $$props.i18n);
	};

	return [value, selectable, height, i18n, dispatch, click_handler];
}

class FilePreview extends SvelteComponent$3 {
	constructor(options) {
		super();

		init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, {
			value: 0,
			selectable: 1,
			height: 2,
			i18n: 3
		});
	}
}

const FilePreview$1 = FilePreview;

/* home/runner/work/gradio/gradio/js/file/shared/File.svelte generated by Svelte v4.2.2 */
const {
	SvelteComponent: SvelteComponent$2,
	bubble: bubble$1,
	check_outros: check_outros$2,
	create_component: create_component$2,
	destroy_component: destroy_component$2,
	detach: detach$2,
	empty: empty$2,
	group_outros: group_outros$2,
	init: init$2,
	insert: insert$2,
	mount_component: mount_component$2,
	safe_not_equal: safe_not_equal$2,
	space: space$2,
	transition_in: transition_in$2,
	transition_out: transition_out$2
} = window.__gradio__svelte__internal;
function create_else_block$2(ctx) {
	let empty_1;
	let current;

	empty_1 = new Empty({
			props: {
				unpadded_box: true,
				size: "large",
				$$slots: { default: [create_default_slot$2] },
				$$scope: { ctx }
			}
		});

	return {
		c() {
			create_component$2(empty_1.$$.fragment);
		},
		m(target, anchor) {
			mount_component$2(empty_1, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const empty_1_changes = {};

			if (dirty & /*$$scope*/ 128) {
				empty_1_changes.$$scope = { dirty, ctx };
			}

			empty_1.$set(empty_1_changes);
		},
		i(local) {
			if (current) return;
			transition_in$2(empty_1.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out$2(empty_1.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component$2(empty_1, detaching);
		}
	};
}

// (19:0) {#if value}
function create_if_block$2(ctx) {
	let filepreview;
	let current;

	filepreview = new FilePreview$1({
			props: {
				i18n: /*i18n*/ ctx[5],
				selectable: /*selectable*/ ctx[3],
				value: /*value*/ ctx[0],
				height: /*height*/ ctx[4]
			}
		});

	filepreview.$on("select", /*select_handler*/ ctx[6]);

	return {
		c() {
			create_component$2(filepreview.$$.fragment);
		},
		m(target, anchor) {
			mount_component$2(filepreview, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const filepreview_changes = {};
			if (dirty & /*i18n*/ 32) filepreview_changes.i18n = /*i18n*/ ctx[5];
			if (dirty & /*selectable*/ 8) filepreview_changes.selectable = /*selectable*/ ctx[3];
			if (dirty & /*value*/ 1) filepreview_changes.value = /*value*/ ctx[0];
			if (dirty & /*height*/ 16) filepreview_changes.height = /*height*/ ctx[4];
			filepreview.$set(filepreview_changes);
		},
		i(local) {
			if (current) return;
			transition_in$2(filepreview.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out$2(filepreview.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component$2(filepreview, detaching);
		}
	};
}

// (22:1) <Empty unpadded_box={true} size="large">
function create_default_slot$2(ctx) {
	let file;
	let current;
	file = new File$1({});

	return {
		c() {
			create_component$2(file.$$.fragment);
		},
		m(target, anchor) {
			mount_component$2(file, target, anchor);
			current = true;
		},
		i(local) {
			if (current) return;
			transition_in$2(file.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out$2(file.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component$2(file, detaching);
		}
	};
}

function create_fragment$2(ctx) {
	let blocklabel;
	let t;
	let current_block_type_index;
	let if_block;
	let if_block_anchor;
	let current;

	blocklabel = new BlockLabel({
			props: {
				show_label: /*show_label*/ ctx[2],
				float: /*value*/ ctx[0] === null,
				Icon: File$1,
				label: /*label*/ ctx[1] || "File"
			}
		});

	const if_block_creators = [create_if_block$2, create_else_block$2];
	const if_blocks = [];

	function select_block_type(ctx, dirty) {
		if (/*value*/ ctx[0]) return 0;
		return 1;
	}

	current_block_type_index = select_block_type(ctx);
	if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);

	return {
		c() {
			create_component$2(blocklabel.$$.fragment);
			t = space$2();
			if_block.c();
			if_block_anchor = empty$2();
		},
		m(target, anchor) {
			mount_component$2(blocklabel, target, anchor);
			insert$2(target, t, anchor);
			if_blocks[current_block_type_index].m(target, anchor);
			insert$2(target, if_block_anchor, anchor);
			current = true;
		},
		p(ctx, [dirty]) {
			const blocklabel_changes = {};
			if (dirty & /*show_label*/ 4) blocklabel_changes.show_label = /*show_label*/ ctx[2];
			if (dirty & /*value*/ 1) blocklabel_changes.float = /*value*/ ctx[0] === null;
			if (dirty & /*label*/ 2) blocklabel_changes.label = /*label*/ ctx[1] || "File";
			blocklabel.$set(blocklabel_changes);
			let previous_block_index = current_block_type_index;
			current_block_type_index = select_block_type(ctx);

			if (current_block_type_index === previous_block_index) {
				if_blocks[current_block_type_index].p(ctx, dirty);
			} else {
				group_outros$2();

				transition_out$2(if_blocks[previous_block_index], 1, 1, () => {
					if_blocks[previous_block_index] = null;
				});

				check_outros$2();
				if_block = if_blocks[current_block_type_index];

				if (!if_block) {
					if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
					if_block.c();
				} else {
					if_block.p(ctx, dirty);
				}

				transition_in$2(if_block, 1);
				if_block.m(if_block_anchor.parentNode, if_block_anchor);
			}
		},
		i(local) {
			if (current) return;
			transition_in$2(blocklabel.$$.fragment, local);
			transition_in$2(if_block);
			current = true;
		},
		o(local) {
			transition_out$2(blocklabel.$$.fragment, local);
			transition_out$2(if_block);
			current = false;
		},
		d(detaching) {
			if (detaching) {
				detach$2(t);
				detach$2(if_block_anchor);
			}

			destroy_component$2(blocklabel, detaching);
			if_blocks[current_block_type_index].d(detaching);
		}
	};
}

function instance$2($$self, $$props, $$invalidate) {
	let { value = null } = $$props;
	let { label } = $$props;
	let { show_label = true } = $$props;
	let { selectable = false } = $$props;
	let { height = undefined } = $$props;
	let { i18n } = $$props;

	function select_handler(event) {
		bubble$1.call(this, $$self, event);
	}

	$$self.$$set = $$props => {
		if ('value' in $$props) $$invalidate(0, value = $$props.value);
		if ('label' in $$props) $$invalidate(1, label = $$props.label);
		if ('show_label' in $$props) $$invalidate(2, show_label = $$props.show_label);
		if ('selectable' in $$props) $$invalidate(3, selectable = $$props.selectable);
		if ('height' in $$props) $$invalidate(4, height = $$props.height);
		if ('i18n' in $$props) $$invalidate(5, i18n = $$props.i18n);
	};

	return [value, label, show_label, selectable, height, i18n, select_handler];
}

class File_1 extends SvelteComponent$2 {
	constructor(options) {
		super();

		init$2(this, options, instance$2, create_fragment$2, safe_not_equal$2, {
			value: 0,
			label: 1,
			show_label: 2,
			selectable: 3,
			height: 4,
			i18n: 5
		});
	}
}

const File = File_1;

/* home/runner/work/gradio/gradio/js/file/shared/FileUpload.svelte generated by Svelte v4.2.2 */
const {
	SvelteComponent: SvelteComponent$1,
	add_flush_callback,
	bind,
	binding_callbacks,
	bubble,
	check_outros: check_outros$1,
	create_component: create_component$1,
	create_slot,
	destroy_component: destroy_component$1,
	detach: detach$1,
	empty: empty$1,
	get_all_dirty_from_scope,
	get_slot_changes,
	group_outros: group_outros$1,
	init: init$1,
	insert: insert$1,
	mount_component: mount_component$1,
	safe_not_equal: safe_not_equal$1,
	space: space$1,
	transition_in: transition_in$1,
	transition_out: transition_out$1,
	update_slot_base
} = window.__gradio__svelte__internal;
const { createEventDispatcher, tick } = window.__gradio__svelte__internal;
function create_else_block$1(ctx) {
	let upload;
	let updating_dragging;
	let current;

	function upload_dragging_binding(value) {
		/*upload_dragging_binding*/ ctx[15](value);
	}

	let upload_props = {
		filetype: /*accept_file_types*/ ctx[9],
		file_count: /*file_count*/ ctx[3],
		root: /*root*/ ctx[5],
		$$slots: { default: [create_default_slot$1] },
		$$scope: { ctx }
	};

	if (/*dragging*/ ctx[8] !== void 0) {
		upload_props.dragging = /*dragging*/ ctx[8];
	}

	upload = new Upload({ props: upload_props });
	binding_callbacks.push(() => bind(upload, 'dragging', upload_dragging_binding));
	upload.$on("load", /*handle_upload*/ ctx[10]);

	return {
		c() {
			create_component$1(upload.$$.fragment);
		},
		m(target, anchor) {
			mount_component$1(upload, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const upload_changes = {};
			if (dirty & /*accept_file_types*/ 512) upload_changes.filetype = /*accept_file_types*/ ctx[9];
			if (dirty & /*file_count*/ 8) upload_changes.file_count = /*file_count*/ ctx[3];
			if (dirty & /*root*/ 32) upload_changes.root = /*root*/ ctx[5];

			if (dirty & /*$$scope*/ 65536) {
				upload_changes.$$scope = { dirty, ctx };
			}

			if (!updating_dragging && dirty & /*dragging*/ 256) {
				updating_dragging = true;
				upload_changes.dragging = /*dragging*/ ctx[8];
				add_flush_callback(() => updating_dragging = false);
			}

			upload.$set(upload_changes);
		},
		i(local) {
			if (current) return;
			transition_in$1(upload.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out$1(upload.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component$1(upload, detaching);
		}
	};
}

// (51:0) {#if value}
function create_if_block$1(ctx) {
	let modifyupload;
	let t;
	let filepreview;
	let current;

	modifyupload = new ModifyUpload({
			props: { i18n: /*i18n*/ ctx[7], absolute: true }
		});

	modifyupload.$on("clear", /*handle_clear*/ ctx[11]);

	filepreview = new FilePreview$1({
			props: {
				i18n: /*i18n*/ ctx[7],
				selectable: /*selectable*/ ctx[4],
				value: /*value*/ ctx[0],
				height: /*height*/ ctx[6]
			}
		});

	filepreview.$on("select", /*select_handler*/ ctx[14]);

	return {
		c() {
			create_component$1(modifyupload.$$.fragment);
			t = space$1();
			create_component$1(filepreview.$$.fragment);
		},
		m(target, anchor) {
			mount_component$1(modifyupload, target, anchor);
			insert$1(target, t, anchor);
			mount_component$1(filepreview, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const modifyupload_changes = {};
			if (dirty & /*i18n*/ 128) modifyupload_changes.i18n = /*i18n*/ ctx[7];
			modifyupload.$set(modifyupload_changes);
			const filepreview_changes = {};
			if (dirty & /*i18n*/ 128) filepreview_changes.i18n = /*i18n*/ ctx[7];
			if (dirty & /*selectable*/ 16) filepreview_changes.selectable = /*selectable*/ ctx[4];
			if (dirty & /*value*/ 1) filepreview_changes.value = /*value*/ ctx[0];
			if (dirty & /*height*/ 64) filepreview_changes.height = /*height*/ ctx[6];
			filepreview.$set(filepreview_changes);
		},
		i(local) {
			if (current) return;
			transition_in$1(modifyupload.$$.fragment, local);
			transition_in$1(filepreview.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out$1(modifyupload.$$.fragment, local);
			transition_out$1(filepreview.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			if (detaching) {
				detach$1(t);
			}

			destroy_component$1(modifyupload, detaching);
			destroy_component$1(filepreview, detaching);
		}
	};
}

// (55:1) <Upload   on:load={handle_upload}   filetype={accept_file_types}   {file_count}   {root}   bind:dragging  >
function create_default_slot$1(ctx) {
	let current;
	const default_slot_template = /*#slots*/ ctx[13].default;
	const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[16], null);

	return {
		c() {
			if (default_slot) default_slot.c();
		},
		m(target, anchor) {
			if (default_slot) {
				default_slot.m(target, anchor);
			}

			current = true;
		},
		p(ctx, dirty) {
			if (default_slot) {
				if (default_slot.p && (!current || dirty & /*$$scope*/ 65536)) {
					update_slot_base(
						default_slot,
						default_slot_template,
						ctx,
						/*$$scope*/ ctx[16],
						!current
						? get_all_dirty_from_scope(/*$$scope*/ ctx[16])
						: get_slot_changes(default_slot_template, /*$$scope*/ ctx[16], dirty, null),
						null
					);
				}
			}
		},
		i(local) {
			if (current) return;
			transition_in$1(default_slot, local);
			current = true;
		},
		o(local) {
			transition_out$1(default_slot, local);
			current = false;
		},
		d(detaching) {
			if (default_slot) default_slot.d(detaching);
		}
	};
}

function create_fragment$1(ctx) {
	let blocklabel;
	let t;
	let current_block_type_index;
	let if_block;
	let if_block_anchor;
	let current;

	blocklabel = new BlockLabel({
			props: {
				show_label: /*show_label*/ ctx[2],
				Icon: File$1,
				float: /*value*/ ctx[0] === null,
				label: /*label*/ ctx[1] || "File"
			}
		});

	const if_block_creators = [create_if_block$1, create_else_block$1];
	const if_blocks = [];

	function select_block_type(ctx, dirty) {
		if (/*value*/ ctx[0]) return 0;
		return 1;
	}

	current_block_type_index = select_block_type(ctx);
	if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);

	return {
		c() {
			create_component$1(blocklabel.$$.fragment);
			t = space$1();
			if_block.c();
			if_block_anchor = empty$1();
		},
		m(target, anchor) {
			mount_component$1(blocklabel, target, anchor);
			insert$1(target, t, anchor);
			if_blocks[current_block_type_index].m(target, anchor);
			insert$1(target, if_block_anchor, anchor);
			current = true;
		},
		p(ctx, [dirty]) {
			const blocklabel_changes = {};
			if (dirty & /*show_label*/ 4) blocklabel_changes.show_label = /*show_label*/ ctx[2];
			if (dirty & /*value*/ 1) blocklabel_changes.float = /*value*/ ctx[0] === null;
			if (dirty & /*label*/ 2) blocklabel_changes.label = /*label*/ ctx[1] || "File";
			blocklabel.$set(blocklabel_changes);
			let previous_block_index = current_block_type_index;
			current_block_type_index = select_block_type(ctx);

			if (current_block_type_index === previous_block_index) {
				if_blocks[current_block_type_index].p(ctx, dirty);
			} else {
				group_outros$1();

				transition_out$1(if_blocks[previous_block_index], 1, 1, () => {
					if_blocks[previous_block_index] = null;
				});

				check_outros$1();
				if_block = if_blocks[current_block_type_index];

				if (!if_block) {
					if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
					if_block.c();
				} else {
					if_block.p(ctx, dirty);
				}

				transition_in$1(if_block, 1);
				if_block.m(if_block_anchor.parentNode, if_block_anchor);
			}
		},
		i(local) {
			if (current) return;
			transition_in$1(blocklabel.$$.fragment, local);
			transition_in$1(if_block);
			current = true;
		},
		o(local) {
			transition_out$1(blocklabel.$$.fragment, local);
			transition_out$1(if_block);
			current = false;
		},
		d(detaching) {
			if (detaching) {
				detach$1(t);
				detach$1(if_block_anchor);
			}

			destroy_component$1(blocklabel, detaching);
			if_blocks[current_block_type_index].d(detaching);
		}
	};
}

function instance$1($$self, $$props, $$invalidate) {
	let { $$slots: slots = {}, $$scope } = $$props;
	let { value } = $$props;
	let { label } = $$props;
	let { show_label = true } = $$props;
	let { file_count = "single" } = $$props;
	let { file_types = null } = $$props;
	let { selectable = false } = $$props;
	let { root } = $$props;
	let { height = undefined } = $$props;
	let { i18n } = $$props;

	async function handle_upload({ detail }) {
		$$invalidate(0, value = detail);
		await tick();
		dispatch("change", value);
		dispatch("upload", detail);
	}

	function handle_clear() {
		$$invalidate(0, value = null);
		dispatch("change", null);
		dispatch("clear");
	}

	const dispatch = createEventDispatcher();
	let accept_file_types;

	if (file_types == null) {
		accept_file_types = null;
	} else {
		file_types = file_types.map(x => {
			if (x.startsWith(".")) {
				return x;
			}

			return x + "/*";
		});

		accept_file_types = file_types.join(", ");
	}

	let dragging = false;

	function select_handler(event) {
		bubble.call(this, $$self, event);
	}

	function upload_dragging_binding(value) {
		dragging = value;
		$$invalidate(8, dragging);
	}

	$$self.$$set = $$props => {
		if ('value' in $$props) $$invalidate(0, value = $$props.value);
		if ('label' in $$props) $$invalidate(1, label = $$props.label);
		if ('show_label' in $$props) $$invalidate(2, show_label = $$props.show_label);
		if ('file_count' in $$props) $$invalidate(3, file_count = $$props.file_count);
		if ('file_types' in $$props) $$invalidate(12, file_types = $$props.file_types);
		if ('selectable' in $$props) $$invalidate(4, selectable = $$props.selectable);
		if ('root' in $$props) $$invalidate(5, root = $$props.root);
		if ('height' in $$props) $$invalidate(6, height = $$props.height);
		if ('i18n' in $$props) $$invalidate(7, i18n = $$props.i18n);
		if ('$$scope' in $$props) $$invalidate(16, $$scope = $$props.$$scope);
	};

	$$self.$$.update = () => {
		if ($$self.$$.dirty & /*dragging*/ 256) {
			dispatch("drag", dragging);
		}
	};

	return [
		value,
		label,
		show_label,
		file_count,
		selectable,
		root,
		height,
		i18n,
		dragging,
		accept_file_types,
		handle_upload,
		handle_clear,
		file_types,
		slots,
		select_handler,
		upload_dragging_binding,
		$$scope
	];
}

class FileUpload extends SvelteComponent$1 {
	constructor(options) {
		super();

		init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, {
			value: 0,
			label: 1,
			show_label: 2,
			file_count: 3,
			file_types: 12,
			selectable: 4,
			root: 5,
			height: 6,
			i18n: 7
		});
	}
}

const FileUpload$1 = FileUpload;

/* home/runner/work/gradio/gradio/js/file/Index.svelte generated by Svelte v4.2.2 */
const {
	SvelteComponent,
	assign,
	check_outros,
	create_component,
	destroy_component,
	detach,
	empty,
	flush,
	get_spread_object,
	get_spread_update,
	group_outros,
	init,
	insert,
	mount_component,
	safe_not_equal,
	space,
	transition_in,
	transition_out
} = window.__gradio__svelte__internal;
function create_else_block(ctx) {
	let fileupload;
	let current;

	fileupload = new FileUpload$1({
			props: {
				label: /*label*/ ctx[6],
				show_label: /*show_label*/ ctx[7],
				value: /*_value*/ ctx[17],
				file_count: /*file_count*/ ctx[15],
				file_types: /*file_types*/ ctx[16],
				selectable: /*_selectable*/ ctx[9],
				root: /*root*/ ctx[5],
				height: /*height*/ ctx[8],
				i18n: /*gradio*/ ctx[14].i18n,
				$$slots: { default: [create_default_slot_1] },
				$$scope: { ctx }
			}
		});

	fileupload.$on("change", /*change_handler*/ ctx[22]);
	fileupload.$on("drag", /*drag_handler*/ ctx[23]);
	fileupload.$on("clear", /*clear_handler*/ ctx[24]);
	fileupload.$on("select", /*select_handler_1*/ ctx[25]);
	fileupload.$on("upload", /*upload_handler*/ ctx[26]);

	return {
		c() {
			create_component(fileupload.$$.fragment);
		},
		m(target, anchor) {
			mount_component(fileupload, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const fileupload_changes = {};
			if (dirty & /*label*/ 64) fileupload_changes.label = /*label*/ ctx[6];
			if (dirty & /*show_label*/ 128) fileupload_changes.show_label = /*show_label*/ ctx[7];
			if (dirty & /*_value*/ 131072) fileupload_changes.value = /*_value*/ ctx[17];
			if (dirty & /*file_count*/ 32768) fileupload_changes.file_count = /*file_count*/ ctx[15];
			if (dirty & /*file_types*/ 65536) fileupload_changes.file_types = /*file_types*/ ctx[16];
			if (dirty & /*_selectable*/ 512) fileupload_changes.selectable = /*_selectable*/ ctx[9];
			if (dirty & /*root*/ 32) fileupload_changes.root = /*root*/ ctx[5];
			if (dirty & /*height*/ 256) fileupload_changes.height = /*height*/ ctx[8];
			if (dirty & /*gradio*/ 16384) fileupload_changes.i18n = /*gradio*/ ctx[14].i18n;

			if (dirty & /*$$scope, gradio*/ 134234112) {
				fileupload_changes.$$scope = { dirty, ctx };
			}

			fileupload.$set(fileupload_changes);
		},
		i(local) {
			if (current) return;
			transition_in(fileupload.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(fileupload.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(fileupload, detaching);
		}
	};
}

// (62:1) {#if !interactive}
function create_if_block(ctx) {
	let file;
	let current;

	file = new File({
			props: {
				selectable: /*_selectable*/ ctx[9],
				value: /*_value*/ ctx[17],
				label: /*label*/ ctx[6],
				show_label: /*show_label*/ ctx[7],
				height: /*height*/ ctx[8],
				i18n: /*gradio*/ ctx[14].i18n
			}
		});

	file.$on("select", /*select_handler*/ ctx[21]);

	return {
		c() {
			create_component(file.$$.fragment);
		},
		m(target, anchor) {
			mount_component(file, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const file_changes = {};
			if (dirty & /*_selectable*/ 512) file_changes.selectable = /*_selectable*/ ctx[9];
			if (dirty & /*_value*/ 131072) file_changes.value = /*_value*/ ctx[17];
			if (dirty & /*label*/ 64) file_changes.label = /*label*/ ctx[6];
			if (dirty & /*show_label*/ 128) file_changes.show_label = /*show_label*/ ctx[7];
			if (dirty & /*height*/ 256) file_changes.height = /*height*/ ctx[8];
			if (dirty & /*gradio*/ 16384) file_changes.i18n = /*gradio*/ ctx[14].i18n;
			file.$set(file_changes);
		},
		i(local) {
			if (current) return;
			transition_in(file.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(file.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(file, detaching);
		}
	};
}

// (73:2) <FileUpload    {label}    {show_label}    value={_value}    {file_count}    {file_types}    selectable={_selectable}    {root}    {height}    on:change={({ detail }) => {     value = detail;    }}    on:drag={({ detail }) => (dragging = detail)}    on:clear={() => gradio.dispatch("clear")}    on:select={({ detail }) => gradio.dispatch("select", detail)}    on:upload={() => gradio.dispatch("upload")}    i18n={gradio.i18n}   >
function create_default_slot_1(ctx) {
	let uploadtext;
	let current;

	uploadtext = new UploadText({
			props: {
				i18n: /*gradio*/ ctx[14].i18n,
				type: "file"
			}
		});

	return {
		c() {
			create_component(uploadtext.$$.fragment);
		},
		m(target, anchor) {
			mount_component(uploadtext, target, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const uploadtext_changes = {};
			if (dirty & /*gradio*/ 16384) uploadtext_changes.i18n = /*gradio*/ ctx[14].i18n;
			uploadtext.$set(uploadtext_changes);
		},
		i(local) {
			if (current) return;
			transition_in(uploadtext.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(uploadtext.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(uploadtext, detaching);
		}
	};
}

// (42:0) <Block  {visible}  variant={value === null ? "dashed" : "solid"}  border_mode={dragging ? "focus" : "base"}  padding={false}  {elem_id}  {elem_classes}  {container}  {scale}  {min_width}  allow_overflow={false} >
function create_default_slot(ctx) {
	let statustracker;
	let t;
	let current_block_type_index;
	let if_block;
	let if_block_anchor;
	let current;

	const statustracker_spread_levels = [
		{
			autoscroll: /*gradio*/ ctx[14].autoscroll
		},
		{ i18n: /*gradio*/ ctx[14].i18n },
		/*loading_status*/ ctx[10],
		{
			status: /*loading_status*/ ctx[10]?.status || "complete"
		}
	];

	let statustracker_props = {};

	for (let i = 0; i < statustracker_spread_levels.length; i += 1) {
		statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]);
	}

	statustracker = new Static({ props: statustracker_props });
	const if_block_creators = [create_if_block, create_else_block];
	const if_blocks = [];

	function select_block_type(ctx, dirty) {
		if (!/*interactive*/ ctx[4]) return 0;
		return 1;
	}

	current_block_type_index = select_block_type(ctx);
	if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);

	return {
		c() {
			create_component(statustracker.$$.fragment);
			t = space();
			if_block.c();
			if_block_anchor = empty();
		},
		m(target, anchor) {
			mount_component(statustracker, target, anchor);
			insert(target, t, anchor);
			if_blocks[current_block_type_index].m(target, anchor);
			insert(target, if_block_anchor, anchor);
			current = true;
		},
		p(ctx, dirty) {
			const statustracker_changes = (dirty & /*gradio, loading_status, pending_upload*/ 17408)
			? get_spread_update(statustracker_spread_levels, [
					dirty & /*gradio*/ 16384 && {
						autoscroll: /*gradio*/ ctx[14].autoscroll
					},
					dirty & /*gradio*/ 16384 && { i18n: /*gradio*/ ctx[14].i18n },
					dirty & /*loading_status*/ 1024 && get_spread_object(/*loading_status*/ ctx[10]),
					dirty & /*pending_upload, loading_status*/ 1024 && {
						status: /*loading_status*/ ctx[10]?.status || "complete"
					}
				])
			: {};

			statustracker.$set(statustracker_changes);
			let previous_block_index = current_block_type_index;
			current_block_type_index = select_block_type(ctx);

			if (current_block_type_index === previous_block_index) {
				if_blocks[current_block_type_index].p(ctx, dirty);
			} else {
				group_outros();

				transition_out(if_blocks[previous_block_index], 1, 1, () => {
					if_blocks[previous_block_index] = null;
				});

				check_outros();
				if_block = if_blocks[current_block_type_index];

				if (!if_block) {
					if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
					if_block.c();
				} else {
					if_block.p(ctx, dirty);
				}

				transition_in(if_block, 1);
				if_block.m(if_block_anchor.parentNode, if_block_anchor);
			}
		},
		i(local) {
			if (current) return;
			transition_in(statustracker.$$.fragment, local);
			transition_in(if_block);
			current = true;
		},
		o(local) {
			transition_out(statustracker.$$.fragment, local);
			transition_out(if_block);
			current = false;
		},
		d(detaching) {
			if (detaching) {
				detach(t);
				detach(if_block_anchor);
			}

			destroy_component(statustracker, detaching);
			if_blocks[current_block_type_index].d(detaching);
		}
	};
}

function create_fragment(ctx) {
	let block;
	let current;

	block = new Block({
			props: {
				visible: /*visible*/ ctx[3],
				variant: /*value*/ ctx[0] === null ? "dashed" : "solid",
				border_mode: /*dragging*/ ctx[18] ? "focus" : "base",
				padding: false,
				elem_id: /*elem_id*/ ctx[1],
				elem_classes: /*elem_classes*/ ctx[2],
				container: /*container*/ ctx[11],
				scale: /*scale*/ ctx[12],
				min_width: /*min_width*/ ctx[13],
				allow_overflow: false,
				$$slots: { default: [create_default_slot] },
				$$scope: { ctx }
			}
		});

	return {
		c() {
			create_component(block.$$.fragment);
		},
		m(target, anchor) {
			mount_component(block, target, anchor);
			current = true;
		},
		p(ctx, [dirty]) {
			const block_changes = {};
			if (dirty & /*visible*/ 8) block_changes.visible = /*visible*/ ctx[3];
			if (dirty & /*value*/ 1) block_changes.variant = /*value*/ ctx[0] === null ? "dashed" : "solid";
			if (dirty & /*dragging*/ 262144) block_changes.border_mode = /*dragging*/ ctx[18] ? "focus" : "base";
			if (dirty & /*elem_id*/ 2) block_changes.elem_id = /*elem_id*/ ctx[1];
			if (dirty & /*elem_classes*/ 4) block_changes.elem_classes = /*elem_classes*/ ctx[2];
			if (dirty & /*container*/ 2048) block_changes.container = /*container*/ ctx[11];
			if (dirty & /*scale*/ 4096) block_changes.scale = /*scale*/ ctx[12];
			if (dirty & /*min_width*/ 8192) block_changes.min_width = /*min_width*/ ctx[13];

			if (dirty & /*$$scope, _selectable, _value, label, show_label, height, gradio, interactive, file_count, file_types, root, value, dragging, loading_status*/ 134727665) {
				block_changes.$$scope = { dirty, ctx };
			}

			block.$set(block_changes);
		},
		i(local) {
			if (current) return;
			transition_in(block.$$.fragment, local);
			current = true;
		},
		o(local) {
			transition_out(block.$$.fragment, local);
			current = false;
		},
		d(detaching) {
			destroy_component(block, detaching);
		}
	};
}

function instance($$self, $$props, $$invalidate) {
	let _value;
	let { elem_id = "" } = $$props;
	let { elem_classes = [] } = $$props;
	let { visible = true } = $$props;
	let { value } = $$props;
	let { interactive } = $$props;
	let { root } = $$props;
	let { label } = $$props;
	let { show_label } = $$props;
	let { height = undefined } = $$props;
	let { proxy_url } = $$props;
	let { _selectable = false } = $$props;
	let { loading_status } = $$props;
	let { container = true } = $$props;
	let { scale = null } = $$props;
	let { min_width = undefined } = $$props;
	let { gradio } = $$props;
	let { file_count } = $$props;
	let { file_types = ["file"] } = $$props;
	let old_value = _value;
	let dragging = false;
	const select_handler = ({ detail }) => gradio.dispatch("select", detail);

	const change_handler = ({ detail }) => {
		$$invalidate(0, value = detail);
	};

	const drag_handler = ({ detail }) => $$invalidate(18, dragging = detail);
	const clear_handler = () => gradio.dispatch("clear");
	const select_handler_1 = ({ detail }) => gradio.dispatch("select", detail);
	const upload_handler = () => gradio.dispatch("upload");

	$$self.$$set = $$props => {
		if ('elem_id' in $$props) $$invalidate(1, elem_id = $$props.elem_id);
		if ('elem_classes' in $$props) $$invalidate(2, elem_classes = $$props.elem_classes);
		if ('visible' in $$props) $$invalidate(3, visible = $$props.visible);
		if ('value' in $$props) $$invalidate(0, value = $$props.value);
		if ('interactive' in $$props) $$invalidate(4, interactive = $$props.interactive);
		if ('root' in $$props) $$invalidate(5, root = $$props.root);
		if ('label' in $$props) $$invalidate(6, label = $$props.label);
		if ('show_label' in $$props) $$invalidate(7, show_label = $$props.show_label);
		if ('height' in $$props) $$invalidate(8, height = $$props.height);
		if ('proxy_url' in $$props) $$invalidate(19, proxy_url = $$props.proxy_url);
		if ('_selectable' in $$props) $$invalidate(9, _selectable = $$props._selectable);
		if ('loading_status' in $$props) $$invalidate(10, loading_status = $$props.loading_status);
		if ('container' in $$props) $$invalidate(11, container = $$props.container);
		if ('scale' in $$props) $$invalidate(12, scale = $$props.scale);
		if ('min_width' in $$props) $$invalidate(13, min_width = $$props.min_width);
		if ('gradio' in $$props) $$invalidate(14, gradio = $$props.gradio);
		if ('file_count' in $$props) $$invalidate(15, file_count = $$props.file_count);
		if ('file_types' in $$props) $$invalidate(16, file_types = $$props.file_types);
	};

	$$self.$$.update = () => {
		if ($$self.$$.dirty & /*value, root, proxy_url*/ 524321) {
			$$invalidate(17, _value = normalise_file(value, root, proxy_url));
		}

		if ($$self.$$.dirty & /*old_value, _value, gradio*/ 1196032) {
			if (JSON.stringify(old_value) !== JSON.stringify(_value)) {
				gradio.dispatch("change");
				$$invalidate(20, old_value = _value);
			}
		}
	};

	return [
		value,
		elem_id,
		elem_classes,
		visible,
		interactive,
		root,
		label,
		show_label,
		height,
		_selectable,
		loading_status,
		container,
		scale,
		min_width,
		gradio,
		file_count,
		file_types,
		_value,
		dragging,
		proxy_url,
		old_value,
		select_handler,
		change_handler,
		drag_handler,
		clear_handler,
		select_handler_1,
		upload_handler
	];
}

class Index extends SvelteComponent {
	constructor(options) {
		super();

		init(this, options, instance, create_fragment, safe_not_equal, {
			elem_id: 1,
			elem_classes: 2,
			visible: 3,
			value: 0,
			interactive: 4,
			root: 5,
			label: 6,
			show_label: 7,
			height: 8,
			proxy_url: 19,
			_selectable: 9,
			loading_status: 10,
			container: 11,
			scale: 12,
			min_width: 13,
			gradio: 14,
			file_count: 15,
			file_types: 16
		});
	}

	get elem_id() {
		return this.$$.ctx[1];
	}

	set elem_id(elem_id) {
		this.$$set({ elem_id });
		flush();
	}

	get elem_classes() {
		return this.$$.ctx[2];
	}

	set elem_classes(elem_classes) {
		this.$$set({ elem_classes });
		flush();
	}

	get visible() {
		return this.$$.ctx[3];
	}

	set visible(visible) {
		this.$$set({ visible });
		flush();
	}

	get value() {
		return this.$$.ctx[0];
	}

	set value(value) {
		this.$$set({ value });
		flush();
	}

	get interactive() {
		return this.$$.ctx[4];
	}

	set interactive(interactive) {
		this.$$set({ interactive });
		flush();
	}

	get root() {
		return this.$$.ctx[5];
	}

	set root(root) {
		this.$$set({ root });
		flush();
	}

	get label() {
		return this.$$.ctx[6];
	}

	set label(label) {
		this.$$set({ label });
		flush();
	}

	get show_label() {
		return this.$$.ctx[7];
	}

	set show_label(show_label) {
		this.$$set({ show_label });
		flush();
	}

	get height() {
		return this.$$.ctx[8];
	}

	set height(height) {
		this.$$set({ height });
		flush();
	}

	get proxy_url() {
		return this.$$.ctx[19];
	}

	set proxy_url(proxy_url) {
		this.$$set({ proxy_url });
		flush();
	}

	get _selectable() {
		return this.$$.ctx[9];
	}

	set _selectable(_selectable) {
		this.$$set({ _selectable });
		flush();
	}

	get loading_status() {
		return this.$$.ctx[10];
	}

	set loading_status(loading_status) {
		this.$$set({ loading_status });
		flush();
	}

	get container() {
		return this.$$.ctx[11];
	}

	set container(container) {
		this.$$set({ container });
		flush();
	}

	get scale() {
		return this.$$.ctx[12];
	}

	set scale(scale) {
		this.$$set({ scale });
		flush();
	}

	get min_width() {
		return this.$$.ctx[13];
	}

	set min_width(min_width) {
		this.$$set({ min_width });
		flush();
	}

	get gradio() {
		return this.$$.ctx[14];
	}

	set gradio(gradio) {
		this.$$set({ gradio });
		flush();
	}

	get file_count() {
		return this.$$.ctx[15];
	}

	set file_count(file_count) {
		this.$$set({ file_count });
		flush();
	}

	get file_types() {
		return this.$$.ctx[16];
	}

	set file_types(file_types) {
		this.$$set({ file_types });
		flush();
	}
}

export { File as BaseFile, FileUpload$1 as BaseFileUpload, FilePreview$1 as FilePreview, Index as default };
//# sourceMappingURL=Index-17f629f9.js.map
