function create_default_slot$1(ctx) {
let code;
let current_block_type_index;
let if_block;
let current;
const if_block_creators = [create_if_block$3, create_if_block_3$2];
const if_blocks = [];
function select_block_type_1(ctx, dirty) {
if (/*current_language*/ ctx[7] === "python") return 0;
if (/*current_language*/ ctx[7] === "javascript") return 1;
return -1;
}
if (~(current_block_type_index = select_block_type_1(ctx))) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
}
return {
c() {
code = element$2("code");
if (if_block) if_block.c();
attr$2(code, "class", "svelte-1d98qmk");
},
m(target, anchor) {
insert$3(target, code, anchor);
if (~current_block_type_index) {
if_blocks[current_block_type_index].m(code, null);
}
current = true;
},
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type_1(ctx);
if (current_block_type_index === previous_block_index) {
if (~current_block_type_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
}
} else {
if (if_block) {
group_outros$3();
transition_out$4(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros$3();
}
if (~current_block_type_index) {
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$4(if_block, 1);
if_block.m(code, null);
} else {
if_block = null;
}
}
},
i(local) {
if (current) return;
transition_in$4(if_block);
current = true;
},
o(local) {
transition_out$4(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach$3(code);
}
if (~current_block_type_index) {
if_blocks[current_block_type_index].d();
}
}
};
}
function create_fragment$4(ctx) {
let div;
let current_block_type_index;
let if_block;
let t;
let block;
let current;
const if_block_creators = [create_if_block_7, create_else_block_2];
const if_blocks = [];
function select_block_type(ctx, dirty) {
if (/*named*/ ctx[6]) 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);
block = new Block({
props: {
$$slots: { default: [create_default_slot$1] },
$$scope: { ctx }
}
});
return {
c() {
div = element$2("div");
if_block.c();
t = space$2();
create_component$4(block.$$.fragment);
attr$2(div, "class", "container svelte-1d98qmk");
},
m(target, anchor) {
insert$3(target, div, anchor);
if_blocks[current_block_type_index].m(div, null);
append$2(div, t);
mount_component$4(block, div, null);
current = true;
},
p(ctx, [dirty]) {
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$3();
transition_out$4(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros$3();
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$4(if_block, 1);
if_block.m(div, t);
}
const block_changes = {};
if (dirty & /*$$scope, python_code, dependency, endpoint_parameters, dependency_failures, dependency_index, root, current_language, js_code, js_parameters, named*/ 16778239) {
block_changes.$$scope = { dirty, ctx };
}
block.$set(block_changes);
},
i(local) {
if (current) return;
transition_in$4(if_block);
transition_in$4(block.$$.fragment, local);
current = true;
},
o(local) {
transition_out$4(if_block);
transition_out$4(block.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach$3(div);
}
if_blocks[current_block_type_index].d();
destroy_component$4(block);
}
};
}
function instance$4($$self, $$props, $$invalidate) {
let { dependency } = $$props;
let { dependency_index } = $$props;
let { root } = $$props;
let { dependency_failures } = $$props;
let { endpoint_parameters } = $$props;
let { js_parameters } = $$props;
let { named } = $$props;
let { current_language } = $$props;
let python_code;
let js_code;
let blob_components = ["Audio", "File", "Image", "Video"];
let blob_examples = endpoint_parameters.filter(param => blob_components.includes(param.component));
function div1_binding($$value) {
binding_callbacks$1[$$value ? 'unshift' : 'push'](() => {
python_code = $$value;
$$invalidate(8, python_code);
});
}
function div1_binding_1($$value) {
binding_callbacks$1[$$value ? 'unshift' : 'push'](() => {
js_code = $$value;
$$invalidate(9, js_code);
});
}
$$self.$$set = $$props => {
if ('dependency' in $$props) $$invalidate(0, dependency = $$props.dependency);
if ('dependency_index' in $$props) $$invalidate(1, dependency_index = $$props.dependency_index);
if ('root' in $$props) $$invalidate(2, root = $$props.root);
if ('dependency_failures' in $$props) $$invalidate(3, dependency_failures = $$props.dependency_failures);
if ('endpoint_parameters' in $$props) $$invalidate(4, endpoint_parameters = $$props.endpoint_parameters);
if ('js_parameters' in $$props) $$invalidate(5, js_parameters = $$props.js_parameters);
if ('named' in $$props) $$invalidate(6, named = $$props.named);
if ('current_language' in $$props) $$invalidate(7, current_language = $$props.current_language);
};
return [
dependency,
dependency_index,
root,
dependency_failures,
endpoint_parameters,
js_parameters,
named,
current_language,
python_code,
js_code,
blob_components,
blob_examples,
div1_binding,
div1_binding_1
];
}
class CodeSnippets extends SvelteComponent$4 {
constructor(options) {
super();
init$4(this, options, instance$4, create_fragment$4, safe_not_equal$4, {
dependency: 0,
dependency_index: 1,
root: 2,
dependency_failures: 3,
endpoint_parameters: 4,
js_parameters: 5,
named: 6,
current_language: 7
});
}
}
const python = ""+new URL('python-20e39c92.svg', import.meta.url).href+"";
const javascript = ""+new URL('javascript-850cf94b.svg', import.meta.url).href+"";
const ApiDocs_svelte_svelte_type_style_lang = '';
/* src/api_docs/ApiDocs.svelte generated by Svelte v4.2.2 */
const {
SvelteComponent: SvelteComponent$3,
append: append$1,
attr: attr$1,
bubble: bubble$1,
check_outros: check_outros$2,
create_component: create_component$3,
destroy_component: destroy_component$3,
destroy_each,
detach: detach$2,
element: element$1,
empty: empty$2,
ensure_array_like: ensure_array_like$1,
group_outros: group_outros$2,
init: init$3,
insert: insert$2,
listen: listen$1,
mount_component: mount_component$3,
safe_not_equal: safe_not_equal$3,
space: space$1,
src_url_equal: src_url_equal$1,
text: text$1,
transition_in: transition_in$3,
transition_out: transition_out$3
} = window.__gradio__svelte__internal;
const { onMount: onMount$2, createEventDispatcher: createEventDispatcher$2 } = window.__gradio__svelte__internal;
function get_each_context$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[18] = list[i];
child_ctx[20] = i;
return child_ctx;
}
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[21] = list[i][0];
child_ctx[22] = list[i][1];
return child_ctx;
}
// (103:0) {#if info}
function create_if_block$2(ctx) {
let show_if;
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block_1$1, create_else_block];
const if_blocks = [];
function select_block_type(ctx, dirty) {
if (dirty & /*dependencies*/ 2) show_if = null;
if (show_if == null) show_if = !!/*dependencies*/ ctx[1].filter(func).length;
if (show_if) return 0;
return 1;
}
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
if_block.c();
if_block_anchor = empty$2();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert$2(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros$2();
transition_out$3(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$3(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i(local) {
if (current) return;
transition_in$3(if_block);
current = true;
},
o(local) {
transition_out$3(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach$2(if_block_anchor);
}
if_blocks[current_block_type_index].d(detaching);
}
};
}
// (183:1) {:else}
function create_else_block(ctx) {
let noapi;
let current;
noapi = new NoApi({ props: { root: /*root*/ ctx[0] } });
noapi.$on("close", /*close_handler_1*/ ctx[12]);
return {
c() {
create_component$3(noapi.$$.fragment);
},
m(target, anchor) {
mount_component$3(noapi, target, anchor);
current = true;
},
p(ctx, dirty) {
const noapi_changes = {};
if (dirty & /*root*/ 1) noapi_changes.root = /*root*/ ctx[0];
noapi.$set(noapi_changes);
},
i(local) {
if (current) return;
transition_in$3(noapi.$$.fragment, local);
current = true;
},
o(local) {
transition_out$3(noapi.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component$3(noapi, detaching);
}
};
}
// (104:1) {#if dependencies.filter((dependency) => dependency.show_api).length}
function create_if_block_1$1(ctx) {
let div0;
let apibanner;
let t0;
let div4;
let div1;
let t6;
let div3;
let div2;
let t7;
let installsnippet;
let t8;
let show_if = Object.keys(/*info*/ ctx[5].named_endpoints).length;
let t9;
let current;
apibanner = new ApiBanner({
props: {
root: /*root*/ ctx[0],
api_count: /*dependencies*/ ctx[1].filter(func_1).length
}
});
apibanner.$on("close", /*close_handler*/ ctx[10]);
let each_value_1 = ensure_array_like$1(/*langs*/ ctx[7]);
let each_blocks_1 = [];
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks_1[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
}
installsnippet = new InstallSnippet({
props: {
current_language: /*current_language*/ ctx[2]
}
});
let if_block = show_if && create_if_block_3$1();
let each_value = ensure_array_like$1(/*dependencies*/ ctx[1]);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
}
const out = i => transition_out$3(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
return {
c() {
div0 = element$1("div");
create_component$3(apibanner.$$.fragment);
t0 = space$1();
div4 = element$1("div");
div1 = element$1("div");
div1.innerHTML = `Use the gradio_client
Python library or the
@gradio/client
Javascript package to query the demo via API.
`;
t6 = space$1();
div3 = element$1("div");
div2 = element$1("div");
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].c();
}
t7 = space$1();
create_component$3(installsnippet.$$.fragment);
t8 = space$1();
if (if_block) if_block.c();
t9 = space$1();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr$1(div0, "class", "banner-wrap svelte-bdjvpc");
attr$1(div1, "class", "client-doc svelte-bdjvpc");
attr$1(div2, "class", "snippets svelte-bdjvpc");
attr$1(div3, "class", "endpoint svelte-bdjvpc");
attr$1(div4, "class", "docs-wrap svelte-bdjvpc");
},
m(target, anchor) {
insert$2(target, div0, anchor);
mount_component$3(apibanner, div0, null);
insert$2(target, t0, anchor);
insert$2(target, div4, anchor);
append$1(div4, div1);
append$1(div4, t6);
append$1(div4, div3);
append$1(div3, div2);
for (let i = 0; i < each_blocks_1.length; i += 1) {
if (each_blocks_1[i]) {
each_blocks_1[i].m(div2, null);
}
}
append$1(div3, t7);
mount_component$3(installsnippet, div3, null);
append$1(div3, t8);
if (if_block) if_block.m(div3, null);
append$1(div3, t9);
for (let i = 0; i < each_blocks.length; i += 1) {
if (each_blocks[i]) {
each_blocks[i].m(div3, null);
}
}
current = true;
},
p(ctx, dirty) {
const apibanner_changes = {};
if (dirty & /*root*/ 1) apibanner_changes.root = /*root*/ ctx[0];
if (dirty & /*dependencies*/ 2) apibanner_changes.api_count = /*dependencies*/ ctx[1].filter(func_1).length;
apibanner.$set(apibanner_changes);
if (dirty & /*current_language, langs*/ 132) {
each_value_1 = ensure_array_like$1(/*langs*/ ctx[7]);
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_1[i]) {
each_blocks_1[i].p(child_ctx, dirty);
} else {
each_blocks_1[i] = create_each_block_1(child_ctx);
each_blocks_1[i].c();
each_blocks_1[i].m(div2, null);
}
}
for (; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].d(1);
}
each_blocks_1.length = each_value_1.length;
}
const installsnippet_changes = {};
if (dirty & /*current_language*/ 4) installsnippet_changes.current_language = /*current_language*/ ctx[2];
installsnippet.$set(installsnippet_changes);
if (dirty & /*info*/ 32) show_if = Object.keys(/*info*/ ctx[5].named_endpoints).length;
if (show_if) {
if (if_block) ; else {
if_block = create_if_block_3$1();
if_block.c();
if_block.m(div3, t9);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty & /*info, dependencies, js_info, is_running, current_language, root, dependency_failures*/ 127) {
each_value = ensure_array_like$1(/*dependencies*/ ctx[1]);
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$1(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in$3(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$1(child_ctx);
each_blocks[i].c();
transition_in$3(each_blocks[i], 1);
each_blocks[i].m(div3, null);
}
}
group_outros$2();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros$2();
}
},
i(local) {
if (current) return;
transition_in$3(apibanner.$$.fragment, local);
transition_in$3(installsnippet.$$.fragment, local);
for (let i = 0; i < each_value.length; i += 1) {
transition_in$3(each_blocks[i]);
}
current = true;
},
o(local) {
transition_out$3(apibanner.$$.fragment, local);
transition_out$3(installsnippet.$$.fragment, local);
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out$3(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching) {
detach$2(div0);
detach$2(t0);
detach$2(div4);
}
destroy_component$3(apibanner);
destroy_each(each_blocks_1, detaching);
destroy_component$3(installsnippet);
if (if_block) if_block.d();
destroy_each(each_blocks, detaching);
}
};
}
// (128:5) {#each langs as [language, img]}
function create_each_block_1(ctx) {
let li;
let img_1;
let img_1_src_value;
let t0;
let t1_value = /*language*/ ctx[21] + "";
let t1;
let t2;
let li_class_value;
let mounted;
let dispose;
function click_handler() {
return /*click_handler*/ ctx[11](/*language*/ ctx[21]);
}
return {
c() {
li = element$1("li");
img_1 = element$1("img");
t0 = space$1();
t1 = text$1(t1_value);
t2 = space$1();
if (!src_url_equal$1(img_1.src, img_1_src_value = /*img*/ ctx[22])) attr$1(img_1, "src", img_1_src_value);
attr$1(img_1, "alt", "");
attr$1(img_1, "class", "svelte-bdjvpc");
attr$1(li, "class", li_class_value = "snippet " + (/*current_language*/ ctx[2] === /*language*/ ctx[21]
? 'current-lang'
: 'inactive-lang') + " svelte-bdjvpc");
},
m(target, anchor) {
insert$2(target, li, anchor);
append$1(li, img_1);
append$1(li, t0);
append$1(li, t1);
append$1(li, t2);
if (!mounted) {
dispose = listen$1(li, "click", click_handler);
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty & /*current_language*/ 4 && li_class_value !== (li_class_value = "snippet " + (/*current_language*/ ctx[2] === /*language*/ ctx[21]
? 'current-lang'
: 'inactive-lang') + " svelte-bdjvpc")) {
attr$1(li, "class", li_class_value);
}
},
d(detaching) {
if (detaching) {
detach$2(li);
}
mounted = false;
dispose();
}
};
}
// (141:4) {#if Object.keys(info.named_endpoints).length}
function create_if_block_3$1(ctx) {
let h2;
return {
c() {
h2 = element$1("h2");
h2.textContent = "Endpoints";
attr$1(h2, "class", "header svelte-bdjvpc");
},
m(target, anchor) {
insert$2(target, h2, anchor);
},
d(detaching) {
if (detaching) {
detach$2(h2);
}
}
};
}
// (146:5) {#if dependency.show_api}
function create_if_block_2$1(ctx) {
let div;
let codesnippets;
let t0;
let responseobject;
let t1;
let current;
codesnippets = new CodeSnippets({
props: {
named: true,
endpoint_parameters: /*info*/ ctx[5].named_endpoints["/" + /*dependency*/ ctx[18].api_name].parameters,
js_parameters: /*js_info*/ ctx[6].named_endpoints["/" + /*dependency*/ ctx[18].api_name].parameters,
dependency: /*dependency*/ ctx[18],
dependency_index: /*dependency_index*/ ctx[20],
current_language: /*current_language*/ ctx[2],
root: /*root*/ ctx[0],
dependency_failures: /*dependency_failures*/ ctx[4]
}
});
responseobject = new ResponseObject({
props: {
endpoint_returns: /*info*/ ctx[5].named_endpoints["/" + /*dependency*/ ctx[18].api_name].returns,
js_returns: /*js_info*/ ctx[6].named_endpoints["/" + /*dependency*/ ctx[18].api_name].returns,
is_running: /*is_running*/ ctx[3],
current_language: /*current_language*/ ctx[2]
}
});
return {
c() {
div = element$1("div");
create_component$3(codesnippets.$$.fragment);
t0 = space$1();
create_component$3(responseobject.$$.fragment);
t1 = space$1();
attr$1(div, "class", "endpoint-container svelte-bdjvpc");
},
m(target, anchor) {
insert$2(target, div, anchor);
mount_component$3(codesnippets, div, null);
append$1(div, t0);
mount_component$3(responseobject, div, null);
append$1(div, t1);
current = true;
},
p(ctx, dirty) {
const codesnippets_changes = {};
if (dirty & /*info, dependencies*/ 34) codesnippets_changes.endpoint_parameters = /*info*/ ctx[5].named_endpoints["/" + /*dependency*/ ctx[18].api_name].parameters;
if (dirty & /*js_info, dependencies*/ 66) codesnippets_changes.js_parameters = /*js_info*/ ctx[6].named_endpoints["/" + /*dependency*/ ctx[18].api_name].parameters;
if (dirty & /*dependencies*/ 2) codesnippets_changes.dependency = /*dependency*/ ctx[18];
if (dirty & /*current_language*/ 4) codesnippets_changes.current_language = /*current_language*/ ctx[2];
if (dirty & /*root*/ 1) codesnippets_changes.root = /*root*/ ctx[0];
if (dirty & /*dependency_failures*/ 16) codesnippets_changes.dependency_failures = /*dependency_failures*/ ctx[4];
codesnippets.$set(codesnippets_changes);
const responseobject_changes = {};
if (dirty & /*info, dependencies*/ 34) responseobject_changes.endpoint_returns = /*info*/ ctx[5].named_endpoints["/" + /*dependency*/ ctx[18].api_name].returns;
if (dirty & /*js_info, dependencies*/ 66) responseobject_changes.js_returns = /*js_info*/ ctx[6].named_endpoints["/" + /*dependency*/ ctx[18].api_name].returns;
if (dirty & /*is_running*/ 8) responseobject_changes.is_running = /*is_running*/ ctx[3];
if (dirty & /*current_language*/ 4) responseobject_changes.current_language = /*current_language*/ ctx[2];
responseobject.$set(responseobject_changes);
},
i(local) {
if (current) return;
transition_in$3(codesnippets.$$.fragment, local);
transition_in$3(responseobject.$$.fragment, local);
current = true;
},
o(local) {
transition_out$3(codesnippets.$$.fragment, local);
transition_out$3(responseobject.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach$2(div);
}
destroy_component$3(codesnippets);
destroy_component$3(responseobject);
}
};
}
// (145:4) {#each dependencies as dependency, dependency_index}
function create_each_block$1(ctx) {
let if_block_anchor;
let current;
let if_block = /*dependency*/ ctx[18].show_api && create_if_block_2$1(ctx);
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty$2();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert$2(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
if (/*dependency*/ ctx[18].show_api) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*dependencies*/ 2) {
transition_in$3(if_block, 1);
}
} else {
if_block = create_if_block_2$1(ctx);
if_block.c();
transition_in$3(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros$2();
transition_out$3(if_block, 1, 1, () => {
if_block = null;
});
check_outros$2();
}
},
i(local) {
if (current) return;
transition_in$3(if_block);
current = true;
},
o(local) {
transition_out$3(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach$2(if_block_anchor);
}
if (if_block) if_block.d(detaching);
}
};
}
function create_fragment$3(ctx) {
let if_block_anchor;
let current;
let if_block = /*info*/ ctx[5] && create_if_block$2(ctx);
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty$2();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert$2(target, if_block_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (/*info*/ ctx[5]) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*info*/ 32) {
transition_in$3(if_block, 1);
}
} else {
if_block = create_if_block$2(ctx);
if_block.c();
transition_in$3(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros$2();
transition_out$3(if_block, 1, 1, () => {
if_block = null;
});
check_outros$2();
}
},
i(local) {
if (current) return;
transition_in$3(if_block);
current = true;
},
o(local) {
transition_out$3(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach$2(if_block_anchor);
}
if (if_block) if_block.d(detaching);
}
};
}
const func = dependency => dependency.show_api;
const func_1 = dependency => dependency.show_api;
function instance$3($$self, $$props, $$invalidate) {
let { instance_map } = $$props;
let { dependencies } = $$props;
let { root } = $$props;
let { app } = $$props;
if (root === "") {
root = location.protocol + "//" + location.host + location.pathname;
}
if (!root.endsWith("/")) {
root += "/";
}
let current_language = "python";
const langs = [["python", python], ["javascript", javascript]];
let is_running = false;
dependencies.map(dependency => dependency.inputs.map(_id => {
let default_data = instance_map[_id].documentation?.example_data;
if (default_data === undefined) {
default_data = "";
} else if (typeof default_data === "object") {
default_data = JSON.stringify(default_data);
}
return default_data;
}));
dependencies.map(dependency => new Array(dependency.outputs.length));
let dependency_failures = dependencies.map(dependency => new Array(dependency.inputs.length).fill(false));
async function get_info() {
let response = await fetch(root + "info");
let data = await response.json();
return data;
}
async function get_js_info() {
let js_api_info = await app.view_api();
return js_api_info;
}
let info;
let js_info;
get_info().then(data => {
$$invalidate(5, info = data);
});
get_js_info().then(js_api_info => {
$$invalidate(6, js_info = js_api_info);
});
onMount$2(() => {
document.body.style.overflow = "hidden";
if ("parentIFrame" in window) {
window.parentIFrame?.scrollTo(0, 0);
}
return () => {
document.body.style.overflow = "auto";
};
});
function close_handler(event) {
bubble$1.call(this, $$self, event);
}
const click_handler = language => $$invalidate(2, current_language = language);
function close_handler_1(event) {
bubble$1.call(this, $$self, event);
}
$$self.$$set = $$props => {
if ('instance_map' in $$props) $$invalidate(8, instance_map = $$props.instance_map);
if ('dependencies' in $$props) $$invalidate(1, dependencies = $$props.dependencies);
if ('root' in $$props) $$invalidate(0, root = $$props.root);
if ('app' in $$props) $$invalidate(9, app = $$props.app);
};
return [
root,
dependencies,
current_language,
is_running,
dependency_failures,
info,
js_info,
langs,
instance_map,
app,
close_handler,
click_handler,
close_handler_1
];
}
class ApiDocs extends SvelteComponent$3 {
constructor(options) {
super();
init$3(this, options, instance$3, create_fragment$3, safe_not_equal$3, {
instance_map: 8,
dependencies: 1,
root: 0,
app: 9
});
}
}
get_store_value($format);
class Gradio {
#id;
#el;
constructor(id, el, theme, version, root, autoscroll) {
this.#id = id;
this.theme = theme;
this.version = version;
this.#el = el;
this.i18n = get_store_value($format);
this.root = root;
this.autoscroll = autoscroll;
}
dispatch(event_name, data) {
const e = new CustomEvent("gradio", {
bubbles: true,
detail: { data, id: this.#id, event: event_name }
});
this.#el.dispatchEvent(e);
}
}
/* src/Render.svelte generated by Svelte v4.2.2 */
const {
SvelteComponent: SvelteComponent$2,
add_flush_callback,
assign,
bind,
binding_callbacks,
bubble,
check_outros: check_outros$1,
construct_svelte_component,
create_component: create_component$2,
destroy_component: destroy_component$2,
detach: detach$1,
empty: empty$1,
ensure_array_like,
get_spread_object,
get_spread_update,
group_outros: group_outros$1,
init: init$2,
insert: insert$1,
mount_component: mount_component$2,
outro_and_destroy_block,
safe_not_equal: safe_not_equal$2,
transition_in: transition_in$2,
transition_out: transition_out$2,
update_keyed_each
} = window.__gradio__svelte__internal;const { onMount: onMount$1, createEventDispatcher: createEventDispatcher$1, setContext } = window.__gradio__svelte__internal;
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i].component;
child_ctx[19] = list[i].id;
child_ctx[2] = list[i].props;
child_ctx[20] = list[i].children;
child_ctx[21] = list[i].has_modes;
return child_ctx;
}
// (69:1) {#if children && children.length}
function create_if_block$1(ctx) {
let each_blocks = [];
let each_1_lookup = new Map();
let each_1_anchor;
let current;
let each_value = ensure_array_like(/*children*/ ctx[1]);
const get_key = ctx => /*each_id*/ ctx[19];
for (let i = 0; i < each_value.length; i += 1) {
let child_ctx = get_each_context(ctx, each_value, i);
let key = get_key(child_ctx);
each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
}
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty$1();
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
if (each_blocks[i]) {
each_blocks[i].m(target, anchor);
}
}
insert$1(target, each_1_anchor, anchor);
current = true;
},
p(ctx, dirty) {
if (dirty & /*children, target, root, instance_map, dynamic_ids, theme_mode*/ 235) {
each_value = ensure_array_like(/*children*/ ctx[1]);
group_outros$1();
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, outro_and_destroy_block, create_each_block, each_1_anchor, get_each_context);
check_outros$1();
}
},
i(local) {
if (current) return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in$2(each_blocks[i]);
}
current = true;
},
o(local) {
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out$2(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching) {
detach$1(each_1_anchor);
}
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].d(detaching);
}
}
};
}
// (70:2) {#each children as { component, id: each_id, props, children: _children, has_modes }
function create_each_block(key_1, ctx) {
let first;
let render;
let current;
render = new Render({
props: {
component: /*component*/ ctx[10],
target: /*target*/ ctx[6],
id: /*each_id*/ ctx[19],
props: /*props*/ ctx[2],
root: /*root*/ ctx[3],
instance_map: /*instance_map*/ ctx[0],
children: /*_children*/ ctx[20],
dynamic_ids: /*dynamic_ids*/ ctx[5],
has_modes: /*has_modes*/ ctx[21],
theme_mode: /*theme_mode*/ ctx[7]
}
});
render.$on("destroy", /*destroy_handler*/ ctx[13]);
render.$on("mount", /*mount_handler*/ ctx[14]);
return {
key: key_1,
first: null,
c() {
first = empty$1();
create_component$2(render.$$.fragment);
this.first = first;
},
m(target, anchor) {
insert$1(target, first, anchor);
mount_component$2(render, target, anchor);
current = true;
},
p(new_ctx, dirty) {
ctx = new_ctx;
const render_changes = {};
if (dirty & /*children*/ 2) render_changes.component = /*component*/ ctx[10];
if (dirty & /*target*/ 64) render_changes.target = /*target*/ ctx[6];
if (dirty & /*children*/ 2) render_changes.id = /*each_id*/ ctx[19];
if (dirty & /*children*/ 2) render_changes.props = /*props*/ ctx[2];
if (dirty & /*root*/ 8) render_changes.root = /*root*/ ctx[3];
if (dirty & /*instance_map*/ 1) render_changes.instance_map = /*instance_map*/ ctx[0];
if (dirty & /*children*/ 2) render_changes.children = /*_children*/ ctx[20];
if (dirty & /*dynamic_ids*/ 32) render_changes.dynamic_ids = /*dynamic_ids*/ ctx[5];
if (dirty & /*children*/ 2) render_changes.has_modes = /*has_modes*/ ctx[21];
if (dirty & /*theme_mode*/ 128) render_changes.theme_mode = /*theme_mode*/ ctx[7];
render.$set(render_changes);
},
i(local) {
if (current) return;
transition_in$2(render.$$.fragment, local);
current = true;
},
o(local) {
transition_out$2(render.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach$1(first);
}
destroy_component$2(render, detaching);
}
};
}
// (56:0)
function create_default_slot(ctx) {
let if_block_anchor;
let current;
let if_block = /*children*/ ctx[1] && /*children*/ ctx[1].length && create_if_block$1(ctx);
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty$1();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert$1(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
if (/*children*/ ctx[1] && /*children*/ ctx[1].length) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*children*/ 2) {
transition_in$2(if_block, 1);
}
} else {
if_block = create_if_block$1(ctx);
if_block.c();
transition_in$2(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros$1();
transition_out$2(if_block, 1, 1, () => {
if_block = null;
});
check_outros$1();
}
},
i(local) {
if (current) return;
transition_in$2(if_block);
current = true;
},
o(local) {
transition_out$2(if_block);
current = false;
},
d(detaching) {
if (detaching) {
detach$1(if_block_anchor);
}
if (if_block) if_block.d(detaching);
}
};
}
function create_fragment$2(ctx) {
let switch_instance;
let updating_value;
let switch_instance_anchor;
let current;
const switch_instance_spread_levels = [
{
elem_id: "elem_id" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_id || `component-${/*id*/ ctx[4]}`
},
{
elem_classes: "elem_classes" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_classes || []
},
{ target: /*target*/ ctx[6] },
/*props*/ ctx[2],
{ theme_mode: /*theme_mode*/ ctx[7] },
{ root: /*root*/ ctx[3] },
{
gradio: new Gradio(/*id*/ ctx[4], /*target*/ ctx[6], /*theme_mode*/ ctx[7], /*version*/ ctx[8], /*root*/ ctx[3], /*autoscroll*/ ctx[9])
}
];
function switch_instance_value_binding(value) {
/*switch_instance_value_binding*/ ctx[16](value);
}
var switch_value = /*component*/ ctx[10];
function switch_props(ctx, dirty) {
let switch_instance_props = {
$$slots: { default: [create_default_slot] },
$$scope: { ctx }
};
if (dirty !== undefined && dirty & /*props, id, target, theme_mode, root, version, autoscroll*/ 988) {
switch_instance_props = get_spread_update(switch_instance_spread_levels, [
dirty & /*props, id*/ 20 && {
elem_id: "elem_id" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_id || `component-${/*id*/ ctx[4]}`
},
dirty & /*props*/ 4 && {
elem_classes: "elem_classes" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_classes || []
},
dirty & /*target*/ 64 && { target: /*target*/ ctx[6] },
dirty & /*props*/ 4 && get_spread_object(/*props*/ ctx[2]),
dirty & /*theme_mode*/ 128 && { theme_mode: /*theme_mode*/ ctx[7] },
dirty & /*root*/ 8 && { root: /*root*/ ctx[3] },
dirty & /*id, target, theme_mode, version, root, autoscroll*/ 984 && {
gradio: new Gradio(/*id*/ ctx[4], /*target*/ ctx[6], /*theme_mode*/ ctx[7], /*version*/ ctx[8], /*root*/ ctx[3], /*autoscroll*/ ctx[9])
}
]);
} else {
for (let i = 0; i < switch_instance_spread_levels.length; i += 1) {
switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]);
}
}
if (/*instance_map*/ ctx[0][/*id*/ ctx[4]].props.value !== void 0) {
switch_instance_props.value = /*instance_map*/ ctx[0][/*id*/ ctx[4]].props.value;
}
return { props: switch_instance_props };
}
if (switch_value) {
switch_instance = construct_svelte_component(switch_value, switch_props(ctx));
/*switch_instance_binding*/ ctx[15](switch_instance);
binding_callbacks.push(() => bind(switch_instance, 'value', switch_instance_value_binding));
switch_instance.$on("prop_change", /*handle_prop_change*/ ctx[11]);
}
return {
c() {
if (switch_instance) create_component$2(switch_instance.$$.fragment);
switch_instance_anchor = empty$1();
},
m(target, anchor) {
if (switch_instance) mount_component$2(switch_instance, target, anchor);
insert$1(target, switch_instance_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (dirty & /*component*/ 1024 && switch_value !== (switch_value = /*component*/ ctx[10])) {
if (switch_instance) {
group_outros$1();
const old_component = switch_instance;
transition_out$2(old_component.$$.fragment, 1, 0, () => {
destroy_component$2(old_component, 1);
});
check_outros$1();
}
if (switch_value) {
switch_instance = construct_svelte_component(switch_value, switch_props(ctx, dirty));
/*switch_instance_binding*/ ctx[15](switch_instance);
binding_callbacks.push(() => bind(switch_instance, 'value', switch_instance_value_binding));
switch_instance.$on("prop_change", /*handle_prop_change*/ ctx[11]);
create_component$2(switch_instance.$$.fragment);
transition_in$2(switch_instance.$$.fragment, 1);
mount_component$2(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
} else {
switch_instance = null;
}
} else if (switch_value) {
const switch_instance_changes = (dirty & /*props, id, target, theme_mode, root, version, autoscroll*/ 988)
? get_spread_update(switch_instance_spread_levels, [
dirty & /*props, id*/ 20 && {
elem_id: "elem_id" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_id || `component-${/*id*/ ctx[4]}`
},
dirty & /*props*/ 4 && {
elem_classes: "elem_classes" in /*props*/ ctx[2] && /*props*/ ctx[2].elem_classes || []
},
dirty & /*target*/ 64 && { target: /*target*/ ctx[6] },
dirty & /*props*/ 4 && get_spread_object(/*props*/ ctx[2]),
dirty & /*theme_mode*/ 128 && { theme_mode: /*theme_mode*/ ctx[7] },
dirty & /*root*/ 8 && { root: /*root*/ ctx[3] },
dirty & /*id, target, theme_mode, version, root, autoscroll*/ 984 && {
gradio: new Gradio(/*id*/ ctx[4], /*target*/ ctx[6], /*theme_mode*/ ctx[7], /*version*/ ctx[8], /*root*/ ctx[3], /*autoscroll*/ ctx[9])
}
])
: {};
if (dirty & /*$$scope, children, target, root, instance_map, dynamic_ids, theme_mode*/ 16777451) {
switch_instance_changes.$$scope = { dirty, ctx };
}
if (!updating_value && dirty & /*instance_map, id*/ 17) {
updating_value = true;
switch_instance_changes.value = /*instance_map*/ ctx[0][/*id*/ ctx[4]].props.value;
add_flush_callback(() => updating_value = false);
}
switch_instance.$set(switch_instance_changes);
}
},
i(local) {
if (current) return;
if (switch_instance) transition_in$2(switch_instance.$$.fragment, local);
current = true;
},
o(local) {
if (switch_instance) transition_out$2(switch_instance.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach$1(switch_instance_anchor);
}
/*switch_instance_binding*/ ctx[15](null);
if (switch_instance) destroy_component$2(switch_instance, detaching);
}
};
}
function instance$2($$self, $$props, $$invalidate) {
let { root } = $$props;
let { component } = $$props;
let { instance_map } = $$props;
let { id } = $$props;
let { props } = $$props;
let { children } = $$props;
let { dynamic_ids } = $$props;
let { parent = null } = $$props;
let { target } = $$props;
let { theme_mode } = $$props;
let { version } = $$props;
let { autoscroll } = $$props;
const dispatch = createEventDispatcher$1();
let filtered_children = [];
onMount$1(() => {
dispatch("mount", id);
for (const child of filtered_children) {
dispatch("mount", child.id);
}
return () => {
dispatch("destroy", id);
for (const child of filtered_children) {
dispatch("mount", child.id);
}
};
});
setContext("BLOCK_KEY", parent);
function handle_prop_change(e) {
for (const k in e.detail) {
$$invalidate(0, instance_map[id].props[k] = e.detail[k], instance_map);
}
}
function destroy_handler(event) {
bubble.call(this, $$self, event);
}
function mount_handler(event) {
bubble.call(this, $$self, event);
}
function switch_instance_binding($$value) {
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
instance_map[id].instance = $$value;
$$invalidate(0, instance_map);
});
}
function switch_instance_value_binding(value) {
if ($$self.$$.not_equal(instance_map[id].props.value, value)) {
instance_map[id].props.value = value;
$$invalidate(0, instance_map);
}
}
$$self.$$set = $$props => {
if ('root' in $$props) $$invalidate(3, root = $$props.root);
if ('component' in $$props) $$invalidate(10, component = $$props.component);
if ('instance_map' in $$props) $$invalidate(0, instance_map = $$props.instance_map);
if ('id' in $$props) $$invalidate(4, id = $$props.id);
if ('props' in $$props) $$invalidate(2, props = $$props.props);
if ('children' in $$props) $$invalidate(1, children = $$props.children);
if ('dynamic_ids' in $$props) $$invalidate(5, dynamic_ids = $$props.dynamic_ids);
if ('parent' in $$props) $$invalidate(12, parent = $$props.parent);
if ('target' in $$props) $$invalidate(6, target = $$props.target);
if ('theme_mode' in $$props) $$invalidate(7, theme_mode = $$props.theme_mode);
if ('version' in $$props) $$invalidate(8, version = $$props.version);
if ('autoscroll' in $$props) $$invalidate(9, autoscroll = $$props.autoscroll);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*children, instance_map*/ 3) {
$$invalidate(1, children = children && children.filter(v => {
const valid_node = instance_map[v.id].type !== "statustracker";
if (!valid_node) {
filtered_children.push(v);
}
return valid_node;
}));
}
if ($$self.$$.dirty & /*instance_map, id, children*/ 19) {
{
if (instance_map[id].type === "form") {
if (children?.every(c => !c.props.visible)) {
$$invalidate(2, props.visible = false, props);
} else {
$$invalidate(2, props.visible = true, props);
}
}
}
}
};
return [
instance_map,
children,
props,
root,
id,
dynamic_ids,
target,
theme_mode,
version,
autoscroll,
component,
handle_prop_change,
parent,
destroy_handler,
mount_handler,
switch_instance_binding,
switch_instance_value_binding
];
}
class Render extends SvelteComponent$2 {
constructor(options) {
super();
init$2(this, options, instance$2, create_fragment$2, safe_not_equal$2, {
root: 3,
component: 10,
instance_map: 0,
id: 4,
props: 2,
children: 1,
dynamic_ids: 5,
parent: 12,
target: 6,
theme_mode: 7,
version: 8,
autoscroll: 9
});
}
}
/* src/MountComponents.svelte generated by Svelte v4.2.2 */
const {
SvelteComponent: SvelteComponent$1,
create_component: create_component$1,
destroy_component: destroy_component$1,
init: init$1,
mount_component: mount_component$1,
safe_not_equal: safe_not_equal$1,
transition_in: transition_in$1,
transition_out: transition_out$1
} = window.__gradio__svelte__internal;
const { onMount, createEventDispatcher } = window.__gradio__svelte__internal;
function create_fragment$1(ctx) {
let render;
let current;
render = new Render({
props: {
component: /*rootNode*/ ctx[0].component,
id: /*rootNode*/ ctx[0].id,
props: /*rootNode*/ ctx[0].props,
children: /*rootNode*/ ctx[0].children,
dynamic_ids: /*dynamic_ids*/ ctx[1],
instance_map: /*instance_map*/ ctx[2],
root: /*root*/ ctx[3],
target: /*target*/ ctx[4],
theme_mode: /*theme_mode*/ ctx[5],
version: /*version*/ ctx[6],
autoscroll: /*autoscroll*/ ctx[7]
}
});
return {
c() {
create_component$1(render.$$.fragment);
},
m(target, anchor) {
mount_component$1(render, target, anchor);
current = true;
},
p(ctx, [dirty]) {
const render_changes = {};
if (dirty & /*rootNode*/ 1) render_changes.component = /*rootNode*/ ctx[0].component;
if (dirty & /*rootNode*/ 1) render_changes.id = /*rootNode*/ ctx[0].id;
if (dirty & /*rootNode*/ 1) render_changes.props = /*rootNode*/ ctx[0].props;
if (dirty & /*rootNode*/ 1) render_changes.children = /*rootNode*/ ctx[0].children;
if (dirty & /*dynamic_ids*/ 2) render_changes.dynamic_ids = /*dynamic_ids*/ ctx[1];
if (dirty & /*instance_map*/ 4) render_changes.instance_map = /*instance_map*/ ctx[2];
if (dirty & /*root*/ 8) render_changes.root = /*root*/ ctx[3];
if (dirty & /*target*/ 16) render_changes.target = /*target*/ ctx[4];
if (dirty & /*theme_mode*/ 32) render_changes.theme_mode = /*theme_mode*/ ctx[5];
if (dirty & /*version*/ 64) render_changes.version = /*version*/ ctx[6];
if (dirty & /*autoscroll*/ 128) render_changes.autoscroll = /*autoscroll*/ ctx[7];
render.$set(render_changes);
},
i(local) {
if (current) return;
transition_in$1(render.$$.fragment, local);
current = true;
},
o(local) {
transition_out$1(render.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component$1(render, detaching);
}
};
}
function instance$1($$self, $$props, $$invalidate) {
let { rootNode } = $$props;
let { dynamic_ids } = $$props;
let { instance_map } = $$props;
let { root } = $$props;
let { target } = $$props;
let { theme_mode } = $$props;
let { version } = $$props;
let { autoscroll } = $$props;
const dispatch = createEventDispatcher();
onMount(() => {
dispatch("mount");
});
$$self.$$set = $$props => {
if ('rootNode' in $$props) $$invalidate(0, rootNode = $$props.rootNode);
if ('dynamic_ids' in $$props) $$invalidate(1, dynamic_ids = $$props.dynamic_ids);
if ('instance_map' in $$props) $$invalidate(2, instance_map = $$props.instance_map);
if ('root' in $$props) $$invalidate(3, root = $$props.root);
if ('target' in $$props) $$invalidate(4, target = $$props.target);
if ('theme_mode' in $$props) $$invalidate(5, theme_mode = $$props.theme_mode);
if ('version' in $$props) $$invalidate(6, version = $$props.version);
if ('autoscroll' in $$props) $$invalidate(7, autoscroll = $$props.autoscroll);
};
return [
rootNode,
dynamic_ids,
instance_map,
root,
target,
theme_mode,
version,
autoscroll
];
}
class MountComponents extends SvelteComponent$1 {
constructor(options) {
super();
init$1(this, options, instance$1, create_fragment$1, safe_not_equal$1, {
rootNode: 0,
dynamic_ids: 1,
instance_map: 2,
root: 3,
target: 4,
theme_mode: 5,
version: 6,
autoscroll: 7
});
}
}
const logo = ""+new URL('logo-3707f936.svg', import.meta.url).href+"";
const Blocks_svelte_svelte_type_style_lang = '';
/* src/Blocks.svelte generated by Svelte v4.2.2 */
const {
SvelteComponent,
append,
attr,
check_outros,
component_subscribe,
create_component,
destroy_component,
detach,
element,
empty,
globals,
group_outros,
init,
insert,
listen,
mount_component,
noop,
safe_not_equal,
set_data,
set_style,
space,
src_url_equal,
subscribe,
text,
transition_in,
transition_out
} = window.__gradio__svelte__internal;
const { document: document_1 } = globals;
const { tick } = window.__gradio__svelte__internal;
function create_if_block_6(ctx) {
document_1.title = /*title*/ ctx[3];
return { c: noop, m: noop, d: noop };
}
// (531:1) {#if analytics_enabled}
function create_if_block_5(ctx) {
let script0;
let script0_src_value;
let t0;
let script1;
return {
c() {
script0 = element("script");
script0.innerHTML = ``;
t0 = space();
script1 = element("script");
script1.textContent = "window.dataLayer = window.dataLayer || [];\n\t\t\tfunction gtag() {\n\t\t\t\tdataLayer.push(arguments);\n\t\t\t}\n\t\t\tgtag(\"js\", new Date());\n\t\t\tgtag(\"config\", \"UA-156449732-1\", {\n\t\t\t\tcookie_flags: \"samesite=none;secure\"\n\t\t\t});";
script0.async = true;
script0.defer = true;
if (!src_url_equal(script0.src, script0_src_value = "https://www.googletagmanager.com/gtag/js?id=UA-156449732-1")) attr(script0, "src", script0_src_value);
},
m(target, anchor) {
insert(target, script0, anchor);
insert(target, t0, anchor);
insert(target, script1, anchor);
},
d(detaching) {
if (detaching) {
detach(script0);
detach(t0);
detach(script1);
}
}
};
}
// (552:2) {#if ready}
function create_if_block_4(ctx) {
let mountcomponents;
let current;
mountcomponents = new MountComponents({
props: {
rootNode: /*rootNode*/ ctx[15],
dynamic_ids: /*dynamic_ids*/ ctx[17],
instance_map: /*instance_map*/ ctx[18],
root: /*root*/ ctx[1],
target: /*target*/ ctx[5],
theme_mode: /*theme_mode*/ ctx[11],
version: /*version*/ ctx[13],
autoscroll: /*autoscroll*/ ctx[6]
}
});
mountcomponents.$on("mount", /*handle_mount*/ ctx[23]);
mountcomponents.$on("destroy", /*destroy_handler*/ ctx[31]);
return {
c() {
create_component(mountcomponents.$$.fragment);
},
m(target, anchor) {
mount_component(mountcomponents, target, anchor);
current = true;
},
p(ctx, dirty) {
const mountcomponents_changes = {};
if (dirty[0] & /*rootNode*/ 32768) mountcomponents_changes.rootNode = /*rootNode*/ ctx[15];
if (dirty[0] & /*dynamic_ids*/ 131072) mountcomponents_changes.dynamic_ids = /*dynamic_ids*/ ctx[17];
if (dirty[0] & /*instance_map*/ 262144) mountcomponents_changes.instance_map = /*instance_map*/ ctx[18];
if (dirty[0] & /*root*/ 2) mountcomponents_changes.root = /*root*/ ctx[1];
if (dirty[0] & /*target*/ 32) mountcomponents_changes.target = /*target*/ ctx[5];
if (dirty[0] & /*theme_mode*/ 2048) mountcomponents_changes.theme_mode = /*theme_mode*/ ctx[11];
if (dirty[0] & /*version*/ 8192) mountcomponents_changes.version = /*version*/ ctx[13];
if (dirty[0] & /*autoscroll*/ 64) mountcomponents_changes.autoscroll = /*autoscroll*/ ctx[6];
mountcomponents.$set(mountcomponents_changes);
},
i(local) {
if (current) return;
transition_in(mountcomponents.$$.fragment, local);
current = true;
},
o(local) {
transition_out(mountcomponents.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(mountcomponents, detaching);
}
};
}
// (568:1) {#if show_footer}
function create_if_block_2(ctx) {
let footer;
let t0;
let a;
let t1_value = /*$_*/ ctx[20]("common.built_with_gradio") + "";
let t1;
let t2;
let img;
let img_src_value;
let img_alt_value;
let if_block = /*show_api*/ ctx[7] && create_if_block_3(ctx);
return {
c() {
footer = element("footer");
if (if_block) if_block.c();
t0 = space();
a = element("a");
t1 = text(t1_value);
t2 = space();
img = element("img");
if (!src_url_equal(img.src, img_src_value = logo)) attr(img, "src", img_src_value);
attr(img, "alt", img_alt_value = /*$_*/ ctx[20]("common.logo"));
attr(img, "class", "svelte-mpyp5e");
attr(a, "href", "https://gradio.app");
attr(a, "class", "built-with svelte-mpyp5e");
attr(a, "target", "_blank");
attr(a, "rel", "noreferrer");
attr(footer, "class", "svelte-mpyp5e");
},
m(target, anchor) {
insert(target, footer, anchor);
if (if_block) if_block.m(footer, null);
append(footer, t0);
append(footer, a);
append(a, t1);
append(a, t2);
append(a, img);
},
p(ctx, dirty) {
if (/*show_api*/ ctx[7]) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_3(ctx);
if_block.c();
if_block.m(footer, t0);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty[0] & /*$_*/ 1048576 && t1_value !== (t1_value = /*$_*/ ctx[20]("common.built_with_gradio") + "")) set_data(t1, t1_value);
if (dirty[0] & /*$_*/ 1048576 && img_alt_value !== (img_alt_value = /*$_*/ ctx[20]("common.logo"))) {
attr(img, "alt", img_alt_value);
}
},
d(detaching) {
if (detaching) {
detach(footer);
}
if (if_block) if_block.d();
}
};
}
// (570:3) {#if show_api}
function create_if_block_3(ctx) {
let button;
let t0_value = /*$_*/ ctx[20]("errors.use_via_api") + "";
let t0;
let t1;
let img;
let img_src_value;
let img_alt_value;
let t2;
let div;
let mounted;
let dispose;
return {
c() {
button = element("button");
t0 = text(t0_value);
t1 = space();
img = element("img");
t2 = space();
div = element("div");
div.textContent = "·";
if (!src_url_equal(img.src, img_src_value = api_logo)) attr(img, "src", img_src_value);
attr(img, "alt", img_alt_value = /*$_*/ ctx[20]("common.logo"));
attr(img, "class", "svelte-mpyp5e");
attr(button, "class", "show-api svelte-mpyp5e");
attr(div, "class", "svelte-mpyp5e");
},
m(target, anchor) {
insert(target, button, anchor);
append(button, t0);
append(button, t1);
append(button, img);
insert(target, t2, anchor);
insert(target, div, anchor);
if (!mounted) {
dispose = listen(button, "click", /*click_handler*/ ctx[32]);
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*$_*/ 1048576 && t0_value !== (t0_value = /*$_*/ ctx[20]("errors.use_via_api") + "")) set_data(t0, t0_value);
if (dirty[0] & /*$_*/ 1048576 && img_alt_value !== (img_alt_value = /*$_*/ ctx[20]("common.logo"))) {
attr(img, "alt", img_alt_value);
}
},
d(detaching) {
if (detaching) {
detach(button);
detach(t2);
detach(div);
}
mounted = false;
dispose();
}
};
}
// (595:0) {#if api_docs_visible && ready}
function create_if_block_1(ctx) {
let div2;
let div0;
let t;
let div1;
let apidocs;
let current;
let mounted;
let dispose;
apidocs = new ApiDocs({
props: {
instance_map: /*instance_map*/ ctx[18],
dependencies: /*dependencies*/ ctx[2],
root: /*root*/ ctx[1],
app: /*app*/ ctx[12]
}
});
apidocs.$on("close", /*close_handler*/ ctx[34]);
return {
c() {
div2 = element("div");
div0 = element("div");
t = space();
div1 = element("div");
create_component(apidocs.$$.fragment);
attr(div0, "class", "backdrop svelte-mpyp5e");
attr(div1, "class", "api-docs-wrap svelte-mpyp5e");
attr(div2, "class", "api-docs svelte-mpyp5e");
},
m(target, anchor) {
insert(target, div2, anchor);
append(div2, div0);
append(div2, t);
append(div2, div1);
mount_component(apidocs, div1, null);
current = true;
if (!mounted) {
dispose = listen(div0, "click", /*click_handler_1*/ ctx[33]);
mounted = true;
}
},
p(ctx, dirty) {
const apidocs_changes = {};
if (dirty[0] & /*instance_map*/ 262144) apidocs_changes.instance_map = /*instance_map*/ ctx[18];
if (dirty[0] & /*dependencies*/ 4) apidocs_changes.dependencies = /*dependencies*/ ctx[2];
if (dirty[0] & /*root*/ 2) apidocs_changes.root = /*root*/ ctx[1];
if (dirty[0] & /*app*/ 4096) apidocs_changes.app = /*app*/ ctx[12];
apidocs.$set(apidocs_changes);
},
i(local) {
if (current) return;
transition_in(apidocs.$$.fragment, local);
current = true;
},
o(local) {
transition_out(apidocs.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) {
detach(div2);
}
destroy_component(apidocs);
mounted = false;
dispose();
}
};
}
// (620:0) {#if messages}
function create_if_block(ctx) {
let toast;
let current;
toast = new Toast({
props: { messages: /*messages*/ ctx[19] }
});
toast.$on("close", /*handle_error_close*/ ctx[22]);
return {
c() {
create_component(toast.$$.fragment);
},
m(target, anchor) {
mount_component(toast, target, anchor);
current = true;
},
p(ctx, dirty) {
const toast_changes = {};
if (dirty[0] & /*messages*/ 524288) toast_changes.messages = /*messages*/ ctx[19];
toast.$set(toast_changes);
},
i(local) {
if (current) return;
transition_in(toast.$$.fragment, local);
current = true;
},
o(local) {
transition_out(toast.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(toast, detaching);
}
};
}
function create_fragment(ctx) {
let if_block0_anchor;
let if_block1_anchor;
let t0;
let div1;
let div0;
let t1;
let t2;
let t3;
let if_block5_anchor;
let current;
let if_block0 = /*control_page_title*/ ctx[9] && create_if_block_6(ctx);
let if_block1 = /*analytics_enabled*/ ctx[4] && create_if_block_5();
let if_block2 = /*ready*/ ctx[0] && create_if_block_4(ctx);
let if_block3 = /*show_footer*/ ctx[8] && create_if_block_2(ctx);
let if_block4 = /*api_docs_visible*/ ctx[16] && /*ready*/ ctx[0] && create_if_block_1(ctx);
let if_block5 = /*messages*/ ctx[19] && create_if_block(ctx);
return {
c() {
if (if_block0) if_block0.c();
if_block0_anchor = empty();
if (if_block1) if_block1.c();
if_block1_anchor = empty();
t0 = space();
div1 = element("div");
div0 = element("div");
if (if_block2) if_block2.c();
t1 = space();
if (if_block3) if_block3.c();
t2 = space();
if (if_block4) if_block4.c();
t3 = space();
if (if_block5) if_block5.c();
if_block5_anchor = empty();
attr(div0, "class", "contain");
set_style(div0, "flex-grow", /*app_mode*/ ctx[10] ? "1" : "auto");
attr(div1, "class", "wrap svelte-mpyp5e");
set_style(div1, "min-height", /*app_mode*/ ctx[10] ? "100%" : "auto");
},
m(target, anchor) {
if (if_block0) if_block0.m(document_1.head, null);
append(document_1.head, if_block0_anchor);
if (if_block1) if_block1.m(document_1.head, null);
append(document_1.head, if_block1_anchor);
insert(target, t0, anchor);
insert(target, div1, anchor);
append(div1, div0);
if (if_block2) if_block2.m(div0, null);
append(div1, t1);
if (if_block3) if_block3.m(div1, null);
insert(target, t2, anchor);
if (if_block4) if_block4.m(target, anchor);
insert(target, t3, anchor);
if (if_block5) if_block5.m(target, anchor);
insert(target, if_block5_anchor, anchor);
current = true;
},
p(ctx, dirty) {
if (/*control_page_title*/ ctx[9]) {
if (if_block0) ; else {
if_block0 = create_if_block_6(ctx);
if_block0.c();
if_block0.m(if_block0_anchor.parentNode, if_block0_anchor);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
if (/*analytics_enabled*/ ctx[4]) {
if (if_block1) ; else {
if_block1 = create_if_block_5();
if_block1.c();
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
if (/*ready*/ ctx[0]) {
if (if_block2) {
if_block2.p(ctx, dirty);
if (dirty[0] & /*ready*/ 1) {
transition_in(if_block2, 1);
}
} else {
if_block2 = create_if_block_4(ctx);
if_block2.c();
transition_in(if_block2, 1);
if_block2.m(div0, null);
}
} else if (if_block2) {
group_outros();
transition_out(if_block2, 1, 1, () => {
if_block2 = null;
});
check_outros();
}
if (dirty[0] & /*app_mode*/ 1024) {
set_style(div0, "flex-grow", /*app_mode*/ ctx[10] ? "1" : "auto");
}
if (/*show_footer*/ ctx[8]) {
if (if_block3) {
if_block3.p(ctx, dirty);
} else {
if_block3 = create_if_block_2(ctx);
if_block3.c();
if_block3.m(div1, null);
}
} else if (if_block3) {
if_block3.d(1);
if_block3 = null;
}
if (dirty[0] & /*app_mode*/ 1024) {
set_style(div1, "min-height", /*app_mode*/ ctx[10] ? "100%" : "auto");
}
if (/*api_docs_visible*/ ctx[16] && /*ready*/ ctx[0]) {
if (if_block4) {
if_block4.p(ctx, dirty);
if (dirty[0] & /*api_docs_visible, ready*/ 65537) {
transition_in(if_block4, 1);
}
} else {
if_block4 = create_if_block_1(ctx);
if_block4.c();
transition_in(if_block4, 1);
if_block4.m(t3.parentNode, t3);
}
} else if (if_block4) {
group_outros();
transition_out(if_block4, 1, 1, () => {
if_block4 = null;
});
check_outros();
}
if (/*messages*/ ctx[19]) {
if (if_block5) {
if_block5.p(ctx, dirty);
if (dirty[0] & /*messages*/ 524288) {
transition_in(if_block5, 1);
}
} else {
if_block5 = create_if_block(ctx);
if_block5.c();
transition_in(if_block5, 1);
if_block5.m(if_block5_anchor.parentNode, if_block5_anchor);
}
} else if (if_block5) {
group_outros();
transition_out(if_block5, 1, 1, () => {
if_block5 = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block2);
transition_in(if_block4);
transition_in(if_block5);
current = true;
},
o(local) {
transition_out(if_block2);
transition_out(if_block4);
transition_out(if_block5);
current = false;
},
d(detaching) {
if (detaching) {
detach(t0);
detach(div1);
detach(t2);
detach(t3);
detach(if_block5_anchor);
}
if (if_block0) if_block0.d(detaching);
detach(if_block0_anchor);
if (if_block1) if_block1.d(detaching);
detach(if_block1_anchor);
if (if_block2) if_block2.d();
if (if_block3) if_block3.d();
if (if_block4) if_block4.d(detaching);
if (if_block5) if_block5.d(detaching);
}
};
}
const MESSAGE_QUOTE_RE = /^'([^]+)'$/;
const SHOW_DUPLICATE_MESSAGE_ON_ETA = 15;
const SHOW_MOBILE_QUEUE_WARNING_ON_ETA = 10;
function is_dep(id, type, deps) {
for (const dep of deps) {
for (const dep_item of dep[type]) {
if (dep_item === id) return true;
}
}
return false;
}
function has_no_default_value(value) {
return Array.isArray(value) && value.length === 0 || value === "" || value === 0 || !value;
}
function get_data(comp) {
if (comp.instance.get_value) {
return comp.instance.get_value();
}
return comp.props.value;
}
function isCustomEvent(event) {
return "detail" in event;
}
function instance($$self, $$props, $$invalidate) {
let $loading_status,
$$unsubscribe_loading_status = noop,
$$subscribe_loading_status = () => ($$unsubscribe_loading_status(), $$unsubscribe_loading_status = subscribe(loading_status, $$value => $$invalidate(30, $loading_status = $$value)), loading_status);
let $_;
component_subscribe($$self, $format, $$value => $$invalidate(20, $_ = $$value));
$$self.$$.on_destroy.push(() => $$unsubscribe_loading_status());
setupi18n();
let { root } = $$props;
let { components } = $$props;
let { layout } = $$props;
let { dependencies } = $$props;
let { title = "Gradio" } = $$props;
let { analytics_enabled = false } = $$props;
let { target } = $$props;
let { autoscroll } = $$props;
let { show_api = true } = $$props;
let { show_footer = true } = $$props;
let { control_page_title = false } = $$props;
let { app_mode } = $$props;
let { theme_mode } = $$props;
let { app } = $$props;
let { space_id } = $$props;
let { version } = $$props;
let { js } = $$props;
let loading_status = create_loading_status_store();
$$subscribe_loading_status();
let rootNode = {
id: layout.id,
type: "column",
props: { interactive: false },
has_modes: false,
instance: null,
component: null,
component_class_id: ""
};
const AsyncFunction = Object.getPrototypeOf(async function () {
}).constructor;
dependencies.forEach(d => {
if (d.js) {
const wrap = d.backend_fn
? d.inputs.length === 1
: d.outputs.length === 1;
try {
d.frontend_fn = new AsyncFunction("__fn_args",
`let result = await (${d.js})(...__fn_args);
return (${wrap} && !Array.isArray(result)) ? [result] : result;`);
} catch(e) {
console.error("Could not parse custom js method.");
console.error(e);
}
}
});
let params = new URLSearchParams(window.location.search);
let api_docs_visible = params.get("view") === "api" && show_api;
function set_api_docs_visible(visible) {
$$invalidate(16, api_docs_visible = visible);
let params = new URLSearchParams(window.location.search);
if (visible) {
params.set("view", "api");
} else {
params.delete("view");
}
history.replaceState(null, "", "?" + params.toString());
}
let dynamic_ids = new Set();
let instance_map;
async function walk_layout(node, type_map, instance_map, component_map) {
$$invalidate(0, ready = false);
let instance = instance_map[node.id];
const _component = (await component_map.get(`${instance.type}_${type_map.get(node.id) || "false"}`)).component;
instance.component = _component.default;
if (node.children) {
instance.children = node.children.map(v => instance_map[v.id]);
await Promise.all(node.children.map(v => walk_layout(v, type_map, instance_map, component_map)));
}
}
let { ready = false } = $$props;
let { render_complete = false } = $$props;
let target_map = {};
function prepare_components() {
target_map = dependencies.reduce(
(acc, dep, i) => {
dep.targets.forEach(([id, trigger]) => {
if (!acc[id]) {
acc[id] = {};
}
if (acc[id]?.[trigger]) {
acc[id][trigger].push(i);
} else {
acc[id][trigger] = [i];
}
});
return acc;
},
{}
);
$$subscribe_loading_status($$invalidate(14, loading_status = create_loading_status_store()));
dependencies.forEach((v, i) => {
loading_status.register(i, v.inputs, v.outputs);
});
const _dynamic_ids = new Set();
for (const comp of components) {
const { id, props } = comp;
const is_input = is_dep(id, "inputs", dependencies);
if (is_input || !is_dep(id, "outputs", dependencies) && has_no_default_value(props?.value)) {
_dynamic_ids.add(id);
}
}
$$invalidate(17, dynamic_ids = _dynamic_ids);
const _rootNode = {
id: layout.id,
type: "column",
props: { interactive: false },
has_modes: false,
instance: null,
component: null,
component_class_id: ""
};
components.push(_rootNode);
const _component_set = new Set();
const __component_map = new Map();
const __type_for_id = new Map();
const _instance_map = components.reduce(
(acc, next) => {
acc[next.id] = next;
return acc;
},
{}
);
components.forEach(c => {
if (c.props.interactive === false) {
c.props.interactive = false;
} else if (c.props.interactive === true) {
c.props.interactive = true;
} else if (dynamic_ids.has(c.id)) {
c.props.interactive = true;
} else {
c.props.interactive = false;
}
if (c.props.server_fns) {
let server = {};
c.props.server_fns.forEach(fn => {
server[fn] = async (...args) => {
if (args.length === 1) {
args = args[0];
}
const result = await app.component_server(c.id, fn, args);
return result;
};
});
c.props.server = server;
}
if (target_map[c.id]) {
c.props.attached_events = Object.keys(target_map[c.id]);
}
__type_for_id.set(c.id, c.props.interactive);
if (c.type === "dataset") {
const example_component_map = new Map();
c.props.components.forEach(name => {
if (example_component_map.has(name)) {
return;
}
let _c;
const matching_component = components.find(c => c.type === name);
if (matching_component) {
_c = load_component({
api_url: root,
name,
id: matching_component.component_class_id,
variant: "example"
});
example_component_map.set(name, _c);
}
});
c.props.component_map = example_component_map;
}
// maybe load custom
const _c = load_component({
api_url: root,
name: c.type,
id: c.component_class_id,
variant: "component"
});
_component_set.add(_c);
__component_map.set(`${c.type}_${c.props.interactive}`, _c);
});
Promise.all(Array.from(_component_set)).then(() => {
walk_layout(layout, __type_for_id, _instance_map, __component_map).then(async () => {
$$invalidate(0, ready = true);
$$invalidate(18, instance_map = _instance_map);
$$invalidate(15, rootNode = _rootNode);
}).catch(e => {
console.error(e);
});
});
}
async function handle_update(data, fn_index, outputs_set_to_non_interactive) {
const outputs = dependencies[fn_index].outputs;
data?.forEach((value, i) => {
const output = instance_map[outputs[i]];
output.props.value_is_output = true;
});
$$invalidate(15, rootNode);
await tick();
data?.forEach((value, i) => {
const output = instance_map[outputs[i]];
if (typeof value === "object" && value !== null && value.__type__ === "update") {
for (const [update_key, update_value] of Object.entries(value)) {
if (update_key === "__type__") {
continue;
} else {
output.props[update_key] = update_value;
if (update_key == "interactive" && !update_value) {
outputs_set_to_non_interactive.push(outputs[i]);
}
}
}
} else {
output.props.value = value;
}
});
$$invalidate(15, rootNode);
}
let submit_map = new Map();
function set_prop(obj, prop, val) {
if (!obj?.props) {
// @ts-ignore
obj.props = {};
}
obj.props[prop] = val;
$$invalidate(15, rootNode);
}
let handled_dependencies = [];
let messages = [];
function new_message(message, fn_index, type) {
return { message, fn_index, type, id: ++_error_id };
}
let _error_id = -1;
let user_left_page = false;
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "hidden") {
user_left_page = true;
}
});
const DUPLICATE_MESSAGE = $_("blocks.long_requests_queue");
const MOBILE_QUEUE_WARNING = $_("blocks.connection_can_break");
const MOBILE_RECONNECT_MESSAGE = $_("blocks.lost_connection");
const is_mobile_device = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i).test(navigator.userAgent);
let showed_duplicate_message = false;
let showed_mobile_warning = false;
async function trigger_api_call(dep_index, trigger_id = null, event_data = null) {
let dep = dependencies[dep_index];
const current_status = loading_status.get_status_for_fn(dep_index);
$$invalidate(19, messages = messages.filter(({ fn_index }) => fn_index !== dep_index));
if (dep.cancels) {
await Promise.all(dep.cancels.map(async fn_index => {
const submission = submit_map.get(fn_index);
submission?.cancel();
return submission;
}));
}
if (current_status === "pending" || current_status === "generating") {
dep.pending_request = true;
}
let payload = {
fn_index: dep_index,
data: await Promise.all(dep.inputs.map(id => get_data(instance_map[id]))),
event_data: dep.collects_event_data ? event_data : null,
trigger_id
};
if (dep.frontend_fn) {
dep.frontend_fn(payload.data.concat(await Promise.all(dep.inputs.map(id => get_data(instance_map[id]))))).then(v => {
if (dep.backend_fn) {
payload.data = v;
make_prediction(payload);
} else {
handle_update(v, dep_index, []);
}
});
} else {
if (dep.backend_fn) {
if (dep.trigger_mode === "once") {
if (!dep.pending_request) make_prediction(payload);
} else if (dep.trigger_mode === "multiple") {
make_prediction(payload);
} else if (dep.trigger_mode === "always_last") {
if (!dep.pending_request) {
make_prediction(payload);
} else {
dep.final_event = payload;
}
}
}
}
function make_prediction(payload) {
const pending_outputs = [];
let outputs_set_to_non_interactive = [];
const submission = app.submit(payload.fn_index, payload.data, payload.event_data, payload.trigger_id).on("data", ({ data, fn_index }) => {
if (dep.pending_request && dep.final_event) {
dep.pending_request = false;
make_prediction(dep.final_event);
}
dep.pending_request = false;
handle_update(data, fn_index, outputs_set_to_non_interactive);
}).on("status", ({ fn_index, ...status }) => {
tick().then(() => {
const outputs = dependencies[fn_index].outputs;
outputs.forEach(id => {
if (instance_map[id].props.interactive && status.stage === "pending" && dep.targets[0][1] !== "focus") {
pending_outputs.push(id);
$$invalidate(18, instance_map[id].props.interactive = false, instance_map);
} else if (status.stage === "complete" && pending_outputs.includes(id) && !outputs_set_to_non_interactive.includes(id)) {
$$invalidate(18, instance_map[id].props.interactive = true, instance_map);
}
});
//@ts-ignore
loading_status.update({
...status,
status: status.stage,
progress: status.progress_data,
fn_index
});
if (!showed_duplicate_message && space_id !== null && status.position !== undefined && status.position >= 2 && status.eta !== undefined && status.eta > SHOW_DUPLICATE_MESSAGE_ON_ETA) {
showed_duplicate_message = true;
$$invalidate(19, messages = [new_message(DUPLICATE_MESSAGE, fn_index, "warning"), ...messages]);
}
if (!showed_mobile_warning && is_mobile_device && status.eta !== undefined && status.eta > SHOW_MOBILE_QUEUE_WARNING_ON_ETA) {
showed_mobile_warning = true;
$$invalidate(19, messages = [new_message(MOBILE_QUEUE_WARNING, fn_index, "warning"), ...messages]);
}
if (status.stage === "complete") {
dependencies.map(async (dep, i) => {
if (dep.trigger_after === fn_index) {
trigger_api_call(i, payload.trigger_id);
}
});
submission.destroy();
}
if (status.broken && is_mobile_device && user_left_page) {
window.setTimeout(
() => {
$$invalidate(19, messages = [
new_message(MOBILE_RECONNECT_MESSAGE, fn_index, "error"),
...messages
]);
},
0
);
trigger_api_call(dep_index, payload.trigger_id, event_data);
user_left_page = false;
} else if (status.stage === "error") {
if (status.message) {
const _message = status.message.replace(MESSAGE_QUOTE_RE, (_, b) => b);
$$invalidate(19, messages = [new_message(_message, fn_index, "error"), ...messages]);
}
dependencies.map(async (dep, i) => {
if (dep.trigger_after === fn_index && !dep.trigger_only_on_success) {
trigger_api_call(i, payload.trigger_id);
}
});
submission.destroy();
}
});
}).on("log", ({ log, fn_index, level }) => {
$$invalidate(19, messages = [new_message(log, fn_index, level), ...messages]);
});
submit_map.set(dep_index, submission);
}
}
function trigger_share(title, description) {
if (space_id === null) {
return;
}
const discussion_url = new URL(`https://huggingface.co/spaces/${space_id}/discussions/new`);
if (title !== undefined && title.length > 0) {
discussion_url.searchParams.set("title", title);
}
discussion_url.searchParams.set("description", description);
window.open(discussion_url.toString(), "_blank");
}
function handle_error_close(e) {
const _id = e.detail;
$$invalidate(19, messages = messages.filter(m => m.id !== _id));
}
const is_external_url = link => !!(link && new URL(link, location.href).origin !== location.origin);
async function handle_mount() {
if (js) {
let blocks_frontend_fn = new AsyncFunction(`let result = await (${js})();
return (!Array.isArray(result)) ? [result] : result;`);
blocks_frontend_fn();
}
await tick();
var a = target.getElementsByTagName("a");
for (var i = 0; i < a.length; i++) {
const _target = a[i].getAttribute("target");
const _link = a[i].getAttribute("href");
// only target anchor tags with external links
if (is_external_url(_link) && _target !== "_blank") a[i].setAttribute("target", "_blank");
}
// handle load triggers
dependencies.forEach((dep, i) => {
if (dep.targets[0][1] === "load") {
trigger_api_call(i);
}
});
target.addEventListener("gradio", e => {
if (!isCustomEvent(e)) throw new Error("not a custom event");
const { id, event, data } = e.detail;
if (event === "share") {
const { title, description } = data;
trigger_share(title, description);
} else if (event === "error" || event === "warning") {
$$invalidate(19, messages = [new_message(data, -1, event), ...messages]);
} else {
const deps = target_map[id]?.[event];
deps?.forEach(dep_id => {
trigger_api_call(dep_id, id, data);
});
}
});
$$invalidate(25, render_complete = true);
}
function handle_destroy(id) {
handled_dependencies = handled_dependencies.map(dep => {
return dep.filter(_id => _id !== id);
});
}
function set_status(statuses) {
for (const id in statuses) {
let loading_status = statuses[id];
let dependency = dependencies[loading_status.fn_index];
loading_status.scroll_to_output = dependency.scroll_to_output;
loading_status.show_progress = dependency.show_progress;
set_prop(instance_map[id], "loading_status", loading_status);
}
const inputs_to_update = loading_status.get_inputs_to_update();
for (const [id, pending_status] of inputs_to_update) {
set_prop(instance_map[id], "pending", pending_status === "pending");
}
}
const destroy_handler = ({ detail }) => handle_destroy(detail);
const click_handler = () => {
set_api_docs_visible(!api_docs_visible);
};
const click_handler_1 = () => {
set_api_docs_visible(false);
};
const close_handler = () => {
set_api_docs_visible(false);
};
$$self.$$set = $$props => {
if ('root' in $$props) $$invalidate(1, root = $$props.root);
if ('components' in $$props) $$invalidate(26, components = $$props.components);
if ('layout' in $$props) $$invalidate(27, layout = $$props.layout);
if ('dependencies' in $$props) $$invalidate(2, dependencies = $$props.dependencies);
if ('title' in $$props) $$invalidate(3, title = $$props.title);
if ('analytics_enabled' in $$props) $$invalidate(4, analytics_enabled = $$props.analytics_enabled);
if ('target' in $$props) $$invalidate(5, target = $$props.target);
if ('autoscroll' in $$props) $$invalidate(6, autoscroll = $$props.autoscroll);
if ('show_api' in $$props) $$invalidate(7, show_api = $$props.show_api);
if ('show_footer' in $$props) $$invalidate(8, show_footer = $$props.show_footer);
if ('control_page_title' in $$props) $$invalidate(9, control_page_title = $$props.control_page_title);
if ('app_mode' in $$props) $$invalidate(10, app_mode = $$props.app_mode);
if ('theme_mode' in $$props) $$invalidate(11, theme_mode = $$props.theme_mode);
if ('app' in $$props) $$invalidate(12, app = $$props.app);
if ('space_id' in $$props) $$invalidate(28, space_id = $$props.space_id);
if ('version' in $$props) $$invalidate(13, version = $$props.version);
if ('js' in $$props) $$invalidate(29, js = $$props.js);
if ('ready' in $$props) $$invalidate(0, ready = $$props.ready);
if ('render_complete' in $$props) $$invalidate(25, render_complete = $$props.render_complete);
};
$$self.$$.update = () => {
if ($$self.$$.dirty[0] & /*components, layout*/ 201326592) {
(prepare_components());
}
if ($$self.$$.dirty[0] & /*$loading_status*/ 1073741824) {
set_status($loading_status);
}
};
return [
ready,
root,
dependencies,
title,
analytics_enabled,
target,
autoscroll,
show_api,
show_footer,
control_page_title,
app_mode,
theme_mode,
app,
version,
loading_status,
rootNode,
api_docs_visible,
dynamic_ids,
instance_map,
messages,
$_,
set_api_docs_visible,
handle_error_close,
handle_mount,
handle_destroy,
render_complete,
components,
layout,
space_id,
js,
$loading_status,
destroy_handler,
click_handler,
click_handler_1,
close_handler
];
}
class Blocks extends SvelteComponent {
constructor(options) {
super();
init(
this,
options,
instance,
create_fragment,
safe_not_equal,
{
root: 1,
components: 26,
layout: 27,
dependencies: 2,
title: 3,
analytics_enabled: 4,
target: 5,
autoscroll: 6,
show_api: 7,
show_footer: 8,
control_page_title: 9,
app_mode: 10,
theme_mode: 11,
app: 12,
space_id: 28,
version: 13,
js: 29,
ready: 0,
render_complete: 25
},
null,
[-1, -1]
);
}
}
const Blocks$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
__proto__: null,
default: Blocks
}, Symbol.toStringTag, { value: 'Module' }));
export { Blocks$1 as B, Toast as T };
//# sourceMappingURL=Blocks-98cbd2e4.js.map