1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[30193],{284:(e,t,r)=>{let a;r.d(t,{rc:()=>F,ZD:()=>I,UC:()=>P,VY:()=>J,hJ:()=>E,ZL:()=>O,bL:()=>A,hE:()=>M,l9:()=>L});var i=r(12115),n=r(68599),s=r(47527),o=r(29483),l=r(70379),d=r(95155),u=Symbol("radix.slottable"),c="AlertDialog",[m,f]=(0,n.A)(c,[o.Hs]),p=(0,o.Hs)(),h=e=>{let{__scopeAlertDialog:t,...r}=e,a=p(t);return(0,d.jsx)(o.bL,{...a,...r,modal:!0})};h.displayName=c;var g=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,i=p(r);return(0,d.jsx)(o.l9,{...i,...a,ref:t})});g.displayName="AlertDialogTrigger";var v=e=>{let{__scopeAlertDialog:t,...r}=e,a=p(t);return(0,d.jsx)(o.ZL,{...a,...r})};v.displayName="AlertDialogPortal";var x=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,i=p(r);return(0,d.jsx)(o.hJ,{...i,...a,ref:t})});x.displayName="AlertDialogOverlay";var w="AlertDialogContent",[j,N]=m(w),y=((a=({children:e})=>(0,d.jsx)(d.Fragment,{children:e})).displayName="AlertDialogContent.Slottable",a.__radixId=u,a),b=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,children:a,...n}=e,u=p(r),c=i.useRef(null),m=(0,s.s)(t,c),f=i.useRef(null);return(0,d.jsx)(o.G$,{contentName:w,titleName:_,docsSlug:"alert-dialog",children:(0,d.jsx)(j,{scope:r,cancelRef:f,children:(0,d.jsxs)(o.UC,{role:"alertdialog",...u,...n,ref:m,onOpenAutoFocus:(0,l.mK)(n.onOpenAutoFocus,e=>{e.preventDefault(),f.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,d.jsx)(y,{children:a}),(0,d.jsx)($,{contentRef:c})]})})})});b.displayName=w;var _="AlertDialogTitle",R=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,i=p(r);return(0,d.jsx)(o.hE,{...i,...a,ref:t})});R.displayName=_;var S="AlertDialogDescription",U=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,i=p(r);return(0,d.jsx)(o.VY,{...i,...a,ref:t})});U.displayName=S;var C=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,i=p(r);return(0,d.jsx)(o.bm,{...i,...a,ref:t})});C.displayName="AlertDialogAction";var k="AlertDialogCancel",D=i.forwardRef((e,t)=>{let{__scopeAlertDialog:r,...a}=e,{cancelRef:i}=N(k,r),n=p(r),l=(0,s.s)(t,i);return(0,d.jsx)(o.bm,{...n,...a,ref:l})});D.displayName=k;var $=({contentRef:e})=>{let t=`\`${w}\` requires a description for the component to be accessible for screen reader users. 2 3You can add a description to the \`${w}\` by passing a \`${S}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 4 5Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${w}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. 6 7For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return i.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},A=h,L=g,O=v,E=x,P=b,F=C,I=D,M=R,J=U},20618:(e,t,r)=>{r.r(t),r.d(t,{default:()=>b});var a=r(95155),i=r(76684),n=r(83414),s=r(62909),o=r(59838),l=r(12115),d=r(58619),u=r(31691),c=r(14851),m=r(4474),f=r(79984),p=r(79792),h=r(39540),g=r(39658),v=r(66609),x=r(6296),w=r(6962),j=r(5872),N=r(81491),y=r(74350);let b=({credits_amount:e=1,locale:t="en"})=>{let[r,b]=(0,l.useState)(!1),[_,R]=(0,l.useState)(!1),[S,U]=(0,l.useState)(!1),[C,k]=(0,l.useState)("form"),[D,$]=(0,l.useState)("preview"),[A,L]=(0,l.useState)(""),[O,E]=(0,l.useState)(""),[P,F]=(0,l.useState)(!1),[I,M]=(0,l.useState)(!1),[J,T]=(0,l.useState)(null),[V,q]=(0,l.useState)(null),z=(0,l.useRef)(null),[B,W]=(0,l.useState)(null);(0,l.useEffect)(()=>{R(u.apiService.isLoggedInToApp(c.U.appName))},[]),(0,l.useEffect)(()=>{"json"===C&&E(JSON.stringify({model:"generate-music-cover",input:{task_id:A}},null,2))},[C,A]),(0,l.useEffect)(()=>()=>{Y()},[]);let Z=async()=>{let t;if(!_)return void b(!0);if("json"===C)try{if(t=JSON.parse(O),!t.input?.task_id)return void v.oR.error("task_id is required")}catch{v.oR.error("Invalid JSON");return}else{if(!A.trim())return void v.oR.error("task_id is required");t={model:"generate-music-cover",input:{task_id:A}}}try{if(F(!0),T(null),(await u.apiService.getUserInfo(c.U.appName)).data.credits_amount<e){U(!0),F(!1);return}let r=await d.v.submit(t.model,t.input);r.data?.task_id&&(v.oR.success("Generating cover..."),q(r.data.task_id),G(r.data.task_id))}catch(e){v.oR.error(e.message||"Failed")}finally{F(!1)}},G=e=>{M(!0);let t=async()=>{try{let t=await d.v.queryDetail(e);t.data&&(T(t.data),"finished"===t.data.status?(Y(),v.oR.success("Completed!")):"failed"===t.data.status&&(Y(),v.oR.error(t.data.error_message||"Failed")))}catch(e){console.error(e)}};t(),z.current=setInterval(t,5e3)},Y=()=>{z.current&&(clearInterval(z.current),z.current=null),M(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N.default,{app_name:c.U.appName,onLoginSuccess:()=>{b(!1),window.location.reload()},open:r,onOpenChange:b}),(0,a.jsx)(y.lG,{open:S,onOpenChange:U,children:(0,a.jsx)(y.Cf,{className:"sm:max-w-[425px]",children:(0,a.jsxs)("div",{className:"space-y-4 py-4",children:[(0,a.jsxs)("div",{className:"text-center space-y-2",children:[(0,a.jsx)(j.A,{className:"h-12 w-12 mx-auto text-orange-500"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Insufficient Credits"})]}),(0,a.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,a.jsx)(m.$,{variant:"outline",className:"flex-1",onClick:()=>U(!1),children:"Cancel"}),(0,a.jsx)(m.$,{className:"flex-1 bg-gradient-to-r from-orange-500 via-pink-500 to-rose-500",onClick:()=>window.open("/dashboard/billing","_blank"),children:"Recharge Now"})]})]})})}),(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"container mx-auto px-3 sm:px-4 py-4 sm:py-8 max-w-7xl",children:(0,a.jsxs)("div",{className:s.m.shell,children:[(0,a.jsx)(f.Zp,{className:s.m.panel,children:(0,a.jsx)(f.Wu,{className:s.m.content,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:s.m.header,children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:"Input"}),(0,a.jsxs)("div",{className:s.m.segmented,children:[(0,a.jsx)(m.$,{size:"sm",variant:"form"===C?"default":"ghost",onClick:()=>k("form"),className:"h-8",children:"Form"}),(0,a.jsx)(m.$,{size:"sm",variant:"json"===C?"default":"ghost",onClick:()=>k("json"),className:"h-8",children:"JSON"})]})]}),"json"===C?(0,a.jsx)(h.T,{value:O,onChange:e=>E(e.target.value),className:"min-h-[200px] font-mono text-sm",disabled:P||I}):(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(p.J,{className:"text-sm font-medium",children:"Task Id *"}),(0,a.jsx)(g.p,{placeholder:"From music generation",value:A,onChange:e=>L(e.target.value),disabled:P||I})]})})," ",(0,a.jsx)(i.Bn,{estimatedCredits:(0,o.O5)(e),onReset:()=>{k("form"),L(""),E("")},onRun:Z,disabled:P||I,resetDisabled:P||I,loading:P||I,loadingText:P?"Submitting...":I?"Processing...":"Running..."})]})})}),(0,a.jsx)(f.Zp,{className:s.m.panel,children:(0,a.jsx)(f.Wu,{className:s.m.content,children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:s.m.header,children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:"Output"}),(0,a.jsxs)("div",{className:s.m.segmented,children:[(0,a.jsx)(m.$,{size:"sm",variant:"preview"===D?"default":"ghost",onClick:()=>$("preview"),className:"h-8",children:"Preview"}),(0,a.jsx)(m.$,{size:"sm",variant:"json"===D?"default":"ghost",onClick:()=>$("json"),className:"h-8",children:"JSON"})]})]}),"json"===D?(0,a.jsx)(h.T,{value:JSON.stringify(J||{},null,2),readOnly:!0,className:"min-h-[500px] font-mono text-sm bg-muted"}
7):I&&(!J||"not_started"===J.status||"running"===J.status)?(0,a.jsx)(n.EV,{active:I,taskId:J?.task_id||V}):J?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(n.BP,{data:J}),(0,a.jsx)(n.V6,{message:J.error_message}),J.files?.map((e,t)=>(0,a.jsxs)("div",{className:"space-y-3 p-4 bg-background/50 rounded-lg",children:[e.image_url&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("img",{src:e.image_url,alt:"Music Cover",className:"w-full max-w-[300px] rounded-lg"}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(m.$,{variant:"outline",size:"sm",disabled:B===t,onClick:async()=>{try{W(t);let r=await fetch(`/api/download?url=${encodeURIComponent(e.image_url)}`),a=await r.blob(),i=URL.createObjectURL(a),n=document.createElement("a");n.href=i,n.download=`cover_${J.task_id}_${t}.png`,n.click(),URL.revokeObjectURL(i),v.oR.success("Downloaded!")}catch{v.oR.error("Download failed")}finally{W(null)}},children:B===t?(0,a.jsx)(x.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(w.A,{className:"h-4 w-4"})})})]}),e.audio_url&&(0,a.jsx)("audio",{controls:!0,src:e.audio_url,className:"w-full"})]},t))]}):(0,a.jsx)("div",{className:"w-full aspect-video bg-muted/30 rounded-lg border-2 border-dashed border-muted-foreground/20 flex items-center justify-center",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Cover image will appear here"})})]})})})]})})})]})}},58619:(e,t,r)=>{r.d(t,{v:()=>n});var a=r(31691),i=r(14851);let n={async submit(e,t){let r=await a.apiService.post("/api/generate/submit",{model:e,input:t},i.U.appName);if(200!==r.code&&0!==r.code)throw Error(r.message||r.detail||r.error?.message||"Submit failed");return r},async queryDetail(e){let t=await a.apiService.get(`/api/generate/detail/music?task_id=${e}`,i.U.appName);if(200!==t.code&&0!==t.code)throw Error(t.message||t.detail||t.error?.message||"Query failed");return t},async queryStatus(e){let t=await a.apiService.get(`/api/generate/status/${e}`,i.U.appName);if(200!==t.code&&0!==t.code)throw Error(t.message||t.detail||t.error?.message||"Query failed");return t}}},59838:(e,t,r)=>{r.d(t,{KI:()=>u,KW:()=>l,O5:()=>n,Pt:()=>x,Pz:()=>m,T0:()=>w,Vs:()=>p,X6:()=>s,Y3:()=>d,bi:()=>c,r2:()=>f});var a=r(66);function i(e,t=0){let r="number"==typeof e?e:"string"==typeof e&&""!==e.trim()?Number(e):NaN;return Number.isFinite(r)?r:t}function n(e){let t=Math.max(0,i(e,0));return Number.isInteger(t)?String(t):t.toFixed(2).replace(/\.?0+$/,"")}function s(e,t){return i(e,0)*i(t,0)}function o(e){return Math.round(1e6*i(e,0))}function l(e,t){return o(e)*o(t)/1e12}function d(e,t){return Math.ceil(l(e,t))}function u(e,t){return Math.ceil(i(e,0)/60)*i(t,0)}function c(e,t){return i(e,1)*i(t,0)}function m(e,t,r){return i(t[String(e??"").trim().toUpperCase()],r)}function f({width:e,height:t,duration:r,fps:a,scale:n,creditsPerOutputMegapixel:s}){let o=i(n,2),l=Math.ceil(i(r,5)*i(a,24));return i(e,1280)*i(t,720)*l*o*o/1e6*i(s,.1)}function p(e,t={}){let r=t.file;return r&&(0,a.E)(r)?Promise.resolve({width:r.width,height:r.height,duration:r.duration,fps:r.fps}):"u"<typeof document?Promise.resolve({}):new Promise(a=>{let i=document.createElement("video");i.preload="metadata",i.muted=!0,i.onloadedmetadata=async()=>{let n={width:i.videoWidth||void 0,height:i.videoHeight||void 0,duration:Number.isFinite(i.duration)?i.duration:void 0};i.removeAttribute("src"),i.load();let s=t.includeFps?await h(e,r):void 0;a({...n,fps:s})},i.onerror=()=>a({}),i.src=e})}async function h(e,t){if(t)try{return g(await t.arrayBuffer())}catch{return}if("u">typeof fetch)try{let t=await fetch(e);if(!t.ok)return;let r=Number(t.headers.get("content-length"));if(Number.isFinite(r)&&r>0x7800000)return;return g(await t.arrayBuffer())}catch{return}}function g(e){let t=new DataView(e),r=[],a=null,i=(e,n)=>{let s=e;for(;s+8<=n;){var o,l,d;let e=t.getUint32(s),u=v(t,s+4),c=8,m=e;if(1===e){if(s+16>n)break;o=t,l=s+8,m=0x100000000*o.getUint32(l)+o.getUint32(l+4),c=16}else 0===e&&(m=n-s);if(m<c||s+m>n)break;let f=s+c,p=s+m;if("trak"===u){let e=a,t={};a=t,i(f,p),r.push(t),a=e}
7else{(function(e,t,r,a,i){if(i){if("hdlr"===e&&r+12<=a){i.isVideo="vide"===v(t,r+8);return}if("mdhd"===e&&r+24<=a){let e=1===t.getUint8(r)?r+20:r+12;e+4<=a&&(i.timescale=t.getUint32(e));return}if("stts"===e&&r+8<=a){let e=r+4,n=t.getUint32(e);e+=4;let s=0,o=0;for(let r=0;r<n&&e+8<=a;r+=1){let r=t.getUint32(e),a=t.getUint32(e+4);s+=r,o+=r*a,e+=8}i.sampleCount=s,i.sampleDurationUnits=o}}})(u,t,f,p,a),("moov"===(d=u)||"mdia"===d||"minf"===d||"stbl"===d)&&i(f,p)}s=p}};for(let e of(i(0,t.byteLength),r)){if(!e.isVideo||!e.timescale||!e.sampleCount||!e.sampleDurationUnits)continue;let t=e.sampleDurationUnits/e.timescale,r=e.sampleCount/t;if(Number.isFinite(r)&&r>0)return r}}function v(e,t){return String.fromCharCode(e.getUint8(t),e.getUint8(t+1),e.getUint8(t+2),e.getUint8(t+3))}function x(e){return"u"<typeof document?Promise.resolve(void 0):new Promise(t=>{let r=document.createElement("audio");r.preload="metadata",r.onloadedmetadata=()=>{t(Number.isFinite(r.duration)?r.duration:void 0),r.src=""},r.onerror=()=>t(void 0),r.src=e})}function w(e,t){return t?.startsWith("audio/")?x(e):p(e).then(e=>e.duration)}},78152:(e,t,r)=>{r.d(t,{CG:()=>n,F7:()=>i,Lv:()=>s});let a={enableUtm:!0,enableReferrer:!0};function i(e){return e?e.source:function(e={}){let t,r,i={...a,...e};if(i.enableUtm){let e,t,r,a,i=(t=(e=new URLSearchParams(window.location.search)).get("utm_source"),r=e.get("utm_medium"),a=e.get("utm_campaign"),t?{source:t,utmSource:t,utmMedium:r||void 0,utmCampaign:a||void 0,detectionMethod:"utm"}:null);if(i)return i}let n=(r=(t=new URLSearchParams(window.location.search)).get("source")||t.get("ref"))?{source:r,detectionMethod:"query_param"}:null;if(n)return n;if(i.enableReferrer){let e=function(e){if("u"<typeof document||!document.referrer)return null;let t=document.referrer,r=new URL(t).hostname;if(e){for(let[a,i]of Object.entries(e))if(r.includes(a.toLowerCase()))return{source:i,rawReferrer:t,detectionMethod:"referrer"}}return r===window.location.hostname?null:{source:r,rawReferrer:t,detectionMethod:"referrer"}}(i.customDomainMapping);if(e)return e}return{source:"direct_visit",detectionMethod:"default"}}().source}function n(){try{if(document.referrer){let e=new URL(document.referrer);if(e.hostname===window.location.hostname)return`${e.pathname}${e.search}`}return`${window.location.pathname}${window.location.search}`}catch(e){console.error("Error detecting internal source:",e);return}}function s(){let e=new URLSearchParams(window.location.search);return{utm_source:e.get("utm_source")||void 0,utm_medium:e.get("utm_medium")||void 0,utm_campaign:e.get("utm_campaign")||void 0,registration_page:window.location.pathname}}},91760:(e,t,r)=>{r.d(t,{b:()=>l});var a=r(12115);r(47650);var i=r(42442),n=r(95155),s=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=(0,i.TL)(`Primitive.${t}`),s=a.forwardRef((e,a)=>{let{asChild:i,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(i?r:t,{...s,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),o=a.forwardRef((e,t)=>(0,n.jsx)(s.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));o.displayName="Label";var l=o}}]);
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.