1import { B as Block } from './Button-5e2814d0.js'; 2import { S as Static } from './Index-259f3890.js'; 3import { B as BlockLabel } from './BlockLabel-4986e1f2.js'; 4import { I as IconButton } from './IconButton-e4d36fc3.js'; 5import { E as Empty } from './Empty-65007a7c.js'; 6import { S as ShareButton } from './ShareButton-11d2080f.js'; 7import { D as Download } from './Download-ea83bae3.js'; 8import { I as Image } from './Image-6cbf81d1.js'; 9import { n as normalise_file } from './index-2b08cc7a.js'; 10/* empty css */import { M as ModifyUpload } from './ModifyUpload-75a66d7d.js'; 11import { u as uploadToHuggingFace } from './utils-8f25e669.js'; 12import './svelte/svelte.js'; 13import './Clear-9760deed.js'; 14 15var has = Object.prototype.hasOwnProperty; 16 17function find(iter, tar, key) { 18 for (key of iter.keys()) { 19 if (dequal(key, tar)) return key; 20 } 21} 22 23function dequal(foo, bar) { 24 var ctor, len, tmp; 25 if (foo === bar) return true; 26 27 if (foo && bar && (ctor=foo.constructor) === bar.constructor) { 28 if (ctor === Date) return foo.getTime() === bar.getTime(); 29 if (ctor === RegExp) return foo.toString() === bar.toString(); 30 31 if (ctor === Array) { 32 if ((len=foo.length) === bar.length) { 33 while (len-- && dequal(foo[len], bar[len])); 34 } 35 return len === -1; 36 } 37 38 if (ctor === Set) { 39 if (foo.size !== bar.size) { 40 return false; 41 } 42 for (len of foo) { 43 tmp = len; 44 if (tmp && typeof tmp === 'object') { 45 tmp = find(bar, tmp); 46 if (!tmp) return false; 47 } 48 if (!bar.has(tmp)) return false; 49 } 50 return true; 51 } 52 53 if (ctor === Map) { 54 if (foo.size !== bar.size) { 55 return false; 56 } 57 for (len of foo) { 58 tmp = len[0]; 59 if (tmp && typeof tmp === 'object') { 60 tmp = find(bar, tmp); 61 if (!tmp) return false; 62 } 63 if (!dequal(len[1], bar.get(tmp))) { 64 return false; 65 } 66 } 67 return true; 68 } 69 70 if (ctor === ArrayBuffer) { 71 foo = new Uint8Array(foo); 72 bar = new Uint8Array(bar); 73 } else if (ctor === DataView) { 74 if ((len=foo.byteLength) === bar.byteLength) { 75 while (len-- && foo.getInt8(len) === bar.getInt8(len)); 76 } 77 return len === -1; 78 } 79 80 if (ArrayBuffer.isView(foo)) { 81 if ((len=foo.byteLength) === bar.byteLength) { 82 while (len-- && foo[len] === bar[len]); 83 } 84 return len === -1; 85 } 86 87 if (!ctor || typeof foo === 'object') { 88 len = 0; 89 for (ctor in foo) { 90 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 91 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 92 } 93 return Object.keys(bar).length === len; 94 } 95 } 96 97 return foo !== foo && bar !== bar; 98} 99 100async function format_gallery_for_sharing(value) { 101 if (!value) 102 return ""; 103 let urls = await Promise.all( 104 value.map(async ([image, _]) => { 105 if (image === null || !image.url) 106 return ""; 107 return await uploadToHuggingFace(image.url, "url"); 108 }) 109 ); 110 return `<div style="display: flex; flex-wrap: wrap; gap: 16px">${urls.map((url) => `<img src="${url}" style="height: 400px" />`).join("")}</div>`; 111} 112 113const Gallery_svelte_svelte_type_style_lang = ''; 114 115/* home/runner/work/gradio/gradio/js/gallery/shared/Gallery.svelte generated by Svelte v4.2.2 */ 116const { 117 SvelteComponent: SvelteComponent$1, 118 add_iframe_resize_listener, 119 add_render_callback, 120 append, 121 attr, 122 binding_callbacks: binding_callbacks$1, 123 bubble, 124 check_outros, 125 create_component: create_component$1, 126 destroy_component: destroy_component$1, 127 destroy_each, 128 detach: detach$1, 129 element, 130 empty, 131 ensure_array_like, 132 globals, 133 group_outros, 134 init: init$1, 135 insert: insert$1, 136 listen, 137 mount_component: mount_component$1, 138 run_all, 139 safe_not_equal: safe_not_equal$1, 140 set_data, 141 set_style, 142 space: space$1, 143 src_url_equal, 144 text, 145 toggle_class, 146 transition_in: transition_in$1, 147 transition_out: transition_out$1 148} = window.__gradio__svelte__internal; 149const { window: window_1 } = globals; 150const { createEventDispatcher: createEventDispatcher$1 } = window.__gradio__svelte__internal;const { tick } = window.__gradio__svelte__internal; 151function get_each_context(ctx, list, i) { 152 const child_ctx = ctx.slice(); 153 child_ctx[39] = list[i]; 154 child_ctx[41] = i; 155 return child_ctx; 156} 157 158function get_each_context_1(ctx, list, i) { 159 const child_ctx = ctx.slice(); 160 child_ctx[42] = list[i]; 161 child_ctx[43] = list; 162 child_ctx[41] = i; 163 return child_ctx; 164} 165 166// (153:0) {#if show_label} 167function create_if_block_6(ctx) { 168 let blocklabel; 169 let current; 170 171 blocklabel = new BlockLabel({ 172 props: { 173 show_label: /*show_label*/ ctx[1], 174 Icon: Image, 175 label: /*label*/ ctx[2] || "Gallery" 176 } 177 }); 178 179 return { 180 c() { 181 create_component$1(blocklabel.$$.fragment); 182 }, 183 m(target, anchor) { 184 mount_component$1(blocklabel, target, anchor); 185 current = true; 186 }, 187 p(ctx, dirty) { 188 const blocklabel_changes = {};
189 if (dirty[0] & /*show_label*/ 2) blocklabel_changes.show_label = /*show_label*/ ctx[1]; 190 if (dirty[0] & /*label*/ 4) blocklabel_changes.label = /*label*/ ctx[2] || "Gallery"; 191 blocklabel.$set(blocklabel_changes); 192 }, 193 i(local) { 194 if (current) return; 195 transition_in$1(blocklabel.$$.fragment, local); 196 current = true; 197 }, 198 o(local) { 199 transition_out$1(blocklabel.$$.fragment, local); 200 current = false; 201 }, 202 d(detaching) { 203 destroy_component$1(blocklabel, detaching); 204 } 205 }; 206} 207 208// (158:0) {:else} 209function create_else_block(ctx) { 210 let t0; 211 let div1; 212 let div0; 213 let t1; 214 let div1_resize_listener; 215 let current; 216 let if_block0 = /*selected_index*/ ctx[0] !== null && /*allow_preview*/ ctx[7] && create_if_block_3(ctx); 217 let if_block1 = /*show_share_button*/ ctx[9] && create_if_block_2(ctx); 218 let each_value = ensure_array_like(/*_value*/ ctx[12]); 219 let each_blocks = []; 220 221 for (let i = 0; i < each_value.length; i += 1) { 222 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 223 } 224 225 return { 226 c() { 227 if (if_block0) if_block0.c(); 228 t0 = space$1(); 229 div1 = element("div"); 230 div0 = element("div"); 231 if (if_block1) if_block1.c(); 232 t1 = space$1(); 233 234 for (let i = 0; i < each_blocks.length; i += 1) { 235 each_blocks[i].c(); 236 } 237 238 attr(div0, "class", "grid-container svelte-fiatpe"); 239 set_style(div0, "--grid-cols", /*columns*/ ctx[4]); 240 set_style(div0, "--grid-rows", /*rows*/ ctx[5]); 241 set_style(div0, "--object-fit", /*object_fit*/ ctx[8]); 242 set_style(div0, "height", /*height*/ ctx[6]); 243 toggle_class(div0, "pt-6", /*show_label*/ ctx[1]); 244 attr(div1, "class", "grid-wrap svelte-fiatpe"); 245 add_render_callback(() => /*div1_elementresize_handler*/ ctx[34].call(div1)); 246 toggle_class(div1, "fixed-height", !/*height*/ ctx[6] || /*height*/ ctx[6] == "auto"); 247 }, 248 m(target, anchor) { 249 if (if_block0) if_block0.m(target, anchor); 250 insert$1(target, t0, anchor); 251 insert$1(target, div1, anchor); 252 append(div1, div0); 253 if (if_block1) if_block1.m(div0, null); 254 append(div0, t1); 255 256 for (let i = 0; i < each_blocks.length; i += 1) { 257 if (each_blocks[i]) { 258 each_blocks[i].m(div0, null); 259 } 260 } 261 262 div1_resize_listener = add_iframe_resize_listener(div1, /*div1_elementresize_handler*/ ctx[34].bind(div1)); 263 current = true; 264 }, 265 p(ctx, dirty) { 266 if (/*selected_index*/ ctx[0] !== null && /*allow_preview*/ ctx[7]) { 267 if (if_block0) { 268 if_block0.p(ctx, dirty); 269 270 if (dirty[0] & /*selected_index, allow_preview*/ 129) { 271 transition_in$1(if_block0, 1); 272 } 273 } else { 274 if_block0 = create_if_block_3(ctx); 275 if_block0.c(); 276 transition_in$1(if_block0, 1); 277 if_block0.m(t0.parentNode, t0); 278 } 279 } else if (if_block0) { 280 group_outros(); 281 282 transition_out$1(if_block0, 1, 1, () => { 283 if_block0 = null; 284 }); 285 286 check_outros(); 287 } 288 289 if (/*show_share_button*/ ctx[9]) { 290 if (if_block1) { 291 if_block1.p(ctx, dirty); 292 293 if (dirty[0] & /*show_share_button*/ 512) { 294 transition_in$1(if_block1, 1); 295 } 296 } else { 297 if_block1 = create_if_block_2(ctx); 298 if_block1.c(); 299 transition_in$1(if_block1, 1); 300 if_block1.m(div0, t1); 301 } 302 } else if (if_block1) { 303 group_outros(); 304 305 transition_out$1(if_block1, 1, 1, () => { 306 if_block1 = null; 307 }); 308 309 check_outros(); 310 } 311 312 if (dirty[0] & /*_value, selected_index*/ 4097) { 313 each_value = ensure_array_like(/*_value*/ ctx[12]); 314 let i; 315 316 for (i = 0; i < each_value.length; i += 1) { 317 const child_ctx = get_each_context(ctx, each_value, i); 318 319 if (each_blocks[i]) { 320 each_blocks[i].p(child_ctx, dirty); 321 } else { 322 each_blocks[i] = create_each_block(child_ctx); 323 each_blocks[i].c(); 324 each_blocks[i].m(div0, null); 325 } 326 } 327 328 for (; i < each_blocks.length; i += 1) { 329 each_blocks[i].d(1); 330 } 331 332 each_blocks.length = each_value.length; 333 } 334 335 if (!current || dirty[0] & /*columns*/ 16) { 336 set_style(div0, "--grid-cols", /*columns*/ ctx[4]); 337 } 338 339 if (!current || dirty[0] & /*rows*/ 32) {
340 set_style(div0, "--grid-rows", /*rows*/ ctx[5]); 341 } 342 343 if (!current || dirty[0] & /*object_fit*/ 256) { 344 set_style(div0, "--object-fit", /*object_fit*/ ctx[8]); 345 } 346 347 if (!current || dirty[0] & /*height*/ 64) { 348 set_style(div0, "height", /*height*/ ctx[6]); 349 } 350 351 if (!current || dirty[0] & /*show_label*/ 2) { 352 toggle_class(div0, "pt-6", /*show_label*/ ctx[1]); 353 } 354 355 if (!current || dirty[0] & /*height*/ 64) { 356 toggle_class(div1, "fixed-height", !/*height*/ ctx[6] || /*height*/ ctx[6] == "auto"); 357 } 358 }, 359 i(local) { 360 if (current) return; 361 transition_in$1(if_block0); 362 transition_in$1(if_block1); 363 current = true; 364 }, 365 o(local) { 366 transition_out$1(if_block0); 367 transition_out$1(if_block1); 368 current = false; 369 }, 370 d(detaching) { 371 if (detaching) { 372 detach$1(t0); 373 detach$1(div1); 374 } 375 376 if (if_block0) if_block0.d(detaching); 377 if (if_block1) if_block1.d(); 378 destroy_each(each_blocks, detaching); 379 div1_resize_listener(); 380 } 381 }; 382} 383 384// (156:0) {#if value === null || _value === null || _value.length === 0} 385function create_if_block(ctx) { 386 let empty_1; 387 let current; 388 389 empty_1 = new Empty({ 390 props: { 391 unpadded_box: true, 392 size: "large", 393 $$slots: { default: [create_default_slot$1] }, 394 $$scope: { ctx } 395 } 396 }); 397 398 return { 399 c() { 400 create_component$1(empty_1.$$.fragment); 401 }, 402 m(target, anchor) { 403 mount_component$1(empty_1, target, anchor); 404 current = true; 405 }, 406 p(ctx, dirty) { 407 const empty_1_changes = {}; 408 409 if (dirty[1] & /*$$scope*/ 8192) { 410 empty_1_changes.$$scope = { dirty, ctx }; 411 } 412 413 empty_1.$set(empty_1_changes); 414 }, 415 i(local) { 416 if (current) return; 417 transition_in$1(empty_1.$$.fragment, local); 418 current = true; 419 }, 420 o(local) { 421 transition_out$1(empty_1.$$.fragment, local); 422 current = false; 423 }, 424 d(detaching) { 425 destroy_component$1(empty_1, detaching); 426 } 427 }; 428} 429 430// (159:1) {#if selected_index !== null && allow_preview} 431function create_if_block_3(ctx) { 432 let button1; 433 let div0; 434 let t0; 435 let modifyupload; 436 let t1; 437 let button0; 438 let img; 439 let img_src_value; 440 let img_alt_value; 441 let img_title_value; 442 let t2; 443 let t3; 444 let div1; 445 let current; 446 let mounted; 447 let dispose; 448 let if_block0 = /*show_download_button*/ ctx[10] && create_if_block_5(ctx); 449 450 modifyupload = new ModifyUpload({ 451 props: { i18n: /*i18n*/ ctx[11], absolute: false } 452 }); 453 454 modifyupload.$on("clear", /*clear_handler*/ ctx[26]); 455 let if_block1 = /*_value*/ ctx[12][/*selected_index*/ ctx[0]]?.caption && create_if_block_4(ctx); 456 let each_value_1 = ensure_array_like(/*_value*/ ctx[12]); 457 let each_blocks = []; 458 459 for (let i = 0; i < each_value_1.length; i += 1) { 460 each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); 461 } 462 463 return { 464 c() { 465 button1 = element("button"); 466 div0 = element("div"); 467 if (if_block0) if_block0.c(); 468 t0 = space$1(); 469 create_component$1(modifyupload.$$.fragment); 470 t1 = space$1(); 471 button0 = element("button"); 472 img = element("img"); 473 t2 = space$1(); 474 if (if_block1) if_block1.c(); 475 t3 = space$1(); 476 div1 = element("div"); 477 478 for (let i = 0; i < each_blocks.length; i += 1) { 479 each_blocks[i].c(); 480 } 481 482 attr(div0, "class", "icon-buttons svelte-fiatpe"); 483 attr(img, "data-testid", "detailed-image"); 484 if (!src_url_equal(img.src, img_src_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].image.url)) attr(img, "src", img_src_value); 485 attr(img, "alt", img_alt_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption || ""); 486 attr(img, "title", img_title_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption || null); 487 attr(img, "loading", "lazy"); 488 attr(img, "class", "svelte-fiatpe"); 489 toggle_class(img, "with-caption", !!/*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption); 490 attr(button0, "class", "image-button svelte-fiatpe"); 491 492 set_style(button0, "height", "calc(100% - " + (/*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption 493 ? '80px' 494 : '60px') + ")"); 495 496 attr(button0, "aria-label", "detailed view of selected image"); 497 attr(div1, "class", "thumbnails scroll-hide svelte-fiatpe"); 498 attr(div1, "data-testid", "container_el"); 499 attr(button1, "class", "preview svelte-fiatpe"); 500 }, 501 m(target, anchor) { 502 insert$1(target, button1, anchor); 503 append(button1, div0); 504 if (if_block0) if_block0.m(div0, null); 505 append(div0, t0);
506 mount_component$1(modifyupload, div0, null); 507 append(button1, t1); 508 append(button1, button0); 509 append(button0, img); 510 append(button1, t2); 511 if (if_block1) if_block1.m(button1, null); 512 append(button1, t3); 513 append(button1, div1); 514 515 for (let i = 0; i < each_blocks.length; i += 1) { 516 if (each_blocks[i]) { 517 each_blocks[i].m(div1, null); 518 } 519 } 520 521 /*div1_binding*/ ctx[30](div1); 522 current = true; 523 524 if (!mounted) { 525 dispose = [ 526 listen(button0, "click", /*click_handler*/ ctx[27]), 527 listen(button1, "keydown", /*on_keydown*/ ctx[18]) 528 ]; 529 530 mounted = true; 531 } 532 }, 533 p(ctx, dirty) { 534 if (/*show_download_button*/ ctx[10]) { 535 if (if_block0) { 536 if_block0.p(ctx, dirty); 537 538 if (dirty[0] & /*show_download_button*/ 1024) { 539 transition_in$1(if_block0, 1); 540 } 541 } else { 542 if_block0 = create_if_block_5(ctx); 543 if_block0.c(); 544 transition_in$1(if_block0, 1); 545 if_block0.m(div0, t0); 546 } 547 } else if (if_block0) { 548 group_outros(); 549 550 transition_out$1(if_block0, 1, 1, () => { 551 if_block0 = null; 552 }); 553 554 check_outros(); 555 } 556 557 const modifyupload_changes = {}; 558 if (dirty[0] & /*i18n*/ 2048) modifyupload_changes.i18n = /*i18n*/ ctx[11]; 559 modifyupload.$set(modifyupload_changes); 560 561 if (!current || dirty[0] & /*_value, selected_index*/ 4097 && !src_url_equal(img.src, img_src_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].image.url)) { 562 attr(img, "src", img_src_value); 563 } 564 565 if (!current || dirty[0] & /*_value, selected_index*/ 4097 && img_alt_value !== (img_alt_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption || "")) { 566 attr(img, "alt", img_alt_value); 567 } 568 569 if (!current || dirty[0] & /*_value, selected_index*/ 4097 && img_title_value !== (img_title_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption || null)) { 570 attr(img, "title", img_title_value); 571 } 572 573 if (!current || dirty[0] & /*_value, selected_index*/ 4097) { 574 toggle_class(img, "with-caption", !!/*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption); 575 } 576 577 if (!current || dirty[0] & /*_value, selected_index*/ 4097) { 578 set_style(button0, "height", "calc(100% - " + (/*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption 579 ? '80px' 580 : '60px') + ")"); 581 } 582 583 if (/*_value*/ ctx[12][/*selected_index*/ ctx[0]]?.caption) { 584 if (if_block1) { 585 if_block1.p(ctx, dirty); 586 } else { 587 if_block1 = create_if_block_4(ctx); 588 if_block1.c(); 589 if_block1.m(button1, t3); 590 } 591 } else if (if_block1) { 592 if_block1.d(1); 593 if_block1 = null; 594 } 595 596 if (dirty[0] & /*_value, el, selected_index*/ 12289) { 597 each_value_1 = ensure_array_like(/*_value*/ ctx[12]); 598 let i; 599 600 for (i = 0; i < each_value_1.length; i += 1) { 601 const child_ctx = get_each_context_1(ctx, each_value_1, i); 602 603 if (each_blocks[i]) { 604 each_blocks[i].p(child_ctx, dirty); 605 } else { 606 each_blocks[i] = create_each_block_1(child_ctx); 607 each_blocks[i].c(); 608 each_blocks[i].m(div1, null); 609 } 610 } 611 612 for (; i < each_blocks.length; i += 1) { 613 each_blocks[i].d(1); 614 } 615 616 each_blocks.length = each_value_1.length; 617 } 618 }, 619 i(local) { 620 if (current) return; 621 transition_in$1(if_block0); 622 transition_in$1(modifyupload.$$.fragment, local); 623 current = true; 624 }, 625 o(local) { 626 transition_out$1(if_block0); 627 transition_out$1(modifyupload.$$.fragment, local); 628 current = false; 629 }, 630 d(detaching) { 631 if (detaching) { 632 detach$1(button1); 633 } 634 635 if (if_block0) if_block0.d(); 636 destroy_component$1(modifyupload); 637 if (if_block1) if_block1.d(); 638 destroy_each(each_blocks, detaching); 639 /*div1_binding*/ ctx[30](null); 640 mounted = false; 641 run_all(dispose); 642 } 643 }; 644} 645 646// (162:4) {#if show_download_button} 647function create_if_block_5(ctx) { 648 let a; 649 let iconbutton; 650 let a_href_value; 651 let current; 652 653 iconbutton = new IconButton({ 654 props: { 655 Icon: Download, 656 label: /*i18n*/ ctx[11]("common.download") 657 } 658 }); 659 660 return { 661 c() { 662 a = element("a"); 663 create_component$1(iconbutton.$$.fragment); 664 attr(a, "href", a_href_value = getHrefValue(/*value*/ ctx[3][/*selected_index*/ ctx[0]])); 665 attr(a, "target", window.__is_colab__ ? "_blank" : null); 666 attr(a, "download", "image"); 667 attr(a, "class", "svelte-fiatpe"); 668 }, 669 m(target, anchor) { 670 insert$1(target, a, anchor);
671 mount_component$1(iconbutton, a, null); 672 current = true; 673 }, 674 p(ctx, dirty) { 675 const iconbutton_changes = {}; 676 if (dirty[0] & /*i18n*/ 2048) iconbutton_changes.label = /*i18n*/ ctx[11]("common.download"); 677 iconbutton.$set(iconbutton_changes); 678 679 if (!current || dirty[0] & /*value, selected_index*/ 9 && a_href_value !== (a_href_value = getHrefValue(/*value*/ ctx[3][/*selected_index*/ ctx[0]]))) { 680 attr(a, "href", a_href_value); 681 } 682 }, 683 i(local) { 684 if (current) return; 685 transition_in$1(iconbutton.$$.fragment, local); 686 current = true; 687 }, 688 o(local) { 689 transition_out$1(iconbutton.$$.fragment, local); 690 current = false; 691 }, 692 d(detaching) { 693 if (detaching) { 694 detach$1(a); 695 } 696 697 destroy_component$1(iconbutton); 698 } 699 }; 700} 701 702// (195:3) {#if _value[selected_index]?.caption} 703function create_if_block_4(ctx) { 704 let caption; 705 let t_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption + ""; 706 let t; 707 708 return { 709 c() { 710 caption = element("caption"); 711 t = text(t_value); 712 attr(caption, "class", "caption svelte-fiatpe"); 713 }, 714 m(target, anchor) { 715 insert$1(target, caption, anchor); 716 append(caption, t); 717 }, 718 p(ctx, dirty) { 719 if (dirty[0] & /*_value, selected_index*/ 4097 && t_value !== (t_value = /*_value*/ ctx[12][/*selected_index*/ ctx[0]].caption + "")) set_data(t, t_value); 720 }, 721 d(detaching) { 722 if (detaching) { 723 detach$1(caption); 724 } 725 } 726 }; 727} 728 729// (205:4) {#each _value as image, i} 730function create_each_block_1(ctx) { 731 let button; 732 let img; 733 let img_src_value; 734 let img_title_value; 735 let t; 736 let button_aria_label_value; 737 let i = /*i*/ ctx[41]; 738 let mounted; 739 let dispose; 740 const assign_button = () => /*button_binding*/ ctx[28](button, i); 741 const unassign_button = () => /*button_binding*/ ctx[28](null, i); 742 743 function click_handler_1() { 744 return /*click_handler_1*/ ctx[29](/*i*/ ctx[41]); 745 } 746 747 return { 748 c() { 749 button = element("button"); 750 img = element("img"); 751 t = space$1(); 752 if (!src_url_equal(img.src, img_src_value = /*image*/ ctx[42].image.url)) attr(img, "src", img_src_value); 753 attr(img, "title", img_title_value = /*image*/ ctx[42].caption || null); 754 attr(img, "data-testid", "thumbnail " + (/*i*/ ctx[41] + 1)); 755 attr(img, "alt", ""); 756 attr(img, "loading", "lazy"); 757 attr(img, "class", "svelte-fiatpe"); 758 attr(button, "class", "thumbnail-item thumbnail-small svelte-fiatpe"); 759 attr(button, "aria-label", button_aria_label_value = "Thumbnail " + (/*i*/ ctx[41] + 1) + " of " + /*_value*/ ctx[12].length); 760 toggle_class(button, "selected", /*selected_index*/ ctx[0] === /*i*/ ctx[41]); 761 }, 762 m(target, anchor) { 763 insert$1(target, button, anchor); 764 append(button, img); 765 append(button, t); 766 assign_button(); 767 768 if (!mounted) { 769 dispose = listen(button, "click", click_handler_1); 770 mounted = true; 771 } 772 }, 773 p(new_ctx, dirty) { 774 ctx = new_ctx; 775 776 if (dirty[0] & /*_value*/ 4096 && !src_url_equal(img.src, img_src_value = /*image*/ ctx[42].image.url)) { 777 attr(img, "src", img_src_value); 778 } 779 780 if (dirty[0] & /*_value*/ 4096 && img_title_value !== (img_title_value = /*image*/ ctx[42].caption || null)) { 781 attr(img, "title", img_title_value); 782 } 783 784 if (dirty[0] & /*_value*/ 4096 && button_aria_label_value !== (button_aria_label_value = "Thumbnail " + (/*i*/ ctx[41] + 1) + " of " + /*_value*/ ctx[12].length)) { 785 attr(button, "aria-label", button_aria_label_value); 786 } 787 788 if (i !== /*i*/ ctx[41]) { 789 unassign_button(); 790 i = /*i*/ ctx[41]; 791 assign_button(); 792 } 793 794 if (dirty[0] & /*selected_index*/ 1) { 795 toggle_class(button, "selected", /*selected_index*/ ctx[0] === /*i*/ ctx[41]); 796 } 797 }, 798 d(detaching) { 799 if (detaching) { 800 detach$1(button); 801 } 802 803 unassign_button(); 804 mounted = false; 805 dispose(); 806 } 807 }; 808} 809 810// (236:3) {#if show_share_button} 811function create_if_block_2(ctx) { 812 let div; 813 let sharebutton; 814 let current; 815 816 sharebutton = new ShareButton({ 817 props: { 818 i18n: /*i18n*/ ctx[11], 819 value: /*_value*/ ctx[12], 820 formatter: format_gallery_for_sharing 821 } 822 }); 823 824 sharebutton.$on("share", /*share_handler*/ ctx[31]); 825 sharebutton.$on("error", /*error_handler*/ ctx[32]); 826 827 return { 828 c() { 829 div = element("div"); 830 create_component$1(sharebutton.$$.fragment); 831 attr(div, "class", "icon-button svelte-fiatpe"); 832 }, 833 m(target, anchor) { 834 insert$1(target, div, anchor);
835 mount_component$1(sharebutton, div, null); 836 current = true; 837 }, 838 p(ctx, dirty) { 839 const sharebutton_changes = {}; 840 if (dirty[0] & /*i18n*/ 2048) sharebutton_changes.i18n = /*i18n*/ ctx[11]; 841 if (dirty[0] & /*_value*/ 4096) sharebutton_changes.value = /*_value*/ ctx[12]; 842 sharebutton.$set(sharebutton_changes); 843 }, 844 i(local) { 845 if (current) return; 846 transition_in$1(sharebutton.$$.fragment, local); 847 current = true; 848 }, 849 o(local) { 850 transition_out$1(sharebutton.$$.fragment, local); 851 current = false; 852 }, 853 d(detaching) { 854 if (detaching) { 855 detach$1(div); 856 } 857 858 destroy_component$1(sharebutton); 859 } 860 }; 861} 862 863// (261:5) {#if entry.caption} 864function create_if_block_1(ctx) { 865 let div; 866 let t_value = /*entry*/ ctx[39].caption + ""; 867 let t; 868 869 return { 870 c() { 871 div = element("div"); 872 t = text(t_value); 873 attr(div, "class", "caption-label svelte-fiatpe"); 874 }, 875 m(target, anchor) { 876 insert$1(target, div, anchor); 877 append(div, t); 878 }, 879 p(ctx, dirty) { 880 if (dirty[0] & /*_value*/ 4096 && t_value !== (t_value = /*entry*/ ctx[39].caption + "")) set_data(t, t_value); 881 }, 882 d(detaching) { 883 if (detaching) { 884 detach$1(div); 885 } 886 } 887 }; 888} 889 890// (247:3) {#each _value as entry, i} 891function create_each_block(ctx) { 892 let button; 893 let img; 894 let img_alt_value; 895 let img_src_value; 896 let t0; 897 let t1; 898 let button_aria_label_value; 899 let mounted; 900 let dispose; 901 let if_block = /*entry*/ ctx[39].caption && create_if_block_1(ctx); 902 903 function click_handler_2() { 904 return /*click_handler_2*/ ctx[33](/*i*/ ctx[41]); 905 } 906 907 return { 908 c() { 909 button = element("button"); 910 img = element("img"); 911 t0 = space$1(); 912 if (if_block) if_block.c(); 913 t1 = space$1(); 914 attr(img, "alt", img_alt_value = /*entry*/ ctx[39].caption || ""); 915 916 if (!src_url_equal(img.src, img_src_value = typeof /*entry*/ ctx[39].image === "string" 917 ? /*entry*/ ctx[39].image 918 : /*entry*/ ctx[39].image.url)) attr(img, "src", img_src_value); 919 920 attr(img, "loading", "lazy"); 921 attr(img, "class", "svelte-fiatpe"); 922 attr(button, "class", "thumbnail-item thumbnail-lg svelte-fiatpe"); 923 attr(button, "aria-label", button_aria_label_value = "Thumbnail " + (/*i*/ ctx[41] + 1) + " of " + /*_value*/ ctx[12].length); 924 toggle_class(button, "selected", /*selected_index*/ ctx[0] === /*i*/ ctx[41]); 925 }, 926 m(target, anchor) { 927 insert$1(target, button, anchor); 928 append(button, img); 929 append(button, t0); 930 if (if_block) if_block.m(button, null); 931 append(button, t1); 932 933 if (!mounted) { 934 dispose = listen(button, "click", click_handler_2); 935 mounted = true; 936 } 937 }, 938 p(new_ctx, dirty) { 939 ctx = new_ctx; 940 941 if (dirty[0] & /*_value*/ 4096 && img_alt_value !== (img_alt_value = /*entry*/ ctx[39].caption || "")) { 942 attr(img, "alt", img_alt_value); 943 } 944 945 if (dirty[0] & /*_value*/ 4096 && !src_url_equal(img.src, img_src_value = typeof /*entry*/ ctx[39].image === "string" 946 ? /*entry*/ ctx[39].image 947 : /*entry*/ ctx[39].image.url)) { 948 attr(img, "src", img_src_value); 949 } 950 951 if (/*entry*/ ctx[39].caption) { 952 if (if_block) { 953 if_block.p(ctx, dirty); 954 } else { 955 if_block = create_if_block_1(ctx); 956 if_block.c(); 957 if_block.m(button, t1); 958 } 959 } else if (if_block) { 960 if_block.d(1); 961 if_block = null; 962 } 963 964 if (dirty[0] & /*_value*/ 4096 && button_aria_label_value !== (button_aria_label_value = "Thumbnail " + (/*i*/ ctx[41] + 1) + " of " + /*_value*/ ctx[12].length)) { 965 attr(button, "aria-label", button_aria_label_value); 966 } 967 968 if (dirty[0] & /*selected_index*/ 1) { 969 toggle_class(button, "selected", /*selected_index*/ ctx[0] === /*i*/ ctx[41]); 970 } 971 }, 972 d(detaching) { 973 if (detaching) { 974 detach$1(button); 975 } 976 977 if (if_block) if_block.d(); 978 mounted = false; 979 dispose(); 980 } 981 }; 982} 983 984// (157:1) <Empty unpadded_box={true} size="large"> 985function create_default_slot$1(ctx) { 986 let image_1; 987 let current; 988 image_1 = new Image({}); 989 990 return { 991 c() { 992 create_component$1(image_1.$$.fragment); 993 }, 994 m(target, anchor) { 995 mount_component$1(image_1, target, anchor); 996 current = true; 997 }, 998 i(local) { 999 if (current) return; 1000 transition_in$1(image_1.$$.fragment, local); 1001 current = true; 1002 }, 1003 o(local) { 1004 transition_out$1(image_1.$$.fragment, local); 1005 current = false;
1006 }, 1007 d(detaching) { 1008 destroy_component$1(image_1, detaching); 1009 } 1010 }; 1011} 1012 1013function create_fragment$1(ctx) { 1014 let t; 1015 let current_block_type_index; 1016 let if_block1; 1017 let if_block1_anchor; 1018 let current; 1019 let mounted; 1020 let dispose; 1021 add_render_callback(/*onwindowresize*/ ctx[25]); 1022 let if_block0 = /*show_label*/ ctx[1] && create_if_block_6(ctx); 1023 const if_block_creators = [create_if_block, create_else_block]; 1024 const if_blocks = []; 1025 1026 function select_block_type(ctx, dirty) { 1027 if (/*value*/ ctx[3] === null || /*_value*/ ctx[12] === null || /*_value*/ ctx[12].length === 0) return 0; 1028 return 1; 1029 } 1030 1031 current_block_type_index = select_block_type(ctx); 1032 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1033 1034 return { 1035 c() { 1036 if (if_block0) if_block0.c(); 1037 t = space$1(); 1038 if_block1.c(); 1039 if_block1_anchor = empty(); 1040 }, 1041 m(target, anchor) { 1042 if (if_block0) if_block0.m(target, anchor); 1043 insert$1(target, t, anchor); 1044 if_blocks[current_block_type_index].m(target, anchor); 1045 insert$1(target, if_block1_anchor, anchor); 1046 current = true; 1047 1048 if (!mounted) { 1049 dispose = listen(window_1, "resize", /*onwindowresize*/ ctx[25]); 1050 mounted = true; 1051 } 1052 }, 1053 p(ctx, dirty) { 1054 if (/*show_label*/ ctx[1]) { 1055 if (if_block0) { 1056 if_block0.p(ctx, dirty); 1057 1058 if (dirty[0] & /*show_label*/ 2) { 1059 transition_in$1(if_block0, 1); 1060 } 1061 } else { 1062 if_block0 = create_if_block_6(ctx); 1063 if_block0.c(); 1064 transition_in$1(if_block0, 1); 1065 if_block0.m(t.parentNode, t); 1066 } 1067 } else if (if_block0) { 1068 group_outros(); 1069 1070 transition_out$1(if_block0, 1, 1, () => { 1071 if_block0 = null; 1072 }); 1073 1074 check_outros(); 1075 } 1076 1077 let previous_block_index = current_block_type_index; 1078 current_block_type_index = select_block_type(ctx); 1079 1080 if (current_block_type_index === previous_block_index) { 1081 if_blocks[current_block_type_index].p(ctx, dirty); 1082 } else { 1083 group_outros(); 1084 1085 transition_out$1(if_blocks[previous_block_index], 1, 1, () => { 1086 if_blocks[previous_block_index] = null; 1087 }); 1088 1089 check_outros(); 1090 if_block1 = if_blocks[current_block_type_index]; 1091 1092 if (!if_block1) { 1093 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1094 if_block1.c(); 1095 } else { 1096 if_block1.p(ctx, dirty); 1097 } 1098 1099 transition_in$1(if_block1, 1); 1100 if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); 1101 } 1102 }, 1103 i(local) { 1104 if (current) return; 1105 transition_in$1(if_block0); 1106 transition_in$1(if_block1); 1107 current = true; 1108 }, 1109 o(local) { 1110 transition_out$1(if_block0); 1111 transition_out$1(if_block1); 1112 current = false; 1113 }, 1114 d(detaching) { 1115 if (detaching) { 1116 detach$1(t); 1117 detach$1(if_block1_anchor); 1118 } 1119 1120 if (if_block0) if_block0.d(detaching); 1121 if_blocks[current_block_type_index].d(detaching); 1122 mounted = false; 1123 dispose(); 1124 } 1125 }; 1126} 1127 1128function isFileData(obj) { 1129 return typeof obj === "object" && obj !== null && "data" in obj; 1130} 1131 1132function getHrefValue(selected) { 1133 if (isFileData(selected)) { 1134 return selected.path; 1135 } else if (typeof selected === "string") { 1136 return selected; 1137 } else if (Array.isArray(selected)) { 1138 return getHrefValue(selected[0]); 1139 } 1140 1141 return ""; 1142} 1143 1144function instance$1($$self, $$props, $$invalidate) { 1145 let previous; 1146 let next; 1147 let { show_label = true } = $$props; 1148 let { label } = $$props; 1149 let { root = "" } = $$props; 1150 let { proxy_url = null } = $$props; 1151 let { value = null } = $$props; 1152 let { columns = [2] } = $$props; 1153 let { rows = undefined } = $$props; 1154 let { height = "auto" } = $$props; 1155 let { preview } = $$props; 1156 let { allow_preview = true } = $$props; 1157 let { object_fit = "cover" } = $$props; 1158 let { show_share_button = false } = $$props; 1159 let { show_download_button = false } = $$props; 1160 let { i18n } = $$props; 1161 let { selected_index = null } = $$props; 1162 const dispatch = createEventDispatcher$1(); 1163 1164 // tracks whether the value of the gallery was reset 1165 let was_reset = true; 1166 1167 let _value = null; 1168 let prevValue = value; 1169 1170 if (selected_index === null && preview && value?.length) { 1171 selected_index = 0; 1172 } 1173 1174 let old_selected_index = selected_index; 1175 1176 function handle_preview_click(event) { 1177 const element = event.target; 1178 const x = event.clientX; 1179 const width = element.offsetWidth; 1180 const centerX = width / 2; 1181 1182 if (x < centerX) {
1183 $$invalidate(0, selected_index = previous); 1184 } else { 1185 $$invalidate(0, selected_index = next); 1186 } 1187 } 1188 1189 function on_keydown(e) { 1190 switch (e.code) { 1191 case "Escape": 1192 e.preventDefault(); 1193 $$invalidate(0, selected_index = null); 1194 break; 1195 case "ArrowLeft": 1196 e.preventDefault(); 1197 $$invalidate(0, selected_index = previous); 1198 break; 1199 case "ArrowRight": 1200 e.preventDefault(); 1201 $$invalidate(0, selected_index = next); 1202 break; 1203 } 1204 } 1205 1206 let el = []; 1207 let container_element; 1208 1209 async function scroll_to_img(index) { 1210 if (typeof index !== "number") return; 1211 await tick(); 1212 if (el[index] === undefined) return; 1213 el[index]?.focus(); 1214 const { left: container_left, width: container_width } = container_element.getBoundingClientRect(); 1215 const { left, width } = el[index].getBoundingClientRect(); 1216 const relative_left = left - container_left; 1217 const pos = relative_left + width / 2 - container_width / 2 + container_element.scrollLeft; 1218 1219 if (container_element && typeof container_element.scrollTo === "function") { 1220 container_element.scrollTo({ 1221 left: pos < 0 ? 0 : pos, 1222 behavior: "smooth" 1223 }); 1224 } 1225 } 1226 1227 let client_height = 0; 1228 let window_height = 0; 1229 1230 function onwindowresize() { 1231 $$invalidate(16, window_height = window_1.innerHeight); 1232 } 1233 1234 const clear_handler = () =>
1234 $$invalidate(0, selected_index = null); 1235 const click_handler = event => handle_preview_click(event); 1236 1237 function button_binding($$value, i) { 1238 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1239 el[i] = $$value; 1240 $$invalidate(13, el); 1241 }); 1242 } 1243 1244 const click_handler_1 = i => $$invalidate(0, selected_index = i); 1245 1246 function div1_binding($$value) { 1247 binding_callbacks$1[$$value ? 'unshift' : 'push'](() => { 1248 container_element = $$value; 1249 $$invalidate(14, container_element); 1250 }); 1251 } 1252 1253 function share_handler(event) { 1254 bubble.call(this, $$self, event); 1255 } 1256 1257 function error_handler(event) { 1258 bubble.call(this, $$self, event); 1259 } 1260 1261 const click_handler_2 = i => $$invalidate(0, selected_index = i); 1262 1263 function div1_elementresize_handler() { 1264 client_height = this.clientHeight; 1265 $$invalidate(15, client_height); 1266 } 1267 1268 $$self.$$set = $$props => { 1269 if ('show_label' in $$props) $$invalidate(1, show_label = $$props.show_label); 1270 if ('label' in $$props) $$invalidate(2, label = $$props.label); 1271 if ('root' in $$props) $$invali
1271date(19, root = $$props.root); 1272 if ('proxy_url' in $$props) $$invalidate(20, proxy_url = $$props.proxy_url); 1273 if ('value' in $$props) $$invalidate(3, value = $$props.value); 1274 if ('columns' in $$props) $$invalidate(4, columns = $$props.columns); 1275 if ('rows' in $$props) $$invalidate(5, rows = $$props.rows); 1276 if ('height' in $$props) $$invalidate(6, height = $$props.height); 1277 if ('preview' in $$props) $$invalidate(21, preview = $$props.preview); 1278 if ('allow_preview' in $$props) $$invalidate(7, allow_preview = $$props.allow_preview); 1279 if ('object_fit' in $$props) $$invalidate(8, object_fit = $$props.object_fit); 1280 if ('show_share_button' in $$props) $$invalidate(9, show_share_button = $$props.show_share_button); 1281 if ('show_download_button' in $$props) $$invalidate(10, show_download_button = $$props.show_download_button); 1282 if ('i18n' in $$props) $$invalidate(11, i18n = $$props.i18n); 1283 if ('selected_index' in $$props) $$invalidate(0, selected_index = $$props.selected_index); 1284 }; 1285 1286 $$self.$$.update = () => { 1287 if ($$self.$$.dirty[0] & /*value, was_reset*/ 4194312) { 1288 $$invalidate(22, was_reset = value == null || value.length == 0 ? true : was_reset); 1289 } 1290 1291 if ($$self.$$.dirty[0] & /*value, root, proxy_url*/ 1572872) { 1292 $$invalidate(12, _value = value === null 1293 ? null 1294 : value.map(data => ({ 1295 image: normalise_file(data.image, root, proxy_url), 1296 caption: data.caption 1297 }))); 1298 } 1299 1300 if ($$self.$$.dirty[0] & /*prevValue, value, was_reset, preview, selected_index*/ 14680073) { 1301 if (!dequal(prevValue, value)) { 1302 // When value is falsy (clear button or first load), 1303 // preview determines the selected image 1304 if (was_reset) { 1305 $$invalidate(0, selected_index = preview && value?.length ? 0 : null); 1306 $$invalidate(22, was_reset = false); 1307 } else // gallery has at least as many elements as it did before 1308 { 1309 $$invalidate( 1310 0, 1311 selected_index = selected_index !== null && value !== null && selected_index < value.length 1312 ? selected_index 1313 : null 1314 ); 1315 } 1316 1317 dispatch("change"); 1318 $$invalidate(23, prevValue = value); 1319 } 1320 } 1321 1322 if ($$self.$$.dirty[0] & /*selected_index, _value*/ 4097) { 1323 previous = ((selected_index ?? 0) + (_value?.length ?? 0) - 1) % (_value?.length ?? 0); 1324 } 1325 1326 if ($$self.$$.dirty[0] & /*selected_index, _value*/ 4097) { 1327 next = ((selected_index ?? 0) + 1) % (_value?.length ?? 0); 1328 } 1329 1330 if ($$self.$$.dirty[0] & /*selected_index, old_selected_index, _value*/ 16781313) { 1331 { 1332 if (selected_index !== old_selected_index) { 1333 $$invalidate(24, old_selected_index = selected_index); 1334 1335 if (selected_index !== null) { 1336 dispatch("select", { 1337 index: selected_index, 1338 value: _value?.[selected_index] 1339 }); 1340 } 1341 } 1342 } 1343 } 1344 1345 if ($$self.$$.dirty[0] & /*allow_preview, selected_index*/ 129) { 1346 if (allow_preview) { 1347 scroll_to_img(selected_index); 1348 } 1349 } 1350 }; 1351 1352 return [ 1353 selected_index, 1354 show_label, 1355 label, 1356 value, 1357 columns, 1358 rows, 1359 height, 1360 allow_preview, 1361 object_fit, 1362 show_share_button, 1363 show_download_button, 1364 i18n, 1365 _value, 1366 el, 1367 container_element, 1368 client_height, 1369 window_height, 1370 handle_preview_click, 1371 on_keydown, 1372 root, 1373 proxy_url, 1374 preview, 1375 was_reset, 1376 prevValue, 1377 old_selected_index, 1378 onwindowresize, 1379 clear_handler, 1380 click_handler, 1381 button_binding, 1382 click_handler_1, 1383 div1_binding, 1384 share_handler, 1385 error_handler, 1386 click_handler_2, 1387 div1_elementresize_handler 1388 ]; 1389} 1390 1391class Gallery extends SvelteComponent$1 { 1392 constructor(options) { 1393 super(); 1394 1395 init$1( 1396 this, 1397 options, 1398 instance$1, 1399 create_fragment$1, 1400 safe_not_equal$1, 1401 { 1402 show_label: 1, 1403 label: 2, 1404 root: 19, 1405 proxy_url: 20, 1406 value: 3, 1407 columns: 4, 1408 rows: 5, 1409 height: 6, 1410 preview: 21, 1411 allow_preview: 7, 1412 object_fit: 8, 1413 show_share_button: 9, 1414 show_download_button: 10, 1415 i18n: 11, 1416 selected_index: 0 1417 }, 1418 null, 1419 [-1, -1] 1420 ); 1421 } 1422} 1423 1424const Gallery$1 = Gallery; 1425 1426/* home/runner/work/gradio/gradio/js/gallery/Index.svelte generated by Svelte v4.2.2 */ 1427const { 1428 SvelteComponent, 1429 add_flush_callback, 1430 assign, 1431 bind, 1432 binding_callbacks, 1433 create_component, 1434 destroy_component, 1435 detach, 1436 get_spread_object, 1437 get_spread_update, 1438 init, 1439 insert, 1440 mount_component, 1441 safe_not_equal, 1442 space, 1443 transition_in, 1444 transition_out 1445} = window.__gradio__svelte__internal;const { createEventDispatcher }
1445 = window.__gradio__svelte__internal; 1446function create_default_slot(ctx) { 1447 let statustracker; 1448 let t; 1449 let gallery; 1450 let updating_selected_index; 1451 let current; 1452 1453 const statustracker_spread_levels = [ 1454 { 1455 autoscroll: /*gradio*/ ctx[21].autoscroll 1456 }, 1457 { i18n: /*gradio*/ ctx[21].i18n }, 1458 /*loading_status*/ ctx[1] 1459 ]; 1460 1461 let statustracker_props = {}; 1462 1463 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 1464 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 1465 } 1466 1467 statustracker = new Static({ props: statustracker_props }); 1468 1469 function gallery_selected_index_binding(value) { 1470 /*gallery_selected_index_binding*/ ctx[22](value); 1471 } 1472 1473 let gallery_props = { 1474 label: /*label*/ ctx[3], 1475 value: /*value*/ ctx[9], 1476 show_label: /*show_label*/ ctx[2], 1477 root: /*root*/ ctx[4], 1478 proxy_url: /*proxy_url*/ ctx[5], 1479 columns: /*columns*/ ctx[13], 1480 rows: /*rows*/ ctx[14], 1481 height: /*height*/ ctx[15], 1482 preview: /*preview*/ ctx[16], 1483 object_fit: /*object_fit*/ ctx[18], 1484 allow_preview: /*allow_preview*/ ctx[17], 1485 show_share_button: /*show_share_button*/ ctx[19], 1486 show_download_button: /*show_download_button*/ ctx[20], 1487 i18n: /*gradio*/ ctx[21].i18n 1488 }; 1489 1490 if (/*selected_index*/ ctx[0] !== void 0) { 1491 gallery_props.selected_index = /*selected_index*/ ctx[0]; 1492 } 1493 1494 gallery = new Gallery$1({ props: gallery_props }); 1495 binding_callbacks.push(() => bind(gallery, 'selected_index', gallery_selected_index_binding)); 1496 gallery.$on("change", /*change_handler*/ ctx[23]); 1497 gallery.$on("select", /*select_handler*/ ctx[24]); 1498 gallery.$on("share", /*share_handler*/ ctx[25]); 1499 gallery.$on("error", /*error_handler*/ ctx[26]); 1500 1501 return { 1502 c() { 1503 create_component(statustracker.$$.fragment); 1504 t = space(); 1505 create_component(gallery.$$.fragment); 1506 }, 1507 m(target, anchor) { 1508 mount_component(statustracker, target, anchor); 1509 insert(target, t, anchor); 1510 mount_component(gallery, target, anchor); 1511 current = true; 1512 }, 1513 p(ctx, dirty) { 1514 const statustracker_changes = (dirty & /*gradio, loading_status*/ 2097154) 1515 ? get_spread_update(statustracker_spread_levels, [ 1516 dirty & /*gradio*/ 2097152 && { 1517 autoscroll: /*gradio*/ ctx[21].autoscroll 1518 }, 1519 dirty & /*gradio*/ 2097152 && { i18n: /*gradio*/ ctx[21].i18n }, 1520 dirty & /*loading_status*/ 2 && get_spread_object(/*loading_status*/ ctx[1]) 1521 ]) 1522 : {}; 1523 1524 statustracker.$set(statustracker_changes); 1525 const gallery_changes = {}; 1526 if (dirty & /*label*/ 8) gallery_changes.label = /*label*/ ctx[3]; 1527 if (dirty & /*value*/ 512) gallery_changes.value = /*value*/ ctx[9]; 1528 if (dirty & /*show_label*/ 4) gallery_changes.show_label = /*show_label*/ ctx[2]; 1529 if (dirty & /*root*/ 16) gallery_changes.root = /*root*/ ctx[4]; 1530 if (dirty & /*proxy_url*/ 32) gallery_changes.proxy_url = /*proxy_url*/ ctx[5]; 1531 if (dirty & /*columns*/ 8192) gallery_changes.columns = /*columns*/ ctx[13]; 1532 if (dirty & /*rows*/ 16384) gallery_changes.rows = /*rows*/ ctx[14]; 1533 if (dirty & /*height*/ 32768) gallery_changes.height = /*height*/ ctx[15]; 1534 if (dirty & /*preview*/ 65536) gallery_changes.preview = /*preview*/ ctx[16]; 1535 if (dirty & /*object_fit*/ 262144) gallery_changes.object_fit = /*object_fit*/ ctx[18]; 1536 if (dirty & /*allow_preview*/ 131072) gallery_changes.allow_preview = /*allow_preview*/ ctx[17]; 1537 if (dirty & /*show_share_button*/ 524288) gallery_changes.show_share_button = /*show_share_button*/ ctx[19]; 1538 if (dirty & /*show_download_button*/ 1048576) gallery_changes.show_download_button = /*show_download_button*/ ctx[20]; 1539 if (dirty & /*gradio*/ 2097152) gallery_changes.i18n = /*gradio*/ ctx[21].i18n; 1540 1541 if (!updating_selected_index && dirty & /*selected_index*/ 1) { 1542 updating_selected_index = true; 1543 gallery_changes.selected_index = /*selected_index*/ ctx[0]; 1544 add_flush_callback(() => updating_selected_index = false); 1545 } 1546 1547 gallery.$set(gallery_changes); 1548 }, 1549 i(local) { 1550 if (current) return; 1551 transition_in(statustracker.$$.fragment, local); 1552 transition_in(gallery.$$.fragment, local); 1553 current = true; 1554 }, 1555 o(local) { 1556 transition_out(statustracker.$$.fragment, local); 1557 transition_out(gallery.$$.fragment, local); 1558 current = false;
1559 }, 1560 d(detaching) { 1561 if (detaching) { 1562 detach(t); 1563 } 1564 1565 destroy_component(statustracker, detaching); 1566 destroy_component(gallery, detaching); 1567 } 1568 }; 1569} 1570 1571function create_fragment(ctx) { 1572 let block; 1573 let current; 1574 1575 block = new Block({ 1576 props: { 1577 visible: /*visible*/ ctx[8], 1578 variant: "solid", 1579 padding: false, 1580 elem_id: /*elem_id*/ ctx[6], 1581 elem_classes: /*elem_classes*/ ctx[7], 1582 container: /*container*/ ctx[10], 1583 scale: /*scale*/ ctx[11], 1584 min_width: /*min_width*/ ctx[12], 1585 allow_overflow: false, 1586 height: typeof /*height*/ ctx[15] === "number" 1587 ? /*height*/ ctx[15] 1588 : undefined, 1589 $$slots: { default: [create_default_slot] }, 1590 $$scope: { ctx } 1591 } 1592 }); 1593 1594 return { 1595 c() { 1596 create_component(block.$$.fragment); 1597 }, 1598 m(target, anchor) { 1599 mount_component(block, target, anchor); 1600 current = true; 1601 }, 1602 p(ctx, [dirty]) { 1603 const block_changes = {}; 1604 if (dirty & /*visible*/ 256) block_changes.visible = /*visible*/ ctx[8]; 1605 if (dirty & /*elem_id*/ 64) block_changes.elem_id = /*elem_id*/ ctx[6]; 1606 if (dirty & /*elem_classes*/ 128) block_changes.elem_classes = /*elem_classes*/ ctx[7]; 1607 if (dirty & /*container*/ 1024) block_changes.container = /*container*/ ctx[10]; 1608 if (dirty & /*scale*/ 2048) block_changes.scale = /*scale*/ ctx[11]; 1609 if (dirty & /*min_width*/ 4096) block_changes.min_width = /*min_width*/ ctx[12]; 1610 1611 if (dirty & /*height*/ 32768) block_changes.height = typeof /*height*/ ctx[15] === "number" 1612 ? /*height*/ ctx[15] 1613 : undefined; 1614 1615 if (dirty & /*$$scope, label, value, show_label, root, proxy_url, columns, rows, height, preview, object_fit, allow_preview, show_share_button, show_download_button, gradio, selected_index, loading_status*/ 272622143) { 1616 block_changes.$$scope = { dirty, ctx }; 1617 } 1618 1619 block.$set(block_changes); 1620 }, 1621 i(local) { 1622 if (current) return; 1623 transition_in(block.$$.fragment, local); 1624 current = true; 1625 }, 1626 o(local) { 1627 transition_out(block.$$.fragment, local); 1628 current = false; 1629 }, 1630 d(detaching) { 1631 destroy_component(block, detaching); 1632 } 1633 }; 1634} 1635 1636function instance($$self, $$props, $$invalidate) { 1637 let { loading_status } = $$props; 1638 let { show_label } = $$props; 1639 let { label } = $$props; 1640 let { root } = $$props; 1641 let { proxy_url } = $$props; 1642 let { elem_id = "" } = $$props; 1643 let { elem_classes = [] } = $$props; 1644 let { visible = true } = $$props; 1645 let { value = null } = $$props; 1646 let { container = true } = $$props; 1647 let { scale = null } = $$props; 1648 let { min_width = undefined } = $$props; 1649 let { columns = [2] } = $$props; 1650 let { rows = undefined } = $$props; 1651 let { height = "auto" } = $$props; 1652 let { preview } = $$props; 1653 let { allow_preview = true } = $$props; 1654 let { selected_index = null } = $$props; 1655 let { object_fit = "cover" } = $$props; 1656 let { show_share_button = false } = $$props; 1657 let { show_download_button = false } = $$props; 1658 let { gradio } = $$props; 1659 const dispatch = createEventDispatcher(); 1660 1661 function gallery_selected_index_binding(value) { 1662 selected_index = value; 1663 $$invalidate(0, selected_index); 1664 } 1665 1666 const change_handler = () => gradio.dispatch("change", value); 1667 const select_handler = e => gradio.dispatch("select", e.detail); 1668 const share_handler = e => gradio.dispatch("share", e.detail); 1669 const error_handler = e => gradio.dispatch("error", e.detail); 1670 1671 $$self.$$set = $$props => {
1672 if ('loading_status' in $$props) $$invalidate(1, loading_status = $$props.loading_status); 1673 if ('show_label' in $$props) $$invalidate(2, show_label = $$props.show_label); 1674 if ('label' in $$props) $$invalidate(3, label = $$props.label); 1675 if ('root' in $$props) $$invalidate(4, root = $$props.root); 1676 if ('proxy_url' in $$props) $$invalidate(5, proxy_url = $$props.proxy_url); 1677 if ('elem_id' in $$props) $$invalidate(6, elem_id = $$props.elem_id); 1678 if ('elem_classes' in $$props) $$invalidate(7, elem_classes = $$props.elem_classes); 1679 if ('visible' in $$props) $$invalidate(8, visible = $$props.visible); 1680 if ('value' in $$props) $$invalidate(9, value = $$props.value); 1681 if ('container' in $$props) $$invalidate(10, container = $$props.container); 1682 if ('scale' in $$props) $$invalidate(11, scale = $$props.scale); 1683 if ('min_width' in $$props) $$invalidate(12, min_width = $$props.min_width); 1684 if ('columns' in $$props) $$invalidate(13, columns = $$props.columns); 1685 if ('rows' in $$props) $$invalidate(14, rows = $$props.rows);
1686 if ('height' in $$props) $$invalidate(15, height = $$props.height); 1687 if ('preview' in $$props) $$invalidate(16, preview = $$props.preview); 1688 if ('allow_preview' in $$props) $$invalidate(17, allow_preview = $$props.allow_preview); 1689 if ('selected_index' in $$props) $$invalidate(0, selected_index = $$props.selected_index); 1690 if ('object_fit' in $$props) $$invalidate(18, object_fit = $$props.object_fit); 1691 if ('show_share_button' in $$props) $$invalidate(19, show_share_button = $$props.show_share_button); 1692 if ('show_download_button' in $$props) $$invalidate(20, show_download_button = $$props.show_download_button); 1693 if ('gradio' in $$props) $$invalidate(21, gradio = $$props.gradio); 1694 }; 1695 1696 $$self.$$.update = () => { 1697 if ($$self.$$.dirty & /*selected_index*/ 1) { 1698 (dispatch("prop_change", { selected_index })); 1699 } 1700 }; 1701 1702 return [ 1703 selected_index, 1704 loading_status, 1705 show_label, 1706 label, 1707 root, 1708 proxy_url, 1709 elem_id, 1710 elem_classes, 1711 visible, 1712 value, 1713 container, 1714 scale, 1715 min_width, 1716 columns, 1717 rows, 1718 height, 1719 preview, 1720 allow_preview, 1721 object_fit, 1722 show_share_button, 1723 show_download_button, 1724 gradio, 1725 gallery_selected_index_binding, 1726 change_handler, 1727 select_handler, 1728 share_handler, 1729 error_handler 1730 ]; 1731} 1732 1733class Index extends SvelteComponent { 1734 constructor(options) { 1735 super(); 1736 1737 init(this, options, instance, create_fragment, safe_not_equal, { 1738 loading_status: 1, 1739 show_label: 2, 1740 label: 3, 1741 root: 4, 1742 proxy_url: 5, 1743 elem_id: 6, 1744 elem_classes: 7, 1745 visible: 8, 1746 value: 9, 1747 container: 10, 1748 scale: 11, 1749 min_width: 12, 1750 columns: 13, 1751 rows: 14, 1752 height: 15, 1753 preview: 16, 1754 allow_preview: 17, 1755 selected_index: 0, 1756 object_fit: 18, 1757 show_share_button: 19, 1758 show_download_button: 20, 1759 gradio: 21 1760 }); 1761 } 1762} 1763 1764export { Gallery$1 as BaseGallery, Index as default }; 1765//# sourceMappingURL=Index-40075593.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.