1import{c as I,r,ar as $,aJ as q,aK as F,j as e,X as T,M as Y,m as D,h as H,P as U,n as M,f as A,aL as K,aM as O,z as B}from"./index-Ck2k3YFA.js";import{S as J}from"./event-date-picker-BDTlK3Nl.js";const Q=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],X=I("link-2",Q);const G=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],te=I("palette",G);const V=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],se=I("star",V);const W=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],re=I("undo-2",W);function ae({value:o,onChange:x}){const[m,u]=r.useState(!1),[d,z]=r.useState(""),[b,f]=r.useState([]),[y,g]=r.useState([]),[v,h]=r.useState(!1),[k,c]=r.useState(null),[j,w]=r.useState(null),a=r.useRef(null),[n,S]=r.useState(null);r.useEffect(()=>{if(!m)return;const t=d.trim(),i=$(t);if(i){f([]),g([]);const P=new AbortController;return h(!0),S(null),q(i,P.signal).then(L=>S({parsed:i,meta:L})).finally(()=>h(!1)),()=>P.abort()}if(S(null),!t){f([]),g([]);return}const C=new AbortController,E=setTimeout(async()=>{h(!0);const P=fetch(`https://itunes.apple.com/search?term=${encodeURIComponent(t)}&media=music&entity=song&limit=15`,{signal:C.signal}).then(N=>N.json()).then(N=>{C.signal.aborted||f((N.results??[]).filter(R=>R.previewUrl))}).catch(()=>{}),L=F({data:{query:t}}).then(N=>{C.signal.aborted||g(N.connected?N.tracks:[])}).catch(()=>g([]));await Promise.all([P,L]),C.signal.aborted||h(!1)},350);return()=>{clearTimeout(E),C.abort()}},[d,m]),r.useEffect(()=>()=>{a.current?.pause()},[]);const s=t=>{if(k===t.trackId){a.current?.pause(),c(null);return}a.current?.pause();const i=new Audio(t.previewUrl);a.current=i,i.play().catch(()=>{}),i.onended=()=>c(null),c(t.trackId)},l=t=>{a.current?.pause(),c(null),x({song:t.trackName,song_artist:t.artistName,song_preview_url:t.previewUrl,song_artwork_url:t.artworkUrl100.replace("100x100","300x300"),track_length_ms:t.trackTimeMillis}),u(!1)},p=t=>{if(!t.previewUrl)return;if(j===t.id){a.current?.pause(),w(null);return}a.current?.pause(),c(null);const i=new Audio(t.previewUrl);a.current=i,i.play().catch(()=>{}),i.onended=()=>w(null),w(t.id)},_=t=>{a.current?.pause(),c(null),w(null),x({song:t.name,song_artist:t.artist,song_preview_url:t.externalUrl,song_artwork_url:t.artwork,track_length_ms:t.durationMs}),u(!1)};return o?e.jsxs("div",{className:"flex items-center gap-2 border border-foreground
1/15 rounded-lg px-2 py-1.5",children:[o.song_artwork_url&&e.jsx("img",{src:o.song_artwork_url,alt:"",className:"size-8 rounded object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.song}),e.jsx("p",{className:"text-[10px] text-foreground/60 truncate",children:o.song_artist})]}),e.jsx("button",{type:"button",onClick:()=>x(null),className:"size-6 grid place-items-center rounded-full hover:bg-foreground/10","aria-label":"Remove song",children:e.jsx(T,{className:"size-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>u(!0),className:"w-full flex items-center gap-2 border border-foreground/15 rounded-lg px-3 py-2 text-sm text-foreground/60 hover:border-foreground/40",children:[e.jsx(Y,{className:"size-3.5"}),"Pick a song (optional)"]}),m&&e.jsx("div",{className:"fixed inset-0 z-[60] bg-black/70 backdrop-blur-sm flex items-start justify-center p-4 pt-20",onClick:()=>{a.current?.pause(),c(null),u(!1)},children:e.jsxs("div",{className:"bg-background rounded-2xl max-w-lg w-full max-h-[70vh] flex flex-col overflow-hidden shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-foreground
1/10",children:[e.jsx(D,{className:"size-4 text-foreground/50"}),e.jsx("input",{autoFocus:!0,value:d,onChange:t=>z(t.target.value),placeholder:"Search or paste a YouTube / Spotify linkâ¦",className:"flex-1 bg-transparent text-sm outline-none"}),v&&e.jsx(H,{size:24}),e.jsx("button",{onClick:()=>{a.current?.pause(),c(null),u(!1)},className:"text-foreground/60 hover:text-foreground",children:e.jsx(T,{className:"size-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[!n&&b.length===0&&y.length===0&&!v&&e.jsxs("div",{className:"p-6 text-center text-xs text-foreground/50 space-y-2",children:[e.jsx("p",{children:d?"No results":"Search for a song to add"}),e.jsx("p",{className:"text-foreground/40",children:"Can't find it? Paste a YouTube or Spotify link here to use any song."})]}),y.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"px-4 pt-3 pb-1 text-[10px] font-semibold uppercase tracking-wide text-foreground/40",children:"From your Spotify"}),y.map(t=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-foreground
1/5",children:[e.jsxs("button",{type:"button",onClick:()=>p(t),className:"relative size-10 rounded overflow-hidden shrink-0 bg-foreground/10 group",children:[t.artwork&&e.jsx("img",{src:t.artwork,alt:"",className:"w-full h-full object-cover"}),t.previewUrl&&e.jsx("span",{className:"absolute inset-0 bg-black/40 grid place-items-center opacity-0 group-hover:opacity-100 transition-opacity",children:j===t.id?e.jsx(U,{className:"size-4 text-white"}):e.jsx(M,{className:"size-4 text-white"})}),e.jsx("span",{className:"absolute bottom-0 right-0 text-[8px] font-bold uppercase px-1 rounded-tl bg-[#1DB954] text-black",children:"SP"})]}),e.jsxs("button",{type:"button",onClick:()=>_(t),className:"flex-1 min-w-0 text-left",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("p",{className:"text-xs text-foreground/60 truncate",children:t.artist})]})]},t.id)),b.length>0&&e.jsx("p",{className:"px-4 pt-3 pb-1 text-[10px] font-semibold uppercase tracking-wide text-foreground/40",children:"More results"})]}),n&&e.jsxs("button",{type:"button",onClick:()=>{a.current?.pause(),c(null),x({song:n.meta.title,song_artist:n.meta.author,song_preview_url:n.parsed.canonicalUrl,song_artwork_url:n.meta.thumbnail}),u(!1)},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-foreground
1/5 text-left border-b border-foreground/10",children:[e.jsxs("div",{className:"relative size-12 rounded overflow-hidden shrink-0 bg-foreground/10 grid place-items-center",children:[n.meta.thumbnail?e.jsx("img",{src:n.meta.thumbnail,alt:"",className:"w-full h-full object-cover"}):e.jsx(X,{className:"size-5 text-foreground/60"}),e.jsx("span",{className:"absolute bottom-0 right-0 text-[8px] font-bold uppercase px-1 rounded-tl bg-black/70 text-white",children:n.parsed.kind==="youtube"?"YT":"SP"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:n.meta.title}),e.jsx("p",{className:"text-xs text-foreground/60 truncate",children:n.meta.author}),e.jsxs("p",{className:"text-[10px] text-foreground/40 mt-0.5",children:["Use this ",n.parsed.kind==="youtube"?"YouTube":"Spotify"," link"]})]})]}),b.map(t=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-foreground/5",children:[e.jsxs("button",{type:"button",onClick:()=>s(t),className:"relative size-10 rounded overflow-hidden shrink-0 group",children:[e.jsx("img",{src:t.artworkUrl100,alt:"",className:"w-full h-full object-cover"}),e.jsx("span",{className:"absolute inset-0 bg-black/40 grid place-items-center opacity-0 group-hover:opacity-100 transition-opacity",children:k===t.trackId?e.jsx(U,{className:"size-4 text-white"}):e.jsx(M,{className:"size-4 text-white"})}),k===t.trackId&&e.jsx("span",{className:"absolute inset-0 bg-black/40 grid place-items-center",children:e.jsx(U,{className:"size-4 text-white"})})]}),e.jsxs("button",{type:"button",onClick:()=>l(t),className:"flex-1 min-w-0 text-left",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.trackName}),e.jsx("p",{className:"text-xs text-foreground/60 truncate",children:t.artistName})]})]},t.trackId))]})]})})]})}function ne({value:o,onChange:x,suggestContext:m,tone:u="light"}){const[d,z]=r.useState(""),[b,f]=r.useState([]),[y,g]=r.useState([]),[v,h]=r.useState(!1),k=A(K),c=A(O);r.useEffect(()=>{const s=d.trim();if(s.length<1){f([]);return}let l=!0;const p=setTimeout(async()=>{try{const _=await k({data:{q:s,limit:6}});l&&f(_.topics)}catch{}},220);return()=>{l=!1,clearTimeout(p)}},[d,k]);const j=s=>{const l=s.replace(/#/g,"").trim();l&&(o.some(p=>p.toLowerCase()===l.toLowerCase())||(x([...o,l].slice(0,12)),z(""),f([]),g(p=>p.filter(_=>_.toLowerCase()!==l.toLowerCase()))))},w=s=>x(o.filter(l=>l!==s)),a=async()=>{if(m){h(!0);try{const s=await c({data:m});g((s.topics??[]).filter(l=>!o.some(p=>p.toLowerCase()===l.toLowerCase())))}catch{}finally{h(!1)}}},n=u==="glass"?"border-white/50 bg-white/50 text-foreground":"border-black/10 bg-black/[0.04] text-foreground",S=u==="glass"?"border-white/60 bg-white/55 backdrop-blur-xl":"border-black/10 bg-white";return e.jsxs("div",{className:"space-y-2",children:[o.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(s=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium ${n}`,children:["#",s.replace(/\s+/g,""),e.jsx("button",{type:"button",onClick:()=>w(s),"aria-label":`Remove ${s}`,children:e.jsx(T,{className:"size-3 opacity-50 hover:opacity-100"})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:`flex items-center gap-2 rounded-xl border px-3 py-2 ${S}`,children:[e.jsx(B,{className:"size-3.5 shrink-0 opacity-45"}),e.jsx("input",{value:d,onChange:s=>z(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),j(d))},placeholder:"Add topic",className:"min-w-0 flex-1 bg-transparent text-[13px] outline-none placeholder:opacity-45"}),m&&e.jsxs("button",{type:"button",onClick:a,disabled:v,className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-white/50 bg-white/60 px-2.5 py-1 text-[10px] font-medium backdrop-blur disabled:opacity-50",children:[e.jsx(J,{className:"size-3"}),v?"Thinkingâ¦":"Suggest"]})]}),b.length>0&&e.jsx("div",{className:"absolute left-0 right-0 top-full z-30 mt-1.5 overflow-hidden rounded-xl border border-white/60 bg-white/85 p-1 shadow-xl backdrop-blur-2xl",children:b.map(s=>e.jsxs("button",{type:"button",onClick:()=>j(s.name),className:"flex w-full items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-left text-[12px] hover:bg-black/5",children:[e.jsx("span",{className:"truncate",children:s.name}),e.jsx("span",{className:"shrink-0 text-[10px] opacity-45",children:s.post_count})]},s.id))})]}),y.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em] opacity-45",children:"Suggested"}),y.map(s=>e.jsxs("button",{type:"button",onClick:()=>j(s),className:"rounded-full border border-dashed border-black/20 px-2.5 py-1 text-[11px] opacity-80 hover:opacity-100",children:["+ ",s]},s))]})]})}export{te as P,ae as S,ne as T,re as U,se as a};
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.