PageSourceSearch

https://music-prod.com/assets/SampleSortSelect-BAW8WFid.js

js music-prod.com collected 2026-09-29 12:35:42 UTC 17,323 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-REUEbryQ.js";import{r as a,u as s}from"./vendor-react-tIoPkRwd.js";import{W as r}from"./WaveformPlayer-BILB8t2N.js";import{M as t}from"./MidiPlayer-BAzGOMZY.js";import{s as n,D as i,a as l,b as o,c as d,d as c,f as m,B as u,L as p,u as x,e as h,C as f}from"./index--0ud_HHy.js";import{T as g}from"./textarea-C1OSlJeR.js";import{S as j}from"./slider-dzwntY2e.js";import{P as b}from"./progress-CX25eQo1.js";import{F as y}from"./vendor-supabase-BcbvpzCe.js";import{o as w}from"./polarEmbed-Bz_n0YBj.js";import{S as v}from"./sparkles-B8pZP29O.js";import{P as N}from"./pause-BKIWcS-8.js";import{P as k}from"./play-y5bldSkr.js";import{D as C}from"./download-yNQ0nzkl.js";import{S as M}from"./shopping-cart-BZMjCg_4.js";import{g as U}from"./imageUtils-BNh51NXU.js";import{u as S}from"./use-mobile-B4hqzuWL.js";import{D as P}from"./constants-DPfX1E16.js";import{C as I}from"./clock-Bhs4QKh8.js";import{S as $,a as D,b as E,c as A,d as L}from"./select-C_YCD5Vd.js";import{A as G}from"./arrow-up-down-BP799NbT.js";const T=[{id:"subtle",label:"Subtle",desc:"Close to original"},{id:"balanced",label:"Balanced",desc:"Similar but new"},{id:"creative",label:"Creative",desc:"Fresh take"}];function q(e){if(!e)return{sampleType:"loop",length:8};const a=(e.category||"").toLowerCase(),s=a.includes("one shot")||a.includes("one-shot")||"oneshot"===a,r=Math.round(e.duration||0);return{sampleType:s?"one-shot":"loop",length:Math.min(10,Math.max(1,r||(s?2:8)))}}function F({sample:s,open:r,onOpenChange:t}){const h=q(s),[f,U]=a.useState("balanced"),[S,P]=a.useState(h.sampleType),[I,$]=a.useState(h.length),[D,E]=a.useState(""),[A,L]=a.useState(!1),[G,F]=a.useState([]),[O,z]=a.useState(null),[B,R]=a.useState(!1),[_,K]=a.useState(0),[V,W]=a.useState(null),[Y,H]=a.useState(!1),J=a.useRef(new Map),X=a.useRef(null),Z=a.useCallback(async()=>{try{const{data:e}=await n.functions.invoke("make-unique-sample",{body:{action:"usage"}});e&&"object"==typeof e&&"dailyUsed"in e&&W(e)}catch{}},[]);a.useEffect(()=>{r&&Z()},[r,Z]);const Q=async()=>{if(!Y){H(!0);try{const{data:e,error:a}=await n.functions.invoke("polar-auth/buy-make-unique-credits",{body:{}});if(a)throw a;const s=null==e?void 0:e.url;if(!s)throw new Error("Could not start checkout");await w(s,"dark"),setTimeout(Z,4e3)}catch(e){x.error((null==e?void 0:e.message)||"Could not start checkout")}finally{H(!1)}}},ee=a.useCallback(()=>{var e;J.current.forEach(e=>e.pause()),null==(e=X.current)||e.pause(),z(null),R(!1)},[]);a.useEffect(()=>{r||(ee(),J.current.clear(),X.current=null,F([]),U("balanced"),E(""),K(0))},[r,ee]),a.useEffect(()=>{if(!r||!s)return;const e=q(s);P(e.sampleType),$(e.length)},[r,s]),a.useEffect(()=>{if(!A)return void K(0);K(0);const e=setInterval(()=>K(e=>e+1),1e3);return()=>clearInterval(e)},[A]);const ae=async e=>{const{data:a,error:s}=await n.functions.invoke("make-unique-sample",{body:e});if(s){if(s instanceof y){const e=await s.context.json().catch(()=>null);throw new Error((null==e?void 0:e.error)||s.message||"Generation failed")}throw new Error(s.message||"Generation failed")}if(null==a?void 0:a.error)throw new Error(a.error);return a},se=async()=>{if(!s||A)return;L(!0);const e=f;try{const a=await ae({sampleId:s.id,category:s.category,name:s.name,tags:s.tags,bpm:s.bpm,key:s.key,variation:e,sampleType:S,length:Math.min(10,Math.max(1,Math.round(I))),description:D.trim().slice(0,500)}),r=null==a?void 0:a.predictionId;if(!r)throw new Error("Could not start generation");const t=Date.now(),n=18e4;for(;Date.now()-t<n;){await new Promise(e=>setTimeout(e,3e3));const a=await ae({action:"status",predictionId:r});if("succeeded"===a.status&&a.audioUrl)return F(s=>[...s,{id:r,url:a.audioUrl,variation:e,createdAt:Date.now()}]),void x.success("Unique sample ready");if("failed"===a.status||"canceled"===a.status)throw new Error(a.error||"Generation failed")}throw new Error("Generation timed out, please try again")}catch(a){x.error((null==a?void 0:a.message)||"Generation failed")}finally{L(!1),Z()}};return e.jsx(i,{open:r,onOpenChange:t,children:e.jsxs(l,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[e.jsxs(o,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-primary"}),"Make unique"]}),e.jsx(c,{children:"Generate a one-of-a-kind variation of this sample with AI."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Variation"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:T.map(a=>e.jsxs("button",{onClick:()=>U(a.id),disabled:A,className:m("rounded-xl border p-3 text-left transition-all",f===a.id?"border-primary bg-primary/10":"border-border hover:border-primary/50"),children:[e.jsx("p",{className:"text-sm font-medium",children:a.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.desc})]},a.id))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:["loop","one-shot"].map(a=>e.jsx("button",{onClick:()=>P(a),disabled:A,className:m("rounded-xl border p-3 text-sm font-medium capitalize transition-all",S===a?"border-primary bg-primary/10":"border-border hover:border-primary/50"),children:a},a))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Length"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[I,"s"]})]}),e.jsx(j,{value:[I],min:1,max:10,step:1,disabled:A,onValueChange:e=>$(e[0])})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:["Describe your variation ",e.jsx("span",{className:"normal-case text-muted-foreground
1/70",children:"(optional)"})]}),e.jsx(g,{value:D,onChange:e=>E(e.target.value.slice(0,500)),disabled:A,placeholder:"e.g. dark trap loop, distorted, for a moody hip-hop beat",className:"min-h-20 resize-none",maxLength:500}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-right",children:[D.length,"/500"]})]}),(G.length>0||A)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:G.length>0?`Generations (${G.length})`:"Original"}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-secondary/30 border border-border",children:[e.jsx("button",{onClick:()=>{const e=(null==s?void 0:s.previewUrl)||(null==s?void 0:s.audioUrl);e&&(X.current||(X.current=new Audio(e),X.current.onended=()=>R(!1)),B?(X.current.pause(),R(!1)):(J.current.forEach(e=>e.pause()),z(null),X.current.play(),R(!0)))},className:"w-10 h-10 flex items-center justify-center rounded-full bg-secondary text-foreground hover:opacity-90",children:B?e.jsx(N,{className:"w-4 h-4"}):e.jsx(k,{className:"w-4 h-4 ml-0.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:null==s?void 0:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Original"})]})]}),G.map((a,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-primary/5 border border-primary/30",children:[e.jsx("button",{onClick:()=>(e=>{var a;let s=J.current.get(e.id);s||(s=new Audio(e.url),s.onended=()=>z(a=>a===e.id?null:a),J.current.set(e.id,s)),O===e.id?(s.pause(),z(null)):(J.current.forEach((a,s)=>{s!==e.id&&a.pause()}),null==(a=X.current)||a.pause(),R(!1),s.play(),z(e.id))})(a),className:"w-10 h-10 flex items-center justify-center rounded-full bg-primary text-primary-foreground hover:opacity-90",children:O===a.id?e.jsx(N,{className:"w-4 h-4"}):e.jsx(k,{className:"w-4 h-4 ml-0.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate flex items-center gap-1.5",children:[e.jsx(v,{className:"w-3 h-3 text-primary"}),null==s?void 0:s.name,"-unique-",r+1]}),e.jsxs("p",{className:"text-xs text-muted-foreground capitalize",children:[a.variation," · AI generated"]})]}),e.jsx(u,{size:"icon",variant:"ghost",onClick:()=>(async e=>{if(s)try{const a=await fetch(e.url),r=await a.blob(),t=URL.createObjectURL(r),n=document.createElement("a");n.href=t;const i=G.findIndex(a=>a.id===e.id)+1;n.download=`${s.name}-unique-${i}.wav`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch{x.error("Download failed")}})(a),className:"rounded-full",children:e.jsx(C,{className:"w-4 h-4"})})]},a.id)),A&&e.jsxs("div",{className:"p-3 rounded-xl border border-dashed border-primary/30 bg-primary/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-primary",children:[e.jsx(p,{className:"w-3 h-3 animate-spin"}),"Generating variation ",G.length+1,"…"]}),e.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[_,"s / ~",90,"s"]})]}),e.jsx(b,{value:Math.min(99,_/90*100),className:"h-1.5"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:_>90?"Taking a bit longer than usual. Hang tight…":"This usually takes 60–90 seconds. Keep this dialog open."})]})]}),(()=>{const a=V?Math.max(0,V.dailyLimit-V.dailyUsed):null,s=V?Math.max(0,V.monthlyLimit-V.monthlyUsed):null,r=null!==a&&null!==s?Math.min(a,s):null,t=(null==V?void 0:V.creditBalance)??0,n=(r??0)+t,i=null!==V&&n<=0,l=null!==V&&n<=1;return e.jsxs(e.Fragment,{children:[e.jsx(u,{onClick:se,disabled:A||i,className:"w-full rounded-full",size:"lg",children:A?e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"w-4 h-4 mr-2 animate-spin"})," Generating… ",_,"s"]}):i?e.jsx(e.Fragment,{children:"Out of generations"}):e.jsxs(e.Fragment,{children:[e.jsx(v,{className:"w-4 h-4 mr-2"})," ",G.length>0?"Generate another":"Generate"]})}),l&&!A&&e.jsxs("div",{className:"rounded-xl border border-primary/30 bg-primary/5 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:i?"You’re out of generations":"Only 1 generation left"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Buy 20 more generations for $10. Stack as many packs as you want."})]}),e.jsx(u,{onClick:Q,disabled:Y,variant:"default",size:"sm",className:"w-full rounded-full",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"w-4 h-4 mr-2 animate-spin"})," Opening checkout…"]}):e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4 mr-2"})," Buy 20 generations for $10"]})})]}),!A&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:V?`${r??0} of ${V.dailyLimit} today · ${s??0} of ${V.monthlyLimit} this month${t>0?` · ${t} purchased`:""}`:"10 generations per day · 30 per month"})]})})()]})})}const O=({sample:s})=>{var r;const[t,n]=a.useState(!1),i=(null==(r=s.categories)?void 0:r.length)?s.categories:[s.category],l=i[0],o=i.slice(1);return e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"tag-pill-primary whitespace-nowrap",children:l}),o.length>0&&!t&&e.jsxs("button",{onClick:e=>{e.stopPropagation(),n(!0)},className:"tag-pill-primary whitespace-nowrap cursor-pointer hover:bg-accent/80 transition-colors",children:["+",o.length]}),t&&o.map(a=>e.jsx("span",{className:"tag-pill-primary whitespace-nowrap",children:a},a)),s.isMidi&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold whitespace-nowrap bg-accent text-accent-foreground",children:"MIDI"})]})},z=a.memo(({sample:n,isPlaying:i,onPlay:l,isSubscribed:o,isAdmin:d=!1,isLiteUser:c=!1,onDownload:u,isDownloaded:p=!1})=>{const x=U(n.packCoverUrl,96)||P,g=S(),j=s(),{openSubscriptionModal:b}=h(),[y,w]=a.useState(!1),M=!n.isMidi,$=o||d,D=e=>{e.stopPropagation(),n.packId&&j(`/pack/${n.packId}`)};return e.jsxs("div",{className:"flex flex-col animate-in fade-in slide-in-from-bottom-1 duration-200","data-sample-id":n.id,children:[e.jsxs("div",{className:m("group flex items-center gap-2 sm:gap-4 p-2 sm:p-3 transition-all duration-200 md:grid md:grid-cols-[3rem_minmax(0,12rem)_8rem_minmax(0,1fr)_max-content_max-content] md:gap-3 md:items-center","bg-card hover:bg-secondary/50",i&&"bg-secondary"),children:[e.jsx("div",{className:"flex-shrink-0",onClick:D,children:e.jsx("img",{src:x,alt:n.packName,className:m("w-10 h-10 sm:w-12 sm:h-12 rounded object-cover",n.packId&&"cursor-pointer hover:opacity-80 transition-opacity")})}),e.jsxs("div",{className:"flex-1 min-w-0 md:w-auto md:flex-none",children:[e.jsx("h3",{className:"font-medium text-sm text-foreground truncate font-sans",children:n.name}),e.jsx("p",{onClick:D,className:m("text-xs text-muted-foreground truncate",n.packId&&"cursor-pointer hover:text-foreground transition-colors"),children:n.packName})]}),e.jsx(O,{sample:n}),!g&&e.jsx("div",{className:"hidden md:block min-w-0",children:n.isMidi?e.jsx(t,{midiUrl:n.previewUrl,isActive:i,onPlay:l,compact:!0,defaultInstrument:n.midiInstrument}):e.jsx(r,{audioUrl:n.previewUrl,fallbackAudioUrls:[n.audioUrl,n.downloadUrl],isActive:i,onPlay:l,compact:!0,sampleName:n.name,peaks:n.waveformData,duration:n.duration})}),e.jsxs("div",{className:"flex-shrink-0 hidden sm:flex items-center gap-4 text-xs text-muted-foreground",children:[n.bpm?e.jsxs("span",{className:"hidden lg:inline",children:[n.bpm," BPM"]}):null,n.key?e.jsx("span",{className:"hidden lg:inline",children:n.key}):null,e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{className:"w-3 h-3"}),n.duration>=60?`${Math.floor(n.duration/60)}:${Math.floor(n.duration%60).toString().padStart(2,"0")}`:`${n.duration.toFixed(1)}s`]})]}),e.jsx("button",{onClick:e=>{e.stopPropagation(),l()},className:m("md:hidden flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center transition-all","bg-primary/10 text-primary hover:bg-primary/20 active:scale-95",i&&"bg-primary text-primary-foreground"),children:i?e.jsx(N,{className:"w-4 h-4"}):e.jsx(k,{className:"w-4 h-4 ml-0.5"})}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[M&&e.jsxs("button",{onClick:e=>{e.stopPropagation(),$?w(!0):b()},title:"Make a unique variation with AI",className:m("flex-shrink-0 flex items-center justify-center gap-1.5 w-10 h-10 sm:w-auto 
1sm:h-auto sm:px-3 sm:py-2 text-xs font-medium rounded-full sm:rounded transition-all",$?"bg-primary/10 text-primary hover:bg-primary/20":"bg-accent text-accent-foreground hover:bg-accent/80"),children:[e.jsx(v,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}),e.jsx("span",{className:"hidden lg:inline",children:"Make unique"})]}),o||c?e.jsxs("button",{onClick:e=>{e.stopPropagation(),u()},className:m("flex-shrink-0 flex items-center justify-center gap-1.5 w-10 h-10 sm:w-auto sm:h-auto sm:px-3 sm:py-2 text-xs font-medium rounded-full sm:rounded transition-all",p?"bg-success/20 text-success hover:bg-success/30":"bg-primary text-primary-foreground hover:bg-primary/90"),children:[p?e.jsx(f,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}):e.jsx(C,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Downloaded":"Download"})]}):e.jsxs("button",{onClick:e=>{e.stopPropagation(),b()},className:"flex-shrink-0 flex items-center justify-center gap-1.5 w-10 h-10 sm:w-auto sm:h-auto sm:px-3 sm:py-2 text-xs font-medium rounded-full sm:rounded transition-all bg-accent text-accent-foreground hover:bg-accent/80",children:[e.jsx(C,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Get Access"})]})]})]}),e.jsx(F,{sample:y?n:null,open:y,onOpenChange:w}),g&&i&&e.jsx("div",{className:"overflow-hidden bg-secondary/50 border-t border-border animate-in fade-in slide-in-from-top-1 duration-200",children:e.jsxs("div",{className:"p-3",children:[n.isMidi?e.jsx(t,{midiUrl:n.previewUrl,isActive:i,onPlay:l,compact:!1,defaultInstrument:n.midiInstrument}):e.jsx(r,{audioUrl:n.previewUrl,fallbackAudioUrls:[n.audioUrl,n.downloadUrl],isActive:i,onPlay:l,compact:!1,sampleName:n.name,peaks:n.waveformData,duration:n.duration}),e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-2 text-xs text-muted-foreground",children:[n.bpm?e.jsxs("span",{children:[n.bpm," BPM"]}):null,n.key?e.jsx("span",{children:n.key}):null,e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(I,{className:"w-3 h-3"}),n.duration>=60?`${Math.floor(n.duration/60)}:${Math.floor(n.duration%60).toString().padStart(2,"0")}`:`${n.duration.toFixed(1)}s`]})]})]})})]})});z.displayName="SampleRow";const B=[{value:"random",label:"Random"},{value:"newest",label:"Newest"},{value:"name",label:"Name"},{value:"bpm",label:"BPM"},{value:"duration",label:"Duration"},{value:"key",label:"Key"},{value:"downloads",label:"Most Downloaded"}];function R({value:a,onChange:s}){return e.jsxs($,{value:a,onValueChange:e=>s(e),children:[e.jsxs(D,{className:"w-[160px] h-9 text-sm bg-card border-border",children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1.5 text-muted-foreground"}),e.jsx(E,{})]}),e.jsx(A,{className:"bg-popover border-border z-50",children:B.map(a=>e.jsx(L,{value:a.value,children:a.label},a.value))})]})}export{R as S,z 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.