import{B as e,Bt as t,Ct as n,D as r,F as i,L as a,N as o,Nt as s,Pt as c,R as l,U as u,Vt as d,W as f,X as p,Y as m,_t as h,a as g,at as _,ft as v,g as y,it as b,mt as x,o as S,ot as C,pt as w,u as T,v as E,vt as D,w as O,x as k,z as A}from"./xY0c-UfG.js";import"./xihTtKlq.js";import"./9K8VREGP.js";import{t as j}from"./qwr5boV8.js";import{t as M}from"./Dn3R8S-U.js";import{D as N,x as P}from"./CcwhSY5o.js";import{M as F,N as I}from"./CW-Ov0pM2.js";import{m as L}from"./CIfkrRcg2.js";import{t as R}from"./BLs1h0Rh.js";var z=e(`<title> </title>`),B=e(`<svg><!><path d="M12,10H6.78A11,11,0,0,1,27,16h2A13,13,0,0,0,6,7.68V4H4v8h8Z"></path><path d="M20,22h5.22A11,11,0,0,1,5,16H3a13,13,0,0,0,23,8.32V28h2V20H20Z"></path></svg>`);function V(e,n){let r=g(n,[`children`,`$$slots`,`$$events`,`$$legacy`]),l=g(r,[`size`,`title`]);c(n,!1);let u=h(),f=h(),x=S(n,`size`,8,16),w=S(n,`title`,8,void 0);b(()=>(m(r),m(w())),()=>{D(u,r[`aria-label`]||r[`aria-labelledby`]||w())}),b(()=>(p(u),m(r)),()=>{D(f,{"aria-hidden":p(u)?void 0:!0,role:p(u)?`img`:void 0,focusable:Number(r.tabindex)===0?!0:void 0})}),_(),T();var E=B();y(E,()=>({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,fill:`currentColor`,preserveAspectRatio:`xMidYMid meet`,width:x(),height:x(),...p(f),...l}));var O=v(E),k=e=>{var t=z(),n=v(t,!0);d(t),C(()=>i(n,w())),a(e,t)};o(O,e=>{w()&&e(k)}),t(2),d(E),a(e,E),s()}var H=A(`<div><span class="sg-attachment-chip-icon"><!></span> <span class="sg-attachment-chip-name"> </span> <span class="sg-attachment-chip-actions"><button class="sg-attachment-chip-btn" type="button"><!></button></span></div>`),U=A(`<img/>`),W=A(`<span class="sg-attachment-chip-overlay"><!></span>`),G=A(`<span class="sg-attachment-chip-sub"> </span>`),K=A(`<span class="sg-attachment-chip-sub"> </span>`),q=A(`<!><span>Saving…</span>`,1),J=A(`<!><span>Saved to library</span>`,1),Y=A(`<!><span>Save to library</span>`,1),ee=A(`<button type="button"><!></button>`),te=A(`<button class="sg-attachment-chip-close sg-attachment-chip-retry" aria-label="Retry upload" type="button"><!></button>`),ne=A(`<div><span><!> <!></span> <span class="sg-attachment-chip-body"><span class="sg-attachment-chip-name"> </span> <!></span> <!> <!> <button class="sg-attachment-chip-close" type="button"><!></button></div>`);function X(e,u){c(u,!0);let m=S(u,`status`,3,`ready`),h=S(u,`compact`,3,!1),g=S(u,`saveState`,3,`idle`),_=n(()=>!h()&&!!u.imageUrl);function y(e){let t=/\.([^.\s]+)\s*$/.exec(e);return t?t[1].toLowerCase():``}let b=n(()=>{let e=y(u.label);return e===`pdf`?{label:`PDF`,icon:I}:e===`csv`||e===`xls`||e===`xlsx`?{label:`Spreadsheet`,icon:F}:e===`md`||e===`markdown`?{label:`Markdown`,icon:L}:e===`txt`||e===`text`?{label:`Text`,icon:L}:{label:`Document`,icon:L}});var T=l(),D=w(T),A=e=>{var t=H();let n;var r=v(t);L(v(r),{size:14}),d(r);var o=x(r,2),s=v(o,!0);d(o),O(o,e=>P?.(e));var c=x(o,2),l=v(c);N(v(l),{size:14}),d(l),d(c),d(t),C(()=>{n=k(t,1,`sg-attachment-chip is-compact`,null,n,{"is-error":m()===`error`}),E(t,`title`,u.label),i(s,u.label),E(l,`aria-label`,`Remove ${u.label??``}`)}),f(`click`,l,function(...e){u.onremove?.apply(this,e)}),a(e,t)},z=e=>{var s=ne();let c;var h=v(s);let y;var S=v(h),T=e=>{var t=U();C(()=>{E(t,`src`,u.imageUrl),E(t,`alt`,u.label)}),a(e,t)},D=e=>{let t=n(()=>p(b).icon);var i=l();r(w(i),()=>p(t),(e,t)=>{t(e,{size:20})}),a(e,i)};o(S,e=>{p(_)?e(T):e(D,-1)});var A=x(S,2),F=e=>{var t=W();M(v(t),{size:16}),d(t),a(e,t)};o(A,e=>{m()===`uploading`&&e(F)}),d(h);var I=x(h,2),L=v(I),z=v(L,!0);d(L),O(L,e=>P?.(e));var B=x(L,2),H=e=>{var t=G(),n=v(t,!0);d(t),C(()=>i(n,u.sub)),a(e,t)},X=e=>{var t=K(),n=v(t,!0);d(t),C(()=>i(n,p(b).label)),a(e,t)};o(B,e=>{m()===`error`&&u.sub?e(H):p(_)||e(X,1)}),d(I);var Z=x(I,2),re=e=>{var n=ee();let r;var i=v(n),s=e=>{var n=q();M(w(n),{size:12}),t(),a(e,n)},c=e=>{var n=J();j(w(n),{size:12}),t(),a(e,n)},l=e=>{var n=Y();R(w(n),{size:12}),t(),a(e,n)};o(i,e=>{g()===`saving`?e(s):g()===`saved`?e(c,1):e(l,-1)}),d(n),C(()=>{r=k(n,1,`sg-attachment-chip-save`,null,r,{"is-saving":g()===`saving`,"is-saved":g()===`saved`}),n.disabled=g()===`saving`||g()===`saved`}),f(`click`,n,function(...e){u.onsave?.apply(this,e)}),a(e,n)};o(Z,e=>{u.onsave&&m()===`ready`&&e(re)});var Q=x(Z,2),ie=e=>{var t=te();V(v(t),{size:12}),d(t),f(`click`,t,function(...e){u.onretry?.apply(this,e)}),a(e,t)};o(Q,e=>{m()===`error`&&u.onretry&&e(ie)});var $=x(Q,2);N(v($),{size:12}),d($),d(s),C(()=>{c=k(s,1,`sg-attachment-chip`,null,c,{"is-error":m()===`error`}),E(s,`title`,u.label),y=k(h,1,`sg-attachment-chip-thumb`,null,y,{"is-doc":!p(_)}),i(z,u.label),E($,`aria-label`,`Remove ${u.label??``}`)}),f(`click`,$,function(...e){u.onremove?.apply(this,e)}),a(e,s)};o(D,e=>{h()?e(A):e(z,-1)}),a(e,T),s()}u([`click`]);export{X as t};