import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_async.js";import*as e from"./svelte/svelte_internal_client.js";import{createEventDispatcher as X}from"./svelte/svelte_svelte.js";import"./i18n-BldJSFLV.js";import{u as Y}from"./utils.svelte-Ceck75cM.js";import{b as C,d as M,E as A,c as G,j as J,I as K,D as Q}from"./IconButtonWrapper-Cljb5D-5.js";import{S as U}from"./ShareButton-DCJS4lh5.js";import{F as V}from"./FullscreenButton-Cqzqqtq6.js";import{I as Z}from"./Image-Bdf4wQSw.js";const $=_=>{let r;if(_.currentTarget instanceof Element)r=_.currentTarget.querySelector("img");else return[NaN,NaN];const a=r.getBoundingClientRect(),i=r.naturalWidth/a.width,u=r.naturalHeight/a.height;if(i>u){const g=r.naturalHeight/i,o=(a.height-g)/2;var n=Math.round((_.clientX-a.left)*i),d=Math.round((_.clientY-a.top-o)*i)}else{const g=r.naturalWidth/u,o=(a.width-g)/2;var n=Math.round((_.clientX-a.left-o)*u),d=Math.round((_.clientY-a.top)*u)}return n<0||n>=r.naturalWidth||d<0||d>=r.naturalHeight?null:[n,d]};var ee=e.from_html("<!> <!> <!>",1),te=e.from_html('<div class="image-container svelte-12vrxzd"><!> <button class="svelte-12vrxzd"><div><!></div></button></div>'),re=e.from_html("<!> <!>",1);function ae(_,r){e.push(r,!1);let a=e.prop(r,"value",12),i=e.prop(r,"label",12,void 0),u=e.prop(r,"show_label",12),n=e.prop(r,"buttons",28,()=>[]),d=e.prop(r,"on_custom_button_click",12,null),g=e.prop(r,"selectable",12,!1),o=e.prop(r,"i18n",12),b=e.prop(r,"display_icon_button_wrapper_top_corner",12,!1),h=e.prop(r,"fullscreen",12,!1),p=e.prop(r,"show_button_background",12,!0);const q=X(),D=t=>{let c=$(t);c&&q("select",{index:c,value:null})};let k=e.mutable_source();var E={get value(){return a()},set value(t){a(t),e.flush()},get label(){return i()},set label(t){i(t),e.flush()},get show_label(){return u()},set show_label(t){u(t),e.flush()},get buttons(){return n()},set buttons(t){n(t),e.flush()},get on_custom_button_click(){return d()},set on_custom_button_click(t){d(t),e.flush()},get selectable(){return g()},set selectable(t){g(t),e.flush()},get i18n(){return o()},set i18n(t){o(t),e.flush()},get display_icon_button_wrapper_top_corner(){return b()},set display_icon_button_wrapper_top_corner(t){b(t),e.flush()},get fullscreen(){return h()},set fullscreen(t){h(t),e.flush()},get show_button_background(){return p()},set show_button_background(t){p(t),e.flush()}};e.init();var y=re(),I=e.first_child(y);{let t=e.derived_safe_equal(()=>(e.deep_read_state(u()),e.deep_read_state(i()),e.deep_read_state(o()),e.untrack(()=>u()?i()||o()("image.image"):"")));C(I,{get show_label(){return u()},get Icon(){return M},get label(){return e.get(t)}})}var H=e.sibling(I,2);{var N=t=>{A(t,{unpadded_box:!0,size:"large",children:(c,m)=>{M(c)},$$slots:{default:!0}})},T=t=>{var c=te(),m=e.child(c);G(m,{get display_top_corner(){return b()},get show_background(){return p()},get buttons(){return n()},get on_custom_button_click(){return d()},children:(f,le)=>{var P=ee(),S=e.first_child(P);{var j=s=>{V(s,{get fullscreen(){return h()},$$events:{fullscreen(l){e.bubble_event.call(this,r,l)}}})};e.if(S,s=>{e.deep_read_state(n()),e.untrack(()=>n().some(l=>typeof l=="string"&&l==="fullscreen"))&&s(j)})}var z=e.sibling(S,2);{var F=s=>{{let l=e.derived_safe_equal(()=>(e.deep_read_state(a()),e.untrack(()=>a().orig_name||"image")));J(s,{get href(){return e.deep_read_state(a()),e.untrack(()=>a().url)},get download(){return e.get(l)},children:(B,ne)=>{{let R=e.derived_safe_equal(()=>(e.deep_read_state(o()),e.untrack(()=>o()("common.download"))));K(B,{get Icon(){return Q},get label(){return e.get(R)}})}},$$slots:{default:!0}})}};e.if(z,s=>{e.deep_read_state(n()),e.untrack(()=>n().some(l=>typeof l=="string"&&l==="download"))&&s(F)})}var L=e.sibling(z,2);{var O=s=>{U(s,{get i18n(){return o()},formatter:async l=>l?`<img src="${await Y(l)}" />`:"",get value(){return a()},$$events:{share(l){e.bubble_event.call(this,r,l)},error(l){e.bubble_event.call(this,r,l)}}})};e.if(L,s=>{e.deep_read_state(n()),e.untrack(()=>n().some(l=>typeof l=="string"&&l==="share"))&&s(O)})}e.append(f,P)},$$slots:{default:!0}});var v=e.sibling(m,2),w=e.child(v);let x;var W=e.child(w);Z(W,{get src(){return e.deep_read_state(a()),e.untrack(()=>a().url)},restProps:{loading:"lazy",alt:""},$$events:{load(f){e.bubble_event.call(this,r,f)}}}),e.reset(w),e.reset(v),e.reset(c),e.bind_this(c,f=>e.set(k,f),()=>e.get(k)),e.template_effect(()=>x=e.set_class(w,1,"image-frame svelte-12vrxzd",null,x,{selectable:g()})),e.event("click",v,D),e.append(t,c)};e.if(H,t=>{e.deep_read_state(a()),e.untrack(()=>a()==null||!a()?.url)?t(N):t(T,!1)})}return e.append(_,y),e.pop(E)}const be=Object.freeze(Object.defineProperty({__proto__:null,default:ae},Symbol.toStringTag,{value:"Module"}));export{ae as I,be as a,$ as g};
