1import { B as Block } from './Button-bd009e9a.js'; 2import './Index-7fdff9d2.js'; 3import './index-10ead756.js'; 4import './svelte/svelte.js'; 5 6const Index_svelte_svelte_type_style_lang = ''; 7 8/* home/runner/work/gradio/gradio/js/dataset/Index.svelte generated by Svelte v4.2.2 */ 9const { 10 SvelteComponent, 11 append, 12 assign, 13 attr, 14 check_outros, 15 construct_svelte_component, 16 create_component, 17 destroy_component, 18 destroy_each, 19 detach, 20 element, 21 empty, 22 ensure_array_like, 23 get_spread_object, 24 get_spread_update, 25 group_outros, 26 init, 27 insert, 28 listen, 29 mount_component, 30 noop, 31 null_to_empty, 32 run_all, 33 safe_not_equal, 34 set_data, 35 set_style, 36 space, 37 svg_element, 38 text, 39 toggle_class, 40 transition_in, 41 transition_out 42} = window.__gradio__svelte__internal; 43function get_each_context(ctx, list, i) { 44 const child_ctx = ctx.slice(); 45 child_ctx[35] = list[i]; 46 return child_ctx; 47} 48 49function get_each_context_2(ctx, list, i) { 50 const child_ctx = ctx.slice(); 51 child_ctx[38] = list[i]; 52 child_ctx[40] = i; 53 return child_ctx; 54} 55 56function get_each_context_3(ctx, list, i) { 57 const child_ctx = ctx.slice(); 58 child_ctx[0] = list[i].value; 59 child_ctx[42] = list[i].component; 60 child_ctx[45] = i; 61 const constants_0 = /*components*/ child_ctx[1][/*j*/ child_ctx[45]]; 62 child_ctx[43] = constants_0; 63 return child_ctx; 64} 65 66function get_each_context_4(ctx, list, i) { 67 const child_ctx = ctx.slice(); 68 child_ctx[46] = list[i]; 69 return child_ctx; 70} 71 72function get_each_context_1(ctx, list, i) { 73 const child_ctx = ctx.slice(); 74 child_ctx[38] = list[i]; 75 child_ctx[40] = i; 76 return child_ctx; 77} 78 79// (127:1) {:else} 80function create_else_block_1(ctx) { 81 let div; 82 let table; 83 let thead; 84 let tr; 85 let t; 86 let tbody; 87 let current; 88 let each_value_4 = ensure_array_like(/*headers*/ ctx[5]); 89 let each_blocks_1 = []; 90 91 for (let i = 0; i < each_value_4.length; i += 1) { 92 each_blocks_1[i] = create_each_block_4(get_each_context_4(ctx, each_value_4, i)); 93 } 94 95 let each_value_2 = ensure_array_like(/*component_meta*/ ctx[17]); 96 let each_blocks = []; 97 98 for (let i = 0; i < each_value_2.length; i += 1) { 99 each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); 100 } 101 102 const out = i => transition_out(each_blocks[i], 1, 1, () => { 103 each_blocks[i] = null; 104 }); 105 106 return { 107 c() { 108 div = element("div"); 109 table = element("table"); 110 thead = element("thead"); 111 tr = element("tr"); 112 113 for (let i = 0; i < each_blocks_1.length; i += 1) { 114 each_blocks_1[i].c(); 115 } 116 117 t = space(); 118 tbody = element("tbody"); 119 120 for (let i = 0; i < each_blocks.length; i += 1) { 121 each_blocks[i].c(); 122 } 123 124 attr(tr, "class", "tr-head svelte-13hsdno"); 125 attr(table, "tabindex", "0"); 126 attr(table, "role", "grid"); 127 attr(table, "class", "svelte-13hsdno"); 128 attr(div, "class", "table-wrap svelte-13hsdno"); 129 }, 130 m(target, anchor) { 131 insert(target, div, anchor); 132 append(div, table); 133 append(table, thead); 134 append(thead, tr); 135 136 for (let i = 0; i < each_blocks_1.length; i += 1) { 137 if (each_blocks_1[i]) { 138 each_blocks_1[i].m(tr, null); 139 } 140 } 141 142 append(table, t); 143 append(table, tbody); 144 145 for (let i = 0; i < each_blocks.length; i += 1) { 146 if (each_blocks[i]) { 147 each_blocks[i].m(tbody, null); 148 } 149 } 150 151 current = true; 152 }, 153 p(ctx, dirty) { 154 if (dirty[0] & /*headers*/ 32) { 155 each_value_4 = ensure_array_like(/*headers*/ ctx[5]); 156 let i; 157 158 for (i = 0; i < each_value_4.length; i += 1) { 159 const child_ctx = get_each_context_4(ctx, each_value_4, i); 160 161 if (each_blocks_1[i]) { 162 each_blocks_1[i].p(child_ctx, dirty); 163 } else { 164 each_blocks_1[i] = create_each_block_4(child_ctx); 165 each_blocks_1[i].c(); 166 each_blocks_1[i].m(tr, null); 167 } 168 } 169 170 for (; i < each_blocks_1.length; i += 1) { 171 each_blocks_1[i].d(1); 172 } 173 174 each_blocks_1.length = each_value_4.length; 175 } 176 177 if (dirty[0] & /*value, page, samples_per_page, gradio, handle_mouseenter, handle_mouseleave, component_meta, components, component_props, samples_dir, current_hover, component_map*/ 7025167) { 178 each_value_2 = ensure_array_like(/*component_meta*/ ctx[17]); 179 let i; 180 181 for (i = 0; i < each_value_2.length; i += 1) { 182 const child_ctx = get_each_context_2(ctx, each_value_2, i); 183 184 if (each_blocks[i]) { 185 each_blocks[i].p(child_ctx, dirty); 186 transition_in(each_blocks[i], 1); 187 } else { 188 each_blocks[i] = create_each_block_2(child_ctx); 189 each_blocks[i].c(); 190 transition_in(each_blocks[i], 1); 191 each_blocks[i].m(tbody, null); 192 } 193 } 194 195 group_outros(); 196 197 for (i = each_value_2.length; i < each_blocks.length; i += 1) { 198 out(i); 199 } 200 201 check_outros(); 202 } 203 }, 204 i(local) { 205 if (current) return; 206 207 for (let i = 0; i < each_value_2.length; i += 1) { 208 transition_in(each_blocks[i]); 209 } 210 211 current = true; 212 }, 213 o(local) {
214 each_blocks = each_blocks.filter(Boolean); 215 216 for (let i = 0; i < each_blocks.length; i += 1) { 217 transition_out(each_blocks[i]); 218 } 219 220 current = false; 221 }, 222 d(detaching) { 223 if (detaching) { 224 detach(div); 225 } 226 227 destroy_each(each_blocks_1, detaching); 228 destroy_each(each_blocks, detaching); 229 } 230 }; 231} 232 233// (98:1) {#if gallery} 234function create_if_block_2(ctx) { 235 let div; 236 let current; 237 let each_value_1 = ensure_array_like(/*selected_samples*/ ctx[14]); 238 let each_blocks = []; 239 240 for (let i = 0; i < each_value_1.length; i += 1) { 241 each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); 242 } 243 244 const out = i => transition_out(each_blocks[i], 1, 1, () => { 245 each_blocks[i] = null; 246 }); 247 248 return { 249 c() { 250 div = element("div"); 251 252 for (let i = 0; i < each_blocks.length; i += 1) { 253 each_blocks[i].c(); 254 } 255 256 attr(div, "class", "gallery svelte-13hsdno"); 257 }, 258 m(target, anchor) { 259 insert(target, div, anchor); 260 261 for (let i = 0; i < each_blocks.length; i += 1) { 262 if (each_blocks[i]) { 263 each_blocks[i].m(div, null); 264 } 265 } 266 267 current = true; 268 }, 269 p(ctx, dirty) { 270 if (dirty[0] & /*value, page, samples_per_page, gradio, selected_samples, handle_mouseenter, handle_mouseleave, component_meta, component_props, samples_dir, current_hover, component_map, components*/ 7041551) { 271 each_value_1 = ensure_array_like(/*selected_samples*/ ctx[14]); 272 let i; 273 274 for (i = 0; i < each_value_1.length; i += 1) { 275 const child_ctx = get_each_context_1(ctx, each_value_1, i); 276 277 if (each_blocks[i]) { 278 each_blocks[i].p(child_ctx, dirty); 279 transition_in(each_blocks[i], 1); 280 } else { 281 each_blocks[i] = create_each_block_1(child_ctx); 282 each_blocks[i].c(); 283 transition_in(each_blocks[i], 1); 284 each_blocks[i].m(div, null); 285 } 286 } 287 288 group_outros(); 289 290 for (i = each_value_1.length; i < each_blocks.length; i += 1) { 291 out(i); 292 } 293 294 check_outros(); 295 } 296 }, 297 i(local) { 298 if (current) return; 299 300 for (let i = 0; i < each_value_1.length; i += 1) { 301 transition_in(each_blocks[i]); 302 } 303 304 current = true; 305 }, 306 o(local) {
307 each_blocks = each_blocks.filter(Boolean); 308 309 for (let i = 0; i < each_blocks.length; i += 1) { 310 transition_out(each_blocks[i]); 311 } 312 313 current = false; 314 }, 315 d(detaching) { 316 if (detaching) { 317 detach(div); 318 } 319 320 destroy_each(each_blocks, detaching); 321 } 322 }; 323} 324 325// (132:6) {#each headers as header} 326function create_each_block_4(ctx) { 327 let th; 328 let t0_value = /*header*/ ctx[46] + ""; 329 let t0; 330 let t1; 331 332 return { 333 c() { 334 th = element("th"); 335 t0 = text(t0_value); 336 t1 = space(); 337 attr(th, "class", "svelte-13hsdno"); 338 }, 339 m(target, anchor) { 340 insert(target, th, anchor); 341 append(th, t0); 342 append(th, t1); 343 }, 344 p(ctx, dirty) { 345 if (dirty[0] & /*headers*/ 32 && t0_value !== (t0_value = /*header*/ ctx[46] + "")) set_data(t0, t0_value); 346 }, 347 d(detaching) { 348 if (detaching) { 349 detach(th); 350 } 351 } 352 }; 353} 354 355// (152:8) {#if component_name !== undefined && component_map.get(component_name) !== undefined} 356function create_if_block_5(ctx) { 357 let td; 358 let switch_instance; 359 let td_class_value; 360 let current; 361 362 const switch_instance_spread_levels = [ 363 /*component_props*/ ctx[2][/*j*/ ctx[45]], 364 { value: /*value*/ ctx[0] }, 365 { samples_dir: /*samples_dir*/ ctx[19] }, 366 { type: "table" }, 367 { 368 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 369 }, 370 { index: /*i*/ ctx[40] } 371 ]; 372 373 var switch_value = /*component*/ ctx[42]; 374 375 function switch_props(ctx, dirty) { 376 let switch_instance_props = {}; 377
378 if (dirty !== undefined && dirty[0] & /*component_props, component_meta, samples_dir, current_hover*/ 720900) { 379 switch_instance_props = get_spread_update(switch_instance_spread_levels, [ 380 dirty[0] & /*component_props*/ 4 && get_spread_object(/*component_props*/ ctx[2][/*j*/ ctx[45]]), 381 dirty[0] & /*component_meta*/ 131072 && { value: /*value*/ ctx[0] }, 382 dirty[0] & /*samples_dir*/ 524288 && { samples_dir: /*samples_dir*/ ctx[19] }, 383 switch_instance_spread_levels[3], 384 dirty[0] & /*current_hover*/ 65536 && { 385 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 386 }, 387 switch_instance_spread_levels[5] 388 ]); 389 } else { 390 for (let i = 0; i < switch_instance_spread_levels.length; i += 1) { 391 switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]); 392 } 393 } 394 395 return { props: switch_instance_props }; 396 } 397 398 if (switch_value) { 399 switch_instance = construct_svelte_component(switch_value, switch_props(ctx)); 400 } 401 402 return { 403 c() { 404 td = element("td"); 405 if (switch_instance) create_component(switch_instance.$$.fragment); 406 407 set_style(td, "max-width", /*component_name*/ ctx[43] === 'textbox' 408 ? '35ch' 409 : 'auto'); 410 411 attr(td, "class", td_class_value = "" + (null_to_empty(/*component_name*/ ctx[43]) + " svelte-13hsdno")); 412 }, 413 m(target, anchor) { 414 insert(target, td, anchor); 415 if (switch_instance) mount_component(switch_instance, td, null); 416 current = true; 417 }, 418 p(ctx, dirty) { 419 if (dirty[0] & /*component_meta*/ 131072 && switch_value !== (switch_value = /*component*/ ctx[42])) { 420 if (switch_instance) { 421 group_outros(); 422 const old_component = switch_instance; 423 424 transition_out(old_component.$$.fragment, 1, 0, () => { 425 destroy_component(old_component, 1); 426 }); 427 428 check_outros(); 429 } 430 431 if (switch_value) { 432 switch_instance = construct_svelte_component(switch_value, switch_props(ctx, dirty)); 433 create_component(switch_instance.$$.fragment); 434 transition_in(switch_instance.$$.fragment, 1); 435 mount_component(switch_instance, td, null); 436 } else { 437 switch_instance = null; 438 } 439 } else if (switch_value) { 440 const switch_instance_changes = (dirty[0] & /*component_props, component_meta, samples_dir, current_hover*/ 720900) 441 ? get_spread_update(switch_instance_spread_levels, [ 442 dirty[0] & /*component_props*/ 4 && get_spread_object(/*component_props*/ ctx[2][/*j*/ ctx[45]]), 443 dirty[0] & /*component_meta*/ 131072 && { value: /*value*/ ctx[0] }, 444 dirty[0] & /*samples_dir*/ 524288 && { samples_dir: /*samples_dir*/ ctx[19] }, 445 switch_instance_spread_levels[3], 446 dirty[0] & /*current_hover*/ 65536 && { 447 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 448 }, 449 switch_instance_spread_levels[5] 450 ]) 451 : {}; 452 453 switch_instance.$set(switch_instance_changes); 454 } 455 456 if (!current || dirty[0] & /*components*/ 2) { 457 set_style(td, "max-width", /*component_name*/ ctx[43] === 'textbox' 458 ? '35ch' 459 : 'auto'); 460 } 461 462 if (!current || dirty[0] & /*components*/ 2 && td_class_value !== (td_class_value = "" + (null_to_empty(/*component_name*/ ctx[43]) + " svelte-13hsdno"))) { 463 attr(td, "class", td_class_value); 464 } 465 }, 466 i(local) { 467 if (current) return; 468 if (switch_instance) transition_in(switch_instance.$$.fragment, local); 469 current = true; 470 }, 471 o(local) { 472 if (switch_instance) transition_out(switch_instance.$$.fragment, local); 473 current = false; 474 }, 475 d(detaching) { 476 if (detaching) { 477 detach(td); 478 } 479 480 if (switch_instance) destroy_component(switch_instance); 481 } 482 }; 483} 484 485// (150:7) {#each sample_row as { value, component } 486function create_each_block_3(ctx) { 487 let show_if = /*component_name*/ ctx[43] !== undefined && /*component_map*/ ctx[3].get(/*component_name*/ ctx[43]) !== undefined; 488 let if_block_anchor; 489 let current; 490 let if_block = show_if && create_if_block_5(ctx); 491 492 return { 493 c() { 494 if (if_block) if_block.c(); 495 if_block_anchor = empty(); 496 }, 497 m(target, anchor) { 498 if (if_block) if_block.m(target, anchor); 499 insert(target, if_block_anchor, anchor); 500 current = true; 501 }, 502 p(ctx, dirty) {
503 if (dirty[0] & /*components, component_map*/ 10) show_if = /*component_name*/ ctx[43] !== undefined && /*component_map*/ ctx[3].get(/*component_name*/ ctx[43]) !== undefined; 504 505 if (show_if) { 506 if (if_block) { 507 if_block.p(ctx, dirty); 508 509 if (dirty[0] & /*components, component_map*/ 10) { 510 transition_in(if_block, 1); 511 } 512 } else { 513 if_block = create_if_block_5(ctx); 514 if_block.c(); 515 transition_in(if_block, 1); 516 if_block.m(if_block_anchor.parentNode, if_block_anchor); 517 } 518 } else if (if_block) { 519 group_outros(); 520 521 transition_out(if_block, 1, 1, () => { 522 if_block = null; 523 }); 524 525 check_outros(); 526 } 527 }, 528 i(local) { 529 if (current) return; 530 transition_in(if_block); 531 current = true; 532 }, 533 o(local) { 534 transition_out(if_block); 535 current = false; 536 }, 537 d(detaching) { 538 if (detaching) { 539 detach(if_block_anchor); 540 } 541 542 if (if_block) if_block.d(detaching); 543 } 544 }; 545} 546 547// (140:5) {#each component_meta as sample_row, i} 548function create_each_block_2(ctx) { 549 let tr; 550 let t; 551 let current; 552 let mounted; 553 let dispose; 554 let each_value_3 = ensure_array_like(/*sample_row*/ ctx[38]); 555 let each_blocks = []; 556 557 for (let i = 0; i < each_value_3.length; i += 1) { 558 each_blocks[i] = create_each_block_3(get_each_context_3(ctx, each_value_3, i)); 559 } 560 561 const out = i => transition_out(each_blocks[i], 1, 1, () => { 562 each_blocks[i] = null; 563 }); 564 565 function click_handler_1() { 566 return /*click_handler_1*/ ctx[30](/*i*/ ctx[40]); 567 } 568 569 function mouseenter_handler_1() { 570 return /*mouseenter_handler_1*/ ctx[31](/*i*/ ctx[40]); 571 } 572 573 return { 574 c() { 575 tr = element("tr"); 576 577 for (let i = 0; i < each_blocks.length; i += 1) { 578 each_blocks[i].c(); 579 } 580 581 t = space(); 582 attr(tr, "class", "tr-body svelte-13hsdno"); 583 }, 584 m(target, anchor) { 585 insert(target, tr, anchor); 586 587 for (let i = 0; i < each_blocks.length; i += 1) { 588 if (each_blocks[i]) { 589 each_blocks[i].m(tr, null); 590 } 591 } 592 593 append(tr, t); 594 current = true; 595 596 if (!mounted) { 597 dispose = [ 598 listen(tr, "click", click_handler_1), 599 listen(tr, "mouseenter", mouseenter_handler_1), 600 listen(tr, "mouseleave", /*mouseleave_handler_1*/ ctx[32]) 601 ]; 602 603 mounted = true; 604 } 605 }, 606 p(new_ctx, dirty) { 607 ctx = new_ctx; 608 609 if (dirty[0] & /*components, component_meta, component_props, samples_dir, current_hover, component_map*/ 720910) { 610 each_value_3 = ensure_array_like(/*sample_row*/ ctx[38]); 611 let i; 612 613 for (i = 0; i < each_value_3.length; i += 1) { 614 const child_ctx = get_each_context_3(ctx, each_value_3, i); 615 616 if (each_blocks[i]) { 617 each_blocks[i].p(child_ctx, dirty); 618 transition_in(each_blocks[i], 1); 619 } else { 620 each_blocks[i] = create_each_block_3(child_ctx); 621 each_blocks[i].c(); 622 transition_in(each_blocks[i], 1); 623 each_blocks[i].m(tr, t); 624 } 625 } 626 627 group_outros(); 628 629 for (i = each_value_3.length; i < each_blocks.length; i += 1) { 630 out(i); 631 } 632 633 check_outros(); 634 } 635 }, 636 i(local) { 637 if (current) return; 638 639 for (let i = 0; i < each_value_3.length; i += 1) { 640 transition_in(each_blocks[i]); 641 } 642 643 current = true; 644 }, 645 o(local) {
646 each_blocks = each_blocks.filter(Boolean); 647 648 for (let i = 0; i < each_blocks.length; i += 1) { 649 transition_out(each_blocks[i]); 650 } 651 652 current = false; 653 }, 654 d(detaching) { 655 if (detaching) { 656 detach(tr); 657 } 658 659 destroy_each(each_blocks, detaching); 660 mounted = false; 661 run_all(dispose); 662 } 663 }; 664} 665 666// (101:4) {#if sample_row[0]} 667function create_if_block_3(ctx) { 668 let button; 669 let show_if = /*component_meta*/ ctx[17].length && /*component_map*/ ctx[3].get(/*components*/ ctx[1][0]); 670 let t; 671 let current; 672 let mounted; 673 let dispose; 674 let if_block = show_if && create_if_block_4(ctx); 675 676 function click_handler() { 677 return /*click_handler*/ ctx[27](/*i*/ ctx[40], /*sample_row*/ ctx[38]); 678 } 679 680 function mouseenter_handler() { 681 return /*mouseenter_handler*/ ctx[28](/*i*/ ctx[40]); 682 } 683 684 return { 685 c() { 686 button = element("button"); 687 if (if_block) if_block.c(); 688 t = space(); 689 attr(button, "class", "gallery-item svelte-13hsdno"); 690 }, 691 m(target, anchor) { 692 insert(target, button, anchor); 693 if (if_block) if_block.m(button, null); 694 append(button, t); 695 current = true; 696 697 if (!mounted) { 698 dispose = [ 699 listen(button, "click", click_handler), 700 listen(button, "mouseenter", mouseenter_handler), 701 listen(button, "mouseleave", /*mouseleave_handler*/ ctx[29]) 702 ]; 703 704 mounted = true; 705 } 706 }, 707 p(new_ctx, dirty) { 708 ctx = new_ctx; 709 if (dirty[0] & /*component_meta, component_map, components*/ 131082) show_if = /*component_meta*/ ctx[17].length && /*component_map*/ ctx[3].get(/*components*/ ctx[1][0]); 710 711 if (show_if) { 712 if (if_block) { 713 if_block.p(ctx, dirty); 714 715 if (dirty[0] & /*component_meta, component_map, components*/ 131082) { 716 transition_in(if_block, 1); 717 } 718 } else { 719 if_block = create_if_block_4(ctx); 720 if_block.c(); 721 transition_in(if_block, 1); 722 if_block.m(button, t); 723 } 724 } else if (if_block) { 725 group_outros(); 726 727 transition_out(if_block, 1, 1, () => { 728 if_block = null; 729 }); 730 731 check_outros(); 732 } 733 }, 734 i(local) { 735 if (current) return; 736 transition_in(if_block); 737 current = true; 738 }, 739 o(local) { 740 transition_out(if_block); 741 current = false; 742 }, 743 d(detaching) { 744 if (detaching) { 745 detach(button); 746 } 747 748 if (if_block) if_block.d(); 749 mounted = false; 750 run_all(dispose); 751 } 752 }; 753} 754 755// (112:6) {#if component_meta.length && component_map.get(components[0])} 756function create_if_block_4(ctx) { 757 let switch_instance; 758 let switch_instance_anchor; 759 let current; 760 761 const switch_instance_spread_levels = [ 762 /*component_props*/ ctx[2][0], 763 { value: /*sample_row*/ ctx[38][0] }, 764 { samples_dir: /*samples_dir*/ ctx[19] }, 765 { type: "gallery" }, 766 { 767 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 768 }, 769 { index: /*i*/ ctx[40] } 770 ]; 771 772 var switch_value = /*component_meta*/ ctx[17][0][0].component; 773 774 function switch_props(ctx, dirty) { 775 let switch_instance_props = {}; 776
777 if (dirty !== undefined && dirty[0] & /*component_props, selected_samples, samples_dir, current_hover*/ 606212) { 778 switch_instance_props = get_spread_update(switch_instance_spread_levels, [ 779 dirty[0] & /*component_props*/ 4 && get_spread_object(/*component_props*/ ctx[2][0]), 780 dirty[0] & /*selected_samples*/ 16384 && { value: /*sample_row*/ ctx[38][0] }, 781 dirty[0] & /*samples_dir*/ 524288 && { samples_dir: /*samples_dir*/ ctx[19] }, 782 switch_instance_spread_levels[3], 783 dirty[0] & /*current_hover*/ 65536 && { 784 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 785 }, 786 switch_instance_spread_levels[5] 787 ]); 788 } else { 789 for (let i = 0; i < switch_instance_spread_levels.length; i += 1) { 790 switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]); 791 } 792 } 793 794 return { props: switch_instance_props }; 795 } 796 797 if (switch_value) { 798 switch_instance = construct_svelte_component(switch_value, switch_props(ctx)); 799 } 800 801 return { 802 c() { 803 if (switch_instance) create_component(switch_instance.$$.fragment); 804 switch_instance_anchor = empty(); 805 }, 806 m(target, anchor) { 807 if (switch_instance) mount_component(switch_instance, target, anchor); 808 insert(target, switch_instance_anchor, anchor); 809 current = true; 810 }, 811 p(ctx, dirty) { 812 if (dirty[0] & /*component_meta*/ 131072 && switch_value !== (switch_value = /*component_meta*/ ctx[17][0][0].component)) { 813 if (switch_instance) { 814 group_outros(); 815 const old_component = switch_instance; 816 817 transition_out(old_component.$$.fragment, 1, 0, () => { 818 destroy_component(old_component, 1); 819 }); 820 821 check_outros(); 822 } 823 824 if (switch_value) { 825 switch_instance = construct_svelte_component(switch_value, switch_props(ctx, dirty)); 826 create_component(switch_instance.$$.fragment); 827 transition_in(switch_instance.$$.fragment, 1); 828 mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor); 829 } else { 830 switch_instance = null; 831 } 832 } else if (switch_value) { 833 const switch_instance_changes = (dirty[0] & /*component_props, selected_samples, samples_dir, current_hover*/ 606212) 834 ? get_spread_update(switch_instance_spread_levels, [ 835 dirty[0] & /*component_props*/ 4 && get_spread_object(/*component_props*/ ctx[2][0]), 836 dirty[0] & /*selected_samples*/ 16384 && { value: /*sample_row*/ ctx[38][0] }, 837 dirty[0] & /*samples_dir*/ 524288 && { samples_dir: /*samples_dir*/ ctx[19] }, 838 switch_instance_spread_levels[3], 839 dirty[0] & /*current_hover*/ 65536 && { 840 selected: /*current_hover*/ ctx[16] === /*i*/ ctx[40] 841 }, 842 switch_instance_spread_levels[5] 843 ]) 844 : {}; 845 846 switch_instance.$set(switch_instance_changes); 847 } 848 }, 849 i(local) { 850 if (current) return; 851 if (switch_instance) transition_in(switch_instance.$$.fragment, local); 852 current = true; 853 }, 854 o(local) { 855 if (switch_instance) transition_out(switch_instance.$$.fragment, local); 856 current = false; 857 }, 858 d(detaching) { 859 if (detaching) { 860 detach(switch_instance_anchor); 861 } 862 863 if (switch_instance) destroy_component(switch_instance, detaching); 864 } 865 }; 866} 867 868// (100:3) {#each selected_samples as sample_row, i} 869function create_each_block_1(ctx) { 870 let if_block_anchor; 871 let current; 872 let if_block = /*sample_row*/ ctx[38][0] && create_if_block_3(ctx); 873 874 return { 875 c() { 876 if (if_block) if_block.c(); 877 if_block_anchor = empty(); 878 }, 879 m(target, anchor) { 880 if (if_block) if_block.m(target, anchor); 881 insert(target, if_block_anchor, anchor); 882 current = true; 883 }, 884 p(ctx, dirty) { 885 if (/*sample_row*/ ctx[38][0]) { 886 if (if_block) { 887 if_block.p(ctx, dirty); 888 889 if (dirty[0] & /*selected_samples*/ 16384) { 890 transition_in(if_block, 1); 891 } 892 } else { 893 if_block = create_if_block_3(ctx); 894 if_block.c(); 895 transition_in(if_block, 1); 896 if_block.m(if_block_anchor.parentNode, if_block_anchor); 897 } 898 } else if (if_block) { 899 group_outros(); 900 901 transition_out(if_block, 1, 1, () => { 902 if_block = null; 903 }); 904 905 check_outros(); 906 } 907 }, 908 i(local) { 909 if (current) return; 910 transition_in(if_block); 911 current = true; 912 }, 913 o(local) { 914 transition_out(if_block); 915 current = false;
916 }, 917 d(detaching) { 918 if (detaching) { 919 detach(if_block_anchor); 920 } 921 922 if (if_block) if_block.d(detaching); 923 } 924 }; 925} 926 927// (177:1) {#if paginate} 928function create_if_block(ctx) { 929 let div; 930 let t; 931 let each_value = ensure_array_like(/*visible_pages*/ ctx[15]); 932 let each_blocks = []; 933 934 for (let i = 0; i < each_value.length; i += 1) { 935 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 936 } 937 938 return { 939 c() { 940 div = element("div"); 941 t = text("Pages:\n\t\t\t"); 942 943 for (let i = 0; i < each_blocks.length; i += 1) { 944 each_blocks[i].c(); 945 } 946 947 attr(div, "class", "paginate svelte-13hsdno"); 948 }, 949 m(target, anchor) { 950 insert(target, div, anchor); 951 append(div, t); 952 953 for (let i = 0; i < each_blocks.length; i += 1) { 954 if (each_blocks[i]) { 955 each_blocks[i].m(div, null); 956 } 957 } 958 }, 959 p(ctx, dirty) { 960 if (dirty[0] & /*visible_pages, page*/ 40960) { 961 each_value = ensure_array_like(/*visible_pages*/ ctx[15]); 962 let i; 963 964 for (i = 0; i < each_value.length; i += 1) { 965 const child_ctx = get_each_context(ctx, each_value, i); 966 967 if (each_blocks[i]) { 968 each_blocks[i].p(child_ctx, dirty); 969 } else { 970 each_blocks[i] = create_each_block(child_ctx); 971 each_blocks[i].c(); 972 each_blocks[i].m(div, null); 973 } 974 } 975 976 for (; i < each_blocks.length; i += 1) { 977 each_blocks[i].d(1); 978 } 979 980 each_blocks.length = each_value.length; 981 } 982 }, 983 d(detaching) { 984 if (detaching) { 985 detach(div); 986 } 987 988 destroy_each(each_blocks, detaching); 989 } 990 }; 991} 992 993// (183:4) {:else} 994function create_else_block(ctx) { 995 let button; 996 let t0_value = /*visible_page*/ ctx[35] + 1 + ""; 997 let t0; 998 let t1; 999 let mounted; 1000 let dispose; 1001 1002 function click_handler_2() { 1003 return /*click_handler_2*/ ctx[33](/*visible_page*/ ctx[35]); 1004 } 1005 1006 return { 1007 c() { 1008 button = element("button"); 1009 t0 = text(t0_value); 1010 t1 = space(); 1011 attr(button, "class", "svelte-13hsdno"); 1012 toggle_class(button, "current-page", /*page*/ ctx[13] === /*visible_page*/ ctx[35]); 1013 }, 1014 m(target, anchor) { 1015 insert(target, button, anchor); 1016 append(button, t0); 1017 append(button, t1); 1018 1019 if (!mounted) { 1020 dispose = listen(button, "click", click_handler_2); 1021 mounted = true; 1022 } 1023 }, 1024 p(new_ctx, dirty) { 1025 ctx = new_ctx; 1026 if (dirty[0] & /*visible_pages*/ 32768 && t0_value !== (t0_value = /*visible_page*/ ctx[35] + 1 + "")) set_data(t0, t0_value); 1027 1028 if (dirty[0] & /*page, visible_pages*/ 40960) { 1029 toggle_class(button, "current-page", /*page*/ ctx[13] === /*visible_page*/ ctx[35]); 1030 } 1031 }, 1032 d(detaching) { 1033 if (detaching) { 1034 detach(button); 1035 } 1036 1037 mounted = false; 1038 dispose(); 1039 } 1040 }; 1041} 1042 1043// (181:4) {#if visible_page === -1} 1044function create_if_block_1(ctx) { 1045 let div; 1046 1047 return { 1048 c() { 1049 div = element("div"); 1050 div.textContent = "..."; 1051 }, 1052 m(target, anchor) { 1053 insert(target, div, anchor); 1054 }, 1055 p: noop, 1056 d(detaching) { 1057 if (detaching) { 1058 detach(div); 1059 } 1060 } 1061 }; 1062} 1063 1064// (180:3) {#each visible_pages as visible_page} 1065function create_each_block(ctx) { 1066 let if_block_anchor; 1067 1068 function select_block_type_1(ctx, dirty) { 1069 if (/*visible_page*/ ctx[35] === -1) return create_if_block_1; 1070 return create_else_block; 1071 } 1072 1073 let current_block_type = select_block_type_1(ctx); 1074 let if_block = current_block_type(ctx); 1075 1076 return { 1077 c() { 1078 if_block.c(); 1079 if_block_anchor = empty(); 1080 }, 1081 m(target, anchor) { 1082 if_block.m(target, anchor); 1083 insert(target, if_block_anchor, anchor); 1084 }, 1085 p(ctx, dirty) { 1086 if (current_block_type === (current_block_type = select_block_type_1(ctx)) && if_block) { 1087 if_block.p(ctx, dirty); 1088 } else { 1089 if_block.d(1); 1090 if_block = current_block_type(ctx); 1091 1092 if (if_block) { 1093 if_block.c(); 1094 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1095 } 1096 } 1097 }, 1098 d(detaching) { 1099 if (detaching) { 1100 detach(if_block_anchor); 1101 } 1102 1103 if_block.d(detaching); 1104 } 1105 }; 1106} 1107 1108// (70:0) <Block {visible} padding={false} {elem_id} {elem_classes} {scale} {min_width} allow_overflow={false} container={false} > 1109function create_default_slot(ctx) { 1110 let div; 1111 let svg; 1112 let path; 1113 let t0; 1114 let t1; 1115 let t2; 1116 let current_block_type_index; 1117 let if_block0; 1118 let t3; 1119 let if_block1_anchor; 1120 let current; 1121 const if_block_creators = [create_if_block_2, create_else_block_1]; 1122 const if_blocks = []; 1123 1124 function select_block_type(ctx, dirty) { 1125 if (/*gallery*/ ctx[18]) return 0; 1126 return 1; 1127 } 1128 1129 current_block_type_index = select_block_type(ctx); 1130 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1131 let if_block1 = /*paginate*/ ctx[20] && create_if_block(ctx); 1132 1133 return { 1134 c() { 1135 div = element("div");
1136 svg = svg_element("svg"); 1137 path = svg_element("path"); 1138 t0 = space(); 1139 t1 = text(/*label*/ ctx[4]); 1140 t2 = space(); 1141 if_block0.c(); 1142 t3 = space(); 1143 if (if_block1) if_block1.c(); 1144 if_block1_anchor = empty(); 1145 attr(path, "fill", "currentColor"); 1146 attr(path, "d", "M10 6h18v2H10zm0 18h18v2H10zm0-9h18v2H10zm-6 0h2v2H4zm0-9h2v2H4zm0 18h2v2H4z"); 1147 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 1148 attr(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink"); 1149 attr(svg, "aria-hidden", "true"); 1150 attr(svg, "role", "img"); 1151 attr(svg, "width", "1em"); 1152 attr(svg, "height", "1em"); 1153 attr(svg, "preserveAspectRatio", "xMidYMid meet"); 1154 attr(svg, "viewBox", "0 0 32 32"); 1155 attr(svg, "class", "svelte-13hsdno"); 1156 attr(div, "class", "label svelte-13hsdno"); 1157 }, 1158 m(target, anchor) { 1159 insert(target, div, anchor); 1160 append(div, svg); 1161 append(svg, path); 1162 append(div, t0); 1163 append(div, t1); 1164 insert(target, t2, anchor); 1165 if_blocks[current_block_type_index].m(target, anchor); 1166 insert(target, t3, anchor); 1167 if (if_block1) if_block1.m(target, anchor); 1168 insert(target, if_block1_anchor, anchor); 1169 current = true; 1170 }, 1171 p(ctx, dirty) { 1172 if (!current || dirty[0] & /*label*/ 16) set_data(t1, /*label*/ ctx[4]); 1173 let previous_block_index = current_block_type_index; 1174 current_block_type_index = select_block_type(ctx); 1175 1176 if (current_block_type_index === previous_block_index) { 1177 if_blocks[current_block_type_index].p(ctx, dirty); 1178 } else { 1179 group_outros(); 1180 1181 transition_out(if_blocks[previous_block_index], 1, 1, () => { 1182 if_blocks[previous_block_index] = null; 1183 }); 1184 1185 check_outros(); 1186 if_block0 = if_blocks[current_block_type_index]; 1187 1188 if (!if_block0) { 1189 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1190 if_block0.c(); 1191 } else { 1192 if_block0.p(ctx, dirty); 1193 } 1194 1195 transition_in(if_block0, 1); 1196 if_block0.m(t3.parentNode, t3); 1197 } 1198 1199 if (/*paginate*/ ctx[20]) if_block1.p(ctx, dirty); 1200 }, 1201 i(local) { 1202 if (current) return; 1203 transition_in(if_block0); 1204 current = true; 1205 }, 1206 o(local) { 1207 transition_out(if_block0); 1208 current = false; 1209 }, 1210 d(detaching) { 1211 if (detaching) { 1212 detach(div); 1213 detach(t2); 1214 detach(t3); 1215 detach(if_block1_anchor); 1216 } 1217 1218 if_blocks[current_block_type_index].d(detaching); 1219 if (if_block1) if_block1.d(detaching); 1220 } 1221 }; 1222} 1223 1224function create_fragment(ctx) { 1225 let block; 1226 let current; 1227 1228 block = new Block({ 1229 props: { 1230 visible: /*visible*/ ctx[8], 1231 padding: false, 1232 elem_id: /*elem_id*/ ctx[6], 1233 elem_classes: /*elem_classes*/ ctx[7], 1234 scale: /*scale*/ ctx[10], 1235 min_width: /*min_width*/ ctx[11], 1236 allow_overflow: false, 1237 container: false, 1238 $$slots: { default: [create_default_slot] }, 1239 $$scope: { ctx } 1240 } 1241 }); 1242 1243 return { 1244 c() { 1245 create_component(block.$$.fragment); 1246 }, 1247 m(target, anchor) { 1248 mount_component(block, target, anchor); 1249 current = true; 1250 }, 1251 p(ctx, dirty) { 1252 const block_changes = {}; 1253 if (dirty[0] & /*visible*/ 256) block_changes.visible = /*visible*/ ctx[8]; 1254 if (dirty[0] & /*elem_id*/ 64) block_changes.elem_id = /*elem_id*/ ctx[6]; 1255 if (dirty[0] & /*elem_classes*/ 128) block_changes.elem_classes = /*elem_classes*/ ctx[7]; 1256 if (dirty[0] & /*scale*/ 1024) block_changes.scale = /*scale*/ ctx[10]; 1257 if (dirty[0] & /*min_width*/ 2048) block_changes.min_width = /*min_width*/ ctx[11]; 1258 1259 if (dirty[0] & /*visible_pages, page, selected_samples, value, samples_per_page, gradio, component_meta, component_props, current_hover, component_map, components, gallery, headers, label*/ 520767 | dirty[1] & /*$$scope*/ 262144) { 1260 block_changes.$$scope = { dirty, ctx }; 1261 } 1262 1263 block.$set(block_changes); 1264 }, 1265 i(local) { 1266 if (current) return; 1267 transition_in(block.$$.fragment, local); 1268 current = true; 1269 }, 1270 o(local) { 1271 transition_out(block.$$.fragment, local); 1272 current = false; 1273 }, 1274 d(detaching) { 1275 destroy_component(block, detaching); 1276 } 1277 }; 1278} 1279 1280function instance($$self, $$props, $$invalidate) { 1281 let gallery; 1282 let { components } = $$props; 1283 let { component_props } = $$props; 1284 let { component_map } = $$props; 1285 let { label = "Examples" } = $$props; 1286 let { headers } = $$props; 1287 let { samples } = $$props; 1288 let { elem_id = "" } = $$props; 1289 let { elem_classes = [] } = $$props; 1290 let { visible = true } = $$props; 1291 let { value = null } = $$props; 1292 let { root } = $$props; 1293 let { proxy_url } = $$props; 1294 let { samples_per_page = 10 } = $$props; 1295 let { scale = null } = $$props; 1296 let { min_width = undefined } = $$props; 1297 let { gradio } = $$props; 1298 1299 // Although the `samples_dir` prop is not used in any of the core Gradio component, it is kept for backward compatibility 1300 // with any custom components created with gradio<=4.20.0 1301 let samples_dir = proxy_url ? `/proxy=${proxy_url}file=` : `${root}/file=`; 1302 1303 let page = 0; 1304 let paginate = samples.length > samples_per_page; 1305 let selected_samples; 1306 let page_count; 1307 let visible_pages = []; 1308 let current_hover = -1; 1309 1310 function handle_mouseenter(i) {
1311 $$invalidate(16, current_hover = i); 1312 } 1313 1314 function handle_mouseleave() { 1315 $$invalidate(16, current_hover = -1); 1316 } 1317 1318 let component_meta = []; 1319 1320 async function get_component_meta(selected_samples) { 1321 $$invalidate(17, component_meta = await Promise.all(selected_samples.map(async sample_row => await Promise.all(sample_row.map(async (sample_cell, j) => { 1322 return { 1323 value: sample_cell, 1324 component: (await component_map.get(components[j]))?.component?.default 1325 }; 1326 }))))); 1327 } 1328 1329 const click_handler = (i, sample_row) => { 1330 $$invalidate(0, value = i + page * samples_per_page); 1331 gradio.dispatch("click", value); 1332 gradio.dispatch("select", { index: value, value: sample_row }); 1333 }; 1334 1335 const mouseenter_handler = i => handle_mouseenter(i); 1336 const mouseleave_handler = () => handle_mouseleave(); 1337 1338 const click_handler_1 = i => { 1339 $$invalidate(0, value = i + page * samples_per_page); 1340 gradio.dispatch("click", value); 1341 }; 1342 1343 const mouseenter_handler_1 = i => handle_mouseenter(i); 1344 const mouseleave_handler_1 = () => handle_mouseleave(); 1345 const click_handler_2 = visible_page => $$invalidate(13, page = visible_page); 1346 1347 $$self.$$set = $$props => {
1348 if ('components' in $$props) $$invalidate(1, components = $$props.components); 1349 if ('component_props' in $$props) $$invalidate(2, component_props = $$props.component_props); 1350 if ('component_map' in $$props) $$invalidate(3, component_map = $$props.component_map); 1351 if ('label' in $$props) $$invalidate(4, label = $$props.label); 1352 if ('headers' in $$props) $$invalidate(5, headers = $$props.headers); 1353 if ('samples' in $$props) $$invalidate(23, samples = $$props.samples); 1354 if ('elem_id' in $$props) $$invalidate(6, elem_id = $$props.elem_id); 1355 if ('elem_classes' in $$props) $$invalidate(7, elem_classes = $$props.elem_classes); 1356 if ('visible' in $$props) $$invalidate(8, visible = $$props.visible); 1357 if ('value' in $$props) $$invalidate(0, value = $$props.value); 1358 if ('root' in $$props) $$invalidate(24, root = $$props.root); 1359 if ('proxy_url' in $$props) $$invalidate(25, proxy_url = $$props.proxy_url); 1360 if ('samples_per_page' in $$props) $$invalidate(9, samples_per_page = $$props.samples_per_page); 1361 if ('scale' in $$props) $$invali
1361date(10, scale = $$props.scale); 1362 if ('min_width' in $$props) $$invalidate(11, min_width = $$props.min_width); 1363 if ('gradio' in $$props) $$invalidate(12, gradio = $$props.gradio); 1364 }; 1365 1366 $$self.$$.update = () => { 1367 if ($$self.$$.dirty[0] & /*components*/ 2) { 1368 $$invalidate(18, gallery = components.length < 2); 1369 } 1370 1371 if ($$self.$$.dirty[0] & /*samples, page, samples_per_page, page_count, visible_pages*/ 75538944) { 1372 { 1373 if (paginate) { 1374 $$invalidate(15, visible_pages = []); 1375 $$invalidate(14, selected_samples = samples.slice(page * samples_per_page, (page + 1) * samples_per_page)); 1376 $$invalidate(26, page_count = Math.ceil(samples.length / samples_per_page)); 1377 1378 [0, page, page_count - 1].forEach(anchor => { 1379 for (let i = anchor - 2; i <= anchor + 2; i++) { 1380 if (i >= 0 && i < page_count && !visible_pages.includes(i)) { 1381 if (visible_pages.length > 0 && i - visible_pages[visible_pages.length - 1] > 1) { 1382 visible_pages.push(-1); 1383 } 1384 1385 visible_pages.push(i); 1386 } 1387 } 1388 }); 1389 } else { 1390 $$invalidate(14, selected_samples = samples.slice()); 1391 } 1392 } 1393 } 1394 1395 if ($$self.$$.dirty[0] & /*selected_samples*/ 16384) { 1396 get_component_meta(selected_samples); 1397 } 1398 }; 1399 1400 return [ 1401 value, 1402 components, 1403 component_props, 1404 component_map, 1405 label, 1406 headers, 1407 elem_id, 1408 elem_classes, 1409 visible, 1410 samples_per_page, 1411 scale, 1412 min_width, 1413 gradio, 1414 page, 1415 selected_samples, 1416 visible_pages, 1417 current_hover, 1418 component_meta, 1419 gallery, 1420 samples_dir, 1421 paginate, 1422 handle_mouseenter, 1423 handle_mouseleave, 1424 samples, 1425 root, 1426 proxy_url, 1427 page_count, 1428 click_handler, 1429 mouseenter_handler, 1430 mouseleave_handler, 1431 click_handler_1, 1432 mouseenter_handler_1, 1433 mouseleave_handler_1, 1434 click_handler_2 1435 ]; 1436} 1437 1438class Index extends SvelteComponent { 1439 constructor(options) { 1440 super(); 1441 1442 init( 1443 this, 1444 options, 1445 instance, 1446 create_fragment, 1447 safe_not_equal, 1448 { 1449 components: 1, 1450 component_props: 2, 1451 component_map: 3, 1452 label: 4, 1453 headers: 5, 1454 samples: 23, 1455 elem_id: 6, 1456 elem_classes: 7, 1457 visible: 8, 1458 value: 0, 1459 root: 24, 1460 proxy_url: 25, 1461 samples_per_page: 9, 1462 scale: 10, 1463 min_width: 11, 1464 gradio: 12 1465 }, 1466 null, 1467 [-1, -1] 1468 ); 1469 } 1470} 1471 1472export { Index as default }; 1473//# sourceMappingURL=Index-0285e6c9.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.