PageSourceSearch

https://drexyhhhh-danbooru-tags-transformer-v2-with-wd-tagger.hf.space/assets/Index-CUPNJP3k.js

js drexyhhhh-danbooru-tags-transformer-v2-with-wd-tagger.hf.space collected 2026-10-03 16:51:33 UTC 6,971 bytes, 300 lines download raw bytes

1import { p as prop, d as bind_this, i as if_block, a as set_attribute, r as rest_props } from './i18n-dpAHICcw.js';
2import { R as push, S as first_child, a as append, t as template_effect, T as pop, X as sibling, W as from_html, av as prepare_files, N as tick, ak as delegate, a6 as comment, w as get, a5 as user_derived, v as proxy, y as user_effect, a7 as text, a0 as set_text, a8 as next } from './index-CDZuCcOm.js';
3import { G as Gradio } from './utils.svelte-CyWLYi-B.js';
4import { s as snippet } from './snippet-DVkMfmSq.js';
5import { B as Button } from './Button-DxE-syeF.js';
6import './clone-dZfS06Ds.js';
7import './Image-CJziNDBt.js';
8import './misc-C2MjMwBX.js';
9/* empty css                                             */
10import './ScrollFade.svelte_svelte_type_style_lang-DUvCSfRk.js';
11import './MarkdownCode.svelte_svelte_type_style_lang-GeNUGzep.js';
12import './prism-python-C_fanlsZ.js';
13/* empty css                                                    */
14
15var root_3 = from_html(`<img class="button-icon svelte-94gmgt"/>`);
16var root_2 = from_html(`<!> <!>`, 1);
17var root_1 = from_html(`<input class="hide svelte-94gmgt" type="file"/> <!>`, 1);
18
19function UploadButton($$anchor, $$props) {
20	push($$props, true);
21
22	let elem_id = prop($$props, 'elem_id', 3, ""),
23		elem_classes = prop($$props, 'elem_classes', 19, () => []),
24		visible = prop($$props, 'visible', 3, true),
25		file_types = prop($$props, 'file_types', 19, () => []),
26		size = prop($$props, 'size', 3, "lg"),
27		icon = prop($$props, 'icon', 3, null),
28		scale = prop($$props, 'scale', 3, null),
29		min_width = prop($$props, 'min_width', 3, undefined),
30		variant = prop($$props, 'variant', 3, "secondary"),
31		disabled = prop($$props, 'disabled', 3, false),
32		max_file_size = prop($$props, 'max_file_size', 3, null);
33
34	let hidden_upload;
35
36	let accept_file_types = user_derived(() => {
37		if (file_types() == null) {
38			return null;
39		}
40
41		const mapped = file_types().map((x) => {
42			if (x.startsWith(".")) {
43				return x;
44			}
45
46			return x + "/*";
47		});
48
49		return mapped.join(", ");
50	});
51
52	function open_file_upload() {
53		$$props.onclick?.();
54		hidden_upload.click();
55	}
56
57	async function load_files(files) {
58		let _files = Array.from(files);
59
60		if (!files.length) {
61			return;
62		}
63
64		if ($$props.file_count === "single") {
65			_files = [files[0]];
66		}
67
68		let all_file_data = await prepare_files(_files);
69
70		await tick();
71
72		try {
73			all_file_data = (await $$props.upload(all_file_data, $$props.root, undefined, max_file_size() ?? Infinity))?.filter((x) => x !== null);
74		} catch(e) {
75			$$props.onerror?.(e.message);
76
77			return;
78		}
79
80		const new_value = $$props.file_count === "single" ? all_file_data?.[0] : all_file_data;
81
82		$$props.onchange?.(new_value);
83		$$props.onupload?.(new_value);
84	}
85
86	async function load_files_from_upload(e) {
87		const target = e.target;
88
89		if (!target.files) return;
90
91		await load_files(target.files);
92	}
93
94	function clear_input_value(e) {
95		const target = e.target;
96
97		if (target.value) target.value = "";
98	}
99
100	var fragment = root_1();
101	var input = first_child(fragment);
102
103	input.__change = load_files_from_upload;
104	input.__click = clear_input_value;
105	bind_this(input, ($$value) => hidden_upload = $$value, () => hidden_upload);
106
107	var node = sibling(input, 2);
108
109	Button(node, {
110		get size() {
111			return size();
112		},
113
114		get variant() {
115			return variant();
116		},
117
118		get elem_id() {
119			return elem_id();
120		},
121
122		get elem_classes() {
123			return elem_classes();
124		},
125
126		get visible() {
127			return visible();
128		},
129		onclick: open_file_upload,
130		get scale() {
131			return scale();
132		},
133
134		get min_width() {
135			return min_width();
136		},
137
138		get disabled() {
139			return disabled();
140		},
141
142		children: ($$anchor, $$slotProps) => {
143			var fragment_1 = root_2();
144			var node_1 = first_child(fragment_1);
145
146			{
147				var consequent = ($$anchor) => {
148					var img = root_3();
149
150					template_effect(() => {
151						set_attribute(img, 'src', icon().url);
152						set_attribute(img, 'alt', `${$$props.value} icon`);
153					});
154
155					append($$anchor, img);
156				};
157
158				if_block(node_1, ($$render) => {
159					if (icon()) $$render(consequent);
160				});
161			}
162
163			var node_2 = sibling(node_1, 2);
164
165			{
166				var consequent_1 = ($$anchor) => {
167					var fragment_2 = comment();
168					var node_3 = first_child(fragment_2);
169
170					snippet(node_3, () => $$props.children);
171					append($$anchor, fragment_2);
172				};
173
174				if_block(node_2, ($$render) => {
175					if ($$props.children) $$render(consequent_1);
176				});
177			}
178
179			append($$anchor, fragment_1);
180		},
181		$$slots: { default: true }
182	});
183
184	template_effect(() => {
185		set_attribute(input, 'accept', get(accept_file_types));
186		input.multiple = $$props.file_count === "multiple" || undefined;
187		input.webkitdirectory = $$props.file_count === "directory" || undefined;
188		set_attribute(input, 'mozdirectory', $$props.file_count === "directory" || undefined);
189		set_attribute(input, 'data-testid', `${$$props.label ?? ''}-upload-button`);
190	});
191
192	append($$anchor, fragment);
193	pop();
194}
195
196delegate(['change', 'click']);
197
198function Index($$anchor, $$props) {
199	push($$props, true);
200
201	const props = rest_props($$props, ['$$slots', '$$events', '$$legacy']);
202	const gradio = new Gradio(props);
203	let value = proxy(gradio.props.value);
204
205	user_effect(() => {
206		if (value !== gradio.props.value) {
207			gradio.props.value = value;
208		}
209	});
210
211	async function handle_event(detail, event) {
212		gradio.props.value = detail;
213		gradio.dispatch(event);
214	}
215
216	const disabled = user_derived(() => !gradio.shared.interactive);
217
218	UploadButton($$anchor, {
219		get elem_id() {
220			return gradio.shared.elem_id;
221		},
222
223		get elem_classes() {
224			return gradio.shared.elem_classes;
225		},
226
227		get visible() {
228			return gradio.shared.visible;
229		},
230
231		get file_count() {
232			return gradio.props.file_count;
233		},
234
235		get file_types() {
236			return gradio.props.file_types;
237		},
238
239		get size() {
240			return gradio.props.size;
241		},
242
243		get scale() {
244			return gradio.shared.scale;
245		},
246
247		get icon() {
248			return gradio.props.icon;
249		},
250
251		get min_width() {
252			return gradio.shared.min_width;
253		},
254
255		get root() {
256			return gradio.shared.root;
257		},
258
259		get value() {
260			return value;
261		},
262
263		get disabled() {
264			return get(disabled);
265		},
266
267		get variant() {
268			return gradio.props.variant;
269		},
270
271		get label() {
272			return gradio.shared.label;
273		},
274
275		get max_file_size() {
276			return gradio.shared.max_file_size;
277		},
278		onclick: () => gradio.dispatch("click"),
279		onchange: (detail) => handle_event(detail, "change"),
280		onupload: (detail) => handle_event(detail, "upload"),
281		onerror: (detail) => {
282			gradio.dispatch("error", detail);
283		},
284		upload: (...args) => gradio.shared.client.upload(...args),
285		children: ($$anchor, $$slotProps) => {
286			next();
287
288			var text$1 = text();
289
290			template_effect(() => set_text(text$1, gradio.shared.label ?? ""));
291			append($$anchor, text$1);
292		},
293		$$slots: { default: true }
294	});
295
296	pop();
297}
298
299export { UploadButton as BaseUploadButton, Index as default };
300//# sourceMappingURL=Index-CUPNJP3k.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.