import './async-D55cHugf.js';
import { d as bind_props, f as attr_class, g as attr_style, i as stringify, e as ensure_array_like, a as attr } from './index-u8mz_F03.js';
import { k } from './BlockLabel-bKYWnOzQ.js';
import { w } from './IconButton-BRnu7KaR.js';
import { p } from './Empty-DGRbZO0a.js';
import { y as y$1 } from './ShareButton-7VTs9dOO.js';
import { o } from './Clear-D7Yjckqz.js';
import { l } from './Download-DcU5dONL.js';
import { i } from './Image2-vcp9_ifi.js';
import { h, e } from './Upload-BbxeBrrD.js';
import { n } from './Play-B_z3rKL1.js';
import { r } from './Video-FfbWmOVG.js';
import { h as h$1 } from './Webcam-CvKMKUzA.js';
import { y } from './IconButtonWrapper-CjFRPb3y.js';
import { k as k$1 } from './FullscreenButton-D8PvgSmk.js';
import { L as Le } from './2-BLdXJizP.js';
import { e as ee } from './Upload2-uTutz1dY.js';
import { v } from './ModifyUpload-CWSi2EyW.js';
import { c } from './Image-CuPo5pWT.js';
import { c as ch } from './Video2-BN5I0jvO.js';
import { b } from './utils.svelte-B2py64Fz.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index-server-CQz6EZl_.js';
import './Maximize-CuHbK64j.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './DownloadLink-nj1p0krE.js';
import './Edit-DWZSi_T0.js';
import './Undo-Ce01x-M5.js';
import './clone-Yk88IHKV.js';

async function rt(h){return h?`<div style="display: flex; flex-wrap: wrap; gap: 16px">${(await Promise.all(h.map(async([c,g])=>c===null||!c.url?"":await b(c.url)))).map(c=>`<img src="${c}" style="height: 400px" />`).join("")}</div>`:""}async function ll(h,d,c="uploaded_file"){const g=h.type.split("/")[1]||"png",f=new File([h],`${c}.${g}`),m=[new Le({path:f.name,orig_name:f.name,blob:f,size:f.size,mime_type:f.type,is_stream:false})];return await d(...m)}function xt(h$2,d){h$2.component(c$1=>{let{show_label:g=true,label:f,value:m=void 0,columns:O=[2],rows:R=void 0,height:b="auto",preview:S,allow_preview:V=true,object_fit:C="cover",show_share_button:W=false,show_download_button:A=false,i18n:_,selected_index:p$1=void 0,interactive:E,_fetch:H,show_fullscreen_button:q=true,fullscreen:J=false,root:K="",file_types:N=["image","video"],sources:k$2,max_file_size:Q=null,upload:L,stream_handler:P,fit_columns:X=true,buttons:Y=null,oncustom_button_click:Z=null,onpreview_open:Ut=()=>{},onchange:jt=()=>{},onclear:$=()=>{},onselect:Et=t=>{},onshare:Lt=t=>{},onerror:tt=t=>{},onpreview_close:lt=()=>{},onfullscreen:at=t=>{},ondelete:Pt=()=>{},onupload:it=()=>{},onsource_change:y$2=()=>{}}=d,B=null,I="normal",ot=false,r$1=false,u=m==null?null:m.map(t=>"video"in t?{video:t.video,caption:t.caption}:"image"in t?{image:t.image,caption:t.caption}:{});function st(t,n,a){if(t&&n&&a){const l=t.length;return Array.isArray(n)?n.map(i=>Math.min(i,l)):Math.min(n,l)}else return n}let ut=st(u,O,X);p$1==null&&S&&m?.length&&(p$1=0),((p$1??0)+(u?.length??0)-1)%(u?.length??0),((p$1??0)+1)%(u?.length??0);async function nt(t,n){let a;try{a=await H(t);}catch(z){if(z instanceof TypeError){window.open(t,"_blank","noreferrer");return}throw z}const l=await a.blob(),i=URL.createObjectURL(l),e=document.createElement("a");e.href=i,e.download=n,e.click(),URL.revokeObjectURL(i);}let s=p$1!=null&&u!=null?u[p$1]:null;let M=false,w$1=true,x;function et(t){if(g?(t.push("<!--[-->"),k(t,{show_label:g,Icon:i,label:f||"Gallery"})):t.push("<!--[!-->"),t.push("<!--]--> "),m==null||u==null||u.length===0)t.push("<!--[-->"),p(t,{unpadded_box:true,size:"large",children:n=>{i(n);},$$slots:{default:true}});else {if(t.push("<!--[!-->"),t.push('<div class="gallery-container svelte-7anmrz">'),s&&V){t.push("<!--[-->"),t.push(`<span${attr_class("preview svelte-7anmrz",void 0,{minimal:I==="minimal"})}>`),y(t,{display_top_corner:ot,buttons:Y,on_custom_button_click:Z,children:l$1=>{A?(l$1.push("<!--[-->"),w(l$1,{Icon:l,label:_("common.download"),onclick:()=>{const i="image"in s?s?.image:s?.video;if(i==null)return;const{url:e,orig_name:z}=i;e&&nt(e,z??"image");}})):l$1.push("<!--[!-->"),l$1.push("<!--]--> "),q?(l$1.push("<!--[-->"),k$1(l$1,{fullscreen:J,onclick:i=>at({detail:i})})):l$1.push("<!--[!-->"),l$1.push("<!--]--> "),W?(l$1.push("<!--[-->"),l$1.push('<div class="icon-button">'),y$1(l$1,{i18n:_,value:u,formatter:rt}),l$1.push("<!----></div>")):l$1.push("<!--[!-->"),l$1.push("<!--]--> "),(l$1.push("<!--[-->"),w(l$1,{Icon:o,label:"Close",onclick:()=>{p$1=null,lt();}})),l$1.push("<!--]-->");}}),t.push(`<!----> <button class="media-button svelte-7anmrz"${attr_style(`height: calc(100% - ${stringify(s.caption?"80px":"60px")})`)} aria-label="detailed view of selected image">`),"image"in s?(t.push("<!--[-->"),c(t,{restProps:{alt:s.caption||"",title:s.caption||null,class:s.caption&&"with-caption",loading:"lazy"},src:s.image.url,data_testid:"detailed-image"})):(t.push("<!--[!-->"),ch(t,{src:s.video.url,"data-testid":"detailed-video",alt:s.caption||"",loading:"lazy",loop:false,is_stream:false,muted:false,controls:true})),t.push("<!--]--></button> "),s?.caption?(t.push("<!--[-->"),t.push(`<caption class="caption svelte-7anmrz">${escape_html(s.caption)}</caption>`)):t.push("<!--[!-->"),t.push(`<!--]--> <div class="thumbnails scroll-hide svelte-7anmrz" data-testid="container_el"${attr_style(`justify-content: ${stringify("center")};`)}><!--[-->`);const a=ensure_array_like(u);for(let l=0,i=a.length;l<i;l++){let e=a[l];t.push(`<button${attr_class("thumbnail-item thumbnail-small svelte-7anmrz",void 0,{selected:p$1===l&&I!=="minimal"})}${attr("aria-label","Thumbnail "+(l+1)+" of "+u.length)}>`),"image"in e?(t.push("<!--[-->"),c(t,{src:e.image.url,restProps:{title:e.caption||null,alt:"",class:"with-caption",loading:"lazy"},data_testid:`thumbnail ${l+1}`})):(t.push("<!--[!-->"),n(t),t.push("<!----> "),ch(t,{src:e.video.url,title:e.caption||null,is_stream:false,"data-testid":"thumbnail "+(l+1),alt:"",loading:"lazy",loop:false}),t.push("<!---->")),t.push("<!--]--></button>");}t.push("<!--]--></div></span>");}else t.push("<!--[!-->");t.push(`<!--]--> <div${attr_class("grid-wrap svelte-7anmrz",void 0,{minimal:I==="minimal","fixed-height":!b||b=="auto",hidden:r$1})}${attr_style("",{height:b!=="auto"?typeof b=="number"?b+"px":b:null})}>`),E&&p$1===null?(t.push("<!--[-->"),v(t,{i18n:_,onclear:()=>{m=[],y$2("upload"),$();},children:a=>{L&&P?(a.push("<!--[-->"),w(a,{Icon:h,label:_("upload_text.click_to_upload"),children:l=>{ee(l,{icon_upload:true,onload:i=>it(i),filetype:N,file_count:"multiple",max_file_size:Q,root:K,onerror:i=>tt(i),stream_handler:P,upload:L,get upload_promise(){return B},set upload_promise(i){B=i,w$1=false;},get uploading(){return M},set uploading(i){M=i,w$1=false;}});}})):a.push("<!--[!-->"),a.push("<!--]--> "),k$2.includes("webcam")?(a.push("<!--[-->"),w(a,{Icon:h$1,label:_("common.webcam"),onclick:()=>{y$2("webcam");}})):a.push("<!--[!-->"),a.push("<!--]--> "),k$2.includes("webcam-video")?(a.push("<!--[-->"),w(a,{Icon:r,label:_("common.video"),onclick:()=>{y$2("webcam-video");}})):a.push("<!--[!-->"),a.push("<!--]--> "),k$2.includes("clipboard")?(a.push("<!--[-->"),w(a,{label:_("upload_text.paste_clipboard"),onclick:()=>{y$2("clipboard");},Icon:e})):a.push("<!--[!-->"),a.push("<!--]-->");}})):t.push("<!--[!-->"),t.push(`<!--]--> <div${attr_class("grid-container svelte-7anmrz",void 0,{"pt-6":g})}${attr_style(`--grid-cols:${stringify(ut)}; --grid-rows:${stringify(R)}; --object-fit: ${stringify(C)};`)}><!--[-->`);const n$1=ensure_array_like(u);for(let a=0,l=n$1.length;a<l;a++){let i=n$1[a];t.push(`<div class="gallery-item svelte-7anmrz"><button${attr_class("thumbnail-item thumbnail-lg svelte-7anmrz",void 0,{selected:p$1===a})}${attr("aria-label","Thumbnail "+(a+1)+" of "+u.length)}>`),"image"in i?(t.push("<!--[-->"),c(t,{alt:i.caption||"",src:typeof i.image=="string"?i.image:i.image.url})):(t.push("<!--[!-->"),n(t),t.push("<!----> "),ch(t,{src:i.video.url,title:i.caption||null,is_stream:false,"data-testid":"thumbnail "+(a+1),alt:"",loading:"lazy",loop:false}),t.push("<!---->")),t.push("<!--]--> "),i.caption?(t.push("<!--[-->"),t.push(`<div class="caption-label svelte-7anmrz">${escape_html(i.caption)}</div>`)):t.push("<!--[!-->"),t.push("<!--]--></button> "),E?(t.push("<!--[-->"),t.push('<button class="delete-button svelte-7anmrz" aria-label="Delete image">'),o(t),t.push("<!----></button>")):t.push("<!--[!-->"),t.push("<!--]--></div>");}t.push("<!--]--></div></div></div>");}t.push("<!--]-->");}do w$1=true,x=c$1.copy(),et(x);while(!w$1);c$1.subsume(x),bind_props(d,{value:m,selected_index:p$1});});}const al=Object.freeze(Object.defineProperty({__proto__:null,default:xt},Symbol.toStringTag,{value:"Module"}));

export { xt as G, al as a, ll as h };
//# sourceMappingURL=Gallery-CCN3JI-P.js.map
