1import { B as Block } from './Button-f2ef1e3f.js'; 2import { B as BlockLabel } from './BlockLabel-b0ab52e0.js'; 3import { E as Empty } from './Empty-27f3e442.js'; 4import { S as Static } from './Index-f4e7a341.js'; 5import { I as Image } from './Image-6cbf81d1.js'; 6import { n as normalise_file } from './index-546f83db.js'; 7import { r as resolve_wasm_src } from './file-url-c18a1f7c.js'; 8import './svelte/svelte.js'; 9 10const Index_svelte_svelte_type_style_lang = ''; 11 12/* home/runner/work/gradio/gradio/js/annotatedimage/Index.svelte generated by Svelte v4.2.2 */ 13const { 14 SvelteComponent, 15 append, 16 assign, 17 attr, 18 check_outros, 19 create_component, 20 destroy_component, 21 destroy_each, 22 detach, 23 element, 24 empty, 25 ensure_array_like, 26 get_spread_object, 27 get_spread_update, 28 group_outros, 29 init, 30 insert, 31 listen, 32 mount_component, 33 noop, 34 run_all, 35 safe_not_equal, 36 set_data, 37 set_style, 38 space, 39 src_url_equal, 40 text, 41 toggle_class, 42 transition_in, 43 transition_out 44} = window.__gradio__svelte__internal; 45function get_each_context(ctx, list, i) { 46 const child_ctx = ctx.slice(); 47 child_ctx[29] = list[i]; 48 child_ctx[31] = i; 49 return child_ctx; 50} 51 52function get_each_context_1(ctx, list, i) { 53 const child_ctx = ctx.slice(); 54 child_ctx[29] = list[i]; 55 child_ctx[31] = i; 56 return child_ctx; 57} 58 59// (120:2) {:else} 60function create_else_block(ctx) { 61 let div; 62 let img; 63 let img_src_value; 64 let t0; 65 let t1; 66 let if_block_anchor; 67 68 let each_value_1 = ensure_array_like(/*_value*/ ctx[14] 69 ? /*_value*/ ctx[14]?.annotations 70 : []); 71 72 let each_blocks = []; 73 74 for (let i = 0; i < each_value_1.length; i += 1) { 75 each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); 76 } 77 78 let if_block = /*show_legend*/ ctx[6] && /*_value*/ ctx[14] && create_if_block_1(ctx); 79 80 return { 81 c() { 82 div = element("div"); 83 img = element("img"); 84 t0 = space(); 85 86 for (let i = 0; i < each_blocks.length; i += 1) { 87 each_blocks[i].c(); 88 } 89 90 t1 = space(); 91 if (if_block) if_block.c(); 92 if_block_anchor = empty(); 93 attr(img, "class", "base-image svelte-m3v3vb"); 94 if (!src_url_equal(img.src, img_src_value = /*_value*/ ctx[14] ? /*_value*/ ctx[14].image.url : null)) attr(img, "src", img_src_value); 95 attr(img, "alt", "the base file that is annotated"); 96 toggle_class(img, "fit-height", /*height*/ ctx[7]); 97 attr(div, "class", "image-container svelte-m3v3vb"); 98 }, 99 m(target, anchor) { 100 insert(target, div, anchor); 101 append(div, img); 102 append(div, t0); 103 104 for (let i = 0; i < each_blocks.length; i += 1) { 105 if (each_blocks[i]) { 106 each_blocks[i].m(div, null); 107 } 108 } 109 110 insert(target, t1, anchor); 111 if (if_block) if_block.m(target, anchor); 112 insert(target, if_block_anchor, anchor); 113 }, 114 p(ctx, dirty) { 115 if (dirty[0] & /*_value*/ 16384 && !src_url_equal(img.src, img_src_value = /*_value*/ ctx[14] ? /*_value*/ ctx[14].image.url : null)) { 116 attr(img, "src", img_src_value); 117 } 118 119 if (dirty[0] & /*height*/ 128) { 120 toggle_class(img, "fit-height", /*height*/ ctx[7]); 121 } 122 123 if (dirty[0] & /*label, _value, color_map, active*/ 49680) { 124 each_value_1 = ensure_array_like(/*_value*/ ctx[14] 125 ? /*_value*/ ctx[14]?.annotations 126 : []); 127 128 let i; 129 130 for (i = 0; i < each_value_1.length; i += 1) { 131 const child_ctx = get_each_context_1(ctx, each_value_1, i); 132 133 if (each_blocks[i]) { 134 each_blocks[i].p(child_ctx, dirty); 135 } else { 136 each_blocks[i] = create_each_block_1(child_ctx); 137 each_blocks[i].c(); 138 each_blocks[i].m(div, null); 139 } 140 } 141 142 for (; i < each_blocks.length; i += 1) { 143 each_blocks[i].d(1); 144 } 145 146 each_blocks.length = each_value_1.length; 147 } 148 149 if (/*show_legend*/ ctx[6] && /*_value*/ ctx[14]) { 150 if (if_block) { 151 if_block.p(ctx, dirty); 152 } else { 153 if_block = create_if_block_1(ctx); 154 if_block.c(); 155 if_block.m(if_block_anchor.parentNode, if_block_anchor); 156 } 157 } else if (if_block) { 158 if_block.d(1); 159 if_block = null; 160 } 161 }, 162 i: noop, 163 o: noop, 164 d(detaching) { 165 if (detaching) { 166 detach(div); 167 detach(t1); 168 detach(if_block_anchor); 169 } 170 171 destroy_each(each_blocks, detaching); 172 if (if_block) if_block.d(detaching); 173 } 174 }; 175} 176 177// (118:2) {#if _value == null} 178function create_if_block(ctx) { 179 let empty_1; 180 let current; 181 182 empty_1 = new Empty({ 183 props: { 184 size: "large", 185 unpadded_box: true, 186 $$slots: { default: [create_default_slot_1] }, 187 $$scope: { ctx } 188 } 189 }); 190 191 return { 192 c() { 193 create_component(empty_1.$$.fragment); 194 }, 195 m(target, anchor) { 196 mount_component(empty_1, target, anchor); 197 current = true; 198 }, 199 p(ctx, dirty) { 200 const empty_1_changes = {}; 201
202 if (dirty[1] & /*$$scope*/ 4) { 203 empty_1_changes.$$scope = { dirty, ctx }; 204 } 205 206 empty_1.$set(empty_1_changes); 207 }, 208 i(local) { 209 if (current) return; 210 transition_in(empty_1.$$.fragment, local); 211 current = true; 212 }, 213 o(local) { 214 transition_out(empty_1.$$.fragment, local); 215 current = false; 216 }, 217 d(detaching) { 218 destroy_component(empty_1, detaching); 219 } 220 }; 221} 222 223// (128:4) {#each _value ? _value?.annotations : [] as ann, i} 224function create_each_block_1(ctx) { 225 let img; 226 let img_alt_value; 227 let img_src_value; 228 let img_style_value; 229 230 return { 231 c() { 232 img = element("img"); 233 attr(img, "alt", img_alt_value = "segmentation mask identifying " + /*label*/ ctx[4] + " within the uploaded file"); 234 attr(img, "class", "mask fit-height svelte-m3v3vb"); 235 if (!src_url_equal(img.src, img_src_value = /*ann*/ ctx[29].image.url)) attr(img, "src", img_src_value); 236 237 attr(img, "style", img_style_value = /*color_map*/ ctx[9] && /*ann*/ ctx[29].label in /*color_map*/ ctx[9] 238 ? null 239 : `filter: hue-rotate(${Math.round(/*i*/ ctx[31] * 360 / /*_value*/ ctx[14]?.annotations.length)}deg);`); 240 241 toggle_class(img, "active", /*active*/ ctx[15] == /*ann*/ ctx[29].label); 242 toggle_class(img, "inactive", /*active*/ ctx[15] != /*ann*/ ctx[29].label && /*active*/ ctx[15] != null); 243 }, 244 m(target, anchor) { 245 insert(target, img, anchor); 246 }, 247 p(ctx, dirty) { 248 if (dirty[0] & /*label*/ 16 && img_alt_value !== (img_alt_value = "segmentation mask identifying " + /*label*/ ctx[4] + " within the uploaded file")) { 249 attr(img, "alt", img_alt_value); 250 } 251 252 if (dirty[0] & /*_value*/ 16384 && !src_url_equal(img.src, img_src_value = /*ann*/ ctx[29].image.url)) { 253 attr(img, "src", img_src_value); 254 } 255 256 if (dirty[0] & /*color_map, _value*/ 16896 && img_style_value !== (img_style_value = /*color_map*/ ctx[9] && /*ann*/ ctx[29].label in /*color_map*/ ctx[9] 257 ? null 258 : `filter: hue-rotate(${Math.round(/*i*/ ctx[31] * 360 / /*_value*/ ctx[14]?.annotations.length)}deg);`)) { 259 attr(img, "style", img_style_value); 260 } 261 262 if (dirty[0] & /*active, _value*/ 49152) { 263 toggle_class(img, "active", /*active*/ ctx[15] == /*ann*/ ctx[29].label); 264 } 265 266 if (dirty[0] & /*active, _value*/ 49152) { 267 toggle_class(img, "inactive", /*active*/ ctx[15] != /*ann*/ ctx[29].label && /*active*/ ctx[15] != null); 268 } 269 }, 270 d(detaching) { 271 if (detaching) { 272 detach(img); 273 } 274 } 275 }; 276} 277 278// (143:3) {#if show_legend && _value} 279function create_if_block_1(ctx) { 280 let div; 281 let each_value = ensure_array_like(/*_value*/ ctx[14].annotations); 282 let each_blocks = []; 283 284 for (let i = 0; i < each_value.length; i += 1) { 285 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 286 } 287 288 return { 289 c() { 290 div = element("div"); 291 292 for (let i = 0; i < each_blocks.length; i += 1) { 293 each_blocks[i].c(); 294 } 295 296 attr(div, "class", "legend svelte-m3v3vb"); 297 }, 298 m(target, anchor) { 299 insert(target, div, anchor); 300 301 for (let i = 0; i < each_blocks.length; i += 1) { 302 if (each_blocks[i]) { 303 each_blocks[i].m(div, null); 304 } 305 } 306 }, 307 p(ctx, dirty) { 308 if (dirty[0] & /*color_map, _value, handle_mouseover, handle_mouseout, handle_click*/ 475648) { 309 each_value = ensure_array_like(/*_value*/ ctx[14].annotations); 310 let i; 311 312 for (i = 0; i < each_value.length; i += 1) { 313 const child_ctx = get_each_context(ctx, each_value, i); 314 315 if (each_blocks[i]) { 316 each_blocks[i].p(child_ctx, dirty); 317 } else { 318 each_blocks[i] = create_each_block(child_ctx); 319 each_blocks[i].c(); 320 each_blocks[i].m(div, null); 321 } 322 } 323 324 for (; i < each_blocks.length; i += 1) { 325 each_blocks[i].d(1); 326 } 327 328 each_blocks.length = each_value.length; 329 } 330 }, 331 d(detaching) { 332 if (detaching) { 333 detach(div); 334 } 335 336 destroy_each(each_blocks, detaching); 337 } 338 }; 339} 340 341// (145:5) {#each _value.annotations as ann, i} 342function create_each_block(ctx) { 343 let button; 344 let t0_value = /*ann*/ ctx[29].label + ""; 345 let t0; 346 let t1; 347 let mounted; 348 let dispose; 349 350 function mouseover_handler() { 351 return /*mouseover_handler*/ ctx[24](/*ann*/ ctx[29]); 352 } 353 354 function focus_handler() { 355 return /*focus_handler*/ ctx[25](/*ann*/ ctx[29]); 356 } 357 358 function click_handler() { 359 return /*click_handler*/ ctx[28](/*i*/ ctx[31], /*ann*/ ctx[29]); 360 } 361 362 return { 363 c() { 364 button = element("button"); 365 t0 = text(t0_value); 366 t1 = space(); 367 attr(button, "class", "legend-item svelte-m3v3vb"); 368 369 set_style(button, "background-color", /*color_map*/ ctx[9] && /*ann*/ ctx[29].label in /*color_map*/ ctx[9] 370 ? /*color_map*/ ctx[9][/*ann*/ ctx[29].label] + '88' 371 : `hsla(${Math.round(/*i*/ ctx[31] * 360 / /*_value*/ ctx[14].annotations.length)}, 100%, 50%, 0.3)`); 372 }, 373 m(target, anchor) { 374 insert(target, button, anchor); 375 append(button, t0); 376 append(button, t1); 377 378 if (!mounted) { 379 dispose = [
380 listen(button, "mouseover", mouseover_handler), 381 listen(button, "focus", focus_handler), 382 listen(button, "mouseout", /*mouseout_handler*/ ctx[26]), 383 listen(button, "blur", /*blur_handler*/ ctx[27]), 384 listen(button, "click", click_handler) 385 ]; 386 387 mounted = true; 388 } 389 }, 390 p(new_ctx, dirty) { 391 ctx = new_ctx; 392 if (dirty[0] & /*_value*/ 16384 && t0_value !== (t0_value = /*ann*/ ctx[29].label + "")) set_data(t0, t0_value); 393 394 if (dirty[0] & /*color_map, _value*/ 16896) { 395 set_style(button, "background-color", /*color_map*/ ctx[9] && /*ann*/ ctx[29].label in /*color_map*/ ctx[9] 396 ? /*color_map*/ ctx[9][/*ann*/ ctx[29].label] + '88' 397 : `hsla(${Math.round(/*i*/ ctx[31] * 360 / /*_value*/ ctx[14].annotations.length)}, 100%, 50%, 0.3)`); 398 } 399 }, 400 d(detaching) { 401 if (detaching) { 402 detach(button); 403 } 404 405 mounted = false; 406 run_all(dispose); 407 } 408 }; 409} 410 411// (119:3) <Empty size="large" unpadded_box={true}> 412function create_default_slot_1(ctx) { 413 let image; 414 let current; 415 image = new Image({}); 416 417 return { 418 c() { 419 create_component(image.$$.fragment); 420 }, 421 m(target, anchor) { 422 mount_component(image, target, anchor); 423 current = true; 424 }, 425 i(local) { 426 if (current) return; 427 transition_in(image.$$.fragment, local); 428 current = true; 429 }, 430 o(local) { 431 transition_out(image.$$.fragment, local); 432 current = false; 433 }, 434 d(detaching) { 435 destroy_component(image, detaching); 436 } 437 }; 438} 439 440// (94:0) <Block {visible} {elem_id} {elem_classes} padding={false} {height} {width} allow_overflow={false} {container} {scale} {min_width} > 441function create_default_slot(ctx) { 442 let statustracker; 443 let t0; 444 let blocklabel; 445 let t1; 446 let div; 447 let current_block_type_index; 448 let if_block; 449 let current; 450 451 const statustracker_spread_levels = [ 452 { autoscroll: /*gradio*/ ctx[3].autoscroll }, 453 { i18n: /*gradio*/ ctx[3].i18n }, 454 /*loading_status*/ ctx[13] 455 ]; 456 457 let statustracker_props = {}; 458 459 for (let i = 0; i < statustracker_spread_levels.length; i += 1) { 460 statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]); 461 } 462 463 statustracker = new Static({ props: statustracker_props }); 464 465 blocklabel = new BlockLabel({ 466 props: { 467 show_label: /*show_label*/ ctx[5], 468 Icon: Image, 469 label: /*label*/ ctx[4] || /*gradio*/ ctx[3].i18n("image.image") 470 } 471 }); 472 473 const if_block_creators = [create_if_block, create_else_block]; 474 const if_blocks = []; 475 476 function select_block_type(ctx, dirty) { 477 if (/*_value*/ ctx[14] == null) return 0; 478 return 1; 479 } 480 481 current_block_type_index = select_block_type(ctx); 482 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 483 484 return { 485 c() { 486 create_component(statustracker.$$.fragment); 487 t0 = space(); 488 create_component(blocklabel.$$.fragment); 489 t1 = space(); 490 div = element("div"); 491 if_block.c(); 492 attr(div, "class", "container svelte-m3v3vb"); 493 }, 494 m(target, anchor) { 495 mount_component(statustracker, target, anchor); 496 insert(target, t0, anchor); 497 mount_component(blocklabel, target, anchor); 498 insert(target, t1, anchor); 499 insert(target, div, anchor); 500 if_blocks[current_block_type_index].m(div, null); 501 current = true; 502 }, 503 p(ctx, dirty) { 504 const statustracker_changes = (dirty[0] & /*gradio, loading_status*/ 8200) 505 ? get_spread_update(statustracker_spread_levels, [ 506 dirty[0] & /*gradio*/ 8 && { autoscroll: /*gradio*/ ctx[3].autoscroll }, 507 dirty[0] & /*gradio*/ 8 && { i18n: /*gradio*/ ctx[3].i18n }, 508 dirty[0] & /*loading_status*/ 8192 && get_spread_object(/*loading_status*/ ctx[13]) 509 ]) 510 : {}; 511 512 statustracker.$set(statustracker_changes); 513 const blocklabel_changes = {}; 514 if (dirty[0] & /*show_label*/ 32) blocklabel_changes.show_label = /*show_label*/ ctx[5]; 515 if (dirty[0] & /*label, gradio*/ 24) blocklabel_changes.label = /*label*/ ctx[4] || /*gradio*/ ctx[3].i18n("image.image"); 516 blocklabel.$set(blocklabel_changes); 517 let previous_block_index = current_block_type_index; 518 current_block_type_index = select_block_type(ctx); 519 520 if (current_block_type_index === previous_block_index) { 521 if_blocks[current_block_type_index].p(ctx, dirty); 522 } else { 523 group_outros(); 524 525 transition_out(if_blocks[previous_block_index], 1, 1, () => { 526 if_blocks[previous_block_index] = null; 527 }); 528 529 check_outros(); 530 if_block = if_blocks[current_block_type_index]; 531 532 if (!if_block) { 533 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 534 if_block.c(); 535 } else { 536 if_block.p(ctx, dirty); 537 } 538 539 transition_in(if_block, 1); 540 if_block.m(div, null); 541 } 542 }, 543 i(local) { 544 if (current) return; 545 transition_in(statustracker.$$.fragment, local); 546 transition_in(blocklabel.$$.fragment, local); 547 transition_in(if_block); 548 current = true; 549 }, 550 o(local) { 551 transition_out(statustracker.$$.fragment, local); 552 transition_out(blocklabel.$$.fragment, local); 553 transition_out(if_block); 554 current = false;
555 }, 556 d(detaching) { 557 if (detaching) { 558 detach(t0); 559 detach(t1); 560 detach(div); 561 } 562 563 destroy_component(statustracker, detaching); 564 destroy_component(blocklabel, detaching); 565 if_blocks[current_block_type_index].d(); 566 } 567 }; 568} 569 570function create_fragment(ctx) { 571 let block; 572 let current; 573 574 block = new Block({ 575 props: { 576 visible: /*visible*/ ctx[2], 577 elem_id: /*elem_id*/ ctx[0], 578 elem_classes: /*elem_classes*/ ctx[1], 579 padding: false, 580 height: /*height*/ ctx[7], 581 width: /*width*/ ctx[8], 582 allow_overflow: false, 583 container: /*container*/ ctx[10], 584 scale: /*scale*/ ctx[11], 585 min_width: /*min_width*/ ctx[12], 586 $$slots: { default: [create_default_slot] }, 587 $$scope: { ctx } 588 } 589 }); 590 591 return { 592 c() { 593 create_component(block.$$.fragment); 594 }, 595 m(target, anchor) { 596 mount_component(block, target, anchor); 597 current = true; 598 }, 599 p(ctx, dirty) { 600 const block_changes = {}; 601 if (dirty[0] & /*visible*/ 4) block_changes.visible = /*visible*/ ctx[2]; 602 if (dirty[0] & /*elem_id*/ 1) block_changes.elem_id = /*elem_id*/ ctx[0]; 603 if (dirty[0] & /*elem_classes*/ 2) block_changes.elem_classes = /*elem_classes*/ ctx[1]; 604 if (dirty[0] & /*height*/ 128) block_changes.height = /*height*/ ctx[7]; 605 if (dirty[0] & /*width*/ 256) block_changes.width = /*width*/ ctx[8]; 606 if (dirty[0] & /*container*/ 1024) block_changes.container = /*container*/ ctx[10]; 607 if (dirty[0] & /*scale*/ 2048) block_changes.scale = /*scale*/ ctx[11]; 608 if (dirty[0] & /*min_width*/ 4096) block_changes.min_width = /*min_width*/ ctx[12]; 609 610 if (dirty[0] & /*_value, color_map, show_legend, label, active, height, show_label, gradio, loading_status*/ 58104 | dirty[1] & /*$$scope*/ 4) { 611 block_changes.$$scope = { dirty, ctx }; 612 } 613 614 block.$set(block_changes); 615 }, 616 i(local) { 617 if (current) return; 618 transition_in(block.$$.fragment, local); 619 current = true; 620 }, 621 o(local) { 622 transition_out(block.$$.fragment, local); 623 current = false; 624 }, 625 d(detaching) { 626 destroy_component(block, detaching); 627 } 628 }; 629} 630 631function instance($$self, $$props, $$invalidate) { 632 let { elem_id = "" } = $$props; 633 let { elem_classes = [] } = $$props; 634 let { visible = true } = $$props; 635 let { value = null } = $$props; 636 let old_value = null; 637 let _value = null; 638 let { gradio } = $$props; 639 let { label = gradio.i18n("annotated_image.annotated_image") } = $$props; 640 let { show_label = true } = $$props; 641 let { show_legend = true } = $$props; 642 let { height } = $$props; 643 let { width } = $$props; 644 let { color_map } = $$props; 645 let { container = true } = $$props; 646 let { scale = null } = $$props; 647 let { min_width = undefined } = $$props; 648 let { root } = $$props; 649 let { proxy_url } = $$props; 650 let active = null; 651 let { loading_status } = $$props; 652 653 // `value` can be updated before the Promises from `resolve_wasm_src` are resolved. 654 // In such a case, the resolved values for the old `value` have to be discarded, 655 // This variable `latest_promise` is used to pick up only the values resolved for the latest `value`. 656 let latest_promise = null; 657 658 function handle_mouseover(_label) { 659 $$invalidate(15, active = _label); 660 } 661 662 function handle_mouseout() { 663 $$invalidate(15, active = null); 664 } 665 666 function handle_click(i, value) { 667 gradio.dispatch("select", { value: label, index: i }); 668 } 669 670 const mouseover_handler = ann => handle_mouseover(ann.label); 671 const focus_handler = ann => handle_mouseover(ann.label); 672 const mouseout_handler = () => handle_mouseout(); 673 const blur_handler = () => handle_mouseout(); 674 const click_handler = (i, ann) => handle_click(i, ann.label); 675 676 $$self.$$set = $$props => {
677 if ('elem_id' in $$props) $$invalidate(0, elem_id = $$props.elem_id); 678 if ('elem_classes' in $$props) $$invalidate(1, elem_classes = $$props.elem_classes); 679 if ('visible' in $$props) $$invalidate(2, visible = $$props.visible); 680 if ('value' in $$props) $$invalidate(19, value = $$props.value); 681 if ('gradio' in $$props) $$invalidate(3, gradio = $$props.gradio); 682 if ('label' in $$props) $$invalidate(4, label = $$props.label); 683 if ('show_label' in $$props) $$invalidate(5, show_label = $$props.show_label); 684 if ('show_legend' in $$props) $$invalidate(6, show_legend = $$props.show_legend); 685 if ('height' in $$props) $$invalidate(7, height = $$props.height); 686 if ('width' in $$props) $$invalidate(8, width = $$props.width); 687 if ('color_map' in $$props) $$invalidate(9, color_map = $$props.color_map); 688 if ('container' in $$props) $$invalidate(10, container = $$props.container); 689 if ('scale' in $$props) $$invalidate(11, scale = $$props.scale); 690 if ('min_width' in $$props) $$invalidate(12, min_width = $$props.min_width);
691 if ('root' in $$props) $$invalidate(20, root = $$props.root); 692 if ('proxy_url' in $$props) $$invalidate(21, proxy_url = $$props.proxy_url); 693 if ('loading_status' in $$props) $$invalidate(13, loading_status = $$props.loading_status); 694 }; 695 696 $$self.$$.update = () => { 697 if ($$self.$$.dirty[0] & /*value, old_value, gradio, root, proxy_url, latest_promise*/ 16252936) { 698 { 699 if (value !== old_value) { 700 $$invalidate(22, old_value = value); 701 gradio.dispatch("change"); 702 } 703 704 if (value) { 705 const normalized_value = { 706 image: normalise_file(value.image, root, proxy_url), 707 annotations: value.annotations.map(ann => ({ 708 image: normalise_file(ann.image, root, proxy_url), 709 label: ann.label 710 })) 711 }; 712 713 $$invalidate(14, _value = normalized_value); 714 715 // In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed values immediately 716 // without waiting for `resolve_wasm_src()` to resolve. 717 // If it waits, a blank image is displayed until the async task finishes 718 // and it leads to undesirable flickering. 719 // So set `_value` immediately above, and update it with the resolved values below later. 720 const image_url_promise = resolve_wasm_src(normalized_value.image.url); 721 722 const annotation_urls_promise = Promise.all(normalized_value.annotations.map(ann => resolve_wasm_src(ann.image.url))); 723 const current_promise = Promise.all([image_url_promise, annotation_urls_promise]); 724 $$invalidate(23, latest_promise = current_promise); 725 726 current_promise.then(([image_url, annotation_urls]) => { 727 if (latest_promise !== current_promise) { 728 return; 729 } 730 731 const async_resolved_value = { 732 image: { 733 ...normalized_value.image, 734 url: image_url ?? undefined 735 }, 736 annotations: normalized_value.annotations.map((ann, i) => ({ 737 ...ann, 738 image: { 739 ...ann.image, 740 url: annotation_urls[i] ?? undefined 741 } 742 })) 743 }; 744 745 $$invalidate(14, _value = async_resolved_value); 746 }); 747 } else { 748 $$invalidate(14, _value = null); 749 } 750 } 751 } 752 }; 753 754 return [ 755 elem_id, 756 elem_classes, 757 visible, 758 gradio, 759 label, 760 show_label, 761 show_legend, 762 height, 763 width, 764 color_map, 765 container, 766 scale, 767 min_width, 768 loading_status, 769 _value, 770 active, 771 handle_mouseover, 772 handle_mouseout, 773 handle_click, 774 value, 775 root, 776 proxy_url, 777 old_value, 778 latest_promise, 779 mouseover_handler, 780 focus_handler, 781 mouseout_handler, 782 blur_handler, 783 click_handler 784 ]; 785} 786 787class Index extends SvelteComponent { 788 constructor(options) { 789 super(); 790 791 init( 792 this, 793 options, 794 instance, 795 create_fragment, 796 safe_not_equal, 797 { 798 elem_id: 0, 799 elem_classes: 1, 800 visible: 2, 801 value: 19, 802 gradio: 3, 803 label: 4, 804 show_label: 5, 805 show_legend: 6, 806 height: 7, 807 width: 8, 808 color_map: 9, 809 container: 10, 810 scale: 11, 811 min_width: 12, 812 root: 20, 813 proxy_url: 21, 814 loading_status: 13 815 }, 816 null, 817 [-1, -1] 818 ); 819 } 820} 821 822export { Index as default }; 823//# sourceMappingURL=Index-c23b5c72.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.