Spaces:
Runtime error
Runtime error
OpenHathi-SI-v0.1
/
env
/Lib
/site-packages
/gradio
/templates
/frontend
/assets
/Example-7d6bb9b6.js
import { d as dsvFormat } from './dsv-a37bb3db.js'; | |
var csv = dsvFormat(","); | |
var csvParseRows = csv.parseRows; | |
var tsv = dsvFormat("\t"); | |
var tsvParseRows = tsv.parseRows; | |
const Example_svelte_svelte_type_style_lang = ''; | |
/* home/runner/work/gradio/gradio/js/dataframe/Example.svelte generated by Svelte v4.2.2 */ | |
const { | |
SvelteComponent, | |
append, | |
attr, | |
destroy_each, | |
detach, | |
element, | |
empty, | |
ensure_array_like, | |
init, | |
insert, | |
listen, | |
noop, | |
run_all, | |
safe_not_equal, | |
set_data, | |
space, | |
text, | |
toggle_class | |
} = window.__gradio__svelte__internal; | |
function get_each_context(ctx, list, i) { | |
const child_ctx = ctx.slice(); | |
child_ctx[11] = list[i]; | |
child_ctx[13] = i; | |
return child_ctx; | |
} | |
function get_each_context_1(ctx, list, i) { | |
const child_ctx = ctx.slice(); | |
child_ctx[14] = list[i]; | |
child_ctx[16] = i; | |
return child_ctx; | |
} | |
// (48:0) {#if loaded} | |
function create_if_block(ctx) { | |
let div; | |
let mounted; | |
let dispose; | |
function select_block_type(ctx, dirty) { | |
if (typeof /*loaded_value*/ ctx[6] === "string") return create_if_block_1; | |
return create_else_block; | |
} | |
let current_block_type = select_block_type(ctx); | |
let if_block = current_block_type(ctx); | |
return { | |
c() { | |
div = element("div"); | |
if_block.c(); | |
attr(div, "class", "svelte-1cib1xd"); | |
toggle_class(div, "table", /*type*/ ctx[1] === "table"); | |
toggle_class(div, "gallery", /*type*/ ctx[1] === "gallery"); | |
toggle_class(div, "selected", /*selected*/ ctx[2]); | |
}, | |
m(target, anchor) { | |
insert(target, div, anchor); | |
if_block.m(div, null); | |
if (!mounted) { | |
dispose = [ | |
listen(div, "mouseenter", /*mouseenter_handler*/ ctx[9]), | |
listen(div, "mouseleave", /*mouseleave_handler*/ ctx[10]) | |
]; | |
mounted = true; | |
} | |
}, | |
p(ctx, dirty) { | |
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(div, null); | |
} | |
} | |
if (dirty & /*type*/ 2) { | |
toggle_class(div, "table", /*type*/ ctx[1] === "table"); | |
} | |
if (dirty & /*type*/ 2) { | |
toggle_class(div, "gallery", /*type*/ ctx[1] === "gallery"); | |
} | |
if (dirty & /*selected*/ 4) { | |
toggle_class(div, "selected", /*selected*/ ctx[2]); | |
} | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(div); | |
} | |
if_block.d(); | |
mounted = false; | |
run_all(dispose); | |
} | |
}; | |
} | |
// (60:2) {:else} | |
function create_else_block(ctx) { | |
let table; | |
let t; | |
let each_value = ensure_array_like(/*loaded_value*/ ctx[6].slice(0, 3)); | |
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)); | |
} | |
let if_block = /*value*/ ctx[0].length > 3 && create_if_block_2(ctx); | |
return { | |
c() { | |
table = element("table"); | |
for (let i = 0; i < each_blocks.length; i += 1) { | |
each_blocks[i].c(); | |
} | |
t = space(); | |
if (if_block) if_block.c(); | |
attr(table, "class", " svelte-1cib1xd"); | |
}, | |
m(target, anchor) { | |
insert(target, table, anchor); | |
for (let i = 0; i < each_blocks.length; i += 1) { | |
if (each_blocks[i]) { | |
each_blocks[i].m(table, null); | |
} | |
} | |
append(table, t); | |
if (if_block) if_block.m(table, null); | |
}, | |
p(ctx, dirty) { | |
if (dirty & /*loaded_value*/ 64) { | |
each_value = ensure_array_like(/*loaded_value*/ ctx[6].slice(0, 3)); | |
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(table, t); | |
} | |
} | |
for (; i < each_blocks.length; i += 1) { | |
each_blocks[i].d(1); | |
} | |
each_blocks.length = each_value.length; | |
} | |
if (/*value*/ ctx[0].length > 3) { | |
if (if_block) { | |
if_block.p(ctx, dirty); | |
} else { | |
if_block = create_if_block_2(ctx); | |
if_block.c(); | |
if_block.m(table, null); | |
} | |
} else if (if_block) { | |
if_block.d(1); | |
if_block = null; | |
} | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(table); | |
} | |
destroy_each(each_blocks, detaching); | |
if (if_block) if_block.d(); | |
} | |
}; | |
} | |
// (58:2) {#if typeof loaded_value === "string"} | |
function create_if_block_1(ctx) { | |
let t; | |
return { | |
c() { | |
t = text(/*loaded_value*/ ctx[6]); | |
}, | |
m(target, anchor) { | |
insert(target, t, anchor); | |
}, | |
p(ctx, dirty) { | |
if (dirty & /*loaded_value*/ 64) set_data(t, /*loaded_value*/ ctx[6]); | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(t); | |
} | |
} | |
}; | |
} | |
// (64:6) {#each row.slice(0, 3) as cell, j} | |
function create_each_block_1(ctx) { | |
let td; | |
let t_value = /*cell*/ ctx[14] + ""; | |
let t; | |
return { | |
c() { | |
td = element("td"); | |
t = text(t_value); | |
attr(td, "class", "svelte-1cib1xd"); | |
}, | |
m(target, anchor) { | |
insert(target, td, anchor); | |
append(td, t); | |
}, | |
p(ctx, dirty) { | |
if (dirty & /*loaded_value*/ 64 && t_value !== (t_value = /*cell*/ ctx[14] + "")) set_data(t, t_value); | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(td); | |
} | |
} | |
}; | |
} | |
// (67:6) {#if row.length > 3} | |
function create_if_block_3(ctx) { | |
let td; | |
return { | |
c() { | |
td = element("td"); | |
td.textContent = "…"; | |
attr(td, "class", "svelte-1cib1xd"); | |
}, | |
m(target, anchor) { | |
insert(target, td, anchor); | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(td); | |
} | |
} | |
}; | |
} | |
// (62:4) {#each loaded_value.slice(0, 3) as row, i} | |
function create_each_block(ctx) { | |
let tr; | |
let t; | |
let each_value_1 = ensure_array_like(/*row*/ ctx[11].slice(0, 3)); | |
let each_blocks = []; | |
for (let i = 0; i < each_value_1.length; i += 1) { | |
each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); | |
} | |
let if_block = /*row*/ ctx[11].length > 3 && create_if_block_3(); | |
return { | |
c() { | |
tr = element("tr"); | |
for (let i = 0; i < each_blocks.length; i += 1) { | |
each_blocks[i].c(); | |
} | |
t = space(); | |
if (if_block) if_block.c(); | |
}, | |
m(target, anchor) { | |
insert(target, tr, anchor); | |
for (let i = 0; i < each_blocks.length; i += 1) { | |
if (each_blocks[i]) { | |
each_blocks[i].m(tr, null); | |
} | |
} | |
append(tr, t); | |
if (if_block) if_block.m(tr, null); | |
}, | |
p(ctx, dirty) { | |
if (dirty & /*loaded_value*/ 64) { | |
each_value_1 = ensure_array_like(/*row*/ ctx[11].slice(0, 3)); | |
let i; | |
for (i = 0; i < each_value_1.length; i += 1) { | |
const child_ctx = get_each_context_1(ctx, each_value_1, i); | |
if (each_blocks[i]) { | |
each_blocks[i].p(child_ctx, dirty); | |
} else { | |
each_blocks[i] = create_each_block_1(child_ctx); | |
each_blocks[i].c(); | |
each_blocks[i].m(tr, t); | |
} | |
} | |
for (; i < each_blocks.length; i += 1) { | |
each_blocks[i].d(1); | |
} | |
each_blocks.length = each_value_1.length; | |
} | |
if (/*row*/ ctx[11].length > 3) { | |
if (if_block) ; else { | |
if_block = create_if_block_3(); | |
if_block.c(); | |
if_block.m(tr, null); | |
} | |
} else if (if_block) { | |
if_block.d(1); | |
if_block = null; | |
} | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(tr); | |
} | |
destroy_each(each_blocks, detaching); | |
if (if_block) if_block.d(); | |
} | |
}; | |
} | |
// (72:4) {#if value.length > 3} | |
function create_if_block_2(ctx) { | |
let div; | |
return { | |
c() { | |
div = element("div"); | |
attr(div, "class", "overlay svelte-1cib1xd"); | |
toggle_class(div, "odd", /*index*/ ctx[3] % 2 != 0); | |
toggle_class(div, "even", /*index*/ ctx[3] % 2 == 0); | |
toggle_class(div, "button", /*type*/ ctx[1] === "gallery"); | |
}, | |
m(target, anchor) { | |
insert(target, div, anchor); | |
}, | |
p(ctx, dirty) { | |
if (dirty & /*index*/ 8) { | |
toggle_class(div, "odd", /*index*/ ctx[3] % 2 != 0); | |
} | |
if (dirty & /*index*/ 8) { | |
toggle_class(div, "even", /*index*/ ctx[3] % 2 == 0); | |
} | |
if (dirty & /*type*/ 2) { | |
toggle_class(div, "button", /*type*/ ctx[1] === "gallery"); | |
} | |
}, | |
d(detaching) { | |
if (detaching) { | |
detach(div); | |
} | |
} | |
}; | |
} | |
function create_fragment(ctx) { | |
let if_block_anchor; | |
let if_block = /*loaded*/ ctx[4] && create_if_block(ctx); | |
return { | |
c() { | |
if (if_block) if_block.c(); | |
if_block_anchor = empty(); | |
}, | |
m(target, anchor) { | |
if (if_block) if_block.m(target, anchor); | |
insert(target, if_block_anchor, anchor); | |
}, | |
p(ctx, [dirty]) { | |
if (/*loaded*/ ctx[4]) { | |
if (if_block) { | |
if_block.p(ctx, dirty); | |
} else { | |
if_block = create_if_block(ctx); | |
if_block.c(); | |
if_block.m(if_block_anchor.parentNode, if_block_anchor); | |
} | |
} else if (if_block) { | |
if_block.d(1); | |
if_block = null; | |
} | |
}, | |
i: noop, | |
o: noop, | |
d(detaching) { | |
if (detaching) { | |
detach(if_block_anchor); | |
} | |
if (if_block) if_block.d(detaching); | |
} | |
}; | |
} | |
function instance($$self, $$props, $$invalidate) { | |
let { gradio } = $$props; | |
let { value } = $$props; | |
let { samples_dir } = $$props; | |
let { type } = $$props; | |
let { selected = false } = $$props; | |
let { index } = $$props; | |
let hovered = false; | |
let loaded_value = value; | |
let loaded = Array.isArray(loaded_value); | |
const mouseenter_handler = () => $$invalidate(5, hovered = true); | |
const mouseleave_handler = () => $$invalidate(5, hovered = false); | |
$$self.$$set = $$props => { | |
if ('gradio' in $$props) $$invalidate(7, gradio = $$props.gradio); | |
if ('value' in $$props) $$invalidate(0, value = $$props.value); | |
if ('samples_dir' in $$props) $$invalidate(8, samples_dir = $$props.samples_dir); | |
if ('type' in $$props) $$invalidate(1, type = $$props.type); | |
if ('selected' in $$props) $$invalidate(2, selected = $$props.selected); | |
if ('index' in $$props) $$invalidate(3, index = $$props.index); | |
}; | |
$$self.$$.update = () => { | |
if ($$self.$$.dirty & /*loaded, value, samples_dir, gradio*/ 401) { | |
if (!loaded && typeof value === "string" && (/\.[a-zA-Z]+$/).test(value)) { | |
fetch(samples_dir + value).then(v => v.text()).then(v => { | |
try { | |
if (value.endsWith("csv")) { | |
const small_df = v.split("\n").slice(0, 4).map(v => v.split(",").slice(0, 4).join(",")).join("\n"); | |
$$invalidate(6, loaded_value = csvParseRows(small_df)); | |
} else if (value.endsWith("tsv")) { | |
const small_df = v.split("\n").slice(0, 4).map(v => v.split("\t").slice(0, 4).join("\t")).join("\n"); | |
$$invalidate(6, loaded_value = tsvParseRows(small_df)); | |
} else { | |
throw new Error(gradio.i18n("dataframe.incorrect_format")); | |
} | |
$$invalidate(4, loaded = true); | |
} catch(e) { | |
console.error(e); | |
} | |
}).catch(e => { | |
$$invalidate(6, loaded_value = value); | |
$$invalidate(4, loaded = true); | |
}); | |
} | |
} | |
}; | |
return [ | |
value, | |
type, | |
selected, | |
index, | |
loaded, | |
hovered, | |
loaded_value, | |
gradio, | |
samples_dir, | |
mouseenter_handler, | |
mouseleave_handler | |
]; | |
} | |
class Example extends SvelteComponent { | |
constructor(options) { | |
super(); | |
init(this, options, instance, create_fragment, safe_not_equal, { | |
gradio: 7, | |
value: 0, | |
samples_dir: 8, | |
type: 1, | |
selected: 2, | |
index: 3 | |
}); | |
} | |
} | |
export { Example as default }; | |
//# sourceMappingURL=Example-7d6bb9b6.js.map | |