import"./svelte/svelte_internal_flags_async.js";import*as e from"./svelte/svelte_internal_client.js";import{B as D,b as H,d as E,E as J,c as K}from"./IconButtonWrapper-Cljb5D-5.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_svelte.js";import"./i18n-BldJSFLV.js";import{G as N}from"./utils.svelte-Ceck75cM.js";import{F as O}from"./FullscreenButton-Cqzqqtq6.js";import{S as Q}from"./StreamingBar-b2qVLPYU.js";import"./MarkdownCode-C2b9iIxl.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./prism-python-CpYAgONt.js";var R=e.from_html("<img/>"),T=e.from_html('<button class="legend-item svelte-1oizopk"> </button>'),U=e.from_html('<div class="legend svelte-1oizopk"></div>'),V=e.from_html('<div class="image-container svelte-1oizopk"><!> <img alt="the base file that is annotated"/> <!></div> <!>',1),X=e.from_html('<!> <!> <div class="container svelte-1oizopk"><!></div>',1);function we(F,h){e.push(h,!0);const G=e.rest_props(h,["$$slots","$$events","$$legacy"]),t=new N(G);let f=e.state(e.proxy(t.props.value)),d=e.state(null),b,n=e.state(!1),M=e.derived(()=>t.shared.label||t.i18n("annotated_image.annotated_image"));e.user_effect(()=>{e.get(f)!=t.props.value&&(e.set(f,t.props.value,!0),t.dispatch("change"))});function $(a){e.set(d,a,!0)}function k(){e.set(d,null)}function S(a,w){t.dispatch("select",{value:w,index:a})}D(F,{get visible(){return t.shared.visible},get elem_id(){return t.shared.elem_id},get elem_classes(){return t.shared.elem_classes},padding:!1,get height(){return t.props.height},get width(){return t.props.width},allow_overflow:!1,get container(){return t.shared.container},get scale(){return t.shared.scale},get min_width(){return t.shared.min_width},get fullscreen(){return e.get(n)},set fullscreen(a){e.set(n,a,!0)},children:(a,w)=>{var x=X(),y=e.first_child(x);Q(y,e.spread_props({get autoscroll(){return t.shared.autoscroll},get i18n(){return t.i18n}},()=>t.shared.loading_status));var z=e.sibling(y,2);H(z,{get show_label(){return t.shared.show_label},get Icon(){return E},get label(){return e.get(M)}});var B=e.sibling(z,2),L=e.child(B);{var W=p=>{J(p,{size:"large",unpadded_box:!0,children:(g,c)=>{E(g)},$$slots:{default:!0}})},j=p=>{var g=V(),c=e.first_child(g),I=e.child(c);{let s=e.derived(()=>t.props.buttons||[]);K(I,{get buttons(){return e.get(s)},on_custom_button_click:o=>{t.dispatch("custom_button_click",{id:o})},children:(o,v)=>{var r=e.comment(),i=e.first_child(r);{var l=m=>{O(m,{get fullscreen(){return e.get(n)},$$events:{fullscreen:({detail:u})=>{e.set(n,u,!0)}}})};e.if(i,m=>{(t.props.buttons||[]).some(u=>typeof u=="string"&&u==="fullscreen")&&m(l)})}e.append(o,r)},$$slots:{default:!0}})}var _=e.sibling(I,2);let P;var q=e.sibling(_,2);e.each(q,17,()=>t.props.value?t.props.value.annotations:[],e.index,(s,o,v)=>{var r=R();let i;e.template_effect(l=>{e.set_attribute(r,"alt",`segmentation mask identifying ${t.shared.label??""} within the uploaded file`),i=e.set_class(r,1,"mask fit-height svelte-1oizopk",null,i,{"fit-height":!e.get(n),active:e.get(d)==e.get(o).label,inactive:e.get(d)!=e.get(o).label&&e.get(d)!=null}),e.set_attribute(r,"src",e.get(o).image.url),e.set_style(r,l)},[()=>t.props.color_map&&e.get(o).label in t.props.color_map?null:`filter: hue-rotate(${Math.round(v*360/(t.props.value?.annotations.length??1))}deg);`]),e.append(s,r)}),e.reset(c),e.bind_this(c,s=>b=s,()=>b);var A=e.sibling(c,2);{var C=s=>{var o=U();e.each(o,21,()=>t.props.value.annotations,e.index,(v,r,i)=>{var l=T(),m=e.child(l,!0);e.reset(l),e.template_effect(u=>{e.set_style(l,`background-color: ${u??""}`),e.set_text(m,e.get(r).label)},[()=>t.props.color_map&&e.get(r).label in t.props.color_map?t.props.color_map[e.get(r).label]+"88":`hsla(${Math.round(i*360/t.props.value.annotations.length)}, 100%, 50%, 0.3)`]),e.event("mouseover",l,()=>$(e.get(r).label)),e.event("focus",l,()=>$(e.get(r).label)),e.event("mouseout",l,()=>k()),e.event("blur",l,()=>k()),e.event("click",l,()=>S(i,e.get(r).label)),e.append(v,l)}),e.reset(o),e.append(s,o)};e.if(A,s=>{t.props.show_legend&&t.props.value&&s(C)})}e.template_effect(()=>{P=e.set_class(_,1,"base-image svelte-1oizopk",null,P,{"fit-height":t.props.height&&!e.get(n)}),e.set_attribute(_,"src",t.props.value?t.props.value.image.url:null)}),e.append(p,g)};e.if(L,p=>{t.props.value==null?p(W):p(j,!1)})}e.reset(B),e.append(a,x)},$$slots:{default:!0}}),e.pop()}export{we as default};
